diff --git a/Makefile b/Makefile index 3d6f626347..5f5b628c90 100644 --- a/Makefile +++ b/Makefile @@ -95,8 +95,8 @@ AS := $(MIPS_BINUTILS_PREFIX)as LD := $(MIPS_BINUTILS_PREFIX)ld OBJCOPY := $(MIPS_BINUTILS_PREFIX)objcopy OBJDUMP := $(MIPS_BINUTILS_PREFIX)objdump -EMULATOR = mupen64plus -EMU_FLAGS = --noosd +EMULATOR ?= +EMU_FLAGS ?= INC := -Iinclude -Isrc -Ibuild -I. @@ -269,11 +269,14 @@ setup: python3 extract_baserom.py python3 extract_assets.py -j$(N_THREADS) -test: $(ROM) +run: $(ROM) +ifeq ($(EMULATOR),) + $(error Emulator path not set. Set EMULATOR in the Makefile or define it as an environment variable) +endif $(EMULATOR) $(EMU_FLAGS) $< -.PHONY: all clean setup test distclean assetclean +.PHONY: all clean setup run distclean assetclean #### Various Recipes #### diff --git a/assets/xml/objects/object_cow.xml b/assets/xml/objects/object_cow.xml index 5d067c329f..3cdad5ef93 100644 --- a/assets/xml/objects/object_cow.xml +++ b/assets/xml/objects/object_cow.xml @@ -1,14 +1,14 @@ - + - - - - - + + + + + @@ -18,14 +18,14 @@ - + - - - - - + + + + + diff --git a/assets/xml/overlays/ovl_Effect_Ss_Fhg_Flash.xml b/assets/xml/overlays/ovl_Effect_Ss_Fhg_Flash.xml new file mode 100644 index 0000000000..d2de328dad --- /dev/null +++ b/assets/xml/overlays/ovl_Effect_Ss_Fhg_Flash.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/include/functions.h b/include/functions.h index 5742e765f1..9a7f822522 100644 --- a/include/functions.h +++ b/include/functions.h @@ -184,9 +184,9 @@ void EffectSs_Insert(PlayState* play, EffectSs* effectSs); void EffectSs_Spawn(PlayState* play, s32 type, s32 priority, void* initParams); void EffectSs_UpdateAll(PlayState* play); void EffectSs_DrawAll(PlayState* play); -s16 func_80027DD4(s16 arg0, s16 arg1, s32 arg2); -s16 func_80027E34(s16 arg0, s16 arg1, f32 arg2); -u8 func_80027E84(u8 arg0, u8 arg1, f32 arg2); +s16 EffectSs_LerpInv(s16 a, s16 b, s32 weightInv); +s16 EffectSs_LerpS16(s16 a, s16 b, f32 weight); +u8 EffectSs_LerpU8(u8 a, u8 b, f32 weight); void EffectSs_DrawGEffect(PlayState* play, EffectSs* this, void* texture); void EffectSsDust_Spawn(PlayState* play, u16 drawFlags, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life, @@ -230,12 +230,12 @@ void EffectSsBomb_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* acc void EffectSsBomb2_SpawnFade(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel); void EffectSsBomb2_SpawnLayered(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep); -void EffectSsBlast_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, - Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 scaleStepDecay, s16 life); -void EffectSsBlast_SpawnWhiteCustomScale(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, +void EffectSsBlast_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* innerColor, + Color_RGBA8* outerColor, s16 scale, s16 scaleStep, s16 scaleStepDecay, s16 life); +void EffectSsBlast_SpawnWhiteShockwaveSetScale(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 life); -void EffectSsBlast_SpawnShockwave(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, - Color_RGBA8* primColor, Color_RGBA8* envColor, s16 life); +void EffectSsBlast_SpawnShockwaveSetColor(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, + Color_RGBA8* innerColor, Color_RGBA8* outerColor, s16 life); void EffectSsBlast_SpawnWhiteShockwave(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel); void EffectSsGSpk_SpawnAccel(PlayState* play, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep); @@ -1365,14 +1365,6 @@ void ListAlloc_Free(ListAlloc* this, void* data); void ListAlloc_FreeAll(ListAlloc* this); void Main_LogSystemHeap(void); void Main(void* arg); -void SpeedMeter_InitImpl(SpeedMeter* this, u32 arg1, u32 y); -void SpeedMeter_Init(SpeedMeter* this); -void SpeedMeter_Destroy(SpeedMeter* this); -void SpeedMeter_DrawTimeEntries(SpeedMeter* this, GraphicsContext* gfxCtx); -void SpeedMeter_InitAllocEntry(SpeedMeterAllocEntry* this, u32 maxval, u32 val, u16 backColor, u16 foreColor, u32 ulx, - u32 lrx, u32 uly, u32 lry); -void SpeedMeter_DrawAllocEntry(SpeedMeterAllocEntry* this, GraphicsContext* gfxCtx); -void SpeedMeter_DrawAllocEntries(SpeedMeter* meter, GraphicsContext* gfxCtx, GameState* state); void SysCfb_Init(s32 n64dd); void* SysCfb_GetFbPtr(s32 idx); void* SysCfb_GetFbEnd(void); diff --git a/include/gfx.h b/include/gfx.h new file mode 100644 index 0000000000..a50dd3a196 --- /dev/null +++ b/include/gfx.h @@ -0,0 +1,164 @@ +#ifndef GFX_H +#define GFX_H + +#include "ultra64.h" +#include "ultra64/gbi.h" +#include "sched.h" +#include "thga.h" + +// Texture memory size, 4 KiB +#define TMEM_SIZE 0x1000 + +typedef struct { + /* 0x00000 */ u16 headMagic; // GFXPOOL_HEAD_MAGIC + /* 0x00008 */ Gfx polyOpaBuffer[0x17E0]; + /* 0x0BF08 */ Gfx polyXluBuffer[0x800]; + /* 0x0FF08 */ Gfx overlayBuffer[0x400]; + /* 0x11F08 */ Gfx workBuffer[0x80]; + /* 0x11308 */ Gfx unusedBuffer[0x20]; + /* 0x12408 */ u16 tailMagic; // GFXPOOL_TAIL_MAGIC +} GfxPool; // size = 0x12410 + +typedef struct GraphicsContext { + /* 0x0000 */ Gfx* polyOpaBuffer; // Pointer to "Zelda 0" + /* 0x0004 */ Gfx* polyXluBuffer; // Pointer to "Zelda 1" + /* 0x0008 */ char unk_008[0x08]; // Unused, could this be pointers to "Zelda 2" / "Zelda 3" + /* 0x0010 */ Gfx* overlayBuffer; // Pointer to "Zelda 4" + /* 0x0014 */ u32 unk_014; + /* 0x0018 */ char unk_018[0x20]; + /* 0x0038 */ OSMesg msgBuff[0x08]; + /* 0x0058 */ OSMesgQueue* schedMsgQueue; + /* 0x005C */ OSMesgQueue queue; + /* 0x0078 */ OSScTask task; + /* 0x00E0 */ char unk_0E0[0xD0]; + /* 0x01B0 */ Gfx* workBuffer; + /* 0x01B4 */ TwoHeadGfxArena work; + /* 0x01C4 */ char unk_01C4[0xC0]; + /* 0x0284 */ OSViMode* viMode; + /* 0x0288 */ char unk_0288[0x20]; // Unused, could this be Zelda 2/3 ? + /* 0x02A8 */ TwoHeadGfxArena overlay; // "Zelda 4" + /* 0x02B8 */ TwoHeadGfxArena polyOpa; // "Zelda 0" + /* 0x02C8 */ TwoHeadGfxArena polyXlu; // "Zelda 1" + /* 0x02D8 */ u32 gfxPoolIdx; + /* 0x02DC */ u16* curFrameBuffer; + /* 0x02E0 */ char unk_2E0[0x04]; + /* 0x02E4 */ u32 viFeatures; + /* 0x02E8 */ s32 fbIdx; + /* 0x02EC */ void (*callback)(struct GraphicsContext*, void*); + /* 0x02F0 */ void* callbackParam; + /* 0x02F4 */ f32 xScale; + /* 0x02F8 */ f32 yScale; + /* 0x02FC */ char unk_2FC[0x04]; +} GraphicsContext; // size = 0x300 + +typedef enum { + /* 0 */ SETUPDL_0, + /* 1 */ SETUPDL_1, + /* 2 */ SETUPDL_2, + /* 3 */ SETUPDL_3, + /* 4 */ SETUPDL_4, + /* 5 */ SETUPDL_5, + /* 6 */ SETUPDL_6, + /* 7 */ SETUPDL_7, + /* 8 */ SETUPDL_8, + /* 9 */ SETUPDL_9, + /* 10 */ SETUPDL_10, + /* 11 */ SETUPDL_11, + /* 12 */ SETUPDL_12, + /* 13 */ SETUPDL_13, + /* 14 */ SETUPDL_14, + /* 15 */ SETUPDL_15, + /* 16 */ SETUPDL_16, + /* 17 */ SETUPDL_17, + /* 18 */ SETUPDL_18, + /* 19 */ SETUPDL_19, + /* 20 */ SETUPDL_20, + /* 21 */ SETUPDL_21, + /* 22 */ SETUPDL_22, + /* 23 */ SETUPDL_23, + /* 24 */ SETUPDL_24, + /* 25 */ SETUPDL_25, + /* 26 */ SETUPDL_26, + /* 27 */ SETUPDL_27, + /* 28 */ SETUPDL_28, + /* 29 */ SETUPDL_29, + /* 30 */ SETUPDL_30, + /* 31 */ SETUPDL_31, + /* 32 */ SETUPDL_32, + /* 33 */ SETUPDL_33, + /* 34 */ SETUPDL_34, + /* 35 */ SETUPDL_35, + /* 36 */ SETUPDL_36, + /* 37 */ SETUPDL_37, + /* 38 */ SETUPDL_38, + /* 39 */ SETUPDL_39, + /* 40 */ SETUPDL_40, + /* 41 */ SETUPDL_41, + /* 42 */ SETUPDL_42, + /* 43 */ SETUPDL_43, + /* 44 */ SETUPDL_44, + /* 45 */ SETUPDL_45, + /* 46 */ SETUPDL_46, + /* 47 */ SETUPDL_47, + /* 48 */ SETUPDL_48, + /* 49 */ SETUPDL_49, + /* 50 */ SETUPDL_50, + /* 51 */ SETUPDL_51, + /* 52 */ SETUPDL_52, + /* 53 */ SETUPDL_53, + /* 54 */ SETUPDL_54, + /* 55 */ SETUPDL_55, + /* 56 */ SETUPDL_56, + /* 57 */ SETUPDL_57, + /* 58 */ SETUPDL_58, + /* 59 */ SETUPDL_59, + /* 60 */ SETUPDL_60, + /* 61 */ SETUPDL_61, + /* 62 */ SETUPDL_62, + /* 63 */ SETUPDL_63, + /* 64 */ SETUPDL_64, + /* 65 */ SETUPDL_65, + /* 66 */ SETUPDL_66, + /* 67 */ SETUPDL_67, + /* 68 */ SETUPDL_68, + /* 69 */ SETUPDL_69, + /* 70 */ SETUPDL_70, + /* 71 */ SETUPDL_MAX +} SetupDL; + +#define UCODE_NULL 0 +#define UCODE_F3DZEX 1 +#define UCODE_UNK 2 +#define UCODE_S2DEX 3 + +typedef struct { + /* 0x00 */ u32 type; + /* 0x04 */ void* ptr; +} UCodeInfo; // size = 0x8 + +typedef struct { + /* 0x00 */ uintptr_t segments[NUM_SEGMENTS]; + /* 0x40 */ Gfx* dlStack[18]; + /* 0x88 */ s32 dlDepth; + /* 0x8C */ u32 dlCnt; + /* 0x90 */ u32 vtxCnt; + /* 0x94 */ u32 spvtxCnt; + /* 0x98 */ u32 tri1Cnt; + /* 0x9C */ u32 tri2Cnt; + /* 0xA0 */ u32 quadCnt; + /* 0xA4 */ u32 lineCnt; + /* 0xA8 */ u32 loaducodeCnt; + /* 0xAC */ u32 pipeSyncRequired; + /* 0xB0 */ u32 tileSyncRequired; + /* 0xB4 */ u32 loadSyncRequired; + /* 0xB8 */ u32 syncErr; + /* 0xBC */ s32 enableLog; + /* 0xC0 */ s32 ucodeType; + /* 0xC4 */ s32 ucodeInfoCount; + /* 0xC8 */ UCodeInfo* ucodeInfo; + /* 0xCC */ u32 modeH; + /* 0xD0 */ u32 modeL; + /* 0xD4 */ u32 geometryMode; +} UCodeDisas; // size = 0xD8 + +#endif diff --git a/include/jpeg.h b/include/jpeg.h new file mode 100644 index 0000000000..253d797bd4 --- /dev/null +++ b/include/jpeg.h @@ -0,0 +1,80 @@ +#ifndef JPEG_H +#define JPEG_H + +#include "ultra64.h" +#include "sched.h" + +typedef struct { + /* 0x00 */ u16 table[8*8]; +} JpegQuantizationTable; // size = 0x80 + +typedef struct { + /* 0x00 */ u8 codeOffs[16]; + /* 0x10 */ u16 codesA[16]; + /* 0x30 */ u16 codesB[16]; + /* 0x50 */ u8* symbols; +} JpegHuffmanTable; // size = 0x54 + +// this struct might be inaccurate but it's not used outside jpegutils.c anyways +typedef struct { + /* 0x000 */ u8 codeOffs[16]; + /* 0x010 */ u16 dcCodes[120]; + /* 0x100 */ u16 acCodes[256]; +} JpegHuffmanTableOld; // size = 0x300 + +typedef union { + struct { + /* 0x00 */ u32 address; + /* 0x04 */ u32 mbCount; + /* 0x08 */ u32 mode; + /* 0x0C */ u32 qTableYPtr; + /* 0x10 */ u32 qTableUPtr; + /* 0x14 */ u32 qTableVPtr; + /* 0x18 */ u32 mbSize; // This field is used by the microcode to save the macroblock size during a yield + }; + long long int force_structure_alignment; +} JpegTaskData; // size = 0x20 + +typedef struct { + /* 0x000 */ JpegTaskData taskData; + /* 0x020 */ u64 yieldData[0x200 / sizeof(u64)]; + /* 0x220 */ JpegQuantizationTable qTableY; + /* 0x2A0 */ JpegQuantizationTable qTableU; + /* 0x320 */ JpegQuantizationTable qTableV; + /* 0x3A0 */ u8 codesLengths[0x110]; + /* 0x4B0 */ u16 codes[0x108]; + /* 0x6C0 */ u16 data[4][0x180]; +} JpegWork; // size = 0x12C0 + +typedef struct { + /* 0x00 */ void* imageData; + /* 0x04 */ u8 mode; + /* 0x05 */ u8 unk_05; + /* 0x08 */ JpegHuffmanTable* hTablePtrs[4]; + /* 0x18 */ u8 unk_18; +} JpegDecoder; // size = 0x1C + +typedef struct { + /* 0x00 */ u8 dqtCount; + /* 0x04 */ u8* dqtPtr[3]; + /* 0x10 */ u8 dhtCount; + /* 0x14 */ u8* dhtPtr[4]; + /* 0x24 */ void* imageData; + /* 0x28 */ u32 mode; // 0 if Y V0 is 1 and 2 if Y V0 is 2 + /* 0x30 */ OSScTask scTask; + /* 0x98 */ OSMesgQueue mq; + /* 0xB0 */ OSMesg msg; + /* 0xB4 */ JpegWork* workBuf; +} JpegContext; // size = 0xB8 + +typedef struct { + /* 0x00 */ u32 byteIdx; + /* 0x04 */ u8 bitIdx; + /* 0x05 */ u8 dontSkip; + /* 0x08 */ u32 curWord; + /* 0x0C */ s16 unk_0C; + /* 0x0E */ s16 unk_0E; + /* 0x10 */ s16 unk_10; +} JpegDecoderState; // size = 0x14 + +#endif diff --git a/include/prerender.h b/include/prerender.h new file mode 100644 index 0000000000..12f17f7ed9 --- /dev/null +++ b/include/prerender.h @@ -0,0 +1,33 @@ +#ifndef PRERENDER_H +#define PRERENDER_H + +#include "ultra64/ultratypes.h" + +typedef struct ListAlloc { + /* 0x00 */ struct ListAlloc* prev; + /* 0x04 */ struct ListAlloc* next; +} ListAlloc; // size = 0x8 + +typedef struct { + /* 0x00 */ s32 width; + /* 0x04 */ s32 height; + /* 0x08 */ s32 widthSave; + /* 0x0C */ s32 heightSave; + /* 0x10 */ u16* fbuf; + /* 0x14 */ u16* fbufSave; + /* 0x18 */ u8* cvgSave; + /* 0x1C */ u16* zbuf; + /* 0x20 */ u16* zbufSave; + /* 0x24 */ s32 ulxSave; + /* 0x28 */ s32 ulySave; + /* 0x2C */ s32 lrxSave; + /* 0x30 */ s32 lrySave; + /* 0x34 */ s32 ulx; + /* 0x38 */ s32 uly; + /* 0x3C */ s32 lrx; + /* 0x40 */ s32 lry; + /* 0x44 */ ListAlloc alloc; + /* 0x4C */ u32 unk_4C; +} PreRender; // size = 0x50 + +#endif diff --git a/include/regs.h b/include/regs.h index a8f5bd18bc..8875ae12ca 100644 --- a/include/regs.h +++ b/include/regs.h @@ -106,6 +106,7 @@ #define R_MESSAGE_DEBUGGER_TEXTID YREG(79) #define R_C_UP_ICON_X YREG(88) #define R_C_UP_ICON_Y YREG(89) +#define R_EPONAS_SONG_PLAYED DREG(53) #define R_MAGIC_FILL_COLOR(i) ZREG(0 + (i)) #define R_PAUSE_SWITCH_PAGE_FRAME_ADVANCE_ON ZREG(13) #define R_PAUSE_CURSOR_L_R_SELECTED_PRIM_TIMER ZREG(28) diff --git a/include/speedmeter.h b/include/speedmeter.h new file mode 100644 index 0000000000..02409ba931 --- /dev/null +++ b/include/speedmeter.h @@ -0,0 +1,35 @@ +#ifndef SPEEDMETER_H +#define SPEEDMETER_H + +#include "ultra64/ultratypes.h" + +struct GraphicsContext; +struct GameState; + +typedef struct { + /* 0x00 */ char unk_00[0x18]; + /* 0x18 */ s32 unk_18; + /* 0x1C */ s32 y; +} SpeedMeter; // size = 0x20 + +typedef struct { + /* 0x00 */ s32 maxval; + /* 0x04 */ s32 val; + /* 0x08 */ u16 backColor; + /* 0x0A */ u16 foreColor; + /* 0x0C */ s32 ulx; + /* 0x10 */ s32 lrx; + /* 0x14 */ s32 uly; + /* 0x18 */ s32 lry; +} SpeedMeterAllocEntry; // size = 0x1C + +void SpeedMeter_InitImpl(SpeedMeter* this, u32 arg1, u32 y); +void SpeedMeter_Init(SpeedMeter* this); +void SpeedMeter_Destroy(SpeedMeter* this); +void SpeedMeter_DrawTimeEntries(SpeedMeter* this, struct GraphicsContext* gfxCtx); +void SpeedMeter_InitAllocEntry(SpeedMeterAllocEntry* this, u32 maxval, u32 val, u16 backColor, u16 foreColor, u32 ulx, + u32 lrx, u32 uly, u32 lry); +void SpeedMeter_DrawAllocEntry(SpeedMeterAllocEntry* this, struct GraphicsContext* gfxCtx); +void SpeedMeter_DrawAllocEntries(SpeedMeter* meter, struct GraphicsContext* gfxCtx, struct GameState* state); + +#endif diff --git a/include/z64.h b/include/z64.h index b0199887c2..6aed863d74 100644 --- a/include/z64.h +++ b/include/z64.h @@ -27,9 +27,12 @@ #include "z64message.h" #include "z64pause.h" #include "z64skin.h" +#include "z64game.h" #include "z64transition.h" +#include "z64transition_instances.h" #include "z64interface.h" #include "z64skybox.h" +#include "z64sram.h" #include "z64view.h" #include "alignment.h" #include "seqcmd.h" @@ -47,6 +50,10 @@ #include "mempak.h" #include "tha.h" #include "thga.h" +#include "speedmeter.h" +#include "gfx.h" +#include "jpeg.h" +#include "prerender.h" #define SCREEN_WIDTH 320 #define SCREEN_HEIGHT 240 @@ -85,17 +92,9 @@ #define STACK_TOP(stack) \ ((u8*)(stack) + sizeof(stack)) -// Texture memory size, 4 KiB -#define TMEM_SIZE 0x1000 - // NOTE: Once we start supporting other builds, this can be changed with an ifdef #define REGION_NATIVE REGION_EU -typedef struct{ - /* 0x00 */ char unk[0x4]; - /* 0x04 */ MtxF mf; -} HorseStruct; - typedef struct { /* 0x00 */ s32 regPage; // 0: no page selected (reg editor is not active); 1: first page; `REG_PAGES`: last page /* 0x04 */ s32 regGroup; // Indexed from 0 to `REG_GROUPS`-1. Each group has its own character to identify it. @@ -105,123 +104,6 @@ typedef struct { /* 0x14 */ s16 data[REG_GROUPS * REGS_PER_GROUP]; // Accessed through *REG macros, see regs.h } RegEditor; // size = 0x15D4 -typedef struct { - /* 0x00000 */ u16 headMagic; // GFXPOOL_HEAD_MAGIC - /* 0x00008 */ Gfx polyOpaBuffer[0x17E0]; - /* 0x0BF08 */ Gfx polyXluBuffer[0x800]; - /* 0x0FF08 */ Gfx overlayBuffer[0x400]; - /* 0x11F08 */ Gfx workBuffer[0x80]; - /* 0x11308 */ Gfx unusedBuffer[0x20]; - /* 0x12408 */ u16 tailMagic; // GFXPOOL_TAIL_MAGIC -} GfxPool; // size = 0x12410 - -typedef struct GraphicsContext { - /* 0x0000 */ Gfx* polyOpaBuffer; // Pointer to "Zelda 0" - /* 0x0004 */ Gfx* polyXluBuffer; // Pointer to "Zelda 1" - /* 0x0008 */ char unk_008[0x08]; // Unused, could this be pointers to "Zelda 2" / "Zelda 3" - /* 0x0010 */ Gfx* overlayBuffer; // Pointer to "Zelda 4" - /* 0x0014 */ u32 unk_014; - /* 0x0018 */ char unk_018[0x20]; - /* 0x0038 */ OSMesg msgBuff[0x08]; - /* 0x0058 */ OSMesgQueue* schedMsgQueue; - /* 0x005C */ OSMesgQueue queue; - /* 0x0078 */ OSScTask task; - /* 0x00E0 */ char unk_0E0[0xD0]; - /* 0x01B0 */ Gfx* workBuffer; - /* 0x01B4 */ TwoHeadGfxArena work; - /* 0x01C4 */ char unk_01C4[0xC0]; - /* 0x0284 */ OSViMode* viMode; - /* 0x0288 */ char unk_0288[0x20]; // Unused, could this be Zelda 2/3 ? - /* 0x02A8 */ TwoHeadGfxArena overlay; // "Zelda 4" - /* 0x02B8 */ TwoHeadGfxArena polyOpa; // "Zelda 0" - /* 0x02C8 */ TwoHeadGfxArena polyXlu; // "Zelda 1" - /* 0x02D8 */ u32 gfxPoolIdx; - /* 0x02DC */ u16* curFrameBuffer; - /* 0x02E0 */ char unk_2E0[0x04]; - /* 0x02E4 */ u32 viFeatures; - /* 0x02E8 */ s32 fbIdx; - /* 0x02EC */ void (*callback)(struct GraphicsContext*, void*); - /* 0x02F0 */ void* callbackParam; - /* 0x02F4 */ f32 xScale; - /* 0x02F8 */ f32 yScale; - /* 0x02FC */ char unk_2FC[0x04]; -} GraphicsContext; // size = 0x300 - -typedef enum { - /* 0 */ SETUPDL_0, - /* 1 */ SETUPDL_1, - /* 2 */ SETUPDL_2, - /* 3 */ SETUPDL_3, - /* 4 */ SETUPDL_4, - /* 5 */ SETUPDL_5, - /* 6 */ SETUPDL_6, - /* 7 */ SETUPDL_7, - /* 8 */ SETUPDL_8, - /* 9 */ SETUPDL_9, - /* 10 */ SETUPDL_10, - /* 11 */ SETUPDL_11, - /* 12 */ SETUPDL_12, - /* 13 */ SETUPDL_13, - /* 14 */ SETUPDL_14, - /* 15 */ SETUPDL_15, - /* 16 */ SETUPDL_16, - /* 17 */ SETUPDL_17, - /* 18 */ SETUPDL_18, - /* 19 */ SETUPDL_19, - /* 20 */ SETUPDL_20, - /* 21 */ SETUPDL_21, - /* 22 */ SETUPDL_22, - /* 23 */ SETUPDL_23, - /* 24 */ SETUPDL_24, - /* 25 */ SETUPDL_25, - /* 26 */ SETUPDL_26, - /* 27 */ SETUPDL_27, - /* 28 */ SETUPDL_28, - /* 29 */ SETUPDL_29, - /* 30 */ SETUPDL_30, - /* 31 */ SETUPDL_31, - /* 32 */ SETUPDL_32, - /* 33 */ SETUPDL_33, - /* 34 */ SETUPDL_34, - /* 35 */ SETUPDL_35, - /* 36 */ SETUPDL_36, - /* 37 */ SETUPDL_37, - /* 38 */ SETUPDL_38, - /* 39 */ SETUPDL_39, - /* 40 */ SETUPDL_40, - /* 41 */ SETUPDL_41, - /* 42 */ SETUPDL_42, - /* 43 */ SETUPDL_43, - /* 44 */ SETUPDL_44, - /* 45 */ SETUPDL_45, - /* 46 */ SETUPDL_46, - /* 47 */ SETUPDL_47, - /* 48 */ SETUPDL_48, - /* 49 */ SETUPDL_49, - /* 50 */ SETUPDL_50, - /* 51 */ SETUPDL_51, - /* 52 */ SETUPDL_52, - /* 53 */ SETUPDL_53, - /* 54 */ SETUPDL_54, - /* 55 */ SETUPDL_55, - /* 56 */ SETUPDL_56, - /* 57 */ SETUPDL_57, - /* 58 */ SETUPDL_58, - /* 59 */ SETUPDL_59, - /* 60 */ SETUPDL_60, - /* 61 */ SETUPDL_61, - /* 62 */ SETUPDL_62, - /* 63 */ SETUPDL_63, - /* 64 */ SETUPDL_64, - /* 65 */ SETUPDL_65, - /* 66 */ SETUPDL_66, - /* 67 */ SETUPDL_67, - /* 68 */ SETUPDL_68, - /* 69 */ SETUPDL_69, - /* 70 */ SETUPDL_70, - /* 71 */ SETUPDL_MAX -} SetupDL; - typedef struct { /* 0x00 */ u8 seqId; /* 0x01 */ u8 natureAmbienceId; @@ -300,143 +182,12 @@ typedef struct { /* 0x013C */ void* absoluteSpace; // Space used to allocate actor overlays with alloc type ACTOROVL_ALLOC_ABSOLUTE } ActorContext; // size = 0x140 -typedef struct { - /* 0x00 */ char unk_00[0x4]; - /* 0x04 */ void* script; - /* 0x08 */ u8 state; - /* 0x0C */ f32 timer; - /* 0x10 */ u16 curFrame; // current frame of the script that is running - /* 0x12 */ u16 unk_12; // set but never used - /* 0x14 */ s32 subCamId; - /* 0x18 */ u16 camEyeSplinePointsAppliedFrame; // stores the frame the cam eye spline points data was last applied on - /* 0x1A */ u8 camAtReady; // cam `at` data is ready to be applied - /* 0x1B */ u8 camEyeReady; // cam `eye` data is ready to be applied - /* 0x1C */ CutsceneCameraPoint* camAtPoints; - /* 0x20 */ CutsceneCameraPoint* camEyePoints; - /* 0x24 */ CsCmdActorCue* playerCue; - /* 0x28 */ CsCmdActorCue* actorCues[10]; // "npcdemopnt" -} CutsceneContext; // size = 0x50 - typedef struct { /* 0x00 */ u16 countdown; /* 0x04 */ Vec3f worldPos; /* 0x10 */ Vec3f projectedPos; } SfxSource; // size = 0x1C -typedef enum { - /* 0x00 */ DO_ACTION_ATTACK, - /* 0x01 */ DO_ACTION_CHECK, - /* 0x02 */ DO_ACTION_ENTER, - /* 0x03 */ DO_ACTION_RETURN, - /* 0x04 */ DO_ACTION_OPEN, - /* 0x05 */ DO_ACTION_JUMP, - /* 0x06 */ DO_ACTION_DECIDE, - /* 0x07 */ DO_ACTION_DIVE, - /* 0x08 */ DO_ACTION_FASTER, - /* 0x09 */ DO_ACTION_THROW, - /* 0x0A */ DO_ACTION_NONE, // in do_action_static, the texture at this position is NAVI, however this value is in practice the "No Action" value - /* 0x0B */ DO_ACTION_CLIMB, - /* 0x0C */ DO_ACTION_DROP, - /* 0x0D */ DO_ACTION_DOWN, - /* 0x0E */ DO_ACTION_SAVE, - /* 0x0F */ DO_ACTION_SPEAK, - /* 0x10 */ DO_ACTION_NEXT, - /* 0x11 */ DO_ACTION_GRAB, - /* 0x12 */ DO_ACTION_STOP, - /* 0x13 */ DO_ACTION_PUTAWAY, - /* 0x14 */ DO_ACTION_REEL, - /* 0x15 */ DO_ACTION_1, - /* 0x16 */ DO_ACTION_2, - /* 0x17 */ DO_ACTION_3, - /* 0x18 */ DO_ACTION_4, - /* 0x19 */ DO_ACTION_5, - /* 0x1A */ DO_ACTION_6, - /* 0x1B */ DO_ACTION_7, - /* 0x1C */ DO_ACTION_8, - /* 0x1D */ DO_ACTION_MAX -} DoAction; - -// TODO extract this information from the texture definitions themselves -#define DO_ACTION_TEX_WIDTH 48 -#define DO_ACTION_TEX_HEIGHT 16 -#define DO_ACTION_TEX_SIZE ((DO_ACTION_TEX_WIDTH * DO_ACTION_TEX_HEIGHT) / 2) // (sizeof(gCheckDoActionENGTex)) - -typedef struct { - /* 0x0000 */ View view; - /* 0x0128 */ Vtx* actionVtx; - /* 0x012C */ Vtx* beatingHeartVtx; - /* 0x0130 */ u8* parameterSegment; - /* 0x0134 */ u8* doActionSegment; - /* 0x0138 */ u8* iconItemSegment; - /* 0x013C */ u8* mapSegment; - /* 0x0140 */ u8 mapPalette[32]; - /* 0x0160 */ DmaRequest dmaRequest_160; - /* 0x0180 */ DmaRequest dmaRequest_180; - /* 0x01A0 */ char unk_1A0[0x20]; - /* 0x01C0 */ OSMesgQueue loadQueue; - /* 0x01D8 */ OSMesg loadMsg; - /* 0x01DC */ Viewport viewport; - /* 0x01EC */ s16 unk_1EC; - /* 0x01EE */ u16 unk_1EE; - /* 0x01F0 */ u16 unk_1F0; - /* 0x01F4 */ f32 unk_1F4; - /* 0x01F8 */ s16 naviCalling; - /* 0x01FA */ s16 unk_1FA; - /* 0x01FC */ s16 unk_1FC; - /* 0x01FE */ s16 heartColorOscillator; - /* 0x0200 */ s16 heartColorOscillatorDirection; - /* 0x0202 */ s16 beatingHeartPrim[3]; - /* 0x0208 */ s16 beatingHeartEnv[3]; - /* 0x020E */ s16 heartsPrimR[2]; - /* 0x0212 */ s16 heartsPrimG[2]; - /* 0x0216 */ s16 heartsPrimB[2]; - /* 0x021A */ s16 heartsEnvR[2]; - /* 0x021E */ s16 heartsEnvG[2]; - /* 0x0222 */ s16 heartsEnvB[2]; - /* 0x0226 */ s16 unk_226; // Used only in unused functions - /* 0x0228 */ s16 unk_228; // Used only in unused functions - /* 0x022A */ s16 beatingHeartOscillator; - /* 0x022C */ s16 beatingHeartOscillatorDirection; - /* 0x022E */ s16 unk_22E; - /* 0x0230 */ s16 lensMagicConsumptionTimer; // When lens is active, 1 unit of magic is consumed every time the timer reaches 0 - /* 0x0232 */ s16 counterDigits[4]; // used for key and rupee counters - /* 0x023A */ u8 numHorseBoosts; - /* 0x023C */ u16 unk_23C; - /* 0x023E */ u16 hbaAmmo; // ammo while playing the horseback archery minigame - /* 0x0240 */ u16 unk_240; - /* 0x0242 */ u16 unk_242; - /* 0x0224 */ u16 unk_244; // screen fill alpha? - /* 0x0246 */ u16 aAlpha; // also carrots alpha - /* 0x0248 */ u16 bAlpha; // also HBA score alpha - /* 0x024A */ u16 cLeftAlpha; - /* 0x024C */ u16 cDownAlpha; - /* 0x024E */ u16 cRightAlpha; - /* 0x0250 */ u16 healthAlpha; // also max C-Up alpha - /* 0x0252 */ u16 magicAlpha; // also Rupee and Key counters alpha - /* 0x0254 */ u16 minimapAlpha; - /* 0x0256 */ s16 startAlpha; - /* 0x0258 */ s16 unk_258; - /* 0x025A */ s16 unk_25A; - /* 0x025C */ s16 mapRoomNum; - /* 0x025E */ s16 mapPaletteIndex; // "map_palete_no" - /* 0x0260 */ u8 unk_260; - /* 0x0261 */ u8 unk_261; - struct { - /* 0x0262 */ u8 hGauge; // "h_gage"; unknown? - /* 0x0263 */ u8 bButton; // "b_button" - /* 0x0264 */ u8 aButton; // "a_button" - /* 0x0265 */ u8 bottles; // "c_bottle" - /* 0x0266 */ u8 tradeItems; // "c_warasibe" - /* 0x0267 */ u8 hookshot; // "c_hook" - /* 0x0268 */ u8 ocarina; // "c_ocarina" - /* 0x0269 */ u8 warpSongs; // "c_warp" - /* 0x026A */ u8 sunsSong; // "m_sunmoon" - /* 0x026B */ u8 farores; // "m_wind" - /* 0x026C */ u8 dinsNayrus; // "m_magic"; din's fire and nayru's love - /* 0x026D */ u8 all; // "another"; enables all item restrictions - } restrictions; -} InterfaceContext; // size = 0x270 - typedef struct { /* 0x00 */ void* loadedRamAddr; /* 0x04 */ uintptr_t vromStart; @@ -470,24 +221,6 @@ typedef struct { /* 0x00 */ u16 state; } GameOverContext; // size = 0x2 -typedef struct { - /* 0x00 */ s16 id; - /* 0x04 */ void* segment; - /* 0x08 */ DmaRequest dmaRequest; - /* 0x28 */ OSMesgQueue loadQueue; - /* 0x40 */ OSMesg loadMsg; -} ObjectStatus; // size = 0x44 - -typedef struct { - /* 0x0000 */ void* spaceStart; - /* 0x0004 */ void* spaceEnd; // original name: "endSegment" - /* 0x0008 */ u8 num; // number of objects in bank - /* 0x0009 */ u8 unk_09; - /* 0x000A */ u8 mainKeepIndex; // "gameplay_keep" index in bank - /* 0x000B */ u8 subKeepIndex; // "gameplay_field_keep" or "gameplay_dangeon_keep" index in bank - /* 0x000C */ ObjectStatus status[OBJECT_EXCHANGE_BANK_MAX]; -} ObjectContext; // size = 0x518 - typedef enum { /* 0 */ LENS_MODE_HIDE_ACTORS, // lens actors are visible by default, and hidden by using lens (for example, fake walls) /* 1 */ LENS_MODE_SHOW_ACTORS // lens actors are invisible by default, and shown by using lens (for example, invisible enemies) @@ -549,182 +282,6 @@ typedef struct { /* 0x290 */ OcLine* colLine[COLLISION_CHECK_OC_LINE_MAX]; } CollisionCheckContext; // size = 0x29C -typedef struct ListAlloc { - /* 0x00 */ struct ListAlloc* prev; - /* 0x04 */ struct ListAlloc* next; -} ListAlloc; // size = 0x8 - -typedef struct { - /* 0x00 */ s32 width; - /* 0x04 */ s32 height; - /* 0x08 */ s32 widthSave; - /* 0x0C */ s32 heightSave; - /* 0x10 */ u16* fbuf; - /* 0x14 */ u16* fbufSave; - /* 0x18 */ u8* cvgSave; - /* 0x1C */ u16* zbuf; - /* 0x20 */ u16* zbufSave; - /* 0x24 */ s32 ulxSave; - /* 0x28 */ s32 ulySave; - /* 0x2C */ s32 lrxSave; - /* 0x30 */ s32 lrySave; - /* 0x34 */ s32 ulx; - /* 0x38 */ s32 uly; - /* 0x3C */ s32 lrx; - /* 0x40 */ s32 lry; - /* 0x44 */ ListAlloc alloc; - /* 0x4C */ u32 unk_4C; -} PreRender; // size = 0x50 - -#define TRANS_TRIGGER_OFF 0 // transition is not active -#define TRANS_TRIGGER_START 20 // start transition (exiting an area) -#define TRANS_TRIGGER_END -20 // transition is ending (arriving in a new area) - -typedef enum { - /* 0 */ TRANS_MODE_OFF, - /* 1 */ TRANS_MODE_SETUP, - /* 2 */ TRANS_MODE_INSTANCE_INIT, - /* 3 */ TRANS_MODE_INSTANCE_RUNNING, - /* 4 */ TRANS_MODE_FILL_WHITE_INIT, - /* 5 */ TRANS_MODE_FILL_IN, - /* 6 */ TRANS_MODE_FILL_OUT, - /* 7 */ TRANS_MODE_FILL_BROWN_INIT, - /* 8 */ TRANS_MODE_08, // unused - /* 9 */ TRANS_MODE_09, // unused - /* 10 */ TRANS_MODE_INSTANT, - /* 11 */ TRANS_MODE_INSTANCE_WAIT, - /* 12 */ TRANS_MODE_SANDSTORM_INIT, - /* 13 */ TRANS_MODE_SANDSTORM, - /* 14 */ TRANS_MODE_SANDSTORM_END_INIT, - /* 15 */ TRANS_MODE_SANDSTORM_END, - /* 16 */ TRANS_MODE_CS_BLACK_FILL_INIT, - /* 17 */ TRANS_MODE_CS_BLACK_FILL -} TransitionMode; - -typedef enum { - /* 0 */ TRANS_TYPE_WIPE, - /* 1 */ TRANS_TYPE_TRIFORCE, - /* 2 */ TRANS_TYPE_FADE_BLACK, - /* 3 */ TRANS_TYPE_FADE_WHITE, - /* 4 */ TRANS_TYPE_FADE_BLACK_FAST, - /* 5 */ TRANS_TYPE_FADE_WHITE_FAST, - /* 6 */ TRANS_TYPE_FADE_BLACK_SLOW, - /* 7 */ TRANS_TYPE_FADE_WHITE_SLOW, - /* 8 */ TRANS_TYPE_WIPE_FAST, - /* 9 */ TRANS_TYPE_FILL_WHITE2, - /* 10 */ TRANS_TYPE_FILL_WHITE, - /* 11 */ TRANS_TYPE_INSTANT, - /* 12 */ TRANS_TYPE_FILL_BROWN, - /* 13 */ TRANS_TYPE_FADE_WHITE_CS_DELAYED, - /* 14 */ TRANS_TYPE_SANDSTORM_PERSIST, - /* 15 */ TRANS_TYPE_SANDSTORM_END, - /* 16 */ TRANS_TYPE_CS_BLACK_FILL, - /* 17 */ TRANS_TYPE_FADE_WHITE_INSTANT, - /* 18 */ TRANS_TYPE_FADE_GREEN, - /* 19 */ TRANS_TYPE_FADE_BLUE, - // transition types 20 - 31 are unused - // transition types 32 - 55 are constructed using the TRANS_TYPE_CIRCLE macro - /* 56 */ TRANS_TYPE_MAX = 56 -} TransitionType; - -#define TRANS_NEXT_TYPE_DEFAULT 0xFF // when `nextTransitionType` is set to default, the type will be taken from the entrance table for the ending transition - -typedef enum { - /* 0 */ TCA_NORMAL, - /* 1 */ TCA_WAVE, - /* 2 */ TCA_RIPPLE, - /* 3 */ TCA_STARBURST -} TransitionCircleAppearance; - -typedef enum { - /* 0 */ TCC_BLACK, - /* 1 */ TCC_WHITE, - /* 2 */ TCC_GRAY, - /* 3 */ TCC_SPECIAL // color varies depending on appearance. unused and appears broken -} TransitionCircleColor; - -typedef enum { - /* 0 */ TCS_FAST, - /* 1 */ TCS_SLOW -} TransitionCircleSpeed; - -#define TC_SET_PARAMS (1 << 7) - -#define TRANS_TYPE_CIRCLE(appearance, color, speed) ((1 << 5) | ((color & 3) << 3) | ((appearance & 3) << 1) | (speed & 1)) - -typedef struct { - union { - TransitionFade fade; - TransitionCircle circle; - TransitionTriforce triforce; - TransitionWipe wipe; - } instanceData; - /* 0x228 */ s32 transitionType; - /* 0x22C */ void* (*init)(void* transition); - /* 0x230 */ void (*destroy)(void* transition); - /* 0x234 */ void (*update)(void* transition, s32 updateRate); - /* 0x238 */ void (*draw)(void* transition, Gfx** gfxP); - /* 0x23C */ void (*start)(void* transition); - /* 0x240 */ void (*setType)(void* transition, s32 type); - /* 0x244 */ void (*setColor)(void* transition, u32 color); - /* 0x248 */ void (*setUnkColor)(void* transition, u32 color); - /* 0x24C */ s32 (*isDone)(void* transition); -} TransitionContext; // size = 0x250 - -typedef struct { - /* 0x00 */ u8* readBuff; -} SramContext; // size = 0x4 - -#define SRAM_SIZE 0x8000 -#define SRAM_HEADER_SIZE 0x10 - -typedef enum { - /* 0x00 */ SRAM_HEADER_SOUND, - /* 0x01 */ SRAM_HEADER_ZTARGET, - /* 0x02 */ SRAM_HEADER_LANGUAGE, - /* 0x03 */ SRAM_HEADER_MAGIC // must be the value of `sZeldaMagic` for save to be considered valid -} SramHeaderField; - -typedef struct GameAllocEntry { - /* 0x00 */ struct GameAllocEntry* next; - /* 0x04 */ struct GameAllocEntry* prev; - /* 0x08 */ u32 size; - /* 0x0C */ u32 unk_0C; -} GameAllocEntry; // size = 0x10 - -typedef struct { - /* 0x00 */ GameAllocEntry base; - /* 0x10 */ GameAllocEntry* head; -} GameAlloc; // size = 0x14 - -// Used in Graph_GetNextGameState in graph.c -#define DEFINE_GAMESTATE_INTERNAL(typeName, enumName) enumName, -#define DEFINE_GAMESTATE(typeName, enumName, name) DEFINE_GAMESTATE_INTERNAL(typeName, enumName) -typedef enum { -#include "tables/gamestate_table.h" - GAMESTATE_ID_MAX -} GameStateId; -#undef DEFINE_GAMESTATE -#undef DEFINE_GAMESTATE_INTERNAL - -struct GameState; - -typedef void (*GameStateFunc)(struct GameState* gameState); - -typedef struct GameState { - /* 0x00 */ GraphicsContext* gfxCtx; - /* 0x04 */ GameStateFunc main; - /* 0x08 */ GameStateFunc destroy; // "cleanup" - /* 0x0C */ GameStateFunc init; - /* 0x10 */ u32 size; - /* 0x14 */ Input input[MAXCONTROLLERS]; - /* 0x74 */ TwoHeadArena tha; - /* 0x84 */ GameAlloc alloc; - /* 0x98 */ u32 running; - /* 0x9C */ u32 frames; - /* 0xA0 */ u32 inPreNMIState; -} GameState; // size = 0xA4 - typedef struct { /* 0x00 */ GameState state; } SetupState; // size = 0xA4 @@ -1212,114 +769,6 @@ typedef struct { /* 0x10 */ OSTime resetTime; } PreNmiBuff; // size = 0x18 (actually osAppNMIBuffer is 0x40 bytes large but the rest is unused) -#define UCODE_NULL 0 -#define UCODE_F3DZEX 1 -#define UCODE_UNK 2 -#define UCODE_S2DEX 3 - -typedef struct { - /* 0x00 */ u32 type; - /* 0x04 */ void* ptr; -} UCodeInfo; // size = 0x8 - -typedef struct { - /* 0x00 */ uintptr_t segments[NUM_SEGMENTS]; - /* 0x40 */ Gfx* dlStack[18]; - /* 0x88 */ s32 dlDepth; - /* 0x8C */ u32 dlCnt; - /* 0x90 */ u32 vtxCnt; - /* 0x94 */ u32 spvtxCnt; - /* 0x98 */ u32 tri1Cnt; - /* 0x9C */ u32 tri2Cnt; - /* 0xA0 */ u32 quadCnt; - /* 0xA4 */ u32 lineCnt; - /* 0xA8 */ u32 loaducodeCnt; - /* 0xAC */ u32 pipeSyncRequired; - /* 0xB0 */ u32 tileSyncRequired; - /* 0xB4 */ u32 loadSyncRequired; - /* 0xB8 */ u32 syncErr; - /* 0xBC */ s32 enableLog; - /* 0xC0 */ s32 ucodeType; - /* 0xC4 */ s32 ucodeInfoCount; - /* 0xC8 */ UCodeInfo* ucodeInfo; - /* 0xCC */ u32 modeH; - /* 0xD0 */ u32 modeL; - /* 0xD4 */ u32 geometryMode; -} UCodeDisas; // size = 0xD8 - -typedef struct { - /* 0x00 */ u16 table[8*8]; -} JpegQuantizationTable; // size = 0x80 - -typedef struct { - /* 0x00 */ u8 codeOffs[16]; - /* 0x10 */ u16 codesA[16]; - /* 0x30 */ u16 codesB[16]; - /* 0x50 */ u8* symbols; -} JpegHuffmanTable; // size = 0x54 - -// this struct might be inaccurate but it's not used outside jpegutils.c anyways -typedef struct { - /* 0x000 */ u8 codeOffs[16]; - /* 0x010 */ u16 dcCodes[120]; - /* 0x100 */ u16 acCodes[256]; -} JpegHuffmanTableOld; // size = 0x300 - -typedef union { - struct { - /* 0x00 */ u32 address; - /* 0x04 */ u32 mbCount; - /* 0x08 */ u32 mode; - /* 0x0C */ u32 qTableYPtr; - /* 0x10 */ u32 qTableUPtr; - /* 0x14 */ u32 qTableVPtr; - /* 0x18 */ u32 mbSize; // This field is used by the microcode to save the macroblock size during a yield - }; - long long int force_structure_alignment; -} JpegTaskData; // size = 0x20 - -typedef struct { - /* 0x000 */ JpegTaskData taskData; - /* 0x020 */ u64 yieldData[0x200 / sizeof(u64)]; - /* 0x220 */ JpegQuantizationTable qTableY; - /* 0x2A0 */ JpegQuantizationTable qTableU; - /* 0x320 */ JpegQuantizationTable qTableV; - /* 0x3A0 */ u8 codesLengths[0x110]; - /* 0x4B0 */ u16 codes[0x108]; - /* 0x6C0 */ u16 data[4][0x180]; -} JpegWork; // size = 0x12C0 - -typedef struct { - /* 0x00 */ void* imageData; - /* 0x04 */ u8 mode; - /* 0x05 */ u8 unk_05; - /* 0x08 */ JpegHuffmanTable* hTablePtrs[4]; - /* 0x18 */ u8 unk_18; -} JpegDecoder; // size = 0x1C - -typedef struct { - /* 0x00 */ u8 dqtCount; - /* 0x04 */ u8* dqtPtr[3]; - /* 0x10 */ u8 dhtCount; - /* 0x14 */ u8* dhtPtr[4]; - /* 0x24 */ void* imageData; - /* 0x28 */ u32 mode; // 0 if Y V0 is 1 and 2 if Y V0 is 2 - /* 0x30 */ OSScTask scTask; - /* 0x98 */ OSMesgQueue mq; - /* 0xB0 */ OSMesg msg; - /* 0xB4 */ JpegWork* workBuf; -} JpegContext; // size = 0xB8 - -typedef struct { - /* 0x00 */ u32 byteIdx; - /* 0x04 */ u8 bitIdx; - /* 0x05 */ u8 dontSkip; - /* 0x08 */ u32 curWord; - /* 0x0C */ s16 unk_0C; - /* 0x0E */ s16 unk_0E; - /* 0x10 */ s16 unk_10; -} JpegDecoderState; // size = 0x14 - typedef enum { /* 0 */ VI_MODE_EDIT_STATE_INACTIVE, /* 1 */ VI_MODE_EDIT_STATE_ACTIVE, @@ -1370,69 +819,4 @@ typedef struct { /* 0x08 */ Color_RGBA8_u32 envColor; } struct_80166500; // size = 0x10 -typedef struct { - /* 0x00 */ char unk_00[0x18]; - /* 0x18 */ s32 unk_18; - /* 0x1C */ s32 y; -} SpeedMeter; // size = 0x20 - -typedef struct { - /* 0x00 */ s32 maxval; - /* 0x04 */ s32 val; - /* 0x08 */ u16 backColor; - /* 0x0A */ u16 foreColor; - /* 0x0C */ s32 ulx; - /* 0x10 */ s32 lrx; - /* 0x14 */ s32 uly; - /* 0x18 */ s32 lry; -} SpeedMeterAllocEntry; // size = 0x1C - -typedef struct { - /* 0x00 */ volatile OSTime* time; - /* 0x04 */ u8 x; - /* 0x05 */ u8 y; - /* 0x06 */ u16 color; -} SpeedMeterTimeEntry; // size = 0x08 - -typedef struct { - /* 0x00 */ u32 value; - /* 0x04 */ const char* name; -} F3dzexConst; // size = 0x8 - -typedef struct { - /* 0x00 */ u32 value; - /* 0x04 */ const char* setName; - /* 0x08 */ const char* unsetName; -} F3dzexFlag; // size = 0x0C - -typedef struct { - /* 0x00 */ const char* name; - /* 0x04 */ u32 value; - /* 0x08 */ u32 mask; -} F3dzexRenderMode; // size = 0x0C - -typedef struct { - /* 0x00 */ const char* name; - /* 0x04 */ u32 value; -} F3dzexSetModeMacroValue; // size = 0x8 - -typedef struct { - /* 0x00 */ const char* name; - /* 0x04 */ u32 shift; - /* 0x08 */ u32 len; - /* 0x0C */ F3dzexSetModeMacroValue values[4]; -} F3dzexSetModeMacro; // size = 0x2C - -typedef struct { - /* 0x00 */ u16* value; - /* 0x04 */ const char* name; -} FlagSetEntry; // size = 0x08 - -#define ROM_FILE(name) \ - { (uintptr_t)_##name##SegmentRomStart, (uintptr_t)_##name##SegmentRomEnd } -#define ROM_FILE_EMPTY(name) \ - { (uintptr_t)_##name##SegmentRomStart, (uintptr_t)_##name##SegmentRomStart } -#define ROM_FILE_UNSET \ - { 0 } - #endif diff --git a/include/z64animation.h b/include/z64animation.h index c7108a6681..ca87a69d15 100755 --- a/include/z64animation.h +++ b/include/z64animation.h @@ -88,8 +88,12 @@ typedef enum { /* 1 */ ANIMTAPER_ACCEL } AnimationTapers; +#define ANIM_FLAG_0 (1 << 0) // (no effect outside of player) Related to scaling an animation from/to child/adult #define ANIM_FLAG_UPDATE_Y (1 << 1) +#define ANIM_FLAG_PLAYER_2 (1 << 2) // (player-only) Related to scaling an animation from/to child/adult +#define ANIM_FLAG_PLAYER_SETMOVE (1 << 3) // (player-only) Call AnimationContext_SetMoveActor #define ANIM_FLAG_NO_MOVE (1 << 4) +#define ANIM_FLAG_PLAYER_7 (1 << 7) // (player-only) typedef struct SkelAnime { /* 0x00 */ u8 limbCount; // Number of limbs in the skeleton @@ -287,7 +291,7 @@ typedef struct { typedef struct { /* 0x000 */ struct Actor* actor; /* 0x004 */ struct SkelAnime* skelAnime; - /* 0x008 */ f32 unk_08; + /* 0x008 */ f32 diffScaleY; } AnimEntryMoveActor; // size = 0xC typedef union { @@ -317,7 +321,7 @@ void AnimationContext_SetCopyAll(struct PlayState* play, s32 vecCount, Vec3s* ds void AnimationContext_SetCopyTrue(struct PlayState* play, s32 vecCount, Vec3s* dst, Vec3s* src, u8* copyFlag); void AnimationContext_SetCopyFalse(struct PlayState* play, s32 vecCount, Vec3s* dst, Vec3s* src, u8* copyFlag); void AnimationContext_SetInterp(struct PlayState* play, s32 vecCount, Vec3s* base, Vec3s* mod, f32 weight); -void AnimationContext_SetMoveActor(struct PlayState* play, struct Actor* actor, SkelAnime* skelAnime, f32 arg3); +void AnimationContext_SetMoveActor(struct PlayState* play, struct Actor* actor, SkelAnime* skelAnime, f32 moveDiffScaleY); void AnimationContext_SetNextQueue(struct PlayState* play); void AnimationContext_DisableQueue(struct PlayState* play); diff --git a/include/z64bgcheck.h b/include/z64bgcheck.h index aa25557c11..2396b9ccbe 100644 --- a/include/z64bgcheck.h +++ b/include/z64bgcheck.h @@ -1,16 +1,13 @@ -#ifndef Z_BGCHECK_H -#define Z_BGCHECK_H +#ifndef Z64BGCHECK_H +#define Z64BGCHECK_H + +#include "ultra64/ultratypes.h" +#include "z64math.h" struct PlayState; struct Actor; struct DynaPolyActor; -#define COLPOLY_NORMAL_FRAC (1.0f / SHT_MAX) -#define COLPOLY_SNORMAL(x) ((s16)((x) * SHT_MAX)) -#define COLPOLY_GET_NORMAL(n) ((n)*COLPOLY_NORMAL_FRAC) -#define COLPOLY_VIA_FLAG_TEST(vIA, flags) ((vIA) & (((flags)&7) << 13)) -#define COLPOLY_VTX_INDEX(vI) ((vI)&0x1FFF) - #define DYNAPOLY_INVALIDATE_LOOKUP (1 << 0) #define BGACTOR_NEG_ONE -1 @@ -27,10 +24,30 @@ struct DynaPolyActor; #define FUNC_80041EA4_VOID_OUT 12 typedef struct { - Vec3f scale; - Vec3s rot; - Vec3f pos; -} ScaleRotPos; + /* 0x00 */ Vec3f scale; + /* 0x0C */ Vec3s rot; + /* 0x14 */ Vec3f pos; +} ScaleRotPos; // size = 0x20 + +// Macros for `CollisionPoly` + +#define COLPOLY_NORMAL_FRAC (1.0f / SHT_MAX) +#define COLPOLY_SNORMAL(x) ((s16)((x) * SHT_MAX)) +#define COLPOLY_GET_NORMAL(n) ((n)*COLPOLY_NORMAL_FRAC) +#define COLPOLY_VTX_CHECK_FLAGS_ANY(vI, flags) ((vI) & (((flags) & 7) << 13)) +#define COLPOLY_VTX_FLAGS_MASKED(vI) ((vI) & 0xE000) +#define COLPOLY_VTX_INDEX(vI) ((vI) & 0x1FFF) +#define COLPOLY_VTX(vtxId, flags) ((((flags) & 7) << 13) | ((vtxId) & 0x1FFF)) + +// flags for flags_vIA +// poly exclusion flags (xpFlags) +#define COLPOLY_IGNORE_NONE 0 +#define COLPOLY_IGNORE_CAMERA (1 << 0) +#define COLPOLY_IGNORE_ENTITY (1 << 1) +#define COLPOLY_IGNORE_PROJECTILES (1 << 2) + +// flags for flags_vIB +#define COLPOLY_IS_FLOOR_CONVEYOR (1 << 0) typedef struct { /* 0x00 */ u16 type; @@ -39,7 +56,7 @@ typedef struct { struct { /* 0x02 */ u16 flags_vIA; // 0xE000 is poly exclusion flags (xpFlags), 0x1FFF is vtxId /* 0x04 */ u16 flags_vIB; // 0xE000 is flags, 0x1FFF is vtxId - // 0x2000 = poly IsConveyor surface + // 0x2000 = poly IsFloorConveyor surface /* 0x06 */ u16 vIC; }; }; @@ -75,29 +92,18 @@ typedef struct { // Macros for `WaterBox.properties` -#define WATERBOX_BGCAM_INDEX_SHIFT 0 -#define WATERBOX_BGCAM_INDEX_MASK 0x000000FF -#define WATERBOX_BGCAM_INDEX(properties) \ - (((properties) >> WATERBOX_BGCAM_INDEX_SHIFT) & (WATERBOX_BGCAM_INDEX_MASK >> WATERBOX_BGCAM_INDEX_SHIFT)) - -#define WATERBOX_LIGHT_INDEX_SHIFT 8 -#define WATERBOX_LIGHT_INDEX_MASK 0x00001F00 -#define WATERBOX_LIGHT_INDEX(properties) \ - (((properties) >> WATERBOX_LIGHT_INDEX_SHIFT) & (WATERBOX_LIGHT_INDEX_MASK >> WATERBOX_LIGHT_INDEX_SHIFT)) #define WATERBOX_LIGHT_INDEX_NONE 0x1F // warns and defaults to 0 -#define WATERBOX_ROOM_SHIFT 13 -#define WATERBOX_ROOM_MASK 0x0007E000 -#define WATERBOX_ROOM(properties) (((properties) >> WATERBOX_ROOM_SHIFT) & (WATERBOX_ROOM_MASK >> WATERBOX_ROOM_SHIFT)) +#define WATERBOX_ROOM(properties) (((properties) >> 13) & 0x3F) #define WATERBOX_ROOM_ALL 0x3F // value for "room index" indicating "all rooms" -#define WATERBOX_FLAG_19_SHIFT 19 -#define WATERBOX_FLAG_19 (1 << WATERBOX_FLAG_19_SHIFT) +#define WATERBOX_FLAG_19 (1 << 19) -#define WATERBOX_PROPERTIES(bgCamIndex, lightIndex, room, setFlag19) \ - ((((bgCamIndex) << WATERBOX_BGCAM_INDEX_SHIFT) & WATERBOX_BGCAM_INDEX_MASK) | \ - (((lightIndex) << WATERBOX_LIGHT_INDEX_SHIFT) & WATERBOX_LIGHT_INDEX_MASK) | \ - (((room) << WATERBOX_ROOM_SHIFT) & WATERBOX_ROOM_MASK) | (((setFlag19) & 1) << WATERBOX_FLAG_19_SHIFT)) +#define WATERBOX_PROPERTIES(bgCamIndex, lightIndex, room, setFlag19) \ + ((((bgCamIndex) & 0xFF) << 0) | \ + (((lightIndex) & 0x1F) << 8) | \ + (((room) & 0x3F) << 13) | \ + (((setFlag19) & 1) << 19)) typedef struct { /* 0x00 */ s16 xMin; @@ -213,6 +219,27 @@ typedef enum { } ConveyorSpeed; #define CONVEYOR_DIRECTION_TO_BINANG(conveyorDirection) ((conveyorDirection) * (0x10000 / 64)) +#define CONVEYOR_DIRECTION_FROM_BINANG(conveyorDirectionBinang) ((conveyorDirectionBinang) * (64 / 0x10000)) + +#define SURFACETYPE0(bgCamIndex, exitIndex, floorType, unk18, wallType, floorProperty, isSoft, isHorseBlocked) \ + ((((bgCamIndex) & 0xFF) << 0) | \ + (((exitIndex) & 0x1F) << 8) | \ + (((floorType) & 0x1F) << 13) | \ + (((unk18) & 0x07) << 18) | \ + (((wallType) & 0x1F) << 21) | \ + (((floorProperty) & 0x0F) << 26) | \ + (((isSoft) & 1) << 30) | \ + (((isHorseBlocked) & 1) << 31)) + +#define SURFACETYPE1(material, floorEffect, lightSetting, echo, canHookshot, conveyorSpeed, conveyorDirection, unk27) \ + ((((material) & 0x0F) << 0) | \ + (((floorEffect) & 0x03) << 4) | \ + (((lightSetting) & 0x1F) << 6) | \ + (((echo) & 0x3F) << 11) | \ + (((canHookshot) & 1) << 17) | \ + (((conveyorSpeed) & 0x07) << 18) | \ + (((conveyorDirection) & 0x3F) << 21) | \ + (((unk27) & 1) << 27)) typedef struct { u32 data[2]; diff --git a/include/z64collision_check.h b/include/z64collision_check.h index b0b6879d93..3e4ae20f32 100644 --- a/include/z64collision_check.h +++ b/include/z64collision_check.h @@ -1,12 +1,11 @@ -#ifndef Z_COLLISION_CHECK_H -#define Z_COLLISION_CHECK_H +#ifndef Z64COLLISION_CHECK_H +#define Z64COLLISION_CHECK_H #define COLLISION_CHECK_AT_MAX 50 #define COLLISION_CHECK_AC_MAX 60 #define COLLISION_CHECK_OC_MAX 50 #define COLLISION_CHECK_OC_LINE_MAX 3 -// From z64.h struct Actor; typedef struct { diff --git a/include/z64cutscene.h b/include/z64cutscene.h index 24ca4ffc9a..004bdb6904 100644 --- a/include/z64cutscene.h +++ b/include/z64cutscene.h @@ -513,4 +513,21 @@ typedef struct { /* 0x8 */ s16 relativeToPlayer; } CutsceneCameraMove; // size = 0xC +typedef struct { + /* 0x00 */ char unk_00[0x4]; + /* 0x04 */ void* script; + /* 0x08 */ u8 state; + /* 0x0C */ f32 timer; + /* 0x10 */ u16 curFrame; // current frame of the script that is running + /* 0x12 */ u16 unk_12; // set but never used + /* 0x14 */ s32 subCamId; + /* 0x18 */ u16 camEyeSplinePointsAppliedFrame; // stores the frame the cam eye spline points data was last applied on + /* 0x1A */ u8 camAtReady; // cam `at` data is ready to be applied + /* 0x1B */ u8 camEyeReady; // cam `eye` data is ready to be applied + /* 0x1C */ CutsceneCameraPoint* camAtPoints; + /* 0x20 */ CutsceneCameraPoint* camEyePoints; + /* 0x24 */ CsCmdActorCue* playerCue; + /* 0x28 */ CsCmdActorCue* actorCues[10]; // "npcdemopnt" +} CutsceneContext; // size = 0x50 + #endif diff --git a/include/z64dma.h b/include/z64dma.h index c27aa02739..1e9e87b074 100755 --- a/include/z64dma.h +++ b/include/z64dma.h @@ -22,6 +22,18 @@ typedef struct { /* 0x0C */ uintptr_t romEnd; } DmaEntry; +typedef struct { + /* 0x00 */ uintptr_t vromStart; + /* 0x04 */ uintptr_t vromEnd; +} RomFile; // size = 0x8 + +#define ROM_FILE(name) \ + { (uintptr_t)_##name##SegmentRomStart, (uintptr_t)_##name##SegmentRomEnd } +#define ROM_FILE_EMPTY(name) \ + { (uintptr_t)_##name##SegmentRomStart, (uintptr_t)_##name##SegmentRomStart } +#define ROM_FILE_UNSET \ + { 0 } + extern DmaEntry gDmaDataTable[]; extern u32 gDmaMgrVerbose; diff --git a/include/z64game.h b/include/z64game.h new file mode 100644 index 0000000000..8cd6478963 --- /dev/null +++ b/include/z64game.h @@ -0,0 +1,51 @@ +#ifndef Z64GAME_H +#define Z64GAME_H +// This file is named "game" after game.c for now, this may change later with the system name + +#include "ultra64/ultratypes.h" +#include "padmgr.h" +#include "tha.h" + +struct GraphicsContext; + +typedef struct GameAllocEntry { + /* 0x00 */ struct GameAllocEntry* next; + /* 0x04 */ struct GameAllocEntry* prev; + /* 0x08 */ u32 size; + /* 0x0C */ u32 unk_0C; +} GameAllocEntry; // size = 0x10 + +typedef struct { + /* 0x00 */ GameAllocEntry base; + /* 0x10 */ GameAllocEntry* head; +} GameAlloc; // size = 0x14 + +// Used in Graph_GetNextGameState in graph.c +#define DEFINE_GAMESTATE_INTERNAL(typeName, enumName) enumName, +#define DEFINE_GAMESTATE(typeName, enumName, name) DEFINE_GAMESTATE_INTERNAL(typeName, enumName) +typedef enum { +#include "tables/gamestate_table.h" + GAMESTATE_ID_MAX +} GameStateId; +#undef DEFINE_GAMESTATE +#undef DEFINE_GAMESTATE_INTERNAL + +struct GameState; + +typedef void (*GameStateFunc)(struct GameState* gameState); + +typedef struct GameState { + /* 0x00 */ struct GraphicsContext* gfxCtx; + /* 0x04 */ GameStateFunc main; + /* 0x08 */ GameStateFunc destroy; // "cleanup" + /* 0x0C */ GameStateFunc init; + /* 0x10 */ u32 size; + /* 0x14 */ Input input[MAXCONTROLLERS]; + /* 0x74 */ TwoHeadArena tha; + /* 0x84 */ GameAlloc alloc; + /* 0x98 */ u32 running; + /* 0x9C */ u32 frames; + /* 0xA0 */ u32 inPreNMIState; +} GameState; // size = 0xA4 + +#endif diff --git a/include/z64interface.h b/include/z64interface.h index 781b1e6fb6..4412cfdeda 100644 --- a/include/z64interface.h +++ b/include/z64interface.h @@ -29,6 +29,120 @@ extern u8 _icon_item_24_staticSegmentRomStart[]; #define GET_QUEST_ICON_VROM(itemId) \ ((uintptr_t)_icon_item_24_staticSegmentRomStart + (((itemId)-ITEM_MEDALLION_FOREST) * QUEST_ICON_SIZE)) +typedef enum { + /* 0x00 */ DO_ACTION_ATTACK, + /* 0x01 */ DO_ACTION_CHECK, + /* 0x02 */ DO_ACTION_ENTER, + /* 0x03 */ DO_ACTION_RETURN, + /* 0x04 */ DO_ACTION_OPEN, + /* 0x05 */ DO_ACTION_JUMP, + /* 0x06 */ DO_ACTION_DECIDE, + /* 0x07 */ DO_ACTION_DIVE, + /* 0x08 */ DO_ACTION_FASTER, + /* 0x09 */ DO_ACTION_THROW, + /* 0x0A */ DO_ACTION_NONE, // in do_action_static, the texture at this position is NAVI, however this value is in practice the "No Action" value + /* 0x0B */ DO_ACTION_CLIMB, + /* 0x0C */ DO_ACTION_DROP, + /* 0x0D */ DO_ACTION_DOWN, + /* 0x0E */ DO_ACTION_SAVE, + /* 0x0F */ DO_ACTION_SPEAK, + /* 0x10 */ DO_ACTION_NEXT, + /* 0x11 */ DO_ACTION_GRAB, + /* 0x12 */ DO_ACTION_STOP, + /* 0x13 */ DO_ACTION_PUTAWAY, + /* 0x14 */ DO_ACTION_REEL, + /* 0x15 */ DO_ACTION_1, + /* 0x16 */ DO_ACTION_2, + /* 0x17 */ DO_ACTION_3, + /* 0x18 */ DO_ACTION_4, + /* 0x19 */ DO_ACTION_5, + /* 0x1A */ DO_ACTION_6, + /* 0x1B */ DO_ACTION_7, + /* 0x1C */ DO_ACTION_8, + /* 0x1D */ DO_ACTION_MAX +} DoAction; + +// TODO extract this information from the texture definitions themselves +#define DO_ACTION_TEX_WIDTH 48 +#define DO_ACTION_TEX_HEIGHT 16 +#define DO_ACTION_TEX_SIZE ((DO_ACTION_TEX_WIDTH * DO_ACTION_TEX_HEIGHT) / 2) // (sizeof(gCheckDoActionENGTex)) + +typedef struct { + /* 0x0000 */ View view; + /* 0x0128 */ Vtx* actionVtx; + /* 0x012C */ Vtx* beatingHeartVtx; + /* 0x0130 */ u8* parameterSegment; + /* 0x0134 */ u8* doActionSegment; + /* 0x0138 */ u8* iconItemSegment; + /* 0x013C */ u8* mapSegment; + /* 0x0140 */ u8 mapPalette[32]; + /* 0x0160 */ DmaRequest dmaRequest_160; + /* 0x0180 */ DmaRequest dmaRequest_180; + /* 0x01A0 */ char unk_1A0[0x20]; + /* 0x01C0 */ OSMesgQueue loadQueue; + /* 0x01D8 */ OSMesg loadMsg; + /* 0x01DC */ Viewport viewport; + /* 0x01EC */ s16 unk_1EC; + /* 0x01EE */ u16 unk_1EE; + /* 0x01F0 */ u16 unk_1F0; + /* 0x01F4 */ f32 unk_1F4; + /* 0x01F8 */ s16 naviCalling; + /* 0x01FA */ s16 unk_1FA; + /* 0x01FC */ s16 unk_1FC; + /* 0x01FE */ s16 heartColorOscillator; + /* 0x0200 */ s16 heartColorOscillatorDirection; + /* 0x0202 */ s16 beatingHeartPrim[3]; + /* 0x0208 */ s16 beatingHeartEnv[3]; + /* 0x020E */ s16 heartsPrimR[2]; + /* 0x0212 */ s16 heartsPrimG[2]; + /* 0x0216 */ s16 heartsPrimB[2]; + /* 0x021A */ s16 heartsEnvR[2]; + /* 0x021E */ s16 heartsEnvG[2]; + /* 0x0222 */ s16 heartsEnvB[2]; + /* 0x0226 */ s16 unk_226; // Used only in unused functions + /* 0x0228 */ s16 unk_228; // Used only in unused functions + /* 0x022A */ s16 beatingHeartOscillator; + /* 0x022C */ s16 beatingHeartOscillatorDirection; + /* 0x022E */ s16 unk_22E; + /* 0x0230 */ s16 lensMagicConsumptionTimer; // When lens is active, 1 unit of magic is consumed every time the timer reaches 0 + /* 0x0232 */ s16 counterDigits[4]; // used for key and rupee counters + /* 0x023A */ u8 numHorseBoosts; + /* 0x023C */ u16 unk_23C; + /* 0x023E */ u16 hbaAmmo; // ammo while playing the horseback archery minigame + /* 0x0240 */ u16 unk_240; + /* 0x0242 */ u16 unk_242; + /* 0x0224 */ u16 unk_244; // screen fill alpha? + /* 0x0246 */ u16 aAlpha; // also carrots alpha + /* 0x0248 */ u16 bAlpha; // also HBA score alpha + /* 0x024A */ u16 cLeftAlpha; + /* 0x024C */ u16 cDownAlpha; + /* 0x024E */ u16 cRightAlpha; + /* 0x0250 */ u16 healthAlpha; // also max C-Up alpha + /* 0x0252 */ u16 magicAlpha; // also Rupee and Key counters alpha + /* 0x0254 */ u16 minimapAlpha; + /* 0x0256 */ s16 startAlpha; + /* 0x0258 */ s16 unk_258; + /* 0x025A */ s16 unk_25A; + /* 0x025C */ s16 mapRoomNum; + /* 0x025E */ s16 mapPaletteIndex; // "map_palete_no" + /* 0x0260 */ u8 unk_260; + /* 0x0261 */ u8 unk_261; + struct { + /* 0x0262 */ u8 hGauge; // "h_gage"; unknown? + /* 0x0263 */ u8 bButton; // "b_button" + /* 0x0264 */ u8 aButton; // "a_button" + /* 0x0265 */ u8 bottles; // "c_bottle" + /* 0x0266 */ u8 tradeItems; // "c_warasibe" + /* 0x0267 */ u8 hookshot; // "c_hook" + /* 0x0268 */ u8 ocarina; // "c_ocarina" + /* 0x0269 */ u8 warpSongs; // "c_warp" + /* 0x026A */ u8 sunsSong; // "m_sunmoon" + /* 0x026B */ u8 farores; // "m_wind" + /* 0x026C */ u8 dinsNayrus; // "m_magic"; din's fire and nayru's love + /* 0x026D */ u8 all; // "another"; enables all item restrictions + } restrictions; +} InterfaceContext; // size = 0x270 + /** * Button HUD Positions (Upper Left) */ diff --git a/include/z64object.h b/include/z64object.h index 8add3b7a63..3f80fee7a7 100644 --- a/include/z64object.h +++ b/include/z64object.h @@ -1,8 +1,29 @@ #ifndef Z64OBJECT_H #define Z64OBJECT_H +#include "ultra64.h" +#include "z64dma.h" + #define OBJECT_EXCHANGE_BANK_MAX 19 +typedef struct { + /* 0x00 */ s16 id; + /* 0x04 */ void* segment; + /* 0x08 */ DmaRequest dmaRequest; + /* 0x28 */ OSMesgQueue loadQueue; + /* 0x40 */ OSMesg loadMsg; +} ObjectStatus; // size = 0x44 + +typedef struct { + /* 0x0000 */ void* spaceStart; + /* 0x0004 */ void* spaceEnd; // original name: "endSegment" + /* 0x0008 */ u8 num; // number of objects in bank + /* 0x0009 */ u8 unk_09; + /* 0x000A */ u8 mainKeepIndex; // "gameplay_keep" index in bank + /* 0x000B */ u8 subKeepIndex; // "gameplay_field_keep" or "gameplay_dangeon_keep" index in bank + /* 0x000C */ ObjectStatus status[OBJECT_EXCHANGE_BANK_MAX]; +} ObjectContext; // size = 0x518 + #define DEFINE_OBJECT(_0, enum) enum, #define DEFINE_OBJECT_NULL(_0, enum) enum, #define DEFINE_OBJECT_UNSET(enum) enum, diff --git a/include/z64save.h b/include/z64save.h index e8f7e92cbc..3686ff5e4d 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -350,6 +350,18 @@ typedef enum { /* 0x06 */ HS_DAMPE_RACE } HighScores; +// the score value for the fishing minigame also stores many flags. +#define HS_FISH_LENGTH_CHILD 0x7F // mask for record length of catch as child. +#define HS_FISH_LENGTH_ADULT 0x7F000000 // mask for record length of catch as adult. +#define HS_FISH_PLAYED_CHILD 0x100 // set when first talking to owner as child +#define HS_FISH_PLAYED_ADULT 0x200 // set when first talking to owner as adult +#define HS_FISH_PRIZE_CHILD 0x400 // won the Piece of Heart +#define HS_FISH_PRIZE_ADULT 0x800 // won the Golden Scale +#define HS_FISH_STOLE_HAT 0x1000 // Pond owner is visibly bald as Adult Link. +#define HS_FISH_CHEAT_CHILD 0x80 // used Sinking Lure as child to catch record fish +#define HS_FISH_CHEAT_ADULT 0x80000000 // used Sinking Lure as adult to catch record fish +#define HS_FISH_PLAYED 0x10000 // incremented for every play. controls weather. + typedef enum { /* 0 */ SUNSSONG_INACTIVE, /* 1 */ SUNSSONG_START, // the suns ocarina effect signals that the song has finished playing @@ -413,7 +425,7 @@ typedef enum { #define EVENTCHKINF_1B 0x1B #define EVENTCHKINF_1C 0x1C #define EVENTCHKINF_1D 0x1D -#define EVENTCHKINF_1E 0x1E +#define EVENTCHKINF_HORSE_RACE_COW_UNLOCK 0x1E #define EVENTCHKINF_20 0x20 #define EVENTCHKINF_21 0x21 #define EVENTCHKINF_22 0x22 diff --git a/include/z64scene.h b/include/z64scene.h index 4efc1a567d..106fd62cb3 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -2,14 +2,10 @@ #define Z64SCENE_H #include "z64.h" +#include "z64dma.h" // for RomFile #include "command_macros_base.h" -typedef struct { - /* 0x00 */ uintptr_t vromStart; - /* 0x04 */ uintptr_t vromEnd; -} RomFile; // size = 0x8 - typedef struct { /* 0x00 */ RomFile sceneFile; /* 0x08 */ RomFile titleFile; diff --git a/include/z64skybox.h b/include/z64skybox.h index d97efe4567..73017cbb37 100644 --- a/include/z64skybox.h +++ b/include/z64skybox.h @@ -5,7 +5,7 @@ #include "ultra64/gbi.h" #include "z64math.h" -#include "z64scene.h" // for RomFile +#include "z64dma.h" // for RomFile struct GameState; struct GraphicsContext; diff --git a/include/z64sram.h b/include/z64sram.h new file mode 100644 index 0000000000..0f87f55fcd --- /dev/null +++ b/include/z64sram.h @@ -0,0 +1,20 @@ +#ifndef Z64SRAM_H +#define Z64SRAM_H + +#include "ultra64/ultratypes.h" + +typedef struct { + /* 0x00 */ u8* readBuff; +} SramContext; // size = 0x4 + +#define SRAM_SIZE 0x8000 +#define SRAM_HEADER_SIZE 0x10 + +typedef enum { + /* 0x00 */ SRAM_HEADER_SOUND, + /* 0x01 */ SRAM_HEADER_ZTARGET, + /* 0x02 */ SRAM_HEADER_LANGUAGE, + /* 0x03 */ SRAM_HEADER_MAGIC // must be the value of `sZeldaMagic` for save to be considered valid +} SramHeaderField; + +#endif diff --git a/include/z64transition.h b/include/z64transition.h index 324ddb7b7d..9cf74f7229 100644 --- a/include/z64transition.h +++ b/include/z64transition.h @@ -1,85 +1,84 @@ #ifndef Z64TRANSITION_H #define Z64TRANSITION_H -#include "ultra64.h" -#include "color.h" +#include "ultra64/ultratypes.h" +#include "ultra64/gbi.h" // for Gfx +#include "z64transition_instances.h" -typedef struct { - /* 0x0 */ f32 x; - /* 0x4 */ f32 y; -} TransitionTileVtxData; // size = 0x8 - -typedef struct { - /* 0x00 */ s32 cols; - /* 0x04 */ s32 rows; - /* 0x08 */ s32 frame; - /* 0x0C */ TransitionTileVtxData* vtxData; - /* 0x10 */ Vtx* vtxFrame1; - /* 0x14 */ Vtx* vtxFrame2; - /* 0x18 */ Mtx projection; - /* 0x58 */ Mtx modelView; - /* 0x98 */ Mtx unk_98; - /* 0xD8 */ Gfx* gfx; // "gfxtbl" - /* 0xDC */ u16* zBuffer; -} TransitionTile; // size = 0xE0 +#define TRANS_TRIGGER_OFF 0 // transition is not active +#define TRANS_TRIGGER_START 20 // start transition (exiting an area) +#define TRANS_TRIGGER_END -20 // transition is ending (arriving in a new area) typedef enum { - /* 1 */ TRANS_INSTANCE_TYPE_FILL_OUT = 1, - /* 2 */ TRANS_INSTANCE_TYPE_FILL_IN -} TransitionInstanceType; + /* 0 */ TRANS_MODE_OFF, + /* 1 */ TRANS_MODE_SETUP, + /* 2 */ TRANS_MODE_INSTANCE_INIT, + /* 3 */ TRANS_MODE_INSTANCE_RUNNING, + /* 4 */ TRANS_MODE_FILL_WHITE_INIT, + /* 5 */ TRANS_MODE_FILL_IN, + /* 6 */ TRANS_MODE_FILL_OUT, + /* 7 */ TRANS_MODE_FILL_BROWN_INIT, + /* 8 */ TRANS_MODE_08, // unused + /* 9 */ TRANS_MODE_09, // unused + /* 10 */ TRANS_MODE_INSTANT, + /* 11 */ TRANS_MODE_INSTANCE_WAIT, + /* 12 */ TRANS_MODE_SANDSTORM_INIT, + /* 13 */ TRANS_MODE_SANDSTORM, + /* 14 */ TRANS_MODE_SANDSTORM_END_INIT, + /* 15 */ TRANS_MODE_SANDSTORM_END, + /* 16 */ TRANS_MODE_CS_BLACK_FILL_INIT, + /* 17 */ TRANS_MODE_CS_BLACK_FILL +} TransitionMode; + +typedef enum { + /* 0 */ TRANS_TYPE_WIPE, + /* 1 */ TRANS_TYPE_TRIFORCE, + /* 2 */ TRANS_TYPE_FADE_BLACK, + /* 3 */ TRANS_TYPE_FADE_WHITE, + /* 4 */ TRANS_TYPE_FADE_BLACK_FAST, + /* 5 */ TRANS_TYPE_FADE_WHITE_FAST, + /* 6 */ TRANS_TYPE_FADE_BLACK_SLOW, + /* 7 */ TRANS_TYPE_FADE_WHITE_SLOW, + /* 8 */ TRANS_TYPE_WIPE_FAST, + /* 9 */ TRANS_TYPE_FILL_WHITE2, + /* 10 */ TRANS_TYPE_FILL_WHITE, + /* 11 */ TRANS_TYPE_INSTANT, + /* 12 */ TRANS_TYPE_FILL_BROWN, + /* 13 */ TRANS_TYPE_FADE_WHITE_CS_DELAYED, + /* 14 */ TRANS_TYPE_SANDSTORM_PERSIST, + /* 15 */ TRANS_TYPE_SANDSTORM_END, + /* 16 */ TRANS_TYPE_CS_BLACK_FILL, + /* 17 */ TRANS_TYPE_FADE_WHITE_INSTANT, + /* 18 */ TRANS_TYPE_FADE_GREEN, + /* 19 */ TRANS_TYPE_FADE_BLUE, + // transition types 20 - 31 are unused + // transition types 32 - 55 are constructed using the TRANS_TYPE_CIRCLE macro + /* 56 */ TRANS_TYPE_MAX = 56 +} TransitionType; + +#define TRANS_NEXT_TYPE_DEFAULT 0xFF // when `nextTransitionType` is set to default, the type will be taken from the entrance table for the ending transition + +#define TC_SET_PARAMS (1 << 7) + +#define TRANS_TYPE_CIRCLE(appearance, color, speed) ((1 << 5) | ((color & 3) << 3) | ((appearance & 3) << 1) | (speed & 1)) typedef struct { - /* 0x000 */ Color_RGBA8_u32 color; - /* 0x004 */ Color_RGBA8_u32 unkColor; - /* 0x008 */ u8 direction; - /* 0x009 */ u8 frame; - /* 0x00A */ u8 isDone; - /* 0x00C */ u16 texX; - /* 0x00E */ u16 texY; - /* 0x010 */ u16 normal; - /* 0x018 */ Mtx projection; - /* 0x058 */ Mtx lookAt; - /* 0x098 */ Mtx modelView[2][3]; -} TransitionWipe; // size = 0x218 - -#define TRANS_INSTANCE_TYPE_FADE_FLASH 3 - -typedef struct { - /* 0x000 */ u8 type; - /* 0x001 */ u8 isDone; - /* 0x002 */ u8 direction; - /* 0x004 */ Color_RGBA8_u32 color; - /* 0x008 */ u16 timer; -} TransitionFade; // size = 0xC - -typedef struct { - /* 0x000 */ Color_RGBA8_u32 color; - /* 0x004 */ Color_RGBA8_u32 unkColor; - /* 0x008 */ s32 texX; - /* 0x00C */ s32 texY; - /* 0x010 */ s32 speed; - /* 0x014 */ u8 direction; - /* 0x015 */ u8 colorType; - /* 0x016 */ u8 speedType; - /* 0x017 */ u8 appearanceType; - /* 0x018 */ u8 isDone; - /* 0x019 */ u8 frame; - /* 0x01A */ u16 normal; - /* 0x020 */ Mtx projection; - /* 0x060 */ Mtx lookAt; - /* 0x0A0 */ void* texture; - /* 0x0A8 */ Mtx modelView[2][3]; -} TransitionCircle; // size = 0x228; - -typedef struct { - /* 0x000 */ Color_RGBA8_u32 color; - /* 0x004 */ f32 transPos; - /* 0x008 */ f32 step; - /* 0x00C */ s32 state; - /* 0x010 */ s32 type; - /* 0x018 */ Mtx projection; - /* 0x058 */ s32 frame; - /* 0x060 */ Mtx modelView[2][3]; -} TransitionTriforce; // size = 0x1E0; + union { + TransitionFade fade; + TransitionCircle circle; + TransitionTriforce triforce; + TransitionWipe wipe; + } instanceData; + /* 0x228 */ s32 transitionType; + /* 0x22C */ void* (*init)(void* transition); + /* 0x230 */ void (*destroy)(void* transition); + /* 0x234 */ void (*update)(void* transition, s32 updateRate); + /* 0x238 */ void (*draw)(void* transition, Gfx** gfxP); + /* 0x23C */ void (*start)(void* transition); + /* 0x240 */ void (*setType)(void* transition, s32 type); + /* 0x244 */ void (*setColor)(void* transition, u32 color); + /* 0x248 */ void (*setUnkColor)(void* transition, u32 color); + /* 0x24C */ s32 (*isDone)(void* transition); +} TransitionContext; // size = 0x250 #endif diff --git a/include/z64transition_instances.h b/include/z64transition_instances.h new file mode 100644 index 0000000000..c8fd3f16c2 --- /dev/null +++ b/include/z64transition_instances.h @@ -0,0 +1,104 @@ +#ifndef Z64TRANSITION_INSTANCES_H +#define Z64TRANSITION_INSTANCES_H + +#include "ultra64.h" +#include "color.h" + +typedef struct { + /* 0x0 */ f32 x; + /* 0x4 */ f32 y; +} TransitionTileVtxData; // size = 0x8 + +typedef struct { + /* 0x00 */ s32 cols; + /* 0x04 */ s32 rows; + /* 0x08 */ s32 frame; + /* 0x0C */ TransitionTileVtxData* vtxData; + /* 0x10 */ Vtx* vtxFrame1; + /* 0x14 */ Vtx* vtxFrame2; + /* 0x18 */ Mtx projection; + /* 0x58 */ Mtx modelView; + /* 0x98 */ Mtx unk_98; + /* 0xD8 */ Gfx* gfx; // "gfxtbl" + /* 0xDC */ u16* zBuffer; +} TransitionTile; // size = 0xE0 + +typedef enum { + /* 1 */ TRANS_INSTANCE_TYPE_FILL_OUT = 1, + /* 2 */ TRANS_INSTANCE_TYPE_FILL_IN +} TransitionInstanceType; + +typedef struct { + /* 0x000 */ Color_RGBA8_u32 color; + /* 0x004 */ Color_RGBA8_u32 unkColor; + /* 0x008 */ u8 direction; + /* 0x009 */ u8 frame; + /* 0x00A */ u8 isDone; + /* 0x00C */ u16 texX; + /* 0x00E */ u16 texY; + /* 0x010 */ u16 normal; + /* 0x018 */ Mtx projection; + /* 0x058 */ Mtx lookAt; + /* 0x098 */ Mtx modelView[2][3]; +} TransitionWipe; // size = 0x218 + +#define TRANS_INSTANCE_TYPE_FADE_FLASH 3 + +typedef struct { + /* 0x000 */ u8 type; + /* 0x001 */ u8 isDone; + /* 0x002 */ u8 direction; + /* 0x004 */ Color_RGBA8_u32 color; + /* 0x008 */ u16 timer; +} TransitionFade; // size = 0xC + +typedef enum { + /* 0 */ TCA_NORMAL, + /* 1 */ TCA_WAVE, + /* 2 */ TCA_RIPPLE, + /* 3 */ TCA_STARBURST +} TransitionCircleAppearance; + +typedef enum { + /* 0 */ TCC_BLACK, + /* 1 */ TCC_WHITE, + /* 2 */ TCC_GRAY, + /* 3 */ TCC_SPECIAL // color varies depending on appearance. unused and appears broken +} TransitionCircleColor; + +typedef enum { + /* 0 */ TCS_FAST, + /* 1 */ TCS_SLOW +} TransitionCircleSpeed; + +typedef struct { + /* 0x000 */ Color_RGBA8_u32 color; + /* 0x004 */ Color_RGBA8_u32 unkColor; + /* 0x008 */ s32 texX; + /* 0x00C */ s32 texY; + /* 0x010 */ s32 speed; + /* 0x014 */ u8 direction; + /* 0x015 */ u8 colorType; + /* 0x016 */ u8 speedType; + /* 0x017 */ u8 appearanceType; + /* 0x018 */ u8 isDone; + /* 0x019 */ u8 frame; + /* 0x01A */ u16 normal; + /* 0x020 */ Mtx projection; + /* 0x060 */ Mtx lookAt; + /* 0x0A0 */ void* texture; + /* 0x0A8 */ Mtx modelView[2][3]; +} TransitionCircle; // size = 0x228; + +typedef struct { + /* 0x000 */ Color_RGBA8_u32 color; + /* 0x004 */ f32 transPos; + /* 0x008 */ f32 step; + /* 0x00C */ s32 state; + /* 0x010 */ s32 type; + /* 0x018 */ Mtx projection; + /* 0x058 */ s32 frame; + /* 0x060 */ Mtx modelView[2][3]; +} TransitionTriforce; // size = 0x1E0; + +#endif diff --git a/src/code/flg_set.c b/src/code/flg_set.c index 5a4ab25fe3..04167c2ec8 100644 --- a/src/code/flg_set.c +++ b/src/code/flg_set.c @@ -1,5 +1,10 @@ #include "global.h" +typedef struct { + /* 0x00 */ u16* value; + /* 0x04 */ const char* name; +} FlagSetEntry; // size = 0x08 + void FlagSet_Update(PlayState* play) { static s32 entryIdx = 0; static u32 curBit = 0; diff --git a/src/code/speed_meter.c b/src/code/speed_meter.c index 5d38d65bf2..dc1bc0596d 100644 --- a/src/code/speed_meter.c +++ b/src/code/speed_meter.c @@ -56,6 +56,13 @@ volatile OSTime D_8016A578; // Accumulator for `gRDPTimeTotal` volatile OSTime gRDPTimeAcc; +typedef struct { + /* 0x00 */ volatile OSTime* time; + /* 0x04 */ u8 x; + /* 0x05 */ u8 y; + /* 0x06 */ u16 color; +} SpeedMeterTimeEntry; // size = 0x08 + SpeedMeterTimeEntry* sSpeedMeterTimeEntryPtr; SpeedMeterTimeEntry sSpeedMeterTimeEntryArray[] = { diff --git a/src/code/ucode_disas.c b/src/code/ucode_disas.c index bd3e8662a9..10bffd767e 100644 --- a/src/code/ucode_disas.c +++ b/src/code/ucode_disas.c @@ -1,5 +1,34 @@ #include "global.h" +typedef struct { + /* 0x00 */ u32 value; + /* 0x04 */ const char* name; +} F3dzexConst; // size = 0x8 + +typedef struct { + /* 0x00 */ u32 value; + /* 0x04 */ const char* setName; + /* 0x08 */ const char* unsetName; +} F3dzexFlag; // size = 0x0C + +typedef struct { + /* 0x00 */ const char* name; + /* 0x04 */ u32 value; + /* 0x08 */ u32 mask; +} F3dzexRenderMode; // size = 0x0C + +typedef struct { + /* 0x00 */ const char* name; + /* 0x04 */ u32 value; +} F3dzexSetModeMacroValue; // size = 0x8 + +typedef struct { + /* 0x00 */ const char* name; + /* 0x04 */ u32 shift; + /* 0x08 */ u32 len; + /* 0x0C */ F3dzexSetModeMacroValue values[4]; +} F3dzexSetModeMacro; // size = 0x2C + typedef void (*UcodeDisasCallback)(UCodeDisas*, u32); #define F3DZEX_CONST(name) \ diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index 833bea98a4..814b2e34ba 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -41,12 +41,6 @@ void BgCheck_ResetPolyCheckTbl(SSNodeList* nodeList, s32 numPolys); #define BGCHECK_IGNORE_WALL (1 << 1) #define BGCHECK_IGNORE_FLOOR (1 << 2) -// poly exclusion flags (xpFlags) -#define COLPOLY_IGNORE_NONE 0 -#define COLPOLY_IGNORE_CAMERA (1 << 0) -#define COLPOLY_IGNORE_ENTITY (1 << 1) -#define COLPOLY_IGNORE_PROJECTILES (1 << 2) - // raycast down flags (downChkFlags) #define BGCHECK_RAYCAST_DOWN_CHECK_CEILINGS (1 << 0) #define BGCHECK_RAYCAST_DOWN_CHECK_WALLS (1 << 1) @@ -579,7 +573,7 @@ f32 BgCheck_RaycastDownStaticList(CollisionContext* colCtx, u16 xpFlags, SSList* while (true) { polyId = curNode->polyId; - if (COLPOLY_VIA_FLAG_TEST(colCtx->colHeader->polyList[polyId].flags_vIA, xpFlags) || + if (COLPOLY_VTX_CHECK_FLAGS_ANY(colCtx->colHeader->polyList[polyId].flags_vIA, xpFlags) || ((groundChk & BGCHECK_GROUND_CHECK_ON) && colCtx->colHeader->polyList[polyId].normal.y < 0)) { if (curNode->next == SS_NULL) { break; @@ -735,7 +729,7 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 nz = COLPOLY_GET_NORMAL(curPoly->normal.z); normalXZ = sqrtf(SQ(nx) + SQ(nz)); planeDist = Math3D_DistPlaneToPos(nx, ny, nz, curPoly->dist, &resultPos); - if (radius < fabsf(planeDist) || COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIA, xpFlags)) { + if (radius < fabsf(planeDist) || COLPOLY_VTX_CHECK_FLAGS_ANY(curPoly->flags_vIA, xpFlags)) { if (curNode->next == SS_NULL) { break; } else { @@ -816,7 +810,7 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 nz = COLPOLY_GET_NORMAL(curPoly->normal.z); normalXZ = sqrtf(SQ(nx) + SQ(nz)); planeDist = Math3D_DistPlaneToPos(nx, ny, nz, curPoly->dist, &resultPos); - if (radius < fabsf(planeDist) || COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIA, xpFlags)) { + if (radius < fabsf(planeDist) || COLPOLY_VTX_CHECK_FLAGS_ANY(curPoly->flags_vIA, xpFlags)) { if (curNode->next == SS_NULL) { break; } else { @@ -916,7 +910,7 @@ s32 BgCheck_CheckStaticCeiling(StaticLookup* lookup, u16 xpFlags, CollisionConte while (true) { curPolyId = curNode->polyId; - if (COLPOLY_VIA_FLAG_TEST(colCtx->colHeader->polyList[curPolyId].flags_vIA, xpFlags)) { + if (COLPOLY_VTX_CHECK_FLAGS_ANY(colCtx->colHeader->polyList[curPolyId].flags_vIA, xpFlags)) { if (curNode->next == SS_NULL) { break; } else { @@ -977,8 +971,8 @@ s32 BgCheck_CheckLineAgainstSSList(SSList* ssList, CollisionContext* colCtx, u16 polyId = curNode->polyId; checkedPoly = &colCtx->polyNodes.polyCheckTbl[polyId]; - if (*checkedPoly == true || COLPOLY_VIA_FLAG_TEST(polyList[polyId].flags_vIA, xpFlags1) || - !(xpFlags2 == 0 || COLPOLY_VIA_FLAG_TEST(polyList[polyId].flags_vIA, xpFlags2))) { + if (*checkedPoly == true || COLPOLY_VTX_CHECK_FLAGS_ANY(polyList[polyId].flags_vIA, xpFlags1) || + !(xpFlags2 == 0 || COLPOLY_VTX_CHECK_FLAGS_ANY(polyList[polyId].flags_vIA, xpFlags2))) { if (curNode->next == SS_NULL) { break; @@ -1064,7 +1058,7 @@ s32 BgCheck_SphVsFirstStaticPolyList(SSNode* node, u16 xpFlags, CollisionContext while (true) { curPolyId = node->polyId; curPoly = &polyList[curPolyId]; - if (COLPOLY_VIA_FLAG_TEST(colCtx->colHeader->polyList[curPolyId].flags_vIA, xpFlags)) { + if (COLPOLY_VTX_CHECK_FLAGS_ANY(colCtx->colHeader->polyList[curPolyId].flags_vIA, xpFlags)) { if (node->next == SS_NULL) { break; } else { @@ -2964,10 +2958,10 @@ void DynaPoly_AddBgActorToLookup(PlayState* play, DynaCollisionContext* dyna, s3 *newPoly = pbgdata->polyList[i]; // Yeah, this is all kinds of fake, but my God, it matches. - newPoly->flags_vIA = - (COLPOLY_VTX_INDEX(newPoly->flags_vIA) + *vtxStartIndex) | ((*newPoly).flags_vIA & 0xE000); - newPoly->flags_vIB = - (COLPOLY_VTX_INDEX(newPoly->flags_vIB) + *vtxStartIndex) | ((*newPoly).flags_vIB & 0xE000); + newPoly->flags_vIA = (COLPOLY_VTX_INDEX(newPoly->flags_vIA) + *vtxStartIndex) | + COLPOLY_VTX_FLAGS_MASKED((*newPoly).flags_vIA); + newPoly->flags_vIB = (COLPOLY_VTX_INDEX(newPoly->flags_vIB) + *vtxStartIndex) | + COLPOLY_VTX_FLAGS_MASKED((*newPoly).flags_vIB); newPoly->vIC = *vtxStartIndex + newPoly->vIC; dVtxList = dyna->vtxList; vtxA.x = dVtxList[(u32)COLPOLY_VTX_INDEX(newPoly->flags_vIA)].x; @@ -3116,7 +3110,7 @@ f32 BgCheck_RaycastDownDynaList(DynaRaycastDown* dynaRaycastDown, u32 listType) while (true) { id = curNode->polyId; - if (COLPOLY_VIA_FLAG_TEST(polyList[id].flags_vIA, dynaRaycastDown->xpFlags)) { + if (COLPOLY_VTX_CHECK_FLAGS_ANY(polyList[id].flags_vIA, dynaRaycastDown->xpFlags)) { if (curNode->next == SS_NULL) { break; } else { @@ -3319,7 +3313,7 @@ s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCo ASSERT(!IS_ZERO(normalXZ), "!IS_ZERO(ac_size)", "../z_bgcheck.c", 7382); planeDist = Math3D_DistPlaneToPos(nx, ny, nz, poly->dist, &resultPos); - if (radius < fabsf(planeDist) || COLPOLY_VIA_FLAG_TEST(poly->flags_vIA, xpFlags)) { + if (radius < fabsf(planeDist) || COLPOLY_VTX_CHECK_FLAGS_ANY(poly->flags_vIA, xpFlags)) { if (curNode->next == SS_NULL) { break; } else { @@ -3392,7 +3386,7 @@ s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCo ASSERT(!IS_ZERO(normalXZ), "!IS_ZERO(ac_size)", "../z_bgcheck.c", 7489); planeDist = Math3D_DistPlaneToPos(nx, ny, nz, poly->dist, &resultPos); - if (radius < fabsf(planeDist) || COLPOLY_VIA_FLAG_TEST(poly->flags_vIA, xpFlags)) { + if (radius < fabsf(planeDist) || COLPOLY_VTX_CHECK_FLAGS_ANY(poly->flags_vIA, xpFlags)) { if (curNode->next == SS_NULL) { break; } else { @@ -3548,7 +3542,7 @@ s32 BgCheck_CheckDynaCeilingList(CollisionContext* colCtx, u16 xpFlags, DynaColl while (true) { polyId = curNode->polyId; poly = &dyna->polyList[polyId]; - if (COLPOLY_VIA_FLAG_TEST(poly->flags_vIA, xpFlags)) { + if (COLPOLY_VTX_CHECK_FLAGS_ANY(poly->flags_vIA, xpFlags)) { if (curNode->next == SS_NULL) { break; } else { @@ -3648,7 +3642,7 @@ s32 BgCheck_CheckLineAgainstBgActorSSList(DynaLineTest* dynaLineTest) { while (true) { polyId = curNode->polyId; curPoly = &dynaLineTest->dyna->polyList[polyId]; - if (COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIA, dynaLineTest->xpFlags)) { + if (COLPOLY_VTX_CHECK_FLAGS_ANY(curPoly->flags_vIA, dynaLineTest->xpFlags)) { if (curNode->next == SS_NULL) { break; } else { @@ -3781,7 +3775,7 @@ s32 BgCheck_SphVsFirstDynaPolyList(CollisionContext* colCtx, u16 xpFlags, Collis while (true) { curPolyId = curNode->polyId; curPoly = &dyna->polyList[curPolyId]; - if (COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIA, xpFlags)) { + if (COLPOLY_VTX_CHECK_FLAGS_ANY(curPoly->flags_vIA, xpFlags)) { if (curNode->next == SS_NULL) { break; } else { @@ -4155,7 +4149,7 @@ s32 SurfaceType_IsIgnoredByEntities(CollisionContext* colCtx, CollisionPoly* pol if (BgCheck_GetCollisionHeader(colCtx, bgId) == NULL) { return true; } - flags = poly->flags_vIA & 0x4000; + flags = COLPOLY_VTX_CHECK_FLAGS_ANY(poly->flags_vIA, COLPOLY_IGNORE_ENTITY); return !!flags; } @@ -4169,7 +4163,7 @@ s32 SurfaceType_IsIgnoredByProjectiles(CollisionContext* colCtx, CollisionPoly* if (BgCheck_GetCollisionHeader(colCtx, bgId) == NULL) { return true; } - flags = poly->flags_vIA & 0x8000; + flags = COLPOLY_VTX_CHECK_FLAGS_ANY(poly->flags_vIA, COLPOLY_IGNORE_PROJECTILES); return !!flags; } @@ -4188,7 +4182,7 @@ s32 SurfaceType_IsFloorConveyor(CollisionContext* colCtx, CollisionPoly* poly, s if (BgCheck_GetCollisionHeader(colCtx, bgId) == NULL) { return true; } - flags = poly->flags_vIB & 0x2000; + flags = COLPOLY_VTX_CHECK_FLAGS_ANY(poly->flags_vIB, COLPOLY_IS_FLOOR_CONVEYOR); return !!flags; } @@ -4318,7 +4312,7 @@ s32 WaterBox_GetSurface2(PlayState* play, CollisionContext* colCtx, Vec3f* pos, * WaterBox get BgCam index */ u32 WaterBox_GetBgCamIndex(CollisionContext* colCtx, WaterBox* waterBox) { - u32 bgCamIndex = WATERBOX_BGCAM_INDEX(waterBox->properties); + u32 bgCamIndex = waterBox->properties & 0xFF; return bgCamIndex; } @@ -4341,7 +4335,7 @@ u16 WaterBox_GetBgCamSetting(CollisionContext* colCtx, WaterBox* waterBox) { * WaterBox get lighting settings */ u32 WaterBox_GetLightIndex(CollisionContext* colCtx, WaterBox* waterBox) { - u32 lightIndex = WATERBOX_LIGHT_INDEX(waterBox->properties); + u32 lightIndex = (waterBox->properties >> 8) & 0x1F; return lightIndex; } diff --git a/src/code/z_eff_blure.c b/src/code/z_eff_blure.c index 242dac94d7..75f8d80bc0 100644 --- a/src/code/z_eff_blure.c +++ b/src/code/z_eff_blure.c @@ -295,9 +295,9 @@ void EffectBlure_GetComputedValues(EffectBlure* this, s32 index, f32 ratio, Vec3 switch (this->calcMode) { case 1: - vec1->x = func_80027E34(elem->p1.x, elem->p2.x, ratio); - vec1->y = func_80027E34(elem->p1.y, elem->p2.y, ratio); - vec1->z = func_80027E34(elem->p1.z, elem->p2.z, ratio); + vec1->x = EffectSs_LerpS16(elem->p1.x, elem->p2.x, ratio); + vec1->y = EffectSs_LerpS16(elem->p1.y, elem->p2.y, ratio); + vec1->z = EffectSs_LerpS16(elem->p1.z, elem->p2.z, ratio); vec2->x = elem->p2.x; vec2->y = elem->p2.y; vec2->z = elem->p2.z; @@ -307,19 +307,19 @@ void EffectBlure_GetComputedValues(EffectBlure* this, s32 index, f32 ratio, Vec3 vec1->x = elem->p1.x; vec1->y = elem->p1.y; vec1->z = elem->p1.z; - vec2->x = func_80027E34(elem->p2.x, elem->p1.x, ratio); - vec2->y = func_80027E34(elem->p2.y, elem->p1.y, ratio); - vec2->z = func_80027E34(elem->p2.z, elem->p1.z, ratio); + vec2->x = EffectSs_LerpS16(elem->p2.x, elem->p1.x, ratio); + vec2->y = EffectSs_LerpS16(elem->p2.y, elem->p1.y, ratio); + vec2->z = EffectSs_LerpS16(elem->p2.z, elem->p1.z, ratio); break; case 3: ratio *= 0.5f; - vec1->x = func_80027E34(elem->p1.x, elem->p2.x, ratio); - vec1->y = func_80027E34(elem->p1.y, elem->p2.y, ratio); - vec1->z = func_80027E34(elem->p1.z, elem->p2.z, ratio); - vec2->x = func_80027E34(elem->p2.x, elem->p1.x, ratio); - vec2->y = func_80027E34(elem->p2.y, elem->p1.y, ratio); - vec2->z = func_80027E34(elem->p2.z, elem->p1.z, ratio); + vec1->x = EffectSs_LerpS16(elem->p1.x, elem->p2.x, ratio); + vec1->y = EffectSs_LerpS16(elem->p1.y, elem->p2.y, ratio); + vec1->z = EffectSs_LerpS16(elem->p1.z, elem->p2.z, ratio); + vec2->x = EffectSs_LerpS16(elem->p2.x, elem->p1.x, ratio); + vec2->y = EffectSs_LerpS16(elem->p2.y, elem->p1.y, ratio); + vec2->z = EffectSs_LerpS16(elem->p2.z, elem->p1.z, ratio); ratio *= 2.0f; break; @@ -356,14 +356,14 @@ void EffectBlure_GetComputedValues(EffectBlure* this, s32 index, f32 ratio, Vec3 color1->r = color1->g = color1->b = color1->a = 255; color2->r = color2->g = color2->b = color2->a = 255; } else { - color1->r = func_80027E84(this->p1StartColor[0], this->p1EndColor[0], ratio); - color1->g = func_80027E84(this->p1StartColor[1], this->p1EndColor[1], ratio); - color1->b = func_80027E84(this->p1StartColor[2], this->p1EndColor[2], ratio); - color1->a = func_80027E84(this->p1StartColor[3], this->p1EndColor[3], ratio); - color2->r = func_80027E84(this->p2StartColor[0], this->p2EndColor[0], ratio); - color2->g = func_80027E84(this->p2StartColor[1], this->p2EndColor[1], ratio); - color2->b = func_80027E84(this->p2StartColor[2], this->p2EndColor[2], ratio); - color2->a = func_80027E84(this->p2StartColor[3], this->p2EndColor[3], ratio); + color1->r = EffectSs_LerpU8(this->p1StartColor[0], this->p1EndColor[0], ratio); + color1->g = EffectSs_LerpU8(this->p1StartColor[1], this->p1EndColor[1], ratio); + color1->b = EffectSs_LerpU8(this->p1StartColor[2], this->p1EndColor[2], ratio); + color1->a = EffectSs_LerpU8(this->p1StartColor[3], this->p1EndColor[3], ratio); + color2->r = EffectSs_LerpU8(this->p2StartColor[0], this->p2EndColor[0], ratio); + color2->g = EffectSs_LerpU8(this->p2StartColor[1], this->p2EndColor[1], ratio); + color2->b = EffectSs_LerpU8(this->p2StartColor[2], this->p2EndColor[2], ratio); + color2->a = EffectSs_LerpU8(this->p2StartColor[3], this->p2EndColor[3], ratio); } } @@ -618,18 +618,18 @@ void EffectBlure_DrawElemHermiteInterpolation(EffectBlure* this, EffectBlureElem vtx[j1].v.ob[0] = Math_FNearbyIntF(sp158.x); vtx[j1].v.ob[1] = Math_FNearbyIntF(sp158.y); vtx[j1].v.ob[2] = Math_FNearbyIntF(sp158.z); - vtx[j1].v.cn[0] = func_80027E84(sp1A4.r, sp19C.r, temp_f28); - vtx[j1].v.cn[1] = func_80027E84(sp1A4.g, sp19C.g, temp_f28); - vtx[j1].v.cn[2] = func_80027E84(sp1A4.b, sp19C.b, temp_f28); - vtx[j1].v.cn[3] = func_80027E84(sp1A4.a, sp19C.a, temp_f28); + vtx[j1].v.cn[0] = EffectSs_LerpU8(sp1A4.r, sp19C.r, temp_f28); + vtx[j1].v.cn[1] = EffectSs_LerpU8(sp1A4.g, sp19C.g, temp_f28); + vtx[j1].v.cn[2] = EffectSs_LerpU8(sp1A4.b, sp19C.b, temp_f28); + vtx[j1].v.cn[3] = EffectSs_LerpU8(sp1A4.a, sp19C.a, temp_f28); vtx[j2].v.ob[0] = Math_FNearbyIntF(sp14C.x); vtx[j2].v.ob[1] = Math_FNearbyIntF(sp14C.y); vtx[j2].v.ob[2] = Math_FNearbyIntF(sp14C.z); - vtx[j2].v.cn[0] = func_80027E84(sp1A0.r, sp198.r, temp_f28); - vtx[j2].v.cn[1] = func_80027E84(sp1A0.g, sp198.g, temp_f28); - vtx[j2].v.cn[2] = func_80027E84(sp1A0.b, sp198.b, temp_f28); - vtx[j2].v.cn[3] = func_80027E84(sp1A0.a, sp198.a, temp_f28); + vtx[j2].v.cn[0] = EffectSs_LerpU8(sp1A0.r, sp198.r, temp_f28); + vtx[j2].v.cn[1] = EffectSs_LerpU8(sp1A0.g, sp198.g, temp_f28); + vtx[j2].v.cn[2] = EffectSs_LerpU8(sp1A0.b, sp198.b, temp_f28); + vtx[j2].v.cn[3] = EffectSs_LerpU8(sp1A0.a, sp198.a, temp_f28); } gSPVertex(POLY_XLU_DISP++, vtx, 16, 0); @@ -957,9 +957,9 @@ void EffectBlure_Draw(void* thisx, GraphicsContext* gfxCtx) { switch (this->calcMode) { case 1: - vtx[j].v.ob[0] = func_80027E34(elem->p1.x, elem->p2.x, ratio); - vtx[j].v.ob[1] = func_80027E34(elem->p1.y, elem->p2.y, ratio); - vtx[j].v.ob[2] = func_80027E34(elem->p1.z, elem->p2.z, ratio); + vtx[j].v.ob[0] = EffectSs_LerpS16(elem->p1.x, elem->p2.x, ratio); + vtx[j].v.ob[1] = EffectSs_LerpS16(elem->p1.y, elem->p2.y, ratio); + vtx[j].v.ob[2] = EffectSs_LerpS16(elem->p1.z, elem->p2.z, ratio); vtx[j + 1].v.ob[0] = elem->p2.x; vtx[j + 1].v.ob[1] = elem->p2.y; vtx[j + 1].v.ob[2] = elem->p2.z; @@ -968,18 +968,18 @@ void EffectBlure_Draw(void* thisx, GraphicsContext* gfxCtx) { vtx[j].v.ob[0] = elem->p1.x; vtx[j].v.ob[1] = elem->p1.y; vtx[j].v.ob[2] = elem->p1.z; - vtx[j + 1].v.ob[0] = func_80027E34(elem->p2.x, elem->p1.x, ratio); - vtx[j + 1].v.ob[1] = func_80027E34(elem->p2.y, elem->p1.y, ratio); - vtx[j + 1].v.ob[2] = func_80027E34(elem->p2.z, elem->p1.z, ratio); + vtx[j + 1].v.ob[0] = EffectSs_LerpS16(elem->p2.x, elem->p1.x, ratio); + vtx[j + 1].v.ob[1] = EffectSs_LerpS16(elem->p2.y, elem->p1.y, ratio); + vtx[j + 1].v.ob[2] = EffectSs_LerpS16(elem->p2.z, elem->p1.z, ratio); break; case 3: ratio = ratio * 0.5f; - vtx[j].v.ob[0] = func_80027E34(elem->p1.x, elem->p2.x, ratio); - vtx[j].v.ob[1] = func_80027E34(elem->p1.y, elem->p2.y, ratio); - vtx[j].v.ob[2] = func_80027E34(elem->p1.z, elem->p2.z, ratio); - vtx[j + 1].v.ob[0] = func_80027E34(elem->p2.x, elem->p1.x, ratio); - vtx[j + 1].v.ob[1] = func_80027E34(elem->p2.y, elem->p1.y, ratio); - vtx[j + 1].v.ob[2] = func_80027E34(elem->p2.z, elem->p1.z, ratio); + vtx[j].v.ob[0] = EffectSs_LerpS16(elem->p1.x, elem->p2.x, ratio); + vtx[j].v.ob[1] = EffectSs_LerpS16(elem->p1.y, elem->p2.y, ratio); + vtx[j].v.ob[2] = EffectSs_LerpS16(elem->p1.z, elem->p2.z, ratio); + vtx[j + 1].v.ob[0] = EffectSs_LerpS16(elem->p2.x, elem->p1.x, ratio); + vtx[j + 1].v.ob[1] = EffectSs_LerpS16(elem->p2.y, elem->p1.y, ratio); + vtx[j + 1].v.ob[2] = EffectSs_LerpS16(elem->p2.z, elem->p1.z, ratio); ratio = ratio + ratio; break; case 0: @@ -996,19 +996,19 @@ void EffectBlure_Draw(void* thisx, GraphicsContext* gfxCtx) { vtx[j].v.flag = 0; vtx[j].v.tc[0] = 0; vtx[j].v.tc[1] = 0; - vtx[j].v.cn[0] = func_80027E84(this->p1StartColor[0], this->p1EndColor[0], ratio); - vtx[j].v.cn[1] = func_80027E84(this->p1StartColor[1], this->p1EndColor[1], ratio); - vtx[j].v.cn[2] = func_80027E84(this->p1StartColor[2], this->p1EndColor[2], ratio); - vtx[j].v.cn[3] = func_80027E84(this->p1StartColor[3], this->p1EndColor[3], ratio); + vtx[j].v.cn[0] = EffectSs_LerpU8(this->p1StartColor[0], this->p1EndColor[0], ratio); + vtx[j].v.cn[1] = EffectSs_LerpU8(this->p1StartColor[1], this->p1EndColor[1], ratio); + vtx[j].v.cn[2] = EffectSs_LerpU8(this->p1StartColor[2], this->p1EndColor[2], ratio); + vtx[j].v.cn[3] = EffectSs_LerpU8(this->p1StartColor[3], this->p1EndColor[3], ratio); j++; vtx[j].v.flag = 0; vtx[j].v.tc[0] = 0; vtx[j].v.tc[1] = 0; - vtx[j].v.cn[0] = func_80027E84(this->p2StartColor[0], this->p2EndColor[0], ratio); - vtx[j].v.cn[1] = func_80027E84(this->p2StartColor[1], this->p2EndColor[1], ratio); - vtx[j].v.cn[2] = func_80027E84(this->p2StartColor[2], this->p2EndColor[2], ratio); - vtx[j].v.cn[3] = func_80027E84(this->p2StartColor[3], this->p2EndColor[3], ratio); + vtx[j].v.cn[0] = EffectSs_LerpU8(this->p2StartColor[0], this->p2EndColor[0], ratio); + vtx[j].v.cn[1] = EffectSs_LerpU8(this->p2StartColor[1], this->p2EndColor[1], ratio); + vtx[j].v.cn[2] = EffectSs_LerpU8(this->p2StartColor[2], this->p2EndColor[2], ratio); + vtx[j].v.cn[3] = EffectSs_LerpU8(this->p2StartColor[3], this->p2EndColor[3], ratio); j++; } } diff --git a/src/code/z_effect_soft_sprite.c b/src/code/z_effect_soft_sprite.c index 55a1245a3f..6fb6e05d38 100644 --- a/src/code/z_effect_soft_sprite.c +++ b/src/code/z_effect_soft_sprite.c @@ -324,16 +324,25 @@ void EffectSs_DrawAll(PlayState* play) { } } -s16 func_80027DD4(s16 arg0, s16 arg1, s32 arg2) { - s16 ret = (arg2 == 0) ? arg1 : (arg0 + (s32)((arg1 - arg0) / (f32)arg2)); +/** + * Lerp from `a` (weightInv == inf) to `b` (weightInv == 1 or 0). + */ +s16 EffectSs_LerpInv(s16 a, s16 b, s32 weightInv) { + s16 ret = (weightInv == 0) ? b : (a + (s32)((b - a) / (f32)weightInv)); return ret; } -s16 func_80027E34(s16 arg0, s16 arg1, f32 arg2) { - return (arg1 - arg0) * arg2 + arg0; +/** + * Lerp from `a` (weight == 0) to `b` (weight == 1). + */ +s16 EffectSs_LerpS16(s16 a, s16 b, f32 weight) { + return (b - a) * weight + a; } -u8 func_80027E84(u8 arg0, u8 arg1, f32 arg2) { - return arg2 * ((f32)arg1 - (f32)arg0) + arg0; +/** + * Lerp from `a` (weight == 0) to `b` (weight == 1). + */ +u8 EffectSs_LerpU8(u8 a, u8 b, f32 weight) { + return weight * ((f32)b - (f32)a) + a; } diff --git a/src/code/z_effect_soft_sprite_old_init.c b/src/code/z_effect_soft_sprite_old_init.c index 5c6b957110..f2d7d0a541 100644 --- a/src/code/z_effect_soft_sprite_old_init.c +++ b/src/code/z_effect_soft_sprite_old_init.c @@ -46,7 +46,7 @@ void EffectSs_DrawGEffect(PlayState* play, EffectSs* this, void* texture) { MtxF mfTrans; MtxF mfScale; MtxF mfResult; - MtxF mfTrans11DA0; + MtxF mfTransBillboard; s32 pad1; Mtx* mtx; void* object = play->objectCtx.status[this->rgObjBankIdx].segment; @@ -56,8 +56,8 @@ void EffectSs_DrawGEffect(PlayState* play, EffectSs* this, void* texture) { scale = this->rgScale * 0.0025f; SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); SkinMatrix_SetScale(&mfScale, scale, scale, scale); - SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTrans11DA0); - SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfScale, &mfResult); + SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTransBillboard); + SkinMatrix_MtxFMtxFMult(&mfTransBillboard, &mfScale, &mfResult); gSegments[6] = VIRTUAL_TO_PHYSICAL(object); gSPSegment(POLY_XLU_DISP++, 0x06, object); @@ -316,15 +316,26 @@ void EffectSsBomb2_SpawnLayered(PlayState* play, Vec3f* pos, Vec3f* velocity, Ve // EffectSsBlast Spawn Functions -void EffectSsBlast_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, - Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 scaleStepDecay, s16 life) { +/** + * Spawn a ring-shaped shockwave effect. + * + * @param pos Position from which to find collision to draw the shockwave along. + * @param innerColor Color on the inside of the ring. Alpha is effect's alpha. + * @param outerColor Color on the outside of the ring. + * @param scale How large the shockwave is initially. The shockwave will be `scale*64/400` units wide. + * @param scaleStep How much to increase `scale` by each frame. + * @param scaleStepDecay How much to decrease `scaleStep` by each frame + * (should be a divisor of `scaleStep`, or small enough that `scaleStep` won't go negative). + */ +void EffectSsBlast_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* innerColor, + Color_RGBA8* outerColor, s16 scale, s16 scaleStep, s16 scaleStepDecay, s16 life) { EffectSsBlastParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); Math_Vec3f_Copy(&initParams.velocity, velocity); Math_Vec3f_Copy(&initParams.accel, accel); - Color_RGBA8_Copy(&initParams.primColor, primColor); - Color_RGBA8_Copy(&initParams.envColor, envColor); + Color_RGBA8_Copy(&initParams.innerColor, innerColor); + Color_RGBA8_Copy(&initParams.outerColor, outerColor); initParams.scale = scale; initParams.scaleStep = scaleStep; initParams.scaleStepDecay = scaleStepDecay; @@ -333,24 +344,39 @@ void EffectSsBlast_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* ac EffectSs_Spawn(play, EFFECT_SS_BLAST, 128, &initParams); } -void EffectSsBlast_SpawnWhiteCustomScale(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, - s16 scaleStep, s16 life) { - static Color_RGBA8 primColor = { 255, 255, 255, 255 }; - static Color_RGBA8 envColor = { 200, 200, 200, 0 }; +/** + * Spawn a white shockwave effect. + * + * @see EffectSsBlast_Spawn + */ +void EffectSsBlast_SpawnWhiteShockwaveSetScale(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, + s16 scaleStep, s16 life) { + static Color_RGBA8 innerColor = { 255, 255, 255, 255 }; + static Color_RGBA8 outerColor = { 200, 200, 200, 0 }; - EffectSsBlast_Spawn(play, pos, velocity, accel, &primColor, &envColor, scale, scaleStep, 35, life); + EffectSsBlast_Spawn(play, pos, velocity, accel, &innerColor, &outerColor, scale, scaleStep, 35, life); } -void EffectSsBlast_SpawnShockwave(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, - Color_RGBA8* envColor, s16 life) { - EffectSsBlast_Spawn(play, pos, velocity, accel, primColor, envColor, 100, 375, 35, life); +/** + * Spawn a shockwave effect, quickly expanding. + * + * @see EffectSsBlast_Spawn + */ +void EffectSsBlast_SpawnShockwaveSetColor(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, + Color_RGBA8* innerColor, Color_RGBA8* outerColor, s16 life) { + EffectSsBlast_Spawn(play, pos, velocity, accel, innerColor, outerColor, 100, 375, 35, life); } +/** + * Spawn a white shockwave effect, quickly expanding, for 10 frames. + * + * @see EffectSsBlast_Spawn + */ void EffectSsBlast_SpawnWhiteShockwave(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { - static Color_RGBA8 primColor = { 255, 255, 255, 255 }; - static Color_RGBA8 envColor = { 200, 200, 200, 0 }; + static Color_RGBA8 innerColor = { 255, 255, 255, 255 }; + static Color_RGBA8 outerColor = { 200, 200, 200, 0 }; - EffectSsBlast_SpawnShockwave(play, pos, velocity, accel, &primColor, &envColor, 10); + EffectSsBlast_SpawnShockwaveSetColor(play, pos, velocity, accel, &innerColor, &outerColor, 10); } // EffectSsGSpk Spawn Functions @@ -745,12 +771,12 @@ void EffectSsFhgFlash_SpawnLightBall(PlayState* play, Vec3f* pos, Vec3f* velocit } /** - * Spawn a shock effect + * Spawn a purple shock effect (a ball of electrical arcs). * - * param determines where the ligntning should go - * 0: don't attach to any actor. spawns at the position specified by pos - * 1: spawn at one of Player's body parts, chosen at random - * 2: spawn at one of Phantom Ganon's body parts, chosen at random + * @param actor If param is `FHGFLASH_SHOCK_PG`, the Phantom Ganon actor. Unused otherwise. + * @param pos If param is `FHGFLASH_SHOCK_NO_ACTOR`, the position of the effect. Unused otherwise. + * @param scale The effect will be around `scale*20/100` units wide (randomized). + * @param param Determines what the effect attaches to. See `FhgFlashLightningParam`. */ void EffectSsFhgFlash_SpawnShock(PlayState* play, Actor* actor, Vec3f* pos, s16 scale, u8 param) { EffectSsFhgFlashInitParams initParams; diff --git a/src/code/z_message_PAL.c b/src/code/z_message_PAL.c index 415dbb853a..0cc56c129f 100644 --- a/src/code/z_message_PAL.c +++ b/src/code/z_message_PAL.c @@ -2486,7 +2486,7 @@ void Message_DrawMain(PlayState* play, Gfx** p) { } else { Message_CloseTextbox(play); if (msgCtx->lastPlayedSong == OCARINA_SONG_EPONAS) { - DREG(53) = 1; + R_EPONAS_SONG_PLAYED = true; } osSyncPrintf(VT_FGCOL(YELLOW)); osSyncPrintf("☆☆☆ocarina=%d message->ocarina_no=%d ", msgCtx->lastPlayedSong, diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index ea04f2877f..5c85a4c32c 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -1064,12 +1064,12 @@ s32 Player_OverrideLimbDrawGameplayCommon(PlayState* play, s32 limbIndex, Gfx** sCurBodyPartPos = &this->bodyPartsPos[-1]; if (!LINK_IS_ADULT) { - if (!(this->skelAnime.moveFlags & 4) || (this->skelAnime.moveFlags & 1)) { + if (!(this->skelAnime.moveFlags & ANIM_FLAG_PLAYER_2) || (this->skelAnime.moveFlags & ANIM_FLAG_0)) { pos->x *= 0.64f; pos->z *= 0.64f; } - if (!(this->skelAnime.moveFlags & 4) || (this->skelAnime.moveFlags & 2)) { + if (!(this->skelAnime.moveFlags & ANIM_FLAG_PLAYER_2) || (this->skelAnime.moveFlags & ANIM_FLAG_UPDATE_Y)) { pos->y *= 0.64f; } } diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index bc8a9f392e..0efb58769d 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -914,13 +914,13 @@ void AnimationContext_SetCopyFalse(PlayState* play, s32 vecCount, Vec3s* dst, Ve /** * Requests moving an actor according to the translation of its root limb */ -void AnimationContext_SetMoveActor(PlayState* play, Actor* actor, SkelAnime* skelAnime, f32 arg3) { +void AnimationContext_SetMoveActor(PlayState* play, Actor* actor, SkelAnime* skelAnime, f32 moveDiffScaleY) { AnimationEntry* entry = AnimationContext_AddEntry(&play->animationCtx, ANIMENTRY_MOVEACTOR); if (entry != NULL) { entry->data.move.actor = actor; entry->data.move.skelAnime = skelAnime; - entry->data.move.unk_08 = arg3; + entry->data.move.diffScaleY = moveDiffScaleY; } } @@ -1011,7 +1011,7 @@ void AnimationContext_MoveActor(PlayState* play, AnimationEntryData* data) { SkelAnime_UpdateTranslation(entry->skelAnime, &diff, actor->shape.rot.y); actor->world.pos.x += diff.x * actor->scale.x; - actor->world.pos.y += diff.y * actor->scale.y * entry->unk_08; + actor->world.pos.y += diff.y * actor->scale.y * entry->diffScaleY; actor->world.pos.z += diff.z * actor->scale.z; } diff --git a/src/gcc_fix/missing_gcc_functions.c b/src/gcc_fix/missing_gcc_functions.c index 4c572a764b..c62418c7bb 100644 --- a/src/gcc_fix/missing_gcc_functions.c +++ b/src/gcc_fix/missing_gcc_functions.c @@ -7,7 +7,9 @@ #include "global.h" -// Self-hosted memcmp. +// Self-hosted libc memory functions, gcc assumes these exist even in a freestanding +// environment and there is no way to tell it otherwise. + int memcmp(void* s1, const void* s2, size_t n) { u8* m1 = (u8*)s1; u8* m2 = (u8*)s2; @@ -35,177 +37,212 @@ void* memset(void* str, s32 c, size_t n) { return str; } -// These functions convert c to an unsigned integer, rounding toward zero. Negative values -// all become zero. -u32 __fixunssfdi(f32 a) { - if (a < 0.0f) { - a = 0.0f; +// Conversions involving 64-bit integer types required by the O32 MIPS ABI. + +// f32 -> u64, negative values become 0 +u64 __fixunssfdi(f32 a) { + if (a > 0.0f) { + register union { + f64 f; + u64 i; + } m; + + __asm__ ("cvt.l.s %0, %1" : "=f"(m.f) : "f"(a)); + return m.i; } - - return (u32)a; + return 0; } -u32 __fixunsdfdi(f64 a) { - if (a < 0.0) { - a = 0.0; +// f64 -> u64, negative values become 0 +u64 __fixunsdfdi(f64 a) { + if (a > 0.0) { + register union { + f64 f; + u64 i; + } m; + + __asm__ ("cvt.l.d %0, %1" : "=f"(m.f) : "f"(a)); + return m.i; } - - return (u32)a; + return 0; } -// These functions convert c to a signed integer, rounding toward zero. -s32 __fixsfdi(f32 c) { - return (s32)c; +// f32 -> s64 +s64 __fixsfdi(f32 c) { + register union { + f64 f; + s64 i; + } m; + + __asm__ ("cvt.l.s %0, %1" : "=f"(m.f) : "f"(c)); + return m.i; } -s32 __fixdfdi(f64 c) { - return (s32)c; +// f64 -> s64 +s64 __fixdfdi(f64 c) { + register union { + f64 f; + s64 i; + } m; + + __asm__ ("cvt.l.d %0, %1" : "=f"(m.f) : "f"(c)); + return m.i; } -// These functions convert c, a signed integer, to floating point. -f32 __floatdisf(s32 c) { - return (f32)c; +// s64 -> f32 +f32 __floatdisf(s64 c) { + register union { + f64 f; + s64 i; + } m; + register f32 v; + + m.i = c; + __asm__ ("cvt.s.l %0, %1" : "=f"(v) : "f"(m.f)); + return v; } -f64 __floatdidf(s32 c) { - return (f64)c; +// s64 -> f64 +f64 __floatdidf(s64 c) { + register union { + f64 f; + s64 i; + } m; + register f64 v; + + m.i = c; + __asm__ ("cvt.d.l %0, %1" : "=f"(v) : "f"(m.f)); + return v; } -// These functions convert c, an unsigned integer, to floating point. -f32 __floatundisf(u32 c) { - return (f32)c; +// u64 -> f32 +f32 __floatundisf(u64 c) { + register union { + f64 f; + u64 i; + } m; + register f32 v; + + m.i = c; + __asm__ ("cvt.s.l %0, %1" : "=f"(v) : "f"(m.f)); + if ((s64)c < 0) { + // cvt.s.l assumes signed input, adjust output + v += 4294967296.0f; // 2^32 + } + return v; } -f64 __floatundidf(u32 c) { - return (f64)c; +// u64 -> f64 +f64 __floatundidf(u64 c) { + register union { + f64 f; + u64 i; + } m; + register f64 v; + + m.i = c; + __asm__ ("cvt.d.l %0, %1" : "=f"(v) : "f"(m.f)); + if ((s64)c < 0) { + // cvt.d.l assumes signed input, adjust output + v += 18446744073709551616.0; // 2^64 + } + return v; } -f32 __powisf2(f32 a, s32 b) { - const s32 recip = b < 0; - f32 r = 1; +// Compute x^m by binary exponentiation - while (1) { - if (b & 1) { - r *= a; +f32 __powisf2(f32 x, s32 m) { + u32 n = (m < 0) ? -m : m; + f32 y = (n % 2 != 0) ? x : 1.0f; + + while (n >>= 1) { + x = x * x; + + if (n % 2 != 0) { + y = y * x; } - - b /= 2; - - if (b == 0) { - break; - } - - a *= a; } - return recip ? 1 / r : r; + return (m < 0) ? (1.0f / y) : y; } +// Compute division and modulo of 64-bit signed and unsigned integers + __asm__(" \n\ .set push \n\ - .set noat \n\ .set noreorder \n\ .set gp=64 \n\ \n\ .global __umoddi3 \n\ __umoddi3: \n\ - .type __umoddi3, @function \n\ - .ent __umoddi3 \n\ - sw $a0, ($sp) \n\ - sw $a1, 4($sp) \n\ - sw $a2, 8($sp) \n\ - sw $a3, 0xc($sp) \n\ - ld $t7, 8($sp) \n\ - ld $t6, ($sp) \n\ - ddivu $zero, $t6, $t7 \n\ - bnez $t7, 1f \n\ - nop \n\ - break 7 \n\ -1: \n\ - mfhi $v0 \n\ - dsll32 $v1, $v0, 0 \n\ - dsra32 $v1, $v1, 0 \n\ - jr $ra \n\ + .type __umoddi3, @function \n\ + .ent __umoddi3 \n\ + sw $a0, 0x0($sp) \n\ + sw $a1, 0x4($sp) \n\ + sw $a2, 0x8($sp) \n\ + sw $a3, 0xC($sp) \n\ + ld $t6, 0($sp) \n\ + ld $t7, 8($sp) \n\ + dremu $v0, $t6, $t7 \n\ + dsll32 $v1, $v0, 0 \n\ + dsra32 $v1, $v1, 0 \n\ + jr $ra \n\ dsra32 $v0, $v0, 0 \n\ - .end __umoddi3 \n\ - .size __umoddi3, . - __umoddi3 \n\ + .end __umoddi3 \n\ + .size __umoddi3, . - __umoddi3 \n\ \n\ .global __udivdi3 \n\ __udivdi3: \n\ - .type __udivdi3, @function \n\ - .ent __udivdi3 \n\ - sw $a0, ($sp) \n\ - sw $a1, 4($sp) \n\ - sw $a2, 8($sp) \n\ - sw $a3, 0xc($sp) \n\ - ld $t7, 8($sp) \n\ - ld $t6, ($sp) \n\ - ddivu $zero, $t6, $t7 \n\ - bnez $t7, 1f \n\ - nop \n\ - break 7 \n\ -1: \n\ - mflo $v0 \n\ - dsll32 $v1, $v0, 0 \n\ - dsra32 $v1, $v1, 0 \n\ - jr $ra \n\ + .type __udivdi3, @function \n\ + .ent __udivdi3 \n\ + sw $a0, 0x0($sp) \n\ + sw $a1, 0x4($sp) \n\ + sw $a2, 0x8($sp) \n\ + sw $a3, 0xC($sp) \n\ + ld $t6, 0($sp) \n\ + ld $t7, 8($sp) \n\ + ddivu $v0, $t6, $t7 \n\ + dsll32 $v1, $v0, 0 \n\ + dsra32 $v1, $v1, 0 \n\ + jr $ra \n\ dsra32 $v0, $v0, 0 \n\ - .end __udivdi3 \n\ - .size __udivdi3, . - __udivdi3 \n\ + .end __udivdi3 \n\ + .size __udivdi3, . - __udivdi3 \n\ \n\ .global __moddi3 \n\ __moddi3: \n\ - .type __moddi3, @function \n\ - .ent __moddi3 \n\ - sw $a0, ($sp) \n\ - sw $a1, 4($sp) \n\ - sw $a2, 8($sp) \n\ - sw $a3, 0xc($sp) \n\ - ld $t7, 8($sp) \n\ - ld $t6, ($sp) \n\ - ddivu $zero, $t6, $t7 \n\ - bnez $t7, 1f \n\ - nop \n\ - break 7 \n\ -1: \n\ - mfhi $v0 \n\ - dsll32 $v1, $v0, 0 \n\ - dsra32 $v1, $v1, 0 \n\ - jr $ra \n\ + .type __moddi3, @function \n\ + .ent __moddi3 \n\ + sw $a0, 0x0($sp) \n\ + sw $a1, 0x4($sp) \n\ + sw $a2, 0x8($sp) \n\ + sw $a3, 0xC($sp) \n\ + ld $t6, 0($sp) \n\ + ld $t7, 8($sp) \n\ + drem $v0, $t6, $t7 \n\ + dsll32 $v1, $v0, 0 \n\ + dsra32 $v1, $v1, 0 \n\ + jr $ra \n\ dsra32 $v0, $v0, 0 \n\ - .end __moddi3 \n\ - .size __moddi3, . - __moddi3 \n\ + .end __moddi3 \n\ + .size __moddi3, . - __moddi3 \n\ \n\ .global __divdi3 \n\ __divdi3: \n\ - .type __divdi3, @function \n\ - .ent __divdi3 \n\ - sw $a0, ($sp) \n\ - sw $a1, 4($sp) \n\ - sw $a2, 8($sp) \n\ - sw $a3, 0xc($sp) \n\ + .type __divdi3, @function \n\ + .ent __divdi3 \n\ + sw $a0, 0x0($sp) \n\ + sw $a1, 0x4($sp) \n\ + sw $a2, 0x8($sp) \n\ + sw $a3, 0xC($sp) \n\ + ld $t6, 0($sp) \n\ ld $t7, 8($sp) \n\ - ld $t6, ($sp) \n\ - ddiv $zero, $t6, $t7 \n\ - nop \n\ - bnez $t7, 1f \n\ - nop \n\ - break 7 \n\ -1: \n\ - daddiu $at, $zero, -1 \n\ - bne $t7, $at, 2f \n\ - daddiu $at, $zero, 1 \n\ - dsll32 $at, $at, 0x1f \n\ - bne $t6, $at, 2f \n\ - nop \n\ - break 6 \n\ -2: \n\ - mflo $v0 \n\ + ddiv $v0, $t6, $t7 \n\ dsll32 $v1, $v0, 0 \n\ dsra32 $v1, $v1, 0 \n\ jr $ra \n\ dsra32 $v0, $v0, 0 \n\ - .end __divdi3 \n\ - .size __divdi3, . - __divdi3 \n\ + .end __divdi3 \n\ + .size __divdi3, . - __divdi3 \n\ \n\ .set pop \n\ \n"); diff --git a/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c b/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c index d920235bda..32c4cbd2c9 100644 --- a/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c +++ b/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c @@ -4161,7 +4161,7 @@ void BossGanon_LightBall_Draw(Actor* thisx, PlayState* play) { } } else if (this->unk_1A8 == 0) { Matrix_ReplaceRotation(&play->billboardMtxF); - Matrix_RotateZ((this->actor.shape.rot.z / 32768.0f) * 3.1416f, MTXMODE_APPLY); + Matrix_RotateZ((this->actor.shape.rot.z / (f32)0x8000) * 3.1416f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_boss_ganon.c", 9907), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gGanondorfSquareDL); diff --git a/src/overlays/actors/ovl_Demo_Ec/z_demo_ec.c b/src/overlays/actors/ovl_Demo_Ec/z_demo_ec.c index 8c46fd31dc..176ea5615a 100644 --- a/src/overlays/actors/ovl_Demo_Ec/z_demo_ec.c +++ b/src/overlays/actors/ovl_Demo_Ec/z_demo_ec.c @@ -176,19 +176,19 @@ void DemoEc_UpdateBgFlags(DemoEc* this, PlayState* play) { } void func_8096D594(DemoEc* this, PlayState* play) { - this->skelAnime.moveFlags |= 3; + this->skelAnime.moveFlags |= ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y; AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, 1.0f); } void func_8096D5D4(DemoEc* this, PlayState* play) { this->skelAnime.baseTransl = this->skelAnime.jointTable[0]; this->skelAnime.prevTransl = this->skelAnime.jointTable[0]; - this->skelAnime.moveFlags |= 3; + this->skelAnime.moveFlags |= ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y; AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, 1.0f); } void func_8096D64C(DemoEc* this, PlayState* play) { - this->skelAnime.moveFlags |= 3; + this->skelAnime.moveFlags |= ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y; AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, 1.0f); } @@ -1083,7 +1083,7 @@ void DemoEc_UpdateFishingOwner(DemoEc* this, PlayState* play) { void DemoEc_FishingOwnerPostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { DemoEc* this = (DemoEc*)thisx; - if ((limbIndex == 8) && !(HIGH_SCORE(HS_FISHING) & 0x1000)) { + if ((limbIndex == 8) && !(HIGH_SCORE(HS_FISHING) & HS_FISH_STOLE_HAT)) { gSPDisplayList((*gfx)++, SEGMENTED_TO_VIRTUAL(gFishingOwnerHatDL)); } } diff --git a/src/overlays/actors/ovl_Demo_Ik/z_demo_ik.c b/src/overlays/actors/ovl_Demo_Ik/z_demo_ik.c index 1ed4932ec6..42cbf7e4d1 100644 --- a/src/overlays/actors/ovl_Demo_Ik/z_demo_ik.c +++ b/src/overlays/actors/ovl_Demo_Ik/z_demo_ik.c @@ -51,12 +51,12 @@ s32 DemoIk_CheckForCue(PlayState* play, u16 cueId, s32 cueChannel) { } void DemoIk_SetMove(DemoIk* this, PlayState* play) { - this->skelAnime.moveFlags |= 1; + this->skelAnime.moveFlags |= ANIM_FLAG_0; AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, 1.0f); } void DemoIk_EndMove(DemoIk* this) { - this->skelAnime.moveFlags &= ~1; + this->skelAnime.moveFlags &= ~ANIM_FLAG_0; } f32 DemoIk_GetCurFrame(DemoIk* this) { diff --git a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c index 45515d51b2..2a5ee19bce 100644 --- a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c +++ b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c @@ -69,10 +69,10 @@ void EnBomBowlMan_Init(Actor* thisx, PlayState* play2) { for (i = 0; i < 2; i++) { cucco = (EnSyatekiNiw*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_SYATEKI_NIW, cuccoSpawnPos[i].x, - cuccoSpawnPos[i].y, cuccoSpawnPos[i].z, 0, 0, 0, 1); - + cuccoSpawnPos[i].y, cuccoSpawnPos[i].z, 0, 0, 0, + SYATEKI_MINIGAME_ALLEY); if (cucco != NULL) { - cucco->unk_2F4 = cuccoScales[i]; + cucco->scale = cuccoScales[i]; cucco->collider.dim.radius = (s16)cuccoColliderDims[i][0]; cucco->collider.dim.height = (s16)cuccoColliderDims[i][1]; } diff --git a/src/overlays/actors/ovl_En_Cow/z_en_cow.c b/src/overlays/actors/ovl_En_Cow/z_en_cow.c index c3879516eb..0f42827ed0 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.c +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.c @@ -5,7 +5,6 @@ */ #include "z_en_cow.h" -#include "assets/objects/object_cow/object_cow.h" #define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3) @@ -13,17 +12,19 @@ void EnCow_Init(Actor* thisx, PlayState* play); void EnCow_Destroy(Actor* thisx, PlayState* play); void EnCow_Update(Actor* thisx, PlayState* play2); void EnCow_Draw(Actor* thisx, PlayState* play); -void func_809DFE98(Actor* thisx, PlayState* play); -void func_809E0070(Actor* thisx, PlayState* play); -void func_809DF494(EnCow* this, PlayState* play); -void func_809DF6BC(EnCow* this, PlayState* play); -void func_809DF778(EnCow* this, PlayState* play); -void func_809DF7D8(EnCow* this, PlayState* play); -void func_809DF870(EnCow* this, PlayState* play); -void func_809DF8FC(EnCow* this, PlayState* play); -void func_809DF96C(EnCow* this, PlayState* play); -void func_809DFA84(EnCow* this, PlayState* play); +void EnCow_TalkEnd(EnCow* this, PlayState* play); +void EnCow_GiveMilkEnd(EnCow* this, PlayState* play); +void EnCow_GiveMilkWait(EnCow* this, PlayState* play); +void EnCow_GiveMilk(EnCow* this, PlayState* play); +void EnCow_CheckForEmptyBottle(EnCow* this, PlayState* play); +void EnCow_UpdateAnimation(EnCow* this, PlayState* play); +void EnCow_Talk(EnCow* this, PlayState* play); +void EnCow_Idle(EnCow* this, PlayState* play); + +void EnCow_DrawTail(Actor* thisx, PlayState* play); +void EnCow_UpdateTail(Actor* thisx, PlayState* play); +void EnCow_IdleTail(EnCow* this, PlayState* play); ActorInit En_Cow_InitVars = { ACTOR_EN_COW, @@ -57,45 +58,50 @@ static ColliderCylinderInit sCylinderInit = { { 30, 40, 0, { 0, 0, 0 } }, }; -static Vec3f D_809E010C = { 0.0f, -1300.0f, 1100.0f }; +static Vec3f sHeadFocusOffset = { 0.0f, -1300.0f, 1100.0f }; -void func_809DEE00(Vec3f* vec, s16 rotY) { +void EnCow_RotateY(Vec3f* vec, s16 rotY) { f32 xCalc; f32 rotCalcTemp; rotCalcTemp = Math_CosS(rotY); xCalc = (Math_SinS(rotY) * vec->z) + (rotCalcTemp * vec->x); rotCalcTemp = Math_SinS(rotY); + vec->z = (Math_CosS(rotY) * vec->z) + (-rotCalcTemp * vec->x); vec->x = xCalc; } -void func_809DEE9C(EnCow* this) { +void EnCow_SetColliderPos(EnCow* this) { Vec3f vec; vec.y = 0.0f; vec.x = 0.0f; vec.z = 30.0f; - func_809DEE00(&vec, this->actor.shape.rot.y); - this->colliders[0].dim.pos.x = this->actor.world.pos.x + vec.x; - this->colliders[0].dim.pos.y = this->actor.world.pos.y; - this->colliders[0].dim.pos.z = this->actor.world.pos.z + vec.z; + + EnCow_RotateY(&vec, this->actor.shape.rot.y); + + this->colliders[COW_COLLIDER_FRONT].dim.pos.x = this->actor.world.pos.x + vec.x; + this->colliders[COW_COLLIDER_FRONT].dim.pos.y = this->actor.world.pos.y; + this->colliders[COW_COLLIDER_FRONT].dim.pos.z = this->actor.world.pos.z + vec.z; vec.x = 0.0f; vec.y = 0.0f; vec.z = -20.0f; - func_809DEE00(&vec, this->actor.shape.rot.y); - this->colliders[1].dim.pos.x = this->actor.world.pos.x + vec.x; - this->colliders[1].dim.pos.y = this->actor.world.pos.y; - this->colliders[1].dim.pos.z = this->actor.world.pos.z + vec.z; + + EnCow_RotateY(&vec, this->actor.shape.rot.y); + + this->colliders[COW_COLLIDER_REAR].dim.pos.x = this->actor.world.pos.x + vec.x; + this->colliders[COW_COLLIDER_REAR].dim.pos.y = this->actor.world.pos.y; + this->colliders[COW_COLLIDER_REAR].dim.pos.z = this->actor.world.pos.z + vec.z; } -void func_809DEF94(EnCow* this) { +void EnCow_SetTailPos(EnCow* this) { Vec3f vec; VEC_SET(vec, 0.0f, 57.0f, -36.0f); + EnCow_RotateY(&vec, this->actor.shape.rot.y); - func_809DEE00(&vec, this->actor.shape.rot.y); this->actor.world.pos.x += vec.x; this->actor.world.pos.y += vec.y; this->actor.world.pos.z += vec.z; @@ -106,188 +112,216 @@ void EnCow_Init(Actor* thisx, PlayState* play) { s32 pad; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 72.0f); - switch (this->actor.params) { - case 0: - SkelAnime_InitFlex(play, &this->skelAnime, &gCowBodySkel, NULL, this->jointTable, this->morphTable, 6); + + switch (COW_GET_TYPE(this)) { + case COW_TYPE_BODY: + SkelAnime_InitFlex(play, &this->skelAnime, &gCowBodySkel, NULL, this->jointTable, this->morphTable, + COW_LIMB_MAX); Animation_PlayLoop(&this->skelAnime, &gCowBodyChewAnim); - Collider_InitCylinder(play, &this->colliders[0]); - Collider_SetCylinder(play, &this->colliders[0], &this->actor, &sCylinderInit); - Collider_InitCylinder(play, &this->colliders[1]); - Collider_SetCylinder(play, &this->colliders[1], &this->actor, &sCylinderInit); - func_809DEE9C(this); - this->actionFunc = func_809DF96C; + + Collider_InitCylinder(play, &this->colliders[COW_COLLIDER_FRONT]); + Collider_SetCylinder(play, &this->colliders[COW_COLLIDER_FRONT], &this->actor, &sCylinderInit); + + Collider_InitCylinder(play, &this->colliders[COW_COLLIDER_REAR]); + Collider_SetCylinder(play, &this->colliders[COW_COLLIDER_REAR], &this->actor, &sCylinderInit); + + EnCow_SetColliderPos(this); + + this->actionFunc = EnCow_Idle; + if (play->sceneId == SCENE_LINKS_HOUSE) { if (!LINK_IS_ADULT) { Actor_Kill(&this->actor); return; } - if (!GET_EVENTCHKINF(EVENTCHKINF_1E)) { + + if (!GET_EVENTCHKINF(EVENTCHKINF_HORSE_RACE_COW_UNLOCK)) { Actor_Kill(&this->actor); return; } } + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_COW, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, 1); - this->unk_278 = Rand_ZeroFloat(1000.0f) + 40.0f; - this->unk_27A = 0; + this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, + COW_TYPE_TAIL); + this->animationTimer = Rand_ZeroFloat(1000.0f) + 40.0f; + this->breathTimer = 0; this->actor.targetMode = 6; - DREG(53) = 0; + R_EPONAS_SONG_PLAYED = false; break; - case 1: - SkelAnime_InitFlex(play, &this->skelAnime, &gCowTailSkel, NULL, this->jointTable, this->morphTable, 6); + + case COW_TYPE_TAIL: + SkelAnime_InitFlex(play, &this->skelAnime, &gCowTailSkel, NULL, this->jointTable, this->morphTable, + COW_TAIL_LIMB_MAX); Animation_PlayLoop(&this->skelAnime, &gCowTailIdleAnim); - this->actor.update = func_809DFE98; - this->actor.draw = func_809E0070; - this->actionFunc = func_809DFA84; - func_809DEF94(this); + this->actor.update = EnCow_UpdateTail; + this->actor.draw = EnCow_DrawTail; + this->actionFunc = EnCow_IdleTail; + EnCow_SetTailPos(this); this->actor.flags &= ~ACTOR_FLAG_0; - this->unk_278 = ((u32)(Rand_ZeroFloat(1000.0f)) & 0xFFFF) + 40.0f; + this->animationTimer = (u16)Rand_ZeroFloat(1000.0f) + 40.0f; break; } + this->actor.colChkInfo.mass = MASS_IMMOVABLE; Actor_SetScale(&this->actor, 0.01f); - this->unk_276 = 0; + this->cowFlags = 0; } void EnCow_Destroy(Actor* thisx, PlayState* play) { EnCow* this = (EnCow*)thisx; - if (this->actor.params == 0) { - Collider_DestroyCylinder(play, &this->colliders[0]); - Collider_DestroyCylinder(play, &this->colliders[1]); + if (COW_GET_TYPE(this) == COW_TYPE_BODY) { + Collider_DestroyCylinder(play, &this->colliders[COW_COLLIDER_FRONT]); + Collider_DestroyCylinder(play, &this->colliders[COW_COLLIDER_REAR]); } } -void func_809DF494(EnCow* this, PlayState* play) { - if (this->unk_278 > 0) { - this->unk_278--; +void EnCow_UpdateAnimation(EnCow* this, PlayState* play) { + if (this->animationTimer > 0) { + this->animationTimer--; } else { - this->unk_278 = Rand_ZeroFloat(500.0f) + 40.0f; + this->animationTimer = Rand_ZeroFloat(500.0f) + 40.0f; Animation_Change(&this->skelAnime, &gCowBodyChewAnim, 1.0f, this->skelAnime.curFrame, Animation_GetLastFrame(&gCowBodyChewAnim), ANIMMODE_ONCE, 1.0f); } - if ((this->actor.xzDistToPlayer < 150.0f) && !(this->unk_276 & 2)) { - this->unk_276 |= 2; - if (this->skelAnime.animation == &gCowBodyChewAnim) { - this->unk_278 = 0; + if (this->actor.xzDistToPlayer < 150.0f) { + if (!(this->cowFlags & COW_FLAG_PLAYER_NEARBY)) { + this->cowFlags |= COW_FLAG_PLAYER_NEARBY; + + if (this->skelAnime.animation == &gCowBodyChewAnim) { + this->animationTimer = 0; + } } } - this->unk_27A++; - if (this->unk_27A > 48) { - this->unk_27A = 0; + this->breathTimer++; + + if (this->breathTimer > 48) { + this->breathTimer = 0; } - // (1.0f / 100.0f) instead of 0.01f below is necessary so 0.01f doesn't get reused mistakenly - if (this->unk_27A < 0x20) { - this->actor.scale.x = ((Math_SinS(this->unk_27A << 0xA) * (1.0f / 100.0f)) + 1.0f) * 0.01f; + if (this->breathTimer < 32) { + this->actor.scale.x = ((Math_SinS(this->breathTimer * 0x0400) * (1.0f / 100.0f)) + 1.0f) * 0.01f; } else { this->actor.scale.x = 0.01f; } - if (this->unk_27A >= 0x11) { - this->actor.scale.y = ((Math_SinS((this->unk_27A << 0xA) - 0x4000) * (1.0f / 100.0f)) + 1.0f) * 0.01f; + if (this->breathTimer > 16) { + this->actor.scale.y = ((Math_SinS((this->breathTimer * 0x0400) - 0x4000) * (1.0f / 100.0f)) + 1.0f) * 0.01f; } else { this->actor.scale.y = 0.01f; } } -void func_809DF6BC(EnCow* this, PlayState* play) { +void EnCow_TalkEnd(EnCow* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(play)) { this->actor.flags &= ~ACTOR_FLAG_16; Message_CloseTextbox(play); - this->actionFunc = func_809DF96C; + this->actionFunc = EnCow_Idle; } } -void func_809DF730(EnCow* this, PlayState* play) { +void EnCow_GiveMilkEnd(EnCow* this, PlayState* play) { if (Actor_TextboxIsClosing(&this->actor, play)) { this->actor.flags &= ~ACTOR_FLAG_16; - this->actionFunc = func_809DF96C; + this->actionFunc = EnCow_Idle; } } -void func_809DF778(EnCow* this, PlayState* play) { +void EnCow_GiveMilkWait(EnCow* this, PlayState* play) { if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; - this->actionFunc = func_809DF730; + this->actionFunc = EnCow_GiveMilkEnd; } else { Actor_OfferGetItem(&this->actor, play, GI_MILK, 10000.0f, 100.0f); } } -void func_809DF7D8(EnCow* this, PlayState* play) { +void EnCow_GiveMilk(EnCow* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(play)) { this->actor.flags &= ~ACTOR_FLAG_16; Message_CloseTextbox(play); - this->actionFunc = func_809DF778; + this->actionFunc = EnCow_GiveMilkWait; Actor_OfferGetItem(&this->actor, play, GI_MILK, 10000.0f, 100.0f); } } -void func_809DF870(EnCow* this, PlayState* play) { +void EnCow_CheckForEmptyBottle(EnCow* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(play)) { if (Inventory_HasEmptyBottle()) { Message_ContinueTextbox(play, 0x2007); - this->actionFunc = func_809DF7D8; + this->actionFunc = EnCow_GiveMilk; } else { Message_ContinueTextbox(play, 0x2013); - this->actionFunc = func_809DF6BC; + this->actionFunc = EnCow_TalkEnd; } } } -void func_809DF8FC(EnCow* this, PlayState* play) { +void EnCow_Talk(EnCow* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, play)) { - this->actionFunc = func_809DF870; + this->actionFunc = EnCow_CheckForEmptyBottle; } else { this->actor.flags |= ACTOR_FLAG_16; func_8002F2CC(&this->actor, play, 170.0f); this->actor.textId = 0x2006; } - func_809DF494(this, play); + + EnCow_UpdateAnimation(this, play); } -void func_809DF96C(EnCow* this, PlayState* play) { +void EnCow_Idle(EnCow* this, PlayState* play) { if ((play->msgCtx.ocarinaMode == OCARINA_MODE_00) || (play->msgCtx.ocarinaMode == OCARINA_MODE_04)) { - if (DREG(53) != 0) { - if (this->unk_276 & 4) { - this->unk_276 &= ~0x4; - DREG(53) = 0; + // There is a complex interaction between `R_EPONAS_SONG_PLAYED` and `COW_FLAG_FAILED_TO_GIVE_MILK` to allow + // multiple cows to try and give milk on the same frame. + // `COW_FLAG_FAILED_TO_GIVE_MILK` gets set if this cow is not in range with the player to interact. + // In the case of a failure, `R_EPONAS_SONG_PLAYED` is not set to false in case another cow can succeed. + // On the following frame, if both `R_EPONAS_SONG_PLAYED` and `COW_FLAG_FAILED_TO_GIVE_MILK` are set, the + // first cow that updates can assume all other cows also failed and can safely unset `R_EPONAS_SONG_PLAYED`. + // All cows also unset their own `COW_FLAG_FAILED_TO_GIVE_MILK` flag. + if (R_EPONAS_SONG_PLAYED) { + if (this->cowFlags & COW_FLAG_FAILED_TO_GIVE_MILK) { + this->cowFlags &= ~COW_FLAG_FAILED_TO_GIVE_MILK; + R_EPONAS_SONG_PLAYED = false; } else { if ((this->actor.xzDistToPlayer < 150.0f) && - (ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) < 0x61A8)) { - DREG(53) = 0; - this->actionFunc = func_809DF8FC; + (ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) < 25000)) { + R_EPONAS_SONG_PLAYED = false; + this->actionFunc = EnCow_Talk; this->actor.flags |= ACTOR_FLAG_16; func_8002F2CC(&this->actor, play, 170.0f); this->actor.textId = 0x2006; } else { - this->unk_276 |= 4; + this->cowFlags |= COW_FLAG_FAILED_TO_GIVE_MILK; } } } else { - this->unk_276 &= ~0x4; + this->cowFlags &= ~COW_FLAG_FAILED_TO_GIVE_MILK; } } - func_809DF494(this, play); + + EnCow_UpdateAnimation(this, play); } -void func_809DFA84(EnCow* this, PlayState* play) { - if (this->unk_278 > 0) { - this->unk_278--; +void EnCow_IdleTail(EnCow* this, PlayState* play) { + if (this->animationTimer > 0) { + this->animationTimer--; } else { - this->unk_278 = Rand_ZeroFloat(200.0f) + 40.0f; + this->animationTimer = Rand_ZeroFloat(200.0f) + 40.0f; Animation_Change(&this->skelAnime, &gCowTailIdleAnim, 1.0f, this->skelAnime.curFrame, Animation_GetLastFrame(&gCowTailIdleAnim), ANIMMODE_ONCE, 1.0f); } if ((this->actor.xzDistToPlayer < 150.0f) && - (ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) >= 0x61A9) && !(this->unk_276 & 2)) { - this->unk_276 |= 2; - if (this->skelAnime.animation == &gCowTailIdleAnim) { - this->unk_278 = 0; + (ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) > 25000)) { + if (!(this->cowFlags & COW_FLAG_PLAYER_NEARBY)) { + this->cowFlags |= COW_FLAG_PLAYER_NEARBY; + + if (this->skelAnime.animation == &gCowTailIdleAnim) { + this->animationTimer = 0; + } } } } @@ -299,10 +333,12 @@ void EnCow_Update(Actor* thisx, PlayState* play2) { s16 targetY; Player* player = GET_PLAYER(play); - CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliders[0].base); - CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliders[1].base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliders[COW_COLLIDER_FRONT].base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliders[COW_COLLIDER_REAR].base); + Actor_MoveXZGravity(thisx); Actor_UpdateBgCheckInfo(play, thisx, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_2); + if (SkelAnime_Update(&this->skelAnime)) { if (this->skelAnime.animation == &gCowBodyChewAnim) { Actor_PlaySfx(thisx, NA_SE_EV_COW_CRY); @@ -313,7 +349,9 @@ void EnCow_Update(Actor* thisx, PlayState* play2) { ANIMMODE_LOOP, 1.0f); } } + this->actionFunc(this, play); + if ((thisx->xzDistToPlayer < 150.0f) && (ABS(Math_Vec3f_Yaw(&thisx->world.pos, &player->actor.world.pos)) < 0xC000)) { targetX = Math_Vec3f_Pitch(&thisx->focus.pos, &player->actor.focus.pos); @@ -330,16 +368,16 @@ void EnCow_Update(Actor* thisx, PlayState* play2) { } else if (targetY < -0x2500) { targetY = -0x2500; } - } else { targetY = 0; targetX = 0; } - Math_SmoothStepToS(&this->someRot.x, targetX, 0xA, 0xC8, 0xA); - Math_SmoothStepToS(&this->someRot.y, targetY, 0xA, 0xC8, 0xA); + + Math_SmoothStepToS(&this->headRot.x, targetX, 10, 200, 10); + Math_SmoothStepToS(&this->headRot.y, targetY, 10, 200, 10); } -void func_809DFE98(Actor* thisx, PlayState* play) { +void EnCow_UpdateTail(Actor* thisx, PlayState* play) { EnCow* this = (EnCow*)thisx; s32 pad; @@ -352,27 +390,30 @@ void func_809DFE98(Actor* thisx, PlayState* play) { ANIMMODE_LOOP, 1.0f); } } + this->actionFunc(this, play); } s32 EnCow_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { EnCow* this = (EnCow*)thisx; - if (limbIndex == 2) { - rot->y += this->someRot.y; - rot->x += this->someRot.x; + if (limbIndex == COW_LIMB_HEAD) { + rot->y += this->headRot.y; + rot->x += this->headRot.x; } - if (limbIndex == 5) { + + if (limbIndex == COW_LIMB_NOSE_RING) { *dList = NULL; } + return false; } void EnCow_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { EnCow* this = (EnCow*)thisx; - if (limbIndex == 2) { - Matrix_MultVec3f(&D_809E010C, &this->actor.focus.pos); + if (limbIndex == COW_LIMB_HEAD) { + Matrix_MultVec3f(&sHeadFocusOffset, &this->actor.focus.pos); } } @@ -384,7 +425,7 @@ void EnCow_Draw(Actor* thisx, PlayState* play) { EnCow_OverrideLimbDraw, EnCow_PostLimbDraw, this); } -void func_809E0070(Actor* thisx, PlayState* play) { +void EnCow_DrawTail(Actor* thisx, PlayState* play) { EnCow* this = (EnCow*)thisx; Gfx_SetupDL_37Opa(play->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Cow/z_en_cow.h b/src/overlays/actors/ovl_En_Cow/z_en_cow.h index 9fcc67c797..145d937f68 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.h +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.h @@ -3,6 +3,23 @@ #include "ultra64.h" #include "global.h" +#include "assets/objects/object_cow/object_cow.h" + +#define COW_FLAG_PLAYER_NEARBY (1 << 1) +#define COW_FLAG_FAILED_TO_GIVE_MILK (1 << 2) + +#define COW_GET_TYPE(thisx) ((thisx)->actor.params) + +typedef enum { + /* 0 */ COW_TYPE_BODY, + /* 1 */ COW_TYPE_TAIL +} CowType; + +typedef enum { + /* 0 */ COW_COLLIDER_FRONT, + /* 1 */ COW_COLLIDER_REAR, + /* 2 */ COW_COLLIDER_MAX +} CowCollider; struct EnCow; @@ -10,14 +27,14 @@ typedef void (*EnCowActionFunc)(struct EnCow*, PlayState*); typedef struct EnCow { /* 0x0000 */ Actor actor; - /* 0x014C */ ColliderCylinder colliders[2]; + /* 0x014C */ ColliderCylinder colliders[COW_COLLIDER_MAX]; /* 0x01E4 */ SkelAnime skelAnime; - /* 0x0228 */ Vec3s jointTable[6]; - /* 0x024C */ Vec3s morphTable[6]; - /* 0x0270 */ Vec3s someRot; - /* 0x0276 */ u16 unk_276; - /* 0x0278 */ u16 unk_278; - /* 0x027A */ u16 unk_27A; + /* 0x0228 */ Vec3s jointTable[COW_LIMB_MAX]; + /* 0x024C */ Vec3s morphTable[COW_LIMB_MAX]; + /* 0x0270 */ Vec3s headRot; + /* 0x0276 */ u16 cowFlags; + /* 0x0278 */ u16 animationTimer; + /* 0x027A */ u16 breathTimer; /* 0x027C */ EnCowActionFunc actionFunc; } EnCow; // size = 0x0280 diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/src/overlays/actors/ovl_En_Horse/z_en_horse.c index edeb55195c..cd87b114a8 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -743,7 +743,7 @@ void EnHorse_Init(Actor* thisx, PlayState* play2) { AREG(6) = 0; Actor_ProcessInitChain(&this->actor, sInitChain); EnHorse_ClearDustFlags(&this->dustFlags); - DREG(53) = 0; + R_EPONAS_SONG_PLAYED = false; this->riderPos = this->actor.world.pos; this->noInputTimer = 0; this->noInputTimerMax = 0; @@ -1735,8 +1735,8 @@ void EnHorse_SetFollowAnimation(EnHorse* this, PlayState* play); void EnHorse_Inactive(EnHorse* this, PlayState* play2) { PlayState* play = play2; - if (DREG(53) != 0 && this->type == HORSE_EPONA) { - DREG(53) = 0; + if (R_EPONAS_SONG_PLAYED && this->type == HORSE_EPONA) { + R_EPONAS_SONG_PLAYED = false; if (EnHorse_Spawn(this, play) != 0) { Audio_PlaySfxGeneral(NA_SE_EV_HORSE_NEIGH, &this->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); @@ -1810,8 +1810,8 @@ void EnHorse_Idle(EnHorse* this, PlayState* play) { this->actor.speed = 0.0f; EnHorse_IdleAnimSounds(this, play); - if (DREG(53) && this->type == HORSE_EPONA) { - DREG(53) = 0; + if (R_EPONAS_SONG_PLAYED && this->type == HORSE_EPONA) { + R_EPONAS_SONG_PLAYED = false; if (!func_80A5BBBC(play, this, &this->actor.world.pos)) { if (EnHorse_Spawn(this, play)) { Audio_PlaySfxGeneral(NA_SE_EV_HORSE_NEIGH, &this->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, @@ -1905,7 +1905,7 @@ void EnHorse_FollowPlayer(EnHorse* this, PlayState* play) { f32 distToPlayer; f32 angleDiff; - DREG(53) = 0; + R_EPONAS_SONG_PLAYED = false; distToPlayer = Actor_WorldDistXZToActor(&this->actor, &GET_PLAYER(play)->actor); // First rotate if the player is behind @@ -2597,7 +2597,7 @@ void EnHorse_FleePlayer(EnHorse* this, PlayState* play) { s32 animFinished; s16 yaw; - if (DREG(53) || this->type == HORSE_HNI) { + if (R_EPONAS_SONG_PLAYED || this->type == HORSE_HNI) { EnHorse_StartIdleRidable(this); Audio_PlaySfxGeneral(NA_SE_EV_HORSE_NEIGH, &this->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); diff --git a/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c b/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c index 13d0cc410c..64c15537dd 100644 --- a/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c +++ b/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c @@ -358,7 +358,7 @@ void func_80A6A068(EnHorseLinkChild* this, PlayState* play) { return; } - if ((GET_EVENTCHKINF(EVENTCHKINF_16) && (DREG(53) != 0)) || + if ((GET_EVENTCHKINF(EVENTCHKINF_16) && R_EPONAS_SONG_PLAYED) || ((play->sceneId == SCENE_LON_LON_RANCH) && (gSaveContext.save.cutsceneIndex == 0xFFF1))) { func_80A6A4DC(this); } else { @@ -434,7 +434,7 @@ void func_80A6A068(EnHorseLinkChild* this, PlayState* play) { void func_80A6A4DC(EnHorseLinkChild* this) { this->action = 5; this->animationIdx = Rand_ZeroOne() > 0.5f ? 0 : 1; - DREG(53) = 0; + R_EPONAS_SONG_PLAYED = false; Animation_Change(&this->skin.skelAnime, sAnimations[this->animationIdx], func_80A695A4(this), 0.0f, Animation_GetLastFrame(sAnimations[this->animationIdx]), ANIMMODE_ONCE, 0.0f); } @@ -442,8 +442,8 @@ void func_80A6A4DC(EnHorseLinkChild* this) { void func_80A6A5A4(EnHorseLinkChild* this, PlayState* play) { s16 yawDiff; - if (DREG(53) != 0) { - DREG(53) = 0; + if (R_EPONAS_SONG_PLAYED) { + R_EPONAS_SONG_PLAYED = false; Audio_PlaySfxGeneral(NA_SE_EV_KID_HORSE_NEIGH, &this->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); func_80A6A724(this); diff --git a/src/overlays/actors/ovl_En_In/z_en_in.c b/src/overlays/actors/ovl_En_In/z_en_in.c index f18b0cf7fe..9b31fbc2ff 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -339,7 +339,7 @@ void func_80A795C8(EnIn* this, PlayState* play) { void func_80A79690(SkelAnime* skelAnime, EnIn* this, PlayState* play) { if (skelAnime->baseTransl.y < skelAnime->jointTable[0].y) { - skelAnime->moveFlags |= 3; + skelAnime->moveFlags |= ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y; AnimationContext_SetMoveActor(play, &this->actor, skelAnime, 1.0f); } } diff --git a/src/overlays/actors/ovl_En_Ma3/z_en_ma3.c b/src/overlays/actors/ovl_En_Ma3/z_en_ma3.c index 43c19df76f..caccc853f3 100644 --- a/src/overlays/actors/ovl_En_Ma3/z_en_ma3.c +++ b/src/overlays/actors/ovl_En_Ma3/z_en_ma3.c @@ -87,7 +87,7 @@ u16 EnMa3_GetTextId(PlayState* play, Actor* thisx) { HIGH_SCORE(HS_HORSE_RACE) = 180; } - if (!GET_EVENTCHKINF(EVENTCHKINF_1E) && (((void)0, gSaveContext.timerSeconds) < 50)) { + if (!GET_EVENTCHKINF(EVENTCHKINF_HORSE_RACE_COW_UNLOCK) && (((void)0, gSaveContext.timerSeconds) < 50)) { return 0x208F; } @@ -128,7 +128,7 @@ s16 EnMa3_UpdateTalkState(PlayState* play, Actor* thisx) { if (Message_ShouldAdvance(play)) { SET_INFTABLE(INFTABLE_B9); if (play->msgCtx.choiceIndex == 0) { - if (GET_EVENTCHKINF(EVENTCHKINF_1E)) { + if (GET_EVENTCHKINF(EVENTCHKINF_HORSE_RACE_COW_UNLOCK)) { Message_ContinueTextbox(play, 0x2091); } else if (HIGH_SCORE(HS_HORSE_RACE) == 0) { Message_ContinueTextbox(play, 0x2092); @@ -145,7 +145,7 @@ s16 EnMa3_UpdateTalkState(PlayState* play, Actor* thisx) { talkState = NPC_TALK_STATE_IDLE; break; case 0x208F: - SET_EVENTCHKINF(EVENTCHKINF_1E); + SET_EVENTCHKINF(EVENTCHKINF_HORSE_RACE_COW_UNLOCK); FALLTHROUGH; case 0x2004: case 0x2012: diff --git a/src/overlays/actors/ovl_En_Nb/z_en_nb.c b/src/overlays/actors/ovl_En_Nb/z_en_nb.c index 71778064f0..db81a98eee 100644 --- a/src/overlays/actors/ovl_En_Nb/z_en_nb.c +++ b/src/overlays/actors/ovl_En_Nb/z_en_nb.c @@ -745,7 +745,7 @@ void EnNb_InitDemo6KInConfrontation(EnNb* this, PlayState* play) { } void func_80AB2688(EnNb* this, PlayState* play) { - this->skelAnime.moveFlags |= 1; + this->skelAnime.moveFlags |= ANIM_FLAG_0; AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, 1.0f); } diff --git a/src/overlays/actors/ovl_En_Niw/z_en_niw.c b/src/overlays/actors/ovl_En_Niw/z_en_niw.c index dd9a4da1fd..8c05a3636d 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.c +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.c @@ -229,7 +229,7 @@ void EnNiw_Init(Actor* thisx, PlayState* play) { case 0xD: case 0xE: Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit2); - if (play->sceneId == SCENE_LINKS_HOUSE && !GET_EVENTCHKINF(EVENTCHKINF_1E)) { + if (play->sceneId == SCENE_LINKS_HOUSE && !GET_EVENTCHKINF(EVENTCHKINF_HORSE_RACE_COW_UNLOCK)) { Actor_Kill(&this->actor); } break; diff --git a/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c b/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c index d58a4a443a..4ac7533203 100644 --- a/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c +++ b/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c @@ -390,17 +390,17 @@ s32 EnRu1_UpdateSkelAnime(EnRu1* this) { } void func_80AEB364(EnRu1* this, PlayState* play) { - this->skelAnime.moveFlags |= 1; + this->skelAnime.moveFlags |= ANIM_FLAG_0; AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, 1.0f); } void func_80AEB3A4(EnRu1* this, PlayState* play) { - this->skelAnime.moveFlags |= 1; + this->skelAnime.moveFlags |= ANIM_FLAG_0; func_80AEB364(this, play); } void func_80AEB3CC(EnRu1* this) { - this->skelAnime.moveFlags &= ~0x1; + this->skelAnime.moveFlags &= ~ANIM_FLAG_0; } void func_80AEB3DC(EnRu1* this, PlayState* play) { @@ -461,7 +461,7 @@ void func_80AEB6E0(EnRu1* this, PlayState* play) { SkelAnime* skelAnime = &this->skelAnime; if (skelAnime->baseTransl.y < skelAnime->jointTable[0].y) { - skelAnime->moveFlags |= 3; + skelAnime->moveFlags |= ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y; AnimationContext_SetMoveActor(play, &this->actor, skelAnime, 1.0f); } } @@ -472,13 +472,13 @@ void func_80AEB738(EnRu1* this, PlayState* play) { skelAnime->baseTransl = skelAnime->jointTable[0]; skelAnime->prevTransl = skelAnime->jointTable[0]; if (skelAnime->baseTransl.y < skelAnime->jointTable[0].y) { - skelAnime->moveFlags |= 3; + skelAnime->moveFlags |= ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y; AnimationContext_SetMoveActor(play, &this->actor, skelAnime, 1.0f); } } void func_80AEB7D0(EnRu1* this) { - this->skelAnime.moveFlags &= ~0x3; + this->skelAnime.moveFlags &= ~(ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y); } f32 func_80AEB7E0(CsCmdActorCue* cue, PlayState* play) { diff --git a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c index 7447e736c5..59d924aeb4 100644 --- a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c +++ b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c @@ -122,7 +122,7 @@ void EnSsh_SpawnShockwave(EnSsh* this, PlayState* play) { pos.x = this->actor.world.pos.x; pos.y = this->actor.floorHeight; pos.z = this->actor.world.pos.z; - EffectSsBlast_SpawnWhiteCustomScale(play, &pos, &zeroVec, &zeroVec, 100, 220, 8); + EffectSsBlast_SpawnWhiteShockwaveSetScale(play, &pos, &zeroVec, &zeroVec, 100, 220, 8); } s32 EnSsh_CreateBlureEffect(PlayState* play) { diff --git a/src/overlays/actors/ovl_En_St/z_en_st.c b/src/overlays/actors/ovl_En_St/z_en_st.c index e44f46f0dd..1e0288fab1 100644 --- a/src/overlays/actors/ovl_En_St/z_en_st.c +++ b/src/overlays/actors/ovl_En_St/z_en_st.c @@ -161,7 +161,7 @@ void EnSt_SpawnBlastEffect(EnSt* this, PlayState* play) { blastPos.y = this->actor.floorHeight; blastPos.z = this->actor.world.pos.z; - EffectSsBlast_SpawnWhiteCustomScale(play, &blastPos, &zeroVec, &zeroVec, 100, 220, 8); + EffectSsBlast_SpawnWhiteShockwaveSetScale(play, &blastPos, &zeroVec, &zeroVec, 100, 220, 8); } void EnSt_SpawnDeadEffect(EnSt* this, PlayState* play) { diff --git a/src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.c b/src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.c index af1e2aa199..ff0f5f3244 100644 --- a/src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.c +++ b/src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.c @@ -15,16 +15,16 @@ void EnSyatekiNiw_Destroy(Actor* thisx, PlayState* play); void EnSyatekiNiw_Update(Actor* thisx, PlayState* play); void EnSyatekiNiw_Draw(Actor* thisx, PlayState* play); -void func_80B11DEC(EnSyatekiNiw* this, PlayState* play); +void EnSyatekiNiw_SetupDefault(EnSyatekiNiw* this, PlayState* play); void EnSyatekiNiw_UpdateEffects(EnSyatekiNiw* this, PlayState* play); -void func_80B129EC(EnSyatekiNiw* this, PlayState* play); +void EnSyatekiNiw_Remove(EnSyatekiNiw* this, PlayState* play); void EnSyatekiNiw_DrawEffects(EnSyatekiNiw* this, PlayState* play); -void func_80B123A8(EnSyatekiNiw* this, PlayState* play); -void func_80B11E78(EnSyatekiNiw* this, PlayState* play); -void func_80B12460(EnSyatekiNiw* this, PlayState* play); -void func_80B128D8(EnSyatekiNiw* this, PlayState* play); +void EnSyatekiNiw_SetupArchery(EnSyatekiNiw* this, PlayState* play); +void EnSyatekiNiw_Default(EnSyatekiNiw* this, PlayState* play); +void EnSyatekiNiw_Archery(EnSyatekiNiw* this, PlayState* play); +void EnSyatekiNiw_ExitArchery(EnSyatekiNiw* this, PlayState* play); -void EnSyatekiNiw_SpawnFeather(EnSyatekiNiw* this, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, f32 arg4); +void EnSyatekiNiw_SpawnFeather(EnSyatekiNiw* this, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 scale); ActorInit En_Syateki_Niw_InitVars = { ACTOR_EN_SYATEKI_NIW, @@ -72,14 +72,14 @@ void EnSyatekiNiw_Init(Actor* thisx, PlayState* play) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); SkelAnime_InitFlex(play, &this->skelAnime, &gCuccoSkel, &gCuccoAnim, this->jointTable, this->morphTable, 16); - this->unk_29E = this->actor.params; - if (this->unk_29E < 0) { - this->unk_29E = 0; + this->minigameType = this->actor.params; + if (this->minigameType < 0) { + this->minigameType = SYATEKI_MINIGAME_ARCHERY; } Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); - if (this->unk_29E == 0) { + if (this->minigameType == SYATEKI_MINIGAME_ARCHERY) { osSyncPrintf("\n\n"); // "Archery range chicken" osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 射的場鶏 ☆☆☆☆☆ \n" VT_RST); @@ -92,9 +92,9 @@ void EnSyatekiNiw_Init(Actor* thisx, PlayState* play) { Actor_SetScale(&this->actor, 0.01f); } - this->unk_2DC = this->actor.world.pos; - this->unk_2E8 = this->actor.world.pos; - this->actionFunc = func_80B11DEC; + this->initPos = this->actor.world.pos; + this->targetPos = this->actor.world.pos; + this->actionFunc = EnSyatekiNiw_SetupDefault; } void EnSyatekiNiw_Destroy(Actor* thisx, PlayState* play) { @@ -103,241 +103,240 @@ void EnSyatekiNiw_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyCylinder(play, &this->collider); } -void func_80B11A94(EnSyatekiNiw* this, PlayState* play, s16 arg2) { - if (this->unk_254 == 0) { - if (arg2 == 0) { - this->unk_264 = 0.0f; +void EnSyatekiNiw_UpdateRotations(EnSyatekiNiw* this, PlayState* play, s16 animationType) { + if (this->peckTimer == 0) { + if (animationType == 0) { + this->headRotXTarget = 0.0f; } else { - this->unk_264 = -10000.0f; + this->headRotXTarget = -10000.0f; } - this->unk_28E++; - this->unk_254 = 3; - if (!(this->unk_28E & 1)) { - this->unk_264 = 0.0f; - if (arg2 == 0) { - this->unk_254 = Rand_ZeroFloat(30.0f); + this->headRotXState++; + this->peckTimer = 3; + if (!(this->headRotXState & 1)) { + this->headRotXTarget = 0.0f; + if (animationType == 0) { + this->peckTimer = Rand_ZeroFloat(30.0f); } } } - if (this->unk_258 == 0) { - this->unk_292++; - this->unk_292 &= 1; - switch (arg2) { + if (this->flapTimer == 0) { + this->wingsRotState++; + this->wingsRotState &= 1; + switch (animationType) { case 0: - this->unk_26C = 0.0f; - this->unk_268 = 0.0f; + this->leftWingRotXTarget = 0.0f; + this->rightWingRotXTarget = 0.0f; break; case 1: - this->unk_258 = 3; - this->unk_26C = 7000.0f; - this->unk_268 = 7000.0f; - if (this->unk_292 == 0) { - this->unk_26C = 0.0f; - this->unk_268 = 0.0f; + this->flapTimer = 3; + this->leftWingRotXTarget = 7000.0f; + this->rightWingRotXTarget = 7000.0f; + if (this->wingsRotState == 0) { + this->leftWingRotXTarget = 0.0f; + this->rightWingRotXTarget = 0.0f; } break; case 2: - this->unk_258 = 2; - this->unk_268 = this->unk_26C = -10000.0f; - this->unk_280 = this->unk_278 = 25000.0f; - this->unk_284 = this->unk_27C = 6000.0f; - if (this->unk_292 == 0) { - this->unk_278 = 8000.0f; - this->unk_280 = 8000.0f; + this->flapTimer = 2; + this->rightWingRotXTarget = this->leftWingRotXTarget = -10000.0f; + this->leftWingRotYTarget = this->rightWingRotYTarget = 25000.0f; + this->leftWingRotZTarget = this->rightWingRotZTarget = 6000.0f; + if (this->wingsRotState == 0) { + this->rightWingRotYTarget = 8000.0f; + this->leftWingRotYTarget = 8000.0f; } break; case 3: - this->unk_258 = 2; - this->unk_278 = 10000.0f; - this->unk_280 = 10000.0f; - if (this->unk_292 == 0) { - this->unk_278 = 3000.0f; - this->unk_280 = 3000.0f; + this->flapTimer = 2; + this->rightWingRotYTarget = 10000.0f; + this->leftWingRotYTarget = 10000.0f; + if (this->wingsRotState == 0) { + this->rightWingRotYTarget = 3000.0f; + this->leftWingRotYTarget = 3000.0f; } break; case 4: - this->unk_254 = this->unk_256 = 5; + this->peckTimer = this->timer1 = 5; break; case 5: - this->unk_258 = 5; - this->unk_278 = 14000.0f; - this->unk_280 = 14000.0f; - if (this->unk_292 == 0) { - this->unk_278 = 10000.0f; - this->unk_280 = 10000.0f; + this->flapTimer = 5; + this->rightWingRotYTarget = 14000.0f; + this->leftWingRotYTarget = 14000.0f; + if (this->wingsRotState == 0) { + this->rightWingRotYTarget = 10000.0f; + this->leftWingRotYTarget = 10000.0f; } break; } } - if (this->unk_264 != this->unk_2BC.x) { - Math_ApproachF(&this->unk_2BC.x, this->unk_264, 0.5f, 4000.0f); + if (this->headRotXTarget != this->headRot.x) { + Math_ApproachF(&this->headRot.x, this->headRotXTarget, 0.5f, 4000.0f); } - if (this->unk_26C != this->unk_2A4.x) { - Math_ApproachF(&this->unk_2A4.x, this->unk_26C, 0.8f, 7000.0f); + if (this->leftWingRotXTarget != this->leftWingRot.x) { + Math_ApproachF(&this->leftWingRot.x, this->leftWingRotXTarget, 0.8f, 7000.0f); } - if (this->unk_280 != this->unk_2A4.y) { - Math_ApproachF(&this->unk_2A4.y, this->unk_280, 0.8f, 7000.0f); + if (this->leftWingRotYTarget != this->leftWingRot.y) { + Math_ApproachF(&this->leftWingRot.y, this->leftWingRotYTarget, 0.8f, 7000.0f); } - if (this->unk_284 != this->unk_2A4.z) { - Math_ApproachF(&this->unk_2A4.z, this->unk_284, 0.8f, 7000.0f); + if (this->leftWingRotZTarget != this->leftWingRot.z) { + Math_ApproachF(&this->leftWingRot.z, this->leftWingRotZTarget, 0.8f, 7000.0f); } - if (this->unk_268 != this->unk_2B0.x) { - Math_ApproachF(&this->unk_2B0.x, this->unk_268, 0.8f, 7000.0f); + if (this->rightWingRotXTarget != this->rightWingRot.x) { + Math_ApproachF(&this->rightWingRot.x, this->rightWingRotXTarget, 0.8f, 7000.0f); } - if (this->unk_278 != this->unk_2B0.y) { - Math_ApproachF(&this->unk_2B0.y, this->unk_278, 0.8f, 7000.0f); + if (this->rightWingRotYTarget != this->rightWingRot.y) { + Math_ApproachF(&this->rightWingRot.y, this->rightWingRotYTarget, 0.8f, 7000.0f); } - if (this->unk_27C != this->unk_2B0.z) { - Math_ApproachF(&this->unk_2B0.z, this->unk_27C, 0.8f, 7000.0f); + if (this->rightWingRotZTarget != this->rightWingRot.z) { + Math_ApproachF(&this->rightWingRot.z, this->rightWingRotZTarget, 0.8f, 7000.0f); } } -void func_80B11DEC(EnSyatekiNiw* this, PlayState* play) { +void EnSyatekiNiw_SetupDefault(EnSyatekiNiw* this, PlayState* play) { Animation_Change(&this->skelAnime, &gCuccoAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gCuccoAnim), ANIMMODE_LOOP, -10.0f); - if (this->unk_29E != 0) { - Actor_SetScale(&this->actor, this->unk_2F4); + if (this->minigameType != SYATEKI_MINIGAME_ARCHERY) { + Actor_SetScale(&this->actor, this->scale); } - this->actionFunc = func_80B11E78; + this->actionFunc = EnSyatekiNiw_Default; } -void func_80B11E78(EnSyatekiNiw* this, PlayState* play) { +void EnSyatekiNiw_Default(EnSyatekiNiw* this, PlayState* play) { Vec3f dustVelocity = { 0.0f, 0.0f, 0.0f }; Vec3f dustAccel = { 0.0f, 0.2f, 0.0f }; Color_RGBA8 dustPrimColor = { 0, 0, 0, 255 }; Color_RGBA8 dustEnvColor = { 0, 0, 0, 255 }; Vec3f dustPos; - f32 tmpf2; - f32 sp4C; - f32 sp50; - f32 tmpf1; - s16 sp4A; + f32 posZDiff; + f32 posZMod; + f32 posXMod; + f32 posXDiff; + s16 animationType; - if ((this->unk_29C != 0) && (this->unk_29E == 0) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { - this->unk_29C = 0; - this->actionFunc = func_80B123A8; + if (this->isFalling && (this->minigameType == SYATEKI_MINIGAME_ARCHERY) && + (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { + this->isFalling = false; + this->actionFunc = EnSyatekiNiw_SetupArchery; return; } - sp4A = 0; - if ((this->unk_25E == 0) && (this->unk_25C == 0)) { - this->unk_294++; - if (this->unk_294 >= 8) { - this->unk_25E = Rand_ZeroFloat(30.0f); - this->unk_294 = Rand_ZeroFloat(3.99f); + animationType = 0; + if ((this->movementTimer == 0) && (this->hopTimer == 0)) { + this->targetPosTimer++; + if (this->targetPosTimer >= 8) { + this->movementTimer = Rand_ZeroFloat(30.0f); + this->targetPosTimer = Rand_ZeroFloat(3.99f); - switch (this->unk_29E) { - case 0: - sp50 = Rand_CenteredFloat(100.0f); - if (sp50 < 0.0f) { - sp50 -= 100.0f; + switch (this->minigameType) { + case SYATEKI_MINIGAME_ARCHERY: + posXMod = Rand_CenteredFloat(100.0f); + if (posXMod < 0.0f) { + posXMod -= 100.0f; } else { - sp50 += 100.0f; + posXMod += 100.0f; } - sp4C = Rand_CenteredFloat(100.0f); - if (sp4C < 0.0f) { - sp4C -= 100.0f; + posZMod = Rand_CenteredFloat(100.0f); + if (posZMod < 0.0f) { + posZMod -= 100.0f; } else { - sp4C += 100.0f; + posZMod += 100.0f; } - this->unk_2E8.x = this->unk_2DC.x + sp50; - this->unk_2E8.z = this->unk_2DC.z + sp4C; + this->targetPos.x = this->initPos.x + posXMod; + this->targetPos.z = this->initPos.z + posZMod; - if (this->unk_2E8.x < -150.0f) { - this->unk_2E8.x = -150.0f; + if (this->targetPos.x < -150.0f) { + this->targetPos.x = -150.0f; } - if (this->unk_2E8.x > 150.0f) { - this->unk_2E8.x = 150.0f; + if (this->targetPos.x > 150.0f) { + this->targetPos.x = 150.0f; } - if (this->unk_2E8.z < -60.0f) { - this->unk_2E8.z = -60.0f; + if (this->targetPos.z < -60.0f) { + this->targetPos.z = -60.0f; } - if (this->unk_2E8.z > -40.0f) { - this->unk_2E8.z = -40.0f; + if (this->targetPos.z > -40.0f) { + this->targetPos.z = -40.0f; } break; - case 1: - sp50 = Rand_CenteredFloat(50.0f); - if (sp50 < 0.0f) { - sp50 -= 50.0f; + case SYATEKI_MINIGAME_ALLEY: + posXMod = Rand_CenteredFloat(50.0f); + if (posXMod < 0.0f) { + posXMod -= 50.0f; } else { - sp50 += 50.0f; + posXMod += 50.0f; } - sp4C = Rand_CenteredFloat(30.0f); - if (sp4C < 0.0f) { - sp4C -= 30.0f; + posZMod = Rand_CenteredFloat(30.0f); + if (posZMod < 0.0f) { + posZMod -= 30.0f; } else { - sp4C += 30.0f; + posZMod += 30.0f; } - this->unk_2E8.x = this->unk_2DC.x + sp50; - this->unk_2E8.z = this->unk_2DC.z + sp4C; + this->targetPos.x = this->initPos.x + posXMod; + this->targetPos.z = this->initPos.z + posZMod; break; } } else { - this->unk_25C = 4; + this->hopTimer = 4; if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->actor.velocity.y = 2.5f; - if ((Rand_ZeroFloat(10.0f) < 1.0f) && (this->unk_29E == 0)) { - this->unk_25C = 0xC; + if ((Rand_ZeroFloat(10.0f) < 1.0f) && (this->minigameType == SYATEKI_MINIGAME_ARCHERY)) { + this->hopTimer = 12; this->actor.velocity.y = 10.0f; } } } } - if (this->unk_25C != 0) { - sp4A = 1; - Math_ApproachF(&this->actor.world.pos.x, this->unk_2E8.x, 1.0f, this->unk_2C8.y); - Math_ApproachF(&this->actor.world.pos.z, this->unk_2E8.z, 1.0f, this->unk_2C8.y); - Math_ApproachF(&this->unk_2C8.y, 3.0f, 1.0f, 0.3f); - tmpf1 = this->unk_2E8.x - this->actor.world.pos.x; - tmpf2 = this->unk_2E8.z - this->actor.world.pos.z; + if (this->hopTimer != 0) { + animationType = 1; + Math_ApproachF(&this->actor.world.pos.x, this->targetPos.x, 1.0f, this->posRotStep.y); + Math_ApproachF(&this->actor.world.pos.z, this->targetPos.z, 1.0f, this->posRotStep.y); + Math_ApproachF(&this->posRotStep.y, 3.0f, 1.0f, 0.3f); + posXDiff = this->targetPos.x - this->actor.world.pos.x; + posZDiff = this->targetPos.z - this->actor.world.pos.z; - if (fabsf(tmpf1) < 10.0f) { - tmpf1 = 0; + if (fabsf(posXDiff) < 10.0f) { + posXDiff = 0; } - if (fabsf(tmpf2) < 10.0f) { - tmpf2 = 0.0f; + if (fabsf(posZDiff) < 10.0f) { + posZDiff = 0.0f; } - if ((tmpf1 == 0.0f) && (tmpf2 == 0.0f)) { - this->unk_25C = 0; - this->unk_294 = 7; + if ((posXDiff == 0.0f) && (posZDiff == 0.0f)) { + this->hopTimer = 0; + this->targetPosTimer = 7; } - Math_SmoothStepToS(&this->actor.world.rot.y, RAD_TO_BINANG(Math_FAtan2F(tmpf1, tmpf2)), 3, this->unk_2C8.z, 0); - Math_ApproachF(&this->unk_2C8.z, 10000.0f, 1.0f, 1000.0f); + Math_SmoothStepToS(&this->actor.world.rot.y, RAD_TO_BINANG(Math_FAtan2F(posXDiff, posZDiff)), 3, + this->posRotStep.z, 0); + Math_ApproachF(&this->posRotStep.z, 10000.0f, 1.0f, 1000.0f); } - if (this->unk_260 == 0) { - func_80B11A94(this, play, sp4A); - return; - } - - if ((play->gameplayFrames % 4) == 0) { + if (this->sootTimer == 0) { + EnSyatekiNiw_UpdateRotations(this, play, animationType); + } else if ((play->gameplayFrames % 4) == 0) { // draw smoke from bombchu hit dustVelocity.y = Rand_CenteredFloat(5.0f); dustAccel.y = 0.2f; dustPos = this->actor.world.pos; @@ -345,54 +344,54 @@ void func_80B11E78(EnSyatekiNiw* this, PlayState* play) { } } -void func_80B123A8(EnSyatekiNiw* this, PlayState* play) { +void EnSyatekiNiw_SetupArchery(EnSyatekiNiw* this, PlayState* play) { Animation_Change(&this->skelAnime, &gCuccoAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gCuccoAnim), ANIMMODE_LOOP, -10.0f); - this->unk_27C = 6000.0f; - this->unk_288 = -10000.0f; - this->unk_2B0.z = 6000.0f; - this->unk_2B0.y = 10000.0f; - this->actionFunc = func_80B12460; - this->unk_2A4.z = 6000.0f; - this->unk_284 = 6000.0f; - this->unk_2B0.x = -10000.0f; - this->unk_268 = -10000.0f; - this->unk_2A4.y = -10000.0f; - this->unk_2A4.x = -10000.0f; - this->unk_26C = -10000.0f; + this->rightWingRotZTarget = 6000.0f; + this->unkArcheryFloat = -10000.0f; + this->rightWingRot.z = 6000.0f; + this->rightWingRot.y = 10000.0f; + this->actionFunc = EnSyatekiNiw_Archery; + this->leftWingRot.z = 6000.0f; + this->leftWingRotZTarget = 6000.0f; + this->rightWingRot.x = -10000.0f; + this->rightWingRotXTarget = -10000.0f; + this->leftWingRot.y = -10000.0f; + this->leftWingRot.x = -10000.0f; + this->leftWingRotXTarget = -10000.0f; } -void func_80B12460(EnSyatekiNiw* this, PlayState* play) { +void EnSyatekiNiw_Archery(EnSyatekiNiw* this, PlayState* play) { Player* player = GET_PLAYER(play); - f32 phi_f16 = 0.0f; + f32 rotYTargetOffset = 0.0f; player->actor.freezeTimer = 10; - switch (this->unk_29A) { + switch (this->archeryState) { case 0: - this->unk_296 = 2; - this->unk_2C8.y = 0.0f; - this->unk_29A = 1; + this->archeryAnimationType = 2; + this->posRotStep.y = 0.0f; + this->archeryState = 1; break; case 1: this->actor.speed = 2.0f; - if (this->unk_25C == 0) { - this->unk_25C = 3; + if (this->hopTimer == 0) { + this->hopTimer = 3; this->actor.velocity.y = 3.5f; } - if (this->unk_25A == 0) { - this->unk_298++; - this->unk_298 &= 1; - this->unk_25A = 5; + if (this->archeryTimer == 0) { + this->rotYFlip++; + this->rotYFlip &= 1; + this->archeryTimer = 5; } - phi_f16 = (this->unk_298 == 0) ? 5000.0f : -5000.0f; + rotYTargetOffset = (this->rotYFlip == 0) ? 5000.0f : -5000.0f; if (this->actor.world.pos.z > 100.0f) { this->actor.speed = 2.0f; this->actor.gravity = -0.3f; this->actor.velocity.y = 5.0f; - this->unk_29A = 2; + this->archeryState = 2; } break; @@ -404,71 +403,71 @@ void func_80B12460(EnSyatekiNiw* this, PlayState* play) { if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->actor.world.pos.z > 110.0f)) { this->actor.velocity.y = 0.0f; this->actor.gravity = 0.0f; - this->unk_284 = 0.0f; - this->unk_27C = 0.0f; - this->unk_278 = 0.0f; - this->unk_280 = 0.0f; - this->unk_288 = 0.0f; + this->leftWingRotZTarget = 0.0f; + this->rightWingRotZTarget = 0.0f; + this->rightWingRotYTarget = 0.0f; + this->leftWingRotYTarget = 0.0f; + this->unkArcheryFloat = 0.0f; this->actor.speed = 0.5f; - this->unk_254 = this->unk_256 = 0; - this->unk_28E = this->unk_290 = 0; - this->unk_296 = 1; - this->unk_29A = 3; + this->peckTimer = this->timer1 = 0; + this->headRotXState = this->unk_290 = 0; + this->archeryAnimationType = 1; + this->archeryState = 3; } break; case 3: if ((player->actor.world.pos.z - 50.0f) < this->actor.world.pos.z) { this->actor.speed = 0.0f; - this->unk_262 = 0x3C; - this->unk_25A = 0x14; - this->unk_264 = 10000.0f; - this->unk_29A = 4; + this->cluckTimer = 60; + this->archeryTimer = 20; + this->headRotXTarget = 10000.0f; + this->archeryState = 4; } break; case 4: - if (this->unk_25A == 0) { - this->unk_296 = 4; - this->unk_264 = 5000.0f; - this->unk_26C = 0.0f; - this->unk_268 = 0.0f; - this->unk_284 = 0.0f; - this->unk_27C = 0.0f; - this->unk_280 = 14000.0f; - this->unk_278 = 14000.0f; + if (this->archeryTimer == 0) { + this->archeryAnimationType = 4; + this->headRotXTarget = 5000.0f; + this->leftWingRotXTarget = 0.0f; + this->rightWingRotXTarget = 0.0f; + this->leftWingRotZTarget = 0.0f; + this->rightWingRotZTarget = 0.0f; + this->leftWingRotYTarget = 14000.0f; + this->rightWingRotYTarget = 14000.0f; Actor_PlaySfx(&this->actor, NA_SE_EV_CHICKEN_CRY_M); - this->unk_254 = this->unk_256 = this->unk_25A = 0x1E; - this->unk_29A = 5; + this->peckTimer = this->timer1 = this->archeryTimer = 30; + this->archeryState = 5; } break; case 5: - if (this->unk_25A == 1) { - this->unk_258 = 0; - this->unk_296 = 5; - this->unk_256 = this->unk_258; - this->unk_254 = this->unk_258; + if (this->archeryTimer == 1) { + this->flapTimer = 0; + this->archeryAnimationType = 5; + this->timer1 = this->flapTimer; + this->peckTimer = this->flapTimer; this->actor.speed = 1.0f; } - if ((this->unk_25A == 0) && ((player->actor.world.pos.z - 30.0f) < this->actor.world.pos.z)) { + if ((this->archeryTimer == 0) && ((player->actor.world.pos.z - 30.0f) < this->actor.world.pos.z)) { Audio_PlaySfxGeneral(NA_SE_VO_LI_DOWN, &this->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); - this->unk_25E = 0x14; - this->unk_29A = 6; + this->movementTimer = 20; + this->archeryState = 6; this->actor.speed = 0.0f; } break; case 6: - if (this->unk_25E == 1) { + if (this->movementTimer == 1) { play->transitionTrigger = TRANS_TRIGGER_START; play->nextEntranceIndex = gSaveContext.save.entranceIndex; play->shootingGalleryStatus = 0; player->actor.freezeTimer = 20; - this->unk_25E = 0x14; - this->actionFunc = func_80B128D8; + this->movementTimer = 20; + this->actionFunc = EnSyatekiNiw_ExitArchery; } break; } @@ -476,94 +475,94 @@ void func_80B12460(EnSyatekiNiw* this, PlayState* play) { Math_SmoothStepToS(&this->actor.world.rot.y, RAD_TO_BINANG(Math_FAtan2F(player->actor.world.pos.x - this->actor.world.pos.x, player->actor.world.pos.z - this->actor.world.pos.z)) + - phi_f16, - 5, this->unk_2C8.y, 0); - Math_ApproachF(&this->unk_2C8.y, 3000.0f, 1.0f, 500.0f); - if (this->unk_296 == 2) { - this->unk_256 = 10; - this->unk_254 = this->unk_256; + rotYTargetOffset, + 5, this->posRotStep.y, 0); + Math_ApproachF(&this->posRotStep.y, 3000.0f, 1.0f, 500.0f); + if (this->archeryAnimationType == 2) { + this->peckTimer = this->timer1 = 10; } - func_80B11A94(this, play, this->unk_296); + EnSyatekiNiw_UpdateRotations(this, play, this->archeryAnimationType); } -void func_80B128D8(EnSyatekiNiw* this, PlayState* play) { - if (this->unk_25E == 1) { +void EnSyatekiNiw_ExitArchery(EnSyatekiNiw* this, PlayState* play) { + if (this->movementTimer == 1) { gSaveContext.timerState = TIMER_STATE_OFF; } } -void func_80B128F8(EnSyatekiNiw* this, PlayState* play) { - s16 sp26; - s16 sp24; +void EnSyatekiNiw_SetupRemove(EnSyatekiNiw* this, PlayState* play) { + s16 screenX; + s16 screenY; - Actor_SetFocus(&this->actor, this->unk_2D4); - Actor_GetScreenPos(play, &this->actor, &sp26, &sp24); - if ((this->actor.projectedPos.z > 200.0f) && (this->actor.projectedPos.z < 800.0f) && (sp26 > 0) && - (sp26 < SCREEN_WIDTH) && (sp24 > 0) && (sp24 < SCREEN_HEIGHT)) { + Actor_SetFocus(&this->actor, this->focusYOffset); + Actor_GetScreenPos(play, &this->actor, &screenX, &screenY); + if ((this->actor.projectedPos.z > 200.0f) && (this->actor.projectedPos.z < 800.0f) + && (screenX > 0) && (screenX < SCREEN_WIDTH) && (screenY > 0) + && (screenY < SCREEN_HEIGHT)) { this->actor.speed = 5.0f; - this->unk_298 = Rand_ZeroFloat(1.99f); - this->unk_2D8 = Rand_CenteredFloat(8000.0f) + -10000.0f; - this->unk_262 = 0x1E; - this->unk_25E = 0x64; - this->actionFunc = func_80B129EC; + this->rotYFlip = Rand_ZeroFloat(1.99f); + this->removeStateYaw = Rand_CenteredFloat(8000.0f) + -10000.0f; + this->cluckTimer = 30; + this->movementTimer = 100; + this->actionFunc = EnSyatekiNiw_Remove; } } -void func_80B129EC(EnSyatekiNiw* this, PlayState* play) { +void EnSyatekiNiw_Remove(EnSyatekiNiw* this, PlayState* play) { s32 pad; - f32 phi_f2; - s16 sp2E; - s16 sp2C; - f32 tmpf2; + f32 rotYTargetOffset; + s16 screenX; + s16 screenY; + f32 rotYTarget; - Actor_SetFocus(&this->actor, this->unk_2D4); - Actor_GetScreenPos(play, &this->actor, &sp2E, &sp2C); - if ((this->unk_25E == 0) || (this->actor.projectedPos.z < -70.0f) || (sp2E < 0) || (sp2E > SCREEN_WIDTH) || - (sp2C < 0) || (sp2C > SCREEN_HEIGHT)) { + Actor_SetFocus(&this->actor, this->focusYOffset); + Actor_GetScreenPos(play, &this->actor, &screenX, &screenY); + if ((this->movementTimer == 0) || (this->actor.projectedPos.z < -70.0f) || (screenX < 0) || + (screenX > SCREEN_WIDTH) || (screenY < 0) || (screenY > SCREEN_HEIGHT)) { Actor_Kill(&this->actor); return; } - this->unk_2A0 = 1; - if (this->unk_25C == 0) { - this->unk_298++; - this->unk_298 &= 1; - this->unk_25C = (s16)Rand_CenteredFloat(4.0f) + 5; + this->spawnFeathers = true; + if (this->hopTimer == 0) { + this->rotYFlip++; + this->rotYFlip &= 1; + this->hopTimer = (s16)Rand_CenteredFloat(4.0f) + 5; if ((Rand_ZeroFloat(5.0f) < 1.0f) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { this->actor.velocity.y = 4.0f; } } - phi_f2 = (this->unk_298 == 0) ? 5000.0f : -5000.0f; - tmpf2 = this->unk_2D8 + phi_f2; - Math_SmoothStepToS(&this->actor.world.rot.y, tmpf2, 3, this->unk_2C8.y, 0); - Math_ApproachF(&this->unk_2C8.y, 3000.0f, 1.0f, 500.0f); - func_80B11A94(this, play, 2); + rotYTargetOffset = (this->rotYFlip == 0) ? 5000.0f : -5000.0f; + rotYTarget = this->removeStateYaw + rotYTargetOffset; + Math_SmoothStepToS(&this->actor.world.rot.y, rotYTarget, 3, this->posRotStep.y, 0); + Math_ApproachF(&this->posRotStep.y, 3000.0f, 1.0f, 500.0f); + EnSyatekiNiw_UpdateRotations(this, play, 2); } -void func_80B12BA4(EnSyatekiNiw* this, PlayState* play) { +void EnSyatekiNiw_CheckHit(EnSyatekiNiw* this, PlayState* play) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; - switch (this->unk_29E) { - case 0: - if (this->unk_29C == 0) { - this->unk_262 = 0x1E; + switch (this->minigameType) { + case SYATEKI_MINIGAME_ARCHERY: + if (!this->isFalling) { + this->cluckTimer = 30; Actor_PlaySfx(&this->actor, NA_SE_EV_CHICKEN_CRY_A); - this->unk_29C = 1; - this->unk_2A0 = 1; - this->actionFunc = func_80B123A8; + this->isFalling = true; + this->spawnFeathers = true; + this->actionFunc = EnSyatekiNiw_SetupArchery; this->actor.gravity = -3.0f; } break; - case 1: - this->unk_262 = 0x1E; - this->unk_2F8 = 1; + case SYATEKI_MINIGAME_ALLEY: + this->cluckTimer = 30; + this->unkAlleyHitByte = 1; Actor_PlaySfx(&this->actor, NA_SE_EV_CHICKEN_CRY_A); - this->unk_260 = 100; - this->unk_2A0 = 1; - this->unk_25E = this->unk_260; + this->sootTimer = 100; + this->spawnFeathers = true; + this->movementTimer = this->sootTimer; break; } } @@ -575,42 +574,42 @@ void EnSyatekiNiw_Update(Actor* thisx, PlayState* play) { s16 i; Vec3f sp90 = { 0.0f, 0.0f, 0.0f }; Vec3f sp84 = { 0.0f, 0.0f, 0.0f }; - Vec3f sp78; - Vec3f sp6C; - Vec3f sp60; + Vec3f pos; + Vec3f vel; + Vec3f accel; if (1) {} if (1) {} if (1) {} EnSyatekiNiw_UpdateEffects(this, play); - this->unk_28C++; - if (this->unk_254 != 0) { - this->unk_254--; + this->lifetime++; + if (this->peckTimer != 0) { + this->peckTimer--; } - if (this->unk_258 != 0) { - this->unk_258--; + if (this->flapTimer != 0) { + this->flapTimer--; } - if (this->unk_25A != 0) { - this->unk_25A--; + if (this->archeryTimer != 0) { + this->archeryTimer--; } - if (this->unk_25C != 0) { - this->unk_25C--; + if (this->hopTimer != 0) { + this->hopTimer--; } - if (this->unk_25E != 0) { - this->unk_25E--; + if (this->movementTimer != 0) { + this->movementTimer--; } - if (this->unk_262 != 0) { - this->unk_262--; + if (this->cluckTimer != 0) { + this->cluckTimer--; } - if (this->unk_260 != 0) { - this->unk_260--; + if (this->sootTimer != 0) { + this->sootTimer--; } this->actor.shape.rot = this->actor.world.rot; @@ -622,47 +621,48 @@ void EnSyatekiNiw_Update(Actor* thisx, PlayState* play) { UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_3 | UPDBGCHECKINFO_FLAG_4); - if (this->unk_2A0 != 0) { + if (this->spawnFeathers) { for (i = 0; i < 20; i++) { - sp78.x = Rand_CenteredFloat(10.0f) + this->actor.world.pos.x; - sp78.y = Rand_CenteredFloat(10.0f) + (this->actor.world.pos.y + 20.0f); - sp78.z = Rand_CenteredFloat(10.0f) + this->actor.world.pos.z; - sp6C.x = Rand_CenteredFloat(3.0f); - sp6C.y = (Rand_ZeroFloat(2.0f) * 0.5f) + 2.0f; - sp6C.z = Rand_CenteredFloat(3.0f); - sp60.z = sp60.x = 0.0f; - sp60.y = -0.15f; - EnSyatekiNiw_SpawnFeather(this, &sp78, &sp6C, &sp60, Rand_ZeroFloat(8.0f) + 8.0f); + pos.x = Rand_CenteredFloat(10.0f) + this->actor.world.pos.x; + pos.y = Rand_CenteredFloat(10.0f) + (this->actor.world.pos.y + 20.0f); + pos.z = Rand_CenteredFloat(10.0f) + this->actor.world.pos.z; + vel.x = Rand_CenteredFloat(3.0f); + vel.y = (Rand_ZeroFloat(2.0f) * 0.5f) + 2.0f; + vel.z = Rand_CenteredFloat(3.0f); + accel.z = accel.x = 0.0f; + accel.y = -0.15f; + EnSyatekiNiw_SpawnFeather(this, &pos, &vel, &accel, Rand_ZeroFloat(8.0f) + 8.0f); } - this->unk_2A0 = 0; + this->spawnFeathers = false; } - func_80B12BA4(this, play); - if (this->unk_262 == 0) { - if (this->actionFunc == func_80B11E78) { - this->unk_262 = 0x12C; + EnSyatekiNiw_CheckHit(this, play); + if (this->cluckTimer == 0) { + if (this->actionFunc == EnSyatekiNiw_Default) { + this->cluckTimer = 300; Actor_PlaySfx(&this->actor, NA_SE_EV_CHICKEN_CRY_N); } else { - this->unk_262 = 0x1E; + this->cluckTimer = 30; Actor_PlaySfx(&this->actor, NA_SE_EV_CHICKEN_CRY_A); } } - i = 0; - switch (this->unk_29E) { - case 0: + // here, "i" doubles as boolean value. + i = false; + switch (this->minigameType) { + case SYATEKI_MINIGAME_ARCHERY: if (play->shootingGalleryStatus != 0) { - i = 1; + i = true; } break; - case 1: - i = 1; + case SYATEKI_MINIGAME_ALLEY: + i = true; break; } - if (i != 0) { + if (i) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); @@ -671,22 +671,22 @@ void EnSyatekiNiw_Update(Actor* thisx, PlayState* play) { s32 SyatekiNiw_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { EnSyatekiNiw* this = (EnSyatekiNiw*)thisx; - Vec3f sp0 = { 0.0f, 0.0f, 0.0f }; + Vec3f unusedZeroVec = { 0.0f, 0.0f, 0.0f }; if (limbIndex == 13) { - rot->y += (s16)this->unk_2BC.x; + rot->y += (s16)this->headRot.x; } if (limbIndex == 11) { - rot->x += (s16)this->unk_2B0.z; - rot->y += (s16)this->unk_2B0.y; - rot->z += (s16)this->unk_2B0.x; + rot->x += (s16)this->rightWingRot.z; + rot->y += (s16)this->rightWingRot.y; + rot->z += (s16)this->rightWingRot.x; } if (limbIndex == 7) { - rot->x += (s16)this->unk_2A4.z; - rot->y += (s16)this->unk_2A4.y; - rot->z += (s16)this->unk_2A4.x; + rot->x += (s16)this->leftWingRot.z; + rot->y += (s16)this->leftWingRot.y; + rot->z += (s16)this->leftWingRot.x; } return false; @@ -694,12 +694,12 @@ s32 SyatekiNiw_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec void EnSyatekiNiw_Draw(Actor* thisx, PlayState* play) { EnSyatekiNiw* this = (EnSyatekiNiw*)thisx; - Color_RGBA8 sp30 = { 0, 0, 0, 255 }; + Color_RGBA8 sootShade = { 0, 0, 0, 255 }; - if (this->actionFunc != func_80B128F8) { + if (this->actionFunc != EnSyatekiNiw_SetupRemove) { Gfx_SetupDL_25Opa(play->state.gfxCtx); - if (this->unk_260 != 0) { - func_80026230(play, &sp30, 0, 0x14); + if (this->sootTimer != 0) { + func_80026230(play, &sootShade, 0, 20); } SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, @@ -709,20 +709,20 @@ void EnSyatekiNiw_Draw(Actor* thisx, PlayState* play) { } } -void EnSyatekiNiw_SpawnFeather(EnSyatekiNiw* this, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, f32 arg4) { +void EnSyatekiNiw_SpawnFeather(EnSyatekiNiw* this, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 scale) { s16 i; EnSyatekiNiwEffect* effect = &this->effects[0]; for (i = 0; i < EN_SYATEKI_NIW_EFFECT_COUNT; i++, effect++) { - if (effect->unk_00 == 0) { - effect->unk_00 = 1; - effect->unk_04 = *arg1; - effect->unk_10 = *arg2; - effect->unk_1C = *arg3; - effect->unk_34 = 0; - effect->unk_2C = (arg4 / 1000.0f); - effect->unk_28 = (s16)Rand_ZeroFloat(20.0f) + 0x28; - effect->unk_2A = Rand_ZeroFloat(1000.0f); + if (effect->state == 0) { + effect->state = 1; + effect->pos = *pos; + effect->vel = *vel; + effect->accel = *accel; + effect->timer = 0; + effect->scale = (scale / 1000.0f); + effect->lifespan = (s16)Rand_ZeroFloat(20.0f) + 40; + effect->rotPulse = Rand_ZeroFloat(1000.0f); return; } } @@ -733,25 +733,25 @@ void EnSyatekiNiw_UpdateEffects(EnSyatekiNiw* this, PlayState* play) { EnSyatekiNiwEffect* effect = &this->effects[0]; for (i = 0; i < EN_SYATEKI_NIW_EFFECT_COUNT; i++, effect++) { - if (effect->unk_00 != 0) { - effect->unk_04.x += effect->unk_10.x; - effect->unk_04.y += effect->unk_10.y; - effect->unk_04.z += effect->unk_10.z; - effect->unk_34++; - effect->unk_10.x += effect->unk_1C.x; - effect->unk_10.y += effect->unk_1C.y; - effect->unk_10.z += effect->unk_1C.z; - if (effect->unk_00 == 1) { - effect->unk_2A++; - Math_ApproachF(&effect->unk_10.x, 0.0f, 1.0f, 0.05f); - Math_ApproachF(&effect->unk_10.z, 0.0f, 1.0f, 0.05f); - if (effect->unk_10.y < -0.5f) { - effect->unk_10.y = 0.5f; + if (effect->state != 0) { + effect->pos.x += effect->vel.x; + effect->pos.y += effect->vel.y; + effect->pos.z += effect->vel.z; + effect->timer++; + effect->vel.x += effect->accel.x; + effect->vel.y += effect->accel.y; + effect->vel.z += effect->accel.z; + if (effect->state == 1) { + effect->rotPulse++; + Math_ApproachF(&effect->vel.x, 0.0f, 1.0f, 0.05f); + Math_ApproachF(&effect->vel.z, 0.0f, 1.0f, 0.05f); + if (effect->vel.y < -0.5f) { + effect->vel.y = 0.5f; } - effect->unk_30 = (Math_SinS(effect->unk_2A * 3000) * M_PI) * 0.2f; - if (effect->unk_28 < effect->unk_34) { - effect->unk_00 = 0; + effect->rot = (Math_SinS(effect->rotPulse * 3000) * M_PI) * 0.2f; + if (effect->lifespan < effect->timer) { + effect->state = 0; } } } @@ -769,16 +769,16 @@ void EnSyatekiNiw_DrawEffects(EnSyatekiNiw* this, PlayState* play) { Gfx_SetupDL_25Xlu(play->state.gfxCtx); for (i = 0; i < EN_SYATEKI_NIW_EFFECT_COUNT; i++, effect++) { - if (effect->unk_00 == 1) { + if (effect->state == 1) { if (materialFlag == 0) { gSPDisplayList(POLY_XLU_DISP++, gCuccoEffectFeatherMaterialDL); materialFlag++; } - Matrix_Translate(effect->unk_04.x, effect->unk_04.y, effect->unk_04.z, MTXMODE_NEW); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&play->billboardMtxF); - Matrix_Scale(effect->unk_2C, effect->unk_2C, 1.0f, MTXMODE_APPLY); - Matrix_RotateZ(effect->unk_30, MTXMODE_APPLY); + Matrix_Scale(effect->scale, effect->scale, 1.0f, MTXMODE_APPLY); + Matrix_RotateZ(effect->rot, MTXMODE_APPLY); Matrix_Translate(0.0f, -1000.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_syateki_niw.c", 1251), diff --git a/src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.h b/src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.h index 26e6449aab..5f1cfcf723 100644 --- a/src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.h +++ b/src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.h @@ -9,15 +9,15 @@ struct EnSyatekiNiw; typedef void (*EnSyatekiNiwActionFunc)(struct EnSyatekiNiw*, PlayState*); typedef struct { - /* 0x00 */ u8 unk_00; - /* 0x0C */ Vec3f unk_04; - /* 0x10 */ Vec3f unk_10; - /* 0x1C */ Vec3f unk_1C; - /* 0x28 */ s16 unk_28; - /* 0x2A */ s16 unk_2A; - /* 0x2C */ f32 unk_2C; - /* 0x30 */ f32 unk_30; - /* 0x34 */ u8 unk_34; + /* 0x00 */ u8 state; + /* 0x0C */ Vec3f pos; + /* 0x10 */ Vec3f vel; + /* 0x1C */ Vec3f accel; + /* 0x28 */ s16 lifespan; + /* 0x2A */ s16 rotPulse; + /* 0x2C */ f32 scale; + /* 0x30 */ f32 rot; + /* 0x34 */ u8 timer; } EnSyatekiNiwEffect; // size = 0x38 #define EN_SYATEKI_NIW_EFFECT_COUNT 5 @@ -28,46 +28,51 @@ typedef struct EnSyatekiNiw { /* 0x0190 */ Vec3s jointTable[16]; /* 0x01F0 */ Vec3s morphTable[16]; /* 0x0250 */ EnSyatekiNiwActionFunc actionFunc; - /* 0x0254 */ s16 unk_254; - /* 0x0256 */ s16 unk_256; - /* 0x0258 */ s16 unk_258; - /* 0x025A */ s16 unk_25A; - /* 0x025C */ s16 unk_25C; - /* 0x025E */ s16 unk_25E; - /* 0x0260 */ s16 unk_260; - /* 0x0262 */ s16 unk_262; - /* 0x0264 */ f32 unk_264; - /* 0x0268 */ f32 unk_268; - /* 0x026C */ f32 unk_26C; + /* 0x0254 */ s16 peckTimer; // intervals of bobbing head on ground + /* 0x0256 */ s16 timer1; // sometimes set alongside peckTimer, never read. + /* 0x0258 */ s16 flapTimer; // intervals of beating wings + /* 0x025A */ s16 archeryTimer; + /* 0x025C */ s16 hopTimer; // intervals of jumping + /* 0x025E */ s16 movementTimer; // intervals of changing location + /* 0x0260 */ s16 sootTimer; // cucco is covered in soot, smoke emmits + /* 0x0262 */ s16 cluckTimer; // intervals of clucking SFX + /* 0x0264 */ f32 headRotXTarget; + /* 0x0268 */ f32 rightWingRotXTarget; + /* 0x026C */ f32 leftWingRotXTarget; /* 0x0270 */ char unk_270[0x8]; - /* 0x0278 */ f32 unk_278; - /* 0x027C */ f32 unk_27C; - /* 0x0284 */ f32 unk_280; - /* 0x0280 */ f32 unk_284; - /* 0x0288 */ f32 unk_288; - /* 0x028C */ s16 unk_28C; - /* 0x028E */ s16 unk_28E; - /* 0x0290 */ s16 unk_290; - /* 0x0292 */ s16 unk_292; - /* 0x0294 */ s16 unk_294; - /* 0x0296 */ s16 unk_296; - /* 0x0298 */ s16 unk_298; - /* 0x029C */ s16 unk_29A; - /* 0x029C */ s16 unk_29C; - /* 0x029E */ s16 unk_29E; - /* 0x02A0 */ s16 unk_2A0; - /* 0x02A4 */ Vec3f unk_2A4; - /* 0x02B0 */ Vec3f unk_2B0; - /* 0x02BC */ Vec3f unk_2BC; - /* 0x02C8 */ Vec3f unk_2C8; - /* 0x02D4 */ f32 unk_2D4; - /* 0x02D8 */ f32 unk_2D8; - /* 0x02DC */ Vec3f unk_2DC; - /* 0x02E8 */ Vec3f unk_2E8; - /* 0x02F4 */ f32 unk_2F4; - /* 0x02F8 */ u8 unk_2F8; + /* 0x0278 */ f32 rightWingRotYTarget; + /* 0x027C */ f32 rightWingRotZTarget; + /* 0x0284 */ f32 leftWingRotYTarget; + /* 0x0280 */ f32 leftWingRotZTarget; + /* 0x0288 */ f32 unkArcheryFloat; // set, but never used. another rot target? + /* 0x028C */ s16 lifetime; // always ticks up, never read + /* 0x028E */ s16 headRotXState; + /* 0x0290 */ s16 unk_290; // set to 0, never read. + /* 0x0292 */ s16 wingsRotState; + /* 0x0294 */ s16 targetPosTimer; + /* 0x0296 */ s16 archeryAnimationType; + /* 0x0298 */ s16 rotYFlip; + /* 0x029C */ s16 archeryState; // state index for "Archery" action + /* 0x029C */ s16 isFalling; // set when hit in archery game + /* 0x029E */ s16 minigameType; // uses EnSyatekiMinigame from params + /* 0x02A0 */ s16 spawnFeathers; // triggers feather particles + /* 0x02A4 */ Vec3f leftWingRot; + /* 0x02B0 */ Vec3f rightWingRot; + /* 0x02BC */ Vec3f headRot; + /* 0x02C8 */ Vec3f posRotStep; + /* 0x02D4 */ f32 focusYOffset; + /* 0x02D8 */ f32 removeStateYaw; + /* 0x02DC */ Vec3f initPos; + /* 0x02E8 */ Vec3f targetPos; + /* 0x02F4 */ f32 scale; + /* 0x02F8 */ u8 unkAlleyHitByte; // Set when hit in Bombchu Alley. Never read. /* 0x02FC */ ColliderCylinder collider; - /* 0x0348 */ EnSyatekiNiwEffect effects[EN_SYATEKI_NIW_EFFECT_COUNT]; + /* 0x0348 */ EnSyatekiNiwEffect effects[EN_SYATEKI_NIW_EFFECT_COUNT]; // feather particles } EnSyatekiNiw; // size = 0x0460 +typedef enum { + SYATEKI_MINIGAME_ARCHERY, // unused archery game behavior + SYATEKI_MINIGAME_ALLEY // Bombchu Alley behavior +} EnSyatekiMinigame; + #endif diff --git a/src/overlays/actors/ovl_En_Test/z_en_test.c b/src/overlays/actors/ovl_En_Test/z_en_test.c index 9f6b744379..a51c4d133d 100644 --- a/src/overlays/actors/ovl_En_Test/z_en_test.c +++ b/src/overlays/actors/ovl_En_Test/z_en_test.c @@ -1592,7 +1592,7 @@ void func_8086318C(EnTest* this, PlayState* play) { void EnTest_SetupRecoil(EnTest* this) { this->swordState = 0; - this->skelAnime.moveFlags = 2; + this->skelAnime.moveFlags = ANIM_FLAG_UPDATE_Y; this->unk_7C8 = 0x13; this->skelAnime.playSpeed = -1.0f; this->skelAnime.startFrame = this->skelAnime.curFrame; diff --git a/src/overlays/actors/ovl_En_Xc/z_en_xc.c b/src/overlays/actors/ovl_En_Xc/z_en_xc.c index 48c0159837..f6138cc691 100644 --- a/src/overlays/actors/ovl_En_Xc/z_en_xc.c +++ b/src/overlays/actors/ovl_En_Xc/z_en_xc.c @@ -249,25 +249,25 @@ void func_80B3C8CC(EnXc* this, PlayState* play) { SkelAnime* skelAnime = &this->skelAnime; if (skelAnime->jointTable[0].y >= skelAnime->baseTransl.y) { - skelAnime->moveFlags |= 3; + skelAnime->moveFlags |= ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y; AnimationContext_SetMoveActor(play, &this->actor, skelAnime, 1.0f); } } void func_80B3C924(EnXc* this, PlayState* play) { - this->skelAnime.moveFlags |= 3; + this->skelAnime.moveFlags |= ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y; AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, 1.0f); } void func_80B3C964(EnXc* this, PlayState* play) { this->skelAnime.baseTransl = this->skelAnime.jointTable[0]; this->skelAnime.prevTransl = this->skelAnime.jointTable[0]; - this->skelAnime.moveFlags |= 3; + this->skelAnime.moveFlags |= ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y; AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, 1.0f); } void func_80B3C9DC(EnXc* this) { - this->skelAnime.moveFlags &= ~0x3; + this->skelAnime.moveFlags &= ~(ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y); } void func_80B3C9EC(EnXc* this) { diff --git a/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c b/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c index 93e742927a..680d3183a3 100644 --- a/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c +++ b/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c @@ -345,7 +345,7 @@ void func_80B4B834(CsCmdActorCue* cue, Vec3f* dest) { } void func_80B4B874(EnZl1* this, PlayState* play) { - this->skelAnime.moveFlags |= 1; + this->skelAnime.moveFlags |= ANIM_FLAG_0; AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, 1.0f); } diff --git a/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c b/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c index af279524f8..1d4f87d0e2 100644 --- a/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c +++ b/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c @@ -298,7 +298,7 @@ void EnZl4_UpdateFace(EnZl4* this) { } void EnZl4_SetMove(EnZl4* this, PlayState* play) { - this->skelAnime.moveFlags |= 1; + this->skelAnime.moveFlags |= ANIM_FLAG_0; AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, 1.0f); } diff --git a/src/overlays/actors/ovl_Fishing/z_fishing.c b/src/overlays/actors/ovl_Fishing/z_fishing.c index 6f8629384d..ff5ed8eb42 100644 --- a/src/overlays/actors/ovl_Fishing/z_fishing.c +++ b/src/overlays/actors/ovl_Fishing/z_fishing.c @@ -22,10 +22,10 @@ void Fishing_DrawFish(Actor* thisx, PlayState* play); void Fishing_DrawOwner(Actor* thisx, PlayState* play); typedef struct { - /* 0x00 */ u8 unk_00; + /* 0x00 */ u8 isLoach; /* 0x02 */ Vec3s pos; - /* 0x08 */ u8 unk_08; - /* 0x0C */ f32 unk_0C; + /* 0x08 */ u8 baseLength; + /* 0x0C */ f32 perception; } FishingFishInit; // size = 0x10 typedef enum { @@ -50,12 +50,10 @@ typedef struct { /* 0x25 */ u8 timer; /* 0x26 */ char unk_26[0x04]; /* 0x2A */ s16 alpha; - /* 0x2C */ s16 unk_2C; - /* 0x2E */ s16 unk_2E; - /* 0x30 */ f32 unk_30; - /* 0x34 */ f32 unk_34; - /* 0x38 */ f32 unk_38; - /* 0x3C */ f32 unk_3C; + /* 0x2C */ s16 state; + /* 0x2E */ s16 alphaMax; + /* 0x30 */ f32 scale; + /* 0x34 */ Vec3f rot; } FishingEffect; // size = 0x40 #define POND_PROP_COUNT 140 @@ -100,10 +98,10 @@ typedef struct { /* 0x00 */ u8 type; /* 0x02 */ s16 timer; /* 0x04 */ Vec3f pos; - /* 0x10 */ Vec3f unk_10; + /* 0x10 */ Vec3f homePos; /* 0x1C */ Vec3f projectedPos; - /* 0x28 */ f32 unk_28; - /* 0x2C */ f32 unk_2C; + /* 0x28 */ f32 velY; + /* 0x2C */ f32 scaleX; /* 0x30 */ f32 unk_30; /* 0x34 */ f32 unk_34; /* 0x38 */ f32 unk_38; @@ -114,6 +112,12 @@ typedef struct { /* 0x44 */ u8 shouldDraw; } FishingGroupFish; // size = 0x48 +typedef enum { + /* 0x00 */ FS_LURE_STOCK, + /* 0x01 */ FS_LURE_UNK, // hinted at with an "== 1" + /* 0x02 */ FS_LURE_SINKING +} FishingLureTypes; + #define LINE_SEG_COUNT 200 #define SINKING_LURE_SEG_COUNT 20 @@ -129,41 +133,47 @@ ActorInit Fishing_InitVars = { (ActorFunc)Fishing_DrawFish, }; -static f32 D_80B7A650 = 0.0f; +static f32 sStormStrength = 0.0f; -static u8 D_80B7A654 = 0; +static u8 sStormStrengthTarget = 0; -static f32 D_80B7A658 = 0.0f; +static f32 sFishingStormShade = 0.0f; -static Vec3f D_80B7A65C = { 0.0f, 0.0f, 0.0f }; +static Vec3f sFishingStormSfxPos = { 0.0f, 0.0f, 0.0f }; -static f32 D_80B7A668 = 0.0f; +static f32 sStormSfxFreqScale = 0.0f; static u8 sSinkingLureLocation = 0; -static f32 D_80B7A670 = 0.0f; +static f32 sFishOnHandLength = 0.0f; -static u8 D_80B7A674 = true; +static u8 sIsRodVisible = true; -static u16 D_80B7A678 = 0; +static u16 sFishLengthToWeigh = 0; -static u8 D_80B7A67C = 0; +static u8 sFishingCaughtTextDelay = 0; -static s32 D_80B7A680 = 0; +static s32 sFishingTimePlayed = 0; -static s16 D_80B7A684 = 0; +static s16 sOwnerTheftTimer = 0; -static u8 D_80B7A688 = 0; -static u8 D_80B7A68C = 0; -static u8 D_80B7A690 = 0; +typedef enum { + /* 0x00 */ FS_OWNER_BALD, + /* 0x01 */ FS_OWNER_CAPPED, + /* 0x02 */ FS_OWNER_HAIR +} FishingOwnerHair; -static s16 D_80B7A694 = 0; +static u8 sOwnerHair = FS_OWNER_BALD; +static u8 sIsOwnersHatHooked = false; // hat is on fishing hook +static u8 sIsOwnersHatSunk = false; // hat is sinking into pond. + +static s16 sRodCastState = 0; static Vec3f sFishMouthOffset = { 500.0f, 500.0f, 0.0f }; static u8 D_80B7A6A4 = 0; -static f32 D_80B7A6A8 = 0.0f; +static f32 sRodBendRotY = 0.0f; static f32 D_80B7A6AC = 0.0f; static f32 D_80B7A6B0 = 0.0f; static f32 D_80B7A6B4 = 0.0f; @@ -171,12 +181,12 @@ static f32 D_80B7A6B8 = 0.0f; static f32 D_80B7A6BC = 0.0f; static f32 D_80B7A6C0 = 0.0f; -static s16 D_80B7A6C4 = 0; -static s16 D_80B7A6C8 = 0; +static s16 sStickAdjXPrev = 0; +static s16 sStickAdjYPrev = 0; -static u8 D_80B7A6CC = 0; -static u8 D_80B7A6D0 = 0; -static u8 D_80B7A6D4 = 0; +static u8 sFishingPlayerCinematicState = 0; +static u8 sFishingCinematicTimer = 0; +static u8 sSinkingLureFound = false; static ColliderJntSphElementInit sJntSphElementsInit[12] = { { @@ -326,81 +336,81 @@ static ColliderJntSphInit sJntSphInit = { sJntSphElementsInit, }; -static f32 D_80B7A898 = 0.0f; +static f32 sFishGroupVar = 0.0f; static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; -static Vec3f D_80B7A8A8 = { 0.0f, 0.0f, 2000.0f }; +static Vec3f sUnusedVec = { 0.0f, 0.0f, 2000.0f }; static Fishing* sFishingMain; -static u8 D_80B7E074; +static u8 sReelLock; static u8 sLinkAge; -static u8 D_80B7E076; -static u8 D_80B7E077; -static f32 D_80B7E078; -static u8 D_80B7E07C; -static u8 D_80B7E07D; -static u8 D_80B7E07E; -static s16 D_80B7E080; -static u8 D_80B7E082; -static u16 D_80B7E084; -static u16 D_80B7E086; -static s8 D_80B7E088; +static u8 sFishingFoggy; +static u8 sStormChanceTimer; +static f32 sFishingRecordLength; +static u8 sFishOnHandIsLoach; +static u8 sFishGameNumber; // increments for each purchased play. effects weather +static u8 sLureCaughtWith; +static s16 sFishFightTime; +static u8 sPondOwnerTextIdIndex; +static u16 sFishesCaught; +static u16 sFishingCaughtTextId; +static s8 sLureCameraZoomLevel; static Vec3f sOwnerHeadPos; -static Vec3s sEffOwnerHatRot; -static u8 D_80B7E0A2; -static s16 D_80B7E0A4; -static s16 D_80B7E0A6; +static Vec3s sEffOwnersHatRot; +static u8 sLureMoveDelay; // a small delay between the lure hitting the water, and being able to reel. +static s16 sRumbleDelay; +static s16 sFishingMusicDelay; static Fishing* sFishingHookedFish; -static s16 D_80B7E0AC; -static s16 D_80B7E0AE; +static s16 sFishingPlayingState; +static s16 sLureTimer; // AND'd for various effects/checks static s16 D_80B7E0B0; static s16 D_80B7E0B2; -static s16 D_80B7E0B4; -static u8 D_80B7E0B6; +static s16 sRodCastTimer; // used for the inital line casting +static u8 sLureEquipped; static Vec3f sLurePos; -static Vec3f D_80B7E0C8; +static Vec3f sLureDrawPos; static Vec3f sLureRot; -static Vec3f D_80B7E0E8; -static Vec3f D_80B7E0F8; -static f32 D_80B7E104; -static f32 D_80B7E108; -static f32 D_80B7E10C; -static f32 D_80B7E110; +static Vec3f sLurePosDelta; +static Vec3f sLureCastDelta; +static f32 sLure1Rotate; // lure type 1 is programmed to change this. +static f32 sLurePosZOffset; +static f32 sLureRotXTarget; +static f32 sLureRotXStep; static s8 D_80B7E114; -static s16 D_80B7E116; +static s16 sRodPullback; // holding A+Down to keep the fish on line static u8 D_80B7E118; -static f32 D_80B7E11C; -static u8 D_80B7E120; -static s16 D_80B7E122; -static u8 D_80B7E124; -static Vec3f D_80B7E128; -static f32 D_80B7E134; -static f32 D_80B7E138; -static s16 D_80B7E13C; -static f32 D_80B7E140; -static f32 D_80B7E144; +static f32 sRodReelingSpeed; +static u8 sWiggleAttraction; +static s16 sLureBitTimer; +static u8 sLineHooked; +static Vec3f sLureLineSegPosDelta; +static f32 sLureWiggleRotYTarget; +static f32 sLureWigglePosY; +static s16 sLureWiggleRotY; +static f32 sLureWiggleSign; // +/-1.0f +static f32 sRodLineSpooled; // 200 represents the full spool. static f32 D_80B7E148; -static f32 D_80B7E14C; +static f32 sFishingLineScale; static s16 D_80B7E150; -static f32 D_80B7E154; +static f32 sReelLinePosStep; static Vec3f sRodTipPos; static Vec3f sReelLinePos[LINE_SEG_COUNT]; static Vec3f sReelLineRot[LINE_SEG_COUNT]; static Vec3f sReelLineUnk[LINE_SEG_COUNT]; static Vec3f sLureHookRefPos[2]; static f32 sLureHookRotY[2]; -static u8 D_80B7FDA8; +static u8 sRodHitTimer; // brief timer for bending rod when line is snapped static Vec3f sSinkingLurePos[SINKING_LURE_SEG_COUNT]; -static s16 D_80B7FEA0; +static s16 sSinkingLureSegmentIndex; static f32 sProjectedW; static Vec3f sSubCamEye; static Vec3f sSubCamAt; static s16 sSubCamId; -static f32 D_80B7FEC8; +static f32 sCatchCamX; static f32 sSubCamVelFactor; static f32 D_80B7FED0; static Vec3f sSinkingLureBasePos; -static f32 D_80B7FEE4; +static f32 sSinkingLureHeldY; // the lure going to its mark when being held up. static s32 sRandSeed0; static s32 sRandSeed1; static s32 sRandSeed2; @@ -462,7 +472,7 @@ s16 Fishing_SmoothStepToS(s16* pValue, s16 target, s16 scale, s16 step) { return stepSize; } -void Fishing_SpawnRipple(Vec3f* projectedPos, FishingEffect* effect, Vec3f* pos, f32 arg3, f32 arg4, s16 arg5, +void Fishing_SpawnRipple(Vec3f* projectedPos, FishingEffect* effect, Vec3f* pos, f32 scale, f32 rotX, s16 alpha, s16 countLimit) { s16 i; @@ -476,18 +486,18 @@ void Fishing_SpawnRipple(Vec3f* projectedPos, FishingEffect* effect, Vec3f* pos, effect->pos = *pos; effect->vel = sZeroVec; effect->accel = sZeroVec; - effect->unk_30 = arg3 * 0.0025f; - effect->unk_34 = arg4 * 0.0025f; + effect->scale = scale * 0.0025f; + effect->rot.x = rotX * 0.0025f; - if (arg3 > 300.0f) { + if (scale > 300.0f) { effect->alpha = 0; - effect->unk_2E = arg5; - effect->unk_2C = 0; - effect->unk_38 = (effect->unk_34 - effect->unk_30) * 0.05f; + effect->alphaMax = alpha; + effect->state = 0; + effect->rot.y = (effect->rot.x - effect->scale) * 0.05f; } else { - effect->alpha = arg5; - effect->unk_2C = 1; - effect->unk_38 = (effect->unk_34 - effect->unk_30) * 0.1f; + effect->alpha = alpha; + effect->state = 1; + effect->rot.y = (effect->rot.x - effect->scale) * 0.1f; } break; } @@ -512,7 +522,7 @@ void Fishing_SpawnDustSplash(Vec3f* projectedPos, FishingEffect* effect, Vec3f* effect->vel = *vel; effect->accel = accel; effect->alpha = 100 + (s16)Rand_ZeroFloat(100.0f); - effect->unk_30 = scale; + effect->scale = scale; break; } @@ -536,8 +546,8 @@ void Fishing_SpawnWaterDust(Vec3f* projectedPos, FishingEffect* effect, Vec3f* p effect->accel = accel; effect->alpha = 255; effect->timer = (s16)Rand_ZeroFloat(100.0f); - effect->unk_30 = scale; - effect->unk_34 = 2.0f * scale; + effect->scale = scale; + effect->rot.x = 2.0f * scale; break; } @@ -545,7 +555,7 @@ void Fishing_SpawnWaterDust(Vec3f* projectedPos, FishingEffect* effect, Vec3f* p } } -void Fishing_SpawnBubble(Vec3f* projectedPos, FishingEffect* effect, Vec3f* pos, f32 scale, u8 arg4) { +void Fishing_SpawnBubble(Vec3f* projectedPos, FishingEffect* effect, Vec3f* pos, f32 scale, u8 state) { s16 i; Vec3f vel = { 0.0f, 1.0f, 0.0f }; @@ -560,8 +570,8 @@ void Fishing_SpawnBubble(Vec3f* projectedPos, FishingEffect* effect, Vec3f* pos, effect->vel = vel; effect->accel = sZeroVec; effect->timer = (s16)Rand_ZeroFloat(100.0f); - effect->unk_30 = scale; - effect->unk_2C = arg4; + effect->scale = scale; + effect->state = state; break; } @@ -584,9 +594,9 @@ void Fishing_SpawnRainDrop(FishingEffect* effect, Vec3f* pos, Vec3f* rot) { effect->type = FS_EFF_RAIN_DROP; effect->pos = *pos; effect->accel = sZeroVec; - effect->unk_34 = rot->x; - effect->unk_38 = rot->y; - effect->unk_3C = rot->z; + effect->rot.x = rot->x; + effect->rot.y = rot->y; + effect->rot.z = rot->z; Matrix_RotateY(rot->y, MTXMODE_NEW); Matrix_RotateX(rot->x, MTXMODE_APPLY); Matrix_MultVec3f(&velSrc, &effect->vel); @@ -826,13 +836,13 @@ void Fishing_Init(Actor* thisx, PlayState* play2) { sLinkAge = gSaveContext.save.linkAge; } - if (thisx->params < 100) { - D_80B7E074 = 0; + if (thisx->params < EN_FISH_PARAM) { + sReelLock = 0; sFishingMain = this; Collider_InitJntSph(play, &sFishingMain->collider); Collider_SetJntSph(play, &sFishingMain->collider, thisx, &sJntSphInit, sFishingMain->colliderElements); - thisx->params = 1; + thisx->params = EN_FISH_OWNER; SkelAnime_InitFlex(play, &this->skelAnime, &gFishingOwnerSkel, &gFishingOwnerAnim, NULL, NULL, 0); Animation_MorphToLoop(&this->skelAnime, &gFishingOwnerAnim, 0.0f); @@ -852,55 +862,55 @@ void Fishing_Init(Actor* thisx, PlayState* play2) { thisx->flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; if (sLinkAge != LINK_AGE_CHILD) { - if (HIGH_SCORE(HS_FISHING) & 0x1000) { - D_80B7A688 = 0; + if (HIGH_SCORE(HS_FISHING) & HS_FISH_STOLE_HAT) { + sOwnerHair = FS_OWNER_BALD; } else { - D_80B7A688 = 1; + sOwnerHair = FS_OWNER_CAPPED; } } else { - D_80B7A688 = 2; + sOwnerHair = FS_OWNER_HAIR; } - D_80B7A684 = 20; + sOwnerTheftTimer = 20; play->specialEffects = sEffects; gTimeSpeed = 1; - D_80B7E0AC = 0; - D_80B7E0A6 = 10; + sFishingPlayingState = 0; + sFishingMusicDelay = 10; SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1); if (sLinkAge == LINK_AGE_CHILD) { - if ((HIGH_SCORE(HS_FISHING) & 0x7F) != 0) { - D_80B7E078 = HIGH_SCORE(HS_FISHING) & 0x7F; + if ((HIGH_SCORE(HS_FISHING) & HS_FISH_LENGTH_CHILD) != 0) { + sFishingRecordLength = HIGH_SCORE(HS_FISHING) & HS_FISH_LENGTH_CHILD; } else { - D_80B7E078 = 40.0f; + sFishingRecordLength = 40.0f; // 6 lbs } } else { - if ((HIGH_SCORE(HS_FISHING) & 0x7F000000) != 0) { - D_80B7E078 = (HIGH_SCORE(HS_FISHING) & 0x7F000000) >> 0x18; + if ((HIGH_SCORE(HS_FISHING) & HS_FISH_LENGTH_ADULT) != 0) { + sFishingRecordLength = (HIGH_SCORE(HS_FISHING) & HS_FISH_LENGTH_ADULT) >> 0x18; } else { - D_80B7E078 = 45.0f; + sFishingRecordLength = 45.0f; // 7 lbs } } - D_80B7E07D = (HIGH_SCORE(HS_FISHING) & 0xFF0000) >> 0x10; - if ((D_80B7E07D & 7) == 7) { + sFishGameNumber = (HIGH_SCORE(HS_FISHING) & (HS_FISH_PLAYED * 255)) >> 0x10; + if ((sFishGameNumber & 7) == 7) { play->roomCtx.unk_74[0] = 90; - D_80B7E076 = 1; + sFishingFoggy = 1; } else { play->roomCtx.unk_74[0] = 40; - D_80B7E076 = 0; + sFishingFoggy = 0; } - if (((D_80B7E07D & 7) == 6) || (KREG(3) != 0)) { - D_80B7E077 = 100; + if (((sFishGameNumber & 7) == 6) || (KREG(3) != 0)) { + sStormChanceTimer = 100; if (KREG(3) != 0) { KREG(3) = 0; - HIGH_SCORE(HS_FISHING) &= 0xFF00FFFF; - HIGH_SCORE(HS_FISHING) |= 0x60000; + HIGH_SCORE(HS_FISHING) &= ~(HS_FISH_PLAYED * 255); + HIGH_SCORE(HS_FISHING) |= (HS_FISH_PLAYED * 6); } } else { - D_80B7E077 = 0; + sStormChanceTimer = 0; } for (i = 0; i < FISHING_EFFECT_COUNT; i++) { @@ -921,17 +931,17 @@ void Fishing_Init(Actor* thisx, PlayState* play2) { fish->type = FS_GROUP_FISH_NORMAL; if (i <= 20) { - fish->unk_10.x = fish->pos.x = sinf(sFishGroupAngle1) * 720.0f; - fish->unk_10.z = fish->pos.z = cosf(sFishGroupAngle1) * 720.0f; + fish->homePos.x = fish->pos.x = sinf(sFishGroupAngle1) * 720.0f; + fish->homePos.z = fish->pos.z = cosf(sFishGroupAngle1) * 720.0f; } else if (i <= 40) { - fish->unk_10.x = fish->pos.x = sinf(sFishGroupAngle2) * 720.0f; - fish->unk_10.z = fish->pos.z = cosf(sFishGroupAngle2) * 720.0f; + fish->homePos.x = fish->pos.x = sinf(sFishGroupAngle2) * 720.0f; + fish->homePos.z = fish->pos.z = cosf(sFishGroupAngle2) * 720.0f; } else { - fish->unk_10.x = fish->pos.x = sinf(sFishGroupAngle3) * 720.0f; - fish->unk_10.z = fish->pos.z = cosf(sFishGroupAngle3) * 720.0f; + fish->homePos.x = fish->pos.x = sinf(sFishGroupAngle3) * 720.0f; + fish->homePos.z = fish->pos.z = cosf(sFishGroupAngle3) * 720.0f; } - fish->unk_10.y = fish->pos.y = -35.0f; + fish->homePos.y = fish->pos.y = -35.0f; fish->timer = Rand_ZeroFloat(100.0f); @@ -951,7 +961,7 @@ void Fishing_Init(Actor* thisx, PlayState* play2) { ENKANBAN_FISHING); Actor_Spawn(&play->actorCtx, play, ACTOR_FISHING, 0.0f, 0.0f, 0.0f, 0, 0, 0, 200); - if ((KREG(1) == 1) || ((D_80B7E07D & 3) == 3)) { + if ((KREG(1) == 1) || ((sFishGameNumber & 3) == 3)) { if (sLinkAge != LINK_AGE_CHILD) { fishCount = 16; } else { @@ -966,7 +976,7 @@ void Fishing_Init(Actor* thisx, PlayState* play2) { sFishInits[i].pos.z, 0, Rand_ZeroFloat(0x10000), 0, 100 + i); } } else { - if ((thisx->params < 115) || (thisx->params == 200)) { + if ((thisx->params < (EN_FISH_PARAM + 15)) || (thisx->params == EN_FISH_AQUARIUM)) { SkelAnime_InitFlex(play, &this->skelAnime, &gFishingFishSkel, &gFishingFishAnim, NULL, NULL, 0); Animation_MorphToLoop(&this->skelAnime, &gFishingFishAnim, 0.0f); } else { @@ -976,32 +986,34 @@ void Fishing_Init(Actor* thisx, PlayState* play2) { SkelAnime_Update(&this->skelAnime); - if (thisx->params == 200) { - this->unk_158 = 100; + if (thisx->params == EN_FISH_AQUARIUM) { + this->fishState = 100; Actor_ChangeCategory(play, &play->actorCtx, thisx, ACTORCAT_PROP); thisx->targetMode = 0; thisx->flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; this->lightNode = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); } else { - this->unk_158 = 10; - this->unk_15A = 10; + this->fishState = 10; + this->fishStateNext = 10; - this->unk_150 = sFishInits[thisx->params - 100].unk_00; - this->unk_1A8 = sFishInits[thisx->params - 100].unk_0C; - this->unk_1AC = sFishInits[thisx->params - 100].unk_08; + this->isLoach = sFishInits[thisx->params - EN_FISH_PARAM].isLoach; + this->perception = sFishInits[thisx->params - EN_FISH_PARAM].perception; + this->fishLength = sFishInits[thisx->params - EN_FISH_PARAM].baseLength; - this->unk_1AC += Rand_ZeroFloat(4.99999f); + this->fishLength += Rand_ZeroFloat(4.99999f); - if ((this->unk_1AC >= 65.0f) && (Rand_ZeroOne() < 0.05f)) { - this->unk_1AC += Rand_ZeroFloat(7.99999f); + // small chance to make big fish even bigger. + if ((this->fishLength >= 65.0f) && (Rand_ZeroOne() < 0.05f)) { + this->fishLength += Rand_ZeroFloat(7.99999f); } if (KREG(6) != 0) { - this->unk_1AC = KREG(6) + 80.0f; + this->fishLength = KREG(6) + 80.0f; } + // "Come back when you get older! The fish will be bigger, too!" if (sLinkAge == LINK_AGE_CHILD) { - this->unk_1AC *= 0.73f; + this->fishLength *= 0.73f; } } } @@ -1013,9 +1025,9 @@ void Fishing_Destroy(Actor* thisx, PlayState* play2) { SkelAnime_Free(&this->skelAnime, play); - if (thisx->params == 200) { + if (thisx->params == EN_FISH_AQUARIUM) { LightContext_RemoveLight(play, &play->lightCtx, this->lightNode); - } else if (thisx->params == 1) { + } else if (thisx->params == EN_FISH_OWNER) { Collider_DestroyJntSph(play, &this->collider); } } @@ -1033,14 +1045,14 @@ void Fishing_UpdateEffects(FishingEffect* effect, PlayState* play) { effect->vel.y += effect->accel.y; if (effect->type == FS_EFF_RIPPLE) { - Math_ApproachF(&effect->unk_30, effect->unk_34, 0.2f, effect->unk_38); + Math_ApproachF(&effect->scale, effect->rot.x, 0.2f, effect->rot.y); - if (effect->unk_2C == 0) { + if (effect->state == 0) { effect->alpha += 20; - if (effect->alpha >= effect->unk_2E) { - effect->alpha = effect->unk_2E; - effect->unk_2C++; + if (effect->alpha >= effect->alphaMax) { + effect->alpha = effect->alphaMax; + effect->state++; } } else { effect->alpha -= 8; @@ -1050,7 +1062,7 @@ void Fishing_UpdateEffects(FishingEffect* effect, PlayState* play) { } } } else if (effect->type == FS_EFF_WATER_DUST) { - Math_ApproachF(&effect->unk_30, effect->unk_34, 0.1f, 0.1f); + Math_ApproachF(&effect->scale, effect->rot.x, 0.1f, 0.1f); effect->alpha -= 10; if (effect->pos.y > (WATER_SURFACE_Y(play) - 5.0f)) { @@ -1063,7 +1075,7 @@ void Fishing_UpdateEffects(FishingEffect* effect, PlayState* play) { effect->type = FS_EFF_NONE; } } else if (effect->type == FS_EFF_BUBBLE) { - if (effect->unk_2C == 0) { + if (effect->state == 0) { rippleY = WATER_SURFACE_Y(play); } else { rippleY = 69.0f; @@ -1100,14 +1112,14 @@ void Fishing_UpdateEffects(FishingEffect* effect, PlayState* play) { effect->pos.y = WATER_SURFACE_Y(play) + ((sqrtf(sqDistXZ) - 920.0f) * 0.11f); effect->timer = KREG(17) + 2; effect->type = FS_EFF_RAIN_SPLASH; - effect->unk_30 = (KREG(18) + 30) * 0.001f; + effect->scale = (KREG(18) + 30) * 0.001f; } else { effect->pos.y = WATER_SURFACE_Y(play) + 3.0f; effect->timer = 0; if (Rand_ZeroOne() < 0.75f) { effect->type = FS_EFF_RAIN_RIPPLE; effect->vel = sZeroVec; - effect->unk_30 = (KREG(18) + 30) * 0.001f; + effect->scale = (KREG(18) + 30) * 0.001f; } else { effect->type = FS_EFF_NONE; } @@ -1116,7 +1128,7 @@ void Fishing_UpdateEffects(FishingEffect* effect, PlayState* play) { effect->vel = sZeroVec; } } else if (effect->type >= FS_EFF_RAIN_RIPPLE) { - effect->unk_30 += (KREG(18) + 30) * 0.001f; + effect->scale += (KREG(18) + 30) * 0.001f; if (effect->timer >= 6) { effect->type = FS_EFF_NONE; @@ -1125,11 +1137,11 @@ void Fishing_UpdateEffects(FishingEffect* effect, PlayState* play) { f32 sqDistXZ; f32 bottomY; - effect->unk_30 = 0.010000001f; + effect->scale = 10 * .001f; - Math_ApproachS(&sEffOwnerHatRot.y, 0, 20, 100); - Math_ApproachS(&sEffOwnerHatRot.x, 0, 20, 100); - Math_ApproachS(&sEffOwnerHatRot.z, -0x4000, 20, 100); + Math_ApproachS(&sEffOwnersHatRot.y, 0, 20, 100); + Math_ApproachS(&sEffOwnersHatRot.x, 0, 20, 100); + Math_ApproachS(&sEffOwnersHatRot.z, -0x4000, 20, 100); sqDistXZ = SQ(effect->pos.x) + SQ(effect->pos.z); bottomY = WATER_SURFACE_Y(play) + ((sqrtf(sqDistXZ) - 920.0f) * 0.147f); @@ -1144,19 +1156,19 @@ void Fishing_UpdateEffects(FishingEffect* effect, PlayState* play) { Fishing_SpawnRipple(NULL, play->specialEffects, &pos, 30.0f, 300.0f, 150, 90); } - if (effect->unk_2C >= 0) { - effect->unk_2C++; + if (effect->state >= 0) { + effect->state++; } - if (effect->unk_2C == 30) { + if (effect->state == 30) { Message_StartTextbox(play, 0x40B3, NULL); } - if ((effect->unk_2C >= 100) && (Message_GetState(&play->msgCtx) == TEXT_STATE_EVENT)) { + if ((effect->state >= 100) && (Message_GetState(&play->msgCtx) == TEXT_STATE_EVENT)) { if (Message_ShouldAdvance(play) || (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE)) { Message_CloseTextbox(play); Rupees_ChangeBy(-50); - effect->unk_2C = -1; + effect->state = -1; } } } @@ -1190,7 +1202,7 @@ void Fishing_DrawEffects(FishingEffect* effect, PlayState* play) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, effect->alpha); Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_Scale(effect->unk_30, 1.0f, effect->unk_30, MTXMODE_APPLY); + Matrix_Scale(effect->scale, 1.0f, effect->scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_fishing.c", 2305), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1214,7 +1226,7 @@ void Fishing_DrawEffects(FishingEffect* effect, PlayState* play) { Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&play->billboardMtxF); - Matrix_Scale(effect->unk_30, effect->unk_30, 1.0f, MTXMODE_APPLY); + Matrix_Scale(effect->scale, effect->scale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_fishing.c", 2346), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1242,7 +1254,7 @@ void Fishing_DrawEffects(FishingEffect* effect, PlayState* play) { Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&play->billboardMtxF); - Matrix_Scale(effect->unk_30, effect->unk_30, 1.0f, MTXMODE_APPLY); + Matrix_Scale(effect->scale, effect->scale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_fishing.c", 2394), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1265,7 +1277,7 @@ void Fishing_DrawEffects(FishingEffect* effect, PlayState* play) { Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&play->billboardMtxF); - Matrix_Scale(effect->unk_30, effect->unk_30, 1.0f, MTXMODE_APPLY); + Matrix_Scale(effect->scale, effect->scale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_fishing.c", 2423), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1287,9 +1299,9 @@ void Fishing_DrawEffects(FishingEffect* effect, PlayState* play) { } Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_RotateY(effect->unk_38, MTXMODE_APPLY); - Matrix_RotateX(effect->unk_34, MTXMODE_APPLY); - Matrix_RotateZ(effect->unk_3C, MTXMODE_APPLY); + Matrix_RotateY(effect->rot.y, MTXMODE_APPLY); + Matrix_RotateX(effect->rot.x, MTXMODE_APPLY); + Matrix_RotateZ(effect->rot.z, MTXMODE_APPLY); Matrix_Scale(0.002f, 1.0f, 0.1f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_fishing.c", 2467), @@ -1314,7 +1326,7 @@ void Fishing_DrawEffects(FishingEffect* effect, PlayState* play) { } Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_Scale(effect->unk_30, 1.0f, effect->unk_30, MTXMODE_APPLY); + Matrix_Scale(effect->scale, 1.0f, effect->scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_fishing.c", 2504), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1343,7 +1355,7 @@ void Fishing_DrawEffects(FishingEffect* effect, PlayState* play) { Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&play->billboardMtxF); Matrix_RotateY(rotY, MTXMODE_APPLY); - Matrix_Scale(effect->unk_30, effect->unk_30, 1.0f, MTXMODE_APPLY); + Matrix_Scale(effect->scale, effect->scale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_fishing.c", 2541), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1356,10 +1368,10 @@ void Fishing_DrawEffects(FishingEffect* effect, PlayState* play) { effect = firstEffect; if (effect->type == FS_EFF_OWNER_HAT) { Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_RotateY(BINANG_TO_RAD_ALT2(sEffOwnerHatRot.y), MTXMODE_APPLY); - Matrix_RotateX(BINANG_TO_RAD_ALT2(sEffOwnerHatRot.x), MTXMODE_APPLY); - Matrix_RotateZ(BINANG_TO_RAD_ALT2(sEffOwnerHatRot.z), MTXMODE_APPLY); - Matrix_Scale(effect->unk_30, effect->unk_30, effect->unk_30, MTXMODE_APPLY); + Matrix_RotateY(BINANG_TO_RAD_ALT2(sEffOwnersHatRot.y), MTXMODE_APPLY); + Matrix_RotateX(BINANG_TO_RAD_ALT2(sEffOwnersHatRot.x), MTXMODE_APPLY); + Matrix_RotateZ(BINANG_TO_RAD_ALT2(sEffOwnersHatRot.z), MTXMODE_APPLY); + Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); Matrix_Translate(-1250.0f, 0.0f, 0.0f, MTXMODE_APPLY); Matrix_RotateX(M_PI / 2, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_fishing.c", 2560), @@ -1394,7 +1406,8 @@ void Fishing_DrawStreamSplash(PlayState* play) { CLOSE_DISPS(play->state.gfxCtx, "../z_fishing.c", 2613); } -s32 func_80B6C2EC(Vec3f* vec) { +// Checks if postion is above Fishing Pond owner's countertop. +s32 Fishing_IsAboveCounter(Vec3f* vec) { if (((vec->x >= 110.0f) && (vec->x <= 150.0f) && (vec->z <= 1400.0f) && (vec->z >= 1160.0f)) || ((vec->x >= 110.0f) && (vec->x <= 210.0f) && (vec->z <= 1200.0f) && (vec->z >= 1160.0f))) { if (vec->y <= 42.0f) { @@ -1415,14 +1428,14 @@ void Fishing_UpdateLine(PlayState* play, Vec3f* basePos, Vec3f* pos, Vec3f* rot, f32 ry; f32 dist; f32 spD8; - s16 temp_s2; + s16 spooled; s32 pad; f32 temp_f20; Vec3f posSrc = { 0.0f, 0.0f, 0.0f }; Vec3f posStep; - f32 phi_f18; - Vec3f spA4; - Vec3f sp98; + f32 lineLength; + Vec3f tempPos; + Vec3f segPos; f32 sp94; f32 sp90; f32 sp8C; @@ -1432,36 +1445,36 @@ void Fishing_UpdateLine(PlayState* play, Vec3f* basePos, Vec3f* pos, Vec3f* rot, f32 phi_f2; if (D_80B7A6A4 != 0) { - spA4 = *basePos; - sp98 = pos[LINE_SEG_COUNT - 1]; + tempPos = *basePos; + segPos = pos[LINE_SEG_COUNT - 1]; - sp94 = sp98.x - spA4.x; - sp90 = sp98.y - spA4.y; - sp8C = sp98.z - spA4.z; + sp94 = segPos.x - tempPos.x; + sp90 = segPos.y - tempPos.y; + sp8C = segPos.z - tempPos.z; - phi_f18 = sqrtf(SQ(sp94) + SQ(sp90) + SQ(sp8C)) * 0.97f; - if (phi_f18 > 1000.0f) { - phi_f18 = 1000.0f; + lineLength = sqrtf(SQ(sp94) + SQ(sp90) + SQ(sp8C)) * 0.97f; + if (lineLength > 1000.0f) { + lineLength = 1000.0f; } - D_80B7E144 = 200.0f - (phi_f18 * 200.0f * 0.001f); + sRodLineSpooled = 200.0f - (lineLength * 200.0f * 0.001f); } - temp_s2 = D_80B7E144; + spooled = sRodLineSpooled; posSrc.z = 5.0f; for (i = 0; i < LINE_SEG_COUNT; i++) { - if (i <= temp_s2) { + if (i <= spooled) { pos[i] = *basePos; } else if (D_80B7A6A4 != 0) { - temp_f20 = (f32)(i - temp_s2) / (f32)(LINE_SEG_COUNT - temp_s2 + 1); - Math_ApproachF(&pos[i].x, (sp94 * temp_f20) + spA4.x, 1.0f, 20.0f); - Math_ApproachF(&pos[i].y, (sp90 * temp_f20) + spA4.y, 1.0f, 20.0f); - Math_ApproachF(&pos[i].z, (sp8C * temp_f20) + spA4.z, 1.0f, 20.0f); + temp_f20 = (f32)(i - spooled) / (f32)(LINE_SEG_COUNT - spooled + 1); + Math_ApproachF(&pos[i].x, (sp94 * temp_f20) + tempPos.x, 1.0f, 20.0f); + Math_ApproachF(&pos[i].y, (sp90 * temp_f20) + tempPos.y, 1.0f, 20.0f); + Math_ApproachF(&pos[i].z, (sp8C * temp_f20) + tempPos.z, 1.0f, 20.0f); } } - for (i = temp_s2 + 1, k = 0; i < LINE_SEG_COUNT; i++, k++) { + for (i = spooled + 1, k = 0; i < LINE_SEG_COUNT; i++, k++) { temp_f18 = 2.0f * D_80B7E148; dx = (pos + i)->x - (pos + i - 1)->x; @@ -1475,7 +1488,7 @@ void Fishing_UpdateLine(PlayState* play, Vec3f* basePos, Vec3f* pos, Vec3f* rot, phi_f12 = WATER_SURFACE_Y(play); } - if (D_80B7E0B6 == 2) { + if (sLureEquipped == FS_LURE_SINKING) { if (spD8 < phi_f12) { phi_f12 = ((sqrtf(sqDistXZ) - 920.0f) * 0.147f) + WATER_SURFACE_Y(play); if (spD8 > phi_f12) { @@ -1505,7 +1518,7 @@ void Fishing_UpdateLine(PlayState* play, Vec3f* basePos, Vec3f* pos, Vec3f* rot, } } - if (func_80B6C2EC(&pos[i])) { + if (Fishing_IsAboveCounter(&pos[i])) { spD8 = 42.0f; } @@ -1539,11 +1552,11 @@ void Fishing_UpdateLinePos(Vec3f* pos) { f32 dist; Vec3f posSrc = { 0.0f, 0.0f, 0.0f }; Vec3f posStep; - s16 min = D_80B7E144; + s16 spooled = sRodLineSpooled; posSrc.z = 5.0f; - for (i = LINE_SEG_COUNT - 2; i > min; i--) { + for (i = LINE_SEG_COUNT - 2; i > spooled; i--) { dx = (pos + i)->x - (pos + i + 1)->x; dy = (pos + i)->y - (pos + i + 1)->y; dz = (pos + i)->z - (pos + i + 1)->z; @@ -1578,7 +1591,7 @@ void Fishing_DrawLureHook(PlayState* play, Vec3f* pos, Vec3f* refPos, u8 hookInd Matrix_Push(); - if ((D_80B7A694 == 3) && ((pos->y > WATER_SURFACE_Y(play)) || ((D_80B7A68C != 0) && hookIndex))) { + if ((sRodCastState == 3) && ((pos->y > WATER_SURFACE_Y(play)) || (sIsOwnersHatHooked && hookIndex))) { offsetY = 0.0f; } else if (pos->y < WATER_SURFACE_Y(play)) { offsetY = -1.0f; @@ -1604,7 +1617,7 @@ void Fishing_DrawLureHook(PlayState* play, Vec3f* pos, Vec3f* refPos, u8 hookInd Matrix_Translate(pos->x, pos->y, pos->z, MTXMODE_NEW); - if ((player->actor.speed == 0.0f) && (D_80B7E138 == 0.0f)) { + if ((player->actor.speed == 0.0f) && (sLureWigglePosY == 0.0f)) { Math_ApproachF(&sLureHookRotY[hookIndex], ry, 0.1f, 0.3f); } else { sLureHookRotY[hookIndex] = ry; @@ -1625,24 +1638,24 @@ void Fishing_DrawLureHook(PlayState* play, Vec3f* pos, Vec3f* refPos, u8 hookInd G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gFishingLureHookDL); - if ((hookIndex == 1) && (D_80B7A68C != 0)) { + if ((hookIndex == 1) && (sIsOwnersHatHooked)) { Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); Matrix_Translate(250.0f, 0.0f, -1400.0f, MTXMODE_APPLY); Matrix_Push(); - if (D_80B7A690 != 0) { + if (sIsOwnersHatSunk) { FishingEffect* effect = play->specialEffects; MtxF mf; Matrix_MultVec3f(&sZeroVec, &effect->pos); Matrix_Get(&mf); - Matrix_MtxFToYXZRotS(&mf, &sEffOwnerHatRot, 0); + Matrix_MtxFToYXZRotS(&mf, &sEffOwnersHatRot, 0); - D_80B7A690 = 0; - D_80B7A68C = 0; + sIsOwnersHatSunk = false; + sIsOwnersHatHooked = false; effect->type = FS_EFF_OWNER_HAT; - effect->unk_2C = 0; + effect->state = 0; effect->vel = sZeroVec; effect->accel = sZeroVec; } @@ -1682,7 +1695,7 @@ void Fishing_UpdateSinkingLure(PlayState* play) { sSinkingLurePos[0] = sLurePos; - if (D_80B7A6D4 != 0) { + if (sSinkingLureFound) { offsetY = -1.0f; } else if (sLurePos.y < WATER_SURFACE_Y(play)) { offsetY = 0.5f; @@ -1690,7 +1703,7 @@ void Fishing_UpdateSinkingLure(PlayState* play) { offsetY = -5.0f; } - if (D_80B7A694 == 5) { + if (sRodCastState == 5) { Matrix_RotateY(BINANG_TO_RAD(player->actor.shape.rot.y), MTXMODE_NEW); sp94.x = 5.0f; sp94.y = 0.0f; @@ -1701,7 +1714,7 @@ void Fishing_UpdateSinkingLure(PlayState* play) { for (i = 1; i < SINKING_LURE_SEG_COUNT; i++) { Vec3f* pos = sSinkingLurePos; - if ((i < 10) && (D_80B7A694 == 5)) { + if ((i < 10) && (sRodCastState == 5)) { offsetX = (10 - i) * sp88.x * 0.1f; offsetZ = (10 - i) * sp88.z * 0.1f; } else { @@ -1745,9 +1758,9 @@ void Fishing_DrawSinkingLure(PlayState* play) { gSPDisplayList(POLY_OPA_DISP++, gFishingSinkingLureSegmentMaterialDL); for (i = SINKING_LURE_SEG_COUNT - 1; i >= 0; i--) { - if ((i + D_80B7FEA0) < SINKING_LURE_SEG_COUNT) { + if ((i + sSinkingLureSegmentIndex) < SINKING_LURE_SEG_COUNT) { Matrix_Translate(sSinkingLurePos[i].x, sSinkingLurePos[i].y, sSinkingLurePos[i].z, MTXMODE_NEW); - scale = sSinkingLureSizes[i + D_80B7FEA0] * 0.04f; + scale = sSinkingLureSizes[i + sSinkingLureSegmentIndex] * 0.04f; Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); Matrix_ReplaceRotation(&play->billboardMtxF); @@ -1762,9 +1775,9 @@ void Fishing_DrawSinkingLure(PlayState* play) { gSPDisplayList(POLY_XLU_DISP++, gFishingSinkingLureSegmentMaterialDL); for (i = SINKING_LURE_SEG_COUNT - 1; i >= 0; i--) { - if ((i + D_80B7FEA0) < SINKING_LURE_SEG_COUNT) { + if ((i + sSinkingLureSegmentIndex) < SINKING_LURE_SEG_COUNT) { Matrix_Translate(sSinkingLurePos[i].x, sSinkingLurePos[i].y, sSinkingLurePos[i].z, MTXMODE_NEW); - scale = sSinkingLureSizes[i + D_80B7FEA0] * 0.04f; + scale = sSinkingLureSizes[i + sSinkingLureSegmentIndex] * 0.04f; Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); Matrix_ReplaceRotation(&play->billboardMtxF); @@ -1783,7 +1796,7 @@ void Fishing_DrawLureAndLine(PlayState* play, Vec3f* linePos, Vec3f* lineRot) { Vec3f posStep; Vec3f hookPos[2]; s16 i; - s16 spB4 = D_80B7E144; + s16 spooled = sRodLineSpooled; s32 pad; Player* player = GET_PLAYER(play); @@ -1792,17 +1805,17 @@ void Fishing_DrawLureAndLine(PlayState* play, Vec3f* linePos, Vec3f* lineRot) { Gfx_SetupDL_25Opa(play->state.gfxCtx); Matrix_Push(); - if (D_80B7A6D4 != 0) { + if (sSinkingLureFound) { Vec3f posTemp = sLurePos; sLurePos = sSinkingLureBasePos; Fishing_DrawSinkingLure(play); sLurePos = posTemp; } - if ((D_80B7A694 == 4) || (D_80B7A694 == 5)) { + if ((sRodCastState == 4) || (sRodCastState == 5)) { sLurePos = sFishingHookedFish->fishMouthPos; - if ((D_80B7A694 == 5) && (D_80B7E0B6 == 2)) { + if ((sRodCastState == 5) && (sLureEquipped == FS_LURE_SINKING)) { Matrix_RotateY(BINANG_TO_RAD(player->actor.shape.rot.y), MTXMODE_NEW); posSrc.x = 2.0f; posSrc.y = 0.0f; @@ -1811,7 +1824,7 @@ void Fishing_DrawLureAndLine(PlayState* play, Vec3f* linePos, Vec3f* lineRot) { sLurePos.x += posStep.x; sLurePos.z += posStep.z; } - } else if (D_80B7A694 == 0) { + } else if (sRodCastState == 0) { sLurePos = sReelLinePos[LINE_SEG_COUNT - 1]; sLureRot.x = sReelLineRot[LINE_SEG_COUNT - 2].x + M_PI; @@ -1822,12 +1835,12 @@ void Fishing_DrawLureAndLine(PlayState* play, Vec3f* linePos, Vec3f* lineRot) { } } - if (D_80B7E0B6 != 2) { + if (sLureEquipped != FS_LURE_SINKING) { Matrix_Translate(sLurePos.x, sLurePos.y, sLurePos.z, MTXMODE_NEW); - Matrix_RotateY(sLureRot.y + D_80B7E104, MTXMODE_APPLY); + Matrix_RotateY(sLureRot.y + sLure1Rotate, MTXMODE_APPLY); Matrix_RotateX(sLureRot.x, MTXMODE_APPLY); Matrix_Scale(0.0039999997f, 0.0039999997f, 0.0039999997f, MTXMODE_APPLY); - Matrix_Translate(0.0f, 0.0f, D_80B7E108, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, sLurePosZOffset, MTXMODE_APPLY); Matrix_RotateZ(M_PI / 2, MTXMODE_APPLY); Matrix_RotateY(M_PI / 2, MTXMODE_APPLY); @@ -1840,7 +1853,7 @@ void Fishing_DrawLureAndLine(PlayState* play, Vec3f* linePos, Vec3f* lineRot) { posSrc.x = -850.0f; posSrc.y = 0.0f; posSrc.z = 0.0f; - Matrix_MultVec3f(&posSrc, &D_80B7E0C8); + Matrix_MultVec3f(&posSrc, &sLureDrawPos); posSrc.x = 500.0f; posSrc.z = -300.0f; @@ -1858,7 +1871,7 @@ void Fishing_DrawLureAndLine(PlayState* play, Vec3f* linePos, Vec3f* lineRot) { gDPSetCombineMode(POLY_XLU_DISP++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 55); - if ((D_80B7A694 == 4) && ((D_80B7E124 != 0) || (D_80B7E0B6 != 2))) { + if ((sRodCastState == 4) && ((sLineHooked != 0) || (sLureEquipped != FS_LURE_SINKING))) { f32 rx; f32 ry; f32 dist; @@ -1879,14 +1892,14 @@ void Fishing_DrawLureAndLine(PlayState* play, Vec3f* linePos, Vec3f* lineRot) { Matrix_Translate(sRodTipPos.x, sRodTipPos.y, sRodTipPos.z, MTXMODE_NEW); Matrix_RotateY(ry, MTXMODE_APPLY); Matrix_RotateX(rx, MTXMODE_APPLY); - Matrix_Scale(D_80B7E14C, 1.0f, dist, MTXMODE_APPLY); + Matrix_Scale(sFishingLineScale, 1.0f, dist, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_fishing.c", 3444), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gFishingLineModelDL); } else { - for (i = spB4; i < LINE_SEG_COUNT - 1; i++) { - if ((i == LINE_SEG_COUNT - 3) && (D_80B7E0B6 == 0) && (D_80B7A694 == 3)) { + for (i = spooled; i < LINE_SEG_COUNT - 1; i++) { + if ((i == LINE_SEG_COUNT - 3) && (sLureEquipped == FS_LURE_STOCK) && (sRodCastState == 3)) { f32 rx; f32 ry; f32 dist; @@ -1894,9 +1907,9 @@ void Fishing_DrawLureAndLine(PlayState* play, Vec3f* linePos, Vec3f* lineRot) { f32 dy; f32 dz; - dx = D_80B7E0C8.x - (linePos + i)->x; - dy = D_80B7E0C8.y - (linePos + i)->y; - dz = D_80B7E0C8.z - (linePos + i)->z; + dx = sLureDrawPos.x - (linePos + i)->x; + dy = sLureDrawPos.y - (linePos + i)->y; + dz = sLureDrawPos.z - (linePos + i)->z; ry = Math_FAtan2F(dx, dz); dist = sqrtf(SQ(dx) + SQ(dz)); @@ -1907,7 +1920,7 @@ void Fishing_DrawLureAndLine(PlayState* play, Vec3f* linePos, Vec3f* lineRot) { Matrix_Translate((linePos + i)->x, (linePos + i)->y, (linePos + i)->z, MTXMODE_NEW); Matrix_RotateY(ry, MTXMODE_APPLY); Matrix_RotateX(rx, MTXMODE_APPLY); - Matrix_Scale(D_80B7E14C, 1.0f, dist, MTXMODE_APPLY); + Matrix_Scale(sFishingLineScale, 1.0f, dist, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_fishing.c", 3475), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1918,7 +1931,7 @@ void Fishing_DrawLureAndLine(PlayState* play, Vec3f* linePos, Vec3f* lineRot) { Matrix_Translate((linePos + i)->x, (linePos + i)->y, (linePos + i)->z, MTXMODE_NEW); Matrix_RotateY((lineRot + i)->y, MTXMODE_APPLY); Matrix_RotateX((lineRot + i)->x, MTXMODE_APPLY); - Matrix_Scale(D_80B7E14C, 1.0f, 0.005f, MTXMODE_APPLY); + Matrix_Scale(sFishingLineScale, 1.0f, 0.005f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_fishing.c", 3492), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1947,7 +1960,7 @@ static Vec3f sRodTipOffset = { 0.0f, 0.0f, 0.0f }; void Fishing_DrawRod(PlayState* play) { s16 i; - f32 spC8; + f32 lureXZLen; f32 spC4; f32 spC0; Input* input = &play->state.input[0]; @@ -1956,8 +1969,8 @@ void Fishing_DrawRod(PlayState* play) { OPEN_DISPS(play->state.gfxCtx, "../z_fishing.c", 3600); - if (D_80B7FDA8 != 0) { - D_80B7FDA8--; + if (sRodHitTimer != 0) { + sRodHitTimer--; Math_ApproachF(&D_80B7A6C0, 35.0f, 1.0f, 100.0f); Math_ApproachF(&D_80B7A6BC, -0.8f, 1.0f, 0.4f); @@ -1965,8 +1978,8 @@ void Fishing_DrawRod(PlayState* play) { } else { s16 target = 0; - if ((D_80B7A694 == 4) && (D_80B7E124 != 0)) { - target = Math_SinS(D_80B7E0AE * 25600) * 1500.0f; + if ((sRodCastState == 4) && sLineHooked) { + target = Math_SinS(sLureTimer * 25600) * 1500.0f; } else { Math_ApproachZeroF(&D_80B7A6C0, 0.1f, 10.0f); Math_ApproachZeroF(&D_80B7A6BC, 1.0f, 0.05f); @@ -1975,17 +1988,17 @@ void Fishing_DrawRod(PlayState* play) { Math_ApproachS(&player->actor.shape.rot.x, target, 5, 1000); } - if ((D_80B7A694 == 3) || (D_80B7A694 == 4)) { - if ((input->rel.stick_x == 0) && (D_80B7A6C4 != 0)) { + if ((sRodCastState == 3) || (sRodCastState == 4)) { + if ((input->rel.stick_x == 0) && (sStickAdjXPrev != 0)) { D_80B7A6B0 = 0.0f; } - if ((input->rel.stick_y == 0) && (D_80B7A6C8 != 0)) { + if ((input->rel.stick_y == 0) && (sStickAdjYPrev != 0)) { D_80B7A6B4 = 0.0f; } - spC8 = player->unk_85C; + lureXZLen = player->unk_85C; Math_SmoothStepToF(&player->unk_85C, input->rel.stick_y * 0.02f, 0.3f, 5.0f, 0.0f); - spC8 = player->unk_85C - spC8; + lureXZLen = player->unk_85C - lureXZLen; spC4 = player->unk_858; Math_SmoothStepToF(&player->unk_858, input->rel.stick_x * 0.02f, 0.3f, 5.0f, 0.0f); @@ -2004,18 +2017,18 @@ void Fishing_DrawRod(PlayState* play) { player->unk_85C = -1.0f; } - Math_ApproachF(&D_80B7A6A8, spC4 * 70.0f * -0.01f, 1.0f, D_80B7A6B0); + Math_ApproachF(&sRodBendRotY, spC4 * 70.0f * -0.01f, 1.0f, D_80B7A6B0); Math_ApproachF(&D_80B7A6B0, 1.0f, 1.0f, 0.1f); - Math_ApproachF(&D_80B7A6AC, spC8 * 70.0f * 0.01f, 1.0f, D_80B7A6B4); + Math_ApproachF(&D_80B7A6AC, lureXZLen * 70.0f * 0.01f, 1.0f, D_80B7A6B4); Math_ApproachF(&D_80B7A6B4, 1.0f, 1.0f, 0.1f); Math_ApproachZeroF(&D_80B7A6B8, 1.0f, 0.05f); } else { Math_ApproachZeroF(&player->unk_85C, 1.0f, 0.1f); Math_ApproachZeroF(&player->unk_858, 1.0f, 0.1f); - Math_ApproachF(&D_80B7A6AC, (Math_SinS(D_80B7E0AE * 3000) * 0.025f) + -0.03f, 1.0f, 0.05f); - Math_ApproachZeroF(&D_80B7A6A8, 1.0f, 0.05f); + Math_ApproachF(&D_80B7A6AC, (Math_SinS(sLureTimer * 3000) * 0.025f) + -0.03f, 1.0f, 0.05f); + Math_ApproachZeroF(&sRodBendRotY, 1.0f, 0.05f); - if ((D_80B7E0B4 >= 19) && (D_80B7E0B4 <= 24)) { + if ((sRodCastTimer > 18) && (sRodCastTimer < 25)) { Math_ApproachF(&D_80B7A6B8, 0.8f, 1.0f, 0.2f); } else { Math_ApproachF(&D_80B7A6B8, 0.0f, 1.0f, 0.4f); @@ -2036,7 +2049,7 @@ void Fishing_DrawRod(PlayState* play) { Matrix_Translate(0.0f, 230.0f, 0.0f, MTXMODE_APPLY); } - if (D_80B7A694 == 5) { + if (sRodCastState == 5) { Matrix_RotateY(0.56f * M_PI, MTXMODE_APPLY); } else { Matrix_RotateY(0.41f * M_PI, MTXMODE_APPLY); @@ -2052,7 +2065,7 @@ void Fishing_DrawRod(PlayState* play) { Matrix_Translate(0.0f, 0.0f, -1300.0f, MTXMODE_APPLY); for (i = 0; i < 22; i++) { - Matrix_RotateY(sRodBendRatios[i] * D_80B7A6A8 * 0.5f, MTXMODE_APPLY); + Matrix_RotateY(sRodBendRatios[i] * sRodBendRotY * 0.5f, MTXMODE_APPLY); Matrix_RotateX(sRodBendRatios[i] * spC0 * 0.5f, MTXMODE_APPLY); Matrix_Push(); @@ -2085,18 +2098,18 @@ void Fishing_DrawRod(PlayState* play) { CLOSE_DISPS(play->state.gfxCtx, "../z_fishing.c", 3838); } -static Vec3f D_80B7AF94 = { 0.0f, 0.0f, 0.0f }; +static Vec3f sSoundPos = { 0.0f, 0.0f, 0.0f }; void Fishing_UpdateLure(Fishing* this, PlayState* play) { f32 spE4; f32 spE0; - s16 phi_v0; + s16 timer; s16 spDC; f32 spD8; f32 spD4; f32 spD0; - f32 phi_f16; - f32 spC8; + f32 lengthCasted; + f32 lureXZLen; s16 i; Player* player = GET_PLAYER(play); Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; @@ -2108,12 +2121,12 @@ void Fishing_UpdateLure(Fishing* this, PlayState* play) { f32 sp7C; f32 sp78; f32 phi_f0; - f32 sp70; + f32 wiggle; Vec3f sp64; Vec3f sp58; s32 pad; - D_80B7E0AE++; + sLureTimer++; if (D_80B7E0B0 != 0) { D_80B7E0B0--; @@ -2123,12 +2136,12 @@ void Fishing_UpdateLure(Fishing* this, PlayState* play) { D_80B7E0B2--; } - if (D_80B7E0B4 != 0) { - D_80B7E0B4--; + if (sRodCastTimer != 0) { + sRodCastTimer--; } - if (D_80B7E122 != 0) { - D_80B7E122--; + if (sLureBitTimer != 0) { + sLureBitTimer--; } if (D_80B7E150 != 0) { @@ -2139,33 +2152,34 @@ void Fishing_UpdateLure(Fishing* this, PlayState* play) { D_80B7A6A4--; } - if (D_80B7E0A4 != 0) { - D_80B7E0A4--; + if (sRumbleDelay != 0) { + sRumbleDelay--; } if (D_80B7E114 != 0) { D_80B7E114--; } - if (D_80B7E0AC == 1) { - D_80B7E0AC = 2; - D_80B7E084 = 0; - D_80B7E082 = 0; - D_80B7E0B6 = 0; + if (sFishingPlayingState == 1) { + sFishingPlayingState = 2; + sFishesCaught = 0; + sPondOwnerTextIdIndex = 0; + sLureEquipped = FS_LURE_STOCK; - if (((sLinkAge == LINK_AGE_CHILD) && (HIGH_SCORE(HS_FISHING) & 0x400)) || - ((sLinkAge != LINK_AGE_CHILD) && (HIGH_SCORE(HS_FISHING) & 0x800))) { + // if prize item won as child or adult, set the sinking lure location. + if (((sLinkAge == LINK_AGE_CHILD) && (HIGH_SCORE(HS_FISHING) & HS_FISH_PRIZE_CHILD)) || + ((sLinkAge != LINK_AGE_CHILD) && (HIGH_SCORE(HS_FISHING) & HS_FISH_PRIZE_ADULT))) { sSinkingLureLocation = (u8)Rand_ZeroFloat(3.999f) + 1; } D_80B7E148 = 520.0f; - D_80B7E144 = 195.0f; + sRodLineSpooled = 195.0f; - D_80B7A694 = D_80B7E0B6 = D_80B7E0AE = D_80B7E0B0 = D_80B7E0B2 = D_80B7E0B4 = D_80B7E120 = D_80B7E114 = + sRodCastState = sLureEquipped = sLureTimer = D_80B7E0B0 = D_80B7E0B2 = sRodCastTimer = sWiggleAttraction = D_80B7E114 = D_80B7E150 = 0; - D_80B7E104 = D_80B7E154 = D_80B7E108 = 0.0f; + sLure1Rotate = sReelLinePosStep = sLurePosZOffset = 0.0f; - D_80B7E128 = zeroVec; + sLureLineSegPosDelta = zeroVec; for (i = 0; i < LINE_SEG_COUNT; i++) { sReelLinePos[i] = zeroVec; @@ -2174,78 +2188,78 @@ void Fishing_UpdateLure(Fishing* this, PlayState* play) { } } - SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &sLurePos, &D_80B7AF94, &sProjectedW); + SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &sLurePos, &sSoundPos, &sProjectedW); - if (D_80B7A694 == 0) { - Math_ApproachF(&D_80B7E108, -800.0f, 1.0f, 20.0f); + if (sRodCastState == 0) { + Math_ApproachF(&sLurePosZOffset, -800.0f, 1.0f, 20.0f); } else { - Math_ApproachF(&D_80B7E108, 300.0f, 1.0f, 20.0f); + Math_ApproachF(&sLurePosZOffset, 300.0f, 1.0f, 20.0f); } - switch (D_80B7A694) { + switch (sRodCastState) { case 0: - D_80B7FEA0 = 0; + sSinkingLureSegmentIndex = 0; if (KREG(14) != 0) { KREG(14) = 0; - D_80B7E0B6 = 2 - D_80B7E0B6; - if (D_80B7E0B6 != 0) { - D_80B7E082 = 0; + sLureEquipped = FS_LURE_SINKING - sLureEquipped; + if (sLureEquipped != FS_LURE_STOCK) { + sPondOwnerTextIdIndex = 0; } } - Math_ApproachF(&D_80B7E144, 195.0f, 1.0f, 1.0f); + Math_ApproachF(&sRodLineSpooled, 195.0f, 1.0f, 1.0f); if (player->stateFlags1 & PLAYER_STATE1_27) { - D_80B7E0B4 = 0; + sRodCastTimer = 0; player->unk_860 = 0; } - if (D_80B7E0B4 == 0) { + if (sRodCastTimer == 0) { if ((D_80B7E0B0 == 0) && (player->unk_860 == 1)) { - D_80B7E0B4 = 37; + sRodCastTimer = 37; Message_CloseTextbox(play); } } else { sLureRot.x = sReelLineRot[LINE_SEG_COUNT - 2].x + M_PI; sLureRot.y = sReelLineRot[LINE_SEG_COUNT - 2].y; - if (D_80B7E0B4 == 18) { - D_80B7A694 = 1; + if (sRodCastTimer == 18) { + sRodCastState = 1; sLurePos = sRodTipPos; Matrix_RotateY(BINANG_TO_RAD_ALT(player->actor.shape.rot.y), MTXMODE_NEW); sp90.x = 0.0f; sp90.y = 0.0f; sp90.z = 25.0f; - Matrix_MultVec3f(&sp90, &D_80B7E0E8); - D_80B7E0E8.y = 15.0f; - D_80B7E0F8.x = D_80B7E0F8.z = 0.0f; - D_80B7E0F8.y = -1.0f; + Matrix_MultVec3f(&sp90, &sLurePosDelta); + sLurePosDelta.y = 15.0f; + sLureCastDelta.x = sLureCastDelta.z = 0.0f; + sLureCastDelta.y = -1.0f; D_80B7E148 = 0.0f; D_80B7E0B2 = 5; - D_80B7E11C = 0.5f; + sRodReelingSpeed = 0.5f; D_80B7E118 = Rand_ZeroFloat(1.9f); sFishMouthOffset.y = 500.0f; - Sfx_PlaySfxAtPos(&D_80B7AF94, NA_SE_IT_SWORD_SWING_HARD); + Sfx_PlaySfxAtPos(&sSoundPos, NA_SE_IT_SWORD_SWING_HARD); } } break; - case 1: + case 1: // casting the line spE0 = sLurePos.y; - sLurePos.x += D_80B7E0E8.x; - sLurePos.y += D_80B7E0E8.y; - sLurePos.z += D_80B7E0E8.z; + sLurePos.x += sLurePosDelta.x; + sLurePos.y += sLurePosDelta.y; + sLurePos.z += sLurePosDelta.z; - D_80B7E0E8.x += D_80B7E0F8.x; - D_80B7E0E8.y += D_80B7E0F8.y; - D_80B7E0E8.z += D_80B7E0F8.z; - - if (CHECK_BTN_ALL(input->cur.button, BTN_A) || (D_80B7A68C != 0)) { - D_80B7E0E8.x *= 0.9f; - D_80B7E0E8.z *= 0.9f; - if (D_80B7A68C == 0) { + sLurePosDelta.x += sLureCastDelta.x; + sLurePosDelta.y += sLureCastDelta.y; + sLurePosDelta.z += sLureCastDelta.z; + // air drag by hat or reeling during cast. + if (CHECK_BTN_ALL(input->cur.button, BTN_A) || sIsOwnersHatHooked) { + sLurePosDelta.x *= 0.9f; + sLurePosDelta.z *= 0.9f; + if (!sIsOwnersHatHooked) { Sfx_PlaySfxCentered(NA_SE_IT_FISHING_REEL_HIGH - SFX_FLAG); } } @@ -2262,14 +2276,14 @@ void Fishing_UpdateLure(Fishing* this, PlayState* play) { sLureRot.y = Math_Atan2F(spD0, spD8) + M_PI; } - phi_f16 = sqrtf(SQ(spD8) + SQ(spD4) + SQ(spD0)); - if (phi_f16 > 1000.0f) { - phi_f16 = 1000.0f; + lengthCasted = sqrtf(SQ(spD8) + SQ(spD4) + SQ(spD0)); + if (lengthCasted > 1000.0f) { + lengthCasted = 1000.0f; } - D_80B7E144 = 200.0f - (phi_f16 * 200.0f * 0.001f); + sRodLineSpooled = 200.0f - (lengthCasted * 200.0f * 0.001f); - spC8 = SQ(sLurePos.x) + SQ(sLurePos.z); - if (spC8 > SQ(920.0f)) { + lureXZLen = SQ(sLurePos.x) + SQ(sLurePos.z); + if (lureXZLen > SQ(920.0f)) { if ((KREG(56) != 0) || (sLurePos.y > 160.0f) || (sLurePos.x < 80.0f) || (sLurePos.x > 180.0f) || (sLurePos.z > 1350.0f) || (sLurePos.z < 1100.0f) || (sLurePos.y < 45.0f)) { sp80 = this->actor.world.pos; @@ -2279,50 +2293,50 @@ void Fishing_UpdateLure(Fishing* this, PlayState* play) { this->actor.world.pos = sp80; if (this->actor.bgCheckFlags & BGCHECKFLAG_CEILING) { - D_80B7E0E8.y = -0.5f; + sLurePosDelta.y = -0.5f; } if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { - if (D_80B7E0E8.y > 0.0f) { - D_80B7E0E8.y = 0.0f; + if (sLurePosDelta.y > 0.0f) { + sLurePosDelta.y = 0.0f; } - D_80B7E0E8.x = D_80B7E0E8.z = 0.0f; + sLurePosDelta.x = sLurePosDelta.z = 0.0f; } } else { - if (func_80B6C2EC(&sLurePos) != 0) { - D_80B7A694 = 3; - D_80B7E154 = 0.0f; + if (Fishing_IsAboveCounter(&sLurePos)) { + sRodCastState = 3; + sReelLinePosStep = 0.0f; } } - spE4 = ((sqrtf(spC8) - 920.0f) * 0.11f) + WATER_SURFACE_Y(play); + spE4 = ((sqrtf(lureXZLen) - 920.0f) * 0.11f) + WATER_SURFACE_Y(play); if (sLurePos.y <= spE4) { sLurePos.y = spE4; - D_80B7E0E8.x = D_80B7E0E8.y = D_80B7E0E8.z = 0.0f; - D_80B7A694 = 3; - D_80B7E154 = 0.0; + sLurePosDelta.x = sLurePosDelta.y = sLurePosDelta.z = 0.0f; + sRodCastState = 3; + sReelLinePosStep = 0.0; } else { Math_ApproachF(&D_80B7E148, 0.0f, 1.0f, 0.05f); - Sfx_PlaySfxAtPos(&D_80B7AF94, NA_SE_EN_FANTOM_FLOAT - SFX_FLAG); + Sfx_PlaySfxAtPos(&sSoundPos, NA_SE_EN_FANTOM_FLOAT - SFX_FLAG); } } else { spE4 = WATER_SURFACE_Y(play); if (sLurePos.y <= spE4) { - D_80B7A694 = 2; - D_80B7E154 = 0.0f; - D_80B7E0E8.x = D_80B7E0E8.z = 0.0f; + sRodCastState = 2; + sReelLinePosStep = 0.0f; + sLurePosDelta.x = sLurePosDelta.z = 0.0f; - if (D_80B7E0B6 == 2) { - D_80B7E0A2 = 0; + if (sLureEquipped == FS_LURE_SINKING) { + sLureMoveDelay = 0; } else { - D_80B7E0A2 = 10; + sLureMoveDelay = 10; } if ((sLurePos.y <= spE4) && (spE4 < spE0) && (spE4 == WATER_SURFACE_Y(play))) { D_80B7E114 = 10; - Sfx_PlaySfxAtPos(&D_80B7AF94, NA_SE_EV_BOMB_DROP_WATER); - D_80B7E0F8.y = 0.0f; - D_80B7E0E8.y *= 0.2f; + Sfx_PlaySfxAtPos(&sSoundPos, NA_SE_EV_BOMB_DROP_WATER); + sLureCastDelta.y = 0.0f; + sLurePosDelta.y *= 0.2f; for (i = 0; i < 50; i++) { sp7C = Rand_ZeroFloat(1.5f) + 0.5f; @@ -2346,7 +2360,7 @@ void Fishing_UpdateLure(Fishing* this, PlayState* play) { } } else { Math_ApproachZeroF(&D_80B7E148, 1.0f, 0.05f); - Sfx_PlaySfxAtPos(&D_80B7AF94, NA_SE_EN_FANTOM_FLOAT - SFX_FLAG); + Sfx_PlaySfxAtPos(&sSoundPos, NA_SE_EN_FANTOM_FLOAT - SFX_FLAG); } } @@ -2354,219 +2368,220 @@ void Fishing_UpdateLure(Fishing* this, PlayState* play) { sReelLinePos[LINE_SEG_COUNT - 1].y = sLurePos.y; sReelLinePos[LINE_SEG_COUNT - 1].z = sLurePos.z; - D_80B7E140 = 1.0f; - D_80B7E10C = 0.5f; + sLureWiggleSign = 1.0f; + sLureRotXTarget = 0.5f; break; case 2: if (sLurePos.y <= WATER_SURFACE_Y(play)) { - sLurePos.y += D_80B7E0E8.y; + sLurePos.y += sLurePosDelta.y; - Math_ApproachZeroF(&D_80B7E0E8.y, 1.0f, 1.0f); + Math_ApproachZeroF(&sLurePosDelta.y, 1.0f, 1.0f); - if (D_80B7E0B6 != 2) { + if (sLureEquipped != FS_LURE_SINKING) { Math_ApproachF(&sLurePos.y, WATER_SURFACE_Y(play), 0.5f, 1.0f); } } Math_ApproachF(&D_80B7E148, 2.0f, 1.0f, 0.1f); - if (D_80B7E0A2 == 0) { - D_80B7A694 = 3; + if (sLureMoveDelay == 0) { + sRodCastState = 3; } else { - D_80B7E0A2--; + sLureMoveDelay--; } break; case 3: - D_80B7FEA0 = 0; + sSinkingLureSegmentIndex = 0; - if ((D_80B7A68C != 0) && ((SQ(sLurePos.x) + SQ(sLurePos.z)) < SQ(500.0f))) { - D_80B7A690 = 1; + if (sIsOwnersHatHooked && ((SQ(sLurePos.x) + SQ(sLurePos.z)) < SQ(500.0f))) { + sIsOwnersHatSunk = true; } player->unk_860 = 2; - if (D_80B7E138 < 3.0f) { - spD0 = D_80B7E10C * Math_SinS(D_80B7E0AE * 0x1060); - Math_ApproachF(&sLureRot.x, -M_PI / 6.0f + spD0, 0.3f, D_80B7E110); - Math_ApproachF(&D_80B7E110, 0.5f, 1.0f, 0.02f); - Math_ApproachZeroF(&D_80B7E10C, 1.0f, 0.02f); + if (sLureWigglePosY < 3.0f) { + spD0 = sLureRotXTarget * Math_SinS(sLureTimer * 0x1060); + Math_ApproachF(&sLureRot.x, -M_PI / 6.0f + spD0, 0.3f, sLureRotXStep); + Math_ApproachF(&sLureRotXStep, 0.5f, 1.0f, 0.02f); + Math_ApproachZeroF(&sLureRotXTarget, 1.0f, 0.02f); } else { - D_80B7E110 = 0.0f; + sLureRotXStep = 0.0f; } spDC = 0x4000; spE4 = WATER_SURFACE_Y(play); - spC8 = SQ(sLurePos.x) + SQ(sLurePos.z); - if (spC8 < SQ(920.0f)) { + lureXZLen = SQ(sLurePos.x) + SQ(sLurePos.z); + if (lureXZLen < SQ(920.0f)) { if (sLurePos.y <= (spE4 + 4.0f)) { - sp70 = 0.0f; + wiggle = 0.0f; if (D_80B7E150 == 0) { if (fabsf(input->rel.stick_x) > 30.0f) { - sp70 = fabsf((input->rel.stick_x - D_80B7A6C4) * (1.0f / 60.0f)); + wiggle = fabsf((input->rel.stick_x - sStickAdjXPrev) * (1.0f / 60.0f)); } else if (fabsf(input->rel.stick_y) > 30.0f) { - sp70 = fabsf((input->rel.stick_y - D_80B7A6C8) * (1.0f / 60.0f)); + wiggle = fabsf((input->rel.stick_y - sStickAdjYPrev) * (1.0f / 60.0f)); } } - if (sp70 > 1.0f) { - sp70 = 1.0f; + if (wiggle > 1.0f) { + wiggle = 1.0f; } if (CHECK_BTN_ALL(input->press.button, BTN_B)) { - sp70 = 0.5f; + wiggle = 0.5f; } - if (D_80B7A68C != 0) { - if (sp70 > 0.3f) { - sp70 = 0.3f; + if (sIsOwnersHatHooked) { + if (wiggle > 0.3f) { + wiggle = 0.3f; } } - if ((sp70 > 0.2f) && (D_80B7E138 < 4.0f)) { + if ((wiggle > 0.2f) && (sLureWigglePosY < 4.0f)) { D_80B7E150 = 5; - if (sp70 > 0.8f) { - D_80B7E120 = 2; + if (wiggle > 0.8f) { + sWiggleAttraction = 2; } else { - D_80B7E120 = 1; + sWiggleAttraction = 1; } sp90.x = player->actor.world.pos.x - sLurePos.x; sp90.z = player->actor.world.pos.z - sLurePos.z; sp90.y = Math_Atan2F(sp90.z, sp90.x); - D_80B7E134 = (sp70 * D_80B7E140) + sp90.y; - D_80B7E140 = D_80B7E140 * -1.0f; - D_80B7E138 = fabsf(sp70) * 6.0f; + sLureWiggleRotYTarget = (wiggle * sLureWiggleSign) + sp90.y; + sLureWiggleSign *= -1.0f; + sLureWigglePosY = fabsf(wiggle) * 6.0f; sLureRot.x = 0.0f; - D_80B7E10C = 0.5f; - D_80B7E144 += (fabsf(sp70) * (7.5f + (KREG(25) * 0.1f))); + sLureRotXTarget = 0.5f; + sRodLineSpooled += (fabsf(wiggle) * (7.5f + (KREG(25) * 0.1f))); - func_800F436C(&D_80B7AF94, NA_SE_EV_LURE_MOVE_W, (sp70 * 1.999f * 0.25f) + 0.75f); + func_800F436C(&sSoundPos, NA_SE_EV_LURE_MOVE_W, (wiggle * 1.999f * 0.25f) + 0.75f); - if (D_80B7E0B6 == 2) { - D_80B7E128.y = 5.0f * sp70; - sReelLinePos[LINE_SEG_COUNT - 1].y += D_80B7E128.y; - sLurePos.y += D_80B7E128.y; + if (sLureEquipped == FS_LURE_SINKING) { + sLureLineSegPosDelta.y = 5.0f * wiggle; + sReelLinePos[LINE_SEG_COUNT - 1].y += sLureLineSegPosDelta.y; + sLurePos.y += sLureLineSegPosDelta.y; } } else if (CHECK_BTN_ALL(input->cur.button, BTN_A)) { spDC = 0x500; - D_80B7E134 = sReelLineRot[LINE_SEG_COUNT - 2].y + M_PI; + sLureWiggleRotYTarget = sReelLineRot[LINE_SEG_COUNT - 2].y + M_PI; sLureRot.x = 0.0f; - D_80B7E10C = 0.5f; - if (D_80B7E0B6 == 2) { - D_80B7E128.y = 0.2f; - sReelLinePos[LINE_SEG_COUNT - 1].y += D_80B7E128.y; - sLurePos.y += D_80B7E128.y; + sLureRotXTarget = 0.5f; + if (sLureEquipped == FS_LURE_SINKING) { + sLureLineSegPosDelta.y = 0.2f; + sReelLinePos[LINE_SEG_COUNT - 1].y += sLureLineSegPosDelta.y; + sLurePos.y += sLureLineSegPosDelta.y; } } } else { - if (D_80B7E144 > 150.0f) { + if (sRodLineSpooled > 150.0f) { sLureRot.x = sReelLineRot[LINE_SEG_COUNT - 2].x + M_PI; - D_80B7E134 = sReelLineRot[LINE_SEG_COUNT - 2].y + M_PI; - D_80B7E144 += 2.0f; + sLureWiggleRotYTarget = sReelLineRot[LINE_SEG_COUNT - 2].y + M_PI; + sRodLineSpooled += 2.0f; } } } else { - spE4 = ((sqrtf(spC8) - 920.0f) * 0.11f) + WATER_SURFACE_Y(play); + spE4 = ((sqrtf(lureXZLen) - 920.0f) * 0.11f) + WATER_SURFACE_Y(play); if (sLurePos.y <= spE4) { sLurePos.y = spE4; spDC = 0x500; - D_80B7E134 = sReelLineRot[LINE_SEG_COUNT - 2].y + M_PI; + sLureWiggleRotYTarget = sReelLineRot[LINE_SEG_COUNT - 2].y + M_PI; sLureRot.x = 0.0f; + // lure hopping on land if (CHECK_BTN_ALL(input->press.button, BTN_B)) { - D_80B7E144 += 6.0f; - Sfx_PlaySfxAtPos(&D_80B7AF94, NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_SAND); + sRodLineSpooled += 6.0f; + Sfx_PlaySfxAtPos(&sSoundPos, NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_SAND); } } else { - if (D_80B7E144 > 150.0f) { + if (sRodLineSpooled > 150.0f) { sLureRot.x = sReelLineRot[LINE_SEG_COUNT - 2].x + M_PI; - D_80B7E134 = sReelLineRot[LINE_SEG_COUNT - 2].y + M_PI; - D_80B7E144 += 2.0f; + sLureWiggleRotYTarget = sReelLineRot[LINE_SEG_COUNT - 2].y + M_PI; + sRodLineSpooled += 2.0f; } } } - Math_ApproachZeroF(&D_80B7E138, 1.0f, 0.3f); - Math_ApproachS(&D_80B7E13C, (D_80B7E134 * 32768.0f) / M_PI, 3, spDC); + Math_ApproachZeroF(&sLureWigglePosY, 1.0f, 0.3f); + Math_ApproachS(&sLureWiggleRotY, (sLureWiggleRotYTarget * 32768.0f) / M_PI, 3, spDC); - sLureRot.y = BINANG_TO_RAD_ALT(D_80B7E13C); + sLureRot.y = BINANG_TO_RAD_ALT(sLureWiggleRotY); sp90.x = 0.0f; sp90.y = 0.0f; - sp90.z = D_80B7E138; + sp90.z = sLureWigglePosY; Matrix_RotateY(sLureRot.y, MTXMODE_NEW); - if (D_80B7E0B6 == 2) { + if (sLureEquipped == FS_LURE_SINKING) { Matrix_MultVec3f(&sp90, &sp64); - D_80B7E128.x = sp64.x; - D_80B7E128.z = sp64.z; + sLureLineSegPosDelta.x = sp64.x; + sLureLineSegPosDelta.z = sp64.z; phi_f0 = 10.0f; } else { - Matrix_MultVec3f(&sp90, &D_80B7E128); + Matrix_MultVec3f(&sp90, &sLureLineSegPosDelta); phi_f0 = 0.0f; } - D_80B7E104 = 0.0f; + sLure1Rotate = 0.0f; - if ((D_80B7E0B6 == 1) && CHECK_BTN_ALL(input->cur.button, BTN_A)) { - D_80B7E128.y = -2.0f; + if ((sLureEquipped == FS_LURE_UNK) && CHECK_BTN_ALL(input->cur.button, BTN_A)) { + sLureLineSegPosDelta.y = -2.0f; - if ((D_80B7E0AE & 1) != 0) { - D_80B7E104 = 0.5f; + if ((sLureTimer & 1) != 0) { + sLure1Rotate = 0.5f; } else { - D_80B7E104 = -0.5f; + sLure1Rotate = -0.5f; } } else if (sReelLinePos[LINE_SEG_COUNT - 1].y < (WATER_SURFACE_Y(play) + phi_f0)) { - if (D_80B7E0B6 == 2) { + if (sLureEquipped == FS_LURE_SINKING) { sp58 = this->actor.world.pos; this->actor.prevPos = this->actor.world.pos = sLurePos; Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 30.0f, 30.0f, UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_6); this->actor.world.pos = sp58; - D_80B7E128.y += -0.5f; - if (D_80B7E128.y < -1.0f) { - D_80B7E128.y = -1.0f; + sLureLineSegPosDelta.y += -0.5f; + if (sLureLineSegPosDelta.y < -1.0f) { + sLureLineSegPosDelta.y = -1.0f; } if (sLurePos.y < (this->actor.floorHeight + 5.0f)) { sReelLinePos[LINE_SEG_COUNT - 1].y = sLurePos.y = this->actor.floorHeight + 5.0f; - D_80B7E128.y = 0.0f; + sLureLineSegPosDelta.y = 0.0f; } else { - D_80B7E120 = 1; + sWiggleAttraction = 1; } } else { - D_80B7E128.y = fabsf(sReelLinePos[LINE_SEG_COUNT - 1].y - WATER_SURFACE_Y(play)) * 0.2f; - if (D_80B7E128.y > 1.5f) { - D_80B7E128.y = 1.5f; + sLureLineSegPosDelta.y = fabsf(sReelLinePos[LINE_SEG_COUNT - 1].y - WATER_SURFACE_Y(play)) * 0.2f; + if (sLureLineSegPosDelta.y > 1.5f) { + sLureLineSegPosDelta.y = 1.5f; } } } - sReelLinePos[LINE_SEG_COUNT - 1].x += D_80B7E128.x; - sReelLinePos[LINE_SEG_COUNT - 1].y += D_80B7E128.y; - sReelLinePos[LINE_SEG_COUNT - 1].z += D_80B7E128.z; + sReelLinePos[LINE_SEG_COUNT - 1].x += sLureLineSegPosDelta.x; + sReelLinePos[LINE_SEG_COUNT - 1].y += sLureLineSegPosDelta.y; + sReelLinePos[LINE_SEG_COUNT - 1].z += sLureLineSegPosDelta.z; if (sReelLinePos[LINE_SEG_COUNT - 1].y > (spE4 + 6.0f)) { sReelLinePos[LINE_SEG_COUNT - 1].y -= 5.0f; } - D_80B7E0E8.x = D_80B7E0E8.y = D_80B7E0E8.z = D_80B7E0F8.y = 0.0f; + sLurePosDelta.x = sLurePosDelta.y = sLurePosDelta.z = sLureCastDelta.y = 0.0f; if (CHECK_BTN_ALL(input->cur.button, BTN_A)) { if (CHECK_BTN_ALL(input->cur.button, BTN_R)) { - D_80B7E144 += 1.5f; + sRodLineSpooled += 1.5f; Sfx_PlaySfxCentered(NA_SE_IT_FISHING_REEL_HIGH - SFX_FLAG); - Math_ApproachF(&D_80B7E154, 1000.0f, 1.0f, 2.0f); + Math_ApproachF(&sReelLinePosStep, 1000.0f, 1.0f, 2.0f); } else { - D_80B7E144 += D_80B7E11C; + sRodLineSpooled += sRodReelingSpeed; Sfx_PlaySfxCentered(NA_SE_IT_FISHING_REEL_SLOW - SFX_FLAG); - Math_ApproachF(&D_80B7E154, 1000.0f, 1.0f, 0.2f); + Math_ApproachF(&sReelLinePosStep, 1000.0f, 1.0f, 0.2f); } if (sReelLinePos[LINE_SEG_COUNT - 1].y > (WATER_SURFACE_Y(play) + 4.0f)) { @@ -2578,31 +2593,31 @@ void Fishing_UpdateLure(Fishing* this, PlayState* play) { Math_ApproachF(&D_80B7E148, 2.0f, 1.0f, 0.2f); } - Math_ApproachF(&sLurePos.x, sReelLinePos[LINE_SEG_COUNT - 1].x, 1.0f, D_80B7E154); - Math_ApproachF(&sLurePos.y, sReelLinePos[LINE_SEG_COUNT - 1].y, 1.0f, D_80B7E154); - Math_ApproachF(&sLurePos.z, sReelLinePos[LINE_SEG_COUNT - 1].z, 1.0f, D_80B7E154); + Math_ApproachF(&sLurePos.x, sReelLinePos[LINE_SEG_COUNT - 1].x, 1.0f, sReelLinePosStep); + Math_ApproachF(&sLurePos.y, sReelLinePos[LINE_SEG_COUNT - 1].y, 1.0f, sReelLinePosStep); + Math_ApproachF(&sLurePos.z, sReelLinePos[LINE_SEG_COUNT - 1].z, 1.0f, sReelLinePosStep); - if (D_80B7E138 > 1.0f) { - Math_ApproachF(&D_80B7E154, 1000.0f, 1.0f, 1.0f); + if (sLureWigglePosY > 1.0f) { + Math_ApproachF(&sReelLinePosStep, 1000.0f, 1.0f, 1.0f); } - Math_ApproachF(&D_80B7E154, 1000.0f, 1.0f, 0.1f); + Math_ApproachF(&sReelLinePosStep, 1000.0f, 1.0f, 0.1f); - if (D_80B7E144 >= 195.0f) { - D_80B7E144 = 195.0f; - D_80B7A694 = 0; + if (sRodLineSpooled >= 195.0f) { + sRodLineSpooled = 195.0f; + sRodCastState = 0; D_80B7E148 = 520.0f; - D_80B7A6CC = 3; + sFishingPlayerCinematicState = 3; } if ((sLurePos.y <= (WATER_SURFACE_Y(play) + 4.0f)) && (sLurePos.y >= (WATER_SURFACE_Y(play) - 4.0f))) { - phi_v0 = 63; - if (CHECK_BTN_ALL(input->cur.button, BTN_A) || (D_80B7E138 > 1.0f)) { - phi_v0 = 1; + timer = 63; + if (CHECK_BTN_ALL(input->cur.button, BTN_A) || (sLureWigglePosY > 1.0f)) { + timer = 1; } - if ((D_80B7E0AE & phi_v0) == 0) { + if ((sLureTimer & timer) == 0) { spA8 = sLurePos; spA8.y = WATER_SURFACE_Y(play); Fishing_SpawnRipple(NULL, play->specialEffects, &spA8, 30.0f, 300.0f, 150, 90); @@ -2613,20 +2628,20 @@ void Fishing_UpdateLure(Fishing* this, PlayState* play) { case 4: if (this->unk_157 != 0) { this->unk_157--; - D_80B7E144 += D_80B7E11C; + sRodLineSpooled += sRodReelingSpeed; } if (CHECK_BTN_ALL(input->cur.button, BTN_A)) { if ((SQ(sLurePos.x) + SQ(sLurePos.z)) > SQ(920.0f)) { - D_80B7E144 += (1.0f + (KREG(65) * 0.1f)); + sRodLineSpooled += (1.0f + (KREG(65) * 0.1f)); } else { - D_80B7E144 += D_80B7E11C; + sRodLineSpooled += sRodReelingSpeed; } Sfx_PlaySfxCentered(NA_SE_IT_FISHING_REEL_SLOW - SFX_FLAG); } - if ((D_80B7E0AE & 0x1F) == 0) { - if ((D_80B7E124 != 0) || (D_80B7E0B6 != 2)) { + if ((sLureTimer & 0x1F) == 0) { + if (sLineHooked || (sLureEquipped != FS_LURE_SINKING)) { D_80B7A6A4 = 5; } } @@ -2635,7 +2650,7 @@ void Fishing_UpdateLure(Fishing* this, PlayState* play) { break; case 5: - D_80B7E14C = 0.0005000001f; + sFishingLineScale = 0.0005000001f; sReelLinePos[LINE_SEG_COUNT - 1].x = sLurePos.x; sReelLinePos[LINE_SEG_COUNT - 1].y = sLurePos.y; sReelLinePos[LINE_SEG_COUNT - 1].z = sLurePos.z; @@ -2644,7 +2659,7 @@ void Fishing_UpdateLure(Fishing* this, PlayState* play) { } } -s32 func_80B70A2C(Fishing* this, PlayState* play, u8 ignorePosCheck) { +s32 Fishing_SplashBySize(Fishing* this, PlayState* play, u8 ignorePosCheck) { s16 i; s16 count; f32 scale; @@ -2658,9 +2673,9 @@ s32 func_80B70A2C(Fishing* this, PlayState* play, u8 ignorePosCheck) { } // Necessary to match - if (this->unk_1AC) {} + if (this->fishLength) {} - if (this->unk_1AC >= 40.0f) { + if (this->fishLength >= 40.0f) { count = 40; scale = 1.2f; } else { @@ -2690,12 +2705,12 @@ s32 func_80B70A2C(Fishing* this, PlayState* play, u8 ignorePosCheck) { Fishing_SpawnRipple(&this->actor.projectedPos, play->specialEffects, &pos, 100.0f, 800.0f, 150, 90); - this->unk_151 = 30; + this->lilyTimer = 30; return true; } -void func_80B70CF0(Fishing* this, PlayState* play) { +void Fishing_SplashBySize2(Fishing* this, PlayState* play) { s16 count; s16 i; f32 scale; @@ -2705,9 +2720,9 @@ void func_80B70CF0(Fishing* this, PlayState* play) { f32 angle; // Necessary to match - if (this->unk_1AC) {} + if (this->fishLength) {} - if (this->unk_1AC >= 45.0f) { + if (this->fishLength >= 45.0f) { count = 30; scale = 0.5f; } else { @@ -2734,86 +2749,86 @@ void func_80B70CF0(Fishing* this, PlayState* play) { } void func_80B70ED4(Fishing* this, Input* input) { - Vec3f sp34; + Vec3f lineVec; Vec3f sp28; - f32 sp24; + f32 lineLengthSQ; - sp34.x = sLurePos.x - this->actor.world.pos.x; - sp34.y = sLurePos.y - this->actor.world.pos.y; - sp34.z = sLurePos.z - this->actor.world.pos.z; + lineVec.x = sLurePos.x - this->actor.world.pos.x; + lineVec.y = sLurePos.y - this->actor.world.pos.y; + lineVec.z = sLurePos.z - this->actor.world.pos.z; - sp24 = SQ(sp34.x) + SQ(sp34.y) + SQ(sp34.z); + lineLengthSQ = SQ(lineVec.x) + SQ(lineVec.y) + SQ(lineVec.z); - if ((D_80B7A694 == 3) && (this->unk_1A2 == 0) && (D_80B7A68C == 0)) { + if ((sRodCastState == 3) && (this->unk_1A2 == 0) && !sIsOwnersHatHooked) { Matrix_RotateY(BINANG_TO_RAD_ALT(-this->actor.shape.rot.y), MTXMODE_NEW); - Matrix_MultVec3f(&sp34, &sp28); + Matrix_MultVec3f(&lineVec, &sp28); - if ((sp28.z > 0.0f) || (this->unk_1AC < 40.0f)) { - if ((this->unk_158 == 7) && (sp24 < SQ(200.0f))) { - this->unk_158 = 4; - this->unk_1B4 = sLurePos; - this->unk_1B0 = 28672.0f; - this->unk_188 = 5.0f; + if ((sp28.z > 0.0f) || (this->fishLength < 40.0f)) { + if ((this->fishState == 7) && (lineLengthSQ < SQ(200.0f))) { + this->fishState = 4; + this->fishTargetPos = sLurePos; + this->rotationStep = 28672.0f; + this->speedTarget = 5.0f; } else { - if ((CHECK_BTN_ALL(input->cur.button, BTN_A) || (D_80B7E138 > 1.0f)) && (sp24 < SQ(120.0f))) { - this->unk_158 = 2; + if ((CHECK_BTN_ALL(input->cur.button, BTN_A) || (sLureWigglePosY > 1.0f)) && (lineLengthSQ < SQ(120.0f))) { + this->fishState = 2; this->unk_15E = 0; - this->unk_17A[0] = 0; - this->unk_17A[2] = (s16)Rand_ZeroFloat(100.0f) + 100; - this->unk_1A8 = sFishInits[this->actor.params - 100].unk_0C; - this->unk_1B0 = 0.0f; + this->timerArray[0] = 0; + this->timerArray[2] = (s16)Rand_ZeroFloat(100.0f) + 100; + this->perception = sFishInits[this->actor.params - EN_FISH_PARAM].perception; + this->rotationStep = 0.0f; } - if ((this->unk_17A[1] == 0) && (sp24 < SQ(70.0f))) { - this->unk_158 = 2; + if ((this->timerArray[1] == 0) && (lineLengthSQ < SQ(70.0f))) { + this->fishState = 2; this->unk_15E = 0; - this->unk_17A[0] = 0; - this->unk_17A[2] = (s16)Rand_ZeroFloat(100.0f) + 100; - this->unk_1A8 = sFishInits[this->actor.params - 100].unk_0C; - this->unk_1B0 = 0.0f; + this->timerArray[0] = 0; + this->timerArray[2] = (s16)Rand_ZeroFloat(100.0f) + 100; + this->perception = sFishInits[this->actor.params - EN_FISH_PARAM].perception; + this->rotationStep = 0.0f; } } } - } else if ((D_80B7A694 == 4) && (D_80B7E124 != 0) && (sp24 < SQ(100.0f)) && (this->unk_158 >= 10)) { - this->unk_15A = 0; - this->unk_158 = 1; + } else if ((sRodCastState == 4) && sLineHooked && (lineLengthSQ < SQ(100.0f)) && (this->fishState >= 10)) { + this->fishStateNext = 0; + this->fishState = 1; this->unk_1A4 = 1000; this->unk_1A2 = 100; - this->unk_17A[1] = 50; + this->timerArray[1] = 50; } - if ((D_80B7E0B6 != 2) && (D_80B7E114 != 0) && (this->unk_1AC > 60.0f) && (sp24 < SQ(30.0f)) && - (this->unk_158 >= 10)) { - this->unk_15A = 0; - this->unk_158 = 1; + if ((sLureEquipped != FS_LURE_SINKING) && (D_80B7E114 != 0) && (this->fishLength > 60.0f) && + (lineLengthSQ < SQ(30.0f)) && (this->fishState >= 10)) { + this->fishStateNext = 0; + this->fishState = 1; this->unk_1A4 = 1000; this->unk_1A2 = 100; - this->unk_17A[1] = 50; + this->timerArray[1] = 50; } } -void func_80B71278(Fishing* this, u8 arg1) { +void Fishing_FishLeapSfx(Fishing* this, u8 outOfWater) { s16 sfxId; - u8 temp; + u8 length; - if (this->unk_150 == 0) { - temp = this->unk_1AC; + if (this->isLoach == 0) { + length = this->fishLength; } else { - temp = 2.0f * this->unk_1AC; + length = 2.0f * this->fishLength; } - if (arg1 == 0) { - if (temp >= 50) { + if (outOfWater == false) { + if (length >= 50) { sfxId = NA_SE_EV_DIVE_INTO_WATER; - } else if (temp >= 40) { + } else if (length >= 40) { sfxId = NA_SE_EV_BOMB_DROP_WATER; } else { sfxId = NA_SE_EV_BOMB_DROP_WATER; } } else { - if (temp >= 50) { + if (length >= 50) { sfxId = NA_SE_EV_JUMP_OUT_WATER; - } else if (temp >= 40) { + } else if (length >= 40) { sfxId = NA_SE_EV_OUT_OF_WATER; } else { sfxId = NA_SE_EV_OUT_OF_WATER; @@ -2825,8 +2840,8 @@ void func_80B71278(Fishing* this, u8 arg1) { void Fishing_HandleAquariumDialog(Fishing* this, PlayState* play) { if (sLinkAge == LINK_AGE_CHILD) { - if ((HIGH_SCORE(HS_FISHING) & 0x7F) != 0) { - if (HIGH_SCORE(HS_FISHING) & 0x80) { + if ((HIGH_SCORE(HS_FISHING) & HS_FISH_LENGTH_CHILD) != 0) { + if (HIGH_SCORE(HS_FISHING) & HS_FISH_CHEAT_CHILD) { this->actor.textId = 0x40B1; } else { this->actor.textId = 0x4089; @@ -2835,8 +2850,8 @@ void Fishing_HandleAquariumDialog(Fishing* this, PlayState* play) { this->actor.textId = 0x40AE; } } else { - if ((HIGH_SCORE(HS_FISHING) & 0x7F000000) != 0) { - if (HIGH_SCORE(HS_FISHING) & 0x80000000) { + if ((HIGH_SCORE(HS_FISHING) & HS_FISH_LENGTH_ADULT) != 0) { + if (HIGH_SCORE(HS_FISHING) & HS_FISH_CHEAT_ADULT) { this->actor.textId = 0x40B1; } else { this->actor.textId = 0x4089; @@ -2846,47 +2861,47 @@ void Fishing_HandleAquariumDialog(Fishing* this, PlayState* play) { } } - if (this->unk_1D3 == 0) { - if (this->unk_1D4 == 0) { + if (!this->isAquariumMessage) { + if (this->aquariumWaitTimer == 0) { this->actor.flags |= ACTOR_FLAG_0; if (Actor_ProcessTalkRequest(&this->actor, play)) { - D_80B7A678 = D_80B7E078; - this->unk_1D3 = 1; + sFishLengthToWeigh = sFishingRecordLength; + this->isAquariumMessage = true; } else { func_8002F2F4(&this->actor, play); } } else { - this->unk_1D4--; + this->aquariumWaitTimer--; this->actor.flags &= ~ACTOR_FLAG_0; } } else if (Actor_TextboxIsClosing(&this->actor, play)) { - this->unk_1D3 = 0; - this->unk_1D4 = 20; + this->isAquariumMessage = false; + this->aquariumWaitTimer = 20; } } void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { s16 i; - s16 sp134 = 10; - f32 sp130; - f32 sp12C; - f32 sp128; - f32 sp124; + s16 rotXYScale = 10; + f32 distX; + f32 distY; + f32 distZ; + f32 distToTarget; f32 multiplier; - f32 sp11C; - f32 sp118; - Vec3f sp10C; - Vec3f sp100; - s16 spFE; - s16 spFC; - s16 spFA; - s16 phi_v0; + f32 chance; + f32 playerSpeedMod; + Vec3f multiVecSrc; + Vec3f targetPosOffset; + s16 rotXTarget; + s16 rotYtarget; + s16 rotZScale; + s16 timer; s16 spF6; - s16 spF4; - s16 spF2; - s16 spF0; - s16 spEE; + s16 rotXScale; + s16 rotXStep; + s16 rotYScale; + s16 rotYStep; Fishing* this = (Fishing*)thisx; PlayState* play = play2; Player* player = GET_PLAYER(play); @@ -2894,47 +2909,47 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { f32 spD8; f32 phi_f0; f32 phi_f2; - Vec3f spC4; + Vec3f bubblePos; Vec3f spB8; u8 phi_v0_2; f32 temp_f0; f32 temp; s32 pad; - f32 spA4; - u16 spA2; - u8 phi_a1; + f32 rumbleStrength; + u16 attempts; + u8 rumbleStrength8; this->actor.uncullZoneForward = 700.0f; this->actor.uncullZoneScale = 50.0f; - if (this->unk_150 == 0) { - sp118 = (player->actor.speed * 0.15f) + 0.25f; + if (this->isLoach == 0) { + playerSpeedMod = (player->actor.speed * 0.15f) + 0.25f; } else { - sp118 = (player->actor.speed * 0.3f) + 0.25f; + playerSpeedMod = (player->actor.speed * 0.3f) + 0.25f; } if ((D_80B7E0B0 != 0) || (sSubCamId != SUB_CAM_ID_DONE) || - ((player->actor.world.pos.z > 1150.0f) && (this->unk_158 != 100))) { + ((player->actor.world.pos.z > 1150.0f) && (this->fishState != 100))) { this->actor.flags &= ~ACTOR_FLAG_0; } else { this->actor.flags |= ACTOR_FLAG_0; - if (D_80B7A694 != 0) { + if (sRodCastState != 0) { if (D_80B7E0B2 == 0) { this->actor.focus.pos = sLurePos; } else if (D_80B7E0B2 == 1) { - D_80B7A6CC = 1; + sFishingPlayerCinematicState = 1; D_80B7FED0 = 0.0f; - D_80B7E088 = 2; + sLureCameraZoomLevel = 2; } } this->actor.focus.pos = this->actor.world.pos; } - this->unk_15C++; + this->stateAndTimer++; for (i = 0; i < 4; i++) { - if (this->unk_17A[i] != 0) { - this->unk_17A[i]--; + if (this->timerArray[i] != 0) { + this->timerArray[i]--; } } @@ -2946,18 +2961,18 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { this->unk_1A2--; } - if (this->unk_1A0 != 0) { - this->unk_1A0--; + if (this->bumpTimer != 0) { + this->bumpTimer--; } - if (this->unk_151 != 0) { - this->unk_151--; + if (this->lilyTimer != 0) { + this->lilyTimer--; } - Math_ApproachF(&this->unk_198, this->unk_190, 1.0f, 0.2f); + Math_ApproachF(&this->fishLimbRotPhaseStep, this->unk_190, 1.0f, 0.2f); - if (this->unk_158 == 6) { - Math_ApproachF(&this->unk_19C, this->unk_194, 0.2f, 200.0f); + if (this->fishState == 6) { + Math_ApproachF(&this->fishLimbRotPhaseMag, this->unk_194, 0.2f, 200.0f); } else { phi_f0 = 1.0f; phi_f2 = 1.0f; @@ -2965,62 +2980,62 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { phi_f0 = (KREG(64) * 0.1f) + 1.5f; phi_f2 = 3.0f; } - Math_ApproachF(&this->unk_19C, this->unk_194 * phi_f0, 1.0f, 500.0f * phi_f2); + Math_ApproachF(&this->fishLimbRotPhaseMag, this->unk_194 * phi_f0, 1.0f, 500.0f * phi_f2); } - Math_ApproachS(&this->unk_170, 0, 5, 0x1F4); + Math_ApproachS(&this->fishLimbDRotZDelta, 0, 5, 500); - if (this->unk_150 == 0) { - Actor_SetScale(&this->actor, this->unk_1AC * 15.0f * 0.00001f); + if (this->isLoach == 0) { + Actor_SetScale(&this->actor, this->fishLength * 15.0f * 0.00001f); - this->unk_18C += this->unk_198; + this->fishLimbRotPhase += this->fishLimbRotPhaseStep; - temp = cosf(this->unk_18C); - this->unk_16C = this->unk_16E + (s16)(temp * this->unk_19C); + temp = cosf(this->fishLimbRotPhase); + this->fishLimb23RotYDelta = this->unk_16E + (s16)(temp * this->fishLimbRotPhaseMag); - temp = cosf(this->unk_18C + -1.2f); - this->unk_176 = this->unk_16E + (s16)(temp * this->unk_19C * 1.6f); + temp = cosf(this->fishLimbRotPhase + -1.2f); + this->fishLimb4RotYDelta = this->unk_16E + (s16)(temp * this->fishLimbRotPhaseMag * 1.6f); } else { - Actor_SetScale(&this->actor, this->unk_1AC * 65.0f * 0.000001f); + Actor_SetScale(&this->actor, this->fishLength * 65.0f * 0.000001f); this->actor.scale.x = this->actor.scale.z * 1.1f; this->actor.scale.y = this->actor.scale.z * 1.1f; - this->unk_18C += this->unk_198 * 0.8f; + this->fishLimbRotPhase += this->fishLimbRotPhaseStep * 0.8f; for (i = 0; i < 3; i++) { - temp = cosf(this->unk_18C + (i * 2.1f)); - this->unk_1CC[i] = this->unk_16E + (s16)(temp * this->unk_19C * 2.0f); + temp = cosf(this->fishLimbRotPhase + (i * 2.1f)); + this->loachRotYDelta[i] = this->unk_16E + (s16)(temp * this->fishLimbRotPhaseMag * 2.0f); } - temp = cosf(this->unk_18C + 0.4f); - this->unk_16C = (this->unk_19C * temp * 2.0f) * 0.6f; + temp = cosf(this->fishLimbRotPhase + 0.4f); + this->fishLimb23RotYDelta = (this->fishLimbRotPhaseMag * temp * 2.0f) * 0.6f; } - sp130 = this->unk_1B4.x - this->actor.world.pos.x; - sp12C = this->unk_1B4.y - this->actor.world.pos.y; - sp128 = this->unk_1B4.z - this->actor.world.pos.z; + distX = this->fishTargetPos.x - this->actor.world.pos.x; + distY = this->fishTargetPos.y - this->actor.world.pos.y; + distZ = this->fishTargetPos.z - this->actor.world.pos.z; - spFC = Math_Atan2S(sp128, sp130); - sp124 = sqrtf(SQ(sp130) + SQ(sp128)); + rotYtarget = Math_Atan2S(distZ, distX); + distToTarget = sqrtf(SQ(distX) + SQ(distZ)); - spFE = Math_Atan2S(sp124, sp12C); - sp124 = sqrtf(SQ(sp130) + SQ(sp128) + SQ(sp12C)); + rotXTarget = Math_Atan2S(distToTarget, distY); + distToTarget = sqrtf(SQ(distX) + SQ(distZ) + SQ(distY)); - if ((this->unk_1A0 != 0) && (this->unk_158 != 2) && (this->unk_158 != 3) && (this->unk_158 != 4)) { - if ((this->unk_15C & 0x40) != 0) { - spFC += 0x4000; + if ((this->bumpTimer != 0) && (this->fishState != 2) && (this->fishState != 3) && (this->fishState != 4)) { + if ((this->stateAndTimer & 0x40) != 0) { + rotYtarget += 0x4000; } else { - spFC -= 0x4000; + rotYtarget -= 0x4000; } - if (((this->unk_15C + 0x20) & 0x40) != 0) { - spFE += 0x2000; + if (((this->stateAndTimer + 0x20) & 0x40) != 0) { + rotXTarget += 0x2000; } else { - spFE -= 0x2000; + rotXTarget -= 0x2000; } } - switch (this->unk_158) { + switch (this->fishState) { case 100: Fishing_HandleAquariumDialog(this, play); @@ -3031,109 +3046,109 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { (s16)this->actor.world.pos.y + 20.0f, (s16)this->actor.world.pos.z - 50.0f, 255, 255, 255, 255); - this->unk_1AC = D_80B7E078; - sp100.y = (f32)Math_SinS(play->gameplayFrames * 300) * 1; - sp100.z = (f32)Math_SinS(play->gameplayFrames * 230) * 2; + this->fishLength = sFishingRecordLength; + targetPosOffset.y = (f32)Math_SinS(play->gameplayFrames * 300) * 1; + targetPosOffset.z = (f32)Math_SinS(play->gameplayFrames * 230) * 2; this->actor.world.pos.x = 130.0f; - this->actor.world.pos.y = 55.0f + sp100.y; - this->actor.world.pos.z = 1300.0f + sp100.z; + this->actor.world.pos.y = 55.0f + targetPosOffset.y; + this->actor.world.pos.z = 1300.0f + targetPosOffset.z; this->actor.shape.rot.y = -0x8000; if ((this->actor.projectedPos.z < 200.0f) && (this->actor.projectedPos.z > 0.0f)) { - spC4.x = Rand_CenteredFloat(5.0f) + 130.0f; - spC4.y = 40.0f; - spC4.z = Rand_CenteredFloat(5.0f) + 1280.0f; - Fishing_SpawnBubble(NULL, play->specialEffects, &spC4, Rand_ZeroFloat(0.02f) + 0.03f, 1); + bubblePos.x = Rand_CenteredFloat(5.0f) + 130.0f; + bubblePos.y = 40.0f; + bubblePos.z = Rand_CenteredFloat(5.0f) + 1280.0f; + Fishing_SpawnBubble(NULL, play->specialEffects, &bubblePos, Rand_ZeroFloat(0.02f) + 0.03f, 1); } - Math_ApproachS(&this->unk_172, (Math_SinS(this->unk_15C * 0x800) * 2500.0f) + 2500.0f, 2, 0x7D0); - Math_ApproachS(&this->unk_174, Math_SinS(this->unk_15C * 0xA00) * 1500.0f, 2, 0x7D0); + Math_ApproachS(&this->fishLimbEFRotYDelta, (Math_SinS(this->stateAndTimer * 0x800) * 2500.0f) + 2500.0f, 2, 0x7D0); + Math_ApproachS(&this->fishLimb89RotYDelta, Math_SinS(this->stateAndTimer * 0xA00) * 1500.0f, 2, 0x7D0); this->unk_190 = 0.3f; this->unk_194 = 1000.0f / 3.0f; return; case 10: - this->unk_1B4 = this->actor.home.pos; + this->fishTargetPos = this->actor.home.pos; Math_ApproachF(&this->actor.speed, 2.0f, 1.0f, 0.5f); - Math_ApproachF(&this->unk_1B0, 4096.0f, 1.0f, 256.0f); + Math_ApproachF(&this->rotationStep, 4096.0f, 1.0f, 256.0f); - if (sp124 < 40.0f) { - this->unk_158 = 11; + if (distToTarget < 40.0f) { + this->fishState = 11; this->unk_190 = 0.4f; this->unk_194 = 500.0f; } func_80B70ED4(this, input); - if (this->actor.xzDistToPlayer < (250.0f * sp118)) { - this->unk_15A = this->unk_158 = 0; + if (this->actor.xzDistToPlayer < (250.0f * playerSpeedMod)) { + this->fishStateNext = this->fishState = 0; this->unk_1A4 = 1000; this->unk_1A2 = 200; - this->unk_17A[1] = 50; + this->timerArray[1] = 50; } break; case 11: - this->unk_1B4 = this->actor.home.pos; + this->fishTargetPos = this->actor.home.pos; Math_ApproachF(&this->actor.speed, 0.0f, 1.0f, 0.05f); - Math_ApproachF(&this->unk_1B0, 0.0f, 1.0f, 256.0f); + Math_ApproachF(&this->rotationStep, 0.0f, 1.0f, 256.0f); - if (sp124 >= 40.0f) { - this->unk_158 = 10; + if (distToTarget >= 40.0f) { + this->fishState = 10; this->unk_190 = 1.0f; this->unk_194 = 2000.0f; } func_80B70ED4(this, input); - if (this->actor.xzDistToPlayer < (250.0f * sp118)) { - this->unk_15A = this->unk_158 = 0; + if (this->actor.xzDistToPlayer < (250.0f * playerSpeedMod)) { + this->fishStateNext = this->fishState = 0; this->unk_1A4 = 1000; this->unk_1A2 = 200; - this->unk_17A[1] = 50; + this->timerArray[1] = 50; } if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { if ((gSaveContext.save.dayTime >= CLOCK_TIME(18, 0)) && (gSaveContext.save.dayTime <= CLOCK_TIME(18, 0) + 27)) { - this->unk_158 = 7; - this->unk_17A[3] = (s16)Rand_ZeroFloat(150.0f) + 200; + this->fishState = 7; + this->timerArray[3] = (s16)Rand_ZeroFloat(150.0f) + 200; } if ((gSaveContext.save.dayTime >= CLOCK_TIME(5, 30) - 1) && (gSaveContext.save.dayTime < CLOCK_TIME(5, 30) + 27)) { - this->unk_158 = 7; - this->unk_17A[3] = (s16)Rand_ZeroFloat(150.0f) + 200; + this->fishState = 7; + this->timerArray[3] = (s16)Rand_ZeroFloat(150.0f) + 200; } } if (KREG(15) != 0) { KREG(15) = 0; - this->unk_158 = 7; - this->unk_17A[3] = (s16)Rand_ZeroFloat(150.0f) + 2000; + this->fishState = 7; + this->timerArray[3] = (s16)Rand_ZeroFloat(150.0f) + 2000; } break; case 0: Math_ApproachF(&this->actor.speed, 1.0f, 1.0f, 0.05f); - Math_ApproachF(&this->unk_1B0, 0.0f, 1.0f, 256.0f); + Math_ApproachF(&this->rotationStep, 0.0f, 1.0f, 256.0f); - if (this->unk_17A[0] == 0) { + if (this->timerArray[0] == 0) { if (this->unk_1A4 == 0) { - this->unk_158 = this->unk_15A = 10; + this->fishState = this->fishStateNext = 10; } else { - this->unk_158 = 1; - this->unk_17A[0] = (s16)Rand_ZeroFloat(30.0f) + 10; - this->unk_1B4.x = Rand_CenteredFloat(300.0f); - this->unk_1B4.y = (WATER_SURFACE_Y(play) - 50.0f) - Rand_ZeroFloat(50.0f); - this->unk_1B4.z = Rand_CenteredFloat(300.0f); + this->fishState = 1; + this->timerArray[0] = (s16)Rand_ZeroFloat(30.0f) + 10; + this->fishTargetPos.x = Rand_CenteredFloat(300.0f); + this->fishTargetPos.y = (WATER_SURFACE_Y(play) - 50.0f) - Rand_ZeroFloat(50.0f); + this->fishTargetPos.z = Rand_CenteredFloat(300.0f); this->unk_190 = 1.0f; this->unk_194 = 2000.0f; } } - if (D_80B7E0B6 == 2) { + if (sLureEquipped == FS_LURE_SINKING) { func_80B70ED4(this, input); } else { this->actor.flags &= ~ACTOR_FLAG_0; @@ -3141,36 +3156,36 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { break; case 1: - if (this->unk_150 == 1) { - this->unk_158 = -1; + if (this->isLoach == 1) { + this->fishState = -1; this->unk_1A4 = 20000; this->unk_1A2 = 20000; - this->unk_1B4.x = 0.0f; - this->unk_1B4.y = -140.0f; - this->unk_1B4.z = 0.0f; + this->fishTargetPos.x = 0.0f; + this->fishTargetPos.y = -140.0f; + this->fishTargetPos.z = 0.0f; } else { - Math_ApproachF(&this->unk_1B0, 4096.0f, 1.0f, 256.0f); + Math_ApproachF(&this->rotationStep, 4096.0f, 1.0f, 256.0f); - if ((this->actor.xzDistToPlayer < (250.0f * sp118)) || (this->unk_17A[1] != 0)) { - Math_ApproachF(&this->unk_1B0, 8192.0f, 1.0f, 768.0f); + if ((this->actor.xzDistToPlayer < (250.0f * playerSpeedMod)) || (this->timerArray[1] != 0)) { + Math_ApproachF(&this->rotationStep, 8192.0f, 1.0f, 768.0f); Math_ApproachF(&this->actor.speed, 4.2f, 1.0f, 0.75); this->unk_190 = 1.2f; this->unk_194 = 4000.0f; - this->unk_17A[0] = 20; + this->timerArray[0] = 20; } else { this->unk_190 = 1.0f; this->unk_194 = 2000.0f; Math_ApproachF(&this->actor.speed, 1.5f, 1.0f, 0.1f); } - if ((this->unk_17A[0] == 0) || (sp124 < 50.0f)) { - this->unk_158 = 0; - this->unk_17A[0] = (s16)Rand_ZeroFloat(30.0f) + 3; + if ((this->timerArray[0] == 0) || (distToTarget < 50.0f)) { + this->fishState = 0; + this->timerArray[0] = (s16)Rand_ZeroFloat(30.0f) + 3; this->unk_190 = 1.0f; this->unk_194 = 500.0f; } - if (D_80B7E0B6 == 2) { + if (sLureEquipped == FS_LURE_SINKING) { func_80B70ED4(this, input); } else { this->actor.flags &= ~ACTOR_FLAG_0; @@ -3178,57 +3193,57 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { } break; - case -1: - Math_ApproachS(&this->unk_166, 0, 0x14, 0x20); + case -1: // loach state 1 + Math_ApproachS(&this->rotationTarget.x, 0, 0x14, 0x20); - if ((this->actor.xzDistToPlayer < (250.0f * sp118)) || (this->unk_17A[1] != 0)) { + if ((this->actor.xzDistToPlayer < (250.0f * playerSpeedMod)) || (this->timerArray[1] != 0)) { Math_ApproachF(&this->actor.speed, 3.0f, 1.0f, 0.75); this->unk_190 = 1.0f; - this->unk_17A[0] = 20; + this->timerArray[0] = 20; this->unk_194 = 4000.0f; - Math_ApproachF(&this->unk_1B0, 4096.0f, 1.0f, 256.0f); + Math_ApproachF(&this->rotationStep, 4096.0f, 1.0f, 256.0f); if ((play->gameplayFrames % 32) == 0) { - this->unk_1B4.x = Rand_CenteredFloat(600.0f); - this->unk_1B4.z = Rand_CenteredFloat(600.0f); - this->unk_1B4.y = -120.0f; + this->fishTargetPos.x = Rand_CenteredFloat(600.0f); + this->fishTargetPos.z = Rand_CenteredFloat(600.0f); + this->fishTargetPos.y = -120.0f; } - } else if (sp124 > 50.0f) { + } else if (distToTarget > 50.0f) { this->unk_190 = 0.8f; this->unk_194 = 1500.0f; Math_ApproachF(&this->actor.speed, 1.0f, 1.0f, 0.1f); - Math_ApproachF(&this->unk_1B0, 2048.0f, 1.0f, 128.0f); + Math_ApproachF(&this->rotationStep, 2048.0f, 1.0f, 128.0f); } else { this->unk_190 = 0.4f; this->unk_194 = 500.0f; Math_ApproachZeroF(&this->actor.speed, 1.0f, 0.02f); - Math_ApproachF(&this->unk_1B0, 0.0f, 1.0f, 256.0f); + Math_ApproachF(&this->rotationStep, 0.0f, 1.0f, 256.0f); } if (this->unk_1A4 == 0) { - this->unk_158 = 10; - this->unk_15A = 10; + this->fishState = 10; + this->fishStateNext = 10; } else if ((KREG(2) != 0) || (((this->unk_1A4 & 0x7FF) == 0) && (this->unk_1A4 < 15000))) { KREG(2) = 0; - this->unk_158 = -2; + this->fishState = -2; this->actor.world.rot.x = this->actor.shape.rot.x = 0; - this->unk_1B4.y = WATER_SURFACE_Y(play) + 10.0f; - this->unk_1B4.x = Rand_ZeroFloat(50.0f); - this->unk_1B4.z = Rand_ZeroFloat(50.0f); + this->fishTargetPos.y = WATER_SURFACE_Y(play) + 10.0f; + this->fishTargetPos.x = Rand_ZeroFloat(50.0f); + this->fishTargetPos.z = Rand_ZeroFloat(50.0f); } this->actor.flags &= ~ACTOR_FLAG_0; break; case -2: - if ((this->actor.xzDistToPlayer < (250.0f * sp118)) || (this->unk_17A[1] != 0)) { - this->unk_158 = -1; - this->unk_1B4.y = -120.0f; + if ((this->actor.xzDistToPlayer < (250.0f * playerSpeedMod)) || (this->timerArray[1] != 0)) { + this->fishState = -1; + this->fishTargetPos.y = -120.0f; } else { this->unk_190 = 0.6f; this->unk_194 = 1000.0f; - Math_ApproachS(&this->unk_166, -0x1000, 0x14, 0x100); + Math_ApproachS(&this->rotationTarget.x, -0x1000, 0x14, 0x100); if (this->actor.world.pos.y < (WATER_SURFACE_Y(play) - 20.0f)) { Math_ApproachF(&this->actor.speed, 0.5f, 1.0f, 0.1f); @@ -3236,11 +3251,11 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { Math_ApproachZeroF(&this->actor.speed, 1.0f, 0.01f); if ((this->actor.speed == 0.0f) || (this->actor.world.pos.y > (WATER_SURFACE_Y(play) - 5.0f))) { - this->unk_1B4.x = Rand_ZeroFloat(300.0f); - this->unk_1B4.z = Rand_ZeroFloat(300.0f); - this->unk_1B4.y = this->actor.floorHeight + 10.0f; - this->unk_158 = -25; - this->unk_1B0 = 0.0f; + this->fishTargetPos.x = Rand_ZeroFloat(300.0f); + this->fishTargetPos.z = Rand_ZeroFloat(300.0f); + this->fishTargetPos.y = this->actor.floorHeight + 10.0f; + this->fishState = -25; + this->rotationStep = 0.0f; spB8 = this->fishMouthPos; spB8.y = WATER_SURFACE_Y(play); @@ -3254,99 +3269,99 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { } } - Math_ApproachF(&this->unk_1B0, 2048.0f, 1.0f, 128.0f); + Math_ApproachF(&this->rotationStep, 2048.0f, 1.0f, 128.0f); this->actor.flags &= ~ACTOR_FLAG_0; } break; case -25: - if ((this->actor.xzDistToPlayer < (250.0f * sp118)) || (this->unk_17A[1] != 0)) { - this->unk_158 = -1; - this->unk_1B4.y = -120.0f; + if ((this->actor.xzDistToPlayer < (250.0f * playerSpeedMod)) || (this->timerArray[1] != 0)) { + this->fishState = -1; + this->fishTargetPos.y = -120.0f; } else { - Math_ApproachS(&this->unk_166, 0x1000, 0x14, 0x6A); + Math_ApproachS(&this->rotationTarget.x, 0x1000, 0x14, 0x6A); - if (sp124 > 40.0f) { + if (distToTarget > 40.0f) { this->unk_190 = 0.7f; this->unk_194 = 1200.0f; Math_ApproachF(&this->actor.speed, 0.5f, 1.0f, 0.01f); - Math_ApproachF(&this->unk_1B0, 2048.0f, 1.0f, 128.0f); + Math_ApproachF(&this->rotationStep, 2048.0f, 1.0f, 128.0f); } else { - this->unk_158 = -1; + this->fishState = -1; } } break; case 2: if (((this->actor.params + D_80B7E118) & 1) != 0) { - sp10C.x = 10.0f; + multiVecSrc.x = 10.0f; } else { - sp10C.x = -10.0f; + multiVecSrc.x = -10.0f; } - sp10C.y = 0.0f; - sp10C.z = 0.0f; + multiVecSrc.y = 0.0f; + multiVecSrc.z = 0.0f; Matrix_RotateY(sLureRot.y, MTXMODE_NEW); - Matrix_MultVec3f(&sp10C, &sp100); + Matrix_MultVec3f(&multiVecSrc, &targetPosOffset); - this->unk_1B4.x = sLurePos.x + sp100.x; - this->unk_1B4.z = sLurePos.z + sp100.z; + this->fishTargetPos.x = sLurePos.x + targetPosOffset.x; + this->fishTargetPos.z = sLurePos.z + targetPosOffset.z; - if (D_80B7E0B6 == 2) { - this->unk_1B4.y = sLurePos.y; - } else if (this->unk_150 == 0) { - this->unk_1B4.y = sLurePos.y - 15.0f; + if (sLureEquipped == FS_LURE_SINKING) { + this->fishTargetPos.y = sLurePos.y; + } else if (this->isLoach == 0) { + this->fishTargetPos.y = sLurePos.y - 15.0f; } else { - this->unk_1B4.y = sLurePos.y - 5.0f; + this->fishTargetPos.y = sLurePos.y - 5.0f; } - if (this->unk_1B4.y <= this->actor.floorHeight) { - this->unk_1B4.y = this->actor.floorHeight + 3.0f; + if (this->fishTargetPos.y <= this->actor.floorHeight) { + this->fishTargetPos.y = this->actor.floorHeight + 3.0f; } - if ((D_80B7E0B6 != 2) && (this->unk_1B4.y < this->actor.world.pos.y)) { - Math_ApproachF(&this->actor.world.pos.y, this->unk_1B4.y, 0.1f, - (this->actor.world.pos.y - this->unk_1B4.y) * 0.1f); + if ((sLureEquipped != FS_LURE_SINKING) && (this->fishTargetPos.y < this->actor.world.pos.y)) { + Math_ApproachF(&this->actor.world.pos.y, this->fishTargetPos.y, 0.1f, + (this->actor.world.pos.y - this->fishTargetPos.y) * 0.1f); } - Math_ApproachF(&this->unk_1B0, 8192.0f, 1.0f, (KREG(16) * 128) + 384.0f); + Math_ApproachF(&this->rotationStep, 8192.0f, 1.0f, (KREG(16) * 128) + 384.0f); if (CHECK_BTN_ALL(input->press.button, BTN_A)) { - this->unk_1A8 += 0.005f; + this->perception += 0.005f; } - if (D_80B7E120 != 0) { - if (D_80B7E120 == 1) { - this->unk_1A8 += 0.01f; + if (sWiggleAttraction != 0) { + if (sWiggleAttraction == 1) { + this->perception += 0.01f; } else { - this->unk_1A8 += 0.05f; + this->perception += 0.05f; } - D_80B7E120 = 0; + sWiggleAttraction = 0; } if (CHECK_BTN_ALL(input->press.button, BTN_B)) { - this->unk_1A8 += 0.008f; + this->perception += 0.008f; } - if (sp124 < ((this->unk_1AC * 0.5f) + 20.0f)) { + if (distToTarget < ((this->fishLength * 0.5f) + 20.0f)) { if (this->unk_15E == 0) { this->unk_190 = 1.0f; this->unk_194 = 500.0f; - this->unk_17A[0] = (s16)Rand_ZeroFloat(10.0f) + 2; + this->timerArray[0] = (s16)Rand_ZeroFloat(10.0f) + 2; } Math_ApproachF(&this->actor.speed, -0.2f, 1.0f, 0.1f); this->unk_15E = 1; } else { if (this->unk_15E != 0) { this->unk_190 = 1.0f; - this->unk_1B0 = 0.0f; + this->rotationStep = 0.0f; this->unk_194 = 3000.0f; } Math_ApproachF(&this->actor.speed, 3.0f, 1.0f, 0.15f); this->unk_15E = 0; } - if (this->unk_1AC >= 60.0f) { + if (this->fishLength >= 60.0f) { multiplier = 0.3f; - } else if (this->unk_1AC >= 45.0f) { + } else if (this->fishLength >= 45.0f) { multiplier = 0.6f; } else { multiplier = 1.0f; @@ -3357,202 +3372,203 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { } else if ((gSaveContext.save.dayTime >= CLOCK_TIME(5, 0)) && (gSaveContext.save.dayTime < CLOCK_TIME(7, 0))) { multiplier *= 1.5f; - } else if (D_80B7E076 != 0) { + } else if (sFishingFoggy != 0) { multiplier *= 1.5f; - } else if ((u8)D_80B7A650 != 0) { + } else if ((u8)sStormStrength != 0) { multiplier *= 3.0f; } - sp11C = 0.03f * multiplier; - if (D_80B7E0B6 == 2) { - sp11C *= 5.0f; + chance = 0.03f * multiplier; + if (sLureEquipped == FS_LURE_SINKING) { + chance *= 5.0f; } - if (((this->unk_17A[0] == 1) || (Rand_ZeroOne() < sp11C)) && - ((Rand_ZeroOne() < (this->unk_1A8 * multiplier)) || ((this->unk_150 + 1) == KREG(69)))) { - if (this->unk_150 == 0) { - this->unk_158 = 3; + if (((this->timerArray[0] == 1) || (Rand_ZeroOne() < chance)) && + ((Rand_ZeroOne() < (this->perception * multiplier)) || ((this->isLoach + 1) == KREG(69)))) { + if (this->isLoach == 0) { + this->fishState = 3; this->unk_190 = 1.2f; this->unk_194 = 5000.0f; - this->unk_17A[0] = Rand_ZeroFloat(10.0f); + this->timerArray[0] = Rand_ZeroFloat(10.0f); } else { - this->unk_158 = -3; + this->fishState = -3; this->unk_190 = 1.0f; this->unk_194 = 3000.0f; - this->unk_17A[0] = 40; + this->timerArray[0] = 40; } - if (D_80B7E0B6 == 2) { - this->unk_188 = Rand_ZeroFloat(1.5f) + 3.0f; + if (sLureEquipped == FS_LURE_SINKING) { + this->speedTarget = Rand_ZeroFloat(1.5f) + 3.0f; } else { - this->unk_188 = Rand_ZeroFloat(1.5f) + 4.5f; + this->speedTarget = Rand_ZeroFloat(1.5f) + 4.5f; } } - if ((D_80B7A694 != 3) || (this->unk_17A[2] == 0) || + if ((sRodCastState != 3) || (this->timerArray[2] == 0) || (sqrtf(SQ(this->actor.world.pos.x) + SQ(this->actor.world.pos.z)) > 800.0f)) { - this->unk_158 = this->unk_15A; - this->unk_17A[1] = (s16)Rand_ZeroFloat(30.0f) + 50; - this->unk_17A[0] = (s16)Rand_ZeroFloat(10.0f) + 5; + this->fishState = this->fishStateNext; + this->timerArray[1] = (s16)Rand_ZeroFloat(30.0f) + 50; + this->timerArray[0] = (s16)Rand_ZeroFloat(10.0f) + 5; this->unk_190 = 1.0f; - this->unk_1B0 = 0.0f; + this->rotationStep = 0.0f; this->unk_194 = 2000.0f; } - if (this->actor.xzDistToPlayer < (100.0f * sp118)) { - this->unk_15A = this->unk_158 = 0; + if (this->actor.xzDistToPlayer < (100.0f * playerSpeedMod)) { + this->fishStateNext = this->fishState = 0; this->unk_1A4 = 1000; this->unk_1A2 = 200; - this->unk_17A[1] = 50; + this->timerArray[1] = 50; } break; case 3: - this->unk_151 = 6; - sp134 = 2; + this->lilyTimer = 6; + rotXYScale = 2; if ((((s16)player->actor.world.pos.x + D_80B7E118) & 1) != 0) { - sp10C.x = 30.0f; + multiVecSrc.x = 30.0f; } else { - sp10C.x = -30.0f; + multiVecSrc.x = -30.0f; } - sp10C.y = 0.0f; - sp10C.z = 30.0f; + multiVecSrc.y = 0.0f; + multiVecSrc.z = 30.0f; Matrix_RotateY(sLureRot.y, MTXMODE_NEW); - Matrix_MultVec3f(&sp10C, &sp100); + Matrix_MultVec3f(&multiVecSrc, &targetPosOffset); - this->unk_1B4.x = sLurePos.x + sp100.x; - this->unk_1B4.z = sLurePos.z + sp100.z; - this->unk_1B4.y = sLurePos.y - 10.0f; - this->unk_1B0 = 4096.0f; - Math_ApproachF(&this->actor.speed, this->unk_188 * 0.8f, 1.0f, 1.0f); + this->fishTargetPos.x = sLurePos.x + targetPosOffset.x; + this->fishTargetPos.z = sLurePos.z + targetPosOffset.z; + this->fishTargetPos.y = sLurePos.y - 10.0f; + this->rotationStep = 4096.0f; + Math_ApproachF(&this->actor.speed, this->speedTarget * 0.8f, 1.0f, 1.0f); - if ((D_80B7A694 != 3) || (sLurePos.y > (WATER_SURFACE_Y(play) + 5.0f)) || + if ((sRodCastState != 3) || (sLurePos.y > (WATER_SURFACE_Y(play) + 5.0f)) || (sqrtf(SQ(sLurePos.x) + SQ(sLurePos.z)) > 800.0f)) { - this->unk_158 = this->unk_15A; - this->unk_17A[0] = 0; + this->fishState = this->fishStateNext; + this->timerArray[0] = 0; this->unk_190 = 1.0f; this->unk_194 = 2000.0f; - } else if ((this->unk_17A[0] == 0) || (sp124 < 30.0f)) { - this->unk_158 = 4; - this->unk_1B4 = sLurePos; - this->unk_1B0 = 16384.0f; + } else if ((this->timerArray[0] == 0) || (distToTarget < 30.0f)) { + this->fishState = 4; + this->fishTargetPos = sLurePos; + this->rotationStep = 16384.0f; this->unk_190 = 1.2f; this->unk_194 = 5000.0f; - this->unk_17A[0] = 20; + this->timerArray[0] = 20; } break; case 4: - Math_ApproachF(&this->unk_1B0, 16384.0f, 1.0f, 4096.0f); - Math_ApproachS(&this->unk_170, 0x4E20, 4, 0x1388); + Math_ApproachF(&this->rotationStep, 16384.0f, 1.0f, 4096.0f); + Math_ApproachS(&this->fishLimbDRotZDelta, 0x4E20, 4, 0x1388); - this->unk_151 = 50; - sp134 = 2; - this->unk_1B4 = sLurePos; - Math_ApproachF(&this->actor.speed, this->unk_188, 1.0f, 1.0f); + this->lilyTimer = 50; + rotXYScale = 2; + this->fishTargetPos = sLurePos; + Math_ApproachF(&this->actor.speed, this->speedTarget, 1.0f, 1.0f); - if ((D_80B7A694 != 3) || (this->unk_17A[0] == 0) || (sLurePos.y > (WATER_SURFACE_Y(play) + 5.0f)) || + if ((sRodCastState != 3) || (this->timerArray[0] == 0) || (sLurePos.y > (WATER_SURFACE_Y(play) + 5.0f)) || (sqrtf(SQ(sLurePos.x) + SQ(sLurePos.z)) > 800.0f)) { - this->unk_17A[0] = 0; - this->unk_158 = this->unk_15A; + this->timerArray[0] = 0; + this->fishState = this->fishStateNext; this->unk_190 = 1.0f; this->unk_194 = 2000.0f; - } else if (sp124 < 10.0f) { - if (func_80B70A2C(this, play, false)) { - func_80B71278(this, 0); + } else if (distToTarget < 10.0f) { + if (Fishing_SplashBySize(this, play, false)) { + Fishing_FishLeapSfx(this, false); } - this->unk_158 = 5; + this->fishState = 5; this->unk_190 = 1.2f; this->unk_194 = 5000.0f; - this->unk_17A[1] = 150; - this->unk_17A[0] = 0; - this->unk_17A[2] = 0; - this->unk_17A[3] = 120; + this->timerArray[1] = 150; + this->timerArray[0] = 0; + this->timerArray[2] = 0; + this->timerArray[3] = 120; - D_80B7A694 = 4; + sRodCastState = 4; sFishingHookedFish = this; sFishMouthOffset.y = 500.0f - Rand_ZeroFloat(400.0f); - if (D_80B7E0B6 == 2) { - if (this->unk_1AC > 70.0f) { - phi_v0 = (s16)Rand_ZeroFloat(20.0f) + 10; - } else if (this->unk_1AC > 60.0f) { - phi_v0 = (s16)Rand_ZeroFloat(30.0f) + 20; - } else if (this->unk_1AC > 50.0f) { - phi_v0 = (s16)Rand_ZeroFloat(30.0f) + 30; + // get rumble time based on size and lure used. + if (sLureEquipped == FS_LURE_SINKING) { + if (this->fishLength > 70.0f) { + timer = (s16)Rand_ZeroFloat(20.0f) + 10; + } else if (this->fishLength > 60.0f) { + timer = (s16)Rand_ZeroFloat(30.0f) + 20; + } else if (this->fishLength > 50.0f) { + timer = (s16)Rand_ZeroFloat(30.0f) + 30; } else { - phi_v0 = (s16)Rand_ZeroFloat(40.0f) + 40; + timer = (s16)Rand_ZeroFloat(40.0f) + 40; } - D_80B7E122 = phi_v0; - D_80B7E0A4 = phi_v0; - Rumble_Override(0.0f, 60, phi_v0 * 3, 10); + sLureBitTimer = timer; + sRumbleDelay = timer; + Rumble_Override(0.0f, 60, timer * 3, 10); } else { - if (this->unk_1AC > 70.0f) { - phi_v0 = (s16)Rand_ZeroFloat(5.0f) + 10; - } else if (this->unk_1AC > 60.0f) { - phi_v0 = (s16)Rand_ZeroFloat(5.0f) + 15; - } else if (this->unk_1AC > 50.0f) { - phi_v0 = (s16)Rand_ZeroFloat(5.0f) + 17; + if (this->fishLength > 70.0f) { + timer = (s16)Rand_ZeroFloat(5.0f) + 10; + } else if (this->fishLength > 60.0f) { + timer = (s16)Rand_ZeroFloat(5.0f) + 15; + } else if (this->fishLength > 50.0f) { + timer = (s16)Rand_ZeroFloat(5.0f) + 17; } else { - phi_v0 = (s16)Rand_ZeroFloat(5.0f) + 25; + timer = (s16)Rand_ZeroFloat(5.0f) + 25; } - D_80B7E122 = phi_v0; - D_80B7E0A4 = phi_v0; - Rumble_Override(0.0f, 180, phi_v0 * 3, 10); + sLureBitTimer = timer; + sRumbleDelay = timer; + Rumble_Override(0.0f, 180, timer * 3, 10); } - D_80B7E124 = 0; - D_80B7E116 = 100; - D_80B7E080 = 0; + sLineHooked = 0; + sRodPullback = 100; + sFishFightTime = 0; } break; case -3: - this->unk_151 = 50; - this->unk_1B4 = sLurePos; + this->lilyTimer = 50; + this->fishTargetPos = sLurePos; Math_ApproachF(&this->actor.speed, 2.0f, 1.0f, 1.0f); - if ((D_80B7A694 != 3) || (this->unk_17A[0] == 0) || (sLurePos.y > (WATER_SURFACE_Y(play) + 5.0f)) || + if ((sRodCastState != 3) || (this->timerArray[0] == 0) || (sLurePos.y > (WATER_SURFACE_Y(play) + 5.0f)) || (sqrtf(SQ(sLurePos.x) + SQ(sLurePos.z)) > 800.0f)) { - this->unk_17A[0] = 0; + this->timerArray[0] = 0; this->unk_190 = 1.0f; - this->unk_158 = this->unk_15A; + this->fishState = this->fishStateNext; this->unk_194 = 2000.0f; - } else if (sp124 < 10.0f) { + } else if (distToTarget < 10.0f) { if (sLurePos.y > (WATER_SURFACE_Y(play) - 10.0f)) { Actor_PlaySfx(&this->actor, NA_SE_EV_JUMP_OUT_WATER); Sfx_PlaySfxCentered(NA_SE_PL_CATCH_BOOMERANG); } - func_80B70A2C(this, play, false); - this->unk_158 = 5; + Fishing_SplashBySize(this, play, false); + this->fishState = 5; this->unk_190 = 1.2f; this->unk_194 = 5000.0f; - this->unk_17A[1] = 150; - this->unk_17A[0] = 0; - this->unk_17A[2] = 0; - this->unk_17A[3] = 120; + this->timerArray[1] = 150; + this->timerArray[0] = 0; + this->timerArray[2] = 0; + this->timerArray[3] = 120; - D_80B7A694 = 4; + sRodCastState = 4; sFishingHookedFish = this; - if (D_80B7E0B6 == 2) { - D_80B7E122 = 30; - D_80B7E0A4 = 100; + if (sLureEquipped == FS_LURE_SINKING) { + sLureBitTimer = 30; + sRumbleDelay = 100; Rumble_Override(0.0f, 60, 90, 10); } else { - D_80B7E122 = 30; - D_80B7E0A4 = 40; + sLureBitTimer = 30; + sRumbleDelay = 40; Rumble_Override(0.0f, 180, 90, 10); } - D_80B7E124 = 0; - D_80B7E116 = 100; - D_80B7E080 = 0; + sLineHooked = false; + sRodPullback = 100; + sFishFightTime = 0; } break; @@ -3560,23 +3576,24 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { this->actor.uncullZoneForward = 1200.0f; this->actor.uncullZoneScale = 200.0f; - D_80B7E080++; - osSyncPrintf("HIT FISH %dcm\n", (u8)this->unk_1AC); + sFishFightTime++; + osSyncPrintf("HIT FISH %dcm\n", (u8)this->fishLength); - Math_ApproachS(&this->unk_170, 0x2AF8, 4, 0xBB8); + Math_ApproachS(&this->fishLimbDRotZDelta, 0x2AF8, 4, 0xBB8); sFishingHookedFish = this; Math_ApproachS(&player->actor.shape.rot.y, this->actor.yawTowardsPlayer + 0x8000, 5, 0x500); - if (D_80B7E124 == 0) { - if ((D_80B7FEA0 < 20) && ((D_80B7E0AE & 3) == 0)) { - D_80B7FEA0++; + if (sLineHooked == 0) { + if ((sSinkingLureSegmentIndex < 20) && ((sLureTimer & 3) == 0)) { + sSinkingLureSegmentIndex++; } } - if ((D_80B7E122 != 0) && (D_80B7E124 == 0)) { - if (((input->rel.stick_y < -50) && (D_80B7A6C8 > -40)) || CHECK_BTN_ALL(input->press.button, BTN_A)) { + if ((sLureBitTimer != 0) && (sLineHooked == 0)) { // pull the line to hook it + if (((input->rel.stick_y < -50) && (sStickAdjYPrev > -40)) || + CHECK_BTN_ALL(input->press.button, BTN_A)) { if (input->rel.stick_y < -50) { - temp_f0 = 40.0f - ((this->unk_1AC - 30.0f) * 1.333333f); + temp_f0 = 40.0f - ((this->fishLength - 30.0f) * 1.333333f); if (temp_f0 > 0.0f) { this->unk_152 = temp_f0; this->unk_154 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; @@ -3584,106 +3601,106 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { } } - this->unk_198 = 1.7f; - this->unk_19C = 7000.0f; - D_80B7E124 = 1; + this->fishLimbRotPhaseStep = 1.7f; + this->fishLimbRotPhaseMag = 7000.0f; + sLineHooked = 1; SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 8, NA_BGM_ENEMY); - D_80B7E0A6 = 0; + sFishingMusicDelay = 0; - if (this->unk_150 == 1) { - spA4 = (this->unk_1AC * 3.0f) + 120.0f; + if (this->isLoach == 1) { + rumbleStrength = (this->fishLength * 3.0f) + 120.0f; } else { - spA4 = (2.0f * this->unk_1AC) + 120.0f; + rumbleStrength = (2.0f * this->fishLength) + 120.0f; } - if (spA4 > 255.0f) { - spA4 = 255.0f; + if (rumbleStrength > 255.0f) { + rumbleStrength = 255.0f; } - Rumble_Override(0.0f, spA4, 120, 5); - D_80B7E0A4 = 40; - D_80B7FDA8 = 10; + Rumble_Override(0.0f, rumbleStrength, 120, 5); + sRumbleDelay = 40; + sRodHitTimer = 10; Sfx_PlaySfxCentered(NA_SE_IT_FISHING_HIT); } } if (this->actor.world.pos.y < WATER_SURFACE_Y(play)) { - if (this->unk_17A[1] > 30) { + if (this->timerArray[1] > 30) { phi_v0_2 = 7; } else { phi_v0_2 = 0xF; } - if (((this->unk_15C & phi_v0_2) == 0) && (Rand_ZeroOne() < 0.75f) && (D_80B7E0A4 == 0)) { - if (this->unk_1AC >= 70.0f) { - spA4 = 255.0f; - } else if (this->unk_1AC >= 60.0f) { - spA4 = 230.0f; - } else if (this->unk_1AC >= 50.0f) { - spA4 = 200.0f; - } else if (this->unk_1AC >= 40.0f) { - spA4 = 170.0f; + if (((this->stateAndTimer & phi_v0_2) == 0) && (Rand_ZeroOne() < 0.75f) && (sRumbleDelay == 0)) { + if (this->fishLength >= 70.0f) { + rumbleStrength = 255.0f; + } else if (this->fishLength >= 60.0f) { + rumbleStrength = 230.0f; + } else if (this->fishLength >= 50.0f) { + rumbleStrength = 200.0f; + } else if (this->fishLength >= 40.0f) { + rumbleStrength = 170.0f; } else { - spA4 = 140.0f; + rumbleStrength = 140.0f; } if (phi_v0_2 == 0xF) { - spA4 *= 3.0f / 4.0f; + rumbleStrength *= 3.0f / 4.0f; } - Rumble_Override(0.0f, spA4, (s16)Rand_ZeroFloat(5.0f) + 10, 5); + Rumble_Override(0.0f, rumbleStrength, (s16)Rand_ZeroFloat(5.0f) + 10, 5); } - if (this->unk_17A[1] > 30) { - if (this->unk_17A[0] == 0) { - sp10C.x = 0.0f; - sp10C.y = 0.0f; - sp10C.z = 200.0f; + if (this->timerArray[1] > 30) { + if (this->timerArray[0] == 0) { + multiVecSrc.x = 0.0f; + multiVecSrc.y = 0.0f; + multiVecSrc.z = 200.0f; - for (spA2 = 0; spA2 < 100; spA2++) { + for (attempts = 0; attempts < 100; attempts++) { Matrix_RotateY(Rand_CenteredFloat(3.0f * M_PI / 4.0f) + BINANG_TO_RAD_ALT(this->actor.yawTowardsPlayer + 0x8000), MTXMODE_NEW); - Matrix_MultVec3f(&sp10C, &sp100); + Matrix_MultVec3f(&multiVecSrc, &targetPosOffset); - this->unk_1B4.x = this->actor.world.pos.x + sp100.x; - this->unk_1B4.z = this->actor.world.pos.z + sp100.z; + this->fishTargetPos.x = this->actor.world.pos.x + targetPosOffset.x; + this->fishTargetPos.z = this->actor.world.pos.z + targetPosOffset.z; - if ((SQ(this->unk_1B4.x) + SQ(this->unk_1B4.z)) < SQ(750.0f)) { + if ((SQ(this->fishTargetPos.x) + SQ(this->fishTargetPos.z)) < SQ(750.0f)) { break; } } - if ((Rand_ZeroOne() < 0.1f) && (this->unk_17A[3] == 0)) { - if (this->unk_1AC >= 60.0f) { - phi_a1 = 255; - } else if (this->unk_1AC >= 50.0f) { - phi_a1 = 200; + if ((Rand_ZeroOne() < 0.1f) && (this->timerArray[3] == 0)) { + if (this->fishLength >= 60.0f) { + rumbleStrength8 = 255; + } else if (this->fishLength >= 50.0f) { + rumbleStrength8 = 200; } else { - phi_a1 = 180; + rumbleStrength8 = 180; } - Rumble_Override(0.0f, phi_a1, 90, 2); - this->unk_17A[0] = 20; - this->unk_17A[1] = 100; - this->unk_17A[2] = 20; - this->unk_17A[3] = 100; - this->unk_1B4.y = 300.0f; - D_80B7E0A4 = 0x28; - D_80B7E116 = (s16)Rand_ZeroFloat(30.0f) + 20; + Rumble_Override(0.0f, rumbleStrength8, 90, 2); + this->timerArray[0] = 20; + this->timerArray[1] = 100; + this->timerArray[2] = 20; + this->timerArray[3] = 100; + this->fishTargetPos.y = 300.0f; + sRumbleDelay = 40; + sRodPullback = (s16)Rand_ZeroFloat(30.0f) + 20; } else { - this->unk_17A[0] = (s16)Rand_ZeroFloat(10.0f) + 3; - this->unk_17A[2] = 0; - this->unk_1B4.y = -70.0f - Rand_ZeroFloat(150.0f); + this->timerArray[0] = (s16)Rand_ZeroFloat(10.0f) + 3; + this->timerArray[2] = 0; + this->fishTargetPos.y = -70.0f - Rand_ZeroFloat(150.0f); } } - if (this->unk_17A[2] != 0) { - D_80B7E11C = 0.0f; + if (this->timerArray[2] != 0) { + sRodReelingSpeed = 0.0f; this->unk_190 = 1.6f; this->unk_194 = 6000.0f; Math_ApproachF(&this->actor.speed, 7.5f, 1.0f, 1.0f); - Math_ApproachS(&this->unk_170, 0x4E20, 2, 0xFA0); + Math_ApproachS(&this->fishLimbDRotZDelta, 20000, 2, 4000); } else { - if ((D_80B7E124 == 0) && (D_80B7E0B6 == 2)) { + if ((sLineHooked == 0) && (sLureEquipped == FS_LURE_SINKING)) { this->unk_190 = 1.0f; this->unk_194 = 2000.0f; Math_ApproachF(&this->actor.speed, 3.0f, 1.0f, 0.2f); @@ -3693,15 +3710,15 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { Math_ApproachF(&this->actor.speed, 5.0f, 1.0f, 0.5f); } - if (this->unk_150 == 0) { - D_80B7E11C = 1.0f - (this->unk_1AC * 0.00899f); + if (this->isLoach == 0) { + sRodReelingSpeed = 1.0f - (this->fishLength * 0.00899f); } else { - D_80B7E11C = 1.0f - (this->unk_1AC * 0.00899f * 1.4f); + sRodReelingSpeed = 1.0f - (this->fishLength * 0.00899f * 1.4f); } } } else { - if (((this->unk_17A[1] & 0xF) == 0) && CHECK_BTN_ALL(input->cur.button, BTN_A) && - (!(this->unk_1AC >= 60.0f) || (D_80B7E080 >= 2000))) { + if (((this->timerArray[1] & 0xF) == 0) && CHECK_BTN_ALL(input->cur.button, BTN_A) && + (!(this->fishLength >= 60.0f) || (sFishFightTime >= 2000))) { this->unk_152 = (s16)Rand_ZeroFloat(30.0f) + 15; this->unk_154 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; } @@ -3709,57 +3726,57 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { this->unk_190 = 1.0f; this->unk_194 = 4500.0f; - if (this->unk_150 == 0) { - D_80B7E11C = 1.3f - (this->unk_1AC * 0.00899f); + if (this->isLoach == 0) { + sRodReelingSpeed = 1.3f - (this->fishLength * 0.00899f); } else { - D_80B7E11C = 1.3f - (this->unk_1AC * 0.00899f * 1.4f); + sRodReelingSpeed = 1.3f - (this->fishLength * 0.00899f * 1.4f); } Math_ApproachF(&this->actor.speed, 2.0f, 1.0f, 0.5f); - if (this->unk_17A[1] == 0) { + if (this->timerArray[1] == 0) { this->unk_152 = 0; - if (D_80B7E080 < 2000) { - this->unk_17A[1] = (s16)Rand_ZeroFloat(50.0f) + 50; - } else if (D_80B7E080 < 3000) { - this->unk_17A[1] = (s16)Rand_ZeroFloat(20.0f) + 30; + if (sFishFightTime < 2000) { + this->timerArray[1] = (s16)Rand_ZeroFloat(50.0f) + 50; + } else if (sFishFightTime < 3000) { + this->timerArray[1] = (s16)Rand_ZeroFloat(20.0f) + 30; } else { - this->unk_17A[1] = (s16)Rand_ZeroFloat(10.0f) + 25; + this->timerArray[1] = (s16)Rand_ZeroFloat(10.0f) + 25; } } } } - if (D_80B7E074 != 0) { - D_80B7E11C = 0.0f; + if (sReelLock != 0) { + sRodReelingSpeed = 0.0f; } - if (D_80B7E124 || (D_80B7E0B6 != 2)) { + if (sLineHooked || (sLureEquipped != FS_LURE_SINKING)) { if (this->actor.speed < 3.0f) { - if ((D_80B7E0AE & 8) != 0) { - sp100.x = -0.8f; + if ((sLureTimer & 8) != 0) { + targetPosOffset.x = -0.8f; } else { - sp100.x = -0.75f; + targetPosOffset.x = -0.75f; } } else { - if ((D_80B7E0AE & 4) != 0) { - sp100.x = -0.9f; + if ((sLureTimer & 4) != 0) { + targetPosOffset.x = -0.9f; } else { - sp100.x = -0.85f; + targetPosOffset.x = -0.85f; } } Math_ApproachF(&D_80B7A6C0, 35.0f, 0.1f, 3.5f); - Math_ApproachF(&D_80B7A6BC, sp100.x, 0.3f, 0.1f); + Math_ApproachF(&D_80B7A6BC, targetPosOffset.x, 0.3f, 0.1f); } sReelLinePos[LINE_SEG_COUNT - 1] = this->fishMouthPos; - sp10C.x = sReelLinePos[LINE_SEG_COUNT - 1].x - sReelLinePos[LINE_SEG_COUNT - 2].x; - sp10C.y = sReelLinePos[LINE_SEG_COUNT - 1].y - sReelLinePos[LINE_SEG_COUNT - 2].y; - sp10C.z = sReelLinePos[LINE_SEG_COUNT - 1].z - sReelLinePos[LINE_SEG_COUNT - 2].z; + multiVecSrc.x = sReelLinePos[LINE_SEG_COUNT - 1].x - sReelLinePos[LINE_SEG_COUNT - 2].x; + multiVecSrc.y = sReelLinePos[LINE_SEG_COUNT - 1].y - sReelLinePos[LINE_SEG_COUNT - 2].y; + multiVecSrc.z = sReelLinePos[LINE_SEG_COUNT - 1].z - sReelLinePos[LINE_SEG_COUNT - 2].z; - if ((SQ(sp10C.x) + SQ(sp10C.y) + SQ(sp10C.z)) > SQ(20.0f)) { + if ((SQ(multiVecSrc.x) + SQ(multiVecSrc.y) + SQ(multiVecSrc.z)) > SQ(20.0f)) { Math_ApproachF(&this->actor.world.pos.x, sReelLinePos[LINE_SEG_COUNT - 2].x, 0.2f, 2.0f * (this->actor.speed * 1.5f)); Math_ApproachF(&this->actor.world.pos.y, sReelLinePos[LINE_SEG_COUNT - 2].y, 0.2f, @@ -3769,84 +3786,85 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { } if (CHECK_BTN_ALL(input->cur.button, BTN_A) || (input->rel.stick_y < -30)) { - if (D_80B7E116 < 100) { - D_80B7E116++; + if (sRodPullback < 100) { + sRodPullback++; } } else { - if (D_80B7E116 != 0) { - D_80B7E116--; + if (sRodPullback != 0) { + sRodPullback--; } } - if ((D_80B7A694 < 3) || ((D_80B7E074 != 0) && (D_80B7E080 > 50)) || (D_80B7E080 >= 6000) || - ((D_80B7E122 == 0) && (D_80B7E124 == 0)) || (D_80B7E116 == 0) || - (((D_80B7E0AE & 0x7F) == 0) && (Rand_ZeroOne() < 0.05f) && (D_80B7E0B6 != 2) && (KREG(69) == 0))) { - D_80B7A67C = 20; + if ((sRodCastState < 3) || ((sReelLock != 0) && (sFishFightTime > 50)) || (sFishFightTime >= 6000) || + ((sLureBitTimer == 0) && (sLineHooked == 0)) || (sRodPullback == 0) || + (((sLureTimer & 0x7F) == 0) && (Rand_ZeroOne() < 0.05f) && (sLureEquipped != FS_LURE_SINKING) && + (KREG(69) == 0))) { + sFishingCaughtTextDelay = 20; - if ((D_80B7E122 == 0) && (D_80B7E124 == 0)) { - D_80B7E086 = 0x4081; - if (((sLinkAge == LINK_AGE_CHILD) && (HIGH_SCORE(HS_FISHING) & 0x400)) || - ((sLinkAge != LINK_AGE_CHILD) && (HIGH_SCORE(HS_FISHING) & 0x800))) { - D_80B7A67C = 0; + if ((sLureBitTimer == 0) && (sLineHooked == 0)) { + sFishingCaughtTextId = 0x4081; + if (((sLinkAge == LINK_AGE_CHILD) && (HIGH_SCORE(HS_FISHING) & HS_FISH_PRIZE_CHILD)) || + ((sLinkAge != LINK_AGE_CHILD) && (HIGH_SCORE(HS_FISHING) & HS_FISH_PRIZE_ADULT))) { + sFishingCaughtTextDelay = 0; } } else { - D_80B7E086 = 0x4082; + sFishingCaughtTextId = 0x4082; Rumble_Override(0.0f, 1, 3, 1); SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 10); } - this->unk_158 = this->unk_15A = 0; + this->fishState = this->fishStateNext = 0; this->unk_1A4 = 10000; this->unk_1A2 = 500; - this->unk_17A[1] = 50; - this->unk_17A[0] = 0; + this->timerArray[1] = 50; + this->timerArray[0] = 0; this->unk_190 = 1.0f; this->unk_194 = 3000.0f; - if (D_80B7A694 == 4) { - D_80B7A694 = 3; + if (sRodCastState == 4) { + sRodCastState = 3; } - D_80B7E0A6 = 50; - D_80B7E11C = 0.5f; + sFishingMusicDelay = 50; + sRodReelingSpeed = 0.5f; this->unk_152 = 0; } else if (this->actor.xzDistToPlayer < (KREG(59) + 50.0f)) { - this->unk_158 = 6; - this->unk_17A[0] = 100; + this->fishState = 6; + this->timerArray[0] = 100; player->unk_860 = 3; Rumble_Override(0.0f, 1, 3, 1); - D_80B7E084++; + sFishesCaught++; Cutscene_StartManual(play, &play->csCtx); - D_80B7A6CC = 100; - D_80B7FEC8 = 45.0f; - D_80B7A694 = 5; + sFishingPlayerCinematicState = 100; + sCatchCamX = 45.0f; + sRodCastState = 5; this->unk_190 = 1.0f; this->unk_194 = 500.0f; - this->unk_19C = 5000.0f; + this->fishLimbRotPhaseMag = 5000.0f; if (this->actor.world.pos.y <= WATER_SURFACE_Y(play)) { - func_80B71278(this, 1); - func_80B70A2C(this, play, true); + Fishing_FishLeapSfx(this, true); + Fishing_SplashBySize(this, play, true); } - goto case_6; + goto hoistCatch; } break; - case_6: + hoistCatch: case 6: - Math_ApproachS(&this->unk_170, 0x2AF8, 2, 0xFA0); - Math_ApproachF(&D_80B7FEC8, 15.0f, 0.05f, 0.75f); + Math_ApproachS(&this->fishLimbDRotZDelta, 11000, 2, 4000); + Math_ApproachF(&sCatchCamX, 15.0f, 0.05f, 0.75f); - sp10C.x = D_80B7FEC8; + multiVecSrc.x = sCatchCamX; if (sLinkAge != LINK_AGE_CHILD) { - sp10C.y = 30.0f; - sp10C.z = 55.0f; + multiVecSrc.y = 30.0f; + multiVecSrc.z = 55.0f; } else { - sp10C.y = 10.0f; - sp10C.z = 50.0f; + multiVecSrc.y = 10.0f; + multiVecSrc.z = 50.0f; } Matrix_RotateY(BINANG_TO_RAD_ALT(player->actor.shape.rot.y), MTXMODE_NEW); - Matrix_MultVec3f(&sp10C, &sSubCamEye); + Matrix_MultVec3f(&multiVecSrc, &sSubCamEye); sSubCamEye.x += player->actor.world.pos.x; sSubCamEye.y += player->actor.world.pos.y; @@ -3859,75 +3877,76 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { sSubCamAt.y += 25.0f; } - if (this->unk_17A[0] == 90) { + if (this->timerArray[0] == 90) { SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 9, NA_BGM_HEART_GET); - D_80B7A67C = 40; + sFishingCaughtTextDelay = 40; - if (this->unk_150 == 0) { - D_80B7A678 = this->unk_1AC; + if (this->isLoach == 0) { + sFishLengthToWeigh = this->fishLength; - if (D_80B7A678 >= 75) { - D_80B7E086 = 0x409F; - } else if (D_80B7A678 >= 50) { - D_80B7E086 = 0x4091; + if (sFishLengthToWeigh >= 75) { + sFishingCaughtTextId = 0x409F; + } else if (sFishLengthToWeigh >= 50) { + sFishingCaughtTextId = 0x4091; } else { - D_80B7E086 = 0x4083; + sFishingCaughtTextId = 0x4083; } } else { - D_80B7A678 = 2.0f * this->unk_1AC; - D_80B7E086 = 0x4099; + sFishLengthToWeigh = 2.0f * this->fishLength; + sFishingCaughtTextId = 0x4099; } - this->unk_1D5 = 0; + this->keepState = 0; } this->unk_160 = -0x4000; this->actor.shape.rot.y = player->actor.shape.rot.y + 0x5000; this->actor.shape.rot.x = this->actor.shape.rot.z = this->unk_162 = this->unk_164 = this->unk_16E = 0; - sp10C.x = 4.0f; - sp10C.y = -10.0f; - sp10C.z = 5.0f; - Matrix_MultVec3f(&sp10C, &sp100); - Math_ApproachF(&this->actor.world.pos.x, player->bodyPartsPos[PLAYER_BODYPART_R_HAND].x + sp100.x, 1.0f, + multiVecSrc.x = 4.0f; + multiVecSrc.y = -10.0f; + multiVecSrc.z = 5.0f; + Matrix_MultVec3f(&multiVecSrc, &targetPosOffset); + Math_ApproachF(&this->actor.world.pos.x, player->bodyPartsPos[PLAYER_BODYPART_R_HAND].x + targetPosOffset.x, 1.0f, 6.0f); - Math_ApproachF(&this->actor.world.pos.y, player->bodyPartsPos[PLAYER_BODYPART_R_HAND].y + sp100.y, 1.0f, + Math_ApproachF(&this->actor.world.pos.y, player->bodyPartsPos[PLAYER_BODYPART_R_HAND].y + targetPosOffset.y, 1.0f, 6.0f); - Math_ApproachF(&this->actor.world.pos.z, player->bodyPartsPos[PLAYER_BODYPART_R_HAND].z + sp100.z, 1.0f, + Math_ApproachF(&this->actor.world.pos.z, player->bodyPartsPos[PLAYER_BODYPART_R_HAND].z + targetPosOffset.z, 1.0f, 6.0f); - D_80B7E144 = 188.0f; + sRodLineSpooled = 188.0f; - if (this->unk_17A[0] <= 50) { - switch (this->unk_1D5) { + if (this->timerArray[0] <= 50) { + switch (this->keepState) { case 0: if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) || (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE)) { if (Message_ShouldAdvance(play)) { Message_CloseTextbox(play); if (play->msgCtx.choiceIndex == 0) { - if (D_80B7A670 == 0.0f) { - D_80B7A670 = this->unk_1AC; - D_80B7E07C = this->unk_150; - D_80B7E07E = D_80B7E0B6; + if (sFishOnHandLength == 0.0f) { + sFishOnHandLength = this->fishLength; + sFishOnHandIsLoach = this->isLoach; + sLureCaughtWith = sLureEquipped; Actor_Kill(&this->actor); - } else if ((this->unk_150 == 0) && (D_80B7E07C == 0) && - ((s16)this->unk_1AC < (s16)D_80B7A670)) { - this->unk_1D5 = 1; - this->unk_17A[0] = 0x3C; + } else if ((this->isLoach == 0) && (sFishOnHandIsLoach == 0) && + ((s16)this->fishLength < (s16)sFishOnHandLength)) { + this->keepState = 1; + this->timerArray[0] = 0x3C; + Message_StartTextbox(play, 0x4098, NULL); } else { - f32 temp1 = D_80B7A670; - s16 temp2 = D_80B7E07C; - D_80B7A670 = this->unk_1AC; - D_80B7E07C = this->unk_150; - D_80B7E07E = D_80B7E0B6; - this->unk_1AC = temp1; - this->unk_150 = temp2; + f32 lengthTemp = sFishOnHandLength; + s16 loachTemp = sFishOnHandIsLoach; + sFishOnHandLength = this->fishLength; + sFishOnHandIsLoach = this->isLoach; + sLureCaughtWith = sLureEquipped; + this->fishLength = lengthTemp; + this->isLoach = loachTemp; } } - if (this->unk_1D5 == 0) { - D_80B7A694 = 0; + if (this->keepState == 0) { + sRodCastState = 0; } } } @@ -3938,32 +3957,32 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { if (Message_ShouldAdvance(play)) { Message_CloseTextbox(play); if (play->msgCtx.choiceIndex != 0) { - f32 temp1 = D_80B7A670; - s16 temp2 = D_80B7E07C; - D_80B7A670 = this->unk_1AC; - D_80B7E07E = D_80B7E0B6; - this->unk_1AC = temp1; - this->unk_150 = temp2; + f32 temp1 = sFishOnHandLength; + s16 temp2 = sFishOnHandIsLoach; + sFishOnHandLength = this->fishLength; + sLureCaughtWith = sLureEquipped; + this->fishLength = temp1; + this->isLoach = temp2; } - D_80B7A694 = 0; + sRodCastState = 0; } } break; } } - if (D_80B7A694 == 0) { + if (sRodCastState == 0) { if (this->actor.update != NULL) { - this->unk_158 = this->unk_15A = 0; + this->fishState = this->fishStateNext = 0; this->unk_1A4 = 10000; this->unk_1A2 = 500; - this->unk_17A[1] = 50; - this->unk_17A[0] = 0; + this->timerArray[1] = 50; + this->timerArray[0] = 0; this->unk_190 = 1.0f; this->unk_194 = 2000.0f; SkelAnime_Free(&this->skelAnime, play); - if (this->unk_150 == 0) { + if (this->isLoach == 0) { SkelAnime_InitFlex(play, &this->skelAnime, &gFishingFishSkel, &gFishingFishAnim, NULL, NULL, 0); Animation_MorphToLoop(&this->skelAnime, &gFishingFishAnim, 0.0f); } else { @@ -3974,92 +3993,93 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { } D_80B7E148 = 520.0f; - D_80B7E144 = 195.0f; + sRodLineSpooled = 195.0f; SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 10); - D_80B7E0A6 = 20; - D_80B7A6CC = 3; + sFishingMusicDelay = 20; + sFishingPlayerCinematicState = 3; } break; case 7: - this->unk_151 = 50; - sp134 = 5; - this->unk_1B0 = 12288.0f; + this->lilyTimer = 50; + rotXYScale = 5; + this->rotationStep = 12288.0f; - if (this->actor.params < 104) { - this->unk_1B4 = sGroupFishes[this->actor.params - 100].pos; - D_80B7A898 = 1; - } else if (this->actor.params < 108) { - this->unk_1B4 = sGroupFishes[this->actor.params - 100 + 16].pos; - D_80B7A898 = 2; + if (this->actor.params < (EN_FISH_PARAM + 4)) { + this->fishTargetPos = sGroupFishes[this->actor.params - EN_FISH_PARAM].pos; + sFishGroupVar = 1; + } else if (this->actor.params < (EN_FISH_PARAM + 8)) { + this->fishTargetPos = sGroupFishes[this->actor.params - EN_FISH_PARAM + 16].pos; + sFishGroupVar = 2; } else { - this->unk_1B4 = sGroupFishes[this->actor.params - 100 + 32].pos; - D_80B7A898 = 3; + this->fishTargetPos = sGroupFishes[this->actor.params - EN_FISH_PARAM + 32].pos; + sFishGroupVar = 3; } Math_ApproachF(&this->actor.speed, 5.0f, 1.0f, 1.0f); - if (sp124 < 20.0f) { - Math_ApproachS(&this->unk_170, 0x4E20, 2, 0xFA0); + if (distToTarget < 20.0f) { + Math_ApproachS(&this->fishLimbDRotZDelta, 20000, 2, 4000); - if ((this->unk_17A[2] == 0) && func_80B70A2C(this, play, false)) { - func_80B71278(this, Rand_ZeroFloat(1.99f)); - this->unk_17A[2] = (s16)Rand_ZeroFloat(20.0f) + 20; + if ((this->timerArray[2] == 0) && Fishing_SplashBySize(this, play, false)) { + Fishing_FishLeapSfx(this, Rand_ZeroFloat(1.99f)); + this->timerArray[2] = (s16)Rand_ZeroFloat(20.0f) + 20; } } - if (this->unk_17A[3] == 0) { - this->unk_158 = 10; - this->unk_15A = 10; + if (this->timerArray[3] == 0) { + this->fishState = 10; + this->fishStateNext = 10; } else { func_80B70ED4(this, input); - if (this->actor.xzDistToPlayer < (100.0f * sp118)) { - this->unk_15A = this->unk_158 = 0; + if (this->actor.xzDistToPlayer < (100.0f * playerSpeedMod)) { + this->fishStateNext = this->fishState = 0; this->unk_1A4 = 500; this->unk_1A2 = 200; - this->unk_17A[1] = 50; + this->timerArray[1] = 50; } } break; } - Math_ApproachS(&this->unk_172, (Math_SinS(this->unk_15C * 0x1000) * 5000.0f) + 5000.0f, 2, 0x7D0); + Math_ApproachS(&this->fishLimbEFRotYDelta, (Math_SinS(this->stateAndTimer * 0x1000) * 5000.0f) + 5000.0f, 2, 0x7D0); - if (this->unk_158 != 6) { + if (this->fishState != 6) { if (this->actor.world.pos.y > WATER_SURFACE_Y(play)) { this->unk_190 = 1.5f; this->unk_194 = 5000.0f; Math_ApproachS(&this->unk_16E, 0, 5, 0x7D0); - spF4 = spF0 = spFA = 3; - spF2 = spEE = 0x2000; + rotXScale = rotYScale = rotZScale = 3; + rotXStep = rotYStep = 0x2000; - this->unk_17A[2] = 0; + this->timerArray[2] = 0; this->unk_184 -= 1.0f; } else { Math_ApproachZeroF(&this->unk_184, 1.0f, 2.0f); - if ((this->unk_158 != -1) && (this->unk_158 != -2) && (this->unk_158 != -25)) { - this->unk_166 = 0; + // check for Loach states + if ((this->fishState != -1) && (this->fishState != -2) && (this->fishState != -25)) { + this->rotationTarget.x = 0; } - this->unk_168 = this->unk_16A = 0; - spF4 = spF0 = spFA = 4; - spF2 = spEE = 0x2000; + this->rotationTarget.y = this->rotationTarget.z = 0; + rotXScale = rotYScale = rotZScale = 4; + rotXStep = rotYStep = 0x2000; - spF6 = Fishing_SmoothStepToS(&this->actor.world.rot.y, spFC, sp134, this->unk_1B0) * 3.0f; - Math_ApproachS(&this->actor.world.rot.x, spFE, sp134, this->unk_1B0 * 0.5f); + spF6 = Fishing_SmoothStepToS(&this->actor.world.rot.y, rotYtarget, rotXYScale, this->rotationStep) * 3.0f; + Math_ApproachS(&this->actor.world.rot.x, rotXTarget, rotXYScale, this->rotationStep * 0.5f); - if (spF6 > 0x1F40) { - spF6 = 0x1F40; - } else if (spF6 < -0x1F40) { - spF6 = -0x1F40; + if (spF6 > 8000) { + spF6 = 8000; + } else if (spF6 < -8000) { + spF6 = -8000; } if (this->actor.speed >= 3.2f) { - Math_ApproachS(&this->unk_16E, spF6, 2, 0x4E20); + Math_ApproachS(&this->unk_16E, spF6, 2, 20000); } else { - Math_ApproachS(&this->unk_16E, spF6, 3, 0xBB8); + Math_ApproachS(&this->unk_16E, spF6, 3, 3000); } Actor_UpdateVelocityXYZ(&this->actor); @@ -4070,25 +4090,25 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { this->actor.world.pos.y += (this->unk_184 * 1.5f); if (this->unk_152 != 0) { - this->unk_168 = this->unk_154; + this->rotationTarget.y = this->unk_154; this->unk_152--; if (this->unk_156 != 0) { - spF0 = 5; - spEE = 0x4000; + rotYScale = 5; + rotYStep = 0x4000; } else { - spF0 = 10; - spEE = 0x800; + rotYScale = 10; + rotYStep = 0x800; } - this->unk_166 = -0x500 - this->actor.shape.rot.x; - spF4 = 5; - spF2 = 0x4000; + this->rotationTarget.x = -0x500 - this->actor.shape.rot.x; + rotXScale = 5; + rotXStep = 0x4000; } else { this->unk_156 = 0; } - Math_ApproachS(&this->unk_160, this->unk_166, spF4, spF2); - Math_ApproachS(&this->unk_162, this->unk_168, spF0, spEE); - Math_ApproachS(&this->unk_164, this->unk_16A, spFA, 0x2000); + Math_ApproachS(&this->unk_160, this->rotationTarget.x, rotXScale, rotXStep); + Math_ApproachS(&this->unk_162, this->rotationTarget.y, rotYScale, rotYStep); + Math_ApproachS(&this->unk_164, this->rotationTarget.z, rotZScale, 0x2000); if (this->actor.speed <= 0.5f) { Math_ApproachS(&this->actor.shape.rot.x, 0, 10, this->unk_178); @@ -4100,37 +4120,37 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { this->actor.shape.rot.y = this->actor.world.rot.y; - if ((this->unk_158 != -1) && (this->unk_158 != -2) && (this->unk_158 != -25)) { + if ((this->fishState != -1) && (this->fishState != -2) && (this->fishState != -25)) { if ((this->actor.world.pos.y > WATER_SURFACE_Y(play)) && (this->actor.prevPos.y <= WATER_SURFACE_Y(play))) { - func_80B70A2C(this, play, true); - func_80B71278(this, 1); + Fishing_SplashBySize(this, play, true); + Fishing_FishLeapSfx(this, true); this->unk_184 = this->actor.velocity.y; this->actor.velocity.y = 0.0f; - this->unk_16A = Rand_CenteredFloat(32768.0f); + this->rotationTarget.z = Rand_CenteredFloat(32768.0f); } else if ((this->actor.world.pos.y < WATER_SURFACE_Y(play)) && (this->actor.prevPos.y >= WATER_SURFACE_Y(play))) { if (this->unk_184 < -5.0f) { this->unk_184 = -5.0f; } this->actor.world.rot.x = -0xFA0; - func_80B70A2C(this, play, true); - this->unk_1D2 = 20; - func_80B71278(this, 0); + Fishing_SplashBySize(this, play, true); + this->bubbleTime = 20; + Fishing_FishLeapSfx(this, 0); } } if ((this->actor.world.pos.y < WATER_SURFACE_Y(play)) && - (this->actor.world.pos.y > (WATER_SURFACE_Y(play) - 10.0f)) && ((this->unk_15C & 1) == 0) && + (this->actor.world.pos.y > (WATER_SURFACE_Y(play) - 10.0f)) && ((this->stateAndTimer & 1) == 0) && (this->actor.speed > 0.0f)) { Vec3f pos = this->actor.world.pos; pos.y = WATER_SURFACE_Y(play); Fishing_SpawnRipple(&this->actor.projectedPos, play->specialEffects, &pos, 80.0f, 500.0f, 150, 90); } - if ((this->actor.speed > 0.0f) || (this->unk_158 == 5)) { + if ((this->actor.speed > 0.0f) || (this->fishState == 5)) { f32 velocityY = this->actor.velocity.y; - spD8 = this->unk_1AC * 0.1f; + spD8 = this->fishLength * 0.1f; this->actor.world.pos.y -= spD8; this->actor.prevPos.y -= spD8; @@ -4143,7 +4163,7 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { this->actor.velocity.y = velocityY; if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { - this->unk_1A0 = 20; + this->bumpTimer = 20; } if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { @@ -4153,47 +4173,48 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { this->actor.velocity.z = this->actor.world.pos.z * -0.003f; Actor_PlaySfx(&this->actor, NA_SE_EV_FISH_LEAP); - func_80B70CF0(this, play); + Fishing_SplashBySize2(this, play); + if (Rand_ZeroOne() < 0.5f) { - this->unk_16A = 0x4000; + this->rotationTarget.z = 0x4000; } else { - this->unk_16A = -0x4000; + this->rotationTarget.z = -0x4000; } if (Rand_ZeroOne() < 0.5f) { - this->unk_166 = 0; + this->rotationTarget.x = 0; } else { - this->unk_166 = (s16)Rand_CenteredFloat(32.0f) + 0x8000; + this->rotationTarget.x = (s16)Rand_CenteredFloat(32.0f) + 0x8000; } - this->unk_168 = (s16)Rand_CenteredFloat(16384.0f); + this->rotationTarget.y = (s16)Rand_CenteredFloat(16384.0f); this->unk_190 = 1.0f; this->unk_194 = 5000.0f; - this->unk_19C = 5000.0f; + this->fishLimbRotPhaseMag = 5000.0f; } else { this->unk_184 = 0.0f; - if ((this->unk_158 == 5) && ((this->unk_15C & 1) == 0)) { + if ((this->fishState == 5) && ((this->stateAndTimer & 1) == 0)) { Vec3f pos; pos.x = Rand_CenteredFloat(10.0f) + this->actor.world.pos.x; pos.z = Rand_CenteredFloat(10.0f) + this->actor.world.pos.z; pos.y = this->actor.floorHeight + 5.0f; Fishing_SpawnWaterDust(&this->actor.projectedPos, play->specialEffects, &pos, - (this->unk_1AC * 0.005f) + 0.15f); + (this->fishLength * 0.005f) + 0.15f); } } } } } - if (this->unk_1D2 != 0) { + if (this->bubbleTime != 0) { s16 i; Vec3f pos; - f32 range = (this->unk_1AC * 0.075f) + 10.0f; + f32 range = (this->fishLength * 0.075f) + 10.0f; - this->unk_1D2--; + this->bubbleTime--; for (i = 0; i < 2; i++) { pos.x = Rand_CenteredFloat(range) + this->actor.world.pos.x; @@ -4209,19 +4230,19 @@ s32 Fishing_FishOverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Ve Fishing* this = (Fishing*)thisx; if (limbIndex == 0xD) { - rot->z -= this->unk_170 - 11000; + rot->z -= this->fishLimbDRotZDelta - 11000; } else if ((limbIndex == 2) || (limbIndex == 3)) { - rot->y += this->unk_16C; + rot->y += this->fishLimb23RotYDelta; } else if (limbIndex == 4) { - rot->y += this->unk_176; + rot->y += this->fishLimb4RotYDelta; } else if (limbIndex == 0xE) { - rot->y -= this->unk_172; + rot->y -= this->fishLimbEFRotYDelta; } else if (limbIndex == 0xF) { - rot->y += this->unk_172; + rot->y += this->fishLimbEFRotYDelta; } else if (limbIndex == 8) { - rot->y += this->unk_174; + rot->y += this->fishLimb89RotYDelta; } else if (limbIndex == 9) { - rot->y -= this->unk_174; + rot->y -= this->fishLimb89RotYDelta; } return 0; @@ -4239,11 +4260,11 @@ s32 Fishing_LoachOverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, V Fishing* this = (Fishing*)thisx; if (limbIndex == 3) { - rot->y += this->unk_1CC[0]; + rot->y += this->loachRotYDelta[0]; } else if (limbIndex == 4) { - rot->y += this->unk_1CC[1]; + rot->y += this->loachRotYDelta[1]; } else if (limbIndex == 5) { - rot->y += this->unk_1CC[2]; + rot->y += this->loachRotYDelta[2]; } return 0; @@ -4269,15 +4290,15 @@ void Fishing_DrawFish(Actor* thisx, PlayState* play) { Matrix_RotateZ(BINANG_TO_RAD_ALT(this->unk_164 + this->actor.shape.rot.z), MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - if (this->unk_150 == 0) { - Matrix_RotateY(BINANG_TO_RAD(this->unk_16C) - (M_PI / 2), MTXMODE_APPLY); - Matrix_Translate(0.0f, 0.0f, this->unk_16C * 10.0f * 0.01f, MTXMODE_APPLY); + if (this->isLoach == 0) { + Matrix_RotateY(BINANG_TO_RAD(this->fishLimb23RotYDelta) - (M_PI / 2), MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, this->fishLimb23RotYDelta * 10.0f * 0.01f, MTXMODE_APPLY); SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, Fishing_FishOverrideLimbDraw, Fishing_FishPostLimbDraw, this); } else { Matrix_Translate(0.0f, 0.0f, 3000.0f, MTXMODE_APPLY); - Matrix_RotateY(BINANG_TO_RAD(this->unk_16C), MTXMODE_APPLY); + Matrix_RotateY(BINANG_TO_RAD(this->fishLimb23RotYDelta), MTXMODE_APPLY); Matrix_Translate(0.0f, 0.0f, -3000.0f, MTXMODE_APPLY); Matrix_RotateY(-(M_PI / 2), MTXMODE_APPLY); @@ -4342,7 +4363,7 @@ void Fishing_UpdatePondProps(PlayState* play) { actor = play->actorCtx.actorLists[ACTORCAT_NPC].head; while (actor != NULL) { - if (!((actor->id == ACTOR_FISHING) && (actor->params >= 100))) { + if (!((actor->id == ACTOR_FISHING) && (actor->params >= EN_FISH_PARAM))) { actor = actor->next; } else { Fishing_HandleReedContact(prop, &actor->world.pos); @@ -4356,10 +4377,10 @@ void Fishing_UpdatePondProps(PlayState* play) { actor = play->actorCtx.actorLists[ACTORCAT_NPC].head; while (actor != NULL) { - if (!((actor->id == ACTOR_FISHING) && (actor->params >= 100))) { + if (!((actor->id == ACTOR_FISHING) && (actor->params >= EN_FISH_PARAM))) { actor = actor->next; } else { - Fishing_HandleLilyPadContact(prop, &actor->world.pos, ((Fishing*)actor)->unk_151); + Fishing_HandleLilyPadContact(prop, &actor->world.pos, ((Fishing*)actor)->lilyTimer); actor = actor->next; } } @@ -4510,7 +4531,7 @@ void Fishing_UpdateGroupFishes(PlayState* play) { f32 temp1; f32 temp2; - if ((D_80B7E114 != 0) || (D_80B7A694 == 4)) { + if ((D_80B7E114 != 0) || (sRodCastState == 4)) { refPos = &sLurePos; } else { refPos = &player->actor.world.pos; @@ -4526,7 +4547,7 @@ void Fishing_UpdateGroupFishes(PlayState* play) { if ((SQ(temp1) + SQ(temp2)) < SQ(50.0f)) { sFishGroupAngle1 += 0.3f; groupContactFlags |= 1; - } else if (D_80B7A898 != 0.0f) { + } else if (sFishGroupVar != 0.0f) { sFishGroupAngle1 += 0.05f; basePos[0].y = WATER_SURFACE_Y(play) - 5.0f; } else { @@ -4543,7 +4564,7 @@ void Fishing_UpdateGroupFishes(PlayState* play) { if ((SQ(temp1) + SQ(temp2)) < SQ(50.0f)) { sFishGroupAngle2 -= 0.3f; groupContactFlags |= 2; - } else if (D_80B7A898 != 0.0f) { + } else if (sFishGroupVar != 0.0f) { sFishGroupAngle2 -= 0.05f; basePos[1].y = WATER_SURFACE_Y(play) - 5.0f; } else { @@ -4560,7 +4581,7 @@ void Fishing_UpdateGroupFishes(PlayState* play) { if ((SQ(temp1) + SQ(temp2)) < SQ(50.0f)) { sFishGroupAngle3 -= 0.3f; groupContactFlags |= 4; - } else if (D_80B7A898 != 0.0f) { + } else if (sFishGroupVar != 0.0f) { sFishGroupAngle3 -= 0.05f; basePos[2].y = WATER_SURFACE_Y(play) - 5.0f; } else { @@ -4596,22 +4617,22 @@ void Fishing_UpdateGroupFishes(PlayState* play) { groupFlag = 4; } - dx = fish->unk_10.x - fish->pos.x; - dy = fish->unk_10.y - fish->pos.y; - dz = fish->unk_10.z - fish->pos.z; + dx = fish->homePos.x - fish->pos.x; + dy = fish->homePos.y - fish->pos.y; + dz = fish->homePos.z - fish->pos.z; spD4 = Math_Atan2S(dz, dx); dist = sqrtf(SQ(dx) + SQ(dz)); spD6 = Math_Atan2S(dist, dy); if ((dist < 10.0f) || (((fish->timer % 32) == 0) && (Rand_ZeroOne() > 0.5f))) { - fish->unk_10.y = basePos[groupIndex].y + Rand_CenteredFloat(10.0f); + fish->homePos.y = basePos[groupIndex].y + Rand_CenteredFloat(10.0f); - if (D_80B7A898 != 0.0f) { - fish->unk_10.x = basePos[groupIndex].x + Rand_CenteredFloat(200.0f); - fish->unk_10.z = basePos[groupIndex].z + Rand_CenteredFloat(200.0f); + if (sFishGroupVar != 0.0f) { + fish->homePos.x = basePos[groupIndex].x + Rand_CenteredFloat(200.0f); + fish->homePos.z = basePos[groupIndex].z + Rand_CenteredFloat(200.0f); } else { - fish->unk_10.x = basePos[groupIndex].x + Rand_CenteredFloat(100.0f); - fish->unk_10.z = basePos[groupIndex].z + Rand_CenteredFloat(100.0f); + fish->homePos.x = basePos[groupIndex].x + Rand_CenteredFloat(100.0f); + fish->homePos.z = basePos[groupIndex].z + Rand_CenteredFloat(100.0f); } ripplePos = fish->pos; @@ -4619,8 +4640,8 @@ void Fishing_UpdateGroupFishes(PlayState* play) { Fishing_SpawnRipple(&fish->projectedPos, play->specialEffects, &ripplePos, 20.0f, Rand_ZeroFloat(50.0f) + 100.0f, 150, 90); - if (fish->unk_28 < 1.5f) { - fish->unk_28 = 1.5f; + if (fish->velY < 1.5f) { + fish->velY = 1.5f; } fish->unk_34 = 1.5f; @@ -4628,32 +4649,32 @@ void Fishing_UpdateGroupFishes(PlayState* play) { } target = Fishing_SmoothStepToS(&fish->unk_3E, spD4, 5, 0x4000) * 3.0f; - if (target > 0x1F40) { - target = 0x1F40; - } else if (target < -0x1F40) { - target = -0x1F40; + if (target > 8000) { + target = 8000; + } else if (target < -8000) { + target = -8000; } - Math_ApproachS(&fish->unk_42, target, 3, 0x1388); + Math_ApproachS(&fish->unk_42, target, 3, 5000); offset = fish->unk_42 * -0.0001f; Math_ApproachS(&fish->unk_3C, spD6, 5, 0x4000); if (groupContactFlags & groupFlag) { fish->unk_38 = 1.0f; - fish->unk_28 = 6.0f; + fish->velY = 6.0f; fish->unk_34 = 2.0f; } - if (D_80B7A898 != 0.0f) { + if (sFishGroupVar != 0.0f) { fish->unk_38 = 1.0f; - fish->unk_28 = 4.0f; + fish->velY = 4.0f; fish->unk_34 = 2.0f; } - Math_ApproachF(&fish->unk_28, 0.75f, 1.0f, 0.05f); + Math_ApproachF(&fish->velY, 0.75f, 1.0f, 0.05f); - temp1 = fish->unk_28 * spD8; + temp1 = fish->velY * spD8; temp2 = Math_CosS(fish->unk_3C) * temp1; fish->pos.x += temp2 * Math_SinS(fish->unk_3E); @@ -4664,14 +4685,14 @@ void Fishing_UpdateGroupFishes(PlayState* play) { Math_ApproachF(&fish->unk_34, 1.0f, 1.0f, 0.1f); Math_ApproachF(&fish->unk_38, 0.4f, 1.0f, 0.04f); fish->unk_30 += fish->unk_34; - fish->unk_2C = (cosf(fish->unk_30) * fish->unk_38) + offset; + fish->scaleX = (cosf(fish->unk_30) * fish->unk_38) + offset; } } fish++; } - D_80B7A898 = 0.0f; + sFishGroupVar = 0.0f; } void Fishing_DrawGroupFishes(PlayState* play) { @@ -4703,7 +4724,7 @@ void Fishing_DrawGroupFishes(PlayState* play) { Matrix_Translate(fish->pos.x, fish->pos.y, fish->pos.z, MTXMODE_NEW); Matrix_RotateY(BINANG_TO_RAD_ALT2((f32)fish->unk_3E), MTXMODE_APPLY); Matrix_RotateX(BINANG_TO_RAD_ALT2(-(f32)fish->unk_3C), MTXMODE_APPLY); - Matrix_Scale(fish->unk_2C * scale, scale, scale, MTXMODE_APPLY); + Matrix_Scale(fish->scaleX * scale, scale, scale, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_fishing.c", 8093), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -4716,14 +4737,15 @@ void Fishing_DrawGroupFishes(PlayState* play) { CLOSE_DISPS(play->state.gfxCtx, "../z_fishing.c", 8099); } -static u16 D_80B7AFB8[] = { 0x4096, 0x408D, 0x408E, 0x408F, 0x4094, 0x4095 }; +static u16 sPondOwnerTextIds[] = { 0x4096, 0x408D, 0x408E, 0x408F, 0x4094, 0x4095 }; void Fishing_HandleOwnerDialog(Fishing* this, PlayState* play) { - switch (this->unk_15C) { + switch (this->stateAndTimer) { case 0: - if (D_80B7E0AC == 0) { + if (sFishingPlayingState == 0) { if (sLinkAge != LINK_AGE_CHILD) { - if ((HIGH_SCORE(HS_FISHING) & 0x100) && !(HIGH_SCORE(HS_FISHING) & 0x200)) { + if ((HIGH_SCORE(HS_FISHING) & HS_FISH_PLAYED_CHILD) && + !(HIGH_SCORE(HS_FISHING) & HS_FISH_PLAYED_ADULT)) { this->actor.textId = 0x4093; } else { this->actor.textId = 0x407B; @@ -4731,22 +4753,22 @@ void Fishing_HandleOwnerDialog(Fishing* this, PlayState* play) { } else { this->actor.textId = 0x407B; } - } else if (D_80B7A68C == 0) { + } else if (!sIsOwnersHatHooked) { this->actor.textId = 0x4084; } else { this->actor.textId = 0x4097; } if (Actor_ProcessTalkRequest(&this->actor, play)) { - if (D_80B7E0AC == 0) { - this->unk_15C = 1; + if (sFishingPlayingState == 0) { + this->stateAndTimer = 1; if (sLinkAge != LINK_AGE_CHILD) { - HIGH_SCORE(HS_FISHING) |= 0x200; + HIGH_SCORE(HS_FISHING) |= HS_FISH_PLAYED_ADULT; } else { - HIGH_SCORE(HS_FISHING) |= 0x100; + HIGH_SCORE(HS_FISHING) |= HS_FISH_PLAYED_CHILD; } } else { - this->unk_15C = 10; + this->stateAndTimer = 10; } } else { func_8002F2CC(&this->actor, play, 100.0f); @@ -4767,15 +4789,15 @@ void Fishing_HandleOwnerDialog(Fishing* this, PlayState* play) { this->actor.textId = 0x407D; } Message_ContinueTextbox(play, this->actor.textId); - this->unk_15C = 2; + this->stateAndTimer = 2; } else { Message_ContinueTextbox(play, 0x407E); - this->unk_15C = 3; + this->stateAndTimer = 3; } break; case 1: Message_ContinueTextbox(play, 0x2D); - this->unk_15C = 3; + this->stateAndTimer = 3; break; } } @@ -4785,17 +4807,17 @@ void Fishing_HandleOwnerDialog(Fishing* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(play)) { Message_CloseTextbox(play); Message_ContinueTextbox(play, 0x407F); - this->unk_15C = 4; + this->stateAndTimer = 4; } break; case 3: if ((Message_GetState(&play->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(play)) { Message_CloseTextbox(play); - this->unk_15C = 0; + this->stateAndTimer = 0; } if (Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) { - this->unk_15C = 0; + this->stateAndTimer = 0; } break; @@ -4805,9 +4827,9 @@ void Fishing_HandleOwnerDialog(Fishing* this, PlayState* play) { switch (play->msgCtx.choiceIndex) { case 0: - D_80B7A678 = D_80B7E078; + sFishLengthToWeigh = sFishingRecordLength; Message_ContinueTextbox(play, 0x4080); - this->unk_15C = 5; + this->stateAndTimer = 5; break; case 1: Message_ContinueTextbox(play, 0x407F); @@ -4822,30 +4844,30 @@ void Fishing_HandleOwnerDialog(Fishing* this, PlayState* play) { play->interfaceCtx.unk_260 = 1; play->startPlayerFishing(play); - D_80B7E0AC = 1; - D_80B7A684 = 20; - this->unk_15C = 0; + sFishingPlayingState = 1; + sOwnerTheftTimer = 20; + this->stateAndTimer = 0; if ((HIGH_SCORE(HS_FISHING) & 0xFF0000) < 0xFF0000) { - HIGH_SCORE(HS_FISHING) += 0x10000; + HIGH_SCORE(HS_FISHING) += HS_FISH_PLAYED; } } break; case 10: - if (D_80B7A68C != 0) { + if (sIsOwnersHatHooked) { // owner asks for hat back if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { Message_CloseTextbox(play); switch (play->msgCtx.choiceIndex) { case 0: Message_ContinueTextbox(play, 0x40B2); - D_80B7A688 = 1; - D_80B7A68C = 0; - this->unk_15C = 20; + sOwnerHair = FS_OWNER_CAPPED; + sIsOwnersHatHooked = false; + this->stateAndTimer = 20; break; case 1: - this->unk_15C = 0; + this->stateAndTimer = 0; break; } } @@ -4855,73 +4877,74 @@ void Fishing_HandleOwnerDialog(Fishing* this, PlayState* play) { switch (play->msgCtx.choiceIndex) { case 0: - if (D_80B7A670 == 0.0f) { + if (sFishOnHandLength == 0.0f) { this->actor.textId = 0x408C; - this->unk_15C = 20; - } else if (D_80B7E07C == 0) { - D_80B7A678 = D_80B7A670; - if ((s16)D_80B7E078 < (s16)D_80B7A670) { - if (D_80B7E07E == 2) { + this->stateAndTimer = 20; + } else if (sFishOnHandIsLoach == 0) { + sFishLengthToWeigh = sFishOnHandLength; + if ((s16)sFishingRecordLength < (s16)sFishOnHandLength) { + if (sLureCaughtWith == FS_LURE_SINKING) { this->actor.textId = 0x40B0; } else { this->actor.textId = 0x4086; } - this->unk_15C = 11; + this->stateAndTimer = 11; } else { this->actor.textId = 0x408B; - this->unk_15C = 20; + this->stateAndTimer = 20; } } else { this->actor.textId = 0x409B; - this->unk_15C = 11; + this->stateAndTimer = 11; } Message_ContinueTextbox(play, this->actor.textId); break; case 1: - if (D_80B7A680 > 36000) { - D_80B7A680 = 30000; + if (sFishingTimePlayed > 36000) { + sFishingTimePlayed = 30000; Message_ContinueTextbox(play, 0x4088); } else { - if (D_80B7E076 == 0) { - if (D_80B7E082 == 0) { - D_80B7E082++; + if (sFishingFoggy == 0) { + if (sPondOwnerTextIdIndex == 0) { + sPondOwnerTextIdIndex++; } } - if ((D_80B7E0B6 == 2) && (D_80B7AFB8[D_80B7E082] == 0x408D)) { + if ((sLureEquipped == FS_LURE_SINKING) && + (sPondOwnerTextIds[sPondOwnerTextIdIndex] == 0x408D)) { Message_ContinueTextbox(play, 0x40AF); } else { - Message_ContinueTextbox(play, D_80B7AFB8[D_80B7E082]); + Message_ContinueTextbox(play, sPondOwnerTextIds[sPondOwnerTextIdIndex]); } - D_80B7E082++; + sPondOwnerTextIdIndex++; if (sLinkAge != LINK_AGE_CHILD) { - if (D_80B7E082 >= 6) { - D_80B7E082 = 0; + if (sPondOwnerTextIdIndex >= 6) { + sPondOwnerTextIdIndex = 0; } } else { - if (D_80B7E082 >= 4) { - D_80B7E082 = 0; + if (sPondOwnerTextIdIndex >= 4) { + sPondOwnerTextIdIndex = 0; } } } - this->unk_15C = 0; + this->stateAndTimer = 0; break; case 2: - if (D_80B7E084 == 0) { + if (sFishesCaught == 0) { Message_ContinueTextbox(play, 0x4085); } else if (sLinkAge == LINK_AGE_CHILD) { Message_ContinueTextbox(play, 0x4092); } - this->unk_15C = 22; + this->stateAndTimer = 22; break; } } } break; - case 11: + case 11: // collect prize, update record. if (((Message_GetState(&play->msgCtx) == TEXT_STATE_EVENT) || (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE)) && Message_ShouldAdvance(play)) { @@ -4929,80 +4952,81 @@ void Fishing_HandleOwnerDialog(Fishing* this, PlayState* play) { Message_CloseTextbox(play); - if (D_80B7E07C == 0) { - D_80B7E078 = D_80B7A670; - D_80B7A670 = 0.0f; + if (sFishOnHandIsLoach == 0) { + sFishingRecordLength = sFishOnHandLength; + sFishOnHandLength = 0.0f; if (sLinkAge == LINK_AGE_CHILD) { f32 temp; HIGH_SCORE(HS_FISHING) &= 0xFFFFFF00; - HIGH_SCORE(HS_FISHING) |= (s32)D_80B7E078 & 0x7F; + HIGH_SCORE(HS_FISHING) |= (s32)sFishingRecordLength & HS_FISH_LENGTH_CHILD; - temp = (HIGH_SCORE(HS_FISHING) & 0x7F000000) >> 0x18; - if (temp < D_80B7E078) { + temp = (HIGH_SCORE(HS_FISHING) & HS_FISH_LENGTH_ADULT) >> 0x18; + if (temp < sFishingRecordLength) { HIGH_SCORE(HS_FISHING) &= 0xFFFFFF; - HIGH_SCORE(HS_FISHING) |= ((s32)D_80B7E078 & 0x7F) << 0x18; + HIGH_SCORE(HS_FISHING) |= ((s32)sFishingRecordLength & HS_FISH_LENGTH_CHILD) << 0x18; - if (D_80B7E07E == 2) { - HIGH_SCORE(HS_FISHING) |= 0x80000000; + if (sLureCaughtWith == FS_LURE_SINKING) { + HIGH_SCORE(HS_FISHING) |= HS_FISH_CHEAT_ADULT; } } - if (D_80B7E07E == 2) { - HIGH_SCORE(HS_FISHING) |= 0x80; - this->unk_15C = 0; + if (sLureCaughtWith == FS_LURE_SINKING) { + HIGH_SCORE(HS_FISHING) |= HS_FISH_CHEAT_CHILD; + this->stateAndTimer = 0; break; } } else { HIGH_SCORE(HS_FISHING) &= 0xFFFFFF; - HIGH_SCORE(HS_FISHING) |= ((s32)D_80B7E078 & 0x7F) << 0x18; + HIGH_SCORE(HS_FISHING) |= ((s32)sFishingRecordLength & HS_FISH_LENGTH_CHILD) << 0x18; - if (D_80B7E07E == 2) { - HIGH_SCORE(HS_FISHING) |= 0x80000000; - this->unk_15C = 0; + if (sLureCaughtWith == FS_LURE_SINKING) { + HIGH_SCORE(HS_FISHING) |= HS_FISH_CHEAT_ADULT; + this->stateAndTimer = 0; break; } } - if (D_80B7E078 >= 60.0f) { + if (sFishingRecordLength >= 60.0f) { // 13 lbs getItemId = GI_RUPEE_PURPLE; - } else if (D_80B7E078 >= 50.0f) { + } else if (sFishingRecordLength >= 50.0f) { // 9 lbs getItemId = GI_RUPEE_RED; - } else if (D_80B7E078 >= 40.0f) { + } else if (sFishingRecordLength >= 40.0f) { // 6 lbs getItemId = GI_RUPEE_BLUE; } else { getItemId = GI_RUPEE_GREEN; } - if (sLinkAge == LINK_AGE_CHILD) { - if ((D_80B7E078 >= 50.0f) && !(HIGH_SCORE(HS_FISHING) & 0x400)) { - HIGH_SCORE(HS_FISHING) |= 0x400; + if (sLinkAge == LINK_AGE_CHILD) { // 9 lbs + if ((sFishingRecordLength >= 50.0f) && !(HIGH_SCORE(HS_FISHING) & HS_FISH_PRIZE_CHILD)) { + HIGH_SCORE(HS_FISHING) |= HS_FISH_PRIZE_CHILD; getItemId = GI_HEART_PIECE; sSinkingLureLocation = (u8)Rand_ZeroFloat(3.999f) + 1; } - } else { - if ((D_80B7E078 >= 60.0f) && !(HIGH_SCORE(HS_FISHING) & 0x800)) { - HIGH_SCORE(HS_FISHING) |= 0x800; + } else { // 13 lbs + if ((sFishingRecordLength >= 60.0f) && !(HIGH_SCORE(HS_FISHING) & HS_FISH_PRIZE_ADULT)) { + HIGH_SCORE(HS_FISHING) |= HS_FISH_PRIZE_ADULT; getItemId = GI_SCALE_GOLDEN; sSinkingLureLocation = (u8)Rand_ZeroFloat(3.999f) + 1; } } } else { getItemId = GI_RUPEE_PURPLE; - D_80B7A670 = 0.0f; + sFishOnHandLength = 0.0f; // doesn't record loach } this->actor.parent = NULL; + Actor_OfferGetItem(&this->actor, play, getItemId, 2000.0f, 1000.0f); - this->unk_15C = 23; + this->stateAndTimer = 23; } break; case 20: if ((Message_GetState(&play->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(play)) { Message_CloseTextbox(play); - this->unk_15C = 0; + this->stateAndTimer = 0; } break; @@ -5012,15 +5036,15 @@ void Fishing_HandleOwnerDialog(Fishing* this, PlayState* play) { switch (play->msgCtx.choiceIndex) { case 0: - this->unk_15C = 0; + this->stateAndTimer = 0; break; case 1: - if (D_80B7E084 == 0) { + if (sFishesCaught == 0) { Message_ContinueTextbox(play, 0x4085); } else if (sLinkAge == LINK_AGE_CHILD) { Message_ContinueTextbox(play, 0x4092); } - this->unk_15C = 22; + this->stateAndTimer = 22; break; } } @@ -5030,56 +5054,56 @@ void Fishing_HandleOwnerDialog(Fishing* this, PlayState* play) { if (play) {} if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { - this->unk_15C = 0; - if (D_80B7A68C != 0) { - D_80B7A688 = 1; - D_80B7A68C = 0; + this->stateAndTimer = 0; + if (sIsOwnersHatHooked) { + sOwnerHair = FS_OWNER_CAPPED; + sIsOwnersHatHooked = false; } - D_80B7E0AC = 0; + sFishingPlayingState = 0; play->interfaceCtx.unk_260 = 0; } break; case 23: - D_80B7A674 = false; + sIsRodVisible = false; if (Actor_HasParent(&this->actor, play)) { - this->unk_15C = 24; + this->stateAndTimer = 24; } else { Actor_OfferGetItem(&this->actor, play, GI_SCALE_GOLDEN, 2000.0f, 1000.0f); } break; case 24: - D_80B7A674 = false; + sIsRodVisible = false; if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { - if (D_80B7E07C == 0) { - this->unk_15C = 0; + if (sFishOnHandIsLoach == 0) { + this->stateAndTimer = 0; } else { Message_StartTextbox(play, 0x409C, NULL); - this->unk_15C = 20; + this->stateAndTimer = 20; } } break; } } -static s16 D_80B7AFC4[] = { 0, 1, 2, 2, 1 }; +static s16 sOwnerBlinkIndex[] = { 0, 1, 2, 2, 1 }; static Vec3f sStreamSfxPos = { 670.0f, 0.0f, -600.0f }; -static Vec3s sSinkingLureLocationPos[] = { - { -364, -30, -269 }, - { 1129, 3, -855 }, - { -480, 0, -1055 }, - { 553, -48, -508 }, +static Vec3s sSinkingLureLocations[] = { + { -364, -30, -269 }, // in the pond, log past the lilies. + { 1129, 3, -855 }, // rock next to stream + { -480, 0, -1055 }, // wall opposite of entrance + { 553, -48, -508 }, // tip of log beside 3 posts }; void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { PlayState* play = play2; Fishing* this = (Fishing*)thisx; - Vec3f sp114; - Vec3f sp108; - Vec3f spFC; + Vec3f multiVecSrc; + Vec3f eyeTarget; + Vec3f lureDist; s16 headRotTarget; s16 playerShadowAlpha; f32 target; @@ -5110,7 +5134,7 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { SkelAnime_Update(&this->skelAnime); - if ((D_80B7A684 != 0) || (Message_GetState(&play->msgCtx) != TEXT_STATE_NONE)) { + if ((sOwnerTheftTimer != 0) || (Message_GetState(&play->msgCtx) != TEXT_STATE_NONE)) { this->actor.flags &= ~ACTOR_FLAG_0; } else { this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_5; @@ -5122,88 +5146,92 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { headRotTarget = 0; } - if (headRotTarget > 0x2710) { - headRotTarget = 0x2710; - } else if (headRotTarget < -0x2710) { - headRotTarget = -0x2710; + if (headRotTarget > 10000) { + headRotTarget = 10000; + } else if (headRotTarget < -10000) { + headRotTarget = -10000; } - Math_ApproachS(&this->unk_164, headRotTarget, 3, 0x1388); + Math_ApproachS(&this->unk_164, headRotTarget, 3, 5000); if (((play->gameplayFrames % 32) == 0) && (Rand_ZeroOne() < 0.3f)) { this->unk_162 = 4; } - this->unk_160 = D_80B7AFC4[this->unk_162]; + this->unk_160 = sOwnerBlinkIndex[this->unk_162]; if (this->unk_162 != 0) { this->unk_162--; } - if (D_80B7A684 != 0) { - D_80B7A684--; + if (sOwnerTheftTimer != 0) { + sOwnerTheftTimer--; } - if ((D_80B7A68C == 0) && (D_80B7E0B6 != 2) && (D_80B7A694 > 0) && (D_80B7A688 == 1) && (D_80B7A684 == 0)) { + // steal the owner's hat + if (!sIsOwnersHatHooked && (sLureEquipped != FS_LURE_SINKING) && (sRodCastState > 0) && + (sOwnerHair == FS_OWNER_CAPPED) && (sOwnerTheftTimer == 0)) { f32 dx = sOwnerHeadPos.x - sLurePos.x; f32 dy = sOwnerHeadPos.y - sLurePos.y; f32 dz = sOwnerHeadPos.z - sLurePos.z; if ((sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) < 25.0f) || (KREG(77) > 0)) { KREG(77) = 0; - D_80B7A688 = 0; - D_80B7A68C = 1; + sOwnerHair = FS_OWNER_BALD; + sIsOwnersHatHooked = true; Message_StartTextbox(play, 0x4087, NULL); } } - if (D_80B7A688 == 0) { - HIGH_SCORE(HS_FISHING) |= 0x1000; - } else if (D_80B7A688 == 1) { - HIGH_SCORE(HS_FISHING) &= ~0x1000; + // update hat flag. + if (sOwnerHair == FS_OWNER_BALD) { + HIGH_SCORE(HS_FISHING) |= HS_FISH_STOLE_HAT; + } else if (sOwnerHair == FS_OWNER_CAPPED) { + HIGH_SCORE(HS_FISHING) &= ~HS_FISH_STOLE_HAT; } if (KREG(77) < 0) { KREG(77) = 0; - D_80B7A690 = 1; + sIsOwnersHatSunk = true; } - if (D_80B7A67C != 0) { - D_80B7A67C--; - if (D_80B7A67C == 0) { - Message_StartTextbox(play, D_80B7E086, NULL); + if (sFishingCaughtTextDelay != 0) { + sFishingCaughtTextDelay--; + if (sFishingCaughtTextDelay == 0) { + Message_StartTextbox(play, sFishingCaughtTextId, NULL); } } Fishing_HandleOwnerDialog(this, play); - D_80B7E14C = 0.0015f; - D_80B7A680++; + sFishingLineScale = 0.0015f; + sFishingTimePlayed++; - if ((D_80B7E0AC != 0) && D_80B7A674) { + if ((sFishingPlayingState != 0) && sIsRodVisible) { Fishing_UpdateLure(this, play); } Fishing_UpdateEffects(play->specialEffects, play); Fishing_UpdatePondProps(play); Fishing_UpdateGroupFishes(play); - - if ((D_80B7E0AC != 0) && (D_80B7A6CC == 0) && (player->actor.world.pos.z > 1360.0f) && + // can't leave with the rod + if ((sFishingPlayingState != 0) && (sFishingPlayerCinematicState == 0) && (player->actor.world.pos.z > 1360.0f) && (fabsf(player->actor.world.pos.x) < 25.0f)) { player->actor.world.pos.z = 1360.0f; player->actor.speed = 0.0f; - if (D_80B7A6D0 == 0) { - D_80B7A6CC = 10; + if (sFishingCinematicTimer == 0) { + sFishingPlayerCinematicState = 10; } } + // check if can/have found sinking lure. if ((sSinkingLureLocation != 0) && - (fabsf(player->actor.world.pos.x - sSinkingLureLocationPos[sSinkingLureLocation - 1].x) < 25.0f) && - (fabsf(player->actor.world.pos.y - sSinkingLureLocationPos[sSinkingLureLocation - 1].y) < 10.0f) && - (fabsf(player->actor.world.pos.z - sSinkingLureLocationPos[sSinkingLureLocation - 1].z) < 25.0f)) { + (fabsf(player->actor.world.pos.x - sSinkingLureLocations[sSinkingLureLocation - 1].x) < 25.0f) && + (fabsf(player->actor.world.pos.y - sSinkingLureLocations[sSinkingLureLocation - 1].y) < 10.0f) && + (fabsf(player->actor.world.pos.z - sSinkingLureLocations[sSinkingLureLocation - 1].z) < 25.0f)) { sSinkingLureLocation = 0; - D_80B7A6CC = 20; + sFishingPlayerCinematicState = 20; Rumble_Override(0.0f, 150, 10, 10); Sfx_PlaySfxCentered(NA_SE_SY_TRE_BOX_APPEAR); SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 20); @@ -5211,18 +5239,19 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { if (KREG(0) != 0) { KREG(0) = 0; - D_80B7E0B6 = 0; - D_80B7A6CC = 20; + sLureEquipped = FS_LURE_STOCK; + sFishingPlayerCinematicState = 20; Rumble_Override(0.0f, 150, 10, 10); Sfx_PlaySfxCentered(NA_SE_SY_TRE_BOX_APPEAR); SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 20); } - if (D_80B7A6D0 != 0) { - D_80B7A6D0--; + if (sFishingCinematicTimer != 0) { + sFishingCinematicTimer--; } - switch (D_80B7A6CC) { + // handle cinematics (i.e.: catching fish, finding sinking lure) + switch (sFishingPlayerCinematicState) { case 0: break; @@ -5239,7 +5268,7 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { sSubCamAt.x = mainCam->at.x; sSubCamAt.y = mainCam->at.y; sSubCamAt.z = mainCam->at.z; - D_80B7A6CC = 2; + sFishingPlayerCinematicState = 2; Interface_ChangeHudVisibilityMode(HUD_VISIBILITY_A_B_MINIMAP); sSubCamVelFactor = 0.0f; FALLTHROUGH; @@ -5248,50 +5277,50 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { case 2: Letterbox_SetSizeTarget(27); - spFC.x = sLurePos.x - player->actor.world.pos.x; - spFC.z = sLurePos.z - player->actor.world.pos.z; - lureDistXZ = sqrtf(SQXZ(spFC)); - Matrix_RotateY(Math_Atan2F(spFC.z, spFC.x), MTXMODE_NEW); + lureDist.x = sLurePos.x - player->actor.world.pos.x; + lureDist.z = sLurePos.z - player->actor.world.pos.z; + lureDistXZ = sqrtf(SQXZ(lureDist)); + Matrix_RotateY(Math_Atan2F(lureDist.z, lureDist.x), MTXMODE_NEW); - sp114.x = 0.0f; - sp114.y = 0.0f; - sp114.z = 100.0f; - Matrix_MultVec3f(&sp114, &spFC); + multiVecSrc.x = 0.0f; + multiVecSrc.y = 0.0f; + multiVecSrc.z = 100.0f; + Matrix_MultVec3f(&multiVecSrc, &lureDist); - if (D_80B7A694 == 1) { + if (sRodCastState == 1) { subCamAtMaxVelFrac = 0.2f; } else { subCamAtMaxVelFrac = 0.1f; } - Math_ApproachF(&sSubCamAt.x, sLurePos.x, subCamAtMaxVelFrac, fabsf(spFC.x) * sSubCamVelFactor); + Math_ApproachF(&sSubCamAt.x, sLurePos.x, subCamAtMaxVelFrac, fabsf(lureDist.x) * sSubCamVelFactor); Math_ApproachF(&sSubCamAt.y, sLurePos.y, subCamAtMaxVelFrac, 50.0f * sSubCamVelFactor); - Math_ApproachF(&sSubCamAt.z, sLurePos.z, subCamAtMaxVelFrac, fabsf(spFC.z) * sSubCamVelFactor); + Math_ApproachF(&sSubCamAt.z, sLurePos.z, subCamAtMaxVelFrac, fabsf(lureDist.z) * sSubCamVelFactor); - sp114.x = 0.0f - D_80B7FED0; + multiVecSrc.x = 0.0f - D_80B7FED0; if (sLinkAge != LINK_AGE_CHILD) { - sp114.y = 80.0f; + multiVecSrc.y = 80.0f; } else { - sp114.y = 55.0f; + multiVecSrc.y = 55.0f; } - sp114.z = -80.0f; + multiVecSrc.z = -80.0f; - Matrix_MultVec3f(&sp114, &sp108); - sp108.x += player->actor.world.pos.x; - sp108.y += player->actor.world.pos.y; - sp108.z += player->actor.world.pos.z; + Matrix_MultVec3f(&multiVecSrc, &eyeTarget); + eyeTarget.x += player->actor.world.pos.x; + eyeTarget.y += player->actor.world.pos.y; + eyeTarget.z += player->actor.world.pos.z; Math_ApproachF(&D_80B7FED0, 30.0f, 0.1f, 0.4f); - if (CHECK_BTN_ALL(input->press.button, BTN_Z)) { - if ((D_80B7E088 >= 0) && (D_80B7E122 == 0)) { - D_80B7E088++; + if (CHECK_BTN_ALL(input->press.button, BTN_Z)) { // zoom in/out from the lure + if ((sLureCameraZoomLevel >= 0) && (sLureBitTimer == 0)) { + sLureCameraZoomLevel++; - if (D_80B7E088 >= 4) { - D_80B7E088 = 0; + if (sLureCameraZoomLevel >= 4) { + sLureCameraZoomLevel = 0; } - if ((D_80B7E088 == 0) || (D_80B7E088 == 3)) { + if ((sLureCameraZoomLevel == 0) || (sLureCameraZoomLevel == 3)) { Sfx_PlaySfxCentered(NA_SE_SY_CAMERA_ZOOM_DOWN); } else { Sfx_PlaySfxCentered(NA_SE_SY_CAMERA_ZOOM_UP); @@ -5299,44 +5328,44 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { } } - if (D_80B7A694 >= 3) { + if (sRodCastState >= 3) { if (lureDistXZ < 110.0f) { - D_80B7E088 = -1; - } else if ((lureDistXZ > 300.0f) && (D_80B7E088 < 0)) { - D_80B7E088 = 0; + sLureCameraZoomLevel = -1; + } else if ((lureDistXZ > 300.0f) && (sLureCameraZoomLevel < 0)) { + sLureCameraZoomLevel = 0; } } - if (D_80B7E088 > 0) { + if (sLureCameraZoomLevel > 0) { f32 dist; f32 offset; f32 factor; - dist = sqrtf(SQ(spFC.x) + SQ(spFC.z)) * 0.001f; + dist = sqrtf(SQ(lureDist.x) + SQ(lureDist.z)) * 0.001f; if (dist > 1.0f) { dist = 1.0f; } - if (D_80B7E088 == 2) { + if (sLureCameraZoomLevel == 2) { offset = 0.3f; } else { offset = 0.1f; } factor = 0.4f + offset + (dist * 0.4f); - sp108.x += (sLurePos.x - sp108.x) * factor; - sp108.y += ((sLurePos.y - sp108.y) * factor) + 20.0f; - sp108.z += (sLurePos.z - sp108.z) * factor; - D_80B7E14C = 0.0005000001f; + eyeTarget.x += (sLurePos.x - eyeTarget.x) * factor; + eyeTarget.y += ((sLurePos.y - eyeTarget.y) * factor) + 20.0f; + eyeTarget.z += (sLurePos.z - eyeTarget.z) * factor; + sFishingLineScale = 0.0005000001f; } - sp114.x = 0.0f; - sp114.y = 0.0f; - sp114.z = 100.0f; - Matrix_MultVec3f(&sp114, &spFC); + multiVecSrc.x = 0.0f; + multiVecSrc.y = 0.0f; + multiVecSrc.z = 100.0f; + Matrix_MultVec3f(&multiVecSrc, &lureDist); - Math_ApproachF(&sSubCamEye.x, sp108.x, 0.3f, fabsf(spFC.x) * sSubCamVelFactor); - Math_ApproachF(&sSubCamEye.y, sp108.y, 0.3f, 20.0f * sSubCamVelFactor); - Math_ApproachF(&sSubCamEye.z, sp108.z, 0.3f, fabsf(spFC.z) * sSubCamVelFactor); + Math_ApproachF(&sSubCamEye.x, eyeTarget.x, 0.3f, fabsf(lureDist.x) * sSubCamVelFactor); + Math_ApproachF(&sSubCamEye.y, eyeTarget.y, 0.3f, 20.0f * sSubCamVelFactor); + Math_ApproachF(&sSubCamEye.z, eyeTarget.z, 0.3f, fabsf(lureDist.z) * sSubCamVelFactor); break; case 3: { @@ -5347,7 +5376,7 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { mainCam->at = sSubCamAt; Play_ReturnToMainCam(play, sSubCamId, 0); Cutscene_StopManual(play, &play->csCtx); - D_80B7A6CC = 0; + sFishingPlayerCinematicState = 0; sSubCamId = SUB_CAM_ID_DONE; Environment_EnableUnderwaterLights(play, 0); play->envCtx.adjFogNear = 0; @@ -5356,7 +5385,7 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { break; } - case 10: { + case 10: { // owner tells you to return the rod. Camera* mainCam; Cutscene_StartManual(play, &play->csCtx); @@ -5372,7 +5401,7 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { sSubCamAt.y = mainCam->at.y; sSubCamAt.z = mainCam->at.z; Message_StartTextbox(play, 0x409E, NULL); - D_80B7A6CC = 11; + sFishingPlayerCinematicState = 11; Rumble_Override(0.0f, 150, 10, 10); FALLTHROUGH; } @@ -5390,15 +5419,16 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { Play_ReturnToMainCam(play, sSubCamId, 0); Cutscene_StopManual(play, &play->csCtx); func_8002DF54(play, &this->actor, PLAYER_CSMODE_7); - D_80B7A6CC = 0; + sFishingPlayerCinematicState = 0; + sSubCamId = SUB_CAM_ID_DONE; - D_80B7A6D0 = 30; + sFishingCinematicTimer = 30; Environment_EnableUnderwaterLights(play, 0); play->envCtx.adjFogNear = 0; } break; - case 20: { + case 20: { // found the sinking lure Camera* mainCam; Cutscene_StartManual(play, &play->csCtx); @@ -5414,57 +5444,57 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { sSubCamAt.y = mainCam->at.y; sSubCamAt.z = mainCam->at.z; Message_StartTextbox(play, 0x409A, NULL); - D_80B7A6CC = 21; - D_80B7FEC8 = 45.0f; - D_80B7A6D0 = 10; + sFishingPlayerCinematicState = 21; + sCatchCamX = 45.0f; + sFishingCinematicTimer = 10; FALLTHROUGH; } case 21: - if ((D_80B7A6D0 == 0) && Message_ShouldAdvance(play)) { - D_80B7A6CC = 22; - D_80B7A6D0 = 40; + if ((sFishingCinematicTimer == 0) && Message_ShouldAdvance(play)) { + sFishingPlayerCinematicState = 22; + sFishingCinematicTimer = 40; func_8002DF54(play, &this->actor, PLAYER_CSMODE_28); - D_80B7FEE4 = 0.0f; + sSinkingLureHeldY = 0.0f; } break; case 22: - if (D_80B7A6D0 == 30) { + if (sFishingCinematicTimer == 30) { SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 9, NA_BGM_ITEM_GET); } - D_80B7A6D4 = 1; + sSinkingLureFound = true; - Math_ApproachF(&D_80B7FEE4, 71.0f, 0.5f, 3.0f); + Math_ApproachF(&sSinkingLureHeldY, 71.0f, 0.5f, 3.0f); Matrix_RotateY(BINANG_TO_RAD_ALT(player->actor.shape.rot.y), MTXMODE_NEW); - sp114.x = Math_SinS(play->gameplayFrames * 0x1000); - sp114.y = D_80B7FEE4; - sp114.z = -5.0f; + multiVecSrc.x = Math_SinS(play->gameplayFrames * 0x1000); + multiVecSrc.y = sSinkingLureHeldY; + multiVecSrc.z = -5.0f; if (sLinkAge == LINK_AGE_CHILD) { - sp114.y -= 20.0f; + multiVecSrc.y -= 20.0f; } - Matrix_MultVec3f(&sp114, &sp108); + Matrix_MultVec3f(&multiVecSrc, &eyeTarget); - sSinkingLureBasePos.x = player->actor.world.pos.x + sp108.x; - sSinkingLureBasePos.y = player->actor.world.pos.y + sp108.y; - sSinkingLureBasePos.z = player->actor.world.pos.z + sp108.z; + sSinkingLureBasePos.x = player->actor.world.pos.x + eyeTarget.x; + sSinkingLureBasePos.y = player->actor.world.pos.y + eyeTarget.y; + sSinkingLureBasePos.z = player->actor.world.pos.z + eyeTarget.z; - Math_ApproachF(&D_80B7FEC8, 15.0f, 0.1f, 0.75f); + Math_ApproachF(&sCatchCamX, 15.0f, 0.1f, 0.75f); - sp114.x = D_80B7FEC8 - 15.0f; + multiVecSrc.x = sCatchCamX - 15.0f; if (sLinkAge != LINK_AGE_CHILD) { - sp114.y = 60.0f; - sp114.z = -30.0f; + multiVecSrc.y = 60.0f; + multiVecSrc.z = -30.0f; } else { - sp114.y = 40.0f; - sp114.z = -35.0f; + multiVecSrc.y = 40.0f; + multiVecSrc.z = -35.0f; } - Matrix_MultVec3f(&sp114, &sSubCamEye); + Matrix_MultVec3f(&multiVecSrc, &sSubCamEye); sSubCamEye.x += player->actor.world.pos.x; sSubCamEye.y += player->actor.world.pos.y; sSubCamEye.z += player->actor.world.pos.z; @@ -5476,7 +5506,7 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { sSubCamAt.y += 40.0f; } - if (D_80B7A6D0 == 0) { + if (sFishingCinematicTimer == 0) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) || (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE)) { if (Message_ShouldAdvance(play)) { @@ -5484,8 +5514,8 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { Message_CloseTextbox(play); if (play->msgCtx.choiceIndex == 0) { - D_80B7E0B6 = 2; - D_80B7E082 = 0; + sLureEquipped = FS_LURE_SINKING; + sPondOwnerTextIdIndex = 0; } mainCam->eye = sSubCamEye; @@ -5494,12 +5524,13 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { Play_ReturnToMainCam(play, sSubCamId, 0); Cutscene_StopManual(play, &play->csCtx); func_8002DF54(play, &this->actor, PLAYER_CSMODE_7); - D_80B7A6CC = 0; + sFishingPlayerCinematicState = 0; + sSubCamId = SUB_CAM_ID_DONE; player->unk_860 = -5; D_80B7E0B0 = 5; - D_80B7A6D4 = 0; - D_80B7E0A6 = 20; + sSinkingLureFound = false; + sFishingMusicDelay = 20; Environment_EnableUnderwaterLights(play, 0); play->envCtx.adjFogNear = 0; } @@ -5517,7 +5548,7 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { if (sSubCamEye.y <= (WATER_SURFACE_Y(play) + 1.0f)) { Environment_EnableUnderwaterLights(play, 1); - if (D_80B7E076 != 0) { + if (sFishingFoggy != 0) { play->envCtx.adjFogNear = -178; } else { play->envCtx.adjFogNear = -46; @@ -5566,15 +5597,15 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { } if (sREG(15) != 0) { - if (D_80B7A654 != (sREG(15) - 1)) { - if (D_80B7A654 == 0) { + if (sStormStrengthTarget != (sREG(15) - 1)) { + if (sStormStrengthTarget == 0) { play->envCtx.stormRequest = STORM_REQUEST_START; } else { play->envCtx.stormRequest = STORM_REQUEST_STOP; } } - D_80B7A654 = sREG(15) - 1; + sStormStrengthTarget = sREG(15) - 1; } if (sREG(14) == 1) { @@ -5590,53 +5621,55 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { osSyncPrintf("zelda_time %x\n", ((void)0, gSaveContext.save.dayTime)); osSyncPrintf(VT_RST); - if (D_80B7E077 >= 2) { - D_80B7E077--; + if (sStormChanceTimer >= 2) { + sStormChanceTimer--; } - if ((D_80B7E077 == 1) && (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) && ((D_80B7A680 & 0xFFF) == 0xFFF)) { - D_80B7E077 = 200; + if ((sStormChanceTimer == 1) && (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) && + ((sFishingTimePlayed & 0xFFF) == 0xFFF)) { + sStormChanceTimer = 200; if (Rand_ZeroOne() < 0.5f) { - D_80B7A654 = (u8)Rand_ZeroFloat(10.0f) + 5; + sStormStrengthTarget = (u8)Rand_ZeroFloat(10.0f) + 5; play->envCtx.stormRequest = STORM_REQUEST_START; } else { - D_80B7A654 = 0; + sStormStrengthTarget = 0; play->envCtx.stormRequest = STORM_REQUEST_STOP; } } - Math_ApproachF(&D_80B7A650, D_80B7A654, 1.0f, 0.05f); + Math_ApproachF(&sStormStrength, sStormStrengthTarget, 1.0f, 0.05f); - if (D_80B7A650 > 0.0f) { - target = (D_80B7A650 * 0.03f) + 0.8f; + if (sStormStrength > 0.0f) { + target = (sStormStrength * 0.03f) + 0.8f; if (target > 1.2f) { target = 1.2f; } - Math_ApproachF(&D_80B7A668, target, 1.0f, 0.01f); + Math_ApproachF(&sStormSfxFreqScale, target, 1.0f, 0.01f); } - target = (10.0f - D_80B7A650) * 150.1f; + target = (10.0f - sStormStrength) * 150.1f; if (target < 0.0f) { target = 0.0f; } if (1) {} if (1) {} - Math_ApproachF(&D_80B7A65C.z, target, 1.0f, 5.0f); + Math_ApproachF(&sFishingStormSfxPos.z, target, 1.0f, 5.0f); - if (D_80B7A65C.z < 1500.0f) { - func_800F436C(&D_80B7A65C, NA_SE_EV_RAIN - SFX_FLAG, D_80B7A668); + if (sFishingStormSfxPos.z < 1500.0f) { + func_800F436C(&sFishingStormSfxPos, NA_SE_EV_RAIN - SFX_FLAG, sStormSfxFreqScale); } - if (D_80B7A654 != 0) { - Math_ApproachF(&D_80B7A658, -200.0f, 1.0f, 2.0f); + if (sStormStrengthTarget != 0) { + Math_ApproachF(&sFishingStormShade, -200.0f, 1.0f, 2.0f); } else { - Math_ApproachZeroF(&D_80B7A658, 1.0f, 2.0f); + Math_ApproachZeroF(&sFishingStormShade, 1.0f, 2.0f); } - play->envCtx.adjLight1Color[0] = play->envCtx.adjLight1Color[1] = play->envCtx.adjLight1Color[2] = D_80B7A658; + play->envCtx.adjLight1Color[0] = play->envCtx.adjLight1Color[1] = play->envCtx.adjLight1Color[2] = + sFishingStormShade; - if ((u8)D_80B7A650 > 0) { + if ((u8)sStormStrength > 0) { s32 pad; Camera* mainCam = Play_GetCamera(play, CAM_ID_MAIN); s16 i; @@ -5650,7 +5683,7 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { rot.y = 1.0f; rot.z = (Camera_GetInputDirYaw(mainCam) * -(M_PI / 0x8000)) + rot.y; - for (i = 0; i < (u8)D_80B7A650; i++) { + for (i = 0; i < (u8)sStormStrength; i++) { pos.x = Rand_CenteredFloat(700.0f) + play->view.eye.x; pos.y = (Rand_ZeroFloat(100.0f) + 150.0f) - 170.0f; pos.z = Rand_CenteredFloat(700.0f) + play->view.eye.z; @@ -5670,8 +5703,8 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &sStreamSfxPos, &sStreamSfxProjectedPos, &sProjectedW); Sfx_PlaySfxAtPos(&sStreamSfxProjectedPos, NA_SE_EV_WATER_WALL - SFX_FLAG); - - gSaveContext.minigameScore = (SQ((f32)D_80B7A678) * 0.0036f) + 0.5f; + // convert length to weight. Theoretical max of 59 lbs (127^2*.0036+.5) + gSaveContext.minigameScore = (SQ((f32)sFishLengthToWeigh) * 0.0036f) + 0.5f; if (BREG(26) != 0) { BREG(26) = 0; @@ -5696,9 +5729,9 @@ void Fishing_OwnerPostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3 OPEN_DISPS(play->state.gfxCtx, "../z_fishing.c", 9134); Matrix_MultVec3f(&sZeroVec, &sOwnerHeadPos); - if (D_80B7A688 == 1) { + if (sOwnerHair == FS_OWNER_CAPPED) { gSPDisplayList(POLY_OPA_DISP++, SEGMENTED_TO_VIRTUAL(gFishingOwnerHatDL)); - } else if (D_80B7A688 == 2) { + } else if (sOwnerHair == FS_OWNER_HAIR) { gSPDisplayList(POLY_OPA_DISP++, SEGMENTED_TO_VIRTUAL(gFishingOwnerHairDL)); } @@ -5735,10 +5768,10 @@ void Fishing_DrawOwner(Actor* thisx, PlayState* play) { Fishing_DrawGroupFishes(play); Fishing_DrawStreamSplash(play); - if (D_80B7E0A6 != 0) { - D_80B7E0A6--; + if (sFishingMusicDelay != 0) { + sFishingMusicDelay--; - if (D_80B7E0A6 == 0) { + if (sFishingMusicDelay == 0) { if (sLinkAge != LINK_AGE_CHILD) { SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_KAKARIKO_ADULT); } else { @@ -5753,17 +5786,17 @@ void Fishing_DrawOwner(Actor* thisx, PlayState* play) { } } - if ((D_80B7E0AC != 0) && D_80B7A674) { + if ((sFishingPlayingState != 0) && sIsRodVisible) { Fishing_DrawRod(play); Fishing_UpdateLinePos(sReelLinePos); Fishing_UpdateLine(play, &sRodTipPos, sReelLinePos, sReelLineRot, sReelLineUnk); Fishing_DrawLureAndLine(play, sReelLinePos, sReelLineRot); - D_80B7A6C4 = input->rel.stick_x; - D_80B7A6C8 = input->rel.stick_y; + sStickAdjXPrev = input->rel.stick_x; + sStickAdjYPrev = input->rel.stick_y; } - D_80B7A674 = true; + sIsRodVisible = true; Matrix_Translate(130.0f, 40.0f, 1300.0f, MTXMODE_NEW); Matrix_Scale(0.08f, 0.12f, 0.14f, MTXMODE_APPLY); @@ -5776,7 +5809,7 @@ void Fishing_DrawOwner(Actor* thisx, PlayState* play) { gSPDisplayList(POLY_OPA_DISP++, gFishingAquariumBottomDL); gSPDisplayList(POLY_XLU_DISP++, gFishingAquariumContainerDL); - if ((D_80B7E0AC != 0) && (D_80B7E0B6 == 2)) { + if ((sFishingPlayingState != 0) && (sLureEquipped == FS_LURE_SINKING)) { Fishing_DrawSinkingLure(play); } diff --git a/src/overlays/actors/ovl_Fishing/z_fishing.h b/src/overlays/actors/ovl_Fishing/z_fishing.h index 58483652c6..40b7f908b1 100644 --- a/src/overlays/actors/ovl_Fishing/z_fishing.h +++ b/src/overlays/actors/ovl_Fishing/z_fishing.h @@ -9,50 +9,48 @@ struct Fishing; typedef struct Fishing { /* 0x0000 */ Actor actor; /* 0x014C */ char unk_14C[0x004]; - /* 0x0150 */ u8 unk_150; - /* 0x0151 */ u8 unk_151; + /* 0x0150 */ u8 isLoach; + /* 0x0151 */ u8 lilyTimer; // if near lily and >0, lily moves. Move more if >20 /* 0x0152 */ u8 unk_152; /* 0x0154 */ s16 unk_154; /* 0x0156 */ u8 unk_156; /* 0x0157 */ u8 unk_157; - /* 0x0158 */ s16 unk_158; - /* 0x015A */ s16 unk_15A; - /* 0x015C */ s16 unk_15C; + /* 0x0158 */ s16 fishState; // negative index for loach behavior + /* 0x015A */ s16 fishStateNext; + /* 0x015C */ s16 stateAndTimer; // fish use as timer that's AND'd, owner as talking state /* 0x015E */ s16 unk_15E; - /* 0x0160 */ s16 unk_160; - /* 0x0162 */ s16 unk_162; - /* 0x0164 */ s16 unk_164; - /* 0x0166 */ s16 unk_166; - /* 0x0168 */ s16 unk_168; - /* 0x016A */ s16 unk_16A; - /* 0x016C */ s16 unk_16C; + /* 0x0160 */ s16 unk_160; // fish use as rotateX, owner as index of eye texture + /* 0x0162 */ s16 unk_162; // fish use as rotateY, owner as index of eye texture + /* 0x0164 */ s16 unk_164; // fish use as rotateZ, owner as rotation of head + /* 0x0166 */ Vec3s rotationTarget; + /* 0x016C */ s16 fishLimb23RotYDelta; /* 0x016E */ s16 unk_16E; - /* 0x0170 */ s16 unk_170; - /* 0x0172 */ s16 unk_172; - /* 0x0174 */ s16 unk_174; - /* 0x0176 */ s16 unk_176; + /* 0x0170 */ s16 fishLimbDRotZDelta; + /* 0x0172 */ s16 fishLimbEFRotYDelta; + /* 0x0174 */ s16 fishLimb89RotYDelta; + /* 0x0176 */ s16 fishLimb4RotYDelta; /* 0x0178 */ s16 unk_178; - /* 0x017A */ s16 unk_17A[4]; + /* 0x017A */ s16 timerArray[4]; /* 0x0184 */ f32 unk_184; - /* 0x0188 */ f32 unk_188; - /* 0x018C */ f32 unk_18C; - /* 0x0190 */ f32 unk_190; - /* 0x0194 */ f32 unk_194; - /* 0x0198 */ f32 unk_198; - /* 0x019C */ f32 unk_19C; - /* 0x01A0 */ s16 unk_1A0; - /* 0x01A2 */ s16 unk_1A2; - /* 0x01A4 */ s16 unk_1A4; - /* 0x01A8 */ f32 unk_1A8; - /* 0x01AC */ f32 unk_1AC; - /* 0x01B0 */ f32 unk_1B0; - /* 0x01B4 */ Vec3f unk_1B4; + /* 0x0188 */ f32 speedTarget; + /* 0x018C */ f32 fishLimbRotPhase; + /* 0x0190 */ f32 unk_190; // fishLimbRotPhaseStep target + /* 0x0194 */ f32 unk_194; // fishLimbRotPhaseMag target + /* 0x0198 */ f32 fishLimbRotPhaseStep; + /* 0x019C */ f32 fishLimbRotPhaseMag; + /* 0x01A0 */ s16 bumpTimer; // set when hitting a wall. + /* 0x01A2 */ s16 unk_1A2; // "scared" timer? + /* 0x01A4 */ s16 unk_1A4; // "scared" timer? set at same time as above + /* 0x01A8 */ f32 perception; // how easily they are drawn to the lure. + /* 0x01AC */ f32 fishLength; // fish are (x^2*.0036+.5) lbs, loach double that. + /* 0x01B0 */ f32 rotationStep; + /* 0x01B4 */ Vec3f fishTargetPos; /* 0x01C0 */ Vec3f fishMouthPos; - /* 0x01CC */ s16 unk_1CC[3]; - /* 0x01D2 */ u8 unk_1D2; - /* 0x01D3 */ u8 unk_1D3; - /* 0x01D4 */ u8 unk_1D4; - /* 0x01D5 */ u8 unk_1D5; + /* 0x01CC */ s16 loachRotYDelta[3]; // adds rotation to the loach limb 3-5. + /* 0x01D2 */ u8 bubbleTime; // spawn bubbles while >0 + /* 0x01D3 */ u8 isAquariumMessage; + /* 0x01D4 */ u8 aquariumWaitTimer; + /* 0x01D5 */ u8 keepState; // case-switch and keeping or releasing a fish /* 0x01D8 */ SkelAnime skelAnime; /* 0x021C */ LightNode* lightNode; /* 0x0220 */ LightInfo lightInfo; @@ -60,4 +58,8 @@ typedef struct Fishing { /* 0x0250 */ ColliderJntSphElement colliderElements[12]; } Fishing; // size = 0x0550 +#define EN_FISH_OWNER 1 // param for owner of pond. default if params<100 +#define EN_FISH_PARAM 100 // param base for fish in pond. +#define EN_FISH_AQUARIUM 200 // param for record fish in tank. + #endif diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index 9b6b3364a6..6c6c2f712b 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -1867,8 +1867,8 @@ void func_80832DBC(Player* this) { func_808322FC(this); this->skelAnime.jointTable[0].x = this->skelAnime.baseTransl.x; this->skelAnime.jointTable[0].z = this->skelAnime.baseTransl.z; - if (this->skelAnime.moveFlags & 8) { - if (this->skelAnime.moveFlags & 2) { + if (this->skelAnime.moveFlags & ANIM_FLAG_PLAYER_SETMOVE) { + if (this->skelAnime.moveFlags & ANIM_FLAG_UPDATE_Y) { this->skelAnime.jointTable[0].y = this->skelAnime.prevTransl.y; } } else { @@ -1905,17 +1905,20 @@ void func_80832E48(Player* this, s32 flags) { func_808322FC(this); } +#define FLAG_FUNC_80832F54_8 (1 << 8) +#define FLAG_FUNC_80832F54_9 (1 << 9) + void func_80832F54(PlayState* play, Player* this, s32 flags) { - if (flags & 0x200) { + if (flags & FLAG_FUNC_80832F54_9) { func_80832D20(this); - } else if ((flags & 0x100) || (this->skelAnime.moveFlags != 0)) { + } else if ((flags & FLAG_FUNC_80832F54_8) || (this->skelAnime.moveFlags != 0)) { func_80832CFC(this); } else { this->skelAnime.prevTransl = this->skelAnime.jointTable[0]; this->skelAnime.prevRot = this->actor.shape.rot.y; } - this->skelAnime.moveFlags = flags; + this->skelAnime.moveFlags = flags & 0xFF; Player_ZeroSpeedXZ(this); AnimationContext_DisableQueue(play); } @@ -1934,7 +1937,7 @@ void func_80833064(PlayState* play, Player* this, LinkAnimationHeader* anim, s32 } void func_8083308C(PlayState* play, Player* this, LinkAnimationHeader* anim) { - func_80833064(play, this, anim, 0x1C); + func_80833064(play, this, anim, ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE); } void func_808330AC(PlayState* play, Player* this, LinkAnimationHeader* anim, s32 flags, f32 playbackSpeed) { @@ -1951,7 +1954,7 @@ void func_80833114(PlayState* play, Player* this, LinkAnimationHeader* anim, s32 } void func_8083313C(PlayState* play, Player* this, LinkAnimationHeader* anim) { - func_80833114(play, this, anim, 0x1C); + func_80833114(play, this, anim, ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE); } void func_8083315C(PlayState* play, Player* this) { @@ -2884,8 +2887,8 @@ s32 func_80835588(Player* this, PlayState* play) { void func_808355DC(Player* this) { this->stateFlags1 |= PLAYER_STATE1_17; - if (!(this->skelAnime.moveFlags & 0x80) && (this->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT) && - (D_80853608 < 0x2000)) { + if (!(this->skelAnime.moveFlags & ANIM_FLAG_PLAYER_7) && + (this->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT) && (D_80853608 < 0x2000)) { this->yaw = this->actor.shape.rot.y = this->actor.wallYaw + 0x8000; } @@ -3263,7 +3266,9 @@ s32 func_80836670(Player* this, PlayState* play) { func_80835C58(play, this, func_80850AEC, 1); this->stateFlags3 |= PLAYER_STATE3_7; func_80832264(play, this, &gPlayerAnim_link_hook_fly_start); - func_80832F54(play, this, 0x9B); + func_80832F54(play, this, + ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | + ANIM_FLAG_PLAYER_7); func_80832224(this); this->yaw = this->actor.shape.rot.y; this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; @@ -3782,7 +3787,7 @@ void func_80837948(PlayState* play, Player* this, s32 arg2) { func_808322D0(play, this, D_80854190[arg2].unk_00); if ((arg2 != PLAYER_MWA_FLIPSLASH_START) && (arg2 != PLAYER_MWA_JUMPSLASH_START)) { - func_80832F54(play, this, 0x209); + func_80832F54(play, this, FLAG_FUNC_80832F54_9 | ANIM_FLAG_0 | ANIM_FLAG_PLAYER_SETMOVE); } this->yaw = this->actor.shape.rot.y; @@ -3827,7 +3832,7 @@ s32 func_80837B18(PlayState* play, Player* this, s32 damage) { void func_80837B60(Player* this) { this->skelAnime.prevTransl = this->skelAnime.jointTable[0]; - func_80832E48(this, 3); + func_80832E48(this, ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y); } void func_80837B9C(Player* this, PlayState* play) { @@ -4686,7 +4691,9 @@ s32 func_80839800(Player* this, PlayState* play) { } func_80832224(this); - func_80832F54(play, this, 0x28F); + func_80832F54(play, this, + FLAG_FUNC_80832F54_9 | ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_2 | + ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_PLAYER_7); // If this door is the second half of a double door (spawned as child) if (doorActor->parent != NULL) { @@ -4989,7 +4996,9 @@ s32 func_8083A6AC(Player* this, PlayState* play) { this->actor.shape.rot.y = this->yaw; this->stateFlags1 |= PLAYER_STATE1_21; - func_80832F54(play, this, 0x9F); + func_80832F54(play, this, + ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | + ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); this->unk_850 = -1; this->unk_84F = sp50; @@ -5034,7 +5043,7 @@ void func_8083AA10(Player* this, PlayState* play) { return; } - if (!(this->stateFlags3 & PLAYER_STATE3_1) && !(this->skelAnime.moveFlags & 0x80) && + if (!(this->stateFlags3 & PLAYER_STATE3_1) && !(this->skelAnime.moveFlags & ANIM_FLAG_PLAYER_7) && (func_8084411C != this->func_674) && (func_80844A44 != this->func_674)) { if ((D_80853604 == FLOOR_PROPERTY_7) || (this->meleeWeaponState != 0)) { @@ -5659,7 +5668,7 @@ s32 func_8083C2B0(Player* this, PlayState* play) { LinkAnimation_Change(play, &this->skelAnime, anim, 1.0f, frame, frame, ANIMMODE_ONCE, 0.0f); if (Player_IsChildWithHylianShield(this)) { - func_80832F54(play, this, 4); + func_80832F54(play, this, ANIM_FLAG_PLAYER_2); } Player_PlaySfx(this, NA_SE_IT_SHIELD_POSTURE); @@ -6310,7 +6319,9 @@ s32 func_8083E0FC(Player* this, PlayState* play) { Actor_MountHorse(play, this, &rideActor->actor); func_80832264(play, this, D_80854578[temp].anim); - func_80832F54(play, this, 0x9B); + func_80832F54(play, this, + ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | + ANIM_FLAG_PLAYER_7); this->actor.parent = this->rideActor; func_80832224(this); Actor_DisableLens(play); @@ -6465,7 +6476,9 @@ s32 func_8083E5A8(Player* this, PlayState* play) { if ((giEntry->itemId != ITEM_NONE) && (giEntry->gi >= 0) && (Item_CheckObtainability(giEntry->itemId) == ITEM_NONE)) { func_808322D0(play, this, this->ageProperties->unk_98); - func_80832F54(play, this, 0x28F); + func_80832F54(play, this, + FLAG_FUNC_80832F54_9 | ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_2 | + ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_PLAYER_7); chest->unk_1F4 = 1; Camera_ChangeSetting(Play_GetCamera(play, CAM_ID_MAIN), CAM_SET_SLOW_CHEST_CS); } else { @@ -6641,7 +6654,9 @@ s32 func_8083EC18(Player* this, PlayState* play, u32 interactWallFlags) { func_80832224(this); Math_Vec3f_Copy(&this->actor.prevPos, &this->actor.world.pos); func_80832264(play, this, sp30); - func_80832F54(play, this, 0x9F); + func_80832F54(play, this, + ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | + ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); return true; } @@ -6720,7 +6735,9 @@ s32 Player_TryEnteringCrawlspace(Player* this, PlayState* play, u32 interactWall func_80832224(this); this->actor.prevPos = this->actor.world.pos; func_80832264(play, this, &gPlayerAnim_link_child_tunnel_start); - func_80832F54(play, this, 0x9D); + func_80832F54(play, this, + ANIM_FLAG_0 | ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | + ANIM_FLAG_PLAYER_7); return true; } @@ -6808,7 +6825,9 @@ s32 Player_TryLeavingCrawlspace(Player* this, PlayState* play) { // Leaving a crawlspace forwards this->actor.shape.rot.y = this->actor.wallYaw + 0x8000; func_80832264(play, this, &gPlayerAnim_link_child_tunnel_end); - func_80832F54(play, this, 0x9D); + func_80832F54(play, this, + ANIM_FLAG_0 | ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | + ANIM_FLAG_PLAYER_7); OnePointCutscene_Init(play, 9601, 999, NULL, CAM_ID_MAIN); } else { // Leaving a crawlspace backwards @@ -6816,7 +6835,9 @@ s32 Player_TryLeavingCrawlspace(Player* this, PlayState* play) { LinkAnimation_Change(play, &this->skelAnime, &gPlayerAnim_link_child_tunnel_start, -1.0f, Animation_GetLastFrame(&gPlayerAnim_link_child_tunnel_start), 0.0f, ANIMMODE_ONCE, 0.0f); - func_80832F54(play, this, 0x9D); + func_80832F54(play, this, + ANIM_FLAG_0 | ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | + ANIM_FLAG_PLAYER_7); OnePointCutscene_Init(play, 9602, 999, NULL, CAM_ID_MAIN); } @@ -8226,7 +8247,7 @@ void func_80843188(Player* this, PlayState* play) { LinkAnimation_Change(play, &this->skelAnime, &gPlayerAnim_clink_normal_defense_ALL, 1.0f, Animation_GetLastFrame(&gPlayerAnim_clink_normal_defense_ALL), 0.0f, ANIMMODE_ONCE, 0.0f); - func_80832F54(play, this, 4); + func_80832F54(play, this, ANIM_FLAG_PLAYER_2); } else { if (this->itemAction < 0) { func_8008EC70(this); @@ -9525,7 +9546,9 @@ void func_808467D4(PlayState* play, Player* this) { this->yaw = this->actor.shape.rot.y = -0x8000; LinkAnimation_Change(play, &this->skelAnime, this->ageProperties->unk_A0, 2.0f / 3.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f); - func_80832F54(play, this, 0x28F); + func_80832F54(play, this, + FLAG_FUNC_80832F54_9 | ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_2 | + ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_PLAYER_7); if (LINK_IS_ADULT) { func_80846720(play, this, 0); } @@ -9534,7 +9557,8 @@ void func_808467D4(PlayState* play, Player* this) { void func_808468A8(PlayState* play, Player* this) { func_80835C58(play, this, func_8084F9A0, 0); - func_80832F54(play, this, 0x9B); + func_80832F54(play, this, + ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); } void func_808468E8(PlayState* play, Player* this) { @@ -10579,7 +10603,9 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { func_8083A360(play, this); this->stateFlags1 |= PLAYER_STATE1_23; func_80832264(play, this, &gPlayerAnim_link_uma_wait_1); - func_80832F54(play, this, 0x9B); + func_80832F54(play, this, + ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | + ANIM_FLAG_PLAYER_7); this->unk_850 = 99; } @@ -10604,7 +10630,7 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { func_8084FF7C(this); } - if (!(this->skelAnime.moveFlags & 0x80)) { + if (!(this->skelAnime.moveFlags & ANIM_FLAG_PLAYER_7)) { if (((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (D_808535E4 == FLOOR_TYPE_5) && (this->currentBoots != PLAYER_BOOTS_IRON)) || ((this->currentBoots == PLAYER_BOOTS_HOVER) && @@ -10787,9 +10813,10 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { Player_UpdateCamAndSeqModes(play, this); - if (this->skelAnime.moveFlags & 8) { - AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, - (this->skelAnime.moveFlags & 4) ? 1.0f : this->ageProperties->unk_08); + if (this->skelAnime.moveFlags & ANIM_FLAG_PLAYER_SETMOVE) { + AnimationContext_SetMoveActor( + play, &this->actor, &this->skelAnime, + (this->skelAnime.moveFlags & ANIM_FLAG_PLAYER_2) ? 1.0f : this->ageProperties->unk_08); } func_808368EC(this, play); @@ -11579,7 +11606,7 @@ void func_8084BDFC(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_6; if (LinkAnimation_Update(play, &this->skelAnime)) { - func_80832E48(this, 1); + func_80832E48(this, ANIM_FLAG_0); func_8083C0E8(this, play); return; } @@ -13936,7 +13963,8 @@ void func_808510D4(PlayState* play, Player* this, void* anim) { } void func_808510F4(PlayState* play, Player* this, void* anim) { - func_8083303C(play, this, anim, 0x9C); + func_8083303C(play, this, anim, + ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); } void func_80851114(PlayState* play, Player* this, void* anim) { @@ -13944,7 +13972,8 @@ void func_80851114(PlayState* play, Player* this, void* anim) { } void func_80851134(PlayState* play, Player* this, void* anim) { - func_808330EC(play, this, anim, 0x9C); + func_808330EC(play, this, anim, + ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); } void func_80851154(PlayState* play, Player* this, void* anim) { @@ -14189,7 +14218,9 @@ void func_808519EC(PlayState* play, Player* this, CsCmdActorCue* cue) { Math_Vec3f_Copy(&this->actor.world.pos, &D_80855198); this->actor.shape.rot.y = -0x8000; func_808322D0(play, this, this->ageProperties->unk_9C); - func_80832F54(play, this, 0x28F); + func_80832F54(play, this, + FLAG_FUNC_80832F54_9 | ANIM_FLAG_0 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_2 | + ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_PLAYER_7); } static struct_808551A4 D_808551A4[] = { @@ -14299,17 +14330,20 @@ void func_80851E28(PlayState* play, Player* this, CsCmdActorCue* cue) { } void func_80851E64(PlayState* play, Player* this, CsCmdActorCue* cue) { - func_80833064(play, this, &gPlayerAnim_link_swimer_swim_get, 0x98); + func_80833064(play, this, &gPlayerAnim_link_swimer_swim_get, + ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); } void func_80851E90(PlayState* play, Player* this, CsCmdActorCue* cue) { - func_8083303C(play, this, &gPlayerAnim_clink_op3_negaeri, 0x9C); + func_8083303C(play, this, &gPlayerAnim_clink_op3_negaeri, + ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); func_80832698(this, NA_SE_VO_LI_GROAN); } void func_80851ECC(PlayState* play, Player* this, CsCmdActorCue* cue) { if (LinkAnimation_Update(play, &this->skelAnime)) { - func_808330EC(play, this, &gPlayerAnim_clink_op3_wait2, 0x9C); + func_808330EC(play, this, &gPlayerAnim_clink_op3_wait2, + ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); } } @@ -14335,7 +14369,8 @@ static struct_80832924 D_808551BC[] = { void func_80851FB0(PlayState* play, Player* this, CsCmdActorCue* cue) { if (LinkAnimation_Update(play, &this->skelAnime)) { - func_808330EC(play, this, &gPlayerAnim_clink_op3_wait3, 0x9C); + func_808330EC(play, this, &gPlayerAnim_clink_op3_wait3, + ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); this->unk_850 = 1; } else if (this->unk_850 == 0) { func_80832924(this, D_808551BC); @@ -14358,7 +14393,8 @@ void func_80852048(PlayState* play, Player* this, CsCmdActorCue* cue) { } void func_80852080(PlayState* play, Player* this, CsCmdActorCue* cue) { - func_80833064(play, this, &gPlayerAnim_clink_demo_futtobi, 0x9D); + func_80833064(play, this, &gPlayerAnim_clink_demo_futtobi, + ANIM_FLAG_0 | ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); func_80832698(this, NA_SE_VO_LI_FALL_L); } @@ -14406,7 +14442,7 @@ void func_80852234(PlayState* play, Player* this, CsCmdActorCue* cue) { } void func_8085225C(PlayState* play, Player* this, CsCmdActorCue* cue) { - func_80832F54(play, this, 0x98); + func_80832F54(play, this, ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE | ANIM_FLAG_PLAYER_7); } void func_80852280(PlayState* play, Player* this, CsCmdActorCue* cue) { @@ -14644,7 +14680,7 @@ void func_80852B4C(PlayState* play, Player* this, CsCmdActorCue* cue, struct_808 arg3->func(play, this, cue); } - if ((D_80858AA0 & 4) && !(this->skelAnime.moveFlags & 4)) { + if ((D_80858AA0 & ANIM_FLAG_PLAYER_2) && !(this->skelAnime.moveFlags & ANIM_FLAG_PLAYER_2)) { this->skelAnime.morphTable[0].y /= this->ageProperties->unk_08; D_80858AA0 = 0; } @@ -14831,7 +14867,7 @@ void func_80853148(PlayState* play, Actor* actor) { } if (this->skelAnime.animation == &gPlayerAnim_link_normal_backspace) { - func_80832F54(play, this, 0x19); + func_80832F54(play, this, ANIM_FLAG_0 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_NO_MOVE); } func_80832224(this); diff --git a/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.c b/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.c index 3261f10f66..22b97ce748 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.c +++ b/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.c @@ -7,15 +7,15 @@ #include "z_eff_ss_blast.h" #include "assets/objects/gameplay_keep/gameplay_keep.h" -#define rPrimColorR regs[0] -#define rPrimColorG regs[1] -#define rPrimColorB regs[2] -#define rPrimColorA regs[3] -#define rEnvColorR regs[4] -#define rEnvColorG regs[5] -#define rEnvColorB regs[6] -#define rEnvColorA regs[7] -#define rAlphaTarget regs[8] +#define rInnerColorR regs[0] +#define rInnerColorG regs[1] +#define rInnerColorB regs[2] +#define rInnerColorA regs[3] +#define rOuterColorR regs[4] +#define rOuterColorG regs[5] +#define rOuterColorB regs[6] +#define rOuterColorA regs[7] +#define rAlphaStep regs[8] #define rScale regs[9] #define rScaleStep regs[10] #define rScaleStepDecay regs[11] @@ -40,15 +40,15 @@ u32 EffectSsBlast_Init(PlayState* play, u32 index, EffectSs* this, void* initPar this->life = initParams->life; this->draw = EffectSsBlast_Draw; this->update = EffectSsBlast_Update; - this->rPrimColorR = initParams->primColor.r; - this->rPrimColorG = initParams->primColor.g; - this->rPrimColorB = initParams->primColor.b; - this->rPrimColorA = initParams->primColor.a; - this->rEnvColorR = initParams->envColor.r; - this->rEnvColorG = initParams->envColor.g; - this->rEnvColorB = initParams->envColor.b; - this->rEnvColorA = initParams->envColor.a; - this->rAlphaTarget = initParams->primColor.a / initParams->life; + this->rInnerColorR = initParams->innerColor.r; + this->rInnerColorG = initParams->innerColor.g; + this->rInnerColorB = initParams->innerColor.b; + this->rInnerColorA = initParams->innerColor.a; + this->rOuterColorR = initParams->outerColor.r; + this->rOuterColorG = initParams->outerColor.g; + this->rOuterColorB = initParams->outerColor.b; + this->rOuterColorA = initParams->outerColor.a; + this->rAlphaStep = initParams->innerColor.a / initParams->life; this->rScale = initParams->scale; this->rScaleStep = initParams->scaleStep; this->rScaleStepDecay = initParams->scaleStepDecay; @@ -59,18 +59,19 @@ void EffectSsBlast_Draw(PlayState* play, u32 index, EffectSs* this) { GraphicsContext* gfxCtx = play->state.gfxCtx; MtxF mf; s32 pad; - f32 radius; + f32 scale; OPEN_DISPS(gfxCtx, "../z_eff_ss_blast.c", 170); - radius = this->rScale * 0.0025f; + scale = this->rScale * (1 / 400.0f); Gfx_SetupDL_25Xlu(play->state.gfxCtx); - gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rEnvColorA); + gDPSetEnvColor(POLY_XLU_DISP++, this->rOuterColorR, this->rOuterColorG, this->rOuterColorB, this->rOuterColorA); func_800BFCB8(play, &mf, &this->pos); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, this->rPrimColorA); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rInnerColorR, this->rInnerColorG, this->rInnerColorB, + this->rInnerColorA); Matrix_Put(&mf); - Matrix_Scale(radius, radius, radius, MTXMODE_APPLY); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_ss_blast.c", 199), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, this->gfx); @@ -79,9 +80,9 @@ void EffectSsBlast_Draw(PlayState* play, u32 index, EffectSs* this) { } void EffectSsBlast_Update(PlayState* play, u32 index, EffectSs* this) { - Math_StepToS(&this->rPrimColorA, 0, this->rAlphaTarget); - this->rScale += this->rScaleStep; + Math_StepToS(&this->rInnerColorA, 0, this->rAlphaStep); + this->rScale += this->rScaleStep; if (this->rScaleStep != 0) { this->rScaleStep -= this->rScaleStepDecay; } diff --git a/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.h b/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.h index a5d4c2e0df..465997e758 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.h +++ b/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.h @@ -8,8 +8,8 @@ typedef struct { /* 0x00 */ Vec3f pos; /* 0x0C */ Vec3f velocity; /* 0x18 */ Vec3f accel; - /* 0x24 */ Color_RGBA8 primColor; - /* 0x28 */ Color_RGBA8 envColor; + /* 0x24 */ Color_RGBA8 innerColor; + /* 0x28 */ Color_RGBA8 outerColor; /* 0x2C */ s16 scale; /* 0x2E */ s16 scaleStep; /* 0x30 */ s16 scaleStepDecay; diff --git a/src/overlays/effects/ovl_Effect_Ss_Bomb/z_eff_ss_bomb.c b/src/overlays/effects/ovl_Effect_Ss_Bomb/z_eff_ss_bomb.c index e64c991d21..aed5572b35 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Bomb/z_eff_ss_bomb.c +++ b/src/overlays/effects/ovl_Effect_Ss_Bomb/z_eff_ss_bomb.c @@ -7,8 +7,10 @@ #include "z_eff_ss_bomb.h" #include "assets/objects/gameplay_keep/gameplay_keep.h" +#define EFFSSBOMB_LIFESPAN 20 + #define rScale regs[0] -#define rTexIdx regs[1] +#define rTexIndex regs[1] u32 EffectSsBomb_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); void EffectSsBomb_Draw(PlayState* play, u32 index, EffectSs* this); @@ -26,31 +28,32 @@ u32 EffectSsBomb_Init(PlayState* play, u32 index, EffectSs* this, void* initPara Math_Vec3f_Copy(&this->velocity, &initParams->velocity); Math_Vec3f_Copy(&this->accel, &initParams->accel); this->gfx = SEGMENTED_TO_VIRTUAL(gEffBombExplosion1DL); - this->life = 20; + this->life = EFFSSBOMB_LIFESPAN; this->draw = EffectSsBomb_Draw; this->update = EffectSsBomb_Update; this->rScale = 100; - this->rTexIdx = 0; + this->rTexIndex = 0; return 1; } +static void* sExplosionTextures[] = { + gEffBombExplosion1Tex, + gEffBombExplosion2Tex, + gEffBombExplosion3Tex, + gEffBombExplosion4Tex, +}; + void EffectSsBomb_Draw(PlayState* play, u32 index, EffectSs* this) { - static void* explosionTextures[] = { - gEffBombExplosion1Tex, - gEffBombExplosion2Tex, - gEffBombExplosion3Tex, - gEffBombExplosion4Tex, - }; GraphicsContext* gfxCtx = play->state.gfxCtx; MtxF mfTrans; MtxF mfScale; MtxF mfResult; - MtxF mfTrans11DA0; + MtxF mfTransBillboard; Mtx* mtx; s32 pad; f32 scale; - s16 color; + s16 intensity; if (1) {} @@ -60,8 +63,8 @@ void EffectSsBomb_Draw(PlayState* play, u32 index, EffectSs* this) { SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); SkinMatrix_SetScale(&mfScale, scale, scale, 1.0f); - SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTrans11DA0); - SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfScale, &mfResult); + SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTransBillboard); + SkinMatrix_MtxFMtxFMult(&mfTransBillboard, &mfScale, &mfResult); gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -69,12 +72,13 @@ void EffectSsBomb_Draw(PlayState* play, u32 index, EffectSs* this) { if (mtx != NULL) { gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(explosionTextures[this->rTexIdx])); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sExplosionTextures[this->rTexIndex])); gDPPipeSync(POLY_XLU_DISP++); Gfx_SetupDL_61Xlu(gfxCtx); - color = this->life * 12.75f; - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, color, color, color, color); + intensity = this->life * ((f32)255 / EFFSSBOMB_LIFESPAN); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, intensity, intensity, intensity, intensity); gDPPipeSync(POLY_XLU_DISP++); + //! @bug env color is not set but used in gEffBombExplosion1DL gSPDisplayList(POLY_XLU_DISP++, this->gfx); gDPPipeSync(POLY_XLU_DISP++); } @@ -83,11 +87,11 @@ void EffectSsBomb_Draw(PlayState* play, u32 index, EffectSs* this) { } void EffectSsBomb_Update(PlayState* play, u32 index, EffectSs* this) { - if ((this->life < 21) && (this->life > 16)) { - this->rTexIdx = (20 - this->life); + if ((this->life <= EFFSSBOMB_LIFESPAN) && (this->life > (EFFSSBOMB_LIFESPAN - ARRAY_COUNT(sExplosionTextures)))) { + this->rTexIndex = (EFFSSBOMB_LIFESPAN - this->life); } else { this->rScale += 0; - this->rTexIdx = 3; + this->rTexIndex = ARRAY_COUNT(sExplosionTextures) - 1; } this->accel.x = ((Rand_ZeroOne() * 0.4f) - 0.2f); diff --git a/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.c b/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.c index 03f5a02f94..bff52614a6 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.c +++ b/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.c @@ -8,7 +8,7 @@ #include "assets/objects/gameplay_keep/gameplay_keep.h" #define rScale regs[0] -#define rTexIdx regs[1] +#define rTexIndex regs[1] #define rPrimColorR regs[2] #define rPrimColorG regs[3] #define rPrimColorB regs[4] @@ -68,7 +68,7 @@ void EffectSsBomb2_DrawFade(PlayState* play, u32 index, EffectSs* this) { MtxF mfTrans; MtxF mfScale; MtxF mfResult; - MtxF mfTrans11DA0; + MtxF mfTransBillboard; Mtx* mtx; s32 pad; f32 scale; @@ -78,8 +78,8 @@ void EffectSsBomb2_DrawFade(PlayState* play, u32 index, EffectSs* this) { scale = this->rScale * 0.01f; SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); SkinMatrix_SetScale(&mfScale, scale, scale, 1.0f); - SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTrans11DA0); - SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfScale, &mfResult); + SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTransBillboard); + SkinMatrix_MtxFMtxFMult(&mfTransBillboard, &mfScale, &mfResult); mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); @@ -89,7 +89,7 @@ void EffectSsBomb2_DrawFade(PlayState* play, u32 index, EffectSs* this) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, this->rPrimColorA); gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, 0); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(textures[this->rTexIdx])); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(textures[this->rTexIndex])); gSPDisplayList(POLY_XLU_DISP++, this->gfx); } @@ -108,7 +108,7 @@ void EffectSsBomb2_DrawLayered(PlayState* play, u32 index, EffectSs* this) { MtxF mfTrans; MtxF mfScale; MtxF mfResult; - MtxF mfTrans11DA0; + MtxF mfTransBillboard; MtxF mtx2F; Mtx* mtx2; Mtx* mtx; @@ -124,8 +124,8 @@ void EffectSsBomb2_DrawLayered(PlayState* play, u32 index, EffectSs* this) { scale = this->rScale * 0.01f; SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); SkinMatrix_SetScale(&mfScale, scale, scale, 1.0f); - SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTrans11DA0); - SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfScale, &mfResult); + SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTransBillboard); + SkinMatrix_MtxFMtxFMult(&mfTransBillboard, &mfScale, &mfResult); mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); @@ -139,7 +139,7 @@ void EffectSsBomb2_DrawLayered(PlayState* play, u32 index, EffectSs* this) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, this->rPrimColorA); gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, 0); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(textures[this->rTexIdx])); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(textures[this->rTexIndex])); gSPDisplayList(POLY_XLU_DISP++, gEffBombExplosion2DL); gSPDisplayList(POLY_XLU_DISP++, gEffBombExplosion3DL); @@ -167,7 +167,7 @@ void EffectSsBomb2_DrawLayered(PlayState* play, u32 index, EffectSs* this) { void EffectSsBomb2_Update(PlayState* play, u32 index, EffectSs* this) { s32 divisor; - this->rTexIdx = (23 - this->life) / 3; + this->rTexIndex = (23 - this->life) / 3; this->rScale += this->rScaleStep; if (this->rScaleStep == 30) { @@ -178,21 +178,21 @@ void EffectSsBomb2_Update(PlayState* play, u32 index, EffectSs* this) { if ((this->life < 23) && (this->life > 13)) { divisor = this->life - 13; - this->rPrimColorR = func_80027DD4(this->rPrimColorR, 255, divisor); - this->rPrimColorG = func_80027DD4(this->rPrimColorG, 255, divisor); - this->rPrimColorB = func_80027DD4(this->rPrimColorB, 150, divisor); - this->rPrimColorA = func_80027DD4(this->rPrimColorA, 255, divisor); - this->rEnvColorR = func_80027DD4(this->rEnvColorR, 150, divisor); - this->rEnvColorG = func_80027DD4(this->rEnvColorG, 0, divisor); - this->rEnvColorB = func_80027DD4(this->rEnvColorB, 0, divisor); + this->rPrimColorR = EffectSs_LerpInv(this->rPrimColorR, 255, divisor); + this->rPrimColorG = EffectSs_LerpInv(this->rPrimColorG, 255, divisor); + this->rPrimColorB = EffectSs_LerpInv(this->rPrimColorB, 150, divisor); + this->rPrimColorA = EffectSs_LerpInv(this->rPrimColorA, 255, divisor); + this->rEnvColorR = EffectSs_LerpInv(this->rEnvColorR, 150, divisor); + this->rEnvColorG = EffectSs_LerpInv(this->rEnvColorG, 0, divisor); + this->rEnvColorB = EffectSs_LerpInv(this->rEnvColorB, 0, divisor); } else if ((this->life < 14) && (this->life > -1)) { divisor = this->life + 1; - this->rPrimColorR = func_80027DD4(this->rPrimColorR, 50, divisor); - this->rPrimColorG = func_80027DD4(this->rPrimColorG, 50, divisor); - this->rPrimColorB = func_80027DD4(this->rPrimColorB, 50, divisor); - this->rPrimColorA = func_80027DD4(this->rPrimColorA, 150, divisor); - this->rEnvColorR = func_80027DD4(this->rEnvColorR, 10, divisor); - this->rEnvColorG = func_80027DD4(this->rEnvColorG, 10, divisor); - this->rEnvColorB = func_80027DD4(this->rEnvColorB, 10, divisor); + this->rPrimColorR = EffectSs_LerpInv(this->rPrimColorR, 50, divisor); + this->rPrimColorG = EffectSs_LerpInv(this->rPrimColorG, 50, divisor); + this->rPrimColorB = EffectSs_LerpInv(this->rPrimColorB, 50, divisor); + this->rPrimColorA = EffectSs_LerpInv(this->rPrimColorA, 150, divisor); + this->rEnvColorR = EffectSs_LerpInv(this->rEnvColorR, 10, divisor); + this->rEnvColorG = EffectSs_LerpInv(this->rEnvColorG, 10, divisor); + this->rEnvColorB = EffectSs_LerpInv(this->rEnvColorB, 10, divisor); } } diff --git a/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.c b/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.c index 9a5127e8af..b52bdfb796 100644 --- a/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.c +++ b/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.c @@ -8,7 +8,7 @@ #include "assets/objects/object_dodongo/object_dodongo.h" #define rScale regs[0] -#define rTexIdx regs[1] +#define rTexIndex regs[1] #define rPrimColorR regs[2] #define rPrimColorG regs[3] #define rPrimColorB regs[4] @@ -48,7 +48,7 @@ u32 EffectSsDFire_Init(PlayState* play, u32 index, EffectSs* this, void* initPar this->rObjBankIdx = objBankIndex; this->draw = EffectSsDFire_Draw; this->update = EffectSsDFire_Update; - this->rTexIdx = ((s16)(play->state.frames % 4) ^ 3); + this->rTexIndex = ((s16)(play->state.frames % 4) ^ 3); this->rPrimColorR = 255; this->rPrimColorG = 255; this->rPrimColorB = 50; @@ -68,7 +68,7 @@ void EffectSsDFire_Draw(PlayState* play, u32 index, EffectSs* this) { MtxF mfTrans; MtxF mfScale; MtxF mfResult; - MtxF mfTrans11DA0; + MtxF mfTransBillboard; s32 pad; void* object; Mtx* mtx; @@ -84,8 +84,8 @@ void EffectSsDFire_Draw(PlayState* play, u32 index, EffectSs* this) { scale = this->rScale / 100.0f; SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); SkinMatrix_SetScale(&mfScale, scale, scale, 1.0f); - SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTrans11DA0); - SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfScale, &mfResult); + SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTransBillboard); + SkinMatrix_MtxFMtxFMult(&mfTransBillboard, &mfScale, &mfResult); mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); @@ -96,7 +96,7 @@ void EffectSsDFire_Draw(PlayState* play, u32 index, EffectSs* this) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, this->rPrimColorA); gSegments[6] = VIRTUAL_TO_PHYSICAL(object); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sTextures[this->rTexIdx])); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sTextures[this->rTexIndex])); gSPDisplayList(POLY_XLU_DISP++, this->gfx); } } @@ -105,8 +105,8 @@ void EffectSsDFire_Draw(PlayState* play, u32 index, EffectSs* this) { } void EffectSsDFire_Update(PlayState* play, u32 index, EffectSs* this) { - this->rTexIdx++; - this->rTexIdx &= 3; + this->rTexIndex++; + this->rTexIndex &= 3; this->rScale += this->rScaleStep; if (this->rFadeDelay >= this->life) { diff --git a/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.c b/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.c index 7610d1c074..1910c5914b 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.c +++ b/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.c @@ -15,7 +15,7 @@ #define rEnvColorG regs[5] #define rEnvColorB regs[6] #define rEnvColorA regs[7] -#define rTexIdx regs[8] // this reg is also used to set specific colors in the fire update function +#define rTexIndex regs[8] // this reg is also used to set specific colors in the fire update function #define rScale regs[9] #define rScaleStep regs[10] #define rDrawFlags regs[11] @@ -67,7 +67,7 @@ u32 EffectSsDust_Init(PlayState* play, u32 index, EffectSs* this, void* initPara this->rPrimColorA = initParams->primColor.a; this->rEnvColorA = initParams->envColor.a; - this->rTexIdx = 0; + this->rTexIndex = 0; this->rScale = initParams->scale; this->rScaleStep = initParams->scaleStep; this->rLifespan = initParams->life; @@ -84,7 +84,7 @@ void EffectSsDust_Draw(PlayState* play, u32 index, EffectSs* this) { MtxF mfTrans; MtxF mfScale; MtxF mfResult; - MtxF mfTrans11DA0; + MtxF mfTransBillboard; s32 pad; Mtx* mtx; f32 scale; @@ -94,8 +94,8 @@ void EffectSsDust_Draw(PlayState* play, u32 index, EffectSs* this) { scale = this->rScale * 0.0025f; SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); SkinMatrix_SetScale(&mfScale, scale, scale, 1.0f); - SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTrans11DA0); - SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfScale, &mfResult); + SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTransBillboard); + SkinMatrix_MtxFMtxFMult(&mfTransBillboard, &mfScale, &mfResult); gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); @@ -103,7 +103,7 @@ void EffectSsDust_Draw(PlayState* play, u32 index, EffectSs* this) { if (mtx != NULL) { gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPPipeSync(POLY_XLU_DISP++); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(dustTextures[this->rTexIdx])); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(dustTextures[this->rTexIndex])); POLY_XLU_DISP = Gfx_SetupDL(POLY_XLU_DISP, SETUPDL_0); gDPPipeSync(POLY_XLU_DISP++); @@ -134,12 +134,12 @@ void EffectSsDust_Update(PlayState* play, u32 index, EffectSs* this) { if ((this->life <= this->rLifespan) && (this->life >= (this->rLifespan - 7))) { if (this->rLifespan >= 5) { - this->rTexIdx = this->rLifespan - this->life; + this->rTexIndex = this->rLifespan - this->life; } else { - this->rTexIdx = ((this->rLifespan - this->life) * (8 / this->rLifespan)); + this->rTexIndex = (this->rLifespan - this->life) * (8 / this->rLifespan); } } else { - this->rTexIdx = 7; + this->rTexIndex = 7; } this->rScale += this->rScaleStep; @@ -150,7 +150,7 @@ void EffectSsDust_UpdateFire(PlayState* play, u32 index, EffectSs* this) { this->accel.x = (Rand_ZeroOne() * 0.4f) - 0.2f; this->accel.z = (Rand_ZeroOne() * 0.4f) - 0.2f; - switch (this->rTexIdx) { + switch (this->rTexIndex) { case 0: this->rPrimColorR = 255; this->rPrimColorG = 150; @@ -181,8 +181,8 @@ void EffectSsDust_UpdateFire(PlayState* play, u32 index, EffectSs* this) { break; } - if (this->rTexIdx < 7) { - this->rTexIdx++; + if (this->rTexIndex < 7) { + this->rTexIndex++; } this->rScale += this->rScaleStep; diff --git a/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.c b/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.c index 464f31e588..29451fdb4d 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.c +++ b/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.c @@ -25,15 +25,16 @@ EffectSsInit Effect_Ss_Fhg_Flash_InitVars = { EffectSsFhgFlash_Init, }; -static UNK_TYPE D_809A5178[258]; -static Gfx D_809A5100[15]; +// Should eventually come from assets/overlays/ovl_Effect_Ss_Fhg_Flash/ovl_Effect_Ss_Fhg_Flash.h +//! TODO: investigate having ZAPD forward declare static variables +static Gfx sShockDL[15]; u32 EffectSsFhgFlash_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { EffectSsFhgFlashInitParams* initParams = (EffectSsFhgFlashInitParams*)initParamsx; s32 pad; s32 objBankIdx; Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - Vec3f sp34 = { 0.0f, -1000.0f, 0.0f }; + Vec3f farAwayVec = { 0.0f, -1000.0f, 0.0f }; uintptr_t oldSeg6; if (initParams->type == FHGFLASH_LIGHTBALL) { @@ -69,17 +70,17 @@ u32 EffectSsFhgFlash_Init(PlayState* play, u32 index, EffectSs* this, void* init this->rParam = initParams->param; if (initParams->param != FHGFLASH_SHOCK_NO_ACTOR) { - this->pos = sp34; - this->gfx = SEGMENTED_TO_VIRTUAL(D_809A5100); + this->pos = farAwayVec; // Set the initial position to where the effect cannot be seen + this->gfx = SEGMENTED_TO_VIRTUAL(sShockDL); } else { this->pos = initParams->pos; - this->gfx = SEGMENTED_TO_VIRTUAL(D_809A5100); + this->gfx = SEGMENTED_TO_VIRTUAL(sShockDL); } } return 1; } -static Color_RGB8 sColors[] = { +static Color_RGB8 sLightBallColors[] = { { 165, 255, 61 }, { 0, 255, 255 }, { 255, 40, 0 }, { 255, 255, 0 }, { 0, 0, 255 }, { 255, 0, 255 }, { 255, 150, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, }; @@ -101,10 +102,11 @@ void EffectSsFhgFlash_DrawLightBall(PlayState* play, u32 index, EffectSs* this) gSPSegment(POLY_XLU_DISP++, 0x06, object); Gfx_SetupDL_25Xlu(play->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, this->rAlpha); - gDPSetEnvColor(POLY_XLU_DISP++, sColors[this->rParam].r, sColors[this->rParam].g, sColors[this->rParam].b, 0); + gDPSetEnvColor(POLY_XLU_DISP++, sLightBallColors[this->rParam].r, sLightBallColors[this->rParam].g, + sLightBallColors[this->rParam].b, 0); gDPPipeSync(POLY_XLU_DISP++); Matrix_ReplaceRotation(&play->billboardMtxF); - Matrix_RotateZ((this->rXZRot / 32768.0f) * 3.1416f, MTXMODE_APPLY); + Matrix_RotateZ((this->rXZRot / (f32)0x8000) * 3.1416f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_fhg_flash.c", 326), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, this->gfx); @@ -126,7 +128,7 @@ void EffectSsFhgFlash_DrawShock(PlayState* play, u32 index, EffectSs* this) { if (this->rParam != FHGFLASH_SHOCK_NO_ACTOR) { Gfx_SetupDL_44Xlu(play->state.gfxCtx); - Matrix_RotateX((this->rXZRot / 32768.0f) * 1.1416f, MTXMODE_APPLY); + Matrix_RotateX((this->rXZRot / (f32)0x8000) * 1.1416f, MTXMODE_APPLY); gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_AA_ZB_XLU_DECAL2); } else { Gfx_SetupDL_25Xlu(play->state.gfxCtx); @@ -137,7 +139,7 @@ void EffectSsFhgFlash_DrawShock(PlayState* play, u32 index, EffectSs* this) { gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, this->rAlpha); gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 155, 0); - Matrix_RotateZ((this->rXZRot / 32768.0f) * 3.1416f, MTXMODE_APPLY); + Matrix_RotateZ((this->rXZRot / (f32)0x8000) * 3.1416f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_fhg_flash.c", 395), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, this->gfx); @@ -172,10 +174,10 @@ void EffectSsFhgFlash_UpdateShock(PlayState* play, u32 index, EffectSs* this) { s16 randBodyPart; Player* player; BossGanondrof* phantomGanon; - s16 rand; + s16 rotStep; - rand = (Rand_ZeroOne() * 20000.0f); - this->rXZRot = (this->rXZRot + rand) + 0x4000; + rotStep = Rand_ZeroOne() * 20000.0f; + this->rXZRot += rotStep + 0x4000; if (this->rParam == FHGFLASH_SHOCK_PLAYER) { player = GET_PLAYER(play); @@ -201,55 +203,4 @@ void EffectSsFhgFlash_UpdateShock(PlayState* play, u32 index, EffectSs* this) { } } -static Vtx D_809A50C0[4] = { - VTX(-10, -10, 0, 0, 1024, 0xFF, 0xFF, 0xFF, 0xFF), - VTX(10, -10, 0, 1024, 1024, 0xFF, 0xFF, 0xFF, 0xFF), - VTX(10, 10, 0, 1024, 0, 0xFF, 0xFF, 0xFF, 0xFF), - VTX(-10, 10, 0, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF), -}; - -static Gfx D_809A5100[15] = { - gsDPPipeSync(), - gsDPSetTextureLUT(G_TT_NONE), - gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), - gsDPLoadTextureBlock(D_809A5178, G_IM_FMT_I, G_IM_SIZ_8b, 32, 32, 0, G_TX_MIRROR | G_TX_WRAP, - G_TX_MIRROR | G_TX_WRAP, 5, 5, G_TX_NOLOD, G_TX_NOLOD), - gsDPSetCombineLERP(PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, COMBINED, 0, 0, 0, - COMBINED), - gsSPClearGeometryMode(G_CULL_BACK | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR), - gsSPVertex(D_809A50C0, 4, 0), - gsSP2Triangles(0, 1, 2, 0, 0, 2, 3, 0), - gsSPEndDisplayList(), -}; - -static UNK_TYPE D_809A5178[258] = { - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x005B3000, 0x00000000, 0x00000000, - 0x00000000, 0x000B0000, 0x07000000, 0x00000000, 0x00000000, 0x005BB64B, 0x3A000000, 0x00000000, 0x00000000, - 0x005B0000, 0x00000000, 0x00000000, 0x00000000, 0x001E00B6, 0xFF5B0000, 0x00000000, 0x00000000, 0x00251F0C, - 0x07000000, 0x0A000000, 0x00000000, 0x00000000, 0xB6FF0000, 0x00000000, 0x00000000, 0x00255B00, 0x071F1E14, - 0x0A000000, 0x00000000, 0x00000000, 0x00457350, 0x00000000, 0x00000000, 0x00295B8C, 0x5B5B0000, 0x00000000, - 0x00000000, 0x00000000, 0x00455C39, 0x0F000000, 0x00000000, 0x0000A1FF, 0x5B000000, 0x00000000, 0x00000000, - 0x00000000, 0x005B5B00, 0x00000000, 0x00000000, 0x005B311C, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x5BB60000, 0x00000000, 0x00000000, 0x5BB63100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFB60000, - 0x00000000, 0x00000046, 0xEA310000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0072B646, 0x00000000, - 0x0000B6A1, 0x81000000, 0x00000000, 0x00000000, 0x00000000, 0x000C0000, 0x00172E19, 0xBDAB5D41, 0x366BEAEA, - 0x81000000, 0x00000000, 0x00000000, 0x00000000, 0x06000000, 0x00000074, 0xFFFF0500, 0x0A2342B6, 0xFF000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x005B0000, 0x03030100, 0x00FF0700, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00020503, 0x00000000, 0x00466200, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00076200, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00002962, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00003EA1, 0x62000000, 0x00000000, 0x00000000, 0x0000002E, 0xB6350000, - 0x00000000, 0x00000000, 0x000000EA, 0x46000000, 0x00000000, 0x00000000, 0x00002EFF, 0xFF5A0000, 0x00000000, - 0x00000000, 0x000000FF, 0xFF001700, 0x00000000, 0x00000000, 0x01015BFF, 0xA1A10000, 0x00000000, 0x00000000, - 0x00030046, 0x97732100, 0x00000000, 0x00000000, 0x040CB65E, 0x4A5B4600, 0x00000000, 0x00000003, 0x0C0E8C46, - 0x1C035C00, 0x00000000, 0x00000017, 0x134F5B00, 0x00000046, 0x46000000, 0x00000000, 0x34D20000, 0x0401005B, - 0x00000000, 0x00000000, 0x5BB60000, 0x00000000, 0x30FCB600, 0x0000A1E7, 0x00000001, 0x0100141E, 0x5B000000, - 0x00000000, 0x00000000, 0x00000000, 0x0000A1FF, 0x5B46FF00, 0x00000100, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x000000FC, 0xFFA13100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0xB6000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 -}; +#include "assets/overlays/ovl_Effect_Ss_Fhg_Flash/ovl_Effect_Ss_Fhg_Flash.c" diff --git a/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.h b/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.h index 4a56d0b9f8..0d2d9616ef 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.h +++ b/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.h @@ -32,11 +32,9 @@ typedef enum { } FhgFlashLightBallParam; typedef enum { - /* 0x00 */ FHGFLASH_SHOCK_NO_ACTOR, - /* 0x01 */ FHGFLASH_SHOCK_PLAYER, - /* 0x02 */ FHGFLASH_SHOCK_PG + /* 0x00 */ FHGFLASH_SHOCK_NO_ACTOR, // Don't attach to any actor. Stays at a fixed position. + /* 0x01 */ FHGFLASH_SHOCK_PLAYER, // Move to a random Player body part every frame. + /* 0x02 */ FHGFLASH_SHOCK_PG // Move to a random Phantom Ganon body part every frame. } FhgFlashLightningParam; - - #endif diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Magma2/z_eff_ss_g_magma2.c b/src/overlays/effects/ovl_Effect_Ss_G_Magma2/z_eff_ss_g_magma2.c index 1469e74ce3..b7cda8ceda 100644 --- a/src/overlays/effects/ovl_Effect_Ss_G_Magma2/z_eff_ss_g_magma2.c +++ b/src/overlays/effects/ovl_Effect_Ss_G_Magma2/z_eff_ss_g_magma2.c @@ -13,7 +13,7 @@ #define rEnvColorR regs[3] #define rEnvColorG regs[4] #define rEnvColorA regs[5] -#define rTexIdx regs[6] +#define rTexIndex regs[6] #define rTimer regs[7] #define rUpdateRate regs[8] #define rDrawMode regs[9] @@ -54,7 +54,7 @@ u32 EffectSsGMagma2_Init(PlayState* play, u32 index, EffectSs* this, void* initP this->draw = EffectSsGMagma2_Draw; this->update = EffectSsGMagma2_Update; this->gfx = SEGMENTED_TO_VIRTUAL(object_kingdodongo_DL_025A90); - this->rTexIdx = 0; + this->rTexIndex = 0; this->rDrawMode = initParams->drawMode; this->rUpdateRate = initParams->updateRate; this->rScale = initParams->scale; @@ -97,7 +97,7 @@ void EffectSsGMagma2_Draw(PlayState* play, u32 index, EffectSs* this) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, 0, this->rPrimColorA); gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, 0, this->rEnvColorA); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sTextures[this->rTexIdx])); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sTextures[this->rTexIndex])); gSPDisplayList(POLY_XLU_DISP++, this->gfx); CLOSE_DISPS(gfxCtx, "../z_eff_ss_g_magma2.c", 311); @@ -108,9 +108,9 @@ void EffectSsGMagma2_Update(PlayState* play, u32 index, EffectSs* this) { if (this->rTimer >= 10) { this->rTimer -= 10; - this->rTexIdx++; + this->rTexIndex++; - if (this->rTexIdx >= 10) { + if (this->rTexIndex >= 10) { this->life = 0; } diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.c b/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.c index aad2a21f53..0b7c5cdd9f 100644 --- a/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.c +++ b/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.c @@ -15,7 +15,7 @@ #define rEnvColorG regs[5] #define rEnvColorB regs[6] #define rEnvColorA regs[7] -#define rTexIdx regs[8] +#define rTexIndex regs[8] #define rScale regs[9] #define rScaleStep regs[10] @@ -57,7 +57,7 @@ u32 EffectSsGSpk_Init(PlayState* play, u32 index, EffectSs* this, void* initPara this->rEnvColorG = initParams->envColor.g; this->rEnvColorB = initParams->envColor.b; this->rEnvColorA = initParams->envColor.a; - this->rTexIdx = 0; + this->rTexIndex = 0; this->rScale = initParams->scale; this->rScaleStep = initParams->scaleStep; this->actor = initParams->actor; @@ -76,7 +76,7 @@ void EffectSsGSpk_Draw(PlayState* play, u32 index, EffectSs* this) { MtxF mfTrans; MtxF mfScale; MtxF mfResult; - MtxF mfTrans11DA0; + MtxF mfTransBillboard; Mtx* mtx; f32 scale; s32 pad; @@ -86,14 +86,14 @@ void EffectSsGSpk_Draw(PlayState* play, u32 index, EffectSs* this) { scale = this->rScale * 0.0025f; SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); SkinMatrix_SetScale(&mfScale, scale, scale, 1.0f); - SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTrans11DA0); - SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfScale, &mfResult); + SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTransBillboard); + SkinMatrix_MtxFMtxFMult(&mfTransBillboard, &mfScale, &mfResult); mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); if (mtx != NULL) { gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sparkTextures[this->rTexIdx])); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sparkTextures[this->rTexIndex])); Gfx_SetupDL_60NoCDXlu(gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, 255); gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rEnvColorA); @@ -122,8 +122,8 @@ void EffectSsGSpk_Update(PlayState* play, u32 index, EffectSs* this) { this->vec.x += this->accel.x; this->vec.z += this->accel.z; - this->rTexIdx++; - this->rTexIdx &= 3; + this->rTexIndex++; + this->rTexIndex &= 3; this->rScale += this->rScaleStep; } @@ -137,7 +137,7 @@ void EffectSsGSpk_UpdateNoAccel(PlayState* play, u32 index, EffectSs* this) { } } - this->rTexIdx++; - this->rTexIdx &= 3; + this->rTexIndex++; + this->rTexIndex &= 3; this->rScale += this->rScaleStep; } diff --git a/src/overlays/effects/ovl_Effect_Ss_HitMark/z_eff_ss_hitmark.c b/src/overlays/effects/ovl_Effect_Ss_HitMark/z_eff_ss_hitmark.c index 75b11bd271..87e1ab5194 100644 --- a/src/overlays/effects/ovl_Effect_Ss_HitMark/z_eff_ss_hitmark.c +++ b/src/overlays/effects/ovl_Effect_Ss_HitMark/z_eff_ss_hitmark.c @@ -7,7 +7,7 @@ #include "z_eff_ss_hitmark.h" #include "assets/objects/gameplay_keep/gameplay_keep.h" -#define rTexIdx regs[0] +#define rTexIndex regs[0] #define rType regs[1] #define rPrimColorR regs[2] #define rPrimColorG regs[3] @@ -56,7 +56,7 @@ u32 EffectSsHitMark_Init(PlayState* play, u32 index, EffectSs* this, void* initP this->draw = EffectSsHitMark_Draw; this->update = EffectSsHitMark_Update; colorIdx = initParams->type * 4; - this->rTexIdx = 0; + this->rTexIndex = 0; this->rType = initParams->type; this->rPrimColorR = sColors[colorIdx].r; this->rPrimColorG = sColors[colorIdx].g; @@ -74,7 +74,7 @@ void EffectSsHitMark_Draw(PlayState* play, u32 index, EffectSs* this) { MtxF mfTrans; MtxF mfScale; MtxF mfResult; - MtxF mfTrans11DA0; + MtxF mfTransBillboard; Mtx* mtx; f32 scale; s32 pad; @@ -84,15 +84,15 @@ void EffectSsHitMark_Draw(PlayState* play, u32 index, EffectSs* this) { SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); scale = this->rScale / 100.0f; SkinMatrix_SetScale(&mfScale, scale, scale, 1.0f); - SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTrans11DA0); - SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfScale, &mfResult); + SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTransBillboard); + SkinMatrix_MtxFMtxFMult(&mfTransBillboard, &mfScale, &mfResult); gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); if (mtx != NULL) { gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sTextures[(this->rType * 8) + (this->rTexIdx)])); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sTextures[(this->rType * 8) + (this->rTexIndex)])); Gfx_SetupDL_61Xlu(gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, 255); gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, 0); @@ -105,18 +105,18 @@ void EffectSsHitMark_Update(PlayState* play, u32 index, EffectSs* this) { s32 colorIdx; if (this->rType == EFFECT_HITMARK_DUST) { - this->rTexIdx = (15 - this->life) / 2; + this->rTexIndex = (15 - this->life) / 2; } else { - this->rTexIdx = 7 - this->life; + this->rTexIndex = 7 - this->life; } - if (this->rTexIdx != 0) { + if (this->rTexIndex != 0) { colorIdx = this->rType * 4 + 2; - this->rPrimColorR = func_80027DD4(this->rPrimColorR, sColors[colorIdx].r, this->life + 1); - this->rPrimColorG = func_80027DD4(this->rPrimColorG, sColors[colorIdx].g, this->life + 1); - this->rPrimColorB = func_80027DD4(this->rPrimColorB, sColors[colorIdx].b, this->life + 1); - this->rEnvColorR = func_80027DD4(this->rEnvColorR, sColors[colorIdx + 1].r, this->life + 1); - this->rEnvColorG = func_80027DD4(this->rEnvColorG, sColors[colorIdx + 1].g, this->life + 1); - this->rEnvColorB = func_80027DD4(this->rEnvColorB, sColors[colorIdx + 1].b, this->life + 1); + this->rPrimColorR = EffectSs_LerpInv(this->rPrimColorR, sColors[colorIdx].r, this->life + 1); + this->rPrimColorG = EffectSs_LerpInv(this->rPrimColorG, sColors[colorIdx].g, this->life + 1); + this->rPrimColorB = EffectSs_LerpInv(this->rPrimColorB, sColors[colorIdx].b, this->life + 1); + this->rEnvColorR = EffectSs_LerpInv(this->rEnvColorR, sColors[colorIdx + 1].r, this->life + 1); + this->rEnvColorG = EffectSs_LerpInv(this->rEnvColorG, sColors[colorIdx + 1].g, this->life + 1); + this->rEnvColorB = EffectSs_LerpInv(this->rEnvColorB, sColors[colorIdx + 1].b, this->life + 1); } } diff --git a/src/overlays/effects/ovl_Effect_Ss_KiraKira/z_eff_ss_kirakira.c b/src/overlays/effects/ovl_Effect_Ss_KiraKira/z_eff_ss_kirakira.c index 632072003c..09f9e79179 100644 --- a/src/overlays/effects/ovl_Effect_Ss_KiraKira/z_eff_ss_kirakira.c +++ b/src/overlays/effects/ovl_Effect_Ss_KiraKira/z_eff_ss_kirakira.c @@ -81,8 +81,8 @@ void EffectSsKiraKira_Draw(PlayState* play, u32 index, EffectSs* this) { MtxF mfTrans; MtxF mfRotY; MtxF mfScale; - MtxF mfTrans11DA0; - MtxF mfTrans11DA0RotY; + MtxF mfTransBillboard; + MtxF mfTransBillboardRotY; MtxF mfResult; Mtx* mtx; @@ -94,9 +94,9 @@ void EffectSsKiraKira_Draw(PlayState* play, u32 index, EffectSs* this) { SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); SkinMatrix_SetRotateZYX(&mfRotY, 0, 0, this->rYaw); SkinMatrix_SetScale(&mfScale, scale, scale, 1.0f); - SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTrans11DA0); - SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfRotY, &mfTrans11DA0RotY); - SkinMatrix_MtxFMtxFMult(&mfTrans11DA0RotY, &mfScale, &mfResult); + SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTransBillboard); + SkinMatrix_MtxFMtxFMult(&mfTransBillboard, &mfRotY, &mfTransBillboardRotY); + SkinMatrix_MtxFMtxFMult(&mfTransBillboardRotY, &mfScale, &mfResult); gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); diff --git a/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.c b/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.c index 17c6c1260b..14c5389e42 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.c +++ b/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.c @@ -76,8 +76,8 @@ void EffectSsLightning_Draw(PlayState* play, u32 index, EffectSs* this) { MtxF mfTrans; MtxF mfScale; MtxF mfRotate; - MtxF mfTrans11DA0; - MtxF mfTrans11DA0Rotate; + MtxF mfTransBillboard; + MtxF mfTransBillboardRotate; Mtx* mtx; f32 yScale; s16 texIdx; @@ -96,9 +96,9 @@ void EffectSsLightning_Draw(PlayState* play, u32 index, EffectSs* this) { xzScale = yScale * 0.6f; SkinMatrix_SetScale(&mfScale, xzScale, yScale, xzScale); SkinMatrix_SetRotateZYX(&mfRotate, this->vec.x, this->vec.y, this->rYaw); - SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTrans11DA0); - SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfRotate, &mfTrans11DA0Rotate); - SkinMatrix_MtxFMtxFMult(&mfTrans11DA0Rotate, &mfScale, &mfResult); + SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTransBillboard); + SkinMatrix_MtxFMtxFMult(&mfTransBillboard, &mfRotate, &mfTransBillboardRotate); + SkinMatrix_MtxFMtxFMult(&mfTransBillboardRotate, &mfScale, &mfResult); gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/effects/ovl_Effect_Ss_Sibuki2/z_eff_ss_sibuki2.c b/src/overlays/effects/ovl_Effect_Ss_Sibuki2/z_eff_ss_sibuki2.c index 77ccaf49af..4225af82c0 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Sibuki2/z_eff_ss_sibuki2.c +++ b/src/overlays/effects/ovl_Effect_Ss_Sibuki2/z_eff_ss_sibuki2.c @@ -15,7 +15,7 @@ #define rEnvColorG regs[5] #define rEnvColorB regs[6] #define rEnvColorA regs[7] -#define rTexIdx regs[8] +#define rTexIndex regs[8] #define rScale regs[9] u32 EffectSsSibuki2_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); @@ -45,7 +45,7 @@ u32 EffectSsSibuki2_Init(PlayState* play, u32 index, EffectSs* this, void* initP this->rEnvColorG = 100; this->rEnvColorB = 100; this->rEnvColorA = 255; - this->rTexIdx = 0; + this->rTexIndex = 0; return 1; } @@ -68,14 +68,14 @@ void EffectSsSibuki2_Draw(PlayState* play, u32 index, EffectSs* this) { Gfx_SetupDL_25Opa(gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, this->rPrimColorA); gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rEnvColorA); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(bubbleTextures[this->rTexIdx])); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(bubbleTextures[this->rTexIndex])); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gEffUnusedBubblesDL)); CLOSE_DISPS(gfxCtx, "../z_eff_ss_sibuki2.c", 198); } void EffectSsSibuki2_Update(PlayState* play, u32 index, EffectSs* this) { - if (this->rTexIdx < 8) { - this->rTexIdx++; + if (this->rTexIndex < 8) { + this->rTexIndex++; } } diff --git a/tools/mkldscript.c b/tools/mkldscript.c index c29f61f819..ed61e543e9 100644 --- a/tools/mkldscript.c +++ b/tools/mkldscript.c @@ -219,7 +219,8 @@ static void write_ld_script(FILE *fout) // Debugging sections fputs( - // mdebug debug sections + // mdebug sections + " .pdr : { *(.pdr) }" "\n" " .mdebug : { *(.mdebug) }" "\n" " .mdebug.abi32 : { *(.mdebug.abi32) }" "\n" // DWARF debug sections @@ -249,8 +250,16 @@ static void write_ld_script(FILE *fout) // DWARF 3 " .debug_pubtypes 0 : { *(.debug_pubtypes) }" "\n" " .debug_ranges 0 : { *(.debug_ranges) }" "\n" - // DWARF Extension + // DWARF 5 + " .debug_addr 0 : { *(.debug_addr) }" "\n" + " .debug_line_str 0 : { *(.debug_line_str) }" "\n" + " .debug_loclists 0 : { *(.debug_loclists) }" "\n" " .debug_macro 0 : { *(.debug_macro) }" "\n" + " .debug_names 0 : { *(.debug_names) }" "\n" + " .debug_rnglists 0 : { *(.debug_rnglists) }" "\n" + " .debug_str_offsets 0 : { *(.debug_str_offsets) }" "\n" + " .debug_sup 0 : { *(.debug_sup) }\n" + // gnu attributes " .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }" "\n", fout); // Discard all other sections not mentioned above