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.
 
 
 
 
 

62 lignes
1.7 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 <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. printf("crater: running %s: %s -> %s\n",
  27. config->assemble ? "assembler" : "disassembler",
  28. config->src_path, config->dst_path);
  29. if (config->assemble)
  30. retval = assemble(config->src_path, config->dst_path);
  31. else
  32. retval = disassemble(config->src_path, config->dst_path);
  33. retval = retval ? EXIT_SUCCESS : EXIT_FAILURE;
  34. } else {
  35. ROM *rom;
  36. const char* errmsg;
  37. if ((errmsg = rom_open(&rom, config->rom_path))) {
  38. ERROR("couldn't load ROM image '%s': %s", config->rom_path, errmsg)
  39. retval = EXIT_FAILURE;
  40. } else {
  41. GameGear *gg = gamegear_create();
  42. printf("crater: emulating: %s\n", rom->name);
  43. gamegear_load(gg, rom);
  44. iomanager_emulate(gg);
  45. gamegear_destroy(gg);
  46. rom_close(rom);
  47. }
  48. }
  49. config_destroy(config);
  50. return retval;
  51. }