An emulator, assembler, and disassembler for the Sega Game Gear
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

59 righe
1.5 KiB

  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 <stdlib.h>
  4. #include <stdio.h>
  5. #include "src/assembler.h"
  6. #include "src/config.h"
  7. #include "src/disassembler.h"
  8. #include "src/emulator.h"
  9. #include "src/gamegear.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. SET_LOG_LEVEL(config->debug)
  23. if (DEBUG_LEVEL)
  24. config_dump_args(config);
  25. if (config->assemble) {
  26. retval = assemble_file(config->src_path, config->dst_path);
  27. retval = retval ? EXIT_SUCCESS : EXIT_FAILURE;
  28. } else if (config->disassemble) {
  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. emulate(gg);
  42. gamegear_destroy(gg);
  43. rom_close(rom);
  44. }
  45. }
  46. config_destroy(config);
  47. return retval;
  48. }