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.

crater.c 1.4 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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/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. SET_LOG_LEVEL(config->debug)
  22. if (DEBUG_LEVEL)
  23. config_dump_args(config);
  24. if (config->assemble) {
  25. retval = assemble_file(config->src_path, config->dst_path);
  26. retval = retval ? EXIT_SUCCESS : EXIT_FAILURE;
  27. } else if (config->disassemble) {
  28. retval = disassemble_file(config->src_path, config->dst_path);
  29. retval = retval ? EXIT_SUCCESS : EXIT_FAILURE;
  30. } else {
  31. ROM rom;
  32. const char* errmsg;
  33. if ((errmsg = rom_open(&rom, config->rom_path))) {
  34. ERROR("couldn't load ROM image '%s': %s", config->rom_path, errmsg)
  35. retval = EXIT_FAILURE;
  36. } else {
  37. printf("crater: emulating: %s\n", rom.name);
  38. emulate(&rom, config);
  39. rom_close(&rom);
  40. }
  41. }
  42. config_destroy(config);
  43. return retval;
  44. }