From 42a72ba07ff784b10e7ed8465eb586f879ba53c8 Mon Sep 17 00:00:00 2001 From: Liam Coleman Date: Sat, 16 Nov 2024 21:02:31 -0600 Subject: [PATCH] More TU Matching in PAL (#469) * Fix w20Dll linking * Match some more TUs in PAL * Fix NTSC Build --- configure.py | 10 +-- include/dolphin/gx/GXFrameBuffer.h | 1 + src/game/audio.c | 7 ++- src/game/card.c | 5 ++ src/game/init.c | 29 ++++++++- src/game/main.c | 9 ++- src/game/saveload.c | 99 ++++++++++++++++++++++++++---- 7 files changed, 138 insertions(+), 22 deletions(-) diff --git a/configure.py b/configure.py index 9a885735..2456a535 100644 --- a/configure.py +++ b/configure.py @@ -373,13 +373,13 @@ config.libs = [ "cflags": cflags_game, "host": False, "objects": [ - Object(MatchingFor("GMPE01_00", "GMPE01_01"), "game/main.c"), + Object(Matching, "game/main.c"), Object(Matching, "game/pad.c"), Object(Matching, "game/dvd.c"), Object(Matching, "game/data.c"), Object(Matching, "game/decode.c"), Object(Matching, "game/font.c"), - Object(MatchingFor("GMPE01_00", "GMPE01_01"), "game/init.c"), + Object(Matching, "game/init.c"), Object(Matching, "game/jmp.c"), Object(Matching, "game/malloc.c"), Object(Matching, "game/memory.c"), @@ -400,7 +400,7 @@ config.libs = [ Object(Matching, "game/objsysobj.c"), Object(Matching, "game/objdll.c"), Object(Matching, "game/frand.c"), - Object(MatchingFor("GMPE01_00", "GMPE01_01"), "game/audio.c"), + Object(Matching, "game/audio.c"), Object(Matching, "game/EnvelopeExec.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "game/minigame_seq.c"), Object(Matching, "game/ovllist.c"), @@ -411,7 +411,7 @@ config.libs = [ Object(Matching, "game/wipe.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "game/window.c"), Object(Matching, "game/messdata.c"), - Object(MatchingFor("GMPE01_00", "GMPE01_01"), "game/card.c"), + Object(Matching, "game/card.c"), Object(Matching, "game/armem.c"), Object(Matching, "game/chrman.c"), Object(Matching, "game/mapspace.c"), @@ -420,7 +420,7 @@ config.libs = [ Object(Matching, "game/thpmain.c"), Object(Matching, "game/objsub.c"), Object(Matching, "game/flag.c"), - Object(MatchingFor("GMPE01_00", "GMPE01_01"), "game/saveload.c"), + Object(Matching, "game/saveload.c"), Object(Matching, "game/sreset.c"), Object(Matching, "game/board/main.c"), Object(Matching, "game/board/player.c"), diff --git a/include/dolphin/gx/GXFrameBuffer.h b/include/dolphin/gx/GXFrameBuffer.h index ebd81e78..f5785f8c 100644 --- a/include/dolphin/gx/GXFrameBuffer.h +++ b/include/dolphin/gx/GXFrameBuffer.h @@ -47,6 +47,7 @@ void GXCopyDisp(void* dest, GXBool clear); void GXSetDispCopyGamma(GXGamma gamma); void GXSetDispCopySrc(u16 left, u16 top, u16 wd, u16 ht); void GXSetDispCopyDst(u16 wd, u16 ht); +f32 GXGetYScaleFactor(u16 efbHeight, u16 xfbHeight); u32 GXSetDispCopyYScale(f32 vscale); void GXSetCopyFilter(GXBool aa, u8 sample_pattern[12][2], GXBool vf, u8 vfilter[7]); void GXSetPixelFmt(GXPixelFmt pix_fmt, GXZFmt16 z_fmt); diff --git a/src/game/audio.c b/src/game/audio.c index 808369d4..8b01f192 100644 --- a/src/game/audio.c +++ b/src/game/audio.c @@ -555,10 +555,11 @@ void HuAudAUXVolSet(s8 arg0, s8 arg1) { void HuAudVoiceInit(s16 ovl) { SNDGRPTBL *var_r29; OSTick temp_r23; + s16 var_r27; s16 temp_r26; s16 temp_r25; s16 temp_r30; - s16 var_r27; + void *temp_r3; s16 i; @@ -602,7 +603,11 @@ void HuAudVoiceInit(s16 ovl) { charVoiceGroupStat[temp_r30] = 1; temp_r26 = temp_r30 + 0xA; temp_r3 = HuMemDirectMalloc(HEAP_DATA, msmSysGetSampSize(temp_r26)); + #if VERSION_NTSC msmSysLoadGroupBase(temp_r26, temp_r3); + #else + temp_r25 = msmSysLoadGroupBase(temp_r26, temp_r3); + #endif HuMemDirectFree(temp_r3); } } diff --git a/src/game/card.c b/src/game/card.c index 845bf3b0..97fdd32d 100644 --- a/src/game/card.c +++ b/src/game/card.c @@ -1,6 +1,7 @@ #include "dolphin.h" #include "game/memory.h" #include "game/card.h" +#include "version.h" static void *cardWork; u8 UnMountCnt; @@ -98,7 +99,11 @@ s32 HuCardFormat(s16 slot) static void MountCallBack(s32 chan, s32 result) { + #if VERSION_ENG UnMountCnt = (1 << chan); + #else + UnMountCnt |= (1 << chan); + #endif } s32 HuCardOpen(s16 slot, const char *fileName, CARDFileInfo *fileInfo) diff --git a/src/game/init.c b/src/game/init.c index f3a4f853..61315c66 100644 --- a/src/game/init.c +++ b/src/game/init.c @@ -39,6 +39,8 @@ static void InitVI(); static void SwapBuffers(); static void LoadMemInfo(); +#define ASSERT_LINE(ntsc, pal) ((VERSION_NTSC) ? (ntsc) : (pal)) + void HuSysInit(GXRenderModeObj *mode) { u32 rnd_temp; @@ -46,13 +48,19 @@ void HuSysInit(GXRenderModeObj *mode) DVDInit(); VIInit(); PADInit(); + #if VERSION_NTSC if(OSGetProgressiveMode() == 1 && VIGetDTVStatus() == 1) { mode = &GXNtsc480Prog; } + #else + mode->efbHeight = 480; + #endif InitRenderMode(mode); InitMem(); VIConfigure(RenderMode); + #if VERSION_NTSC VIConfigurePan(0, 0, 640, 480); + #endif DefaultFifo = OSAlloc(0x100000); DefaultFifoObj = GXInit(DefaultFifo, 0x100000); InitGX(); @@ -91,7 +99,7 @@ static void InitRenderMode(GXRenderModeObj *mode) break; default: - OSPanic("init.c", 169, "DEMOInit: invalid TV format\n"); + OSPanic("init.c", ASSERT_LINE(169, 167), "DEMOInit: invalid TV format\n"); break; } GXAdjustForOverscan(RenderMode, &rmodeobj, 0, 16); @@ -104,7 +112,12 @@ static void InitGX() GXSetScissor(0, 0, RenderMode->fbWidth, RenderMode->efbHeight); GXSetDispCopySrc(0, 0, RenderMode->fbWidth, RenderMode->efbHeight); GXSetDispCopyDst(RenderMode->fbWidth, RenderMode->xfbHeight); + #if VERSION_NTSC GXSetDispCopyYScale((float)RenderMode->xfbHeight/(float)RenderMode->efbHeight); + #else + OSReport("%D\n", RenderMode->xfbHeight); + GXSetDispCopyYScale(GXGetYScaleFactor(RenderMode->efbHeight, RenderMode->xfbHeight)); + #endif GXSetCopyFilter(RenderMode->aa, RenderMode->sample_pattern, GX_TRUE, RenderMode->vfilter); if(RenderMode->aa) { GXSetPixelFmt(GX_PF_RGB565_Z16, GX_ZC_LINEAR); @@ -120,9 +133,21 @@ static void InitMem() void *arena_lo = OSGetArenaLo(); void *arena_hi = OSGetArenaHi(); u32 fb_size = (u16)(((u16)RenderMode->fbWidth+15) & ~15)*RenderMode->xfbHeight*2; + u32 *fb1; + u32 *fb2; + u32 i; DemoFrameBuffer1 = (void *)OSRoundUp32B((u32)arena_lo); DemoFrameBuffer2 = (void *)OSRoundUp32B((u32)DemoFrameBuffer1+fb_size); DemoCurrentBuffer = DemoFrameBuffer2; + #if VERSION_PAL + fb1 = DemoFrameBuffer1; + fb2 = DemoFrameBuffer2; + for(i=0; i