mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-13 07:05:12 +01:00
Added argument management, fixed bug for prg files with sdhc card
This commit is contained in:
parent
434971987f
commit
706fc918dd
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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];
|
||||
|
@ -13,6 +13,22 @@
|
||||
#include <main.h>
|
||||
#include <Prefs.h>
|
||||
|
||||
#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;
|
||||
|
57
Src/main.cpp
57
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");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user