An emulator, assembler, and disassembler for the Sega Game Gear
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

emulator.c 1.1 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* Copyright (C) 2014-2016 Ben Kurtovic <ben.kurtovic@gmail.com>
  2. Released under the terms of the MIT License. See LICENSE for details. */
  3. #include <signal.h>
  4. #include "emulator.h"
  5. #include "logging.h"
  6. static GameGear *global_gg;
  7. /*
  8. Signal handler for SIGINT.
  9. */
  10. static void handle_sigint(int sig)
  11. {
  12. (void) sig;
  13. if (global_gg)
  14. gamegear_power_off(global_gg);
  15. }
  16. /*
  17. GameGear callback: handle SDL logic at the end of a frame.
  18. */
  19. static void draw_frame(GameGear *gg)
  20. {
  21. (void) gg;
  22. // TODO: SDL draw / switch buffers here
  23. }
  24. /*
  25. Emulate a Game Gear. Handle I/O with the host computer.
  26. Block until emulation is finished.
  27. */
  28. void emulate(GameGear *gg)
  29. {
  30. global_gg = gg;
  31. signal(SIGINT, handle_sigint);
  32. gamegear_set_callback(gg, draw_frame);
  33. gamegear_simulate(gg);
  34. if (gamegear_get_exception(gg))
  35. ERROR("caught exception: %s", gamegear_get_exception(gg))
  36. else
  37. WARN("caught signal, stopping...")
  38. if (DEBUG_LEVEL)
  39. gamegear_print_state(gg);
  40. gamegear_clear_callback(gg);
  41. signal(SIGINT, SIG_DFL);
  42. global_gg = NULL;
  43. }