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

@ -20,7 +20,8 @@ current:
(IO) implemented Sega Mouse emulation (Populous 2, Body Count, Shangai 2, Fun'n Games, ...)
[Wii only]
- added lightgun & mouse support through Wiimote IR
- 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

@ -22,16 +22,15 @@
#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 u64 DvdMaxOffset = 0x57057C00; /* 1.4 GB max. */
static vu32* const dvd = (u32*)0xCC006000; /* DVD I/O Address base */
static u8 *inquiry=(unsigned char *)0x80000004; /* pointer to drive ID */
#else
static u64 DvdMaxOffset = 0x118244F00LL; /* 4.7 GB max. */
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;
@ -396,7 +396,7 @@ static void FileSelector ()
else /*** This is a file ***/
{
FileSelected();
haverom = 1;
haverom = 1;
}
redraw = 1;
}
@ -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
@ -49,7 +49,7 @@ int getpvd ()
{
if (memcmp (&dvdbuffer, "\2CD001\1", 8) == 0)
{
memcpy(&rootdir32, &dvdbuffer[PVDROOT + EXTENT], 4);
memcpy(&rootdir32, &dvdbuffer[PVDROOT + EXTENT], 4);
basedir = (u64)rootdir32;
memcpy (&rootdirlength, &dvdbuffer[PVDROOT + FILE_LENGTH], 4);
basedir <<= 11;
@ -61,8 +61,8 @@ int getpvd ()
sector++;
}
if (IsJoliet > 0) return 1; /*** Joliet PVD Found ? ***/
if (IsJoliet > 0) return 1; /*** Joliet PVD Found ? ***/
/*** Look for standard ISO9660 PVD ***/
sector = 16;
while (sector < 32)
@ -82,8 +82,8 @@ int getpvd ()
else return 0; /*** Can't read sector! ***/
sector++;
}
return (IsJoliet == 0);
return (IsJoliet == 0);
}
/****************************************************************************

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,20 +899,21 @@ 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;
}
}
load_menu = menu;
@ -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) */
@ -1103,16 +1095,16 @@ void MainMenu ()
case 2: /*** Emulator Reset ***/
if (genromsize || (config.bios_enabled == 3))
{
system_init ();
audio_init(48000);
system_reset ();
system_init ();
audio_init(48000);
system_reset ();
quit = 1;
}
break;
case 3: /*** Load ROM Menu ***/
loadmenu();
menu = 0;
loadmenu();
menu = 0;
break;
case 4: /*** Memory Manager ***/
@ -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();