An emulator, assembler, and disassembler for the Sega Game Gear
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

crater.c 1.6 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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/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. 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. iomanager_emulate(gg);
  42. gamegear_destroy(gg);
  43. rom_close(rom);
  44. }
  45. }
  46. config_destroy(config);
  47. return retval;
  48. }