diff --git a/Src/C64_SDL.h b/Src/C64_SDL.h index d66cf19..72805b9 100644 --- a/Src/C64_SDL.h +++ b/Src/C64_SDL.h @@ -112,32 +112,10 @@ 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) { // Reset chips @@ -153,8 +131,6 @@ 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 791cf69..2a19be1 100644 --- a/Src/gui/disc_menu.cpp +++ b/Src/gui/disc_menu.cpp @@ -8,7 +8,7 @@ #include "game_info.hh" #include "game_info_box.hh" -static const char *game_exts[] = {".d64", ".D64", ".t64", ".T64", +const char *game_exts[] = {".d64", ".D64", ".t64", ".T64", ".prg",".PRG", ".p00", ".P00", NULL}; const char *prg_exts[] = {".prg",".PRG", ".p00", ".P00", NULL}; diff --git a/Src/gui/gui.cpp b/Src/gui/gui.cpp index fc25a7c..02205ed 100644 --- a/Src/gui/gui.cpp +++ b/Src/gui/gui.cpp @@ -563,6 +563,75 @@ void Gui::saveGameInfo(const char *base_path, const char *name) this->gameInfoChanged = false; } +extern char *floppy8; //Complete path +extern const char *game_exts[]; +extern const char *prg_exts[]; +extern const char *save_exts[]; + +//Class already defined in disck_menu.cpp +class StartGameListener2 : public TimeoutHandler +{ +public: + StartGameListener2() + { + + //Gui::gui->status_bar->queueMessage("Resetting the C64"); + //TheC64->Reset(); + TimerController::controller->arm(this, 4500); + } + + virtual void timeoutCallback() + { + if (ext_matches_list(floppy8, game_exts)) + { + char *filename; + filename = strrchr(floppy8, '/'); + if (filename) filename++; + + Gui::gui->dv->loadGameInfo(filename); + + if (Gui::gui->dv->gameInfo->gi) + Gui::gui->updateGameInfo(Gui::gui->dv->gameInfo->gi); + else + Gui::gui->updateGameInfo(new GameInfo(filename)); + + Gui::gui->status_bar->queueMessage("Invoking the load sequence"); + TheC64->startFakeKeySequence("\nLOAD \"*\",8,1\nRUN\n"); + + } + + if (ext_matches_list(floppy8, save_exts)) + { + char *prefs_path; + + prefs_path = (char *)xmalloc(strlen(floppy8) + 8); + + sprintf(prefs_path, "%s.prefs", floppy8); + + TheC64->LoadSnapshot(floppy8); + + char *filename; + filename = strrchr(floppy8, '/'); + if (filename) filename++; + char *cpy = xstrdup(filename); + char *p = strstr(cpy, ".sav"); + if (p) + *p = '\0'; + + Gui::gui->sgv->loadGameInfo(cpy); + + if (Gui::gui->sgv->gameInfo->gi) + Gui::gui->updateGameInfo(Gui::gui->sgv->gameInfo->gi); + else + Gui::gui->updateGameInfo(new GameInfo(cpy)); + + free(cpy); + ThePrefs.Load(prefs_path); + free(prefs_path); + } + delete this; + } +}; /* The singleton/factory stuff */ Gui *Gui::gui; @@ -579,4 +648,6 @@ void Gui::init() Gui::gui->status_bar->queueMessage("Welcome to C64-network.org, the networked C64!"); Gui::gui->status_bar->queueMessage("Press Home for the menu!"); + if (floppy8) if ((ext_matches_list(floppy8, game_exts))||(ext_matches_list(floppy8, save_exts))) new StartGameListener2(); + } diff --git a/Src/gui/save_game_menu.cpp b/Src/gui/save_game_menu.cpp index 1762af0..43f4615 100644 --- a/Src/gui/save_game_menu.cpp +++ b/Src/gui/save_game_menu.cpp @@ -9,7 +9,7 @@ #include "game_info.hh" #include "game_info_box.hh" -static const char *save_exts[] = {".sav", ".SAV", NULL}; +const char *save_exts[] = {".sav", ".SAV", NULL}; class SaveGameMenu; diff --git a/Src/gui/sdl_ttf_font.hh b/Src/gui/sdl_ttf_font.hh index c18d03e..4c97b94 100644 --- a/Src/gui/sdl_ttf_font.hh +++ b/Src/gui/sdl_ttf_font.hh @@ -46,7 +46,7 @@ public: SDL_Surface *p; SDL_Rect dst; - p = TTF_RenderText_Blended(this->font, msg, this->clr); + p = TTF_RenderUTF8_Blended(this->font, msg, this->clr); panic_if(!p, "TTF error for '%s': %s\n", msg, TTF_GetError()); dst = (SDL_Rect){x, y, w, h}; diff --git a/Src/main.cpp b/Src/main.cpp index 0b7ebfc..2bc8b88 100644 --- a/Src/main.cpp +++ b/Src/main.cpp @@ -237,9 +237,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 + //Cancel the old files unlink ("/frodo/tmp/a"); - + unlink ("/frodo/tmp/dummy"); #endif @@ -367,6 +367,7 @@ void Frodo::LoadFrodorc() extern const char *prg_exts[]; +extern const char *game_exts[]; void Frodo::ReadyToRun(void) { @@ -380,14 +381,13 @@ void Frodo::ReadyToRun(void) //Mount the floppy if passed as argument if (floppy8) +{ + if (ext_matches_list(floppy8, game_exts)) { - strncpy(ThePrefs.DrivePath[0], floppy8, sizeof(ThePrefs.DrivePath[0])); + strncpy(ThePrefs.DrivePath[0], floppy8, sizeof(ThePrefs.DrivePath[0])); - char *filename; - filename = strrchr(floppy8, '/'); - if (!filename) filename++; - - if (ext_matches_list(filename, prg_exts)) { + if (ext_matches_list(floppy8, prg_exts)) { + char *tmp_filename; FILE *src, *dst; @@ -422,7 +422,7 @@ if (floppy8) free(tmp_filename); } } - +} panic_if (!init_graphics(), "Can't initialize graphics!\n");