diff --git a/src/dos/dos_programs.cpp b/src/dos/dos_programs.cpp index a2d0ae7..4592fdd 100644 --- a/src/dos/dos_programs.cpp +++ b/src/dos/dos_programs.cpp @@ -50,6 +50,73 @@ Bitu DEBUG_EnableDebugger(void); void MSCDEX_SetCDInterface(int intNr, int forceCD); +// Mounts a folder as a harddrive before starting the shell +// Designed for the Wii +void MountDOSBoxDir(char DriveLetter, const char *path) { + DOS_Drive * newdrive; + Bit16u sizes[4]; + Bit8u mediaid; + std::string str_size; + std::string label; + str_size="512,127,16383,4031"; + mediaid=0xF8; /* Hard Disk */ + char number[20]; + const char * scan=str_size.c_str(); + Bitu index=0;Bitu count=0; + /* Parse the str_size string */ + while (*scan) { + if (*scan==',') { + number[index]=0; + sizes[count++]=atoi(number); + index=0; + } else number[index++]=*scan; + scan++; + } + number[index]=0; + sizes[count++]=atoi(number); + + // get the drive letter + char drive=toupper(DriveLetter); + std::string temp_line = path; + struct stat test; + bool failed = false; + if (stat(temp_line.c_str(),&test)) { + failed = true; + Cross::ResolveHomedir(temp_line); + //Try again after resolving ~ + if(!stat(temp_line.c_str(),&test)) failed = false; + } + if(failed) { + printf(MSG_Get("PROGRAM_MOUNT_ERROR_1"),temp_line.c_str()); + return; + } + /* Not a switch so a normal directory/file */ + if (!(test.st_mode & S_IFDIR)) { + printf(MSG_Get("PROGRAM_MOUNT_ERROR_2"),temp_line.c_str()); + return; + } + if (temp_line[temp_line.size()-1]!=CROSS_FILESPLIT) temp_line+=CROSS_FILESPLIT; + Bit8u bit8size=(Bit8u) sizes[1]; + newdrive=new localDrive(temp_line.c_str(),sizes[0],bit8size,sizes[2],sizes[3],mediaid); + if (Drives[drive-'A']) { + printf(MSG_Get("PROGRAM_MOUNT_ALREADY_MOUNTED"),drive,Drives[drive-'A']->GetInfo()); + if (newdrive) delete newdrive; + return; + } + if (!newdrive) E_Exit("DOS:Can't create drive"); + Drives[drive-'A']=newdrive; + /* Set the correct media byte in the table */ + mem_writeb(Real2Phys(dos.tables.mediaid)+(drive-'A')*2,newdrive->GetMediaByte()); + printf(MSG_Get("PROGRAM_MOUNT_STATUS_2"),drive,newdrive->GetInfo()); + /* For hard drives set the label to DRIVELETTER_Drive. + * For floppy drives set the label to DRIVELETTER_Floppy. + * This way every drive except cdroms should get a label.*/ + label = drive; label+="_DRIVE"; + newdrive->dirCache.SetLabel(label.c_str(),false,true); + return; +} + + class MOUNT : public Program { public: diff --git a/src/gui/sdlmain.cpp b/src/gui/sdlmain.cpp index f5bde23..dacfa89 100644 --- a/src/gui/sdlmain.cpp +++ b/src/gui/sdlmain.cpp @@ -1463,6 +1463,7 @@ static void printconfiglocation() { exit(0); } +void MountDOSBoxDir(char DriveLetter, const char *path); //extern void UI_Init(void); int main(int argc, char* argv[]) { @@ -1636,6 +1637,9 @@ int main(int argc, char* argv[]) { /* Init the keyMapper */ MAPPER_Init(); if (control->cmdline->FindExist("-startmapper")) MAPPER_Run(false); +#ifdef HW_RVL + MountDOSBoxDir('C', "sd:/DOSBox"); +#endif /* Start up main machine */ control->StartUp(); /* Shutdown everything */