diff --git a/Src/1541t64.cpp b/Src/1541t64.cpp index 0b4999d..5412520 100644 --- a/Src/1541t64.cpp +++ b/Src/1541t64.cpp @@ -224,7 +224,7 @@ uint8 ArchDrive::open_file(int channel, const uint8 *name, int name_len) // Open temporary file if ((file[channel] = #if defined(GEKKO) - fopen("/frodo/tmp/a", "w+") + fopen("/frodo/tmp/ab", "w+") #else tmpfile() #endif diff --git a/Src/C64_SDL.h b/Src/C64_SDL.h index ddf1c3c..d66cf19 100644 --- a/Src/C64_SDL.h +++ b/Src/C64_SDL.h @@ -112,9 +112,31 @@ void C64::startFakeKeySequence(const char *str) this->fake_key_sequence = true; } +//Class already defined in disck_menu.cpp +class StartGameListener : public TimeoutHandler +{ +public: + StartGameListener() + { + + Gui::gui->status_bar->queueMessage("Resetting the C64"); + TheC64->Reset(); + TimerController::controller->arm(this, 4500); + } + + virtual void timeoutCallback() + { + Gui::gui->status_bar->queueMessage("Invoking the load sequence"); + TheC64->startFakeKeySequence("\nLOAD \"*\",8,1\nRUN\n"); + delete this; + } +}; + /* * Start main emulation thread */ + +extern char *floppy8; void C64::Run(void) { @@ -131,6 +153,9 @@ void C64::Run(void) PatchKernal(ThePrefs.FastReset, ThePrefs.Emul1541Proc); quit_thyself = false; + + if (floppy8) new StartGameListener(); + thread_func(); } diff --git a/Src/gui/disc_menu.cpp b/Src/gui/disc_menu.cpp index ea53870..791cf69 100644 --- a/Src/gui/disc_menu.cpp +++ b/Src/gui/disc_menu.cpp @@ -10,7 +10,7 @@ static const char *game_exts[] = {".d64", ".D64", ".t64", ".T64", ".prg",".PRG", ".p00", ".P00", NULL}; -static const char *prg_exts[] = {".prg",".PRG", ".p00", ".P00", NULL}; +const char *prg_exts[] = {".prg",".PRG", ".p00", ".P00", NULL}; class DiscMenu; @@ -120,7 +120,7 @@ public: FILE *src, *dst; tmp_filename = (char *)xmalloc(strlen(Gui::gui->tmp_path) + 4); - sprintf(tmp_filename, "%s/a", Gui::gui->tmp_path); + sprintf(tmp_filename, "%s/ab", Gui::gui->tmp_path); /* Clean temp dir first (we only want one file) */ unlink(tmp_filename); diff --git a/Src/gui/gui.cpp b/Src/gui/gui.cpp index 8a689a0..7964ada 100644 --- a/Src/gui/gui.cpp +++ b/Src/gui/gui.cpp @@ -20,22 +20,6 @@ extern SDL_Surface *screen; -#if defined(GEKKO) -#define THEME_ROOT_PATH "/frodo/themes" -#define METADATA_ROOT_PATH "/frodo/metadata" -#define GAME_ROOT_PATH "/frodo/images" -#define GAME_ROOT_PATH_USB "usb:/" -#define GAME_ROOT_PATH_SMB "smb:/" -#define TMP_ROOT_PATH "/frodo/tmp" -#define SAVE_GAME_ROOT_PATH "/frodo/saves" -#else -#define THEME_ROOT_PATH "themes" -#define METADATA_ROOT_PATH "metadata" -#define GAME_ROOT_PATH "images" -#define TMP_ROOT_PATH "tmp" -#define SAVE_GAME_ROOT_PATH "saves" -#endif - static const char *get_theme_path(const char *dir, const char *what) { static char buf[255]; diff --git a/Src/gui/gui.hh b/Src/gui/gui.hh index 6d1ff66..575f54f 100644 --- a/Src/gui/gui.hh +++ b/Src/gui/gui.hh @@ -13,6 +13,22 @@ #include #include +#if defined(GEKKO) +#define THEME_ROOT_PATH "/frodo/themes" +#define METADATA_ROOT_PATH "/frodo/metadata" +#define GAME_ROOT_PATH "/frodo/images" +#define GAME_ROOT_PATH_USB "usb:/" +#define GAME_ROOT_PATH_SMB "smb:/" +#define TMP_ROOT_PATH "/frodo/tmp" +#define SAVE_GAME_ROOT_PATH "/frodo/saves" +#else +#define THEME_ROOT_PATH "themes" +#define METADATA_ROOT_PATH "metadata" +#define GAME_ROOT_PATH "images" +#define TMP_ROOT_PATH "tmp" +#define SAVE_GAME_ROOT_PATH "saves" +#endif + class DialogueBox; class StatusBar; class NetworkServerMessages; diff --git a/Src/main.cpp b/Src/main.cpp index e44cfea..a93bb0a 100644 --- a/Src/main.cpp +++ b/Src/main.cpp @@ -224,6 +224,9 @@ extern "C" int main(int argc, char **argv) dir_tmp = opendir("/frodo/tmp"); if (!dir_tmp) {mkdir("/frodo/tmp",0777);printf("Making tmp directory\n");sleep(2);} else closedir(dir_tmp); + //Cancel the old a file + unlink ("/frodo/tmp/a"); + #endif @@ -261,11 +264,12 @@ Frodo::Frodo() * Process command line arguments */ char *network_server_connect = 0; +char *floppy8 = 0; void Frodo::ArgvReceived(int argc, char **argv) { - if (argc == 2) - network_server_connect = argv[1]; + if (argc == 2) floppy8 = argv[1]; + else if (argc == 3) network_server_connect = argv[2]; } const char *try_path(const char *path, const char *file) @@ -348,6 +352,9 @@ void Frodo::LoadFrodorc() * Arguments processed, run emulation */ + +extern const char *prg_exts[]; + void Frodo::ReadyToRun(void) { if (getcwd(AppDirPath, 256) == NULL) @@ -357,6 +364,52 @@ void Frodo::ReadyToRun(void) if (network_server_connect) strncpy(ThePrefs.NetworkServer, network_server_connect, sizeof(ThePrefs.NetworkServer)); + +//Mount the floppy if passed as argument +if (floppy8) + { + strncpy(ThePrefs.DrivePath[0], floppy8, sizeof(ThePrefs.DrivePath[0])); + + char *filename; + filename = strrchr(floppy8, '/'); + if (!filename) filename++; + + if (ext_matches_list(filename, prg_exts)) { + char *tmp_filename; + FILE *src, *dst; + + tmp_filename = (char *)xmalloc(strlen(TMP_ROOT_PATH) + 4); + sprintf(tmp_filename, "%s/ab", TMP_ROOT_PATH); + + /* Clean temp dir first (we only want one file) */ + unlink(tmp_filename); + + src = fopen(ThePrefs.DrivePath[0], "r"); + if (src != NULL) + { + snprintf(ThePrefs.DrivePath[0], sizeof(ThePrefs.DrivePath[0]), + "%s", TMP_ROOT_PATH); + + /* Special handling of .prg: Copy to TMP_PATH and + * load that as a dir */ + dst = fopen(tmp_filename, "w"); + if (dst) + { + Uint8 buf[1024]; + size_t v; + + do { + v = fread(buf, 1, sizeof(buf), src); + fwrite(buf, 1, v, dst); + } while (v > 0); + fclose(dst); + } + fclose(src); + } + free(tmp_filename); + } + } + panic_if (!init_graphics(), "Can't initialize graphics!\n");