z_lights.c OK (#343)

* rename some structs

* changes

* rename stuff and start a func

* progress

* progress

* progress

* remove unwanted file

* progress

* match last few funcs

* done, i think

* small changes

* match Lights_Draw (thanks krim)

* comments

* cleanup

* most pr suggestions

* name changes

* rename
This commit is contained in:
fig02
2020-09-05 09:45:10 -04:00
committed by GitHub
parent 612980f90c
commit bb1aacbd0b
111 changed files with 614 additions and 1244 deletions
+26 -28
View File
@@ -288,10 +288,10 @@ void FlagSet_Update(GlobalContext* globalCtx);
void Overlay_LoadGameState(GameStateOverlay* overlayEntry);
void Overlay_FreeGameState(GameStateOverlay* overlayEntry);
void ActorShape_Init(ActorShape* shape, f32 arg1, void* shadowDrawFunc, f32 arg3);
void ActorShadow_DrawFunc_Circle(Actor* actor, LightMapper* lightMapper, GlobalContext* globalCtx);
void ActorShadow_DrawFunc_WhiteCircle(Actor* actor, LightMapper* lightMapper, GlobalContext* globalCtx);
void ActorShadow_DrawFunc_Squiggly(Actor* actor, LightMapper* lightMapper, GlobalContext* globalCtx);
void ActorShadow_DrawFunc_Teardrop(Actor* actor, LightMapper* lightMapper, GlobalContext* globalCtx);
void ActorShadow_DrawFunc_Circle(Actor* actor, Lights* lights, GlobalContext* globalCtx);
void ActorShadow_DrawFunc_WhiteCircle(Actor* actor, Lights* lights, GlobalContext* globalCtx);
void ActorShadow_DrawFunc_Squiggly(Actor* actor, Lights* lights, GlobalContext* globalCtx);
void ActorShadow_DrawFunc_Teardrop(Actor* actor, Lights* lights, GlobalContext* globalCtx);
void func_8002BDB0(Actor* actor, s32 arg1, s32 arg2, UNK_PTR arg3, s32 arg4, UNK_PTR arg5);
void func_8002C124(TargetContext* targetCtx, GlobalContext* globalCtx);
s32 Flags_GetSwitch(GlobalContext* globalCtx, s32 flag);
@@ -903,7 +903,7 @@ void KaleidoSetup_Destroy(GlobalContext* globalCtx);
// ? func_8006EE60(?);
// ? func_8006EEBC(?);
// ? func_8006EF10(?);
// ? func_8006F0A0(?);
s32 func_8006F0A0(s32 arg0);
// ? func_8006F0D4(?);
// ? func_8006F0FC(?);
u8 func_8006F140(GlobalContext*, EnvironmentContext*, UNK_TYPE);
@@ -975,29 +975,27 @@ void Health_InitData(GlobalContext* globalCtx);
void Health_UpdateData(GlobalContext* globalCtx);
void Health_Draw(GlobalContext* globalCtx);
void Health_HandleCriticalAlarm(GlobalContext* globalCtx);
void Lights_InitPositionalLight(LightInfoPositional* info, s16 posX, s16 posY, s16 posZ, u8 red, u8 green, u8 blue,
s16 radius, u32 type);
void Lights_InitType0PositionalLight(LightInfoPositional* info, s16 posX, s16 posY, s16 posZ, u8 red, u8 green, u8 blue,
s16 radius);
void Lights_InitType2PositionalLight(LightInfoPositional* info, s16 posX, s16 posY, s16 posZ, u8 red, u8 green, u8 blue,
s16 radius);
void Lights_SetPositionalLightColorAndRadius(LightInfoPositional* info, u8 red, u8 green, u8 blue, s16 radius);
void Lights_InitDirectional(LightInfoDirectional* info, s8 dirX, s8 dirY, s8 dirZ, u8 red, u8 green, u8 blue);
void Lights_MapperInit(LightMapper* mapper, u8 red, u8 green, u8 blue);
// ? func_8007A0B4(?);
// ? func_8007A474(?);
z_Light* Lights_FindFreeSlot();
void func_8007A614(GlobalContext* globalCtx, LightingContext* lightCtx);
void func_8007A698(LightingContext* lightCtx, u8 arg1, u8 arg2, u8 arg3, s16 arg4, s16 arg5);
void Lights_SetAmbientColor(LightingContext* lightCtx, u8 red, u8 green, u8 blue);
LightMapper* Lights_CreateMapper(LightingContext* lightCtx, GraphicsContext* gfxCtx);
void Lights_ClearHead(GlobalContext* globalCtx, LightingContext* lightCtx);
void Lights_RemoveAll(GlobalContext* globalCtx, LightingContext* lightCtx);
z_Light* Lights_Insert(GlobalContext* globalCtx, LightingContext* lightCtx, void* info);
void Lights_Remove(GlobalContext* globalCtx, LightingContext* lightCtx, z_Light* light);
LightMapper* func_8007A960(GraphicsContext* gfxCtx, u8 red, u8 green, u8 blue);
// ? func_8007A9B4(?);
// ? func_8007ABBC(?);
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_DirectionalSetInfo(LightInfo* info, s8 x, s8 y, s8 z, u8 r, u8 g, u8 b);
void Lights_Reset(Lights* lights, u8 ambentR, u8 ambentG, u8 ambentB);
void Lights_Draw(Lights* lights, GraphicsContext* gfxCtx);
void Lights_BindAll(Lights* lights, LightNode* listHead, Vec3f* vec);
void LightContext_Init(GlobalContext* globalCtx, LightContext* lightCtx);
void LightContext_SetAmbientColor(LightContext* lightCtx, u8 r, u8 g, u8 b);
void func_8007A698(LightContext* lightCtx, u8 arg1, u8 arg2, u8 arg3, s16 numLights, s16 arg5);
Lights* LightContext_NewLights(LightContext* lightCtx, GraphicsContext* gfxCtx);
void LightContext_InitList(GlobalContext* globalCtx, LightContext* lightCtx);
void LightContext_DestroyList(GlobalContext* globalCtx, LightContext* lightCtx);
LightNode* LightContext_InsertLight(GlobalContext* globalCtx, LightContext* lightCtx, LightInfo* info);
void LightContext_RemoveLight(GlobalContext* globalCtx, LightContext* lightCtx, LightNode* node);
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(GlobalContext* globalCtx);
void Lights_DrawGlow(GlobalContext* globalCtx);
void ZeldaArena_CheckPointer(void* ptr, u32 size, const char* name, const char* action);
void* ZeldaArena_Malloc(u32 size);
void* ZeldaArena_MallocDebug(u32 size, const char* file, s32 line);
+3 -3
View File
@@ -36,8 +36,8 @@ extern u8 D_04006020[];
extern Gfx D_0400C820[];
extern u32 D_0400CB70;
extern u32 D_04010130;
//extern ? D_04015720;
//extern ? D_04015760;
extern Gfx D_04015720[];
extern Gfx D_04015760[];
//extern ? D_0401A0B0;
extern u32 D_0401E370;
//extern ? D_0402CF30;
@@ -3644,7 +3644,7 @@ extern OSPifRam pifMempakBuf;
//extern ? D_801759BA;
//extern ? D_801759BC;
//extern ? D_801759BE;
extern u16 gZBuffer[SCREEN_WIDTH * SCREEN_HEIGHT]; // 0x25800 bytes
extern u16 gZBuffer[SCREEN_HEIGHT][SCREEN_WIDTH]; // 0x25800 bytes
extern u64 gGfxSPTaskOutputBuffer[0x3000]; // 0x18000 bytes
extern u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE]; // 0xC00 bytes
extern u8 gGfxSPTaskStack[0x400]; // 0x400 bytes
+1 -1
View File
@@ -1214,7 +1214,7 @@ typedef struct GlobalContext {
/* 0x007A0 */ s16 activeCamera;
/* 0x007A2 */ s16 nextCamera;
/* 0x007A4 */ SoundContext soundCtx;
/* 0x007A8 */ LightingContext lightCtx;
/* 0x007A8 */ LightContext lightCtx;
/* 0x007B8 */ SubGlobalContext7B8 sub_7B8;
/* 0x007C0 */ CollisionContext colCtx;
/* 0x01C24 */ ActorContext actorCtx;
+2 -2
View File
@@ -14,7 +14,7 @@ struct Actor;
struct GlobalContext;
// From z64light.h
struct LightMapper;
struct Lights;
typedef struct {
Vec3f pos;
@@ -98,7 +98,7 @@ typedef struct {
/* 0x00 */ Vec3s rot; // Current actor shape rotation
/* 0x06 */ u8 unk_06;
/* 0x08 */ f32 unk_08; // Model y axis offset. Represents model space units. collision mesh related
/* 0x0C */ void (*shadowDrawFunc)(struct Actor*, struct LightMapper*, struct GlobalContext*);
/* 0x0C */ void (*shadowDrawFunc)(struct Actor*, struct Lights*, struct GlobalContext*);
/* 0x10 */ f32 unk_10;
/* 0x14 */ u8 unk_14;
/* 0x15 */ u8 unk_15;
+3 -3
View File
@@ -132,7 +132,7 @@ typedef struct {
/* 0x24 */ f32 maxInitialSpeed;
/* 0x28 */ f32 lengthCutoff;
/* 0x2C */ u8 duration;
/* 0x2E */ LightInfoPositionalParams lightParams;
/* 0x2E */ LightPoint lightPoint;
/* 0x3C */ s32 lightDecay; // halves light radius every frame when set to 1
} EffectShieldParticleInit; // size = 0x40
@@ -152,8 +152,8 @@ typedef struct {
/* 0x1AC */ f32 lengthCutoff;
/* 0x1B0 */ u8 duration;
/* 0x1B1 */ u8 timer;
/* 0x1B2 */ LightInfoPositional lightInfo;
/* 0x1C0 */ z_Light* light;
/* 0x1B2 */ LightInfo lightInfo;
/* 0x1C0 */ LightNode* lightNode;
/* 0x1C4 */ s32 lightDecay; // halves light radius every frame when set to 1
} EffectShieldParticle; // size = 0x1C8
+48 -59
View File
@@ -3,73 +3,62 @@
#include <ultra64.h>
#include <ultra64/gbi.h>
typedef struct z_Light_t {
/* 0x0 */ struct LightInfo* info;
/* 0x4 */ struct z_Light_t* prev;
/* 0x8 */ struct z_Light_t* next;
} z_Light;
#include <z64math.h>
#include <color.h>
typedef struct {
/* 0x0 */ z_Light* lightsHead;
/* 0x4 */ u8 ambientRed;
/* 0x5 */ u8 ambientGreen;
/* 0x6 */ u8 ambientBlue;
/* 0x0 */ s16 x;
/* 0x2 */ s16 y;
/* 0x4 */ s16 z;
/* 0x6 */ u8 color[3];
/* 0x9 */ u8 drawGlow;
/* 0xA */ s16 radius;
} LightPoint; // size = 0xC
typedef struct {
/* 0x0 */ s8 x;
/* 0x1 */ s8 y;
/* 0x2 */ s8 z;
/* 0x3 */ u8 color[3];
} LightDirectional; // size = 0x6
typedef union {
LightPoint point;
LightDirectional dir;
} LightParams; // size = 0xC
typedef struct {
/* 0x0 */ u8 type;
/* 0x2 */ LightParams params;
} LightInfo; // size = 0xE
typedef struct Lights{
/* 0x00 */ u8 numLights;
/* 0x08 */ Lightsn l;
} Lights; // size = 0x80
typedef struct LightNode {
/* 0x0 */ LightInfo* info;
/* 0x4 */ struct LightNode* prev;
/* 0x8 */ struct LightNode* next;
} LightNode; // size = 0xC
typedef struct {
/* 0x0 */ LightNode* listHead;
/* 0x4 */ Color_RGB8 ambient;
/* 0x7 */ u8 unk_07;
/* 0x8 */ u8 unk_08;
/* 0x9 */ u8 unk_09;
/* 0xA */ s16 unk_0A;
/* 0xC */ s16 unk_0C;
} LightingContext;
} LightContext; // size = 0x10
typedef struct {
/* 0x000 */ int numOccupied;
/* 0x004 */ int nextFree;
/* 0x008 */ z_Light lights[32];
} LightsList;
typedef enum {
/* 0x00 */ LIGHT_POINT_NOGLOW,
/* 0x01 */ LIGHT_DIRECTIONAL,
/* 0x02 */ LIGHT_POINT_GLOW
} LightType;
typedef struct {
/* 0x0 */ u8 type;
/* 0x2 */ u16 params[6];
} LightInfo;
typedef struct {
/* 0x0 */ s8 dirX;
/* 0x1 */ s8 dirY;
/* 0x2 */ s8 dirZ;
/* 0x3 */ u8 red;
/* 0x4 */ u8 green;
/* 0x5 */ u8 blue;
/* 0x6 */ u16 pad[3];
} LightInfoDirectionalParams;
typedef struct {
/* 0x0 */ s16 posX;
/* 0x2 */ s16 posY;
/* 0x4 */ s16 posZ;
/* 0x6 */ u8 red;
/* 0x7 */ u8 green;
/* 0x8 */ u8 blue;
/* 0x9 */ u8 unk_09;
/* 0xA */ s16 radius;
} LightInfoPositionalParams;
typedef struct {
/* 0x00 */ u8 numLights;
/* 0x01 */ u8 enablePosLights;
/* 0x02 */ UNK_TYPE1 pad2[6];
/* 0x08 */ Ambient ambient;
/* 0x10 */ Light lights[7];
} LightMapper;
typedef struct {
/* 0x0 */ u8 type;
/* 0x2 */ LightInfoDirectionalParams params;
} LightInfoDirectional;
typedef struct {
/* 0x0 */ u8 type;
/* 0x2 */ LightInfoPositionalParams params;
} LightInfoPositional;
typedef void (*LightsBindFunc)(Lights* lights, LightParams* params, Vec3f* vec);
#endif