From 93a2a6522a0e8a05093194452aa99d176bbfcb32 Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Wed, 12 Aug 2026 12:56:27 -0400 Subject: [PATCH] d_a_movie_player fixes --- include/JSystem/JSystem.pch | 4 +- include/d/actor/d_a_movie_player.h | 8 ++- include/d/d_com_inf_game.h | 1 + include/d/dolzel.pch | 1 + include/dolphin/thp.h | 33 +--------- src/d/actor/d_a_movie_player.cpp | 97 ++++++++++++++++-------------- 6 files changed, 62 insertions(+), 82 deletions(-) diff --git a/include/JSystem/JSystem.pch b/include/JSystem/JSystem.pch index 1c0c49b73..df12d1589 100644 --- a/include/JSystem/JSystem.pch +++ b/include/JSystem/JSystem.pch @@ -1,7 +1,7 @@ #ifndef JSYSTEM_PCH #define JSYSTEM_PCH -#include "JSystem/JSupport/JSUList.h" -#include "JSystem/J3DGraphBase/J3DShape.h" +#include "JSystem/JSupport/JSUList.h" // IWYU pragma: export +#include "JSystem/J3DGraphBase/J3DShape.h" // IWYU pragma: export #endif /* JSYSTEM_PCH */ diff --git a/include/d/actor/d_a_movie_player.h b/include/d/actor/d_a_movie_player.h index 9bc90b21b..68a5da83d 100644 --- a/include/d/actor/d_a_movie_player.h +++ b/include/d/actor/d_a_movie_player.h @@ -6,9 +6,11 @@ #include "d/d_drawlist.h" #include "dolphin/dvd/dvd.h" +#if VERSION > VERSION_DEMO #ifdef __cplusplus extern "C" { #endif +#endif typedef u8 THPSample; typedef s16 THPCoeff; @@ -45,8 +47,10 @@ static void __THPInverseDCTY8(THPCoeff* in, u32 xPos); static void __THPGQRSetup(); static s32 __THPHuffDecodeTab(THPFileInfo* info, THPHuffmanTab* h); +#if VERSION > VERSION_DEMO #ifdef __cplusplus -} +} // extern "C" +#endif #endif class daMP_c : public fopAc_ac_c { @@ -63,7 +67,7 @@ public: public: /* 0x290 */ u32 (*mpGetMovieRestFrame)(); - /* 0x294 */ u32 (*mpSetPercentMovieVol)(f32); + /* 0x294 */ void (*mpSetPercentMovieVol)(f32); #if VERSION == VERSION_PAL /* 0x29C */ u32 (*mpTHPGetTotalFrame)(void); #endif diff --git a/include/d/d_com_inf_game.h b/include/d/d_com_inf_game.h index 3ddbc1567..11f36f73a 100644 --- a/include/d/d_com_inf_game.h +++ b/include/d/d_com_inf_game.h @@ -8,6 +8,7 @@ #include "d/d_drawlist.h" #include "d/d_event.h" #include "d/d_event_manager.h" +#include "d/d_item_data.h" #include "d/d_map.h" #include "d/d_particle.h" #include "d/d_resorce.h" diff --git a/include/d/dolzel.pch b/include/d/dolzel.pch index 608cceab3..91e321c8e 100644 --- a/include/d/dolzel.pch +++ b/include/d/dolzel.pch @@ -29,6 +29,7 @@ #include "JSystem/JKernel/JKRFileFinder.h" // IWYU pragma: export #include "d/d_bg_s_lin_chk.h" // IWYU pragma: export #include "m_Do/m_Do_hostIO.h" // IWYU pragma: export +#include "m_Do/m_Do_graphic.h" // IWYU pragma: export #include "d/d_cc_uty.h" // IWYU pragma: export #include "d/d_magma.h" // IWYU pragma: export #include "d/d_mesg.h" // IWYU pragma: export diff --git a/include/dolphin/thp.h b/include/dolphin/thp.h index 455afe6cc..ca0774919 100644 --- a/include/dolphin/thp.h +++ b/include/dolphin/thp.h @@ -28,7 +28,7 @@ typedef struct _THPComponent { THPCoeff predDC; } THPComponent; -typedef struct _THPFileInfo { +typedef struct _local_THPFileInfo { THPQuantTab quantTabs[3]; THPHuffmanTab huffmanTabs[4]; THPComponent components[3]; @@ -116,37 +116,6 @@ typedef struct THPHeader { #define THP_READ_BUFFER_COUNT 10 #define THP_TEXTURE_SET_COUNT 3 -static u32 THPAudioDecode(s16* audioBuffer, u8* audioFrame, s32 flag); -static s32 __THPAudioGetNewSample(THPAudioDecodeInfo* info); -static void __THPAudioInitialize(THPAudioDecodeInfo* info, u8* ptr); - -s32 __THPAudioGetNewSample(THPAudioDecodeInfo*); -void __THPAudioInitialize(THPAudioDecodeInfo*, u8*); - -static void __THPSetupBuffers(void); -static u8 __THPReadFrameHeader(void); -static u8 __THPReadScaneHeader(void); -static u8 __THPReadQuantizationTable(void); -static u8 __THPReadHuffmanTableSpecification(void); -static void __THPHuffGenerateSizeTable(void); -static void __THPHuffGenerateCodeTable(void); -static void __THPHuffGenerateDecoderTables(u8 tabIndex); -static void __THPRestartDefinition(void); -static void __THPPrepBitStream(void); -static void __THPDecompressYUV(void* tileY, void* tileU, void* tileV); -static void __THPGQRRestore(void); -static void __THPDecompressiMCURow512x448(void); -static void __THPDecompressiMCURow640x480(void); -static void __THPDecompressiMCURowNxN(void); -static void __THPInverseDCTNoYPos(THPCoeff* in, u32 xPos); -static void __THPHuffDecodeDCTCompY(THPFileInfo* info, THPCoeff* block); -static void __THPHuffDecodeDCTCompU(THPFileInfo* info, THPCoeff* block); -static void __THPHuffDecodeDCTCompV(THPFileInfo* info, THPCoeff* block); - -static void __THPInverseDCTY8(THPCoeff* in, u32 xPos); -static void __THPGQRSetup(); -static s32 __THPHuffDecodeTab(THPFileInfo* info, THPHuffmanTab* h); - #ifdef __cplusplus } #endif diff --git a/src/d/actor/d_a_movie_player.cpp b/src/d/actor/d_a_movie_player.cpp index b5282b97a..abf611ebb 100644 --- a/src/d/actor/d_a_movie_player.cpp +++ b/src/d/actor/d_a_movie_player.cpp @@ -62,68 +62,72 @@ static const f64 __THPAANScaleFactor[8] = { #define THPROUNDUP(a, b) ((((s32)(a)) + ((s32)(b)-1L)) / ((s32)(b))) -daMP_Player_c daMP_ActivePlayer; +static daMP_Player_c daMP_ActivePlayer; -BOOL daMP_ReadThreadCreated; -OSMessageQueue daMP_FreeReadBufferQueue; -OSMessageQueue daMP_ReadedBufferQueue; -OSMessageQueue daMP_ReadedBufferQueue2; -OSMessage daMP_FreeReadBufferMessage[10]; -OSMessage daMP_ReadedBufferMessage[10]; -OSMessage daMP_ReadedBufferMessage2[10]; -OSThread daMP_ReadThread; -u8 daMP_ReadThreadStack[0x1000]; +static BOOL daMP_ReadThreadCreated; +static OSMessageQueue daMP_FreeReadBufferQueue; +static OSMessageQueue daMP_ReadedBufferQueue; +static OSMessageQueue daMP_ReadedBufferQueue2; +static OSMessage daMP_FreeReadBufferMessage[10]; +static OSMessage daMP_ReadedBufferMessage[10]; +static OSMessage daMP_ReadedBufferMessage2[10]; +static OSThread daMP_ReadThread; +static u8 daMP_ReadThreadStack[0x1000]; -BOOL daMP_VideoDecodeThreadCreated; -OSThread daMP_VideoDecodeThread; -u8 daMP_VideoDecodeThreadStack[0x64000]; +static BOOL daMP_VideoDecodeThreadCreated; +static OSThread daMP_VideoDecodeThread; +static u8 daMP_VideoDecodeThreadStack[0x64000]; -OSMessageQueue daMP_FreeTextureSetQueue; -OSMessageQueue daMP_DecodedTextureSetQueue; -OSMessage daMP_FreeTextureSetMessage[3]; -OSMessage daMP_DecodedTextureSetMessage[3]; +static OSMessageQueue daMP_FreeTextureSetQueue; +static OSMessageQueue daMP_DecodedTextureSetQueue; +static OSMessage daMP_FreeTextureSetMessage[3]; +static OSMessage daMP_DecodedTextureSetMessage[3]; -BOOL daMP_First; +static BOOL daMP_First; -BOOL daMP_AudioDecodeThreadCreated; -OSThread daMP_AudioDecodeThread; -u8 daMP_AudioDecodeThreadStack[0x64000]; -OSMessageQueue daMP_FreeAudioBufferQueue; -OSMessageQueue daMP_DecodedAudioBufferQueue; -OSMessage daMP_FreeAudioBufferMessage[3]; -OSMessage daMP_DecodedAudioBufferMessage[3]; +static BOOL daMP_AudioDecodeThreadCreated; +static OSThread daMP_AudioDecodeThread; +static u8 daMP_AudioDecodeThreadStack[0x64000]; +static OSMessageQueue daMP_FreeAudioBufferQueue; +static OSMessageQueue daMP_DecodedAudioBufferQueue; +static OSMessage daMP_FreeAudioBufferMessage[3]; +static OSMessage daMP_DecodedAudioBufferMessage[3]; -BOOL daMP_Initialized; -u32 daMP_WorkBuffer[16] ALIGN_DECL(32); -OSMessageQueue daMP_PrepareReadyQueue; -OSMessageQueue daMP_UsedTextureSetQueue; -OSMessage daMP_PrepareReadyMessage; -OSMessage daMP_UsedTextureSetMessage[3]; -VIRetraceCallback daMP_OldVIPostCallback; +static BOOL daMP_Initialized; +static u32 daMP_WorkBuffer[16] ALIGN_DECL(32); +static OSMessageQueue daMP_PrepareReadyQueue; +static OSMessageQueue daMP_UsedTextureSetQueue; +static OSMessage daMP_PrepareReadyMessage; +static OSMessage daMP_UsedTextureSetMessage[3]; +static VIRetraceCallback daMP_OldVIPostCallback; -u32 daMP_SoundBufferIndex; -u32 daMP_OldAIDCallback; +static u32 daMP_SoundBufferIndex; +static u32 daMP_OldAIDCallback; -void* daMP_LastAudioBuffer; -void* daMP_CurAudioBuffer; -s32 daMP_AudioSystem; -s16 daMP_SoundBuffer[2][0x460] ALIGN_DECL(32); +static void* daMP_LastAudioBuffer; +static void* daMP_CurAudioBuffer; +static s32 daMP_AudioSystem; +static s16 daMP_SoundBuffer[2][0x460] ALIGN_DECL(32); -THPVideoInfo daMP_videoInfo; -THPAudioInfo daMP_audioInfo; -u32 daMP_DrawPosX; -u32 daMP_DrawPosY; -void* daMP_buffer; +static THPVideoInfo daMP_videoInfo; +static THPAudioInfo daMP_audioInfo; +static u32 daMP_DrawPosX; +static u32 daMP_DrawPosY; +static void* daMP_buffer; +#if VERSION > VERSION_DEMO BOOL daMP_Fail_alloc; u16 daMP_backup_FrameRate; u8 daMP_backup_vfilter[7]; +#endif daMP_Dlst_base_c daMP_c_Dlst_base; +#if VERSION > VERSION_DEMO #ifdef __cplusplus extern "C" { #endif +#endif /* 000000EC-00000584 .text THPAudioDecode */ static u32 THPAudioDecode(s16* audioBuffer, u8* audioFrame, s32 flag) { @@ -2618,8 +2622,10 @@ static BOOL THPInit() { return TRUE; } +#if VERSION > VERSION_DEMO #ifdef __cplusplus -} +} // extern "C" +#endif #endif /* 00003208-0000323C .text daMP_PopReadedBuffer__Fv */ @@ -4150,8 +4156,7 @@ static u32 daMP_Get_MovieRestFrame() { } /* 000062F0-00006370 .text daMP_Set_PercentMovieVolume__Ff */ -static u32 daMP_Set_PercentMovieVolume(f32 volume) { - /* Nonmatching - regalloc */ +static void daMP_Set_PercentMovieVolume(f32 volume) { #if VERSION > VERSION_DEMO if (!daMP_Fail_alloc) #endif