From 11806f7ac950324b72262a0b8ac5f412f26d2e71 Mon Sep 17 00:00:00 2001 From: EpochFlame Date: Tue, 12 Sep 2023 21:16:31 -0400 Subject: [PATCH] match most of THPVideoDecode.c also fix OSMessage types for better accuracy --- .vscode/settings.json | 3 +- docs/recommended_todo.md | 6 +- include/Dolphin/OS/OSMessage.h | 14 +- include/THP/THPAudioDecode.h | 2 +- include/THP/THPVideoDecode.h | 13 +- src/Dolphin/os/OSMessage.c | 12 +- src/sysGCU/THPVideoDecode.c | 610 +++++++++------------------------ tools/progress.csv | 2 + 8 files changed, 196 insertions(+), 466 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 431261a4d..802530beb 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -25,6 +25,7 @@ "thpfile.h": "c", "thpaudiodecode.h": "c", "thpdraw.h": "c", - "thpplayer.h": "c" + "thpplayer.h": "c", + "thpvideodecode.h": "c" } } \ No newline at end of file diff --git a/docs/recommended_todo.md b/docs/recommended_todo.md index f865f8373..25a9282a0 100644 --- a/docs/recommended_todo.md +++ b/docs/recommended_todo.md @@ -185,9 +185,9 @@ | JSTObjectSpecialActor.cpp | 2289 | illustratedBookMessage.cpp | 2964 | | captionMessage.cpp | 3528 | messageObj.cpp | 4504 | | aramMgr.cpp | 4920 | gameflow.cpp | 5333 | -| messageMgr.cpp | 6825 | THPRead.c | 7129 | -| section.cpp | 7138 | moviePlayerPauseAndDraw.cpp | 8587 | -| screenScene.cpp | 9274 | THPVideoDecode.c | 10029 | +| messageMgr.cpp | 6825 | THPVideoDecode.c | 6852 | +| THPRead.c | 7129 | section.cpp | 7138 | +| moviePlayerPauseAndDraw.cpp | 8587 | screenScene.cpp | 9274 | | JSTObjectParticleActor.cpp | 11032 | loadResource.cpp | 11781 | | heapStatus.cpp | 12405 | dvdThread.cpp | 12535 | | JSTObjectCamera.cpp | 12894 | P2DScreen.cpp | 12998 | diff --git a/include/Dolphin/OS/OSMessage.h b/include/Dolphin/OS/OSMessage.h index 51021fb97..2bc49a742 100644 --- a/include/Dolphin/OS/OSMessage.h +++ b/include/Dolphin/OS/OSMessage.h @@ -20,9 +20,9 @@ struct OSMessageQueue { OSThreadQueue queueSend; // _00 OSThreadQueue queueReceive; // _08 OSMessage* msgArray; // _10, array of messages. - int msgCount; // _14, array limit size. - int firstIndex; // _18, first message index in array. - int usedCount; // _1C, actual number of used messages. + s32 msgCount; // _14, array limit size. + s32 firstIndex; // _18, first message index in array. + s32 usedCount; // _1C, actual number of used messages. }; // Defines for message flags for sending/receiving. @@ -37,10 +37,10 @@ typedef enum { /////// MESSAGE FUNCTIONS //////// // Functions for handling messages. -void OSInitMessageQueue(OSMessageQueue* queue, OSMessage* msgArray, int msgCount); -BOOL OSSendMessage(OSMessageQueue* queue, OSMessage msg, int flags); -BOOL OSJamMessage(OSMessageQueue* queue, OSMessage msg, int flags); -BOOL OSReceiveMessage(OSMessageQueue* queue, OSMessage* msgPtr, int flags); +void OSInitMessageQueue(OSMessageQueue* queue, OSMessage* msgArray, s32 msgCount); +BOOL OSSendMessage(OSMessageQueue* queue, OSMessage msg, s32 flags); +BOOL OSJamMessage(OSMessageQueue* queue, OSMessage msg, s32 flags); +BOOL OSReceiveMessage(OSMessageQueue* queue, OSMessage* msgPtr, s32 flags); ////////////////////////////////// diff --git a/include/THP/THPAudioDecode.h b/include/THP/THPAudioDecode.h index df44ed29f..84394dcbe 100644 --- a/include/THP/THPAudioDecode.h +++ b/include/THP/THPAudioDecode.h @@ -10,7 +10,7 @@ static void AudioDecode(THPReadBuffer* readBuffer); #ifdef __cplusplus extern "C" { #endif -int THPAudioDecode(s16* arg1, u8* arg2, int arg3); // TODO: determine args and name properly +int THPAudioDecode(s16* buffer, u8* frame, s32 flags); // TODO: determine args and name properly BOOL CreateAudioDecodeThread(OSPriority prio, void* param); void AudioDecodeThreadStart(); diff --git a/include/THP/THPVideoDecode.h b/include/THP/THPVideoDecode.h index 00d67f60e..8c6f60854 100644 --- a/include/THP/THPVideoDecode.h +++ b/include/THP/THPVideoDecode.h @@ -5,19 +5,20 @@ #include "THP/THPRead.h" #include "types.h" +static void* VideoDecoder(void*); +static void* VideoDecoderForOnMemory(void*); +static void VideoDecode(THPReadBuffer*); + #ifdef __cplusplus extern "C" { #endif // ifdef __cplusplus - -BOOL CreateVideoDecodeThread(int, void*); +s32 THPVideoDecode(void* file, void* tileY, void* tileU, void* tileV, void* work); +BOOL CreateVideoDecodeThread(OSPriority priority, void* task); void VideoDecodeThreadStart(); void VideoDecodeThreadCancel(); -void VideoDecoder(void*); -void VideoDecoderForOnMemory(void*); -void VideoDecode(THPReadBuffer*); OSMessage PopFreeTextureSet(); BOOL PushFreeTextureSet(OSMessage*); -OSMessage PopDecodedTextureSet(); +OSMessage PopDecodedTextureSet(s32 flags); BOOL PushDecodedTextureSet(OSMessage*); extern BOOL VideoDecodeThreadCreated; diff --git a/src/Dolphin/os/OSMessage.c b/src/Dolphin/os/OSMessage.c index c9a43a0ab..9d1c66c23 100644 --- a/src/Dolphin/os/OSMessage.c +++ b/src/Dolphin/os/OSMessage.c @@ -7,12 +7,12 @@ * Address: 800EF4BC * Size: 000060 */ -void OSInitMessageQueue(OSMessageQueue* queue, void** buffer, int capacity) +void OSInitMessageQueue(OSMessageQueue* queue, OSMessage* msgArray, s32 msgCount) { OSInitThreadQueue(&queue->queueSend); OSInitThreadQueue(&queue->queueReceive); - queue->msgArray = buffer; - queue->msgCount = capacity; + queue->msgArray = msgArray; + queue->msgCount = msgCount; queue->firstIndex = 0; queue->usedCount = 0; } @@ -27,7 +27,7 @@ void OSInitMessageQueue(OSMessageQueue* queue, void** buffer, int capacity) * Address: 800EF51C * Size: 0000C8 */ -BOOL OSSendMessage(OSMessageQueue* queue, void* msg, int flags) +BOOL OSSendMessage(OSMessageQueue* queue, void* msg, s32 flags) { int mesgId; u32 interrupt; @@ -57,7 +57,7 @@ BOOL OSSendMessage(OSMessageQueue* queue, void* msg, int flags) * Address: 800EF5E4 * Size: 0000DC */ -BOOL OSReceiveMessage(OSMessageQueue* queue, void** buffer, int flags) +BOOL OSReceiveMessage(OSMessageQueue* queue, void** buffer, s32 flags) { u32 interrupt; @@ -89,7 +89,7 @@ BOOL OSReceiveMessage(OSMessageQueue* queue, void** buffer, int flags) * Address: 800EF6C0 * Size: 0000D4 */ -BOOL OSJamMessage(OSMessageQueue* queue, void* msg, int flags) +BOOL OSJamMessage(OSMessageQueue* queue, void* msg, s32 flags) { s32 lastMesg; u32 interrupt; diff --git a/src/sysGCU/THPVideoDecode.c b/src/sysGCU/THPVideoDecode.c index 7e9ec75d7..17e0d504e 100644 --- a/src/sysGCU/THPVideoDecode.c +++ b/src/sysGCU/THPVideoDecode.c @@ -1,76 +1,44 @@ #include "THP/THPVideoDecode.h" +#include "THP/THPPlayer.h" #include "types.h" +#define STACK_SIZE 4096 +#define BUFFER_COUNT 3 + +static OSThread VideoDecodeThread; +static u8 VideoDecodeThreadStack[STACK_SIZE]; +static OSMessageQueue FreeTextureSetQueue; +static OSMessageQueue DecodedTextureSetQueue; +static OSMessage FreeTextureSetMessage[BUFFER_COUNT]; +static OSMessage DecodedTextureSetMessage[BUFFER_COUNT]; + +static BOOL VideoDecodeThreadCreated; +static BOOL First; + /* * --INFO-- * Address: 8044F8B4 * Size: 0000D8 */ -BOOL CreateVideoDecodeThread(int priority, void* taskMaybe) +BOOL CreateVideoDecodeThread(OSPriority priority, void* task) { - /* - .loc_0x0: - stwu r1, -0x10(r1) - mflr r0 - cmplwi r4, 0 - lis r5, 0x8050 - stw r0, 0x14(r1) - stw r31, 0xC(r1) - addi r31, r5, 0x5710 - beq- .loc_0x5C - lis r5, 0x8045 - addi r6, r31, 0x318 - subi r0, r5, 0x53C - mr r8, r3 - mr r5, r4 - addi r3, r31, 0 - mr r4, r0 - li r7, 0x1000 - li r9, 0x1 - addi r6, r6, 0x1000 - bl -0x35D930 - cmpwi r3, 0 - bne- .loc_0x94 - li r3, 0 - b .loc_0xC4 - - .loc_0x5C: - lis r4, 0x8045 - addi r6, r31, 0x318 - mr r8, r3 - addi r3, r31, 0 - subi r4, r4, 0x604 - li r5, 0 - li r7, 0x1000 - li r9, 0x1 - addi r6, r6, 0x1000 - bl -0x35D968 - cmpwi r3, 0 - bne- .loc_0x94 - li r3, 0 - b .loc_0xC4 - - .loc_0x94: - addi r3, r31, 0x1318 - addi r4, r31, 0x1358 - li r5, 0x3 - bl -0x360498 - addi r3, r31, 0x1338 - addi r4, r31, 0x1364 - li r5, 0x3 - bl -0x3604A8 - li r0, 0x1 - li r3, 0x1 - stw r0, -0x63A8(r13) - stw r0, -0x63A4(r13) - - .loc_0xC4: - lwz r0, 0x14(r1) - lwz r31, 0xC(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + BOOL res; + if (task) { + res = OSCreateThread(&VideoDecodeThread, VideoDecoderForOnMemory, task, VideoDecodeThreadStack + STACK_SIZE, STACK_SIZE, priority, + 1); + if (res == FALSE) + return FALSE; + } else { + res = OSCreateThread(&VideoDecodeThread, VideoDecoder, NULL, VideoDecodeThreadStack + STACK_SIZE, STACK_SIZE, priority, 1); + if (res == FALSE) + return FALSE; + } + + OSInitMessageQueue(&FreeTextureSetQueue, FreeTextureSetMessage, BUFFER_COUNT); + OSInitMessageQueue(&DecodedTextureSetQueue, DecodedTextureSetMessage, BUFFER_COUNT); + VideoDecodeThreadCreated = TRUE; + First = TRUE; + return TRUE; } /* @@ -78,26 +46,10 @@ BOOL CreateVideoDecodeThread(int priority, void* taskMaybe) * Address: 8044F98C * Size: 000034 */ -void VideoDecodeThreadStart(void) +void VideoDecodeThreadStart() { - /* - .loc_0x0: - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - lwz r0, -0x63A8(r13) - cmpwi r0, 0 - beq- .loc_0x24 - lis r3, 0x8050 - addi r3, r3, 0x5710 - bl -0x35D4B8 - - .loc_0x24: - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + if (VideoDecodeThreadCreated) + OSResumeThread(&VideoDecodeThread); } /* @@ -105,28 +57,12 @@ void VideoDecodeThreadStart(void) * Address: 8044F9C0 * Size: 00003C */ -void VideoDecodeThreadCancel(void) +void VideoDecodeThreadCancel() { - /* - .loc_0x0: - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - lwz r0, -0x63A8(r13) - cmpwi r0, 0 - beq- .loc_0x2C - lis r3, 0x8050 - addi r3, r3, 0x5710 - bl -0x35D748 - li r0, 0 - stw r0, -0x63A8(r13) - - .loc_0x2C: - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + if (VideoDecodeThreadCreated) { + OSCancelThread(&VideoDecodeThread); + VideoDecodeThreadCreated = FALSE; + } } /* @@ -134,75 +70,34 @@ void VideoDecodeThreadCancel(void) * Address: 8044F9FC * Size: 0000C8 */ -void VideoDecoder(void*) +static void* VideoDecoder(void* arg) { - /* - .loc_0x0: - stwu r1, -0x10(r1) - mflr r0 - lis r3, 0x8051 - stw r0, 0x14(r1) - stw r31, 0xC(r1) - addi r31, r3, 0x4490 - stw r30, 0x8(r1) - - .loc_0x1C: - lbz r0, 0xA7(r31) - cmplwi r0, 0 - beq- .loc_0x94 - b .loc_0x88 - - .loc_0x2C: - bl -0x1D8 - lwz r4, 0xC0(r31) - mr r30, r3 - lwz r5, 0x4(r3) - lwz r6, 0x50(r31) - add r5, r5, r4 - divwu r4, r5, r6 - subi r0, r6, 0x1 - mullw r4, r4, r6 - sub r4, r5, r4 - cmplw r4, r0 - bne- .loc_0x6C - lbz r0, 0xA6(r31) - rlwinm. r0,r0,0,31,31 - bne- .loc_0x6C - bl 0x194 - - .loc_0x6C: - mr r3, r30 - bl -0x24C - bl -0x360E38 - lwz r4, 0xD8(r31) - addi r0, r4, 0x1 - stw r0, 0xD8(r31) - bl -0x360E20 - - .loc_0x88: - lwz r0, 0xD8(r31) - cmpwi r0, 0 - blt+ .loc_0x2C - - .loc_0x94: - lbz r0, 0xA7(r31) - cmplwi r0, 0 - beq- .loc_0xAC - bl -0x24C - mr r30, r3 - b .loc_0xB4 - - .loc_0xAC: - bl -0x320 - mr r30, r3 - - .loc_0xB4: - mr r3, r30 - bl 0x144 - mr r3, r30 - bl -0x29C - b .loc_0x1C - */ + THPReadBuffer* thpBuffer; + int decodedFrame = ActivePlayer.mVideoDecodeCount; + + while (TRUE) { + if (ActivePlayer.mAudioExist) { + for (; ActivePlayer.mVideoDecodeCount < 0; decodedFrame--) { + thpBuffer = (THPReadBuffer*)PopReadedBuffer2(); + s32 curFrame = (thpBuffer->mFrameNumber + ActivePlayer.mInitReadFrame); + s32 remaining = (curFrame % ActivePlayer.mHeader.mNumFrames); + if (remaining == (ActivePlayer.mHeader.mNumFrames - 1) && (ActivePlayer.mPlayFlag & 1) == 0) + VideoDecode(thpBuffer); + + PushFreeReadBuffer((OSMessage*)thpBuffer); + OSDisableInterrupts(); + OSRestoreInterrupts(ActivePlayer.mVideoDecodeCount++); // regswap r3/r4 here + } + } + + if (ActivePlayer.mAudioExist) + thpBuffer = (THPReadBuffer*)PopReadedBuffer2(); + else + thpBuffer = (THPReadBuffer*)PopReadedBuffer(); + + VideoDecode(thpBuffer); + PushFreeReadBuffer((OSMessage*)thpBuffer); + } } /* @@ -210,108 +105,60 @@ void VideoDecoder(void*) * Address: 8044FAC4 * Size: 000134 */ -void VideoDecoderForOnMemory(void*) +static void* VideoDecoderForOnMemory(void* arg) { - /* - .loc_0x0: - stwu r1, -0x30(r1) - mflr r0 - lis r4, 0x8051 - stw r0, 0x34(r1) - stw r31, 0x2C(r1) - addi r31, r4, 0x4490 - stw r30, 0x28(r1) - stw r29, 0x24(r1) - li r29, 0 - stw r3, 0x8(r1) - lwz r30, 0xBC(r31) - - .loc_0x2C: - lbz r0, 0xA7(r31) - cmplwi r0, 0 - beq- .loc_0xB8 - b .loc_0xAC - - .loc_0x3C: - bl -0x360EC8 - lwz r4, 0xD8(r31) - addi r0, r4, 0x1 - stw r0, 0xD8(r31) - bl -0x360EB0 - lwz r0, 0xC0(r31) - lwz r5, 0x50(r31) - add r4, r29, r0 - divwu r3, r4, r5 - subi r0, r5, 0x1 - mullw r3, r3, r5 - sub r3, r4, r3 - cmplw r3, r0 - bne- .loc_0x94 - lbz r0, 0xA6(r31) - rlwinm. r0,r0,0,31,31 - beq- .loc_0xB8 - lwz r3, 0x8(r1) - lwz r0, 0xB4(r31) - lwz r30, 0x0(r3) - stw r0, 0x8(r1) - b .loc_0xA8 - - .loc_0x94: - lwz r3, 0x8(r1) - lwz r4, 0x0(r3) - add r0, r3, r30 - stw r0, 0x8(r1) - mr r30, r4 - - .loc_0xA8: - addi r29, r29, 0x1 - - .loc_0xAC: - lwz r0, 0xD8(r31) - cmpwi r0, 0 - blt+ .loc_0x3C - - .loc_0xB8: - stw r29, 0xC(r1) - addi r3, r1, 0x8 - bl .loc_0x134 - lwz r0, 0xC0(r31) - lwz r5, 0x50(r31) - add r4, r29, r0 - divwu r3, r4, r5 - subi r0, r5, 0x1 - mullw r3, r3, r5 - sub r3, r4, r3 - cmplw r3, r0 - bne- .loc_0x118 - lbz r0, 0xA6(r31) - rlwinm. r0,r0,0,31,31 - beq- .loc_0x108 - lwz r3, 0x8(r1) - lwz r0, 0xB4(r31) - lwz r30, 0x0(r3) - stw r0, 0x8(r1) - b .loc_0x12C - - .loc_0x108: - lis r3, 0x8050 - addi r3, r3, 0x5710 - bl -0x35D458 - b .loc_0x12C - - .loc_0x118: - lwz r3, 0x8(r1) - lwz r4, 0x0(r3) - add r0, r3, r30 - stw r0, 0x8(r1) - mr r30, r4 - - .loc_0x12C: - addi r29, r29, 0x1 - b .loc_0x2C - - .loc_0x134: - */ + s32 readSize; + s32 frame; + u32 i; + THPReadBuffer readBuffer; + + frame = 0; + i = 0; + readSize = ActivePlayer.mInitReadSize; + + readBuffer.mPtr = (u8*)arg; + while (TRUE) { + if (ActivePlayer.mAudioExist) { + OSDisableInterrupts(); + OSRestoreInterrupts(ActivePlayer.mVideoDecodeCount++); // regswap r3/r4 here + while (i--) { + ActivePlayer.mVideoDecodeCount++; + s32 remaining = (frame + ActivePlayer.mInitReadFrame) % ActivePlayer.mHeader.mNumFrames; + if (remaining == ActivePlayer.mHeader.mNumFrames - 1) { + if ((ActivePlayer.mPlayFlag & 1) == 0) + break; + + readSize = *(s32*)readBuffer.mPtr; + readBuffer.mPtr = ActivePlayer.mMovieData; + } else { + s32 size = *(s32*)readBuffer.mPtr; + readBuffer.mPtr += readSize; + readSize = size; + } + frame++; + } + } + + readBuffer.mFrameNumber = frame; + + VideoDecode(&readBuffer); + + s32 remaining = (frame + ActivePlayer.mInitReadFrame) % ActivePlayer.mHeader.mNumFrames; + if (remaining == ActivePlayer.mHeader.mNumFrames - 1) { + if ((ActivePlayer.mPlayFlag & 1)) { + readSize = *(s32*)readBuffer.mPtr; + readBuffer.mPtr = ActivePlayer.mMovieData; + } else { + OSSuspendThread(&VideoDecodeThread); + } + } else { + s32 size = *(s32*)readBuffer.mPtr; + readBuffer.mPtr += readSize; + readSize = size; + } + + frame++; + } } /* @@ -319,99 +166,44 @@ void VideoDecoderForOnMemory(void*) * Address: 8044FBF8 * Size: 000120 */ -void VideoDecode(THPReadBuffer* buffer) +static void VideoDecode(THPReadBuffer* readBuffer) { - /* - .loc_0x0: - stwu r1, -0x30(r1) - mflr r0 - lis r4, 0x8051 - stw r0, 0x34(r1) - stmw r24, 0x10(r1) - addi r31, r4, 0x4490 - mr r27, r3 - lwz r0, 0x6C(r31) - lwz r4, 0x0(r3) - rlwinm r3,r0,2,0,29 - addi r28, r3, 0x8 - addi r29, r4, 0x8 - add r28, r4, r28 - bl .loc_0x120 - lis r4, 0x8051 - li r30, 0 - addi r26, r4, 0x4490 - mr r24, r3 - mr r25, r26 - b .loc_0xE4 - - .loc_0x50: - lbz r0, 0x70(r25) - cmpwi r0, 0 - beq- .loc_0x60 - b .loc_0xD0 - - .loc_0x60: - lwz r4, 0x0(r24) - mr r3, r28 - lwz r5, 0x4(r24) - lwz r6, 0x8(r24) - lwz r7, 0x9C(r26) - bl -0x358B24 - cmpwi r3, 0 - stw r3, 0xAC(r26) - beq- .loc_0xAC - lwz r0, -0x63A4(r13) - cmpwi r0, 0 - beq- .loc_0xA0 - li r3, 0 - bl -0x1658 - li r0, 0 - stw r0, -0x63A4(r13) - - .loc_0xA0: - lis r3, 0x8050 - addi r3, r3, 0x5710 - bl -0x35D524 - - .loc_0xAC: - lwz r0, 0x4(r27) - mr r3, r24 - stw r0, 0xC(r24) - bl 0x110 - bl -0x36107C - lwz r4, 0xD8(r26) - addi r0, r4, 0x1 - stw r0, 0xD8(r26) - bl -0x361064 - - .loc_0xD0: - lwz r0, 0x0(r29) - addi r29, r29, 0x4 - addi r25, r25, 0x1 - addi r30, r30, 0x1 - add r28, r28, r0 - - .loc_0xE4: - lwz r0, 0x6C(r31) - cmplw r30, r0 - blt+ .loc_0x50 - lwz r0, -0x63A4(r13) - cmpwi r0, 0 - beq- .loc_0x10C - li r3, 0x1 - bl -0x16C4 - li r0, 0 - stw r0, -0x63A4(r13) - - .loc_0x10C: - lmw r24, 0x10(r1) - lwz r0, 0x34(r1) - mtlr r0 - addi r1, r1, 0x30 - blr - - .loc_0x120: - */ + THPTextureSet* textureSet; + s32 i; + u32* tileOffsets; + u8* tile; + + tileOffsets = (u32*)(readBuffer->mPtr + 8); + tile = &readBuffer->mPtr[ActivePlayer.mCompInfo.mNumComponents * 4] + 8; + textureSet = (THPTextureSet*)PopFreeTextureSet(); + + for (i = 0; i < ActivePlayer.mCompInfo.mNumComponents; i++) { + switch (ActivePlayer.mCompInfo.mFrameComp[i]) { + case 0: { + ActivePlayer.mVideoError + = THPVideoDecode(tile, textureSet->mYTexture, textureSet->mUTexture, textureSet->mVTexture, ActivePlayer.mThpWorkArea); + if (ActivePlayer.mVideoError) { + if (First) { + PrepareReady(FALSE); + First = FALSE; + } + OSSuspendThread(&VideoDecodeThread); + } + textureSet->mFrameNumber = readBuffer->mFrameNumber; + PushDecodedTextureSet((OSMessage*)textureSet); + OSDisableInterrupts(); + OSRestoreInterrupts(ActivePlayer.mVideoDecodeCount++); // regswap r3/r4 here + } + } + + tile += *tileOffsets; + tileOffsets++; + } + + if (First) { + PrepareReady(TRUE); + First = FALSE; + } } /* @@ -421,22 +213,9 @@ void VideoDecode(THPReadBuffer* buffer) */ OSMessage PopFreeTextureSet() { - /* - .loc_0x0: - stwu r1, -0x10(r1) - mflr r0 - lis r3, 0x8050 - li r5, 0x1 - stw r0, 0x14(r1) - addi r4, r1, 0x8 - addi r3, r3, 0x6A28 - bl -0x360750 - lwz r0, 0x14(r1) - lwz r3, 0x8(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + void* msg; + OSReceiveMessage(&FreeTextureSetQueue, &msg, 1); + return msg; } /* @@ -444,56 +223,20 @@ OSMessage PopFreeTextureSet() * Address: 8044FD4C * Size: 000030 */ -BOOL PushFreeTextureSet(OSMessage* msg) -{ - /* - .loc_0x0: - stwu r1, -0x10(r1) - mflr r0 - lis r5, 0x8050 - mr r4, r3 - stw r0, 0x14(r1) - addi r3, r5, 0x6A28 - li r5, 0 - bl -0x36084C - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ -} +BOOL PushFreeTextureSet(OSMessage* msg) { OSSendMessage(&FreeTextureSetQueue, msg, 0); } /* * --INFO-- * Address: 8044FD7C * Size: 000044 */ -OSMessage PopDecodedTextureSet() +OSMessage PopDecodedTextureSet(s32 flags) { - /* - .loc_0x0: - stwu r1, -0x10(r1) - mflr r0 - lis r4, 0x8050 - mr r5, r3 - stw r0, 0x14(r1) - addi r3, r4, 0x6A48 - addi r4, r1, 0x8 - bl -0x3607B4 - cmpwi r3, 0x1 - bne- .loc_0x30 - lwz r3, 0x8(r1) - b .loc_0x34 - - .loc_0x30: - li r3, 0 - - .loc_0x34: - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + void* msg; + if (OSReceiveMessage(&DecodedTextureSetQueue, &msg, flags) == TRUE) { + return msg; + } + return NULL; } /* @@ -501,21 +244,4 @@ OSMessage PopDecodedTextureSet() * Address: 8044FDC0 * Size: 000030 */ -BOOL PushDecodedTextureSet(OSMessage* msg) -{ - /* - .loc_0x0: - stwu r1, -0x10(r1) - mflr r0 - lis r5, 0x8050 - mr r4, r3 - stw r0, 0x14(r1) - addi r3, r5, 0x6A48 - li r5, 0x1 - bl -0x3608C0 - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ -} +BOOL PushDecodedTextureSet(OSMessage* msg) { OSSendMessage(&DecodedTextureSetQueue, msg, OS_MESSAGE_BLOCK); } diff --git a/tools/progress.csv b/tools/progress.csv index 7ea513de0..6c1dc858c 100644 --- a/tools/progress.csv +++ b/tools/progress.csv @@ -529,3 +529,5 @@ You have 2591 out of 10000 Pokos and 72 out of 201 treasures.",2023-09-10 23:58: You have 2610 out of 10000 Pokos and 72 out of 201 treasures.",2023-09-11 20:36:36.785182 2612,1215260,0.26121411277564555,74,263065,0.3690296497469335," You have 2612 out of 10000 Pokos and 74 out of 201 treasures.",2023-09-12 16:09:22.614997 +2613,1215920,0.2613559765039275,74,263149,0.36914748560719135," +You have 2613 out of 10000 Pokos and 74 out of 201 treasures.",2023-09-12 20:28:42.908752