Skip to content

Commit

Permalink
Load symbol files from command line
Browse files Browse the repository at this point in the history
  • Loading branch information
drhelius committed Jan 6, 2024
1 parent 5a4f5da commit f3d1c55
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 10 deletions.
19 changes: 11 additions & 8 deletions platforms/desktop-shared/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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();

Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion platforms/desktop-shared/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
52 changes: 51 additions & 1 deletion platforms/desktop-shared/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit f3d1c55

Please sign in to comment.