fixed libDI support (thanks svpe)

This commit is contained in:
ekeeke31 2008-08-20 20:25:17 +00:00
parent 18ae625179
commit 54fd830729
6 changed files with 60 additions and 78 deletions

View File

@ -21,6 +21,7 @@ current:
[Wii only]
- added lightgun & mouse support through Wiimote IR
- added DVD support thanks to libDI (no modchip required)
[NGC/Wii]
- added "Gun cursor" option to enable/disable gun position display

View File

@ -24,14 +24,13 @@
#ifndef HW_RVL
static u64 DvdMaxOffset = 0x57057C00; /* 1.4 GB max. */
static vu32* const dvd = (u32*)0xCC006000; /* DVD I/O Address base */
static u8 *inquiry=(unsigned char *)0x80000004;
static u8 *inquiry=(unsigned char *)0x80000004; /* pointer to drive ID */
#else
static u64 DvdMaxOffset = 0x118244F00LL; /* 4.7 GB max. */
#endif
/* 2k buffer for all DVD operations */
u8 DVDreadbuffer[2048] ATTRIBUTE_ALIGN (32);
static u8 DVDreadbuffer[2048] ATTRIBUTE_ALIGN (32); /* data buffer for all DVD operations */
/***************************************************************************
@ -67,17 +66,8 @@ u32 dvd_read (void *dst, u32 len, u64 offset)
if (dvd[0] & 0x4) return 0;
#else
int ret = DI_ReadDVD(buffer, len , (u32)(offset >> 2));
if (ret)
{
char msg[50];
u32 val;
DI_GetError(&val);
sprintf(msg, "DI Read Error: 0x%08X\n",val);
return 0;
}
if (DI_ReadDVD(buffer, len >> 11, (u32)(offset >> 11))) return 0;
#endif
memcpy (dst, buffer, len);
return 1;
}

View File

@ -191,7 +191,7 @@ static void FileSelected()
}
/* Add/move the file to the top of the history. */
history_add_file(rootSDdir, filelist[selection].filename);
if (UseSDCARD) history_add_file(rootSDdir, filelist[selection].filename);
rootdir = filelist[selection].offset;
rootdirlength = filelist[selection].length;
@ -408,7 +408,7 @@ static void FileSelector ()
*
* Function to load a DVD directory and display to user.
****************************************************************************/
void OpenDVD ()
int OpenDVD ()
{
UseSDCARD = 0;
UseHistory = 0;
@ -421,6 +421,14 @@ void OpenDVD ()
#ifndef HW_RVL
DVD_Mount();
#else
u32 val;
DI_GetCoverRegister(&val);
if(val & 0x1)
{
WaitPrompt("No Disc inserted !");
return 0;
}
DI_Mount();
while(DI_GetStatus() & DVD_INIT);
if (!(DI_GetStatus() & DVD_READY))
@ -428,7 +436,7 @@ void OpenDVD ()
char msg[50];
sprintf(msg, "DI Status Error: 0x%08X\n",DI_GetStatus());
WaitPrompt(msg);
return;
return 0;
}
#endif
@ -436,7 +444,7 @@ void OpenDVD ()
if (!getpvd())
{
WaitPrompt ("Failed to mount DVD");
return;
return 0;
}
}
@ -456,6 +464,8 @@ void OpenDVD ()
}
}
else FileSelector ();
return 1;
}
/****************************************************************************
@ -511,7 +521,7 @@ int OpenSD ()
*
* Function to load a recent file from SDCARD (Marty Disibio)
****************************************************************************/
void OpenHistory()
int OpenHistory()
{
int i;
@ -553,10 +563,11 @@ void OpenHistory()
if(!maxfiles)
{
WaitPrompt ("No recent files");
return;
return 0;
}
FileSelector();
return 1;
}

View File

@ -26,7 +26,7 @@ int rootdirlength = 0;
/** Global file entry table **/
FILEENTRIES filelist[MAXFILES];
static char dvdbuffer[2048];
static char dvdbuffer[2048] ATTRIBUTE_ALIGN (32);
/****************************************************************************
* Primary Volume Descriptor

View File

@ -28,6 +28,7 @@
#ifdef HW_RVL
#include <wiiuse/wpad.h>
#include <di/di.h>
#endif
/***************************************************************************
@ -877,11 +878,12 @@ void loadmenu ()
{
int ret;
int quit = 0;
int count = 3;
char item[3][20] = {
int count = 4;
char item[4][20] = {
{"Load Recent"},
{"Load from SDCARD"},
{"Load from DVD"}
{"Load from DVD"},
{"Stop DVD Motor"}
};
menu = load_menu;
@ -897,18 +899,19 @@ void loadmenu ()
break;
case 0: /*** Load Recent ***/
OpenHistory();
quit = 1;
quit = OpenHistory();
break;
case 1: /*** Load from SCDARD ***/
OpenSD();
quit = 1;
quit = OpenSD();
break;
case 2: /*** Load from DVD ***/
OpenDVD();
quit = 1;
quit = OpenDVD();
break;
case 3: /*** Stop DVD Disc ***/
dvd_motor_off();
break;
}
}
@ -1048,13 +1051,8 @@ void MainMenu ()
int quit = 0;
uint32 crccheck;
#ifdef HW_RVL
int count = 8;
char items[8][20] =
#else
int count = 9;
char items[9][20] =
#endif
{
{"Play Game"},
{"Game Infos"},
@ -1062,14 +1060,8 @@ void MainMenu ()
{"Load New Game"},
{"File Management"},
{"Emulator Options"},
#ifdef HW_RVL
{"Return to Loader"},
{"System Menu"}
#else
{"Stop DVD Motor"},
{"SD/PSO Reload"},
{"System Reboot"}
#endif
};
/* Switch to menu default rendering mode (60hz or 50hz, but always 480 lines) */
@ -1123,12 +1115,14 @@ void MainMenu ()
optionmenu ();
break;
#ifdef HW_RVL
case 6: /*** TP Reload ***/
case 6: /*** SD/PSO/TP Reload ***/
memfile_autosave();
VIDEO_ClearFrameBuffer(vmode, xfb[whichfb], COLOR_BLACK);
VIDEO_Flush();
VIDEO_WaitVSync();
#ifdef HW_RVL
DI_Close();
#endif
exit(0);
break;
@ -1137,27 +1131,13 @@ void MainMenu ()
VIDEO_ClearFrameBuffer(vmode, xfb[whichfb], COLOR_BLACK);
VIDEO_Flush();
VIDEO_WaitVSync();
#ifdef HW_RVL
DI_Close();
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
break;
#else
case 6: /*** Stop DVD Motor ***/
ShowAction("Stopping DVD Motor ...");
dvd_motor_off();
break;
case 7: /*** SD/PSO Reload ***/
memfile_autosave();
VIDEO_ClearFrameBuffer(vmode, xfb[whichfb], COLOR_BLACK);
VIDEO_Flush();
VIDEO_WaitVSync();
exit(0);
break;
case 8: /*** Reboot Gamecube ***/
memfile_autosave();
SYS_ResetSystem(SYS_HOTRESET,0,0);
break;
#endif
break;
}
}

View File

@ -34,9 +34,9 @@ extern void MainMenu();
extern void set_region();
extern int ManageSRAM(u8 direction, u8 device);
extern int ManageState(u8 direction, u8 device);
extern void OpenDVD();
extern int OpenDVD();
extern int OpenSD();
extern void OpenHistory();
extern int OpenHistory();
extern void memfile_autosave();
extern void memfile_autoload();