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.

crater.c 1.5 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 <stdio.h>
  5. #include "src/assembler.h"
  6. #include "src/config.h"
  7. #include "src/disassembler.h"
  8. #include "src/gamegear.h"
  9. #include "src/iomanager.h"
  10. #include "src/logging.h"
  11. #include "src/rom.h"
  12. /*
  13. Main function.
  14. */
  15. int main(int argc, char *argv[])
  16. {
  17. Config *config;
  18. int retval = EXIT_SUCCESS;
  19. retval = config_create(&config, argc, argv);
  20. if (retval != CONFIG_OK)
  21. return retval == CONFIG_EXIT_SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE;
  22. #ifdef DEBUG_MODE
  23. config_dump_args(config);
  24. #endif
  25. if (config->assemble || config->disassemble) {
  26. if (config->assemble)
  27. retval = assemble_file(config->src_path, config->dst_path);
  28. else
  29. retval = disassemble_file(config->src_path, config->dst_path);
  30. retval = retval ? EXIT_SUCCESS : EXIT_FAILURE;
  31. } else {
  32. ROM *rom;
  33. const char* errmsg;
  34. if ((errmsg = rom_open(&rom, config->rom_path))) {
  35. ERROR("couldn't load ROM image '%s': %s", config->rom_path, errmsg)
  36. retval = EXIT_FAILURE;
  37. } else {
  38. GameGear *gg = gamegear_create();
  39. printf("crater: emulating: %s\n", rom->name);
  40. gamegear_load(gg, rom);
  41. iomanager_emulate(gg);
  42. gamegear_destroy(gg);
  43. rom_close(rom);
  44. }
  45. }
  46. config_destroy(config);
  47. return retval;
  48. }