diff options
| author | Anghelo Carvajal <angheloalf95@gmail.com> | 2023-11-22 23:55:05 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-23 13:55:05 +1100 |
| commit | 506e2155474b1914fe93f070c55debdeaf6df0a6 (patch) | |
| tree | 5ffab32ee39bb1cafc8803caafd1030ff72f93ef /include | |
| parent | 5ef277df2db5dd54c02c098ec88777f63680f6c3 (diff) | |
Yet another header cleanup (#1508)
* lights.c
* z64skin_matrix.h
* Move out some stuff from macros.h
* gamealloc.h
* move most transition functions to z64transition.h
* z64lib.h
* `include` cleanup on transition files
* z_overlay cleanup
* z64malloc.h
* format
* forgot to remove those
* forgot this
* fix borken includes
Diffstat (limited to 'include')
| -rw-r--r-- | include/functions.h | 117 | ||||
| -rw-r--r-- | include/gamealloc.h | 24 | ||||
| -rw-r--r-- | include/gfx.h | 21 | ||||
| -rw-r--r-- | include/ichain.h | 2 | ||||
| -rw-r--r-- | include/macros.h | 20 | ||||
| -rw-r--r-- | include/main.h | 2 | ||||
| -rw-r--r-- | include/variables.h | 4 | ||||
| -rw-r--r-- | include/z64.h | 4 | ||||
| -rw-r--r-- | include/z64curve.h | 3 | ||||
| -rw-r--r-- | include/z64game.h | 16 | ||||
| -rw-r--r-- | include/z64lib.h | 29 | ||||
| -rw-r--r-- | include/z64light.h | 32 | ||||
| -rw-r--r-- | include/z64malloc.h | 17 | ||||
| -rw-r--r-- | include/z64math.h | 1 | ||||
| -rw-r--r-- | include/z64save.h | 4 | ||||
| -rw-r--r-- | include/z64skin.h | 11 | ||||
| -rw-r--r-- | include/z64skin_matrix.h | 34 | ||||
| -rw-r--r-- | include/z64speed_meter.h | 2 | ||||
| -rw-r--r-- | include/z64transition.h | 76 |
19 files changed, 238 insertions, 181 deletions
diff --git a/include/functions.h b/include/functions.h index 50e7687c3..8a63226ed 100644 --- a/include/functions.h +++ b/include/functions.h @@ -489,7 +489,6 @@ s32 Actor_TrackNone(Vec3s* headRot, Vec3s* torsoRot); s32 Actor_TrackPoint(Actor* actor, Vec3f* target, Vec3s* headRot, Vec3s* torsoRot); s32 Actor_TrackPlayerSetFocusHeight(PlayState* play, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, f32 focusHeight); s32 Actor_TrackPlayer(PlayState* play, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, Vec3f focusPos); -void SaveContext_Init(void); void GetItem_Draw(PlayState* play, s16 drawId); @@ -505,21 +504,6 @@ void Font_LoadCharNES(PlayState* play, u8 codePointIndex, s32 offset); void Font_LoadMessageBoxEndIcon(Font* font, u16 icon); void Font_LoadOrderedFont(Font* font); -void* Lib_MemCpy(void* dest, void* src, size_t size); -void* Lib_MemSet(void* buffer, s32 value, size_t size); -void Lib_GetControlStickData(f32* outMagnitude, s16* outAngle, Input* input); -void Actor_ProcessInitChain(Actor* actor, InitChainEntry* ichain); -void Color_RGBA8_Copy(Color_RGBA8* dst, Color_RGBA8* src); -void Lib_PlaySfx(u16 sfxId); -void Lib_PlaySfx_2(u16 sfxId); -void Lib_PlaySfx_AtPos(Vec3f* pos, u16 sfxId); -void Lib_Vec3f_TranslateAndRotateY(Vec3f* translation, s16 rotAngle, Vec3f* src, Vec3f* dst); -void Color_RGB8_Lerp(Color_RGB8* from, Color_RGB8* to, f32 lerp, Color_RGB8* dst); -void Lib_Nop801004FC(void); -void* Lib_SegmentedToVirtual(void* ptr); -void* Lib_SegmentedToVirtualNull(void* ptr); -uintptr_t Lib_VirtualToPhysical(void* ptr); -void* Lib_PhysicalToVirtual(uintptr_t ptr); void LifeMeter_Init(PlayState* play); void LifeMeter_UpdateColors(PlayState* play); s32 LifeMeter_SaveInterfaceHealth(PlayState* play); @@ -528,43 +512,7 @@ s32 LifeMeter_DecreaseInterfaceHealth(PlayState* play); void LifeMeter_Draw(PlayState* play); void LifeMeter_UpdateSizeAndBeep(PlayState* play); u32 LifeMeter_IsCritical(void); -void Lights_PointSetInfo(LightInfo* info, s16 x, s16 y, s16 z, u8 r, u8 g, u8 b, s16 radius, s32 type); -void Lights_PointNoGlowSetInfo(LightInfo* info, s16 x, s16 y, s16 z, u8 r, u8 g, u8 b, s16 radius); -void Lights_PointGlowSetInfo(LightInfo* info, s16 x, s16 y, s16 z, u8 r, u8 g, u8 b, s16 radius); -void Lights_PointSetColorAndRadius(LightInfo* info, u8 r, u8 g, u8 b, s16 radius); -void Lights_PointSetPosition(LightInfo* info, s16 x, s16 y, s16 z); -void Lights_DirectionalSetInfo(LightInfo* info, s8 x, s8 y, s8 z, u8 r, u8 g, u8 b); -void Lights_Reset(Lights* lights, u8 r, u8 g, u8 b); -void Lights_Draw(Lights* lights, GraphicsContext* gfxCtx); -Light* Lights_FindSlot(Lights* lights); -void Lights_BindPointWithReference(Lights* lights, LightParams* params, Vec3f* pos); -void Lights_BindPoint(Lights* lights, LightParams* params, PlayState* play); -void Lights_BindDirectional(Lights* lights, LightParams* params, void* unused); -void Lights_BindAll(Lights* lights, LightNode* listHead, Vec3f* refPos, PlayState* play); -LightNode* Lights_FindBufSlot(void); -void Lights_FreeNode(LightNode* light); -void LightContext_Init(PlayState* play, LightContext* lightCtx); -void LightContext_SetAmbientColor(LightContext* lightCtx, u8 r, u8 g, u8 b); -void LightContext_SetFog(LightContext* lightCtx, u8 r, u8 g, u8 b, s16 near, s16 far); -Lights* LightContext_NewLights(LightContext* lightCtx, GraphicsContext* gfxCtx); -void LightContext_InitList(PlayState* play, LightContext* lightCtx); -void LightContext_DestroyList(PlayState* play, LightContext* lightCtx); -LightNode* LightContext_InsertLight(PlayState* play, LightContext* lightCtx, LightInfo* info); -void LightContext_RemoveLight(PlayState* play, LightContext* lightCtx, LightNode* light); -Lights* Lights_NewAndDraw(GraphicsContext* gfxCtx, u8 ambientR, u8 ambientG, u8 ambientB, u8 numLights, u8 r, u8 g, u8 b, s8 x, s8 y, s8 z); -Lights* Lights_New(GraphicsContext* gfxCtx, u8 ambientR, u8 ambientG, u8 ambientB); -void Lights_GlowCheck(PlayState* play); -void Lights_DrawGlow(PlayState* play); -void* ZeldaArena_Malloc(size_t size); -void* ZeldaArena_MallocR(size_t size); -void* ZeldaArena_Realloc(void* ptr, size_t newSize); -void ZeldaArena_Free(void* ptr); -void* ZeldaArena_Calloc(size_t num, size_t size); -void ZeldaArena_GetSizes(size_t* outMaxFree, size_t* outFree, size_t* outAlloc); -s32 ZeldaArena_Check(void); -void ZeldaArena_Init(void* start, size_t size); -void ZeldaArena_Cleanup(void); -u8 ZeldaArena_IsInitialized(void); + // void func_80102E40(void); // void func_80102E90(void); // void func_80102EA4(void); @@ -773,31 +721,6 @@ void Inventory_SaveLotteryCodeGuess(PlayState* play); s32 Schedule_RunScript(PlayState* play, u8* script, ScheduleOutput* output); -void SkinMatrix_Vec3fMtxFMultXYZW(MtxF* mf, Vec3f* src, Vec3f* xyzDest, f32* wDest); -void SkinMatrix_Vec3fMtxFMultXYZ(MtxF* mf, Vec3f* src, Vec3f* dest); -void SkinMatrix_MtxFMtxFMult(MtxF* mfB, MtxF* mfA, MtxF* dest); -void SkinMatrix_GetClear(MtxF** mfp); -void SkinMatrix_GetClear(MtxF** mfp); -void SkinMatrix_MtxFCopy(MtxF* src, MtxF* dest); -s32 SkinMatrix_Invert(MtxF* src, MtxF* dest); -void SkinMatrix_SetScale(MtxF* mf, f32 x, f32 y, f32 z); -void SkinMatrix_SetRotateRPY(MtxF* mf, s16 roll, s16 pitch, s16 yaw); -void SkinMatrix_SetRotateYRP(MtxF* mf, s16 yaw, s16 roll, s16 pitch); -void SkinMatrix_SetTranslate(MtxF* mf, f32 x, f32 y, f32 z); -void SkinMatrix_SetScaleRotateRPYTranslate(MtxF* mf, f32 scaleX, f32 scaleY, f32 scaleZ, s16 roll, s16 pitch, s16 yaw, f32 dx, f32 dy, f32 dz); -void SkinMatrix_SetScaleRotateYRPTranslate(MtxF* mf, f32 scaleX, f32 scaleY, f32 scaleZ, s16 yaw, s16 roll, s16 pitch, f32 dx, f32 dy, f32 dz); -void SkinMatrix_SetRotateRPYTranslate(MtxF* mf, s16 roll, s16 pitch, s16 yaw, f32 dx, f32 dy, f32 dz); -void SkinMatrix_Vec3fToVec3s(Vec3f* src, Vec3s* dest); -void SkinMatrix_Vec3sToVec3f(Vec3s* src, Vec3f* dest); -void SkinMatrix_MtxFToMtx(MtxF* src, Mtx* dest); -Mtx* SkinMatrix_MtxFToNewMtx(GraphicsContext* gfxCtx, MtxF* src); -void SkinMatrix_SetRotateAroundVec(MtxF* mf, s16 a, f32 x, f32 y, f32 z); -void SkinMatrix_SetXRotation(MtxF* mf, s16 a); -void SkinMatrix_MulXRotation(MtxF* mf, s16 a); -void SkinMatrix_SetYRotation(MtxF* mf, s16 a); -void SkinMatrix_MulYRotation(MtxF* mf, s16 a); -void SkinMatrix_SetZRotation(MtxF* mf, s16 a); - uintptr_t KaleidoManager_FaultAddrConv(uintptr_t address, void* param); void KaleidoManager_LoadOvl(KaleidoMgrOverlay* ovl); void KaleidoManager_ClearOvl(KaleidoMgrOverlay* ovl); @@ -809,39 +732,6 @@ void KaleidoScopeCall_Init(PlayState* play); void KaleidoScopeCall_Destroy(PlayState* play); void KaleidoScopeCall_Update(PlayState* play); void KaleidoScopeCall_Draw(PlayState* play); -void Transition_Init(TransitionContext* transitionCtx); -void Transition_Destroy(TransitionContext* transitionCtx); - -void TransitionTile_Destroy(TransitionTile* this); -TransitionTile* TransitionTile_Init(TransitionTile* this, s32 cols, s32 rows); -void TransitionTile_Draw(TransitionTile* this, Gfx** gfxP); -void TransitionTile_Update(TransitionTile* this); - -void TransitionFade_Start(void* thisx); -void* TransitionFade_Init(void* thisx); -void TransitionFade_Destroy(void* thisx); -void TransitionFade_Update(void* thisx, s32 updateRate); -void TransitionFade_Draw(void* thisx, Gfx** gfxP); -s32 TransitionFade_IsDone(void* thisx); -void TransitionFade_SetColor(void* thisx, u32 color); -void TransitionFade_SetType(void* thisx, s32 type); -void TransitionOverlay_ClearLoadInfo(TransitionOverlay *overlayEntry); -void TransitionOverlay_SetSegment(TransitionOverlay *overlayEntry, void* vramStart, void* vramEnd, uintptr_t vromStart, uintptr_t vromEnd); -void TransitionCircle_Start(void* thisx); -void* TransitionCircle_Init(void* thisx); -void TransitionCircle_Destroy(void* thisx); -void TransitionCircle_Update(void* thisx); -void TransitionCircle_SetColor(void* thisx, u32 color); -void TransitionCircle_SetType(void* thisx, s32 type); -void TransitionCircle_LoadAndSetTexture(Gfx** gfxp, TexturePtr texture, s32 fmt, s32 arg3, s32 masks, s32 maskt, f32 arg6); -void TransitionCircle_Draw(void* thisx, Gfx** gfxp); -s32 TransitionCircle_IsDone(void* thisx); -void* TransitionOverlay_VramToRam(TransitionOverlay *overlayEntry, void* vramAddr); -void TransitionOverlay_VramToRamArray(TransitionOverlay *overlayEntry, void** vramAddrs, s32 count); -s32 TransitionOverlay_Load(TransitionOverlay *overlayEntry); -s32 TransitionOverlay_Free(TransitionOverlay *overlayEntry); -void func_80165438(UNK_PTR param_1); -// void func_80165444(s32 param_1, UNK_TYPE4 param_2, UNK_TYPE4 param_3, UNK_TYPE4 param_4, UNK_TYPE4 param_5); void Play_SetMotionBlurAlpha(u32 alpha); void Play_EnableMotionBlur(u32 alpha); @@ -894,11 +784,6 @@ void Play_AssignPlayerCsIdsFromScene(GameState* thisx, s32 spawnCsId); void Play_FillScreen(GameState* thisx, s16 fillScreenOn, u8 red, u8 green, u8 blue, u8 alpha); void Play_Init(GameState* thisx); -void GameAlloc_Log(GameAlloc* this); -void* GameAlloc_Malloc(GameAlloc* this, size_t size); -void GameAlloc_Free(GameAlloc* this, void* data); -void GameAlloc_Cleanup(GameAlloc* this); -void GameAlloc_Init(GameAlloc* this); void Graph_FaultClient(void); void Graph_InitTHGA(TwoHeadGfxArena* arena, Gfx* buffer, s32 size); void Graph_SetNextGfxPool(GraphicsContext* gfxCtx); diff --git a/include/gamealloc.h b/include/gamealloc.h new file mode 100644 index 000000000..ad97415ea --- /dev/null +++ b/include/gamealloc.h @@ -0,0 +1,24 @@ +#ifndef GAMEALLOC_H +#define GAMEALLOC_H + +#include "ultra64.h" + +typedef struct GameAllocEntry { + /* 0x0 */ struct GameAllocEntry* next; + /* 0x4 */ struct GameAllocEntry* prev; + /* 0x8 */ size_t size; + /* 0xC */ u32 unk_0C; +} GameAllocEntry; // size = 0x10 + +typedef struct GameAlloc { + /* 0x00 */ GameAllocEntry base; + /* 0x10 */ GameAllocEntry* head; +} GameAlloc; // size = 0x14 + +void GameAlloc_Log(GameAlloc* this); +void* GameAlloc_Malloc(GameAlloc* this, size_t size); +void GameAlloc_Free(GameAlloc* this, void* data); +void GameAlloc_Cleanup(GameAlloc* this); +void GameAlloc_Init(GameAlloc* this); + +#endif diff --git a/include/gfx.h b/include/gfx.h index 87f949d8b..a26c759ad 100644 --- a/include/gfx.h +++ b/include/gfx.h @@ -239,6 +239,10 @@ void func_8012D40C(f32* param_1, f32* param_2, s16* param_3); extern Gfx gSetupDLs[SETUPDL_MAX][6]; extern Gfx gEmptyDL[]; + +extern GfxMasterList D_0E000000; + + #define WORK_DISP __gfxCtx->work.p #define POLY_OPA_DISP __gfxCtx->polyOpa.p #define POLY_XLU_DISP __gfxCtx->polyXlu.p @@ -283,4 +287,21 @@ extern Gfx gEmptyDL[]; _g->words.w1 = (unsigned int)(d); \ }) +/** + * `x` vertex x + * `y` vertex y + * `z` vertex z + * `s` texture s coordinate + * `t` texture t coordinate + * `crnx` red component of color vertex, or x component of normal vertex + * `cgny` green component of color vertex, or y component of normal vertex + * `cbnz` blue component of color vertex, or z component of normal vertex + * `a` alpha + */ +#define VTX(x, y, z, s, t, crnx, cgny, cbnz, a) \ + { { { x, y, z }, 0, { s, t }, { crnx, cgny, cbnz, a } }, } + +#define VTX_T(x, y, z, s, t, cr, cg, cb, a) \ + { { x, y, z }, 0, { s, t }, { cr, cg, cb, a }, } + #endif diff --git a/include/ichain.h b/include/ichain.h index 07bd07313..591bd8f57 100644 --- a/include/ichain.h +++ b/include/ichain.h @@ -3,7 +3,7 @@ #include "libc/stddef.h" -typedef struct { +typedef struct InitChainEntry { u32 cont: 1; u32 type: 4; u32 offset: 11; diff --git a/include/macros.h b/include/macros.h index 223a12e8e..6d7433037 100644 --- a/include/macros.h +++ b/include/macros.h @@ -3,7 +3,6 @@ #include "libc/stdint.h" #include "PR/os_convert.h" -#include "main.h" #define SCREEN_WIDTH 320 #define SCREEN_HEIGHT 240 @@ -21,8 +20,6 @@ #define ARRAY_COUNT_2D(arr) (ARRAY_COUNT(arr) * ARRAY_COUNT(arr[0])) -#define SEGMENTED_TO_K0(addr) (void*)((gSegments[SEGMENT_NUMBER(addr)] + K0BASE) + SEGMENT_OFFSET(addr)) - #define GET_ACTIVE_CAM(play) ((play)->cameraPtrs[(play)->activeCamId]) #define GET_PLAYER(play) ((Player*)(play)->actorCtx.actorLists[ACTORCAT_PLAYER].first) @@ -67,23 +64,6 @@ (flag & 0x1) ? 0 : \ 0) -/** - * `x` vertex x - * `y` vertex y - * `z` vertex z - * `s` texture s coordinate - * `t` texture t coordinate - * `crnx` red component of color vertex, or x component of normal vertex - * `cgny` green component of color vertex, or y component of normal vertex - * `cbnz` blue component of color vertex, or z component of normal vertex - * `a` alpha - */ -#define VTX(x, y, z, s, t, crnx, cgny, cbnz, a) \ - { { { x, y, z }, 0, { s, t }, { crnx, cgny, cbnz, a } }, } - -#define VTX_T(x, y, z, s, t, cr, cg, cb, a) \ - { { x, y, z }, 0, { s, t }, { cr, cg, cb, a }, } - #define SQ(x) ((x) * (x)) #define ABS(x) ((x) >= 0 ? (x) : -(x)) #define ABS_ALT(x) ((x) < 0 ? -(x) : (x)) diff --git a/include/main.h b/include/main.h index 2b25dbb07..796faece0 100644 --- a/include/main.h +++ b/include/main.h @@ -16,4 +16,6 @@ extern PadMgr gPadMgr; void Main(void* arg); +#define SEGMENTED_TO_K0(addr) (void*)((gSegments[SEGMENT_NUMBER(addr)] + K0BASE) + SEGMENT_OFFSET(addr)) + #endif diff --git a/include/variables.h b/include/variables.h index 6cec93922..474251159 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1519,7 +1519,6 @@ extern TriNorm D_801EF590; extern TriNorm D_801EF5C8; extern TriNorm D_801EF600; extern TriNorm D_801EF638; -extern SaveContext gSaveContext; // extern UNK_TYPE1 D_801F4E20; // extern UNK_TYPE1 sBeatingHeartsDDPrim; @@ -1532,7 +1531,7 @@ extern SaveContext gSaveContext; // extern UNK_TYPE1 D_801F4F66; // extern UNK_TYPE1 D_801F4F68; // extern UNK_TYPE1 D_801F4F6A; -// extern LightsBuffer sLightsBuffer; + // extern UNK_TYPE1 D_801F5130; // extern UNK_TYPE1 D_801F5270; // extern UNK_TYPE1 D_801F528E; @@ -1652,7 +1651,6 @@ extern AudioCustomReverbFunction gAudioCustomReverbFunction; extern AudioCustomSynthFunction gAudioCustomSynthFunction; // other segments -extern GfxMasterList D_0E000000; extern Mtx D_01000000; extern u16 D_0F000000[]; diff --git a/include/z64.h b/include/z64.h index d8aa31074..5ef67b9e8 100644 --- a/include/z64.h +++ b/include/z64.h @@ -21,6 +21,8 @@ #include "sfx.h" #include "message_data_static.h" +#include "main.h" + #include "gfx.h" #include "gfxprint.h" #include "padutils.h" @@ -47,6 +49,7 @@ #include "z64game.h" #include "z64interface.h" #include "z64item.h" +#include "z64lib.h" #include "z64light.h" #include "z64map.h" #include "z64math.h" @@ -58,6 +61,7 @@ #include "z64save.h" #include "z64scene.h" #include "z64schedule.h" +#include "z64skin_matrix.h" #include "z64skin.h" #include "z64skybox.h" #include "z64sound_source.h" diff --git a/include/z64curve.h b/include/z64curve.h index 77174be5e..ae3c3442b 100644 --- a/include/z64curve.h +++ b/include/z64curve.h @@ -4,6 +4,7 @@ #include "PR/ultratypes.h" #include "z64math.h" +struct Actor; struct PlayState; typedef struct { @@ -56,7 +57,7 @@ s32 SkelCurve_Init(struct PlayState* play, SkelCurve* skelCurve, CurveSkeletonHe void SkelCurve_Destroy(struct PlayState* play, SkelCurve* skelCurve); void SkelCurve_SetAnim(SkelCurve* skelCurve, CurveAnimationHeader* animation, f32 arg2, f32 endFrame, f32 curFrame, f32 playSpeed); s32 SkelCurve_Update(struct PlayState* play, SkelCurve* skelCurve); -void SkelCurve_Draw(Actor* actor, struct PlayState* play, SkelCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx); +void SkelCurve_Draw(struct Actor* actor, struct PlayState* play, SkelCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, struct Actor* thisx); // ZAPD compatibility typedefs diff --git a/include/z64game.h b/include/z64game.h index 50dd68473..352c5e189 100644 --- a/include/z64game.h +++ b/include/z64game.h @@ -2,11 +2,13 @@ #define Z64GAME_H #include "ultra64.h" + #include "libc/stdbool.h" #include "libc/stdint.h" +#include "gamealloc.h" +#include "padmgr.h" #include "padutils.h" #include "tha.h" -#include "padmgr.h" #include "unk.h" struct GraphicsContext; @@ -42,18 +44,6 @@ typedef struct { /* 0x2C */ size_t instanceSize; } GameStateOverlay; // size = 0x30 -typedef struct GameAllocEntry { - /* 0x0 */ struct GameAllocEntry* next; - /* 0x4 */ struct GameAllocEntry* prev; - /* 0x8 */ size_t size; - /* 0xC */ u32 unk_0C; -} GameAllocEntry; // size = 0x10 - -typedef struct GameAlloc { - /* 0x00 */ GameAllocEntry base; - /* 0x10 */ GameAllocEntry* head; -} GameAlloc; // size = 0x14 - typedef struct GameState { /* 0x00 */ struct GraphicsContext* gfxCtx; /* 0x04 */ GameStateFunc main; diff --git a/include/z64lib.h b/include/z64lib.h new file mode 100644 index 000000000..0a4009ba3 --- /dev/null +++ b/include/z64lib.h @@ -0,0 +1,29 @@ +#ifndef Z64LIB_H +#define Z64LIB_H + +#include "ultra64.h" + +#include "color.h" +#include "z64math.h" + +struct Actor; +struct InitChainEntry; +struct Input; + +void* Lib_MemCpy(void* dest, void* src, size_t size); +void* Lib_MemSet(void* buffer, s32 value, size_t size); +void Lib_GetControlStickData(f32* outMagnitude, s16* outAngle, struct Input* input); +void Actor_ProcessInitChain(struct Actor* actor, struct InitChainEntry* ichain); +void Color_RGBA8_Copy(Color_RGBA8* dst, Color_RGBA8* src); +void Lib_PlaySfx(u16 sfxId); +void Lib_PlaySfx_2(u16 sfxId); +void Lib_PlaySfx_AtPos(Vec3f* pos, u16 sfxId); +void Lib_Vec3f_TranslateAndRotateY(Vec3f* translation, s16 rotAngle, Vec3f* src, Vec3f* dst); +void Color_RGB8_Lerp(Color_RGB8* from, Color_RGB8* to, f32 lerp, Color_RGB8* dst); +void Lib_Nop801004FC(void); +void* Lib_SegmentedToVirtual(void* ptr); +void* Lib_SegmentedToVirtualNull(void* ptr); +uintptr_t Lib_VirtualToPhysical(void* ptr); +void* Lib_PhysicalToVirtual(uintptr_t ptr); + +#endif diff --git a/include/z64light.h b/include/z64light.h index 21b1920c3..7b9fa12a1 100644 --- a/include/z64light.h +++ b/include/z64light.h @@ -2,13 +2,13 @@ #define Z64LIGHT_H #include "ultra64.h" -#include "PR/gbi.h" #include "color.h" #include "z64math.h" +struct GraphicsContext; struct PlayState; -typedef struct { +typedef struct AdjLightSettings { /* 0x00 */ s16 ambientColor[3]; /* 0x06 */ s16 light1Color[3]; /* 0x0C */ s16 light2Color[3]; @@ -17,7 +17,7 @@ typedef struct { /* 0x1A */ s16 zFar; } AdjLightSettings; // size = 0x1C -typedef struct { +typedef struct LightPoint { /* 0x0 */ s16 x; /* 0x2 */ s16 y; /* 0x4 */ s16 z; @@ -26,7 +26,7 @@ typedef struct { /* 0xA */ s16 radius; } LightPoint; // size = 0xC -typedef struct { +typedef struct LightDirectional { /* 0x0 */ s8 x; /* 0x1 */ s8 y; /* 0x2 */ s8 z; @@ -39,7 +39,7 @@ typedef union LightParams { } LightParams; // size = 0xC typedef struct LightInfo { - /* 0x0 */ u8 type; + /* 0x0 */ u8 type; // LightType enum /* 0x2 */ LightParams params; } LightInfo; // size = 0xE @@ -77,7 +77,25 @@ typedef enum LightType { /* 2 */ LIGHT_POINT_GLOW } LightType; -typedef void (*LightsBindFunc)(Lights* lights, LightParams* params, Vec3f* vec); -typedef void (*LightsPosBindFunc)(Lights* lights, LightParams* params, struct PlayState* play); +void Lights_PointNoGlowSetInfo(LightInfo* info, s16 x, s16 y, s16 z, u8 r, u8 g, u8 b, s16 radius); +void Lights_PointGlowSetInfo(LightInfo* info, s16 x, s16 y, s16 z, u8 r, u8 g, u8 b, s16 radius); +void Lights_PointSetColorAndRadius(LightInfo* info, u8 r, u8 g, u8 b, s16 radius); +void Lights_PointSetPosition(LightInfo* info, s16 x, s16 y, s16 z); +void Lights_DirectionalSetInfo(LightInfo* info, s8 x, s8 y, s8 z, u8 r, u8 g, u8 b); +void Lights_Reset(Lights* lights, u8 r, u8 g, u8 b); +void Lights_Draw(Lights* lights, struct GraphicsContext* gfxCtx); +void Lights_BindAll(Lights* lights, LightNode* listHead, Vec3f* refPos, struct PlayState* play); +void LightContext_Init(struct PlayState* play, LightContext* lightCtx); +void LightContext_SetAmbientColor(LightContext* lightCtx, u8 r, u8 g, u8 b); +void LightContext_SetFog(LightContext* lightCtx, u8 r, u8 g, u8 b, s16 near, s16 far); +Lights* LightContext_NewLights(LightContext* lightCtx, struct GraphicsContext* gfxCtx); +void LightContext_InitList(struct PlayState* play, LightContext* lightCtx); +void LightContext_DestroyList(struct PlayState* play, LightContext* lightCtx); +LightNode* LightContext_InsertLight(struct PlayState* play, LightContext* lightCtx, LightInfo* info); +void LightContext_RemoveLight(struct PlayState* play, LightContext* lightCtx, LightNode* light); +Lights* Lights_NewAndDraw(struct GraphicsContext* gfxCtx, u8 ambientR, u8 ambientG, u8 ambientB, u8 numLights, u8 r, u8 g, u8 b, s8 x, s8 y, s8 z); +Lights* Lights_New(struct GraphicsContext* gfxCtx, u8 ambientR, u8 ambientG, u8 ambientB); +void Lights_GlowCheck(struct PlayState* play); +void Lights_DrawGlow(struct PlayState* play); #endif diff --git a/include/z64malloc.h b/include/z64malloc.h new file mode 100644 index 000000000..b679d3984 --- /dev/null +++ b/include/z64malloc.h @@ -0,0 +1,17 @@ +#ifndef Z64MALLOC_H +#define Z64MALLOC_H + +#include "ultra64.h" + +void* ZeldaArena_Malloc(size_t size); +void* ZeldaArena_MallocR(size_t size); +void* ZeldaArena_Realloc(void* ptr, size_t newSize); +void ZeldaArena_Free(void* ptr); +void* ZeldaArena_Calloc(size_t num, size_t size); +void ZeldaArena_GetSizes(size_t* outMaxFree, size_t* outFree, size_t* outAlloc); +s32 ZeldaArena_Check(void); +void ZeldaArena_Init(void* start, size_t size); +void ZeldaArena_Cleanup(void); +u8 ZeldaArena_IsInitialized(void); + +#endif diff --git a/include/z64math.h b/include/z64math.h index fa9b0a4ff..27ab62dca 100644 --- a/include/z64math.h +++ b/include/z64math.h @@ -2,6 +2,7 @@ #define Z64MATH_H #include "ultra64.h" +#include "libc/math.h" #define VEC_SET(V,X,Y,Z) V.x=X;V.y=Y;V.z=Z diff --git a/include/z64save.h b/include/z64save.h index cdebffc25..67449a178 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -1678,6 +1678,8 @@ void Sram_SetFlashPagesOwlSave(SramContext* sramCtx, s32 curPage, s32 numPages); void Sram_StartWriteToFlashOwlSave(SramContext* sramCtx); void Sram_UpdateWriteToFlashOwlSave(SramContext* sramCtx); +void SaveContext_Init(void); + extern u32 gSramSlotOffsets[]; extern u8 gAmmoItems[]; extern s32 gFlashSaveStartPages[]; @@ -1686,4 +1688,6 @@ extern s32 gFlashSpecialSaveNumPages[]; extern s32 gFlashOwlSaveStartPages[]; extern s32 gFlashOwlSaveNumPages[]; +extern SaveContext gSaveContext; + #endif diff --git a/include/z64skin.h b/include/z64skin.h index a9e2ebc01..b334e939c 100644 --- a/include/z64skin.h +++ b/include/z64skin.h @@ -3,6 +3,7 @@ #include "z64animation.h" +struct Actor; struct GraphicsContext; struct GameState; struct PlayState; @@ -89,10 +90,10 @@ void Skin_UpdateVertices(MtxF* mtx, SkinVertex* skinVertices, SkinLimbModif* mod void Skin_ApplyLimbModifications(struct GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, s32 arg3); void Skin_DrawAnimatedLimb(struct GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, s32 arg3, s32 drawFlags); void Skin_DrawLimb(struct GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, Gfx* dListOverride, s32 drawFlags); -void func_80138228(Actor* actor, struct PlayState* play, Skin* skin, SkinPostDraw postDraw, s32 setTranslation); -void func_80138258(Actor* actor, struct PlayState* play, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation); -void func_8013828C(Actor* actor, struct PlayState* play, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6); -void func_801382C4(Actor* actor, struct PlayState* play, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6, s32 drawFlags); +void func_80138228(struct Actor* actor, struct PlayState* play, Skin* skin, SkinPostDraw postDraw, s32 setTranslation); +void func_80138258(struct Actor* actor, struct PlayState* play, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation); +void func_8013828C(struct Actor* actor, struct PlayState* play, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6); +void func_801382C4(struct Actor* actor, struct PlayState* play, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6, s32 drawFlags); void Skin_GetLimbPos(Skin* skin, s32 limbIndex, Vec3f* offset, Vec3f* dst); void Skin_GetVertexPos(Skin* skin, s32 limbIndex, s32 vtxIndex, Vec3f* dst); @@ -101,6 +102,6 @@ void Skin_InitAnimatedLimb(struct GameState* gameState, Skin* skin, s32 limbInde void Skin_Init(struct GameState* gameState, Skin* skin, SkeletonHeader* skeletonHeader, AnimationHeader* animationHeader); void Skin_Free(struct GameState* gameState, Skin* skin); s32 func_801387D4(Skin* skin, SkinLimb** skeleton, MtxF* limbMatrices, u8 parentIndex, u8 limbIndex); -s32 Skin_ApplyAnimTransformations(Skin* skin, MtxF* limbMatrices, Actor* actor, s32 setTranslation); +s32 Skin_ApplyAnimTransformations(Skin* skin, MtxF* limbMatrices, struct Actor* actor, s32 setTranslation); #endif diff --git a/include/z64skin_matrix.h b/include/z64skin_matrix.h new file mode 100644 index 000000000..01f7c885a --- /dev/null +++ b/include/z64skin_matrix.h @@ -0,0 +1,34 @@ +#ifndef Z64SKIN_MATRIX_H +#define Z64SKIN_MATRIX_H + +#include "ultra64.h" +#include "z64math.h" + +struct GraphicsContext; + +void SkinMatrix_Vec3fMtxFMultXYZW(MtxF* mf, Vec3f* src, Vec3f* xyzDest, f32* wDest); +void SkinMatrix_Vec3fMtxFMultXYZ(MtxF* mf, Vec3f* src, Vec3f* dest); +void SkinMatrix_MtxFMtxFMult(MtxF* mfB, MtxF* mfA, MtxF* dest); +void SkinMatrix_GetClear(MtxF** mfp); +void SkinMatrix_GetClear(MtxF** mfp); +void SkinMatrix_MtxFCopy(MtxF* src, MtxF* dest); +s32 SkinMatrix_Invert(MtxF* src, MtxF* dest); +void SkinMatrix_SetScale(MtxF* mf, f32 x, f32 y, f32 z); +void SkinMatrix_SetRotateRPY(MtxF* mf, s16 roll, s16 pitch, s16 yaw); +void SkinMatrix_SetRotateYRP(MtxF* mf, s16 yaw, s16 roll, s16 pitch); +void SkinMatrix_SetTranslate(MtxF* mf, f32 x, f32 y, f32 z); +void SkinMatrix_SetScaleRotateRPYTranslate(MtxF* mf, f32 scaleX, f32 scaleY, f32 scaleZ, s16 roll, s16 pitch, s16 yaw, f32 dx, f32 dy, f32 dz); +void SkinMatrix_SetScaleRotateYRPTranslate(MtxF* mf, f32 scaleX, f32 scaleY, f32 scaleZ, s16 yaw, s16 roll, s16 pitch, f32 dx, f32 dy, f32 dz); +void SkinMatrix_SetRotateRPYTranslate(MtxF* mf, s16 roll, s16 pitch, s16 yaw, f32 dx, f32 dy, f32 dz); +void SkinMatrix_Vec3fToVec3s(Vec3f* src, Vec3s* dest); +void SkinMatrix_Vec3sToVec3f(Vec3s* src, Vec3f* dest); +void SkinMatrix_MtxFToMtx(MtxF* src, Mtx* dest); +Mtx* SkinMatrix_MtxFToNewMtx(struct GraphicsContext* gfxCtx, MtxF* src); +void SkinMatrix_SetRotateAroundVec(MtxF* mf, s16 a, f32 x, f32 y, f32 z); +void SkinMatrix_SetXRotation(MtxF* mf, s16 a); +void SkinMatrix_MulXRotation(MtxF* mf, s16 a); +void SkinMatrix_SetYRotation(MtxF* mf, s16 a); +void SkinMatrix_MulYRotation(MtxF* mf, s16 a); +void SkinMatrix_SetZRotation(MtxF* mf, s16 a); + +#endif diff --git a/include/z64speed_meter.h b/include/z64speed_meter.h index 44b47ed1e..2c2bd9053 100644 --- a/include/z64speed_meter.h +++ b/include/z64speed_meter.h @@ -1,7 +1,7 @@ #ifndef Z64SPEED_METER_H #define Z64SPEED_METER_H -#include "PR/ultratypes.h" +#include "ultra64.h" struct GameState; struct GraphicsContext; diff --git a/include/z64transition.h b/include/z64transition.h index 267098997..fa46ac40c 100644 --- a/include/z64transition.h +++ b/include/z64transition.h @@ -2,26 +2,37 @@ #define Z64TRANSITION_H #include "ultra64.h" + #include "libc/stdint.h" +#include "unk.h" + #include "overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.h" #include "overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.h" #include "overlays/fbdemos/ovl_fbdemo_wipe3/z_fbdemo_wipe3.h" #include "overlays/fbdemos/ovl_fbdemo_wipe4/z_fbdemo_wipe4.h" #include "overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.h" -typedef enum { +typedef enum TransitionOverlayStatus { + /* -1 */ TRANSITION_OVERLAY_STATUS_FAILED = -1, // failed allocation or null reference + /* 0 */ TRANSITION_OVERLAY_STATUS_LOAD_FREE, // successfully loaded/freed overlay + /* 1 */ TRANSITION_OVERLAY_STATUS_ADD_REMOVAL, // successfully added/removed instance + /* 2 */ TRANSITION_OVERLAY_STATUS_LOADED_NO_INSTANCES, // overlay is loaded but has no instances (?) TODO: Figure out why this exists + /* 3 */ TRANSITION_OVERLAY_STATUS_INTERNAL // internal overlay, so always loaded +} TransitionOverlayStatus; + +typedef enum TransitionTileState { /* 0 */ TRANS_TILE_OFF, // Inactive, do nothing /* 1 */ TRANS_TILE_SETUP, // Save the necessary buffers /* 2 */ TRANS_TILE_PROCESS, // Initialize the transition /* 3 */ TRANS_TILE_READY // The transition is ready, so will update and draw each frame } TransitionTileState; -typedef struct { +typedef struct TransitionTileVtxData { /* 0x0 */ f32 x; /* 0x4 */ f32 y; } TransitionTileVtxData; // size = 0x8 -typedef struct { +typedef struct TransitionTile { /* 0x00 */ s32 cols; /* 0x04 */ s32 rows; /* 0x08 */ s32 frame; @@ -38,7 +49,7 @@ typedef struct { #define TC_SET_PARAMS (1 << 7) -typedef struct { +typedef struct TransitionInit { /* 0x00 */ void* (*init)(void* transition); /* 0x04 */ void (*destroy)(void* transition); /* 0x08 */ void (*update)(void* transition, s32 updateRate); @@ -50,7 +61,7 @@ typedef struct { /* 0x20 */ s32 (*isDone)(void* transition); } TransitionInit; // size = 0x24 -typedef struct { +typedef struct TransitionOverlay { union { struct { /* 0x00 */ u32 count : 8; @@ -73,8 +84,8 @@ typedef enum { #define TRANS_INSTANCE_TYPE_FADE_FLASH 3 -typedef struct { - /* 0x0 */ u8 type; +typedef struct TransitionFade { + /* 0x0 */ u8 type; // TransitionFadeType enum /* 0x1 */ u8 isDone; /* 0x2 */ u8 direction; /* 0x4 */ Color_RGBA8_u32 color; @@ -83,7 +94,7 @@ typedef struct { #define FBDEMO_CIRCLE_GET_MASK_TYPE(type) ((type) & 1) -typedef struct { +typedef struct TransitionCircle { /* 0x00 */ Color_RGBA8_u32 color; /* 0x04 */ f32 referenceRadius; // Reference for where to transition to /* 0x08 */ f32 stepValue; // How fast the Transition is @@ -103,7 +114,7 @@ typedef struct { #define TRANS_TRIGGER_START 20 // start transition (exiting an area) #define TRANS_TRIGGER_END -20 // transition is ending (arriving in a new area) -typedef enum { +typedef enum TransitionMode { /* 0 */ TRANS_MODE_OFF, /* 1 */ TRANS_MODE_SETUP, /* 2 */ TRANS_MODE_INSTANCE_INIT, @@ -128,7 +139,7 @@ typedef enum { #define TRANS_TYPE_WIPE3 (1 << 6) #define TRANS_TYPE_SET_PARAMS (1 << 7) -typedef enum { +typedef enum TransitionType { /* 0 */ TRANS_TYPE_WIPE, /* 1 */ TRANS_TYPE_TRIFORCE, /* 2 */ TRANS_TYPE_FADE_BLACK, @@ -188,12 +199,12 @@ typedef union TransitionInstance { #undef DEFINE_TRANSITION #undef DEFINE_TRANSITION_INTERNAL -typedef struct { +typedef struct TransitionContext { /* 0x000 */ s16 transitionType; /* 0x002 */ s8 fbdemoType; - /* 0x003 */ char unk_003[0x5]; + /* 0x003 */ UNK_TYPE1 unk_003[0x5]; /* 0x008 */ TransitionInstance instanceData; - /* 0x220 */ char unk_220[0x10]; + /* 0x220 */ UNK_TYPE1 unk_220[0x10]; /* 0x230 */ void* (*init)(void* transition); /* 0x234 */ void (*destroy)(void* transition); /* 0x238 */ void (*update)(void* transition, s32 updateRate); @@ -203,7 +214,44 @@ typedef struct { /* 0x248 */ void (*setColor)(void* transition, u32 color); /* 0x24C */ void (*setEnvColor)(void* transition, u32 color); /* 0x250 */ s32 (*isDone)(void* transition); - /* 0x254 */ char unk_254[0x4]; + /* 0x254 */ UNK_TYPE1 unk_254[0x4]; } TransitionContext; // size = 0x258 + +// z_dbdemo_dlftbls.c + +void Transition_Init(TransitionContext* transitionCtx); +void Transition_Destroy(TransitionContext* transitionCtx); + +// z_fbdemo.c + +void TransitionTile_Destroy(TransitionTile* this); +TransitionTile* TransitionTile_Init(TransitionTile* this, s32 cols, s32 rows); +void TransitionTile_Draw(TransitionTile* this, Gfx** gfxP); +void TransitionTile_Update(TransitionTile* this); + +// z_fbdemo_fade.c + +void TransitionFade_Start(void* thisx); +void* TransitionFade_Init(void* thisx); +void TransitionFade_Destroy(void* thisx); +void TransitionFade_Update(void* thisx, s32 updateRate); +void TransitionFade_Draw(void* thisx, Gfx** gfxP); +s32 TransitionFade_IsDone(void* thisx); +void TransitionFade_SetColor(void* thisx, u32 color); +void TransitionFade_SetType(void* thisx, s32 type); + +// z_fbdemo_circle.c + +void TransitionCircle_LoadAndSetTexture(Gfx** gfxp, TexturePtr texture, s32 fmt, s32 arg3, s32 masks, s32 maskt, f32 arg6); + +// z_overlay.c + +void* TransitionOverlay_VramToRam(TransitionOverlay* overlayEntry, void* vramAddr); +void TransitionOverlay_VramToRamArray(TransitionOverlay *overlayEntry, void** vramAddrs, s32 count); +TransitionOverlayStatus TransitionOverlay_Load(TransitionOverlay *overlayEntry); +TransitionOverlayStatus TransitionOverlay_Free(TransitionOverlay *overlayEntry); +void TransitionOverlay_ClearLoadInfo(TransitionOverlay *overlayEntry); +void TransitionOverlay_SetSegment(TransitionOverlay *overlayEntry, void* vramStart, void* vramEnd, uintptr_t vromStart, uintptr_t vromEnd); + #endif |
