From 650e1c44a479ff0166b8d6d89a691df592357efa Mon Sep 17 00:00:00 2001 From: TakaRikka <38417346+TakaRikka@users.noreply.github.com> Date: Mon, 11 Nov 2024 07:53:04 -0800 Subject: [PATCH] work on d_a_movie_player (#2246) * work on d_a_movie_player * d_a_demo_item mostly done --- configure.py | 2 +- include/JSystem/JFramework/JFWDisplay.h | 5 + include/d/actor/d_a_demo_item.h | 57 +- include/d/actor/d_a_movie_player.h | 241 +- include/d/d_a_itembase_static.h | 1 + include/d/d_item.h | 1 + include/f_op/f_op_actor_mng.h | 11 +- include/f_pc/f_pc_manager.h | 2 +- include/m_Do/m_Do_graphic.h | 1 + src/d/actor/d_a_demo_item.cpp | 1268 +++---- src/d/actor/d_a_movie_player.cpp | 4391 +++++++++++++++++------ src/d/d_com_static.cpp | 2 +- src/d/d_item.cpp | 6 +- 13 files changed, 3982 insertions(+), 2006 deletions(-) diff --git a/configure.py b/configure.py index 5ba12234973..7e2c181299d 100644 --- a/configure.py +++ b/configure.py @@ -1645,7 +1645,7 @@ def MatchingFor(*versions): ActorRel(NonMatching, "d_a_mant"), ActorRel(NonMatching, "d_a_mg_fshop"), ActorRel(Matching, "d_a_mirror"), - ActorRel(NonMatching, "d_a_movie_player"), + ActorRel(NonMatching, "d_a_movie_player", extra_cflags=["-O3,p"]), ActorRel(NonMatching, "d_a_myna"), ActorRel(NonMatching, "d_a_ni"), ActorRel(NonMatching, "d_a_npc_aru"), diff --git a/include/JSystem/JFramework/JFWDisplay.h b/include/JSystem/JFramework/JFWDisplay.h index 17590f42695..5aa79d3792b 100644 --- a/include/JSystem/JFramework/JFWDisplay.h +++ b/include/JSystem/JFramework/JFWDisplay.h @@ -91,6 +91,11 @@ class JFWDisplay { mFrameRate = 0; } + void setFrameRate(u16 rate) { + mFrameRate = rate; + mTickRate = 0; + } + void setDrawDoneMethod(EDrawDone drawDone) { mDrawDoneMethod = drawDone; } void setFader(JUTFader* fader) { mFader = fader; } JUTFader* getFader() const { return mFader; } diff --git a/include/d/actor/d_a_demo_item.h b/include/d/actor/d_a_demo_item.h index f61d1097b9a..70fe4cf9514 100644 --- a/include/d/actor/d_a_demo_item.h +++ b/include/d/actor/d_a_demo_item.h @@ -2,6 +2,8 @@ #define D_A_DEMO_ITEM_H #include "f_op/f_op_actor_mng.h" +#include "d/actor/d_a_itembase.h" +#include "d/d_particle.h" /** * @ingroup actors-unsorted @@ -11,10 +13,16 @@ * @details * */ -class daDitem_c : public fopAc_ac_c { +class daDitem_c : public daItemBase_c { public: - /* 804DFBCC */ bool __CreateHeap(); - /* 804DFBD4 */ void CreateInit(); + enum Action_e { + ACTION_START_e, + ACTION_EVENT_e, + ACTION_WAIT_LIGHT_END_e, + ACTION_END_e, + }; + + /* 804DFBD4 */ int CreateInit(); /* 804DFC98 */ void action(); /* 804DFD10 */ void actionStart(); /* 804E00DC */ void actionEvent(); @@ -29,15 +37,52 @@ class daDitem_c : public fopAc_ac_c { /* 804E1098 */ void initEffectLight(); /* 804E10D0 */ void settingEffectLight(); /* 804E111C */ void set_mtx(); - /* 804E11D4 */ void setTevStr(); - /* 804E122C */ void setListStart(); /* 804E1230 */ void draw_WOOD_STICK(); + /* 804E122C */ virtual void setListStart(); + /* 804E11D4 */ virtual void setTevStr(); + /* 804DFBCC */ virtual int __CreateHeap(); + + inline int Delete(); + inline int create(); + inline int execute(); + inline int draw(); + + void setAction(u8 i_action) { mAction = i_action; } + + u32 chkArgFlag(u8 i_flag) { return field_0x93d & i_flag; } + private: - /* 0x568 */ u8 field_0x568[0x9c8 - 0x568]; + /* 0x92C */ cXyz field_0x92c; + /* 0x938 */ f32 field_0x938; + /* 0x93C */ u8 field_0x93c; + /* 0x93D */ u8 field_0x93d; + /* 0x93E */ u8 field_0x93e; + /* 0x93F */ u8 mSetLightEff; + /* 0x940 */ f32 mLightStrength; + /* 0x944 */ u8 field_0x944[0x948 - 0x944]; + /* 0x948 */ LIGHT_INFLUENCE mLight; + /* 0x968 */ u8 mAction; + /* 0x969 */ u8 field_0x969; + /* 0x96A */ u8 mParticleAlpha; + /* 0x96C */ dPa_followEcallBack field_0x96c; + /* 0x980 */ dPa_followEcallBack field_0x980; + /* 0x994 */ JPABaseEmitter* field_0x994; + /* 0x998 */ JPABaseEmitter* field_0x998; + /* 0x99C */ cXyz field_0x99c; + /* 0x9A8 */ Z2SoundObjSimple mSound; }; STATIC_ASSERT(sizeof(daDitem_c) == 0x9c8); +namespace daDitem_prm { +inline u8 getFlag(daDitem_c* i_this) { + return (fopAcM_GetParam(i_this) >> 0x10) & 0xFF; +} + +inline u8 getNo(daDitem_c* i_this) { + return fopAcM_GetParam(i_this) & 0xFF; +} +}; #endif /* D_A_DEMO_ITEM_H */ diff --git a/include/d/actor/d_a_movie_player.h b/include/d/actor/d_a_movie_player.h index 736faf99a7e..3a8a0cca089 100644 --- a/include/d/actor/d_a_movie_player.h +++ b/include/d/actor/d_a_movie_player.h @@ -2,6 +2,105 @@ #define D_A_MOVIE_PLAYER_H #include "f_op/f_op_actor.h" +#include "d/d_drawlist.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef u8 THPSample; +typedef s16 THPCoeff; +typedef f32 THPQuantTab[64]; + +typedef struct _THPHuffmanTab { + u8 quick[32]; + u8 increment[32]; + u8* Vij; + s32 maxCode[18]; + s32 valPtr[18]; + u8 Vij1; + u8 pad[11]; +} THPHuffmanTab; + +typedef struct _THPComponent { + u8 quantizationTableSelector; + u8 DCTableSelector; + u8 ACTableSelector; + THPCoeff predDC; +} THPComponent; + +typedef struct _THPFileInfo { + THPQuantTab quantTabs[3]; + THPHuffmanTab huffmanTabs[4]; + THPComponent components[3]; + u16 xPixelSize; + u16 yPixelSize; + u16 MCUsPerRow; + u16 decompressedY; + u8* c; + u32 currByte; + u32 cnt; + u8 validHuffmanTabs; + u8 RST; + u16 nMCU; + u16 currMCU; + u8* dLC[3]; +} THPFileInfo; + +typedef struct THPAudioRecordHeader { + u32 offsetNextChannel; + u32 sampleSize; + s16 lCoef[8][2]; + s16 rCoef[8][2]; + s16 lYn1; + s16 lYn2; + s16 rYn1; + s16 rYn2; +} THPAudioRecordHeader; + +typedef struct THPAudioDecodeInfo { + u8* encodeData; + u32 offsetNibbles; + u8 predictor; + u8 scale; + s16 yn1; + s16 yn2; +} THPAudioDecodeInfo; + +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 /** * @ingroup actors-unsorted @@ -15,26 +114,27 @@ class daMP_c : public fopAc_ac_c { public: /* 80031AD0 */ static int daMP_c_THPPlayerPlay(); /* 80031B24 */ static void daMP_c_THPPlayerPause(); - /* 80031A78 */ static int daMP_c_Get_MovieRestFrame(); + /* 80031A78 */ static u32 daMP_c_Get_MovieRestFrame(); /* 80031AA4 */ static void daMP_c_Set_PercentMovieVolume(f32); - /* 80878BB8 */ void daMP_c_Get_arg_demoNo(); - /* 80878C04 */ void daMP_c_Get_arg_movieNo(); - /* 80878C28 */ void daMP_c_Init(); - /* 80878D64 */ void daMP_c_Finish(); - /* 80878D94 */ void daMP_c_Main(); - /* 80878DD8 */ void daMP_c_Draw(); - /* 80878E60 */ void daMP_c_Callback_Init(fopAc_ac_c*); - /* 80878ED4 */ daMP_c(); - /* 80878F18 */ void daMP_c_Callback_Finish(daMP_c*); - /* 80878F38 */ void daMP_c_Callback_Main(daMP_c*); - /* 80878F70 */ void daMP_c_Callback_Draw(daMP_c*); + /* 80878BB8 */ int daMP_c_Get_arg_demoNo(); + /* 80878C04 */ int daMP_c_Get_arg_movieNo(); + /* 80878C28 */ int daMP_c_Init(); + /* 80878D64 */ int daMP_c_Finish(); + /* 80878D94 */ int daMP_c_Main(); + /* 80878DD8 */ int daMP_c_Draw(); + /* 80878ED4 */ daMP_c() {} + + /* 80878E60 */ static int daMP_c_Callback_Init(fopAc_ac_c*); + /* 80878F18 */ static int daMP_c_Callback_Finish(daMP_c*); + /* 80878F38 */ static int daMP_c_Callback_Main(daMP_c*); + /* 80878F70 */ static int daMP_c_Callback_Draw(daMP_c*); static daMP_c* m_myObj; private: - /* 0x568 */ int (*mpGetMovieRestFrame)(void); + /* 0x568 */ u32 (*mpGetMovieRestFrame)(void); /* 0x56C */ void (*mpSetPercentMovieVol)(f32); - /* 0x570 */ int (*mpTHPGetTotalFrame)(void); + /* 0x570 */ u32 (*mpTHPGetTotalFrame)(void); /* 0x574 */ int (*mpTHPPlay)(void); /* 0x578 */ void (*mpTHPStop)(void); /* 0x57C */ int (*mpTHPPause)(void); @@ -42,16 +142,117 @@ class daMP_c : public fopAc_ac_c { STATIC_ASSERT(sizeof(daMP_c) == 0x580); -struct daMP_THPReadBuffer {}; +struct daMP_THPReadBuffer { + /* 0x00 */ void* m00; + /* 0x04 */ s32 m04; +}; -class daMP_Dlst_base_c { +class daMP_Dlst_base_c : public dDlst_base_c { public: - /* 80878DB8 */ void draw(); - /* 80878FD8 */ daMP_Dlst_base_c(); + /* 80878FD8 */ daMP_Dlst_base_c() {} + + /* 80878DB8 */ virtual void draw(); +}; + +struct THPVideoInfo { + /* 0x00 */ u32 field_0x0; + /* 0x04 */ u32 field_0x4; + /* 0x08 */ u8 field_0x8[0x0C - 0x08]; +}; + +struct THPAudioInfo { + /* 0x00 */ u8 field_0x0[0xC - 0x0]; + /* 0x0C */ u32 field_0xc; +}; + +// made up +struct daMP_Player_c { + /* 0x000 */ DVDFileInfo mFileInfo; + /* 0x03C */ char* field_0x3c; + /* 0x040 */ int field_0x40; + /* 0x044 */ int field_0x44; + /* 0x048 */ int field_0x48; + /* 0x04C */ f32 field_0x4c; + /* 0x050 */ u32 mTotalFrames; + /* 0x054 */ int field_0x54; + /* 0x058 */ int field_0x58; + /* 0x05C */ int field_0x5c; + /* 0x060 */ int field_0x60; + /* 0x064 */ int field_0x64; + /* 0x068 */ u8 field_0x68[0x06C - 0x068]; + struct { + u32 _0; + u8 _4; + u8 _5[0x14 - 0x5]; + } /* 0x06C */ field_0x6c; // not sure if this is right + /* 0x080 */ THPVideoInfo mVideoInfo; + /* 0x08C */ THPAudioInfo mAudioInfo; + /* 0x09C */ int field_0x9c; + /* 0x0A0 */ int field_0xa0; + /* 0x0A4 */ u8 mState; + /* 0x0A5 */ u8 field_0xa5; + /* 0x0A6 */ u8 field_0xa6; + /* 0x0A7 */ u8 field_0xa7; + /* 0x0A8 */ int field_0xa8; + /* 0x0AC */ int field_0xac; + /* 0x0B0 */ int field_0xb0; + /* 0x0B4 */ int field_0xb4; + /* 0x0B8 */ int field_0xb8; + /* 0x0BC */ int field_0xbc; + /* 0x0C0 */ int field_0xc0; + /* 0x0C4 */ u8 field_0xC4[0x0C8 - 0x0C4]; + /* 0x0C8 */ s64 field_0xc8; + /* 0x0D0 */ int field_0xd0; + /* 0x0D4 */ int field_0xd4; + /* 0x0D8 */ int field_0xd8; + /* 0x0DC */ f32 field_0xdc; + /* 0x0E0 */ f32 field_0xe0; + /* 0x0E4 */ f32 field_0xe4; + /* 0x0E8 */ int field_0xe8; + /* 0x0EC */ int field_0xec; + /* 0x0F0 */ int field_0xf0; + /* 0x0F4 */ int field_0xf4; + /* 0x0F8 */ int field_0xf8; + /* 0x0FC */ int field_0xfc; + /* 0x100 */ int field_0x100; + /* 0x104 */ u8 field_0x104[0x10C - 0x104]; + /* 0x10C */ int field_0x10c; + /* 0x110 */ u8 field_0x110[0x118 - 0x110]; + /* 0x118 */ int field_0x118; + /* 0x11C */ u8 field_0x11C[0x124 - 0x11C]; + /* 0x124 */ int field_0x124; + /* 0x128 */ u8 field_0x128[0x130 - 0x128]; + /* 0x130 */ int field_0x130; + /* 0x134 */ u8 field_0x134[0x13C - 0x134]; + /* 0x13C */ int field_0x13c; + /* 0x140 */ u8 field_0x140[0x148 - 0x140]; + /* 0x148 */ int field_0x148; + /* 0x14C */ u8 field_0x14C[0x154 - 0x14C]; + /* 0x154 */ int field_0x154; + /* 0x158 */ u8 field_0x158[0x160 - 0x158]; + /* 0x160 */ int field_0x160; + /* 0x164 */ u8 field_0x164[0x16C - 0x164]; + /* 0x16C */ int field_0x16c; + /* 0x170 */ u8 field_0x170[0x178 - 0x170]; + /* 0x178 */ int field_0x178; + /* 0x17C */ int field_0x17c; + /* 0x180 */ int field_0x180; + /* 0x184 */ u8 field_0x184[0x1A8 - 0x184]; + /* 0x1A8 */ int field_0x1a8; + /* 0x1AC */ int field_0x1ac; + /* 0x1B0 */ int field_0x1b0; + /* 0x1B4 */ int field_0x1b4; + /* 0x1B8 */ int field_0x1b8; + /* 0x1BC */ int field_0x1bc; + /* 0x1C0 */ int field_0x1c0; + /* 0x1C4 */ int field_0x1c4; + /* 0x1C8 */ int field_0x1c8; }; -struct THPVideoInfo {}; +inline s32 daMP_NEXT_READ_SIZE(daMP_THPReadBuffer* readBuf) { + return *(s32*)readBuf->m00; +} -struct THPAudioInfo {}; +void daMP_PrepareReady(int); #endif /* D_A_MOVIE_PLAYER_H */ diff --git a/include/d/d_a_itembase_static.h b/include/d/d_a_itembase_static.h index f97a9129f19..36a0f558992 100644 --- a/include/d/d_a_itembase_static.h +++ b/include/d/d_a_itembase_static.h @@ -5,5 +5,6 @@ class fopAc_ac_c; int CheckFieldItemCreateHeap(fopAc_ac_c* actor); +int CheckItemCreateHeap(fopAc_ac_c* i_this); #endif /* D_A_D_A_ITEMBASE_STATIC_H */ diff --git a/include/d/d_item.h b/include/d/d_item.h index 0451fb2665e..e9dee1c0106 100644 --- a/include/d/d_item.h +++ b/include/d/d_item.h @@ -397,5 +397,6 @@ int isArrow(u8); int addBombCount(u8, u8); BOOL isBottleItem(u8 item_no); u8 check_itemno(int i_itemNo); +BOOL isInsect(u8 i_itemNo); #endif /* D_D_ITEM_H */ diff --git a/include/f_op/f_op_actor_mng.h b/include/f_op/f_op_actor_mng.h index 11bcf0f4384..a689c4289e0 100644 --- a/include/f_op/f_op_actor_mng.h +++ b/include/f_op/f_op_actor_mng.h @@ -4,6 +4,7 @@ #include "f_op/f_op_actor.h" #include "f_op/f_op_actor_iter.h" #include "f_pc/f_pc_manager.h" +#include "f_op/f_op_draw_tag.h" #include "d/d_bg_s.h" #include "d/d_bg_s_gnd_chk.h" #include "d/d_bg_s_lin_chk.h" @@ -288,7 +289,7 @@ inline csXyz* fopAcM_GetShapeAngle_p(fopAc_ac_c* pActor) { return &pActor->shape_angle; } -inline bool fopAcM_CheckCondition(fopAc_ac_c* p_actor, u32 flag) { +inline u32 fopAcM_CheckCondition(fopAc_ac_c* p_actor, u32 flag) { return p_actor->actor_condition & flag; } @@ -462,6 +463,14 @@ inline void fopAcM_onActor(const fopAc_ac_c* p_actor) { dComIfGs_onActor(setId, fopAcM_GetHomeRoomNo(p_actor)); } +inline void fopAcM_onDraw(fopAc_ac_c* i_actor) { + fopDwTg_ToDrawQ(&i_actor->draw_tag, fpcM_DrawPriority(i_actor)); +} + +inline void fopAcM_offDraw(fopAc_ac_c* i_actor) { + fopDwTg_DrawQTo(&i_actor->draw_tag); +} + void fopAcM_initManager(); void* fopAcM_FastCreate(s16 pProcTypeID, FastCreateReqFunc param_2, void* param_3, void* pData); diff --git a/include/f_pc/f_pc_manager.h b/include/f_pc/f_pc_manager.h index 57895a485f2..8570b613788 100644 --- a/include/f_pc/f_pc_manager.h +++ b/include/f_pc/f_pc_manager.h @@ -40,7 +40,7 @@ inline int fpcM_Create(s16 procName, FastCreateReqFunc createFunc, void* process } inline s16 fpcM_DrawPriority(const void* param_0) { - return fpcLf_GetPriority((const leafdraw_class*)param_0); + return (s16)fpcLf_GetPriority((const leafdraw_class*)param_0); } inline s32 fpcM_ChangeLayerID(void* proc, int layerID) { diff --git a/include/m_Do/m_Do_graphic.h b/include/m_Do/m_Do_graphic.h index cbfee44297b..2c002c191f1 100644 --- a/include/m_Do/m_Do_graphic.h +++ b/include/m_Do/m_Do_graphic.h @@ -101,6 +101,7 @@ class mDoGph_gInf_c { static f32 getInvScale() { return 1.0f; } static f32 getScale() { return 1.0f; } static void setWideZoomLightProjection(Mtx m) {} + static void setFrameRate(u16 i_rate) { JFWDisplay::getManager()->setFrameRate(i_rate); } static GXTexObj mFrameBufferTexObj; static GXTexObj mZbufferTexObj; diff --git a/src/d/actor/d_a_demo_item.cpp b/src/d/actor/d_a_demo_item.cpp index 97d835b5d40..a2028ea6774 100644 --- a/src/d/actor/d_a_demo_item.cpp +++ b/src/d/actor/d_a_demo_item.cpp @@ -4,901 +4,585 @@ */ #include "d/actor/d_a_demo_item.h" -#include "dol2asm.h" - - - -// -// Forward References: -// - -extern "C" bool __CreateHeap__9daDitem_cFv(); -extern "C" void CreateInit__9daDitem_cFv(); -extern "C" void action__9daDitem_cFv(); -extern "C" void actionStart__9daDitem_cFv(); -extern "C" void __dt__4cXyzFv(); -extern "C" void actionEvent__9daDitem_cFv(); -extern "C" void actionWaitLightEnd__9daDitem_cFv(); -extern "C" void actionEnd__9daDitem_cFv(); -extern "C" void setInsectEffect__9daDitem_cFv(); -extern "C" void followInsectEffect__9daDitem_cFv(); -extern "C" void endInsectEffect__9daDitem_cFv(); -extern "C" void onEventReg__9daDitem_cFii(); -extern "C" void set_pos__9daDitem_cFv(); -extern "C" void anim_control__9daDitem_cFv(); -extern "C" void initEffectLight__9daDitem_cFv(); -extern "C" void settingEffectLight__9daDitem_cFv(); -extern "C" void set_mtx__9daDitem_cFv(); -extern "C" void setTevStr__9daDitem_cFv(); -extern "C" void setListStart__9daDitem_cFv(); -extern "C" void draw_WOOD_STICK__9daDitem_cFv(); -extern "C" static void daDitem_Delete__FP9daDitem_c(); -extern "C" static void daDitem_Create__FP9daDitem_c(); -extern "C" void __dt__8cM3dGCylFv(); -extern "C" void __dt__8cM3dGAabFv(); -extern "C" void __dt__12dBgS_ObjAcchFv(); -extern "C" static void daDitem_Execute__FP9daDitem_c(); -extern "C" static void daDitem_Draw__FP9daDitem_c(); -extern "C" void __sinit_d_a_demo_item_cpp(); -extern "C" static void func_804E19B0(); -extern "C" static void func_804E19B8(); -extern "C" extern char const* const d_a_demo_item__stringBase0; - -// -// External References: -// - -SECTION_INIT void __init_data(); -extern "C" void mDoMtx_YrotM__FPA4_fs(); -extern "C" void __ct__10fopAc_ac_cFv(); -extern "C" void fopAcM_delete__FP10fopAc_ac_c(); -extern "C" void fopAcM_entrySolidHeap__FP10fopAc_ac_cPFP10fopAc_ac_c_iUl(); -extern "C" void fopAcM_setCullSizeBox2__FP10fopAc_ac_cP12J3DModelData(); -extern "C" void fopAcM_addAngleY__FP10fopAc_ac_css(); -extern "C" void fopDwTg_ToDrawQ__FP16create_tag_classi(); -extern "C" void fopDwTg_DrawQTo__FP16create_tag_class(); -extern "C" void fpcLf_GetPriority__FPC14leafdraw_class(); -extern "C" void getLayerNo__14dComIfG_play_cFi(); -extern "C" void dComIfG_resLoad__FP30request_of_phase_process_classPCc(); -extern "C" void dComIfGp_getReverb__Fi(); -extern "C" void isEventBit__11dSv_event_cCFUs(); -extern "C" void setEventReg__11dSv_event_cFUsUc(); -extern "C" void getEventReg__11dSv_event_cCFUs(); -extern "C" void hide__12daItemBase_cFv(); -extern "C" void chkDraw__12daItemBase_cFv(); -extern "C" void chkDead__12daItemBase_cFv(); -extern "C" void CheckItemCreateHeap__FP10fopAc_ac_c(); -extern "C" void __ct__19dPa_followEcallBackFUcUc(); -extern "C" void -set__13dPa_control_cFUcUsPC4cXyzPC12dKy_tevstr_cPC5csXyzPC4cXyzUcP18dPa_levelEcallBackScPC8_GXColorPC8_GXColorPC4cXyzf(); -extern "C" void __ct__12dBgS_AcchCirFv(); -extern "C" void __dt__9dBgS_AcchFv(); -extern "C" void __ct__9dBgS_AcchFv(); -extern "C" void SetObj__16dBgS_PolyPassChkFv(); -extern "C" void __ct__10dCcD_GSttsFv(); -extern "C" void __ct__12dCcD_GObjInfFv(); -extern "C" void execItemGet__FUc(); -extern "C" void isInsect__FUc(); -extern "C" void DeleteBase__12daItemBase_cFPCc(); -extern "C" bool clothCreate__12daItemBase_cFv(); -extern "C" void DrawBase__12daItemBase_cFv(); -extern "C" void RotateYBase__12daItemBase_cFv(); -extern "C" void settingBeforeDraw__12daItemBase_cFv(); -extern "C" void setShadow__12daItemBase_cFv(); -extern "C" void animEntry__12daItemBase_cFv(); -extern "C" void animPlay__12daItemBase_cFffffff(); -extern "C" void chkFlag__12daItemBase_cFi(); -extern "C" void getTevFrm__12daItemBase_cFv(); -extern "C" void getBtpFrm__12daItemBase_cFv(); -extern "C" void getShadowSize__12daItemBase_cFv(); -extern "C" void getCollisionH__12daItemBase_cFv(); -extern "C" void getCollisionR__12daItemBase_cFv(); -extern "C" void settingTevStruct__18dScnKy_env_light_cFiP4cXyzP12dKy_tevstr_c(); -extern "C" void setLightTevColorType_MAJI__18dScnKy_env_light_cFP12J3DModelDataP12dKy_tevstr_c(); -extern "C" void dKy_efplight_set__FP15LIGHT_INFLUENCE(); -extern "C" void dKy_efplight_cut__FP15LIGHT_INFLUENCE(); -extern "C" void cLib_addCalc__FPfffff(); -extern "C" void cLib_addCalc2__FPffff(); -extern "C" void cLib_chaseUC__FPUcUcUc(); -extern "C" void cLib_chaseF__FPfff(); -extern "C" void cLib_offsetPos__FP4cXyzPC4cXyzsPC4cXyz(); -extern "C" void deleteObject__14Z2SoundObjBaseFv(); -extern "C" void __ct__16Z2SoundObjSimpleFv(); -extern "C" void __dl__FPv(); -extern "C" void getName__10JUTNameTabCFUs(); -extern "C" void _savegpr_28(); -extern "C" void _savegpr_29(); -extern "C" void _restgpr_28(); -extern "C" void _restgpr_29(); -extern "C" extern void* __vt__8dCcD_Cyl[36]; -extern "C" extern void* __vt__9dCcD_Stts[11]; -extern "C" void* item_resource__10dItem_data[1530]; -extern "C" extern void* __vt__12daItemBase_c[17 + 1 /* padding */]; -extern "C" extern void* __vt__12cCcD_CylAttr[25]; -extern "C" extern void* __vt__14cCcD_ShapeAttr[22]; -extern "C" extern void* __vt__9cCcD_Stts[8]; -extern "C" u8 now__14mDoMtx_stack_c[48]; -extern "C" extern u8 g_dComIfG_gameInfo[122384]; -extern "C" extern u8 mStayNo__20dStage_roomControl_c[4]; -extern "C" void __register_global_object(); - -// -// Declarations: -// +#include "d/d_com_inf_game.h" +#include "d/d_item.h" +#include "d/d_item_data.h" +#include "d/d_a_itembase_static.h" +#include "d/actor/d_a_player.h" +#include "JSystem/J3DGraphBase/J3DMaterial.h" +#include "Z2AudioLib/Z2Instances.h" /* 804DFBCC-804DFBD4 0000EC 0008+00 1/0 0/0 0/0 .text __CreateHeap__9daDitem_cFv */ -bool daDitem_c::__CreateHeap() { - return true; +int daDitem_c::__CreateHeap() { + return 1; } -/* ############################################################################################## */ /* 804E19D4-804E19D8 000000 0004+00 6/6 0/0 0/0 .rodata l_light_color */ -SECTION_RODATA static u32 const l_light_color = 0x8C7C6AFF; -COMPILER_STRIP_GATE(0x804E19D4, &l_light_color); - -/* 804E19D8-804E19DC 000004 0004+00 4/7 0/0 0/0 .rodata @3812 */ -SECTION_RODATA static f32 const lit_3812 = 1.0f; -COMPILER_STRIP_GATE(0x804E19D8, &lit_3812); - -/* 804E19DC-804E19E0 000008 0004+00 2/6 0/0 0/0 .rodata @3813 */ -SECTION_RODATA static u8 const lit_3813[4] = { - 0x00, - 0x00, - 0x00, - 0x00, -}; -COMPILER_STRIP_GATE(0x804E19DC, &lit_3813); +static const GXColor l_light_color = {0x8C, 0x7C, 0x6A, 0xFF}; /* 804DFBD4-804DFC98 0000F4 00C4+00 1/1 0/0 0/0 .text CreateInit__9daDitem_cFv */ -void daDitem_c::CreateInit() { - // NONMATCHING +int daDitem_c::CreateInit() { + fopAcM_SetMtx(this, mpModel->getBaseTRMtx()); + fopAcM_setCullSizeBox2(this, mpModel->getModelData()); + + hide(); + + field_0x93d = daDitem_prm::getFlag(this); + field_0x93e = 1; + + initEffectLight(); + + if (chkArgFlag(0x20)) { + scale.setall(1.0f); + } else { + scale.setall(0.0f); + } + + mSound.init(¤t.pos, 1); + set_mtx(); + return 1; } /* 804DFC98-804DFD10 0001B8 0078+00 1/1 0/0 0/0 .text action__9daDitem_cFv */ void daDitem_c::action() { - // NONMATCHING + switch (mAction) { + case ACTION_START_e: + actionStart(); + break; + case ACTION_EVENT_e: + actionEvent(); + break; + case ACTION_WAIT_LIGHT_END_e: + actionWaitLightEnd(); + break; + case ACTION_END_e: + actionEnd(); + break; + } + + followInsectEffect(); } -/* ############################################################################################## */ -/* 804E19E0-804E19E4 00000C 0004+00 0/1 0/0 0/0 .rodata @3927 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_3927 = 11.0f / 20.0f; -COMPILER_STRIP_GATE(0x804E19E0, &lit_3927); -#pragma pop - -/* 804E19E4-804E19E8 000010 0004+00 0/1 0/0 0/0 .rodata @3928 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_3928 = 6.0f / 5.0f; -COMPILER_STRIP_GATE(0x804E19E4, &lit_3928); -#pragma pop - -/* 804E19E8-804E19EC 000014 0004+00 0/1 0/0 0/0 .rodata @3929 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_3929 = 4.0f / 5.0f; -COMPILER_STRIP_GATE(0x804E19E8, &lit_3929); -#pragma pop - /* 804DFD10-804E00A0 000230 0390+00 1/1 0/0 0/0 .text actionStart__9daDitem_cFv */ void daDitem_c::actionStart() { - // NONMATCHING -} - -/* 804E00A0-804E00DC 0005C0 003C+00 2/2 0/0 0/0 .text __dt__4cXyzFv */ -// cXyz::~cXyz() { -extern "C" void __dt__4cXyzFv() { - // NONMATCHING + if (chkDraw()) { + if (!chkArgFlag(0x2) && !chkArgFlag(0x4) && !mSetLightEff) { + mSetLightEff = true; + settingEffectLight(); + dKy_efplight_set(&mLight); + + // "Get Item: Effect Light set & display start!\n" + OS_REPORT("ゲットアイテム:エフェクトライトセット&表示スタート!\n"); + } + + if (m_itemNo == DUNGEON_EXIT || m_itemNo == DUNGEON_EXIT_2) { + current.angle.y = dComIfGp_getPlayer(0)->shape_angle.y; + } + + if (m_itemNo == UTAWA_HEART || m_itemNo == KAKERA_HEART) { + JPABaseEmitter* emitter = field_0x96c.getEmitter(); + if (emitter == NULL) { + dComIfGp_particle_set(0x8DE, ¤t.pos, NULL, NULL, 0xFF, &field_0x96c, -1, NULL, NULL, NULL); + } + + emitter = field_0x980.getEmitter(); + if (emitter == NULL) { + dComIfGp_particle_set(0x8DF, ¤t.pos, NULL, NULL, 0xFF, &field_0x96c, -1, NULL, NULL, NULL); + } + + mParticleAlpha = 0xFF; + } + + if ((m_itemNo == ORANGE_RUPEE || m_itemNo == SILVER_RUPEE) && field_0x96c.getEmitter() == NULL) { + cXyz scale(0.55f, 0.55f, 0.55f); + dComIfGp_particle_set(0xC14, &field_0x99c, NULL, &scale, 0xFF, &field_0x96c, -1, NULL, NULL, NULL); + } + + if (m_itemNo == WALLET_LV3 && field_0x96c.getEmitter() == NULL) { + cXyz scale(1.2f, 1.2f, 1.2f); + dComIfGp_particle_set(0xC14, &field_0x99c, NULL, &scale, 0xFF, &field_0x96c, -1, NULL, NULL, NULL); + } + + if (m_itemNo == CHUCHU_RARE && field_0x96c.getEmitter() == NULL) { + cXyz scale(0.8f, 0.8f, 0.8f); + dComIfGp_particle_set(0xC14, &field_0x99c, NULL, &scale, 0xFF, &field_0x96c, -1, NULL, NULL, NULL); + } + + if ((m_itemNo == FAIRY_DROP || m_itemNo == DROP_BOTTLE) && field_0x96c.getEmitter() == NULL) { + dComIfGp_particle_set(0x8C15, &field_0x99c, NULL, NULL, 0xFF, &field_0x96c, -1, NULL, NULL, NULL); + } + + if (isInsect(m_itemNo)) { + setInsectEffect(); + } + + fopAcM_onDraw(this); + setAction(ACTION_EVENT_e); + } } -/* ############################################################################################## */ -/* 804E19EC-804E19F0 000018 0004+00 1/1 0/0 0/0 .rodata @4145 */ -SECTION_RODATA static f32 const lit_4145 = 1.0f / 10.0f; -COMPILER_STRIP_GATE(0x804E19EC, &lit_4145); - -/* 804E1A4C-804E1A4C 000078 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ -#pragma push -#pragma force_active on -SECTION_DEAD static char const* const stringBase_804E1A4C = "F_SP116"; -SECTION_DEAD static char const* const stringBase_804E1A54 = "F_SP118"; -SECTION_DEAD static char const* const stringBase_804E1A5C = "F_SP121"; -SECTION_DEAD static char const* const stringBase_804E1A64 = "D_SB06"; -SECTION_DEAD static char const* const stringBase_804E1A6B = "F_SP115"; -SECTION_DEAD static char const* const stringBase_804E1A73 = "F_SP108"; -SECTION_DEAD static char const* const stringBase_804E1A7B = "F_SP110"; -SECTION_DEAD static char const* const stringBase_804E1A83 = "F_SP109"; -SECTION_DEAD static char const* const stringBase_804E1A8B = "F_SP126"; -SECTION_DEAD static char const* const stringBase_804E1A93 = "D_MN05"; -SECTION_DEAD static char const* const stringBase_804E1A9A = "D_MN04"; -SECTION_DEAD static char const* const stringBase_804E1AA1 = "D_MN01"; -SECTION_DEAD static char const* const stringBase_804E1AA8 = "D_MN10"; -SECTION_DEAD static char const* const stringBase_804E1AAF = "D_MN11"; -SECTION_DEAD static char const* const stringBase_804E1AB6 = "D_MN06"; -SECTION_DEAD static char const* const stringBase_804E1ABD = "D_MN07"; -SECTION_DEAD static char const* const stringBase_804E1AC4 = "D_MN08"; -SECTION_DEAD static char const* const stringBase_804E1ACB = "F_SP128"; -SECTION_DEAD static char const* const stringBase_804E1AD3 = "F_SP114"; -SECTION_DEAD static char const* const stringBase_804E1ADB = "F_SP00"; -SECTION_DEAD static char const* const stringBase_804E1AE2 = "F_SP127"; -SECTION_DEAD static char const* const stringBase_804E1AEA = "D_SB02"; -SECTION_DEAD static char const* const stringBase_804E1AF1 = "D_SB03"; -SECTION_DEAD static char const* const stringBase_804E1AF8 = "D_SB04"; -SECTION_DEAD static char const* const stringBase_804E1AFF = "D_SB00"; -SECTION_DEAD static char const* const stringBase_804E1B06 = "F_SP117"; -#pragma pop - /* 804E00DC-804E0A50 0005FC 0974+00 1/1 0/0 0/0 .text actionEvent__9daDitem_cFv */ +// NONMATCHING - r30/r31 swap void daDitem_c::actionEvent() { - // NONMATCHING + if (mSetLightEff) { + cLib_addCalc2(&mLight.mPow, mLightStrength, 0.1f, 1.0f); + } + + if (m_itemNo == POU_SPIRIT) { + mSound.startLevelSound(Z2SE_EN_PO_SOUL, 0, -1); + } + + if (chkDead()) { + if (!chkArgFlag(0x1)) { + execItemGet(m_itemNo); + } + + if (m_itemNo == KAKERA_HEART) { + s32 room_no = dComIfGp_roomControl_getStayNo(); + + if (strcmp(dComIfGp_getStartStageName(), "F_SP116") == 0 && room_no == 2) { + onEventReg(0, 0); + } else if (strcmp(dComIfGp_getStartStageName(), "F_SP118") == 0 && room_no == 1) { + onEventReg(0, 1); + } else if (strcmp(dComIfGp_getStartStageName(), "F_SP121") == 0 && room_no == 6) { + onEventReg(0, 2); + } else if (strcmp(dComIfGp_getStartStageName(), "D_SB06") == 0 && room_no == 1 && dComIfG_play_c::getLayerNo(0) == 2) { + onEventReg(0, 3); + } else if (strcmp(dComIfGp_getStartStageName(), "F_SP115") == 0 && room_no == 0) { + onEventReg(0, 4); + } else if (strcmp(dComIfGp_getStartStageName(), "F_SP108") == 0 && room_no == 14) { + onEventReg(0, 5); + } else if (strcmp(dComIfGp_getStartStageName(), "F_SP115") == 0 && room_no == 1) { + onEventReg(0, 6); + } else if (strcmp(dComIfGp_getStartStageName(), "F_SP121") == 0 && room_no == 11) { + onEventReg(1, 0); + } else if (strcmp(dComIfGp_getStartStageName(), "D_SB06") == 0 && room_no == 1 && dComIfG_play_c::getLayerNo(0) == 0) { + onEventReg(1, 1); + } else if (strcmp(dComIfGp_getStartStageName(), "F_SP110") == 0 && room_no == 0) { + onEventReg(1, 2); + } else if (strcmp(dComIfGp_getStartStageName(), "F_SP109") == 0 && room_no == 0 && dComIfGs_isTmpBit(0x0604)) { + onEventReg(1, 3); + } else if (strcmp(dComIfGp_getStartStageName(), "F_SP126") == 0 && room_no == 0) { + onEventReg(1, 5); + } else if (strcmp(dComIfGp_getStartStageName(), "D_MN05") == 0 && room_no == 5) { + onEventReg(1, 6); + } else if (strcmp(dComIfGp_getStartStageName(), "D_MN05") == 0 && room_no == 3) { + onEventReg(1, 7); + } else if (strcmp(dComIfGp_getStartStageName(), "D_MN04") == 0 && room_no == 6) { + onEventReg(2, 0); + } else if (strcmp(dComIfGp_getStartStageName(), "D_MN04") == 0 && room_no == 4) { + onEventReg(2, 1); + } else if (strcmp(dComIfGp_getStartStageName(), "D_MN01") == 0 && room_no == 3) { + onEventReg(2, 2); + } else if (strcmp(dComIfGp_getStartStageName(), "D_MN01") == 0 && room_no == 8) { + onEventReg(2, 3); + } else if (strcmp(dComIfGp_getStartStageName(), "D_MN10") == 0 && room_no == 13) { + onEventReg(2, 4); + } else if (strcmp(dComIfGp_getStartStageName(), "D_MN10") == 0 && room_no == 2) { + onEventReg(2, 5); + } else if (strcmp(dComIfGp_getStartStageName(), "D_MN11") == 0 && room_no == 7) { + onEventReg(2, 6); + } else if (strcmp(dComIfGp_getStartStageName(), "D_MN11") == 0 && room_no == 0) { + onEventReg(2, 7); + } else if (strcmp(dComIfGp_getStartStageName(), "D_MN06") == 0 && room_no == 4) { + onEventReg(3, 0); + } else if (strcmp(dComIfGp_getStartStageName(), "D_MN06") == 0 && room_no == 3) { + onEventReg(3, 1); + } else if (strcmp(dComIfGp_getStartStageName(), "D_MN07") == 0 && room_no == 11) { + onEventReg(3, 2); + } else if (strcmp(dComIfGp_getStartStageName(), "D_MN07") == 0 && room_no == 12) { + onEventReg(3, 3); + } else if (strcmp(dComIfGp_getStartStageName(), "D_MN08") == 0 && room_no == 4) { + onEventReg(3, 4); + } else if (strcmp(dComIfGp_getStartStageName(), "D_MN08") == 0 && room_no == 1) { + onEventReg(3, 5); + } else if (strcmp(dComIfGp_getStartStageName(), "F_SP128") == 0 && room_no == 0) { + onEventReg(3, 7); + } else if (strcmp(dComIfGp_getStartStageName(), "F_SP114") == 0 && room_no == 1) { + onEventReg(4, 0); + } else if (strcmp(dComIfGp_getStartStageName(), "F_SP00") == 0 && room_no == 0) { + onEventReg(4, 3); + } else if (strcmp(dComIfGp_getStartStageName(), "F_SP108") == 0 && room_no == 5) { + onEventReg(4, 5); + } else if (strcmp(dComIfGp_getStartStageName(), "F_SP127") == 0 && room_no == 0) { + onEventReg(4, 6); + } else if (strcmp(dComIfGp_getStartStageName(), "D_SB02") == 0 && room_no == 0) { + onEventReg(4, 7); + } else if (strcmp(dComIfGp_getStartStageName(), "D_SB03") == 0 && room_no == 0) { + onEventReg(5, 0); + } else if (strcmp(dComIfGp_getStartStageName(), "D_SB04") == 0 && room_no == 10) { + onEventReg(5, 1); + } else if (strcmp(dComIfGp_getStartStageName(), "D_SB00") == 0 && room_no == 0) { + onEventReg(5, 2); + } else if (strcmp(dComIfGp_getStartStageName(), "F_SP117") == 0 && room_no == 2) { + onEventReg(5, 3); + } + } + + endInsectEffect(); + fopAcM_offDraw(this); + setAction(ACTION_WAIT_LIGHT_END_e); + } } -/* ############################################################################################## */ -/* 804E19F0-804E19F4 00001C 0004+00 0/1 0/0 0/0 .rodata @4175 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4175 = 1.0f / 5.0f; -COMPILER_STRIP_GATE(0x804E19F0, &lit_4175); -#pragma pop - -/* 804E19F4-804E19F8 000020 0004+00 0/1 0/0 0/0 .rodata @4176 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4176 = 3.0f; -COMPILER_STRIP_GATE(0x804E19F4, &lit_4176); -#pragma pop - /* 804E0A50-804E0B40 000F70 00F0+00 1/1 0/0 0/0 .text actionWaitLightEnd__9daDitem_cFv */ void daDitem_c::actionWaitLightEnd() { - // NONMATCHING + BOOL particle_hidden = TRUE; + + if (m_itemNo == UTAWA_HEART || m_itemNo == KAKERA_HEART) { + particle_hidden = cLib_chaseUC(&mParticleAlpha, 0, 26); + + JPABaseEmitter* emitter = field_0x96c.getEmitter(); + if (emitter != NULL) { + emitter->setGlobalAlpha(mParticleAlpha); + } + + emitter = field_0x980.getEmitter(); + if (emitter != NULL) { + emitter->setGlobalAlpha(mParticleAlpha); + } + } + + cLib_addCalc(&mLight.mPow, 0.0f, 0.2f, 3.0f, 1.0f); + + if (mSetLightEff && mLight.mPow == 0.0f && particle_hidden) { + setAction(ACTION_END_e); + } else if (chkArgFlag(0x2) || chkArgFlag(0x4)) { + setAction(ACTION_END_e); + } } /* 804E0B40-804E0B60 001060 0020+00 1/1 0/0 0/0 .text actionEnd__9daDitem_cFv */ void daDitem_c::actionEnd() { - // NONMATCHING + fopAcM_delete(this); } /* 804E0B60-804E0C44 001080 00E4+00 1/1 0/0 0/0 .text setInsectEffect__9daDitem_cFv */ void daDitem_c::setInsectEffect() { - // NONMATCHING + if (!chkArgFlag(0x2) && !chkArgFlag(0x4)) { + field_0x994 = dComIfGp_particle_set(0xA1B, ¤t.pos, &home.angle, NULL, 0xFF, NULL, -1, NULL, NULL, NULL); + } + + field_0x998 = dComIfGp_particle_set(0xA1C, ¤t.pos, &home.angle, NULL, 0xFF, NULL, -1, NULL, NULL, NULL); } /* 804E0C44-804E0CB0 001164 006C+00 1/1 0/0 0/0 .text followInsectEffect__9daDitem_cFv */ void daDitem_c::followInsectEffect() { - // NONMATCHING + if (field_0x994 != NULL) { + field_0x994->setGlobalTranslation(current.pos); + } + + if (field_0x998 != NULL) { + field_0x998->setGlobalTranslation(current.pos); + } } /* 804E0CB0-804E0D44 0011D0 0094+00 2/2 0/0 0/0 .text endInsectEffect__9daDitem_cFv */ void daDitem_c::endInsectEffect() { - // NONMATCHING + if (field_0x994 != NULL) { + field_0x994->stopCreateParticle(); + field_0x994->quitImmortalEmitter(); + field_0x994->becomeInvalidEmitter(); + field_0x994 = NULL; + } + + if (field_0x998 != NULL) { + field_0x998->stopCreateParticle(); + field_0x998->quitImmortalEmitter(); + field_0x998->becomeInvalidEmitter(); + field_0x998 = NULL; + } } -/* ############################################################################################## */ -/* 804E19F8-804E1A04 000024 000C+00 1/1 0/0 0/0 .rodata l_event_reg$4260 */ -SECTION_RODATA static u8 const l_event_reg[12] = { - 0xF0, 0xFF, 0xEF, 0xFF, 0xEE, 0xFF, 0xED, 0xFF, 0xEC, 0xFF, 0xEB, 0xFF, -}; -COMPILER_STRIP_GATE(0x804E19F8, &l_event_reg); - /* 804E0D44-804E0DB4 001264 0070+00 1/1 0/0 0/0 .text onEventReg__9daDitem_cFii */ -void daDitem_c::onEventReg(int param_0, int param_1) { - // NONMATCHING +void daDitem_c::onEventReg(int i_regNo, int i_value) { + static u16 const l_event_reg[] = { + 0xF0FF, 0xEFFF, 0xEEFF, 0xEDFF, 0xECFF, 0xEBFF, + }; + + u8 reg = dComIfGs_getEventReg(l_event_reg[i_regNo]); + reg |= (1 << i_value); + + dComIfGs_setEventReg(l_event_reg[i_regNo], reg); + + // "Heart Piece: %d %d\n" + OS_REPORT("ハートの欠片:%d %d\n", i_regNo, i_value); } -/* ############################################################################################## */ -/* 804E1A04-804E1A08 000030 0004+00 0/1 0/0 0/0 .rodata @4361 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4361 = 200.0f; -COMPILER_STRIP_GATE(0x804E1A04, &lit_4361); -#pragma pop - -/* 804E1A08-804E1A0C 000034 0004+00 0/1 0/0 0/0 .rodata @4362 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4362 = 90.0f; -COMPILER_STRIP_GATE(0x804E1A08, &lit_4362); -#pragma pop - -/* 804E1A0C-804E1A10 000038 0004+00 0/1 0/0 0/0 .rodata @4363 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4363 = 50.0f; -COMPILER_STRIP_GATE(0x804E1A0C, &lit_4363); -#pragma pop - -/* 804E1A10-804E1A14 00003C 0004+00 0/1 0/0 0/0 .rodata @4364 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4364 = 30.0f; -COMPILER_STRIP_GATE(0x804E1A10, &lit_4364); -#pragma pop - -/* 804E1A14-804E1A18 000040 0004+00 0/1 0/0 0/0 .rodata @4365 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4365 = 140.0f; -COMPILER_STRIP_GATE(0x804E1A14, &lit_4365); -#pragma pop - -/* 804E1A18-804E1A1C 000044 0004+00 0/2 0/0 0/0 .rodata @4366 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4366 = 20.0f; -COMPILER_STRIP_GATE(0x804E1A18, &lit_4366); -#pragma pop - -/* 804E1BE8-804E1BEC 000008 0001+03 2/2 0/0 0/0 .bss @1109 */ -static u8 lit_1109[1 + 3 /* padding */]; - -/* 804E1BEC-804E1BF0 00000C 0001+03 0/0 0/0 0/0 .bss @1107 */ -#pragma push -#pragma force_active on -static u8 lit_1107[1 + 3 /* padding */]; -#pragma pop - -/* 804E1BF0-804E1BF4 000010 0001+03 0/0 0/0 0/0 .bss @1105 */ -#pragma push -#pragma force_active on -static u8 lit_1105[1 + 3 /* padding */]; -#pragma pop - -/* 804E1BF4-804E1BF8 000014 0001+03 0/0 0/0 0/0 .bss @1104 */ -#pragma push -#pragma force_active on -static u8 lit_1104[1 + 3 /* padding */]; -#pragma pop - -/* 804E1BF8-804E1BFC 000018 0001+03 0/0 0/0 0/0 .bss @1099 */ -#pragma push -#pragma force_active on -static u8 lit_1099[1 + 3 /* padding */]; -#pragma pop - -/* 804E1BFC-804E1C00 00001C 0001+03 0/0 0/0 0/0 .bss @1097 */ -#pragma push -#pragma force_active on -static u8 lit_1097[1 + 3 /* padding */]; -#pragma pop - -/* 804E1C00-804E1C04 000020 0001+03 0/0 0/0 0/0 .bss @1095 */ -#pragma push -#pragma force_active on -static u8 lit_1095[1 + 3 /* padding */]; -#pragma pop - -/* 804E1C04-804E1C08 000024 0001+03 0/0 0/0 0/0 .bss @1094 */ -#pragma push -#pragma force_active on -static u8 lit_1094[1 + 3 /* padding */]; -#pragma pop - -/* 804E1C08-804E1C0C 000028 0001+03 0/0 0/0 0/0 .bss @1057 */ -#pragma push -#pragma force_active on -static u8 lit_1057[1 + 3 /* padding */]; -#pragma pop - -/* 804E1C0C-804E1C10 00002C 0001+03 0/0 0/0 0/0 .bss @1055 */ -#pragma push -#pragma force_active on -static u8 lit_1055[1 + 3 /* padding */]; -#pragma pop - -/* 804E1C10-804E1C14 000030 0001+03 0/0 0/0 0/0 .bss @1053 */ -#pragma push -#pragma force_active on -static u8 lit_1053[1 + 3 /* padding */]; -#pragma pop - -/* 804E1C14-804E1C18 000034 0001+03 0/0 0/0 0/0 .bss @1052 */ -#pragma push -#pragma force_active on -static u8 lit_1052[1 + 3 /* padding */]; -#pragma pop - -/* 804E1C18-804E1C1C 000038 0001+03 0/0 0/0 0/0 .bss @1014 */ -#pragma push -#pragma force_active on -static u8 lit_1014[1 + 3 /* padding */]; -#pragma pop - -/* 804E1C1C-804E1C20 00003C 0001+03 0/0 0/0 0/0 .bss @1012 */ -#pragma push -#pragma force_active on -static u8 lit_1012[1 + 3 /* padding */]; -#pragma pop - -/* 804E1C20-804E1C24 000040 0001+03 0/0 0/0 0/0 .bss @1010 */ -#pragma push -#pragma force_active on -static u8 lit_1010[1 + 3 /* padding */]; -#pragma pop - -/* 804E1C24-804E1C28 000044 0001+03 0/0 0/0 0/0 .bss @1009 */ -#pragma push -#pragma force_active on -static u8 lit_1009[1 + 3 /* padding */]; -#pragma pop - -/* 804E1C28-804E1C34 000048 000C+00 0/1 0/0 0/0 .bss @3758 */ -#pragma push -#pragma force_active on -static u8 lit_3758[12]; -#pragma pop +UNK_BSS(1109) +UNK_BSS(1107) +UNK_BSS(1105) +UNK_BSS(1104) +UNK_BSS(1099) +UNK_BSS(1097) +UNK_BSS(1095) +UNK_BSS(1094) +UNK_BSS(1057) +UNK_BSS(1055) +UNK_BSS(1053) +UNK_BSS(1052) +UNK_BSS(1014) +UNK_BSS(1012) +UNK_BSS(1010) +UNK_BSS(1009) /* 804E1C34-804E1C40 000054 000C+00 0/2 0/0 0/0 .bss l_player_offset */ -#pragma push -#pragma force_active on -static u8 l_player_offset[12]; -#pragma pop - -/* 804E1C40-804E1C4C 000060 000C+00 0/1 0/0 0/0 .bss @3759 */ -#pragma push -#pragma force_active on -static u8 lit_3759[12]; -#pragma pop +static cXyz l_player_offset(0.0f, 115.0f, 54.0f); /* 804E1C4C-804E1C58 00006C 000C+00 0/2 0/0 0/0 .bss l_wolf_offset */ -#pragma push -#pragma force_active on -static u8 l_wolf_offset[12]; -#pragma pop - -/* 804E1C58-804E1C64 000078 000C+00 0/1 0/0 0/0 .bss @3760 */ -#pragma push -#pragma force_active on -static u8 lit_3760[12]; -#pragma pop +static cXyz l_wolf_offset(13.0f, 135.0f, 57.0f); /* 804E1C64-804E1C70 000084 000C+00 0/2 0/0 0/0 .bss l_horse_offset */ -#pragma push -#pragma force_active on -static u8 l_horse_offset[12]; -#pragma pop - -/* 804E1C70-804E1C80 000090 000C+04 0/1 0/0 0/0 .bss @4275 */ -#pragma push -#pragma force_active on -static u8 lit_4275[12 + 4 /* padding */]; -#pragma pop - -/* 804E1C80-804E1C8C 0000A0 000C+00 0/1 0/0 0/0 .bss @4278 */ -#pragma push -#pragma force_active on -static u8 lit_4278[12]; -#pragma pop - -/* 804E1C8C-804E1C98 0000AC 000C+00 0/1 0/0 0/0 .bss @4279 */ -#pragma push -#pragma force_active on -static u8 lit_4279[12]; -#pragma pop - -/* 804E1C98-804E1CBC 0000B8 0024+00 0/1 0/0 0/0 .bss offset_tbl$4274 */ -#pragma push -#pragma force_active on -static u8 offset_tbl[36]; -#pragma pop +static cXyz l_horse_offset(0.0f, 20.0f, 54.0f); /* 804E0DB4-804E105C 0012D4 02A8+00 1/1 0/0 0/0 .text set_pos__9daDitem_cFv */ void daDitem_c::set_pos() { - // NONMATCHING + daPy_py_c* player = (daPy_py_c*)dComIfGp_getPlayer(0); + + cXyz pos; + cXyz offset; + cXyz sp38(player->current.pos); + + static cXyz offset_tbl[] = { + cXyz(0.0f, 200.0f, 0.0f), + cXyz(0.0f, 90.0f, 50.0f), + cXyz(30.0f, 140.0f, 20.0f), + }; + + if (chkArgFlag(0x8)) { + current.pos = field_0x92c; + return; + } else if (chkArgFlag(0x2)) { + offset = offset_tbl[1]; + } else if (chkArgFlag(0x4)) { + offset = offset_tbl[1]; + } else if (chkArgFlag(0x10)) { + offset = field_0x92c; + } else { + offset = offset_tbl[0]; + } + + if (daPy_py_c::i_checkNowWolf()) { + offset = l_wolf_offset; + sp38.y = player->getLeftFootPosP()->y; + } else if (player->checkHorseRide()) { + offset = l_horse_offset; + } else { + offset = l_player_offset; + sp38.y = player->getLeftFootPosP()->y; + } + + cLib_offsetPos(&pos, &sp38, player->shape_angle.y, &offset); + current.pos = pos; } /* 804E105C-804E1098 00157C 003C+00 1/1 0/0 0/0 .text anim_control__9daDitem_cFv */ void daDitem_c::anim_control() { - // NONMATCHING + animPlay(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f); } /* 804E1098-804E10D0 0015B8 0038+00 1/1 0/0 0/0 .text initEffectLight__9daDitem_cFv */ void daDitem_c::initEffectLight() { - // NONMATCHING + mLight.mColor.r = l_light_color.r; + mLight.mColor.g = l_light_color.g; + mLight.mColor.b = l_light_color.b; + mLight.mPow = 0.0f; + mLight.mFluctuation = 0.0f; + mSetLightEff = false; } -/* ############################################################################################## */ -/* 804E1A1C-804E1A20 000048 0004+00 1/2 0/0 0/0 .rodata @4394 */ -SECTION_RODATA static f32 const lit_4394 = 0.5f; -COMPILER_STRIP_GATE(0x804E1A1C, &lit_4394); - -/* 804E1A20-804E1A24 00004C 0004+00 1/1 0/0 0/0 .rodata @4395 */ -SECTION_RODATA static f32 const lit_4395 = 8.0f; -COMPILER_STRIP_GATE(0x804E1A20, &lit_4395); - /* 804E10D0-804E111C 0015F0 004C+00 2/2 0/0 0/0 .text settingEffectLight__9daDitem_cFv */ void daDitem_c::settingEffectLight() { - // NONMATCHING + f32 var_f31 = mpModel->getModelData()->getJointNodePointer(0)->getMax()->y; + mLight.mPosition.set(current.pos.x, current.pos.y + (var_f31 * 0.5f), current.pos.z); + mLightStrength = 8.0f; } /* 804E111C-804E11D4 00163C 00B8+00 2/2 0/0 0/0 .text set_mtx__9daDitem_cFv */ void daDitem_c::set_mtx() { - // NONMATCHING + mpModel->setBaseScale(scale); + + if (m_itemNo != DUNGEON_EXIT && m_itemNo != DUNGEON_BACK && m_itemNo != LV7_DUNGEON_EXIT && m_itemNo != DUNGEON_EXIT_2) { + s16 var_r28 = 0xFFFF / 250; + fopAcM_addAngleY(this, current.angle.y + var_r28, var_r28); + } + + mDoMtx_stack_c::transS(current.pos.x, current.pos.y, current.pos.z); + mDoMtx_stack_c::YrotM(current.angle.y); + mpModel->setBaseTRMtx(mDoMtx_stack_c::get()); } /* 804E11D4-804E122C 0016F4 0058+00 1/0 0/0 0/0 .text setTevStr__9daDitem_cFv */ void daDitem_c::setTevStr() { - // NONMATCHING + g_env_light.settingTevStruct(14, ¤t.pos, &tevStr); + g_env_light.setLightTevColorType_MAJI(mpModel, &tevStr); } /* 804E122C-804E1230 00174C 0004+00 1/0 0/0 0/0 .text setListStart__9daDitem_cFv */ -void daDitem_c::setListStart() { - /* empty function */ -} - -/* ############################################################################################## */ -/* 804E1A24-804E1A2C 000050 0008+00 1/1 0/0 0/0 .rodata nodisp_mat$4435 */ -SECTION_RODATA static u8 const nodisp_mat[8] = { - 0x70, 0x61, 0x72, 0x74, 0x73, 0x5F, 0x6D, 0x00, -}; -COMPILER_STRIP_GATE(0x804E1A24, &nodisp_mat); +void daDitem_c::setListStart() {} /* 804E1230-804E12C8 001750 0098+00 1/1 0/0 0/0 .text draw_WOOD_STICK__9daDitem_cFv */ void daDitem_c::draw_WOOD_STICK() { - // NONMATCHING + static const char nodisp_mat[] = "parts_m"; + + J3DModelData* modelData = mpModel->getModelData(); + JUTNameTab* nametab = modelData->getMaterialTable().getMaterialName(); + + for (u16 i = 0; i < modelData->getMaterialNum(); i++) { + if (strcmp(nodisp_mat, nametab->getName(i)) == 0) { + modelData->getMaterialNodePointer(i)->getShape()->hide(); + } + } +} + +int daDitem_c::Delete() { + if (!chkArgFlag(0x2) && !chkArgFlag(0x4) && mSetLightEff) { + dKy_efplight_cut(&mLight); + } + + if (m_itemNo == UTAWA_HEART || m_itemNo == KAKERA_HEART) { + field_0x96c.remove(); + field_0x980.remove(); + } + + if (m_itemNo == ORANGE_RUPEE || m_itemNo == SILVER_RUPEE || m_itemNo == WALLET_LV3 || m_itemNo == FAIRY_DROP || m_itemNo == DROP_BOTTLE || m_itemNo == CHUCHU_RARE) { + field_0x96c.remove(); + } + + endInsectEffect(); + mSound.deleteObject(); + return DeleteBase(dItem_data::getArcName(m_itemNo)); } /* 804E12C8-804E13C8 0017E8 0100+00 1/0 0/0 0/0 .text daDitem_Delete__FP9daDitem_c */ -static void daDitem_Delete(daDitem_c* param_0) { - // NONMATCHING +static int daDitem_Delete(daDitem_c* i_this) { + return i_this->Delete(); } -/* ############################################################################################## */ -/* 804E1B10-804E1B30 -00001 0020+00 1/0 0/0 0/0 .data l_daDitem_Method */ -static actor_method_class l_daDitem_Method = { - (process_method_func)daDitem_Create__FP9daDitem_c, - (process_method_func)daDitem_Delete__FP9daDitem_c, - (process_method_func)daDitem_Execute__FP9daDitem_c, - 0, - (process_method_func)daDitem_Draw__FP9daDitem_c, -}; +int daDitem_c::create() { + fopAcM_SetupActor(this, daDitem_c); -/* 804E1B30-804E1B60 -00001 0030+00 0/0 0/0 1/0 .data g_profile_Demo_Item */ -extern actor_process_profile_definition g_profile_Demo_Item = { - fpcLy_CURRENT_e, // mLayerID - 7, // mListID - fpcPi_CURRENT_e, // mListPrio - PROC_Demo_Item, // mProcName - &g_fpcLf_Method.mBase, // sub_method - sizeof(daDitem_c), // mSize - 0, // mSizeOther - 0, // mParameters - &g_fopAc_Method.base, // sub_method - 241, // mPriority - &l_daDitem_Method, // sub_method - 0x00060000, // mStatus - fopAc_ACTOR_e, // mActorType - fopAc_CULLBOX_CUSTOM_e, // cullType -}; + m_itemNo = daDitem_prm::getNo(this); -/* 804E1B60-804E1B6C 000050 000C+00 2/2 0/0 0/0 .data __vt__8cM3dGCyl */ -SECTION_DATA extern void* __vt__8cM3dGCyl[3] = { - (void*)NULL /* RTTI */, - (void*)NULL, - (void*)__dt__8cM3dGCylFv, -}; + const char* arc_name = dItem_data::getArcName(m_itemNo); + s16 bmd_name = dItem_data::getBmdName(m_itemNo); -/* 804E1B6C-804E1B78 00005C 000C+00 2/2 0/0 0/0 .data __vt__8cM3dGAab */ -SECTION_DATA extern void* __vt__8cM3dGAab[3] = { - (void*)NULL /* RTTI */, - (void*)NULL, - (void*)__dt__8cM3dGAabFv, -}; + if (bmd_name < 0 || arc_name == NULL) { + if (bmd_name == 0) { + // "It's an item with no model data! [%d]\n" + OS_REPORT_ERROR("モデルデータのないアイテムゲットです![%d]\n", m_itemNo); + } -/* 804E1B78-804E1B9C 000068 0024+00 2/2 0/0 0/0 .data __vt__12dBgS_ObjAcch */ -SECTION_DATA extern void* __vt__12dBgS_ObjAcch[9] = { - (void*)NULL /* RTTI */, - (void*)NULL, - (void*)__dt__12dBgS_ObjAcchFv, - (void*)NULL, - (void*)NULL, - (void*)func_804E19B8, - (void*)NULL, - (void*)NULL, - (void*)func_804E19B0, -}; + if (arc_name == NULL) { + // "There's no archive name for Get Model! [%d]\n" + OS_REPORT_ERROR("ゲット用モデルのアーカイブ名がありません![%d]\n", m_itemNo); + } -/* 804E1B9C-804E1BE0 00008C 0044+00 1/1 0/0 0/0 .data __vt__9daDitem_c */ -SECTION_DATA extern void* __vt__9daDitem_c[17] = { - (void*)NULL /* RTTI */, - (void*)NULL, - (void*)DrawBase__12daItemBase_cFv, - (void*)setListStart__9daDitem_cFv, - (void*)settingBeforeDraw__12daItemBase_cFv, - (void*)setTevStr__9daDitem_cFv, - (void*)setShadow__12daItemBase_cFv, - (void*)animEntry__12daItemBase_cFv, - (void*)RotateYBase__12daItemBase_cFv, - (void*)clothCreate__12daItemBase_cFv, - (void*)__CreateHeap__9daDitem_cFv, - (void*)chkFlag__12daItemBase_cFi, - (void*)getTevFrm__12daItemBase_cFv, - (void*)getBtpFrm__12daItemBase_cFv, - (void*)getShadowSize__12daItemBase_cFv, - (void*)getCollisionH__12daItemBase_cFv, - (void*)getCollisionR__12daItemBase_cFv, -}; + m_itemNo = GREEN_RUPEE; + } -/* 804E13C8-804E15BC 0018E8 01F4+00 1/0 0/0 0/0 .text daDitem_Create__FP9daDitem_c */ -static void daDitem_Create(daDitem_c* param_0) { - // NONMATCHING -} + int phase_state = dComIfG_resLoad(&mPhase, dItem_data::getArcName(m_itemNo)); + if (phase_state == cPhs_COMPLEATE_e) { + if (!fopAcM_entrySolidHeap(this, CheckItemCreateHeap, 0x80003390)) { + return cPhs_ERROR_e; + } -/* 804E15BC-804E1604 001ADC 0048+00 1/0 0/0 0/0 .text __dt__8cM3dGCylFv */ -// cM3dGCyl::~cM3dGCyl() { -extern "C" void __dt__8cM3dGCylFv() { - // NONMATCHING -} + CreateInit(); + OS_REPORT("DEMOITEM PARAM:%x\n", fopAcM_GetParam(this)); + } -/* 804E1604-804E164C 001B24 0048+00 1/0 0/0 0/0 .text __dt__8cM3dGAabFv */ -// cM3dGAab::~cM3dGAab() { -extern "C" void __dt__8cM3dGAabFv() { - // NONMATCHING + return phase_state; } -/* 804E164C-804E16BC 001B6C 0070+00 3/2 0/0 0/0 .text __dt__12dBgS_ObjAcchFv */ -// dBgS_ObjAcch::~dBgS_ObjAcch() { -extern "C" void __dt__12dBgS_ObjAcchFv() { - // NONMATCHING +/* 804E13C8-804E15BC 0018E8 01F4+00 1/0 0/0 0/0 .text daDitem_Create__FP9daDitem_c */ +static int daDitem_Create(daDitem_c* i_this) { + return i_this->create(); } -/* ############################################################################################## */ -/* 804E1A2C-804E1A30 000058 0004+00 0/1 0/0 0/0 .rodata @4668 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4668 = 7.0f / 20.0f; -COMPILER_STRIP_GATE(0x804E1A2C, &lit_4668); -#pragma pop - -/* 804E1A30-804E1A34 00005C 0004+00 0/1 0/0 0/0 .rodata @4669 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4669 = 10.0f; -COMPILER_STRIP_GATE(0x804E1A30, &lit_4669); -#pragma pop - -/* 804E1A34-804E1A38 000060 0004+00 0/1 0/0 0/0 .rodata @4670 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4670 = 15.0f; -COMPILER_STRIP_GATE(0x804E1A34, &lit_4670); -#pragma pop +int daDitem_c::execute() { + m_timer++; + + action(); + set_pos(); + anim_control(); + + if (chkDraw()) { + f32 target_scale_x = 1.0f; + if (field_0x938 != 0.0f) { + target_scale_x = field_0x938; + } + + cLib_chaseF(&scale.x, target_scale_x, 0.35f); + scale.y = scale.x; + scale.z = scale.x; + } + + settingEffectLight(); + set_mtx(); + + eyePos = current.pos; + eyePos.y += mpModel->getModelData()->getJointNodePointer(0)->getMax()->y * 0.5f; + + if (m_itemNo == ORANGE_RUPEE || m_itemNo == SILVER_RUPEE) { + field_0x99c = current.pos; + field_0x99c.y += 10.0f; + } else if (m_itemNo == WALLET_LV3 || m_itemNo == CHUCHU_RARE) { + field_0x99c = current.pos; + field_0x99c.y += 15.0f; + } else if (m_itemNo == FAIRY_DROP || m_itemNo == DROP_BOTTLE) { + field_0x99c = current.pos; + } + + mSound.framework(0, dComIfGp_getReverb(fopAcM_GetRoomNo(this))); + return 1; +} /* 804E16BC-804E1878 001BDC 01BC+00 1/0 0/0 0/0 .text daDitem_Execute__FP9daDitem_c */ -static void daDitem_Execute(daDitem_c* param_0) { - // NONMATCHING +static int daDitem_Execute(daDitem_c* i_this) { + return i_this->execute(); } -/* 804E1878-804E18CC 001D98 0054+00 1/0 0/0 0/0 .text daDitem_Draw__FP9daDitem_c */ -static void daDitem_Draw(daDitem_c* param_0) { - // NONMATCHING -} +int daDitem_c::draw() { + switch (m_itemNo) { + case WOOD_STICK: + draw_WOOD_STICK(); + break; + } -/* ############################################################################################## */ -/* 804E1A38-804E1A3C 000064 0004+00 0/1 0/0 0/0 .rodata @4716 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4716 = 115.0f; -COMPILER_STRIP_GATE(0x804E1A38, &lit_4716); -#pragma pop - -/* 804E1A3C-804E1A40 000068 0004+00 0/1 0/0 0/0 .rodata @4717 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4717 = 54.0f; -COMPILER_STRIP_GATE(0x804E1A3C, &lit_4717); -#pragma pop - -/* 804E1A40-804E1A44 00006C 0004+00 0/1 0/0 0/0 .rodata @4718 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4718 = 13.0f; -COMPILER_STRIP_GATE(0x804E1A40, &lit_4718); -#pragma pop - -/* 804E1A44-804E1A48 000070 0004+00 0/1 0/0 0/0 .rodata @4719 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4719 = 135.0f; -COMPILER_STRIP_GATE(0x804E1A44, &lit_4719); -#pragma pop - -/* 804E1A48-804E1A4C 000074 0004+00 0/1 0/0 0/0 .rodata @4720 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4720 = 57.0f; -COMPILER_STRIP_GATE(0x804E1A48, &lit_4720); -#pragma pop - -/* 804E18CC-804E19B0 001DEC 00E4+00 0/0 1/0 0/0 .text __sinit_d_a_demo_item_cpp */ -void __sinit_d_a_demo_item_cpp() { - // NONMATCHING + DrawBase(); + return 1; } -#pragma push -#pragma force_active on -REGISTER_CTORS(0x804E18CC, __sinit_d_a_demo_item_cpp); -#pragma pop - -/* 804E19B0-804E19B8 001ED0 0008+00 1/0 0/0 0/0 .text @36@__dt__12dBgS_ObjAcchFv */ -static void func_804E19B0() { - // NONMATCHING +/* 804E1878-804E18CC 001D98 0054+00 1/0 0/0 0/0 .text daDitem_Draw__FP9daDitem_c */ +static int daDitem_Draw(daDitem_c* i_this) { + return i_this->draw(); } -/* 804E19B8-804E19C0 001ED8 0008+00 1/0 0/0 0/0 .text @20@__dt__12dBgS_ObjAcchFv */ -static void func_804E19B8() { - // NONMATCHING -} +/* 804E1B10-804E1B30 -00001 0020+00 1/0 0/0 0/0 .data l_daDitem_Method */ +static actor_method_class l_daDitem_Method = { + (process_method_func)daDitem_Create, + (process_method_func)daDitem_Delete, + (process_method_func)daDitem_Execute, + (process_method_func)NULL, + (process_method_func)daDitem_Draw, +}; + +/* 804E1B30-804E1B60 -00001 0030+00 0/0 0/0 1/0 .data g_profile_Demo_Item */ +extern actor_process_profile_definition g_profile_Demo_Item = { + fpcLy_CURRENT_e, // mLayerID + 7, // mListID + fpcPi_CURRENT_e, // mListPrio + PROC_Demo_Item, // mProcName + &g_fpcLf_Method.mBase, // sub_method + sizeof(daDitem_c), // mSize + 0, // mSizeOther + 0, // mParameters + &g_fopAc_Method.base, // sub_method + 241, // mPriority + &l_daDitem_Method, // sub_method + 0x00060000, // mStatus + fopAc_ACTOR_e, // mActorType + fopAc_CULLBOX_CUSTOM_e, // cullType +}; -/* ############################################################################################## */ -/* 804E1CBC-804E1CC0 0000DC 0004+00 0/0 0/0 0/0 .bss - * sInstance__40JASGlobalInstance<19JASDefaultBankTable> */ -#pragma push -#pragma force_active on -static u8 data_804E1CBC[4]; -#pragma pop - -/* 804E1CC0-804E1CC4 0000E0 0004+00 0/0 0/0 0/0 .bss - * sInstance__35JASGlobalInstance<14JASAudioThread> */ -#pragma push -#pragma force_active on -static u8 data_804E1CC0[4]; -#pragma pop - -/* 804E1CC4-804E1CC8 0000E4 0004+00 0/0 0/0 0/0 .bss sInstance__27JASGlobalInstance<7Z2SeMgr> */ -#pragma push -#pragma force_active on -static u8 data_804E1CC4[4]; -#pragma pop - -/* 804E1CC8-804E1CCC 0000E8 0004+00 0/0 0/0 0/0 .bss sInstance__28JASGlobalInstance<8Z2SeqMgr> */ -#pragma push -#pragma force_active on -static u8 data_804E1CC8[4]; -#pragma pop - -/* 804E1CCC-804E1CD0 0000EC 0004+00 0/0 0/0 0/0 .bss sInstance__31JASGlobalInstance<10Z2SceneMgr> - */ -#pragma push -#pragma force_active on -static u8 data_804E1CCC[4]; -#pragma pop - -/* 804E1CD0-804E1CD4 0000F0 0004+00 0/0 0/0 0/0 .bss sInstance__32JASGlobalInstance<11Z2StatusMgr> - */ -#pragma push -#pragma force_active on -static u8 data_804E1CD0[4]; -#pragma pop - -/* 804E1CD4-804E1CD8 0000F4 0004+00 0/0 0/0 0/0 .bss sInstance__31JASGlobalInstance<10Z2DebugSys> - */ -#pragma push -#pragma force_active on -static u8 data_804E1CD4[4]; -#pragma pop - -/* 804E1CD8-804E1CDC 0000F8 0004+00 0/0 0/0 0/0 .bss - * sInstance__36JASGlobalInstance<15JAISoundStarter> */ -#pragma push -#pragma force_active on -static u8 data_804E1CD8[4]; -#pragma pop - -/* 804E1CDC-804E1CE0 0000FC 0004+00 0/0 0/0 0/0 .bss - * sInstance__35JASGlobalInstance<14Z2SoundStarter> */ -#pragma push -#pragma force_active on -static u8 data_804E1CDC[4]; -#pragma pop - -/* 804E1CE0-804E1CE4 000100 0004+00 0/0 0/0 0/0 .bss - * sInstance__33JASGlobalInstance<12Z2SpeechMgr2> */ -#pragma push -#pragma force_active on -static u8 data_804E1CE0[4]; -#pragma pop - -/* 804E1CE4-804E1CE8 000104 0004+00 0/0 0/0 0/0 .bss sInstance__28JASGlobalInstance<8JAISeMgr> */ -#pragma push -#pragma force_active on -static u8 data_804E1CE4[4]; -#pragma pop - -/* 804E1CE8-804E1CEC 000108 0004+00 0/0 0/0 0/0 .bss sInstance__29JASGlobalInstance<9JAISeqMgr> */ -#pragma push -#pragma force_active on -static u8 data_804E1CE8[4]; -#pragma pop - -/* 804E1CEC-804E1CF0 00010C 0004+00 0/0 0/0 0/0 .bss - * sInstance__33JASGlobalInstance<12JAIStreamMgr> */ -#pragma push -#pragma force_active on -static u8 data_804E1CEC[4]; -#pragma pop - -/* 804E1CF0-804E1CF4 000110 0004+00 0/0 0/0 0/0 .bss sInstance__31JASGlobalInstance<10Z2SoundMgr> - */ -#pragma push -#pragma force_active on -static u8 data_804E1CF0[4]; -#pragma pop - -/* 804E1CF4-804E1CF8 000114 0004+00 0/0 0/0 0/0 .bss - * sInstance__33JASGlobalInstance<12JAISoundInfo> */ -#pragma push -#pragma force_active on -static u8 data_804E1CF4[4]; -#pragma pop - -/* 804E1CF8-804E1CFC 000118 0004+00 0/0 0/0 0/0 .bss - * sInstance__34JASGlobalInstance<13JAUSoundTable> */ -#pragma push -#pragma force_active on -static u8 data_804E1CF8[4]; -#pragma pop - -/* 804E1CFC-804E1D00 00011C 0004+00 0/0 0/0 0/0 .bss - * sInstance__38JASGlobalInstance<17JAUSoundNameTable> */ -#pragma push -#pragma force_active on -static u8 data_804E1CFC[4]; -#pragma pop - -/* 804E1D00-804E1D04 000120 0004+00 0/0 0/0 0/0 .bss - * sInstance__33JASGlobalInstance<12JAUSoundInfo> */ -#pragma push -#pragma force_active on -static u8 data_804E1D00[4]; -#pragma pop - -/* 804E1D04-804E1D08 000124 0004+00 0/0 0/0 0/0 .bss sInstance__32JASGlobalInstance<11Z2SoundInfo> - */ -#pragma push -#pragma force_active on -static u8 data_804E1D04[4]; -#pragma pop - -/* 804E1D08-804E1D0C 000128 0004+00 0/0 0/0 0/0 .bss - * sInstance__34JASGlobalInstance<13Z2SoundObjMgr> */ -#pragma push -#pragma force_active on -static u8 data_804E1D08[4]; -#pragma pop - -/* 804E1D0C-804E1D10 00012C 0004+00 0/0 0/0 0/0 .bss sInstance__31JASGlobalInstance<10Z2Audience> - */ -#pragma push -#pragma force_active on -static u8 data_804E1D0C[4]; -#pragma pop - -/* 804E1D10-804E1D14 000130 0004+00 0/0 0/0 0/0 .bss sInstance__32JASGlobalInstance<11Z2FxLineMgr> - */ -#pragma push -#pragma force_active on -static u8 data_804E1D10[4]; -#pragma pop - -/* 804E1D14-804E1D18 000134 0004+00 0/0 0/0 0/0 .bss sInstance__31JASGlobalInstance<10Z2EnvSeMgr> - */ -#pragma push -#pragma force_active on -static u8 data_804E1D14[4]; -#pragma pop - -/* 804E1D18-804E1D1C 000138 0004+00 0/0 0/0 0/0 .bss sInstance__32JASGlobalInstance<11Z2SpeechMgr> - */ -#pragma push -#pragma force_active on -static u8 data_804E1D18[4]; -#pragma pop - -/* 804E1D1C-804E1D20 00013C 0004+00 0/0 0/0 0/0 .bss - * sInstance__34JASGlobalInstance<13Z2WolfHowlMgr> */ -#pragma push -#pragma force_active on -static u8 data_804E1D1C[4]; -#pragma pop - -/* 804E1A4C-804E1A4C 000078 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ \ No newline at end of file +AUDIO_INSTANCES; diff --git a/src/d/actor/d_a_movie_player.cpp b/src/d/actor/d_a_movie_player.cpp index 268abe92470..61edf10f45f 100644 --- a/src/d/actor/d_a_movie_player.cpp +++ b/src/d/actor/d_a_movie_player.cpp @@ -3,749 +3,2799 @@ * */ +// This TU seems to disable inlining entirely, as there are several weak functions that get inlined +// in other TUs, but not here. +#pragma dont_inline on + +#include +#include +#include +#include "JSystem/JKernel/JKRExpHeap.h" +#include "JSystem/JAudio2/JASAiCtrl.h" #include "d/actor/d_a_movie_player.h" +#include "d/d_com_inf_game.h" #include "dol2asm.h" -#include "dolphin/types.h" - -// -// Forward References: -// - -extern "C" static void THPAudioDecode(); -extern "C" void __THPAudioGetNewSample(); -extern "C" void __THPAudioInitialize(); -extern "C" static void THPVideoDecode(); -extern "C" void __THPSetupBuffers(); -extern "C" void __THPReadFrameHeader(); -extern "C" void __THPReadScaneHeader(); -extern "C" void __THPReadQuantizationTable(); -extern "C" void __THPReadHuffmanTableSpecification(); -extern "C" void __THPHuffGenerateSizeTable(); -extern "C" void __THPHuffGenerateCodeTable(); -extern "C" void __THPHuffGenerateDecoderTables(); -extern "C" void __THPRestartDefinition(); -extern "C" void __THPPrepBitStream(); -extern "C" void __THPDecompressYUV(); -extern "C" void __THPGQRRestore(); -extern "C" void __THPGQRSetup(); -extern "C" void __THPDecompressiMCURow512x448(); -extern "C" void __THPInverseDCTY8(); -extern "C" void __THPInverseDCTNoYPos(); -extern "C" void __THPDecompressiMCURow640x480(); -extern "C" void __THPDecompressiMCURowNxN(); -extern "C" void __THPHuffDecodeDCTCompY(); -extern "C" void __THPHuffDecodeTab(); -extern "C" void __THPHuffDecodeDCTCompU(); -extern "C" void __THPHuffDecodeDCTCompV(); -extern "C" static void i_OSInitFastCast(); -extern "C" static void THPInit(); -extern "C" static void daMP_PopReadedBuffer__Fv(); -extern "C" static void daMP_PushReadedBuffer__FPv(); -extern "C" static void daMP_PopFreeReadBuffer__Fv(); -extern "C" static void daMP_PushFreeReadBuffer__FPv(); -extern "C" static void daMP_PopReadedBuffer2__Fv(); -extern "C" static void daMP_PushReadedBuffer2__FPv(); -extern "C" static void daMP_ReadThreadStart__Fv(); -extern "C" static void daMP_ReadThreadCancel__Fv(); -extern "C" static void daMP_Reader__FPv(); -extern "C" static void daMP_NEXT_READ_SIZE__FP18daMP_THPReadBuffer(); -extern "C" static void daMP_CreateReadThread__Fl(); -extern "C" static void daMP_PopFreeTextureSet__Fv(); -extern "C" static void daMP_PushFreeTextureSet__FPv(); -extern "C" static void daMP_PopDecodedTextureSet__Fl(); -extern "C" static void daMP_PushDecodedTextureSet__FPv(); -extern "C" static void daMP_VideoDecode__FP18daMP_THPReadBuffer(); -extern "C" static void daMP_VideoDecoder__FPv(); -extern "C" static void daMP_VideoDecoderForOnMemory__FPv(); -extern "C" static void daMP_CreateVideoDecodeThread__FlPUc(); -extern "C" static void daMP_VideoDecodeThreadStart__Fv(); -extern "C" static void daMP_VideoDecodeThreadCancel__Fv(); -extern "C" static void daMP_PopFreeAudioBuffer__Fv(); -extern "C" static void daMP_PushFreeAudioBuffer__FPv(); -extern "C" static void daMP_PopDecodedAudioBuffer__Fl(); -extern "C" static void daMP_PushDecodedAudioBuffer__FPv(); -extern "C" static void daMP_AudioDecode__FP18daMP_THPReadBuffer(); -extern "C" static void daMP_AudioDecoder__FPv(); -extern "C" static void daMP_AudioDecoderForOnMemory__FPv(); -extern "C" static void daMP_CreateAudioDecodeThread__FlPUc(); -extern "C" static void daMP_AudioDecodeThreadStart__Fv(); -extern "C" static void daMP_AudioDecodeThreadCancel__Fv(); -extern "C" static void daMP_THPGXRestore__Fv(); -extern "C" static void daMP_THPGXYuv2RgbSetup__FPC16_GXRenderModeObj(); -extern "C" static void i_GXSetTexCoordGen(); -extern "C" static void daMP_THPGXYuv2RgbDraw__FPUcPUcPUcssssss(); -extern "C" static void i_GXTexCoord2u16(); -extern "C" static void daMP_MixAudio__FPsPsUl(); -extern "C" static void daMP_audioCallbackWithMSound__Fl(); -extern "C" static void daMP_audioInitWithMSound__Fv(); -extern "C" static void daMP_audioQuitWithMSound__Fv(); -extern "C" static void daMP_PushUsedTextureSet__FPv(); -extern "C" static void daMP_PopUsedTextureSet__Fv(); -extern "C" static void daMP_THPPlayerInit__Fl(); -extern "C" static void daMP_THPPlayerQuit__Fv(); -extern "C" static void daMP_THPPlayerOpen__FPCci(); -extern "C" static void daMP_THPPlayerClose__Fv(); -extern "C" static void daMP_THPPlayerCalcNeedMemory__Fv(); -extern "C" static void daMP_THPPlayerSetBuffer__FPUc(); -extern "C" static void daMP_InitAllMessageQueue__Fv(); -extern "C" static void daMP_ProperTimingForStart__Fv(); -extern "C" static void daMP_ProperTimingForGettingNextFrame__Fv(); -extern "C" static void daMP_PlayControl__FUl(); -extern "C" static void daMP_WaitUntilPrepare__Fv(); -extern "C" static void daMP_PrepareReady__Fi(); -extern "C" static void daMP_THPPlayerPrepare__Flll(); -extern "C" static void daMP_THPPlayerDrawDone__Fv(); -extern "C" static void daMP_THPPlayerPlay__Fv(); -extern "C" static void daMP_THPPlayerStop__Fv(); -extern "C" static void daMP_THPPlayerPause__Fv(); -extern "C" static void daMP_THPPlayerDrawCurrentFrame__FPC16_GXRenderModeObjUlUlUlUl(); -extern "C" void fadeIn__13mDoGph_gInf_cFf(); -extern "C" void isFade__13mDoGph_gInf_cFv(); -extern "C" static void daMP_THPPlayerGetVideoInfo__FP12THPVideoInfo(); -extern "C" static void daMP_THPPlayerGetAudioInfo__FP12THPAudioInfo(); -extern "C" static void daMP_THPPlayerGetTotalFrame__Fv(); -extern "C" static void daMP_THPPlayerGetState__Fv(); -extern "C" static void daMP_THPPlayerSetVolume__Fll(); -extern "C" static void daMP_ActivePlayer_Init__FPCc(); -extern "C" void getRenderMode__8JUTVideoCFv(); -extern "C" void getManager__8JUTVideoFv(); -extern "C" static void daMP_ActivePlayer_Finish__Fv(); -extern "C" static void JKRFree__FPv(); -extern "C" static void daMP_ActivePlayer_Main__Fv(); -extern "C" static void daMP_ActivePlayer_Draw__Fv(); -extern "C" static void dComIfGp_event_reset__Fv(); -extern "C" void getEvent__14dComIfG_play_cFv(); -extern "C" static void daMP_Get_MovieRestFrame__Fv(); -extern "C" static void daMP_Set_PercentMovieVolume__Ff(); -extern "C" void daMP_c_Get_arg_demoNo__6daMP_cFv(); -extern "C" static void fopAcM_GetParam__FPCv(); -extern "C" static void fpcM_GetParam__FPCv(); -extern "C" void daMP_c_Get_arg_movieNo__6daMP_cFv(); -extern "C" void daMP_c_Init__6daMP_cFv(); -extern "C" void setFrameRate__13mDoGph_gInf_cFUs(); -extern "C" void setFrameRate__10JFWDisplayFUs(); -extern "C" void getManager__10JFWDisplayFv(); -extern "C" void daMP_c_Finish__6daMP_cFv(); -extern "C" void daMP_c_Main__6daMP_cFv(); -extern "C" void draw__16daMP_Dlst_base_cFv(); -extern "C" void daMP_c_Draw__6daMP_cFv(); -extern "C" static void dComIfGd_set2DOpa__FP12dDlst_base_c(); -extern "C" void set2DOpa__12dDlst_list_cFP12dDlst_base_c(); -extern "C" void daMP_c_Callback_Init__6daMP_cFP10fopAc_ac_c(); -extern "C" static void fopAcM_OnCondition__FP10fopAc_ac_cUl(); -extern "C" void __ct__6daMP_cFv(); -extern "C" static void* __nw__FUlPv(); -extern "C" static void fopAcM_CheckCondition__FP10fopAc_ac_cUl(); -extern "C" void daMP_c_Callback_Finish__6daMP_cFP6daMP_c(); -extern "C" void daMP_c_Callback_Main__6daMP_cFP6daMP_c(); -extern "C" void daMP_c_Callback_Draw__6daMP_cFP6daMP_c(); -extern "C" static bool daMP_Callback_Dummy__FP6daMP_c(); -extern "C" void __sinit_d_a_movie_player_cpp(); -extern "C" void __ct__16daMP_Dlst_base_cFv(); -extern "C" void __ct__12dDlst_base_cFv(); -extern "C" void draw__12dDlst_base_cFv(); -extern "C" extern char const* const d_a_movie_player__stringBase0; - -// -// External References: -// - -extern "C" void fadeOut__13mDoGph_gInf_cFf(); -extern "C" void mDoExt_getArchiveHeap__Fv(); -extern "C" void __ct__10fopAc_ac_cFv(); -extern "C" void fopOvlpM_IsPeek__Fv(); -extern "C" void daMP_c_Get_MovieRestFrame__6daMP_cFv(); -extern "C" void daMP_c_Set_PercentMovieVolume__6daMP_cFf(); -extern "C" void reset__14dEvt_control_cFv(); -extern "C" void set__12dDlst_list_cFRPP12dDlst_base_cRPP12dDlst_base_cP12dDlst_base_c(); -extern "C" void cAPICPad_ANY_BUTTON__FUl(); -extern "C" void registerMixCallback__9JASDriverFPFl_Ps10JASMixMode(); -extern "C" void getOutputMode__9JASDriverFv(); -extern "C" void alloc__7JKRHeapFUli(); -extern "C" void free__7JKRHeapFPvP7JKRHeap(); -extern "C" void PPCMfhid2(); -extern "C" void LCEnable(); -extern "C" void LCDisable(); -extern "C" void VIGetNextField(); -extern "C" void AIGetDSPSampleRate(); -extern "C" void GXDrawDone(); -extern "C" void GXInvalidateTexAll(); -extern "C" static void i_GXEnd(); -extern "C" static void i_GXPosition3s16(); -extern "C" void _savegpr_21(); -extern "C" void _savegpr_22(); -extern "C" void _savegpr_23(); -extern "C" void _savegpr_24(); -extern "C" void _savegpr_25(); -extern "C" void _savegpr_26(); -extern "C" void _savegpr_27(); -extern "C" void _restgpr_21(); -extern "C" void _restgpr_22(); -extern "C" void _restgpr_23(); -extern "C" void _restgpr_24(); -extern "C" void _restgpr_25(); -extern "C" void _restgpr_26(); -extern "C" void _restgpr_27(); -extern "C" void __div2i(); -extern "C" void sprintf(); -extern "C" extern u8 g_dComIfG_gameInfo[122384]; -extern "C" extern u8 g_clearColor[4]; -extern "C" extern u8 mBlureFlag__13mDoGph_gInf_c[4]; -extern "C" u8 m_myObj__6daMP_c[4]; -extern "C" u8 sManager__10JFWDisplay[4]; -extern "C" u8 sManager__8JUTVideo[4]; - -// -// Declarations: -// +#include "Z2AudioLib/Z2Instances.h" +#include "m_Do/m_Do_graphic.h" +#include "f_op/f_op_overlap_mng.h" +#include "SSystem/SComponent/c_API_controller_pad.h" + +#ifdef __cplusplus +extern "C" { +#endif /* 80872758-80872BF0 000078 0498+00 1/1 0/0 0/0 .text THPAudioDecode */ -static void THPAudioDecode() { - // NONMATCHING +// NONMATCHING +static u32 THPAudioDecode(s16* audioBuffer, u8* audioFrame, s32 flag) { + THPAudioRecordHeader* header; + THPAudioDecodeInfo decInfo; + u8 *left, *right; + s16 *decLeftPtr, *decRightPtr; + s16 yn1, yn2; + s32 i; + s32 step; + s32 sample; + s64 yn; + + if (audioBuffer == NULL || audioFrame == NULL) { + return 0; + } + + header = (THPAudioRecordHeader*)audioFrame; + left = audioFrame + sizeof(THPAudioRecordHeader); + right = left + header->offsetNextChannel; + + if (flag == 1) { + decRightPtr = audioBuffer; + decLeftPtr = audioBuffer + header->sampleSize; + step = 1; + } else { + decRightPtr = audioBuffer; + decLeftPtr = audioBuffer + 1; + step = 2; + } + + if (header->offsetNextChannel == 0) { + __THPAudioInitialize(&decInfo, left); + + yn1 = header->lYn1; + yn2 = header->lYn2; + + for (i = 0; i < header->sampleSize; i++) { + sample = __THPAudioGetNewSample(&decInfo); + yn = header->lCoef[decInfo.predictor][1] * yn2; + yn += header->lCoef[decInfo.predictor][0] * yn1; + yn += (sample << decInfo.scale) << 11; + yn <<= 5; + + if (sample > 0x8000) { + yn += 0x10000; + } else if ((sample == 0x8000) && ((yn & 0x10000) != 0)) { + yn += 0x10000; + } + + yn += 0x8000; + + if (yn > 2147483647LL) { + yn = 2147483647LL; + } + + if (yn < -2147483648LL) { + yn = -2147483648LL; + } + + *decLeftPtr = (s16)(yn >> 16); + decLeftPtr += step; + *decRightPtr = (s16)(yn >> 16); + decRightPtr += step; + yn2 = yn1; + yn1 = (s16)(yn >> 16); + } + } else { + __THPAudioInitialize(&decInfo, left); + + yn1 = header->lYn1; + yn2 = header->lYn2; + + for (i = 0; i < header->sampleSize; i++) { + sample = __THPAudioGetNewSample(&decInfo); + yn = header->lCoef[decInfo.predictor][1] * yn2; + yn += header->lCoef[decInfo.predictor][0] * yn1; + yn += (sample << decInfo.scale) << 11; + yn <<= 5; + yn += 0x8000; + + if (yn > 2147483647LL) { + yn = 2147483647LL; + } + + if (yn < -2147483648LL) { + yn = -2147483648LL; + } + + *decLeftPtr = (s16)(yn >> 16); + decLeftPtr += step; + yn2 = yn1; + yn1 = (s16)(yn >> 16); + } + + __THPAudioInitialize(&decInfo, right); + + yn1 = header->rYn1; + yn2 = header->rYn2; + + for (i = 0; i < header->sampleSize; i++) { + sample = __THPAudioGetNewSample(&decInfo); + yn = header->rCoef[decInfo.predictor][1] * yn2; + yn += header->rCoef[decInfo.predictor][0] * yn1; + yn += (sample << decInfo.scale) << 11; + yn <<= 5; + + yn += 0x8000; + + if (yn > 2147483647LL) { + yn = 2147483647LL; + } + + if (yn < -2147483648LL) { + yn = -2147483648LL; + } + + *decRightPtr = (s16)(yn >> 16); + decRightPtr += step; + yn2 = yn1; + yn1 = (s16)(yn >> 16); + } + } + + return header->sampleSize; } /* 80872BF0-80872C80 000510 0090+00 1/1 0/0 0/0 .text __THPAudioGetNewSample */ -void __THPAudioGetNewSample() { - // NONMATCHING -} - -/* 80872C80-80872CBC 0005A0 003C+00 1/1 0/0 0/0 .text __THPAudioInitialize */ -void __THPAudioInitialize() { - // NONMATCHING -} - -/* ############################################################################################## */ -/* 808795A0-808795A4 000000 0001+03 15/15 0/0 0/0 .bss @1109 */ -static u8 lit_1109[1 + 3 /* padding */]; - -/* 808795A4-808795A8 000004 0001+03 0/0 0/0 0/0 .bss @1107 */ -#pragma push -#pragma force_active on -static u8 lit_1107[1 + 3 /* padding */]; -#pragma pop - -/* 808795A8-808795AC 000008 0001+03 0/0 0/0 0/0 .bss @1105 */ -#pragma push -#pragma force_active on -static u8 lit_1105[1 + 3 /* padding */]; -#pragma pop - -/* 808795AC-808795B0 00000C 0001+03 0/0 0/0 0/0 .bss @1104 */ -#pragma push -#pragma force_active on -static u8 lit_1104[1 + 3 /* padding */]; -#pragma pop - -/* 808795B0-808795B4 000010 0001+03 0/0 0/0 0/0 .bss @1099 */ -#pragma push -#pragma force_active on -static u8 lit_1099[1 + 3 /* padding */] ALIGN_DECL(16); -#pragma pop - -/* 808795B4-808795B8 000014 0001+03 0/0 0/0 0/0 .bss @1097 */ -#pragma push -#pragma force_active on -static u8 lit_1097[1 + 3 /* padding */]; -#pragma pop - -/* 808795B8-808795BC 000018 0001+03 0/0 0/0 0/0 .bss @1095 */ -#pragma push -#pragma force_active on -static u8 lit_1095[1 + 3 /* padding */]; -#pragma pop - -/* 808795BC-808795C0 00001C 0001+03 0/0 0/0 0/0 .bss @1094 */ -#pragma push -#pragma force_active on -static u8 lit_1094[1 + 3 /* padding */]; -#pragma pop - -/* 808795C0-808795C4 000020 0001+03 0/0 0/0 0/0 .bss @1057 */ -#pragma push -#pragma force_active on -static u8 lit_1057[1 + 3 /* padding */] ALIGN_DECL(32); -#pragma pop - -/* 808795C4-808795C8 000024 0001+03 0/0 0/0 0/0 .bss @1055 */ -#pragma push -#pragma force_active on -static u8 lit_1055[1 + 3 /* padding */]; -#pragma pop - -/* 808795C8-808795CC 000028 0001+03 0/0 0/0 0/0 .bss @1053 */ -#pragma push -#pragma force_active on -static u8 lit_1053[1 + 3 /* padding */]; -#pragma pop - -/* 808795CC-808795D0 00002C 0001+03 0/0 0/0 0/0 .bss @1052 */ -#pragma push -#pragma force_active on -static u8 lit_1052[1 + 3 /* padding */]; -#pragma pop +static s32 __THPAudioGetNewSample(THPAudioDecodeInfo* info) { + s32 sample; -/* 808795D0-808795D4 000030 0001+03 0/0 0/0 0/0 .bss @1014 */ -#pragma push -#pragma force_active on -static u8 lit_1014[1 + 3 /* padding */] ALIGN_DECL(16); -#pragma pop + if (!(info->offsetNibbles & 0x0f)) { + info->predictor = (u8)((*(info->encodeData) & 0x70) >> 4); + info->scale = (u8)((*(info->encodeData) & 0xF)); + info->encodeData++; + info->offsetNibbles += 2; + } -/* 808795D4-808795D8 000034 0001+03 0/0 0/0 0/0 .bss @1012 */ -#pragma push -#pragma force_active on -static u8 lit_1012[1 + 3 /* padding */]; -#pragma pop + if (info->offsetNibbles & 0x1) { + sample = (s32)((*(info->encodeData) & 0xF) << 28) >> 28; + info->encodeData++; + } else { + sample = (s32)((*(info->encodeData) & 0xF0) << 24) >> 28; + } -/* 808795D8-808795DC 000038 0001+03 0/0 0/0 0/0 .bss @1010 */ -#pragma push -#pragma force_active on -static u8 lit_1010[1 + 3 /* padding */]; -#pragma pop + info->offsetNibbles++; + return sample; +} -/* 808795DC-808795E0 00003C 0001+03 0/0 0/0 0/0 .bss @1009 */ -#pragma push -#pragma force_active on -static u8 lit_1009[1 + 3 /* padding */]; -#pragma pop +/* 80872C80-80872CBC 0005A0 003C+00 1/1 0/0 0/0 .text __THPAudioInitialize */ +static void __THPAudioInitialize(THPAudioDecodeInfo* info, u8* ptr) { + info->encodeData = ptr; + info->offsetNibbles = 2; + info->predictor = (u8)((*(info->encodeData) & 0x70) >> 4); + info->scale = (u8)((*(info->encodeData) & 0xF)); + info->encodeData++; +} + +UNK_BSS(1109); +UNK_BSS(1107); +UNK_BSS(1105); +UNK_BSS(1104); +UNK_BSS(1099); +UNK_BSS(1097); +UNK_BSS(1095); +UNK_BSS(1094); +UNK_BSS(1057); +UNK_BSS(1055); +UNK_BSS(1053); +UNK_BSS(1052); +UNK_BSS(1014); +UNK_BSS(1012); +UNK_BSS(1010); +UNK_BSS(1009); /* 808795E0-80879A40 000040 0460+00 0/0 0/0 0/0 .bss THPStatistics */ -#pragma push -#pragma force_active on static u8 THPStatistics[1120] ALIGN_DECL(32); -#pragma pop /* 80879A40-80879A44 0004A0 0004+00 1/2 0/0 0/0 .bss Ydchuff */ -static u8 Ydchuff[4]; +static THPHuffmanTab* Ydchuff; /* 80879A44-80879A48 0004A4 0004+00 1/2 0/0 0/0 .bss Udchuff */ -static u8 Udchuff[4]; +static THPHuffmanTab* Udchuff; /* 80879A48-80879A4C 0004A8 0004+00 1/2 0/0 0/0 .bss Vdchuff */ -static u8 Vdchuff[4]; +static THPHuffmanTab* Vdchuff; /* 80879A4C-80879A50 0004AC 0004+00 1/2 0/0 0/0 .bss Yachuff */ -static u8 Yachuff[4]; +static THPHuffmanTab* Yachuff; /* 80879A50-80879A54 0004B0 0004+00 1/2 0/0 0/0 .bss Uachuff */ -static u8 Uachuff[4]; +static THPHuffmanTab* Uachuff; /* 80879A54-80879A60 0004B4 0004+08 1/2 0/0 0/0 .bss Vachuff */ -static u8 Vachuff[4 + 8 /* padding */]; +static THPHuffmanTab* Vachuff; /* 80879A60-80879B60 0004C0 0100+00 0/2 0/0 0/0 .bss __THPIDCTWorkspace */ -#pragma push -#pragma force_active on -static u8 __THPIDCTWorkspace[256] ALIGN_DECL(32); -#pragma pop +static f32 __THPIDCTWorkspace[64] ALIGN_DECL(32); /* 80879B60-80879B64 0005C0 0004+00 1/3 0/0 0/0 .bss __THPHuffmanBits */ -static u8 __THPHuffmanBits[4]; +static u8* __THPHuffmanBits; /* 80879B64-80879B68 0005C4 0004+00 2/3 0/0 0/0 .bss __THPHuffmanSizeTab */ -static u8 __THPHuffmanSizeTab[4]; +static u8* __THPHuffmanSizeTab; /* 80879B68-80879B6C 0005C8 0004+00 1/3 0/0 0/0 .bss __THPHuffmanCodeTab */ -static u8 __THPHuffmanCodeTab[4]; +static u16* __THPHuffmanCodeTab; /* 80879B6C-80879B80 0005CC 0004+10 0/5 0/0 0/0 .bss Gbase */ -#pragma push -#pragma force_active on -static u8 Gbase[4 + 16 /* padding */]; -#pragma pop +static THPSample* Gbase; /* 80879B80-80879B84 0005E0 0004+00 0/5 0/0 0/0 .bss Gwid */ -#pragma push -#pragma force_active on -static u8 Gwid[4] ALIGN_DECL(32); -#pragma pop +static u32 Gwid ALIGN_DECL(32); /* 80879B84-80879B88 0005E4 0004+00 0/5 0/0 0/0 .bss Gq */ -#pragma push -#pragma force_active on -static u8 Gq[4]; -#pragma pop +static f32* Gq; /* 80879B88-80879B94 0005E8 000C+00 0/2 0/0 0/0 .bss __THPLCWork512 */ -#pragma push -#pragma force_active on -static u8 __THPLCWork512[12]; -#pragma pop +static u8* __THPLCWork512[3]; /* 80879B94-80879BA0 0005F4 000C+00 0/3 0/0 0/0 .bss __THPLCWork640 */ -#pragma push -#pragma force_active on -static u8 __THPLCWork640[12]; -#pragma pop +static u8* __THPLCWork640[3]; /* 80879BA0-80879BA4 000600 0004+00 2/2 0/0 0/0 .bss __THPOldGQR5 */ -static u8 __THPOldGQR5[4]; +static u32 __THPOldGQR5; /* 80879BA4-80879BA8 000604 0004+00 2/2 0/0 0/0 .bss __THPOldGQR6 */ -static u8 __THPOldGQR6[4]; +static u32 __THPOldGQR6; /* 80879BA8-80879BAC 000608 0004+00 1/3 0/0 0/0 .bss __THPWorkArea */ -static u8 __THPWorkArea[4]; +static u8* __THPWorkArea; /* 80879BAC-80879BC4 00060C 0018+00 1/4 0/0 0/0 .bss __THPMCUBuffer */ -static u8 __THPMCUBuffer[24]; +static THPCoeff* __THPMCUBuffer[6]; /* 80879BC4-80879BC8 000624 0004+00 5/12 0/0 0/0 .bss __THPInfo */ -static u8 __THPInfo[4]; +static THPFileInfo* __THPInfo; /* 80879BC8-80879BD0 000628 0004+04 0/2 0/0 0/0 .bss __THPInitFlag */ -#pragma push -#pragma force_active on -static u8 __THPInitFlag[4 + 4 /* padding */]; -#pragma pop +static BOOL __THPInitFlag; /* 80872CBC-80872F00 0005DC 0244+00 1/1 0/0 0/0 .text THPVideoDecode */ -static void THPVideoDecode() { - // NONMATCHING +static s32 THPVideoDecode(void* file, void* tileY, void* tileU, void* tileV, void* work) { + u8 all_done, status; + s32 errorCode; + + if (!file) { + goto _err_no_input; + } + + if (tileY == NULL || tileU == NULL || tileV == NULL) { + goto _err_no_output; + } + + if (!work) { + goto _err_no_work; + } + + if (!(PPCMfhid2() & 0x10000000)) { + goto _err_lc_not_enabled; + } + + if (__THPInitFlag == FALSE) { + goto _err_not_initialized; + } + + __THPWorkArea = (u8*)work; + __THPInfo = (THPFileInfo*)OSRoundUp32B(__THPWorkArea); + __THPWorkArea = (u8*)OSRoundUp32B(__THPWorkArea) + sizeof(THPFileInfo); + DCZeroRange(__THPInfo, sizeof(THPFileInfo)); + __THPInfo->cnt = 33; + __THPInfo->decompressedY = 0; + __THPInfo->c = (u8*)file; + all_done = FALSE; + + for (;;) { + if ((*(__THPInfo->c)++) != 255) { + goto _err_bad_syntax; + } + + while (*__THPInfo->c == 255) { + ((__THPInfo->c)++); + } + + status = (*(__THPInfo->c)++); + + if (status <= 0xD7) { + if (status == 196) { + status = __THPReadHuffmanTableSpecification(); + if (status != 0) { + goto _err_bad_status; + } + } + + else if (status == 192) { + status = __THPReadFrameHeader(); + if (status != 0) { + goto _err_bad_status; + } + } + + else { + goto _err_unsupported_marker; + } + } + + else if (0xD8 <= status && status <= 0xDF) { + if (status == 221) { + __THPRestartDefinition(); + } + + else if (status == 219) { + status = __THPReadQuantizationTable(); + if (status != 0) { + goto _err_bad_status; + } + } + + else if (status == 218) { + status = __THPReadScaneHeader(); + if (status != 0) { + goto _err_bad_status; + } + + all_done = TRUE; + } else if (status == 216) { + // empty but required for match + } else { + goto _err_unsupported_marker; + } + } + + else if (0xE0 <= status) { + if ((224 <= status && status <= 239) || status == 254) { + __THPInfo->c += (__THPInfo->c)[0] << 8 | (__THPInfo->c)[1]; + } else { + goto _err_unsupported_marker; + } + } + + if (all_done) { + break; + } + } + + __THPSetupBuffers(); + __THPDecompressYUV(tileY, tileU, tileV); + return 0; + +_err_no_input: + errorCode = 25; + goto _err_exit; + +_err_no_output: + errorCode = 27; + goto _err_exit; + +_err_no_work: + errorCode = 26; + goto _err_exit; + +_err_unsupported_marker: + errorCode = 11; + goto _err_exit; + +_err_bad_resource: + errorCode = 1; + goto _err_exit; + +_err_no_mem: + errorCode = 6; + goto _err_exit; + +_err_bad_syntax: + errorCode = 3; + goto _err_exit; + +_err_bad_status: + errorCode = status; + goto _err_exit; + +_err_lc_not_enabled: + errorCode = 28; + goto _err_exit; + +_err_not_initialized: + errorCode = 29; + goto _err_exit; + +_err_exit: + return errorCode; } /* 80872F00-80872F48 000820 0048+00 1/1 0/0 0/0 .text __THPSetupBuffers */ -void __THPSetupBuffers() { - // NONMATCHING +static void __THPSetupBuffers() { + u8 i; + THPCoeff* buffer; + + buffer = (THPCoeff*)OSRoundUp32B(__THPWorkArea); + + for (i = 0; i < 6; i++) { + __THPMCUBuffer[i] = &buffer[i * 64]; + } } /* 80872F48-80873088 000868 0140+00 1/1 0/0 0/0 .text __THPReadFrameHeader */ -void __THPReadFrameHeader() { - // NONMATCHING +static u8 __THPReadFrameHeader() { + u8 i, utmp8; + + __THPInfo->c += 2; + + utmp8 = (*(__THPInfo->c)++); + + if (utmp8 != 8) { + return 10; + } + + __THPInfo->yPixelSize = (u16)((__THPInfo->c)[0] << 8 | (__THPInfo->c)[1]); + __THPInfo->c += 2; + __THPInfo->xPixelSize = (u16)((__THPInfo->c)[0] << 8 | (__THPInfo->c)[1]); + __THPInfo->c += 2; + + utmp8 = (*(__THPInfo->c)++); + if (utmp8 != 3) { + return 12; + } + + for (i = 0; i < 3; i++) { + utmp8 = (*(__THPInfo->c)++); + utmp8 = (*(__THPInfo->c)++); + if ((i == 0 && utmp8 != 0x22) || (i > 0 && utmp8 != 0x11)) { + return 19; + } + + __THPInfo->components[i].quantizationTableSelector = (*(__THPInfo->c)++); + } + + return 0; } +#define THPROUNDUP(a, b) ((((s32)(a)) + ((s32)(b)-1L)) / ((s32)(b))) + /* 80873088-808731B4 0009A8 012C+00 1/1 0/0 0/0 .text __THPReadScaneHeader */ -void __THPReadScaneHeader() { - // NONMATCHING +static u8 __THPReadScaneHeader() { + u8 i, utmp8; + __THPInfo->c += 2; + + utmp8 = (*(__THPInfo->c)++); + + if (utmp8 != 3) { + return 12; + } + + for (i = 0; i < 3; i++) { + utmp8 = (*(__THPInfo->c)++); + + utmp8 = (*(__THPInfo->c)++); + __THPInfo->components[i].DCTableSelector = (u8)(utmp8 >> 4); + __THPInfo->components[i].ACTableSelector = (u8)(utmp8 & 15); + + if ((__THPInfo->validHuffmanTabs & (1 << ((utmp8 >> 4)))) == 0) { + return 15; + } + + if ((__THPInfo->validHuffmanTabs & (1 << ((utmp8 & 15) + 1))) == 0) { + return 15; + } + } + + __THPInfo->c += 3; + __THPInfo->MCUsPerRow = (u16)THPROUNDUP(__THPInfo->xPixelSize, 16); + __THPInfo->components[0].predDC = 0; + __THPInfo->components[1].predDC = 0; + __THPInfo->components[2].predDC = 0; + return 0; } -/* ############################################################################################## */ /* 80879034-80879084 000000 0050+00 8/8 0/0 0/0 .rodata __THPJpegNaturalOrder */ -SECTION_RODATA static u8 const __THPJpegNaturalOrder[80] = { - 0x00, 0x01, 0x08, 0x10, 0x09, 0x02, 0x03, 0x0A, 0x11, 0x18, 0x20, 0x19, 0x12, 0x0B, 0x04, 0x05, - 0x0C, 0x13, 0x1A, 0x21, 0x28, 0x30, 0x29, 0x22, 0x1B, 0x14, 0x0D, 0x06, 0x07, 0x0E, 0x15, 0x1C, - 0x23, 0x2A, 0x31, 0x38, 0x39, 0x32, 0x2B, 0x24, 0x1D, 0x16, 0x0F, 0x17, 0x1E, 0x25, 0x2C, 0x33, - 0x3A, 0x3B, 0x34, 0x2D, 0x26, 0x1F, 0x27, 0x2E, 0x35, 0x3C, 0x3D, 0x36, 0x2F, 0x37, 0x3E, 0x3F, - 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, +static const u8 __THPJpegNaturalOrder[80] = { + 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, + 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, + 29, 22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, + 47, 55, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, }; -COMPILER_STRIP_GATE(0x80879034, &__THPJpegNaturalOrder); /* 80879084-808790C4 000050 0040+00 1/1 0/0 0/0 .rodata __THPAANScaleFactor */ -SECTION_RODATA static u8 const __THPAANScaleFactor[64] = { - 0x3F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xF6, 0x31, 0x50, 0xC0, 0x00, 0x00, 0x00, - 0x3F, 0xF4, 0xE7, 0xAE, 0xA0, 0x00, 0x00, 0x00, 0x3F, 0xF2, 0xD0, 0x62, 0xE0, 0x00, 0x00, 0x00, - 0x3F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xE9, 0x24, 0x69, 0xC0, 0x00, 0x00, 0x00, - 0x3F, 0xE1, 0x51, 0x7A, 0x80, 0x00, 0x00, 0x00, 0x3F, 0xD1, 0xA8, 0x55, 0xE0, 0x00, 0x00, 0x00, -}; -COMPILER_STRIP_GATE(0x80879084, &__THPAANScaleFactor); - -/* 808790C4-808790CC 000090 0008+00 1/1 0/0 0/0 .rodata @3998 */ -SECTION_RODATA static u8 const lit_3998[8] = { - 0x43, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +static const f64 __THPAANScaleFactor[8] = { + 1.0f, 1.387039845f, 1.306562965f, 1.175875602f, 1.0f, 0.785694958f, 0.541196100f, 0.275899379f, }; -COMPILER_STRIP_GATE(0x808790C4, &lit_3998); /* 808731B4-80873574 000AD4 03C0+00 1/1 0/0 0/0 .text __THPReadQuantizationTable */ -void __THPReadQuantizationTable() { - // NONMATCHING +// NONMATCHING - regalloc +static u8 __THPReadQuantizationTable() { + f32 q_temp[64]; + + u16 length = (u16)((__THPInfo->c)[0] << 8 | (__THPInfo->c)[1]); + __THPInfo->c += 2; + length -= 2; + + do { + u16 i; + u16 id = (*(__THPInfo->c)++); + + for (i = 0; i < 64; i++) { + q_temp[__THPJpegNaturalOrder[i]] = (f32)(*(__THPInfo->c)++); + } + + u16 row; + u16 col; + u16 j; + j = 0; + for (row = 0; row < 8; row++) { + for (col = 0; col < 8; col++) { + __THPInfo->quantTabs[id][j] = (f32)((f64)q_temp[j] * __THPAANScaleFactor[row] * __THPAANScaleFactor[col]); + j++; + } + } + + length -= 65; + } while (length != 0); + + return 0; } /* 80873574-8087375C 000E94 01E8+00 1/1 0/0 0/0 .text __THPReadHuffmanTableSpecification */ -void __THPReadHuffmanTableSpecification() { - // NONMATCHING +static u8 __THPReadHuffmanTableSpecification() { + u8 t_class, id, i, tab_index; + u16 length, num_Vij; + + __THPHuffmanSizeTab = __THPWorkArea; + __THPHuffmanCodeTab = (u16*)((u32)__THPWorkArea + 256 + 1); + length = (u16)((__THPInfo->c)[0] << 8 | (__THPInfo->c)[1]); + __THPInfo->c += 2; + length -= 2; + + for (;;) { + i = (*(__THPInfo->c)++); + id = (u8)(i & 15); + t_class = (u8)(i >> 4); + __THPHuffmanBits = __THPInfo->c; + tab_index = (u8)((id << 1) + t_class); + num_Vij = 0; + + for (i = 0; i < 16; i++) { + num_Vij += (*(__THPInfo->c)++); + } + + __THPInfo->huffmanTabs[tab_index].Vij = __THPInfo->c; + __THPInfo->c += num_Vij; + __THPHuffGenerateSizeTable(); + __THPHuffGenerateCodeTable(); + __THPHuffGenerateDecoderTables(tab_index); + __THPInfo->validHuffmanTabs |= 1 << tab_index; + length -= 17 + num_Vij; + + if (length == 0) { + break; + } + } + + return 0; } /* 8087375C-8087383C 00107C 00E0+00 1/1 0/0 0/0 .text __THPHuffGenerateSizeTable */ -void __THPHuffGenerateSizeTable() { - // NONMATCHING +static void __THPHuffGenerateSizeTable() { + s32 p, l, i; + p = 0; + + for (l = 1; l <= 16; l++) { + i = (s32)__THPHuffmanBits[l - 1]; + while (i--) { + __THPHuffmanSizeTab[p++] = (u8)l; + } + } + + __THPHuffmanSizeTab[p] = 0; } /* 8087383C-808738B0 00115C 0074+00 1/1 0/0 0/0 .text __THPHuffGenerateCodeTable */ -void __THPHuffGenerateCodeTable() { - // NONMATCHING +static void __THPHuffGenerateCodeTable() { + u8 si; + u16 p, code; + + p = 0; + code = 0; + si = __THPHuffmanSizeTab[0]; + + while (__THPHuffmanSizeTab[p]) { + while (__THPHuffmanSizeTab[p] == si) { + __THPHuffmanCodeTab[p++] = code; + code++; + } + + code <<= 1; + si++; + } } /* 808738B0-808739A8 0011D0 00F8+00 1/1 0/0 0/0 .text __THPHuffGenerateDecoderTables */ -void __THPHuffGenerateDecoderTables() { - // NONMATCHING +static void __THPHuffGenerateDecoderTables(u8 tabIndex) { + s32 p, l; + THPHuffmanTab* h; + + p = 0; + h = &__THPInfo->huffmanTabs[tabIndex]; + for (l = 1; l <= 16; l++) { + if (__THPHuffmanBits[l - 1]) { + h->valPtr[l] = p - __THPHuffmanCodeTab[p]; + p += __THPHuffmanBits[l - 1]; + h->maxCode[l] = __THPHuffmanCodeTab[p - 1]; + } else { + h->maxCode[l] = -1; + h->valPtr[l] = -1; + } + } + + h->maxCode[17] = 0xfffffL; } /* 808739A8-80873A04 0012C8 005C+00 1/1 0/0 0/0 .text __THPRestartDefinition */ -void __THPRestartDefinition() { - // NONMATCHING +static void __THPRestartDefinition() { + __THPInfo->RST = TRUE; + __THPInfo->c += 2; + __THPInfo->nMCU = (u16)((__THPInfo->c)[0] << 8 | (__THPInfo->c)[1]); + __THPInfo->c += 2; + __THPInfo->currMCU = __THPInfo->nMCU; } /* 80873A04-80873C44 001324 0240+00 1/1 0/0 0/0 .text __THPPrepBitStream */ -void __THPPrepBitStream() { - // NONMATCHING +static void __THPPrepBitStream() { + u32* ptr; + u32 offset, i, j, k; + + ptr = (u32*)((u32)__THPInfo->c & 0xFFFFFFFC); + offset = (u32)__THPInfo->c & 3; + + if (__THPInfo->cnt != 33) { + __THPInfo->cnt -= (3 - offset) * 8; + } else { + __THPInfo->cnt = (offset * 8) + 1; + } + + __THPInfo->c = (u8*)ptr; + __THPInfo->currByte = *ptr; + + for (i = 0; i < 4; i++) { + if (__THPInfo->validHuffmanTabs & (1 << i)) { + for (j = 0; j < 32; j++) { + __THPInfo->huffmanTabs[i].quick[j] = 0xFF; + + for (k = 0; k < 5; k++) { + s32 code = (s32)(j >> (5 - k - 1)); + + if (code <= __THPInfo->huffmanTabs[i].maxCode[k + 1]) { + __THPInfo->huffmanTabs[i].quick[j] + = __THPInfo->huffmanTabs[i].Vij[(s32)(code + __THPInfo->huffmanTabs[i].valPtr[k + 1])]; + __THPInfo->huffmanTabs[i].increment[j] = (u8)(k + 1); + k = 99; + } else { + } + } + } + } + } + + { + s32 YdcTab, UdcTab, VdcTab, YacTab, UacTab, VacTab; + + YdcTab = (__THPInfo->components[0].DCTableSelector << 1); + UdcTab = (__THPInfo->components[1].DCTableSelector << 1); + VdcTab = (__THPInfo->components[2].DCTableSelector << 1); + + YacTab = (__THPInfo->components[0].ACTableSelector << 1) + 1; + UacTab = (__THPInfo->components[1].ACTableSelector << 1) + 1; + VacTab = (__THPInfo->components[2].ACTableSelector << 1) + 1; + + Ydchuff = &__THPInfo->huffmanTabs[YdcTab]; + Udchuff = &__THPInfo->huffmanTabs[UdcTab]; + Vdchuff = &__THPInfo->huffmanTabs[VdcTab]; + + Yachuff = &__THPInfo->huffmanTabs[YacTab]; + Uachuff = &__THPInfo->huffmanTabs[UacTab]; + Vachuff = &__THPInfo->huffmanTabs[VacTab]; + } } /* 80873C44-80873D28 001564 00E4+00 1/1 0/0 0/0 .text __THPDecompressYUV */ -void __THPDecompressYUV() { - // NONMATCHING +static void __THPDecompressYUV(void* tileY, void* tileU, void* tileV) { + u16 currentY, targetY; + __THPInfo->dLC[0] = (u8*)tileY; + __THPInfo->dLC[1] = (u8*)tileU; + __THPInfo->dLC[2] = (u8*)tileV; + + currentY = __THPInfo->decompressedY; + targetY = __THPInfo->yPixelSize; + + __THPGQRSetup(); + __THPPrepBitStream(); + + if (__THPInfo->xPixelSize == 512 && targetY == 448) { + while (currentY < targetY) { + __THPDecompressiMCURow512x448(); + currentY += 16; + } + } else if (__THPInfo->xPixelSize == 640 && targetY == 480) { + while (currentY < targetY) { + __THPDecompressiMCURow640x480(); + currentY += 16; + } + } else { + while (currentY < targetY) { + __THPDecompressiMCURowNxN(); + currentY += 16; + } + } + + __THPGQRRestore(); } /* 80873D28-80873D48 001648 0020+00 1/1 0/0 0/0 .text __THPGQRRestore */ -void __THPGQRRestore() { - // NONMATCHING +static void __THPGQRRestore() { + register u32 tmp1, tmp2; + tmp1 = __THPOldGQR5; + tmp2 = __THPOldGQR6; + + // clang-format off +#ifdef __MWERKS__ + asm { + mtspr GQR5, tmp1; + mtspr GQR6, tmp2; + } +#endif + // clang-format on } /* 80873D48-80873D7C 001668 0034+00 1/1 0/0 0/0 .text __THPGQRSetup */ -void __THPGQRSetup() { - // NONMATCHING +static void __THPGQRSetup() { + register u32 tmp1, tmp2; + + // clang-format off +#ifdef __MWERKS__ + asm { + mfspr tmp1, GQR5; + mfspr tmp2, GQR6; + } +#endif + // clang-format on + + __THPOldGQR5 = tmp1; + __THPOldGQR6 = tmp2; + + // clang-format off +#ifdef __MWERKS__ + asm { + li r3, 0x0007 + oris r3, r3, 0x0007 + mtspr GQR5, r3 + li r3, 0x3D04 + oris r3, r3, 0x3D04 + mtspr GQR6, r3 + } +#endif + // clang-format on } /* 80873D7C-80873FBC 00169C 0240+00 1/1 0/0 0/0 .text __THPDecompressiMCURow512x448 */ -void __THPDecompressiMCURow512x448() { - // NONMATCHING +static void __THPDecompressiMCURow512x448() { + u8 cl_num; + u32 x_pos; + THPComponent* comp; + + LCQueueWait(3); + + for (cl_num = 0; cl_num < __THPInfo->MCUsPerRow; cl_num++) { + __THPHuffDecodeDCTCompY(__THPInfo, __THPMCUBuffer[0]); + __THPHuffDecodeDCTCompY(__THPInfo, __THPMCUBuffer[1]); + __THPHuffDecodeDCTCompY(__THPInfo, __THPMCUBuffer[2]); + __THPHuffDecodeDCTCompY(__THPInfo, __THPMCUBuffer[3]); + __THPHuffDecodeDCTCompU(__THPInfo, __THPMCUBuffer[4]); + __THPHuffDecodeDCTCompV(__THPInfo, __THPMCUBuffer[5]); + + comp = &__THPInfo->components[0]; + Gbase = __THPLCWork512[0]; + Gwid = 512; + Gq = __THPInfo->quantTabs[comp->quantizationTableSelector]; + x_pos = (u32)(cl_num * 16); + __THPInverseDCTNoYPos(__THPMCUBuffer[0], x_pos); + __THPInverseDCTNoYPos(__THPMCUBuffer[1], x_pos + 8); + __THPInverseDCTY8(__THPMCUBuffer[2], x_pos); + __THPInverseDCTY8(__THPMCUBuffer[3], x_pos + 8); + + comp = &__THPInfo->components[1]; + Gbase = __THPLCWork512[1]; + Gwid = 256; + Gq = __THPInfo->quantTabs[comp->quantizationTableSelector]; + x_pos /= 2; + __THPInverseDCTNoYPos(__THPMCUBuffer[4], x_pos); + comp = &__THPInfo->components[2]; + Gbase = __THPLCWork512[2]; + Gq = __THPInfo->quantTabs[comp->quantizationTableSelector]; + __THPInverseDCTNoYPos(__THPMCUBuffer[5], x_pos); + + if (__THPInfo->RST != 0) { + if ((--__THPInfo->currMCU) == 0) { + __THPInfo->currMCU = __THPInfo->nMCU; + __THPInfo->cnt = 1 + ((__THPInfo->cnt + 6) & 0xFFFFFFF8); + + if (__THPInfo->cnt > 33) { + __THPInfo->cnt = 33; + } + + __THPInfo->components[0].predDC = 0; + __THPInfo->components[1].predDC = 0; + __THPInfo->components[2].predDC = 0; + } + } + } + + LCStoreData(__THPInfo->dLC[0], __THPLCWork512[0], 0x2000); + LCStoreData(__THPInfo->dLC[1], __THPLCWork512[1], 0x800); + LCStoreData(__THPInfo->dLC[2], __THPLCWork512[2], 0x800); + + __THPInfo->dLC[0] += 0x2000; + __THPInfo->dLC[1] += 0x800; + __THPInfo->dLC[2] += 0x800; } -/* ############################################################################################## */ -/* 808790CC-808790D0 000098 0004+00 0/2 0/0 0/0 .rodata @4205 */ -#pragma push -#pragma force_active on -SECTION_RODATA static u32 const lit_4205 = 0x3FB504F3; -COMPILER_STRIP_GATE(0x808790CC, &lit_4205); -#pragma pop - -/* 808790D0-808790D4 00009C 0004+00 0/2 0/0 0/0 .rodata @4206 */ -#pragma push -#pragma force_active on -SECTION_RODATA static u32 const lit_4206 = 0x3FEC835E; -COMPILER_STRIP_GATE(0x808790D0, &lit_4206); -#pragma pop - -/* 808790D4-808790D8 0000A0 0004+00 0/2 0/0 0/0 .rodata @4207 */ -#pragma push -#pragma force_active on -SECTION_RODATA static u32 const lit_4207 = 0x3F8A8BD4; -COMPILER_STRIP_GATE(0x808790D4, &lit_4207); -#pragma pop - -/* 808790D8-808790DC 0000A4 0004+00 0/2 0/0 0/0 .rodata @4208 */ -#pragma push -#pragma force_active on -SECTION_RODATA static u32 const lit_4208 = 0xC0273D75; -COMPILER_STRIP_GATE(0x808790D8, &lit_4208); -#pragma pop - -/* 808790DC-808790E0 0000A8 0004+00 0/2 0/0 0/0 .rodata @4209 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4209 = 1024.0f; -COMPILER_STRIP_GATE(0x808790DC, &lit_4209); -#pragma pop - /* 80873FBC-8087445C 0018DC 04A0+00 3/3 0/0 0/0 .text __THPInverseDCTY8 */ -void __THPInverseDCTY8() { - // NONMATCHING +static void __THPInverseDCTY8(register THPCoeff* in, register u32 xPos) { + register f32 *q, *ws; + register f32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8, tmp9; + register f32 tmp10, tmp11, tmp12, tmp13; + register f32 tmp20, tmp21, tmp22, tmp23; + register f32 cc4 = 1.414213562F; + register f32 cc2 = 1.847759065F; + register f32 cc2c6s = 1.082392200F; + register f32 cc2c6a = -2.613125930F; + register f32 bias = 1024.0F; + + q = Gq; + ws = &__THPIDCTWorkspace[0] - 2; + + { + register u32 itmp0, itmp1, itmp2, itmp3; + + // clang-format off +#ifdef __MWERKS__ + asm { + li itmp2, 8 + mtctr itmp2 + + _loopHead0: + psq_l tmp10, 0(in), 0, 5 + psq_l tmp11, 0(q), 0, 0 + lwz itmp0, 12(in) + lwz itmp3, 8(in) + ps_mul tmp10, tmp10, tmp11 + lwz itmp1, 4(in) + lhz itmp2, 2(in) + or itmp0, itmp0, itmp3 + + _loopHead1: + cmpwi itmp0, 0 + bne _regularIDCT + ps_merge00 tmp0, tmp10, tmp10 + cmpwi itmp1, 0 + psq_st tmp0, 8(ws), 0, 0 + bne _halfIDCT + psq_st tmp0, 16(ws), 0, 0 + cmpwi itmp2, 0 + psq_st tmp0, 24(ws), 0, 0 + bne _quarterIDCT + addi q, q, 8*sizeof(f32) + psq_stu tmp0, 32(ws), 0, 0 + addi in, in, 8*sizeof(THPCoeff) + bdnz _loopHead0 + b _loopEnd + + _quarterIDCT: + ps_msub tmp2, tmp10, cc2, tmp10 + addi in, in, 8*sizeof(THPCoeff) + ps_merge00 tmp9, tmp10, tmp10 + addi q, q, 8*sizeof(f32) + ps_sub tmp1, cc2, cc2c6s + lwz itmp1, 4(in) + ps_msub tmp3, tmp10, cc4, tmp2 + lhz itmp2, 2(in) + ps_merge11 tmp5, tmp10, tmp2 + psq_l tmp11, 0(q), 0, 0 + ps_nmsub tmp4, tmp10, tmp1, tmp3 + ps_add tmp7, tmp9, tmp5 + psq_l tmp10, 0(in), 0, 5 + ps_merge11 tmp6, tmp3, tmp4 + ps_sub tmp5, tmp9, tmp5 + lwz itmp0, 12(in) + ps_add tmp8, tmp9, tmp6 + lwz itmp3, 8(in) + ps_sub tmp6, tmp9, tmp6 + psq_stu tmp7, 8(ws), 0, 0 + ps_merge10 tmp6, tmp6, tmp6 + psq_stu tmp8, 8(ws), 0, 0 + ps_merge10 tmp5, tmp5, tmp5 + or itmp0, itmp0, itmp3 + psq_stu tmp6, 8(ws), 0, 0 + ps_mul tmp10, tmp10, tmp11 + psq_stu tmp5, 8(ws), 0, 0 + bdnz _loopHead1 + b _loopEnd + + _halfIDCT: + psq_l tmp1, 4(in), 0, 5 + psq_l tmp9, 8(q), 0, 0 + addi in, in, 8*sizeof(THPCoeff) + ps_mul tmp1, tmp1, tmp9 + addi q, q, 8*sizeof(f32) + ps_sub tmp3, tmp10, tmp1 + ps_add tmp2, tmp10, tmp1 + lwz itmp0, 12(in) + ps_madd tmp4, tmp1, cc4, tmp3 + ps_nmsub tmp5, tmp1, cc4, tmp2 + ps_mul tmp8, tmp3, cc2 + ps_merge00 tmp4, tmp2, tmp4 + lwz itmp3, 8(in) + ps_nmsub tmp6, tmp1, cc2c6a, tmp8 + ps_merge00 tmp5, tmp5, tmp3 + lwz itmp1, 4(in) + ps_sub tmp6, tmp6, tmp2 + ps_nmsub tmp7, tmp10, cc2c6s, tmp8 + lhz itmp2, 2(in) + ps_merge11 tmp2, tmp2, tmp6 + ps_msub tmp8, tmp3, cc4, tmp6 + psq_l tmp10, 0(in), 0, 5 + ps_add tmp9, tmp4, tmp2 + ps_sub tmp7, tmp7, tmp8 + psq_l tmp11, 0(q), 0, 0 + ps_merge11 tmp3, tmp8, tmp7 + ps_sub tmp4, tmp4, tmp2 + psq_stu tmp9, 8(ws), 0, 0 + ps_add tmp0, tmp5, tmp3 + ps_sub tmp1, tmp5, tmp3 + or itmp0, itmp0, itmp3 + psq_stu tmp0, 8(ws), 0, 0 + ps_merge10 tmp1, tmp1, tmp1 + ps_merge10 tmp4, tmp4, tmp4 + psq_stu tmp1, 8(ws), 0, 0 + ps_mul tmp10, tmp10, tmp11 + psq_stu tmp4, 8(ws), 0, 0 + bdnz _loopHead1 + b _loopEnd + + _regularIDCT: + psq_l tmp9, 4(in), 0, 5 + psq_l tmp5, 8(q), 0, 0 + ps_mul tmp9, tmp9, tmp5 + psq_l tmp2, 8(in), 0, 5 + psq_l tmp6, 16(q), 0, 0 + ps_merge01 tmp0, tmp10, tmp9 + psq_l tmp3, 12(in), 0, 5 + ps_merge01 tmp1, tmp9, tmp10 + psq_l tmp7, 24(q), 0, 0 + addi in, in, 8*sizeof(THPCoeff) + ps_madd tmp4, tmp2, tmp6, tmp0 + ps_nmsub tmp5, tmp2, tmp6, tmp0 + ps_madd tmp6, tmp3, tmp7, tmp1 + ps_nmsub tmp7, tmp3, tmp7, tmp1 + addi q, q, 8*sizeof(f32) + ps_add tmp0, tmp4, tmp6 + ps_sub tmp3, tmp4, tmp6 + ps_msub tmp2, tmp7, cc4, tmp6 + lwz itmp0, 12(in) + ps_sub tmp8, tmp7, tmp5 + ps_add tmp1, tmp5, tmp2 + ps_sub tmp2, tmp5, tmp2 + ps_mul tmp8, tmp8, cc2 + lwz itmp3, 8(in) + ps_merge00 tmp1, tmp0, tmp1 + ps_nmsub tmp6, tmp5, cc2c6a, tmp8 + ps_msub tmp4, tmp7, cc2c6s, tmp8 + lwz itmp1, 4(in) + ps_sub tmp6, tmp6, tmp0 + ps_merge00 tmp2, tmp2, tmp3 + lhz itmp2, 2(in) + ps_madd tmp5, tmp3, cc4, tmp6 + ps_merge11 tmp7, tmp0, tmp6 + psq_l tmp10, 0(in), 0, 5 + ps_sub tmp4, tmp4, tmp5 + ps_add tmp3, tmp1, tmp7 + psq_l tmp11, 0(q), 0, 0 + ps_merge11 tmp4, tmp5, tmp4 + ps_sub tmp0, tmp1, tmp7 + ps_mul tmp10, tmp10, tmp11 + ps_add tmp5, tmp2, tmp4 + ps_sub tmp6, tmp2, tmp4 + ps_merge10 tmp5, tmp5, tmp5 + psq_stu tmp3, 8(ws), 0, 0 + ps_merge10 tmp0, tmp0, tmp0 + psq_stu tmp6, 8(ws), 0, 0 + psq_stu tmp5, 8(ws), 0, 0 + or itmp0, itmp0, itmp3 + psq_stu tmp0, 8(ws), 0, 0 + bdnz _loopHead1 + + _loopEnd: + + } +#endif + // clang-format on + } + + ws = &__THPIDCTWorkspace[0]; + + { + register THPSample* obase = Gbase; + register u32 wid = Gwid; + + register u32 itmp0, off0, off1; + register THPSample *out0, *out1; + + // clang-format off +#ifdef __MWERKS__ + asm { + psq_l tmp10, 8*0*sizeof(f32)(ws), 0, 0 + slwi off0, wid, 3; + psq_l tmp11, 8*4*sizeof(f32)(ws), 0, 0 + slwi xPos, xPos, 2 + psq_l tmp12, 8*2*sizeof(f32)(ws), 0, 0 + slwi off1, wid, 2 + ps_add tmp6, tmp10, tmp11 + add off0, off0, xPos + psq_l tmp13, 8*6*sizeof(f32)(ws), 0, 0 + ps_sub tmp8, tmp10, tmp11 + add off1, off0, off1 + ps_add tmp6, tmp6, bias + li itmp0, 3 + ps_add tmp7, tmp12, tmp13 + add out0, obase, off0 + ps_sub tmp9, tmp12, tmp13 + ps_add tmp0, tmp6, tmp7 + add out1, obase, off1 + ps_add tmp8, tmp8, bias + mtctr itmp0 + + _loopHead10: + psq_l tmp4, 8*1*sizeof(f32)(ws), 0, 0 + ps_msub tmp9, tmp9, cc4, tmp7 + psq_l tmp5, 8*3*sizeof(f32)(ws), 0, 0 + ps_sub tmp3, tmp6, tmp7 + ps_add tmp1, tmp8, tmp9 + psq_l tmp6, 8*5*sizeof(f32)(ws), 0, 0 + ps_sub tmp2, tmp8, tmp9 + psq_l tmp7, 8*7*sizeof(f32)(ws), 0, 0 + ps_add tmp8, tmp6, tmp5 + ps_sub tmp6, tmp6, tmp5 + addi ws, ws, 2*sizeof(f32) + ps_add tmp9, tmp4, tmp7 + ps_sub tmp4, tmp4, tmp7 + psq_l tmp10, 8*0*sizeof(f32)(ws), 0, 0 + ps_add tmp7, tmp9, tmp8 + ps_sub tmp5, tmp9, tmp8 + ps_add tmp8, tmp6, tmp4 + psq_l tmp11, 8*4*sizeof(f32)(ws), 0, 0 + ps_add tmp9, tmp0, tmp7 + ps_mul tmp8, tmp8, cc2 + psq_l tmp12, 8*2*sizeof(f32)(ws), 0, 0 + ps_sub tmp23, tmp0, tmp7 + ps_madd tmp6, tmp6, cc2c6a, tmp8 + psq_l tmp13, 8*6*sizeof(f32)(ws), 0, 0 + ps_sub tmp6, tmp6, tmp7 + addi off0, off0, 2*sizeof(THPSample) + psq_st tmp9, 0(out0), 0, 6 + ps_msub tmp4, tmp4, cc2c6s, tmp8 + ps_add tmp9, tmp1, tmp6 + ps_msub tmp5, tmp5, cc4, tmp6 + ps_sub tmp22, tmp1, tmp6 + psq_st tmp9, 8(out0), 0, 6 + ps_add tmp8, tmp2, tmp5 + ps_add tmp4, tmp4, tmp5 + psq_st tmp8, 16(out0), 0, 6 + addi off1, off1, 2*sizeof(THPSample) + ps_sub tmp9, tmp3, tmp4 + ps_add tmp20, tmp3, tmp4 + psq_st tmp9, 24(out0), 0, 6 + ps_sub tmp21, tmp2, tmp5 + ps_add tmp6, tmp10, tmp11 + psq_st tmp20, 0(out1), 0, 6 + ps_sub tmp8, tmp10, tmp11 + ps_add tmp6, tmp6, bias + psq_st tmp21, 8(out1), 0, 6 + ps_add tmp7, tmp12, tmp13 + ps_sub tmp9, tmp12, tmp13 + psq_st tmp22, 16(out1), 0, 6 + add out0, obase, off0 + ps_add tmp0, tmp6, tmp7 + psq_st tmp23, 24(out1), 0, 6 + ps_add tmp8, tmp8, bias + add out1, obase, off1 + + bdnz _loopHead10 + psq_l tmp4, 8*1*sizeof(f32)(ws), 0, 0 + ps_msub tmp9, tmp9, cc4, tmp7 + psq_l tmp5, 8*3*sizeof(f32)(ws), 0, 0 + ps_sub tmp3, tmp6, tmp7 + ps_add tmp1, tmp8, tmp9 + psq_l tmp6, 8*5*sizeof(f32)(ws), 0, 0 + ps_sub tmp2, tmp8, tmp9 + psq_l tmp7, 8*7*sizeof(f32)(ws), 0, 0 + ps_add tmp8, tmp6, tmp5 + ps_sub tmp6, tmp6, tmp5 + ps_add tmp9, tmp4, tmp7 + ps_sub tmp4, tmp4, tmp7 + ps_add tmp7, tmp9, tmp8 + ps_sub tmp5, tmp9, tmp8 + ps_add tmp8, tmp6, tmp4 + ps_add tmp9, tmp0, tmp7 + ps_mul tmp8, tmp8, cc2 + ps_sub tmp23, tmp0, tmp7 + ps_madd tmp6, tmp6, cc2c6a, tmp8 + psq_st tmp9, 0(out0), 0, 6 + ps_sub tmp6, tmp6, tmp7 + ps_msub tmp4, tmp4, cc2c6s, tmp8 + psq_st tmp23, 24(out1), 0, 6 + ps_add tmp9, tmp1, tmp6 + ps_msub tmp5, tmp5, cc4, tmp6 + ps_sub tmp22, tmp1, tmp6 + psq_st tmp9, 8(out0), 0, 6 + ps_add tmp8, tmp2, tmp5 + ps_add tmp4, tmp4, tmp5 + psq_st tmp8, 16(out0), 0, 6 + ps_sub tmp9, tmp3, tmp4 + psq_st tmp22, 16(out1), 0, 6 + ps_add tmp20, tmp3, tmp4 + psq_st tmp9, 24(out0), 0, 6 + ps_sub tmp21, tmp2, tmp5 + psq_st tmp20, 0(out1), 0, 6 + psq_st tmp21, 8(out1), 0, 6 + + } +#endif + // clang-format on + } } /* 8087445C-808748F4 001D7C 0498+00 3/3 0/0 0/0 .text __THPInverseDCTNoYPos */ -void __THPInverseDCTNoYPos() { - // NONMATCHING +static void __THPInverseDCTNoYPos(register THPCoeff* in, register u32 xPos) { + register f32 *q, *ws; + register f32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8, tmp9; + register f32 tmp10, tmp11, tmp12, tmp13; + register f32 tmp20, tmp21, tmp22, tmp23; + register f32 cc4 = 1.414213562F; + register f32 cc2 = 1.847759065F; + register f32 cc2c6s = 1.082392200F; + register f32 cc2c6a = -2.613125930F; + register f32 bias = 1024.0F; + q = Gq; + ws = &__THPIDCTWorkspace[0] - 2; + + { + register u32 itmp0, itmp1, itmp2, itmp3; + // clang-format off +#ifdef __MWERKS__ + asm { + li itmp2, 8 + mtctr itmp2 + + _loopHead0: + psq_l tmp10, 0(in), 0, 5 + psq_l tmp11, 0(q), 0, 0 + lwz itmp0, 12(in) + lwz itmp3, 8(in) + ps_mul tmp10, tmp10, tmp11 + lwz itmp1, 4(in) + lhz itmp2, 2(in) + or. itmp0, itmp0, itmp3 + + _loopHead1: + cmpwi itmp0, 0 + bne _regularIDCT + ps_merge00 tmp0, tmp10, tmp10 + cmpwi itmp1, 0 + psq_st tmp0, 8(ws), 0, 0 + bne _halfIDCT + psq_st tmp0, 16(ws), 0, 0 + cmpwi itmp2, 0 + psq_st tmp0, 24(ws), 0, 0 + bne _quarterIDCT + addi q, q, 8*sizeof(f32) + psq_stu tmp0, 32(ws), 0, 0 + addi in, in, 8*sizeof(THPCoeff) + bdnz _loopHead0 + b _loopEnd + + _quarterIDCT: + addi in, in, 8*sizeof(THPCoeff) + ps_msub tmp2, tmp10, cc2, tmp10 + addi q, q, 8*sizeof(f32) + ps_merge00 tmp9, tmp10, tmp10 + lwz itmp1, 4(in) + ps_sub tmp1, cc2, cc2c6s + ps_msub tmp3, tmp10, cc4, tmp2 + lhz itmp2, 2(in) + ps_merge11 tmp5, tmp10, tmp2 + psq_l tmp11, 0(q), 0, 0 + ps_nmsub tmp4, tmp10, tmp1, tmp3 + ps_add tmp7, tmp9, tmp5 + psq_l tmp10, 0(in), 0, 5 + ps_merge11 tmp6, tmp3, tmp4 + ps_sub tmp5, tmp9, tmp5 + lwz itmp0, 12(in) + ps_add tmp8, tmp9, tmp6 + lwz itmp3, 8(in) + ps_sub tmp6, tmp9, tmp6 + psq_stu tmp7, 8(ws), 0, 0 + ps_merge10 tmp6, tmp6, tmp6 + psq_stu tmp8, 8(ws), 0, 0 + ps_merge10 tmp5, tmp5, tmp5 + or itmp0, itmp0, itmp3 + psq_stu tmp6, 8(ws), 0, 0 + ps_mul tmp10, tmp10, tmp11 + psq_stu tmp5, 8(ws), 0, 0 + bdnz _loopHead1 + b _loopEnd + + _halfIDCT: + psq_l tmp1, 4(in), 0, 5 + psq_l tmp9, 8(q), 0, 0 + addi in, in, 8*sizeof(THPCoeff) + ps_mul tmp1, tmp1, tmp9 + addi q, q, 8*sizeof(f32) + ps_sub tmp3, tmp10, tmp1 + ps_add tmp2, tmp10, tmp1 + lwz itmp0, 12(in) + ps_madd tmp4, tmp1, cc4, tmp3 + ps_nmsub tmp5, tmp1, cc4, tmp2 + ps_mul tmp8, tmp3, cc2 + ps_merge00 tmp4, tmp2, tmp4 + lwz itmp3, 8(in) + ps_nmsub tmp6, tmp1, cc2c6a, tmp8 + ps_merge00 tmp5, tmp5, tmp3 + lwz itmp1, 4(in) + ps_sub tmp6, tmp6, tmp2 + ps_nmsub tmp7, tmp10, cc2c6s, tmp8 + lhz itmp2, 2(in) + ps_merge11 tmp2, tmp2, tmp6 + ps_msub tmp8, tmp3, cc4, tmp6 + psq_l tmp10, 0(in), 0, 5 + ps_add tmp9, tmp4, tmp2 + ps_sub tmp7, tmp7, tmp8 + psq_l tmp11, 0(q), 0, 0 + ps_merge11 tmp3, tmp8, tmp7 + ps_sub tmp4, tmp4, tmp2 + psq_stu tmp9, 8(ws), 0, 0 + ps_add tmp0, tmp5, tmp3 + ps_sub tmp1, tmp5, tmp3 + or itmp0, itmp0, itmp3 + psq_stu tmp0, 8(ws), 0, 0 + ps_merge10 tmp1, tmp1, tmp1 + ps_merge10 tmp4, tmp4, tmp4 + psq_stu tmp1, 8(ws), 0, 0 + ps_mul tmp10, tmp10, tmp11 + psq_stu tmp4, 8(ws), 0, 0 + bdnz _loopHead1 + b _loopEnd + + _regularIDCT: + psq_l tmp9, 4(in), 0, 5 + psq_l tmp5, 8(q), 0, 0 + ps_mul tmp9, tmp9, tmp5 + psq_l tmp2, 8(in), 0, 5 + psq_l tmp6, 16(q), 0, 0 + ps_merge01 tmp0, tmp10, tmp9 + psq_l tmp3, 12(in), 0, 5 + ps_merge01 tmp1, tmp9, tmp10 + psq_l tmp7, 24(q), 0, 0 + addi in, in, 8*sizeof(THPCoeff) + ps_madd tmp4, tmp2, tmp6, tmp0 + ps_nmsub tmp5, tmp2, tmp6, tmp0 + ps_madd tmp6, tmp3, tmp7, tmp1 + ps_nmsub tmp7, tmp3, tmp7, tmp1 + addi q, q, 8*sizeof(f32) + ps_add tmp0, tmp4, tmp6 + ps_sub tmp3, tmp4, tmp6 + ps_msub tmp2, tmp7, cc4, tmp6 + lwz itmp0, 12(in) + ps_sub tmp8, tmp7, tmp5 + ps_add tmp1, tmp5, tmp2 + ps_sub tmp2, tmp5, tmp2 + ps_mul tmp8, tmp8, cc2 + lwz itmp3, 8(in) + ps_merge00 tmp1, tmp0, tmp1 + ps_nmsub tmp6, tmp5, cc2c6a, tmp8 + ps_msub tmp4, tmp7, cc2c6s, tmp8 + lwz itmp1, 4(in) + ps_sub tmp6, tmp6, tmp0 + ps_merge00 tmp2, tmp2, tmp3 + lhz itmp2, 2(in) + ps_madd tmp5, tmp3, cc4, tmp6 + ps_merge11 tmp7, tmp0, tmp6 + psq_l tmp10, 0(in), 0, 5 + ps_sub tmp4, tmp4, tmp5 + ps_add tmp3, tmp1, tmp7 + psq_l tmp11, 0(q), 0, 0 + ps_merge11 tmp4, tmp5, tmp4 + ps_sub tmp0, tmp1, tmp7 + ps_mul tmp10, tmp10, tmp11 + ps_add tmp5, tmp2, tmp4 + ps_sub tmp6, tmp2, tmp4 + ps_merge10 tmp5, tmp5, tmp5 + psq_stu tmp3, 8(ws), 0, 0 + ps_merge10 tmp0, tmp0, tmp0 + psq_stu tmp6, 8(ws), 0, 0 + psq_stu tmp5, 8(ws), 0, 0 + or itmp0, itmp0, itmp3 + psq_stu tmp0, 8(ws), 0, 0 + bdnz _loopHead1 + + _loopEnd: + + } +#endif + // clang-format on + } + + ws = &__THPIDCTWorkspace[0]; + + { + register THPSample* obase = Gbase; + register u32 wid = Gwid; + + register u32 itmp0, off0, off1; + register THPSample *out0, *out1; + + // clang-format off +#ifdef __MWERKS__ + asm { + psq_l tmp10, 8*0*sizeof(f32)(ws), 0, 0 + slwi xPos, xPos, 2 + psq_l tmp11, 8*4*sizeof(f32)(ws), 0, 0 + slwi off1, wid, 2 + psq_l tmp12, 8*2*sizeof(f32)(ws), 0, 0 + mr off0, xPos + ps_add tmp6, tmp10, tmp11 + psq_l tmp13, 8*6*sizeof(f32)(ws), 0, 0 + ps_sub tmp8, tmp10, tmp11 + add off1, off0, off1 + ps_add tmp6, tmp6, bias + li itmp0, 3 + ps_add tmp7, tmp12, tmp13 + add out0, obase, off0 + ps_sub tmp9, tmp12, tmp13 + ps_add tmp0, tmp6, tmp7 + add out1, obase, off1 + ps_add tmp8, tmp8, bias + mtctr itmp0 + + _loopHead10: + psq_l tmp4, 8*1*sizeof(f32)(ws), 0, 0 + ps_msub tmp9, tmp9, cc4, tmp7 + psq_l tmp5, 8*3*sizeof(f32)(ws), 0, 0 + ps_sub tmp3, tmp6, tmp7 + ps_add tmp1, tmp8, tmp9 + psq_l tmp6, 8*5*sizeof(f32)(ws), 0, 0 + ps_sub tmp2, tmp8, tmp9 + psq_l tmp7, 8*7*sizeof(f32)(ws), 0, 0 + ps_add tmp8, tmp6, tmp5 + ps_sub tmp6, tmp6, tmp5 + addi ws, ws, 2*sizeof(f32) + ps_add tmp9, tmp4, tmp7 + ps_sub tmp4, tmp4, tmp7 + psq_l tmp10, 8*0*sizeof(f32)(ws), 0, 0 + ps_add tmp7, tmp9, tmp8 + ps_sub tmp5, tmp9, tmp8 + ps_add tmp8, tmp6, tmp4 + psq_l tmp11, 8*4*sizeof(f32)(ws), 0, 0 + ps_add tmp9, tmp0, tmp7 + ps_mul tmp8, tmp8, cc2 + psq_l tmp12, 8*2*sizeof(f32)(ws), 0, 0 + ps_sub tmp23, tmp0, tmp7 + ps_madd tmp6, tmp6, cc2c6a, tmp8 + psq_l tmp13, 8*6*sizeof(f32)(ws), 0, 0 + ps_sub tmp6, tmp6, tmp7 + addi off0, off0, 2*sizeof(THPSample) + psq_st tmp9, 0(out0), 0, 6 + ps_msub tmp4, tmp4, cc2c6s, tmp8 + ps_add tmp9, tmp1, tmp6 + ps_msub tmp5, tmp5, cc4, tmp6 + ps_sub tmp22, tmp1, tmp6 + psq_st tmp9, 8(out0), 0, 6 + ps_add tmp8, tmp2, tmp5 + ps_add tmp4, tmp4, tmp5 + psq_st tmp8, 16(out0), 0, 6 + addi off1, off1, 2*sizeof(THPSample) + ps_sub tmp9, tmp3, tmp4 + ps_add tmp20, tmp3, tmp4 + psq_st tmp9, 24(out0), 0, 6 + ps_sub tmp21, tmp2, tmp5 + ps_add tmp6, tmp10, tmp11 + psq_st tmp20, 0(out1), 0, 6 + ps_sub tmp8, tmp10, tmp11 + ps_add tmp6, tmp6, bias + psq_st tmp21, 8(out1), 0, 6 + ps_add tmp7, tmp12, tmp13 + ps_sub tmp9, tmp12, tmp13 + psq_st tmp22, 16(out1), 0, 6 + add out0, obase, off0 + ps_add tmp0, tmp6, tmp7 + psq_st tmp23, 24(out1), 0, 6 + ps_add tmp8, tmp8, bias + add out1, obase, off1 + bdnz _loopHead10 + psq_l tmp4, 8*1*sizeof(f32)(ws), 0, 0 + ps_msub tmp9, tmp9, cc4, tmp7 + psq_l tmp5, 8*3*sizeof(f32)(ws), 0, 0 + ps_sub tmp3, tmp6, tmp7 + ps_add tmp1, tmp8, tmp9 + psq_l tmp6, 8*5*sizeof(f32)(ws), 0, 0 + ps_sub tmp2, tmp8, tmp9 + psq_l tmp7, 8*7*sizeof(f32)(ws), 0, 0 + ps_add tmp8, tmp6, tmp5 + ps_sub tmp6, tmp6, tmp5 + ps_add tmp9, tmp4, tmp7 + ps_sub tmp4, tmp4, tmp7 + ps_add tmp7, tmp9, tmp8 + ps_sub tmp5, tmp9, tmp8 + ps_add tmp8, tmp6, tmp4 + ps_add tmp9, tmp0, tmp7 + ps_mul tmp8, tmp8, cc2 + ps_sub tmp23, tmp0, tmp7 + ps_madd tmp6, tmp6, cc2c6a, tmp8 + psq_st tmp9, 0(out0), 0, 6 + ps_sub tmp6, tmp6, tmp7 + ps_msub tmp4, tmp4, cc2c6s, tmp8 + psq_st tmp23, 24(out1), 0, 6 + ps_add tmp9, tmp1, tmp6 + ps_msub tmp5, tmp5, cc4, tmp6 + ps_sub tmp22, tmp1, tmp6 + psq_st tmp9, 8(out0), 0, 6 + ps_add tmp8, tmp2, tmp5 + ps_add tmp4, tmp4, tmp5 + psq_st tmp22, 16(out1), 0, 6 + psq_st tmp8, 16(out0), 0, 6 + ps_sub tmp9, tmp3, tmp4 + ps_add tmp20, tmp3, tmp4 + psq_st tmp9, 24(out0), 0, 6 + ps_sub tmp21, tmp2, tmp5 + psq_st tmp20, 0(out1), 0, 6 + psq_st tmp21, 8(out1), 0, 6 + } +#endif + // clang-format on + } } /* 808748F4-80874B38 002214 0244+00 1/1 0/0 0/0 .text __THPDecompressiMCURow640x480 */ -void __THPDecompressiMCURow640x480() { - // NONMATCHING +static void __THPDecompressiMCURow640x480() { + u8 cl_num; + u32 x_pos; + THPComponent* comp; + + LCQueueWait(3); + + { + for (cl_num = 0; cl_num < __THPInfo->MCUsPerRow; cl_num++) { + THPFileInfo* um = __THPInfo; + __THPHuffDecodeDCTCompY(um, __THPMCUBuffer[0]); + __THPHuffDecodeDCTCompY(__THPInfo, __THPMCUBuffer[1]); + __THPHuffDecodeDCTCompY(__THPInfo, __THPMCUBuffer[2]); + __THPHuffDecodeDCTCompY(__THPInfo, __THPMCUBuffer[3]); + __THPHuffDecodeDCTCompU(__THPInfo, __THPMCUBuffer[4]); + __THPHuffDecodeDCTCompV(__THPInfo, __THPMCUBuffer[5]); + + comp = &__THPInfo->components[0]; + Gbase = __THPLCWork640[0]; + Gwid = 640; + Gq = __THPInfo->quantTabs[comp->quantizationTableSelector]; + x_pos = (u32)(cl_num * 16); + __THPInverseDCTNoYPos(__THPMCUBuffer[0], x_pos); + __THPInverseDCTNoYPos(__THPMCUBuffer[1], x_pos + 8); + __THPInverseDCTY8(__THPMCUBuffer[2], x_pos); + __THPInverseDCTY8(__THPMCUBuffer[3], x_pos + 8); + + comp = &__THPInfo->components[1]; + Gbase = __THPLCWork640[1]; + Gwid = 320; + Gq = __THPInfo->quantTabs[comp->quantizationTableSelector]; + x_pos /= 2; + __THPInverseDCTNoYPos(__THPMCUBuffer[4], x_pos); + + comp = &__THPInfo->components[2]; + Gbase = __THPLCWork640[2]; + Gq = __THPInfo->quantTabs[comp->quantizationTableSelector]; + __THPInverseDCTNoYPos(__THPMCUBuffer[5], x_pos); + + if (__THPInfo->RST != 0) { + __THPInfo->currMCU--; + if (__THPInfo->currMCU == 0) { + __THPInfo->currMCU = __THPInfo->nMCU; + + __THPInfo->cnt = 1 + ((__THPInfo->cnt + 6) & 0xFFFFFFF8); + + if (__THPInfo->cnt > 32) { + __THPInfo->cnt = 33; + } + + __THPInfo->components[0].predDC = 0; + __THPInfo->components[1].predDC = 0; + __THPInfo->components[2].predDC = 0; + } + } + } + } + + LCStoreData(__THPInfo->dLC[0], __THPLCWork640[0], 0x2800); + LCStoreData(__THPInfo->dLC[1], __THPLCWork640[1], 0xA00); + LCStoreData(__THPInfo->dLC[2], __THPLCWork640[2], 0xA00); + + __THPInfo->dLC[0] += 0x2800; + __THPInfo->dLC[1] += 0xA00; + __THPInfo->dLC[2] += 0xA00; } /* 80874B38-80874D8C 002458 0254+00 1/1 0/0 0/0 .text __THPDecompressiMCURowNxN */ -void __THPDecompressiMCURowNxN() { - // NONMATCHING +static void __THPDecompressiMCURowNxN() { + u8 cl_num; + u32 x_pos, x; + THPComponent* comp; + + x = __THPInfo->xPixelSize; + + LCQueueWait(3); + + for (cl_num = 0; cl_num < __THPInfo->MCUsPerRow; cl_num++) { + __THPHuffDecodeDCTCompY(__THPInfo, __THPMCUBuffer[0]); + __THPHuffDecodeDCTCompY(__THPInfo, __THPMCUBuffer[1]); + __THPHuffDecodeDCTCompY(__THPInfo, __THPMCUBuffer[2]); + __THPHuffDecodeDCTCompY(__THPInfo, __THPMCUBuffer[3]); + __THPHuffDecodeDCTCompU(__THPInfo, __THPMCUBuffer[4]); + __THPHuffDecodeDCTCompV(__THPInfo, __THPMCUBuffer[5]); + + comp = &__THPInfo->components[0]; + Gbase = __THPLCWork640[0]; + Gwid = x; + Gq = __THPInfo->quantTabs[comp->quantizationTableSelector]; + x_pos = (u32)(cl_num * 16); + __THPInverseDCTNoYPos(__THPMCUBuffer[0], x_pos); + __THPInverseDCTNoYPos(__THPMCUBuffer[1], x_pos + 8); + __THPInverseDCTY8(__THPMCUBuffer[2], x_pos); + __THPInverseDCTY8(__THPMCUBuffer[3], x_pos + 8); + + comp = &__THPInfo->components[1]; + Gbase = __THPLCWork640[1]; + Gwid = x / 2; + Gq = __THPInfo->quantTabs[comp->quantizationTableSelector]; + x_pos /= 2; + __THPInverseDCTNoYPos(__THPMCUBuffer[4], x_pos); + + comp = &__THPInfo->components[2]; + Gbase = __THPLCWork640[2]; + Gq = __THPInfo->quantTabs[comp->quantizationTableSelector]; + __THPInverseDCTNoYPos(__THPMCUBuffer[5], x_pos); + + if (__THPInfo->RST != 0) { + __THPInfo->currMCU--; + if (__THPInfo->currMCU == 0) { + __THPInfo->currMCU = __THPInfo->nMCU; + __THPInfo->cnt = 1 + ((__THPInfo->cnt + 6) & 0xFFFFFFF8); + + if (__THPInfo->cnt > 32) { + __THPInfo->cnt = 33; + } + + __THPInfo->components[0].predDC = 0; + __THPInfo->components[1].predDC = 0; + __THPInfo->components[2].predDC = 0; + } + } + } + + LCStoreData(__THPInfo->dLC[0], __THPLCWork640[0], ((4 * sizeof(u8) * 64) * (x / 16))); + LCStoreData(__THPInfo->dLC[1], __THPLCWork640[1], ((sizeof(u8) * 64) * (x / 16))); + LCStoreData(__THPInfo->dLC[2], __THPLCWork640[2], ((sizeof(u8) * 64) * (x / 16))); + __THPInfo->dLC[0] += ((4 * sizeof(u8) * 64) * (x / 16)); + __THPInfo->dLC[1] += ((sizeof(u8) * 64) * (x / 16)); + __THPInfo->dLC[2] += ((sizeof(u8) * 64) * (x / 16)); } /* 80874D8C-80875198 0026AC 040C+00 3/3 0/0 0/0 .text __THPHuffDecodeDCTCompY */ -void __THPHuffDecodeDCTCompY() { - // NONMATCHING +static void __THPHuffDecodeDCTCompY(register THPFileInfo* info, THPCoeff* block) { + { + register s32 t; + THPCoeff dc; + register THPCoeff diff; + + __dcbz((void*)block, 0); + t = __THPHuffDecodeTab(info, Ydchuff); + __dcbz((void*)block, 32); + diff = 0; + __dcbz((void*)block, 64); + + if (t) { + { + register s32 v; + register u32 cb; + register u32 cnt; + register u32 code; + register u32 tmp; + register u32 cnt1; + register u32 tmp1; + // clang-format off +#ifdef __MWERKS__ + asm { + lwz cnt,info->cnt; + subfic code,cnt,33; + lwz cb,info->currByte; + + subfc. tmp, code, t; + subi cnt1,cnt,1; + + bgt _notEnoughBitsDIFF; + add v,cnt,t; + + slw cnt,cb,cnt1; + stw v,info->cnt; + subfic v,t,32; + srw diff,cnt,v; + } +#endif + // clang-format on + + // clang-format off +#ifdef __MWERKS__ + asm + { + b _DoneDIFF; + _notEnoughBitsDIFF: + lwz tmp1, info->c; + slw v, cb, cnt1; + lwzu cb, 4(tmp1); + addi tmp, tmp, 1; + stw cb, info->currByte; + srw cb, cb, code; + stw tmp1, info->c; + add v, cb, v; + stw tmp, info->cnt; + subfic tmp, t, 32; + srw diff, v, tmp; + _DoneDIFF: + } +#endif + // clang-format on + } + + if (__cntlzw((u32)diff) > 32 - t) { + diff += ((0xFFFFFFFF << t) + 1); + } + }; + + __dcbz((void*)block, 96); + dc = (s16)(info->components[0].predDC + diff); + block[0] = info->components[0].predDC = dc; + } + + { + register s32 k; + register s32 code; + register u32 cnt; + register u32 cb; + register u32 increment; + register s32 tmp; + register THPHuffmanTab* h = Yachuff; + + // clang-format off +#ifdef __MWERKS__ + asm + { + lwz cnt, info->cnt; + addi increment, h, 32; + lwz cb, info->currByte; + } +#endif + // clang-format on + + for (k = 1; k < 64; k++) + { + register s32 ssss; + register s32 rrrr; + + // clang-format off +#ifdef __MWERKS__ + asm { + addi code, cnt, 4; + cmpwi cnt, 28; + rlwnm tmp, cb, code, 27, 31; + bgt _notEnoughBits; + + lbzx ssss, h, tmp; + lbzx code, increment, tmp; + cmpwi ssss, 0xFF; + + beq _FailedCheckEnoughBits; + add cnt, cnt, code; + b _DoneDecodeTab; + } +#endif + // clang-format on + + { + register u32 maxcodebase; + register u32 tmp2; + + _FailedCheckEnoughBits: + cnt += 5; + maxcodebase = (u32) & (h->maxCode); + // clang-format off +#ifdef __MWERKS__ + asm { + li tmp2, sizeof(s32)*(5); + li code, 5; + add maxcodebase, maxcodebase, tmp2; + __WHILE_START: + cmpwi cnt, 33; + slwi tmp, tmp, 1 + + beq _FCEB_faster; + rlwnm ssss, cb, cnt, 31, 31; + lwzu tmp2, 4(maxcodebase); + or tmp, tmp, ssss + addi cnt, cnt, 1; + b __WHILE_CHECK; + + _FCEB_faster: + lwz ssss, info->c; + li cnt, 1; + lwzu cb, 4(ssss); + + lwzu tmp2, 4(maxcodebase); + + stw ssss, info->c; + rlwimi tmp, cb, 1,31,31; + b __FL_WHILE_CHECK; + + __FL_WHILE_START: + slwi tmp, tmp, 1; + + rlwnm ssss, cb, cnt, 31, 31; + lwzu tmp2, 4(maxcodebase); + or tmp, tmp, ssss; + + __FL_WHILE_CHECK: + cmpw tmp,tmp2 + addi cnt, cnt, 1; + addi code, code, 1 + bgt __FL_WHILE_START; + b _FCEB_Done; + + __WHILE_CHECK: + cmpw tmp,tmp2 + addi code, code, 1 + bgt __WHILE_START; + } +#endif + // clang-format on + } + _FCEB_Done: + ssss = (h->Vij[(s32)(tmp + h->valPtr[code])]); + goto _DoneDecodeTab; + + _notEnoughBits: + // clang-format off +#ifdef __MWERKS__ + asm + { + cmpwi cnt, 33; + lwz tmp, info->c; + beq _getfullword; + + cmpwi cnt, 32; + rlwnm code, cb, code, 27, 31 + beq _1bitleft; + + lbzx ssss, h, code; + lbzx rrrr, increment, code; + cmpwi ssss, 0xFF; + add code, cnt, rrrr; + beq _FailedCheckNoBits0; + + cmpwi code, 33; + bgt _FailedCheckNoBits1; + } +#endif + // clang-format on + cnt = (u32)code; + goto _DoneDecodeTab; + + _getfullword : { + // clang-format off +#ifdef __MWERKS__ + asm + { + lwzu cb, 4(tmp); + rlwinm code, cb, 5, 27, 31 + stw tmp, info->c; + lbzx ssss, h, code; + lbzx tmp, increment, code; + cmpwi ssss, 0xFF + addi cnt, tmp, 1 + beq _FailedCheckEnoughbits_Updated; + } +#endif + // clang-format on + } + goto _DoneDecodeTab; + + _FailedCheckEnoughbits_Updated: + ssss = 5; + do { + // clang-format off +#ifdef __MWERKS__ + asm + { + subfic tmp, ssss, 31; + addi ssss, ssss, 1; + srw code, cb, tmp; + } +#endif + // clang-format on + } while (code > h->maxCode[ssss]); + + cnt = (u32)(ssss + 1); + ssss = (h->Vij[(s32)(code + h->valPtr[ssss])]); + + goto _DoneDecodeTab; + + _1bitleft: + // clang-format off +#ifdef __MWERKS__ + asm { + lwzu cb, 4(tmp); + + stw tmp, info->c; + rlwimi code, cb, 4, 28, 31; + lbzx ssss, h, code; + lbzx cnt, increment, code + cmpwi ssss, 0xFF + beq _Read4; + + } +#endif + // clang-format on + + goto _DoneDecodeTab; + + _Read4 : { + register u32 maxcodebase = (u32) & (h->maxCode); + register u32 tmp2; + + // clang-format off +#ifdef __MWERKS__ + asm { + li cnt, sizeof(s32)*5; + add maxcodebase, maxcodebase, cnt; + + slwi tmp, code, 32-5; + li cnt,5; + rlwimi tmp, cb, 32-1, 1,31; + + __DR4_WHILE_START: + + subfic ssss, cnt, 31; + lwzu tmp2, 4(maxcodebase); + srw code, tmp, ssss; + __DR4_WHILE_CHECK: + cmpw code, tmp2 + addi cnt, cnt, 1 + bgt __DR4_WHILE_START; + + } +#endif + // clang-format on + } + ssss = (h->Vij[(s32)(code + h->valPtr[cnt])]); + goto _DoneDecodeTab; + + _FailedCheckNoBits0: + _FailedCheckNoBits1: + _REALFAILEDCHECKNOBITS : { + register u32 mask = 0xFFFFFFFF << (33 - cnt); + register u32 tmp2; + register u32 tmp3; + code = (s32)(cb & (~mask)); + mask = (u32) & (h->maxCode); + + // clang-format off +#ifdef __MWERKS__ + asm { + lwz tmp, info->c; + subfic tmp2, cnt, 33; + addi tmp3, tmp2, 1; + slwi tmp2, tmp2, 2; + lwzu cb, 4(tmp); + add mask,mask, tmp2; + stw tmp, info->c; + slwi code, code, 1; + rlwimi code, cb, 1, 31, 31; + lwzu tmp2, 4(mask); + li cnt, 2; + b __FCNB1_WHILE_CHECK; + + __FCNB1_WHILE_START: + slwi code, code, 1; + + addi tmp3, tmp3, 1; + lwzu tmp2, 4(mask); + add code, code, rrrr; + addi cnt, cnt, 1; + + __FCNB1_WHILE_CHECK: + cmpw code, tmp2; + rlwnm rrrr, cb, cnt, 31, 31; + bgt __FCNB1_WHILE_START; + + } +#endif + // clang-format on + ssss = (h->Vij[(s32)(code + h->valPtr[tmp3])]); + } + + goto _DoneDecodeTab; + + _DoneDecodeTab: + // clang-format off +#ifdef __MWERKS__ + asm { + andi. rrrr, ssss, 15; + srawi ssss, ssss, 4; + beq _RECV_SSSS_ZERO; + } +#endif + // clang-format on + + { + k += ssss; + { + register s32 v; + register u32 cnt1; + register u32 tmp1; + // clang-format off +#ifdef __MWERKS__ + asm + { + subfic code,cnt,33; + subfc. tmp, code, rrrr; + subi cnt1,cnt,1; + bgt _RECVnotEnoughBits; + add cnt,cnt,rrrr; + slw tmp1,cb,cnt1; + subfic v,rrrr,32; + srw ssss,tmp1,v; + } +#endif + // clang-format on + // clang-format off +#ifdef __MWERKS__ + asm + { + b _RECVDone; + _RECVnotEnoughBits: + lwz tmp1, info->c; + slw v, cb, cnt1; + lwzu cb, 4(tmp1); + addi cnt, tmp, 1; + stw tmp1, info->c; + srw tmp1, cb, code; + + add v, tmp1, v; + subfic tmp, rrrr, 32; + srw ssss, v, tmp; + _RECVDone: + } +#endif + // clang-format on + } + + if (__cntlzw((u32)ssss) > 32 - rrrr) { + ssss += ((0xFFFFFFFF << rrrr) + 1); + } + + block[__THPJpegNaturalOrder[k]] = (s16)ssss; +#ifdef __MWERKS__ + goto _RECV_END; +#else + continue; +#endif + } + + { + _RECV_SSSS_ZERO: + if (ssss != 15) { + break; + } + + k += 15; + }; + + // clang-format off +#ifdef __MWERKS__ + asm + { + _RECV_END: + } +#endif + // clang-format on + } + info->cnt = cnt; + info->currByte = cb; + } } /* 80875198-80875410 002AB8 0278+00 3/3 0/0 0/0 .text __THPHuffDecodeTab */ -void __THPHuffDecodeTab() { - // NONMATCHING +static s32 __THPHuffDecodeTab(register THPFileInfo* info, register THPHuffmanTab* h) { + register s32 code; + register u32 cnt; + register s32 cb; + register u32 increment; + register s32 tmp; + + // clang-format off +#ifdef __MWERKS__ + asm + { + lwz cnt, info->cnt; + addi increment, h, 32; + lwz cb, info->currByte; + addi code, cnt, 4; + cmpwi cnt, 28; + rlwnm tmp, cb, code, 27, 31; + bgt _notEnoughBits; + lbzx code, h, tmp; + lbzx increment, increment, tmp; + cmpwi code, 0xFF; + beq _FailedCheckEnoughBits; + add cnt, cnt, increment; + stw cnt, info->cnt; + } +#endif + // clang-format on +_done: + return code; + + { + register u32 maxcodebase; + register u32 tmp2; + + _FailedCheckEnoughBits: + maxcodebase = (u32) & (h->maxCode); + cnt += 5; + + // clang-format off +#ifdef __MWERKS__ + asm { + li tmp2, sizeof(s32)*(5); + li code, 5; + add maxcodebase, maxcodebase, tmp2; + __WHILE_START: + cmpwi cnt, 33; + slwi tmp, tmp, 1 + + beq _FCEB_faster; + rlwnm increment, cb, cnt, 31, 31; + lwzu tmp2, 4(maxcodebase); + or tmp, tmp, increment + addi cnt, cnt, 1; + b __WHILE_CHECK; + + _FCEB_faster: + lwz increment, info->c; + li cnt, 1; + lwzu cb, 4(increment); + lwzu tmp2, 4(maxcodebase); + + stw increment, info->c; + rlwimi tmp, cb, 1,31,31; + stw cb, info->currByte; + b __FL_WHILE_CHECK; + + __FL_WHILE_START: + slwi tmp, tmp, 1; + rlwnm increment, cb, cnt, 31, 31; + lwzu tmp2, 4(maxcodebase); + or tmp, tmp, increment; + + __FL_WHILE_CHECK: + cmpw tmp,tmp2 + addi cnt, cnt, 1; + addi code, code, 1 + bgt __FL_WHILE_START; + b _FCEB_Done; + + __WHILE_CHECK: + cmpw tmp,tmp2 + addi code, code, 1 + bgt __WHILE_START; + } +#endif + // clang-format on + } +_FCEB_Done: + info->cnt = cnt; + return (h->Vij[(s32)(tmp + h->valPtr[code])]); + + // clang-format off +#ifdef __MWERKS__ + asm + { + _notEnoughBits: + cmpwi cnt, 33; + lwz tmp, info->c; + beq _getfullword; + + cmpwi cnt, 32; + rlwnm code, cb, code, 27, 31 + beq _1bitleft; + + lbzx tmp, h, code; + lbzx increment, increment, code; + cmpwi tmp, 0xFF; + add code, cnt, increment; + beq _FailedCheckNoBits0; + + cmpwi code, 33; + stw code, info->cnt; + bgt _FailedCheckNoBits1; + } +#endif + // clang-format on + return tmp; + + // clang-format off +#ifdef __MWERKS__ + asm { + _1bitleft: + lwzu cb, 4(tmp); + + stw tmp, info->c; + rlwimi code, cb, 4, 28, 31; + lbzx tmp, h, code; + lbzx increment, increment, code + stw cb, info->currByte; + cmpwi tmp, 0xFF + stw increment, info->cnt; + beq _Read4; + + } +#endif + // clang-format on + return tmp; + +_Read4 : { + register u32 maxcodebase = (u32) & (h->maxCode); + register u32 tmp2; + + // clang-format off +#ifdef __MWERKS__ + asm + { + li cnt, sizeof(s32)*5; + add maxcodebase, maxcodebase, cnt; + + slwi tmp, code, 32-5; + li cnt,5; + rlwimi tmp, cb, 32-1, 1,31; + + __DR4_WHILE_START: + + subfic cb, cnt, 31; + lwzu tmp2, 4(maxcodebase); + srw code, tmp, cb; + __DR4_WHILE_CHECK: + cmpw code, tmp2 + addi cnt, cnt, 1 + bgt __DR4_WHILE_START; + + } +#endif + // clang-format on +} + + info->cnt = cnt; +__CODE_PLUS_VP_CNT: + return (h->Vij[(s32)(code + h->valPtr[cnt])]); + +_getfullword: + // clang-format off +#ifdef __MWERKS__ + asm + { + lwzu cb, 4(tmp); + + rlwinm code, cb, 5, 27, 31 + stw tmp, info->c; + lbzx cnt, h, code; + lbzx increment, increment, code; + cmpwi cnt, 0xFF + stw cb, info->currByte; + addi increment, increment, 1 + beq _FailedCheckEnoughbits_Updated; + + stw increment, info->cnt; + } +#endif + // clang-format on + return (s32)cnt; + +_FailedCheckEnoughbits_Updated: + + cnt = 5; + do { + // clang-format off +#ifdef __MWERKS__ + asm + { + subfic tmp, cnt, 31; + addi cnt, cnt, 1; + srw code, cb, tmp; + } +#endif + // clang-format on + } while (code > h->maxCode[cnt]); + + info->cnt = cnt + 1; + goto __CODE_PLUS_VP_CNT; + +_FailedCheckNoBits0: +_FailedCheckNoBits1: + +{ + register u32 mask = 0xFFFFFFFF << (33 - cnt); + register u32 tmp2; + + code = (s32)(cb & (~mask)); + mask = (u32) & (h->maxCode); + + // clang-format off +#ifdef __MWERKS__ + asm + { + lwz tmp, info->c; + subfic tmp2, cnt, 33; + addi cnt, tmp2, 1; + slwi tmp2, tmp2, 2; + lwzu cb, 4(tmp); + add mask,mask, tmp2; + stw tmp, info->c; + slwi code, code, 1; + stw cb, info->currByte; + rlwimi code, cb, 1, 31, 31; + lwzu tmp2, 4(mask); + li tmp, 2; + b __FCNB1_WHILE_CHECK; + + __FCNB1_WHILE_START: + slwi code, code, 1; + + addi cnt, cnt, 1; + lwzu tmp2, 4(mask); + add code, code, increment; + addi tmp, tmp, 1; + + __FCNB1_WHILE_CHECK: + cmpw code, tmp2; + rlwnm increment, cb, tmp, 31, 31; + bgt __FCNB1_WHILE_START; + + } +#endif + // clang-format on +} + + info->cnt = (u32)tmp; + return (h->Vij[(s32)(code + h->valPtr[cnt])]); } /* 80875410-808755F8 002D30 01E8+00 3/3 0/0 0/0 .text __THPHuffDecodeDCTCompU */ -void __THPHuffDecodeDCTCompU() { - // NONMATCHING +static void __THPHuffDecodeDCTCompU(register THPFileInfo* info, THPCoeff* block) { + register s32 t; + register THPCoeff diff; + THPCoeff dc; + register s32 v; + register u32 cb; + register u32 cnt; + register u32 cnt33; + register u32 tmp; + register u32 cnt1; + register u32 tmp1; + register s32 k; + register s32 ssss; + register s32 rrrr; + + __dcbz((void*)block, 0); + t = __THPHuffDecodeTab(info, Udchuff); + __dcbz((void*)block, 32); + diff = 0; + __dcbz((void*)block, 64); + + if (t) { + // clang-format off +#ifdef __MWERKS__ + asm + { + lwz cnt,info->cnt; + subfic cnt33,cnt,33; + lwz cb,info->currByte; + subfc. tmp, cnt33, t; + subi cnt1,cnt,1; + bgt _notEnoughBitsDIFF; + add v,cnt,t; + slw cnt,cb,cnt1; + stw v,info->cnt; + subfic v,t,32; + srw diff,cnt,v; + } +#endif + // clang-format on + + // clang-format off +#ifdef __MWERKS__ + asm + { + b _DoneDIFF; + _notEnoughBitsDIFF: + lwz tmp1, info->c; + slw v, cb, cnt1; + lwzu cb, 4(tmp1); + addi tmp, tmp, 1; + stw cb, info->currByte; + srw cb, cb, cnt33; + stw tmp1, info->c; + add v, cb, v; + stw tmp, info->cnt; + subfic tmp, t, 32; + srw diff, v, tmp; + _DoneDIFF: + } +#endif + // clang-format on + + if (__cntlzw((u32)diff) > 32 - t) { + diff += ((0xFFFFFFFF << t) + 1); + } + } + + __dcbz((void*)block, 96); + dc = (s16)(info->components[1].predDC + diff); + block[0] = info->components[1].predDC = dc; + + for (k = 1; k < 64; k++) { + ssss = __THPHuffDecodeTab(info, Uachuff); + rrrr = ssss >> 4; + ssss &= 15; + + if (ssss) { + k += rrrr; + // clang-format off +#ifdef __MWERKS__ + asm + { + lwz cnt,info->cnt; + subfic cnt33,cnt,33; + lwz cb,info->currByte; + subf. tmp, cnt33, ssss; + subi cnt1,cnt,1; + bgt _notEnoughBits; + add v,cnt,ssss; + slw cnt,cb,cnt1; + stw v,info->cnt; + subfic v,ssss,32; + srw rrrr,cnt,v; + } +#endif + // clang-format on + + // clang-format off +#ifdef __MWERKS__ + asm + { + b _Done; + _notEnoughBits: + lwz tmp1, info->c; + slw v, cb, cnt1; + lwzu cb, 4(tmp1); + addi tmp, tmp, 1; + stw cb, info->currByte; + srw cb, cb, cnt33; + stw tmp1, info->c; + add v, cb, v; + stw tmp, info->cnt; + subfic tmp, ssss, 32; + srw rrrr, v, tmp; + _Done: + } +#endif + // clang-format on + + if (__cntlzw((u32)rrrr) > 32 - ssss) { + rrrr += ((0xFFFFFFFF << ssss) + 1); + } + + block[__THPJpegNaturalOrder[k]] = (s16)rrrr; + } + + else { + if (rrrr != 15) + break; + k += 15; + } + } } /* 808755F8-808757E0 002F18 01E8+00 3/3 0/0 0/0 .text __THPHuffDecodeDCTCompV */ -void __THPHuffDecodeDCTCompV() { - // NONMATCHING +static void __THPHuffDecodeDCTCompV(register THPFileInfo* info, THPCoeff* block) { + register s32 t; + register THPCoeff diff; + THPCoeff dc; + register s32 v; + register u32 cb; + register u32 cnt; + register u32 cnt33; + register u32 tmp; + register u32 cnt1; + register u32 tmp1; + register s32 k; + register s32 ssss; + register s32 rrrr; + + __dcbz((void*)block, 0); + t = __THPHuffDecodeTab(info, Vdchuff); + __dcbz((void*)block, 32); + diff = 0; + __dcbz((void*)block, 64); + + if (t) { + // clang-format off +#ifdef __MWERKS__ + asm + { + lwz cnt,info->cnt; + subfic cnt33,cnt,33; + lwz cb,info->currByte; + subf. tmp, cnt33, t; + subi cnt1,cnt,1; + bgt _notEnoughBitsDIFF; + add v,cnt,t; + slw cnt,cb,cnt1; + stw v,info->cnt; + subfic v,t,32; + srw diff,cnt,v; + } +#endif + // clang-format on + + // clang-format off +#ifdef __MWERKS__ + asm + { + b _DoneDIFF; + _notEnoughBitsDIFF: + lwz tmp1, info->c; + slw v, cb, cnt1; + lwzu cb, 4(tmp1); + addi tmp, tmp, 1; + stw cb, info->currByte; + srw cb, cb, cnt33; + stw tmp1, info->c; + add v, cb, v; + stw tmp, info->cnt; + subfic tmp, t, 32; + srw diff, v, tmp; + _DoneDIFF: + } +#endif + // clang-format on + + if (__cntlzw((u32)diff) > 32 - t) { + diff += ((0xFFFFFFFF << t) + 1); + } + } + + __dcbz((void*)block, 96); + + dc = (s16)(info->components[2].predDC + diff); + block[0] = info->components[2].predDC = dc; + + for (k = 1; k < 64; k++) { + ssss = __THPHuffDecodeTab(info, Vachuff); + rrrr = ssss >> 4; + ssss &= 15; + + if (ssss) { + k += rrrr; + + // clang-format off +#ifdef __MWERKS__ + asm + { + lwz cnt,info->cnt; + subfic cnt33,cnt,33; + lwz cb,info->currByte; + + subf. tmp, cnt33, ssss; + subi cnt1,cnt,1; + + bgt _notEnoughBits; + add v,cnt,ssss; + + slw cnt,cb,cnt1; + stw v,info->cnt; + subfic v,ssss,32; + srw rrrr,cnt,v; + } +#endif + // clang-format on + + // clang-format off +#ifdef __MWERKS__ + asm + { + b _Done; + _notEnoughBits: + lwz tmp1, info->c; + slw v, cb, cnt1; + lwzu cb, 4(tmp1); + addi tmp, tmp, 1; + stw cb, info->currByte; + srw cb, cb, cnt33; + stw tmp1, info->c; + add v, cb, v; + stw tmp, info->cnt; + subfic tmp, ssss, 32; + srw rrrr, v, tmp; + _Done: + } +#endif + // clang-format on + + if (__cntlzw((u32)rrrr) > 32 - ssss) { + rrrr += ((0xFFFFFFFF << ssss) + 1); + } + + block[__THPJpegNaturalOrder[k]] = (s16)rrrr; + } else { + if (rrrr != 15) + break; + k += 15; + } + } } /* 808757E0-8087584C 003100 006C+00 1/1 0/0 0/0 .text THPInit */ -static void THPInit() { - // NONMATCHING +static BOOL THPInit() { + u8* base; + base = (u8*)(0xE000 << 16); + + __THPLCWork512[0] = base; + base += 0x2000; + __THPLCWork512[1] = base; + base += 0x800; + __THPLCWork512[2] = base; + base += 0x200; + + base = (u8*)(0xE000 << 16); + __THPLCWork640[0] = base; + base += 0x2800; + __THPLCWork640[1] = base; + base += 0xA00; + __THPLCWork640[2] = base; + base += 0xA00; + + OSInitFastCast(); + + __THPInitFlag = TRUE; + return TRUE; } -/* 8087584C-80875880 00316C 0034+00 1/1 0/0 0/0 .text OSInitFastCast */ -static void i_OSInitFastCast() { - // NONMATCHING +#ifdef __cplusplus } +#endif -/* ############################################################################################## */ /* 80879BD0-80879DA0 000630 01D0+00 28/29 0/0 0/0 .bss daMP_ActivePlayer */ -static u8 daMP_ActivePlayer[464] ALIGN_DECL(16); +static daMP_Player_c daMP_ActivePlayer ALIGN_DECL(16); /* 80879DA0-80879DA4 000800 0004+00 2/3 0/0 0/0 .bss daMP_ReadThreadCreated */ -static u8 daMP_ReadThreadCreated[4]; +static BOOL daMP_ReadThreadCreated; /* 80879DA4-80879DC4 000804 0020+00 2/3 0/0 0/0 .bss daMP_FreeReadBufferQueue */ -static u8 daMP_FreeReadBufferQueue[32]; +static OSMessageQueue daMP_FreeReadBufferQueue; /* 80879DC4-80879DE4 000824 0020+00 2/3 0/0 0/0 .bss daMP_ReadedBufferQueue */ -static u8 daMP_ReadedBufferQueue[32]; +static OSMessageQueue daMP_ReadedBufferQueue; /* 80875880-808758B4 0031A0 0034+00 2/2 0/0 0/0 .text daMP_PopReadedBuffer__Fv */ -static void daMP_PopReadedBuffer() { - // NONMATCHING +void* daMP_PopReadedBuffer() { + OSMessage msg; + OSReceiveMessage(&daMP_ReadedBufferQueue, &msg, 1); + return msg; } /* 808758B4-808758E4 0031D4 0030+00 1/1 0/0 0/0 .text daMP_PushReadedBuffer__FPv */ -static void daMP_PushReadedBuffer(void* param_0) { - // NONMATCHING +void daMP_PushReadedBuffer(void* r3) { + OSMessage msg = (OSMessage)r3; + OSSendMessage(&daMP_ReadedBufferQueue, msg, 1); } /* 808758E4-80875918 003204 0034+00 1/1 0/0 0/0 .text daMP_PopFreeReadBuffer__Fv */ -static void daMP_PopFreeReadBuffer() { - // NONMATCHING +daMP_THPReadBuffer* daMP_PopFreeReadBuffer() { + OSMessage msg; + OSReceiveMessage(&daMP_FreeReadBufferQueue, &msg, 1); + return (daMP_THPReadBuffer*)msg; } /* 80875918-80875948 003238 0030+00 2/2 0/0 0/0 .text daMP_PushFreeReadBuffer__FPv */ -static void daMP_PushFreeReadBuffer(void* param_0) { - // NONMATCHING +void daMP_PushFreeReadBuffer(void* r3) { + OSMessage msg = (OSMessage)r3; + OSSendMessage(&daMP_FreeReadBufferQueue, msg, 1); } -/* ############################################################################################## */ /* 80879DE4-80879E04 000844 0020+00 2/3 0/0 0/0 .bss daMP_ReadedBufferQueue2 */ -static u8 daMP_ReadedBufferQueue2[32]; +static OSMessageQueue daMP_ReadedBufferQueue2; /* 80875948-8087597C 003268 0034+00 1/1 0/0 0/0 .text daMP_PopReadedBuffer2__Fv */ -static void daMP_PopReadedBuffer2() { - // NONMATCHING +void* daMP_PopReadedBuffer2() { + OSMessage msg; + OSReceiveMessage(&daMP_ReadedBufferQueue2, &msg, 1); + return msg; } /* 8087597C-808759AC 00329C 0030+00 1/1 0/0 0/0 .text daMP_PushReadedBuffer2__FPv */ -static void daMP_PushReadedBuffer2(void* param_0) { - // NONMATCHING +void daMP_PushReadedBuffer2(void* r3) { + OSMessage msg = (OSMessage)r3; + OSSendMessage(&daMP_ReadedBufferQueue2, msg, 1); } -/* ############################################################################################## */ /* 80879E04-80879E2C 000864 0028+00 0/1 0/0 0/0 .bss daMP_FreeReadBufferMessage */ -#pragma push -#pragma force_active on -static u8 daMP_FreeReadBufferMessage[40]; -#pragma pop +static OSMessage daMP_FreeReadBufferMessage[10]; /* 80879E2C-80879E54 00088C 0028+00 0/1 0/0 0/0 .bss daMP_ReadedBufferMessage */ -#pragma push -#pragma force_active on -static u8 daMP_ReadedBufferMessage[40]; -#pragma pop +static OSMessage daMP_ReadedBufferMessage[10]; /* 80879E54-80879E80 0008B4 0028+04 0/1 0/0 0/0 .bss daMP_ReadedBufferMessage2 */ -#pragma push -#pragma force_active on -static u8 daMP_ReadedBufferMessage2[40 + 4 /* padding */]; -#pragma pop +static OSMessage daMP_ReadedBufferMessage2[10]; /* 80879E80-8087A198 0008E0 0318+00 3/4 0/0 0/0 .bss daMP_ReadThread */ -static u8 daMP_ReadThread[792] ALIGN_DECL(32); +static OSThread daMP_ReadThread; /* 808759AC-808759E4 0032CC 0038+00 1/1 0/0 0/0 .text daMP_ReadThreadStart__Fv */ -static void daMP_ReadThreadStart() { - // NONMATCHING +void daMP_ReadThreadStart() { + if (daMP_ReadThreadCreated) { + OSResumeThread(&daMP_ReadThread); + } } /* 808759E4-80875A28 003304 0044+00 1/1 0/0 0/0 .text daMP_ReadThreadCancel__Fv */ -static void daMP_ReadThreadCancel() { - // NONMATCHING +void daMP_ReadThreadCancel() { + if (daMP_ReadThreadCreated) { + OSCancelThread(&daMP_ReadThread); + daMP_ReadThreadCreated = FALSE; + } } /* 80875A28-80875B0C 003348 00E4+00 1/1 0/0 0/0 .text daMP_Reader__FPv */ -static void daMP_Reader(void* param_0) { - // NONMATCHING -} - -/* 80875B0C-80875B18 00342C 000C+00 1/1 0/0 0/0 .text daMP_NEXT_READ_SIZE__FP18daMP_THPReadBuffer - */ -static void daMP_NEXT_READ_SIZE(daMP_THPReadBuffer* param_0) { - // NONMATCHING +// NONMATCHINIG - regalloc +void daMP_Reader(void*) { + s32 r28 = 0; + s32 r30 = daMP_ActivePlayer.field_0xb8; + s32 r29 = daMP_ActivePlayer.field_0xbc; + while (true) { + daMP_THPReadBuffer* readBuf = daMP_PopFreeReadBuffer(); + int readBytes = DVDReadPrio(&daMP_ActivePlayer.mFileInfo, readBuf->m00, r29, r30, 2); + if (readBytes != r29) { + if (readBytes == -1) { + daMP_ActivePlayer.field_0xa8 = -1; + } + if (r28 == 0) { + daMP_PrepareReady(0); + } + OSSuspendThread(&daMP_ReadThread); + } + readBuf->m04 = r28; + daMP_PushReadedBuffer(readBuf); + r30 += r29; + r29 = daMP_NEXT_READ_SIZE(readBuf); + u32 r0 = (r28 + daMP_ActivePlayer.field_0xc0) % daMP_ActivePlayer.mTotalFrames; + if (r0 == daMP_ActivePlayer.mTotalFrames - 1) { + if (daMP_ActivePlayer.field_0xa6 & 0x01) { + r30 = daMP_ActivePlayer.field_0x64; + } else { + OSSuspendThread(&daMP_ReadThread); + } + } + r28++; + } } -/* ############################################################################################## */ -/* 8087911C-8087911C 0000E8 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ -#pragma push -#pragma force_active on -SECTION_DEAD static char const* const stringBase_8087911C = "Can't create read thread\n"; -#pragma pop - /* 8087A198-8087C198 000BF8 2000+00 0/1 0/0 0/0 .bss daMP_ReadThreadStack */ -#pragma push -#pragma force_active on -static u8 daMP_ReadThreadStack[8192]; -#pragma pop +static u8 daMP_ReadThreadStack[0x2000]; /* 8087C198-8087C1A0 002BF8 0004+04 2/4 0/0 0/0 .bss daMP_VideoDecodeThreadCreated */ -static u8 daMP_VideoDecodeThreadCreated[4 + 4 /* padding */]; +static BOOL daMP_VideoDecodeThreadCreated; /* 80875B18-80875BC8 003438 00B0+00 1/1 0/0 0/0 .text daMP_CreateReadThread__Fl */ -static void daMP_CreateReadThread(s32 param_0) { +static BOOL daMP_CreateReadThread(s32 param_0) { // NONMATCHING + if (!OSCreateThread(&daMP_ReadThread, daMP_Reader, 0, daMP_ReadThreadStack + sizeof(daMP_ReadThreadStack), sizeof(daMP_ReadThreadStack), param_0, 1)) { + OSReport("Can't create read thread\n"); + return 0; + } + + OSInitMessageQueue(&daMP_FreeReadBufferQueue, daMP_FreeReadBufferMessage, 10); + OSInitMessageQueue(&daMP_ReadedBufferQueue, daMP_ReadedBufferMessage, 10); + OSInitMessageQueue(&daMP_ReadedBufferQueue2, daMP_ReadedBufferMessage2, 10); + daMP_ReadThreadCreated = TRUE; + return 1; } -/* ############################################################################################## */ /* 8087C1A0-8087C4B8 002C00 0318+00 4/5 0/0 0/0 .bss daMP_VideoDecodeThread */ -static u8 daMP_VideoDecodeThread[792] ALIGN_DECL(32); +static OSThread daMP_VideoDecodeThread; /* 8087C4B8-808E04B8 002F18 64000+00 1/1 0/0 0/0 .bss daMP_VideoDecodeThreadStack */ -static u8 daMP_VideoDecodeThreadStack[409600]; +static u8 daMP_VideoDecodeThreadStack[0x64000]; /* 808E04B8-808E04D8 066F18 0020+00 2/2 0/0 0/0 .bss daMP_FreeTextureSetQueue */ -static u8 daMP_FreeTextureSetQueue[32]; +static OSMessageQueue daMP_FreeTextureSetQueue; /* 80875BC8-80875BFC 0034E8 0034+00 1/1 0/0 0/0 .text daMP_PopFreeTextureSet__Fv */ -static void daMP_PopFreeTextureSet() { - // NONMATCHING +OSMessage daMP_PopFreeTextureSet() { + OSMessage msg; + OSReceiveMessage(&daMP_FreeTextureSetQueue, &msg, 1); + return msg; } /* 80875BFC-80875C2C 00351C 0030+00 2/2 0/0 0/0 .text daMP_PushFreeTextureSet__FPv */ -static void daMP_PushFreeTextureSet(void* param_0) { - // NONMATCHING +void daMP_PushFreeTextureSet(void* r3) { + OSMessage msg = (OSMessage)r3; + OSSendMessage(&daMP_FreeTextureSetQueue, msg, 0); } -/* ############################################################################################## */ /* 808E04D8-808E04F8 066F38 0020+00 2/2 0/0 0/0 .bss daMP_DecodedTextureSetQueue */ -static u8 daMP_DecodedTextureSetQueue[32]; +static OSMessageQueue daMP_DecodedTextureSetQueue; /* 80875C2C-80875C70 00354C 0044+00 1/1 0/0 0/0 .text daMP_PopDecodedTextureSet__Fl */ -static void daMP_PopDecodedTextureSet(s32 param_0) { - // NONMATCHING +void* daMP_PopDecodedTextureSet(s32 r3) { + OSMessage msg; + if (OSReceiveMessage(&daMP_DecodedTextureSetQueue, &msg, r3) == TRUE) { + return msg; + } else { + return NULL; + } } /* 80875C70-80875CA0 003590 0030+00 1/1 0/0 0/0 .text daMP_PushDecodedTextureSet__FPv */ -static void daMP_PushDecodedTextureSet(void* param_0) { - // NONMATCHING +void daMP_PushDecodedTextureSet(void* r3) { + OSMessage msg = (OSMessage)r3; + OSSendMessage(&daMP_DecodedTextureSetQueue, msg, 1); } -/* ############################################################################################## */ /* 808E04F8-808E0504 066F58 000C+00 0/0 0/0 0/0 .bss daMP_FreeTextureSetMessage */ -#pragma push -#pragma force_active on -static u8 daMP_FreeTextureSetMessage[12]; -#pragma pop +static OSMessage daMP_FreeTextureSetMessage[3]; /* 808E0504-808E0510 066F64 000C+00 0/0 0/0 0/0 .bss daMP_DecodedTextureSetMessage */ -#pragma push -#pragma force_active on -static u8 daMP_DecodedTextureSetMessage[12]; -#pragma pop +static OSMessage daMP_DecodedTextureSetMessage[3]; /* 808E0510-808E0514 066F70 0004+00 1/1 0/0 0/0 .bss daMP_First */ -static u8 daMP_First[4]; +static BOOL daMP_First; /* 80875CA0-80875DD8 0035C0 0138+00 2/2 0/0 0/0 .text daMP_VideoDecode__FP18daMP_THPReadBuffer */ static void daMP_VideoDecode(daMP_THPReadBuffer* param_0) { @@ -763,67 +2813,85 @@ static void daMP_VideoDecoderForOnMemory(void* param_0) { // NONMATCHING } -/* ############################################################################################## */ -/* 8087911C-8087911C 0000E8 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ -#pragma push -#pragma force_active on -SECTION_DEAD static char const* const stringBase_80879136 = "Can't create video decode thread\n"; -#pragma pop - /* 80875FD4-808760EC 0038F4 0118+00 1/1 0/0 0/0 .text daMP_CreateVideoDecodeThread__FlPUc */ -static void daMP_CreateVideoDecodeThread(s32 param_0, u8* param_1) { - // NONMATCHING +static int daMP_CreateVideoDecodeThread(s32 param_0, u8* param_1) { + if (param_1 != NULL) { + if (!OSCreateThread(&daMP_VideoDecodeThread, daMP_VideoDecoderForOnMemory, param_1, daMP_VideoDecodeThreadStack + sizeof(daMP_VideoDecodeThreadStack), sizeof(daMP_VideoDecodeThreadStack), param_0, 1)) { + OSReport("Can't create video decode thread\n"); + return 0; + } + } else { + if (!OSCreateThread(&daMP_VideoDecodeThread, daMP_VideoDecoder, NULL, daMP_VideoDecodeThreadStack + sizeof(daMP_VideoDecodeThreadStack), sizeof(daMP_VideoDecodeThreadStack), param_0, 1)) { + OSReport("Can't create video decode thread\n"); + return 0; + } + } + + OSInitMessageQueue(&daMP_FreeTextureSetQueue, daMP_FreeTextureSetMessage, 3); + OSInitMessageQueue(&daMP_DecodedTextureSetQueue, daMP_DecodedTextureSetMessage, 3); + + daMP_First = daMP_VideoDecodeThreadCreated = TRUE; + return 1; } /* 808760EC-80876124 003A0C 0038+00 1/1 0/0 0/0 .text daMP_VideoDecodeThreadStart__Fv */ static void daMP_VideoDecodeThreadStart() { - // NONMATCHING + if (daMP_VideoDecodeThreadCreated) { + OSResumeThread(&daMP_VideoDecodeThread); + } } /* 80876124-80876168 003A44 0044+00 1/1 0/0 0/0 .text daMP_VideoDecodeThreadCancel__Fv */ -static void daMP_VideoDecodeThreadCancel() { - // NONMATCHING +void daMP_VideoDecodeThreadCancel() { + if (daMP_VideoDecodeThreadCreated) { + OSCancelThread(&daMP_VideoDecodeThread); + daMP_VideoDecodeThreadCreated = FALSE; + } } -/* ############################################################################################## */ /* 808E0514-808E0518 066F74 0004+00 2/2 0/0 0/0 .bss daMP_AudioDecodeThreadCreated */ -static u8 daMP_AudioDecodeThreadCreated[4]; +static BOOL daMP_AudioDecodeThreadCreated; /* 808E0518-808E0830 066F78 0318+00 3/3 0/0 0/0 .bss daMP_AudioDecodeThread */ -static u8 daMP_AudioDecodeThread[792]; +static OSThread daMP_AudioDecodeThread; /* 808E0830-80944830 067290 64000+00 0/0 0/0 0/0 .bss daMP_AudioDecodeThreadStack */ -#pragma push -#pragma force_active on -static u8 daMP_AudioDecodeThreadStack[409600]; -#pragma pop +static u8 daMP_AudioDecodeThreadStack[0x64000]; /* 80944830-80944850 0CB290 0020+00 2/2 0/0 0/0 .bss daMP_FreeAudioBufferQueue */ -static u8 daMP_FreeAudioBufferQueue[32]; +static OSMessageQueue daMP_FreeAudioBufferQueue; /* 80876168-8087619C 003A88 0034+00 1/1 0/0 0/0 .text daMP_PopFreeAudioBuffer__Fv */ -static void daMP_PopFreeAudioBuffer() { - // NONMATCHING +static OSMessage daMP_PopFreeAudioBuffer() { + OSMessage msg; + OSReceiveMessage(&daMP_FreeAudioBufferQueue, &msg, OS_MESSAGE_BLOCK); + return msg; } /* 8087619C-808761CC 003ABC 0030+00 2/2 0/0 0/0 .text daMP_PushFreeAudioBuffer__FPv */ static void daMP_PushFreeAudioBuffer(void* param_0) { - // NONMATCHING + OSMessage msg = (OSMessage)param_0; + OSSendMessage(&daMP_FreeAudioBufferQueue, msg, OS_MESSAGE_NOBLOCK); } -/* ############################################################################################## */ /* 80944850-80944870 0CB2B0 0020+00 2/2 0/0 0/0 .bss daMP_DecodedAudioBufferQueue */ -static u8 daMP_DecodedAudioBufferQueue[32]; +static OSMessageQueue daMP_DecodedAudioBufferQueue; /* 808761CC-80876210 003AEC 0044+00 1/1 0/0 0/0 .text daMP_PopDecodedAudioBuffer__Fl */ -static void daMP_PopDecodedAudioBuffer(s32 param_0) { - // NONMATCHING +static OSMessage daMP_PopDecodedAudioBuffer(s32 param_0) { + OSMessage msg; + if (OSReceiveMessage(&daMP_DecodedAudioBufferQueue, &msg, param_0) == 1) { + return msg; + } + + return NULL; } /* 80876210-80876240 003B30 0030+00 1/1 0/0 0/0 .text daMP_PushDecodedAudioBuffer__FPv */ static void daMP_PushDecodedAudioBuffer(void* param_0) { - // NONMATCHING + OSMessage msg = (OSMessage)param_0; + OSSendMessage(&daMP_DecodedAudioBufferQueue, msg, OS_MESSAGE_BLOCK); } /* 80876240-8087631C 003B60 00DC+00 2/2 0/0 0/0 .text daMP_AudioDecode__FP18daMP_THPReadBuffer */ @@ -833,7 +2901,11 @@ static void daMP_AudioDecode(daMP_THPReadBuffer* param_0) { /* 8087631C-80876344 003C3C 0028+00 1/1 0/0 0/0 .text daMP_AudioDecoder__FPv */ static void daMP_AudioDecoder(void* param_0) { - // NONMATCHING + while (1) { + void* var_r31 = daMP_PopReadedBuffer(); + daMP_AudioDecode((daMP_THPReadBuffer*)var_r31); + daMP_PushReadedBuffer2(var_r31); + } } /* 80876344-808763EC 003C64 00A8+00 1/1 0/0 0/0 .text daMP_AudioDecoderForOnMemory__FPv @@ -842,162 +2914,212 @@ static void daMP_AudioDecoderForOnMemory(void* param_0) { // NONMATCHING } -/* ############################################################################################## */ -/* 8087911C-8087911C 0000E8 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ -#pragma push -#pragma force_active on -SECTION_DEAD static char const* const stringBase_80879158 = "Can't create audio decode thread\n"; -#pragma pop +/* 80944870-8094487C 0CB2D0 000C+00 0/0 0/0 0/0 .bss daMP_FreeAudioBufferMessage */ +static OSMessage daMP_FreeAudioBufferMessage[3]; + +/* 8094487C-80944888 0CB2DC 000C+00 0/0 0/0 0/0 .bss daMP_DecodedAudioBufferMessage */ +static OSMessage daMP_DecodedAudioBufferMessage[3]; /* 808763EC-808764E8 003D0C 00FC+00 1/1 0/0 0/0 .text daMP_CreateAudioDecodeThread__FlPUc */ -static void daMP_CreateAudioDecodeThread(s32 param_0, u8* param_1) { - // NONMATCHING +static int daMP_CreateAudioDecodeThread(s32 param_0, u8* param_1) { + if (param_1 != NULL) { + if (!OSCreateThread(&daMP_AudioDecodeThread, daMP_AudioDecoderForOnMemory, param_1, daMP_AudioDecodeThreadStack + sizeof(daMP_AudioDecodeThreadStack), sizeof(daMP_AudioDecodeThreadStack), param_0, 1)) { + return 0; + } + } else { + if (!OSCreateThread(&daMP_AudioDecodeThread, daMP_AudioDecoder, NULL, daMP_AudioDecodeThreadStack + sizeof(daMP_AudioDecodeThreadStack), sizeof(daMP_AudioDecodeThreadStack), param_0, 1)) { + OSReport("Can't create audio decode thread\n"); + return 0; + } + } + + OSInitMessageQueue(&daMP_FreeAudioBufferQueue, daMP_FreeAudioBufferMessage, 3); + OSInitMessageQueue(&daMP_DecodedAudioBufferQueue, daMP_DecodedAudioBufferMessage, 3); + + daMP_AudioDecodeThreadCreated = TRUE; + return 1; } /* 808764E8-80876520 003E08 0038+00 1/1 0/0 0/0 .text daMP_AudioDecodeThreadStart__Fv */ -static void daMP_AudioDecodeThreadStart() { - // NONMATCHING +void daMP_AudioDecodeThreadStart() { + if (daMP_AudioDecodeThreadCreated) { + OSResumeThread(&daMP_AudioDecodeThread); + } } /* 80876520-80876564 003E40 0044+00 1/1 0/0 0/0 .text daMP_AudioDecodeThreadCancel__Fv */ -static void daMP_AudioDecodeThreadCancel() { - // NONMATCHING +void daMP_AudioDecodeThreadCancel() { + if (daMP_AudioDecodeThreadCreated) { + OSCancelThread(&daMP_AudioDecodeThread); + daMP_AudioDecodeThreadCreated = FALSE; + } } /* 80876564-8087667C 003E84 0118+00 1/1 0/0 0/0 .text daMP_THPGXRestore__Fv */ static void daMP_THPGXRestore() { - // NONMATCHING + GXSetZMode(GX_ENABLE, GX_ALWAYS, GX_DISABLE); + GXSetBlendMode(GX_BM_NONE, GX_BL_ONE, GX_BL_ZERO, GX_LO_SET); + GXSetNumTexGens(1); + GXSetNumChans(0); + GXSetNumTevStages(1); + GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL); + GXSetTevOp(GX_TEVSTAGE0, GX_REPLACE); + GXSetTevSwapMode(GX_TEVSTAGE0, GX_TEV_SWAP0, GX_TEV_SWAP0); + GXSetTevSwapMode(GX_TEVSTAGE1, GX_TEV_SWAP0, GX_TEV_SWAP0); + GXSetTevSwapMode(GX_TEVSTAGE2, GX_TEV_SWAP0, GX_TEV_SWAP0); + GXSetTevSwapMode(GX_TEVSTAGE3, GX_TEV_SWAP0, GX_TEV_SWAP0); + GXSetTevSwapModeTable(GX_TEV_SWAP0, GX_CH_RED, GX_CH_GREEN, GX_CH_BLUE, GX_CH_ALPHA); + GXSetTevSwapModeTable(GX_TEV_SWAP1, GX_CH_RED, GX_CH_RED, GX_CH_RED, GX_CH_ALPHA); + GXSetTevSwapModeTable(GX_TEV_SWAP2, GX_CH_GREEN, GX_CH_GREEN, GX_CH_GREEN, GX_CH_ALPHA); + GXSetTevSwapModeTable(GXTevSwapSel(GX_TEV_SWAP1|GX_TEV_SWAP2), GX_CH_BLUE, GX_CH_BLUE, GX_CH_BLUE, GX_CH_ALPHA); +} + +static f32 dummyLiteral() { + f32 temp = 100.0f; + temp += 60.0f; + return temp; } -/* ############################################################################################## */ -/* 808790E0-808790E4 0000AC 0004+00 1/1 0/0 0/0 .rodata @4465 */ -SECTION_RODATA static f32 const lit_4465 = 100.0f; -COMPILER_STRIP_GATE(0x808790E0, &lit_4465); +/* 8087667C-80876BA8 003F9C 052C+00 1/1 0/0 0/0 .text + * daMP_THPGXYuv2RgbSetup__FPC16_GXRenderModeObj */ +// NONMATCHING - stack slightly too small +static void daMP_THPGXYuv2RgbSetup(GXRenderModeObj const* param_0) { + int width = param_0->fb_width; + int height = param_0->efb_height; + f32 var_f31 = 0.0f; + Mtx sp50; + Mtx sp20; + + GXSetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR); + C_MTXOrtho(sp50, var_f31, height - var_f31, 0.0f, width, 0.0f, -1.0f); + GXSetProjection(sp50, GX_ORTHOGRAPHIC); + GXSetViewport(0.0f, 0.0f, width, height, 0.0f, 1.0f); + GXSetScissor(0, 0, width, height); + MTXIdentity(sp20); + GXLoadPosMtxImm(sp20, GX_PNMTX0); + GXSetCurrentMtx(0); + GXSetZCompLoc(GX_TRUE); + GXSetZMode(GX_ENABLE, GX_ALWAYS, GX_DISABLE); + GXSetBlendMode(GX_BM_NONE, GX_BL_ONE, GX_BL_ZERO, GX_LO_CLEAR); + GXSetAlphaCompare(GX_ALWAYS, 0, GX_AOP_OR, GX_ALWAYS, 0); + GXSetFog(GX_FOG_NONE, 0.0f, 0.0f, 0.0f, 0.0f, g_clearColor); + GXSetFogRangeAdj(GX_DISABLE, 0, NULL); + GXSetCullMode(GX_CULL_NONE); + GXSetDither(GX_ENABLE); + GXSetColorUpdate(GX_ENABLE); + GXSetAlphaUpdate(GX_DISABLE); + GXSetNumIndStages(0); + GXSetNumChans(0); + GXSetNumTexGens(2); + GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, 60); + GXSetTexCoordGen(GX_TEXCOORD1, GX_TG_MTX2x4, GX_TG_TEX0, 60); + GXInvalidateTexAll(); + GXClearVtxDesc(); + GXSetVtxDesc(GX_VA_POS, GX_DIRECT); + GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT); + GXSetVtxAttrFmt(GX_VTXFMT7, GX_VA_POS, GX_CLR_RGBA, GX_RGBA4, 0); + GXSetVtxAttrFmt(GX_VTXFMT7, GX_VA_TEX0, GX_CLR_RGBA, GX_RGBX8, 0); + GXSetNumTevStages(4); + GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD1, GX_TEXMAP1, GX_COLOR_NULL); + GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_TEXC, GX_CC_KONST, GX_CC_C0); + GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_FALSE, GX_TEVPREV); + GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_TEXA, GX_CA_KONST, GX_CA_A0); + GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_SUB, GX_TB_ZERO, GX_CS_SCALE_1, GX_FALSE, GX_TEVPREV); + GXSetTevKColorSel(GX_TEVSTAGE0, GX_TEV_KCSEL_K0); + GXSetTevKAlphaSel(GX_TEVSTAGE0, GX_TEV_KASEL_K0_A); + GXSetTevSwapMode(GX_TEVSTAGE0, GX_TEV_SWAP0, GX_TEV_SWAP0); + GXSetTevOrder(GX_TEVSTAGE1, GX_TEXCOORD1, GX_TEXMAP2, GX_COLOR_NULL); + GXSetTevColorIn(GX_TEVSTAGE1, GX_CC_ZERO, GX_CC_TEXC, GX_CC_KONST, GX_CC_CPREV); + GXSetTevColorOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_2, GX_FALSE, GX_TEVPREV); + GXSetTevAlphaIn(GX_TEVSTAGE1, GX_CA_ZERO, GX_CA_TEXA, GX_CA_KONST, GX_CA_APREV); + GXSetTevAlphaOp(GX_TEVSTAGE1, GX_TEV_SUB, GX_TB_ZERO, GX_CS_SCALE_1, GX_FALSE, GX_TEVPREV); + GXSetTevKColorSel(GX_TEVSTAGE1, GX_TEV_KCSEL_K1); + GXSetTevKAlphaSel(GX_TEVSTAGE1, GX_TEV_KASEL_K1_A); + GXSetTevSwapMode(GX_TEVSTAGE1, GX_TEV_SWAP0, GX_TEV_SWAP0); + GXSetTevOrder(GX_TEVSTAGE2, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL); + GXSetTevColorIn(GX_TEVSTAGE2, GX_CC_ZERO, GX_CC_TEXC, GX_CC_ONE, GX_CC_CPREV); + GXSetTevColorOp(GX_TEVSTAGE2, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV); + GXSetTevAlphaIn(GX_TEVSTAGE2, GX_CA_TEXA, GX_CA_ZERO, GX_CA_ZERO, GX_CA_APREV); + GXSetTevAlphaOp(GX_TEVSTAGE2, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV); + GXSetTevSwapMode(GX_TEVSTAGE2, GX_TEV_SWAP0, GX_TEV_SWAP0); + GXSetTevOrder(GX_TEVSTAGE3, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR_NULL); + GXSetTevColorIn(GX_TEVSTAGE3, GX_CC_APREV, GX_CC_CPREV, GX_CC_KONST, GX_CC_ZERO); + GXSetTevColorOp(GX_TEVSTAGE3, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV); + GXSetTevAlphaIn(GX_TEVSTAGE3, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO); + GXSetTevAlphaOp(GX_TEVSTAGE3, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV); + GXSetTevSwapMode(GX_TEVSTAGE3, GX_TEV_SWAP0, GX_TEV_SWAP0); + GXSetTevKColorSel(GX_TEVSTAGE3, GX_TEV_KCSEL_K2); + + GXColorS10 spA8 = {-0x5A, 0x00, -0x72, 0x87}; + GXSetTevColorS10(GX_TEVREG0, spA8); + + GXColor spB0 = {0x00, 0x00, 0xE2, 0x58}; + GXSetTevKColor(GX_KCOLOR0, spB0); + + GXColor spB4 = {0xB3, 0x00, 0x00, 0xB6}; + GXSetTevKColor(GX_KCOLOR1, spB4); + + GXColor spB8 = {0xFF, 0x00, 0xFF, 0x80}; + GXSetTevKColor(GX_KCOLOR2, spB8); + + GXSetTevSwapModeTable(GX_TEV_SWAP0, GX_CH_RED, GX_CH_GREEN, GX_CH_BLUE, GX_CH_ALPHA); +} -/* 808790E4-808790E8 0000B0 0004+00 0/0 0/0 0/0 .rodata @4466 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4466 = 60.0f; -COMPILER_STRIP_GATE(0x808790E4, &lit_4466); -#pragma pop +/* 80876BD0-80876DE4 0044F0 0214+00 1/1 0/0 0/0 .text daMP_THPGXYuv2RgbDraw__FPUcPUcPUcssssss */ +static void daMP_THPGXYuv2RgbDraw(u8* param_0, u8* param_1, u8* param_2, s16 param_3, + s16 param_4, s16 param_5, s16 param_6, s16 param_7, + s16 param_8) { + GXTexObj sp48; + GXTexObj sp28; + GXTexObj sp8; + + GXInitTexObj(&sp48, param_0, param_5, param_6, GX_TF_I8, GX_CLAMP, GX_CLAMP, GX_FALSE); + GXInitTexObjLOD(&sp48, GX_NEAR, GX_NEAR, 0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1); + GXLoadTexObj(&sp48, GX_TEXMAP0); + + GXInitTexObj(&sp28, param_1, param_5 >> 1, param_6 >> 1, GX_TF_I8, GX_CLAMP, GX_CLAMP, GX_FALSE); + GXInitTexObjLOD(&sp28, GX_NEAR, GX_NEAR, 0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1); + GXLoadTexObj(&sp28, GX_TEXMAP1); + + GXInitTexObj(&sp8, param_2, param_5 >> 1, param_6 >> 1, GX_TF_I8, GX_CLAMP, GX_CLAMP, GX_FALSE); + GXInitTexObjLOD(&sp8, GX_NEAR, GX_NEAR, 0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1); + GXLoadTexObj(&sp8, GX_TEXMAP2); + + GXBegin(GX_QUADS, GX_VTXFMT7, 4); + GXPosition3s16(param_3, param_4, 0); + GXTexCoord2u16(0, 0); + GXPosition3s16(param_3 + param_7, param_4, 0); + GXTexCoord2u16(1, 0); + GXPosition3s16(param_3 + param_7, param_4 + param_8, 0); + GXTexCoord2u16(1, 1); + GXPosition3s16(param_3, param_4 + param_8, 0); + GXTexCoord2u16(0, 1); + GXEnd(); +} -/* 808790E8-808790F0 0000B4 0008+00 0/1 0/0 0/0 .rodata @4779 */ -#pragma push -#pragma force_active on -SECTION_RODATA static u8 const lit_4779[8] = { - 0xFF, 0xA6, 0x00, 0x00, 0xFF, 0x8E, 0x00, 0x87, -}; -COMPILER_STRIP_GATE(0x808790E8, &lit_4779); -#pragma pop - -/* 808790F0-808790F4 0000BC 0004+00 0/1 0/0 0/0 .rodata @4782 */ -#pragma push -#pragma force_active on -SECTION_RODATA static u32 const lit_4782 = 0x0000E258; -COMPILER_STRIP_GATE(0x808790F0, &lit_4782); -#pragma pop - -/* 808790F4-808790F8 0000C0 0004+00 0/1 0/0 0/0 .rodata @4785 */ -#pragma push -#pragma force_active on -SECTION_RODATA static u32 const lit_4785 = 0xB30000B6; -COMPILER_STRIP_GATE(0x808790F4, &lit_4785); -#pragma pop - -/* 808790F8-808790FC 0000C4 0004+00 0/1 0/0 0/0 .rodata @4788 */ -#pragma push -#pragma force_active on -SECTION_RODATA static u32 const lit_4788 = 0xFF00FF80; -COMPILER_STRIP_GATE(0x808790F8, &lit_4788); -#pragma pop - -/* 808790FC-80879100 0000C8 0004+00 2/4 0/0 0/0 .rodata @4809 */ -SECTION_RODATA static u8 const lit_4809[4] = { - 0x00, - 0x00, - 0x00, - 0x00, -}; -COMPILER_STRIP_GATE(0x808790FC, &lit_4809); - -/* 80879100-80879104 0000CC 0004+00 0/1 0/0 0/0 .rodata @4810 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4810 = -1.0f; -COMPILER_STRIP_GATE(0x80879100, &lit_4810); -#pragma pop - -/* 80879104-8087910C 0000D0 0004+04 1/3 0/0 0/0 .rodata @4811 */ -SECTION_RODATA static f32 const lit_4811[1 + 1 /* padding */] = { - 1.0f, - /* padding */ - 0.0f, -}; -COMPILER_STRIP_GATE(0x80879104, &lit_4811); - -/* 8087910C-80879114 0000D8 0008+00 2/3 0/0 0/0 .rodata @4814 */ -SECTION_RODATA static u8 const lit_4814[8] = { - 0x43, 0x30, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, -}; -COMPILER_STRIP_GATE(0x8087910C, &lit_4814); - -/* 8087667C-80876BA8 003F9C 052C+00 1/1 0/0 0/0 .text - * daMP_THPGXYuv2RgbSetup__FPC16_GXRenderModeObj */ -static void daMP_THPGXYuv2RgbSetup(_GXRenderModeObj const* param_0) { - // NONMATCHING -} - -/* 80876BA8-80876BD0 0044C8 0028+00 1/1 0/0 0/0 .text GXSetTexCoordGen */ -static void i_GXSetTexCoordGen() { - // NONMATCHING -} - -/* 80876BD0-80876DE4 0044F0 0214+00 1/1 0/0 0/0 .text daMP_THPGXYuv2RgbDraw__FPUcPUcPUcssssss */ -static void daMP_THPGXYuv2RgbDraw(u8* param_0, u8* param_1, u8* param_2, s16 param_3, - s16 param_4, s16 param_5, s16 param_6, s16 param_7, - s16 param_8) { - // NONMATCHING -} - -/* 80876DE4-80876DE8 004704 0004+00 1/1 0/0 0/0 .text GXEnd */ -static void i_GXEnd() { - /* empty function */ -} - -/* 80876DE8-80876DF8 004708 0010+00 1/1 0/0 0/0 .text GXTexCoord2u16 */ -static void i_GXTexCoord2u16() { - // NONMATCHING -} - -/* 80876DF8-80876E0C 004718 0014+00 1/1 0/0 0/0 .text GXPosition3s16 */ -static void i_GXPosition3s16() { - // NONMATCHING -} - -/* ############################################################################################## */ /* 80879114-80879118 0000E0 0004+00 1/1 0/0 0/0 .rodata @4894 */ SECTION_RODATA static f32 const lit_4894 = 7.0f / 10.0f; COMPILER_STRIP_GATE(0x80879114, &lit_4894); /* 80879434-80879534 000000 0100+00 1/1 0/0 0/0 .data daMP_VolumeTable */ -SECTION_DATA static u8 daMP_VolumeTable[256] = { - 0x00, 0x00, 0x00, 0x02, 0x00, 0x08, 0x00, 0x12, 0x00, 0x20, 0x00, 0x32, 0x00, 0x49, 0x00, 0x63, - 0x00, 0x82, 0x00, 0xA4, 0x00, 0xCB, 0x00, 0xF5, 0x01, 0x24, 0x01, 0x57, 0x01, 0x8E, 0x01, 0xC9, - 0x02, 0x08, 0x02, 0x4B, 0x02, 0x92, 0x02, 0xDD, 0x03, 0x2C, 0x03, 0x7F, 0x03, 0xD7, 0x04, 0x32, - 0x04, 0x92, 0x04, 0xF5, 0x05, 0x5D, 0x05, 0xC9, 0x06, 0x38, 0x06, 0xAC, 0x07, 0x24, 0x07, 0xA0, - 0x08, 0x20, 0x08, 0xA4, 0x09, 0x2C, 0x09, 0xB8, 0x0A, 0x48, 0x0A, 0xDD, 0x0B, 0x75, 0x0C, 0x12, - 0x0C, 0xB2, 0x0D, 0x57, 0x0D, 0xFF, 0x0E, 0xAC, 0x0F, 0x5D, 0x10, 0x12, 0x10, 0xCA, 0x11, 0x87, - 0x12, 0x48, 0x13, 0x0D, 0x13, 0xD7, 0x14, 0xA4, 0x15, 0x75, 0x16, 0x4A, 0x17, 0x24, 0x18, 0x01, - 0x18, 0xE3, 0x19, 0xC8, 0x1A, 0xB2, 0x1B, 0xA0, 0x1C, 0x91, 0x1D, 0x87, 0x1E, 0x81, 0x1F, 0x7F, - 0x20, 0x81, 0x21, 0x87, 0x22, 0x91, 0x23, 0x9F, 0x24, 0xB2, 0x25, 0xC8, 0x26, 0xE2, 0x28, 0x01, - 0x29, 0x23, 0x2A, 0x4A, 0x2B, 0x75, 0x2C, 0xA3, 0x2D, 0xD6, 0x2F, 0x0D, 0x30, 0x48, 0x31, 0x87, - 0x32, 0xCA, 0x34, 0x11, 0x35, 0x5C, 0x36, 0xAB, 0x37, 0xFF, 0x39, 0x56, 0x3A, 0xB1, 0x3C, 0x11, - 0x3D, 0x74, 0x3E, 0xDC, 0x40, 0x48, 0x41, 0xB7, 0x43, 0x2B, 0x44, 0xA3, 0x46, 0x1F, 0x47, 0x9F, - 0x49, 0x23, 0x4A, 0xAB, 0x4C, 0x37, 0x4D, 0xC7, 0x4F, 0x5C, 0x50, 0xF4, 0x52, 0x90, 0x54, 0x31, - 0x55, 0xD6, 0x57, 0x7E, 0x59, 0x2B, 0x5A, 0xDC, 0x5C, 0x90, 0x5E, 0x49, 0x60, 0x06, 0x61, 0xC7, - 0x63, 0x8C, 0x65, 0x55, 0x67, 0x22, 0x68, 0xF4, 0x6A, 0xC9, 0x6C, 0xA2, 0x6E, 0x80, 0x70, 0x61, - 0x72, 0x47, 0x74, 0x30, 0x76, 0x1E, 0x78, 0x10, 0x7A, 0x06, 0x7C, 0x00, 0x7D, 0xFE, 0x80, 0x00, +SECTION_DATA static u16 daMP_VolumeTable[] = { + 0x0000, 0x0002, 0x0008, 0x0012, 0x0020, 0x0032, 0x0049, 0x0063, + 0x0082, 0x00A4, 0x00CB, 0x00F5, 0x0124, 0x0157, 0x018E, 0x01C9, + 0x0208, 0x024B, 0x0292, 0x02DD, 0x032C, 0x037F, 0x03D7, 0x0432, + 0x0492, 0x04F5, 0x055D, 0x05C9, 0x0638, 0x06AC, 0x0724, 0x07A0, + 0x0820, 0x08A4, 0x092C, 0x09B8, 0x0A48, 0x0ADD, 0x0B75, 0x0C12, + 0x0CB2, 0x0D57, 0x0DFF, 0x0EAC, 0x0F5D, 0x1012, 0x10CA, 0x1187, + 0x1248, 0x130D, 0x13D7, 0x14A4, 0x1575, 0x164A, 0x1724, 0x1801, + 0x18E3, 0x19C8, 0x1AB2, 0x1BA0, 0x1C91, 0x1D87, 0x1E81, 0x1F7F, + 0x2081, 0x2187, 0x2291, 0x239F, 0x24B2, 0x25C8, 0x26E2, 0x2801, + 0x2923, 0x2A4A, 0x2B75, 0x2CA3, 0x2DD6, 0x2F0D, 0x3048, 0x3187, + 0x32CA, 0x3411, 0x355C, 0x36AB, 0x37FF, 0x3956, 0x3AB1, 0x3C11, + 0x3D74, 0x3EDC, 0x4048, 0x41B7, 0x432B, 0x44A3, 0x461F, 0x479F, + 0x4923, 0x4AAB, 0x4C37, 0x4DC7, 0x4F5C, 0x50F4, 0x5290, 0x5431, + 0x55D6, 0x577E, 0x592B, 0x5ADC, 0x5C90, 0x5E49, 0x6006, 0x61C7, + 0x638C, 0x6555, 0x6722, 0x68F4, 0x6AC9, 0x6CA2, 0x6E80, 0x7061, + 0x7247, 0x7430, 0x761E, 0x7810, 0x7A06, 0x7C00, 0x7DFE, 0x8000, }; /* 80876E0C-80877074 00472C 0268+00 1/1 0/0 0/0 .text daMP_MixAudio__FPsPsUl */ @@ -1005,149 +3127,231 @@ static void daMP_MixAudio(s16* param_0, s16* param_1, u32 param_2) { // NONMATCHING } -/* ############################################################################################## */ -/* 80944870-8094487C 0CB2D0 000C+00 0/0 0/0 0/0 .bss daMP_FreeAudioBufferMessage */ -#pragma push -#pragma force_active on -static u8 daMP_FreeAudioBufferMessage[12]; -#pragma pop - -/* 8094487C-80944888 0CB2DC 000C+00 0/0 0/0 0/0 .bss daMP_DecodedAudioBufferMessage */ -#pragma push -#pragma force_active on -static u8 daMP_DecodedAudioBufferMessage[12]; -#pragma pop - /* 80944888-809448A0 0CB2E8 0004+14 3/3 0/0 0/0 .bss daMP_Initialized */ -static u8 daMP_Initialized[4 + 20 /* padding */]; +static BOOL daMP_Initialized; /* 809448A0-809448E0 0CB300 0040+00 2/2 0/0 0/0 .bss daMP_WorkBuffer */ -static u8 daMP_WorkBuffer[64] ALIGN_DECL(32); +static u8 daMP_WorkBuffer[0x40] ALIGN_DECL(32); /* 809448E0-80944900 0CB340 0020+00 3/3 0/0 0/0 .bss daMP_PrepareReadyQueue */ -static u8 daMP_PrepareReadyQueue[32]; +static OSMessageQueue daMP_PrepareReadyQueue; /* 80944900-80944920 0CB360 0020+00 2/2 0/0 0/0 .bss daMP_UsedTextureSetQueue */ -static u8 daMP_UsedTextureSetQueue[32]; +static OSMessageQueue daMP_UsedTextureSetQueue; /* 80944920-80944924 0CB380 0004+00 1/1 0/0 0/0 .bss daMP_PrepareReadyMessage */ -static u8 daMP_PrepareReadyMessage[4]; +static OSMessage daMP_PrepareReadyMessage; /* 80944924-80944930 0CB384 000C+00 0/0 0/0 0/0 .bss daMP_UsedTextureSetMessage */ -#pragma push -#pragma force_active on -static u8 daMP_UsedTextureSetMessage[12]; -#pragma pop +static OSMessage daMP_UsedTextureSetMessage[3]; /* 80944930-80944934 0CB390 0004+00 3/3 0/0 0/0 .bss daMP_OldVIPostCallback */ -static u8 daMP_OldVIPostCallback[4]; +static VIRetraceCallback daMP_OldVIPostCallback; /* 80944934-80944938 0CB394 0004+00 1/1 0/0 0/0 .bss daMP_SoundBufferIndex */ -static u8 daMP_SoundBufferIndex[4]; +static u32 daMP_SoundBufferIndex; /* 80944938-8094493C 0CB398 0004+00 0/0 0/0 0/0 .bss daMP_OldAIDCallback */ -#pragma push -#pragma force_active on -static u8 daMP_OldAIDCallback[4]; -#pragma pop +static u32 daMP_OldAIDCallback; /* 8094493C-80944940 0CB39C 0004+00 0/0 0/0 0/0 .bss daMP_LastAudioBuffer */ -#pragma push -#pragma force_active on -static u8 daMP_LastAudioBuffer[4]; -#pragma pop +static void* daMP_LastAudioBuffer; /* 80944940-80944944 0CB3A0 0004+00 0/0 0/0 0/0 .bss daMP_CurAudioBuffer */ -#pragma push -#pragma force_active on -static u8 daMP_CurAudioBuffer[4]; -#pragma pop +static void* daMP_CurAudioBuffer; /* 80944944-80944960 0CB3A4 0004+18 0/0 0/0 0/0 .bss daMP_AudioSystem */ -#pragma push -#pragma force_active on -static u8 daMP_AudioSystem[4 + 24 /* padding */]; -#pragma pop +static s32 daMP_AudioSystem; /* 80944960-80945AE0 0CB3C0 1180+00 1/1 0/0 0/0 .bss daMP_SoundBuffer */ -static u8 daMP_SoundBuffer[4480] ALIGN_DECL(32); +static u8 daMP_SoundBuffer[2][0x8C0] ALIGN_DECL(32); /* 80877074-8087712C 004994 00B8+00 1/1 0/0 0/0 .text daMP_audioCallbackWithMSound__Fl */ -static void daMP_audioCallbackWithMSound(s32 param_0) { - // NONMATCHING +static s16* daMP_audioCallbackWithMSound(s32 param_0) { + if (daMP_ActivePlayer.field_0xa0 == 0 || daMP_ActivePlayer.field_0xa5 != 2 || daMP_ActivePlayer.field_0xa7 == 0) { + return NULL; + } + + BOOL intr = OSEnableInterrupts(); + daMP_SoundBufferIndex ^= 1; + daMP_MixAudio((s16*)daMP_SoundBuffer[daMP_SoundBufferIndex], NULL, param_0); + OSRestoreInterrupts(intr); + return (s16*)daMP_SoundBuffer[daMP_SoundBufferIndex]; } /* 8087712C-80877158 004A4C 002C+00 1/1 0/0 0/0 .text daMP_audioInitWithMSound__Fv */ static void daMP_audioInitWithMSound() { - // NONMATCHING + JASDriver::registerMixCallback(daMP_audioCallbackWithMSound, MIX_MODE_INTERLEAVE); } /* 80877158-80877180 004A78 0028+00 2/2 0/0 0/0 .text daMP_audioQuitWithMSound__Fv */ static void daMP_audioQuitWithMSound() { - // NONMATCHING + JASDriver::registerMixCallback(NULL, MIX_MODE_MONO); } /* 80877180-808771B0 004AA0 0030+00 1/1 0/0 0/0 .text daMP_PushUsedTextureSet__FPv */ static void daMP_PushUsedTextureSet(void* param_0) { - // NONMATCHING + OSMessage msg = (OSMessage)param_0; + OSSendMessage(&daMP_UsedTextureSetQueue, msg, OS_MESSAGE_NOBLOCK); } /* 808771B0-808771F4 004AD0 0044+00 2/2 0/0 0/0 .text daMP_PopUsedTextureSet__Fv */ -static void daMP_PopUsedTextureSet() { - // NONMATCHING +static OSMessage daMP_PopUsedTextureSet() { + OSMessage msg; + if (OSReceiveMessage(&daMP_DecodedAudioBufferQueue, &msg, OS_MESSAGE_NOBLOCK) == 1) { + return msg; + } + + return NULL; } /* 808771F4-808772CC 004B14 00D8+00 1/1 0/0 0/0 .text daMP_THPPlayerInit__Fl */ -static void daMP_THPPlayerInit(s32 param_0) { +static int daMP_THPPlayerInit(s32 param_0) { // NONMATCHING + memset(&daMP_ActivePlayer, 0, sizeof(daMP_ActivePlayer)); + LCEnable(); + + OSInitMessageQueue(&daMP_UsedTextureSetQueue, daMP_UsedTextureSetMessage, 3); + + if (!THPInit()) { + return 0; + } + + BOOL enable = OSDisableInterrupts(); + daMP_AudioSystem = param_0; + daMP_SoundBufferIndex = 0; + daMP_LastAudioBuffer = NULL; + daMP_CurAudioBuffer = NULL; + daMP_audioInitWithMSound(); + OSRestoreInterrupts(enable); + + if (daMP_AudioSystem == 0) { + memset(daMP_SoundBuffer, 0, sizeof(daMP_SoundBuffer)); + DCStoreRange(daMP_SoundBuffer, sizeof(daMP_SoundBuffer)); + } + + daMP_Initialized = TRUE; + return 1; } /* 808772CC-8087730C 004BEC 0040+00 1/1 0/0 0/0 .text daMP_THPPlayerQuit__Fv */ static void daMP_THPPlayerQuit() { - // NONMATCHING + LCDisable(); + daMP_audioQuitWithMSound(); + daMP_Initialized = FALSE; + daMP_ActivePlayer.field_0xa8 = 0; + daMP_ActivePlayer.field_0xac = 0; } -/* ############################################################################################## */ -/* 80879118-8087911C 0000E4 0004+00 1/2 0/0 0/0 .rodata @4983 */ -SECTION_RODATA static f32 const lit_4983 = 127.0f; -COMPILER_STRIP_GATE(0x80879118, &lit_4983); - -/* 8087911C-8087911C 0000E8 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ -#pragma push -#pragma force_active on -SECTION_DEAD static char const* const stringBase_8087917A = - "You must call daMP_THPPlayerInit before you call" - " this function\n"; -SECTION_DEAD static char const* const stringBase_808791BA = - "Can't open %s. Because thp file have already ope" - "ned.\n"; -SECTION_DEAD static char const* const stringBase_808791F0 = "Can't open %s.\n"; -SECTION_DEAD static char const* const stringBase_80879200 = - "Fail to read the header from THP file.\n"; -SECTION_DEAD static char const* const stringBase_80879228 = "THP"; -SECTION_DEAD static char const* const stringBase_8087922C = "This file is not THP file.\n"; -SECTION_DEAD static char const* const stringBase_80879248 = "invalid version.\n"; -SECTION_DEAD static char const* const stringBase_8087925A = - "Fail to read the frame component infomation from" - " THP file.\n"; -SECTION_DEAD static char const* const stringBase_80879296 = - "Fail to read the video infomation from THP file." - "\n"; -SECTION_DEAD static char const* const stringBase_808792C8 = "Unknow frame components.\n"; -#pragma pop - /* 8087730C-808776EC 004C2C 03E0+00 1/1 0/0 0/0 .text daMP_THPPlayerOpen__FPCci */ -static void daMP_THPPlayerOpen(char const* param_0, int param_1) { - // NONMATCHING +// NONMATCHING - regalloc, some missing instructions +static BOOL daMP_THPPlayerOpen(char const* filename, int param_1) { + if (!daMP_Initialized) { + OSReport("You must call daMP_THPPlayerInit before you call this function\n"); + return 0; + } + + if (daMP_ActivePlayer.field_0xa0 != 0) { + OSReport("Can't open %s. Because thp file have already opened.\n"); + return 0; + } + + THPVideoInfo* temp_r29 = &daMP_ActivePlayer.mVideoInfo; + memset(temp_r29, 0, sizeof(THPVideoInfo)); + memset(&daMP_ActivePlayer.mAudioInfo, 0, sizeof(THPAudioInfo)); + + if (!DVDOpen(filename, &daMP_ActivePlayer.mFileInfo)) { + OSReport("Can't open %s.\n", filename); + return 0; + } + + if (DVDReadPrio(&daMP_ActivePlayer.mFileInfo, daMP_WorkBuffer, sizeof(daMP_WorkBuffer), 0, 2) < 0) { + OSReport("Fail to read the header from THP file.\n"); + DVDClose(&daMP_ActivePlayer.mFileInfo); + return 0; + } + + char* temp_r23 = (char*)&daMP_ActivePlayer.field_0x3c; + memcpy(temp_r23, daMP_WorkBuffer, 0x30); + + if (strcmp(temp_r23, "THP") != 0) { + OSReport("This file is not THP file.\n"); + DVDClose(&daMP_ActivePlayer.mFileInfo); + return 0; + } + + if (daMP_ActivePlayer.field_0x40 != 0x11000) { + OSReport("invalid version.\n"); + DVDClose(&daMP_ActivePlayer.mFileInfo); + return 0; + } + + s32 var_r26 = daMP_ActivePlayer.field_0x5c; + + if (DVDReadPrio(&daMP_ActivePlayer.mFileInfo, daMP_WorkBuffer, 0x20, var_r26, 2) < 0) { + OSReport("Fail to read the frame component infomation from THP file.\n"); + DVDClose(&daMP_ActivePlayer.mFileInfo); + return 0; + } + + memcpy(&daMP_ActivePlayer.field_0x6c, daMP_WorkBuffer, 0x14); + var_r26 += 0x14; + + daMP_ActivePlayer.field_0xa7 = 0; + + for (int i = 0; i < daMP_ActivePlayer.field_0x6c._0; i++) { + switch (daMP_ActivePlayer.field_0x6c._4) { + case 0: + if (DVDReadPrio(&daMP_ActivePlayer.mFileInfo, daMP_WorkBuffer, 0x20, var_r26, 2) < 0) { + OSReport("Fail to read the video infomation from THP file.\n"); + DVDClose(&daMP_ActivePlayer.mFileInfo); + return 0; + } + + memcpy(temp_r29, daMP_WorkBuffer, sizeof(THPVideoInfo)); + var_r26 += 0xC; + break; + case 1: + if (DVDReadPrio(&daMP_ActivePlayer.mFileInfo, daMP_WorkBuffer, 0x20, var_r26, 2) < 0) { + OSReport("Fail to read the video infomation from THP file.\n"); + DVDClose(&daMP_ActivePlayer.mFileInfo); + return 0; + } + + memcpy(&daMP_ActivePlayer.mAudioInfo, daMP_WorkBuffer, sizeof(THPAudioInfo)); + daMP_ActivePlayer.field_0xa7 = 1; + var_r26 += 0x10; + break; + default: + OSReport("Unknow frame components.\n"); + return 0; + } + } + + daMP_ActivePlayer.field_0xa5 = 0; + daMP_ActivePlayer.mState = 0; + daMP_ActivePlayer.field_0xa6 = 0; + daMP_ActivePlayer.field_0xb0 = param_1; + daMP_ActivePlayer.field_0xa0 = 1; + daMP_ActivePlayer.field_0xdc = 127.0f; + daMP_ActivePlayer.field_0xe0 = 127.0f; + daMP_ActivePlayer.field_0xe8 = 0; + return 1; } /* 808776EC-80877740 00500C 0054+00 2/2 0/0 0/0 .text daMP_THPPlayerClose__Fv */ -static void daMP_THPPlayerClose() { - // NONMATCHING +static int daMP_THPPlayerClose() { + if (daMP_ActivePlayer.field_0xa0 != 0 && daMP_ActivePlayer.mState == 0) { + daMP_ActivePlayer.field_0xa0 = 0; + DVDClose(&daMP_ActivePlayer.mFileInfo); + return 1; + } + + return 0; } /* 80877740-808777F0 005060 00B0+00 1/1 0/0 0/0 .text daMP_THPPlayerCalcNeedMemory__Fv */ -static void daMP_THPPlayerCalcNeedMemory() { +static u32 daMP_THPPlayerCalcNeedMemory() { // NONMATCHING } @@ -1177,16 +3381,19 @@ static void daMP_PlayControl(u32 param_0) { } /* 80877F48-80877F88 005868 0040+00 1/1 0/0 0/0 .text daMP_WaitUntilPrepare__Fv */ -static void daMP_WaitUntilPrepare() { - // NONMATCHING +s32 daMP_WaitUntilPrepare() { + OSMessage msg; + OSReceiveMessage(&daMP_PrepareReadyQueue, &msg, 1); + u32 temp = (s32)msg; + return (-temp | temp) >> 31; // fakematch? should be temp != 0; } /* 80877F88-80877FB8 0058A8 0030+00 2/2 0/0 0/0 .text daMP_PrepareReady__Fi */ -static void daMP_PrepareReady(int param_0) { - // NONMATCHING +void daMP_PrepareReady(int r3) { + OSMessage msg = (OSMessage)r3; + OSSendMessage(&daMP_PrepareReadyQueue, msg, 1); } -/* ############################################################################################## */ /* 8087911C-8087911C 0000E8 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ #pragma push #pragma force_active on @@ -1204,69 +3411,117 @@ SECTION_DEAD static char const* const stringBase_80879397 = #pragma pop /* 80877FB8-808782A0 0058D8 02E8+00 1/1 0/0 0/0 .text daMP_THPPlayerPrepare__Flll */ -static void daMP_THPPlayerPrepare(s32 param_0, s32 param_1, s32 param_2) { +static BOOL daMP_THPPlayerPrepare(s32 param_0, s32 param_1, s32 param_2) { // NONMATCHING } /* 808782A0-808782E4 005BC0 0044+00 1/1 0/0 0/0 .text daMP_THPPlayerDrawDone__Fv */ static void daMP_THPPlayerDrawDone() { - // NONMATCHING + GXDrawDone(); + + if (daMP_Initialized) { + while (1) { + void* temp_r3 = daMP_PopUsedTextureSet(); + if (temp_r3 == NULL) { + break; + } + daMP_PushFreeTextureSet(temp_r3); + } + } } /* 808782E4-80878344 005C04 0060+00 1/1 0/0 0/0 .text daMP_THPPlayerPlay__Fv */ -static void daMP_THPPlayerPlay() { - // NONMATCHING +static int daMP_THPPlayerPlay() { + if (daMP_ActivePlayer.field_0xa0 != 0 && (daMP_ActivePlayer.mState == 1 || daMP_ActivePlayer.mState == 4)) { + daMP_ActivePlayer.mState = 2; + daMP_ActivePlayer.field_0xd0 = 0; + daMP_ActivePlayer.field_0xd4 = 0; + daMP_ActivePlayer.field_0xc8 = -1; + return 1; + } + + return 0; } /* 80878344-808783FC 005C64 00B8+00 3/3 0/0 0/0 .text daMP_THPPlayerStop__Fv */ static void daMP_THPPlayerStop() { - // NONMATCHING + if (daMP_ActivePlayer.field_0xa0 != 0 && daMP_ActivePlayer.mState != 0) { + daMP_ActivePlayer.field_0xa5 = 0; + daMP_ActivePlayer.mState = 0; + + VISetPostRetraceCallback(daMP_OldVIPostCallback); + + if (daMP_ActivePlayer.field_0xb0 == 0) { + DVDCancel(&daMP_ActivePlayer.mFileInfo.block); + daMP_ReadThreadCancel(); + } + + daMP_VideoDecodeThreadCancel(); + + if (daMP_ActivePlayer.field_0xa7 != 0) { + daMP_AudioDecodeThreadCancel(); + daMP_audioQuitWithMSound(); + } + + while (daMP_PopUsedTextureSet() != NULL) {} + + daMP_ActivePlayer.field_0xdc = daMP_ActivePlayer.field_0xe0; + daMP_ActivePlayer.field_0xe8 = 0.0f; + } } /* 808783FC-80878438 005D1C 003C+00 1/1 0/0 0/0 .text daMP_THPPlayerPause__Fv */ -static void daMP_THPPlayerPause() { - // NONMATCHING +static int daMP_THPPlayerPause() { + if (daMP_ActivePlayer.field_0xa0 != 0 && daMP_ActivePlayer.mState == 2) { + daMP_ActivePlayer.field_0xa5 = 4; + daMP_ActivePlayer.mState = 4; + return 1; + } + + return 0; } /* 80878438-80878534 005D58 00FC+00 1/1 0/0 0/0 .text * daMP_THPPlayerDrawCurrentFrame__FPC16_GXRenderModeObjUlUlUlUl */ -static void daMP_THPPlayerDrawCurrentFrame(_GXRenderModeObj const* param_0, u32 param_1, +static int daMP_THPPlayerDrawCurrentFrame(_GXRenderModeObj const* param_0, u32 param_1, u32 param_2, u32 param_3, u32 param_4) { // NONMATCHING } -/* 80878534-80878558 005E54 0024+00 1/1 0/0 0/0 .text fadeIn__13mDoGph_gInf_cFf */ -// void mDoGph_gInf_c::fadeIn(f32 param_0) { -extern "C" void fadeIn__13mDoGph_gInf_cFf() { - // NONMATCHING -} - -/* 80878558-80878568 005E78 0010+00 1/1 0/0 0/0 .text isFade__13mDoGph_gInf_cFv */ -// void mDoGph_gInf_c::isFade() { -extern "C" void isFade__13mDoGph_gInf_cFv() { - // NONMATCHING -} - /* 80878568-808785B0 005E88 0048+00 1/1 0/0 0/0 .text daMP_THPPlayerGetVideoInfo__FP12THPVideoInfo */ -static void daMP_THPPlayerGetVideoInfo(THPVideoInfo* param_0) { - // NONMATCHING +static int daMP_THPPlayerGetVideoInfo(THPVideoInfo* info) { + if (daMP_ActivePlayer.field_0xa0 != 0) { + memcpy(info, &daMP_ActivePlayer.mVideoInfo, sizeof(THPVideoInfo)); + return 1; + } + + return 0; } /* 808785B0-808785F8 005ED0 0048+00 1/1 0/0 0/0 .text daMP_THPPlayerGetAudioInfo__FP12THPAudioInfo */ -static void daMP_THPPlayerGetAudioInfo(THPAudioInfo* param_0) { - // NONMATCHING +static int daMP_THPPlayerGetAudioInfo(THPAudioInfo* info) { + if (daMP_ActivePlayer.field_0xa0 != 0) { + memcpy(info, &daMP_ActivePlayer.mAudioInfo, sizeof(THPAudioInfo)); + return 1; + } + + return 0; } /* 808785F8-8087861C 005F18 0024+00 2/2 0/0 0/0 .text daMP_THPPlayerGetTotalFrame__Fv */ -static void daMP_THPPlayerGetTotalFrame() { - // NONMATCHING +static u32 daMP_THPPlayerGetTotalFrame() { + if (daMP_ActivePlayer.field_0xa0 != 0) { + return daMP_ActivePlayer.mTotalFrames; + } + + return 0; } /* 8087861C-8087862C 005F3C 0010+00 2/2 0/0 0/0 .text daMP_THPPlayerGetState__Fv */ -static void daMP_THPPlayerGetState() { - // NONMATCHING +static int daMP_THPPlayerGetState() { + return daMP_ActivePlayer.mState; } /* 8087862C-80878758 005F4C 012C+00 1/1 0/0 0/0 .text daMP_THPPlayerSetVolume__Fll */ @@ -1274,255 +3529,233 @@ static void daMP_THPPlayerSetVolume(s32 param_0, s32 param_1) { // NONMATCHING } -/* ############################################################################################## */ -/* 8087911C-8087911C 0000E8 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ -#pragma push -#pragma force_active on -SECTION_DEAD static char const* const stringBase_808793C2 = "Fail to open the thp file\n"; -SECTION_DEAD static char const* const stringBase_808793DD = "Can't allocate the memory"; -SECTION_DEAD static char const* const stringBase_808793F7 = "Fail to prepare\n"; -#pragma pop - -/* 80878758-808788BC 006078 0164+00 1/1 0/0 0/0 .text daMP_ActivePlayer_Init__FPCc */ -static void daMP_ActivePlayer_Init(char const* param_0) { - // NONMATCHING -} - -/* 808788BC-808788C4 0061DC 0008+00 2/2 0/0 0/0 .text getRenderMode__8JUTVideoCFv */ -// void JUTVideo::getRenderMode() const { -extern "C" void getRenderMode__8JUTVideoCFv() { - // NONMATCHING -} - -/* 808788C4-808788D4 0061E4 0010+00 2/2 0/0 0/0 .text getManager__8JUTVideoFv */ -// void JUTVideo::getManager() { -extern "C" void getManager__8JUTVideoFv() { - // NONMATCHING -} - -/* ############################################################################################## */ /* 80945AE0-80945AEC 0CC540 000C+00 1/1 0/0 0/0 .bss daMP_videoInfo */ -static u8 daMP_videoInfo[12]; +static THPVideoInfo daMP_videoInfo; /* 80945AEC-80945AFC 0CC54C 0010+00 0/0 0/0 0/0 .bss daMP_audioInfo */ -#pragma push -#pragma force_active on -static u8 daMP_audioInfo[16]; -#pragma pop +static THPAudioInfo daMP_audioInfo; /* 80945AFC-80945B00 0CC55C 0004+00 1/1 0/0 0/0 .bss daMP_DrawPosX */ -static u8 daMP_DrawPosX[4]; +static u32 daMP_DrawPosX; /* 80945B00-80945B04 0CC560 0004+00 1/1 0/0 0/0 .bss daMP_DrawPosY */ -static u8 daMP_DrawPosY[4]; +static u32 daMP_DrawPosY; /* 80945B04-80945B08 0CC564 0004+00 2/2 0/0 0/0 .bss daMP_buffer */ -static u8 daMP_buffer[4]; +static void* daMP_buffer; + +/* 80878758-808788BC 006078 0164+00 1/1 0/0 0/0 .text daMP_ActivePlayer_Init__FPCc */ +static BOOL daMP_ActivePlayer_Init(char const* moviePath) { + daMP_THPPlayerInit(0); + + if (!daMP_THPPlayerOpen(moviePath, 0)) { + OSReport("Fail to open the thp file\n"); + JUT_ASSERT(0); + return 0; + } + + daMP_THPPlayerGetVideoInfo(&daMP_videoInfo); + daMP_THPPlayerGetAudioInfo(&daMP_audioInfo); + + u16 var_r31 = JUTVideo::getManager()->getRenderMode()->fb_width; + u16 temp_r4 = JUTVideo::getManager()->getRenderMode()->efb_height; + + daMP_DrawPosX = (var_r31 - daMP_videoInfo.field_0x0) >> 1; + daMP_DrawPosY = (temp_r4 - daMP_videoInfo.field_0x4) >> 1; + + // "The memory needed for this THP movie is %d bytes\n" + OS_REPORT("このTHPムービーが必要なメモリは%dバイトです\n", daMP_THPPlayerCalcNeedMemory()); + + daMP_buffer = mDoExt_getArchiveHeap()->alloc(daMP_THPPlayerCalcNeedMemory(), 0x20); + if (daMP_buffer == NULL) { + OSReport("Can't allocate the memory"); + JUT_ASSERT(0); + return 0; + } + + daMP_THPPlayerSetBuffer((u8*)daMP_buffer); + + if (!daMP_THPPlayerPrepare(0, 0, daMP_audioInfo.field_0xc != 1 ? OSGetTick() % daMP_audioInfo.field_0xc : 0)) { + OSReport("Fail to prepare\n"); + JUT_ASSERT(0); + return 0; + } + + return 1; +} /* 808788D4-80878914 0061F4 0040+00 1/1 0/0 0/0 .text daMP_ActivePlayer_Finish__Fv */ static void daMP_ActivePlayer_Finish() { - // NONMATCHING -} + daMP_THPPlayerStop(); + daMP_THPPlayerClose(); + daMP_THPPlayerQuit(); -/* 80878914-80878938 006234 0024+00 2/2 0/0 0/0 .text JKRFree__FPv */ -extern "C" void JKRFree__FPv() { - // NONMATCHING + if (daMP_buffer != NULL) { + JKRFree(daMP_buffer); + } } -/* ############################################################################################## */ -/* 8087911C-8087911C 0000E8 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ -#pragma push -#pragma force_active on -SECTION_DEAD static char const* const stringBase_80879408 = "Error happen"; -#pragma pop - /* 80878938-80878994 006258 005C+00 1/1 0/0 0/0 .text daMP_ActivePlayer_Main__Fv */ static void daMP_ActivePlayer_Main() { - // NONMATCHING + if (daMP_THPPlayerGetState() == 5) { + daMP_THPPlayerStop(); + daMP_THPPlayerClose(); + + if (daMP_buffer != NULL) { + JKRFree(daMP_buffer); + } + + OSReport("Error happen"); + } } /* 80878994-80878A34 0062B4 00A0+00 1/1 0/0 0/0 .text daMP_ActivePlayer_Draw__Fv */ static void daMP_ActivePlayer_Draw() { - // NONMATCHING -} + int var_r31 = daMP_THPPlayerDrawCurrentFrame(JUTVideo::getManager()->getRenderMode(), daMP_DrawPosX, daMP_DrawPosY, daMP_videoInfo.field_0x0, daMP_videoInfo.field_0x4); + daMP_THPPlayerDrawDone(); -/* 80878A34-80878A64 006354 0030+00 1/1 0/0 0/0 .text dComIfGp_event_reset__Fv */ -static void dComIfGp_event_reset() { - // NONMATCHING -} - -/* 80878A64-80878A6C 006384 0008+00 1/1 0/0 0/0 .text getEvent__14dComIfG_play_cFv */ -// void dComIfG_play_c::getEvent() { -extern "C" void getEvent__14dComIfG_play_cFv() { - // NONMATCHING + if (!fopOvlpM_IsPeek() && var_r31 > 0 && (cAPICPad_ANY_BUTTON(0) || !daMP_c::daMP_c_Get_MovieRestFrame())) { + dComIfGp_event_reset(); + daMP_c::daMP_c_Set_PercentMovieVolume(0.0f); + } } -/* ############################################################################################## */ /* 80945B08-80945B0C 0CC568 0004+00 5/5 0/0 0/0 .bss daMP_Fail_alloc */ -static u8 daMP_Fail_alloc[4]; +static BOOL daMP_Fail_alloc; /* 80878A6C-80878B38 00638C 00CC+00 1/1 0/0 0/0 .text daMP_Get_MovieRestFrame__Fv */ -static void daMP_Get_MovieRestFrame() { +static u32 daMP_Get_MovieRestFrame() { // NONMATCHING + return 0; } /* 80878B38-80878BB8 006458 0080+00 1/1 0/0 0/0 .text daMP_Set_PercentMovieVolume__Ff */ static void daMP_Set_PercentMovieVolume(f32 param_0) { - // NONMATCHING -} + if (!daMP_Fail_alloc) { + s32 var_r3; + if (param_0 >= 1.0f) { + var_r3 = 127; + } else if (param_0 <= 0.0f) { + var_r3 = 0; + } else { + var_r3 = param_0 / 127.0f; + } -/* 80878BB8-80878BDC 0064D8 0024+00 1/1 0/0 0/0 .text daMP_c_Get_arg_demoNo__6daMP_cFv */ -void daMP_c::daMP_c_Get_arg_demoNo() { - // NONMATCHING -} - -/* 80878BDC-80878BFC 0064FC 0020+00 2/2 0/0 0/0 .text fopAcM_GetParam__FPCv */ -static void fopAcM_GetParam(void const* param_0) { - // NONMATCHING + daMP_THPPlayerSetVolume(var_r3, 1000); + } } -/* 80878BFC-80878C04 00651C 0008+00 1/1 0/0 0/0 .text fpcM_GetParam__FPCv */ -static void fpcM_GetParam(void const* param_0) { - // NONMATCHING +/* 80878BB8-80878BDC 0064D8 0024+00 1/1 0/0 0/0 .text daMP_c_Get_arg_demoNo__6daMP_cFv */ +int daMP_c::daMP_c_Get_arg_demoNo() { + return (fopAcM_GetParam(this) >> 7) & 0x7F; } /* 80878C04-80878C28 006524 0024+00 1/1 0/0 0/0 .text daMP_c_Get_arg_movieNo__6daMP_cFv */ -void daMP_c::daMP_c_Get_arg_movieNo() { - // NONMATCHING +int daMP_c::daMP_c_Get_arg_movieNo() { + return fopAcM_GetParam(this) & 0x7F; } -/* ############################################################################################## */ -/* 8087911C-8087911C 0000E8 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ -#pragma push -#pragma force_active on -SECTION_DEAD static char const* const stringBase_80879415 = "/Movie/demo_movie%02d_%02d.thp"; -#pragma pop - /* 80878C28-80878D10 006548 00E8+00 1/1 0/0 0/0 .text daMP_c_Init__6daMP_cFv */ -void daMP_c::daMP_c_Init() { - // NONMATCHING -} +int daMP_c::daMP_c_Init() { + JUT_ASSERT(9469, m_myObj == 0); -/* 80878D10-80878D44 006630 0034+00 1/1 0/0 0/0 .text setFrameRate__13mDoGph_gInf_cFUs */ -// void mDoGph_gInf_c::setFrameRate(u16 param_0) { -extern "C" void setFrameRate__13mDoGph_gInf_cFUs() { - // NONMATCHING -} + mDoGph_gInf_c::setFrameRate(1); + daMP_Fail_alloc = FALSE; -/* 80878D44-80878D54 006664 0010+00 1/1 0/0 0/0 .text setFrameRate__10JFWDisplayFUs */ -// void JFWDisplay::setFrameRate(u16 param_0) { -extern "C" void setFrameRate__10JFWDisplayFUs() { - // NONMATCHING -} + int demoNo = daMP_c_Get_arg_demoNo(); + JUT_ASSERT(9505, 0 <= demoNo && demoNo <= 99); -/* 80878D54-80878D64 006674 0010+00 1/1 0/0 0/0 .text getManager__10JFWDisplayFv */ -// void JFWDisplay::getManager() { -extern "C" void getManager__10JFWDisplayFv() { - // NONMATCHING + int movieNo = daMP_c_Get_arg_movieNo(); + JUT_ASSERT(9507, 0 <= movieNo && movieNo <= 99); + + char path[32]; + sprintf(path, "/Movie/demo_movie%02d_%02d.thp", demoNo, movieNo); + + if (!daMP_ActivePlayer_Init(path)) { + daMP_Fail_alloc = TRUE; + } + + mpGetMovieRestFrame = daMP_Get_MovieRestFrame; + mpSetPercentMovieVol = daMP_Set_PercentMovieVolume; + mpTHPGetTotalFrame = daMP_THPPlayerGetTotalFrame; + mpTHPPlay = daMP_THPPlayerPlay; + mpTHPStop = daMP_THPPlayerStop; + mpTHPPause = daMP_THPPlayerPause; + + m_myObj = this; + return cPhs_COMPLEATE_e; } /* 80878D64-80878D94 006684 0030+00 1/1 0/0 0/0 .text daMP_c_Finish__6daMP_cFv */ -void daMP_c::daMP_c_Finish() { - // NONMATCHING +int daMP_c::daMP_c_Finish() { + daMP_ActivePlayer_Finish(); + m_myObj = NULL; + return 1; } /* 80878D94-80878DB8 0066B4 0024+00 1/1 0/0 0/0 .text daMP_c_Main__6daMP_cFv */ -void daMP_c::daMP_c_Main() { - // NONMATCHING +int daMP_c::daMP_c_Main() { + daMP_ActivePlayer_Main(); + return 1; } /* 80878DB8-80878DD8 0066D8 0020+00 1/0 0/0 0/0 .text draw__16daMP_Dlst_base_cFv */ void daMP_Dlst_base_c::draw() { - // NONMATCHING + daMP_ActivePlayer_Draw(); } -/* ############################################################################################## */ /* 80945B0C-80945B10 0CC56C 0004+00 2/2 0/0 0/0 .bss daMP_c_Dlst_base */ -static u8 daMP_c_Dlst_base[4]; +static daMP_Dlst_base_c daMP_c_Dlst_base; /* 80878DD8-80878E04 0066F8 002C+00 1/1 0/0 0/0 .text daMP_c_Draw__6daMP_cFv */ -void daMP_c::daMP_c_Draw() { - // NONMATCHING -} - -/* 80878E04-80878E34 006724 0030+00 1/1 0/0 0/0 .text dComIfGd_set2DOpa__FP12dDlst_base_c - */ -// static void dComIfGd_set2DOpa(dDlst_base_c* param_0) { -extern "C" static asm void dComIfGd_set2DOpa__FP12dDlst_base_c() { - // NONMATCHING -} - -/* 80878E34-80878E60 006754 002C+00 1/1 0/0 0/0 .text set2DOpa__12dDlst_list_cFP12dDlst_base_c */ -// void dDlst_list_c::set2DOpa(dDlst_base_c* param_0) { -extern "C" void set2DOpa__12dDlst_list_cFP12dDlst_base_c() { - // NONMATCHING +int daMP_c::daMP_c_Draw() { + dComIfGd_set2DOpa(&daMP_c_Dlst_base); + return 1; } /* 80878E60-80878EC4 006780 0064+00 1/0 0/0 0/0 .text daMP_c_Callback_Init__6daMP_cFP10fopAc_ac_c */ -void daMP_c::daMP_c_Callback_Init(fopAc_ac_c* param_0) { - // NONMATCHING -} - -/* 80878EC4-80878ED4 0067E4 0010+00 1/1 0/0 0/0 .text fopAcM_OnCondition__FP10fopAc_ac_cUl */ -static void fopAcM_OnCondition(fopAc_ac_c* param_0, u32 param_1) { - // NONMATCHING -} - -/* 80878ED4-80878F04 0067F4 0030+00 1/1 0/0 0/0 .text __ct__6daMP_cFv */ -daMP_c::daMP_c() { - // NONMATCHING -} - -/* 80878F04-80878F0C 006824 0008+00 1/1 0/0 0/0 .text __nw__FUlPv */ -extern "C" static void* __nw__FUlPv() { - // NONMATCHING -} - -/* 80878F0C-80878F18 00682C 000C+00 1/1 0/0 0/0 .text fopAcM_CheckCondition__FP10fopAc_ac_cUl */ -static void fopAcM_CheckCondition(fopAc_ac_c* param_0, u32 param_1) { - // NONMATCHING +int daMP_c::daMP_c_Callback_Init(fopAc_ac_c* i_this) { + fopAcM_SetupActor(i_this, daMP_c); + return ((daMP_c*)i_this)->daMP_c_Init(); } /* 80878F18-80878F38 006838 0020+00 1/0 0/0 0/0 .text daMP_c_Callback_Finish__6daMP_cFP6daMP_c */ -void daMP_c::daMP_c_Callback_Finish(daMP_c* param_0) { - // NONMATCHING +int daMP_c::daMP_c_Callback_Finish(daMP_c* i_this) { + return i_this->daMP_c_Finish(); } /* 80878F38-80878F70 006858 0038+00 1/0 0/0 0/0 .text daMP_c_Callback_Main__6daMP_cFP6daMP_c */ -void daMP_c::daMP_c_Callback_Main(daMP_c* param_0) { - // NONMATCHING +int daMP_c::daMP_c_Callback_Main(daMP_c* i_this) { + if (daMP_Fail_alloc) { + return 1; + } + + return i_this->daMP_c_Main(); } /* 80878F70-80878FA8 006890 0038+00 1/0 0/0 0/0 .text daMP_c_Callback_Draw__6daMP_cFP6daMP_c */ -void daMP_c::daMP_c_Callback_Draw(daMP_c* param_0) { - // NONMATCHING -} +int daMP_c::daMP_c_Callback_Draw(daMP_c* i_this) { + if (daMP_Fail_alloc) { + return 1; + } -/* 80878FA8-80878FB0 0068C8 0008+00 1/0 0/0 0/0 .text daMP_Callback_Dummy__FP6daMP_c */ -static bool daMP_Callback_Dummy(daMP_c* param_0) { - return true; + return i_this->daMP_c_Draw(); } -/* 80878FB0-80878FD8 0068D0 0028+00 0/0 1/0 0/0 .text __sinit_d_a_movie_player_cpp */ -void __sinit_d_a_movie_player_cpp() { - // NONMATCHING +/* 80878FA8-80878FB0 0068C8 0008+00 1/0 0/0 0/0 .text daMP_Callback_Dummy__FP6daMP_c */ +static int daMP_Callback_Dummy(daMP_c* i_this) { + return 1; } -#pragma push -#pragma force_active on -REGISTER_CTORS(0x80878FB0, __sinit_d_a_movie_player_cpp); -#pragma pop - -/* ############################################################################################## */ /* 80879534-80879554 -00001 0020+00 1/0 0/0 0/0 .data daMP_METHODS */ static actor_method_class daMP_METHODS = { - (process_method_func)daMP_c_Callback_Init__6daMP_cFP10fopAc_ac_c, - (process_method_func)daMP_c_Callback_Finish__6daMP_cFP6daMP_c, - (process_method_func)daMP_c_Callback_Main__6daMP_cFP6daMP_c, - (process_method_func)daMP_Callback_Dummy__FP6daMP_c, - (process_method_func)daMP_c_Callback_Draw__6daMP_cFP6daMP_c, + (process_method_func)daMP_c::daMP_c_Callback_Init, + (process_method_func)daMP_c::daMP_c_Callback_Finish, + (process_method_func)daMP_c::daMP_c_Callback_Main, + (process_method_func)daMP_Callback_Dummy, + (process_method_func)daMP_c::daMP_c_Callback_Draw, }; /* 80879554-80879584 -00001 0030+00 0/0 0/0 1/0 .data g_profile_MOVIE_PLAYER */ @@ -1543,208 +3776,4 @@ extern actor_process_profile_definition g_profile_MOVIE_PLAYER = { fopAc_CULLBOX_CUSTOM_e, // cullType }; -/* 80879584-80879590 000150 000C+00 1/1 0/0 0/0 .data __vt__16daMP_Dlst_base_c */ -SECTION_DATA extern void* __vt__16daMP_Dlst_base_c[3] = { - (void*)NULL /* RTTI */, - (void*)NULL, - (void*)draw__16daMP_Dlst_base_cFv, -}; - -/* 80878FD8-80879014 0068F8 003C+00 1/1 0/0 0/0 .text __ct__16daMP_Dlst_base_cFv */ -daMP_Dlst_base_c::daMP_Dlst_base_c() { - // NONMATCHING -} - -/* ############################################################################################## */ -/* 80879590-8087959C 00015C 000C+00 1/1 0/0 0/0 .data __vt__12dDlst_base_c */ -SECTION_DATA extern void* __vt__12dDlst_base_c[3] = { - (void*)NULL /* RTTI */, - (void*)NULL, - (void*)draw__12dDlst_base_cFv, -}; - -/* 80879014-80879024 006934 0010+00 1/1 0/0 0/0 .text __ct__12dDlst_base_cFv */ -// dDlst_base_c::dDlst_base_c() { -extern "C" void __ct__12dDlst_base_cFv() { - // NONMATCHING -} - -/* 80879024-80879028 006944 0004+00 1/0 0/0 0/0 .text draw__12dDlst_base_cFv */ -// void dDlst_base_c::draw() { -extern "C" void draw__12dDlst_base_cFv() { - /* empty function */ -} - -/* ############################################################################################## */ -/* 80945B10-80945B14 0CC570 0004+00 0/0 0/0 0/0 .bss - * sInstance__40JASGlobalInstance<19JASDefaultBankTable> */ -#pragma push -#pragma force_active on -static u8 data_80945B10[4]; -#pragma pop - -/* 80945B14-80945B18 0CC574 0004+00 0/0 0/0 0/0 .bss - * sInstance__35JASGlobalInstance<14JASAudioThread> */ -#pragma push -#pragma force_active on -static u8 data_80945B14[4]; -#pragma pop - -/* 80945B18-80945B1C 0CC578 0004+00 0/0 0/0 0/0 .bss sInstance__27JASGlobalInstance<7Z2SeMgr> */ -#pragma push -#pragma force_active on -static u8 data_80945B18[4]; -#pragma pop - -/* 80945B1C-80945B20 0CC57C 0004+00 0/0 0/0 0/0 .bss sInstance__28JASGlobalInstance<8Z2SeqMgr> */ -#pragma push -#pragma force_active on -static u8 data_80945B1C[4]; -#pragma pop - -/* 80945B20-80945B24 0CC580 0004+00 0/0 0/0 0/0 .bss sInstance__31JASGlobalInstance<10Z2SceneMgr> - */ -#pragma push -#pragma force_active on -static u8 data_80945B20[4]; -#pragma pop - -/* 80945B24-80945B28 0CC584 0004+00 0/0 0/0 0/0 .bss sInstance__32JASGlobalInstance<11Z2StatusMgr> - */ -#pragma push -#pragma force_active on -static u8 data_80945B24[4]; -#pragma pop - -/* 80945B28-80945B2C 0CC588 0004+00 0/0 0/0 0/0 .bss sInstance__31JASGlobalInstance<10Z2DebugSys> - */ -#pragma push -#pragma force_active on -static u8 data_80945B28[4]; -#pragma pop - -/* 80945B2C-80945B30 0CC58C 0004+00 0/0 0/0 0/0 .bss - * sInstance__36JASGlobalInstance<15JAISoundStarter> */ -#pragma push -#pragma force_active on -static u8 data_80945B2C[4]; -#pragma pop - -/* 80945B30-80945B34 0CC590 0004+00 0/0 0/0 0/0 .bss - * sInstance__35JASGlobalInstance<14Z2SoundStarter> */ -#pragma push -#pragma force_active on -static u8 data_80945B30[4]; -#pragma pop - -/* 80945B34-80945B38 0CC594 0004+00 0/0 0/0 0/0 .bss - * sInstance__33JASGlobalInstance<12Z2SpeechMgr2> */ -#pragma push -#pragma force_active on -static u8 data_80945B34[4]; -#pragma pop - -/* 80945B38-80945B3C 0CC598 0004+00 0/0 0/0 0/0 .bss sInstance__28JASGlobalInstance<8JAISeMgr> */ -#pragma push -#pragma force_active on -static u8 data_80945B38[4]; -#pragma pop - -/* 80945B3C-80945B40 0CC59C 0004+00 0/0 0/0 0/0 .bss sInstance__29JASGlobalInstance<9JAISeqMgr> */ -#pragma push -#pragma force_active on -static u8 data_80945B3C[4]; -#pragma pop - -/* 80945B40-80945B44 0CC5A0 0004+00 0/0 0/0 0/0 .bss - * sInstance__33JASGlobalInstance<12JAIStreamMgr> */ -#pragma push -#pragma force_active on -static u8 data_80945B40[4]; -#pragma pop - -/* 80945B44-80945B48 0CC5A4 0004+00 0/0 0/0 0/0 .bss sInstance__31JASGlobalInstance<10Z2SoundMgr> - */ -#pragma push -#pragma force_active on -static u8 data_80945B44[4]; -#pragma pop - -/* 80945B48-80945B4C 0CC5A8 0004+00 0/0 0/0 0/0 .bss - * sInstance__33JASGlobalInstance<12JAISoundInfo> */ -#pragma push -#pragma force_active on -static u8 data_80945B48[4]; -#pragma pop - -/* 80945B4C-80945B50 0CC5AC 0004+00 0/0 0/0 0/0 .bss - * sInstance__34JASGlobalInstance<13JAUSoundTable> */ -#pragma push -#pragma force_active on -static u8 data_80945B4C[4]; -#pragma pop - -/* 80945B50-80945B54 0CC5B0 0004+00 0/0 0/0 0/0 .bss - * sInstance__38JASGlobalInstance<17JAUSoundNameTable> */ -#pragma push -#pragma force_active on -static u8 data_80945B50[4]; -#pragma pop - -/* 80945B54-80945B58 0CC5B4 0004+00 0/0 0/0 0/0 .bss - * sInstance__33JASGlobalInstance<12JAUSoundInfo> */ -#pragma push -#pragma force_active on -static u8 data_80945B54[4]; -#pragma pop - -/* 80945B58-80945B5C 0CC5B8 0004+00 0/0 0/0 0/0 .bss sInstance__32JASGlobalInstance<11Z2SoundInfo> - */ -#pragma push -#pragma force_active on -static u8 data_80945B58[4]; -#pragma pop - -/* 80945B5C-80945B60 0CC5BC 0004+00 0/0 0/0 0/0 .bss - * sInstance__34JASGlobalInstance<13Z2SoundObjMgr> */ -#pragma push -#pragma force_active on -static u8 data_80945B5C[4]; -#pragma pop - -/* 80945B60-80945B64 0CC5C0 0004+00 0/0 0/0 0/0 .bss sInstance__31JASGlobalInstance<10Z2Audience> - */ -#pragma push -#pragma force_active on -static u8 data_80945B60[4]; -#pragma pop - -/* 80945B64-80945B68 0CC5C4 0004+00 0/0 0/0 0/0 .bss sInstance__32JASGlobalInstance<11Z2FxLineMgr> - */ -#pragma push -#pragma force_active on -static u8 data_80945B64[4]; -#pragma pop - -/* 80945B68-80945B6C 0CC5C8 0004+00 0/0 0/0 0/0 .bss sInstance__31JASGlobalInstance<10Z2EnvSeMgr> - */ -#pragma push -#pragma force_active on -static u8 data_80945B68[4]; -#pragma pop - -/* 80945B6C-80945B70 0CC5CC 0004+00 0/0 0/0 0/0 .bss sInstance__32JASGlobalInstance<11Z2SpeechMgr> - */ -#pragma push -#pragma force_active on -static u8 data_80945B6C[4]; -#pragma pop - -/* 80945B70-80945B74 0CC5D0 0004+00 0/0 0/0 0/0 .bss - * sInstance__34JASGlobalInstance<13Z2WolfHowlMgr> */ -#pragma push -#pragma force_active on -static u8 data_80945B70[4]; -#pragma pop - -/* 8087911C-8087911C 0000E8 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ \ No newline at end of file +AUDIO_INSTANCES; diff --git a/src/d/d_com_static.cpp b/src/d/d_com_static.cpp index eb008e3f8e6..3c6c69b7036 100644 --- a/src/d/d_com_static.cpp +++ b/src/d/d_com_static.cpp @@ -420,7 +420,7 @@ void daGrass_c::deleteRoomFlower(int param_0) { daMP_c* daMP_c::m_myObj; /* 80031A78-80031AA4 02C3B8 002C+00 0/0 0/0 1/1 .text daMP_c_Get_MovieRestFrame__6daMP_cFv */ -int daMP_c::daMP_c_Get_MovieRestFrame() { +u32 daMP_c::daMP_c_Get_MovieRestFrame() { return m_myObj->mpGetMovieRestFrame(); } diff --git a/src/d/d_item.cpp b/src/d/d_item.cpp index 1f2c93b6efd..7df1ea0a1a9 100644 --- a/src/d/d_item.cpp +++ b/src/d/d_item.cpp @@ -2048,8 +2048,8 @@ BOOL isHeart(u8 i_itemNo) { return is_heart; } -bool isInsect(u8 i_itemNo) { - bool is_insect = false; +BOOL isInsect(u8 i_itemNo) { + BOOL is_insect = false; switch (i_itemNo) { case M_BEETLE: @@ -2189,4 +2189,4 @@ int addBombCount(u8 i_bombType, u8 i_addNum) { } /* 80450F90-80450F98 000490 0004+04 0/0 2/2 0/0 .sbss mData__12dEnemyItem_c */ -u8* dEnemyItem_c::mData; \ No newline at end of file +u8* dEnemyItem_c::mData;