- preliminary Wii DVD support (with libdi)

- misc small dvd fixes
This commit is contained in:
michniewski 2008-08-19 06:05:57 +00:00
parent 0ca6590c3f
commit 30dd0d1a0d
6 changed files with 106 additions and 47 deletions

View File

@ -28,20 +28,20 @@ INCLUDES := source/snes9x source/ngc
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE) \ CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE) \
-DNGC -DHW_RVL -DNO_ASM -DCPU_SHUTDOWN -DSPC700C \ -DNGC -DNO_ASM -DCPU_SHUTDOWN -DSPC700C \
-DSPC700_SHUTDOWN -DNEW_COLOUR_BLENDING \ -DSPC700_SHUTDOWN -DNEW_COLOUR_BLENDING \
-DNO_INLINE_GET_SET -DSDD1_DECOMP -DCORRECT_VRAM_READS \ -DNO_INLINE_GET_SET -DSDD1_DECOMP -DCORRECT_VRAM_READS \
-DDETECT_NASTY_FX_INTERLEAVE -DNGC_ZOOM -DSDUSE_LFN \ -DDETECT_NASTY_FX_INTERLEAVE -DNGC_ZOOM -DSDUSE_LFN \
-DFORCE_WII=1 $(CUSTOMFLAGS) \ -DFORCE_WII -DWII_DVD $(CUSTOMFLAGS) \
-fomit-frame-pointer -fno-exceptions -Wno-unused-parameter -pipe -fomit-frame-pointer -fno-exceptions -Wno-unused-parameter -pipe
CXXFLAGS = $(CFLAGS) CXXFLAGS = $(CFLAGS)
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map -Wl,--cref LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project # any extra libraries we wish to link with the project
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
LIBS := -lpng -lmxml -lfat -lwiiuse -lz -lbte -logc -lm -lfreetype -ltinysmb LIBS := -ldi -lpng -lmxml -lfat -lwiiuse -lz -lbte -logc -lm -lfreetype -ltinysmb
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing # list of directories containing libraries, this must be the top level containing

View File

@ -12,6 +12,10 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#ifdef WII_DVD
#include <di/di.h>
#endif
#include "menudraw.h" #include "menudraw.h"
#include "snes9xGx.h" #include "snes9xGx.h"
#include "unzip.h" #include "unzip.h"
@ -24,8 +28,10 @@ u64 dvddir = 0;
u64 dvdrootdir = 0; u64 dvdrootdir = 0;
int dvddirlength = 0; int dvddirlength = 0;
#ifdef HW_DOL
/** DVD I/O Address base **/ /** DVD I/O Address base **/
volatile unsigned long *dvd = (volatile unsigned long *) 0xCC006000; volatile unsigned long *dvd = (volatile unsigned long *) 0xCC006000;
#endif
/** Due to lack of memory, we'll use this little 2k keyhole for all DVD operations **/ /** Due to lack of memory, we'll use this little 2k keyhole for all DVD operations **/
unsigned char DVDreadbuffer[2048] ATTRIBUTE_ALIGN (32); unsigned char DVDreadbuffer[2048] ATTRIBUTE_ALIGN (32);
@ -37,10 +43,11 @@ unsigned char dvdbuffer[2048];
* *
* Gets and returns the dvd driveid * Gets and returns the dvd driveid
**/ **/
static unsigned char *inquiry=(unsigned char *)0x80000004; #ifdef HW_DOL
int dvd_driveid() int dvd_driveid()
{ {
static unsigned char *inquiry=(unsigned char *)0x80000004;
dvd[0] = 0x2e; dvd[0] = 0x2e;
dvd[1] = 0; dvd[1] = 0;
dvd[2] = 0x12000000; dvd[2] = 0x12000000;
@ -56,11 +63,14 @@ int dvd_driveid()
return (int)inquiry[2]; return (int)inquiry[2];
} }
#endif
/** /**
* dvd_read * dvd_read
* *
* The only DVD function we need - you gotta luv gc-linux self-boots! * The only DVD function we need - you gotta luv gc-linux self-boots!
* returns: 1 - ok ; 0 - error
*/ */
int int
dvd_read (void *dst, unsigned int len, u64 offset) dvd_read (void *dst, unsigned int len, u64 offset)
@ -69,32 +79,44 @@ dvd_read (void *dst, unsigned int len, u64 offset)
unsigned char *buffer = (unsigned char *) (unsigned int) DVDreadbuffer; unsigned char *buffer = (unsigned char *) (unsigned int) DVDreadbuffer;
if (len > 2048) if (len > 2048)
return 1; /*** We only allow 2k reads **/ return 0; /*** We only allow 2k reads **/
DCInvalidateRange ((void *) buffer, len); DCInvalidateRange ((void *) buffer, len);
if(offset < 0x57057C00 || (isWii == true && offset < 0x118244F00LL)) // don't read past the end of the DVD if(offset < 0x57057C00 || (isWii == true && offset < 0x118244F00LL)) // don't read past the end of the DVD
{ {
offset >>= 2; offset >>= 2;
#ifdef HW_DOL
dvd[0] = 0x2E; dvd[0] = 0x2E;
dvd[1] = 0; dvd[1] = 0;
dvd[2] = 0xA8000000; dvd[2] = 0xA8000000;
dvd[3] = (u32)offset; dvd[3] = (u32)offset;
dvd[4] = len; dvd[4] = len;
dvd[5] = (unsigned long) buffer; dvd[5] = (u32) buffer;
dvd[6] = len; dvd[6] = len;
dvd[7] = 3; /*** Enable reading with DMA ***/ dvd[7] = 3; /*** Enable reading with DMA ***/
while (dvd[7] & 1); while (dvd[7] & 1);
memcpy (dst, buffer, len); memcpy (dst, buffer, len);
}
else // Let's not read past end of DVD
return 0;
if (dvd[0] & 0x4) /* Ensure it has completed */ if (dvd[0] & 0x4) /* Ensure it has completed */
return 0; return 0;
return 1; return 1;
#elif WII_DVD
int ret = 1;
ret = DI_ReadDVD(dst, (u32)len, (u32)offset);
if (ret==0)
return 1;
else
return 0;
#endif
}
else // Let's not read past end of DVD
return 0;
} }
/** Minimal ISO Directory Definition **/ /** Minimal ISO Directory Definition **/
@ -127,7 +149,7 @@ getpvd ()
/** Look for Joliet PVD first **/ /** Look for Joliet PVD first **/
while (sector < 32) while (sector < 32)
{ {
if (dvd_read (dvdbuffer, 2048, (u64)(sector << 11))) if (dvd_read (&dvdbuffer, 2048, (u64)(sector << 11)))
{ {
if (memcmp (&dvdbuffer, "\2CD001\1", 8) == 0) if (memcmp (&dvdbuffer, "\2CD001\1", 8) == 0)
{ {
@ -180,14 +202,15 @@ getpvd ()
****************************************************************************/ ****************************************************************************/
bool TestDVD() bool TestDVD()
{ {
// DVD not available on Wii - disable
#ifdef HW_RVL
return false;
#endif
if (!getpvd()) if (!getpvd())
{ {
#ifdef HW_DOL
DVD_Mount(); DVD_Mount();
#elif WII_DVD
DI_Mount();
while(DI_GetStatus() & DVD_INIT);
#endif
if (!getpvd()) if (!getpvd())
return false; return false;
} }
@ -250,7 +273,7 @@ getentry (int entrycount)
fname[j] = 0; fname[j] = 0;
if (strlen (fname) >= MAXJOLIET) if (strlen (fname) >= MAXJOLIET)
fname[MAXJOLIET] = 0; fname[MAXJOLIET - 1] = 0;
if (strlen (fname) == 0) if (strlen (fname) == 0)
fname[0] = filename[0]; fname[0] = filename[0];
@ -285,7 +308,7 @@ getentry (int entrycount)
*rr = 0; *rr = 0;
strcpy (filelist[entrycount].filename, fname); strcpy (filelist[entrycount].filename, fname);
fname[MAXDISPLAY] = 0; fname[MAXDISPLAY - 1] = 0;
strcpy (filelist[entrycount].displayname, fname); strcpy (filelist[entrycount].displayname, fname);
memcpy (&offset32, &dvdbuffer[diroffset + EXTENT], 4); memcpy (&offset32, &dvdbuffer[diroffset + EXTENT], 4);
@ -488,6 +511,7 @@ LoadDVDFile (unsigned char *buffer)
* *
* libOGC tends to foul up if you don't, and sometimes does if you do! * libOGC tends to foul up if you don't, and sometimes does if you do!
****************************************************************************/ ****************************************************************************/
#ifdef HW_DOL
void uselessinquiry () void uselessinquiry ()
{ {
dvd[0] = 0; dvd[0] = 0;
@ -518,4 +542,5 @@ void dvd_motor_off( )
dvd[0] = 0x14; dvd[0] = 0x14;
dvd[1] = 0; dvd[1] = 0;
} }
#endif

View File

@ -19,6 +19,10 @@
#include <wiiuse/wpad.h> #include <wiiuse/wpad.h>
#include <sys/dir.h> #include <sys/dir.h>
#ifdef WII_DVD
#include <di/di.h>
#endif
#include "snes9x.h" #include "snes9x.h"
#include "memmap.h" #include "memmap.h"
@ -454,11 +458,26 @@ OpenDVD (int method)
if (!getpvd()) if (!getpvd())
{ {
ShowAction((char*) "Loading DVD..."); ShowAction((char*) "Loading DVD...");
#ifdef HW_DOL
DVD_Mount(); // mount the DVD unit again DVD_Mount(); // mount the DVD unit again
#elif WII_DVD
u32 val;
DI_GetCoverRegister(&val);
if(val & 0x1) // True if no disc inside, use (val & 0x2) for true if disc inside.
{
WaitPrompt("No disc inserted!");
return 0;
}
DI_Mount();
while(DI_GetStatus() & DVD_INIT);
#endif
if (!getpvd()) if (!getpvd())
{
WaitPrompt ((char *)"Invalid DVD.");
return 0; // not a ISO9660 DVD return 0; // not a ISO9660 DVD
} }
}
maxfiles = ParseDVDdirectory(); // load root folder maxfiles = ParseDVDdirectory(); // load root folder

View File

@ -18,6 +18,10 @@
#include <string.h> #include <string.h>
#include <wiiuse/wpad.h> #include <wiiuse/wpad.h>
#ifdef WII_DVD
#include <di/di.h>
#endif
#include "snes9x.h" #include "snes9x.h"
#include "memmap.h" #include "memmap.h"
#include "debug.h" #include "debug.h"
@ -150,8 +154,8 @@ PreferencesMenu ()
GCSettings.SaveMethod++; GCSettings.SaveMethod++;
#endif #endif
// disable DVD access in Wii mode // check if DVD access in Wii mode is disabled
#ifdef HW_RVL #ifndef WII_DVD
if(GCSettings.LoadMethod == METHOD_DVD) if(GCSettings.LoadMethod == METHOD_DVD)
GCSettings.LoadMethod++; GCSettings.LoadMethod++;
#endif #endif
@ -977,6 +981,9 @@ mainmenu (int selectedMenu)
case 6: case 6:
// Exit to Loader // Exit to Loader
#ifdef HW_RVL #ifdef HW_RVL
#ifdef WII_DVD
DI_Close();
#endif
exit(0); exit(0);
#else // gamecube #else // gamecube
if (psoid[0] == PSOSDLOADID) if (psoid[0] == PSOSDLOADID)

View File

@ -165,6 +165,10 @@
#include <sdcard/card_io.h> #include <sdcard/card_io.h>
#include <fat.h> #include <fat.h>
#ifdef WII_DVD
#include <di/di.h>
#endif
#include "snes9x.h" #include "snes9x.h"
#include "memmap.h" #include "memmap.h"
#include "debug.h" #include "debug.h"
@ -831,6 +835,10 @@ emulate ()
int int
main () main ()
{ {
#ifdef WII_DVD
DI_Init(); // first
#endif
unsigned int save_flags; unsigned int save_flags;
int selectedMenu = -1; int selectedMenu = -1;

View File

@ -401,7 +401,7 @@ clearscreen (int colour)
memcpy ((char *) xfb[whichfb], (char *) backdrop, 640 * screenheight * 2); memcpy ((char *) xfb[whichfb], (char *) backdrop, 640 * screenheight * 2);
#else #else
// on gc copy from aram // on gc copy from aram
ARAMFetch ((char *) xfb[whichfb], (char *) AR_BACKDROP, 640 * screenheight * 2); // FIX ARAMFetch ((char *) xfb[whichfb], (char *) AR_BACKDROP, 640 * screenheight * 2);
#endif #endif
} }