mirror of
https://github.com/retro100/dosbox-wii.git
synced 2024-12-25 01:51:49 +01:00
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:
parent
1ca7041b17
commit
502432d531
File diff suppressed because one or more lines are too long
@ -33,7 +33,7 @@
|
||||
#include <process.h>
|
||||
#endif
|
||||
#ifdef HW_RVL
|
||||
#include <wiiuse/WPAD.h>
|
||||
#include <wiihardware.h>
|
||||
#endif
|
||||
|
||||
#include "SDL.h"
|
||||
@ -1467,6 +1467,9 @@ static void printconfiglocation() {
|
||||
//extern void UI_Init(void);
|
||||
int main(int argc, char* argv[]) {
|
||||
try {
|
||||
#ifdef HW_RVL
|
||||
WiiInit();
|
||||
#endif
|
||||
CommandLine com_line(argc,argv);
|
||||
Config myconf(&com_line);
|
||||
control=&myconf;
|
||||
@ -1601,9 +1604,7 @@ int main(int argc, char* argv[]) {
|
||||
if(!parsed_anyconfigfile) {
|
||||
//Try to create the userlevel configfile.
|
||||
config_file.clear();
|
||||
#ifndef HW_RVL
|
||||
Cross::CreatePlatformConfigDir(config_path);
|
||||
#endif
|
||||
Cross::GetPlatformConfigName(config_file);
|
||||
config_path += config_file;
|
||||
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
|
||||
SDL_WM_GrabInput(SDL_GRAB_OFF);
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
|
||||
#ifdef HW_RVL
|
||||
printf("Press A to return to homebrew channel.\n");
|
||||
while (1) {
|
||||
WPAD_ScanPads();
|
||||
u16 buttonsDown = WPAD_ButtonsDown(0);
|
||||
if( buttonsDown & WPAD_BUTTON_A ) break;
|
||||
if( buttonsDown & WPAD_BUTTON_HOME ) exit(0);
|
||||
}
|
||||
WiiFinished();
|
||||
#endif
|
||||
SDL_Quit();//Let's hope sdl will quit as well when it catches an exception
|
||||
return 0;
|
||||
|
@ -24,6 +24,10 @@
|
||||
#include <string>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef HW_RVL
|
||||
#include "wiihardware.h"
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#ifndef _WIN32_IE
|
||||
#define _WIN32_IE 0x0400
|
||||
@ -46,6 +50,9 @@ void Cross::GetPlatformConfigDir(std::string& in) {
|
||||
#elif defined(MACOSX)
|
||||
in = "~/Library/Preferences";
|
||||
ResolveHomedir(in);
|
||||
#elif defined(HW_RVL)
|
||||
in = "sd:/DOSBox";
|
||||
ResolveHomedir(in);
|
||||
#else
|
||||
in = "~/.dosbox";
|
||||
ResolveHomedir(in);
|
||||
@ -58,6 +65,8 @@ void Cross::GetPlatformConfigName(std::string& in) {
|
||||
#define DEFAULT_CONFIG_FILE "dosbox-" VERSION ".conf"
|
||||
#elif defined(MACOSX)
|
||||
#define DEFAULT_CONFIG_FILE "DOSBox " VERSION " Preferences"
|
||||
#elif defined(HW_RVL)
|
||||
#define DEFAULT_CONFIG_FILE "dosbox-" VERSION ".conf"
|
||||
#else /*linux freebsd*/
|
||||
#define DEFAULT_CONFIG_FILE "dosbox-" VERSION ".conf"
|
||||
#endif
|
||||
@ -75,6 +84,10 @@ void Cross::CreatePlatformConfigDir(std::string& in) {
|
||||
in = "~/Library/Preferences/";
|
||||
ResolveHomedir(in);
|
||||
//Don't create it. Assume it exists
|
||||
#elif defined(HW_RVL)
|
||||
in = "sd:/DOSBox";
|
||||
CreateDir(in);
|
||||
//Don't create it. Assume it exists
|
||||
#else
|
||||
in = "~/.dosbox";
|
||||
ResolveHomedir(in);
|
||||
|
151
src/platform/wii/wiihardware.cpp
Normal file
151
src/platform/wii/wiihardware.cpp
Normal 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
|
||||
}
|
9
src/platform/wii/wiihardware.h
Normal file
9
src/platform/wii/wiihardware.h
Normal 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
|
@ -22,7 +22,7 @@
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#ifdef HW_RVL
|
||||
#include <wiiuse/WPAD.h>
|
||||
#include <wiihardware.h>
|
||||
#endif
|
||||
#include "dosbox.h"
|
||||
#include "regs.h"
|
||||
@ -635,13 +635,7 @@ void SHELL_Init() {
|
||||
SHELL_ProgramStart(&first_shell);
|
||||
|
||||
#ifdef HW_RVL
|
||||
printf("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);
|
||||
}
|
||||
WiiMessagePause("Press A to continue (or Home to exit).\n");
|
||||
#endif
|
||||
|
||||
first_shell->Run();
|
||||
|
Loading…
Reference in New Issue
Block a user