diff --git a/README.md b/README.md index 35214bbb..ebbcff37 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,9 @@ 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. -As of April 8, 2025, this is our current score: +As of April 9, 2025, this is our current score: -    Decomp progress: 77.46% +    Decomp progress: 78.38%     Documentation progress: 49.86% @@ -117,20 +117,20 @@ s32 is_drumstick_unlocked(void) { ``` -As of April 8, 2025, this is our current score: +As of April 9, 2025, this is our current score: ``` ==================================================================== ADVENTURE ONE (ASM -> C Decompilation) - -------------- 77.46% Complete (80.07% NON_MATCHING) --------------- - # Decompiled functions: 1841 - # GLOBAL_ASM remaining: 110 - # NON_MATCHING functions: 14 - # NON_EQUIVALENT WIP functions: 36 + -------------- 78.38% Complete (80.98% NON_MATCHING) --------------- + # Decompiled functions: 1844 + # GLOBAL_ASM remaining: 107 + # NON_MATCHING functions: 13 + # NON_EQUIVALENT WIP functions: 35 --------------------------- Game Status ---------------------------- Balloons: 37/47, Keys: 4/4, Trophies: 3/5 T.T. Amulets: 4/4, Wizpig Amulets: 3/4 -------------------------------------------------------------------- - We are collecting silver coins in Boulder Canyon. (1/8 silver coins) + We are collecting silver coins in Boulder Canyon. (6/8 silver coins) ==================================================================== ADVENTURE TWO (Cleanup & Documentation) ------------------------- 49.86% Complete -------------------------- diff --git a/include/PR/libaudio.h b/include/PR/libaudio.h index 0e35affb..737c35e3 100644 --- a/include/PR/libaudio.h +++ b/include/PR/libaudio.h @@ -599,7 +599,7 @@ typedef struct ALSoundState { /* 0x0C */ ALVoice voice; /* 0x28 */ ALSound *sound; /* sound referenced here */ /* 0x2C */ s16 priority; - /* 0x30 */ f32 pitch; /* current playback pitch */ + /* 0x30 */ struct ALSoundState *unk30; /* 0x34 */ u8 pad34[0x2]; /* 0x34 */ u8 soundPriority; /* 0x38 */ s16 vol; /* volume - combined with volume from bank */ diff --git a/include/f3ddkr.h b/include/f3ddkr.h index f475758c..bde6cae4 100644 --- a/include/f3ddkr.h +++ b/include/f3ddkr.h @@ -126,4 +126,10 @@ _g->words.w1 = rgba; \ } +#if defined(F3DDKR_GBI) + // ?????? - Needed to modify this to work with matching build_tex_display_list +#undef TXL2WORDS_4b +#define TXL2WORDS_4b(txls) ((txls)/16) +#endif + #endif diff --git a/include/structs.h b/include/structs.h index 9f5bc0f1..daf81024 100644 --- a/include/structs.h +++ b/include/structs.h @@ -7,6 +7,7 @@ #include "enums.h" #include "level_object_entries.h" #include "object_properties.h" +#include "gbi.h" // Stolen from PD // This hacky structure allows coords to be accessed using @@ -127,7 +128,7 @@ typedef struct TextureHeader { // 0x80 = V clamp flag. 0 = Wrap, 1 = Clamp /* 0x08 */ s16 ciPaletteOffset; /* 0x0A */ s16 numberOfCommands; // initialized in RAM; Number of commands in the texture display list. (Usually 0x07) - /* 0x0C */ s32 *cmd; // initialized in RAM; Pointer to texture display list. + /* 0x0C */ Gfx *cmd; // initialized in RAM; Pointer to texture display list. /* 0x10 */ u8 unk10; /* 0x11 */ u8 unk11; /* 0x12 */ u16 numOfTextures; // For animated textures, static textures are just 0x01. Each texture has it's own header. diff --git a/src/audio_spatial.c b/src/audio_spatial.c index af40cd7e..0998c87c 100644 --- a/src/audio_spatial.c +++ b/src/audio_spatial.c @@ -180,7 +180,7 @@ s32 func_800090C0(f32 x, f32 z, s32 yRot) { * Write the adjusted positions to the arguments. * Returns the distance between the input and the nearest endpoint. */ -s32 audioline_distance(f32 inX, f32 inY, f32 inZ, floatXYZVals *floatXYZ, f32 *outX, f32 *outY, f32 *outZ) { +s32 audioline_distance(f32 inX, f32 inY, f32 inZ, f32 coords[6], f32 *outX, f32 *outY, f32 *outZ) { f32 dx, dy, dz; f32 x1, y1, z1; f32 x2, y2, z2; @@ -188,12 +188,12 @@ s32 audioline_distance(f32 inX, f32 inY, f32 inZ, floatXYZVals *floatXYZ, f32 *o f32 mag; f32 ret; - x1 = floatXYZ->x1; - y1 = floatXYZ->y1; - z1 = floatXYZ->z1; - x2 = floatXYZ->x2; - y2 = floatXYZ->y2; - z2 = floatXYZ->z2; + x1 = coords[0]; + y1 = coords[1]; + z1 = coords[2]; + x2 = coords[3]; + y2 = coords[4]; + z2 = coords[5]; mag = 0.0f; dx = x2 - x1; @@ -305,7 +305,7 @@ void audioline_ambient_create(u8 arg0, u16 soundId, f32 x, f32 y, f32 z, u8 arg5 if (lineID < 7 && argC < 30) { temp_v1 = &D_80119C58[lineID]; - temp_a0 = &temp_v1->unk4[argC * 3]; + temp_a0 = &temp_v1->unk4.unk4_floats[argC * 3]; temp_a0[0] = x; temp_a0[1] = y; temp_a0[2] = z; @@ -325,51 +325,41 @@ void audioline_ambient_create(u8 arg0, u16 soundId, f32 x, f32 y, f32 z, u8 arg5 } } -#ifdef NON_MATCHING -// single regalloc diff -// audioline_reverb_create -void func_80009968(f32 x, f32 y, f32 z, u8 arg3, u8 arg4, u8 arg5) { - Vec3f *temp_a1; - s32 tempArg5 = arg5; - - if ((arg4 < 7) && (tempArg5 < 15)) { - temp_a1 = (Vec3f *) &D_8011A6D8[arg4].unk4.unk4_05; - temp_a1[tempArg5].x = x; - temp_a1[tempArg5].y = y; - temp_a1[tempArg5].z = z; - if (tempArg5 == 0) { - D_8011A6D8[arg4].unk0.unk0_02 = arg3 & 0xFF; +void audioline_reverb_create(f32 x, f32 y, f32 z, u8 arg3, u8 arg4, u8 arg5) { + unk8011A6D8 *temp; + if (arg4 < ARRAY_COUNT(D_8011A6D8) && arg5 < ARRAY_COUNT(D_8011A6D8[0].unk4.unk4_vec)) { + temp = &D_8011A6D8[arg4]; + temp->unk4.unk4_floats[3 * arg5 + 0] = x; + temp->unk4.unk4_floats[3 * arg5 + 1] = y; + temp->unk4.unk4_floats[3 * arg5 + 2] = z; + if (arg5 == 0) { + temp->unk0.unk0_02 = arg3; } - if (D_8011A6D8[arg4].unkB8 < tempArg5) { - D_8011A6D8[arg4].unkB8 = tempArg5; + if (temp->unkB8 < arg5) { + temp->unkB8 = arg5; } } } -#else -#pragma GLOBAL_ASM("asm/nonmatchings/audio_spatial/func_80009968.s") -#endif s32 func_800099EC(u8 arg0) { s32 ret; - f32 *var_a2; - f32 temp_f0; s32 i; unk80119C58 *temp_v0; + Vec3f *var_a2; ret = 1; temp_v0 = &D_80119C58[arg0]; - var_a2 = (f32 *) &temp_v0->unk4; + var_a2 = temp_v0->unk4.unk4_vec; if (temp_v0->unk17C <= 0) { return 0; } for (i = 0; i < temp_v0->unk17C; i++) { - temp_f0 = *var_a2; - if (temp_f0 == -100000.0 || temp_f0 + 1 == -100000.0 || temp_f0 + 2 == -100000.0) { + if (var_a2->x == -100000.0 || var_a2->x + 1 == -100000.0 || var_a2->x + 2 == -100000.0) { ret = 0; } - var_a2 += 3; + var_a2 += 1; } return ret; @@ -377,25 +367,23 @@ s32 func_800099EC(u8 arg0) { s32 func_80009AB4(u8 arg0) { s32 ret; - f32 *var_a2; - f32 temp_f0; s32 i; unk8011A6D8 *temp_v0; + Vec3f *var_a2; ret = 1; temp_v0 = &D_8011A6D8[arg0]; - var_a2 = (f32 *) &temp_v0->unk4; + var_a2 = temp_v0->unk4.unk4_vec; if (temp_v0->unkB8 <= 0) { return 0; } for (i = 0; i < temp_v0->unkB8; i++) { - temp_f0 = *var_a2; - if (temp_f0 == -100000.0 || temp_f0 + 1 == -100000.0 || temp_f0 + 2 == -100000.0) { + if (var_a2->x == -100000.0 || var_a2->x + 1 == -100000.0 || var_a2->x + 2 == -100000.0) { ret = 0; } - var_a2 += 3; + var_a2 += 1; } return ret; @@ -406,27 +394,29 @@ u8 func_80009D6C(unk8011A6D8 *, f32, f32, f32); // audioline_reverb void func_80009B7C(s32 *soundState, f32 x, f32 y, f32 z) { s32 j; + s32 levelSegmentIndex; + s32 numOfYVals; + s32 distBetween; f32 outX; f32 outY; f32 outZ; - s32 levelSegmentIndex; - f32 yVals[8]; // Not sure of the number needed - s32 distBetween; - s32 numOfYVals; u8 temp_v0_4; u8 volume; s32 var_s6; s32 i; s32 k; + unk8011A6D8 *temp; + f32 yVals[9]; // Not sure of the number needed levelSegmentIndex = get_level_segment_index_from_position(x, y, z); volume = 0; var_s6 = 400; for (i = 0; i < ARRAY_COUNT(D_8011A6D8); i++) { - if (D_8011A6D8[i].unk0.unk0_02 != 0) { + temp = &D_8011A6D8[i]; + if (temp->unk0.unk0_02 != 0) { if (func_80009AB4(i) != 0) { - for (j = 0; j < D_8011A6D8[i].unkB8; j++) { - distBetween = audioline_distance(x, y, z, &D_8011A6D8[i].unk4.unk4_02[j], &outX, &outY, &outZ); + for (j = 0; j < temp->unkB8; j++) { + distBetween = audioline_distance(x, y, z, &temp->unk4.unk4_vec[j], &outX, &outY, &outZ); if (distBetween < var_s6) { numOfYVals = func_8002BAB0(levelSegmentIndex, x, z, yVals); for (k = 0; k < numOfYVals; k++) { @@ -444,7 +434,7 @@ void func_80009B7C(s32 *soundState, f32 x, f32 y, f32 z) { } } if (soundState != NULL) { - sound_event_update((s32) soundState, 0x100, (u32) volume); + sound_event_update((s32) soundState, AL_SNDP_FX_EVT, (u32) volume); } } #else @@ -454,24 +444,26 @@ void func_80009B7C(s32 *soundState, f32 x, f32 y, f32 z) { #pragma GLOBAL_ASM("asm/nonmatchings/audio_spatial/func_80009D6C.s") #ifdef NON_EQUIVALENT -extern unk80119C58 **D_80119C5C; -extern unk8011A6D8 **D_8011A6DC; // debug_render_audio_effects void func_8000A184(Gfx **arg0, Vertex **arg1, Triangle **arg2) { s32 i, j; + unk80119C58 *temp; + unk8011A6D8 *temp2; for (i = 0; i < ARRAY_COUNT(D_80119C58); i++) { - if (D_80119C58[i].soundID != 0) { - for (j = 0; j < D_80119C58[i].unk17C; j++) { - debug_render_line(arg0, arg1, arg2, (floatXYZVals *) &D_80119C5C[i], 0xFF, 0xFF, 0); + temp = &D_80119C58[i]; + if (temp->soundID != 0) { + for (j = 0; j < temp->unk17C; j++) { + debug_render_line(arg0, arg1, arg2, &temp->unk4.unk4_vec[j], 0xFF, 0xFF, 0); } } } for (i = 0; i < ARRAY_COUNT(D_8011A6D8); i++) { - if (D_8011A6D8[i].unk0.unk0_02 != 0) { - for (j = 0; j < D_8011A6D8[i].unkB8; j++) { - debug_render_line(arg0, arg1, arg2, (floatXYZVals *) &D_8011A6DC[i], 0xFF, 0xFF, 0); + temp2 = &D_8011A6D8[i]; + if (temp2->unk0.unk0_02 != 0) { + for (j = 0; j < temp2->unkB8; j++) { + debug_render_line(arg0, arg1, arg2, &temp->unk4.unk4_vec[j], 0xFF, 0, 0xFF); } } } @@ -500,7 +492,7 @@ void func_8000A2E8(s32 arg0) { * Generates and renders a coloured line visible from anywhere. * Allows use of a colour, that interpolates from bright to dark from the beginning to the end of the line. */ -void debug_render_line(Gfx **dList, Vertex **verts, Triangle **tris, floatXYZVals *coords, u8 red, u8 green, u8 blue) { +void debug_render_line(Gfx **dList, Vertex **verts, Triangle **tris, f32 coords[6], u8 red, u8 green, u8 blue) { Gfx *temp_dlist; Vertex *temp_verts; Triangle *temp_tris; @@ -511,12 +503,12 @@ void debug_render_line(Gfx **dList, Vertex **verts, Triangle **tris, floatXYZVal s16 y2; s16 z2; - x1 = coords->x1; - y1 = coords->y1; - z1 = coords->z1; - x2 = coords->x2; - y2 = coords->y2; - z2 = coords->z2; + x1 = coords[0]; + y1 = coords[1]; + z1 = coords[2]; + x2 = coords[3]; + y2 = coords[4]; + z2 = coords[5]; temp_dlist = *dList; temp_verts = *verts; diff --git a/src/audio_spatial.h b/src/audio_spatial.h index 77d7d931..b4820c74 100644 --- a/src/audio_spatial.h +++ b/src/audio_spatial.h @@ -22,6 +22,29 @@ typedef struct unk8011A6D8_04 { /* 0x08 */ f32 unk8; } unk8011A6D8_04; +/* Size: 0x180 / 384 bytes */ +typedef struct unk80119C58 { + union { + /* 0x00 */ f32 unk0_01; + /* 0x00 */ u8 unk0_02; + /* 0x00 */ s32 unk0_03; + } unk0; + union { + /* 0x004 */ f32 unk4_floats[30 * 3]; // Should be a Vec3f, but that just doesn't match + /* 0x004 */ Vec3f unk4_vec[30]; + } unk4; + /* 0x16C */ s32 soundID; + /* 0x170 */ s32 unk170; + /* 0x174 */ u8 unk174; + /* 0x175 */ u8 unk175; + /* 0x176 */ u8 unk176; + /* 0x177 */ u8 unk177; + /* 0x178 */ s32 unk178; + /* 0x17C */ s8 unk17C; + /* 0x17D */ u8 unk17D; + /* 0x17E */ u8 unk17E; +} unk80119C58; + /* Size: 0xC0 / 192 bytes - Thought it was a LevelHeader, but that didn't match other usages */ typedef struct unk8011A6D8 { union { @@ -29,13 +52,9 @@ typedef struct unk8011A6D8 { /* 0x00 */ u8 unk0_02; } unk0; union { - /* 0x04 */ unk8011A6D8_04 *unk4_01; - /* 0x04 */ floatXYZVals *unk4_02; - /* 0x04 */ unk8011A6D8_04 **unk4_03; - /* 0x04 */ Vec3f **unk4_04; - /* 0x04 */ Vec3f *unk4_05; + f32 unk4_floats[15 * 3]; + Vec3f unk4_vec[15]; } unk4; - /* 0x05 */ u8 pad05[0xB0]; /* 0xB8 */ s8 unkB8; /* 0xB9 */ u8 padB9[0x03]; /* 0xBC */ f32 unkBC; @@ -62,14 +81,14 @@ void func_800095E8(u16 soundId, f32 x, f32 y, f32 z, u8 arg4, u8 arg5, f32 pitch void audioline_ambient_create(u8 arg0, u16 soundId, f32 x, f32 y, f32 z, u8 arg5, u8 arg6, u8 arg7, u8 arg8, u16 arg9, u8 argA, u8 lineID, u8 argC); s32 func_800099EC(u8 arg0); -void debug_render_line(Gfx **dList, Vertex **verts, Triangle **tris, floatXYZVals *coords, u8 red, u8 green, u8 blue); +void debug_render_line(Gfx **dList, Vertex **verts, Triangle **tris, f32 coords[6], u8 red, u8 green, u8 blue); void func_80006BFC(Object *obj, ObjectSegment *segment, Object *obj2, s32 updateRate); void update_spatial_audio_position(SoundMask *arg0, f32 x, f32 y, f32 z); s32 func_80009AB4(u8 arg0); void audioline_init(void); +void audioline_reverb_create(f32, f32, f32, u8, u8, u8); -s32 audioline_distance(f32 inX, f32 inY, f32 inZ, floatXYZVals *floatXYZ, f32 *outX, f32 *outY, f32 *outZ); -void func_80009968(f32, f32, f32, u8, u8, u8); // Non Matching +s32 audioline_distance(f32 inX, f32 inY, f32 inZ, f32 coords[6], f32 *outX, f32 *outY, f32 *outZ); void func_80008174(void); // Non Matching void func_80008438(Object **arg0, s32 numRacers, s32 updateRate); // Non Matching void func_80006FC8(Object **objs, s32 numRacers, ObjectSegment *segment, u8 arg3, s32 updateRate); // Non Matching diff --git a/src/audio_vehicle.c b/src/audio_vehicle.c index 533452ed..02a7c789 100644 --- a/src/audio_vehicle.c +++ b/src/audio_vehicle.c @@ -325,7 +325,7 @@ void func_80005254(Object *obj, u32 buttonsPressed, u32 buttonsHeld, s32 updateR sp6C = (((var_f20 * 0.5) / 12.0) + 0.5); temp_a0_4 = (s32) gRacerSound->unkA8; if (temp_a0_4 != 0) { - sound_event_update(temp_a0_4, 16, *((u32 *) &sp6C)); + sound_event_update(temp_a0_4, AL_SNDP_PITCH_EVT, *((u32 *) &sp6C)); } gRacerSound->unkAC = 110; gRacerSound->unkD0 = 0; @@ -337,9 +337,9 @@ void func_80005254(Object *obj, u32 buttonsPressed, u32 buttonsHeld, s32 updateR gRacerSound->unkD0 = 0; } if (gRacerSound->unkD0 >= 10) { - sound_event_update((s32) gRacerSound->unkA8, 8, 0); + sound_event_update((s32) gRacerSound->unkA8, AL_SNDP_VOL_EVT, 0); } else { - sound_event_update((s32) gRacerSound->unkA8, 8, gRacerSound->unkAC << 8); + sound_event_update((s32) gRacerSound->unkA8, AL_SNDP_VOL_EVT, gRacerSound->unkAC << 8); func_80009B7C((s32 *) gRacerSound->unkA8, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position); } @@ -732,10 +732,10 @@ void func_80006FC8(Object **objs, s32 numRacers, ObjectSegment *segment, u8 arg3 func_80009B7C((s32 *) gRacerSound->unk50, objs[loopCount1]->segment.trans.x_position, objs[loopCount1]->segment.trans.y_position, objs[loopCount1]->segment.trans.z_position); - sound_event_update((s32) gRacerSound->unk50, 8, temp_s3 << 8); - sound_event_update((s32) gRacerSound->unk50, 16, *((u32 *) &sp8C)); + sound_event_update((s32) gRacerSound->unk50, AL_SNDP_VOL_EVT, temp_s3 << 8); + sound_event_update((s32) gRacerSound->unk50, AL_SNDP_PITCH_EVT, *((u32 *) &sp8C)); func_80004604((ALSoundState *) gRacerSound->unk50, 80); - sound_event_update((s32) gRacerSound->unk50, 4, gRacerSound->unk91[0]); + sound_event_update((s32) gRacerSound->unk50, AL_SNDP_PAN_EVT, gRacerSound->unk91[0]); } } else if (gRacerSound->unk50 != NULL) { sound_stop(gRacerSound->unk50); @@ -769,13 +769,15 @@ void func_80006FC8(Object **objs, s32 numRacers, ObjectSegment *segment, u8 arg3 func_80009B7C( (s32 *) gRacerSound->unk48[loopCount2], objs[loopCount1]->segment.trans.x_position, objs[loopCount1]->segment.trans.y_position, objs[loopCount1]->segment.trans.z_position); - sound_event_update((s32) gRacerSound->unk48[loopCount2], 8, temp_s3 << 8); - sound_event_update((s32) gRacerSound->unk48[loopCount2], 16, *((u32 *) &sp8C)); + sound_event_update((s32) gRacerSound->unk48[loopCount2], AL_SNDP_VOL_EVT, temp_s3 << 8); + sound_event_update((s32) gRacerSound->unk48[loopCount2], AL_SNDP_PITCH_EVT, + *((u32 *) &sp8C)); func_80004604((ALSoundState *) gRacerSound->unk48[loopCount2], 80); if (arg3 != 1) { gRacerSound->unk91[0] = 64; } - sound_event_update((s32) gRacerSound->unk48[loopCount2], 4, gRacerSound->unk91[0]); + sound_event_update((s32) gRacerSound->unk48[loopCount2], AL_SNDP_PAN_EVT, + gRacerSound->unk91[0]); } } } @@ -910,12 +912,12 @@ void func_80006FC8(Object **objs, s32 numRacers, ObjectSegment *segment, u8 arg3 if (temp->unk48[0] != NULL) { func_80009B7C((s32 *) temp->unk48[0], temp->racerPos.x, temp->racerPos.y, temp->racerPos.z); - sound_event_update((s32) temp->unk48[0], 8, temp->unk88 << 8); - sound_event_update((s32) temp->unk48[0], 16, *((u32 *) &temp->unk8C)); + sound_event_update((s32) temp->unk48[0], AL_SNDP_VOL_EVT, temp->unk88 << 8); + sound_event_update((s32) temp->unk48[0], AL_SNDP_PITCH_EVT, *((u32 *) &temp->unk8C)); if (arg3 != 1) { temp->unk91[0] = 64; } - sound_event_update((s32) temp->unk48[0], 4, temp->unk91[0]); + sound_event_update((s32) temp->unk48[0], AL_SNDP_PAN_EVT, temp->unk91[0]); func_80004604((ALSoundState *) temp->unk48[0], 70); } } diff --git a/src/audio_vehicle.h b/src/audio_vehicle.h index 041574f7..a76a819c 100644 --- a/src/audio_vehicle.h +++ b/src/audio_vehicle.h @@ -5,26 +5,6 @@ #include "structs.h" #include "audio.h" -/* Size: 0x180 / 384 bytes */ -typedef struct unk80119C58 { - union { - /* 0x00 */ f32 unk0_01; - /* 0x00 */ u8 unk0_02; - /* 0x00 */ s32 unk0_03; - } unk0; - /* 0x004 */ f32 unk4[30 * 3]; // Should be a Vec3f, but that just doesn't match - /* 0x16C */ s32 soundID; - /* 0x170 */ s32 unk170; - /* 0x174 */ u8 unk174; - /* 0x175 */ u8 unk175; - /* 0x176 */ u8 unk176; - /* 0x177 */ u8 unk177; - /* 0x178 */ s32 unk178; - /* 0x17C */ s8 unk17C; - /* 0x17D */ u8 unk17D; - /* 0x17E */ u8 unk17E; -} unk80119C58; - /* Size: 0xE0 / 224 bytes */ typedef struct VehicleSoundData { /* 0x00 */ u16 unk0[2]; diff --git a/src/audiosfx.c b/src/audiosfx.c index e250561c..1f0c0435 100644 --- a/src/audiosfx.c +++ b/src/audiosfx.c @@ -11,7 +11,7 @@ ALUnkStruct D_800DC6B0 = { NULL, NULL, NULL }; unk800DC6BC gAlSndPlayer; unk800DC6BC *gAlSndPlayerPtr = &gAlSndPlayer; s32 sfxVolumeSlider = 256; -s32 D_800DC6C4 = 0; // Currently unknown, might be a different type. +s16 D_800DC6C4 = 0; u16 *gSoundChannelVolume; /**** Debug strings ****/ @@ -262,7 +262,35 @@ ALSound *func_80004384(UNUSED ALBank *arg0, ALSound *arg1) { return (ALSound *) nextAllocList; } -#pragma GLOBAL_ASM("asm/nonmatchings/audiosfx/func_80004520.s") +void func_80004520(ALSoundState *soundState) { + if (soundState == D_800DC6B0.next) { + D_800DC6B0.next = soundState->next; + } + if (soundState == D_800DC6B0.prev) { + D_800DC6B0.prev = soundState->prev; + } + alUnlink((ALLink *) soundState); + if (D_800DC6B0.unk8 != NULL) { + soundState->next = D_800DC6B0.unk8; + soundState->prev = NULL; + D_800DC6B0.unk8->prev = soundState; + D_800DC6B0.unk8 = soundState; + } else { + soundState->prev = NULL; + soundState->next = NULL; + D_800DC6B0.unk8 = soundState; + } + if (soundState->flags & AL_SNDP_PAN_EVT) { + D_800DC6C4--; + } + soundState->soundState = 0; + if (soundState->unk30 != NULL) { + if (soundState == soundState->unk30->next) { + soundState->unk30->next = NULL; + } + soundState->unk30 = NULL; + } +} /** * Official Name: gsSndpSetPriority diff --git a/src/hasm/math_util.c b/src/hasm/math_util.c index b8fb3734..ec3eb0c8 100644 --- a/src/hasm/math_util.c +++ b/src/hasm/math_util.c @@ -329,6 +329,7 @@ GLOBAL_ASM("asm/math_util/f32_matrix_y_scale.s") #endif #ifdef NON_EQUIVALENT +/* Official Name: mathRpyXyzMtx */ void object_transform_to_matrix_2(Matrix mtx, ObjectTransform *trans) { f32 yRotSine; f32 yRotCosine; @@ -543,6 +544,7 @@ GLOBAL_ASM("asm/math_util/f32_vec3_apply_object_rotation3.s") #endif #ifdef NON_MATCHING +/* Official Name: mathXZInTri */ s32 point_triangle_2d_xz_intersection(s32 x, s32 z, s16 *vec3A, s16 *vec3B, s16 *vec3C) { s32 result; s32 aX; @@ -586,6 +588,7 @@ GLOBAL_ASM("asm/math_util/point_triangle_2d_xz_intersection.s") #endif #ifdef NON_EQUIVALENT +/* Official Name: mathTranslateMtx */ void f32_matrix_from_position(Matrix *mtx, f32 x, f32 y, f32 z) { s32 j; s32 i; @@ -607,6 +610,7 @@ void f32_matrix_from_position(Matrix *mtx, f32 x, f32 y, f32 z) { GLOBAL_ASM("asm/math_util/f32_matrix_from_position.s") #endif +/* Official Name: mathScaleMtx */ GLOBAL_ASM("asm/math_util/f32_matrix_from_scale.s") #ifdef NON_MATCHING diff --git a/src/hasm/math_util.s b/src/hasm/math_util.s index fa3077d3..87e7d1f2 100644 --- a/src/hasm/math_util.s +++ b/src/hasm/math_util.s @@ -27,6 +27,7 @@ glabel gArcTanTable /* Generated by spimdisasm 1.30.0 */ +/* Official Name: disableInterrupts */ leaf interrupts_disable /* 70110 8006F510 3C08800E */ lui $t0, %hi(gIntDisFlag) /* 70114 8006F514 8108D430 */ lb $t0, %lo(gIntDisFlag)($t0) @@ -42,6 +43,7 @@ leaf interrupts_disable /* 70138 8006F538 00000000 */ nop .end interrupts_disable +/* Official Name: enableInterrupts */ leaf interrupts_enable /* 7013C 8006F53C 3C08800E */ lui $t0, %hi(gIntDisFlag) /* 70140 8006F540 8108D430 */ lb $t0, %lo(gIntDisFlag)($t0) @@ -56,12 +58,14 @@ leaf interrupts_enable /* 70160 8006F560 00000000 */ nop .end interrupts_enable +/* Official Name: setIntDisFlag */ leaf set_gIntDisFlag /* 70164 8006F564 3C01800E */ lui $at, %hi(gIntDisFlag) /* 70168 8006F568 03E00008 */ jr $ra /* 7016C 8006F56C A024D430 */ sb $a0, %lo(gIntDisFlag)($at) .end set_gIntDisFlag +/* Official Name: getIntDisFlag */ leaf get_gIntDisFlag /* 70170 8006F570 3C02800E */ lui $v0, %hi(gIntDisFlag) /* 70174 8006F574 03E00008 */ jr $ra @@ -128,6 +132,7 @@ leaf f32_matrix_to_s32_matrix /* 70248 8006F648 00000000 */ nop .end f32_matrix_to_s32_matrix +/* Official Name: mathMtxXFMF */ leaf guMtxXFMF /* 7024C 8006F64C 44856000 */ mtc1 $a1, $f12 /* 70250 8006F650 C4840000 */ lwc1 $f4, 0x0($a0) @@ -171,6 +176,7 @@ leaf guMtxXFMF /* 702E8 8006F6E8 E7040000 */ swc1 $f4, 0x0($t8) .end guMtxXFMF +/* Official Name: mathMtxFastXFMF */ leaf f32_matrix_dot /* 702EC 8006F6EC C4A40000 */ lwc1 $f4, 0x0($a1) /* 702F0 8006F6F0 C48A0000 */ lwc1 $f10, 0x0($a0) @@ -205,6 +211,7 @@ leaf f32_matrix_dot /* 70364 8006F764 E4CE0008 */ swc1 $f14, 0x8($a2) .end f32_matrix_dot +/* Official Name: mathMtxCatF */ leaf f32_matrix_mult /* 70368 8006F768 27BDFFF8 */ addiu $sp, $sp, -0x8 /* 7036C 8006F76C F7A20000 */ sdc1 $f2, 0x0($sp) @@ -275,6 +282,7 @@ leaf f32_matrix_mult /* 7046C 8006F86C 27BD0008 */ addiu $sp, $sp, 0x8 .end f32_matrix_mult +/* Official Name: mathMtxF2L */ leaf f32_matrix_to_s16_matrix /* 70470 8006F870 3C014780 */ lui $at, (0x47800000 >> 16) /* 70474 8006F874 44816000 */ mtc1 $at, $f12 @@ -318,6 +326,7 @@ leaf f32_matrix_to_s16_matrix /* 70508 8006F908 00000000 */ nop .end f32_matrix_to_s16_matrix +/* Official Name: mathSeed */ leaf set_rng_seed /* 7050C 8006F90C 3C01800E */ lui $at, %hi(gCurrentRNGSeed) /* 70510 8006F910 03E00008 */ jr $ra @@ -346,6 +355,7 @@ leaf get_rng_seed /* 70548 8006F948 8C42D434 */ lw $v0, %lo(gCurrentRNGSeed)($v0) .end get_rng_seed +/* Official Name: mathRnd */ leaf get_random_number_from_range /* 7054C 8006F94C 3C08800E */ lui $t0, %hi(gCurrentRNGSeed) /* 70550 8006F950 8D08D434 */ lw $t0, %lo(gCurrentRNGSeed)($t0) @@ -377,6 +387,7 @@ leaf get_random_number_from_range /* 705B4 8006F9B4 00000000 */ nop .end get_random_number_from_range +/* Official Name: fastShortReflection */ leaf s16_matrix_rotate /* 705B8 8006F9B8 84880000 */ lh $t0, 0x0($a0) /* 705BC 8006F9BC 84AB0000 */ lh $t3, 0x0($a1) @@ -668,6 +679,7 @@ leaf object_transform_to_matrix /* 70A00 8006FE00 00000000 */ nop .end object_transform_to_matrix +/* Official Name: mathSquashY */ leaf f32_matrix_scale /* 70A04 8006FE04 44859000 */ mtc1 $a1, $f18 /* 70A08 8006FE08 C4900010 */ lwc1 $f16, 0x10($a0) @@ -682,6 +694,7 @@ leaf f32_matrix_scale /* 70A2C 8006FE2C E4900018 */ swc1 $f16, 0x18($a0) .end f32_matrix_scale +/* Official Name: mathTransY */ leaf f32_matrix_y_scale /* 70A30 8006FE30 44858000 */ mtc1 $a1, $f16 /* 70A34 8006FE34 C4800010 */ lwc1 $f0, 0x10($a0) @@ -702,6 +715,7 @@ leaf f32_matrix_y_scale /* 70A70 8006FE70 E4880038 */ swc1 $f8, 0x38($a0) .end f32_matrix_y_scale +/* Official Name: mathRpyXyzMtx */ leaf object_transform_to_matrix_2 /* 70A74 8006FE74 27BDFFF8 */ addiu $sp, $sp, -0x8 /* 70A78 8006FE78 3C013780 */ lui $at, (0x37800000 >> 16) @@ -1013,6 +1027,7 @@ leaf s16_vec3_apply_object_rotation /* 70F1C 8007031C 00000000 */ nop .end s16_vec3_apply_object_rotation +/* Official Name: mathOneFloatRPY */ leaf f32_vec3_apply_object_rotation /* 70F20 80070320 27BDFFF8 */ addiu $sp, $sp, -0x8 /* 70F24 80070324 FFBF0000 */ sd $ra, 0x0($sp) @@ -1062,6 +1077,7 @@ leaf f32_vec3_apply_object_rotation /* 70FD4 800703D4 00000000 */ nop .end f32_vec3_apply_object_rotation +/* Official Name: mathOneFloatYPR */ leaf f32_vec3_apply_object_rotation2 /* 70FD8 800703D8 27BDFFF8 */ addiu $sp, $sp, -0x8 /* 70FDC 800703DC FFBF0000 */ sd $ra, 0x0($sp) @@ -1111,6 +1127,7 @@ leaf f32_vec3_apply_object_rotation2 /* 7108C 8007048C 00000000 */ nop .end f32_vec3_apply_object_rotation2 +/* Official Name: mathOneFloatPY */ leaf f32_vec3_apply_object_rotation3 /* 71090 80070490 27BDFFF8 */ addiu $sp, $sp, -0x8 /* 71094 80070494 FFBF0000 */ sd $ra, 0x0($sp) @@ -1138,6 +1155,7 @@ leaf f32_vec3_apply_object_rotation3 /* 710EC 800704EC 00000000 */ nop .end f32_vec3_apply_object_rotation3 +/* Official Name: mathXZInTri */ leaf point_triangle_2d_xz_intersection /* 710F0 800704F0 8FAE0010 */ lw $t6, 0x10($sp) /* 710F4 800704F4 84C80000 */ lh $t0, 0x0($a2) @@ -1211,6 +1229,7 @@ leaf point_triangle_2d_xz_intersection /* 711F4 800705F4 00000000 */ nop .end point_triangle_2d_xz_intersection +/* Official Name: mathTranslateMtx */ leaf f32_matrix_from_position /* 711F8 800705F8 00804025 */ or $t0, $a0, $zero /* 711FC 800705FC 25090040 */ addiu $t1, $t0, 0x40 @@ -1231,6 +1250,7 @@ leaf f32_matrix_from_position /* 71234 80070634 AC870038 */ sw $a3, 0x38($a0) .end f32_matrix_from_position +/* Official Name: mathScaleMtx */ leaf f32_matrix_from_scale /* 71238 80070638 00804025 */ or $t0, $a0, $zero /* 7123C 8007063C 25090040 */ addiu $t1, $t0, 0x40 @@ -1387,57 +1407,65 @@ leaf coss_f /* 71428 80070828 00000000 */ nop .end coss_f +/* Official Name: mathCosInterp */ leaf coss_s16 -/* 7142C 8007082C 24844000 */ addiu $a0, $a0, 0x4000 -glabel sins_s16 -/* 71430 80070830 00041440 */ sll $v0, $a0, 17 -/* 71434 80070834 04430003 */ bgezl $v0, .L80070844 -/* 71438 80070838 000450C2 */ srl $t2, $a0, 3 -/* 7143C 8007083C 38847FFF */ xori $a0, $a0, 0x7FFF -/* 71440 80070840 000450C2 */ srl $t2, $a0, 3 +addiu $a0, $a0, 0x4000 +/* Fall through */ + +/* Official Name: mathSinInterp */ +glabel sins_s16 +sll $v0, $a0, 17 +bgezl $v0, .L80070844 +srl $t2, $a0, 3 +xori $a0, $a0, 0x7FFF +srl $t2, $a0, 3 .L80070844: -/* 71444 80070844 3C02800E */ lui $v0, %hi(gSineTable) -/* 71448 80070848 314A07FE */ andi $t2, $t2, 0x7FE -/* 7144C 8007084C 2442D43C */ addiu $v0, $v0, %lo(gSineTable) -/* 71450 80070850 004A1021 */ addu $v0, $v0, $t2 -/* 71454 80070854 944A0002 */ lhu $t2, 0x2($v0) -/* 71458 80070858 94420000 */ lhu $v0, 0x0($v0) -/* 7145C 8007085C 3089000F */ andi $t1, $a0, 0xF -/* 71460 80070860 00042400 */ sll $a0, $a0, 16 -/* 71464 80070864 01425023 */ subu $t2, $t2, $v0 -/* 71468 80070868 01490019 */ multu $t2, $t1 -/* 7146C 8007086C 00021040 */ sll $v0, $v0, 1 -/* 71470 80070870 00005012 */ mflo $t2 -/* 71474 80070874 000A50C2 */ srl $t2, $t2, 3 -/* 71478 80070878 04810002 */ bgez $a0, .L80070884 -/* 7147C 8007087C 004A1021 */ addu $v0, $v0, $t2 -/* 71480 80070880 00021023 */ negu $v0, $v0 +lui $v0, %hi(gSineTable) +andi $t2, $t2, 0x7FE +addiu $v0, $v0, %lo(gSineTable) +addu $v0, $v0, $t2 +lhu $t2, 0x2($v0) +lhu $v0, 0x0($v0) +andi $t1, $a0, 0xF +sll $a0, $a0, 16 +subu $t2, $t2, $v0 +multu $t2, $t1 +sll $v0, $v0, 1 +mflo $t2 +srl $t2, $t2, 3 +bgez $a0, .L80070884 + addu $v0, $v0, $t2 +negu $v0, $v0 .L80070884: -/* 71484 80070884 03E00008 */ jr $ra -/* 71488 80070888 00000000 */ nop +jr $ra +nop .end coss_s16 +/* Official Name: mathCos */ leaf coss_2 -/* 7148C 8007088C 24844000 */ addiu $a0, $a0, 0x4000 +addiu $a0, $a0, 0x4000 +/* Fall through */ + +/* Official Name: mathSin */ glabel sins_2 -/* 71490 80070890 00041440 */ sll $v0, $a0, 17 -/* 71494 80070894 04430003 */ bgezl $v0, .L800708A4 -/* 71498 80070898 000450C2 */ srl $t2, $a0, 3 -/* 7149C 8007089C 38847FFF */ xori $a0, $a0, 0x7FFF -/* 714A0 800708A0 000450C2 */ srl $t2, $a0, 3 +sll $v0, $a0, 17 +bgezl $v0, .L800708A4 +srl $t2, $a0, 3 +xori $a0, $a0, 0x7FFF +srl $t2, $a0, 3 .L800708A4: -/* 714A4 800708A4 3C02800E */ lui $v0, %hi(gSineTable) -/* 714A8 800708A8 314A07FE */ andi $t2, $t2, 0x7FE -/* 714AC 800708AC 2442D43C */ addiu $v0, $v0, %lo(gSineTable) -/* 714B0 800708B0 004A1021 */ addu $v0, $v0, $t2 -/* 714B4 800708B4 94420000 */ lhu $v0, 0x0($v0) -/* 714B8 800708B8 00042400 */ sll $a0, $a0, 16 -/* 714BC 800708BC 04810002 */ bgez $a0, .L800708C8 -/* 714C0 800708C0 00021040 */ sll $v0, $v0, 1 -/* 714C4 800708C4 00021023 */ negu $v0, $v0 +lui $v0, %hi(gSineTable) +andi $t2, $t2, 0x7FE +addiu $v0, $v0, %lo(gSineTable) +addu $v0, $v0, $t2 +lhu $v0, 0x0($v0) +sll $a0, $a0, 16 +bgez $a0, .L800708C8 +sll $v0, $v0, 1 +negu $v0, $v0 .L800708C8: -/* 714C8 800708C8 03E00008 */ jr $ra -/* 714CC 800708CC 00000000 */ nop +jr $ra +nop .end coss_2 leaf calc_dyn_lighting_for_level_segment diff --git a/src/object_functions.c b/src/object_functions.c index c2e11d94..40128723 100644 --- a/src/object_functions.c +++ b/src/object_functions.c @@ -5440,7 +5440,8 @@ void obj_init_audioreverb(Object *obj, LevelObjectEntry_AudioReverb *entry) { temp = entry->lineID; reverb->lineID = temp & 0xFF; reverb->unk5 = entry->unkA; - func_80009968(entry->common.x, entry->common.y, entry->common.z, reverb->unk2, reverb->lineID, reverb->unk5); + audioline_reverb_create(entry->common.x, entry->common.y, entry->common.z, reverb->unk2, reverb->lineID, + reverb->unk5); free_object(obj); } diff --git a/src/textures_sprites.c b/src/textures_sprites.c index ab88742a..0ec5578b 100644 --- a/src/textures_sprites.c +++ b/src/textures_sprites.c @@ -1146,167 +1146,165 @@ void func_8007CDC0(Sprite *sprite1, Sprite *sprite2, s32 arg2) { #pragma GLOBAL_ASM("asm/nonmatchings/textures_sprites/func_8007CDC0.s") #endif -#ifdef NON_EQUIVALENT -// HEAVILY WIP -// Alternative attempt: https://decomp.me/scratch/TbR8j -void build_tex_display_list(TextureHeader *tex, Gfx *dList) { - s32 texFlags; +void build_tex_display_list(TextureHeader *tex, Gfx *_dList) { + s32 texFormat; + s32 texRenderMode; + s32 width; + s32 height; s32 cms; s32 cmt; - s32 texFormat; - s32 temp_v0_4; + s32 masks; + s32 maskt; s32 i; s32 uClamp; s32 vClamp; - s32 masks; - s32 maskt; - u8 height; - u8 width; - s32 var_v0; + s32 size; + s32 texLut; + Gfx *dList; - tex->cmd = (s32 *) dList; + tex->cmd = dList = _dList; texFormat = tex->format & 0xF; - texFlags = (tex->format >> 4) & 0xF; + texRenderMode = (tex->format >> 4) & 0xF; height = tex->height; width = tex->width; - var_v0 = 1; + size = 1; masks = 1; maskt = 1; uClamp = TRUE; vClamp = TRUE; + for (i = 0; i < 7; i++) { - if (var_v0 < width) { + if (size < width) { masks = i + 1; - } - if (var_v0 == width) { + } else if ((size == width) != 0) { uClamp = FALSE; } - if (var_v0 < height) { + if (size < height) { maskt = i + 1; - } - if (var_v0 == height) { + } else if ((size == height) != 0) { vClamp = FALSE; } - var_v0 <<= 1; + size *= 2; } - if (uClamp || (tex->flags & 0x40)) { - cms = 2; - masks = 0; + + if (uClamp || (tex->flags & RENDER_CLAMP_X)) { + cms = G_TX_CLAMP; + masks = G_TX_NOMASK; } else { - cms = 0; + cms = G_TX_WRAP; } - if (vClamp || (tex->flags & 0x80)) { - cmt = 2; - maskt = 0; + + if (vClamp || (tex->flags & RENDER_CLAMP_Y)) { + cmt = G_TX_CLAMP; + maskt = G_TX_NOMASK; } else { - cmt = 0; + cmt = G_TX_WRAP; } - if (!(tex->flags & 0x400)) { - if (texFormat == 0) { + + if (!(tex->flags & RENDER_LINE_SWAP)) { + // If it is not swapped, then use the regular loadTexBlock macros. + if (texFormat == TEX_FORMAT_RGBA32) { gDPLoadTextureBlock(dList++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_RGBA, G_IM_SIZ_32b, width, height, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); - if ((texFlags == 0) || (texFlags == 2)) { - tex->flags |= 4; + if (texRenderMode == TRANSPARENT || texRenderMode == TRANSPARENT_2) { + tex->flags |= RENDER_SEMI_TRANSPARENT; } } - if (texFormat == 1) { + if (texFormat == TEX_FORMAT_RGBA16) { gDPLoadTextureBlock(dList++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_RGBA, G_IM_SIZ_16b, width, height, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); - if ((texFlags == 0) || (texFlags == 2)) { - tex->flags |= 4; + if (texRenderMode == TRANSPARENT || texRenderMode == TRANSPARENT_2) { + tex->flags |= RENDER_SEMI_TRANSPARENT; } } - if (texFormat == 7) { - gDPLoadTextureBlock(dList++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_CI, G_IM_SIZ_16b, width, height, 0, cms, - cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); - temp_v0_4 = func_8007EF64(tex->ciPaletteOffset); - gDPLoadTLUT_pal16(dList++, 0, temp_v0_4); + if (texFormat == TEX_FORMAT_CI4) { + texLut = func_8007EF64(tex->ciPaletteOffset); + gDPLoadTextureBlock_4b(dList++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_CI, width, height, 0, cms, cmt, masks, + maskt, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTLUT_pal16(dList++, 0, texLut); - tex->flags |= 0x20; - if ((texFlags == 0) || (texFlags == 2)) { - tex->flags |= 4; + tex->flags |= RENDER_COLOUR_INDEX; + if (texRenderMode == TRANSPARENT || texRenderMode == TRANSPARENT_2) { + tex->flags |= RENDER_SEMI_TRANSPARENT; } } - if (texFormat == 4) { + if (texFormat == TEX_FORMAT_IA16) { gDPLoadTextureBlock(dList++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_IA, G_IM_SIZ_16b, width, height, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); - tex->flags |= 4; + tex->flags |= RENDER_SEMI_TRANSPARENT; } - if (texFormat == 5) { + if (texFormat == TEX_FORMAT_IA8) { gDPLoadTextureBlock(dList++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_IA, G_IM_SIZ_8b, width, height, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); - tex->flags |= 4; + tex->flags |= RENDER_SEMI_TRANSPARENT; } - if (texFormat == 6) { - gDPLoadTextureBlock(dList++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_IA, G_IM_SIZ_4b, width, height, 0, cms, - cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); - tex->flags |= 4; + if (texFormat == TEX_FORMAT_IA4) { + gDPLoadTextureBlock_4b(dList++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_IA, width, height, 0, cms, cmt, masks, + maskt, G_TX_NOLOD, G_TX_NOLOD); + tex->flags |= RENDER_SEMI_TRANSPARENT; } - if (texFormat == 2) { + if (texFormat == TEX_FORMAT_I8) { gDPLoadTextureBlock(dList++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_I, G_IM_SIZ_8b, width, height, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); } - if (texFormat == 3) { - gDPLoadTextureBlock(dList++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_I, G_IM_SIZ_4b, width, height, 0, cms, - cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); + if (texFormat == TEX_FORMAT_I4) { + gDPLoadTextureBlock_4b(dList++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_I, width, height, 0, cms, cmt, masks, + maskt, G_TX_NOLOD, G_TX_NOLOD); } - tex->numberOfCommands = ((s32) ((s32) dList - (s32) tex->cmd) >> 3); + tex->numberOfCommands = dList - tex->cmd; } else { - - if (texFormat == 0) { + // Textures are swapped, so we need to use the LoadTextureBlockS macros. + if (texFormat == TEX_FORMAT_RGBA32) { gDPLoadTextureBlockS(dList++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_RGBA, G_IM_SIZ_32b, width, height, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); - if ((texFlags == 0) || (texFlags == 2)) { - tex->flags |= 4; + if (texRenderMode == TRANSPARENT || texRenderMode == TRANSPARENT_2) { + tex->flags |= RENDER_SEMI_TRANSPARENT; } } - if (texFormat == 1) { + if (texFormat == TEX_FORMAT_RGBA16) { gDPLoadTextureBlockS(dList++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_RGBA, G_IM_SIZ_16b, width, height, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); - if ((texFlags == 0) || (texFlags == 2)) { - tex->flags |= 4; + if (texRenderMode == TRANSPARENT || texRenderMode == TRANSPARENT_2) { + tex->flags |= RENDER_SEMI_TRANSPARENT; } } - if (texFormat == 7) { - gDPLoadTextureBlockS(dList++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_CI, G_IM_SIZ_16b, width, height, 0, cms, - cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); - temp_v0_4 = func_8007EF64(tex->ciPaletteOffset); - gDPLoadTLUT_pal16(dList++, 0, temp_v0_4); + if (texFormat == TEX_FORMAT_CI4) { + texLut = func_8007EF64(tex->ciPaletteOffset); + gDPLoadTextureBlock_4bS(dList++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_CI, width, height, 0, cms, cmt, masks, + maskt, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTLUT_pal16(dList++, 0, texLut); - tex->flags |= 0x20; - if ((texFlags == 0) || (texFlags == 2)) { - tex->flags |= 4; + tex->flags |= RENDER_COLOUR_INDEX; + if (texRenderMode == TRANSPARENT || texRenderMode == TRANSPARENT_2) { + tex->flags |= RENDER_SEMI_TRANSPARENT; } } - if (texFormat == 4) { + if (texFormat == TEX_FORMAT_IA16) { gDPLoadTextureBlockS(dList++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_IA, G_IM_SIZ_16b, width, height, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); - tex->flags |= 4; + tex->flags |= RENDER_SEMI_TRANSPARENT; } - if (texFormat == 5) { + if (texFormat == TEX_FORMAT_IA8) { gDPLoadTextureBlockS(dList++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_IA, G_IM_SIZ_8b, width, height, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); - tex->flags |= 4; + tex->flags |= RENDER_SEMI_TRANSPARENT; } - if (texFormat == 6) { - gDPLoadTextureBlockS(dList++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_IA, G_IM_SIZ_4b, width, height, 0, cms, - cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); - tex->flags |= 4; + if (texFormat == TEX_FORMAT_IA4) { + gDPLoadTextureBlock_4bS(dList++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_IA, width, height, 0, cms, cmt, masks, + maskt, G_TX_NOLOD, G_TX_NOLOD); + tex->flags |= RENDER_SEMI_TRANSPARENT; } - if (texFormat == 2) { + if (texFormat == TEX_FORMAT_I8) { gDPLoadTextureBlockS(dList++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_I, G_IM_SIZ_8b, width, height, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); } - if (texFormat == 3) { - gDPLoadTextureBlockS(dList++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_I, G_IM_SIZ_4b, width, height, 0, cms, - cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); + if (texFormat == TEX_FORMAT_I4) { + gDPLoadTextureBlock_4bS(dList++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_I, width, height, 0, cms, cmt, masks, + maskt, G_TX_NOLOD, G_TX_NOLOD); } - tex->numberOfCommands = ((s32) ((s32) dList - (s32) tex->cmd) >> 3); + tex->numberOfCommands = dList - tex->cmd; } } -#else -#pragma GLOBAL_ASM("asm/nonmatchings/textures_sprites/build_tex_display_list.s") -#endif s32 func_8007EF64(s16 arg0) { return (s32) (arg0 + gCiPalettes); diff --git a/src/textures_sprites.h b/src/textures_sprites.h index 159b0cd7..a74c21b0 100644 --- a/src/textures_sprites.h +++ b/src/textures_sprites.h @@ -68,6 +68,13 @@ enum RenderFlags { RENDER_ALL = 0xFFFFFFFF }; +typedef enum TextureRenderModes { + TRANSPARENT, + OPAQUE, + TRANSPARENT_2, + OPAQUE_2 +} TextureRenderModes; + typedef enum TransFlags { OBJ_FLAGS_NONE, OBJ_FLAGS_UNK_0001 = (1 << 0), @@ -143,7 +150,7 @@ MemoryPoolSlot *func_8007C12C(s32 spriteID, s32 arg1); // Non Matching void tex_init_textures(void); // Non Matching void load_blinking_lights_texture(Gfx **dList, TextureHeader *texture_list, u32 flags, s32 texture_index); // Non Matching -void build_tex_display_list(TextureHeader *tex, Gfx *dList); // Non Matching +void build_tex_display_list(TextureHeader *tex, Gfx *_dList); // Non Matching void func_8007CDC0(Sprite *sprite1, Sprite *sprite2, s32 arg2); // Non Matching #endif diff --git a/ver/symbols/symbol_addrs.jpn.v79.txt b/ver/symbols/symbol_addrs.jpn.v79.txt index 85299318..57bd1401 100644 --- a/ver/symbols/symbol_addrs.jpn.v79.txt +++ b/ver/symbols/symbol_addrs.jpn.v79.txt @@ -146,7 +146,7 @@ update_spatial_audio_position = 0x800096D8; func_800096F8 = 0x800096F8; func_8000974C = 0x8000974C; audioline_ambient_create = 0x800098A4; -func_80009968 = 0x80009968; +audioline_reverb_create = 0x80009968; func_800099EC = 0x800099EC; func_80009AB4 = 0x80009AB4; func_80009B7C = 0x80009B7C; diff --git a/ver/symbols/symbol_addrs.pal.v77.txt b/ver/symbols/symbol_addrs.pal.v77.txt index 4851fb4c..d060bb74 100644 --- a/ver/symbols/symbol_addrs.pal.v77.txt +++ b/ver/symbols/symbol_addrs.pal.v77.txt @@ -146,7 +146,7 @@ update_spatial_audio_position = 0x800096D8; func_800096F8 = 0x800096F8; func_8000974C = 0x8000974C; audioline_ambient_create = 0x800098A4; -func_80009968 = 0x80009968; +audioline_reverb_create = 0x80009968; func_800099EC = 0x800099EC; func_80009AB4 = 0x80009AB4; func_80009B7C = 0x80009B7C; diff --git a/ver/symbols/symbol_addrs.pal.v80.txt b/ver/symbols/symbol_addrs.pal.v80.txt index f029b537..a5cfedd0 100644 --- a/ver/symbols/symbol_addrs.pal.v80.txt +++ b/ver/symbols/symbol_addrs.pal.v80.txt @@ -146,7 +146,7 @@ update_spatial_audio_position = 0x800096D8; func_800096F8 = 0x800096F8; func_8000974C = 0x8000974C; audioline_ambient_create = 0x800098A4; -func_80009968 = 0x80009968; +audioline_reverb_create = 0x80009968; func_800099EC = 0x800099EC; func_80009AB4 = 0x80009AB4; func_80009B7C = 0x80009B7C; diff --git a/ver/symbols/symbol_addrs.us.v77.txt b/ver/symbols/symbol_addrs.us.v77.txt index a52d4b42..2f95b4a6 100644 --- a/ver/symbols/symbol_addrs.us.v77.txt +++ b/ver/symbols/symbol_addrs.us.v77.txt @@ -146,7 +146,7 @@ update_spatial_audio_position = 0x800096D8; func_800096F8 = 0x800096F8; func_8000974C = 0x8000974C; audioline_ambient_create = 0x800098A4; -func_80009968 = 0x80009968; +audioline_reverb_create = 0x80009968; func_800099EC = 0x800099EC; func_80009AB4 = 0x80009AB4; func_80009B7C = 0x80009B7C; diff --git a/ver/symbols/symbol_addrs.us.v80.txt b/ver/symbols/symbol_addrs.us.v80.txt index a865f382..993768e6 100644 --- a/ver/symbols/symbol_addrs.us.v80.txt +++ b/ver/symbols/symbol_addrs.us.v80.txt @@ -146,7 +146,7 @@ update_spatial_audio_position = 0x800096D8; func_800096F8 = 0x800096F8; func_8000974C = 0x8000974C; audioline_ambient_create = 0x800098A4; -func_80009968 = 0x80009968; +audioline_reverb_create = 0x80009968; func_800099EC = 0x800099EC; func_80009AB4 = 0x80009AB4; func_80009B7C = 0x80009B7C;