From b3a328747535601f473c0fe2fdc2fcfec32b8eaf Mon Sep 17 00:00:00 2001 From: TakaRikka <38417346+TakaRikka@users.noreply.github.com> Date: Tue, 18 Nov 2025 01:34:34 -0800 Subject: [PATCH] npc_gnd finished, movie_player almost done (#2818) * movie_player mostly done * d_a_npc_gnd done * fix fshop debug match --- configure.py | 2 +- include/d/actor/d_a_mg_fshop.h | 48 +- include/d/actor/d_a_movie_player.h | 241 +---- include/d/actor/d_a_npc_gnd.h | 17 +- include/dolphin/thp.h | 158 ++++ include/m_Do/m_Do_graphic.h | 4 + include/revolution/thp.h | 154 ++++ src/d/actor/d_a_mg_fshop.cpp | 1326 +++++++-------------------- src/d/actor/d_a_movie_player.cpp | 1373 ++++++++++++++++++++-------- src/d/actor/d_a_npc_gnd.cpp | 487 ++++++---- src/d/actor/d_a_npc_henna.cpp | 4 +- 11 files changed, 2019 insertions(+), 1795 deletions(-) create mode 100644 include/dolphin/thp.h create mode 100644 include/revolution/thp.h diff --git a/configure.py b/configure.py index 58c9ddb4b6..29015a63cd 100755 --- a/configure.py +++ b/configure.py @@ -1870,7 +1870,7 @@ config.libs = [ ActorRel(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d_a_npc_du"), ActorRel(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d_a_npc_fairy"), ActorRel(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d_a_npc_fguard"), - ActorRel(NonMatching, "d_a_npc_gnd"), + ActorRel(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d_a_npc_gnd"), ActorRel(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d_a_npc_gra", extra_cflags=[DANPCF_C_HACK]), ActorRel(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d_a_npc_grc", extra_cflags=[DANPCF_C_HACK]), ActorRel(NonMatching, "d_a_npc_grd"), diff --git a/include/d/actor/d_a_mg_fshop.h b/include/d/actor/d_a_mg_fshop.h index 529b068903..e92366eae1 100644 --- a/include/d/actor/d_a_mg_fshop.h +++ b/include/d/actor/d_a_mg_fshop.h @@ -19,7 +19,7 @@ struct fs_weed_s { struct fs_tsubo_s { /* 0x00 */ cXyz field_0x00; /* 0x0C */ u8 field_0x0c[0x14 - 0x0c]; - /* 0x14 */ J3DModel* field_0x14; + /* 0x14 */ J3DModel* model; /* 0x18 */ u8 field_0x18[0x1C - 0x18]; /* 0x1C */ f32 field_0x1c; /* 0x20 */ s16 field_0x20; @@ -30,13 +30,13 @@ struct fs_tsubo_s { struct fs_rod_s { /* 0x00 */ cXyz field_0x00; /* 0x0C */ u8 field_0x0C[0x14 - 0x0C]; - /* 0x14 */ J3DModel* field_0x14; - /* 0x18 */ J3DModel* field_0x18[6]; + /* 0x14 */ J3DModel* model; + /* 0x18 */ J3DModel* ringModel[6]; /* 0x30 */ mDoExt_3DlineMat0_c line_mat; /* 0x4C */ int field_0x4c; /* 0x50 */ u8 field_0x50[0x54 - 0x50]; /* 0x54 */ f32 field_0x54; - /* 0x58 */ s16 field_0x58; + /* 0x58 */ s16 rot_x; }; struct fs_lure_s { @@ -44,9 +44,8 @@ struct fs_lure_s { /* 0x0C */ s16 field_0x0c; /* 0x0E */ s16 field_0x0e; /* 0x10 */ s16 field_0x10; - /* 0x12 */ u8 field_0x12[0x14 - 0x12]; - /* 0x14 */ J3DModel* field_0x14; - /* 0x18 */ J3DModel* field_0x18[2]; + /* 0x14 */ J3DModel* model; + /* 0x18 */ J3DModel* hookModel[2]; /* 0x20 */ u8 field_0x20[0x24 - 0x20]; /* 0x24 */ int field_0x24; /* 0x28 */ f32 field_0x28; @@ -60,18 +59,15 @@ struct fs_lure_s { }; struct fs_koro2_s { - /* 0x00 */ J3DModel* mpModel; - /* 0x04 */ Mtx field_0x04; - /* 0x34 */ s8 field_0x34; - /* 0x35 */ u8 field_0x35[0x38 - 0x35]; - /* 0x38 */ cXyz field_0x38; - /* 0x44 */ cXyz field_0x44; - /* 0x50 */ s16 field_0x50; - /* 0x52 */ u8 field_0x52[0x54 - 0x52]; - /* 0x54 */ cXyz field_0x54; + /* 0x00 */ J3DModel* model; + /* 0x04 */ Mtx bgMtx; + /* 0x34 */ s8 part_id; + /* 0x38 */ cXyz pos; + /* 0x44 */ cXyz size; + /* 0x50 */ s16 rot_y; + /* 0x54 */ cXyz world_pos; /* 0x60 */ u8 field_0x60; - /* 0x61 */ u8 field_0x61[0x64 - 0x61]; - /* 0x64 */ dBgW* mpBgW; + /* 0x64 */ dBgW* bgw; }; /** @@ -93,12 +89,12 @@ public: /* 0x1288 */ fs_weed_s mWeed[60]; /* 0x3F88 */ mDoExt_3DlineMat0_c field_0x3f88; /* 0x3FA4 */ fs_tsubo_s mTsubo[2]; - /* 0x3FF4 */ J3DModel* field_0x3ff4; + /* 0x3FF4 */ J3DModel* hatModel; /* 0x3FF8 */ s16 field_0x3ff8; /* 0x3FFA */ s16 field_0x3ffa; /* 0x3FFC */ f32 field_0x3ffc; /* 0x4000 */ f32 field_0x4000; - /* 0x4004 */ J3DModel* field_0x4004; + /* 0x4004 */ J3DModel* photoModel; /* 0x4008 */ fshop_class* field_0x4008; /* 0x400C */ u8 field_0x400c; /* 0x400D */ u8 field_0x400d; @@ -107,21 +103,21 @@ public: /* 0x4014 */ cXyz field_0x4014; /* 0x4020 */ csXyz field_0x4020; /* 0x4028 */ J3DModel* mpA_crwaku_model; - /* 0x402C */ dBgW* field_0x402c; + /* 0x402C */ dBgW* koro2WakuBgw; /* 0x4030 */ Mtx field_0x4030; /* 0x4060 */ s16 field_0x4060; /* 0x4062 */ s16 field_0x4062; /* 0x4064 */ cXyz field_0x4064; - /* 0x4070 */ J3DModel* field_0x4070; - /* 0x4074 */ dBgS_AcchCir field_0x4074; - /* 0x40B4 */ dBgS_ObjAcch field_0x40b4; + /* 0x4070 */ J3DModel* ballModel; + /* 0x4074 */ dBgS_AcchCir ballAcchcir; + /* 0x40B4 */ dBgS_ObjAcch ballAcch; /* 0x428C */ u8 field_0x428c; /* 0x428D */ u8 field_0x428d; /* 0x4290 */ fs_koro2_s mKoro2[100]; - /* 0x6B30 */ J3DModel* field_0x6b30; + /* 0x6B30 */ J3DModel* canoeModel; /* 0x6B34 */ s16 field_0x6b34; /* 0x6B38 */ Mtx field_0x6b38; - /* 0x6B68 */ dBgW* field_0x6b68; + /* 0x6B68 */ dBgW* tableBgw; /* 0x6B6C */ u32 field_0x6b6c[2]; /* 0x6B74 */ u8 field_0x6B74[0x6B7C - 0x6B74]; /* 0x6B7C */ u8 field_0x6b7c; diff --git a/include/d/actor/d_a_movie_player.h b/include/d/actor/d_a_movie_player.h index 3a8a0cca08..7de7967ff2 100644 --- a/include/d/actor/d_a_movie_player.h +++ b/include/d/actor/d_a_movie_player.h @@ -1,106 +1,53 @@ #ifndef D_A_MOVIE_PLAYER_H #define D_A_MOVIE_PLAYER_H +#include #include "f_op/f_op_actor.h" #include "d/d_drawlist.h" -#ifdef __cplusplus -extern "C" { -#endif +struct daMP_THPReadBuffer { + u8* ptr; + s32 frameNumber; + BOOL isValid; +}; -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 +struct daMP_THPPlayer { + /* 0x000 */ DVDFileInfo fileInfo; + /* 0x03C */ THPHeader header; + /* 0x06C */ THPFrameCompInfo compInfo; + /* 0x080 */ THPVideoInfo videoInfo; + /* 0x08C */ THPAudioInfo audioInfo; + /* 0x09C */ void* thpWork; + /* 0x0A0 */ BOOL open; + /* 0x0A4 */ u8 state; + /* 0x0A5 */ u8 internalState; + /* 0x0A6 */ u8 playFlag; + /* 0x0A7 */ u8 audioExist; + /* 0x0A8 */ s32 dvdError; + /* 0x0AC */ s32 videoError; + /* 0x0B0 */ BOOL onMemory; + /* 0x0B4 */ u8* movieData; + /* 0x0B8 */ s32 initOffset; + /* 0x0BC */ s32 initReadSize; + /* 0x0C0 */ s32 initReadFrame; + /* 0x0C4 */ u32 curField; + /* 0x0C8 */ s64 retaceCount; + /* 0x0D0 */ s32 prevCount; + /* 0x0D4 */ s32 curCount; + /* 0x0D8 */ s32 videoDecodeCount; + /* 0x0DC */ f32 curVolume; + /* 0x0E0 */ f32 targetVolume; + /* 0x0E4 */ f32 deltaVolume; + /* 0x0E8 */ s32 rampCount; + /* 0x0EC */ s32 curAudioTrack; + /* 0x0F0 */ s32 curVideoNumber; + /* 0x0F4 */ s32 curAudioNumber; + /* 0x0F8 */ THPTextureSet* dispTextureSet; + /* 0x0FC */ THPAudioBuffer* playAudioBuffer; + /* 0x100 */ daMP_THPReadBuffer readBuffer[10]; + /* 0x000 */ THPTextureSet textureSet[THP_TEXTURE_SET_COUNT]; + /* 0x000 */ THPAudioBuffer audioBuffer[THP_AUDIO_BUFFER_COUNT]; +}; /** * @ingroup actors-unsorted @@ -142,11 +89,6 @@ private: STATIC_ASSERT(sizeof(daMP_c) == 0x580); -struct daMP_THPReadBuffer { - /* 0x00 */ void* m00; - /* 0x04 */ s32 m04; -}; - class daMP_Dlst_base_c : public dDlst_base_c { public: /* 80878FD8 */ daMP_Dlst_base_c() {} @@ -154,103 +96,8 @@ public: /* 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; -}; - inline s32 daMP_NEXT_READ_SIZE(daMP_THPReadBuffer* readBuf) { - return *(s32*)readBuf->m00; + return *(s32*)readBuf->ptr; } void daMP_PrepareReady(int); diff --git a/include/d/actor/d_a_npc_gnd.h b/include/d/actor/d_a_npc_gnd.h index 5a3a436509..b29b16d57c 100644 --- a/include/d/actor/d_a_npc_gnd.h +++ b/include/d/actor/d_a_npc_gnd.h @@ -72,11 +72,11 @@ public: /* 809BCA14 */ void setCollision(); /* 809BCB48 */ int drawDbgInfo(); /* 809BCB50 */ bool afterSetMotionAnm(int, int, f32, int); - /* 809BCCE8 */ void selectAction(); - /* 809BCD30 */ void chkAction(int (daNpc_Gnd_c::*)(void*)); - /* 809BCD5C */ void setAction(int (daNpc_Gnd_c::*)(void*)); - /* 809BCE04 */ void wait(void*); - /* 809BD050 */ void talk(void*); + /* 809BCCE8 */ int selectAction(); + /* 809BCD30 */ int chkAction(int (daNpc_Gnd_c::*)(void*)); + /* 809BCD5C */ int setAction(int (daNpc_Gnd_c::*)(void*)); + /* 809BCE04 */ int wait(void*); + /* 809BD050 */ int talk(void*); /* 809BE2D0 */ daNpc_Gnd_c( daNpcT_faceMotionAnmData_c const* i_faceMotionAnmData, daNpcT_motionAnmData_c const* i_motionAnmData, @@ -96,16 +96,15 @@ public: /* 809BE424 */ s32 getNeckJointNo() { return 3; } /* 809BE42C */ s32 getBackboneJointNo() { return 1; } - static char* mCutNameList; + static char* mCutNameList[1]; static cutFunc mCutList[1]; private: /* 0xE40 */ NPC_GND_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl1; /* 0xF80 */ u8 mType; - /* 0xF81 */ u8 field_0xf81[0xF84 - 0xF81]; - /* 0xF84 */ u8 field_0xF84; - /* 0xF85 */ u8 field_0xF85[0xF9C - 0xF85]; + /* 0xF84 */ int (daNpc_Gnd_c::*mNextAction)(void*); + /* 0xF90 */ int (daNpc_Gnd_c::*mAction)(void*); /* 0xF9C */ u8 field_0xF9C; }; diff --git a/include/dolphin/thp.h b/include/dolphin/thp.h new file mode 100644 index 0000000000..250c518f6b --- /dev/null +++ b/include/dolphin/thp.h @@ -0,0 +1,158 @@ +#ifndef _DOLPHIN_THP_H_ +#define _DOLPHIN_THP_H_ + +#ifdef __REVOLUTION_SDK__ +#include +#else +#include + +#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; + +typedef struct THPTextureSet { + u8* ytexture; + u8* utexture; + u8* vtexture; + s32 frameNumber; +} THPTextureSet; + +typedef struct THPAudioBuffer { + s16* buffer; + s16* curPtr; + u32 validSample; +} THPAudioBuffer; + +typedef struct THPVideoInfo { + u32 xSize; + u32 ySize; + u32 videoType; +} THPVideoInfo; + +typedef struct THPAudioInfo { + u32 sndChannels; + u32 sndFrequency; + u32 sndNumSamples; + u32 sndNumTracks; +} THPAudioInfo; + +typedef struct THPFrameCompInfo { + u32 numComponents; + u8 frameComp[16]; +} THPFrameCompInfo; + +typedef struct THPHeader { + /* 0x00 */ char magic[4]; + /* 0x04 */ u32 version; + /* 0x08 */ u32 bufsize; + /* 0x0C */ u32 audioMaxSamples; + /* 0x10 */ f32 frameRate; + /* 0x14 */ u32 numFrames; + /* 0x18 */ u32 firstFrameSize; + /* 0x1C */ u32 movieDataSize; + /* 0x20 */ u32 compInfoDataOffsets; + /* 0x24 */ u32 offsetDataOffsets; + /* 0x28 */ u32 movieDataOffsets; + /* 0x2C */ u32 finalFrameDataOffsets; +} THPHeader; + +#define THP_AUDIO_BUFFER_COUNT 3 +#define THP_READ_BUFFER_COUNT 10 +#define THP_TEXTURE_SET_COUNT 3 + +static u32 THPAudioDecode(s16* audioBuffer, u8* audioFrame, s32 flag); +static s32 __THPAudioGetNewSample(THPAudioDecodeInfo* info); +static void __THPAudioInitialize(THPAudioDecodeInfo* info, u8* ptr); + +s32 __THPAudioGetNewSample(THPAudioDecodeInfo*); +void __THPAudioInitialize(THPAudioDecodeInfo*, u8*); + +static void __THPSetupBuffers(void); +static u8 __THPReadFrameHeader(void); +static u8 __THPReadScaneHeader(void); +static u8 __THPReadQuantizationTable(void); +static u8 __THPReadHuffmanTableSpecification(void); +static void __THPHuffGenerateSizeTable(void); +static void __THPHuffGenerateCodeTable(void); +static void __THPHuffGenerateDecoderTables(u8 tabIndex); +static void __THPRestartDefinition(void); +static void __THPPrepBitStream(void); +static void __THPDecompressYUV(void* tileY, void* tileU, void* tileV); +static void __THPGQRRestore(void); +static void __THPDecompressiMCURow512x448(void); +static void __THPDecompressiMCURow640x480(void); +static void __THPDecompressiMCURowNxN(void); +static void __THPInverseDCTNoYPos(THPCoeff* in, u32 xPos); +static void __THPHuffDecodeDCTCompY(THPFileInfo* info, THPCoeff* block); +static void __THPHuffDecodeDCTCompU(THPFileInfo* info, THPCoeff* block); +static void __THPHuffDecodeDCTCompV(THPFileInfo* info, THPCoeff* block); + +static void __THPInverseDCTY8(THPCoeff* in, u32 xPos); +static void __THPGQRSetup(); +static s32 __THPHuffDecodeTab(THPFileInfo* info, THPHuffmanTab* h); + +#ifdef __cplusplus +} +#endif + +#endif +#endif // _DOLPHIN_THP_H_ diff --git a/include/m_Do/m_Do_graphic.h b/include/m_Do/m_Do_graphic.h index 44685e321f..324f2e9db0 100644 --- a/include/m_Do/m_Do_graphic.h +++ b/include/m_Do/m_Do_graphic.h @@ -78,6 +78,10 @@ public: /* 80008078 */ static void onBlure(); /* 80008330 */ static void calcFade(); + static void fadeIn(f32 fadeSpeed) { + fadeOut(-fadeSpeed); + } + static JUTFader* getFader() { return mFader; } static void setFader(JUTFader* fader) { JFWDisplay::getManager()->setFader(fader); diff --git a/include/revolution/thp.h b/include/revolution/thp.h new file mode 100644 index 0000000000..00e6968b42 --- /dev/null +++ b/include/revolution/thp.h @@ -0,0 +1,154 @@ +#ifndef _REVOLUTION_THP_H_ +#define _REVOLUTION_THP_H_ + +#include + +#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; + +typedef struct THPTextureSet { + u8* ytexture; + u8* utexture; + u8* vtexture; + s32 frameNumber; +} THPTextureSet; + +typedef struct THPAudioBuffer { + s16* buffer; + s16* curPtr; + u32 validSample; +} THPAudioBuffer; + +typedef struct THPVideoInfo { + u32 xSize; + u32 ySize; + u32 videoType; +} THPVideoInfo; + +typedef struct THPAudioInfo { + u32 sndChannels; + u32 sndFrequency; + u32 sndNumSamples; + u32 sndNumTracks; +} THPAudioInfo; + +typedef struct THPFrameCompInfo { + u32 numComponents; + u8 frameComp[16]; +} THPFrameCompInfo; + +typedef struct THPHeader { + /* 0x00 */ char magic[4]; + /* 0x04 */ u32 version; + /* 0x08 */ u32 bufsize; + /* 0x0C */ u32 audioMaxSamples; + /* 0x10 */ f32 frameRate; + /* 0x14 */ u32 numFrames; + /* 0x18 */ u32 firstFrameSize; + /* 0x1C */ u32 movieDataSize; + /* 0x20 */ u32 compInfoDataOffsets; + /* 0x24 */ u32 offsetDataOffsets; + /* 0x28 */ u32 movieDataOffsets; + /* 0x2C */ u32 finalFrameDataOffsets; +} THPHeader; + +#define THP_AUDIO_BUFFER_COUNT 3 +#define THP_READ_BUFFER_COUNT 10 +#define THP_TEXTURE_SET_COUNT 3 + +static u32 THPAudioDecode(s16* audioBuffer, u8* audioFrame, s32 flag); +static s32 __THPAudioGetNewSample(THPAudioDecodeInfo* info); +static void __THPAudioInitialize(THPAudioDecodeInfo* info, u8* ptr); + +s32 __THPAudioGetNewSample(THPAudioDecodeInfo*); +void __THPAudioInitialize(THPAudioDecodeInfo*, u8*); + +static void __THPSetupBuffers(void); +static u8 __THPReadFrameHeader(void); +static u8 __THPReadScaneHeader(void); +static u8 __THPReadQuantizationTable(void); +static u8 __THPReadHuffmanTableSpecification(void); +static void __THPHuffGenerateSizeTable(void); +static void __THPHuffGenerateCodeTable(void); +static void __THPHuffGenerateDecoderTables(u8 tabIndex); +static void __THPRestartDefinition(void); +static void __THPPrepBitStream(void); +static void __THPDecompressYUV(void* tileY, void* tileU, void* tileV); +static void __THPGQRRestore(void); +static void __THPDecompressiMCURow512x448(void); +static void __THPDecompressiMCURow640x480(void); +static void __THPDecompressiMCURowNxN(void); +static void __THPInverseDCTNoYPos(THPCoeff* in, u32 xPos); +static void __THPHuffDecodeDCTCompY(THPFileInfo* info, THPCoeff* block); +static void __THPHuffDecodeDCTCompU(THPFileInfo* info, THPCoeff* block); +static void __THPHuffDecodeDCTCompV(THPFileInfo* info, THPCoeff* block); + +static void __THPInverseDCTY8(THPCoeff* in, u32 xPos); +static void __THPGQRSetup(); +static s32 __THPHuffDecodeTab(THPFileInfo* info, THPHuffmanTab* h); + +#ifdef __cplusplus +} +#endif + +#endif // _REVOLUTION_THP_H_ diff --git a/src/d/actor/d_a_mg_fshop.cpp b/src/d/actor/d_a_mg_fshop.cpp index 7e94d1bbf6..109c35bacf 100644 --- a/src/d/actor/d_a_mg_fshop.cpp +++ b/src/d/actor/d_a_mg_fshop.cpp @@ -14,6 +14,24 @@ #include "d/d_s_play.h" #include "Z2AudioLib/Z2Instances.h" +enum koro2_parts { + KORO2_PART_BOX = 1, + KORO2_PART_CURVE_A_U_L, + KORO2_PART_CURVE_A_U_R, + KORO2_PART_CURVE_A_R_U, + KORO2_PART_CURVE_A_L_U, + KORO2_PART_START, + KORO2_PART_GOAL, + KORO2_PART_CURVE_B_U_L, + KORO2_PART_CURVE_B_U_R, + KORO2_PART_CURVE_B_R_U, + KORO2_PART_CURVE_B_L_U, + KORO2_PART_SLOPE_D, + KORO2_PART_SLOPE_U, + KORO2_PART_SLOPE_L, + KORO2_PART_SLOPE_R, +}; + /* 8086C06C-8086C08C 0000EC 0020+00 1/1 0/0 0/0 .text * ride_call_back__FP4dBgWP10fopAc_ac_cP10fopAc_ac_c */ static void ride_call_back(dBgW* i_bgw, fopAc_ac_c* i_bgActor, fopAc_ac_c* i_rideActor) { @@ -25,16 +43,15 @@ static void ride_call_back(dBgW* i_bgw, fopAc_ac_c* i_bgActor, fopAc_ac_c* i_rid /* 8086C08C-8086C140 00010C 00B4+00 1/1 0/0 0/0 .text Reel_CallBack__FP8J3DJointi */ static int Reel_CallBack(J3DJoint* i_joint, int param_1) { - s32 userarea; J3DJoint* var_r27; if (param_1 == 0) { var_r27 = i_joint; int jnt_no = var_r27->getJntNo(); J3DModel* model = j3dSys.getModel(); - userarea = model->getUserArea(); + fs_rod_s* rod = (fs_rod_s*)model->getUserArea(); MTXCopy(model->getAnmMtx(jnt_no), *calc_mtx); - cMtx_XrotM(*calc_mtx, *(s16*)(userarea + 0x58)); // fakematch, unknown type for userarea + cMtx_XrotM(*calc_mtx, rod->rot_x); model->setAnmMtx(jnt_no, *calc_mtx); MTXCopy(*calc_mtx, J3DSys::mCurrentMtx); } @@ -44,14 +61,14 @@ static int Reel_CallBack(J3DJoint* i_joint, int param_1) { /* 8086C140-8086C214 0001C0 00D4+00 1/1 0/0 0/0 .text frog_CallBack__FP8J3DJointi */ static int frog_CallBack(J3DJoint* i_joint, int param_1) { - int userarea; + fs_lure_s* lure; J3DJoint* var_r27; if (param_1 == 0) { var_r27 = i_joint; int jnt_no = var_r27->getJntNo(); J3DModel* model = j3dSys.getModel(); - userarea = model->getUserArea(); // unknown type + lure = (fs_lure_s*)model->getUserArea(); if (jnt_no == 1) { MTXCopy(model->getAnmMtx(jnt_no), *calc_mtx); @@ -86,847 +103,141 @@ static void koro2_draw(fshop_class* i_this) { mDoExt_modelUpdateDL(ArcIX_A_crwaku_model[0]); for (int i = 0; i < ARRAY_SIZE(i_this->mKoro2); i++) { - if (i_this->mKoro2[i].mpModel != NULL) { - g_env_light.setLightTevColorType_MAJI(i_this->mKoro2[i].mpModel, &actor->tevStr); - mDoExt_modelUpdateDL(i_this->mKoro2[i].mpModel); + if (i_this->mKoro2[i].model != NULL) { + g_env_light.setLightTevColorType_MAJI(i_this->mKoro2[i].model, &actor->tevStr); + mDoExt_modelUpdateDL(i_this->mKoro2[i].model); } } dComIfGd_setList(); } +/** + * Koro2 (Rollgoal) map data works as a 15x15 grid + * Each grid value represents a piece to be placed there (koro2_parts enum) + * (0) represents an empty space + * + * Up to 100 parts are supported in a course, though each piece has it's own max limit: + * Start: 1 + * Goal: 1 + * Box: 31 + * CurveA: 16 + * CurveB: 4 + * Slope: 8 + */ + /* 808702A4-8087032C 000020 0087+01 1/1 0/0 0/0 .data koro2_map_LV1 */ static s8 koro2_map_LV1[135] = { - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x07, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x05, - 0x01, - 0x01, - 0x02, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x03, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x04, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x05, - 0x01, - 0x01, - 0x02, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x06, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x01, 0x01, 0x02, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x05, 0x01, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; /* 8087032C-808703B4 0000A8 0087+01 1/0 0/0 0/0 .data koro2_map_LV2 */ static s8 koro2_map_LV2[135] = { - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x07, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x05, - 0x01, - 0x01, - 0x02, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x03, - 0x01, - 0x02, - 0x00, - 0x03, - 0x01, - 0x04, - 0x00, - 0x00, - 0x01, - 0x00, - 0x05, - 0x01, - 0x04, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x05, - 0x01, - 0x01, - 0x02, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x06, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x01, 0x01, 0x02, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x03, 0x01, 0x02, 0x00, 0x03, 0x01, 0x04, 0x00, + 0x00, 0x01, 0x00, 0x05, 0x01, 0x04, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x05, 0x01, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; /* 808703B4-8087043C 000130 0087+01 1/0 0/0 0/0 .data koro2_map_LV3 */ static s8 koro2_map_LV3[135] = { - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x07, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x05, - 0x01, - 0x01, - 0x02, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x03, - 0x01, - 0x02, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x01, - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x01, - 0x00, - 0x05, - 0x01, - 0x01, - 0x01, - 0x04, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x03, - 0x01, - 0x01, - 0x02, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x05, - 0x01, - 0x01, - 0x04, - 0x00, - 0x00, - 0x06, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x01, 0x01, 0x02, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x03, 0x01, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x01, 0x00, 0x05, 0x01, 0x01, 0x01, 0x04, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x03, 0x01, 0x01, 0x02, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x05, 0x01, 0x01, 0x04, 0x00, 0x00, 0x06, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; /* 8087043C-808704C4 0001B8 0087+01 1/0 0/0 0/0 .data koro2_map_LV4 */ static s8 koro2_map_LV4[135] = { - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x07, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x03, - 0x01, - 0x02, - 0x00, - 0x00, - 0x00, - 0x00, - 0x05, - 0x01, - 0x04, - 0x00, - 0x05, - 0x01, - 0x02, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x03, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x04, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x05, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x02, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x03, - 0x01, - 0x01, - 0x01, - 0x01, - 0x01, - 0x04, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x03, - 0x01, - 0x01, - 0x02, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x05, - 0x01, - 0x01, - 0x04, - 0x00, - 0x00, - 0x06, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x03, 0x01, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x05, 0x01, 0x04, 0x00, 0x05, 0x01, 0x02, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x03, 0x01, 0x01, 0x02, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x05, 0x01, 0x01, 0x04, 0x00, 0x00, 0x06, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; /* 808704C4-8087054C 000240 0087+01 1/0 0/0 0/0 .data koro2_map_LV5 */ static s8 koro2_map_LV5[135] = { - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x07, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x09, - 0x00, - 0x00, - 0x08, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x0C, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x0B, - 0x00, - 0x00, - 0x0A, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x0D, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x06, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x09, 0x00, 0x00, 0x08, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x0C, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0B, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; /* 8087054C-808705D4 0002C8 0087+01 1/0 0/0 0/0 .data koro2_map_LV7 */ static s8 koro2_map_LV7[135] = { - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x07, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x05, - 0x0E, - 0x00, - 0x00, - 0x0F, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x08, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x0C, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x0D, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x06, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x05, 0x0E, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; /* 808705D4-8087065C 000350 0087+01 1/0 0/0 0/0 .data koro2_map_LV6 */ @@ -1002,16 +313,16 @@ static int daFshop_Draw(fshop_class* i_this) { fopAc_ac_c* actor = &i_this->actor; g_env_light.settingTevStruct(0x10, &actor->current.pos, &actor->tevStr); - if (i_this->field_0x4070 != NULL) { - g_env_light.setLightTevColorType_MAJI(i_this->field_0x4070, &actor->tevStr); + if (i_this->ballModel != NULL) { + g_env_light.setLightTevColorType_MAJI(i_this->ballModel, &actor->tevStr); - J3DMaterial* sp1C = i_this->field_0x4070->getModelData()->getMaterialNodePointer(0); + J3DMaterial* sp1C = i_this->ballModel->getModelData()->getMaterialNodePointer(0); sp1C->getTevKColor(1)->r = 0; - mDoExt_modelUpdateDL(i_this->field_0x4070); + mDoExt_modelUpdateDL(i_this->ballModel); dComIfGd_setSimpleShadow( - &actor->current.pos, i_this->field_0x40b4.GetGroundH(), (TREG_F(8) + 66.6f) * actor->scale.x, - i_this->field_0x40b4.m_gnd, 0, 1.0f, dDlst_shadowControl_c::getSimpleTex()); + &actor->current.pos, i_this->ballAcch.GetGroundH(), (TREG_F(8) + 66.6f) * actor->scale.x, + i_this->ballAcch.m_gnd, 0, 1.0f, dDlst_shadowControl_c::getSimpleTex()); return 1; } @@ -1030,20 +341,20 @@ static int daFshop_Draw(fshop_class* i_this) { f32 fVar4 = i_this->mLure[i].field_0x00.x - camera->lookat.eye.x; f32 fVar5 = i_this->mLure[i].field_0x00.z - camera->lookat.eye.z; if (SQUARE(fVar4) + SQUARE(fVar5) > KREG_F(11) + 1200.0f) { - g_env_light.setLightTevColorType_MAJI(i_this->mLure[i].field_0x14, &actor->tevStr); - mDoExt_modelUpdateDL(i_this->mLure[i].field_0x14); + g_env_light.setLightTevColorType_MAJI(i_this->mLure[i].model, &actor->tevStr); + mDoExt_modelUpdateDL(i_this->mLure[i].model); if (i_this->mLure[i].field_0x24 != 3) { for (int j = 0; j < 2; j++) { - dComIfGp_entrySimpleModel(i_this->mLure[i].field_0x18[j], roomNo); + dComIfGp_entrySimpleModel(i_this->mLure[i].hookModel[j], roomNo); } } } } for (int i = 0; i < 3; i++) { - g_env_light.setLightTevColorType_MAJI(i_this->mRod[i].field_0x14, &actor->tevStr); - mDoExt_modelUpdateDL(i_this->mRod[i].field_0x14); + g_env_light.setLightTevColorType_MAJI(i_this->mRod[i].model, &actor->tevStr); + mDoExt_modelUpdateDL(i_this->mRod[i].model); static GXColor rod_color[3] = { {0x96, 0x50, 0x14, 0xFF}, @@ -1054,30 +365,30 @@ static int daFshop_Draw(fshop_class* i_this) { dComIfGd_set3DlineMat(&i_this->mRod[i].line_mat); for (int j = 0; j < 6; j++) { - dComIfGp_entrySimpleModel(i_this->mRod[i].field_0x18[j], roomNo); + dComIfGp_entrySimpleModel(i_this->mRod[i].ringModel[j], roomNo); } } for (int i = 0; i < 2; i++) { - g_env_light.setLightTevColorType_MAJI(i_this->mTsubo[i].field_0x14, &actor->tevStr); - mDoExt_modelUpdateDL(i_this->mTsubo[i].field_0x14); + g_env_light.setLightTevColorType_MAJI(i_this->mTsubo[i].model, &actor->tevStr); + mDoExt_modelUpdateDL(i_this->mTsubo[i].model); } static GXColor l_color = {0x32, 0x64, 0x1E, 0xFF}; i_this->field_0x3f88.update(15, TREG_F(11) + 1.2f, l_color, 2, &actor->tevStr); dComIfGd_set3DlineMat(&i_this->field_0x3f88); - g_env_light.setLightTevColorType_MAJI(i_this->field_0x6b30, &actor->tevStr); - mDoExt_modelUpdateDL(i_this->field_0x6b30); + g_env_light.setLightTevColorType_MAJI(i_this->canoeModel, &actor->tevStr); + mDoExt_modelUpdateDL(i_this->canoeModel); - g_env_light.setLightTevColorType_MAJI(i_this->field_0x3ff4, &actor->tevStr); - mDoExt_modelUpdateDL(i_this->field_0x3ff4); + g_env_light.setLightTevColorType_MAJI(i_this->hatModel, &actor->tevStr); + mDoExt_modelUpdateDL(i_this->hatModel); - if (i_this->field_0x4004 != NULL) { + if (i_this->photoModel != NULL) { mDoMtx_stack_c::transS(0.0f, 0.0f, 0.0f); - i_this->field_0x4004->setBaseTRMtx(mDoMtx_stack_c::get()); - g_env_light.setLightTevColorType_MAJI(i_this->field_0x4004, &actor->tevStr); - mDoExt_modelUpdateDL(i_this->field_0x4004); + i_this->photoModel->setBaseTRMtx(mDoMtx_stack_c::get()); + g_env_light.setLightTevColorType_MAJI(i_this->photoModel, &actor->tevStr); + mDoExt_modelUpdateDL(i_this->photoModel); } return 1; @@ -1151,18 +462,18 @@ static void lure_set(fshop_class* i_this) { mDoMtx_stack_c::ZrotM(pLure->field_0x10); mDoMtx_stack_c::scaleM(pLure->field_0x2c, pLure->field_0x2c, pLure->field_0x28); mDoMtx_stack_c::transM(0.0f, 0.0f, 0.0f); - pLure->field_0x14->setBaseTRMtx(mDoMtx_stack_c::get()); + pLure->model->setBaseTRMtx(mDoMtx_stack_c::get()); if (pLure->field_0x24 != 3) { mDoMtx_stack_c::push(); mDoMtx_stack_c::transM(0.0f, hook_1_offy[pLure->field_0x24], 1.0f); mDoMtx_stack_c::XrotM(-10000); - pLure->field_0x18[0]->setBaseTRMtx(mDoMtx_stack_c::get()); + pLure->hookModel[0]->setBaseTRMtx(mDoMtx_stack_c::get()); mDoMtx_stack_c::pop(); mDoMtx_stack_c::transM(0.0f, hook_2_offy[pLure->field_0x24], hook_2_offz[pLure->field_0x24]); mDoMtx_stack_c::XrotM(0x4000); - pLure->field_0x18[1]->setBaseTRMtx(mDoMtx_stack_c::get()); + pLure->hookModel[1]->setBaseTRMtx(mDoMtx_stack_c::get()); } } } @@ -1182,7 +493,7 @@ static void rod_set(fshop_class* i_this) { } mDoMtx_stack_c::XrotM(1300); mDoMtx_stack_c::YrotM(0); - pRod->field_0x14->setBaseTRMtx(mDoMtx_stack_c::get()); + pRod->model->setBaseTRMtx(mDoMtx_stack_c::get()); cXyz* local_64 = pRod->line_mat.getPos(0); if (pRod->field_0x4c == 0) { @@ -1213,7 +524,7 @@ static void rod_set(fshop_class* i_this) { mDoMtx_stack_c::scaleM(guide_s[j], guide_s[j], guide_s[j]); mDoMtx_stack_c::transM(0.0f, 4.0f, 0.0f); mDoMtx_stack_c::YrotM(0x4000); - pRod->field_0x18[j]->setBaseTRMtx(mDoMtx_stack_c::get()); + pRod->ringModel[j]->setBaseTRMtx(mDoMtx_stack_c::get()); } } } @@ -1280,7 +591,7 @@ static void tsubo_set(fshop_class* i_this) { mDoMtx_stack_c::XrotM(xrot); mDoMtx_stack_c::ZrotM(zrot); mDoMtx_stack_c::scaleM(1.0f, 1.0f, 1.0f); - pTsubo->field_0x14->setBaseTRMtx(mDoMtx_stack_c::get()); + pTsubo->model->setBaseTRMtx(mDoMtx_stack_c::get()); cLib_addCalc0(&pTsubo->field_0x1c, 1.0f, 50.0f); } @@ -1333,12 +644,12 @@ static void koro2_mtx_set(fshop_class* i_this) { if (i_this->field_0x400d) { mDoMtx_stack_c::transS(0.0f, -10000.0f, 0.0f); MTXCopy(mDoMtx_stack_c::get(), i_this->field_0x4030); - i_this->field_0x402c->Move(); + i_this->koro2WakuBgw->Move(); for (int i = 0; i < 100; i++) { - if (i_this->mKoro2[i].mpModel != NULL) { - MTXCopy(mDoMtx_stack_c::get(), i_this->mKoro2[i].field_0x04); - i_this->mKoro2[i].mpBgW->Move(); + if (i_this->mKoro2[i].model != NULL) { + MTXCopy(mDoMtx_stack_c::get(), i_this->mKoro2[i].bgMtx); + i_this->mKoro2[i].bgw->Move(); } } } else { @@ -1352,35 +663,35 @@ static void koro2_mtx_set(fshop_class* i_this) { i_this->mpA_crwaku_model->setBaseTRMtx(mDoMtx_stack_c::get()); MTXCopy(mDoMtx_stack_c::get(), i_this->field_0x4030); - i_this->field_0x402c->Move(); + i_this->koro2WakuBgw->Move(); mDoMtx_stack_c::pop(); f32 var_f31 = VREG_F(2) + -10.0f; f32 var_f30 = VREG_F(4) + -18.0f; for (int i = 0; i < 100; i++) { - if (i_this->mKoro2[i].mpModel != NULL) { + if (i_this->mKoro2[i].model != NULL) { mDoMtx_stack_c::push(); - mDoMtx_stack_c::transM(i_this->mKoro2[i].field_0x38.x + var_f31, - i_this->mKoro2[i].field_0x38.y, - i_this->mKoro2[i].field_0x38.z + var_f30); - mDoMtx_stack_c::YrotM(i_this->mKoro2[i].field_0x50); - mDoMtx_stack_c::scaleM(i_this->mKoro2[i].field_0x44.x, - i_this->mKoro2[i].field_0x44.y, - i_this->mKoro2[i].field_0x44.z); + mDoMtx_stack_c::transM(i_this->mKoro2[i].pos.x + var_f31, + i_this->mKoro2[i].pos.y, + i_this->mKoro2[i].pos.z + var_f30); + mDoMtx_stack_c::YrotM(i_this->mKoro2[i].rot_y); + mDoMtx_stack_c::scaleM(i_this->mKoro2[i].size.x, + i_this->mKoro2[i].size.y, + i_this->mKoro2[i].size.z); mDoMtx_stack_c::push(); mDoMtx_stack_c::scaleM(0.01f, 0.01f, 0.01f); - i_this->mKoro2[i].mpModel->setBaseTRMtx(mDoMtx_stack_c::get()); - MTXCopy(mDoMtx_stack_c::get(), i_this->mKoro2[i].field_0x04); + i_this->mKoro2[i].model->setBaseTRMtx(mDoMtx_stack_c::get()); + MTXCopy(mDoMtx_stack_c::get(), i_this->mKoro2[i].bgMtx); - i_this->mKoro2[i].mpBgW->Move(); + i_this->mKoro2[i].bgw->Move(); mDoMtx_stack_c::pop(); - mDoMtx_stack_c::multVecZero(&i_this->mKoro2[i].field_0x54); + mDoMtx_stack_c::multVecZero(&i_this->mKoro2[i].world_pos); - if (i_this->mKoro2[i].field_0x34 == 6) { + if (i_this->mKoro2[i].part_id == KORO2_PART_START) { cStack_44.set(0.0f, 0.0f, 2.5f); mDoMtx_stack_c::multVec(&cStack_44, &BallStartPos); - } else if (i_this->mKoro2[i].field_0x34 == 7) { + } else if (i_this->mKoro2[i].part_id == KORO2_PART_GOAL) { cStack_44.set(0.0f, 0.0f, -2.0f); mDoMtx_stack_c::multVec(&cStack_44, &BallEndPos); } @@ -1499,7 +810,7 @@ static void koro2_game(fshop_class* i_this) { /* 8086D854-8086DA00 0018D4 01AC+00 1/1 0/0 0/0 .text ball_wall_check__FP11fshop_class */ static int ball_wall_check(fshop_class* i_this) { - if (!i_this->field_0x40b4.ChkWallHit()) { + if (!i_this->ballAcch.ChkWallHit()) { return 0; } @@ -1556,7 +867,7 @@ static int daFshop_Execute(fshop_class* i_this) { return 1; } - if (i_this->field_0x4070 != NULL) { + if (i_this->ballModel != NULL) { actor->scale.x = 0.024f; cXyz local_cc; cXyz local_d8; @@ -1606,15 +917,15 @@ static int daFshop_Execute(fshop_class* i_this) { actor->speed.y = -15.0f; } - i_this->field_0x40b4.m_gnd.OffWall(); - i_this->field_0x40b4.CrrPos(dComIfG_Bgsp()); + i_this->ballAcch.m_gnd.OffWall(); + i_this->ballAcch.CrrPos(dComIfG_Bgsp()); ball_wall_check(i_this); fshop_class* iVar6 = i_this->field_0x4008; for (int i = 0; i < 100; i++) { - if (iVar6->mKoro2[i].mpModel != NULL) { - local_cc.x = iVar6->mKoro2[i].field_0x54.x - actor->current.pos.x; - local_cc.z = iVar6->mKoro2[i].field_0x54.z - actor->current.pos.z; + if (iVar6->mKoro2[i].model != NULL) { + local_cc.x = iVar6->mKoro2[i].world_pos.x - actor->current.pos.x; + local_cc.z = iVar6->mKoro2[i].world_pos.z - actor->current.pos.z; if (JMAFastSqrt(local_cc.x * local_cc.x + local_cc.z * local_cc.z) < 40.0f) { iVar6->mKoro2[i].field_0x60 = 0; } @@ -1629,7 +940,7 @@ static int daFshop_Execute(fshop_class* i_this) { if (henna != NULL && henna->field_0x7b9 != 0 && (actor->field_0x567 == 1 || dTimer_getRestTimeMs() == 0)) { BOOL bVar5 = FALSE; for (int i = 0; i < 100; i++) { - if (iVar6->mKoro2[i].mpModel != NULL && iVar6->mKoro2[i].field_0x60) { + if (iVar6->mKoro2[i].model != NULL && iVar6->mKoro2[i].field_0x60) { bVar5 = TRUE; break; } @@ -1655,7 +966,7 @@ static int daFshop_Execute(fshop_class* i_this) { if (henna != NULL) { BOOL bVar5 = FALSE; for (int i = 0; i < 100; i++) { - if (iVar6->mKoro2[i].mpModel != NULL && iVar6->mKoro2[i].field_0x60) { + if (iVar6->mKoro2[i].model != NULL && iVar6->mKoro2[i].field_0x60) { bVar5 = TRUE; break; } @@ -1676,7 +987,7 @@ static int daFshop_Execute(fshop_class* i_this) { } } - if (i_this->field_0x40b4.ChkGroundHit()) { + if (i_this->ballAcch.ChkGroundHit()) { if (i_this->field_0x428c == 0) { actor->speed.y = 7.0f; } else if (i_this->field_0x428c == 1) { @@ -1736,7 +1047,7 @@ static int daFshop_Execute(fshop_class* i_this) { local_cc = pmVar11->lookat.eye - actor->current.pos; mDoMtx_stack_c::YrotM(cM_atan2s(local_cc.x, local_cc.z)); mDoMtx_stack_c::XrotM(-cM_atan2s(local_cc.y, JMAFastSqrt((local_cc.x * local_cc.x + local_cc.z * local_cc.z)))); - i_this->field_0x4070->setBaseTRMtx(mDoMtx_stack_c::get()); + i_this->ballModel->setBaseTRMtx(mDoMtx_stack_c::get()); return 1; } else { lure_set(i_this); @@ -1777,12 +1088,12 @@ static int daFshop_Execute(fshop_class* i_this) { mDoMtx_stack_c::transS(-450.0f, 25.0f, -250.0f); mDoMtx_stack_c::YrotM(0x4000); mDoMtx_stack_c::ZrotM(iVar6 + 2000); - i_this->field_0x6b30->setBaseTRMtx(mDoMtx_stack_c::get()); + i_this->canoeModel->setBaseTRMtx(mDoMtx_stack_c::get()); mDoMtx_stack_c::transS(-450.0f, 0.0f, -250.0f); mDoMtx_stack_c::scaleM(4.0f, 1.5f, 1.0f); MTXCopy(mDoMtx_stack_c::get(), i_this->field_0x6b38); - i_this->field_0x6b68->Move(); + i_this->tableBgw->Move(); local_c0.x = 325.0f - pPlayer->current.pos.x; local_c0.z = 237.0f - pPlayer->current.pos.z; @@ -1804,7 +1115,7 @@ static int daFshop_Execute(fshop_class* i_this) { mDoMtx_stack_c::XrotM((s16)iVar10); mDoMtx_stack_c::ZrotM(iVar11 + 15000); mDoMtx_stack_c::transM(-10.0f, -7.0f, 0.0f); - i_this->field_0x3ff4->setBaseTRMtx(mDoMtx_stack_c::get()); + i_this->hatModel->setBaseTRMtx(mDoMtx_stack_c::get()); koro2_game(i_this); } @@ -1831,13 +1142,13 @@ static int daFshop_Delete(fshop_class* i_this) { } dComIfG_resDelete(&i_this->mPhase, "Fshop"); - dComIfG_Bgsp().Release(i_this->field_0x6b68); + dComIfG_Bgsp().Release(i_this->tableBgw); if (i_this->field_0x400e != 0) { - dComIfG_Bgsp().Release(i_this->field_0x402c); + dComIfG_Bgsp().Release(i_this->koro2WakuBgw); for (int i = 0; i < 100; i++) { - if (i_this->mKoro2[i].mpBgW != NULL) { - dComIfG_Bgsp().Release(i_this->mKoro2[i].mpBgW); + if (i_this->mKoro2[i].bgw != NULL) { + dComIfG_Bgsp().Release(i_this->mKoro2[i].bgw); } } } @@ -1864,106 +1175,113 @@ static int koro2_heapinit(fopAc_ac_c* actor) { fshop_class* i_this = (fshop_class*)actor; - i_this->field_0x402c = new dBgW(); - if (i_this->field_0x402c == NULL) { + i_this->koro2WakuBgw = new dBgW(); + if (i_this->koro2WakuBgw == NULL) { return 0; } cBgD_t* dzb = (cBgD_t*)dComIfG_getObjectRes("Fshop", 37); - if (i_this->field_0x402c->Set(dzb, 1, &i_this->field_0x4030) == 1) { + if (i_this->koro2WakuBgw->Set(dzb, 1, &i_this->field_0x4030) == 1) { return 0; } - i_this->field_0x402c->SetCrrFunc(dBgS_MoveBGProc_Typical); - i_this->field_0x402c->SetRideCallback(ride_call_back); + i_this->koro2WakuBgw->SetCrrFunc(dBgS_MoveBGProc_Typical); + i_this->koro2WakuBgw->SetRideCallback(ride_call_back); i_this->mpA_crwaku_model = ArcIX_A_crwaku_model[0]; int part_no = 0; int flag567 = actor->field_0x567 & 8; - int r29 = 0; - int r28 = 0; - int r30 = 0; - int r27 = 0; - int r26 = 0; - int r25 = 0; + int crstart_model_idx = 0; + int crgoal_model_idx = 0; + int crbox_model_idx = 0; + int crcurve_a_model_idx = 0; + int crcurve_b_model_idx = 0; + int crcurve_c_model_idx = 0; + s8* mapData = koro2_map_d[actor->field_0x567 & 7]; - for (int i = 0; i < 9; i++) { - for (int local_60 = 0; local_60 < 15; local_60++) { - int index = local_60 * 9 + i; + for (int column = 0; column < 9; column++) { + for (int row = 0; row < 15; row++) { + int index = (row * 9) + column; if (mapData[index] != 0) { - if (flag567 != 0) { - i_this->mKoro2[part_no].field_0x34 = pande_d[mapData[index]]; - i_this->mKoro2[part_no].field_0x38.x = 2.5f * (8 - i); + if (flag567) { + i_this->mKoro2[part_no].part_id = pande_d[mapData[index]]; + i_this->mKoro2[part_no].pos.x = 2.5f * (8 - column); } else { - i_this->mKoro2[part_no].field_0x34 = mapData[index]; - i_this->mKoro2[part_no].field_0x38.x = 2.5f * i; + i_this->mKoro2[part_no].part_id = mapData[index]; + i_this->mKoro2[part_no].pos.x = 2.5f * column; } - i_this->mKoro2[part_no].field_0x38.y = 2.0f; - i_this->mKoro2[part_no].field_0x38.z = 2.5f * local_60; + i_this->mKoro2[part_no].pos.y = 2.0f; + i_this->mKoro2[part_no].pos.z = 2.5f * row; - if (i_this->mKoro2[part_no].field_0x34 == 6) { - i_this->mKoro2[part_no].field_0x38.z -= 2.5f; - } else if (i_this->mKoro2[part_no].field_0x34 == 8) { - i_this->mKoro2[part_no].field_0x38.z -= 2.5f; - i_this->mKoro2[part_no].field_0x38.x -= 2.5f; - } else if (i_this->mKoro2[part_no].field_0x34 == 11) { - i_this->mKoro2[part_no].field_0x38.z += 2.5f; - i_this->mKoro2[part_no].field_0x38.x += 2.5f; + if (i_this->mKoro2[part_no].part_id == KORO2_PART_START) { + i_this->mKoro2[part_no].pos.z -= 2.5f; + } else if (i_this->mKoro2[part_no].part_id == KORO2_PART_CURVE_B_U_L) { + i_this->mKoro2[part_no].pos.z -= 2.5f; + i_this->mKoro2[part_no].pos.x -= 2.5f; + } else if (i_this->mKoro2[part_no].part_id == KORO2_PART_CURVE_B_L_U) { + i_this->mKoro2[part_no].pos.z += 2.5f; + i_this->mKoro2[part_no].pos.x += 2.5f; } - i_this->mKoro2[part_no].field_0x44.set(2.5f, 2.5f, 2.5f); + i_this->mKoro2[part_no].size.set(2.5f, 2.5f, 2.5f); - if (i_this->mKoro2[part_no].field_0x34 == 2 || i_this->mKoro2[part_no].field_0x34 == 8) { - i_this->mKoro2[part_no].field_0x50 = -0x4000; - } else if (i_this->mKoro2[part_no].field_0x34 == 4 || i_this->mKoro2[part_no].field_0x34 == 10) { - i_this->mKoro2[part_no].field_0x50 = -0x8000; - } else if (i_this->mKoro2[part_no].field_0x34 == 5 || i_this->mKoro2[part_no].field_0x34 == 11) { - i_this->mKoro2[part_no].field_0x50 = 0x4000; - } else if (i_this->mKoro2[part_no].field_0x34 == 12) { - i_this->mKoro2[part_no].field_0x50 = -0x8000; - } else if (i_this->mKoro2[part_no].field_0x34 == 14) { - i_this->mKoro2[part_no].field_0x50 = -0x4000; - } else if (i_this->mKoro2[part_no].field_0x34 == 15) { - i_this->mKoro2[part_no].field_0x50 = 0x4000; + if (i_this->mKoro2[part_no].part_id == KORO2_PART_CURVE_A_U_L || + i_this->mKoro2[part_no].part_id == KORO2_PART_CURVE_B_U_L) + { + i_this->mKoro2[part_no].rot_y = -0x4000; + } else if (i_this->mKoro2[part_no].part_id == KORO2_PART_CURVE_A_R_U || + i_this->mKoro2[part_no].part_id == KORO2_PART_CURVE_B_R_U) + { + i_this->mKoro2[part_no].rot_y = -0x8000; + } else if (i_this->mKoro2[part_no].part_id == KORO2_PART_CURVE_A_L_U || + i_this->mKoro2[part_no].part_id == KORO2_PART_CURVE_B_L_U) + { + i_this->mKoro2[part_no].rot_y = 0x4000; + } else if (i_this->mKoro2[part_no].part_id == KORO2_PART_SLOPE_D) { + i_this->mKoro2[part_no].rot_y = -0x8000; + } else if (i_this->mKoro2[part_no].part_id == KORO2_PART_SLOPE_L) { + i_this->mKoro2[part_no].rot_y = -0x4000; + } else if (i_this->mKoro2[part_no].part_id == KORO2_PART_SLOPE_R) { + i_this->mKoro2[part_no].rot_y = 0x4000; } - if (koro2_bmd[i_this->mKoro2[part_no].field_0x34 - 1] == 10) { - i_this->mKoro2[part_no].mpModel = ArcIX_A_crbox_model[r30]; - r30++; - } else if (koro2_bmd[i_this->mKoro2[part_no].field_0x34 - 1] == 15) { - i_this->mKoro2[part_no].mpModel = ArcIX_A_crstart_model[r29]; - r29++; - } else if (koro2_bmd[i_this->mKoro2[part_no].field_0x34 - 1] == 13) { - i_this->mKoro2[part_no].mpModel = ArcIX_A_crgoal_model[r28]; - r28++; - } else if (koro2_bmd[i_this->mKoro2[part_no].field_0x34 - 1] == 11) { - i_this->mKoro2[part_no].mpModel = ArcIX_A_crcurve_a_model[r27]; - r27++; - } else if (koro2_bmd[i_this->mKoro2[part_no].field_0x34 - 1] == 12) { - i_this->mKoro2[part_no].mpModel = ArcIX_A_crcurve_b_model[r26]; - r26++; - } else if (koro2_bmd[i_this->mKoro2[part_no].field_0x34 - 1] == 14) { - i_this->mKoro2[part_no].mpModel = ArcIX_A_crsaka_model[r25]; - r25++; + if (koro2_bmd[i_this->mKoro2[part_no].part_id - 1] == 10) { + i_this->mKoro2[part_no].model = ArcIX_A_crbox_model[crbox_model_idx]; + crbox_model_idx++; + } else if (koro2_bmd[i_this->mKoro2[part_no].part_id - 1] == 15) { + i_this->mKoro2[part_no].model = ArcIX_A_crstart_model[crstart_model_idx]; + crstart_model_idx++; + } else if (koro2_bmd[i_this->mKoro2[part_no].part_id - 1] == 13) { + i_this->mKoro2[part_no].model = ArcIX_A_crgoal_model[crgoal_model_idx]; + crgoal_model_idx++; + } else if (koro2_bmd[i_this->mKoro2[part_no].part_id - 1] == 11) { + i_this->mKoro2[part_no].model = ArcIX_A_crcurve_a_model[crcurve_a_model_idx]; + crcurve_a_model_idx++; + } else if (koro2_bmd[i_this->mKoro2[part_no].part_id - 1] == 12) { + i_this->mKoro2[part_no].model = ArcIX_A_crcurve_b_model[crcurve_b_model_idx]; + crcurve_b_model_idx++; + } else if (koro2_bmd[i_this->mKoro2[part_no].part_id - 1] == 14) { + i_this->mKoro2[part_no].model = ArcIX_A_crsaka_model[crcurve_c_model_idx]; + crcurve_c_model_idx++; } - if (i_this->mKoro2[part_no].mpModel == NULL) { + if (i_this->mKoro2[part_no].model == NULL) { return 0; } - i_this->mKoro2[part_no].mpBgW = new dBgW(); - if (i_this->mKoro2[part_no].mpBgW == NULL) { + i_this->mKoro2[part_no].bgw = new dBgW(); + if (i_this->mKoro2[part_no].bgw == NULL) { return 0; } - cBgD_t* dzb = (cBgD_t*)dComIfG_getObjectRes("Fshop",koro2_dzb[i_this->mKoro2[part_no].field_0x34 - 1]); - if (i_this->mKoro2[part_no].mpBgW->Set(dzb, 1, &i_this->mKoro2[part_no].field_0x04) == 1) { + cBgD_t* dzb = (cBgD_t*)dComIfG_getObjectRes("Fshop",koro2_dzb[i_this->mKoro2[part_no].part_id - 1]); + if (i_this->mKoro2[part_no].bgw->Set(dzb, 1, &i_this->mKoro2[part_no].bgMtx) == 1) { return 0; } - i_this->mKoro2[part_no].mpBgW->SetCrrFunc(dBgS_MoveBGProc_Typical); + i_this->mKoro2[part_no].bgw->SetCrrFunc(dBgS_MoveBGProc_Typical); part_no++; if (part_no >= 100) { @@ -2021,13 +1339,13 @@ static int useHeapInit(fopAc_ac_c* actor) { modelData = dComIfG_getObjectRes("Fshop", lure_d[i_this->mLure[i].field_0x24]); JUT_ASSERT(2832, modelData != NULL); - i_this->mLure[i].field_0x14 = mDoExt_J3DModel__create((J3DModelData*)modelData, 0x80000, 0x11000084); - if (i_this->mLure[i].field_0x14 == NULL) { + i_this->mLure[i].model = mDoExt_J3DModel__create((J3DModelData*)modelData, 0x80000, 0x11000084); + if (i_this->mLure[i].model == NULL) { return 0; } if (i_this->mLure[i].field_0x24 == 3) { - i_this->mLure[i].field_0x14->setUserArea((uintptr_t)&i_this->mLure[i]); + i_this->mLure[i].model->setUserArea((uintptr_t)&i_this->mLure[i]); for (u16 j = 0; j < ((J3DModelData*)modelData)->getJointNum(); j++) { if (j == 1) { @@ -2039,8 +1357,8 @@ static int useHeapInit(fopAc_ac_c* actor) { JUT_ASSERT(2852, modelData != NULL); for (int j = 0; j < 2; j++) { - i_this->mLure[i].field_0x18[j] = mDoExt_J3DModel__create((J3DModelData*)modelData, 0x20000, 0x11000084); - if (i_this->mLure[i].field_0x18[j] == NULL) { + i_this->mLure[i].hookModel[j] = mDoExt_J3DModel__create((J3DModelData*)modelData, 0x20000, 0x11000084); + if (i_this->mLure[i].hookModel[j] == NULL) { return 0; } } @@ -2067,16 +1385,16 @@ static int useHeapInit(fopAc_ac_c* actor) { i_this->mRod[i].field_0x54 = 30.0f * (1.0f + cM_rndF2(0.15f)); } - static int rod_d[] = {0x19, 0x18,}; + static int rod_d[] = {0x19, 0x18}; modelData = dComIfG_getObjectRes("Fshop", rod_d[i_this->mRod[i].field_0x4c]); JUT_ASSERT(2903, modelData != NULL); - i_this->mRod[i].field_0x14 = mDoExt_J3DModel__create((J3DModelData*)modelData, 0x80000, 0x11000084); - if (i_this->mRod[i].field_0x14 == NULL) { + i_this->mRod[i].model = mDoExt_J3DModel__create((J3DModelData*)modelData, 0x80000, 0x11000084); + if (i_this->mRod[i].model == NULL) { return 0; } - i_this->mRod[i].field_0x14->setUserArea((uintptr_t)&i_this->mRod[i]); - i_this->mRod[i].field_0x58 = cM_rndF2(65536.0f); + i_this->mRod[i].model->setUserArea((uintptr_t)&i_this->mRod[i]); + i_this->mRod[i].rot_x = cM_rndF2(65536.0f); for (u16 j = 0; j < ((J3DModelData*)modelData)->getJointNum(); j++) { if (j == 1) { @@ -2088,8 +1406,8 @@ static int useHeapInit(fopAc_ac_c* actor) { JUT_ASSERT(2923, modelData != NULL); for (int j = 0; j < 6; j++) { - i_this->mRod[i].field_0x18[j] = mDoExt_J3DModel__create((J3DModelData*)modelData, 0x20000, 0x11000084); - if (i_this->mRod[i].field_0x18[j] == NULL) { + i_this->mRod[i].ringModel[j] = mDoExt_J3DModel__create((J3DModelData*)modelData, 0x20000, 0x11000084); + if (i_this->mRod[i].ringModel[j] == NULL) { return 0; } } @@ -2126,8 +1444,8 @@ static int useHeapInit(fopAc_ac_c* actor) { JUT_ASSERT(2969, modelData != NULL); - i_this->mTsubo[i].field_0x14 = mDoExt_J3DModel__create((J3DModelData*)modelData, 0x80000, 0x11000084); - if (i_this->mTsubo[i].field_0x14 == NULL) { + i_this->mTsubo[i].model = mDoExt_J3DModel__create((J3DModelData*)modelData, 0x80000, 0x11000084); + if (i_this->mTsubo[i].model == NULL) { return 0; } } @@ -2138,26 +1456,26 @@ static int useHeapInit(fopAc_ac_c* actor) { modelData = dComIfG_getObjectRes("Fshop", 0x12); JUT_ASSERT(3035, modelData != NULL); - i_this->field_0x6b30 = mDoExt_J3DModel__create((J3DModelData*)modelData, 0x80000, 0x11000084); - if (i_this->field_0x6b30 == NULL) { + i_this->canoeModel = mDoExt_J3DModel__create((J3DModelData*)modelData, 0x80000, 0x11000084); + if (i_this->canoeModel == NULL) { return 0; } - i_this->field_0x6b68 = new dBgW(); - if (i_this->field_0x6b68 == NULL) { + i_this->tableBgw = new dBgW(); + if (i_this->tableBgw == NULL) { return 0; } - if (i_this->field_0x6b68->Set((cBgD_t*)dComIfG_getObjectRes("Fshop", 0x26), 1, &i_this->field_0x6b38) == 1) { + if (i_this->tableBgw->Set((cBgD_t*)dComIfG_getObjectRes("Fshop", 0x26), 1, &i_this->field_0x6b38) == 1) { return 0; } - i_this->field_0x6b68->SetCrrFunc(dBgS_MoveBGProc_Typical); + i_this->tableBgw->SetCrrFunc(dBgS_MoveBGProc_Typical); modelData = dComIfG_getObjectRes("Fshop", 0x15); JUT_ASSERT(3069, modelData != NULL); - i_this->field_0x3ff4 = mDoExt_J3DModel__create((J3DModelData*)modelData, 0x80000, 0x11000084); - if (i_this->field_0x3ff4 == 0) { + i_this->hatModel = mDoExt_J3DModel__create((J3DModelData*)modelData, 0x80000, 0x11000084); + if (i_this->hatModel == NULL) { return 0; } @@ -2212,8 +1530,8 @@ static int useHeapInit(fopAc_ac_c* actor) { if ((int)dComIfGs_getEventReg(0xF47F) >= 10) { modelData = dComIfG_getObjectRes("Fshop", 0x11); JUT_ASSERT(3137, modelData != NULL); - i_this->field_0x4004 = mDoExt_J3DModel__create((J3DModelData*)modelData, 0x80000, 0x11000084); - if (i_this->field_0x4004 == 0) { + i_this->photoModel = mDoExt_J3DModel__create((J3DModelData*)modelData, 0x80000, 0x11000084); + if (i_this->photoModel == NULL) { return 0; } } @@ -2227,8 +1545,8 @@ static int BalluseHeapInit(fopAc_ac_c* actor) { void* modelData = dComIfG_getObjectRes("Fshop", 9); JUT_ASSERT(3157, modelData != NULL); - i_this->field_0x4070 = mDoExt_J3DModel__create((J3DModelData*)modelData, 0x80000, 0x11000084); - if (i_this->field_0x4070 == 0) { + i_this->ballModel = mDoExt_J3DModel__create((J3DModelData*)modelData, 0x80000, 0x11000084); + if (i_this->ballModel == NULL) { return 0; } @@ -2240,26 +1558,26 @@ static int daFshop_Create(fopAc_ac_c* actor) { fshop_class* i_this = (fshop_class*)actor; fopAcM_ct(actor, fshop_class); - int sp3C = dComIfG_resLoad(&i_this->mPhase, "Fshop"); - if (sp3C == cPhs_COMPLEATE_e) { + int phase_state = dComIfG_resLoad(&i_this->mPhase, "Fshop"); + if (phase_state == cPhs_COMPLEATE_e) { OS_REPORT("FSHOP PARAM %x\n", fopAcM_GetParam(actor)); if ((fopAcM_GetParam(actor) & 0xFF) == 0x23) { if (!fopAcM_entrySolidHeap(actor, BalluseHeapInit, 0x800)) { OS_REPORT("//////////////FSHOP BALL SET NON !!\n"); - return 5; + return cPhs_ERROR_e; } - i_this->field_0x40b4.Set(fopAcM_GetPosition_p(actor), fopAcM_GetOldPosition_p(actor), actor, 1, &i_this->field_0x4074, fopAcM_GetSpeed_p(actor), NULL, NULL); - i_this->field_0x4074.SetWall(9.0f, 11.0f); - i_this->field_0x40b4.OnWallSort(); - return sp3C; + i_this->ballAcch.Set(fopAcM_GetPosition_p(actor), fopAcM_GetOldPosition_p(actor), actor, 1, &i_this->ballAcchcir, fopAcM_GetSpeed_p(actor), NULL, NULL); + i_this->ballAcchcir.SetWall(9.0f, 11.0f); + i_this->ballAcch.OnWallSort(); + return phase_state; } if ((s8)(fopAcM_GetParam(actor) & 0xFF) >= 100) { i_this->field_0x400e = (fopAcM_GetParam(actor) & 0xFF) - 100; actor->field_0x567 = ((i_this->field_0x400e - 1) | (dComIfGs_getEventReg(0xF63F) & 8)); - u32 sp58[] = { + u32 heapsizes[] = { 0x84A0, 0x9AC0, 0xB440, @@ -2270,24 +1588,24 @@ static int daFshop_Create(fopAc_ac_c* actor) { 0xA9E0, }; - if (!fopAcM_entrySolidHeap(actor, koro2_heapinit, sp58[i_this->field_0x400e - 1])) { + if (!fopAcM_entrySolidHeap(actor, koro2_heapinit, heapsizes[i_this->field_0x400e - 1])) { OS_REPORT("//////////////FSHOP KORO222 SET NON !!\n"); - return 5; + return cPhs_ERROR_e; } - if (i_this->field_0x402c != NULL && dComIfG_Bgsp().Regist(i_this->field_0x402c, actor)) { - return 5; + if (i_this->koro2WakuBgw != NULL && dComIfG_Bgsp().Regist(i_this->koro2WakuBgw, actor)) { + return cPhs_ERROR_e; } for (int i = 0; i < 100; i++) { - if (i_this->mKoro2[i].mpBgW != NULL && dComIfG_Bgsp().Regist(i_this->mKoro2[i].mpBgW, actor)) { - return 5; + if (i_this->mKoro2[i].bgw != NULL && dComIfG_Bgsp().Regist(i_this->mKoro2[i].bgw, actor)) { + return cPhs_ERROR_e; } } i_this->field_0x428d = 30; i_this->field_0x400d = 1; - return sp3C; + return phase_state; } fopAcM_SetParam(actor, 0); @@ -2297,13 +1615,13 @@ static int daFshop_Create(fopAc_ac_c* actor) { if (!fopAcM_entrySolidHeap(actor, useHeapInit, 0x5B000)) { OS_REPORT("//////////////FSHOP SET NON !!\n"); - return 5; + return cPhs_ERROR_e; } OS_REPORT("//////////////FSHOP SET 2 !!\n"); - if (i_this->field_0x6b68 != NULL && dComIfG_Bgsp().Regist(i_this->field_0x6b68, actor)) { - return 5; + if (i_this->tableBgw != NULL && dComIfG_Bgsp().Regist(i_this->tableBgw, actor)) { + return cPhs_ERROR_e; } for (int i = 0; i < 60; i++) { @@ -2367,30 +1685,30 @@ static int daFshop_Create(fopAc_ac_c* actor) { sp24 = dComIfGs_getEventReg(check_kind[i]); } - if (sp24 >= 0xA) { - u32 sp28 = (sp24 << 8) | 0xFFFF0000 | i; - fopAcM_create(PROC_MG_FISH, sp28, &actor->current.pos, fopAcM_GetRoomNo(actor), NULL, NULL, -1); + if (sp24 >= 10) { + u32 parameters = (sp24 << 8) | 0xFFFF0000 | i; + fopAcM_create(PROC_MG_FISH, parameters, &actor->current.pos, fopAcM_GetRoomNo(actor), NULL, NULL, -1); } } - cXyz sp48(-648.0f + YREG_F(7), 215.0f + YREG_F(8), 380.0f + YREG_F(9)); - csXyz sp40(0, 0, 0); - fopAcM_create(PROC_OBJ_KAGE, 0xFFFFFF01, &sp48, fopAcM_GetRoomNo(actor), &sp40, NULL, -1); + cXyz work_pos(-648.0f + YREG_F(7), 215.0f + YREG_F(8), 380.0f + YREG_F(9)); + csXyz work_angle(0, 0, 0); + fopAcM_create(PROC_OBJ_KAGE, 0xFFFFFF01, &work_pos, fopAcM_GetRoomNo(actor), &work_angle, NULL, -1); for (int i = 0; i < 8; i++) { fopAcM_create(PROC_MG_FISH, 0xFFFF2005, &actor->current.pos, fopAcM_GetRoomNo(actor), NULL, NULL, -1); } - sp48.set(-131.0f, 3000.0f + nREG_F(7), -4500.0f); - fopAcM_create(PROC_NPC_TK, -1, &sp48, fopAcM_GetRoomNo(actor), NULL, NULL, -1); + work_pos.set(-131.0f, 3000.0f + nREG_F(7), -4500.0f); + fopAcM_create(PROC_NPC_TK, -1, &work_pos, fopAcM_GetRoomNo(actor), NULL, NULL, -1); for (int i = 0; i < 5; i++) { - sp48.set(-450.0f, 0.0f, -878.0f); - fopAcM_create(PROC_BD, 0xFFFFFFFF, &sp48, fopAcM_GetRoomNo(actor), NULL, NULL, -1); + work_pos.set(-450.0f, 0.0f, -878.0f); + fopAcM_create(PROC_BD, 0xFFFFFFFF, &work_pos, fopAcM_GetRoomNo(actor), NULL, NULL, -1); } } - return sp3C; + return phase_state; } /* 808708BC-808708DC -00001 0020+00 1/0 0/0 0/0 .data l_daFshop_Method */ diff --git a/src/d/actor/d_a_movie_player.cpp b/src/d/actor/d_a_movie_player.cpp index 0a0b1ff8d3..a19713d8af 100644 --- a/src/d/actor/d_a_movie_player.cpp +++ b/src/d/actor/d_a_movie_player.cpp @@ -9,18 +9,12 @@ // in other TUs, but not here. #pragma dont_inline on -#include -#include -#include #include "JSystem/JKernel/JKRExpHeap.h" #include "JSystem/JAudio2/JASAiCtrl.h" +#include "JSystem/JAudio2/JASDriverIF.h" #include "d/actor/d_a_movie_player.h" -#include "d/d_com_inf_game.h" -#include "dol2asm.h" #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" { @@ -70,13 +64,12 @@ static u32 THPAudioDecode(s16* audioBuffer, u8* audioFrame, s32 flag) { yn += (sample << decInfo.scale) << 11; yn <<= 5; - if (sample > 0x8000) { - yn += 0x10000; - } else if ((sample == 0x8000) && ((yn & 0x10000) != 0)) { - yn += 0x10000; - } - - yn += 0x8000; + if ((u16)(yn & 0xffff) > 0x8000) { + yn += 0x10000; + } else if ((u16)(yn & 0xffff) == 0x8000) { + if ((yn & 0x10000)) + yn += 0x10000; + } if (yn > 2147483647LL) { yn = 2147483647LL; @@ -105,7 +98,15 @@ static u32 THPAudioDecode(s16* audioBuffer, u8* audioFrame, s32 flag) { yn += header->lCoef[decInfo.predictor][0] * yn1; yn += (sample << decInfo.scale) << 11; yn <<= 5; - yn += 0x8000; + + if ((u16)(yn & 0xffff) > 0x8000) { + yn += 0x10000; + } else { + if ((u16)(yn & 0xffff) == 0x8000) { + if ((yn & 0x10000)) + yn += 0x10000; + } + } if (yn > 2147483647LL) { yn = 2147483647LL; @@ -133,7 +134,14 @@ static u32 THPAudioDecode(s16* audioBuffer, u8* audioFrame, s32 flag) { yn += (sample << decInfo.scale) << 11; yn <<= 5; - yn += 0x8000; + if ((u16)(yn & 0xffff) > 0x8000) { + yn += 0x10000; + } else { + if ((u16)(yn & 0xffff) == 0x8000) { + if ((yn & 0x10000)) + yn += 0x10000; + } + } if (yn > 2147483647LL) { yn = 2147483647LL; @@ -276,13 +284,13 @@ static s32 THPVideoDecode(void* file, void* tileY, void* tileU, void* tileV, voi } __THPWorkArea = (u8*)work; - __THPInfo = (THPFileInfo*)OSRoundUp32B(__THPWorkArea); + __THPInfo = (THPFileInfo*)OSRoundUp32B(__THPWorkArea); __THPWorkArea = (u8*)OSRoundUp32B(__THPWorkArea) + sizeof(THPFileInfo); DCZeroRange(__THPInfo, sizeof(THPFileInfo)); - __THPInfo->cnt = 33; + __THPInfo->cnt = 33; __THPInfo->decompressedY = 0; - __THPInfo->c = (u8*)file; - all_done = FALSE; + __THPInfo->c = (u8*)file; + all_done = FALSE; for (;;) { if ((*(__THPInfo->c)++) != 255) { @@ -465,7 +473,7 @@ static u8 __THPReadScaneHeader() { for (i = 0; i < 3; i++) { utmp8 = (*(__THPInfo->c)++); - utmp8 = (*(__THPInfo->c)++); + utmp8 = (*(__THPInfo->c)++); __THPInfo->components[i].DCTableSelector = (u8)(utmp8 >> 4); __THPInfo->components[i].ACTableSelector = (u8)(utmp8 & 15); @@ -479,7 +487,7 @@ static u8 __THPReadScaneHeader() { } __THPInfo->c += 3; - __THPInfo->MCUsPerRow = (u16)THPROUNDUP(__THPInfo->xPixelSize, 16); + __THPInfo->MCUsPerRow = (u16)THPROUNDUP(__THPInfo->xPixelSize, 16); __THPInfo->components[0].predDC = 0; __THPInfo->components[1].predDC = 0; __THPInfo->components[2].predDC = 0; @@ -502,35 +510,37 @@ static const f64 __THPAANScaleFactor[8] = { /* 808731B4-80873574 000AD4 03C0+00 1/1 0/0 0/0 .text __THPReadQuantizationTable */ // NONMATCHING - regalloc static u8 __THPReadQuantizationTable() { - f32 q_temp[64]; + u16 length, id, i, row, col; + f32 q_temp[64]; - u16 length = (u16)((__THPInfo->c)[0] << 8 | (__THPInfo->c)[1]); - __THPInfo->c += 2; - length -= 2; + length = (u16)((__THPInfo->c)[0] << 8 | (__THPInfo->c)[1]); + __THPInfo->c += 2; + length -= 2; - do { - u16 i; - u16 id = (*(__THPInfo->c)++); + for (;;) { + id = (*(__THPInfo->c)++); - for (i = 0; i < 64; i++) { - q_temp[__THPJpegNaturalOrder[i]] = (f32)(*(__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++; - } - } + i = 0; + for (row = 0; row < 8; row++) { + for (col = 0; col < 8; col++) { + __THPInfo->quantTabs[id][i] + = (f32)((f64)q_temp[i] * __THPAANScaleFactor[row] + * __THPAANScaleFactor[col]); + i++; + } + } - length -= 65; - } while (length != 0); + length -= 65; + if (!length) { + break; + } + } - return 0; + return 0; } /* 80873574-8087375C 000E94 01E8+00 1/1 0/0 0/0 .text __THPReadHuffmanTableSpecification @@ -541,17 +551,17 @@ static u8 __THPReadHuffmanTableSpecification() { __THPHuffmanSizeTab = __THPWorkArea; __THPHuffmanCodeTab = (u16*)((u32)__THPWorkArea + 256 + 1); - length = (u16)((__THPInfo->c)[0] << 8 | (__THPInfo->c)[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); + 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; + tab_index = (u8)((id << 1) + t_class); + num_Vij = 0; for (i = 0; i < 16; i++) { num_Vij += (*(__THPInfo->c)++); @@ -593,9 +603,9 @@ static void __THPHuffGenerateCodeTable() { u8 si; u16 p, code; - p = 0; + p = 0; code = 0; - si = __THPHuffmanSizeTab[0]; + si = __THPHuffmanSizeTab[0]; while (__THPHuffmanSizeTab[p]) { while (__THPHuffmanSizeTab[p] == si) { @@ -643,7 +653,7 @@ static void __THPPrepBitStream() { u32* ptr; u32 offset, i, j, k; - ptr = (u32*)((u32)__THPInfo->c & 0xFFFFFFFC); + ptr = (u32*)((u32)__THPInfo->c & 0xFFFFFFFC); offset = (u32)__THPInfo->c & 3; if (__THPInfo->cnt != 33) { @@ -652,7 +662,7 @@ static void __THPPrepBitStream() { __THPInfo->cnt = (offset * 8) + 1; } - __THPInfo->c = (u8*)ptr; + __THPInfo->c = (u8*)ptr; __THPInfo->currByte = *ptr; for (i = 0; i < 4; i++) { @@ -704,7 +714,7 @@ static void __THPDecompressYUV(void* tileY, void* tileU, void* tileV) { __THPInfo->dLC[2] = (u8*)tileV; currentY = __THPInfo->decompressedY; - targetY = __THPInfo->yPixelSize; + targetY = __THPInfo->yPixelSize; __THPGQRSetup(); __THPPrepBitStream(); @@ -791,31 +801,31 @@ static void __THPDecompressiMCURow512x448() { __THPHuffDecodeDCTCompU(__THPInfo, __THPMCUBuffer[4]); __THPHuffDecodeDCTCompV(__THPInfo, __THPMCUBuffer[5]); - comp = &__THPInfo->components[0]; + comp = &__THPInfo->components[0]; Gbase = __THPLCWork512[0]; - Gwid = 512; - Gq = __THPInfo->quantTabs[comp->quantizationTableSelector]; + 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]; + comp = &__THPInfo->components[1]; Gbase = __THPLCWork512[1]; - Gwid = 256; - Gq = __THPInfo->quantTabs[comp->quantizationTableSelector]; + Gwid = 256; + Gq = __THPInfo->quantTabs[comp->quantizationTableSelector]; x_pos /= 2; __THPInverseDCTNoYPos(__THPMCUBuffer[4], x_pos); - comp = &__THPInfo->components[2]; + comp = &__THPInfo->components[2]; Gbase = __THPLCWork512[2]; - Gq = __THPInfo->quantTabs[comp->quantizationTableSelector]; + 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); + __THPInfo->cnt = 1 + ((__THPInfo->cnt + 6) & 0xFFFFFFF8); if (__THPInfo->cnt > 33) { __THPInfo->cnt = 33; @@ -843,13 +853,13 @@ static void __THPInverseDCTY8(register THPCoeff* in, register u32 xPos) { 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 cc4 = 1.414213562F; + register f32 cc2 = 1.847759065F; register f32 cc2c6s = 1.082392200F; register f32 cc2c6a = -2.613125930F; - register f32 bias = 1024.0F; + register f32 bias = 1024.0F; - q = Gq; + q = Gq; ws = &__THPIDCTWorkspace[0] - 2; { @@ -1023,7 +1033,7 @@ static void __THPInverseDCTY8(register THPCoeff* in, register u32 xPos) { { register THPSample* obase = Gbase; - register u32 wid = Gwid; + register u32 wid = Gwid; register u32 itmp0, off0, off1; register THPSample *out0, *out1; @@ -1158,13 +1168,13 @@ static void __THPInverseDCTNoYPos(register THPCoeff* in, register u32 xPos) { 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 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 f32 bias = 1024.0F; + q = Gq; + ws = &__THPIDCTWorkspace[0] - 2; { register u32 itmp0, itmp1, itmp2, itmp3; @@ -1336,7 +1346,7 @@ static void __THPInverseDCTNoYPos(register THPCoeff* in, register u32 xPos) { { register THPSample* obase = Gbase; - register u32 wid = Gwid; + register u32 wid = Gwid; register u32 itmp0, off0, off1; register THPSample *out0, *out1; @@ -1480,26 +1490,26 @@ static void __THPDecompressiMCURow640x480() { __THPHuffDecodeDCTCompU(__THPInfo, __THPMCUBuffer[4]); __THPHuffDecodeDCTCompV(__THPInfo, __THPMCUBuffer[5]); - comp = &__THPInfo->components[0]; + comp = &__THPInfo->components[0]; Gbase = __THPLCWork640[0]; - Gwid = 640; - Gq = __THPInfo->quantTabs[comp->quantizationTableSelector]; + 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]; + comp = &__THPInfo->components[1]; Gbase = __THPLCWork640[1]; - Gwid = 320; - Gq = __THPInfo->quantTabs[comp->quantizationTableSelector]; + Gwid = 320; + Gq = __THPInfo->quantTabs[comp->quantizationTableSelector]; x_pos /= 2; __THPInverseDCTNoYPos(__THPMCUBuffer[4], x_pos); - comp = &__THPInfo->components[2]; + comp = &__THPInfo->components[2]; Gbase = __THPLCWork640[2]; - Gq = __THPInfo->quantTabs[comp->quantizationTableSelector]; + Gq = __THPInfo->quantTabs[comp->quantizationTableSelector]; __THPInverseDCTNoYPos(__THPMCUBuffer[5], x_pos); if (__THPInfo->RST != 0) { @@ -1548,20 +1558,20 @@ static void __THPDecompressiMCURowNxN() { __THPHuffDecodeDCTCompU(__THPInfo, __THPMCUBuffer[4]); __THPHuffDecodeDCTCompV(__THPInfo, __THPMCUBuffer[5]); - comp = &__THPInfo->components[0]; + comp = &__THPInfo->components[0]; Gbase = __THPLCWork640[0]; - Gwid = x; - Gq = __THPInfo->quantTabs[comp->quantizationTableSelector]; + 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]; + comp = &__THPInfo->components[1]; Gbase = __THPLCWork640[1]; - Gwid = x / 2; - Gq = __THPInfo->quantTabs[comp->quantizationTableSelector]; + Gwid = x / 2; + Gq = __THPInfo->quantTabs[comp->quantizationTableSelector]; x_pos /= 2; __THPInverseDCTNoYPos(__THPMCUBuffer[4], x_pos); @@ -1574,7 +1584,7 @@ static void __THPDecompressiMCURowNxN() { __THPInfo->currMCU--; if (__THPInfo->currMCU == 0) { __THPInfo->currMCU = __THPInfo->nMCU; - __THPInfo->cnt = 1 + ((__THPInfo->cnt + 6) & 0xFFFFFFF8); + __THPInfo->cnt = 1 + ((__THPInfo->cnt + 6) & 0xFFFFFFF8); if (__THPInfo->cnt > 32) { __THPInfo->cnt = 33; @@ -1667,7 +1677,7 @@ static void __THPHuffDecodeDCTCompY(register THPFileInfo* info, THPCoeff* block) }; __dcbz((void*)block, 96); - dc = (s16)(info->components[0].predDC + diff); + dc = (s16)(info->components[0].predDC + diff); block[0] = info->components[0].predDC = dc; } @@ -1837,7 +1847,7 @@ static void __THPHuffDecodeDCTCompY(register THPFileInfo* info, THPCoeff* block) // clang-format on } while (code > h->maxCode[ssss]); - cnt = (u32)(ssss + 1); + cnt = (u32)(ssss + 1); ssss = (h->Vij[(s32)(code + h->valPtr[ssss])]); goto _DoneDecodeTab; @@ -2361,7 +2371,7 @@ static void __THPHuffDecodeDCTCompU(register THPFileInfo* info, THPCoeff* block) } __dcbz((void*)block, 96); - dc = (s16)(info->components[1].predDC + diff); + dc = (s16)(info->components[1].predDC + diff); block[0] = info->components[1].predDC = dc; for (k = 1; k < 64; k++) { @@ -2498,7 +2508,7 @@ static void __THPHuffDecodeDCTCompV(register THPFileInfo* info, THPCoeff* block) __dcbz((void*)block, 96); - dc = (s16)(info->components[2].predDC + diff); + dc = (s16)(info->components[2].predDC + diff); block[0] = info->components[2].predDC = dc; for (k = 1; k < 64; k++) { @@ -2578,7 +2588,7 @@ static BOOL THPInit() { __THPLCWork512[2] = base; base += 0x200; - base = (u8*)(0xE000 << 16); + base = (u8*)(0xE000 << 16); __THPLCWork640[0] = base; base += 0x2800; __THPLCWork640[1] = base; @@ -2597,7 +2607,7 @@ static BOOL THPInit() { #endif /* 80879BD0-80879DA0 000630 01D0+00 28/29 0/0 0/0 .bss daMP_ActivePlayer */ -static daMP_Player_c daMP_ActivePlayer ALIGN_DECL(16); +static daMP_THPPlayer daMP_ActivePlayer ALIGN_DECL(16); /* 80879DA0-80879DA4 000800 0004+00 2/3 0/0 0/0 .bss daMP_ReadThreadCreated */ static BOOL daMP_ReadThreadCreated; @@ -2610,28 +2620,26 @@ static OSMessageQueue daMP_ReadedBufferQueue; /* 80875880-808758B4 0031A0 0034+00 2/2 0/0 0/0 .text daMP_PopReadedBuffer__Fv */ void* daMP_PopReadedBuffer() { - OSMessage msg; - OSReceiveMessage(&daMP_ReadedBufferQueue, &msg, 1); - return msg; + OSMessage buffer; + OSReceiveMessage(&daMP_ReadedBufferQueue, &buffer, 1); + return buffer; } /* 808758B4-808758E4 0031D4 0030+00 1/1 0/0 0/0 .text daMP_PushReadedBuffer__FPv */ -void daMP_PushReadedBuffer(void* r3) { - OSMessage msg = (OSMessage)r3; - OSSendMessage(&daMP_ReadedBufferQueue, msg, 1); +void daMP_PushReadedBuffer(void* buffer) { + OSSendMessage(&daMP_ReadedBufferQueue, buffer, 1); } /* 808758E4-80875918 003204 0034+00 1/1 0/0 0/0 .text daMP_PopFreeReadBuffer__Fv */ -daMP_THPReadBuffer* daMP_PopFreeReadBuffer() { - OSMessage msg; - OSReceiveMessage(&daMP_FreeReadBufferQueue, &msg, 1); - return (daMP_THPReadBuffer*)msg; +void* daMP_PopFreeReadBuffer() { + OSMessage buffer; + OSReceiveMessage(&daMP_FreeReadBufferQueue, &buffer, 1); + return buffer; } /* 80875918-80875948 003238 0030+00 2/2 0/0 0/0 .text daMP_PushFreeReadBuffer__FPv */ -void daMP_PushFreeReadBuffer(void* r3) { - OSMessage msg = (OSMessage)r3; - OSSendMessage(&daMP_FreeReadBufferQueue, msg, 1); +void daMP_PushFreeReadBuffer(void* buffer) { + OSSendMessage(&daMP_FreeReadBufferQueue, buffer, 1); } /* 80879DE4-80879E04 000844 0020+00 2/3 0/0 0/0 .bss daMP_ReadedBufferQueue2 */ @@ -2639,15 +2647,14 @@ static OSMessageQueue daMP_ReadedBufferQueue2; /* 80875948-8087597C 003268 0034+00 1/1 0/0 0/0 .text daMP_PopReadedBuffer2__Fv */ void* daMP_PopReadedBuffer2() { - OSMessage msg; - OSReceiveMessage(&daMP_ReadedBufferQueue2, &msg, 1); - return msg; + OSMessage buffer; + OSReceiveMessage(&daMP_ReadedBufferQueue2, &buffer, 1); + return buffer; } /* 8087597C-808759AC 00329C 0030+00 1/1 0/0 0/0 .text daMP_PushReadedBuffer2__FPv */ -void daMP_PushReadedBuffer2(void* r3) { - OSMessage msg = (OSMessage)r3; - OSSendMessage(&daMP_ReadedBufferQueue2, msg, 1); +void daMP_PushReadedBuffer2(void* buffer) { + OSSendMessage(&daMP_ReadedBufferQueue2, buffer, 1); } /* 80879E04-80879E2C 000864 0028+00 0/1 0/0 0/0 .bss daMP_FreeReadBufferMessage */ @@ -2678,41 +2685,44 @@ void daMP_ReadThreadCancel() { } /* 80875A28-80875B0C 003348 00E4+00 1/1 0/0 0/0 .text daMP_Reader__FPv */ -void daMP_Reader(void*) { - daMP_THPReadBuffer* readBuf; - int r30; - int r29; - int r28; - int readBytes; - r28 = 0; - r30 = daMP_ActivePlayer.field_0xb8; - r29 = daMP_ActivePlayer.field_0xbc; - while (true) { - readBuf = daMP_PopFreeReadBuffer(); - 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++; - } +void* daMP_Reader(void*) { + daMP_THPReadBuffer* buf; + s32 curFrame; + s32 status; + s32 offset; + s32 initReadSize; + s32 frame = 0; + + offset = daMP_ActivePlayer.initOffset; + initReadSize = daMP_ActivePlayer.initReadSize; + + while (TRUE) { + buf = (daMP_THPReadBuffer*)daMP_PopFreeReadBuffer(); + status = DVDReadPrio(&daMP_ActivePlayer.fileInfo, buf->ptr, initReadSize, offset, 2); + if (status != initReadSize) { + if (status == -1) + daMP_ActivePlayer.dvdError = -1; + if (frame == 0) + daMP_PrepareReady(FALSE); + + OSSuspendThread(&daMP_ReadThread); + } + + buf->frameNumber = frame; + daMP_PushReadedBuffer(buf); + offset += initReadSize; + initReadSize = daMP_NEXT_READ_SIZE(buf); + + curFrame = (frame + daMP_ActivePlayer.initReadFrame) % daMP_ActivePlayer.header.numFrames; + if (curFrame == daMP_ActivePlayer.header.numFrames - 1) { + if (daMP_ActivePlayer.playFlag & 1) + offset = daMP_ActivePlayer.header.movieDataOffsets; + else + OSSuspendThread(&daMP_ReadThread); + } + + frame++; + } } /* 8087A198-8087C198 000BF8 2000+00 0/1 0/0 0/0 .bss daMP_ReadThreadStack */ @@ -2723,17 +2733,16 @@ static BOOL daMP_VideoDecodeThreadCreated; /* 80875B18-80875BC8 003438 00B0+00 1/1 0/0 0/0 .text daMP_CreateReadThread__Fl */ static BOOL daMP_CreateReadThread(s32 param_0) { - // NONMATCHING - if (!OSCreateThread(&daMP_ReadThread, (void*(*)(void*))daMP_Reader, 0, daMP_ReadThreadStack + sizeof(daMP_ReadThreadStack), sizeof(daMP_ReadThreadStack), param_0, 1)) { + 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; + return FALSE; } OSInitMessageQueue(&daMP_FreeReadBufferQueue, daMP_FreeReadBufferMessage, 10); OSInitMessageQueue(&daMP_ReadedBufferQueue, daMP_ReadedBufferMessage, 10); OSInitMessageQueue(&daMP_ReadedBufferQueue2, daMP_ReadedBufferMessage2, 10); daMP_ReadThreadCreated = TRUE; - return 1; + return TRUE; } /* 8087C1A0-8087C4B8 002C00 0318+00 4/5 0/0 0/0 .bss daMP_VideoDecodeThread */ @@ -2746,35 +2755,33 @@ static u8 daMP_VideoDecodeThreadStack[0x64000]; static OSMessageQueue daMP_FreeTextureSetQueue; /* 80875BC8-80875BFC 0034E8 0034+00 1/1 0/0 0/0 .text daMP_PopFreeTextureSet__Fv */ -OSMessage daMP_PopFreeTextureSet() { - OSMessage msg; - OSReceiveMessage(&daMP_FreeTextureSetQueue, &msg, 1); - return msg; +void* daMP_PopFreeTextureSet() { + OSMessage tex; + OSReceiveMessage(&daMP_FreeTextureSetQueue, &tex, 1); + return tex; } /* 80875BFC-80875C2C 00351C 0030+00 2/2 0/0 0/0 .text daMP_PushFreeTextureSet__FPv */ -void daMP_PushFreeTextureSet(void* r3) { - OSMessage msg = (OSMessage)r3; - OSSendMessage(&daMP_FreeTextureSetQueue, msg, 0); +void daMP_PushFreeTextureSet(void* tex) { + OSSendMessage(&daMP_FreeTextureSetQueue, tex, 0); } /* 808E04D8-808E04F8 066F38 0020+00 2/2 0/0 0/0 .bss daMP_DecodedTextureSetQueue */ static OSMessageQueue daMP_DecodedTextureSetQueue; /* 80875C2C-80875C70 00354C 0044+00 1/1 0/0 0/0 .text daMP_PopDecodedTextureSet__Fl */ -void* daMP_PopDecodedTextureSet(s32 r3) { - OSMessage msg; - if (OSReceiveMessage(&daMP_DecodedTextureSetQueue, &msg, r3) == TRUE) { - return msg; +void* daMP_PopDecodedTextureSet(s32 flags) { + OSMessage tex; + if (OSReceiveMessage(&daMP_DecodedTextureSetQueue, &tex, flags) == TRUE) { + return tex; } else { return NULL; } } /* 80875C70-80875CA0 003590 0030+00 1/1 0/0 0/0 .text daMP_PushDecodedTextureSet__FPv */ -void daMP_PushDecodedTextureSet(void* r3) { - OSMessage msg = (OSMessage)r3; - OSSendMessage(&daMP_DecodedTextureSetQueue, msg, 1); +void daMP_PushDecodedTextureSet(void* tex) { + OSSendMessage(&daMP_DecodedTextureSetQueue, tex, 1); } /* 808E04F8-808E0504 066F58 000C+00 0/0 0/0 0/0 .bss daMP_FreeTextureSetMessage */ @@ -2787,33 +2794,148 @@ static OSMessage daMP_DecodedTextureSetMessage[3]; 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) { - // NONMATCHING +static void daMP_VideoDecode(daMP_THPReadBuffer* readBuffer) { + THPTextureSet* textureSet; + s32 i; + u32* tileOffsets; + u8* tile; + + tileOffsets = (u32*)(readBuffer->ptr + 8); + tile = &readBuffer->ptr[daMP_ActivePlayer.compInfo.numComponents * 4] + 8; + textureSet = (THPTextureSet*)daMP_PopFreeTextureSet(); + + for (i = 0; i < daMP_ActivePlayer.compInfo.numComponents; i++) { + switch (daMP_ActivePlayer.compInfo.frameComp[i]) { + case 0: { + if ((daMP_ActivePlayer.videoError = THPVideoDecode( + tile, textureSet->ytexture, textureSet->utexture, + textureSet->vtexture, daMP_ActivePlayer.thpWork))) { + if (daMP_First) { + daMP_PrepareReady(FALSE); + daMP_First = FALSE; + } + OSSuspendThread(&daMP_VideoDecodeThread); + } + textureSet->frameNumber = readBuffer->frameNumber; + daMP_PushDecodedTextureSet(textureSet); + BOOL enable = OSDisableInterrupts(); + daMP_ActivePlayer.videoDecodeCount++; + OSRestoreInterrupts(enable); + } + } + + tile += *tileOffsets; + tileOffsets++; + } + + if (daMP_First) { + daMP_PrepareReady(1); + daMP_First = 0; + } } /* 80875DD8-80875EA0 0036F8 00C8+00 1/1 0/0 0/0 .text daMP_VideoDecoder__FPv */ -static void daMP_VideoDecoder(void* param_0) { - // NONMATCHING +static void* daMP_VideoDecoder(void* param_0) { + daMP_THPReadBuffer* thpBuffer; + + while (TRUE) { + if (daMP_ActivePlayer.audioExist) { + for (; daMP_ActivePlayer.videoDecodeCount < 0;) { + thpBuffer = (daMP_THPReadBuffer*)daMP_PopReadedBuffer2(); + s32 remaining + = ((thpBuffer->frameNumber + daMP_ActivePlayer.initReadFrame) + % daMP_ActivePlayer.header.numFrames); + if (remaining == (daMP_ActivePlayer.header.numFrames - 1) + && (daMP_ActivePlayer.playFlag & 1) == 0) + daMP_VideoDecode(thpBuffer); + + daMP_PushFreeReadBuffer(thpBuffer); + BOOL enable = OSDisableInterrupts(); + daMP_ActivePlayer.videoDecodeCount++; + OSRestoreInterrupts(enable); + } + } + + if (daMP_ActivePlayer.audioExist) + thpBuffer = (daMP_THPReadBuffer*)daMP_PopReadedBuffer2(); + else + thpBuffer = (daMP_THPReadBuffer*)daMP_PopReadedBuffer(); + + daMP_VideoDecode(thpBuffer); + daMP_PushFreeReadBuffer(thpBuffer); + } } /* 80875EA0-80875FD4 0037C0 0134+00 1/1 0/0 0/0 .text daMP_VideoDecoderForOnMemory__FPv */ -static void daMP_VideoDecoderForOnMemory(void* param_0) { - // NONMATCHING +static void* daMP_VideoDecoderForOnMemory(void* param_0) { + daMP_THPReadBuffer readBuffer; + s32 readSize; + s32 frame; + s32 remaining; + + readSize = daMP_ActivePlayer.initReadSize; + readBuffer.ptr = (u8*)param_0; + frame = 0; + + while (TRUE) { + if (daMP_ActivePlayer.audioExist) { + while (daMP_ActivePlayer.videoDecodeCount < 0) { + BOOL enable = OSDisableInterrupts(); + daMP_ActivePlayer.videoDecodeCount++; + OSRestoreInterrupts(enable); + remaining = (frame + daMP_ActivePlayer.initReadFrame) + % daMP_ActivePlayer.header.numFrames; + if (remaining == daMP_ActivePlayer.header.numFrames - 1) { + if ((daMP_ActivePlayer.playFlag & 1) == 0) + break; + + readSize = *(s32*)readBuffer.ptr; + readBuffer.ptr = daMP_ActivePlayer.movieData; + } else { + s32 size = *(s32*)readBuffer.ptr; + readBuffer.ptr += readSize; + readSize = size; + } + frame++; + } + } + + readBuffer.frameNumber = frame; + + daMP_VideoDecode(&readBuffer); + + remaining = (frame + daMP_ActivePlayer.initReadFrame) + % daMP_ActivePlayer.header.numFrames; + if (remaining == daMP_ActivePlayer.header.numFrames - 1) { + if ((daMP_ActivePlayer.playFlag & 1)) { + readSize = *(s32*)readBuffer.ptr; + readBuffer.ptr = daMP_ActivePlayer.movieData; + } else { + OSSuspendThread(&daMP_VideoDecodeThread); + } + } else { + s32 size = *(s32*)readBuffer.ptr; + readBuffer.ptr += readSize; + readSize = size; + } + + frame++; + } } /* 80875FD4-808760EC 0038F4 0118+00 1/1 0/0 0/0 .text daMP_CreateVideoDecodeThread__FlPUc */ -static int daMP_CreateVideoDecodeThread(s32 param_0, u8* param_1) { +static BOOL daMP_CreateVideoDecodeThread(OSPriority prio, u8* param_1) { if (param_1 != NULL) { - if (!OSCreateThread(&daMP_VideoDecodeThread, (void*(*)(void*))daMP_VideoDecoderForOnMemory, param_1, daMP_VideoDecodeThreadStack + sizeof(daMP_VideoDecodeThreadStack), sizeof(daMP_VideoDecodeThreadStack), param_0, 1)) { + if (!OSCreateThread(&daMP_VideoDecodeThread, daMP_VideoDecoderForOnMemory, param_1, daMP_VideoDecodeThreadStack + sizeof(daMP_VideoDecodeThreadStack), sizeof(daMP_VideoDecodeThreadStack), prio, 1)) { OSReport("Can't create video decode thread\n"); - return 0; + return FALSE; } } else { - if (!OSCreateThread(&daMP_VideoDecodeThread, (void*(*)(void*))daMP_VideoDecoder, NULL, daMP_VideoDecodeThreadStack + sizeof(daMP_VideoDecodeThreadStack), sizeof(daMP_VideoDecodeThreadStack), param_0, 1)) { + if (!OSCreateThread(&daMP_VideoDecodeThread, daMP_VideoDecoder, NULL, daMP_VideoDecodeThreadStack + sizeof(daMP_VideoDecodeThreadStack), sizeof(daMP_VideoDecodeThreadStack), prio, 1)) { OSReport("Can't create video decode thread\n"); - return 0; + return FALSE; } } @@ -2821,7 +2943,7 @@ static int daMP_CreateVideoDecodeThread(s32 param_0, u8* param_1) { OSInitMessageQueue(&daMP_DecodedTextureSetQueue, daMP_DecodedTextureSetMessage, 3); daMP_First = daMP_VideoDecodeThreadCreated = TRUE; - return 1; + return TRUE; } /* 808760EC-80876124 003A0C 0038+00 1/1 0/0 0/0 .text daMP_VideoDecodeThreadStart__Fv */ @@ -2852,55 +2974,104 @@ static u8 daMP_AudioDecodeThreadStack[0x64000]; static OSMessageQueue daMP_FreeAudioBufferQueue; /* 80876168-8087619C 003A88 0034+00 1/1 0/0 0/0 .text daMP_PopFreeAudioBuffer__Fv */ -static OSMessage daMP_PopFreeAudioBuffer() { - OSMessage msg; - OSReceiveMessage(&daMP_FreeAudioBufferQueue, &msg, OS_MESSAGE_BLOCK); - return msg; +static void* daMP_PopFreeAudioBuffer() { + OSMessage buffer; + OSReceiveMessage(&daMP_FreeAudioBufferQueue, &buffer, OS_MESSAGE_BLOCK); + return buffer; } /* 8087619C-808761CC 003ABC 0030+00 2/2 0/0 0/0 .text daMP_PushFreeAudioBuffer__FPv */ -static void daMP_PushFreeAudioBuffer(void* param_0) { - OSMessage msg = (OSMessage)param_0; - OSSendMessage(&daMP_FreeAudioBufferQueue, msg, OS_MESSAGE_NOBLOCK); +static void daMP_PushFreeAudioBuffer(void* buffer) { + OSSendMessage(&daMP_FreeAudioBufferQueue, buffer, OS_MESSAGE_NOBLOCK); } /* 80944850-80944870 0CB2B0 0020+00 2/2 0/0 0/0 .bss daMP_DecodedAudioBufferQueue */ static OSMessageQueue daMP_DecodedAudioBufferQueue; /* 808761CC-80876210 003AEC 0044+00 1/1 0/0 0/0 .text daMP_PopDecodedAudioBuffer__Fl */ -static OSMessage daMP_PopDecodedAudioBuffer(s32 param_0) { - OSMessage msg; - if (OSReceiveMessage(&daMP_DecodedAudioBufferQueue, &msg, param_0) == 1) { - return msg; +static void* daMP_PopDecodedAudioBuffer(s32 flags) { + OSMessage buffer; + if (OSReceiveMessage(&daMP_DecodedAudioBufferQueue, &buffer, flags) == 1) { + return buffer; } return NULL; } /* 80876210-80876240 003B30 0030+00 1/1 0/0 0/0 .text daMP_PushDecodedAudioBuffer__FPv */ -static void daMP_PushDecodedAudioBuffer(void* param_0) { - OSMessage msg = (OSMessage)param_0; - OSSendMessage(&daMP_DecodedAudioBufferQueue, msg, OS_MESSAGE_BLOCK); +static void daMP_PushDecodedAudioBuffer(void* buffer) { + OSSendMessage(&daMP_DecodedAudioBufferQueue, buffer, OS_MESSAGE_BLOCK); } /* 80876240-8087631C 003B60 00DC+00 2/2 0/0 0/0 .text daMP_AudioDecode__FP18daMP_THPReadBuffer */ -static void daMP_AudioDecode(daMP_THPReadBuffer* param_0) { - // NONMATCHING +static void daMP_AudioDecode(daMP_THPReadBuffer* readBuffer) { + THPAudioBuffer* audioBuf; + s32 i; + u32* offsets; + u8* audioData; + + offsets = (u32*)(readBuffer->ptr + 8); + audioData = &readBuffer->ptr[daMP_ActivePlayer.compInfo.numComponents * 4] + 8; + audioBuf = (THPAudioBuffer*)daMP_PopFreeAudioBuffer(); + + for (i = 0; i < daMP_ActivePlayer.compInfo.numComponents; i++) { + switch (daMP_ActivePlayer.compInfo.frameComp[i]) { + case 1: { + audioBuf->validSample = THPAudioDecode( + audioBuf->buffer, + (audioData + *offsets * daMP_ActivePlayer.curAudioTrack), 0); + audioBuf->curPtr = audioBuf->buffer; + daMP_PushDecodedAudioBuffer(audioBuf); + return; + } + } + + audioData += *offsets; + offsets++; + } } /* 8087631C-80876344 003C3C 0028+00 1/1 0/0 0/0 .text daMP_AudioDecoder__FPv */ -static void daMP_AudioDecoder(void* param_0) { - while (1) { - void* var_r31 = daMP_PopReadedBuffer(); - daMP_AudioDecode((daMP_THPReadBuffer*)var_r31); - daMP_PushReadedBuffer2(var_r31); +static void* daMP_AudioDecoder(void* param_0) { + daMP_THPReadBuffer* buf; + + while (TRUE) { + buf = (daMP_THPReadBuffer*)daMP_PopReadedBuffer(); + daMP_AudioDecode(buf); + daMP_PushReadedBuffer2(buf); } } /* 80876344-808763EC 003C64 00A8+00 1/1 0/0 0/0 .text daMP_AudioDecoderForOnMemory__FPv */ -static void daMP_AudioDecoderForOnMemory(void* param_0) { - // NONMATCHING +static void* daMP_AudioDecoderForOnMemory(void* param_0) { + s32 readSize; + daMP_THPReadBuffer readBuffer; + s32 frame; + + readSize = daMP_ActivePlayer.initReadSize; + readBuffer.ptr = (u8*)param_0; + frame = 0; + + while (TRUE) { + readBuffer.frameNumber = frame; + daMP_AudioDecode(&readBuffer); + + s32 remaining = (frame + daMP_ActivePlayer.initReadFrame) % daMP_ActivePlayer.header.numFrames; + if (remaining == daMP_ActivePlayer.header.numFrames - 1) { + if ((daMP_ActivePlayer.playFlag & 1)) { + readSize = *(s32*)readBuffer.ptr; + readBuffer.ptr = daMP_ActivePlayer.movieData; + } else { + OSSuspendThread(&daMP_AudioDecodeThread); + } + } else { + s32 size = *(s32*)readBuffer.ptr; + readBuffer.ptr += readSize; + readSize = size; + } + frame++; + } } /* 80944870-8094487C 0CB2D0 000C+00 0/0 0/0 0/0 .bss daMP_FreeAudioBufferMessage */ @@ -2911,15 +3082,15 @@ static OSMessage daMP_DecodedAudioBufferMessage[3]; /* 808763EC-808764E8 003D0C 00FC+00 1/1 0/0 0/0 .text daMP_CreateAudioDecodeThread__FlPUc */ -static int daMP_CreateAudioDecodeThread(s32 param_0, u8* param_1) { +static BOOL daMP_CreateAudioDecodeThread(OSPriority prio, u8* param_1) { if (param_1 != NULL) { - if (!OSCreateThread(&daMP_AudioDecodeThread, (void*(*)(void*))daMP_AudioDecoderForOnMemory, param_1, daMP_AudioDecodeThreadStack + sizeof(daMP_AudioDecodeThreadStack), sizeof(daMP_AudioDecodeThreadStack), param_0, 1)) { - return 0; + if (!OSCreateThread(&daMP_AudioDecodeThread, daMP_AudioDecoderForOnMemory, param_1, daMP_AudioDecodeThreadStack + sizeof(daMP_AudioDecodeThreadStack), sizeof(daMP_AudioDecodeThreadStack), prio, 1)) { + return FALSE; } } else { - if (!OSCreateThread(&daMP_AudioDecodeThread, (void*(*)(void*))daMP_AudioDecoder, NULL, daMP_AudioDecodeThreadStack + sizeof(daMP_AudioDecodeThreadStack), sizeof(daMP_AudioDecodeThreadStack), param_0, 1)) { + if (!OSCreateThread(&daMP_AudioDecodeThread, daMP_AudioDecoder, NULL, daMP_AudioDecodeThreadStack + sizeof(daMP_AudioDecodeThreadStack), sizeof(daMP_AudioDecodeThreadStack), prio, 1)) { OSReport("Can't create audio decode thread\n"); - return 0; + return FALSE; } } @@ -2927,7 +3098,7 @@ static int daMP_CreateAudioDecodeThread(s32 param_0, u8* param_1) { OSInitMessageQueue(&daMP_DecodedAudioBufferQueue, daMP_DecodedAudioBufferMessage, 3); daMP_AudioDecodeThreadCreated = TRUE; - return 1; + return TRUE; } /* 808764E8-80876520 003E08 0038+00 1/1 0/0 0/0 .text daMP_AudioDecodeThreadStart__Fv */ @@ -2961,7 +3132,7 @@ static void daMP_THPGXRestore() { 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); + GXSetTevSwapModeTable(GX_TEV_SWAP3, GX_CH_BLUE, GX_CH_BLUE, GX_CH_BLUE, GX_CH_ALPHA); } static f32 dummyLiteral() { @@ -2972,27 +3143,29 @@ static f32 dummyLiteral() { /* 8087667C-80876BA8 003F9C 052C+00 1/1 0/0 0/0 .text * daMP_THPGXYuv2RgbSetup__FPC16_GXRenderModeObj */ -static void daMP_THPGXYuv2RgbSetup(GXRenderModeObj const* param_0) { - int width = param_0->fbWidth; - int height = param_0->efbHeight; - f32 var_f31 = 0.0f; +static void daMP_THPGXYuv2RgbSetup(const GXRenderModeObj* rmode) { + s32 w, h; + f32 var_f31; + Mtx44 m; + Mtx e_m; + + w = rmode->fbWidth; + h = rmode->efbHeight; + var_f31 = 0.0f; #if WIDESCREEN_SUPPORT if (!mDoGph_gInf_c::isWide()) { - var_f31 = ((u16)height - (width * 808.0f) / FB_WIDTH) * 0.5f; + var_f31 = ((u16)h - (w * 808.0f) / FB_WIDTH) * 0.5f; } #endif - Mtx44 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); + C_MTXOrtho(m, var_f31, h - var_f31, 0.0f, w, 0.0f, -1.0f); + GXSetProjection(m, GX_ORTHOGRAPHIC); + GXSetViewport(0.0f, 0.0f, w, h, 0.0f, 1.0f); + GXSetScissor(0, 0, w, h); + MTXIdentity(e_m); + GXLoadPosMtxImm(e_m, GX_PNMTX0); GXSetCurrentMtx(0); GXSetZCompLoc(GX_TRUE); GXSetZMode(GX_ENABLE, GX_ALWAYS, GX_DISABLE); @@ -3062,43 +3235,39 @@ static void daMP_THPGXYuv2RgbSetup(GXRenderModeObj const* param_0) { } /* 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; +static void daMP_THPGXYuv2RgbDraw(u8* y_data, u8* u_data, u8* v_data, s16 x, + s16 y, s16 textureWidth, s16 textureHeight, s16 polygonWidth, + s16 polygonHeight) { + GXTexObj tobj0; + GXTexObj tobj1; + GXTexObj tobj2; - 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(&tobj0, y_data, textureWidth, textureHeight, GX_TF_I8, GX_CLAMP, GX_CLAMP, GX_FALSE); + GXInitTexObjLOD(&tobj0, GX_NEAR, GX_NEAR, 0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1); + GXLoadTexObj(&tobj0, 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(&tobj1, u_data, textureWidth >> 1, textureHeight >> 1, GX_TF_I8, GX_CLAMP, GX_CLAMP, GX_FALSE); + GXInitTexObjLOD(&tobj1, GX_NEAR, GX_NEAR, 0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1); + GXLoadTexObj(&tobj1, 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); + GXInitTexObj(&tobj2, v_data, textureWidth >> 1, textureHeight >> 1, GX_TF_I8, GX_CLAMP, GX_CLAMP, GX_FALSE); + GXInitTexObjLOD(&tobj2, GX_NEAR, GX_NEAR, 0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1); + GXLoadTexObj(&tobj2, GX_TEXMAP2); GXBegin(GX_QUADS, GX_VTXFMT7, 4); - GXPosition3s16(param_3, param_4, 0); + GXPosition3s16(x, y, 0); GXTexCoord2u16(0, 0); - GXPosition3s16(param_3 + param_7, param_4, 0); + GXPosition3s16(x + polygonWidth, y, 0); GXTexCoord2u16(1, 0); - GXPosition3s16(param_3 + param_7, param_4 + param_8, 0); + GXPosition3s16(x + polygonWidth, y + polygonHeight, 0); GXTexCoord2u16(1, 1); - GXPosition3s16(param_3, param_4 + param_8, 0); + GXPosition3s16(x, y + polygonHeight, 0); GXTexCoord2u16(0, 1); GXEnd(); } -/* 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 u16 daMP_VolumeTable[] = { +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, @@ -3118,15 +3287,95 @@ SECTION_DATA static u16 daMP_VolumeTable[] = { }; /* 80876E0C-80877074 00472C 0268+00 1/1 0/0 0/0 .text daMP_MixAudio__FPsPsUl */ -static void daMP_MixAudio(s16* param_0, s16* param_1, u32 param_2) { - // NONMATCHING +// NONMATCHING - missing extsh +static void daMP_MixAudio(s16* destination, s16*, u32 sample) { + if (daMP_ActivePlayer.open && daMP_ActivePlayer.internalState == 2 && daMP_ActivePlayer.audioExist) { + u32 sampleNum; + u32 requestSample; + s32 i; + s16* dst; + s16* curPtr; + s32 l_mix, r_mix; + u16 attenuation; + + requestSample = sample; + dst = destination; + + do { + do { + if (daMP_ActivePlayer.playAudioBuffer == (THPAudioBuffer*)NULL) { + if (!(daMP_ActivePlayer.playAudioBuffer = (THPAudioBuffer*)daMP_PopDecodedAudioBuffer(0))) { + memset(dst, 0, requestSample * 4); + return; + } + daMP_ActivePlayer.curAudioNumber++; + } + } while ((sampleNum = daMP_ActivePlayer.playAudioBuffer->validSample) == 0); + + if (sampleNum >= requestSample) { + sampleNum = requestSample; + } + + curPtr = daMP_ActivePlayer.playAudioBuffer->curPtr; + + for (i = 0; i < sampleNum; i++) { + if (daMP_ActivePlayer.rampCount != 0) { + daMP_ActivePlayer.rampCount--; + daMP_ActivePlayer.curVolume += daMP_ActivePlayer.deltaVolume; + } else { + daMP_ActivePlayer.curVolume = daMP_ActivePlayer.targetVolume; + } + + attenuation = daMP_VolumeTable[(s32)daMP_ActivePlayer.curVolume]; + + l_mix = 0.7f * (attenuation * curPtr[0] >> 15); + // clamp volume + if (l_mix < -32768) + l_mix = -32768; + if (l_mix > 32767) + l_mix = 32767; + + r_mix = 0.7f * (attenuation * curPtr[1] >> 15); + if (r_mix < -32768) + r_mix = -32768; + if (r_mix > 32767) + r_mix = 32767; + + if (JASDriver::getOutputMode() == 0) { + l_mix = r_mix = ((r_mix >> 1) + (l_mix >> 1)); + } + + dst[0] = l_mix; + dst[1] = r_mix; + + dst += 2; + curPtr += 2; + } + + requestSample -= sampleNum; + daMP_ActivePlayer.playAudioBuffer->validSample -= sampleNum; + daMP_ActivePlayer.playAudioBuffer->curPtr = curPtr; + + if ((daMP_ActivePlayer.playAudioBuffer)->validSample == 0) { + daMP_PushFreeAudioBuffer(daMP_ActivePlayer.playAudioBuffer); + daMP_ActivePlayer.playAudioBuffer = (THPAudioBuffer*)NULL; + } + + if (requestSample == 0) { + break; + } + + } while (TRUE); + } else { + memset(destination, 0, sample * 4); + } } /* 80944888-809448A0 0CB2E8 0004+14 3/3 0/0 0/0 .bss daMP_Initialized */ static BOOL daMP_Initialized; /* 809448A0-809448E0 0CB300 0040+00 2/2 0/0 0/0 .bss daMP_WorkBuffer */ -static u8 daMP_WorkBuffer[0x40] ALIGN_DECL(32); +static u32 daMP_WorkBuffer[16] ALIGN_DECL(32); /* 809448E0-80944900 0CB340 0020+00 3/3 0/0 0/0 .bss daMP_PrepareReadyQueue */ static OSMessageQueue daMP_PrepareReadyQueue; @@ -3162,15 +3411,15 @@ static s32 daMP_AudioSystem; 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 s16* daMP_audioCallbackWithMSound(s32 param_0) { - if (daMP_ActivePlayer.field_0xa0 == 0 || daMP_ActivePlayer.field_0xa5 != 2 || daMP_ActivePlayer.field_0xa7 == 0) { +static s16* daMP_audioCallbackWithMSound(s32 sample) { + if (daMP_ActivePlayer.open == 0 || daMP_ActivePlayer.internalState != 2 || daMP_ActivePlayer.audioExist == 0) { return NULL; } - BOOL intr = OSEnableInterrupts(); + BOOL enable = OSEnableInterrupts(); daMP_SoundBufferIndex ^= 1; - daMP_MixAudio((s16*)daMP_SoundBuffer[daMP_SoundBufferIndex], NULL, param_0); - OSRestoreInterrupts(intr); + daMP_MixAudio((s16*)daMP_SoundBuffer[daMP_SoundBufferIndex], NULL, sample); + OSRestoreInterrupts(enable); return (s16*)daMP_SoundBuffer[daMP_SoundBufferIndex]; } @@ -3185,16 +3434,15 @@ static void daMP_audioQuitWithMSound() { } /* 80877180-808771B0 004AA0 0030+00 1/1 0/0 0/0 .text daMP_PushUsedTextureSet__FPv */ -static void daMP_PushUsedTextureSet(void* param_0) { - OSMessage msg = (OSMessage)param_0; - OSSendMessage(&daMP_UsedTextureSetQueue, msg, OS_MESSAGE_NOBLOCK); +static void daMP_PushUsedTextureSet(void* tex) { + OSSendMessage(&daMP_UsedTextureSetQueue, tex, OS_MESSAGE_NOBLOCK); } /* 808771B0-808771F4 004AD0 0044+00 2/2 0/0 0/0 .text daMP_PopUsedTextureSet__Fv */ -static OSMessage daMP_PopUsedTextureSet() { - OSMessage msg; - if (OSReceiveMessage(&daMP_DecodedAudioBufferQueue, &msg, OS_MESSAGE_NOBLOCK) == 1) { - return msg; +static void* daMP_PopUsedTextureSet() { + OSMessage tex; + if (OSReceiveMessage(&daMP_DecodedAudioBufferQueue, &tex, OS_MESSAGE_NOBLOCK) == 1) { + return tex; } return NULL; @@ -3202,7 +3450,8 @@ static OSMessage daMP_PopUsedTextureSet() { /* 808771F4-808772CC 004B14 00D8+00 1/1 0/0 0/0 .text daMP_THPPlayerInit__Fl */ static int daMP_THPPlayerInit(s32 param_0) { - // NONMATCHING + BOOL enable; + memset(&daMP_ActivePlayer, 0, sizeof(daMP_ActivePlayer)); LCEnable(); @@ -3212,7 +3461,7 @@ static int daMP_THPPlayerInit(s32 param_0) { return 0; } - BOOL enable = OSDisableInterrupts(); + enable = OSDisableInterrupts(); daMP_AudioSystem = param_0; daMP_SoundBufferIndex = 0; daMP_LastAudioBuffer = NULL; @@ -3234,88 +3483,89 @@ static void daMP_THPPlayerQuit() { LCDisable(); daMP_audioQuitWithMSound(); daMP_Initialized = FALSE; - daMP_ActivePlayer.field_0xa8 = 0; - daMP_ActivePlayer.field_0xac = 0; + daMP_ActivePlayer.dvdError = 0; + daMP_ActivePlayer.videoError = 0; } /* 8087730C-808776EC 004C2C 03E0+00 1/1 0/0 0/0 .text daMP_THPPlayerOpen__FPCci */ -// NONMATCHING - regalloc, some missing instructions -static BOOL daMP_THPPlayerOpen(char const* filename, int param_1) { +// NONMATCHING - regalloc +static BOOL daMP_THPPlayerOpen(char const* filename, BOOL onMemory) { + s32 offset; + s32 i; + if (!daMP_Initialized) { OSReport("You must call daMP_THPPlayerInit before you call this function\n"); return 0; } - if (daMP_ActivePlayer.field_0xa0 != 0) { + if (daMP_ActivePlayer.open) { 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)); + memset(&daMP_ActivePlayer.videoInfo, 0, sizeof(THPVideoInfo)); + memset(&daMP_ActivePlayer.audioInfo, 0, sizeof(THPAudioInfo)); - if (!DVDOpen(filename, &daMP_ActivePlayer.mFileInfo)) { + if (!DVDOpen(filename, &daMP_ActivePlayer.fileInfo)) { OSReport("Can't open %s.\n", filename); return 0; } - if (DVDReadPrio(&daMP_ActivePlayer.mFileInfo, daMP_WorkBuffer, sizeof(daMP_WorkBuffer), 0, 2) < 0) { + if (DVDReadPrio(&daMP_ActivePlayer.fileInfo, daMP_WorkBuffer, sizeof(daMP_WorkBuffer), 0, 2) < 0) { OSReport("Fail to read the header from THP file.\n"); - DVDClose(&daMP_ActivePlayer.mFileInfo); + DVDClose(&daMP_ActivePlayer.fileInfo); return 0; } - char* temp_r23 = (char*)&daMP_ActivePlayer.field_0x3c; - memcpy(temp_r23, daMP_WorkBuffer, 0x30); + memcpy(&daMP_ActivePlayer.header, daMP_WorkBuffer, sizeof(THPHeader)); - if (strcmp(temp_r23, "THP") != 0) { + if (strcmp(daMP_ActivePlayer.header.magic, "THP") != 0) { OSReport("This file is not THP file.\n"); - DVDClose(&daMP_ActivePlayer.mFileInfo); + DVDClose(&daMP_ActivePlayer.fileInfo); return 0; } - if (daMP_ActivePlayer.field_0x40 != 0x11000) { + if (daMP_ActivePlayer.header.version != 0x11000) { OSReport("invalid version.\n"); - DVDClose(&daMP_ActivePlayer.mFileInfo); + DVDClose(&daMP_ActivePlayer.fileInfo); return 0; } - s32 var_r26 = daMP_ActivePlayer.field_0x5c; + offset = daMP_ActivePlayer.header.compInfoDataOffsets; - if (DVDReadPrio(&daMP_ActivePlayer.mFileInfo, daMP_WorkBuffer, 0x20, var_r26, 2) < 0) { + if (DVDReadPrio(&daMP_ActivePlayer.fileInfo, daMP_WorkBuffer, 0x20, offset, 2) < 0) { OSReport("Fail to read the frame component infomation from THP file.\n"); - DVDClose(&daMP_ActivePlayer.mFileInfo); + DVDClose(&daMP_ActivePlayer.fileInfo); return 0; } - memcpy(&daMP_ActivePlayer.field_0x6c, daMP_WorkBuffer, 0x14); - var_r26 += 0x14; + memcpy(&daMP_ActivePlayer.compInfo, daMP_WorkBuffer, sizeof(THPFrameCompInfo)); + offset += sizeof(THPFrameCompInfo); - daMP_ActivePlayer.field_0xa7 = 0; + daMP_ActivePlayer.audioExist = 0; - for (int i = 0; i < daMP_ActivePlayer.field_0x6c._0; i++) { - switch (daMP_ActivePlayer.field_0x6c._4) { + for (i = 0; i < daMP_ActivePlayer.compInfo.numComponents; i++) { + switch (daMP_ActivePlayer.compInfo.frameComp[i]) { case 0: - if (DVDReadPrio(&daMP_ActivePlayer.mFileInfo, daMP_WorkBuffer, 0x20, var_r26, 2) < 0) { + if (DVDReadPrio(&daMP_ActivePlayer.fileInfo, daMP_WorkBuffer, 0x20, offset, 2) < 0) { OSReport("Fail to read the video infomation from THP file.\n"); - DVDClose(&daMP_ActivePlayer.mFileInfo); + DVDClose(&daMP_ActivePlayer.fileInfo); return 0; } - memcpy(temp_r29, daMP_WorkBuffer, sizeof(THPVideoInfo)); - var_r26 += 0xC; + memcpy(&daMP_ActivePlayer.videoInfo, daMP_WorkBuffer, sizeof(THPVideoInfo)); + offset += sizeof(THPVideoInfo); break; case 1: - if (DVDReadPrio(&daMP_ActivePlayer.mFileInfo, daMP_WorkBuffer, 0x20, var_r26, 2) < 0) { + if (DVDReadPrio(&daMP_ActivePlayer.fileInfo, daMP_WorkBuffer, 0x20, offset, 2) < 0) { OSReport("Fail to read the video infomation from THP file.\n"); - DVDClose(&daMP_ActivePlayer.mFileInfo); + DVDClose(&daMP_ActivePlayer.fileInfo); return 0; } - memcpy(&daMP_ActivePlayer.mAudioInfo, daMP_WorkBuffer, sizeof(THPAudioInfo)); - daMP_ActivePlayer.field_0xa7 = 1; - var_r26 += 0x10; + memcpy(&daMP_ActivePlayer.audioInfo, daMP_WorkBuffer, sizeof(THPAudioInfo)); + daMP_ActivePlayer.audioExist = 1; + offset += sizeof(THPAudioInfo); break; default: OSReport("Unknow frame components.\n"); @@ -3323,91 +3573,344 @@ static BOOL daMP_THPPlayerOpen(char const* filename, int param_1) { } } - 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; + daMP_ActivePlayer.internalState = 0; + daMP_ActivePlayer.state = 0; + daMP_ActivePlayer.playFlag = 0; + daMP_ActivePlayer.onMemory = onMemory; + daMP_ActivePlayer.open = 1; + daMP_ActivePlayer.curVolume = 127.0f; + daMP_ActivePlayer.targetVolume = 127.0f; + daMP_ActivePlayer.rampCount = 0; return 1; } /* 808776EC-80877740 00500C 0054+00 2/2 0/0 0/0 .text daMP_THPPlayerClose__Fv */ -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; +static BOOL daMP_THPPlayerClose() { + if (daMP_ActivePlayer.open && daMP_ActivePlayer.state == 0) { + daMP_ActivePlayer.open = 0; + DVDClose(&daMP_ActivePlayer.fileInfo); + return TRUE; } - return 0; + return FALSE; } /* 80877740-808777F0 005060 00B0+00 1/1 0/0 0/0 .text daMP_THPPlayerCalcNeedMemory__Fv */ static u32 daMP_THPPlayerCalcNeedMemory() { - // NONMATCHING + if (daMP_ActivePlayer.open) { + u32 size = daMP_ActivePlayer.onMemory + ? ALIGN_NEXT(daMP_ActivePlayer.header.movieDataSize, 32) + : ALIGN_NEXT(daMP_ActivePlayer.header.bufsize, 32) * 10; + + size += ALIGN_NEXT(daMP_ActivePlayer.videoInfo.xSize * daMP_ActivePlayer.videoInfo.ySize, 32) * 3; + size += ALIGN_NEXT(daMP_ActivePlayer.videoInfo.xSize * daMP_ActivePlayer.videoInfo.ySize / 4, 32) * 3; + size += ALIGN_NEXT(daMP_ActivePlayer.videoInfo.xSize * daMP_ActivePlayer.videoInfo.ySize / 4, 32) * 3; + + if (daMP_ActivePlayer.audioExist) { + size += ALIGN_NEXT(daMP_ActivePlayer.header.audioMaxSamples * 4, 32) * THP_AUDIO_BUFFER_COUNT; + } + + return size + 0x1000; + } + + return 0; } /* 808777F0-80877A08 005110 0218+00 1/1 0/0 0/0 .text daMP_THPPlayerSetBuffer__FPUc */ -static void daMP_THPPlayerSetBuffer(u8* param_0) { - // NONMATCHING +static BOOL daMP_THPPlayerSetBuffer(u8* buffer) { + u32 i; + u8* ptr; + u32 ysize; + u32 uvsize; + + if (daMP_ActivePlayer.open && daMP_ActivePlayer.state == 0) { + ptr = buffer; + if (daMP_ActivePlayer.onMemory) { + daMP_ActivePlayer.movieData = buffer; + ptr += daMP_ActivePlayer.header.movieDataSize; + } else { + for (i = 0; i < ARRAY_SIZE(daMP_ActivePlayer.readBuffer); i++) { + daMP_ActivePlayer.readBuffer[i].ptr = ptr; + ptr += ALIGN_NEXT(daMP_ActivePlayer.header.bufsize, 32); + } + } + + ysize = ALIGN_NEXT(daMP_ActivePlayer.videoInfo.xSize * daMP_ActivePlayer.videoInfo.ySize, 32); + uvsize = ALIGN_NEXT(daMP_ActivePlayer.videoInfo.xSize * daMP_ActivePlayer.videoInfo.ySize / 4, 32); + + for (i = 0; i < ARRAY_SIZE(daMP_ActivePlayer.textureSet); i++) { + daMP_ActivePlayer.textureSet[i].ytexture = ptr; + + DCInvalidateRange(ptr, ysize); + ptr += ysize; + + daMP_ActivePlayer.textureSet[i].utexture = ptr; + DCInvalidateRange(ptr, uvsize); + ptr += uvsize; + + daMP_ActivePlayer.textureSet[i].vtexture = ptr; + DCInvalidateRange(ptr, uvsize); + ptr += uvsize; + } + + if (daMP_ActivePlayer.audioExist) { + for (i = 0; i < ARRAY_SIZE(daMP_ActivePlayer.audioBuffer); i++) { + daMP_ActivePlayer.audioBuffer[i].buffer = (s16*)ptr; + daMP_ActivePlayer.audioBuffer[i].curPtr = (s16*)ptr; + daMP_ActivePlayer.audioBuffer[i].validSample = 0; + ptr += ALIGN_NEXT(daMP_ActivePlayer.header.audioMaxSamples * 4, 32); + } + } + + daMP_ActivePlayer.thpWork = ptr; + return TRUE; + } + + return FALSE; } /* 80877A08-80877ADC 005328 00D4+00 1/1 0/0 0/0 .text daMP_InitAllMessageQueue__Fv */ static void daMP_InitAllMessageQueue() { - // NONMATCHING + int i; + if (daMP_ActivePlayer.onMemory == FALSE) { + for (i = 0; i < THP_READ_BUFFER_COUNT; i++) { + daMP_PushFreeReadBuffer(&daMP_ActivePlayer.readBuffer[i]); + } + } + + for (i = 0; i < THP_TEXTURE_SET_COUNT; i++) { + daMP_PushFreeTextureSet(&daMP_ActivePlayer.textureSet[i]); + } + + if (daMP_ActivePlayer.audioExist) { + for (i = 0; i < THP_AUDIO_BUFFER_COUNT; i++) { + daMP_PushFreeAudioBuffer(&daMP_ActivePlayer.audioBuffer[i]); + } + } + + OSInitMessageQueue(&daMP_PrepareReadyQueue, &daMP_PrepareReadyMessage, 1); } /* 80877ADC-80877B48 0053FC 006C+00 1/1 0/0 0/0 .text daMP_ProperTimingForStart__Fv */ -static void daMP_ProperTimingForStart() { - // NONMATCHING +static BOOL daMP_ProperTimingForStart() { + if (daMP_ActivePlayer.videoInfo.videoType & 1) { + if (VIGetNextField() == 0) + return TRUE; + } else if (daMP_ActivePlayer.videoInfo.videoType & 2) { + if (VIGetNextField() == 1) + return TRUE; + } else + return TRUE; + + return FALSE; } /* 80877B48-80877C8C 005468 0144+00 1/1 0/0 0/0 .text daMP_ProperTimingForGettingNextFrame__Fv */ -static void daMP_ProperTimingForGettingNextFrame() { - // NONMATCHING +static BOOL daMP_ProperTimingForGettingNextFrame() { + if ((daMP_ActivePlayer.videoInfo.videoType & 1)) { + if (VIGetNextField() == 0) { + return TRUE; + } + } else if ((daMP_ActivePlayer.videoInfo.videoType & 2)) { + if (VIGetNextField() == 1) { + return TRUE; + } + } else { + s32 frameRate = daMP_ActivePlayer.header.frameRate * 100.0f; + if (VIGetTvFormat() == VI_PAL) { + daMP_ActivePlayer.curCount = daMP_ActivePlayer.retaceCount * frameRate / 5000; + } else { + daMP_ActivePlayer.curCount = daMP_ActivePlayer.retaceCount * frameRate / 5994; + } + + if (daMP_ActivePlayer.prevCount != daMP_ActivePlayer.curCount) { + daMP_ActivePlayer.prevCount = daMP_ActivePlayer.curCount; + return TRUE; + } + } + + return FALSE; } /* 80877C8C-80877F48 0055AC 02BC+00 1/1 0/0 0/0 .text daMP_PlayControl__FUl */ -static void daMP_PlayControl(u32 param_0) { - // NONMATCHING +static void daMP_PlayControl(u32 retraceCnt) { + THPTextureSet* decodedTexture; + + if (daMP_OldVIPostCallback != NULL) + daMP_OldVIPostCallback(retraceCnt); + + decodedTexture = (THPTextureSet*)-1; + if (daMP_ActivePlayer.open && daMP_ActivePlayer.state == 2) { + if (daMP_ActivePlayer.dvdError || daMP_ActivePlayer.videoError) { + daMP_ActivePlayer.internalState = 5; + daMP_ActivePlayer.state = 5; + return; + } + + ++daMP_ActivePlayer.retaceCount; + + if (daMP_ActivePlayer.retaceCount == 0) { + if (daMP_ProperTimingForStart()) { + if (daMP_ActivePlayer.audioExist) { + if (daMP_ActivePlayer.curVideoNumber - daMP_ActivePlayer.curAudioNumber <= 1) { + decodedTexture = (THPTextureSet*)daMP_PopDecodedTextureSet(0); + daMP_ActivePlayer.videoDecodeCount--; + daMP_ActivePlayer.curVideoNumber++; + } else { + daMP_ActivePlayer.internalState = 2; + } + } else { + decodedTexture = (THPTextureSet*)daMP_PopDecodedTextureSet(0); + } + } else { + daMP_ActivePlayer.retaceCount = -1; + } + } else { + if (daMP_ActivePlayer.retaceCount == 1) { + daMP_ActivePlayer.internalState = 2; + } + + if (daMP_ProperTimingForGettingNextFrame()) { + if (daMP_ActivePlayer.audioExist) { + if (daMP_ActivePlayer.curVideoNumber - daMP_ActivePlayer.curAudioNumber <= 1) { + decodedTexture = (THPTextureSet*)daMP_PopDecodedTextureSet(0); + daMP_ActivePlayer.videoDecodeCount--; + daMP_ActivePlayer.curVideoNumber++; + } + } else { + decodedTexture = (THPTextureSet*)daMP_PopDecodedTextureSet(0); + } + } + } + + if (decodedTexture != NULL && decodedTexture != (THPTextureSet*)-1) { + if (daMP_ActivePlayer.dispTextureSet != NULL) + daMP_PushUsedTextureSet(daMP_ActivePlayer.dispTextureSet); + daMP_ActivePlayer.dispTextureSet = decodedTexture; + } + + if ((daMP_ActivePlayer.playFlag & 1) == 0) { + if (daMP_ActivePlayer.audioExist) { + s32 audioFrame = daMP_ActivePlayer.curAudioNumber + daMP_ActivePlayer.initReadFrame; + if (audioFrame == daMP_ActivePlayer.header.numFrames && daMP_ActivePlayer.playAudioBuffer == NULL) { + daMP_ActivePlayer.internalState = 3; + daMP_ActivePlayer.state = 3; + } + } else { + s32 curFrame; + if (daMP_ActivePlayer.dispTextureSet != NULL) + curFrame = daMP_ActivePlayer.dispTextureSet->frameNumber + daMP_ActivePlayer.initReadFrame; + else + curFrame = daMP_ActivePlayer.initReadFrame - 1; + + if (curFrame == daMP_ActivePlayer.header.numFrames - 1 && decodedTexture == NULL) { + daMP_ActivePlayer.internalState = 3; + daMP_ActivePlayer.state = 3; + } + } + } + } } /* 80877F48-80877F88 005868 0040+00 1/1 0/0 0/0 .text daMP_WaitUntilPrepare__Fv */ -s32 daMP_WaitUntilPrepare() { +BOOL daMP_WaitUntilPrepare() { OSMessage msg; OSReceiveMessage(&daMP_PrepareReadyQueue, &msg, 1); - u32 temp = (s32)msg; - return (-temp | temp) >> 31; // fakematch? should be temp != 0; + + if ((BOOL)msg) { + return TRUE; + } else { + return FALSE; + } } /* 80877F88-80877FB8 0058A8 0030+00 2/2 0/0 0/0 .text daMP_PrepareReady__Fi */ -void daMP_PrepareReady(int r3) { - OSMessage msg = (OSMessage)r3; - OSSendMessage(&daMP_PrepareReadyQueue, msg, 1); +void daMP_PrepareReady(BOOL msg) { + OSSendMessage(&daMP_PrepareReadyQueue, (OSMessage)msg, 1); } -/* 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_808792E2 = - "This thp file doesn't have the offset data\n"; -SECTION_DEAD static char const* const stringBase_8087930E = - "Fail to read the offset data from THP file.\n"; -SECTION_DEAD static char const* const stringBase_8087933B = - "Specified frame number is over total frame numbe" - "r\n"; -SECTION_DEAD static char const* const stringBase_8087936E = - "Specified audio track number is invalid\n"; -SECTION_DEAD static char const* const stringBase_80879397 = - "Fail to read all movie data from THP file\n"; -#pragma pop - /* 80877FB8-808782A0 0058D8 02E8+00 1/1 0/0 0/0 .text daMP_THPPlayerPrepare__Flll */ -static BOOL daMP_THPPlayerPrepare(s32 param_0, s32 param_1, s32 param_2) { - // NONMATCHING +static BOOL daMP_THPPlayerPrepare(s32 frame, s32 flag, s32 audioTrack) { + u8* threadData; + if (daMP_ActivePlayer.open && daMP_ActivePlayer.state == 0) { + if (frame > 0) { + if (daMP_ActivePlayer.header.offsetDataOffsets == 0) { + OSReport("This thp file doesn't have the offset data\n"); + return FALSE; + } + + if (daMP_ActivePlayer.header.numFrames > frame) { + if (DVDReadPrio(&daMP_ActivePlayer.fileInfo, daMP_WorkBuffer, 0x20, daMP_ActivePlayer.header.offsetDataOffsets + (frame - 1) * 4, 2) < 0) { + OSReport("Fail to read the offset data from THP file.\n"); + return FALSE; + } + + daMP_ActivePlayer.initOffset = daMP_ActivePlayer.header.movieDataOffsets + daMP_WorkBuffer[0]; + daMP_ActivePlayer.initReadFrame = frame; + daMP_ActivePlayer.initReadSize = daMP_WorkBuffer[1] - daMP_WorkBuffer[0]; + } else { + OSReport("Specified frame number is over total frame number\n"); + return FALSE; + } + } else { + daMP_ActivePlayer.initOffset = daMP_ActivePlayer.header.movieDataOffsets; + daMP_ActivePlayer.initReadSize = daMP_ActivePlayer.header.firstFrameSize; + daMP_ActivePlayer.initReadFrame = frame; + } + + if (daMP_ActivePlayer.audioExist) { + if (audioTrack < 0 || audioTrack >= daMP_ActivePlayer.audioInfo.sndNumTracks) { + OSReport("Specified audio track number is invalid\n"); + return FALSE; + } + daMP_ActivePlayer.curAudioTrack = audioTrack; + } + + daMP_ActivePlayer.playFlag = flag & 1; + daMP_ActivePlayer.videoDecodeCount = 0; + + if (daMP_ActivePlayer.onMemory) { + if (DVDReadPrio(&daMP_ActivePlayer.fileInfo, daMP_ActivePlayer.movieData, daMP_ActivePlayer.header.movieDataSize, daMP_ActivePlayer.header.movieDataOffsets, 2) < 0) { + OSReport("Fail to read all movie data from THP file\n"); + return FALSE; + } + + threadData = daMP_ActivePlayer.movieData + daMP_ActivePlayer.initOffset - daMP_ActivePlayer.header.movieDataOffsets; + daMP_CreateVideoDecodeThread(20, threadData); + + if (daMP_ActivePlayer.audioExist) + daMP_CreateAudioDecodeThread(12, threadData); + } else { + daMP_CreateVideoDecodeThread(20, 0); + if (daMP_ActivePlayer.audioExist) + daMP_CreateAudioDecodeThread(12, NULL); + daMP_CreateReadThread(8); + } + + daMP_InitAllMessageQueue(); + daMP_VideoDecodeThreadStart(); + + if (daMP_ActivePlayer.audioExist) + daMP_AudioDecodeThreadStart(); + if (daMP_ActivePlayer.onMemory == 0) + daMP_ReadThreadStart(); + + if (!daMP_WaitUntilPrepare()) + return FALSE; + + daMP_ActivePlayer.state = 1; + daMP_ActivePlayer.internalState = 0; + daMP_ActivePlayer.dispTextureSet = (THPTextureSet*)NULL; + daMP_ActivePlayer.playAudioBuffer = (THPAudioBuffer*)NULL; + daMP_ActivePlayer.curVideoNumber = 0; + daMP_ActivePlayer.curAudioNumber = 0; + + daMP_OldVIPostCallback = VISetPostRetraceCallback(daMP_PlayControl); + + return TRUE; + } + + return FALSE; } /* 808782A0-808782E4 005BC0 0044+00 1/1 0/0 0/0 .text daMP_THPPlayerDrawDone__Fv */ @@ -3415,61 +3918,61 @@ static void daMP_THPPlayerDrawDone() { GXDrawDone(); if (daMP_Initialized) { - while (1) { - void* temp_r3 = daMP_PopUsedTextureSet(); - if (temp_r3 == NULL) { + while (TRUE) { + void* tex = daMP_PopUsedTextureSet(); + if (tex == NULL) { break; } - daMP_PushFreeTextureSet(temp_r3); + daMP_PushFreeTextureSet(tex); } } } /* 808782E4-80878344 005C04 0060+00 1/1 0/0 0/0 .text daMP_THPPlayerPlay__Fv */ -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; +static BOOL daMP_THPPlayerPlay() { + if (daMP_ActivePlayer.open != 0 && (daMP_ActivePlayer.state == 1 || daMP_ActivePlayer.state == 4)) { + daMP_ActivePlayer.state = 2; + daMP_ActivePlayer.prevCount = 0; + daMP_ActivePlayer.curCount = 0; + daMP_ActivePlayer.retaceCount = -1; + return TRUE; } - return 0; + return FALSE; } /* 80878344-808783FC 005C64 00B8+00 3/3 0/0 0/0 .text daMP_THPPlayerStop__Fv */ static void daMP_THPPlayerStop() { - if (daMP_ActivePlayer.field_0xa0 != 0 && daMP_ActivePlayer.mState != 0) { - daMP_ActivePlayer.field_0xa5 = 0; - daMP_ActivePlayer.mState = 0; + if (daMP_ActivePlayer.open != 0 && daMP_ActivePlayer.state != 0) { + daMP_ActivePlayer.internalState = 0; + daMP_ActivePlayer.state = 0; VISetPostRetraceCallback(daMP_OldVIPostCallback); - if (daMP_ActivePlayer.field_0xb0 == 0) { - DVDCancel(&daMP_ActivePlayer.mFileInfo.cb); + if (daMP_ActivePlayer.onMemory == 0) { + DVDCancel(&daMP_ActivePlayer.fileInfo.cb); daMP_ReadThreadCancel(); } daMP_VideoDecodeThreadCancel(); - if (daMP_ActivePlayer.field_0xa7 != 0) { + if (daMP_ActivePlayer.audioExist != 0) { daMP_AudioDecodeThreadCancel(); daMP_audioQuitWithMSound(); } while (daMP_PopUsedTextureSet() != NULL) {} - daMP_ActivePlayer.field_0xdc = daMP_ActivePlayer.field_0xe0; - daMP_ActivePlayer.field_0xe8 = 0.0f; + daMP_ActivePlayer.curVolume = daMP_ActivePlayer.targetVolume; + daMP_ActivePlayer.rampCount = 0.0f; } } /* 808783FC-80878438 005D1C 003C+00 1/1 0/0 0/0 .text daMP_THPPlayerPause__Fv */ static int daMP_THPPlayerPause() { - if (daMP_ActivePlayer.field_0xa0 != 0 && daMP_ActivePlayer.mState == 2) { - daMP_ActivePlayer.field_0xa5 = 4; - daMP_ActivePlayer.mState = 4; + if (daMP_ActivePlayer.open != 0 && daMP_ActivePlayer.state == 2) { + daMP_ActivePlayer.internalState = 4; + daMP_ActivePlayer.state = 4; return 1; } @@ -3478,16 +3981,34 @@ static int daMP_THPPlayerPause() { /* 80878438-80878534 005D58 00FC+00 1/1 0/0 0/0 .text * daMP_THPPlayerDrawCurrentFrame__FPC16_GXRenderModeObjUlUlUlUl */ -static int daMP_THPPlayerDrawCurrentFrame(_GXRenderModeObj const* param_0, u32 param_1, - u32 param_2, u32 param_3, u32 param_4) { - // NONMATCHING +static int daMP_THPPlayerDrawCurrentFrame(const GXRenderModeObj* rmode, u32 x, + u32 y, u32 polygonW, u32 polygonH) { + s32 frame; + if (daMP_ActivePlayer.open && daMP_ActivePlayer.state != 0 && daMP_ActivePlayer.dispTextureSet != NULL) { + daMP_THPGXYuv2RgbSetup(rmode); + daMP_THPGXYuv2RgbDraw(daMP_ActivePlayer.dispTextureSet->ytexture, + daMP_ActivePlayer.dispTextureSet->utexture, + daMP_ActivePlayer.dispTextureSet->vtexture, x, y, + daMP_ActivePlayer.videoInfo.xSize, + daMP_ActivePlayer.videoInfo.ySize, polygonW, polygonH); + daMP_THPGXRestore(); + frame = (daMP_ActivePlayer.dispTextureSet->frameNumber + daMP_ActivePlayer.initReadFrame) % daMP_ActivePlayer.header.numFrames; + + if (mDoGph_gInf_c::isFade()) { + mDoGph_gInf_c::fadeIn(1.0f); + } + + return frame; + } + + return -1; } /* 80878568-808785B0 005E88 0048+00 1/1 0/0 0/0 .text daMP_THPPlayerGetVideoInfo__FP12THPVideoInfo */ static int daMP_THPPlayerGetVideoInfo(THPVideoInfo* info) { - if (daMP_ActivePlayer.field_0xa0 != 0) { - memcpy(info, &daMP_ActivePlayer.mVideoInfo, sizeof(THPVideoInfo)); + if (daMP_ActivePlayer.open != 0) { + memcpy(info, &daMP_ActivePlayer.videoInfo, sizeof(THPVideoInfo)); return 1; } @@ -3497,8 +4018,8 @@ static int daMP_THPPlayerGetVideoInfo(THPVideoInfo* info) { /* 808785B0-808785F8 005ED0 0048+00 1/1 0/0 0/0 .text daMP_THPPlayerGetAudioInfo__FP12THPAudioInfo */ static int daMP_THPPlayerGetAudioInfo(THPAudioInfo* info) { - if (daMP_ActivePlayer.field_0xa0 != 0) { - memcpy(info, &daMP_ActivePlayer.mAudioInfo, sizeof(THPAudioInfo)); + if (daMP_ActivePlayer.open != 0) { + memcpy(info, &daMP_ActivePlayer.audioInfo, sizeof(THPAudioInfo)); return 1; } @@ -3507,8 +4028,8 @@ static int daMP_THPPlayerGetAudioInfo(THPAudioInfo* info) { /* 808785F8-8087861C 005F18 0024+00 2/2 0/0 0/0 .text daMP_THPPlayerGetTotalFrame__Fv */ static u32 daMP_THPPlayerGetTotalFrame() { - if (daMP_ActivePlayer.field_0xa0 != 0) { - return daMP_ActivePlayer.mTotalFrames; + if (daMP_ActivePlayer.open != 0) { + return daMP_ActivePlayer.header.numFrames; } return 0; @@ -3516,12 +4037,45 @@ static u32 daMP_THPPlayerGetTotalFrame() { /* 8087861C-8087862C 005F3C 0010+00 2/2 0/0 0/0 .text daMP_THPPlayerGetState__Fv */ static int daMP_THPPlayerGetState() { - return daMP_ActivePlayer.mState; + return daMP_ActivePlayer.state; } /* 8087862C-80878758 005F4C 012C+00 1/1 0/0 0/0 .text daMP_THPPlayerSetVolume__Fll */ -static void daMP_THPPlayerSetVolume(s32 param_0, s32 param_1) { - // NONMATCHING +static BOOL daMP_THPPlayerSetVolume(s32 vol, s32 duration) { + u32 numSamples; + BOOL interrupt; + + if (daMP_ActivePlayer.open && daMP_ActivePlayer.audioExist) { + numSamples = AIGetDSPSampleRate() == 0 ? 32 : 48; + + // clamp volume + if (vol > 127) + vol = 127; + if (vol < 0) + vol = 0; + + // clamp duration + if (duration > 60000) + duration = 60000; + if (duration < 0) + duration = 0; + + interrupt = OSDisableInterrupts(); + + daMP_ActivePlayer.targetVolume = vol; + if (duration != 0) { + daMP_ActivePlayer.rampCount = numSamples * duration; + daMP_ActivePlayer.deltaVolume = (daMP_ActivePlayer.targetVolume - daMP_ActivePlayer.curVolume) / daMP_ActivePlayer.rampCount; + } else { + daMP_ActivePlayer.rampCount = 0; + daMP_ActivePlayer.curVolume = daMP_ActivePlayer.targetVolume; + } + OSRestoreInterrupts(interrupt); + + return TRUE; + } + + return FALSE; } /* 80945AE0-80945AEC 0CC540 000C+00 1/1 0/0 0/0 .bss daMP_videoInfo */ @@ -3552,11 +4106,11 @@ static BOOL daMP_ActivePlayer_Init(char const* moviePath) { daMP_THPPlayerGetVideoInfo(&daMP_videoInfo); daMP_THPPlayerGetAudioInfo(&daMP_audioInfo); - u16 var_r31 = JUTVideo::getManager()->getRenderMode()->fbWidth; - u16 temp_r4 = JUTVideo::getManager()->getRenderMode()->efbHeight; + u16 width = JUTVideo::getManager()->getRenderMode()->fbWidth; + u16 height = JUTVideo::getManager()->getRenderMode()->efbHeight; - daMP_DrawPosX = (var_r31 - daMP_videoInfo.field_0x0) >> 1; - daMP_DrawPosY = (temp_r4 - daMP_videoInfo.field_0x4) >> 1; + daMP_DrawPosX = (width - daMP_videoInfo.xSize) >> 1; + daMP_DrawPosY = (height - daMP_videoInfo.ySize) >> 1; // "The memory needed for this THP movie is %d bytes\n" OS_REPORT("このTHPムービーが必要なメモリは%dバイトです\n", daMP_THPPlayerCalcNeedMemory()); @@ -3570,7 +4124,7 @@ static BOOL daMP_ActivePlayer_Init(char const* moviePath) { daMP_THPPlayerSetBuffer((u8*)daMP_buffer); - if (!daMP_THPPlayerPrepare(0, 0, daMP_audioInfo.field_0xc != 1 ? OSGetTick() % daMP_audioInfo.field_0xc : 0)) { + if (!daMP_THPPlayerPrepare(0, 0, daMP_audioInfo.sndNumTracks != 1 ? OSGetTick() % daMP_audioInfo.sndNumTracks : 0)) { OSReport("Fail to prepare\n"); JUT_ASSERT(0, FALSE); return 0; @@ -3606,10 +4160,10 @@ static void daMP_ActivePlayer_Main() { /* 80878994-80878A34 0062B4 00A0+00 1/1 0/0 0/0 .text daMP_ActivePlayer_Draw__Fv */ static void daMP_ActivePlayer_Draw() { - int var_r31 = daMP_THPPlayerDrawCurrentFrame(JUTVideo::getManager()->getRenderMode(), daMP_DrawPosX, daMP_DrawPosY, daMP_videoInfo.field_0x0, daMP_videoInfo.field_0x4); + int frame = daMP_THPPlayerDrawCurrentFrame(JUTVideo::getManager()->getRenderMode(), daMP_DrawPosX, daMP_DrawPosY, daMP_videoInfo.xSize, daMP_videoInfo.ySize); daMP_THPPlayerDrawDone(); - if (!fopOvlpM_IsPeek() && var_r31 > 0 && (cAPICPad_ANY_BUTTON(0) || !daMP_c::daMP_c_Get_MovieRestFrame())) { + if (!fopOvlpM_IsPeek() && frame > 0 && (cAPICPad_ANY_BUTTON(0) || !daMP_c::daMP_c_Get_MovieRestFrame())) { dComIfGp_event_reset(); daMP_c::daMP_c_Set_PercentMovieVolume(0.0f); } @@ -3619,24 +4173,43 @@ static void daMP_ActivePlayer_Draw() { static BOOL daMP_Fail_alloc; /* 80878A6C-80878B38 00638C 00CC+00 1/1 0/0 0/0 .text daMP_Get_MovieRestFrame__Fv */ +// NONMATCHING - ending section isnt right static u32 daMP_Get_MovieRestFrame() { - // NONMATCHING - return 0; + u32 temp_r31; + if (daMP_Fail_alloc != 0 || daMP_THPPlayerGetState() == 5) { + return 0; + } + + if (daMP_ActivePlayer.open && daMP_ActivePlayer.dispTextureSet != NULL) { + temp_r31 = (daMP_ActivePlayer.dispTextureSet->frameNumber + daMP_ActivePlayer.initReadFrame) % daMP_ActivePlayer.header.numFrames; + } else { + return -1; + } + + u32 temp_r3 = daMP_THPPlayerGetTotalFrame(); + if (temp_r3 == 0) { + return 0; + } + if (temp_r3 <= 1) { + return 0; + } + + return temp_r3 - temp_r31; } /* 80878B38-80878BB8 006458 0080+00 1/1 0/0 0/0 .text daMP_Set_PercentMovieVolume__Ff */ -static void daMP_Set_PercentMovieVolume(f32 param_0) { +static void daMP_Set_PercentMovieVolume(f32 volume) { if (!daMP_Fail_alloc) { - s32 var_r3; - if (param_0 >= 1.0f) { - var_r3 = 127; - } else if (param_0 <= 0.0f) { - var_r3 = 0; + s32 player_vol; + if (volume >= 1.0f) { + player_vol = 127; + } else if (volume <= 0.0f) { + player_vol = 0; } else { - var_r3 = param_0 / 127.0f; + player_vol = volume / 127.0f; } - daMP_THPPlayerSetVolume(var_r3, 1000); + daMP_THPPlayerSetVolume(player_vol, 1000); } } diff --git a/src/d/actor/d_a_npc_gnd.cpp b/src/d/actor/d_a_npc_gnd.cpp index ee032aaa79..93846af3c8 100644 --- a/src/d/actor/d_a_npc_gnd.cpp +++ b/src/d/actor/d_a_npc_gnd.cpp @@ -6,8 +6,6 @@ #include "d/dolzel_rel.h" // IWYU pragma: keep #include "d/actor/d_a_npc_gnd.h" -#include "dol2asm.h" - /* 809BE5BC-809BE5C4 000020 0008+00 1/1 0/0 0/0 .data l_bmdData */ static int l_bmdData[1][2] = { @@ -60,12 +58,11 @@ static daNpcT_MotionSeqMngr_c::sequenceStepData_c l_motionSequenceData[4] = { }; /* 809BE640-809BE644 -00001 0004+00 1/1 0/0 0/0 .data mCutNameList__11daNpc_Gnd_c */ -SECTION_DATA char* daNpc_Gnd_c::mCutNameList = ""; +char* daNpc_Gnd_c::mCutNameList[1] = {""}; /* 809BE644-809BE650 0000A8 000C+00 2/2 0/0 0/0 .data mCutList__11daNpc_Gnd_c */ daNpc_Gnd_c::cutFunc daNpc_Gnd_c::mCutList[1] = {NULL}; -/* ############################################################################################## */ /* 809BE4A0-809BE52C 000000 008C+00 6/6 0/0 0/0 .rodata m__17daNpc_Gnd_Param_c */ const daNpc_Gnd_HIOParam daNpc_Gnd_Param_c::m = { 280.0f, @@ -138,8 +135,8 @@ int daNpc_Gnd_c::create() { mType = getType(); mFlowNodeNo = getFlowNodeNo(); mTwilight = false; - int rv = loadRes(l_loadResPtrnList[mType], (const char**)l_resNameList); - if (rv == cPhs_COMPLEATE_e) { + int phase_state = loadRes(l_loadResPtrnList[mType], (const char**)l_resNameList); + if (phase_state == cPhs_COMPLEATE_e) { if (!fopAcM_entrySolidHeap(this, createHeapCallBack, 0)) { return cPhs_ERROR_e; } @@ -183,7 +180,7 @@ int daNpc_Gnd_c::create() { mCreating = 0; } - return rv; + return phase_state; } /* 809BB9D4-809BBC70 0004B4 029C+00 1/1 0/0 0/0 .text CreateHeap__11daNpc_Gnd_cFv */ @@ -256,7 +253,7 @@ int daNpc_Gnd_c::Draw() { /* 809BBF44-809BBF64 000A24 0020+00 1/1 0/0 0/0 .text * createHeapCallBack__11daNpc_Gnd_cFP10fopAc_ac_c */ int daNpc_Gnd_c::createHeapCallBack(fopAc_ac_c* i_this) { - return static_cast(i_this)->CreateHeap(); + return ((daNpc_Gnd_c*)i_this)->CreateHeap(); } /* 809BBF64-809BBFBC 000A44 0058+00 1/1 0/0 0/0 .text ctrlJointCallBack__11daNpc_Gnd_cFP8J3DJointi @@ -264,8 +261,8 @@ int daNpc_Gnd_c::createHeapCallBack(fopAc_ac_c* i_this) { int daNpc_Gnd_c::ctrlJointCallBack(J3DJoint* i_joint, int arg1) { if (arg1 == 0) { J3DModel* model = j3dSys.getModel(); - daNpc_Gnd_c* i_this = reinterpret_cast(model->getUserArea()); - if (i_this != 0) { + daNpc_Gnd_c* i_this = (daNpc_Gnd_c*)model->getUserArea(); + if (i_this != NULL) { i_this->ctrlJoint(i_joint, model); } } @@ -275,11 +272,11 @@ int daNpc_Gnd_c::ctrlJointCallBack(J3DJoint* i_joint, int arg1) { /* 809BBFBC-809BBFDC 000A9C 0020+00 1/1 0/0 0/0 .text getType__11daNpc_Gnd_cFv */ u8 daNpc_Gnd_c::getType() { - switch ((u8)fopAcM_GetParam(this)) { - case 0: - return TYPE_0; - default: - return TYPE_1; + switch (fopAcM_GetParam(this) & 0xFF) { + case 0: + return TYPE_0; + default: + return TYPE_1; } } @@ -299,18 +296,18 @@ int daNpc_Gnd_c::isDelete() { } switch (mType) { - case TYPE_0: - return 0; - default: { - return 1; - } + case TYPE_0: + return 0; + default: + return 1; } } /* 809BC028-809BC168 000B08 0140+00 1/1 0/0 0/0 .text reset__11daNpc_Gnd_cFv */ void daNpc_Gnd_c::reset() { initialize(); - memset(&field_0xF84, 0, (u8*)&field_0xF9C - (u8*)&field_0xF84); + memset(&mNextAction, 0, (u8*)&field_0xF9C - (u8*)&mNextAction); + for (int idx = 0; idx < 2; ++idx) { if (mpMatAnm[idx] != NULL) { mpMatAnm[idx]->initialize(); @@ -331,95 +328,209 @@ void daNpc_Gnd_c::afterJntAnm(int param_1) { } } -/* ############################################################################################## */ -/* 809BE554-809BE558 0000B4 0004+00 3/3 0/0 0/0 .rodata @4552 */ -SECTION_RODATA static f32 const lit_4552 = -1.0f; -COMPILER_STRIP_GATE(0x809BE554, &lit_4552); - /* 809BC1F4-809BC328 000CD4 0134+00 1/0 0/0 0/0 .text ctrlBtk__11daNpc_Gnd_cFv */ BOOL daNpc_Gnd_c::ctrlBtk() { - // NONMATCHING - return false; // Placeholder + if (mpMatAnm[0] != NULL && mpMatAnm[1] != NULL) { + if (field_0xe29 != 0 && mBtkAnm.getBtkAnm()) { + mpMatAnm[0]->setNowOffsetX(-1.0f * (0.2f * cM_ssin(mJntAnm.getEyeAngleY()))); + mpMatAnm[0]->setNowOffsetY(0.2f * cM_ssin(mJntAnm.getEyeAngleX())); + mpMatAnm[1]->setNowOffsetX(0.2f * cM_ssin(mJntAnm.getEyeAngleY())); + mpMatAnm[1]->setNowOffsetY(0.2f * cM_ssin(mJntAnm.getEyeAngleX())); + + if (field_0xe2a != 0) { + mpMatAnm[0]->setMorfFrm(field_0xe2a); + mpMatAnm[1]->setMorfFrm(field_0xe2a); + field_0xe2a = 0; + } + + mpMatAnm[0]->onEyeMoveFlag(); + mpMatAnm[1]->onEyeMoveFlag(); + return 1; + } + + if (field_0xe2a != 0) { + mpMatAnm[0]->setMorfFrm(field_0xe2a); + mpMatAnm[1]->setMorfFrm(field_0xe2a); + field_0xe2a = 0; + } + + mpMatAnm[0]->offEyeMoveFlag(); + mpMatAnm[1]->offEyeMoveFlag(); + } + + return 0; } /* 809BC328-809BC448 000E08 0120+00 1/0 0/0 0/0 .text setParam__11daNpc_Gnd_cFv */ void daNpc_Gnd_c::setParam() { - // NONMATCHING + u32 attn_flags = (fopAc_AttnFlag_SPEAK_e | fopAc_AttnFlag_TALK_e); + + selectAction(); + srchActors(); + + s16 talk_distance = mpHIO->m.common.talk_distance; + s16 talk_angle = mpHIO->m.common.talk_angle; + s16 attention_distance = mpHIO->m.common.attention_distance; + s16 attention_angle = mpHIO->m.common.attention_angle; + + attention_info.distances[fopAc_attn_LOCK_e] = daNpcT_getDistTableIdx(attention_distance, attention_angle); + attention_info.distances[fopAc_attn_TALK_e] = attention_info.distances[fopAc_attn_LOCK_e]; + attention_info.distances[fopAc_attn_SPEAK_e] = daNpcT_getDistTableIdx(talk_distance, talk_angle); + attention_info.flags = attn_flags; + + scale.set(mpHIO->m.common.scale, mpHIO->m.common.scale, mpHIO->m.common.scale); + mCcStts.SetWeight(mpHIO->m.common.weight); + mCylH = mpHIO->m.common.height; + mWallR = mpHIO->m.common.width; + mAttnFovY = mpHIO->m.common.fov; + mAcchCir.SetWallR(mWallR); + mAcchCir.SetWallH(mpHIO->m.common.knee_length); + mRealShadowSize = mpHIO->m.common.real_shadow_size; + gravity = mpHIO->m.common.gravity; + mExpressionMorfFrame = mpHIO->m.common.expression_morf_frame; + mMorfFrames = mpHIO->m.common.morf_frame; + + mAcch.SetGrndNone(); + mAcch.SetWallNone(); + gravity = 0.0f; } /* 809BC448-809BC4A8 000F28 0060+00 1/0 0/0 0/0 .text setAfterTalkMotion__11daNpc_Gnd_cFv */ void daNpc_Gnd_c::setAfterTalkMotion() { - // NONMATCHING + mFaceMotionSeqMngr.getNo(); + mFaceMotionSeqMngr.setNo(0, -1.0f, 0, 0); } /* 809BC4A8-809BC4AC 000F88 0004+00 1/1 0/0 0/0 .text srchActors__11daNpc_Gnd_cFv */ -void daNpc_Gnd_c::srchActors() { - /* empty function */ -} +void daNpc_Gnd_c::srchActors() {} /* 809BC4AC-809BC5AC 000F8C 0100+00 1/0 0/0 0/0 .text evtTalk__11daNpc_Gnd_cFv */ BOOL daNpc_Gnd_c::evtTalk() { - // NONMATCHING - return false; // Placeholder + if (chkAction(&daNpc_Gnd_c::talk)) { + (this->*mAction)(NULL); + } else { + mPreItemNo = 0; + if (dComIfGp_event_chkTalkXY()) { + if (!dComIfGp_evmng_ChkPresentEnd()) { + return TRUE; + } + mEvtNo = 1; + evtChange(); + return TRUE; + } else { + setAction(&daNpc_Gnd_c::talk); + } + } + + return TRUE; } /* 809BC5AC-809BC674 00108C 00C8+00 1/0 0/0 0/0 .text evtCutProc__11daNpc_Gnd_cFv */ BOOL daNpc_Gnd_c::evtCutProc() { - // NONMATCHING - return false; // Placeholder + BOOL rt = FALSE; + + s32 staffId = dComIfGp_getEventManager().getMyStaffId("Gnd", this, -1); + if (staffId != -1) { + mStaffId = staffId; + int actIdx = dComIfGp_getEventManager().getMyActIdx(mStaffId, mCutNameList, 1, FALSE, FALSE); + if ((this->*mCutList[actIdx])(mStaffId)) { + dComIfGp_getEventManager().cutEnd(mStaffId); + } + + rt = TRUE; + } + + return rt; } /* 809BC674-809BC760 001154 00EC+00 1/0 0/0 0/0 .text action__11daNpc_Gnd_cFv */ void daNpc_Gnd_c::action() { - // NONMATCHING + if (mStagger.checkRebirth()) { + mStagger.initialize(); + mMode = MODE_INIT; + } + + if (mNextAction) { + if (mAction == mNextAction) { + (this->*mAction)(NULL); + } else { + setAction(mNextAction); + } + } } /* 809BC760-809BC7D8 001240 0078+00 1/0 0/0 0/0 .text beforeMove__11daNpc_Gnd_cFv */ void daNpc_Gnd_c::beforeMove() { - // NONMATCHING + if (checkHide() || mNoDraw) { + attention_info.flags = 0; + } } -/* ############################################################################################## */ -/* 809BE558-809BE55C 0000B8 0004+00 0/1 0/0 0/0 .rodata @4723 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4723 = 10.0f; -COMPILER_STRIP_GATE(0x809BE558, &lit_4723); -#pragma pop - -/* 809BE55C-809BE560 0000BC 0004+00 0/1 0/0 0/0 .rodata @4724 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4724 = 30.0f; -COMPILER_STRIP_GATE(0x809BE55C, &lit_4724); -#pragma pop - -/* 809BE560-809BE568 0000C0 0004+04 0/1 0/0 0/0 .rodata @4725 */ -#pragma push -#pragma force_active on -SECTION_RODATA static u32 const lit_4725[1 + 1 /* padding */] = { - 0x38C90FDB, - /* padding */ - 0x00000000, -}; -COMPILER_STRIP_GATE(0x809BE560, &lit_4725); -#pragma pop - -/* 809BE568-809BE570 0000C8 0008+00 1/3 0/0 0/0 .rodata @4727 */ -SECTION_RODATA static u8 const lit_4727[8] = { - 0x43, 0x30, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, -}; -COMPILER_STRIP_GATE(0x809BE568, &lit_4727); - /* 809BC7D8-809BCA14 0012B8 023C+00 1/0 0/0 0/0 .text setAttnPos__11daNpc_Gnd_cFv */ void daNpc_Gnd_c::setAttnPos() { - // NONMATCHING + cXyz cStack_3c(10.0f, 30.0f, 0.0f); + cXyz cStack_48(10.0f, 0.0f, 0.0f); + + mStagger.calc(FALSE); + f32 rad = cM_s2rad((s16)(mCurAngle.y - field_0xd7e.y)); + + mJntAnm.setParam(this, mpMorf[0]->getModel(), &cStack_3c, getBackboneJointNo(), + getNeckJointNo(), getHeadJointNo(), mpHIO->m.common.body_angleX_min, + mpHIO->m.common.body_angleX_max, mpHIO->m.common.body_angleY_min, + mpHIO->m.common.body_angleY_max, mpHIO->m.common.head_angleX_min, + mpHIO->m.common.head_angleX_max, mpHIO->m.common.head_angleY_min, + mpHIO->m.common.head_angleY_max, mpHIO->m.common.neck_rotation_ratio, rad, + &cStack_48); + + mJntAnm.calcJntRad(0.2f, 1.0f, rad); + setMtx(); + + mDoMtx_stack_c::copy(mpMorf[0]->getModel()->getAnmMtx(getHeadJointNo())); + mDoMtx_stack_c::multVec(&cStack_3c, &eyePos); + + mJntAnm.setEyeAngleX(eyePos, 1.0f, 0); + mJntAnm.setEyeAngleY(eyePos, mCurAngle.y, FALSE, 1.0f, 0); + + attention_info.position = current.pos; + attention_info.position.y += mpHIO->m.common.attention_offset; } /* 809BCA14-809BCB48 0014F4 0134+00 1/0 0/0 0/0 .text setCollision__11daNpc_Gnd_cFv */ void daNpc_Gnd_c::setCollision() { - // NONMATCHING + cXyz pos; + u32 tgType = 0xD8FBFDFF; + u32 tgSPrm = 0x1F; + + if (!mHide) { + if (dComIfGp_event_runCheck()) { + tgType = 0; + tgSPrm = 0; + } else { + if (mTwilight) { + tgType = 0; + tgSPrm = 0; + } else if (mStagger.checkStagger()) { + tgType = 0; + tgSPrm = 0; + } + } + + f32 cylH = mCylH; + f32 wallR = mWallR; + pos = current.pos; + mCyl1.SetCoSPrm(0x79); + mCyl1.SetTgType(tgType); + mCyl1.SetTgSPrm(tgSPrm); + mCyl1.OnTgNoHitMark(); + mCyl1.SetH(cylH); + mCyl1.SetR(wallR); + mCyl1.SetC(pos); + dComIfG_Ccsp()->Set(&mCyl1); + } + + mCyl1.ClrCoHit(); + mCyl1.ClrTgHit(); } /* 809BCB48-809BCB50 001628 0008+00 1/0 0/0 0/0 .text drawDbgInfo__11daNpc_Gnd_cFv */ @@ -429,55 +540,186 @@ int daNpc_Gnd_c::drawDbgInfo() { /* 809BCB50-809BCCE8 001630 0198+00 1/0 0/0 0/0 .text afterSetMotionAnm__11daNpc_Gnd_cFiifi */ bool daNpc_Gnd_c::afterSetMotionAnm(int param_0, int param_1, f32 param_2, int param_3) { - // NONMATCHING - return false; // Placeholder + static struct { + int _0; + int _4; + } brkAnmData[] = { + {0x11, 1}, + }; + + static struct { + int _0; + int _4; + } bpkAnmData[] = { + {0x0E, 1}, + }; + + J3DAnmTevRegKey* brk = NULL; + J3DAnmColor* bpk = NULL; + + if (brkAnmData[param_0]._0 != -1) { + brk = getTevRegKeyAnmP(l_resNameList[brkAnmData[param_0]._4], brkAnmData[param_0]._0); + } + + if (brk != NULL) { + if (mBrkAnm.getBrkAnm() == brk) { + mAnmFlags |= 0x100; + } else if (setBrkAnm(brk, mpMorf[0]->getModel()->getModelData(), 1.0f, param_1)) { + mAnmFlags |= 0x104; + } + } + + if (brk == NULL && brkAnmData[param_0]._0 != -1) { + return 0; + } + + if (bpkAnmData[param_0]._0 != -1) { + bpk = getColorAnmP(l_resNameList[bpkAnmData[param_0]._4], bpkAnmData[param_0]._0); + } + + if (bpk != NULL) { + if (mBpkAnm.getBpkAnm() == bpk) { + mAnmFlags |= 0x200; + } else if (setBpkAnm(bpk, mpMorf[0]->getModel()->getModelData(), 1.0f, param_1)) { + mAnmFlags |= 0x208; + } + } + + if (bpk == NULL && bpkAnmData[param_0]._0 != -1) { + return 0; + } + + return 1; } /* 809BCCE8-809BCD30 0017C8 0048+00 1/1 0/0 0/0 .text selectAction__11daNpc_Gnd_cFv */ -void daNpc_Gnd_c::selectAction() { - // NONMATCHING +int daNpc_Gnd_c::selectAction() { + mNextAction = NULL; + mNextAction = &daNpc_Gnd_c::wait; + return 1; } /* 809BCD30-809BCD5C 001810 002C+00 1/1 0/0 0/0 .text * chkAction__11daNpc_Gnd_cFM11daNpc_Gnd_cFPCvPvPv_i */ -void daNpc_Gnd_c::chkAction(int (daNpc_Gnd_c::*param_0)(void*)) { - // NONMATCHING +int daNpc_Gnd_c::chkAction(int (daNpc_Gnd_c::*i_action)(void*)) { + return mAction == i_action; } /* 809BCD5C-809BCE04 00183C 00A8+00 2/2 0/0 0/0 .text * setAction__11daNpc_Gnd_cFM11daNpc_Gnd_cFPCvPvPv_i */ -void daNpc_Gnd_c::setAction(int (daNpc_Gnd_c::*param_0)(void*)) { - // NONMATCHING +int daNpc_Gnd_c::setAction(int (daNpc_Gnd_c::*i_action)(void*)) { + mMode = MODE_EXIT; + if (mAction != NULL) { + (this->*(mAction))(NULL); + } + + mMode = MODE_ENTER; + mAction = i_action; + if (mAction != NULL) { + (this->*(mAction))(NULL); + } + + return 1; } /* 809BCE04-809BD050 0018E4 024C+00 1/0 0/0 0/0 .text wait__11daNpc_Gnd_cFPv */ -void daNpc_Gnd_c::wait(void* param_0) { - // NONMATCHING +int daNpc_Gnd_c::wait(void* param_0) { + switch (mMode) { + case MODE_ENTER: + case MODE_INIT: + if (!mStagger.checkStagger()) { + mFaceMotionSeqMngr.setNo(0, -1.0f, FALSE, 0); + mMotionSeqMngr.setNo(0, -1.0f, FALSE, 0); + mMode = MODE_RUN; + } + case MODE_RUN: + if (!mStagger.checkStagger()) { + if (mPlayerActorMngr.getActorP()) { + mJntAnm.lookNone(0); + if (chkActorInSight(mPlayerActorMngr.getActorP(), mAttnFovY, mCurAngle.y)) { + mJntAnm.lookPlayer(0); + } + if (!srchPlayerActor() && home.angle.y == mCurAngle.y) { + mMode = MODE_INIT; + } + } else { + mJntAnm.lookNone(0); + if (home.angle.y != mCurAngle.y) { + if (field_0xe34 == 0) { + setAngle(home.angle.y); + mMode = MODE_INIT; + } else if (step(home.angle.y, -1, -1, 15, 0)) { + mMode = MODE_INIT; + } + attention_info.flags = 0; + } else { + srchPlayerActor(); + } + } + } + break; + case MODE_EXIT: + break; + } + + return 1; } /* 809BD050-809BD248 001B30 01F8+00 2/0 0/0 0/0 .text talk__11daNpc_Gnd_cFPv */ -void daNpc_Gnd_c::talk(void* param_0) { - // NONMATCHING +int daNpc_Gnd_c::talk(void* param_0) { + switch (mMode) { + case MODE_ENTER: + case MODE_INIT: + if (!mStagger.checkStagger()) { + initTalk(mFlowNodeNo, NULL); + if (checkStep()) { + mStepMode = 0; + } + mMode = MODE_RUN; + } + case MODE_RUN: + if (!mStagger.checkStagger()) { + if (mTwilight || mCurAngle.y == fopAcM_searchPlayerAngleY(this)) { + if (talkProc(NULL, FALSE, NULL, FALSE)) { + mPlayerActorMngr.entry(daPy_getPlayerActorClass()); + dComIfGp_event_reset(); + mMode = MODE_EXIT; + } + mJntAnm.lookPlayer(0); + if (mTwilight) { + mJntAnm.lookNone(0); + } + } else { + mJntAnm.lookPlayer(0); + step(fopAcM_searchPlayerAngleY(this), -1, -1, 15, 0); + } + } + break; + case MODE_EXIT: + break; + } + + return 0; } /* 809BD248-809BD268 001D28 0020+00 1/0 0/0 0/0 .text daNpc_Gnd_Create__FPv */ static int daNpc_Gnd_Create(void* i_this) { - return static_cast(i_this)->create(); + return ((daNpc_Gnd_c*)i_this)->create(); } /* 809BD268-809BD288 001D48 0020+00 1/0 0/0 0/0 .text daNpc_Gnd_Delete__FPv */ static int daNpc_Gnd_Delete(void* i_this) { - return static_cast(i_this)->Delete(); + return ((daNpc_Gnd_c*)i_this)->Delete(); } /* 809BD288-809BD2A8 001D68 0020+00 1/0 0/0 0/0 .text daNpc_Gnd_Execute__FPv */ static int daNpc_Gnd_Execute(void* i_this) { - return static_cast(i_this)->Execute(); + return ((daNpc_Gnd_c*)i_this)->Execute(); } /* 809BD2A8-809BD2C8 001D88 0020+00 1/0 0/0 0/0 .text daNpc_Gnd_Draw__FPv */ static int daNpc_Gnd_Draw(void* i_this) { - return static_cast(i_this)->Draw(); + return ((daNpc_Gnd_c*)i_this)->Draw(); } /* 809BD2C8-809BD2D0 001DA8 0008+00 1/0 0/0 0/0 .text daNpc_Gnd_IsDelete__FPv */ @@ -485,73 +727,6 @@ static int daNpc_Gnd_IsDelete(void* i_this) { return 1; } -/* ############################################################################################## */ -/* 809BE570-809BE578 0000D0 0008+00 0/1 0/0 0/0 .rodata @4785 */ -#pragma push -#pragma force_active on -SECTION_RODATA static u8 const lit_4785[8] = { - 0x3F, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; -COMPILER_STRIP_GATE(0x809BE570, &lit_4785); -#pragma pop - -/* 809BE578-809BE580 0000D8 0008+00 0/1 0/0 0/0 .rodata @4786 */ -#pragma push -#pragma force_active on -SECTION_RODATA static u8 const lit_4786[8] = { - 0x40, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; -COMPILER_STRIP_GATE(0x809BE578, &lit_4786); -#pragma pop - -/* 809BE580-809BE588 0000E0 0008+00 0/1 0/0 0/0 .rodata @4787 */ -#pragma push -#pragma force_active on -SECTION_RODATA static u8 const lit_4787[8] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; -COMPILER_STRIP_GATE(0x809BE580, &lit_4787); -#pragma pop - -extern "C" void talk__11daNpc_Gnd_cFPv(); -/* 809BE650-809BE65C -00001 000C+00 1/1 0/0 0/0 .data @4607 */ -SECTION_DATA static void* lit_4607[3] = { - (void*)NULL, - (void*)0xFFFFFFFF, - (void*)talk__11daNpc_Gnd_cFPv, -}; - -/* 809BE65C-809BE668 -00001 000C+00 1/1 0/0 0/0 .data @4617 */ -SECTION_DATA static void* lit_4617[3] = { - (void*)NULL, - (void*)0xFFFFFFFF, - (void*)talk__11daNpc_Gnd_cFPv, -}; - -/* 809BE668-809BE670 0000CC 0008+00 0/1 0/0 0/0 .data brkAnmData$4830 */ -#pragma push -#pragma force_active on -SECTION_DATA static u8 brkAnmData[8] = { - 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x01, -}; -#pragma pop - -/* 809BE670-809BE678 0000D4 0008+00 0/1 0/0 0/0 .data bpkAnmData$4831 */ -#pragma push -#pragma force_active on -SECTION_DATA static u8 bpkAnmData[8] = { - 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x01, -}; -#pragma pop - -extern "C" void wait__11daNpc_Gnd_cFPv(); -/* 809BE678-809BE684 -00001 000C+00 1/1 0/0 0/0 .data @4881 */ -SECTION_DATA static void* lit_4881[3] = { - (void*)NULL, - (void*)0xFFFFFFFF, - (void*)wait__11daNpc_Gnd_cFPv, -}; - /* 809BE684-809BE6A4 -00001 0020+00 1/0 0/0 0/0 .data daNpc_Gnd_MethodTable */ static actor_method_class daNpc_Gnd_MethodTable = { (process_method_func)daNpc_Gnd_Create, diff --git a/src/d/actor/d_a_npc_henna.cpp b/src/d/actor/d_a_npc_henna.cpp index ca7879f6f3..f5d4a38586 100644 --- a/src/d/actor/d_a_npc_henna.cpp +++ b/src/d/actor/d_a_npc_henna.cpp @@ -1857,8 +1857,8 @@ static void demo_camera_shop(npc_henna_class* i_this) { i_this->field_0x7b9 = 1; for (s32 i = 0; i < 100; i++) { koro = &fshop->field_0x4008->mKoro2[i]; - if ((koro->field_0x34 >= 2 && koro->field_0x34 <= 5) || - (koro->field_0x34 >= 8 && koro->field_0x34 <= 11)) + if ((koro->part_id >= 2 && koro->part_id <= 5) || + (koro->part_id >= 8 && koro->part_id <= 11)) { fshop->field_0x4008->mKoro2[i].field_0x60 = 1; }