diff --git a/platforms/desktop-shared/application.cpp b/platforms/desktop-shared/application.cpp index 6febe1d..a9ecca0 100644 --- a/platforms/desktop-shared/application.cpp +++ b/platforms/desktop-shared/application.cpp @@ -22,6 +22,7 @@ #include "imgui/imgui_impl_sdl.h" #include "emu.h" #include "gui.h" +#include "gui_debug.h" #include "config.h" #include "renderer.h" @@ -46,15 +47,10 @@ static void render(void); static void frame_throttle(void); static void save_window_size(void); -int application_init(const char* arg) +int application_init(const char* rom_file, const char* symbol_file) { Log ("<·> %s %s Desktop App <·>", GEARCOLECO_TITLE, GEARCOLECO_VERSION); - if (IsValidPointer(arg) && (strlen(arg) > 0)) - { - Log ("Loading with argv: %s"); - } - config_init(); config_read(); @@ -77,9 +73,16 @@ int application_init(const char* arg) if (config_emulator.fullscreen) application_trigger_fullscreen(true); - if (IsValidPointer(arg) && (strlen(arg) > 0)) + if (IsValidPointer(rom_file) && (strlen(rom_file) > 0)) + { + Log ("Rom file argument: %s", rom_file); + gui_load_rom(rom_file); + } + if (IsValidPointer(symbol_file) && (strlen(symbol_file) > 0)) { - gui_load_rom(arg); + Log ("Symbol file argument: %s", symbol_file); + gui_debug_reset_symbols(); + gui_debug_load_symbols_file(symbol_file); } return ret; diff --git a/platforms/desktop-shared/application.h b/platforms/desktop-shared/application.h index 4f17a64..7472bf1 100644 --- a/platforms/desktop-shared/application.h +++ b/platforms/desktop-shared/application.h @@ -34,7 +34,7 @@ EXTERN float application_display_scale; EXTERN SDL_version application_sdl_build_version; EXTERN SDL_version application_sdl_link_version; -EXTERN int application_init(const char* arg); +EXTERN int application_init(const char* rom_file, const char* symbol_file); EXTERN void application_destroy(void); EXTERN void application_mainloop(void); EXTERN void application_trigger_quit(void); diff --git a/platforms/desktop-shared/main.cpp b/platforms/desktop-shared/main.cpp index 0fb99ef..47cf9c9 100644 --- a/platforms/desktop-shared/main.cpp +++ b/platforms/desktop-shared/main.cpp @@ -17,11 +17,61 @@ * */ +#include "../../src/gearcoleco.h" #include "application.h" int main(int argc, char* argv[]) { - int ret = application_init((argc == 2) ? argv[1] : NULL); + char* rom_file = NULL; + char* symbol_file = NULL; + bool show_usage = false; + int ret = 0; + + for (int i = 0; i < argc; i++) + { + if ((strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "-?") == 0) || + (strcmp(argv[i], "--help") == 0) || (strcmp(argv[i], "/?") == 0)) + { + show_usage = true; + ret = 0; + } + else if ((strcmp(argv[i], "-v") == 0) || (strcmp(argv[i], "--version") == 0)) + { + printf("%s %s\n", GEARCOLECO_TITLE, GEARCOLECO_VERSION); + printf("Build: %s\n", EMULATOR_BUILD); + return 0; + } + else if (argv[i][0] == '-') + { + show_usage = true; + ret = -1; + } + } + + switch (argc) + { + case 3: + rom_file = argv[1]; + symbol_file = argv[2]; + break; + case 2: + rom_file = argv[1]; + break; + case 1: + break; + default: + show_usage = true; + ret = -1; + break; + } + + if (show_usage) + { + printf("Usage: %s [rom_file] [symbol_file]\n", argv[0]); + return ret; + } + + ret = application_init(rom_file, symbol_file); if (ret == 0) application_mainloop();