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.
 
 
 
 
 

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