From b827c54d192b2d9133c0589c61b239c6c648c4bf Mon Sep 17 00:00:00 2001 From: dborth Date: Sat, 4 Oct 2008 02:27:05 +0000 Subject: [PATCH] DVD is FIXED! YAY! --- source/ngc/dvd.cpp | 53 ++++++++++++++++++++------------------------ source/ngc/smbop.cpp | 11 +++++++-- source/ngc/smbop.h | 2 +- 3 files changed, 34 insertions(+), 32 deletions(-) diff --git a/source/ngc/dvd.cpp b/source/ngc/dvd.cpp index d79aeee..6a1f5d5 100644 --- a/source/ngc/dvd.cpp +++ b/source/ngc/dvd.cpp @@ -52,44 +52,38 @@ unsigned char dvdbuffer[2048]; int dvd_read (void *dst, unsigned int len, u64 offset) { - - unsigned char *buffer = (unsigned char *) (unsigned int) DVDreadbuffer; - if (len > 2048) return 0; /*** We only allow 2k reads **/ - DCInvalidateRange ((void *) buffer, len); - // don't read past the end of the DVD (1.5 GB for GC DVD, 4.7 GB for DVD) - if(offset < 0x57057C00 || (isWii && offset < 0x118244F00LL)) + if((offset < 0x57057C00) || (isWii && (offset < 0x118244F00LL))) { + unsigned char *buffer = (unsigned char *) (unsigned int) DVDreadbuffer; + DCInvalidateRange ((void *) buffer, len); - #ifdef HW_DOL + #ifdef HW_DOL + dvd[0] = 0x2E; + dvd[1] = 0; + dvd[2] = 0xA8000000; + dvd[3] = (u32)(offset >> 2); + dvd[4] = len; + dvd[5] = (u32) buffer; + dvd[6] = len; + dvd[7] = 3; + + // Enable reading with DMA + while (dvd[7] & 1); + + // Ensure it has completed + if (dvd[0] & 0x4) + return 0; + #else + if (DI_ReadDVD(buffer, len >> 11, (u32)(offset >> 11))) + return 0; + #endif - dvd[0] = 0x2E; - dvd[1] = 0; - dvd[2] = 0xA8000000; - dvd[3] = (u32)(offset >> 2); - dvd[4] = len; - dvd[5] = (u32) buffer; - dvd[6] = len; - dvd[7] = 3; /*** Enable reading with DMA ***/ - while (dvd[7] & 1); memcpy (dst, buffer, len); - - if (dvd[0] & 0x4) /* Ensure it has completed */ - return 0; - return 1; - - #elif WII_DVD - int ret = 1; - ret = DI_ReadDVD(dst, len >> 11, (u32)(offset >> 11)); - if (ret==0) - return 1; - else - return 0; - #endif } return 0; @@ -476,6 +470,7 @@ LoadDVDFile () { return UnZipFile (rbuffer, discoffset); // unzip from dvd } + return dvddirlength; } diff --git a/source/ngc/smbop.cpp b/source/ngc/smbop.cpp index 0b04e05..f908cef 100644 --- a/source/ngc/smbop.cpp +++ b/source/ngc/smbop.cpp @@ -235,8 +235,15 @@ LoadSMBFile () /**************************************************************************** * Write savebuffer to SMB file ****************************************************************************/ +// no buffer specified, use savebuffer int SaveBufferToSMB (char *filepath, int datasize, bool silent) +{ + return SaveBufferToSMB((char *)savebuffer, filepath, datasize, silent); +} + +int +SaveBufferToSMB (char * sbuffer, char *filepath, int datasize, bool silent) { if(!ConnectShare (NOTSILENT)) return 0; @@ -256,10 +263,10 @@ SaveBufferToSMB (char *filepath, int datasize, bool silent) { if (dsize > 1024) wrote = - SMB_WriteFile ((char *) savebuffer + boffset, 1024, boffset, smbfile); + SMB_WriteFile ((char *) sbuffer + boffset, 1024, boffset, smbfile); else wrote = - SMB_WriteFile ((char *) savebuffer + boffset, dsize, boffset, smbfile); + SMB_WriteFile ((char *) sbuffer + boffset, dsize, boffset, smbfile); boffset += wrote; dsize -= wrote; diff --git a/source/ngc/smbop.h b/source/ngc/smbop.h index 27a0582..fa32759 100644 --- a/source/ngc/smbop.h +++ b/source/ngc/smbop.h @@ -23,5 +23,5 @@ int LoadSMBFile (); int LoadBufferFromSMB (char *filepath, bool silent); int LoadBufferFromSMB (char * sbuffer, char *filepath, bool silent); int SaveBufferToSMB (char *filepath, int datasize, bool silent); - +int SaveBufferToSMB (char * sbuffer, char *filepath, int datasize, bool silent); #endif