From 490bdb5649fa703e8d4aa7f13454303af7e39b7c Mon Sep 17 00:00:00 2001 From: Dean Southwood Date: Mon, 9 Dec 2024 17:12:31 +1100 Subject: [PATCH] assorted naviState and hvqm4dec progress --- include/Dolphin/rand.h | 6 +- include/Navi.h | 6 +- include/NaviState.h | 30 +- include/gameflow.h | 3 +- include/hvqm4.h | 206 +++++ include/system.h | 1 + src/hvqm4dec/hvqm4dec.c | 299 +++---- src/plugPikiKando/naviState.cpp | 1310 +++++------------------------- src/plugPikiNishimura/KingAi.cpp | 2 +- 9 files changed, 577 insertions(+), 1286 deletions(-) create mode 100644 include/hvqm4.h diff --git a/include/Dolphin/rand.h b/include/Dolphin/rand.h index c10a0995..3720c439 100644 --- a/include/Dolphin/rand.h +++ b/include/Dolphin/rand.h @@ -10,9 +10,9 @@ extern "C" { #define RAND_MAX (32767.0f) -inline f32 randFloat() { return (f32)rand() / RAND_MAX; } -inline int randInt(int multiplier) { return multiplier * randFloat(); } -inline f32 randWeightFloat(f32 range) { return (range * (f32)rand()) / RAND_MAX; } +// inline f32 randFloat() { return (f32)rand() / RAND_MAX; } +// inline int randInt(int multiplier) { return multiplier * randFloat(); } +// inline f32 randWeightFloat(f32 range) { return (range * (f32)rand()) / RAND_MAX; } #define RAND_FLOAT_RANGE(origin, deviation) (origin - randFloat() * deviation) #define RAND_FLOAT_BETWEEN(min, max) (min + randFloat() * (max - min)) diff --git a/include/Navi.h b/include/Navi.h index e0b64e71..e2e7c0a7 100644 --- a/include/Navi.h +++ b/include/Navi.h @@ -133,7 +133,7 @@ struct Navi : public Creature, public PaniAnimKeyListener, public PelletView { NaviStateMachine* mStateMachine; // _320 ShadowCaster mShadowCaster; // _324 NaviDrawer* mNaviDrawer; // _6B8 - u8 _6BC[0x4]; // _6BC, unknown + f32 _6BC; // _6BC int _6C0; // _6C0 ShapeDynMaterials mNaviDynMats; // _6C4 Vector3f _6D4; // _6D4 @@ -142,9 +142,9 @@ struct Navi : public Creature, public PaniAnimKeyListener, public PelletView { Vector3f _6F0; // _6F0 u8 _6FC[0x4]; // _6FC, unknown int _700; // _700 - u8 _704[0x4]; // _704, unknown + f32 _704; // _704 GoalItem* mGoalItem; // _708 - u8 _70C[0x4]; // _70C, unknown + u8 _70C; // _70C CPlate* mPlateMgr; // _710, manages pikis in navi's party u8 _714[0x4]; // _714, unknown u8 _718; // _718 diff --git a/include/NaviState.h b/include/NaviState.h index 8fb0a725..fe473aba 100644 --- a/include/NaviState.h +++ b/include/NaviState.h @@ -164,9 +164,10 @@ struct NaviContainerState : public NaviState, virtual public ContainerWin::Liste // _00-_10 = NaviState // _10 = ContainerWin::Listener ptr // _14 = GmWin::CloseListener ptr - u8 _18[0x8]; // _18, TODO: members - // ContainerWin::Listener - // GmWin::CloseListener + int _18; // _18 + int _1C; // _1C + // ContainerWin::Listener + // GmWin::CloseListener }; /** @@ -381,7 +382,11 @@ struct NaviFlickState : public NaviState { // _00 = VTBL // _00-_10 = NaviState - u8 _10[0x24 - 0x10]; // _10, unknown + u16 _10; // _10 + f32 _14; // _14 + f32 _18; // _18 + f32 _1C; // _1C + f32 _20; // _20 }; /** @@ -418,7 +423,9 @@ struct NaviGatherState : public NaviState { // _00 = VTBL // _00-_10 = NaviState - u8 _10[0x1C - 0x10]; // _10, unknown + u16 _10; // _10 + f32 _14; // _14 + u8 _18; // _18 }; /** @@ -438,9 +445,13 @@ struct NaviGeyzerState : public NaviState { // _00 = VTBL // _00-_10 = NaviState - u8 _10[0x10]; // _10, unknown - Vector3f _20; // _20 - u8 _2C[0x34 - 0x2C]; // _2C, unknown + u16 _10; // _10 + f32 _14; // _14 + f32 _18; // _18 + f32 _1C; // _1C + Vector3f _20; // _20 + f32 _2C; // _2C + u8 _30; // _30 }; /** @@ -458,7 +469,8 @@ struct NaviIdleState : public NaviState { // _00 = VTBL // _00-_10 = NaviState - u8 _10[0x8]; // _10, unknown + u8 _10[0x4]; // _10, unknown + bool mStopBeingIdle; // _14 }; /** diff --git a/include/gameflow.h b/include/gameflow.h index 2e9a6196..52655766 100644 --- a/include/gameflow.h +++ b/include/gameflow.h @@ -372,7 +372,8 @@ struct GameFlow : public Node { GameLoadIdler mGameLoadIdler; // _31C u8 _330[0x338 - 0x330]; // _330, unknown int _338; // _338 - u8 _33C[0x350 - 0x33C]; // _33C, unknown + u32 _33C; // _33C, unknown + u8 _340[0x350 - 0x340]; // _340, unknown u32 _350; // _350, unknown u8 _354[0x8]; // _354, unknown u8 _35C; // _35C, maybe Colour? diff --git a/include/hvqm4.h b/include/hvqm4.h new file mode 100644 index 00000000..46222cd9 --- /dev/null +++ b/include/hvqm4.h @@ -0,0 +1,206 @@ +#ifndef _HVQM4_H +#define _HVQM4_H + +#include "types.h" + +#ifdef __cplusplus +extern "C" { +#endif // ifdef __cplusplus + +//////////// HVQM4 DECODER FUNCTIONS AND STRUCTS (C) //////////// +// Names from Tilka/hvqm4, presumably from Disney PK debug originally. +// Versioning is a bit weird, so take with a grain of salt. Should be close to correct though. + +#define HVQM_PLANE_COUNT 3 // apparently +#define HVQM_LUMA_CHROMA 2 // apparently + +// Structs. + +/** + * @brief TODO + * + * @note Size: 0xA. + */ +typedef struct SeqObj { + struct VideoState* state; // _00 + u16 width; // _04 + u16 height; // _06 + u8 h_samp; // _08 + u8 v_samp; // _09 +} SeqObj; + +/** + * @brief TODO + * + * @note Size: 0x7. + */ +typedef struct VideoInfo { + u16 hres; // _00 + u16 vres; // _02 + u8 h_samp; // _04 + u8 v_samp; // _05 + u8 video_mode; // _06 +} VideoInfo; + +// Private structs? Maybe move these to a priv header/the .c file itself + +/** + * @brief TODO + * + * @note Size: 0x2. + */ +typedef struct BlockData { + u8 value; // _00 + u8 type; // _01 +} BlockData; + +/** + * @brief TODO + * + * @note Size: 0x808. + */ +typedef struct Tree { + u32 pos; // _00 + int root; // _04 + u16 array[2][0x200]; // _08, may be u32s, need to check our version +} Tree; + +/** + * @brief TODO + * + * @note Size: 0x10. + */ +typedef struct BitBuffer { + const void* ptr; // _00 + u32 size; // _04 + u32 value; // _08 + int bit; // _0C +} BitBuffer; + +/** + * @brief TODO + * + * @note Size: 0x14. + */ +typedef struct BitBufferWithTree { + BitBuffer buf; // _00 + Tree* tree; // _10 +} BitBufferWithTree; + +/** + * @brief TODO + * + * @note Size: 0x38. + */ +typedef struct HVQPlaneDesc { + BlockData* border; // _00, beginning of plane incl. border + BlockData* payload; // _04, beginning of non-border plane data + u16 h_blocks; // _08 + u16 v_blocks; // _0A + u16 h_blocks_safe; // _0C + u16 v_blocks_safe; // _0E + u16 mcb_offset[4]; // _10 + u32 pb_offset[4]; // _18 + u16 width_in_samples; // _28 + u16 height_in_samples; // _2A + u32 size_in_samples; // _2C + u8 width_shift; // _30 + u8 height_shift; // _31 + u8 pb_per_mcb_x; // _32 + u8 pb_per_mcb_y; // _33 + u8 blocks_per_mcb; // _34 + u8 padding[3]; // _35 +} HVQPlaneDesc; + +/** + * @brief TODO + * + * @note Size: 0x15. + */ +typedef struct StackState { + u32 plane_idx; // _00 + const BlockData* line_prev; // _04 + const BlockData* line_curr; // _08 + const BlockData* line_next; // _0C + BlockData next; // _10 + BlockData curr; // _12 + u8 value_prev; // _14 +} StackState; + +/** + * @brief TODO + * + * @note Size: 0x3CD0. + */ +typedef struct VideoState { + HVQPlaneDesc planes[HVQM_PLANE_COUNT]; // _00 + Tree trees[6]; // _A8 + BitBufferWithTree dc_values[HVQM_PLANE_COUNT]; // _30D8, DC values + BitBufferWithTree dc_rle[HVQM_PLANE_COUNT]; // _3114, DC run lengths + BitBufferWithTree bufTree0[HVQM_PLANE_COUNT]; // _3150 + BitBufferWithTree basis_num[HVQM_LUMA_CHROMA]; // _318C + BitBufferWithTree basis_num_run[HVQM_LUMA_CHROMA]; // _31B4 + BitBuffer fixvl[HVQM_PLANE_COUNT]; // _31DC, uncompressed high-entropy data + BitBufferWithTree mv_h; // _320C, horizontal motion vectors + BitBufferWithTree mv_v; // _3220, vertical motion vectors + BitBufferWithTree mcb_proc; // _3234, macroblock proc + BitBufferWithTree mcb_type; // _3248, macroblock type + u16 h_nest_size; // _325C + u16 v_nest_size; // _325E + u8 is_landscape; // _3260 + u8 nest_data[70 * 38]; // _3261 + u16 dc_max; // _3CC6 + u16 dc_min; // _3CC8 + u8 unk_shift; // _3CCA + u8 dc_shift; // _3CCB + u8 mc_residual_bits_h[2]; // _3CCC, num res bits to read from mv_h, past + future + u8 mc_residual_bits_v[2]; // _3CCE, num res bits to read from mv_v, past + future +} VideoState; + +/** + * @brief TODO + * + * @note Size: 0x34. + */ +typedef struct MCPlane { + u32 rle; // _00 + u32 pb_dc; // _04 + BlockData* payload_cur_blk; // _08 + BlockData* payload_cur_row; // _0C + void* present; // _10 + void* top; // _14 + void* target; // _18 + void* past; // _1C + void* future; // _20 + u16 h_mcb_stride; // _24 + u32 v_mcb_stride; // _28 + u32 pb_per_mcb_x; // _2C + u32 stride; // _30 +} MCPlane; + +/** + * @brief TODO + * + * @note Size: 0x8. + */ +typedef struct RLDecoder { + u32 value; // _00 + u32 count; // _04 +} RLDecoder; + +// Global functions. +void HVQM4InitDecoder(); +void HVQM4InitSeqObj(SeqObj* seqObj, VideoInfo* videoInfo); +u32 HVQM4BuffSize(SeqObj* seqObj); +void HVQM4SetBuffer(SeqObj* seqObj, void* workBuffer); +void HVQM4DecodeIpic(SeqObj* seqObj, u8 const* frame, void* present); +void HVQM4DecodePpic(SeqObj* seqObj, u8 const* frame, void* present, void* past); +void HVQM4DecodeBpic(SeqObj* seqObj, u8 const* frame, void* present, void* past, void* future); + +///////////////////////////////////////////////////////// + +#ifdef __cplusplus +}; +#endif // ifdef __cplusplus + +#endif diff --git a/include/system.h b/include/system.h index 0f68b7a7..cd2ab2dc 100644 --- a/include/system.h +++ b/include/system.h @@ -307,6 +307,7 @@ struct DVDStream : public RandomAccessStream { bool mIsFileOpen; // _4C, trigger to do DVDClose on close() }; +static inline f32 randFloat() { return System::getRand(1.0f); } static inline f32 randFloat(f32 max) { return max * System::getRand(1.0f); } static inline f32 randBalanced(f32 centre) { return System::getRand(1.0f) - centre; } static inline bool coinFlip() { return System::getRand(1.0f) > 0.5f; } diff --git a/src/hvqm4dec/hvqm4dec.c b/src/hvqm4dec/hvqm4dec.c index 4cb03ee8..ef25bdc9 100644 --- a/src/hvqm4dec/hvqm4dec.c +++ b/src/hvqm4dec/hvqm4dec.c @@ -1,12 +1,48 @@ #include "types.h" +#include "hvqm4.h" + +/* + +Initial code attempts + comments + function arguments/naming guides taken from +http://github.com/Tilka/hvqm4 +with many thanks. + +*/ + +static int clipTable[0x80]; +static int divTable[0x10]; +static int mcdivTable[0x200]; + +static u32 readTree_signed; +static u32 readTree_scale; + +// forward declarations +static u8 getByte(BitBuffer* buf); +static s16 getBit(BitBuffer* buf); /* * --INFO-- * Address: 8001EC3C * Size: 000360 */ -void init_global_constants(void) +static void init_global_constants() { + int i; + clipTable[0] = 0; + // this is wrong + for (i = 1; i < 0x80; i++) { + clipTable[i] = 0x1000 / i; + } + + // these are right + divTable[0] = 0; + for (i = 1; i < 0x10; i++) { + divTable[i] = 0x1000 / (i * 16) * 16; + } + mcdivTable[0] = 0; + for (i = 1; i < 0x200; i++) { + mcdivTable[i] = 0x1000 / i; + } /* .loc_0x0: stwu r1, -0x18(r1) @@ -277,9 +313,10 @@ void init_global_constants(void) * Address: ........ * Size: 000014 */ -void set_border(void) +static void set_border(BlockData* dst) { - // UNUSED FUNCTION + dst->value = 0x7F; + dst->type = 0xFF; } /* @@ -287,90 +324,38 @@ void set_border(void) * Address: 8001EF9C * Size: 00011C */ -void setHVQPlaneDesc(void) +static void setHVQPlaneDesc(SeqObj* seqObj, u32 planeIdx, u8 hSamp, u8 vSamp) { - /* - .loc_0x0: - rlwinm r0,r5,0,24,31 - lwz r7, 0x0(r3) - mulli r4, r4, 0x38 - cmplwi r0, 0x2 - add r4, r7, r4 - bne- .loc_0x20 - li r0, 0x1 - b .loc_0x24 - - .loc_0x20: - li r0, 0 - - .loc_0x24: - stb r0, 0x30(r4) - rlwinm r0,r6,0,24,31 - cmplwi r0, 0x2 - lhz r7, 0x4(r3) - lbz r0, 0x30(r4) - sraw r0, r7, r0 - sth r0, 0x28(r4) - bne- .loc_0x4C - li r0, 0x1 - b .loc_0x50 - - .loc_0x4C: - li r0, 0 - - .loc_0x50: - stb r0, 0x31(r4) - rlwinm r8,r5,2,22,29 - rlwinm r7,r6,2,22,29 - lhz r9, 0x6(r3) - li r10, 0x2 - lbz r0, 0x31(r4) - li r6, 0 - li r5, 0x1 - sraw r0, r9, r0 - sth r0, 0x2A(r4) - li r0, 0x4 - lhz r11, 0x28(r4) - lhz r9, 0x2A(r4) - mullw r9, r11, r9 - stw r9, 0x2C(r4) - lbz r9, 0x30(r4) - sraw r9, r10, r9 - stb r9, 0x32(r4) - lbz r9, 0x31(r4) - sraw r9, r10, r9 - stb r9, 0x33(r4) - lbz r10, 0x32(r4) - lbz r9, 0x33(r4) - mullw r9, r10, r9 - stb r9, 0x34(r4) - lhz r9, 0x4(r3) - divw r8, r9, r8 - sth r8, 0x8(r4) - lhz r3, 0x6(r3) - divw r3, r3, r7 - sth r3, 0xA(r4) - lhz r3, 0x8(r4) - addi r3, r3, 0x2 - sth r3, 0xC(r4) - lhz r3, 0xA(r4) - addi r3, r3, 0x2 - sth r3, 0xE(r4) - sth r6, 0x10(r4) - sth r5, 0x16(r4) - lhz r3, 0xC(r4) - sth r3, 0x12(r4) - addi r3, r3, 0x1 - sth r3, 0x14(r4) - stw r6, 0x18(r4) - stw r0, 0x24(r4) - lhz r0, 0x28(r4) - rlwinm r3,r0,2,0,29 - stw r3, 0x1C(r4) - addi r0, r3, 0x4 - stw r0, 0x20(r4) - blr - */ + u32 mcb, pb; + HVQPlaneDesc* plane = &seqObj->state->planes[planeIdx]; + plane->width_shift = (hSamp == 2) ? 1 : 0; + plane->width_in_samples = seqObj->width >> plane->width_shift; + plane->height_shift = (vSamp == 2) ? 1 : 0; + plane->height_in_samples = seqObj->height >> plane->height_shift; + plane->size_in_samples = plane->width_in_samples * plane->height_in_samples; + + // pixels per 2x2 block + plane->pb_per_mcb_x = 2 >> plane->width_shift; // 1..2 + plane->pb_per_mcb_y = 2 >> plane->height_shift; // 1..2 + plane->blocks_per_mcb = plane->pb_per_mcb_x * plane->pb_per_mcb_y; // 1..4 + // number of 4x4 blocks + plane->h_blocks = seqObj->width / (hSamp * 4); + plane->v_blocks = seqObj->height / (vSamp * 4); + // number of 4x4 blocks + border + plane->h_blocks_safe = plane->h_blocks + 2; + plane->v_blocks_safe = plane->v_blocks + 2; + // offset of blocks in MCB + plane->mcb_offset[0] = 0; + plane->mcb_offset[3] = 1; + mcb = plane->h_blocks_safe; + plane->mcb_offset[1] = mcb; + plane->mcb_offset[2] = mcb + 1; + + plane->pb_offset[0] = 0; + plane->pb_offset[3] = 4; + pb = plane->width_in_samples << 2; + plane->pb_offset[1] = pb; + plane->pb_offset[2] = pb + 4; } /* @@ -378,7 +363,7 @@ void setHVQPlaneDesc(void) * Address: ........ * Size: 000030 */ -void setCode(void) +static void setCode(BitBuffer* dst, const void* src) { // UNUSED FUNCTION } @@ -388,7 +373,7 @@ void setCode(void) * Address: 8001F0B8 * Size: 0002CC */ -void _readTree(void) +static s16 _readTree(Tree* dst, BitBuffer* src) { /* .loc_0x0: @@ -615,7 +600,7 @@ void _readTree(void) * Address: 8001F384 * Size: 000064 */ -void getByte(void) +static u8 getByte(BitBuffer* buf) { /* .loc_0x0: @@ -656,7 +641,7 @@ void getByte(void) * Address: ........ * Size: 000140 */ -void readTree(void) +static void readTree(BitBufferWithTree* buf, u32 isSigned, u32 scale) { // UNUSED FUNCTION } @@ -666,7 +651,7 @@ void readTree(void) * Address: ........ * Size: 000084 */ -void decodeUOvfSym(void) +static int decodeUOvfSym(BitBufferWithTree* buf, int max) { // UNUSED FUNCTION } @@ -676,7 +661,7 @@ void decodeUOvfSym(void) * Address: 8001F3E8 * Size: 0002C4 */ -void Ipic_BasisNumDec(void) +static void Ipic_BasisNumDec(VideoState* state) { /* .loc_0x0: @@ -925,7 +910,7 @@ void Ipic_BasisNumDec(void) * Address: 8001F6AC * Size: 00013C */ -void IpicDcvDec(void) +static void IpicDcvDec(VideoState* state) { /* .loc_0x0: @@ -1038,7 +1023,7 @@ void IpicDcvDec(void) * Address: 8001F7E8 * Size: 000040 */ -void getBit(void) +static s16 getBit(BitBuffer* buf) { /* .loc_0x0: @@ -1070,7 +1055,7 @@ void getBit(void) * Address: 8001F828 * Size: 000070 */ -void decodeHuff(void) +static u32 decodeHuff(BitBufferWithTree* buf) { /* .loc_0x0: @@ -1118,7 +1103,7 @@ void decodeHuff(void) * Address: 8001F898 * Size: 0003A4 */ -void MakeNest(void) +static void MakeNest(VideoState* state, u16 nestX, u16 nestY) { /* .loc_0x0: @@ -1427,7 +1412,7 @@ void MakeNest(void) * Address: 8001FC3C * Size: 000198 */ -void WeightImBlock(void) +static void WeightImBlock(u8* dst, u32 stride, u8 value, u8 top, u8 bottom, u8 left, u8 right) { /* .loc_0x0: @@ -1541,7 +1526,7 @@ void WeightImBlock(void) * Address: 8001FDD4 * Size: 000048 */ -void OrgBlock(void) +static void OrgBlock(VideoState* state, u8* dst, u32 dstStride, u32 planeIdx) { /* .loc_0x0: @@ -1570,8 +1555,10 @@ void OrgBlock(void) * --INFO-- * Address: 8001FE1C * Size: 0003D0 + * + * @note: AOT = Adaptive Orthogonal Transform, apparently */ -void IntraAotBlock(void) +static void IntraAotBlock(VideoState* state, u8* dst, u32 stride, u8 targetAverage, u8 blockType, u32 planeIdx) { /* .loc_0x0: @@ -1837,7 +1824,7 @@ void IntraAotBlock(void) * Address: 800201EC * Size: 00047C */ -void GetAotBasis(void) +static u32 GetAotBasis(VideoState* state, u8 basisOut[4][4], int* sum, const u8* nestData, u32 nestStride, u32 planeIdx) { /* .loc_0x0: @@ -2212,7 +2199,7 @@ void GetAotBasis(void) * Address: 80020668 * Size: 000144 */ -void IpicBlockDec(void) +static void IpicBlockDec(VideoState* state, u8* dst, u32 stride, StackState* stackState) { /* .loc_0x0: @@ -2323,7 +2310,7 @@ void IpicBlockDec(void) * Address: 800207AC * Size: 0000D4 */ -void IpicLineDec(void) +static void IpicLineDec(VideoState* state, u8* dst, u32 stride, StackState* stackState, u16 hBlocks) { /* .loc_0x0: @@ -2392,7 +2379,7 @@ void IpicLineDec(void) * Address: 80020880 * Size: 0000DC */ -void IpicPlaneDec(void) +static void IpicPlaneDec(VideoState* state, int planeIdx, u8* dst) { /* .loc_0x0: @@ -2463,7 +2450,7 @@ void IpicPlaneDec(void) * Address: 8002095C * Size: 00008C */ -void initMCHandler(void) +static void initMCHandler(VideoState* state, MCPlane mcplanes[HVQM_PLANE_COUNT], void* present, void* past, void* future) { /* .loc_0x0: @@ -2512,7 +2499,7 @@ void initMCHandler(void) * Address: ........ * Size: 00004C */ -void resetMCHandler(void) +static void resetMCHandler(VideoState* state, MCPlane mcplanes[HVQM_PLANE_COUNT], void* present) { // UNUSED FUNCTION } @@ -2521,8 +2508,10 @@ void resetMCHandler(void) * --INFO-- * Address: 800209E8 * Size: 00009C + * + * @note Copy 4x4 samples without interpolation. */ -void _MotionComp_00(void) +static void _MotionComp_00(u8* dst, u32 dstStride, const u8* src, u32 srcStride) { /* .loc_0x0: @@ -2572,8 +2561,10 @@ void _MotionComp_00(void) * --INFO-- * Address: 80020A84 * Size: 0001AC + * + * @note Offset vertically by half a sample */ -void _MotionComp_01(void) +static void _MotionComp_01(u8* dst, u32 dstStride, const u8* src, u32 srcStride) { /* .loc_0x0: @@ -2691,8 +2682,10 @@ void _MotionComp_01(void) * --INFO-- * Address: 80020C30 * Size: 00019C + * + * @note Offset vertically by half a sample */ -void _MotionComp_10(void) +static void _MotionComp_10(u8* dst, u32 dstStride, const u8* src, u32 srcStride) { /* .loc_0x0: @@ -2806,8 +2799,10 @@ void _MotionComp_10(void) * --INFO-- * Address: 80020DCC * Size: 0002AC + * + * @note Offset by half a sample in both directions */ -void _MotionComp_11(void) +static void _MotionComp_11(u8* dst, u32 dstStride, const u8* src, u32 srcStride) { /* .loc_0x0: @@ -2989,8 +2984,10 @@ void _MotionComp_11(void) * --INFO-- * Address: 80021078 * Size: 000A00 + * + * @note hpel = half-pixel offset. DX = horizontal, DY = vertical. */ -void MotionComp(void) +static void MotionComp(void* dst, u32 dstStride, const void* src, u32 srcStride, u32 hpeldx, u32 hpeldy) { /* .loc_0x0: @@ -3678,7 +3675,7 @@ void MotionComp(void) * Address: 80021A78 * Size: 00041C */ -void decode_PB_cc(void) +static void decode_PB_cc(VideoState* state, MCPlane mcplanes[HVQM_PLANE_COUNT], u32 proc, u32 type) { /* .loc_0x0: @@ -4017,7 +4014,8 @@ void decode_PB_cc(void) * Address: 80021E94 * Size: 00086C */ -void PrediAotBlock(void) +static void PrediAotBlock(VideoState* state, u8* dst, const u8* src, u32 stride, u8 blockType, u8* nestData, u32 hNestSize, u32 planeIdx, + u32 hpeldx, u32 hpeldy) { /* .loc_0x0: @@ -4650,7 +4648,7 @@ void PrediAotBlock(void) * Address: 80022700 * Size: 0004C4 */ -void GetMCAotBasis(void) +static u32 GetMCAotBasis(VideoState* state, u8 basisOut[4][4], int* sum, const u8* nestData, u32 nestStride, u32 planeIdx) { /* .loc_0x0: @@ -5043,7 +5041,7 @@ void GetMCAotBasis(void) * Address: 80022BC4 * Size: 000164 */ -void MCBlockDecMCNest(void) +static void MCBlockDecMCNest(VideoState* state, MCPlane mcplanes[HVQM_PLANE_COUNT], int x, int y) { /* .loc_0x0: @@ -5156,7 +5154,7 @@ void MCBlockDecMCNest(void) * Address: 80022D28 * Size: 000158 */ -void MCBlockDecDCNest(void) +static void MCBlockDecDCNest(VideoState* state, MCPlane mcplanes[HVQM_PLANE_COUNT]) { /* .loc_0x0: @@ -5280,7 +5278,7 @@ void MCBlockDecDCNest(void) * Address: ........ * Size: 0000C8 */ -void initMCBproc(void) +static void initMCBproc(BitBufferWithTree* buftree, RLDecoder* proc) { // UNUSED FUNCTION } @@ -5290,7 +5288,7 @@ void initMCBproc(void) * Address: ........ * Size: 0000A4 */ -void getMCBproc(void) +static u32 getMCBproc(BitBufferWithTree* buftree, RLDecoder* proc) { // UNUSED FUNCTION } @@ -5300,7 +5298,7 @@ void getMCBproc(void) * Address: ........ * Size: 000110 */ -void initMCBtype(void) +static void initMCBtype(BitBufferWithTree* buftree, RLDecoder* type) { // UNUSED FUNCTION } @@ -5310,7 +5308,7 @@ void initMCBtype(void) * Address: ........ * Size: 0000F8 */ -void getMCBtype(void) +static u32 getMCBtype(BitBufferWithTree* buftree, RLDecoder* type) { // UNUSED FUNCTION } @@ -5320,7 +5318,7 @@ void getMCBtype(void) * Address: 80022E80 * Size: 000430 */ -void spread_PB_descMap(void) +static void spread_PB_descMap(SeqObj* seqObj, MCPlane mcplanes[HVQM_PLANE_COUNT]) { /* .loc_0x0: @@ -5652,7 +5650,7 @@ void spread_PB_descMap(void) * Address: 800232B0 * Size: 00043C */ -void BpicPlaneDec(void) +static void BpicPlaneDec(SeqObj* seqObj, void* present, void* past, void* future) { /* .loc_0x0: @@ -5987,40 +5985,19 @@ void BpicPlaneDec(void) * Address: 800236EC * Size: 000020 */ -void HVQM4InitDecoder(void) -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x8(r1) - bl -0x4ABC - lwz r0, 0xC(r1) - addi r1, r1, 0x8 - mtlr r0 - blr - */ -} +void HVQM4InitDecoder() { init_global_constants(); } /* * --INFO-- * Address: 8002370C * Size: 000024 */ -void HVQM4InitSeqObj(void) +void HVQM4InitSeqObj(SeqObj* seqObj, VideoInfo* videoInfo) { - /* - .loc_0x0: - lhz r0, 0x0(r4) - sth r0, 0x4(r3) - lhz r0, 0x2(r4) - sth r0, 0x6(r3) - lbz r0, 0x4(r4) - stb r0, 0x8(r3) - lbz r0, 0x5(r4) - stb r0, 0x9(r3) - blr - */ + seqObj->width = videoInfo->hres; + seqObj->height = videoInfo->vres; + seqObj->h_samp = videoInfo->h_samp; + seqObj->v_samp = videoInfo->v_samp; } /* @@ -6028,7 +6005,7 @@ void HVQM4InitSeqObj(void) * Address: 80023730 * Size: 000074 */ -void HVQM4BuffSize(void) +u32 HVQM4BuffSize(SeqObj*) { /* .loc_0x0: @@ -6077,7 +6054,7 @@ void HVQM4BuffSize(void) * Address: 800237A4 * Size: 000464 */ -void HVQM4SetBuffer(void) +void HVQM4SetBuffer(SeqObj*, void*) { /* .loc_0x0: @@ -6408,7 +6385,7 @@ void HVQM4SetBuffer(void) * Address: 80023C08 * Size: 000510 */ -void HVQM4DecodeIpic(void) +void HVQM4DecodeIpic(SeqObj*, const u8*, void*) { /* .loc_0x0: @@ -6826,30 +6803,14 @@ void HVQM4DecodeIpic(void) * Address: 80024118 * Size: 000024 */ -void HVQM4DecodePpic(void) -{ - /* - .loc_0x0: - mflr r0 - mr r7, r5 - stw r0, 0x4(r1) - stwu r1, -0x8(r1) - bl .loc_0x24 - lwz r0, 0xC(r1) - addi r1, r1, 0x8 - mtlr r0 - blr - - .loc_0x24: - */ -} +void HVQM4DecodePpic(SeqObj* seqObj, const u8* frame, void* present, void* past) { HVQM4DecodeBpic(seqObj, frame, present, past, present); } /* * --INFO-- * Address: 8002413C * Size: 0005A8 */ -void HVQM4DecodeBpic(void) +void HVQM4DecodeBpic(SeqObj* seqObj, const u8* frame, void* present, void* past, void* future) { /* .loc_0x0: diff --git a/src/plugPikiKando/naviState.cpp b/src/plugPikiKando/naviState.cpp index 0555713e..624b099d 100644 --- a/src/plugPikiKando/naviState.cpp +++ b/src/plugPikiKando/naviState.cpp @@ -6,7 +6,9 @@ #include "SoundMgr.h" #include "Kontroller.h" #include "gameflow.h" +#include "UtilityKando.h" #include "PlayerState.h" +#include "RumbleMgr.h" #include "EffectMgr.h" #include "UfoItem.h" #include "MoviePlayer.h" @@ -14,9 +16,11 @@ #include "NaviMgr.h" #include "Interface.h" #include "GameCoreSection.h" +#include "PikiMacros.h" #include "jaudio/PikiDemo.h" #include "GoalItem.h" #include "UtEffect.h" +#include "CPlate.h" /* * --INFO-- @@ -2803,6 +2807,17 @@ NaviContainerState::NaviContainerState() */ void NaviContainerState::init(Navi* navi) { + navi->_70C = 1; + rumbleMgr->stop(); + int pikisInParty = 0; + CPlate* plate = navi->mPlateMgr; + TRAVERSELOOP(plate, idx) + { + Piki* piki = static_cast(plate->getCreatureCheck(idx)); + if (piki->mColor == navi->mGoalItem->_428) { + pikisInParty++; + } + } /* .loc_0x0: mflr r0 @@ -2962,25 +2977,18 @@ void NaviContainerState::init(Navi* navi) * Address: 80105294 * Size: 000030 */ -void NaviContainerState::informWin(int) +void NaviContainerState::informWin(int p1) { - /* - .loc_0x0: - cmpwi r4, 0 - ble- .loc_0x18 - li r0, 0x1 - stw r0, 0x18(r3) - stw r4, 0x1C(r3) - blr + if (p1 > 0) { + _18 = 1; + _1C = p1; + return; + } - .loc_0x18: - bgelr- - li r0, 0x2 - stw r0, 0x18(r3) - neg r0, r4 - stw r0, 0x1C(r3) - blr - */ + if (p1 < 0) { + _18 = 2; + _1C = -p1; + } } /* @@ -2990,15 +2998,9 @@ void NaviContainerState::informWin(int) */ void NaviContainerState::onCloseWindow() { - /* - .loc_0x0: - lwz r0, 0x18(r3) - cmpwi r0, 0 - bnelr- - li r0, 0x3 - stw r0, 0x18(r3) - blr - */ + if (_18 == 0) { + _18 = 3; + } } /* @@ -3008,6 +3010,7 @@ void NaviContainerState::onCloseWindow() */ void NaviContainerState::exec(Navi* navi) { + /* .loc_0x0: mflr r0 @@ -3244,22 +3247,7 @@ void NaviContainerState::enterPikis(Navi* navi, int) * Address: 801055AC * Size: 000028 */ -void NaviContainerState::exitPikis(Navi* navi, int) -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x8(r1) - lwz r3, 0x708(r4) - mr r4, r5 - bl -0x1A2A4 - lwz r0, 0xC(r1) - addi r1, r1, 0x8 - mtlr r0 - blr - */ -} +void NaviContainerState::exitPikis(Navi* navi, int p2) { navi->mGoalItem->exitPikis(p2); } /* * --INFO-- @@ -3268,23 +3256,8 @@ void NaviContainerState::exitPikis(Navi* navi, int) */ void NaviContainerState::cleanup(Navi* navi) { - /* - .loc_0x0: - mflr r0 - lis r3, 0x803A - stw r0, 0x4(r1) - subi r3, r3, 0x2848 - li r0, 0 - stwu r1, -0x8(r1) - stw r0, 0x33C(r3) - lwz r3, 0x708(r4) - li r4, 0x1 - bl -0x1A690 - lwz r0, 0xC(r1) - addi r1, r1, 0x8 - mtlr r0 - blr - */ + gameflow._33C = 0; + navi->mGoalItem->setSpotActive(true); } /* @@ -3311,37 +3284,10 @@ void NaviPickState::procAnimMsg(Navi* navi, MsgAnim*) { } */ void NaviPickState::init(Navi* navi) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x30(r1) - stw r31, 0x2C(r1) - addi r3, r1, 0x18 - stw r30, 0x28(r1) - addi r30, r4, 0 - li r4, 0 - bl 0x198E4 - addi r31, r3, 0 - addi r3, r1, 0x20 - li r4, 0x4 - bl 0x198D4 - addi r4, r3, 0 - addi r3, r30, 0 - addi r5, r31, 0 - bl -0xAE24 - lfs f0, -0x61E4(r2) - mr r3, r30 - stfs f0, 0x864(r30) - stfs f0, 0x8B8(r30) - bl -0xAE00 - lwz r0, 0x34(r1) - lwz r31, 0x2C(r1) - lwz r30, 0x28(r1) - addi r1, r1, 0x30 - mtlr r0 - blr - */ + navi->startMotion(PaniMotionInfo(PIKIANIM_Pick), PaniMotionInfo(PIKIANIM_Run)); + navi->mNaviAnimMgr.getAnimator()->mCurrentFrame = 11.0f; + navi->mNaviAnimMgr.getBlendAnimator()->mCurrentFrame = 11.0f; + navi->enableMotionBlend(); } /* @@ -3351,32 +3297,9 @@ void NaviPickState::init(Navi* navi) */ void NaviPickState::exec(Navi* navi) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x8(r1) - lwz r0, 0x184(r4) - cmplwi r0, 0 - beq- .loc_0x28 - lwz r5, 0x2E4(r4) - lwz r0, 0x28(r5) - rlwinm. r0,r0,0,18,18 - beq- .loc_0x3C - - .loc_0x28: - lwz r12, 0x0(r3) - li r5, 0 - lwz r12, 0x4C(r12) - mtlr r12 - blrl - - .loc_0x3C: - lwz r0, 0xC(r1) - addi r1, r1, 0x8 - mtlr r0 - blr - */ + if (!navi->mStickTarget || navi->mKontroller->isPressed(KBBTN_B)) { + transit(navi, NAVISTATE_Walk); + } } /* @@ -3384,21 +3307,7 @@ void NaviPickState::exec(Navi* navi) * Address: 80105710 * Size: 000024 */ -void NaviPickState::cleanup(Navi* navi) -{ - /* - .loc_0x0: - mflr r0 - mr r3, r4 - stw r0, 0x4(r1) - stwu r1, -0x8(r1) - bl -0x74EA8 - lwz r0, 0xC(r1) - addi r1, r1, 0x8 - mtlr r0 - blr - */ -} +void NaviPickState::cleanup(Navi* navi) { navi->endStickObject(); } /* * --INFO-- @@ -3415,43 +3324,7 @@ NaviRopeState::NaviRopeState() * Address: 80105778 * Size: 000074 */ -void NaviRopeState::init(Navi* navi) -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x30(r1) - stw r31, 0x2C(r1) - stw r30, 0x28(r1) - stw r29, 0x24(r1) - mr. r29, r4 - addi r30, r29, 0 - beq- .loc_0x28 - addi r30, r30, 0x2B8 - - .loc_0x28: - addi r3, r1, 0x10 - li r4, 0x3E - bl 0x197B0 - addi r31, r3, 0 - addi r5, r30, 0 - addi r3, r1, 0x18 - li r4, 0x3E - bl 0x197D0 - addi r4, r3, 0 - addi r3, r29, 0 - addi r5, r31, 0 - bl -0xAF5C - lwz r0, 0x34(r1) - lwz r31, 0x2C(r1) - lwz r30, 0x28(r1) - lwz r29, 0x24(r1) - addi r1, r1, 0x30 - mtlr r0 - blr - */ -} +void NaviRopeState::init(Navi* navi) { navi->startMotion(PaniMotionInfo(PIKIANIM_HNoboru, navi), PaniMotionInfo(PIKIANIM_HNoboru)); } /* * --INFO-- @@ -3652,66 +3525,12 @@ NaviRopeExitState::NaviRopeExitState() */ void NaviRopeExitState::init(Navi* navi) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x48(r1) - stfd f31, 0x40(r1) - stfd f30, 0x38(r1) - stw r31, 0x34(r1) - stw r30, 0x30(r1) - stw r29, 0x2C(r1) - addi r29, r4, 0 - addi r3, r29, 0 - bl -0x74ECC - cmplwi r29, 0 - addi r30, r29, 0 - beq- .loc_0x3C - addi r30, r30, 0x2B8 - - .loc_0x3C: - addi r3, r1, 0x10 - li r4, 0x15 - bl 0x19484 - addi r31, r3, 0 - addi r5, r30, 0 - addi r3, r1, 0x18 - li r4, 0x15 - bl 0x194A4 - addi r4, r3, 0 - addi r3, r29, 0 - addi r5, r31, 0 - bl -0xB288 - lfs f30, 0xA0(r29) - fmr f1, f30 - bl 0x116050 - lfs f0, -0x61D4(r2) - fmuls f31, f0, f1 - fmr f1, f30 - bl 0x1161D4 - lfs f0, -0x61D4(r2) - fmuls f0, f0, f1 - stfs f0, 0x70(r29) - lfs f0, -0x297C(r13) - stfs f0, 0x74(r29) - stfs f31, 0x78(r29) - lwz r3, 0x70(r29) - lwz r0, 0x74(r29) - stw r3, 0xA4(r29) - stw r0, 0xA8(r29) - lwz r0, 0x78(r29) - stw r0, 0xAC(r29) - lwz r0, 0x4C(r1) - lfd f31, 0x40(r1) - lfd f30, 0x38(r1) - lwz r31, 0x34(r1) - lwz r30, 0x30(r1) - lwz r29, 0x2C(r1) - addi r1, r1, 0x48 - mtlr r0 - blr - */ + u32 badCompiler; + navi->endRope(); + navi->startMotion(PaniMotionInfo(PIKIANIM_Jump, navi), PaniMotionInfo(PIKIANIM_Jump)); + f32 angle = navi->mDirection; + navi->_70.set(50.0f * sinf(angle), 200.0f, 50.0f * cosf(angle)); + navi->_A4 = navi->_70; } /* @@ -3733,24 +3552,7 @@ void NaviRopeExitState::cleanup(Navi* navi) { } * Address: 80105B74 * Size: 000030 */ -void NaviRopeExitState::procBounceMsg(Navi* navi, MsgBounce*) -{ - /* - .loc_0x0: - mflr r0 - li r5, 0 - stw r0, 0x4(r1) - stwu r1, -0x8(r1) - lwz r12, 0x0(r3) - lwz r12, 0x4C(r12) - mtlr r12 - blrl - lwz r0, 0xC(r1) - addi r1, r1, 0x8 - mtlr r0 - blr - */ -} +void NaviRopeExitState::procBounceMsg(Navi* navi, MsgBounce*) { transit(navi, NAVISTATE_Walk); } /* * --INFO-- @@ -3769,50 +3571,9 @@ NaviFunbariState::NaviFunbariState() */ void NaviFunbariState::init(Navi* navi) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x30(r1) - stw r31, 0x2C(r1) - stw r30, 0x28(r1) - stw r29, 0x24(r1) - mr. r29, r4 - addi r30, r29, 0 - beq- .loc_0x28 - addi r30, r30, 0x2B8 - - .loc_0x28: - addi r3, r1, 0x10 - li r4, 0x30 - bl 0x19340 - addi r31, r3, 0 - addi r5, r30, 0 - addi r3, r1, 0x18 - li r4, 0x30 - bl 0x19360 - addi r4, r3, 0 - addi r3, r29, 0 - addi r5, r31, 0 - bl -0xB3CC - cmplwi r29, 0 - addi r4, r29, 0 - beq- .loc_0x68 - addi r4, r4, 0x2B8 - - .loc_0x68: - addi r3, r29, 0x834 - bl 0x19E6C - li r0, 0x1 - stb r0, 0xACC(r29) - lwz r0, 0x34(r1) - lwz r31, 0x2C(r1) - lwz r30, 0x28(r1) - lwz r29, 0x24(r1) - addi r1, r1, 0x30 - mtlr r0 - blr - */ + navi->startMotion(PaniMotionInfo(PIKIANIM_Kuttuku, navi), PaniMotionInfo(PIKIANIM_Kuttuku)); + navi->mNaviAnimMgr.finishMotion(navi); + navi->_ACC = 1; } /* @@ -3820,51 +3581,20 @@ void NaviFunbariState::init(Navi* navi) * Address: 80105C7C * Size: 00001C */ -void NaviFunbariState::exec(Navi* navi) -{ - /* - .loc_0x0: - lfs f0, -0x2978(r13) - stfs f0, 0xA4(r4) - lfs f0, -0x2974(r13) - stfs f0, 0xA8(r4) - lfs f0, -0x2970(r13) - stfs f0, 0xAC(r4) - blr - */ -} +void NaviFunbariState::exec(Navi* navi) { navi->_A4.set(0.0f, 0.0f, 0.0f); } /* * --INFO-- * Address: 80105C98 * Size: 000044 */ -void NaviFunbariState::procAnimMsg(Navi* navi, MsgAnim*) +void NaviFunbariState::procAnimMsg(Navi* navi, MsgAnim* msg) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x8(r1) - lwz r5, 0x4(r5) - lwz r0, 0x0(r5) - cmpwi r0, 0 - beq- .loc_0x20 - b .loc_0x34 - - .loc_0x20: - lwz r12, 0x0(r3) - li r5, 0 - lwz r12, 0x4C(r12) - mtlr r12 - blrl - - .loc_0x34: - lwz r0, 0xC(r1) - addi r1, r1, 0x8 - mtlr r0 - blr - */ + switch (msg->mKeyEvent->mEventType) { + case KEY_Done: + transit(navi, NAVISTATE_Walk); + break; + } } /* @@ -3891,62 +3621,17 @@ NaviIdleState::NaviIdleState() */ void NaviIdleState::init(Navi* navi) { - /* - .loc_0x0: - mflr r0 - lis r5, 0x8022 - stw r0, 0x4(r1) - addi r6, r5, 0x2680 - stwu r1, -0x58(r1) - stmw r27, 0x44(r1) - mr r27, r3 - addi r28, r4, 0 - addi r3, r1, 0x20 - li r4, 0x4 - lwz r5, 0x0(r6) - lwz r0, 0x4(r6) - stw r5, 0x20(r1) - stw r0, 0x24(r1) - lwz r5, 0x8(r6) - lwz r0, 0xC(r6) - stw r5, 0x28(r1) - stw r0, 0x2C(r1) - lwz r5, 0x10(r6) - lwz r0, 0x14(r6) - stw r5, 0x30(r1) - stw r0, 0x34(r1) - lwz r5, 0x18(r6) - lwz r0, 0x1C(r6) - stw r5, 0x38(r1) - stw r0, 0x3C(r1) - bl 0x10384 - cmplwi r28, 0 - addi r29, r3, 0 - addi r30, r28, 0 - beq- .loc_0x80 - addi r30, r30, 0x2B8 + Choice motionIDs[4] = { + { PIKIANIM_Rinbow, 0.1f }, + { PIKIANIM_Sagasu2, 0.1f }, + { PIKIANIM_Wait, 0.5f }, + { PIKIANIM_Furimuku, 0.3f }, + }; - .loc_0x80: - addi r3, r1, 0x10 - addi r4, r29, 0 - bl 0x191AC - addi r31, r3, 0 - addi r4, r29, 0 - addi r5, r30, 0 - addi r3, r1, 0x18 - bl 0x191CC - addi r4, r3, 0 - addi r3, r28, 0 - addi r5, r31, 0 - bl -0xB560 - li r0, 0 - stb r0, 0x14(r27) - lmw r27, 0x44(r1) - lwz r0, 0x5C(r1) - addi r1, r1, 0x58 - mtlr r0 - blr - */ + int randID = selectRandomly(motionIDs, 4); + + navi->startMotion(PaniMotionInfo(randID, navi), PaniMotionInfo(randID)); + mStopBeingIdle = false; } /* @@ -3956,98 +3641,24 @@ void NaviIdleState::init(Navi* navi) */ void NaviIdleState::exec(Navi* navi) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x50(r1) - stw r31, 0x4C(r1) - addi r31, r4, 0 - li r4, 0 - stw r30, 0x48(r1) - addi r30, r3, 0 - addi r3, r31, 0 - bl -0x8324 - lbz r0, 0x14(r30) - cmplwi r0, 0 - bne- .loc_0x44 - lfs f1, 0x738(r31) - lfs f0, -0x625C(r2) - fcmpo cr0, f1, f0 - blt- .loc_0xB4 - - .loc_0x44: - lwz r3, 0x2E4(r31) - lwz r3, 0x20(r3) - rlwinm. r0,r3,0,19,19 - bne- .loc_0xB4 - rlwinm. r0,r3,0,18,18 - bne- .loc_0xB4 - rlwinm. r0,r3,0,17,17 - bne- .loc_0xB4 - rlwinm. r0,r3,0,14,14 - bne- .loc_0xB4 - rlwinm. r0,r3,0,13,13 - bne- .loc_0xB4 - rlwinm. r0,r3,0,9,9 - bne- .loc_0xB4 - rlwinm. r0,r3,0,11,11 - bne- .loc_0xB4 - rlwinm. r0,r3,0,12,12 - bne- .loc_0xB4 - rlwinm. r0,r3,0,10,10 - bne- .loc_0xB4 - rlwinm. r0,r3,0,31,31 - bne- .loc_0xB4 - rlwinm. r0,r3,0,30,30 - bne- .loc_0xB4 - rlwinm. r0,r3,0,29,29 - bne- .loc_0xB4 - rlwinm. r0,r3,0,28,28 - beq- .loc_0xE0 - - .loc_0xB4: - cmplwi r31, 0 - addi r4, r31, 0 - beq- .loc_0xC4 - addi r4, r4, 0x2B8 - - .loc_0xC4: - addi r3, r31, 0x834 - bl 0x19C08 - mr r3, r31 - bl -0xB618 - li r0, 0x1 - stb r0, 0x14(r30) - b .loc_0x124 - - .loc_0xE0: - lwz r3, 0x2F6C(r13) - bl -0x85A60 - rlwinm. r0,r3,0,24,31 - bne- .loc_0x124 - lfs f1, 0x738(r31) - lfs f0, -0x61D0(r2) - fcmpo cr0, f1, f0 - ble- .loc_0x124 - lfs f0, -0x625C(r2) - addi r3, r30, 0 - addi r4, r31, 0 - stfs f0, 0x738(r31) - li r5, 0x18 - lwz r12, 0x0(r30) - lwz r12, 0x4C(r12) - mtlr r12 - blrl + navi->makeVelocity(false); + if ((!mStopBeingIdle && navi->_738 < 1.0f) || navi->mKontroller->isCurrentInput(KBBTN_A) || navi->mKontroller->isCurrentInput(KBBTN_B) + || navi->mKontroller->isCurrentInput(KBBTN_X) || navi->mKontroller->isCurrentInput(KBBTN_L) + || navi->mKontroller->isCurrentInput(KBBTN_R) || navi->mKontroller->isCurrentInput(KBBTN_MSTICK_LEFT) + || navi->mKontroller->isCurrentInput(KBBTN_MSTICK_RIGHT) || navi->mKontroller->isCurrentInput(KBBTN_MSTICK_UP) + || navi->mKontroller->isCurrentInput(KBBTN_MSTICK_DOWN) || navi->mKontroller->isCurrentInput(KBBTN_CSTICK_LEFT) + || navi->mKontroller->isCurrentInput(KBBTN_CSTICK_RIGHT) || navi->mKontroller->isCurrentInput(KBBTN_CSTICK_UP) + || navi->mKontroller->isCurrentInput(KBBTN_CSTICK_DOWN)) { + navi->mNaviAnimMgr.finishMotion(navi); + navi->enableMotionBlend(); + mStopBeingIdle = true; + return; + } - .loc_0x124: - lwz r0, 0x54(r1) - lwz r31, 0x4C(r1) - lwz r30, 0x48(r1) - addi r1, r1, 0x50 - mtlr r0 - blr - */ + if (!playerState->isTutorial() && navi->_738 > 140.0f) { + navi->_738 = 1.0f; + transit(navi, NAVISTATE_Pellet); + } } /* @@ -4055,42 +3666,17 @@ void NaviIdleState::exec(Navi* navi) * Address: 80105F2C * Size: 000064 */ -void NaviIdleState::procAnimMsg(Navi* navi, MsgAnim*) +void NaviIdleState::procAnimMsg(Navi* navi, MsgAnim* msg) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x8(r1) - lwz r5, 0x4(r5) - lwz r0, 0x0(r5) - cmpwi r0, 0 - beq- .loc_0x20 - b .loc_0x54 - - .loc_0x20: - lbz r0, 0x14(r3) - cmplwi r0, 0 - beq- .loc_0x44 - lwz r12, 0x0(r3) - li r5, 0 - lwz r12, 0x4C(r12) - mtlr r12 - blrl - b .loc_0x54 - - .loc_0x44: - lwz r12, 0x0(r3) - lwz r12, 0x38(r12) - mtlr r12 - blrl - - .loc_0x54: - lwz r0, 0xC(r1) - addi r1, r1, 0x8 - mtlr r0 - blr - */ + switch (msg->mKeyEvent->mEventType) { + case KEY_Done: + if (mStopBeingIdle) { + transit(navi, NAVISTATE_Walk); + } else { + init(navi); + } + break; + } } /* @@ -4098,15 +3684,7 @@ void NaviIdleState::procAnimMsg(Navi* navi, MsgAnim*) * Address: 80105F90 * Size: 00000C */ -void NaviIdleState::cleanup(Navi* navi) -{ - /* - .loc_0x0: - lfs f0, -0x6268(r2) - stfs f0, 0x738(r4) - blr - */ -} +void NaviIdleState::cleanup(Navi* navi) { navi->_738 = 0.0f; } /* * --INFO-- @@ -4125,6 +3703,12 @@ NaviFlickState::NaviFlickState() */ void NaviFlickState::init(Navi* navi) { + _10 = 0; + _18 = navi->mDirection; + _1C = 0.1f * randFloat(PI); + navi->_70.y = 0.0f; + _20 = navi->_704 + 0.1f * navi->_704 * randFloat(); + navi->startMotion(PaniMotionInfo(PIKIANIM_JHit, navi), PaniMotionInfo(PIKIANIM_JHit)); /* .loc_0x0: mflr r0 @@ -4212,113 +3796,29 @@ void NaviFlickState::init(Navi* navi) */ void NaviFlickState::exec(Navi* navi) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x48(r1) - stfd f31, 0x40(r1) - stw r31, 0x3C(r1) - stw r30, 0x38(r1) - stw r29, 0x34(r1) - addi r29, r4, 0 - stw r28, 0x30(r1) - mr r28, r3 - lhz r0, 0x10(r3) - cmplwi r0, 0 - bne- .loc_0x74 - lfs f31, 0x20(r28) - lfs f1, 0x18(r28) - bl 0x115BA8 - fneg f31, f31 - fmuls f0, f31, f1 - stfs f0, 0x70(r29) - lfs f1, 0x18(r28) - bl 0x115A00 - fmuls f0, f31, f1 - stfs f0, 0x78(r29) - lfs f1, 0xA0(r29) - lfs f0, 0x1C(r28) - fadds f1, f1, f0 - bl -0xCDBE4 - stfs f1, 0xA0(r29) - b .loc_0x154 - - .loc_0x74: - cmplwi r0, 0x2 - bne- .loc_0x120 - lwz r3, 0x2DEC(r13) - lfs f1, 0x14(r28) - lfs f0, 0x28C(r3) - fsubs f0, f1, f0 - stfs f0, 0x14(r28) - lfs f1, 0x14(r28) - lfs f0, -0x6268(r2) - fcmpo cr0, f1, f0 - bge- .loc_0xE8 - cmplwi r29, 0 - addi r30, r29, 0 - beq- .loc_0xB0 - addi r30, r30, 0x2B8 - - .loc_0xB0: - addi r3, r1, 0x1C - li r4, 0x20 - bl 0x18D9C - addi r31, r3, 0 - addi r5, r30, 0 - addi r3, r1, 0x24 - li r4, 0x20 - bl 0x18DBC - addi r4, r3, 0 - addi r3, r29, 0 - addi r5, r31, 0 - bl -0xB970 - li r0, 0x3 - sth r0, 0x10(r28) - - .loc_0xE8: - lfs f1, -0x61CC(r2) - lfs f0, 0x70(r29) - fmuls f0, f1, f0 - stfs f0, 0x70(r29) - lfs f0, 0x78(r29) - fmuls f0, f1, f0 - stfs f0, 0x78(r29) - lfs f0, -0x296C(r13) - stfs f0, 0xA4(r29) - lfs f0, -0x2968(r13) - stfs f0, 0xA8(r29) - lfs f0, -0x2964(r13) - stfs f0, 0xAC(r29) - b .loc_0x154 + if (_10 == 0) { + f32 speed = _20; + navi->_70.x = -speed * sinf(_18); + navi->_70.z = -speed * cosf(_18); + navi->mDirection = roundAng(navi->mDirection + _1C); + return; + } - .loc_0x120: - lfs f1, -0x61CC(r2) - lfs f0, 0x70(r29) - fmuls f0, f1, f0 - stfs f0, 0x70(r29) - lfs f0, 0x78(r29) - fmuls f0, f1, f0 - stfs f0, 0x78(r29) - lfs f0, -0x2960(r13) - stfs f0, 0xA4(r29) - lfs f0, -0x295C(r13) - stfs f0, 0xA8(r29) - lfs f0, -0x2958(r13) - stfs f0, 0xAC(r29) + if (_10 == 2) { + _14 -= gsys->getFrameTime(); + if (_14 < 0.0f) { + navi->startMotion(PaniMotionInfo(PIKIANIM_GetUp, navi), PaniMotionInfo(PIKIANIM_GetUp)); + _10 = 3; + } + navi->_70.x = navi->_70.x * 0.9f; + navi->_70.z = navi->_70.z * 0.9f; + navi->_A4.set(0.0f, 0.0f, 0.0f); + return; + } - .loc_0x154: - lwz r0, 0x4C(r1) - lfd f31, 0x40(r1) - lwz r31, 0x3C(r1) - lwz r30, 0x38(r1) - lwz r29, 0x34(r1) - lwz r28, 0x30(r1) - addi r1, r1, 0x48 - mtlr r0 - blr - */ + navi->_70.x = navi->_70.x * 0.9f; + navi->_70.z = navi->_70.z * 0.9f; + navi->_A4.set(0.0f, 0.0f, 0.0f); } /* @@ -4326,107 +3826,28 @@ void NaviFlickState::exec(Navi* navi) * Address: 8010627C * Size: 000150 */ -void NaviFlickState::procAnimMsg(Navi* navi, MsgAnim*) +void NaviFlickState::procAnimMsg(Navi* navi, MsgAnim* msg) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x40(r1) - stw r31, 0x3C(r1) - stw r30, 0x38(r1) - stw r29, 0x34(r1) - addi r29, r4, 0 - stw r28, 0x30(r1) - addi r28, r3, 0 - lwz r5, 0x4(r5) - lwz r0, 0x0(r5) - cmpwi r0, 0 - beq- .loc_0x38 - b .loc_0x130 - - .loc_0x38: - lhz r0, 0x10(r28) - cmplwi r0, 0 - bne- .loc_0x90 - cmplwi r29, 0 - addi r30, r29, 0 - beq- .loc_0x54 - addi r30, r30, 0x2B8 - - .loc_0x54: - addi r3, r1, 0x18 - li r4, 0x1E - bl 0x18C80 - addi r31, r3, 0 - addi r5, r30, 0 - addi r3, r1, 0x20 - li r4, 0x1E - bl 0x18CA0 - addi r4, r3, 0 - addi r5, r31, 0 - addi r3, r29, 0x834 - bl 0x1976C - li r0, 0x1 - sth r0, 0x10(r28) - b .loc_0x130 - - .loc_0x90: - cmplwi r0, 0x1 - bne- .loc_0xE0 - li r0, 0x2 - sth r0, 0x10(r28) - bl 0x111D54 - xoris r0, r3, 0x8000 - lfd f4, -0x6240(r2) - stw r0, 0x2C(r1) - lis r0, 0x4330 - lfs f2, -0x6258(r2) - stw r0, 0x28(r1) - lfs f1, -0x625C(r2) - lfd f3, 0x28(r1) - lfs f0, -0x61E8(r2) - fsubs f3, f3, f4 - fdivs f2, f3, f2 - fmuls f1, f1, f2 - fmuls f0, f0, f1 - stfs f0, 0x14(r28) - b .loc_0x130 - - .loc_0xE0: - lfs f1, 0x58(r29) - lfs f0, -0x625C(r2) - fcmpo cr0, f1, f0 - cror 2, 0, 0x2 - bne- .loc_0x114 - mr r3, r28 - lwz r12, 0x0(r28) - addi r4, r29, 0 - li r5, 0x1D - lwz r12, 0x4C(r12) - mtlr r12 - blrl - b .loc_0x130 - - .loc_0x114: - mr r3, r28 - lwz r12, 0x0(r28) - addi r4, r29, 0 - li r5, 0 - lwz r12, 0x4C(r12) - mtlr r12 - blrl + switch (msg->mKeyEvent->mEventType) { + case KEY_Done: + if (_10 == 0) { + navi->mNaviAnimMgr.startMotion(PaniMotionInfo(PIKIANIM_JKoke, navi), PaniMotionInfo(PIKIANIM_JKoke)); + _10 = 1; + break; + } + if (_10 == 1) { + _10 = 2; + _14 = randFloat(0.1f); + break; + } + if (navi->mHealth <= 0.0f) { + transit(navi, NAVISTATE_Dead); + break; + } - .loc_0x130: - lwz r0, 0x44(r1) - lwz r31, 0x3C(r1) - lwz r30, 0x38(r1) - lwz r29, 0x34(r1) - lwz r28, 0x30(r1) - addi r1, r1, 0x40 - mtlr r0 - blr - */ + transit(navi, NAVISTATE_Walk); + break; + } } /* @@ -4436,22 +3857,9 @@ void NaviFlickState::procAnimMsg(Navi* navi, MsgAnim*) */ void NaviFlickState::cleanup(Navi* navi) { - /* - .loc_0x0: - mflr r0 - mr r3, r4 - stw r0, 0x4(r1) - stwu r1, -0x8(r1) - lwz r12, 0x0(r4) - lwz r12, 0x88(r12) - mtlr r12 - blrl - rlwinm. r0,r3,0,24,31 - lwz r0, 0xC(r1) - addi r1, r1, 0x8 - mtlr r0 - blr - */ + if (navi->isAlive()) { + DEBUGPRINT(navi->mHealth); + } } /* @@ -4462,102 +3870,26 @@ void NaviFlickState::cleanup(Navi* navi) NaviGeyzerState::NaviGeyzerState() : NaviState(NAVISTATE_Geyzer) { -} - -/* - * --INFO-- - * Address: 80106454 - * Size: 000140 - */ -void NaviGeyzerState::init(Navi* navi) -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - li r0, 0x1 - stwu r1, -0x50(r1) - stw r31, 0x4C(r1) - stw r30, 0x48(r1) - stw r29, 0x44(r1) - mr r29, r4 - stw r28, 0x40(r1) - addi r28, r3, 0 - sth r0, 0x10(r3) - lfs f0, 0xA0(r4) - stfs f0, 0x18(r3) - bl 0x111BE8 - xoris r0, r3, 0x8000 - lfd f4, -0x6240(r2) - stw r0, 0x3C(r1) - lis r0, 0x4330 - lfs f3, -0x6258(r2) - cmplwi r29, 0 - stw r0, 0x38(r1) - lfs f2, -0x625C(r2) - mr r30, r29 - lfd f1, 0x38(r1) - lfs f0, -0x6218(r2) - fsubs f4, f1, f4 - lfs f1, -0x61E8(r2) - fdivs f3, f4, f3 - fmuls f2, f2, f3 - fmuls f0, f0, f2 - fmuls f0, f1, f0 - stfs f0, 0x1C(r28) - beq- .loc_0x88 - addi r30, r30, 0x2B8 - - .loc_0x88: - addi r3, r1, 0x24 - li r4, 0x1F - bl 0x18A74 - addi r31, r3, 0 - addi r5, r30, 0 - addi r3, r1, 0x2C - li r4, 0x1F - bl 0x18A94 - addi r4, r3, 0 - addi r3, r29, 0 - addi r5, r31, 0 - bl -0xBC98 - li r0, 0 - cmplwi r29, 0 - stb r0, 0x30(r28) - mr r30, r29 - beq- .loc_0xD0 - addi r30, r30, 0x2B8 +} - .loc_0xD0: - addi r3, r1, 0x14 - li r4, 0xC - bl 0x18A2C - addi r31, r3, 0 - addi r5, r30, 0 - addi r3, r1, 0x1C - li r4, 0xC - bl 0x18A4C - addi r4, r3, 0 - addi r5, r31, 0 - addi r3, r29, 0x834 - bl 0x19518 - li r0, 0x2 - sth r0, 0x10(r28) - li r0, 0 - lfs f1, -0x61C8(r2) - lfs f0, 0x98(r29) - fadds f0, f1, f0 - stfs f0, 0x2C(r28) - sth r0, 0x10(r28) - lwz r0, 0x54(r1) - lwz r31, 0x4C(r1) - lwz r30, 0x48(r1) - lwz r29, 0x44(r1) - lwz r28, 0x40(r1) - addi r1, r1, 0x50 - mtlr r0 - blr - */ +/* + * --INFO-- + * Address: 80106454 + * Size: 000140 + */ +void NaviGeyzerState::init(Navi* navi) +{ + _10 = 1; // why + _18 = navi->mDirection; + _1C = 0.1f * randFloat(PI); + navi->startMotion(PaniMotionInfo(PIKIANIM_JHit, navi), PaniMotionInfo(PIKIANIM_JHit)); + _30 = 0; + navi->mNaviAnimMgr.startMotion(PaniMotionInfo(PIKIANIM_OCarry, navi), PaniMotionInfo(PIKIANIM_OCarry)); + + _10 = 2; // does this + _2C = 69.0f + navi->mPosition.y; + + _10 = 0; // get set like this } /* @@ -4722,95 +4054,26 @@ void NaviGeyzerState::exec(Navi* navi) * Address: 801067A8 * Size: 000120 */ -void NaviGeyzerState::procAnimMsg(Navi* navi, MsgAnim*) +void NaviGeyzerState::procAnimMsg(Navi* navi, MsgAnim* msg) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x48(r1) - stw r31, 0x44(r1) - stw r30, 0x40(r1) - stw r29, 0x3C(r1) - addi r29, r4, 0 - stw r28, 0x38(r1) - addi r28, r3, 0 - lwz r5, 0x4(r5) - lwz r0, 0x0(r5) - cmpwi r0, 0 - beq- .loc_0x38 - b .loc_0x100 - - .loc_0x38: - lhz r0, 0x10(r28) - cmplwi r0, 0x1 - bne- .loc_0x90 - cmplwi r29, 0 - addi r30, r29, 0 - beq- .loc_0x54 - addi r30, r30, 0x2B8 - - .loc_0x54: - addi r3, r1, 0x24 - li r4, 0x1E - bl 0x18754 - addi r31, r3, 0 - addi r5, r30, 0 - addi r3, r1, 0x2C - li r4, 0x1E - bl 0x18774 - addi r4, r3, 0 - addi r5, r31, 0 - addi r3, r29, 0x834 - bl 0x19240 - li r0, 0x2 - sth r0, 0x10(r28) - b .loc_0x100 - - .loc_0x90: - cmplwi r0, 0x2 - bne- .loc_0xDC - cmplwi r29, 0 - addi r30, r29, 0 - beq- .loc_0xA8 - addi r30, r30, 0x2B8 - - .loc_0xA8: - addi r3, r1, 0x14 - li r4, 0x1E - bl 0x18700 - addi r31, r3, 0 - addi r5, r30, 0 - addi r3, r1, 0x1C - li r4, 0x1E - bl 0x18720 - addi r4, r3, 0 - addi r5, r31, 0 - addi r3, r29, 0x834 - bl 0x191EC - b .loc_0x100 + switch (msg->mKeyEvent->mEventType) { + case KEY_Done: + if (_10 == 1) { + navi->mNaviAnimMgr.startMotion(PaniMotionInfo(PIKIANIM_JKoke, navi), PaniMotionInfo(PIKIANIM_JKoke)); + _10 = 2; + break; + } - .loc_0xDC: - cmplwi r0, 0x4 - bne- .loc_0x100 - mr r3, r28 - lwz r12, 0x0(r28) - addi r4, r29, 0 - li r5, 0 - lwz r12, 0x4C(r12) - mtlr r12 - blrl + if (_10 == 2) { + navi->mNaviAnimMgr.startMotion(PaniMotionInfo(PIKIANIM_JKoke, navi), PaniMotionInfo(PIKIANIM_JKoke)); + break; + } - .loc_0x100: - lwz r0, 0x4C(r1) - lwz r31, 0x44(r1) - lwz r30, 0x40(r1) - lwz r29, 0x3C(r1) - lwz r28, 0x38(r1) - addi r1, r1, 0x48 - mtlr r0 - blr - */ + if (_10 == 4) { + transit(navi, NAVISTATE_Walk); + } + break; + } } /* @@ -4818,50 +4081,13 @@ void NaviGeyzerState::procAnimMsg(Navi* navi, MsgAnim*) * Address: 801068C8 * Size: 000094 */ -void NaviGeyzerState::procBounceMsg(Navi* navi, MsgBounce*) +void NaviGeyzerState::procBounceMsg(Navi* navi, MsgBounce* msg) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x28(r1) - stw r31, 0x24(r1) - mr r31, r3 - lhz r0, 0x10(r3) - cmplwi r0, 0 - beq- .loc_0x80 - li r0, 0x3 - sth r0, 0x10(r31) - bl 0x111780 - xoris r0, r3, 0x8000 - lfd f4, -0x6240(r2) - stw r0, 0x1C(r1) - lis r0, 0x4330 - lfs f3, -0x6258(r2) - li r4, 0xA - stw r0, 0x18(r1) - lfs f2, -0x625C(r2) - li r5, 0 - lfd f1, 0x18(r1) - li r6, 0 - lfs f0, -0x61BC(r2) - fsubs f4, f1, f4 - lfs f1, -0x61C0(r2) - fdivs f3, f4, f3 - fmuls f2, f2, f3 - fmuls f0, f0, f2 - fadds f0, f1, f0 - stfs f0, 0x14(r31) - lwz r3, 0x3178(r13) - bl 0x76404 - - .loc_0x80: - lwz r0, 0x2C(r1) - lwz r31, 0x24(r1) - addi r1, r1, 0x28 - mtlr r0 - blr - */ + if (_10 != 0) { + _10 = 3; + _14 = 0.3f + randFloat(0.2f); + rumbleMgr->start(10, 0, nullptr); + } } /* @@ -4871,22 +4097,9 @@ void NaviGeyzerState::procBounceMsg(Navi* navi, MsgBounce*) */ void NaviGeyzerState::cleanup(Navi* navi) { - /* - .loc_0x0: - mflr r0 - mr r3, r4 - stw r0, 0x4(r1) - stwu r1, -0x8(r1) - lwz r12, 0x0(r4) - lwz r12, 0x88(r12) - mtlr r12 - blrl - rlwinm. r0,r3,0,24,31 - lwz r0, 0xC(r1) - addi r1, r1, 0x8 - mtlr r0 - blr - */ + if (navi->isAlive()) { + DEBUGPRINT(navi->mPosition.y); + } } /* @@ -4904,47 +4117,14 @@ NaviGatherState::NaviGatherState() * Address: 801069D4 * Size: 00002C */ -void NaviGatherState::resume(Navi* navi) -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x8(r1) - lwz r12, 0x0(r3) - lwz r12, 0x40(r12) - mtlr r12 - blrl - lwz r0, 0xC(r1) - addi r1, r1, 0x8 - mtlr r0 - blr - */ -} +void NaviGatherState::resume(Navi* navi) { cleanup(navi); } /* * --INFO-- * Address: 80106A00 * Size: 000030 */ -void NaviGatherState::restart(Navi* navi) -{ - /* - .loc_0x0: - mflr r0 - li r5, 0 - stw r0, 0x4(r1) - stwu r1, -0x8(r1) - lwz r12, 0x0(r3) - lwz r12, 0x4C(r12) - mtlr r12 - blrl - lwz r0, 0xC(r1) - addi r1, r1, 0x8 - mtlr r0 - blr - */ -} +void NaviGatherState::restart(Navi* navi) { transit(navi, NAVISTATE_Walk); } /* * --INFO-- @@ -4953,93 +4133,23 @@ void NaviGatherState::restart(Navi* navi) */ void NaviGatherState::init(Navi* navi) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x60(r1) - stw r31, 0x5C(r1) - stw r30, 0x58(r1) - stw r29, 0x54(r1) - mr. r29, r4 - stw r28, 0x50(r1) - addi r28, r3, 0 - addi r30, r29, 0 - lfs f0, -0x61B8(r2) - stfs f0, 0x6BC(r4) - beq- .loc_0x38 - addi r30, r30, 0x2B8 - - .loc_0x38: - addi r3, r1, 0x10 - li r4, 0x31 - bl 0x184E8 - addi r31, r3, 0 - addi r5, r30, 0 - addi r3, r1, 0x18 - li r4, 0x31 - bl 0x18508 - addi r4, r3, 0 - addi r3, r29, 0 - addi r5, r31, 0 - bl -0xC224 - mr r3, r29 - bl -0xC1F4 - lfs f0, -0x6268(r2) - li r30, 0x1 - li r0, 0 - stfs f0, 0xAB8(r29) - li r3, 0x13B - stfs f0, 0xAC4(r29) - stw r30, 0xABC(r29) - sth r0, 0x10(r28) - bl -0x616E4 - lwz r0, 0x92C(r29) - cmpwi r0, 0 - bne- .loc_0xA4 - b .loc_0xA8 - - .loc_0xA4: - li r30, 0x2 - - .loc_0xA8: - lfs f1, -0x6268(r2) - mr r3, r30 - lfs f0, -0x625C(r2) - addi r4, r1, 0x20 - stfs f1, 0x28(r1) - stfs f1, 0x24(r1) - stfs f1, 0x20(r1) - stfs f1, 0x34(r1) - stfs f1, 0x30(r1) - stfs f1, 0x2C(r1) - lwz r5, 0x94(r29) - lwz r0, 0x98(r29) - stw r5, 0x20(r1) - stw r0, 0x24(r1) - lwz r0, 0x9C(r29) - stw r0, 0x28(r1) - stfs f0, 0x44(r1) - bl 0xD7C4 - li r3, 0x7 - addi r4, r1, 0x20 - bl 0xD7B8 - li r0, 0 - stb r0, 0x18(r28) - li r4, 0x3 - li r5, 0 - lwz r3, 0x3178(r13) - li r6, 0 - bl 0x76204 - lwz r0, 0x64(r1) - lwz r31, 0x5C(r1) - lwz r30, 0x58(r1) - lwz r29, 0x54(r1) - lwz r28, 0x50(r1) - addi r1, r1, 0x60 - mtlr r0 - blr - */ + navi->_6BC = 30.0f; + navi->startMotion(PaniMotionInfo(PIKIANIM_Fue, navi), PaniMotionInfo(PIKIANIM_Fue)); + navi->enableMotionBlend(); + navi->_AB8 = 0.0f; + navi->_AC4 = 0.0f; + navi->_ABC = 1; + _10 = 0; + SeSystem::playPlayerSe(0x13B); + + int effIDMaybe = (navi->mNaviID == 0) ? 1 : 2; + EffectParm parm; + parm._00 = navi->mPosition; + parm._24 = 1.0f; + UtEffectMgr::cast(effIDMaybe, parm); + UtEffectMgr::cast(7, parm); + _18 = 0; + rumbleMgr->start(3, 0, nullptr); } /* diff --git a/src/plugPikiNishimura/KingAi.cpp b/src/plugPikiNishimura/KingAi.cpp index c6a545e2..72f715f8 100644 --- a/src/plugPikiNishimura/KingAi.cpp +++ b/src/plugPikiNishimura/KingAi.cpp @@ -2529,7 +2529,7 @@ void KingAi::setAttackPriority() f32 boundedFactor = (factor < 0.0f) ? 0.0f : (factor > 1.0f) ? 1.0f : factor; f32 chance = boundedFactor * kingProps->mKingProps._384() + (1.0f - boundedFactor) * kingProps->mKingProps._374(); // t02, t01 - if (0.99999f * randWeightFloat(1.0f) < chance) { + if (randFloat(0.99999f) < chance) { _08 = 0; _18 = 0; // mKing->_3C0->_05 = 0; // whatever this is