mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-25 21:14:22 +01:00
Added support for loading games from USB port (only FAT)
This commit is contained in:
parent
1c57b2170e
commit
07b3a3c166
@ -108,6 +108,7 @@ Prefs::Prefs()
|
||||
AlwaysCopy = false;
|
||||
SystemKeys = true;
|
||||
ShowLEDs = true;
|
||||
Usbport = false;
|
||||
|
||||
this->SetupJoystickDefaults();
|
||||
|
||||
@ -527,6 +528,8 @@ void Prefs::Load(const char *filename)
|
||||
strcpy(Theme, value);
|
||||
else if (!strcmp(keyword, "CursorKeysForJoystick"))
|
||||
CursorKeysForJoystick = !strcmp(value, "TRUE");
|
||||
else if (!strcmp(keyword, "Usbport"))
|
||||
Usbport = !strcmp(value, "TRUE");
|
||||
}
|
||||
}
|
||||
fclose(file);
|
||||
@ -640,6 +643,7 @@ bool Prefs::Save(const char *filename)
|
||||
maybe_write(file, NetworkRegion != TheDefaultPrefs.NetworkRegion, "NetworkRegion = %d\n", NetworkRegion);
|
||||
maybe_write(file, strcmp(Theme, TheDefaultPrefs.Theme) != 0, "Theme = %s\n", Theme);
|
||||
maybe_write(file, CursorKeysForJoystick != TheDefaultPrefs.CursorKeysForJoystick, "CursorKeysForJoystick = %s\n", CursorKeysForJoystick ? "TRUE" : "FALSE");
|
||||
maybe_write(file, Usbport != TheDefaultPrefs.Usbport, "Usbport = %s\n", Usbport ? "TRUE" : "FALSE");
|
||||
fclose(file);
|
||||
ThePrefsOnDisk = *this;
|
||||
return true;
|
||||
|
@ -155,6 +155,7 @@ public:
|
||||
bool AlwaysCopy; // Always use a work surface (Win32)
|
||||
bool SystemKeys; // Enable system keys and menu keys (Win32)
|
||||
bool ShowLEDs; // Show LEDs (Win32)
|
||||
bool Usbport; // Load from usb port
|
||||
|
||||
uint32 MsPerFrame;
|
||||
|
||||
|
@ -24,6 +24,7 @@ extern SDL_Surface *screen;
|
||||
#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 TMP_ROOT_PATH "/frodo/tmp"
|
||||
#define SAVE_GAME_ROOT_PATH "/frodo/saves"
|
||||
#else
|
||||
@ -107,6 +108,7 @@ Gui::Gui()
|
||||
this->theme_base_path = THEME_ROOT_PATH;
|
||||
this->metadata_base_path = METADATA_ROOT_PATH;
|
||||
this->game_base_path = GAME_ROOT_PATH;
|
||||
this->game_base_path_usb = GAME_ROOT_PATH_USB;
|
||||
this->tmp_path = TMP_ROOT_PATH;
|
||||
this->save_game_path = SAVE_GAME_ROOT_PATH;
|
||||
|
||||
|
@ -129,6 +129,7 @@ public:
|
||||
const char *metadata_base_path;
|
||||
const char *theme_base_path;
|
||||
const char *game_base_path;
|
||||
const char *game_base_path_usb;
|
||||
const char *tmp_path;
|
||||
const char *save_game_path;
|
||||
|
||||
|
@ -4,7 +4,8 @@
|
||||
|
||||
ListenerManager::ListenerManager()
|
||||
{
|
||||
printf("Flushing listeners\n");
|
||||
//commented since appear under the screen
|
||||
//printf("Flushing listeners\n");
|
||||
this->flushListeners();
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include "menu.hh"
|
||||
#include "dialogue_box.hh"
|
||||
|
||||
extern int usbismount;
|
||||
|
||||
class KeyboardTypingListener : public KeyboardListener, TimeoutHandler
|
||||
{
|
||||
public:
|
||||
@ -68,7 +70,9 @@ public:
|
||||
switch (which)
|
||||
{
|
||||
case 0: /* Insert disc */
|
||||
Gui::gui->dv->setDirectory(Gui::gui->game_base_path);
|
||||
if (Gui::gui->np->Usbport & usbismount) Gui::gui->dv->setDirectory(Gui::gui->game_base_path_usb);
|
||||
else Gui::gui->dv->setDirectory(Gui::gui->game_base_path);
|
||||
|
||||
Gui::gui->pushView(Gui::gui->dv);
|
||||
|
||||
Gui::gui->dv->runStartSequence(this->p_submenus[0].sel == 0);
|
||||
|
@ -138,7 +138,7 @@ const char *frodo_help[11] = {
|
||||
};
|
||||
|
||||
|
||||
const char *main_menu_messages[14] = {
|
||||
const char *main_menu_messages[13] = {
|
||||
/*00*/ "File",
|
||||
/*01*/ "^|Start|Insert",
|
||||
/*02*/ "States",
|
||||
@ -154,7 +154,7 @@ const char *main_menu_messages[14] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
const char **main_menu_help[14] = {
|
||||
const char **main_menu_help[13] = {
|
||||
(const char*[]){
|
||||
"Insert a disc/tape or",
|
||||
"start it",
|
||||
@ -205,7 +205,7 @@ const char **main_menu_help[14] = {
|
||||
};
|
||||
|
||||
|
||||
const char *options_menu_messages[14] = {
|
||||
const char *options_menu_messages[15] = {
|
||||
/*00*/ "Help",
|
||||
/*01*/ " ",
|
||||
/*02*/ "Map Controller 1 to:",
|
||||
@ -216,13 +216,14 @@ const char *options_menu_messages[14] = {
|
||||
/*07*/ "^|window|fullscreen",
|
||||
/*08*/ "Speed (approx. %)",
|
||||
/*09*/ "^|95|100|110",
|
||||
/*10*/ "Reset the C=64",
|
||||
/*11*/ " ",
|
||||
/*10*/ "Usb port",
|
||||
/*11*/ "^|ON|OFF",
|
||||
/*12*/ "Setup GUI theme",
|
||||
/*13*/ "Reset the C=64",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char *bind_key_menu_messages[13] = {
|
||||
const char *bind_key_menu_messages[9] = {
|
||||
/*00*/ "Wiimote",
|
||||
/*01*/ "^|A|B|1|2|+|-",
|
||||
/*02*/ "Nunchuk",
|
||||
@ -234,7 +235,7 @@ const char *bind_key_menu_messages[13] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
const char **options_menu_help[14] = {
|
||||
const char **options_menu_help[15] = {
|
||||
(const char*[]){
|
||||
"Help and keyboard.",
|
||||
"shortcuts",
|
||||
@ -273,7 +274,8 @@ const char **options_menu_help[14] = {
|
||||
},
|
||||
NULL,
|
||||
(const char*[]){
|
||||
"Reset the c64.",
|
||||
"Load games from usb port",
|
||||
"instead of SD card",
|
||||
NULL,
|
||||
},
|
||||
NULL,
|
||||
@ -282,6 +284,10 @@ const char **options_menu_help[14] = {
|
||||
"menus.",
|
||||
NULL,
|
||||
},
|
||||
(const char*[]){
|
||||
"Reset the c64.",
|
||||
NULL,
|
||||
},
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
@ -28,7 +28,7 @@ public:
|
||||
Gui::gui->pushDialogueBox(new DialogueBox(frodo_help));
|
||||
return;
|
||||
}
|
||||
else if (which == 10)
|
||||
else if (which == 13)
|
||||
{
|
||||
Gui::gui->status_bar->queueMessage("Resetting the C64");
|
||||
Gui::gui->exitMenu();
|
||||
@ -74,13 +74,14 @@ public:
|
||||
case 2:
|
||||
Gui::gui->np->MsPerFrame = SPEED_110; break;
|
||||
default:
|
||||
panic("Impossible submenu value: %d\n", this->p_submenus[4].sel);
|
||||
panic("Impossible submenu value: %d\n", this->p_submenus[3].sel);
|
||||
}
|
||||
Gui::gui->np->Usbport = !this->p_submenus[4].sel;
|
||||
}
|
||||
|
||||
void updateSubmenus()
|
||||
{
|
||||
int submenu_defs[5];
|
||||
int submenu_defs[4];
|
||||
|
||||
submenu_defs[0] = Gui::gui->np->JoystickSwap == true ? 0 : 1;
|
||||
submenu_defs[1] = !Gui::gui->np->Emul1541Proc;
|
||||
@ -97,6 +98,7 @@ public:
|
||||
submenu_defs[3] = 1; break;
|
||||
}
|
||||
|
||||
submenu_defs[4] = !Gui::gui->np->Usbport;
|
||||
this->setText(options_menu_messages, submenu_defs);
|
||||
}
|
||||
|
||||
|
59
Src/main.cpp
59
Src/main.cpp
@ -32,7 +32,9 @@
|
||||
#include "utils.hh"
|
||||
|
||||
#if defined(GEKKO)
|
||||
#include <gccore.h>
|
||||
#include <fat.h>
|
||||
#include <ogc/usbstorage.h>
|
||||
#endif
|
||||
|
||||
|
||||
@ -43,7 +45,7 @@ extern int init_graphics(void);
|
||||
// Global variables
|
||||
C64 *TheC64 = NULL; // Global C64 object
|
||||
char AppDirPath[1024]; // Path of application directory
|
||||
|
||||
int usbismount = 0;
|
||||
|
||||
// ROM file names
|
||||
#ifndef DATADIR
|
||||
@ -76,6 +78,48 @@ char AppDirPath[1024]; // Path of application directory
|
||||
#include "1541_ROM.h"
|
||||
|
||||
|
||||
|
||||
|
||||
#if defined(GEKKO)
|
||||
|
||||
//init and deinit USB device functions
|
||||
//code taken from Arikado
|
||||
|
||||
|
||||
int InitUSB()
|
||||
{
|
||||
printf("Initializing USB FAT subsytem ...\n\n");
|
||||
fatUnmount("usb:");
|
||||
bool isMounted = fatMountSimple("usb", &__io_usbstorage);
|
||||
|
||||
if(!isMounted)
|
||||
{
|
||||
fatUnmount("usb:");
|
||||
fatMountSimple("usb", &__io_usbstorage);
|
||||
bool isInserted = __io_usbstorage.isInserted();
|
||||
|
||||
if(isInserted)
|
||||
{ int retry = 10;
|
||||
while(retry)
|
||||
{
|
||||
isMounted = fatMountSimple("usb", &__io_usbstorage);
|
||||
if (isMounted) break;
|
||||
sleep(1);
|
||||
retry--;
|
||||
}
|
||||
}
|
||||
}
|
||||
return isMounted;
|
||||
}
|
||||
|
||||
void DeInitUSB()
|
||||
{
|
||||
fatUnmount("usb:");
|
||||
__io_usbstorage.shutdown();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Load C64 ROM files
|
||||
*/
|
||||
@ -136,11 +180,18 @@ extern "C" int main(int argc, char **argv)
|
||||
//initialize libfat library
|
||||
if (!fatInitDefault())
|
||||
{
|
||||
printf("Couldn't initialize fat subsytem\n");
|
||||
printf("Couldn't initialize SD fat subsytem\n\n");
|
||||
sleep(3);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
usbismount = InitUSB();
|
||||
if (usbismount)
|
||||
printf("USB FAT subsytem initialized\n");
|
||||
else
|
||||
printf("Impossible to initialize USB FAT subsytem\n");
|
||||
sleep(2);
|
||||
|
||||
//create tmp directory if it does not exist
|
||||
dir_tmp = diropen("/frodo/tmp");
|
||||
if (!dir_tmp) {mkdir("/frodo/tmp",0777);printf("Making tmp directory\n");sleep(3);} else dirclose(dir_tmp);
|
||||
@ -154,6 +205,7 @@ extern "C" int main(int argc, char **argv)
|
||||
delete the_app;
|
||||
|
||||
#ifdef GEKKO
|
||||
DeInitUSB();
|
||||
fatUnmount(0);
|
||||
#endif
|
||||
|
||||
@ -288,9 +340,6 @@ void Frodo::ReadyToRun(void)
|
||||
|
||||
delete TheC64;
|
||||
|
||||
#if defined(GEKKO)
|
||||
fatUnmount("sd:");
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user