An emulator, assembler, and disassembler for the Sega Game Gear
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

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