.sav file passed as arguments, UDF8 ttf font

This commit is contained in:
fabio.olimpieri 2013-03-06 22:32:16 +00:00
parent 99454336cb
commit fe0cbaf42e
6 changed files with 83 additions and 36 deletions

View File

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

View File

@ -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};

View File

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

View File

@ -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;

View File

@ -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};

View File

@ -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");