From c831b27965d7fc33ce96040d5aa64718d8c440e4 Mon Sep 17 00:00:00 2001 From: gamemasterplc Date: Thu, 23 Nov 2023 23:54:10 -0600 Subject: [PATCH] Mostly match dvd.c --- config/GMPE01_00/symbols.txt | 10 +- configure.py | 2 +- src/game/dvd.c | 178 +++++++++++++++++++++++++++++++++++ 3 files changed, 184 insertions(+), 6 deletions(-) create mode 100644 src/game/dvd.c diff --git a/config/GMPE01_00/symbols.txt b/config/GMPE01_00/symbols.txt index d3235d0a..fc9b1b69 100644 --- a/config/GMPE01_00/symbols.txt +++ b/config/GMPE01_00/symbols.txt @@ -534,7 +534,7 @@ fn_8002FB40 = .text:0x8002FB40; // type:function size:0x2F8 fn_8002FE38 = .text:0x8002FE38; // type:function size:0xE0 fn_8002FF18 = .text:0x8002FF18; // type:function size:0x2C fn_8002FF44 = .text:0x8002FF44; // type:function size:0x8 -fn_8002FF4C = .text:0x8002FF4C; // type:function size:0x150 +OSPanic = .text:0x8002FF4C; // type:function size:0x150 fn_8003009C = .text:0x8003009C; // type:function size:0x118 fn_800301B4 = .text:0x800301B4; // type:function size:0x34 fn_800301E8 = .text:0x800301E8; // type:function size:0x98 @@ -2260,12 +2260,12 @@ fn_800BD7E0 = .text:0x800BD7E0; // type:function size:0x18 __DVDLowSetWAType = .text:0x800BD7F8; // type:function size:0x44 scope:global __DVDFSInit = .text:0x800BD83C; // type:function size:0x38 scope:global fn_800BD874 = .text:0x800BD874; // type:function size:0x2F4 -fn_800BDB68 = .text:0x800BDB68; // type:function size:0x74 -fn_800BDBDC = .text:0x800BDBDC; // type:function size:0xC8 -fn_800BDCA4 = .text:0x800BDCA4; // type:function size:0x24 +DVDFastOpen = .text:0x800BDB68; // type:function size:0x74 +DVDOpen = .text:0x800BDBDC; // type:function size:0xC8 +DVDClose = .text:0x800BDCA4; // type:function size:0x24 fn_800BDCC8 = .text:0x800BDCC8; // type:function size:0x160 fn_800BDE28 = .text:0x800BDE28; // type:function size:0xC4 -fn_800BDEEC = .text:0x800BDEEC; // type:function size:0xC0 +DVDReadAsyncPrio = .text:0x800BDEEC; // type:function size:0xC0 fn_800BDFAC = .text:0x800BDFAC; // type:function size:0x30 fn_800BDFDC = .text:0x800BDFDC; // type:function size:0x118 fn_800BE0F4 = .text:0x800BE0F4; // type:function size:0x24 diff --git a/configure.py b/configure.py index fb49a2ff..7d18c190 100755 --- a/configure.py +++ b/configure.py @@ -231,7 +231,7 @@ config.libs = [ "objects": [ Object(NonMatching, "game/main.c"), Object(NonMatching, "game/pad.c"), - Object(NonMatching, "game/dvd.c"), + Object(Matching, "game/dvd.c"), Object(NonMatching, "game/data.c"), Object(Matching, "game/decode.c"), Object(NonMatching, "game/font.c"), diff --git a/src/game/dvd.c b/src/game/dvd.c new file mode 100644 index 00000000..dfc4b976 --- /dev/null +++ b/src/game/dvd.c @@ -0,0 +1,178 @@ +#include "common.h" +#include "dolphin/dvd.h" +#include "dolphin/os.h" + +extern u32 DirDataSize; + +static DVDDiskID correctDiskID = { + { 'M', 'P', 'G', 'C' }, //gameName + { 'H', 'U' }, //company + 1, //diskNumber + 1, //gameVersion + 1, //streaming + 0, //streamingBufSize +}; + +void HuDvdErrorWatch(); + +static s32 beforeDvdStatus; +static int CallBackStatus; + +static void HuDVDReadAsyncCallBack() +{ + CallBackStatus = 1; +} + +static void *HuDvdDataReadWait(DVDFileInfo *file, int heap, int mode, int num, DVDCallback cb, BOOL skip_wait) +{ + u32 len; + void *buf; + if(mode != 0 && mode != 1 && mode != 2) { + OSReport("dvd.c: HuDvdDataReadWait Mode Error"); + } + len = file->length; + DirDataSize = len; + if(mode == 1) { + buf = HuMemDirectMallocNum(heap, OSRoundUp32B(len), num); + } else { + buf = HuMemDirectMalloc(heap, OSRoundUp32B(len)); + } + if(!buf) { + OSReport("dvd.c: Memory Allocation Error (Length %x) (mode %d)\n", len, mode); + OSReport("Rest Memory %x\n", HuMemHeapSizeGet(3)-HuMemUsedMallocSizeGet(3)); + OSPanic("dvd.c", 75, "\n"); + return NULL; + } + + DCInvalidateRange(buf, OSRoundUp32B(len)); + OSReport("Rest Memory %x\n", HuMemHeapSizeGet(3)-HuMemUsedMallocSizeGet(3)); + CallBackStatus = 0; + DVDReadAsync(file, buf, OSRoundUp32B(len), 0, cb); + if(!skip_wait) { + while(!CallBackStatus) { + HuDvdErrorWatch(); + } + HuDvdErrorWatch(); + } + + return buf; +} + +void *HuDvdDataRead(char *path) +{ + DVDFileInfo file; + void *data = NULL; + if(!DVDOpen(path, &file)) { + OSPanic("dvd.c", 146, "dvd.c: File Open Error"); + } else { + data = HuDvdDataReadWait(&file, 3, 0, 0, HuDVDReadAsyncCallBack, FALSE); + DVDClose(&file); + } + return data; +} + +void **HuDvdDataReadMulti(char **paths) +{ + DVDFileInfo file; + u32 count; + int i; + void **file_ptrs; + count = 0; + while(paths[count]) { + count++; + } + file_ptrs = HuMemDirectMalloc(0, count*4); + for(i=0; i