From edf24c73d094ed6a5cdcba0245b804f4b5c76196 Mon Sep 17 00:00:00 2001 From: Chris Moeller Date: Sun, 23 Nov 2014 22:09:46 -0800 Subject: [PATCH] Fixed a few outstanding lazyusf bugs due to failing to migrate fixes --- Frameworks/lazyusf/lazyusf/audiolib.c | 12 +++++------- Frameworks/lazyusf/lazyusf/os.c | 24 ++++++++++++------------ 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/Frameworks/lazyusf/lazyusf/audiolib.c b/Frameworks/lazyusf/lazyusf/audiolib.c index f843b16ac..c567928ea 100644 --- a/Frameworks/lazyusf/lazyusf/audiolib.c +++ b/Frameworks/lazyusf/lazyusf/audiolib.c @@ -142,7 +142,7 @@ int alEvtqPostEvent_Alt(usf_state_t * state, int paddr) { #define MIN(a,b) (((a)<(b))?(a):(b)) #endif -int32_t __nextSampleTime(usf_state_t * state, int32_t driver, int32_t *client) { +uint32_t __nextSampleTime(usf_state_t * state, uint32_t driver, uint32_t *client) { uint32_t c = 0; int32_t deltaTime = 0x7FFFFFFF; @@ -169,8 +169,8 @@ int32_t _timeToSamplesNoRound(usf_state_t * state, long synth, long micros) return (int32_t)tmp; } -int32_t byteswap(char b[4] ) { - int32_t out = 0; +uint32_t byteswap(char b[4] ) { + uint32_t out = 0; out += b[3]; out += b[2] << 8; out += b[1] << 16; @@ -180,10 +180,8 @@ int32_t byteswap(char b[4] ) { int alAudioFrame(usf_state_t * state, int paddr) { - ALPlayer *cl; uint32_t alGlobals = 0; - uint32_t driver = 0, head = 0, deltaTime = 0, c = 0, *paramSamples, *curSamples, handler = 0, dl = 0; - int32_t client = 0; + uint32_t driver = 0, *paramSamples, *curSamples, client = 0, dl = 0; uint32_t A0 = state->GPR[4].UW[0]; uint32_t A1 = state->GPR[5].UW[0]; uint32_t A2 = state->GPR[6].UW[0]; @@ -223,7 +221,7 @@ int alAudioFrame(usf_state_t * state, int paddr) { while (outLen > 0) { - int32_t maxOutSamples = 0, nOut = 0, cmdPtr = 0, output = 0, setParam = 0, handler = 0, tmp = 0x700000; + uint32_t maxOutSamples = 0, nOut = 0, cmdPtr = 0, output = 0, setParam = 0, handler = 0; maxOutSamples = N64WORD(driver + 0x48); nOut = MIN(maxOutSamples, outLen); diff --git a/Frameworks/lazyusf/lazyusf/os.c b/Frameworks/lazyusf/lazyusf/os.c index 9dc713ee7..9e1c7d267 100644 --- a/Frameworks/lazyusf/lazyusf/os.c +++ b/Frameworks/lazyusf/lazyusf/os.c @@ -165,8 +165,8 @@ int osVirtualToPhysical(usf_state_t * state, int paddr) { int osAiSetNextBuffer(usf_state_t * state, int paddr) { uint32_t var = 0, var2 = 0; - var = ((*(short*)PageRAM2(paddr + 0x4)) & 0xFFFF) << 16; - var += *(short*)PageRAM2(paddr + 0x8); + var = ((*(int16_t*)PageRAM2(paddr + 0x4)) & 0xFFFF) << 16; + var += *(int16_t*)PageRAM2(paddr + 0x8); var2 = N64WORD(var); if(AI_CONTROL_REG & 0x80000000) @@ -183,8 +183,8 @@ int saveThreadContext(usf_state_t * state, int paddr) { #if 0 uint32_t OSThreadContextAddr = 0; - OSThreadContextAddr = ((*(short*)PageRAM2(paddr)) & 0xFFFF) << 16; - OSThreadContextAddr += *(short*)PageRAM2(paddr + 0x4); + OSThreadContextAddr = ((*(int16_t*)PageRAM2(paddr)) & 0xFFFF) << 16; + OSThreadContextAddr += *(int16_t*)PageRAM2(paddr + 0x4); OSThreadContextAddr = N64WORD(OSThreadContextAddr); @@ -201,18 +201,18 @@ int loadThreadContext(usf_state_t * state, int paddr) { uint32_t i = 0, OSThreadContextAddr = 0, T9 = 0, osOSThread = 0, Addr2 = 0, GlobalBitMask = 0, Tmp = 0; uint32_t K0 = 0, K1 = 0, T0 = 0, R1 = 0, RCP = 0, intrList = 0; OSThread t; - OSThreadContextAddr = ((*(short*)PageRAM2(paddr)) & 0xFFFF) << 16; - OSThreadContextAddr += *(short*)PageRAM2(paddr + 0x8); + OSThreadContextAddr = ((*(int16_t*)PageRAM2(paddr)) & 0xFFFF) << 16; + OSThreadContextAddr += *(int16_t*)PageRAM2(paddr + 0x8); - Addr2 = ((*(short*)PageRAM2(paddr + 0xC)) & 0xFFFF) << 16; - Addr2 += *(short*)PageRAM2(paddr + 0x10); + Addr2 = ((*(int16_t*)PageRAM2(paddr + 0xC)) & 0xFFFF) << 16; + Addr2 += *(int16_t*)PageRAM2(paddr + 0x10); - GlobalBitMask = ((*(short*)PageRAM2(paddr + 0x20)) & 0xFFFF) << 16; - GlobalBitMask += *(short*)PageRAM2(paddr + 0x28); + GlobalBitMask = ((*(int16_t*)PageRAM2(paddr + 0x20)) & 0xFFFF) << 16; + GlobalBitMask += *(int16_t*)PageRAM2(paddr + 0x28); GlobalBitMask = N64WORD(GlobalBitMask); - intrList = ((*(short*)PageRAM2(paddr + 0x14C + 0x0)) & 0xFFFF) << 16; - intrList += *(short*)PageRAM2(paddr + 0x150 + 0x0); + intrList = ((*(int16_t*)PageRAM2(paddr + 0x14C + 0x0)) & 0xFFFF) << 16; + intrList += *(int16_t*)PageRAM2(paddr + 0x150 + 0x0); return 0;