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.
 
 
 
 
 

57 lignes
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. }