File system works, thanks to some code from VBA-Wii. Config file now loads and saves. Restructured so less wii-specific code throughout project.

This commit is contained in:
Carl.Kenner 2009-05-05 00:02:38 +00:00
parent 1ca7041b17
commit 502432d531
6 changed files with 181 additions and 20 deletions

File diff suppressed because one or more lines are too long

View File

@ -33,7 +33,7 @@
#include <process.h> #include <process.h>
#endif #endif
#ifdef HW_RVL #ifdef HW_RVL
#include <wiiuse/WPAD.h> #include <wiihardware.h>
#endif #endif
#include "SDL.h" #include "SDL.h"
@ -1467,6 +1467,9 @@ static void printconfiglocation() {
//extern void UI_Init(void); //extern void UI_Init(void);
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
try { try {
#ifdef HW_RVL
WiiInit();
#endif
CommandLine com_line(argc,argv); CommandLine com_line(argc,argv);
Config myconf(&com_line); Config myconf(&com_line);
control=&myconf; control=&myconf;
@ -1601,9 +1604,7 @@ int main(int argc, char* argv[]) {
if(!parsed_anyconfigfile) { if(!parsed_anyconfigfile) {
//Try to create the userlevel configfile. //Try to create the userlevel configfile.
config_file.clear(); config_file.clear();
#ifndef HW_RVL
Cross::CreatePlatformConfigDir(config_path); Cross::CreatePlatformConfigDir(config_path);
#endif
Cross::GetPlatformConfigName(config_file); Cross::GetPlatformConfigName(config_file);
config_path += config_file; config_path += config_file;
if(control->PrintConfig(config_path.c_str())) { if(control->PrintConfig(config_path.c_str())) {
@ -1665,15 +1666,8 @@ int main(int argc, char* argv[]) {
//Force visible mouse to end user. Somehow this sometimes doesn't happen //Force visible mouse to end user. Somehow this sometimes doesn't happen
SDL_WM_GrabInput(SDL_GRAB_OFF); SDL_WM_GrabInput(SDL_GRAB_OFF);
SDL_ShowCursor(SDL_ENABLE); SDL_ShowCursor(SDL_ENABLE);
#ifdef HW_RVL #ifdef HW_RVL
printf("Press A to return to homebrew channel.\n"); WiiFinished();
while (1) {
WPAD_ScanPads();
u16 buttonsDown = WPAD_ButtonsDown(0);
if( buttonsDown & WPAD_BUTTON_A ) break;
if( buttonsDown & WPAD_BUTTON_HOME ) exit(0);
}
#endif #endif
SDL_Quit();//Let's hope sdl will quit as well when it catches an exception SDL_Quit();//Let's hope sdl will quit as well when it catches an exception
return 0; return 0;

View File

@ -24,6 +24,10 @@
#include <string> #include <string>
#include <stdlib.h> #include <stdlib.h>
#ifdef HW_RVL
#include "wiihardware.h"
#endif
#ifdef WIN32 #ifdef WIN32
#ifndef _WIN32_IE #ifndef _WIN32_IE
#define _WIN32_IE 0x0400 #define _WIN32_IE 0x0400
@ -46,6 +50,9 @@ void Cross::GetPlatformConfigDir(std::string& in) {
#elif defined(MACOSX) #elif defined(MACOSX)
in = "~/Library/Preferences"; in = "~/Library/Preferences";
ResolveHomedir(in); ResolveHomedir(in);
#elif defined(HW_RVL)
in = "sd:/DOSBox";
ResolveHomedir(in);
#else #else
in = "~/.dosbox"; in = "~/.dosbox";
ResolveHomedir(in); ResolveHomedir(in);
@ -58,6 +65,8 @@ void Cross::GetPlatformConfigName(std::string& in) {
#define DEFAULT_CONFIG_FILE "dosbox-" VERSION ".conf" #define DEFAULT_CONFIG_FILE "dosbox-" VERSION ".conf"
#elif defined(MACOSX) #elif defined(MACOSX)
#define DEFAULT_CONFIG_FILE "DOSBox " VERSION " Preferences" #define DEFAULT_CONFIG_FILE "DOSBox " VERSION " Preferences"
#elif defined(HW_RVL)
#define DEFAULT_CONFIG_FILE "dosbox-" VERSION ".conf"
#else /*linux freebsd*/ #else /*linux freebsd*/
#define DEFAULT_CONFIG_FILE "dosbox-" VERSION ".conf" #define DEFAULT_CONFIG_FILE "dosbox-" VERSION ".conf"
#endif #endif
@ -75,6 +84,10 @@ void Cross::CreatePlatformConfigDir(std::string& in) {
in = "~/Library/Preferences/"; in = "~/Library/Preferences/";
ResolveHomedir(in); ResolveHomedir(in);
//Don't create it. Assume it exists //Don't create it. Assume it exists
#elif defined(HW_RVL)
in = "sd:/DOSBox";
CreateDir(in);
//Don't create it. Assume it exists
#else #else
in = "~/.dosbox"; in = "~/.dosbox";
ResolveHomedir(in); ResolveHomedir(in);

View File

@ -0,0 +1,151 @@
#include <gccore.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ogcsys.h>
#include <sys/dir.h>
#include <sys/stat.h>
#include <zlib.h>
#include <malloc.h>
#include <sdcard/wiisd_io.h>
#include <sdcard/gcsd.h>
#include <ogc/usbstorage.h>
#include <fat.h>
#include "wiihardware.h"
char rootdir[10];
enum {
METHOD_AUTO,
METHOD_SD,
METHOD_USB,
METHOD_DVD,
METHOD_SMB,
METHOD_MC_SLOTA,
METHOD_MC_SLOTB,
METHOD_SD_SLOTA,
METHOD_SD_SLOTB
};
bool unmountRequired[9] = { false, false, false, false, false, false, false, false, false };
bool isMounted[9] = { false, false, false, false, false, false, false, false, false };
#ifdef HW_RVL
const DISC_INTERFACE* sd = &__io_wiisd;
const DISC_INTERFACE* usb = &__io_usbstorage;
#else
const DISC_INTERFACE* carda = &__io_gcsda;
const DISC_INTERFACE* cardb = &__io_gcsdb;
#endif
/****************************************************************************
* UnmountAllFAT
* Unmounts all FAT devices
***************************************************************************/
void UnmountAllFAT()
{
#ifdef HW_RVL
fatUnmount("sd:/");
fatUnmount("usb:/");
#else
fatUnmount("carda:/");
fatUnmount("cardb:/");
#endif
}
/****************************************************************************
* MountFAT
* Checks if the device needs to be (re)mounted
* If so, unmounts the device
* Attempts to mount the device specified
* Sets libfat to use the device by default
***************************************************************************/
bool MountFAT(int method)
{
bool mounted = true; // assume our disc is already mounted
char name[10];
const DISC_INTERFACE* disc = NULL;
switch(method)
{
#ifdef HW_RVL
case METHOD_SD:
sprintf(name, "sd");
disc = sd;
break;
case METHOD_USB:
sprintf(name, "usb");
disc = usb;
break;
#else
case METHOD_SD_SLOTA:
sprintf(name, "carda");
disc = carda;
break;
case METHOD_SD_SLOTB:
sprintf(name, "cardb");
disc = cardb;
break;
#endif
default:
return false; // unknown device
}
sprintf(rootdir, "%s:/", name);
if(unmountRequired[method])
{
unmountRequired[method] = false;
fatUnmount(rootdir);
disc->shutdown();
isMounted[method] = false;
}
if(!isMounted[method])
{
if(!disc->startup())
mounted = false;
else if(!fatMountSimple(name, disc))
mounted = false;
}
isMounted[method] = mounted;
return mounted;
}
void MountAllFAT()
{
#ifdef HW_RVL
MountFAT(METHOD_SD);
MountFAT(METHOD_USB);
#else
MountFAT(METHOD_SD_SLOTA);
MountFAT(METHOD_SD_SLOTB);
#endif
}
void WiiInit() {
MountAllFAT();
}
bool WiiMessagePause(const char *s) {
if (s) printf(s);
#ifdef HW_RVL
while (1) {
WPAD_ScanPads();
u16 buttonsDown = WPAD_ButtonsDown(0);
if( buttonsDown & WPAD_BUTTON_A ) return false;
if( buttonsDown & WPAD_BUTTON_HOME ) return true;
}
#else
return false;
#endif
}
void WiiFinished() {
UnmountAllFAT();
#ifdef HW_RVL
if (WiiMessagePause("Press A to return to homebrew channel.\n")) exit(0);
#endif
}

View File

@ -0,0 +1,9 @@
#ifndef WIIHARDWARE_H
#define WIIHARDWARE_H
#include <wiiuse/WPAD.h>
void WiiInit();
void WiiFinished();
bool WiiMessagePause(const char *s);
#endif

View File

@ -22,7 +22,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <string.h> #include <string.h>
#ifdef HW_RVL #ifdef HW_RVL
#include <wiiuse/WPAD.h> #include <wiihardware.h>
#endif #endif
#include "dosbox.h" #include "dosbox.h"
#include "regs.h" #include "regs.h"
@ -635,13 +635,7 @@ void SHELL_Init() {
SHELL_ProgramStart(&first_shell); SHELL_ProgramStart(&first_shell);
#ifdef HW_RVL #ifdef HW_RVL
printf("Press A to continue (or Home to exit).\n"); WiiMessagePause("Press A to continue (or Home to exit).\n");
while (1) {
WPAD_ScanPads();
u16 buttonsDown = WPAD_ButtonsDown(0);
if( buttonsDown & WPAD_BUTTON_A ) break;
if( buttonsDown & WPAD_BUTTON_HOME ) exit(0);
}
#endif #endif
first_shell->Run(); first_shell->Run();