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.
 
 
 
 
 

59 lignes
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 <signal.h>
  4. #include <stdbool.h>
  5. #include <unistd.h>
  6. #include "iomanager.h"
  7. #include "logging.h"
  8. static volatile bool caught_signal;
  9. /*
  10. Signal handler for SIGINT.
  11. */
  12. static void handle_sigint(int sig)
  13. {
  14. (void) sig; // We don't care
  15. caught_signal = true;
  16. }
  17. /*
  18. Emulate a Game Gear. Handle I/O with the host computer.
  19. Block until emulation is finished.
  20. */
  21. void iomanager_emulate(GameGear *gg)
  22. {
  23. caught_signal = false;
  24. signal(SIGINT, handle_sigint);
  25. DEBUG("IOManager powering GameGear")
  26. gamegear_power(gg, true);
  27. // TODO: use SDL events
  28. while (!caught_signal) {
  29. if (gamegear_simulate(gg)) {
  30. ERROR("caught exception: %s", gamegear_get_exception(gg))
  31. #ifdef DEBUG_MODE
  32. z80_dump_registers(&gg->cpu);
  33. #endif
  34. break;
  35. }
  36. usleep(1000 * 1000 / 60);
  37. }
  38. if (caught_signal) {
  39. WARN("caught signal, stopping...")
  40. #ifdef DEBUG_MODE
  41. z80_dump_registers(&gg->cpu);
  42. #endif
  43. }
  44. DEBUG("IOManager unpowering GameGear")
  45. gamegear_power(gg, false);
  46. signal(SIGINT, SIG_DFL);
  47. }