diff --git a/include/PR/gbi.h b/include/PR/gbi.h index 5f58904002..2c04e570f7 100644 --- a/include/PR/gbi.h +++ b/include/PR/gbi.h @@ -1261,6 +1261,16 @@ typedef struct { char pad3; } Light_t; +// Added in MM +typedef struct { + unsigned char col[3]; + unsigned char unk3; + unsigned char colc[3]; + unsigned char unk7; + short pos[3]; + unsigned char unkE; +} PointLight_t; + typedef struct { unsigned char col[3]; /* ambient light value (rgba) */ char pad1; @@ -1273,7 +1283,8 @@ typedef struct { } Hilite_t; typedef union { - Light_t l; + Light_t l; + PointLight_t p; long long int force_structure_alignment[2]; } Light; diff --git a/include/color.h b/include/color.h index f2fe275668..4d287c27fa 100644 --- a/include/color.h +++ b/include/color.h @@ -4,23 +4,38 @@ #include typedef struct { - /* 0x0 */ u8 red; - /* 0x1 */ u8 green; - /* 0x2 */ u8 blue; - /* 0x3 */ u8 alpha; -} ColorRGBA8; // size = 0x4 + /* 0x0 */ u8 r; + /* 0x1 */ u8 g; + /* 0x2 */ u8 b; +} Color_RGB8; // size = 0x3 typedef struct { - /* 0x0 */ u8 red; - /* 0x1 */ u8 green; - /* 0x2 */ u8 blue; -} RGB; // size = 0x3 + /* 0x0 */ u8 r; + /* 0x1 */ u8 g; + /* 0x2 */ u8 b; + /* 0x3 */ u8 a; +} Color_RGBA8; // size = 0x4 + +// only use when necessary for alignment purposes +typedef union { + struct { + u8 r, g, b, a; + }; + u32 rgba; +} Color_RGBA8_u32; typedef struct { - /* 0x0 */ u8 red; - /* 0x1 */ u8 green; - /* 0x2 */ u8 blue; - /* 0x3 */ u8 alpha; -} RGBA8; // size = 0x4 + f32 r, g, b, a; +} Color_RGBAf; + +typedef union { + struct { + u16 r : 5; + u16 g : 5; + u16 b : 5; + u16 a : 1; + }; + u16 rgba; +} Color_RGB5A1; #endif diff --git a/include/functions.h b/include/functions.h index 03213eb1d9..35d0503856 100644 --- a/include/functions.h +++ b/include/functions.h @@ -551,17 +551,17 @@ void EffectBlure_Draw(EffBlureParams* params, GraphicsContext* gCtxt); void EffectShieldParticle_Init(EffShieldParticleParams* params, EffShieldParticleInit* init); void EffectShieldParticle_Destroy(EffShieldParticleParams* params); s32 EffectShieldParticle_Update(EffShieldParticleParams* params); -void EffectShieldParticle_CalculateColors(EffShieldParticleParams* params, ColorRGBA8* primColor, ColorRGBA8* envColor); +void EffectShieldParticle_CalculateColors(EffShieldParticleParams* params, Color_RGBA8* primColor, Color_RGBA8* envColor); void EffectShieldParticle_Draw(EffShieldParticleParams* params, GraphicsContext* gCtxt); void EffectSpark_Init(EffSparkParams* params, EffSparkParams* init); void EffectSpark_Destroy(EffSparkParams* params); s32 EffectSpark_Update(EffSparkParams* params); void EffectSpark_Draw(EffSparkParams* params, GraphicsContext* gCtxt); // void func_800AE2A0(void); -void func_800AE434(GlobalContext* ctxt, ColorRGBA8* color, s16 sParm3, s16 sParm4); +void func_800AE434(GlobalContext* ctxt, Color_RGBA8* color, s16 sParm3, s16 sParm4); void func_800AE5A0(GlobalContext* ctxt); // void func_800AE5E4(void); -void func_800AE778(GlobalContext* ctxt, ColorRGBA8* color, s16 param_3, s16 param_4); +void func_800AE778(GlobalContext* ctxt, Color_RGBA8* color, s16 param_3, s16 param_4); void func_800AE8EC(GlobalContext* ctxt); void func_800AE930(CollisionContext* bgCtxt, s32 param_2, float* param_3, f32 param_4, s16 param_5, BgPolygon* param_6, s32 param_7); // void func_800AEF44(void); @@ -596,7 +596,7 @@ s32 func_800B096C(s16 param_1, s16 param_2, s32 param_3); s16 func_800B09D0(s16 a0, s16 a1, f32 a2); u8 func_800B0A24(u8 a0, u8 a1, f32 a2); void func_800B0B10(GlobalContext* ctxt, LoadedParticleEntry* particle, u32 uParm3); -void EffectSS_SpawnDust(GlobalContext* ctxt, u16 flags, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, ColorRGBA8* color1, ColorRGBA8* color2, s16 scale, s16 scaleChangePerFrame, s16 life, u8 type); +void EffectSS_SpawnDust(GlobalContext* ctxt, u16 flags, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, Color_RGBA8* color1, Color_RGBA8* color2, s16 scale, s16 scaleChangePerFrame, s16 life, u8 type); // void func_800B0DE0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8); // void func_800B0E48(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8); // void func_800B0EB0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9); @@ -621,11 +621,11 @@ void EffectSS_SpawnDust(GlobalContext* ctxt, u16 flags, Vec3f* position, Vec3f* // void func_800B1830(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE2 param_7, UNK_TYPE4 param_8); // void EffectSS_SpawnBomb2(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4); // void func_800B1970(UNK_TYPE4 param_1, Vec3f* param_2, Vec3f* param_3, Vec3f* param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6); -// void EffectSS_SpawnBlast(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, ColorRGBA8* param_5, ColorRGBA8* param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10); +// void EffectSS_SpawnBlast(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, Color_RGBA8* param_5, Color_RGBA8* param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10); // void func_800B1A70(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7); // void func_800B1AC4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE2 param_7); // void func_800B1B10(void); -// void EffectSS_SpawnGSpark(UNK_TYPE4 uParm1, UNK_TYPE4 uParm2, Vec3f* pzParm3, Vec3f* pzParm4, Vec3f* param_5, ColorRGBA8* param_6, ColorRGBA8* param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9); +// void EffectSS_SpawnGSpark(UNK_TYPE4 uParm1, UNK_TYPE4 uParm2, Vec3f* pzParm3, Vec3f* pzParm4, Vec3f* param_5, Color_RGBA8* param_6, Color_RGBA8* param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9); // void func_800B1BDC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9); // void func_800B1C70(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_800B1CC4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7); @@ -633,9 +633,9 @@ void EffectSS_SpawnDust(GlobalContext* ctxt, u16 flags, Vec3f* position, Vec3f* // void EffectSS_SpawnDodongoFire(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE4 param_10); // void EffectSS_SpawnBubble(UNK_TYPE4 uParm1, Vec3f* pzParm2, UNK_TYPE4 uParm3, UNK_TYPE4 uParm4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); // void EffectSS_SpawnGRipple(UNK_TYPE4 uParm1, Vec3f* pzParm2, UNK_TYPE2 uParm3, UNK_TYPE2 uParm4, UNK_TYPE2 param_5); -void EffectSS_SpawnGSplash(GlobalContext *globalCtx, Vec3f* pzParm2, ColorRGBA8* primaryCol, ColorRGBA8* envCol, s16 type, s16 scale); +void EffectSS_SpawnGSplash(GlobalContext *globalCtx, Vec3f* pzParm2, Color_RGBA8* primaryCol, Color_RGBA8* envCol, s16 type, s16 scale); // void EffectSS_SpawnGFire(UNK_TYPE4 uParm1, Vec3f* pzParm2); -// void EffectSS_SpawnLightning(UNK_TYPE4 uParm1, Vec3f* pzParm2, ColorRGBA8* pzParm3, ColorRGBA8* pzParm4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8); +// void EffectSS_SpawnLightning(UNK_TYPE4 uParm1, Vec3f* pzParm2, Color_RGBA8* pzParm3, Color_RGBA8* pzParm4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8); // void func_800B2090(UNK_TYPE4 param_1, Vec3f* param_2, Vec3f* param_3, Vec3f* param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8); // void EffectSS_SpawnBigOctoBubble2(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9); // void EffectSS_SpawnFragment(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE4 param_9); @@ -654,11 +654,11 @@ void EffectSS_SpawnGSplash(GlobalContext *globalCtx, Vec3f* pzParm2, ColorRGBA8* void EffectSS_SpawnShard(GlobalContext *globalCtx, Vec3f *pos, Vec3f *vel, Vec3f *param_4, s16 gravity, s16 param_6, s16 param_7, s16 param_8, s16 param_9, s16 param_10, s16 param_11,s16 param_12, s32 param_13, s16 param_14, s16 param_15, Gfx* dList); // void EffectSS_SpawnIcePiece(UNK_TYPE4 uParm1, Vec3f* pzParm2, UNK_TYPE4 uParm3, Vec3f* pzParm4, Vec3f* param_5, UNK_TYPE4 param_6); // void func_800B2930(void); -// void EffectSS_SpawnEnemyIce(UNK_TYPE4 uParm1, Actor* pzParm2, Vec3f* pzParm3, ColorRGBA8* pzParm4, ColorRGBA8* param_5, UNK_TYPE4 param_6); +// void EffectSS_SpawnEnemyIce(UNK_TYPE4 uParm1, Actor* pzParm2, Vec3f* pzParm3, Color_RGBA8* pzParm4, Color_RGBA8* param_5, UNK_TYPE4 param_6); // void func_800B2B44(void); // void func_800B2B7C(void); // void func_800B2BC0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8); -// void EffectSS_SpawnFireTail(UNK_TYPE4 uParm1, UNK_TYPE4 uParm2, Vec3f* pzParm3, UNK_TYPE4 uParm4, Vec3f* param_5, UNK_TYPE2 param_6, ColorRGBA8* param_7, ColorRGBA8* param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10, UNK_TYPE4 param_11); +// void EffectSS_SpawnFireTail(UNK_TYPE4 uParm1, UNK_TYPE4 uParm2, Vec3f* pzParm3, UNK_TYPE4 uParm4, Vec3f* param_5, UNK_TYPE2 param_6, Color_RGBA8* param_7, Color_RGBA8* param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10, UNK_TYPE4 param_11); // void func_800B2CE0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE4 param_6); // void func_800B2DA4(void); // void EffectSS_SpawnEnemyFire(UNK_TYPE4 uParm1, Actor* pzParm2, Vec3f* pzParm3, UNK_TYPE2 uParm4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7); @@ -677,13 +677,13 @@ void DLF_LoadGameState(GameStateOverlay* gameState); void DLF_FreeGameState(GameStateOverlay* gameState); void Actor_PrintLists(ActorContext* actCtxt); void Actor_SetDrawParams(ActorShape* actorShape, f32 yOffset, ActorShadowFunc func, f32 scale); -void Actor_PostDraw(Actor* actor, LightMapper* mapper, GlobalContext* ctxt, u32 displayList, ColorRGBA8* color); -void func_800B3FC0(Actor* actor, LightMapper* mapper, GlobalContext* ctxt); -void func_800B4024(Actor* actor, LightMapper* mapper, GlobalContext* ctxt); -void func_800B4088(Actor* actor, LightMapper* mapper, GlobalContext* ctxt); -void func_800B40B8(Actor* actor, LightMapper* mapper, GlobalContext* ctxt); +void Actor_PostDraw(Actor* actor, Lights* mapper, GlobalContext* ctxt, u32 displayList, Color_RGBA8* color); +void func_800B3FC0(Actor* actor, Lights* mapper, GlobalContext* ctxt); +void func_800B4024(Actor* actor, Lights* mapper, GlobalContext* ctxt); +void func_800B4088(Actor* actor, Lights* mapper, GlobalContext* ctxt); +void func_800B40B8(Actor* actor, Lights* mapper, GlobalContext* ctxt); void func_800B40E0(GlobalContext* ctxt, s32 iParm2, z_Matrix* pzParm3, s32 iParm4, f32 param_5, f32 param_6, f32 param_7); -void func_800B42F8(Actor* actor, LightMapper* mapper, GlobalContext* ctxt); +void func_800B42F8(Actor* actor, Lights* mapper, GlobalContext* ctxt); // void func_800B4A98(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); void func_800B4AEC(GlobalContext* ctxt, Actor* actor, f32 param_3); void func_800B4B50(Actor* actor, s32 iParm2, GlobalContext* pzParm3); @@ -1741,12 +1741,12 @@ void func_800F6B44(GlobalContext* ctxt, KankyoContext* kanCtxt, s32 iParm3, s32 // void func_800F6CEC(void); // void func_800F6EA4(void); // UNK_TYPE4 Kankyo_IsSceneUpsideDown(GlobalContext* ctxt); -void func_800F6FF8(GlobalContext* ctxt, KankyoContext* kanCtxt, LightingContext* lCtxt); +void func_800F6FF8(GlobalContext* ctxt, KankyoContext* kanCtxt, LightContext* lCtxt); // void func_800F8554(void); // void func_800F88C4(void); // void func_800F8970(void); // void func_800F8A9C(void); -// void func_800F8CD4(GlobalContext* ctxt, KankyoContext* kanCtxt, LightingContext* lCtxt, s32 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); +// void func_800F8CD4(GlobalContext* ctxt, KankyoContext* kanCtxt, LightContext* lCtxt, s32 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); // void func_800F8D84(void); // void func_800F9728(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); // void func_800F9824(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE2 param_10, UNK_TYPE1 param_11); @@ -1769,10 +1769,10 @@ void func_800FBF3C(GlobalContext* ctxt); // void func_800FC444(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5, UNK_TYPE1 param_6); // void func_800FC64C(void); // void func_800FD2B4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -void func_800FD538(RGB* param_1, RGB* param_2, f32 param_3, Vec3s* param_4); -void func_800FD59C(GlobalContext* ctxt, RGB* pzParm2, f32 fParm3); -void func_800FD5E0(GlobalContext* ctxt, RGB* pzParm2, f32 fParm3); -void func_800FD654(GlobalContext* ctxt, RGB* pzParm2, f32 fParm3); +void func_800FD538(Color_RGB8* param_1, Color_RGB8* param_2, f32 param_3, Vec3s* param_4); +void func_800FD59C(GlobalContext* ctxt, Color_RGB8* pzParm2, f32 fParm3); +void func_800FD5E0(GlobalContext* ctxt, Color_RGB8* pzParm2, f32 fParm3); +void func_800FD654(GlobalContext* ctxt, Color_RGB8* pzParm2, f32 fParm3); // void func_800FD698(void); // u32 get_days_elapsed(void); // void reset_days_elapsed(void); @@ -1863,12 +1863,12 @@ void Math_SmoothScaleMaxF(f32* start, f32 target, f32 scale, f32 maxStep); void Math_SmoothDownscaleMaxF(f32* start, f32 scale, f32 maxStep); s32 Math_SmoothScaleMaxMinS(s16* start, s16 target, s16 scale, s16 maxStep, s16 minStep); void Math_SmoothScaleMaxS(s16* start, s16 target, s16 scale, s16 maxStep); -void Color_RGBA8_Copy(ColorRGBA8* dst, ColorRGBA8* src); +void Color_RGBA8_Copy(Color_RGBA8* dst, Color_RGBA8* src); void func_801000A4(u16 param_1); void func_801000CC(u16 param_1); void func_801000F4(UNK_TYPE4 param_1, u16 param_2); void Lib_TranslateAndRotateYVec3f(Vec3f* translation, s16 rotation, Vec3f* src, Vec3f* dst); -void Lib_LerpRGB(RGB* a, RGB* b, f32 t, RGB* dst); +void Lib_LerpRGB(Color_RGB8* a, Color_RGB8* b, f32 t, Color_RGB8* dst); f32 Lib_PushAwayVec3f(Vec3f* start, Vec3f* pusher, f32 distanceToApproach); void Lib_Nop801004FC(void); void* Lib_PtrSegToVirt(void* ptr); @@ -1883,33 +1883,33 @@ void LifeMeter_UpdateColors(GlobalContext* ctxt); void LifeMeter_Draw(GlobalContext* ctxt); void LifeMeter_UpdateSizeAndBeep(GlobalContext* ctxt); // s32 LifeMeter_IsCritical(void); -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_SetPositionalLightPosition(LightInfoPositional* info, s16 posX, s16 posY, s16 posZ); -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); -void Lights_UploadLights(LightMapper* mapper, GraphicsContext* gCtxt); -Light* Lights_MapperGetNextFreeSlot(LightMapper* mapper); -void Lights_MapPositionalWithReference(LightMapper* mapper, LightInfoPositionalParams* params, Vec3f* pos); -void Lights_MapPositional(LightMapper* mapper, LightInfoPositionalParams* params, GlobalContext* ctxt); -void Lights_MapDirectional(LightMapper* mapper, LightInfoDirectionalParams* params, GlobalContext* ctxt); -void Lights_MapLights(LightMapper* mapper, z_Light* lights, Vec3f* refPos, GlobalContext* ctxt); -z_Light* Lights_FindFreeSlot(void); -void Lights_Free(z_Light* light); -void Lights_Init(GlobalContext* ctxt, LightingContext* lCtxt); -void Lights_SetAmbientColor(LightingContext* lCtxt, u8 red, u8 green, u8 blue); -void func_80102544(LightingContext* lCtxt, u8 a1, u8 a2, u8 a3, s16 sp12, s16 sp16); -LightMapper* Lights_CreateMapper(LightingContext* lCtxt, GraphicsContext* gCtxt); -void Lights_ClearHead(GlobalContext* ctxt, LightingContext* lCtxt); -void Lights_RemoveAll(GlobalContext* ctxt, LightingContext* lCtxt); -z_Light* Lights_Insert(GlobalContext* ctxt, LightingContext* lCtxt, LightInfo* info); -void Lights_Remove(GlobalContext* ctxt, LightingContext* lCtxt, z_Light* light); -LightMapper* func_801026E8(GraphicsContext* gCtxt, u8 ambientRed, u8 ambientGreen, u8 ambientBlue, u8 numLights, u8 red, u8 green, u8 blue, s8 dirX, s8 dirY, s8 dirZ); -LightMapper* Lights_MapperAllocateAndInit(GraphicsContext* gCtxt, u8 red, u8 green, u8 blue); -void func_80102880(GlobalContext* ctxt); -void func_80102A64(GlobalContext* ctxt); +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, GlobalContext* globalCtx); +void Lights_BindDirectional(Lights* lights, LightParams* params, void* unused); +void Lights_BindAll(Lights* lights, LightNode* listHead, Vec3f* refPos, GlobalContext* globalCtx); +LightNode* Lights_FindBufSlot(); +void Lights_FreeNode(LightNode* light); +void LightContext_Init(GlobalContext* globalCtx, LightContext* lightCtx); +void LightContext_SetAmbientColor(LightContext* lightCtx, u8 r, u8 g, u8 b); +void func_80102544(LightContext* lightCtx, u8 a1, u8 a2, u8 a3, s16 numLights, s16 sp16); +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* 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(GlobalContext* globalCtx); +void Lights_DrawGlow(GlobalContext* globalCtx); void* zelda_malloc(u32 size); void* zelda_mallocR(u32 size); void* zelda_realloc(void* oldPtr, u32 newSize); @@ -2481,7 +2481,7 @@ Gfx* SceneProc_SetTile1Layer(GlobalContext* ctxt, ScrollingTextureParams* params void SceneProc_DrawType0Texture(GlobalContext* ctxt, u32 segment, ScrollingTextureParams* params); Gfx* SceneProc_SetTile2Layers(GlobalContext* ctxt, ScrollingTextureParams* params); void SceneProc_DrawType1Texture(GlobalContext* ctxt, u32 segment, ScrollingTextureParams* params); -void SceneProc_DrawFlashingTexture(GlobalContext* ctxt, u32 segment, FlashingTexturePrimColor* primColor, RGBA8* envColor); +void SceneProc_DrawFlashingTexture(GlobalContext* ctxt, u32 segment, FlashingTexturePrimColor* primColor, Color_RGBA8* envColor); void SceneProc_DrawType2Texture(GlobalContext* ctxt, u32 segment, FlashingTextureParams* params); s32 SceneProc_Lerp(s32 a, s32 b, f32 t); void SceneProc_DrawType3Texture(GlobalContext* ctxt, u32 segment, FlashingTextureParams* params); diff --git a/include/variables.h b/include/variables.h index 42efca03fd..80977e89f7 100644 --- a/include/variables.h +++ b/include/variables.h @@ -432,14 +432,14 @@ extern UNK_PTR D_801AE8F0; // extern UNK_TYPE4 D_801AEC70; // extern UNK_TYPE4 D_801AEC74; // extern UNK_TYPE4 D_801AEC78; -extern ColorRGBA8 D_801AEC80; +extern Color_RGBA8 D_801AEC80; extern s801AEC84 D_801AEC84[13]; extern f32 actorMovementScale; extern f32 D_801AECF0; extern f32 D_801AECF4; // extern UNK_TYPE1 D_801AED48; // extern UNK_TYPE4 D_801AED58; -extern ColorRGBA8 actorDefaultHitColor; +extern Color_RGBA8 actorDefaultHitColor; // extern UNK_TYPE1 D_801AED8C; // extern UNK_TYPE4 D_801AED98; // extern UNK_TYPE4 D_801AEDA4; @@ -1033,8 +1033,8 @@ extern actor_init_var_func actorInitVarFuncs[11]; // extern UNK_TYPE2 D_801BEA20; // extern UNK_TYPE1 D_801BEA30; // extern UNK_TYPE1 D_801BEA70; -extern light_map_positional_func lightPositionalMapFuncs[3]; -extern light_map_directional_func lightDirectionalMapFuncs[3]; +//extern LightsPosBindFunc posBindFuncs[3]; +//extern LightsBindFunc dirBindFuncs[3]; // extern UNK_TYPE4 D_801BEAD4; // extern UNK_TYPE4 D_801BEAD8; // extern UNK_TYPE1 D_801BEAE0; @@ -4017,7 +4017,7 @@ extern f32 D_801F4E70; // extern UNK_TYPE1 D_801F4F66; // extern UNK_TYPE1 D_801F4F68; // extern UNK_TYPE1 D_801F4F6A; -extern LightsList lightsList; +extern LightsBuffer sLightsBuffer; extern Arena mainHeap; // extern UNK_TYPE1 D_801F5130; // extern UNK_TYPE1 D_801F5270; @@ -4090,7 +4090,7 @@ extern Input D_801F6C18; // extern UNK_TYPE1 D_801F6D0C; extern UNK_TYPE4 D_801F6D10; // extern UNK_TYPE1 D_801F6D18; -extern ColorRGBA8 D_801F6D30; +extern Color_RGBA8 D_801F6D30; // extern UNK_TYPE1 D_801F6D38; // extern UNK_TYPE4 D_801F6D4C; // extern UNK_TYPE1 D_801F6D50; diff --git a/include/z64.h b/include/z64.h index fec555b48e..a2252eb511 100644 --- a/include/z64.h +++ b/include/z64.h @@ -394,7 +394,7 @@ typedef struct { /* 0x04 */ UNK_TYPE4 unk4; /* 0x08 */ UNK_TYPE4 unk8; /* 0x0C */ f32 unkC; - /* 0x10 */ ColorRGBA8 unk10; + /* 0x10 */ Color_RGBA8 unk10; } TargetContextEntry; // size = 0x14 typedef struct { @@ -444,8 +444,6 @@ typedef void(*func_ptr)(void); typedef void(*actor_init_var_func)(u8*, InitChainEntry*); -typedef void(*light_map_directional_func)(LightMapper* mapper, void* params, Vec3f* pos); - typedef void(*osCreateThread_func)(void*); typedef void*(*printf_func)(void*, char*, size_t); @@ -593,7 +591,7 @@ typedef struct { /* 0x0 */ u16 cycleLength; /* 0x2 */ u16 numKeyFrames; /* 0x4 */ FlashingTexturePrimColor* primColors; - /* 0x8 */ RGBA8* envColors; + /* 0x8 */ Color_RGBA8* envColors; /* 0xC */ u16* keyFrames; } FlashingTextureParams; // size = 0x10 @@ -802,8 +800,8 @@ typedef struct { /* 0x24 */ u16 unk24; /* 0x26 */ UNK_TYPE1 unk26; /* 0x27 */ UNK_TYPE1 unk27; - /* 0x28 */ LightInfoDirectional unk28; - /* 0x36 */ LightInfoDirectional unk36; + /* 0x28 */ LightInfo unk28; + /* 0x36 */ LightInfo unk36; /* 0x44 */ UNK_TYPE1 unk44; /* 0x45 */ UNK_TYPE1 unk45; /* 0x46 */ UNK_TYPE1 unk46; @@ -901,16 +899,16 @@ typedef struct { /* 0xC1 */ u8 unkC1; /* 0xC2 */ u8 unkC2; /* 0xC3 */ u8 unkC3; - /* 0xC4 */ RGB unkC4; + /* 0xC4 */ Color_RGB8 unkC4; /* 0xC7 */ s8 unkC7; /* 0xC8 */ s8 unkC8; /* 0xC9 */ s8 unkC9; - /* 0xCA */ RGB unkCA; + /* 0xCA */ Color_RGB8 unkCA; /* 0xCD */ s8 unkCD; /* 0xCE */ s8 unkCE; /* 0xCF */ s8 unkCF; - /* 0xD0 */ RGB unkD0; - /* 0xD3 */ RGB unkD3; + /* 0xD0 */ Color_RGB8 unkD0; + /* 0xD3 */ Color_RGB8 unkD3; /* 0xD6 */ s16 unkD6; /* 0xD8 */ s16 unkD8; /* 0xDA */ UNK_TYPE1 unkDA; @@ -1278,8 +1276,6 @@ typedef void(*draw_func)(GlobalContext* ctxt, s16 index); typedef void(*global_context_func)(GlobalContext*); -typedef void(*light_map_positional_func)(LightMapper* mapper, void* params, GlobalContext* ctxt); - typedef void(*room_draw_func)(GlobalContext* ctxt, Room* room, u32 flags); typedef struct { @@ -1416,7 +1412,7 @@ typedef struct ActorContext ActorContext; typedef struct s800B948C s800B948C; struct FireObjLight { - /* 0x00 */ z_Light* light; + /* 0x00 */ LightNode* light; /* 0x04 */ LightInfoPositional lightInfo; /* 0x12 */ u8 unk12; }; // size = 0x13 @@ -1610,7 +1606,7 @@ struct GlobalContext { /* 0x00814 */ u8 unk814; /* 0x00815 */ u8 unk815; /* 0x00816 */ UNK_TYPE1 pad816[0x2]; - /* 0x00818 */ LightingContext lightCtx; + /* 0x00818 */ LightContext lightCtx; /* 0x00828 */ u32 unk828; /* 0x0082C */ UNK_TYPE1 pad82C[0x4]; /* 0x00830 */ CollisionContext colCtx; @@ -1787,22 +1783,22 @@ struct ActorBgIknvObj { typedef struct { /* 0x00 */ u32 type; /* 0x04 */ u32 setScissor; - /* 0x08 */ ColorRGBA8 color; - /* 0x0C */ ColorRGBA8 envColor; + /* 0x08 */ Color_RGBA8 color; + /* 0x0C */ Color_RGBA8 envColor; } struct_801F8010; // size = 0x10 typedef struct { /* 0x00 */ u32 useRgba; /* 0x04 */ u32 setScissor; - /* 0x08 */ ColorRGBA8 primColor; - /* 0x08 */ ColorRGBA8 envColor; + /* 0x08 */ Color_RGBA8 primColor; + /* 0x08 */ Color_RGBA8 envColor; } struct_801F8020; // size = 0x10 typedef struct { /* 0x00 */ u32 unk_00; /* 0x04 */ u32 setScissor; - /* 0x08 */ ColorRGBA8 primColor; - /* 0x0C */ ColorRGBA8 envColor; + /* 0x08 */ Color_RGBA8 primColor; + /* 0x0C */ Color_RGBA8 envColor; /* 0x10 */ u16* tlut; /* 0x14 */ Gfx* monoDl; } VisMono; // size = 0x18 diff --git a/include/z64actor.h b/include/z64actor.h index 34520966a7..8de48871f6 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -11,7 +11,7 @@ struct Actor; struct GlobalContext; -struct LightMapper; +struct Lights; struct BgPolygon; typedef void(*ActorFunc)(struct Actor* this, struct GlobalContext* ctxt); @@ -106,7 +106,7 @@ typedef struct { /* 0x1F */ UNK_TYPE1 pad1F[0x1]; } ActorOverlay; // size = 0x20 -typedef void(*ActorShadowFunc)(struct Actor* actor, struct LightMapper* mapper, struct GlobalContext* ctxt); +typedef void(*ActorShadowFunc)(struct Actor* actor, struct Lights* mapper, struct GlobalContext* ctxt); typedef struct { /* 0x00 */ Vec3s rot; // Current actor shape rotation diff --git a/include/z64effect.h b/include/z64effect.h index aa5519de05..4c96a296d9 100644 --- a/include/z64effect.h +++ b/include/z64effect.h @@ -40,8 +40,8 @@ typedef struct { /* 0x490 */ f32 gravity; /* 0x494 */ u32 particleFactor1; /* 0x498 */ u32 particleFactor2; - /* 0x49C */ ColorRGBA8 colorStart[4]; - /* 0x4AC */ ColorRGBA8 colorEnd[4]; + /* 0x49C */ Color_RGBA8 colorStart[4]; + /* 0x4AC */ Color_RGBA8 colorEnd[4]; /* 0x4BC */ s32 age; /* 0x4C0 */ s32 duration; } EffSparkParams; // size = 0x4C4 @@ -57,19 +57,19 @@ typedef struct { typedef struct { /* 0x000 */ UNK_TYPE1 pad0[0x184]; - /* 0x184 */ ColorRGBA8 unk184; - /* 0x188 */ ColorRGBA8 unk188; - /* 0x18C */ ColorRGBA8 unk18C; - /* 0x190 */ ColorRGBA8 unk190; + /* 0x184 */ Color_RGBA8 unk184; + /* 0x188 */ Color_RGBA8 unk188; + /* 0x18C */ Color_RGBA8 unk18C; + /* 0x190 */ Color_RGBA8 unk190; /* 0x194 */ UNK_TYPE1 pad194[0xC]; } EffBlureInit1; // size = 0x1A0 typedef struct { /* 0x00 */ UNK_TYPE1 pad0[0x8]; - /* 0x08 */ ColorRGBA8 unk8; - /* 0x0C */ ColorRGBA8 unkC; - /* 0x10 */ ColorRGBA8 unk10; - /* 0x14 */ ColorRGBA8 unk14; + /* 0x08 */ Color_RGBA8 unk8; + /* 0x0C */ Color_RGBA8 unkC; + /* 0x10 */ Color_RGBA8 unk10; + /* 0x14 */ Color_RGBA8 unk14; /* 0x18 */ UNK_TYPE1 pad18[0xC]; } EffBlureInit2; // size = 0x24 @@ -79,10 +79,10 @@ typedef struct { /* 0x184 */ f32 unk184; /* 0x188 */ u16 unk188; /* 0x18A */ UNK_TYPE1 pad18A[0x4]; - /* 0x18E */ ColorRGBA8 unk18E; - /* 0x192 */ ColorRGBA8 unk192; - /* 0x196 */ ColorRGBA8 unk196; - /* 0x19A */ ColorRGBA8 unk19A; + /* 0x18E */ Color_RGBA8 unk18E; + /* 0x192 */ Color_RGBA8 unk192; + /* 0x196 */ Color_RGBA8 unk196; + /* 0x19A */ Color_RGBA8 unk19A; /* 0x19E */ u8 unk19E; /* 0x19F */ u8 unk19F; /* 0x1A0 */ u8 unk1A0; @@ -108,17 +108,17 @@ typedef struct { typedef struct { /* 0x00 */ u8 numParticles; /* 0x02 */ Vec3s position; - /* 0x08 */ ColorRGBA8 primColorStart; - /* 0x0C */ ColorRGBA8 envColorStart; - /* 0x10 */ ColorRGBA8 primColorMid; - /* 0x14 */ ColorRGBA8 envColorMid; - /* 0x18 */ ColorRGBA8 primColorEnd; - /* 0x1C */ ColorRGBA8 envColorEnd; + /* 0x08 */ Color_RGBA8 primColorStart; + /* 0x0C */ Color_RGBA8 envColorStart; + /* 0x10 */ Color_RGBA8 primColorMid; + /* 0x14 */ Color_RGBA8 envColorMid; + /* 0x18 */ Color_RGBA8 primColorEnd; + /* 0x1C */ Color_RGBA8 envColorEnd; /* 0x20 */ f32 acceleration; /* 0x24 */ f32 maxInitialSpeed; /* 0x28 */ f32 lengthCutoff; /* 0x2C */ u8 duration; - /* 0x2E */ LightInfoPositionalParams lightParams; + /* 0x2E */ LightPoint lightPoint; /* 0x3C */ s32 hasLight; } EffShieldParticleInit; // size = 0x40 @@ -127,12 +127,12 @@ typedef struct { /* 0x180 */ u8 numParticles; /* 0x181 */ UNK_TYPE1 pad181[0x1]; /* 0x182 */ Vec3s position; - /* 0x188 */ ColorRGBA8 primColorStart; - /* 0x18C */ ColorRGBA8 envColorStart; - /* 0x190 */ ColorRGBA8 primColorMid; - /* 0x194 */ ColorRGBA8 envColorMid; - /* 0x198 */ ColorRGBA8 primColorEnd; - /* 0x19C */ ColorRGBA8 envColorEnd; + /* 0x188 */ Color_RGBA8 primColorStart; + /* 0x18C */ Color_RGBA8 envColorStart; + /* 0x190 */ Color_RGBA8 primColorMid; + /* 0x194 */ Color_RGBA8 envColorMid; + /* 0x198 */ Color_RGBA8 primColorEnd; + /* 0x19C */ Color_RGBA8 envColorEnd; /* 0x1A0 */ f32 acceleration; /* 0x1A4 */ UNK_TYPE1 pad1A4[0x4]; /* 0x1A8 */ f32 maxInitialSpeed; @@ -140,7 +140,7 @@ typedef struct { /* 0x1B0 */ u8 duration; /* 0x1B1 */ u8 age; /* 0x1B2 */ LightInfo lightInfo; - /* 0x1C0 */ z_Light* light; + /* 0x1C0 */ LightNode* light; /* 0x1C4 */ s32 hasLight; } EffShieldParticleParams; // size = 0x1C8 @@ -161,7 +161,7 @@ typedef struct { typedef struct { /* 0x0 */ s16 unk0; /* 0x2 */ s16 maxLife; - /* 0x4 */ ColorRGBA8 color; + /* 0x4 */ Color_RGBA8 color; } EffTireMarkInit; // size = 0x8 typedef struct { @@ -169,7 +169,7 @@ typedef struct { /* 0x600 */ s16 unk600; /* 0x602 */ s16 numParticles; /* 0x604 */ s16 maxLife; - /* 0x606 */ ColorRGBA8 color; + /* 0x606 */ Color_RGBA8 color; /* 0x60A */ UNK_TYPE1 pad60A[0x2]; } EffTireMarkParams; // size = 0x60C @@ -198,8 +198,8 @@ typedef struct { /* 0x00 */ Vec3f position; /* 0x0C */ Vec3f velocity; /* 0x18 */ Vec3f acceleration; - /* 0x24 */ ColorRGBA8 color1; - /* 0x28 */ ColorRGBA8 color2; + /* 0x24 */ Color_RGBA8 color1; + /* 0x28 */ Color_RGBA8 color2; /* 0x2C */ s16 scale; /* 0x2E */ s16 scaleChangePerFrame; /* 0x30 */ s16 life; diff --git a/include/z64light.h b/include/z64light.h index eeb1cbac40..cbfe663518 100644 --- a/include/z64light.h +++ b/include/z64light.h @@ -3,72 +3,79 @@ #include #include +#include + +typedef struct { + /* 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 */ u16 params[6]; + /* 0x2 */ LightParams params; } LightInfo; // size = 0xE -typedef struct z_Light_t { - /* 0x0 */ LightInfo* info; - /* 0x4 */ struct z_Light_t* prev; - /* 0x8 */ struct z_Light_t* next; -} z_Light; // size = 0xC +typedef struct { + /* 0x00 */ u8 enablePosLights; + /* 0x01 */ u8 numLights; + /* 0x08 */ Lightsn l; +} Lights; // size = 0x80 typedef struct { - /* 0x0 */ z_Light* lightsHead; - /* 0x4 */ u8 ambientRed; - /* 0x5 */ u8 ambientGreen; - /* 0x6 */ u8 ambientBlue; + /* 0x0 */ u8 type; + /* 0x2 */ LightPoint params; +} LightInfoPositional; // size = 0xE + +typedef struct LightNode { + /* 0x0 */ LightInfo* info; + /* 0x4 */ struct LightNode* prev; + /* 0x8 */ struct LightNode* next; +} LightNode; // size = 0xC + +// TODO move LightsBuffer to .c file once .bss has been split +#define LIGHTS_BUFFER_SIZE 32 + +typedef struct { + /* 0x000 */ s32 numOccupied; + /* 0x004 */ s32 searchIndex; + /* 0x008 */ LightNode lights[LIGHTS_BUFFER_SIZE]; +} LightsBuffer; // size = 0x188 + +typedef struct { + /* 0x0 */ LightNode* listHead; + /* 0x4 */ Color_RGB8 ambient; /* 0x7 */ u8 unk7; /* 0x8 */ u8 unk8; /* 0x9 */ u8 unk9; /* 0xA */ s16 unkA; /* 0xC */ s16 unkC; -} LightingContext; // size = 0x10 +} LightContext; // size = 0x10 -typedef struct { - /* 0x000 */ s32 numOccupied; - /* 0x004 */ s32 nextFree; - /* 0x008 */ z_Light lights[32]; -} LightsList; // size = 0x188 +typedef enum { + /* 0x00 */ LIGHT_POINT_NOGLOW, + /* 0x01 */ LIGHT_DIRECTIONAL, + /* 0x02 */ LIGHT_POINT_GLOW +} LightType; -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; // size = 0xC +typedef struct GlobalContext GlobalContext; -typedef struct { - /* 0x0 */ s16 posX; - /* 0x2 */ s16 posY; - /* 0x4 */ s16 posZ; - /* 0x6 */ u8 red; - /* 0x7 */ u8 green; - /* 0x8 */ u8 blue; - /* 0x9 */ u8 unk9; // func_80102880 sets this only for type 2, func_80102A64 draws something if this is set - /* 0xA */ s16 radius; -} LightInfoPositionalParams; // size = 0xC - -typedef struct { - /* 0x00 */ u8 enablePosLights; - /* 0x01 */ u8 numLights; - /* 0x02 */ UNK_TYPE1 pad2[6]; - /* 0x08 */ Lights7 lights; -} LightMapper; // size = 0x80 - -typedef struct { - /* 0x0 */ u8 type; - /* 0x2 */ LightInfoDirectionalParams params; -} LightInfoDirectional; // size = 0xE - -typedef struct { - /* 0x0 */ u8 type; - /* 0x2 */ LightInfoPositionalParams params; -} LightInfoPositional; // size = 0xE +typedef void (*LightsBindFunc)(Lights* lights, LightParams* params, Vec3f* vec); +typedef void (*LightsPosBindFunc)(Lights* lights, LightParams* params, GlobalContext* globalCtx); #endif diff --git a/linker_scripts/code_script.txt b/linker_scripts/code_script.txt index bfc6deed04..969ede1664 100644 --- a/linker_scripts/code_script.txt +++ b/linker_scripts/code_script.txt @@ -489,7 +489,7 @@ SECTIONS build/asm/code/code_data_z_kankyo.o(.data) build/asm/code/code_data_z_lib.o(.data) build/asm/code/code_data_z_lifemeter.o(.data) - build/asm/code/code_data_z_lights.o(.data) + build/src/code/z_lights.o(.data) build/asm/code/code_data_z_map_disp.o(.data) build/asm/code/code_data_z_map_exp.o(.data) build/asm/code/code_data_z_msgevent.o(.data) @@ -565,7 +565,7 @@ SECTIONS build/asm/code/code_rodata_z_kankyo.o(.rodata) build/asm/code/code_rodata_z_lib.o(.rodata) build/asm/code/code_rodata_z_lifemeter.o(.rodata) - build/asm/code/code_rodata_z_lights.o(.rodata) + build/src/code/z_lights.o(.rodata) build/asm/code/code_rodata_z_map_disp.o(.rodata) build/asm/code/code_rodata_0x8010C230.o(.rodata) build/asm/code/code_rodata_z_parameter.o(.rodata) diff --git a/src/code/game.c b/src/code/game.c index bde34635e9..5f1013a687 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -27,34 +27,34 @@ void GameState_SetFBFilter(Gfx** gfx, u32 arg1) { if ((R_FB_FILTER_TYPE > 0) && (R_FB_FILTER_TYPE < 5)) { D_801F8010.type = R_FB_FILTER_TYPE; - D_801F8010.color.red = R_FB_FILTER_PRIM_COLOR(0); - D_801F8010.color.green = R_FB_FILTER_PRIM_COLOR(1); - D_801F8010.color.blue = R_FB_FILTER_PRIM_COLOR(2); - D_801F8010.color.alpha = R_FB_FILTER_A; + D_801F8010.color.r = R_FB_FILTER_PRIM_COLOR(0); + D_801F8010.color.g = R_FB_FILTER_PRIM_COLOR(1); + D_801F8010.color.b = R_FB_FILTER_PRIM_COLOR(2); + D_801F8010.color.a = R_FB_FILTER_A; func_80140D10(&D_801F8010, &_gfx, arg1); } else { if ((R_FB_FILTER_TYPE == 5) || (R_FB_FILTER_TYPE == 6)) { D_801F8020.useRgba = (R_FB_FILTER_TYPE == 6); - D_801F8020.primColor.red = R_FB_FILTER_PRIM_COLOR(0); - D_801F8020.primColor.green = R_FB_FILTER_PRIM_COLOR(1); - D_801F8020.primColor.blue = R_FB_FILTER_PRIM_COLOR(2); - D_801F8020.primColor.alpha = R_FB_FILTER_A; - D_801F8020.envColor.red = R_FB_FILTER_ENV_COLOR(0); - D_801F8020.envColor.green = R_FB_FILTER_ENV_COLOR(1); - D_801F8020.envColor.blue = R_FB_FILTER_ENV_COLOR(2); - D_801F8020.envColor.alpha = R_FB_FILTER_A; + D_801F8020.primColor.r = R_FB_FILTER_PRIM_COLOR(0); + D_801F8020.primColor.g = R_FB_FILTER_PRIM_COLOR(1); + D_801F8020.primColor.b = R_FB_FILTER_PRIM_COLOR(2); + D_801F8020.primColor.a = R_FB_FILTER_A; + D_801F8020.envColor.r = R_FB_FILTER_ENV_COLOR(0); + D_801F8020.envColor.g = R_FB_FILTER_ENV_COLOR(1); + D_801F8020.envColor.b = R_FB_FILTER_ENV_COLOR(2); + D_801F8020.envColor.a = R_FB_FILTER_A; func_80142100(&D_801F8020, &_gfx, arg1); } else { if (R_FB_FILTER_TYPE == 7) { sMonoColors.unk_00 = 0; - sMonoColors.primColor.red = R_FB_FILTER_PRIM_COLOR(0); - sMonoColors.primColor.green = R_FB_FILTER_PRIM_COLOR(1); - sMonoColors.primColor.blue = R_FB_FILTER_PRIM_COLOR(2); - sMonoColors.primColor.alpha = R_FB_FILTER_A; - sMonoColors.envColor.red = R_FB_FILTER_ENV_COLOR(0); - sMonoColors.envColor.green = R_FB_FILTER_ENV_COLOR(1); - sMonoColors.envColor.blue = R_FB_FILTER_ENV_COLOR(2); - sMonoColors.envColor.alpha = R_FB_FILTER_A; + sMonoColors.primColor.r = R_FB_FILTER_PRIM_COLOR(0); + sMonoColors.primColor.g = R_FB_FILTER_PRIM_COLOR(1); + sMonoColors.primColor.b = R_FB_FILTER_PRIM_COLOR(2); + sMonoColors.primColor.a = R_FB_FILTER_A; + sMonoColors.envColor.r = R_FB_FILTER_ENV_COLOR(0); + sMonoColors.envColor.g = R_FB_FILTER_ENV_COLOR(1); + sMonoColors.envColor.b = R_FB_FILTER_ENV_COLOR(2); + sMonoColors.envColor.a = R_FB_FILTER_A; VisMono_Draw(&sMonoColors, &_gfx, arg1); } } @@ -81,11 +81,11 @@ void GameState_Draw(GameState *ctxt, GraphicsContext *gCtxt) { if (R_FB_FILTER_TYPE && R_FB_FILTER_ENV_COLOR(3) == 0) { GameState_SetFBFilter(&nextDisplayList, (u32) gCtxt->zbuffer); } - + if (R_ENABLE_ARENA_DBG < 0) { R_ENABLE_ARENA_DBG = 0; } - + gSPEndDisplayList(nextDisplayList++); Graph_BranchDlist(_polyOpa, nextDisplayList); gCtxt->polyOpa.p = nextDisplayList; @@ -111,12 +111,12 @@ void Game_ResetSegments(GraphicsContext *gCtxt) { void func_801736DC(GraphicsContext *gCtxt) { Gfx* nextDisplayList; Gfx* _polyOpa; - + nextDisplayList = Graph_GfxPlusOne(_polyOpa = gCtxt->polyOpa.p); gSPDisplayList(gCtxt->overlay.p++, nextDisplayList); gSPEndDisplayList(nextDisplayList++); Graph_BranchDlist(_polyOpa, nextDisplayList); - + gCtxt->polyOpa.p = nextDisplayList; } @@ -207,7 +207,7 @@ lblUnk:; Gamealloc_Init(&ctxt->alloc); Game_InitHeap(ctxt, 0x100000); Game_SetFramerateDivisor(ctxt, 3); - + gameStateInit(ctxt); func_80140CE0(&D_801F8010); @@ -216,7 +216,7 @@ lblUnk:; func_80140898(&D_801F8048); func_801773A0(&D_801F7FF0); func_8013ED9C(); - + osSendMesg(&ctxt->gfxCtx->unk5C, NULL, 1); } diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c index 4d1d0fbf96..cbb29f8a6e 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.c @@ -3828,9 +3828,9 @@ void CollisionCheck_SpawnShieldParticles(GlobalContext* ctxt, Vec3f* v) { shieldParticleInitMetal.position.x = v->x; shieldParticleInitMetal.position.y = v->y; shieldParticleInitMetal.position.z = v->z; - shieldParticleInitMetal.lightParams.posX = shieldParticleInitMetal.position.x; - shieldParticleInitMetal.lightParams.posY = shieldParticleInitMetal.position.y; - shieldParticleInitMetal.lightParams.posZ = shieldParticleInitMetal.position.z; + shieldParticleInitMetal.lightPoint.x = shieldParticleInitMetal.position.x; + shieldParticleInitMetal.lightPoint.y = shieldParticleInitMetal.position.y; + shieldParticleInitMetal.lightPoint.z = shieldParticleInitMetal.position.z; Effect_Add(ctxt, &effectIndex, 3, 0, 1, &shieldParticleInitMetal); } @@ -3883,9 +3883,9 @@ void CollisionCheck_SpawnShieldParticlesWood(GlobalContext* ctxt, Vec3f* v, Vec3 shieldParticleInitWood.position.x = v->x; shieldParticleInitWood.position.y = v->y; shieldParticleInitWood.position.z = v->z; - shieldParticleInitWood.lightParams.posX = shieldParticleInitWood.position.x; - shieldParticleInitWood.lightParams.posY = shieldParticleInitWood.position.y; - shieldParticleInitWood.lightParams.posZ = shieldParticleInitWood.position.z; + shieldParticleInitWood.lightPoint.x = shieldParticleInitWood.position.x; + shieldParticleInitWood.lightPoint.y = shieldParticleInitWood.position.y; + shieldParticleInitWood.lightPoint.z = shieldParticleInitWood.position.z; Effect_Add(ctxt, &effectIndex, 3, 0, 1, &shieldParticleInitWood); func_8019F1C0(pos, 0x1837); diff --git a/src/code/z_effect_soft_sprite.c b/src/code/z_effect_soft_sprite.c index be20a2452c..3755a7aa27 100644 --- a/src/code/z_effect_soft_sprite.c +++ b/src/code/z_effect_soft_sprite.c @@ -253,12 +253,12 @@ void EffectSS_DrawParticle(GlobalContext* ctxt, s32 index) { } void EffectSS_DrawAllParticles(GlobalContext* ctxt) { - LightMapper* s0; + Lights* s0; s32 i; - s0 = Lights_CreateMapper(&ctxt->lightCtx, ctxt->state.gfxCtx); - Lights_MapLights(s0, ctxt->lightCtx.lightsHead, 0, ctxt); - Lights_UploadLights(s0, ctxt->state.gfxCtx); + s0 = LightContext_NewLights(&ctxt->lightCtx, ctxt->state.gfxCtx); + Lights_BindAll(s0, ctxt->lightCtx.listHead, 0, ctxt); + Lights_Draw(s0, ctxt->state.gfxCtx); for (i = 0; i < EffectSS2Info.size; i++) { if (EffectSS2Info.data_table[i].life > -1) { diff --git a/src/code/z_lib.c b/src/code/z_lib.c index cb48e72d31..9e99b9d85d 100644 --- a/src/code/z_lib.c +++ b/src/code/z_lib.c @@ -538,11 +538,11 @@ void Math_SmoothScaleMaxS(s16* start, s16 target, s16 scale, s16 maxStep) { *start += v0; } -void Color_RGBA8_Copy(ColorRGBA8* dst, ColorRGBA8* src) { - dst->red = src->red; - dst->green = src->green; - dst->blue = src->blue; - dst->alpha = src->alpha; +void Color_RGBA8_Copy(Color_RGBA8* dst, Color_RGBA8* src) { + dst->r = src->r; + dst->g = src->g; + dst->b = src->b; + dst->a = src->a; } void func_801000A4(u16 a0) { @@ -569,11 +569,11 @@ void Lib_TranslateAndRotateYVec3f(Vec3f* translation, s16 rotation, Vec3f* src, } #ifdef NON_MATCHING -void Lib_LerpRGB(RGB* a, RGB* b, f32 t, RGB* dst) { +void Lib_LerpRGB(Color_RGB8* a, Color_RGB8* b, f32 t, Color_RGB8* dst) { // XXX regalloc is slightly off - dst->red = (f32)a->red + ((f32)b->red - (f32)a->red) * t; - dst->green = (f32)a->green + ((f32)b->green - (f32)a->green) * t; - dst->blue = (f32)a->blue + ((f32)b->blue - (f32)a->blue) * t; + dst->r = (f32)a->r + ((f32)b->r - (f32)a->r) * t; + dst->g = (f32)a->g + ((f32)b->g - (f32)a->g) * t; + dst->b = (f32)a->b + ((f32)b->b - (f32)a->b) * t; } #else #pragma GLOBAL_ASM("./asm/non_matchings/code/z_lib/Lib_LerpRGB.asm") diff --git a/src/code/z_lights.c b/src/code/z_lights.c index 7ed0b0951d..c1c36d35c0 100644 --- a/src/code/z_lights.c +++ b/src/code/z_lights.c @@ -1,152 +1,143 @@ #include #include -void Lights_InitPositionalLight(LightInfoPositional* info, s16 posX, s16 posY, s16 posZ, u8 red, u8 green, u8 blue, s16 radius, u32 type) { +void Lights_PointSetInfo(LightInfo* info, s16 x, s16 y, s16 z, u8 r, u8 g, u8 b, s16 radius, s32 type) { info->type = type; - info->params.posX = posX; - info->params.posY = posY; - info->params.posZ = posZ; - Lights_SetPositionalLightColorAndRadius(info, red, green, blue, radius); + info->params.point.x = x; + info->params.point.y = y; + info->params.point.z = z; + Lights_PointSetColorAndRadius(info, r, g, b, radius); } -void Lights_InitType0PositionalLight(LightInfoPositional* info, s16 posX, s16 posY, s16 posZ, u8 red, u8 green, u8 blue, s16 radius) { - Lights_InitPositionalLight(info, posX, posY, posZ, red, green, blue, radius, 0); +void Lights_PointNoGlowSetInfo(LightInfo* info, s16 x, s16 y, s16 z, u8 r, u8 g, u8 b, s16 radius) { + Lights_PointSetInfo(info, x, y, z, r, g, b, radius, LIGHT_POINT_NOGLOW); } -void Lights_InitType2PositionalLight(LightInfoPositional* info, s16 posX, s16 posY, s16 posZ, u8 red, u8 green, u8 blue, s16 radius) { - Lights_InitPositionalLight(info, posX, posY, posZ, red, green, blue, radius, 2); +void Lights_PointGlowSetInfo(LightInfo* info, s16 x, s16 y, s16 z, u8 r, u8 g, u8 b, s16 radius) { + Lights_PointSetInfo(info, x, y, z, r, g, b, radius, LIGHT_POINT_GLOW); } -void Lights_SetPositionalLightColorAndRadius(LightInfoPositional* info, u8 red, u8 green, u8 blue, s16 radius) { - info->params.red = red; - info->params.green = green; - info->params.blue = blue; - info->params.radius = radius; +void Lights_PointSetColorAndRadius(LightInfo* info, u8 r, u8 g, u8 b, s16 radius) { + info->params.point.color[0] = r; + info->params.point.color[1] = g; + info->params.point.color[2] = b; + info->params.point.radius = radius; } -void Lights_SetPositionalLightPosition(LightInfoPositional* info, s16 posX, s16 posY, s16 posZ) { - info->params.posX = posX; - info->params.posY = posY; - info->params.posZ = posZ; +void Lights_PointSetPosition(LightInfo* info, s16 x, s16 y, s16 z) { + info->params.point.x = x; + info->params.point.y = y; + info->params.point.z = z; } -void Lights_InitDirectional(LightInfoDirectional* info, s8 dirX, s8 dirY, s8 dirZ, u8 red, u8 green, u8 blue) { - info->type = 1; - info->params.dirX = dirX; - info->params.dirY = dirY; - info->params.dirZ = dirZ; - info->params.red = red; - info->params.green = green; - info->params.blue = blue; +void Lights_DirectionalSetInfo(LightInfo* info, s8 x, s8 y, s8 z, u8 r, u8 g, u8 b) { + info->type = LIGHT_DIRECTIONAL; + info->params.dir.x = x; + info->params.dir.y = y; + info->params.dir.z = z; + info->params.dir.color[0] = r; + info->params.dir.color[1] = g; + info->params.dir.color[2] = b; } -void Lights_MapperInit(LightMapper* mapper, u8 red, u8 green, u8 blue) { - mapper->lights.a.l.colc[0] = red; - mapper->lights.a.l.col[0] = red; - mapper->lights.a.l.colc[1] = green; - mapper->lights.a.l.col[1] = green; - mapper->lights.a.l.colc[2] = blue; - mapper->lights.a.l.col[2] = blue; - mapper->numLights = 0; +void Lights_Reset(Lights* lights, u8 r, u8 g, u8 b) { + lights->l.a.l.colc[0] = r; + lights->l.a.l.col[0] = r; + lights->l.a.l.colc[1] = g; + lights->l.a.l.col[1] = g; + lights->l.a.l.colc[2] = b; + lights->l.a.l.col[2] = b; + lights->numLights = 0; } -// XXX regalloc -#ifdef NON_MATCHING -void Lights_UploadLights(LightMapper* mapper, GraphicsContext* gCtxt) { +/* + * Draws every light in the provided Lights group + */ +void Lights_Draw(Lights* lights, GraphicsContext* gfxCtx) { Light* l; s32 i; - gSPNumLights(gCtxt->polyOpa.p++, mapper->numLights); - gSPNumLights(gCtxt->polyXlu.p++, mapper->numLights); + OPEN_DISPS(gfxCtx); - l = &mapper->lights.l[0]; + gSPNumLights(POLY_OPA_DISP++, lights->numLights); + gSPNumLights(POLY_XLU_DISP++, lights->numLights); - for (i = 0; i < mapper->numLights;) { - gSPLight(gCtxt->polyOpa.p++, l, ++i); - gSPLight(gCtxt->polyXlu.p++, l++, i); + l = lights->l.l; + + for (i = 0; i < lights->numLights;) { + gSPLight(POLY_OPA_DISP++, l, ++i); + gSPLight(POLY_XLU_DISP++, l++, i); } - gSPLight(gCtxt->polyOpa.p++, &mapper->lights.a, ++i); - gSPLight(gCtxt->polyXlu.p++, &mapper->lights.a, i); -} -#else -#pragma GLOBAL_ASM("./asm/non_matchings/code/z_lights/Lights_UploadLights.asm") -#endif + gSPLight(POLY_OPA_DISP++, &lights->l.a, ++i); + gSPLight(POLY_XLU_DISP++, &lights->l.a, i); -Light* Lights_MapperGetNextFreeSlot(LightMapper* mapper) { - if (6 < mapper->numLights) { + CLOSE_DISPS(gfxCtx); +} + +Light* Lights_FindSlot(Lights* lights) { + if (lights->numLights >= 7) { return NULL; } - return &mapper->lights.l[mapper->numLights++]; + return &lights->l.l[lights->numLights++]; } -// XXX regalloc, some reorderings -#ifdef NON_MATCHING -void Lights_MapPositionalWithReference(LightMapper* mapper, LightInfoPositionalParams* params, Vec3f* pos) { +void Lights_BindPointWithReference(Lights* lights, LightParams* params, Vec3f* pos) { f32 xDiff; f32 yDiff; f32 zDiff; - f32 dist; - f32 radiusF; + f32 posDiff; + f32 scale; Light* light; - if (pos == NULL) return; + if ((pos != NULL) && (params->point.radius >= 1)) { + xDiff = params->point.x - pos->x; + yDiff = params->point.y - pos->y; + zDiff = params->point.z - pos->z; + scale = params->point.radius; + posDiff = SQ(xDiff) + SQ(yDiff) + SQ(zDiff); - if (params->radius < 1) return; + if (SQ(scale) > posDiff) { + light = Lights_FindSlot(lights); - xDiff = params->posX - pos->x; - yDiff = params->posY - pos->y; - zDiff = params->posZ - pos->z; - radiusF = params->radius; - dist = xDiff * xDiff + yDiff * yDiff + zDiff * zDiff; + if (light != NULL) { + posDiff = sqrtf(posDiff); + scale = posDiff / scale; + scale = 1 - SQ(scale); - if (radiusF * radiusF > dist) { - light = Lights_MapperGetNextFreeSlot(mapper); - if (light == NULL) return; + light->l.col[0] = params->point.color[0] * scale; + light->l.colc[0] = light->l.col[0]; + light->l.col[1] = params->point.color[1] * scale; + light->l.colc[1] = light->l.col[1]; + light->l.col[2] = params->point.color[2] * scale; + light->l.colc[2] = light->l.col[2]; - dist = sqrtf(dist); + scale = (posDiff < 1) ? 120 : 120 / posDiff; - light->l.colc[0] = light->l.col[0] = params->red * (1 - (dist / radiusF) * (dist / radiusF)); - light->l.colc[1] = light->l.col[1] = params->green * (1 - (dist / radiusF) * (dist / radiusF)); - light->l.colc[2] = light->l.col[2] = params->blue * (1 - (dist / radiusF) * (dist / radiusF)); - - if (dist < 1) { - dist = 120; - } else { - dist = 120 / dist; + light->l.dir[0] = xDiff * scale; + light->l.dir[1] = yDiff * scale; + light->l.dir[2] = zDiff * scale; + } } - - xDiff *= dist; - yDiff *= dist; - zDiff *= dist; - - light->l.dir[0] = xDiff; - light->l.dir[1] = yDiff; - light->l.dir[2] = zDiff; } } -#else -#pragma GLOBAL_ASM("./asm/non_matchings/code/z_lights/Lights_MapPositionalWithReference.asm") -#endif -// This function matches, but uses .rodata. We don't have a good way to match partial .rodata for a file yet. -#ifdef NON_MATCHING -void Lights_MapPositional(LightMapper* mapper, LightInfoPositionalParams* params, GlobalContext* ctxt) { +void Lights_BindPoint(Lights* lights, LightParams* params, GlobalContext* globalCtx) { Light* light; - f32 radiusF = params->radius; + f32 radiusF = params->point.radius; Vec3f posF; Vec3f adjustedPos; u32 pad; if (radiusF > 0) { - posF.x = params->posX; - posF.y = params->posY; - posF.z = params->posZ; - Matrix_MultiplyByVectorXYZ(&ctxt->unk187B0,&posF,&adjustedPos); + posF.x = params->point.x; + posF.y = params->point.y; + posF.z = params->point.z; + Matrix_MultiplyByVectorXYZ(&globalCtx->unk187B0,&posF,&adjustedPos); if ((adjustedPos.z > -radiusF) && (600 + radiusF > adjustedPos.z) && (400 > fabsf(adjustedPos.x) - radiusF) && (400 > fabsf(adjustedPos.y) - radiusF)) { - light = Lights_MapperGetNextFreeSlot(mapper); + light = Lights_FindSlot(lights); if (light != NULL) { radiusF = 4500000.0f / (radiusF * radiusF); if (radiusF > 255) { @@ -155,236 +146,250 @@ void Lights_MapPositional(LightMapper* mapper, LightInfoPositionalParams* params radiusF = 20; } - light->lPos.col[0] = params->red; - light->lPos.colc[0] = light->lPos.col[0]; - light->lPos.col[1] = params->green; - light->lPos.colc[1] = light->lPos.col[1]; - light->lPos.col[2] = params->blue; - light->lPos.colc[2] = light->lPos.col[2]; - light->lPos.pos[0] = params->posX; - light->lPos.pos[1] = params->posY; - light->lPos.pos[2] = params->posZ; - light->lPos.pad1 = 0x8; - light->lPos.pad2 = 0xFF; - light->lPos.unkE = (s8)radiusF; + light->p.col[0] = params->point.color[0]; + light->p.colc[0] = light->p.col[0]; + light->p.col[1] = params->point.color[1]; + light->p.colc[1] = light->p.col[1]; + light->p.col[2] = params->point.color[2]; + light->p.colc[2] = light->p.col[2]; + light->p.pos[0] = params->point.x; + light->p.pos[1] = params->point.y; + light->p.pos[2] = params->point.z; + light->p.unk3 = 0x8; + light->p.unk7 = 0xFF; + light->p.unkE = (s32)radiusF; } } } } -#else -#pragma GLOBAL_ASM("./asm/non_matchings/code/z_lights/Lights_MapPositional.asm") -#endif -void Lights_MapDirectional(LightMapper* mapper, LightInfoDirectionalParams* params, GlobalContext* ctxt) { - Light* light = Lights_MapperGetNextFreeSlot(mapper); +void Lights_BindDirectional(Lights* lights, LightParams* params, void* unused) { + Light* light = Lights_FindSlot(lights); if (light != NULL) { - light->l.col[0] = params->red; + light->l.col[0] = params->dir.color[0]; light->l.colc[0] = light->l.col[0]; - light->l.col[1] = params->green; + light->l.col[1] = params->dir.color[1]; light->l.colc[1] = light->l.col[1]; - light->l.col[2] = params->blue; + light->l.col[2] = params->dir.color[2]; light->l.colc[2] = light->l.col[2]; - light->l.dir[0] = params->dirX; - light->l.dir[1] = params->dirY; - light->l.dir[2] = params->dirZ; - light->l.pad1 = 0; + light->l.dir[0] = params->dir.x; + light->l.dir[1] = params->dir.y; + light->l.dir[2] = params->dir.z; + light->l.pad1 = 0; // TODO the fact that pad1 is set here means that it now does something in MM's microcode } } -void Lights_MapLights(LightMapper* mapper, z_Light* lights, Vec3f* refPos, GlobalContext* ctxt) { - if (lights != NULL) { - if ((refPos == NULL) && (mapper->enablePosLights == 1)) { +/** + * For every light in a provided list, try to find a free slot in the provided Lights group and bind + * a light to it. Then apply color and positional/directional info for each light + * based on the parameters supplied by the node. + * + * Note: Lights in a given list can only be binded to however many free slots are + * available in the Lights group. This is at most 7 slots for a new group, but could be less. + */ +void Lights_BindAll(Lights* lights, LightNode* listHead, Vec3f* refPos, GlobalContext* globalCtx) { + static LightsPosBindFunc posBindFuncs[] = { Lights_BindPoint, Lights_BindDirectional, Lights_BindPoint }; + static LightsBindFunc dirBindFuncs[] = { Lights_BindPointWithReference, Lights_BindDirectional, Lights_BindPointWithReference }; + + if (listHead != NULL) { + if ((refPos == NULL) && (lights->enablePosLights == 1)) { do { - lightPositionalMapFuncs[lights->info->type](mapper, &lights->info->params, ctxt); - lights = lights->next; - } while (lights != NULL); + posBindFuncs[listHead->info->type](lights, &listHead->info->params, globalCtx); + listHead = listHead->next; + } while (listHead != NULL); } else { do { - lightDirectionalMapFuncs[lights->info->type](mapper, &lights->info->params, refPos); - lights = lights->next; - } while (lights != NULL); + dirBindFuncs[listHead->info->type](lights, &listHead->info->params, refPos); + listHead = listHead->next; + } while (listHead != NULL); } } } -z_Light* Lights_FindFreeSlot(void) { - z_Light* ret; +LightNode* Lights_FindBufSlot() { + LightNode* ret; - if (0x1f < lightsList.numOccupied) { + if (sLightsBuffer.numOccupied >= LIGHTS_BUFFER_SIZE) { return NULL; } - ret = &lightsList.lights[lightsList.nextFree]; + ret = &sLightsBuffer.lights[sLightsBuffer.searchIndex]; while (ret->info != NULL) { - lightsList.nextFree++; - if (lightsList.nextFree < 0x20) { + sLightsBuffer.searchIndex++; + if (sLightsBuffer.searchIndex < LIGHTS_BUFFER_SIZE) { ret++; } else { - lightsList.nextFree = 0; - ret = &lightsList.lights[0]; + sLightsBuffer.searchIndex = 0; + ret = &sLightsBuffer.lights[0]; } } - lightsList.numOccupied++; + sLightsBuffer.numOccupied++; return ret; } -void Lights_Free(z_Light* light) { +void Lights_FreeNode(LightNode* light) { if (light != NULL) { - lightsList.numOccupied--; + sLightsBuffer.numOccupied--; light->info = NULL; - lightsList.nextFree = (light - lightsList.lights) / (s32)sizeof(z_Light); //! @bug Due to pointer arithmetic, the division is unnecessary + sLightsBuffer.searchIndex = (light - sLightsBuffer.lights) / (s32)sizeof(LightNode); //! @bug Due to pointer arithmetic, the division is unnecessary } } -void Lights_Init(GlobalContext* ctxt, LightingContext* lCtxt) { - Lights_ClearHead(ctxt, lCtxt); - Lights_SetAmbientColor(lCtxt, 80, 80, 80); - func_80102544(lCtxt, 0, 0, 0, 0x3e4, 0x3200); - bzero(&lightsList, sizeof(LightsList)); +void LightContext_Init(GlobalContext* globalCtx, LightContext* lightCtx) { + LightContext_InitList(globalCtx, lightCtx); + LightContext_SetAmbientColor(lightCtx, 80, 80, 80); + func_80102544(lightCtx, 0, 0, 0, 0x3E4, 0x3200); + bzero(&sLightsBuffer, sizeof(LightsBuffer)); } -void Lights_SetAmbientColor(LightingContext* lCtxt, u8 red, u8 green, u8 blue) { - lCtxt->ambientRed = red; - lCtxt->ambientGreen = green; - lCtxt->ambientBlue = blue; +void LightContext_SetAmbientColor(LightContext* lightCtx, u8 r, u8 g, u8 b) { + lightCtx->ambient.r = r; + lightCtx->ambient.g = g; + lightCtx->ambient.b = b; } -void func_80102544(LightingContext* lCtxt, u8 a1, u8 a2, u8 a3, s16 sp12, s16 sp16) { - lCtxt->unk7 = a1; - lCtxt->unk8 = a2; - lCtxt->unk9 = a3; - lCtxt->unkA = sp12; - lCtxt->unkC = sp16; +void func_80102544(LightContext* lightCtx, u8 a1, u8 a2, u8 a3, s16 numLights, s16 sp16) { + lightCtx->unk7 = a1; + lightCtx->unk8 = a2; + lightCtx->unk9 = a3; + lightCtx->unkA = numLights; + lightCtx->unkC = sp16; } -LightMapper* Lights_CreateMapper(LightingContext* lCtxt, GraphicsContext* gCtxt) { - return Lights_MapperAllocateAndInit(gCtxt, lCtxt->ambientRed, lCtxt->ambientGreen, lCtxt->ambientBlue); +/** + * Allocate a new Lights group and initilize the ambient color with that provided by LightContext + */ +Lights* LightContext_NewLights(LightContext* lightCtx, GraphicsContext* gfxCtx) { + return Lights_New(gfxCtx, lightCtx->ambient.r, lightCtx->ambient.g, lightCtx->ambient.b); } -void Lights_ClearHead(GlobalContext* ctxt, LightingContext* lCtxt) { - lCtxt->lightsHead = NULL; +void LightContext_InitList(GlobalContext* globalCtx, LightContext* lightCtx) { + lightCtx->listHead = NULL; } -void Lights_RemoveAll(GlobalContext* ctxt, LightingContext* lCtxt) { - while (lCtxt->lightsHead != NULL) { - Lights_Remove(ctxt, lCtxt, lCtxt->lightsHead); - lCtxt->lightsHead = lCtxt->lightsHead->next; +void LightContext_DestroyList(GlobalContext* globalCtx, LightContext* lightCtx) { + while (lightCtx->listHead != NULL) { + LightContext_RemoveLight(globalCtx, lightCtx, lightCtx->listHead); + lightCtx->listHead = lightCtx->listHead->next; } } -z_Light* Lights_Insert(GlobalContext* ctxt, LightingContext* lCtxt, LightInfo* info) { - z_Light* light; +/** + * Insert a new light into the list pointed to by LightContext + * + * Note: Due to the limited number of slots in a Lights group, inserting too many lights in the + * list may result in older entries not being bound to a Light when calling Lights_BindAll + */ +LightNode* LightContext_InsertLight(GlobalContext* globalCtx, LightContext* lightCtx, LightInfo* info) { + LightNode* light; - light = Lights_FindFreeSlot(); + light = Lights_FindBufSlot(); if (light != NULL) { light->info = info; light->prev = NULL; - light->next = lCtxt->lightsHead; + light->next = lightCtx->listHead; - if (lCtxt->lightsHead != NULL) { - lCtxt->lightsHead->prev = light; + if (lightCtx->listHead != NULL) { + lightCtx->listHead->prev = light; } - lCtxt->lightsHead = light; + lightCtx->listHead = light; } return light; } -void Lights_Remove(GlobalContext* ctxt, LightingContext* lCtxt, z_Light* light) { +void LightContext_RemoveLight(GlobalContext* globalCtx, LightContext* lightCtx, LightNode* light) { if (light != NULL) { if (light->prev != NULL) { light->prev->next = light->next; } else { - lCtxt->lightsHead = light->next; + lightCtx->listHead = light->next; } if (light->next != NULL) { light->next->prev = light->prev; } - Lights_Free(light); + Lights_FreeNode(light); } } -LightMapper* func_801026E8(GraphicsContext* gCtxt, u8 ambientRed, u8 ambientGreen, u8 ambientBlue, u8 numLights, u8 red, u8 green, u8 blue, s8 dirX, s8 dirY, s8 dirZ) { - LightMapper* mapper; +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; s32 i; // TODO allocation should be a macro - mapper = (LightMapper *)((int)gCtxt->polyOpa.d - sizeof(LightMapper)); - gCtxt->polyOpa.d = (void*)mapper; + lights = (Lights *)((int)gfxCtx->polyOpa.d - sizeof(Lights)); + gfxCtx->polyOpa.d = (void*)lights; - mapper->lights.a.l.col[0] = mapper->lights.a.l.colc[0] = ambientRed; - mapper->lights.a.l.col[1] = mapper->lights.a.l.colc[1] = ambientGreen; - mapper->lights.a.l.col[2] = mapper->lights.a.l.colc[2] = ambientBlue; - mapper->enablePosLights = 0; - mapper->numLights = numLights; + lights->l.a.l.col[0] = lights->l.a.l.colc[0] = ambientR; + lights->l.a.l.col[1] = lights->l.a.l.colc[1] = ambientG; + lights->l.a.l.col[2] = lights->l.a.l.colc[2] = ambientB; + lights->enablePosLights = 0; + lights->numLights = numLights; for (i = 0; i < numLights; i++) { - mapper->lights.l[i].l.col[0] = mapper->lights.l[i].l.colc[0] = red; - mapper->lights.l[i].l.col[1] = mapper->lights.l[i].l.colc[1] = green; - mapper->lights.l[i].l.col[2] = mapper->lights.l[i].l.colc[2] = blue; - mapper->lights.l[i].l.dir[0] = dirX; - mapper->lights.l[i].l.dir[1] = dirY; - mapper->lights.l[i].l.dir[2] = dirZ; + lights->l.l[i].l.col[0] = lights->l.l[i].l.colc[0] = r; + lights->l.l[i].l.col[1] = lights->l.l[i].l.colc[1] = g; + lights->l.l[i].l.col[2] = lights->l.l[i].l.colc[2] = b; + lights->l.l[i].l.dir[0] = x; + lights->l.l[i].l.dir[1] = y; + lights->l.l[i].l.dir[2] = z; } - Lights_UploadLights(mapper,gCtxt); + Lights_Draw(lights,gfxCtx); - return mapper; + return lights; } -LightMapper* Lights_MapperAllocateAndInit(GraphicsContext* gCtxt, u8 red, u8 green, u8 blue) { - LightMapper* mapper; +Lights* Lights_New(GraphicsContext* gfxCtx, u8 ambientR, u8 ambientG, u8 ambientB) { + Lights* lights; // TODO allocation should be a macro - mapper = (LightMapper *)((int)gCtxt->polyOpa.d - sizeof(LightMapper)); - gCtxt->polyOpa.d = (void*)mapper; + lights = (Lights *)((int)gfxCtx->polyOpa.d - sizeof(Lights)); + gfxCtx->polyOpa.d = (void*)lights; - mapper->lights.a.l.col[0] = red; - mapper->lights.a.l.colc[0] = red; - mapper->lights.a.l.col[1] = green; - mapper->lights.a.l.colc[1] = green; - mapper->lights.a.l.col[2] = blue; - mapper->lights.a.l.colc[2] = blue; - mapper->enablePosLights = 0; - mapper->numLights = 0; + lights->l.a.l.col[0] = ambientR; + lights->l.a.l.colc[0] = ambientR; + lights->l.a.l.col[1] = ambientG; + lights->l.a.l.colc[1] = ambientG; + lights->l.a.l.col[2] = ambientB; + lights->l.a.l.colc[2] = ambientB; + lights->enablePosLights = 0; + lights->numLights = 0; - return mapper; + return lights; } -// XXX regalloc -#ifdef NON_MATCHING -void func_80102880(GlobalContext* ctxt) { - z_Light* light = ctxt->lightsContext.lightsHead; - LightInfoPositionalParams* params; - Vec3f local_14; - Vec3f local_20; - f32 local_24; - f32 fVar4; - s32 s2; - u32 pad[2]; +void Lights_GlowCheck(GlobalContext* globalCtx) { + LightNode* light = globalCtx->lightCtx.listHead; while (light != NULL) { - if (light->info->type == 2) { - params = (LightInfoPositionalParams*)&light->info->params; - local_14.x = params->posX; - local_14.y = params->posY; - local_14.z = params->posZ; - func_800B4EDC(ctxt, &local_14, &local_20, &local_24); + LightPoint* params = (LightPoint*)&light->info->params; - params->unk9 = 0; + if (light->info->type == LIGHT_POINT_GLOW) { + Vec3f pos; + Vec3f multDest; + f32 wDest; - if ((local_20.z > 1) && - (fabsf(local_20.x * local_24) < 1) && - (fabsf(local_20.y * local_24) < 1)) { - fVar4 = local_20.z * local_24; - s2 = (s32)(fVar4 * 16352) + 16352; - if (s2 < func_80178A94(local_20.x * local_24 * 160 + 160, local_20.y * local_24 * -120 + 120)) { - params->unk9 = 1; + pos.x = params->x; + pos.y = params->y; + pos.z = params->z; + func_800B4EDC(globalCtx, &pos, &multDest, &wDest); + + params->drawGlow = 0; + + if ((multDest.z > 1) && (fabsf(multDest.x * wDest) < 1) && (fabsf(multDest.y * wDest) < 1)) { + s32 wX = multDest.x * wDest * 160 + 160; + s32 wY = multDest.y * wDest * -120 + 120; + s32 wZ = (s32)((multDest.z * wDest) * 16352) + 16352; + s32 zBuf = func_80178A94(wX, wY); + + if (wZ < zBuf) { + params->drawGlow = 1; } } } @@ -392,22 +397,16 @@ void func_80102880(GlobalContext* ctxt) { light = light->next; } } -#else -#pragma GLOBAL_ASM("./asm/non_matchings/code/z_lights/func_80102880.asm") -#endif -// XXX regalloc -#ifdef NON_MATCHING -void func_80102A64(GlobalContext* ctxt) { +void Lights_DrawGlow(GlobalContext* globalCtx) { Gfx* dl; - LightInfoPositionalParams* params; - f32 scale; - GraphicsContext* gCtxt; - z_Light* light = ctxt->lightsContext.lightsHead; + LightPoint* params; + LightNode* light = globalCtx->lightCtx.listHead; if (light != NULL) { - gCtxt = ctxt->common.gCtxt; - dl = func_8012C7FC(gCtxt->polyXlu.p); + OPEN_DISPS(globalCtx->state.gfxCtx); + + dl = func_8012C7FC(POLY_XLU_DISP); gSPSetOtherMode(dl++, G_SETOTHERMODE_H, 4, 4, 0x00000080); //! This doesn't resolve to any of the macros in gdi.h @@ -417,17 +416,17 @@ void func_80102A64(GlobalContext* ctxt) { gSPDisplayList(dl++, &D_04029CB0); do { - if (light->info->type == 2) { - params = (LightInfoPositionalParams*)&light->info->params; - if (params->unk9 != 0) { - scale = (f32)params->radius * (f32)params->radius * 2e-6f; + if (light->info->type == LIGHT_POINT_GLOW) { + params = (LightPoint*)&light->info->params; + if (params->drawGlow) { + f32 scale = SQ((f32)params->radius) * 2e-6f; - gDPSetPrimColor(dl++, 0, 0, params->red, params->green, params->blue, 50); + gDPSetPrimColor(dl++, 0, 0, params->color[0], params->color[1], params->color[2], 50); - SysMatrix_InsertTranslation(params->posX, params->posY, params->posZ, 0); + SysMatrix_InsertTranslation(params->x, params->y, params->z, 0); SysMatrix_InsertScale(scale,scale,scale,1); - gSPMatrix(dl++, SysMatrix_AppendStateToPolyOpaDisp((ctxt->common).gCtxt), G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(dl++, SysMatrix_AppendStateToPolyOpaDisp(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(dl++, &D_04029CF0); } @@ -436,9 +435,8 @@ void func_80102A64(GlobalContext* ctxt) { light = light->next; } while (light != NULL); - gCtxt->polyXlu.p = dl; + POLY_XLU_DISP = dl; + + CLOSE_DISPS(globalCtx->state.gfxCtx); } } -#else -#pragma GLOBAL_ASM("./asm/non_matchings/code/z_lights/func_80102A64.asm") -#endif diff --git a/src/code/z_scene.c b/src/code/z_scene.c index e697bd871b..8a0ed87b78 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -310,7 +310,7 @@ void Scene_HeaderCommand0C(GlobalContext* ctxt, SceneCmd* entry) { lightInfo = (LightInfo*)Lib_PtrSegToVirt(entry->lightList.segment); for (i = 0; i < entry->lightList.num; i++) { - Lights_Insert(ctxt, &ctxt->lightCtx, lightInfo); + LightContext_InsertLight(ctxt, &ctxt->lightCtx, lightInfo); lightInfo++; } } diff --git a/src/code/z_scene_proc.c b/src/code/z_scene_proc.c index b7775e8680..9dea984ea5 100644 --- a/src/code/z_scene_proc.c +++ b/src/code/z_scene_proc.c @@ -66,7 +66,7 @@ void SceneProc_DrawType1Texture(GlobalContext* ctxt, u32 segment, ScrollingTextu #ifdef NON_MATCHING // Slight ordering differences at the beginning -void SceneProc_DrawFlashingTexture(GlobalContext* ctxt, u32 segment, FlashingTexturePrimColor* primColor, RGBA8* envColor) { +void SceneProc_DrawFlashingTexture(GlobalContext* ctxt, u32 segment, FlashingTexturePrimColor* primColor, Color_RGBA8* envColor) { GraphicsContext* gfxCtx; Gfx* dl; @@ -108,7 +108,7 @@ void SceneProc_DrawFlashingTexture(GlobalContext* ctxt, u32 segment, FlashingTex #endif void SceneProc_DrawType2Texture(GlobalContext* ctxt, u32 segment, FlashingTextureParams* params) { - RGBA8* envColor; + Color_RGBA8* envColor; FlashingTexturePrimColor* primColor = (FlashingTexturePrimColor *)Lib_PtrSegToVirt(params->primColors); u32 pad; u32 index = gSceneProcStep % params->cycleLength; @@ -116,7 +116,7 @@ void SceneProc_DrawType2Texture(GlobalContext* ctxt, u32 segment, FlashingTextur primColor += index; if (params->envColors) { - envColor = (RGBA8*)Lib_PtrSegToVirt(params->envColors) + index; + envColor = (Color_RGBA8*)Lib_PtrSegToVirt(params->envColors) + index; } else { envColor = NULL; } @@ -132,18 +132,18 @@ s32 SceneProc_Lerp(s32 a, s32 b, f32 t) { // Slight ordering and regalloc differences around t = ... void SceneProc_DrawType3Texture(GlobalContext* ctxt, u32 segment, FlashingTextureParams* params) { FlashingTextureParams* params2 = params; - RGBA8* envColorTo; + Color_RGBA8* envColorTo; FlashingTexturePrimColor* primColorTo = (FlashingTexturePrimColor *)Lib_PtrSegToVirt(params2->primColors); u16* keyFrames = (u16*)Lib_PtrSegToVirt(params2->keyFrames); s32 index = gSceneProcStep % params2->cycleLength; s32 pad1; s32 keyFrameIndex; - RGBA8* envColorPtrIn; + Color_RGBA8* envColorPtrIn; f32 t; s32 pad2; FlashingTexturePrimColor primColorIn; - RGBA8* envColorFrom; - RGBA8 envColorIn; + Color_RGBA8* envColorFrom; + Color_RGBA8 envColorIn; s32 pad3; FlashingTexturePrimColor* primColorFrom; @@ -169,7 +169,7 @@ void SceneProc_DrawType3Texture(GlobalContext* ctxt, u32 segment, FlashingTextur primColorIn.lodFrac = SceneProc_Lerp(primColorFrom->lodFrac, primColorTo->lodFrac, t); if (params2->envColors) { - envColorTo = (RGBA8*)Lib_PtrSegToVirt(params2->envColors) + keyFrameIndex; + envColorTo = (Color_RGBA8*)Lib_PtrSegToVirt(params2->envColors) + keyFrameIndex; envColorFrom = envColorTo - 1; envColorIn.red = SceneProc_Lerp(envColorFrom->red, envColorTo->red, t); envColorIn.green = SceneProc_Lerp(envColorFrom->green, envColorTo->green, t); diff --git a/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.c b/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.c index 1a0c98f308..42a340eb03 100644 --- a/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.c +++ b/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.c @@ -82,12 +82,12 @@ void EnDyExtra_Update(Actor* thisx, GlobalContext* globalCtx) { } void EnDyExtra_Draw(Actor* thisx, GlobalContext* globalCtx) { - static ColorRGBA8 D_80A61740[] = { { 255, 255, 170, 255 }, - { 255, 170, 255, 255 }, - { 255, 255, 170, 255 }, - { 170, 255, 255, 255 }, - { 255, 255, 170, 255 } }; - static ColorRGBA8 D_80A61754[] = { + static Color_RGBA8 D_80A61740[] = { { 255, 255, 170, 255 }, + { 255, 170, 255, 255 }, + { 255, 255, 170, 255 }, + { 170, 255, 255, 255 }, + { 255, 255, 170, 255 } }; + static Color_RGBA8 D_80A61754[] = { { 255, 100, 0, 255 }, { 255, 0, 100, 255 }, { 100, 255, 0, 255 }, { 0, 100, 255, 255 }, { 255, 230, 0, 255 } }; static u8 D_80A61768[] = { 0x02, 0x01, 0x01, 0x02, 0x00, 0x00, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x02, 0x01, @@ -118,10 +118,10 @@ void EnDyExtra_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gSPMatrix(POLY_XLU_DISP++, SysMatrix_AppendStateToPolyOpaDisp(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, D_80A61740[this->type].red, D_80A61740[this->type].green, - D_80A61740[this->type].blue, 255); - gDPSetEnvColor(POLY_XLU_DISP++, D_80A61754[this->type].red, D_80A61754[this->type].green, - D_80A61754[this->type].blue, 128); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, D_80A61740[this->type].r, D_80A61740[this->type].g, + D_80A61740[this->type].b, 255); + gDPSetEnvColor(POLY_XLU_DISP++, D_80A61754[this->type].r, D_80A61754[this->type].g, + D_80A61754[this->type].b, 128); gSPDisplayList(POLY_XLU_DISP++, D_0600DEF0); CLOSE_DISPS(gfxCtx); diff --git a/tables/functions.txt b/tables/functions.txt index 380856b5c2..9fe98f2e0c 100644 --- a/tables/functions.txt +++ b/tables/functions.txt @@ -1873,33 +1873,33 @@ 0x80100B8C:("LifeMeter_Draw",), 0x80101844:("LifeMeter_UpdateSizeAndBeep",), 0x80101930:("LifeMeter_IsCritical",), - 0x801019A0:("Lights_InitPositionalLight",), - 0x801019FC:("Lights_InitType0PositionalLight",), - 0x80101A60:("Lights_InitType2PositionalLight",), - 0x80101AC8:("Lights_SetPositionalLightColorAndRadius",), - 0x80101AFC:("Lights_SetPositionalLightPosition",), - 0x80101B34:("Lights_InitDirectional",), - 0x80101B8C:("Lights_MapperInit",), - 0x80101BC8:("Lights_UploadLights",), - 0x80101D0C:("Lights_MapperGetNextFreeSlot",), - 0x80101D3C:("Lights_MapPositionalWithReference",), - 0x801020A0:("Lights_MapPositional",), - 0x80102284:("Lights_MapDirectional",), - 0x801022F0:("Lights_MapLights",), - 0x801023D8:("Lights_FindFreeSlot",), - 0x80102464:("Lights_Free",), - 0x801024AC:("Lights_Init",), - 0x80102518:("Lights_SetAmbientColor",), + 0x801019A0:("Lights_PointSetInfo",), + 0x801019FC:("Lights_PointNoGlowSetInfo",), + 0x80101A60:("Lights_PointGlowSetInfo",), + 0x80101AC8:("Lights_PointSetColorAndRadius",), + 0x80101AFC:("Lights_PointSetPosition",), + 0x80101B34:("Lights_DirectionalSetInfo",), + 0x80101B8C:("Lights_Reset",), + 0x80101BC8:("Lights_Draw",), + 0x80101D0C:("Lights_FindSlot",), + 0x80101D3C:("Lights_BindPointWithReference",), + 0x801020A0:("Lights_BindPoint",), + 0x80102284:("Lights_BindDirectional",), + 0x801022F0:("Lights_BindAll",), + 0x801023D8:("Lights_FindBufSlot",), + 0x80102464:("Lights_FreeNode",), + 0x801024AC:("LightContext_Init",), + 0x80102518:("LightContext_SetAmbientColor",), 0x80102544:("func_80102544",), - 0x80102580:("Lights_CreateMapper",), - 0x801025B8:("Lights_ClearHead",), - 0x801025C8:("Lights_RemoveAll",), - 0x80102624:("Lights_Insert",), - 0x80102684:("Lights_Remove",), - 0x801026E8:("func_801026E8",), - 0x80102834:("Lights_MapperAllocateAndInit",), - 0x80102880:("func_80102880",), - 0x80102A64:("func_80102A64",), + 0x80102580:("LightContext_NewLights",), + 0x801025B8:("LightContext_InitList",), + 0x801025C8:("LightContext_DestroyList",), + 0x80102624:("LightContext_InsertLight",), + 0x80102684:("LightContext_RemoveLight",), + 0x801026E8:("Lights_NewAndDraw",), + 0x80102834:("Lights_New",), + 0x80102880:("Lights_GlowCheck",), + 0x80102A64:("Lights_DrawGlow",), 0x80102C60:("zelda_malloc",), 0x80102C88:("zelda_mallocR",), 0x80102CB0:("zelda_realloc",), diff --git a/tables/variables.txt b/tables/variables.txt index cb4eebfe5c..9795333bb7 100644 --- a/tables/variables.txt +++ b/tables/variables.txt @@ -431,14 +431,14 @@ 0x801AEC70:("D_801AEC70","UNK_TYPE4","",0x4), 0x801AEC74:("D_801AEC74","UNK_TYPE4","",0x4), 0x801AEC78:("D_801AEC78","UNK_TYPE4","",0x4), - 0x801AEC80:("D_801AEC80","ColorRGBA8","",0x4), + 0x801AEC80:("D_801AEC80","Color_RGBA8","",0x4), 0x801AEC84:("D_801AEC84","s801AEC84","[13]",0x68), 0x801AECEC:("actorMovementScale","f32","",0x4), 0x801AECF0:("D_801AECF0","f32","",0x4), 0x801AECF4:("D_801AECF4","f32","",0x4), 0x801AED48:("D_801AED48","UNK_TYPE1","",0x1), 0x801AED58:("D_801AED58","UNK_TYPE4","",0x4), - 0x801AED88:("actorDefaultHitColor","ColorRGBA8","",0x4), + 0x801AED88:("actorDefaultHitColor","Color_RGBA8","",0x4), 0x801AED8C:("D_801AED8C","UNK_TYPE1","",0x1), 0x801AED98:("D_801AED98","UNK_TYPE4","",0x4), 0x801AEDA4:("D_801AEDA4","UNK_TYPE4","",0x4), @@ -1032,8 +1032,8 @@ 0x801BEA20:("D_801BEA20","UNK_TYPE2","",0x2), 0x801BEA30:("D_801BEA30","UNK_TYPE1","",0x1), 0x801BEA70:("D_801BEA70","UNK_TYPE1","",0x1), - 0x801BEAB0:("lightPositionalMapFuncs","light_map_positional_func","[3]",0xc), - 0x801BEABC:("lightDirectionalMapFuncs","light_map_directional_func","[3]",0xc), + 0x801BEAB0:("posBindFuncs","LightsPosBindFunc","[3]",0xc), + 0x801BEABC:("dirBindFuncs","LightsBindFunc","[3]",0xc), 0x801BEAD4:("D_801BEAD4","UNK_TYPE4","",0x4), 0x801BEAD8:("D_801BEAD8","UNK_TYPE4","",0x4), 0x801BEAE0:("D_801BEAE0","UNK_TYPE1","",0x1), @@ -4202,7 +4202,7 @@ 0x801F4F66:("D_801F4F66","UNK_TYPE1","",0x1), 0x801F4F68:("D_801F4F68","UNK_TYPE1","",0x1), 0x801F4F6A:("D_801F4F6A","UNK_TYPE1","",0x1), - 0x801F4F70:("lightsList","LightsList","",0x188), + 0x801F4F70:("sLightsBuffer","LightsBuffer","",0x188), 0x801F5100:("mainHeap","Arena","",0x24), 0x801F5130:("D_801F5130","UNK_TYPE1","",0x1), 0x801F5270:("D_801F5270","UNK_TYPE1","",0x1), @@ -4275,7 +4275,7 @@ 0x801F6D0C:("D_801F6D0C","UNK_TYPE1","",0x1), 0x801F6D10:("D_801F6D10","UNK_TYPE4","",0x4), 0x801F6D18:("D_801F6D18","UNK_TYPE1","",0x1), - 0x801F6D30:("D_801F6D30","ColorRGBA8","",0x4), + 0x801F6D30:("D_801F6D30","Color_RGBA8","",0x4), 0x801F6D38:("D_801F6D38","UNK_TYPE1","",0x1), 0x801F6D4C:("D_801F6D4C","UNK_TYPE4","",0x4), 0x801F6D50:("D_801F6D50","UNK_TYPE1","",0x1), diff --git a/undef.txt b/undef.txt index 3c7fdb0838..dd0b7e43d5 100644 --- a/undef.txt +++ b/undef.txt @@ -294,7 +294,7 @@ D_801F4F60 = code_bss_start + 0x00010FC0; D_801F4F66 = code_bss_start + 0x00010FC6; D_801F4F68 = code_bss_start + 0x00010FC8; D_801F4F6A = code_bss_start + 0x00010FCA; -lightsList = code_bss_start + 0x00010FD0; +sLightsBuffer = code_bss_start + 0x00010FD0; mainHeap = code_bss_start + 0x00011160; D_801F5130 = code_bss_start + 0x00011190; D_801F5270 = code_bss_start + 0x000112D0;