An emulator, assembler, and disassembler for the Sega Game Gear
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

69 lines
1.6 KiB

  1. /* Copyright (C) 2014-2017 Ben Kurtovic <ben.kurtovic@gmail.com>
  2. Released under the terms of the MIT License. See LICENSE for details. */
  3. #pragma once
  4. #include <stdbool.h>
  5. #include <stdint.h>
  6. #include "io.h"
  7. #include "mmu.h"
  8. #include "psg.h"
  9. #include "rom.h"
  10. #include "save.h"
  11. #include "z80.h"
  12. #define GG_SCREEN_WIDTH 160
  13. #define GG_SCREEN_HEIGHT 144
  14. #define GG_PIXEL_WIDTH 8
  15. #define GG_PIXEL_HEIGHT 7
  16. #define GG_LOGICAL_WIDTH (GG_SCREEN_WIDTH * GG_PIXEL_WIDTH)
  17. #define GG_LOGICAL_HEIGHT (GG_SCREEN_HEIGHT * GG_PIXEL_HEIGHT)
  18. #define GG_FPS 60
  19. #define GG_EXC_BUFF_SIZE 128
  20. /* Structs, etc. */
  21. struct GameGear;
  22. typedef void (*GGFrameCallback)(struct GameGear*);
  23. typedef struct GameGear {
  24. Z80 cpu;
  25. MMU mmu;
  26. VDP vdp;
  27. PSG psg;
  28. IO io;
  29. bool powered;
  30. GGFrameCallback callback;
  31. char exc_buffer[GG_EXC_BUFF_SIZE];
  32. } GameGear;
  33. typedef enum {
  34. BUTTON_UP = 0,
  35. BUTTON_DOWN = 1,
  36. BUTTON_LEFT = 2,
  37. BUTTON_RIGHT = 3,
  38. BUTTON_TRIGGER_1 = 4,
  39. BUTTON_TRIGGER_2 = 5,
  40. BUTTON_START
  41. } GGButton;
  42. /* Functions */
  43. GameGear* gamegear_create();
  44. void gamegear_destroy(GameGear*);
  45. void gamegear_load_rom(GameGear*, const ROM*);
  46. void gamegear_load_bios(GameGear*, const BIOS*);
  47. void gamegear_load_save(GameGear*, Save*);
  48. void gamegear_simulate(GameGear*);
  49. void gamegear_input(GameGear*, GGButton, bool);
  50. void gamegear_power_off(GameGear*);
  51. void gamegear_attach_callback(GameGear*, GGFrameCallback);
  52. void gamegear_attach_display(GameGear*, uint32_t*);
  53. void gamegear_detach(GameGear*);
  54. const char* gamegear_get_exception(GameGear*);
  55. void gamegear_print_state(const GameGear*);