An emulator, assembler, and disassembler for the Sega Game Gear
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 

61 řádky
1.2 KiB

  1. /* Copyright (C) 2014-2015 Ben Kurtovic <ben.kurtovic@gmail.com>
  2. Released under the terms of the MIT License. See LICENSE for details. */
  3. #include <stdlib.h>
  4. #include "gamegear.h"
  5. #include "logging.h"
  6. /*
  7. Create and return a pointer to a new GameGear object.
  8. If memory could not be allocated, OUT_OF_MEMORY() is triggered.
  9. */
  10. GameGear* gamegear_create()
  11. {
  12. GameGear *gg = malloc(sizeof(GameGear));
  13. if (!gg)
  14. OUT_OF_MEMORY()
  15. gg->rom = NULL;
  16. return gg;
  17. }
  18. /*
  19. Destroy a previously-allocated GameGear object.
  20. Does *not* destroy any loaded ROM objects.
  21. */
  22. void gamegear_destroy(GameGear *gg)
  23. {
  24. free(gg);
  25. }
  26. /*
  27. Load a ROM image into the GameGear object.
  28. Does *not* steal the reference to the ROM object.
  29. */
  30. void gamegear_load(GameGear *gg, ROM *rom)
  31. {
  32. gg->rom = rom;
  33. }
  34. /*
  35. Set the GameGear object's power state (true = on; false = off).
  36. Powering on the GameGear executes boot code (e.g. clearing memory and
  37. setting initial register values) and starts the clock. Powering it off
  38. stops the clock.
  39. Setting the power state to its current value has no effect.
  40. */
  41. void gamegear_power(GameGear *gg, bool state)
  42. {
  43. if (gg->state == state)
  44. return;
  45. // TODO
  46. gg->state = state;
  47. }