diff --git a/Makefile b/Makefile index 5cefd6257a..4b1260b47a 100644 --- a/Makefile +++ b/Makefile @@ -133,7 +133,7 @@ OBJCOPY := $(MIPS_BINUTILS_PREFIX)objcopy OBJDUMP := $(MIPS_BINUTILS_PREFIX)objdump NM := $(MIPS_BINUTILS_PREFIX)nm -N64_EMULATOR ?= +N64_EMULATOR ?= INC := -Iinclude -Iinclude/libc -Isrc -I$(BUILD_DIR) -I. -I$(EXTRACTED_DIR) @@ -243,7 +243,7 @@ $(BUILD_DIR)/src/boot/stackcheck.o: OPTFLAGS := -O2 $(BUILD_DIR)/src/code/__osMalloc.o: OPTFLAGS := -O2 $(BUILD_DIR)/src/code/code_800FC620.o: OPTFLAGS := -O2 -$(BUILD_DIR)/src/code/code_800FCE80.o: OPTFLAGS := -O2 +$(BUILD_DIR)/src/code/fp_math.o: OPTFLAGS := -O2 $(BUILD_DIR)/src/code/rand.o: OPTFLAGS := -O2 $(BUILD_DIR)/src/code/gfxprint.o: OPTFLAGS := -O2 $(BUILD_DIR)/src/code/jpegutils.o: OPTFLAGS := -O2 diff --git a/include/fp_math.h b/include/fp_math.h new file mode 100644 index 0000000000..26f9b171b7 --- /dev/null +++ b/include/fp_math.h @@ -0,0 +1,17 @@ +#ifndef FP_MATH_H +#define FP_MATH_H + +#include "ultra64.h" + +f32 Math_FTanF(f32 angle); +f32 Math_FFloorF(f32 x); +f32 Math_FCeilF(f32 x); +f32 Math_FRoundF(f32 x); +f32 Math_FNearbyIntF(f32 x); +f32 Math_FTruncF(f32 x); +f32 Math_FAtanF(f32 x); +f32 Math_FAtan2F(f32 y, f32 x); +f32 Math_FAsinF(f32 x); +f32 Math_FAcosF(f32 x); + +#endif diff --git a/include/functions.h b/include/functions.h index 35b378a7a8..54b57c8ea5 100644 --- a/include/functions.h +++ b/include/functions.h @@ -4,23 +4,6 @@ #include "z64.h" #include "macros.h" -f32 fabsf(f32 f); -#ifdef __sgi -#pragma intrinsic(fabsf) -#else -#define fabsf(f) __builtin_fabsf((f32)(f)) -#endif - -f32 sqrtf(f32 f); -#ifdef __sgi -#pragma intrinsic(sqrtf) -#endif - -f64 sqrt(f64 f); -#ifdef __sgi -#pragma intrinsic(sqrt) -#endif - void cleararena(void); void bootproc(void); void Main_ThreadEntry(void* arg); @@ -839,41 +822,6 @@ s32 Environment_IsForcedSequenceDisabled(void); void Environment_PlayStormNatureAmbience(PlayState* play); void Environment_StopStormNatureAmbience(PlayState* play); void Environment_WarpSongLeave(PlayState* play); -void Lib_MemSet(u8* dest, size_t len, u8 val); -f32 Math_CosS(s16 angle); -f32 Math_SinS(s16 angle); -s32 Math_ScaledStepToS(s16* pValue, s16 target, s16 step); -s32 Math_StepToS(s16* pValue, s16 target, s16 step); -s32 Math_StepToF(f32* pValue, f32 target, f32 step); -s32 Math_StepUntilAngleS(s16* pValue, s16 limit, s16 step); -s32 Math_StepUntilS(s16* pValue, s16 limit, s16 step); -s32 Math_StepToAngleS(s16* pValue, s16 target, s16 step); -s32 Math_StepUntilF(f32* pValue, f32 limit, f32 step); -s32 Math_AsymStepToF(f32* pValue, f32 target, f32 incrStep, f32 decrStep); -void Lib_GetControlStickData(f32* outMagnitude, s16* outAngle, Input* input); -s16 Rand_S16Offset(s16 base, s16 range); -void Math_Vec3f_Copy(Vec3f* dest, Vec3f* src); -void Math_Vec3s_ToVec3f(Vec3f* dest, Vec3s* src); -void Math_Vec3f_Sum(Vec3f* a, Vec3f* b, Vec3f* dest); -void Math_Vec3f_Diff(Vec3f* a, Vec3f* b, Vec3f* dest); -void Math_Vec3s_DiffToVec3f(Vec3f* dest, Vec3s* a, Vec3s* b); -void Math_Vec3f_Scale(Vec3f* vec, f32 scaleF); -f32 Math_Vec3f_DistXYZ(Vec3f* a, Vec3f* b); -f32 Math_Vec3f_DistXYZAndStoreDiff(Vec3f* a, Vec3f* b, Vec3f* dest); -f32 Math_Vec3f_DistXZ(Vec3f* a, Vec3f* b); -s16 Math_Vec3f_Yaw(Vec3f* origin, Vec3f* point); -s16 Math_Vec3f_Pitch(Vec3f* a, Vec3f* b); -void Actor_ProcessInitChain(Actor* actor, InitChainEntry* ichain); -f32 Math_SmoothStepToF(f32* pValue, f32 target, f32 fraction, f32 step, f32 minStep); -void Math_ApproachF(f32* pValue, f32 target, f32 fraction, f32 step); -void Math_ApproachZeroF(f32* pValue, f32 fraction, f32 step); -f32 Math_SmoothStepToDegF(f32* pValue, f32 target, f32 fraction, f32 step, f32 minStep); -s16 Math_SmoothStepToS(s16* pValue, s16 target, s16 scale, s16 step, s16 minStep); -void Math_ApproachS(s16* pValue, s16 target, s16 scale, s16 step); -void Color_RGBA8_Copy(Color_RGBA8* dst, Color_RGBA8* src); -void Sfx_PlaySfxCentered(u16 sfxId); -void Sfx_PlaySfxCentered2(u16 sfxId); -void Sfx_PlaySfxAtPos(Vec3f* projectedPos, u16 sfxId); void Health_InitMeter(PlayState* play); void Health_UpdateMeter(PlayState* play); void Health_DrawMeter(PlayState* play); @@ -1346,80 +1294,9 @@ void Main(void* arg); void SysCfb_Init(s32 n64dd); void* SysCfb_GetFbPtr(s32 idx); void* SysCfb_GetFbEnd(void); -f32 Math_FactorialF(f32 n); -f32 Math_Factorial(s32 n); -f32 Math_PowF(f32 base, s32 exp); -f32 Math_SinF(f32 angle); -f32 Math_CosF(f32 angle); -s32 Math3D_PlaneVsLineSegClosestPoint(f32 planeAA, f32 planeAB, f32 planeAC, f32 planeADist, f32 planeBA, f32 planeBB, - f32 planeBC, f32 planeBDist, Vec3f* linePointA, Vec3f* linePointB, - Vec3f* closestPoint); -void Math3D_LineClosestToPoint(InfiniteLine* line, Vec3f* pos, Vec3f* closestPoint); -s32 Math3D_PlaneVsPlaneVsLineClosestPoint(f32 planeAA, f32 planeAB, f32 planeAC, f32 planeADist, f32 planeBA, - f32 planeBB, f32 planeBC, f32 planeBDist, Vec3f* point, Vec3f* closestPoint); -void Math3D_LineSplitRatio(Vec3f* v0, Vec3f* v1, f32 ratio, Vec3f* ret); -f32 Math3D_Cos(Vec3f* a, Vec3f* b); -s32 Math3D_CosOut(Vec3f* a, Vec3f* b, f32* dst); -void Math3D_Vec3fReflect(Vec3f* vec, Vec3f* normal, Vec3f* reflVec); -s32 Math3D_PointInSquare2D(f32 upperLeftX, f32 lowerRightX, f32 upperLeftY, f32 lowerRightY, f32 x, f32 y); -f32 Math3D_Dist1DSq(f32 a, f32 b); -f32 Math3D_Dist2DSq(f32 x0, f32 y0, f32 x1, f32 y1); -f32 Math3D_Vec3fMagnitudeSq(Vec3f* vec); -f32 Math3D_Vec3fMagnitude(Vec3f* vec); -f32 Math3D_Vec3fDistSq(Vec3f* a, Vec3f* b); -void Math3D_Vec3f_Cross(Vec3f* a, Vec3f* b, Vec3f* ret); -void Math3D_SurfaceNorm(Vec3f* va, Vec3f* vb, Vec3f* vc, Vec3f* normal); -f32 Math3D_Vec3f_DistXYZ(Vec3f* a, Vec3f* b); -s32 Math3D_PointRelativeToCubeFaces(Vec3f* point, Vec3f* min, Vec3f* max); -s32 Math3D_PointRelativeToCubeEdges(Vec3f* point, Vec3f* min, Vec3f* max); -s32 Math3D_PointRelativeToCubeVertices(Vec3f* point, Vec3f* min, Vec3f* max); -s32 Math3D_LineVsCube(Vec3f* min, Vec3f* max, Vec3f* a, Vec3f* b); -void Math3D_RotateXZPlane(Vec3f* pointOnPlane, s16 angle, f32* a, f32* c, f32* d); -void Math3D_DefPlane(Vec3f* va, Vec3f* vb, Vec3f* vc, f32* nx, f32* ny, f32* nz, f32* originDist); -f32 Math3D_UDistPlaneToPos(f32 nx, f32 ny, f32 nz, f32 originDist, Vec3f* p); -f32 Math3D_DistPlaneToPos(f32 nx, f32 ny, f32 nz, f32 originDist, Vec3f* p); -s32 Math3D_TriChkPointParaYSlopedY(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 z, f32 x); -s32 Math3D_TriChkPointParaYIntersectDist(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 z, - f32 x, f32* yIntersect, f32 chkDist); -s32 Math3D_TriChkPointParaYIntersectInsideTri(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, - f32 z, f32 x, f32* yIntersect, f32 chkDist); -s32 Math3D_TriChkLineSegParaYIntersect(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 z, - f32 x, f32* yIntersect, f32 y0, f32 y1); -s32 Math3D_TriChkPointParaYDist(Vec3f* v0, Vec3f* v1, Vec3f* v2, Plane* plane, f32 z, f32 x, f32 chkDist); -s32 Math3D_TriChkPointParaXIntersect(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 y, - f32 z, f32* xIntersect); -s32 Math3D_TriChkLineSegParaXIntersect(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 y, - f32 z, f32* xIntersect, f32 x0, f32 x1); -s32 Math3D_TriChkPointParaXDist(Vec3f* v0, Vec3f* v1, Vec3f* v2, Plane* plane, f32 y, f32 z, f32 chkDist); -s32 Math3D_TriChkPointParaZIntersect(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 x, - f32 y, f32* zIntersect); -s32 Math3D_TriChkLineSegParaZIntersect(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 x, - f32 y, f32* zIntersect, f32 z0, f32 z1); -s32 Math3D_TriChkLineSegParaZDist(Vec3f* v0, Vec3f* v1, Vec3f* v2, Plane* plane, f32 x, f32 y, f32 chkDist); -s32 Math3D_LineSegVsPlane(f32 nx, f32 ny, f32 nz, f32 originDist, Vec3f* linePointA, Vec3f* linePointB, - Vec3f* intersect, s32 fromFront); -void Math3D_TriNorm(TriNorm* tri, Vec3f* va, Vec3f* vb, Vec3f* vc); -s32 Math3D_PointDistSqToLine2D(f32 x0, f32 y0, f32 x1, f32 y1, f32 x2, f32 y2, f32* lineLenSq); -s32 Math3D_LineVsSph(Sphere16* sphere, Linef* line); -s32 Math3D_TriVsSphIntersect(Sphere16* sphere, TriNorm* tri, Vec3f* intersectPoint); -s32 Math3D_CylVsLineSeg(Cylinder16* cyl, Vec3f* linePointA, Vec3f* linePointB, Vec3f* intersectA, Vec3f* intersectB); -s32 Math3D_CylVsTri(Cylinder16* cyl, TriNorm* tri); -s32 Math3D_CylTriVsIntersect(Cylinder16* cyl, TriNorm* tri, Vec3f* intersect); -s32 Math3D_SphVsSph(Sphere16* sphereA, Sphere16* sphereB); -s32 Math3D_SphVsSphOverlap(Sphere16* sphereA, Sphere16* sphereB, f32* overlapSize); -s32 Math3D_SphVsSphOverlapCenterDist(Sphere16* sphereA, Sphere16* sphereB, f32* overlapSize, f32* centerDist); -s32 Math3D_SphVsCylOverlap(Sphere16* sph, Cylinder16* cyl, f32* overlapSize); -s32 Math3D_SphVsCylOverlapCenterDist(Sphere16* sph, Cylinder16* cyl, f32* overlapSize, f32* centerDist); -s32 Math3D_CylVsCylOverlap(Cylinder16* ca, Cylinder16* cb, f32* overlapSize); -s32 Math3D_CylVsCylOverlapCenterDist(Cylinder16* ca, Cylinder16* cb, f32* overlapSize, f32* centerDist); -s32 Math3D_TriVsTriIntersect(TriNorm* ta, TriNorm* tb, Vec3f* intersect); -s32 Math3D_XZInSphere(Sphere16* sphere, f32 x, f32 z); -s32 Math3D_XYInSphere(Sphere16* sphere, f32 x, f32 y); -s32 Math3D_YZInSphere(Sphere16* sphere, f32 y, f32 z); + void Math3D_DrawSphere(PlayState* play, Sphere16* sph); void Math3D_DrawCylinder(PlayState* play, Cylinder16* cyl); -s16 Math_Atan2S(f32 x, f32 y); -f32 Math_Atan2F(f32 x, f32 y); void Matrix_Init(GameState* gameState); void Matrix_Push(void); void Matrix_Pop(void); @@ -1681,24 +1558,7 @@ void Audio_Init(void); void Audio_InitSound(void); void func_800F7170(void); void func_800F71BC(s32 arg0); -void Audio_SetSfxBanksMute(u16 muteMask); -void Audio_QueueSeqCmdMute(u8 channelIndex); -void Audio_ClearBGMMute(u8 channelIndex); -void Audio_PlaySfxGeneral(u16 sfxId, Vec3f* pos, u8 token, f32* freqScale, f32* vol, s8* reverbAdd); -void Audio_ProcessSfxRequest(void); -void Audio_ChooseActiveSfx(u8 bankId); -void Audio_PlayActiveSfx(u8 bankId); -void Audio_StopSfxByBank(u8 bankId); -void func_800F8884(u8 bankId, Vec3f* pos); -void Audio_StopSfxByPosAndBank(u8 bankId, Vec3f* pos); -void Audio_StopSfxByPos(Vec3f* pos); -void Audio_StopSfxByPosAndId(Vec3f* pos, u16 sfxId); -void Audio_StopSfxByTokenAndId(u8 token, u16 sfxId); -void Audio_StopSfxById(u32 sfxId); -void Audio_ProcessSfxRequests(void); -void func_800F8F88(void); -u8 Audio_IsSfxPlaying(u32 sfxId); -void Audio_ResetSfx(void); + void Audio_StartSequence(u8 seqPlayerIndex, u8 seqId, u8 seqArgs, u16 fadeInDuration); void Audio_StopSequence(u8 seqPlayerIndex, u16 fadeOutDuration); void Audio_QueueSeqCmd(u32 cmd); @@ -1748,20 +1608,7 @@ s8 PadUtils_GetRelX(Input* input); s8 PadUtils_GetRelY(Input* input); void PadUtils_UpdateRelXY(Input* input); s32 PadSetup_Init(OSMesgQueue* mq, u8* outMask, OSContStatus* status); -f32 Math_FTanF(f32 angle); -f32 Math_FFloorF(f32 x); -f32 Math_FCeilF(f32 x); -f32 Math_FRoundF(f32 x); -f32 Math_FNearbyIntF(f32 x); -f32 Math_FTruncF(f32 x); -f32 Math_FAtanF(f32 x); -f32 Math_FAtan2F(f32 y, f32 x); -f32 Math_FAsinF(f32 x); -f32 Math_FAcosF(f32 x); -f32 ceilf(f32 x); -f32 truncf(f32 x); -f32 roundf(f32 x); -f32 nearbyintf(f32 x); + void* SystemArena_Malloc(u32 size); void* SystemArena_MallocR(u32 size); void* SystemArena_Realloc(void* ptr, u32 newSize); @@ -1779,14 +1626,7 @@ void* SystemArena_ReallocDebug(void* ptr, u32 newSize, const char* file, int lin void SystemArena_FreeDebug(void* ptr, const char* file, int line); void SystemArena_Display(void); #endif -u32 Rand_Next(void); -void Rand_Seed(u32 seed); -f32 Rand_ZeroOne(void); -f32 Rand_Centered(void); -void Rand_Seed_Variable(u32* rndNum, u32 seed); -u32 Rand_Next_Variable(u32* rndNum); -f32 Rand_ZeroOne_Variable(u32* rndNum); -f32 Rand_Centered_Variable(u32* rndNum); + void __osMallocInit(Arena* arena, void* start, u32 size); void __osMallocAddBlock(Arena* arena, void* start, s32 size); void __osMallocCleanup(Arena* arena); @@ -1825,8 +1665,6 @@ s32 JpegDecoder_ParseNextSymbol(JpegHuffmanTable* hTable, s16* outCoeff, s8* out u16 JpegDecoder_ReadBits(u8 len); s32 osPfsFreeBlocks(OSPfs* pfs, s32* leftoverBytes); void guScale(Mtx* m, f32 x, f32 y, f32 z); -f32 sinf(f32 angle); -s16 sins(u16 angle); OSTask* _VirtualToPhysicalTask(OSTask* intp); void osSpTaskLoad(OSTask* intp); void osSpTaskStartGo(OSTask* tp); @@ -1890,8 +1728,6 @@ s32 osPfsDeleteFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* s32 __osPfsReleasePages(OSPfs* pfs, __OSInode* inode, u8 initialPage, u8 bank, __OSInodeUnit* finalPage); void guOrthoF(f32[4][4], f32, f32, f32, f32, f32, f32, f32); void guOrtho(Mtx*, f32, f32, f32, f32, f32, f32, f32); -f32 cosf(f32 angle); -s16 coss(u16 angle); void osViSetEvent(OSMesgQueue* mq, OSMesg msg, u32 retraceCount); s32 osPfsIsPlug(OSMesgQueue* mq, u8* pattern); void __osPfsRequestData(u8 cmd); diff --git a/include/ichain.h b/include/ichain.h index 07bd073133..8334237801 100644 --- a/include/ichain.h +++ b/include/ichain.h @@ -1,7 +1,9 @@ #ifndef ICHAIN_H #define ICHAIN_H -#include "libc/stddef.h" +#include "ultra64.h" + +struct Actor; typedef struct { u32 cont: 1; @@ -55,4 +57,6 @@ typedef enum { #define ICHAIN_CONTINUE 1 #define ICHAIN_STOP 0 +void Actor_ProcessInitChain(struct Actor* actor, InitChainEntry* ichain); + #endif diff --git a/include/libc/math.h b/include/libc/math.h index 831be6de7e..d8031ee1a6 100644 --- a/include/libc/math.h +++ b/include/libc/math.h @@ -34,6 +34,23 @@ double round(double); long lroundf(float); long lround(double); +f32 fabsf(f32 f); +#ifdef __sgi +#pragma intrinsic(fabsf) +#else +#define fabsf(f) __builtin_fabsf((f32)(f)) +#endif + +f32 sqrtf(f32 f); +#ifdef __sgi +#pragma intrinsic(sqrtf) +#endif + +f64 sqrt(f64 f); +#ifdef __sgi +#pragma intrinsic(sqrt) +#endif + extern float qNaN0x3FFFFF; extern float qNaN0x10000; extern float sNaN0x3FFFFF; diff --git a/include/macros.h b/include/macros.h index 97627d9b4c..6315fbe94c 100644 --- a/include/macros.h +++ b/include/macros.h @@ -14,7 +14,6 @@ #define VIRTUAL_TO_PHYSICAL(addr) (uintptr_t)((u8*)(addr) - 0x80000000) #define SEGMENTED_TO_VIRTUAL(addr) PHYSICAL_TO_VIRTUAL(gSegments[SEGMENT_NUMBER(addr)] + SEGMENT_OFFSET(addr)) -#define SQ(x) ((x)*(x)) #define ABS(x) ((x) >= 0 ? (x) : -(x)) #define DECR(x) ((x) == 0 ? 0 : --(x)) #define CLAMP(x, min, max) ((x) < (min) ? (min) : (x) > (max) ? (max) : (x)) diff --git a/include/rand.h b/include/rand.h new file mode 100644 index 0000000000..508c9d6466 --- /dev/null +++ b/include/rand.h @@ -0,0 +1,15 @@ +#ifndef RAND_H +#define RAND_H + +#include "ultra64.h" + +u32 Rand_Next(void); +void Rand_Seed(u32 seed); +f32 Rand_ZeroOne(void); +f32 Rand_Centered(void); +void Rand_Seed_Variable(u32* rndNum, u32 seed); +u32 Rand_Next_Variable(u32* rndNum); +f32 Rand_ZeroOne_Variable(u32* rndNum); +f32 Rand_Centered_Variable(u32* rndNum); + +#endif diff --git a/include/regs.h b/include/regs.h index 36c36c4190..4a11f7a557 100644 --- a/include/regs.h +++ b/include/regs.h @@ -353,4 +353,15 @@ typedef enum { #define R_VI_CUR_ADDI_SCAN_LINES HREG(83) #define R_VI_CUR_Y_SCALE_MODE HREG(84) +typedef struct { + /* 0x00 */ s32 regPage; // 0: no page selected (reg editor is not active); 1: first page; `REG_PAGES`: last page + /* 0x04 */ s32 regGroup; // Indexed from 0 to `REG_GROUPS`-1. Each group has its own character to identify it. + /* 0x08 */ s32 regCur; // Selected reg, indexed from 0 as the page start + /* 0x0C */ s32 dPadInputPrev; + /* 0x10 */ s32 inputRepeatTimer; + /* 0x14 */ s16 data[REG_GROUPS * REGS_PER_GROUP]; // Accessed through *REG macros, see regs.h +} RegEditor; // size = 0x15D4 + +extern RegEditor* gRegEditor; + #endif diff --git a/include/sfx.h b/include/sfx.h index d5545af8d6..a8ea68dee5 100644 --- a/include/sfx.h +++ b/include/sfx.h @@ -125,4 +125,27 @@ typedef struct { #define SFX_DIST_SCALING 10.0f #endif +void Audio_SetSfxBanksMute(u16 muteMask); +void Audio_QueueSeqCmdMute(u8 channelIndex); +void Audio_ClearBGMMute(u8 channelIndex); +void Audio_PlaySfxGeneral(u16 sfxId, Vec3f* pos, u8 token, f32* freqScale, f32* vol, s8* reverbAdd); +void Audio_ProcessSfxRequest(void); +void Audio_ChooseActiveSfx(u8 bankId); +void Audio_PlayActiveSfx(u8 bankId); +void Audio_StopSfxByBank(u8 bankId); +void func_800F8884(u8 bankId, Vec3f* pos); +void Audio_StopSfxByPosAndBank(u8 bankId, Vec3f* pos); +void Audio_StopSfxByPos(Vec3f* pos); +void Audio_StopSfxByPosAndId(Vec3f* pos, u16 sfxId); +void Audio_StopSfxByTokenAndId(u8 token, u16 sfxId); +void Audio_StopSfxById(u32 sfxId); +void Audio_ProcessSfxRequests(void); +void func_800F8F88(void); +u8 Audio_IsSfxPlaying(u32 sfxId); +void Audio_ResetSfx(void); + +extern Vec3f gSfxDefaultPos; +extern f32 gSfxDefaultFreqAndVolScale; +extern s8 gSfxDefaultReverb; + #endif diff --git a/include/sys_math.h b/include/sys_math.h new file mode 100644 index 0000000000..0da5df8902 --- /dev/null +++ b/include/sys_math.h @@ -0,0 +1,14 @@ +#ifndef SYS_MATH_H +#define SYS_MATH_H + +#include "ultra64.h" + +f32 Math_FactorialF(f32 n); +f32 Math_Factorial(s32 n); +f32 Math_PowF(f32 base, s32 exp); +f32 Math_SinF(f32 angle); +f32 Math_CosF(f32 angle); +s16 Math_Atan2S(f32 x, f32 y); +f32 Math_Atan2F(f32 x, f32 y); + +#endif diff --git a/include/sys_math3d.h b/include/sys_math3d.h new file mode 100644 index 0000000000..b01063a9f0 --- /dev/null +++ b/include/sys_math3d.h @@ -0,0 +1,73 @@ +#ifndef SYS_MATH3D_H +#define SYS_MATH3D_H + +#include "ultra64.h" +#include "z64math.h" + +s32 Math3D_PlaneVsLineSegClosestPoint(f32 planeAA, f32 planeAB, f32 planeAC, f32 planeADist, f32 planeBA, f32 planeBB, + f32 planeBC, f32 planeBDist, Vec3f* linePointA, Vec3f* linePointB, + Vec3f* closestPoint); +void Math3D_LineClosestToPoint(InfiniteLine* line, Vec3f* pos, Vec3f* closestPoint); +s32 Math3D_PlaneVsPlaneVsLineClosestPoint(f32 planeAA, f32 planeAB, f32 planeAC, f32 planeADist, f32 planeBA, + f32 planeBB, f32 planeBC, f32 planeBDist, Vec3f* point, Vec3f* closestPoint); +void Math3D_LineSplitRatio(Vec3f* v0, Vec3f* v1, f32 ratio, Vec3f* ret); +f32 Math3D_Cos(Vec3f* a, Vec3f* b); +s32 Math3D_CosOut(Vec3f* a, Vec3f* b, f32* dst); +void Math3D_Vec3fReflect(Vec3f* vec, Vec3f* normal, Vec3f* reflVec); +s32 Math3D_PointInSquare2D(f32 upperLeftX, f32 lowerRightX, f32 upperLeftY, f32 lowerRightY, f32 x, f32 y); +f32 Math3D_Dist1DSq(f32 a, f32 b); +f32 Math3D_Dist2DSq(f32 x0, f32 y0, f32 x1, f32 y1); +f32 Math3D_Vec3fMagnitudeSq(Vec3f* vec); +f32 Math3D_Vec3fMagnitude(Vec3f* vec); +f32 Math3D_Vec3fDistSq(Vec3f* a, Vec3f* b); +void Math3D_Vec3f_Cross(Vec3f* a, Vec3f* b, Vec3f* ret); +void Math3D_SurfaceNorm(Vec3f* va, Vec3f* vb, Vec3f* vc, Vec3f* normal); +f32 Math3D_Vec3f_DistXYZ(Vec3f* a, Vec3f* b); +s32 Math3D_PointRelativeToCubeFaces(Vec3f* point, Vec3f* min, Vec3f* max); +s32 Math3D_PointRelativeToCubeEdges(Vec3f* point, Vec3f* min, Vec3f* max); +s32 Math3D_PointRelativeToCubeVertices(Vec3f* point, Vec3f* min, Vec3f* max); +s32 Math3D_LineVsCube(Vec3f* min, Vec3f* max, Vec3f* a, Vec3f* b); +void Math3D_RotateXZPlane(Vec3f* pointOnPlane, s16 angle, f32* a, f32* c, f32* d); +void Math3D_DefPlane(Vec3f* va, Vec3f* vb, Vec3f* vc, f32* nx, f32* ny, f32* nz, f32* originDist); +f32 Math3D_UDistPlaneToPos(f32 nx, f32 ny, f32 nz, f32 originDist, Vec3f* p); +f32 Math3D_DistPlaneToPos(f32 nx, f32 ny, f32 nz, f32 originDist, Vec3f* p); +s32 Math3D_TriChkPointParaYSlopedY(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 z, f32 x); +s32 Math3D_TriChkPointParaYIntersectDist(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 z, + f32 x, f32* yIntersect, f32 chkDist); +s32 Math3D_TriChkPointParaYIntersectInsideTri(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, + f32 z, f32 x, f32* yIntersect, f32 chkDist); +s32 Math3D_TriChkLineSegParaYIntersect(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 z, + f32 x, f32* yIntersect, f32 y0, f32 y1); +s32 Math3D_TriChkPointParaYDist(Vec3f* v0, Vec3f* v1, Vec3f* v2, Plane* plane, f32 z, f32 x, f32 chkDist); +s32 Math3D_TriChkPointParaXIntersect(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 y, + f32 z, f32* xIntersect); +s32 Math3D_TriChkLineSegParaXIntersect(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 y, + f32 z, f32* xIntersect, f32 x0, f32 x1); +s32 Math3D_TriChkPointParaXDist(Vec3f* v0, Vec3f* v1, Vec3f* v2, Plane* plane, f32 y, f32 z, f32 chkDist); +s32 Math3D_TriChkPointParaZIntersect(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 x, + f32 y, f32* zIntersect); +s32 Math3D_TriChkLineSegParaZIntersect(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 x, + f32 y, f32* zIntersect, f32 z0, f32 z1); +s32 Math3D_TriChkLineSegParaZDist(Vec3f* v0, Vec3f* v1, Vec3f* v2, Plane* plane, f32 x, f32 y, f32 chkDist); +s32 Math3D_LineSegVsPlane(f32 nx, f32 ny, f32 nz, f32 originDist, Vec3f* linePointA, Vec3f* linePointB, + Vec3f* intersect, s32 fromFront); +void Math3D_TriNorm(TriNorm* tri, Vec3f* va, Vec3f* vb, Vec3f* vc); +s32 Math3D_PointDistSqToLine2D(f32 x0, f32 y0, f32 x1, f32 y1, f32 x2, f32 y2, f32* lineLenSq); +s32 Math3D_LineVsSph(Sphere16* sphere, Linef* line); +s32 Math3D_TriVsSphIntersect(Sphere16* sphere, TriNorm* tri, Vec3f* intersectPoint); +s32 Math3D_CylVsLineSeg(Cylinder16* cyl, Vec3f* linePointA, Vec3f* linePointB, Vec3f* intersectA, Vec3f* intersectB); +s32 Math3D_CylVsTri(Cylinder16* cyl, TriNorm* tri); +s32 Math3D_CylTriVsIntersect(Cylinder16* cyl, TriNorm* tri, Vec3f* intersect); +s32 Math3D_SphVsSph(Sphere16* sphereA, Sphere16* sphereB); +s32 Math3D_SphVsSphOverlap(Sphere16* sphereA, Sphere16* sphereB, f32* overlapSize); +s32 Math3D_SphVsSphOverlapCenterDist(Sphere16* sphereA, Sphere16* sphereB, f32* overlapSize, f32* centerDist); +s32 Math3D_SphVsCylOverlap(Sphere16* sph, Cylinder16* cyl, f32* overlapSize); +s32 Math3D_SphVsCylOverlapCenterDist(Sphere16* sph, Cylinder16* cyl, f32* overlapSize, f32* centerDist); +s32 Math3D_CylVsCylOverlap(Cylinder16* ca, Cylinder16* cb, f32* overlapSize); +s32 Math3D_CylVsCylOverlapCenterDist(Cylinder16* ca, Cylinder16* cb, f32* overlapSize, f32* centerDist); +s32 Math3D_TriVsTriIntersect(TriNorm* ta, TriNorm* tb, Vec3f* intersect); +s32 Math3D_XZInSphere(Sphere16* sphere, f32 x, f32 z); +s32 Math3D_XYInSphere(Sphere16* sphere, f32 x, f32 y); +s32 Math3D_YZInSphere(Sphere16* sphere, f32 y, f32 z); + +#endif diff --git a/include/ultra64/gu.h b/include/ultra64/gu.h index 429d12352e..7e2a50d725 100644 --- a/include/ultra64/gu.h +++ b/include/ultra64/gu.h @@ -21,6 +21,12 @@ typedef union { f32 f; } fu; +f32 sinf(f32 angle); +s16 sins(u16 angle); + +f32 cosf(f32 angle); +s16 coss(u16 angle); + extern f32 __libm_qnan_f; #endif diff --git a/include/variables.h b/include/variables.h index a67d99246b..0b3b260bf2 100644 --- a/include/variables.h +++ b/include/variables.h @@ -172,7 +172,6 @@ extern u8 gSequenceTable[]; extern u8 gSampleBankTable[]; extern SaveContext gSaveContext; -extern RegEditor* gRegEditor; extern u8 gUseCutsceneCam; extern u16 D_8015FCCC; diff --git a/include/z64.h b/include/z64.h index 85ba06e8a7..2a556d3f9f 100644 --- a/include/z64.h +++ b/include/z64.h @@ -44,6 +44,7 @@ #include "sfx.h" #include "color.h" #include "gfxprint.h" +#include "z_lib.h" #include "ichain.h" #include "regs.h" #include "irqmgr.h" @@ -58,6 +59,10 @@ #include "gfx.h" #include "jpeg.h" #include "prerender.h" +#include "rand.h" +#include "sys_math.h" +#include "sys_math3d.h" +#include "fp_math.h" #define SCREEN_WIDTH 320 #define SCREEN_HEIGHT 240 @@ -99,15 +104,6 @@ // NOTE: Once we start supporting other builds, this can be changed with an ifdef #define REGION_NATIVE REGION_EU -typedef struct { - /* 0x00 */ s32 regPage; // 0: no page selected (reg editor is not active); 1: first page; `REG_PAGES`: last page - /* 0x04 */ s32 regGroup; // Indexed from 0 to `REG_GROUPS`-1. Each group has its own character to identify it. - /* 0x08 */ s32 regCur; // Selected reg, indexed from 0 as the page start - /* 0x0C */ s32 dPadInputPrev; - /* 0x10 */ s32 inputRepeatTimer; - /* 0x14 */ s16 data[REG_GROUPS * REGS_PER_GROUP]; // Accessed through *REG macros, see regs.h -} RegEditor; // size = 0x15D4 - typedef struct { /* 0x00 */ u8 seqId; /* 0x01 */ u8 natureAmbienceId; diff --git a/include/z64camera.h b/include/z64camera.h index 81584c1b68..e3696b4fbb 100644 --- a/include/z64camera.h +++ b/include/z64camera.h @@ -6,10 +6,6 @@ #include "z64math.h" #include "z64save.h" -// these two angle conversion macros are slightly inaccurate -#define CAM_DEG_TO_BINANG(degrees) (s16)TRUNCF_BINANG((degrees) * 182.04167f + .5f) -#define CAM_BINANG_TO_DEG(binang) ((f32)(binang) * (360.0001525f / 65535.0f)) - #define CAM_STAT_CUT 0 #define CAM_STAT_WAIT 1 #define CAM_STAT_UNK3 3 diff --git a/include/z64math.h b/include/z64math.h index 6661a8dc22..16ba1a2039 100644 --- a/include/z64math.h +++ b/include/z64math.h @@ -2,7 +2,9 @@ #define Z64MATH_H #include "ultra64.h" +#include "math.h" +#define SQ(x) ((x)*(x)) #define VEC_SET(V,X,Y,Z) (V).x=(X);(V).y=(Y);(V).z=(Z) typedef struct { @@ -116,6 +118,11 @@ typedef VecSphGeo VecGeo; #define BINANG_TO_RAD_ALT(binang) (((f32)(binang) / (f32)0x8000) * M_PI) #define BINANG_TO_RAD_ALT2(binang) (((f32)(binang) * M_PI) / 0x8000) +// Angle conversion macros (Camera) +// these two angle conversion macros are slightly inaccurate +#define CAM_DEG_TO_BINANG(degrees) (s16)TRUNCF_BINANG((degrees) * 182.04167f + .5f) +#define CAM_BINANG_TO_DEG(binang) ((f32)(binang) * (360.0001525f / 65535.0f)) + // Vector macros #define SQXZ(vec) ((vec).x * (vec).x + (vec).z * (vec).z) #define DOTXZ(vec1, vec2) ((vec1).x * (vec2).x + (vec1).z * (vec2).z) diff --git a/include/z_lib.h b/include/z_lib.h new file mode 100644 index 0000000000..34581da982 --- /dev/null +++ b/include/z_lib.h @@ -0,0 +1,44 @@ +#ifndef Z_LIB_H +#define Z_LIB_H + +#include "libc/stddef.h" +#include "padmgr.h" +#include "z64math.h" +#include "color.h" + +void Lib_MemSet(u8* dest, size_t len, u8 val); +f32 Math_CosS(s16 angle); +f32 Math_SinS(s16 angle); +s32 Math_ScaledStepToS(s16* pValue, s16 target, s16 step); +s32 Math_StepToS(s16* pValue, s16 target, s16 step); +s32 Math_StepToF(f32* pValue, f32 target, f32 step); +s32 Math_StepUntilAngleS(s16* pValue, s16 limit, s16 step); +s32 Math_StepUntilS(s16* pValue, s16 limit, s16 step); +s32 Math_StepToAngleS(s16* pValue, s16 target, s16 step); +s32 Math_StepUntilF(f32* pValue, f32 limit, f32 step); +s32 Math_AsymStepToF(f32* pValue, f32 target, f32 incrStep, f32 decrStep); +void Lib_GetControlStickData(f32* outMagnitude, s16* outAngle, Input* input); +s16 Rand_S16Offset(s16 base, s16 range); +void Math_Vec3f_Copy(Vec3f* dest, Vec3f* src); +void Math_Vec3s_ToVec3f(Vec3f* dest, Vec3s* src); +void Math_Vec3f_Sum(Vec3f* a, Vec3f* b, Vec3f* dest); +void Math_Vec3f_Diff(Vec3f* a, Vec3f* b, Vec3f* dest); +void Math_Vec3s_DiffToVec3f(Vec3f* dest, Vec3s* a, Vec3s* b); +void Math_Vec3f_Scale(Vec3f* vec, f32 scaleF); +f32 Math_Vec3f_DistXYZ(Vec3f* a, Vec3f* b); +f32 Math_Vec3f_DistXYZAndStoreDiff(Vec3f* a, Vec3f* b, Vec3f* dest); +f32 Math_Vec3f_DistXZ(Vec3f* a, Vec3f* b); +s16 Math_Vec3f_Yaw(Vec3f* origin, Vec3f* point); +s16 Math_Vec3f_Pitch(Vec3f* a, Vec3f* b); +f32 Math_SmoothStepToF(f32* pValue, f32 target, f32 fraction, f32 step, f32 minStep); +void Math_ApproachF(f32* pValue, f32 target, f32 fraction, f32 step); +void Math_ApproachZeroF(f32* pValue, f32 fraction, f32 step); +f32 Math_SmoothStepToDegF(f32* pValue, f32 target, f32 fraction, f32 step, f32 minStep); +s16 Math_SmoothStepToS(s16* pValue, s16 target, s16 scale, s16 step, s16 minStep); +void Math_ApproachS(s16* pValue, s16 target, s16 scale, s16 step); +void Color_RGBA8_Copy(Color_RGBA8* dst, Color_RGBA8* src); +void Sfx_PlaySfxCentered(u16 sfxId); +void Sfx_PlaySfxCentered2(u16 sfxId); +void Sfx_PlaySfxAtPos(Vec3f* projectedPos, u16 sfxId); + +#endif diff --git a/spec b/spec index 53841452dd..9cc1b8d59b 100644 --- a/spec +++ b/spec @@ -437,6 +437,9 @@ beginseg include "$(BUILD_DIR)/src/code/sys_cfb.o" include "$(BUILD_DIR)/src/code/sys_math.o" include "$(BUILD_DIR)/src/code/sys_math3d.o" +#if OOT_DEBUG + include "$(BUILD_DIR)/src/code/sys_math3d_draw.o" +#endif include "$(BUILD_DIR)/src/code/sys_math_atan.o" include "$(BUILD_DIR)/src/code/sys_matrix.o" include "$(BUILD_DIR)/src/code/sys_ucode.o" @@ -484,7 +487,7 @@ beginseg include "$(BUILD_DIR)/src/code/code_800FC620.o" include "$(BUILD_DIR)/src/code/padutils.o" include "$(BUILD_DIR)/src/code/padsetup.o" - include "$(BUILD_DIR)/src/code/code_800FCE80.o" + include "$(BUILD_DIR)/src/code/fp_math.o" include "$(BUILD_DIR)/src/code/fp.o" include "$(BUILD_DIR)/src/code/system_malloc.o" include "$(BUILD_DIR)/src/code/rand.o" diff --git a/src/code/code_80069420.c b/src/code/code_80069420.c index 6dd0a94f42..9a190edcf3 100644 --- a/src/code/code_80069420.c +++ b/src/code/code_80069420.c @@ -1,4 +1,4 @@ -#include "global.h" +#include "ultra64.h" /** * memcpy: copies `len` bytes from memory starting at `src` to memory starting at `dest`. Expects the memory diff --git a/src/code/fault.c b/src/code/fault.c index 662c1a9f1a..7d8e62fef1 100644 --- a/src/code/fault.c +++ b/src/code/fault.c @@ -48,9 +48,9 @@ // just above (the exact upper bound depends on the block numbers assigned to // extern variables declared in headers). #if OOT_DEBUG -#pragma increment_block_number 20 +#pragma increment_block_number 0 #else -#pragma increment_block_number 25 +#pragma increment_block_number 20 #endif void FaultDrawer_Init(void); diff --git a/src/code/fmodf.c b/src/code/fmodf.c index e1e3862231..4ebec43bdc 100644 --- a/src/code/fmodf.c +++ b/src/code/fmodf.c @@ -1,4 +1,4 @@ -#include "global.h" +#include "ultra64.h" /** * Computes one `x` modulo `y` for floats. diff --git a/src/code/code_800FCE80.c b/src/code/fp_math.c similarity index 98% rename from src/code/code_800FCE80.c rename to src/code/fp_math.c index 8ac46833d9..c429b83e23 100644 --- a/src/code/code_800FCE80.c +++ b/src/code/fp_math.c @@ -1,4 +1,5 @@ -#include "global.h" +#include "z64math.h" +#include "macros.h" s32 gUseAtanContFrac; diff --git a/src/code/rand.c b/src/code/rand.c index 4a0c5dc4a3..baf3965421 100644 --- a/src/code/rand.c +++ b/src/code/rand.c @@ -41,7 +41,7 @@ * * @note Original name: qrand.c */ -#include "ultra64.h" +#include "rand.h" #define RAND_MULTIPLIER 1664525 #define RAND_INCREMENT 1013904223 diff --git a/src/code/sys_math.c b/src/code/sys_math.c index f19719bb95..6a7344baad 100644 --- a/src/code/sys_math.c +++ b/src/code/sys_math.c @@ -1,4 +1,4 @@ -#include "global.h" +#include "sys_math.h" f32 sFactorialTbl[] = { 1.0f, 1.0f, 2.0f, 6.0f, 24.0f, 120.0f, 720.0f, 5040.0f, 40320.0f, 362880.0f, 3628800.0f, 39916800.0f, 479001600.0f }; diff --git a/src/code/sys_math3d.c b/src/code/sys_math3d.c index 6525f825da..f0bfb60bc6 100644 --- a/src/code/sys_math3d.c +++ b/src/code/sys_math3d.c @@ -1,9 +1,13 @@ -#include "global.h" +#include "ultra64.h" +#include "z_lib.h" +#include "z64math.h" #include "terminal.h" +#include "macros.h" +#include "sys_math3d.h" // For retail BSS ordering, the block number of cbf in Math3D_CylVsCylOverlapCenterDist // must be 0. -#pragma increment_block_number 187 +#pragma increment_block_number 114 s32 Math3D_LineVsLineClosestTwoPoints(Vec3f* lineAPointA, Vec3f* lineAPointB, Vec3f* lineBPointA, Vec3f* lineBPointB, Vec3f* lineAClosestToB, Vec3f* lineBClosestToA); @@ -2147,11 +2151,3 @@ s32 Math3D_YZInSphere(Sphere16* sphere, f32 y, f32 z) { } return false; } - -#if OOT_DEBUG -void Math3D_DrawSphere(PlayState* play, Sphere16* sph) { -} - -void Math3D_DrawCylinder(PlayState* play, Cylinder16* cyl) { -} -#endif diff --git a/src/code/sys_math3d_draw.c b/src/code/sys_math3d_draw.c new file mode 100644 index 0000000000..76651c825e --- /dev/null +++ b/src/code/sys_math3d_draw.c @@ -0,0 +1,7 @@ +#include "z64.h" + +void Math3D_DrawSphere(PlayState* play, Sphere16* sph) { +} + +void Math3D_DrawCylinder(PlayState* play, Cylinder16* cyl) { +} diff --git a/src/code/sys_math_atan.c b/src/code/sys_math_atan.c index efbe8a2055..0647745b06 100644 --- a/src/code/sys_math_atan.c +++ b/src/code/sys_math_atan.c @@ -1,4 +1,5 @@ -#include "global.h" +#include "z64math.h" +#include "macros.h" static u16 sAtan2Tbl[] = { 0x0000, 0x000A, 0x0014, 0x001F, 0x0029, 0x0033, 0x003D, 0x0047, 0x0051, 0x005C, 0x0066, 0x0070, 0x007A, 0x0084, diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c index 118a445d7b..bebcac08d7 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.c @@ -2360,9 +2360,6 @@ void CollisionCheck_ATTrisVsACTris(PlayState* play, CollisionCheckContext* colCh #if OOT_DEBUG static s8 sBssDummy7; -static s8 sBssDummy8; -static s8 sBssDummy9; -static s8 sBssDummy10; #endif void CollisionCheck_ATTrisVsACQuad(PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol, @@ -3329,12 +3326,10 @@ void Collider_SetTrisDim(PlayState* play, ColliderTris* tris, s32 elemIndex, Col } #if OOT_DEBUG -// Due to an unknown reason, bss ordering changed between the 2 static Vec3f variables in the function below. -// In order to reproduce this behavior, we need a specific number of bss variables in the file before that point. -// For this, we introduce a certain amount of dummy variables throughout the file, which we fit inside padding added -// by the compiler between structs like TriNorm and/or Vec3f, so they don't take space in bss. -static s8 sBssDummy11; -static s8 sBssDummy12; +// The two static Vec3f variables in the function below cross a block index rollover, causing a bss order swap. +//! In order to replicate this behavior, we declare a certain amount of sBssDummy variables throughout the file, which +//! we fit inside padding added by the compiler between structs like TriNorm and/or Vec3f, so they don't take space in +//! bss. #endif /** diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index ce79a7df93..aab4069048 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -215,7 +215,7 @@ s16 sSunDepthTestY; // These variables could be moved farther down in the file to reduce the amount // of block number padding here, but currently this causes BSS ordering issues // for debug. -#pragma increment_block_number 230 +#pragma increment_block_number 227 LightNode* sNGameOverLightNode; LightInfo sNGameOverLightInfo; diff --git a/src/code/z_lib.c b/src/code/z_lib.c index 58a2911622..5eba9346f5 100644 --- a/src/code/z_lib.c +++ b/src/code/z_lib.c @@ -1,4 +1,11 @@ -#include "global.h" +#include "ultra64.h" +#include "z_lib.h" +#include "ichain.h" +#include "regs.h" +#include "macros.h" +#include "sys_math.h" +#include "rand.h" +#include "sfx.h" /** * memset: sets `len` bytes to `val` starting at address `dest`. @@ -334,7 +341,7 @@ void (*sInitChainHandlers[])(u8* ptr, InitChainEntry* ichain) = { IChain_Apply_Vec3f, IChain_Apply_Vec3fdiv1000, IChain_Apply_Vec3s, }; -void Actor_ProcessInitChain(Actor* actor, InitChainEntry* ichain) { +void Actor_ProcessInitChain(struct Actor* actor, InitChainEntry* ichain) { do { sInitChainHandlers[ichain->type]((u8*)actor, ichain); } while ((ichain++)->cont); diff --git a/src/code/z_olib.c b/src/code/z_olib.c index d5056e8f70..c1f93a0522 100644 --- a/src/code/z_olib.c +++ b/src/code/z_olib.c @@ -1,4 +1,6 @@ -#include "global.h" +#include "z64math.h" +#include "fp_math.h" +#include "z_lib.h" /** * Calculates the distances between `a` and `b` diff --git a/src/libultra/gu/coss.c b/src/libultra/gu/coss.c index 0eb8b5e65d..6a52bd1d40 100644 --- a/src/libultra/gu/coss.c +++ b/src/libultra/gu/coss.c @@ -1,4 +1,4 @@ -#include "global.h" +#include "ultra64.h" /** * @param angle binang diff --git a/src/overlays/actors/ovl_Fishing/z_fishing.c b/src/overlays/actors/ovl_Fishing/z_fishing.c index bee978e5bc..76daff7a0e 100644 --- a/src/overlays/actors/ovl_Fishing/z_fishing.c +++ b/src/overlays/actors/ovl_Fishing/z_fishing.c @@ -11,7 +11,7 @@ #include "terminal.h" // For retail BSS ordering, the block number of sStreamSfxProjectedPos must be 0. -#pragma increment_block_number 198 +#pragma increment_block_number 193 #define FLAGS ACTOR_FLAG_4