Improve lighting documentation (#680)

* Improve lighting documentation

* More renames in LevelObjectEntry_RgbaLight

* Fix wrong-styled function name

* Suggested changes to comments

* Rename functions

* Fix renaming variable

* Add light mask enum

* Missed function to rename

* Update score
This commit is contained in:
Jordan Longstaff
2025-07-19 14:05:02 -04:00
committed by GitHub
parent 0ce9693f15
commit 8d2e6ab45d
13 changed files with 336 additions and 308 deletions
+21 -21
View File
@@ -5,11 +5,11 @@ This repo contains a work-in-progress decompilation of Diddy Kong Racing for the
All versions are supported, and the US 1.0 version (SHA1 = 0cb115d8716dbbc2922fda38e533b9fe63bb9670) of the game is the default if not specified.
<!-- README_SCORE_SUMMARY_BEGIN -->
As of July 16, 2025, this is our current score:
As of July 19, 2025, this is our current score:
&emsp;&emsp;&emsp;&emsp;Decomp progress: 96.77%
&emsp;&emsp;&emsp;&emsp;Documentation progress: 62.57%
&emsp;&emsp;&emsp;&emsp;Documentation progress: 63.41%
<!-- README_SCORE_SUMMARY_END -->
---
@@ -117,30 +117,30 @@ s32 is_drumstick_unlocked(void) {
```
<!-- README_SCORE_BEGIN -->
As of July 16, 2025, this is our current score:
As of July 19, 2025, this is our current score:
```
======================================================================
=======================================================================
ADVENTURE ONE (ASM -> C Decompilation)
--------------- 96.77% Complete (97.77% NON_MATCHING) ----------------
---------------- 96.77% Complete (97.77% NON_MATCHING) ----------------
# Decompiled functions: 1941
# GLOBAL_ASM remaining: 11
# NON_MATCHING functions: 5
# NON_EQUIVALENT WIP functions: 6
---------------------------- Game Status -----------------------------
Balloons: 46/47, Keys: 4/4, Trophies: 4/5
# NON_MATCHING functions: 5
# NON_EQUIVALENT WIP functions: 6
----------------------------- Game Status -----------------------------
Balloons: 46/47, Keys: 4/4, Trophies: 4/5
T.T. Amulets: 4/4, Wizpig Amulets: 4/4
----------------------------------------------------------------------
We are collecting silver coins in Star City. (7/8 silver coins)
======================================================================
ADVENTURE TWO (Cleanup & Documentation)
-------------------------- 62.57% Complete ---------------------------
# Documented functions: 1232
# Undocumented remaining: 420
---------------------------- Game Status -----------------------------
Balloons: 30/47, Keys: 3/4, Trophies: 2/5
-----------------------------------------------------------------------
We are collecting silver coins in Star City. (7/8 silver coins)
=======================================================================
ADVENTURE TWO (Cleanup & Documentation)
--------------------------- 63.41% Complete ---------------------------
# Documented functions: 1239
# Undocumented remaining: 413
----------------------------- Game Status -----------------------------
Balloons: 30/47, Keys: 3/4, Trophies: 2/5
T.T. Amulets: 3/4, Wizpig Amulets: 3/4
----------------------------------------------------------------------
We are participating in the Trophy Race of Sherbet Island. (Round Two)
======================================================================
-----------------------------------------------------------------------
We are participating in the Trophy Race of Sherbet Island. (Round Four)
=======================================================================
```
<!-- README_SCORE_END -->
+5 -5
View File
@@ -266,11 +266,11 @@ typedef struct LevelObjectEntry_RgbaLight {
/* 0x00 */ LevelObjectEntryCommon common;
/* 0x08 */ u8 unk8;
/* 0x09 */ u8 unk9;
/* 0x0A */ u8 unkA;
/* 0x0B */ u8 unkB;
/* 0x0C */ u8 unkC;
/* 0x0D */ u8 unkD;
/* 0x0E */ s16 unkE;
/* 0x0A */ u8 colourR;
/* 0x0B */ u8 colourG;
/* 0x0C */ u8 colourB;
/* 0x0D */ u8 intensity;
/* 0x0E */ s16 radius;
/* 0x10 */ s16 unk10;
/* 0x12 */ s16 unk12;
/* 0x14 */ s16 unk14;
+1 -1
View File
@@ -815,7 +815,7 @@ typedef struct ObjectHeader {
/* 0x3A */ u8 unk3A;
/* 0x3B */ u8 unk3B;
/* 0x3C */ u8 unk3C;
/* 0x3D */ u8 unk3D;
/* 0x3D */ u8 shadeIntensityy;
/* 0x3E */ s16 shadeAngleY;
/* 0x40 */ s16 shadeAngleZ;
/* 0x42 */ s16 unk42;
+2 -2
View File
@@ -489,7 +489,7 @@ void level_load(s32 levelId, s32 numberOfPlayers, s32 entranceId, Vehicle vehicl
}
music_voicelimit_set(gCurrentLevelHeader->voiceLimit);
music_volume_reset();
setup_lights(32);
lights_init(32);
var_s0 = VEHICLE_CAR;
if (vehicleId >= VEHICLE_CAR && vehicleId < NUMBER_OF_PLAYER_VEHICLES) {
var_s0 = gCurrentLevelHeader->unk4F[vehicleId];
@@ -685,7 +685,7 @@ void level_free(void) {
music_stop();
music_jingle_stop();
music_channel_reset_all();
free_lights();
lights_free();
free_track();
audspat_reset();
sound_volume_change(VOLUME_NORMAL);
+178 -156
View File
File diff suppressed because it is too large Load Diff
+32 -26
View File
@@ -13,6 +13,12 @@ enum LightType {
LIGHT_UNK5,
};
enum LightMask {
LIGHT_MASK_NONE = 0,
LIGHT_MASK_UNK2 = 1 << 1,
LIGHT_MASK_UNK4 = 1 << 2,
};
typedef struct SubMiscAssetObjectHeader24 {
u8 unk0;
u8 unk1;
@@ -44,14 +50,14 @@ typedef struct ObjectLight {
s32 colourG;
s32 colourB;
s32 intensity;
s32 unk2C;
s32 unk30;
s32 unk34;
s32 unk38;
u16 unk3C;
u16 unk3E;
u16 unk40;
u16 unk42;
s32 targetColourChangeRateR;
s32 targetColourChangeRateG;
s32 targetColourChangeRateB;
s32 targetIntensityChangeRate;
u16 targetColourDiffR;
u16 targetColourDiffG;
u16 targetColourDiffB;
u16 targetIntensityDiff;
union {
SubMiscAssetObjectHeader24 *unk44;
MiscAssetObjectHeader24 *unk44_asset;
@@ -60,12 +66,12 @@ typedef struct ObjectLight {
u16 unk4A;
u16 unk4C;
u16 unk4E;
s16 unk50;
s16 unk52;
s16 unk54;
s16 unk56;
s16 unk58;
s16 unk5A;
s16 minX;
s16 minY;
s16 minZ;
s16 maxX;
s16 maxY;
s16 maxZ;
f32 radius;
f32 unk60;
f32 unk64;
@@ -81,27 +87,27 @@ typedef struct ObjectLight {
} ObjectLight;
/* Size: 0x14 bytes */
typedef struct unk800DC960 {
typedef struct ObjectLightShadeProperties {
ObjectLight* lightObj;
s32 colourR;
s32 colourG;
s32 colourB;
s32 intensity;
} unk800DC960;
} ObjectLightShadeProperties;
void free_lights(void);
void lightUpdateLights(s32 updateRate);
void func_80032BAC(ObjectLight *light);
s32 get_light_count(void);
void lights_free(void);
void light_update_all(s32 updateRate);
void light_remove(ObjectLight *light);
s32 light_count(void);
f32 light_distance_calc(ObjectLight *light);
f32 light_direction_calc(ObjectLight *light);
ObjectLight *func_80031CAC(Object *obj, LevelObjectEntry_RgbaLight *lightEntry);
ObjectLight *add_object_light(Object *obj, ObjectHeader24 *arg1);
void func_80032424(ObjectLight *light, s32 updateRate);
ObjectLight *light_add_from_level_object_entry(Object *obj, LevelObjectEntry_RgbaLight *lightEntry);
ObjectLight *light_add_from_object_header(Object *obj, ObjectHeader24 *arg1);
void light_update(ObjectLight *light, s32 updateRate);
//Non Matching
void setup_lights(s32 count);
void func_80032C7C(Object *object);
void func_800337E4(void);
void lights_init(s32 count);
void light_update_shading(Object *object);
void light_update_ambience(void);
#endif
+1 -1
View File
@@ -5539,7 +5539,7 @@ void obj_loop_texscroll(Object *obj, s32 updateRate) {
/* Official name: rgbalightInit */
void obj_init_rgbalight(Object *obj, LevelObjectEntry_RgbaLight *entry, UNUSED s32 arg2) {
obj->light = func_80031CAC(obj, entry);
obj->light = light_add_from_level_object_entry(obj, entry);
}
/**
+11 -11
View File
@@ -2268,7 +2268,7 @@ void objFreeAssets(Object *obj, s32 count, s32 objType) {
void light_setup_light_sources(Object *obj) {
s32 i;
for (i = 0; i < obj->header->numLightSources; i++) {
obj->lightData[i] = add_object_light(obj, &obj->header->unk24[i]);
obj->lightData[i] = light_add_from_object_header(obj, &obj->header->unk24[i]);
}
}
@@ -2286,11 +2286,11 @@ s32 init_object_shading(Object *obj, ShadeProperties *shadeData) {
if (obj->modelInstances[i] != NULL && obj->modelInstances[i]->objModel->normals != NULL) {
set_shading_properties(obj->shading, obj->header->shadeAmbient, obj->header->shadeDiffuse, 0,
obj->header->shadeAngleY, obj->header->shadeAngleZ);
if (obj->header->unk3D != 0) {
if (obj->header->shadeIntensityy != 0) {
obj->shading->lightR = obj->header->unk3A;
obj->shading->lightG = obj->header->unk3B;
obj->shading->lightB = obj->header->unk3C;
obj->shading->lightIntensity = obj->header->unk3D;
obj->shading->lightIntensity = obj->header->shadeIntensityy;
obj->shading->lightDirX = -(obj->shading->shadowDirX >> 1);
obj->shading->lightDirY = -(obj->shading->shadowDirY >> 1);
obj->shading->lightDirZ = -(obj->shading->shadowDirZ >> 1);
@@ -2596,7 +2596,7 @@ void obj_destroy(Object *obj, s32 arg1) {
}
if (obj->lightData != NULL) {
for (i = 0; i < obj->header->numLightSources; i++) {
func_80032BAC(obj->lightData[i]);
light_remove(obj->lightData[i]);
}
}
switch (obj->behaviorId) {
@@ -2653,7 +2653,7 @@ void obj_destroy(Object *obj, s32 arg1) {
i = BHV_RACER;
break;
case BHV_LIGHT_RGBA:
func_80032BAC(obj->light);
light_remove(obj->light);
i = BHV_RACER;
break;
@@ -2899,12 +2899,12 @@ void obj_update(s32 updateRate) {
}
// Update lights
lightUpdateLights(updateRate);
if (get_light_count() > 0) {
light_update_all(updateRate);
if (light_count() > 0) {
for (i = gObjectListStart; i < gObjectCount; i++) {
obj = gObjPtrList[i];
if (!(obj->trans.flags & OBJ_FLAGS_PARTICLE) && (obj->shading != NULL)) {
func_80032C7C(obj);
light_update_shading(obj);
}
}
}
@@ -7840,11 +7840,11 @@ UNUSED void add_shading_properties(Object *obj, f32 ambientChange, f32 diffuseCh
set_shading_properties(obj->shading, obj->shading->ambient, obj->shading->diffuse,
(obj->shading->unk22 + angleX), (obj->shading->unk24 + angleY),
(obj->shading->unk26 + angleZ));
if (obj->header->unk3D != 0) {
if (obj->header->shadeIntensityy != 0) {
obj->shading->lightR = obj->header->unk3A;
obj->shading->lightG = obj->header->unk3B;
obj->shading->lightB = obj->header->unk3C;
obj->shading->lightIntensity = obj->header->unk3D;
obj->shading->lightIntensity = obj->header->shadeIntensityy;
obj->shading->lightDirX = -(obj->shading->shadowDirX >> 1);
obj->shading->lightDirY = -(obj->shading->shadowDirY >> 1);
obj->shading->lightDirZ = -(obj->shading->shadowDirZ >> 1);
@@ -7967,7 +7967,7 @@ void calc_dynamic_lighting_for_object_1(Object *object, ObjectModel *model, s16
objRot.z_rotation = -object->trans.rotation.z_rotation;
vec3f_rotate_ypr(&objRot, &direction);
if (object->header->unk3D != 0 && arg2) {
if (object->header->shadeIntensityy != 0 && arg2) {
mtxf_transform_dir(get_projection_matrix_f32(), &direction, &direction);
}
+17 -17
View File
@@ -479,21 +479,21 @@ compute_grid_overlap_mask = 0x800314DC;
resolve_collisions = 0x80031600;
// lights.c .text
free_lights = 0x80031B60;
setup_lights = 0x80031BB8;
func_80031CAC = 0x80031CAC;
add_object_light = 0x80031F88;
disable_object_light = 0x80032210;
enable_object_light = 0x80032218;
toggle_object_light = 0x80032224;
func_80032248 = 0x80032248;
func_80032344 = 0x80032344;
lightUpdateLights = 0x80032398;
func_80032424 = 0x80032424;
func_80032BAC = 0x80032BAC;
get_light_count = 0x80032C6C;
func_80032C7C = 0x80032C7C;
func_800337E4 = 0x800337E4;
lights_free = 0x80031B60;
lights_init = 0x80031BB8;
light_add_from_level_object_entry = 0x80031CAC;
light_add_from_object_header = 0x80031F88;
light_disable = 0x80032210;
light_enable = 0x80032218;
light_toggle = 0x80032224;
light_setup_colour_change = 0x80032248;
light_setup_intensity_change = 0x80032344;
light_update_all = 0x80032398;
light_update = 0x80032424;
light_remove = 0x80032BAC;
light_count = 0x80032C6C;
light_update_shading = 0x80032C7C;
light_update_ambience = 0x800337E4;
light_distance_calc = 0x80033A14;
light_direction_calc = 0x80033C08;
@@ -2253,10 +2253,10 @@ D_800DC92C = 0x800DE2CC;
// lights.c .data
gActiveLights = 0x800DE2F0;
D_800DC954 = 0x800DE2F4;
gActiveLightAttrs = 0x800DE2F4;
gMaxLights = 0x800DE2F8;
gNumActiveLights = 0x800DE2FC;
D_800DC960 = 0x800DE300;
gShadeBuffer = 0x800DE300;
gLightDirs = 0x800DE304;
D_800DC968 = 0x800DE308;
+17 -17
View File
@@ -479,21 +479,21 @@ compute_grid_overlap_mask = 0x800314DC;
resolve_collisions = 0x80031600;
// lights.c .text
free_lights = 0x80031B60;
setup_lights = 0x80031BB8;
func_80031CAC = 0x80031CAC;
add_object_light = 0x80031F88;
disable_object_light = 0x80032210;
enable_object_light = 0x80032218;
toggle_object_light = 0x80032224;
func_80032248 = 0x80032248;
func_80032344 = 0x80032344;
lightUpdateLights = 0x80032398;
func_80032424 = 0x80032424;
func_80032BAC = 0x80032BAC;
get_light_count = 0x80032C6C;
func_80032C7C = 0x80032C7C;
func_800337E4 = 0x800337E4;
lights_free = 0x80031B60;
lights_init = 0x80031BB8;
light_add_from_level_object_entry = 0x80031CAC;
light_add_from_object_header = 0x80031F88;
light_disable = 0x80032210;
light_enable = 0x80032218;
light_toggle = 0x80032224;
light_setup_colour_change = 0x80032248;
light_setup_intensity_change = 0x80032344;
light_update_all = 0x80032398;
light_update = 0x80032424;
light_remove = 0x80032BAC;
light_count = 0x80032C6C;
light_update_shading = 0x80032C7C;
light_update_ambience = 0x800337E4;
light_distance_calc = 0x80033A14;
light_direction_calc = 0x80033C08;
@@ -2149,10 +2149,10 @@ gVoidData = 0x800DC9B4;
D_800DC928 = 0x800DC9B8;
D_800DC92C = 0x800DC9BC;
gActiveLights = 0x800DC9E0;
D_800DC954 = 0x800DC9E4;
gActiveLightAttrs = 0x800DC9E4;
gMaxLights = 0x800DC9E8;
gNumActiveLights = 0x800DC9EC;
D_800DC960 = 0x800DC9F0;
gShadeBuffer = 0x800DC9F0;
gLightDirs = 0x800DC9F4;
D_800DC968 = 0x800DC9F8;
gTajTransformTransitionEnd = 0x800DCA00;
+17 -17
View File
@@ -471,21 +471,21 @@ compute_scene_camera_transform_matrix = 0x80031058;
generate_collision_candidates = 0x80031170;
compute_grid_overlap_mask = 0x8003151C;
resolve_collisions = 0x80031640;
free_lights = 0x80031BA0;
setup_lights = 0x80031BF8;
func_80031CAC = 0x80031CEC;
add_object_light = 0x80031FC8;
disable_object_light = 0x80032250;
enable_object_light = 0x80032258;
toggle_object_light = 0x80032264;
func_80032248 = 0x80032288;
func_80032344 = 0x80032384;
lightUpdateLights = 0x800323D8;
func_80032424 = 0x80032464;
func_80032BAC = 0x80032BEC;
get_light_count = 0x80032CAC;
func_80032C7C = 0x80032CBC;
func_800337E4 = 0x80033824;
lights_free = 0x80031BA0;
lights_init = 0x80031BF8;
light_add_from_level_object_entry = 0x80031CEC;
light_add_from_object_header = 0x80031FC8;
light_disable = 0x80032250;
light_enable = 0x80032258;
light_toggle = 0x80032264;
light_setup_colour_change = 0x80032288;
light_setup_intensity_change = 0x80032384;
light_update_all = 0x800323D8;
light_update = 0x80032464;
light_remove = 0x80032BEC;
light_count = 0x80032CAC;
light_update_shading = 0x80032CBC;
light_update_ambience = 0x80033824;
light_distance_calc = 0x80033A54;
light_direction_calc = 0x80033C48;
obj_init_scenery = 0x80033D00;
@@ -2076,10 +2076,10 @@ gVoidData = 0x800DCF24;
D_800DC928 = 0x800DCF28;
D_800DC92C = 0x800DCF2C;
gActiveLights = 0x800DCF50;
D_800DC954 = 0x800DCF54;
gActiveLightAttrs = 0x800DCF54;
gMaxLights = 0x800DCF58;
gNumActiveLights = 0x800DCF5C;
D_800DC960 = 0x800DCF60;
gShadeBuffer = 0x800DCF60;
gLightDirs = 0x800DCF64;
D_800DC968 = 0x800DCF68;
gTajTransformTransitionEnd = 0x800DCF70;
+17 -17
View File
@@ -479,21 +479,21 @@ compute_grid_overlap_mask = 0x800314DC;
resolve_collisions = 0x80031600;
// lights.c .text
free_lights = 0x80031B60;
setup_lights = 0x80031BB8;
func_80031CAC = 0x80031CAC;
add_object_light = 0x80031F88;
disable_object_light = 0x80032210;
enable_object_light = 0x80032218;
toggle_object_light = 0x80032224;
func_80032248 = 0x80032248;
func_80032344 = 0x80032344;
lightUpdateLights = 0x80032398;
func_80032424 = 0x80032424;
func_80032BAC = 0x80032BAC;
get_light_count = 0x80032C6C;
func_80032C7C = 0x80032C7C;
func_800337E4 = 0x800337E4;
lights_free = 0x80031B60;
lights_init = 0x80031BB8;
light_add_from_level_object_entry = 0x80031CAC;
light_add_from_object_header = 0x80031F88;
light_disable = 0x80032210;
light_enable = 0x80032218;
light_toggle = 0x80032224;
light_setup_colour_change = 0x80032248;
light_setup_intensity_change = 0x80032344;
light_update_all = 0x80032398;
light_update = 0x80032424;
light_remove = 0x80032BAC;
light_count = 0x80032C6C;
light_update_shading = 0x80032C7C;
light_update_ambience = 0x800337E4;
light_distance_calc = 0x80033A14;
light_direction_calc = 0x80033C08;
@@ -2248,10 +2248,10 @@ D_800DC92C = 0x800DC92C;
// lights.c .data
gActiveLights = 0x800DC950;
D_800DC954 = 0x800DC954;
gActiveLightAttrs = 0x800DC954;
gMaxLights = 0x800DC958;
gNumActiveLights = 0x800DC95C;
D_800DC960 = 0x800DC960;
gShadeBuffer = 0x800DC960;
gLightDirs = 0x800DC964;
D_800DC968 = 0x800DC968;
+17 -17
View File
@@ -471,21 +471,21 @@ compute_scene_camera_transform_matrix = 0x80031058;
generate_collision_candidates = 0x80031170;
compute_grid_overlap_mask = 0x8003151C;
resolve_collisions = 0x80031640;
free_lights = 0x80031BA0;
setup_lights = 0x80031BF8;
func_80031CAC = 0x80031CEC;
add_object_light = 0x80031FC8;
disable_object_light = 0x80032250;
enable_object_light = 0x80032258;
toggle_object_light = 0x80032264;
func_80032248 = 0x80032288;
func_80032344 = 0x80032384;
lightUpdateLights = 0x800323D8;
func_80032424 = 0x80032464;
func_80032BAC = 0x80032BEC;
get_light_count = 0x80032CAC;
func_80032C7C = 0x80032CBC;
func_800337E4 = 0x80033824;
lights_free = 0x80031BA0;
lights_init = 0x80031BF8;
light_add_from_level_object_entry = 0x80031CEC;
light_add_from_object_header = 0x80031FC8;
light_disable = 0x80032250;
light_enable = 0x80032258;
light_toggle = 0x80032264;
light_setup_colour_change = 0x80032288;
light_setup_intensity_change = 0x80032384;
light_update_all = 0x800323D8;
light_update = 0x80032464;
light_remove = 0x80032BEC;
light_count = 0x80032CAC;
light_update_shading = 0x80032CBC;
light_update_ambience = 0x80033824;
light_distance_calc = 0x80033A54;
light_direction_calc = 0x80033C48;
obj_init_scenery = 0x80033D00;
@@ -2073,10 +2073,10 @@ gVoidData = 0x800DCE94;
D_800DC928 = 0x800DCE98;
D_800DC92C = 0x800DCE9C;
gActiveLights = 0x800DCEC0;
D_800DC954 = 0x800DCEC4;
gActiveLightAttrs = 0x800DCEC4;
gMaxLights = 0x800DCEC8;
gNumActiveLights = 0x800DCECC;
D_800DC960 = 0x800DCED0;
gShadeBuffer = 0x800DCED0;
gLightDirs = 0x800DCED4;
D_800DC968 = 0x800DCED8;
gTajTransformTransitionEnd = 0x800DCEE0;