diff --git a/assets/xml/objects/object_niw.xml b/assets/xml/objects/object_niw.xml index a74cbe7daf..4eafec9566 100644 --- a/assets/xml/objects/object_niw.xml +++ b/assets/xml/objects/object_niw.xml @@ -30,8 +30,8 @@ - - + + diff --git a/format.sh b/format.sh index d5d3c2d49c..f8e5ef9091 100755 --- a/format.sh +++ b/format.sh @@ -21,13 +21,13 @@ export -f add_final_newline shopt -s globstar -if [ $(command -v clang-format) ] +if [ $(command -v clang-format-${FORMAT_VER}) ] then - CLANG_FORMAT="clang-format" + CLANG_FORMAT="clang-format-${FORMAT_VER}" else - if [ $(command -v clang-format-${FORMAT_VER}) ] + if [ $(command -v clang-format) ] then - CLANG_FORMAT="clang-format-${FORMAT_VER}" + CLANG_FORMAT="clang-format" else echo "Neither clang-format nor clang-format-${FORMAT_VER} found. Exiting." exit 1 diff --git a/include/functions.h b/include/functions.h index ed449e5f17..5a800b058c 100644 --- a/include/functions.h +++ b/include/functions.h @@ -31,7 +31,7 @@ void DmaMgr_Error(DmaRequest* req, const char* file, const char* errorName, cons const char* DmaMgr_GetFileNameImpl(u32 vrom); const char* DmaMgr_GetFileName(u32 vrom); void DmaMgr_ProcessMsg(DmaRequest* req); -void DmaMgr_ThreadEntry(void* arg0); +void DmaMgr_ThreadEntry(void* arg); s32 DmaMgr_SendRequestImpl(DmaRequest* req, u32 ram, u32 vrom, u32 size, u32 unk, OSMesgQueue* queue, OSMesg msg); s32 DmaMgr_SendRequest0(u32 ram, u32 vrom, u32 size); void DmaMgr_Init(void); @@ -79,7 +79,7 @@ s32 sprintf(char* dst, const char* fmt, ...); void __osPiCreateAccessQueue(void); void __osPiGetAccess(void); void __osPiRelAccess(void); -s32 osSendMesg(OSMesgQueue* mq, OSMesg mesg, s32 flag); +s32 osSendMesg(OSMesgQueue* mq, OSMesg msg, s32 flag); void osStopThread(OSThread* thread); void osViExtendVStart(u32 arg0); s32 osRecvMesg(OSMesgQueue* mq, OSMesg* msg, s32 flag); @@ -101,7 +101,7 @@ void __osSetSR(u32); u32 __osGetSR(void); void osWritebackDCache(void* vaddr, s32 nbytes); void* osViGetNextFramebuffer(void); -void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgCnt); +void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQueue, OSMesg* cmdBuf, s32 cmdMsgCnt); void __osDevMgrMain(void* arg); s32 __osPiRawStartDma(s32 dir, u32 cartAddr, void* dramAddr, size_t size); u32 osVirtualToPhysical(void* vaddr); @@ -122,7 +122,7 @@ void osInvalICache(void* vaddr, s32 nbytes); void osCreateMesgQueue(OSMesgQueue* mq, OSMesg* msg, s32 count); void osInvalDCache(void* vaddr, s32 nbytes); s32 __osSiDeviceBusy(void); -s32 osJamMesg(OSMesgQueue* mq, OSMesg mesg, s32 flag); +s32 osJamMesg(OSMesgQueue* mq, OSMesg msg, s32 flag); void osSetThreadPri(OSThread* thread, OSPri pri); OSPri osGetThreadPri(OSThread* thread); s32 __osEPiRawReadIo(OSPiHandle* handle, u32 devAddr, u32* data); @@ -1347,14 +1347,14 @@ void func_800AA178(u32); View* View_New(GraphicsContext* gfxCtx); void View_Free(View* view); void View_Init(View*, GraphicsContext*); -void func_800AA358(View* view, Vec3f* eye, Vec3f* lookAt, Vec3f* up); -void func_800AA3F0(View* view, Vec3f* eye, Vec3f* lookAt, Vec3f* up); +void View_LookAt(View* view, Vec3f* eye, Vec3f* lookAt, Vec3f* up); +void View_LookAtUnsafe(View* view, Vec3f* eye, Vec3f* lookAt, Vec3f* up); void View_SetScale(View* view, f32 scale); void View_GetScale(View* view, f32* scale); -void func_800AA460(View* view, f32 fovy, f32 near, f32 far); -void func_800AA48C(View* view, f32* fovy, f32* near, f32* far); -void func_800AA4A8(View* view, f32 fovy, f32 near, f32 far); -void func_800AA4E0(View* view, f32* fovy, f32* near, f32* far); +void View_SetPerspective(View* view, f32 fovy, f32 zNear, f32 zFar); +void View_GetPerspective(View* view, f32* fovy, f32* zNear, f32* zFar); +void View_SetOrtho(View* view, f32 fovy, f32 zNear, f32 zFar); +void View_GetOrtho(View* view, f32* fovy, f32* zNear, f32* zFar); void View_SetViewport(View* view, Viewport* viewport); void View_GetViewport(View* view, Viewport* viewport); void View_SetDistortionOrientation(View* view, f32 rotX, f32 rotY, f32 rotZ); @@ -1364,14 +1364,12 @@ void View_InitDistortion(View* view); void View_ClearDistortion(View* view); void View_SetDistortion(View* view, Vec3f orientation, Vec3f scale, f32 speed); s32 View_StepDistortion(View* view, Mtx* projectionMtx); -void func_800AAA50(View* view, s32 arg1); -s32 func_800AAA9C(View* view); -s32 func_800AB0A8(View* view); -s32 func_800AB2C4(View* view); -s32 func_800AB560(View* view); -s32 func_800AB944(View* view); -s32 func_800AB9EC(View* view, s32 arg1, Gfx** p); -s32 func_800ABE74(f32 eyeX, f32 eyeY, f32 eyeZ); +void View_Apply(View* view, s32 mask); +s32 View_ApplyOrthoToOverlay(View* view); +s32 View_ApplyPerspectiveToOverlay(View* view); +s32 View_UpdateViewingMatrix(View* view); +s32 View_ApplyTo(View* view, s32 mask, Gfx** p); +s32 View_ErrorCheckEyePosition(f32 eyeX, f32 eyeY, f32 eyeZ); void ViMode_LogPrint(OSViMode* viMode); void ViMode_Configure(ViMode* viMode, s32 mode, s32 type, s32 unk_70, s32 unk_74, s32 unk_78, s32 unk_7C, s32 width, s32 height, s32 unk_left, s32 unk_right, s32 unk_top, s32 unk_bottom); @@ -1648,7 +1646,7 @@ void PadMgr_HandlePreNMI(PadMgr* padmgr); // This function must remain commented out, because it is called incorrectly in // fault.c (actual bug in game), and the compiler notices and won't compile it // void PadMgr_RequestPadData(PadMgr* padmgr, Input* inputs, s32 mode); -void PadMgr_Init(PadMgr* padmgr, OSMesgQueue* siIntMsgQ, IrqMgr* irqMgr, OSId id, OSPri priority, void* stack); +void PadMgr_Init(PadMgr* padmgr, OSMesgQueue* serialEventQueue, IrqMgr* irqMgr, OSId id, OSPri priority, void* stack); void Sched_SwapFrameBuffer(CfbInfo* cfbInfo); void func_800C84E4(SchedContext* sc, CfbInfo* cfbInfo); void Sched_HandleReset(SchedContext* sc); diff --git a/include/irqmgr.h b/include/irqmgr.h index 6c5b72458a..e1b3befbca 100644 --- a/include/irqmgr.h +++ b/include/irqmgr.h @@ -40,7 +40,7 @@ typedef struct { void IrqMgr_Init(IrqMgr* irqMgr, void* stack, OSPri pri, u8 retraceCount); -void IrqMgr_AddClient(IrqMgr* irqMgr, IrqMgrClient* client, OSMesgQueue* msgQ); +void IrqMgr_AddClient(IrqMgr* irqMgr, IrqMgrClient* client, OSMesgQueue* msgQueue); void IrqMgr_RemoveClient(IrqMgr* irqMgr, IrqMgrClient* client); #endif diff --git a/include/padmgr.h b/include/padmgr.h index 459bcfeba1..52f6f08ee7 100644 --- a/include/padmgr.h +++ b/include/padmgr.h @@ -12,12 +12,12 @@ typedef struct { typedef struct PadMgr { /* 0x0000 */ OSContStatus padStatus[4]; - /* 0x0010 */ OSMesg serialMsgBuf[1]; + /* 0x0010 */ OSMesg serialLockMsgBuf[1]; /* 0x0014 */ OSMesg lockMsgBuf[1]; /* 0x0018 */ OSMesg interruptMsgBuf[4]; - /* 0x0028 */ OSMesgQueue serialMsgQ; - /* 0x0040 */ OSMesgQueue lockMsgQ; - /* 0x0058 */ OSMesgQueue interruptMsgQ; + /* 0x0028 */ OSMesgQueue serialLockQueue; + /* 0x0040 */ OSMesgQueue lockQueue; + /* 0x0058 */ OSMesgQueue interruptQueue; /* 0x0070 */ IrqMgrClient irqClient; /* 0x0078 */ IrqMgr* irqMgr; /* 0x0080 */ OSThread thread; diff --git a/include/ultra64/controller.h b/include/ultra64/controller.h index 86e3e4bee1..3b92328127 100644 --- a/include/ultra64/controller.h +++ b/include/ultra64/controller.h @@ -3,7 +3,6 @@ #include "message.h" -#define SIAccessQueueSize 2 #define BLOCKSIZE 32 #define MAXCONTROLLERS 4 #define PFS_ONE_PAGE 8 diff --git a/include/ultra64/thread.h b/include/ultra64/thread.h index 6b901d4f2d..4c8146c0bc 100644 --- a/include/ultra64/thread.h +++ b/include/ultra64/thread.h @@ -30,6 +30,7 @@ typedef union { /* 0x00 */ f32 f_odd; /* 0x04 */ f32 f_even; } f; + f64 d; } __OSfp; // size = 0x08 typedef struct { @@ -63,4 +64,9 @@ typedef struct OSThread { /* 0x20 */ __OSThreadContext context; } OSThread; // size = 0x1B0 +typedef struct { + OSThread* next; + OSPri priority; +} __OSThreadTail; // size = 0x8 + #endif diff --git a/include/ultra64/vi.h b/include/ultra64/vi.h index f54bb3b65b..c0a81f836f 100644 --- a/include/ultra64/vi.h +++ b/include/ultra64/vi.h @@ -64,7 +64,7 @@ typedef struct { /* 0x08 */ OSViMode* modep; /* 0x0C */ u32 features; /* 0x10 */ OSMesgQueue* mq; - /* 0x14 */ OSMesg* msg; + /* 0x14 */ OSMesg msg; /* 0x18 */ __OSViScale x; /* 0x24 */ __OSViScale y; } OSViContext; // size = 0x30 diff --git a/include/variables.h b/include/variables.h index 621081b91e..9d1d04e0bf 100644 --- a/include/variables.h +++ b/include/variables.h @@ -28,7 +28,7 @@ extern OSViMode osViModePalLan1; extern s32 osViClock; extern u32 __osShutdown; extern OSHWIntr __OSGlobalIntMask; -extern OSThread* __osThreadTail[]; +extern __OSThreadTail __osThreadTail; extern OSThread* __osRunQueue; extern OSThread* __osActiveQueue; extern OSThread* __osRunningThread; @@ -45,7 +45,7 @@ extern u32 __additional_scanline; extern u8 gBuildTeam[]; extern u8 gBuildDate[]; extern u8 gBuildMakeOption[]; -extern OSMesgQueue gPiMgrCmdQ; +extern OSMesgQueue gPiMgrCmdQueue; extern OSViMode gViConfigMode; extern u8 D_80013960; extern OSMesgQueue __osPiAccessQueue; diff --git a/include/z64.h b/include/z64.h index ae1d62d461..18d4f08e50 100644 --- a/include/z64.h +++ b/include/z64.h @@ -42,13 +42,28 @@ #define REGION_JP 2 #define REGION_EU 3 -#define Z_PRIORITY_MAIN 10 -#define Z_PRIORITY_GRAPH 11 -#define Z_PRIORITY_AUDIOMGR 12 -#define Z_PRIORITY_PADMGR 14 -#define Z_PRIORITY_SCHED 15 -#define Z_PRIORITY_DMAMGR 16 -#define Z_PRIORITY_IRQMGR 17 +#define THREAD_PRI_IDLE_INIT 10 +#define THREAD_PRI_MAIN_INIT 10 +#define THREAD_PRI_DMAMGR_LOW 10 // Used when decompressing files +#define THREAD_PRI_GRAPH 11 +#define THREAD_PRI_AUDIOMGR 12 +#define THREAD_PRI_PADMGR 14 +#define THREAD_PRI_MAIN 15 +#define THREAD_PRI_SCHED 15 +#define THREAD_PRI_DMAMGR 16 +#define THREAD_PRI_IRQMGR 17 +#define THREAD_PRI_FAULT_CLIENT (OS_PRIORITY_APPMAX - 1) +#define THREAD_PRI_FAULT OS_PRIORITY_APPMAX + +#define THREAD_ID_IDLE 1 +#define THREAD_ID_FAULT 2 +#define THREAD_ID_MAIN 3 +#define THREAD_ID_GRAPH 4 +#define THREAD_ID_SCHED 5 +#define THREAD_ID_PADMGR 7 +#define THREAD_ID_AUDIOMGR 10 +#define THREAD_ID_DMAMGR 18 +#define THREAD_ID_IRQMGR 19 #define STACK(stack, size) \ u64 stack[ALIGN8(size) / sizeof(u64)] @@ -118,9 +133,10 @@ typedef struct OSScTask { /* 0x08 */ u32 flags; /* 0x0C */ CfbInfo* framebuffer; /* 0x10 */ OSTask list; - /* 0x50 */ OSMesgQueue* msgQ; + /* 0x50 */ OSMesgQueue* msgQueue; /* 0x54 */ OSMesg msg; -} OSScTask; + /* 0x58 */ char unk_58[0x10]; +} OSScTask; // size = 0x68 typedef struct GraphicsContext { /* 0x0000 */ Gfx* polyOpaBuffer; // Pointer to "Zelda 0" @@ -130,11 +146,11 @@ typedef struct GraphicsContext { /* 0x0014 */ u32 unk_014; /* 0x0018 */ char unk_018[0x20]; /* 0x0038 */ OSMesg msgBuff[0x08]; - /* 0x0058 */ OSMesgQueue* schedMsgQ; + /* 0x0058 */ OSMesgQueue* schedMsgQueue; /* 0x005C */ OSMesgQueue queue; /* 0x0074 */ char unk_074[0x04]; - /* 0x0078 */ OSScTask task; // size of OSScTask might be wrong - /* 0x00D0 */ char unk_0D0[0xE0]; + /* 0x0078 */ OSScTask task; + /* 0x00E0 */ char unk_0E0[0xD0]; /* 0x01B0 */ Gfx* workBuffer; /* 0x01B4 */ TwoHeadGfxArena work; /* 0x01C4 */ char unk_01C4[0xC0]; @@ -171,7 +187,7 @@ typedef struct { /* 0x0020 */ f32 zFar; // distance to far clipping plane /* 0x0024 */ f32 scale; // scale for matrix elements /* 0x0028 */ Vec3f eye; - /* 0x0034 */ Vec3f lookAt; + /* 0x0034 */ Vec3f at; /* 0x0040 */ Vec3f up; /* 0x0050 */ Vp vp; /* 0x0060 */ Mtx projection; @@ -188,6 +204,17 @@ typedef struct { /* 0x0124 */ s32 unk_124; } View; // size = 0x128 +#define VIEW_VIEWING (1 << 0) +#define VIEW_VIEWPORT (1 << 1) +#define VIEW_PROJECTION_PERSPECTIVE (1 << 2) +#define VIEW_PROJECTION_ORTHO (1 << 3) +#define VIEW_ALL (VIEW_VIEWING | VIEW_VIEWPORT | VIEW_PROJECTION_PERSPECTIVE | VIEW_PROJECTION_ORTHO) + +#define VIEW_FORCE_VIEWING (VIEW_VIEWING << 4) +#define VIEW_FORCE_VIEWPORT (VIEW_VIEWPORT << 4) +#define VIEW_FORCE_PROJECTION_PERSPECTIVE (VIEW_PROJECTION_PERSPECTIVE << 4) +#define VIEW_FORCE_PROJECTION_ORTHO (VIEW_PROJECTION_ORTHO << 4) + typedef struct { /* 0x00 */ u8 seqId; /* 0x01 */ u8 natureAmbienceId; @@ -1565,9 +1592,9 @@ typedef struct { } FrameBufferSwap; typedef struct { - /* 0x0000 */ OSMesgQueue interruptQ; - /* 0x0018 */ OSMesg intBuf[8]; - /* 0x0038 */ OSMesgQueue cmdQ; + /* 0x0000 */ OSMesgQueue interruptQueue; + /* 0x0018 */ OSMesg interruptMsgBuf[8]; + /* 0x0038 */ OSMesgQueue cmdQueue; /* 0x0050 */ OSMesg cmdMsgBuf[8]; /* 0x0070 */ OSThread thread; /* 0x0220 */ OSScTask* audioListHead; @@ -1596,18 +1623,14 @@ typedef struct { /* 0x0000 */ IrqMgr* irqMgr; /* 0x0004 */ SchedContext* sched; /* 0x0008 */ OSScTask audioTask; - /* 0x0060 */ char unk_60[0x10]; /* 0x0070 */ AudioTask* rspTask; - /* 0x0074 */ OSMesgQueue unk_74; - /* 0x008C */ OSMesg unk_8C; - /* 0x0090 */ OSMesgQueue unk_90; - /* 0x00A8 */ OSMesg unk_A8; - /* 0x00AC */ OSMesgQueue unk_AC; - /* 0x00C4 */ OSMesg unk_C4; - /* 0x00C8 */ OSMesgQueue unk_C8; - /* 0x00E0 */ OSMesg unk_E0; - /* 0x00E4 */ char unk_E4[0x04]; - /* 0x00E8 */ OSThread unk_E8; + /* 0x0074 */ OSMesgQueue interruptQueue; + /* 0x008C */ OSMesg interruptMsgBuf[8]; + /* 0x00AC */ OSMesgQueue taskQueue; + /* 0x00C4 */ OSMesg taskMsgBuf[1]; + /* 0x00C8 */ OSMesgQueue lockQueue; + /* 0x00E0 */ OSMesg lockMsgBuf[1]; + /* 0x00E8 */ OSThread thread; } AudioMgr; // size = 0x298 struct ArenaNode; @@ -1615,7 +1638,7 @@ struct ArenaNode; typedef struct Arena { /* 0x00 */ struct ArenaNode* head; /* 0x04 */ void* start; - /* 0x08 */ OSMesgQueue lock; + /* 0x08 */ OSMesgQueue lockQueue; /* 0x20 */ u8 unk_20; /* 0x21 */ u8 isInit; /* 0x22 */ u8 flag; @@ -1782,7 +1805,6 @@ typedef struct { /* 0x28 */ u32 mode; // 0 if Y V0 is 1 and 2 if Y V0 is 2 /* 0x2C */ char unk_2C[4]; /* 0x30 */ OSScTask scTask; - /* 0x88 */ char unk_88[0x10]; /* 0x98 */ OSMesgQueue mq; /* 0xB0 */ OSMesg msg; /* 0xB4 */ JpegWork* workBuf; diff --git a/include/z64audio.h b/include/z64audio.h index b4b0ccd0cc..0326d7638f 100644 --- a/include/z64audio.h +++ b/include/z64audio.h @@ -716,7 +716,7 @@ typedef struct { /* 0x18 */ s32 bytesRemaining; /* 0x1C */ s8* isDone; /* 0x20 */ SoundFontSample sample; - /* 0x30 */ OSMesgQueue msgqueue; + /* 0x30 */ OSMesgQueue msgQueue; /* 0x48 */ OSMesg msg; /* 0x4C */ OSIoMesg ioMesg; } AudioSlowLoad; // size = 0x64 @@ -741,7 +741,7 @@ typedef struct { typedef struct { /* 0x00 */ OSTask task; - /* 0x40 */ OSMesgQueue* taskQueue; + /* 0x40 */ OSMesgQueue* msgQueue; /* 0x44 */ void* unk_44; // probably a message that gets unused. /* 0x48 */ char unk_48[0x8]; } AudioTask; // size = 0x50 @@ -779,12 +779,12 @@ typedef struct { /* 0x1E18 */ OSPiHandle* cartHandle; /* 0x1E1C */ OSPiHandle* driveHandle; /* 0x1E20 */ OSMesgQueue externalLoadQueue; - /* 0x1E38 */ OSMesg externalLoadMesgBuf[0x10]; + /* 0x1E38 */ OSMesg externalLoadMsgBuf[16]; /* 0x1E78 */ OSMesgQueue preloadSampleQueue; - /* 0x1E90 */ OSMesg preloadSampleMesgBuf[0x10]; + /* 0x1E90 */ OSMesg preloadSampleMsgBuf[16]; /* 0x1ED0 */ OSMesgQueue currAudioFrameDmaQueue; - /* 0x1EE8 */ OSMesg currAudioFrameDmaMesgBuf[0x40]; - /* 0x1FE8 */ OSIoMesg currAudioFrameDmaIoMesgBuf[0x40]; + /* 0x1EE8 */ OSMesg currAudioFrameDmaMsgBuf[64]; + /* 0x1FE8 */ OSIoMesg currAudioFrameDmaIoMsgBuf[64]; /* 0x25E8 */ OSMesgQueue syncDmaQueue; /* 0x2600 */ OSMesg syncDmaMesg; /* 0x2604 */ OSIoMesg syncDmaIoMesg; @@ -876,9 +876,9 @@ typedef struct { /* 0x5BF0 */ OSMesgQueue taskStartQueue; /* 0x5C08 */ OSMesgQueue cmdProcQueue; /* 0x5C20 */ OSMesgQueue audioResetQueue; - /* 0x5C38 */ OSMesg taskStartMsgs[1]; - /* 0x5C3C */ OSMesg audioResetMesgs[1]; - /* 0x5C40 */ OSMesg cmdProcMsgs[4]; + /* 0x5C38 */ OSMesg taskStartMsgBuf[1]; + /* 0x5C3C */ OSMesg audioResetMsgBuf[1]; + /* 0x5C40 */ OSMesg cmdProcMsgBuf[4]; /* 0x5C50 */ AudioCmd cmdBuf[0x100]; } AudioContext; // size = 0x6450 diff --git a/src/boot/boot_main.c b/src/boot/boot_main.c index 89e09a184a..9d8631b57a 100644 --- a/src/boot/boot_main.c +++ b/src/boot/boot_main.c @@ -24,6 +24,7 @@ void bootproc(void) { Locale_Init(); StackCheck_Init(&sIdleThreadInfo, sIdleThreadStack, STACK_TOP(sIdleThreadStack), 0, 256, "idle"); - osCreateThread(&sIdleThread, 1, Idle_ThreadEntry, NULL, STACK_TOP(sIdleThreadStack), Z_PRIORITY_MAIN); + osCreateThread(&sIdleThread, THREAD_ID_IDLE, Idle_ThreadEntry, NULL, STACK_TOP(sIdleThreadStack), + THREAD_PRI_IDLE_INIT); osStartThread(&sIdleThread); } diff --git a/src/boot/idle.c b/src/boot/idle.c index d81484e4c4..f4e3715d7f 100644 --- a/src/boot/idle.c +++ b/src/boot/idle.c @@ -5,7 +5,7 @@ OSThread gMainThread; STACK(sMainStack, 0x900); StackEntry sMainStackInfo; OSMesg sPiMgrCmdBuff[50]; -OSMesgQueue gPiMgrCmdQ; +OSMesgQueue gPiMgrCmdQueue; OSViMode gViConfigMode; u8 D_80013960; @@ -78,9 +78,9 @@ void Idle_ThreadEntry(void* arg) { ViConfig_UpdateVi(1); osViBlack(1); osViSwapBuffer(0x803DA80); //! @bug Invalid vram address (probably intended to be 0x803DA800) - osCreatePiManager(OS_PRIORITY_PIMGR, &gPiMgrCmdQ, sPiMgrCmdBuff, 50); + osCreatePiManager(OS_PRIORITY_PIMGR, &gPiMgrCmdQueue, sPiMgrCmdBuff, ARRAY_COUNT(sPiMgrCmdBuff)); StackCheck_Init(&sMainStackInfo, sMainStack, STACK_TOP(sMainStack), 0, 0x400, "main"); - osCreateThread(&gMainThread, 3, Main_ThreadEntry, arg, STACK_TOP(sMainStack), Z_PRIORITY_MAIN); + osCreateThread(&gMainThread, THREAD_ID_MAIN, Main_ThreadEntry, arg, STACK_TOP(sMainStack), THREAD_PRI_MAIN_INIT); osStartThread(&gMainThread); osSetThreadPri(NULL, OS_PRIORITY_IDLE); diff --git a/src/boot/z_std_dma.c b/src/boot/z_std_dma.c index d50807f4f8..a0050fca50 100644 --- a/src/boot/z_std_dma.c +++ b/src/boot/z_std_dma.c @@ -3,7 +3,7 @@ StackEntry sDmaMgrStackInfo; OSMesgQueue sDmaMgrMsgQueue; -OSMesg sDmaMgrMsgs[0x20]; +OSMesg sDmaMgrMsgBuf[32]; OSThread sDmaMgrThread; STACK(sDmaMgrStack, 0x500); const char* sDmaMgrCurFileName; @@ -70,7 +70,7 @@ s32 DmaMgr_DmaRomToRam(u32 rom, u32 ram, u32 size) { if (gDmaMgrVerbose == 10) { osSyncPrintf("%10lld ノーマルDMA %08x %08x %08x (%d)\n", OS_CYCLES_TO_USEC(osGetTime()), ioMsg.dramAddr, - ioMsg.devAddr, ioMsg.size, gPiMgrCmdQ.validCount); + ioMsg.devAddr, ioMsg.size, MQ_GET_COUNT(&gPiMgrCmdQueue)); } ret = osEPiStartDma(gCartHandle, &ioMsg, OS_READ); @@ -79,12 +79,14 @@ s32 DmaMgr_DmaRomToRam(u32 rom, u32 ram, u32 size) { } if (gDmaMgrVerbose == 10) { - osSyncPrintf("%10lld ノーマルDMA START (%d)\n", OS_CYCLES_TO_USEC(osGetTime()), gPiMgrCmdQ.validCount); + osSyncPrintf("%10lld ノーマルDMA START (%d)\n", OS_CYCLES_TO_USEC(osGetTime()), + MQ_GET_COUNT(&gPiMgrCmdQueue)); } osRecvMesg(&queue, NULL, OS_MESG_BLOCK); if (gDmaMgrVerbose == 10) { - osSyncPrintf("%10lld ノーマルDMA END (%d)\n", OS_CYCLES_TO_USEC(osGetTime()), gPiMgrCmdQ.validCount); + osSyncPrintf("%10lld ノーマルDMA END (%d)\n", OS_CYCLES_TO_USEC(osGetTime()), + MQ_GET_COUNT(&gPiMgrCmdQueue)); } size -= buffSize; @@ -102,7 +104,7 @@ s32 DmaMgr_DmaRomToRam(u32 rom, u32 ram, u32 size) { if (gDmaMgrVerbose == 10) { osSyncPrintf("%10lld ノーマルDMA %08x %08x %08x (%d)\n", OS_CYCLES_TO_USEC(osGetTime()), ioMsg.dramAddr, - ioMsg.devAddr, ioMsg.size, gPiMgrCmdQ.validCount); + ioMsg.devAddr, ioMsg.size, MQ_GET_COUNT(&gPiMgrCmdQueue)); } ret = osEPiStartDma(gCartHandle, &ioMsg, OS_READ); @@ -112,7 +114,7 @@ s32 DmaMgr_DmaRomToRam(u32 rom, u32 ram, u32 size) { osRecvMesg(&queue, NULL, OS_MESG_BLOCK); if (gDmaMgrVerbose == 10) { - osSyncPrintf("%10lld ノーマルDMA END (%d)\n", OS_CYCLES_TO_USEC(osGetTime()), gPiMgrCmdQ.validCount); + osSyncPrintf("%10lld ノーマルDMA END (%d)\n", OS_CYCLES_TO_USEC(osGetTime()), MQ_GET_COUNT(&gPiMgrCmdQueue)); } end: @@ -131,7 +133,7 @@ s32 DmaMgr_DmaHandler(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction) { if (gDmaMgrVerbose == 10) { osSyncPrintf("%10lld サウンドDMA %08x %08x %08x (%d)\n", OS_CYCLES_TO_USEC(osGetTime()), mb->dramAddr, - mb->devAddr, mb->size, gPiMgrCmdQ.validCount); + mb->devAddr, mb->size, MQ_GET_COUNT(&gPiMgrCmdQueue)); } ret = osEPiStartDma(pihandle, mb, direction); @@ -160,7 +162,6 @@ void DmaMgr_DmaFromDriveRom(u32 ram, u32 rom, u32 size) { osEPiStartDma(handle, &ioMsg, OS_READ); osRecvMesg(&queue, NULL, OS_MESG_BLOCK); - return; } void DmaMgr_Error(DmaRequest* req, const char* file, const char* errorName, const char* errorDesc) { @@ -280,9 +281,9 @@ void DmaMgr_ProcessMsg(DmaRequest* req) { "圧縮されたセグメントの一部だけをDMA転送することはできません"); } - osSetThreadPri(NULL, Z_PRIORITY_MAIN); + osSetThreadPri(NULL, THREAD_PRI_DMAMGR_LOW); Yaz0_Decompress(romStart, ram, romSize); - osSetThreadPri(NULL, Z_PRIORITY_DMAMGR); + osSetThreadPri(NULL, THREAD_PRI_DMAMGR); found = true; if (0) { @@ -308,7 +309,7 @@ void DmaMgr_ProcessMsg(DmaRequest* req) { } } -void DmaMgr_ThreadEntry(void* arg0) { +void DmaMgr_ThreadEntry(void* arg) { OSMesg msg; DmaRequest* req; @@ -351,19 +352,17 @@ s32 DmaMgr_SendRequestImpl(DmaRequest* req, u32 ram, u32 vrom, u32 size, u32 unk req->notifyQueue = queue; req->notifyMsg = msg; - if (1) { - if ((sDmaMgrQueueFullLogged == 0) && (sDmaMgrMsgQueue.validCount >= sDmaMgrMsgQueue.msgCount)) { - sDmaMgrQueueFullLogged++; - osSyncPrintf("%c", BEL); - osSyncPrintf(VT_FGCOL(RED)); - osSyncPrintf("dmaEntryMsgQが一杯です。キューサイズの再検討をおすすめします。"); - LOG_NUM("(sizeof(dmaEntryMsgBufs) / sizeof(dmaEntryMsgBufs[0]))", ARRAY_COUNT(sDmaMgrMsgs), - "../z_std_dma.c", 952); - osSyncPrintf(VT_RST); - } + if (1 && (sDmaMgrQueueFullLogged == 0) && MQ_IS_FULL(&sDmaMgrMsgQueue)) { + sDmaMgrQueueFullLogged++; + osSyncPrintf("%c", BEL); + osSyncPrintf(VT_FGCOL(RED)); + osSyncPrintf("dmaEntryMsgQが一杯です。キューサイズの再検討をおすすめします。"); + LOG_NUM("(sizeof(dmaEntryMsgBufs) / sizeof(dmaEntryMsgBufs[0]))", ARRAY_COUNT(sDmaMgrMsgBuf), "../z_std_dma.c", + 952); + osSyncPrintf(VT_RST); } - osSendMesg(&sDmaMgrMsgQueue, req, OS_MESG_BLOCK); + osSendMesg(&sDmaMgrMsgQueue, (OSMesg)req, OS_MESG_BLOCK); return 0; } @@ -421,9 +420,10 @@ void DmaMgr_Init(void) { Fault_AddHungupAndCrash("../z_std_dma.c", 1055); } - osCreateMesgQueue(&sDmaMgrMsgQueue, sDmaMgrMsgs, ARRAY_COUNT(sDmaMgrMsgs)); + osCreateMesgQueue(&sDmaMgrMsgQueue, sDmaMgrMsgBuf, ARRAY_COUNT(sDmaMgrMsgBuf)); StackCheck_Init(&sDmaMgrStackInfo, sDmaMgrStack, STACK_TOP(sDmaMgrStack), 0, 0x100, "dmamgr"); - osCreateThread(&sDmaMgrThread, 0x12, DmaMgr_ThreadEntry, 0, STACK_TOP(sDmaMgrStack), Z_PRIORITY_DMAMGR); + osCreateThread(&sDmaMgrThread, THREAD_ID_DMAMGR, DmaMgr_ThreadEntry, NULL, STACK_TOP(sDmaMgrStack), + THREAD_PRI_DMAMGR); osStartThread(&sDmaMgrThread); } diff --git a/src/code/__osMalloc.c b/src/code/__osMalloc.c index 0b66eb3539..ddf3024fae 100644 --- a/src/code/__osMalloc.c +++ b/src/code/__osMalloc.c @@ -56,15 +56,15 @@ void ArenaImpl_SetDebugInfo(ArenaNode* node, const char* file, s32 line, Arena* } void ArenaImpl_LockInit(Arena* arena) { - osCreateMesgQueue(&arena->lock, &sArenaLockMsg, 1); + osCreateMesgQueue(&arena->lockQueue, &sArenaLockMsg, 1); } void ArenaImpl_Lock(Arena* arena) { - osSendMesg(&arena->lock, NULL, OS_MESG_BLOCK); + osSendMesg(&arena->lockQueue, NULL, OS_MESG_BLOCK); } void ArenaImpl_Unlock(Arena* arena) { - osRecvMesg(&arena->lock, NULL, OS_MESG_BLOCK); + osRecvMesg(&arena->lockQueue, NULL, OS_MESG_BLOCK); } ArenaNode* ArenaImpl_GetNextBlock(ArenaNode* node) { diff --git a/src/code/audioMgr.c b/src/code/audioMgr.c index a4775861e2..ccef4dbb27 100644 --- a/src/code/audioMgr.c +++ b/src/code/audioMgr.c @@ -1,11 +1,10 @@ #include "global.h" void func_800C3C80(AudioMgr* audioMgr) { - AudioTask* task; + AudioTask* task = audioMgr->rspTask; - task = audioMgr->rspTask; - if (audioMgr->rspTask->taskQueue != NULL) { - osSendMesg(task->taskQueue, NULL, OS_MESG_BLOCK); + if (audioMgr->rspTask->msgQueue != NULL) { + osSendMesg(task->msgQueue, NULL, OS_MESG_BLOCK); } } @@ -17,14 +16,14 @@ void AudioMgr_HandleRetrace(AudioMgr* audioMgr) { } if (audioMgr->rspTask != NULL) { audioMgr->audioTask.next = NULL; - audioMgr->audioTask.flags = 2; + audioMgr->audioTask.flags = OS_SC_NEEDS_RSP; audioMgr->audioTask.framebuffer = NULL; audioMgr->audioTask.list = audioMgr->rspTask->task; - audioMgr->audioTask.msgQ = &audioMgr->unk_AC; + audioMgr->audioTask.msgQueue = &audioMgr->taskQueue; audioMgr->audioTask.msg = NULL; - osSendMesg(&audioMgr->sched->cmdQ, &audioMgr->audioTask, OS_MESG_BLOCK); + osSendMesg(&audioMgr->sched->cmdQueue, (OSMesg)&audioMgr->audioTask, OS_MESG_BLOCK); Sched_SendEntryMsg(audioMgr->sched); } @@ -37,7 +36,7 @@ void AudioMgr_HandleRetrace(AudioMgr* audioMgr) { D_8016A558 += osGetTime() - D_8016A550; D_8016A550 = 0; if (audioMgr->rspTask != NULL) { - osRecvMesg(&audioMgr->unk_AC, NULL, OS_MESG_BLOCK); + osRecvMesg(&audioMgr->taskQueue, NULL, OS_MESG_BLOCK); func_800C3C80(audioMgr); } audioMgr->rspTask = rspTask; @@ -58,16 +57,16 @@ void AudioMgr_ThreadEntry(void* arg0) { Audio_Init(); AudioLoad_SetDmaHandler(DmaMgr_DmaHandler); Audio_InitSound(); - osSendMesg(&audioMgr->unk_C8, NULL, OS_MESG_BLOCK); - IrqMgr_AddClient(audioMgr->irqMgr, &irqClient, &audioMgr->unk_74); + osSendMesg(&audioMgr->lockQueue, NULL, OS_MESG_BLOCK); + IrqMgr_AddClient(audioMgr->irqMgr, &irqClient, &audioMgr->interruptQueue); while (true) { - osRecvMesg(&audioMgr->unk_74, (OSMesg*)&msg, OS_MESG_BLOCK); + osRecvMesg(&audioMgr->interruptQueue, (OSMesg*)&msg, OS_MESG_BLOCK); switch (*msg) { case OS_SC_RETRACE_MSG: AudioMgr_HandleRetrace(audioMgr); - while (audioMgr->unk_74.validCount != 0) { - osRecvMesg(&audioMgr->unk_74, (OSMesg*)&msg, OS_MESG_BLOCK); + while (!MQ_IS_EMPTY(&audioMgr->interruptQueue)) { + osRecvMesg(&audioMgr->interruptQueue, (OSMesg*)&msg, OS_MESG_BLOCK); switch (*msg) { case OS_SC_RETRACE_MSG: break; @@ -85,7 +84,7 @@ void AudioMgr_ThreadEntry(void* arg0) { } void AudioMgr_Unlock(AudioMgr* audioMgr) { - osRecvMesg(&audioMgr->unk_C8, NULL, OS_MESG_BLOCK); + osRecvMesg(&audioMgr->lockQueue, NULL, OS_MESG_BLOCK); } void AudioMgr_Init(AudioMgr* audioMgr, void* stack, OSPri pri, OSId id, SchedContext* sched, IrqMgr* irqMgr) { @@ -95,12 +94,12 @@ void AudioMgr_Init(AudioMgr* audioMgr, void* stack, OSPri pri, OSId id, SchedCon audioMgr->irqMgr = irqMgr; audioMgr->rspTask = NULL; - osCreateMesgQueue(&audioMgr->unk_AC, &audioMgr->unk_C4, 1); - osCreateMesgQueue(&audioMgr->unk_74, &audioMgr->unk_8C, 8); - osCreateMesgQueue(&audioMgr->unk_C8, &audioMgr->unk_E0, 1); + osCreateMesgQueue(&audioMgr->taskQueue, audioMgr->taskMsgBuf, ARRAY_COUNT(audioMgr->taskMsgBuf)); + osCreateMesgQueue(&audioMgr->interruptQueue, audioMgr->interruptMsgBuf, ARRAY_COUNT(audioMgr->interruptMsgBuf)); + osCreateMesgQueue(&audioMgr->lockQueue, audioMgr->lockMsgBuf, ARRAY_COUNT(audioMgr->lockMsgBuf)); - osSendMesg(&audioMgr->unk_AC, NULL, OS_MESG_BLOCK); + osSendMesg(&audioMgr->taskQueue, NULL, OS_MESG_BLOCK); - osCreateThread(&audioMgr->unk_E8, id, AudioMgr_ThreadEntry, audioMgr, stack, pri); - osStartThread(&audioMgr->unk_E8); + osCreateThread(&audioMgr->thread, id, AudioMgr_ThreadEntry, audioMgr, stack, pri); + osStartThread(&audioMgr->thread); } diff --git a/src/code/audio_load.c b/src/code/audio_load.c index 21655c0f9d..092ae1d3f6 100644 --- a/src/code/audio_load.c +++ b/src/code/audio_load.c @@ -58,7 +58,7 @@ void AudioLoad_ProcessSlowLoads(s32 resetStatus); void AudioLoad_DmaSlowCopyUnkMedium(s32 devAddr, u8* ramAddr, s32 size, s32 arg3); OSMesgQueue sScriptLoadQueue; -OSMesg sScriptLoadMesgBuf[0x10]; +OSMesg sScriptLoadMsgBuf[16]; s8* sScriptLoadDonePointers[0x10]; s32 sAudioLoadPad1[2]; // file padding @@ -193,7 +193,7 @@ void* AudioLoad_DmaSampleData(u32 devAddr, u32 size, s32 arg2, u8* dmaIndexRef, dma->ttl = 3; dma->devAddr = dmaDevAddr; dma->sizeUnused = transfer; - AudioLoad_Dma(&gAudioContext.currAudioFrameDmaIoMesgBuf[gAudioContext.curAudioFrameDmaCount++], OS_MESG_PRI_NORMAL, + AudioLoad_Dma(&gAudioContext.currAudioFrameDmaIoMsgBuf[gAudioContext.curAudioFrameDmaCount++], OS_MESG_PRI_NORMAL, OS_READ, dmaDevAddr, dma->ramAddr, transfer, &gAudioContext.currAudioFrameDmaQueue, medium, "SUPERDMA"); *dmaIndexRef = dmaIndex; @@ -442,7 +442,7 @@ s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId) { void AudioLoad_AsyncLoad(s32 tableType, s32 id, s32 nChunks, s32 retData, OSMesgQueue* retQueue) { if (AudioLoad_AsyncLoadInner(tableType, id, nChunks, retData, retQueue) == NULL) { - osSendMesg(retQueue, 0xFFFFFFFF, OS_MESG_NOBLOCK); + osSendMesg(retQueue, (OSMesg)0xFFFFFFFF, OS_MESG_NOBLOCK); } } @@ -967,7 +967,7 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData, ret = AudioLoad_SearchCaches(tableType, realId); if (ret != NULL) { status = 2; - osSendMesg(retQueue, MK_ASYNC_MSG(retData, 0, 0, 0), OS_MESG_NOBLOCK); + osSendMesg(retQueue, (OSMesg)MK_ASYNC_MSG(retData, 0, 0, 0), OS_MESG_NOBLOCK); } else { sp50 = AudioLoad_GetLoadTable(tableType); size = sp50->entries[realId].size; @@ -1106,11 +1106,12 @@ void AudioLoad_Init(void* heap, u32 heapSize) { gAudioContext.rspTask[0].task.t.data_size = 0; gAudioContext.rspTask[1].task.t.data_size = 0; osCreateMesgQueue(&gAudioContext.syncDmaQueue, &gAudioContext.syncDmaMesg, 1); - osCreateMesgQueue(&gAudioContext.currAudioFrameDmaQueue, gAudioContext.currAudioFrameDmaMesgBuf, 0x40); - osCreateMesgQueue(&gAudioContext.externalLoadQueue, gAudioContext.externalLoadMesgBuf, - ARRAY_COUNT(gAudioContext.externalLoadMesgBuf)); - osCreateMesgQueue(&gAudioContext.preloadSampleQueue, gAudioContext.preloadSampleMesgBuf, - ARRAY_COUNT(gAudioContext.externalLoadMesgBuf)); + osCreateMesgQueue(&gAudioContext.currAudioFrameDmaQueue, gAudioContext.currAudioFrameDmaMsgBuf, + ARRAY_COUNT(gAudioContext.currAudioFrameDmaMsgBuf)); + osCreateMesgQueue(&gAudioContext.externalLoadQueue, gAudioContext.externalLoadMsgBuf, + ARRAY_COUNT(gAudioContext.externalLoadMsgBuf)); + osCreateMesgQueue(&gAudioContext.preloadSampleQueue, gAudioContext.preloadSampleMsgBuf, + ARRAY_COUNT(gAudioContext.externalLoadMsgBuf)); gAudioContext.curAudioFrameDmaCount = 0; gAudioContext.sampleDmaCount = 0; gAudioContext.cartHandle = osCartRomInit(); @@ -1161,7 +1162,7 @@ void AudioLoad_Init(void* heap, u32 heapSize) { AudioHeap_AllocPoolInit(&gAudioContext.permanentPool, temp_v0_3, D_8014A6C4.permanentPoolSize); gAudioContextInitalized = true; - osSendMesg(gAudioContext.taskStartQueueP, (void*)gAudioContext.totalTaskCnt, OS_MESG_NOBLOCK); + osSendMesg(gAudioContext.taskStartQueueP, (OSMesg)gAudioContext.totalTaskCnt, OS_MESG_NOBLOCK); } void AudioLoad_InitSlowLoads(void) { @@ -1273,7 +1274,7 @@ void AudioLoad_ProcessSlowLoads(s32 resetStatus) { switch (gAudioContext.slowLoads[i].status) { case LOAD_STATUS_LOADING: if (slowLoad->medium != MEDIUM_UNK) { - osRecvMesg(&slowLoad->msgqueue, NULL, OS_MESG_BLOCK); + osRecvMesg(&slowLoad->msgQueue, NULL, OS_MESG_BLOCK); } if (resetStatus != 0) { @@ -1313,9 +1314,9 @@ void AudioLoad_ProcessSlowLoads(s32 resetStatus) { void AudioLoad_DmaSlowCopy(AudioSlowLoad* slowLoad, s32 size) { Audio_InvalDCache(slowLoad->curRamAddr, size); - osCreateMesgQueue(&slowLoad->msgqueue, &slowLoad->msg, 1); + osCreateMesgQueue(&slowLoad->msgQueue, &slowLoad->msg, 1); AudioLoad_Dma(&slowLoad->ioMesg, OS_MESG_PRI_NORMAL, 0, slowLoad->curDevAddr, slowLoad->curRamAddr, size, - &slowLoad->msgqueue, slowLoad->medium, "SLOWCOPY"); + &slowLoad->msgQueue, slowLoad->medium, "SLOWCOPY"); } void AudioLoad_DmaSlowCopyUnkMedium(s32 devAddr, u8* ramAddr, s32 size, s32 arg3) { @@ -1376,7 +1377,7 @@ AudioAsyncLoad* AudioLoad_StartAsyncLoadUnkMedium(s32 unkMediumParam, u32 devAdd return NULL; } - osSendMesg(&gAudioContext.asyncLoadUnkMediumQueue, asyncLoad, OS_MESG_NOBLOCK); + osSendMesg(&gAudioContext.asyncLoadUnkMediumQueue, (OSMesg)asyncLoad, OS_MESG_NOBLOCK); asyncLoad->unkMediumParam = unkMediumParam; return asyncLoad; } @@ -2017,5 +2018,5 @@ void AudioLoad_ProcessScriptLoads(void) { } void AudioLoad_InitScriptLoads(void) { - osCreateMesgQueue(&sScriptLoadQueue, sScriptLoadMesgBuf, ARRAY_COUNT(sScriptLoadMesgBuf)); + osCreateMesgQueue(&sScriptLoadQueue, sScriptLoadMsgBuf, ARRAY_COUNT(sScriptLoadMsgBuf)); } diff --git a/src/code/code_800E4FE0.c b/src/code/code_800E4FE0.c index 8a1ed54b16..4d3d8afb4f 100644 --- a/src/code/code_800E4FE0.c +++ b/src/code/code_800E4FE0.c @@ -67,7 +67,7 @@ AudioTask* func_800E5000(void) { } } - osSendMesg(gAudioContext.taskStartQueueP, gAudioContext.totalTaskCnt, OS_MESG_NOBLOCK); + osSendMesg(gAudioContext.taskStartQueueP, (OSMesg)gAudioContext.totalTaskCnt, OS_MESG_NOBLOCK); gAudioContext.rspTaskIdx ^= 1; gAudioContext.curAIBufIdx++; gAudioContext.curAIBufIdx %= 3; @@ -99,7 +99,7 @@ AudioTask* func_800E5000(void) { } } - sp48 = gAudioContext.currAudioFrameDmaQueue.validCount; + sp48 = MQ_GET_COUNT(&gAudioContext.currAudioFrameDmaQueue); if (sp48 != 0) { for (i = 0; i < sp48; i++) { osRecvMesg(&gAudioContext.currAudioFrameDmaQueue, NULL, OS_MESG_NOBLOCK); @@ -114,7 +114,8 @@ AudioTask* func_800E5000(void) { if (gAudioContext.resetStatus != 0) { if (AudioHeap_ResetStep() == 0) { if (gAudioContext.resetStatus == 0) { - osSendMesg(gAudioContext.audioResetQueueP, gAudioContext.audioResetSpecIdToLoad, OS_MESG_NOBLOCK); + osSendMesg(gAudioContext.audioResetQueueP, (OSMesg)(u32)gAudioContext.audioResetSpecIdToLoad, + OS_MESG_NOBLOCK); } sWaitingAudioTask = NULL; @@ -171,7 +172,7 @@ AudioTask* func_800E5000(void) { gWaveSamples[8] = (s16*)(((u8*)func_800E4FE0) + (gAudioContext.audioRandom & 0xFFF0)); index = gAudioContext.rspTaskIdx; - gAudioContext.currTask->taskQueue = NULL; + gAudioContext.currTask->msgQueue = NULL; gAudioContext.currTask->unk_44 = NULL; task = &gAudioContext.currTask->task.t; @@ -348,11 +349,12 @@ void Audio_InitMesgQueuesInternal(void) { gAudioContext.taskStartQueueP = &gAudioContext.taskStartQueue; gAudioContext.cmdProcQueueP = &gAudioContext.cmdProcQueue; gAudioContext.audioResetQueueP = &gAudioContext.audioResetQueue; - osCreateMesgQueue(gAudioContext.taskStartQueueP, gAudioContext.taskStartMsgs, - ARRAY_COUNT(gAudioContext.taskStartMsgs)); - osCreateMesgQueue(gAudioContext.cmdProcQueueP, gAudioContext.cmdProcMsgs, ARRAY_COUNT(gAudioContext.cmdProcMsgs)); - osCreateMesgQueue(gAudioContext.audioResetQueueP, gAudioContext.audioResetMesgs, - ARRAY_COUNT(gAudioContext.audioResetMesgs)); + osCreateMesgQueue(gAudioContext.taskStartQueueP, gAudioContext.taskStartMsgBuf, + ARRAY_COUNT(gAudioContext.taskStartMsgBuf)); + osCreateMesgQueue(gAudioContext.cmdProcQueueP, gAudioContext.cmdProcMsgBuf, + ARRAY_COUNT(gAudioContext.cmdProcMsgBuf)); + osCreateMesgQueue(gAudioContext.audioResetQueueP, gAudioContext.audioResetMsgBuf, + ARRAY_COUNT(gAudioContext.audioResetMsgBuf)); } void Audio_QueueCmd(u32 opArgs, void** data) { @@ -398,7 +400,7 @@ s32 Audio_ScheduleProcessCmds(void) { ret = osSendMesg(gAudioContext.cmdProcQueueP, - (void*)(((gAudioContext.cmdRdPos & 0xFF) << 8) | (gAudioContext.cmdWrPos & 0xFF)), OS_MESG_NOBLOCK); + (OSMesg)(((gAudioContext.cmdRdPos & 0xFF) << 8) | (gAudioContext.cmdWrPos & 0xFF)), OS_MESG_NOBLOCK); if (ret != -1) { gAudioContext.cmdRdPos = gAudioContext.cmdWrPos; ret = 0; @@ -514,7 +516,7 @@ s32 func_800E5EDC(void) { void func_800E5F34(void) { // macro? // clang-format off - s32 chk = -1; s32 sp28; do {} while (osRecvMesg(gAudioContext.audioResetQueueP, (OSMesg*)&sp28, OS_MESG_NOBLOCK) != chk); + s32 chk = -1; OSMesg msg; do {} while (osRecvMesg(gAudioContext.audioResetQueueP, &msg, OS_MESG_NOBLOCK) != chk); // clang-format on } diff --git a/src/code/fault.c b/src/code/fault.c index d1cd9627ae..e03c94d591 100644 --- a/src/code/fault.c +++ b/src/code/fault.c @@ -128,8 +128,8 @@ void Fault_ClientRunTask(FaultClientTask* task) { // Run the fault client callback on a separate thread thread = alloca(sizeof(OSThread)); - osCreateThread(thread, 2, Fault_ClientProcessThread, task, sFaultInstance->clientThreadSp, - OS_PRIORITY_APPMAX - 1); + osCreateThread(thread, THREAD_ID_FAULT, Fault_ClientProcessThread, task, sFaultInstance->clientThreadSp, + THREAD_PRI_FAULT_CLIENT); osStartThread(thread); } else { // Run the fault client callback on this thread @@ -1265,7 +1265,8 @@ void Fault_Init(void) { gFaultMgr.faultHandlerEnabled = true; osCreateMesgQueue(&sFaultInstance->queue, &sFaultInstance->msg, 1); StackCheck_Init(&sFaultThreadInfo, &sFaultStack, STACK_TOP(sFaultStack), 0, 0x100, "fault"); - osCreateThread(&sFaultInstance->thread, 2, Fault_ThreadEntry, 0, STACK_TOP(sFaultStack), OS_PRIORITY_APPMAX); + osCreateThread(&sFaultInstance->thread, THREAD_ID_FAULT, Fault_ThreadEntry, 0, STACK_TOP(sFaultStack), + THREAD_PRI_FAULT); osStartThread(&sFaultInstance->thread); } diff --git a/src/code/graph.c b/src/code/graph.c index c178fa9e81..ecb6eb5067 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -227,7 +227,7 @@ void Graph_TaskSet00(GraphicsContext* gfxCtx) { gfxCtx->fbIdx--; } - scTask->msgQ = &gfxCtx->queue; + scTask->msgQueue = &gfxCtx->queue; scTask->msg = NULL; cfb = &sGraphCfbInfos[sGraphCfbInfoIdx++]; @@ -245,9 +245,9 @@ void Graph_TaskSet00(GraphicsContext* gfxCtx) { if (1) {} - gfxCtx->schedMsgQ = &gSchedContext.cmdQ; + gfxCtx->schedMsgQueue = &gSchedContext.cmdQueue; - osSendMesg(&gSchedContext.cmdQ, scTask, OS_MESG_BLOCK); + osSendMesg(&gSchedContext.cmdQueue, (OSMesg)scTask, OS_MESG_BLOCK); Sched_SendEntryMsg(&gSchedContext); } diff --git a/src/code/irqmgr.c b/src/code/irqmgr.c index 9df7563d81..d29be50823 100644 --- a/src/code/irqmgr.c +++ b/src/code/irqmgr.c @@ -50,18 +50,18 @@ u32 sIrqMgrRetraceCount = 0; * * @param irqMgr the IrqMgr instance to register with. * @param client client to register. - * @param msgQ message queue to send notifications of interrupts to, associated with the client. + * @param msgQueue message queue to send notifications of interrupts to, associated with the client. */ -void IrqMgr_AddClient(IrqMgr* irqMgr, IrqMgrClient* client, OSMesgQueue* msgQ) { +void IrqMgr_AddClient(IrqMgr* irqMgr, IrqMgrClient* client, OSMesgQueue* msgQueue) { OSIntMask prevInt; LogUtils_CheckNullPointer("this", irqMgr, "../irqmgr.c", 96); LogUtils_CheckNullPointer("c", client, "../irqmgr.c", 97); - LogUtils_CheckNullPointer("msgQ", msgQ, "../irqmgr.c", 98); + LogUtils_CheckNullPointer("msgQ", msgQueue, "../irqmgr.c", 98); prevInt = osSetIntMask(OS_IM_NONE); - client->queue = msgQ; + client->queue = msgQueue; client->prev = irqMgr->clients; irqMgr->clients = client; @@ -298,6 +298,6 @@ void IrqMgr_Init(IrqMgr* irqMgr, void* stack, OSPri pri, u8 retraceCount) { osCreateMesgQueue(&irqMgr->queue, irqMgr->msgBuf, ARRAY_COUNT(irqMgr->msgBuf)); osSetEventMesg(OS_EVENT_PRENMI, &irqMgr->queue, (OSMesg)IRQ_PRENMI_MSG); osViSetEvent(&irqMgr->queue, (OSMesg)IRQ_RETRACE_MSG, retraceCount); - osCreateThread(&irqMgr->thread, 19, IrqMgr_ThreadEntry, irqMgr, stack, pri); + osCreateThread(&irqMgr->thread, THREAD_ID_IRQMGR, IrqMgr_ThreadEntry, irqMgr, stack, pri); osStartThread(&irqMgr->thread); } diff --git a/src/code/main.c b/src/code/main.c index 775ba3e723..9794054c75 100644 --- a/src/code/main.c +++ b/src/code/main.c @@ -22,8 +22,8 @@ StackEntry sAudioStackInfo; StackEntry sPadMgrStackInfo; StackEntry sIrqMgrStackInfo; AudioMgr gAudioMgr; -OSMesgQueue sSiIntMsgQ; -OSMesg sSiIntMsgBuf[1]; +OSMesgQueue sSerialEventQueue; +OSMesg sSerialMsgBuf[1]; void Main_LogSystemHeap(void) { osSyncPrintf(VT_FGCOL(GREEN)); @@ -35,7 +35,7 @@ void Main_LogSystemHeap(void) { void Main(void* arg) { IrqMgrClient irqClient; - OSMesgQueue irqMgrMsgQ; + OSMesgQueue irqMgrMsgQueue; OSMesg irqMgrMsgBuf[60]; u32 systemHeapStart; u32 fb; @@ -69,37 +69,38 @@ void Main(void* arg) { R_ENABLE_ARENA_DBG = 0; - osCreateMesgQueue(&sSiIntMsgQ, sSiIntMsgBuf, ARRAY_COUNT(sSiIntMsgBuf)); - osSetEventMesg(OS_EVENT_SI, &sSiIntMsgQ, NULL); + osCreateMesgQueue(&sSerialEventQueue, sSerialMsgBuf, ARRAY_COUNT(sSerialMsgBuf)); + osSetEventMesg(OS_EVENT_SI, &sSerialEventQueue, NULL); Main_LogSystemHeap(); - osCreateMesgQueue(&irqMgrMsgQ, irqMgrMsgBuf, ARRAY_COUNT(irqMgrMsgBuf)); + osCreateMesgQueue(&irqMgrMsgQueue, irqMgrMsgBuf, ARRAY_COUNT(irqMgrMsgBuf)); StackCheck_Init(&sIrqMgrStackInfo, sIrqMgrStack, STACK_TOP(sIrqMgrStack), 0, 0x100, "irqmgr"); - IrqMgr_Init(&gIrqMgr, STACK_TOP(sIrqMgrStack), Z_PRIORITY_IRQMGR, 1); + IrqMgr_Init(&gIrqMgr, STACK_TOP(sIrqMgrStack), THREAD_PRI_IRQMGR, 1); osSyncPrintf("タスクスケジューラの初期化\n"); // "Initialize the task scheduler" StackCheck_Init(&sSchedStackInfo, sSchedStack, STACK_TOP(sSchedStack), 0, 0x100, "sched"); - Sched_Init(&gSchedContext, STACK_TOP(sSchedStack), Z_PRIORITY_SCHED, D_80013960, 1, &gIrqMgr); + Sched_Init(&gSchedContext, STACK_TOP(sSchedStack), THREAD_PRI_SCHED, D_80013960, 1, &gIrqMgr); - IrqMgr_AddClient(&gIrqMgr, &irqClient, &irqMgrMsgQ); + IrqMgr_AddClient(&gIrqMgr, &irqClient, &irqMgrMsgQueue); StackCheck_Init(&sAudioStackInfo, sAudioStack, STACK_TOP(sAudioStack), 0, 0x100, "audio"); - AudioMgr_Init(&gAudioMgr, STACK_TOP(sAudioStack), Z_PRIORITY_AUDIOMGR, 10, &gSchedContext, &gIrqMgr); + AudioMgr_Init(&gAudioMgr, STACK_TOP(sAudioStack), THREAD_PRI_AUDIOMGR, THREAD_ID_AUDIOMGR, &gSchedContext, + &gIrqMgr); StackCheck_Init(&sPadMgrStackInfo, sPadMgrStack, STACK_TOP(sPadMgrStack), 0, 0x100, "padmgr"); - PadMgr_Init(&gPadMgr, &sSiIntMsgQ, &gIrqMgr, 7, Z_PRIORITY_PADMGR, STACK_TOP(sPadMgrStack)); + PadMgr_Init(&gPadMgr, &sSerialEventQueue, &gIrqMgr, THREAD_ID_PADMGR, THREAD_PRI_PADMGR, STACK_TOP(sPadMgrStack)); AudioMgr_Unlock(&gAudioMgr); StackCheck_Init(&sGraphStackInfo, sGraphStack, STACK_TOP(sGraphStack), 0, 0x100, "graph"); - osCreateThread(&sGraphThread, 4, Graph_ThreadEntry, arg, STACK_TOP(sGraphStack), Z_PRIORITY_GRAPH); + osCreateThread(&sGraphThread, THREAD_ID_GRAPH, Graph_ThreadEntry, arg, STACK_TOP(sGraphStack), THREAD_PRI_GRAPH); osStartThread(&sGraphThread); - osSetThreadPri(NULL, 15); + osSetThreadPri(NULL, THREAD_PRI_MAIN); while (true) { msg = NULL; - osRecvMesg(&irqMgrMsgQ, (OSMesg)&msg, OS_MESG_BLOCK); + osRecvMesg(&irqMgrMsgQueue, (OSMesg*)&msg, OS_MESG_BLOCK); if (msg == NULL) { break; } diff --git a/src/code/padmgr.c b/src/code/padmgr.c index 68c34d369c..160a5301f9 100644 --- a/src/code/padmgr.c +++ b/src/code/padmgr.c @@ -4,47 +4,47 @@ s32 D_8012D280 = 1; OSMesgQueue* PadMgr_LockSerialMesgQueue(PadMgr* padMgr) { - OSMesgQueue* ctrlrQ = NULL; + OSMesgQueue* serialEventQueue = NULL; if (D_8012D280 > 2) { // "serialMsgQ Waiting for lock" osSyncPrintf("%2d %d serialMsgQロック待ち %08x %08x %08x\n", osGetThreadId(NULL), - padMgr->serialMsgQ.validCount, padMgr, &padMgr->serialMsgQ, &ctrlrQ); + MQ_GET_COUNT(&padMgr->serialLockQueue), padMgr, &padMgr->serialLockQueue, &serialEventQueue); } - osRecvMesg(&padMgr->serialMsgQ, (OSMesg)&ctrlrQ, OS_MESG_BLOCK); + osRecvMesg(&padMgr->serialLockQueue, (OSMesg*)&serialEventQueue, OS_MESG_BLOCK); if (D_8012D280 > 2) { // "serialMsgQ Locked" osSyncPrintf("%2d %d serialMsgQをロックしました %08x\n", osGetThreadId(NULL), - padMgr->serialMsgQ.validCount, ctrlrQ); + MQ_GET_COUNT(&padMgr->serialLockQueue), serialEventQueue); } - return ctrlrQ; + return serialEventQueue; } -void PadMgr_UnlockSerialMesgQueue(PadMgr* padMgr, OSMesgQueue* ctrlrQ) { +void PadMgr_UnlockSerialMesgQueue(PadMgr* padMgr, OSMesgQueue* serialEventQueue) { if (D_8012D280 > 2) { // "serialMsgQ Unlock" osSyncPrintf("%2d %d serialMsgQロック解除します %08x %08x %08x\n", osGetThreadId(NULL), - padMgr->serialMsgQ.validCount, padMgr, &padMgr->serialMsgQ, ctrlrQ); + MQ_GET_COUNT(&padMgr->serialLockQueue), padMgr, &padMgr->serialLockQueue, serialEventQueue); } - osSendMesg(&padMgr->serialMsgQ, ctrlrQ, OS_MESG_BLOCK); + osSendMesg(&padMgr->serialLockQueue, (OSMesg)serialEventQueue, OS_MESG_BLOCK); if (D_8012D280 > 2) { // "serialMsgQ Unlocked" osSyncPrintf("%2d %d serialMsgQロック解除しました %08x %08x %08x\n", osGetThreadId(NULL), - padMgr->serialMsgQ.validCount, padMgr, &padMgr->serialMsgQ, ctrlrQ); + MQ_GET_COUNT(&padMgr->serialLockQueue), padMgr, &padMgr->serialLockQueue, serialEventQueue); } } void PadMgr_LockPadData(PadMgr* padMgr) { - osRecvMesg(&padMgr->lockMsgQ, NULL, OS_MESG_BLOCK); + osRecvMesg(&padMgr->lockQueue, NULL, OS_MESG_BLOCK); } void PadMgr_UnlockPadData(PadMgr* padMgr) { - osSendMesg(&padMgr->lockMsgQ, NULL, OS_MESG_BLOCK); + osSendMesg(&padMgr->lockQueue, NULL, OS_MESG_BLOCK); } void PadMgr_RumbleControl(PadMgr* padMgr) { @@ -52,7 +52,7 @@ void PadMgr_RumbleControl(PadMgr* padMgr) { static u32 frame; s32 temp = 1; s32 triedRumbleComm; - OSMesgQueue* ctrlrQ = PadMgr_LockSerialMesgQueue(padMgr); + OSMesgQueue* serialEventQueue = PadMgr_LockSerialMesgQueue(padMgr); s32 var4; s32 i; @@ -133,7 +133,7 @@ void PadMgr_RumbleControl(PadMgr* padMgr) { i = frame % 4; if (padMgr->ctrlrIsConnected[i] && (padMgr->padStatus[i].status & 1) && (padMgr->pakType[i] != 1)) { - var4 = osMotorInit(ctrlrQ, &padMgr->pfs[i], i); + var4 = osMotorInit(serialEventQueue, &padMgr->pfs[i], i); if (var4 == 0) { padMgr->pakType[i] = 1; @@ -156,15 +156,15 @@ void PadMgr_RumbleControl(PadMgr* padMgr) { } frame++; - PadMgr_UnlockSerialMesgQueue(padMgr, ctrlrQ); + PadMgr_UnlockSerialMesgQueue(padMgr, serialEventQueue); } void PadMgr_RumbleStop(PadMgr* padMgr) { s32 i; - OSMesgQueue* ctrlrQ = PadMgr_LockSerialMesgQueue(padMgr); + OSMesgQueue* serialEventQueue = PadMgr_LockSerialMesgQueue(padMgr); for (i = 0; i < 4; i++) { - if (osMotorInit(ctrlrQ, &padMgr->pfs[i], i) == 0) { + if (osMotorInit(serialEventQueue, &padMgr->pfs[i], i) == 0) { if ((gFaultMgr.msgId == 0) && (padMgr->rumbleOnFrames != 0)) { osSyncPrintf(VT_FGCOL(YELLOW)); // "Stop vibration pack" @@ -176,7 +176,7 @@ void PadMgr_RumbleStop(PadMgr* padMgr) { } } - PadMgr_UnlockSerialMesgQueue(padMgr, ctrlrQ); + PadMgr_UnlockSerialMesgQueue(padMgr, serialEventQueue); } void PadMgr_RumbleReset(PadMgr* padMgr) { @@ -265,23 +265,23 @@ void PadMgr_ProcessInputs(PadMgr* padMgr) { void PadMgr_HandleRetraceMsg(PadMgr* padMgr) { s32 i; - OSMesgQueue* queue = PadMgr_LockSerialMesgQueue(padMgr); + OSMesgQueue* serialEventQueue = PadMgr_LockSerialMesgQueue(padMgr); u32 mask; - osContStartReadData(queue); + osContStartReadData(serialEventQueue); if (padMgr->retraceCallback) { padMgr->retraceCallback(padMgr, padMgr->retraceCallbackValue); } - osRecvMesg(queue, NULL, OS_MESG_BLOCK); + osRecvMesg(serialEventQueue, NULL, OS_MESG_BLOCK); osContGetReadData(padMgr->pads); if (padMgr->preNMIShutdown) { bzero(padMgr->pads, sizeof(padMgr->pads)); } PadMgr_ProcessInputs(padMgr); - osContStartQuery(queue); - osRecvMesg(queue, NULL, OS_MESG_BLOCK); + osContStartQuery(serialEventQueue); + osRecvMesg(serialEventQueue, NULL, OS_MESG_BLOCK); osContGetQuery(padMgr->padStatus); - PadMgr_UnlockSerialMesgQueue(padMgr, queue); + PadMgr_UnlockSerialMesgQueue(padMgr, serialEventQueue); mask = 0; for (i = 0; i < 4; i++) { @@ -351,22 +351,22 @@ void PadMgr_RequestPadData(PadMgr* padMgr, Input* inputs, s32 mode) { } void PadMgr_ThreadEntry(PadMgr* padMgr) { - s16* mesg = NULL; + s16* msg = NULL; s32 exit; osSyncPrintf("コントローラスレッド実行開始\n"); // "Controller thread execution start" exit = false; while (!exit) { - if ((D_8012D280 > 2) && (padMgr->interruptMsgQ.validCount == 0)) { + if ((D_8012D280 > 2) && MQ_IS_EMPTY(&padMgr->interruptQueue)) { // "Waiting for controller thread event" osSyncPrintf("コントローラスレッドイベント待ち %lld\n", OS_CYCLES_TO_USEC(osGetTime())); } - osRecvMesg(&padMgr->interruptMsgQ, (OSMesg)&mesg, OS_MESG_BLOCK); - LogUtils_CheckNullPointer("msg", mesg, "../padmgr.c", 563); + osRecvMesg(&padMgr->interruptQueue, (OSMesg*)&msg, OS_MESG_BLOCK); + LogUtils_CheckNullPointer("msg", msg, "../padmgr.c", 563); - switch (*mesg) { + switch (*msg) { case OS_SC_RETRACE_MSG: if (D_8012D280 > 2) { osSyncPrintf("padmgr_HandleRetraceMsg START %lld\n", OS_CYCLES_TO_USEC(osGetTime())); @@ -393,19 +393,19 @@ void PadMgr_ThreadEntry(PadMgr* padMgr) { osSyncPrintf("コントローラスレッド実行終了\n"); // "Controller thread execution end" } -void PadMgr_Init(PadMgr* padMgr, OSMesgQueue* siIntMsgQ, IrqMgr* irqMgr, OSId id, OSPri priority, void* stack) { +void PadMgr_Init(PadMgr* padMgr, OSMesgQueue* serialEventQueue, IrqMgr* irqMgr, OSId id, OSPri priority, void* stack) { osSyncPrintf("パッドマネージャ作成 padmgr_Create()\n"); // "Pad Manager creation" bzero(padMgr, sizeof(PadMgr)); padMgr->irqMgr = irqMgr; - osCreateMesgQueue(&padMgr->interruptMsgQ, padMgr->interruptMsgBuf, 4); - IrqMgr_AddClient(padMgr->irqMgr, &padMgr->irqClient, &padMgr->interruptMsgQ); - osCreateMesgQueue(&padMgr->serialMsgQ, padMgr->serialMsgBuf, 1); - PadMgr_UnlockSerialMesgQueue(padMgr, siIntMsgQ); - osCreateMesgQueue(&padMgr->lockMsgQ, padMgr->lockMsgBuf, 1); + osCreateMesgQueue(&padMgr->interruptQueue, padMgr->interruptMsgBuf, ARRAY_COUNT(padMgr->interruptMsgBuf)); + IrqMgr_AddClient(padMgr->irqMgr, &padMgr->irqClient, &padMgr->interruptQueue); + osCreateMesgQueue(&padMgr->serialLockQueue, padMgr->serialLockMsgBuf, ARRAY_COUNT(padMgr->serialLockMsgBuf)); + PadMgr_UnlockSerialMesgQueue(padMgr, serialEventQueue); + osCreateMesgQueue(&padMgr->lockQueue, padMgr->lockMsgBuf, ARRAY_COUNT(padMgr->lockMsgBuf)); PadMgr_UnlockPadData(padMgr); - PadSetup_Init(siIntMsgQ, (u8*)&padMgr->validCtrlrsMask, padMgr->padStatus); + PadSetup_Init(serialEventQueue, (u8*)&padMgr->validCtrlrsMask, padMgr->padStatus); padMgr->nControllers = 4; osContSetCh(padMgr->nControllers); diff --git a/src/code/sched.c b/src/code/sched.c index 504ed4c710..cdf22616e4 100644 --- a/src/code/sched.c +++ b/src/code/sched.c @@ -82,12 +82,12 @@ void Sched_HandleReset(SchedContext* sc) { if (sc->curRSPTask != NULL) { LOG_TIME("(((u64)(now - graph_rsp_start_time)*(1000000LL/15625LL))/((62500000LL*3/4)/15625LL))", OS_CYCLES_TO_USEC(now - sRSPGFXStartTime), "../sched.c", 427); - osSendMesg(&sc->interruptQ, RSP_DONE_MSG, OS_MESG_NOBLOCK); + osSendMesg(&sc->interruptQueue, (OSMesg)RSP_DONE_MSG, OS_MESG_NOBLOCK); } if (sc->curRDPTask != NULL) { LOG_TIME("(((u64)(now - rdp_start_time)*(1000000LL/15625LL))/((62500000LL*3/4)/15625LL))", OS_CYCLES_TO_USEC(now - sRDPStartTime), "../sched.c", 431); - osSendMesg(&sc->interruptQ, RDP_DONE_MSG, OS_MESG_NOBLOCK); + osSendMesg(&sc->interruptQueue, (OSMesg)RDP_DONE_MSG, OS_MESG_NOBLOCK); } } } @@ -231,8 +231,8 @@ void func_800C8BC4(SchedContext* sc, OSScTask* task) { u32 Sched_IsComplete(SchedContext* sc, OSScTask* task) { if (!(task->state & (OS_SC_DP | OS_SC_SP))) { - if (task->msgQ != NULL) { - osSendMesg(task->msgQ, task->msg, OS_MESG_BLOCK); + if (task->msgQueue != NULL) { + osSendMesg(task->msgQueue, task->msg, OS_MESG_BLOCK); } if (task->flags & OS_SC_SWAPBUFFER) { @@ -292,10 +292,10 @@ void Sched_HandleEntry(SchedContext* sc) { OSScTask* nextRSP = NULL; OSScTask* nextRDP = NULL; s32 state; - OSMesg msg = NULL; + OSScTask* task = NULL; - while (osRecvMesg(&sc->cmdQ, &msg, OS_MESG_NOBLOCK) != -1) { - Sched_QueueTask(sc, msg); + while (osRecvMesg(&sc->cmdQueue, (OSMesg*)&task, OS_MESG_NOBLOCK) != -1) { + Sched_QueueTask(sc, task); } if (sc->doAudio != 0 && sc->curRSPTask != NULL) { @@ -425,22 +425,20 @@ void Sched_SendEntryMsg(SchedContext* sc) { osSyncPrintf("osScKickEntryMsg\n"); } - osSendMesg(&sc->interruptQ, ENTRY_MSG, OS_MESG_BLOCK); + osSendMesg(&sc->interruptQueue, (OSMesg)ENTRY_MSG, OS_MESG_BLOCK); } void Sched_ThreadEntry(void* arg) { - void* msg; + OSMesg msg = NULL; SchedContext* sc = (SchedContext*)arg; - msg = NULL; - while (true) { if (sLogScheduler) { // "%08d: standby" osSyncPrintf("%08d:待機中\n", (u32)OS_CYCLES_TO_USEC(osGetTime())); } - osRecvMesg(&sc->interruptQ, &msg, OS_MESG_BLOCK); + osRecvMesg(&sc->interruptQueue, &msg, OS_MESG_BLOCK); switch ((s32)msg) { case ENTRY_MSG: @@ -461,8 +459,6 @@ void Sched_ThreadEntry(void* arg) { } Sched_HandleRDPDone(sc); continue; - default: - break; } switch (((OSScMsg*)msg)->type) { case 1: @@ -481,11 +477,11 @@ void Sched_ThreadEntry(void* arg) { void Sched_Init(SchedContext* sc, void* stack, OSPri priority, UNK_TYPE arg3, UNK_TYPE arg4, IrqMgr* irqMgr) { bzero(sc, sizeof(SchedContext)); sc->unk_24C = 1; - osCreateMesgQueue(&sc->interruptQ, sc->intBuf, 8); - osCreateMesgQueue(&sc->cmdQ, sc->cmdMsgBuf, 8); - osSetEventMesg(OS_EVENT_SP, &sc->interruptQ, RSP_DONE_MSG); - osSetEventMesg(OS_EVENT_DP, &sc->interruptQ, RDP_DONE_MSG); - IrqMgr_AddClient(irqMgr, &sc->irqClient, &sc->interruptQ); - osCreateThread(&sc->thread, 5, Sched_ThreadEntry, sc, stack, priority); + osCreateMesgQueue(&sc->interruptQueue, sc->interruptMsgBuf, ARRAY_COUNT(sc->interruptMsgBuf)); + osCreateMesgQueue(&sc->cmdQueue, sc->cmdMsgBuf, ARRAY_COUNT(sc->cmdMsgBuf)); + osSetEventMesg(OS_EVENT_SP, &sc->interruptQueue, RSP_DONE_MSG); + osSetEventMesg(OS_EVENT_DP, &sc->interruptQueue, RDP_DONE_MSG); + IrqMgr_AddClient(irqMgr, &sc->irqClient, &sc->interruptQueue); + osCreateThread(&sc->thread, THREAD_ID_SCHED, Sched_ThreadEntry, sc, stack, priority); osStartThread(&sc->thread); } diff --git a/src/code/speed_meter.c b/src/code/speed_meter.c index 7d768d090e..204ac000d3 100644 --- a/src/code/speed_meter.c +++ b/src/code/speed_meter.c @@ -70,12 +70,12 @@ void SpeedMeter_DrawTimeEntries(SpeedMeter* this, GraphicsContext* gfxCtx) { } View_Init(&view, gfxCtx); - view.flags = 0xA; + view.flags = VIEW_VIEWPORT | VIEW_PROJECTION_ORTHO; SET_FULLSCREEN_VIEWPORT(&view); gfx = OVERLAY_DISP; - func_800AB9EC(&view, 0xF, &gfx); + View_ApplyTo(&view, VIEW_ALL, &gfx); gDPPipeSync(gfx++); gDPSetOtherMode(gfx++, @@ -126,12 +126,12 @@ void SpeedMeter_DrawAllocEntry(SpeedMeterAllocEntry* this, GraphicsContext* gfxC OPEN_DISPS(gfxCtx, "../speed_meter.c", 318); View_Init(&view, gfxCtx); - view.flags = 0xA; + view.flags = VIEW_VIEWPORT | VIEW_PROJECTION_ORTHO; SET_FULLSCREEN_VIEWPORT(&view); gfx = OVERLAY_DISP; - func_800AB9EC(&view, 0xF, &gfx); + View_ApplyTo(&view, VIEW_ALL, &gfx); gDPPipeSync(gfx++); gDPSetOtherMode(gfx++, diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 47a0a218e9..2f23fd6b87 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -1319,7 +1319,7 @@ Gfx* func_8002E830(Vec3f* object, Vec3f* eye, Vec3f* lightDir, GraphicsContext* eye->x, eye->y, eye->z, object->x, object->y, object->z, lightDir->x, lightDir->y, lightDir->z); } - func_800ABE74(correctedEyeX, eye->y, eye->z); + View_ErrorCheckEyePosition(correctedEyeX, eye->y, eye->z); guLookAtHilite(&D_8015BBA8, lookAt, *hilite, correctedEyeX, eye->y, eye->z, object->x, object->y, object->z, 0.0f, 1.0f, 0.0f, lightDir->x, lightDir->y, lightDir->z, lightDir->x, lightDir->y, lightDir->z, 0x10, 0x10); diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 01080370be..55722ae3d7 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -5097,9 +5097,9 @@ s32 Camera_Unique9(Camera* camera) { anim->atTarget = anim->curKeyFrame->atTargetInit; } else if (atInitFlags == 2) { if (anim->isNewKeyFrame) { - anim->atTarget.x = camera->globalCtx->view.lookAt.x + anim->curKeyFrame->atTargetInit.x; - anim->atTarget.y = camera->globalCtx->view.lookAt.y + anim->curKeyFrame->atTargetInit.y; - anim->atTarget.z = camera->globalCtx->view.lookAt.z + anim->curKeyFrame->atTargetInit.z; + anim->atTarget.x = camera->globalCtx->view.at.x + anim->curKeyFrame->atTargetInit.x; + anim->atTarget.y = camera->globalCtx->view.at.y + anim->curKeyFrame->atTargetInit.y; + anim->atTarget.z = camera->globalCtx->view.at.z + anim->curKeyFrame->atTargetInit.z; } } else if (atInitFlags == 3) { if (anim->isNewKeyFrame) { @@ -7473,7 +7473,7 @@ Vec3s Camera_Update(Camera* camera) { if (gDbgCamEnabled) { camera->globalCtx->view.fovy = D_8015BD80.fov; DbCamera_Update(&D_8015BD80, camera); - func_800AA358(&camera->globalCtx->view, &D_8015BD80.eye, &D_8015BD80.at, &D_8015BD80.unk_1C); + View_LookAt(&camera->globalCtx->view, &D_8015BD80.eye, &D_8015BD80.at, &D_8015BD80.unk_1C); if (R_DBG_CAM_UPDATE) { osSyncPrintf("camera: debug out\n"); } @@ -7524,7 +7524,7 @@ Vec3s Camera_Update(Camera* camera) { View_SetScale(&camera->globalCtx->view, 1.0f); } camera->globalCtx->view.fovy = viewFov; - func_800AA358(&camera->globalCtx->view, &viewEye, &viewAt, &viewUp); + View_LookAt(&camera->globalCtx->view, &viewEye, &viewAt, &viewUp); camera->camDir.x = eyeAtAngle.pitch; camera->camDir.y = eyeAtAngle.yaw; camera->camDir.z = 0; diff --git a/src/code/z_jpeg.c b/src/code/z_jpeg.c index 6f57e12ace..fbb4dc6f60 100644 --- a/src/code/z_jpeg.c +++ b/src/code/z_jpeg.c @@ -55,12 +55,12 @@ void Jpeg_ScheduleDecoderTask(JpegContext* ctx) { ctx->scTask.next = NULL; ctx->scTask.flags = OS_SC_NEEDS_RSP; - ctx->scTask.msgQ = &ctx->mq; + ctx->scTask.msgQueue = &ctx->mq; ctx->scTask.msg = NULL; ctx->scTask.framebuffer = NULL; ctx->scTask.list.t = sJpegTask; - osSendMesg(&gSchedContext.cmdQ, (OSMesg)&ctx->scTask, OS_MESG_BLOCK); + osSendMesg(&gSchedContext.cmdQueue, (OSMesg)&ctx->scTask, OS_MESG_BLOCK); Sched_SendEntryMsg(&gSchedContext); // osScKickEntryMsg osRecvMesg(&ctx->mq, NULL, OS_MESG_BLOCK); } diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index 62dba8d28c..68593c156b 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -731,11 +731,11 @@ void Environment_UpdateSkybox(u8 skyboxId, EnvironmentContext* envCtx, SkyboxCon } if ((envCtx->skyboxDmaState == SKYBOX_DMA_FILE1_START) || (envCtx->skyboxDmaState == SKYBOX_DMA_FILE2_START)) { - if (osRecvMesg(&envCtx->loadQueue, 0, OS_MESG_NOBLOCK) == 0) { + if (osRecvMesg(&envCtx->loadQueue, NULL, OS_MESG_NOBLOCK) == 0) { envCtx->skyboxDmaState++; } } else if (envCtx->skyboxDmaState >= SKYBOX_DMA_FILE1_DONE) { - if (osRecvMesg(&envCtx->loadQueue, 0, OS_MESG_NOBLOCK) == 0) { + if (osRecvMesg(&envCtx->loadQueue, NULL, OS_MESG_NOBLOCK) == 0) { envCtx->skyboxDmaState = SKYBOX_DMA_INACTIVE; } } @@ -1408,9 +1408,9 @@ void Environment_DrawLensFlare(GlobalContext* globalCtx, EnvironmentContext* env dist = Math3D_Vec3f_DistXYZ(&pos, &view->eye) / 12.0f; // compute a unit vector in the look direction - tempX = view->lookAt.x - view->eye.x; - tempY = view->lookAt.y - view->eye.y; - tempZ = view->lookAt.z - view->eye.z; + tempX = view->at.x - view->eye.x; + tempY = view->at.y - view->eye.y; + tempZ = view->at.z - view->eye.z; length = sqrtf(SQ(tempX) + SQ(tempY) + SQ(tempZ)); @@ -1584,9 +1584,9 @@ void Environment_DrawRain(GlobalContext* globalCtx, View* view, GraphicsContext* if (!(globalCtx->cameraPtrs[0]->unk_14C & 0x100) && (globalCtx->envCtx.unk_EE[2] == 0)) { OPEN_DISPS(gfxCtx, "../z_kankyo.c", 2799); - vec.x = view->lookAt.x - view->eye.x; - vec.y = view->lookAt.y - view->eye.y; - vec.z = view->lookAt.z - view->eye.z; + vec.x = view->at.x - view->eye.x; + vec.y = view->at.y - view->eye.y; + vec.z = view->at.z - view->eye.z; length = sqrtf(SQXYZ(vec)); @@ -1859,8 +1859,8 @@ void Environment_DrawLightning(GlobalContext* globalCtx, s32 unused) { for (i = 0; i < ARRAY_COUNT(sLightningBolts); i++) { switch (sLightningBolts[i].state) { case LIGHTNING_BOLT_START: - dx = globalCtx->view.lookAt.x - globalCtx->view.eye.x; - dz = globalCtx->view.lookAt.z - globalCtx->view.eye.z; + dx = globalCtx->view.at.x - globalCtx->view.eye.x; + dz = globalCtx->view.at.z - globalCtx->view.eye.z; x = dx / sqrtf(SQ(dx) + SQ(dz)); z = dz / sqrtf(SQ(dx) + SQ(dz)); diff --git a/src/code/z_message_PAL.c b/src/code/z_message_PAL.c index f07145ac87..7d3fe73250 100644 --- a/src/code/z_message_PAL.c +++ b/src/code/z_message_PAL.c @@ -1936,7 +1936,7 @@ void Message_DrawTextBox(GlobalContext* globalCtx, Gfx** p) { void Message_SetView(View* view) { SET_FULLSCREEN_VIEWPORT(view); - func_800AB2C4(view); + View_ApplyOrthoToOverlay(view); } /** diff --git a/src/code/z_msgevent.c b/src/code/z_msgevent.c index 267180e1f1..5cca1c7179 100644 --- a/src/code/z_msgevent.c +++ b/src/code/z_msgevent.c @@ -1,7 +1,6 @@ #include "global.h" void MsgEvent_SendNullTask(void) { - s32 pad[4]; OSScTask task; OSMesgQueue queue; OSMesg msg; @@ -9,12 +8,12 @@ void MsgEvent_SendNullTask(void) { task.next = NULL; task.flags = OS_SC_RCP_MASK; - task.msgQ = &queue; + task.msgQueue = &queue; task.msg = NULL; task.framebuffer = NULL; task.list.t.type = M_NULTASK; - osCreateMesgQueue(task.msgQ, &msg, 1); - osSendMesg(&gSchedContext.cmdQ, &task, OS_MESG_BLOCK); + osCreateMesgQueue(task.msgQueue, &msg, 1); + osSendMesg(&gSchedContext.cmdQueue, (OSMesg)&task, OS_MESG_BLOCK); Sched_SendEntryMsg(&gSchedContext); osRecvMesg(&queue, NULL, OS_MESG_BLOCK); } diff --git a/src/code/z_onepointdemo.c b/src/code/z_onepointdemo.c index 48ac424682..4306c0f765 100644 --- a/src/code/z_onepointdemo.c +++ b/src/code/z_onepointdemo.c @@ -75,7 +75,7 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act if (timer < 20) { timer = 20; } - D_801208EC[0].atTargetInit = globalCtx->view.lookAt; + D_801208EC[0].atTargetInit = globalCtx->view.at; D_801208EC[0].eyeTargetInit = globalCtx->view.eye; D_801208EC[0].fovTargetInit = globalCtx->view.fovy; D_801208EC[1].atTargetInit = mainCam->at; @@ -91,7 +91,7 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); break; case 1030: - D_80120964[0].atTargetInit = globalCtx->view.lookAt; + D_80120964[0].atTargetInit = globalCtx->view.at; D_80120964[0].eyeTargetInit = globalCtx->view.eye; D_80120964[0].fovTargetInit = globalCtx->view.fovy; OLib_Vec3fDiffToVecSphGeo(&spD0, &mainCam->at, &mainCam->eye); @@ -104,7 +104,7 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); break; case 5000: - D_801209B4[0].atTargetInit = D_801209B4[1].atTargetInit = globalCtx->view.lookAt; + D_801209B4[0].atTargetInit = D_801209B4[1].atTargetInit = globalCtx->view.at; D_801209B4[0].eyeTargetInit = globalCtx->view.eye; D_801209B4[0].fovTargetInit = D_801209B4[2].fovTargetInit = globalCtx->view.fovy; OLib_Vec3fDiffToVecSphGeo(&spD0, &actor->focus.pos, &mainCam->at); @@ -232,9 +232,9 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act if ((sp82 > 0) && (sp82 < 320) && (sp7E > 0) && (sp7E < 240) && (sp80 > 0) && (sp80 < 320) && (sp7C > 0) && (sp7C < 240) && !OnePointCutscene_BgCheckLineTest(&globalCtx->colCtx, &actor->focus.pos, &player->actor.focus.pos)) { - D_80121184[0].atTargetInit.x = (globalCtx->view.lookAt.x + actor->focus.pos.x) * 0.5f; - D_80121184[0].atTargetInit.y = (globalCtx->view.lookAt.y + actor->focus.pos.y) * 0.5f; - D_80121184[0].atTargetInit.z = (globalCtx->view.lookAt.z + actor->focus.pos.z) * 0.5f; + D_80121184[0].atTargetInit.x = (globalCtx->view.at.x + actor->focus.pos.x) * 0.5f; + D_80121184[0].atTargetInit.y = (globalCtx->view.at.y + actor->focus.pos.y) * 0.5f; + D_80121184[0].atTargetInit.z = (globalCtx->view.at.z + actor->focus.pos.z) * 0.5f; D_80121184[0].eyeTargetInit = globalCtx->view.eye; D_80121184[0].eyeTargetInit.y = player->actor.focus.pos.y + 20.0f; D_80121184[0].fovTargetInit = mainCam->fov * 0.75f; @@ -490,7 +490,7 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act csCam->unk_14C |= 2; break; case 3140: - D_80121C24[0].atTargetInit = globalCtx->view.lookAt; + D_80121C24[0].atTargetInit = globalCtx->view.at; D_80121C24[0].eyeTargetInit = globalCtx->view.eye; D_80121C24[0].fovTargetInit = globalCtx->view.fovy; @@ -674,7 +674,7 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act Quake_SetCountdown(i, timer); break; case 3290: - D_80121F1C[0].atTargetInit = globalCtx->view.lookAt; + D_80121F1C[0].atTargetInit = globalCtx->view.at; D_80121F1C[0].eyeTargetInit = globalCtx->view.eye; D_80121F1C[0].fovTargetInit = globalCtx->view.fovy; Actor_GetFocus(&spA0, actor); @@ -691,7 +691,7 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act Quake_SetCountdown(i, 5); break; case 3340: - D_80121FBC[0].atTargetInit = globalCtx->view.lookAt; + D_80121FBC[0].atTargetInit = globalCtx->view.at; D_80121FBC[0].eyeTargetInit = globalCtx->view.eye; D_80121FBC[0].fovTargetInit = globalCtx->view.fovy; @@ -714,7 +714,7 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); break; case 3350: - D_801220D4[0].atTargetInit = globalCtx->view.lookAt; + D_801220D4[0].atTargetInit = globalCtx->view.at; D_801220D4[0].eyeTargetInit = globalCtx->view.eye; D_801220D4[0].fovTargetInit = globalCtx->view.fovy; if (actor->world.pos.x > 0.0f) { @@ -996,7 +996,7 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act } break; case 1000: - D_801232A4[0].atTargetInit = globalCtx->view.lookAt; + D_801232A4[0].atTargetInit = globalCtx->view.at; D_801232A4[0].eyeTargetInit = globalCtx->view.eye; D_801232A4[0].fovTargetInit = globalCtx->view.fovy; @@ -1057,7 +1057,7 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); break; case 9703: - D_80123894[0].atTargetInit = globalCtx->view.lookAt; + D_80123894[0].atTargetInit = globalCtx->view.at; D_80123894[0].eyeTargetInit = globalCtx->view.eye; D_80123894[0].fovTargetInit = globalCtx->view.fovy; if (LINK_IS_ADULT) { @@ -1071,7 +1071,7 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); break; case 9704: - D_8012390C[0].atTargetInit = globalCtx->view.lookAt; + D_8012390C[0].atTargetInit = globalCtx->view.at; D_8012390C[0].eyeTargetInit = globalCtx->view.eye; D_8012390C[0].fovTargetInit = globalCtx->view.fovy; @@ -1081,7 +1081,7 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); break; case 9705: - D_8012395C[0].atTargetInit = globalCtx->view.lookAt; + D_8012395C[0].atTargetInit = globalCtx->view.at; D_8012395C[0].eyeTargetInit = globalCtx->view.eye; D_8012395C[0].fovTargetInit = globalCtx->view.fovy; @@ -1178,7 +1178,7 @@ s16 OnePointCutscene_Init(GlobalContext* globalCtx, s16 csId, s16 timer, Actor* csCam->timer = timer; csCam->target = actor; - csCam->at = globalCtx->view.lookAt; + csCam->at = globalCtx->view.at; csCam->eye = globalCtx->view.eye; csCam->fov = globalCtx->view.fovy; diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index 18d77312a1..f8e7766da8 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -2975,7 +2975,7 @@ void func_8008A8B8(GlobalContext* globalCtx, s32 topY, s32 bottomY, s32 leftX, s up.x = up.z = 0.0f; up.y = 1.0f; - func_800AA358(&interfaceCtx->view, &eye, &lookAt, &up); + View_LookAt(&interfaceCtx->view, &eye, &lookAt, &up); interfaceCtx->viewport.topY = topY; interfaceCtx->viewport.bottomY = bottomY; @@ -2983,13 +2983,13 @@ void func_8008A8B8(GlobalContext* globalCtx, s32 topY, s32 bottomY, s32 leftX, s interfaceCtx->viewport.rightX = rightX; View_SetViewport(&interfaceCtx->view, &interfaceCtx->viewport); - func_800AA460(&interfaceCtx->view, 60.0f, 10.0f, 60.0f); - func_800AB560(&interfaceCtx->view); + View_SetPerspective(&interfaceCtx->view, 60.0f, 10.0f, 60.0f); + View_ApplyPerspectiveToOverlay(&interfaceCtx->view); } void func_8008A994(InterfaceContext* interfaceCtx) { SET_FULLSCREEN_VIEWPORT(&interfaceCtx->view); - func_800AB2C4(&interfaceCtx->view); + View_ApplyOrthoToOverlay(&interfaceCtx->view); } void Interface_Draw(GlobalContext* globalCtx) { diff --git a/src/code/z_play.c b/src/code/z_play.c index daacbe0195..7a3fed57c3 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -1086,8 +1086,8 @@ void Gameplay_Draw(GlobalContext* globalCtx) { POLY_OPA_DISP = Gameplay_SetFog(globalCtx, POLY_OPA_DISP); POLY_XLU_DISP = Gameplay_SetFog(globalCtx, POLY_XLU_DISP); - func_800AA460(&globalCtx->view, globalCtx->view.fovy, globalCtx->view.zNear, globalCtx->lightCtx.fogFar); - func_800AAA50(&globalCtx->view, 15); + View_SetPerspective(&globalCtx->view, globalCtx->view.fovy, globalCtx->view.zNear, globalCtx->lightCtx.fogFar); + View_Apply(&globalCtx->view, VIEW_ALL); // The billboard matrix temporarily stores the viewing matrix Matrix_MtxToMtxF(&globalCtx->view.viewing, &globalCtx->billboardMtxF); @@ -1118,11 +1118,11 @@ void Gameplay_Draw(GlobalContext* globalCtx) { View view; View_Init(&view, gfxCtx); - view.flags = 2 | 8; + view.flags = VIEW_VIEWPORT | VIEW_PROJECTION_ORTHO; SET_FULLSCREEN_VIEWPORT(&view); - func_800AB9EC(&view, 15, &gfxP); + View_ApplyTo(&view, VIEW_ALL, &gfxP); globalCtx->transitionCtx.draw(&globalCtx->transitionCtx.data, &gfxP); } @@ -1305,7 +1305,7 @@ void Gameplay_Draw(GlobalContext* globalCtx) { if (globalCtx->view.unk_124 != 0) { Camera_Update(GET_ACTIVE_CAM(globalCtx)); - func_800AB944(&globalCtx->view); + View_UpdateViewingMatrix(&globalCtx->view); globalCtx->view.unk_124 = 0; if (globalCtx->skyboxId && (globalCtx->skyboxId != SKYBOX_UNSET_1D) && !globalCtx->envCtx.skyboxDisabled) { SkyboxDraw_UpdateMatrix(&globalCtx->skyboxCtx, globalCtx->view.eye.x, globalCtx->view.eye.y, diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index e79298ba2e..152e186ce4 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -1307,7 +1307,7 @@ void Player_DrawGetItemImpl(GlobalContext* globalCtx, Player* this, Vec3f* refPo } void Player_DrawGetItem(GlobalContext* globalCtx, Player* this) { - if (!this->giObjectLoading || !osRecvMesg(&this->giObjectLoadQueue, NULL, OS_MESG_NOBLOCK)) { + if (!this->giObjectLoading || osRecvMesg(&this->giObjectLoadQueue, NULL, OS_MESG_NOBLOCK) == 0) { this->giObjectLoading = false; Player_DrawGetItemImpl(globalCtx, this, &sGetItemRefPos, ABS(this->unk_862)); } diff --git a/src/code/z_room.c b/src/code/z_room.c index 9487ac866a..e03ecfebe4 100644 --- a/src/code/z_room.c +++ b/src/code/z_room.c @@ -569,7 +569,7 @@ s32 func_8009728C(GlobalContext* globalCtx, RoomContext* roomCtx, s32 roomNum) { s32 func_800973FC(GlobalContext* globalCtx, RoomContext* roomCtx) { if (roomCtx->status == 1) { - if (!osRecvMesg(&roomCtx->loadQueue, NULL, OS_MESG_NOBLOCK)) { + if (osRecvMesg(&roomCtx->loadQueue, NULL, OS_MESG_NOBLOCK) == 0) { roomCtx->status = 0; roomCtx->curRoom.segment = roomCtx->unk_34; gSegments[3] = VIRTUAL_TO_PHYSICAL(roomCtx->unk_34); diff --git a/src/code/z_sample.c b/src/code/z_sample.c index 6e999787cd..79f3968859 100644 --- a/src/code/z_sample.c +++ b/src/code/z_sample.c @@ -18,8 +18,8 @@ void Sample_Draw(SampleContext* this) { func_80095248(gfxCtx, 0, 0, 0); - view->flags = 1 | 2 | 4; - func_800AAA50(view, 15); + view->flags = VIEW_VIEWING | VIEW_VIEWPORT | VIEW_PROJECTION_PERSPECTIVE; + View_Apply(view, VIEW_ALL); { Mtx* mtx = Graph_Alloc(gfxCtx, sizeof(Mtx)); @@ -55,7 +55,7 @@ void Sample_SetupView(SampleContext* this) { View_Init(view, gfxCtx); SET_FULLSCREEN_VIEWPORT(view); - func_800AA460(view, 60.0f, 10.0f, 12800.0f); + View_SetPerspective(view, 60.0f, 10.0f, 12800.0f); { Vec3f eye; @@ -72,7 +72,7 @@ void Sample_SetupView(SampleContext* this) { up.z = 0.0f; up.y = 1.0f; - func_800AA358(view, &eye, &lookAt, &up); + View_LookAt(view, &eye, &lookAt, &up); } } diff --git a/src/code/z_scene.c b/src/code/z_scene.c index b0b5b7c637..5cf17d0ebf 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -91,7 +91,7 @@ void Object_UpdateBank(ObjectContext* objectCtx) { osSyncPrintf("OBJECT EXCHANGE BANK-%2d SIZE %8.3fK SEG=%08x\n", i, size / 1024.0f, status->segment); DmaMgr_SendRequest2(&status->dmaRequest, status->segment, objectFile->vromStart, size, 0, &status->loadQueue, NULL, "../z_scene.c", 266); - } else if (!osRecvMesg(&status->loadQueue, NULL, OS_MESG_NOBLOCK)) { + } else if (osRecvMesg(&status->loadQueue, NULL, OS_MESG_NOBLOCK) == 0) { status->id = -status->id; } } diff --git a/src/code/z_ss_sram.c b/src/code/z_ss_sram.c index 847482d195..3a4251a1c4 100644 --- a/src/code/z_ss_sram.c +++ b/src/code/z_ss_sram.c @@ -4,7 +4,7 @@ typedef struct { /* 0x00 */ OSPiHandle piHandle; /* 0x74 */ OSIoMesg ioMesg; - /* 0x8C */ OSMesgQueue mesgQ; + /* 0x8C */ OSMesgQueue msgQueue; } SsSramContext; // size = 0xA4 SsSramContext sSsSramContext = { 0 }; @@ -32,20 +32,20 @@ void SsSram_Init(u32 addr, u8 handleType, u8 handleDomain, u8 handleLatency, u8 __osRestoreInt(prevInt); sSsSramContext.ioMesg.hdr.pri = OS_MESG_PRI_NORMAL; - sSsSramContext.ioMesg.hdr.retQueue = &sSsSramContext.mesgQ; + sSsSramContext.ioMesg.hdr.retQueue = &sSsSramContext.msgQueue; sSsSramContext.ioMesg.devAddr = addr; } } void SsSram_Dma(void* dramAddr, size_t size, s32 direction) { - OSMesg mesg; + OSMesg msg; - osCreateMesgQueue(&sSsSramContext.mesgQ, &mesg, 1); + osCreateMesgQueue(&sSsSramContext.msgQueue, &msg, 1); sSsSramContext.ioMesg.dramAddr = dramAddr; sSsSramContext.ioMesg.size = size; osWritebackDCache(dramAddr, size); osEPiStartDma(&sSsSramContext.piHandle, &sSsSramContext.ioMesg, direction); - osRecvMesg(&sSsSramContext.mesgQ, &mesg, OS_MESG_BLOCK); + osRecvMesg(&sSsSramContext.msgQueue, &msg, OS_MESG_BLOCK); osInvalDCache(dramAddr, size); } diff --git a/src/code/z_view.c b/src/code/z_view.c index 340d15aea0..eb2b04c19e 100644 --- a/src/code/z_view.c +++ b/src/code/z_view.c @@ -1,7 +1,10 @@ #include "global.h" #include "vt.h" -vu32 D_8012ABF0 = true; +vu32 sLogOnNextViewInit = true; + +s32 View_ApplyPerspective(View*); +s32 View_ApplyOrtho(View*); void View_ViewportToVp(Vp* dest, Viewport* src) { s32 width = src->rightX - src->leftX; @@ -45,42 +48,46 @@ void View_Init(View* view, GraphicsContext* gfxCtx) { view->fovy = 60.0f; view->zNear = 10.0f; view->zFar = 12800.0f; - view->lookAt.x = 0.0f; + view->at.x = 0.0f; view->up.x = 0.0f; view->up.y = 1.0f; view->up.z = 0.0f; view->eye.z = -1.0f; - if (D_8012ABF0) { - if (D_8012ABF0 == 0) {} + if (sLogOnNextViewInit) { + if (sLogOnNextViewInit == false) {} osSyncPrintf("\nview: initialize ---\n"); - D_8012ABF0 = false; + sLogOnNextViewInit = false; } view->unk_124 = 0; - view->flags = 1 | 2 | 4; + view->flags = VIEW_VIEWING | VIEW_VIEWPORT | VIEW_PROJECTION_PERSPECTIVE; View_InitDistortion(view); } -void func_800AA358(View* view, Vec3f* eye, Vec3f* lookAt, Vec3f* up) { - if (eye->x == lookAt->x && eye->z == lookAt->z) { +void View_LookAt(View* view, Vec3f* eye, Vec3f* at, Vec3f* up) { + if (eye->x == at->x && eye->z == at->z) { eye->x += 0.1f; } view->eye = *eye; - view->lookAt = *lookAt; + view->at = *at; view->up = *up; - view->flags |= 1; + view->flags |= VIEW_VIEWING; } -void func_800AA3F0(View* view, Vec3f* eye, Vec3f* lookAt, Vec3f* up) { +/* + * Unused. View_LookAt is always used instead. This version is similar but + * is missing the input sanitization and the update to the flags. + */ +void View_LookAtUnsafe(View* view, Vec3f* eye, Vec3f* at, Vec3f* up) { view->eye = *eye; - view->lookAt = *lookAt; + view->at = *at; view->up = *up; } void View_SetScale(View* view, f32 scale) { - view->flags |= 4; + view->flags |= VIEW_PROJECTION_PERSPECTIVE; view->scale = scale; } @@ -88,43 +95,47 @@ void View_GetScale(View* view, f32* scale) { *scale = view->scale; } -void func_800AA460(View* view, f32 fovy, f32 near, f32 far) { +void View_SetPerspective(View* view, f32 fovy, f32 zNear, f32 zFar) { view->fovy = fovy; - view->zNear = near; - view->zFar = far; - view->flags |= 4; + view->zNear = zNear; + view->zFar = zFar; + view->flags |= VIEW_PROJECTION_PERSPECTIVE; } -void func_800AA48C(View* view, f32* fovy, f32* near, f32* far) { +void View_GetPerspective(View* view, f32* fovy, f32* zNear, f32* zFar) { *fovy = view->fovy; - *near = view->zNear; - *far = view->zFar; + *zNear = view->zNear; + *zFar = view->zFar; } -void func_800AA4A8(View* view, f32 fovy, f32 near, f32 far) { +void View_SetOrtho(View* view, f32 fovy, f32 zNear, f32 zFar) { view->fovy = fovy; - view->zNear = near; - view->zFar = far; - view->flags |= 8; + view->zNear = zNear; + view->zFar = zFar; + view->flags |= VIEW_PROJECTION_ORTHO; view->scale = 1.0f; } -void func_800AA4E0(View* view, f32* fovy, f32* near, f32* far) { +/* + * Identical to View_GetPerspective, and never called. + * Named as it seems to fit the "set, get" pattern. + */ +void View_GetOrtho(View* view, f32* fovy, f32* zNear, f32* zFar) { *fovy = view->fovy; - *near = view->zNear; - *far = view->zFar; + *zNear = view->zNear; + *zFar = view->zFar; } void View_SetViewport(View* view, Viewport* viewport) { view->viewport = *viewport; - view->flags |= 2; + view->flags |= VIEW_VIEWPORT; } void View_GetViewport(View* view, Viewport* viewport) { *viewport = view->viewport; } -void func_800AA550(View* view) { +void View_ApplyShrinkWindow(View* view) { s32 varY; s32 varX; s32 pad; @@ -255,17 +266,20 @@ s32 View_StepDistortion(View* view, Mtx* projectionMtx) { return true; } -void func_800AAA50(View* view, s32 arg1) { - arg1 = (view->flags & arg1) | (arg1 >> 4); +/** + * Apply view to POLY_OPA_DISP, POLY_XLU_DISP (and OVERLAY_DISP if ortho) + */ +void View_Apply(View* view, s32 mask) { + mask = (view->flags & mask) | (mask >> 4); - if (arg1 & 8) { - func_800AB0A8(view); + if (mask & VIEW_PROJECTION_ORTHO) { + View_ApplyOrtho(view); } else { - func_800AAA9C(view); + View_ApplyPerspective(view); } } -s32 func_800AAA9C(View* view) { +s32 View_ApplyPerspective(View* view) { f32 aspect; s32 width; s32 height; @@ -276,16 +290,18 @@ s32 func_800AAA9C(View* view) { OPEN_DISPS(gfxCtx, "../z_view.c", 596); + // Viewport vp = Graph_Alloc(gfxCtx, sizeof(Vp)); LogUtils_CheckNullPointer("vp", vp, "../z_view.c", 601); View_ViewportToVp(vp, &view->viewport); view->vp = *vp; - func_800AA550(view); + View_ApplyShrinkWindow(view); gSPViewport(POLY_OPA_DISP++, vp); gSPViewport(POLY_XLU_DISP++, vp); + // Perspective projection projection = Graph_Alloc(gfxCtx, sizeof(Mtx)); LogUtils_CheckNullPointer("projection", projection, "../z_view.c", 616); view->projectionPtr = projection; @@ -332,22 +348,24 @@ s32 func_800AAA9C(View* view) { gSPPerspNormalize(POLY_XLU_DISP++, view->normal); gSPMatrix(POLY_XLU_DISP++, projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + // View matrix (look-at) viewing = Graph_Alloc(gfxCtx, sizeof(Mtx)); LogUtils_CheckNullPointer("viewing", viewing, "../z_view.c", 667); view->viewingPtr = viewing; - if (view->eye.x == view->lookAt.x && view->eye.y == view->lookAt.y && view->eye.z == view->lookAt.z) { + if (view->eye.x == view->at.x && view->eye.y == view->at.y && view->eye.z == view->at.z) { view->eye.x += 1.0f; view->eye.y += 1.0f; view->eye.z += 1.0f; } - func_800ABE74(view->eye.x, view->eye.y, view->eye.z); - guLookAt(viewing, view->eye.x, view->eye.y, view->eye.z, view->lookAt.x, view->lookAt.y, view->lookAt.z, view->up.x, + View_ErrorCheckEyePosition(view->eye.x, view->eye.y, view->eye.z); + guLookAt(viewing, view->eye.x, view->eye.y, view->eye.z, view->at.x, view->at.y, view->at.z, view->up.x, view->up.y, view->up.z); view->viewing = *viewing; + // Debug print view matrix if (QREG(88) & 2) { s32 i; MtxF mf; @@ -368,7 +386,7 @@ s32 func_800AAA9C(View* view) { return 1; } -s32 func_800AB0A8(View* view) { +s32 View_ApplyOrtho(View* view) { Vp* vp; Mtx* projection; GraphicsContext* gfxCtx = view->gfxCtx; @@ -380,7 +398,7 @@ s32 func_800AB0A8(View* view) { View_ViewportToVp(vp, &view->viewport); view->vp = *vp; - func_800AA550(view); + View_ApplyShrinkWindow(view); gSPViewport(POLY_OPA_DISP++, vp); gSPViewport(POLY_XLU_DISP++, vp); @@ -403,7 +421,10 @@ s32 func_800AB0A8(View* view) { return 1; } -s32 func_800AB2C4(View* view) { +/** + * Apply scissor, viewport and projection (ortho) to OVERLAY_DISP. + */ +s32 View_ApplyOrthoToOverlay(View* view) { Vp* vp; Mtx* projection; GraphicsContext* gfxCtx; @@ -438,7 +459,10 @@ s32 func_800AB2C4(View* view) { return 1; } -s32 func_800AB560(View* view) { +/** + * Apply scissor, viewport, view and projection (perspective) to OVERLAY_DISP. + */ +s32 View_ApplyPerspectiveToOverlay(View* view) { s32 pad[2]; f32 aspect; s32 width; @@ -479,14 +503,15 @@ s32 func_800AB560(View* view) { LogUtils_CheckNullPointer("viewing", viewing, "../z_view.c", 848); view->viewingPtr = viewing; - if (view->eye.x == view->lookAt.x && view->eye.y == view->lookAt.y && view->eye.z == view->lookAt.z) { + // This check avoids a divide-by-zero in guLookAt if eye == at + if (view->eye.x == view->at.x && view->eye.y == view->at.y && view->eye.z == view->at.z) { view->eye.x += 1.0f; view->eye.y += 1.0f; view->eye.z += 1.0f; } - func_800ABE74(view->eye.x, view->eye.y, view->eye.z); - guLookAt(viewing, view->eye.x, view->eye.y, view->eye.z, view->lookAt.x, view->lookAt.y, view->lookAt.z, view->up.x, + View_ErrorCheckEyePosition(view->eye.x, view->eye.y, view->eye.z); + guLookAt(viewing, view->eye.x, view->eye.y, view->eye.z, view->at.x, view->at.y, view->at.z, view->up.x, view->up.y, view->up.z); view->viewing = *viewing; @@ -498,11 +523,14 @@ s32 func_800AB560(View* view) { return 1; } -s32 func_800AB944(View* view) { +/** + * Just updates view's view matrix from its eye/at/up vectors. Opens disps but doesn't use them. + */ +s32 View_UpdateViewingMatrix(View* view) { OPEN_DISPS(view->gfxCtx, "../z_view.c", 878); - func_800ABE74(view->eye.x, view->eye.y, view->eye.z); - guLookAt(view->viewingPtr, view->eye.x, view->eye.y, view->eye.z, view->lookAt.x, view->lookAt.y, view->lookAt.z, + View_ErrorCheckEyePosition(view->eye.x, view->eye.y, view->eye.z); + guLookAt(view->viewingPtr, view->eye.x, view->eye.y, view->eye.z, view->at.x, view->at.y, view->at.z, view->up.x, view->up.y, view->up.z); CLOSE_DISPS(view->gfxCtx, "../z_view.c", 886); @@ -510,7 +538,7 @@ s32 func_800AB944(View* view) { return 1; } -s32 func_800AB9EC(View* view, s32 arg1, Gfx** gfxp) { +s32 View_ApplyTo(View* view, s32 mask, Gfx** gfxp) { Gfx* gfx = *gfxp; GraphicsContext* gfxCtx = view->gfxCtx; s32 width; @@ -519,9 +547,9 @@ s32 func_800AB9EC(View* view, s32 arg1, Gfx** gfxp) { Mtx* projection; Mtx* viewing; - arg1 = (view->flags & arg1) | (arg1 >> 4); + mask = (view->flags & mask) | (mask >> 4); - if (arg1 & 2) { + if (mask & VIEW_VIEWPORT) { vp = Graph_Alloc(gfxCtx, sizeof(Vp)); LogUtils_CheckNullPointer("vp", vp, "../z_view.c", 910); View_ViewportToVp(vp, &view->viewport); @@ -534,7 +562,7 @@ s32 func_800AB9EC(View* view, s32 arg1, Gfx** gfxp) { gSPViewport(gfx++, vp); } - if (arg1 & 8) { + if (mask & VIEW_PROJECTION_ORTHO) { projection = Graph_Alloc(gfxCtx, sizeof(Mtx)); LogUtils_CheckNullPointer("projection", projection, "../z_view.c", 921); view->projectionPtr = projection; @@ -545,7 +573,7 @@ s32 func_800AB9EC(View* view, s32 arg1, Gfx** gfxp) { view->projection = *projection; gSPMatrix(gfx++, projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); - } else if (arg1 & 6) { + } else if (mask & (VIEW_PROJECTION_PERSPECTIVE | VIEW_VIEWPORT)) { projection = Graph_Alloc(gfxCtx, sizeof(Mtx)); LogUtils_CheckNullPointer("projection", projection, "../z_view.c", 932); view->projectionPtr = projection; @@ -562,13 +590,13 @@ s32 func_800AB9EC(View* view, s32 arg1, Gfx** gfxp) { gSPMatrix(gfx++, projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); } - if (arg1 & 1) { + if (mask & VIEW_VIEWING) { viewing = Graph_Alloc(gfxCtx, sizeof(Mtx)); LogUtils_CheckNullPointer("viewing", viewing, "../z_view.c", 948); view->viewingPtr = viewing; - func_800ABE74(view->eye.x, view->eye.y, view->eye.z); - guLookAt(viewing, view->eye.x, view->eye.y, view->eye.z, view->lookAt.x, view->lookAt.y, view->lookAt.z, + View_ErrorCheckEyePosition(view->eye.x, view->eye.y, view->eye.z); + guLookAt(viewing, view->eye.x, view->eye.y, view->eye.z, view->at.x, view->at.y, view->at.z, view->up.x, view->up.y, view->up.z); view->viewing = *viewing; @@ -582,7 +610,10 @@ s32 func_800AB9EC(View* view, s32 arg1, Gfx** gfxp) { return 1; } -s32 func_800ABE74(f32 eyeX, f32 eyeY, f32 eyeZ) { +/** + * Logs an error and returns nonzero if camera is too far from the origin. + */ +s32 View_ErrorCheckEyePosition(f32 eyeX, f32 eyeY, f32 eyeZ) { s32 error = 0; if (SQ(eyeX) + SQ(eyeY) + SQ(eyeZ) > SQ(32767.0f)) { diff --git a/src/libultra/io/contramwrite.c b/src/libultra/io/contramwrite.c index e27c032278..d8fb594e95 100644 --- a/src/libultra/io/contramwrite.c +++ b/src/libultra/io/contramwrite.c @@ -44,10 +44,10 @@ s32 __osContRamWrite(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer, s32 ret = __osSiRawStartDma(OS_WRITE, &gPifMempakBuf); crc = __osContDataCrc(buffer); - osRecvMesg(mq, (OSMesg*)NULL, OS_MESG_BLOCK); + osRecvMesg(mq, NULL, OS_MESG_BLOCK); ret = __osSiRawStartDma(OS_READ, &gPifMempakBuf); - osRecvMesg(mq, (OSMesg*)NULL, OS_MESG_BLOCK); + osRecvMesg(mq, NULL, OS_MESG_BLOCK); ret = ((((__OSContRamHeader*)ptr)->rxsize & 0xC0) >> 4); if (!ret) { diff --git a/src/libultra/io/controller.c b/src/libultra/io/controller.c index 5b44e01123..bb13787ed3 100644 --- a/src/libultra/io/controller.c +++ b/src/libultra/io/controller.c @@ -5,7 +5,7 @@ u8 __osContLastPoll; u8 __osMaxControllers; // always 4 OSTimer __osEepromTimer; -OSMesgQueue __osEepromTimerMsgQ; +OSMesgQueue __osEepromTimerMsgQueue; OSMesg __osEepromTimerMsg; u32 gOSContInitialized = 0; @@ -13,7 +13,7 @@ u32 gOSContInitialized = 0; #define HALF_SECOND OS_USEC_TO_CYCLES(500000) s32 osContInit(OSMesgQueue* mq, u8* ctlBitfield, OSContStatus* status) { - OSMesg mesg; + OSMesg msg; s32 ret = 0; OSTime currentTime; OSTimer timer; @@ -26,20 +26,20 @@ s32 osContInit(OSMesgQueue* mq, u8* ctlBitfield, OSContStatus* status) { gOSContInitialized = 1; currentTime = osGetTime(); if (HALF_SECOND > currentTime) { - osCreateMesgQueue(&timerqueue, &mesg, 1); - osSetTimer(&timer, HALF_SECOND - currentTime, 0, &timerqueue, &mesg); - osRecvMesg(&timerqueue, &mesg, OS_MESG_BLOCK); + osCreateMesgQueue(&timerqueue, &msg, 1); + osSetTimer(&timer, HALF_SECOND - currentTime, 0, &timerqueue, &msg); + osRecvMesg(&timerqueue, &msg, OS_MESG_BLOCK); } __osMaxControllers = MAXCONTROLLERS; __osPackRequestData(CONT_CMD_REQUEST_STATUS); ret = __osSiRawStartDma(OS_WRITE, &__osPifInternalBuff); - osRecvMesg(mq, &mesg, OS_MESG_BLOCK); + osRecvMesg(mq, &msg, OS_MESG_BLOCK); ret = __osSiRawStartDma(OS_READ, &__osPifInternalBuff); - osRecvMesg(mq, &mesg, OS_MESG_BLOCK); + osRecvMesg(mq, &msg, OS_MESG_BLOCK); __osContGetInitData(ctlBitfield, status); __osContLastPoll = CONT_CMD_REQUEST_STATUS; __osSiCreateAccessQueue(); - osCreateMesgQueue(&__osEepromTimerMsgQ, &__osEepromTimerMsg, 1); + osCreateMesgQueue(&__osEepromTimerMsgQueue, &__osEepromTimerMsg, 1); return ret; } diff --git a/src/libultra/io/devmgr.c b/src/libultra/io/devmgr.c index 7f8975a715..9380902c6b 100644 --- a/src/libultra/io/devmgr.c +++ b/src/libultra/io/devmgr.c @@ -15,7 +15,7 @@ void __osDevMgrMain(void* arg) { ioMesg = NULL; while (true) { - osRecvMesg(arg0->cmdQueue, (OSMesg)&ioMesg, OS_MESG_BLOCK); + osRecvMesg(arg0->cmdQueue, (OSMesg*)&ioMesg, OS_MESG_BLOCK); if ((ioMesg->piHandle != NULL) && (ioMesg->piHandle->type == DEVICE_TYPE_64DD) && ((ioMesg->piHandle->transferInfo.cmdType == 0) || (ioMesg->piHandle->transferInfo.cmdType == 1))) { transfer = &ioMesg->piHandle->transferInfo; @@ -46,7 +46,7 @@ void __osDevMgrMain(void* arg) { HW_REG(PI_STATUS_REG, u32) = PI_STATUS_CLEAR_INTR; __osSetGlobalIntMask(0x00100C01); } - osSendMesg(ioMesg->hdr.retQueue, ioMesg, OS_MESG_NOBLOCK); + osSendMesg(ioMesg->hdr.retQueue, (OSMesg)ioMesg, OS_MESG_NOBLOCK); if ((phi_s2 != 1) || (ioMesg->piHandle->transferInfo.block[0].errStatus != 0)) { break; @@ -55,7 +55,7 @@ void __osDevMgrMain(void* arg) { phi_s2 = 0; } - osSendMesg(arg0->acccessQueue, 0, OS_MESG_NOBLOCK); + osSendMesg(arg0->acccessQueue, NULL, OS_MESG_NOBLOCK); if (ioMesg->piHandle->transferInfo.blockNum == 1) { osYieldThread(); } @@ -80,7 +80,7 @@ void __osDevMgrMain(void* arg) { ioMesg->size); break; case OS_MESG_TYPE_LOOPBACK: - osSendMesg(ioMesg->hdr.retQueue, ioMesg, OS_MESG_NOBLOCK); + osSendMesg(ioMesg->hdr.retQueue, (OSMesg)ioMesg, OS_MESG_NOBLOCK); phi_s0 = -1; break; default: @@ -90,7 +90,7 @@ void __osDevMgrMain(void* arg) { if (phi_s0 == 0) { osRecvMesg(arg0->eventQueue, &sp70, OS_MESG_BLOCK); - osSendMesg(ioMesg->hdr.retQueue, ioMesg, OS_MESG_NOBLOCK); + osSendMesg(ioMesg->hdr.retQueue, (OSMesg)ioMesg, OS_MESG_NOBLOCK); osSendMesg(arg0->acccessQueue, NULL, OS_MESG_NOBLOCK); } } diff --git a/src/libultra/io/piacs.c b/src/libultra/io/piacs.c index 681e5f0aeb..0ffa3448c4 100644 --- a/src/libultra/io/piacs.c +++ b/src/libultra/io/piacs.c @@ -1,24 +1,23 @@ #include "global.h" -u32 __osPiAccessQueueEnabled = 0; - -OSMesg piAccessBuf; +u32 __osPiAccessQueueEnabled = false; +OSMesg piAccessBuf[1]; OSMesgQueue __osPiAccessQueue; void __osPiCreateAccessQueue(void) { - __osPiAccessQueueEnabled = 1; - osCreateMesgQueue(&__osPiAccessQueue, &piAccessBuf, 1); + __osPiAccessQueueEnabled = true; + osCreateMesgQueue(&__osPiAccessQueue, piAccessBuf, ARRAY_COUNT(piAccessBuf)); osSendMesg(&__osPiAccessQueue, NULL, OS_MESG_NOBLOCK); } void __osPiGetAccess(void) { - OSMesg mesg; + OSMesg msg; if (!__osPiAccessQueueEnabled) { __osPiCreateAccessQueue(); } - osRecvMesg(&__osPiAccessQueue, &mesg, OS_MESG_BLOCK); + osRecvMesg(&__osPiAccessQueue, &msg, OS_MESG_BLOCK); } void __osPiRelAccess(void) { diff --git a/src/libultra/io/pimgr.c b/src/libultra/io/pimgr.c index d69c76c471..e7b735e6b3 100644 --- a/src/libultra/io/pimgr.c +++ b/src/libultra/io/pimgr.c @@ -17,13 +17,13 @@ OSPiHandle* __osCurrentHandle[] = { &__Dom2SpeedParam, }; -void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgCnt) { +void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQueue, OSMesg* cmdBuf, s32 cmdMsgCnt) { u32 prevInt; OSPri newPri; OSPri currentPri; if (!__osPiDevMgr.initialized) { - osCreateMesgQueue(cmdQ, cmdBuf, cmdMsgCnt); + osCreateMesgQueue(cmdQueue, cmdBuf, cmdMsgCnt); osCreateMesgQueue(&piEventQueue, piEventBuf, 1); if (!__osPiAccessQueueEnabled) { __osPiCreateAccessQueue(); @@ -39,7 +39,7 @@ void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgC prevInt = __osDisableInt(); __osPiDevMgr.initialized = true; - __osPiDevMgr.cmdQueue = cmdQ; + __osPiDevMgr.cmdQueue = cmdQueue; __osPiDevMgr.mgrThread = &piThread; __osPiDevMgr.eventQueue = &piEventQueue; __osPiDevMgr.acccessQueue = &__osPiAccessQueue; diff --git a/src/libultra/io/siacs.c b/src/libultra/io/siacs.c index 90dbe7e5d7..c814867bd8 100644 --- a/src/libultra/io/siacs.c +++ b/src/libultra/io/siacs.c @@ -1,24 +1,24 @@ #include "global.h" -OSMesg osSiMesgBuff[SIAccessQueueSize]; -OSMesgQueue gOSSiMessageQueue; -u32 gOSSiAccessQueueCreated = 0; +OSMesg siAccessBuf[1]; +OSMesgQueue __osSiAccessQueue; +u32 __osSiAccessQueueEnabled = false; void __osSiCreateAccessQueue(void) { - gOSSiAccessQueueCreated = 1; - osCreateMesgQueue(&gOSSiMessageQueue, &osSiMesgBuff[0], SIAccessQueueSize - 1); - osSendMesg(&gOSSiMessageQueue, NULL, OS_MESG_NOBLOCK); + __osSiAccessQueueEnabled = true; + osCreateMesgQueue(&__osSiAccessQueue, siAccessBuf, ARRAY_COUNT(siAccessBuf)); + osSendMesg(&__osSiAccessQueue, NULL, OS_MESG_NOBLOCK); } void __osSiGetAccess(void) { - OSMesg mesg; + OSMesg msg; - if (!gOSSiAccessQueueCreated) { + if (!__osSiAccessQueueEnabled) { __osSiCreateAccessQueue(); } - osRecvMesg(&gOSSiMessageQueue, &mesg, OS_MESG_BLOCK); + osRecvMesg(&__osSiAccessQueue, &msg, OS_MESG_BLOCK); } void __osSiRelAccess(void) { - osSendMesg(&gOSSiMessageQueue, NULL, OS_MESG_NOBLOCK); + osSendMesg(&__osSiAccessQueue, NULL, OS_MESG_NOBLOCK); } diff --git a/src/libultra/io/vimgr.c b/src/libultra/io/vimgr.c index 44b7212b54..f2ec481e12 100644 --- a/src/libultra/io/vimgr.c +++ b/src/libultra/io/vimgr.c @@ -4,7 +4,7 @@ OSThread viThread; STACK(viThreadStack, 0x1000); OSMesgQueue viEventQueue; -OSMesg viEventBuf[6]; +OSMesg viEventBuf[5]; OSIoMesg viRetraceMsg; OSIoMesg viCounterMsg; OSMgrArgs __osViDevMgr = { 0 }; @@ -20,7 +20,7 @@ void osCreateViManager(OSPri pri) { if (!__osViDevMgr.initialized) { __osTimerServicesInit(); __additional_scanline = 0; - osCreateMesgQueue(&viEventQueue, viEventBuf, 5); + osCreateMesgQueue(&viEventQueue, viEventBuf, ARRAY_COUNT(viEventBuf)); viRetraceMsg.hdr.type = OS_MESG_TYPE_VRETRACE; viRetraceMsg.hdr.pri = OS_MESG_PRI_NORMAL; viRetraceMsg.hdr.retQueue = NULL; @@ -59,7 +59,7 @@ void viMgrMain(void* vargs) { static u16 viRetrace; OSMgrArgs* args; u32 addTime; - OSIoMesg* mesg = NULL; + OSIoMesg* msg = NULL; u32 temp = 0; // always 0 viRetrace = __osViGetCurrentContext()->retraceCount; @@ -70,8 +70,8 @@ void viMgrMain(void* vargs) { args = (OSMgrArgs*)vargs; while (true) { - osRecvMesg(args->eventQueue, (OSMesg)&mesg, OS_MESG_BLOCK); - switch (mesg->hdr.type) { + osRecvMesg(args->eventQueue, (OSMesg*)&msg, OS_MESG_BLOCK); + switch (msg->hdr.type) { case OS_MESG_TYPE_VRETRACE: __osViSwapContext(); viRetrace--; diff --git a/src/libultra/os/createmesgqueue.c b/src/libultra/os/createmesgqueue.c index 87a4031f30..a85eadb0d7 100644 --- a/src/libultra/os/createmesgqueue.c +++ b/src/libultra/os/createmesgqueue.c @@ -1,8 +1,8 @@ #include "global.h" void osCreateMesgQueue(OSMesgQueue* mq, OSMesg* msg, s32 count) { - mq->mtqueue = (OSThread*)__osThreadTail; - mq->fullqueue = (OSThread*)__osThreadTail; + mq->mtqueue = (OSThread*)&__osThreadTail; + mq->fullqueue = (OSThread*)&__osThreadTail; mq->validCount = 0; mq->first = 0; mq->msgCount = count; diff --git a/src/libultra/os/createthread.c b/src/libultra/os/createthread.c index baed395259..90c0251602 100644 --- a/src/libultra/os/createthread.c +++ b/src/libultra/os/createthread.c @@ -1,8 +1,8 @@ #include "global.h" -OSThread* __osThreadTail[2] = { NULL, (OSThread*)OS_PRIORITY_THREADTAIL }; -OSThread* __osRunQueue = (OSThread*)__osThreadTail; -OSThread* __osActiveQueue = (OSThread*)__osThreadTail; +__OSThreadTail __osThreadTail = { NULL, OS_PRIORITY_THREADTAIL }; +OSThread* __osRunQueue = (OSThread*)&__osThreadTail; +OSThread* __osActiveQueue = (OSThread*)&__osThreadTail; OSThread* __osRunningThread = NULL; OSThread* __osFaultedThread = NULL; @@ -20,8 +20,8 @@ void osCreateThread(OSThread* thread, OSId id, void (*entry)(void*), void* arg, thread->context.ra = __osCleanupThread; mask = OS_IM_ALL; - thread->context.sr = (mask & OS_IM_CPU) | 2; - thread->context.rcp = (mask & RCP_IMASK) >> 16; + thread->context.sr = (mask & OS_IM_CPU) | SR_EXL; + thread->context.rcp = (mask & RCP_IMASK) >> RCP_IMASKSHIFT; thread->context.fpcsr = FPCSR_FS | FPCSR_EV; thread->fp = 0; thread->state = OS_STATE_STOPPED; diff --git a/src/libultra/os/jammesg.c b/src/libultra/os/jammesg.c index 5668c476e2..e0ca40fc68 100644 --- a/src/libultra/os/jammesg.c +++ b/src/libultra/os/jammesg.c @@ -3,7 +3,7 @@ s32 osJamMesg(OSMesgQueue* mq, OSMesg msg, s32 flag) { register u32 prevInt = __osDisableInt(); - while (mq->validCount >= mq->msgCount) { + while (MQ_IS_FULL(mq)) { if (flag == OS_MESG_BLOCK) { __osRunningThread->state = OS_STATE_WAITING; __osEnqueueAndYield(&mq->fullqueue); diff --git a/src/libultra/os/recvmesg.c b/src/libultra/os/recvmesg.c index 0f4c83cff8..48737c1c65 100644 --- a/src/libultra/os/recvmesg.c +++ b/src/libultra/os/recvmesg.c @@ -3,12 +3,12 @@ s32 osRecvMesg(OSMesgQueue* mq, OSMesg* msg, s32 flag) { register u32 prevInt = __osDisableInt(); - while (mq->validCount == 0) { + while (MQ_IS_EMPTY(mq)) { if (flag == OS_MESG_NOBLOCK) { __osRestoreInt(prevInt); return -1; } - __osRunningThread->state = 8; + __osRunningThread->state = OS_STATE_WAITING; __osEnqueueAndYield((OSThread**)mq); } diff --git a/src/libultra/os/sendmesg.c b/src/libultra/os/sendmesg.c index eafd9da8b3..df0bc2bee4 100644 --- a/src/libultra/os/sendmesg.c +++ b/src/libultra/os/sendmesg.c @@ -1,12 +1,12 @@ #include "global.h" -s32 osSendMesg(OSMesgQueue* mq, OSMesg mesg, s32 flag) { +s32 osSendMesg(OSMesgQueue* mq, OSMesg msg, s32 flag) { register u32 prevInt = __osDisableInt(); register u32 index; - while (mq->validCount >= mq->msgCount) { + while (MQ_IS_FULL(mq)) { if (flag == OS_MESG_BLOCK) { - __osRunningThread->state = 8; + __osRunningThread->state = OS_STATE_WAITING; __osEnqueueAndYield(&mq->fullqueue); } else { __osRestoreInt(prevInt); @@ -15,7 +15,7 @@ s32 osSendMesg(OSMesgQueue* mq, OSMesg mesg, s32 flag) { } index = (mq->first + mq->validCount) % mq->msgCount; - mq->msg[index] = mesg; + mq->msg[index] = msg; mq->validCount++; if (mq->mtqueue->next != NULL) { diff --git a/src/libultra/os/setthreadpri.c b/src/libultra/os/setthreadpri.c index 572d3495ae..a9a1b0eb6e 100644 --- a/src/libultra/os/setthreadpri.c +++ b/src/libultra/os/setthreadpri.c @@ -9,12 +9,12 @@ void osSetThreadPri(OSThread* thread, OSPri pri) { if (thread->priority != pri) { thread->priority = pri; - if (thread != __osRunningThread && thread->state != 1) { + if (thread != __osRunningThread && thread->state != OS_STATE_STOPPED) { __osDequeueThread(thread->queue, thread); __osEnqueueThread(thread->queue, thread); } if (__osRunningThread->priority < __osRunQueue->priority) { - __osRunningThread->state = 2; + __osRunningThread->state = OS_STATE_RUNNABLE; __osEnqueueAndYield(&__osRunQueue); } } diff --git a/src/libultra/os/startthread.c b/src/libultra/os/startthread.c index 80d1f25646..6594fd5ae5 100644 --- a/src/libultra/os/startthread.c +++ b/src/libultra/os/startthread.c @@ -4,16 +4,16 @@ void osStartThread(OSThread* thread) { register u32 prevInt = __osDisableInt(); switch (thread->state) { - case 8: - thread->state = 2; + case OS_STATE_WAITING: + thread->state = OS_STATE_RUNNABLE; __osEnqueueThread(&__osRunQueue, thread); break; - case 1: + case OS_STATE_STOPPED: if (thread->queue == NULL || thread->queue == &__osRunQueue) { - thread->state = 2; + thread->state = OS_STATE_RUNNABLE; __osEnqueueThread(&__osRunQueue, thread); } else { - thread->state = 8; + thread->state = OS_STATE_WAITING; __osEnqueueThread(thread->queue, thread); __osEnqueueThread(&__osRunQueue, __osPopThread(thread->queue)); } @@ -24,7 +24,7 @@ void osStartThread(OSThread* thread) { __osDispatchThread(); } else { if (__osRunningThread->priority < __osRunQueue->priority) { - __osRunningThread->state = 2; + __osRunningThread->state = OS_STATE_RUNNABLE; __osEnqueueAndYield(&__osRunQueue); } } diff --git a/src/libultra/os/stopthread.c b/src/libultra/os/stopthread.c index eebd8ce9b7..54a236b49b 100644 --- a/src/libultra/os/stopthread.c +++ b/src/libultra/os/stopthread.c @@ -5,19 +5,19 @@ void osStopThread(OSThread* thread) { register u32 state; if (thread == NULL) { - state = 4; + state = OS_STATE_RUNNING; } else { state = thread->state; } switch (state) { - case 4: - __osRunningThread->state = 1; + case OS_STATE_RUNNING: + __osRunningThread->state = OS_STATE_STOPPED; __osEnqueueAndYield(NULL); break; - case 2: - case 8: - thread->state = 1; + case OS_STATE_RUNNABLE: + case OS_STATE_WAITING: + thread->state = OS_STATE_STOPPED; __osDequeueThread(thread->queue, thread); break; } diff --git a/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c b/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c index a99af73468..18679d1954 100644 --- a/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c +++ b/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c @@ -47,10 +47,10 @@ void BgDyYoseizo_SetupSpinGrow_Reward(BgDyYoseizo* this, GlobalContext* globalCt void BgDyYoseizo_SpinGrowSetupGive_Reward(BgDyYoseizo* this, GlobalContext* globalCtx); void BgDyYoseizo_Give_Reward(BgDyYoseizo* this, GlobalContext* globalCtx); -void BgDyYoseizo_ParticleInit(BgDyYoseizo* this, Vec3f* initPos, Vec3f* initVelocity, Vec3f* accel, - Color_RGB8* primColor, Color_RGB8* envColor, f32 scale, s16 life, s16 type); -void BgDyYoseizo_ParticleUpdate(BgDyYoseizo* this, GlobalContext* globalCtx); -void BgDyYoseizo_ParticleDraw(BgDyYoseizo* this, GlobalContext* globalCtx); +void BgDyYoseizo_SpawnEffect(BgDyYoseizo* this, Vec3f* initPos, Vec3f* initVelocity, Vec3f* accel, + Color_RGB8* primColor, Color_RGB8* envColor, f32 scale, s16 life, s16 type); +void BgDyYoseizo_UpdateEffects(BgDyYoseizo* this, GlobalContext* globalCtx); +void BgDyYoseizo_DrawEffects(BgDyYoseizo* this, GlobalContext* globalCtx); static s32 sUnusedGetItemIds[] = { GI_FARORES_WIND, GI_NAYRUS_LOVE, GI_DINS_FIRE }; @@ -97,71 +97,70 @@ void BgDyYoseizo_Init(Actor* thisx, GlobalContext* globalCtx2) { void BgDyYoseizo_Destroy(Actor* this, GlobalContext* globalCtx) { } -static Color_RGB8 sParticlePrimColors[] = { +static Color_RGB8 sEffectPrimColors[] = { { 255, 255, 255 }, { 255, 255, 100 }, { 100, 255, 100 }, { 255, 100, 100 }, { 255, 255, 170 }, { 255, 255, 100 }, { 100, 255, 100 }, { 255, 100, 100 }, { 255, 255, 170 }, }; -static Color_RGB8 sParticleEnvColors[] = { +static Color_RGB8 sEffectEnvColors[] = { { 155, 255, 255 }, { 255, 255, 100 }, { 100, 255, 100 }, { 255, 100, 100 }, { 255, 100, 255 }, { 255, 255, 100 }, { 100, 255, 100 }, { 255, 100, 100 }, { 100, 255, 255 }, }; -void BgDyYoseizo_SpawnParticles(BgDyYoseizo* this, GlobalContext* globalCtx, s16 type) { - Vec3f particleInitVelocity = { 0.0f, 0.0f, 0.0f }; - Vec3f particleAccel; - Vec3f particleInitPos; - Color_RGB8 particlePrimColor; - Color_RGB8 particleEnvColor; +void BgDyYoseizo_SpawnEffects(BgDyYoseizo* this, GlobalContext* globalCtx, s16 type) { + Vec3f vel = { 0.0f, 0.0f, 0.0f }; + Vec3f accel; + Vec3f pos; + Color_RGB8 primColor; + Color_RGB8 envColor; f32 spawnPosVariation; - s32 particleType; - f32 particleScale; + s32 effectType; + f32 scale; s32 i; - s16 particleLife; + s16 life; if (!(this->scale < 0.01f)) { spawnPosVariation = this->scale * 3500.0f; - particleAccel.x = Rand_ZeroOne() - 0.5f; - particleAccel.y = Rand_ZeroOne() - 0.5f; - particleAccel.z = Rand_ZeroOne() - 0.5f; + accel.x = Rand_ZeroOne() - 0.5f; + accel.y = Rand_ZeroOne() - 0.5f; + accel.z = Rand_ZeroOne() - 0.5f; for (i = 0; i < 2; i++) { if (type == 0) { - particleType = 0; - particleScale = 0.4f; - particleLife = 90; - particleInitPos.x = this->actor.world.pos.x; - particleInitPos.y = this->actor.world.pos.y + spawnPosVariation + - ((Rand_ZeroOne() - 0.5f) * (spawnPosVariation * 0.5f)); - particleInitPos.z = this->actor.world.pos.z + 30.0f; + effectType = 0; + scale = 0.4f; + life = 90; + pos.x = this->actor.world.pos.x; + pos.y = this->actor.world.pos.y + spawnPosVariation + + ((Rand_ZeroOne() - 0.5f) * (spawnPosVariation * 0.5f)); + pos.z = this->actor.world.pos.z + 30.0f; } else { - particleLife = 50; - particleType = type; - particleScale = 0.2f; - particleInitPos.x = this->actor.world.pos.x + Rand_CenteredFloat(10.0f); + life = 50; + effectType = type; + scale = 0.2f; + pos.x = this->actor.world.pos.x + Rand_CenteredFloat(10.0f); if (globalCtx->sceneNum == SCENE_DAIYOUSEI_IZUMI) { - particleInitPos.y = this->actor.world.pos.y + spawnPosVariation + 50.0f + - ((Rand_ZeroOne() - 0.5f) * (spawnPosVariation * 0.1f)); - particleInitPos.z = this->actor.world.pos.z + 30.0f; + pos.y = this->actor.world.pos.y + spawnPosVariation + 50.0f + + ((Rand_ZeroOne() - 0.5f) * (spawnPosVariation * 0.1f)); + pos.z = this->actor.world.pos.z + 30.0f; } else { - particleInitPos.y = this->actor.world.pos.y + spawnPosVariation - 30.0f + - ((Rand_ZeroOne() - 0.5f) * (spawnPosVariation * 0.1f)); - particleInitPos.z = this->actor.world.pos.z + 60.0f; + pos.y = this->actor.world.pos.y + spawnPosVariation - 30.0f + + ((Rand_ZeroOne() - 0.5f) * (spawnPosVariation * 0.1f)); + pos.z = this->actor.world.pos.z + 60.0f; } if (LINK_IS_ADULT) { - particleInitPos.y += 20.0f; + pos.y += 20.0f; } } - particlePrimColor.r = sParticlePrimColors[particleType].r; - particlePrimColor.g = sParticlePrimColors[particleType].g; - particlePrimColor.b = sParticlePrimColors[particleType].b; - particleEnvColor.r = sParticleEnvColors[particleType].r; - particleEnvColor.g = sParticleEnvColors[particleType].g; - particleEnvColor.b = sParticleEnvColors[particleType].b; - BgDyYoseizo_ParticleInit(this, &particleInitPos, &particleInitVelocity, &particleAccel, &particlePrimColor, - &particleEnvColor, particleScale, particleLife, particleType); + primColor.r = sEffectPrimColors[effectType].r; + primColor.g = sEffectPrimColors[effectType].g; + primColor.b = sEffectPrimColors[effectType].b; + envColor.r = sEffectEnvColors[effectType].r; + envColor.g = sEffectEnvColors[effectType].g; + envColor.b = sEffectEnvColors[effectType].b; + BgDyYoseizo_SpawnEffect(this, &pos, &vel, &accel, &primColor, &envColor, scale, life, effectType); } } } @@ -341,7 +340,7 @@ void BgDyYoseizo_SpinGrow_NoReward(BgDyYoseizo* this, GlobalContext* globalCtx) } else { this->actor.shape.rot.y += 3000; } - BgDyYoseizo_SpawnParticles(this, globalCtx, 0); + BgDyYoseizo_SpawnEffects(this, globalCtx, 0); } void BgDyYoseizo_CompleteSpinGrow_NoReward(BgDyYoseizo* this, GlobalContext* globalCtx) { @@ -376,7 +375,7 @@ void BgDyYoseizo_SetupGreetPlayer_NoReward(BgDyYoseizo* this, GlobalContext* glo this->actor.textId = 0xDB; this->dialogState = TEXT_STATE_EVENT; Message_StartTextbox(globalCtx, this->actor.textId, NULL); - BgDyYoseizo_SpawnParticles(this, globalCtx, 0); + BgDyYoseizo_SpawnEffects(this, globalCtx, 0); this->actionFunc = BgDyYoseizo_GreetPlayer_NoReward; } @@ -397,7 +396,7 @@ void BgDyYoseizo_GreetPlayer_NoReward(BgDyYoseizo* this, GlobalContext* globalCt } BgDyYoseizo_Bob(this, globalCtx); - BgDyYoseizo_SpawnParticles(this, globalCtx, 0); + BgDyYoseizo_SpawnEffects(this, globalCtx, 0); } void BgDyYoseizo_SetupHealPlayer_NoReward(BgDyYoseizo* this, GlobalContext* globalCtx) { @@ -506,7 +505,7 @@ void BgDyYoseizo_SayFarewell_NoReward(BgDyYoseizo* this, GlobalContext* globalCt } BgDyYoseizo_Bob(this, globalCtx); - BgDyYoseizo_SpawnParticles(this, globalCtx, 0); + BgDyYoseizo_SpawnEffects(this, globalCtx, 0); } void BgDyYoseizo_SetupSpinShrink(BgDyYoseizo* this, GlobalContext* globalCtx) { @@ -540,7 +539,7 @@ void BgDyYoseizo_SpinShrink(BgDyYoseizo* this, GlobalContext* globalCtx) { Math_ApproachF(&this->heightFraction, 0.8f, 0.1f, 0.02f); Math_ApproachF(&this->scaleFraction, 0.2f, 0.03f, 0.05f); this->actor.shape.rot.y += 3000; - BgDyYoseizo_SpawnParticles(this, globalCtx, 0); + BgDyYoseizo_SpawnEffects(this, globalCtx, 0); } } } @@ -645,7 +644,7 @@ void BgDyYoseizo_SpinGrowSetupGive_Reward(BgDyYoseizo* this, GlobalContext* glob this->actionFunc = BgDyYoseizo_Give_Reward; } } - BgDyYoseizo_SpawnParticles(this, globalCtx, 0); + BgDyYoseizo_SpawnEffects(this, globalCtx, 0); } static s16 sDemoEffectLightColors[] = { DEMO_EFFECT_LIGHT_GREEN, DEMO_EFFECT_LIGHT_RED, DEMO_EFFECT_LIGHT_BLUE }; @@ -693,7 +692,7 @@ void BgDyYoseizo_Give_Reward(BgDyYoseizo* this, GlobalContext* globalCtx) { actionIndex = globalCtx->csCtx.npcActions[0]->action - 4; if (globalCtx->sceneNum == SCENE_DAIYOUSEI_IZUMI) { actionIndex++; - BgDyYoseizo_SpawnParticles(this, globalCtx, actionIndex); + BgDyYoseizo_SpawnEffects(this, globalCtx, actionIndex); } else if (!this->lightBallSpawned) { demoEffectParams = ((s16)(sDemoEffectLightColors[actionIndex] << 0xC) | DEMO_EFFECT_LIGHT); @@ -702,7 +701,7 @@ void BgDyYoseizo_Give_Reward(BgDyYoseizo* this, GlobalContext* globalCtx) { this->lightBallSpawned = true; } } else { - BgDyYoseizo_SpawnParticles(this, globalCtx, 0); + BgDyYoseizo_SpawnEffects(this, globalCtx, 0); } if ((globalCtx->sceneNum == SCENE_DAIYOUSEI_IZUMI) && (globalCtx->csCtx.npcActions[0]->action >= 10) && @@ -861,7 +860,7 @@ void BgDyYoseizo_Update(Actor* thisx, GlobalContext* globalCtx2) { Actor_SetFocus(&this->actor, this->heightOffset); this->actor.focus.pos.y = this->heightOffset; func_80038290(globalCtx, &this->actor, &this->headRot, &this->torsoRot, this->actor.focus.pos); - BgDyYoseizo_ParticleUpdate(this, globalCtx); + BgDyYoseizo_UpdateEffects(this, globalCtx); Actor_SetScale(&this->actor, this->scale); } @@ -909,38 +908,38 @@ void BgDyYoseizo_Draw(Actor* thisx, GlobalContext* globalCtx) { this->skelAnime.dListCount, BgDyYoseizo_OverrideLimbDraw, NULL, this); } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_dy_yoseizo.c", 1629); - BgDyYoseizo_ParticleDraw(this, globalCtx); + BgDyYoseizo_DrawEffects(this, globalCtx); } -void BgDyYoseizo_ParticleInit(BgDyYoseizo* this, Vec3f* initPos, Vec3f* initVelocity, Vec3f* accel, - Color_RGB8* primColor, Color_RGB8* envColor, f32 scale, s16 life, s16 type) { - BgDyYoseizoParticle* particle; +void BgDyYoseizo_SpawnEffect(BgDyYoseizo* this, Vec3f* initPos, Vec3f* initVelocity, Vec3f* accel, + Color_RGB8* primColor, Color_RGB8* envColor, f32 scale, s16 life, s16 type) { + BgDyYoseizoEffect* effect; s16 i; - particle = this->particles; + effect = this->effects; - for (i = 0; i < 200; i++, particle++) { - if (particle->alive == 0) { - particle->alive = 1; - particle->pos = *initPos; - particle->velocity = *initVelocity; - particle->accel = *accel; - particle->primColor = *primColor; - particle->alpha = 0; - particle->envColor = *envColor; - particle->scale = scale; - particle->timer = life; - particle->type = type; - particle->pitch = 0.0f; - particle->yaw = Rand_CenteredFloat(30000.0f); - particle->roll = 0.0f; + for (i = 0; i < BG_DY_YOSEIZO_EFFECT_COUNT; i++, effect++) { + if (effect->alive == 0) { + effect->alive = 1; + effect->pos = *initPos; + effect->velocity = *initVelocity; + effect->accel = *accel; + effect->primColor = *primColor; + effect->alpha = 0; + effect->envColor = *envColor; + effect->scale = scale; + effect->timer = life; + effect->type = type; + effect->pitch = 0.0f; + effect->yaw = Rand_CenteredFloat(30000.0f); + effect->roll = 0.0f; return; } } } -void BgDyYoseizo_ParticleUpdate(BgDyYoseizo* this, GlobalContext* globalCtx) { - BgDyYoseizoParticle* particle = this->particles; +void BgDyYoseizo_UpdateEffects(BgDyYoseizo* this, GlobalContext* globalCtx) { + BgDyYoseizoEffect* effect = this->effects; Player* player = GET_PLAYER(globalCtx); Vec3f sp94; Vec3f sp88; @@ -948,17 +947,17 @@ void BgDyYoseizo_ParticleUpdate(BgDyYoseizo* this, GlobalContext* globalCtx) { f32 goalYaw; s16 i = 0; - for (i = 0; i < 200; i++, particle++) { - if (particle->alive != 0) { - particle->roll += 3000.0f; + for (i = 0; i < BG_DY_YOSEIZO_EFFECT_COUNT; i++, effect++) { + if (effect->alive != 0) { + effect->roll += 3000.0f; - if (particle->type == 0) { - particle->pos.x += particle->velocity.x; - particle->pos.y += particle->velocity.y; - particle->pos.z += particle->velocity.z; - particle->velocity.x += particle->accel.x; - particle->velocity.y += particle->accel.y; - particle->velocity.z += particle->accel.z; + if (effect->type == 0) { + effect->pos.x += effect->velocity.x; + effect->pos.y += effect->velocity.y; + effect->pos.z += effect->velocity.z; + effect->velocity.x += effect->accel.x; + effect->velocity.y += effect->accel.y; + effect->velocity.z += effect->accel.z; } else { Audio_PlayActorSound2(&this->actor, NA_SE_EV_HEALING - SFX_FLAG); @@ -966,69 +965,69 @@ void BgDyYoseizo_ParticleUpdate(BgDyYoseizo* this, GlobalContext* globalCtx) { sp94.y = player->actor.world.pos.y - 150.0f; sp94.z = player->actor.world.pos.z - 50.0f; - goalPitch = Math_Vec3f_Pitch(&particle->pos, &sp94); - goalYaw = Math_Vec3f_Yaw(&particle->pos, &sp94); + goalPitch = Math_Vec3f_Pitch(&effect->pos, &sp94); + goalYaw = Math_Vec3f_Yaw(&effect->pos, &sp94); - Math_ApproachF(&particle->pitch, goalPitch, 0.9f, 5000.0f); - Math_ApproachF(&particle->yaw, goalYaw, 0.9f, 5000.0f); + Math_ApproachF(&effect->pitch, goalPitch, 0.9f, 5000.0f); + Math_ApproachF(&effect->yaw, goalYaw, 0.9f, 5000.0f); Matrix_Push(); - Matrix_RotateY(BINANG_TO_RAD_ALT(particle->yaw), MTXMODE_NEW); - Matrix_RotateX(BINANG_TO_RAD_ALT(particle->pitch), MTXMODE_APPLY); + Matrix_RotateY(BINANG_TO_RAD_ALT(effect->yaw), MTXMODE_NEW); + Matrix_RotateX(BINANG_TO_RAD_ALT(effect->pitch), MTXMODE_APPLY); sp94.x = sp94.y = sp94.z = 3.0f; Matrix_MultVec3f(&sp94, &sp88); Matrix_Pop(); - particle->pos.x += sp88.x; - particle->pos.y += sp88.y; - particle->pos.z += sp88.z; + effect->pos.x += sp88.x; + effect->pos.y += sp88.y; + effect->pos.z += sp88.z; } } // fade up, fade down, vanish and reset - if (particle->timer != 0) { - particle->timer--; - particle->alpha += 30; + if (effect->timer != 0) { + effect->timer--; + effect->alpha += 30; - if (particle->alpha > 255) { - particle->alpha = 255; + if (effect->alpha > 255) { + effect->alpha = 255; } } else { - particle->alpha -= 30; + effect->alpha -= 30; - if (particle->alpha <= 0) { - particle->alpha = particle->alive = 0; + if (effect->alpha <= 0) { + effect->alpha = effect->alive = 0; } } } } -void BgDyYoseizo_ParticleDraw(BgDyYoseizo* this, GlobalContext* globalCtx) { +void BgDyYoseizo_DrawEffects(BgDyYoseizo* this, GlobalContext* globalCtx) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - u8 phi_s3 = 0; - BgDyYoseizoParticle* particle = this->particles; + u8 materialFlag = 0; + BgDyYoseizoEffect* effect = this->effects; s16 i; OPEN_DISPS(gfxCtx, "../z_bg_dy_yoseizo.c", 1767); func_80093D84(globalCtx->state.gfxCtx); - for (i = 0; i < 200; i++, particle++) { - if (particle->alive == 1) { - if (phi_s3 == 0) { + for (i = 0; i < BG_DY_YOSEIZO_EFFECT_COUNT; i++, effect++) { + if (effect->alive == 1) { + if (materialFlag == 0) { gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gGreatFairyParticleMaterialDL)); gDPPipeSync(POLY_XLU_DISP++); - phi_s3++; + materialFlag++; } - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, particle->primColor.r, particle->primColor.g, particle->primColor.b, - particle->alpha); - gDPSetEnvColor(POLY_XLU_DISP++, particle->envColor.r, particle->envColor.g, particle->envColor.b, 0); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, effect->primColor.r, effect->primColor.g, effect->primColor.b, + effect->alpha); + gDPSetEnvColor(POLY_XLU_DISP++, effect->envColor.r, effect->envColor.g, effect->envColor.b, 0); - Matrix_Translate(particle->pos.x, particle->pos.y, particle->pos.z, MTXMODE_NEW); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&globalCtx->billboardMtxF); - Matrix_Scale(particle->scale, particle->scale, 1.0f, MTXMODE_APPLY); - Matrix_RotateZ(particle->roll, MTXMODE_APPLY); + Matrix_Scale(effect->scale, effect->scale, 1.0f, MTXMODE_APPLY); + Matrix_RotateZ(effect->roll, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_bg_dy_yoseizo.c", 1810), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.h b/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.h index 59abc6065c..d77987077f 100644 --- a/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.h +++ b/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.h @@ -10,6 +10,8 @@ struct BgDyYoseizo; typedef void (*BgDyYoseizoActionFunc)(struct BgDyYoseizo*, GlobalContext*); +#define BG_DY_YOSEIZO_EFFECT_COUNT 200 + typedef struct { /* 0x00 */ u8 alive; // drawn if 1, respawn if 0 /* 0x04 */ Vec3f pos; @@ -24,7 +26,7 @@ typedef struct { /* 0x36 */ f32 pitch; /* 0x36 */ f32 yaw; /* 0x40 */ f32 roll; -} BgDyYoseizoParticle; // size = 0x44 +} BgDyYoseizoEffect; // size = 0x44 typedef struct BgDyYoseizo { /* 0x0000 */ Actor actor; @@ -67,7 +69,7 @@ typedef struct BgDyYoseizo { /* 0x0340 */ EnDyExtra* beam; /* 0x0344 */ EnExItem* item; /* 0x0348 */ char unk_348[0x4C]; - /* 0x0394 */ BgDyYoseizoParticle particles[200]; + /* 0x0394 */ BgDyYoseizoEffect effects[BG_DY_YOSEIZO_EFFECT_COUNT]; } BgDyYoseizo; // size = 0x38B4 #endif diff --git a/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c b/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c index c6c77676bc..6c39d10b93 100644 --- a/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c +++ b/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c @@ -130,11 +130,11 @@ void func_808C1554(void* arg0, void* floorTex, s32 arg2, f32 arg3) { } } -void func_808C17C8(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, f32 arg4, s16 arg5) { +void func_808C17C8(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, f32 arg4, s16 countLimit) { s16 i; BossDodongoEffect* eff = (BossDodongoEffect*)globalCtx->specialEffects; - for (i = 0; i < arg5; i++, eff++) { + for (i = 0; i < countLimit; i++, eff++) { if (eff->unk_24 == 0) { eff->unk_24 = 1; eff->unk_00 = *arg1; @@ -183,7 +183,7 @@ void BossDodongo_Init(Actor* thisx, GlobalContext* globalCtx) { u16* temp_s2; u32 temp_v0; - globalCtx->specialEffects = &this->effects; + globalCtx->specialEffects = this->effects; Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 9200.0f, ActorShadow_DrawCircle, 250.0f); Actor_SetScale(&this->actor, 0.01f); @@ -991,7 +991,8 @@ void BossDodongo_Update(Actor* thisx, GlobalContext* globalCtx2) { sp54.x = sinf(sp4C) * sp50 + (-890.0f); sp54.y = -1513.76f; sp54.z = cosf(sp4C) * sp50 + (-3304.0f); - func_808C17C8(globalCtx, &sp54, &sp6C, &sp60, ((s16)Rand_ZeroFloat(2.0f)) + 6, 0x50); + func_808C17C8(globalCtx, &sp54, &sp6C, &sp60, ((s16)Rand_ZeroFloat(2.0f)) + 6, + BOSS_DODONGO_EFFECT_COUNT); } } @@ -1645,7 +1646,7 @@ void BossDodongo_UpdateEffects(GlobalContext* globalCtx) { s16 colorIndex; s16 i; - for (i = 0; i < 80; i++, eff++) { + for (i = 0; i < BOSS_DODONGO_EFFECT_COUNT; i++, eff++) { if (eff->unk_24 != 0) { eff->unk_00.x += eff->unk_0C.x; eff->unk_00.y += eff->unk_0C.y; @@ -1672,7 +1673,7 @@ void BossDodongo_UpdateEffects(GlobalContext* globalCtx) { void BossDodongo_DrawEffects(GlobalContext* globalCtx) { MtxF* unkMtx; s16 i; - u8 phi_s3 = 0; + u8 materialFlag = 0; BossDodongoEffect* eff; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; @@ -1683,13 +1684,13 @@ void BossDodongo_DrawEffects(GlobalContext* globalCtx) { func_80093D84(globalCtx->state.gfxCtx); unkMtx = &globalCtx->billboardMtxF; - for (i = 0; i < 80; i++, eff++) { + for (i = 0; i < BOSS_DODONGO_EFFECT_COUNT; i++, eff++) { if (eff->unk_24 == 1) { gDPPipeSync(POLY_XLU_DISP++); - if (phi_s3 == 0) { + if (materialFlag == 0) { gSPDisplayList(POLY_XLU_DISP++, object_kingdodongo_DL_009D50); - phi_s3++; + materialFlag++; } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, eff->color.r, eff->color.g, eff->color.b, eff->alpha); diff --git a/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.h b/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.h index 3bc07819e1..55d6075b71 100644 --- a/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.h +++ b/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.h @@ -8,6 +8,8 @@ struct BossDodongo; typedef void (*BossDodongoActionFunc)(struct BossDodongo*, GlobalContext*); +#define BOSS_DODONGO_EFFECT_COUNT 80 + typedef struct { /* 0x00 */ Vec3f unk_00; /* 0x0C */ Vec3f unk_0C; @@ -95,7 +97,7 @@ typedef struct BossDodongo { /* 0x0434 */ Vec3f cameraAt; /* 0x0440 */ ColliderJntSph collider; /* 0x0460 */ ColliderJntSphElement items[19]; - /* 0x0920 */ BossDodongoEffect effects[80]; + /* 0x0920 */ BossDodongoEffect effects[BOSS_DODONGO_EFFECT_COUNT]; } BossDodongo; // size = 0x1820 #endif diff --git a/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c b/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c index 15f50d6381..6a4c8710a6 100644 --- a/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c +++ b/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c @@ -1433,7 +1433,7 @@ void BossFd_UpdateEffects(BossFd* this, GlobalContext* globalCtx) { s16 i1; s16 i2; - for (i1 = 0; i1 < 180; i1++, effect++) { + for (i1 = 0; i1 < BOSSFD_EFFECT_COUNT; i1++, effect++) { if (effect->type != BFD_FX_NONE) { effect->timer1++; @@ -1512,19 +1512,19 @@ void BossFd_DrawEffects(BossFdEffect* effect, GlobalContext* globalCtx) { static void* dustTex[] = { gDust1Tex, gDust1Tex, gDust2Tex, gDust3Tex, gDust4Tex, gDust5Tex, gDust6Tex, gDust7Tex, gDust8Tex, }; - u8 flag = false; + u8 materialFlag = 0; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; s16 i; BossFdEffect* firstEffect = effect; OPEN_DISPS(gfxCtx, "../z_boss_fd.c", 4023); - for (i = 0; i < 180; i++, effect++) { + for (i = 0; i < BOSSFD_EFFECT_COUNT; i++, effect++) { if (effect->type == BFD_FX_EMBER) { - if (!flag) { + if (materialFlag == 0) { func_80093D84(globalCtx->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, gVolvagiaEmberMaterialDL); - flag++; + materialFlag++; } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, effect->color.r, effect->color.g, effect->color.b, effect->alpha); @@ -1539,13 +1539,13 @@ void BossFd_DrawEffects(BossFdEffect* effect, GlobalContext* globalCtx) { } effect = firstEffect; - flag = false; - for (i = 0; i < 180; i++, effect++) { + materialFlag = 0; + for (i = 0; i < BOSSFD_EFFECT_COUNT; i++, effect++) { if (effect->type == BFD_FX_DEBRIS) { - if (!flag) { + if (materialFlag == 0) { func_80093D18(globalCtx->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, gVolvagiaDebrisMaterialDL); - flag++; + materialFlag++; } Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); @@ -1560,15 +1560,15 @@ void BossFd_DrawEffects(BossFdEffect* effect, GlobalContext* globalCtx) { } effect = firstEffect; - flag = false; - for (i = 0; i < 180; i++, effect++) { + materialFlag = 0; + for (i = 0; i < BOSSFD_EFFECT_COUNT; i++, effect++) { if (effect->type == BFD_FX_DUST) { - if (!flag) { + if (materialFlag == 0) { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); gSPDisplayList(POLY_XLU_DISP++, gVolvagiaDustMaterialDL); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 90, 30, 0, 255); gDPSetEnvColor(POLY_XLU_DISP++, 90, 30, 0, 0); - flag++; + materialFlag++; } Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); @@ -1583,14 +1583,14 @@ void BossFd_DrawEffects(BossFdEffect* effect, GlobalContext* globalCtx) { } effect = firstEffect; - flag = false; - for (i = 0; i < 180; i++, effect++) { + materialFlag = 0; + for (i = 0; i < BOSSFD_EFFECT_COUNT; i++, effect++) { if (effect->type == BFD_FX_FIRE_BREATH) { - if (!flag) { + if (materialFlag == 0) { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); gSPDisplayList(POLY_XLU_DISP++, gVolvagiaDustMaterialDL); gDPSetEnvColor(POLY_XLU_DISP++, 255, 10, 0, 255); - flag++; + materialFlag++; } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 0, effect->alpha); @@ -1606,13 +1606,13 @@ void BossFd_DrawEffects(BossFdEffect* effect, GlobalContext* globalCtx) { } effect = firstEffect; - flag = false; - for (i = 0; i < 180; i++, effect++) { + materialFlag = 0; + for (i = 0; i < BOSSFD_EFFECT_COUNT; i++, effect++) { if (effect->type == BFD_FX_SKULL_PIECE) { - if (!flag) { + if (materialFlag == 0) { func_80093D84(globalCtx->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, gVolvagiaSkullPieceMaterialDL); - flag++; + materialFlag++; } Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); diff --git a/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.h b/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.h index ea24fd346e..223f9ae485 100644 --- a/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.h +++ b/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.h @@ -36,6 +36,8 @@ typedef enum { /* 6 */ BFD_CS_EMERGE } BossFdCutsceneState; +#define BOSSFD_EFFECT_COUNT 180 + typedef struct { /* 0x00 */ Vec3f pos; /* 0x0C */ Vec3f velocity; @@ -51,8 +53,6 @@ typedef struct { /* 0x38 */ f32 bFdFxFloat2; } BossFdEffect; // size = 0x3C -#define BOSSFD_EFFECT_COUNT 180 - #define vFdFxRotX bFdFxFloat1 #define vFdFxScaleMod bFdFxFloat1 #define vFdFxRotY bFdFxFloat2 @@ -179,7 +179,7 @@ typedef struct BossFd { /* 0x1408 */ BossFdCam camData; /* 0x1490 */ ColliderJntSph collider; /* 0x14B0 */ ColliderJntSphElement elements[19]; - /* 0x1970 */ BossFdEffect effects[180]; + /* 0x1970 */ BossFdEffect effects[BOSSFD_EFFECT_COUNT]; } BossFd; // size = 0x43A0 #endif 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 f3acdf9f4e..c2ab26a1f9 100644 --- a/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c +++ b/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c @@ -110,6 +110,8 @@ static BossGanon* sGanondorf; static EnZl3* sZelda; +#define BOSSGANON_EFFECT_COUNT 200 + typedef struct { /* 0x00 */ u8 type; /* 0x01 */ u8 timer; @@ -128,7 +130,7 @@ typedef struct { /* 0x48 */ f32 unk_48; // mostly y rot } GanondorfEffect; // size = 0x4C -GanondorfEffect sEffectBuf[200]; +GanondorfEffect sEffects[BOSSGANON_EFFECT_COUNT]; void BossGanonEff_SpawnWindowShard(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, f32 scale) { static Color_RGB8 shardColors[] = { { 255, 175, 85 }, { 155, 205, 155 }, { 155, 125, 55 } }; @@ -343,10 +345,10 @@ void BossGanon_Init(Actor* thisx, GlobalContext* globalCtx2) { if (thisx->params < 0x64) { Flags_SetSwitch(globalCtx, 0x14); - globalCtx->specialEffects = sEffectBuf; + globalCtx->specialEffects = sEffects; - for (i = 0; i < ARRAY_COUNT(sEffectBuf); i++) { - sEffectBuf[i].type = GDF_EFF_NONE; + for (i = 0; i < BOSSGANON_EFFECT_COUNT; i++) { + sEffects[i].type = GDF_EFF_NONE; } sGanondorf = this; @@ -4610,7 +4612,7 @@ void BossGanon_UpdateEffects(GlobalContext* globalCtx) { spA0.x = 0.0f; spA0.y = 0.0f; - for (i = 0; i < ARRAY_COUNT(sEffectBuf); i++, eff++) { + for (i = 0; i < BOSSGANON_EFFECT_COUNT; i++, eff++) { if (eff->type != GDF_EFF_NONE) { eff->pos.x += eff->velocity.x; eff->pos.y += eff->velocity.y; @@ -4808,7 +4810,7 @@ static u8 sLightningEnvColors[] = { }; void BossGanon_DrawEffects(GlobalContext* globalCtx) { - u8 flag = 0; + u8 materialFlag = 0; s16 i; s32 pad; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; @@ -4821,9 +4823,9 @@ void BossGanon_DrawEffects(GlobalContext* globalCtx) { for (i = 0; i < 200; i++, eff++) { if (eff->type == GDF_EFF_WINDOW_SHARD) { gDPPipeSync(POLY_OPA_DISP++); - if (flag == 0) { + if (materialFlag == 0) { gSPDisplayList(POLY_OPA_DISP++, gDorfWindowShardMaterialDL); - flag++; + materialFlag++; } if ((eff->timer & 7) != 0) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, eff->color.r, eff->color.g, eff->color.b, 255); @@ -4841,15 +4843,15 @@ void BossGanon_DrawEffects(GlobalContext* globalCtx) { } eff = effFirst; - flag = 0; + materialFlag = 0; for (i = 0; i < 150; i++, eff++) { if (eff->type == GDF_EFF_SPARKLE) { gDPPipeSync(POLY_XLU_DISP++); - if (flag == 0) { + if (materialFlag == 0) { gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 0, 0); gSPDisplayList(POLY_XLU_DISP++, gDorfLightBallMaterialDL); - flag++; + materialFlag++; } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, eff->alpha); Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); @@ -4863,15 +4865,15 @@ void BossGanon_DrawEffects(GlobalContext* globalCtx) { } eff = effFirst; - flag = 0; + materialFlag = 0; for (i = 0; i < 150; i++, eff++) { if (eff->type == GDF_EFF_LIGHT_RAY) { gDPPipeSync(POLY_XLU_DISP++); - if (flag == 0) { + if (materialFlag == 0) { gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 0, 0); gSPDisplayList(POLY_XLU_DISP++, gDorfLightBallMaterialDL); - flag++; + materialFlag++; } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, eff->alpha); Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); @@ -4887,11 +4889,11 @@ void BossGanon_DrawEffects(GlobalContext* globalCtx) { } eff = effFirst; - flag = 0; + materialFlag = 0; for (i = 0; i < 150; i++, eff++) { if (eff->type == GDF_EFF_SHOCK) { - if (flag == 0) { + if (materialFlag == 0) { gDPPipeSync(POLY_XLU_DISP++); if (eff->unk_2E == GDF_SHOCK_PLAYER_PURPLE) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 100, 0, 200, 255); @@ -4900,7 +4902,7 @@ void BossGanon_DrawEffects(GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 0, 0); } - flag++; + materialFlag++; } Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); Matrix_Scale(eff->scale, eff->scale, 1.0f, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c b/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c index 04a27e1c12..1d84580196 100644 --- a/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c +++ b/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c @@ -26,8 +26,8 @@ void func_80900580(BossGanon2* this, GlobalContext* globalCtx); void func_80900650(BossGanon2* this, GlobalContext* globalCtx); void func_80900890(BossGanon2* this, GlobalContext* globalCtx); void func_8090120C(BossGanon2* this, GlobalContext* globalCtx); -void func_80905DA8(BossGanon2* this, GlobalContext* globalCtx); -void func_809060E8(GlobalContext* globalCtx); +void BossGanon2_UpdateEffects(BossGanon2* this, GlobalContext* globalCtx); +void BossGanon2_DrawEffects(GlobalContext* globalCtx); void BossGanon2_GenShadowTexture(void* shadowTexture, BossGanon2* this, GlobalContext* globalCtx); void BossGanon2_DrawShadowTexture(void* shadowTexture, BossGanon2* this, GlobalContext* globalCtx); @@ -92,25 +92,25 @@ void BossGanon2_SetObjectSegment(BossGanon2* this, GlobalContext* globalCtx, s32 } void func_808FD210(GlobalContext* globalCtx, Vec3f* arg1) { - BossGanon2Effect* effect = globalCtx->specialEffects; + BossGanon2Effect* effects = globalCtx->specialEffects; - effect->type = 1; - effect->position = *arg1; - effect->unk_2E = 0; - effect->unk_01 = 0; - effect->velocity.x = 25.0f; - effect->velocity.y = 15.0f; - effect->velocity.z = 0.0f; - effect->accel.x = 0.0f; - effect->accel.y = -1.0f; - effect->accel.z = 0.0f; + effects[0].type = 1; + effects[0].position = *arg1; + effects[0].unk_2E = 0; + effects[0].unk_01 = 0; + effects[0].velocity.x = 25.0f; + effects[0].velocity.y = 15.0f; + effects[0].velocity.z = 0.0f; + effects[0].accel.x = 0.0f; + effects[0].accel.y = -1.0f; + effects[0].accel.z = 0.0f; } void func_808FD27C(GlobalContext* globalCtx, Vec3f* position, Vec3f* velocity, f32 scale) { BossGanon2Effect* effect = globalCtx->specialEffects; s16 i; - for (i = 0; i < ARRAY_COUNT(sParticles); i++, effect++) { + for (i = 0; i < BOSS_GANON2_EFFECT_COUNT; i++, effect++) { if (effect->type == 0) { effect->type = 2; effect->position = *position; @@ -132,10 +132,10 @@ void BossGanon2_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; s16 i; - globalCtx->specialEffects = sParticles; + globalCtx->specialEffects = sEffects; - for (i = 0; i < ARRAY_COUNT(sParticles); i++) { - sParticles[i].type = 0; + for (i = 0; i < BOSS_GANON2_EFFECT_COUNT; i++) { + sEffects[i].type = 0; } this->actor.colChkInfo.mass = MASS_IMMOVABLE; @@ -737,12 +737,12 @@ void func_808FD5F4(BossGanon2* this, GlobalContext* globalCtx) { case 24: SkelAnime_Update(&this->skelAnime); if (1) { - BossGanon2Effect* effect = globalCtx->specialEffects; + BossGanon2Effect* effects = globalCtx->specialEffects; - this->unk_3B0 = effect->position; - this->unk_3A4.x = effect->position.x + 70.0f; - this->unk_3A4.y = effect->position.y - 30.0f; - this->unk_3A4.z = effect->position.z + 70.0f; + this->unk_3B0 = effects[0].position; + this->unk_3A4.x = effects[0].position.x + 70.0f; + this->unk_3A4.y = effects[0].position.y - 30.0f; + this->unk_3A4.z = effects[0].position.z + 70.0f; } if ((this->unk_398 & 3) == 0) { func_80078884(NA_SE_IT_SWORD_SWING); @@ -762,15 +762,15 @@ void func_808FD5F4(BossGanon2* this, GlobalContext* globalCtx) { this->unk_3B0.y = ((player->actor.world.pos.y + 10.0f + 60.0f) - 20.0f) - 3.0f; this->unk_3B0.z = (player->actor.world.pos.z - 40.0f) - 10.0f; if (this->unk_398 == 10) { - BossGanon2Effect* effect = globalCtx->specialEffects; + BossGanon2Effect* effects = globalCtx->specialEffects; - effect->unk_2E = 1; - effect->position.x = sZelda->actor.world.pos.x + 50.0f + 10.0f; - effect->position.y = sZelda->actor.world.pos.y + 350.0f; - effect->position.z = sZelda->actor.world.pos.z - 25.0f; - effect->velocity.x = 0.0f; - effect->velocity.z = 0.0f; - effect->velocity.y = -30.0f; + effects[0].unk_2E = 1; + effects[0].position.x = sZelda->actor.world.pos.x + 50.0f + 10.0f; + effects[0].position.y = sZelda->actor.world.pos.y + 350.0f; + effects[0].position.z = sZelda->actor.world.pos.z - 25.0f; + effects[0].velocity.x = 0.0f; + effects[0].velocity.z = 0.0f; + effects[0].velocity.y = -30.0f; this->unk_39C = 26; this->unk_398 = 0; } else { @@ -2164,7 +2164,7 @@ void BossGanon2_Update(Actor* thisx, GlobalContext* globalCtx) { if (D_80906D78 != 0) { D_80906D78 = 0; - for (i2 = 0; i2 < ARRAY_COUNT(sParticles); i2++) { + for (i2 = 0; i2 < 100; i2++) { angle = Rand_ZeroFloat(2 * M_PI); sp44 = Rand_ZeroFloat(40.0f) + 10.0f; sp58 = this->actor.world.pos; @@ -2178,7 +2178,7 @@ void BossGanon2_Update(Actor* thisx, GlobalContext* globalCtx) { } } this->unk_388 += 0.15f; - func_80905DA8(this, globalCtx); + BossGanon2_UpdateEffects(this, globalCtx); } void func_809034E4(Vec3f* arg0, Vec3f* arg1) { @@ -2812,17 +2812,17 @@ void BossGanon2_Draw(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5983); - func_809060E8(globalCtx); + BossGanon2_DrawEffects(globalCtx); } -void func_80905DA8(BossGanon2* this, GlobalContext* globalCtx) { +void BossGanon2_UpdateEffects(BossGanon2* this, GlobalContext* globalCtx) { s32 pad[5]; Player* player = GET_PLAYER(globalCtx); BossGanon2Effect* effect = globalCtx->specialEffects; Vec3f sp78; s16 i; - for (i = 0; i < ARRAY_COUNT(sParticles); i++, effect++) { + for (i = 0; i < BOSS_GANON2_EFFECT_COUNT; i++, effect++) { if (effect->type != 0) { effect->position.x += effect->velocity.x; effect->position.y += effect->velocity.y; @@ -2877,9 +2877,9 @@ void func_80905DA8(BossGanon2* this, GlobalContext* globalCtx) { } } -void func_809060E8(GlobalContext* globalCtx) { +void BossGanon2_DrawEffects(GlobalContext* globalCtx) { s16 alpha; - u8 usingObjectGEff = false; + u8 objectFlag = 0; BossGanon2Effect* effect; s16 i; BossGanon2Effect* effects; @@ -2930,11 +2930,11 @@ void func_809060E8(GlobalContext* globalCtx) { effect = effects; - for (i = 0; i < ARRAY_COUNT(sParticles); i++, effect++) { + for (i = 0; i < BOSS_GANON2_EFFECT_COUNT; i++, effect++) { if (effect->type == 2) { - if (!usingObjectGEff) { + if (objectFlag == 0) { BossGanon2_SetObjectSegment(NULL, globalCtx, OBJECT_GEFF, true); - usingObjectGEff++; + objectFlag++; } Matrix_Translate(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2_data.c b/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2_data.c index 3f36cf19a5..46b6fb5089 100644 --- a/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2_data.c +++ b/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2_data.c @@ -2,6 +2,8 @@ #include "overlays/actors/ovl_En_Zl3/z_en_zl3.h" #include "objects/object_ganon2/object_ganon2.h" +#define BOSS_GANON2_EFFECT_COUNT 100 + typedef struct { /* 0x00 */ u8 type; /* 0x01 */ u8 unk_01; @@ -340,7 +342,7 @@ static Actor* D_8090EB30; // unused static UNK_TYPE D_8090EB34; -static BossGanon2Effect sParticles[100]; +static BossGanon2Effect sEffects[BOSS_GANON2_EFFECT_COUNT]; static s32 sSeed1; static s32 sSeed2; diff --git a/src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.c b/src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.c index af64376365..680ab2edb9 100644 --- a/src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.c +++ b/src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.c @@ -897,7 +897,7 @@ void BossGanondrof_Charge(BossGanondrof* this, GlobalContext* globalCtx) { Matrix_Push(); Matrix_RotateY(BINANG_TO_RAD_ALT(thisx->shape.rot.y), MTXMODE_NEW); Matrix_RotateX(BINANG_TO_RAD_ALT(thisx->shape.rot.x), MTXMODE_APPLY); - Matrix_RotateZ(BINANG_TO_RAD_ALT(this->work[GND_PARTICLE_ANGLE]), MTXMODE_APPLY); + Matrix_RotateZ(BINANG_TO_RAD_ALT(this->work[GND_EFFECT_ANGLE]), MTXMODE_APPLY); Matrix_MultVec3f(&baseOffset, &offset); Matrix_Pop(); pos.x = this->spearTip.x + offset.x; @@ -910,7 +910,7 @@ void BossGanondrof_Charge(BossGanondrof* this, GlobalContext* globalCtx) { accel.y = (offset.y * -50.0f) / 1000.0f; accel.z = (offset.z * -50.0f) / 1000.0f; EffectSsFhgFlash_SpawnLightBall(globalCtx, &pos, &vel, &accel, 150, i % 7); - this->work[GND_PARTICLE_ANGLE] += 0x1A5C; + this->work[GND_EFFECT_ANGLE] += 0x1A5C; } } diff --git a/src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.h b/src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.h index 8b0616baca..5621821a1d 100644 --- a/src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.h +++ b/src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.h @@ -42,7 +42,7 @@ typedef enum { /* 9 */ GND_THROW_COUNT, /* 10 */ GND_MASK_OFF, /* 11 */ GND_EYE_STATE, - /* 12 */ GND_PARTICLE_ANGLE, + /* 12 */ GND_EFFECT_ANGLE, /* 13 */ GND_BODY_DECAY_INDEX, /* 14 */ GND_BODY_DECAY_FLAG, /* 15 */ GND_LIMB_DECAY_INDEX, diff --git a/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c b/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c index ba5eca139f..72b0ca40b4 100644 --- a/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c +++ b/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c @@ -18,6 +18,8 @@ ((tent != NULL) && \ ((tent->work[MO_TENT_ACTION_STATE] == MO_TENT_GRAB) || (tent->work[MO_TENT_ACTION_STATE] == MO_TENT_SHAKE))) +#define BOSS_MO_EFFECT_COUNT 300 + typedef struct { /* 0x00 */ Vec3f pos; /* 0x0C */ Vec3f vel; @@ -140,7 +142,7 @@ static f32 sFlatWidth[41] = { #include "z_boss_mo_colchk.c" -static BossMoEffect sEffects[300]; +static BossMoEffect sEffects[BOSS_MO_EFFECT_COUNT]; static s32 sSeed1; static s32 sSeed2; static s32 sSeed3; @@ -184,12 +186,12 @@ s32 BossMo_NearLand(Vec3f* pos, f32 margin) { return false; } -void BossMo_SpawnRipple(BossMoEffect* effect, Vec3f* pos, f32 scale, f32 maxScale, s16 maxAlpha, s16 partLimit, +void BossMo_SpawnRipple(BossMoEffect* effect, Vec3f* pos, f32 scale, f32 maxScale, s16 maxAlpha, s16 countLimit, u8 type) { static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; s16 i; - for (i = 0; i < partLimit; i++, effect++) { + for (i = 0; i < countLimit; i++, effect++) { if (effect->type == MO_FX_NONE) { effect->stopTimer = 0; effect->type = type; @@ -335,7 +337,7 @@ void BossMo_Init(Actor* thisx, GlobalContext* globalCtx2) { MO_WATER_LEVEL(globalCtx) = this->waterLevel = MO_WATER_LEVEL(globalCtx); globalCtx->roomCtx.unk_74[0] = 0xA0; globalCtx->specialEffects = sEffects; - for (i = 0; i < ARRAY_COUNT(sEffects); i++) { + for (i = 0; i < BOSS_MO_EFFECT_COUNT; i++) { sEffects[i].type = MO_FX_NONE; } this->actor.world.pos.x = 200.0f; @@ -2751,7 +2753,7 @@ void BossMo_UpdateEffects(BossMo* this, GlobalContext* globalCtx) { Vec3f bubbleSpeed = { 0.0f, 0.0f, 0.0f }; Vec3f bubbleVel; - for (i = 0; i < ARRAY_COUNT(sEffects); i++, effect++) { + for (i = 0; i < BOSS_MO_EFFECT_COUNT; i++, effect++) { if (effect->type != MO_FX_NONE) { effect->timer++; if (effect->stopTimer == 0) { @@ -2896,7 +2898,7 @@ void BossMo_UpdateEffects(BossMo* this, GlobalContext* globalCtx) { } void BossMo_DrawEffects(BossMoEffect* effect, GlobalContext* globalCtx) { - u8 flag = 0; + u8 materialFlag = 0; s16 i; s32 pad; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; @@ -2905,14 +2907,14 @@ void BossMo_DrawEffects(BossMoEffect* effect, GlobalContext* globalCtx) { OPEN_DISPS(gfxCtx, "../z_boss_mo.c", 7264); Matrix_Push(); - for (i = 0; i < ARRAY_COUNT(sEffects); i++, effect++) { + for (i = 0; i < BOSS_MO_EFFECT_COUNT; i++, effect++) { if (effect->type == MO_FX_BIG_RIPPLE) { - if (flag == 0) { + if (materialFlag == 0) { func_80094BC4(gfxCtx); gDPSetEnvColor(POLY_XLU_DISP++, 155, 155, 255, 0); - flag++; + materialFlag++; } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, effect->alpha); @@ -2927,15 +2929,15 @@ void BossMo_DrawEffects(BossMoEffect* effect, GlobalContext* globalCtx) { } effect = effectHead; - flag = 0; - for (i = 0; i < ARRAY_COUNT(sEffects); i++, effect++) { + materialFlag = 0; + for (i = 0; i < BOSS_MO_EFFECT_COUNT; i++, effect++) { if (effect->type == MO_FX_SMALL_RIPPLE) { - if (flag == 0) { + if (materialFlag == 0) { func_80093D84(globalCtx->state.gfxCtx); gDPSetEnvColor(POLY_XLU_DISP++, 155, 155, 255, 0); - flag++; + materialFlag++; } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, effect->alpha); @@ -2950,18 +2952,18 @@ void BossMo_DrawEffects(BossMoEffect* effect, GlobalContext* globalCtx) { } effect = effectHead; - flag = 0; - for (i = 0; i < ARRAY_COUNT(sEffects); i++, effect++) { + materialFlag = 0; + for (i = 0; i < BOSS_MO_EFFECT_COUNT; i++, effect++) { if (((effect->type == MO_FX_DROPLET) || (effect->type == MO_FX_SPLASH)) || (effect->type == MO_FX_SPLASH_TRAIL)) { - if (flag == 0) { + if (materialFlag == 0) { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(gDust1Tex)); gSPDisplayList(POLY_XLU_DISP++, gMorphaDropletMaterialDL); gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 255, 0); - flag++; + materialFlag++; } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (s16)effect->fwork[MO_FX_SHIMMER], (s16)effect->fwork[MO_FX_SHIMMER], @@ -2979,17 +2981,17 @@ void BossMo_DrawEffects(BossMoEffect* effect, GlobalContext* globalCtx) { } effect = effectHead; - flag = 0; - for (i = 0; i < ARRAY_COUNT(sEffects); i++, effect++) { + materialFlag = 0; + for (i = 0; i < BOSS_MO_EFFECT_COUNT; i++, effect++) { if (effect->type == MO_FX_WET_SPOT) { - if (flag == 0) { + if (materialFlag == 0) { func_80094044(gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(gDust1Tex)); gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 255, 0); gSPDisplayList(POLY_XLU_DISP++, gMorphaDropletMaterialDL); - flag++; + materialFlag++; } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (s16)effect->fwork[MO_FX_SHIMMER], (s16)effect->fwork[MO_FX_SHIMMER], @@ -3005,15 +3007,15 @@ void BossMo_DrawEffects(BossMoEffect* effect, GlobalContext* globalCtx) { } effect = effectHead; - flag = 0; - for (i = 0; i < ARRAY_COUNT(sEffects); i++, effect++) { + materialFlag = 0; + for (i = 0; i < BOSS_MO_EFFECT_COUNT; i++, effect++) { if (effect->type == MO_FX_BUBBLE) { - if (flag == 0) { + if (materialFlag == 0) { func_80093D18(globalCtx->state.gfxCtx); gDPSetEnvColor(POLY_OPA_DISP++, 150, 150, 150, 0); - flag++; + materialFlag++; } gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, effect->alpha); diff --git a/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c b/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c index 6db8b63200..e2ba71adf4 100644 --- a/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c +++ b/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c @@ -52,8 +52,8 @@ void BossSst_UpdateHand(Actor* thisx, GlobalContext* globalCtx); void BossSst_UpdateHead(Actor* thisx, GlobalContext* globalCtx); void BossSst_DrawHand(Actor* thisx, GlobalContext* globalCtx); void BossSst_DrawHead(Actor* thisx, GlobalContext* globalCtx); -void BossSst_UpdateEffect(Actor* thisx, GlobalContext* globalCtx); -void BossSst_DrawEffect(Actor* thisx, GlobalContext* globalCtx); +void BossSst_UpdateEffects(Actor* thisx, GlobalContext* globalCtx); +void BossSst_DrawEffects(Actor* thisx, GlobalContext* globalCtx); void BossSst_HeadSfx(BossSst* this, u16 sfxId); @@ -1154,7 +1154,7 @@ void BossSst_HeadMelt(BossSst* this, GlobalContext* globalCtx) { } void BossSst_HeadSetupFinish(BossSst* this) { - this->actor.draw = BossSst_DrawEffect; + this->actor.draw = BossSst_DrawEffects; this->timer = 40; Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS_CLEAR); BossSst_SetCameraTargets(1.0 / 40, 6); @@ -2235,7 +2235,7 @@ void BossSst_HandMelt(BossSst* this, GlobalContext* globalCtx) { } void BossSst_HandSetupFinish(BossSst* this) { - this->actor.draw = BossSst_DrawEffect; + this->actor.draw = BossSst_DrawEffects; this->timer = 20; this->effects[0].status = 0; this->actionFunc = BossSst_HandFinish; @@ -2621,7 +2621,7 @@ void BossSst_UpdateHand(Actor* thisx, GlobalContext* globalCtx) { trail->yRotMod = this->handYRotMod; this->trailIndex = (this->trailIndex + 1) % 7; - BossSst_UpdateEffect(&this->actor, globalCtx); + BossSst_UpdateEffects(&this->actor, globalCtx); } void BossSst_UpdateHead(Actor* thisx, GlobalContext* globalCtx) { @@ -2673,7 +2673,7 @@ void BossSst_UpdateHead(Actor* thisx, GlobalContext* globalCtx) { BossSst_HeadSfx(this, NA_SE_EN_SHADEST_MOVE - SFX_FLAG); } - BossSst_UpdateEffect(&this->actor, globalCtx); + BossSst_UpdateEffects(&this->actor, globalCtx); } s32 BossSst_OverrideHandDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, @@ -2759,7 +2759,7 @@ void BossSst_DrawHand(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_sst.c", 6654); - BossSst_DrawEffect(&this->actor, globalCtx); + BossSst_DrawEffects(&this->actor, globalCtx); } s32 BossSst_OverrideHeadDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, @@ -2927,7 +2927,7 @@ void BossSst_DrawHead(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_sst.c", 6941); SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &this->actor.focus.pos, &this->center); - BossSst_DrawEffect(&this->actor, globalCtx); + BossSst_DrawEffects(&this->actor, globalCtx); } void BossSst_SpawnHeadShadow(BossSst* this) { @@ -3086,7 +3086,7 @@ void BossSst_IceShatter(BossSst* this) { } } -void BossSst_UpdateEffect(Actor* thisx, GlobalContext* globalCtx) { +void BossSst_UpdateEffects(Actor* thisx, GlobalContext* globalCtx) { BossSst* this = (BossSst*)thisx; BossSstEffect* effect; s32 i; @@ -3147,7 +3147,7 @@ void BossSst_UpdateEffect(Actor* thisx, GlobalContext* globalCtx) { } } -void BossSst_DrawEffect(Actor* thisx, GlobalContext* globalCtx) { +void BossSst_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { s32 pad; BossSst* this = (BossSst*)thisx; s32 i; diff --git a/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.h b/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.h index 8b2b311d6e..1d7ab7d85a 100644 --- a/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.h +++ b/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.h @@ -8,6 +8,7 @@ struct BossSst; typedef void (*BossSstActionFunc)(struct BossSst*, GlobalContext*); +#define BOSS_SST_EFFECT_COUNT 18 typedef struct { /* 0x0000 */ Vec3f pos; @@ -47,7 +48,7 @@ typedef struct BossSst { /* 0x03D4 */ ColliderJntSph colliderJntSph; /* 0x03F4 */ ColliderJntSphElement colliderItems[11]; /* 0x06B4 */ ColliderCylinder colliderCyl; - /* 0x0700 */ BossSstEffect effects[18]; + /* 0x0700 */ BossSstEffect effects[BOSS_SST_EFFECT_COUNT]; /* 0x09D0 */ s16 trailIndex; /* 0x09D2 */ s16 trailCount; /* 0x09D4 */ BossSstHandTrail handTrails[7]; diff --git a/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c b/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c index 4c0c19dbaa..2cc8fabd47 100644 --- a/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c +++ b/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c @@ -45,6 +45,8 @@ typedef enum { /* 0x69 */ TW_DEATHBALL_KOUME } TwinrovaType; +#define BOSS_TW_EFFECT_COUNT 150 + typedef struct { /* 0x0000 */ u8 type; /* 0x0001 */ u8 frame; @@ -229,7 +231,7 @@ static u8 D_8094C878; static s16 D_8094C87A; static s16 D_8094C87C; static u8 D_8094C87E; -static BossTwEffect sTwEffects[150]; +static BossTwEffect sEffects[BOSS_TW_EFFECT_COUNT]; void BossTw_AddDotEffect(GlobalContext* globalCtx, Vec3f* initalPos, Vec3f* initalSpeed, Vec3f* accel, f32 scale, s16 args, s16 countLimit) { @@ -272,11 +274,11 @@ void BossTw_AddDmgCloud(GlobalContext* globalCtx, s16 type, Vec3f* initialPos, V } void BossTw_AddRingEffect(GlobalContext* globalCtx, Vec3f* initalPos, f32 scale, f32 arg3, s16 alpha, s16 args, - s16 arg6, s16 arg7) { + s16 arg6, s16 countLimit) { s16 i; BossTwEffect* eff; - for (i = 0, eff = globalCtx->specialEffects; i < arg7; i++, eff++) { + for (i = 0, eff = globalCtx->specialEffects; i < countLimit; i++, eff++) { if (eff->type == TWEFF_NONE) { eff->type = TWEFF_RING; eff->pos = *initalPos; @@ -298,7 +300,7 @@ void BossTw_AddPlayerFreezeEffect(GlobalContext* globalCtx, Actor* target) { BossTwEffect* eff; s16 i; - for (eff = globalCtx->specialEffects, i = 0; i < ARRAY_COUNT(sTwEffects); i++, eff++) { + for (eff = globalCtx->specialEffects, i = 0; i < BOSS_TW_EFFECT_COUNT; i++, eff++) { if (eff->type == TWEFF_NONE) { eff->type = TWEFF_PLYR_FRZ; eff->curSpeed = sZeroVector; @@ -323,7 +325,7 @@ void BossTw_AddFlameEffect(GlobalContext* globalCtx, Vec3f* initalPos, Vec3f* in s16 i; BossTwEffect* eff; - for (i = 0, eff = globalCtx->specialEffects; i < ARRAY_COUNT(sTwEffects); i++, eff++) { + for (i = 0, eff = globalCtx->specialEffects; i < BOSS_TW_EFFECT_COUNT; i++, eff++) { if (eff->type == TWEFF_NONE) { eff->type = TWEFF_FLAME; eff->pos = *initalPos; @@ -343,7 +345,7 @@ void BossTw_AddMergeFlameEffect(GlobalContext* globalCtx, Vec3f* initialPos, f32 s16 i; BossTwEffect* eff; - for (i = 0, eff = globalCtx->specialEffects; i < ARRAY_COUNT(sTwEffects); i++, eff++) { + for (i = 0, eff = globalCtx->specialEffects; i < BOSS_TW_EFFECT_COUNT; i++, eff++) { if (eff->type == TWEFF_NONE) { eff->type = TWEFF_MERGEFLAME; eff->pos = *initialPos; @@ -366,7 +368,7 @@ void BossTw_AddShieldBlastEffect(GlobalContext* globalCtx, Vec3f* initalPos, Vec s16 i; BossTwEffect* eff; - for (i = 0, eff = globalCtx->specialEffects; i < ARRAY_COUNT(sTwEffects); i++, eff++) { + for (i = 0, eff = globalCtx->specialEffects; i < BOSS_TW_EFFECT_COUNT; i++, eff++) { if (eff->type == TWEFF_NONE) { eff->type = TWEFF_SHLD_BLST; eff->pos = *initalPos; @@ -393,7 +395,7 @@ void BossTw_AddShieldDeflectEffect(GlobalContext* globalCtx, f32 arg1, s16 arg2) sShieldHitYaw = player->actor.shape.rot.y; for (i = 0; i < 8; i++) { - for (eff = globalCtx->specialEffects, j = 0; j < ARRAY_COUNT(sTwEffects); j++, eff++) { + for (eff = globalCtx->specialEffects, j = 0; j < BOSS_TW_EFFECT_COUNT; j++, eff++) { if (eff->type == TWEFF_NONE) { eff->type = TWEFF_SHLD_DEFL; eff->pos = sShieldHitPos; @@ -423,7 +425,7 @@ void BossTw_AddShieldHitEffect(GlobalContext* globalCtx, f32 arg1, s16 arg2) { sShieldHitYaw = player->actor.shape.rot.y; for (i = 0; i < 8; i++) { - for (eff = globalCtx->specialEffects, j = 0; j < ARRAY_COUNT(sTwEffects); j++, eff++) { + for (eff = globalCtx->specialEffects, j = 0; j < BOSS_TW_EFFECT_COUNT; j++, eff++) { if (eff->type == TWEFF_NONE) { eff->type = TWEFF_SHLD_HIT; eff->pos = sShieldHitPos; @@ -500,10 +502,10 @@ void BossTw_Init(Actor* thisx, GlobalContext* globalCtx2) { D_8094C858 = D_8094C854 = 0.0f; sFixedBlastType = Rand_ZeroFloat(1.99f); - globalCtx->specialEffects = sTwEffects; + globalCtx->specialEffects = sEffects; - for (i = 0; i < ARRAY_COUNT(sTwEffects); i++) { - sTwEffects[i].type = TWEFF_NONE; + for (i = 0; i < BOSS_TW_EFFECT_COUNT; i++) { + sEffects[i].type = TWEFF_NONE; } } @@ -734,7 +736,7 @@ void BossTw_SpawnGroundBlast(BossTw* this, GlobalContext* globalCtx, s16 blastTy Vec3f velocity; Vec3f accel; - for (i = 0; i < ARRAY_COUNT(sTwEffects); i++) { + for (i = 0; i < BOSS_TW_EFFECT_COUNT; i++) { velocity.x = Rand_CenteredFloat(20.0f); velocity.y = Rand_ZeroFloat(10.0f); velocity.z = Rand_CenteredFloat(20.0f); @@ -1097,7 +1099,7 @@ void BossTw_ShootBeam(BossTw* this, GlobalContext* globalCtx) { Vec3f velocity; Vec3f accel = { 0.0f, 0.0f, 0.0f }; - for (i = 0; i < ARRAY_COUNT(sTwEffects); i++) { + for (i = 0; i < 150; i++) { velocity.x = Rand_CenteredFloat(15.0f); velocity.y = Rand_CenteredFloat(15.0f); velocity.z = Rand_CenteredFloat(15.0f); @@ -1151,7 +1153,7 @@ void BossTw_ShootBeam(BossTw* this, GlobalContext* globalCtx) { Math_ApproachF(&this->targetPos.z, player->bodyPartsPos[PLAYER_BODYPART_R_HAND].z, 1.0f, 400.0f); if ((this->work[CS_TIMER_1] % 4) == 0) { BossTw_AddRingEffect(globalCtx, &player->bodyPartsPos[PLAYER_BODYPART_R_HAND], 0.5f, 3.0f, 0xFF, - this->actor.params, 1, 150); + this->actor.params, 1, BOSS_TW_EFFECT_COUNT); } } else { this->beamShootState = 0; @@ -1284,7 +1286,8 @@ void BossTw_ShootBeam(BossTw* this, GlobalContext* globalCtx) { } if (BossTw_BeamReflHitCheck(this, &this->actor.world.pos) && (this->work[CS_TIMER_1] % 4) == 0) { - BossTw_AddRingEffect(globalCtx, &this->unk_530, 0.5f, 3.0f, 255, this->actor.params, 1, 150); + BossTw_AddRingEffect(globalCtx, &this->unk_530, 0.5f, 3.0f, 255, this->actor.params, 1, + BOSS_TW_EFFECT_COUNT); } if (BossTw_BeamReflHitCheck(this, &otherTw->actor.world.pos) && otherTw->actionFunc != BossTw_HitByBeam) { @@ -4581,7 +4584,7 @@ void BossTw_UpdateEffects(GlobalContext* globalCtx) { f32 phi_f0; Actor* unk44; - for (i = 0; i < ARRAY_COUNT(sTwEffects); i++) { + for (i = 0; i < BOSS_TW_EFFECT_COUNT; i++) { if (eff->type != 0) { eff->pos.x += eff->curSpeed.x; eff->pos.y += eff->curSpeed.y; @@ -4897,7 +4900,7 @@ f32 BossTw_RandZeroOne(void) { } void BossTw_DrawEffects(GlobalContext* globalCtx) { - u8 sp18F = 0; + u8 materialFlag = 0; s16 i; s16 j; s32 pad; @@ -4913,11 +4916,11 @@ void BossTw_DrawEffects(GlobalContext* globalCtx) { func_80093D84(globalCtx->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(sTwEffects); i++) { + for (i = 0; i < BOSS_TW_EFFECT_COUNT; i++) { if (currentEffect->type == 1) { - if (sp18F == 0) { + if (materialFlag == 0) { gSPDisplayList(POLY_XLU_DISP++, object_tw_DL_01A528); - sp18F++; + materialFlag++; } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, currentEffect->color.r, currentEffect->color.g, @@ -4933,14 +4936,14 @@ void BossTw_DrawEffects(GlobalContext* globalCtx) { currentEffect++; } - sp18F = 0; + materialFlag = 0; currentEffect = effectHead; - for (i = 0; i < ARRAY_COUNT(sTwEffects); i++) { + for (i = 0; i < BOSS_TW_EFFECT_COUNT; i++) { if (currentEffect->type == 3) { - if (sp18F == 0) { + if (materialFlag == 0) { gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01A998)); - sp18F++; + materialFlag++; } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, currentEffect->alpha); @@ -4957,15 +4960,15 @@ void BossTw_DrawEffects(GlobalContext* globalCtx) { currentEffect++; } - sp18F = 0; + materialFlag = 0; currentEffect = effectHead; - for (i = 0; i < ARRAY_COUNT(sTwEffects); i++) { + for (i = 0; i < BOSS_TW_EFFECT_COUNT; i++) { if (currentEffect->type == 2) { - if (sp18F == 0) { + if (materialFlag == 0) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 255, 215, 255, 128); - sp18F++; + materialFlag++; } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 200, 20, 0, currentEffect->alpha); @@ -4983,13 +4986,13 @@ void BossTw_DrawEffects(GlobalContext* globalCtx) { currentEffect++; } - sp18F = 0; + materialFlag = 0; currentEffect = effectHead; - for (i = 0; i < ARRAY_COUNT(sTwEffects); i++) { + for (i = 0; i < BOSS_TW_EFFECT_COUNT; i++) { if (currentEffect->type == 4) { - if (sp18F == 0) { - sp18F++; + if (materialFlag == 0) { + materialFlag++; } gSPSegment(POLY_XLU_DISP++, 0xD, @@ -5028,20 +5031,20 @@ void BossTw_DrawEffects(GlobalContext* globalCtx) { currentEffect++; } - sp18F = 0; + materialFlag = 0; currentEffect = effectHead; - for (i = 0; i < ARRAY_COUNT(sTwEffects); i++) { + for (i = 0; i < BOSS_TW_EFFECT_COUNT; i++) { Actor* actor; Vec3f off; if (currentEffect->type == TWEFF_PLYR_FRZ) { - if (sp18F == 0) { + if (materialFlag == 0) { gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01AA50)); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, 255); gSPSegment(POLY_XLU_DISP++, 8, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); - sp18F++; + materialFlag++; BossTw_InitRand(1, 0x71AC, 0x263A); } @@ -5074,10 +5077,10 @@ void BossTw_DrawEffects(GlobalContext* globalCtx) { currentEffect++; } - sp18F = 0; + materialFlag = 0; currentEffect = effectHead; - for (i = 0; i < ARRAY_COUNT(sTwEffects); i++) { + for (i = 0; i < BOSS_TW_EFFECT_COUNT; i++) { if (currentEffect->type >= 6) { if (currentEffect->work[EFF_ARGS] == 0) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, currentEffect->alpha); diff --git a/src/overlays/actors/ovl_Boss_Va/z_boss_va.c b/src/overlays/actors/ovl_Boss_Va/z_boss_va.c index af5d0526ad..357f9a0e48 100644 --- a/src/overlays/actors/ovl_Boss_Va/z_boss_va.c +++ b/src/overlays/actors/ovl_Boss_Va/z_boss_va.c @@ -23,6 +23,8 @@ #define PHASE_4 15 #define PHASE_DEATH 18 +#define BOSS_VA_EFFECT_COUNT 400 + typedef struct BossVaEffect { /* 0x00 */ Vec3f pos; /* 0x0C */ Vec3f velocity; @@ -376,7 +378,7 @@ static u8 sKillBari = 0; static u8 sBodyBari[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; static s16 sCsCamera = 0; -static BossVaEffect sVaEffects[400]; +static BossVaEffect sEffects[BOSS_VA_EFFECT_COUNT]; static u8 sBodyState; static u8 sFightPhase; static s8 sCsState; @@ -439,7 +441,7 @@ void BossVa_BloodDroplets(GlobalContext* globalCtx, Vec3f* pos, s16 phase, s16 y spawnPos.x = Rand_CenteredFloat(10.0f) + pos->x; spawnPos.y = pos->y - (Rand_ZeroOne() * 15.0f); spawnPos.z = Rand_CenteredFloat(10.0f) + pos->z; - BossVa_SpawnBloodDroplets(globalCtx, sVaEffects, &spawnPos, 65, phase, yaw); + BossVa_SpawnBloodDroplets(globalCtx, sEffects, &spawnPos, 65, phase, yaw); } } @@ -451,7 +453,7 @@ void BossVa_BloodSplatter(GlobalContext* globalCtx, BossVaEffect* src, s16 yaw, pos.x = Rand_CenteredFloat(10.0f) + src->pos.x; pos.y = src->pos.y - (Rand_ZeroOne() * 15.0f); pos.z = Rand_CenteredFloat(10.0f) + src->pos.z; - BossVa_SpawnBloodSplatter(globalCtx, sVaEffects, &pos, (s16)Rand_CenteredFloat(0x6590) + yaw, scale); + BossVa_SpawnBloodSplatter(globalCtx, sEffects, &pos, (s16)Rand_CenteredFloat(0x6590) + yaw, scale); } } @@ -463,7 +465,7 @@ void BossVa_Gore(GlobalContext* globalCtx, BossVaEffect* src, s16 yaw, s16 scale pos.x = Rand_CenteredFloat(10.0f) + src->pos.x; pos.y = Rand_CenteredFloat(10.0f) + src->pos.y; pos.z = Rand_CenteredFloat(10.0f) + src->pos.z; - BossVa_SpawnGore(globalCtx, sVaEffects, &pos, (s16)Rand_CenteredFloat(0x6590) + yaw, scale); + BossVa_SpawnGore(globalCtx, sEffects, &pos, (s16)Rand_CenteredFloat(0x6590) + yaw, scale); } } @@ -482,7 +484,7 @@ void BossVa_Spark(GlobalContext* globalCtx, BossVa* this, s32 count, s16 scale, offset.x = Rand_CenteredFloat(xzSpread) + this->effectPos[index].x - this->actor.world.pos.x; offset.y = Rand_CenteredFloat(ySpread) + this->effectPos[index].y - this->actor.world.pos.y; offset.z = Rand_CenteredFloat(xzSpread) + this->effectPos[index].z - this->actor.world.pos.z; - BossVa_SpawnSpark(globalCtx, sVaEffects, this, &offset, scale, mode); + BossVa_SpawnSpark(globalCtx, sEffects, this, &offset, scale, mode); } } @@ -502,7 +504,7 @@ void BossVa_Tumor(GlobalContext* globalCtx, BossVa* this, s32 count, s16 scale, offset.x = Rand_CenteredFloat(xzSpread) + this->effectPos[index].x - this->actor.world.pos.x; offset.y = Rand_CenteredFloat(ySpread) + this->effectPos[index].y - this->actor.world.pos.y; offset.z = Rand_CenteredFloat(xzSpread) + this->effectPos[index].z - this->actor.world.pos.z; - BossVa_SpawnTumor(globalCtx, sVaEffects, this, &offset, scale, mode); + BossVa_SpawnTumor(globalCtx, sEffects, this, &offset, scale, mode); } } @@ -687,7 +689,7 @@ void BossVa_Init(Actor* thisx, GlobalContext* globalCtx2) { sInitRot[i].y + this->actor.world.rot.y, sInitRot[i].z + this->actor.world.rot.z, i); } - Lib_MemSet((u8*)sVaEffects, ARRAY_COUNT(sVaEffects) * sizeof(BossVaEffect), 0); + Lib_MemSet((u8*)sEffects, BOSS_VA_EFFECT_COUNT * sizeof(BossVaEffect), 0); if (sCsState < BOSSVA_BATTLE) { BossVa_SetupIntro(this); } else { @@ -1171,7 +1173,7 @@ void BossVa_BodyPhase2(BossVa* this, GlobalContext* globalCtx) { sp48.y += 310.0f + (this->actor.shape.yOffset * this->actor.scale.y); sp48.x += -10.0f; sp48.z += 220.0f; - BossVa_SpawnSparkBall(globalCtx, sVaEffects, this, &sp48, 4, 0); + BossVa_SpawnSparkBall(globalCtx, sEffects, this, &sp48, 4, 0); } if (Rand_ZeroOne() < 0.1f) { @@ -2096,7 +2098,7 @@ void BossVa_ZapperAttack(BossVa* this, GlobalContext* globalCtx) { if (this->timer2 == 20) { Vec3f sp44 = this->zapHeadPos; - BossVa_SpawnZapperCharge(globalCtx, sVaEffects, this, &sp44, &this->headRot, 100, 0); + BossVa_SpawnZapperCharge(globalCtx, sEffects, this, &sp44, &this->headRot, 100, 0); } } @@ -2355,7 +2357,7 @@ void BossVa_ZapperEnraged(BossVa* this, GlobalContext* globalCtx) { if (this->timer2 == 4) { Vec3f sp48 = this->zapHeadPos; - BossVa_SpawnZapperCharge(globalCtx, sVaEffects, this, &sp48, &this->headRot, 100, 0); + BossVa_SpawnZapperCharge(globalCtx, sEffects, this, &sp48, &this->headRot, 100, 0); } } @@ -3280,7 +3282,7 @@ void BossVa_Draw(Actor* thisx, GlobalContext* globalCtx) { } if (*paramsPtr == BOSSVA_BODY) { - BossVa_DrawEffects(sVaEffects, globalCtx); + BossVa_DrawEffects(sEffects, globalCtx); } else if (*paramsPtr == BOSSVA_DOOR) { BossVa_DrawDoor(globalCtx, sDoorState); } @@ -3291,7 +3293,7 @@ void BossVa_Draw(Actor* thisx, GlobalContext* globalCtx) { static s32 sUnkValue = 0x009B0000; // Unreferenced? Possibly a color void BossVa_UpdateEffects(GlobalContext* globalCtx) { - BossVaEffect* effect = sVaEffects; + BossVaEffect* effect = sEffects; Player* player = GET_PLAYER(globalCtx); s16 spB6; s16 i; @@ -3309,7 +3311,7 @@ void BossVa_UpdateEffects(GlobalContext* globalCtx) { f32 pad78; f32 pad74; - for (i = 0; i < ARRAY_COUNT(sVaEffects); i++, effect++) { + for (i = 0; i < BOSS_VA_EFFECT_COUNT; i++, effect++) { if (effect->type != VA_NONE) { effect->timer--; @@ -3507,19 +3509,19 @@ void BossVa_DrawEffects(BossVaEffect* effect, GlobalContext* globalCtx) { }; s16 i; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - u8 flag = 0; + u8 materialFlag = 0; BossVaEffect* effectHead = effect; Camera* camera = Gameplay_GetCamera(globalCtx, sCsCamera); OPEN_DISPS(gfxCtx, "../z_boss_va.c", 4953); - for (i = 0; i < ARRAY_COUNT(sVaEffects); i++, effect++) { + for (i = 0; i < BOSS_VA_EFFECT_COUNT; i++, effect++) { if (effect->type == VA_LARGE_SPARK) { - if (!flag) { + if (materialFlag == 0) { func_80093D84(globalCtx->state.gfxCtx); gDPSetEnvColor(POLY_XLU_DISP++, 130, 130, 30, 0); gSPDisplayList(POLY_XLU_DISP++, gBarinadeDL_0156A0); - flag++; + materialFlag++; } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 230, 230, 230, effect->primColor[3]); @@ -3534,12 +3536,12 @@ void BossVa_DrawEffects(BossVaEffect* effect, GlobalContext* globalCtx) { } effect = effectHead; - for (i = 0, flag = 0; i < ARRAY_COUNT(sVaEffects); i++, effect++) { + for (i = 0, materialFlag = 0; i < BOSS_VA_EFFECT_COUNT; i++, effect++) { if (effect->type == VA_SPARK_BALL) { - if (!flag) { + if (materialFlag == 0) { func_80093D84(globalCtx->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, gBarinadeDL_011738); - flag++; + materialFlag++; } Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&globalCtx->billboardMtxF); @@ -3560,13 +3562,13 @@ void BossVa_DrawEffects(BossVaEffect* effect, GlobalContext* globalCtx) { } effect = effectHead; - for (i = 0, flag = 0; i < ARRAY_COUNT(sVaEffects); i++, effect++) { + for (i = 0, materialFlag = 0; i < BOSS_VA_EFFECT_COUNT; i++, effect++) { if (effect->type == VA_BLOOD) { - if (!flag) { + if (materialFlag == 0) { func_80093D84(globalCtx->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, gBarinadeDL_009430); gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(gEffBubble1Tex)); - flag++; + materialFlag++; } gDPPipeSync(POLY_XLU_DISP++); @@ -3590,15 +3592,15 @@ void BossVa_DrawEffects(BossVaEffect* effect, GlobalContext* globalCtx) { } effect = effectHead; - for (i = 0, flag = 0; i < ARRAY_COUNT(sVaEffects); i++, effect++) { + for (i = 0, materialFlag = 0; i < BOSS_VA_EFFECT_COUNT; i++, effect++) { if (effect->type == VA_TUMOR) { BossVa* parent = effect->parent; - if (!flag) { + if (materialFlag == 0) { func_80093D18(globalCtx->state.gfxCtx); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, effect->envColor[3]); gSPDisplayList(POLY_OPA_DISP++, gBarinadeDL_0128B8); - flag++; + materialFlag++; } if ((effect->mode != TUMOR_BODY) || ((Math_Vec3f_DistXZ(&camera->eye, &effect->pos) - @@ -3614,12 +3616,12 @@ void BossVa_DrawEffects(BossVaEffect* effect, GlobalContext* globalCtx) { } effect = effectHead; - for (i = 0, flag = 0; i < ARRAY_COUNT(sVaEffects); i++, effect++) { + for (i = 0, materialFlag = 0; i < BOSS_VA_EFFECT_COUNT; i++, effect++) { if (effect->type == VA_GORE) { - if (!flag) { + if (materialFlag == 0) { func_80093D18(globalCtx->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, gBarinadeDL_012BA0); - flag++; + materialFlag++; } gDPPipeSync(POLY_OPA_DISP++); @@ -3645,12 +3647,12 @@ void BossVa_DrawEffects(BossVaEffect* effect, GlobalContext* globalCtx) { } effect = effectHead; - for (i = 0, flag = 0; i < ARRAY_COUNT(sVaEffects); i++, effect++) { + for (i = 0, materialFlag = 0; i < BOSS_VA_EFFECT_COUNT; i++, effect++) { if (effect->type == VA_ZAP_CHARGE) { - if (!flag) { + if (materialFlag == 0) { func_80093D84(globalCtx->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, gBarinadeDL_0135B0); - flag++; + materialFlag++; } gDPPipeSync(POLY_XLU_DISP++); @@ -3668,13 +3670,13 @@ void BossVa_DrawEffects(BossVaEffect* effect, GlobalContext* globalCtx) { } effect = effectHead; - for (i = 0, flag = 0; i < ARRAY_COUNT(sVaEffects); i++, effect++) { + for (i = 0, materialFlag = 0; i < BOSS_VA_EFFECT_COUNT; i++, effect++) { if (effect->type == VA_BLAST_SPARK) { - if (!flag) { + if (materialFlag == 0) { func_80093C14(globalCtx->state.gfxCtx); gDPSetEnvColor(POLY_XLU_DISP++, 130, 130, 30, 0); gSPDisplayList(POLY_XLU_DISP++, gBarinadeDL_0156A0); - flag++; + materialFlag++; } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 230, 230, 230, effect->primColor[3]); @@ -3690,13 +3692,13 @@ void BossVa_DrawEffects(BossVaEffect* effect, GlobalContext* globalCtx) { } effect = effectHead; - for (i = 0, flag = 0; i < ARRAY_COUNT(sVaEffects); i++, effect++) { + for (i = 0, materialFlag = 0; i < BOSS_VA_EFFECT_COUNT; i++, effect++) { if (effect->type == VA_SMALL_SPARK) { - if (!flag) { + if (materialFlag == 0) { func_80093D84(globalCtx->state.gfxCtx); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 100, 0); gSPDisplayList(POLY_XLU_DISP++, gBarinadeDL_008F08); - flag++; + materialFlag++; } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, effect->primColor[3]); @@ -3722,7 +3724,7 @@ void BossVa_SpawnSpark(GlobalContext* globalCtx, BossVaEffect* effect, BossVa* t Vec3f tempVec; s16 i; - for (i = 0; i < ARRAY_COUNT(sVaEffects); i++, effect++) { + for (i = 0; i < BOSS_VA_EFFECT_COUNT; i++, effect++) { if (effect->type == VA_NONE) { effect->type = VA_LARGE_SPARK; effect->parent = this; @@ -3779,7 +3781,7 @@ void BossVa_SpawnSparkBall(GlobalContext* globalCtx, BossVaEffect* effect, BossV Vec3f pos = { 0.0f, -1000.0f, 0.0f }; s16 i; - for (i = 0; i < ARRAY_COUNT(sVaEffects); i++, effect++) { + for (i = 0; i < BOSS_VA_EFFECT_COUNT; i++, effect++) { if (effect->type == VA_NONE) { effect->type = VA_SPARK_BALL; effect->parent = this; @@ -3812,7 +3814,7 @@ void BossVa_SpawnBloodDroplets(GlobalContext* globalCtx, BossVaEffect* effect, V Vec3f velocity = { 0.0f, 0.0f, 0.0f }; f32 xzVel; - for (i = 0; i < ARRAY_COUNT(sVaEffects); i++, effect++) { + for (i = 0; i < BOSS_VA_EFFECT_COUNT; i++, effect++) { if (effect->type == VA_NONE) { effect->type = VA_BLOOD; effect->pos = *pos; @@ -3842,7 +3844,7 @@ void BossVa_SpawnBloodSplatter(GlobalContext* globalCtx, BossVaEffect* effect, V Vec3f accel = { 0.0f, 0.0f, 0.0f }; Vec3f velocity; - for (i = 0; i < ARRAY_COUNT(sVaEffects); i++, effect++) { + for (i = 0; i < BOSS_VA_EFFECT_COUNT; i++, effect++) { if (effect->type == VA_NONE) { effect->type = VA_BLOOD; effect->pos = *pos; @@ -3876,7 +3878,7 @@ void BossVa_SpawnTumor(GlobalContext* globalCtx, BossVaEffect* effect, BossVa* t Vec3f pos = { 0.0f, -1000.0f, 0.0f }; s16 i; - for (i = 0; i < ARRAY_COUNT(sVaEffects); i++, effect++) { + for (i = 0; i < BOSS_VA_EFFECT_COUNT; i++, effect++) { if (effect->type == VA_NONE) { effect->type = VA_TUMOR; effect->parent = this; @@ -3910,7 +3912,7 @@ void BossVa_SpawnGore(GlobalContext* globalCtx, BossVaEffect* effect, Vec3f* pos Vec3f accel = { 0.0f, 0.0f, 0.0f }; Vec3f velocity; - for (i = 0; i < ARRAY_COUNT(sVaEffects); i++, effect++) { + for (i = 0; i < BOSS_VA_EFFECT_COUNT; i++, effect++) { if (effect->type == VA_NONE) { effect->type = VA_GORE; effect->pos = *pos; @@ -3952,7 +3954,7 @@ void BossVa_SpawnZapperCharge(GlobalContext* globalCtx, BossVaEffect* effect, Bo Vec3f unused = { 0.0f, -1000.0f, 0.0f }; s16 i; - for (i = 0; i < ARRAY_COUNT(sVaEffects); i++, effect++) { + for (i = 0; i < BOSS_VA_EFFECT_COUNT; i++, effect++) { if (effect->type == VA_NONE) { effect->type = VA_ZAP_CHARGE; effect->parent = this; diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c index 0d63d40257..78f61c1df0 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c @@ -526,9 +526,9 @@ void DemoKankyo_DrawRain(Actor* thisx, GlobalContext* globalCtx) { for (i = 0; i < 30; i++) { s32 pad[2]; - dx = globalCtx->view.lookAt.x - globalCtx->view.eye.x; - dy = globalCtx->view.lookAt.y - globalCtx->view.eye.y; - dz = globalCtx->view.lookAt.z - globalCtx->view.eye.z; + dx = globalCtx->view.at.x - globalCtx->view.eye.x; + dy = globalCtx->view.at.y - globalCtx->view.eye.y; + dz = globalCtx->view.at.z - globalCtx->view.eye.z; norm = sqrtf(SQ(dx) + SQ(dy) + SQ(dz)); if (globalCtx->sceneNum != SCENE_TOKINOMA) { diff --git a/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.c b/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.c index f4f27e1059..4015f2e2ad 100644 --- a/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.c +++ b/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.c @@ -9,10 +9,10 @@ void EfcErupc_Update(Actor* thisx, GlobalContext* globalCtx); void EfcErupc_Draw(Actor* thisx, GlobalContext* globalCtx); void EfcErupc_UpdateAction(EfcErupc* this, GlobalContext* globalCtx); -void EfcErupc_DrawParticles(EfcErupcParticles* particles, GlobalContext* globalCtx); -void EfcErupc_UpdateParticles(EfcErupc* this, GlobalContext* globalCtx); -void EfcErupc_AddParticle(EfcErupcParticles* particles, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 scaleFactor); -void EfcErupc_InitParticles(EfcErupcParticles* particles); +void EfcErupc_DrawEffects(EfcErupcEffect* effect, GlobalContext* globalCtx); +void EfcErupc_UpdateEffects(EfcErupc* this, GlobalContext* globalCtx); +void EfcErupc_SpawnEffect(EfcErupcEffect* effect, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 scaleFactor); +void EfcErupc_InitEffects(EfcErupcEffect* effect); const ActorInit Efc_Erupc_InitVars = { ACTOR_EFC_ERUPC, @@ -35,7 +35,7 @@ void EfcErupc_Init(Actor* thisx, GlobalContext* globalCtx) { EfcErupc_SetupAction(this, EfcErupc_UpdateAction); Actor_SetScale(&this->actor, 1.0f); - EfcErupc_InitParticles(this->particles); + EfcErupc_InitEffects(this->effects); this->unk_14C = this->unk_14E = this->unk_150 = 0; this->unk_152 = 5; this->unk_154 = -100; @@ -99,7 +99,7 @@ void EfcErupc_UpdateAction(EfcErupc* this, GlobalContext* globalCtx) { vel.y = Rand_ZeroFloat(100.0f); vel.z = Rand_CenteredFloat(100.0f); accel.y = this->unk_154 * 0.1f; - EfcErupc_AddParticle(this->particles, &pos, &vel, &accel, 80.0f); + EfcErupc_SpawnEffect(this->effects, &pos, &vel, &accel, 80.0f); } } @@ -107,7 +107,7 @@ void EfcErupc_Update(Actor* thisx, GlobalContext* globalCtx) { EfcErupc* this = (EfcErupc*)thisx; this->actionFunc(this, globalCtx); - EfcErupc_UpdateParticles(this, globalCtx); + EfcErupc_UpdateEffects(this, globalCtx); } void EfcErupc_Draw(Actor* thisx, GlobalContext* globalCtx) { @@ -156,26 +156,25 @@ void EfcErupc_Draw(Actor* thisx, GlobalContext* globalCtx) { } } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_efc_erupc.c", 356); - EfcErupc_DrawParticles(this->particles, globalCtx); + EfcErupc_DrawEffects(this->effects, globalCtx); } -void EfcErupc_DrawParticles(EfcErupcParticles* particles, GlobalContext* globalCtx) { +void EfcErupc_DrawEffects(EfcErupcEffect* effect, GlobalContext* globalCtx) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; s16 i; s32 pad; OPEN_DISPS(gfxCtx, "../z_efc_erupc.c", 368); - for (i = 0; i < EFC_ERUPC_NUM_PARTICLES; i++, particles++) { - if (particles->isActive) { + for (i = 0; i < EFC_ERUPC_EFFECT_COUNT; i++, effect++) { + if (effect->isActive) { func_80093D84(globalCtx->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, object_efc_erupc_DL_002760); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, particles->color.r, particles->color.g, particles->color.b, - particles->alpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, effect->color.r, effect->color.g, effect->color.b, effect->alpha); gDPSetEnvColor(POLY_XLU_DISP++, 150, 0, 0, 0); gDPPipeSync(POLY_XLU_DISP++); - Matrix_Translate(particles->pos.x, particles->pos.y, particles->pos.z, MTXMODE_NEW); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&globalCtx->billboardMtxF); - Matrix_Scale(particles->scale, particles->scale, 1.0f, MTXMODE_APPLY); + Matrix_Scale(effect->scale, effect->scale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_efc_erupc.c", 393), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_efc_erupc_DL_0027D8); @@ -191,19 +190,19 @@ static Color_RGB8 D_8099D770[] = { { 255, 0, 0 }, }; -void EfcErupc_UpdateParticles(EfcErupc* this, GlobalContext* globalCtx) { +void EfcErupc_UpdateEffects(EfcErupc* this, GlobalContext* globalCtx) { s16 i; s16 index; - Color_RGB8 particleColors[] = { + Color_RGB8 effectColors[] = { { 255, 128, 0 }, { 255, 0, 0 }, { 0, 0, 0 }, { 100, 0, 0 }, }; Color_RGB8* color; - EfcErupcParticles* cur = this->particles; + EfcErupcEffect* cur = this->effects; - for (i = 0; i < EFC_ERUPC_NUM_PARTICLES; i++, cur++) { + for (i = 0; i < EFC_ERUPC_EFFECT_COUNT; i++, cur++) { if (cur->isActive) { cur->pos.x += cur->vel.x; cur->pos.y += cur->vel.y; @@ -213,7 +212,7 @@ void EfcErupc_UpdateParticles(EfcErupc* this, GlobalContext* globalCtx) { cur->vel.z += cur->accel.z; cur->animTimer += 1; index = cur->animTimer % 4; - color = &particleColors[index]; + color = &effectColors[index]; cur->color.r = color->r; cur->color.g = color->g; cur->color.b = color->b; @@ -226,27 +225,27 @@ void EfcErupc_UpdateParticles(EfcErupc* this, GlobalContext* globalCtx) { } } -void EfcErupc_AddParticle(EfcErupcParticles* particles, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 scaleFactor) { +void EfcErupc_SpawnEffect(EfcErupcEffect* effect, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 scaleFactor) { s16 i; - for (i = 0; i < EFC_ERUPC_NUM_PARTICLES; i++, particles++) { - if (!particles->isActive) { - particles->isActive = true; - particles->pos = *pos; - particles->vel = *vel; - particles->accel = *accel; - particles->scale = scaleFactor / 1000.0f; - particles->alpha = 255; - particles->animTimer = (s16)Rand_ZeroFloat(10.0f); + for (i = 0; i < EFC_ERUPC_EFFECT_COUNT; i++, effect++) { + if (!effect->isActive) { + effect->isActive = true; + effect->pos = *pos; + effect->vel = *vel; + effect->accel = *accel; + effect->scale = scaleFactor / 1000.0f; + effect->alpha = 255; + effect->animTimer = (s16)Rand_ZeroFloat(10.0f); return; } } } -void EfcErupc_InitParticles(EfcErupcParticles* particles) { +void EfcErupc_InitEffects(EfcErupcEffect* effect) { s16 i; - for (i = 0; i < EFC_ERUPC_NUM_PARTICLES; i++, particles++) { - particles->isActive = false; + for (i = 0; i < EFC_ERUPC_EFFECT_COUNT; i++, effect++) { + effect->isActive = false; } } diff --git a/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.h b/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.h index 3cc425daba..b96914931e 100644 --- a/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.h +++ b/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.h @@ -8,6 +8,8 @@ struct EfcErupc; typedef void (*EfcErupcActionFunc)(struct EfcErupc*, GlobalContext*); +#define EFC_ERUPC_EFFECT_COUNT 100 + typedef struct { /* 0x00 */ Vec3f pos; /* 0x0C */ Vec3f vel; @@ -19,9 +21,7 @@ typedef struct { /* 0x30 */ char unk_2C[4]; /* 0x34 */ f32 scale; /* 0x38 */ char unk_34[8]; -} EfcErupcParticles; // size 0x3C - -#define EFC_ERUPC_NUM_PARTICLES 100 +} EfcErupcEffect; // size 0x3C typedef struct EfcErupc { /* 0x0000 */ Actor actor; @@ -30,7 +30,7 @@ typedef struct EfcErupc { /* 0x0150 */ s16 unk_150; /* 0x0152 */ s16 unk_152; /* 0x0154 */ s16 unk_154; - /* 0x0158 */ EfcErupcParticles particles[EFC_ERUPC_NUM_PARTICLES]; + /* 0x0158 */ EfcErupcEffect effects[EFC_ERUPC_EFFECT_COUNT]; /* 0x18C8 */ EfcErupcActionFunc actionFunc; } EfcErupc; // size = 0x18CC diff --git a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c index 6ef2ecd102..872f7083fc 100644 --- a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c +++ b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c @@ -187,13 +187,13 @@ void func_809B5670(EnAttackNiw* this, GlobalContext* globalCtx) { this->actor.speedXZ = 10.0f; - tmpf1 = (this->unk_298.x + globalCtx->view.lookAt.x) - globalCtx->view.eye.x; - tmpf2 = (this->unk_298.y + globalCtx->view.lookAt.y) - globalCtx->view.eye.y; - tmpf3 = (this->unk_298.z + globalCtx->view.lookAt.z) - globalCtx->view.eye.z; + tmpf1 = (this->unk_298.x + globalCtx->view.at.x) - globalCtx->view.eye.x; + tmpf2 = (this->unk_298.y + globalCtx->view.at.y) - globalCtx->view.eye.y; + tmpf3 = (this->unk_298.z + globalCtx->view.at.z) - globalCtx->view.eye.z; - sp34.x = globalCtx->view.lookAt.x + tmpf1; - sp34.y = globalCtx->view.lookAt.y + tmpf2; - sp34.z = globalCtx->view.lookAt.z + tmpf3; + sp34.x = globalCtx->view.at.x + tmpf1; + sp34.y = globalCtx->view.at.y + tmpf2; + sp34.z = globalCtx->view.at.z + tmpf3; this->unk_2D4 = Math_Vec3f_Yaw(&this->actor.world.pos, &sp34); this->unk_2D0 = Math_Vec3f_Pitch(&this->actor.world.pos, &sp34) * -1.0f; diff --git a/src/overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.c b/src/overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.c index c3f191b02f..a176d802ae 100644 --- a/src/overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.c +++ b/src/overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.c @@ -77,9 +77,9 @@ void EnBomBowlPit_DetectHit(EnBomBowlPit* this, GlobalContext* globalCtx) { this->unk_1C8.x = this->unk_1C8.y = this->unk_1C8.z = 0.1f; this->unk_1A4.x = this->unk_1A4.y = this->unk_1A4.z = 0.1f; - this->unk_180.x = this->unk_168.x = globalCtx->view.lookAt.x; - this->unk_180.y = this->unk_168.y = globalCtx->view.lookAt.y; - this->unk_180.z = this->unk_168.z = globalCtx->view.lookAt.z; + this->unk_180.x = this->unk_168.x = globalCtx->view.at.x; + this->unk_180.y = this->unk_168.y = globalCtx->view.at.y; + this->unk_180.z = this->unk_168.z = globalCtx->view.at.z; this->unk_18C.x = this->unk_174.x = globalCtx->view.eye.x; this->unk_18C.y = this->unk_174.y = globalCtx->view.eye.y; diff --git a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c index 45e41524ab..9720b8cc7d 100644 --- a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c +++ b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c @@ -78,7 +78,7 @@ static ColliderCylinderInit sLaserCylinderInit = { static UNK_TYPE4 D_809D5C98 = 0; // unused static UNK_TYPE4 D_809D5C9C = 0; // unused -static EnClearTagEffect sClearTagEffects[CLEAR_TAG_EFFECT_MAX_COUNT]; +static EnClearTagEffect sEffects[CLEAR_TAG_EFFECT_COUNT]; #include "overlays/ovl_En_Clear_Tag/ovl_En_Clear_Tag.c" @@ -92,7 +92,7 @@ void EnClearTag_CreateDebrisEffect(GlobalContext* globalCtx, Vec3f* position, Ve EnClearTagEffect* effect = (EnClearTagEffect*)globalCtx->specialEffects; // Look for an available effect to allocate a Debris effect to. - for (i = 0; i < CLEAR_TAG_EFFECT_MAX_COUNT; i++, effect++) { + for (i = 0; i < CLEAR_TAG_EFFECT_COUNT; i++, effect++) { if (effect->type == CLEAR_TAG_EFFECT_AVAILABLE) { effect->type = CLEAR_TAG_EFFECT_DEBRIS; @@ -126,7 +126,7 @@ void EnClearTag_CreateFireEffect(GlobalContext* globalCtx, Vec3f* pos, f32 scale EnClearTagEffect* effect = (EnClearTagEffect*)globalCtx->specialEffects; // Look for an available effect to allocate a fire effect to. - for (i = 0; i < CLEAR_TAG_EFFECT_MAX_COUNT; i++, effect++) { + for (i = 0; i < CLEAR_TAG_EFFECT_COUNT; i++, effect++) { if (effect->type == CLEAR_TAG_EFFECT_AVAILABLE) { effect->random = (s16)Rand_ZeroFloat(100.0f); effect->type = CLEAR_TAG_EFFECT_FIRE; @@ -154,7 +154,7 @@ void EnClearTag_CreateSmokeEffect(GlobalContext* globalCtx, Vec3f* position, f32 EnClearTagEffect* effect = (EnClearTagEffect*)globalCtx->specialEffects; // Look for an available effect to allocate a smoke effect to. - for (i = 0; i < CLEAR_TAG_EFFECT_MAX_COUNT; i++, effect++) { + for (i = 0; i < CLEAR_TAG_EFFECT_COUNT; i++, effect++) { if (effect->type == CLEAR_TAG_EFFECT_AVAILABLE) { effect->random = (s16)Rand_ZeroFloat(100.0f); effect->type = CLEAR_TAG_EFFECT_SMOKE; @@ -190,7 +190,7 @@ void EnClearTag_CreateFlashEffect(GlobalContext* globalCtx, Vec3f* position, f32 EnClearTagEffect* effect = (EnClearTagEffect*)globalCtx->specialEffects; // Look for an available effect to allocate a flash effect to. - for (i = 0; i < CLEAR_TAG_EFFECT_MAX_COUNT; i++, effect++) { + for (i = 0; i < CLEAR_TAG_EFFECT_COUNT; i++, effect++) { if (effect->type == CLEAR_TAG_EFFECT_AVAILABLE) { effect->type = CLEAR_TAG_EFFECT_FLASH; @@ -271,9 +271,9 @@ void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx) { // Initialize all effects to available if effects have not been initialized. if (!sIsEffectsInitialized) { sIsEffectsInitialized = true; - globalCtx->specialEffects = &sClearTagEffects[0]; - for (i = 0; i < CLEAR_TAG_EFFECT_MAX_COUNT; i++) { - sClearTagEffects[i].type = CLEAR_TAG_EFFECT_AVAILABLE; + globalCtx->specialEffects = sEffects; + for (i = 0; i < CLEAR_TAG_EFFECT_COUNT; i++) { + sEffects[i].type = CLEAR_TAG_EFFECT_AVAILABLE; } this->drawMode = CLEAR_TAG_DRAW_MODE_ALL; } @@ -780,7 +780,7 @@ void EnClearTag_UpdateEffects(GlobalContext* globalCtx) { f32 originalYPosition; Vec3f sphereCenter; - for (i = 0; i < CLEAR_TAG_EFFECT_MAX_COUNT; i++, effect++) { + for (i = 0; i < CLEAR_TAG_EFFECT_COUNT; i++, effect++) { if (effect->type != CLEAR_TAG_EFFECT_AVAILABLE) { effect->random++; @@ -891,7 +891,7 @@ void EnClearTag_UpdateEffects(GlobalContext* globalCtx) { void EnClearTag_DrawEffects(GlobalContext* globalCtx) { s16 i; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - u8 isMaterialApplied = false; + u8 materialFlag = 0; EnClearTagEffect* effect = (EnClearTagEffect*)globalCtx->specialEffects; EnClearTagEffect* firstEffect = effect; @@ -900,11 +900,11 @@ void EnClearTag_DrawEffects(GlobalContext* globalCtx) { func_80093D84(globalCtx->state.gfxCtx); // Draw all Debris effects. - for (i = 0; i < CLEAR_TAG_EFFECT_MAX_COUNT; i++, effect++) { + for (i = 0; i < CLEAR_TAG_EFFECT_COUNT; i++, effect++) { if (effect->type == CLEAR_TAG_EFFECT_DEBRIS) { // Apply the debris effect material if it has not already been applied. - if (!isMaterialApplied) { - isMaterialApplied++; + if (materialFlag == 0) { + materialFlag++; gSPDisplayList(POLY_OPA_DISP++, gArwingDebrisEffectMaterialDL); } @@ -921,14 +921,14 @@ void EnClearTag_DrawEffects(GlobalContext* globalCtx) { // Draw all ground flash effects. effect = firstEffect; - isMaterialApplied = false; - for (i = 0; i < CLEAR_TAG_EFFECT_MAX_COUNT; i++, effect++) { + materialFlag = 0; + for (i = 0; i < CLEAR_TAG_EFFECT_COUNT; i++, effect++) { if (effect->type == CLEAR_TAG_EFFECT_FLASH) { // Apply the flash ground effect material if it has not already been applied. - if (!isMaterialApplied) { + if (materialFlag == 0) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 200, 0); - isMaterialApplied++; + materialFlag++; } // Draw the ground flash effect. @@ -945,13 +945,13 @@ void EnClearTag_DrawEffects(GlobalContext* globalCtx) { // Draw all smoke effects. effect = firstEffect; - isMaterialApplied = false; - for (i = 0; i < CLEAR_TAG_EFFECT_MAX_COUNT; i++, effect++) { + materialFlag = 0; + for (i = 0; i < CLEAR_TAG_EFFECT_COUNT; i++, effect++) { if (effect->type == CLEAR_TAG_EFFECT_SMOKE) { // Apply the smoke effect material if it has not already been applied. - if (!isMaterialApplied) { + if (materialFlag == 0) { gSPDisplayList(POLY_XLU_DISP++, gArwingFireEffectMaterialDL); - isMaterialApplied++; + materialFlag++; } // Draw the smoke effect. @@ -974,14 +974,14 @@ void EnClearTag_DrawEffects(GlobalContext* globalCtx) { // Draw all fire effects. effect = firstEffect; - isMaterialApplied = false; - for (i = 0; i < CLEAR_TAG_EFFECT_MAX_COUNT; i++, effect++) { + materialFlag = 0; + for (i = 0; i < CLEAR_TAG_EFFECT_COUNT; i++, effect++) { if (effect->type == CLEAR_TAG_EFFECT_FIRE) { // Apply the fire effect material if it has not already been applied. - if (!isMaterialApplied) { + if (materialFlag == 0) { gSPDisplayList(POLY_XLU_DISP++, gArwingFireEffectMaterialDL); gDPSetEnvColor(POLY_XLU_DISP++, 255, 215, 255, 128); - isMaterialApplied++; + materialFlag++; } // Draw the fire effect. @@ -1000,14 +1000,14 @@ void EnClearTag_DrawEffects(GlobalContext* globalCtx) { // Draw all flash billboard effects. effect = firstEffect; - isMaterialApplied = false; - for (i = 0; i < CLEAR_TAG_EFFECT_MAX_COUNT; i++, effect++) { + materialFlag = 0; + for (i = 0; i < CLEAR_TAG_EFFECT_COUNT; i++, effect++) { if (effect->type == CLEAR_TAG_EFFECT_FLASH) { // Apply the flash billboard effect material if it has not already been applied. - if (!isMaterialApplied) { + if (materialFlag == 0) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 200, 0); - isMaterialApplied++; + materialFlag++; } // Draw the flash billboard effect. diff --git a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h index 707fbb4a5d..96299ae2cf 100644 --- a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h +++ b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h @@ -72,6 +72,8 @@ typedef struct EnClearTag { /* 0x01FE */ char unk_1FE[0x06]; } EnClearTag; // size = 0x0204 +#define CLEAR_TAG_EFFECT_COUNT 100 + typedef struct EnClearTagEffect { /* 0x0000 */ u8 type; /* 0x0001 */ u8 random; @@ -90,6 +92,4 @@ typedef struct EnClearTagEffect { /* 0x0060 */ Vec3f floorTangent; } EnClearTagEffect; // size = 0x6C -#define CLEAR_TAG_EFFECT_MAX_COUNT 100 - #endif diff --git a/src/overlays/actors/ovl_En_Diving_Game/z_en_diving_game.c b/src/overlays/actors/ovl_En_Diving_Game/z_en_diving_game.c index db6cbae4f1..f58fc3e997 100644 --- a/src/overlays/actors/ovl_En_Diving_Game/z_en_diving_game.c +++ b/src/overlays/actors/ovl_En_Diving_Game/z_en_diving_game.c @@ -313,9 +313,9 @@ void EnDivingGame_SetupRupeeThrow(EnDivingGame* this, GlobalContext* globalCtx) this->rupeesLeftToThrow = 10; } this->unk_2DC.x = this->unk_2DC.y = this->unk_2DC.z = this->unk_300.x = this->unk_300.y = this->unk_300.z = 0.1f; - this->camLookAt.x = globalCtx->view.lookAt.x; - this->camLookAt.y = globalCtx->view.lookAt.y; - this->camLookAt.z = globalCtx->view.lookAt.z; + this->camLookAt.x = globalCtx->view.at.x; + this->camLookAt.y = globalCtx->view.at.y; + this->camLookAt.z = globalCtx->view.at.z; this->camEye.x = globalCtx->view.eye.x; this->camEye.y = globalCtx->view.eye.y + 80.0f; this->camEye.z = globalCtx->view.eye.z + 250.0f; diff --git a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c index e6e104037b..273b68acea 100644 --- a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c +++ b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c @@ -18,9 +18,9 @@ void EnEncount2_Draw(Actor* thisx, GlobalContext* globalCtx); void EnEncount2_Wait(EnEncount2* this, GlobalContext* globalCtx); void EnEncount2_SpawnRocks(EnEncount2* this, GlobalContext* globalCtx); -void EnEncount2_ParticleInit(EnEncount2* this, Vec3f* particlePos, f32 scale); -void EnEncount2_ParticleDraw(Actor* thisx, GlobalContext* globalCtx); -void EnEncount2_ParticleUpdate(EnEncount2* this, GlobalContext* globalCtx); +void EnEncount2_SpawnEffect(EnEncount2* this, Vec3f* position, f32 scale); +void EnEncount2_DrawEffects(Actor* thisx, GlobalContext* globalCtx); +void EnEncount2_UpdateEffects(EnEncount2* this, GlobalContext* globalCtx); const ActorInit En_Encount2_InitVars = { ACTOR_EN_ENCOUNT2, @@ -123,8 +123,8 @@ void EnEncount2_SpawnRocks(EnEncount2* this, GlobalContext* globalCtx) { f32 tempVec2X; f32 tempVec2Y; f32 tempVec2Z; - f32 particleScale; - Vec3f particlePos; + f32 effectScale; + Vec3f effectPos; s16 spawnedRockType; s16 spawnerState; s16 maxRocks; @@ -164,9 +164,9 @@ void EnEncount2_SpawnRocks(EnEncount2* this, GlobalContext* globalCtx) { } if (spawnerState != ENCOUNT2_INACTIVE) { // Direction vector for the direction the camera is facing - tempVec1X = globalCtx->view.lookAt.x - globalCtx->view.eye.x; - tempVec1Y = globalCtx->view.lookAt.y - globalCtx->view.eye.y; - tempVec1Z = globalCtx->view.lookAt.z - globalCtx->view.eye.z; + tempVec1X = globalCtx->view.at.x - globalCtx->view.eye.x; + tempVec1Y = globalCtx->view.at.y - globalCtx->view.eye.y; + tempVec1Z = globalCtx->view.at.z - globalCtx->view.eye.z; // Normalised direction vector for the direction the camera is facing magnitude = sqrtf(SQ(tempVec1X) + SQ(tempVec1Y) + SQ(tempVec1Z)); @@ -181,16 +181,16 @@ void EnEncount2_SpawnRocks(EnEncount2* this, GlobalContext* globalCtx) { // Position between 160 and 200 units ahead of camera depending on camera pitch, plus a 400 unit offset in +y // (plus some random variation) - particlePos.x = Rand_CenteredFloat(200.0f) + (globalCtx->view.eye.x + (tempVec2X * 200.0f)); - particlePos.y = Rand_CenteredFloat(50.0f) + tempVec1Y; - particlePos.z = Rand_CenteredFloat(200.0f) + (globalCtx->view.eye.z + (tempVec2Z * 200.0f)); - particleScale = Rand_CenteredFloat(0.005f) + 0.007f; + effectPos.x = Rand_CenteredFloat(200.0f) + (globalCtx->view.eye.x + (tempVec2X * 200.0f)); + effectPos.y = Rand_CenteredFloat(50.0f) + tempVec1Y; + effectPos.z = Rand_CenteredFloat(200.0f) + (globalCtx->view.eye.z + (tempVec2Z * 200.0f)); + effectScale = Rand_CenteredFloat(0.005f) + 0.007f; if (spawnerState == ENCOUNT2_ACTIVE_DEATH_MOUNTAIN) { - EnEncount2_ParticleInit(this, &particlePos, particleScale); - } else if (this->particleSpawnTimer == 0) { - EnEncount2_ParticleInit(this, &particlePos, particleScale); - this->particleSpawnTimer = 5; + EnEncount2_SpawnEffect(this, &effectPos, effectScale); + } else if (this->effectSpawnTimer == 0) { + EnEncount2_SpawnEffect(this, &effectPos, effectScale); + this->effectSpawnTimer = 5; } if ((this->numSpawnedRocks < maxRocks) && (this->timerBetweenRockSpawns == 0)) { @@ -257,13 +257,13 @@ void EnEncount2_Update(Actor* thisx, GlobalContext* globalCtx2) { this->timerBetweenRockSpawns--; } - if (this->particleSpawnTimer != 0) { - this->particleSpawnTimer--; + if (this->effectSpawnTimer != 0) { + this->effectSpawnTimer--; } this->actionFunc(this, globalCtx); - EnEncount2_ParticleUpdate(this, globalCtx); + EnEncount2_UpdateEffects(this, globalCtx); if (!this->isNotDeathMountain) { this->unk_17C = this->envEffectsTimer / 60.0f; @@ -284,62 +284,62 @@ void EnEncount2_Update(Actor* thisx, GlobalContext* globalCtx2) { void EnEncount2_Draw(Actor* thisx, GlobalContext* globalCtx) { EnEncount2* this = (EnEncount2*)thisx; - EnEncount2_ParticleDraw(&this->actor, globalCtx); + EnEncount2_DrawEffects(&this->actor, globalCtx); } -void EnEncount2_ParticleInit(EnEncount2* this, Vec3f* particlePos, f32 scale) { - EnEncount2Particle* particle = this->particles; +void EnEncount2_SpawnEffect(EnEncount2* this, Vec3f* position, f32 scale) { + EnEncount2Effect* effect = this->effects; s16 i; - for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { - if (!particle->isAlive) { - particle->pos = *particlePos; - particle->scale = scale; - particle->rot.x = 0.0f; - particle->rot.y = 0.0f; - particle->rot.z = 0.0f; - particle->moveDirection.x = Rand_CenteredFloat(20.0f); - particle->moveDirection.y = -20.0f; - particle->moveDirection.z = Rand_CenteredFloat(20.0f); - particle->isAlive = 1; + for (i = 0; i < EN_ENCOUNT2_EFFECT_COUNT; i++, effect++) { + if (!effect->isAlive) { + effect->pos = *position; + effect->scale = scale; + effect->rot.x = 0.0f; + effect->rot.y = 0.0f; + effect->rot.z = 0.0f; + effect->moveDirection.x = Rand_CenteredFloat(20.0f); + effect->moveDirection.y = -20.0f; + effect->moveDirection.z = Rand_CenteredFloat(20.0f); + effect->isAlive = 1; break; } } } -void EnEncount2_ParticleUpdate(EnEncount2* this, GlobalContext* globalCtx) { +void EnEncount2_UpdateEffects(EnEncount2* this, GlobalContext* globalCtx) { s16 i; - EnEncount2Particle* particle = this->particles; + EnEncount2Effect* effect = this->effects; Player* player = GET_PLAYER(globalCtx); Vec3f targetPos; - for (i = 0; i < ARRAY_COUNT(this->particles); particle++, i++) { - if (particle->isAlive) { - particle->rot.x += Rand_ZeroOne() * 500.0f; - particle->rot.y += Rand_ZeroOne() * 500.0f; - particle->rot.z += Rand_ZeroOne() * 500.0f; - targetPos.x = particle->pos.x + particle->moveDirection.x; - targetPos.y = particle->pos.y + particle->moveDirection.y; - targetPos.z = particle->pos.z + particle->moveDirection.z; - Math_ApproachF(&particle->pos.x, targetPos.x, 0.3f, 30.0f); - Math_ApproachF(&particle->pos.y, targetPos.y, 0.8f, 250.0f); - Math_ApproachF(&particle->pos.z, targetPos.z, 0.3f, 30.0f); - Math_ApproachF(&particle->moveDirection.y, -20.0f, 0.9f, 1.0f); + for (i = 0; i < EN_ENCOUNT2_EFFECT_COUNT; effect++, i++) { + if (effect->isAlive) { + effect->rot.x += Rand_ZeroOne() * 500.0f; + effect->rot.y += Rand_ZeroOne() * 500.0f; + effect->rot.z += Rand_ZeroOne() * 500.0f; + targetPos.x = effect->pos.x + effect->moveDirection.x; + targetPos.y = effect->pos.y + effect->moveDirection.y; + targetPos.z = effect->pos.z + effect->moveDirection.z; + Math_ApproachF(&effect->pos.x, targetPos.x, 0.3f, 30.0f); + Math_ApproachF(&effect->pos.y, targetPos.y, 0.8f, 250.0f); + Math_ApproachF(&effect->pos.z, targetPos.z, 0.3f, 30.0f); + Math_ApproachF(&effect->moveDirection.y, -20.0f, 0.9f, 1.0f); if (globalCtx->sceneNum != SCENE_SPOT16) { - if (particle->pos.y < (player->actor.floorHeight - 50.0f)) { - particle->isAlive = 0; + if (effect->pos.y < (player->actor.floorHeight - 50.0f)) { + effect->isAlive = 0; } - } else if (particle->pos.y < 1500.0f) { - particle->isAlive = 0; + } else if (effect->pos.y < 1500.0f) { + effect->isAlive = 0; } } } } -void EnEncount2_ParticleDraw(Actor* thisx, GlobalContext* globalCtx) { +void EnEncount2_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { EnEncount2* this = (EnEncount2*)thisx; - EnEncount2Particle* particle = this->particles; + EnEncount2Effect* effect = this->effects; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; s16 i; s32 objBankIndex; @@ -352,13 +352,13 @@ void EnEncount2_ParticleDraw(Actor* thisx, GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[objBankIndex].segment); - for (i = 0; i < ARRAY_COUNT(this->particles); particle++, i++) { - if (particle->isAlive) { - Matrix_Translate(particle->pos.x, particle->pos.y, particle->pos.z, MTXMODE_NEW); - Matrix_RotateX(DEG_TO_RAD(particle->rot.x), MTXMODE_APPLY); - Matrix_RotateY(DEG_TO_RAD(particle->rot.y), MTXMODE_APPLY); - Matrix_RotateZ(DEG_TO_RAD(particle->rot.z), MTXMODE_APPLY); - Matrix_Scale(particle->scale, particle->scale, particle->scale, MTXMODE_APPLY); + for (i = 0; i < EN_ENCOUNT2_EFFECT_COUNT; effect++, i++) { + if (effect->isAlive) { + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_RotateX(DEG_TO_RAD(effect->rot.x), MTXMODE_APPLY); + Matrix_RotateY(DEG_TO_RAD(effect->rot.y), MTXMODE_APPLY); + Matrix_RotateZ(DEG_TO_RAD(effect->rot.z), MTXMODE_APPLY); + Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 155, 55, 255); gDPSetEnvColor(POLY_OPA_DISP++, 155, 255, 55, 255); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_encount2.c", 669), diff --git a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.h b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.h index 433e5df74e..e998be8399 100644 --- a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.h +++ b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.h @@ -8,13 +8,15 @@ struct EnEncount2; typedef void (*EnEncount2ActionFunc)(struct EnEncount2*, GlobalContext*); +#define EN_ENCOUNT2_EFFECT_COUNT 50 + typedef struct { /* 0x0000 */ Vec3f pos; /* 0x000C */ f32 scale; /* 0x0010 */ u8 isAlive; /* 0x0014 */ Vec3f moveDirection; /* 0x0020 */ Vec3f rot; -} EnEncount2Particle; // size = 0x2C +} EnEncount2Effect; // size = 0x2C typedef struct EnEncount2 { /* 0x0000 */ Actor actor; @@ -25,7 +27,7 @@ typedef struct EnEncount2 { /* 0x0158 */ s16 numSpawnedRocks; /* 0x015A */ s16 isNotDeathMountain; /* 0x015C */ s16 collapseSpawnerInactive; - /* 0x015E */ s16 particleSpawnTimer; + /* 0x015E */ s16 effectSpawnTimer; /* 0x0160 */ f32 unk_160; /* 0x0164 */ char unk164[0x4]; /* 0x0168 */ f32 unk_168; @@ -35,7 +37,7 @@ typedef struct EnEncount2 { /* 0x0178 */ s16 envEffectsTimer; /* 0x017C */ f32 unk_17C; /* 0x0180 */ u64 isQuaking; - /* 0x0188 */ EnEncount2Particle particles[50]; + /* 0x0188 */ EnEncount2Effect effects[EN_ENCOUNT2_EFFECT_COUNT]; } EnEncount2; // size = 0x0A20 #endif diff --git a/src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.c b/src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.c index 773ce7a37e..8c10e4a3b7 100644 --- a/src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.c +++ b/src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.c @@ -279,9 +279,9 @@ void EnExItem_BowlPrize(EnExItem* this, GlobalContext* globalCtx) { if (this->type == EXITEM_BOMBCHUS_BOWLING) { sp3C = 220.0f; } - tmpf1 = globalCtx->view.lookAt.x - globalCtx->view.eye.x; - tmpf2 = globalCtx->view.lookAt.y - globalCtx->view.eye.y; - tmpf3 = globalCtx->view.lookAt.z + sp3C - globalCtx->view.eye.z; + tmpf1 = globalCtx->view.at.x - globalCtx->view.eye.x; + tmpf2 = globalCtx->view.at.y - globalCtx->view.eye.y; + tmpf3 = globalCtx->view.at.z + sp3C - globalCtx->view.eye.z; tmpf4 = sqrtf(SQ(tmpf1) + SQ(tmpf2) + SQ(tmpf3)); tmpf5 = (tmpf1 / tmpf4) * 5.0f; @@ -362,9 +362,9 @@ void EnExItem_TargetPrizeApproach(EnExItem* this, GlobalContext* globalCtx) { if (this->timer != 0) { if (this->prizeRotateTimer != 0) { - tmpf1 = globalCtx->view.lookAt.x - globalCtx->view.eye.x; - tmpf2 = globalCtx->view.lookAt.y - 10.0f - globalCtx->view.eye.y; - tmpf3 = globalCtx->view.lookAt.z + 10.0f - globalCtx->view.eye.z; + tmpf1 = globalCtx->view.at.x - globalCtx->view.eye.x; + tmpf2 = globalCtx->view.at.y - 10.0f - globalCtx->view.eye.y; + tmpf3 = globalCtx->view.at.z + 10.0f - globalCtx->view.eye.z; tmpf4 = sqrtf(SQ(tmpf1) + SQ(tmpf2) + SQ(tmpf3)); tmpf5 = (tmpf1 / tmpf4) * 5.0f; diff --git a/src/overlays/actors/ovl_En_Fd/z_en_fd.c b/src/overlays/actors/ovl_En_Fd/z_en_fd.c index d97e6f557e..b1c697459d 100644 --- a/src/overlays/actors/ovl_En_Fd/z_en_fd.c +++ b/src/overlays/actors/ovl_En_Fd/z_en_fd.c @@ -23,11 +23,11 @@ void EnFd_Reappear(EnFd* this, GlobalContext* globalCtx); void EnFd_SpinAndGrow(EnFd* this, GlobalContext* globalCtx); void EnFd_JumpToGround(EnFd* this, GlobalContext* globalCtx); void EnFd_WaitForCore(EnFd* this, GlobalContext* globalCtx); -void EnFd_UpdateFlames(EnFd* this); -void EnFd_UpdateDots(EnFd* this); -void EnFd_AddEffect(EnFd*, u8, Vec3f*, Vec3f*, Vec3f*, u8, f32, f32); -void EnFd_DrawDots(EnFd* this, GlobalContext* globalCtx); -void EnFd_DrawFlames(EnFd* this, GlobalContext* globalCtx); +void EnFd_UpdateEffectsFlames(EnFd* this); +void EnFd_UpdateEffectsDots(EnFd* this); +void EnFd_SpawnEffect(EnFd*, u8, Vec3f*, Vec3f*, Vec3f*, u8, f32, f32); +void EnFd_DrawEffectsDots(EnFd* this, GlobalContext* globalCtx); +void EnFd_DrawEffectsFlames(EnFd* this, GlobalContext* globalCtx); void EnFd_Land(EnFd* this, GlobalContext* globalCtx); const ActorInit En_Fd_InitVars = { @@ -255,7 +255,7 @@ void EnFd_SpawnDot(EnFd* this, GlobalContext* globalCtx) { accel.x = (Rand_ZeroOne() - 0.5f) * 2.0f; accel.y = ((Rand_ZeroOne() - 0.5f) * 0.2f) + 0.3f; accel.z = (Rand_ZeroOne() - 0.5f) * 2.0f; - EnFd_AddEffect(this, FD_EFFECT_FLAME, &pos, &velocity, &accel, 8, 0.6f, 0.2f); + EnFd_SpawnEffect(this, FD_EFFECT_FLAME, &pos, &velocity, &accel, 8, 0.6f, 0.2f); } } @@ -678,8 +678,8 @@ void EnFd_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_2); EnFd_Fade(this, globalCtx); this->actionFunc(this, globalCtx); - EnFd_UpdateDots(this); - EnFd_UpdateFlames(this); + EnFd_UpdateEffectsDots(this); + EnFd_UpdateEffectsFlames(this); if (this->actionFunc != EnFd_Reappear && this->actionFunc != EnFd_SpinAndGrow && this->actionFunc != EnFd_WaitForCore) { if (this->attackTimer == 0 && this->invincibilityTimer == 0) { @@ -739,7 +739,7 @@ void EnFd_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec accel.x = (Rand_ZeroOne() - 0.5f) * 0.4f; accel.y = ((Rand_ZeroOne() - 0.5f) * 0.2f) + 0.6f; accel.z = (Rand_ZeroOne() - 0.5f) * 0.4f; - EnFd_AddEffect(this, FD_EFFECT_DOT, &pos, &velocity, &accel, 0, 0.006f, 0.0f); + EnFd_SpawnEffect(this, FD_EFFECT_DOT, &pos, &velocity, &accel, 0, 0.006f, 0.0f); } } } @@ -768,8 +768,8 @@ void EnFd_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_fd.c", 1751); Matrix_Push(); - EnFd_DrawDots(this, globalCtx); - EnFd_DrawFlames(this, globalCtx); + EnFd_DrawEffectsDots(this, globalCtx); + EnFd_DrawEffectsFlames(this, globalCtx); Matrix_Pop(); if (this->actionFunc != EnFd_Reappear && !(this->fadeAlpha < 0.9f)) { if (1) {} @@ -792,12 +792,12 @@ void EnFd_Draw(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_fd.c", 1822); } -void EnFd_AddEffect(EnFd* this, u8 type, Vec3f* pos, Vec3f* velocity, Vec3f* accel, u8 timer, f32 scale, - f32 scaleStep) { +void EnFd_SpawnEffect(EnFd* this, u8 type, Vec3f* pos, Vec3f* velocity, Vec3f* accel, u8 timer, f32 scale, + f32 scaleStep) { EnFdEffect* eff = this->effects; s16 i; - for (i = 0; i < ARRAY_COUNT(this->effects); i++, eff++) { + for (i = 0; i < EN_FD_EFFECT_COUNT; i++, eff++) { if (eff->type != FD_EFFECT_NONE) { continue; } @@ -816,11 +816,11 @@ void EnFd_AddEffect(EnFd* this, u8 type, Vec3f* pos, Vec3f* velocity, Vec3f* acc } } -void EnFd_UpdateFlames(EnFd* this) { +void EnFd_UpdateEffectsFlames(EnFd* this) { s16 i; EnFdEffect* eff = this->effects; - for (i = 0; i < ARRAY_COUNT(this->effects); i++, eff++) { + for (i = 0; i < EN_FD_EFFECT_COUNT; i++, eff++) { if (eff->type == FD_EFFECT_FLAME) { eff->timer--; if (eff->timer == 0) { @@ -839,7 +839,7 @@ void EnFd_UpdateFlames(EnFd* this) { } } -void EnFd_UpdateDots(EnFd* this) { +void EnFd_UpdateEffectsDots(EnFd* this) { EnFdEffect* eff = this->effects; s16 i; Color_RGBA8 dotColors[] = { @@ -849,7 +849,7 @@ void EnFd_UpdateDots(EnFd* this) { { 255, 0, 0, 0 }, }; - for (i = 0; i < ARRAY_COUNT(this->effects); i++, eff++) { + for (i = 0; i < EN_FD_EFFECT_COUNT; i++, eff++) { if (eff->type == FD_EFFECT_DOT) { eff->pos.x += eff->velocity.x; eff->pos.y += eff->velocity.y; @@ -872,26 +872,26 @@ void EnFd_UpdateDots(EnFd* this) { } } -void EnFd_DrawFlames(EnFd* this, GlobalContext* globalCtx) { +void EnFd_DrawEffectsFlames(EnFd* this, GlobalContext* globalCtx) { static void* dustTextures[] = { gDust8Tex, gDust7Tex, gDust6Tex, gDust5Tex, gDust4Tex, gDust3Tex, gDust2Tex, gDust1Tex, }; - s32 firstDone; + s32 materialFlag; s16 i; s16 idx; EnFdEffect* eff = this->effects; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_fd.c", 1969); - firstDone = false; + materialFlag = false; if (1) {} func_80093D84(globalCtx->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(this->effects); i++, eff++) { + for (i = 0; i < EN_FD_EFFECT_COUNT; i++, eff++) { if (eff->type == FD_EFFECT_FLAME) { - if (!firstDone) { + if (!materialFlag) { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); gSPDisplayList(POLY_XLU_DISP++, gFlareDancerDL_7928); gDPSetEnvColor(POLY_XLU_DISP++, 255, 10, 0, (u8)((this->fadeAlpha / 255.0f) * 255)); - firstDone = true; + materialFlag = true; } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 0, (u8)((this->fadeAlpha / 255.0f) * 255)); gDPPipeSync(POLY_XLU_DISP++); @@ -908,22 +908,22 @@ void EnFd_DrawFlames(EnFd* this, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_fd.c", 2020); } -void EnFd_DrawDots(EnFd* this, GlobalContext* globalCtx) { +void EnFd_DrawEffectsDots(EnFd* this, GlobalContext* globalCtx) { s16 i; - s16 firstDone; + s16 materialFlag; EnFdEffect* eff = this->effects; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_fd.c", 2034); - firstDone = false; + materialFlag = false; func_80093D84(globalCtx->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(this->effects); i++, eff++) { + for (i = 0; i < EN_FD_EFFECT_COUNT; i++, eff++) { if (eff->type == FD_EFFECT_DOT) { - if (!firstDone) { + if (!materialFlag) { func_80093D84(globalCtx->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, gFlareDancerDL_79F8); - firstDone = true; + materialFlag = true; } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, eff->color.r, eff->color.g, eff->color.b, (u8)(eff->color.a * (this->fadeAlpha / 255.0f))); diff --git a/src/overlays/actors/ovl_En_Fd/z_en_fd.h b/src/overlays/actors/ovl_En_Fd/z_en_fd.h index a00b622c92..cde714a400 100644 --- a/src/overlays/actors/ovl_En_Fd/z_en_fd.h +++ b/src/overlays/actors/ovl_En_Fd/z_en_fd.h @@ -14,6 +14,8 @@ typedef enum { FD_EFFECT_DOT } FDEffectType; +#define EN_FD_EFFECT_COUNT 200 + typedef struct { /* 0x0000 */ u8 type; /* 0x0001 */ u8 timer; @@ -47,7 +49,7 @@ typedef struct EnFd { /* 0x04D0 */ Vec3f corePos; /* 0x04DC */ Vec3s jointTable[27]; /* 0x057E */ Vec3s morphTable[27]; - /* 0x0620 */ EnFdEffect effects[200]; + /* 0x0620 */ EnFdEffect effects[EN_FD_EFFECT_COUNT]; } EnFd; // size = 0x31E0 #endif diff --git a/src/overlays/actors/ovl_En_Fw/z_en_fw.c b/src/overlays/actors/ovl_En_Fw/z_en_fw.c index bf87d0197e..5dc69cc467 100644 --- a/src/overlays/actors/ovl_En_Fw/z_en_fw.c +++ b/src/overlays/actors/ovl_En_Fw/z_en_fw.c @@ -15,10 +15,10 @@ void EnFw_Init(Actor* thisx, GlobalContext* globalCtx); void EnFw_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnFw_Update(Actor* thisx, GlobalContext* globalCtx); void EnFw_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnFw_UpdateDust(EnFw* this); -void EnFw_DrawDust(EnFw* this, GlobalContext* globalCtx); -void EnFw_AddDust(EnFw* this, Vec3f* initialPos, Vec3f* initialSpeed, Vec3f* accel, u8 initialTimer, f32 scale, - f32 scaleStep); +void EnFw_UpdateEffects(EnFw* this); +void EnFw_DrawEffects(EnFw* this, GlobalContext* globalCtx); +void EnFw_SpawnEffectDust(EnFw* this, Vec3f* initialPos, Vec3f* initialSpeed, Vec3f* accel, u8 initialTimer, f32 scale, + f32 scaleStep); void EnFw_Bounce(EnFw* this, GlobalContext* globalCtx); void EnFw_Run(EnFw* this, GlobalContext* globalCtx); void EnFw_JumpToParentInitPos(EnFw* this, GlobalContext* globalCtx); @@ -177,7 +177,7 @@ s32 EnFw_SpawnDust(EnFw* this, u8 timer, f32 scale, f32 scaleStep, s32 dustCnt, accel.z = (Rand_ZeroOne() - 0.5f) * xzAccel; pos.x = (Math_SinS(angle) * radius) + this->actor.world.pos.x; pos.z = (Math_CosS(angle) * radius) + this->actor.world.pos.z; - EnFw_AddDust(this, &pos, &velocity, &accel, timer, scale, scaleStep); + EnFw_SpawnEffectDust(this, &pos, &velocity, &accel, timer, scale, scaleStep); angle += (s16)(0x10000 / dustCnt); i--; } @@ -398,21 +398,21 @@ void EnFw_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec void EnFw_Draw(Actor* thisx, GlobalContext* globalCtx) { EnFw* this = (EnFw*)thisx; - EnFw_UpdateDust(this); + EnFw_UpdateEffects(this); Matrix_Push(); - EnFw_DrawDust(this, globalCtx); + EnFw_DrawEffects(this, globalCtx); Matrix_Pop(); func_80093D18(globalCtx->state.gfxCtx); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnFw_OverrideLimbDraw, EnFw_PostLimbDraw, this); } -void EnFw_AddDust(EnFw* this, Vec3f* initialPos, Vec3f* initialSpeed, Vec3f* accel, u8 initialTimer, f32 scale, - f32 scaleStep) { +void EnFw_SpawnEffectDust(EnFw* this, Vec3f* initialPos, Vec3f* initialSpeed, Vec3f* accel, u8 initialTimer, f32 scale, + f32 scaleStep) { EnFwEffect* eff = this->effects; s16 i; - for (i = 0; i < ARRAY_COUNT(this->effects); i++, eff++) { + for (i = 0; i < EN_FW_EFFECT_COUNT; i++, eff++) { if (eff->type != 1) { eff->scale = scale; eff->scaleStep = scaleStep; @@ -426,11 +426,11 @@ void EnFw_AddDust(EnFw* this, Vec3f* initialPos, Vec3f* initialSpeed, Vec3f* acc } } -void EnFw_UpdateDust(EnFw* this) { +void EnFw_UpdateEffects(EnFw* this) { EnFwEffect* eff = this->effects; s16 i; - for (i = 0; i < ARRAY_COUNT(this->effects); i++, eff++) { + for (i = 0; i < EN_FW_EFFECT_COUNT; i++, eff++) { if (eff->type != 0) { if ((--eff->timer) == 0) { eff->type = 0; @@ -448,29 +448,29 @@ void EnFw_UpdateDust(EnFw* this) { } } -void EnFw_DrawDust(EnFw* this, GlobalContext* globalCtx) { +void EnFw_DrawEffects(EnFw* this, GlobalContext* globalCtx) { static void* dustTextures[] = { gDust8Tex, gDust7Tex, gDust6Tex, gDust5Tex, gDust4Tex, gDust3Tex, gDust2Tex, gDust1Tex, }; EnFwEffect* eff = this->effects; - s16 firstDone; + s16 materialFlag; s16 alpha; s16 i; s16 idx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_fw.c", 1191); - firstDone = false; + materialFlag = false; func_80093D84(globalCtx->state.gfxCtx); if (1) {} - for (i = 0; i < ARRAY_COUNT(this->effects); i++, eff++) { + for (i = 0; i < EN_FW_EFFECT_COUNT; i++, eff++) { if (eff->type != 0) { - if (!firstDone) { + if (!materialFlag) { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0U); gSPDisplayList(POLY_XLU_DISP++, gFlareDancerDL_7928); gDPSetEnvColor(POLY_XLU_DISP++, 100, 60, 20, 0); - firstDone = true; + materialFlag = true; } alpha = eff->timer * (255.0f / eff->initialTimer); diff --git a/src/overlays/actors/ovl_En_Fw/z_en_fw.h b/src/overlays/actors/ovl_En_Fw/z_en_fw.h index f7d245e5e4..c2d482b98f 100644 --- a/src/overlays/actors/ovl_En_Fw/z_en_fw.h +++ b/src/overlays/actors/ovl_En_Fw/z_en_fw.h @@ -8,6 +8,8 @@ struct EnFw; typedef void (*EnFwActionFunc)(struct EnFw* this, GlobalContext* globalCtx); +#define EN_FW_EFFECT_COUNT 20 + typedef struct { /* 0x0000 */ u8 type; /* 0x0001 */ u8 timer; @@ -42,7 +44,7 @@ typedef struct EnFw { /* 0x0218 */ f32 runRadius; /* 0x021C */ Vec3s jointTable[11]; /* 0x025E */ Vec3s morphTable[11]; - /* 0x02A0 */ EnFwEffect effects[20]; + /* 0x02A0 */ EnFwEffect effects[EN_FW_EFFECT_COUNT]; } EnFw; // size = 0x0700 #endif diff --git a/src/overlays/actors/ovl_En_Fz/z_en_fz.c b/src/overlays/actors/ovl_En_Fz/z_en_fz.c index 35f323dd71..71f38da304 100644 --- a/src/overlays/actors/ovl_En_Fz/z_en_fz.c +++ b/src/overlays/actors/ovl_En_Fz/z_en_fz.c @@ -43,7 +43,7 @@ void EnFz_SpawnIceSmokeNoFreeze(EnFz* this, Vec3f* pos, Vec3f* velocity, Vec3f* void EnFz_SpawnIceSmokeFreeze(EnFz* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 xyScale, f32 xyScaleTarget, s16 primAlpha, u8 isTimerMod8); void EnFz_UpdateIceSmoke(EnFz* this, GlobalContext* globalCtx); -void EnFz_DrawIceSmoke(EnFz* this, GlobalContext* globalCtx); +void EnFz_DrawEffects(EnFz* this, GlobalContext* globalCtx); const ActorInit En_Fz_InitVars = { ACTOR_EN_FZ, @@ -741,152 +741,152 @@ void EnFz_Draw(Actor* thisx, GlobalContext* globalCtx) { } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_fz.c", 1200); - EnFz_DrawIceSmoke(this, globalCtx); + EnFz_DrawEffects(this, globalCtx); } void EnFz_SpawnIceSmokeNoFreeze(EnFz* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 xyScale) { - EnFzEffectSsIceSmoke* iceSmoke = this->iceSmoke; + EnFzEffect* effect = this->effects; s16 i; - for (i = 0; i < ARRAY_COUNT(this->iceSmoke); i++) { - if (iceSmoke->type == 0) { - iceSmoke->type = 1; - iceSmoke->pos = *pos; - iceSmoke->velocity = *velocity; - iceSmoke->accel = *accel; - iceSmoke->primAlphaState = 0; - iceSmoke->xyScale = xyScale / 1000.0f; - iceSmoke->primAlpha = 0; - iceSmoke->timer = 0; + for (i = 0; i < EN_FZ_EFFECT_COUNT; i++) { + if (effect->type == 0) { + effect->type = 1; + effect->pos = *pos; + effect->velocity = *velocity; + effect->accel = *accel; + effect->primAlphaState = 0; + effect->xyScale = xyScale / 1000.0f; + effect->primAlpha = 0; + effect->timer = 0; break; } - iceSmoke++; + effect++; } } void EnFz_SpawnIceSmokeFreeze(EnFz* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 xyScale, f32 xyScaleTarget, s16 primAlpha, u8 isTimerMod8) { - EnFzEffectSsIceSmoke* iceSmoke = this->iceSmoke; + EnFzEffect* effect = this->effects; s16 i; - for (i = 0; i < ARRAY_COUNT(this->iceSmoke); i++) { - if (iceSmoke->type == 0) { - iceSmoke->type = 2; - iceSmoke->pos = *pos; - iceSmoke->velocity = *velocity; - iceSmoke->accel = *accel; - iceSmoke->primAlphaState = 0; - iceSmoke->xyScale = xyScale / 1000.0f; - iceSmoke->xyScaleTarget = xyScaleTarget / 1000.0f; - iceSmoke->primAlpha = primAlpha; - iceSmoke->timer = 0; - iceSmoke->isTimerMod8 = isTimerMod8; + for (i = 0; i < EN_FZ_EFFECT_COUNT; i++) { + if (effect->type == 0) { + effect->type = 2; + effect->pos = *pos; + effect->velocity = *velocity; + effect->accel = *accel; + effect->primAlphaState = 0; + effect->xyScale = xyScale / 1000.0f; + effect->xyScaleTarget = xyScaleTarget / 1000.0f; + effect->primAlpha = primAlpha; + effect->timer = 0; + effect->isTimerMod8 = isTimerMod8; break; } - iceSmoke++; + effect++; } } void EnFz_UpdateIceSmoke(EnFz* this, GlobalContext* globalCtx) { - EnFzEffectSsIceSmoke* iceSmoke = this->iceSmoke; + EnFzEffect* effect = this->effects; s16 i; Vec3f pos; - for (i = 0; i < ARRAY_COUNT(this->iceSmoke); i++) { - if (iceSmoke->type) { - iceSmoke->pos.x += iceSmoke->velocity.x; - iceSmoke->pos.y += iceSmoke->velocity.y; - iceSmoke->pos.z += iceSmoke->velocity.z; - iceSmoke->timer++; - iceSmoke->velocity.x += iceSmoke->accel.x; - iceSmoke->velocity.y += iceSmoke->accel.y; - iceSmoke->velocity.z += iceSmoke->accel.z; - if (iceSmoke->type == 1) { - if (iceSmoke->primAlphaState == 0) { // Becoming more opaque - iceSmoke->primAlpha += 10; - if (iceSmoke->primAlpha >= 100) { - iceSmoke->primAlphaState++; + for (i = 0; i < EN_FZ_EFFECT_COUNT; i++) { + if (effect->type) { + effect->pos.x += effect->velocity.x; + effect->pos.y += effect->velocity.y; + effect->pos.z += effect->velocity.z; + effect->timer++; + effect->velocity.x += effect->accel.x; + effect->velocity.y += effect->accel.y; + effect->velocity.z += effect->accel.z; + if (effect->type == 1) { + if (effect->primAlphaState == 0) { // Becoming more opaque + effect->primAlpha += 10; + if (effect->primAlpha >= 100) { + effect->primAlphaState++; } } else { // Becoming more transparent - iceSmoke->primAlpha -= 3; - if (iceSmoke->primAlpha <= 0) { - iceSmoke->primAlpha = 0; - iceSmoke->type = 0; + effect->primAlpha -= 3; + if (effect->primAlpha <= 0) { + effect->primAlpha = 0; + effect->type = 0; } } - } else if (iceSmoke->type == 2) { // Freezing - Math_ApproachF(&iceSmoke->xyScale, iceSmoke->xyScaleTarget, 0.1f, iceSmoke->xyScaleTarget / 10.0f); - if (iceSmoke->primAlphaState == 0) { // Becoming more opaque - if (iceSmoke->timer >= 7) { - iceSmoke->primAlphaState++; + } else if (effect->type == 2) { // Freezing + Math_ApproachF(&effect->xyScale, effect->xyScaleTarget, 0.1f, effect->xyScaleTarget / 10.0f); + if (effect->primAlphaState == 0) { // Becoming more opaque + if (effect->timer >= 7) { + effect->primAlphaState++; } } else { // Becoming more transparent, slows down - iceSmoke->accel.y = 2.0f; - iceSmoke->primAlpha -= 17; - iceSmoke->velocity.x *= 0.75f; - iceSmoke->velocity.z *= 0.75f; - if (iceSmoke->primAlpha <= 0) { - iceSmoke->primAlpha = 0; - iceSmoke->type = 0; + effect->accel.y = 2.0f; + effect->primAlpha -= 17; + effect->velocity.x *= 0.75f; + effect->velocity.z *= 0.75f; + if (effect->primAlpha <= 0) { + effect->primAlpha = 0; + effect->type = 0; } } - if ((this->unusedTimer2 == 0) && (iceSmoke->primAlpha >= 101) && iceSmoke->isTimerMod8) { - this->collider3.dim.pos.x = (s16)iceSmoke->pos.x; - this->collider3.dim.pos.y = (s16)iceSmoke->pos.y; - this->collider3.dim.pos.z = (s16)iceSmoke->pos.z; + if ((this->unusedTimer2 == 0) && (effect->primAlpha >= 101) && effect->isTimerMod8) { + this->collider3.dim.pos.x = (s16)effect->pos.x; + this->collider3.dim.pos.y = (s16)effect->pos.y; + this->collider3.dim.pos.z = (s16)effect->pos.z; CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider3.base); } - pos.x = iceSmoke->pos.x; - pos.y = iceSmoke->pos.y + 10.0f; - pos.z = iceSmoke->pos.z; + pos.x = effect->pos.x; + pos.y = effect->pos.y + 10.0f; + pos.z = effect->pos.z; - if ((iceSmoke->primAlphaState != 2) && EnFz_ReachedTarget(this, &pos)) { - iceSmoke->primAlphaState = 2; - iceSmoke->velocity.x = 0.0f; - iceSmoke->velocity.z = 0.0f; + if ((effect->primAlphaState != 2) && EnFz_ReachedTarget(this, &pos)) { + effect->primAlphaState = 2; + effect->velocity.x = 0.0f; + effect->velocity.z = 0.0f; } } } - iceSmoke++; + effect++; } } -void EnFz_DrawIceSmoke(EnFz* this, GlobalContext* globalCtx) { - EnFzEffectSsIceSmoke* iceSmoke = this->iceSmoke; +void EnFz_DrawEffects(EnFz* this, GlobalContext* globalCtx) { + EnFzEffect* effect = this->effects; s16 i; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - u8 texLoaded = false; + u8 materialFlag = 0; OPEN_DISPS(gfxCtx, "../z_en_fz.c", 1384); func_80093D84(globalCtx->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(this->iceSmoke); i++) { - if (iceSmoke->type > 0) { + for (i = 0; i < EN_FZ_EFFECT_COUNT; i++) { + if (effect->type > 0) { gDPPipeSync(POLY_XLU_DISP++); - if (!texLoaded) { + if (!materialFlag) { gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gFreezardSteamStartDL)); - texLoaded++; + materialFlag++; } - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, iceSmoke->primAlpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, effect->primAlpha); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 3 * (iceSmoke->timer + (3 * i)), - 15 * (iceSmoke->timer + (3 * i)), 32, 64, 1, 0, 0, 32, 32)); - Matrix_Translate(iceSmoke->pos.x, iceSmoke->pos.y, iceSmoke->pos.z, MTXMODE_NEW); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 3 * (effect->timer + (3 * i)), + 15 * (effect->timer + (3 * i)), 32, 64, 1, 0, 0, 32, 32)); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&globalCtx->billboardMtxF); - Matrix_Scale(iceSmoke->xyScale, iceSmoke->xyScale, 1.0f, MTXMODE_APPLY); + Matrix_Scale(effect->xyScale, effect->xyScale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_fz.c", 1424), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gFreezardSteamDL)); } - iceSmoke++; + effect++; } CLOSE_DISPS(gfxCtx, "../z_en_fz.c", 1430); diff --git a/src/overlays/actors/ovl_En_Fz/z_en_fz.h b/src/overlays/actors/ovl_En_Fz/z_en_fz.h index 03fb037175..eac5e972e1 100644 --- a/src/overlays/actors/ovl_En_Fz/z_en_fz.h +++ b/src/overlays/actors/ovl_En_Fz/z_en_fz.h @@ -21,7 +21,9 @@ typedef struct { /* 0x0030 */ f32 xyScale; /* 0x0034 */ f32 xyScaleTarget; /* 0x0038 */ u8 isTimerMod8; // conditional, used to run CollisionCheck_SetAT -} EnFzEffectSsIceSmoke; // size = 0x3C +} EnFzEffect; // size = 0x3C + +#define EN_FZ_EFFECT_COUNT 40 typedef struct EnFz { /* 0x0000 */ Actor actor; @@ -49,7 +51,7 @@ typedef struct EnFz { /* 0x0263 */ u8 unusedTimer2; // Timer /* 0x0264 */ Vec3f wallHitPos; // Position contact was made with a wall /* 0x0270 */ f32 distToTargetSq; - /* 0x0274 */ EnFzEffectSsIceSmoke iceSmoke[40]; + /* 0x0274 */ EnFzEffect effects[EN_FZ_EFFECT_COUNT]; } EnFz; // size = 0x0BD4 #endif diff --git a/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.c b/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.c index c72cc0093e..c571de0688 100644 --- a/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.c +++ b/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.c @@ -82,7 +82,7 @@ void EnGSwitch_Init(Actor* thisx, GlobalContext* globalCtx) { this->type = (this->actor.params >> 0xC) & 0xF; this->switchFlag = this->actor.params & 0x3F; - this->numEffects = ARRAY_COUNT(this->effects); + this->numEffects = EN_GSWITCH_EFFECT_COUNT; // "index" osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ インデックス ☆☆☆☆☆ %x\n" VT_RST, this->type); // "save" diff --git a/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.h b/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.h index 0bc7cce994..dd4f885a34 100644 --- a/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.h +++ b/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.h @@ -24,6 +24,8 @@ typedef enum { /* 3 */ ENGSWITCH_TARGET_RUPEE } EnGSwitchType; +#define EN_GSWITCH_EFFECT_COUNT 100 + typedef struct { /* 0x00 */ Vec3f pos; /* 0x0C */ s16 scale; @@ -54,7 +56,7 @@ typedef struct EnGSwitch { /* 0x016C */ Vec3f targetPos; /* 0x0178 */ s8 objIndex; /* 0x017C */ ColliderCylinder collider; - /* 0x01C8 */ EnGSwitchEffect effects[100]; + /* 0x01C8 */ EnGSwitchEffect effects[EN_GSWITCH_EFFECT_COUNT]; } EnGSwitch; // size = 0x12F8 #endif diff --git a/src/overlays/actors/ovl_En_Go/z_en_go.c b/src/overlays/actors/ovl_En_Go/z_en_go.c index f4014e5e5f..1786c2d943 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -29,9 +29,10 @@ void func_80A40C78(EnGo* this, GlobalContext* globalCtx); void EnGo_Eyedrops(EnGo* this, GlobalContext* globalCtx); void func_80A40DCC(EnGo* this, GlobalContext* globalCtx); -void EnGo_AddDust(EnGo* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, u8 initialTimer, f32 scale, f32 scaleStep); -void EnGo_UpdateDust(EnGo* this); -void EnGo_DrawDust(EnGo* this, GlobalContext* globalCtx); +void EnGo_SpawnEffectDust(EnGo* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, u8 initialTimer, f32 scale, + f32 scaleStep); +void EnGo_UpdateEffects(EnGo* this); +void EnGo_DrawEffects(EnGo* this, GlobalContext* globalCtx); const ActorInit En_Go_InitVars = { ACTOR_EN_GO, @@ -532,7 +533,7 @@ s32 EnGo_SpawnDust(EnGo* this, u8 initialTimer, f32 scale, f32 scaleStep, s32 nu accel.z = (Rand_ZeroOne() - 0.5f) * xzAccel; pos.x = (Math_SinS(angle) * radius) + this->actor.world.pos.x; pos.z = (Math_CosS(angle) * radius) + this->actor.world.pos.z; - EnGo_AddDust(this, &pos, &velocity, &accel, initialTimer, scale, scaleStep); + EnGo_SpawnEffectDust(this, &pos, &velocity, &accel, initialTimer, scale, scaleStep); angle += (s16)(0x10000 / numDustEffects); i--; } @@ -1124,9 +1125,9 @@ void EnGo_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_go.c", 2479); - EnGo_UpdateDust(this); + EnGo_UpdateEffects(this); Matrix_Push(); - EnGo_DrawDust(this, globalCtx); + EnGo_DrawEffects(this, globalCtx); Matrix_Pop(); if (this->actionFunc == EnGo_CurledUp) { @@ -1145,16 +1146,17 @@ void EnGo_Draw(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnGo_OverrideLimbDraw, EnGo_PostLimbDraw, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_go.c", 2525); - EnGo_DrawDust(this, globalCtx); + EnGo_DrawEffects(this, globalCtx); } } -void EnGo_AddDust(EnGo* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, u8 initialTimer, f32 scale, f32 scaleStep) { - EnGoEffect* dustEffect = this->dustEffects; +void EnGo_SpawnEffectDust(EnGo* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, u8 initialTimer, f32 scale, + f32 scaleStep) { + EnGoEffect* dustEffect = this->effects; s16 i; s16 timer; - for (i = 0; i < ARRAY_COUNT(this->dustEffects); i++, dustEffect++) { + for (i = 0; i < EN_GO_EFFECT_COUNT; i++, dustEffect++) { if (dustEffect->type != 1) { dustEffect->scale = scale; dustEffect->scaleStep = scaleStep; @@ -1171,12 +1173,12 @@ void EnGo_AddDust(EnGo* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, u8 init } } -void EnGo_UpdateDust(EnGo* this) { - EnGoEffect* dustEffect = this->dustEffects; +void EnGo_UpdateEffects(EnGo* this) { + EnGoEffect* dustEffect = this->effects; f32 randomNumber; s16 i; - for (i = 0; i < ARRAY_COUNT(this->dustEffects); i++, dustEffect++) { + for (i = 0; i < EN_GO_EFFECT_COUNT; i++, dustEffect++) { if (dustEffect->type) { dustEffect->timer--; if (dustEffect->timer == 0) { @@ -1197,25 +1199,25 @@ void EnGo_UpdateDust(EnGo* this) { } } -void EnGo_DrawDust(EnGo* this, GlobalContext* globalCtx) { +void EnGo_DrawEffects(EnGo* this, GlobalContext* globalCtx) { static void* dustTex[] = { gDust8Tex, gDust7Tex, gDust6Tex, gDust5Tex, gDust4Tex, gDust3Tex, gDust2Tex, gDust1Tex }; - EnGoEffect* dustEffect = this->dustEffects; + EnGoEffect* dustEffect = this->effects; s16 alpha; - s16 firstDone; + s16 materialFlag; s16 index; s16 i; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_go.c", 2626); - firstDone = false; + materialFlag = false; func_80093D84(globalCtx->state.gfxCtx); if (1) {} - for (i = 0; i < ARRAY_COUNT(this->dustEffects); i++, dustEffect++) { + for (i = 0; i < EN_GO_EFFECT_COUNT; i++, dustEffect++) { if (dustEffect->type) { - if (!firstDone) { + if (!materialFlag) { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); gSPDisplayList(POLY_XLU_DISP++, gGoronDL_00FD40); gDPSetEnvColor(POLY_XLU_DISP++, 100, 60, 20, 0); - firstDone = true; + materialFlag = true; } alpha = dustEffect->timer * (255.0f / dustEffect->initialTimer); diff --git a/src/overlays/actors/ovl_En_Go/z_en_go.h b/src/overlays/actors/ovl_En_Go/z_en_go.h index f020e8de1d..551299e550 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.h +++ b/src/overlays/actors/ovl_En_Go/z_en_go.h @@ -23,6 +23,8 @@ typedef s16 (*callback2_80A3ED24)(GlobalContext*, struct EnGo*); // /* 0x90 */ GORON1_DMT_BIGGORON, +#define EN_GO_EFFECT_COUNT 20 + typedef struct { /* 0x0000 */ u8 type; /* 0x0001 */ u8 timer; @@ -55,7 +57,7 @@ typedef struct EnGo { /* 0x021E */ s16 unk_21E; /* 0x0220 */ s16 jointTable[18]; /* 0x0244 */ s16 morphTable[18]; - /* 0x0268 */ EnGoEffect dustEffects[20]; + /* 0x0268 */ EnGoEffect effects[EN_GO_EFFECT_COUNT]; } EnGo; // size = 0x06C8 #endif diff --git a/src/overlays/actors/ovl_En_Go2/z_en_go2.c b/src/overlays/actors/ovl_En_Go2/z_en_go2.c index b2be801fdb..74e2356e52 100644 --- a/src/overlays/actors/ovl_En_Go2/z_en_go2.c +++ b/src/overlays/actors/ovl_En_Go2/z_en_go2.c @@ -168,12 +168,13 @@ static EnGo2DustEffectData sDustEffectData[2][4] = { static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; -void EnGo2_AddDust(EnGo2* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, u8 initialTimer, f32 scale, f32 scaleStep) { - EnGoEffect* dustEffect = this->dustEffects; +void EnGo2_SpawnEffectDust(EnGo2* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, u8 initialTimer, f32 scale, + f32 scaleStep) { + EnGoEffect* dustEffect = this->effects; s16 i; s16 timer; - for (i = 0; i < ARRAY_COUNT(this->dustEffects); i++, dustEffect++) { + for (i = 0; i < EN_GO2_EFFECT_COUNT; i++, dustEffect++) { if (dustEffect->type != 1) { dustEffect->scale = scale; dustEffect->scaleStep = scaleStep; @@ -190,12 +191,12 @@ void EnGo2_AddDust(EnGo2* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, u8 in } } -void EnGo2_UpdateDust(EnGo2* this) { - EnGoEffect* dustEffect = this->dustEffects; +void EnGo2_UpdateEffects(EnGo2* this) { + EnGoEffect* dustEffect = this->effects; f32 randomNumber; s16 i; - for (i = 0; i < ARRAY_COUNT(this->dustEffects); i++, dustEffect++) { + for (i = 0; i < EN_GO2_EFFECT_COUNT; i++, dustEffect++) { if (dustEffect->type) { dustEffect->timer--; if (dustEffect->timer == 0) { @@ -215,26 +216,26 @@ void EnGo2_UpdateDust(EnGo2* this) { } } -void EnGo2_DrawDust(EnGo2* this, GlobalContext* globalCtx) { - EnGoEffect* dustEffect = this->dustEffects; +void EnGo2_DrawEffects(EnGo2* this, GlobalContext* globalCtx) { + EnGoEffect* dustEffect = this->effects; s16 alpha; - s16 firstDone; + s16 materialFlag; s16 index; s16 i; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_go2_eff.c", 111); - firstDone = false; + materialFlag = false; func_80093D84(globalCtx->state.gfxCtx); if (1) {} - for (i = 0; i < ARRAY_COUNT(this->dustEffects); i++, dustEffect++) { + for (i = 0; i < EN_GO2_EFFECT_COUNT; i++, dustEffect++) { if (dustEffect->type) { - if (!firstDone) { + if (!materialFlag) { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); gSPDisplayList(POLY_XLU_DISP++, gGoronDL_00FD40); gDPSetEnvColor(POLY_XLU_DISP++, 100, 60, 20, 0); - firstDone = true; + materialFlag = true; } alpha = dustEffect->timer * (255.0f / dustEffect->initialTimer); @@ -270,7 +271,7 @@ s32 EnGo2_SpawnDust(EnGo2* this, u8 initialTimer, f32 scale, f32 scaleStep, s32 accel.y += Rand_ZeroOne() * yAccel; pos.x = (Math_SinS(angle) * radius) + this->actor.world.pos.x; pos.z = (Math_CosS(angle) * radius) + this->actor.world.pos.z; - EnGo2_AddDust(this, &pos, &velocity, &accel, initialTimer, scale, scaleStep); + EnGo2_SpawnEffectDust(this, &pos, &velocity, &accel, initialTimer, scale, scaleStep); angle += (s16)(0x10000 / numDustEffects); i--; } @@ -2040,9 +2041,9 @@ void EnGo2_Draw(Actor* thisx, GlobalContext* globalCtx) { void* eyeTextures[] = { gGoronCsEyeClosed2Tex, gGoronCsEyeOpenTex, gGoronCsEyeHalfTex, gGoronCsEyeClosedTex }; void* mouthTextures[] = { gGoronCsMouthNeutralTex, gGoronCsMouthSmileTex }; - EnGo2_UpdateDust(this); + EnGo2_UpdateEffects(this); Matrix_Push(); - EnGo2_DrawDust(this, globalCtx); + EnGo2_DrawEffects(this, globalCtx); Matrix_Pop(); if ((this->actionFunc == EnGo2_CurledUp) && (this->skelAnime.playSpeed == 0.0f) && diff --git a/src/overlays/actors/ovl_En_Go2/z_en_go2.h b/src/overlays/actors/ovl_En_Go2/z_en_go2.h index 079938097b..9c8c1076a2 100644 --- a/src/overlays/actors/ovl_En_Go2/z_en_go2.h +++ b/src/overlays/actors/ovl_En_Go2/z_en_go2.h @@ -65,6 +65,8 @@ typedef struct { f32 yAccel; } EnGo2DustEffectData; // size = 0x18 +#define EN_GO2_EFFECT_COUNT 10 + typedef struct EnGo2 { /* 0x0000 */ Actor actor; /* 0x014C */ SkelAnime skelAnime; @@ -93,7 +95,7 @@ typedef struct EnGo2 { /* 0x0226 */ s16 unk_226[18]; // Remains unknown /* 0x024A */ s16 unk_24A[18]; // Remains unknown /* 0x026E */ u16 unk_26E; // Remains unknown = 1, 2, or 4: used in func_80034A14 - /* 0x0270 */ EnGoEffect dustEffects[10]; + /* 0x0270 */ EnGoEffect effects[EN_GO2_EFFECT_COUNT]; /* 0x04A0 */ Vec3f eye; /* 0x04AC */ Vec3f at; /* 0x04B8 */ Vec3s jointTable[18]; 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 c6cf651ff0..ab70028934 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.c +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.c @@ -30,9 +30,9 @@ void func_80AB714C(EnNiw* this, GlobalContext* globalCtx); void func_80AB7204(EnNiw* this, GlobalContext* globalCtx); void func_80AB7290(EnNiw* this, GlobalContext* globalCtx); void func_80AB7328(EnNiw* this, GlobalContext* globalCtx); -void EnNiw_FeatherSpawn(EnNiw* this, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 scale); -void EnNiw_FeatherUpdate(EnNiw* this, GlobalContext* globalCtx); -void EnNiw_FeatherDraw(EnNiw* this, GlobalContext* globalCtx); +void EnNiw_SpawnFeather(EnNiw* this, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 scale); +void EnNiw_UpdateEffects(EnNiw* this, GlobalContext* globalCtx); +void EnNiw_DrawEffects(EnNiw* this, GlobalContext* globalCtx); static s16 D_80AB85E0 = 0; @@ -347,9 +347,9 @@ void EnNiw_SpawnAttackCucco(EnNiw* this, GlobalContext* globalCtx) { Actor* attackCucco; if ((this->timer5 == 0) && (this->unk_296 < 7)) { - viewX = globalCtx->view.lookAt.x - globalCtx->view.eye.x; - viewY = globalCtx->view.lookAt.y - globalCtx->view.eye.y; - viewZ = globalCtx->view.lookAt.z - globalCtx->view.eye.z; + viewX = globalCtx->view.at.x - globalCtx->view.eye.x; + viewY = globalCtx->view.at.y - globalCtx->view.eye.y; + viewZ = globalCtx->view.at.z - globalCtx->view.eye.z; attackCuccoPos.x = ((Rand_ZeroOne() - 0.5f) * viewX) + globalCtx->view.eye.x; attackCuccoPos.y = Rand_CenteredFloat(0.3f) + ((globalCtx->view.eye.y + 50.0f) + (viewY * 0.5f)); attackCuccoPos.z = ((Rand_ZeroOne() - 0.5f) * viewZ) + globalCtx->view.eye.z; @@ -922,13 +922,13 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { accel.x = 0.0f; accel.y = -0.15f; accel.z = 0.0f; - EnNiw_FeatherSpawn(this, &pos, &vel, &accel, scale); + EnNiw_SpawnFeather(this, &pos, &vel, &accel, scale); } this->unk_2A6 = 0; } - EnNiw_FeatherUpdate(this, globalCtx); + EnNiw_UpdateEffects(this, globalCtx); if (this->timer1 != 0) { this->timer1--; } @@ -983,9 +983,9 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { } if (thisx->floorHeight <= BGCHECK_Y_MIN || thisx->floorHeight >= 32000.0f) { osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 上下? ☆☆☆☆☆ %f\n" VT_RST, thisx->floorHeight); - cam.x = globalCtx->view.lookAt.x - globalCtx->view.eye.x; - cam.y = globalCtx->view.lookAt.y - globalCtx->view.eye.y; - cam.z = globalCtx->view.lookAt.z - globalCtx->view.eye.z; + cam.x = globalCtx->view.at.x - globalCtx->view.eye.x; + cam.y = globalCtx->view.at.y - globalCtx->view.eye.y; + cam.z = globalCtx->view.at.z - globalCtx->view.eye.z; camResult = cam.y / sqrtf(SQ(cam.x) + SQ(cam.y) + SQ(cam.z)); osSyncPrintf(VT_FGCOL(RED) "☆☆☆☆☆ 範囲外X! ☆☆☆☆☆ %f\n" VT_RST, thisx->world.pos.x); osSyncPrintf(VT_FGCOL(RED) "☆☆☆☆☆ 範囲外Y! ☆☆☆☆☆ %f\n" VT_RST, thisx->world.pos.y); @@ -1145,84 +1145,84 @@ void EnNiw_Draw(Actor* thisx, GlobalContext* globalCtx) { func_80033C30(&this->actor.world.pos, &scale, 255, globalCtx); } - EnNiw_FeatherDraw(this, globalCtx); + EnNiw_DrawEffects(this, globalCtx); } -void EnNiw_FeatherSpawn(EnNiw* this, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 scale) { +void EnNiw_SpawnFeather(EnNiw* this, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 scale) { s16 i; - EnNiwFeather* feather = this->feathers; + EnNiwEffect* effect = this->effects; - for (i = 0; i < ARRAY_COUNT(this->feathers); i++, feather++) { - if (feather->type == 0) { - feather->type = 1; - feather->pos = *pos; - feather->vel = *vel; - feather->accel = *accel; - feather->timer = 0; - feather->scale = scale / 1000.0f; - feather->life = (s16)Rand_ZeroFloat(20.0f) + 40; - feather->unk_2A = Rand_ZeroFloat(1000.0f); + for (i = 0; i < EN_NIW_EFFECT_COUNT; i++, effect++) { + if (effect->type == 0) { + effect->type = 1; + effect->pos = *pos; + effect->vel = *vel; + effect->accel = *accel; + effect->timer = 0; + effect->scale = scale / 1000.0f; + effect->life = (s16)Rand_ZeroFloat(20.0f) + 40; + effect->unk_2A = Rand_ZeroFloat(1000.0f); break; } } } -void EnNiw_FeatherUpdate(EnNiw* this, GlobalContext* globalCtx) { +void EnNiw_UpdateEffects(EnNiw* this, GlobalContext* globalCtx) { s16 i; - EnNiwFeather* feather = this->feathers; + EnNiwEffect* effect = this->effects; - for (i = 0; i < ARRAY_COUNT(this->feathers); i++, feather++) { - if (feather->type != 0) { - feather->timer++; - feather->pos.x += feather->vel.x; - feather->pos.y += feather->vel.y; - feather->pos.z += feather->vel.z; - feather->vel.x += feather->accel.x; - feather->vel.y += feather->accel.y; - feather->vel.z += feather->accel.z; - if (feather->type == 1) { - feather->unk_2A++; - Math_ApproachF(&feather->vel.x, 0.0f, 1.0f, 0.05f); - Math_ApproachF(&feather->vel.z, 0.0f, 1.0f, 0.05f); - if (feather->vel.y < -0.5f) { - feather->vel.y = -0.5f; + for (i = 0; i < EN_NIW_EFFECT_COUNT; i++, effect++) { + if (effect->type != 0) { + effect->timer++; + effect->pos.x += effect->vel.x; + effect->pos.y += effect->vel.y; + effect->pos.z += effect->vel.z; + effect->vel.x += effect->accel.x; + effect->vel.y += effect->accel.y; + effect->vel.z += effect->accel.z; + if (effect->type == 1) { + effect->unk_2A++; + 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; } - feather->unk_30 = Math_SinS(feather->unk_2A * 0xBB8) * M_PI * 0.2f; + effect->unk_30 = Math_SinS(effect->unk_2A * 0xBB8) * M_PI * 0.2f; - if (feather->life < feather->timer) { - feather->type = 0; + if (effect->life < effect->timer) { + effect->type = 0; } } } } } -void EnNiw_FeatherDraw(EnNiw* this, GlobalContext* globalCtx) { - u8 flag = 0; +void EnNiw_DrawEffects(EnNiw* this, GlobalContext* globalCtx) { + u8 materialFlag = 0; s16 i; s32 pad; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - EnNiwFeather* feather = &this->feathers[0]; + EnNiwEffect* effect = &this->effects[0]; OPEN_DISPS(gfxCtx, "../z_en_niw.c", 1897); func_80093D84(globalCtx->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(this->feathers); i++, feather++) { - if (feather->type == 1) { - if (!flag) { - gSPDisplayList(POLY_XLU_DISP++, gCuccoParticleAppearDL); - flag++; + for (i = 0; i < EN_NIW_EFFECT_COUNT; i++, effect++) { + if (effect->type == 1) { + if (materialFlag == 0) { + gSPDisplayList(POLY_XLU_DISP++, gCuccoEffectFeatherMaterialDL); + materialFlag++; } - Matrix_Translate(feather->pos.x, feather->pos.y, feather->pos.z, MTXMODE_NEW); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&globalCtx->billboardMtxF); - Matrix_Scale(feather->scale, feather->scale, 1.0f, MTXMODE_APPLY); - Matrix_RotateZ(feather->unk_30, MTXMODE_APPLY); + Matrix_Scale(effect->scale, effect->scale, 1.0f, MTXMODE_APPLY); + Matrix_RotateZ(effect->unk_30, MTXMODE_APPLY); Matrix_Translate(0.0f, -1000.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_niw.c", 1913), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gCuccoParticleAliveDL); + gSPDisplayList(POLY_XLU_DISP++, gCuccoEffectFeatherModelDL); } } diff --git a/src/overlays/actors/ovl_En_Niw/z_en_niw.h b/src/overlays/actors/ovl_En_Niw/z_en_niw.h index d027324968..87707c0c06 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.h +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.h @@ -18,7 +18,9 @@ typedef struct { /* 0x002C */ f32 scale; /* 0x0030 */ f32 unk_30; /* 0x0034 */ u8 timer; -} EnNiwFeather; // size = 0x0038 +} EnNiwEffect; // size = 0x0038 + +#define EN_NIW_EFFECT_COUNT 20 typedef struct EnNiw { /* 0x0000 */ Actor actor; @@ -73,7 +75,7 @@ typedef struct EnNiw { /* 0x0304 */ f32 unk_304; /* 0x0308 */ u8 unk_308; /* 0x030C */ ColliderCylinder collider; - /* 0x0358 */ EnNiwFeather feathers[20]; + /* 0x0358 */ EnNiwEffect effects[EN_NIW_EFFECT_COUNT]; } EnNiw; // size = 0x07B8 #endif 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 d71da67f69..001c5e3eb3 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 @@ -16,15 +16,15 @@ void EnSyatekiNiw_Update(Actor* thisx, GlobalContext* globalCtx); void EnSyatekiNiw_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80B11DEC(EnSyatekiNiw* this, GlobalContext* globalCtx); -void func_80B132A8(EnSyatekiNiw* this, GlobalContext* globalCtx); +void EnSyatekiNiw_UpdateEffects(EnSyatekiNiw* this, GlobalContext* globalCtx); void func_80B129EC(EnSyatekiNiw* this, GlobalContext* globalCtx); -void func_80B13464(EnSyatekiNiw* this, GlobalContext* globalCtx); +void EnSyatekiNiw_DrawEffects(EnSyatekiNiw* this, GlobalContext* globalCtx); void func_80B123A8(EnSyatekiNiw* this, GlobalContext* globalCtx); void func_80B11E78(EnSyatekiNiw* this, GlobalContext* globalCtx); void func_80B12460(EnSyatekiNiw* this, GlobalContext* globalCtx); void func_80B128D8(EnSyatekiNiw* this, GlobalContext* globalCtx); -void func_80B131B8(EnSyatekiNiw* this, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, f32 arg4); +void EnSyatekiNiw_SpawnFeather(EnSyatekiNiw* this, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, f32 arg4); const ActorInit En_Syateki_Niw_InitVars = { ACTOR_EN_SYATEKI_NIW, @@ -583,7 +583,7 @@ void EnSyatekiNiw_Update(Actor* thisx, GlobalContext* globalCtx) { if (1) {} if (1) {} - func_80B132A8(this, globalCtx); + EnSyatekiNiw_UpdateEffects(this, globalCtx); this->unk_28C++; if (this->unk_254 != 0) { this->unk_254--; @@ -632,7 +632,7 @@ void EnSyatekiNiw_Update(Actor* thisx, GlobalContext* globalCtx) { sp6C.z = Rand_CenteredFloat(3.0f); sp60.z = sp60.x = 0.0f; sp60.y = -0.15f; - func_80B131B8(this, &sp78, &sp6C, &sp60, Rand_ZeroFloat(8.0f) + 8.0f); + EnSyatekiNiw_SpawnFeather(this, &sp78, &sp6C, &sp60, Rand_ZeroFloat(8.0f) + 8.0f); } this->unk_2A0 = 0; @@ -706,85 +706,85 @@ void EnSyatekiNiw_Draw(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, SyatekiNiw_OverrideLimbDraw, NULL, this); func_80026608(globalCtx); - func_80B13464(this, globalCtx); + EnSyatekiNiw_DrawEffects(this, globalCtx); } } -void func_80B131B8(EnSyatekiNiw* this, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, f32 arg4) { +void EnSyatekiNiw_SpawnFeather(EnSyatekiNiw* this, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, f32 arg4) { s16 i; - EnSyatekiNiw_1* ptr = &this->unk_348[0]; + EnSyatekiNiwEffect* effect = &this->effects[0]; - for (i = 0; i < 5; i++, ptr++) { - if (ptr->unk_00 == 0) { - ptr->unk_00 = 1; - ptr->unk_04 = *arg1; - ptr->unk_10 = *arg2; - ptr->unk_1C = *arg3; - ptr->unk_34 = 0; - ptr->unk_2C = (arg4 / 1000.0f); - ptr->unk_28 = (s16)Rand_ZeroFloat(20.0f) + 0x28; - ptr->unk_2A = Rand_ZeroFloat(1000.0f); + 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); return; } } } -void func_80B132A8(EnSyatekiNiw* this, GlobalContext* globalCtx) { +void EnSyatekiNiw_UpdateEffects(EnSyatekiNiw* this, GlobalContext* globalCtx) { s16 i; - EnSyatekiNiw_1* ptr = &this->unk_348[0]; + EnSyatekiNiwEffect* effect = &this->effects[0]; - for (i = 0; i < 5; i++, ptr++) { - if (ptr->unk_00 != 0) { - ptr->unk_04.x += ptr->unk_10.x; - ptr->unk_04.y += ptr->unk_10.y; - ptr->unk_04.z += ptr->unk_10.z; - ptr->unk_34++; - ptr->unk_10.x += ptr->unk_1C.x; - ptr->unk_10.y += ptr->unk_1C.y; - ptr->unk_10.z += ptr->unk_1C.z; - if (ptr->unk_00 == 1) { - ptr->unk_2A++; - Math_ApproachF(&ptr->unk_10.x, 0.0f, 1.0f, 0.05f); - Math_ApproachF(&ptr->unk_10.z, 0.0f, 1.0f, 0.05f); - if (ptr->unk_10.y < -0.5f) { - ptr->unk_10.y = 0.5f; + 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; } - ptr->unk_30 = (Math_SinS(ptr->unk_2A * 3000) * M_PI) * 0.2f; - if (ptr->unk_28 < ptr->unk_34) { - ptr->unk_00 = 0; + effect->unk_30 = (Math_SinS(effect->unk_2A * 3000) * M_PI) * 0.2f; + if (effect->unk_28 < effect->unk_34) { + effect->unk_00 = 0; } } } } } -void func_80B13464(EnSyatekiNiw* this, GlobalContext* globalCtx) { +void EnSyatekiNiw_DrawEffects(EnSyatekiNiw* this, GlobalContext* globalCtx) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; s16 i; - EnSyatekiNiw_1* ptr = &this->unk_348[0]; - u8 flag = 0; + EnSyatekiNiwEffect* effect = &this->effects[0]; + u8 materialFlag = 0; OPEN_DISPS(gfxCtx, "../z_en_syateki_niw.c", 1234); func_80093D84(globalCtx->state.gfxCtx); - for (i = 0; i < 5; i++, ptr++) { - if (ptr->unk_00 == 1) { - if (flag == 0) { - gSPDisplayList(POLY_XLU_DISP++, gCuccoParticleAppearDL); - flag++; + for (i = 0; i < EN_SYATEKI_NIW_EFFECT_COUNT; i++, effect++) { + if (effect->unk_00 == 1) { + if (materialFlag == 0) { + gSPDisplayList(POLY_XLU_DISP++, gCuccoEffectFeatherMaterialDL); + materialFlag++; } - Matrix_Translate(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); + Matrix_Translate(effect->unk_04.x, effect->unk_04.y, effect->unk_04.z, MTXMODE_NEW); Matrix_ReplaceRotation(&globalCtx->billboardMtxF); - Matrix_Scale(ptr->unk_2C, ptr->unk_2C, 1.0f, MTXMODE_APPLY); - Matrix_RotateZ(ptr->unk_30, MTXMODE_APPLY); + Matrix_Scale(effect->unk_2C, effect->unk_2C, 1.0f, MTXMODE_APPLY); + Matrix_RotateZ(effect->unk_30, 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), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gCuccoParticleAliveDL); + gSPDisplayList(POLY_XLU_DISP++, gCuccoEffectFeatherModelDL); } } 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 6a6398a6f1..829d67fa25 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 @@ -18,7 +18,9 @@ typedef struct { /* 0x2C */ f32 unk_2C; /* 0x30 */ f32 unk_30; /* 0x34 */ u8 unk_34; -} EnSyatekiNiw_1; // size = 0x38 +} EnSyatekiNiwEffect; // size = 0x38 + +#define EN_SYATEKI_NIW_EFFECT_COUNT 5 typedef struct EnSyatekiNiw { /* 0x0000 */ Actor actor; @@ -65,7 +67,7 @@ typedef struct EnSyatekiNiw { /* 0x02F4 */ f32 unk_2F4; /* 0x02F8 */ u8 unk_2F8; /* 0x02FC */ ColliderCylinder collider; - /* 0x0348 */ EnSyatekiNiw_1 unk_348[5]; + /* 0x0348 */ EnSyatekiNiwEffect effects[EN_SYATEKI_NIW_EFFECT_COUNT]; } EnSyatekiNiw; // size = 0x0460 #endif diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.c b/src/overlays/actors/ovl_En_Zo/z_en_zo.c index 321a02799b..6ddc08a011 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.c +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.c @@ -28,13 +28,13 @@ void EnZo_Surface(EnZo* this, GlobalContext* globalCtx); void EnZo_TreadWater(EnZo* this, GlobalContext* globalCtx); void EnZo_Dive(EnZo* this, GlobalContext* globalCtx); -void EnZo_Ripple(EnZo* this, Vec3f* pos, f32 scale, f32 targetScale, u8 alpha) { +void EnZo_SpawnRipple(EnZo* this, Vec3f* pos, f32 scale, f32 targetScale, u8 alpha) { EnZoEffect* effect; Vec3f vec = { 0.0f, 0.0f, 0.0f }; s16 i; effect = this->effects; - for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + for (i = 0; i < EN_ZO_EFFECT_COUNT; i++) { if (effect->type == ENZO_EFFECT_NONE) { effect->type = ENZO_EFFECT_RIPPLE; effect->pos = *pos; @@ -47,7 +47,7 @@ void EnZo_Ripple(EnZo* this, Vec3f* pos, f32 scale, f32 targetScale, u8 alpha) { } } -void EnZo_Bubble(EnZo* this, Vec3f* pos) { +void EnZo_SpawnBubble(EnZo* this, Vec3f* pos) { EnZoEffect* effect; Vec3f vec = { 0.0f, 0.0f, 0.0f }; Vec3f vel = { 0.0f, 1.0f, 0.0f }; @@ -55,7 +55,7 @@ void EnZo_Bubble(EnZo* this, Vec3f* pos) { f32 waterSurface; effect = this->effects; - for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + for (i = 0; i < EN_ZO_EFFECT_COUNT; i++) { if (1) {} if (effect->type == ENZO_EFFECT_NONE) { waterSurface = this->actor.world.pos.y + this->actor.yDistToWater; @@ -72,13 +72,13 @@ void EnZo_Bubble(EnZo* this, Vec3f* pos) { } } -void EnZo_Splash(EnZo* this, Vec3f* pos, Vec3f* vel, f32 scale) { +void EnZo_SpawnSplash(EnZo* this, Vec3f* pos, Vec3f* vel, f32 scale) { EnZoEffect* effect; Vec3f accel = { 0.0f, -1.0f, 0.0f }; s16 i; effect = this->effects; - for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + for (i = 0; i < EN_ZO_EFFECT_COUNT; i++) { if (1) {} if (effect->type != ENZO_EFFECT_SPLASH) { effect->type = ENZO_EFFECT_SPLASH; @@ -93,11 +93,11 @@ void EnZo_Splash(EnZo* this, Vec3f* pos, Vec3f* vel, f32 scale) { } } -void EnZo_UpdateRipples(EnZo* this) { +void EnZo_UpdateEffectsRipples(EnZo* this) { EnZoEffect* effect = this->effects; s16 i; - for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + for (i = 0; i < EN_ZO_EFFECT_COUNT; i++) { if (effect->type == ENZO_EFFECT_RIPPLE) { Math_ApproachF(&effect->scale, effect->targetScale, 0.2f, 0.8f); if (effect->color.a > 20) { @@ -114,13 +114,13 @@ void EnZo_UpdateRipples(EnZo* this) { } } -void EnZo_UpdateBubbles(EnZo* this) { +void EnZo_UpdateEffectsBubbles(EnZo* this) { EnZoEffect* effect; f32 waterSurface; s16 i; effect = this->effects; - for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + for (i = 0; i < EN_ZO_EFFECT_COUNT; i++) { if (effect->type == ENZO_EFFECT_BUBBLE) { effect->pos.x = ((Rand_ZeroOne() * 0.5f) - 0.25f) + effect->vec.x; effect->pos.z = ((Rand_ZeroOne() * 0.5f) - 0.25f) + effect->vec.z; @@ -131,20 +131,20 @@ void EnZo_UpdateBubbles(EnZo* this) { if (waterSurface <= effect->pos.y) { effect->type = ENZO_EFFECT_NONE; effect->pos.y = waterSurface; - EnZo_Ripple(this, &effect->pos, 0.06f, 0.12f, 200); + EnZo_SpawnRipple(this, &effect->pos, 0.06f, 0.12f, 200); } } effect++; } } -void EnZo_UpdateSplashes(EnZo* this) { +void EnZo_UpdateEffectsSplashes(EnZo* this) { EnZoEffect* effect; f32 waterSurface; s16 i; effect = this->effects; - for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + for (i = 0; i < EN_ZO_EFFECT_COUNT; i++) { if (effect->type == ENZO_EFFECT_SPLASH) { effect->pos.x += effect->vel.x; effect->pos.y += effect->vel.y; @@ -162,30 +162,30 @@ void EnZo_UpdateSplashes(EnZo* this) { if (effect->pos.y < waterSurface) { effect->type = ENZO_EFFECT_NONE; effect->pos.y = waterSurface; - EnZo_Ripple(this, &effect->pos, 0.06f, 0.12f, 200); + EnZo_SpawnRipple(this, &effect->pos, 0.06f, 0.12f, 200); } } effect++; } } -void EnZo_DrawRipples(EnZo* this, GlobalContext* globalCtx) { +void EnZo_DrawEffectsRipples(EnZo* this, GlobalContext* globalCtx) { EnZoEffect* effect; s16 i; - u8 setup; + u8 materialFlag; effect = this->effects; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_zo_eff.c", 217); - setup = false; + materialFlag = false; func_80093D84(globalCtx->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + for (i = 0; i < EN_ZO_EFFECT_COUNT; i++) { if (effect->type == ENZO_EFFECT_RIPPLE) { - if (!setup) { + if (!materialFlag) { if (1) {} gDPPipeSync(POLY_XLU_DISP++); gSPDisplayList(POLY_XLU_DISP++, gZoraRipplesMaterialDL); gDPSetEnvColor(POLY_XLU_DISP++, 155, 155, 155, 0); - setup = true; + materialFlag = true; } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, effect->color.a); @@ -200,24 +200,24 @@ void EnZo_DrawRipples(EnZo* this, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_zo_eff.c", 248); } -void EnZo_DrawBubbles(EnZo* this, GlobalContext* globalCtx) { +void EnZo_DrawEffectsBubbles(EnZo* this, GlobalContext* globalCtx) { EnZoEffect* effect = this->effects; s16 i; - u8 setup; + u8 materialFlag; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_zo_eff.c", 260); - setup = false; + materialFlag = false; func_80093D84(globalCtx->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + for (i = 0; i < EN_ZO_EFFECT_COUNT; i++) { if (effect->type == ENZO_EFFECT_BUBBLE) { - if (!setup) { + if (!materialFlag) { if (1) {} gSPDisplayList(POLY_XLU_DISP++, gZoraBubblesMaterialDL); gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 150, 150, 150, 0); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); - setup = true; + materialFlag = true; } Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); @@ -233,23 +233,23 @@ void EnZo_DrawBubbles(EnZo* this, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_zo_eff.c", 286); } -void EnZo_DrawSplashes(EnZo* this, GlobalContext* globalCtx) { +void EnZo_DrawEffectsSplashes(EnZo* this, GlobalContext* globalCtx) { EnZoEffect* effect; s16 i; - u8 setup; + u8 materialFlag; effect = this->effects; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_zo_eff.c", 298); - setup = false; + materialFlag = false; func_80093D84(globalCtx->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + for (i = 0; i < EN_ZO_EFFECT_COUNT; i++) { if (effect->type == ENZO_EFFECT_SPLASH) { - if (!setup) { + if (!materialFlag) { if (1) {} gSPDisplayList(POLY_XLU_DISP++, gZoraSplashesMaterialDL); gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 200, 0); - setup = true; + materialFlag = true; } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 180, 180, 180, effect->color.a); @@ -272,7 +272,7 @@ void EnZo_TreadWaterRipples(EnZo* this, f32 scale, f32 targetScale, u8 alpha) { pos.x = this->actor.world.pos.x; pos.y = this->actor.world.pos.y + this->actor.yDistToWater; pos.z = this->actor.world.pos.z; - EnZo_Ripple(this, &pos, scale, targetScale, alpha); + EnZo_SpawnRipple(this, &pos, scale, targetScale, alpha); } static ColliderCylinderInit sCylinderInit = { @@ -350,7 +350,7 @@ void EnZo_SpawnSplashes(EnZo* this) { pos.x += vel.x * 6.0f; pos.z += vel.z * 6.0f; pos.y += this->actor.yDistToWater; - EnZo_Splash(this, &pos, &vel, 0.08f); + EnZo_SpawnSplash(this, &pos, &vel, 0.08f); } } @@ -737,7 +737,7 @@ void EnZo_Update(Actor* thisx, GlobalContext* globalCtx) { pos.y += (Rand_ZeroOne() - 0.5f) * 10.0f + 18.0f; pos.x += (Rand_ZeroOne() - 0.5f) * 28.0f; pos.z += (Rand_ZeroOne() - 0.5f) * 28.0f; - EnZo_Bubble(this, &pos); + EnZo_SpawnBubble(this, &pos); } if ((s32)this->alpha != 0) { @@ -745,9 +745,9 @@ void EnZo_Update(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } - EnZo_UpdateRipples(this); - EnZo_UpdateBubbles(this); - EnZo_UpdateSplashes(this); + EnZo_UpdateEffectsRipples(this); + EnZo_UpdateEffectsBubbles(this); + EnZo_UpdateEffectsSplashes(this); } s32 EnZo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, @@ -791,9 +791,9 @@ void EnZo_Draw(Actor* thisx, GlobalContext* globalCtx) { void* eyeTextures[] = { gZoraEyeOpenTex, gZoraEyeHalfTex, gZoraEyeClosedTex }; Matrix_Push(); - EnZo_DrawRipples(this, globalCtx); - EnZo_DrawBubbles(this, globalCtx); - EnZo_DrawSplashes(this, globalCtx); + EnZo_DrawEffectsRipples(this, globalCtx); + EnZo_DrawEffectsBubbles(this, globalCtx); + EnZo_DrawEffectsSplashes(this, globalCtx); Matrix_Pop(); if ((s32)this->alpha != 0) { diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.h b/src/overlays/actors/ovl_En_Zo/z_en_zo.h index ba6eebb30c..87e0d474e8 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.h +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.h @@ -6,6 +6,8 @@ struct EnZo; +#define EN_ZO_EFFECT_COUNT 15 + typedef struct { /* 0x00 */ u8 type; /* 0x04 */ f32 scale; @@ -28,7 +30,7 @@ typedef struct EnZo { /* 0x0208 */ u8 canSpeak; /* 0x020A */ Vec3s jointTable[20]; /* 0x0282 */ Vec3s morphTable[20]; - /* 0x02FC */ EnZoEffect effects[15]; + /* 0x02FC */ EnZoEffect effects[EN_ZO_EFFECT_COUNT]; /* 0x0644 */ f32 dialogRadius; /* 0x0648 */ f32 alpha; /* 0x064C */ s16 unk_64C; diff --git a/src/overlays/actors/ovl_Fishing/z_fishing.c b/src/overlays/actors/ovl_Fishing/z_fishing.c index d28e7eb409..641ac91a46 100644 --- a/src/overlays/actors/ovl_Fishing/z_fishing.c +++ b/src/overlays/actors/ovl_Fishing/z_fishing.c @@ -28,8 +28,6 @@ typedef struct { /* 0x0C */ f32 unk_0C; } FishingFishInit; // size = 0x10 -#define EFFECT_COUNT 130 - typedef enum { /* 0x00 */ FS_EFF_NONE, /* 0x01 */ FS_EFF_RIPPLE, @@ -42,6 +40,8 @@ typedef enum { /* 0x08 */ FS_EFF_RAIN_SPLASH } FishingEffectType; +#define FISHING_EFFECT_COUNT 130 + typedef struct { /* 0x00 */ Vec3f pos; /* 0x0C */ Vec3f vel; @@ -409,7 +409,7 @@ static FishingGroupFish sGroupFishes[GROUP_FISH_COUNT]; static f32 sFishGroupAngle1; static f32 sFishGroupAngle2; static f32 sFishGroupAngle3; -static FishingEffect sFishingEffects[EFFECT_COUNT]; +static FishingEffect sEffects[FISHING_EFFECT_COUNT]; static Vec3f sStreamSoundProjectedPos; void Fishing_SetColliderElement(s32 index, ColliderJntSph* collider, Vec3f* pos, f32 scale) { @@ -579,7 +579,7 @@ void Fishing_SpawnRainDrop(FishingEffect* effect, Vec3f* pos, Vec3f* rot) { effect += 30; - for (i = 30; i < EFFECT_COUNT; i++) { + for (i = 30; i < FISHING_EFFECT_COUNT; i++) { if (effect->type == FS_EFF_NONE) { effect->type = FS_EFF_RAIN_DROP; effect->pos = *pos; @@ -862,7 +862,7 @@ void Fishing_Init(Actor* thisx, GlobalContext* globalCtx2) { } D_80B7A684 = 20; - globalCtx->specialEffects = sFishingEffects; + globalCtx->specialEffects = sEffects; gTimeIncrement = 1; D_80B7E0AC = 0; D_80B7E0A6 = 10; @@ -903,8 +903,8 @@ void Fishing_Init(Actor* thisx, GlobalContext* globalCtx2) { D_80B7E077 = 0; } - for (i = 0; i < EFFECT_COUNT; i++) { - sFishingEffects[i].type = FS_EFF_NONE; + for (i = 0; i < FISHING_EFFECT_COUNT; i++) { + sEffects[i].type = FS_EFF_NONE; } for (i = 0; i < POND_PROP_COUNT; i++) { @@ -1024,7 +1024,7 @@ void Fishing_UpdateEffects(FishingEffect* effect, GlobalContext* globalCtx) { f32 rippleY; s16 i; - for (i = 0; i < EFFECT_COUNT; i++) { + for (i = 0; i < FISHING_EFFECT_COUNT; i++) { if (effect->type) { effect->timer++; effect->pos.x += effect->vel.x; @@ -1167,7 +1167,7 @@ void Fishing_UpdateEffects(FishingEffect* effect, GlobalContext* globalCtx) { } void Fishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { - u8 flag = 0; + u8 materialFlag = 0; f32 rotY; s16 i; s32 pad; @@ -1181,10 +1181,10 @@ void Fishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { for (i = 0; i < 100; i++) { if (effect->type == FS_EFF_RIPPLE) { - if (flag == 0) { + if (materialFlag == 0) { gSPDisplayList(POLY_XLU_DISP++, gFishingRippleMaterialDL); gDPSetEnvColor(POLY_XLU_DISP++, 155, 155, 155, 0); - flag++; + materialFlag++; } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, effect->alpha); @@ -1201,13 +1201,13 @@ void Fishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { } effect = firstEffect; - flag = 0; + materialFlag = 0; for (i = 0; i < 100; i++) { if (effect->type == FS_EFF_DUST_SPLASH) { - if (flag == 0) { + if (materialFlag == 0) { gSPDisplayList(POLY_XLU_DISP++, gFishingDustSplashMaterialDL); gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 200, 0); - flag++; + materialFlag++; } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 180, 180, 180, effect->alpha); @@ -1225,13 +1225,13 @@ void Fishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { } effect = firstEffect; - flag = 0; + materialFlag = 0; for (i = 0; i < 100; i++) { if (effect->type == FS_EFF_WATER_DUST) { - if (flag == 0) { + if (materialFlag == 0) { gSPDisplayList(POLY_OPA_DISP++, gFishingWaterDustMaterialDL); gDPSetEnvColor(POLY_OPA_DISP++, 40, 90, 80, 128); - flag++; + materialFlag++; } gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 40, 90, 80, effect->alpha); @@ -1253,14 +1253,14 @@ void Fishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { } effect = firstEffect; - flag = 0; + materialFlag = 0; for (i = 0; i < 100; i++) { if (effect->type == FS_EFF_BUBBLE) { - if (flag == 0) { + if (materialFlag == 0) { gSPDisplayList(POLY_XLU_DISP++, gFishingBubbleMaterialDL); gDPSetEnvColor(POLY_XLU_DISP++, 150, 150, 150, 0); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); - flag++; + materialFlag++; } Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); @@ -1276,14 +1276,14 @@ void Fishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { } effect = firstEffect + 30; - flag = 0; - for (i = 30; i < EFFECT_COUNT; i++) { + materialFlag = 0; + for (i = 30; i < FISHING_EFFECT_COUNT; i++) { if (effect->type == FS_EFF_RAIN_DROP) { - if (flag == 0) { + if (materialFlag == 0) { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x14); gDPSetCombineMode(POLY_XLU_DISP++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 150, 255, 255, 30); - flag++; + materialFlag++; } Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); @@ -1303,14 +1303,14 @@ void Fishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { func_80093D84(globalCtx->state.gfxCtx); effect = firstEffect + 30; - flag = 0; - for (i = 30; i < EFFECT_COUNT; i++) { + materialFlag = 0; + for (i = 30; i < FISHING_EFFECT_COUNT; i++) { if (effect->type == FS_EFF_RAIN_RIPPLE) { - if (flag == 0) { + if (materialFlag == 0) { gSPDisplayList(POLY_XLU_DISP++, gFishingRippleMaterialDL); gDPSetEnvColor(POLY_XLU_DISP++, 155, 155, 155, 0); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 130); - flag++; + materialFlag++; } Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); @@ -1325,13 +1325,13 @@ void Fishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { } effect = firstEffect + 30; - flag = 0; - for (i = 30; i < EFFECT_COUNT; i++) { + materialFlag = 0; + for (i = 30; i < FISHING_EFFECT_COUNT; i++) { if (effect->type == FS_EFF_RAIN_SPLASH) { - if (flag == 0) { + if (materialFlag == 0) { gSPDisplayList(POLY_XLU_DISP++, gFishingRainSplashMaterialDL); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, KREG(19) + 80); - flag++; + materialFlag++; } if (Rand_ZeroOne() < 0.5f) { @@ -4386,7 +4386,7 @@ void Fishing_UpdatePondProps(GlobalContext* globalCtx) { } void Fishing_DrawPondProps(GlobalContext* globalCtx) { - u8 flag = 0; + u8 materialFlag = 0; FishingProp* prop = &sPondProps[0]; s16 i; s32 pad; @@ -4397,9 +4397,9 @@ void Fishing_DrawPondProps(GlobalContext* globalCtx) { for (i = 0; i < POND_PROP_COUNT; i++) { if (prop->type == FS_PROP_REED) { - if (flag == 0) { + if (materialFlag == 0) { gSPDisplayList(POLY_XLU_DISP++, gFishingReedMaterialDL); - flag++; + materialFlag++; } if (prop->shouldDraw) { @@ -4419,12 +4419,12 @@ void Fishing_DrawPondProps(GlobalContext* globalCtx) { } prop = &sPondProps[0]; - flag = 0; + materialFlag = 0; for (i = 0; i < POND_PROP_COUNT; i++) { if (prop->type == FS_PROP_WOOD_POST) { - if (flag == 0) { + if (materialFlag == 0) { gSPDisplayList(POLY_OPA_DISP++, gFishingWoodPostMaterialDL); - flag++; + materialFlag++; } if (prop->shouldDraw) { @@ -4441,12 +4441,12 @@ void Fishing_DrawPondProps(GlobalContext* globalCtx) { } prop = &sPondProps[0]; - flag = 0; + materialFlag = 0; for (i = 0; i < POND_PROP_COUNT; i++) { if (prop->type == FS_PROP_LILY_PAD) { - if (flag == 0) { + if (materialFlag == 0) { gSPDisplayList(POLY_XLU_DISP++, gFishingLilyPadMaterialDL); - flag++; + materialFlag++; } if (prop->shouldDraw) { @@ -4466,12 +4466,12 @@ void Fishing_DrawPondProps(GlobalContext* globalCtx) { } prop = &sPondProps[0]; - flag = 0; + materialFlag = 0; for (i = 0; i < POND_PROP_COUNT; i++) { if (prop->type == FS_PROP_ROCK) { - if (flag == 0) { + if (materialFlag == 0) { gSPDisplayList(POLY_OPA_DISP++, gFishingRockMaterialDL); - flag++; + materialFlag++; } if (prop->shouldDraw) { @@ -4680,7 +4680,7 @@ void Fishing_UpdateGroupFishes(GlobalContext* globalCtx) { } void Fishing_DrawGroupFishes(GlobalContext* globalCtx) { - u8 flag = 0; + u8 materialFlag = 0; FishingGroupFish* fish = &sGroupFishes[0]; f32 scale; s16 i; @@ -4698,10 +4698,10 @@ void Fishing_DrawGroupFishes(GlobalContext* globalCtx) { for (i = 0; i < GROUP_FISH_COUNT; i++) { if (fish->type != FS_GROUP_FISH_NONE) { - if (flag == 0) { + if (materialFlag == 0) { gSPDisplayList(POLY_OPA_DISP++, gFishingGroupFishMaterialDL); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 155, 155, 155, 255); - flag++; + materialFlag++; } if (fish->shouldDraw) { diff --git a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c index 0397008edc..3e1e5ba43d 100644 --- a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c +++ b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c @@ -229,9 +229,9 @@ void ObjectKankyo_Fairies(ObjectKankyo* this, GlobalContext* globalCtx) { for (i = 0; i < globalCtx->envCtx.unk_EE[3]; i++) { // spawn in front of the camera - dx = globalCtx->view.lookAt.x - globalCtx->view.eye.x; - dy = globalCtx->view.lookAt.y - globalCtx->view.eye.y; - dz = globalCtx->view.lookAt.z - globalCtx->view.eye.z; + dx = globalCtx->view.at.x - globalCtx->view.eye.x; + dy = globalCtx->view.at.y - globalCtx->view.eye.y; + dz = globalCtx->view.at.z - globalCtx->view.eye.z; dist = sqrtf(SQ(dx) + SQ(dy) + SQ(dz)); viewForwards.x = dx / dist; @@ -600,9 +600,9 @@ void ObjectKankyo_DrawSnow(ObjectKankyo* this2, GlobalContext* globalCtx2) { switch (this->effects[i].state) { case 0: // spawn in front of the camera - dx = globalCtx->view.lookAt.x - globalCtx->view.eye.x; - dy = globalCtx->view.lookAt.y - globalCtx->view.eye.y; - dz = globalCtx->view.lookAt.z - globalCtx->view.eye.z; + dx = globalCtx->view.at.x - globalCtx->view.eye.x; + dy = globalCtx->view.at.y - globalCtx->view.eye.y; + dz = globalCtx->view.at.z - globalCtx->view.eye.z; dist = sqrtf(SQ(dx) + SQ(dy) + SQ(dz)); // fake @@ -624,9 +624,9 @@ void ObjectKankyo_DrawSnow(ObjectKankyo* this2, GlobalContext* globalCtx2) { break; case 1: - dx = globalCtx->view.lookAt.x - globalCtx->view.eye.x; - dy = globalCtx->view.lookAt.y - globalCtx->view.eye.y; - dz = globalCtx->view.lookAt.z - globalCtx->view.eye.z; + dx = globalCtx->view.at.x - globalCtx->view.eye.x; + dy = globalCtx->view.at.y - globalCtx->view.eye.y; + dz = globalCtx->view.at.z - globalCtx->view.eye.z; dist = sqrtf(SQ(dx) + SQ(dy) + SQ(dz)); baseX = globalCtx->view.eye.x + dx / dist * 80.0f; diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index 70561ff539..e1f4110c35 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -38,8 +38,8 @@ void FileChoose_SetView(FileChooseContext* this, f32 eyeX, f32 eyeY, f32 eyeZ) { up.y = 1.0f; - func_800AA358(&this->view, &eye, &lookAt, &up); - func_800AAA50(&this->view, 0x7F); + View_LookAt(&this->view, &eye, &lookAt, &up); + View_Apply(&this->view, VIEW_ALL | VIEW_FORCE_VIEWING | VIEW_FORCE_VIEWPORT | VIEW_FORCE_PROJECTION_PERSPECTIVE); } Gfx* FileChoose_QuadTextureIA8(Gfx* gfx, void* texture, s16 width, s16 height, s16 point) { diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index eb3fb25fe6..ba742459f8 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -643,7 +643,7 @@ void Select_DrawMenu(SelectContext* this) { gSPSegment(POLY_OPA_DISP++, 0x00, NULL); func_80095248(gfxCtx, 0, 0, 0); SET_FULLSCREEN_VIEWPORT(&this->view); - func_800AAA50(&this->view, 0xF); + View_Apply(&this->view, VIEW_ALL); func_80094140(gfxCtx); printer = alloca(sizeof(GfxPrint)); @@ -667,7 +667,7 @@ void Select_DrawLoadingScreen(SelectContext* this) { gSPSegment(POLY_OPA_DISP++, 0x00, NULL); func_80095248(gfxCtx, 0, 0, 0); SET_FULLSCREEN_VIEWPORT(&this->view); - func_800AAA50(&this->view, 0xF); + View_Apply(&this->view, VIEW_ALL); func_80094140(gfxCtx); printer = alloca(sizeof(GfxPrint)); @@ -688,7 +688,7 @@ void Select_Draw(SelectContext* this) { gSPSegment(POLY_OPA_DISP++, 0x00, NULL); func_80095248(gfxCtx, 0, 0, 0); SET_FULLSCREEN_VIEWPORT(&this->view); - func_800AAA50(&this->view, 0xF); + View_Apply(&this->view, VIEW_ALL); if (!this->state.running) { Select_DrawLoadingScreen(this); @@ -733,7 +733,7 @@ void Select_Init(GameState* thisx) { this->opt = 0; this->count = ARRAY_COUNT(sScenes); View_Init(&this->view, this->state.gfxCtx); - this->view.flags = (0x08 | 0x02); + this->view.flags = (VIEW_PROJECTION_ORTHO | VIEW_VIEWPORT); this->verticalInputAccumulator = 0; this->verticalInput = 0; this->timerUp = 0; diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index 02ecb3788b..eac084d326 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -49,9 +49,9 @@ void Title_SetupView(TitleContext* this, f32 x, f32 y, f32 z) { lookAt.x = lookAt.y = lookAt.z = 0.0f; up.y = 1.0f; - func_800AA460(view, 30.0f, 10.0f, 12800.0f); - func_800AA358(view, &eye, &lookAt, &up); - func_800AAA50(view, 0xF); + View_SetPerspective(view, 30.0f, 10.0f, 12800.0f); + View_LookAt(view, &eye, &lookAt, &up); + View_Apply(view, VIEW_ALL); } void Title_Draw(TitleContext* this) { diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c index d6fb3164a9..089c3a015d 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c @@ -1428,8 +1428,8 @@ void KaleidoScope_SetView(PauseContext* pauseCtx, f32 x, f32 y, f32 z) { up.x = up.z = 0.0f; up.y = 1.0f; - func_800AA358(&pauseCtx->view, &eye, &lookAt, &up); - func_800AAA50(&pauseCtx->view, 127); + View_LookAt(&pauseCtx->view, &eye, &lookAt, &up); + View_Apply(&pauseCtx->view, VIEW_ALL | VIEW_FORCE_VIEWING | VIEW_FORCE_VIEWPORT | VIEW_FORCE_PROJECTION_PERSPECTIVE); } static u8 D_8082AE48[][4] = {