diff --git a/configure.py b/configure.py index d34766cfe3..b6393e9ad8 100755 --- a/configure.py +++ b/configure.py @@ -364,6 +364,7 @@ "shared/rendering/sky/update_sky_shells_animated.c", "shared/runtime/dma/002b7a48.c", "shared/ui/help/001fe778.c", + "shared/ui/help/001ff938.c", "shared/ui/help/00204c60.c", "shared/ui/help/00215340.c", "shared/ui/help/0021d0a0.c", diff --git a/scripts/test_public_tools.py b/scripts/test_public_tools.py index c66379afcd..47f742b401 100755 --- a/scripts/test_public_tools.py +++ b/scripts/test_public_tools.py @@ -477,7 +477,7 @@ class DataDeclarationTests(unittest.TestCase): """No new data label may get a second type or name (scripts/data-decls.py).""" # Labels that still disagree; lower it when you fix some, never raise it. - KNOWN_CONFLICTS = 602 + KNOWN_CONFLICTS = 600 def test_no_new_conflicting_declarations(self): decls = load_module("rnc_data_decls", ROOT / "scripts" / "data-decls.py") diff --git a/src/assembly/textbin/audio/voices/sound_update.c b/src/assembly/textbin/audio/voices/sound_update.c index 1309e87550..a24f0f291f 100644 --- a/src/assembly/textbin/audio/voices/sound_update.c +++ b/src/assembly/textbin/audio/voices/sound_update.c @@ -118,6 +118,7 @@ extern void voice_update_callback() __asm__("FUN_0022ddd8"); s32 sound_update(void) __asm__("FUN_0022ca50"); s32 sound_update(void) { + VoiceSlot *voices; VoiceVector listener_occlusion_position; VoiceVector listener_velocity; VoiceVector relative_velocity; @@ -133,6 +134,8 @@ s32 sound_update(void) { VoiceMoby *moby; f32 water_height; s32 history_index; + s32 divisor; + s32 current_index; s32 previous_history_index; s32 listener_sample_count; s32 group_volume; @@ -172,26 +175,26 @@ s32 sound_update(void) { } qzero(&listener_velocity); - { - s32 *history_position = &D_0013E550.listener_history_position; - history_index = D_0013E550.listener_history_position + 1; - history_index %= 4; - *history_position = history_index; - } + history_index = D_0013E550.listener_history_position + 1; + history_index %= 4; + D_0013E550.listener_history_position = history_index; qcopy(&D_0013E550.listener_history[history_index], &D_00187080); - previous_history_index = (history_index + 3) % 4; + listener_sample_count = 0; - if (previous_history_index != history_index) { + divisor = 18; + current_index = history_index; + previous_history_index = (current_index + 3) % 4; + if (previous_history_index != current_index) { do { - subtract_vector_xyz(&relative_velocity, &D_0013E550.listener_history[history_index], + subtract_vector_xyz(&relative_velocity, &D_0013E550.listener_history[current_index], &D_0013E550.listener_history[previous_history_index]); if (!(vector_length_xyz(&relative_velocity) < frame_time * 60.0f)) { break; } listener_sample_count++; add_vector_xyz(&listener_velocity, &listener_velocity, &relative_velocity); - history_index = previous_history_index; - previous_history_index = (history_index + 3) % 4; + current_index = previous_history_index; + previous_history_index = (current_index + 3) % 4; } while (previous_history_index != D_0013E550.listener_history_position); } if (listener_sample_count >= 2) { @@ -288,37 +291,34 @@ s32 sound_update(void) { if (!(D_0013E550.voices[slot_index].flags & 0x10)) { distance_volume = calculate_voice_volume(&D_0013E550.voices[slot_index], &D_0013E550.voices[slot_index].position); - volumes[slot_index] = distance_volume * D_0013E550.voices[slot_index].volume / 1024; + voice_volumes[slot_index] = distance_volume * D_0013E550.voices[slot_index].volume / 1024; if (!(D_0013E550.voices[slot_index].definition->attenuation_flags & 2)) { voice_flags[slot_index] |= 8; } } else { distance_volume = 0x400; - volumes[slot_index] = D_0013E550.voices[slot_index].volume; + voice_volumes[slot_index] = D_0013E550.voices[slot_index].volume; } if (underwater && !(D_0013E550.voices[slot_index].definition->attenuation_flags & 4) && water_height < D_0013E550.voices[slot_index].position.f[2]) { - volumes[slot_index] /= 2; + voice_volumes[slot_index] /= 2; } voice_flags[slot_index] |= 1; - if (distance_volume < 0x20 && volumes[slot_index] < 0x20 && + if (distance_volume < 0x20 && voice_volumes[slot_index] < 0x20 && (D_0013E550.voices[slot_index].flags & 4)) { voice_flags[slot_index] = 0x20; continue; } - { - u8 slot_flags = D_0013E550.voices[slot_index].flags; - if (((slot_flags ^ 1) & 1) != 0) { - voice_flags[slot_index] |= 2; - if (!(D_0013E550.voices[slot_index].flags & 0x20)) { - voice_flags[slot_index] |= 4; - } + if ((D_0013E550.voices[slot_index].flags & 1) != 1) { + voice_flags[slot_index] |= 2; + if (!(D_0013E550.voices[slot_index].flags & 0x20)) { + voice_flags[slot_index] |= 4; } } } - occlusion_history = D_0013E550.voices[0].occlusion_history; - for (slot_index = 0; slot_index < 30; slot_index++, occlusion_history += sizeof(VoiceSlot)) { + voices = D_0013E550.voices; + for (slot_index = 0; slot_index < 30; slot_index++) { if (!(voice_flags[slot_index] & 8)) { continue; } @@ -328,14 +328,13 @@ s32 sound_update(void) { } occluded_samples = 0; if (world_update_time != D_0013E550.occlusion_frame) { - for (sample_index = 5; sample_index >= 0; sample_index--) { + for (sample_index = 0; sample_index < 6; sample_index++) { clamp_voice_position_to_collision( - &D_0013E550.occlusion_samples[5 - sample_index]); + &D_0013E550.occlusion_samples[sample_index]); } D_0013E550.occlusion_frame = world_update_time; } - sample_index = 0; - for (history_offset = 0; history_offset < 36; + for (history_offset = 0, sample_index = 0; history_offset < 36; history_offset += 6, sample_index++) { D_0013E550.voices[slot_index].occlusion_history[history_offset] = test_voice_occlusion(&D_0013E550.voices[slot_index], @@ -349,9 +348,9 @@ s32 sound_update(void) { } } if (occluded_samples >= 36) { - volumes[slot_index] = 0; + voice_volumes[slot_index] = 0; } else if (occluded_samples >= 19) { - volumes[slot_index] = (36 - occluded_samples) * volumes[slot_index] / 18; + voice_volumes[slot_index] = (36 - occluded_samples) * voice_volumes[slot_index] / divisor; } } else { if ((game_mode == 0 || game_mode == 2) && boot_level_active == 0) { @@ -374,12 +373,14 @@ s32 sound_update(void) { [(D_0013E550.voices[slot_index].occlusion_history_position + 35) % 36]; } } - occluded_samples = - ComputeByteStringHash(occlusion_history, 36); - if (occluded_samples >= 36) { - volumes[slot_index] = 0; - } else if (occluded_samples >= 19) { - volumes[slot_index] = (36 - occluded_samples) * volumes[slot_index] / 18; + { + s32 occluded = + ComputeByteStringHash(voices[slot_index].occlusion_history, 36); + if (occluded >= 36) { + voice_volumes[slot_index] = 0; + } else if (occluded >= 19) { + voice_volumes[slot_index] = (36 - occluded) * voice_volumes[slot_index] / divisor; + } } } } @@ -394,9 +395,9 @@ s32 sound_update(void) { D_0013E550.voices[slot_index].handle = -1; if (command_flags & 0x20) { if (D_0013E550.voices[slot_index].state == 7) { - D_0013E550.voices[slot_index].state = 0; D_0013E550.voices[slot_index].moby = NULL; D_0013E550.voices[slot_index].owner_context = 0; + D_0013E550.voices[slot_index].state = 0; } else { snd_stop_sound(handle); D_0013E550.voices[slot_index].state = 6; @@ -426,14 +427,14 @@ s32 sound_update(void) { pitch_modifier -= 0x5F4; } if (D_0013E550.voices[slot_index].state != 7) { - snd_set_sound_params_cb(handle, parameter_mask, volumes[slot_index], pan, + snd_set_sound_params_cb(handle, parameter_mask, voice_volumes[slot_index], pan, pitch_modifier, pitch_bend, voice_update_callback, &D_0013E550.voices[slot_index]); } else { D_0013E550.voices[slot_index].state = 1; snd_play_sound_vol_pan_pmpb(D_0013E550.voices[slot_index].definition->bank_handle, D_0013E550.voices[slot_index].definition->sound_index, - volumes[slot_index], pan, pitch_modifier, pitch_bend, + voice_volumes[slot_index], pan, pitch_modifier, pitch_bend, voice_start_callback, &D_0013E550.voices[slot_index]); } } diff --git a/src/overlays/l00/gameplay/entities/veldin_robot_enemy.c b/src/overlays/l00/gameplay/entities/veldin_robot_enemy.c index fb309f9df9..afd1702f10 100644 --- a/src/overlays/l00/gameplay/entities/veldin_robot_enemy.c +++ b/src/overlays/l00/gameplay/entities/veldin_robot_enemy.c @@ -177,7 +177,7 @@ extern f32 D_L00_00161BE4 __attribute__((sda)); s32 D_L00_00161BE8 = 3; extern f32 D_L00_00161BEC __attribute__((sda)); extern VendVec D_L00_00166DC0; -extern s32 D_001413D0 NOT_SDA; +extern s32 D_001413D0_lui[] __asm__("D_001413D0") NOT_SDA; extern VendHit D_L00_00173E58; extern VendPath *vend_paths[] __asm__("D_L00_001B04B0"); extern s32 D_L00_0015F580[] MACRO_ADDR; @@ -368,14 +368,14 @@ void FUN_L00_002e0b88(VendMoby *moby) { qcopy(&probe, &moby->pos); probe.f[2] += 0.5f; if (FUN_001efa68(&mtx[3], &probe, 0, moby, &query) != 0 && hit != 0 && - D_L00_00173E58.moby == D_001413D0) { + D_L00_00173E58.moby == (*(s32 *)&D_001413D0_lui)) { vend_2040(moby); moby->state = 6; VEND_ANIM(moby, 7, vend_rand(10)); } if (FUN_001efa68(&mtx[3], &dir, 0, moby, &query) != 0) { qcopy(&dir, D_L00_00173E58.pos); - if (hit != 0 && D_L00_00173E58.moby == D_001413D0) { + if (hit != 0 && D_L00_00173E58.moby == (*(s32 *)&D_001413D0_lui)) { vend_2040(moby); moby->state = 6; VEND_ANIM(moby, 7, vend_rand(10)); diff --git a/src/overlays/l03/gameplay/entities/taxi.c b/src/overlays/l03/gameplay/entities/taxi.c index 3a1fa20aae..e053badb98 100644 --- a/src/overlays/l03/gameplay/entities/taxi.c +++ b/src/overlays/l03/gameplay/entities/taxi.c @@ -1147,7 +1147,7 @@ typedef struct { } G_2da710; extern int D_L03_0015F5C4; -extern unsigned char D_0015EDB0; +#include "rnc/gameplay/state/options.h" extern float D_L03_0015F5A0; extern G_2da710 D_L03_0016C960; extern char D_L03_0017C540[]; @@ -1160,7 +1160,7 @@ void FUN_L03_002da710(struct Moby *m) { char *s; int i; - if (D_L03_0015F5C4 == 2 && D_0015EDB0 != 0) { + if (D_L03_0015F5C4 == 2 && big_head_cheat_enabled != 0) { if (D_L03_0016C960.mode == 2 && D_L03_0016C960.t >= 0x1EA && D_L03_0016C960.t < 0x266) { D_L03_0015F5A0 = -0.2f; } @@ -1222,7 +1222,7 @@ extern struct Moby *D_L03_0015FFD8; extern s32 D_L03_0015FFD8_i __asm__("D_L03_0015FFD8"); extern s32 D_L03_001BA720[]; extern char D_L03_00161BB8[]; -extern u8 D_0014C050[]; +#include "rnc/gameplay/state/game_globals.h" extern u8 D_L03_0015FC88[]; extern L03LevelState D_L03_001BA6D0; extern char *D_L03_001600EC; @@ -1282,7 +1282,7 @@ void FUN_L03_002da870(struct Moby *m) { taxi_kill(m); return; } - if (D_0014C050[m->mission + current_level_index * 16] == 0xFF && v->link != -1) { + if (visited52[m->mission + current_level_index * 16] == 0xFF && v->link != -1) { t = (struct Moby *)((v->link << 8) + D_L03_0015FFD8_i); if (t->oclass == 0x3F4) { flag = (s32 *)(t->pvars + 0x8C); @@ -1345,7 +1345,7 @@ void FUN_L03_002da870(struct Moby *m) { do { group = o->mission; } while (0); - if (D_L03_0015FC88[group] != 0xFF && D_0014C050[group + current_level_index * 16] == 0xFF) { + if (D_L03_0015FC88[group] != 0xFF && visited52[group + current_level_index * 16] == 0xFF) { /* Fakematch: see above. */ do { record: @@ -1429,7 +1429,7 @@ void FUN_L03_002da870(struct Moby *m) { v->pitch = pitch; v->yaw = yaw * 0.5f; } - if (D_0015EDB0) + if (big_head_cheat_enabled) v->height = 2.75f; FUN_L00_002628d8(rate * frame_scale_sq, head_rate * frame_scale_sq, m, v->body, 0); FUN_L00_002628d8(rate * frame_scale_sq, head_rate * frame_scale_sq, m, v->head, 1); @@ -1610,7 +1610,7 @@ extern u8 D_0013D4C2[]; extern char *D_001413D0_db558[] __asm__("D_001413D0"); extern struct Moby *D_L03_0015FFD8; extern s32 D_L03_0015FFD8_i __asm__("D_L03_0015FFD8"); -extern u8 D_0014C050[]; +#include "rnc/gameplay/state/game_globals.h" extern char *D_L03_001600EC; extern float frame_scale_sq __asm__("D_0015ED64"); extern void FUN_L03_002db480(struct Moby *); @@ -1660,7 +1660,7 @@ void FUN_L03_002db558(struct Moby *m) { } else { v->turned = 1; } - if (D_0014C050[m->mission + current_level_index * 16] == 0xFF && v->link != -1) { + if (visited52[m->mission + current_level_index * 16] == 0xFF && v->link != -1) { t = (struct Moby *)((v->link << 8) + D_L03_0015FFD8_i); if (t->oclass == 0x3F4) { *(s32 *)(t->pvars + 0x8C) = 1; @@ -1685,13 +1685,13 @@ void FUN_L03_002db558(struct Moby *m) { { s32 k = o->mission; u32 u = k & 0xFF; - if (k == 0xFF || (D_L03_0015FC88[u] != 0xFF && D_0014C050[u + current_level_index * 16] == 0xFF)) { + if (k == 0xFF || (D_L03_0015FC88[u] != 0xFF && visited52[u + current_level_index * 16] == 0xFF)) { D_L03_001BB330.collected[(s16)o->save_id] = k + 2; } } } } - if (item_available[2] != 0 && D_0014C050[m->mission + current_level_index * 16] == 0xFF) { + if (item_available[2] != 0 && visited52[m->mission + current_level_index * 16] == 0xFF) { break; } if (FUN_L00_00266448(m, (struct TalkState *)&v->talk)) { @@ -1741,7 +1741,7 @@ void FUN_L03_002db558(struct Moby *m) { do { group = o->mission; } while (0); - if (D_L03_0015FC88[group] != 0xFF && D_0014C050[group + current_level_index * 16] == 0xFF) { + if (D_L03_0015FC88[group] != 0xFF && visited52[group + current_level_index * 16] == 0xFF) { rec2: D_L03_001BB330.collected[(s16)o->save_id] = o->mission + 2; } @@ -1805,7 +1805,7 @@ void FUN_L03_002db558(struct Moby *m) { v->head.pitch = pitch; v->body.yaw = v->head.yaw = yaw * 0.5f; } - if (D_0015EDB0) + if (big_head_cheat_enabled) v->head.height = 2.75f; FUN_L00_002628d8(rate * frame_scale_sq, head_rate * frame_scale_sq, m, &v->head, 1); FUN_L00_002628d8(rate * frame_scale_sq, head_rate * frame_scale_sq, m, &v->body, 0); diff --git a/src/overlays/l04/gameplay/entities/big_axebot.c b/src/overlays/l04/gameplay/entities/big_axebot.c index ab41b0e77e..1cc8a44f25 100644 --- a/src/overlays/l04/gameplay/entities/big_axebot.c +++ b/src/overlays/l04/gameplay/entities/big_axebot.c @@ -549,7 +549,6 @@ extern void normalize_vector_triplet(void *) __asm__("FUN_00214128"); extern void refresh_moby_spatial_bounds_from_basis(void *); extern void tick_countdown_32(int *counter); void FUN_L04_002ba3e0(char *arg, void *a, void *b, void *c); -extern char D_0013F350[]; extern P_B7B0 *D_L04_001B0930_B7B0[] __asm__("D_L04_001B0630"); void FUN_L04_002ba520(M_B7B0 *moby) { @@ -1232,7 +1231,7 @@ extern void scale_vector_xyz(void *, void *, float) __asm__("FUN_001f9a68"); extern void subtract_vector_xyz_c(void *, void *, void *) __asm__("FUN_001f9a28"); extern void func_L00_00260D30_k(void *, void *, float) __asm__("FUN_L00_0025fcb8"); -extern short D_L04_00161884 __attribute__((sda)); +extern float D_L04_00161884 __attribute__((sda)); float FUN_L04_002c1fb8(struct Moby *moby, void *out, float speed) { float away[4]; float target[4]; @@ -1259,9 +1258,9 @@ float FUN_L04_002c1fb8(struct Moby *moby, void *out, float speed) { if (other == moby || *(short *)(other + 0xA6) != moby->oclass) continue; if (FUN_001f9b80((float *)(other + 0x10), (float *)&moby->pos) < 3.0f) { subtract_vector_xyz_c(away, &moby->pos, other + 0x10); - scale_vector_xyz(away, away, *(float *)&D_L04_00161884); + scale_vector_xyz(away, away, D_L04_00161884); add_vector_xyz_c(out, out, away); - weight += *(float *)&D_L04_00161884; + weight += D_L04_00161884; } if (FUN_001f9b80((float *)(other + 0x10), target) < target_dist) is_closest = 0; } @@ -1518,7 +1517,6 @@ extern void subtract_vector_xyz(void *dst, void *a, void *b); extern void transform_vector_by_basis(void *, void *, void *); int FUN_L04_002c1e98(struct Moby *moby); void FUN_L04_002c1d70(struct Moby *moby); -extern char D_0013F350[]; extern char D_0013E550[]; extern void *func_L00_0025B478_2C35F0(void *, int, int) __asm__("FUN_L00_0025a420"); extern void func_L00_002592B0_b(char *moby, float target, float *vel, float k, float d, @@ -1556,7 +1554,7 @@ void FUN_L04_002c2270(M_35F0 *moby) { moby->f30 = 0x20; FUN_L04_002c1b80((struct Moby *)moby); if (moby->state == 1 || moby->state == 3) { - H_35F0 *h = (H_35F0 *)(((char *)&D_0013F350)); + H_35F0 *h = (H_35F0 *)(((char *)((char *)&hero))); if (h->f240 == moby || FUN_001f9b48(moby->pos, h->pos) < 1.5f) { blend_moby_animation(moby, (void *)7, 0, (void *)scale_game_frames(10)); data->f146 = scale_game_frames(0x3C); @@ -2269,7 +2267,6 @@ extern void refresh_moby_spatial_bounds_from_basis(void *); extern void subtract_vector_xyz(void *dst, void *a, void *b); extern void tick_countdown_32(int *counter); void FUN_L04_002c4808_c(char *arg) __asm__("FUN_L04_002c4808"); -extern char D_0013F350[]; extern int func_L00_002594C8_o(void *, void *, void *, float, float, float, float, int) __asm__("FUN_L00_00258490"); diff --git a/src/overlays/l04/runtime/dma/002922d0.c b/src/overlays/l04/runtime/dma/002922d0.c index 8abc044863..0faef2c680 100644 --- a/src/overlays/l04/runtime/dma/002922d0.c +++ b/src/overlays/l04/runtime/dma/002922d0.c @@ -364,7 +364,6 @@ extern f32 fast_difference_between_rotations(f32, f32) __asm__("FUN_001fa688"); extern f32 FUN_001f99c0(f32); extern f32 D_0015ED60; extern f32 D_0015ED68; -extern f32 D_0015ED6C; extern s32 D_L04_00173FF0[] __attribute__((section(".data"))); s32 FUN_L04_00295778(struct Moby *moby, LegRig *rig, f32 speed, f32 heading, f32 step) { @@ -506,8 +505,8 @@ s32 FUN_L04_00295778(struct Moby *moby, LegRig *rig, f32 speed, f32 heading, f32 LegRigAnim *anim; f32 rate; - if (!(rig->speed < D_0015ED6C * 0.19f) || !(min_turn < fast_difference_between_rotations(moby->rot.z, heading)) || - !(speed < (rate = D_0015ED6C * 0.19f))) { + if (!(rig->speed < frame_time * 0.19f) || !(min_turn < fast_difference_between_rotations(moby->rot.z, heading)) || + !(speed < (rate = frame_time * 0.19f))) { anim = *entry; rate = rig->speed; } else { diff --git a/src/overlays/l05/gameplay/entities/sharkigator.c b/src/overlays/l05/gameplay/entities/sharkigator.c index 327488c8c4..0153bcece2 100644 --- a/src/overlays/l05/gameplay/entities/sharkigator.c +++ b/src/overlays/l05/gameplay/entities/sharkigator.c @@ -41,10 +41,10 @@ void FUN_L05_002d6f48(unsigned char *moby) { extern void sample_camera_path(int *, int, void *, float *, int, float) __asm__("FUN_00214e58"); -extern short D_L05_001613D0 __attribute__((sda)); +extern float D_L05_001613D0 __attribute__((sda)); void FUN_L05_002d7890(char *moby, int *path) { float *d = *(float **)(moby + 0x78); - d[2] = d[2] + *(float *)&D_L05_001613D0 * frame_time / d[3]; + d[2] = d[2] + D_L05_001613D0 * frame_time / d[3]; if ((float)path[0] < d[2]) { d[2] = d[2] - (float)path[0]; } @@ -194,7 +194,7 @@ INCLUDE_ASM("config/us/overlays/asm/FUN_L05_002d1688.s", FUN_L05_002d1688); #else typedef unsigned int U128_2d1688 __attribute__((mode(TI))); extern char *D_L05_001B0930[]; -extern short D_L05_00161388 __attribute__((sda)); +extern float D_L05_00161388 __attribute__((sda)); extern float D_L05_001612E8 __attribute__((section(".data"))); extern float D_L05_0013F640 __asm__("D_L05_0013F640"); extern float D_0013F3D0[4] __asm__("D_0013F3D0"); @@ -272,7 +272,7 @@ void FUN_L05_002d1688(char *moby) { if (*(unsigned char *)(moby + 0x53) != 1) { set_action_2d1688(moby, 1, 0, timer_2d1688(10)); } - height = *(float *)(D_L05_001B0930[*(int *)(data + 0x60)] + 0x18) - (*(float *)&D_L05_00161388); + height = *(float *)(D_L05_001B0930[*(int *)(data + 0x60)] + 0x18) - (D_L05_00161388); *(float *)(moby + 0x18) = height; *(float *)(data + 0x80) = height; *(unsigned char *)(moby + 0x20) = one; @@ -303,9 +303,9 @@ void FUN_L05_002d1688(char *moby) { } if ((hero.state.control_mode == 0x12 || hero.state.current == 0x12) && distance_to_2d1688(moby + 0x10, &hero.motion.pos) < 8.0f) { - speed = (D_L05_001612E8 - (*(float *)&D_L05_00161388)) - 2.0f; + speed = (D_L05_001612E8 - (D_L05_00161388)) - 2.0f; } else { - speed = (D_L05_001612E8 - (*(float *)&D_L05_00161388)) - 0.5f; + speed = (D_L05_001612E8 - (D_L05_00161388)) - 0.5f; FUN_L05_002d1e30(moby); } move_2d1688(speed, frame_time_sq + frame_time_sq, @@ -326,7 +326,7 @@ void FUN_L05_002d1688(char *moby) { *(float *)(moby + 0x48) = angle_from_2d1688(*(float *)(point + 0x158), 1.5707964f); copy_direction_2d1688(moby + 0xc0, moby + 0x40); qcopy(moby + 0x10, &hero.motion.pos); - fast_vec_normalize((*(float *)&D_L05_00161388), v, moby + 0xe0); + fast_vec_normalize((D_L05_00161388), v, moby + 0xe0); fast_vec_sub(moby + 0x10, moby + 0x10, v); { float speed = frame_time * 10.0f; @@ -377,13 +377,13 @@ void FUN_L05_002d1688(char *moby) { float speed = *(float *)(data + 0x78) - acceleration; *(float *)(data + 0x78) = speed; if (speed < threshold) { - fast_vec_normalize((*(float *)&D_L05_00161388), v, moby + 0xe0); + fast_vec_normalize((D_L05_00161388), v, moby + 0xe0); height = frame_time_sq; steer_2d1688(1.5533431f, height * 12.566371f, height * 12.566371f, frame_time * 25.132742f, moby + 0x44, data + 0x70); copy_direction_2d1688(moby + 0xc0, moby + 0x40); - fast_vec_normalize((*(float *)&D_L05_00161388), w, moby + 0xe0); + fast_vec_normalize((D_L05_00161388), w, moby + 0xe0); fast_vec_sub(z, w, v); fast_vec_sub(moby + 0x10, moby + 0x10, z); } @@ -393,7 +393,7 @@ void FUN_L05_002d1688(char *moby) { if (*(float *)(moby + 0x18) < hero.water_surface_z && *(unsigned char *)(moby + 0xbc) == 0) { *(unsigned char *)(moby + 0xbc) = 1; allocate_voice_for_target_entry_2d1688(0, 0, moby); - fast_vec_normalize((*(float *)&D_L05_00161388), v, moby + 0xe0); + fast_vec_normalize((D_L05_00161388), v, moby + 0xe0); fast_vec_add(v, v, moby + 0x10); v[2] = hero.water_surface_z; FUN_L05_002d1fd8((int)moby, (char *)v); @@ -1072,20 +1072,20 @@ extern s32 FUN_L01_00276fe8(void *, s32, s32, void *, s32, void *, f32); extern s32 random_integer_below_c2(s32) __asm__("func_00213260"); extern s32 spawn_spark_c(void *, void *, void *, s32, s32, s32, s32, s32, s32) __asm__("func_00218888"); extern s32 truncate_float_to_s32_c4(f32) __asm__("func_001FA6D0"); -extern short D_L05_00161A84 __attribute__((sda)); +extern int D_L05_00161A84 __attribute__((sda)); extern float D_L05_00161A98 __attribute__((sda)); -extern short D_L05_00161A9C __attribute__((sda)); -extern short D_L05_00161AA0 __attribute__((sda)); -extern short D_L05_00161AA4 __attribute__((sda)); -extern short D_L05_00161AA8 __attribute__((sda)); -extern short D_L05_00161AAC __attribute__((sda)); -extern short D_L05_00161AB0 __attribute__((sda)); -extern short D_L05_00161AB4 __attribute__((sda)); -extern short D_L05_00161AB8 __attribute__((sda)); -extern short D_L05_00161ABC __attribute__((sda)); -extern short D_L05_00161AC0 __attribute__((sda)); -extern short D_L05_00161AC4 __attribute__((sda)); -extern short D_L05_00161AC8 __attribute__((sda)); +extern int D_L05_00161A9C __attribute__((sda)); +extern int D_L05_00161AA0 __attribute__((sda)); +extern int D_L05_00161AA4 __attribute__((sda)); +extern int D_L05_00161AA8 __attribute__((sda)); +extern float D_L05_00161AAC __attribute__((sda)); +extern float D_L05_00161AB0 __attribute__((sda)); +extern float D_L05_00161AB4 __attribute__((sda)); +extern float D_L05_00161AB8 __attribute__((sda)); +extern float D_L05_00161ABC __attribute__((sda)); +extern float D_L05_00161AC0 __attribute__((sda)); +extern float D_L05_00161AC4 __attribute__((sda)); +extern int D_L05_00161AC8 __attribute__((sda)); extern void FUN_L00_0024f7c8(void *, int, void *); extern void FUN_L00_00257d78(float *, float, float); extern void FUN_L00_00259bc8(void *, int, int, void *, void *, float); @@ -1264,7 +1264,7 @@ void FUN_L05_00301f48(unsigned char *m) { } else if (*(int *)(d + 0x2B0) != 0) { if (vector_distance_xy_alt(pos0, t + 0x10) < 3.0f) { m[0x20] = 7; - *(short *)(d + 0x2D0) = scale_game_frames(*(int *)&D_L05_00161AC8); + *(short *)(d + 0x2D0) = scale_game_frames(D_L05_00161AC8); if (m[0x53] != 2) blend_moby_animation(m, 2, 0, scale_game_frames(10)); } } else { @@ -1279,7 +1279,7 @@ void FUN_L05_00301f48(unsigned char *m) { if (m[0x53] != 1) blend_moby_animation(m, 1, 0, scale_game_frames(20)); } else if (vector_distance_xy_alt(m + 0x10, t + 0x10) < 3.0f) { m[0x20] = 7; - *(short *)(d + 0x2D0) = scale_game_frames(*(int *)&D_L05_00161AC8); + *(short *)(d + 0x2D0) = scale_game_frames(D_L05_00161AC8); if (m[0x53] != 2) blend_moby_animation(m, 2, 0, scale_game_frames(10)); } break; @@ -1311,7 +1311,7 @@ void FUN_L05_00301f48(unsigned char *m) { fast_arc_tan(*(float *)(t + 0x10) - *(float *)(m + 0x10), *(float *)(t + 0x14) - *(float *)(m + 0x14))) < 0.7853982f) { m[0x20] = 7; - *(short *)(d + 0x2D0) = scale_game_frames(*(int *)&D_L05_00161AC8); + *(short *)(d + 0x2D0) = scale_game_frames(D_L05_00161AC8); if (m[0x53] != 2) blend_moby_animation(m, 2, 0, scale_game_frames(10)); } if (*(int *)(d + 0x164) == 2) { @@ -1334,12 +1334,12 @@ void FUN_L05_00301f48(unsigned char *m) { *(short *)(d + 0x2D0) = 0; if (m[0x53] != 3) blend_moby_animation(m, 3, 0, scale_game_frames(1)); a = fast_add_rotations_c4(*(float *)(m + 0x48), 0.0f); - dir[0] = fast_cos_c4(a) * (*(float *)&D_L05_00161AB8 * D_0015ED6C); - dir[1] = fast_sin_c6(a) * (*(float *)&D_L05_00161AB8 * D_0015ED6C); + dir[0] = fast_cos_c4(a) * (D_L05_00161AB8 * D_0015ED6C); + dir[1] = fast_sin_c6(a) * (D_L05_00161AB8 * D_0015ED6C); dir[2] = 0.0f; - dir[3] = *(float *)&D_L05_00161AC0; + dir[3] = D_L05_00161AC0; out[2] = 0.0f; - out[3] = *(float *)&D_L05_00161AC4; + out[3] = D_L05_00161AC4; FUN_L00_0024f7c8(m, 0, hit); for (i = 0x1D; i >= 0; i--) { int c1, c2; @@ -1349,14 +1349,14 @@ void FUN_L05_00301f48(unsigned char *m) { pos[2] += random_float_between_c3(-0.065f, 0.065f); out[0] = random_float_between_c3(-D_0015ED6C, D_0015ED6C); out[1] = random_float_between_c3(-D_0015ED6C, D_0015ED6C); - out[2] = random_float_between_c3(-(*(float *)&D_L05_00161ABC * D_0015ED6C), *(float *)&D_L05_00161ABC * D_0015ED6C); - c1 = truncate_float_to_s32_c4(FUN_001f96b0(random_float_between_c3(*(float *)&D_L05_00161AAC, *(float *)&D_L05_00161AAC * 2.0f))); - c2 = truncate_float_to_s32_c4(FUN_001f96b0(random_float_between_c3(*(float *)&D_L05_00161AB0, *(float *)&D_L05_00161AB0 * 1.2f))); - spawn_spark_c(pos, dir, out, *(int *)&D_L05_00161A9C, *(int *)&D_L05_00161AA0, c1, c2, - truncate_float_to_s32_c4(FUN_001f96b0(random_float_between_c3(*(float *)&D_L05_00161AB4, *(float *)&D_L05_00161AB4 * 1.2f))), -1); + out[2] = random_float_between_c3(-(D_L05_00161ABC * D_0015ED6C), D_L05_00161ABC * D_0015ED6C); + c1 = truncate_float_to_s32_c4(FUN_001f96b0(random_float_between_c3(D_L05_00161AAC, D_L05_00161AAC * 2.0f))); + c2 = truncate_float_to_s32_c4(FUN_001f96b0(random_float_between_c3(D_L05_00161AB0, D_L05_00161AB0 * 1.2f))); + spawn_spark_c(pos, dir, out, D_L05_00161A9C, D_L05_00161AA0, c1, c2, + truncate_float_to_s32_c4(FUN_001f96b0(random_float_between_c3(D_L05_00161AB4, D_L05_00161AB4 * 1.2f))), -1); } - dir[3] = *(float *)&D_L05_00161AC0 * 0.1f; - out[3] = *(float *)&D_L05_00161AC4 * 0.1f; + dir[3] = D_L05_00161AC0 * 0.1f; + out[3] = D_L05_00161AC4 * 0.1f; for (j = 0x1D; j >= 0; j--) { int c1, c2; qcopy(pos, hit); @@ -1365,11 +1365,11 @@ void FUN_L05_00301f48(unsigned char *m) { pos[2] += random_float_between_c3(-0.065f, 0.065f); out[0] = random_float_between_c3(-D_0015ED6C, D_0015ED6C); out[1] = random_float_between_c3(-D_0015ED6C, D_0015ED6C); - out[2] = random_float_between_c3(-(*(float *)&D_L05_00161ABC * D_0015ED6C), *(float *)&D_L05_00161ABC * D_0015ED6C); - c1 = truncate_float_to_s32_c4(FUN_001f96b0(random_float_between_c3(*(float *)&D_L05_00161AAC, *(float *)&D_L05_00161AAC * 2.0f))); - c2 = truncate_float_to_s32_c4(FUN_001f96b0(random_float_between_c3(*(float *)&D_L05_00161AB0, *(float *)&D_L05_00161AB0 * 1.2f))); - spawn_spark_c(pos, dir, out, *(int *)&D_L05_00161AA4, *(int *)&D_L05_00161AA8, c1, c2, - truncate_float_to_s32_c4(FUN_001f96b0(random_float_between_c3(*(float *)&D_L05_00161AB4, *(float *)&D_L05_00161AB4 * 1.2f))), -1); + out[2] = random_float_between_c3(-(D_L05_00161ABC * D_0015ED6C), D_L05_00161ABC * D_0015ED6C); + c1 = truncate_float_to_s32_c4(FUN_001f96b0(random_float_between_c3(D_L05_00161AAC, D_L05_00161AAC * 2.0f))); + c2 = truncate_float_to_s32_c4(FUN_001f96b0(random_float_between_c3(D_L05_00161AB0, D_L05_00161AB0 * 1.2f))); + spawn_spark_c(pos, dir, out, D_L05_00161AA4, D_L05_00161AA8, c1, c2, + truncate_float_to_s32_c4(FUN_001f96b0(random_float_between_c3(D_L05_00161AB4, D_L05_00161AB4 * 1.2f))), -1); } } break; @@ -1402,7 +1402,7 @@ void FUN_L05_00301f48(unsigned char *m) { fast_arc_tan(*(float *)(t + 0x10) - *(float *)(m + 0x10), *(float *)(t + 0x14) - *(float *)(m + 0x14))) < 0.2617994f) { m[0x20] = 7; - *(short *)(d + 0x2D0) = scale_game_frames(*(int *)&D_L05_00161AC8); + *(short *)(d + 0x2D0) = scale_game_frames(D_L05_00161AC8); if (m[0x53] != 7) blend_moby_animation(m, 7, 0, scale_game_frames(5)); } else { *(float *)(d + 0xF4) = 0.0f; @@ -1461,7 +1461,7 @@ void FUN_L05_00301f48(unsigned char *m) { } break; } - *(int *)&D_L05_00161A84 = *(volatile int *)0x10000000; + D_L05_00161A84 = *(volatile int *)0x10000000; } #include "rnc/math/vector.h" @@ -1598,7 +1598,7 @@ extern float func_001F9CE8_3047E8(void *) __asm__("FUN_001f9b20"); extern void update_joint_animation(void *, void *, int, float, float) __asm__("FUN_L00_002628d8"); extern Path_3047E8 *D_L05_001B0CB0_3047E8[] __asm__("D_L05_001B0930"); extern char D_0013F420[]; -extern int D_001413D0[] __attribute__((section(".data"))); +extern s32 D_001413D0_lui[] __asm__("D_001413D0") __attribute__((section(".data"))); void FUN_L05_00303390(Moby *m) { Vec_3047E8 v0; @@ -1721,13 +1721,13 @@ void FUN_L05_00303390(Moby *m) { } } if (d->target == 0) { - d->target = (*(Moby * *)D_001413D0); + d->target = (*(Moby * *)D_001413D0_lui); } d->f2D8 = func_001FA748_3047E8(d->f2D8, D_0015ED6C * 9.424778f); m->glow_color = fast_tween_color(D_L05_00161A74, D_L05_00161A78, (func_001F9FA8_3047E8(d->f2D8) + 1.0f) * 0.5f); k = m->state; if (k < 10) { - if (k >= 4 && d->target == (*(Moby * *)D_001413D0)) { + if (k >= 4 && d->target == (*(Moby * *)D_001413D0_lui)) { float yaw, pitch; func_001F9BF0_3047E8(v0, ((float *)&d->target->pos), ((float *)&m->pos)); yaw = func_001FA790_3047E8(angle_atan2(v0[0], v0[1]), m->rot.z); @@ -1990,34 +1990,34 @@ extern int FUN_L00_00259028(char *m, char *p, float *pos, char *v); extern int FUN_L00_00259740(void *, void *, int); extern s32 spawn_spark_c2(void *, void *, void *, s32, s32, s32, s32, s32, s32) __asm__("func_00218888"); extern s32 truncate_float_to_s32_c5(f32) __asm__("func_001FA6D0"); -extern short D_L05_00161AF8 __attribute__((sda)); -extern short D_L05_00161B0C __attribute__((sda)); -extern short D_L05_00161B10 __attribute__((sda)); -extern short D_L05_00161B14 __attribute__((sda)); -extern short D_L05_00161B18 __attribute__((sda)); -extern short D_L05_00161B1C __attribute__((sda)); -extern short D_L05_00161B20 __attribute__((sda)); -extern short D_L05_00161B24 __attribute__((sda)); -extern short D_L05_00161B28 __attribute__((sda)); -extern short D_L05_00161B2C __attribute__((sda)); -extern short D_L05_00161B30 __attribute__((sda)); -extern short D_L05_00161B34 __attribute__((sda)); -extern short D_L05_00161B38 __attribute__((sda)); -extern short D_L05_00161B3C __attribute__((sda)); -extern short D_L05_00161B40 __attribute__((sda)); -extern short D_L05_00161B44 __attribute__((sda)); -extern short D_L05_00161B48 __attribute__((sda)); -extern short D_L05_00161B4C __attribute__((sda)); -extern short D_L05_00161B50 __attribute__((sda)); -extern short D_L05_00161B54 __attribute__((sda)); -extern short D_L05_00161B58 __attribute__((sda)); -extern short D_L05_00161B5C __attribute__((sda)); -extern short D_L05_00161B60 __attribute__((sda)); -extern short D_L05_00161B64 __attribute__((sda)); -extern short D_L05_00161B68 __attribute__((sda)); -extern short D_L05_00161B6C __attribute__((sda)); +extern float D_L05_00161AF8 __attribute__((sda)); +extern int D_L05_00161B0C __attribute__((sda)); +extern int D_L05_00161B10 __attribute__((sda)); +extern float D_L05_00161B14 __attribute__((sda)); +extern float D_L05_00161B18 __attribute__((sda)); +extern float D_L05_00161B1C __attribute__((sda)); +extern float D_L05_00161B20 __attribute__((sda)); +extern float D_L05_00161B24 __attribute__((sda)); +extern float D_L05_00161B28 __attribute__((sda)); +extern float D_L05_00161B2C __attribute__((sda)); +extern float D_L05_00161B30 __attribute__((sda)); +extern float D_L05_00161B34 __attribute__((sda)); +extern float D_L05_00161B38 __attribute__((sda)); +extern int D_L05_00161B3C __attribute__((sda)); +extern int D_L05_00161B40 __attribute__((sda)); +extern float D_L05_00161B44 __attribute__((sda)); +extern float D_L05_00161B48 __attribute__((sda)); +extern float D_L05_00161B4C __attribute__((sda)); +extern float D_L05_00161B50 __attribute__((sda)); +extern float D_L05_00161B54 __attribute__((sda)); +extern float D_L05_00161B58 __attribute__((sda)); +extern float D_L05_00161B5C __attribute__((sda)); +extern float D_L05_00161B60 __attribute__((sda)); +extern float D_L05_00161B64 __attribute__((sda)); +extern float D_L05_00161B68 __attribute__((sda)); +extern float D_L05_00161B6C __attribute__((sda)); extern short D_L05_00161B78 __attribute__((sda)); -extern short D_L05_00161B7C __attribute__((sda)); +extern float D_L05_00161B7C __attribute__((sda)); extern void FUN_L00_001fff28(void *, int, float); extern void blend_moby_animation(void *, int, int, int) __asm__("FUN_00212f90"); extern void clear_u64_value(void *) __asm__("func_001F99F8"); @@ -2104,7 +2104,7 @@ void FUN_L05_00304320(unsigned char *m) { qcopy(m + 0x10, *(char **)(d + 0xD0) + 0x10); m[0x20] = 1; if (m[0x53] != 0) blend_moby_animation(m, 0, 0, 0); - *(float *)(d + 0x94) = *(float *)&D_L05_00161AF8 * D_0015ED6C_gp; + *(float *)(d + 0x94) = D_L05_00161AF8 * D_0015ED6C_gp; clear_u64_value(d + 0x40); *(unsigned short *)(d + 0x3E) |= 2; d[0x2E] = 1; @@ -2119,7 +2119,7 @@ void FUN_L05_00304320(unsigned char *m) { *(float *)(d + 0x194) = *(volatile float *)(m + 0x48); d[0x58] = truncate_float_to_s32_c5(t); } - d[0x5A] = truncate_float_to_s32_c5(*(float *)&D_L05_00161B7C * 8.0f); + d[0x5A] = truncate_float_to_s32_c5(D_L05_00161B7C * 8.0f); break; } case 1: { @@ -2194,8 +2194,8 @@ void FUN_L05_00304320(unsigned char *m) { } *(int *)pp = idx; } - v20[3] = *(float *)&D_L05_00161B30; - v30[3] = *(float *)&D_L05_00161B34; + v20[3] = D_L05_00161B30; + v30[3] = D_L05_00161B34; FUN_L00_0024f7c8(m, 2, v10); for (i = 0; i < 2; i++) { int a, b, e; @@ -2205,19 +2205,19 @@ void FUN_L05_00304320(unsigned char *m) { v40[0] += random_float_between_c4(-0.065f, 0.065f); v40[1] += random_float_between_c4(-0.065f, 0.065f); v40[2] += random_float_between_c4(-0.065f, 0.065f); - v20[0] = fast_cos_c5(*(float *)(d + 0x194)) * (*(float *)&D_L05_00161B20 * D_0015ED6C_gp); - v20[1] = fast_sin_c7(*(float *)(d + 0x194)) * (*(float *)&D_L05_00161B20 * D_0015ED6C_gp); + v20[0] = fast_cos_c5(*(float *)(d + 0x194)) * (D_L05_00161B20 * D_0015ED6C_gp); + v20[1] = fast_sin_c7(*(float *)(d + 0x194)) * (D_L05_00161B20 * D_0015ED6C_gp); v20[2] = 0.0f; - v20[2] = random_float_between_c4(*(float *)&D_L05_00161B24 * D_0015ED6C_gp * 0.9f, *(float *)&D_L05_00161B24 * D_0015ED6C_gp * 1.1f); - ang = random_float_between_c4(-*(float *)&D_L05_00161B38, *(float *)&D_L05_00161B38) * 0.017453292f; - v30[0] = fast_cos_c5(fast_add_rotations_c5(*(float *)(d + 0x194), ang)) * (*(float *)&D_L05_00161B28 * D_0015ED6C_gp); - v30[1] = fast_sin_c7(fast_add_rotations_c5(*(float *)(d + 0x194), ang)) * (*(float *)&D_L05_00161B28 * D_0015ED6C_gp); + v20[2] = random_float_between_c4(D_L05_00161B24 * D_0015ED6C_gp * 0.9f, D_L05_00161B24 * D_0015ED6C_gp * 1.1f); + ang = random_float_between_c4(-D_L05_00161B38, D_L05_00161B38) * 0.017453292f; + v30[0] = fast_cos_c5(fast_add_rotations_c5(*(float *)(d + 0x194), ang)) * (D_L05_00161B28 * D_0015ED6C_gp); + v30[1] = fast_sin_c7(fast_add_rotations_c5(*(float *)(d + 0x194), ang)) * (D_L05_00161B28 * D_0015ED6C_gp); v30[2] = 0.0f; - v30[2] = random_float_between_c4(*(float *)&D_L05_00161B2C * D_0015ED6C_gp * 0.9f, *(float *)&D_L05_00161B2C * D_0015ED6C_gp * 1.1f); - a = truncate_float_to_s32_c5(FUN_001f96b0(random_float_between_c4(*(float *)&D_L05_00161B14, *(float *)&D_L05_00161B14 + *(float *)&D_L05_00161B14))); - b = truncate_float_to_s32_c5(FUN_001f96b0(random_float_between_c4(*(float *)&D_L05_00161B18, *(float *)&D_L05_00161B18 * 1.2f))); - e = truncate_float_to_s32_c5(FUN_001f96b0(random_float_between_c4(*(float *)&D_L05_00161B1C, *(float *)&D_L05_00161B1C * 1.2f))); - r = ((Spawn_305778)spawn_spark_c2)(v40, v20, v30, *(int *)&D_L05_00161B0C, *(int *)&D_L05_00161B10, a, b, e, -1); + v30[2] = random_float_between_c4(D_L05_00161B2C * D_0015ED6C_gp * 0.9f, D_L05_00161B2C * D_0015ED6C_gp * 1.1f); + a = truncate_float_to_s32_c5(FUN_001f96b0(random_float_between_c4(D_L05_00161B14, D_L05_00161B14 + D_L05_00161B14))); + b = truncate_float_to_s32_c5(FUN_001f96b0(random_float_between_c4(D_L05_00161B18, D_L05_00161B18 * 1.2f))); + e = truncate_float_to_s32_c5(FUN_001f96b0(random_float_between_c4(D_L05_00161B1C, D_L05_00161B1C * 1.2f))); + r = ((Spawn_305778)spawn_spark_c2)(v40, v20, v30, D_L05_00161B0C, D_L05_00161B10, a, b, e, -1); if ((frame_number_gp & 7) == 0 && r != 0 && i == 0) { int j; for (j = 0; j < 8; j++) { @@ -2230,8 +2230,8 @@ void FUN_L05_00304320(unsigned char *m) { } } } - v20[3] = *(float *)&D_L05_00161B60; - v30[3] = *(float *)&D_L05_00161B64; + v20[3] = D_L05_00161B60; + v30[3] = D_L05_00161B64; for (k = 1; k >= 0; k--) { int a, b, e; float ang; @@ -2239,20 +2239,20 @@ void FUN_L05_00304320(unsigned char *m) { v40[0] += random_float_between_c4(-0.2f, 0.2f); v40[1] += random_float_between_c4(-0.2f, 0.2f); v40[2] += random_float_between_c4(-0.2f, 0.2f); - ang = random_float_between_c4(-*(float *)&D_L05_00161B6C, *(float *)&D_L05_00161B6C) * 0.017453292f; - v20[0] = fast_cos_c5(fast_add_rotations_c5(*(float *)(d + 0x194), ang)) * (*(float *)&D_L05_00161B50 * D_0015ED6C_gp); - v20[1] = fast_sin_c7(fast_add_rotations_c5(*(float *)(d + 0x194), ang)) * (*(float *)&D_L05_00161B50 * D_0015ED6C_gp); + ang = random_float_between_c4(-D_L05_00161B6C, D_L05_00161B6C) * 0.017453292f; + v20[0] = fast_cos_c5(fast_add_rotations_c5(*(float *)(d + 0x194), ang)) * (D_L05_00161B50 * D_0015ED6C_gp); + v20[1] = fast_sin_c7(fast_add_rotations_c5(*(float *)(d + 0x194), ang)) * (D_L05_00161B50 * D_0015ED6C_gp); v20[2] = 0.0f; - v20[2] = random_float_between_c4(*(float *)&D_L05_00161B54 * D_0015ED6C_gp * 0.7f, *(float *)&D_L05_00161B54 * D_0015ED6C_gp * 1.5f); - ang = random_float_between_c4(-*(float *)&D_L05_00161B68, *(float *)&D_L05_00161B68) * 0.017453292f; - v30[0] = fast_cos_c5(fast_add_rotations_c5(*(float *)(d + 0x194), ang)) * (*(float *)&D_L05_00161B58 * D_0015ED6C_gp); - v30[1] = fast_sin_c7(fast_add_rotations_c5(*(float *)(d + 0x194), ang)) * (*(float *)&D_L05_00161B58 * D_0015ED6C_gp); + v20[2] = random_float_between_c4(D_L05_00161B54 * D_0015ED6C_gp * 0.7f, D_L05_00161B54 * D_0015ED6C_gp * 1.5f); + ang = random_float_between_c4(-D_L05_00161B68, D_L05_00161B68) * 0.017453292f; + v30[0] = fast_cos_c5(fast_add_rotations_c5(*(float *)(d + 0x194), ang)) * (D_L05_00161B58 * D_0015ED6C_gp); + v30[1] = fast_sin_c7(fast_add_rotations_c5(*(float *)(d + 0x194), ang)) * (D_L05_00161B58 * D_0015ED6C_gp); v30[2] = 0.0f; - v30[2] = random_float_between_c4(*(float *)&D_L05_00161B5C * D_0015ED6C_gp * 0.7f, *(float *)&D_L05_00161B5C * D_0015ED6C_gp * 1.5f); - a = truncate_float_to_s32_c5(FUN_001f96b0(random_float_between_c4(*(float *)&D_L05_00161B44, *(float *)&D_L05_00161B44 + *(float *)&D_L05_00161B44))); - b = truncate_float_to_s32_c5(FUN_001f96b0(random_float_between_c4(*(float *)&D_L05_00161B48, *(float *)&D_L05_00161B48 * 1.2f))); - e = truncate_float_to_s32_c5(FUN_001f96b0(random_float_between_c4(*(float *)&D_L05_00161B4C, *(float *)&D_L05_00161B4C * 1.2f))); - ((Spawn_305778)spawn_spark_c2)(v40, v20, v30, *(int *)&D_L05_00161B3C, *(int *)&D_L05_00161B40, a, b, e, -1); + v30[2] = random_float_between_c4(D_L05_00161B5C * D_0015ED6C_gp * 0.7f, D_L05_00161B5C * D_0015ED6C_gp * 1.5f); + a = truncate_float_to_s32_c5(FUN_001f96b0(random_float_between_c4(D_L05_00161B44, D_L05_00161B44 + D_L05_00161B44))); + b = truncate_float_to_s32_c5(FUN_001f96b0(random_float_between_c4(D_L05_00161B48, D_L05_00161B48 * 1.2f))); + e = truncate_float_to_s32_c5(FUN_001f96b0(random_float_between_c4(D_L05_00161B4C, D_L05_00161B4C * 1.2f))); + ((Spawn_305778)spawn_spark_c2)(v40, v20, v30, D_L05_00161B3C, D_L05_00161B40, a, b, e, -1); } qcopy(v40, m + 0x10); v40[2] = v40[2] + 3.0f; @@ -2971,12 +2971,12 @@ extern void FUN_L00_00260738(char *, void *, void *, void *); extern void allocate_voice_for_target_entry_alt(int, int, int) __asm__("FUN_0022da68"); extern void subtract_vector_xyz(void *out, void *a, void *b) __asm__("FUN_001f9a28"); -extern short D_L05_00161CD4 __attribute__((sda)); -extern short D_L05_00161CD8 __attribute__((sda)); -extern short D_L05_00161CDC __attribute__((sda)); -extern short D_L05_00161CE0 __attribute__((sda)); -extern short D_L05_00161CE4 __attribute__((sda)); -extern short D_L05_00161CE8 __attribute__((sda)); +extern float D_L05_00161CD4 __attribute__((sda)); +extern float D_L05_00161CD8 __attribute__((sda)); +extern float D_L05_00161CDC __attribute__((sda)); +extern float D_L05_00161CE0 __attribute__((sda)); +extern int D_L05_00161CE4 __attribute__((sda)); +extern int D_L05_00161CE8 __attribute__((sda)); void FUN_L05_0030bdd8(unsigned char *moby) { char *data = *(char **)(moby + 0x78); float v[4]; @@ -2990,7 +2990,7 @@ void FUN_L05_0030bdd8(unsigned char *moby) { switch (moby[0x20]) { case 0: *(int *)(data + 0x78) = func_001FA898_r(multiply_global_factor_ed64(random_float_between_alt( - (float)*(int *)&D_L05_00161CE4, (float)*(int *)&D_L05_00161CE8))); + (float)D_L05_00161CE4, (float)D_L05_00161CE8))); *(float *)(data + 0x60) = random_angle_radians(); *(float *)(data + 0x6C) = random_angle_radians(); moby[0x20] = 1; @@ -2999,7 +2999,7 @@ void FUN_L05_0030bdd8(unsigned char *moby) { if (fast_dec_timer((int *)(data + 0x78))) { allocate_voice_for_target_entry_alt(0, 0, (int)moby); *(int *)(data + 0x78) = func_001FA898_r(multiply_global_factor_ed64(random_float_between_alt( - (float)*(int *)&D_L05_00161CE4, (float)*(int *)&D_L05_00161CE8))); + (float)D_L05_00161CE4, (float)D_L05_00161CE8))); } p = (char *)moby + 0x10; qcopy(v, p); @@ -3007,14 +3007,14 @@ void FUN_L05_0030bdd8(unsigned char *moby) { q = (char *)moby + 0x40; qcopy(r, q); t = fast_add_rotations(*(float *)(data + 0x60), - *(float *)&D_L05_00161CD4 * DEG_TO_RAD * frame_time); - k = *(float *)&D_L05_00161CD8 * DEG_TO_RAD * frame_time; + D_L05_00161CD4 * DEG_TO_RAD * frame_time); + k = D_L05_00161CD8 * DEG_TO_RAD * frame_time; *(float *)(data + 0x60) = t; *(float *)(data + 0x6C) = fast_add_rotations(*(float *)(data + 0x6C), k); *(float *)(moby + 0x44) = - *(float *)&D_L05_00161CDC * DEG_TO_RAD * fast_sin(*(float *)(data + 0x60)); + D_L05_00161CDC * DEG_TO_RAD * fast_sin(*(float *)(data + 0x60)); *(float *)(moby + 0x40) = - *(float *)&D_L05_00161CE0 * DEG_TO_RAD * fast_sin(*(float *)(data + 0x6C)); + D_L05_00161CE0 * DEG_TO_RAD * fast_sin(*(float *)(data + 0x6C)); subtract_vector_xyz(d, p, v); FUN_L00_00260738(data + 0x20, d, r, q); break; diff --git a/src/overlays/l05/gameplay/hero/00239fc0.c b/src/overlays/l05/gameplay/hero/00239fc0.c index f82a992219..ab3079dc37 100644 --- a/src/overlays/l05/gameplay/hero/00239fc0.c +++ b/src/overlays/l05/gameplay/hero/00239fc0.c @@ -441,7 +441,6 @@ s32 FUN_L05_00240ed0(s32 mode) { return 1; } -extern char D_0013F350[]; s32 FUN_001efa68(void *, void *, s32, s32, s32); @@ -557,7 +556,7 @@ void FUN_L05_002413e0(void) { char *hit = D_L05_00174258[0]; if (!hit || *(short *)(hit + 0xA6) == 0x1F6 || *(short *)(hit + 0xA6) == 0x59F) { - player = (L16MovementPlayer *)(((char *)&D_0013F350)); + player = (L16MovementPlayer *)(((char *)((char *)&hero))); if (!player->unconstrained) { float length; float limit; @@ -655,7 +654,7 @@ void FUN_L05_002413e0(void) { if (motion_player->slope > 0.5f) motion_player->slope = 0.5f; else if (motion_player->slope < -0.5f) motion_player->slope = -0.5f; } - cap_player = (L16MovementPlayer *)(((char *)&D_0013F350)); + cap_player = (L16MovementPlayer *)(((char *)((char *)&hero))); magnitude = frame_time * 52.0f; if (magnitude < cap_player->speed) { scale_vector_xyz(cap_player->external, cap_player->external, magnitude / cap_player->speed); diff --git a/src/overlays/l06/gameplay/entities/fred.c b/src/overlays/l06/gameplay/entities/fred.c index e8d38475c4..3561e72c2f 100644 --- a/src/overlays/l06/gameplay/entities/fred.c +++ b/src/overlays/l06/gameplay/entities/fred.c @@ -733,7 +733,7 @@ extern void FUN_001f9a10(void *, void *, void *); extern void fast_vec_scale(void *, void *, float) __asm__("FUN_001f9a68"); void mark_moby_for_removal(struct Obj *obj) __asm__("FUN_0020c828"); -extern short D_L06_00162090 __attribute__((sda)); +extern float D_L06_00162090 __attribute__((sda)); extern int GB_FRAME_gp __asm__("D_L06_0015F5CC") __attribute__((sda)); void FUN_L06_00300df0(char *moby) { char *data = *(char **)(moby + 0x78); @@ -756,7 +756,7 @@ void FUN_L06_00300df0(char *moby) { } else { float f = convert_integer_to_float(GB_FRAME_gp % 600) / 600.0f; float g = fast_sin(f * 6.28318f); - *(float *)(moby + 0x18) = *(float *)(data + 0xC) + *(float *)&D_L06_00162090 * g; + *(float *)(moby + 0x18) = *(float *)(data + 0xC) + D_L06_00162090 * g; } break; case 2: @@ -1100,7 +1100,7 @@ void FUN_L06_00301070(struct Moby *m) { update_joint_animation_301070(rate * frame_scale_sq_macro, head_rate * frame_scale_sq_macro, m, d->f40, 0); update_joint_animation_301070(rate * frame_scale_sq_macro, head_rate * frame_scale_sq_macro, m, d->fC0, 2); } -extern unsigned char D_0014C050[]; +#include "rnc/gameplay/state/game_globals.h" extern char *D_L06_0015FFD8_301b90 __asm__("D_L06_0015FFD8"); extern char *D_L06_001600EC_301b90 __asm__("D_L06_001600EC"); extern int *D_L06_001B0C30_301b90[] __asm__("D_L06_001B0C30"); @@ -1165,7 +1165,7 @@ void FUN_L06_00301b90(unsigned char *m) { float vb[4] __attribute__((aligned(16))); switch (m[0x20]) { case 0: - if (D_0014C050[m[0xB0] + (current_level_index << 4)] != 0) { + if (visited52[m[0xB0] + (current_level_index << 4)] != 0) { mark_moby_for_removal((struct Obj *)m); return; } @@ -1396,7 +1396,7 @@ typedef struct { char pad4[0x20]; int f24; } Busy_302578; -extern unsigned char D_0014C050[]; +#include "rnc/gameplay/state/game_globals.h" extern int D_0015EE1D; extern int D_0015EE1C; extern int D_L06_0015F5C4; @@ -1477,7 +1477,7 @@ void FUN_L06_00302578(struct Moby *moby) { switch (moby->state) { case 0: D_L06_0015FDF8 = 0; - if (*(unsigned char *)(d->fF8 + (current_level_index << 4) + (int)D_0014C050) == 0xFF) { + if (*(unsigned char *)(d->fF8 + (current_level_index << 4) + (int)visited52) == 0xFF) { FUN_L06_00304028((char *)moby); } else { D_0013D3AC_302578[5] = 0; @@ -1708,7 +1708,7 @@ void FUN_L06_00302578(struct Moby *moby) { extern int D_0015EE1C; extern int D_0015EE1D; extern int help_request(int a, int b) __asm__("FUN_L00_00203908"); -extern unsigned char D_0014C050[]; +#include "rnc/gameplay/state/game_globals.h" extern unsigned short D_00141C00 __attribute__((section(".data"))); extern void try_set_help_message(int, int) __asm__("FUN_00215130"); @@ -1717,11 +1717,11 @@ void FUN_L06_00302fd8(char *m) { switch (*(int *)(d + 0xBC)) { case 0: { int idx = current_level_index << 4; - int a = *(unsigned char *)(*(int *)(d + 0xF8) + idx + (int)D_0014C050); + int a = *(unsigned char *)(*(int *)(d + 0xF8) + idx + (int)visited52); if (a != 0xFF) { *(int *)(d + 0x9C) = 0; } else { - int b = *(unsigned char *)(*(int *)(d + 0xFC) + idx + (int)D_0014C050); + int b = *(unsigned char *)(*(int *)(d + 0xFC) + idx + (int)visited52); if (b == a) { *(int *)(d + 0x9C) = 3; } else { @@ -2321,15 +2321,15 @@ extern s32 random_integer_below(s32) __asm__("func_00213260"); extern void FUN_L00_0026a9f0(void *, void *, int, int, float, int, int, int, int, float); extern void clear_u64_value(void *) __asm__("func_001F99F8"); -extern short D_L06_001621B4 __attribute__((sda)); -extern short D_L06_001621B8 __attribute__((sda)); +extern float D_L06_001621B4 __attribute__((sda)); +extern int D_L06_001621B8 __attribute__((sda)); void FUN_L06_00304818(int unused, void *obj) { float pos[4]; V6 a; V6 b; int i = 0; clear_u64_value(pos); - if (*(int *)&D_L06_001621B8 > 0) { + if (D_L06_001621B8 > 0) { do { float s; float f; @@ -2344,10 +2344,10 @@ void FUN_L06_00304818(int unused, void *obj) { s = s * frame_time; pa = a.v + random_integer_below(6); pb = b.v + random_integer_below(6); - f = *(float *)&D_L06_001621B4 * 400000.0f; + f = D_L06_001621B4 * 400000.0f; r1 = random_int_between(scale_game_frames(0xF), scale_game_frames(0x14)); - FUN_L00_0026a9f0(obj, pos, *pa, *pb, f, r1, random_int_between(scale_game_frames(0x19), scale_game_frames(0x1E)), 0, 0, s * *(float *)&D_L06_001621B4); - } while (i < *(int *)&D_L06_001621B8); + FUN_L00_0026a9f0(obj, pos, *pa, *pb, f, r1, random_int_between(scale_game_frames(0x19), scale_game_frames(0x1E)), 0, 0, s * D_L06_001621B4); + } while (i < D_L06_001621B8); } } /* Level 06 update for moby class 1123: waits for its partner, animates four ribbons, then bursts into particles. */ @@ -2375,18 +2375,18 @@ extern int FUN_L00_0028d8c0(void *, int); extern s32 fast_tween_color(s32, s32, f32) __asm__("func_001FA6E0"); extern s32 truncate_float_to_s32_c(f32) __asm__("func_001FA6D0"); extern float D_L06_001621F8 __attribute__((sda)); -extern short D_L06_001621FC __attribute__((sda)); -extern short D_L06_00162204 __attribute__((sda)); +extern float D_L06_001621FC __attribute__((sda)); +extern float D_L06_00162204 __attribute__((sda)); extern float D_L06_00162208 __attribute__((sda)); -extern short D_L06_00162210 __attribute__((sda)); -extern short D_L06_00162214 __attribute__((sda)); -extern short D_L06_00162218 __attribute__((sda)); -extern short D_L06_0016221C __attribute__((sda)); -extern short D_L06_00162220 __attribute__((sda)); -extern short D_L06_00162224 __attribute__((sda)); -extern short D_L06_00162228 __attribute__((sda)); -extern short D_L06_0016222C __attribute__((sda)); -extern short D_L06_00162230 __attribute__((sda)); +extern float D_L06_00162210 __attribute__((sda)); +extern int D_L06_00162214 __attribute__((sda)); +extern int D_L06_00162218 __attribute__((sda)); +extern float D_L06_0016221C __attribute__((sda)); +extern float D_L06_00162220 __attribute__((sda)); +extern int D_L06_00162224 __attribute__((sda)); +extern int D_L06_00162228 __attribute__((sda)); +extern float D_L06_0016222C __attribute__((sda)); +extern float D_L06_00162230 __attribute__((sda)); extern void FUN_001f9ff8(float *, float); extern void FUN_L00_00257d78(void *, float, float); extern void FUN_L06_00217300(void *); @@ -2419,7 +2419,7 @@ void FUN_L06_003049f8(char *moby) switch ((unsigned char)moby[0x20]) { case 0: - *(float *)(moby + 0x2C) = *(float *)(*(char **)(moby + 0x24) + 0x24) * *(float *)&D_L06_00162210; + *(float *)(moby + 0x2C) = *(float *)(*(char **)(moby + 0x24) + 0x24) * D_L06_00162210; D_L06_00162238 = 0x16; D_L06_00162234 = 0x2D; d->timer[1] = 0xB; @@ -2456,13 +2456,13 @@ void FUN_L06_003049f8(char *moby) d->f18 = allocate_voice_for_target_entry(0, 4, moby); } FUN_L06_00305000_c(moby); - v = D_L06_001621F8 + *(float *)&D_L06_001621FC * D_0015ED6C; + v = D_L06_001621F8 + D_L06_001621FC * D_0015ED6C; D_L06_001621F8 = v; if (1.0f < v) { D_L06_001621F8 = v - 1.0f; } - f21 = *(float *)&D_L06_00162204 / 30.0f; - f20 = -(*(float *)&D_L06_00162204 * 0.5f); + f21 = D_L06_00162204 / 30.0f; + f20 = -(D_L06_00162204 * 0.5f); for (i = 0; i < 4; i++) { if (d->timer[i] == 0) { for (j = 0; j < 30; j++) { @@ -2521,12 +2521,12 @@ void FUN_L06_003049f8(char *moby) float scale; int s; unsigned char life; - fast_vec_normalize_c(u.m.pos, u.m.b, FUN_L00_00257c48(0.0f, *(float *)&D_L06_00162204 * 0.75f)); + fast_vec_normalize_c(u.m.pos, u.m.b, FUN_L00_00257c48(0.0f, D_L06_00162204 * 0.75f)); add_vector_xyz_c(u.m.pos, u.m.pos, u.m.b + 12); - color = fast_tween_color(*(int *)&D_L06_00162214, *(int *)&D_L06_00162218, random_float_between(0.0f, 1.0f)); - scale = random_float_between(*(float *)&D_L06_0016221C, *(float *)&D_L06_00162220); - s = truncate_float_to_s32_c(random_float_between((float)*(int *)&D_L06_00162224, (float)*(int *)&D_L06_00162228)); - FUN_L00_00257d78(u.m.vel, *(float *)&D_L06_0016222C * D_0015ED6C, *(float *)&D_L06_00162230 * D_0015ED6C); + color = fast_tween_color(D_L06_00162214, D_L06_00162218, random_float_between(0.0f, 1.0f)); + scale = random_float_between(D_L06_0016221C, D_L06_00162220); + s = truncate_float_to_s32_c(random_float_between((float)D_L06_00162224, (float)D_L06_00162228)); + FUN_L00_00257d78(u.m.vel, D_L06_0016222C * D_0015ED6C, D_L06_00162230 * D_0015ED6C); life = scale_game_frames(s); func_L00_00273F80_r(u.m.pos, u.m.vel, color, scale, life, (unsigned char)random_integer_below(0xFF), 0); } @@ -2542,31 +2542,31 @@ extern int coll_line_fix(void *, void *, int, int, int) __asm__("FUN_001efa68"); extern void transform_vector_by_basis(void *, void *, void *) __asm__("FUN_001f9cf8"); extern void FUN_L00_00259858(char *a, int b, int c, float d); -extern short D_L06_001621E8 __attribute__((sda)); -extern short D_L06_001621EC __attribute__((sda)); -extern short D_L06_001621F0 __attribute__((sda)); +extern float D_L06_001621E8 __attribute__((sda)); +extern float D_L06_001621EC __attribute__((sda)); +extern float D_L06_001621F0 __attribute__((sda)); void FUN_L06_00305000(char *m) { float P[4]; float Q[4]; float A[12]; FUN_L00_00259858((char *)A, (int)m, 0x10000, 6.0f); - P[0] = *(float *)&D_L06_001621E8; - P[1] = *(float *)&D_L06_001621EC; - P[2] = *(float *)&D_L06_001621F0; - Q[0] = -*(float *)&D_L06_001621E8; - Q[1] = *(float *)&D_L06_001621EC; - Q[2] = *(float *)&D_L06_001621F0; + P[0] = D_L06_001621E8; + P[1] = D_L06_001621EC; + P[2] = D_L06_001621F0; + Q[0] = -D_L06_001621E8; + Q[1] = D_L06_001621EC; + Q[2] = D_L06_001621F0; transform_vector_by_basis(P, P, m + 0xC0); FUN_001f9a10(P, P, m + 0x10); transform_vector_by_basis(Q, Q, m + 0xC0); FUN_001f9a10(Q, Q, m + 0x10); coll_line_fix(P, Q, 0, (int)m, (int)A); - P[0] = *(float *)&D_L06_001621E8; - P[1] = -*(float *)&D_L06_001621EC; - P[2] = *(float *)&D_L06_001621F0; - Q[0] = -*(float *)&D_L06_001621E8; - Q[1] = -*(float *)&D_L06_001621EC; - Q[2] = *(float *)&D_L06_001621F0; + P[0] = D_L06_001621E8; + P[1] = -D_L06_001621EC; + P[2] = D_L06_001621F0; + Q[0] = -D_L06_001621E8; + Q[1] = -D_L06_001621EC; + Q[2] = D_L06_001621F0; transform_vector_by_basis(P, P, m + 0xC0); FUN_001f9a10(P, P, m + 0x10); transform_vector_by_basis(Q, Q, m + 0xC0); @@ -2585,13 +2585,13 @@ extern float D_L06_001FE890[]; extern int D_L06_00162234; extern int D_L06_00162238; extern int get_effect_texture(int) __asm__("FUN_001f44b8"); -extern short D_L06_001621C4 __attribute__((sda)); -extern short D_L06_001621C8 __attribute__((sda)); -extern short D_L06_001621C0 __attribute__((sda)); -extern short D_L06_001621CC __attribute__((sda)); -extern short D_L06_001621E0 __attribute__((sda)); -extern short D_L06_001621E4 __attribute__((sda)); -extern short D_L06_001621F4 __attribute__((sda)); +extern int D_L06_001621C4 __attribute__((sda)); +extern int D_L06_001621C8 __attribute__((sda)); +extern int D_L06_001621C0 __attribute__((sda)); +extern int D_L06_001621CC __attribute__((sda)); +extern int D_L06_001621E0 __attribute__((sda)); +extern int D_L06_001621E4 __attribute__((sda)); +extern float D_L06_001621F4 __attribute__((sda)); extern f32 D_L06_001621F8_gp __asm__("D_L06_001621F8") __attribute__((sda)); extern f32 D_L06_00162208_gp __asm__("D_L06_00162208") __attribute__((sda)); extern void set_scale_matrix(float *, float) __asm__("FUN_001f9ff8"); @@ -2622,9 +2622,9 @@ void FUN_L06_00305170(char *m) { vu1_add_g_sregister(6, get_effect_texture(0xE)); vu1_add_g_sregister(0x14, 0xFF9000000260L); vu1_add_g_sregister(8, 0); - vu1_add_g_sregister(0x42, (long)*(int *)&D_L06_001621C0 | ((long)*(int *)&D_L06_001621C4 << 2) | - ((long)*(int *)&D_L06_001621C8 << 4) | - ((long)*(int *)&D_L06_001621CC << 6) | 0x8000000000L); + vu1_add_g_sregister(0x42, (long)D_L06_001621C0 | ((long)D_L06_001621C4 << 2) | + ((long)D_L06_001621C8 << 4) | + ((long)D_L06_001621CC << 6) | 0x8000000000L); font_queue_vu_state(); m0 = mat[0]; sp = s; @@ -2644,9 +2644,9 @@ void FUN_L06_00305170(char *m) { s[0] = D_L06_00162234; s[2] = (int)(data + 0xF00); s[1] = D_L06_00162238; - s[3] = *(int *)&D_L06_001621E0; - s[4] = *(int *)&D_L06_001621E4; - *(float *)&s[7] = *(float *)&D_L06_001621F4; + s[3] = D_L06_001621E0; + s[4] = D_L06_001621E4; + *(float *)&s[7] = D_L06_001621F4; *(float *)&s[8] = *(float *)&D_L06_001621F8_gp; s[5] = 0x1E; s[6] = (int)data; diff --git a/src/overlays/l07/gameplay/entities/snagglebeast.c b/src/overlays/l07/gameplay/entities/snagglebeast.c index 67039f77d2..b3fdafb3cd 100644 --- a/src/overlays/l07/gameplay/entities/snagglebeast.c +++ b/src/overlays/l07/gameplay/entities/snagglebeast.c @@ -680,7 +680,7 @@ extern Vec4 D_L07_00166E40; extern int D_L07_00161B64 __attribute__((sda)); extern ChaserSpawnRecord D_L07_00179B40[]; extern int D_L07_0020C600[][4]; -extern int weapon_ammo_counts[] __asm__("D_0013D428"); +#include "rnc/gameplay/state/item_state.h" extern void FUN_L00_00263ac8(float, int, int, void *); extern void FUN_L00_0025e450(void *, void *, void *, float, float, int, int, int, float, float, float, float, int, float, int, int, int, int); extern int FUN_00214720(void *, int); @@ -1185,7 +1185,7 @@ void FUN_L07_00314150(unsigned char *moby) { if (!path_point_ready && target_distance < 20.0f) near = 1; moving = frame_time * 0.01f < spd; if (hit == 4) { - if (moving) hit = 4; + if (frame_time * 0.01f < spd) hit = 4; } else { hit = 2; } @@ -1527,17 +1527,17 @@ void FUN_L07_00314150(unsigned char *moby) { int rem; int pos; if (*(short *)(data + 0x19E) == 0) { - *(short *)(data + 0x19E) = weapon_ammo_counts[slot] / 8; + *(short *)(data + 0x19E) = ((int *)&weapon_ammo_counts)[slot] / 8; if (*(short *)(data + 0x19E) < cnt) *(short *)(data + 0x19E) = cnt; *(float *)(data + 0x1AC) = random_float_between(*(float *)(data + 0x1AC) + 20.0f, *(float *)(data + 0x1AC) + 100.0f); } cnt = *(short *)(data + 0x19E); - if (weapon_ammo_counts[slot] < cnt) { - cnt = weapon_ammo_counts[slot]; + if (((int *)&weapon_ammo_counts)[slot] < cnt) { + cnt = ((int *)&weapon_ammo_counts)[slot]; *(short *)(data + 0x19E) = 0; *(int *)(data + 0x164) += 1; } - rem = weapon_ammo_counts[slot] - cnt * 8; + rem = ((int *)&weapon_ammo_counts)[slot] - cnt * 8; pos = rem > 0; cnt = cnt + pos * rem; if (cnt > 0) { @@ -1577,7 +1577,7 @@ void FUN_L07_00314150(unsigned char *moby) { if (obj != 0) { qcopy_nc(*(char **)(obj + 0x78) + 0x10, &velocity); *(float *)(*(char **)(obj + 0x78) + 0x28) = zv; - weapon_ammo_counts[slot] -= cnt; + ((int *)&weapon_ammo_counts)[slot] -= cnt; *(int *)(data + 0x160) = scale_ticks(0); } } diff --git a/src/overlays/l07/gameplay/entities/taxi_platform.c b/src/overlays/l07/gameplay/entities/taxi_platform.c index cc014801ef..2c445ce8e5 100644 --- a/src/overlays/l07/gameplay/entities/taxi_platform.c +++ b/src/overlays/l07/gameplay/entities/taxi_platform.c @@ -1638,7 +1638,6 @@ void FUN_L07_0030cd48(int arg) { } } /* Ported from rac1-decomp (src/overlays/l07_umbris/vendor_002CE470.c: func_L07_0030E370), where it is exact; names translated to the US level program. */ -extern u8 D_0014C050[]; extern s32 D_L07_00184528[] __attribute__((section(".data"))); extern void transform_vector_by_basis(void *, void *, void *) __asm__("FUN_001f9cf8"); @@ -1673,7 +1672,7 @@ void FUN_L07_0030cf90(struct Moby *moby) { origin[1] = vars->origin_y; origin[2] = vars->origin_z; origin[3] = 0.0f; - if (moby->mission != 0xff && D_0014C050[moby->mission + (current_level_index << 4)] == 0xff) + if (moby->mission != 0xff && visited52[moby->mission + (current_level_index << 4)] == 0xff) vars->target_index = -1; switch (moby->state) { @@ -2553,378 +2552,549 @@ int FUN_L07_0030f540(unsigned char *moby, int lower, int upper) { found: return 1; } -#ifndef NON_MATCHING -INCLUDE_ASM("config/us/overlays/asm/FUN_L07_0030f5f0.s", FUN_L07_0030f5f0); -#else -#include "qzero.h" -extern void func_L00_002A5158_30D8E8(void *, int, int, float, float, float, float) __asm__("FUN_L00_002a3ec8"); -extern void FUN_L00_0025e450_l07(f32, f32, f32, f32, f32, f32, f32, struct Moby *, void *, s32, s32, s32, s32, s32, s32, s32, s32, s32) __asm__("FUN_L00_0025e450"); -extern void FUN_L00_00263ac8(void *, int, void *, float); -extern int FUN_L07_002886d8(void *, void *, float); -extern int FUN_001f0b58(void); -extern int FUN_00213260(int); -extern float resolve_camera_surface_height(void *, int) __asm__("FUN_002135f0"); -extern void FUN_L00_002715e8(void *, int, int, float, float); -extern void FUN_L00_00258278(void *, void *, float, float, float, float); -extern float FUN_L00_00258110(void *, float, float, float, float, float); -extern void FUN_001e93e8(void *, void *) __asm__("FUN_L07_0021ea10"); -extern int FUN_L00_0025c698(void *, void *); -extern unsigned char D_L07_00161B40[] __attribute__((sda, section(".sdata"))); -extern unsigned char D_L07_00161B50[] __attribute__((sda, section(".sdata"))); +/* Update function of the sharkigator (class 1059): tracks the hero, swims its path, lunges and bites. */ +/* Ported from rac1-decomp (src/overlays/l07_umbris/vendor_002CE470.c: func_L07_003109D0), where it is exact; names translated to the US level program. */ + + +struct WalkerTarget { + float pos[4]; + u128 q10; + u128 q20; + u128 q30; + int moby; + int kind; +}; + +extern Rec_30D8E8 * D_L07_001612D0; +extern char D_0013E533[]; extern char D_L07_002117F8[]; extern char D_L07_00211838[]; -extern char D_0013F3D0[]; -extern s32 D_001413D0_lui[] __asm__("D_001413D0") __attribute__((section(".data"))); -extern short D_0013F65C __attribute__((section(".data"))); -extern int D_001415F8 __attribute__((section(".data"))); -extern u8 D_001413F5_lui[] __asm__("D_001413F5") __attribute__((section(".data"))); +extern f32 fast_arc_tan_c2(f32, f32) __asm__("func_001F9E90"); +extern f32 random_angle_radians_c2(void) __asm__("func_00213308"); +extern f32 random_float_between_c2(f32, f32) __asm__("func_002132A8"); +extern float FUN_L00_00258110(float *vel, float cur, float target, float k, float d, float max); +extern float resolve_camera_surface_height(void *, int) __asm__("func_002135F0"); +extern int D_L07_0015F5CC; extern int D_L07_001612D8; -extern char D_L07_00173EE0_30f5f0[] __asm__("D_L07_00173EE0"); +extern int DebugPrint_alt() __asm__("FUN_001e93b0"); +extern int FUN_001f0b58(void); +extern int FUN_L00_00259740(void *, void *, int); +extern int FUN_L00_0025c698(void *, void *); +extern int FUN_L07_0030ebc8_c(char *moby, char *data) __asm__("FUN_L07_0030ebc8"); +extern int is_point_inside_clip_volume_c2(void *arg0, int arg1) __asm__("func_00214720"); +extern int tick_countdown_32_alt(int *arg0) __asm__("FUN_001f9740"); +extern s32 rand(void); +extern s32 truncate_float_to_s32_c(f32) __asm__("func_001FA6D0"); +extern unsigned char D_L07_00161B50_gp[1] __asm__("D_L07_00161B50") __attribute__((sda)); +extern unsigned char D_L07_00161B40_gp[1] __asm__("D_L07_00161B40") __attribute__((sda)); +extern unsigned char *FUN_L00_002715e8(void *, int, int, float, float); +extern void FUN_L00_002223f8(int, int); +extern void FUN_L00_00258278(char *moby, float *vel, float target, float k, float d, float max); +extern void FUN_L00_0025e450_c2(void *, void *, void *, float, float, int, int, int, float, float, float, float, int, float, int, int, int, int) __asm__("FUN_L00_0025e450"); +extern void FUN_L00_00263ac8(void *, int, void *, float); +extern void FUN_L07_0030ec58_c(char *arg) __asm__("FUN_L07_0030ec58"); +extern void blend_moby_animation(void *, s32, s32, s32) __asm__("FUN_00212f90"); +extern void fast_vec_scale_c(void *, void *, f32) __asm__("func_001F9A68"); +extern void mark_moby_for_removal_c4(void *) __asm__("func_0020C828"); +extern void no_op_main_callback_alt(void *, void *) __asm__("FUN_001e93e8"); +extern void subtract_vector_xyz(void *, void *, void *) __asm__("FUN_001f9a28"); +float absolute_float(float input) __asm__("func_001F99C0"); +int FUN_L07_0030ed30_c(char *moby, char *data) __asm__("FUN_L07_0030ed30"); +int FUN_L07_0030f1e0_c(char *moby, char *obj, float a, float lo, float up, float hi, float down, float vmax, float vmin) __asm__("FUN_L07_0030f1e0"); +int FUN_L07_0030f4d0_c(void *moby, int id, float scale) __asm__("FUN_L07_0030f4d0"); +int FUN_L07_0030f540_c(unsigned char *moby, int lower, int upper) __asm__("FUN_L07_0030f540"); +void FUN_L00_002a3ec8_c(void *grids, s32 count, s32 mode, f32 x, f32 z, f32 radius, f32 amount) __asm__("FUN_L00_002a3ec8"); +void FUN_L07_0030e998_c(char *m, char *x, float *hp) __asm__("FUN_L07_0030e998"); +void FUN_L07_0030eee8_c(struct Moby *moby, struct WalkerData *data) __asm__("FUN_L07_0030eee8"); +void FUN_L07_0030f0f8_c(char *a, char *b, float f12, float f13, float f14) __asm__("FUN_L07_0030f0f8"); +void FUN_L07_0030f308_c(char *moby, char *obj, int state, int anim, int seq, int frame, int next, int id, float lo, float hi, float len, float scale, float radius) __asm__("FUN_L07_0030f308"); +extern char D_0013F65C[]; +extern char D_0013F350[]; +extern void func_L00_002A5158_30D8E8(void *, int, int, float, float, float, float) __asm__("FUN_L00_002a3ec8"); + +#define func_L00_002592B0_t(m,a,v,k,d,x) ((void (*)(char *, float, float *, float, float, float))FUN_L00_00258278)(m,a,v,k,d,x) void FUN_L07_0030f5f0(unsigned char *moby) { char *data; - float target[18] __attribute__((aligned(16))); - float point[4] __attribute__((aligned(16))); - float offset[4] __attribute__((aligned(16))); - float goal[4] __attribute__((aligned(16))); - float delta[4] __attribute__((aligned(16))); - float previous[4] __attribute__((aligned(16))); - char *path; - int id, old_command, command; - unsigned char wander, inside; - unsigned char next_state, next_sequence; - float height, distance, angle, scale; - void *position; - if (!moby) return; + struct WalkerTarget target; + float point[4]; + float offset[4]; + float goal[4]; + float delta[4]; + float previous[4]; + int wander; + int inside; + int next_sequence; + int next_state; + unsigned char old_command; + unsigned char command; + char *hero; + + if (moby == 0) { + return; + } data = *(char **)(moby + 0x78); - if (!data) return; + if (data == 0) { + return; + } FUN_L00_00263ac8(moby, 0, data + 0x150, 2.2f); if (moby[0x20] == 0) { - if (FUN_L07_0030ed30(moby, data)) { - stub_printf(D_L07_002117F8, ((char *)moby - D_L07_0015FFD8_30ed30) >> 8); - goto remove; + if (FUN_L07_0030ed30_c((char *)moby, data)) { + DebugPrint_alt(D_L07_002117F8, (int)((char *)moby - (char *)level_mobys) >> 8); + mark_moby_for_removal_c4(moby); + return; } - goto bounds; + goto end; } - position = moby + 0x10; - FUN_L07_002886d8(moby, target, 30.0f); - FUN_L07_0030e998(moby, data, (float *)(data + 0x20)); + FUN_L07_002886d8(moby, &target, 30.0f); + FUN_L07_0030e998_c((char *)moby, data, (float *)(data + 0x20)); FUN_L00_0025d538(moby, data + 0x60); - wander = FUN_001f9740((int *)(data + 0x134)) != 0; - path = *(char **)(data + 0x148); - if (*(int *)(data + 0x110) == 0 || moby[0x20] < 7) { - inside = point_in_path_xy(D_0013F3D0, path + 0x10, *(int *)path) != 0; - if (FUN_001f9b80(position, D_0013F3D0) < 30.0f) { - *(int *)(target + 16) = *(int *)(D_0013F3D0 + 0x2000); - qcopy(target, D_0013F3D0); - qcopy(target + 4, D_0013F3D0 + 0x10); - qcopy(target + 8, D_0013F3D0 + 0x40); - qcopy(target + 12, D_0013F3D0 + 0x50); - *(int *)(target + 17) = 0; + wander = tick_countdown_32_alt((int *)(data + 0x134)) != 0; + if (*(int *)(data + 0x110) != 0 && moby[0x20] >= 7) { + char *path = *(char **)(data + 0x148); + inside = FUN_L00_00259740(&target, path + 0x10, *(int *)path) != 0; + } else { + char *path = *(char **)(data + 0x148); + hero = (char *)&D_0013F3D0; + inside = FUN_L00_00259740(hero, path + 0x10, *(int *)path) != 0; + if (vector_distance_xy_alt(moby + 0x10, hero) < 30.0f) { + target.moby = *(int *)(hero + 0x2000); + qcopy(&target.pos, hero); + qcopy(&target.q10, hero + 0x10); + qcopy(&target.q20, hero + 0x40); + qcopy(&target.q30, hero + 0x50); + target.kind = 0; } else { - *(int *)(target + 16) = 0; - qzero(target); - qzero(target + 4); - qzero(target + 12); - qzero(target + 8); - *(int *)(target + 17) = 2; - } - } else inside = point_in_path_xy(target, path + 0x10, *(int *)path) != 0; - if (*(int *)(data + 0x110)) { - path = *(char **)(data + 0x128); - point_in_path_xy(position, path + 0x10, *(int *)path); - } - next_state = 0xff; - old_command = moby[0xbc]; - command = FUN_L07_0030ebc8(moby, data); - next_sequence = 0xff; - moby[0xbc] = command; - command = (unsigned char)command; + target.moby = 0; + qzero(&target.pos); + qzero(&target.q10); + qzero(&target.q30); + qzero(&target.q20); + target.kind = 2; + } + } + if (*(int *)(data + 0x110) != 0) { + char *path = *(char **)(data + 0x128); + FUN_L00_00259740(moby + 0x10, path + 0x10, *(int *)path); + } + old_command = moby[0xBC]; + next_state = 0xFF; + next_sequence = 0xFF; + moby[0xBC] = FUN_L07_0030ebc8_c((char *)moby, data); + command = moby[0xBC]; if (old_command != command) { - id = command + old_command * 3; - next_state = D_L07_00161B40[id]; - next_sequence = D_L07_00161B50[id]; - } - moby_point_position(moby, 0, point); - if (FUN_L00_001f0d60(0.8f, point, 1, moby) && !FUN_001f0b58()) { - height = (**(float **)(data + 0x12c) - F(data, 0x130)) * 0.5f; - if (height < FUN_001f99c0(F(moby, 0x18) - point[2])) - height = (**(float **)(data + 0x12c) - F(data, 0x130)) * 0.5f; - else height = FUN_001f99c0(F(moby, 0x18) - point[2]); - if (F(data, 0xd8) < 0.0f) height = -height; - if (moby[0x20] == 14 || moby[0x20] == 12) height += height; - if (0.5f < FUN_001f9b80(position, D_L07_00173EE0_30f5f0)) { - distance = FUN_001f9b80(position, D_L07_00173EE0_30f5f0); - distance += distance; - } else distance = 1.0f; - if (D_L07_0015F5CC % 45 == *(short *)(moby + 0xb2) && !FUN_00213260(2)) - func_L00_002A5158_30D8E8(D_L07_001612D0, D_L07_001612D8, 1, F(moby, 0x10), F(moby, 0x14), distance, height); - if (D_L07_0015F5CC % ((rand_e50() & 7) + 20) == 0) { - scale = random_float_between(1.5f, 2.4f); - point[0] += random_float_between(-0.15f, 0.15f); - point[1] += random_float_between(-0.15f, 0.15f); - point[2] = resolve_camera_surface_height(D_L07_00173EE0_30f5f0, 0); - FUN_L00_002715e8(point, 0, -1, scale, 5250.0f); - } - } - if (1.0f <= F(data, 0x14c)) *(u128 *)D_0013F3D0 = *(u128 *)(position); + next_state = ((struct { unsigned char t[3][3]; } *)D_L07_00161B40_gp)->t[old_command][command]; + next_sequence = ((struct { unsigned char t[3][3]; } *)D_L07_00161B50_gp)->t[old_command][command]; + } + FUN_L00_0024f7c8(moby, 0, point); + if (FUN_L00_001f0d60(0.8f, point, 1, moby) != 0 && FUN_001f0b58() == 0) { + float height; + float scale; + height = **(float **)(data + 0x12C); + height -= F(data, 0x130); + height *= 0.5f; + if (height < absolute_float(F(moby, 0x18) - point[2])) { + height = (**(float **)(data + 0x12C) - F(data, 0x130)) * 0.5f; + } else { + height = absolute_float(F(moby, 0x18) - point[2]); + } + if (F(data, 0xD8) < 0.0f) { + height = -height; + } + if (moby[0x20] == 0xE || moby[0x20] == 0xC) { + height += height; + } + if (0.5f < vector_distance_xy_alt(moby + 0x10, (Vec4 *)&D_L07_00173EE0)) { + scale = vector_distance_xy_alt(moby + 0x10, (Vec4 *)&D_L07_00173EE0); + scale += scale; + } else { + scale = 1.0f; + } + if (D_L07_0015F5CC % 45 == *(short *)(moby + 0xB2) && random_integer_below(2) == 0) { + func_L00_002A5158_30D8E8(D_L07_001612D0, D_L07_001612D8, 1, F(moby, 0x10), F(moby, 0x14), scale, height); + } + if (D_L07_0015F5CC % ((rand() & 7) + 20) == 0) { + float size = random_float_between_c2(1.5f, 2.4f); + point[0] += random_float_between_c2(-0.15f, 0.15f); + point[1] += random_float_between_c2(-0.15f, 0.15f); + point[2] = resolve_camera_surface_height((Vec4 *)&D_L07_00173EE0, 0); + FUN_L00_002715e8(point, 0, -1, size, 5250.0f); + } + } + if (1.0f <= F(data, 0x14C)) { + *(u128 *)&D_0013F3D0 = *(u128 *)(moby + 0x10); + } + switch (moby[0x20]) { case 0: - ((void (*)(char *))stub_printf)(D_L07_00211838); - goto bounds; + DebugPrint_alt(D_L07_00211838); + goto end; case 1: - if ((moby[0x70] & 2) && moby[0x53] != 0) blend_moby_animation(moby, 0, 0, 10); - if (inside && *(int *)(target + 16)) { - if (*(int *)(target + 16) == D_001413D0_lui[0] && !FUN_L07_0030f540(moby, 4, 6)) { - if (moby[0x53] != 1) blend_moby_animation(moby, 1, 0, 10); - moby[0x20] = 4; + if ((moby[0x70] & 2) && moby[0x53] != 0) { + blend_moby_animation(moby, 0, 0, 10); + } + if (inside && target.moby != 0 && target.moby == *(int *)&D_001413D0 && + !FUN_L07_0030f540_c(moby, 4, 6)) { + if (moby[0x53] != 1) { + blend_moby_animation(moby, 1, 0, 10); + } + moby[0x20] = 4; + } + if (target.moby != 0 && target.moby == *(int *)&D_001413D0 && + FUN_L07_0030f4d0_c(moby, target.moby, 1.5f)) { + if (moby[0x53] != 2) { + blend_moby_animation(moby, 2, 0, 2); } - } else if (inside) goto wander_one; - if (*(int *)(target + 16) && *(int *)(target + 16) == D_001413D0_lui[0] && FUN_L07_0030f4d0(moby, *(int *)(target + 16), 1.5f)) { - if (moby[0x53] != 2) blend_moby_animation(moby, 2, 0, 2); moby[0x20] = 5; - } else { - wander_one: - if (wander) { - if (moby[0x53] != 1) blend_moby_animation(moby, 1, 0, 10); - *(int *)(data + 0x134) = rand_e50() % 200 + 300; - F(data, 0x13c) = random_angle_radians(); - moby[0x20] = 2; - } - } - fast_vec_scale(data + 0xd0, data + 0xd0, frame_scale * -0.050000012f + 1.0f); - FUN_L07_0030f0f8(moby, data, frame_time_sq * 15.0f, frame_time_sq * 50.0f, frame_time * 8.0f); - if (next_state != 0xff) { - if (moby[0x53] != next_sequence) blend_moby_animation(moby, next_sequence, 0, 6); + } else if (wander) { + if (moby[0x53] != 1) { + blend_moby_animation(moby, 1, 0, 10); + } + *(int *)(data + 0x134) = rand() % 200 + 300; + F(data, 0x13C) = random_angle_radians_c2(); + moby[0x20] = 2; + } + fast_vec_scale_c(data + 0xD0, data + 0xD0, frame_scale * (0.95f - 1.0f) + 1.0f); + FUN_L07_0030f0f8_c((char *)moby, data, frame_time_sq * 15.0f, frame_time_sq * 50.0f, frame_time * 8.0f); + if (next_state != 0xFF) { + if (moby[0x53] != next_sequence) { + blend_moby_animation(moby, next_sequence, 0, 6); + } moby[0x20] = next_state; } - goto bounds; + goto end; case 2: - if ((moby[0x70] & 2) && moby[0x53] != 1) blend_moby_animation(moby, 1, 0, 10); - if (inside && *(int *)(target + 16) && *(int *)(target + 16) == D_001413D0_lui[0]) { - if (!FUN_L07_0030f540(moby, 4, 6)) { - if (moby[0x53] != 1) blend_moby_animation(moby, 1, 0, 10); + if ((moby[0x70] & 2) && moby[0x53] != 1) { + blend_moby_animation(moby, 1, 0, 10); + } + if (inside && target.moby != 0 && target.moby == *(int *)&D_001413D0) { + if (!FUN_L07_0030f540_c(moby, 4, 6)) { + if (moby[0x53] != 1) { + blend_moby_animation(moby, 1, 0, 10); + } moby[0x20] = 4; } } else { - FUN_L00_00258278(moby, data + 0x120, F(data, 0x13c), frame_time_sq * 1.7453293f, frame_time_sq * 4.537856f, frame_time * 1.7453293f); - F(moby, 0x44) = FUN_L00_00258110(data + 0x124, F(moby, 0x44), 0.0f, frame_time_sq * 1.7453293f, frame_time_sq * 4.537856f, frame_time * 1.7453293f); - if (wander && is_point_inside_clip_volume(position, *(int *)(data + 0x114))) { - if (moby[0x53] != 0) blend_moby_animation(moby, 0, 0, 10); - *(int *)(data + 0x134) = rand_e50() % 120 + 60; + float stiffness = 1.74532926f; + float damping = 4.5378561f; + FUN_L00_00258278((char *)moby, (float *)(data + 0x120), F(data, 0x13C), + frame_time_sq * stiffness, frame_time_sq * damping, frame_time * stiffness); + F(moby, 0x44) = FUN_L00_00258110((float *)(data + 0x124), F(moby, 0x44), 0.0f, + frame_time_sq * stiffness, frame_time_sq * damping, frame_time * stiffness); + if (wander && is_point_inside_clip_volume_c2(moby + 0x10, *(int *)(data + 0x114))) { + if (moby[0x53] != 0) { + blend_moby_animation(moby, 0, 0, 10); + } + *(int *)(data + 0x134) = rand() % 120 + 60; moby[0x20] = 1; } } - FUN_L07_0030eee8(moby, data); - if (FUN_L07_0030f1e0(moby, data, F(data, 0x13c), 0.20943952f, frame_time_sq * 6.0f, 0.5235988f, frame_time_sq * 4.0f, frame_time * 7.0f, frame_time * 3.0f) && wander) { - if (moby[0x53] != 0) blend_moby_animation(moby, 0, 0, 10); - *(int *)(data + 0x134) = rand_e50() % 120 + 60; + FUN_L07_0030eee8_c((struct Moby *)moby, (struct WalkerData *)data); + if (FUN_L07_0030f1e0_c((char *)moby, data, F(data, 0x13C), 0.209439516f, frame_time_sq * 6.0f, + 0.52359879f, frame_time_sq * 4.0f, frame_time * 7.0f, frame_time * 3.0f) && + wander) { + if (moby[0x53] != 0) { + blend_moby_animation(moby, 0, 0, 10); + } + *(int *)(data + 0x134) = rand() % 120 + 60; moby[0x20] = 1; } - if (*(int *)(target + 16) && *(int *)(target + 16) == D_001413D0_lui[0] && FUN_L07_0030f4d0(moby, *(int *)(target + 16), 1.5f)) { - if (moby[0x53] != 2) blend_moby_animation(moby, 2, 0, 2); + if (target.moby != 0 && target.moby == *(int *)&D_001413D0 && + FUN_L07_0030f4d0_c(moby, target.moby, 1.5f)) { + if (moby[0x53] != 2) { + blend_moby_animation(moby, 2, 0, 2); + } moby[0x20] = 5; } - FUN_L07_0030f0f8(moby, data, frame_time_sq * 15.0f, frame_time_sq * 50.0f, frame_time * 8.0f); - if (next_state != 0xff) { - if (moby[0x53] != next_sequence) blend_moby_animation(moby, next_sequence, 0, 6); + FUN_L07_0030f0f8_c((char *)moby, data, frame_time_sq * 15.0f, frame_time_sq * 50.0f, frame_time * 8.0f); + if (next_state != 0xFF) { + if (moby[0x53] != next_sequence) { + blend_moby_animation(moby, next_sequence, 0, 6); + } moby[0x20] = next_state; } - goto bounds; - case 4: - angle = fast_arc_tan(target[0] - F(moby, 0x10), target[1] - F(moby, 0x14)); - FUN_L00_00258278(moby, data + 0x120, angle, frame_time_sq * 12.566371f, frame_time_sq * 0.0f, frame_time * 12.566371f); - distance = FUN_001f9b80(position, target); - height = fast_arc_tan(distance, target[2] - F(moby, 0x18)); - F(moby, 0x44) = FUN_L00_00258110(data + 0x124, F(moby, 0x44), -height, frame_time_sq * 12.566371f, frame_time_sq * 0.0f, frame_time * 12.566371f); - wander = FUN_001f9b80(position, D_0013F3D0) < 3.0f; - if (wander) fast_vec_scale(data + 0xd0, data + 0xd0, frame_scale * -0.100000024f + 1.0f); - if (FUN_L07_0030f1e0(moby, data, angle, 0.20943952f, frame_time_sq * 20.0f, 0.5235988f, frame_time_sq * 3.0f, frame_time * 20.0f, frame_time * 5.0f) && wander) { - if (moby[0x53] != 2) blend_moby_animation(moby, 2, 4, 2); + goto end; + case 4: { + float angle; + float pitch; + int close = 1; + float pi4 = 12.566371f; + float three = 3.0f; + float zero = 0.0f; + angle = fast_arc_tan_c2(target.pos[0] - F(moby, 0x10), target.pos[1] - F(moby, 0x14)); + FUN_L00_00258278((char *)moby, (float *)(data + 0x120), angle, + frame_time_sq * pi4, frame_time_sq * zero, frame_time * pi4); + pitch = vector_distance_xy_alt(moby + 0x10, &target); + pitch = fast_arc_tan_c2(pitch, target.pos[2] - F(moby, 0x18)); + F(moby, 0x44) = FUN_L00_00258110((float *)(data + 0x124), F(moby, 0x44), -pitch, + frame_time_sq * pi4, frame_time_sq * zero, frame_time * pi4); + if (!(vector_distance_xy_alt(moby + 0x10, ((char *)&D_0013F3D0)) < three)) { + close = 0; + } + if (close) { + fast_vec_scale_c(data + 0xD0, data + 0xD0, frame_scale * (0.9f - 1.0f) + 1.0f); + } + if (FUN_L07_0030f1e0_c((char *)moby, data, angle, 0.209439516f, frame_time_sq * 20.0f, + 0.52359879f, frame_time_sq * three, frame_time * 20.0f, frame_time * 5.0f) && + close) { + if (moby[0x53] != 2) { + blend_moby_animation(moby, 2, 4, 2); + } *(int *)(moby + 0x94) = 0; moby[0x20] = 5; - F(data, 0x14c) = 0.0f; - qcopy(data + 0x100, position); - } - { - float distance = frame_time_sq * 38.0f; - float height = frame_time_sq * 0.0f; - float scale = frame_time * 38.0f; - F(data, 0x138) = target[2] - 0.25f; - FUN_L07_0030f0f8(moby, data, distance, height, scale); - } - if (!inside || D_0013F65C == 0) { - if (moby[0x53] != 1) blend_moby_animation(moby, 1, 0, 10); + F(data, 0x14C) = zero; + qcopy(data + 0x100, moby + 0x10); + } + ((struct { char pad[0x138]; float f; } *)data)->f = target.pos[2] - 0.25f; + FUN_L07_0030f0f8_c((char *)moby, data, frame_time_sq * 38.0f, frame_time_sq * 0.0f, frame_time * 38.0f); + if (!inside || *(short *)&D_0013F65C == 0) { + if (moby[0x53] != 1) { + blend_moby_animation(moby, 1, 0, 10); + } moby[0x20] = 2; } - if (next_state != 0xff) { - if (moby[0x53] != next_sequence) blend_moby_animation(moby, next_sequence, 0, 6); + if (next_state != 0xFF) { + if (moby[0x53] != next_sequence) { + blend_moby_animation(moby, next_sequence, 0, 6); + } moby[0x20] = next_state; } - goto bounds; + goto end; + } case 5: { float angle; - moby_point_position(moby, 0, point); - subtract_vector_xyz(offset, point, position); - angle = fast_arc_tan(target[0] - point[0], target[1] - point[1]); - FUN_L00_00258278(moby, data + 0x120, angle, frame_time_sq * 12.566371f, frame_time_sq * 0.0f, frame_time * 12.566371f); + char *mpos; + char *start; + float one; + FUN_L00_0024f7c8(moby, 0, point); + mpos = (char *)moby + 0x10; + subtract_vector_xyz(offset, point, mpos); + angle = fast_arc_tan_c2(target.pos[0] - point[0], target.pos[1] - point[1]); + func_L00_002592B0_t((char *)moby, angle, (float *)(data + 0x120), + frame_time_sq * 12.566371f, frame_time_sq * 0.0f, frame_time * 12.566371f); F(moby, 0x44) *= frame_scale * 0.7f; - F(data, 0x14c) += 0.028f; - qcopy(previous, position); - subtract_vector_xyz(goal, target, offset); - subtract_vector_xyz(delta, goal, data + 0x100); - fast_vec_scale(delta, delta, F(data, 0x14c) < 1.0f ? F(data, 0x14c) : 1.0f); - add_vector_xyz(position, delta, data + 0x100); - FUN_001e93e8(previous, position); - FUN_001e93e8(data + 0x100, position); - subtract_vector_xyz(data + 0xd0, position, previous); - if (1.0f <= F(data, 0x14c)) { - D_001415F8 = 0; - hero_set_state(0x3d, 1); - *(int *)(D_001413D0_lui[0] + 0x98) = -1; - D_001413F5_lui[0] = 1; + F(data, 0x14C) += 0.028f; + qcopy(previous, mpos); + subtract_vector_xyz(goal, &target, offset); + start = data + 0x100; + subtract_vector_xyz(delta, goal, start); + one = 1.0f; + fast_vec_scale_c(delta, delta, F(data, 0x14C) < one ? F(data, 0x14C) : one); + add_vector_xyz(mpos, delta, start); + no_op_main_callback_alt(previous, mpos); + no_op_main_callback_alt(start, mpos); + subtract_vector_xyz(data + 0xD0, mpos, previous); + if (one <= F(data, 0x14C)) { + char *hero_bytes = (char *)&D_0013F350; + *(int *)(hero_bytes + 0x22A8) = 0; + FUN_L00_002223f8(0x3D, 1); + *(int *)(*(char **)(hero_bytes + 0x2080) + 0x98) = -1; + hero_bytes[0x20A5] = 1; moby[0x20] = 6; - } else F(data, 0x13c) = angle; - if (!inside && D_0013F65C == 0) { - F(data, 0x14c) = 0.0f; - if (moby[0x53] != 1) blend_moby_animation(moby, 1, 0, 10); - moby[0x20] = 2; + } else { + F(data, 0x13C) = angle; } - goto bounds; - } - case 6: - FUN_L07_0030eee8(moby, data); - FUN_L07_0030f1e0(moby, data, F(data, 0x13c), 0.20943952f, frame_time_sq * 6.0f, 0.5235988f, frame_time_sq * 4.0f, frame_time * 7.0f, frame_time * 3.0f); - FUN_L07_0030f0f8(moby, data, frame_time_sq * 12.0f, frame_time_sq * 50.0f, frame_time * 7.0f); - FUN_L00_00258278(moby, data + 0x120, F(data, 0x13c), frame_time_sq * 1.5707964f, frame_time_sq * 3.1415927f, frame_time * 3.1415927f); - F(moby, 0x44) = FUN_L00_00258110(data + 0x124, F(moby, 0x44), 0.0f, frame_time_sq * 1.5707964f, frame_time_sq * 3.1415927f, frame_time * 3.1415927f); - if ((moby[0x70] & 2) && moby[0x53] != 1) blend_moby_animation(moby, 1, 0, 10); - if (next_state != 0xff) { - if (moby[0x53] != next_sequence) blend_moby_animation(moby, next_sequence, 0, 6); + if (inside || *(short *)&D_0013F65C != 0) { + goto end; + } + *(int *)(data + 0x14C) = 0; + if (moby[0x53] != 1) { + blend_moby_animation(moby, 1, 0, 10); + } + moby[0x20] = 2; + goto end; + } + case 6: { + float seven = 7.0f; + float pi = 3.14159274f; + float pi2 = 1.57079637f; + FUN_L07_0030eee8_c((struct Moby *)moby, (struct WalkerData *)data); + FUN_L07_0030f1e0_c((char *)moby, data, F(data, 0x13C), 0.209439516f, frame_time_sq * 6.0f, + 0.52359879f, frame_time_sq * 4.0f, frame_time * seven, frame_time * 3.0f); + FUN_L07_0030f0f8_c((char *)moby, data, frame_time_sq * 12.0f, frame_time_sq * 50.0f, frame_time * seven); + FUN_L00_00258278((char *)moby, (float *)(data + 0x120), F(data, 0x13C), + frame_time_sq * pi2, frame_time_sq * pi, frame_time * pi); + F(moby, 0x44) = FUN_L00_00258110((float *)(data + 0x124), F(moby, 0x44), 0.0f, + frame_time_sq * pi2, frame_time_sq * pi, frame_time * pi); + if ((moby[0x70] & 2) && moby[0x53] != 1) { + blend_moby_animation(moby, 1, 0, 10); + } + if (next_state != 0xFF) { + if (moby[0x53] != next_sequence) { + blend_moby_animation(moby, next_sequence, 0, 6); + } moby[0x20] = next_state; } - goto bounds; + goto end; + } case 7: if (inside) { - if (moby[0x53] != 4) blend_moby_animation(moby, 4, 0, 10); + if (moby[0x53] != 4) { + blend_moby_animation(moby, 4, 0, 10); + } moby[0x20] = 9; } else if (wander) { - if (moby[0x53] != 4) blend_moby_animation(moby, 4, 0, 10); - *(int *)(data + 0x134) = rand_e50() % 200 + 300; - F(data, 0x13c) = random_angle_radians(); + if (moby[0x53] != 4) { + blend_moby_animation(moby, 4, 0, 10); + } + *(int *)(data + 0x134) = rand() % 200 + 300; + F(data, 0x13C) = random_angle_radians_c2(); moby[0x20] = 8; } - fast_vec_scale(data + 0xd0, data + 0xd0, frame_scale * -0.050000012f + 1.0f); - F(data, 0xd8) -= frame_time * 9.8f; - if (FUN_L00_00258ad0((int)moby, (int)(data + 0xd0), 0x400, 0x10, 1.0f, 0.0f)) fast_vec_scale(data + 0xd0, data + 0xd0, 0.5f); - if (next_state != 0xff) { - if (moby[0x53] != next_sequence) blend_moby_animation(moby, next_sequence, 0, 6); + fast_vec_scale_c(data + 0xD0, data + 0xD0, frame_scale * (0.95f - 1.0f) + 1.0f); + F(data, 0xD8) -= frame_time * 9.8f; + if (FUN_L00_00258ad0((int)moby, (int)(data + 0xD0), 0x400, 0x10, 1.0f, 0.0f)) { + fast_vec_scale_c(data + 0xD0, data + 0xD0, 0.5f); + } + if (next_state != 0xFF) { + if (moby[0x53] != next_sequence) { + blend_moby_animation(moby, next_sequence, 0, 6); + } moby[0x20] = next_state; } - goto bounds; + goto end; case 8: if (inside) { - if (moby[0x53] != 4) blend_moby_animation(moby, 4, 0, 10); + if (moby[0x53] != 4) { + blend_moby_animation(moby, 4, 0, 10); + } moby[0x20] = 9; } else { - FUN_L00_00258278(moby, data + 0x120, F(data, 0x13c), frame_time_sq * 0.7853982f, frame_time_sq * 1.5707964f, frame_time * 0.7853982f); - F(moby, 0x44) = FUN_L00_00258110(data + 0x124, F(moby, 0x44), 0.0f, frame_time_sq * 0.7853982f, frame_time_sq * 1.5707964f, frame_time * 0.7853982f); - if (wander && is_point_inside_clip_volume(position, *(int *)(data + 0x114))) { - if (moby[0x53] != 3) blend_moby_animation(moby, 3, 0, 10); - *(int *)(data + 0x134) = rand_e50() % 120 + 60; + float stiffness = 0.785398185f; + float damping = 1.57079637f; + FUN_L00_00258278((char *)moby, (float *)(data + 0x120), F(data, 0x13C), + frame_time_sq * stiffness, frame_time_sq * damping, frame_time * stiffness); + F(moby, 0x44) = FUN_L00_00258110((float *)(data + 0x124), F(moby, 0x44), 0.0f, + frame_time_sq * stiffness, frame_time_sq * damping, frame_time * stiffness); + if (wander && is_point_inside_clip_volume_c2(moby + 0x10, *(int *)(data + 0x114))) { + if (moby[0x53] != 3) { + blend_moby_animation(moby, 3, 0, 10); + } + *(int *)(data + 0x134) = rand() % 120 + 60; moby[0x20] = 7; } } - FUN_L07_0030eee8(moby, data); - if (FUN_L07_0030f1e0(moby, data, F(data, 0x13c), 0.34906584f, frame_time_sq * 3.0f, 1.0471976f, frame_time_sq * 9.0f, frame_time, frame_time) && wander) { - if (moby[0x53] != 3) blend_moby_animation(moby, 3, 0, 10); - *(int *)(data + 0x134) = rand_e50() % 120 + 60; + FUN_L07_0030eee8_c((struct Moby *)moby, (struct WalkerData *)data); + if (FUN_L07_0030f1e0_c((char *)moby, data, F(data, 0x13C), 0.34906584f, frame_time_sq * 3.0f, + 1.04719758f, frame_time_sq * 9.0f, frame_time, frame_time) && + wander) { + if (moby[0x53] != 3) { + blend_moby_animation(moby, 3, 0, 10); + } + *(int *)(data + 0x134) = rand() % 120 + 60; moby[0x20] = 7; } - F(data, 0xd8) -= frame_time * 9.8f; - if (FUN_L00_00258ad0((int)moby, (int)(data + 0xd0), 0x400, 0x10, 1.0f, 0.0f)) fast_vec_scale(data + 0xd0, data + 0xd0, 0.5f); - if (next_state != 0xff) { - if (moby[0x53] != next_sequence) blend_moby_animation(moby, next_sequence, 0, 6); + F(data, 0xD8) -= frame_time * 9.8f; + if (FUN_L00_00258ad0((int)moby, (int)(data + 0xD0), 0x400, 0x10, 1.0f, 0.0f)) { + fast_vec_scale_c(data + 0xD0, data + 0xD0, 0.5f); + } + if (next_state != 0xFF) { + if (moby[0x53] != next_sequence) { + blend_moby_animation(moby, next_sequence, 0, 6); + } moby[0x20] = next_state; } - goto bounds; - case 9: case 10: { + goto end; + case 9: + case 10: { float angle; - angle = fast_arc_tan(target[0] - F(moby, 0x10), target[1] - F(moby, 0x14)); - FUN_L00_00258278(moby, data + 0x120, angle, frame_time_sq * 0.7853982f, frame_time_sq * 1.5707964f, frame_time * 0.7853982f); - if (FUN_L07_0030f1e0(moby, data, angle, 0.5235988f, frame_time_sq * 4.0f, 1.5707964f, frame_time_sq * 9.0f, frame_time * 1.5f, frame_time) && FUN_001f9b80(position, target) < 1.9f && moby[0x20] != 10) { - if (moby[0x53] != 5) blend_moby_animation(moby, 5, 0, 2); + float pi2 = 1.57079637f; + angle = fast_arc_tan_c2(target.pos[0] - F(moby, 0x10), target.pos[1] - F(moby, 0x14)); + func_L00_002592B0_t((char *)moby, angle, (float *)(data + 0x120), + frame_time_sq * 0.785398185f, frame_time_sq * pi2, frame_time * 0.785398185f); + if (FUN_L07_0030f1e0_c((char *)moby, data, angle, 0.52359879f, frame_time_sq * 4.0f, + pi2, frame_time_sq * 9.0f, frame_time * 1.5f, frame_time) && + vector_distance_xy_alt(moby + 0x10, &target) < 1.9f && moby[0x20] != 10) { + if (moby[0x53] != 5) { + blend_moby_animation(moby, 5, 0, 2); + } moby[0x20] = 10; } - F(data, 0xd8) -= frame_time * 9.8f; - if (FUN_L00_00258ad0((int)moby, (int)(data + 0xd0), 0x400, 0x10, 1.0f, 0.0f)) fast_vec_scale(data + 0xd0, data + 0xd0, 0.5f); - data[0x58] = truncate_float_to_s32(8.0f); - data[0x5a] = truncate_float_to_s32(9.6f); + F(data, 0xD8) -= frame_time * 9.8f; + if (FUN_L00_00258ad0((int)moby, (int)(data + 0xD0), 0x400, 0x10, 1.0f, 0.0f)) { + fast_vec_scale_c(data + 0xD0, data + 0xD0, 0.5f); + } + data[0x58] = func_001FA898_r(8.0f); + data[0x5A] = func_001FA898_r(9.6f); if (!inside) { - if (moby[0x53] != 4) blend_moby_animation(moby, 4, 0, 10); + if (moby[0x53] != 4) { + blend_moby_animation(moby, 4, 0, 10); + } moby[0x20] = 8; } - /* Preserve retail argument-bank order and call setup on the EE. */ - ((void (*)(char *, char *, int, int, float, float, float, float, float, int, int, int, int))FUN_L07_0030f308) - ((char *)moby, data, 10, 5, 17.0f, 20.0f, 1.0f, 1.0f, 1.0f, 4, 4, 11, *(int *)(target + 16)); + ((void (*)(char *, float, char *, float, int, float, int, float, float, int, int, int, int))FUN_L07_0030f308_c)((char *)moby, 17.0f, data, 20.0f, 10, 1.0f, 5, 1.0f, 1.0f, 4, 4, 11, target.moby); if (moby[0x70] & 2) { - if (moby[0x53] != 4) blend_moby_animation(moby, 4, 0, 10); - *(int *)(data + 0x134) = rand_e50() % 200 + 300; + if (moby[0x53] != 4) { + blend_moby_animation(moby, 4, 0, 10); + } + *(int *)(data + 0x134) = rand() % 200 + 300; moby[0x20] = 8; } - if (next_state != 0xff) { - if (moby[0x53] != next_sequence) blend_moby_animation(moby, next_sequence, 0, 6); + if (next_state != 0xFF) { + if (moby[0x53] != next_sequence) { + blend_moby_animation(moby, next_sequence, 0, 6); + } moby[0x20] = next_state; } - goto bounds; + goto end; } case 11: - if (moby[0x70] & 2) moby[0x20] = 7; - goto bounds; + if (moby[0x70] & 2) { + moby[0x20] = 7; + } + goto end; case 12: - if (FUN_L00_0025c698(moby, data + 0x70) & 1) ((void (*)(char *, char *))FUN_L07_0030ec58)(moby, data); - goto bounds; + if (FUN_L00_0025c698(moby, data + 0x70) & 1) { + ((void (*)(char *, char *))FUN_L07_0030ec58_c)((char *)moby, data); + } + goto end; case 13: - if (moby[0x70] & 2) ((void (*)(char *, char *))FUN_L07_0030ec58)(moby, data); - goto bounds; + if (moby[0x70] & 2) { + ((void (*)(char *, char *))FUN_L07_0030ec58_c)((char *)moby, data); + } + goto end; case 14: if (FUN_L00_0025c698(moby, data + 0x70) & (moby[0x70] & 2)) { - /* Preserve retail argument-bank order and call setup on the EE. */ - ((void (*)(void *, float, void *, int, float, float, int, float, int, float, int, float, int, float, int, int, int, int))FUN_L00_0025e450_l07) - (moby, 0.0f, data + 0xd0, 0, 0.0f, 2.0f, 3, 1.0f, 3, 4.0f, 5, 1.0f, -1, 7.0f, 0, 1, -1, 0); - goto remove; - } - goto bounds; - remove: - mark_moby_for_removal(moby); - return; + FUN_L00_0025e450_c2(moby, data + 0xD0, 0, 0.0f, 0.0f, 3, 3, 5, 2.0f, 1.0f, 4.0f, 1.0f, -1, 7.0f, + 0, 1, -1, 0); + mark_moby_for_removal_c4(moby); + return; + } + goto end; case 16: - fast_vec_scale(data + 0xd0, data + 0xd0, frame_scale * -0.050000012f + 1.0f); - F(data, 0xd8) -= frame_time * 9.8f; - FUN_L00_00258ad0((int)moby, (int)(data + 0xd0), 0x400, 0x10, 1.0f, 0.0f); - if (moby[0x70] & 2) ((void (*)(char *, char *))FUN_L07_0030ec58)(moby, data); - goto bounds; + fast_vec_scale_c(data + 0xD0, data + 0xD0, frame_scale * (0.95f - 1.0f) + 1.0f); + F(data, 0xD8) -= frame_time * 9.8f; + FUN_L00_00258ad0((int)moby, (int)(data + 0xD0), 0x400, 0x10, 1.0f, 0.0f); + if (moby[0x70] & 2) { + ((void (*)(char *, char *))FUN_L07_0030ec58_c)((char *)moby, data); + } + goto end; case 15: - fast_vec_scale(data + 0xd0, data + 0xd0, frame_scale * -0.050000012f + 1.0f); - F(data, 0xd8) -= frame_time * 9.8f; - FUN_L00_00258ad0((int)moby, (int)(data + 0xd0), 0x400, 0x10, 1.0f, 0.0f); - if (next_state != 0xff) { - if (moby[0x53] != next_sequence) blend_moby_animation(moby, next_sequence, 0, 6); + fast_vec_scale_c(data + 0xD0, data + 0xD0, frame_scale * (0.95f - 1.0f) + 1.0f); + F(data, 0xD8) -= frame_time * 9.8f; + FUN_L00_00258ad0((int)moby, (int)(data + 0xD0), 0x400, 0x10, 1.0f, 0.0f); + if (next_state != 0xFF) { + if (moby[0x53] != next_sequence) { + blend_moby_animation(moby, next_sequence, 0, 6); + } moby[0x20] = next_state; } - goto bounds; + goto end; case 17: - fast_vec_scale(data + 0xd0, data + 0xd0, frame_scale * -0.050000012f + 1.0f); - if (moby[0x70] & 2) ((void (*)(char *, char *))FUN_L07_0030ec58)(moby, data); - goto bounds; - default: goto bounds; + fast_vec_scale_c(data + 0xD0, data + 0xD0, frame_scale * (0.95f - 1.0f) + 1.0f); + if (moby[0x70] & 2) { + ((void (*)(char *, char *))FUN_L07_0030ec58_c)((char *)moby, data); + } + goto end; + default: + goto end; } -bounds: - if (F(moby, 0x10) < 2.0f || 1021.0f < F(moby, 0x10) || F(moby, 0x14) < 2.0f || 1021.0f < F(moby, 0x14) || F(moby, 0x18) < 2.0f || 1021.0f < F(moby, 0x18)) { - mark_moby_for_removal(moby); +end: + if (F(moby, 0x10) < 2.0f || 1021.0f < F(moby, 0x10) || F(moby, 0x14) < 2.0f || + 1021.0f < F(moby, 0x14) || F(moby, 0x18) < 2.0f || 1021.0f < F(moby, 0x18)) { + mark_moby_for_removal_c4(moby); } } -#endif extern int rand(void) __asm__("FUN_001160d8"); extern int FUN_001f96f8(int); extern int FUN_001f9740(int *); @@ -2948,7 +3118,6 @@ extern char D_0013F3D0[]; extern char D_0013F440[]; extern float D_0013F448; -extern u8 D_0014C050[]; void FUN_L07_003112c8(char *moby) { char *data = *(char **)(moby + 0x78); @@ -2995,7 +3164,7 @@ void FUN_L07_003112c8(char *moby) { moby[0x20] = 1; moby[0xBC] = 0; if (((unsigned char *)moby)[0xB0] != 0xFF) { - if (D_0014C050[((unsigned char *)moby)[0xB0] + current_level_index * 16] != 0xFF) + if (visited52[((unsigned char *)moby)[0xB0] + current_level_index * 16] != 0xFF) break; *(float *)(moby + 0x18) -= 5.0f; if (((unsigned char *)data)[0xBC] == 0) { diff --git a/src/overlays/l08/gameplay/entities/bolt_thief.c b/src/overlays/l08/gameplay/entities/bolt_thief.c index 156789c318..0d5cf87ad9 100644 --- a/src/overlays/l08/gameplay/entities/bolt_thief.c +++ b/src/overlays/l08/gameplay/entities/bolt_thief.c @@ -162,7 +162,7 @@ extern void FUN_001f9a28(void *, void *, void *); extern void moby_point_position(void *, int, void *) __asm__("FUN_L00_0024f7c8"); extern void FUN_L00_00250df8(void *); -extern short D_L08_00161D28 __attribute__((sda)); +extern float D_L08_00161D28 __attribute__((sda)); void FUN_L08_002e8ba0(struct Moby *a) { char *data = (char *)a->pvars; float v0[4], v10[4], v20[4]; @@ -183,7 +183,7 @@ void FUN_L08_002e8ba0(struct Moby *a) { char *r = *(char **)(data + 0x90); *(float *)(*(char **)(data + 0x90) + 0x40) = fast_add_rotations( *(float *)(r + 0x40), - *(float *)&D_L08_00161D28 * DEG_TO_RAD * D_0015ED6C); + D_L08_00161D28 * DEG_TO_RAD * D_0015ED6C); } for (i = 0; i < 12; i++) { char *m = *(char **)(base + 0x10 + i * 16); @@ -195,7 +195,7 @@ void FUN_L08_002e8ba0(struct Moby *a) { extern void FUN_001f9a68(void *, void *, float); -extern short D_L08_00161D38 __attribute__((sda)); +extern float D_L08_00161D38 __attribute__((sda)); void FUN_L08_002e9a18(struct Moby *arg) { char *data = (char *)arg->pvars; float v0[4]; @@ -218,7 +218,7 @@ void FUN_L08_002e9a18(struct Moby *arg) { if (*(char **)(data + 0x90) != 0) { *(float *)(*(char **)(data + 0x90) + 0x40) = fast_add_rotations(*(float *)(*(char **)(data + 0x90) + 0x40), - *(float *)&D_L08_00161D38 * DEG_TO_RAD * D_0015ED6C); + D_L08_00161D38 * DEG_TO_RAD * D_0015ED6C); } p = parts + 0x10; for (i = 0; i < 16; i++) { @@ -602,7 +602,6 @@ extern float FUN_001f9b80(void *, void *); extern float fast_difference_between_rotations(float, float) __asm__("func_001FA688"); extern int D_0013CAE4 __attribute__((section(".data"))); /* no foreign declaration */ extern int D_0013F350; -extern float D_0015ED60; extern int D_0015EDDC; extern int D_L08_00161A90 __attribute__((sda)); extern float D_L08_00161AE8_gp __asm__("D_L08_00161AE8") __attribute__((sda)); @@ -654,7 +653,6 @@ extern unsigned char visited52[][16] __asm__("D_0014C050"); extern int invert52 __asm__("D_0015EDDC"); extern char *D_L08_0015FFD8; extern int D_0015ED84; -extern float D_0015ED60; extern float D_0015ED6C; extern float D_0015ED70; extern CannonCamera52_2E16A0 cannon_camera52 __asm__("D_L08_00167480"); @@ -848,7 +846,7 @@ void FUN_L08_002e0328(Moby *moby) { random_vec[1] = func_002140F8_2E16A0(-1.0f,1.0f); random_vec[2] = func_002140F8_2E16A0(-1.0f,1.0f); *(u128 *)scatter = *(u128 *)random_vec; - fast_vec_normalize(scatter, scatter, fast_vec_length(direction) * (D_0015ED60 * -0.35000002f + 1.0f)); + fast_vec_normalize(scatter, scatter, fast_vec_length(direction) * (frame_scale * -0.35000002f + 1.0f)); fast_vec_add(scatter, direction, scatter); fast_vec_normalize(scatter, scatter, func_002140F8_2E16A0(D_0015ED6C * 3.0f, D_0015ED6C * 6.0f)); min_life = func_001F9850_2E16A0(5); @@ -877,7 +875,7 @@ void FUN_L08_002e0328(Moby *moby) { random_vec[1] = func_002140F8_2E16A0(-1.0f,1.0f); random_vec[2] = func_002140F8_2E16A0(-1.0f,1.0f); *(u128 *)scatter = *(u128 *)random_vec; - fast_vec_normalize(scatter, scatter, fast_vec_length(direction) * (D_0015ED60 * -0.35000002f + 1.0f)); + fast_vec_normalize(scatter, scatter, fast_vec_length(direction) * (frame_scale * -0.35000002f + 1.0f)); fast_vec_add(scatter, direction, scatter); fast_vec_normalize(scatter, scatter, func_002140F8_2E16A0(D_0015ED6C * 3.0f, D_0015ED6C * 6.0f)); min_life = func_001F9850_2E16A0(5); @@ -1889,19 +1887,17 @@ void FUN_L08_002e2df0(struct Moby *moby) { } FUN_L00_0025d538(moby, data->x60); } -#ifndef NON_MATCHING -INCLUDE_ASM("config/us/overlays/asm/FUN_L08_002e3870.s", FUN_L08_002e3870); -#else -/* Ported from rac1-decomp (src/overlays/l08_batalia/vendor_002E0258.c: func_L08_002E4BE8), where it is exact; names translated to the US level program. */ -/* NEAR: 12 words; the four callback and bolt-table address luis get their callee-saved registers in another order. */ +#include "rnc/overlay/hud.h" + /* Batalia turret bolt: rides its turret, flies to the hero when shot and is collected, falls and bounces when the turret dies. */ +/* Ported from rac1-decomp (src/overlays/l08_batalia/vendor_002E0258.c: func_L08_002E4BE8), where it is exact; names translated to the US level program. */ typedef struct Hero Hero; -typedef int u128_4BE8 __attribute__((mode(TI))); +typedef int u128_4BE8_p __attribute__((mode(TI))); typedef struct { - float v0[4]; /* 0x00 */ + float anchor[4]; /* 0x00 */ float v10[4]; /* 0x10 */ float v20[4]; /* 0x20 */ float v30[4]; /* 0x30 */ @@ -1927,7 +1923,7 @@ typedef struct { } Coll_4BE8; typedef struct { - u8 pad_00[0xB1]; + u8 pad_00_p[0xB1]; u8 id; } BoltSource_4BE8; @@ -1942,102 +1938,86 @@ typedef struct { } KillFlags_4BE8; extern BoltSourceStats_4BE8 D_0014D590[][64]; -extern Coll_4BE8 D_L08_00174640; +typedef struct { + float pos[4]; /* 0x00 */ + char pad10[0x10]; + float n[4]; /* 0x20 */ +} CollPos_4BE8; +extern float D_L08_00174660[]; extern KillFlags_4BE8 D_L08_001BADD0; extern KillFlags_4BE8 D_L08_001BBA30; -extern Moby *D_L08_0015FFDC __attribute__((section(".sdata"))); -extern char D_0013E533[]; -extern f32 approach_value(f32 target, f32 step, f32 *value) __asm__("FUN_00213ed8"); -extern f32 convert_integer_to_float(s32) __asm__("func_001FA6C0"); -extern f32 distance_xyz(void *, void *) __asm__("func_001F9B48"); -extern f32 fast_add_rotations(f32, f32) __asm__("func_001FA580"); -extern f32 fast_cos(f32) __asm__("func_001F9DC8"); -extern f32 fast_sin(f32) __asm__("func_001F9DE0"); -extern f32 fast_subtract_rotations(f32, f32) __asm__("func_001FA5C8"); -extern f32 random_angle_radians(void) __asm__("func_00213308"); -extern f32 random_float_between(f32, f32) __asm__("func_002132A8"); -extern f32 vector_length_xy(void *) __asm__("FUN_001f9b20"); -extern float D_0015ED6C; -extern float D_0015ED70; -extern float D_L08_00161C88 __attribute__((sda)); -extern float D_L08_00161C8C __attribute__((sda)); -extern float D_L08_00161C94 __attribute__((sda)); -extern float D_L08_00161C98 __attribute__((sda)); -extern float D_L08_00161C9C __attribute__((sda)); -extern float D_L08_00161CA0 __attribute__((sda)); -extern float D_L08_00161CA4 __attribute__((sda)); -extern float D_L08_00161CA8 __attribute__((sda)); -extern float D_L08_00161CAC __attribute__((sda)); -extern float D_L08_00161CB0 __attribute__((sda)); -extern short D_L08_00161CB4 __attribute__((sda)); -extern short D_L08_00161CB8 __attribute__((sda)); -extern short D_L08_00161CBC __attribute__((sda)); -extern float D_L08_00161CD0 __attribute__((sda)); -extern float multiply_global_factor_ed64(float) __asm__("FUN_001f96b0"); -extern float FUN_001f9b80(void *, void *); -extern float FUN_001f9e90(float, float); +extern struct Moby *D_L08_0015FFDC; +extern f32 fast_arc_tan(f32, f32) __asm__("func_001F9E90"); +extern f32 fast_subtract_rotations_c2(f32, f32) __asm__("func_001FA5C8"); +extern f32 fast_vec_dist(void *, void *); +extern f32 random_angle_radians_c2(void) __asm__("func_00213308"); +extern f32 random_float_between_c5(f32, f32) __asm__("func_002132A8"); +extern float D_L08_00161C88_gp __asm__("D_L08_00161C88") __attribute__((sda)); +extern float D_L08_00161C8C_gp __asm__("D_L08_00161C8C") __attribute__((sda)); +extern float D_L08_00161C94_gp __asm__("D_L08_00161C94") __attribute__((sda)); +extern float D_L08_00161C98_gp __asm__("D_L08_00161C98") __attribute__((sda)); +extern float D_L08_00161C9C; +extern float D_L08_00161CA0_gp __asm__("D_L08_00161CA0") __attribute__((sda)); +extern float D_L08_00161CA4_gp __asm__("D_L08_00161CA4") __attribute__((sda)); +extern float D_L08_00161CA8; +extern float D_L08_00161CAC_gp __asm__("D_L08_00161CAC") __attribute__((sda)); +extern float D_L08_00161CB0; +extern float D_L08_00161CB4_gp __asm__("D_L08_00161CB4") __attribute__((sda)); +extern float D_L08_00161CB8; +extern float D_L08_00161CBC_gp __asm__("D_L08_00161CBC") __attribute__((sda)); +extern float D_L08_00161CD0_gp __asm__("D_L08_00161CD0") __attribute__((sda)); +extern float FUN_001f96b0(float); extern float FUN_L00_0025bc00(float *, float, float, int); -extern float fast_difference_between_rotations(float, float) __asm__("func_001FA688"); -extern int D_L08_0015F5CC; /* no foreign declaration */ -extern int D_L08_00161CC0 __attribute__((sda)); -extern int D_L08_00161CC4 __attribute__((sda)); -extern int D_L08_00161CC8 __attribute__((sda)); -extern int D_L08_00161CCC __attribute__((sda)); -extern int D_L08_00161CD4 __attribute__((sda)); -extern int D_L08_00174658; /* no foreign declaration */ +extern float fast_add_rotations_c4(float, float) __asm__("func_001FA580"); +extern float vector_distance_xy_alt(void *, void *) __asm__("FUN_001f9b80"); +extern int D_L08_00161CC0; +extern int D_L08_00161CC4_gp __asm__("D_L08_00161CC4") __attribute__((sda)); +extern int D_L08_00161CC8; +extern int D_L08_00161CCC_gp __asm__("D_L08_00161CCC") __attribute__((sda)); +extern int D_L08_00161CD4_gp __asm__("D_L08_00161CD4") __attribute__((sda)); +extern int D_L08_00174658; extern int FUN_001efa68(void *, void *, int, int, int); extern int FUN_L00_001f0d60(float, void *, int, void *); extern int FUN_L00_002604f0(void *, int, void *, void *, void *, void *); extern int queue_animation_update_alt(s32, s32, void *, void *, void *, void *, s32) __asm__("FUN_001ff308"); -extern int scale_game_frames_alt(int) __asm__("FUN_001f96f8"); -extern s32 D_0013DF38[]; -extern s32 D_0015ED84 __attribute__((section(".sdata"))); -extern s32 D_0015ED98 __attribute__((section(".sdata"))); -extern s32 allocate_voice_for_target_entry_alt(s32, s32, struct Moby *) __asm__("FUN_0022da68"); -extern s32 random_integer_below(s32) __asm__("func_00213260"); -extern s32 tick_countdown_32_alt(s32 *) __asm__("FUN_001f9740"); -extern s32 truncate_float_to_s32(f32) __asm__("func_001FA6D0"); -extern u8 D_0014C050[]; +extern s32 level_bolts[] __asm__("D_0013DF38"); +extern s32 D_0015ED98; +extern s32 allocate_voice_for_target_entry(s32, s32, struct Moby *) __asm__("FUN_0022da68"); +extern s32 random_integer_below_c2(s32) __asm__("func_00213260"); +extern s32 scale_game_frames_c(s32) __asm__("func_001F96F8"); +extern s32 truncate_float_to_s32_c5(f32) __asm__("func_001FA6D0"); extern unsigned char *FUN_L00_002603d0(int); extern unsigned char *FUN_L00_00272060(float *pos, int a, float f0, float f1, int col, int mode, int b, float *vel, float f2); extern unsigned char D_0014BEC0[][4]; -extern unsigned char D_L08_0015FC88[] __attribute__((section(".sdata"))); -extern void euler_rotation_matrix(float *, float *) __asm__("FUN_001fa050"); -extern void matrix_to_euler(void *, void *) __asm__("FUN_00214598"); +extern unsigned char D_L08_0015FC88_macro[] __asm__("D_L08_0015FC88") __attribute__((section(".sdata"))); extern void FUN_L00_001ff660(void *, void *, void *); extern void FUN_L00_00257d78(void *, float, float); -extern void FUN_L00_0025f730(void *a, float x); +extern void FUN_L00_0025f730_c(void *a, float x) __asm__("FUN_L00_0025f730"); extern void FUN_L00_00260668(void *, int, void *, void *, void *, void *); extern void FUN_L08_0026a0f8(void *, void *, float); -extern void FUN_L08_002e4db8_3870(char *a, float *v) __asm__("FUN_L08_002e4db8"); -extern void FUN_L08_002e4e90_3870(char *m, float *out, float *rot) __asm__("FUN_L08_002e4e90"); -extern void FUN_L08_002e5188_3870(char *m) __asm__("FUN_L08_002e5188"); -extern void add_vector_xyz(void *, void *, void *) __asm__("FUN_001f9a10"); -extern void clear_u64_value(void *) __asm__("func_001F99F8"); +extern void FUN_L08_002e4db8_c(char *a, float *v) __asm__("FUN_L08_002e4db8"); +extern void FUN_L08_002e4e90_c(char *m, float *out, float *rot) __asm__("FUN_L08_002e4e90"); +extern void FUN_L08_002e5188_c(char *m) __asm__("FUN_L08_002e5188"); extern void cross_vectors_xyz(void *, void *, void *) __asm__("func_001F9AD8"); -extern void enqueue_callback_list_1(void *, void *) __asm__("FUN_001f4600"); -extern void mark_moby_for_removal(void *) __asm__("func_0020C828"); +extern void fast_vec_normalize_c2(void *, void *, f32) __asm__("FUN_001f9bf8"); +extern void fast_vec_scale_c(void *, void *, f32) __asm__("func_001F9A68"); +extern void mark_moby_for_removal_c3(void *) __asm__("func_0020C828"); extern void multiply_matrix_basis_columns(void *, void *, void *) __asm__("func_001FA328"); -extern void normalize_vector_xyz(void *, void *, f32) __asm__("FUN_001f9bf8"); -extern void scale_vector_xyz(void *, void *, float) __asm__("FUN_001f9a68"); -extern void subtract_vector_xyz(void *, void *, void *) __asm__("FUN_001f9a28"); extern void transform_vector(void *, void *, void *) __asm__("func_001F9D20"); float absolute_float(float input) __asm__("func_001F99C0"); -extern int D_0013F350; +int FUN_L00_00239df8(HudElem *m); +void FUN_L00_00239cc8(HudElem *e); +void FUN_L00_00239d00(void *o); extern char D_0013F3D0[]; extern char D_0013F490[]; -extern float func_001FA850_2E16A0(float, float) __asm__("FUN_001fa688"); -extern float func_001F9CE8_2E16A0(void *) __asm__("FUN_001f9b20"); -extern float func_00214D28_2E16A0(float *,float,float) __asm__("FUN_00213ed8"); -extern void func_001F49B0_2E16A0(void *,void *) __asm__("FUN_001f4600"); extern void func_L00_0023A658_4BE8(void) __asm__("FUN_L08_002444a8"); extern void func_L00_0023A690_4BE8(void) __asm__("FUN_L08_002444e0"); extern void func_L00_0023A788_4BE8(void) __asm__("FUN_L08_002445d8"); -extern unsigned char D_0014C050_4BE8[][16] __asm__("D_0014C050"); extern int D_L08_00174658_lui __asm__("D_L08_00174658") __attribute__((section(".data"))); -void FUN_L08_002e3870(Moby *moby) { - float dir[4]; +void FUN_L08_002e3870(struct Moby *moby) { + char *cam; + float direction[4]; float point[4]; float local[4]; float scratch[16]; @@ -2049,92 +2029,93 @@ void FUN_L08_002e3870(Moby *moby) { switch (moby->oclass) { case 0x279: - moby->scale = moby->pclass->scale * *(float *)&D_L08_00161CB4; + moby->scale = moby->pclass->scale * D_L08_00161CB4_gp; break; case 0x3DC: - moby->scale = moby->pclass->scale * *(float *)&D_L08_00161CB8; + moby->scale = moby->pclass->scale * D_L08_00161CB8; break; case 0x3DD: - moby->scale = moby->pclass->scale * *(float *)&D_L08_00161CBC; + moby->scale = moby->pclass->scale * D_L08_00161CBC_gp; break; } linked = 0; - if (D_L08_00161CD4 > D_L08_0015F5CC) { - D_L08_00161CD4 = D_L08_0015F5CC; + if (D_L08_00161CD4_gp > D_L08_0015F5CC) { + D_L08_00161CD4_gp = D_L08_0015F5CC; } moby->flags &= ~0x100; - qcopy(vars->v0, &moby->pos); + qcopy(vars->anchor, &moby->pos); if (vars->s6E == 0) { - normalize_vector_xyz(point, &moby->rot_row2, 0.1f); + fast_vec_normalize_c2(point, &moby->rot_row2, 0.1f); add_vector_xyz(point, point, &moby->pos); - scale_vector_xyz(local, &moby->rot_row2, -2.0f); + fast_vec_scale_c(local, &moby->rot_row2, -2.0f); add_vector_xyz(local, local, &moby->pos); if (FUN_001efa68(point, local, 2, 0, 0) != 0) { - qcopy(vars->v0, D_L08_00174640.pos); - linked = D_L08_00174640.moby; - normalize_vector_xyz(dir, D_L08_00174640.n, 1.0f); + CollPos_4BE8 *hit = (CollPos_4BE8 *)D_L08_00174660; + qcopy(vars->anchor, hit->pos); + linked = ((int *)hit)[-2]; + fast_vec_normalize_c2(direction, hit->n, 1.0f); } else { - qcopy(vars->v0, &moby->pos); - clear_u64_value(dir); - dir[2] = 1.0f; + qcopy(vars->anchor, &moby->pos); + clear_u64_value(direction); + direction[2] = 1.0f; } } - FUN_L08_002e4db8_3870((char *)moby, dir); - vars->f60 = random_angle_radians(); + FUN_L08_002e4db8_c((char *)moby, direction); + vars->f60 = random_angle_radians_c2(); vars->f64 = moby->rot.x; - FUN_L08_002e4e90_3870((char *)moby, (float *)&moby->pos, (float *)&moby->rot); + FUN_L08_002e4e90_c((char *)moby, (float *)&moby->pos, (float *)&moby->rot); if (linked != 0 && FUN_L00_002603d0(linked) != 0) { vars->u7C.i = linked; - FUN_L00_00260668(moby, linked, vars->v0, vars->v10, vars->v20, vars->v30); + FUN_L00_00260668(moby, linked, vars->anchor, vars->v10, vars->v20, vars->v30); } moby->state = 1; vars->s6C = 0; - vars->u70.i = truncate_float_to_s32(random_float_between(0.0f, (float)scale_game_frames_alt(600))); - vars->u78.i = D_L08_00161CCC; + vars->u70.i = truncate_float_to_s32_c5(random_float_between_c5(0.0f, (float)scale_game_frames_c(600))); + vars->u78.i = D_L08_00161CCC_gp; break; } case 1: { Vars_4BE8 *vars = (Vars_4BE8 *)moby->pvars; if (vars->u7C.i != 0) { - FUN_L00_002604f0(moby, vars->u7C.i, vars->v20, vars->v30, vars->v0, vars->v10); - if ((signed char)((Moby *)vars->u7C.i)->state < 0) { + FUN_L00_002604f0(moby, vars->u7C.i, vars->v20, vars->v30, vars->anchor, vars->v10); + if ((signed char)((struct Moby *)vars->u7C.i)->state < 0) { vars = (Vars_4BE8 *)moby->pvars; clear_u64_value(vars->velocity); - FUN_L08_0026a0f8(vars, &moby->rot_row1, D_L08_00161C98 * 0.017453292f * D_0015ED6C); + FUN_L08_0026a0f8(vars, &moby->rot_row1, D_L08_00161C98_gp * 0.017453292f * frame_time); moby->state = 4; break; } } - if (absolute_float(moby->pos.z - ((Hero *)(((char *)D_0013F350)))->motion.pos.f[2]) < ((Hero *)(((char *)D_0013F350)))->reach_distance - && FUN_001f9b80(&moby->pos, ((Hero *)(((char *)D_0013F350)))->motion.pos.f) < ((Hero *)(((char *)D_0013F350)))->reach_height) { - vars->timer = scale_game_frames_alt(1); + if (absolute_float(moby->pos.z - hero.motion.pos.f[2]) < hero.reach_distance + && vector_distance_xy_alt(&moby->pos, hero.motion.pos.f) < hero.reach_height) { + vars->timer = scale_game_frames_c(1); moby->state = 2; } if (moby->visible == 0) { - if (moby > D_L08_0015FFDC && FUN_001f9b80(&moby->pos, ((char *)&D_0013F3D0)) > 24.0f) { - mark_moby_for_removal(moby); + if (moby > D_L08_0015FFDC && vector_distance_xy_alt(&moby->pos, ((char *)&D_0013F3D0)) > 24.0f) { + mark_moby_for_removal_c3(moby); return; } break; } switch (moby->oclass) { case 0x3DD: - vars->f60 = fast_add_rotations(vars->f60, D_L08_00161CAC * 0.017453292f * D_0015ED6C); - vars->f64 = fast_add_rotations(vars->f64, D_L08_00161CB0 * 0.017453292f * D_0015ED6C); + vars->f60 = fast_add_rotations_c4(vars->f60, D_L08_00161CAC_gp * 0.017453292f * frame_time); + vars->f64 = fast_add_rotations_c4(vars->f64, D_L08_00161CB0 * 0.017453292f * frame_time); break; case 0x3DC: - vars->f60 = fast_add_rotations(vars->f60, D_L08_00161CA4 * 0.017453292f * D_0015ED6C); - vars->f64 = fast_add_rotations(vars->f64, D_L08_00161CA8 * 0.017453292f * D_0015ED6C); + vars->f60 = fast_add_rotations_c4(vars->f60, D_L08_00161CA4_gp * 0.017453292f * frame_time); + vars->f64 = fast_add_rotations_c4(vars->f64, D_L08_00161CA8 * 0.017453292f * frame_time); break; default: - vars->f60 = fast_add_rotations(vars->f60, D_L08_00161C9C * 0.017453292f * D_0015ED6C); - vars->f64 = fast_add_rotations(vars->f64, D_L08_00161CA0 * 0.017453292f * D_0015ED6C); + vars->f60 = fast_add_rotations_c4(vars->f60, D_L08_00161C9C * 0.017453292f * frame_time); + vars->f64 = fast_add_rotations_c4(vars->f64, D_L08_00161CA0_gp * 0.017453292f * frame_time); break; } - FUN_L08_002e4e90_3870((char *)moby, (float *)&moby->pos, (float *)&moby->rot); + FUN_L08_002e4e90_c((char *)moby, (float *)&moby->pos, (float *)&moby->rot); if (vars->s6C != 0) { - vars->f74 = fast_add_rotations(vars->f74, D_0015ED6C * 5.2359877f); + vars->f74 = fast_add_rotations_c4(vars->f74, frame_time * 5.2359877f); if (vars->u70.i > 12) { vars->u78.i += 0x5000000; } else { @@ -2142,14 +2123,14 @@ void FUN_L08_002e3870(Moby *moby) { } if (tick_countdown_32_alt(&vars->u70.i) != 0) { vars->s6C = 0; - vars->u70.i = truncate_float_to_s32(random_float_between((float)scale_game_frames_alt(300), (float)scale_game_frames_alt(600))); + vars->u70.i = truncate_float_to_s32_c5(random_float_between_c5((float)scale_game_frames_c(300), (float)scale_game_frames_c(600))); } else if (moby->visible != 0 && D_L08_00161CC8 != 0) { - func_001F49B0_2E16A0(FUN_L08_002e5188_3870, moby); + func_001F49B0_2E16A0(FUN_L08_002e5188_c, moby); return; } } else if (tick_countdown_32_alt(&vars->u70.i) != 0) { vars->u70.i = 24; - vars->f74 = random_angle_radians(); + vars->f74 = random_angle_radians_c2(); vars->s6C = 1; } break; @@ -2158,37 +2139,38 @@ void FUN_L08_002e3870(Moby *moby) { Vars_4BE8 *vars = (Vars_4BE8 *)moby->pvars; euler_rotation_matrix(scratch, vars->v10); - qcopy(dir, scratch + 8); + qcopy(direction, scratch + 8); if (tick_countdown_32_alt(&vars->timer) != 0) { Vars_4BE8 *vars = (Vars_4BE8 *)moby->pvars; float deg_to_rad = 0.017453292f; + char *hero_pos = D_0013F3D0; - subtract_vector_xyz(point, &moby->pos, ((char *)&D_0013F3D0)); - normalize_vector_xyz(point, point, 1.0f); - cross_vectors_xyz(point, dir, point); - FUN_L08_0026a0f8(vars, point, D_L08_00161C94 * deg_to_rad * D_0015ED6C); + subtract_vector_xyz(point, &moby->pos, hero_pos); + fast_vec_normalize_c2(point, point, 1.0f); + cross_vectors_xyz(point, direction, point); + FUN_L08_0026a0f8(vars, point, D_L08_00161C94_gp * deg_to_rad * frame_time); moby->flags |= 0x100; - normalize_vector_xyz(vars->velocity, dir, D_0015ED6C * 8.0f); + fast_vec_normalize_c2(vars->velocity, direction, frame_time * 8.0f); vars->f74 = 0.0f; - vars->u70.f = D_0015ED6C * 8.0f; - vars->u78.p = *(char **)((char *)&D_0013F3D0 + 0x2000); + vars->u70.f = frame_time * 8.0f; + vars->u78.p = *(char **)(hero_pos + 0x2000); vars->u7C.f = 0.5f; - if (D_L08_00161CD4 + scale_game_frames_alt(3) < D_L08_0015F5CC) { - D_L08_00161CD4 = D_L08_0015F5CC; - allocate_voice_for_target_entry_alt(0, 0x20, moby); + if (D_L08_00161CD4_gp + scale_game_frames_c(3) < D_L08_0015F5CC) { + D_L08_00161CD4_gp = D_L08_0015F5CC; + allocate_voice_for_target_entry(0, 0x20, moby); vars->f64 = 0.0f; } else { - vars->f64 = random_float_between(-30.0f, 30.0f) * deg_to_rad; + vars->f64 = random_float_between_c5(-30.0f, 30.0f) * deg_to_rad; } moby->state = 3; } else { - if (scale_game_frames_alt(10) < vars->timer) { - float goal_yaw = fast_add_rotations(vars->f60, fast_sin((float)(vars->timer % 8 - 4) * 0.7854f) * 0.17453292f); + if (scale_game_frames_c(10) < vars->timer) { + float goal_yaw = fast_add_rotations_c4(vars->f60, fast_sin((float)(vars->timer % 8 - 4) * 0.7854f) * 0.17453292f); FUN_L00_0025bc00(&vars->f60, goal_yaw, 0.5235988f, 0); } else { - float goal_yaw = fast_add_rotations(FUN_001f9e90(((Hero *)(((char *)D_0013F350)))->motion.pos.f[0] - moby->pos.x, - ((Hero *)(((char *)D_0013F350)))->motion.pos.f[1] - moby->pos.y), + float goal_yaw = fast_add_rotations_c4(fast_arc_tan(hero.motion.pos.f[0] - moby->pos.x, + hero.motion.pos.f[1] - moby->pos.y), 1.5707964f); FUN_L00_0025bc00(&vars->f60, goal_yaw, 0.08726646f, 0); @@ -2196,7 +2178,7 @@ void FUN_L08_002e3870(Moby *moby) { vars->timer = 0; } } - FUN_L08_002e4e90_3870((char *)moby, (float *)&moby->pos, (float *)&moby->rot); + FUN_L08_002e4e90_c((char *)moby, (float *)&moby->pos, (float *)&moby->rot); } break; } @@ -2208,47 +2190,48 @@ void FUN_L08_002e3870(Moby *moby) { if (vars->u78.p == 0) { break; } - normalize_vector_xyz(point, vars->u78.p + 0xE0, vars->u7C.f); + fast_vec_normalize_c2(point, vars->u78.p + 0xE0, vars->u7C.f); add_vector_xyz(point, point, vars->u78.p + 0x10); - subtract_vector_xyz(dir, point, &moby->pos); + subtract_vector_xyz(direction, point, &moby->pos); if (vars->f64 != 0.0f) { float sine = fast_sin(vars->f64); float cosine = fast_cos(vars->f64); - dir[0] = cosine * dir[0] + sine * dir[1]; - dir[1] = cosine * dir[1] - sine * dir[0]; + direction[0] = cosine * direction[0] + sine * direction[1]; + direction[1] = cosine * direction[1] - sine * direction[0]; } - dist = distance_xyz(point, &moby->pos); - normalize_vector_xyz(vars->velocity, vars->velocity, vars->u70.f); + dist = fast_vec_dist(point, &moby->pos); + fast_vec_normalize_c2(vars->velocity, vars->velocity, vars->u70.f); add_vector_xyz(&moby->pos, &moby->pos, vars->velocity); - normalize_vector_xyz(dir, dir, vars->f74); - add_vector_xyz(&moby->pos, &moby->pos, dir); - add_vector_xyz(&moby->pos, &moby->pos, ((char *)&D_0013F490)); - subtract_vector_xyz(local, &moby->pos, ((char *)&D_0013F490 + 0x160)); - transform_vector(local, local, ((char *)&D_0013F490 - 0x100)); - if (((Moby *)vars->u78.p)->oclass != 0 || local[2] > 0.0f) { - func_00214D28_2E16A0(&vars->u70.f, 0.0f, D_L08_00161C8C * D_0015ED70); - func_00214D28_2E16A0(&vars->f74, D_L08_00161C88 * D_0015ED6C, D_L08_00161C8C * D_0015ED70); + fast_vec_normalize_c2(direction, direction, vars->f74); + add_vector_xyz(&moby->pos, &moby->pos, direction); + cam = D_0013F490; + add_vector_xyz(&moby->pos, &moby->pos, cam); + subtract_vector_xyz(local, &moby->pos, cam + 0x160); + transform_vector(local, local, cam - 0x100); + if (((struct Moby *)vars->u78.p)->oclass != 0 || local[2] > 0.0f) { + func_00214D28_2E16A0(&vars->u70.f, 0.0f, D_L08_00161C8C_gp * frame_time_sq); + func_00214D28_2E16A0(&vars->f74, D_L08_00161C88_gp * frame_time, D_L08_00161C8C_gp * frame_time_sq); } else { - normalize_vector_xyz(scratch, ((char *)&D_0013F490 - 0x120), vars->u70.f); + fast_vec_normalize_c2(scratch, cam - 0x120, vars->u70.f); subtract_vector_xyz(scratch + 4, scratch, vars->velocity); - FUN_L00_0025f730(scratch + 4, D_L08_00161C8C * D_0015ED70); + FUN_L00_0025f730_c(scratch + 4, D_L08_00161C8C_gp * frame_time_sq); add_vector_xyz(vars->velocity, vars->velocity, scratch + 4); } if (dist < vars->f74) { vars->f74 = dist; } - fade_range = vars->f74 * (float)scale_game_frames_alt(20); + fade_range = vars->f74 * (float)scale_game_frames_c(20); if (dist < fade_range) { - if (distance_xyz(point, &moby->pos) > 0.52f) { + if (fast_vec_dist(point, &moby->pos) > 0.52f) { if (D_L08_00161CC0 != 0) { - moby->alpha = (distance_xyz(point, &moby->pos) + fade_range) * 128.0f / (fade_range + fade_range); + moby->alpha = (fast_vec_dist(point, &moby->pos) + fade_range) * 128.0f / (fade_range + fade_range); } - if (D_L08_00161CC4 != 0) { - moby->scale = moby->pclass->scale * *(float *)&D_L08_00161CB4 * (distance_xyz(point, &moby->pos) + fade_range) / (fade_range + fade_range); + if (D_L08_00161CC4_gp != 0) { + moby->scale = moby->pclass->scale * D_L08_00161CB4_gp * (fast_vec_dist(point, &moby->pos) + fade_range) / (fade_range + fade_range); } } else { - int bolts; + int value; int spin; float shrink; float size; @@ -2258,59 +2241,56 @@ void FUN_L08_002e3870(Moby *moby) { case 0x305: { int i; int j; - int collected; + int n; - D_0014BEC0[D_0015ED84][moby->command] = 1; - collected = 0; + D_0014BEC0[current_level_index][moby->command] = 1; + n = 0; for (i = 0; i < 20; i++) { for (j = 0; j < 4; j++) { if (D_0014BEC0[i][j] != 0) { - collected++; + n++; } } } - bolts = collected * 100; + value = n * 100; break; } case 0x3DD: - bolts = 10; + value = 10; break; case 0x3DC: - bolts = 5; + value = 5; break; default: - bolts = 1; + value = 1; break; } shrink = 0.7f; - FUN_L00_00257d78(scratch, D_0015ED6C * shrink, D_0015ED6C); - scale_vector_xyz(scratch + 4, scratch, 10.0f); + FUN_L00_00257d78(scratch, frame_time * shrink, frame_time); + fast_vec_scale_c(scratch + 4, scratch, 10.0f); add_vector_xyz(scratch + 4, scratch + 4, &moby->pos); - spin = random_integer_below(2); + spin = random_integer_below_c2(2); if (spin == 0) { spin--; } - size = random_float_between(0.4f, 0.5f); - FUN_L00_00272060(scratch + 4, scale_game_frames_alt(0x19), size * 0.2f, size, 0x7F207F7F, 0, spin, scratch, 0.0f); + size = random_float_between_c5(0.4f, 0.5f); + FUN_L00_00272060(scratch + 4, scale_game_frames_c(0x19), size * 0.2f, size, 0x7F207F7F, 0, spin, scratch, 0.0f); spin = -spin; - FUN_L00_00272060(scratch + 4, scale_game_frames_alt(0x19), size * 0.14f, size * shrink, 0x7F7F7F7F, 1, spin, scratch, 0.0f); + FUN_L00_00272060(scratch + 4, scale_game_frames_c(0x19), size * 0.14f, size * shrink, 0x7F7F7F7F, 1, spin, scratch, 0.0f); source = moby->parent; if (source && !(source->id & 0x80)) { - D_0014D590[D_0015ED84][source->id].bolts += bolts; - } - { - void *f0 = func_L00_0023A658_4BE8, *f1 = func_L00_0023A690_4BE8, *f2 = func_L00_0023A788_4BE8; - D_0015ED98 += bolts; - D_0013DF38[D_0015ED84] += bolts; - queue_animation_update_alt(2, 0x754E, f0, f1, f2, &D_0015ED98, 9999999); + D_0014D590[current_level_index][source->id].bolts += value; } + D_0015ED98 += value; + level_bolts[current_level_index] += value; + queue_animation_update_alt(2, 0x754E, func_L00_0023A658_4BE8, func_L00_0023A690_4BE8, func_L00_0023A788_4BE8, &D_0015ED98, 9999999); if (moby < D_L08_0015FFDC) { D_L08_001BADD0.killed[(short)moby->save_id] = moby->mission + 2; - if (moby->mission == 0xFF || (D_L08_0015FC88[moby->mission] != 0xFF && D_0014C050_4BE8[D_0015ED84][moby->mission] == 0xFF)) { + if (moby->mission == 0xFF || (D_L08_0015FC88_macro[moby->mission] != 0xFF && D_0014C050[moby->mission + current_level_index * 16] == 0xFF)) { D_L08_001BBA30.killed[(short)moby->save_id] = moby->mission + 2; } } - mark_moby_for_removal(moby); + mark_moby_for_removal_c3(moby); return; } } @@ -2321,84 +2301,84 @@ void FUN_L08_002e3870(Moby *moby) { Vars_4BE8 *vars = (Vars_4BE8 *)moby->pvars; add_vector_xyz(&moby->pos, &moby->pos, vars->velocity); - vars->velocity[2] -= D_0015ED70 * 10.8f; + vars->velocity[2] -= frame_time_sq * 10.8f; multiply_matrix_basis_columns(&moby->rot_row0, vars, &moby->rot_row0); if (moby->pos.z < 2.0f || moby->pos.x > 510.0f || moby->pos.x < 2.0f || moby->pos.y > 510.0f || moby->pos.y < 2.0f) { - int bolts; + int value; BoltSource_4BE8 *source; switch (moby->oclass) { case 0x3DD: - bolts = 10; + value = 10; break; case 0x3DC: - bolts = 5; + value = 5; break; default: - bolts = 1; + value = 1; break; } source = moby->parent; if (source && !(source->id & 0x80)) { - D_0014D590[D_0015ED84][source->id].bolts += bolts; + D_0014D590[current_level_index][source->id].bolts += value; } - D_0015ED98 += bolts; - D_0013DF38[D_0015ED84] += bolts; - mark_moby_for_removal(moby); + D_0015ED98 += value; + level_bolts[current_level_index] += value; + mark_moby_for_removal_c3(moby); return; } - if (moby->pos.z < vars->f60 - 4.0f && moby->pos.z < ((Hero *)(((char *)D_0013F350)))->motion.pos.f[2] - 4.0f) { + if (moby->pos.z < vars->f60 - 4.0f && moby->pos.z < hero.motion.pos.f[2] - 4.0f) { Vars_4BE8 *vars = (Vars_4BE8 *)moby->pvars; - *(u128_4BE8 *)vars->v10 = *(u128_4BE8 *)((char *)D_0013F350 + 0x90); - vars->timer = scale_game_frames_alt(1); + *(u128_4BE8_p *)vars->v10 = *(u128_4BE8_p *)((char *)&hero + 0x90); + vars->timer = scale_game_frames_c(1); moby->state = 2; break; } if (FUN_L00_001f0d60(0.25f, &moby->pos, 0x22, moby) != 0) { - subtract_vector_xyz(dir, &moby->pos, D_L08_00174640.pos); - FUN_L00_001ff660(vars->velocity, vars->velocity, dir); - if (FUN_001f9e90(dir[2], func_001F9CE8_2E16A0(dir)) < 0.7853982f - && FUN_001f9e90(D_L08_00174640.n[2], func_001F9CE8_2E16A0(D_L08_00174640.n)) < 0.7853982f) { - Coll_4BE8 *hit = &D_L08_00174640; + subtract_vector_xyz(direction, &moby->pos, ((CollPos_4BE8 *)D_L08_00174660)->pos); + FUN_L00_001ff660(vars->velocity, vars->velocity, direction); + if (fast_arc_tan(direction[2], func_001F9CE8_2E16A0(direction)) < 0.7853982f + && fast_arc_tan(((Coll_4BE8 *)((char *)D_L08_00174660 - 0x20))->n[2], func_001F9CE8_2E16A0(((CollPos_4BE8 *)D_L08_00174660)->n)) < 0.7853982f) { + Coll_4BE8 *coll = (Coll_4BE8 *)((char *)D_L08_00174660 - 0x20); int frames; float per_frame; moby->flags &= ~0x100; vars = (Vars_4BE8 *)moby->pvars; - frames = truncate_float_to_s32(multiply_global_factor_ed64(D_L08_00161CD0 + random_float_between(-10.0f, 10.0f))); + frames = truncate_float_to_s32_c5(FUN_001f96b0(D_L08_00161CD0_gp + random_float_between_c5(-10.0f, 10.0f))); per_frame = 1.0f / convert_integer_to_float(frames); - qcopy(vars->v0, hit->pos); + qcopy(vars->anchor, coll->pos); matrix_to_euler(&moby->rot_row0, &moby->rot); - normalize_vector_xyz(dir, hit->n, 1.0f); - FUN_L08_002e4db8_3870((char *)moby, dir); - vars->f60 = random_angle_radians(); - vars->f64 = random_angle_radians(); - FUN_L08_002e4e90_3870((char *)moby, vars->v20, vars->v30); + fast_vec_normalize_c2(direction, coll->n, 1.0f); + FUN_L08_002e4db8_c((char *)moby, direction); + vars->f60 = random_angle_radians_c2(); + vars->f64 = random_angle_radians_c2(); + FUN_L08_002e4e90_c((char *)moby, vars->v20, vars->v30); subtract_vector_xyz(vars->velocity, vars->v20, &moby->pos); - scale_vector_xyz(vars->velocity, vars->velocity, per_frame); - if (hit->moby != 0) { - unsigned char *carrier = FUN_L00_002603d0(hit->moby); + fast_vec_scale_c(vars->velocity, vars->velocity, per_frame); + if (coll->moby != 0) { + unsigned char *carrier = FUN_L00_002603d0(coll->moby); if (carrier != 0) { add_vector_xyz(vars->velocity, vars->velocity, carrier + 0x10); - scale_vector_xyz(point, carrier + 0x10, convert_integer_to_float(frames)); + fast_vec_scale_c(point, carrier + 0x10, convert_integer_to_float(frames)); add_vector_xyz(vars->v20, vars->v20, point); - add_vector_xyz(vars->v0, vars->v0, point); + add_vector_xyz(vars->anchor, vars->anchor, point); } } - vars->velocity[2] += D_0015ED70 * 10.8f * (float)(frames >> 1); - vars->spin_x = fast_subtract_rotations(vars->v30[0], moby->rot.x) * per_frame; - vars->spin_y = fast_subtract_rotations(vars->v30[1], moby->rot.y) * per_frame; - vars->spin_z = fast_subtract_rotations(vars->v30[2], moby->rot.z) * per_frame; + vars->velocity[2] += frame_time_sq * 10.8f * (float)(frames >> 1); + vars->spin_x = fast_subtract_rotations_c2(vars->v30[0], moby->rot.x) * per_frame; + vars->spin_y = fast_subtract_rotations_c2(vars->v30[1], moby->rot.y) * per_frame; + vars->spin_z = fast_subtract_rotations_c2(vars->v30[2], moby->rot.z) * per_frame; moby->state = 5; vars->timer = frames; vars->u7C.i = D_L08_00174658_lui; - if (absolute_float(moby->pos.z - ((Hero *)(((char *)D_0013F350)))->motion.pos.f[2]) < ((Hero *)(((char *)D_0013F350)))->reach_distance - && FUN_001f9b80(&moby->pos, ((Hero *)(((char *)D_0013F350)))->motion.pos.f) < ((Hero *)(((char *)D_0013F350)))->reach_height) { + if (absolute_float(moby->pos.z - hero.motion.pos.f[2]) < hero.reach_distance + && vector_distance_xy_alt(&moby->pos, hero.motion.pos.f) < hero.reach_height) { Vars_4BE8 *vars = (Vars_4BE8 *)moby->pvars; - vars->timer = scale_game_frames_alt(1); + vars->timer = scale_game_frames_c(1); moby->state = 2; } } @@ -2408,18 +2388,18 @@ void FUN_L08_002e3870(Moby *moby) { case 5: { Vars_4BE8 *vars = (Vars_4BE8 *)moby->pvars; - moby->rot.x = fast_add_rotations(moby->rot.x, vars->spin_x); - moby->rot.y = fast_add_rotations(moby->rot.y, vars->spin_y); - moby->rot.z = fast_add_rotations(moby->rot.z, vars->spin_z); + moby->rot.x = fast_add_rotations_c4(moby->rot.x, vars->spin_x); + moby->rot.y = fast_add_rotations_c4(moby->rot.y, vars->spin_y); + moby->rot.z = fast_add_rotations_c4(moby->rot.z, vars->spin_z); add_vector_xyz(&moby->pos, &moby->pos, vars->velocity); - vars->velocity[2] -= D_0015ED70 * 10.8f; + vars->velocity[2] -= frame_time_sq * 10.8f; if (tick_countdown_32_alt(&vars->timer) != 0) { int frames; float per_frame; - if (absolute_float(moby->pos.z - ((Hero *)(((char *)D_0013F350)))->motion.pos.f[2]) < ((Hero *)(((char *)D_0013F350)))->reach_distance - && FUN_001f9b80(&moby->pos, ((Hero *)(((char *)D_0013F350)))->motion.pos.f) < ((Hero *)(((char *)D_0013F350)))->reach_height) { - vars->timer = scale_game_frames_alt(1); + if (absolute_float(moby->pos.z - hero.motion.pos.f[2]) < hero.reach_distance + && vector_distance_xy_alt(&moby->pos, hero.motion.pos.f) < hero.reach_height) { + vars->timer = scale_game_frames_c(1); moby->state = 2; break; } @@ -2428,39 +2408,38 @@ void FUN_L08_002e3870(Moby *moby) { if (vars->u7C.i != 0) { Vars_4BE8 *vars = (Vars_4BE8 *)moby->pvars; - FUN_L00_00260668(moby, vars->u7C.i, vars->v0, vars->v10, vars->v20, vars->v30); + FUN_L00_00260668(moby, vars->u7C.i, vars->anchor, vars->v10, vars->v20, vars->v30); } else { qcopy(&moby->pos, vars->v20); qcopy(&moby->rot, vars->v30); } break; } - frames = truncate_float_to_s32((float)scale_game_frames_alt(20)); + frames = truncate_float_to_s32_c5((float)scale_game_frames_c(20)); per_frame = 1.0f / convert_integer_to_float(frames); moby->command++; - vars->spin_x = fast_subtract_rotations(vars->v30[0], moby->rot.x) * per_frame; - vars->spin_y = fast_subtract_rotations(vars->v30[1], moby->rot.y) * per_frame; - vars->spin_z = fast_subtract_rotations(vars->v30[2], moby->rot.z) * per_frame; + vars->spin_x = fast_subtract_rotations_c2(vars->v30[0], moby->rot.x) * per_frame; + vars->spin_y = fast_subtract_rotations_c2(vars->v30[1], moby->rot.y) * per_frame; + vars->spin_z = fast_subtract_rotations_c2(vars->v30[2], moby->rot.z) * per_frame; subtract_vector_xyz(vars->velocity, vars->v20, &moby->pos); - scale_vector_xyz(vars->velocity, vars->velocity, per_frame); + fast_vec_scale_c(vars->velocity, vars->velocity, per_frame); vars->timer = frames; if (vars->u7C.i != 0) { unsigned char *carrier = FUN_L00_002603d0(vars->u7C.i); if (carrier != 0) { add_vector_xyz(vars->velocity, vars->velocity, carrier + 0x10); - scale_vector_xyz(dir, carrier + 0x10, convert_integer_to_float(frames)); - add_vector_xyz(vars->v20, vars->v20, dir); - add_vector_xyz(vars->v0, vars->v0, dir); + fast_vec_scale_c(direction, carrier + 0x10, convert_integer_to_float(frames)); + add_vector_xyz(vars->v20, vars->v20, direction); + add_vector_xyz(vars->anchor, vars->anchor, direction); } } - vars->velocity[2] += D_0015ED70 * 10.8f * (float)(frames >> 1); + vars->velocity[2] += frame_time_sq * 10.8f * (float)(frames >> 1); } break; } } } -#endif #include "qcopy.h" @@ -2470,18 +2449,18 @@ void FUN_L08_002e3870(Moby *moby) { extern f32 fast_cos(f32) __asm__("func_001F9DC8"); extern f32 fast_sin(f32) __asm__("func_001F9DE0"); -extern short D_L08_00161C64 __attribute__((sda)); -extern short D_L08_00161C7C __attribute__((sda)); -extern short D_L08_00161C80 __attribute__((sda)); -extern short D_L08_00161C78 __attribute__((sda)); -extern short D_L08_00161CB8 __attribute__((sda)); -extern short D_L08_00161CBC __attribute__((sda)); -extern short D_L08_00161C84 __attribute__((sda)); -extern short D_L08_00161C68 __attribute__((sda)); -extern short D_L08_00161C6C __attribute__((sda)); -extern short D_L08_00161CB4 __attribute__((sda)); -extern short D_L08_00161C70 __attribute__((sda)); -extern short D_L08_00161C74 __attribute__((sda)); +extern float D_L08_00161C64 __attribute__((sda)); +extern float D_L08_00161C7C __attribute__((sda)); +extern float D_L08_00161C80 __attribute__((sda)); +extern float D_L08_00161C78 __attribute__((sda)); +extern float D_L08_00161CB8 __attribute__((sda)); +extern float D_L08_00161CBC __attribute__((sda)); +extern float D_L08_00161C84 __attribute__((sda)); +extern float D_L08_00161C68 __attribute__((sda)); +extern float D_L08_00161C6C __attribute__((sda)); +extern float D_L08_00161CB4 __attribute__((sda)); +extern float D_L08_00161C70 __attribute__((sda)); +extern float D_L08_00161C74 __attribute__((sda)); extern void euler_rotation_matrix(float *, float *) __asm__("FUN_001fa050"); extern void matrix_to_euler(void *, void *) __asm__("FUN_00214598"); extern void add_vector_xyz(void *, void *, void *) __asm__("FUN_001f9a10"); @@ -2503,19 +2482,19 @@ void FUN_L08_002e4e90(struct Moby *moby, float *out, float *rot) { float t; switch (moby->oclass) { case 0x3DC: - sx = *(float *)&D_L08_00161C68 * *(float *)&D_L08_00161CB8; - sy = *(float *)&D_L08_00161C74 * *(float *)&D_L08_00161CB8; - sz = *(float *)&D_L08_00161C80 * *(float *)&D_L08_00161CB8; + sx = D_L08_00161C68 * D_L08_00161CB8; + sy = D_L08_00161C74 * D_L08_00161CB8; + sz = D_L08_00161C80 * D_L08_00161CB8; break; case 0x3DD: - sx = *(float *)&D_L08_00161C6C * *(float *)&D_L08_00161CBC; - sy = *(float *)&D_L08_00161C78 * *(float *)&D_L08_00161CBC; - sz = *(float *)&D_L08_00161C84 * *(float *)&D_L08_00161CBC; + sx = D_L08_00161C6C * D_L08_00161CBC; + sy = D_L08_00161C78 * D_L08_00161CBC; + sz = D_L08_00161C84 * D_L08_00161CBC; break; default: - sx = *(float *)&D_L08_00161C64 * *(float *)&D_L08_00161CB4; - sy = *(float *)&D_L08_00161C70 * *(float *)&D_L08_00161CB4; - sz = *(float *)&D_L08_00161C7C * *(float *)&D_L08_00161CB4; + sx = D_L08_00161C64 * D_L08_00161CB4; + sy = D_L08_00161C70 * D_L08_00161CB4; + sz = D_L08_00161C7C * D_L08_00161CB4; break; } euler_rotation_matrix(b, (float *)(data + 0x10)); diff --git a/src/overlays/l08/gameplay/entities/bomb.c b/src/overlays/l08/gameplay/entities/bomb.c index b4971eec99..bf2ca6eda6 100644 --- a/src/overlays/l08/gameplay/entities/bomb.c +++ b/src/overlays/l08/gameplay/entities/bomb.c @@ -16,11 +16,11 @@ extern float random_float_between(float, float) __asm__("FUN_002132a8"); extern int FUN_L08_00279f00(char *); extern void FUN_L00_0025d1b8(void *); -extern short D_L08_00161468 __attribute__((sda)); -extern short D_L08_0016146C __attribute__((sda)); +extern float D_L08_00161468 __attribute__((sda)); +extern float D_L08_0016146C __attribute__((sda)); void FUN_L08_002b8228(struct Moby *moby) { - float a = *(float *)&D_L08_00161468; - float b = *(float *)&D_L08_0016146C; + float a = D_L08_00161468; + float b = D_L08_0016146C; char *d; moby->rot.x = 0.0f; moby->rot.y = 0.5235988f; @@ -121,7 +121,6 @@ extern void func_L00_0023A788_2B94B0(void) __asm__("FUN_L00_00239df8"); extern char D_L08_001746D8_2B94B0[] __asm__("D_L08_00174658"); extern int D_L08_001746D8_2B94B0i __asm__("D_L08_00174658") __attribute__((section(".data"))); extern char D_L08_00174700_2B94B0[] __asm__("D_L08_00174680"); -extern char D_0013F350[]; extern s32 D_0013DF38_arr[] __asm__("D_0013DF38"); void FUN_L08_002b82a0(Moby_2B94B0 *m) @@ -186,12 +185,12 @@ void FUN_L08_002b82a0(Moby_2B94B0 *m) case 2: hit = 0; m->f48 = func_001FA748_2B94B0(m->f48, d->fC); - if (((Hero_2B94B0 *)D_0013F350)->f208C == 15) { - if (vector_distance(((Hero_2B94B0 *)D_0013F350)->v510, m->pos) < 0.5f) hit = 1; - if (vector_distance(((Hero_2B94B0 *)D_0013F350)->v520, m->pos) < 0.5f) hit = 1; - if (vector_distance(((Hero_2B94B0 *)D_0013F350)->v530, m->pos) < 0.5f) hit = 1; - } else if (vector_distance(m->pos, ((Hero_2B94B0 *)D_0013F350)->pos) < ((Hero_2B94B0 *)D_0013F350)->f2288) { - if (absolute_float(m->pos[2] - ((Hero_2B94B0 *)D_0013F350)->pos[2]) < ((Hero_2B94B0 *)D_0013F350)->f228C) hit = 1; + if (((Hero_2B94B0 *)((char *)&hero))->f208C == 15) { + if (vector_distance(((Hero_2B94B0 *)((char *)&hero))->v510, m->pos) < 0.5f) hit = 1; + if (vector_distance(((Hero_2B94B0 *)((char *)&hero))->v520, m->pos) < 0.5f) hit = 1; + if (vector_distance(((Hero_2B94B0 *)((char *)&hero))->v530, m->pos) < 0.5f) hit = 1; + } else if (vector_distance(m->pos, ((Hero_2B94B0 *)((char *)&hero))->pos) < ((Hero_2B94B0 *)((char *)&hero))->f2288) { + if (absolute_float(m->pos[2] - ((Hero_2B94B0 *)((char *)&hero))->pos[2]) < ((Hero_2B94B0 *)((char *)&hero))->f228C) hit = 1; } if (hit == 0) break; if (d->target != 0) d->target->fA = 0; @@ -294,7 +293,7 @@ extern int allocate_voice_for_target_entry(int, int, void *) __asm__("FUN_0022da extern int tick_countdown_32_alt(void *) __asm__("FUN_001f9740"); extern s32 random_integer_below_c3(s32) __asm__("func_00213260"); extern s32 scale_game_frames_c(s32) __asm__("func_001F96F8"); -extern short D_L08_00161860 __attribute__((sda)); +extern float D_L08_00161860 __attribute__((sda)); extern void FUN_L00_001ff660_c(void *, void *, void *) __asm__("FUN_L00_001ff660"); extern void FUN_L00_00259fe8(void *, float); extern void FUN_L00_0025d458_c(void *, short *) __asm__("FUN_L00_0025d458"); @@ -359,7 +358,7 @@ void FUN_L08_002d23f0(char *moby) { f20 = 0.16f; c.r.start[2] -= f20; add_vector_xyz((moby + 0x10), (moby + 0x10), (d + 0x10)); - *(float *)(d + 0x18) -= *(float *)&D_L08_00161860 * D_0015ED70_gp; + *(float *)(d + 0x18) -= D_L08_00161860 * D_0015ED70_gp; qcopy(c.r.end, moby + 0x10); c.r.end[2] -= f20; c.r.x.moby = moby; @@ -720,7 +719,7 @@ extern f32 vector_length_xy(void *) __asm__("FUN_001f9b20"); extern float D_0015ED6C; extern int D_L08_001B0CB0[]; extern int multiply_quaternions() __asm__("FUN_001fa3c0"); -extern int fun_00213928() __asm__("FUN_00213928"); +extern s32 fun_00213928(void *, void *, void *, u32, s32 *, f32 *, s32 *, s32) __asm__("FUN_00213928"); extern int FUN_L00_001fff28(); extern int allocate_voice_for_target_entry_alt(int,int,void*) __asm__("FUN_0022da68"); extern int scale_game_frames_alt(int) __asm__("FUN_001f96f8"); @@ -1455,317 +1454,415 @@ char *FUN_L08_002daa10(struct Moby *moby) { p = D_L08_0015FFD8 + (idx << 8); } } -#ifndef NON_MATCHING -INCLUDE_ASM("config/us/overlays/asm/FUN_L08_002dabf0.s", FUN_L08_002dabf0); -#else -#include "rnc/data_labels.h" -#include "rnc/overlay/quad.h" -extern void FUN_L08_0026dae0(void *, int, void *, float); -extern void FUN_L08_00264650(void *); -extern void FUN_L08_002da8d8(void *); -extern void FUN_L08_002649a8(void *, void *, void *, int, int *, float *, int, int); -extern void FUN_L08_00266a48(float, void *, void *, int, int, int); -extern void FUN_L08_00261970(void *, int, int); -extern void FUN_L08_00267948(void *, void *); -extern void FUN_L08_00267a28(void *, void *); -extern int FUN_L08_0026a3d0(float, void *, void *); -extern void FUN_L08_00263050(void *); -extern int FUN_L08_002635a0(void *, void *, void *, void *); -extern void FUN_L08_00262778(float, float, float, float, void *, void *); -extern void FUN_L08_00269c20(float, void *); -extern float FUN_L08_00265120(void *, void *, void *, float, float); -extern int FUN_L08_00266b88(void *, void *); -extern float FUN_L08_002592c8(void *); -extern char D_0013F3D0[] __attribute__((section(".data"))); -extern int FUN_001f9740(int *); -extern float FUN_L08_00211a20(float); -extern void set_vector_length_xy(void *, void *, float) __asm__("FUN_001f9c48"); +/* Update function of the blarg bomb thrower: hit reactions, then a state machine that walks to its bomb crate, picks up and throws bombs at the hero. */ +/* Ported from rac1-decomp (src/overlays/l08_batalia/vendor_002B9438.c: func_L08_002DBF68), where it is exact; names translated to the US level program. */ + +typedef struct { char pad0[0x20]; struct Moby *moby; } Hit_2D5FA8_c; + +typedef struct { char pad0[0x140]; float x, y; char pad148[0x10]; float f158; } Cam_DBF68; + +typedef struct { char pad0[0x40]; struct Moby *target; int result; } Look_DBF68; + +typedef struct { + char pad0[0x20]; + float health; + char pad24[5]; + unsigned char b29; + char pad2A[0xE]; + int i38; + char pad3C[4]; + float v40[4]; + char pad50[8]; + unsigned char b58; + char pad59; + unsigned char b5A; + char pad5B[5]; + short anim[3]; + char pad66; + unsigned char tint; + char pad68[8]; + char blk70[0x10]; + float f80, f84, f88, f8C; + int pad90; + int i94; + char pad98[0x15]; + unsigned char bAD; + char padAE[0x12]; + float fC0, fC4; + char padC8[8]; + char blkD0[8]; + float fD8, fDC; + char padE0[0x14]; + float fF4; + char padF8[0x14]; + float f10C, f110, f114; + char pad118[8]; + struct Moby *waypoint; + struct Moby *p124; + int i128; + char blk12C[4]; + short s130, s132; + int i134; + char pad138[0x28]; + char blk160[0x10]; +} Data_DBF68; + +typedef struct { char pad0[0x140]; float x,y,z,w; } Camera46_c; + +char *FUN_L08_002d22e0_c(int arg, char *pos, char *vec) __asm__("FUN_L08_002d22e0"); +char *FUN_L08_002daa10_c(struct Moby *moby) __asm__("FUN_L08_002daa10"); +extern f32 convert_integer_to_float_c(s32) __asm__("func_001FA6C0"); +extern f32 fast_arc_tan_c2(f32, f32) __asm__("func_001F9E90"); +extern f32 fast_cos_c4(f32) __asm__("func_001F9DC8"); +extern f32 fast_vec_length_c2(void *) __asm__("func_001F9AF0"); +extern float D_L08_00161978_gp __asm__("D_L08_00161978") __attribute__((sda)); +extern float D_L08_0016197C_gp __asm__("D_L08_0016197C") __attribute__((sda)); +extern float D_L08_00161988_gp __asm__("D_L08_00161988") __attribute__((sda)); +extern float D_L08_0016198C_gp __asm__("D_L08_0016198C") __attribute__((sda)); +extern float D_L08_00161990_gp __asm__("D_L08_00161990") __attribute__((sda)); +extern float D_L08_001675C0[]; +extern float FUN_001f96b0(float); +extern float FUN_L00_0025abf0(void *, void *, void *, float, float); +extern float fast_difference_between_rotations_c3(float, float) __asm__("func_001FA688"); +extern float fast_vec_dist(void *, void *); +extern float vector_distance_xy_alt(void *, void *) __asm__("FUN_001f9b80"); +extern int D_L08_001619AC_gp __asm__("D_L08_001619AC") __attribute__((sda)); +extern int D_L08_001619D0_gp __asm__("D_L08_001619D0") __attribute__((sda)); +extern int FUN_L00_00259028(char *m, char *p, float *pos, char *v); +extern int FUN_L00_0025c698(void *, void *); +extern int FUN_L08_0026a3d0(void *, float, void *); +extern s32 scale_game_frames_c2(s32) __asm__("func_001F96F8"); +extern s32 truncate_float_to_s32_c4(f32) __asm__("func_001FA6D0"); +extern void FUN_L00_00258278(void*,void*,float,float,float,float); +extern void FUN_L00_0025a120(void *); +extern void FUN_L00_0025c558(void *, void *, float, int, int, int); +extern void FUN_L00_0025d458_c2(void *, short *) __asm__("FUN_L00_0025d458"); +extern void FUN_L00_0025d538_c2(void *, void *) __asm__("FUN_L00_0025d538"); +extern void FUN_L00_0025f730(void*,float); +extern void FUN_L01_0026d930(char *p); +extern void FUN_L04_002c46d0(void *); +extern void set_vector_length_xy(void *, void *, f32) __asm__("FUN_001f9c48"); +f32 compute_interpolated_record_value(void *anim) __asm__("FUN_0020c9e0"); +void FUN_L00_00257470(unsigned char *m, int flags, int arg); +void FUN_L00_00263ac8(float x, int a, int b, unsigned char *p); +extern Hit_2D5FA8_c *find_2D5FA8_c(struct Moby *, int, int) __asm__("FUN_L00_0025a420"); +extern int FUN_00213928(struct Moby *, Hit_2D5FA8_c *, float *, int, int *, float *, int, int); +extern void FUN_00212f90(struct Moby *, int, int, int); +extern void explode_2D5FA8_c(struct Moby *, int, int) __asm__("FUN_L00_00257470"); +extern void effects_start_2D5FA8_c(struct Moby *, short *) __asm__("FUN_L00_0025d458"); +extern void effects_update_2D5FA8_c(struct Moby *, short *) __asm__("FUN_L00_0025d538"); +extern void func_L00_00264B40_x(struct Moby *, int, float, char *) __asm__("FUN_L00_00263ac8"); +extern float FUN_0020c9e0(struct Moby *); +extern void func_L00_002592B0_x(float, void *, void *, float, float, float) __asm__("FUN_L00_00258278"); extern char camera_state_bytes[] __asm__("D_L08_00167480"); -extern float frame_time __attribute__((sda)); -extern int D_L08_001619B4 __attribute__((sda)); -extern float D_L08_00161978 __attribute__((sda)); -extern float D_L08_0016197C __attribute__((sda)); -extern float D_L08_00161988 __attribute__((sda)); -extern float D_L08_0016198C __attribute__((sda)); -extern float D_L08_00161990 __attribute__((sda)); -extern int D_L08_001619AC __attribute__((sda)); -extern int D_L08_001619D0 __attribute__((sda)); void FUN_L08_002dabf0(struct Moby *moby) { - char *d = (char *)moby->pvars; - struct { char pad[0x40]; struct Moby *target; int result; } search; - float point[4], velocity[4], aim[4]; - struct { int hit; float damage; float scratch[2]; } collision; + Data_DBF68 *vars = (Data_DBF68 *)moby->pvars; + Look_DBF68 search; + float point[4]; + float velocity[4]; + float aim[4]; + int hit; + float damage; + float scratch; struct Moby *target; - char *old; - char *next; - long hit_duration; - int one; - float distance, time, angle; - collision.damage = 0.0f; - FUN_L08_0026dae0(moby, D_L08_001619AC, d + 0x160, 3.0f); - if (moby->visible && FUN_001f9b48(&moby->pos, (camera_state_bytes + 0x140)) < 29.0f) { - FUN_L08_00264650(moby); - moby->shadow_range = 0x17; - } - if (moby->state == 3) moby->flags &= 0xfbff; - else moby->flags |= 0x400; + struct Moby *old_waypoint; + + damage = 0.0f; + func_L00_00264B40_x(moby, D_L08_001619AC_gp, 3.0f, vars->blk160); + if (moby->visible != 0) { + if (fast_vec_dist(&moby->pos, D_L08_001675C0) < 29.0f) { + FUN_L00_0025a120(moby); + moby->shadow_range = 0x17; + } + } + if (moby->state == 3) { + moby->flags &= 0xFBFF; + } else { + moby->flags |= 0x400; + } if (moby->state == 100) { - time = convert_integer_to_float(D_L08_001619D0); - moby->alpha = truncate_float_to_s32((float)*(short *)(d + 0x132) + - (float)-(int)*(short *)(d + 0x132) * ((float)(D_L08_001619D0 - *(short *)(d + 0x130)) / time)); - FUN_L08_002da8d8(moby); + float duration = convert_integer_to_float_c(D_L08_001619D0_gp); + int start_alpha = vars->s132; + moby->alpha = func_001FA898_2D6C58((float)start_alpha + (float)-start_alpha * ((float)(D_L08_001619D0_gp - vars->s130) / duration)); + FUN_L04_002c46d0(moby); return; } - FUN_L08_002649a8(moby, FUN_L00_0025a420(moby, 0x330000, 0), d + 0x20, 0, &collision.hit, &collision.damage, 0, 4); - if (collision.hit != 1 && moby->state != 99) { + FUN_00213928(moby, find_2D5FA8_c(moby, 0x330000, 0), &vars->health, 0, &hit, &damage, 0, 4); + if (hit != 1 && moby->state != 0x63) { moby->flags |= 0x1000; - *(float *)(d + 0x20) -= collision.damage; - if (0.0f < *(float *)(d + 0x20)) { - if (collision.damage < 1.0f) d[0x67] = 100; - else { - float distance, time, angle; - time = frame_time; - distance = D_0015ED70 * 30.0f; - *(int *)(d + 0x94) = 9; - *(float *)(d + 0x88) = time * 5.0f; - *(float *)(d + 0x8c) = time * 7.0f; - *(float *)(d + 0x80) = distance; - *(float *)(d + 0x84) = 0.0005f; - d[0xad] = 0; - old = d + 0x70; - angle = fast_arc_tan(moby->pos.x - hero.motion.pos.f[0], moby->pos.y - hero.motion.pos.f[1]); - FUN_L08_00266a48(angle, moby, old, 6, 1, 0); - *(float *)(d + 0xc0) = 6.0f; - *(float *)(d + 0xc4) = 10.0f; - d[0x67] = 120; - moby->state = 90; + vars->health -= damage; + if (0.0f < vars->health) { + if (damage < 1.0f) { + vars->tint = 100; + } else { + char *hero_bytes; + vars->f80 = frame_time_sq * 30.0f; + vars->f88 = frame_time * 5.0f; + vars->f8C = frame_time * 7.0f; + vars->i94 = 9; + vars->f84 = 0.0005f; + vars->bAD = 0; + hero_bytes = (char *)&hero; + FUN_L00_0025c558(moby, vars->blk70, + fast_arc_tan_c2(moby->pos.x - *(float *)(hero_bytes + 0x80), + moby->pos.y - *(float *)(hero_bytes + 0x84)), + 6, 1, 0); + vars->fC0 = 6.0f; + vars->fC4 = 10.0f; + vars->tint = 0x78; + moby->state = 0x5A; } } else { - float distance, time, angle; - angle = D_0015ED70 * 30.0f; - distance = D_L08_0016198C * D_0015ED6C; - time = D_L08_00161990 * D_0015ED6C; - *(int *)(d + 0x94) = 9; - *(float *)(d + 0x84) = 0.0005f; - *(float *)(d + 0x88) = distance; - *(float *)(d + 0x80) = angle; - *(float *)(d + 0x8c) = time; - d[0xad] = 0; - old = d + 0x70; - angle = fast_arc_tan(moby->pos.x - hero.motion.pos.f[0], moby->pos.y - hero.motion.pos.f[1]); - FUN_L08_00266a48(angle, moby, old, 9, 1, 0); - *(float *)(d + 0xc0) = 6.0f; - *(float *)(d + 0xc4) = 10.0f; - FUN_L08_00261970(moby, 0, -1); - *(unsigned char *)(d + 0x67) = 250; - moby->state = 99; - moby->flags &= 0xefff; - (*(struct Moby **)(d + 0x120))->command = 0; + char *hero_bytes; + vars->i94 = 9; + vars->f84 = 0.0005f; + vars->f80 = frame_time_sq * 30.0f; + vars->f88 = D_L08_0016198C_gp * frame_time; + vars->f8C = D_L08_00161990_gp * frame_time; + vars->bAD = 0; + hero_bytes = (char *)&hero; + FUN_L00_0025c558(moby, vars->blk70, + fast_arc_tan_c2(moby->pos.x - *(float *)(hero_bytes + 0x80), + moby->pos.y - *(float *)(hero_bytes + 0x84)), + 9, 1, 0); + vars->fC0 = 6.0f; + vars->fC4 = 10.0f; + explode_2D5FA8_c(moby, 0, -1); + vars->tint = 0xFA; + moby->state = 0x63; + moby->flags &= 0xEFFF; + vars->waypoint->command = 0; } - FUN_L08_00267948(moby, d + 0x60); + effects_start_2D5FA8_c(moby, vars->anim); + } + moby->hit_slot = 0xFF; + search.result = FUN_L08_0026a3d0(moby, 16.0f, &search); + if (search.target == 0) { + search.target = *(struct Moby **)&D_001413D0; } - moby->hit_slot = 255; - search.result = FUN_L08_0026a3d0(16.0f, moby, &search); - if (!search.target) search.target = *(struct Moby **)D_001413D0; target = search.target; switch (moby->state) { case 0: - one = 1; moby->flags |= 0x1000; - d[0x29] = one; - *(float *)(d + 0x20) = 2.0f; - FUN_L08_00263050(d + 0xd0); - { float distance = D_L08_00161978 * D_0015ED6C; - *(float *)(d + 0xdc) = 2.0f; - *(float *)(d + 0xd8) = 2.0f; - *(float *)(d + 0x10c) = 0.03f; - *(float *)(d + 0x110) = 0.3f; - *(float *)(d + 0x114) = 0.25f; - *(float *)(d + 0xf4) = distance; } - d[0x58] = truncate_float_to_s32(17.0f); - d[0x5a] = truncate_float_to_s32(10.4f); - clear_u64_value(d + 0x40); - next = FUN_L08_002daa10(moby); - *(char **)(d + 0x120) = next; - next[0xbc] = one; - *(int *)(d + 0x128) = scale_game_frames(180); + vars->b29 = 1; + vars->health = 2.0f; + FUN_L01_0026d930(vars->blkD0); + vars->fDC = 2.0f; + vars->fD8 = 2.0f; + vars->f10C = 0.03f; + vars->f110 = 0.3f; + vars->f114 = 0.25f; + vars->fF4 = D_L08_00161978_gp * frame_time; + vars->b58 = func_001FA898_2D6C58(17.0f); + vars->b5A = func_001FA898_2D6C58(10.4f); + clear_u64_value(vars->v40); + vars->waypoint = (struct Moby *)FUN_L08_002daa10_c((char *)moby); + vars->waypoint->command = 1; + vars->i128 = scale_game_frames_c2(0xB4); if (moby->prev_seq != 4) { - hit_duration = 0; -change_animation: - blend_moby_animation(moby, 4, 0, hit_duration); + FUN_00212f90(moby, 4, 0, 0); } -set_idle: - moby->state = one; - goto reset_timer; + moby->state = 1; + vars->i134 = scale_game_frames_c2(0xF0); + break; case 1: - FUN_L08_002635a0(moby, d + 0xd0, *(char **)(d + 0x120) + 0x10, d + 0x40); - distance = FUN_001f9b48(&moby->pos, *(char **)(d + 0x120) + 0x10); - if (distance < 3.0f) { - next = *(char **)(d + 0x120); - angle = fast_arc_tan(*(float *)(next + 0x10) - moby->pos.x, *(float *)(next + 0x14) - moby->pos.y); - if (fast_difference_between_rotations(moby->rot.z, angle) < 0.2617994f) { - if (6.0f < FUN_001f9b80(&moby->pos, &target->pos)) { - if (moby->prev_seq != 5) blend_moby_animation(moby, 5, 0, 10); + FUN_L00_00259028((char *)moby, vars->blkD0, (float *)&vars->waypoint->pos, (char *)vars->v40); + if (fast_vec_dist(&moby->pos, &vars->waypoint->pos) < 3.0f) { + if (fast_difference_between_rotations_c3(moby->rot.z, + fast_arc_tan_c2(vars->waypoint->pos.x - moby->pos.x, + vars->waypoint->pos.y - moby->pos.y)) < 0.2617994f) { + if (6.0f < vector_distance_xy_alt(&moby->pos, &target->pos)) { + if (moby->prev_seq != 5) { + FUN_00212f90(moby, 5, 0, 10); + } moby->state = 6; - } else { - old = *(char **)(d + 0x120); - *(int *)(d + 0x134) = scale_game_frames(240); - next = FUN_L08_002daa10(moby); - *(char **)(d + 0x120) = next; - if (!next) *(char **)(d + 0x120) = old; - old[0xbc] = 0; - (*(struct Moby **)(d + 0x120))->command = 1; + break; + } + vars->i134 = scale_game_frames_c2(0xF0); + { + struct Moby *old_waypoint = vars->waypoint; + struct Moby *next_waypoint = (struct Moby *)FUN_L08_002daa10_c((char *)moby); + vars->waypoint = next_waypoint; + if (next_waypoint == 0) { + vars->waypoint = old_waypoint; + } + old_waypoint->command = 0; + vars->waypoint->command = 1; } break; } } - if (!FUN_001f9740((int *)(d + 0x134))) break; - old = *(char **)(d + 0x120); - next = FUN_L08_002daa10(moby); - *(char **)(d + 0x120) = next; - if (!next) *(char **)(d + 0x120) = old; - old[0xbc] = 0; - (*(struct Moby **)(d + 0x120))->command = 1; - goto reset_timer; + if (tick_countdown_32_alt(&vars->i134) != 0) { + old_waypoint = vars->waypoint; + if ((vars->waypoint = (struct Moby *)FUN_L08_002daa10_c((char *)moby)) == 0) { + vars->waypoint = old_waypoint; + } + old_waypoint->command = 0; + vars->waypoint->command = 1; + vars->i134 = scale_game_frames_c2(0xF0); + } + break; case 6: - FUN_L08_002635a0(moby, d + 0xd0, *(char **)(d + 0x120) + 0x10, d + 0x40); - if (!(moby->anim_flags & 2)) break; - blend_moby_animation(*(void **)(d + 0x120), 1, 0, scale_game_frames(6)); - { - u64 *point = (u64 *)&moby->pos; - u64 *aim = (u64 *)(*(char **)(d + 0x120) + 0x10); - point[0] = aim[0]; - point[1] = aim[1]; + FUN_L00_00259028((char *)moby, vars->blkD0, (float *)&vars->waypoint->pos, (char *)vars->v40); + if (moby->anim_flags & 2) { + FUN_00212f90(vars->waypoint, 1, 0, scale_game_frames_c2(6)); + qcopy(&moby->pos, &vars->waypoint->pos); + moby->pos.z -= 0.1f; + if (moby->prev_seq != 1) { + FUN_00212f90(moby, 1, 0, 10); + } + moby->state = 3; + moby->flags &= 0xEFFF; + moby->rot.z = fast_arc_tan_c2(target->pos.x - moby->pos.x, target->pos.y - moby->pos.y); + vars->i128 = scale_game_frames_c2(0x78); + moby->collision = 0; } - moby->pos.z -= 0.1f; - if (moby->prev_seq != 1) blend_moby_animation(moby, 1, 0, 10); - moby->state = 3; - moby->flags &= 0xefff; - moby->rot.z = fast_arc_tan(target->pos.x - moby->pos.x, target->pos.y - moby->pos.y); - *(int *)(d + 0x128) = scale_game_frames(120); - moby->collision = 0; break; - case 3: - distance = FUN_001f9b80(&moby->pos, &target->pos); - angle = fast_arc_tan(target->pos.x - moby->pos.x, target->pos.y - moby->pos.y); - FUN_L08_00262778(angle, 0.02f, 0.3f, 0.2f, moby, d + 0x12c); - if (distance < 20.0f && 8.0f < distance && FUN_001f9740((int *)(d + 0x128))) { - char *old = camera_state_bytes; - angle = fast_arc_tan(moby->pos.x - *(float *)(old + 0x140), moby->pos.y - *(float *)(old + 0x144)); - if (fast_difference_between_rotations(*(float *)(old + 0x158), angle) < 0.55850536f) goto begin_attack; + case 3: { + float dist = vector_distance_xy_alt(&moby->pos, &target->pos); + func_L00_002592B0_x(fast_arc_tan_c2(target->pos.x - moby->pos.x, target->pos.y - moby->pos.y), + moby, vars->blk12C, 0.02f, 0.3f, 0.2f); + if (dist < 20.0f && 8.0f < dist && tick_countdown_32_alt(&vars->i128) != 0) { + Cam_DBF68 *cam = (Cam_DBF68 *)camera_state_bytes; + if (fast_difference_between_rotations_c3(cam->f158, fast_arc_tan_c2(moby->pos.x - cam->x, moby->pos.y - cam->y)) < 0.55850536f) { + goto attack; + } + } + if (vars->i38 == 0 || !(0.5f < dist)) { + break; + } + attack: + FUN_00212f90(vars->waypoint, 1, 0, scale_game_frames_c2(6)); + if (moby->prev_seq != 2) { + FUN_00212f90(moby, 2, 0, scale_game_frames_c2(7)); } - if (!*(int *)(d + 0x38) || !(0.5f < distance)) break; -begin_attack: - blend_moby_animation(*(void **)(d + 0x120), 1, 0, scale_game_frames(6)); - if (moby->prev_seq != 2) blend_moby_animation(moby, 2, 0, scale_game_frames(7)); moby->state = 4; moby->flags |= 0x1000; moby->collision = moby->pclass->collision; break; + } case 4: - point[0] = fast_cos(moby->rot.z); point[0] += point[0]; - point[1] = fast_sin(moby->rot.z); point[1] += point[1]; - point[2] = 0; - add_vector_xyz(point, point, *(char **)(d + 0x120) + 0x10); - if (0.2f < FUN_001f9b80(&moby->pos, point)) - FUN_L08_002635a0(moby, d + 0xd0, point, d + 0x40); - if (!(moby->anim_flags & 2)) break; - if (FUN_001f9b80(&moby->pos, &target->pos) < 6.0f) goto select_target; - { - char *old = camera_state_bytes; - angle = fast_arc_tan(moby->pos.x - *(float *)(old + 0x140), moby->pos.y - *(float *)(old + 0x144)); - if (!(0.55850536f < fast_difference_between_rotations(*(float *)(old + 0x158), angle))) goto fire_animation; + point[0] = fast_cos_c4(moby->rot.z) * 2.0f; + point[1] = fast_sin(moby->rot.z) * 2.0f; + point[2] = 0.0f; + add_vector_xyz(point, point, &vars->waypoint->pos); + if (0.2f < vector_distance_xy_alt(&moby->pos, point)) { + FUN_L00_00259028((char *)moby, vars->blkD0, point, (char *)vars->v40); + } + if (moby->anim_flags & 2) { + Cam_DBF68 *cam; + if (vector_distance_xy_alt(&moby->pos, &target->pos) < 6.0f + || (cam = (Cam_DBF68 *)camera_state_bytes, + 0.55850536f < fast_difference_between_rotations_c3(cam->f158, fast_arc_tan_c2(moby->pos.x - cam->x, moby->pos.y - cam->y)))) { + old_waypoint = vars->waypoint; + if ((vars->waypoint = (struct Moby *)FUN_L08_002daa10_c((char *)moby)) == 0) { + vars->waypoint = old_waypoint; + } + old_waypoint->command = 0; + vars->waypoint->command = 1; + if (moby->prev_seq != 4) { + FUN_00212f90(moby, 4, 0, scale_game_frames_c2(7)); + } + moby->state = 1; + vars->i134 = scale_game_frames_c2(0xF0); + } else { + if (moby->prev_seq != 3) { + FUN_00212f90(moby, 3, 0, scale_game_frames_c2(6)); + } + moby->state = 5; + } } -select_target: - old = *(char **)(d + 0x120); - next = FUN_L08_002daa10(moby); - *(char **)(d + 0x120) = next; - if (!next) *(char **)(d + 0x120) = old; - old[0xbc] = 0; - one = 1; - (*(struct Moby **)(d + 0x120))->command = one; - if (moby->prev_seq != 4) { hit_duration = scale_game_frames(7); goto change_animation; } - goto set_idle; -fire_animation: - if (moby->prev_seq != 3) blend_moby_animation(moby, 3, 0, scale_game_frames(6)); - moby->state = 5; break; case 5: - angle = fast_arc_tan(target->pos.x - moby->pos.x, target->pos.y - moby->pos.y); - FUN_L08_00262778(angle, 0.02f, 0.3f, 0.2f, moby, d + 0x12c); - if (moby->seq == moby->prev_seq && FUN_L08_002592c8(moby) == 19.0f) { + func_L00_002592B0_x(fast_arc_tan_c2(target->pos.x - moby->pos.x, target->pos.y - moby->pos.y), + moby, vars->blk12C, 0.02f, 0.3f, 0.2f); + if (moby->seq == moby->prev_seq && FUN_0020c9e0(moby) == 19.0f) { + float distance, time; + char *next; subtract_vector_xyz(aim, &target->pos, &moby->pos); - aim[2] = 0; - distance = vector_length_xyz(aim); - time = distance / FUN_L08_00211a20(D_L08_0016197C); - distance -= D_L08_00161988 * time + 2.0f; - if (10.0f < distance) distance = 10.0f; - else if (distance < 3.0f) distance = 3.0f; - FUN_L08_00269c20(distance, aim); + aim[2] = 0.0f; + distance = fast_vec_length_c2(aim); + time = distance / FUN_001f96b0(D_L08_0016197C_gp); + distance = distance - (D_L08_00161988_gp * time + 2.0f); + if (10.0f < distance) { + distance = 10.0f; + } else if (distance < 3.0f) { + distance = 3.0f; + } + FUN_L00_0025f730(aim, distance); add_vector_xyz(aim, aim, &moby->pos); - FUN_L00_0024f7c8(moby, 9, point); + func_L00_00250800_2D6C58(moby, 9, point); subtract_vector_xyz(velocity, &target->pos, point); set_vector_length_xy(velocity, velocity, time); - velocity[2] = FUN_L08_00265120(point, aim, collision.scratch, time, -(D_0015ED70 * 15.0f)); - next = FUN_L08_002d22e0((int)moby, (char *)point, (char *)velocity); - *(char **)(d + 0x124) = next; - if (next) { - old = *(char **)(next + 0x78); - *(int *)(old + 0x20) = scale_game_frames(180); - *(short *)(old + 0xc) = scale_game_frames(10); - *(short *)(old + 0xe) = scale_game_frames(10); - (*(struct Moby **)(d + 0x124))->state = 1; - (*(struct Moby **)(d + 0x124))->command |= 3; - *(int *)(d + 0x128) = scale_game_frames(180); + velocity[2] = FUN_L00_0025abf0(point, aim, &scratch, time, -(frame_time_sq * 15.0f)); + next = FUN_L08_002d22e0_c((int)moby, (char *)point, (char *)velocity); + vars->p124 = (struct Moby *)next; + if (next != 0) { + char *next_vars = *(char **)(next + 0x78); + *(int *)(next_vars + 0x20) = scale_game_frames_c2(0xB4); + *(short *)(next_vars + 0xC) = scale_game_frames_c2(10); + *(short *)(next_vars + 0xE) = scale_game_frames_c2(10); + vars->p124->state = 1; + vars->p124->command |= 3; + vars->i128 = scale_game_frames_c2(0xB4); } break; } if (moby->anim_flags & 2) { moby->state = 1; - if (moby->prev_seq != 4) blend_moby_animation(moby, 4, 0, 3); -reset_timer: - *(int *)(d + 0x134) = scale_game_frames(240); + if (moby->prev_seq != 4) { + FUN_00212f90(moby, 4, 0, 3); + } + vars->i134 = scale_game_frames_c2(0xF0); } break; - case 91: + case 0x5B: if (moby->anim_flags & 2) { - if (moby->prev_seq != 7) blend_moby_animation(moby, 7, 0, 3); - moby->state = 93; + if (moby->prev_seq != 7) { + FUN_00212f90(moby, 7, 0, 3); + } + moby->state = 0x5D; } break; - case 90: case 92: case 93: - if (FUN_L08_00266b88(moby, d + 0x70) & 0x40) { - old = *(char **)(d + 0x120); - next = FUN_L08_002daa10(moby); - *(char **)(d + 0x120) = next; - if (!next) *(char **)(d + 0x120) = old; - else { old[0xbc] = 0; (*(struct Moby **)(d + 0x120))->command = 1; } - if (moby->prev_seq != 4) blend_moby_animation(moby, 4, 0, 10); + case 0x5A: + case 0x5C: + case 0x5D: + if (FUN_L00_0025c698(moby, vars->blk70) & 0x40) { + old_waypoint = vars->waypoint; + if ((vars->waypoint = (struct Moby *)FUN_L08_002daa10_c((char *)moby)) == 0) { + vars->waypoint = old_waypoint; + } else { + old_waypoint->command = 0; + vars->waypoint->command = 1; + } + if (moby->prev_seq != 4) { + FUN_00212f90(moby, 4, 0, 10); + } moby->state = 1; - *(int *)(d + 0x134) = scale_game_frames(240); + vars->i134 = scale_game_frames_c2(0xF0); + } + if (moby->pos.z < 5.0f) { + mark_moby_for_removal(moby); + return; } - if (moby->pos.z < 5.0f) { mark_moby_for_removal(moby); return; } break; - case 99: - if (FUN_L08_00266b88(moby, d + 0x70) & 0x40) { - moby->anim_speed = 0; + case 0x63: + if (FUN_L00_0025c698(moby, vars->blk70) & 0x40) { + moby->anim_speed = 0.0f; moby->state = 100; moby->collision = 0; - hit_duration = D_L08_001619D0; - *(short *)(d + 0x132) = 40; - *(short *)(d + 0x130) = hit_duration; - FUN_L08_002da8d8(moby); + vars->s132 = 0x28; + vars->s130 = D_L08_001619D0_gp; + FUN_L04_002c46d0(moby); mark_moby_for_removal(moby); return; } + break; } - goto finish; -finish: - FUN_L08_00267a28(moby, d + 0x60); - *(int *)(d + 0x38) = 0; + effects_update_2D5FA8_c(moby, vars->anim); + vars->i38 = 0; } -#endif /* Pvars of the hero-carrying lift. */ typedef struct { u8 pad0[0x20]; @@ -1922,7 +2019,7 @@ typedef struct { extern float FUN_001f9b80(void *, void *); extern float fast_arc_tan(float, float) __asm__("FUN_001f9e90"); extern int D_L08_001B0CB0[]; -extern unsigned char D_0014C050[]; +#include "rnc/gameplay/state/game_globals.h" extern int D_L08_0015F5CC; /* no foreign declaration */ extern Route_2dd4f8 *D_L08_001B0FB0_r[] __asm__("D_L08_001B0CB0"); @@ -1960,7 +2057,7 @@ void FUN_L08_002dc180(struct Moby *moby) { y = fast_arc_tan(*(float *)((char *)a + ((n - 2) << 4) + 0x10) - *(float *)(data + 0x60), *(float *)((char *)a + ((n - 2) << 4) + 0x14) - *(float *)(data + 0x64)); fr = current_level_index << 4; - t = D_0014C050; + t = visited52; *(float *)(data + 0x78) = y; *(float *)(data + 0xE4) = 1.0f; *(int *)(data + 0x104) = 0; @@ -2709,21 +2806,21 @@ extern char *spawn_spark(void *, void *, void *, int, int, int, int, int, int) _ extern float multiply_global_factor_ed64(float) __asm__("FUN_001f96b0"); extern int fast_tween_color(int, int, float) __asm__("FUN_001fa6e0"); extern s32 truncate_float_to_s32(f32) __asm__("FUN_001fa6d0"); -extern short D_L08_00161A48 __attribute__((sda)); -extern short D_L08_00161A4C __attribute__((sda)); -extern short D_L08_00161A50 __attribute__((sda)); -extern short D_L08_00161A54 __attribute__((sda)); -extern short D_L08_00161A58 __attribute__((sda)); -extern short D_L08_00161A5C __attribute__((sda)); -extern short D_L08_00161A60 __attribute__((sda)); -extern short D_L08_00161A64 __attribute__((sda)); -extern short D_L08_00161A68 __attribute__((sda)); -extern short D_L08_00161A6C __attribute__((sda)); -extern short D_L08_00161A70 __attribute__((sda)); -extern short D_L08_00161A74 __attribute__((sda)); -extern short D_L08_00161A78 __attribute__((sda)); -extern short D_L08_00161A7C __attribute__((sda)); -extern short D_L08_00161A80 __attribute__((sda)); +extern float D_L08_00161A48 __attribute__((sda)); +extern float D_L08_00161A4C __attribute__((sda)); +extern float D_L08_00161A50 __attribute__((sda)); +extern int D_L08_00161A54 __attribute__((sda)); +extern int D_L08_00161A58 __attribute__((sda)); +extern int D_L08_00161A5C __attribute__((sda)); +extern float D_L08_00161A60 __attribute__((sda)); +extern float D_L08_00161A64 __attribute__((sda)); +extern float D_L08_00161A68 __attribute__((sda)); +extern float D_L08_00161A6C __attribute__((sda)); +extern float D_L08_00161A70 __attribute__((sda)); +extern int D_L08_00161A74 __attribute__((sda)); +extern int D_L08_00161A78 __attribute__((sda)); +extern int D_L08_00161A7C __attribute__((sda)); +extern int D_L08_00161A80 __attribute__((sda)); extern void random_vector(float *, float, float) __asm__("FUN_L00_00257d78"); extern void scale_vector_xyz(void *out, void *a, f32 s) __asm__("FUN_001f9a68"); extern void transform_vector_by_basis(void *, void *, void *) __asm__("FUN_001f9cf8"); @@ -2744,24 +2841,24 @@ void FUN_L08_002dec90(struct Moby *m, char *pos) { v60[2] = 0.3f; transform_vector_by_basis(v50, v60, &m->rot_row0); add_vector_xyz(v50, v50, &m->pos); - scale_vector_xyz(v10, v30, *(float *)&D_L08_00161A48); - scale_vector_xyz(v20, v30, *(float *)&D_L08_00161A4C); - random_vector(v40, 0.0f, *(float *)&D_L08_00161A50 * frame_time); + scale_vector_xyz(v10, v30, D_L08_00161A48); + scale_vector_xyz(v20, v30, D_L08_00161A4C); + random_vector(v40, 0.0f, D_L08_00161A50 * frame_time); add_vector_xyz(v20, v20, v40); - v10[3] = random_float_between(*(float *)&D_L08_00161A64, *(float *)&D_L08_00161A68); - v20[3] = random_float_between(*(float *)&D_L08_00161A6C, *(float *)&D_L08_00161A70); - a = fast_tween_color(*(int *)&D_L08_00161A74, *(int *)&D_L08_00161A78, + v10[3] = random_float_between(D_L08_00161A64, D_L08_00161A68); + v20[3] = random_float_between(D_L08_00161A6C, D_L08_00161A70); + a = fast_tween_color(D_L08_00161A74, D_L08_00161A78, random_float_between(0.0f, 1.0f)); - b = fast_tween_color(*(int *)&D_L08_00161A7C, *(int *)&D_L08_00161A80, + b = fast_tween_color(D_L08_00161A7C, D_L08_00161A80, random_float_between(0.0f, 1.0f)); c = func_001FA898_r( - multiply_global_factor_ed64((float)*(int *)&D_L08_00161A54 * random_float_between(0.0f, 1.0f) + 1.0f)); + multiply_global_factor_ed64((float)D_L08_00161A54 * random_float_between(0.0f, 1.0f) + 1.0f)); d = func_001FA898_r(multiply_global_factor_ed64( - (float)*(int *)&D_L08_00161A58 * - (random_float_between(-*(float *)&D_L08_00161A60, *(float *)&D_L08_00161A60) + 1.0f))); + (float)D_L08_00161A58 * + (random_float_between(-D_L08_00161A60, D_L08_00161A60) + 1.0f))); e = func_001FA898_r(multiply_global_factor_ed64( - (float)*(int *)&D_L08_00161A5C * - (random_float_between(-*(float *)&D_L08_00161A60, *(float *)&D_L08_00161A60) + 1.0f))); + (float)D_L08_00161A5C * + (random_float_between(-D_L08_00161A60, D_L08_00161A60) + 1.0f))); r = spawn_spark(v50, v10, v20, a, b, c, d, e, -1); if (r != 0) { r[9] = func_001FA898_r(8.0f) - 0x70; diff --git a/src/overlays/l10/gameplay/entities/platform.c b/src/overlays/l10/gameplay/entities/platform.c index 7e7df1334a..13f7fe7505 100644 --- a/src/overlays/l10/gameplay/entities/platform.c +++ b/src/overlays/l10/gameplay/entities/platform.c @@ -29,11 +29,11 @@ void build_spherical_offset(f32 *out, f32 scale, f32 a, f32 b) __asm__("FUN_0021 int D_L10_00161BF0 = 240; int D_L10_00161BF4 = 600; -extern short D_L10_00161BF8 __attribute__((sda)); -extern short D_L10_00161BFC __attribute__((sda)); -extern short D_L10_00161C00 __attribute__((sda)); -extern short D_L10_00161C04 __attribute__((sda)); -extern short D_L10_00161C08 __attribute__((sda)); +extern float D_L10_00161BF8 __attribute__((sda)); +extern float D_L10_00161BFC __attribute__((sda)); +extern float D_L10_00161C00 __attribute__((sda)); +extern float D_L10_00161C04 __attribute__((sda)); +extern float D_L10_00161C08 __attribute__((sda)); void FUN_L10_002d8c00(struct Moby *moby) { char *data = (char *)moby->pvars; float a[4]; @@ -44,15 +44,15 @@ void FUN_L10_002d8c00(struct Moby *moby) { moby->state = 1; } if (FUN_001f9740((int *)data)) { - float x = *(float *)&D_L10_00161BF8; + float x = D_L10_00161BF8; float p = random_float_between_alt(-x, x) * DEG_TO_RAD; float q = fast_add_rotations(moby->rot.z, p); float r = - random_float_between_alt(*(float *)&D_L10_00161BFC, *(float *)&D_L10_00161C00) * + random_float_between_alt(D_L10_00161BFC, D_L10_00161C00) * DEG_TO_RAD; build_spherical_offset( a, - random_float_between_alt(*(float *)&D_L10_00161C04, *(float *)&D_L10_00161C08) * + random_float_between_alt(D_L10_00161C04, D_L10_00161C08) * frame_time, q, r); FUN_001f9a10(b, &moby->pos, a); @@ -238,7 +238,6 @@ void FUN_L10_00295c20(struct Moby *moby) { FUN_L00_00260738(d + 0x60, v, &moby->rot, &moby->rot); } /* Spinning pickup: waits until the hero is close and level with it, then plays the scene, saves and goes away. */ -extern float D_0015ED6C_p __asm__("D_0015ED6C"); extern char *D_L10_0015FFD8_p __asm__("D_L10_0015FFD8"); extern void FUN_L00_002d6bf0_p(void *) __asm__("FUN_L00_002d6bf0"); extern void FUN_L10_00298940_p(void *) __asm__("FUN_L10_00298940"); @@ -253,7 +252,7 @@ extern int memcard_save_data(int, int) __asm__("FUN_0020b178"); extern int D_L10_0015F640; void FUN_L10_00298668(struct Moby *m) { char *d = (char *)m->pvars; - m->rot.z = fast_add_rotations(m->rot.z, D_0015ED6C_p * 1.5707964f); + m->rot.z = fast_add_rotations(m->rot.z, frame_time * 1.5707964f); switch (m->state) { case 0: FUN_L00_002d6bf0_p(m); @@ -413,136 +412,171 @@ void FUN_L10_00298b68(struct Moby *moby) { mark_moby_for_removal_98b68(moby); } } -#ifndef NON_MATCHING -INCLUDE_ASM("config/us/overlays/asm/FUN_L10_002be858.s", FUN_L10_002be858); -#else -extern int D_L10_0015F5CC; -extern struct Moby *D_L10_0015FFD8; +#include "rnc/math/vector.h" + +/* Ported from rac1-decomp (src/overlays/l10_orxon/vendor_00296BD8.c: func_L10_002BFBB8), where it is exact; names translated to the US level program. */ + +typedef unsigned int Q_2BFBB8 __attribute__((mode(TI), aligned(16))); + +typedef struct { char p0[0x10]; float x; float y; char p1[8]; unsigned char state; char p2[0xDF]; } Ent; + +extern struct Moby * D_L10_0015FFD8; +extern char D_0013F350[]; +extern char D_L10_00167100[]; +extern f32 convert_integer_to_float(s32) __asm__("func_001FA6C0"); +extern f32 fast_cos(f32) __asm__("func_001F9DC8"); +extern f32 fast_sin(f32) __asm__("func_001F9DE0"); +extern f32 random_float_between(f32, f32) __asm__("func_002132A8"); extern float D_0015ED6C; extern float D_0015ED70; -extern unsigned char D_001413F4[]; -extern char D_0013F3D0[]; -extern int D_L10_001618A8 __attribute__((sda)); -#define D_001618A8 (*(int *)0x001618a8) -extern struct { char pad[0x180]; char *effect; } D_L10_00167100; -#define D_00167280 D_L10_00167100.effect -extern int D_001618A0 __asm__("D_L10_001618A0") __attribute__((sda)); -extern int D_001618A4 __asm__("D_L10_001618A4") __attribute__((sda)); -extern int FUN_001f96f8(int); -extern float vector_distance(void *, void *) __asm__("FUN_001f9b80"); -extern float fast_cos(float) __asm__("FUN_001f9dc8"); -extern float fast_sin(float) __asm__("FUN_001f9de0"); -extern float random_float_between_alt(float, float) __asm__("FUN_002132a8"); -extern int random_integer_below(int) __asm__("FUN_00213260"); -extern int random_int_between(int, int) __asm__("FUN_L00_00257b90"); -extern float random_angle_radians(void) __asm__("FUN_00213308"); +extern float vector_distance_xy_alt(void *, void *) __asm__("FUN_001f9b80"); +extern int D_L10_0015F5CC; +extern int D_L10_001618A0 __attribute__((sda)); +extern int D_L10_001618A4 __attribute__((sda)); +extern int D_L10_001618A8; +extern int FUN_L00_00257b90(int, int); +extern int allocate_voice_for_target_entry(int, int, int) __asm__("FUN_0022da68"); +extern int tick_countdown_32_alt(int *) __asm__("FUN_001f9740"); +extern s32 fast_tween_color(s32, s32, f32) __asm__("func_001FA6E0"); +extern s32 random_integer_below(s32) __asm__("func_00213260"); +extern s32 scale_game_frames(s32) __asm__("func_001F96F8"); +extern s32 truncate_float_to_s32(f32) __asm__("func_001FA6D0"); +extern void * FUN_L00_002715e8(void *, int, int, float, float); +extern void * FUN_L00_00272060(void *, int, float, float, int, int, int, void *, float); extern void add_vectors(void *, void *, void *) __asm__("FUN_L00_001ff290"); -extern void normalize_vector_xyz(void *, void *, float) __asm__("FUN_001f9bf8"); -extern void FUN_L00_00272060(void *, int, float, float, int, int, int, float *, float); extern void FUN_L00_00216f90(void *, void *, int, int); -extern void *FUN_L00_002715e8(void *, int, int, float, float); -extern float convert_integer_to_float() __asm__("FUN_001fa6c0"); -extern int truncate_float_to_s32(float) __asm__("FUN_001fa6d0"); -extern unsigned int fast_tween_color(float, int, int) __asm__("FUN_001fa6e0"); +extern void FUN_L00_002e8568(int); extern void FUN_L00_002e8590(float, float); extern void FUN_L00_002e8648(void); extern void FUN_L00_002e8680(void); -extern void FUN_L00_002e8568(int); - -void FUN_L10_002be858(unsigned char *moby) { +extern void fast_vec_normalize_c(void *, void *, f32) __asm__("FUN_001f9bf8"); +extern struct Moby * D_L10_0015FFD8; + +#define func_001F9850_2BFBB8 ((int (*)(int))scale_game_frames) +#define func_001F9D48_2BFBB8 ((float (*)(void *, void *))vector_distance_xy_alt) +#define func_002140F8_2BFBB8 ((float (*)(float, float))random_float_between) +#define func_00214158_2BFBB8 ((float (*)(void))random_angle_radians) +#define func_002140B0_2BFBB8 ((int (*)(int))random_integer_below) +#define func_L00_00258BC8_2BFBB8 ((int (*)(int, int))FUN_L00_00257b90) +#define func_001F9F90_2BFBB8 ((float (*)(float))fast_cos) +#define func_001F9FA8_2BFBB8 ((float (*)(float))fast_sin) +#define func_L00_001FF4B0_2BFBB8 ((void (*)(void *, void *, float))fast_vec_normalize_c) +#define func_L00_00272F00_2BFBB8 FUN_L00_00272060 +#define func_L00_00272488_2BFBB8 FUN_L00_002715e8 +#define func_0022ED80_2BFBB8 ((int (*)(int, int, int))allocate_voice_for_target_entry) +#define func_L00_00217718_2BFBB8 FUN_L00_00216f90 +#define func_001FA888_2BFBB8 ((float (*)(int))convert_integer_to_float) +#define func_001FA898_2BFBB8 ((int (*)(float))truncate_float_to_s32) +#define func_001FA8A8_2BFBB8 fast_tween_color +#define func_001F9908_2BFBB8 ((int (*)(int *))tick_countdown_32_alt) +#define func_L00_002E9A40_2BFBB8 FUN_L00_002e8590 +#define func_L00_002E9B30_2BFBB8 FUN_L00_002e8680 +#define func_L00_002E9AF8_2BFBB8 FUN_L00_002e8648 +#define func_L00_002E9A18_2BFBB8 FUN_L00_002e8568 + +void FUN_L10_002be858(char *moby) +{ int *data = *(int **)(moby + 0x78); float position[4]; float velocity[4]; float offset_buffer[4]; - float *offset; float angle; + float *offset; int i; - if ((unsigned char)moby[0x20] == 0) { + char *hero_bytes; + int life; + if (*(unsigned char *)(moby + 0x20) == 0) { D_L10_001618A8 = 0; - D_001618A4 = FUN_001f96f8(D_001618A4); - D_001618A0 = FUN_001f96f8(D_001618A0); - moby[0x20] = 1; + D_L10_001618A4 = func_001F9850_2BFBB8(D_L10_001618A4); + D_L10_001618A0 = func_001F9850_2BFBB8(D_L10_001618A0); + *(unsigned char *)(moby + 0x20) = 1; } - if (hero.vehicle_mode == 1 && *data != -1 && vector_distance(moby + 0x10, &hero.motion.pos) < 0.5f) { + hero_bytes = D_0013F350; + if ((unsigned char)hero_bytes[0x20A4] == 1 && *data != -1 && + func_001F9D48_2BFBB8(moby + 0x10, hero_bytes + 0x80) < 0.5f) { offset = offset_buffer; i = 9; do { float size, size_scaled; - int red, green, blue, color, life, spin; + int red, green, blue, color, spin, green_alpha; i--; - size = random_float_between_alt(0.1f, 1.0f); - red = random_int_between(0x40, 0xff); - green = random_int_between(0x40, 0xff); - blue = random_int_between(0x40, 0xff); - velocity[0] = fast_cos(random_angle_radians()) * random_float_between_alt(0.0f, 0.5f); - velocity[1] = fast_sin(random_angle_radians()) * random_float_between_alt(0.0f, 0.5f); + size = func_002140F8_2BFBB8(0.1f, 1.0f); + red = func_L00_00258BC8_2BFBB8(0x40, 0xff); + green = func_L00_00258BC8_2BFBB8(0x40, 0xff); + blue = func_L00_00258BC8_2BFBB8(0x40, 0xff); + velocity[0] = func_001F9F90_2BFBB8(func_00214158_2BFBB8()) * func_002140F8_2BFBB8(0.0f, 0.5f); + velocity[1] = func_001F9FA8_2BFBB8(func_00214158_2BFBB8()) * func_002140F8_2BFBB8(0.0f, 0.5f); velocity[2] = 0.0f; - velocity[2] += random_float_between_alt(0.0f, 0.5f); - add_vectors(offset, velocity, D_0013F3D0); - normalize_vector_xyz(position, position, random_float_between_alt(0.0f, D_0015ED6C)); - position[2] = random_float_between_alt(D_0015ED6C * 2.5f, D_0015ED6C * 5.0f); - life = FUN_001f96f8(random_int_between(15, 30)); - /* Channels are 64..255, so alpha and shifted green have disjoint bits. */ - color = (blue << 16) | ((green << 8) + 0x7f000000) | red; + velocity[2] += func_002140F8_2BFBB8(0.0f, 0.5f); + add_vectors(offset, velocity, D_0013F350 + 0x80); + func_L00_001FF4B0_2BFBB8(position, position, func_002140F8_2BFBB8(0.0f, D_0015ED6C)); + position[2] = func_002140F8_2BFBB8(D_0015ED6C * 2.5f, D_0015ED6C * 5.0f); + life = func_001F9850_2BFBB8(func_L00_00258BC8_2BFBB8(15, 30)); + green_alpha = (green << 8) | 0x7f000000; + color = (blue << 16) | green_alpha | red; size_scaled = size * 0.07f; size *= 0.7f; - spin = random_integer_below(2) ? 1 : -1; - FUN_L00_00272060(velocity, life, size_scaled, size, color, 0, spin, position, D_0015ED70 * 15.0f); + spin = func_002140B0_2BFBB8(2) ? 1 : -1; + func_L00_00272F00_2BFBB8(velocity, life, size_scaled, size, color, 0, spin, position, D_0015ED70 * 15.0f); } while (i >= 0); - allocate_voice_for_target_entry(0, 0, (int)moby); + func_0022ED80_2BFBB8(0, 0, (int)moby); { - char *effect = (char *)D_L10_0015FFD8 + (*data << 8); - FUN_L00_00216f90(effect + 0x10, effect + 0x40, 0x43, 0); + int moby_offset = *data << 8; + char *effect = (*(char * *)&D_L10_0015FFD8) + moby_offset; + func_L00_00217718_2BFBB8(effect + 0x10, effect + 0x40, 0x43, 0); } { - char *effect = D_00167280; - D_001618A8 = D_001618A0; + char *table = D_L10_00167100; + char *effect = *(char **)(table + 0x180); + D_L10_001618A8 = D_L10_001618A0; if (*(short *)(effect + 0x86) == 0) { - short *timer = (short *)(*(char **)(effect + 0x70) + 0x20); - *timer = FUN_001f96f8(0x5a); - qcopy(effect + 0x40, effect); + char *current = *(char **)(table + 0x180); + short *timer = (short *)(*(char **)(current + 0x70) + 0x20); + *timer = func_001F9850_2BFBB8(0x5a); + qcopy(current + 0x40, current); } } i = 9; do { float size, size_scaled; - int red, green, blue, color, life, spin; - *(OvlQuad *)velocity = 0; - velocity[0] = random_float_between_alt(-1.0f, 1.0f); + int red, green, blue, color, spin, green_alpha; + *(Q_2BFBB8 *)velocity = 0; + velocity[0] = func_002140F8_2BFBB8(-1.0f, 1.0f); i--; - velocity[1] = random_float_between_alt(-1.0f, 1.0f); - *(OvlQuad *)position = *(OvlQuad *)velocity; - size = random_float_between_alt(0.1f, 1.0f); - red = random_int_between(0x40, 0xff); - green = random_int_between(0x40, 0xff); - blue = random_int_between(0x40, 0xff); - velocity[0] = fast_cos(random_angle_radians()) * random_float_between_alt(0.0f, 0.5f); - velocity[1] = fast_sin(random_angle_radians()) * random_float_between_alt(0.0f, 0.5f); + velocity[1] = func_002140F8_2BFBB8(-1.0f, 1.0f); + *(Q_2BFBB8 *)position = *(Q_2BFBB8 *)velocity; + size = func_002140F8_2BFBB8(0.1f, 1.0f); + red = func_L00_00258BC8_2BFBB8(0x40, 0xff); + green = func_L00_00258BC8_2BFBB8(0x40, 0xff); + blue = func_L00_00258BC8_2BFBB8(0x40, 0xff); + velocity[0] = func_001F9F90_2BFBB8(func_00214158_2BFBB8()) * func_002140F8_2BFBB8(0.0f, 0.5f); + velocity[1] = func_001F9FA8_2BFBB8(func_00214158_2BFBB8()) * func_002140F8_2BFBB8(0.0f, 0.5f); velocity[2] = 0.0f; - velocity[2] += random_float_between_alt(0.0f, 0.5f); - add_vectors(offset, velocity, (char *)D_L10_0015FFD8 + (*data << 8) + 0x10); - normalize_vector_xyz(position, position, random_float_between_alt(0.0f, D_0015ED6C)); - position[2] = random_float_between_alt(D_0015ED6C * 2.5f, D_0015ED6C * 5.0f); - life = FUN_001f96f8(random_int_between(15, 30)); - color = (blue << 16) | ((green << 8) | 0x7f000000) | red; + velocity[2] += func_002140F8_2BFBB8(0.0f, 0.5f); + add_vectors(offset, velocity, (*(char * *)&D_L10_0015FFD8) + (*data << 8) + 0x10); + func_L00_001FF4B0_2BFBB8(position, position, func_002140F8_2BFBB8(0.0f, D_0015ED6C)); + position[2] = func_002140F8_2BFBB8(D_0015ED6C * 2.5f, D_0015ED6C * 5.0f); + life = func_001F9850_2BFBB8(func_L00_00258BC8_2BFBB8(15, 30)); + green_alpha = (green << 8) | 0x7f000000; + color = (blue << 16) | green_alpha | red; size_scaled = size * 0.07f; size *= 0.7f; - spin = random_integer_below(2) ? 1 : -1; - FUN_L00_00272060(velocity, life, size_scaled, size, color, 0, spin, position, D_0015ED70 * 15.0f); + spin = func_002140B0_2BFBB8(2) ? 1 : -1; + func_L00_00272F00_2BFBB8(velocity, life, size_scaled, size, color, 0, spin, position, D_0015ED70 * 15.0f); } while (i >= 0); } - if (D_L10_0015F5CC % FUN_001f96f8(0x3c) == 0 && *data != -1) { - for (i = 0; i < truncate_float_to_s32(16.0f); i++) { + if (D_L10_0015F5CC % func_001F9850_2BFBB8(0x3c) == 0 && *data != -1) { + for (i = 0; i < func_001FA898_2BFBB8(16.0f); i++) { char *effect; - *(OvlQuad *)position = *(OvlQuad *)(moby + 0x10); - position[2] += convert_integer_to_float(i) * 0.1f * 0.0625f + 1.8f; - effect = (char *)FUN_L00_002715e8(position, 0, 0x1eff7f40, 0.0f, D_0015ED6C * 315000.0f); + *(Q_2BFBB8 *)position = *(Q_2BFBB8 *)(moby + 0x10); + position[2] += func_001FA888_2BFBB8(i) * 0.1f * 0.0625f + 1.8f; + effect = (char *)func_L00_00272488_2BFBB8(position, 0, 0x1eff7f40, 0.0f, D_0015ED6C * 315000.0f); if (effect != 0) { - float size = frame_time; - float *velocity = (float *)(effect + 0x20); - velocity[0] = 0.0f; - velocity[1] = 0.0f; - velocity[2] = size * -1.5f; + float *vel = (float *)(effect + 0x20); + float z = D_0015ED6C * -1.5f; + vel[0] = 0.0f; + vel[1] = 0.0f; + vel[2] = z; } } } @@ -552,18 +586,17 @@ void FUN_L10_002be858(unsigned char *moby) { angle = phase * 3.1415927f; } if (3.1415927f < angle) angle -= 6.2831855f; - *(unsigned int *)(moby + 0x90) = fast_tween_color((fast_sin(angle) + 1.0f) * 0.5f, 0x80464646, 0x80828282); - fast_dec_timer(&D_001618A8); - if (D_001618A8 != 0) { - if (D_001618A4 < D_001618A8) angle = 0.002f; - else angle = convert_integer_to_float(D_001618A8) / convert_integer_to_float(D_001618A4) * 0.007999999f + 0.002f; - FUN_L00_002e8590(angle, 0.2f); - FUN_L00_002e8680(); - FUN_L00_002e8648(); - FUN_L00_002e8568(0); + *(unsigned int *)(moby + 0x90) = func_001FA8A8_2BFBB8(0x80464646, 0x80828282, (func_001F9FA8_2BFBB8(angle) + 1.0f) * 0.5f); + func_001F9908_2BFBB8(&D_L10_001618A8); + if (D_L10_001618A8 != 0) { + if (D_L10_001618A4 < D_L10_001618A8) angle = 0.002f; + else angle = func_001FA888_2BFBB8(D_L10_001618A8) / func_001FA888_2BFBB8(D_L10_001618A4) * 0.007999999f + 0.002f; + func_L00_002E9A40_2BFBB8(angle, 0.2f); + func_L00_002E9B30_2BFBB8(); + func_L00_002E9AF8_2BFBB8(); + func_L00_002E9A18_2BFBB8(0); } } -#endif /* Collectible drop: waits until it is taken, then sinks below its rest height and records the pickup. */ typedef struct { char pad0[0x454]; @@ -1589,8 +1622,8 @@ void FUN_L10_002d8d30(char *m) { extern void transform_vector(void *, void *, void *) __asm__("FUN_001f9d20"); extern void transpose_rotation_matrix(void *, void *) __asm__("FUN_001fa2d8"); -extern short D_L10_00161C0C __attribute__((sda)); -extern short D_L10_00161C10 __attribute__((sda)); +extern float D_L10_00161C0C __attribute__((sda)); +extern float D_L10_00161C10 __attribute__((sda)); int FUN_L10_002d9000(struct Moby *m, float *p) { float a[4] __attribute__((aligned(16))); float t10[16] __attribute__((aligned(16))); @@ -1601,8 +1634,8 @@ int FUN_L10_002d9000(struct Moby *m, float *p) { subtract_vector_xyz(t60, a, &m->pos); *(OvlQuad *)t50 = *(OvlQuad *)t60; transform_vector(t50, t50, t10); - if (absolute_float(t50[0]) < *(float *)&D_L10_00161C10) { - return absolute_float(t50[1]) < *(float *)&D_L10_00161C0C; + if (absolute_float(t50[0]) < D_L10_00161C10) { + return absolute_float(t50[1]) < D_L10_00161C0C; } return 0; } diff --git a/src/overlays/l10/gameplay/entities/screamer.c b/src/overlays/l10/gameplay/entities/screamer.c index e93a95a85c..d1770241bb 100644 --- a/src/overlays/l10/gameplay/entities/screamer.c +++ b/src/overlays/l10/gameplay/entities/screamer.c @@ -529,7 +529,6 @@ void FUN_L00_00263ac8_2e01a8(float x, int a, int b, unsigned char *p) __asm__("F void FUN_L10_002e17c0_2e01a8(Moby *moby) __asm__("FUN_L10_002e17c0"); void FUN_L10_002e1cb0_2e01a8(unsigned char *moby) __asm__("FUN_L10_002e1cb0"); extern float frame_time_x __asm__("D_0015ED6C"); -extern char D_0013F350[]; extern float D_0015ED70; extern float func_001F9CB8_2E0630(void *) __asm__("FUN_001f9af0"); extern void func_001F9BF0_2E0630(void *, void *, void *) __asm__("FUN_001f9a28"); @@ -690,7 +689,7 @@ void FUN_L10_002e01a8(Moby *moby) { func_L00_00259B08_2E0630(moby, &vars->velocity, 0.5f, 0x200, 0.0f, 0); func_L00_0025CC58_2E0630(&moby->rot.y, 0, -func_L00_001FF860_2E0630(vector_length_xy(&vars->velocity), vars->velocity.z), frame_time_x * 6.2831855f); if (func_001F9D48_2E0630(&moby->pos, &target->pos) < D_L10_00161DFC) { - if (absolute_float_2e01a8(moby->pos.z - ((Hero_2e01a8 *)D_0013F350)->motion.pos.f[2]) < 2.0f) { + if (absolute_float_2e01a8(moby->pos.z - ((Hero_2e01a8 *)((char *)&hero))->motion.pos.f[2]) < 2.0f) { func_0022ED80_2E1568(0, 0, moby); moby->state = 8; func_001F9BC0_2E0630(&vars->velocity); @@ -836,7 +835,7 @@ void FUN_L10_002e01a8(Moby *moby) { FUN_L00_0024f7c8(moby, 0, scratch); coll_sphere_mobys(0.2f, scratch, 0, moby, &scratch[4]); if (func_001F9D10_2E0630(&moby->pos, &target->pos) < one - || *(int *)(D_0013F350 + 0x208C) == 7 + || *(int *)(((char *)&hero) + 0x208C) == 7 || (moby->anim_flags & 2)) { moby->state = 12; if (moby->prev_seq != 3) func_00213DE0_2E0630(moby, 3, 0, func_001F9850_2E0630(2)); @@ -1088,7 +1087,7 @@ void FUN_L10_002e17c0(struct Moby *moby) /* Ported from rac1-decomp (src/overlays/l10_orxon/vendor_00296BD8.c: func_L10_002E3070), where it is exact; names translated to the US level program. */ -extern short D_L10_00161E00 __attribute__((sda)); +extern int D_L10_00161E00 __attribute__((sda)); void FUN_L10_002e1cb0(struct Moby *moby) { short *p; if (moby->group != 0xFF) { @@ -1097,7 +1096,7 @@ void FUN_L10_002e1cb0(struct Moby *moby) { do { int idx = *(unsigned short *)p & 0x7FFF; ((char *)D_L10_0015FFD0_e[2])[(idx << 8) + 0xBC] = - scale_game_frames(*(int *)&D_L10_00161E00); + scale_game_frames(D_L10_00161E00); } while (*p++ >= 0); } } @@ -1259,14 +1258,14 @@ extern int random_integer_below(int) __asm__("FUN_00213260"); extern int tick_countdown_32(void *); extern s32 FUN_L00_0025e3b8(s32); extern s32 truncate_float_to_s32(f32) __asm__("FUN_001fa6d0"); -extern short D_L10_00161E24 __attribute__((sda)); -extern short D_L10_00161E28 __attribute__((sda)); -extern short D_L10_00161E34 __attribute__((sda)); +extern float D_L10_00161E24 __attribute__((sda)); +extern float D_L10_00161E28 __attribute__((sda)); +extern float D_L10_00161E34 __attribute__((sda)); extern f32 D_L10_00161E40_gp __asm__("D_L10_00161E40") __attribute__((sda)); -extern short D_L10_00161E44 __attribute__((sda)); -extern short D_L10_00161E4C __attribute__((sda)); -extern unsigned char D_0013E533[]; -extern unsigned char D_0014C050[]; +extern float D_L10_00161E44 __attribute__((sda)); +extern float D_L10_00161E4C __attribute__((sda)); +#include "rnc/data_labels.h" +#include "rnc/gameplay/state/game_globals.h" extern void *FUN_L00_00263fd8(char *, int, float *, void *, int, int, float, float *, float *, float *); extern void collect_mobies_in_sphere(void *, float, int, void *, void *) __asm__("FUN_L00_001f2868"); @@ -1302,7 +1301,7 @@ void FUN_L10_002e1d38(Moby2E30F8 *m) { FUN_L10_002e3ef0_u(m); t = d->tgt; - m->f2C = *(float *)(m->p24 + 0x24) * *(float *)&D_L10_00161E24; + m->f2C = *(float *)(m->p24 + 0x24) * D_L10_00161E24; FUN_L00_00263ac8(2.5f, (int)m, 2, d->q2B0); *(OvlQuad *)from = *(OvlQuad *)m->pos; from[2] += 1.0f; @@ -1321,7 +1320,7 @@ void FUN_L10_002e1d38(Moby2E30F8 *m) { } switch (m->state) { case 0: - if (d->i1DC != 0 && D_0013E533[0x2EC1] == 1) { + if (d->i1DC != 0 && ((unsigned char *)&D_0013E533)[0x2EC1] == 1) { mark_moby_for_removal(m); return; } @@ -1337,7 +1336,7 @@ void FUN_L10_002e1d38(Moby2E30F8 *m) { d->v170[3] = m->f48; FUN_L01_0026d930((char *)&d->iD0); { - float k = *(float *)&D_L10_00161E24 * 1024.0f; + float k = D_L10_00161E24 * 1024.0f; float s; float e; int r; @@ -1345,7 +1344,7 @@ void FUN_L10_002e1d38(Moby2E30F8 *m) { d->fD8 = 2.0f; r = truncate_float_to_s32(k); s = d->f1A4 * frame_time; - e = *(float *)&D_L10_00161E24; + e = D_L10_00161E24; d->iD0 = r; d->fD4 = e; d->fF4 = s; @@ -1359,7 +1358,7 @@ void FUN_L10_002e1d38(Moby2E30F8 *m) { (((short)p->id >> 5) * 4 + (current_level_index << 8))) >> (p->id & 0x1F)) & 1) && - D_0014C050[p->bB0 + (current_level_index << 4)] == 0xFF)) { + visited52[p->bB0 + (current_level_index << 4)] == 0xFF)) { d->i1BC = -1; } } @@ -1485,7 +1484,7 @@ void FUN_L10_002e1d38(Moby2E30F8 *m) { d->fF4 = lim; } } - if (*(float *)&D_L10_00161E4C * DEG_TO_RAD < diff || d->i1D8 == 0) { + if (D_L10_00161E4C * DEG_TO_RAD < diff || d->i1D8 == 0) { FUN_L00_00258278((char *)m, &d->f190, ang, 0.02f, 0.3f, frame_time * 6.2831855f); } aim = FUN_L10_002e4840((struct Moby *)m); @@ -1512,7 +1511,7 @@ void FUN_L10_002e1d38(Moby2E30F8 *m) { char *h = D_L10_001742C0; if ((*(char **)(h + 0x18) == 0 || *(short *)(*(char **)(h + 0x18) + 0xA6) != 0x31A) && - FUN_001f9b48(from2, h + 0x20) < *(float *)&D_L10_00161E34) { + FUN_001f9b48(from2, h + 0x20) < D_L10_00161E34) { m->state = 6; d->i1A8 = scale_game_frames(0x3C); if (m->anim != 1) { @@ -1531,7 +1530,7 @@ void FUN_L10_002e1d38(Moby2E30F8 *m) { } if (D_L10_0015F5CC % 7 == 0 && d->i1A8 == 0) { if (FUN_001f9b80(d->v1C0, m->pos) < d->fF4 && - diff <= *(float *)&D_L10_00161E4C * DEG_TO_RAD) { + diff <= D_L10_00161E4C * DEG_TO_RAD) { m->state = 6; d->i1A8 = scale_game_frames(0x3C); if (m->anim != 1) { @@ -1595,7 +1594,7 @@ void FUN_L10_002e1d38(Moby2E30F8 *m) { d->fF4 = lim; } } - if (tick_countdown_32(&d->i1A8) || *(float *)&D_L10_00161E4C * DEG_TO_RAD < diff) { + if (tick_countdown_32(&d->i1A8) || D_L10_00161E4C * DEG_TO_RAD < diff) { float from2[4]; float to2[4]; int ok = 1; @@ -1607,7 +1606,7 @@ void FUN_L10_002e1d38(Moby2E30F8 *m) { char *h = D_L10_001742C0; if ((*(char **)(h + 0x18) == 0 || *(short *)(*(char **)(h + 0x18) + 0xA6) != 0x31A) && - FUN_001f9b48(from2, h + 0x20) < *(float *)&D_L10_00161E34) { + FUN_001f9b48(from2, h + 0x20) < D_L10_00161E34) { ok = 0; } } @@ -1628,7 +1627,7 @@ void FUN_L10_002e1d38(Moby2E30F8 *m) { } else if (FUN_001f9b80(m->pos, t + 0x10) < (*(short *)(t + 0xA6) == 0x359 ? 2.45f : 4.02f)) { if (hero.invulnerable_frames < scale_game_frames(10) && - diff < *(float *)&D_L10_00161E4C * DEG_TO_RAD && see) { + diff < D_L10_00161E4C * DEG_TO_RAD && see) { int anim = 7; if (random_integer_below(100) & 1) { anim = 6; @@ -1678,7 +1677,7 @@ void FUN_L10_002e1d38(Moby2E30F8 *m) { } } else if (m->anim >= 6 && m->anim <= 7 && (m->b70 & 2)) { float home = FUN_001f9b48(m->pos, d->v170); - if ((D_0013E533[0x2EC1] == 1 ? 1.0f : 30.0f) < home || d->i164 == 2) { + if ((((unsigned char *)&D_0013E533)[0x2EC1] == 1 ? 1.0f : 30.0f) < home || d->i164 == 2) { m->state = 8; blend_moby_animation(m, 4, 0, scale_game_frames(0xC)); } else { @@ -1714,7 +1713,7 @@ void FUN_L10_002e1d38(Moby2E30F8 *m) { m->f48 = rot; if (see) { if (tick_countdown_32(&d->i1A8) || - *(float *)&D_L10_00161E44 < FUN_001f9b48(m->pos, t + 0x10)) { + D_L10_00161E44 < FUN_001f9b48(m->pos, t + 0x10)) { int anim; m->state = 7; d->fF4 = frame_time * 5.0f; @@ -1801,7 +1800,7 @@ void FUN_L10_002e1d38(Moby2E30F8 *m) { m->s34 &= 0xEFFF; m->state = 0xB; q = truncate_float_to_s32(768.0f); - x = *(float *)&D_L10_00161E28 * frame_time_sq; + x = D_L10_00161E28 * frame_time_sq; d->bAD = 0; d->i90 = q; d->f98 = 0.75f; @@ -2082,7 +2081,6 @@ extern int func_L00_00260FB0_2E52B0(float, void *, void *, int, int, void *, int extern float func_001F9D48_2E52B0(void *, void *) __asm__("FUN_001f9b80"); extern float func_001F9D10_2E52B0(void *, void *) __asm__("FUN_001f9b48"); extern void func_00213DE0_2E52B0(void *, int, int, int) __asm__("FUN_00212f90"); -extern char D_0013F350[]; extern char D_0013D50F_2E52B0[] __asm__("D_0013D408"); extern V_2E52B0 D_L10_00174380_2E52B0 __asm__("D_L10_00174300"); extern Path_2E52B0 *D_L10_001B0C30_2E52B0[] __asm__("D_L10_001B0930"); @@ -2102,8 +2100,8 @@ void FUN_L10_002e3ef0(void *mv) { Moby *q; int v21; - if (((Hero *)(D_0013F350))->items[0].item_id == 0x15) { - if (((D_2E52B0 *)((Hero *)(D_0013F350))->items[0].moby->pvars)->f10 == m) { + if (((Hero *)(((char *)&hero)))->items[0].item_id == 0x15) { + if (((D_2E52B0 *)((Hero *)(((char *)&hero)))->items[0].moby->pvars)->f10 == m) { func_L10_002E14F8_2E52B0(m); if (m->state == 1) m->state = 2; } @@ -2131,9 +2129,9 @@ void FUN_L10_002e3ef0(void *mv) { v21 = 11; if (B < 3.0f) B = 0.0f; } - if (((Hero *)(D_0013F350))->state.current == 32 - || (((Hero *)(D_0013F350))->state.prev == 32 - && ((Hero *)(D_0013F350))->state_timer < func_001F9850_2E52B0(30))) { + if (((Hero *)(((char *)&hero)))->state.current == 32 + || (((Hero *)(((char *)&hero)))->state.prev == 32 + && ((Hero *)(((char *)&hero)))->state_timer < func_001F9850_2E52B0(30))) { if (2.0f < B) B = 2.0f; } if (r->h2A == m->oclass) { @@ -2141,14 +2139,14 @@ void FUN_L10_002e3ef0(void *mv) { v21 = 11; } if ((unsigned int)(m->prev_seq - 6) < 2) { - if (((Hero *)(D_0013F350))->vehicle_mode == 1 - && r->f20 == ((Hero *)(D_0013F350))->moby) { + if (((Hero *)(((char *)&hero)))->vehicle_mode == 1 + && r->f20 == ((Hero *)(((char *)&hero)))->moby) { B = 0.0f; v21 = 11; } } if (r->h2A == 0x47) { - *(u128_2E52B0 *)&vA = *(u128_2E52B0 *)(D_0013F350 + 0x80); + *(u128_2E52B0 *)&vA = *(u128_2E52B0 *)(((char *)&hero) + 0x80); *(u128_2E52B0 *)&vB = *(u128_2E52B0 *)((V_2E52B0 *)&m->pos); vA.z += 1.0f; vB.z += 1.0f; @@ -2205,7 +2203,7 @@ void FUN_L10_002e3ef0(void *mv) { m->state = 10; d->h26 = func_001F9850_2E52B0(60); d->f80 = D_L10_00161E2C * D_0015ED70; - s = ((Hero *)(D_0013F350))->vehicle_mode == 1 ? 1.0f : 3.0f; + s = ((Hero *)(((char *)&hero)))->vehicle_mode == 1 ? 1.0f : 3.0f; trooper_set_knockback(d->a70, s, 0.5f); d->fC0 = 3.5f; d->fC4 = 7.0f; @@ -2235,12 +2233,12 @@ void FUN_L10_002e3ef0(void *mv) { if (d->f1AC != 0) { d->f1A0 = D_L10_00161E40_gp + 6.0f; } else if (m->state == 1) { - if (m == ((Moby *)((Hero *)(D_0013F350))->unk240) || m == ((Moby *)((Hero *)(D_0013F350))->coll_hit_moby)) { + if (m == ((Moby *)((Hero *)(((char *)&hero)))->unk240) || m == ((Moby *)((Hero *)(((char *)&hero)))->coll_hit_moby)) { d->f1A0 = 6.0f; } else { d->f1A0 = 0.0f; } - if (((Hero *)(D_0013F350))->vehicle_mode == 1) func_L10_002E14F8_2E52B0(m); + if (((Hero *)(((char *)&hero)))->vehicle_mode == 1) func_L10_002E14F8_2E52B0(m); } else { d->f1A0 = D_L10_00161E40_gp; } @@ -2262,7 +2260,7 @@ void FUN_L10_002e3ef0(void *mv) { if (1.0f < func_001F9D10_2E52B0(&m->pos, &d->a170)) { m->state = 8; if (m->prev_seq != 4) func_00213DE0_2E52B0(m, 4, 0, func_001F9850_2E52B0(12)); - } else if (((Hero *)(D_0013F350))->vehicle_mode != 1) { + } else if (((Hero *)(((char *)&hero)))->vehicle_mode != 1) { m->state = 1; if (m->prev_seq != 0) func_00213DE0_2E52B0(m, 0, 0, func_001F9850_2E52B0(20)); } @@ -2270,7 +2268,7 @@ void FUN_L10_002e3ef0(void *mv) { } else { d->f1D4 = 0; } - if (d->f160 == 0) d->f160 = ((Hero *)(D_0013F350))->moby; + if (d->f160 == 0) d->f160 = ((Hero *)(((char *)&hero)))->moby; } #define NOT_SDA @@ -2285,10 +2283,10 @@ extern float FUN_001f9dc8(float); extern float FUN_001f9de0(float); extern float fast_subtract_rotations(float, float) __asm__("FUN_001fa5c8"); extern float FUN_001f9e90(float, float); -extern unsigned char D_0013E533[]; +#include "rnc/data_labels.h" extern void FUN_001f9a10(void *, void *, void *); -extern short D_L10_00161E48 __attribute__((sda)); +extern float D_L10_00161E48 __attribute__((sda)); float FUN_L10_002e4840(struct Moby *self) { char *owner = *(char **)(self->pvars + 0x160); float hi, lo, ang, dist, v[3]; @@ -2297,15 +2295,15 @@ float FUN_L10_002e4840(struct Moby *self) { return FUN_001f9e90(self->pos.x - *(float *)(owner + 0x10), self->pos.y - *(float *)(owner + 0x14)); } - lo = -(*(float *)&D_L10_00161E48 * DEG_TO_RAD); - hi = *(float *)&D_L10_00161E48 * DEG_TO_RAD; + lo = -(D_L10_00161E48 * DEG_TO_RAD); + hi = D_L10_00161E48 * DEG_TO_RAD; ang = FUN_001f9e90(self->pos.x - *(float *)(owner + 0x10), self->pos.y - *(float *)(owner + 0x14)); dist = FUN_001f9b48(owner + 0x10, &self->pos); v[0] = FUN_001f9dc8(ang) * 2.0f; v[1] = FUN_001f9de0(ang) * 2.0f; v[2] = 0.0f; - FUN_001f9a10(v, v, D_0013E533 + 0xE9D); + FUN_001f9a10(v, v, ((unsigned char *)&D_0013E533) + 0xE9D); p = D_L10_001ABCC0[self->group]; if (p != 0) { do { @@ -2407,7 +2405,6 @@ extern char D_L10_00179890[]; extern char D_L10_001DD390[]; extern f32 fast_arc_tan(f32, f32) __asm__("func_001F9E90"); extern f32 fast_vec_length_c(void *) __asm__("func_001F9AF0"); -extern float D_0015ED60; extern float FUN_L00_00258110_c(float *vel, float cur, float target, float k, float d, float max) __asm__("FUN_L00_00258110"); extern float fast_difference_between_rotations_c2(float, float) __asm__("func_001FA688"); extern float fast_vec_dist(void *, void *); @@ -2418,9 +2415,9 @@ extern int is_point_inside_clip_volume(void *arg0, int arg1) __asm__("func_00214 extern s32 D_0015ED84; extern s32 scale_game_frames_c2(s32) __asm__("func_001F96F8"); extern s32 truncate_float_to_s32_c2(f32) __asm__("func_001FA6D0"); -extern short D_L10_00161EE4 __attribute__((sda)); -extern short D_L10_00161EE8 __attribute__((sda)); -extern short D_L10_00161EEC __attribute__((sda)); +extern int D_L10_00161EE4 __attribute__((sda)); +extern float D_L10_00161EE8 __attribute__((sda)); +extern float D_L10_00161EEC __attribute__((sda)); extern unsigned char D_0013D4CB[]; extern unsigned char D_001413F4[]; extern unsigned char D_0014161B[]; @@ -2469,12 +2466,12 @@ void FUN_L10_002e4a88(Ship_5E48 *m) { d->f19C = 0.0f; m->s32 = 0x7F; qcopy(&m->pos, &D_L10_001B0C30_2E52B0[d->i140]->nodes[0]); - d->s196 = scale_game_frames_c2(*(int *)&D_L10_00161EE4); + d->s196 = scale_game_frames_c2(D_L10_00161EE4); m->i94 = 0; m->s34 |= 0x41; if (m->b53 != 0) blend_moby_animation(m, 0, 0, 0); m->state = 1; - if (D_0014C050[m->bB0 + (D_0015ED84 << 4)] != 0xFF) break; + if (visited52[m->bB0 + (D_0015ED84 << 4)] != 0xFF) break; goto del; case 1: if (!is_point_inside_clip_volume(&tgt->pos, d->i148)) break; @@ -2545,7 +2542,7 @@ void FUN_L10_002e4a88(Ship_5E48 *m) { m->f44 = FUN_L00_00258110_c(&d->f19C, m->f44, -b, 0.02f, 0.3f, D_0015ED6C * 3.1415927f); if (fast_difference_between_rotations_c2(m->f48, fast_arc_tan(tgt->pos.x - m->pos.x, tgt->pos.y - m->pos.y)) < 0.17453292f) { if (m->b53 != 3) blend_moby_animation(m, 3, 0, scale_game_frames_c2(6)); - m->f58 = *(float *)&D_L10_00161EEC; + m->f58 = D_L10_00161EEC; } if (m->b52 == 3 && d->i114 != 2 && D_L10_001742D8 == tgt) { int near = is_value_within_interpolated_window((char *)m, 1.0f); @@ -2555,7 +2552,7 @@ void FUN_L10_002e4a88(Ship_5E48 *m) { build_spherical_offset_c(&B, 1.0f, m->f48, -m->f44); FUN_L00_001ff290(&D, &C, &B); func_001F9BF0_2E52B0(&B, &A, &C); - fast_vec_normalize(&B, &B, *(float *)&D_L10_00161EE8 * D_0015ED6C); + fast_vec_normalize(&B, &B, D_L10_00161EE8 * D_0015ED6C); fast_vec_scale(&E, &B, FUN_001f96b0(3.0f)); FUN_L00_001ff290(&D, &E, &C); FUN_L03_00250ae8(m, &E, 0); @@ -2603,7 +2600,7 @@ void FUN_L10_002e4a88(Ship_5E48 *m) { m->f44 = FUN_L00_00258110_c(&d->f19C, m->f44, -b, 0.02f, 0.3f, D_0015ED6C * 3.1415927f); if (tick_countdown_32_alt(&d->i168)) { blend_moby_animation(m, 3, 0, scale_game_frames_c2(10)); - m->f58 = *(float *)&D_L10_00161EEC; + m->f58 = D_L10_00161EEC; m->state = 4; d->i168 = truncate_float_to_s32_c2(FUN_001f96b0(d->f160 * 60.0f)); } @@ -2618,7 +2615,7 @@ void FUN_L10_002e4a88(Ship_5E48 *m) { break; case 6: m->pos.z += D_0015ED6C * 10.0f; - m->f2C *= D_0015ED60 * -0.015299976f + 1.0f; + m->f2C *= frame_scale * -0.015299976f + 1.0f; if (250.0f < m->pos.z) goto del; if (!(m->f2C < 0.01f)) break; goto del; @@ -2629,7 +2626,7 @@ void FUN_L10_002e4a88(Ship_5E48 *m) { next = m->bBC; if (next == 4) { blend_moby_animation(m, 3, 0, scale_game_frames_c2(10)); - m->f58 = *(float *)&D_L10_00161EEC; + m->f58 = D_L10_00161EEC; m->state = next; d->i168 = truncate_float_to_s32_c2(FUN_001f96b0(d->f160 * 60.0f)); } else if (next == 6) { @@ -3356,7 +3353,7 @@ extern float fast_add_rotations_alt(float) __asm__("FUN_001fa580"); extern float fast_cos_local(float, float) __asm__("FUN_001f9dc8"); extern int D_0013DD4C; /* no foreign declaration */ extern unsigned char D_0014C190_c[] __asm__("D_0014C190"); -extern GateMoby_2EAD50 *D_L10_0015FFD8_c __asm__("D_L10_0015FFD8") __attribute__((sda)); +extern struct Moby * D_L10_0015FFD8_gp __asm__("D_L10_0015FFD8") __attribute__((sda)); extern s32 FUN_001f96b0_c(f32) __asm__("FUN_001f96b0"); extern unsigned char D_001413F4[]; extern void add_vector_xyz_c(void *, void *, void *) __asm__("FUN_001f9a10"); @@ -3395,7 +3392,7 @@ void FUN_L10_002e9990(GateMoby_2EAD50 *m) m->pos = out; } else { if (d->door > 0) { - D_L10_0015FFD8_c[d->door].flags |= 2; + (*(GateMoby_2EAD50 * *)&D_L10_0015FFD8_gp)[d->door].flags |= 2; } m->state = 1; } @@ -3408,11 +3405,11 @@ void FUN_L10_002e9990(GateMoby_2EAD50 *m) m->pos = d->home; m->state = 3; if (d->door > 0) { - D_L10_0015FFD8_c[d->door].flags &= 0xFFFD; + (*(GateMoby_2EAD50 * *)&D_L10_0015FFD8_gp)[d->door].flags &= 0xFFFD; } } else if (D_0013DE4B_2EAD50[0] != 0) { if (d->door > 0) { - D_L10_0015FFD8_c[d->door].flags &= 0xFFFD; + (*(GateMoby_2EAD50 * *)&D_L10_0015FFD8_gp)[d->door].flags &= 0xFFFD; } *(int *)(bits + ((((short)m->uid >> 5) * 4) + (current_level_index << 8))) |= st << (m->uid & 0x1F); D_L10_001BA950[(short)m->uid >> 5] |= st << (m->uid & 0x1F); diff --git a/src/overlays/l12/gameplay/entities/003054b0.c b/src/overlays/l12/gameplay/entities/003054b0.c index e7fbd920c1..dc43ec3643 100644 --- a/src/overlays/l12/gameplay/entities/003054b0.c +++ b/src/overlays/l12/gameplay/entities/003054b0.c @@ -40,7 +40,7 @@ typedef struct { } Gun_306890; extern char *FUN_L00_0025a420(void *, int, int); -extern char D_0013F350[] __attribute__((section(".data"))); +extern struct Hero hero_lui __asm__("D_0013F350") __attribute__((section(".data"))); extern char D_L12_00167240[]; extern f32 convert_integer_to_float(s32) __asm__("func_001FA6C0"); extern f32 fast_arc_tan(f32, f32) __asm__("func_001F9E90"); @@ -81,7 +81,6 @@ extern void build_spherical_offset(void *, f32, f32, f32) __asm__("func_00214DB0 float absolute_float(float input) __asm__("func_001F99C0"); void FUN_L12_00306350_c2(struct Moby *moby, int slot) __asm__("FUN_L12_00306350"); extern float random_angle_radians(void) __asm__("FUN_00213308"); -extern char D_0013F350[]; extern float func_001F9B88_304310(float) __asm__("FUN_001f99c0"); extern char D_L12_00167240[]; extern int func_001F9908_304920(void *) __asm__("FUN_001f9740"); @@ -128,8 +127,8 @@ void FUN_L12_003054b0(char *moby) { v1[2] += 1.5f; md->f60 = fast_arc_tan(vector_distance_xy_alt(v1, v0), v0[2] - v1[2]); FUN_L00_002628d8(m, (char *)md, 0, D_0015ED64 * 0.008f, D_0015ED64 * 0.3f); - yaw = fast_subtract_rotations(fast_add_rotations(fast_arc_tan(((Hero *)D_0013F350)->motion.pos.f[0] - *(float *)(m + 0x10), - ((Hero *)D_0013F350)->motion.pos.f[1] - *(float *)(m + 0x14)), + yaw = fast_subtract_rotations(fast_add_rotations(fast_arc_tan(((Hero *)((char *)&hero))->motion.pos.f[0] - *(float *)(m + 0x10), + ((Hero *)((char *)&hero))->motion.pos.f[1] - *(float *)(m + 0x14)), -1.5707964f), *(float *)(moby + 0x48)); if (md->h90 == 0) { @@ -150,7 +149,7 @@ void FUN_L12_003054b0(char *moby) { } } flag = 0; - hp = (float *)(D_0013F350 + 0x80); + hp = (float *)(((char *)&hero) + 0x80); dist = vector_distance_xy_alt(moby + 0x10, hp); dz = func_001F9B88_304310(hp[2] - *(float *)(moby + 0x18)); if (scale_game_frames(0x4B0) < D_L12_00161F34) { @@ -186,7 +185,7 @@ void FUN_L12_003054b0(char *moby) { qcopy(v2, D_L12_00167240); v2[2] += random_float_between_c(-1.5f, 0.3f); } else { - qcopy(v2, &((Hero *)D_0013F350)->motion.unkD0); + qcopy(v2, &((Hero *)((char *)&hero))->motion.unkD0); v2[2] += FUN_L00_00257c48(0.0f, 0.5f); } n = D_L12_00161F20 - 3; @@ -481,15 +480,10 @@ void FUN_L12_003064e8(char *moby) { FUN_L00_00250df8_c(obj); } } -#ifndef NON_MATCHING -INCLUDE_ASM("config/us/overlays/asm/FUN_L12_00306828.s", FUN_L12_00306828); -#else -extern int D_L12_0015F5CC; -extern float convert_integer_to_float(int) __asm__("FUN_001fa6c0"); -extern float fast_sin(float) __asm__("FUN_001f9de0"); -extern int truncate_float_to_s32(float) __asm__("FUN_001fa6d0"); +/* Ported from rac1-decomp (src/overlays/l12_hoven/vendor_002EDAA0.c: func_L12_00307C08), where it is exact; names translated to the US level program. */ -extern char *D_L12_0015FFD8_lui __asm__("D_L12_0015FFD8") __attribute__((section(".data"))); +extern int D_L12_0015F5CC; +extern unsigned char * D_L12_0015FFD8; void FUN_L12_00306828(struct Moby *moby) { int i; @@ -500,18 +494,20 @@ void FUN_L12_00306828(struct Moby *moby) { int period; float sine; float color; - unsigned int red; + int red; int green; int blue; int packed_color; float phase; float divisor; - other = moby; - if (i != 17) { - other = (struct Moby *)(((unsigned int)*(int *)(data + i * 0x30 + 0x20) << 8) + (unsigned int)D_L12_0015FFD8_lui); + if (i == 17) { + other = moby; + } else { + other = (struct Moby *)((char *)(*(struct Moby * *)&D_L12_0015FFD8_p) + ((unsigned int)*(int *)(data + i * 0x30 + 0x20) << 8)); } - if (other->oclass != 0x4FE) { - period = scale_ticks(0xAA); + if (other->oclass == 0x4FE) continue; + { + period = scale_game_frames(0xAA); divisor = convert_integer_to_float(period); phase = (float)(D_L12_0015F5CC % period) / divisor; sine = fast_sin((phase + phase) * 3.1415927f + -3.1415927f); @@ -519,15 +515,17 @@ void FUN_L12_00306828(struct Moby *moby) { red = truncate_float_to_s32(color); green = truncate_float_to_s32(color); blue = truncate_float_to_s32(sine * 10.0f); - packed_color = ((blue + 0x46) << 16) | - (alpha | ((green + 0xB4 > 0xFF ? 0xFF : green + 0xB4) << 8)) | - ((int)(red + 0xB4) > 0xFF ? 0xFF : red + 0xB4); + packed_color = ((blue + 0x46) << 16) | alpha | + ((green + 0xB4 > 0xFF ? 0xFF : green + 0xB4) << 8) | + (red + 0xB4 > 0xFF ? 0xFF : red + 0xB4); other->flags |= 0x10; other->glow_color = packed_color; } } + /* Fakematch: keeping alpha live past the loop gives retail's schedule of the loop body. */ + alpha++; + alpha--; } -#endif /* NON_MATCHING */ /* Planetbuster part update: rides its path, drops its parts and hands its voice slot back when done. */ /* Ported from rac1-decomp (src/overlays/l12_hoven/vendor_002EDAA0.c: func_L12_00307DB0), where it is exact; names translated to the US level program. */ @@ -567,10 +565,10 @@ extern int is_point_inside_clip_volume_c(void *arg0, int arg1) __asm__("func_002 extern int tick_countdown_32_alt(int *) __asm__("FUN_001f9740"); extern s32 scale_game_frames(s32) __asm__("func_001F96F8"); -extern short D_L12_00161F28 __attribute__((sda)); -extern short D_L12_00161F2C __attribute__((sda)); -extern short D_L12_00161F30 __attribute__((sda)); -extern unsigned char D_0014C050[]; +extern float D_L12_00161F28 __attribute__((sda)); +extern float D_L12_00161F2C __attribute__((sda)); +extern float D_L12_00161F30 __attribute__((sda)); +#include "rnc/gameplay/state/game_globals.h" extern void FUN_L00_00258278(char *moby, float target, float *vel, float k, float d, float max); extern void FUN_L00_0025b8c0(float *, float *, float, float, float, float); extern void FUN_L00_00262b00(float, float, char *, float *, float *); @@ -592,7 +590,6 @@ extern void release_voice_slot(s32) __asm__("FUN_0022d798"); extern void subtract_vector_xyz(void *, void *, void *) __asm__("FUN_001f9a28"); void FUN_L12_003054b0_u(void *moby) __asm__("FUN_L12_003054b0"); void FUN_L12_00306350_c(struct Moby *moby, int slot) __asm__("FUN_L12_00306350"); -void FUN_L12_00306828(struct Moby *moby); extern int current_level_index_gp __asm__("D_0015ED84") __attribute__((section(".sdata"))); extern char D_0013F3D0[]; extern int D_L12_00161F00_gp __asm__("D_L12_00161F00") __attribute__((section(".sdata"))); @@ -610,7 +607,7 @@ void FUN_L12_003069d0(char *moby) { switch ((unsigned char)moby[0x20]) { case 0: D_L12_001619B4 = 0; - if (D_0014C050[(unsigned char)moby[0xB0] + (current_level_index_gp << 4)] == 0xFF) { + if (visited52[(unsigned char)moby[0xB0] + (current_level_index_gp << 4)] == 0xFF) { int i; for (i = 0; i < 17; i++) { int s = *(int *)(d + i * 0x30 + 0x20); @@ -678,9 +675,9 @@ void FUN_L12_003069d0(char *moby) { D_0015ED64 * 0.03f, D_0015ED64 * 0.3f, D_0015ED6C_gp * 2.7f); } FUN_L00_00262b00(0.7f, D_0015ED6C_gp * 1.2217305f, moby, (float *)(d + 0x5CC), (float *)(d + 0x5C8)); - FUN_L00_00262b80(moby, d + 0x5E4, d + 0x5E8, *(float *)&D_L12_00161F30, - *(float *)&D_L12_00161F28 * 0.017453292f * D_0015ED6C_gp, - *(float *)&D_L12_00161F2C * 0.017453292f * D_0015ED6C_gp); + FUN_L00_00262b80(moby, d + 0x5E4, d + 0x5E8, D_L12_00161F30, + D_L12_00161F28 * 0.017453292f * D_0015ED6C_gp, + D_L12_00161F2C * 0.017453292f * D_0015ED6C_gp); FUN_L12_0027b370(moby, d, 0x11); if (is_point_inside_clip_volume_c(D_0013F3D0, *(int *)(d + 0x5EC)) || D_L12_00161F00_gp) { int i; @@ -698,9 +695,9 @@ void FUN_L12_003069d0(char *moby) { int nx; float f; FUN_L00_00262b00(0.7f, D_0015ED6C_gp * 1.2217305f, moby, (float *)(d + 0x5CC), (float *)(d + 0x5C8)); - FUN_L00_00262b80(moby, d + 0x5E4, d + 0x5E8, *(float *)&D_L12_00161F30, - *(float *)&D_L12_00161F28 * 0.017453292f * D_0015ED6C_gp, - *(float *)&D_L12_00161F2C * 0.017453292f * D_0015ED6C_gp); + FUN_L00_00262b80(moby, d + 0x5E4, d + 0x5E8, D_L12_00161F30, + D_L12_00161F28 * 0.017453292f * D_0015ED6C_gp, + D_L12_00161F2C * 0.017453292f * D_0015ED6C_gp); path = ((P_7DB0 * *)&D_L12_001B0930)[*(int *)(d + 0x5C0)]; if (*(short *)(d + 0x5F8) < *(int *)path - 11) { approach_value((float *)(d + 0x5F0), D_0015ED6C_gp * 8.0f, D_0015ED70 * 10.0f); @@ -733,9 +730,9 @@ void FUN_L12_003069d0(char *moby) { D_L12_00161F34++; FUN_L00_0025bc98(moby + 0x48, 3.0543261f, d + 0x5F4, -1, D_0015ED64 * 0.0015f, D_0015ED64 * 0.3f, D_0015ED6C_gp * 0.17453292f); FUN_L00_00262b00(0.7f, D_0015ED6C_gp * 1.2217305f, moby, (float *)(d + 0x5CC), (float *)(d + 0x5C8)); - FUN_L00_00262b80(moby, d + 0x5E4, d + 0x5E8, *(float *)&D_L12_00161F30, - *(float *)&D_L12_00161F28 * 0.017453292f * D_0015ED6C_gp, - *(float *)&D_L12_00161F2C * 0.017453292f * D_0015ED6C_gp); + FUN_L00_00262b80(moby, d + 0x5E4, d + 0x5E8, D_L12_00161F30, + D_L12_00161F28 * 0.017453292f * D_0015ED6C_gp, + D_L12_00161F2C * 0.017453292f * D_0015ED6C_gp); FUN_L12_0027b370(moby, d, 0x11); FUN_L12_003054b0_u(moby); break; @@ -979,7 +976,7 @@ void FUN_L12_00307ab8(struct Moby *m) { } #include "rnc/gameplay/entities/moby.h" -extern unsigned char D_0014C050[]; +#include "rnc/gameplay/state/game_globals.h" extern int FUN_L01_00275690(void *, float); extern int FUN_0022da68(int, int, void *); @@ -996,7 +993,7 @@ void FUN_L12_003081b0(struct Moby *m) { switch (st) { case 0: - if (m->mission != 0xFF && D_0014C050[m->mission + current_level_index * 16] == 0xFF) { + if (m->mission != 0xFF && visited52[m->mission + current_level_index * 16] == 0xFF) { mark_moby_for_removal(m); break; } diff --git a/src/overlays/l12/gameplay/entities/platform.c b/src/overlays/l12/gameplay/entities/platform.c index 935bb407ba..41e20d2c91 100644 --- a/src/overlays/l12/gameplay/entities/platform.c +++ b/src/overlays/l12/gameplay/entities/platform.c @@ -332,20 +332,20 @@ extern s32 truncate_float_to_s32(f32) __asm__("FUN_001fa6d0"); extern void clear_u64_value(void *) __asm__("FUN_001f99f8"); extern int func_001FA898_r(float) __asm__("FUN_001fa6d0"); -extern short D_L12_00161888 __attribute__((sda)); -extern short D_L12_0016188C __attribute__((sda)); -extern short D_L12_00161890 __attribute__((sda)); -extern short D_L12_00161894 __attribute__((sda)); -extern short D_L12_00161898 __attribute__((sda)); -extern short D_L12_0016189C __attribute__((sda)); -extern short D_L12_001618A0 __attribute__((sda)); -extern short D_L12_001618A4 __attribute__((sda)); -extern short D_L12_001618AC __attribute__((sda)); -extern short D_L12_001618B0 __attribute__((sda)); -extern short D_L12_001618B4 __attribute__((sda)); -extern short D_L12_001618B8 __attribute__((sda)); -extern short D_L12_001618BC __attribute__((sda)); -extern short D_L12_001618C0 __attribute__((sda)); +extern float D_L12_00161888 __attribute__((sda)); +extern float D_L12_0016188C __attribute__((sda)); +extern float D_L12_00161890 __attribute__((sda)); +extern float D_L12_00161894 __attribute__((sda)); +extern float D_L12_00161898 __attribute__((sda)); +extern float D_L12_0016189C __attribute__((sda)); +extern float D_L12_001618A0 __attribute__((sda)); +extern float D_L12_001618A4 __attribute__((sda)); +extern int D_L12_001618AC __attribute__((sda)); +extern int D_L12_001618B0 __attribute__((sda)); +extern int D_L12_001618B4 __attribute__((sda)); +extern int D_L12_001618B8 __attribute__((sda)); +extern int D_L12_001618BC __attribute__((sda)); +extern int D_L12_001618C0 __attribute__((sda)); int D_L12_001618C4 = 0xa0f0e8e0; int D_L12_001618C8 = 0x20f0e8e0; int D_L12_001618CC = 0x10017; @@ -366,25 +366,25 @@ void FUN_L12_002e19a8(void *pos) { w[0] = w[0] + random_float_between_alt(-0.25f, 0.25f); w[1] = w[1] + random_float_between_alt(-0.25f, 0.25f); clear_u64_value(v3); - v4[0] = fast_cos(r) * (random_float_between_alt(*(float *)&D_L12_00161898, - *(float *)&D_L12_0016189C) * + v4[0] = fast_cos(r) * (random_float_between_alt(D_L12_00161898, + D_L12_0016189C) * frame_time); - v4[1] = fast_sin(r) * (random_float_between_alt(*(float *)&D_L12_00161898, - *(float *)&D_L12_0016189C) * + v4[1] = fast_sin(r) * (random_float_between_alt(D_L12_00161898, + D_L12_0016189C) * frame_time); *(int *)&v4[2] = 0; - v3[2] = random_float_between_alt(*(float *)&D_L12_00161888, *(float *)&D_L12_0016188C) * + v3[2] = random_float_between_alt(D_L12_00161888, D_L12_0016188C) * frame_time; - v4[2] = random_float_between_alt(*(float *)&D_L12_00161890, *(float *)&D_L12_00161894) * + v4[2] = random_float_between_alt(D_L12_00161890, D_L12_00161894) * frame_time; - v3[3] = *(float *)&D_L12_001618A0; - v4[3] = *(float *)&D_L12_001618A4; - a = func_001FA898_r(random_float_between_alt((float)*(int *)&D_L12_001618AC, - (float)*(int *)&D_L12_001618B0)); - b = func_001FA898_r(random_float_between_alt((float)*(int *)&D_L12_001618B4, - (float)*(int *)&D_L12_001618B8)); - c = func_001FA898_r(random_float_between_alt((float)*(int *)&D_L12_001618BC, - (float)*(int *)&D_L12_001618C0)); + v3[3] = D_L12_001618A0; + v4[3] = D_L12_001618A4; + a = func_001FA898_r(random_float_between_alt((float)D_L12_001618AC, + (float)D_L12_001618B0)); + b = func_001FA898_r(random_float_between_alt((float)D_L12_001618B4, + (float)D_L12_001618B8)); + c = func_001FA898_r(random_float_between_alt((float)D_L12_001618BC, + (float)D_L12_001618C0)); spawn_spark(w, v3, v4, D_L12_001618C4, D_L12_001618C8, a, b, c, D_L12_001618CC); } while (--i >= 0); @@ -1161,7 +1161,7 @@ extern void FUN_001f9a28(void *, void *, void *); extern void transform_vector(void *, void *, void *) __asm__("FUN_001f9d20"); extern void euler_rotation_matrix(void *, void *) __asm__("FUN_001fa050"); -extern short D_L12_00161914 __attribute__((sda)); +extern float D_L12_00161914 __attribute__((sda)); void FUN_L12_002e3e28(struct Moby *moby, float *out, int on) { float m[4]; float a[4]; @@ -1174,7 +1174,7 @@ void FUN_L12_002e3e28(struct Moby *moby, float *out, int on) { m[2] = -moby->rot.z; euler_rotation_matrix(b, m); transform_vector(a, a, b); - g = *(float *)&D_L12_00161914; + g = D_L12_00161914; out[1] = a[0] / g; out[0] = -a[1] / g; } else { @@ -1228,7 +1228,6 @@ typedef struct { int fFC; } Data_2E51E8; -extern Moby *D_L12_0015FFD8; extern char *D_L12_001B0930[]; extern f32 distance_xyz(void *, void *) __asm__("func_001F9B48"); extern f32 fast_add_rotations_c2(f32, f32) __asm__("func_001FA580"); @@ -1269,7 +1268,7 @@ void FUN_L12_002e3ed8(Moby *moby) { data = (*(Data_2E51E8 **)&moby->pvars); qcopy(oldPos, (*(float (*)[4])&moby->pos)); qcopy(oldRot, (*(float (*)[4])&moby->rot)); - if (moby->state != 0 && data->fFC != -1 && (signed char)D_L12_0015FFD8[data->fFC].state >= 0) { + if (moby->state != 0 && data->fFC != -1 && (signed char)(*(Moby * *)&D_L12_0015FFD8_p)[data->fFC].state >= 0) { FUN_L12_002e3948_c((char *)moby); return; } @@ -1455,7 +1454,7 @@ void FUN_L12_002e3ed8(Moby *moby) { } break; case 9: { - Moby *o = (Moby *)((char *)D_L12_0015FFD8 + (data->fF0 << 8)); + Moby *o = (Moby *)((char *)(*(Moby * *)&D_L12_0015FFD8_p) + (data->fF0 << 8)); qcopy(angles, (*(float (*)[4])&moby->pos)); angles[2] = (*(float (*)[4])&o->pos)[2]; clear_u64_value_c2(goal); @@ -2358,7 +2357,7 @@ extern int D_L12_00161F20 __attribute__((section(".sdata"))); extern int D_L12_001619A0 __attribute__((sda)); typedef struct { char pad[0x25c]; struct Moby *moby; int count; } Tracking_e9f68; extern Tracking_e9f68 D_L12_00167100; -extern unsigned char D_0014C050[]; +#include "rnc/gameplay/state/game_globals.h" #include "rnc/audio/voice_pool.h" extern unsigned char D_0013E550[]; extern unsigned char D_0013D4CB __attribute__((section(".data"))); @@ -2419,7 +2418,7 @@ void FUN_L12_002e9f68(struct Moby *moby) { check_mode: if (index == 0) goto update_state; } - if (D_0014C050[moby->mission + current_level_index * 16] == 255) { + if (visited52[moby->mission + current_level_index * 16] == 255) { if (*(struct Moby **)(data + 0xac)) { mark_moby_for_removal(*(struct Moby **)(data + 0xac)); *(struct Moby **)(data + 0xac) = 0; @@ -3004,7 +3003,7 @@ void FUN_L12_002eb570(L16WatchMoby *m) { /* Hit handler: counts hits toward a help message, bursts debris and blinks the moby until its timer runs out. */ extern char D_0013D408[]; extern int tick_countdown_32_alt(int *arg0) __asm__("FUN_001f9740"); -extern short D_0015EE04 __attribute__((sda)); +extern int D_0015EE04 __attribute__((sda)); extern s32 D_L12_001619B4 __attribute__((sda)); extern void FUN_L00_0025e450(void *, void *, void *, float, float, int, int, int, float, float, float, int, float, float, int, int, int, int); @@ -3020,8 +3019,8 @@ void FUN_L12_002ebca8(struct Moby *m, int flag) { unsigned char *q; if (find_moby_hit(m, 0xA30000, 0) != 0) { if (hero.state.current != 0x32) { - *(int *)&D_0015EE04 += 1; - if (*(int *)&D_0015EE04 >= 5) { + D_0015EE04 += 1; + if (D_0015EE04 >= 5) { q = (unsigned char *)(D_0013D408); if (q[0x15] == 0) { q[0x15] = 1; @@ -3069,9 +3068,9 @@ extern void subtract_vector_xyz_c(void *, void *, void *) __asm__("FUN_001f9a28" void FUN_L01_00275690(char *vec, float scale); extern int func_L01_00276680_i(char *vec, float scale) __asm__("FUN_L01_00275690"); -extern short D_L12_001619A8 __attribute__((sda)); -extern short D_L12_001619AC __attribute__((sda)); -extern short D_L12_001619B0 __attribute__((sda)); +extern float D_L12_001619A8 __attribute__((sda)); +extern float D_L12_001619AC __attribute__((sda)); +extern float D_L12_001619B0 __attribute__((sda)); void FUN_L12_002ebea8(char *m) { char *d = *(char **)(m + 0x78); float A[4]; @@ -3124,8 +3123,8 @@ void FUN_L12_002ebea8(char *m) { h = fast_subtract_rotations(h, fast_arc_tan(B[0], B[1])); ang = h / vector_length_xyz_c(A); *(float *)(m + 0x40) = fast_add_rotations_c(*(float *)(m + 0x40), - fast_subtract_rotations(ang * *(float *)&D_L12_001619AC, *(float *)(m + 0x40)) / *(float *)&D_L12_001619B0); - if (distance_xyz(m + 0x10, C) < *(float *)&D_L12_001619A8 * D_0015ED6C) { + fast_subtract_rotations(ang * D_L12_001619AC, *(float *)(m + 0x40)) / D_L12_001619B0); + if (distance_xyz(m + 0x10, C) < D_L12_001619A8 * D_0015ED6C) { char *t3; *(int *)(d + 0x60) = next; t3 = *(char **)(p + 0x10); @@ -3134,10 +3133,10 @@ void FUN_L12_002ebea8(char *m) { } } subtract_vector_xyz_c(E, C, m + 0x10); - normalize_vector_xyz(E, E, *(float *)&D_L12_001619A8 * D_0015ED6C); + normalize_vector_xyz(E, E, D_L12_001619A8 * D_0015ED6C); add_vector_xyz_c2(m + 0x10, m + 0x10, E); *(float *)(m + 0x48) = fast_add_rotations_c(*(float *)(m + 0x48), - fast_subtract_rotations(fast_arc_tan(E[0], E[1]), *(float *)(m + 0x48)) / *(float *)&D_L12_001619B0); + fast_subtract_rotations(fast_arc_tan(E[0], E[1]), *(float *)(m + 0x48)) / D_L12_001619B0); *(float *)(m + 0x44) = 0.52359879f; break; } diff --git a/src/overlays/l13/gameplay/entities/elevator.c b/src/overlays/l13/gameplay/entities/elevator.c index fda5130cfc..46539a1a51 100644 --- a/src/overlays/l13/gameplay/entities/elevator.c +++ b/src/overlays/l13/gameplay/entities/elevator.c @@ -583,7 +583,7 @@ extern float random_float_between(float, float) __asm__("FUN_002132a8"); extern int frame_count __asm__("D_L13_0015F5CC"); extern void moby_point_position(void *, int, void *) __asm__("FUN_L00_0024f7c8"); -extern short D_L13_00161388 __attribute__((sda)); +extern float D_L13_00161388 __attribute__((sda)); int D_L13_0016138C = 2; void FUN_L13_002b47a0(struct Moby *moby) { float v[4]; @@ -597,8 +597,8 @@ void FUN_L13_002b47a0(struct Moby *moby) { x = (20.0f - d) / 20.0f * 5.0f + 2.5f; ang = fast_add_rotations(random_float_between(-x, x) * DEG_TO_RAD, moby->rot.z); - v2[0] = FUN_001f9dc8(ang) * (*(float *)&D_L13_00161388 * frame_time); - v2[1] = FUN_001f9de0(ang) * (*(float *)&D_L13_00161388 * frame_time); + v2[0] = FUN_001f9dc8(ang) * (D_L13_00161388 * frame_time); + v2[1] = FUN_001f9de0(ang) * (D_L13_00161388 * frame_time); v2[2] = 0; FUN_001f9a10(v, v, v2); FUN_L13_003061c8(*(float *)(data + 0x68), v, v2, moby); @@ -2583,7 +2583,7 @@ typedef struct { char pad0[0x10]; JetVec velocity; Jet *source; int pad24,pad28; extern JetPlayer jet_player47 __asm__("D_0013F350"); extern JetCamera jet_camera47 __asm__("D_L13_00166F80"); extern JetTransition D_001516D0[]; -extern unsigned char D_0014C050[]; +#include "rnc/gameplay/state/game_globals.h" extern unsigned char D_0013E550[]; extern unsigned char D_0013A4E0[]; extern float D_L13_0015ED60; @@ -2699,7 +2699,7 @@ void FUN_L13_002bb068(Jet *m) { hp_bar_clut[0]=palette; if (!initialized) __builtin_memcpy(D_L13_001CBE70,palette,1024); hp_bar_saved=1; d->wait_timer=1; d->energy=1; - if (m->persistent!=0xFF && (D_0014C050)[m->persistent+(D_L13_0015ED84<<4)]==0xFF) m->state=9; + if (m->persistent!=0xFF && (visited52)[m->persistent+(D_L13_0015ED84<<4)]==0xFF) m->state=9; if (d->group_a>0) jet_group_state(d->group_a,0,0,0); if (d->group_b>0) jet_group_state(d->group_b,0,0,0); jet_group_switch(D_L13_001CBDE8,1,1,-1); jet_group_switch(&D_L13_00161440,1,-1,-1); jet_group_flag(0x102,0); @@ -2708,7 +2708,7 @@ void FUN_L13_002bb068(Jet *m) { } case 1: { short enter=0; - if (m->persistent!=0xFF && (D_0014C050)[m->persistent+(D_L13_0015ED84<<4)]==0xFF) m->state=9; + if (m->persistent!=0xFF && (visited52)[m->persistent+(D_L13_0015ED84<<4)]==0xFF) m->state=9; else if (d->trigger!=-1 && jet_check_trigger(D_0013F3D0,d->trigger)) { d->blend=0.99f; D_L13_0015F3FC=0.99f; enter=1; } else if (jet_distance(m,((JetPlayer*)(&jet_player47))->moby)<2.0f) { int pressed=jet_try_help(7,0x53E4)!=0; diff --git a/src/overlays/l13/gameplay/entities/qwarks_starfighter_part.c b/src/overlays/l13/gameplay/entities/qwarks_starfighter_part.c index 433423d0a8..db9201e1ee 100644 --- a/src/overlays/l13/gameplay/entities/qwarks_starfighter_part.c +++ b/src/overlays/l13/gameplay/entities/qwarks_starfighter_part.c @@ -493,7 +493,7 @@ extern void transform_vector_by_basis(void *, void *, void *) __asm__("func_001F float absolute_float(float input) __asm__("func_001F99C0"); void FUN_L13_002e8b58(struct Moby *moby); void set_animation_parameter(s32 anim_id, s32 value) __asm__("FUN_001ff570"); -extern unsigned char D_0014C050[]; +#include "rnc/gameplay/state/game_globals.h" extern char D_0013F350[]; extern char D_001516D0[]; extern int func_001FA898_r(float) __asm__("FUN_001fa6d0"); @@ -524,7 +524,7 @@ void FUN_L13_002eb098(Moby388 *moby) { switch (moby->state) { case 0: { int j; - if (moby->bB0 != 0xFF && D_0014C050[moby->bB0 + (D_0015ED84 << 4)] == 0xFF) { + if (moby->bB0 != 0xFF && visited52[moby->bB0 + (D_0015ED84 << 4)] == 0xFF) { mark_moby_for_removal_c(moby); return; } diff --git a/src/overlays/l13/gameplay/entities/rocket.c b/src/overlays/l13/gameplay/entities/rocket.c index 1a6ab62e6c..15b6f72412 100644 --- a/src/overlays/l13/gameplay/entities/rocket.c +++ b/src/overlays/l13/gameplay/entities/rocket.c @@ -268,7 +268,7 @@ extern float fast_arc_tan(float, float) __asm__("FUN_001f9e90"); extern int FUN_001f96f8(int); extern s32 truncate_float_to_s32(f32) __asm__("FUN_001fa6d0"); extern void FUN_L00_00250df8(void *); -void blend_moby_animation(MobyAnim *arg0, int arg1, int arg2, int arg3) __asm__("FUN_00212f90"); +extern void blend_moby_animation(void *, s32, s32, s32) __asm__("FUN_00212f90"); extern char *func_0020D348_m_c(int) __asm__("FUN_0020c4f8"); extern int func_001FA898_r(float) __asm__("FUN_001fa6d0"); @@ -340,7 +340,6 @@ extern void fast_vec_normalize_c(void *, void *, f32) __asm__("FUN_001f9bf8"); extern void mark_moby_for_removal_c(void *) __asm__("func_0020C828"); extern void set_vector_length_xy_c(void *, void *, f32) __asm__("FUN_001f9c48"); extern void subtract_vector_xyz(void *, void *, void *) __asm__("FUN_001f9a28"); -extern char D_0013F350[]; void FUN_L13_00306300(struct Moby *moby) { extern struct { char pad[0x18]; struct Moby *moby; int pad1; L13Vec_p pos; L13Vec_p pad2; L13Vec_p matrix; } D_L13_00174140; @@ -366,7 +365,7 @@ void FUN_L13_00306300(struct Moby *moby) { set_vector_length_xy_c(&work.velocity, &work.velocity, 1.0f); work.velocity.z = 1.0f; flags = 0x10001; - base = (unsigned char *)((char *)&D_0013F350); + base = (unsigned char *)((char *)((char *)&hero)); if (base[0x1FF6] != 0 && *(float *)(data + 0xC) != 31337.6015625f && fast_vec_dist(&moby->pos, base + 0x80) < 2.0f) { fast_vec_normalize_c(data, data, 0.5f); @@ -375,7 +374,7 @@ void FUN_L13_00306300(struct Moby *moby) { *(int *)(data + 0x2C) = 5; *(float *)(data + 0xC) = 31337.6015625f; for (i = 0; i < 6; i++) { - unsigned char *b = (unsigned char *)((char *)&D_0013F350); + unsigned char *b = (unsigned char *)((char *)((char *)&hero)); ent = ((char **)(b + 0x2020))[i]; if (ent != 0) { int f2 = flags | 1; @@ -742,313 +741,382 @@ void FUN_L13_00307b10(struct Moby *moby) { break; } } -#ifndef NON_MATCHING -INCLUDE_ASM("config/us/overlays/asm/FUN_L13_00307e98.s", FUN_L13_00307e98); -#else -extern void FUN_L13_00308d10(struct Moby *); -extern void FUN_L13_00309370(struct Moby *); -extern void FUN_L00_00263ac8(void *, int, void *, float); -extern void FUN_L00_0025a120(struct Moby *); -extern void FUN_L01_0026d930(void *); -extern float FUN_L00_0025be00(float *, float *, float, float, float, float); -extern void FUN_L00_00258278(struct Moby *, float *, float, float, float, float); -extern int FUN_L00_00258b50(void *, void *, void *, void *, float); -extern void FUN_L00_00259d08(void *, void *, void *, void *, void *, void *, int); +/* Update function of moby class 1262 (blarg space commando): turn, walk its path, shoot, die. */ +/* Ported from rac1-decomp (src/overlays/l13_gemlik/vendor_002EBD00.c: func_L13_00309330), where it is exact; names translated to the US level program. */ + + +typedef struct { + u8 pad0[0x18]; + u8 active; + u8 valid; + s16 oclass; + u8 pad1C[0x14]; +} Shot_309330; + +typedef struct { + s32 unk0; + f32 unk4; + f32 unk8; + f32 unkC; + u8 pad10[0x14]; + f32 unk24; + u8 pad28[0x18]; +} Ctl_309330; + +typedef struct { + u8 pad0[0x20]; + f32 unk20; + s16 unk24; + u8 pad26[2]; + u8 unk28; + u8 pad29[7]; + f32 unk30; + u8 pad34[0x24]; + u8 unk58; + u8 pad59; + u8 unk5A; + u8 pad5B[5]; + Vec4 vel; /* 0x60 */ + u8 pad70[0x50]; + Ctl_309330 ctl; /* 0xC0 */ + u8 pad100[0x60]; + struct Moby *target; /* 0x160 */ + s32 unk164; + u8 pad168[8]; + Vec4 home; /* 0x170 */ + u8 pad180[4]; + s32 unk184; + f32 turn; /* 0x188 */ + u8 pad18C[8]; + s32 timer; /* 0x194 */ + s32 path; /* 0x198 */ + u8 pad19C[0xC]; + f32 unk1A8; + u8 pad1AC[0x34]; + Vec4 unk1E0; + u8 pad1F0[0x210]; + u8 unk400[1]; +} Vars_309330; + +extern char D_L13_001670C0[]; +extern f32 convert_integer_to_float(s32) __asm__("func_001FA6C0"); +extern f32 fast_arc_tan_c(f32, f32) __asm__("func_001F9E90"); +extern f32 fast_cos(f32) __asm__("func_001F9DC8"); +extern f32 fast_sin(f32) __asm__("func_001F9DE0"); +extern float fast_add_rotations_c(float, float) __asm__("func_001FA580"); +extern float fast_difference_between_rotations(float, float) __asm__("func_001FA688"); +extern int D_L13_00161E70; +extern int FUN_L00_00258b50(struct Moby *, void *, void *, void *, float); +extern int FUN_L00_0025c698(void *, void *); extern int FUN_L00_00261b48(int, void *, void *, void *); +extern s32 rand(void); +extern s32 truncate_float_to_s32_c(f32) __asm__("func_001FA6D0"); +extern void FUN_L00_0024f7c8(void *, int, void *); +extern void FUN_L00_00258278(void *moby, float *vel, float target, float k, float d, float max); +extern void FUN_L00_00259888_c2(void *, struct Moby *, int, float, void *) __asm__("FUN_L00_00259888"); +extern void FUN_L00_00259d08(void *, void *, void *, void *, struct Moby *, Shot_309330 *, int); +extern void FUN_L00_0025a120(void *); +extern void FUN_L00_0025be00(float *, float, float *, float, float, float); +extern void FUN_L00_0025e450_c(void *, void *, void *, float, float, int, int, int, float, float, float, int, float, float, int, int, int, int) __asm__("FUN_L00_0025e450"); extern void FUN_L00_00261d78(int, void *, void *, float); -extern int FUN_L00_0025c698(struct Moby *, void *); -extern void FUN_00212f90(struct Moby *, int, int, int); -extern float compute_interpolated_record_value(struct Moby *) __asm__("FUN_0020c9e0"); -extern float fast_vec_dist(void *, void *) __asm__("FUN_001f9b48"); -extern float fast_arc_tan(float, float) __asm__("FUN_001f9e90"); -extern float FUN_001fa688(float, float); -extern float fast_add_rotations(float, float) __asm__("FUN_001fa580"); -extern float fast_cos(float) __asm__("func_001F9DC8"); -extern float fast_sin(float) __asm__("func_001F9DE0"); -extern float FUN_001fa6c0(int); -extern int FUN_001fa6d0(float); -extern int FUN_001f9740(int *); -extern int scale_game_frames(int) __asm__("func_001F96F8"); -extern float random_float_between(float, float) __asm__("FUN_002132a8"); -extern void rand(void) __asm__("FUN_001160d8"); -extern float D_0015ED70; -extern float D_L13_00161E58 __attribute__((sda)); -extern int D_L13_00161E70 __attribute__((sda)); -extern float D_L13_00161E74 __attribute__((sda)); -extern float D_L13_00161E78 __attribute__((sda)); -extern char D_L13_001670C0[]; +extern void FUN_L00_00263ac8(float, struct Moby *, int, void *); +extern void FUN_L01_0026d930(void *); +extern void FUN_L13_00308d10_c(struct Moby *) __asm__("FUN_L13_00308d10"); +extern void FUN_L13_00309370_c(char *m) __asm__("FUN_L13_00309370"); +extern void mark_moby_for_removal_c2(void *) __asm__("func_0020C828"); +f32 compute_interpolated_record_value(void *anim) __asm__("FUN_0020c9e0"); +extern void func_L00_0025A8C0_30A9B0(void *, void *, int, void *, float) __asm__("FUN_L13_00265990"); +extern float D_L13_00161E58_gp __asm__("D_L13_00161E58") __attribute__((sda)); +extern float D_L13_00161E74_gp __asm__("D_L13_00161E74") __attribute__((sda)); +extern float D_L13_00161E78_gp __asm__("D_L13_00161E78") __attribute__((sda)); +extern void func_L00_002592B0_309330(struct Moby *, float, float *, float, float, float) __asm__("FUN_L13_00263fc8"); -/* State update; raw offsets retain the retail interpretations of shared pvars. */ void FUN_L13_00307e98(struct Moby *moby) { - char *data = (char *)moby->pvars; + Vars_309330 *vars = (Vars_309330 *)moby->pvars; struct Moby *target; - OvlVec4 next, pos, direction; - struct { - OvlVec4 vector; - float unk10, unk14; - unsigned char active, valid; - unsigned short oclass; - char pad1C[0x14]; - } __attribute__((aligned(16))) hit; - float angle; - float *rotation; - void *anim; - int flags, value; - - FUN_L13_00308d10(moby); - target = *(struct Moby **)(data + 0x160); - FUN_L00_00263ac8(moby, 1, data + 0x400, 2.5f); - if (moby->visible && fast_vec_dist(&moby->pos, D_L13_001670C0) < 28.0f) { + Vec4 point; + Vec4 origin; + Vec4 direction; + Shot_309330 shot; + s32 blocked; + s32 path_blocked; + s32 hit; + + FUN_L13_00308d10_c(moby); + target = vars->target; + FUN_L00_00263ac8(2.5f, moby, 1, vars->unk400); + if (moby->visible != 0 && fast_vec_dist(&moby->pos, D_L13_001670C0) < 28.0f) { FUN_L00_0025a120(moby); moby->shadow_range = 0x16; } switch (moby->state) { - case 0: { - float distance; - *(float *)(data + 0x20) = 2.0f; - data[0x28] = 1; - data[0x58] = 12; - data[0x5a] = 8; - *(short *)(data + 0x24) = 2; - *(float *)(data + 0x30) = 1.5f; - FUN_L01_0026d930(data + 0xc0); - angle = D_L13_00161E58 * 716.8f; - *(float *)(data + 0xc8) = 2.0f; - *(float *)(data + 0xcc) = 0.5f; - value = FUN_001fa6d0(angle); - *(float *)(data + 0xc4) = D_L13_00161E58 * 0.7f; - *(int *)(data + 0xc0) = value; - distance = random_float_between(0.95f, 1.05f); - *(float *)(data + 0xe4) = D_L13_00161E78 * D_0015ED6C * distance; - qcopy(data + 0x170, &moby->pos); - moby_point_position(moby, 0, data + 0x1e0); + case 0: + vars->unk20 = 2.0f; + vars->unk28 = 1; + vars->unk58 = 12; + vars->unk5A = 8; + vars->unk24 = 2; + vars->unk30 = 1.5f; + FUN_L01_0026d930(&vars->ctl); + vars->ctl.unk8 = 2.0f; + vars->ctl.unkC = 0.5f; + vars->ctl.unk0 = func_001FA898_r(D_L13_00161E58_gp * 716.8f); + vars->ctl.unk4 = D_L13_00161E58_gp * 0.7f; + vars->ctl.unk24 = D_L13_00161E78_gp * frame_time * random_float_between(0.95f, 1.05f); + qcopy(&vars->home, &moby->pos); + FUN_L00_0024f7c8(moby, 0, &vars->unk1E0); moby->state = 1; break; - } - case 1: { - float distance; - rotation = &moby->rot.z; - angle = fast_arc_tan(target->pos.x - moby->pos.x, target->pos.y - moby->pos.y); - FUN_L00_0025be00(rotation, (float *)(data + 0x188), angle, - D_0015ED70 * 6.2831855f, D_0015ED70 * 6.2831855f, D_0015ED6C * 3.1415927f); - if (*(int *)(data + 0x164) != 2) { - distance = vector_distance_xy(&moby->pos, &target->pos); - if (D_L13_00161E74 < distance) { - angle = fast_arc_tan(target->pos.x - moby->pos.x, target->pos.y - moby->pos.y); - if (FUN_001fa688(moby->rot.z, angle) < 0.2617994f) { - moby->state = 2; if (moby->prev_seq != 3) FUN_00212f90(moby, 3, 0, scale_game_frames(10)); + case 1: + FUN_L00_0025be00(&moby->rot.z, fast_arc_tan_c(target->pos.x - moby->pos.x, target->pos.y - moby->pos.y), + &vars->turn, frame_time_sq * 6.2831855f, frame_time_sq * 6.2831855f, frame_time * 3.1415927f); + if (vars->unk164 != 2) { + f32 dist = vector_distance_xy_alt(&moby->pos, &target->pos); + if (D_L13_00161E74_gp < dist) { + if (fast_difference_between_rotations(moby->rot.z, fast_arc_tan_c(target->pos.x - moby->pos.x, + target->pos.y - moby->pos.y)) < 0.2617994f) { + moby->state = 2; + if (moby->prev_seq != 3) { + blend_moby_animation(moby, 3, 0, scale_game_frames(10)); + } } else { - moby->state = 7; if (moby->prev_seq != 1) FUN_00212f90(moby, 1, 0, scale_game_frames(20)); + moby->state = 7; + if (moby->prev_seq != 1) { + blend_moby_animation(moby, 1, 0, scale_game_frames(20)); + } } } else { - moby->state = 5; if (moby->prev_seq != 6) FUN_00212f90(moby, 6, 0, scale_game_frames(10)); + moby->state = 5; + if (moby->prev_seq != 6) { + blend_moby_animation(moby, 6, 0, scale_game_frames(10)); + } } - return; - } else { - if (*(int *)(data + 0x184)) { - moby->state = 11; - if (moby->prev_seq != 1) FUN_00212f90(moby, 1, 0, scale_game_frames(20)); - return; + } else if (vars->unk184 != 0) { + moby->state = 11; + if (moby->prev_seq != 1) { + blend_moby_animation(moby, 1, 0, scale_game_frames(20)); } } break; - } - case 2: { - if (!(moby->anim_flags & 2)) return; - moby->state = 3; - FUN_L13_00309370(moby); - if (moby->prev_seq != 5) FUN_00212f90(moby, 5, 0, scale_game_frames(10)); - return; - } - case 3: { - float distance; - if (!(moby->anim_flags & 2)) return; - distance = vector_distance_xy(&moby->pos, &target->pos); - if (*(int *)(data + 0x164) != 2 && distance < 15.0f) { - moby->state = 4; - if (moby->prev_seq != 4) - FUN_00212f90(moby, 4, 0, scale_game_frames(20)); - *(int *)(data + 0x194) = scale_game_frames(D_L13_00161E70); - return; - } - moby->state = 1; if (moby->prev_seq != 0) FUN_00212f90(moby, 0, 0, scale_game_frames(20)); - return; - } - case 4: { - float distance; - rotation = &moby->rot.z; - angle = fast_arc_tan(target->pos.x - moby->pos.x, target->pos.y - moby->pos.y); - FUN_L00_0025be00(rotation, (float *)(data + 0x188), angle, - D_0015ED70 * 6.2831855f, D_0015ED70 * 6.2831855f, D_0015ED6C * 3.1415927f); - if (FUN_001f9740((int *)(data + 0x194))) { + case 2: + if (moby->anim_flags & 2) { moby->state = 3; - FUN_L13_00309370(moby); - if (moby->prev_seq != 5) FUN_00212f90(moby, 5, 0, scale_game_frames(5)); - return; + FUN_L13_00309370_c((char *)moby); + if (moby->prev_seq != 5) { + blend_moby_animation(moby, 5, 0, scale_game_frames(10)); + } } - distance = vector_distance_xy(&moby->pos, &target->pos); - if (distance < D_L13_00161E74) { - moby_point_position(moby, 0, data + 0x1e0); - moby->state = 5; if (moby->prev_seq != 6) FUN_00212f90(moby, 6, 0, scale_game_frames(10)); - return; - } else if (*(int *)(data + 0x184)) { - moby->state = 11; if (moby->prev_seq != 1) FUN_00212f90(moby, 1, 0, scale_game_frames(20)); - return; + break; + case 3: + if (moby->anim_flags & 2) { + f32 dist = vector_distance_xy_alt(&moby->pos, &target->pos); + if (vars->unk164 != 2 && dist < 15.0f) { + moby->state = 4; + if (moby->prev_seq != 4) { + blend_moby_animation(moby, 4, 0, scale_game_frames(20)); + } + vars->timer = scale_game_frames(D_L13_00161E70); + } else { + moby->state = 1; + if (moby->prev_seq != 0) { + blend_moby_animation(moby, 0, 0, scale_game_frames(20)); + } + } } break; - } - case 5: { - float distance; - rotation = &moby->rot.z; - angle = fast_arc_tan(target->pos.x - moby->pos.x, target->pos.y - moby->pos.y); - FUN_L00_0025be00(rotation, (float *)(data + 0x188), angle, - D_0015ED70 * 6.2831855f, D_0015ED70 * 6.2831855f, D_0015ED6C * 3.1415927f); - moby_point_position(moby, 0, &next); - qcopy(&pos, &moby->pos); - pos.f[2] += 0.3f; - distance = compute_interpolated_record_value(moby); - if (9.0f <= distance && distance <= 15.0f) { + case 4: + FUN_L00_0025be00(&moby->rot.z, fast_arc_tan_c(target->pos.x - moby->pos.x, target->pos.y - moby->pos.y), + &vars->turn, frame_time_sq * 6.2831855f, frame_time_sq * 6.2831855f, frame_time * 3.1415927f); + if (tick_countdown_32_alt(&vars->timer) != 0) { + moby->state = 3; + FUN_L13_00309370_c((char *)moby); + if (moby->prev_seq != 5) { + blend_moby_animation(moby, 5, 0, scale_game_frames(5)); + } + } else if (vector_distance_xy_alt(&moby->pos, &target->pos) < D_L13_00161E74_gp) { + FUN_L00_0024f7c8(moby, 0, &vars->unk1E0); + moby->state = 5; + if (moby->prev_seq != 6) { + blend_moby_animation(moby, 6, 0, scale_game_frames(10)); + } + } else if (vars->unk184 != 0) { + moby->state = 11; + if (moby->prev_seq != 1) { + blend_moby_animation(moby, 1, 0, scale_game_frames(20)); + } + } + break; + case 5: + FUN_L00_0025be00(&moby->rot.z, fast_arc_tan_c(target->pos.x - moby->pos.x, target->pos.y - moby->pos.y), + &vars->turn, frame_time_sq * 6.2831855f, frame_time_sq * 6.2831855f, frame_time * 3.1415927f); + FUN_L00_0024f7c8(moby, 0, &point); + qcopy(&origin, &moby->pos); + origin.f[2] += 0.3f; + { + f32 frame = compute_interpolated_record_value(moby); + if (frame >= 9.0f && frame <= 15.0f) { direction.f[0] = fast_cos(moby->rot.z); direction.f[1] = fast_sin(moby->rot.z); - direction.f[3] = 5627.925f; direction.f[2] = 1.0f; - FUN_L00_00259888(&hit, moby, 1, &direction, 1.0f); - hit.valid = 1; hit.oclass = moby->oclass; hit.active = 0; - FUN_L00_00259d08(&next, &pos, data + 0x1e0, &pos, moby, &hit, 5); + direction.f[3] = 5627.925f; + func_L00_0025A8C0_30A9B0(&shot, moby, 1, &direction, 1.0f); + shot.active = 0; + shot.valid = 1; + shot.oclass = moby->oclass; + FUN_L00_00259d08(&point, &origin, &vars->unk1E0, &origin, moby, &shot, 5); + } } - qcopy(data + 0x1e0, &next); + qcopy(&vars->unk1E0, &point); if (moby->anim_flags & 2) { - moby->state = 6; moby->command = 1; - if (moby->prev_seq != 2) FUN_00212f90(moby, 2, 0, scale_game_frames(10)); - return; + moby->state = 6; + moby->command = 1; + if (moby->prev_seq != 2) { + blend_moby_animation(moby, 2, 0, scale_game_frames(10)); + } } break; - } - case 6: { - if (!(moby->anim_flags & 2)) return; - moby->state = moby->command; - if (moby->prev_seq != 0) FUN_00212f90(moby, 0, 0, scale_game_frames(20)); - return; - } - case 7: { - float distance; - int blocked; - angle = fast_arc_tan(target->pos.x - moby->pos.x, target->pos.y - moby->pos.y); - angle = fast_add_rotations(angle, *(float *)(data + 0x1a8)); - FUN_L00_00258278(moby, (float *)(data + 0x188), angle, 0.05f, 0.3f, D_0015ED6C * 6.2831855f); - next.f[0] = fast_cos(moby->rot.z); next.f[0] += next.f[0]; - next.f[1] = fast_sin(moby->rot.z); next.f[1] += next.f[1]; - next.i[2] = 0; - flags = FUN_L00_00258b50(moby, data + 0xc0, &next, &pos, 1.0f); - if (flags & 2) { + case 6: + if (moby->anim_flags & 2) { + moby->state = moby->command; + if (moby->prev_seq != 0) { + blend_moby_animation(moby, 0, 0, scale_game_frames(20)); + } + } + break; + case 7: + func_L00_002592B0_309330(moby, + fast_add_rotations_c(fast_arc_tan_c(target->pos.x - moby->pos.x, target->pos.y - moby->pos.y), + vars->unk1A8), &vars->turn, + 0.05f, 0.3f, frame_time * 6.2831855f); + point.f[0] = 2.0f * fast_cos(moby->rot.z); + point.f[1] = 2.0f * fast_sin(moby->rot.z); + point.f[2] = 0.0f; + if (FUN_L00_00258b50(moby, &vars->ctl, &point, &origin, 1.0f) & 2) { rand(); - *(float *)(data + 0x1a8) = FUN_001fa6c0(-1) * 1.0995574f; - } else *(float *)(data + 0x1a8) = 0.0f; - FUN_L00_00261d78(*(int *)(data + 0x198), &moby->pos, &moby->pos, 0.75f); - blocked = 0; - if (FUN_L00_00261b48(*(int *)(data + 0x198), &moby->pos, &target->pos, &direction) && - fast_vec_dist(&moby->pos, &direction) < 0.8f) blocked = 1; - distance = vector_distance_xy(&moby->pos, &target->pos); - if (distance < 15.0f) { - moby->state = 2; if (moby->prev_seq != 3) FUN_00212f90(moby, 3, 0, scale_game_frames(10)); - return; - } else if (blocked) { - moby->state = 2; if (moby->prev_seq != 3) FUN_00212f90(moby, 3, 0, scale_game_frames(10)); - return; - } else if (distance < D_L13_00161E74) { - moby->state = 5; if (moby->prev_seq != 6) FUN_00212f90(moby, 6, 0, scale_game_frames(10)); - return; + vars->unk1A8 = convert_integer_to_float(-1) * 1.0995574f; + } else { + vars->unk1A8 = 0.0f; + } + FUN_L00_00261d78(vars->path, &moby->pos, &moby->pos, 0.75f); + path_blocked = 0; + if (FUN_L00_00261b48(vars->path, &moby->pos, &target->pos, &direction) != 0 && + fast_vec_dist(&moby->pos, &direction) < 0.8f) { + path_blocked = 1; + } + { + f32 dist = vector_distance_xy_alt(&moby->pos, &target->pos); + if (dist < 15.0f) { + moby->state = 2; + if (moby->prev_seq != 3) { + blend_moby_animation(moby, 3, 0, scale_game_frames(10)); + } + } else if (path_blocked != 0) { + moby->state = 2; + if (moby->prev_seq != 3) { + blend_moby_animation(moby, 3, 0, scale_game_frames(10)); + } + } else if (dist < D_L13_00161E74_gp) { + moby->state = 5; + if (moby->prev_seq != 6) { + blend_moby_animation(moby, 6, 0, scale_game_frames(10)); + } + } } break; - } - case 11: { - float distance; - int blocked; + case 11: blocked = 0; - angle = fast_arc_tan(target->pos.x - moby->pos.x, target->pos.y - moby->pos.y); - FUN_L00_00258278(moby, (float *)(data + 0x188), angle, 0.05f, 0.3f, D_0015ED6C * 6.2831855f); - next.f[0] = fast_cos(moby->rot.z); next.f[0] += next.f[0]; - next.f[1] = fast_sin(moby->rot.z); next.f[1] += next.f[1]; - next.i[2] = 0; - FUN_L00_00258b50(moby, data + 0xc0, &next, &pos, 1.0f); - FUN_L00_00261d78(*(int *)(data + 0x198), &moby->pos, &moby->pos, 0.75f); - if (FUN_L00_00261b48(*(int *)(data + 0x198), &moby->pos, &target->pos, &direction) && - fast_vec_dist(&moby->pos, &direction) < 0.8f) blocked = 1; - if (!*(int *)(data + 0x184)) moby->state = 13; - else if (blocked) { - moby->state = 12; if (moby->prev_seq != 6) FUN_00212f90(moby, 6, 0, scale_game_frames(10)); - return; - } else { - distance = vector_distance_xy(&moby->pos, &target->pos); - if (distance < D_L13_00161E74) { - moby_point_position(moby, 0, data + 0x1e0); - moby->state = 12; if (moby->prev_seq != 6) FUN_00212f90(moby, 6, 0, scale_game_frames(10)); - return; + func_L00_002592B0_309330(moby, + fast_arc_tan_c(target->pos.x - moby->pos.x, target->pos.y - moby->pos.y), &vars->turn, 0.05f, 0.3f, + frame_time * 6.2831855f); + point.f[0] = 2.0f * fast_cos(moby->rot.z); + point.f[1] = 2.0f * fast_sin(moby->rot.z); + point.f[2] = 0.0f; + FUN_L00_00258b50(moby, &vars->ctl, &point, &origin, 1.0f); + FUN_L00_00261d78(vars->path, &moby->pos, &moby->pos, 0.75f); + if (FUN_L00_00261b48(vars->path, &moby->pos, &target->pos, &direction) != 0 && + fast_vec_dist(&moby->pos, &direction) < 0.8f) { + blocked = 1; + } + if (vars->unk184 == 0) { + moby->state = 13; + } else if (blocked != 0) { + moby->state = 12; + if (moby->prev_seq != 6) { + blend_moby_animation(moby, 6, 0, scale_game_frames(10)); + } + } else if (vector_distance_xy_alt(&moby->pos, &target->pos) < D_L13_00161E74_gp) { + FUN_L00_0024f7c8(moby, 0, &vars->unk1E0); + moby->state = 12; + if (moby->prev_seq != 6) { + blend_moby_animation(moby, 6, 0, scale_game_frames(10)); } } break; - } - case 12: { - float distance; - moby_point_position(moby, 0, &next); - qcopy(&pos, &moby->pos); - pos.f[2] += 1.5f; - distance = compute_interpolated_record_value(moby); - if (9.0f <= distance && distance <= 15.0f) { + case 12: + FUN_L00_0024f7c8(moby, 0, &point); + qcopy(&origin, &moby->pos); + origin.f[2] += 1.5f; + { + f32 frame = compute_interpolated_record_value(moby); + if (frame >= 9.0f && frame <= 15.0f) { direction.f[0] = fast_cos(moby->rot.z); direction.f[1] = fast_sin(moby->rot.z); - direction.f[3] = 5627.925f; direction.f[2] = 1.0f; - FUN_L00_00259888(&hit, moby, 1, &direction, 1.0f); - hit.valid = 1; hit.oclass = moby->oclass; hit.active = 0; - FUN_L00_00259d08(&next, &pos, data + 0x1e0, &pos, moby, &hit, 5); + direction.f[3] = 5627.925f; + func_L00_0025A8C0_30A9B0(&shot, moby, 1, &direction, 1.0f); + shot.active = 0; + shot.valid = 1; + shot.oclass = moby->oclass; + FUN_L00_00259d08(&point, &origin, &vars->unk1E0, &origin, moby, &shot, 5); + } } - qcopy(data + 0x1e0, &next); + qcopy(&vars->unk1E0, &point); if (moby->anim_flags & 2) { - moby->state = 11; if (moby->prev_seq != 1) FUN_00212f90(moby, 1, 0, scale_game_frames(20)); - return; + moby->state = 11; + if (moby->prev_seq != 1) { + blend_moby_animation(moby, 1, 0, scale_game_frames(20)); + } } break; - } - case 13: { - angle = fast_arc_tan(*(float *)(data + 0x170) - moby->pos.x, *(float *)(data + 0x174) - moby->pos.y); - FUN_L00_00258278(moby, (float *)(data + 0x188), angle, 0.05f, 0.3f, D_0015ED6C * 6.2831855f); - next.f[0] = fast_cos(moby->rot.z); next.f[0] += next.f[0]; - next.f[1] = fast_sin(moby->rot.z); next.i[2] = 0; next.f[1] += next.f[1]; - angle = fast_arc_tan(*(float *)(data + 0x170) - moby->pos.x, *(float *)(data + 0x174) - moby->pos.y); - if (FUN_001fa688(moby->rot.z, angle) < 0.7853982f) { - FUN_L00_00258b50(moby, data + 0xc0, &next, &pos, 1.0f); - FUN_L00_00261d78(*(int *)(data + 0x198), &moby->pos, &moby->pos, 0.75f); - } - if (!(fast_vec_dist(data + 0x170, &moby->pos) < 1.0f)) return; - moby->state = 1; if (moby->prev_seq != 0) FUN_00212f90(moby, 0, 0, scale_game_frames(20)); - return; - } - case 15: { - anim = data + 0x60; - flags = FUN_L00_0025c698(moby, anim); - value = flags & 0x40; - flags &= 0x120; - if (value) { - *(OvlQuad *)anim = 0; - moby->state = 1; if (moby->prev_seq != 0) FUN_00212f90(moby, 0, 0, scale_game_frames(10)); - return; + case 13: + func_L00_002592B0_309330(moby, + fast_arc_tan_c(vars->home.f[0] - moby->pos.x, vars->home.f[1] - moby->pos.y), &vars->turn, 0.05f, + 0.3f, frame_time * 6.2831855f); + point.f[0] = 2.0f * fast_cos(moby->rot.z); + point.f[1] = 2.0f * fast_sin(moby->rot.z); + point.f[2] = 0.0f; + if (fast_difference_between_rotations(moby->rot.z, fast_arc_tan_c(vars->home.f[0] - moby->pos.x, + vars->home.f[1] - moby->pos.y)) < 0.7853982f) { + FUN_L00_00258b50(moby, &vars->ctl, &point, &origin, 1.0f); + FUN_L00_00261d78(vars->path, &moby->pos, &moby->pos, 0.75f); + } + if (fast_vec_dist(&vars->home, &moby->pos) < 1.0f) { + moby->state = 1; + if (moby->prev_seq != 0) { + blend_moby_animation(moby, 0, 0, scale_game_frames(20)); + } } - if (flags) mark_moby_for_removal(moby); - return; - } - case 16: { - flags = FUN_L00_0025c698(moby, data + 0x60); - if (flags & 0x160) { - FUN_L00_0025e450(moby, data + 0x60, 0, 0.0f, 0.0f, 10, 3, 16, - 4.0f, 2.0f, 9.0f, 1.0f, -1, 15.0f, 1, 1, -1, 0); - mark_moby_for_removal(moby); + break; + case 15: + hit = FUN_L00_0025c698(moby, &vars->vel); + if (hit & 0x40) { + qzero(&vars->vel); + moby->state = 1; + if (moby->prev_seq != 0) { + blend_moby_animation(moby, 0, 0, scale_game_frames(10)); + } + } else if (hit & 0x120) { + mark_moby_for_removal_c2(moby); } + break; + case 16: + if (FUN_L00_0025c698(moby, &vars->vel) & 0x160) { + FUN_L00_0025e450_c(moby, &vars->vel, 0, 0.0f, 0.0f, 10, 3, 16, 4.0f, 2.0f, 9.0f, -1, 1.0f, 15.0f, 1, 1, -1, 0); + mark_moby_for_removal_c2(moby); + } + break; } - } - return; } -#endif #include "rnc/overlay/collision.h" /* Vars of the level 13 walker FUN_L13_00308d10 drives. */ @@ -1098,7 +1166,7 @@ extern f32 D_L13_00161E68 __attribute__((sda)); extern f32 D_L13_00161E6C __attribute__((sda)); extern s32 *walker_paths_8d10[] __asm__("D_L13_001B07B0"); extern char D_L13_00160680[] __attribute__((section(".sdata"))); -extern int D_001413D0 __attribute__((section(".data"))); +extern s32 D_001413D0_lui[] __asm__("D_001413D0") __attribute__((section(".data"))); extern CollisionHit coll_hit_8d10 __asm__("D_L13_00174140"); extern void FUN_L13_003094f8(struct Moby *); extern f32 random_float_between_8d10(f32, f32) __asm__("FUN_002132a8"); @@ -1211,7 +1279,7 @@ void FUN_L13_00308d10(struct Moby *moby) { } } if (vars->start_frame == 0) { - vars->start_frame = D_001413D0; + vars->start_frame = (*(int *)&D_001413D0_lui); } ground = probe_ground_height_8d10(&moby->pos, 0, 0.5f); if (ground != 0.0f) { @@ -1270,7 +1338,7 @@ extern f32 fast_sin(f32) __asm__("func_001F9DE0"); extern float fast_add_rotations(float, float) __asm__("FUN_001fa580"); extern float probe_ground_height(void *, int, float) __asm__("FUN_00213508"); extern s32 scale_game_frames(s32) __asm__("func_001F96F8"); -extern short D_L13_00161E80 __attribute__((sda)); +extern float D_L13_00161E80 __attribute__((sda)); int D_L13_00161E84 = 150; extern void moby_point_position(void *, int, void *) __asm__("FUN_L00_0024f7c8"); extern void add_vector_xyz(void *, void *, void *); @@ -1285,7 +1353,7 @@ void FUN_L13_00309370(struct Moby *m) { moby_point_position(m, 0, d + 0x1F0); for (i = 0; i < 16; i++) { float a = (convert_integer_to_float(i) * 0.0625f - 0.5f) * - (*(float *)&D_L13_00161E80 * DEG_TO_RAD); + (D_L13_00161E80 * DEG_TO_RAD); v[0] = fast_cos(fast_add_rotations(a, m->rot.z)) * 0.5f; v[1] = fast_sin(fast_add_rotations(a, m->rot.z)) * 0.5f; v[2] = 0.0f; @@ -2341,7 +2409,7 @@ extern void FUN_0020c828(void *); extern void FUN_L13_0030c2b0(void *); extern void spawn_spark(void *, void *, void *, int, int, int, int, int, int) __asm__("FUN_00218888"); extern float D_0015ED70; -extern int D_001413D0 __attribute__((section(".data"))); +extern s32 D_001413D0_lui[] __asm__("D_001413D0") __attribute__((section(".data"))); extern float D_L13_00161F18 __attribute__((sda)); extern float D_L13_00161F1C __attribute__((sda)); extern float D_L13_00161F20 __attribute__((sda)); @@ -2463,7 +2531,7 @@ void FUN_L13_0030c3b8(struct Moby *moby) { return; collision: if (moby->command != 1) return; - if (FUN_001efa68(&old_pos, &moby->pos, 2, (void *)D_001413D0, 0) == 0) return; + if (FUN_001efa68(&old_pos, &moby->pos, 2, (void *)(*(int *)&D_001413D0_lui), 0) == 0) return; FUN_L13_0030c2b0(moby); FUN_0020c828(moby); } diff --git a/src/overlays/l14/gameplay/entities/platform.c b/src/overlays/l14/gameplay/entities/platform.c index 3c497be8fb..f556044eff 100644 --- a/src/overlays/l14/gameplay/entities/platform.c +++ b/src/overlays/l14/gameplay/entities/platform.c @@ -430,12 +430,12 @@ void FUN_L14_002d67e8(struct Moby *m) { extern int D_L14_0015F70C; extern void FUN_L00_0025d808(int a, char *pos, char *b, char *c, int d, float f); -extern short D_L14_00161A30 __attribute__((sda)); +extern float D_L14_00161A30 __attribute__((sda)); void FUN_L14_002d7198(struct Moby *moby) { char *data = (char *)moby->pvars; int idx = *(int *)(data + 0x60); FUN_L00_0025d808(*(int *)((idx << 5) + D_L14_0015F70C + 0x10), &moby->pos, data + 0x64, - data + 0x68, 0, *(float *)&D_L14_00161A30 * frame_time); + data + 0x68, 0, D_L14_00161A30 * frame_time); } /* Draws the racer's two glow quads, at its lamp (0xE0) and its tail (0x200), turned to face the camera. */ typedef struct { @@ -631,13 +631,12 @@ extern void build_look_at_matrix(void *out, void *dir, void *axis, f32 ang) __as extern void cross_vectors_xyz(void *, void *, void *) __asm__("func_001F9AD8"); extern void normalize_vector_xyz(void *, void *, f32) __asm__("FUN_001f9bf8"); float absolute_float(float input) __asm__("func_001F99C0"); -extern char D_0013F350[]; extern char D_0013F3D0[]; /* The caller passes two floats in f12/f13; this routine never reads them. */ void FUN_L14_002de2b8(char *moby, f32 unused_arg1, f32 unused_arg2) { char *data = *(char **)(moby + 0x78); - char *g = (char *)((char *)&D_0013F350); + char *g = (char *)((char *)((char *)&hero)); float v[4]; float up[4]; float d[4]; @@ -653,7 +652,7 @@ void FUN_L14_002de2b8(char *moby, f32 unused_arg1, f32 unused_arg2) { if ((*(char **)(g + 0x2FC) == moby && *(short *)(g + 0x30E) == 0) || (*(char **)(g + 0x4F8) == moby && *(int *)(g + 0x208C) == 3)) { - char *p = (char *)((char *)&D_0013F350); + char *p = (char *)((char *)((char *)&hero)); *(char *)(moby + 0xBC) = 1; if (absolute_float(*(float *)(p + 0x80) - *(float *)(moby + 0x10)) < 0.1f && absolute_float(*(float *)(p + 0x84) - *(float *)(moby + 0x14)) < 0.1f) { diff --git a/src/overlays/l16/gameplay/entities/grindrail_gate.c b/src/overlays/l16/gameplay/entities/grindrail_gate.c index 57b6bf8a4a..c6307dabf4 100644 --- a/src/overlays/l16/gameplay/entities/grindrail_gate.c +++ b/src/overlays/l16/gameplay/entities/grindrail_gate.c @@ -334,7 +334,7 @@ extern char D_L16_001E89A0[], D_L16_001E86D8[], D_L16_001E8A20[], D_L16_001E8A58 extern char D_L16_001E89A0[], D_L16_001E89D8[], D_L16_001E8720[], D_L16_001E8A58[], D_L16_001E8AA0[] __asm__("D_L16_001E8AA0"); extern char D_L16_001E89A0[], D_L16_001E89D8[], D_L16_001E8A20[], D_L16_001E8758[], D_L16_001E8AA0[] __asm__("D_L16_001E8AA0"); extern char D_L16_001E89A0[], D_L16_001E89D8[], D_L16_001E8A20[], D_L16_001E8A58[], D_L16_001E87A0[]; -extern float D_0015ED6C ,D_0015EE70; +extern float frame_time ,D_0015EE70; extern float fast_arc_tan(float,float) __asm__("FUN_001f9e90"); extern float FUN_L00_0025b8c0(float *p, float *v, float t, float u1, float u2, float eps); extern int debug_print_alt() __asm__("FUN_001e93b0"); @@ -374,8 +374,8 @@ void FUN_L16_002e37a0(L16CrateMoby *moby) { d->knock_drag = 0.008f; d->knock_gravity = 0.0005f; - d->knock_speed = D_0015ED6C * 24.0f; - d->knock_rise = D_0015ED6C * 12.0f; + d->knock_speed = frame_time * 24.0f; + d->knock_rise = frame_time * 12.0f; d->knock_flags = 1; d->knock_bAD = 0; FUN_L00_0025c558(moby, d->knock, 1, 1, 0, @@ -528,7 +528,7 @@ void FUN_L16_002e37a0(L16CrateMoby *moby) { extern char *D_L16_001B0930[]; extern float absolute_float(float) __asm__("func_001F99C0"); -extern float D_0015ED6C, D_0015EE70; +extern float frame_time, D_0015EE70; extern float fast_arc_tan(float, float) __asm__("FUN_001f9e90"); extern float FUN_L00_0025b8c0(float *p, float *v, float t, float u1, float u2, float eps); extern int FUN_L00_0025d808() __asm__("FUN_L00_0025d808"); @@ -547,7 +547,7 @@ int FUN_L16_002e3fa0(struct Moby *moby) { float pos[4]; float delta[4]; char *data = (char *)moby->pvars; - float t = D_L16_00161D90 * D_0015ED6C; + float t = D_L16_00161D90 * frame_time; int r; char *path; if (moby->state == 5) @@ -592,7 +592,7 @@ extern float advance_accelerated_scalar_c(float, float, float, float, float *, float *) __asm__("FUN_00213f38"); extern f32 fast_add_rotations(f32 a, f32 b) __asm__("FUN_001fa580"); extern f32 fast_subtract_rotations(f32, f32) __asm__("func_001FA5C8"); -extern float D_0015ED6C, +extern float frame_time, D_0015EE70_c __asm__("D_0015EE70"); extern float D_0015EE6C_u, D_0015ED70_c2 __asm__("D_0015ED70"); @@ -663,7 +663,7 @@ void FUN_L16_002e43e0(struct Moby *moby) { } break; case 3: - advance_accelerated_scalar_c(1.0f, D_0015ED70_c2, D_0015ED70_c2, D_0015ED6C * 0.5f, + advance_accelerated_scalar_c(1.0f, D_0015ED70_c2, D_0015ED70_c2, frame_time * 0.5f, (float *)(d + 0xB0), (float *)(d + 0xB4)); qa = v30; s = *(int *)(d + 0x80 - (-(*(short *)(d + 0xAC) * 4))); @@ -691,7 +691,7 @@ void FUN_L16_002e43e0(struct Moby *moby) { } break; case 5: - advance_accelerated_scalar_c(1.0f, D_0015ED70_c2, D_0015ED70_c2, D_0015ED6C * 0.5f, + advance_accelerated_scalar_c(1.0f, D_0015ED70_c2, D_0015ED70_c2, frame_time * 0.5f, (float *)(d + 0xB0), (float *)(d + 0xB4)); qa = v40; s = *(int *)(d + 0x80 - (-(*(short *)(d + 0xAE) * 4))); @@ -791,7 +791,6 @@ void FUN_L16_002e4900(void *moby_v) { /* Ported from rac1-decomp (src/overlays/l16_kalebo3/vendor_002A50F0.c: func_L16_002E5EC0), where it is exact; names translated to the US level program. */ extern char *D_L16_001B0930[]; -extern float D_0015ED6C; extern float FUN_001f9b48(void *, void *); void FUN_L16_002e4a58(struct Moby *moby) { @@ -814,7 +813,7 @@ void FUN_L16_002e4a58(struct Moby *moby) { } p = *(char **)(d + 0xA4); r = FUN_001f9b48(p + 0x10, p + 0x20); - a = D_0015ED6C * 20.0f; + a = frame_time * 20.0f; b = frame_time_sq * 5.0f; inv = 1.0f / (r * (float)**(int **)(d + 0xA4)); *(int *)(d + 0xB4) = 0; @@ -1011,7 +1010,7 @@ void FUN_L16_002e54a0(struct Moby *m) { } break; } - *(float *)d = FUN_001fa580(*(float *)d, D_0015ED6C * 12.566371f); + *(float *)d = FUN_001fa580(*(float *)d, frame_time * 12.566371f); f = (FUN_001f9de0(*(float *)d) + 1.0f) * 0.5f; if (m->command) { m->glow_color = FUN_001fa6e0_u(f, 0x80208020, 0x80202020); @@ -1125,7 +1124,7 @@ void FUN_L16_002e5e08(struct Moby *m) { float angle = fast_arc_tan(*(float *)(d + 0x180) - m->pos.x, *(float *)(d + 0x184) - m->pos.y); FUN_L00_0025be00(yaw, (float *)(d + 0x1F4), angle, frame_time_sq * 12.566371f, - frame_time_sq * 12.566371f, D_0015ED6C * 12.566371f); + frame_time_sq * 12.566371f, frame_time * 12.566371f); if (is_value_within_interpolated_window(m, 13.0f)) { FUN_L00_002599e8(m, 0, 1, 0.333f, 1.0f, 1.0f, 0, 1, 0); } else if ((m->anim_flags & 2) && FUN_001f9b48(&m->pos, d + 0x180) > 1.5f) { @@ -1220,7 +1219,6 @@ extern char *find_moby_hit(void *, int, int) __asm__("FUN_L00_0025a420"); extern float D_L16_00161E58 __attribute__((sda)); extern float D_0015EE70; extern float FUN_001f9b80(void*,void*); -extern float D_0015ED6C; extern float D_L16_00161E54 __attribute__((sda)); extern float D_L16_00161E5C __attribute__((sda)); extern float D_L16_00161E60 __attribute__((sda)); @@ -1249,12 +1247,12 @@ void FUN_L16_002e6208(void *arg) { d->strength = 0.5f; d->speed = D_L16_00161E54 * frame_time_sq; d->acceleration = D_L16_00161E58 * frame_time_sq; - d->jump_speed = D_L16_00161E60 * D_0015ED6C; - d->turn_speed = D_L16_00161E5C * D_0015ED6C; + d->jump_speed = D_L16_00161E60 * frame_time; + d->turn_speed = D_L16_00161E5C * frame_time; a = 0x29; d->kind = a; d->pending = 0; - d->timer = D_0015ED6C * 2.0f; + d->timer = frame_time * 2.0f; m->flags &= ~0x1000; *(OvlQuad *)scratch = *(OvlQuad *)(hit + 0x10); FUN_L00_0025ab48(scratch, scratch + 4, &d->jump_speed, &d->turn_speed); @@ -1287,7 +1285,7 @@ void FUN_L16_002e6208(void *arg) { extern f32 advance_accelerated_scalar(f32 *, f32 *, f32, f32, f32, f32) __asm__("func_00213F38"); extern f32 fast_add_rotations(f32 a, f32 b) __asm__("FUN_001fa580"); -extern float D_0015ED6C, D_0015EE70; +extern float frame_time, D_0015EE70; extern float D_0015EE6C_u, D_0015ED70_c __asm__("D_0015ED70"); extern float FUN_001f9e90_c(float, float) __asm__("FUN_001f9e90"); extern float FUN_L00_0025be00_c(float *, float *, float, float, float, @@ -1312,8 +1310,8 @@ float FUN_L16_002e6428(void *m_v, void *t_v) { vel = 0.0f; dist = FUN_001f9b48(m + 0x10, t); FUN_L00_0025be00_c((float *)(m + 0x48), (float *)(d + 0x1F4), a, D_0015ED70_c * 12.566371f, - D_0015ED70_c * 12.566371f, D_0015ED6C * 12.566371f); - func_00214D88_7890(&vel, dist, D_0015ED70_c * 8.0f, D_0015ED70_c * 12.0f, D_0015ED6C * 4.0f, + D_0015ED70_c * 12.566371f, frame_time * 12.566371f); + func_00214D88_7890(&vel, dist, D_0015ED70_c * 8.0f, D_0015ED70_c * 12.0f, frame_time * 4.0f, (float *)(d + 0x204)); normalize_vector_xyz(vec, m + 0xC0, *(float *)(d + 0x204)); vec[2] = *(float *)(d + 0x208) - D_0015ED70_c * 10.0f; @@ -1749,7 +1747,6 @@ typedef struct { extern char *D_L16_001B0930[]; extern f32 random_float_between(f32, f32) __asm__("func_002132A8"); -extern float D_0015ED6C; extern float approach_value_alt(float *, float, float) __asm__("FUN_00213ed8"); extern float D_L16_00161E68 __attribute__((sda)); extern float D_L16_00161E6C __attribute__((sda)); @@ -1831,7 +1828,7 @@ void FUN_L16_002e76b8(unsigned char *m) { next = other->parameter - random_float_between(D_L16_00161E68, D_L16_00161E6C); d->countdown--; } else { - next = d->parameter + D_L16_00161E8C * D_0015ED6C; + next = d->parameter + D_L16_00161E8C * frame_time; } if (next < 0.0f) { next += d->period; @@ -1844,7 +1841,7 @@ void FUN_L16_002e76b8(unsigned char *m) { d->parameter = next; d->height_step = height; - d->target_speed = random * D_0015ED6C; + d->target_speed = random * frame_time; } } } else { @@ -1875,9 +1872,9 @@ extern void func_L00_0026DD70_emit(void *, void *, int, int, float, int D_L16_00161E98 = 0x60d0d080; int D_L16_00161E9C = 0x801000; -extern short D_L16_00161EA0 __attribute__((sda)); -extern short D_L16_00161EA4 __attribute__((sda)); -extern short D_L16_00161EA8 __attribute__((sda)); +extern float D_L16_00161EA0 __attribute__((sda)); +extern float D_L16_00161EA4 __attribute__((sda)); +extern float D_L16_00161EA8 __attribute__((sda)); void FUN_L16_002e7a30(unsigned char *m, void *v) { float input[4]; float offset[4]; @@ -1892,16 +1889,16 @@ void FUN_L16_002e7a30(unsigned char *m, void *v) { if (!(FUN_001f9b48(m + 0x10, D_L16_001671C0) < 75.0f)) return; r = FUN_001f9b48(m + 0x10, input); - scale_vector_xyz(out, m + 0xC0, *(float *)&D_L16_00161EA0 * r); - size = *(float *)&D_L16_00161EA4; - size *= D_0015ED6C; + scale_vector_xyz(out, m + 0xC0, D_L16_00161EA0 * r); + size = D_L16_00161EA4; + size *= frame_time; normalize_vector_xyz(offset, m + 0xC0, -0.5f); add_vector_xyz(offset, offset, m + 0x10); a = random_angle_radians(); b = random_angle_radians(); build_spherical_offset_u(velocity, size, a, b); add_vector_xyz(velocity, velocity, out); - final_size = *(float *)&D_L16_00161EA8; + final_size = D_L16_00161EA8; final_size *= 210000.0f; func_L00_0026DD70_emit(offset, velocity, D_L16_00161E98, D_L16_00161E9C, final_size, scale_game_frames(0x23)); @@ -1930,7 +1927,6 @@ extern char *D_L16_0015FFD8; extern char *D_L16_001B0930[]; extern f32 convert_integer_to_float(s32) __asm__("func_001FA6C0"); extern f32 random_float_between(f32, f32) __asm__("func_002132A8"); -extern float D_0015ED6C; extern float D_L16_00161E94 __attribute__((sda)); /* no foreign declaration */ extern s32 random_integer_below(s32) __asm__("func_00213260"); extern short *D_L16_001ABCC0[]; @@ -1986,7 +1982,7 @@ void FUN_L16_002e7ba0(struct Moby *moby) { data->period = period; previous = current; data->height_step = random_float_between(D_L16_00161E7C, D_L16_00161E80); - data->speed = random_float_between(D_L16_00161E70, D_L16_00161E74) * D_0015ED6C; + data->speed = random_float_between(D_L16_00161E70, D_L16_00161E74) * frame_time; data->target_speed = data->speed; current[0x20] = 1; rank--; @@ -2088,7 +2084,6 @@ typedef struct { extern char *D_L16_001600FC; extern f32 advance_accelerated_scalar(f32 *, f32 *, f32, f32, f32, f32) __asm__("func_00213F38"); -extern float D_0015ED6C; extern float FUN_001f9b80(void *, void *); extern float D_L16_00161EAC __attribute__((sda)); /* no foreign declaration */ extern float D_L16_00161EBC __attribute__((sda)); /* no foreign declaration */ @@ -2171,11 +2166,11 @@ void FUN_L16_002e7f80(L16PlatformMoby *moby) { || moby->position[2] < d->goal) { speed = advance_accelerated_scalar(&moby->position[2], &d->speed, d->goal, D_L16_00161EBC * frame_time_sq, D_L16_00161EBC * frame_time_sq, - *(float *)&D_L16_00161EB8_gp * D_0015ED6C); + *(float *)&D_L16_00161EB8_gp * frame_time); } else { speed = advance_accelerated_scalar(&moby->position[2], &d->speed, moby->position[2], D_L16_00161EBC * 4.0f * frame_time_sq, D_L16_00161EBC * 4.0f * frame_time_sq, - *(float *)&D_L16_00161EB8_gp * D_0015ED6C); + *(float *)&D_L16_00161EB8_gp * frame_time); } clear_u64_value(motion.v); motion.v[2] = speed; @@ -2226,7 +2221,6 @@ typedef struct { } L16RingMatrix; extern float absolute_float(float) __asm__("func_001F99C0"); -extern float D_0015ED6C; extern float D_L16_001D9880[][2]; extern float fast_cos(float); extern float fast_sin(float); @@ -2268,7 +2262,7 @@ void FUN_L16_002e84e8(struct Moby *m) { lower += translation; color = fast_tween_color(D_L16_00161EDC, D_L16_00161EE0, - absolute_float((*(float *)((char *)d + 0xB0))) / (D_L16_00161EB8_gp * D_0015ED6C)); + absolute_float((*(float *)((char *)d + 0xB0))) / (D_L16_00161EB8_gp * frame_time)); copy_matrix_rotation(&matrix, &m->rot_row0); qcopy(matrix.position, &m->pos); matrix.position[2] = lower; @@ -2346,7 +2340,7 @@ void FUN_L16_002e88d0(struct Moby *moby) { } break; case 1: moby->rot.z = - FUN_001fa580(moby->rot.z, D_0015ED6C * -0.2617993950843811f); + FUN_001fa580(moby->rot.z, frame_time * -0.2617993950843811f); break; } } diff --git a/src/overlays/l16/gameplay/entities/rocket.c b/src/overlays/l16/gameplay/entities/rocket.c index 49763c8a7a..61bd514f1a 100644 --- a/src/overlays/l16/gameplay/entities/rocket.c +++ b/src/overlays/l16/gameplay/entities/rocket.c @@ -278,8 +278,8 @@ extern int D_L16_0015F5CC; extern int fast_dec_timer(int *arg0) __asm__("FUN_001f9740"); extern s32 SubtractIntegerWithClamp(s32); -extern short D_L16_00161A84 __attribute__((sda)); -extern short D_L16_00161A88 __attribute__((sda)); +extern float D_L16_00161A84 __attribute__((sda)); +extern int D_L16_00161A88 __attribute__((sda)); void FUN_L16_002d5cb8(struct Moby *moby) { char *data = (char *)moby->pvars; switch (moby->state) { @@ -292,14 +292,14 @@ void FUN_L16_002d5cb8(struct Moby *moby) { float f; if (r != 0) { if (r == 2) { - if (SubtractIntegerWithClamp(*(int *)&D_L16_00161A88 - D_L16_0015F5CC) >= 4) { - *(int *)&D_L16_00161A88 = D_L16_0015F5CC; + if (SubtractIntegerWithClamp(D_L16_00161A88 - D_L16_0015F5CC) >= 4) { + D_L16_00161A88 = D_L16_0015F5CC; allocate_voice_for_target_entry(1, 0, moby); } } f = *(float *)data; } else { - f = *(float *)data + *(float *)&D_L16_00161A84; + f = *(float *)data + D_L16_00161A84; } advance_accelerated_scalar(f, frame_time_sq * 10.0f, frame_time_sq * 10.0f, D_0015ED6C * 10.0f, &moby->pos.z, (float *)(data + 4)); @@ -339,10 +339,10 @@ void FUN_L16_002d6740(struct Moby *moby) { } /* Ported from rac1-decomp (src/overlays/l16_kalebo3/vendor_002A50F0.c: func_L16_002DF780), where it is exact; names translated to the US level program. */ -extern short D_L16_00161C74; +extern float D_L16_00161C74; void FUN_L16_002de3b8(float f) { - *(float *)&D_L16_00161C74 = f; + D_L16_00161C74 = f; } /* Ported from rac1-decomp (src/overlays/l16_kalebo3/vendor_002A50F0.c: func_L16_002E2248), where it is exact; names translated to the US level program. */ @@ -640,12 +640,12 @@ void build_spherical_offset_q(f32 *out, f32 scale, f32 a, f32 b) __asm__("FUN_00 extern void func_00215C00_57_q(float, float, float, void *) __asm__("FUN_00214db0"); extern int func_0022ED80_57_q(int, int, void *) __asm__("FUN_0022da68"); -extern short D_L16_001618E8 __attribute__((sda)); -extern short D_L16_001618EC __attribute__((sda)); -extern short D_L16_001618F0 __attribute__((sda)); -extern short D_L16_001618F4 __attribute__((sda)); -extern short D_L16_001618F8 __attribute__((sda)); -extern short D_L16_001618FC __attribute__((sda)); +extern float D_L16_001618E8 __attribute__((sda)); +extern float D_L16_001618EC __attribute__((sda)); +extern float D_L16_001618F0 __attribute__((sda)); +extern float D_L16_001618F4 __attribute__((sda)); +extern float D_L16_001618F8 __attribute__((sda)); +extern float D_L16_001618FC __attribute__((sda)); void FUN_L16_002c44f0(struct Moby *m, void *p) { float origin[4]; float pos[4]; @@ -666,17 +666,17 @@ void FUN_L16_002c44f0(struct Moby *m, void *p) { float *effectVelocity = vel; i = 3; do { - radius = random_float_between_alt_q(*(float *)&D_L16_001618F8, - *(float *)&D_L16_001618FC); + radius = random_float_between_alt_q(D_L16_001618F8, + D_L16_001618FC); a = random_angle_radians_q(); b = random_angle_radians_q(); func_00215C00_57_q(radius, a, b, effectPosition); - out[2] += *(float *)&D_L16_001618F4; + out[2] += D_L16_001618F4; add_vector_xyz_q(effectPosition, effectPosition, &m->pos); - speed = random_float_between_alt_q(*(float *)&D_L16_001618EC * D_0015ED6C, - *(float *)&D_L16_001618F0 * D_0015ED6C); + speed = random_float_between_alt_q(D_L16_001618EC * D_0015ED6C, + D_L16_001618F0 * D_0015ED6C); b = random_angle_radians_q(); - func_00215C00_57_q(speed, b, *(float *)&D_L16_001618E8 * DEG_TO_RAD, + func_00215C00_57_q(speed, b, D_L16_001618E8 * DEG_TO_RAD, effectVelocity); speed = random_float_between_alt_q(3.5f, 5.5f); vel[2] = speed * D_0015ED6C; @@ -864,7 +864,7 @@ void FUN_L16_002c9cd0(char *m); extern void normalize_vector_xyz(void *out, void *a, f32 len) __asm__("FUN_001f9bf8"); s32 is_point_inside_clip_volume(s32 arg0, s32 arg1) __asm__("FUN_00214720"); -extern short D_L16_0016198C __attribute__((sda)); +extern float D_L16_0016198C __attribute__((sda)); void FUN_L16_002c9878(struct Moby *m) { char *d = (char *)m->pvars; float vec[4]; @@ -883,7 +883,7 @@ void FUN_L16_002c9878(struct Moby *m) { *(int *)(d + 0x74) = -1; break; case 2: - target = -(*(float *)&D_L16_0016198C * D_0015ED6C); + target = -(D_L16_0016198C * D_0015ED6C); if (*(float *)(d + 0x6C) != target) { approach_value((float *)(d + 0x6C), target, D_0015ED70_c * 12.0f); normalize_vector_xyz(vec, &m->rot_row0, *(float *)(d + 0x6C)); @@ -894,7 +894,7 @@ void FUN_L16_002c9878(struct Moby *m) { enqueue_callback_list_1_alt(FUN_L16_002c9cd0, m); break; case 1: - target = *(float *)&D_L16_0016198C * D_0015ED6C; + target = D_L16_0016198C * D_0015ED6C; if (*(float *)(d + 0x6C) != target) { approach_value((float *)(d + 0x6C), target, D_0015ED70_c * 12.0f); normalize_vector_xyz(vec, &m->rot_row0, *(float *)(d + 0x6C)); @@ -1645,7 +1645,7 @@ int FUN_L16_002ced20(char *moby, void *vec, float angle) { extern f32 fast_add_rotations(f32 a, f32 b) __asm__("FUN_001fa580"); extern int *D_L16_001ABCC0_c2[] __asm__("D_L16_001ABCC0"); -extern short D_L16_001619DC; +extern float D_L16_001619DC; extern void FUN_L16_002cef60(); void FUN_L16_002cee70(struct Moby *moby) { @@ -1654,7 +1654,7 @@ void FUN_L16_002cee70(struct Moby *moby) { char *m; char *data; if (moby->group != 0xFF) { - f = *(float *)&D_L16_001619DC * DEG_TO_RAD * D_0015ED6C; + f = D_L16_001619DC * DEG_TO_RAD * D_0015ED6C; p = (short *)D_L16_001ABCC0_c2[moby->group]; do { again: @@ -1760,7 +1760,7 @@ extern float random_angle_radians(void) __asm__("FUN_00213308"); extern int scale_game_frames(int); extern int tick_countdown_32(int *); extern int truncate_float_to_s32(float); -extern short D_0014C050 __attribute__((section(".data"))); +extern unsigned char visited52_lui[] __asm__("D_0014C050") __attribute__((section(".data"))); extern void FUN_L16_002e3770(void *, int); extern void allocate_voice_for_target_entry(int, int, void *) __asm__("FUN_0022da68"); extern int func_0022ED80_i(int, int, void *) __asm__("FUN_0022da68"); @@ -1772,7 +1772,7 @@ void FUN_L16_002cf198(struct Moby *m) { case 0: (*(float *)((char *)(d) + (0x68))) = random_angle_radians(); (*(float *)((char *)(d) + (0x30))) = 0.001f; - if ((*(unsigned char *)((char *)(((char *)&D_0014C050) + (current_level_index << 4)) + + if ((*(unsigned char *)((char *)(((char *)&(*(short *)&visited52_lui)) + (current_level_index << 4)) + ((*(unsigned char *)((char *)(m) + (0xB0)))))) == 255 && (*(int *)((char *)(d) + (0x64))) == -1) { (*(unsigned char *)((char *)(m) + (0xBC))) = 1; @@ -2712,8 +2712,8 @@ extern void FUN_0022da68_5e80(int, int, void *) __asm__("FUN_0022da68"); void FUN_L16_002d5e80(struct Moby *m) { char *d = (char *)m->pvars; if (*(int *)(d + 8) == 0) { - if (FUN_001f99a8_5e80(*(int *)&D_L16_00161A88 - D_L16_0015F5CC) >= 4) { - *(int *)&D_L16_00161A88 = D_L16_0015F5CC; + if (FUN_001f99a8_5e80(D_L16_00161A88 - D_L16_0015F5CC) >= 4) { + D_L16_00161A88 = D_L16_0015F5CC; FUN_0022da68_5e80(0, 0, m); } } @@ -2854,7 +2854,7 @@ extern void clear_u64_value(void *) __asm__("FUN_001f99f8"); extern void lerp_vector(void *, void *, void *, float) __asm__("FUN_001f9a40"); extern void FUN_001f9cf8(void *, void *, void *); -extern short D_L16_00161A8C __attribute__((sda)); +extern float D_L16_00161A8C __attribute__((sda)); void FUN_L16_002d6260(struct Moby *moby, void *out1, float *out2) { char *data = (char *)moby->pvars; float v[4]; @@ -2868,7 +2868,7 @@ void FUN_L16_002d6260(struct Moby *moby, void *out1, float *out2) { (float *)(data + 0x20)); lerp_vector(out1, tbl + 0x10, tbl + 0x20, *(float *)(data + 0x1C)); clear_u64_value(out2); - out2[1] = *(float *)&D_L16_00161A8C; + out2[1] = D_L16_00161A8C; out2[2] = moby->rot.z; } diff --git a/src/overlays/l16/gameplay/hero/002097a0.c b/src/overlays/l16/gameplay/hero/002097a0.c index 089fc7c62d..1552348fc0 100644 --- a/src/overlays/l16/gameplay/hero/002097a0.c +++ b/src/overlays/l16/gameplay/hero/002097a0.c @@ -546,7 +546,6 @@ extern void subtract_vector_xyz(void *, void *, void *) __asm__("FUN_001f9a28"); s32 FUN_001efa68(void *, void *, s32, s32, s32); void FUN_L16_0020ffb0(void); extern char D_0013F430[] __attribute__((section(".sdata"))); -extern char D_0013F350[]; void FUN_L16_00211098(void) { V previous; @@ -617,7 +616,7 @@ void FUN_L16_00211098(void) { char *hit = D_L16_00174258[0]; if (!hit || *(short *)(hit + 0xA6) == 0x1F6 || *(short *)(hit + 0xA6) == 0x59F) { - player = (L16MovementPlayer *)(((char *)&D_0013F350)); + player = (L16MovementPlayer *)(((char *)((char *)&hero))); if (!player->unconstrained) { float length; float limit; @@ -715,7 +714,7 @@ void FUN_L16_00211098(void) { if (motion_player->slope > 0.5f) motion_player->slope = 0.5f; else if (motion_player->slope < -0.5f) motion_player->slope = -0.5f; } - cap_player = (L16MovementPlayer *)(((char *)&D_0013F350)); + cap_player = (L16MovementPlayer *)(((char *)((char *)&hero))); magnitude = frame_time * 52.0f; if (magnitude < cap_player->speed) { scale_vector_xyz(cap_player->external, cap_player->external, magnitude / cap_player->speed); diff --git a/src/overlays/l17/gameplay/entities/blarg_ship.c b/src/overlays/l17/gameplay/entities/blarg_ship.c index 45f8c9c033..1e69672ba4 100644 --- a/src/overlays/l17/gameplay/entities/blarg_ship.c +++ b/src/overlays/l17/gameplay/entities/blarg_ship.c @@ -38,7 +38,7 @@ extern void FUN_L06_00239528(void); extern int hero_set_state(int, int) __asm__("FUN_L17_0021e530"); extern char D_00141D54[]; extern char D_00141D7C[]; -extern unsigned char D_0014C050[]; +#include "rnc/gameplay/state/game_globals.h" extern int func_001F9908_i(int *) __asm__("FUN_001f9740"); void FUN_L17_002f26d0(struct Moby *moby) { @@ -204,7 +204,7 @@ void FUN_L17_002f26d0(struct Moby *moby) { *(int *)(d + 0x2C) = 0; } if (*(int *)(d + 0x58) != 0xFF && - D_0014C050[*(int *)(d + 0x58) + (current_level_index << 4)] == 0xFF) { + visited52[*(int *)(d + 0x58) + (current_level_index << 4)] == 0xFF) { *(unsigned char *)(d + 0x4C) = 1; } if (*(unsigned char *)(d + 0x4C) == 0 && @@ -430,8 +430,8 @@ void FUN_L17_002f32f0(struct Moby *moby) { /* Ported from rac1-decomp (src/overlays/l17_fleet/vendor_002F1558.c: func_L17_002F5388), where it is exact; names translated to the US level program. */ -extern short D_L17_001623D0 __attribute__((sda)); -extern short D_L17_001623D8 __attribute__((sda)); +extern float D_L17_001623D0 __attribute__((sda)); +extern float D_L17_001623D8 __attribute__((sda)); extern void FUN_L17_002f32f0_c(char *) __asm__("FUN_L17_002f32f0"); extern void enqueue_callback_list_1_alt(void (*)(void), void *) __asm__("FUN_001f4600"); s32 is_point_inside_clip_volume_u(s32 arg0, s32 arg1) __asm__("FUN_00214720"); @@ -440,7 +440,7 @@ void build_spherical_offset(f32 *out, f32 scale, f32 a, f32 b) __asm__("FUN_0021 extern float D_L17_001DDFE0[]; extern float D_L17_001DE058[]; extern float D_L17_001DE070[]; -extern short D_L17_001623D4 __attribute__((sda)); +extern float D_L17_001623D4 __attribute__((sda)); void FUN_L17_002f3848(struct Moby *moby) { char *d = (char *)moby->pvars; float t0[4]; @@ -466,9 +466,9 @@ void FUN_L17_002f3848(struct Moby *moby) { } qcopy(d, &moby->pos); build_spherical_offset( - t0, (*(float *)&D_L17_001623D4 + *(float *)&D_L17_001623D0) / *(float *)&D_L17_001623D8, + t0, (D_L17_001623D4 + D_L17_001623D0) / D_L17_001623D8, moby->rot.z, 0.0f); - build_spherical_offset(t1, *(float *)&D_L17_001623D0 / *(float *)&D_L17_001623D8, + build_spherical_offset(t1, D_L17_001623D0 / D_L17_001623D8, *(float *)(d + 0x44), 0.0f); add_vector_xyz(t2, t0, t1); *(OvlQuad *)t0 = *(OvlQuad *)t2; @@ -545,7 +545,7 @@ extern void transform_vector_by_basis(void *, void *, void *) __asm__("func_001F extern void vu_euler_rotation_basis(void *, void *) __asm__("func_001FA030"); void blend_moby_animation(MobyAnim *arg0, int arg1, int arg2, int arg3) __asm__("FUN_00212f90"); -extern short D_L17_001623E8 __attribute__((sda)); +extern float D_L17_001623E8 __attribute__((sda)); void FUN_L17_002f40d8(struct Moby *moby) { float s0[4]; float s10[4]; @@ -707,7 +707,7 @@ void FUN_L17_002f40d8(struct Moby *moby) { } add_vector_xyz(sA0, sA0, &moby->pos.x); subtract_vector_xyz(s80, sB0, sA0); - normalize_vector_xyz(s90, s80, *(float *)&D_L17_001623E8 * frame_time); + normalize_vector_xyz(s90, s80, D_L17_001623E8 * frame_time); add_vector_xyz(s90, s90, s20); p = FUN_L11_00308f48((int)moby, s90, sA0, 128.0f, -1.0f, 10.0f); if (p) { diff --git a/src/overlays/l18/gameplay/entities/rocket.c b/src/overlays/l18/gameplay/entities/rocket.c index 9edaa043e5..f755c906a4 100644 --- a/src/overlays/l18/gameplay/entities/rocket.c +++ b/src/overlays/l18/gameplay/entities/rocket.c @@ -112,8 +112,8 @@ void FUN_L18_002d7f68(struct Moby *arg, int value) { extern float FUN_001f9de0(float); extern float FUN_001fa580(float, float); -extern short D_L18_00161A48 __attribute__((sda)); -extern short D_L18_00161A4C __attribute__((sda)); +extern float D_L18_00161A48 __attribute__((sda)); +extern float D_L18_00161A4C __attribute__((sda)); void FUN_L18_002d8710(struct Moby *moby) { char *data = (char *)moby->pvars; float v = FUN_001fa580(moby->rot.y, *(float *)(data + 0x6C)); @@ -138,9 +138,9 @@ void FUN_L18_002d8710(struct Moby *moby) { } } *(float *)(data + 0x74) = FUN_001fa580(*(float *)(data + 0x74), - *(float *)&D_L18_00161A4C * DEG_TO_RAD * frame_time); + D_L18_00161A4C * DEG_TO_RAD * frame_time); moby->pos.z = *(float *)(data + 0x64) + - *(float *)&D_L18_00161A48 * FUN_001f9de0(*(float *)(data + 0x74)); + D_L18_00161A48 * FUN_001f9de0(*(float *)(data + 0x74)); } #define NOT_SDA @@ -178,7 +178,7 @@ extern void FUN_L18_002dc4b8(); extern void enqueue_callback_list_1(void (*)(void), void *) __asm__("FUN_001f4600"); void mark_moby_for_removal(struct Obj *obj) __asm__("FUN_0020c828"); -extern short D_L18_00161CA0 __attribute__((sda)); +extern float D_L18_00161CA0 __attribute__((sda)); void FUN_L18_002dc260(struct Moby *moby) { char buf[0x30]; float v[4]; @@ -202,7 +202,7 @@ void FUN_L18_002dc260(struct Moby *moby) { FUN_L00_00259a88(*(int *)(tgt + 0x2000), buf); } flag = game_frame & 4; - d[1] = d[1] + *(float *)&D_L18_00161CA0 * frame_time; + d[1] = d[1] + D_L18_00161CA0 * frame_time; if (flag == 0) { FUN_L00_002598b0(*(int *)(d + 3), d[0], pos, 0x10000, 1.0f, 1.0f, 0, 1, 0); } @@ -456,7 +456,7 @@ extern f32 convert_integer_to_float(s32) __asm__("FUN_001fa6c0"); extern float FUN_001f96b0(float); extern int D_L18_0015F5C4; extern int FUN_001efa68(void *, void *, int, void *, void *); -extern short D_L18_00161964; +extern float D_L18_00161964; extern void FUN_001f9a10(void *, void *, void *); extern void FUN_001f9a40(void *, void *, void *, float); extern void fast_vec_scale(void *, void *, float) __asm__("FUN_001f9a68"); @@ -526,7 +526,7 @@ void FUN_L18_002d5050(struct Moby *moby) { mark_moby_for_removal(moby); } else if (d->flags & 2) { f = (float)(d->end - d->c); - if (f <= FUN_001f96b0(*(float *)&D_L18_00161964)) { + if (f <= FUN_001f96b0(D_L18_00161964)) { enqueue_callback_list_1(FUN_L18_002d5768, moby); } } @@ -610,7 +610,7 @@ typedef struct { float v[4]; } __attribute__((aligned(16))) QVec; -extern short D_L18_0016196C __attribute__((sda)); +extern float D_L18_0016196C __attribute__((sda)); void FUN_L18_002d5610(void *m, void *src) { char *moby = m; @@ -628,7 +628,7 @@ void FUN_L18_002d5610(void *m, void *src) { 0, -1, 0); if (d != 0.0f) { if (hero.vehicle_mode == 2) { - FUN_L00_002598b0((int)moby, 2.0f, moby + 0x10, 2, *(float *)&D_L18_0016196C, 1.0f, 0, 1, + FUN_L00_002598b0((int)moby, 2.0f, moby + 0x10, 2, D_L18_0016196C, 1.0f, 0, 1, 0); } } @@ -1120,12 +1120,12 @@ extern void upd_a(void *) __asm__("FUN_L00_00250df8"); f32 probe_ground_height(void *arg0, s32 arg1, f32 arg2) __asm__("FUN_00213508"); void mmr_q(void *obj) __asm__("FUN_0020c828"); -extern short D_L18_00161998 __attribute__((sda)); -extern short D_L18_0016199C __attribute__((sda)); -extern short D_L18_001619A0 __attribute__((sda)); +extern float D_L18_00161998 __attribute__((sda)); +extern float D_L18_0016199C __attribute__((sda)); +extern float D_L18_001619A0 __attribute__((sda)); void FUN_L18_002d6600(char *moby) { L18E_q *d = *(L18E_q **)(moby + 0x78); - *(float *)(moby + 0x2C) = (*(L18Cls_q **)(moby + 0x24))->f24 * *(float *)&D_L18_00161998; + *(float *)(moby + 0x2C) = (*(L18Cls_q **)(moby + 0x24))->f24 * D_L18_00161998; switch (((unsigned char *)moby)[0x20]) { case 0: { *(float *)(moby + 0x18) = *(float *)(moby + 0x18) + 1.0f; @@ -1141,7 +1141,7 @@ void FUN_L18_002d6600(char *moby) { *(short *)(a + 0x32) = 0x56; a[0x31] = 1; *(short *)(a + 0x32) = 0x56; - *(float *)(a + 0x2C) = (*(L18Cls_q **)(a + 0x24))->f24 * *(float *)&D_L18_00161998; + *(float *)(a + 0x2C) = (*(L18Cls_q **)(a + 0x24))->f24 * D_L18_00161998; qcopy(a + 0x10, d); qcopy(a + 0x40, moby + 0x40); upd_a(a); @@ -1152,7 +1152,7 @@ void FUN_L18_002d6600(char *moby) { *(short *)(d->p14 + 0x32) = 0x56; d->p14[0x31] = 1; *(float *)(d->p14 + 0x2C) = - (*(L18Cls_q **)(d->p14 + 0x24))->f24 * *(float *)&D_L18_00161998; + (*(L18Cls_q **)(d->p14 + 0x24))->f24 * D_L18_00161998; { char *q = d->p14; qcopy(q + 0x40, moby + 0x40); @@ -1163,7 +1163,7 @@ void FUN_L18_002d6600(char *moby) { *(short *)(d->p18 + 0x32) = 0x40; d->p18[0x31] = 1; *(float *)(d->p18 + 0x2C) = - (*(L18Cls_q **)(d->p18 + 0x24))->f24 * *(float *)&D_L18_00161998; + (*(L18Cls_q **)(d->p18 + 0x24))->f24 * D_L18_00161998; { char *q = d->p18; qcopy(q + 0x40, moby + 0x40); @@ -1173,7 +1173,7 @@ void FUN_L18_002d6600(char *moby) { ((unsigned char *)moby)[0x20] = 1; { float t = *(float *)(moby + 0x18); - float u = *(float *)&D_L18_001619A0; + float u = D_L18_001619A0; d->f10 = t; d->f34 = u; } @@ -1215,12 +1215,12 @@ void FUN_L18_002d6600(char *moby) { (*(float *)&D_L18_00161A6C) * 4.0f); } else { float k = D_0015EE70; - advance_accelerated_scalar(&d->f34, &d->f28, *(float *)&D_L18_0016199C, k * 16.0f, k * 4.0f, + advance_accelerated_scalar(&d->f34, &d->f28, D_L18_0016199C, k * 16.0f, k * 4.0f, (*(float *)&D_L18_00161A6C) * 8.0f); } - } else if (d->f34 != *(float *)&D_L18_001619A0) { + } else if (d->f34 != D_L18_001619A0) { float k = D_0015EE70; - advance_accelerated_scalar(&d->f34, &d->f28, *(float *)&D_L18_001619A0, k * 16.0f, k * 4.0f, + advance_accelerated_scalar(&d->f34, &d->f28, D_L18_001619A0, k * 16.0f, k * 4.0f, (*(float *)&D_L18_00161A6C) * 8.0f); } else { advance_accelerated_scalar(&d->f20, &d->f28, d->f24, D_0015EE70 * 4.0f, D_0015EE70 * 4.0f, @@ -1682,24 +1682,24 @@ extern int scale_game_frames(int); extern int tick_countdown_32(int *); extern int truncate_float_to_s32_p() __asm__("FUN_001fa6d0"); extern short D_L18_00161BFC __attribute__((sda)); -extern short D_L18_00161C00 __attribute__((sda)); -extern short D_L18_00161C04 __attribute__((sda)); -extern short D_L18_00161C08 __attribute__((sda)); -extern short D_L18_00161C0C __attribute__((sda)); -extern short D_L18_00161C10 __attribute__((sda)); -extern short D_L18_00161C14 __attribute__((sda)); -extern short D_L18_00161C18 __attribute__((sda)); -extern short D_L18_00161C1C __attribute__((sda)); -extern short D_L18_00161C20 __attribute__((sda)); -extern short D_L18_00161C24; -extern short D_L18_00161C28 __attribute__((sda)); -extern short D_L18_00161C2C __attribute__((sda)); -extern short D_L18_00161C30 __attribute__((sda)); -extern short D_L18_00161C34; -extern short D_L18_00161C38 __attribute__((sda)); -extern short D_L18_00161C3C __attribute__((sda)); -extern short D_L18_00161C40 __attribute__((sda)); -extern short D_L18_00161C44 __attribute__((sda)); +extern int D_L18_00161C00 __attribute__((sda)); +extern float D_L18_00161C04 __attribute__((sda)); +extern float D_L18_00161C08 __attribute__((sda)); +extern float D_L18_00161C0C __attribute__((sda)); +extern int D_L18_00161C10 __attribute__((sda)); +extern int D_L18_00161C14 __attribute__((sda)); +extern int D_L18_00161C18 __attribute__((sda)); +extern float D_L18_00161C1C __attribute__((sda)); +extern float D_L18_00161C20 __attribute__((sda)); +extern float D_L18_00161C24; +extern float D_L18_00161C28 __attribute__((sda)); +extern float D_L18_00161C2C __attribute__((sda)); +extern int D_L18_00161C30 __attribute__((sda)); +extern int D_L18_00161C34; +extern int D_L18_00161C38 __attribute__((sda)); +extern int D_L18_00161C3C __attribute__((sda)); +extern int D_L18_00161C40 __attribute__((sda)); +extern int D_L18_00161C44 __attribute__((sda)); extern void FUN_L00_00259fe8(unsigned char *m, float s); extern void FUN_L18_002dba20(); extern void FUN_L18_002dbe80_c(char *moby) __asm__("FUN_L18_002dbe80"); @@ -1725,36 +1725,36 @@ void FUN_L18_002db460(struct Moby *moby) { case 0: { float *cc; i = 0; - for (; i < *(int *)&D_L18_00161C40; i++) { + for (; i < D_L18_00161C40; i++) { cc = c; - scale_vector_xyz(v, d, *(float *)&D_L18_00161C08); - FUN_L00_00257d78(cc, 0.0f, *(float *)&D_L18_00161C0C * frame_time); + scale_vector_xyz(v, d, D_L18_00161C08); + FUN_L00_00257d78(cc, 0.0f, D_L18_00161C0C * frame_time); add_vector_xyz(v, cc, v); FUN_L00_00257d78(w, 0.0f, 0.5f); add_vector_xyz(w, w, &moby->pos); clear_vector(a); - v[3] = random_float_between(*(float *)&D_L18_00161C20, *(float *)&D_L18_00161C24); - a[3] = random_float_between(*(float *)&D_L18_00161C28, *(float *)&D_L18_00161C2C); - i0 = FUN_001fa6e0(*(int *)&D_L18_00161C30, *(int *)&D_L18_00161C34, + v[3] = random_float_between(D_L18_00161C20, D_L18_00161C24); + a[3] = random_float_between(D_L18_00161C28, D_L18_00161C2C); + i0 = FUN_001fa6e0(D_L18_00161C30, D_L18_00161C34, random_float_between(0.0f, 1.0f)); - i1 = FUN_001fa6e0(*(int *)&D_L18_00161C38, *(int *)&D_L18_00161C3C, + i1 = FUN_001fa6e0(D_L18_00161C38, D_L18_00161C3C, random_float_between(0.0f, 1.0f)); i2 = func_001FA898_r(FUN_001f96b0( - (float)*(int *)&D_L18_00161C10 * random_float_between(0.0f, 1.0f) + 1.0f)); + (float)D_L18_00161C10 * random_float_between(0.0f, 1.0f) + 1.0f)); i3 = func_001FA898_r(FUN_001f96b0( - (float)*(int *)&D_L18_00161C14 * - (random_float_between(-*(float *)&D_L18_00161C1C, *(float *)&D_L18_00161C1C) + + (float)D_L18_00161C14 * + (random_float_between(-D_L18_00161C1C, D_L18_00161C1C) + 1.0f))); i4 = func_001FA898_r(FUN_001f96b0( - (float)*(int *)&D_L18_00161C18 * - (random_float_between(-*(float *)&D_L18_00161C1C, *(float *)&D_L18_00161C1C) + + (float)D_L18_00161C18 * + (random_float_between(-D_L18_00161C1C, D_L18_00161C1C) + 1.0f))); - a[2] = a[2] - *(float *)&D_L18_00161C04 * frame_time_sq * (float)i3; - spawn_spark(w, v, a, i0, i1, i2, i3, i4, *(int *)&D_L18_00161C44); + a[2] = a[2] - D_L18_00161C04 * frame_time_sq * (float)i3; + spawn_spark(w, v, a, i0, i1, i2, i3, i4, D_L18_00161C44); } d[12] = fast_add_rotations(d[12], frame_time * 18.849556f); { - int col = FUN_001fa6e0(*(int *)&D_L18_00161BFC, *(int *)&D_L18_00161C00, + int col = FUN_001fa6e0(*(int *)&D_L18_00161BFC, D_L18_00161C00, (fast_sin(d[12]) + 1.0f) * 0.5f); float k = frame_time_sq * 10.0f; moby->glow_color = col; @@ -1780,7 +1780,7 @@ void FUN_L18_002db460(struct Moby *moby) { } case 1: d[12] = fast_add_rotations(d[12], frame_time * 18.849556f); - moby->glow_color = FUN_001fa6e0(*(int *)&D_L18_00161BFC, *(int *)&D_L18_00161C00, + moby->glow_color = FUN_001fa6e0(*(int *)&D_L18_00161BFC, D_L18_00161C00, (fast_sin(d[12]) + 1.0f) * 0.5f); if (tick_countdown_32((int *)(d + 11))) { FUN_L00_0028dc90(0xF, 0, (int)moby, 0x58E); @@ -1809,7 +1809,7 @@ void FUN_L18_002db460(struct Moby *moby) { extern short D_L18_00161BFC_d __asm__("D_L18_00161BFC") __attribute__((sda)); -extern short D_L18_00161BF8 __attribute__((sda)); +extern float D_L18_00161BF8 __attribute__((sda)); void FUN_L18_002db938(char *pos, float *vec, int arg, float fa, float fb) { Obj *o = (Obj *)func_0020D348_m(0x270); if (o != 0) { @@ -1819,7 +1819,7 @@ void FUN_L18_002db938(char *pos, float *vec, int arg, float fa, float fb) { o->b31 = 1; o->b20 = 0; g = *(int *)&D_L18_00161BFC_d; - o->f2C = o->f2C * *(float *)&D_L18_00161BF8; + o->f2C = o->f2C * D_L18_00161BF8; o->s32 = 0xFF; o->h34 |= 0x10; o->f90 = g; @@ -1993,13 +1993,13 @@ extern int FUN_001fa728(char *, float); extern s32 random_integer_below(s32) __asm__("FUN_00213260"); extern void FUN_L00_002730e0(void *, void *, int, int, int, int, float); -extern short D_L18_00161BF4 __attribute__((sda)); -extern short D_L18_00161C80 __attribute__((sda)); -extern short D_L18_00161C84 __attribute__((sda)); -extern short D_L18_00161C88 __attribute__((sda)); -extern short D_L18_00161C8C __attribute__((sda)); -extern short D_L18_00161C90 __attribute__((sda)); -extern short D_L18_00161C98 __attribute__((sda)); +extern float D_L18_00161BF4 __attribute__((sda)); +extern int D_L18_00161C80 __attribute__((sda)); +extern int D_L18_00161C84 __attribute__((sda)); +extern float D_L18_00161C88 __attribute__((sda)); +extern int D_L18_00161C8C __attribute__((sda)); +extern int D_L18_00161C90 __attribute__((sda)); +extern float D_L18_00161C98 __attribute__((sda)); void FUN_L18_002dc0c8(struct Moby *moby, void *a1, void *a2) { float buf[4]; float v[4]; @@ -2009,20 +2009,20 @@ void FUN_L18_002dc0c8(struct Moby *moby, void *a1, void *a2) { FUN_001f9a40(buf, a1, a2, 0.5f); buf[3] = FUN_001f9b48(a1, a2) * 0.5f; - if (FUN_001fa728((char *)buf, *(float *)&D_L18_00161BF4) == -1) { + if (FUN_001fa728((char *)buf, D_L18_00161BF4) == -1) { return; } - if (random_float_between(0.0f, 1.0f) < *(float *)&D_L18_00161C98) { + if (random_float_between(0.0f, 1.0f) < D_L18_00161C98) { FUN_001f9a40(v, a1, a2, random_float_between(0.0f, 1.0f)); FUN_001f9a28(w, v, &moby->pos); fast_vec_normalize(w, w, *(float *)(d + 0x20)); - col = FUN_001fa6e0(*(int *)&D_L18_00161C80, *(int *)&D_L18_00161C84, + col = FUN_001fa6e0(D_L18_00161C80, D_L18_00161C84, random_float_between(0.0f, 1.0f)); - FUN_L00_002730e0(v, w, col, FUN_001f96f8(*(int *)&D_L18_00161C8C) & 0xFF, - random_integer_below(0xFF) & 0xFF, 0, *(float *)&D_L18_00161C88); + FUN_L00_002730e0(v, w, col, FUN_001f96f8(D_L18_00161C8C) & 0xFF, + random_integer_below(0xFF) & 0xFF, 0, D_L18_00161C88); w[2] = 0.0f; - FUN_L00_002730e0(v, w, col, FUN_001f96f8(*(int *)&D_L18_00161C90) & 0xFF, - random_integer_below(0xFF) & 0xFF, 0, *(float *)&D_L18_00161C88); + FUN_L00_002730e0(v, w, col, FUN_001f96f8(D_L18_00161C90) & 0xFF, + random_integer_below(0xFF) & 0xFF, 0, D_L18_00161C88); } } /* Ported from rac1-decomp (src/overlays/l18_veldin2/vendor_002A8400.c: func_L18_002DD848), where it is exact; names translated to the US level program. */ @@ -2333,7 +2333,7 @@ extern void spawn_particle_alt_9768(float, void *, void *, int, int, int) __asm_ extern float D_0015EE70 __asm__("D_0015ED70"); extern int D_L18_0015F580; extern float D_0013F3D0[4]; -extern unsigned char D_0014C050[]; +#include "rnc/gameplay/state/game_globals.h" extern unsigned char D_L18_001F29A0_9768[] __asm__("D_L18_001F29A0"); extern unsigned char D_L18_001F29B8_9768[] __asm__("D_L18_001F29B8"); @@ -2347,7 +2347,7 @@ void FUN_L18_002e9768(struct Moby *moby) { case 0: { if (moby->mission != 0xff) { int unkB0 = moby->mission + current_level_index * 16; - if (((unsigned char *)((int *)D_0014C050))[unkB0] == 0xff) goto remove; + if (((unsigned char *)((int *)visited52))[unkB0] == 0xff) goto remove; } moby->state = 1; if (*(int *)data != 0) *(int *)(*(int *)data) = 3; @@ -2475,14 +2475,14 @@ extern void mark_moby_for_removal_c2(void *) __asm__("func_0020C828"); void FUN_L18_002ea598_c(char *moby) __asm__("FUN_L18_002ea598"); extern void spark_s(int, void *, float, int, float, float, int, int, int) __asm__("FUN_L00_002598b0"); -extern short D_L18_00161ED0 __attribute__((sda)); -extern short D_L18_00161ED4 __attribute__((sda)); -extern short D_L18_00161ED8 __attribute__((sda)); -extern short D_L18_00161EE0 __attribute__((sda)); +extern float D_L18_00161ED0 __attribute__((sda)); +extern float D_L18_00161ED4 __attribute__((sda)); +extern float D_L18_00161ED8 __attribute__((sda)); +extern float D_L18_00161EE0 __attribute__((sda)); void FUN_L18_002e9e70(struct Moby *moby) { float *d = (float *)moby->pvars; - float t = fast_add_rotations_c(d[0xB], *(float *)&D_L18_00161ED0 * DEG_TO_RAD * frame_time); - float u = *(float *)&D_L18_00161ED4 * DEG_TO_RAD * frame_time; + float t = fast_add_rotations_c(d[0xB], D_L18_00161ED0 * DEG_TO_RAD * frame_time); + float u = D_L18_00161ED4 * DEG_TO_RAD * frame_time; d[0xB] = t; d[0xC] = fast_add_rotations_c(d[0xC], u); switch (MOBY(moby)->state) { @@ -2497,12 +2497,12 @@ void FUN_L18_002e9e70(struct Moby *moby) { float buf2[4]; float *p = &moby->pos.x; float *q = d + 4; - float lim = *(float *)&D_L18_00161EE0 * frame_time; + float lim = D_L18_00161EE0 * frame_time; float len; subtract_vector_xyz(buf, d, p); len = vector_length_xyz(buf); FUN_L18_002ea598_c(moby); - FUN_L00_00257d78(q, *(float *)&D_L18_00161ED8 * d[9], *(float *)&D_L18_00161ED8 * d[9]); + FUN_L00_00257d78(q, D_L18_00161ED8 * d[9], D_L18_00161ED8 * d[9]); add_vector_xyz(q, q, p); FUN_L18_002eacd8(moby); FUN_L18_002eaea0_u(moby); diff --git a/src/overlays/shared/audio/voices/00276368.c b/src/overlays/shared/audio/voices/00276368.c index e57c5b7e7b..858f9c0e6b 100644 --- a/src/overlays/shared/audio/voices/00276368.c +++ b/src/overlays/shared/audio/voices/00276368.c @@ -17,7 +17,7 @@ typedef unsigned int u128_init __attribute__((mode(TI), aligned(16))); extern struct Own D_L00_001B71F0; extern s32 D_L00_00173E04; extern s32 D_L00_00173E08; -extern u8 D_L00_00173E40[] __attribute__((section(".data"))); +extern int D_L00_00173E40_lui[] __asm__("D_L00_00173E40") __attribute__((section(".data"))); extern void *D_L00_00197300[]; extern s32 D_L00_0015F3F8_gp __asm__("D_L00_0015F3F8") __attribute__((sda)); extern s32 frame_size __asm__("D_0013E504"); @@ -90,7 +90,7 @@ void FUN_L00_00276368(void) { s32 id; struct Own *owner; - { s32 *table = (s32 *)D_L00_00173E40; table[4] |= 0x80000000; } + { s32 *table = (s32 *)((u8 *)&D_L00_00173E40_lui); table[4] |= 0x80000000; } D_L00_001B9CF0.unk124 = 0; D_L00_001B9CF0.unkD0 = 0; if (D_L00_001B9CF0.state == 10) { @@ -251,7 +251,7 @@ extern s32 D_00141660[]; extern s32 D_0015EE78_gp __attribute__((sda)); extern void *D_L00_00197300[]; extern u8 D_L00_0017E4D8[] __attribute__((section(".data"))); -extern u8 D_L00_00173E40[] __attribute__((section(".data"))); +extern int D_L00_00173E40_lui[] __asm__("D_L00_00173E40") __attribute__((section(".data"))); extern void FUN_L00_002a09d8(s32); extern void FUN_L00_002a07f8(void) __asm__("FUN_002335d0"); extern void FUN_L00_002a08c8(void); @@ -347,7 +347,7 @@ void FUN_L00_00276908(void) { } D_L00_0015F5D8 = 1; { - s32 *table = (s32 *)D_L00_00173E40; + s32 *table = (s32 *)((u8 *)&D_L00_00173E40_lui); table[4] &= 0x7fffffff; } FUN_L00_002a08c8(); diff --git a/src/overlays/shared/gameplay/camera/follow_camera_setup.c b/src/overlays/shared/gameplay/camera/follow_camera_setup.c index 0f058695dd..8346334c92 100644 --- a/src/overlays/shared/gameplay/camera/follow_camera_setup.c +++ b/src/overlays/shared/gameplay/camera/follow_camera_setup.c @@ -872,7 +872,6 @@ typedef struct G002e7318 { } G002e7318; extern G002e7318 D_L00_00166E10_c __asm__("D_L00_00166E10"); extern f32 follow_cam_min_distance_gp __asm__("D_L00_00161CD8") __attribute__((sda)); -extern V002e7318 D_L00_00173E60_c __asm__("D_L00_00173E60"); extern V002e7318 D_L00_00173E70; extern s32 FUN_L00_002e4180_c(V002e7318 *, f32) __asm__("FUN_L00_002e4180"); extern s32 coll_sphere(V002e7318 *, f32, s32, s32) __asm__("FUN_L00_001f0d60"); @@ -909,7 +908,7 @@ s32 FUN_L00_002e7318(O002e7318 *o) { hb = 1; } if (x->s38 != 0) { - subtract_vector_xyz(&tmp, &D_L00_00173E60_c, &pos); + subtract_vector_xyz(&tmp, &(*(V002e7318 *)&D_L00_00173E60), &pos); normalize_vector_xyz(&tmp, &tmp, 1.0f); d = dot_vectors_xyz(&g->v40, &tmp); if (d > 0.75f) @@ -1163,7 +1162,7 @@ extern f32 D_L00_00161CD0 __attribute__((sda)); typedef struct { u8 pad[0x100]; f32 x; f32 y; } C940_2e7d20_t; extern C940_2e7d20_t D_0013C940_2e7d20 __asm__("D_0013C940")__attribute__((section(".data"))); typedef struct { u8 pad[0x18]; s32 p18; s32 p1C; u8 v20[0x10]; } E40_2e7d20_t; -extern E40_2e7d20_t D_L00_00173E40 __attribute__((section(".data"))); +extern int D_L00_00173E40_lui[] __asm__("D_L00_00173E40") __attribute__((section(".data"))); void lerp_vector(void *, void *, void *, f32) __asm__("FUN_001f9a40"); extern s32 probe_world_sphere(void *, s32, void *, s32, f32) __asm__("FUN_L00_001f2868"); @@ -1327,11 +1326,11 @@ void follow_camera_avoid_mobies(u8 *m) { if (!collision_line((x + 0x90), &v10, camera_collision_mask, D_0013F350_2e7d20.p2080, 0)) { goto clear; } - if (FUN_L00_002e4290_2e7d20(D_L00_00173E40.v20)) { + if (FUN_L00_002e4290_2e7d20((*(E40_2e7d20_t *)&D_L00_00173E40_lui).v20)) { goto clear; } - if (D_L00_00173E40.p18 != 0 && FUN_L00_0025e3b8(D_L00_00173E40.p18)) { - FUN_001f9a28_2e7d20(&v20, (u8 *)D_L00_00173E40.p18 + 0x10, D_L00_00166DC0); + if ((*(E40_2e7d20_t *)&D_L00_00173E40_lui).p18 != 0 && FUN_L00_0025e3b8((*(E40_2e7d20_t *)&D_L00_00173E40_lui).p18)) { + FUN_001f9a28_2e7d20(&v20, (u8 *)(*(E40_2e7d20_t *)&D_L00_00173E40_lui).p18 + 0x10, D_L00_00166DC0); v20.i[2] = 0; FUN_001f9bf8_2e7d20(&v20, &v20, 1.0f); v20.f[3] = 5627.9248046875f; @@ -1339,7 +1338,7 @@ void follow_camera_avoid_mobies(u8 *m) { w.b18 = 3; w.b19 = 3; w.h1A = *(u16 *)(D_0013F350_2e7d20.p2080 + 0xA6); - FUN_L00_00259a88(D_L00_00173E40.p18, &w); + FUN_L00_00259a88((*(E40_2e7d20_t *)&D_L00_00173E40_lui).p18, &w); } BI_2e7d20(0x4C)++; if (BI_2e7d20(0x4C) >= FUN_001f96f8_2e7d20(0x1E)) { diff --git a/src/overlays/shared/gameplay/entities/00264e40.c b/src/overlays/shared/gameplay/entities/00264e40.c index c1010b15fe..00b1cc3642 100644 --- a/src/overlays/shared/gameplay/entities/00264e40.c +++ b/src/overlays/shared/gameplay/entities/00264e40.c @@ -24,8 +24,8 @@ typedef struct { char *p[7]; short timer; } Slots_265E88; extern char *FUN_L00_0026b230(void *, void *, unsigned long, float); extern f32 random_float_between(f32, f32) __asm__("func_002132A8"); -extern float D_0015ED6C __attribute__((section(".sdata"))); -extern float D_0015ED70 __attribute__((section(".sdata"))); +extern f32 frame_time_macro __asm__("D_0015ED6C") __attribute__((section(".sdata"))); +extern f32 frame_time_sq_macro __asm__("D_0015ED70") __attribute__((section(".sdata"))); extern float D_L02_00174460[]; extern float FUN_001f96b0(float); extern float fast_vec_dist(void *, void *); @@ -33,11 +33,11 @@ extern int D_L02_0015F5CC __attribute__((section(".sdata"))); extern int FUN_001efa68(void *, void *, int, int, int); extern int FUN_001f9770(void *); extern s32 truncate_float_to_s32(f32) __asm__("func_001FA6D0"); -extern short D_L02_001600D0 __attribute__((sda)); -extern short D_L02_001600D4 __attribute__((sda)); -extern short D_L02_001600D8 __attribute__((sda)); -extern short D_L02_001600DC __attribute__((sda)); -extern short D_L02_001600E0 __attribute__((sda)); +extern float D_L02_001600D0 __attribute__((sda)); +extern int D_L02_001600D4 __attribute__((sda)); +extern int D_L02_001600D8 __attribute__((sda)); +extern float D_L02_001600DC __attribute__((sda)); +extern float D_L02_001600E0 __attribute__((sda)); extern void FUN_L00_00257d78(float *, float, float); extern void FUN_L00_0026d598(void *, void *, int); extern void add_vector_xyz(void *, void *, void *) __asm__("FUN_001f9a10"); @@ -75,16 +75,16 @@ void FUN_L02_00264e70(char *slots, float *position, float *direction, float dist } else { travel = distance; } - acceleration = D_0015ED70; + acceleration = frame_time_sq_macro; advance_accelerated_scalar(&speed, &travel_step, travel, 1.0f, acceleration * 48.0f, - (*(float *)&D_L02_001600D0) * D_0015ED6C); + (D_L02_001600D0) * frame_time_macro); ((float (*)(void *, void *, float))fast_vec_normalize)(adjusted, adjusted, travel_step); - n = (*(int *)&D_L02_001600D8); - first_count = (*(int *)&D_L02_001600D4); + n = (D_L02_001600D8); + first_count = (D_L02_001600D4); if (travel < 4.0f) first_count = 1; for (i = 0; i < n + first_count; i++) { FUN_L00_00257d78(offset, 0.0f, - (((*(float *)&D_L02_001600DC) - (*(float *)&D_L02_001600E0)) * (travel / distance) + (*(float *)&D_L02_001600E0)) * D_0015ED6C); + (((D_L02_001600DC) - (D_L02_001600E0)) * (travel / distance) + (D_L02_001600E0)) * frame_time_macro); add_vector_xyz(offset, offset, adjusted); fast_vec_scale(velocity, adjusted, random_float_between(0.0f, 1.0f)); add_vector_xyz(velocity, velocity, origin); @@ -104,7 +104,7 @@ void FUN_L02_00264e70(char *slots, float *position, float *direction, float dist float sp2 = random_float_between(10.0f, 30.0f); sp2 = FUN_001f96b0(sp2); ((Slots_265E88 *)slots)->timer = truncate_float_to_s32(sp2); - FUN_L00_00257d78(offset, 0.0f, D_0015ED6C + D_0015ED6C); + FUN_L00_00257d78(offset, 0.0f, frame_time_macro + frame_time_macro); fast_vec_scale(velocity, adjusted, random_float_between(0.5f, 0.1f)); add_vector_xyz(velocity, velocity, offset); velocity[3] = 0.0f; diff --git a/src/overlays/shared/gameplay/entities/00295100.c b/src/overlays/shared/gameplay/entities/00295100.c index bbd9bee00c..4b64cda208 100644 --- a/src/overlays/shared/gameplay/entities/00295100.c +++ b/src/overlays/shared/gameplay/entities/00295100.c @@ -831,81 +831,76 @@ void FUN_L00_00299560(s32 i) { } FUN_L00_002995d0(a, b, game_language); } -#ifndef NON_MATCHING -INCLUDE_ASM("config/us/overlays/asm/FUN_L00_002995d0.s", FUN_L00_002995d0); -#else -extern s32 D_L00_0015F5D8 __attribute__((section(".sdata"))); -extern s32 D_L00_00161048, D_L00_0016104C, D_L00_00161050; -extern s32 D_L00_0015F40C; -extern s32 D_0015EE78_gp __asm__("D_0015EE78_gp") __attribute__((sda)); +extern int D_L00_00161048_macro __asm__("D_L00_00161048") __attribute__((section(".sdata"))); +extern int D_L00_0016104C_macro __asm__("D_L00_0016104C") __attribute__((section(".sdata"))); +extern s32 D_L00_00161050_macro __asm__("D_L00_00161050") __attribute__((section(".sdata"))); +extern s32 D_L00_00161054_macro __asm__("D_L00_00161054") __attribute__((section(".sdata"))); +extern s32 D_L00_00161058_macro __asm__("D_L00_00161058") __attribute__((section(".sdata"))); +extern s32 D_L00_0015F40C_macro __asm__("D_L00_0015F40C") __attribute__((section(".sdata"))); +extern s32 D_L00_0015F5C4_macro __asm__("D_L00_0015F5C4") __attribute__((section(".sdata"))); +extern s32 D_L00_00173E04_lui __asm__("D_L00_00173E04") __attribute__((section(".data"))); +/* [0] is gs_texture_allocation_start, [4] depth_buffer_address. */ +extern s32 D_0015EE78_macro[6] __asm__("D_0015EE78") __attribute__((section(".sdata"))); extern void flush_cache(s32) __asm__("FUN_00118a80"); -extern void FUN_L00_0028e048(void); -extern void FUN_L00_002656c0(void); -extern void FUN_L00_001f9838(s32); +extern void sound_stop_all_sounds(void) __asm__("FUN_0022dcd0"); +extern void music_stop(void) __asm__("FUN_00215ee8"); +extern void fade_to_black(s32 n) __asm__("FUN_001f4a58"); extern void FUN_L00_002039a0(void); -extern void sce_gs_set_def_load_image(void *, s16, s32, s32, s32, s32, s32, s32) __asm__("FUN_00122330"); -extern void sce_gs_exec_load_image(void *, s32) __asm__("FUN_00122658"); +extern s32 sceGsSetDefLoadImage(void *, s16, s16, s16, s16, s16, s16, s16); +extern s32 sceGsExecLoadImage(void *, u8 *); extern void wait_for_graphics_pipeline_idle(s32, s32) __asm__("FUN_00120558"); -extern void FUN_L00_001eb078(s32, s32); -extern void FUN_L00_001ff008(void); - +extern void FUN_001e93b0(char *, s32); +extern void FUN_001f97b0(void); extern char D_L00_001E9480[]; +/* Sets up a movie load, then uploads image data from the level buffer to GS memory in two runs of strips. */ void FUN_L00_002995d0(s32 sector, s32 size, s32 language) { - u8 buffer[0x60] __attribute__((aligned(16))); - s32 source, destination, second_count, pal, initial_count; + s32 image[24]; + s32 large_count, small_count, gs_address, source, i, j; voice_pool.header[0x6B] |= 8; flush_cache(0); - FUN_L00_0028e048(); - FUN_L00_002656c0(); - D_L00_00161048 = sector; - D_L00_0016104C = size; - D_L00_00161050 = language; + sound_stop_all_sounds(); + music_stop(); + D_L00_00161048_macro = sector; + D_L00_0016104C_macro = size; + D_L00_00161050_macro = language; D_L00_0015F5D8 = 1; - FUN_L00_001f9838(4); + fade_to_black(4); FUN_L00_002039a0(); - destination = *(volatile s32 *)&D_L00_0015F40C; - D_L00_0015F5C4 = 1; - D_L00_00161054 = D_L00_00173E00_298840.x4; - D_L00_00161058 = destination; - initial_count = 13; - second_count = 17; - pal = D_0015ED80; - source = *(volatile s32 *)&depth_buffer_address; - initial_count = pal ? 14 : initial_count; - second_count = pal ? 14 : second_count; - if (initial_count != 0) { - s32 count = initial_count; - do { - count--; - sce_gs_set_def_load_image(buffer, (source << 8) >> 16, 2, 1, 0, 0, 0x80, 0x80); - source += 0x10000; - flush_cache(0); - sce_gs_exec_load_image(buffer, destination); - destination += 0xc000; - wait_for_graphics_pipeline_idle(0, 0); - } while (count != 0); - } - source = D_0015EE78_gp; - if (second_count != 0) { - s32 count = second_count; - do { - count--; - sce_gs_set_def_load_image(buffer, (source << 8) >> 16, 1, 0, 0, 0, 0x40, 0x40); - source += 0x4000; - flush_cache(0); - sce_gs_exec_load_image(buffer, destination); - destination += 0x4000; - wait_for_graphics_pipeline_idle(0, 0); - } while (count != 0); - } - if (source > 0x400000) { - FUN_L00_001eb078((s32)D_L00_001E9480, source - 0x400000); - FUN_L00_001ff008(); + D_L00_0015F5C4_macro = 1; + D_L00_00161054_macro = D_L00_00173E04_lui; + D_L00_00161058_macro = D_L00_0015F40C_macro; + large_count = D_0015ED80 != 0 ? 0xE : 0xD; + small_count = D_0015ED80 != 0 ? 0xE : 0x11; + source = D_L00_00161058_macro; + gs_address = D_0015EE78_macro[4]; + i = 0; + while (i < large_count) { + sceGsSetDefLoadImage(image, gs_address >> 8, 2, 1, 0, 0, 0x80, 0x80); + i++; + gs_address += 0x10000; + flush_cache(0); + sceGsExecLoadImage(image, (u8 *)source); + source += 0xC000; + wait_for_graphics_pipeline_idle(0, 0); + } + gs_address = D_0015EE78_macro[0]; + j = 0; + while (j < small_count) { + sceGsSetDefLoadImage(image, gs_address >> 8, 1, 0, 0, 0, 0x40, 0x40); + j++; + gs_address += 0x4000; + flush_cache(0); + sceGsExecLoadImage(image, (u8 *)source); + source += 0x4000; + wait_for_graphics_pipeline_idle(0, 0); + } + if (gs_address > 0x400000) { + FUN_001e93b0(D_L00_001E9480, gs_address - 0x400000); + FUN_001f97b0(); } } -#endif #ifndef NON_MATCHING INCLUDE_ASM("config/us/overlays/asm/FUN_L00_002997c8.s", FUN_L00_002997c8); #else diff --git a/src/overlays/shared/gameplay/entities/blarg_elite_commando.c b/src/overlays/shared/gameplay/entities/blarg_elite_commando.c index 49ff5b3691..31439e3227 100644 --- a/src/overlays/shared/gameplay/entities/blarg_elite_commando.c +++ b/src/overlays/shared/gameplay/entities/blarg_elite_commando.c @@ -176,7 +176,7 @@ extern float fast_add_rotations(float, float); extern float fast_sin(float); extern float random_angle_radians(void) __asm__("FUN_00213308"); extern float random_float_between(float, float) __asm__("FUN_002132a8"); -extern unsigned char D_0015EDB0; +#include "rnc/gameplay/state/options.h" extern int D_L16_00161A74 __attribute__((sda)); extern int D_L16_00161A78 __attribute__((sda)); extern int D_L16_00161A7C __attribute__((sda)); @@ -225,7 +225,7 @@ void FUN_L16_002d2cf0(char *m) { } else { qcopy(target, owner + 0x10); } - if ((&D_0015EDB0)[7]) + if ((&big_head_cheat_enabled)[7]) FUN_L00_00263b38(d + 0x130, 2.5f); switch (((unsigned char *)m)[0x20]) { case 0: @@ -527,7 +527,6 @@ typedef struct { extern char *D_L16_001B0930[]; extern char *find_moby_hit(void *, int, int) __asm__("FUN_L00_0025a420"); extern unsigned char D_0013D408[]; -extern char D_0013F350[]; extern float multiply_global_factor_ed64(float) __asm__("FUN_001f96b0"); extern float vector_distance_xy(void *, void *) __asm__("FUN_001f9b80"); extern int D_0015EE10 __attribute__((sda)); @@ -623,7 +622,7 @@ void FUN_L16_002d38b0(struct Moby *m) { time_scale = frame_time_sq * 20.0f; m->flags &= 0xEFFF; d->impulse_time = time_scale; - if (((L16DamageResident *)D_0013F350)->difficulty == 2) { + if (((L16DamageResident *)((char *)&hero))->difficulty == 2) { float impulse = frame_time; m->anim_speed = 0.5f; d->forward_impulse = impulse * 24.0f; @@ -668,7 +667,7 @@ void FUN_L16_002d38b0(struct Moby *m) { range = 255.0f; if (d->pursuit_timer == 0) range = d->pursuit_range; - if (((L16DamageResident *)D_0013F350)->mode == 22) { + if (((L16DamageResident *)((char *)&hero))->mode == 22) { d->pursuit_mode = 2; } else if (d->path_index >= 0 && d->pursuit_timer == 0) { char *path = D_L16_001B0930[d->path_index]; @@ -679,7 +678,7 @@ void FUN_L16_002d38b0(struct Moby *m) { if (range < vector_distance_xy(&m->pos, d->target)) d->pursuit_mode = 2; if (d->owner == 0) - d->owner = ((L16DamageResident *)D_0013F350)->owner; + d->owner = ((L16DamageResident *)((char *)&hero))->owner; } /* Ported from rac1-decomp (src/overlays/shared/vendor_002A1B58.c: func_L16_002D5188), where it is exact; names translated to the US level program. */ @@ -825,7 +824,7 @@ extern int random_int_between(int, int) __asm__("FUN_L00_00257b90"); extern int random_integer_below(int) __asm__("FUN_00213260"); extern s32 scale_game_frames(s32) __asm__("func_001F96F8"); extern s32 truncate_float_to_s32(f32) __asm__("FUN_001fa6d0"); -extern short D_L16_0015F5D0; +extern float D_L16_0015F5D0; extern void clear_u64_value(void *) __asm__("FUN_001f99f8"); extern void moby_point_position(void *, int, void *) __asm__("FUN_L00_0024f7c8"); extern void FUN_L00_0026a9f0(void *, void *, int, int, int, int, int, int, float, float); @@ -877,7 +876,7 @@ void FUN_L16_002d41f8(void *m) { delay); } while (remaining != 0); } - if (*(float *)&D_L16_0015F5D0 < 0.95f && distance > 9.0f) { + if (D_L16_0015F5D0 < 0.95f && distance > 9.0f) { spawn_glow_particle(m, origin, movement, 4.0f, scale_game_frames(15), 127, 127, 127, 32); spawn_glow_particle(m, origin, movement, 4.0f, scale_game_frames(24), 127, 32, 0, 32); } diff --git a/src/overlays/shared/gameplay/entities/blarg_space_commando.c b/src/overlays/shared/gameplay/entities/blarg_space_commando.c index 26ea1df65a..f09a20d416 100644 --- a/src/overlays/shared/gameplay/entities/blarg_space_commando.c +++ b/src/overlays/shared/gameplay/entities/blarg_space_commando.c @@ -412,7 +412,7 @@ void FUN_L06_002fdbd0(struct Moby *moby) { extern char *FUN_L00_0025a420(void *, int, int); extern char *FUN_L06_00300c60_c(int unused, char *pa, char *pb) __asm__("FUN_L06_00300c60"); -extern char D_001413D0[]; +#include "rnc/data_labels.h" extern f32 D_0015ED6C; extern f32 fast_arc_tan(f32, f32) __asm__("func_001F9E90"); extern f32 fast_cos(f32) __asm__("func_001F9DC8"); @@ -430,11 +430,11 @@ extern s32 tick_countdown_32_alt(s32 *) __asm__("FUN_001f9740"); extern s32 truncate_float_to_s32_c(f32) __asm__("func_001FA6D0"); extern int current_level_index_gp __asm__("D_0015ED84") __attribute__((sda)); extern float D_L06_00161FA8 __attribute__((sda)); -extern short D_L06_00161FAC __attribute__((sda)); -extern short D_L06_00161FB0 __attribute__((sda)); -extern short D_L06_00161FB4 __attribute__((sda)); -extern short D_L06_00161FB8 __attribute__((sda)); -extern short D_L06_00161FBC __attribute__((sda)); +extern float D_L06_00161FAC __attribute__((sda)); +extern float D_L06_00161FB0 __attribute__((sda)); +extern float D_L06_00161FB4 __attribute__((sda)); +extern float D_L06_00161FB8 __attribute__((sda)); +extern float D_L06_00161FBC __attribute__((sda)); extern unsigned char D_0013D408[]; extern void FUN_L00_00257470(void *, int, int); extern void FUN_L00_0025c558(void *, void *, float, int, int, int); @@ -500,8 +500,8 @@ void FUN_L06_002feb40(char *m) { m[0x20] = 0xF; q = d + 0x60; n = scale_game_frames_c(0x3C); - a = *(float *)&D_L06_00161FB0 * D_0015ED6C; - b = *(float *)&D_L06_00161FB4 * D_0015ED6C; + a = D_L06_00161FB0 * D_0015ED6C; + b = D_L06_00161FB4 * D_0015ED6C; *(short *)(d + 0x26) = n; *(float *)(d + 0x7C) = b; *(float *)(d + 0x78) = a; @@ -518,8 +518,8 @@ void FUN_L06_002feb40(char *m) { float a, b; m[0x20] = 0x10; q = d + 0x60; - a = *(float *)&D_L06_00161FB8 * D_0015ED6C; - b = *(float *)&D_L06_00161FBC * D_0015ED6C; + a = D_L06_00161FB8 * D_0015ED6C; + b = D_L06_00161FBC * D_0015ED6C; *(unsigned short *)(m + 0x34) &= 0xEFFF; *(float *)(d + 0x78) = a; *(float *)(d + 0x7C) = b; @@ -569,9 +569,9 @@ void FUN_L06_002feb40(char *m) { *(unsigned char *)(m + 0xA4) = 0xFF; FUN_L00_0025d538(m, d + 0x110); if (*(int *)(d + 0x188) != 0) { - *(float *)(d + 0x198) = *(float *)&D_L06_00161FAC + 6.0f; + *(float *)(d + 0x198) = D_L06_00161FAC + 6.0f; } else { - *(float *)(d + 0x198) = *(float *)&D_L06_00161FAC; + *(float *)(d + 0x198) = D_L06_00161FAC; } { char *q = d + 0x120; @@ -585,7 +585,7 @@ void FUN_L06_002feb40(char *m) { } } if (*(int *)(d + 0x160) == 0) { - *(int *)(d + 0x160) = *(int *)(D_001413D0); + *(int *)(d + 0x160) = *(int *)(((char *)&D_001413D0)); } } /* Ported from rac1-decomp (src/overlays/shared/vendor_002FF000.c: func_L06_00300530), where it is exact; names translated to the US level program. */ @@ -600,8 +600,8 @@ extern void add_vector_xyz_cf(void *, int, void *) __asm__("FUN_L00_0024f7c8"); extern void add_vector_xyz(void *, void *, void *) __asm__("FUN_001f9a10"); extern void normalize_vector_xyz(void *, void *, f32) __asm__("FUN_001f9bf8"); -extern short D_L06_00161FD4 __attribute__((sda)); -extern short D_L06_00161FD8 __attribute__((sda)); +extern float D_L06_00161FD4 __attribute__((sda)); +extern int D_L06_00161FD8 __attribute__((sda)); void FUN_L06_002ff100(char *m) { char *d = *(char **)(m + 0x78); float v[4]; @@ -612,7 +612,7 @@ void FUN_L06_002ff100(char *m) { *(float *)(d + 0x218) = *(float *)(m + 0x18); for (i = 0; i < 16; i++) { float f = convert_integer_to_float(i) * 0.0625f - 0.5f; - f = f * (*(float *)&D_L06_00161FD4 * 0.017453292f); + f = f * (D_L06_00161FD4 * 0.017453292f); v[0] = fast_cos(fast_add_rotations(f, *(float *)(m + 0x48))) * 0.2f; v[1] = fast_sin_c(fast_add_rotations(f, *(float *)(m + 0x48))) * 0.2f; v[2] = 0.15f; @@ -624,7 +624,7 @@ void FUN_L06_002ff100(char *m) { *(float *)(d + 0x23C + i * 16) = 1.0f; } } - *(float *)(d + 0x21C) = (float)scale_game_frames(*(int *)&D_L06_00161FD8); + *(float *)(d + 0x21C) = (float)scale_game_frames(D_L06_00161FD8); } #ifndef NON_MATCHING INCLUDE_ASM("config/us/overlays/asm/FUN_L06_002ff2c8.s", FUN_L06_002ff2c8); @@ -839,22 +839,22 @@ extern float fast_cos(float) __asm__("func_001F9DC8"); extern float fast_sin(float) __asm__("func_001F9DE0"); extern float random_angle_radians(void) __asm__("FUN_00213308"); extern s32 truncate_float_to_s32(f32) __asm__("FUN_001fa6d0"); -extern short D_L06_00162004 __attribute__((sda)); -extern short D_L06_00162008 __attribute__((sda)); -extern short D_L06_0016200C __attribute__((sda)); -extern short D_L06_00162010 __attribute__((sda)); -extern short D_L06_00162014 __attribute__((sda)); -extern short D_L06_00162018 __attribute__((sda)); -extern short D_L06_0016201C __attribute__((sda)); -extern short D_L06_00162020 __attribute__((sda)); -extern short D_L06_00162024 __attribute__((sda)); -extern short D_L06_00162028 __attribute__((sda)); -extern short D_L06_0016202C __attribute__((sda)); -extern short D_L06_00162030 __attribute__((sda)); -extern short D_L06_00162034 __attribute__((sda)); -extern short D_L06_00162038 __attribute__((sda)); -extern short D_L06_0016203C __attribute__((sda)); -extern short D_L06_00162040 __attribute__((sda)); +extern int D_L06_00162004 __attribute__((sda)); +extern int D_L06_00162008 __attribute__((sda)); +extern float D_L06_0016200C __attribute__((sda)); +extern float D_L06_00162010 __attribute__((sda)); +extern float D_L06_00162014 __attribute__((sda)); +extern float D_L06_00162018 __attribute__((sda)); +extern float D_L06_0016201C __attribute__((sda)); +extern float D_L06_00162020 __attribute__((sda)); +extern float D_L06_00162024 __attribute__((sda)); +extern float D_L06_00162028 __attribute__((sda)); +extern float D_L06_0016202C __attribute__((sda)); +extern float D_L06_00162030 __attribute__((sda)); +extern float D_L06_00162034 __attribute__((sda)); +extern float D_L06_00162038 __attribute__((sda)); +extern float D_L06_0016203C __attribute__((sda)); +extern int D_L06_00162040 __attribute__((sda)); extern void lerp_vector(void *, void *, void *, float) __asm__("FUN_001f9a40"); extern void scale_vector_xyz(void *out, void *a, f32 s) __asm__("FUN_001f9a68"); extern int func_001FA898_r(float) __asm__("FUN_001fa6d0"); @@ -874,37 +874,37 @@ void FUN_L06_002ff978(char *moby) { *(float *)(data - (-(n * 16)) + 0x23C) < 0.99f) { continue; } - if (*(float *)&D_L06_0016203C < random_float_between(0.0f, 1.0f)) { + if (D_L06_0016203C < random_float_between(0.0f, 1.0f)) { continue; } f21 = random_angle_radians(); f22 = random_angle_radians(); v[0] = fast_cos(f21) * - random_float_between(*(float *)&D_L06_0016202C, *(float *)&D_L06_00162030); + random_float_between(D_L06_0016202C, D_L06_00162030); v[1] = fast_sin(f21) * - random_float_between(*(float *)&D_L06_0016202C, *(float *)&D_L06_00162030); + random_float_between(D_L06_0016202C, D_L06_00162030); v[2] = 0; w[0] = fast_cos(f22) * - random_float_between(*(float *)&D_L06_0016202C, *(float *)&D_L06_00162030); + random_float_between(D_L06_0016202C, D_L06_00162030); w[1] = fast_sin(f22) * - random_float_between(*(float *)&D_L06_0016202C, *(float *)&D_L06_00162030); + random_float_between(D_L06_0016202C, D_L06_00162030); w[2] = 0; - v[2] = random_float_between(*(float *)&D_L06_00162034, *(float *)&D_L06_00162038); - w[2] = random_float_between(*(float *)&D_L06_00162034, *(float *)&D_L06_00162038); + v[2] = random_float_between(D_L06_00162034, D_L06_00162038); + w[2] = random_float_between(D_L06_00162034, D_L06_00162038); s18 = func_001FA898_r(multiply_global_factor_ed64( - random_float_between(*(float *)&D_L06_00162014, *(float *)&D_L06_00162018))); + random_float_between(D_L06_00162014, D_L06_00162018))); s19 = func_001FA898_r(multiply_global_factor_ed64( - random_float_between(*(float *)&D_L06_0016201C, *(float *)&D_L06_00162020))); + random_float_between(D_L06_0016201C, D_L06_00162020))); s17 = func_001FA898_r(multiply_global_factor_ed64( - random_float_between(*(float *)&D_L06_00162024, *(float *)&D_L06_00162028))); + random_float_between(D_L06_00162024, D_L06_00162028))); scale_vector_xyz(v, v, 1.0f / (float)s18); - v[3] = *(float *)&D_L06_0016200C; + v[3] = D_L06_0016200C; scale_vector_xyz(w, w, 1.0f / (float)s17); - w[3] = *(float *)&D_L06_00162010; + w[3] = D_L06_00162010; p = data + (off + 0x230); lerp_vector(s10, p, p, random_float_between(0.0f, 1.0f)); - spawn_spark(s10, v, w, *(int *)&D_L06_00162004, *(int *)&D_L06_00162008, s18, s19, s17, - *(int *)&D_L06_00162040); + spawn_spark(s10, v, w, D_L06_00162004, D_L06_00162008, s18, s19, s17, + D_L06_00162040); } } #define NOT_SDA diff --git a/src/overlays/shared/gameplay/entities/bomb.c b/src/overlays/shared/gameplay/entities/bomb.c index 8d43d92853..1d145c1370 100644 --- a/src/overlays/shared/gameplay/entities/bomb.c +++ b/src/overlays/shared/gameplay/entities/bomb.c @@ -989,157 +989,165 @@ s32 FUN_L00_002caf40(s32 arg0) { } return 0; } -#ifndef NON_MATCHING -INCLUDE_ASM("config/us/overlays/asm/FUN_L00_002caf70.s", FUN_L00_002caf70); -#else -extern struct Moby *create_moby_2caf70(s32) __asm__("FUN_L00_0024e838"); -extern f32 FUN_002000e8_2caf70(f32, f32) __asm__("FUN_L00_002000e8"); -extern void FUN_001ff260_2caf70(void *) __asm__("FUN_L00_001ff260"); -extern struct Moby *FUN_0025c338_2caf70(struct Moby *) __asm__("FUN_L00_0025c338"); -extern s16 FUN_001fef20_2caf70(s32) __asm__("FUN_L00_001fef20"); -extern s32 FUN_001efc70_2caf70(void *, void *, s32, void *, s32) __asm__("FUN_L00_001efc70"); -extern void FUN_00262c50_2caf70(void *, f32, f32, f32) __asm__("FUN_L00_00262c50"); -extern f32 FUN_L00_00257be8_2caf70(f32, f32) __asm__("FUN_L00_00257be8"); -extern void FUN_001ff660_2caf70(void *, void *, void *) __asm__("FUN_L00_001ff660"); -extern f32 FUN_001ff3d8_2caf70(void *) __asm__("FUN_L00_001ff3d8"); -extern void FUN_001ff500_2caf70(void *, void *, f32) __asm__("FUN_L00_001ff500"); -extern void FUN_001ff278_2caf70(void *, void *, void *) __asm__("FUN_L00_001ff278"); -extern s32 FUN_L00_00257b90_2caf70(s32, s32) __asm__("FUN_L00_00257b90"); -extern void FUN_L00_0026dd20_2caf70(void *, void *, u32, s32, f32) __asm__("FUN_L00_0026dd20"); -extern void FUN_L00_0026daa0_2caf70(void *, u32, s32, s32, f32) __asm__("FUN_L00_0026daa0"); -extern void *FUN_L00_00275158_2caf70(f32, void *, void *, s32) __asm__("FUN_L00_00275158"); -extern f32 FUN_00200240_2caf70(s32) __asm__("FUN_L00_00200240"); -extern s32 FUN_00200250_2caf70(f32) __asm__("FUN_L00_00200250"); -extern f32 FUN_001ff8b0_2caf70(f32, f32) __asm__("FUN_L00_001ff8b0"); -extern f32 FUN_001ff408_2caf70(void *) __asm__("FUN_L00_001ff408"); -extern f32 cubic_hermite_scalar_2caf70(f32, f32, f32, f32, f32) __asm__("FUN_L00_00257e20"); -extern void FUN_L00_002cbcc0(u8 *, s32); -extern void FUN_0024eb68_2caf70(void *) __asm__("FUN_L00_0024eb68"); -extern f32 D_L00_00161890_2caf70 __asm__("D_L00_00161890") __attribute__((sda)); -extern f32 D_L00_00161894_2caf70 __asm__("D_L00_00161894") __attribute__((section(".sdata"))); -extern f32 D_L00_00161888_2caf70 __asm__("D_L00_00161888") __attribute__((sda)); -extern f32 D_L00_00161870_2caf70 __asm__("D_L00_00161870") __attribute__((sda)); -extern f32 D_L00_00161874_2caf70 __asm__("D_L00_00161874") __attribute__((sda)); -extern f32 D_L00_00161878_2caf70 __asm__("D_L00_00161878") __attribute__((sda)); -extern char D_L00_0015F580_2caf70[] __asm__("D_L00_0015F580") __attribute__((section(".sdata"))); - -struct Moby *FUN_L00_002caf70(struct Moby *source, OvlVec4 *position, struct Moby *other, - f32 vx, f32 vy, f32 height, f32 speed) -{ - struct Moby *m; - u8 *vars; - OvlVec4 start_position, probe, offset, scaled, direction; - OvlVec4 *start = &start_position; - void **handle; - s32 lifetime; - f32 blend, initial_value, target; +/* Ported from rac1-decomp (src/overlays/shared/vendor_002C96D0.c: func_L00_002CC3C0), where it is exact; names translated to the US level program. */ - start_position.q = position->q; - m = create_moby_2caf70(0x131); - if (m != 0) { - vars = m->pvars; - *(struct Moby **)(vars + 0x20) = source; - ((volatile struct Moby *)m)->draw_dist = 0x7f; - m->update_dist = 0x7f; - m->visible = 1; - ((volatile struct Moby *)m)->spawn_frame = ((volatile struct Moby *)source)->spawn_frame; - *(f32 *)((u8 *)m + 0x40) = *(volatile f32 *)&D_L00_00161890_2caf70; - *(f32 *)((u8 *)m + 0x44) = FUN_002000e8_2caf70(speed, *(volatile f32 *)&D_L00_00161894_2caf70); - *(f32 *)((u8 *)m + 0x48) = height; - qcopy(&m->pos, start); - if (other != 0) { - qcopy(vars, &other->pos); - other = FUN_0025c338_2caf70(other); - if (other != 0) - *(f32 *)(vars + 8) = *(f32 *)(vars + 8) + *(f32 *)((u8 *)other + 0x10); - else - *(f32 *)(vars + 8) = *(f32 *)(vars + 8) + 0.5f; - } else { - FUN_001ff260_2caf70(vars); - } - *(f32 *)(vars + 0x18) = vx; - *(f32 *)(vars + 0x1c) = vy; - *(s32 *)(vars + 0x10) = 0; - *(s32 *)(vars + 0x14) = 0; - { - s32 lifetime = FUN_001fef20_2caf70(0x23) + D_0013E520[15] * 10; - *(s32 *)(vars + 0x28) = 0; - *(volatile s16 *)(vars + 0x26) = lifetime; - *(volatile s16 *)(vars + 0x24) = lifetime; - } - probe.q = ((OvlVec4 *)&source->pos)->q; - probe.f[2] = start->f[2]; - if (FUN_001efc70_2caf70(&probe, start, 0, source, 0) != 0) { - FUN_00262c50_2caf70(&offset, D_0015ED6C * 40.0f, - *(f32 *)((u8 *)m + 0x48), -*(f32 *)((u8 *)m + 0x44)); - qcopy(&m->pos, &coll_hit.point); - { - s32 i = 4; - do { - direction.q = 0; - direction.f[0] = FUN_L00_00257be8_2caf70(-1.0f, 1.0f); - direction.f[1] = FUN_L00_00257be8_2caf70(-1.0f, 1.0f); - direction.f[2] = FUN_L00_00257be8_2caf70(-1.0f, 1.0f); - scaled.q = direction.q; - FUN_001ff660_2caf70(&direction, &offset, &coll_hit_normal_2c8440); - FUN_001ff500_2caf70(&scaled, &scaled, FUN_001ff3d8_2caf70(&direction) * 0.5f); - FUN_001ff278_2caf70(&direction, &direction, &scaled); - FUN_001ff500_2caf70(&direction, &direction, - FUN_L00_00257be8_2caf70(D_0015ED6C * 3.0f, D_0015ED6C * 6.0f)); - lifetime = FUN_L00_00257b90_2caf70(FUN_001fef20_2caf70(10), FUN_001fef20_2caf70(15)); - FUN_L00_0026dd20_2caf70(&m->pos, &direction, 0x7f2f4f6f, lifetime, 30000.0f); - i--; - } while (i >= 0); - } - if (D_0013E520[15] == 0) { - FUN_L00_002cbcc0((u8 *)m, 0); - FUN_0024eb68_2caf70(m); - return 0; - } else { - s32 i = *(s32 *)(vars + 0x28) + 1; - *(s32 *)(vars + 0x28) = i; - if (i <= D_0013E520[15] + 5) - goto update_motion; - FUN_L00_002cbcc0((u8 *)m, 1); - } - FUN_0024eb68_2caf70(m); - return 0; -update_motion: - FUN_001ff660_2caf70(&offset, &offset, &coll_hit_normal_2c8440); - *(f32 *)((u8 *)m + 0x48) = FUN_001ff8b0_2caf70(offset.f[0], offset.f[1]); - *(f32 *)((u8 *)m + 0x44) = -FUN_001ff8b0_2caf70(FUN_001ff408_2caf70(&offset), offset.f[2]); - return m; - } - { - s32 i; - FUN_L00_0026daa0_2caf70(m, 0x2f4f7f7f, *(s16 *)(vars + 0x24), -1, D_L00_00161888_2caf70); - handle = (void **)(vars + 0x2c); - i = 0; - do { - u8 *effect = FUN_L00_00275158_2caf70(0.0f, &m->pos, D_L00_0015F580_2caf70, 1); - if (effect != 0) { - f32 blend; - *(f32 *)(effect + 0xc) = FUN_L00_00257be8_2caf70(D_L00_00161870_2caf70, D_L00_00161874_2caf70); - blend = cubic_hermite_scalar_2caf70(-1.5f, 0.0f, 1.0f, 0.0f, - FUN_00200240_2caf70(i) / FUN_00200240_2caf70(16)); - initial_value = *(f32 *)(effect + 0xc); - target = D_L00_00161878_2caf70; - target = (target - initial_value) * blend; - *(f32 *)(effect + 0xc) = initial_value + target; - *(u32 *)(effect + 4) = (FUN_00200250_2caf70(128.0f + blend * -64.0f) << 24) | 0xffffff; - *handle = effect; +typedef int w128 __attribute__((mode(TI))); + +extern char *FUN_L00_0026daa0(char *, int, int, int, float); +extern char *func_0020D348_m(int); +extern char D_L00_00173E60_c[] __asm__("D_L00_00173E60"); +extern f32 convert_integer_to_float_c(s32) __asm__("func_001FA6C0"); +extern f32 fast_arc_tan_c2(f32, f32) __asm__("func_001F9E90"); +extern f32 fast_vec_length(void *) __asm__("func_001F9AF0"); +extern f32 random_float_between_c2(f32, f32) __asm__("func_002132A8"); +extern f32 vector_length_xy(void *) __asm__("FUN_001f9b20"); +extern float D_0015ED6C; +extern char D_L00_0015F580[] __attribute__((section(".sdata"))); +extern float D_L00_00161890_gp __asm__("D_L00_00161890") __attribute__((sda)); +extern float FUN_L00_00257e20(float, float, float, float, float); +extern float fast_add_rotations(float, float) __asm__("func_001FA580"); +extern int FUN_001efa68(void *, void *, int, int, int); +extern int FUN_L00_00257b90_c2(int, int) __asm__("FUN_L00_00257b90"); +extern s32 scale_game_frames_c2(s32) __asm__("func_001F96F8"); +extern s32 truncate_float_to_s32_c(f32) __asm__("func_001FA6D0"); +extern float D_L00_00161870 __attribute__((sda)); +extern float D_L00_00161874 __attribute__((sda)); +extern float D_L00_00161878 __attribute__((sda)); +extern float D_L00_00161888 __attribute__((sda)); +extern unsigned char *FUN_L00_00275158(char *a, char *b, int c, float f); +extern unsigned char D_0013E05A[]; +extern unsigned char D_L00_00173E80[]; +extern void *FUN_L00_0026dd20(void *, void *, unsigned, int, float); +extern void FUN_L00_001ff660(void *, void *, void *); +extern void FUN_L00_002cbcc0_c(unsigned char *, int) __asm__("FUN_L00_002cbcc0"); +extern void add_vector_xyz(void *, void *, void *) __asm__("FUN_001f9a10"); +extern void build_spherical_offset(void *, f32, f32, f32) __asm__("func_00214DB0"); +extern void clear_u64_value_c(void *) __asm__("func_001F99F8"); +extern void fast_vec_normalize(void *, void *, f32) __asm__("FUN_001f9bf8"); +extern void mark_moby_for_removal_c2(void *) __asm__("func_0020C828"); +#include "rnc/gameplay/state/item_state.h" + +char *FUN_L00_002caf70(char *owner, char *spawn_pos, char *target, float vx, float vy, float yaw, float pitch) { + float start_position[4]; + float probe[4]; + float direction[4]; + float scaled[4]; + float spark[4]; + unsigned char *moby; + char *vars; + char *trail; + unsigned char *variant; + int result; + int timer; + int lifetime; + int i; + int sparks; + float length; + float blend; + float index; + float fraction; + float *start; + + start = start_position; + *(w128 *)start_position = *(w128 *)spawn_pos; + moby = func_0020D348_m(0x131); + if (moby != 0) { + vars = *(char **)(moby + 0x78); + *(char **)(vars + 0x20) = owner; + moby[0x30] = 0x7F; + *(short *)(moby + 0x32) = 0x7F; + moby[0x31] = 1; + *(long *)(moby + 0x38) = *(long *)(owner + 0x38); + *(float *)(moby + 0x40) = D_L00_00161890_gp; + *(float *)(moby + 0x44) = fast_add_rotations(pitch, (&D_L00_00161890_gp)[1]); + *(float *)(moby + 0x48) = yaw; + qcopy(moby + 0x10, start); + if (target != 0) { + int bounds; + qcopy(vars, target + 0x10); + bounds = (int)FUN_002141f8(target); + if (bounds != 0) { + *(float *)(vars + 0x8) = *(float *)(vars + 0x8) + *(float *)(bounds + 0x10); } else { - *handle = 0; + *(float *)(vars + 0x8) = *(float *)(vars + 0x8) + 0.5f; } - i++; - handle++; - } while (i < 17); - } + } else { + clear_u64_value_c(vars); + } + *(float *)(vars + 0x18) = vx; + *(float *)(vars + 0x1C) = vy; + *(int *)(vars + 0x10) = 0; + *(int *)(vars + 0x14) = 0; + timer = scale_game_frames_c2(0x23); + variant = item_text_variant; + timer = timer + variant[0xF] * 10; + *(int *)(vars + 0x28) = 0; + *(short *)(vars + 0x24) = timer; + *(short *)(vars + 0x26) = timer; + *(w128 *)probe = *(w128 *)(owner + 0x10); + probe[2] = start[2]; + result = FUN_001efa68(probe, start, 0, (int)owner, 0); + if (result != 0) { + build_spherical_offset(direction, D_0015ED6C * 40.0f, *(float *)(moby + 0x48), -*(float *)(moby + 0x44)); + qcopy(moby + 0x10, D_L00_00173E60_c); + start = scaled; + sparks = 4; + do { + *(w128 *)spark = 0; + spark[0] = random_float_between_c2(-1.0f, 1.0f); + sparks--; + spark[1] = random_float_between_c2(-1.0f, 1.0f); + spark[2] = random_float_between_c2(-1.0f, 1.0f); + *(w128 *)scaled = *(w128 *)spark; + FUN_L00_001ff660(spark, direction, D_L00_00173E80); + length = fast_vec_length(spark); + fast_vec_normalize(start, start, length * 0.5f); + add_vector_xyz(spark, spark, start); + fast_vec_normalize(spark, spark, random_float_between_c2(D_0015ED6C * 3.0f, D_0015ED6C * 6.0f)); + result = scale_game_frames_c2(10); + timer = scale_game_frames_c2(15); + lifetime = FUN_L00_00257b90_c2(result, timer); + FUN_L00_0026dd20(moby + 0x10, (char *)spark, 0x7F2F4F6F, lifetime, 30000.0f); + } while (sparks >= 0); + variant = item_text_variant; + if (variant[0xF] == 0) { + FUN_L00_002cbcc0_c(moby, 0); + mark_moby_for_removal_c2(moby); + return 0; + } + *(int *)(vars + 0x28) = *(int *)(vars + 0x28) + 1; + if (variant[0xF] + 5 < *(int *)(vars + 0x28)) { + FUN_L00_002cbcc0_c(moby, 1); + mark_moby_for_removal_c2(moby); + return 0; + } + FUN_L00_001ff660(direction, direction, D_L00_00173E80); + *(float *)(moby + 0x48) = fast_arc_tan_c2(direction[0], direction[1]); + length = vector_length_xy(direction); + *(float *)(moby + 0x44) = -fast_arc_tan_c2(length, direction[2]); + return moby; + } else { + FUN_L00_0026daa0(moby, 0x2F4F7F7F, *(short *)(vars + 0x24), -1, D_L00_00161888); + for (i = 0; i < 17; i++) { + trail = (char *)FUN_L00_00275158(moby + 0x10, D_L00_0015F580, 1, 0.0f); + if (trail != 0) { + *(float *)(trail + 0xC) = random_float_between_c2(D_L00_00161870, D_L00_00161874); + index = convert_integer_to_float_c(i); + fraction = index / convert_integer_to_float_c(16); + blend = FUN_L00_00257e20(-1.5f, 0.0f, 1.0f, 0.0f, fraction); + *(float *)(trail + 0xC) = *(float *)(trail + 0xC) + (D_L00_00161878 - *(float *)(trail + 0xC)) * blend; + result = truncate_float_to_s32_c(blend * -64.0f + 128.0f); + *(int *)(trail + 4) = (result << 24) | 0xFFFFFF; + ((int *)(vars + 0x2C))[i] = (int)trail; + } else { + ((int *)(vars + 0x2C))[i] = 0; + } + } + } } - return m; + return moby; } -#endif -/* Ported from rac1-decomp (src/overlays/shared/vendor_002C96D0.c: func_L00_002CC868), where it is exact; names translated to the US level program. */ +/* Ported probe rac1-decomp (src/overlays/shared/vendor_002C96D0.c: func_L00_002CC868), where it is exact; names translated to the US level program. */ /* Four floats aligned to 16 bytes, the layout moved by one lq/sq. */ typedef struct { @@ -2234,7 +2242,6 @@ typedef struct { unsigned short hC2; unsigned int wC4; } S_2cdcc0; -extern char D_0013F350[]; extern S_2cdcc0 D_00141680_2cdcc0 __asm__("D_00141680"); extern int D_0015EEA4_2cdcc0 __asm__("D_0015EEA4"); int FUN_L00_00233e98_2cdcc0(int) __asm__("FUN_L00_00233e98"); @@ -2245,7 +2252,7 @@ int FUN_001f96f8_2cdcc0(int) __asm__("FUN_001f96f8"); void FUN_001f9a10_2cdcc0(void *, void *, void *) __asm__("FUN_001f9a10"); unsigned char *FUN_L00_002ce1f0_2cdcc0(unsigned char *, void *) __asm__("FUN_L00_002ce1f0"); void FUN_L00_002cdcc0(void) { - P_2cdcc0 *p = &(*(P_2cdcc0 *)D_0013F350); + P_2cdcc0 *p = &(*(P_2cdcc0 *)((char *)&hero)); S_2cdcc0 *s; float d[4] __attribute__((aligned(16))); float v[4] __attribute__((aligned(16))); @@ -2863,7 +2870,7 @@ extern s32 weapon_ammo_counts[] __asm__("D_0013D428"); extern u8 D_L00_00197BC0[]; extern struct MobyClass *D_L00_00197300[]; extern s32 D_0015ED84 __attribute__((section(".sdata"))); -extern s32 D_L00_0015F5CC __attribute__((section(".sdata"))); +extern int D_L00_0015F5CC_macro __asm__("D_L00_0015F5CC") __attribute__((section(".sdata"))); extern void *D_001413D0 __attribute__((section(".data"))); extern s32 D_001413DC __attribute__((section(".data"))); @@ -2910,14 +2917,14 @@ void crate_update(struct Moby *moby) { pv->below = NULL; } } - pv->frameFC = D_L00_0015F5CC; + pv->frameFC = D_L00_0015F5CC_macro; coll = &pv->coll; if (pv->rider == NULL) { coll->flags |= 1; } else { coll->flags &= ~1; } - if (pv->frameB4 != D_L00_0015F5CC && moby->state != 0 && (pv->flags & 0xC)) { + if (pv->frameB4 != D_L00_0015F5CC_macro && moby->state != 0 && (pv->flags & 0xC)) { FUN_L00_002d1428(moby); } touched = 0; diff --git a/src/overlays/shared/gameplay/entities/camera_object.c b/src/overlays/shared/gameplay/entities/camera_object.c index c050d9842b..9c88487be8 100644 --- a/src/overlays/shared/gameplay/entities/camera_object.c +++ b/src/overlays/shared/gameplay/entities/camera_object.c @@ -145,7 +145,7 @@ extern float D_L00_00161374_gp __asm__("D_L00_00161374") __attribute__((sda)); extern float D_L00_00161378 __attribute__((sda)); extern float D_L00_00161384_gp __asm__("D_L00_00161384") __attribute__((sda)); extern float D_L00_0016138C_gp __asm__("D_L00_0016138C") __attribute__((sda)); -extern float D_0015ED60; +#include "rnc/globals.h" int scale_game_frames(int) __asm__("FUN_001f96f8"); float FUN_001fa6c0(int); void FUN_L00_002a4cd8(unsigned char *p) { @@ -166,7 +166,7 @@ void FUN_L00_002a4cd8(unsigned char *p) { D_L00_0016138C_gp = one / (float)r; break; case 1: - D_L00_00161374_gp -= D_L00_00161378 * D_0015ED60; + D_L00_00161374_gp -= D_L00_00161378 * frame_scale; if (D_L00_00161374_gp <= -8.0f) D_L00_00161374_gp += 8.0f; break; @@ -2130,7 +2130,7 @@ extern char D_0013F490[]; extern void *D_001413D0; extern f32 fast_vec_length(void *) __asm__("func_001F9AF0"); extern s32 scale_game_frames_c(s32) __asm__("func_001F96F8"); -extern short D_L00_001613C4 __attribute__((sda)); +extern float D_L00_001613C4 __attribute__((sda)); extern short D_L00_001B0770[]; extern void FUN_L00_00250df8_c(void *) __asm__("FUN_L00_00250df8"); extern void FUN_L00_0025f780(void *, short *, int); @@ -2145,7 +2145,7 @@ char *FUN_L00_002a96f8(void *owner, void *pos, float a, float b, float c, char * ((unsigned char *)m)[0x30] = 0xFF; m[0x31] = 1; m[0x20] = 0; - *(float *)(m + 0x2C) *= *(float *)&D_L00_001613C4; + *(float *)(m + 0x2C) *= D_L00_001613C4; *(short *)(m + 0x32) = 0xFF; d = *(char **)(m + 0x78); *(float *)(m + 0x48) = rz; diff --git a/src/overlays/shared/gameplay/entities/gadgebot_spawn_container.c b/src/overlays/shared/gameplay/entities/gadgebot_spawn_container.c index 52030cf91c..4593ede0e5 100644 --- a/src/overlays/shared/gameplay/entities/gadgebot_spawn_container.c +++ b/src/overlays/shared/gameplay/entities/gadgebot_spawn_container.c @@ -375,8 +375,8 @@ extern int scale_game_frames_alt(int) __asm__("FUN_001f96f8"); extern int tick_countdown_32_alt(int *) __asm__("FUN_001f9740"); extern s32 random_integer_below(s32) __asm__("func_00213260"); extern s32 truncate_float_to_s32(f32) __asm__("func_001FA6D0"); -extern short D_L06_00161C10 __attribute__((sda)); -extern short D_L06_00161C14 __attribute__((sda)); +extern int D_L06_00161C10 __attribute__((sda)); +extern int D_L06_00161C14 __attribute__((sda)); extern short D_L06_00161BF0[1] __attribute__((sda)); extern void set_vector_unit_z(void *) __asm__("FUN_001f9a00"); extern void FUN_L00_00257470(void *, int, int); @@ -411,7 +411,7 @@ void FUN_L06_002e8678(unsigned char *moby) { int mode; data = *(char **)(moby + 0x78); - if (*(int *)&D_L06_00161C10 != 0) { + if (D_L06_00161C10 != 0) { return; } mode = D_L06_0015F5C4; @@ -439,10 +439,10 @@ void FUN_L06_002e8678(unsigned char *moby) { switch (moby[0x20]) { case 0: { float wait; - int spawn_count = *(int *)&D_L06_00161C14; + int spawn_count = D_L06_00161C14; int divisor = *(short *)(data + 0x240); *(short *)(data + 0x20A) = spawn_count % 8; - *(int *)&D_L06_00161C14 = spawn_count + 1; + D_L06_00161C14 = spawn_count + 1; if (divisor != 0) { *(short *)(moby + 0xB4) = *(short *)(moby + 0xB4) / divisor; } @@ -885,7 +885,7 @@ extern void extract_matrix_rotation_quaternion(void *, void *) __asm__("FUN_0021 extern void fast_vec_normalize(void *, void *, float) __asm__("FUN_001f9bf8"); extern void fast_vec_cross(void *, void *, void *) __asm__("FUN_001f9ad8"); -extern short D_L06_00161C00 __attribute__((sda)); +extern float D_L06_00161C00 __attribute__((sda)); void FUN_L06_002e9998(char *m, float *a1, float *a2) { float d; float A[4], B[4], C[4], D[4], E[4], F[4], G[4], H[4]; @@ -900,7 +900,7 @@ void FUN_L06_002e9998(char *m, float *a1, float *a2) { m += 0xC0; extract_matrix_rotation_quaternion(A, m); extract_matrix_rotation_quaternion(B, F); - quaternion_nlerp(A, A, B, *(float *)&D_L06_00161C00); + quaternion_nlerp(A, A, B, D_L06_00161C00); quaternion_to_rotation_basis(A, m); } /* Ported from rac1-decomp (src/overlays/shared/vendor_002D9548.c: func_L06_002EAED8), where it is exact; names translated to the US level program. */ @@ -1380,7 +1380,7 @@ extern int random_integer_below(int) __asm__("FUN_00213260"); extern int scale_game_frames(int); extern int tick_countdown_32(int *); extern float D_L06_00161CE0 __attribute__((sda)); -extern unsigned char D_0014C050[]; +#include "rnc/gameplay/state/game_globals.h" #define GB_FLAG (*(unsigned char *)0x15EDB3) extern void FUN_L00_001ff290(void *, void *, void *); extern void FUN_L00_00258278(char *moby, float target, float *vel, float k, float d, float max); @@ -1487,7 +1487,7 @@ void FUN_L06_002f0040(GbMoby *moby) { moby->pos[2] = probe_ground_height(moby->pos, 0, 0.5f); FUN_L06_002d8b98((char *)moby); d->f2F0.q = d->f2E0.q = *(OvlQuad *)moby->pos; - if (D_0014C050[moby->fB0 + current_level_index * 16] == 0xFF) { + if (visited52[moby->fB0 + current_level_index * 16] == 0xFF) { mark_moby_for_removal(moby); return; } @@ -2961,7 +2961,7 @@ extern void FUN_L02_002ea7d0(char *); extern void FUN_L06_002f7548(char *); void FUN_L06_002f7628(char *m); extern char D_0014171B_86b8[] __asm__("D_0014C190"); -extern unsigned char D_0014C050[]; +#include "rnc/gameplay/state/game_globals.h" void FUN_L06_002f7288(char *m) { char *d = *(char **)(m + 0x78); @@ -2973,7 +2973,7 @@ void FUN_L06_002f7288(char *m) { D_0014171B_86b8) >> (*(unsigned short *)(m + 0xB2) & 0x1F) & 1) && - (current_level_index != 10 || (q = (unsigned char *)((char *)D_0014C050), + (current_level_index != 10 || (q = (unsigned char *)((char *)visited52), (q + ((unsigned char *)m)[0xB0]))[0xA0] == 0xFF)) { m[0x20] = 2; m[0xBC] = 1; @@ -3187,10 +3187,10 @@ extern f32 fast_add_rotations(f32 a, f32 b) __asm__("FUN_001fa580"); extern float D_0015ED6C; extern int allocate_voice_for_target_entry(int, int, int) __asm__("FUN_0022da68"); extern int FUN_L00_0028d8c0(void *, int); -extern short D_L06_00161E74 __attribute__((sda)); -extern short D_L06_00161E78 __attribute__((sda)); -extern short D_L06_00161E7C __attribute__((sda)); -extern short D_L06_00161E80 __attribute__((sda)); +extern float D_L06_00161E74 __attribute__((sda)); +extern float D_L06_00161E78 __attribute__((sda)); +extern float D_L06_00161E7C __attribute__((sda)); +extern float D_L06_00161E80 __attribute__((sda)); extern void FUN_L00_002502f0(void *, int, int, int); extern void FUN_L06_002f7c68_c(char *m) __asm__("FUN_L06_002f7c68"); extern void release_voice_slot(s32) __asm__("FUN_0022d798"); @@ -3216,19 +3216,19 @@ void FUN_L06_002f7ab8(struct Moby *m) { switch (m->state) { case 0: FUN_L00_002502f0(m, 0x80, 0x80, 0x80); - m->scale = m->pclass->scale * *(float *)&D_L06_00161E80; + m->scale = m->pclass->scale * D_L06_00161E80; *(char **)d = d + 0x20; m->state = 1; m->flags |= 0x20; *(int *)(d + 0x60) = -1; case 1: { - float a0 = *(float *)&D_L06_00161E74 * DEG_TO_RAD * D_0015ED6C; + float a0 = D_L06_00161E74 * DEG_TO_RAD * D_0015ED6C; float a1, a2; float x = fast_add_rotations(m->rot.x, a0); - a1 = *(float *)&D_L06_00161E78 * DEG_TO_RAD * D_0015ED6C; + a1 = D_L06_00161E78 * DEG_TO_RAD * D_0015ED6C; m->rot.x = x; x = fast_add_rotations(m->rot.y, a1); - a2 = *(float *)&D_L06_00161E7C * DEG_TO_RAD * D_0015ED6C; + a2 = D_L06_00161E7C * DEG_TO_RAD * D_0015ED6C; m->rot.y = x; m->rot.z = fast_add_rotations(m->rot.z, a2); } @@ -3246,14 +3246,14 @@ extern float random_float_between_alt(float, float) __asm__("FUN_002132a8"); extern int random_integer_below(int) __asm__("FUN_00213260"); extern void FUN_L00_002730e0(void *, float, void *, int, int, int, int); -extern short D_L06_00161E84 __attribute__((sda)); -extern short D_L06_00161E88 __attribute__((sda)); -extern short D_L06_00161E98 __attribute__((sda)); -extern short D_L06_00161E9C __attribute__((sda)); -extern short D_L06_00161EA0 __attribute__((sda)); -extern short D_L06_00161EA4 __attribute__((sda)); -extern short D_L06_00161EA8 __attribute__((sda)); -extern short D_L06_00161EAC __attribute__((sda)); +extern float D_L06_00161E84 __attribute__((sda)); +extern float D_L06_00161E88 __attribute__((sda)); +extern int D_L06_00161E98 __attribute__((sda)); +extern int D_L06_00161E9C __attribute__((sda)); +extern int D_L06_00161EA0 __attribute__((sda)); +extern int D_L06_00161EA4 __attribute__((sda)); +extern float D_L06_00161EA8 __attribute__((sda)); +extern float D_L06_00161EAC __attribute__((sda)); extern unsigned char D_L06_00161E94 __attribute__((sda)); void FUN_L06_002f7c68(char *m) { float buf[4]; @@ -3263,14 +3263,14 @@ void FUN_L06_002f7c68(char *m) { int r; int c; int v; - random_vector(buf, *(float *)&D_L06_00161E84 * frame_time, - *(float *)&D_L06_00161E88 * frame_time); - f = random_float_between_alt(*(float *)&D_L06_00161EA8, *(float *)&D_L06_00161EAC); + random_vector(buf, D_L06_00161E84 * frame_time, + D_L06_00161E88 * frame_time); + f = random_float_between_alt(D_L06_00161EA8, D_L06_00161EAC); if (random_integer_below(2) != 0) { - r = fast_tween_color(*(int *)&D_L06_00161E98, *(int *)&D_L06_00161E9C, + r = fast_tween_color(D_L06_00161E98, D_L06_00161E9C, random_float_between_alt(0.0f, 1.0f)); } else { - r = fast_tween_color(*(int *)&D_L06_00161EA0, *(int *)&D_L06_00161EA4, + r = fast_tween_color(D_L06_00161EA0, D_L06_00161EA4, random_float_between_alt(0.0f, 1.0f)); } c = D_L06_00161E94; diff --git a/src/overlays/shared/gameplay/entities/nanotech_ball.c b/src/overlays/shared/gameplay/entities/nanotech_ball.c index cf257c4c23..4c71b6a76f 100644 --- a/src/overlays/shared/gameplay/entities/nanotech_ball.c +++ b/src/overlays/shared/gameplay/entities/nanotech_ball.c @@ -139,7 +139,7 @@ typedef struct { char p1C[0x28 - 0x1C]; float f28; } G_2d81b8; -extern int D_L00_00173E40[] __attribute__((section(".data"))); +extern int D_L00_00173E40_lui[] __asm__("D_L00_00173E40") __attribute__((section(".data"))); extern float D_L00_00173E68_2d81b8 __asm__("D_L00_00173E68") __attribute__((section(".data"))); extern float frame_time_sq __asm__("D_0015ED70"); int FUN_001efa68_2d81b8(void *, void *, int, void *, int) __asm__("FUN_001efa68"); @@ -160,7 +160,7 @@ void FUN_L00_002d81b8(unsigned char *m) { z = b.f[2]; } if (hit) { - G_2d81b8 *g = &(*(G_2d81b8 *)D_L00_00173E40); + G_2d81b8 *g = &(*(G_2d81b8 *)D_L00_00173E40_lui); if (g->o) { if (FUN_L00_0025e3b8_2d81b8(g->o)) { *(float *)(m + 0x10) = d->f10 = g->o->x; @@ -370,7 +370,7 @@ void FUN_L00_002d8908(void) { } } #include "rnc/math/vector.h" -extern char *D_001413D0 __attribute__((section(".data"))); +extern s32 D_001413D0_lui[] __asm__("D_001413D0") __attribute__((section(".data"))); #include "rnc/gameplay/entities/moby.h" /* Ported from rac1-decomp (src/overlays/shared/vendor_002D9438.c: func_L00_002D9EA0), where it is exact; names translated to the US level program. */ @@ -993,12 +993,12 @@ void FUN_L00_002d9810(u8 *m) { } #endif int FUN_001efa68(Vec4 *, Vec4 *, int, int, int); -/* True when coll_line_fix returns 0 for the moby and D_001413D0 positions, both raised by 0.5. */ +/* True when coll_line_fix returns 0 for the moby and (*(char * *)&D_001413D0_lui) positions, both raised by 0.5. */ int FUN_L00_002d8980(char *a) { Vec4 p, t; qcopy(&p, a + 0x10); p.f[2] += 0.5f; - qcopy(&t, D_001413D0 + 0x10); + qcopy(&t, (*(char * *)&D_001413D0_lui) + 0x10); t.f[2] += 0.5f; return FUN_001efa68(&p, &t, 0x12, 0, 0) == 0; } @@ -1410,7 +1410,7 @@ extern f32 square_root_scalar(f32) __asm__("func_001F9988"); extern f32 vector_length_xy(void *) __asm__("FUN_001f9b20"); extern float vector_distance_xy(void *, void *) __asm__("FUN_001f9b80"); extern float fast_difference_between_rotations(float, float) __asm__("func_001FA688"); -extern int D_L00_00173E40[]; +extern int D_L00_00173E40_lui[]; extern int collision_segment_hits(void *, void *, int, int, int) __asm__("FUN_001efa68"); extern int allocate_voice_for_target_entry_alt(int,int,int) __asm__("FUN_0022da68"); extern int queue_animation_update_alt(int,int,int,int,int,int,int) __asm__("FUN_001ff308"); @@ -1439,7 +1439,7 @@ extern void transform_vector_by_basis(void *, void *, void *) __asm__("func_001F f32 compute_interpolated_record_value(void *anim) __asm__("FUN_0020c9e0"); float absolute_float(float input) __asm__("func_001F99C0"); s32 scale_game_frames_alt(s32) __asm__("FUN_001f96f8"); -extern char D_00141680[]; +#include "rnc/gameplay/state/game_globals.h" extern char D_0013E550[]; extern int func_001F9908_r(void *) __asm__("FUN_001f9740"); extern SuckHero suck_hero __asm__("D_0013F350"); @@ -1498,7 +1498,7 @@ void FUN_L00_002da790(SuckMoby *self) { FUN_L00_0020e4c8(); cannon->sound = allocate_voice_for_target_entry_alt(2,4,(int)self); cannon->cooldown = scale_game_frames_alt(10); - stats = (SuckStats *)(((char *)&D_00141680)); + stats = (SuckStats *)(((char *)&item_usage)); if (stats->count < 65535) stats->count++; if (scale_game_frames_alt(D_0015EEA4)/600 > stats->longest) stats->longest = scale_game_frames_alt(D_0015EEA4)/600; @@ -1589,7 +1589,7 @@ void FUN_L00_002da790(SuckMoby *self) { transform_vector(&work.aim.velocity,&work.aim.velocity,&work.aim.inverse); add_vector_xyz(&work.aim.end,eye,&work.aim.velocity); if(collision_segment_hits(eye,&work.aim.end,0,(int)self,0)) { - hit=(SuckHit *)D_L00_00173E40; + hit=(SuckHit *)D_L00_00173E40_lui; if(hit->moby && (hit->moby->flags&0x1000)) { cannon->target=hit->moby; cannon->target_timer=scale_game_frames_alt(20); @@ -1617,7 +1617,7 @@ void FUN_L00_002da790(SuckMoby *self) { blend_moby_animation(self,5,0,scale_game_frames_alt(2)); suck_hero.firing=2; cannon->cooldown=scale_game_frames_alt(25); - stats=(SuckStats *)(((char *)&D_00141680)); + stats=(SuckStats *)(((char *)&item_usage)); if(stats->count<65535) stats->count++; if(scale_game_frames_alt(D_0015EEA4)/600>stats->longest) stats->longest=scale_game_frames_alt(D_0015EEA4)/600; @@ -2291,7 +2291,7 @@ extern unsigned char D_001404FC_2DDEA0[] __asm__("D_001403FC"); extern char D_0013F450_2DDEA0[] __asm__("D_0013F350"); extern char D_0013F4D0_2DDEA0[] __asm__("D_0013F3D0"); extern char D_0013FA90_2DDEA0[] __asm__("D_0013F990"); -extern int D_L00_00173E40[]; +extern int D_L00_00173E40_lui[]; extern char D_L00_001EA4B0_2DDEA0[] __asm__("D_L00_001EA130"); extern R_2DDEA0 *func_L00_002DCD40_2DDEA0(struct Moby *) __asm__("FUN_L00_002db890"); extern float func_L00_001FF860_2DDEA0(float, float) __asm__("FUN_001f9e90"); @@ -2515,10 +2515,10 @@ int FUN_L00_002dc9f0(struct Moby *moby, char *vars) { hit_wall = func_L00_001F2BE8_2DDEA0(record->f80, &moby->pos, 1, moby, &work.v[1]); hit_wall |= func_L00_001F10E0_2DDEA0(record->f80, &moby->pos, 0, moby); if (hit_wall != 0) { - qcopy_nc(&moby->pos, &((Coll_2DDEA0 *)D_L00_00173E40)->v30); - func_001F9BF0_2DDEA0(&record->v50, &((Coll_2DDEA0 *)D_L00_00173E40)->v20, &moby->pos); + qcopy_nc(&moby->pos, &((Coll_2DDEA0 *)D_L00_00173E40_lui)->v30); + func_001F9BF0_2DDEA0(&record->v50, &((Coll_2DDEA0 *)D_L00_00173E40_lui)->v20, &moby->pos); } - if (((Coll_2DDEA0 *)D_L00_00173E40)->hit != 0 && ((Coll_2DDEA0 *)D_L00_00173E40)->hit->oclass == 0) hit_wall = 0; + if (((Coll_2DDEA0 *)D_L00_00173E40_lui)->hit != 0 && ((Coll_2DDEA0 *)D_L00_00173E40_lui)->hit->oclass == 0) hit_wall = 0; if (record->state == 6) { moby->flags &= 0x7FFF; moby->collision = ((Cls_2DDEA0 *)moby->pclass)->i10; @@ -2543,17 +2543,17 @@ int FUN_L00_002dc9f0(struct Moby *moby, char *vars) { } if (hit_wall != 0) { surface = 0; - if (((Coll_2DDEA0 *)D_L00_00173E40)->hit != 0 && ((Cls_2DDEA0 *)((Coll_2DDEA0 *)D_L00_00173E40)->hit->pclass) != 0) { - surface = ((Cls_2DDEA0 *)((Coll_2DDEA0 *)D_L00_00173E40)->hit->pclass)->h46; + if (((Coll_2DDEA0 *)D_L00_00173E40_lui)->hit != 0 && ((Cls_2DDEA0 *)((Coll_2DDEA0 *)D_L00_00173E40_lui)->hit->pclass) != 0) { + surface = ((Cls_2DDEA0 *)((Coll_2DDEA0 *)D_L00_00173E40_lui)->hit->pclass)->h46; } - func_L00_001FF4B0_2DDEA0(&((Coll_2DDEA0 *)D_L00_00173E40)->v40, &((Coll_2DDEA0 *)D_L00_00173E40)->v40, 1.0f); + func_L00_001FF4B0_2DDEA0(&((Coll_2DDEA0 *)D_L00_00173E40_lui)->v40, &((Coll_2DDEA0 *)D_L00_00173E40_lui)->v40, 1.0f); if (moby->prev_seq != record->anims[6]) { unsigned char anim = record->anims[6]; func_00213DE0_2DDEA0(moby, anim, 0, func_001F9850_2DDEA0(0x14)); } moby->collision_disable = record->i88; record->state = 6; - if (0.87266463f < func_L00_001FF860_2DDEA0(((Coll_2DDEA0 *)D_L00_00173E40)->v40.z, func_001F9CE8_2DDEA0(&((Coll_2DDEA0 *)D_L00_00173E40)->v40))) { + if (0.87266463f < func_L00_001FF860_2DDEA0(((Coll_2DDEA0 *)D_L00_00173E40_lui)->v40.z, func_001F9CE8_2DDEA0(&((Coll_2DDEA0 *)D_L00_00173E40_lui)->v40))) { if (record->h9E >= 0) func_0022ED80_2DDEA0(record->h9E, 0, moby); func_L00_002DDDE8_2DDEA0(moby, record, 1); return 0; @@ -2563,7 +2563,7 @@ int FUN_L00_002dc9f0(struct Moby *moby, char *vars) { func_L00_002DDDE8_2DDEA0(moby, record, 1); } qzero(&work.v[1]); - work.v[1].z = ((Coll_2DDEA0 *)D_L00_00173E40)->v40.z; + work.v[1].z = ((Coll_2DDEA0 *)D_L00_00173E40_lui)->v40.z; func_L00_001FF610_2DDEA0(&record->vel, &record->vel, &work.v[1]); } if (func_001F9908_2DDEA0(&record->i94) != 0) { @@ -2633,7 +2633,7 @@ extern char D_L00_001E5EE0[] __attribute__((section(".data"))); extern char D_L00_001E6020[] __attribute__((section(".data"))); extern s64 get_effect_texture(s32) __asm__("func_001F44B8"); extern float D_L00_00161B48 __attribute__((sda)); -extern short D_L00_00161B4C __attribute__((sda)); +extern float D_L00_00161B4C __attribute__((sda)); extern float D_L00_00161B50 __attribute__((sda)); extern short D_L00_001E6008[] __attribute__((section(".data"))); extern void fast_draw_quad_real(void *, void *, int); @@ -2661,9 +2661,9 @@ void FUN_L00_002dd8e8(void) { step = 0.3f; a += step; for (i = 1; i < 10; i++) { - b = *(float *)&D_L00_00161B4C; - *(float *)&D_L00_00161B4C = b + D_L00_00161B50; - if (*(float *)&D_L00_00161B4C > 7.0f) *(float *)&D_L00_00161B4C -= 7.0f; + b = D_L00_00161B4C; + D_L00_00161B4C = b + D_L00_00161B50; + if (D_L00_00161B4C > 7.0f) D_L00_00161B4C -= 7.0f; a2 = a + step; for (j = 0; j < 20; j++) { qcopy(s.q[0], D_L00_001E6020 + (j * 16 + i * 0x140)); @@ -2832,7 +2832,7 @@ extern char D_L00_001E4B40[]; extern char D_L00_001E6020[] __asm__("D_L00_001E6020"); extern char D_L00_001E5FE0[]; extern short D_L00_001E6008[] __attribute__((section(".data"))); -extern unsigned char D_L00_00173E60[]; +extern V D_L00_00173E60; void FUN_L00_002ddcb8_u(char *, void *) __asm__("FUN_L00_002ddcb8"); void FUN_L00_002dd8e8_u(void) __asm__("FUN_L00_002dd8e8"); void FUN_001ff2a8_002ddf60(void *, void *, void *) __asm__("FUN_001f9a28"); @@ -2896,7 +2896,7 @@ void FUN_L00_002ddf60(void *frame_context, void *initial_vector) { FUN_001ff500_002ddcb8(&probe, &first, D_L00_00161B84_lui * 10.0f); FUN_001ff278_002ddcb8(&probe, &probe, initial_vector); if (FUN_001efc70_002ddf60(initial_vector, &probe, 20, *(void **)(global + 0x2080), 0)) { - i = truncate_float_to_s32(FUN_001ff488_002ddf60(((char *)D_L00_00173E60), initial_vector) / D_L00_00161B84_lui); + i = truncate_float_to_s32(FUN_001ff488_002ddf60(((char *)((unsigned char *)&D_L00_00173E60)), initial_vector) / D_L00_00161B84_lui); if (i < 10) { halfword = (short *)(D_L00_001E5F40_002ddcb8 + 0xc8) + i; j = i; @@ -3328,9 +3328,9 @@ extern int fast_tween_color(int, int, float) __asm__("FUN_001fa6e0"); extern void FUN_L00_002502f0(void *, int, int, int); extern void FUN_L00_002df4a8_u(void *) __asm__("FUN_L00_002df4a8"); -extern short D_L00_00161B90 __attribute__((sda)); -extern short D_L00_00161B94 __attribute__((sda)); -extern short D_L00_00161B98 __attribute__((sda)); +extern int D_L00_00161B90 __attribute__((sda)); +extern int D_L00_00161B94 __attribute__((sda)); +extern float D_L00_00161B98 __attribute__((sda)); void FUN_L00_002df4f8(char *m) { char *p = *(char **)(m + 0x78); unsigned char s = m[0x20]; @@ -3343,10 +3343,10 @@ void FUN_L00_002df4f8(char *m) { break; case 1: a = fast_add_rotations(*(float *)p, - *(float *)&D_L00_00161B98 * DEG_TO_RAD * frame_time); + D_L00_00161B98 * DEG_TO_RAD * frame_time); *(float *)p = a; a = FUN_001f9de0(a); - c = fast_tween_color(*(int *)&D_L00_00161B90, *(int *)&D_L00_00161B94, a * 0.5f + 0.5f); + c = fast_tween_color(D_L00_00161B90, D_L00_00161B94, a * 0.5f + 0.5f); b = (c >> 16) & 0xFF; g = (c >> 8) & 0xFF; r = c & 0xFF; diff --git a/src/overlays/shared/gameplay/entities/plasmabot.c b/src/overlays/shared/gameplay/entities/plasmabot.c index fc0230e861..7677c43dbb 100644 --- a/src/overlays/shared/gameplay/entities/plasmabot.c +++ b/src/overlays/shared/gameplay/entities/plasmabot.c @@ -77,9 +77,9 @@ void FUN_L14_002b3358(char *moby) { /* Ported from rac1-decomp (src/overlays/shared/vendor_002B2A28.c: func_L14_002B47C8), where it is exact; names translated to the US level program. */ -extern short D_L14_001614DC __attribute__((sda)); +extern float D_L14_001614DC __attribute__((sda)); void FUN_L14_002b3578(char *moby) { - float f = (*(float *)&D_L14_001614DC - 1.0f) * frame_scale + 1.0f; + float f = (D_L14_001614DC - 1.0f) * frame_scale + 1.0f; char *d = *(char **)(moby + 0x78); *(float *)(d + 0x254) = *(float *)(d + 0x254) * f; *(float *)(d + 0x258) = *(float *)(d + 0x258) * f; @@ -115,7 +115,7 @@ void FUN_L14_002b37b0(char *a, float x) { extern char *D_L14_ffd0_e_macro[] __asm__("D_L14_0015FFD0") __attribute__((section(".sdata"))); extern int FUN_001f96f8(int); extern short *D_L14_001ABF40[]; -extern short D_L14_001614E0; +extern int D_L14_001614E0; void FUN_L14_002b3890(int idx) { short *p; @@ -126,7 +126,7 @@ void FUN_L14_002b3890(int idx) { char *moby = D_L14_ffd0_e_macro[2] + ((*(unsigned short *)p & 0x7FFF) << 8); char *data = *(char **)(moby + 0x78); if (*(short *)(moby + 0xA6) == 0x1C) { - *(short *)(data + 0x260) = FUN_001f96f8(*(int *)&D_L14_001614E0); + *(short *)(data + 0x260) = FUN_001f96f8(D_L14_001614E0); } } while (*p++ >= 0); } @@ -168,16 +168,16 @@ void FUN_L14_002fe900(char *moby) { extern void FUN_001f9a10(void *, void *, void *); extern void fast_vec_normalize(void *, void *, float) __asm__("FUN_001f9bf8"); -extern short D_L14_00161FC4 __attribute__((sda)); -extern short D_L14_00161FC8 __attribute__((sda)); +extern float D_L14_00161FC4 __attribute__((sda)); +extern float D_L14_00161FC8 __attribute__((sda)); void FUN_L14_002fec28(char *moby) { char *data = *(char **)(moby + 0x78); float tmp[4]; if (*(char **)(data + 0xF4) != 0) { char *p; - fast_vec_normalize(tmp, moby + 0xC0, *(float *)&D_L14_00161FC4); + fast_vec_normalize(tmp, moby + 0xC0, D_L14_00161FC4); FUN_001f9a10(*(char **)(data + 0xF4) + 0x10, moby + 0x10, tmp); - fast_vec_normalize(tmp, moby + 0xE0, *(float *)&D_L14_00161FC8); + fast_vec_normalize(tmp, moby + 0xE0, D_L14_00161FC8); p = *(char **)(data + 0xF4) + 0x10; FUN_001f9a10(p, p, tmp); } @@ -211,148 +211,177 @@ unsigned char *FUN_L14_002ffaf8(unsigned char *owner, char *pos) { return m; } -#ifndef NON_MATCHING -INCLUDE_ASM("config/us/overlays/asm/FUN_L14_002b17d8.s", FUN_L14_002b17d8); -#else +#include "rnc/math/vector.h" #include "rnc/gameplay/entities/moby.h" -extern void FUN_L14_002b2f60(char *); -extern void FUN_L14_002b2ed8(struct Moby *); -extern int FUN_L14_002b3418(char *); -extern float FUN_L14_002b35d8(char *, int, float); -extern int FUN_L14_002b3920(int); -extern int FUN_L14_002b39a0(unsigned char *); -extern void FUN_L14_002b2600(struct Moby *); -extern int FUN_L14_002d9870(int); -extern unsigned char *FUN_L14_002dea98(char *, char *); -extern unsigned char *FUN_L14_002e0170(char *, float *, int); -extern int FUN_L00_002e2040(char *); -extern void FUN_L00_00257470(void *, int, int); -extern float FUN_L00_0025b8c0(float *, float *, float, float, float, float); -extern void FUN_L00_0025e450(void *, void *, void *, float, float, int, int, int, float, float, float, float, int, float, int, int, int, int); -extern void mark_moby_for_removal(struct Moby *) __asm__("FUN_0020c828"); -extern int FUN_001fa6d0(float); -extern float FUN_001fa6c0(int); -extern float FUN_001f9dc8(float); -extern float FUN_001f9de0(float); -extern float fast_difference_between_rotations(float, float) __asm__("func_001FA688"); -extern float probe_ground_height_ff640(float, void *, int) __asm__("FUN_00213508"); -extern void set_moby_animation_c(void *, int, int) __asm__("FUN_00212ed8"); -extern void moby_point_position(struct Moby *, int, void *) __asm__("FUN_L00_0024f7c8"); -extern void build_moby_bone_transform(struct Moby *, int, void *) __asm__("FUN_0020cca8"); -extern void FUN_L00_00263ac8(void *, int, void *, float); -extern int debug_print(char *, ...) __asm__("FUN_001e93b0"); -extern int FUN_001f9770(short *); -extern float compute_interpolated_record_value(void *) __asm__("FUN_0020c9e0"); -extern void attach_manipulator(void *, int, void *) __asm__("FUN_0020cb10"); -extern void blend_moby_animation(void *, int, int, int) __asm__("FUN_00212f90"); -extern int FUN_L00_0025c698(void *, void *); -extern int FUN_L00_00261968(int, void *, void *); -extern int FUN_L00_002e1f28(void *, int, int); -extern void FUN_L00_002e2190(void *, void *, void *); -extern int coll_line_fix(void *, void *, int, void *, void *) __asm__("FUN_001efa68"); -extern unsigned char D_001413F4[]; -extern int D_L14_0015F5C4 __attribute__((section(".data"))); -extern int D_L14_0015F5C4_gp __asm__("D_L14_0015F5C4") __attribute__((sda)); -extern int D_L14_001614F0 __attribute__((sda)); -extern int D_L14_001614EC __attribute__((sda)); -extern float D_L14_001614E8 __attribute__((sda)); -extern float D_L14_001614E4 __attribute__((sda)); -extern float D_L14_001614F4 __attribute__((sda)); -extern OvlQuad D_L14_00174560; -extern char D_L14_001FBB60[], D_L14_001FBBA0[], D_L14_001FBBF8[], D_L14_001FBC38[], D_L14_001FBC90[]; + +/* Plasmabot update: validates its path and target, walks the path, turns to aim at its owner's target and fires, dies or despawns. */ +/* Ported from rac1-decomp (src/overlays/shared/vendor_002B2A28.c: func_L14_002B2A28), where it is exact; names translated to the US level program. */ typedef struct { - float x, y, scale, distance; - void *moby; + float x; + float y; + float scale; + float distance; + char *moby; int flags; - unsigned char mode, enabled; + unsigned char mode; + unsigned char enabled; unsigned short oclass; float strength; int count; -} LineInfo_2b17d8; - -/* State-driven path movement, aiming and attack update. */ -void FUN_L14_002b17d8(unsigned char *moby) { - OvlVec4 mat[4]; - OvlVec4 direction, end; - unsigned char *data = *(unsigned char **)(moby + 0x78); - OvlVec4 *start; - OvlVec4 *direction_ptr; - LineInfo_2b17d8 info; - OvlVec4 scale; - char *owner = 0; - int mode; - long idx; - unsigned int state; - unsigned long anim; - - FUN_L00_00263ac8(moby, 2, data + 0x120, 2.5f); - if (*(int *)(data + 0x288)) { - if (D_001413F4[0] != 2) { +} LineInfo; + +extern char D_001413F4[]; +extern char D_L14_001FBB60[]; +extern char D_L14_001FBBA0[]; +extern char D_L14_001FBBF8[]; +extern char D_L14_001FBC38[]; +extern char D_L14_001FBC90[]; +extern f32 convert_integer_to_float(s32) __asm__("func_001FA6C0"); +extern f32 fast_arc_tan_c(f32, f32) __asm__("func_001F9E90"); +extern f32 fast_cos(f32) __asm__("func_001F9DC8"); +extern f32 fast_sin(f32) __asm__("func_001F9DE0"); +extern f32 fast_subtract_rotations_c2(f32, f32) __asm__("func_001FA5C8"); +extern float FUN_L00_0025b8c0(float *p, float *v, float t, float u1, float u2, float eps); +extern float fast_difference_between_rotations(float, float) __asm__("func_001FA688"); +extern float probe_ground_height(float, void *, int); +extern int D_L14_0015F5C4; +extern int coll_line_fix(void *, void *, int, void *, void *) __asm__("FUN_001efa68"); +extern int FUN_001f9770(void *); +extern int FUN_L00_0025c698(void *, void *); +extern int FUN_L00_00261968(int, void *, void *); +extern int FUN_L00_002e1f28(void *, int, int); +extern int FUN_L00_002e2040(char *); +extern int FUN_L00_002e2190(void *, void *, void *); +extern int FUN_L14_002b39a0_c(unsigned char *) __asm__("FUN_L14_002b39a0"); +extern s32 random_integer_below(s32) __asm__("func_00213260"); +extern s32 scale_game_frames(s32) __asm__("func_001F96F8"); +extern s32 truncate_float_to_s32(f32) __asm__("func_001FA6D0"); +extern float D_L14_001614E4_gp __asm__("D_L14_001614E4") __attribute__((sda)); +extern float D_L14_001614E8_gp __asm__("D_L14_001614E8") __attribute__((sda)); +extern int D_L14_001614EC_gp __asm__("D_L14_001614EC") __attribute__((sda)); +extern int D_L14_001614F0; +extern float D_L14_001614F4_gp __asm__("D_L14_001614F4") __attribute__((sda)); +extern u8 D_L14_00174560[]; +extern void DebugPrint(char *, ...); +extern void FUN_L00_0024f7c8(char *, int, void *); +extern void FUN_L00_00257470(void *, int, int); +extern void FUN_L00_0025e450_c(struct Moby *, void *, void *, float, float, int, int, int, float, float, float, float, int, float, int, int, int, int) __asm__("FUN_L00_0025e450"); +extern void FUN_L00_00263ac8(float, char *, int, char *); +extern void add_vector_xyz_c3(void *, void *, void *) __asm__("FUN_001f9a10"); +extern void blend_moby_animation(void *, s32, s32, s32) __asm__("FUN_00212f90"); +extern void build_moby_bone_transform_c(char *, int, void *) __asm__("build_moby_bone_transform"); +extern void fast_vec_normalize(void *, void *, f32) __asm__("FUN_001f9bf8"); +extern void mark_moby_for_removal_c(void *) __asm__("func_0020C828"); +extern void set_moby_animation(void *, int, int) __asm__("FUN_00212ed8"); +f32 compute_interpolated_record_value(void *anim) __asm__("FUN_0020c9e0"); +float FUN_L14_002b35d8_c(char *moby, int flag, float angle) __asm__("FUN_L14_002b35d8"); +int FUN_L14_002b3418_c(char *moby) __asm__("FUN_L14_002b3418"); +int FUN_L14_002b3920_c(int index) __asm__("FUN_L14_002b3920"); +int FUN_L14_002d9870_c(int i) __asm__("FUN_L14_002d9870"); +unsigned char *FUN_L14_002dea98_c(char *owner, char *pos) __asm__("FUN_L14_002dea98"); +unsigned char *FUN_L14_002e0170_c(char *owner, float *scale, int mode) __asm__("FUN_L14_002e0170"); +void FUN_L14_002b2600_c(struct Moby *m) __asm__("FUN_L14_002b2600"); +void FUN_L14_002b2ed8_c(struct Moby *m) __asm__("FUN_L14_002b2ed8"); +void FUN_L14_002b2f60_c(char *m) __asm__("FUN_L14_002b2f60"); +void FUN_L14_002b3268_c(char *moby) __asm__("FUN_L14_002b3268"); +void FUN_L14_002b3318_c(char *moby) __asm__("FUN_L14_002b3318"); +void FUN_L14_002b3330_c(char *moby) __asm__("FUN_L14_002b3330"); +void FUN_L14_002b3358_c(char *moby) __asm__("FUN_L14_002b3358"); +void FUN_L14_002b3578_c(char *moby) __asm__("FUN_L14_002b3578"); +void FUN_L14_002b37b0_c(char *moby, float angle) __asm__("FUN_L14_002b37b0"); +void FUN_L14_002b3890_c(int idx) __asm__("FUN_L14_002b3890"); +void attach_manipulator(void *owner, s32 slot_index, void *manip) __asm__("FUN_0020cb10"); + +#define call_4BF0(m) FUN_L14_002b39a0_c((unsigned char *)(m)) +#define call_CE58 ((float (*)(float *, float, float *, float, float, float))FUN_L00_0025be00) +#define call_F4A8 ((void (*)(char *, void *, void *, float, float, int, int, int, float, float, float, float, int, float, int, int, int, int))FUN_L00_0025e450_c) +#define call_D678 ((void (*)(char *))mark_moby_for_removal_c) + +void FUN_L14_002b17d8(char *moby) { + char *data; + char *owner; + int state; + float mat[4][4]; + float direction[4]; + float end[4]; + LineInfo info; + int status; + + data = *(char **)(moby + 0x78); + owner = 0; + FUN_L00_00263ac8(2.5f, moby, 2, data + 0x120); + if (*(int *)(data + 0x288) != 0) { + if (((unsigned char *)D_001413F4)[0] != 2) { *(unsigned short *)(moby + 0x34) |= 0x41; *(int *)(moby + 0x94) = 0; - if ((unsigned char)moby[0x53] == 5) { + if (((unsigned char *)moby)[0x53] == 5) { FUN_L00_002e2040(moby); FUN_L00_00257470(moby, 0, -1); - mark_moby_for_removal((struct Moby *)moby); - return; - } - { - unsigned short flags = *(unsigned short *)(moby + 0x34) & 0xEFFF; - moby[0x30] = 0xFF; - *(unsigned short *)(moby + 0x34) = flags; + { call_D678(moby); return; } } + ((unsigned char *)moby)[0x30] = 0xFF; + *(unsigned short *)(moby + 0x34) &= 0xEFFF; return; } *(unsigned short *)(moby + 0x34) &= 0xFFBE; - if ((unsigned char)moby[0x20] != 11) + if (((unsigned char *)moby)[0x20] != 0xB) { *(int *)(moby + 0x94) = *(int *)(*(char **)(moby + 0x24) + 0x10); - moby[0x30] = 0x40; + } + ((unsigned char *)moby)[0x30] = 0x40; *(unsigned short *)(moby + 0x34) |= 0x1000; } - mode = D_L14_0015F5C4_gp; - if ((unsigned char)moby[0x20] != 0) { - FUN_L14_002b2f60(moby); - FUN_L14_002b3268(moby); - FUN_L14_002b2ed8((struct Moby *)moby); - owner = *(char * volatile *)(data + 0x110); - mode = *(volatile int *)&D_L14_0015F5C4; + if (((unsigned char *)moby)[0x20] != 0) { + FUN_L14_002b2f60_c(moby); + FUN_L14_002b3268_c(moby); + FUN_L14_002b2ed8_c((struct Moby *)moby); + owner = *(char **)(data + 0x110); } - if (mode == 2) { - moby[0x31] = 0; + if (D_L14_0015F5C4 == 2) { + ((unsigned char *)moby)[0x31] = 0; *(unsigned short *)(moby + 0x34) |= 1; - } else if ((unsigned char)moby[0x20] != 1) { - moby[0x31] = 1; + } else if (((unsigned char *)moby)[0x20] != 1) { + ((unsigned char *)moby)[0x31] = 1; *(unsigned short *)(moby + 0x34) &= 0xFFFE; } - switch ((unsigned char)moby[0x20]) { + switch (((unsigned char *)moby)[0x20]) { case 0: { - int idx; - char *p; - unsigned long flag; - flag = (unsigned char)data[0x24A]; - if (data[0x24A]) { - idx = *(int *)(data + 0x240); - if (idx == -1) { debug_print(D_L14_001FBB60, *(short *)(moby + 0xB2)); goto remove; } - if (!*D_L14_001B0BB0[idx]) { debug_print(D_L14_001FBBA0, *(short *)(moby + 0xB2)); goto remove; } + if (((unsigned char *)data)[0x24A] != 0) { + if (*(int *)(data + 0x240) == -1) { + DebugPrint(D_L14_001FBB60, *(short *)(moby + 0xB2)); + { call_D678(moby); return; } + } + if (*D_L14_001B0BB0[*(int *)(data + 0x240)] == 0) { + DebugPrint(D_L14_001FBBA0, *(short *)(moby + 0xB2)); + { call_D678(moby); return; } + } + } + if (*(int *)(data + 0x244) == -1) { + DebugPrint(D_L14_001FBBF8, *(short *)(moby + 0xB2)); + { call_D678(moby); return; } + } + if (*D_L14_001B0BB0[*(int *)(data + 0x244)] == 0) { + DebugPrint(D_L14_001FBC38, *(short *)(moby + 0xB2)); + { call_D678(moby); return; } } - idx = *(int *)(data + 0x244); - if (idx == -1) { debug_print(D_L14_001FBBF8, *(short *)(moby + 0xB2)); goto remove; } - if (!*D_L14_001B0BB0[idx]) { debug_print(D_L14_001FBC38, *(short *)(moby + 0xB2)); goto remove; } - if ((unsigned char)flag && *(int *)(data + 0x264) < 0) { debug_print(D_L14_001FBC90, *(short *)(moby + 0xB2)); goto remove; } - if (FUN_00213260(2)) *(unsigned short *)(moby + 0x34) |= 0x8000; - FUN_L14_002b3358(moby); + if (((unsigned char *)data)[0x24A] != 0 && *(int *)(data + 0x264) < 0) { + DebugPrint(D_L14_001FBC90, *(short *)(moby + 0xB2)); + { call_D678(moby); return; } + } + if (random_integer_below(2) != 0) { + *(unsigned short *)(moby + 0x34) |= 0x8000; + } + FUN_L14_002b3358_c(moby); if (*(int *)(data + 0x240) != -1) { - p = (char *)D_L14_001B0BB0[*(int *)(data + 0x240)]; - qcopy(moby + 0x10, p + 0x10); + qcopy(moby + 0x10, (char *)D_L14_001B0BB0[*(int *)(data + 0x240)] + 0x10); } data[0x28] = 1; data[0x29] = 0; *(float *)(data + 0x20) = 2.0f; *(float *)(data + 0x30) = 1.25f; *(short *)(data + 0x24) = 2; - data[0x58] = FUN_001fa6d0(15.0f); - data[0x5A] = FUN_001fa6d0(16.0f); + data[0x58] = truncate_float_to_s32(15.0f); + data[0x5A] = truncate_float_to_s32(16.0f); *(float *)(data + 0x27C) = 1.0f; *(short *)(data + 0x248) = 0; *(int *)(data + 0x23C) = 0; @@ -363,269 +392,268 @@ void FUN_L14_002b17d8(unsigned char *moby) { *(int *)(data + 0x284) = 0; *(int *)(data + 0x270) = 0; *(int *)(data + 0x274) = 0; - if (!data[0x121]) attach_manipulator(moby, 2, data + 0x120); - if (!data[0x161]) attach_manipulator(moby, 3, data + 0x160); - if (data[0x24A]) { FUN_L14_002b3318(moby); moby[0x20] = 1; return; } - *(float *)(moby + 0x18) = probe_ground_height_ff640(0.5f, moby + 0x10, 0); - if (*(int *)(data + 0x240) == -1) moby[0x20] = 4; - else moby[0x20] = 13; + if (((unsigned char *)data)[0x121] == 0) { + attach_manipulator(moby, 2, data + 0x120); + } + if (((unsigned char *)data)[0x161] == 0) { + attach_manipulator(moby, 3, data + 0x160); + } + if (((unsigned char *)data)[0x24A] != 0) { + FUN_L14_002b3318_c(moby); + ((unsigned char *)moby)[0x20] = 1; + return; + } + *(float *)(moby + 0x18) = probe_ground_height(0.5f, moby + 0x10, 0); + if (*(int *)(data + 0x240) == -1) { + ((unsigned char *)moby)[0x20] = 4; + } else { + ((unsigned char *)moby)[0x20] = 0xD; + } return; } case 1: { - char *p; - float f; + float *path; if (*(int *)(data + 0x114) == 2) return; - if (!FUN_001f9770((short *)(data + 0x248))) return; - if (!FUN_L14_002d9870(*(int *)(data + 0x264))) return; - if (!FUN_L14_002b39a0((unsigned char *)moby)) return; - *(short *)(data + 0x248) = FUN_001f96f8(D_L14_001614F0); - FUN_L14_002b3330(moby); - moby[0x20] = 2; - set_moby_animation_c(moby, 1, 0); - p = (char *)D_L14_001B0BB0[*(int *)(data + 0x240)]; - *(float *)(moby + 0x48) = fast_arc_tan(*(float *)(p + 0x20) - *(float *)(p + 0x10), *(float *)(p + 0x24) - *(float *)(p + 0x14)); + if (FUN_001f9770(data + 0x248) == 0) return; + if (FUN_L14_002d9870_c(*(int *)(data + 0x264)) == 0) return; + if (call_4BF0(moby) == 0) return; + *(short *)(data + 0x248) = scale_game_frames(D_L14_001614F0); + FUN_L14_002b3330_c(moby); + ((unsigned char *)moby)[0x20] = 2; + set_moby_animation(moby, 1, 0); + path = (float *)D_L14_001B0BB0[*(int *)(data + 0x240)]; + *(float *)(moby + 0x48) = fast_arc_tan_c(path[8] - path[4], path[9] - path[5]); *(int *)(data + 0x268) = 0; - f = *(float *)(data + 0x268); *(float *)(data + 0x27C) = 1.0f; *(int *)(data + 0x26C) = 0; *(int *)(data + 0x270) = 0; *(int *)(data + 0x274) = 0; *(int *)(data + 0x24C) = 0; *(int *)(data + 0x250) = 0; - *(float *)(data + 0x254) = *(float *)(data + 0x258) = *(float *)(data + 0x25C) = f; + *(float *)(data + 0x25C) = *(float *)(data + 0x268); + *(float *)(data + 0x258) = *(float *)(data + 0x268); + *(float *)(data + 0x254) = *(float *)(data + 0x268); return; } - case 2: { - - if (compute_interpolated_record_value(moby) >= 3.0f) FUN_L14_002b3418(moby); - if (!((unsigned char)moby[0x70] & 2)) goto finish; - if (moby[0x52] != moby[0x53]) goto finish; - moby[0x20] = 3; - blend_moby_animation(moby, 3, 0, FUN_001f96f8(10)); - *(float *)(moby + 0x58) = 1.0f; + case 2: + if (compute_interpolated_record_value(moby) >= 3.0f) { + FUN_L14_002b3418_c(moby); + } + if ((moby[0x70] & 2) && ((unsigned char *)moby)[0x52] == ((unsigned char *)moby)[0x53]) { + ((unsigned char *)moby)[0x20] = 3; + blend_moby_animation(moby, 3, 0, scale_game_frames(10)); + *(float *)(moby + 0x58) = 1.0f; + } break; - } case 9: { - char *p; - p = (char *)D_L14_001B0BB0[*(int *)(data + 0x240)]; - FUN_L00_0025b8c0((float *)(moby + 0x10), (float *)(data + 0x254), *(float *)(p + 0x10), 0.01f, 0.2f, 0.0f); - FUN_L00_0025b8c0((float *)(moby + 0x14), (float *)(data + 0x258), *(float *)(p + 0x14), 0.01f, 0.2f, 0.0f); - if (!((unsigned char)moby[0x70] & 2)) goto finish; - if (moby[0x52] != moby[0x53]) goto finish; - blend_moby_animation(moby, 0, 0, FUN_001f96f8(10)); - moby[0x20] = 1; - *(float *)(moby + 0x58) = 1.0f; - FUN_L14_002b3318(moby); - return; + float *path = (float *)D_L14_001B0BB0[*(int *)(data + 0x240)]; + FUN_L00_0025b8c0((float *)(moby + 0x10), (float *)(data + 0x254), path[4], 0.01f, 0.2f, 0.0f); + FUN_L00_0025b8c0((float *)(moby + 0x14), (float *)(data + 0x258), path[5], 0.01f, 0.2f, 0.0f); + if ((moby[0x70] & 2) && ((unsigned char *)moby)[0x52] == ((unsigned char *)moby)[0x53]) { + blend_moby_animation(moby, 0, 0, scale_game_frames(10)); + ((unsigned char *)moby)[0x20] = 1; + *(float *)(moby + 0x58) = 1.0f; + FUN_L14_002b3318_c(moby); + return; + } + break; } case 13: { - float angle; + float ang; float k; - float f; - angle = fast_arc_tan(*(float *)(owner + 0x10) - *(float *)(moby + 0x10), *(float *)(owner + 0x14) - *(float *)(moby + 0x14)); + ang = fast_arc_tan_c(*(float *)(owner + 0x10) - *(float *)(moby + 0x10), + *(float *)(owner + 0x14) - *(float *)(moby + 0x14)); k = frame_time_sq * 12.566371f; - FUN_L00_0025be00((float *)(moby + 0x48), (float *)(data + 0x23C), angle, k, k, frame_time * 6.2831855f); - if (*(int *)(data + 0x114) == 2) goto finish; - if (FUN_001f9770((short *)(data + 0x248))) { - moby[0x20] = 3; - blend_moby_animation(moby, 3, 0, FUN_001f96f8(10)); - *(float *)(moby + 0x58) = 1.0f; - *(int *)(data + 0x250) = 0; - *(float *)(data + 0x27C) = 1.0f; - f = *(float *)(data + 0x250); - *(int *)(data + 0x24C) = 0; - *(float *)(data + 0x25C) = f; - *(float *)(data + 0x258) = f; - *(float *)(data + 0x254) = f; - } + call_CE58((float *)(moby + 0x48), ang, (float *)(data + 0x23C), k, k, frame_time * 6.2831855f); + if (*(int *)(data + 0x114) == 2) break; + if (FUN_001f9770(data + 0x248) == 0) break; + ((unsigned char *)moby)[0x20] = 3; + blend_moby_animation(moby, 3, 0, scale_game_frames(10)); + *(float *)(moby + 0x58) = 1.0f; + *(int *)(data + 0x250) = 0; + *(float *)(data + 0x27C) = 1.0f; + *(int *)(data + 0x24C) = 0; + *(float *)(data + 0x25C) = *(float *)(data + 0x250); + *(float *)(data + 0x258) = *(float *)(data + 0x250); + *(float *)(data + 0x254) = *(float *)(data + 0x250); break; } - case 3: { - - if (!FUN_L14_002b3418(moby)) goto finish; - blend_moby_animation(moby, 0, 0, FUN_001f96f8(10)); - moby[0x20] = 4; + case 3: + if (FUN_L14_002b3418_c(moby) != 0) { + blend_moby_animation(moby, 0, 0, scale_game_frames(10)); + ((unsigned char *)moby)[0x20] = 4; + } break; - } - case 8: { - - if (data[0x24A]) FUN_L14_002d9870(*(int *)(data + 0x264)); - if (!FUN_L14_002b3418(moby)) goto finish; - if (data[0x24A]) { - blend_moby_animation(moby, 2, 0, FUN_001f96f8(10)); - moby[0x20] = 9; - } else { - *(short *)(data + 0x248) = FUN_001f96f8(D_L14_001614F0); - moby[0x20] = 13; + case 8: + if (((unsigned char *)data)[0x24A] != 0) { + FUN_L14_002d9870_c(*(int *)(data + 0x264)); + } + if (FUN_L14_002b3418_c(moby) != 0) { + if (((unsigned char *)data)[0x24A] != 0) { + blend_moby_animation(moby, 2, 0, scale_game_frames(10)); + ((unsigned char *)moby)[0x20] = 9; + } else { + *(short *)(data + 0x248) = scale_game_frames(D_L14_001614F0); + ((unsigned char *)moby)[0x20] = 0xD; + } } break; - } case 4: { - int idx; - char *p; - float angle; - float difference; + float ang; float k; - float f; - FUN_L14_002b3578(moby); - angle = fast_arc_tan(*(float *)(owner + 0x10) - *(float *)(moby + 0x10), *(float *)(owner + 0x14) - *(float *)(moby + 0x14)); + float aim; + FUN_L14_002b3578_c(moby); + ang = fast_arc_tan_c(*(float *)(owner + 0x10) - *(float *)(moby + 0x10), + *(float *)(owner + 0x14) - *(float *)(moby + 0x14)); k = frame_time_sq * 12.566371f; - FUN_L00_0025be00((float *)(moby + 0x48), (float *)(data + 0x23C), angle, k, k, frame_time * 6.2831855f); - difference = FUN_L14_002b35d8(moby, 0, *(float *)(moby + 0x48)); - FUN_L14_002b37b0(moby, angle); + call_CE58((float *)(moby + 0x48), ang, (float *)(data + 0x23C), k, k, frame_time * 6.2831855f); + aim = FUN_L14_002b35d8_c(moby, 0, *(float *)(moby + 0x48)); + FUN_L14_002b37b0_c(moby, ang); if (*(int *)(data + 0x114) == 2) { - if (*(int *)(data + 0x240) != -1) { - moby[0x20] = 8; - if ((unsigned char)moby[0x53] != 3) blend_moby_animation(moby, 3, 0, FUN_001f96f8(20)); - idx = *(int *)(data + 0x24C) - 1; - *(int *)(data + 0x24C) = idx; - idx *= 16; - p = (char *)D_L14_001B0BB0[*(int *)(data + 0x240)]; - f = *(float *)(p + idx + 0x1C); - *(float *)(data + 0x254) = *(float *)(data + 0x258) = *(float *)(data + 0x25C) = 0.0f; - *(float *)(data + 0x27C) = -1.0f; - *(float *)(data + 0x250) = f; - FUN_L00_002e2040(moby); - goto finish; + if (*(int *)(data + 0x240) == -1) break; + ((unsigned char *)moby)[0x20] = 8; + if (((unsigned char *)moby)[0x53] != 3) { + blend_moby_animation(moby, 3, 0, scale_game_frames(0x14)); } - } else { - if (!FUN_001f9770((short *)(data + 0x260))) goto finish; - if (FUN_L14_002b3920((unsigned char)moby[0x21]) < 2) { - if (!FUN_L00_002e1f28(moby, 1, 0)) goto finish; - if (FUN_00213260(4)) goto finish; - if (!(fast_difference_between_rotations(*(float *)(moby + 0x48), angle) < 0.017453292f)) goto finish; - if (difference < 0.017453292f) { - if (FUN_L00_00261968(*(int *)(data + 0x244), moby + 0x10, owner + 0x10)) goto finish; - FUN_L14_002b3890((unsigned char)moby[0x21]); - *(float *)(data + 0x278) = angle; - moby[0x20] = 5; - blend_moby_animation(moby, 4, 0, FUN_001f96f8(5)); - *(short *)(data + 0x262) = FUN_001f96f8(D_L14_001614EC); - } + { + int n = *(int *)(data + 0x24C) - 1; + char *path; + *(int *)(data + 0x24C) = n; + path = (char *)D_L14_001B0BB0[*(int *)(data + 0x240)]; + *(float *)(data + 0x250) = *(float *)(path + (n << 4) + 0x1C); } + *(float *)(data + 0x27C) = -1.0f; + *(float *)(data + 0x254) = *(float *)(data + 0x258) = *(float *)(data + 0x25C) = 0.0f; + FUN_L00_002e2040(moby); + break; } + if (FUN_001f9770(data + 0x260) == 0) break; + if (FUN_L14_002b3920_c(((unsigned char *)moby)[0x21]) >= 2) break; + if (FUN_L00_002e1f28(moby, 1, 0) == 0) break; + if (random_integer_below(4) != 0) break; + if (!(fast_difference_between_rotations(*(float *)(moby + 0x48), ang) < 0.017453292f)) break; + if (!(aim < 0.017453292f)) break; + if (FUN_L00_00261968(*(int *)(data + 0x244), moby + 0x10, owner + 0x10) != 0) break; + FUN_L14_002b3890_c(((unsigned char *)moby)[0x21]); + *(float *)(data + 0x278) = ang; + ((unsigned char *)moby)[0x20] = 5; + blend_moby_animation(moby, 4, 0, scale_game_frames(5)); + *(short *)(data + 0x262) = scale_game_frames(D_L14_001614EC_gp); break; } case 5: { - float angle; - float f; - angle = fast_arc_tan(*(float *)(owner + 0x10) - *(float *)(moby + 0x10), *(float *)(owner + 0x14) - *(float *)(moby + 0x14)); - f = fast_subtract_rotations(angle, D_L14_001614E8); - FUN_L14_002b35d8(moby, 0, f); - FUN_L14_002b37b0(moby, angle); - if (!((unsigned char)moby[0x70] & 2)) goto finish; - if (moby[0x52] != moby[0x53]) goto finish; - blend_moby_animation(moby, 5, 0, FUN_001f96f8(10)); - moby[0x20] = 6; + float ang; + ang = fast_arc_tan_c(*(float *)(owner + 0x10) - *(float *)(moby + 0x10), + *(float *)(owner + 0x14) - *(float *)(moby + 0x14)); + FUN_L14_002b35d8_c(moby, 0, fast_subtract_rotations_c2(ang, D_L14_001614E8_gp)); + FUN_L14_002b37b0_c(moby, ang); + if ((moby[0x70] & 2) && ((unsigned char *)moby)[0x52] == ((unsigned char *)moby)[0x53]) { + blend_moby_animation(moby, 5, 0, scale_game_frames(10)); + ((unsigned char *)moby)[0x20] = 6; + } break; } case 6: { - float angle; - float f; - float duration; int flag; + float ang; + float progress; + float sweep; + float angle; flag = 0; - angle = fast_arc_tan(*(float *)(owner + 0x10) - *(float *)(moby + 0x10), *(float *)(owner + 0x14) - *(float *)(moby + 0x14)); - f = FUN_001fa6c0(*(short *)(data + 0x262)); - duration = FUN_001fa6c0(FUN_001f96f8(D_L14_001614EC)); - f = f / duration; - duration = fast_subtract_rotations(*(float *)(data + 0x278), -D_L14_001614E8 + (D_L14_001614E8 + D_L14_001614E8) * f); - if (data[0x24B] && (*(float *)(owner + 0x18) + 0.1f) - *(float *)(moby + 0x18) < 0.0f) flag = 1; - FUN_L14_002b35d8(moby, flag, duration); - FUN_L14_002b37b0(moby, angle); - build_moby_bone_transform((struct Moby *)moby, 0, mat); - direction_ptr = &direction; - qcopy(direction_ptr, &mat[1]); - if (!flag) direction.f[2] = 0.0f; - fast_vec_normalize(direction_ptr, direction_ptr, D_L14_001614E4); - start = &mat[3]; - FUN_001f9a10(&end, start, direction_ptr); - fast_vec_normalize(direction_ptr, direction_ptr, D_L14_001614F4); - FUN_001f9a10(start, start, &direction); + ang = fast_arc_tan_c(*(float *)(owner + 0x10) - *(float *)(moby + 0x10), + *(float *)(owner + 0x14) - *(float *)(moby + 0x14)); + progress = convert_integer_to_float(*(short *)(data + 0x262)); + progress = progress / convert_integer_to_float(scale_game_frames(D_L14_001614EC_gp)); + sweep = D_L14_001614E8_gp; + angle = fast_subtract_rotations_c2(*(float *)(data + 0x278), -sweep + (sweep + sweep) * progress); + if (((unsigned char *)data)[0x24B] != 0) { + if (*(float *)(owner + 0x18) + 0.1f - *(float *)(moby + 0x18) < 0.0f) { + flag = 1; + } + } + FUN_L14_002b35d8_c(moby, flag, angle); + FUN_L14_002b37b0_c(moby, ang); + build_moby_bone_transform_c(moby, 0, mat); + qcopy(direction, mat[1]); + if (flag == 0) { + direction[2] = 0.0f; + } + fast_vec_normalize(direction, direction, D_L14_001614E4_gp); + add_vector_xyz_c3(end, mat[3], direction); + fast_vec_normalize(direction, direction, D_L14_001614F4_gp); + add_vector_xyz_c3(mat[3], mat[3], direction); info.moby = moby; info.flags = 0x10001; info.count = 1; info.strength = 1.0f; - info.x = FUN_001f9dc8(*(float *)(moby + 0x48)); - info.y = FUN_001f9de0(*(float *)(moby + 0x48)); + info.x = fast_cos(*(float *)(moby + 0x48)); + info.y = fast_sin(*(float *)(moby + 0x48)); info.scale = 1.0f; - info.distance = 5627.9248046875f; + info.distance = 5627.9248f; info.enabled = 1; info.oclass = *(unsigned short *)(moby + 0xA6); info.mode = 0; - if (coll_line_fix(start, &end, 0, moby, &info)) qcopy(&end, &D_L14_00174560); - FUN_L00_002e2190(moby, mat, &end); - if (!FUN_001f9770((short *)(data + 0x262))) goto finish; - blend_moby_animation(moby, 6, 0, FUN_001f96f8(10)); - moby[0x20] = 7; - FUN_L00_002e2040(moby); - goto finish; - } - case 7: { - - if (!((unsigned char)moby[0x70] & 2)) goto finish; - if (moby[0x52] != moby[0x53]) goto finish; - blend_moby_animation(moby, 0, 0, FUN_001f96f8(10)); - moby[0x20] = 4; + if (coll_line_fix(mat[3], end, 0, moby, &info) != 0) { + qcopy(end, D_L14_00174560); + } + FUN_L00_002e2190(moby, mat, end); + if (FUN_001f9770(data + 0x262) != 0) { + blend_moby_animation(moby, 6, 0, scale_game_frames(10)); + ((unsigned char *)moby)[0x20] = 7; + FUN_L00_002e2040(moby); + } break; } - case 10: { - anim = (unsigned char)moby[0x52]; - if (!((unsigned char)moby[0x70] & 2)) goto anim_incomplete; - if ((unsigned char)anim != moby[0x53]) goto anim_incomplete; - if ((unsigned char)anim != 7) { - anim = moby[0x53]; - goto check_anim; + case 7: + if ((moby[0x70] & 2) && ((unsigned char *)moby)[0x52] == ((unsigned char *)moby)[0x53]) { + blend_moby_animation(moby, 0, 0, scale_game_frames(10)); + ((unsigned char *)moby)[0x20] = 4; } - blend_moby_animation(moby, 0, 0, 10); - moby[0x20] = 4; break; -anim_incomplete: - if ((unsigned char)anim == 7) goto finish; - anim = moby[0x53]; -check_anim: - if ((int)anim == 7) goto finish; -resume_move: + case 10: { + long n = ((unsigned char *)moby)[0x52]; + if ((moby[0x70] & 2) && (unsigned char)n == ((unsigned char *)moby)[0x53]) { + if ((unsigned char)n != 7) goto check_next; + goto idle; + } + if ((unsigned char)n == 7) break; + check_next: + if (((unsigned char *)moby)[0x53] == 7) break; + idle: blend_moby_animation(moby, 0, 0, 10); - moby[0x20] = 4; + ((unsigned char *)moby)[0x20] = 4; break; } case 11: { - - if (!(FUN_L00_0025c698(moby, data + 0x60) & 0x160)) return; + if ((FUN_L00_0025c698(moby, data + 0x60) & 0x160) == 0) return; FUN_L00_002e2040(moby); - moby_point_position((struct Moby *)moby, 2, mat); - FUN_L14_002dea98(moby, (char *)mat); - FUN_L00_0025e450(moby, data + 0x40, moby + 0x10, 0.0f, 0.0f, 5, 2, 4, 2.0f, 1.0f, 9.0f, 1.0f, -1, 15.0f, 1, 1, -1, 0); - if (D_001413F4[0] == 2) { + FUN_L00_0024f7c8(moby, 2, mat); + FUN_L14_002dea98_c(moby, (char *)mat); + call_F4A8(moby, data + 0x40, moby + 0x10, 0.0f, 0.0f, 5, 2, 4, 2.0f, 1.0f, 9.0f, 1.0f, -1, 15.0f, 1, 1, -1, 0); + if (((unsigned char *)D_001413F4)[0] == 2) { FUN_L00_00257470(moby, 0x200, -1); - } else { - FUN_L00_00257470(moby, 0, -1); + { call_D678(moby); return; } } - mark_moby_for_removal((struct Moby *)moby); - return; + FUN_L00_00257470(moby, 0, -1); + { call_D678(moby); return; } } case 12: { - float f; - moby_point_position((struct Moby *)moby, 2, mat); - FUN_L14_002dea98(moby, (char *)mat); - scale.f[0] = 0.0f; - FUN_L14_002e0170(moby, scale.f, 1); + FUN_L00_0024f7c8(moby, 2, mat); + FUN_L14_002dea98_c(moby, (char *)mat); + status = 0; + ((void (*)(char *, int *, int))FUN_L14_002e0170_c)(moby, &status, 1); FUN_L00_002e2040(moby); -remove: - mark_moby_for_removal((struct Moby *)moby); + call_D678(moby); return; } } -finish: - state = (unsigned char)moby[0x20]; - if (state - 4 > 3 && state != 1) { - FUN_L14_002b35d8(moby, 0, *(float *)(moby + 0x48)); - FUN_L14_002b37b0(moby, *(float *)(moby + 0x48)); + state = ((unsigned char *)moby)[0x20]; + if (!(state >= 4 && state <= 7) && state != 1) { + FUN_L14_002b35d8_c(moby, 0, *(float *)(moby + 0x48)); + FUN_L14_002b37b0_c(moby, *(float *)(moby + 0x48)); } - FUN_L14_002b2600((struct Moby *)moby); + FUN_L14_002b2600_c((struct Moby *)moby); } -#endif #include "rnc/math/vector.h" #include "rnc/gameplay/entities/moby.h" @@ -1025,14 +1053,14 @@ extern int FUN_L00_0025d808(void *, void *, void *, void *, int, float) __asm__( extern void subtract_vector_xyz_c(void *, void *, void *) __asm__("FUN_001f9a28"); extern float func_L00_0025CE58_2B4668(float *p, float a, float *v, float b, float c, float d) __asm__("FUN_L00_0025be00"); -extern short D_L14_001614D8 __attribute__((sda)); +extern float D_L14_001614D8 __attribute__((sda)); int FUN_L14_002b3418(char *moby) { float a[4]; float b[4]; float c[4]; char *data = *(char **)(moby + 0x78); int reached = FUN_L00_0025d808(D_L14_001B0BB0[*(int *)(data + 0x240)], a, data + 0x24C, data + 0x250, 0, - *(float *)&D_L14_001614D8 * frame_time * *(float *)(data + 0x27C)); + D_L14_001614D8 * frame_time * *(float *)(data + 0x27C)); float ang; float k; float m; @@ -1209,7 +1237,6 @@ void FUN_L14_002b3a20(char *m) { extern u8 *D_L14_00167500 NOT_SDA; extern s32 FUN_001f96f8_c(s32) __asm__("FUN_001f96f8"); extern s32 FUN_001f9740(void *); -extern void set_moby_animation_c(void *, s32, s32) __asm__("FUN_00212ed8"); void FUN_L14_002d96e0(struct Moby *moby) { char *data = (char *)moby->pvars; @@ -1228,18 +1255,18 @@ void FUN_L14_002d96e0(struct Moby *moby) { case 1: if (FUN_001f9740(data + 8) != 0) { moby->state = 2; - set_moby_animation_c(moby, 1, 0); + set_moby_animation(moby, 1, 0); } break; case 2: if ((moby->anim_flags & 2) != 0) { moby->state = 3; - set_moby_animation_c(moby, 2, 0); + set_moby_animation(moby, 2, 0); } break; case 3: if (*(s16 *)(D_L14_00167500 + 0x86) != 0x14) { - set_moby_animation_c(moby, 0, 0); + set_moby_animation(moby, 0, 0); moby->state = 4; } break; @@ -1248,19 +1275,19 @@ void FUN_L14_002d96e0(struct Moby *moby) { case 5: if ((moby->anim_flags & 2) != 0) { moby->state = 6; - set_moby_animation_c(moby, 2, 0); + set_moby_animation(moby, 2, 0); } break; case 6: if (FUN_001f9740(data + 8) != 0) { - set_moby_animation_c(moby, 3, 0); + set_moby_animation(moby, 3, 0); moby->state = 7; } break; case 7: if ((moby->anim_flags & 2) != 0) { moby->state = 0; - set_moby_animation_c(moby, 0, 0); + set_moby_animation(moby, 0, 0); } break; } @@ -1285,7 +1312,7 @@ typedef struct { int f90; } Obj; -void set_moby_animation(struct Obj *o, s32 sel, s32 idx) __asm__("FUN_00212ed8"); +extern void set_moby_animation(void *, int, int) __asm__("FUN_00212ed8"); int FUN_L14_002d9870(int i) { unsigned char *moby = (unsigned char *)(D_L14_ffd0_e_macro[2] + i * 256); @@ -1402,10 +1429,10 @@ extern void cross_vectors_xyz(void *, void *, void *) __asm__("func_001F9AD8"); extern void normalize_vector_xyz(void *out, void *a, f32 len) __asm__("FUN_001f9bf8"); extern void subtract_vector_xyz(void *out, void *a, void *b) __asm__("FUN_001f9a28"); -extern short D_L14_00161B08 __attribute__((sda)); -extern short D_L14_00161B0C __attribute__((sda)); -extern short D_L14_00161B10 __attribute__((sda)); -extern short D_L14_00161B14 __attribute__((sda)); +extern float D_L14_00161B08 __attribute__((sda)); +extern float D_L14_00161B0C __attribute__((sda)); +extern float D_L14_00161B10 __attribute__((sda)); +extern float D_L14_00161B14 __attribute__((sda)); unsigned char *FUN_L14_002dea98(char *owner, char *pos) { unsigned char *m = func_0020D348_m(0x145); char *d; @@ -1425,12 +1452,12 @@ unsigned char *FUN_L14_002dea98(char *owner, char *pos) { g = g + 0x210; vec[2] = 0.0f; normalize_vector_xyz(vec, vec, - random_float_between_alt(*(float *)&D_L14_00161B08 * frame_scale, - *(float *)&D_L14_00161B0C * frame_scale)); + random_float_between_alt(D_L14_00161B08 * frame_scale, + D_L14_00161B0C * frame_scale)); cross_vectors_xyz(vec + 4, g, vec); build_look_at_matrix(d, vec, g, FUN_L00_00257c48(0.34906584f, 1.0471976f)); - *(float *)(d + 8) = random_float_between_alt(*(float *)&D_L14_00161B10 * frame_scale, - *(float *)&D_L14_00161B14 * frame_scale); + *(float *)(d + 8) = random_float_between_alt(D_L14_00161B10 * frame_scale, + D_L14_00161B14 * frame_scale); *(float *)(d + 0x10) = FUN_L00_00257c48(0.0f, 0.008726646f); *(float *)(d + 0x14) = FUN_L00_00257c48(0.05235988f, 0.13962634f); *(float *)(d + 0x18) = FUN_L00_00257c48(0.0f, DEG_TO_RAD); @@ -1553,10 +1580,10 @@ extern void create_effect_2e0170(void *, void *, void *, void *, void *, int, fl extern float D_0015ED60; extern char *race_paths_2e0170 __asm__("D_L14_0015F70C"); -extern short D_L14_00161B30 __attribute__((sda)); -extern short D_L14_00161B34 __attribute__((sda)); -extern short D_L14_00161B38 __attribute__((sda)); -extern short D_L14_00161B3C __attribute__((sda)); +extern float D_L14_00161B30 __attribute__((sda)); +extern float D_L14_00161B34 __attribute__((sda)); +extern float D_L14_00161B38 __attribute__((sda)); +extern float D_L14_00161B3C __attribute__((sda)); unsigned char *FUN_L14_002e0170(char *owner, float *scale, int mode) { unsigned char *m = spawn_moby_2e0170(0x193); unsigned char *pos; @@ -1590,13 +1617,13 @@ unsigned char *FUN_L14_002e0170(char *owner, float *scale, int mode) { subtract_vector_2e0170(vec, pos, &hero.motion.pos); vec[2] = 0.0f; normalize_vector_2e0170(vec, vec, - random_scaled_2e0170(*(float *)&D_L14_00161B30 * D_0015ED60, - *(float *)&D_L14_00161B34 * D_0015ED60)); + random_scaled_2e0170(D_L14_00161B30 * D_0015ED60, + D_L14_00161B34 * D_0015ED60)); cross_vectors_2e0170(vec + 4, &hero.gravity_dir, vec); angle = random_angle_2e0170(0.5759586691856384f, 1.3962633609771729f); build_look_at_2e0170(d + 0x30, vec, &hero.gravity_dir, angle); - *(float *)(d + 0x38) = random_scaled_2e0170(*(float *)&D_L14_00161B38 * D_0015ED60, - *(float *)&D_L14_00161B3C * D_0015ED60); + *(float *)(d + 0x38) = random_scaled_2e0170(D_L14_00161B38 * D_0015ED60, + D_L14_00161B3C * D_0015ED60); *(float *)(d + 0x20) = random_angle_2e0170(0.0f, 0.008726646f); *(float *)(d + 0x24) = random_angle_2e0170(0.05235988f, 0.13962634f); *(float *)(d + 0x28) = random_angle_2e0170(0.0f, 0.017453293f); diff --git a/src/overlays/shared/gameplay/entities/rock.c b/src/overlays/shared/gameplay/entities/rock.c index 75cf8d143b..ece6302503 100644 --- a/src/overlays/shared/gameplay/entities/rock.c +++ b/src/overlays/shared/gameplay/entities/rock.c @@ -759,13 +759,13 @@ typedef struct { extern G_q D_L01_0016CCE0_q __asm__("D_L01_0016CCE0"); extern int cutscene_mode __asm__("D_L01_0015F5C4"); -extern unsigned char D_0015EDB0_s __asm__("D_0015EDB0"); +#include "rnc/gameplay/state/options.h" extern unsigned char D_L01_0017C8C0_q[] __asm__("D_L01_0017C8C0") __attribute__((section(".data"))); extern void attach_manipulator_q(void *arg0, s32 arg1, void *arg2) __asm__("FUN_0020cb10"); -extern short D_L01_00161D30 __attribute__((sda)); +extern float D_L01_00161D30 __attribute__((sda)); void FUN_L01_002ff028(char *a) { - if (cutscene_mode == 2 && D_0015EDB0_s != 0) { + if (cutscene_mode == 2 && big_head_cheat_enabled != 0) { int i; for (i = 0; i < D_L01_0016CCE0_q.n; i++) { char *moby = D_L01_0016CCE0_q.m[i]; @@ -774,9 +774,9 @@ void FUN_L01_002ff028(char *a) { unsigned char *q = D_L01_0017C8C0_q; if (q[1] == 0) { attach_manipulator_q(moby, 0, q); - *(float *)(q + 0x20) = *(float *)&D_L01_00161D30; - *(float *)(q + 0x24) = *(float *)&D_L01_00161D30; - *(float *)(q + 0x28) = *(float *)&D_L01_00161D30; + *(float *)(q + 0x20) = D_L01_00161D30; + *(float *)(q + 0x24) = D_L01_00161D30; + *(float *)(q + 0x28) = D_L01_00161D30; } } } @@ -1591,15 +1591,15 @@ extern void random_vector(float *, float, float) __asm__("FUN_L00_00257d78"); extern void FUN_L00_002730e0(void *, void *, int, int, int, int, float); extern void scale_vector_xyz(void *out, void *a, f32 s) __asm__("FUN_001f9a68"); -extern short D_L01_00161F54 __attribute__((sda)); -extern short D_L01_00161F58 __attribute__((sda)); -extern short D_L01_00161F5C __attribute__((sda)); -extern short D_L01_00161F60 __attribute__((sda)); +extern float D_L01_00161F54 __attribute__((sda)); +extern float D_L01_00161F58 __attribute__((sda)); +extern float D_L01_00161F5C __attribute__((sda)); +extern float D_L01_00161F60 __attribute__((sda)); extern short D_L01_00161F64 __attribute__((sda)); -extern short D_L01_00161F68 __attribute__((sda)); -extern short D_L01_00161F6C __attribute__((sda)); -extern short D_L01_00161F70 __attribute__((sda)); -extern short D_L01_00161F74 __attribute__((sda)); +extern int D_L01_00161F68 __attribute__((sda)); +extern int D_L01_00161F6C __attribute__((sda)); +extern float D_L01_00161F70 __attribute__((sda)); +extern float D_L01_00161F74 __attribute__((sda)); void FUN_L01_003089f0(char *m) { float v[4]; float w[4]; @@ -1614,17 +1614,17 @@ void FUN_L01_003089f0(char *m) { moby_point_position(m, 0, v); } t = frame_time; - random_vector(w, *(float *)&D_L01_00161F54 * t, *(float *)&D_L01_00161F58 * t); + random_vector(w, D_L01_00161F54 * t, D_L01_00161F58 * t); c = *(unsigned char *)&D_L01_00161F64; - FUN_L00_002730e0(v, w, *(int *)&D_L01_00161F68, c, random_integer_below_c(0xFF) & 0xFF, 0, - *(float *)&D_L01_00161F70); + FUN_L00_002730e0(v, w, D_L01_00161F68, c, random_integer_below_c(0xFF) & 0xFF, 0, + D_L01_00161F70); for (i = 2; i >= 0; i--) { t = frame_time; - random_vector(u, *(float *)&D_L01_00161F5C * t, *(float *)&D_L01_00161F60 * t); + random_vector(u, D_L01_00161F5C * t, D_L01_00161F60 * t); add_vector_xyz(w, w, u); c2 = *(unsigned char *)&D_L01_00161F64; - FUN_L00_002730e0(v, w, *(int *)&D_L01_00161F6C, c2, random_integer_below_c(0xFF) & 0xFF, - 0, *(float *)&D_L01_00161F74); + FUN_L00_002730e0(v, w, D_L01_00161F6C, c2, random_integer_below_c(0xFF) & 0xFF, + 0, D_L01_00161F74); } } /* Ported from rac1-decomp (src/overlays/shared/vendor_002F7700.c: func_L01_00309F00), where it is exact; names translated to the US level program. */ @@ -1682,9 +1682,9 @@ extern void FUN_L01_0027a248(int, int); extern int enqueue_callback_list_1(void (*)(char *), char *) __asm__("FUN_001f4600"); extern char *create_moby(int) __asm__("FUN_0020c4f8"); -extern short D_L01_00161F88 __attribute__((sda)); -extern short D_L01_00161F8C __attribute__((sda)); -extern short D_L01_00161F90 __attribute__((sda)); +extern float D_L01_00161F88 __attribute__((sda)); +extern float D_L01_00161F8C __attribute__((sda)); +extern float D_L01_00161F90 __attribute__((sda)); void FUN_L01_00308bd8(struct Moby *moby) { char *data = (char *)moby->pvars; int active = 0; @@ -1774,14 +1774,14 @@ void FUN_L01_00308bd8(struct Moby *moby) { case 7: if (*(float *)(data + 0x20) < 1.0f) { advance_accelerated_scalar((float *)(data + 0x20), (float *)(data + 0x28), 1.0f, - *(float *)&D_L01_00161F88 * frame_time_sq, - *(float *)&D_L01_00161F8C * frame_time_sq, - *(float *)&D_L01_00161F90 * frame_time); + D_L01_00161F88 * frame_time_sq, + D_L01_00161F8C * frame_time_sq, + D_L01_00161F90 * frame_time); } else if (*(float *)(data + 0x24) < 1.0f) { advance_accelerated_scalar((float *)(data + 0x24), (float *)(data + 0x2C), 1.0f, - *(float *)&D_L01_00161F88 * frame_time_sq, - *(float *)&D_L01_00161F8C * frame_time_sq, - *(float *)&D_L01_00161F90 * frame_time); + D_L01_00161F88 * frame_time_sq, + D_L01_00161F8C * frame_time_sq, + D_L01_00161F90 * frame_time); } else { allocate_voice_for_target_entry(1, 0, (void *)moby); moby->state = 8; @@ -1793,14 +1793,14 @@ void FUN_L01_00308bd8(struct Moby *moby) { int r = FUN_L00_00233f38(); if (*(float *)(data + 0x20) < 1.0f) { advance_accelerated_scalar((float *)(data + 0x20), (float *)(data + 0x28), 1.0f, - *(float *)&D_L01_00161F88 * frame_time_sq, - *(float *)&D_L01_00161F8C * frame_time_sq, - *(float *)&D_L01_00161F90 * frame_time); + D_L01_00161F88 * frame_time_sq, + D_L01_00161F8C * frame_time_sq, + D_L01_00161F90 * frame_time); } else if (*(float *)(data + 0x24) < 1.0f) { advance_accelerated_scalar((float *)(data + 0x24), (float *)(data + 0x2C), 1.0f, - *(float *)&D_L01_00161F88 * frame_time_sq, - *(float *)&D_L01_00161F8C * frame_time_sq, - *(float *)&D_L01_00161F90 * frame_time); + D_L01_00161F88 * frame_time_sq, + D_L01_00161F8C * frame_time_sq, + D_L01_00161F90 * frame_time); } else if (D_L01_0015F594 != 4 || !(*(float *)(data + 0x20) > 0.25f)) { if (r == 2) { *(float *)(data + 0x34) = 1.95f; @@ -1850,14 +1850,14 @@ void FUN_L01_00308bd8(struct Moby *moby) { approach_value((float *)(data + 0x34), 1.95f, frame_time * 4.0f); } else if (0.0f < *(float *)(data + 0x24)) { advance_accelerated_scalar((float *)(data + 0x24), (float *)(data + 0x28), 0.0f, - *(float *)&D_L01_00161F88 * frame_time_sq, - *(float *)&D_L01_00161F8C * frame_time_sq, - *(float *)&D_L01_00161F90 * frame_time); + D_L01_00161F88 * frame_time_sq, + D_L01_00161F8C * frame_time_sq, + D_L01_00161F90 * frame_time); } else if (0.0f < *(float *)(data + 0x20)) { advance_accelerated_scalar((float *)(data + 0x20), (float *)(data + 0x2C), 0.0f, - *(float *)&D_L01_00161F88 * frame_time_sq, - *(float *)&D_L01_00161F8C * frame_time_sq, - *(float *)&D_L01_00161F90 * frame_time); + D_L01_00161F88 * frame_time_sq, + D_L01_00161F8C * frame_time_sq, + D_L01_00161F90 * frame_time); } else { moby->state = 1; } @@ -1873,8 +1873,8 @@ void FUN_L01_00308bd8(struct Moby *moby) { extern void euler_rotation_basis(void *, void *) __asm__("FUN_001fa030"); extern void FUN_L00_00250df8(void *); -extern short D_L01_00161F78 __attribute__((sda)); -extern short D_L01_00161F80 __attribute__((sda)); +extern float D_L01_00161F78 __attribute__((sda)); +extern float D_L01_00161F80 __attribute__((sda)); void FUN_L01_003092d0(char *m) { char *d = *(char **)(m + 0x78); char **p = (char **)(d + 0x14); @@ -1885,8 +1885,8 @@ void FUN_L01_003092d0(char *m) { float u; char *o = *p; qcopy(o + 0x10, m + 0x10); - u = *(float *)&D_L01_00161F80 * DEG_TO_RAD; - *(float *)(o + 0x18) += *(float *)&D_L01_00161F78; + u = D_L01_00161F80 * DEG_TO_RAD; + *(float *)(o + 0x18) += D_L01_00161F78; *(float *)(*p + 0x44) = u; t = *(float *)(d + 0x20) * 2.4f - 1.2f; euler_rotation_basis(*p + 0xC0, *p + 0x40); diff --git a/src/overlays/shared/gameplay/entities/sandmouse.c b/src/overlays/shared/gameplay/entities/sandmouse.c index d96cee4dc9..ed2429a1a0 100644 --- a/src/overlays/shared/gameplay/entities/sandmouse.c +++ b/src/overlays/shared/gameplay/entities/sandmouse.c @@ -729,7 +729,7 @@ void FUN_L01_0030ded0(char *moby) { INCLUDE_ASM("config/us/overlays/asm/FUN_L01_0030df40.s", FUN_L01_0030df40); #else extern u8 D_0013D4C5; -extern u8 D_0015EDB0; +#include "rnc/gameplay/state/options.h" extern char D_0013E550[]; extern char D_L01_001BB6B0[]; extern s32 D_0014C190[][64]; @@ -796,7 +796,7 @@ void FUN_L01_0030df40(struct Moby *m) { ((struct Moby *)(D_L01_0015FFD8_b618 + HOVER_I(0x48) * 0x100))->collision = 0; } if (m->state >= 3) { - if (D_0015EDB0 != 0) { + if (big_head_cheat_enabled != 0) { if (*(u8 *)(p + 0x91) == 0) attach_manipulator(m, 5, p + 0x90); HOVER_F(0xb8) = HOVER_F(0xb4) = HOVER_F(0xb0) = 2.1f; } else if (*(u8 *)(p + 0x91) != 0) detach_manipulator(m, p + 0x90); @@ -1354,7 +1354,6 @@ extern void normalize_vector_xyz(void *, void *, f32) __asm__("FUN_001f9bf8"); extern void scale_vector_xyz(void *, void *, float) __asm__("FUN_001f9a68"); extern void subtract_vector_xyz(void *, void *, void *) __asm__("FUN_001f9a28"); float absolute_float(float input) __asm__("func_001F99C0"); -extern char D_0013F350[]; extern int func_001FA898_r(float) __asm__("FUN_001fa6d0"); extern int D_0015EE84_c __asm__("D_0015ED84") __attribute__((section(".sdata"))); extern Path_316730 *D_L01_001B0C30_316730[] __asm__("D_L01_001B0930"); @@ -1386,14 +1385,14 @@ void FUN_L01_00315358(Cam_316730 *cam) { Path_316730 *path; float dist; - segment = ((Hero *)(((char *)&D_0013F350)))->unk564; - fraction = ((Hero *)(((char *)&D_0013F350)))->unk568; + segment = ((Hero *)(((char *)((char *)&hero))))->unk564; + fraction = ((Hero *)(((char *)((char *)&hero))))->unk568; progress->t = fraction; progress->idx = segment; FUN_L00_0025d808(D_L01_001B0C30_316730[path_index], camera_goal, &progress->idx, &progress->t, 1.0f, 0); qcopy(follow->pos, camera_goal); path = D_L01_001B0C30_316730[path_index]; - dist = path->nodes[segment].w * (fraction / ((Path_316730 *)((Hero *)(((char *)&D_0013F350)))->unk560)->nodes[segment].w); + dist = path->nodes[segment].w * (fraction / ((Path_316730 *)((Hero *)(((char *)((char *)&hero))))->unk560)->nodes[segment].w); subtract_vector_xyz(delta, &path->nodes[segment + 1], &path->nodes[segment]); normalize_vector_xyz(look_target, delta, dist); add_vector_xyz(rail_point, &path->nodes[segment], look_target); @@ -1425,11 +1424,11 @@ void FUN_L01_00315358(Cam_316730 *cam) { range_start = func_001FA898_r(pathB->nodes[prev].w); range_end = func_001FA898_r(pathB->nodes[i].w); if (range_end < range_start) { - if (((Hero *)(((char *)&D_0013F350)))->unk564 >= range_start || ((Hero *)(((char *)&D_0013F350)))->unk564 < range_end) { + if (((Hero *)(((char *)((char *)&hero))))->unk564 >= range_start || ((Hero *)(((char *)((char *)&hero))))->unk564 < range_end) { break; } } else { - if (((Hero *)(((char *)&D_0013F350)))->unk564 >= range_start && ((Hero *)(((char *)&D_0013F350)))->unk564 < range_end) { + if (((Hero *)(((char *)((char *)&hero))))->unk564 >= range_start && ((Hero *)(((char *)((char *)&hero))))->unk564 < range_end) { break; } } @@ -1444,14 +1443,14 @@ void FUN_L01_00315358(Cam_316730 *cam) { lead = pathB->nodes[j].x; } base = func_001FA898_r(pathB->nodes[j].w); - count = ((Hero *)(((char *)&D_0013F350)))->unk564 - base; + count = ((Hero *)(((char *)((char *)&hero))))->unk564 - base; if (count < 0) { count += pathD->n; } for (i = 0; i < count; i++) { sum += pathD->nodes[(base + i) % pathD->n].w; } - sum += ((Hero *)(((char *)&D_0013F350)))->unk568; + sum += ((Hero *)(((char *)((char *)&hero))))->unk568; dist = camera_length * (sum / hero_length); node = func_001FA898_r(pathC->nodes[j].w); node_fraction = 0.0f; @@ -1479,7 +1478,7 @@ void FUN_L01_00315358(Cam_316730 *cam) { if (params->f24 < 0) { float lead_offset; - FUN_L00_0025df68(path, ((Hero *)(((char *)&D_0013F350)))->motion.pos.f, path_point, &segment, &fraction, 0, 20.0f, 1.0f, 0.0f); + FUN_L00_0025df68(path, ((Hero *)(((char *)((char *)&hero))))->motion.pos.f, path_point, &segment, &fraction, 0, 20.0f, 1.0f, 0.0f); if (params->f36 == 1) { lead_offset = -(params->f38 * 4.0f); } else { @@ -1491,9 +1490,9 @@ void FUN_L01_00315358(Cam_316730 *cam) { int hero_segment; float hero_fraction; - hero_segment = ((Hero *)(((char *)&D_0013F350)))->unk564; - hero_fraction = ((Hero *)(((char *)&D_0013F350)))->unk568; - FUN_L00_0025d808((Path_316730 *)((Hero *)(((char *)&D_0013F350)))->unk560, path_point, &hero_segment, &hero_fraction, params->f38, 1); + hero_segment = ((Hero *)(((char *)((char *)&hero))))->unk564; + hero_fraction = ((Hero *)(((char *)((char *)&hero))))->unk568; + FUN_L00_0025d808((Path_316730 *)((Hero *)(((char *)((char *)&hero))))->unk560, path_point, &hero_segment, &hero_fraction, params->f38, 1); FUN_L00_0025df68(path, path_point, camera_goal, &segment, &fraction, 0, 20.0f, 1.0f, 0.0f); } cam->pos[0] = cam_interp_values(cam->pos[0], camera_goal[0], &data->vel[0], rate, 0.175f, 0.0f); @@ -1503,21 +1502,21 @@ void FUN_L01_00315358(Cam_316730 *cam) { if (params->f24 < 0) { Path_316730 *path = D_L01_001B0C30_316730[params->f20]; - FUN_L00_0025df68(path, ((Hero *)(((char *)&D_0013F350)))->motion.pos.f, look_target, &segment, &fraction, 0, 20.0f, 1.0f, 0.0f); + FUN_L00_0025df68(path, ((Hero *)(((char *)((char *)&hero))))->motion.pos.f, look_target, &segment, &fraction, 0, 20.0f, 1.0f, 0.0f); if (D_0015EE84_c == 0xE && params->f30 == 0) { FUN_L00_0025d808(path, delta, &segment, &fraction, lead, 0); } else { FUN_L00_0025d808(path, delta, &segment, &fraction, lead, 1); } subtract_vector_xyz(delta, delta, look_target); - add_vector_xyz(look_target, ((Hero *)(((char *)&D_0013F350)))->motion.pos.f, delta); + add_vector_xyz(look_target, ((Hero *)(((char *)((char *)&hero))))->motion.pos.f, delta); } else { int hero_segment; float hero_fraction; - hero_segment = ((Hero *)(((char *)&D_0013F350)))->unk564; - hero_fraction = ((Hero *)(((char *)&D_0013F350)))->unk568; - FUN_L00_0025d808((Path_316730 *)((Hero *)(((char *)&D_0013F350)))->unk560, look_target, &hero_segment, &hero_fraction, lead, 1); + hero_segment = ((Hero *)(((char *)((char *)&hero))))->unk564; + hero_fraction = ((Hero *)(((char *)((char *)&hero))))->unk568; + FUN_L00_0025d808((Path_316730 *)((Hero *)(((char *)((char *)&hero))))->unk560, look_target, &hero_segment, &hero_fraction, lead, 1); } normalize_vector_xyz(look_offset, D_L01_001672B0, follow->f4C); add_vector_xyz(path_point, look_offset, look_target); diff --git a/src/overlays/shared/gameplay/entities/sentrybot.c b/src/overlays/shared/gameplay/entities/sentrybot.c index 568e7c5ed7..7040cf0b37 100644 --- a/src/overlays/shared/gameplay/entities/sentrybot.c +++ b/src/overlays/shared/gameplay/entities/sentrybot.c @@ -63,9 +63,9 @@ extern int random_integer_below(int); extern int scale_game_frames(int); extern int tick_countdown_32(void *); extern int truncate_float_to_s32() __asm__("FUN_001fa6d0"); -extern short D_L15_001613E8 __attribute__((sda)); -extern short D_L15_00161410 __attribute__((sda)); -extern short D_L15_00161414 __attribute__((sda)); +extern int D_L15_001613E8 __attribute__((sda)); +extern float D_L15_00161410 __attribute__((sda)); +extern int D_L15_00161414 __attribute__((sda)); extern void moby_point_position(void *, int, void *) __asm__("FUN_L00_0024f7c8"); extern void FUN_L00_0024f8f0(void *, int, void *, void *); extern void FUN_L00_00257470(void *, int, int); @@ -108,7 +108,7 @@ void FUN_L15_002979d8(unsigned char *moby) { int color; float s; - if (*(int *)&D_L15_00161414 != 0) + if (D_L15_00161414 != 0) return; data = *(unsigned char **)(moby + 0x78); if (D_L15_0015F5C4 == 2) { @@ -620,9 +620,9 @@ void FUN_L15_002979d8(unsigned char *moby) { j2 = 2; FUN_L00_0024f8f0(moby, 1, &j2, mat); transform_scaled_vertex_batch((char *)moby, 1, &j2, (char *)pos); - normalize_vector_xyz(va, mat[1], *(float *)&D_L15_00161410 * frame_time); + normalize_vector_xyz(va, mat[1], D_L15_00161410 * frame_time); subtract_vector_xyz(vb, data + 0x100, pos); - normalize_vector_xyz(vb, vb, *(float *)&D_L15_00161410 * frame_time); + normalize_vector_xyz(vb, vb, D_L15_00161410 * frame_time); if (fast_difference_between_rotations(FUN_001f9e90(va[0], va[1]), FUN_001f9e90(vb[0], vb[1])) > 0.7853982f || fast_difference_between_rotations(FUN_001f9e90(vector_length_xy(va), va[2]), @@ -678,9 +678,9 @@ void FUN_L15_002979d8(unsigned char *moby) { j3 = 3; FUN_L00_0024f8f0(moby, 1, &j3, mat); transform_scaled_vertex_batch((char *)moby, 1, &j3, (char *)pos); - normalize_vector_xyz(va, mat[1], -(*(float *)&D_L15_00161410 * frame_time)); + normalize_vector_xyz(va, mat[1], -(D_L15_00161410 * frame_time)); subtract_vector_xyz(vb, data + 0x100, pos); - normalize_vector_xyz(vb, vb, *(float *)&D_L15_00161410 * frame_time); + normalize_vector_xyz(vb, vb, D_L15_00161410 * frame_time); if (fast_difference_between_rotations(FUN_001f9e90(va[0], va[1]), FUN_001f9e90(vb[0], vb[1])) > 0.7853982f || fast_difference_between_rotations(FUN_001f9e90(vector_length_xy(va), va[2]), @@ -853,8 +853,8 @@ void FUN_L15_002979d8(unsigned char *moby) { lvl = *(short *)(data + 0x158) != 0; } tick = D_L15_0015F5CC; - if (tick != *(int *)&D_L15_001613E8 || hero.unk22E0 < lvl) { - *(int *)&D_L15_001613E8 = tick; + if (tick != D_L15_001613E8 || hero.unk22E0 < lvl) { + D_L15_001613E8 = tick; hero.unk22E0 = lvl; } alpha = 0x80; @@ -1257,7 +1257,7 @@ extern float D_L15_00161408 __attribute__((sda)); extern float D_L15_0016140C __attribute__((sda)); extern char D_001413F4[]; extern short D_0013F658[]; -extern int D_001413D0 NOT_SDA; +extern s32 D_001413D0_lui[] __asm__("D_001413D0") NOT_SDA; extern char D_0013F420[]; extern char *FUN_L00_0025a420(void *, int, int); extern float random_float_between(float, float) __asm__("FUN_002132a8"); @@ -1458,7 +1458,7 @@ void FUN_L15_0029a570(void *object, int flag) { *(short *)(data + 0x158) = 0; } if (*(int *)(data + 0x110) == 0) - *(int *)(data + 0x110) = D_001413D0; + *(int *)(data + 0x110) = (*(int *)&D_001413D0_lui); } #define NOT_SDA @@ -1538,21 +1538,21 @@ extern float D_0015ED6C; extern float multiply_global_factor_ed64(float) __asm__("FUN_001f96b0"); extern float random_float_between_alt(float, float) __asm__("FUN_002132a8"); extern s32 truncate_float_to_s32_u(f32) __asm__("FUN_001fa6d0"); -extern short D_L15_00161418 __attribute__((sda)); -extern short D_L15_00161428 __attribute__((sda)); -extern short D_L15_00161438 __attribute__((sda)); -extern short D_L15_00161448 __attribute__((sda)); -extern short D_L15_0016141C __attribute__((sda)); -extern short D_L15_00161420 __attribute__((sda)); -extern short D_L15_00161424 __attribute__((sda)); -extern short D_L15_0016142C __attribute__((sda)); -extern short D_L15_00161430 __attribute__((sda)); -extern short D_L15_00161434 __attribute__((sda)); -extern short D_L15_0016143C __attribute__((sda)); -extern short D_L15_00161440 __attribute__((sda)); -extern short D_L15_00161444 __attribute__((sda)); -extern short D_L15_0016144C __attribute__((sda)); -extern short D_L15_00161454 __attribute__((sda)); +extern int D_L15_00161418 __attribute__((sda)); +extern float D_L15_00161428 __attribute__((sda)); +extern float D_L15_00161438 __attribute__((sda)); +extern float D_L15_00161448 __attribute__((sda)); +extern int D_L15_0016141C __attribute__((sda)); +extern float D_L15_00161420 __attribute__((sda)); +extern float D_L15_00161424 __attribute__((sda)); +extern float D_L15_0016142C __attribute__((sda)); +extern float D_L15_00161430 __attribute__((sda)); +extern float D_L15_00161434 __attribute__((sda)); +extern float D_L15_0016143C __attribute__((sda)); +extern float D_L15_00161440 __attribute__((sda)); +extern float D_L15_00161444 __attribute__((sda)); +extern float D_L15_0016144C __attribute__((sda)); +extern int D_L15_00161454 __attribute__((sda)); extern void random_vector(float *, float, float) __asm__("FUN_L00_00257d78"); extern void add_vector_xyz(void *, void *, void *) __asm__("FUN_001f9a10"); extern void scale_vector_xyz(void *out, void *a, f32 s) __asm__("FUN_001f9a68"); @@ -1565,42 +1565,42 @@ void FUN_L15_0029ae18(char *moby) { char *data = *(char **)(moby + 0x78); float s; int a, b, c; - s = *(float *)&D_L15_00161440; + s = D_L15_00161440; s *= D_0015ED6C; - scale_vector_xyz(spark_a, data, *(float *)&D_L15_00161448); + scale_vector_xyz(spark_a, data, D_L15_00161448); random_vector(noise, s, s); add_vector_xyz(spark_a, spark_a, noise); - s = *(float *)&D_L15_00161444; + s = D_L15_00161444; s *= D_0015ED6C; - scale_vector_xyz(spark_b, data, *(float *)&D_L15_0016144C); + scale_vector_xyz(spark_b, data, D_L15_0016144C); random_vector(noise, s, s); add_vector_xyz(spark_b, spark_b, noise); - spark_a[3] = *(float *)&D_L15_00161420; - spark_b[3] = *(float *)&D_L15_00161424; + spark_a[3] = D_L15_00161420; + spark_b[3] = D_L15_00161424; a = func_001FA898_r(multiply_global_factor_ed64( - random_float_between_alt(*(float *)&D_L15_00161428, *(float *)&D_L15_0016142C))); + random_float_between_alt(D_L15_00161428, D_L15_0016142C))); b = func_001FA898_r(multiply_global_factor_ed64( - random_float_between_alt(*(float *)&D_L15_00161430, *(float *)&D_L15_00161434))); + random_float_between_alt(D_L15_00161430, D_L15_00161434))); c = func_001FA898_r(multiply_global_factor_ed64( - random_float_between_alt(*(float *)&D_L15_00161438, *(float *)&D_L15_0016143C))); - spawn_spark(moby + 0x10, spark_a, spark_b, *(int *)&D_L15_00161418, *(int *)&D_L15_0016141C, a, b, c, - *(int *)&D_L15_00161454); + random_float_between_alt(D_L15_00161438, D_L15_0016143C))); + spawn_spark(moby + 0x10, spark_a, spark_b, D_L15_00161418, D_L15_0016141C, a, b, c, + D_L15_00161454); } /* Ported from rac1-decomp (src/overlays/shared/vendor_00298BB8.c: func_L15_0029C168), where it is exact; names translated to the US level program. */ extern float D_L15_0015F580[] __attribute__((section(".sdata"))); extern void spawn_glow_particle(char *, char *, int, int, float, int, int, int, int) __asm__("FUN_L00_002ac910"); -extern short D_L15_00161458 __attribute__((sda)); -extern short D_L15_0016145C __attribute__((sda)); +extern float D_L15_00161458 __attribute__((sda)); +extern int D_L15_0016145C __attribute__((sda)); extern unsigned char D_L15_00161460 __attribute__((sda)); extern unsigned char D_L15_00161464 __attribute__((sda)); extern unsigned char D_L15_00161468 __attribute__((sda)); extern unsigned char D_L15_0016146C __attribute__((sda)); void FUN_L15_0029af88(char *moby) { char *pos = moby + 0x10; - int t = scale_game_frames(*(int *)&D_L15_0016145C); - spawn_glow_particle(moby, pos, (int)&D_L15_0015F580, t, *(float *)&D_L15_00161458, + int t = scale_game_frames(D_L15_0016145C); + spawn_glow_particle(moby, pos, (int)&D_L15_0015F580, t, D_L15_00161458, D_L15_00161464, D_L15_00161468, D_L15_0016146C, D_L15_00161460); } /* update of moby class 256: a homing missile that leads its target, trails smoke and explodes on contact */ @@ -2346,9 +2346,9 @@ extern int scale_game_frames_alt(int) __asm__("FUN_001f96f8"); extern s32 random_integer_below_c(s32) __asm__("func_00213260"); extern s32 truncate_float_to_s32_c2(f32) __asm__("func_001FA6D0"); extern float D_L15_001614B4 __attribute__((sda)); -extern short D_L15_001614B8 __attribute__((sda)); +extern int D_L15_001614B8 __attribute__((sda)); extern float D_L15_001614BC __attribute__((sda)); -extern short D_L15_001614C0 __attribute__((sda)); +extern int D_L15_001614C0 __attribute__((sda)); extern float D_L15_001614C4 __attribute__((sda)); extern void FUN_L00_002730e0(float *pos, char *vel, int color, unsigned char life, unsigned char b, int mode, float scale); extern void FUN_L15_002a29b8(unsigned char *); @@ -2391,11 +2391,11 @@ void FUN_L15_002a2488(char *moby) { ((unsigned char *)moby)[0x20] = 1; goto tailA; } - ret1 = scale_game_frames_alt(*(int *)&D_L15_001614C0); + ret1 = scale_game_frames_alt(D_L15_001614C0); ret2 = func_001FA898_r((float)ret1); life = (unsigned char)ret2; ret3 = random_integer_below_c(0xFF); - FUN_L00_002730e0(pb, (char *)va, *(int *)&D_L15_001614B8, life, (unsigned char)ret3, 0, *(float *)&D_L15_001614BC); + FUN_L00_002730e0(pb, (char *)va, D_L15_001614B8, life, (unsigned char)ret3, 0, *(float *)&D_L15_001614BC); p = *(char **)(data + 0x6C); if (p == 0 || *(int *)p != D_L15_0015F5CC_macro) { if (p != 0) { @@ -3464,7 +3464,7 @@ extern s32 D_L15_00161AC0_gp __asm__("D_L15_00161AC0") __attribute__((sda)); extern void FUN_L15_002cbd88_u(void) __asm__("FUN_L15_002cbd88"); extern void enqueue_callback_list_1_alt(void (*)(void), void *) __asm__("FUN_001f4600"); -extern short D_L15_00161AC4 __attribute__((sda)); +extern int D_L15_00161AC4 __attribute__((sda)); extern short D_L15_00161AC8 __attribute__((sda)); void FUN_L15_002cbc30(void *arg) { struct Hero *base = &hero; @@ -3479,16 +3479,16 @@ void FUN_L15_002cbc30(void *arg) { } if (*(float *)&D_L15_00161ABC_gp != 0.0f) { *(int *)&D_L15_00161AC0_gp = 1; - if (FUN_L00_0028d8c0(*(void **)&D_L15_00161AC8, *(int *)&D_L15_00161AC4) == 0) { - *(int *)&D_L15_00161AC4 = allocate_voice_for_target_entry(5, 0x11, (int)arg); + if (FUN_L00_0028d8c0(*(void **)&D_L15_00161AC8, D_L15_00161AC4) == 0) { + D_L15_00161AC4 = allocate_voice_for_target_entry(5, 0x11, (int)arg); *(void **)&D_L15_00161AC8 = arg; } enqueue_callback_list_1_alt(FUN_L15_002cbd88_u, arg); } else { - if (FUN_L00_0028d8c0(*(void **)&D_L15_00161AC8, *(int *)&D_L15_00161AC4) != 0) { - release_voice_slot(*(int *)&D_L15_00161AC4); + if (FUN_L00_0028d8c0(*(void **)&D_L15_00161AC8, D_L15_00161AC4) != 0) { + release_voice_slot(D_L15_00161AC4); *(int *)&D_L15_00161AC8 = 0; - *(int *)&D_L15_00161AC4 = -1; + D_L15_00161AC4 = -1; } *(int *)&D_L15_00161AC0_gp = 0; } diff --git a/src/overlays/shared/gameplay/entities/trackdrive_left.c b/src/overlays/shared/gameplay/entities/trackdrive_left.c index ffad467866..e31d08c0c3 100644 --- a/src/overlays/shared/gameplay/entities/trackdrive_left.c +++ b/src/overlays/shared/gameplay/entities/trackdrive_left.c @@ -1357,10 +1357,10 @@ extern int D_L02_0015FFD8; /* no foreign declaration */ extern int FUN_L00_0025be00(); extern s32 random_integer_below(s32) __asm__("func_00213260"); extern s32 truncate_float_to_s32(f32) __asm__("func_001FA6D0"); -extern short D_L02_00161CB0 __attribute__((sda)); -extern short D_L02_00161CB4 __attribute__((sda)); -extern short D_L02_00161CB8 __attribute__((sda)); -extern short D_L02_00161CBC; +extern float D_L02_00161CB0 __attribute__((sda)); +extern int D_L02_00161CB4 __attribute__((sda)); +extern float D_L02_00161CB8 __attribute__((sda)); +extern float D_L02_00161CBC; extern void FUN_L00_002502f0(void *, int, int, int); extern void FUN_L00_002730e0(void *, void *, int, int, int, int, float); extern void add_vector_xyz(void *, void *, void *) __asm__("FUN_001f9a10"); @@ -1407,13 +1407,13 @@ void FUN_L02_002e0450(char *m) { int a; if (D_L02_0015F5CC & 4) s = -1.0f; - normalize_vector_xyz(v, m + 0xD0, s * *(float *)&D_L02_00161CBC); - normalize_vector_xyz(w, v, -2.0f / multiply_global_factor_ed64(*(float *)&D_L02_00161CB0)); + normalize_vector_xyz(v, m + 0xD0, s * D_L02_00161CBC); + normalize_vector_xyz(w, v, -2.0f / multiply_global_factor_ed64(D_L02_00161CB0)); add_vector_xyz(v, v, m + 0x10); - a = truncate_float_to_s32(multiply_global_factor_ed64(*(float *)&D_L02_00161CB0)) & 0xFF; - FUN_L00_002730e0(v, w, *(int *)&D_L02_00161CB4, a, + a = truncate_float_to_s32(multiply_global_factor_ed64(D_L02_00161CB0)) & 0xFF; + FUN_L00_002730e0(v, w, D_L02_00161CB4, a, random_integer_below(0xFF) & 0xFF, 0, - *(float *)&D_L02_00161CB8); + D_L02_00161CB8); } } } @@ -1446,14 +1446,14 @@ typedef struct { } Level02MobyList; extern int level_game_mode __asm__("D_L02_0015F5C4"); -extern unsigned char D_0015EDB0; +#include "rnc/gameplay/state/options.h" extern unsigned char D_L02_0017CA40[]; void attach_manipulator(void *arg0, s32 arg1, void *arg2) __asm__("FUN_0020cb10"); extern Level02MobyList talk_camera __asm__("D_L02_0016CE60"); void FUN_L02_002e0cd8(char *moby) { int i; - if (level_game_mode == 2 && D_0015EDB0 != 0) { + if (level_game_mode == 2 && big_head_cheat_enabled != 0) { for (i = 0; i < talk_camera.count; i++) { char *e = talk_camera.mobys[i]; if (*(short *)(e + 0xA6) == *(short *)(moby + 0xA6)) { diff --git a/src/overlays/shared/gameplay/entities/trespasser.c b/src/overlays/shared/gameplay/entities/trespasser.c index e25f68dae3..9b4422f913 100644 --- a/src/overlays/shared/gameplay/entities/trespasser.c +++ b/src/overlays/shared/gameplay/entities/trespasser.c @@ -16,14 +16,14 @@ /* Ported from rac1-decomp (src/overlays/shared/vendor_002C12B0.c: func_L00_002C2A20), where it is exact; names translated to the US level program. */ extern unsigned char D_0013A4E0[]; -extern unsigned char D_0013E533[]; +#include "rnc/data_labels.h" extern void FUN_L00_002c1778_u(void *) __asm__("FUN_L00_002c1778"); /* Runs FUN_L00_002c1778 when the moby data word 4 is set, else sets byte 0xBC from a mask test. */ void FUN_L00_002c1718(char *m) { if (*(int *)(*(char **)(m + 0x78) + 4) != 0) { FUN_L00_002c1778_u(m); - } else if (*(int *)(D_0013A4E0 + 0x2600) & *(int *)(D_0013E533 + 0x1EBD)) { + } else if (*(int *)(D_0013A4E0 + 0x2600) & *(int *)(((unsigned char *)&D_0013E533) + 0x1EBD)) { m[0xBC] = 1; } else { m[0xBC] = 0; @@ -1104,9 +1104,6 @@ void FUN_L00_002c1778(void *mv) { break; } } -#ifndef NON_MATCHING -INCLUDE_ASM("config/us/overlays/asm/FUN_L00_002c1ad0.s", FUN_L00_002c1ad0); -#else typedef struct { u8 pad0[0x40]; OvlVec4 grip; @@ -1157,32 +1154,62 @@ extern int FUN_L00_00216de8_2c1ad0(int, int) __asm__("FUN_L00_00216de8"); extern int FUN_L00_00233db8_2c1ad0(int, int) __asm__("FUN_L00_00233db8"); extern int FUN_L00_00233e98_2c1ad0(int) __asm__("FUN_L00_00233e98"); #include "rnc/input/pad_state.h" -/* Level 00 carrier: updates its grip, tosses a held moby, then looks for another. */ -void FUN_L00_002c1ad0(struct Moby *moby) { - CarrierVars_2c1ad0 *vars; - OvlVec4 saved, offset, rotatedOffset, local[4], pos, target, basis[3], matrix[4]; - OvlVec4 direction; - union { OvlVec4 launch; OvlVec4 arc; } temporary; - OvlVec4 probe; - f32 angle, slope, distance, horizontal, vertical, radius, speed; - OvlVec4 *targetPosition; +#include "rnc/math/vector.h" +#include "qcopy.h" +#include "qzero.h" +typedef struct { + u8 pad0[0x40]; + Vec4 grip; + struct Moby *held; + s32 timer54; + s32 timer58; + s32 delay; +} GloveVars_2c1ad0; +extern CollisionHit coll_hit __asm__("D_L00_00173E40"); +extern Vec4 D_L00_00166DC0; +extern char D_L00_00166C80[]; +extern short D_L00_001B07B0[]; +extern f32 frame_scale_inv_macro __asm__("D_0015ED68") __attribute__((section(".sdata"))); +extern f32 frame_time_macro __asm__("D_0015ED6C") __attribute__((section(".sdata"))); +extern f32 frame_time_sq_macro __asm__("D_0015ED70") __attribute__((section(".sdata"))); +extern s32 current_level_index_macro __asm__("D_0015ED84") __attribute__((section(".sdata"))); +extern s32 D_0015EEA4_macro __asm__("D_0015EEA4") __attribute__((section(".sdata"))); +extern u32 D_0013CAE4 __attribute__((section(".data"))); +extern void FUN_L00_0024f7c8(void *, int, void *); +/* Float arguments first: the order they are evaluated in gives retail's registers. */ +extern void FUN_L00_002c1928_f(f32, f32, f32, f32 *, f32 *, f32 *) __asm__("FUN_L00_002c1928"); +extern f32 atan2_f(f32, f32) __asm__("FUN_001f9e90"); +extern f32 fast_cos(f32) __asm__("FUN_001f9dc8"); +extern f32 fast_sin(f32) __asm__("FUN_001f9de0"); +/* Mine glove update: aims the glove and throws a mine at the target. */ +void FUN_L00_002c1ad0(struct Moby *moby) { + GloveVars_2c1ad0 *vars; + Vec4 saved, offset, rotatedOffset; + Vec4 local[4]; + Vec4 pos, target; + Vec4 basis[3]; + Vec4 matrix[4]; + Vec4 launch, arc, probe; + float *out; + float angle, slope, horizontal, vertical, radius, root; + s32 hit; if (moby == 0) return; - vars = (CarrierVars_2c1ad0 *)moby->pvars; - if (*(s32 *)((u8 *)vars + 0x5c) < 3) { - ++*(s32 *)((u8 *)vars + 0x5c); + vars = (GloveVars_2c1ad0 *)moby->pvars; + if (vars->delay < 3) { + ++vars->delay; return; } offset.q = 0; offset.f[1] = -0.09f; offset.f[2] = -0.02f; - setup_matrix_2c1ad0(basis, D_L00_00166C80_2c1ad0); + setup_matrix_2c1ad0(basis, D_L00_00166C80); matrix_from_basis_rows_2c1ad0(matrix, basis); if (vars == 0) return; - FUN_L00_0024f7c8((u8 *)moby, 0, &saved); + FUN_L00_0024f7c8(moby, 0, &saved); build_moby_bone_transform(moby, 0, local); rotate_vector_2c1ad0(&rotatedOffset, &offset, local); add_vector_xyz(&vars->grip, &saved, &rotatedOffset); @@ -1192,7 +1219,7 @@ void FUN_L00_002c1ad0(struct Moby *moby) { vars->held = 0; if (hero.state.current == 1) hero_set_state_2c1ad0(0x1E, 1); - if (tick_countdown((s32 *)((u8 *)vars + 0x58)) && !hero.unk20AC) { + if (tick_countdown(&vars->timer58) && !hero.unk20AC) { if ((hero.unk20A8 && hero.unk1BC == scale_game_frames(0x11)) || ((D_0013CAE4 & hero.items[0].button_mask) && hero.state.current == 0x1E && FUN_L00_00233e98_2c1ad0(-1)) || @@ -1203,124 +1230,67 @@ void FUN_L00_002c1ad0(struct Moby *moby) { } } if (vars->held != 0 && !hero.unk20AC) { - f32 *out = (f32 *)vars->held->pvars; - { - f32 speed; - temporary.launch.q = 0; - if (item_text_variant[0x11]) { - if (controller_state.held & 5) { - speed = 12.0f; - distance = D_0015ED6C; - } else { - speed = 4.0f; - distance = frame_time; - } - } else { - if (controller_state.held & 5) { - speed = 6.0f; - distance = D_0015ED6C; - } else { - speed = 4.0f; - distance = frame_time; - } - } - temporary.launch.f[0] = distance * speed; - qcopy(&direction, &temporary.launch); - } - adjust_direction_2c1ad0(&direction, &direction, (u8 *)&hero + 0x640); - angle = fast_add_rotations(-0.361968f, - atan2_f(hero.unk670, hero.unk674)); - pos.f[0] = FUN_001f9dc8(angle) * 0.859039f; - angle = fast_add_rotations(-0.361968f, - atan2_f(hero.unk670, hero.unk674)); - pos.f[1] = FUN_001f9de0(angle) * 0.859039f; + out = (float *)vars->held->pvars; + arc.q = 0; + arc.f[0] = frame_time_macro * (item_text_variant[0x11] ? ((controller_state.held & 5) ? 12.0f : 4.0f) : ((controller_state.held & 5) ? 6.0f : 4.0f)); + launch.q = arc.q; + adjust_direction_2c1ad0(&launch, &launch, hero.basis); + pos.f[0] = fast_cos(fast_add_rotations(-0.361968011f, atan2_f(hero.unk670, hero.unk674))) * 0.859039009f; + pos.f[1] = fast_sin(fast_add_rotations(-0.361968011f, atan2_f(hero.unk670, hero.unk674))) * 0.859039009f; pos.f[2] = 0.0f; add_vector_xyz(&pos, &pos, &hero.motion.pos); - pos.f[2] += 0.49082f; - atan2_f(direction.f[0], direction.f[1]); - targetPosition = ⌖ - scale_vector_xyz(targetPosition, &direction, D_0015ED68 * 60.0f); - add_vector_xyz(targetPosition, targetPosition, &pos); + pos.f[2] += 0.490819991f; + angle = atan2_f(launch.f[0], launch.f[1]); + scale_vector_xyz(&target, &launch, frame_scale_inv_macro * 60.0f); + add_vector_xyz(&target, &target, &pos); if (controller_state.held & 5) { - s32 hit; - f32 gravity; probe.q = 0; - probe.f[2] = item_text_variant[0x11] ? 12.0f : 6.0f; + probe.f[2] = item_text_variant[0x11] ? ((controller_state.held & 5) ? 12.0f : 4.0f) : ((controller_state.held & 5) ? 6.0f : 4.0f); + arc.q = probe.q; hit = 0; - temporary.arc.q = probe.q; - rotate_vector_2c1ad0(&temporary.arc, &temporary.arc, matrix); + rotate_vector_2c1ad0(&arc, &arc, matrix); + fast_subtract_rotations_2c1ad0(hero.moby->rot.z, atan2_f(arc.f[0], arc.f[1])); + angle = atan2_f(arc.f[0], arc.f[1]); + slope = atan2_f(vector_length_xy_2c1ad0(&arc), arc.f[2]); + if (0.593411922f < slope) slope = 0.593411922f; + if (slope < -1.39626336f) slope = -1.39626336f; + build_spherical_offset_2c1ad0(&arc, item_text_variant[0x11] ? ((controller_state.held & 5) ? 12.0f : 4.0f) : ((controller_state.held & 5) ? 6.0f : 4.0f), angle, slope); { - struct Moby *heroMoby = hero.moby; - angle = atan2_f(temporary.arc.f[0], temporary.arc.f[1]); - fast_subtract_rotations_2c1ad0(*(f32 *)((u8 *)heroMoby + 0x48), angle); - } - angle = atan2_f(temporary.arc.f[0], temporary.arc.f[1]); - slope = atan2_f(vector_length_xy_2c1ad0(&temporary.arc), temporary.arc.f[2]); - if (slope > 0.5934119f) - slope = 0.5934119f; - if (slope < -1.3962634f) - slope = -1.3962634f; - speed = 4.0f; - if (item_text_variant[0x11]) { - if (controller_state.held & 5) speed = 12.0f; - } else { - if (controller_state.held & 5) speed = 6.0f; - } - build_spherical_offset_2c1ad0(&temporary.arc, speed, angle, slope); - distance = vector_length_xy_2c1ad0(&temporary.arc); - if (distance == 0.0f) - horizontal = temporary.arc.f[2] / 0.01f; - else - horizontal = temporary.arc.f[2] / distance; - speed = 4.0f; - if (item_text_variant[0x11]) { - if (controller_state.held & 5) speed = 12.0f; - } else { - if (controller_state.held & 5) speed = 6.0f; + float distance = vector_length_xy_2c1ad0(&arc); + float z = arc.f[2]; + if (distance != 0.0f) horizontal = z / distance; + else horizontal = z / 0.01f; } - distance = square_root(frame_time_sq * 9.8f * speed * 0.5f); - gravity = frame_time_sq * 9.8f; - radius = distance + distance; - radius *= distance; - radius *= 1.0f - horizontal; - radius /= gravity; + root = square_root(frame_time_sq_macro * 9.8f * (item_text_variant[0x11] ? ((controller_state.held & 5) ? 12.0f : 4.0f) : ((controller_state.held & 5) ? 6.0f : 4.0f)) * 0.5f); + radius = (root + root) * root * (1.0f - horizontal) / (frame_time_sq_macro * 9.8f); vertical = horizontal * radius; - if (radius > 0.0f) { - temporary.arc.f[0] = FUN_001f9dc8(angle) * radius; - temporary.arc.f[1] = FUN_001f9de0(angle) * radius; - temporary.arc.f[2] = vertical; - add_vector_xyz(&probe, &D_L00_00166DC0_2c1ad0, &temporary.arc); - if (collision_line(&D_L00_00166DC0_2c1ad0, &probe, 2, moby, 0) && - coll_hit.moby != (s32)hero.moby) { - targetPosition->q = coll_hit.point.q; + if (0.0f < radius) { + arc.f[0] = fast_cos(angle) * radius; + arc.f[1] = fast_sin(angle) * radius; + arc.f[2] = vertical; + add_vector_xyz(&probe, &D_L00_00166DC0, &arc); + if (collision_line(&D_L00_00166DC0, &probe, 2, moby, 0) && coll_hit.moby != (s32)hero.moby) { + qcopy(&target, &coll_hit.point); hit = 1; - angle = atan2_f(targetPosition->f[0] - pos.f[0], targetPosition->f[1] - pos.f[1]); + angle = atan2_f(target.f[0] - pos.f[0], target.f[1] - pos.f[1]); } if (!hit) { - targetPosition->f[0] = FUN_001f9dc8(angle) * radius * 5.0f; - targetPosition->f[1] = FUN_001f9de0(angle) * radius * 5.0f; - targetPosition->f[2] = vertical * 5.0f; - add_vector_xyz(targetPosition, targetPosition, &D_L00_00166DC0_2c1ad0); + target.f[0] = fast_cos(angle) * radius * 5.0f; + target.f[1] = fast_sin(angle) * radius * 5.0f; + target.f[2] = vertical * 5.0f; + add_vector_xyz(&target, &target, &D_L00_00166DC0); } } } - { - f32 gravity = frame_time_sq_macro * 9.8f; - speed = 4.0f; - if (item_text_variant[0x11]) { - if (controller_state.held & 5) speed = 12.0f; - } else { - if (controller_state.held & 5) speed = 6.0f; - } - FUN_L00_002c1928((f32 *)&pos, (OvlQuad *)targetPosition, out, - gravity, 1.0f, speed); - } + FUN_L00_002c1928_f(frame_time_sq_macro * 9.8f, 1.0f, item_text_variant[0x11] ? ((controller_state.held & 5) ? 12.0f : 4.0f) : ((controller_state.held & 5) ? 6.0f : 4.0f), pos.f, target.f, out); } switch (moby->state) { case 0: vars->held = 0; - if (moby->anim_flags & 2) moby->state = 2; - else moby->state = 1; + if (!(moby->anim_flags & 2)) + moby->state = 1; + else + moby->state = 2; case 1: if (moby->anim_flags & 2) moby->state = 2; @@ -1328,20 +1298,21 @@ void FUN_L00_002c1ad0(struct Moby *moby) { case 3: if (vars->held != 0) { FUN_L00_002aa008(&pos, vars->held, vars->held->pvars); - if (D_00141680_2c1ad0.deliveries < 0xffff) + if (D_00141680_2c1ad0.deliveries <= 0xfffe) ++D_00141680_2c1ad0.deliveries; { - s32 frames = scale_game_frames(D_0015EEA4); - if (frames / 600 > D_00141680_2c1ad0.unkA2) - D_00141680_2c1ad0.unkA2 = scale_game_frames(D_0015EEA4) / 600; + s32 frames = scale_game_frames(D_0015EEA4_macro); + frames /= 600; + if (D_00141680_2c1ad0.unkA2 < frames) + D_00141680_2c1ad0.unkA2 = scale_game_frames(D_0015EEA4_macro) / 600; } - D_00141680_2c1ad0.levels = (D_00141680_2c1ad0.levels | (1u << current_level_index)) | 0x80000000u; - FUN_L00_0025f780(vars->held, D_L00_001B07B0_lui, 0x3f); + D_00141680_2c1ad0.levels = (D_00141680_2c1ad0.levels | (1u << current_level_index_macro)) | 0x80000000; + FUN_L00_0025f780(vars->held, D_L00_001B07B0, 0x3F); vars->held = 0; - vars->timer = scale_game_frames(10); + vars->timer54 = scale_game_frames(10); } moby->state = 4; - *(s32 *)((u8 *)vars + 0x58) = scale_game_frames(0x14); + vars->timer58 = scale_game_frames(0x14); break; case 4: if (hero.state.current != 0x23 && !hero.unk20A8) @@ -1357,15 +1328,14 @@ void FUN_L00_002c1ad0(struct Moby *moby) { } break; } - tick_countdown(&vars->timer); - if (vars->held != 0) + tick_countdown(&vars->timer54); + if (vars->held != 0) { qcopy(&vars->held->pos, &vars->grip); - else if (vars->timer == 0 && FUN_L00_00233e98_2c1ad0(-1)) { - direction.q = 0; - vars->held = FUN_L00_002a9ed0(moby, &vars->grip, &direction); + } else if (vars->timer54 == 0 && FUN_L00_00233e98_2c1ad0(-1)) { + qzero(&launch); + vars->held = FUN_L00_002a9ed0(moby, &vars->grip, &launch); } } -#endif /* * TODO(route): this body is DONE - it is byte-identical to retail under the * bundled GNU as (572/572 bytes; the only 23 differing words are relocation @@ -2009,7 +1979,7 @@ extern float FUN_002000e8_2c4380(float, float) __asm__("FUN_001fa580"); extern void FUN_L00_0025f800(void *, void *); void FUN_L00_002c4380(char *moby) { - int active = D_0013E533[6]; + int active = ((unsigned char *)&D_0013E533)[6]; char *vars = *(char **)(moby + 0x78); char *target; float v[4] __attribute__((aligned(16))); diff --git a/src/overlays/shared/gameplay/entities/underwater_ring.c b/src/overlays/shared/gameplay/entities/underwater_ring.c index c2e45554c7..1e743fa862 100644 --- a/src/overlays/shared/gameplay/entities/underwater_ring.c +++ b/src/overlays/shared/gameplay/entities/underwater_ring.c @@ -232,14 +232,14 @@ extern void FUN_L02_002ea8b0(char *); int memcard_save_data(int slot, int flags) __asm__("FUN_0020b178"); void mark_moby_for_removal(struct Obj *obj) __asm__("FUN_0020c828"); -extern short D_L15_001621A0 __attribute__((sda)); +extern float D_L15_001621A0 __attribute__((sda)); void FUN_L15_002ebd78(struct Moby *moby) { unsigned char *p; if (current_level_index != 0xF) { moby->rot.z = fast_add_rotations(moby->rot.z, frame_time * 1.5707964f); moby->scale = - moby->pclass->scale * *(float *)&D_L15_001621A0; + moby->pclass->scale * D_L15_001621A0; switch (moby->state) { case 0: FUN_L02_002ea7d0(moby); @@ -277,17 +277,10 @@ void FUN_L15_002ebd78(struct Moby *moby) { } } } -#ifndef NON_MATCHING -INCLUDE_ASM("config/us/overlays/asm/FUN_L15_002ed068.s", FUN_L15_002ed068); -#else -extern struct Moby *D_L15_0015FFD8 __attribute__((sda)); +extern struct Moby *D_L15_0015FFD8; extern int D_L15_0015F594 __attribute__((sda)); -extern struct Moby *D_0013F64C; extern int D_L15_0015F5C4; -extern u8 D_0014C170[]; extern u8 D_0014C050[]; -extern struct Moby *D_L15_0015FFD8_data __asm__("D_L15_0015FFD8") __attribute__((section(".data"))); -extern u8 D_0013F3D0[]; extern u32 D_0013CAE4 __attribute__((section(".data"))); extern void mark_moby_for_removal_002ed068(struct Moby *) __asm__("FUN_0020c828"); extern void try_set_help_message(int, int) __asm__("FUN_00215130"); @@ -302,6 +295,7 @@ extern void FUN_L00_00210a08(int, int, struct Moby *); void FUN_L15_002ed068(struct Moby *moby) { struct Moby *linked = moby->pvars; struct Moby *entry; + struct Moby *pad; u8 state = moby->state; u8 position[16] __attribute__((aligned(16))); @@ -313,16 +307,17 @@ void FUN_L15_002ed068(struct Moby *moby) { return; } entry = (struct Moby *)((char *)D_L15_0015FFD8 + (*(int *)((u8 *)linked + 0x60) << 8)); + entry->flags |= 1; + entry->collision = 0; entry->visible = 0; level = current_level_index; - entry->collision = 0; - entry->flags |= 1; moby->state = (level != 0x12 || D_0014C050[0x120 + moby->mission] != 0xff) ? 1 : 3; break; } case 1: - moby->state = 2; + /* Fakematch: the second store gives retail's register for moby. */ + if (moby) moby->state = 2; else moby->state = 2; return; case 2: if (hero.ground_moby == moby && hero.air_frames.s == 0 && D_L15_0015F5C4 != 2 && hero.state.current != 0x1d) { @@ -334,26 +329,28 @@ void FUN_L15_002ed068(struct Moby *moby) { if (!(D_0013CAE4 & 0x10)) return; if (D_L15_0015F594 != 4) return; if (hero.vehicle_mode == 2 && current_level_index == 0xf) { - linked = (struct Moby *)((char *)D_L15_0015FFD8_data + (*(int *)((u8 *)linked + 0x60) << 8)); - linked->collision = 0; - linked->visible = 0; - linked->flags |= 1; + pad = D_L15_0015FFD8; + pad += *(int *)((u8 *)linked + 0x60); + pad->flags |= 1; + pad->collision = 0; + pad->visible = 0; FUN_L15_00208ca8(); - set_moby_animation(linked, 0, 0); + set_moby_animation(pad, 0, 0); if (current_level_index != 0xf) return; start_scene(9); FUN_L01_0027a248(0, 5); return; } if (hero.vehicle_mode != 0) return; - linked = (struct Moby *)((char *)D_L15_0015FFD8_data + (*(int *)((u8 *)linked + 0x60) << 8)); + pad = D_L15_0015FFD8; + pad += *(int *)((u8 *)linked + 0x60); *(u128 *)position = *(u128 *)&moby->pos; *(float *)(position + 8) = probe_ground_height(position, 0, 0.5f) + 0.1f; FUN_L00_00216f90(position, &moby->rot, 0, 1); - linked->collision = linked->pclass->collision; - linked->visible = 1; - linked->flags &= ~1; - FUN_L00_00210a08(2, 0x5a, linked); + pad->collision = pad->pclass->collision; + pad->visible = 1; + pad->flags &= ~1; + FUN_L00_00210a08(2, 0x5a, pad); if (current_level_index == 0xf) { start_scene(8); *(u128 *)hero.unk1D00 = *(u128 *)&hero.motion.pos; @@ -374,4 +371,3 @@ void FUN_L15_002ed068(struct Moby *moby) { } *(int *)((u8 *)linked + 0x68) = -1; } -#endif diff --git a/src/overlays/shared/gameplay/entities/veldin_ship.c b/src/overlays/shared/gameplay/entities/veldin_ship.c index b69153ba04..438ef19490 100644 --- a/src/overlays/shared/gameplay/entities/veldin_ship.c +++ b/src/overlays/shared/gameplay/entities/veldin_ship.c @@ -416,10 +416,6 @@ void crate_drop_bolts(u8 *a) { *(s16 *)(a + 0xB4) = 0; mark_moby_for_removal_cf(a, 0x100, -1); } -#ifndef NON_MATCHING -INCLUDE_ASM("config/us/overlays/asm/FUN_L00_002d09b8.s", FUN_L00_002d09b8); -#else -#endif #include "qcopy.h" typedef struct V2d1428 { f32 x, y, z, w; @@ -488,7 +484,6 @@ void FUN_L00_002604f0(M2d1428 *, void *, void *, void *, void *, void *); P2d1428 *FUN_L00_002603d0(void *); void FUN_L00_00260738(void *, void *, void *, void *); -#ifdef NON_MATCHING typedef union { f32 f[4]; u128 q; @@ -536,10 +531,12 @@ extern s32 FUN_00257b90_2d09b8(s32, s32) __asm__("FUN_L00_00257b90"); extern void FUN_0026a9f0_2d09b8(void *, void *, s32, s32, s32, s32, s32, s32, f32, f32) __asm__("FUN_L00_0026a9f0"); extern void FUN_002ac910_2d09b8(void *, void *, void *, f32, s32, s32, s32, s32, s32) __asm__("FUN_L00_002ac910"); -void FUN_L00_002d09b8(M2d1428 *m, s32 hit, s32 source) { - u8 *vars = (u8 *)m->vars; - V2d09b8 position, b, rotation, c[3], a, d, e; - s32 kind, close, count, trail_count, particle, i, choice; +void FUN_L00_002d09b8(M2d1428 *moby, s32 hit, s32 source) { + u8 *vars = (u8 *)moby->vars; + V2d09b8 position, away, rotation, basis[3], launch, spawn_pos, spin; + s32 kind; + M2d1428 *self; + s32 close, count, trail_count, particle, i, choice; s32 first, second, first_color, second_color; f32 angle, distance, height, speed, rise; u32 colors[6], other_colors[6]; @@ -548,10 +545,10 @@ void FUN_L00_002d09b8(M2d1428 *m, s32 hit, s32 source) { close = 0; if (absolute_int_2d09b8(D_L00_0015F5CC - D_L00_001618D4_2d09b8) > 1) { - if (m->oclass == 0x1FA) - FUN_0028dc90_2d09b8(0, 0, m, 500); + if (moby->oclass == 0x1FA) + FUN_0028dc90_2d09b8(0, 0, moby, 500); else - FUN_0028dbe8_2d09b8(0, 0, m); + FUN_0028dbe8_2d09b8(0, 0, moby); D_L00_001618D4_2d09b8 = D_L00_0015F5CC; } if (absolute_int_2d09b8(D_L00_0015F5CC - D_L00_001618D8_2d09b8) >= 2) @@ -568,21 +565,27 @@ void FUN_L00_002d09b8(M2d1428 *m, s32 hit, s32 source) { *(u8 **)(*(u8 **)(*(u8 **)(vars + 0xA4) + 0x78) + 0xA0) = *(u8 **)(vars + 0xA0); *(u32 *)(*(u8 **)(*(u8 **)(vars + 0xA4) + 0x78) + 0xAC) |= 4; } + /* Fakematch: the self copy and the two empty tests on angle give retail's spill slots. */ + self = moby; { s32 i; - qcopy(&position, &m->pos); + qcopy(&position, &moby->pos); position.f[2] += 0.3f; FUN_0026b790_2d09b8(0.3f, 1.01f, 1.075f, 0.05f, 50000.0f, &position, 1, 0x40808080); for (i = 4; i >= 0; i--) FUN_0026b790_2d09b8(0.3f, 1.01f, 1.07f, 0.05f, 50000.0f, &position, 1, 0x40808080); if (source) - qcopy(&b, (u8 *)source + 0x10); + qcopy(&away, (u8 *)source + 0x10); else - FUN_001ff2a8_2d09b8(&b, &m->pos, (*(u8 * *)D_001413D0) + 0x10); - switch ((s16)((u16)m->oclass - 500)) { + FUN_001ff2a8_2d09b8(&away, &moby->pos, (*(u8 * *)D_001413D0) + 0x10); + switch ((s16)((u16)moby->oclass - 500)) { case 1: kind = 0x15C; break; case 3: kind = 0x15F; break; - case 2: kind = 0x162; break; + case 2: + if (!angle) { + } + kind = 0x162; + break; case 0: case 11: kind = 0x165; break; case 4: kind = 0x168; break; case 5: kind = 0x16B; break; @@ -593,30 +596,34 @@ void FUN_L00_002d09b8(M2d1428 *m, s32 hit, s32 source) { if (D_L00_0015FFBC >= 201) { count = 4; trail_count = 4; } else if (D_L00_0015FFBC >= 151) { count = 2; trail_count = 2; } else if (D_L00_0015FFBC >= 101) { count = 2; trail_count = 1; } - else if (D_L00_0015FFBC >= 51) { count = 1; trail_count = 0; } - else { count = 1; trail_count = 0; } - angle = D_L00_00166C80_2d19b0[80] - m->pos.x; - speed = D_L00_00166C80_2d19b0[81] - m->pos.y; + else { + if (!angle) { + } + if (D_L00_0015FFBC >= 51) { count = 1; trail_count = 0; } + else { count = 1; trail_count = 0; } + } + angle = D_L00_00166C80_2d19b0[80] - moby->pos.x; + speed = D_L00_00166C80_2d19b0[81] - moby->pos.y; angle = FUN_001ff8b0_2d09b8(angle, speed); - angle = FUN_00200130_2d09b8(angle, m->v40.z); + angle = FUN_00200130_2d09b8(angle, moby->v40.z); angle += 3.1415925f; choice = FUN_00200250_2d09b8(angle / 1.57f); angle = FUN_00200178_2d09b8((f32)choice * 1.57f); FUN_001ff260_2d09b8(&rotation); rotation.f[2] = angle; - FUN_001ffa50_2d09b8(&c, &rotation); + FUN_001ffa50_2d09b8(&basis, &rotation); for (i = 0; i < count; ++i) { - FUN_001ff6d0_2d09b8(&d, &D_L00_001DE6F0_2d09b8[i], &c); - FUN_001ff278_2d09b8(&d, &d, &m->pos); - qcopy(&e, &D_L00_001DE750_2d09b8[i]); - e.f[2] = FUN_002000e8_2d09b8(e.f[2], rotation.f[2]); - FUN_001ff2a8_2d09b8(&a, &d, &m->pos); - a.f[2] = 0.0f; + FUN_001ff6d0_2d09b8(&spawn_pos, &D_L00_001DE6F0_2d09b8[i], &basis); + FUN_001ff278_2d09b8(&spawn_pos, &spawn_pos, &moby->pos); + qcopy(&spin, &D_L00_001DE750_2d09b8[i]); + spin.f[2] = FUN_002000e8_2d09b8(spin.f[2], rotation.f[2]); + FUN_001ff2a8_2d09b8(&launch, &spawn_pos, &moby->pos); + launch.f[2] = 0.0f; speed = FUN_00257be8_2d09b8(1.0f, 5.0f); - FUN_001ff500_2d09b8(speed * D_0015ED6C_2d09b8, &a, &a); - a.f[2] = FUN_00257be8_2d09b8(4.0f, 9.0f) * D_0015ED6C_2d09b8; + FUN_001ff500_2d09b8(speed * D_0015ED6C_2d09b8, &launch, &launch); + launch.f[2] = FUN_00257be8_2d09b8(4.0f, 9.0f) * D_0015ED6C_2d09b8; particle = FUN_00257b50_2d09b8(2); - spawned = FUN_002af8b0_2d09b8(m, &a, &d, &e, kind, particle, 1.0f, 1.0f); + spawned = FUN_002af8b0_2d09b8(moby, &launch, &spawn_pos, &spin, kind, particle, 1.0f, 1.0f); if (spawned) { qcopy((u8 *)spawned + 0x40, &D_L00_001DE750_2d09b8[i]); *(f32 *)((u8 *)spawned + 0x48) = FUN_002000e8_2d09b8(*(f32 *)((u8 *)spawned + 0x48), rotation.f[2]); @@ -624,35 +631,35 @@ void FUN_L00_002d09b8(M2d1428 *m, s32 hit, s32 source) { } } for (i = 0; i < trail_count; i++) { - d.f[0] = FUN_00257be8_2d09b8(-0.5f, 0.5f); - d.f[1] = FUN_00257be8_2d09b8(-0.5f, 0.5f); - d.f[2] = FUN_00257be8_2d09b8(0.0f, 1.0f); - FUN_001ff278_2d09b8(&d, &d, &m->pos); + spawn_pos.f[0] = FUN_00257be8_2d09b8(-0.5f, 0.5f); + spawn_pos.f[1] = FUN_00257be8_2d09b8(-0.5f, 0.5f); + spawn_pos.f[2] = FUN_00257be8_2d09b8(0.0f, 1.0f); + FUN_001ff278_2d09b8(&spawn_pos, &spawn_pos, &moby->pos); speed = FUN_00257be8_2d09b8(6.0f, 12.0f) * D_0015ED6C_2d09b8; - FUN_00257d78_2d09b8(speed, speed, &a); - if (a.f[2] < 0.0f) a.f[2] = -a.f[2]; - e.f[0] = FUN_00257cb0_2d09b8(); - e.f[2] = FUN_00257cb0_2d09b8(); + FUN_00257d78_2d09b8(speed, speed, &launch); + if (launch.f[2] < 0.0f) launch.f[2] = -launch.f[2]; + spin.f[0] = FUN_00257cb0_2d09b8(); + spin.f[2] = FUN_00257cb0_2d09b8(); particle = 1; if (FUN_00257b50_2d09b8(6) == 0) particle = FUN_00200250_2d09b8(FUN_00257be8_2d09b8(3.0f, 6.0f)); - FUN_002af8b0_2d09b8(m, &a, &d, &e, kind + 1, particle, 0.25f, 0.5f); + FUN_002af8b0_2d09b8(moby, &launch, &spawn_pos, &spin, kind + 1, particle, 0.25f, 0.5f); } } - *(u32 *)((u8 *)m + 0x94) = 0; - m->state = 3; - *(u16 *)((u8 *)m + 0x34) |= 1; - m->bBC = FUN_001fef20_2d09b8(15); + *(u32 *)((u8 *)self + 0x94) = 0; + moby->state = 3; + *(u16 *)((u8 *)moby + 0x34) |= 1; + moby->bBC = FUN_001fef20_2d09b8(15); if (hit) { if (D_001413DC_2d09b8 == 22) vars[0xCA] = FUN_001fef20_2d09b8(5); else vars[0xCA] = 1; - FUN_001ff500_2d09b8(0.5f, &a, (u8 *)m + 0xE0); - FUN_001ff278_2d09b8(&a, &a, &m->pos); - FUN_001ff2a8_2d09b8(&d, &(*(V2d09b8 *)camera_position), &m->pos); - FUN_001ff260_2d09b8(&e); - distance = FUN_001ff3d8_2d09b8(&d); + FUN_001ff500_2d09b8(0.5f, &launch, (u8 *)moby + 0xE0); + FUN_001ff278_2d09b8(&launch, &launch, &moby->pos); + FUN_001ff2a8_2d09b8(&spawn_pos, &(*(V2d09b8 *)camera_position), &moby->pos); + FUN_001ff260_2d09b8(&spin); + distance = FUN_001ff3d8_2d09b8(&spawn_pos); choice = 10; if (distance < 8.0f) choice = FUN_00200250_2d09b8(distance) + 2; height = 0.0f; @@ -671,18 +678,17 @@ void FUN_L00_002d09b8(M2d1428 *m, s32 hit, s32 source) { first = FUN_001fef20_2d09b8(25); second = FUN_001fef20_2d09b8(30); second_color = FUN_00257b90_2d09b8(first, second); - FUN_0026a9f0_2d09b8(&a, &e, *effect, *velocity, first_color, second_color, 0, 0, 400000.0f, rise); + FUN_0026a9f0_2d09b8(&launch, &spin, *effect, *velocity, first_color, second_color, 0, 0, 400000.0f, rise); } if (D_L00_0015F5D0 < 0.95f && distance > 9.0f && !close) { - FUN_002ac910_2d09b8(m, &a, &e, 4.0f, FUN_001fef20_2d09b8(15), 127, 127, 127, 32); - FUN_002ac910_2d09b8(m, &a, &e, 4.0f, FUN_001fef20_2d09b8(24), 127, 32, 0, 32); - FUN_002ac910_2d09b8(m, &a, &e, 4.0f, FUN_001fef20_2d09b8(20), 127, 64, 0, 48); + FUN_002ac910_2d09b8(moby, &launch, &spin, 4.0f, FUN_001fef20_2d09b8(15), 127, 127, 127, 32); + FUN_002ac910_2d09b8(moby, &launch, &spin, 4.0f, FUN_001fef20_2d09b8(24), 127, 32, 0, 32); + FUN_002ac910_2d09b8(moby, &launch, &spin, 4.0f, FUN_001fef20_2d09b8(20), 127, 64, 0, 48); } - FUN_002ac910_2d09b8(m, &a, &e, 3.5f, FUN_001fef20_2d09b8(27), 96, 16, 0, 64); - FUN_002ac910_2d09b8(m, &a, &e, 3.0f, FUN_001fef20_2d09b8(29), 32, 0, 0, 32); + FUN_002ac910_2d09b8(moby, &launch, &spin, 3.5f, FUN_001fef20_2d09b8(27), 96, 16, 0, 64); + FUN_002ac910_2d09b8(moby, &launch, &spin, 3.0f, FUN_001fef20_2d09b8(29), 32, 0, 0, 32); } } -#endif void FUN_L00_002d1428(M2d1428 *m) { O2d1428 *o; M2d1428 *p, *n, *next; @@ -1164,7 +1170,7 @@ void FUN_L00_002d2158_c(int collision_arg, Moby_2D3608 *carrier, float *position extern void build_moby_bone_transform(void *, int, void *) __asm__("FUN_0020cca8"); extern u8 D_0013E539_lui __asm__("D_0013E539") __attribute__((section(".data"))); extern char D_0013CAE4[]; -extern char D_00141680[]; +#include "rnc/gameplay/state/game_globals.h" extern void build_moby_bone_transform(void *, int, void *) __asm__("FUN_0020cca8"); void FUN_L00_002d2670(unsigned char *moby) { @@ -1242,7 +1248,7 @@ void FUN_L00_002d2670(unsigned char *moby) { break; case 3: if (*(char **)(d + 0x50)) { - char *stats = ((char *)&D_00141680); + char *stats = ((char *)&item_usage); if (*(unsigned short *)(stats + 0xC8) <= 0xFFFE) *(unsigned short *)(stats + 0xC8) = *(unsigned short *)(stats + 0xC8) + 1; if (scale_game_frames_c2(D_0015EEA4) / 600 > (int)*(unsigned short *)(stats + 0xCA)) *(unsigned short *)(stats + 0xCA) = scale_game_frames_c2(D_0015EEA4) / 600; @@ -1817,7 +1823,6 @@ typedef struct { float x, y, z, w; } Vx __attribute__((aligned(16))); extern char *moby_table __asm__("D_L00_0015FFD8"); extern f32 convert_integer_to_float_c(s32) __asm__("func_001FA6C0"); extern f32 random_float_between_c(f32, f32) __asm__("func_002132A8"); -extern float D_0015ED60; extern int FUN_001f9770(void *); extern int FUN_L00_001fefc8(void *); extern int FUN_L00_0023e738(float *, float, float, float, float, float); @@ -1952,7 +1957,7 @@ void FUN_L00_002d3a10(unsigned char *m) { if ((q & (0xC000L << 18)) == (0x8000L << 18)) *(int *)(o + 0x4C) ^= 0x2; if (!(*(int *)(o + 0x4C) & 0x2)) { if (*(int *)(o + 0x4C) & 0x8) { - float t = *(float *)(o + 0x60) - *(float *)(o + 0x44) * D_0015ED60; + float t = *(float *)(o + 0x60) - *(float *)(o + 0x44) * frame_scale; *(float *)(o + 0x60) = t; if (t <= *(float *)(o + 0x3C)) { *(float *)(o + 0x60) = *(float *)(o + 0x3C); @@ -1961,7 +1966,7 @@ void FUN_L00_002d3a10(unsigned char *m) { } } } else { - float t = *(float *)(o + 0x60) + *(float *)(o + 0x40) * D_0015ED60; + float t = *(float *)(o + 0x60) + *(float *)(o + 0x40) * frame_scale; *(float *)(o + 0x60) = t; if (*(float *)(o + 0x38) <= t) { *(float *)(o + 0x60) = *(float *)(o + 0x38); @@ -1995,7 +2000,7 @@ void FUN_L00_002d3a10(unsigned char *m) { if (*(int *)(o + 0x4C) & 0x80) { float a = convert_integer_to_float_c(o[0x27]) / 100.0f; float b = convert_integer_to_float_c(o[0x29]) / 100.0f; - float t = *(float *)(o + 0x54) - b * D_0015ED60; + float t = *(float *)(o + 0x54) - b * frame_scale; *(float *)(o + 0x54) = t; if (t <= a) { *(float *)(o + 0x54) = a; @@ -2006,7 +2011,7 @@ void FUN_L00_002d3a10(unsigned char *m) { } else { float a = convert_integer_to_float_c(o[0x26]) / 100.0f; float b = convert_integer_to_float_c(o[0x28]) / 100.0f; - float t = *(float *)(o + 0x54) + b * D_0015ED60; + float t = *(float *)(o + 0x54) + b * frame_scale; *(float *)(o + 0x54) = t; if (a <= t) { *(float *)(o + 0x54) = a; @@ -2042,7 +2047,7 @@ void FUN_L00_002d3a10(unsigned char *m) { if (*(int *)(o + 0x4C) & 0x800) { float a = convert_integer_to_float_c(o[0x2C]) / 100.0f; float b = convert_integer_to_float_c(o[0x2E]) / 100.0f; - float t = *(float *)(o + 0x58) - b * D_0015ED60; + float t = *(float *)(o + 0x58) - b * frame_scale; *(float *)(o + 0x58) = t; if (t <= a) { *(float *)(o + 0x58) = a; @@ -2053,7 +2058,7 @@ void FUN_L00_002d3a10(unsigned char *m) { } else { float a = convert_integer_to_float_c(o[0x2B]) / 100.0f; float b = convert_integer_to_float_c(o[0x2D]) / 100.0f; - float t = *(float *)(o + 0x58) + b * D_0015ED60; + float t = *(float *)(o + 0x58) + b * frame_scale; *(float *)(o + 0x58) = t; if (a <= t) { *(float *)(o + 0x58) = a; @@ -2089,7 +2094,7 @@ void FUN_L00_002d3a10(unsigned char *m) { if (*(int *)(o + 0x4C) & 0x8000) { float a = convert_integer_to_float_c(o[0x31]) / 100.0f; float b = convert_integer_to_float_c(o[0x33]) / 100.0f; - float t = *(float *)(o + 0x5C) - b * D_0015ED60; + float t = *(float *)(o + 0x5C) - b * frame_scale; *(float *)(o + 0x5C) = t; if (t <= a) { *(float *)(o + 0x5C) = a; @@ -2100,7 +2105,7 @@ void FUN_L00_002d3a10(unsigned char *m) { } else { float a = convert_integer_to_float_c(o[0x30]) / 100.0f; float b = convert_integer_to_float_c(o[0x32]) / 100.0f; - float t = *(float *)(o + 0x5C) + b * D_0015ED60; + float t = *(float *)(o + 0x5C) + b * frame_scale; *(float *)(o + 0x5C) = t; if (a <= t) { *(float *)(o + 0x5C) = a; @@ -3446,7 +3451,6 @@ extern float D_L00_001E1440_2d73e8[][2] __asm__("D_L00_001E1440"); extern float D_L00_00161374 __asm__("D_L00_00161374"); extern float D_L00_00161384 __asm__("D_L00_00161384"); extern float D_L00_0016138C __asm__("D_L00_0016138C"); -extern float D_0015ED60; extern char camera_position[] __asm__("D_L00_00166DC0"); u64 FUN_001f9298_2d73e8(s32) __asm__("FUN_L00_001f9298"); void FUN_001ff2a8_2d73e8(void *, void *, void *) __asm__("FUN_001f9a28"); @@ -3508,7 +3512,7 @@ void FUN_L00_002d73e8(P *p) { for (i = q->start; i < end; i++) { speed = D_L00_001D4480[i]; f = D_L00_001D31C0[i]; - f -= D_0015ED60 * speed; + f -= frame_scale * speed; transform = D_L00_001D2860[i] ? negative_transform : positive_transform; D_L00_001D31C0[i] = f; if (f <= -8.0f) diff --git a/src/overlays/shared/gameplay/entities/walloper.c b/src/overlays/shared/gameplay/entities/walloper.c index c278475c39..f1a1992470 100644 --- a/src/overlays/shared/gameplay/entities/walloper.c +++ b/src/overlays/shared/gameplay/entities/walloper.c @@ -14,7 +14,7 @@ extern int D_L00_001615AC_gp __asm__("D_L00_001615AC") __attribute__((sda)); extern int D_L00_001615B4_gp __asm__("D_L00_001615B4") __attribute__((sda)); extern int D_L00_001615C8_gp __asm__("D_L00_001615C8") __attribute__((sda)); extern char D_0013E533[]; -extern char D_0013F3D0[], D_001413D0[]; +#include "rnc/data_labels.h" extern char *active_mobies[] __asm__("D_L00_001ABA00"); extern float g_debug_camera[] __asm__("D_L00_00166DC0"); extern u8 D_L00_001DB5C0[], D_L00_001DBA20[]; @@ -174,7 +174,7 @@ next_candidate:; make_hit_descriptor(&hit, o, 0x210000, &camera_direction, enabled_float + 2.0f); hit.mode = 1; hit.kind = 5; hit.id = *(short *)(o + 0xa6); *(short *)(v + 0x3e) = 20; - FUN_L00_001f2868(0.3f, v, 0x10, *(void **)D_001413D0, &hit); + FUN_L00_001f2868(0.3f, v, 0x10, *(void **)((char *)&D_001413D0), &hit); fast_vec_sub(&direction, v + 0x10, v); fast_vec_normalize(&direction, &direction, 1.0f); if (*(char **)(v + 0x20) || *(char **)(v + 0x38)) { @@ -259,9 +259,9 @@ next_candidate:; qcopy(&offset, &D_L00_001DB890[i]); } if (i == 1) { - fast_vec_scale(0.5f, &effects.first.origin, *(char **)D_001413D0 + 0xe0); + fast_vec_scale(0.5f, &effects.first.origin, *(char **)((char *)&D_001413D0) + 0xe0); fast_vec_add(&target_delta, D_0013F3D0, &effects.first.origin); - hit_result = FUN_001efa68(&target_delta, (Vec4 *)v, 0x10, *(void **)D_001413D0, 0); + hit_result = FUN_001efa68(&target_delta, (Vec4 *)v, 0x10, *(void **)((char *)&D_001413D0), 0); } else if (i == 19 || !(i & 1)) { hit_result = FUN_001efa68((Vec4 *)((char *)D_L00_001DB5C0 - 32 + difference), (Vec4 *)point, 0x10, o, 0); } else continue; @@ -1209,7 +1209,6 @@ typedef u32 VecQuad __attribute__((mode(TI), aligned(16))); extern Vec4 collision_hit_point __asm__("D_L00_00173E60"); extern char *active_mobies[] __asm__("D_L00_001ABA00"); -extern char D_0013F350[]; extern f32 convert_integer_to_float(s32) __asm__("func_001FA6C0"); extern f32 fast_arc_sin(f32) __asm__("func_001F9DF8"); extern f32 fast_arc_tan_c(f32, f32) __asm__("func_001F9E90"); @@ -1220,7 +1219,7 @@ extern int D_L00_00173E40[]; extern int collision_line(Vec4f *, Vec4f *, int, void *, int) __asm__("FUN_001efa68"); extern int fun_002141f8(char *) __asm__("FUN_002141f8"); extern float D_L00_001616DC __attribute__((sda)); -extern short D_L00_001616D8 __attribute__((sda)); +extern float D_L00_001616D8 __attribute__((sda)); extern void add_vector_xyz_c4(void *, void *, void *) __asm__("FUN_001f9a10"); extern void build_spherical_offset(void *, f32, f32, f32) __asm__("func_00214DB0"); float absolute_float(float input) __asm__("func_001F99C0"); @@ -1244,7 +1243,7 @@ char *FUN_L00_002bc3b0(char *self, float *position, float *heading, float *pitch limit = D_L00_001616DC; a0s[0] = (int)self; *(VecQuad *)start = *(VecQuad *)position; - g = D_0013F350; + g = ((char *)&hero); m0 = *(char **)(g + 0x2080); *(VecQuad *)end = *(VecQuad *)(m0 + 0x10); position = start; @@ -1275,7 +1274,7 @@ char *FUN_L00_002bc3b0(char *self, float *position, float *heading, float *pitch distance = fast_vec_dist(position, target); if (distance < 2.5f) { float toward; - char *g1 = D_0013F350; + char *g1 = ((char *)&hero); moby = *(char **)(g1 + 0x2080); toward = fast_arc_tan_c(*(float *)(candidate + 0x10) - *(float *)(g1 + 0x80), *(float *)(candidate + 0x14) - *(float *)(g1 + 0x84)); @@ -1291,13 +1290,13 @@ char *FUN_L00_002bc3b0(char *self, float *position, float *heading, float *pitch if (distance > limit) continue; { - char *g2 = D_0013F350; + char *g2 = ((char *)&hero); build_spherical_offset(offset, distance, *heading, *pitch + *(float *)(g2 + 0x2E4) * 0.5f); } add_vector_xyz_c4(offset, offset, position); apparentAngle = fast_arc_sin(fast_vec_dist(offset, target) / (distance + distance)); apparentAngle += apparentAngle; - if (*(float *)&D_L00_001616D8 * 0.017453292f < apparentAngle) { + if (D_L00_001616D8 * 0.017453292f < apparentAngle) { data = (char *)fun_002141f8(candidate); if (data) { radius = convert_integer_to_float(*(unsigned char *)(data + 10)) * 0.125f; @@ -1309,7 +1308,7 @@ char *FUN_L00_002bc3b0(char *self, float *position, float *heading, float *pitch } } } - if (apparentAngle < *(float *)&D_L00_001616D8 * 0.017453292f) { + if (apparentAngle < D_L00_001616D8 * 0.017453292f) { int valid = 1; if (collision_line((Vec4f *)position, (Vec4f *)target, 6, self, 0)) { if (!D_L00_00173E40[6] || (char *)D_L00_00173E40[6] != candidate) @@ -1391,7 +1390,7 @@ extern int D_00141680; extern int D_0015EEA4; extern float D_L00_001616E0 __attribute__((sda)); extern int D_L00_001616EC __attribute__((sda)); -extern int D_L00_001617BC_gp __asm__("D_L00_001617BC") __attribute__((sda)); +extern int D_L00_001617BC; extern int D_L00_001617C0; extern int D_L00_001617C4; extern int D_L00_001617C8; @@ -1425,7 +1424,6 @@ void FUN_L00_00236268(HudElem *e); void FUN_L00_00236458(void); void FUN_L00_0023e838(int i); void FUN_L00_00263d40(int a, int b); -extern char D_0013F350[]; extern char D_0013A5E0_2BDAF0[] __asm__("D_0013CAE0"); extern char item_unlocked[] __asm__("D_0013D408"); extern unsigned char D_0013E633_2BDAF0[] __asm__("D_0013E533"); @@ -1479,7 +1477,7 @@ void FUN_L00_002bc7e8(Moby *moby) { int now; busy = 0; - if (((Hero *)D_0013F350)->items[0].state == 3) { + if (((Hero *)((char *)&hero))->items[0].state == 3) { busy = 1; } data = (struct Ray_2BDAF0 *)moby->pvars; @@ -1494,11 +1492,11 @@ void FUN_L00_002bc7e8(Moby *moby) { in_range = 0; } func_001F9938_2BDAF0(&data->timer); - if ((((unsigned int)((Hero *)D_0013F350)->state.control_mode < 2 || ((Hero *)D_0013F350)->state.control_mode == 12 - || ((Hero *)D_0013F350)->state.control_mode == 4 || ((Hero *)D_0013F350)->state.control_mode == 5)) - && (*(int *)D_0013A5E0_2BDAF0 & ((Hero *)D_0013F350)->items[0].button_mask) != 0 + if ((((unsigned int)((Hero *)((char *)&hero))->state.control_mode < 2 || ((Hero *)((char *)&hero))->state.control_mode == 12 + || ((Hero *)((char *)&hero))->state.control_mode == 4 || ((Hero *)((char *)&hero))->state.control_mode == 5)) + && (*(int *)D_0013A5E0_2BDAF0 & ((Hero *)((char *)&hero))->items[0].button_mask) != 0 && !busy && in_range) { - if (((Hero *)D_0013F350)->unk20A8 == 0) { + if (((Hero *)((char *)&hero))->unk20A8 == 0) { func_L00_0020EB60_2BDAF0(); } if (data->seen == 0) { @@ -1516,21 +1514,21 @@ void FUN_L00_002bc7e8(Moby *moby) { data->timer = func_001F9850_2BDAF0(15); } func_L00_00250800_2BDAF0(moby, 0, data); - if (((Hero *)D_0013F350)->state.current == 1) { + if (((Hero *)((char *)&hero))->state.current == 1) { func_L00_00222B80_2BDAF0(30, 1); } *(u128_2BDAF0 *)&direction = 0; - if (((Hero *)D_0013F350)->state.current == 30 - && (*(unsigned short *)((char *)((Hero *)D_0013F350)->moby + 0x34) & 1)) { + if (((Hero *)((char *)&hero))->state.current == 30 + && (*(unsigned short *)((char *)((Hero *)((char *)&hero))->moby + 0x34) & 1)) { func_001FA480_2BDAF0(points, D_L00_00166C80); func_001FA4A0_2BDAF0(matrix, points); direction.z = 1.0f; func_001F9EE8_2BDAF0(&direction, &direction, matrix); - } else if (((Hero *)D_0013F350)->unk22C8 == 1) { + } else if (((Hero *)((char *)&hero))->unk22C8 == 1) { func_001F9C30_2BDAF0(&direction, &moby->rot_row1, -1.0f); } else { direction.x = 1.0f; - func_001F9EC0_2BDAF0(&direction, &direction, ((Hero *)D_0013F350)->basis[0].f); + func_001F9EC0_2BDAF0(&direction, &direction, ((Hero *)((char *)&hero))->basis[0].f); } data->yaw = func_L00_001FF860_2BDAF0(direction.x, direction.y); data->pitch = func_L00_001FF860_2BDAF0(func_001F9CE8_2BDAF0(&direction), direction.z); @@ -1604,7 +1602,7 @@ void FUN_L00_002bc7e8(Moby *moby) { func_001FFCB0_2BDAF0(data->snd); data->snd = -1; } - D_L00_001617BC_gp = 1; + D_L00_001617BC = 1; if (D_L00_001617C0 >= 0) { float brightness; func_L00_001FF4B0_2BDAF0(&direction, &moby->rot_row1, -0.5f); @@ -1643,10 +1641,8 @@ void FUN_L00_002bc7e8(Moby *moby) { #ifndef NON_MATCHING INCLUDE_ASM("config/us/overlays/asm/FUN_L00_002bcf98.s", FUN_L00_002bcf98); #else -extern s32 D_L00_001617BC_gp __asm__("D_L00_001617BC") __attribute__((sda)); -extern s32 D_L00_001617BC_lui __asm__("D_L00_001617BC") __attribute__((section(".data"))); extern f32 D_L00_001616DC_gp __asm__("D_L00_001616DC") __attribute__((sda)); -extern f32 D_L00_001617CC __attribute__((sda)); +extern f32 D_L00_001617CC_macro __asm__("D_L00_001617CC") __attribute__((section(".sdata"))); extern s32 D_L00_00161718_i __asm__("D_L00_00161718") __attribute__((sda)); extern s32 D_L00_00161720_i __asm__("D_L00_00161720") __attribute__((sda)); extern s32 D_L00_00161724_i __asm__("D_L00_00161724") __attribute__((sda)); @@ -1668,10 +1664,10 @@ void FUN_L00_002bcf98(u8 *m) { s32 *clears; u128 *scaled_vector; - if (D_L00_001617BC_lui != 0) { - D_L00_001617BC_gp = 0; + if (D_L00_001617BC != 0) { + D_L00_001617BC = 0; scale = D_L00_001616DC_gp / convert_integer_to_float(12); - D_L00_001617CC = scale; + D_L00_001617CC_macro = scale; scale_vector_2bcf98(-scale, &vec, m + 0xD0); qcopy(&D_L00_001DBF60_2bcf98, (void *)source); for (i = 10; i >= 0; i--) { @@ -1809,7 +1805,7 @@ extern Vec_2BE3A8 D_L00_001DD3A0_2BE3A8[3] __asm__("D_L00_001DD0A0"); extern Vec_2BE3A8 D_L00_001DD3D0_2BE3A8[3] __asm__("D_L00_001DD0D0"); extern Vec_2BE3A8 D_L00_00173F60_2BE3A8 __asm__("D_L00_00173E60"); extern char D_L00_0015F660_2BE3A8[] __asm__("D_L00_0015F580") __attribute__((section(".sdata"))); -extern char D_001413D0[]; +#include "rnc/data_labels.h" extern void func_L00_002BE2A0_2BE3A8(void) __asm__("FUN_L00_002bcf98"); extern float func_L00_0025F368_2BE3A8(float) __asm__("FUN_L00_0025e310"); extern void func_00215C00_2BE3A8(void *, float, float, float) __asm__("FUN_00214db0"); @@ -1879,7 +1875,7 @@ void FUN_L00_002bd0a0(struct Moby *moby) { } beam_length = D_L00_001616DC_gp; if (data->target == 0) { - if (func_L00_001EFFF0_2BE3A8(data, &beam_end, 20, *(void **)D_001413D0, 0) != 0) { + if (func_L00_001EFFF0_2BE3A8(data, &beam_end, 20, *(void **)((char *)&D_001413D0), 0) != 0) { beam_length = func_001F9D48_2BE3A8(&D_L00_00173F60_2BE3A8, data); } } else { diff --git a/src/overlays/shared/gameplay/hero/hero_check_damage.c b/src/overlays/shared/gameplay/hero/hero_check_damage.c index 5256302260..82e1bf6445 100644 --- a/src/overlays/shared/gameplay/hero/hero_check_damage.c +++ b/src/overlays/shared/gameplay/hero/hero_check_damage.c @@ -1335,16 +1335,16 @@ float FUN_L00_0020f0b8(float *a, float *b) { typedef struct { float x, y, z, w; } __attribute__((aligned(16))) V4_F7F8; -extern char D_0013E533[] __attribute__((section(".data"))); +extern char D_0013E533_lui[] __asm__("D_0013E533") __attribute__((section(".data"))); extern float FUN_L00_0020f0b8_c(float *a, float *b) __asm__("FUN_L00_0020f0b8"); -extern short D_L00_0015F694 __attribute__((sda)); +extern int D_L00_0015F694 __attribute__((sda)); extern void add_vector_xyz(void *, void *, void *) __asm__("FUN_001f9a10"); extern void clear_u64_value_c(void *) __asm__("func_001F99F8"); extern void copy_matrix3x4_alt() __asm__("FUN_001fa2b8"); extern void fast_vec_scale(void *, void *, f32) __asm__("func_001F9A68"); extern void matrix_to_euler(void *, void *) __asm__("FUN_00214598"); void normalize_vector_triplet(f32 *vectors) __asm__("FUN_00214128"); -extern char D_0013F350[] __attribute__((section(".data"))); +extern struct Hero hero_lui __asm__("D_0013F350") __attribute__((section(".data"))); void FUN_L00_0020f160(char *arg) { V4_F7F8 vv[4]; @@ -1357,9 +1357,9 @@ void FUN_L00_0020f160(char *arg) { float mx; { - char *b = ((char *)&D_0013F350); - copy_matrix3x4_alt(((char *)&D_0013F350) + 0x12F0 + *(int *)(b + 0x21B8) * 0x30); - normalize_vector_triplet(((char *)&D_0013F350) + 0x12F0 + *(int *)(b + 0x21B8) * 0x30); + char *b = ((char *)((char *)&hero_lui)); + copy_matrix3x4_alt(((char *)((char *)&hero_lui)) + 0x12F0 + *(int *)(b + 0x21B8) * 0x30); + normalize_vector_triplet(((char *)((char *)&hero_lui)) + 0x12F0 + *(int *)(b + 0x21B8) * 0x30); *(int *)(b + 0x21B8) = (*(int *)(b + 0x21B8) + 1) % 16; *(int *)(b + 0x21BC) = *(int *)(b + 0x21BC) + 1; @@ -1373,27 +1373,27 @@ void FUN_L00_0020f160(char *arg) { } { - char *b = ((char *)&D_0013F350); + char *b = ((char *)((char *)&hero_lui)); if (*(int *)(b + 0x208C) == 0x16) { - *(int *)&D_L00_0015F694 = 14; + D_L00_0015F694 = 14; } else if (*(int *)(b + 0x2084) == 2) { - *(int *)&D_L00_0015F694 = 5; + D_L00_0015F694 = 5; } else { - *(int *)&D_L00_0015F694 = 11; + D_L00_0015F694 = 11; } } { - char *b = ((char *)&D_0013F350); - if (*(int *)(b + 0x21C0) < *(int *)&D_L00_0015F694) { + char *b = ((char *)((char *)&hero_lui)); + if (*(int *)(b + 0x21C0) < D_L00_0015F694) { *(int *)(b + 0x21C0) = *(int *)(b + 0x21C0) + 1; - } else if (*(int *)&D_L00_0015F694 < *(int *)(b + 0x21C0)) { + } else if (D_L00_0015F694 < *(int *)(b + 0x21C0)) { *(int *)(b + 0x21C0) = *(int *)(b + 0x21C0) - 1; } } { - char *b = ((char *)&D_0013F350); + char *b = ((char *)((char *)&hero_lui)); n = *(int *)(b + 0x21C0); if (n < 2) { n = 2; @@ -1407,19 +1407,19 @@ void FUN_L00_0020f160(char *arg) { cnt = 0; for (i = 0; i < n; i++) { - char *b = ((char *)&D_0013F350); + char *b = ((char *)((char *)&hero_lui)); int t; sums = fa; t = i - 15; ri = (*(int *)(b + 0x21B8) - t) % 16; for (k = 0; k < n; k++) { if (i != k) { - char *b = ((char *)&D_0013F350); + char *b = ((char *)((char *)&hero_lui)); int u = k - 15; int rj = (*(int *)(b + 0x21B8) - u) % 16; *(float *)((char *)sums - (-(i * 4))) += FUN_L00_0020f0b8_c( - (float *)(((char *)&D_0013F350) + 0x12F0 + ri * 0x30), - (float *)(((char *)&D_0013F350) + 0x12F0 + rj * 0x30)); + (float *)(((char *)((char *)&hero_lui)) + 0x12F0 + ri * 0x30), + (float *)(((char *)((char *)&hero_lui)) + 0x12F0 + rj * 0x30)); } } } @@ -1444,11 +1444,11 @@ void FUN_L00_0020f160(char *arg) { } acc++; { - char *b = ((char *)&D_0013F350); + char *b = ((char *)((char *)&hero_lui)); int t = i - 15; ri = (*(int *)(b + 0x21B8) - t) % 16; for (k = 0; k < 3; k++) { - add_vector_xyz(&vv[k], &vv[k], ((char *)&D_0013F350) + 0x12F0 + ri * 0x30 + k * 16); + add_vector_xyz(&vv[k], &vv[k], ((char *)((char *)&hero_lui)) + 0x12F0 + ri * 0x30 + k * 16); } } } @@ -2803,7 +2803,7 @@ void FUN_L00_00211be8(void) { /* Ported from rac1-decomp (src/overlays/shared/help_0020CDF0.c: func_L00_002123B0), where it is exact; names translated to the US level program. */ -extern char D_0013E533[]; +extern char D_0013E533_lui[]; extern void FUN_001fa050(void *, void *); extern void FUN_001fa378(void *, void *, void *); extern void FUN_00214598(void *, void *); @@ -2816,9 +2816,9 @@ void FUN_L00_00211cf8(float x, float y, float z) { in[1] = y; in[2] = z; FUN_001fa050(t, in); - FUN_001fa050(u, D_0013E533 + 0xEAD); + FUN_001fa050(u, D_0013E533_lui + 0xEAD); FUN_001fa378(u, u, t); - FUN_00214598(u, D_0013E533 + 0xEAD); + FUN_00214598(u, D_0013E533_lui + 0xEAD); } typedef float V4_211d78[4] __attribute__((aligned(16))); void FUN_001f9d20(void *, void *, void *); @@ -3122,7 +3122,7 @@ typedef union { f32 f[4]; } V; extern u8 D_L00_00173E40[] __attribute__((section(".data"))); -extern u8 D_L00_00173E60[] __attribute__((section(".data"))); +extern V D_L00_00173E60_lui __asm__("D_L00_00173E60") __attribute__((section(".data"))); extern f32 D_L00_00173E68 __attribute__((section(".data"))); void FUN_001f99f8_c(void *) __asm__("FUN_001f99f8"); @@ -3191,7 +3191,7 @@ void FUN_L00_002127b8(void) { hero.unk12ED = r; hero.ground_type = FUN_001f0b58(); if (hero.ground_type == 0) { - hero.water_surface_z = resolve_camera_surface_height(D_L00_00173E60, &hero.unk280); + hero.water_surface_z = resolve_camera_surface_height(((u8 *)&D_L00_00173E60_lui), &hero.unk280); if (hero.motion.pos.f[2] < hero.water_surface_z && hero.unk2F8 <= 0) { hero.unk2F8 = 1; } @@ -3391,7 +3391,7 @@ void FUN_L00_00212ff0(void) { globals->motion.pos.f[2] = n; if (lim < n) globals->motion.pos.f[2] = lim; } - q = D_0013E533 + 0xEA5; + q = D_0013E533_lui + 0xEA5; func_L00_0025C918_2136A8((float *)q, *(float *)(q + 0x250), (float *)(q + 0x27C), frame_scale_sq * 0.057f, frame_scale_sq * 0.3f, D_0015ED6C_c + D_0015ED6C_c); } } else { @@ -3406,7 +3406,7 @@ void FUN_L00_00212ff0(void) { /* Ported from rac1-decomp (src/overlays/shared/help_0020CDF0.c: func_L00_00213970), where it is exact; names translated to the US level program. */ -extern char D_0013E533[]; +extern char D_0013E533_lui[]; extern float FUN_001f9af0(void *); extern void clear_u64_value(void *) __asm__("FUN_001f99f8"); extern void FUN_001f9a68(void *, void *, float); @@ -3414,7 +3414,7 @@ extern void FUN_001f9bf8(void *, void *, float); void build_spherical_offset(f32 *out, f32 scale, f32 a, f32 b) __asm__("FUN_00214db0"); void FUN_L00_002132b8(float a, float b) { - char *p = D_0013E533 + 0x173D; + char *p = D_0013E533_lui + 0x173D; char *q = p - 0x920; float v; build_spherical_offset(p, *(float *)(q + 0x930), *(float *)(q + 0x938), *(float *)(q + 0x934)); @@ -3757,7 +3757,7 @@ void FUN_L00_00213880(void) /* Scales four vectors and one float of the hero by s. */ void FUN_L00_00213de8(float s) { - char *p = D_0013E533 + 0xF1D; + char *p = D_0013E533_lui + 0xF1D; float *f; FUN_001f9a68(p, p, s); diff --git a/src/overlays/shared/gameplay/hero/hero_idle_sequence.c b/src/overlays/shared/gameplay/hero/hero_idle_sequence.c index 6ab3aabfef..d17d23dc93 100644 --- a/src/overlays/shared/gameplay/hero/hero_idle_sequence.c +++ b/src/overlays/shared/gameplay/hero/hero_idle_sequence.c @@ -215,7 +215,7 @@ void FUN_L00_002054e8(void) { } while ((s32)p < (s32)end); } typedef struct { - u8 a0; + u8 unk0; u8 active; char pad[0x3E]; char m40[0x20]; @@ -486,7 +486,7 @@ void FUN_L00_002059d8(void) { /* Ported from rac1-decomp (src/overlays/shared/help_00203E98.c: func_L00_002064C0), where it is exact; names translated to the US level program. */ extern unsigned char D_0013D4D5[]; -extern unsigned char D_0013E533[]; +#include "rnc/data_labels.h" extern void FUN_L00_00235dc0(void); extern void FUN_L00_0023a218(void); extern void FUN_L00_0023a2d0(void); @@ -496,7 +496,7 @@ s32 queue_animation_update(s32 chan, s32 id, s32 fn, s32 d, s32 e, s32 c, void FUN_L00_00205ea8(void) { struct Hero *g; if (D_0013D4D5[6] == 0) { - *(int *)(D_0013E533 + 0x2E65) = 0; + *(int *)(((unsigned char *)&D_0013E533) + 0x2E65) = 0; return; } g = &hero; @@ -2050,11 +2050,11 @@ f32 FUN_L00_00208f20(f32 a, f32 b, f32 c, f32 d) { extern float FUN_L00_00200228(void *, float); extern s32 truncate_float_to_s32(f32) __asm__("FUN_001fa6d0"); -extern unsigned char D_0013E533[]; +#include "rnc/data_labels.h" float FUN_L00_00209018(float *a, int n) { char buf[16] __attribute__((aligned(16))); - char *d = (char *)D_0013E533 + 0xE1D; + char *d = (char *)((unsigned char *)&D_0013E533) + 0xE1D; int i = truncate_float_to_s32(*(float *)(d + 0xAA8)); int m = n - 1; int p = (i + m) % n; @@ -2565,7 +2565,7 @@ extern int FUN_L00_0025e3b8(void *); extern void *D_L00_00173E58_d __asm__("D_L00_00173E58") __attribute__((section(".data"))); void FUN_L00_0020a318(void) { - char *g = (char *)D_0013E533 + 0xE1D; + char *g = (char *)((unsigned char *)&D_0013E533) + 0xE1D; char *p; char *p2; char *h; @@ -2601,9 +2601,9 @@ void FUN_L00_0020a318(void) { p2 = D_L00_0017A680_d; *(float *)(p2 + 0x6D4) = s2 * 0.05f; *(float *)(p2 + 0x6D8) = s2 * 0.3f; - h = (char *)D_0013E533 + 0xE9D; + h = (char *)((unsigned char *)&D_0013E533) + 0xE9D; f = fast_vec_dist(h, collision_hit_point); - g2 = (char *)D_0013E533 + 0xE1D; + g2 = (char *)((unsigned char *)&D_0013E533) + 0xE1D; f = f - *(float *)(g2 + 0x234); f = (1.29999995f - f) / 1.29999995f; f = f * 1.25f; diff --git a/src/overlays/shared/gameplay/hero/hero_set_state.c b/src/overlays/shared/gameplay/hero/hero_set_state.c index 1d0c96a8e7..2c1110a9db 100644 --- a/src/overlays/shared/gameplay/hero/hero_set_state.c +++ b/src/overlays/shared/gameplay/hero/hero_set_state.c @@ -591,7 +591,7 @@ extern char D_L00_0017BF60_e[] __asm__("D_L00_0017BF60"); extern unsigned char opt_mirror_anim __asm__("D_0015EDB5"); extern T2C_222B80 attack_records[] __asm__("D_L00_0017BC28"); extern char *hero_slot_moby(int) __asm__("FUN_L00_0020d460"); -extern char D_00141680[]; +#include "rnc/gameplay/state/game_globals.h" extern float absolute_float(float) __asm__("func_001F99C0"); extern float D_L00_0017BDF0[][25]; extern float FUN_001f9b48(void *, void *); @@ -1300,7 +1300,7 @@ int hero_set_state(int a, int b) { p->state.control_mode = 0xD; p->unk2284 = 7; { - char *h = ((char *)&D_00141680); + char *h = ((char *)&item_usage); if (*(unsigned short *)(h + 0x60) <= 0xFFFE) { *(unsigned short *)(h + 0x60) = *(unsigned short *)(h + 0x60) + 1; } @@ -1348,7 +1348,7 @@ int hero_set_state(int a, int b) { p->state.control_mode = 0xE; p->unk2284 = 7; { - char *h = ((char *)&D_00141680); + char *h = ((char *)&item_usage); if (*(unsigned short *)(h + 0x60) <= 0xFFFE) { *(unsigned short *)(h + 0x60) = *(unsigned short *)(h + 0x60) + 1; } @@ -2214,7 +2214,7 @@ int hero_set_state(int a, int b) { } h[1].level_mask = h[1].level_mask | (1 << current_level_index) | 0x80000000; - h2 = D_00141680; + h2 = item_usage; if (*(unsigned short *)(h2 + 0x128) <= 0xFFFE) { *(unsigned short *)(h2 + 0x128) = *(unsigned short *)(h2 + 0x128) + 1; } @@ -2251,7 +2251,7 @@ int hero_set_state(int a, int b) { break; } case 0x13: { - char *h = ((char *)&D_00141680); + char *h = ((char *)&item_usage); struct Hero *q; T2C_222B80 *e; int k; diff --git a/src/overlays/shared/gameplay/vendor/003015d0.c b/src/overlays/shared/gameplay/vendor/003015d0.c index 2e726cf17f..4fa0741b45 100644 --- a/src/overlays/shared/gameplay/vendor/003015d0.c +++ b/src/overlays/shared/gameplay/vendor/003015d0.c @@ -47,13 +47,13 @@ extern void FUN_L14_00301de8(char *); extern void FUN_L14_00301fa8(char *); extern void FUN_L14_00302538(char *); extern void enqueue_callback_list_1(void (*)(void), void *) __asm__("FUN_001f4600"); -extern short D_L14_0016219C_s __asm__("D_L14_001620CC") __attribute__((sda)); -extern short D_L14_00162188_s __asm__("D_L14_001620B8") __attribute__((sda)); -extern short D_L14_001621A0_s __asm__("D_L14_001620D0") __attribute__((sda)); +extern int D_L14_0016219C_s __asm__("D_L14_001620CC") __attribute__((sda)); +extern int D_L14_00162188_s __asm__("D_L14_001620B8") __attribute__((sda)); +extern int D_L14_001621A0_s __asm__("D_L14_001620D0") __attribute__((sda)); extern s32 D_L14_001620C8_gp __asm__("D_L14_001620C8") __attribute__((sda)); -extern short D_L14_001621A4_s __asm__("D_L14_001620D4") __attribute__((sda)); +extern int D_L14_001621A4_s __asm__("D_L14_001620D4") __attribute__((sda)); -extern short D_L14_001620D8 __attribute__((sda)); +extern int D_L14_001620D8 __attribute__((sda)); void FUN_L14_003015d0(unsigned char *m) { D1224 *d = *(D1224 **)(m + 0x78); float v[4] __attribute__((aligned(16))); @@ -66,7 +66,7 @@ void FUN_L14_003015d0(unsigned char *m) { return; } } - if (*(int *)&D_L14_0016219C_s != 0) { + if (D_L14_0016219C_s != 0) { return; } s = m[0x20]; @@ -80,9 +80,9 @@ void FUN_L14_003015d0(unsigned char *m) { d->sA = 1; break; case 1: - if (*(int *)&D_L14_00162188_s != 0) { + if (D_L14_00162188_s != 0) { if (d->s12 == 0) { - *(int *)&D_L14_00162188_s = *(int *)&D_L14_00162188_s - 1; + D_L14_00162188_s = D_L14_00162188_s - 1; FUN_L14_003017f8((char *)m); } } @@ -108,17 +108,17 @@ void FUN_L14_003015d0(unsigned char *m) { } break; } - if (*(int *)&D_L14_001620D8 == 0) { + if (D_L14_001620D8 == 0) { if (FUN_001f9b80(m + 0x10, &hero.motion.pos) < 10.0f) { FUN_L14_00302538((char *)m); } } if (d->s12 != 0) { - if (*(int *)&D_L14_001621A0_s == 0) { + if (D_L14_001621A0_s == 0) { FUN_L14_00301de8((char *)m); } if (*(int *)&D_L14_001620C8_gp < d->s12) { - if (*(int *)&D_L14_001621A4_s != 0) { + if (D_L14_001621A4_s != 0) { return; } enqueue_callback_list_1(FUN_L14_00301fa8, m); @@ -276,9 +276,6 @@ void FUN_L14_003017f8(char *m) { } } #endif -#ifndef NON_MATCHING -INCLUDE_ASM("config/us/overlays/asm/FUN_L14_00301de8.s", FUN_L14_00301de8); -#else extern int D_L14_001620C4 __attribute__((sda)); extern int D_L14_001620F0 __attribute__((sda)); extern int D_L14_001620F4 __attribute__((sda)); @@ -286,19 +283,18 @@ extern int D_L14_001620F8 __attribute__((sda)); extern float convert_integer_to_float(int) __asm__("FUN_001fa6c0"); extern int fast_tween_color(int, int, float) __asm__("FUN_001fa6e0"); extern void add_vector_xyz(void *, void *, void *) __asm__("FUN_001f9a10"); -void FUN_L14_00301de8(char *m) { - char *d = *(char **)(m + 0x78); +void FUN_L14_00301de8(char *moby) { + char *vars = *(char **)(moby + 0x78); char *dst, *src; u8 *indices; int i, j, k, copy_i, next_i; - int offset; - float t; + float fraction; - if (*(s16 *)(d + 0x12) != 0) { - *(s16 *)(d + 0x12) = *(u16 *)(d + 0x12) - 1; - indices = (u8 *)(d + 0x18); - src = d + 0x260; - dst = d + 0x60; + if (*(s16 *)(vars + 0x12) != 0) { + *(s16 *)(vars + 0x12) = *(u16 *)(vars + 0x12) - 1; + indices = (u8 *)(vars + 0x18); + src = vars + 0x260; + dst = vars + 0x60; for (j = 22; j >= 0; j--) { add_vector_xyz(dst, dst, src); dst += 0x10; @@ -307,14 +303,9 @@ void FUN_L14_00301de8(char *m) { i = 0; do { next_i = i + 1; - src = (char *)((i << 4) + (int)d); - offset = (int)src; - src += 0x560; - dst = (char *)offset + 0x460; for (k = 2; k >= 0; k--) { - add_vector_xyz(dst, dst, src); - dst += 0x40; - src += 0x40; + char *row = vars + (i << 4) + (2 - k) * 0x40; + add_vector_xyz(row + 0x460, row + 0x460, row + 0x560); } i = next_i; } while ((float)i < 4.0f); @@ -323,24 +314,23 @@ void FUN_L14_00301de8(char *m) { indices = 0; /* End the saved index-base lifetime after the transfer. */ copy_i = 0; do { - qcopy(d + 0x420 + (copy_i << 4), (char *)(((u8)src[copy_i] << 4) + (int)d) + 0x20); + qcopy(vars + 0x420 + (copy_i << 4), (char *)(((u8)src[copy_i] << 4) + (int)vars) + 0x20); copy_i++; } while (copy_i < 4); } } - if (*(s16 *)(d + 0x12) > D_L14_001620C4) { - t = convert_integer_to_float(*(s16 *)(d + 0x12) - D_L14_001620C4) / - convert_integer_to_float(*(int *)(d + 0x620) - D_L14_001620C4); - *(int *)(d + 0x14) = fast_tween_color(D_L14_001620F4, D_L14_001620F0, t); - } else if (*(s16 *)(d + 0x12) > D_L14_001620C8) { - t = convert_integer_to_float(*(s16 *)(d + 0x12) - D_L14_001620C8) / + if (*(s16 *)(vars + 0x12) > D_L14_001620C4) { + fraction = convert_integer_to_float(*(s16 *)(vars + 0x12) - D_L14_001620C4) / + convert_integer_to_float(*(int *)(vars + 0x620) - D_L14_001620C4); + *(int *)(vars + 0x14) = fast_tween_color(D_L14_001620F4, D_L14_001620F0, fraction); + } else if (*(s16 *)(vars + 0x12) > D_L14_001620C8) { + fraction = convert_integer_to_float(*(s16 *)(vars + 0x12) - D_L14_001620C8) / convert_integer_to_float(D_L14_001620C4 - D_L14_001620C8); - *(int *)(d + 0x14) = fast_tween_color(D_L14_001620F8, D_L14_001620F4, t); + *(int *)(vars + 0x14) = fast_tween_color(D_L14_001620F8, D_L14_001620F4, fraction); } else { - *(int *)(d + 0x14) = 0; + *(int *)(vars + 0x14) = 0; } } -#endif #ifndef NON_MATCHING INCLUDE_ASM("config/us/overlays/asm/FUN_L14_00301fa8.s", FUN_L14_00301fa8); #else diff --git a/src/overlays/shared/rendering/00245c28.c b/src/overlays/shared/rendering/00245c28.c index a1411fe8b9..7aa10b7187 100644 --- a/src/overlays/shared/rendering/00245c28.c +++ b/src/overlays/shared/rendering/00245c28.c @@ -34,7 +34,7 @@ extern void init_stash(void) __asm__("FUN_00232d00"); extern void FUN_L00_0023d028(void); extern int FUN_L00_00244110(int, int); extern void clear_dma_queue_entry(void) __asm__("FUN_001f0b88"); -extern void FUN_L00_002464a8(void); +extern void FUN_L00_002464a8_u(void) __asm__("FUN_L00_002464a8"); extern void init_hud(void) __asm__("FUN_001fee88"); extern void FUN_L00_00276078(void); extern void FUN_L00_0028eed0(void); @@ -122,7 +122,7 @@ void FUN_L00_00245c28(void) { g_debug_menu.selected_column = one; g_debug_menu.actuator_enabled = one; clear_dma_queue_entry(); - FUN_L00_002464a8(); + FUN_L00_002464a8_u(); init_hud(); FUN_L00_00276078(); FUN_L00_0028eed0(); @@ -300,16 +300,32 @@ void FUN_L00_00245c28(void) { } do_space_transition(); } -#ifndef NON_MATCHING -INCLUDE_ASM("config/us/overlays/asm/FUN_L00_002464a8.s", FUN_L00_002464a8); -#else -#endif #include "rnc/storage/disc_table.h" typedef struct { - u8 pad0[0x24]; + s32 unk0; + s32 unk4; + s32 buffer; + s32 unkC; +} MapChunkSlot; + +typedef struct { + s32 first_data; + s32 second_data; + s32 scratch_data; + s32 mask_data; + s32 initialized; + s32 second_raw; + u8 pad18[0xc]; s32 active; - u8 pad28[0x1fc]; + s32 unk28; + u8 pad2c[4]; + MapChunkSlot slots[8]; + u8 padB0[4]; + f32 unkB4[20]; + s32 unk104[20]; + s32 unk154[20]; + u8 pad1a4[0x80]; s32 archive_index; s32 load_state; s32 file_handle; @@ -333,6 +349,124 @@ typedef struct { s32 last_transfer_bytes; } RenderArchiveState; +/* Sets up the map's tables, loads its data from disc and builds the circular mask. */ +/* Ported from rac1-decomp (src/overlays/shared/map_002465F8.c: func_L00_00246EC0), where it is exact; names translated to the US level program. */ + +extern char render_archive_source_file[] __asm__("D_L00_0015FE00"); +extern char D_L00_001E8B00[]; +extern float map_points[] __asm__("D_L00_00182810"); +extern float map_coefficients[] __asm__("D_L00_00182A70"); +extern s32 D_L00_00173E08 __attribute__((section(".data"))); +extern int D_L00_00183EF0[]; +extern RenderArchiveState D_L00_001841F0 __asm__("D_L00_001841F0"); +extern int FUN_L00_0024d8d0(); +extern s32 D_0015ED84; +extern s32 hud_heap_alloc() __asm__("func_001FF288"); +extern unsigned char D_0013D4C0[]; +extern unsigned char D_0014161B[]; +extern unsigned char D_L00_00184394[]; +extern void decode_map_mask(int *dst, unsigned char *src, short *offs) __asm__("FUN_00206710"); +extern void fast_mem_copy_alt(void *, void *, int) __asm__("FUN_001f98d0"); +extern void load_map_chunk(void *dst, unsigned char *src, int) __asm__("FUN_00207bb0"); +s32 load(s32 dst, s32 sector, s32 sector_count) __asm__("FUN_00216828"); +s32 stash_send_data(u32 src, s32 qw, s32 count, s32 tag) __asm__("FUN_00232e40"); +extern struct DiscFile D_00138438[]; +extern char D_001383A0[]; +extern char D_00141EC0[]; + +void FUN_L00_002464a8(void) { + int i; + RenderArchiveState *state; + int level; + struct DiscFile *file; + int heap_tag, first_size, second_size, scratch; + int *archive, *archive_base; + unsigned char *level_data; + int x, y, mask_buffer; + float radius_sq; + unsigned char *flags; + + D_L00_001841F0.initialized = 1; + { int i; + for (i = 0; i < 20; i++) { + D_L00_001841F0.unk104[i] = D_L00_00183EF0[i * 2]; + D_L00_001841F0.unkB4[i] = 0.65f; + D_L00_001841F0.unk154[i] = D_L00_00183EF0[i * 2 + 1]; + } } + level = current_level_index; + D_L00_001841F0.file_handle = -1; + D_L00_001841F0.archive_index = level > 18 ? 0 : level; + { int i; + for (i = 0; i < 19; i++) { + float world_x0 = map_points[i * 8], world_y0 = map_points[i * 8 + 1], world_x1 = map_points[i * 8 + 2], world_y1 = map_points[i * 8 + 3]; + float map_x0 = map_points[i * 8 + 4], map_y0 = map_points[i * 8 + 5], map_x1 = map_points[i * 8 + 6], map_y1 = map_points[i * 8 + 7]; + float scale_x = (map_x0 - map_x1) / (world_x0 - world_x1); + float scale_y = (map_y0 - map_y1) / (world_y0 - world_y1); + map_coefficients[i * 4 + 1] = scale_x; + map_coefficients[i * 4 + 3] = scale_y; + map_coefficients[i * 4] = map_x0 - scale_x * world_x0; + map_coefficients[i * 4 + 2] = map_y0 - scale_y * world_y0; + } } + flags = (unsigned char *)D_0013D4C0; + if (flags[0x21] != 0) { + D_L00_001841F0.loaded = 1; + file = (struct DiscFile *)D_00138438 + D_L00_001841F0.archive_index; + } else { + D_L00_001841F0.loaded = 0; + file = (struct DiscFile *)D_001383A0 + D_L00_001841F0.archive_index; + } + if (file->size != 0) { + state = &D_L00_001841F0; + state->unk28 = 1; + heap_tag = (int)render_archive_source_file; + archive_base = ((int **)&D_L00_00173E08)[0]; + archive = (int *)((int)archive_base + 0x9A800); + scratch = file->size << 7; + load(archive, file->sector, file->size); + state->file_handle = stash_send_data((int)archive, scratch, 0x4800, (int)D_L00_001E8B00); + state->transfer_bytes = scratch; + FUN_L00_0024d8d0((int)archive, (int)archive_base); + archive = archive_base; + first_size = archive[1] - archive[0]; + state->first_data = hud_heap_alloc(first_size, 0, (char *)heap_tag, 0x2DB); + fast_mem_copy_alt((void *)state->first_data, (char *)archive + archive[0], first_size); + state->first_data += 8; + state->second_data = state->first_data; + second_size = archive[2] - archive[1]; + state->second_raw = hud_heap_alloc(second_size, 0, (char *)heap_tag, 0x2EC); + fast_mem_copy_alt((void *)state->second_raw, (char *)archive + archive[1], second_size); + state->scratch_data = hud_heap_alloc(0x1000, 0, (char *)heap_tag, 0x2F3); + for (i = 0; i < 8; i++) { + D_L00_001841F0.slots[i].unk0 = -1; + D_L00_001841F0.slots[i].unk4 = -1; + D_L00_001841F0.slots[i].buffer = D_L00_001841F0.scratch_data + i * 0x200; + } + mask_buffer = hud_heap_alloc(0x8000, 0, render_archive_source_file, 0x2FC); + level_data = ((char *)&D_00141EC0) + D_L00_001841F0.archive_index * 0x800; + D_L00_001841F0.mask_data = mask_buffer; + if (level_data[0] != 0) { + load_map_chunk((void *)D_L00_001841F0.mask_data, level_data, D_L00_001841F0.second_raw); + } else { + decode_map_mask((int *)D_L00_001841F0.mask_data, (unsigned char *)D_L00_001841F0.first_data, (short *)D_L00_001841F0.second_data); + } + radius_sq = 256.0f; + for (y = 0; y < 32; y++) { + for (x = 0; x < 32; x++) { + if ((15.5f - (float)x) * (15.5f - (float)x) + + (15.5f - (float)y) * (15.5f - (float)y) > radius_sq) { + D_L00_00184394[x / 8 + y * 4] |= 1 << (x - (x / 8) * 8); + } + } + } + } else { + D_L00_001841F0.first_data = 0; + D_L00_001841F0.scratch_data = 0; + D_L00_001841F0.mask_data = 0; + D_L00_001841F0.second_data = 0; + D_L00_001841F0.unk28 = 0; + } +} + extern RenderArchiveState D_L00_001841F0 __asm__("D_L00_001841F0"); extern u8 D_0013D4E1 __attribute__((section(".data"))); extern struct DiscFile D_00138438[]; @@ -398,156 +532,3 @@ void FUN_L00_002468b8(void) { } D_L00_001841F0.active = 0; } -#ifdef NON_MATCHING -#include "rnc/storage/disc_table.h" -extern u8 D_0013D4E1; -extern s32 D_L00_00173E08 __attribute__((section(".data"))); - -typedef struct { - s32 first_data; - s32 second_data; - s32 scratch_data; - s32 mask_data; - s32 initialized; - s32 second_raw; - u8 pad18[0x20c]; - s32 archive_index; - u8 pad228[4]; - s32 file_handle; - s32 loaded; - s32 transfer_bytes; -} RenderArchiveLoad; -extern RenderArchiveLoad D_L00_001841F0_load __asm__("D_L00_001841F0"); - -void FUN_00266040(void *, s32, s32) __asm__("FUN_L00_00266040"); -s32 FUN_00293c58(void *, s32, s32, s32) __asm__("FUN_L00_00293c58"); -void FUN_L00_0024d8d0(void *, s32 *) __asm__("FUN_L00_0024d8d0"); -s32 FUN_002355f0(s32, s32, s32, s32) __asm__("FUN_L00_002355f0"); -void hud_send_resident_bank(s32, s32, s32) __asm__("FUN_001ff128"); -void FUN_L00_00248278(s32, s32, s32) __asm__("FUN_L00_00248278"); -void FUN_L00_00249f48(s32, void *, s32) __asm__("FUN_L00_00249f48"); - -extern f32 D_L00_00182810[]; -extern f32 D_L00_00182A70[]; -extern u8 D_L00_00184394[]; -extern char D_00141EC0[]; -extern s32 D_L00_00183EF0[]; -extern char render_archive_source_file[] __asm__("D_L00_0015FE00"); - -void FUN_L00_002464a8(void) { - s32 i, x, y; - s32 *source; - s32 *destination; - s32 *archive; - s32 first_size, second_size; - s32 scratch; - s32 word0, word1; - s32 heap_tag; - s32 *archive_base; - f32 *points; - f32 *coefficients; - f32 x_slope, y_slope; - f32 x0, y0, x1, y1, x2, y2, x3, y3; - struct DiscFile *file; - u8 *level_data; - u8 *mask; - - D_L00_001841F0_load.initialized = 1; - destination = (s32 *)((u8 *)&D_L00_001841F0_load + 0x154); - source = D_L00_00183EF0; - for (i = 0x13; i >= 0; i--) { - word0 = source[0]; - word1 = source[1]; - *(s32 *)((u8 *)destination - 0x50) = word0; - destination[0] = word1; - *(f32 *)((u8 *)destination - 0xa0) = 0.65f; - source += 2; - destination++; - } - i = current_level_index; - D_L00_001841F0_load.file_handle = -1; - i = 0x12 < i ? 0 : i; - D_L00_001841F0_load.archive_index = i; - coefficients = D_L00_00182A70; - points = D_L00_00182810; - for (i = 0x12; i >= 0; i--) { - x0 = points[0]; - y0 = points[1]; - x1 = points[2]; - y1 = points[3]; - x2 = points[4]; - y2 = points[5]; - x3 = points[6]; - y3 = points[7]; - x3 = (x2 - x3) / (x0 - x1); - y3 = (y2 - y3) / (y0 - y1); - coefficients[1] = x3; - coefficients[3] = y3; - coefficients[0] = x2 - x3 * x0; - coefficients[2] = y2 - y3 * y0; - points += 8; - coefficients += 4; - } - if (D_0013D4E1 != 0) { - file = (struct DiscFile *)0x138438; - D_L00_001841F0_load.loaded = 1; - } else { - file = (struct DiscFile *)0x1383a0; - D_L00_001841F0_load.loaded = 0; - } - file += D_L00_001841F0_load.archive_index; - if (file->size != 0) { - *(s32 *)0x184218 = 1; - heap_tag = (s32)render_archive_source_file; - archive_base = (s32 *)D_L00_00173E08; - archive = (s32 *)((s32)archive_base + 0x9a800); - scratch = file->size << 7; - FUN_00266040(archive, file->sector, file->size); - D_L00_001841F0_load.file_handle = FUN_00293c58(archive, scratch, 0x4800, 0x1e8b00); - D_L00_001841F0_load.transfer_bytes = scratch; - FUN_L00_0024d8d0(archive, archive_base); - archive = archive_base; - first_size = archive[1] - archive[0]; - D_L00_001841F0_load.first_data = FUN_002355f0(first_size, 0, heap_tag, 0x2db); - hud_send_resident_bank(D_L00_001841F0_load.first_data, (s32)archive + archive[0], first_size); - D_L00_001841F0_load.first_data += 8; - D_L00_001841F0_load.second_data = D_L00_001841F0_load.first_data; - second_size = archive[2] - archive[1]; - D_L00_001841F0_load.second_raw = FUN_002355f0(second_size, 0, heap_tag, 0x2ec); - hud_send_resident_bank(D_L00_001841F0_load.second_raw, (s32)archive + archive[1], second_size); - D_L00_001841F0_load.scratch_data = FUN_002355f0(0x1000, 0, heap_tag, 0x2f3); - destination = (s32 *)0x184228; - for (i = 0; i < 8; i++) { - *(s32 *)((u8 *)destination - 8) = -1; - *(s32 *)((u8 *)destination - 4) = -1; - destination[0] = D_L00_001841F0_load.scratch_data + i * 0x200; - destination += 4; - } - D_L00_001841F0_load.mask_data = FUN_002355f0(0x8000, 0, (s32)render_archive_source_file, 0x2fc); - level_data = (u8 *)D_00141EC0 + D_L00_001841F0_load.archive_index * 0x800; - if (level_data[0] != 0) { - FUN_L00_00249f48(D_L00_001841F0_load.mask_data, level_data, D_L00_001841F0_load.second_raw); - } else { - FUN_L00_00248278(D_L00_001841F0_load.mask_data, D_L00_001841F0_load.first_data, D_L00_001841F0_load.second_data); - } - x_slope = 256.0f; - y_slope = 15.5f; - mask = D_L00_00184394; - for (y = 0; y < 32; y++) { - for (x = 0; x < 32; x++) { - if ((y_slope - (f32)x) * (y_slope - (f32)x) + - (y_slope - (f32)y) * (y_slope - (f32)y) > x_slope) { - mask[x / 8 + y * 4] |= 1 << (x - (x / 8) * 8); - } - } - } - } else { - destination = (s32 *)&D_L00_001841F0_load; - D_L00_001841F0_load.first_data = 0; - destination[10] = 0; - destination[2] = 0; - destination[3] = 0; - destination[1] = 0; - } -} -#endif diff --git a/src/overlays/shared/rendering/debug/001f36f8.c b/src/overlays/shared/rendering/debug/001f36f8.c index b10fe7c800..39ba8599cc 100644 --- a/src/overlays/shared/rendering/debug/001f36f8.c +++ b/src/overlays/shared/rendering/debug/001f36f8.c @@ -475,7 +475,7 @@ extern u8 item_defs[] __asm__("D_L00_00179AC0") NOT_SDA; #define D_L00_001C40BE ((u16 *)((u8 *)D_L00_001C40B0 + 0xE)) extern s32 weapon_ammo_counts[] __asm__("D_0013D428"); extern int D_0013E520[]; -extern u8 D_0014C050[]; +#include "rnc/gameplay/state/game_globals.h" extern const char D_L00_0015EFE0[] __attribute__((sda)); extern const char D_L00_0015EFF0[]; extern const char D_L00_0015EFF8[]; @@ -742,7 +742,7 @@ void FUN_L00_001f4598(void) { if ((D_0013C940.buttons.w.pressed & 0x20) != 0) { index = g_debug_menu.segment_index; player_setting = - (u8 *)(g_debug_menu.segment_index + D_0015ED84 * 0x10 + D_0014C050); + (u8 *)(g_debug_menu.segment_index + D_0015ED84 * 0x10 + visited52); new_count = 0; if (*player_setting == 0) new_count = 255; @@ -1102,7 +1102,7 @@ extern int fptodp(float) __asm__("FUN_00120478"); extern int print_debug_text_centered(int,int,int,char*) __asm__("FUN_001f0c50"); extern char D_L00_0015F0F0[]; extern s32 sprintf(char *, const char *, ...); -extern u8 D_0014C050[]; +#include "rnc/gameplay/state/game_globals.h" extern u8 D_L00_0015F444; extern u8 D_L00_0015F445; extern u8 D_L00_0015F446; @@ -1174,7 +1174,7 @@ void FUN_L00_001f58e0(void) { print_debug_text(0xB0, 0xD6, 0x8000C0C0, D_L00_0015F0E8); { int mission = debug_menu60.mission; - sprintf(buf, D_L00_0015F0F0, mission, (D_0014C050)[mission + D_0015ED84 * stride]); + sprintf(buf, D_L00_0015F0F0, mission, (visited52)[mission + D_0015ED84 * stride]); } print_debug_text(0x108, 0xD6, 0x80F0F0F0, buf); if (debug_menu60.group == 1) { diff --git a/src/overlays/shared/ui/help/001ff938.c b/src/overlays/shared/ui/help/001ff938.c index 4c2a4ddd5e..c7534c438c 100644 --- a/src/overlays/shared/ui/help/001ff938.c +++ b/src/overlays/shared/ui/help/001ff938.c @@ -4,147 +4,150 @@ #include "rnc/globals.h" #include "asm.h" -#ifndef NON_MATCHING -INCLUDE_ASM("config/us/overlays/asm/FUN_L15_001ff938.s", FUN_L15_001ff938); -#else #include "qcopy.h" -extern void FUN_L00_00232670(void); -extern void hero_update(void) __asm__("FUN_L00_00211670"); -extern void FUN_L15_002044c8(void); -extern void FUN_L15_0021d040(void); -extern void FUN_L00_00216f10(void); + +/* Ported from rac1-decomp (src/overlays/shared/help_001FFED0.c: func_L15_001FFED0), where it is exact; names translated to the US level program. */ + +extern f32 convert_integer_to_float(s32) __asm__("func_001FA6C0"); +extern f32 fast_sin(f32) __asm__("func_001F9DE0"); +extern float D_L15_0017C0EC, D_L15_0017C14C; +extern int D_L15_0015F5B0; +extern int D_L15_0015F5CC; +extern s32 scale_game_frames(s32) __asm__("func_001F96F8"); +extern s32 truncate_float_to_s32(f32) __asm__("func_001FA6D0"); +extern f32 D_0015EE18; +extern unsigned char D_0013D4DC[]; +extern unsigned char D_0013F350[]; +#include "rnc/gameplay/state/options.h" +extern float D_L15_0017C06C[]; +extern float D_L15_0017C1CC[]; +extern unsigned int fast_tween_color(float, unsigned int, unsigned int); extern void FUN_L00_002054e8(void); -extern void FUN_L00_00208a10(void); -extern void FUN_L00_00207c48(void); -extern void FUN_L00_00207a58(void); -extern void FUN_L00_002484e0(void *); extern void FUN_L00_002059d8(void); extern void FUN_L00_002061f0(void); -extern void moby_point_position(void *, int, void *) __asm__("FUN_L00_0024f7c8"); +extern void FUN_L00_00207a58(void); +extern void FUN_L00_00207c48(void); extern void FUN_L00_00207d00(void); -extern int scale_game_frames(int) __asm__("FUN_001f96f8"); -extern float convert_integer_to_float(int) __asm__("FUN_001fa6c0"); -extern float FUN_001fa6c0_inherited(void) __asm__("FUN_001fa6c0"); -extern float fast_sin(float) __asm__("FUN_001f9de0"); -extern int truncate_float_to_s32(float) __asm__("FUN_001fa6d0"); -extern u32 fast_tween_color(f32, u32, u32) __asm__("FUN_001fa6e0"); -extern void FUN_L00_00216de8(int, int); +extern void FUN_L00_00208a10(void); extern void FUN_L00_00208b60(void); +extern void hero_update(void) __asm__("FUN_L00_00211670"); +extern void FUN_L00_00216de8(int, int); +extern void FUN_L00_00216f10(void); +extern void FUN_L00_00232670(void); +extern void FUN_L00_002484e0(void *); +extern void moby_point_position(void *, int, void *) __asm__("FUN_L00_0024f7c8"); extern void FUN_L00_00257024(void *); -extern float D_L15_0017ACC0_d __asm__("D_L15_0017ACC0") __attribute__((section(".data"))); -extern unsigned char D_0013E533[]; -extern u8 D_0015EDB3; -extern u8 D_0015EDB1; -extern float D_0015EE18_gp __attribute__((sda)); -extern int D_L15_0015F5CC; -extern u8 D_0013D4DC[]; +extern void FUN_L15_002044c8(void); +extern void FUN_L15_0021d040(void); void FUN_L15_001ff938(void) { - u8 *moby; - struct Hero *base; - u32 copy[4] __attribute__((aligned(16))); + unsigned char *hero0, *hero1, *hero2, *hero3, *hero4, *hero5, *hero6; + unsigned char *hero_moby; + unsigned int copy[4] __attribute__((aligned(16))); int period, red, green, blue, alpha, i; - u32 color; + unsigned int color; float pulse; FUN_L00_00232670(); hero_update(); FUN_L15_002044c8(); FUN_L15_0021d040(); - if (hero.vehicle_mode == 0) + hero0 = ((char *)&D_0013F350); + if (hero0[0x20A4] == 0) return; FUN_L00_00216f10(); FUN_L00_002054e8(); - if (hero.vehicle_mode == 0) + if (hero0[0x20A4] == 0) return; FUN_L00_00208a10(); FUN_L00_00207c48(); FUN_L00_00207a58(); - FUN_L00_002484e0((u8 *)&hero + 0x80); + FUN_L00_002484e0(hero0 + 0x80); - if (hero.vehicle_mode == 2) { - if (D_0015EDB3 != 0) - *(float *)((u8 *)&D_L15_0017ACC0_d + 0x13AC) = D_0015EE18_gp * 1.4f; + if (hero0[0x20A4] == 2) { + if ((&big_head_cheat_enabled)[3] != 0) + D_L15_0017C06C[0] = D_0015EE18 * 1.4f; FUN_L00_002059d8(); FUN_L00_002061f0(); - if (((*(u16 *)((u8 *)hero.moby + 0x34) ^ 1) & 1) != 0) { - moby_point_position(hero.moby, 6, copy); - qcopy((u8 *)&hero + 0x1D80, copy); + { + unsigned char *hero_moby = *(unsigned char **)(hero0 + 0x2080); + if (((*(unsigned short *)(hero_moby + 0x34) ^ 1) & 1) != 0) { + moby_point_position(hero_moby, 6, copy); + qcopy(hero0 + 0x1D80, copy); FUN_L00_00207d00(); } + } } - base = &hero; - if (base->vehicle_mode == 3) { - { - struct Hero *base = (struct Hero *)(D_0013E533 + 0xE1D); - if (D_0015EDB1 != 0) - *(float *)((u8 *)&D_L15_0017ACC0_d + 0x150C) = 1.9f; - alpha = 0x80; - period = scale_game_frames(0xAA); - if (base->unk22E0 == 2) - period = scale_game_frames(0x32); - else if (base->unk22E0 == 1) - period = scale_game_frames(0x5A); - } + hero1 = ((char *)&D_0013F350); + if (hero1[0x20A4] == 3) { + if ((&big_head_cheat_enabled)[1] != 0) + D_L15_0017C1CC[0] = 1.9f; + alpha = 0x80; + period = scale_game_frames(0xAA); + if (*(short *)(hero1 + 0x22E0) == 2) + period = scale_game_frames(0x32); + else if (*(short *)(hero1 + 0x22E0) == 1) + period = scale_game_frames(0x5A); pulse = fast_sin((((float)(D_L15_0015F5CC % period) / convert_integer_to_float(period)) * 2.0f) * 3.1415927f + -3.1415927f); red = truncate_float_to_s32(pulse * 20.0f) + 0x32; green = truncate_float_to_s32(pulse * 70.0f) + 0xB4; - blue = truncate_float_to_s32(pulse * 10.0f) + 0x14; - if (green > 0xFF) green = 0xFF; + blue = truncate_float_to_s32(pulse * 10.0f); + hero2 = ((char *)&D_0013F350); + hero_moby = *(unsigned char **)(hero2 + 0x2080); if (red > 0xFF) red = 0xFF; - *(u16 *)((u8 *)hero.moby + 0x34) |= 0x10; - if (hero.unk22E0 == 2) { - u32 channels; - channels = (alpha << 24) | (blue << 16) | ((red / 2) << 8); - color = channels | green; - } else { - u32 channels; - channels = (alpha << 24) | (blue << 16) | (green << 8); - color = channels | red; - } - *(u32 *)((u8 *)hero.moby + 0x90) = fast_tween_color(0.1f, *(u32 *)((u8 *)hero.moby + 0x90), color); + if (green > 0xFF) green = 0xFF; + blue += 0x14; + *(unsigned short *)(hero_moby + 0x34) |= 0x10; + if (*(short *)(hero2 + 0x22E0) == 2) + color = (alpha << 24) | (blue << 16) | ((red / 2) << 8) | green; + else + color = (alpha << 24) | (blue << 16) | (green << 8) | red; + hero3 = ((char *)&D_0013F350); + *(unsigned int *)(*(unsigned char **)(hero3 + 0x2080) + 0x90) = + fast_tween_color(0.1f, *(unsigned int *)(*(unsigned char **)(hero3 + 0x2080) + 0x90), color); for (i = 0; i < 3; i++) - moby_point_position(hero.moby, i, (u8 *)&hero + 0x1D50 + i * 16); { - u32 color; - base = &hero; - alpha = 0x30; - moby = (u8 *)base->moby; - blue = moby[0x92]; - green = moby[0x91]; - red = moby[0x90]; - if (base->unk22DE != 0) - alpha = truncate_float_to_s32((convert_integer_to_float(base->unk22DE) / convert_integer_to_float(0x12)) * (float)alpha); - color = (alpha << 24) | (blue << 16) | (green << 8); - color |= red; - *(u32 *)((u8 *)base + 0x22E4) = color; - FUN_L00_00207d00(); - base->unk22E0 = 0; - if (base->vehicle_mode == 3) { - int pending = base->pending_item[0]; - if (pending != 0 && pending != 0x1F) { - if (base->unk22DE == 0) { - FUN_L00_00216de8(0x19, 0); - base->unk22DE = 0x12; - base->unk22DC = 1; - } - } else { - hero.pending_item[0] = 0; - if (hero.unk12E7 != 0 && *(int *)((u8 *)&hero + 0x300) != 0 && D_0013D4DC[0] != 0 && hero.unk22DE == 0) { - FUN_L00_00216de8(0x19, 0); - /* Keep this prompt path distinct and retain its ordered halfword stores. */ - hero.unk22DE = 0x12; - hero.unk22DC = 1; - } + hero4 = ((char *)&D_0013F350); + moby_point_position(*(void **)(hero4 + 0x2080), i, hero4 + 0x1D50 + i * 16); + } + alpha = 0x30; + hero4 = ((char *)&D_0013F350); + { + unsigned char *hero_moby = *(unsigned char **)(hero4 + 0x2080); + blue = hero_moby[0x92]; + green = hero_moby[0x91]; + red = hero_moby[0x90]; + } + if (*(short *)(hero4 + 0x22DE) != 0) + alpha = truncate_float_to_s32((convert_integer_to_float(*(short *)(hero4 + 0x22DE)) / convert_integer_to_float(0x12)) * (float)alpha); + *(unsigned int *)(hero4 + 0x22E4) = (alpha << 24) | (blue << 16) | (green << 8) | red; + FUN_L00_00207d00(); + *(short *)(hero4 + 0x22E0) = 0; + if (hero4[0x20A4] == 3) { + int pending = ((struct Hero *)hero4)->pending_item[0]; + if (pending != 0 && pending != 0x1F) { + if (*(short *)(hero4 + 0x22DE) == 0) { + FUN_L00_00216de8(0x19, 0); + *(short *)(hero4 + 0x22DE) = 0x12; + *(short *)(hero4 + 0x22DC) = 1; + } + } else { + hero5 = ((char *)&D_0013F350); + ((struct Hero *)hero5)->pending_item[0] = 0; + if (hero5[0x12E7] != 0 && *(int *)(hero5 + 0x300) != 0 && D_0013D4DC[0] != 0 && + *(short *)(hero5 + 0x22DE) == 0) { + FUN_L00_00216de8(0x19, 0); + *(short *)(hero5 + 0x22DE) = 0x12; + *(short *)(hero5 + 0x22DC) = 1; } } } } FUN_L00_00208b60(); - FUN_L00_00257024(hero.moby); + hero6 = ((char *)&D_0013F350); + FUN_L00_00257024(*(void **)(hero6 + 0x2080)); } -#endif #define NOT_SDA #define MACRO_ADDR @@ -153,11 +156,11 @@ void FUN_L15_001ff938(void) { /* Ported from rac1-decomp (src/overlays/shared/help_001FFED0.c: func_L15_00200D20), where it is exact; names translated to the US level program. */ extern unsigned char D_0013E05A[]; -extern unsigned char D_0013E533[]; +#include "rnc/data_labels.h" extern void FUN_L00_00207330(int, int); void FUN_L15_00200788(void) { - unsigned char *base = D_0013E533 + 0xE1D; + unsigned char *base = ((unsigned char *)&D_0013E533) + 0xE1D; int index = *(int *)(base + 0x10B8); if (index >= 0 && *(D_0013E05A + 0x4C6 + index) != 0) { int first = *(int *)(base + 0x1090); @@ -214,7 +217,7 @@ void mark_moby_for_removal(struct Obj *obj) __asm__("FUN_0020c828"); void set_animation_parameter(s32 arg0, s32 arg1) __asm__("FUN_001ff570"); void FUN_L15_00208ca8(void) { - unsigned char *base = D_0013E533 + 0xE1D; + unsigned char *base = ((unsigned char *)&D_0013E533) + 0xE1D; unsigned char *b; int p; void *q; @@ -227,7 +230,7 @@ void FUN_L15_00208ca8(void) { } } FUN_L00_00205538(); - b = D_0013E533 + 0xE1D; + b = ((unsigned char *)&D_0013E533) + 0xE1D; p = *(int *)(b + 0xA84); b[0x20A4] = 0; if (p != 0) { @@ -572,7 +575,7 @@ void FUN_L15_00215e58(void) { extern int hero_set_state(int, int) __asm__("FUN_L15_00216c38"); void FUN_L15_0021ab60(void) { - switch (D_0013E533[0x2EC1]) { + switch (((unsigned char *)&D_0013E533)[0x2EC1]) { case 0: hero_set_state(HERO_STATE_IDLE, 1); break; diff --git a/src/overlays/shared/ui/help/0021d0a0.c b/src/overlays/shared/ui/help/0021d0a0.c index fd343f67de..9fc27034e0 100644 --- a/src/overlays/shared/ui/help/0021d0a0.c +++ b/src/overlays/shared/ui/help/0021d0a0.c @@ -784,10 +784,10 @@ void FUN_L06_002348d0(void) { /* Ported from rac1-decomp (src/overlays/shared/help_0021D6B8.c: func_L06_00239CD0), where it is exact; names translated to the US level program. */ -extern unsigned char D_0013E533[]; +#include "rnc/data_labels.h" void FUN_L06_00239528(void) { - switch (D_0013E533[0x2EC1]) { + switch (((unsigned char *)&D_0013E533)[0x2EC1]) { case 0: hero_set_state(HERO_STATE_IDLE, 1); break; diff --git a/src/overlays/shared/ui/help/00237488.c b/src/overlays/shared/ui/help/00237488.c index 023fa3bffa..d355b06ed1 100644 --- a/src/overlays/shared/ui/help/00237488.c +++ b/src/overlays/shared/ui/help/00237488.c @@ -14,10 +14,10 @@ /* Ported from rac1-decomp (src/overlays/shared/help_00237B00.c: func_L05_00237B00), where it is exact; names translated to the US level program. */ extern f32 approach_value(f32 *, f32, f32) __asm__("FUN_00213ed8"); -extern unsigned char D_0013E533[]; +#include "rnc/data_labels.h" void FUN_L05_00237488(float *out, float *p, float step) { - char *g = (char *)D_0013E533 + 0xE1D; + char *g = (char *)((unsigned char *)&D_0013E533) + 0xE1D; float v[2]; v[0] = -*(float *)(g + 0x1D20); v[1] = *(float *)(g + 0x1D24); @@ -634,7 +634,6 @@ extern void FUN_L00_0029a6b0(void *); extern void FUN_L05_0024cee8(int, int); extern void FUN_L05_002d4168(void *, void *, void *, float, float); extern void tick_countdown_32(s32 *) __asm__("func_001F9740"); -extern char D_0013F350[]; extern PadState D_0013CA40_p2523C8 __asm__("D_0013C940"); extern int D_00141760_2523C8 __asm__("D_00141660") __attribute__((section(".data"))); extern unsigned char D_0013D5C8_2523C8[] __asm__("D_0013D4DC"); @@ -652,32 +651,32 @@ int FUN_L05_00251be8(void) { int start_timer; int mask; - if ((*(Hero *)D_0013F350).unk20AC != 0 && (*(Hero *)D_0013F350).items[0].item_id != 0x24 && ((*(Hero *)D_0013F350).items[0].item_id != 8 || (*(Hero *)D_0013F350).unk308 != 1)) { + if ((*(Hero *)((char *)&hero)).unk20AC != 0 && (*(Hero *)((char *)&hero)).items[0].item_id != 0x24 && ((*(Hero *)((char *)&hero)).items[0].item_id != 8 || (*(Hero *)((char *)&hero)).unk308 != 1)) { return 0; } - if ((*(Hero *)D_0013F350).vehicle_mode != 0) { + if ((*(Hero *)((char *)&hero)).vehicle_mode != 0) { return 0; } - if (((Moby *)(*(Hero *)D_0013F350).items[0].moby) == 0) { + if (((Moby *)(*(Hero *)((char *)&hero)).items[0].moby) == 0) { return 0; } - if ((*(Hero *)D_0013F350).items[0].state != 2) { + if ((*(Hero *)((char *)&hero)).items[0].state != 2) { return 0; } - start_timer = (*(Hero *)D_0013F350).state_timer; - mask = (*(Hero *)D_0013F350).items[0].button_mask; - switch ((*(Hero *)D_0013F350).items[0].item_id) { + start_timer = (*(Hero *)((char *)&hero)).state_timer; + mask = (*(Hero *)((char *)&hero)).items[0].button_mask; + switch ((*(Hero *)((char *)&hero)).items[0].item_id) { case 8: - if ((*(Hero *)D_0013F350).state.control_mode < 2U || ((*(Hero *)D_0013F350).state.control_mode == 4 && (*(Hero *)D_0013F350).unk418 != 0)) { + if ((*(Hero *)((char *)&hero)).state.control_mode < 2U || ((*(Hero *)((char *)&hero)).state.control_mode == 4 && (*(Hero *)((char *)&hero)).unk418 != 0)) { Moby *item; - if ((*(Hero *)D_0013F350).on_slip_ground != 0) { + if ((*(Hero *)((char *)&hero)).on_slip_ground != 0) { break; } if (!FUN_L00_00266d60(mask, scale_game_frames_alt(7), &press_time0)) { break; } - item = (Moby *)(*(Hero *)D_0013F350).items[0].moby; + item = (Moby *)(*(Hero *)((char *)&hero)).items[0].moby; if (item == 0) { break; } @@ -687,75 +686,75 @@ int FUN_L05_00251be8(void) { if (item->state != 0) { break; } - if ((D_0013CA40_p2523C8.held & 0xA) || (((*(Hero *)D_0013F350).state.current == 1 || (*(Hero *)D_0013F350).state.current == 0x1E) && (*(Hero *)D_0013F350).state_timer > scale_game_frames_alt(0x14))) { - if (((*(Hero *)D_0013F350).state.current == 1 || (*(Hero *)D_0013F350).state.current == 0x1E) && (*(Hero *)D_0013F350).state_timer > scale_game_frames_alt(0x14)) { + if ((D_0013CA40_p2523C8.held & 0xA) || (((*(Hero *)((char *)&hero)).state.current == 1 || (*(Hero *)((char *)&hero)).state.current == 0x1E) && (*(Hero *)((char *)&hero)).state_timer > scale_game_frames_alt(0x14))) { + if (((*(Hero *)((char *)&hero)).state.current == 1 || (*(Hero *)((char *)&hero)).state.current == 0x1E) && (*(Hero *)((char *)&hero)).state_timer > scale_game_frames_alt(0x14)) { FUN_L00_00217658(); break; } func_L05_0024D680_2523C8(0x15, 1); break; } - if ((*(Hero *)D_0013F350).unk308 == 1) { + if ((*(Hero *)((char *)&hero)).unk308 == 1) { func_L05_0024D680_2523C8(0x70, 1); } else { func_L05_0024D680_2523C8(0x13, 1); } break; } - if ((*(Hero *)D_0013F350).state.current == 7 || (*(Hero *)D_0013F350).state.current == 9 || (*(Hero *)D_0013F350).state.current == 8 || (*(Hero *)D_0013F350).state.current == 6 - || ((*(Hero *)D_0013F350).state.current == 0xE && (*(Hero *)D_0013F350).anim_frame > 32.0f) - || ((*(Hero *)D_0013F350).state.current == 0xB && (*(Hero *)D_0013F350).unk450 != 3 && (*(Hero *)D_0013F350).anim_frame > 18.0f) || ((*(Hero *)D_0013F350).state.current == 0xB && (*(Hero *)D_0013F350).unk450 == 3 && (*(Hero *)D_0013F350).anim_frame > 20.0f) - || (*(Hero *)D_0013F350).state.current == 0x2D || (*(Hero *)D_0013F350).state.current == 0x11) { - if ((*(Hero *)D_0013F350).state_timer > scale_game_frames_alt(0xA)) { + if ((*(Hero *)((char *)&hero)).state.current == 7 || (*(Hero *)((char *)&hero)).state.current == 9 || (*(Hero *)((char *)&hero)).state.current == 8 || (*(Hero *)((char *)&hero)).state.current == 6 + || ((*(Hero *)((char *)&hero)).state.current == 0xE && (*(Hero *)((char *)&hero)).anim_frame > 32.0f) + || ((*(Hero *)((char *)&hero)).state.current == 0xB && (*(Hero *)((char *)&hero)).unk450 != 3 && (*(Hero *)((char *)&hero)).anim_frame > 18.0f) || ((*(Hero *)((char *)&hero)).state.current == 0xB && (*(Hero *)((char *)&hero)).unk450 == 3 && (*(Hero *)((char *)&hero)).anim_frame > 20.0f) + || (*(Hero *)((char *)&hero)).state.current == 0x2D || (*(Hero *)((char *)&hero)).state.current == 0x11) { + if ((*(Hero *)((char *)&hero)).state_timer > scale_game_frames_alt(0xA)) { int window = scale_game_frames_alt(0xA); - if ((*(Hero *)D_0013F350).state.current == 0xB || (*(Hero *)D_0013F350).state.current == 0xE) { + if ((*(Hero *)((char *)&hero)).state.current == 0xB || (*(Hero *)((char *)&hero)).state.current == 0xE) { window = scale_game_frames_alt(0x12); } if (!FUN_L00_00266d60(mask, window, 0)) { break; } - if (((*(Hero *)D_0013F350).unk41E == 0 && (*(Hero *)D_0013F350).ground_distance > 0.1f) || ((*(Hero *)D_0013F350).unk41E != 0 && (*(Hero *)D_0013F350).ground_distance > 0.57f) - || ((*(Hero *)D_0013F350).state.current == 8 && (*(Hero *)D_0013F350).ground_distance > 0.57f)) { + if (((*(Hero *)((char *)&hero)).unk41E == 0 && (*(Hero *)((char *)&hero)).ground_distance > 0.1f) || ((*(Hero *)((char *)&hero)).unk41E != 0 && (*(Hero *)((char *)&hero)).ground_distance > 0.57f) + || ((*(Hero *)((char *)&hero)).state.current == 8 && (*(Hero *)((char *)&hero)).ground_distance > 0.57f)) { func_L05_0024D680_2523C8(0x14, 1); break; } - if ((*(Hero *)D_0013F350).on_slip_ground != 0) { + if ((*(Hero *)((char *)&hero)).on_slip_ground != 0) { break; } func_L05_0024D680_2523C8(0x13, 1); break; } } - if ((*(Hero *)D_0013F350).state.control_mode == 6) { - Rec2C_2523C8 *rec = &D_L05_0017C188_2523C8[(*(Hero *)D_0013F350).attack_record]; + if ((*(Hero *)((char *)&hero)).state.control_mode == 6) { + Rec2C_2523C8 *rec = &D_L05_0017C188_2523C8[(*(Hero *)((char *)&hero)).attack_record]; int window; - if ((*(Hero *)D_0013F350).state.current == 0x15) { - if ((*(Hero *)D_0013F350).state_timer > scale_game_frames_alt(0x1E)) { - if ((*(Hero *)D_0013F350).unkA9C != 0) { + if ((*(Hero *)((char *)&hero)).state.current == 0x15) { + if ((*(Hero *)((char *)&hero)).state_timer > scale_game_frames_alt(0x1E)) { + if ((*(Hero *)((char *)&hero)).unkA9C != 0) { break; } - if ((*(Hero *)D_0013F350).anim_frame >= (float)rec->f10 && (D_0013CA40_p2523C8.held & 0xA) && FUN_L00_00266d60(mask, scale_game_frames_alt(0xF), 0)) { + if ((*(Hero *)((char *)&hero)).anim_frame >= (float)rec->f10 && (D_0013CA40_p2523C8.held & 0xA) && FUN_L00_00266d60(mask, scale_game_frames_alt(0xF), 0)) { func_L05_0024D680_2523C8(0x15, 1); break; } } } - if ((*(Hero *)D_0013F350).unkA9C != 0) { + if ((*(Hero *)((char *)&hero)).unkA9C != 0) { break; } - if (!((*(Hero *)D_0013F350).anim_frame >= (float)rec->f10)) { + if (!((*(Hero *)((char *)&hero)).anim_frame >= (float)rec->f10)) { break; } - window = (truncate_float_to_s32((*(Hero *)D_0013F350).anim_frame) - rec->fC) * 2; + window = (truncate_float_to_s32((*(Hero *)((char *)&hero)).anim_frame) - rec->fC) * 2; if (window <= 0) { window = 1; } if (window > scale_game_frames_alt(0xF)) { window = scale_game_frames_alt(0xF); } - if ((*(Hero *)D_0013F350).on_slip_ground != 0) { + if ((*(Hero *)((char *)&hero)).on_slip_ground != 0) { break; } if (!FUN_L00_00266d60(mask, window, 0)) { @@ -765,7 +764,7 @@ int FUN_L05_00251be8(void) { func_L05_0024D680_2523C8(0x15, 1); break; } - if ((*(Hero *)D_0013F350).unk308 == 1) { + if ((*(Hero *)((char *)&hero)).unk308 == 1) { func_L05_0024D680_2523C8(0x70, 1); } else { func_L05_0024D680_2523C8(0x13, 1); @@ -779,26 +778,26 @@ int FUN_L05_00251be8(void) { FUN_L00_00221ee0(); FUN_L00_00222158(); window = scale_game_frames_alt(5); - if ((*(Hero *)D_0013F350).air_frames.s != 0) { + if ((*(Hero *)((char *)&hero)).air_frames.s != 0) { window = scale_game_frames_alt(8); } - if ((*(Hero *)D_0013F350).state.control_mode < 2U || (*(Hero *)D_0013F350).state.control_mode == 4 || (*(Hero *)D_0013F350).state.control_mode == 2 || (*(Hero *)D_0013F350).state.control_mode == 0xF - || (*(Hero *)D_0013F350).state.control_mode == 5 || (*(Hero *)D_0013F350).state.current == 0x1E) { - if (FUN_L00_00266d60(mask, window, 0) || ((D_0013CA40_p2523C8.held & mask) && (*(Hero *)D_0013F350).items[0].unk20 > scale_game_frames_alt(0xF))) { - if ((*(Hero *)D_0013F350).unk99E != 0) { - if ((*(Hero *)D_0013F350).unk968 != 0) { - if ((*(Hero *)D_0013F350).unk998 < (*(Hero *)D_0013F350).unk984) { - (*(Hero *)D_0013F350).unk968 = 0; + if ((*(Hero *)((char *)&hero)).state.control_mode < 2U || (*(Hero *)((char *)&hero)).state.control_mode == 4 || (*(Hero *)((char *)&hero)).state.control_mode == 2 || (*(Hero *)((char *)&hero)).state.control_mode == 0xF + || (*(Hero *)((char *)&hero)).state.control_mode == 5 || (*(Hero *)((char *)&hero)).state.current == 0x1E) { + if (FUN_L00_00266d60(mask, window, 0) || ((D_0013CA40_p2523C8.held & mask) && (*(Hero *)((char *)&hero)).items[0].unk20 > scale_game_frames_alt(0xF))) { + if ((*(Hero *)((char *)&hero)).unk99E != 0) { + if ((*(Hero *)((char *)&hero)).unk968 != 0) { + if ((*(Hero *)((char *)&hero)).unk998 < (*(Hero *)((char *)&hero)).unk984) { + (*(Hero *)((char *)&hero)).unk968 = 0; } else { - (*(Hero *)D_0013F350).unk99E = 0; + (*(Hero *)((char *)&hero)).unk99E = 0; } } - if ((*(Hero *)D_0013F350).unk99E != 0 && (*(Hero *)D_0013F350).unk1E6 == 0 && (*(Hero *)D_0013F350).state.current != 0x2C) { + if ((*(Hero *)((char *)&hero)).unk99E != 0 && (*(Hero *)((char *)&hero)).unk1E6 == 0 && (*(Hero *)((char *)&hero)).state.current != 0x2C) { func_L05_0024D680_2523C8(0x2C, 1); break; } } - if ((*(Hero *)D_0013F350).unk968 != 0 && (*(Hero *)D_0013F350).unk1E6 == 0) { + if ((*(Hero *)((char *)&hero)).unk968 != 0 && (*(Hero *)((char *)&hero)).unk1E6 == 0) { func_L05_0024D680_2523C8(0x24, 1); } } @@ -806,7 +805,7 @@ int FUN_L05_00251be8(void) { } break; case 31: - if ((*(Hero *)D_0013F350).vehicle_mode != 0) { + if ((*(Hero *)((char *)&hero)).vehicle_mode != 0) { break; } if (!FUN_L00_0020fe30_c()) { @@ -818,35 +817,35 @@ int FUN_L05_00251be8(void) { if (D_00141760_2523C8 != 0x1F) { break; } - if (((Moby *)(*(Hero *)D_0013F350).items[0].moby)->oclass != 0x1E3) { + if (((Moby *)(*(Hero *)((char *)&hero)).items[0].moby)->oclass != 0x1E3) { break; } - if ((*(Hero *)D_0013F350).unk22DE != 0) { + if ((*(Hero *)((char *)&hero)).unk22DE != 0) { break; } FUN_L00_00216de8(0x18, 0); - (*(Hero *)D_0013F350).unk22DE = 0x12; - (*(Hero *)D_0013F350).unk22DC = 1; + (*(Hero *)((char *)&hero)).unk22DE = 0x12; + (*(Hero *)((char *)&hero)).unk22DC = 1; break; case 32: - if ((*(Hero *)D_0013F350).state.control_mode < 3U || (*(Hero *)D_0013F350).state.control_mode == 4 || (*(Hero *)D_0013F350).state.control_mode == 5) { + if ((*(Hero *)((char *)&hero)).state.control_mode < 3U || (*(Hero *)((char *)&hero)).state.control_mode == 4 || (*(Hero *)((char *)&hero)).state.control_mode == 5) { if (FUN_L00_00266d60(mask, scale_game_frames_alt(8), 0)) { FUN_L00_0029a6b0(0); } } break; case 15: - if ((*(Hero *)D_0013F350).state.control_mode < 2U || (*(Hero *)D_0013F350).state.control_mode == 0xC || (*(Hero *)D_0013F350).state.control_mode == 2 || (*(Hero *)D_0013F350).state.control_mode == 4 - || (*(Hero *)D_0013F350).state.control_mode == 5 || (*(Hero *)D_0013F350).state.control_mode == 0xF || (*(Hero *)D_0013F350).state.current == 0x1E) { + if ((*(Hero *)((char *)&hero)).state.control_mode < 2U || (*(Hero *)((char *)&hero)).state.control_mode == 0xC || (*(Hero *)((char *)&hero)).state.control_mode == 2 || (*(Hero *)((char *)&hero)).state.control_mode == 4 + || (*(Hero *)((char *)&hero)).state.control_mode == 5 || (*(Hero *)((char *)&hero)).state.control_mode == 0xF || (*(Hero *)((char *)&hero)).state.current == 0x1E) { PVar_2523C8 *pv; - if (((Moby *)(*(Hero *)D_0013F350).items[0].moby) == 0) { + if (((Moby *)(*(Hero *)((char *)&hero)).items[0].moby) == 0) { break; } - pv = (PVar_2523C8 *)((Moby *)(*(Hero *)D_0013F350).items[0].moby)->pvars; - if (((D_0013CA40_p2523C8.held & mask) && (*(Hero *)D_0013F350).items[0].unk20 > scale_game_frames_alt(5)) || (D_0013CA40_p2523C8.pressed & mask)) { + pv = (PVar_2523C8 *)((Moby *)(*(Hero *)((char *)&hero)).items[0].moby)->pvars; + if (((D_0013CA40_p2523C8.held & mask) && (*(Hero *)((char *)&hero)).items[0].unk20 > scale_game_frames_alt(5)) || (D_0013CA40_p2523C8.pressed & mask)) { if (FUN_L00_00233e98(-1)) { - if ((*(Hero *)D_0013F350).unk20A8 == 0) { + if ((*(Hero *)((char *)&hero)).unk20A8 == 0) { FUN_L00_0020e4c8(); } break; @@ -854,8 +853,8 @@ int FUN_L05_00251be8(void) { } if (D_0013CA40_p2523C8.held & mask) { if (!FUN_L00_00233e98(-1)) { - if (!FUN_L00_0028d8c0((Moby *)(*(Hero *)D_0013F350).items[0].moby, pv->fC)) { - pv->fC = allocate_voice_for_target_entry_alt(0, 0, (int)((Moby *)(*(Hero *)D_0013F350).items[0].moby)); + if (!FUN_L00_0028d8c0((Moby *)(*(Hero *)((char *)&hero)).items[0].moby, pv->fC)) { + pv->fC = allocate_voice_for_target_entry_alt(0, 0, (int)((Moby *)(*(Hero *)((char *)&hero)).items[0].moby)); } } } @@ -866,45 +865,45 @@ int FUN_L05_00251be8(void) { case 20: case 24: case 25: - if (((*(Hero *)D_0013F350).state.control_mode == 0 && (*(Hero *)D_0013F350).state.current != 0x1E) || (*(Hero *)D_0013F350).state.control_mode == 1 || (*(Hero *)D_0013F350).state.control_mode == 0xC - || (*(Hero *)D_0013F350).state.control_mode == 5 || (*(Hero *)D_0013F350).state.control_mode == 0xF || ((*(Hero *)D_0013F350).state.control_mode == 4 && (*(Hero *)D_0013F350).unk4AC != 0) - || ((*(Hero *)D_0013F350).state.current == 0x23 && (*(Hero *)D_0013F350).anim_frame > 25.0f)) { + if (((*(Hero *)((char *)&hero)).state.control_mode == 0 && (*(Hero *)((char *)&hero)).state.current != 0x1E) || (*(Hero *)((char *)&hero)).state.control_mode == 1 || (*(Hero *)((char *)&hero)).state.control_mode == 0xC + || (*(Hero *)((char *)&hero)).state.control_mode == 5 || (*(Hero *)((char *)&hero)).state.control_mode == 0xF || ((*(Hero *)((char *)&hero)).state.control_mode == 4 && (*(Hero *)((char *)&hero)).unk4AC != 0) + || ((*(Hero *)((char *)&hero)).state.current == 0x23 && (*(Hero *)((char *)&hero)).anim_frame > 25.0f)) { int window; int held_frames; - if ((*(Hero *)D_0013F350).unk20A8 != 0) { + if ((*(Hero *)((char *)&hero)).unk20A8 != 0) { break; } window = scale_game_frames_alt(7); - held_frames = (*(Hero *)D_0013F350).items[0].unk20; + held_frames = (*(Hero *)((char *)&hero)).items[0].unk20; if (FUN_L00_00266d60(mask, window <= held_frames ? window : held_frames, &press_time1) || ((D_0013CA40_p2523C8.held & 0x20) && held_frames > scale_game_frames_alt(8) && held_frames < scale_game_frames_alt(0x11))) { if (FUN_L00_00233e98(-1)) { - if ((*(Hero *)D_0013F350).state.control_mode == 0xC || (*(Hero *)D_0013F350).state.control_mode == 0 || (*(Hero *)D_0013F350).state.current == 3 - || ((*(Hero *)D_0013F350).state.control_mode == 1 && (*(Hero *)D_0013F350).unk229C < 0.7f)) { + if ((*(Hero *)((char *)&hero)).state.control_mode == 0xC || (*(Hero *)((char *)&hero)).state.control_mode == 0 || (*(Hero *)((char *)&hero)).state.current == 3 + || ((*(Hero *)((char *)&hero)).state.control_mode == 1 && (*(Hero *)((char *)&hero)).unk229C < 0.7f)) { func_L05_0024D680_2523C8(0x23, 1); } else { FUN_L00_0020e4c8(); } break; } - if (((Moby *)(*(Hero *)D_0013F350).items[0].moby) != 0) { - allocate_voice_for_target_entry_alt(0, 0, (int)((Moby *)(*(Hero *)D_0013F350).items[0].moby)); + if (((Moby *)(*(Hero *)((char *)&hero)).items[0].moby) != 0) { + allocate_voice_for_target_entry_alt(0, 0, (int)((Moby *)(*(Hero *)((char *)&hero)).items[0].moby)); } } } break; case 18: - if ((*(Hero *)D_0013F350).state.control_mode < 2U || ((*(Hero *)D_0013F350).state.control_mode == 4 && (*(Hero *)D_0013F350).unk418 != 0)) { - if ((*(Hero *)D_0013F350).state.current != 1) { + if ((*(Hero *)((char *)&hero)).state.control_mode < 2U || ((*(Hero *)((char *)&hero)).state.control_mode == 4 && (*(Hero *)((char *)&hero)).unk418 != 0)) { + if ((*(Hero *)((char *)&hero)).state.current != 1) { int window = scale_game_frames_alt(0xA); - int held_frames = (*(Hero *)D_0013F350).items[0].unk20; + int held_frames = (*(Hero *)((char *)&hero)).items[0].unk20; if (FUN_L00_00266d60(mask, window <= held_frames ? window : held_frames, &press_time2)) { - if (((Moby *)(*(Hero *)D_0013F350).items[0].moby) != 0) { + if (((Moby *)(*(Hero *)((char *)&hero)).items[0].moby) != 0) { func_L05_0024D680_2523C8(0x20, 1); - if (((Moby *)(*(Hero *)D_0013F350).items[0].moby) != 0) { - allocate_voice_for_target_entry_alt(0, 0, (int)((Moby *)(*(Hero *)D_0013F350).items[0].moby)); + if (((Moby *)(*(Hero *)((char *)&hero)).items[0].moby) != 0) { + allocate_voice_for_target_entry_alt(0, 0, (int)((Moby *)(*(Hero *)((char *)&hero)).items[0].moby)); } } } @@ -912,7 +911,7 @@ int FUN_L05_00251be8(void) { } break; case 21: - if (((Moby *)(*(Hero *)D_0013F350).items[0].moby) != 0) { + if (((Moby *)(*(Hero *)((char *)&hero)).items[0].moby) != 0) { if (D_0013CA40_p2523C8.pressed & mask) { FUN_L00_0020e4c8(); } @@ -925,32 +924,32 @@ int FUN_L05_00251be8(void) { struct UsageStats *stats; int play_time, unit; - if ((*(Hero *)D_0013F350).unk8CE != 0) { + if ((*(Hero *)((char *)&hero)).unk8CE != 0) { if (D_00141D80[0] == 0 && D_00141920[0] == 0) { - if (++(*(Hero *)D_0013F350).unk8CA > (int)((float)scale_game_frames_alt(0x14) * 60.0f)) { + if (++(*(Hero *)((char *)&hero)).unk8CA > (int)((float)scale_game_frames_alt(0x14) * 60.0f)) { help_request(0x3E81, 0x83); } } } - item = (Moby *)(*(Hero *)D_0013F350).items[0].moby; + item = (Moby *)(*(Hero *)((char *)&hero)).items[0].moby; if (item == 0) { break; } - if (FUN_L00_001fefc8(&(*(Hero *)D_0013F350).unk8CF) == 2 && (*(Hero *)D_0013F350).unk8CE != 0) { - (*(Hero *)D_0013F350).unk8CE--; + if (FUN_L00_001fefc8(&(*(Hero *)((char *)&hero)).unk8CF) == 2 && (*(Hero *)((char *)&hero)).unk8CE != 0) { + (*(Hero *)((char *)&hero)).unk8CE--; } - if ((*(Hero *)D_0013F350).unk8CE == 0) { + if ((*(Hero *)((char *)&hero)).unk8CE == 0) { break; } - if ((*(Hero *)D_0013F350).unk8CF != 0) { + if ((*(Hero *)((char *)&hero)).unk8CF != 0) { break; } if (!FUN_L00_00266d60(mask, scale_game_frames_alt(7), 0)) { break; } best = 0; - if (((Moby *)(*(Hero *)D_0013F350).unk86C) != 0) { - PVar_2523C8 *pv = (PVar_2523C8 *)((Moby *)(*(Hero *)D_0013F350).unk86C)->pvars; + if (((Moby *)(*(Hero *)((char *)&hero)).unk86C) != 0) { + PVar_2523C8 *pv = (PVar_2523C8 *)((Moby *)(*(Hero *)((char *)&hero)).unk86C)->pvars; float best_score = 9999999.0f; int i; @@ -965,11 +964,11 @@ int FUN_L05_00251be8(void) { continue; } candidate = (Moby *)((char *)D_L05_00160098_2523C8 + (id << 8)); - yaw_error = fast_difference_between_rotations((*(Hero *)D_0013F350).motion.rot.f[2], fast_arc_tan(candidate->pos.x - (*(Hero *)D_0013F350).motion.pos.f[0], candidate->pos.y - (*(Hero *)D_0013F350).motion.pos.f[1])); + yaw_error = fast_difference_between_rotations((*(Hero *)((char *)&hero)).motion.rot.f[2], fast_arc_tan(candidate->pos.x - (*(Hero *)((char *)&hero)).motion.pos.f[0], candidate->pos.y - (*(Hero *)((char *)&hero)).motion.pos.f[1])); if (!(yaw_error > 0.7853982f)) { - pitch_error = fast_difference_between_rotations(fast_arc_tan(vector_distance_xy((*(Hero *)D_0013F350).motion.pos.f, &candidate->pos), candidate->pos.z - (*(Hero *)D_0013F350).motion.pos.f[2]), 0.0f); + pitch_error = fast_difference_between_rotations(fast_arc_tan(vector_distance_xy((*(Hero *)((char *)&hero)).motion.pos.f, &candidate->pos), candidate->pos.z - (*(Hero *)((char *)&hero)).motion.pos.f[2]), 0.0f); if (!(pitch_error > 0.7853982f)) { - distance = vector_distance_xy(&candidate->pos, (*(Hero *)D_0013F350).motion.pos.f); + distance = vector_distance_xy(&candidate->pos, (*(Hero *)((char *)&hero)).motion.pos.f); score = distance; score += distance * yaw_error * 2.0f; score += distance * pitch_error * 2.0f; @@ -984,7 +983,7 @@ int FUN_L05_00251be8(void) { } stats = &usage_stats; item->command = scale_game_frames_alt(7); - (*(Hero *)D_0013F350).unk8CF = scale_game_frames_alt(0x32); + (*(Hero *)((char *)&hero)).unk8CF = scale_game_frames_alt(0x32); if (stats->stat[27].count < 0xFFFF) { stats->stat[27].count++; } @@ -996,30 +995,30 @@ int FUN_L05_00251be8(void) { stats->stat[27].level_mask = stats->stat[27].level_mask | (1 << D_0015ED84_gp) | 0x80000000; allocate_voice_for_target_entry_alt(0, 0, (int)item); FUN_L00_0024f7c8(item, 0, joint_pos); - FUN_L05_002d4168(item, joint_pos, best, (*(Hero *)D_0013F350).motion.rot.f[2], (*(Hero *)D_0013F350).motion.rot.f[1]); + FUN_L05_002d4168(item, joint_pos, best, (*(Hero *)((char *)&hero)).motion.rot.f[2], (*(Hero *)((char *)&hero)).motion.rot.f[1]); } break; } - if ((*(Hero *)D_0013F350).state_timer == start_timer) { - if (FUN_L00_0020d498(3) == 3 && (*(Hero *)D_0013F350).state.current != 0x81 && ((*(Hero *)D_0013F350).unk308 == 0 || D_0013D5C8_2523C8[0] == 0) - && (*(Hero *)D_0013F350).unk22D8 == 0) { + if ((*(Hero *)((char *)&hero)).state_timer == start_timer) { + if (FUN_L00_0020d498(3) == 3 && (*(Hero *)((char *)&hero)).state.current != 0x81 && ((*(Hero *)((char *)&hero)).unk308 == 0 || D_0013D5C8_2523C8[0] == 0) + && (*(Hero *)((char *)&hero)).unk22D8 == 0) { func_001F9908_2523C8(&D_L05_0015F674_g); if (D_L05_0015F674_g != 0) { - if ((*(Hero *)D_0013F350).state.control_mode < 2U || (*(Hero *)D_0013F350).state.control_mode == 0xC - || (((*(Hero *)D_0013F350).state.control_mode == 2 || (*(Hero *)D_0013F350).state.control_mode == 4) && (*(Hero *)D_0013F350).grounded_frames != 0)) { + if ((*(Hero *)((char *)&hero)).state.control_mode < 2U || (*(Hero *)((char *)&hero)).state.control_mode == 0xC + || (((*(Hero *)((char *)&hero)).state.control_mode == 2 || (*(Hero *)((char *)&hero)).state.control_mode == 4) && (*(Hero *)((char *)&hero)).grounded_frames != 0)) { if ((D_0013CA40_p2523C8.held & 8) && (D_0013CA40_p2523C8.pressed & 8)) { func_L05_0024D680_2523C8(0x81, 1); } } } - if ((D_0013CA40_p2523C8.pressed & 8) && (*(Hero *)D_0013F350).state.current != 0x81) { + if ((D_0013CA40_p2523C8.pressed & 8) && (*(Hero *)((char *)&hero)).state.current != 0x81) { D_L05_0015F674_g = scale_game_frames_alt(0x1E); } - } else if ((*(Hero *)D_0013F350).state.current != 0x13 && (*(Hero *)D_0013F350).state.current != 0x81 && (*(Hero *)D_0013F350).state.current != 0x15 && (*(Hero *)D_0013F350).state.current != 0x16) { - (*(Hero *)D_0013F350).unk22CA = 0; + } else if ((*(Hero *)((char *)&hero)).state.current != 0x13 && (*(Hero *)((char *)&hero)).state.current != 0x81 && (*(Hero *)((char *)&hero)).state.current != 0x15 && (*(Hero *)((char *)&hero)).state.current != 0x16) { + (*(Hero *)((char *)&hero)).unk22CA = 0; } } - return (*(Hero *)D_0013F350).state_timer < start_timer; + return (*(Hero *)((char *)&hero)).state_timer < start_timer; } /* Hero idle: picks the idle animation from the stick direction, and occasionally plays a fidget or the * look-around when standing still. */ @@ -1327,13 +1326,12 @@ extern float vector_distance_xy_alt(void *, void *) __asm__("FUN_001f9b80"); extern char *D_L05_001B0930[]; /* no foreign declaration */ extern void clear_u64_value(void *) __asm__("func_001F99F8"); float absolute_float_c(float input) __asm__("func_001F99C0"); -extern char D_0013F350[]; extern char D_0013F3D0[]; extern int D_0015ED84; extern char *D_L05_001B0930[]; void FUN_L05_00254358(float *out, float *rot) { - char *g = (char *)((char *)&D_0013F350); + char *g = (char *)((char *)((char *)&hero)); char *m = *(char **)(g + 0x86C); char *path; float distance; @@ -1349,7 +1347,7 @@ void FUN_L05_00254358(float *out, float *rot) { distance = 9999999.0f; best = 0; for (i = 0; i < *(int *)path; i += 2) { - char *h = (char *)((char *)&D_0013F350); + char *h = (char *)((char *)((char *)&hero)); char *p = path + i * 16; float limit = 4.0f; float angle = fast_arc_tan_c(*(float *)(p + 0x10) - *(float *)(h + 0x80), *(float *)(p + 0x14) - *(float *)(h + 0x84)); @@ -1829,10 +1827,10 @@ int FUN_L05_00255208(void) { /* Ported from rac1-decomp (src/overlays/shared/help_00237B00.c: func_L05_0025BDA8), where it is exact; names translated to the US level program. */ extern char D_L05_0017C068[]; -extern unsigned char D_0013E533[]; +#include "rnc/data_labels.h" void FUN_L05_0025b538(void) { - char *g = (char *)D_0013E533 + 0xE1D; + char *g = (char *)((unsigned char *)&D_0013E533) + 0xE1D; int v = *(int *)(g + 0x86C); *(int *)(g + 0x2278) = 0; diff --git a/src/overlays/shared/ui/hud/hud_keep_visible.c b/src/overlays/shared/ui/hud/hud_keep_visible.c index e7e2094641..a3f1629f26 100644 --- a/src/overlays/shared/ui/hud/hud_keep_visible.c +++ b/src/overlays/shared/ui/hud/hud_keep_visible.c @@ -316,49 +316,49 @@ void FUN_L00_00236128(HudElem *e) { extern float star_init_limit0_gp __asm__("D_L00_0015F750") __attribute__((sda)); extern float star_init_limit1_gp __asm__("D_L00_0015F754") __attribute__((sda)); extern float star_init_limit2_gp __asm__("D_L00_0015F758") __attribute__((sda)); -#ifndef NON_MATCHING -INCLUDE_ASM("config/us/overlays/asm/FUN_L00_00236268.s", FUN_L00_00236268); -#else -typedef struct { float x, y, z, w; } E_236268; -extern E_236268 D_L00_0017E660_236268[] __asm__("D_L00_0017E660") __attribute__((section(".data"))); -extern int D_L00_0015F75C_236268 __asm__("D_L00_0015F75C") __attribute__((sda)); -void FUN_L00_00235d80_236268(void) __asm__("FUN_L00_00235d80"); -float FUN_002132a8_236268(float, float) __asm__("FUN_002132a8"); -void FUN_L00_00236268(void) { +/* Fills the 100 hud stars with random positions and drift. */ +/* Ported from rac1-decomp (src/overlays/shared/hud_00235960.c: func_L00_00236BF8), where it is exact; names translated to the US level program. */ + +extern f32 random_float_between(f32, f32) __asm__("FUN_002132a8"); +typedef struct { + float x, y, vx, vy; +} Star_236458; + +extern Star_236458 D_L00_0017E660[]; +extern int D_L00_0015F75C_gp __asm__("D_L00_0015F75C") __attribute__((sda)); + +void FUN_L00_00236268(HudElem *elem) { int i; - FUN_L00_00235d80_236268(); + float margin, lo, band, hi; + int bands; + + FUN_L00_00235d80(elem); for (i = 0; i < 100; i++) { - float margin, band, lo, hi; - int bands; - float *depth; - if (i < 10) margin = star_init_limit0_gp; - else if (i < 20) margin = star_init_limit1_gp; - else margin = star_init_limit2_gp; - bands = D_L00_0015F75C_236268; - band = 232.0f; - lo = 116.0f; - band = (band - (margin + margin)) / (float)bands; - lo = (margin - lo) + (float)(i % bands) * band; + margin = star_init_limit0_gp; + if (i >= 10) { + margin = star_init_limit1_gp; + if (i >= 20) margin = star_init_limit2_gp; + } + bands = D_L00_0015F75C_gp; + band = (232.0f - (margin + margin)) / (float)bands; + lo = (margin - 116.0f) + (float)(i % bands) * band; hi = lo + band; - depth = &D_L00_0017E660_236268[i].z; - D_L00_0017E660_236268[i].x = FUN_002132a8_236268(margin - 17.0f, 17.0f - margin); - D_L00_0017E660_236268[i].y = FUN_002132a8_236268(lo, hi); - *depth = FUN_002132a8_236268(-0.4f, 0.4f); - D_L00_0017E660_236268[i].w = FUN_002132a8_236268(-0.6f, 0.6f); - *depth += FUN_002132a8_236268(-0.4f, 0.4f); - D_L00_0017E660_236268[i].w += FUN_002132a8_236268(-0.6f, 0.6f); - *depth += FUN_002132a8_236268(-0.4f, 0.4f); - D_L00_0017E660_236268[i].w += FUN_002132a8_236268(-0.6f, 0.6f); + D_L00_0017E660[i].x = random_float_between(margin - 17.0f, 17.0f - margin); + D_L00_0017E660[i].y = random_float_between(lo, hi); + D_L00_0017E660[i].vx = random_float_between(-0.4f, 0.4f); + D_L00_0017E660[i].vy = random_float_between(-0.6f, 0.6f); + D_L00_0017E660[i].vx += random_float_between(-0.4f, 0.4f); + D_L00_0017E660[i].vy += random_float_between(-0.6f, 0.6f); + D_L00_0017E660[i].vx += random_float_between(-0.4f, 0.4f); + D_L00_0017E660[i].vy += random_float_between(-0.6f, 0.6f); } + /* Fakematch: keeping bands live past the loop gives retail's schedule of the loop body. */ + bands++; + bands--; } -#endif -typedef struct { - float x, y, vx, vy; -} Star_236458; extern int D_L00_0015F3F8; -extern Star_236458 D_L00_0017E660[]; void FUN_L00_00235ea0(); /* Moves every other star by its velocity and bounces it off a box whose size diff --git a/src/overlays/shared/ui/map/0024e7a8.c b/src/overlays/shared/ui/map/0024e7a8.c index 76c3e22286..a2c74608eb 100644 --- a/src/overlays/shared/ui/map/0024e7a8.c +++ b/src/overlays/shared/ui/map/0024e7a8.c @@ -4,14 +4,14 @@ extern u8 *D_L00_0015FFDC; extern u8 *D_L00_0015FFE0; -extern u32 D_L00_0015F5CC; +#include "rnc/overlay/level_labels.h" extern s32 D_L00_0015FFBC; void FUN_L00_0024e7a8(void) { u8 *p; s32 flag = 0; D_L00_0015FFBC = 0; for (p = D_L00_0015FFDC; p < D_L00_0015FFE0; p += 0x100) { - if ((p[0x20] >= 0xFE && D_L00_0015F5CC >= *(u64 *)(p + 0x38)) || flag) { + if ((p[0x20] >= 0xFE && (*(u32 *)&D_L00_0015F5CC) >= *(u64 *)(p + 0x38)) || flag) { D_L00_0015FFBC++; if (p[0x20] == 0xFF) flag = 1; diff --git a/src/overlays/shared/ui/text/002377b8.c b/src/overlays/shared/ui/text/002377b8.c index bbab3c374d..243f05271c 100644 --- a/src/overlays/shared/ui/text/002377b8.c +++ b/src/overlays/shared/ui/text/002377b8.c @@ -327,214 +327,199 @@ void FUN_L00_00237ba0(Obj *p) { D_L00_0015FA94 = D_L00_0015F3F8; } } -#ifndef NON_MATCHING -INCLUDE_ASM("config/us/overlays/asm/FUN_L00_002382a0.s", FUN_L00_002382a0); -#else -extern s32 D_L00_0015F5CC; -extern s32 D_L00_0015F718_gp __asm__("D_L00_0015F718") __attribute__((sda)); -extern s32 D_L00_0015F71C_gp __asm__("D_L00_0015F71C") __attribute__((sda)); -extern s32 D_L00_0015F720 __attribute__((sda)); -extern s32 D_L00_0015F724 __attribute__((sda)); -extern s32 D_L00_0015F72C __attribute__((sda)); -extern s32 D_L00_0015F780_gp __asm__("D_L00_0015F780") __attribute__((sda)); -extern s32 D_L00_0015F7B0 __attribute__((sda)); -extern f32 D_L00_0015F78C __attribute__((sda)); -extern f32 D_L00_0015F7C0 __attribute__((sda)); -extern f32 D_L00_0015F7C4 __attribute__((sda)); -extern s32 D_L00_0015F790 __attribute__((sda)); -extern s32 D_L00_0015F794 __attribute__((sda)); -extern s32 D_L00_0015F798 __attribute__((sda)); -extern s32 D_L00_0015F79C __attribute__((sda)); -extern s32 D_L00_0015F7A0 __attribute__((sda)); -extern s32 D_L00_0015F7A4 __attribute__((sda)); -extern s32 D_L00_0015F7A8 __attribute__((sda)); -extern s32 D_L00_0015F7AC __attribute__((sda)); -extern s32 D_L00_0015F7B4 __attribute__((sda)); -extern s32 D_L00_0015F7B8 __attribute__((sda)); -extern s32 D_L00_0015F7BC __attribute__((sda)); -extern s32 D_L00_0015FA90; -extern Ent **D_L00_0015FAC0_c __asm__("D_L00_0015FAC0"); -extern s32 D_L00_0017E504; -extern s32 pause_iop_sprite_lists[] __asm__("D_00141EA0"); -extern E00237ae8 D_L00_00179AC0[]; -extern u8 D_0013E520[]; +/* Ported from rac1-decomp (src/overlays/shared/hud_00235960.c: func_L00_00238C30), where it is exact; names translated to the US level program. */ + + + +typedef struct { int id; char pad[0x14]; int item; } E_238C30; + +typedef struct { char pad[0x46]; short h46, h48; char pad4A[2]; } TI_238C30; + +extern unsigned char D_00141EA0[]; +extern E00237ae8 item_defs[] __asm__("D_L00_00179AC0"); +extern char *get_help_message_text(s32) __asm__("func_001FDD10"); +#include "rnc/overlay/level_labels.h" extern char D_L00_0015F7C8[]; -extern f32 convert_integer_to_float(s32) __asm__("FUN_001fa6c0"); -extern s32 truncate_float_to_s32(f32) __asm__("FUN_001fa6d0"); -extern f32 fast_sin(f32) __asm__("FUN_001f9de0"); -extern f32 fast_cos(f32) __asm__("FUN_001f9dc8"); -extern f32 fast_add_rotations(f32, f32) __asm__("FUN_001fa580"); -extern s32 fast_tween_color_alpha_first(f32, s32, s32) __asm__("FUN_001fa6e0"); -extern s32 get_icon_frame(s32, s32) __asm__("FUN_001ff960"); -extern void draw_hud_sprite(s32, s32, s32, s32, s32, s32) __asm__("FUN_001ffc30"); -extern void draw_hud_icon(void *, s32, s32, s32, s32, s32) __asm__("FUN_L00_0023b120"); -extern int font_print_center_2382a0(s32, s32, s32, const char *, s32) __asm__("FUN_001f6af0"); -extern const char *get_text(s32) __asm__("FUN_001fdd10"); -extern s32 strlen_alt(const char *) __asm__("FUN_001166cc"); -extern s32 sprintf_alt(char *, const char *, ...) __asm__("FUN_00116248"); -extern s32 FUN_L00_00235a70(char *, s32 *, s32 *); +extern f32 convert_integer_to_float_c2(s32) __asm__("func_001FA6C0"); +extern f32 fast_cos(f32) __asm__("func_001F9DC8"); +extern f32 fast_sin(f32) __asm__("func_001F9DE0"); +extern float fast_add_rotations_c(float, float) __asm__("func_001FA580"); +extern void * D_L00_0015FAC0; +extern s32 fast_tween_color_c(s32, s32, f32) __asm__("func_001FA6E0"); +extern s32 font_print_center(s32, s32, s64, char *, s32) __asm__("func_001F6AF0"); +extern s32 sprintf(char *, const char *, ...); +extern s32 truncate_float_to_s32_c2(f32) __asm__("func_001FA6D0"); +extern int D_L00_0015F718_gp __asm__("D_L00_0015F718") __attribute__((sda)); +extern int D_L00_0015F71C_gp __asm__("D_L00_0015F71C") __attribute__((sda)); +extern int D_L00_0015F720_gp __asm__("D_L00_0015F720") __attribute__((sda)); +extern int D_L00_0015F724_gp __asm__("D_L00_0015F724") __attribute__((sda)); +extern int D_L00_0015F72C_gp __asm__("D_L00_0015F72C") __attribute__((sda)); +extern int D_L00_0015F780_gp __asm__("D_L00_0015F780") __attribute__((sda)); +extern float D_L00_0015F78C_gp __asm__("D_L00_0015F78C") __attribute__((sda)); +extern int D_L00_0015F790_gp __asm__("D_L00_0015F790") __attribute__((sda)); +extern int D_L00_0015F794_gp __asm__("D_L00_0015F794") __attribute__((sda)); +extern int D_L00_0015F798_gp __asm__("D_L00_0015F798") __attribute__((sda)); +extern int D_L00_0015F79C; +extern int D_L00_0015F7A0_gp __asm__("D_L00_0015F7A0") __attribute__((sda)); +extern int D_L00_0015F7A4_gp __asm__("D_L00_0015F7A4") __attribute__((sda)); +extern int D_L00_0015F7A8_gp __asm__("D_L00_0015F7A8") __attribute__((sda)); +extern int D_L00_0015F7AC; +extern int D_L00_0015F7B0_gp __asm__("D_L00_0015F7B0") __attribute__((sda)); +extern int D_L00_0015F7B4; +extern int D_L00_0015F7B8; +extern int D_L00_0015F7BC_gp __asm__("D_L00_0015F7BC") __attribute__((sda)); +extern float D_L00_0015F7C0; +extern float D_L00_0015F7C4_gp __asm__("D_L00_0015F7C4") __attribute__((sda)); +extern u32 strlen(const char *); +extern unsigned char D_0013E520[]; +extern void FUN_L00_0023b120(char *, int, int, int, int, int); +extern void draw_hud_sprite_c2(s32, s32, s32, s32, s32, s32) __asm__("func_001FFC30"); +int FUN_L00_00235a70_c3(HudElem *rec, int *x, int *y) __asm__("FUN_L00_00235a70"); + -typedef struct { u8 pad[0x46]; s16 h46, h48; u8 pad4A[2]; } TitleItem_2382a0; -s32 FUN_L00_002382a0(char *rec) { - s32 x, y, half_w, half_h, alpha; - s32 marker_alpha; - s32 i, icon_x, icon_y, selected; - s32 entry_offset; - s32 marker_offset; - s32 normal_offset; - s32 color, shadow, text_y, id, item, prefix_length, text_length, j; - f32 open, fade, angle; +int FUN_L00_002382a0(HudElem *rec) { + char *weapon_entry; + int x, y, half_w, half_h, alpha; + int marker_alpha; + int i, icon_x, icon_y, selected; + int color, shadow, text_y, id, item, prefix_length, text_length, j; + float open, fade, angle; const char *text, *suffix; - Ent *entry; - u8 *q = (u8 *)rec + 0x70; + unsigned char *counters = rec->cnt; char formatted[80]; - open = convert_integer_to_float(q[0]) / convert_integer_to_float(D_L00_0015F780_gp); + open = convert_integer_to_float_c2(counters[0]) / convert_integer_to_float_c2(D_L00_0015F780_gp); if (1.0f < open) open = 1.0f; else if (open < 0.0f) open = 0.0f; - fade = convert_integer_to_float(q[1]) / convert_integer_to_float(D_L00_0015F780_gp); + fade = convert_integer_to_float_c2(counters[1]) / convert_integer_to_float_c2(D_L00_0015F780_gp); if (1.0f < fade) fade = 1.0f; else if (fade < 0.0f) fade = 0.0f; - i = 0; { - f32 phase, angle, radius; - phase = convert_integer_to_float(D_L00_0015F5CC % D_L00_0015F7B0); - phase /= convert_integer_to_float(D_L00_0015F7B0); + float phase, angle, radius; + phase = convert_integer_to_float_c2(D_L00_0015F5CC % D_L00_0015F7B0_gp); + phase /= convert_integer_to_float_c2(D_L00_0015F7B0_gp); phase *= 6.28318f; angle = fast_sin(phase - 3.14159f); radius = open * 128.0f; - alpha = truncate_float_to_s32(radius); + alpha = truncate_float_to_s32_c2(radius); angle *= 0.125f; angle += 0.875f; - marker_alpha = truncate_float_to_s32(radius * angle); + marker_alpha = truncate_float_to_s32_c2(radius * angle); } - x = *(s32 *)(rec + 0x50); - y = *(s32 *)(rec + 0x54); - FUN_L00_00235a70(rec, &x, &y); + x = rec->unk50; + y = rec->unk54; + FUN_L00_00235a70_c3(rec, &x, &y); half_w = D_L00_0015F718_gp / 2; half_h = D_L00_0015F71C_gp / 2; - draw_hud_sprite(get_icon_frame(0xe934, 0), x, y, half_w, half_h, alpha); - draw_hud_sprite(get_icon_frame(0xe934, 0), x + D_L00_0015F718_gp, - y + D_L00_0015F71C_gp, -half_w, -half_h, alpha); - draw_hud_sprite(get_icon_frame(0xe934, 0), x + D_L00_0015F718_gp, - y, -half_w, half_h, alpha); - draw_hud_sprite(get_icon_frame(0xe934, 0), x, - y + D_L00_0015F71C_gp, half_w, -half_h, alpha); - if (D_L00_0015FA90 > 0) { - entry_offset = 0; - normal_offset = 0; - marker_offset = 0; - for (; i < D_L00_0015FA90; i++) { - angle = fast_add_rotations(((f32)i + (f32)i) * 3.1415927f / - (f32)D_L00_0015FA90 - 3.1415927f, 1.5707964f); - icon_x = x + D_L00_0015F720 + - (s32)(D_L00_0015F78C * fast_cos(angle) * D_L00_0015F7C4); - icon_y = y + D_L00_0015F724 + - (s32)(D_L00_0015F78C * fast_sin(angle)); - if (*(s32 *)(rec + 0x74) == i && - ((Ent *)(marker_offset + (s32)D_L00_0015FAC0_c[D_L00_0015F72C]))->unk0 != 0) - draw_hud_sprite(get_icon_frame(0xe99c, 0), icon_x - 0x13, - icon_y - 0x13, 0x26, 0x26, marker_alpha); - if (((Ent *)(normal_offset + (s32)D_L00_0015FAC0_c[D_L00_0015F72C]))->unk0 != 0) { - s32 icon_alpha; - if (i != *(s32 *)(rec + 0x74)) - icon_alpha = truncate_float_to_s32((f32)alpha * D_L00_0015F7C0); - else - icon_alpha = alpha; - entry = D_L00_0015FAC0_c[D_L00_0015F72C]; - entry = (Ent *)(entry_offset + (s32)entry); - draw_hud_icon(rec, get_icon_frame(entry->unk0, - D_0013E520[entry->unk18] ? 4 : 0), icon_x, icon_y, 1, icon_alpha); - } - entry_offset += 0x1c; - normal_offset += 0x1c; - marker_offset += 0x1c; + draw_hud_sprite_c2(find_valid_animation_frame_index_alt(0xe934, 0), x, y, half_w, half_h, alpha); + draw_hud_sprite_c2(find_valid_animation_frame_index_alt(0xe934, 0), x + D_L00_0015F718_gp, + y + D_L00_0015F71C_gp, -half_w, -half_h, alpha); + draw_hud_sprite_c2(find_valid_animation_frame_index_alt(0xe934, 0), x + D_L00_0015F718_gp, + y, -half_w, half_h, alpha); + draw_hud_sprite_c2(find_valid_animation_frame_index_alt(0xe934, 0), x, + y + D_L00_0015F71C_gp, half_w, -half_h, alpha); + for (i = 0; i < D_L00_0015FA90; i++) { + angle = fast_add_rotations_c(((float)i + (float)i) * 3.1415927f / + (float)D_L00_0015FA90 - 3.1415927f, 1.5707964f); + icon_x = x + D_L00_0015F720_gp + + (int)(D_L00_0015F78C_gp * fast_cos(angle) * D_L00_0015F7C4_gp); + icon_y = y + D_L00_0015F724_gp + + (int)(D_L00_0015F78C_gp * fast_sin(angle)); + if (rec->unk74 == i && ((E_238C30 **)D_L00_0015FAC0)[D_L00_0015F72C_gp][i].id != 0) + draw_hud_sprite_c2(find_valid_animation_frame_index_alt(0xe99c, 0), icon_x - 0x13, + icon_y - 0x13, 0x26, 0x26, marker_alpha); + if (((E_238C30 **)D_L00_0015FAC0)[D_L00_0015F72C_gp][i].id != 0) { + int icon_alpha; + if (i != rec->unk74) + icon_alpha = truncate_float_to_s32_c2((float)alpha * D_L00_0015F7C0); + else + icon_alpha = alpha; + FUN_L00_0023b120((char *)rec, find_valid_animation_frame_index_alt(((E_238C30 **)D_L00_0015FAC0)[D_L00_0015F72C_gp][i].id, + ((unsigned char *)D_0013E520)[((E_238C30 **)D_L00_0015FAC0)[D_L00_0015F72C_gp][i].item] ? 4 : 0), icon_x, icon_y, 1, icon_alpha); } } - selected = *(s32 *)(rec + 0x74); - if (selected >= 0 && D_L00_0015FAC0_c[D_L00_0015F72C][selected].unk0 != 0) { - f32 opacity; - open *= fade; - opacity = open; - color = fast_tween_color_alpha_first(opacity, D_L00_0015F798, D_L00_0015F79C); - id = pause_iop_sprite_lists[selected]; - if (D_L00_001C40B0[id].h8 != 0) { - s32 shadow, item; + selected = rec->unk74; + if (selected >= 0 && *(int *)(((char **)D_L00_0015FAC0)[D_L00_0015F72C_gp] + selected * 0x1C) != 0) { + color = fast_tween_color_c(D_L00_0015F798_gp, D_L00_0015F79C, open * fade); + { + int id; + id = *(int *)((char *)D_00141EA0 + selected * 4); + weapon_entry = ((char *)&D_L00_001C40B0) + id * 24; + if (*(unsigned short *)(weapon_entry + 8) != 0) { + int shadow, item; item = weapon_ammo_counts[id]; - sprintf_alt(formatted, D_L00_0015F7C8, item, D_L00_001C40B0[id].hE); + sprintf(formatted, D_L00_0015F7C8, item, *(unsigned short *)(weapon_entry + 0xE)); if (item != 0) - shadow = fast_tween_color_alpha_first(opacity, D_L00_0015F7A8, D_L00_0015F7AC); + shadow = fast_tween_color_c(D_L00_0015F7A8_gp, D_L00_0015F7AC, open * fade); else - shadow = fast_tween_color_alpha_first(opacity, D_L00_0015F7A0, D_L00_0015F7A4); - font_print_center_2382a0(x + D_L00_0015F720 + 1, y + D_L00_0015F724 + 13, color, formatted, -1); - font_print_center_2382a0(x + D_L00_0015F720, y + D_L00_0015F724 + 12, shadow, formatted, -1); + shadow = fast_tween_color_c(D_L00_0015F7A0_gp, D_L00_0015F7A4_gp, open * fade); + font_print_center(x + D_L00_0015F720_gp + 1, y + D_L00_0015F724_gp + 13, color, formatted, -1); + font_print_center(x + D_L00_0015F720_gp, y + D_L00_0015F724_gp + 12, shadow, formatted, -1); + } } prefix_length = 0; - shadow = fast_tween_color_alpha_first(opacity, D_L00_0015F790, D_L00_0015F794); + shadow = fast_tween_color_c(D_L00_0015F790_gp, D_L00_0015F794_gp, open * fade); { - s32 item, id; - item = D_L00_0015FAC0_c[D_L00_0015F72C][selected].unk18; - if (D_0013E520[item]) - id = ((TitleItem_2382a0 *)D_L00_00179AC0)[item].h48; + int item, id; + item = *(int *)(((char **)D_L00_0015FAC0)[D_L00_0015F72C_gp] + selected * 0x1C + 0x18); + if (((unsigned char *)D_0013E520)[item]) + id = ((TI_238C30 *)item_defs)[item].h48; else - id = ((TitleItem_2382a0 *)D_L00_00179AC0)[item].h46; - text = get_text(id); + id = ((TI_238C30 *)item_defs)[item].h46; + text = get_help_message_text(id); } - if (text == 0) goto out; - if (strlen_alt(text) == 0) goto out; - text_length = strlen_alt(text); + if (text == 0) return rec->w; + if (strlen((char *)text) == 0) return rec->w; + text_length = strlen((char *)text); suffix = text; - j = 0; - if (text_length > 0) { - suffix = text + 1; - if ((u8)text[1] == '-') { - suffix = text + 2; - prefix_length = 2; - } else { - while (j + 1 < text_length) { - j++; - suffix++; - if (*(const u8 *)suffix == '-') { - prefix_length = j + 2; - suffix++; - break; - } - } + for (j = 0; j < text_length; j++) { + suffix++; + if (*(const unsigned char *)suffix == '-') { + suffix++; + /* Fakematch: touching the frame counter here gives retail's register order for the text position. */ + D_L00_0015F5CC++; + D_L00_0015F5CC--; + prefix_length = j + 2; + break; } } if (prefix_length == 0) { suffix = text; for (j = 0; j < text_length; j++) { suffix++; - if (*(const u8 *)suffix == ' ') { + if (*(const unsigned char *)suffix == ' ') { suffix++; prefix_length = j + 1; break; } } } - text_y = y + D_L00_0015F724; - if (D_L00_001C40B0[pause_iop_sprite_lists[selected]].h8 != 0) + text_y = y + D_L00_0015F724_gp; + { + int id; + char *weapon_entry; + id = *(int *)((char *)D_00141EA0 + selected * 4); + weapon_entry = ((char *)&D_L00_001C40B0) + id * 24; + if (*(unsigned short *)(weapon_entry + 8) != 0) text_y += D_L00_0015F7B4; else if (prefix_length != 0) text_y += D_L00_0015F7B8; else - text_y += D_L00_0015F7BC; + text_y += D_L00_0015F7BC_gp; + } if (prefix_length != 0) { - font_print_center_2382a0(x + D_L00_0015F720 + 1, text_y + 1, color, text, prefix_length); - font_print_center_2382a0(x + D_L00_0015F720, text_y, shadow, text, prefix_length); + font_print_center(x + D_L00_0015F720_gp + 1, text_y + 1, color, (void *)text, prefix_length); + font_print_center(x + D_L00_0015F720_gp, text_y, shadow, (void *)text, prefix_length); text_y += 16; - font_print_center_2382a0(x + D_L00_0015F720 + 1, text_y + 1, color, suffix, -1); - font_print_center_2382a0(x + D_L00_0015F720, text_y, shadow, suffix, -1); + font_print_center(x + D_L00_0015F720_gp + 1, text_y + 1, color, (void *)suffix, -1); + font_print_center(x + D_L00_0015F720_gp, text_y, shadow, (void *)suffix, -1); } else { - font_print_center_2382a0(x + D_L00_0015F720 + 1, text_y + 1, color, text, -1); - font_print_center_2382a0(x + D_L00_0015F720, text_y, shadow, text, -1); + font_print_center(x + D_L00_0015F720_gp + 1, text_y + 1, color, (void *)text, -1); + font_print_center(x + D_L00_0015F720_gp, text_y, shadow, (void *)text, -1); } } -out: - return *(s32 *)(rec + 0x58); + return rec->w; } -#endif extern int D_L00_0015FA90; extern void *D_L00_0015FAC0; extern int D_L00_0015F718_gp __asm__("D_L00_0015F718") __attribute__((sda)); @@ -724,7 +709,7 @@ extern float func_001FA748_239918(float, float) __asm__("FUN_001fa580"); extern int func_00200198_239918(int, int) __asm__("FUN_001ff960"); extern void func_00200468_239918(int, int, int, int, int, int) __asm__("FUN_001ffc30"); extern void func_L00_0023BAB8_239918(void *, int, int, int, int, int) __asm__("FUN_L00_0023b120"); -extern int func_001FE540_239918(int) __asm__("FUN_001fdd10"); +extern int get_text(int) __asm__("FUN_001fdd10"); extern int func_00116810_239918(int) __asm__("FUN_001166cc"); extern int func_001FA8A8_239918(int, int, float) __asm__("FUN_001fa6e0"); extern int func_001F6EA8_239918(int, int, int, int, int) __asm__("FUN_001f6af0"); @@ -803,7 +788,7 @@ int FUN_L00_00238f88(Elem_239918 *element) { if (selected >= 0 && D_L00_0015FAC0_c2[D_L00_0015F72C][selected].unk0 != 0) { text_ids = D_L00_0015F8C0_239918; if (D_L00_0015FAC0_c2[D_L00_0015F72C][selected].unk0 != 0) { - text = func_001FE540_239918(text_ids.v[selected]); + text = get_text(text_ids.v[selected]); if (text != 0 && func_00116810_239918(text) != 0) { float fade = text_fade * open_fade; color = func_001FA8A8_239918(D_L00_0015F7D4, D_L00_0015F7D8, fade);