From ced7fe01a1e7894d75b38568c642b056189841c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Fri, 16 Oct 2026 19:04:33 +0000 Subject: [PATCH 01/33] overlay: decompile five level functions from rac1-decomp ports FUN_L00_002caf70, FUN_L00_002464a8, FUN_L10_002be858, FUN_L07_0030f5f0 and FUN_L08_002e3870 now match retail. --- .../l07/gameplay/entities/taxi_platform.c | 809 +++++++++++------- .../l08/gameplay/entities/bolt_thief.c | 742 ++++++++-------- src/overlays/l10/gameplay/entities/platform.c | 243 +++--- src/overlays/shared/gameplay/entities/bomb.c | 297 +++---- src/overlays/shared/rendering/00245c28.c | 279 +++--- 5 files changed, 1299 insertions(+), 1071 deletions(-) diff --git a/src/overlays/l07/gameplay/entities/taxi_platform.c b/src/overlays/l07/gameplay/entities/taxi_platform.c index cc014801ef..d22a8c4943 100644 --- a/src/overlays/l07/gameplay/entities/taxi_platform.c +++ b/src/overlays/l07/gameplay/entities/taxi_platform.c @@ -2553,378 +2553,597 @@ 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); +/* 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. */ + +typedef u32 VecQuad_p __attribute__((mode(TI), aligned(16))); + +typedef union { + VecQuad_p q; + f32 f[4]; + s32 i[4]; +} Vec4_p; + +typedef struct { + float x; /* 0x00 */ + float y; /* 0x04 */ + float z; /* 0x08 */ + char padC[0x10]; + unsigned char b1C; /* 0x1C */ + unsigned char b1D; /* 0x1D */ + short h1E; /* 0x1E */ + char rest[0x1170]; +} Rec_30D8E8_p; + +typedef u32 u128_p __attribute__((mode(TI), aligned(16))); + +struct WalkerPath_p { + s32 count; + u8 pad4[0xC]; + Vec4_p pts[1]; +}; + +struct WalkerData_p { + u8 pad0[0xF0]; + Vec4_p goal; /* 0xF0 */ + u8 pad100[0x28]; + struct WalkerPath_p *path; /* 0x128 */ + u8 pad12C[8]; + s32 wander; /* 0x134 */ + u8 pad138[4]; + f32 heading; /* 0x13C */ + f32 turnStep; /* 0x140 */ +}; + +struct Tgt_3109D0_p { + float pos[4]; + u128_p q10; + u128_p q20; + u128_p q30; + int moby; + int kind; +}; + +extern Rec_30D8E8_p *D_L07_001612D0_p __asm__("D_L07_001612D0"); +extern Vec4_p D_L07_00173EE0_p __asm__("D_L07_00173EE0"); +extern char *D_L07_0015FFD8_p __asm__("D_L07_0015FFD8"); +extern char D_0013E533_p[] __asm__("D_0013E533"); +extern char D_L07_002117F8_p[] __asm__("D_L07_002117F8"); +extern char D_L07_00211838_p[] __asm__("D_L07_00211838"); +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 D_0015ED60_p __asm__("D_0015ED60"); +extern float D_0015ED6C_p __asm__("D_0015ED6C"); +extern float D_0015ED70_p __asm__("D_0015ED70"); +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_p __asm__("D_L07_0015F5CC"); +extern int D_L07_001612D8_p __asm__("D_L07_001612D8"); +extern int DebugPrint_alt() __asm__("FUN_001e93b0"); 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_00259740(void *, void *, int); 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"))); -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 int D_L07_001612D8; -extern char D_L07_00173EE0_30f5f0[] __asm__("D_L07_00173EE0"); +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_p[1] __asm__("D_L07_00161B50") __attribute__((sda)); +extern unsigned char D_L07_00161B40_p[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_c(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_p *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_0013F3D0_p[] __asm__("D_0013F3D0"); +extern char D_001413D0_p[] __asm__("D_001413D0"); +extern char D_0013F65C_p[] __asm__("D_0013F65C"); +extern char D_0013F350_p[] __asm__("D_0013F350"); +extern void func_L00_002A5158_30D8E8(void *, int, int, float, float, float, float) __asm__("FUN_L00_002a3ec8"); +extern int func_001F9908_30D8E8(int *) __asm__("FUN_001f9740"); + +#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 Tgt_3109D0_p tgt; + float pos[4]; + float off[4]; + float rel[4]; + float step[4]; + float old[4]; + int wander; + int inside; + int anim; + int next; + unsigned char prev; + unsigned char cur; + 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_p, (int)((char *)moby - D_L07_0015FFD8_p) >> 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, &tgt, 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 = func_001F9908_30D8E8((int *)(data + 0x134)) != 0; + if (*(int *)(data + 0x110) != 0 && moby[0x20] >= 7) { + char *p = *(char **)(data + 0x148); + inside = FUN_L00_00259740(&tgt, p + 0x10, *(int *)p) != 0; + } else { + char *p = *(char **)(data + 0x148); + hero = ((char *)&D_0013F3D0_p); + inside = FUN_L00_00259740(hero, p + 0x10, *(int *)p) != 0; + if (vector_distance_xy_alt(moby + 0x10, hero) < 30.0f) { + tgt.moby = *(int *)(hero + 0x2000); + qcopy(&tgt.pos, hero); + qcopy(&tgt.q10, hero + 0x10); + qcopy(&tgt.q20, hero + 0x40); + qcopy(&tgt.q30, hero + 0x50); + tgt.kind = 0; + } else { + tgt.moby = 0; + qzero(&tgt.pos); + qzero(&tgt.q10); + qzero(&tgt.q30); + qzero(&tgt.q20); + tgt.kind = 2; + } + } + if (*(int *)(data + 0x110) != 0) { + char *p = *(char **)(data + 0x128); + FUN_L00_00259740(moby + 0x10, p + 0x10, *(int *)p); + } + prev = moby[0xBC]; + next = 0xFF; + anim = 0xFF; + moby[0xBC] = FUN_L07_0030ebc8_c((char *)moby, data); + cur = moby[0xBC]; + if (prev != cur) { + next = ((struct { unsigned char t[3][3]; } *)D_L07_00161B40_p)->t[prev][cur]; + anim = ((struct { unsigned char t[3][3]; } *)D_L07_00161B50_p)->t[prev][cur]; + } + FUN_L00_0024f7c8(moby, 0, pos); + if (FUN_L00_001f0d60(0.8f, pos, 1, moby) != 0 && FUN_001f0b58() == 0) { + float s; + float f; + s = **(float **)(data + 0x12C); + s -= F(data, 0x130); + s *= 0.5f; + if (s < absolute_float(F(moby, 0x18) - pos[2])) { + s = (**(float **)(data + 0x12C) - F(data, 0x130)) * 0.5f; + } else { + s = absolute_float(F(moby, 0x18) - pos[2]); + } + if (F(data, 0xD8) < 0.0f) { + s = -s; + } + if (moby[0x20] == 0xE || moby[0x20] == 0xC) { + s += s; + } + if (0.5f < vector_distance_xy_alt(moby + 0x10, &D_L07_00173EE0_p)) { + f = vector_distance_xy_alt(moby + 0x10, &D_L07_00173EE0_p); + f += f; } 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; - 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); + f = 1.0f; + } + if (D_L07_0015F5CC_p % 45 == *(short *)(moby + 0xB2) && random_integer_below(2) == 0) { + func_L00_002A5158_30D8E8(D_L07_001612D0_p, D_L07_001612D8_p, 1, F(moby, 0x10), F(moby, 0x14), f, s); + } + if (D_L07_0015F5CC_p % ((rand() & 7) + 20) == 0) { + float size = random_float_between_c2(1.5f, 2.4f); + pos[0] += random_float_between_c2(-0.15f, 0.15f); + pos[1] += random_float_between_c2(-0.15f, 0.15f); + pos[2] = resolve_camera_surface_height(&D_L07_00173EE0_p, 0); + FUN_L00_002715e8(pos, 0, -1, size, 5250.0f); + } + } + if (1.0f <= F(data, 0x14C)) { + *(u128_p *)(((char *)&D_0013F3D0_p)) = *(u128_p *)(moby + 0x10); + } + switch (moby[0x20]) { case 0: - ((void (*)(char *))stub_printf)(D_L07_00211838); - goto bounds; + DebugPrint_alt(D_L07_00211838_p); + 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_c(moby, 0, 0, 10); + } + if (inside && tgt.moby != 0 && tgt.moby == *(int *)(((char *)&D_001413D0_p)) && + !FUN_L07_0030f540_c(moby, 4, 6)) { + if (moby[0x53] != 1) { + blend_moby_animation_c(moby, 1, 0, 10); + } + moby[0x20] = 4; + } + if (tgt.moby != 0 && tgt.moby == *(int *)(((char *)&D_001413D0_p)) && + FUN_L07_0030f4d0_c(moby, tgt.moby, 1.5f)) { + if (moby[0x53] != 2) { + blend_moby_animation_c(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; + } else if (wander) { + if (moby[0x53] != 1) { + blend_moby_animation_c(moby, 1, 0, 10); } + *(int *)(data + 0x134) = rand() % 200 + 300; + F(data, 0x13C) = random_angle_radians_c2(); + 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); - moby[0x20] = next_state; + fast_vec_scale_c(data + 0xD0, data + 0xD0, D_0015ED60_p * (0.95f - 1.0f) + 1.0f); + FUN_L07_0030f0f8_c((char *)moby, data, D_0015ED70_p * 15.0f, D_0015ED70_p * 50.0f, D_0015ED6C_p * 8.0f); + if (next != 0xFF) { + if (moby[0x53] != anim) { + blend_moby_animation_c(moby, anim, 0, 6); + } + moby[0x20] = next; } - 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_c(moby, 1, 0, 10); + } + if (inside && tgt.moby != 0 && tgt.moby == *(int *)(((char *)&D_001413D0_p))) { + if (!FUN_L07_0030f540_c(moby, 4, 6)) { + if (moby[0x53] != 1) { + blend_moby_animation_c(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 a = 1.74532926f; + float b = 4.5378561f; + FUN_L00_00258278((char *)moby, (float *)(data + 0x120), F(data, 0x13C), + D_0015ED70_p * a, D_0015ED70_p * b, D_0015ED6C_p * a); + F(moby, 0x44) = FUN_L00_00258110((float *)(data + 0x124), F(moby, 0x44), 0.0f, + D_0015ED70_p * a, D_0015ED70_p * b, D_0015ED6C_p * a); + if (wander && is_point_inside_clip_volume_c2(moby + 0x10, *(int *)(data + 0x114))) { + if (moby[0x53] != 0) { + blend_moby_animation_c(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_p *)data); + if (FUN_L07_0030f1e0_c((char *)moby, data, F(data, 0x13C), 0.209439516f, D_0015ED70_p * 6.0f, + 0.52359879f, D_0015ED70_p * 4.0f, D_0015ED6C_p * 7.0f, D_0015ED6C_p * 3.0f) && + wander) { + if (moby[0x53] != 0) { + blend_moby_animation_c(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 (tgt.moby != 0 && tgt.moby == *(int *)(((char *)&D_001413D0_p)) && + FUN_L07_0030f4d0_c(moby, tgt.moby, 1.5f)) { + if (moby[0x53] != 2) { + blend_moby_animation_c(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); - 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); + FUN_L07_0030f0f8_c((char *)moby, data, D_0015ED70_p * 15.0f, D_0015ED70_p * 50.0f, D_0015ED6C_p * 8.0f); + if (next != 0xFF) { + if (moby[0x53] != anim) { + blend_moby_animation_c(moby, anim, 0, 6); + } + moby[0x20] = next; + } + goto end; + case 4: { + float ang; + float d; + int close = 1; + float pi4 = 12.566371f; + float three = 3.0f; + float zero = 0.0f; + ang = fast_arc_tan_c2(tgt.pos[0] - F(moby, 0x10), tgt.pos[1] - F(moby, 0x14)); + FUN_L00_00258278((char *)moby, (float *)(data + 0x120), ang, + D_0015ED70_p * pi4, D_0015ED70_p * zero, D_0015ED6C_p * pi4); + d = vector_distance_xy_alt(moby + 0x10, &tgt); + d = fast_arc_tan_c2(d, tgt.pos[2] - F(moby, 0x18)); + F(moby, 0x44) = FUN_L00_00258110((float *)(data + 0x124), F(moby, 0x44), -d, + D_0015ED70_p * pi4, D_0015ED70_p * zero, D_0015ED6C_p * pi4); + if (!(vector_distance_xy_alt(moby + 0x10, ((char *)&D_0013F3D0_p)) < three)) { + close = 0; + } + if (close) { + fast_vec_scale_c(data + 0xD0, data + 0xD0, D_0015ED60_p * (0.9f - 1.0f) + 1.0f); + } + if (FUN_L07_0030f1e0_c((char *)moby, data, ang, 0.209439516f, D_0015ED70_p * 20.0f, + 0.52359879f, D_0015ED70_p * three, D_0015ED6C_p * 20.0f, D_0015ED6C_p * 5.0f) && + close) { + if (moby[0x53] != 2) { + blend_moby_animation_c(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 p[0x138]; float f; } *)data)->f = tgt.pos[2] - 0.25f; + FUN_L07_0030f0f8_c((char *)moby, data, D_0015ED70_p * 38.0f, D_0015ED70_p * 0.0f, D_0015ED6C_p * 38.0f); + if (!inside || *(short *)(((char *)&D_0013F65C_p)) == 0) { + if (moby[0x53] != 1) { + blend_moby_animation_c(moby, 1, 0, 10); + } moby[0x20] = 2; } - if (next_state != 0xff) { - if (moby[0x53] != next_sequence) blend_moby_animation(moby, next_sequence, 0, 6); - moby[0x20] = next_state; + if (next != 0xFF) { + if (moby[0x53] != anim) { + blend_moby_animation_c(moby, anim, 0, 6); + } + moby[0x20] = next; } - 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); - 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; + float ang; + float d; + char *mpos; + char *start; + float one; + FUN_L00_0024f7c8(moby, 0, pos); + mpos = (char *)moby + 0x10; + subtract_vector_xyz(off, pos, mpos); + ang = fast_arc_tan_c2(tgt.pos[0] - pos[0], tgt.pos[1] - pos[1]); + func_L00_002592B0_t((char *)moby, ang, (float *)(data + 0x120), + D_0015ED70_p * 12.566371f, D_0015ED70_p * 0.0f, D_0015ED6C_p * 12.566371f); + F(moby, 0x44) *= D_0015ED60_p * 0.7f; + F(data, 0x14C) += 0.028f; + qcopy(old, mpos); + subtract_vector_xyz(rel, &tgt, off); + start = data + 0x100; + subtract_vector_xyz(step, rel, start); + one = 1.0f; + fast_vec_scale_c(step, step, F(data, 0x14C) < one ? F(data, 0x14C) : one); + add_vector_xyz(mpos, step, start); + no_op_main_callback_alt(old, mpos); + no_op_main_callback_alt(start, mpos); + subtract_vector_xyz(data + 0xD0, mpos, old); + if (one <= F(data, 0x14C)) { + char *g = ((char *)&D_0013F350_p); + *(int *)(g + 0x22A8) = 0; + FUN_L00_002223f8(0x3D, 1); + *(int *)(*(char **)(g + 0x2080) + 0x98) = -1; + g[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) = ang; + } + if (inside || *(short *)(((char *)&D_0013F65C_p)) != 0) { + goto end; } - goto bounds; + *(int *)(data + 0x14C) = 0; + if (moby[0x53] != 1) { + blend_moby_animation_c(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_p *)data); + FUN_L07_0030f1e0_c((char *)moby, data, F(data, 0x13C), 0.209439516f, D_0015ED70_p * 6.0f, + 0.52359879f, D_0015ED70_p * 4.0f, D_0015ED6C_p * seven, D_0015ED6C_p * 3.0f); + FUN_L07_0030f0f8_c((char *)moby, data, D_0015ED70_p * 12.0f, D_0015ED70_p * 50.0f, D_0015ED6C_p * seven); + FUN_L00_00258278((char *)moby, (float *)(data + 0x120), F(data, 0x13C), + D_0015ED70_p * pi2, D_0015ED70_p * pi, D_0015ED6C_p * pi); + F(moby, 0x44) = FUN_L00_00258110((float *)(data + 0x124), F(moby, 0x44), 0.0f, + D_0015ED70_p * pi2, D_0015ED70_p * pi, D_0015ED6C_p * pi); + if ((moby[0x70] & 2) && moby[0x53] != 1) { + blend_moby_animation_c(moby, 1, 0, 10); + } + if (next != 0xFF) { + if (moby[0x53] != anim) { + blend_moby_animation_c(moby, anim, 0, 6); + } + moby[0x20] = next; + } + goto end; } - 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); - moby[0x20] = next_state; - } - goto bounds; case 7: if (inside) { - if (moby[0x53] != 4) blend_moby_animation(moby, 4, 0, 10); + if (moby[0x53] != 4) { + blend_moby_animation_c(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_c(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); - moby[0x20] = next_state; + fast_vec_scale_c(data + 0xD0, data + 0xD0, D_0015ED60_p * (0.95f - 1.0f) + 1.0f); + F(data, 0xD8) -= D_0015ED6C_p * 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); } - goto bounds; + if (next != 0xFF) { + if (moby[0x53] != anim) { + blend_moby_animation_c(moby, anim, 0, 6); + } + moby[0x20] = next; + } + goto end; case 8: if (inside) { - if (moby[0x53] != 4) blend_moby_animation(moby, 4, 0, 10); + if (moby[0x53] != 4) { + blend_moby_animation_c(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 a = 0.785398185f; + float b = 1.57079637f; + FUN_L00_00258278((char *)moby, (float *)(data + 0x120), F(data, 0x13C), + D_0015ED70_p * a, D_0015ED70_p * b, D_0015ED6C_p * a); + F(moby, 0x44) = FUN_L00_00258110((float *)(data + 0x124), F(moby, 0x44), 0.0f, + D_0015ED70_p * a, D_0015ED70_p * b, D_0015ED6C_p * a); + if (wander && is_point_inside_clip_volume_c2(moby + 0x10, *(int *)(data + 0x114))) { + if (moby[0x53] != 3) { + blend_moby_animation_c(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_p *)data); + if (FUN_L07_0030f1e0_c((char *)moby, data, F(data, 0x13C), 0.34906584f, D_0015ED70_p * 3.0f, + 1.04719758f, D_0015ED70_p * 9.0f, D_0015ED6C_p, D_0015ED6C_p) && + wander) { + if (moby[0x53] != 3) { + blend_moby_animation_c(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); - moby[0x20] = next_state; - } - goto bounds; - 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); + F(data, 0xD8) -= D_0015ED6C_p * 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 != 0xFF) { + if (moby[0x53] != anim) { + blend_moby_animation_c(moby, anim, 0, 6); + } + moby[0x20] = next; + } + goto end; + case 9: + case 10: { + float ang; + float d; + float pi2 = 1.57079637f; + ang = fast_arc_tan_c2(tgt.pos[0] - F(moby, 0x10), tgt.pos[1] - F(moby, 0x14)); + func_L00_002592B0_t((char *)moby, ang, (float *)(data + 0x120), + D_0015ED70_p * 0.785398185f, D_0015ED70_p * pi2, D_0015ED6C_p * 0.785398185f); + if (FUN_L07_0030f1e0_c((char *)moby, data, ang, 0.52359879f, D_0015ED70_p * 4.0f, + pi2, D_0015ED70_p * 9.0f, D_0015ED6C_p * 1.5f, D_0015ED6C_p) && + vector_distance_xy_alt(moby + 0x10, &tgt) < 1.9f && moby[0x20] != 10) { + if (moby[0x53] != 5) { + blend_moby_animation_c(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) -= D_0015ED6C_p * 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_c(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, tgt.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_c(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); - moby[0x20] = next_state; + if (next != 0xFF) { + if (moby[0x53] != anim) { + blend_moby_animation_c(moby, anim, 0, 6); + } + moby[0x20] = next; } - 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, D_0015ED60_p * (0.95f - 1.0f) + 1.0f); + F(data, 0xD8) -= D_0015ED6C_p * 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); - moby[0x20] = next_state; - } - goto bounds; + fast_vec_scale_c(data + 0xD0, data + 0xD0, D_0015ED60_p * (0.95f - 1.0f) + 1.0f); + F(data, 0xD8) -= D_0015ED6C_p * 9.8f; + FUN_L00_00258ad0((int)moby, (int)(data + 0xD0), 0x400, 0x10, 1.0f, 0.0f); + if (next != 0xFF) { + if (moby[0x53] != anim) { + blend_moby_animation_c(moby, anim, 0, 6); + } + moby[0x20] = next; + } + 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, D_0015ED60_p * (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 *); diff --git a/src/overlays/l08/gameplay/entities/bolt_thief.c b/src/overlays/l08/gameplay/entities/bolt_thief.c index 156789c318..c167de860a 100644 --- a/src/overlays/l08/gameplay/entities/bolt_thief.c +++ b/src/overlays/l08/gameplay/entities/bolt_thief.c @@ -1889,27 +1889,25 @@ 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 v0_p[4]; /* 0x00 */ float v10[4]; /* 0x10 */ float v20[4]; /* 0x20 */ float v30[4]; /* 0x30 */ - float velocity[4]; /* 0x40 */ - float spin_x, spin_y, spin_z; /* 0x50 */ + float v40[4]; /* 0x40: velocity */ + float f50, f54, f58; /* 0x50: spin */ int pad5C; float f60, f64; /* 0x60 */ - int timer; /* 0x68 */ + int i68; /* 0x68 */ short s6C, s6E; /* 0x6C */ union { int i; float f; } u70; float f74; /* 0x74 */ @@ -1927,540 +1925,532 @@ typedef struct { } Coll_4BE8; typedef struct { - u8 pad_00[0xB1]; + u8 pad_00_p[0xB1]; u8 id; } BoltSource_4BE8; typedef struct { - u16 unk0; + u16 unk0_p; u16 bolts; } BoltSourceStats_4BE8; typedef struct { - unsigned char pad[0x454]; + unsigned char pad_p[0x454]; unsigned char killed[1]; } KillFlags_4BE8; extern BoltSourceStats_4BE8 D_0014D590[][64]; -extern Coll_4BE8 D_L08_00174640; -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); +typedef struct { + float pos[4]; /* 0x00 */ + char pad10[0x10]; + float n[4]; /* 0x20 */ +} CollPos_4BE8; +extern CollPos_4BE8 D_L08_00174660_p __asm__("D_L08_00174660"); +extern KillFlags_4BE8 D_L08_001BADD0_p __asm__("D_L08_001BADD0"); +extern KillFlags_4BE8 D_L08_001BBA30_p __asm__("D_L08_001BBA30"); +extern struct Moby *D_L08_0015FFDC_p __asm__("D_L08_0015FFDC"); +extern char D_0013E533_p[] __asm__("D_0013E533"); +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_0015ED6C_p __asm__("D_0015ED6C"); +extern float D_0015ED70_p __asm__("D_0015ED70"); +extern float D_L08_00161C88_p __asm__("D_L08_00161C88") __attribute__((sda)); +extern float D_L08_00161C8C_p __asm__("D_L08_00161C8C") __attribute__((sda)); +extern float D_L08_00161C94_p __asm__("D_L08_00161C94") __attribute__((sda)); +extern float D_L08_00161C98_p __asm__("D_L08_00161C98") __attribute__((sda)); +extern float D_L08_00161C9C_p __asm__("D_L08_00161C9C"); +extern float D_L08_00161CA0_p __asm__("D_L08_00161CA0") __attribute__((sda)); +extern float D_L08_00161CA4_p __asm__("D_L08_00161CA4") __attribute__((sda)); +extern float D_L08_00161CA8_p __asm__("D_L08_00161CA8"); +extern float D_L08_00161CAC_p __asm__("D_L08_00161CAC") __attribute__((sda)); +extern float D_L08_00161CB0_p __asm__("D_L08_00161CB0"); +extern float D_L08_00161CB4_p __asm__("D_L08_00161CB4") __attribute__((sda)); +extern float D_L08_00161CB8_p __asm__("D_L08_00161CB8"); +extern float D_L08_00161CBC_p __asm__("D_L08_00161CBC") __attribute__((sda)); +extern float D_L08_00161CD0_p __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_0015F5CC_p __asm__("D_L08_0015F5CC"); +extern int D_L08_00161CC0_p __asm__("D_L08_00161CC0"); +extern int D_L08_00161CC4_p __asm__("D_L08_00161CC4") __attribute__((sda)); +extern int D_L08_00161CC8_p __asm__("D_L08_00161CC8"); +extern int D_L08_00161CCC_p __asm__("D_L08_00161CCC") __attribute__((sda)); +extern int D_L08_00161CD4_p __asm__("D_L08_00161CD4") __attribute__((sda)); +extern int D_L08_00174658_p __asm__("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 D_0013DF38_p[] __asm__("D_0013DF38"); +extern s32 D_0015ED84_p __asm__("D_0015ED84"); +extern s32 D_0015ED98_p __asm__("D_0015ED98"); +extern s32 allocate_voice_for_target_entry_alt_c2(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 u8 D_0014C050_p[] __asm__("D_0014C050"); 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_p[] __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; -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"); +int FUN_L00_00239df8(HudElem *m); +void FUN_L00_00239cc8(HudElem *e); +void FUN_L00_00239d00(void *o); +extern char D_0013F350_p[] __asm__("D_0013F350"); +extern char D_0013F3D0_p[] __asm__("D_0013F3D0"); +extern char D_0013F490_p[] __asm__("D_0013F490"); +extern int D_L08_0015F6B0_2E0258 __asm__("D_L08_0015F5CC"); 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"))); +extern unsigned char D_0014C150_4BE8[][16] __asm__("D_0014C050"); +extern int D_L08_001746D8_4BE8 __asm__("D_L08_00174658") __attribute__((section(".data"))); -void FUN_L08_002e3870(Moby *moby) { - float dir[4]; - float point[4]; - float local[4]; - float scratch[16]; +void FUN_L08_002e3870(struct Moby *m) { + char *cam; + float a[4]; + float b[4]; + float c[4]; + float mt[16]; - switch (moby->state) { + switch (m->state) { case 0: { - Vars_4BE8 *vars = (Vars_4BE8 *)moby->pvars; + Vars_4BE8 *d = (Vars_4BE8 *)m->pvars; int linked; - switch (moby->oclass) { + switch (m->oclass) { case 0x279: - moby->scale = moby->pclass->scale * *(float *)&D_L08_00161CB4; + m->scale = m->pclass->scale * *(float *)&D_L08_00161CB4_p; break; case 0x3DC: - moby->scale = moby->pclass->scale * *(float *)&D_L08_00161CB8; + m->scale = m->pclass->scale * *(float *)&D_L08_00161CB8_p; break; case 0x3DD: - moby->scale = moby->pclass->scale * *(float *)&D_L08_00161CBC; + m->scale = m->pclass->scale * *(float *)&D_L08_00161CBC_p; break; } linked = 0; - if (D_L08_00161CD4 > D_L08_0015F5CC) { - D_L08_00161CD4 = D_L08_0015F5CC; - } - moby->flags &= ~0x100; - qcopy(vars->v0, &moby->pos); - if (vars->s6E == 0) { - normalize_vector_xyz(point, &moby->rot_row2, 0.1f); - add_vector_xyz(point, point, &moby->pos); - scale_vector_xyz(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); + if (D_L08_00161CD4_p > D_L08_0015F6B0_2E0258) { + D_L08_00161CD4_p = D_L08_0015F6B0_2E0258; + } + m->flags &= ~0x100; + qcopy(d->v0_p, &m->pos); + if (d->s6E == 0) { + fast_vec_normalize_c2(b, &m->rot_row2, 0.1f); + add_vector_xyz(b, b, &m->pos); + fast_vec_scale_c(c, &m->rot_row2, -2.0f); + add_vector_xyz(c, c, &m->pos); + if (FUN_001efa68(b, c, 2, 0, 0) != 0) { + CollPos_4BE8 *hit = &D_L08_00174660_p; + qcopy(d->v0_p, hit->pos); + linked = ((int *)hit)[-2]; + fast_vec_normalize_c2(a, hit->n, 1.0f); } else { - qcopy(vars->v0, &moby->pos); - clear_u64_value(dir); - dir[2] = 1.0f; + qcopy(d->v0_p, &m->pos); + clear_u64_value(a); + a[2] = 1.0f; } } - FUN_L08_002e4db8_3870((char *)moby, dir); - vars->f60 = random_angle_radians(); - vars->f64 = moby->rot.x; - FUN_L08_002e4e90_3870((char *)moby, (float *)&moby->pos, (float *)&moby->rot); + FUN_L08_002e4db8_c((char *)m, a); + d->f60 = random_angle_radians_c2(); + d->f64 = m->rot.x; + FUN_L08_002e4e90_c((char *)m, (float *)&m->pos, (float *)&m->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); + d->u7C.i = linked; + FUN_L00_00260668(m, linked, d->v0_p, d->v10, d->v20, d->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; + m->state = 1; + d->s6C = 0; + d->u70.i = truncate_float_to_s32_c5(random_float_between_c5(0.0f, (float)scale_game_frames_c(600))); + d->u78.i = D_L08_00161CCC_p; 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) { - vars = (Vars_4BE8 *)moby->pvars; - clear_u64_value(vars->velocity); - FUN_L08_0026a0f8(vars, &moby->rot_row1, D_L08_00161C98 * 0.017453292f * D_0015ED6C); - moby->state = 4; + Vars_4BE8 *d = (Vars_4BE8 *)m->pvars; + + if (d->u7C.i != 0) { + FUN_L00_002604f0(m, d->u7C.i, d->v20, d->v30, d->v0_p, d->v10); + if ((signed char)((struct Moby *)d->u7C.i)->state < 0) { + d = (Vars_4BE8 *)m->pvars; + clear_u64_value(d->v40); + FUN_L08_0026a0f8(d, &m->rot_row1, D_L08_00161C98_p * 0.017453292f * D_0015ED6C_p); + m->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); - moby->state = 2; + if (absolute_float(m->pos.z - ((Hero *)(((char *)&D_0013F350_p)))->motion.pos.f[2]) < ((Hero *)(((char *)&D_0013F350_p)))->reach_distance + && vector_distance_xy_alt(&m->pos, ((Hero *)(((char *)&D_0013F350_p)))->motion.pos.f) < ((Hero *)(((char *)&D_0013F350_p)))->reach_height) { + d->i68 = scale_game_frames_c(1); + m->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 (m->visible == 0) { + if (m > D_L08_0015FFDC_p && vector_distance_xy_alt(&m->pos, ((char *)&D_0013F3D0_p)) > 24.0f) { + mark_moby_for_removal_c3(m); return; } break; } - switch (moby->oclass) { + switch (m->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); + d->f60 = fast_add_rotations_c4(d->f60, D_L08_00161CAC_p * 0.017453292f * D_0015ED6C_p); + d->f64 = fast_add_rotations_c4(d->f64, D_L08_00161CB0_p * 0.017453292f * D_0015ED6C_p); 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); + d->f60 = fast_add_rotations_c4(d->f60, D_L08_00161CA4_p * 0.017453292f * D_0015ED6C_p); + d->f64 = fast_add_rotations_c4(d->f64, D_L08_00161CA8_p * 0.017453292f * D_0015ED6C_p); 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); + d->f60 = fast_add_rotations_c4(d->f60, D_L08_00161C9C_p * 0.017453292f * D_0015ED6C_p); + d->f64 = fast_add_rotations_c4(d->f64, D_L08_00161CA0_p * 0.017453292f * D_0015ED6C_p); break; } - FUN_L08_002e4e90_3870((char *)moby, (float *)&moby->pos, (float *)&moby->rot); - if (vars->s6C != 0) { - vars->f74 = fast_add_rotations(vars->f74, D_0015ED6C * 5.2359877f); - if (vars->u70.i > 12) { - vars->u78.i += 0x5000000; + FUN_L08_002e4e90_c((char *)m, (float *)&m->pos, (float *)&m->rot); + if (d->s6C != 0) { + d->f74 = fast_add_rotations_c4(d->f74, D_0015ED6C_p * 5.2359877f); + if (d->u70.i > 12) { + d->u78.i += 0x5000000; } else { - vars->u78.i -= 0x5000000; + d->u78.i -= 0x5000000; } - 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))); - } else if (moby->visible != 0 && D_L08_00161CC8 != 0) { - func_001F49B0_2E16A0(FUN_L08_002e5188_3870, moby); + if (tick_countdown_32_alt(&d->u70.i) != 0) { + d->s6C = 0; + d->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 (m->visible != 0 && D_L08_00161CC8_p != 0) { + func_001F49B0_2E16A0(FUN_L08_002e5188_c, m); return; } - } else if (tick_countdown_32_alt(&vars->u70.i) != 0) { - vars->u70.i = 24; - vars->f74 = random_angle_radians(); - vars->s6C = 1; + } else if (tick_countdown_32_alt(&d->u70.i) != 0) { + d->u70.i = 24; + d->f74 = random_angle_radians_c2(); + d->s6C = 1; } break; } case 2: { - Vars_4BE8 *vars = (Vars_4BE8 *)moby->pvars; - - euler_rotation_matrix(scratch, vars->v10); - qcopy(dir, scratch + 8); - if (tick_countdown_32_alt(&vars->timer) != 0) { - Vars_4BE8 *vars = (Vars_4BE8 *)moby->pvars; - float deg_to_rad = 0.017453292f; - - 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); - moby->flags |= 0x100; - normalize_vector_xyz(vars->velocity, dir, D_0015ED6C * 8.0f); - vars->f74 = 0.0f; - vars->u70.f = D_0015ED6C * 8.0f; - vars->u78.p = *(char **)((char *)&D_0013F3D0 + 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); - vars->f64 = 0.0f; + Vars_4BE8 *d = (Vars_4BE8 *)m->pvars; + + euler_rotation_matrix(mt, d->v10); + qcopy(a, mt + 8); + if (tick_countdown_32_alt(&d->i68) != 0) { + Vars_4BE8 *e = (Vars_4BE8 *)m->pvars; + float k = 0.017453292f; + char *hero_pos = D_0013F3D0_p; + + subtract_vector_xyz(b, &m->pos, hero_pos); + fast_vec_normalize_c2(b, b, 1.0f); + cross_vectors_xyz(b, a, b); + FUN_L08_0026a0f8(e, b, D_L08_00161C94_p * k * D_0015ED6C_p); + m->flags |= 0x100; + fast_vec_normalize_c2(e->v40, a, D_0015ED6C_p * 8.0f); + e->f74 = 0.0f; + e->u70.f = D_0015ED6C_p * 8.0f; + e->u78.p = *(char **)(hero_pos + 0x2000); + e->u7C.f = 0.5f; + if (D_L08_00161CD4_p + scale_game_frames_c(3) < D_L08_0015F6B0_2E0258) { + D_L08_00161CD4_p = D_L08_0015F6B0_2E0258; + allocate_voice_for_target_entry_alt_c2(0, 0x20, m); + e->f64 = 0.0f; } else { - vars->f64 = random_float_between(-30.0f, 30.0f) * deg_to_rad; + e->f64 = random_float_between_c5(-30.0f, 30.0f) * k; } - moby->state = 3; + m->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) < d->i68) { + float t = fast_add_rotations_c4(d->f60, fast_sin((float)(d->i68 % 8 - 4) * 0.7854f) * 0.17453292f); - FUN_L00_0025bc00(&vars->f60, goal_yaw, 0.5235988f, 0); + FUN_L00_0025bc00(&d->f60, t, 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 t = fast_add_rotations_c4(fast_arc_tan(((Hero *)(((char *)&D_0013F350_p)))->motion.pos.f[0] - m->pos.x, + ((Hero *)(((char *)&D_0013F350_p)))->motion.pos.f[1] - m->pos.y), 1.5707964f); - FUN_L00_0025bc00(&vars->f60, goal_yaw, 0.08726646f, 0); - if (func_001FA850_2E16A0(vars->f60, goal_yaw) < 0.08726646f) { - vars->timer = 0; + FUN_L00_0025bc00(&d->f60, t, 0.08726646f, 0); + if (func_001FA850_2E16A0(d->f60, t) < 0.08726646f) { + d->i68 = 0; } } - FUN_L08_002e4e90_3870((char *)moby, (float *)&moby->pos, (float *)&moby->rot); + FUN_L08_002e4e90_c((char *)m, (float *)&m->pos, (float *)&m->rot); } break; } case 3: { - Vars_4BE8 *vars = (Vars_4BE8 *)moby->pvars; + Vars_4BE8 *d = (Vars_4BE8 *)m->pvars; float dist; - float fade_range; + float lim; - if (vars->u78.p == 0) { + if (d->u78.p == 0) { break; } - normalize_vector_xyz(point, vars->u78.p + 0xE0, vars->u7C.f); - add_vector_xyz(point, point, vars->u78.p + 0x10); - subtract_vector_xyz(dir, 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]; - } - dist = distance_xyz(point, &moby->pos); - normalize_vector_xyz(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(b, d->u78.p + 0xE0, d->u7C.f); + add_vector_xyz(b, b, d->u78.p + 0x10); + subtract_vector_xyz(a, b, &m->pos); + if (d->f64 != 0.0f) { + float s = fast_sin(d->f64); + float co = fast_cos(d->f64); + + a[0] = co * a[0] + s * a[1]; + a[1] = co * a[1] - s * a[0]; + } + dist = fast_vec_dist(b, &m->pos); + fast_vec_normalize_c2(d->v40, d->v40, d->u70.f); + add_vector_xyz(&m->pos, &m->pos, d->v40); + fast_vec_normalize_c2(a, a, d->f74); + add_vector_xyz(&m->pos, &m->pos, a); + cam = D_0013F490_p; + add_vector_xyz(&m->pos, &m->pos, cam); + subtract_vector_xyz(c, &m->pos, cam + 0x160); + transform_vector(c, c, cam - 0x100); + if (((struct Moby *)d->u78.p)->oclass != 0 || c[2] > 0.0f) { + func_00214D28_2E16A0(&d->u70.f, 0.0f, D_L08_00161C8C_p * D_0015ED70_p); + func_00214D28_2E16A0(&d->f74, D_L08_00161C88_p * D_0015ED6C_p, D_L08_00161C8C_p * D_0015ED70_p); } else { - normalize_vector_xyz(scratch, ((char *)&D_0013F490 - 0x120), vars->u70.f); - subtract_vector_xyz(scratch + 4, scratch, vars->velocity); - FUN_L00_0025f730(scratch + 4, D_L08_00161C8C * D_0015ED70); - 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); - if (dist < fade_range) { - if (distance_xyz(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); + fast_vec_normalize_c2(mt, cam - 0x120, d->u70.f); + subtract_vector_xyz(mt + 4, mt, d->v40); + FUN_L00_0025f730_c(mt + 4, D_L08_00161C8C_p * D_0015ED70_p); + add_vector_xyz(d->v40, d->v40, mt + 4); + } + if (dist < d->f74) { + d->f74 = dist; + } + lim = d->f74 * (float)scale_game_frames_c(20); + if (dist < lim) { + if (fast_vec_dist(b, &m->pos) > 0.52f) { + if (D_L08_00161CC0_p != 0) { + m->alpha = (fast_vec_dist(b, &m->pos) + lim) * 128.0f / (lim + lim); } - 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_p != 0) { + m->scale = m->pclass->scale * *(float *)&D_L08_00161CB4_p * (fast_vec_dist(b, &m->pos) + lim) / (lim + lim); } } else { - int bolts; + int value; int spin; - float shrink; + float k; float size; - BoltSource_4BE8 *source; + BoltSource_4BE8 *src; - switch (moby->oclass) { + switch (m->oclass) { case 0x305: { int i; int j; - int collected; + int n; - D_0014BEC0[D_0015ED84][moby->command] = 1; - collected = 0; + D_0014BEC0[D_0015ED84_p][m->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); - add_vector_xyz(scratch + 4, scratch + 4, &moby->pos); - spin = random_integer_below(2); + k = 0.7f; + FUN_L00_00257d78(mt, D_0015ED6C_p * k, D_0015ED6C_p); + fast_vec_scale_c(mt + 4, mt, 10.0f); + add_vector_xyz(mt + 4, mt + 4, &m->pos); + 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(mt + 4, scale_game_frames_c(0x19), size * 0.2f, size, 0x7F207F7F, 0, spin, mt, 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); - source = moby->parent; - if (source && !(source->id & 0x80)) { - D_0014D590[D_0015ED84][source->id].bolts += bolts; + FUN_L00_00272060(mt + 4, scale_game_frames_c(0x19), size * 0.14f, size * k, 0x7F7F7F7F, 1, spin, mt, 0.0f); + src = m->parent; + if (src && !(src->id & 0x80)) { + D_0014D590[D_0015ED84_p][src->id].bolts += value; } - { - 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); - } - 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)) { - D_L08_001BBA30.killed[(short)moby->save_id] = moby->mission + 2; + D_0015ED98_p += value; + D_0013DF38_p[D_0015ED84_p] += value; + queue_animation_update_alt(2, 0x754E, func_L00_0023A658_4BE8, func_L00_0023A690_4BE8, func_L00_0023A788_4BE8, &D_0015ED98_p, 9999999); + if (m < D_L08_0015FFDC_p) { + D_L08_001BADD0_p.killed[(short)m->save_id] = m->mission + 2; + if (m->mission == 0xFF || (D_L08_0015FC88_p[m->mission] != 0xFF && D_0014C150_4BE8[D_0015ED84_p][m->mission] == 0xFF)) { + D_L08_001BBA30_p.killed[(short)m->save_id] = m->mission + 2; } } - mark_moby_for_removal(moby); + mark_moby_for_removal_c3(m); return; } } - multiply_matrix_basis_columns(&moby->rot_row0, vars, &moby->rot_row0); + multiply_matrix_basis_columns(&m->rot_row0, d, &m->rot_row0); break; } case 4: { - Vars_4BE8 *vars = (Vars_4BE8 *)moby->pvars; + Vars_4BE8 *d = (Vars_4BE8 *)m->pvars; - add_vector_xyz(&moby->pos, &moby->pos, vars->velocity); - vars->velocity[2] -= D_0015ED70 * 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; - BoltSource_4BE8 *source; + add_vector_xyz(&m->pos, &m->pos, d->v40); + d->v40[2] -= D_0015ED70_p * 10.8f; + multiply_matrix_basis_columns(&m->rot_row0, d, &m->rot_row0); + if (m->pos.z < 2.0f || m->pos.x > 510.0f || m->pos.x < 2.0f || m->pos.y > 510.0f || m->pos.y < 2.0f) { + int value; + BoltSource_4BE8 *src; - switch (moby->oclass) { + switch (m->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; + src = m->parent; + if (src && !(src->id & 0x80)) { + D_0014D590[D_0015ED84_p][src->id].bolts += value; } - D_0015ED98 += bolts; - D_0013DF38[D_0015ED84] += bolts; - mark_moby_for_removal(moby); + D_0015ED98_p += value; + D_0013DF38_p[D_0015ED84_p] += value; + mark_moby_for_removal_c3(m); return; } - if (moby->pos.z < vars->f60 - 4.0f && moby->pos.z < ((Hero *)(((char *)D_0013F350)))->motion.pos.f[2] - 4.0f) { - Vars_4BE8 *vars = (Vars_4BE8 *)moby->pvars; + if (m->pos.z < d->f60 - 4.0f && m->pos.z < ((Hero *)(((char *)&D_0013F350_p)))->motion.pos.f[2] - 4.0f) { + Vars_4BE8 *e = (Vars_4BE8 *)m->pvars; - *(u128_4BE8 *)vars->v10 = *(u128_4BE8 *)((char *)D_0013F350 + 0x90); - vars->timer = scale_game_frames_alt(1); - moby->state = 2; + *(u128_4BE8_p *)e->v10 = *(u128_4BE8_p *)((char *)&D_0013F350_p + 0x90); + e->i68 = scale_game_frames_c(1); + m->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; - 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))); - per_frame = 1.0f / convert_integer_to_float(frames); - qcopy(vars->v0, hit->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); - 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); - - if (carrier != 0) { - add_vector_xyz(vars->velocity, vars->velocity, carrier + 0x10); - scale_vector_xyz(point, carrier + 0x10, convert_integer_to_float(frames)); - add_vector_xyz(vars->v20, vars->v20, point); - add_vector_xyz(vars->v0, vars->v0, point); + if (FUN_L00_001f0d60(0.25f, &m->pos, 0x22, m) != 0) { + subtract_vector_xyz(a, &m->pos, D_L08_00174660_p.pos); + FUN_L00_001ff660(d->v40, d->v40, a); + if (fast_arc_tan(a[2], func_001F9CE8_2E16A0(a)) < 0.7853982f + && fast_arc_tan(((Coll_4BE8 *)((char *)&D_L08_00174660_p - 0x20))->n[2], func_001F9CE8_2E16A0(D_L08_00174660_p.n)) < 0.7853982f) { + Coll_4BE8 *cl = (Coll_4BE8 *)((char *)&D_L08_00174660_p - 0x20); + int n; + float inv; + + m->flags &= ~0x100; + d = (Vars_4BE8 *)m->pvars; + n = truncate_float_to_s32_c5(FUN_001f96b0(D_L08_00161CD0_p + random_float_between_c5(-10.0f, 10.0f))); + inv = 1.0f / convert_integer_to_float(n); + qcopy(d->v0_p, cl->pos); + matrix_to_euler(&m->rot_row0, &m->rot); + fast_vec_normalize_c2(a, cl->n, 1.0f); + FUN_L08_002e4db8_c((char *)m, a); + d->f60 = random_angle_radians_c2(); + d->f64 = random_angle_radians_c2(); + FUN_L08_002e4e90_c((char *)m, d->v20, d->v30); + subtract_vector_xyz(d->v40, d->v20, &m->pos); + fast_vec_scale_c(d->v40, d->v40, inv); + if (cl->moby != 0) { + unsigned char *q = FUN_L00_002603d0(cl->moby); + + if (q != 0) { + add_vector_xyz(d->v40, d->v40, q + 0x10); + fast_vec_scale_c(b, q + 0x10, convert_integer_to_float(n)); + add_vector_xyz(d->v20, d->v20, b); + add_vector_xyz(d->v0_p, d->v0_p, b); } } - 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; - 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) { - Vars_4BE8 *vars = (Vars_4BE8 *)moby->pvars; - - vars->timer = scale_game_frames_alt(1); - moby->state = 2; + d->v40[2] += D_0015ED70_p * 10.8f * (float)(n >> 1); + d->f50 = fast_subtract_rotations_c2(d->v30[0], m->rot.x) * inv; + d->f54 = fast_subtract_rotations_c2(d->v30[1], m->rot.y) * inv; + d->f58 = fast_subtract_rotations_c2(d->v30[2], m->rot.z) * inv; + m->state = 5; + d->i68 = n; + d->u7C.i = D_L08_001746D8_4BE8; + if (absolute_float(m->pos.z - ((Hero *)(((char *)&D_0013F350_p)))->motion.pos.f[2]) < ((Hero *)(((char *)&D_0013F350_p)))->reach_distance + && vector_distance_xy_alt(&m->pos, ((Hero *)(((char *)&D_0013F350_p)))->motion.pos.f) < ((Hero *)(((char *)&D_0013F350_p)))->reach_height) { + Vars_4BE8 *e = (Vars_4BE8 *)m->pvars; + + e->i68 = scale_game_frames_c(1); + m->state = 2; } } } break; } 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); - add_vector_xyz(&moby->pos, &moby->pos, vars->velocity); - vars->velocity[2] -= D_0015ED70 * 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); - moby->state = 2; + Vars_4BE8 *d = (Vars_4BE8 *)m->pvars; + + m->rot.x = fast_add_rotations_c4(m->rot.x, d->f50); + m->rot.y = fast_add_rotations_c4(m->rot.y, d->f54); + m->rot.z = fast_add_rotations_c4(m->rot.z, d->f58); + add_vector_xyz(&m->pos, &m->pos, d->v40); + d->v40[2] -= D_0015ED70_p * 10.8f; + if (tick_countdown_32_alt(&d->i68) != 0) { + int n; + float inv; + + if (absolute_float(m->pos.z - ((Hero *)(((char *)&D_0013F350_p)))->motion.pos.f[2]) < ((Hero *)(((char *)&D_0013F350_p)))->reach_distance + && vector_distance_xy_alt(&m->pos, ((Hero *)(((char *)&D_0013F350_p)))->motion.pos.f) < ((Hero *)(((char *)&D_0013F350_p)))->reach_height) { + d->i68 = scale_game_frames_c(1); + m->state = 2; break; } - if (moby->command != 0) { - moby->state = 1; - if (vars->u7C.i != 0) { - Vars_4BE8 *vars = (Vars_4BE8 *)moby->pvars; + if (m->command != 0) { + m->state = 1; + if (d->u7C.i != 0) { + Vars_4BE8 *e = (Vars_4BE8 *)m->pvars; - FUN_L00_00260668(moby, vars->u7C.i, vars->v0, vars->v10, vars->v20, vars->v30); + FUN_L00_00260668(m, e->u7C.i, e->v0_p, e->v10, e->v20, e->v30); } else { - qcopy(&moby->pos, vars->v20); - qcopy(&moby->rot, vars->v30); + qcopy(&m->pos, d->v20); + qcopy(&m->rot, d->v30); } break; } - frames = truncate_float_to_s32((float)scale_game_frames_alt(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; - subtract_vector_xyz(vars->velocity, vars->v20, &moby->pos); - scale_vector_xyz(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); + n = truncate_float_to_s32_c5((float)scale_game_frames_c(20)); + inv = 1.0f / convert_integer_to_float(n); + m->command++; + d->f50 = fast_subtract_rotations_c2(d->v30[0], m->rot.x) * inv; + d->f54 = fast_subtract_rotations_c2(d->v30[1], m->rot.y) * inv; + d->f58 = fast_subtract_rotations_c2(d->v30[2], m->rot.z) * inv; + subtract_vector_xyz(d->v40, d->v20, &m->pos); + fast_vec_scale_c(d->v40, d->v40, inv); + d->i68 = n; + if (d->u7C.i != 0) { + unsigned char *q = FUN_L00_002603d0(d->u7C.i); + + if (q != 0) { + add_vector_xyz(d->v40, d->v40, q + 0x10); + fast_vec_scale_c(a, q + 0x10, convert_integer_to_float(n)); + add_vector_xyz(d->v20, d->v20, a); + add_vector_xyz(d->v0_p, d->v0_p, a); } } - vars->velocity[2] += D_0015ED70 * 10.8f * (float)(frames >> 1); + d->v40[2] += D_0015ED70_p * 10.8f * (float)(n >> 1); } break; } } } -#endif #include "qcopy.h" diff --git a/src/overlays/l10/gameplay/entities/platform.c b/src/overlays/l10/gameplay/entities/platform.c index 7e7df1334a..1139f456be 100644 --- a/src/overlays/l10/gameplay/entities/platform.c +++ b/src/overlays/l10/gameplay/entities/platform.c @@ -413,136 +413,172 @@ 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 Ent *D_L10_0015FFD8_c __asm__("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 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 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_alt(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 FUN_L00_001ff290(void *, void *, void *); 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) { - int *data = *(int **)(moby + 0x78); +extern void fast_vec_normalize_c(void *, void *, f32) __asm__("FUN_001f9bf8"); +extern char *D_L10_00160058_00299818 __asm__("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_001FF240_2BFBB8 ((void (*)(void *, void *, void *))FUN_L00_001ff290) +#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_alt) +#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 *m) +{ + int *data = *(int **)(m + 0x78); float position[4]; float velocity[4]; - float offset_buffer[4]; - float *offset; + float offset[4]; float angle; + float *op; int i; - if ((unsigned char)moby[0x20] == 0) { + char *g; + int life; + if (*(unsigned char *)(m + 0x20) == 0) { D_L10_001618A8 = 0; - D_001618A4 = FUN_001f96f8(D_001618A4); - D_001618A0 = FUN_001f96f8(D_001618A0); - moby[0x20] = 1; - } - if (hero.vehicle_mode == 1 && *data != -1 && vector_distance(moby + 0x10, &hero.motion.pos) < 0.5f) { - offset = offset_buffer; + D_L10_001618A4 = func_001F9850_2BFBB8(D_L10_001618A4); + D_L10_001618A0 = func_001F9850_2BFBB8(D_L10_001618A0); + *(unsigned char *)(m + 0x20) = 1; + } + g = D_0013F350; + if ((unsigned char)g[0x20A4] == 1 && *data != -1 && + func_001F9D48_2BFBB8(m + 0x10, g + 0x80) < 0.5f) { + op = offset; i = 9; do { float size, size_scaled; - int red, green, blue, color, life, spin; + int red, green, blue, color, spin, gk; 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); + func_L00_001FF240_2BFBB8(op, 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)); + gk = (green << 8) | 0x7f000000; + color = (blue << 16) | gk | 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)m); { - char *effect = (char *)D_L10_0015FFD8 + (*data << 8); - FUN_L00_00216f90(effect + 0x10, effect + 0x40, 0x43, 0); + int di = *data << 8; + char *effect = D_L10_00160058_00299818 + di; + func_L00_00217718_2BFBB8(effect + 0x10, effect + 0x40, 0x43, 0); } { - char *effect = D_00167280; - D_001618A8 = D_001618A0; + char *b180 = D_L10_00167100; + char *effect = *(char **)(b180 + 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 *e = *(char **)(b180 + 0x180); + short *timer = (short *)(*(char **)(e + 0x70) + 0x20); + *timer = func_001F9850_2BFBB8(0x5a); + qcopy(e + 0x40, e); } } 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, gk; + *(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); + func_L00_001FF240_2BFBB8(op, velocity, D_L10_00160058_00299818 + (*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)); + gk = (green << 8) | 0x7f000000; + color = (blue << 16) | gk | 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 *)(m + 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 +588,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 *)(m + 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]; diff --git a/src/overlays/shared/gameplay/entities/bomb.c b/src/overlays/shared/gameplay/entities/bomb.c index a1d6c431c2..3937322788 100644 --- a/src/overlays/shared/gameplay/entities/bomb.c +++ b/src/overlays/shared/gameplay/entities/bomb.c @@ -989,156 +989,167 @@ 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. */ + +typedef int w128 __attribute__((mode(TI))); - start_position.q = position->q; - m = create_moby_2caf70(0x131); +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 float D_L00_0015F580[] __attribute__((section(".sdata"))); +extern float D_L00_00161890_c __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_002141f8_c2(char *) __asm__("FUN_002141f8"); +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 short D_L00_00161870 __attribute__((sda)); +extern short D_L00_00161874 __attribute__((sda)); +extern short D_L00_00161878 __attribute__((sda)); +extern short 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"); +extern char D_0013E520_c[] __asm__("D_0013E520"); + +char *FUN_L00_002caf70(char *a, char *vec, char *b, float f12, float f13, float f14, float f15) { + float tv[4]; + float lf[4]; + float out[4]; + float tmp[4]; + float v[4]; + unsigned char *m; + char *pos; + char *d; + char *q; + unsigned char *p; + int r; + int r2; + int r3; + int i; + int k; + int *arr; + float len; + float ret; + float fi; + float f16; + float *t; + + t = tv; + *(w128 *)tv = *(w128 *)vec; + m = func_0020D348_m(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; + d = *(char **)(m + 0x78); + *(char **)(d + 0x20) = a; + m[0x30] = 0x7F; + *(short *)(m + 0x32) = 0x7F; + m[0x31] = 1; + *(long *)(m + 0x38) = *(long *)(a + 0x38); + *(float *)(m + 0x40) = D_L00_00161890_c; + *(float *)(m + 0x44) = fast_add_rotations(f15, (&D_L00_00161890_c)[1]); + *(float *)(m + 0x48) = f14; + qcopy(m + 0x10, t); + if (b != 0) { + int rr; + qcopy(d, b + 0x10); + rr = FUN_002141f8_c2(b); + if (rr != 0) { + *(float *)(d + 0x8) = *(float *)(d + 0x8) + *(float *)(rr + 0x10); } else { - *handle = 0; + *(float *)(d + 0x8) = *(float *)(d + 0x8) + 0.5f; } - i++; - handle++; - } while (i < 17); - } + } else { + clear_u64_value_c(d); + } + *(float *)(d + 0x18) = f12; + *(float *)(d + 0x1C) = f13; + *(int *)(d + 0x10) = 0; + *(int *)(d + 0x14) = 0; + r2 = scale_game_frames_c2(0x23); + p = (unsigned char *)((char *)&D_0013E520_c); + r2 = r2 + p[0xF] * 10; + *(int *)(d + 0x28) = 0; + *(short *)(d + 0x24) = r2; + *(short *)(d + 0x26) = r2; + *(w128 *)lf = *(w128 *)(a + 0x10); + lf[2] = t[2]; + r = FUN_001efa68(lf, t, 0, (int)a, 0); + if (r != 0) { + build_spherical_offset(out, D_0015ED6C * 40.0f, *(float *)(m + 0x48), -*(float *)(m + 0x44)); + qcopy(m + 0x10, D_L00_00173E60_c); + t = tmp; + k = 4; + do { + *(w128 *)v = 0; + v[0] = random_float_between_c2(-1.0f, 1.0f); + k--; + v[1] = random_float_between_c2(-1.0f, 1.0f); + v[2] = random_float_between_c2(-1.0f, 1.0f); + *(w128 *)tmp = *(w128 *)v; + FUN_L00_001ff660(v, out, D_L00_00173E80); + len = fast_vec_length(v); + fast_vec_normalize(t, t, len * 0.5f); + add_vector_xyz(v, v, t); + fast_vec_normalize(v, v, random_float_between_c2(D_0015ED6C * 3.0f, D_0015ED6C * 6.0f)); + r = scale_game_frames_c2(10); + r2 = scale_game_frames_c2(15); + r3 = FUN_L00_00257b90_c2(r, r2); + FUN_L00_0026dd20(m + 0x10, (char *)v, 0x7F2F4F6F, r3, 30000.0f); + } while (k >= 0); + p = (unsigned char *)((char *)&D_0013E520_c); + if (p[0xF] == 0) { + FUN_L00_002cbcc0_c(m, 0); + mark_moby_for_removal_c2(m); + return 0; + } + *(int *)(d + 0x28) = *(int *)(d + 0x28) + 1; + if (p[0xF] + 5 < *(int *)(d + 0x28)) { + FUN_L00_002cbcc0_c(m, 1); + mark_moby_for_removal_c2(m); + return 0; + } + FUN_L00_001ff660(out, out, D_L00_00173E80); + *(float *)(m + 0x48) = fast_arc_tan_c2(out[0], out[1]); + len = vector_length_xy(out); + *(float *)(m + 0x44) = -fast_arc_tan_c2(len, out[2]); + return m; + } else { + FUN_L00_0026daa0(m, 0x2F4F7F7F, *(short *)(d + 0x24), -1, *(float *)&D_L00_00161888); + for (i = 0; i < 17; i++) { + q = (char *)FUN_L00_00275158(m + 0x10, (char *)D_L00_0015F580, 1, 0.0f); + if (q != 0) { + *(float *)(q + 0xC) = random_float_between_c2(*(float *)&D_L00_00161870, *(float *)&D_L00_00161874); + fi = convert_integer_to_float_c(i); + f16 = fi / convert_integer_to_float_c(16); + ret = FUN_L00_00257e20(-1.5f, 0.0f, 1.0f, 0.0f, f16); + *(float *)(q + 0xC) = *(float *)(q + 0xC) + (*(float *)&D_L00_00161878 - *(float *)(q + 0xC)) * ret; + r = truncate_float_to_s32_c(ret * -64.0f + 128.0f); + *(int *)(q + 4) = (r << 24) | 0xFFFFFF; + ((int *)(d + 0x2C))[i] = (int)q; + } else { + ((int *)(d + 0x2C))[i] = 0; + } + } + } } return m; } -#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. */ /* Four floats aligned to 16 bytes, the layout moved by one lq/sq. */ diff --git a/src/overlays/shared/rendering/00245c28.c b/src/overlays/shared/rendering/00245c28.c index 82e44ff2fe..c979936b33 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(); @@ -301,7 +301,130 @@ void FUN_L00_00245c28(void) { do_space_transition(); } #ifndef NON_MATCHING -INCLUDE_ASM("config/us/overlays/asm/FUN_L00_002464a8.s", FUN_L00_002464a8); +/* 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 D_00137B80[]; +extern char D_L00_0015FE00[]; +extern char D_L00_001E8B00[]; +extern float D_L00_00182810[]; +extern float D_L00_00182A70[]; +extern int *D_L00_00173E08[]; +extern int D_L00_00183EF0[]; +extern int D_L00_001841F0_c[] __asm__("D_L00_001841F0"); +extern int func_0020C468() __asm__("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_alt(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 *arg0, unsigned char *arg1, int arg2) __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 char D_00138438_c[] __asm__("D_00138438"); +extern char D_001383A0[]; +extern char D_00141EC0[]; +extern int D_0015EE84_2465F8 __asm__("D_0015ED84"); + +void FUN_L00_002464a8(void) { + int i, j; + int *gl; + int *q; + int v; + int *e; + int *data; + int n, len; + int heap_tag, first_size, second_size, scratch; + int *archive, *archive_base; + unsigned char *mask, *level_data; + int x, y, w; + float lim; + unsigned char *pp; + extern int D_L00_001841F0_c[]; + extern char D_00137B80[]; + + D_L00_001841F0_c[4] = 1; + { int i; + for (i = 0; i < 20; i++) { + D_L00_001841F0_c[0x41 + i] = D_L00_00183EF0[i * 2]; + ((float *)D_L00_001841F0_c)[0x2D + i] = 0.65f; + D_L00_001841F0_c[0x55 + i] = D_L00_00183EF0[i * 2 + 1]; + } } + v = D_0015EE84_2465F8; + D_L00_001841F0_c[0x8B] = -1; + D_L00_001841F0_c[0x89] = v > 18 ? 0 : v; + { int i; + for (i = 0; i < 19; i++) { + float a = D_L00_00182810[i * 8], b = D_L00_00182810[i * 8 + 1], c = D_L00_00182810[i * 8 + 2], dd = D_L00_00182810[i * 8 + 3]; + float ee = D_L00_00182810[i * 8 + 4], f = D_L00_00182810[i * 8 + 5], gg = D_L00_00182810[i * 8 + 6], h = D_L00_00182810[i * 8 + 7]; + float p = (ee - gg) / (a - c); + float r = (f - h) / (b - dd); + D_L00_00182A70[i * 4 + 1] = p; + D_L00_00182A70[i * 4 + 3] = r; + D_L00_00182A70[i * 4] = ee - p * a; + D_L00_00182A70[i * 4 + 2] = f - r * b; + } } + pp = (unsigned char *)D_0013D4C0; + if (pp[0x21] != 0) { + D_L00_001841F0_c[0x8C] = 1; + e = (int *)(((char *)&D_00138438_c)) + D_L00_001841F0_c[0x89] * 2; + } else { + D_L00_001841F0_c[0x8C] = 0; + e = (int *)(((char *)&D_001383A0)) + D_L00_001841F0_c[0x89] * 2; + } + if (e[1] != 0) { + gl = D_L00_001841F0_c; + gl[10] = 1; + heap_tag = (int)D_L00_0015FE00; + archive_base = D_L00_00173E08[0]; + archive = (int *)((int)archive_base + 0x9A800); + scratch = e[1] << 7; + load(archive, e[0], e[1]); + gl[0x8B] = stash_send_data((int)archive, scratch, 0x4800, (int)D_L00_001E8B00); + gl[0x8D] = scratch; + func_0020C468((int)archive, (int)archive_base); + archive = archive_base; + first_size = archive[1] - archive[0]; + gl[0] = hud_heap_alloc(first_size, 0, (char *)heap_tag, 0x2DB); + fast_mem_copy_alt((void *)gl[0], (char *)archive + archive[0], first_size); + gl[0] += 8; + gl[1] = gl[0]; + second_size = archive[2] - archive[1]; + gl[5] = hud_heap_alloc(second_size, 0, (char *)heap_tag, 0x2EC); + fast_mem_copy_alt((void *)gl[5], (char *)archive + archive[1], second_size); + gl[2] = hud_heap_alloc(0x1000, 0, (char *)heap_tag, 0x2F3); + for (i = 0; i < 8; i++) { + D_L00_001841F0_c[12 + i * 4] = -1; + D_L00_001841F0_c[13 + i * 4] = -1; + D_L00_001841F0_c[14 + i * 4] = D_L00_001841F0_c[2] + i * 0x200; + } + w = hud_heap_alloc(0x8000, 0, D_L00_0015FE00, 0x2FC); + level_data = ((char *)&D_00141EC0) + D_L00_001841F0_c[0x89] * 0x800; + D_L00_001841F0_c[3] = w; + if (level_data[0] != 0) { + load_map_chunk((void *)D_L00_001841F0_c[3], level_data, D_L00_001841F0_c[5]); + } else { + decode_map_mask_alt((int *)D_L00_001841F0_c[3], (unsigned char *)D_L00_001841F0_c[0], (short *)D_L00_001841F0_c[1]); + } + lim = 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) > lim) { + D_L00_00184394[x / 8 + y * 4] |= 1 << (x - (x / 8) * 8); + } + } + } + } else { + D_L00_001841F0_c[0] = 0; + D_L00_001841F0_c[2] = 0; + D_L00_001841F0_c[3] = 0; + D_L00_001841F0_c[1] = 0; + D_L00_001841F0_c[10] = 0; + } +} #else #endif #include "rnc/storage/disc_table.h" @@ -398,153 +521,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]; - x_slope = (x2 - x3) / (x0 - x1); - y_slope = (y2 - y3) / (y0 - y1); - coefficients[1] = x_slope; - coefficients[3] = y_slope; - coefficients[0] = x2 - x_slope * x0; - coefficients[2] = y2 - y_slope * 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); - } - mask = D_L00_00184394; - for (y = 0; y < 32; y++) { - for (x = 0; x < 32; x++) { - if ((15.5f - (f32)x) * (15.5f - (f32)x) + - (15.5f - (f32)y) * (15.5f - (f32)y) > 256.0f) { - mask[x / 8 + y * 4] |= 1 << (x - (x / 8) * 8); - } - } - } - } else { - D_L00_001841F0_load.first_data = 0; - *(s32 *)0x184218 = 0; - D_L00_001841F0_load.scratch_data = 0; - D_L00_001841F0_load.mask_data = 0; - D_L00_001841F0_load.second_data = 0; - } -} -#endif From e55fb3035661d0504605bcda213cd0b68935dcb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Fri, 16 Oct 2026 19:32:23 +0000 Subject: [PATCH 02/33] overlay: decompile three more level functions from rac1-decomp ports FUN_L14_002b17d8 (plasmabot), FUN_L08_002dabf0 and FUN_L13_00307e98 now match retail. --- src/overlays/l08/gameplay/entities/bomb.c | 618 ++++++++------ src/overlays/l13/gameplay/entities/rocket.c | 613 ++++++++------ .../shared/gameplay/entities/plasmabot.c | 797 ++++++++++-------- 3 files changed, 1172 insertions(+), 856 deletions(-) diff --git a/src/overlays/l08/gameplay/entities/bomb.c b/src/overlays/l08/gameplay/entities/bomb.c index dc65336cfe..78d7407443 100644 --- a/src/overlays/l08/gameplay/entities/bomb.c +++ b/src/overlays/l08/gameplay/entities/bomb.c @@ -1455,317 +1455,421 @@ 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(float, void *, void *) __asm__("FUN_001f9c48"); -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)); +/* 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_p[0x20]; struct Moby *moby; } Hit_2D5FA8_c; + +typedef struct { char pad0_p[0x140]; float x, y; char pad148[0x10]; float f158; } Cam_DBF68; + +typedef struct { char pad0_p[0x40]; struct Moby *target; int r44; } Look_DBF68; + +typedef struct { + char pad0_p[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 *p120; + 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_p[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 Camera46_c D_L08_00167480_p __asm__("D_L08_00167480"); +extern f32 D_0015ED6C_p __asm__("D_0015ED6C"); +extern f32 D_0015ED70_p __asm__("D_0015ED70"); +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_p __asm__("D_L08_00161978") __attribute__((sda)); +extern float D_L08_0016197C_p __asm__("D_L08_0016197C") __attribute__((sda)); +extern float D_L08_00161988_p __asm__("D_L08_00161988") __attribute__((sda)); +extern float D_L08_0016198C_p __asm__("D_L08_0016198C") __attribute__((sda)); +extern float D_L08_00161990_p __asm__("D_L08_00161990") __attribute__((sda)); +extern float D_L08_001675C0_p[] __asm__("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_p __asm__("D_L08_001619AC") __attribute__((sda)); +extern int D_L08_001619D0_p __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"); +s32 fun_00213928_c(void *obj, void *p, void *q, u32 flags, s32 *out, f32 *fp, s32 *kp, s32 idx) __asm__("FUN_00213928"); +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 char D_0013F350_p[] __asm__("D_0013F350"); +extern char D_001413D0_p[] __asm__("D_001413D0"); +extern Hit_2D5FA8_c *find_2D5FA8_c(struct Moby *, int, int) __asm__("FUN_L00_0025a420"); +extern int damage_2D5FA8_c(struct Moby *, Hit_2D5FA8_c *, float *, int, int *, float *, int, int) __asm__("FUN_00213928"); +extern void animate_2D5FA8_c(struct Moby *, int, int, int) __asm__("FUN_00212f90"); +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 func_0020D830_x(struct Moby *) __asm__("FUN_0020c9e0"); +extern void func_L00_002592B0_x(float, void *, void *, float, float, float) __asm__("FUN_L00_00258278"); +extern Cam_DBF68 D_L08_00167500_c __asm__("D_L08_00167480"); 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 *d = (Data_DBF68 *)moby->pvars; + Look_DBF68 look; + float v50[4]; + float v60[4]; + float v70[4]; + int hit; + float damage; + float out; 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; + + damage = 0.0f; + func_L00_00264B40_x(moby, D_L08_001619AC_p, 3.0f, d->blk160); + if (moby->visible != 0) { + if (fast_vec_dist(&moby->pos, D_L08_001675C0_p) < 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 t = convert_integer_to_float_c(D_L08_001619D0_p); + int c = d->s132; + moby->alpha = func_001FA898_2D6C58((float)c + (float)-c * ((float)(D_L08_001619D0_p - d->s130) / t)); + 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) { + damage_2D5FA8_c(moby, find_2D5FA8_c(moby, 0x330000, 0), &d->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; + d->health -= damage; + if (0.0f < d->health) { + if (damage < 1.0f) { + d->tint = 100; + } else { + char *base; + d->f80 = D_0015ED70_p * 30.0f; + d->f88 = D_0015ED6C_p * 5.0f; + d->f8C = D_0015ED6C_p * 7.0f; + d->i94 = 9; + d->f84 = 0.0005f; + d->bAD = 0; + base = ((char *)&D_0013F350_p); + FUN_L00_0025c558(moby, d->blk70, + fast_arc_tan_c2(moby->pos.x - *(float *)(base + 0x80), + moby->pos.y - *(float *)(base + 0x84)), + 6, 1, 0); + d->fC0 = 6.0f; + d->fC4 = 10.0f; + d->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 *base; + d->i94 = 9; + d->f84 = 0.0005f; + d->f80 = D_0015ED70_p * 30.0f; + d->f88 = D_L08_0016198C_p * D_0015ED6C_p; + d->f8C = D_L08_00161990_p * D_0015ED6C_p; + d->bAD = 0; + base = ((char *)&D_0013F350_p); + FUN_L00_0025c558(moby, d->blk70, + fast_arc_tan_c2(moby->pos.x - *(float *)(base + 0x80), + moby->pos.y - *(float *)(base + 0x84)), + 9, 1, 0); + d->fC0 = 6.0f; + d->fC4 = 10.0f; + explode_2D5FA8_c(moby, 0, -1); + d->tint = 0xFA; + moby->state = 0x63; + moby->flags &= 0xEFFF; + d->p120->command = 0; } - FUN_L08_00267948(moby, d + 0x60); + effects_start_2D5FA8_c(moby, d->anim); } - 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; + moby->hit_slot = 0xFF; + look.r44 = FUN_L08_0026a3d0(moby, 16.0f, &look); + if (look.target == 0) { + look.target = *(struct Moby **)(((char *)&D_001413D0_p)); + } + target = look.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); + d->b29 = 1; + d->health = 2.0f; + FUN_L01_0026d930(d->blkD0); + d->fDC = 2.0f; + d->fD8 = 2.0f; + d->f10C = 0.03f; + d->f110 = 0.3f; + d->f114 = 0.25f; + d->fF4 = D_L08_00161978_p * D_0015ED6C_p; + d->b58 = func_001FA898_2D6C58(17.0f); + d->b5A = func_001FA898_2D6C58(10.4f); + clear_u64_value(d->v40); + d->p120 = (struct Moby *)FUN_L08_002daa10_c((char *)moby); + d->p120->command = 1; + d->i128 = scale_game_frames_c2(0xB4); if (moby->prev_seq != 4) { - hit_duration = 0; -change_animation: - blend_moby_animation(moby, 4, 0, hit_duration); + animate_2D5FA8_c(moby, 4, 0, 0); } -set_idle: - moby->state = one; - goto reset_timer; + moby->state = 1; + d->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, d->blkD0, (float *)&d->p120->pos, (char *)d->v40); + if (fast_vec_dist(&moby->pos, &d->p120->pos) < 3.0f) { + if (fast_difference_between_rotations_c3(moby->rot.z, + fast_arc_tan_c2(d->p120->pos.x - moby->pos.x, + d->p120->pos.y - moby->pos.y)) < 0.2617994f) { + if (6.0f < vector_distance_xy_alt(&moby->pos, &target->pos)) { + if (moby->prev_seq != 5) { + animate_2D5FA8_c(moby, 5, 0, 10); + } moby->state = 6; - } else { - *(int *)(d + 0x134) = scale_game_frames(240); - 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; + break; + } + d->i134 = scale_game_frames_c2(0xF0); + { + struct Moby *o = d->p120; + struct Moby *n = (struct Moby *)FUN_L08_002daa10_c((char *)moby); + d->p120 = n; + if (n == 0) { + d->p120 = o; + } + o->command = 0; + d->p120->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(&d->i134) != 0) { + old = d->p120; + if ((d->p120 = (struct Moby *)FUN_L08_002daa10_c((char *)moby)) == 0) { + d->p120 = old; + } + old->command = 0; + d->p120->command = 1; + d->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, d->blkD0, (float *)&d->p120->pos, (char *)d->v40); + if (moby->anim_flags & 2) { + animate_2D5FA8_c(d->p120, 1, 0, scale_game_frames_c2(6)); + qcopy(&moby->pos, &d->p120->pos); + moby->pos.z -= 0.1f; + if (moby->prev_seq != 1) { + animate_2D5FA8_c(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); + d->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, d->blk12C, 0.02f, 0.3f, 0.2f); + if (dist < 20.0f && 8.0f < dist && tick_countdown_32_alt(&d->i128) != 0) { + Cam_DBF68 *cam = &D_L08_00167500_c; + 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 (d->i38 == 0 || !(0.5f < dist)) { + break; + } + attack: + animate_2D5FA8_c(d->p120, 1, 0, scale_game_frames_c2(6)); + if (moby->prev_seq != 2) { + animate_2D5FA8_c(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; + v50[0] = fast_cos_c4(moby->rot.z) * 2.0f; + v50[1] = fast_sin(moby->rot.z) * 2.0f; + v50[2] = 0.0f; + add_vector_xyz(v50, v50, &d->p120->pos); + if (0.2f < vector_distance_xy_alt(&moby->pos, v50)) { + FUN_L00_00259028((char *)moby, d->blkD0, v50, (char *)d->v40); + } + if (moby->anim_flags & 2) { + Cam_DBF68 *cam; + if (vector_distance_xy_alt(&moby->pos, &target->pos) < 6.0f + || (cam = &D_L08_00167500_c, + 0.55850536f < fast_difference_between_rotations_c3(cam->f158, fast_arc_tan_c2(moby->pos.x - cam->x, moby->pos.y - cam->y)))) { + old = d->p120; + if ((d->p120 = (struct Moby *)FUN_L08_002daa10_c((char *)moby)) == 0) { + d->p120 = old; + } + old->command = 0; + d->p120->command = 1; + if (moby->prev_seq != 4) { + animate_2D5FA8_c(moby, 4, 0, scale_game_frames_c2(7)); + } + moby->state = 1; + d->i134 = scale_game_frames_c2(0xF0); + } else { + if (moby->prev_seq != 3) { + animate_2D5FA8_c(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) { - 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); - add_vector_xyz(aim, aim, &moby->pos); - FUN_L00_0024f7c8(moby, 9, point); - subtract_vector_xyz(velocity, &target->pos, point); - set_vector_length_xy(time, velocity, velocity); - 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); + func_L00_002592B0_x(fast_arc_tan_c2(target->pos.x - moby->pos.x, target->pos.y - moby->pos.y), + moby, d->blk12C, 0.02f, 0.3f, 0.2f); + if (moby->seq == moby->prev_seq && func_0020D830_x(moby) == 19.0f) { + float len, t; + char *p; + subtract_vector_xyz(v70, &target->pos, &moby->pos); + v70[2] = 0.0f; + len = fast_vec_length_c2(v70); + t = len / FUN_001f96b0(D_L08_0016197C_p); + len = len - (D_L08_00161988_p * t + 2.0f); + if (10.0f < len) { + len = 10.0f; + } else if (len < 3.0f) { + len = 3.0f; + } + FUN_L00_0025f730(v70, len); + add_vector_xyz(v70, v70, &moby->pos); + func_L00_00250800_2D6C58(moby, 9, v50); + subtract_vector_xyz(v60, &target->pos, v50); + set_vector_length_xy(v60, v60, t); + v60[2] = FUN_L00_0025abf0(v50, v70, &out, t, -(D_0015ED70_p * 15.0f)); + p = FUN_L08_002d22e0_c((int)moby, (char *)v50, (char *)v60); + d->p124 = (struct Moby *)p; + if (p != 0) { + char *pd = *(char **)(p + 0x78); + *(int *)(pd + 0x20) = scale_game_frames_c2(0xB4); + *(short *)(pd + 0xC) = scale_game_frames_c2(10); + *(short *)(pd + 0xE) = scale_game_frames_c2(10); + d->p124->state = 1; + d->p124->command |= 3; + d->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) { + animate_2D5FA8_c(moby, 4, 0, 3); + } + d->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) { + animate_2D5FA8_c(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, d->blk70) & 0x40) { + old = d->p120; + if ((d->p120 = (struct Moby *)FUN_L08_002daa10_c((char *)moby)) == 0) { + d->p120 = old; + } else { + old->command = 0; + d->p120->command = 1; + } + if (moby->prev_seq != 4) { + animate_2D5FA8_c(moby, 4, 0, 10); + } moby->state = 1; - *(int *)(d + 0x134) = scale_game_frames(240); + d->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, d->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); + d->s132 = 0x28; + d->s130 = D_L08_001619D0_p; + 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, d->anim); + d->i38 = 0; } -#endif /* Pvars of the hero-carrying lift. */ typedef struct { u8 pad0[0x20]; diff --git a/src/overlays/l13/gameplay/entities/rocket.c b/src/overlays/l13/gameplay/entities/rocket.c index 1a6ab62e6c..f1268c2ce2 100644 --- a/src/overlays/l13/gameplay/entities/rocket.c +++ b/src/overlays/l13/gameplay/entities/rocket.c @@ -742,313 +742,390 @@ 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 u32 VecQuad_p __attribute__((mode(TI), aligned(16))); + +typedef struct { + u8 pad0_p[0x18]; + u8 unk18; + u8 unk19; + s16 oclass; + u8 pad1C[0x14]; +} Shot_309330; + +typedef struct { + s32 unk0_p; + f32 unk4; + f32 unk8; + f32 unkC; + u8 pad10[0x14]; + f32 unk24; + u8 pad28[0x18]; +} Ctl_309330; + +typedef struct { + u8 pad0_p[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_p[] __asm__("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 D_0015ED6C_p __asm__("D_0015ED6C"); +extern float D_0015ED70_p __asm__("D_0015ED70"); +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_p __asm__("D_L13_00161E70"); +extern int D_L13_00161E74_p __asm__("D_L13_00161E74") __attribute__((sda)); +extern int D_L13_00161E78_p __asm__("D_L13_00161E78") __attribute__((sda)); +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 short D_L13_00161E58_p __asm__("D_L13_00161E58") __attribute__((sda)); +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 blend_moby_animation_c(void *, s32, s32, s32) __asm__("FUN_00212f90"); +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_00161EE8_309330 __asm__("D_L13_00161E58") __attribute__((sda)); +extern int D_L13_00161F00_309330 __asm__("D_L13_00161E70"); +extern float D_L13_00161F04_309330 __asm__("D_L13_00161E74") __attribute__((sda)); +extern float D_L13_00161F08_309330 __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 a; + Vec4 b; + Vec4 c; + Shot_309330 shot; + s32 near; + s32 close; + 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_p) < 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_p = func_001FA898_r(D_L13_00161EE8_309330 * 716.8f); + vars->ctl.unk4 = D_L13_00161EE8_309330 * 0.7f; + vars->ctl.unk24 = D_L13_00161F08_309330 * D_0015ED6C_p * 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, D_0015ED70_p * 6.2831855f, D_0015ED70_p * 6.2831855f, D_0015ED6C_p * 3.1415927f); + if (vars->unk164 != 2) { + f32 dist = vector_distance_xy_alt(&moby->pos, &target->pos); + if (D_L13_00161F04_309330 < 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_c(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_c(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_c(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_c(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; + case 2: + if (moby->anim_flags & 2) { + moby->state = 3; + FUN_L13_00309370_c((char *)moby); + if (moby->prev_seq != 5) { + blend_moby_animation_c(moby, 5, 0, scale_game_frames(10)); + } } - 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))) { + 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_c(moby, 4, 0, scale_game_frames(20)); + } + vars->timer = scale_game_frames(D_L13_00161F00_309330); + } else { + moby->state = 1; + if (moby->prev_seq != 0) { + blend_moby_animation_c(moby, 0, 0, scale_game_frames(20)); + } + } + } + break; + 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, D_0015ED70_p * 6.2831855f, D_0015ED70_p * 6.2831855f, D_0015ED6C_p * 3.1415927f); + if (tick_countdown_32_alt(&vars->timer) != 0) { 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_c(moby, 5, 0, scale_game_frames(5)); + } + } else if (vector_distance_xy_alt(&moby->pos, &target->pos) < D_L13_00161F04_309330) { + FUN_L00_0024f7c8(moby, 0, &vars->unk1E0); + moby->state = 5; + if (moby->prev_seq != 6) { + blend_moby_animation_c(moby, 6, 0, scale_game_frames(10)); + } + } else if (vars->unk184 != 0) { + moby->state = 11; + if (moby->prev_seq != 1) { + blend_moby_animation_c(moby, 1, 0, scale_game_frames(20)); + } } - 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 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, D_0015ED70_p * 6.2831855f, D_0015ED70_p * 6.2831855f, D_0015ED6C_p * 3.1415927f); + FUN_L00_0024f7c8(moby, 0, &a); + qcopy(&b, &moby->pos); + b.f[2] += 0.3f; + { + f32 frame = compute_interpolated_record_value(moby); + if (frame >= 9.0f && frame <= 15.0f) { + c.f[0] = fast_cos(moby->rot.z); + c.f[1] = fast_sin(moby->rot.z); + c.f[2] = 1.0f; + c.f[3] = 5627.925f; + func_L00_0025A8C0_30A9B0(&shot, moby, 1, &c, 1.0f); + shot.unk18 = 0; + shot.unk19 = 1; + shot.oclass = moby->oclass; + FUN_L00_00259d08(&a, &b, &vars->unk1E0, &b, moby, &shot, 5); + } + } + qcopy(&vars->unk1E0, &a); + if (moby->anim_flags & 2) { + moby->state = 6; + moby->command = 1; + if (moby->prev_seq != 2) { + blend_moby_animation_c(moby, 2, 0, scale_game_frames(10)); + } } 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) { - 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); - } - qcopy(data + 0x1e0, &next); + case 6: 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 = moby->command; + if (moby->prev_seq != 0) { + blend_moby_animation_c(moby, 0, 0, scale_game_frames(20)); + } } 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 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, D_0015ED6C_p * 6.2831855f); + a.f[0] = 2.0f * fast_cos(moby->rot.z); + a.f[1] = 2.0f * fast_sin(moby->rot.z); + a.f[2] = 0.0f; + if (FUN_L00_00258b50(moby, &vars->ctl, &a, &b, 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); + close = 0; + if (FUN_L00_00261b48(vars->path, &moby->pos, &target->pos, &c) != 0 && + fast_vec_dist(&moby->pos, &c) < 0.8f) { + close = 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_c(moby, 3, 0, scale_game_frames(10)); + } + } else if (close != 0) { + moby->state = 2; + if (moby->prev_seq != 3) { + blend_moby_animation_c(moby, 3, 0, scale_game_frames(10)); + } + } else if (dist < D_L13_00161F04_309330) { + moby->state = 5; + if (moby->prev_seq != 6) { + blend_moby_animation_c(moby, 6, 0, scale_game_frames(10)); + } + } } break; - } - case 11: { - float distance; - int blocked; - 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; + case 11: + near = 0; + 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, + D_0015ED6C_p * 6.2831855f); + a.f[0] = 2.0f * fast_cos(moby->rot.z); + a.f[1] = 2.0f * fast_sin(moby->rot.z); + a.f[2] = 0.0f; + FUN_L00_00258b50(moby, &vars->ctl, &a, &b, 1.0f); + FUN_L00_00261d78(vars->path, &moby->pos, &moby->pos, 0.75f); + if (FUN_L00_00261b48(vars->path, &moby->pos, &target->pos, &c) != 0 && + fast_vec_dist(&moby->pos, &c) < 0.8f) { + near = 1; + } + if (vars->unk184 == 0) { + moby->state = 13; + } else if (near != 0) { + moby->state = 12; + if (moby->prev_seq != 6) { + blend_moby_animation_c(moby, 6, 0, scale_game_frames(10)); + } + } else if (vector_distance_xy_alt(&moby->pos, &target->pos) < D_L13_00161F04_309330) { + FUN_L00_0024f7c8(moby, 0, &vars->unk1E0); + moby->state = 12; + if (moby->prev_seq != 6) { + blend_moby_animation_c(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) { - 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); - } - qcopy(data + 0x1e0, &next); + case 12: + FUN_L00_0024f7c8(moby, 0, &a); + qcopy(&b, &moby->pos); + b.f[2] += 1.5f; + { + f32 frame = compute_interpolated_record_value(moby); + if (frame >= 9.0f && frame <= 15.0f) { + c.f[0] = fast_cos(moby->rot.z); + c.f[1] = fast_sin(moby->rot.z); + c.f[2] = 1.0f; + c.f[3] = 5627.925f; + func_L00_0025A8C0_30A9B0(&shot, moby, 1, &c, 1.0f); + shot.unk18 = 0; + shot.unk19 = 1; + shot.oclass = moby->oclass; + FUN_L00_00259d08(&a, &b, &vars->unk1E0, &b, moby, &shot, 5); + } + } + qcopy(&vars->unk1E0, &a); 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_c(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, D_0015ED6C_p * 6.2831855f); + a.f[0] = 2.0f * fast_cos(moby->rot.z); + a.f[1] = 2.0f * fast_sin(moby->rot.z); + a.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, &a, &b, 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_c(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_c(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. */ diff --git a/src/overlays/shared/gameplay/entities/plasmabot.c b/src/overlays/shared/gameplay/entities/plasmabot.c index d13f5d4399..ffde2a8e27 100644 --- a/src/overlays/shared/gameplay/entities/plasmabot.c +++ b/src/overlays/shared/gameplay/entities/plasmabot.c @@ -211,148 +211,279 @@ 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); + +/* 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 { + char _pad00_p[0x10]; + unsigned char nframes; +} AnimSeq_2b17d8; + +typedef int u128_96938_p __attribute__((mode(TI))); + +struct Manip; + +typedef struct MobyClass MobyClass; + +typedef struct { + float a_p; + float b; + float c; + float d; + char *moby; + int flags; + unsigned char b98; + unsigned char b99; + unsigned short cls; + float e; + int f; +} Ray; + +typedef struct { + f32 x_p; + f32 y; + f32 z; + f32 w; +} Vec4f_00AC8; + +struct MobyClass_00AC8_p { + u8 pad_0[0xC]; + u8 seq_count; /* number of entries in seqs[] (menu previews clamp the sequence to it) */ + u8 pad_D[3]; + u32 collision; /* collision data; copied into struct Moby.collision when a_p moby is (re)classed */ + u8 pad_14[0x8]; + void *retarget_table; /* retarget table: word table, indexed id * 4 + 4 (0024eec0) */ + struct GifEntry *gifs; /* patched by patch_moby_gifs */ + f32 scale; /* default draw scale: copied into struct Moby.scale, divides it */ + s32 sound_defs; /* sound definitions, 0x20 bytes each */ + void **callbacks; /* function-pointer table, called with the moby */ + u8 pad_30[0x14]; + u16 flags; /* initial struct Moby.flags */ + s16 type; /* class type; 5 (a_p creature) is tested by targeting code */ + struct AnimSeq_2b17d8 *seqs[1]; /* animation sequences, indexed by struct Moby.seq */ +}; + +struct Moby_00AC8_p { + Vec4f_00AC8 bsphere; + Vec4f_00AC8 pos; + u8 state; /* >= 0xFE: dead, waiting to respawn */ + u8 group; /* linked group: index into the level moby-list table D_Lxx_001ABCC0 (0xFF: none) */ + u8 class_slot; /* class slot: pclass = D_L00_00197300[class_slot] (crate_update) */ + u8 alpha; /* 0x80 by default; 0x40 for the smoke trail FUN_L09_00307ba8 spawns */ + struct MobyClass_00AC8_p *pclass; + struct Moby_00AC8_p *next; + f32 scale; /* draw scale (FUN_L01_002fa068 halves it, FUN_L00_00215ef8 divides by it) */ + u8 update_dist; /* update distance; 0xFF (always) or 0x7F for beams, set by spawners */ + u8 visible; /* drawn last frame; set to 1 by spawners */ + s16 draw_dist; /* draw distance; 0xFF (0x7F for beams), set by spawners */ + u16 flags; + u16 occlusion; /* occlusion bits; 0x7F80 set by spawners */ + u64 spawn_frame; /* frame count at which it may respawn */ + Vec4f_00AC8 rot; /* z: yaw (FUN_L00_00266448 compares it with atan2 to the hero) */ + u8 frame; /* animation frame */ + u8 prev_frame; /* frame index in prev_seq */ + u8 seq; /* animation sequence id */ + u8 prev_seq; + f32 anim_time; + f32 anim_speed; + u8 pad5C[8]; + struct Manip *manips; + void *cur_frame_data; + void *prev_frame_data; + u8 anim_flags; + u8 unk71; /* set to 0xFF when a_p moby changes class */ + u8 unk72; + u8 unk73; + void (*update)(struct Moby_00AC8_p *moby); + u8 *pvars; + u8 unk7C; + u8 sound_slot; /* 0x7D: D_0013E550 slot of its looping sound, 0xFF: none (FUN_L00_00232670) */ + u8 anim_trigger_count; + u8 shadow_range; /* shadow range in units of 1024; 0x17 from FUN_L09_002c5990 near D_L09_00166F40 */ + u8 pad80[6]; + s16 unk86; + u8 pad88[8]; + s32 glow_color; /* glow colour (class header + 0x40) */ + u32 collision; /* collision data, from the class header (MobyClass.collision) */ + s32 collision_disable; /* per-primitive collision disable bits; 1 while a_p carrier holds the moby (FUN_L00_002c7a58) */ + u8 pad9C[8]; + u8 hit_slot; /* hit-message slot (0xFF: none) */ + u8 padA5; + s16 oclass; + u8 padA8[8]; + u8 mission; /* 0xB0: index into the level's D_0014C050 row (0xFF: not spawned) */ + u8 padB1; + u16 save_id; /* index into the level collected[]/killed[] tables and save bits D_0014C190[level][id >> 5] */ + s16 unkB4; + u8 padB6[2]; + void *parent; /* 0xB8: spawner (bolt source record); its byte 0xB1 is a_p per-level id (FUN_L00_002a6b70) */ + u8 command; /* external command byte */ + u8 padBD[3]; + Vec4f_00AC8 rot_row0; /* 0xC0: rows of the matrix built from rot (FUN_001fa030) */ + Vec4f_00AC8 rot_row1; + Vec4f_00AC8 rot_row2; + u8 padF0[0x10]; +}; + +typedef struct Moby_00AC8_p Moby_00AC8_p; + +extern char D_001413F4_p[] __asm__("D_001413F4"); +extern char D_L14_001FBB60_p[] __asm__("D_L14_001FBB60"); +extern char D_L14_001FBBA0_p[] __asm__("D_L14_001FBBA0"); +extern char D_L14_001FBBF8_p[] __asm__("D_L14_001FBBF8"); +extern char D_L14_001FBC38_p[] __asm__("D_L14_001FBC38"); +extern char D_L14_001FBC90_p[] __asm__("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 D_0015ED6C_p __asm__("D_0015ED6C"); +extern float D_0015ED70_p __asm__("D_0015ED70"); +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_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 float probe_ground_height(float, void *, int); +extern int *D_L14_001B0BB0_p[] __asm__("D_L14_001B0BB0"); +extern int D_L14_0015F5C4_p __asm__("D_L14_0015F5C4"); +extern int FUN_001efa68(void *, void *, int, void *, void *); +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 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[]; - -typedef struct { - float x, y, scale, distance; - void *moby; - int flags; - unsigned char mode, 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) { - *(unsigned short *)(moby + 0x34) |= 0x41; - *(int *)(moby + 0x94) = 0; - 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; +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 short D_L14_001614E4_p __asm__("D_L14_001614E4") __attribute__((sda)); +extern short D_L14_001614E8_p __asm__("D_L14_001614E8") __attribute__((sda)); +extern short D_L14_001614EC_p __asm__("D_L14_001614EC") __attribute__((sda)); +extern short D_L14_001614F0_p __asm__("D_L14_001614F0"); +extern short D_L14_001614F4_p __asm__("D_L14_001614F4") __attribute__((sda)); +extern u8 D_L14_00174560_p[] __asm__("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_00AC8_p *, 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_alt(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 x_p) __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 *a_p, float x_p) __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 *m) { + char *data; + char *owner; + int st; + float mat[4][4]; + float v[4]; + float hit[4]; + Ray ray; + int x_p; + + data = *(char **)(m + 0x78); + owner = 0; + FUN_L00_00263ac8(2.5f, m, 2, data + 0x120); + if (*(int *)(data + 0x288) != 0) { + if (((unsigned char *)D_001413F4_p)[0] != 2) { + *(unsigned short *)(m + 0x34) |= 0x41; + *(int *)(m + 0x94) = 0; + if (((unsigned char *)m)[0x53] == 5) { + FUN_L00_002e2040(m); + FUN_L00_00257470(m, 0, -1); + { call_D678(m); return; } } + ((unsigned char *)m)[0x30] = 0xFF; + *(unsigned short *)(m + 0x34) &= 0xEFFF; return; } - *(unsigned short *)(moby + 0x34) &= 0xFFBE; - if ((unsigned char)moby[0x20] != 11) - *(int *)(moby + 0x94) = *(int *)(*(char **)(moby + 0x24) + 0x10); - 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 (mode == 2) { - moby[0x31] = 0; - *(unsigned short *)(moby + 0x34) |= 1; - } else if ((unsigned char)moby[0x20] != 1) { - moby[0x31] = 1; - *(unsigned short *)(moby + 0x34) &= 0xFFFE; - } - switch ((unsigned char)moby[0x20]) { + *(unsigned short *)(m + 0x34) &= 0xFFBE; + if (((unsigned char *)m)[0x20] != 0xB) { + *(int *)(m + 0x94) = *(int *)(*(char **)(m + 0x24) + 0x10); + } + ((unsigned char *)m)[0x30] = 0x40; + *(unsigned short *)(m + 0x34) |= 0x1000; + } + if (((unsigned char *)m)[0x20] != 0) { + FUN_L14_002b2f60_c(m); + FUN_L14_002b3268_c(m); + FUN_L14_002b2ed8_c((struct Moby *)m); + owner = *(char **)(data + 0x110); + } + if (D_L14_0015F5C4_p == 2) { + ((unsigned char *)m)[0x31] = 0; + *(unsigned short *)(m + 0x34) |= 1; + } else if (((unsigned char *)m)[0x20] != 1) { + ((unsigned char *)m)[0x31] = 1; + *(unsigned short *)(m + 0x34) &= 0xFFFE; + } + switch (((unsigned char *)m)[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_p, *(short *)(m + 0xB2)); + { call_D678(m); return; } + } + if (*D_L14_001B0BB0_p[*(int *)(data + 0x240)] == 0) { + DebugPrint(D_L14_001FBBA0_p, *(short *)(m + 0xB2)); + { call_D678(m); return; } + } + } + if (*(int *)(data + 0x244) == -1) { + DebugPrint(D_L14_001FBBF8_p, *(short *)(m + 0xB2)); + { call_D678(m); return; } + } + if (*D_L14_001B0BB0_p[*(int *)(data + 0x244)] == 0) { + DebugPrint(D_L14_001FBC38_p, *(short *)(m + 0xB2)); + { call_D678(m); 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_p, *(short *)(m + 0xB2)); + { call_D678(m); return; } + } + if (random_integer_below(2) != 0) { + *(unsigned short *)(m + 0x34) |= 0x8000; + } + FUN_L14_002b3358_c(m); if (*(int *)(data + 0x240) != -1) { - p = (char *)D_L14_001B0BB0[*(int *)(data + 0x240)]; - qcopy(moby + 0x10, p + 0x10); + qcopy(m + 0x10, (char *)D_L14_001B0BB0_p[*(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,264 +494,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(m, 2, data + 0x120); + } + if (((unsigned char *)data)[0x161] == 0) { + attach_manipulator(m, 3, data + 0x160); + } + if (((unsigned char *)data)[0x24A] != 0) { + FUN_L14_002b3318_c(m); + ((unsigned char *)m)[0x20] = 1; + return; + } + *(float *)(m + 0x18) = probe_ground_height(0.5f, m + 0x10, 0); + if (*(int *)(data + 0x240) == -1) { + ((unsigned char *)m)[0x20] = 4; + } else { + ((unsigned char *)m)[0x20] = 0xD; + } return; } case 1: { - char *p; - float f; + float *p; 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(m) == 0) return; + *(short *)(data + 0x248) = scale_game_frames(*(int *)&D_L14_001614F0_p); + FUN_L14_002b3330_c(m); + ((unsigned char *)m)[0x20] = 2; + set_moby_animation_alt(m, 1, 0); + p = (float *)D_L14_001B0BB0_p[*(int *)(data + 0x240)]; + *(float *)(m + 0x48) = fast_arc_tan_c(p[8] - p[4], p[9] - p[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(m) >= 3.0f) { + FUN_L14_002b3418_c(m); + } + if ((m[0x70] & 2) && ((unsigned char *)m)[0x52] == ((unsigned char *)m)[0x53]) { + ((unsigned char *)m)[0x20] = 3; + blend_moby_animation(m, 3, 0, scale_game_frames(10)); + *(float *)(m + 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 *p = (float *)D_L14_001B0BB0_p[*(int *)(data + 0x240)]; + FUN_L00_0025b8c0((float *)(m + 0x10), (float *)(data + 0x254), p[4], 0.01f, 0.2f, 0.0f); + FUN_L00_0025b8c0((float *)(m + 0x14), (float *)(data + 0x258), p[5], 0.01f, 0.2f, 0.0f); + if ((m[0x70] & 2) && ((unsigned char *)m)[0x52] == ((unsigned char *)m)[0x53]) { + blend_moby_animation(m, 0, 0, scale_game_frames(10)); + ((unsigned char *)m)[0x20] = 1; + *(float *)(m + 0x58) = 1.0f; + FUN_L14_002b3318_c(m); + 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)); - 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; - } + ang = fast_arc_tan_c(*(float *)(owner + 0x10) - *(float *)(m + 0x10), + *(float *)(owner + 0x14) - *(float *)(m + 0x14)); + k = D_0015ED70_p * 12.566371f; + call_CE58((float *)(m + 0x48), ang, (float *)(data + 0x23C), k, k, D_0015ED6C_p * 6.2831855f); + if (*(int *)(data + 0x114) == 2) break; + if (FUN_001f9770(data + 0x248) == 0) break; + ((unsigned char *)m)[0x20] = 3; + blend_moby_animation(m, 3, 0, scale_game_frames(10)); + *(float *)(m + 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(m) != 0) { + blend_moby_animation(m, 0, 0, scale_game_frames(10)); + ((unsigned char *)m)[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(m) != 0) { + if (((unsigned char *)data)[0x24A] != 0) { + blend_moby_animation(m, 2, 0, scale_game_frames(10)); + ((unsigned char *)m)[0x20] = 9; + } else { + *(short *)(data + 0x248) = scale_game_frames(*(int *)&D_L14_001614F0_p); + ((unsigned char *)m)[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)); - 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); + float aim; + FUN_L14_002b3578_c(m); + ang = fast_arc_tan_c(*(float *)(owner + 0x10) - *(float *)(m + 0x10), + *(float *)(owner + 0x14) - *(float *)(m + 0x14)); + k = D_0015ED70_p * 12.566371f; + call_CE58((float *)(m + 0x48), ang, (float *)(data + 0x23C), k, k, D_0015ED6C_p * 6.2831855f); + aim = FUN_L14_002b35d8_c(m, 0, *(float *)(m + 0x48)); + FUN_L14_002b37b0_c(m, 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 *)m)[0x20] = 8; + if (((unsigned char *)m)[0x53] != 3) { + blend_moby_animation(m, 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 *pe; + *(int *)(data + 0x24C) = n; + pe = (char *)D_L14_001B0BB0_p[*(int *)(data + 0x240)]; + *(float *)(data + 0x250) = *(float *)(pe + (n << 4) + 0x1C); } + *(float *)(data + 0x27C) = -1.0f; + *(float *)(data + 0x254) = *(float *)(data + 0x258) = *(float *)(data + 0x25C) = 0.0f; + FUN_L00_002e2040(m); + break; } + if (FUN_001f9770(data + 0x260) == 0) break; + if (FUN_L14_002b3920_c(((unsigned char *)m)[0x21]) >= 2) break; + if (FUN_L00_002e1f28(m, 1, 0) == 0) break; + if (random_integer_below(4) != 0) break; + if (!(fast_difference_between_rotations(*(float *)(m + 0x48), ang) < 0.017453292f)) break; + if (!(aim < 0.017453292f)) break; + if (FUN_L00_00261968(*(int *)(data + 0x244), m + 0x10, owner + 0x10) != 0) break; + FUN_L14_002b3890_c(((unsigned char *)m)[0x21]); + *(float *)(data + 0x278) = ang; + ((unsigned char *)m)[0x20] = 5; + blend_moby_animation(m, 4, 0, scale_game_frames(5)); + *(short *)(data + 0x262) = scale_game_frames(*(int *)&D_L14_001614EC_p); 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 *)(m + 0x10), + *(float *)(owner + 0x14) - *(float *)(m + 0x14)); + FUN_L14_002b35d8_c(m, 0, fast_subtract_rotations_c2(ang, *(float *)&D_L14_001614E8_p)); + FUN_L14_002b37b0_c(m, ang); + if ((m[0x70] & 2) && ((unsigned char *)m)[0x52] == ((unsigned char *)m)[0x53]) { + blend_moby_animation(m, 5, 0, scale_game_frames(10)); + ((unsigned char *)m)[0x20] = 6; + } break; } case 6: { - float angle; - float f; - float duration; int flag; + float ang; + float t; + float c; + float f; 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); - 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.scale = 1.0f; - info.distance = 5627.9248046875f; - 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; + ang = fast_arc_tan_c(*(float *)(owner + 0x10) - *(float *)(m + 0x10), + *(float *)(owner + 0x14) - *(float *)(m + 0x14)); + t = convert_integer_to_float(*(short *)(data + 0x262)); + t = t / convert_integer_to_float(scale_game_frames(*(int *)&D_L14_001614EC_p)); + c = *(float *)&D_L14_001614E8_p; + f = fast_subtract_rotations_c2(*(float *)(data + 0x278), -c + (c + c) * t); + if (((unsigned char *)data)[0x24B] != 0) { + if (*(float *)(owner + 0x18) + 0.1f - *(float *)(m + 0x18) < 0.0f) { + flag = 1; + } + } + FUN_L14_002b35d8_c(m, flag, f); + FUN_L14_002b37b0_c(m, ang); + build_moby_bone_transform_c(m, 0, mat); + qcopy(v, mat[1]); + if (flag == 0) { + v[2] = 0.0f; + } + fast_vec_normalize(v, v, *(float *)&D_L14_001614E4_p); + add_vector_xyz_c3(hit, mat[3], v); + fast_vec_normalize(v, v, *(float *)&D_L14_001614F4_p); + add_vector_xyz_c3(mat[3], mat[3], v); + ray.moby = m; + ray.flags = 0x10001; + ray.f = 1; + ray.e = 1.0f; + ray.a_p = fast_cos(*(float *)(m + 0x48)); + ray.b = fast_sin(*(float *)(m + 0x48)); + ray.c = 1.0f; + ray.d = 5627.9248f; + ray.b99 = 1; + ray.cls = *(unsigned short *)(m + 0xA6); + ray.b98 = 0; + if (FUN_001efa68(mat[3], hit, 0, m, &ray) != 0) { + qcopy(hit, D_L14_00174560_p); + } + FUN_L00_002e2190(m, mat, hit); + if (FUN_001f9770(data + 0x262) != 0) { + blend_moby_animation(m, 6, 0, scale_game_frames(10)); + ((unsigned char *)m)[0x20] = 7; + FUN_L00_002e2040(m); + } break; } + case 7: + if ((m[0x70] & 2) && ((unsigned char *)m)[0x52] == ((unsigned char *)m)[0x53]) { + blend_moby_animation(m, 0, 0, scale_game_frames(10)); + ((unsigned char *)m)[0x20] = 4; + } + break; case 10: { - anim = (unsigned char)moby[0x52]; - if (((unsigned char)moby[0x70] & 2) && (unsigned char)anim == (unsigned char)moby[0x53]) { - if ((unsigned char)anim == 7) goto resume_move; - anim = (unsigned char)moby[0x53]; - } else { - if ((unsigned char)anim == 7) goto finish; - anim = (unsigned char)moby[0x53]; + long n = ((unsigned char *)m)[0x52]; + if ((m[0x70] & 2) && (unsigned char)n == ((unsigned char *)m)[0x53]) { + if ((unsigned char)n != 7) goto check_next; + goto idle; } - if ((int)anim == 7) goto finish; -resume_move: - blend_moby_animation(moby, 0, 0, 10); - moby[0x20] = 4; + if ((unsigned char)n == 7) break; + check_next: + if (((unsigned char *)m)[0x53] == 7) break; + idle: + blend_moby_animation(m, 0, 0, 10); + ((unsigned char *)m)[0x20] = 4; break; } case 11: { - - if (!(FUN_L00_0025c698(moby, data + 0x60) & 0x160)) 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_00257470(moby, 0x200, -1); - mark_moby_for_removal((struct Moby *)moby); - return; + if ((FUN_L00_0025c698(m, data + 0x60) & 0x160) == 0) return; + FUN_L00_002e2040(m); + FUN_L00_0024f7c8(m, 2, mat); + FUN_L14_002dea98_c(m, (char *)mat); + call_F4A8(m, data + 0x40, m + 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_p)[0] == 2) { + FUN_L00_00257470(m, 0x200, -1); + { call_D678(m); return; } } - FUN_L00_00257470(moby, 0, -1); - mark_moby_for_removal((struct Moby *)moby); - return; + FUN_L00_00257470(m, 0, -1); + { call_D678(m); 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_002e2040(moby); -remove: - mark_moby_for_removal((struct Moby *)moby); + FUN_L00_0024f7c8(m, 2, mat); + FUN_L14_002dea98_c(m, (char *)mat); + x_p = 0; + ((void (*)(char *, int *, int))FUN_L14_002e0170_c)(m, &x_p, 1); + FUN_L00_002e2040(m); + call_D678(m); 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)); + st = ((unsigned char *)m)[0x20]; + if (!(st >= 4 && st <= 7) && st != 1) { + FUN_L14_002b35d8_c(m, 0, *(float *)(m + 0x48)); + FUN_L14_002b37b0_c(m, *(float *)(m + 0x48)); } - FUN_L14_002b2600((struct Moby *)moby); + FUN_L14_002b2600_c((struct Moby *)m); } -#endif #include "rnc/math/vector.h" #include "rnc/gameplay/entities/moby.h" From f249b42aef715752179716f314eba79a3ba54e3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Fri, 16 Oct 2026 20:18:11 +0000 Subject: [PATCH 03/33] overlay: decompile five more level functions FUN_L00_002382a0 (quick select), FUN_L00_00236268 and FUN_L15_001ff938 come from rac1-decomp ports with their data re-paired against the listing; FUN_L12_00306828 too. FUN_L00_002d09b8 (break_crate) finishes the draft. shared/ui/help/001ff938.c moves to the SN units. --- configure.py | 1 + src/overlays/l12/gameplay/entities/003054b0.c | 52 +-- .../shared/gameplay/entities/veldin_ship.c | 28 +- src/overlays/shared/ui/help/001ff938.c | 206 ++++++----- src/overlays/shared/ui/hud/hud_keep_visible.c | 90 +++-- src/overlays/shared/ui/text/002377b8.c | 349 ++++++++++-------- 6 files changed, 393 insertions(+), 333 deletions(-) diff --git a/configure.py b/configure.py index 7e5c1ca6a7..d2686be878 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/src/overlays/l12/gameplay/entities/003054b0.c b/src/overlays/l12/gameplay/entities/003054b0.c index e7fbd920c1..703af5197f 100644 --- a/src/overlays/l12/gameplay/entities/003054b0.c +++ b/src/overlays/l12/gameplay/entities/003054b0.c @@ -481,53 +481,53 @@ 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_p __asm__("D_L12_0015F5CC"); +extern unsigned char * D_L12_0015FFD8_p_c __asm__("D_L12_0015FFD8"); +extern struct Moby *D_L12_00160058_303CA8 __asm__("D_L12_0015FFD8"); -void FUN_L12_00306828(struct Moby *moby) { +void FUN_L12_00306828(char *moby) { int i; int alpha = 0x80000000; - char *data = (char *)moby->pvars; + char *data = *(char **)(moby + 0x78); for (i = 0; i < 18; i++) { - struct Moby *other; + char *other; 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 = (char *)D_L12_00160058_303CA8 + ((unsigned int)*(int *)(data + i * 0x30 + 0x20) << 8); } - if (other->oclass != 0x4FE) { - period = scale_ticks(0xAA); + if (*(short *)(other + 0xA6) == 0x4FE) continue; + { + period = scale_game_frames(0xAA); divisor = convert_integer_to_float(period); - phase = (float)(D_L12_0015F5CC % period) / divisor; + phase = (float)(D_L12_0015F5CC_p % period) / divisor; sine = fast_sin((phase + phase) * 3.1415927f + -3.1415927f); color = sine * 70.0f; 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); - other->flags |= 0x10; - other->glow_color = packed_color; + packed_color = ((blue + 0x46) << 16) | alpha | + ((green + 0xB4 > 0xFF ? 0xFF : green + 0xB4) << 8) | + (red + 0xB4 > 0xFF ? 0xFF : red + 0xB4); + *(unsigned short *)(other + 0x34) |= 0x10; + *(int *)(other + 0x90) = 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. */ @@ -592,7 +592,7 @@ 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); +void FUN_L12_00306828_u(struct Moby *moby) __asm__("FUN_L12_00306828"); 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"))); @@ -806,7 +806,7 @@ void FUN_L12_003069d0(char *moby) { FUN_L12_003064e8_c(moby); break; } - FUN_L12_00306828(moby); + FUN_L12_00306828_u(moby); if ((unsigned char)moby[0x20] >= 1 && (unsigned char)moby[0x20] <= 3) { if (*(int *)(d + 0x604) == -1) *(int *)(d + 0x604) = allocate_voice_for_target_entry(0, 4, moby); } else { diff --git a/src/overlays/shared/gameplay/entities/veldin_ship.c b/src/overlays/shared/gameplay/entities/veldin_ship.c index b69153ba04..0ab4815765 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; @@ -539,7 +534,9 @@ extern void FUN_002ac910_2d09b8(void *, void *, void *, f32, s32, s32, s32, s32, 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; + 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]; @@ -568,6 +565,8 @@ 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 = m; { s32 i; qcopy(&position, &m->pos); @@ -582,7 +581,11 @@ void FUN_L00_002d09b8(M2d1428 *m, s32 hit, s32 source) { switch ((s16)((u16)m->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,8 +596,12 @@ 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; } + 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] - m->pos.x; speed = D_L00_00166C80_2d19b0[81] - m->pos.y; angle = FUN_001ff8b0_2d09b8(angle, speed); @@ -639,7 +646,7 @@ void FUN_L00_002d09b8(M2d1428 *m, s32 hit, s32 source) { FUN_002af8b0_2d09b8(m, &a, &d, &e, kind + 1, particle, 0.25f, 0.5f); } } - *(u32 *)((u8 *)m + 0x94) = 0; + *(u32 *)((u8 *)self + 0x94) = 0; m->state = 3; *(u16 *)((u8 *)m + 0x34) |= 1; m->bBC = FUN_001fef20_2d09b8(15); @@ -682,7 +689,6 @@ void FUN_L00_002d09b8(M2d1428 *m, s32 hit, s32 source) { FUN_002ac910_2d09b8(m, &a, &e, 3.0f, FUN_001fef20_2d09b8(29), 32, 0, 0, 32); } } -#endif void FUN_L00_002d1428(M2d1428 *m) { O2d1428 *o; M2d1428 *p, *n, *next; diff --git a/src/overlays/shared/ui/help/001ff938.c b/src/overlays/shared/ui/help/001ff938.c index 242b3801ad..ca9517593a 100644 --- a/src/overlays/shared/ui/help/001ff938.c +++ b/src/overlays/shared/ui/help/001ff938.c @@ -4,147 +4,151 @@ #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_p __asm__("D_L15_0017C14C"); +extern int D_L15_0015F5B0_p __asm__("D_L15_0015F5B0"); +extern int D_L15_0015F5CC_p __asm__("D_L15_0015F5CC"); +extern s32 scale_game_frames(s32) __asm__("func_001F96F8"); +extern s32 truncate_float_to_s32(f32) __asm__("func_001FA6D0"); +extern short D_0015EE18_p __asm__("D_0015EE18"); +extern unsigned char D_0013D4DC_p[] __asm__("D_0013D4DC"); +extern unsigned char D_0013E533_p[] __asm__("D_0013E533"); +extern unsigned char D_0013F350_p[] __asm__("D_0013F350"); +extern struct { unsigned char b[8]; } D_0015EDB0_s __asm__("D_0015EDB0"); +extern float D_L15_0017C06C_f[] __asm__("D_L15_0017C06C"); +extern float D_L15_0017C1CC_f[] __asm__("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 FUN_L00_00211670(void); +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 FUN_L00_0024f7c8(void *, int, void *); 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 __attribute__((section(".data"))); -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 *b0, *b1, *b2, *b3, *b4, *b5, *b6; + unsigned char *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_L00_00211670(); FUN_L15_002044c8(); FUN_L15_0021d040(); - if (hero.vehicle_mode == 0) + b0 = ((char *)&D_0013F350_p); + if (b0[0x20A4] == 0) return; FUN_L00_00216f10(); FUN_L00_002054e8(); - if (hero.vehicle_mode == 0) + if (b0[0x20A4] == 0) return; FUN_L00_00208a10(); FUN_L00_00207c48(); FUN_L00_00207a58(); - FUN_L00_002484e0((u8 *)&hero + 0x80); + FUN_L00_002484e0(b0 + 0x80); - if (hero.vehicle_mode == 2) { - if (D_0015EDB3 != 0) - *(float *)((u8 *)&D_L15_0017ACC0_d + 0x13AC) = D_0015EE18_gp * 1.4f; + if (b0[0x20A4] == 2) { + if (D_0015EDB0_s.b[3] != 0) + D_L15_0017C06C_f[0] = (*(float *)&D_0015EE18_p) * 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 *m = *(unsigned char **)(b0 + 0x2080); + if (((*(unsigned short *)(m + 0x34) ^ 1) & 1) != 0) { + FUN_L00_0024f7c8(m, 6, copy); + qcopy(b0 + 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); - } - pulse = fast_sin((((float)(D_L15_0015F5CC % period) / convert_integer_to_float(period)) * 2.0f) * 3.1415927f + -3.1415927f); + b1 = ((char *)&D_0013F350_p); + if (b1[0x20A4] == 3) { + if (D_0015EDB0_s.b[1] != 0) + D_L15_0017C1CC_f[0] = 1.9f; + alpha = 0x80; + period = scale_game_frames(0xAA); + if (*(short *)(b1 + 0x22E0) == 2) + period = scale_game_frames(0x32); + else if (*(short *)(b1 + 0x22E0) == 1) + period = scale_game_frames(0x5A); + pulse = fast_sin((((float)(D_L15_0015F5CC_p % 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); + b2 = ((char *)&D_0013F350_p); + moby = *(unsigned char **)(b2 + 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 *)(moby + 0x34) |= 0x10; + if (*(short *)(b2 + 0x22E0) == 2) + color = (alpha << 24) | (blue << 16) | ((red / 2) << 8) | green; + else + color = (alpha << 24) | (blue << 16) | (green << 8) | red; + b3 = ((char *)&D_0013F350_p); + *(unsigned int *)(*(unsigned char **)(b3 + 0x2080) + 0x90) = + fast_tween_color(0.1f, *(unsigned int *)(*(unsigned char **)(b3 + 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; - } + b4 = ((char *)&D_0013F350_p); + FUN_L00_0024f7c8(*(void **)(b4 + 0x2080), i, b4 + 0x1D50 + i * 16); + } + alpha = 0x30; + b4 = ((char *)&D_0013F350_p); + { + unsigned char *mb = *(unsigned char **)(b4 + 0x2080); + blue = mb[0x92]; + green = mb[0x91]; + red = mb[0x90]; + } + if (*(short *)(b4 + 0x22DE) != 0) + alpha = truncate_float_to_s32((convert_integer_to_float(*(short *)(b4 + 0x22DE)) / convert_integer_to_float(0x12)) * (float)alpha); + *(unsigned int *)(b4 + 0x22E4) = (alpha << 24) | (blue << 16) | (green << 8) | red; + FUN_L00_00207d00(); + *(short *)(b4 + 0x22E0) = 0; + if (b4[0x20A4] == 3) { + int pending = *(int *)(b4 + 0x20B8); + if (pending != 0 && pending != 0x1F) { + if (*(short *)(b4 + 0x22DE) == 0) { + FUN_L00_00216de8(0x19, 0); + *(short *)(b4 + 0x22DE) = 0x12; + *(short *)(b4 + 0x22DC) = 1; + } + } else { + b5 = ((char *)&D_0013F350_p); + *(int *)(b5 + 0x20B8) = 0; + if (b5[0x12E7] != 0 && *(int *)(b5 + 0x300) != 0 && D_0013D4DC_p[0] != 0 && + *(short *)(b5 + 0x22DE) == 0) { + FUN_L00_00216de8(0x19, 0); + *(short *)(b5 + 0x22DE) = 0x12; + *(short *)(b5 + 0x22DC) = 1; } } } } FUN_L00_00208b60(); - FUN_L00_00257024(hero.moby); + b6 = ((char *)&D_0013F350_p); + FUN_L00_00257024(*(void **)(b6 + 0x2080)); } -#endif #define NOT_SDA #define MACRO_ADDR diff --git a/src/overlays/shared/ui/hud/hud_keep_visible.c b/src/overlays/shared/ui/hud/hud_keep_visible.c index 17934d5fda..9bd8a0c3e4 100644 --- a/src/overlays/shared/ui/hud/hud_keep_visible.c +++ b/src/overlays/shared/ui/hud/hud_keep_visible.c @@ -316,42 +316,68 @@ 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 100 hud particle records with randomised 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. */ + +typedef struct { + char pad0[0x8]; + int unk08; + int *unk0C; + char pad10[0x38]; + short unk48; + short unk4A; + char pad4C[0x4]; + int unk50; + int unk54; + int w; + int h; + int flags; + char pad64[0x8]; + int unk6C; + unsigned char cnt[4]; + int unk74; + int unk78; + int unk7C; + void *unk80; +} HudElem_p; + +extern f32 random_float_between(f32, f32) __asm__("FUN_002132a8"); +extern float D_L00_0017E660_c[][4] __asm__("D_L00_0017E660"); +extern short D_L00_0015F750_p __asm__("D_L00_0015F750") __attribute__((sda)); +extern short D_L00_0015F754_p __asm__("D_L00_0015F754") __attribute__((sda)); +extern short D_L00_0015F758_p __asm__("D_L00_0015F758") __attribute__((sda)); +extern short D_L00_0015F75C_p __asm__("D_L00_0015F75C") __attribute__((sda)); +void FUN_L00_00235d80_c(HudElem_p *e) __asm__("FUN_L00_00235d80"); + +void FUN_L00_00236268(HudElem_p *e) { int i; - FUN_L00_00235d80_236268(); + float v, lo, span, hi; + int n; + + FUN_L00_00235d80_c(e); 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; - 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); + v = *(float *)&D_L00_0015F750_p; + if (i >= 10) { + v = *(float *)&D_L00_0015F754_p; + if (i >= 20) v = *(float *)&D_L00_0015F758_p; + } + n = *(int *)&D_L00_0015F75C_p; + span = (232.0f - (v + v)) / (float)n; + lo = (v - 116.0f) + (float)(i % n) * span; + hi = lo + span; + D_L00_0017E660_c[i][0] = random_float_between(v - 17.0f, 17.0f - v); + D_L00_0017E660_c[i][1] = random_float_between(lo, hi); + D_L00_0017E660_c[i][2] = random_float_between(-0.4f, 0.4f); + D_L00_0017E660_c[i][3] = random_float_between(-0.6f, 0.6f); + D_L00_0017E660_c[i][2] += random_float_between(-0.4f, 0.4f); + D_L00_0017E660_c[i][3] += random_float_between(-0.6f, 0.6f); + D_L00_0017E660_c[i][2] += random_float_between(-0.4f, 0.4f); + D_L00_0017E660_c[i][3] += random_float_between(-0.6f, 0.6f); } + /* Fakematch: keeping n live past the loop gives retail's schedule of the loop body. */ + n++; + n--; } -#endif typedef struct { float x, y, vx, vy; diff --git a/src/overlays/shared/ui/text/002377b8.c b/src/overlays/shared/ui/text/002377b8.c index bbab3c374d..8d869a596f 100644 --- a/src/overlays/shared/ui/text/002377b8.c +++ b/src/overlays/shared/ui/text/002377b8.c @@ -327,214 +327,237 @@ 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[]; -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 *); +/* 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 { 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; +typedef struct { + char pad0[0x8]; + int unk08; + int *unk0C; + char pad10[0x38]; + short unk48; + short unk4A; + char pad4C[0x4]; + int unk50; + int unk54; + int w; + int h; + int flags; + char pad64[0x8]; + int unk6C; + unsigned char cnt[4]; + int unk74; + int unk78; + int unk7C; + void *unk80; +} HudElem_p; + +typedef struct { + char pad_00[0x38]; + unsigned short x38; + char pad_3A[0x4C - 0x3A]; +} SrcElem_p; + +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_r[] __asm__("D_00141EA0"); +extern SrcElem_p D_L00_00179AC0_p[] __asm__("D_L00_00179AC0"); +extern char *get_help_message_text(s32) __asm__("func_001FDD10"); +extern char D_0013D428_p[] __asm__("D_0013D428"); +extern char D_L00_0015F5CC_p[] __asm__("D_L00_0015F5CC"); +extern char D_L00_0015F7C8_p[] __asm__("D_L00_0015F7C8"); +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 int D_L00_0015FA90_p __asm__("D_L00_0015FA90"); +extern int D_L00_0015FAC0_p __asm__("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 short D_L00_0015F718_p __asm__("D_L00_0015F718") __attribute__((sda)); +extern short D_L00_0015F71C_p __asm__("D_L00_0015F71C") __attribute__((sda)); +extern short D_L00_0015F720_p __asm__("D_L00_0015F720") __attribute__((sda)); +extern short D_L00_0015F724_p __asm__("D_L00_0015F724") __attribute__((sda)); +extern short D_L00_0015F72C_p __asm__("D_L00_0015F72C") __attribute__((sda)); +extern short D_L00_0015F780_p __asm__("D_L00_0015F780") __attribute__((sda)); +extern short D_L00_0015F78C_p __asm__("D_L00_0015F78C") __attribute__((sda)); +extern short D_L00_0015F790_p __asm__("D_L00_0015F790") __attribute__((sda)); +extern short D_L00_0015F794_p __asm__("D_L00_0015F794") __attribute__((sda)); +extern short D_L00_0015F798_p __asm__("D_L00_0015F798") __attribute__((sda)); +extern short D_L00_0015F79C_p __asm__("D_L00_0015F79C"); +extern short D_L00_0015F7A0_p __asm__("D_L00_0015F7A0") __attribute__((sda)); +extern short D_L00_0015F7A4_p __asm__("D_L00_0015F7A4") __attribute__((sda)); +extern short D_L00_0015F7A8_p __asm__("D_L00_0015F7A8") __attribute__((sda)); +extern short D_L00_0015F7AC_p __asm__("D_L00_0015F7AC"); +extern short D_L00_0015F7B0_p __asm__("D_L00_0015F7B0") __attribute__((sda)); +extern short D_L00_0015F7B4_p __asm__("D_L00_0015F7B4"); +extern short D_L00_0015F7B8_p __asm__("D_L00_0015F7B8"); +extern short D_L00_0015F7BC_p __asm__("D_L00_0015F7BC") __attribute__((sda)); +extern short D_L00_0015F7C0_p __asm__("D_L00_0015F7C0"); +extern short D_L00_0015F7C4_p __asm__("D_L00_0015F7C4") __attribute__((sda)); +extern u32 strlen(const char *); +extern unsigned char D_00141EA0_p[] __asm__("D_00141EA0"); +extern unsigned char D_L00_001C40B0_p[] __asm__("D_L00_001C40B0"); +extern void *D_L00_0015FAC0_v __asm__("D_L00_0015FAC0"); +extern unsigned char D_0013E520_b[] __asm__("D_0013E520"); +extern int D_L00_0015F5CC_i __asm__("D_L00_0015F5CC"); +extern char D_L00_001C40B0_c[] __asm__("D_L00_001C40B0"); +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_p *rec, int *x, int *y) __asm__("FUN_L00_00235a70"); +extern int D_0014171B_i[] __asm__("D_L00_001C40B0"); + +#define GI(x) (*(int *)&(x)) +#define GF(x) (*(float *)&(x)) + +int FUN_L00_002382a0(HudElem_p *rec) { + char *wr; + int x, y, half_w, half_h, alpha; + int marker_alpha; + int i, icon_x, icon_y, selected; + int entry_offset, marker_offset, normal_offset; + 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; + char *entry; + unsigned char *q = 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(q[0]) / convert_integer_to_float_c2(GI(D_L00_0015F780_p)); 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(q[1]) / convert_integer_to_float_c2(GI(D_L00_0015F780_p)); 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_i % GI(D_L00_0015F7B0_p)); + phase /= convert_integer_to_float_c2(GI(D_L00_0015F7B0_p)); 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); - 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; + x = rec->unk50; + y = rec->unk54; + FUN_L00_00235a70_c3(rec, &x, &y); + half_w = GI(D_L00_0015F718_p) / 2; + half_h = GI(D_L00_0015F71C_p) / 2; + 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 + GI(D_L00_0015F718_p), + y + GI(D_L00_0015F71C_p), -half_w, -half_h, alpha); + draw_hud_sprite_c2(find_valid_animation_frame_index_alt(0xe934, 0), x + GI(D_L00_0015F718_p), + y, -half_w, half_h, alpha); + draw_hud_sprite_c2(find_valid_animation_frame_index_alt(0xe934, 0), x, + y + GI(D_L00_0015F71C_p), half_w, -half_h, alpha); + for (i = 0; i < D_L00_0015FA90_p; i++) { + angle = fast_add_rotations_c(((float)i + (float)i) * 3.1415927f / + (float)D_L00_0015FA90_p - 3.1415927f, 1.5707964f); + icon_x = x + GI(D_L00_0015F720_p) + + (int)(GF(D_L00_0015F78C_p) * fast_cos(angle) * GF(D_L00_0015F7C4_p)); + icon_y = y + GI(D_L00_0015F724_p) + + (int)(GF(D_L00_0015F78C_p) * fast_sin(angle)); + if (rec->unk74 == i && ((E_238C30 **)D_L00_0015FAC0_v)[GI(D_L00_0015F72C_p)][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_v)[GI(D_L00_0015F72C_p)][i].id != 0) { + int icon_alpha; + if (i != rec->unk74) + icon_alpha = truncate_float_to_s32_c2((float)alpha * GF(D_L00_0015F7C0_p)); + else + icon_alpha = alpha; + FUN_L00_0023b120((char *)rec, find_valid_animation_frame_index_alt(((E_238C30 **)D_L00_0015FAC0_v)[GI(D_L00_0015F72C_p)][i].id, + ((unsigned char *)D_0013E520_b)[((E_238C30 **)D_L00_0015FAC0_v)[GI(D_L00_0015F72C_p)][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; - item = weapon_ammo_counts[id]; - sprintf_alt(formatted, D_L00_0015F7C8, item, D_L00_001C40B0[id].hE); + selected = rec->unk74; + if (selected >= 0 && *(int *)(((char **)D_L00_0015FAC0_v)[GI(D_L00_0015F72C_p)] + selected * 0x1C) != 0) { + color = fast_tween_color_c(GI(D_L00_0015F798_p), GI(D_L00_0015F79C_p), open * fade); + { + int id; + id = *(int *)((char *)D_00141EA0_r + selected * 4); + wr = D_L00_001C40B0_c + id * 24; + if (*(unsigned short *)(wr + 8) != 0) { + int shadow, item; + item = *(int *)(D_0013D428_p + id * 4); + sprintf(formatted, D_L00_0015F7C8_p, item, *(unsigned short *)(wr + 0xE)); if (item != 0) - shadow = fast_tween_color_alpha_first(opacity, D_L00_0015F7A8, D_L00_0015F7AC); + shadow = fast_tween_color_c(GI(D_L00_0015F7A8_p), GI(D_L00_0015F7AC_p), 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(GI(D_L00_0015F7A0_p), GI(D_L00_0015F7A4_p), open * fade); + font_print_center(x + GI(D_L00_0015F720_p) + 1, y + GI(D_L00_0015F724_p) + 13, color, formatted, -1); + font_print_center(x + GI(D_L00_0015F720_p), y + GI(D_L00_0015F724_p) + 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(GI(D_L00_0015F790_p), GI(D_L00_0015F794_p), 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_v)[GI(D_L00_0015F72C_p)] + selected * 0x1C + 0x18); + if (((unsigned char *)D_0013E520_b)[item]) + id = ((TI_238C30 *)D_L00_00179AC0_p)[item].h48; else - id = ((TitleItem_2382a0 *)D_L00_00179AC0)[item].h46; - text = get_text(id); + id = ((TI_238C30 *)D_L00_00179AC0_p)[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_i++; + D_L00_0015F5CC_i--; + 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 += D_L00_0015F7B4; + text_y = y + GI(D_L00_0015F724_p); + { + int id; + char *wr; + id = *(int *)((char *)D_00141EA0_r + selected * 4); + wr = D_L00_001C40B0_c + id * 24; + if (*(unsigned short *)(wr + 8) != 0) + text_y += GI(D_L00_0015F7B4_p); else if (prefix_length != 0) - text_y += D_L00_0015F7B8; + text_y += GI(D_L00_0015F7B8_p); else - text_y += D_L00_0015F7BC; + text_y += GI(D_L00_0015F7BC_p); + } 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 + GI(D_L00_0015F720_p) + 1, text_y + 1, color, (void *)text, prefix_length); + font_print_center(x + GI(D_L00_0015F720_p), 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 + GI(D_L00_0015F720_p) + 1, text_y + 1, color, (void *)suffix, -1); + font_print_center(x + GI(D_L00_0015F720_p), 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 + GI(D_L00_0015F720_p) + 1, text_y + 1, color, (void *)text, -1); + font_print_center(x + GI(D_L00_0015F720_p), 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)); From 0e9480d42077e75794bafe3da14a5c40adb315b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Fri, 16 Oct 2026 20:44:27 +0000 Subject: [PATCH 04/33] overlay: decompile the giant clank pad and the movie loader FUN_L15_002ed068 (giant clank pad) and FUN_L00_002995d0 (movie load setup and GS image upload) now match. --- .../shared/gameplay/entities/00295100.c | 119 +++++++++--------- .../gameplay/entities/underwater_ring.c | 40 +++--- 2 files changed, 75 insertions(+), 84 deletions(-) diff --git a/src/overlays/shared/gameplay/entities/00295100.c b/src/overlays/shared/gameplay/entities/00295100.c index dfc68546eb..c467a4e92d 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 s32 movie_sector __asm__("D_L00_00161048") __attribute__((section(".sdata"))); +extern s32 movie_size __asm__("D_L00_0016104C") __attribute__((section(".sdata"))); +extern s32 movie_language __asm__("D_L00_00161050") __attribute__((section(".sdata"))); +extern s32 movie_buffer __asm__("D_L00_00161054") __attribute__((section(".sdata"))); +extern s32 movie_image_data __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_data __asm__("D_L00_00173E04") __attribute__((section(".data"))); +/* [0] is gs_texture_allocation_start, [4] depth_buffer_address. */ +extern s32 gs_layout_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 debug_print_002995d0(char *, s32) __asm__("FUN_001e93b0"); +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(); + movie_sector = sector; + movie_size = size; + movie_language = 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; + movie_buffer = D_L00_00173E04_data; + movie_image_data = D_L00_0015F40C_macro; + large_count = D_0015ED80 != 0 ? 0xE : 0xD; + small_count = D_0015ED80 != 0 ? 0xE : 0x11; + source = movie_image_data; + gs_address = gs_layout_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 = gs_layout_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) { + debug_print_002995d0(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/underwater_ring.c b/src/overlays/shared/gameplay/entities/underwater_ring.c index c2e45554c7..f38a2e88e8 100644 --- a/src/overlays/shared/gameplay/entities/underwater_ring.c +++ b/src/overlays/shared/gameplay/entities/underwater_ring.c @@ -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 From cabf6b26e9c72f978060f9e92a68ecf00646404e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Fri, 16 Oct 2026 21:01:18 +0000 Subject: [PATCH 05/33] overlay: decompile the mine glove update FUN_L00_002c1ad0 (2488 bytes, 19 levels) now matches. --- .../shared/gameplay/entities/trespasser.c | 238 ++++++++---------- 1 file changed, 105 insertions(+), 133 deletions(-) diff --git a/src/overlays/shared/gameplay/entities/trespasser.c b/src/overlays/shared/gameplay/entities/trespasser.c index e25f68dae3..8e5d579113 100644 --- a/src/overlays/shared/gameplay/entities/trespasser.c +++ b/src/overlays/shared/gameplay/entities/trespasser.c @@ -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,64 @@ 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 struct { u8 pad0[0x11]; u8 unk11; } D_0013E520_2c1ad0 __asm__("D_0013E520"); +extern struct { u8 pad0[0x88]; u16 deliveries; u16 unk8A; u32 levels; } D_00141680_s __asm__("D_00141680"); +extern struct { u8 pad0[0x18]; s32 moby; u8 pad1C[4]; Vec4 point; } coll_hit_2c1ad0 __asm__("D_L00_00173E40"); +extern Vec4 D_L00_00166DC0_v __asm__("D_L00_00166DC0"); +extern char D_L00_00166C80_c[] __asm__("D_L00_00166C80"); +extern short D_L00_001B07B0_2c1ad0[] __asm__("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_c); 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 +1221,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 +1232,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 * (D_0013E520_2c1ad0.unk11 ? ((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] = D_0013E520_2c1ad0.unk11 ? ((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, D_0013E520_2c1ad0.unk11 ? ((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 * (D_0013E520_2c1ad0.unk11 ? ((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_v, &arc); + if (collision_line(&D_L00_00166DC0_v, &probe, 2, moby, 0) && coll_hit_2c1ad0.moby != (s32)hero.moby) { + qcopy(&target, &coll_hit_2c1ad0.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_v); } } } - { - 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, D_0013E520_2c1ad0.unk11 ? ((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 +1300,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) - ++D_00141680_2c1ad0.deliveries; + if (D_00141680_s.deliveries <= 0xfffe) + ++D_00141680_s.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_s.unk8A < frames) + D_00141680_s.unk8A = 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_s.levels = (D_00141680_s.levels | (1u << current_level_index_macro)) | 0x80000000; + FUN_L00_0025f780(vars->held, D_L00_001B07B0_2c1ad0, 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 +1330,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 From 969d3d8561db7741565dfff1afc2faf7a1fa86a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Fri, 16 Oct 2026 21:09:36 +0000 Subject: [PATCH 06/33] decomp: bring the sound update draft within 62 instructions of retail --- .../textbin/audio/voices/sound_update.c | 129 +++++++++--------- 1 file changed, 66 insertions(+), 63 deletions(-) diff --git a/src/assembly/textbin/audio/voices/sound_update.c b/src/assembly/textbin/audio/voices/sound_update.c index 63e679de5c..ade0c7a7da 100644 --- a/src/assembly/textbin/audio/voices/sound_update.c +++ b/src/assembly/textbin/audio/voices/sound_update.c @@ -77,17 +77,18 @@ typedef struct { extern VoiceRuntimeState D_0013E550; extern f32 D_0013F640[]; -extern s32 boot_level_active __asm__("D_0015F5E8"); -extern s32 game_mode __asm__("D_0015F604"); -extern s32 world_update_time __asm__("D_0015F60C"); +extern f32 D_0015ED6C; +extern s32 D_0015F5E8; +extern s32 D_0015F604; +extern s32 D_0015F60C; extern VoiceVector D_00187080; -extern char camera_rows[] __asm__("D_00187290"); -extern s32 use_alt_fog __asm__("D_001872D4"); +extern u8 D_00187290[]; +extern s32 D_001872D4; extern s32 ComputeByteStringHash(u8 *, s32); extern int snd_get_doppler_pitch_mod(int arg0); -extern void fill_transfer_words(void *, s32, s32) __asm__("func_001F97E8"); -extern void read_global_table_entry(void) __asm__("ReadGlobalTableEntry"); +extern void FillTransferWords(void *, s32, s32); +extern void ReadGlobalTableEntry(void); extern s32 snd_flush_sound_commands(void) __asm__("FUN_0012dc80"); extern void snd_set_master_volume(s32, s32) __asm__("FUN_0012e208"); extern void snd_play_sound_vol_pan_pmpb() __asm__("FUN_0012e308"); @@ -105,7 +106,7 @@ extern f32 vector_length_xyz(void *a) __asm__("FUN_001f9af0"); extern void normalize_vector_xyz(void *out, void *a, f32 len) __asm__("FUN_001f9bf8"); extern void func_001F9CF8(void *out, void *a, void *b) __asm__("FUN_001f9cf8"); extern void func_001FA2D8(void *out, void *a) __asm__("FUN_001fa2d8"); -extern f32 convert_integer_to_float(s32) __asm__("func_001FA6C0"); +extern f32 ConvertIntegerToFloat(s32) __asm__("func_001FA6C0"); extern s32 truncate_float_to_s32(f32) __asm__("FUN_001fa6d0"); extern void music_update() __asm__("FUN_00216290"); extern void clamp_voice_position_to_collision(void *) __asm__("FUN_0022c5a8"); @@ -118,6 +119,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 +135,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; @@ -149,7 +153,7 @@ s32 sound_update(void) { s32 handle; s32 command_flags; - underwater = use_alt_fog; + underwater = D_001872D4; water_height = 0.0f; if (underwater != 0) { water_height = D_0013F640[0]; @@ -166,39 +170,39 @@ s32 sound_update(void) { } D_0013E550.reverb_commands = 0; - if ((game_mode == 0 || game_mode == 2) && boot_level_active == 0) { + if ((D_0015F604 == 0 || D_0015F604 == 2) && D_0015F5E8 == 0) { clamp_voice_position_to_collision(&listener_occlusion_position); } 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; - } - listener_sample_count = 0; + 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; - if (previous_history_index != history_index) { + + listener_sample_count = 0; + 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)) { + if (!(vector_length_xyz(&relative_velocity) < D_0015ED6C * 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) { scale_vector_xyz(&listener_velocity, &listener_velocity, - 1.0f / convert_integer_to_float(listener_sample_count)); + 1.0f / ConvertIntegerToFloat(listener_sample_count)); } - if (game_mode == 2) { + if (D_0015F604 == 2) { snd_set_master_volume(1, 0); snd_set_master_volume(0, D_0013E550.group_0_volume / 2); snd_set_master_volume(3, D_0013E550.group_3_volume / 2); @@ -217,9 +221,9 @@ s32 sound_update(void) { voice_flags = flags; volumes = voice_volumes; - fill_transfer_words(voice_flags, 0, 0x78); - fill_transfer_words(volumes, 0, 0x78); - fill_transfer_words(radial_velocities, 0, 0x78); + FillTransferWords(voice_flags, 0, 0x78); + FillTransferWords(volumes, 0, 0x78); + FillTransferWords(radial_velocities, 0, 0x78); for (slot_index = 0; slot_index < 30; slot_index++) { if (D_0013E550.voices[slot_index].state != 7) { @@ -252,7 +256,7 @@ s32 sound_update(void) { voice_flags[slot_index] = 0x20; continue; } - if (game_mode != 0 && game_mode != 2 && game_mode != 6 && + if (D_0015F604 != 0 && D_0015F604 != 2 && D_0015F604 != 6 && D_0013E550.voices[slot_index].state != 7) { voice_flags[slot_index] = 0x10; continue; @@ -287,53 +291,50 @@ 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; } } } + voices = D_0013E550.voices; for (slot_index = 0; slot_index < 30; slot_index++) { if (!(voice_flags[slot_index] & 8)) { continue; } if (D_0013E550.voices[slot_index].state == 7) { - if ((game_mode != 0 && game_mode != 2) || boot_level_active != 0) { + if ((D_0015F604 != 0 && D_0015F604 != 2) || D_0015F5E8 != 0) { continue; } occluded_samples = 0; - if (world_update_time != D_0013E550.occlusion_frame) { - for (history_offset = 0; history_offset < 6; history_offset++) { + if (D_0015F60C != D_0013E550.occlusion_frame) { + for (sample_index = 0; sample_index < 6; sample_index++) { clamp_voice_position_to_collision( - &D_0013E550.occlusion_samples[history_offset]); + &D_0013E550.occlusion_samples[sample_index]); } - D_0013E550.occlusion_frame = world_update_time; + D_0013E550.occlusion_frame = D_0015F60C; } - sample_index = 0; - for (history_offset = 0; sample_index < 6; + 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], @@ -347,18 +348,18 @@ 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) { + if ((D_0015F604 == 0 || D_0015F604 == 2) && D_0015F5E8 == 0) { D_0013E550.voices[slot_index].occlusion_history_position = (D_0013E550.voices[slot_index].occlusion_history_position + 1) % 36; /* Active sources test every other frame; other voices every fourth. */ - command_flags = (slot_index ^ world_update_time) & 1; + command_flags = (slot_index ^ D_0015F60C) & 1; if (!(D_0013E550.voices[slot_index].flags & 4)) { - command_flags = ((world_update_time ^ slot_index) & 3) == 0; + command_flags = ((D_0015F60C ^ slot_index) & 3) == 0; } if (command_flags) { D_0013E550.voices[slot_index].occlusion_history @@ -372,17 +373,19 @@ s32 sound_update(void) { [(D_0013E550.voices[slot_index].occlusion_history_position + 35) % 36]; } } - occluded_samples = - ComputeByteStringHash(D_0013E550.voices[slot_index].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; + } } } } - func_001FA2D8(listener_matrix, camera_rows); + func_001FA2D8(listener_matrix, D_00187290); for (slot_index = 0; slot_index < 30; slot_index++) { command_flags = voice_flags[slot_index]; if (command_flags == 0) { @@ -392,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; @@ -424,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]); } } @@ -440,7 +443,7 @@ s32 sound_update(void) { music_update(); snd_reset_state_and_flush_commands(); snd_flush_sound_commands(); - read_global_table_entry(); + ReadGlobalTableEntry(); D_0013E550.pending_commands = 0; return 0; } From 8afd0fd3b3fcc6327eaac35f4dffdcfb96718007 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Fri, 16 Oct 2026 21:49:53 +0000 Subject: [PATCH 07/33] overlay: decompile the L14 vendor fade update and bring the snagglebeast draft closer --- src/overlays/l07/gameplay/entities/snagglebeast.c | 2 +- src/overlays/shared/gameplay/vendor/003015d0.c | 14 ++------------ 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/overlays/l07/gameplay/entities/snagglebeast.c b/src/overlays/l07/gameplay/entities/snagglebeast.c index 67039f77d2..b3269814b5 100644 --- a/src/overlays/l07/gameplay/entities/snagglebeast.c +++ b/src/overlays/l07/gameplay/entities/snagglebeast.c @@ -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; } diff --git a/src/overlays/shared/gameplay/vendor/003015d0.c b/src/overlays/shared/gameplay/vendor/003015d0.c index dd512d8e27..557d228585 100644 --- a/src/overlays/shared/gameplay/vendor/003015d0.c +++ b/src/overlays/shared/gameplay/vendor/003015d0.c @@ -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)); @@ -291,7 +288,6 @@ void FUN_L14_00301de8(char *m) { char *dst, *src; u8 *indices; int i, j, k, copy_i, next_i; - int offset; float t; if (*(s16 *)(d + 0x12) != 0) { @@ -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 = d + (i << 4) + (2 - k) * 0x40; + add_vector_xyz(row + 0x460, row + 0x460, row + 0x560); } i = next_i; } while ((float)i < 4.0f); @@ -340,7 +331,6 @@ void FUN_L14_00301de8(char *m) { *(int *)(d + 0x14) = 0; } } -#endif #ifndef NON_MATCHING INCLUDE_ASM("config/us/overlays/asm/FUN_L14_00301fa8.s", FUN_L14_00301fa8); #else From a1a41f8baf059471379b7144b48170120f300d86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Fri, 16 Oct 2026 22:26:43 +0000 Subject: [PATCH 08/33] overlay: bring the walloper reset draft closer Plain and macro declarations for the globals the reset reads keep the sda .extern from turning later lui loads into gp loads. --- src/overlays/shared/gameplay/entities/walloper.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/overlays/shared/gameplay/entities/walloper.c b/src/overlays/shared/gameplay/entities/walloper.c index 423eee33eb..c32689b260 100644 --- a/src/overlays/shared/gameplay/entities/walloper.c +++ b/src/overlays/shared/gameplay/entities/walloper.c @@ -1391,7 +1391,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; @@ -1604,7 +1604,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 +1643,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 +1666,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--) { From db63b39311b891419955c3eaa8f9c6c6fdbe1a1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Fri, 16 Oct 2026 23:10:55 +0000 Subject: [PATCH 09/33] chore: name ported aliases by their labels and header names Aliases with port suffixes become the plain label, the header name or the boot function name where the asm stays the same; parameters named after registers get names from their use. --- .../l07/gameplay/entities/taxi_platform.c | 155 ++++++++-------- .../l08/gameplay/entities/bolt_thief.c | 168 +++++++++--------- src/overlays/l10/gameplay/entities/platform.c | 4 +- src/overlays/l12/gameplay/entities/003054b0.c | 2 +- .../shared/gameplay/entities/00295100.c | 8 +- src/overlays/shared/gameplay/entities/bomb.c | 20 +-- .../shared/gameplay/entities/trespasser.c | 8 +- src/overlays/shared/rendering/00245c28.c | 13 +- src/overlays/shared/ui/help/001ff938.c | 41 +++-- src/overlays/shared/ui/hud/hud_keep_visible.c | 16 +- src/overlays/shared/ui/text/002377b8.c | 116 ++++++------ 11 files changed, 269 insertions(+), 282 deletions(-) diff --git a/src/overlays/l07/gameplay/entities/taxi_platform.c b/src/overlays/l07/gameplay/entities/taxi_platform.c index d22a8c4943..d394b8d8a2 100644 --- a/src/overlays/l07/gameplay/entities/taxi_platform.c +++ b/src/overlays/l07/gameplay/entities/taxi_platform.c @@ -2607,15 +2607,13 @@ struct Tgt_3109D0_p { extern Rec_30D8E8_p *D_L07_001612D0_p __asm__("D_L07_001612D0"); extern Vec4_p D_L07_00173EE0_p __asm__("D_L07_00173EE0"); extern char *D_L07_0015FFD8_p __asm__("D_L07_0015FFD8"); -extern char D_0013E533_p[] __asm__("D_0013E533"); -extern char D_L07_002117F8_p[] __asm__("D_L07_002117F8"); -extern char D_L07_00211838_p[] __asm__("D_L07_00211838"); +extern char D_0013E533[]; +extern char D_L07_002117F8[]; +extern char D_L07_00211838[]; 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 D_0015ED60_p __asm__("D_0015ED60"); -extern float D_0015ED6C_p __asm__("D_0015ED6C"); -extern float D_0015ED70_p __asm__("D_0015ED70"); 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_p __asm__("D_L07_0015F5CC"); @@ -2629,15 +2627,15 @@ extern int is_point_inside_clip_volume_c2(void *arg0, int arg1) __asm__("func_00 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_p[1] __asm__("D_L07_00161B50") __attribute__((sda)); -extern unsigned char D_L07_00161B40_p[1] __asm__("D_L07_00161B40") __attribute__((sda)); +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_c(void *, s32, s32, s32) __asm__("FUN_00212f90"); +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"); @@ -2652,10 +2650,9 @@ 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_p *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_0013F3D0_p[] __asm__("D_0013F3D0"); extern char D_001413D0_p[] __asm__("D_001413D0"); -extern char D_0013F65C_p[] __asm__("D_0013F65C"); -extern char D_0013F350_p[] __asm__("D_0013F350"); +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"); extern int func_001F9908_30D8E8(int *) __asm__("FUN_001f9740"); @@ -2687,7 +2684,7 @@ void FUN_L07_0030f5f0(unsigned char *moby) { FUN_L00_00263ac8(moby, 0, data + 0x150, 2.2f); if (moby[0x20] == 0) { if (FUN_L07_0030ed30_c((char *)moby, data)) { - DebugPrint_alt(D_L07_002117F8_p, (int)((char *)moby - D_L07_0015FFD8_p) >> 8); + DebugPrint_alt(D_L07_002117F8, (int)((char *)moby - D_L07_0015FFD8_p) >> 8); mark_moby_for_removal_c4(moby); return; } @@ -2702,7 +2699,7 @@ void FUN_L07_0030f5f0(unsigned char *moby) { inside = FUN_L00_00259740(&tgt, p + 0x10, *(int *)p) != 0; } else { char *p = *(char **)(data + 0x148); - hero = ((char *)&D_0013F3D0_p); + hero = ((char *)&D_0013F3D0); inside = FUN_L00_00259740(hero, p + 0x10, *(int *)p) != 0; if (vector_distance_xy_alt(moby + 0x10, hero) < 30.0f) { tgt.moby = *(int *)(hero + 0x2000); @@ -2730,8 +2727,8 @@ void FUN_L07_0030f5f0(unsigned char *moby) { moby[0xBC] = FUN_L07_0030ebc8_c((char *)moby, data); cur = moby[0xBC]; if (prev != cur) { - next = ((struct { unsigned char t[3][3]; } *)D_L07_00161B40_p)->t[prev][cur]; - anim = ((struct { unsigned char t[3][3]; } *)D_L07_00161B50_p)->t[prev][cur]; + next = ((struct { unsigned char t[3][3]; } *)D_L07_00161B40_gp)->t[prev][cur]; + anim = ((struct { unsigned char t[3][3]; } *)D_L07_00161B50_gp)->t[prev][cur]; } FUN_L00_0024f7c8(moby, 0, pos); if (FUN_L00_001f0d60(0.8f, pos, 1, moby) != 0 && FUN_001f0b58() == 0) { @@ -2769,55 +2766,55 @@ void FUN_L07_0030f5f0(unsigned char *moby) { } } if (1.0f <= F(data, 0x14C)) { - *(u128_p *)(((char *)&D_0013F3D0_p)) = *(u128_p *)(moby + 0x10); + *(u128_p *)(((char *)&D_0013F3D0)) = *(u128_p *)(moby + 0x10); } switch (moby[0x20]) { case 0: - DebugPrint_alt(D_L07_00211838_p); + DebugPrint_alt(D_L07_00211838); goto end; case 1: if ((moby[0x70] & 2) && moby[0x53] != 0) { - blend_moby_animation_c(moby, 0, 0, 10); + blend_moby_animation(moby, 0, 0, 10); } if (inside && tgt.moby != 0 && tgt.moby == *(int *)(((char *)&D_001413D0_p)) && !FUN_L07_0030f540_c(moby, 4, 6)) { if (moby[0x53] != 1) { - blend_moby_animation_c(moby, 1, 0, 10); + blend_moby_animation(moby, 1, 0, 10); } moby[0x20] = 4; } if (tgt.moby != 0 && tgt.moby == *(int *)(((char *)&D_001413D0_p)) && FUN_L07_0030f4d0_c(moby, tgt.moby, 1.5f)) { if (moby[0x53] != 2) { - blend_moby_animation_c(moby, 2, 0, 2); + blend_moby_animation(moby, 2, 0, 2); } moby[0x20] = 5; } else if (wander) { if (moby[0x53] != 1) { - blend_moby_animation_c(moby, 1, 0, 10); + 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, D_0015ED60_p * (0.95f - 1.0f) + 1.0f); - FUN_L07_0030f0f8_c((char *)moby, data, D_0015ED70_p * 15.0f, D_0015ED70_p * 50.0f, D_0015ED6C_p * 8.0f); + FUN_L07_0030f0f8_c((char *)moby, data, frame_time_sq * 15.0f, frame_time_sq * 50.0f, frame_time * 8.0f); if (next != 0xFF) { if (moby[0x53] != anim) { - blend_moby_animation_c(moby, anim, 0, 6); + blend_moby_animation(moby, anim, 0, 6); } moby[0x20] = next; } goto end; case 2: if ((moby[0x70] & 2) && moby[0x53] != 1) { - blend_moby_animation_c(moby, 1, 0, 10); + blend_moby_animation(moby, 1, 0, 10); } if (inside && tgt.moby != 0 && tgt.moby == *(int *)(((char *)&D_001413D0_p))) { if (!FUN_L07_0030f540_c(moby, 4, 6)) { if (moby[0x53] != 1) { - blend_moby_animation_c(moby, 1, 0, 10); + blend_moby_animation(moby, 1, 0, 10); } moby[0x20] = 4; } @@ -2825,23 +2822,23 @@ void FUN_L07_0030f5f0(unsigned char *moby) { float a = 1.74532926f; float b = 4.5378561f; FUN_L00_00258278((char *)moby, (float *)(data + 0x120), F(data, 0x13C), - D_0015ED70_p * a, D_0015ED70_p * b, D_0015ED6C_p * a); + frame_time_sq * a, frame_time_sq * b, frame_time * a); F(moby, 0x44) = FUN_L00_00258110((float *)(data + 0x124), F(moby, 0x44), 0.0f, - D_0015ED70_p * a, D_0015ED70_p * b, D_0015ED6C_p * a); + frame_time_sq * a, frame_time_sq * b, frame_time * a); if (wander && is_point_inside_clip_volume_c2(moby + 0x10, *(int *)(data + 0x114))) { if (moby[0x53] != 0) { - blend_moby_animation_c(moby, 0, 0, 10); + blend_moby_animation(moby, 0, 0, 10); } *(int *)(data + 0x134) = rand() % 120 + 60; moby[0x20] = 1; } } FUN_L07_0030eee8_c((struct Moby *)moby, (struct WalkerData_p *)data); - if (FUN_L07_0030f1e0_c((char *)moby, data, F(data, 0x13C), 0.209439516f, D_0015ED70_p * 6.0f, - 0.52359879f, D_0015ED70_p * 4.0f, D_0015ED6C_p * 7.0f, D_0015ED6C_p * 3.0f) && + 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_c(moby, 0, 0, 10); + blend_moby_animation(moby, 0, 0, 10); } *(int *)(data + 0x134) = rand() % 120 + 60; moby[0x20] = 1; @@ -2849,14 +2846,14 @@ void FUN_L07_0030f5f0(unsigned char *moby) { if (tgt.moby != 0 && tgt.moby == *(int *)(((char *)&D_001413D0_p)) && FUN_L07_0030f4d0_c(moby, tgt.moby, 1.5f)) { if (moby[0x53] != 2) { - blend_moby_animation_c(moby, 2, 0, 2); + blend_moby_animation(moby, 2, 0, 2); } moby[0x20] = 5; } - FUN_L07_0030f0f8_c((char *)moby, data, D_0015ED70_p * 15.0f, D_0015ED70_p * 50.0f, D_0015ED6C_p * 8.0f); + FUN_L07_0030f0f8_c((char *)moby, data, frame_time_sq * 15.0f, frame_time_sq * 50.0f, frame_time * 8.0f); if (next != 0xFF) { if (moby[0x53] != anim) { - blend_moby_animation_c(moby, anim, 0, 6); + blend_moby_animation(moby, anim, 0, 6); } moby[0x20] = next; } @@ -2870,22 +2867,22 @@ void FUN_L07_0030f5f0(unsigned char *moby) { float zero = 0.0f; ang = fast_arc_tan_c2(tgt.pos[0] - F(moby, 0x10), tgt.pos[1] - F(moby, 0x14)); FUN_L00_00258278((char *)moby, (float *)(data + 0x120), ang, - D_0015ED70_p * pi4, D_0015ED70_p * zero, D_0015ED6C_p * pi4); + frame_time_sq * pi4, frame_time_sq * zero, frame_time * pi4); d = vector_distance_xy_alt(moby + 0x10, &tgt); d = fast_arc_tan_c2(d, tgt.pos[2] - F(moby, 0x18)); F(moby, 0x44) = FUN_L00_00258110((float *)(data + 0x124), F(moby, 0x44), -d, - D_0015ED70_p * pi4, D_0015ED70_p * zero, D_0015ED6C_p * pi4); - if (!(vector_distance_xy_alt(moby + 0x10, ((char *)&D_0013F3D0_p)) < three)) { + 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, D_0015ED60_p * (0.9f - 1.0f) + 1.0f); } - if (FUN_L07_0030f1e0_c((char *)moby, data, ang, 0.209439516f, D_0015ED70_p * 20.0f, - 0.52359879f, D_0015ED70_p * three, D_0015ED6C_p * 20.0f, D_0015ED6C_p * 5.0f) && + if (FUN_L07_0030f1e0_c((char *)moby, data, ang, 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_c(moby, 2, 4, 2); + blend_moby_animation(moby, 2, 4, 2); } *(int *)(moby + 0x94) = 0; moby[0x20] = 5; @@ -2893,16 +2890,16 @@ void FUN_L07_0030f5f0(unsigned char *moby) { qcopy(data + 0x100, moby + 0x10); } ((struct { char p[0x138]; float f; } *)data)->f = tgt.pos[2] - 0.25f; - FUN_L07_0030f0f8_c((char *)moby, data, D_0015ED70_p * 38.0f, D_0015ED70_p * 0.0f, D_0015ED6C_p * 38.0f); - if (!inside || *(short *)(((char *)&D_0013F65C_p)) == 0) { + FUN_L07_0030f0f8_c((char *)moby, data, frame_time_sq * 38.0f, frame_time_sq * 0.0f, frame_time * 38.0f); + if (!inside || *(short *)(((char *)&D_0013F65C)) == 0) { if (moby[0x53] != 1) { - blend_moby_animation_c(moby, 1, 0, 10); + blend_moby_animation(moby, 1, 0, 10); } moby[0x20] = 2; } if (next != 0xFF) { if (moby[0x53] != anim) { - blend_moby_animation_c(moby, anim, 0, 6); + blend_moby_animation(moby, anim, 0, 6); } moby[0x20] = next; } @@ -2919,7 +2916,7 @@ void FUN_L07_0030f5f0(unsigned char *moby) { subtract_vector_xyz(off, pos, mpos); ang = fast_arc_tan_c2(tgt.pos[0] - pos[0], tgt.pos[1] - pos[1]); func_L00_002592B0_t((char *)moby, ang, (float *)(data + 0x120), - D_0015ED70_p * 12.566371f, D_0015ED70_p * 0.0f, D_0015ED6C_p * 12.566371f); + frame_time_sq * 12.566371f, frame_time_sq * 0.0f, frame_time * 12.566371f); F(moby, 0x44) *= D_0015ED60_p * 0.7f; F(data, 0x14C) += 0.028f; qcopy(old, mpos); @@ -2933,7 +2930,7 @@ void FUN_L07_0030f5f0(unsigned char *moby) { no_op_main_callback_alt(start, mpos); subtract_vector_xyz(data + 0xD0, mpos, old); if (one <= F(data, 0x14C)) { - char *g = ((char *)&D_0013F350_p); + char *g = ((char *)&D_0013F350); *(int *)(g + 0x22A8) = 0; FUN_L00_002223f8(0x3D, 1); *(int *)(*(char **)(g + 0x2080) + 0x98) = -1; @@ -2942,12 +2939,12 @@ void FUN_L07_0030f5f0(unsigned char *moby) { } else { F(data, 0x13C) = ang; } - if (inside || *(short *)(((char *)&D_0013F65C_p)) != 0) { + if (inside || *(short *)(((char *)&D_0013F65C)) != 0) { goto end; } *(int *)(data + 0x14C) = 0; if (moby[0x53] != 1) { - blend_moby_animation_c(moby, 1, 0, 10); + blend_moby_animation(moby, 1, 0, 10); } moby[0x20] = 2; goto end; @@ -2957,19 +2954,19 @@ void FUN_L07_0030f5f0(unsigned char *moby) { float pi = 3.14159274f; float pi2 = 1.57079637f; FUN_L07_0030eee8_c((struct Moby *)moby, (struct WalkerData_p *)data); - FUN_L07_0030f1e0_c((char *)moby, data, F(data, 0x13C), 0.209439516f, D_0015ED70_p * 6.0f, - 0.52359879f, D_0015ED70_p * 4.0f, D_0015ED6C_p * seven, D_0015ED6C_p * 3.0f); - FUN_L07_0030f0f8_c((char *)moby, data, D_0015ED70_p * 12.0f, D_0015ED70_p * 50.0f, D_0015ED6C_p * seven); + 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), - D_0015ED70_p * pi2, D_0015ED70_p * pi, D_0015ED6C_p * pi); + 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, - D_0015ED70_p * pi2, D_0015ED70_p * pi, D_0015ED6C_p * pi); + frame_time_sq * pi2, frame_time_sq * pi, frame_time * pi); if ((moby[0x70] & 2) && moby[0x53] != 1) { - blend_moby_animation_c(moby, 1, 0, 10); + blend_moby_animation(moby, 1, 0, 10); } if (next != 0xFF) { if (moby[0x53] != anim) { - blend_moby_animation_c(moby, anim, 0, 6); + blend_moby_animation(moby, anim, 0, 6); } moby[0x20] = next; } @@ -2978,25 +2975,25 @@ void FUN_L07_0030f5f0(unsigned char *moby) { case 7: if (inside) { if (moby[0x53] != 4) { - blend_moby_animation_c(moby, 4, 0, 10); + blend_moby_animation(moby, 4, 0, 10); } moby[0x20] = 9; } else if (wander) { if (moby[0x53] != 4) { - blend_moby_animation_c(moby, 4, 0, 10); + 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_c(data + 0xD0, data + 0xD0, D_0015ED60_p * (0.95f - 1.0f) + 1.0f); - F(data, 0xD8) -= D_0015ED6C_p * 9.8f; + 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 != 0xFF) { if (moby[0x53] != anim) { - blend_moby_animation_c(moby, anim, 0, 6); + blend_moby_animation(moby, anim, 0, 6); } moby[0x20] = next; } @@ -3004,41 +3001,41 @@ void FUN_L07_0030f5f0(unsigned char *moby) { case 8: if (inside) { if (moby[0x53] != 4) { - blend_moby_animation_c(moby, 4, 0, 10); + blend_moby_animation(moby, 4, 0, 10); } moby[0x20] = 9; } else { float a = 0.785398185f; float b = 1.57079637f; FUN_L00_00258278((char *)moby, (float *)(data + 0x120), F(data, 0x13C), - D_0015ED70_p * a, D_0015ED70_p * b, D_0015ED6C_p * a); + frame_time_sq * a, frame_time_sq * b, frame_time * a); F(moby, 0x44) = FUN_L00_00258110((float *)(data + 0x124), F(moby, 0x44), 0.0f, - D_0015ED70_p * a, D_0015ED70_p * b, D_0015ED6C_p * a); + frame_time_sq * a, frame_time_sq * b, frame_time * a); if (wander && is_point_inside_clip_volume_c2(moby + 0x10, *(int *)(data + 0x114))) { if (moby[0x53] != 3) { - blend_moby_animation_c(moby, 3, 0, 10); + blend_moby_animation(moby, 3, 0, 10); } *(int *)(data + 0x134) = rand() % 120 + 60; moby[0x20] = 7; } } FUN_L07_0030eee8_c((struct Moby *)moby, (struct WalkerData_p *)data); - if (FUN_L07_0030f1e0_c((char *)moby, data, F(data, 0x13C), 0.34906584f, D_0015ED70_p * 3.0f, - 1.04719758f, D_0015ED70_p * 9.0f, D_0015ED6C_p, D_0015ED6C_p) && + 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_c(moby, 3, 0, 10); + blend_moby_animation(moby, 3, 0, 10); } *(int *)(data + 0x134) = rand() % 120 + 60; moby[0x20] = 7; } - F(data, 0xD8) -= D_0015ED6C_p * 9.8f; + 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 != 0xFF) { if (moby[0x53] != anim) { - blend_moby_animation_c(moby, anim, 0, 6); + blend_moby_animation(moby, anim, 0, 6); } moby[0x20] = next; } @@ -3050,16 +3047,16 @@ void FUN_L07_0030f5f0(unsigned char *moby) { float pi2 = 1.57079637f; ang = fast_arc_tan_c2(tgt.pos[0] - F(moby, 0x10), tgt.pos[1] - F(moby, 0x14)); func_L00_002592B0_t((char *)moby, ang, (float *)(data + 0x120), - D_0015ED70_p * 0.785398185f, D_0015ED70_p * pi2, D_0015ED6C_p * 0.785398185f); - if (FUN_L07_0030f1e0_c((char *)moby, data, ang, 0.52359879f, D_0015ED70_p * 4.0f, - pi2, D_0015ED70_p * 9.0f, D_0015ED6C_p * 1.5f, D_0015ED6C_p) && + frame_time_sq * 0.785398185f, frame_time_sq * pi2, frame_time * 0.785398185f); + if (FUN_L07_0030f1e0_c((char *)moby, data, ang, 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, &tgt) < 1.9f && moby[0x20] != 10) { if (moby[0x53] != 5) { - blend_moby_animation_c(moby, 5, 0, 2); + blend_moby_animation(moby, 5, 0, 2); } moby[0x20] = 10; } - F(data, 0xD8) -= D_0015ED6C_p * 9.8f; + 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); } @@ -3067,21 +3064,21 @@ void FUN_L07_0030f5f0(unsigned char *moby) { data[0x5A] = func_001FA898_r(9.6f); if (!inside) { if (moby[0x53] != 4) { - blend_moby_animation_c(moby, 4, 0, 10); + blend_moby_animation(moby, 4, 0, 10); } moby[0x20] = 8; } ((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, tgt.moby); if (moby[0x70] & 2) { if (moby[0x53] != 4) { - blend_moby_animation_c(moby, 4, 0, 10); + blend_moby_animation(moby, 4, 0, 10); } *(int *)(data + 0x134) = rand() % 200 + 300; moby[0x20] = 8; } if (next != 0xFF) { if (moby[0x53] != anim) { - blend_moby_animation_c(moby, anim, 0, 6); + blend_moby_animation(moby, anim, 0, 6); } moby[0x20] = next; } @@ -3112,7 +3109,7 @@ void FUN_L07_0030f5f0(unsigned char *moby) { goto end; case 16: fast_vec_scale_c(data + 0xD0, data + 0xD0, D_0015ED60_p * (0.95f - 1.0f) + 1.0f); - F(data, 0xD8) -= D_0015ED6C_p * 9.8f; + 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); @@ -3120,11 +3117,11 @@ void FUN_L07_0030f5f0(unsigned char *moby) { goto end; case 15: fast_vec_scale_c(data + 0xD0, data + 0xD0, D_0015ED60_p * (0.95f - 1.0f) + 1.0f); - F(data, 0xD8) -= D_0015ED6C_p * 9.8f; + F(data, 0xD8) -= frame_time * 9.8f; FUN_L00_00258ad0((int)moby, (int)(data + 0xD0), 0x400, 0x10, 1.0f, 0.0f); if (next != 0xFF) { if (moby[0x53] != anim) { - blend_moby_animation_c(moby, anim, 0, 6); + blend_moby_animation(moby, anim, 0, 6); } moby[0x20] = next; } diff --git a/src/overlays/l08/gameplay/entities/bolt_thief.c b/src/overlays/l08/gameplay/entities/bolt_thief.c index c167de860a..538c402c43 100644 --- a/src/overlays/l08/gameplay/entities/bolt_thief.c +++ b/src/overlays/l08/gameplay/entities/bolt_thief.c @@ -1945,59 +1945,54 @@ typedef struct { char pad10[0x10]; float n[4]; /* 0x20 */ } CollPos_4BE8; -extern CollPos_4BE8 D_L08_00174660_p __asm__("D_L08_00174660"); -extern KillFlags_4BE8 D_L08_001BADD0_p __asm__("D_L08_001BADD0"); -extern KillFlags_4BE8 D_L08_001BBA30_p __asm__("D_L08_001BBA30"); -extern struct Moby *D_L08_0015FFDC_p __asm__("D_L08_0015FFDC"); +extern CollPos_4BE8 D_L08_00174660; +extern KillFlags_4BE8 D_L08_001BADD0; +extern KillFlags_4BE8 D_L08_001BBA30; +extern struct Moby *D_L08_0015FFDC; extern char D_0013E533_p[] __asm__("D_0013E533"); 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_0015ED6C_p __asm__("D_0015ED6C"); -extern float D_0015ED70_p __asm__("D_0015ED70"); -extern float D_L08_00161C88_p __asm__("D_L08_00161C88") __attribute__((sda)); -extern float D_L08_00161C8C_p __asm__("D_L08_00161C8C") __attribute__((sda)); -extern float D_L08_00161C94_p __asm__("D_L08_00161C94") __attribute__((sda)); -extern float D_L08_00161C98_p __asm__("D_L08_00161C98") __attribute__((sda)); -extern float D_L08_00161C9C_p __asm__("D_L08_00161C9C"); -extern float D_L08_00161CA0_p __asm__("D_L08_00161CA0") __attribute__((sda)); -extern float D_L08_00161CA4_p __asm__("D_L08_00161CA4") __attribute__((sda)); -extern float D_L08_00161CA8_p __asm__("D_L08_00161CA8"); -extern float D_L08_00161CAC_p __asm__("D_L08_00161CAC") __attribute__((sda)); -extern float D_L08_00161CB0_p __asm__("D_L08_00161CB0"); -extern float D_L08_00161CB4_p __asm__("D_L08_00161CB4") __attribute__((sda)); +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_p __asm__("D_L08_00161CB8"); -extern float D_L08_00161CBC_p __asm__("D_L08_00161CBC") __attribute__((sda)); -extern float D_L08_00161CD0_p __asm__("D_L08_00161CD0") __attribute__((sda)); +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_add_rotations_c4(float, float) __asm__("func_001FA580"); extern float vector_distance_xy_alt(void *, void *) __asm__("FUN_001f9b80"); -extern int D_L08_0015F5CC_p __asm__("D_L08_0015F5CC"); -extern int D_L08_00161CC0_p __asm__("D_L08_00161CC0"); -extern int D_L08_00161CC4_p __asm__("D_L08_00161CC4") __attribute__((sda)); -extern int D_L08_00161CC8_p __asm__("D_L08_00161CC8"); -extern int D_L08_00161CCC_p __asm__("D_L08_00161CCC") __attribute__((sda)); -extern int D_L08_00161CD4_p __asm__("D_L08_00161CD4") __attribute__((sda)); -extern int D_L08_00174658_p __asm__("D_L08_00174658"); +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 s32 D_0013DF38_p[] __asm__("D_0013DF38"); -extern s32 D_0015ED84_p __asm__("D_0015ED84"); -extern s32 D_0015ED98_p __asm__("D_0015ED98"); -extern s32 allocate_voice_for_target_entry_alt_c2(s32, s32, struct Moby *) __asm__("FUN_0022da68"); +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 u8 D_0014C050_p[] __asm__("D_0014C050"); 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_p[] __asm__("D_L08_0015FC88") __attribute__((section(".sdata"))); +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_c(void *a, float x) __asm__("FUN_L00_0025f730"); @@ -2017,14 +2012,13 @@ int FUN_L00_00239df8(HudElem *m); void FUN_L00_00239cc8(HudElem *e); void FUN_L00_00239d00(void *o); extern char D_0013F350_p[] __asm__("D_0013F350"); -extern char D_0013F3D0_p[] __asm__("D_0013F3D0"); -extern char D_0013F490_p[] __asm__("D_0013F490"); -extern int D_L08_0015F6B0_2E0258 __asm__("D_L08_0015F5CC"); +extern char D_0013F3D0[]; +extern char D_0013F490[]; 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_0014C150_4BE8[][16] __asm__("D_0014C050"); -extern int D_L08_001746D8_4BE8 __asm__("D_L08_00174658") __attribute__((section(".data"))); +extern int D_L08_00174658_lui __asm__("D_L08_00174658") __attribute__((section(".data"))); void FUN_L08_002e3870(struct Moby *m) { char *cam; @@ -2040,18 +2034,18 @@ void FUN_L08_002e3870(struct Moby *m) { switch (m->oclass) { case 0x279: - m->scale = m->pclass->scale * *(float *)&D_L08_00161CB4_p; + m->scale = m->pclass->scale * *(float *)&D_L08_00161CB4_gp; break; case 0x3DC: m->scale = m->pclass->scale * *(float *)&D_L08_00161CB8_p; break; case 0x3DD: - m->scale = m->pclass->scale * *(float *)&D_L08_00161CBC_p; + m->scale = m->pclass->scale * *(float *)&D_L08_00161CBC_gp; break; } linked = 0; - if (D_L08_00161CD4_p > D_L08_0015F6B0_2E0258) { - D_L08_00161CD4_p = D_L08_0015F6B0_2E0258; + if (D_L08_00161CD4_gp > D_L08_0015F5CC) { + D_L08_00161CD4_gp = D_L08_0015F5CC; } m->flags &= ~0x100; qcopy(d->v0_p, &m->pos); @@ -2061,7 +2055,7 @@ void FUN_L08_002e3870(struct Moby *m) { fast_vec_scale_c(c, &m->rot_row2, -2.0f); add_vector_xyz(c, c, &m->pos); if (FUN_001efa68(b, c, 2, 0, 0) != 0) { - CollPos_4BE8 *hit = &D_L08_00174660_p; + CollPos_4BE8 *hit = &D_L08_00174660; qcopy(d->v0_p, hit->pos); linked = ((int *)hit)[-2]; fast_vec_normalize_c2(a, hit->n, 1.0f); @@ -2082,7 +2076,7 @@ void FUN_L08_002e3870(struct Moby *m) { m->state = 1; d->s6C = 0; d->u70.i = truncate_float_to_s32_c5(random_float_between_c5(0.0f, (float)scale_game_frames_c(600))); - d->u78.i = D_L08_00161CCC_p; + d->u78.i = D_L08_00161CCC_gp; break; } case 1: { @@ -2093,7 +2087,7 @@ void FUN_L08_002e3870(struct Moby *m) { if ((signed char)((struct Moby *)d->u7C.i)->state < 0) { d = (Vars_4BE8 *)m->pvars; clear_u64_value(d->v40); - FUN_L08_0026a0f8(d, &m->rot_row1, D_L08_00161C98_p * 0.017453292f * D_0015ED6C_p); + FUN_L08_0026a0f8(d, &m->rot_row1, D_L08_00161C98_gp * 0.017453292f * frame_time); m->state = 4; break; } @@ -2104,7 +2098,7 @@ void FUN_L08_002e3870(struct Moby *m) { m->state = 2; } if (m->visible == 0) { - if (m > D_L08_0015FFDC_p && vector_distance_xy_alt(&m->pos, ((char *)&D_0013F3D0_p)) > 24.0f) { + if (m > D_L08_0015FFDC && vector_distance_xy_alt(&m->pos, ((char *)&D_0013F3D0)) > 24.0f) { mark_moby_for_removal_c3(m); return; } @@ -2112,21 +2106,21 @@ void FUN_L08_002e3870(struct Moby *m) { } switch (m->oclass) { case 0x3DD: - d->f60 = fast_add_rotations_c4(d->f60, D_L08_00161CAC_p * 0.017453292f * D_0015ED6C_p); - d->f64 = fast_add_rotations_c4(d->f64, D_L08_00161CB0_p * 0.017453292f * D_0015ED6C_p); + d->f60 = fast_add_rotations_c4(d->f60, D_L08_00161CAC_gp * 0.017453292f * frame_time); + d->f64 = fast_add_rotations_c4(d->f64, D_L08_00161CB0 * 0.017453292f * frame_time); break; case 0x3DC: - d->f60 = fast_add_rotations_c4(d->f60, D_L08_00161CA4_p * 0.017453292f * D_0015ED6C_p); - d->f64 = fast_add_rotations_c4(d->f64, D_L08_00161CA8_p * 0.017453292f * D_0015ED6C_p); + d->f60 = fast_add_rotations_c4(d->f60, D_L08_00161CA4_gp * 0.017453292f * frame_time); + d->f64 = fast_add_rotations_c4(d->f64, D_L08_00161CA8 * 0.017453292f * frame_time); break; default: - d->f60 = fast_add_rotations_c4(d->f60, D_L08_00161C9C_p * 0.017453292f * D_0015ED6C_p); - d->f64 = fast_add_rotations_c4(d->f64, D_L08_00161CA0_p * 0.017453292f * D_0015ED6C_p); + d->f60 = fast_add_rotations_c4(d->f60, D_L08_00161C9C * 0.017453292f * frame_time); + d->f64 = fast_add_rotations_c4(d->f64, D_L08_00161CA0_gp * 0.017453292f * frame_time); break; } FUN_L08_002e4e90_c((char *)m, (float *)&m->pos, (float *)&m->rot); if (d->s6C != 0) { - d->f74 = fast_add_rotations_c4(d->f74, D_0015ED6C_p * 5.2359877f); + d->f74 = fast_add_rotations_c4(d->f74, frame_time * 5.2359877f); if (d->u70.i > 12) { d->u78.i += 0x5000000; } else { @@ -2135,7 +2129,7 @@ void FUN_L08_002e3870(struct Moby *m) { if (tick_countdown_32_alt(&d->u70.i) != 0) { d->s6C = 0; d->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 (m->visible != 0 && D_L08_00161CC8_p != 0) { + } else if (m->visible != 0 && D_L08_00161CC8 != 0) { func_001F49B0_2E16A0(FUN_L08_002e5188_c, m); return; } @@ -2154,21 +2148,21 @@ void FUN_L08_002e3870(struct Moby *m) { if (tick_countdown_32_alt(&d->i68) != 0) { Vars_4BE8 *e = (Vars_4BE8 *)m->pvars; float k = 0.017453292f; - char *hero_pos = D_0013F3D0_p; + char *hero_pos = D_0013F3D0; subtract_vector_xyz(b, &m->pos, hero_pos); fast_vec_normalize_c2(b, b, 1.0f); cross_vectors_xyz(b, a, b); - FUN_L08_0026a0f8(e, b, D_L08_00161C94_p * k * D_0015ED6C_p); + FUN_L08_0026a0f8(e, b, D_L08_00161C94_gp * k * frame_time); m->flags |= 0x100; - fast_vec_normalize_c2(e->v40, a, D_0015ED6C_p * 8.0f); + fast_vec_normalize_c2(e->v40, a, frame_time * 8.0f); e->f74 = 0.0f; - e->u70.f = D_0015ED6C_p * 8.0f; + e->u70.f = frame_time * 8.0f; e->u78.p = *(char **)(hero_pos + 0x2000); e->u7C.f = 0.5f; - if (D_L08_00161CD4_p + scale_game_frames_c(3) < D_L08_0015F6B0_2E0258) { - D_L08_00161CD4_p = D_L08_0015F6B0_2E0258; - allocate_voice_for_target_entry_alt_c2(0, 0x20, m); + 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, m); e->f64 = 0.0f; } else { e->f64 = random_float_between_c5(-30.0f, 30.0f) * k; @@ -2216,17 +2210,17 @@ void FUN_L08_002e3870(struct Moby *m) { add_vector_xyz(&m->pos, &m->pos, d->v40); fast_vec_normalize_c2(a, a, d->f74); add_vector_xyz(&m->pos, &m->pos, a); - cam = D_0013F490_p; + cam = D_0013F490; add_vector_xyz(&m->pos, &m->pos, cam); subtract_vector_xyz(c, &m->pos, cam + 0x160); transform_vector(c, c, cam - 0x100); if (((struct Moby *)d->u78.p)->oclass != 0 || c[2] > 0.0f) { - func_00214D28_2E16A0(&d->u70.f, 0.0f, D_L08_00161C8C_p * D_0015ED70_p); - func_00214D28_2E16A0(&d->f74, D_L08_00161C88_p * D_0015ED6C_p, D_L08_00161C8C_p * D_0015ED70_p); + func_00214D28_2E16A0(&d->u70.f, 0.0f, D_L08_00161C8C_gp * frame_time_sq); + func_00214D28_2E16A0(&d->f74, D_L08_00161C88_gp * frame_time, D_L08_00161C8C_gp * frame_time_sq); } else { fast_vec_normalize_c2(mt, cam - 0x120, d->u70.f); subtract_vector_xyz(mt + 4, mt, d->v40); - FUN_L00_0025f730_c(mt + 4, D_L08_00161C8C_p * D_0015ED70_p); + FUN_L00_0025f730_c(mt + 4, D_L08_00161C8C_gp * frame_time_sq); add_vector_xyz(d->v40, d->v40, mt + 4); } if (dist < d->f74) { @@ -2235,11 +2229,11 @@ void FUN_L08_002e3870(struct Moby *m) { lim = d->f74 * (float)scale_game_frames_c(20); if (dist < lim) { if (fast_vec_dist(b, &m->pos) > 0.52f) { - if (D_L08_00161CC0_p != 0) { + if (D_L08_00161CC0 != 0) { m->alpha = (fast_vec_dist(b, &m->pos) + lim) * 128.0f / (lim + lim); } - if (D_L08_00161CC4_p != 0) { - m->scale = m->pclass->scale * *(float *)&D_L08_00161CB4_p * (fast_vec_dist(b, &m->pos) + lim) / (lim + lim); + if (D_L08_00161CC4_gp != 0) { + m->scale = m->pclass->scale * *(float *)&D_L08_00161CB4_gp * (fast_vec_dist(b, &m->pos) + lim) / (lim + lim); } } else { int value; @@ -2254,7 +2248,7 @@ void FUN_L08_002e3870(struct Moby *m) { int j; int n; - D_0014BEC0[D_0015ED84_p][m->command] = 1; + D_0014BEC0[current_level_index][m->command] = 1; n = 0; for (i = 0; i < 20; i++) { for (j = 0; j < 4; j++) { @@ -2277,7 +2271,7 @@ void FUN_L08_002e3870(struct Moby *m) { break; } k = 0.7f; - FUN_L00_00257d78(mt, D_0015ED6C_p * k, D_0015ED6C_p); + FUN_L00_00257d78(mt, frame_time * k, frame_time); fast_vec_scale_c(mt + 4, mt, 10.0f); add_vector_xyz(mt + 4, mt + 4, &m->pos); spin = random_integer_below_c2(2); @@ -2290,15 +2284,15 @@ void FUN_L08_002e3870(struct Moby *m) { FUN_L00_00272060(mt + 4, scale_game_frames_c(0x19), size * 0.14f, size * k, 0x7F7F7F7F, 1, spin, mt, 0.0f); src = m->parent; if (src && !(src->id & 0x80)) { - D_0014D590[D_0015ED84_p][src->id].bolts += value; + D_0014D590[current_level_index][src->id].bolts += value; } - D_0015ED98_p += value; - D_0013DF38_p[D_0015ED84_p] += value; - queue_animation_update_alt(2, 0x754E, func_L00_0023A658_4BE8, func_L00_0023A690_4BE8, func_L00_0023A788_4BE8, &D_0015ED98_p, 9999999); - if (m < D_L08_0015FFDC_p) { - D_L08_001BADD0_p.killed[(short)m->save_id] = m->mission + 2; - if (m->mission == 0xFF || (D_L08_0015FC88_p[m->mission] != 0xFF && D_0014C150_4BE8[D_0015ED84_p][m->mission] == 0xFF)) { - D_L08_001BBA30_p.killed[(short)m->save_id] = m->mission + 2; + D_0015ED98 += value; + D_0013DF38_p[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 (m < D_L08_0015FFDC) { + D_L08_001BADD0.killed[(short)m->save_id] = m->mission + 2; + if (m->mission == 0xFF || (D_L08_0015FC88_macro[m->mission] != 0xFF && D_0014C150_4BE8[current_level_index][m->mission] == 0xFF)) { + D_L08_001BBA30.killed[(short)m->save_id] = m->mission + 2; } } mark_moby_for_removal_c3(m); @@ -2312,7 +2306,7 @@ void FUN_L08_002e3870(struct Moby *m) { Vars_4BE8 *d = (Vars_4BE8 *)m->pvars; add_vector_xyz(&m->pos, &m->pos, d->v40); - d->v40[2] -= D_0015ED70_p * 10.8f; + d->v40[2] -= frame_time_sq * 10.8f; multiply_matrix_basis_columns(&m->rot_row0, d, &m->rot_row0); if (m->pos.z < 2.0f || m->pos.x > 510.0f || m->pos.x < 2.0f || m->pos.y > 510.0f || m->pos.y < 2.0f) { int value; @@ -2331,10 +2325,10 @@ void FUN_L08_002e3870(struct Moby *m) { } src = m->parent; if (src && !(src->id & 0x80)) { - D_0014D590[D_0015ED84_p][src->id].bolts += value; + D_0014D590[current_level_index][src->id].bolts += value; } - D_0015ED98_p += value; - D_0013DF38_p[D_0015ED84_p] += value; + D_0015ED98 += value; + D_0013DF38_p[current_level_index] += value; mark_moby_for_removal_c3(m); return; } @@ -2347,17 +2341,17 @@ void FUN_L08_002e3870(struct Moby *m) { break; } if (FUN_L00_001f0d60(0.25f, &m->pos, 0x22, m) != 0) { - subtract_vector_xyz(a, &m->pos, D_L08_00174660_p.pos); + subtract_vector_xyz(a, &m->pos, D_L08_00174660.pos); FUN_L00_001ff660(d->v40, d->v40, a); if (fast_arc_tan(a[2], func_001F9CE8_2E16A0(a)) < 0.7853982f - && fast_arc_tan(((Coll_4BE8 *)((char *)&D_L08_00174660_p - 0x20))->n[2], func_001F9CE8_2E16A0(D_L08_00174660_p.n)) < 0.7853982f) { - Coll_4BE8 *cl = (Coll_4BE8 *)((char *)&D_L08_00174660_p - 0x20); + && fast_arc_tan(((Coll_4BE8 *)((char *)&D_L08_00174660 - 0x20))->n[2], func_001F9CE8_2E16A0(D_L08_00174660.n)) < 0.7853982f) { + Coll_4BE8 *cl = (Coll_4BE8 *)((char *)&D_L08_00174660 - 0x20); int n; float inv; m->flags &= ~0x100; d = (Vars_4BE8 *)m->pvars; - n = truncate_float_to_s32_c5(FUN_001f96b0(D_L08_00161CD0_p + random_float_between_c5(-10.0f, 10.0f))); + n = truncate_float_to_s32_c5(FUN_001f96b0(D_L08_00161CD0_gp + random_float_between_c5(-10.0f, 10.0f))); inv = 1.0f / convert_integer_to_float(n); qcopy(d->v0_p, cl->pos); matrix_to_euler(&m->rot_row0, &m->rot); @@ -2378,13 +2372,13 @@ void FUN_L08_002e3870(struct Moby *m) { add_vector_xyz(d->v0_p, d->v0_p, b); } } - d->v40[2] += D_0015ED70_p * 10.8f * (float)(n >> 1); + d->v40[2] += frame_time_sq * 10.8f * (float)(n >> 1); d->f50 = fast_subtract_rotations_c2(d->v30[0], m->rot.x) * inv; d->f54 = fast_subtract_rotations_c2(d->v30[1], m->rot.y) * inv; d->f58 = fast_subtract_rotations_c2(d->v30[2], m->rot.z) * inv; m->state = 5; d->i68 = n; - d->u7C.i = D_L08_001746D8_4BE8; + d->u7C.i = D_L08_00174658_lui; if (absolute_float(m->pos.z - ((Hero *)(((char *)&D_0013F350_p)))->motion.pos.f[2]) < ((Hero *)(((char *)&D_0013F350_p)))->reach_distance && vector_distance_xy_alt(&m->pos, ((Hero *)(((char *)&D_0013F350_p)))->motion.pos.f) < ((Hero *)(((char *)&D_0013F350_p)))->reach_height) { Vars_4BE8 *e = (Vars_4BE8 *)m->pvars; @@ -2403,7 +2397,7 @@ void FUN_L08_002e3870(struct Moby *m) { m->rot.y = fast_add_rotations_c4(m->rot.y, d->f54); m->rot.z = fast_add_rotations_c4(m->rot.z, d->f58); add_vector_xyz(&m->pos, &m->pos, d->v40); - d->v40[2] -= D_0015ED70_p * 10.8f; + d->v40[2] -= frame_time_sq * 10.8f; if (tick_countdown_32_alt(&d->i68) != 0) { int n; float inv; @@ -2445,7 +2439,7 @@ void FUN_L08_002e3870(struct Moby *m) { add_vector_xyz(d->v0_p, d->v0_p, a); } } - d->v40[2] += D_0015ED70_p * 10.8f * (float)(n >> 1); + d->v40[2] += frame_time_sq * 10.8f * (float)(n >> 1); } break; } diff --git a/src/overlays/l10/gameplay/entities/platform.c b/src/overlays/l10/gameplay/entities/platform.c index 1139f456be..a86624bbc4 100644 --- a/src/overlays/l10/gameplay/entities/platform.c +++ b/src/overlays/l10/gameplay/entities/platform.c @@ -436,7 +436,7 @@ 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_alt(int, int, int) __asm__("FUN_0022da68"); +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"); @@ -465,7 +465,7 @@ extern char *D_L10_00160058_00299818 __asm__("D_L10_0015FFD8"); #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_alt) +#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) diff --git a/src/overlays/l12/gameplay/entities/003054b0.c b/src/overlays/l12/gameplay/entities/003054b0.c index 703af5197f..b58a95068f 100644 --- a/src/overlays/l12/gameplay/entities/003054b0.c +++ b/src/overlays/l12/gameplay/entities/003054b0.c @@ -484,7 +484,7 @@ void FUN_L12_003064e8(char *moby) { /* 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 int D_L12_0015F5CC_p __asm__("D_L12_0015F5CC"); -extern unsigned char * D_L12_0015FFD8_p_c __asm__("D_L12_0015FFD8"); +extern unsigned char * D_L12_0015FFD8; extern struct Moby *D_L12_00160058_303CA8 __asm__("D_L12_0015FFD8"); void FUN_L12_00306828(char *moby) { diff --git a/src/overlays/shared/gameplay/entities/00295100.c b/src/overlays/shared/gameplay/entities/00295100.c index c467a4e92d..dd8b079821 100644 --- a/src/overlays/shared/gameplay/entities/00295100.c +++ b/src/overlays/shared/gameplay/entities/00295100.c @@ -838,7 +838,7 @@ extern s32 movie_buffer __asm__("D_L00_00161054") __attribute__((section(".sdata extern s32 movie_image_data __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_data __asm__("D_L00_00173E04") __attribute__((section(".data"))); +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 gs_layout_macro[6] __asm__("D_0015EE78") __attribute__((section(".sdata"))); extern void flush_cache(s32) __asm__("FUN_00118a80"); @@ -849,7 +849,7 @@ extern void FUN_L00_002039a0(void); 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 debug_print_002995d0(char *, s32) __asm__("FUN_001e93b0"); +extern void FUN_001e93b0(char *, s32); extern void FUN_001f97b0(void); extern char D_L00_001E9480[]; @@ -869,7 +869,7 @@ void FUN_L00_002995d0(s32 sector, s32 size, s32 language) { fade_to_black(4); FUN_L00_002039a0(); D_L00_0015F5C4_macro = 1; - movie_buffer = D_L00_00173E04_data; + movie_buffer = D_L00_00173E04_lui; movie_image_data = D_L00_0015F40C_macro; large_count = D_0015ED80 != 0 ? 0xE : 0xD; small_count = D_0015ED80 != 0 ? 0xE : 0x11; @@ -897,7 +897,7 @@ void FUN_L00_002995d0(s32 sector, s32 size, s32 language) { wait_for_graphics_pipeline_idle(0, 0); } if (gs_address > 0x400000) { - debug_print_002995d0(D_L00_001E9480, gs_address - 0x400000); + FUN_001e93b0(D_L00_001E9480, gs_address - 0x400000); FUN_001f97b0(); } } diff --git a/src/overlays/shared/gameplay/entities/bomb.c b/src/overlays/shared/gameplay/entities/bomb.c index 3937322788..17a735fe87 100644 --- a/src/overlays/shared/gameplay/entities/bomb.c +++ b/src/overlays/shared/gameplay/entities/bomb.c @@ -1003,7 +1003,7 @@ 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 float D_L00_0015F580[] __attribute__((section(".sdata"))); -extern float D_L00_00161890_c __asm__("D_L00_00161890") __attribute__((sda)); +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); @@ -1028,7 +1028,7 @@ extern void fast_vec_normalize(void *, void *, f32) __asm__("FUN_001f9bf8"); extern void mark_moby_for_removal_c2(void *) __asm__("func_0020C828"); extern char D_0013E520_c[] __asm__("D_0013E520"); -char *FUN_L00_002caf70(char *a, char *vec, char *b, float f12, float f13, float f14, float f15) { +char *FUN_L00_002caf70(char *a, char *vec, char *b, float unk18, float unk1C, float yaw, float pitch) { float tv[4]; float lf[4]; float out[4]; @@ -1048,7 +1048,7 @@ char *FUN_L00_002caf70(char *a, char *vec, char *b, float f12, float f13, float float len; float ret; float fi; - float f16; + float fraction; float *t; t = tv; @@ -1061,9 +1061,9 @@ char *FUN_L00_002caf70(char *a, char *vec, char *b, float f12, float f13, float *(short *)(m + 0x32) = 0x7F; m[0x31] = 1; *(long *)(m + 0x38) = *(long *)(a + 0x38); - *(float *)(m + 0x40) = D_L00_00161890_c; - *(float *)(m + 0x44) = fast_add_rotations(f15, (&D_L00_00161890_c)[1]); - *(float *)(m + 0x48) = f14; + *(float *)(m + 0x40) = D_L00_00161890_gp; + *(float *)(m + 0x44) = fast_add_rotations(pitch, (&D_L00_00161890_gp)[1]); + *(float *)(m + 0x48) = yaw; qcopy(m + 0x10, t); if (b != 0) { int rr; @@ -1077,8 +1077,8 @@ char *FUN_L00_002caf70(char *a, char *vec, char *b, float f12, float f13, float } else { clear_u64_value_c(d); } - *(float *)(d + 0x18) = f12; - *(float *)(d + 0x1C) = f13; + *(float *)(d + 0x18) = unk18; + *(float *)(d + 0x1C) = unk1C; *(int *)(d + 0x10) = 0; *(int *)(d + 0x14) = 0; r2 = scale_game_frames_c2(0x23); @@ -1136,8 +1136,8 @@ char *FUN_L00_002caf70(char *a, char *vec, char *b, float f12, float f13, float if (q != 0) { *(float *)(q + 0xC) = random_float_between_c2(*(float *)&D_L00_00161870, *(float *)&D_L00_00161874); fi = convert_integer_to_float_c(i); - f16 = fi / convert_integer_to_float_c(16); - ret = FUN_L00_00257e20(-1.5f, 0.0f, 1.0f, 0.0f, f16); + fraction = fi / convert_integer_to_float_c(16); + ret = FUN_L00_00257e20(-1.5f, 0.0f, 1.0f, 0.0f, fraction); *(float *)(q + 0xC) = *(float *)(q + 0xC) + (*(float *)&D_L00_00161878 - *(float *)(q + 0xC)) * ret; r = truncate_float_to_s32_c(ret * -64.0f + 128.0f); *(int *)(q + 4) = (r << 24) | 0xFFFFFF; diff --git a/src/overlays/shared/gameplay/entities/trespasser.c b/src/overlays/shared/gameplay/entities/trespasser.c index 8e5d579113..a4efa7e84a 100644 --- a/src/overlays/shared/gameplay/entities/trespasser.c +++ b/src/overlays/shared/gameplay/entities/trespasser.c @@ -1169,8 +1169,8 @@ extern struct { u8 pad0[0x11]; u8 unk11; } D_0013E520_2c1ad0 __asm__("D_0013E520 extern struct { u8 pad0[0x88]; u16 deliveries; u16 unk8A; u32 levels; } D_00141680_s __asm__("D_00141680"); extern struct { u8 pad0[0x18]; s32 moby; u8 pad1C[4]; Vec4 point; } coll_hit_2c1ad0 __asm__("D_L00_00173E40"); extern Vec4 D_L00_00166DC0_v __asm__("D_L00_00166DC0"); -extern char D_L00_00166C80_c[] __asm__("D_L00_00166C80"); -extern short D_L00_001B07B0_2c1ad0[] __asm__("D_L00_001B07B0"); +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"))); @@ -1207,7 +1207,7 @@ void FUN_L00_002c1ad0(struct Moby *moby) { offset.q = 0; offset.f[1] = -0.09f; offset.f[2] = -0.02f; - setup_matrix_2c1ad0(basis, D_L00_00166C80_c); + setup_matrix_2c1ad0(basis, D_L00_00166C80); matrix_from_basis_rows_2c1ad0(matrix, basis); if (vars == 0) return; @@ -1309,7 +1309,7 @@ void FUN_L00_002c1ad0(struct Moby *moby) { D_00141680_s.unk8A = scale_game_frames(D_0015EEA4_macro) / 600; } D_00141680_s.levels = (D_00141680_s.levels | (1u << current_level_index_macro)) | 0x80000000; - FUN_L00_0025f780(vars->held, D_L00_001B07B0_2c1ad0, 0x3F); + FUN_L00_0025f780(vars->held, D_L00_001B07B0, 0x3F); vars->held = 0; vars->timer54 = scale_game_frames(10); } diff --git a/src/overlays/shared/rendering/00245c28.c b/src/overlays/shared/rendering/00245c28.c index c979936b33..71cacf8a8f 100644 --- a/src/overlays/shared/rendering/00245c28.c +++ b/src/overlays/shared/rendering/00245c28.c @@ -312,21 +312,20 @@ extern float D_L00_00182A70[]; extern int *D_L00_00173E08[]; extern int D_L00_00183EF0[]; extern int D_L00_001841F0_c[] __asm__("D_L00_001841F0"); -extern int func_0020C468() __asm__("FUN_L00_0024d8d0"); +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_alt(int *dst, unsigned char *src, short *offs) __asm__("FUN_00206710"); +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 *arg0, unsigned char *arg1, int arg2) __asm__("FUN_00207bb0"); +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 char D_00138438_c[] __asm__("D_00138438"); extern char D_001383A0[]; extern char D_00141EC0[]; -extern int D_0015EE84_2465F8 __asm__("D_0015ED84"); void FUN_L00_002464a8(void) { int i, j; @@ -352,7 +351,7 @@ void FUN_L00_002464a8(void) { ((float *)D_L00_001841F0_c)[0x2D + i] = 0.65f; D_L00_001841F0_c[0x55 + i] = D_L00_00183EF0[i * 2 + 1]; } } - v = D_0015EE84_2465F8; + v = current_level_index; D_L00_001841F0_c[0x8B] = -1; D_L00_001841F0_c[0x89] = v > 18 ? 0 : v; { int i; @@ -384,7 +383,7 @@ void FUN_L00_002464a8(void) { load(archive, e[0], e[1]); gl[0x8B] = stash_send_data((int)archive, scratch, 0x4800, (int)D_L00_001E8B00); gl[0x8D] = scratch; - func_0020C468((int)archive, (int)archive_base); + FUN_L00_0024d8d0((int)archive, (int)archive_base); archive = archive_base; first_size = archive[1] - archive[0]; gl[0] = hud_heap_alloc(first_size, 0, (char *)heap_tag, 0x2DB); @@ -406,7 +405,7 @@ void FUN_L00_002464a8(void) { if (level_data[0] != 0) { load_map_chunk((void *)D_L00_001841F0_c[3], level_data, D_L00_001841F0_c[5]); } else { - decode_map_mask_alt((int *)D_L00_001841F0_c[3], (unsigned char *)D_L00_001841F0_c[0], (short *)D_L00_001841F0_c[1]); + decode_map_mask((int *)D_L00_001841F0_c[3], (unsigned char *)D_L00_001841F0_c[0], (short *)D_L00_001841F0_c[1]); } lim = 256.0f; for (y = 0; y < 32; y++) { diff --git a/src/overlays/shared/ui/help/001ff938.c b/src/overlays/shared/ui/help/001ff938.c index ca9517593a..b3bffd47d0 100644 --- a/src/overlays/shared/ui/help/001ff938.c +++ b/src/overlays/shared/ui/help/001ff938.c @@ -10,18 +10,17 @@ 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_p __asm__("D_L15_0017C14C"); -extern int D_L15_0015F5B0_p __asm__("D_L15_0015F5B0"); -extern int D_L15_0015F5CC_p __asm__("D_L15_0015F5CC"); +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 short D_0015EE18_p __asm__("D_0015EE18"); -extern unsigned char D_0013D4DC_p[] __asm__("D_0013D4DC"); -extern unsigned char D_0013E533_p[] __asm__("D_0013E533"); -extern unsigned char D_0013F350_p[] __asm__("D_0013F350"); +extern short D_0015EE18; +extern unsigned char D_0013D4DC[]; +extern unsigned char D_0013F350[]; extern struct { unsigned char b[8]; } D_0015EDB0_s __asm__("D_0015EDB0"); -extern float D_L15_0017C06C_f[] __asm__("D_L15_0017C06C"); -extern float D_L15_0017C1CC_f[] __asm__("D_L15_0017C1CC"); +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_002059d8(void); @@ -53,7 +52,7 @@ void FUN_L15_001ff938(void) { FUN_L00_00211670(); FUN_L15_002044c8(); FUN_L15_0021d040(); - b0 = ((char *)&D_0013F350_p); + b0 = ((char *)&D_0013F350); if (b0[0x20A4] == 0) return; FUN_L00_00216f10(); @@ -67,7 +66,7 @@ void FUN_L15_001ff938(void) { if (b0[0x20A4] == 2) { if (D_0015EDB0_s.b[3] != 0) - D_L15_0017C06C_f[0] = (*(float *)&D_0015EE18_p) * 1.4f; + D_L15_0017C06C[0] = (*(float *)&D_0015EE18) * 1.4f; FUN_L00_002059d8(); FUN_L00_002061f0(); { @@ -80,21 +79,21 @@ void FUN_L15_001ff938(void) { } } - b1 = ((char *)&D_0013F350_p); + b1 = ((char *)&D_0013F350); if (b1[0x20A4] == 3) { if (D_0015EDB0_s.b[1] != 0) - D_L15_0017C1CC_f[0] = 1.9f; + D_L15_0017C1CC[0] = 1.9f; alpha = 0x80; period = scale_game_frames(0xAA); if (*(short *)(b1 + 0x22E0) == 2) period = scale_game_frames(0x32); else if (*(short *)(b1 + 0x22E0) == 1) period = scale_game_frames(0x5A); - pulse = fast_sin((((float)(D_L15_0015F5CC_p % period) / convert_integer_to_float(period)) * 2.0f) * 3.1415927f + -3.1415927f); + 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); - b2 = ((char *)&D_0013F350_p); + b2 = ((char *)&D_0013F350); moby = *(unsigned char **)(b2 + 0x2080); if (red > 0xFF) red = 0xFF; if (green > 0xFF) green = 0xFF; @@ -104,16 +103,16 @@ void FUN_L15_001ff938(void) { color = (alpha << 24) | (blue << 16) | ((red / 2) << 8) | green; else color = (alpha << 24) | (blue << 16) | (green << 8) | red; - b3 = ((char *)&D_0013F350_p); + b3 = ((char *)&D_0013F350); *(unsigned int *)(*(unsigned char **)(b3 + 0x2080) + 0x90) = fast_tween_color(0.1f, *(unsigned int *)(*(unsigned char **)(b3 + 0x2080) + 0x90), color); for (i = 0; i < 3; i++) { - b4 = ((char *)&D_0013F350_p); + b4 = ((char *)&D_0013F350); FUN_L00_0024f7c8(*(void **)(b4 + 0x2080), i, b4 + 0x1D50 + i * 16); } alpha = 0x30; - b4 = ((char *)&D_0013F350_p); + b4 = ((char *)&D_0013F350); { unsigned char *mb = *(unsigned char **)(b4 + 0x2080); blue = mb[0x92]; @@ -134,9 +133,9 @@ void FUN_L15_001ff938(void) { *(short *)(b4 + 0x22DC) = 1; } } else { - b5 = ((char *)&D_0013F350_p); + b5 = ((char *)&D_0013F350); *(int *)(b5 + 0x20B8) = 0; - if (b5[0x12E7] != 0 && *(int *)(b5 + 0x300) != 0 && D_0013D4DC_p[0] != 0 && + if (b5[0x12E7] != 0 && *(int *)(b5 + 0x300) != 0 && D_0013D4DC[0] != 0 && *(short *)(b5 + 0x22DE) == 0) { FUN_L00_00216de8(0x19, 0); *(short *)(b5 + 0x22DE) = 0x12; @@ -146,7 +145,7 @@ void FUN_L15_001ff938(void) { } } FUN_L00_00208b60(); - b6 = ((char *)&D_0013F350_p); + b6 = ((char *)&D_0013F350); FUN_L00_00257024(*(void **)(b6 + 0x2080)); } #define NOT_SDA diff --git a/src/overlays/shared/ui/hud/hud_keep_visible.c b/src/overlays/shared/ui/hud/hud_keep_visible.c index 9bd8a0c3e4..40d876291c 100644 --- a/src/overlays/shared/ui/hud/hud_keep_visible.c +++ b/src/overlays/shared/ui/hud/hud_keep_visible.c @@ -343,10 +343,10 @@ typedef struct { extern f32 random_float_between(f32, f32) __asm__("FUN_002132a8"); extern float D_L00_0017E660_c[][4] __asm__("D_L00_0017E660"); -extern short D_L00_0015F750_p __asm__("D_L00_0015F750") __attribute__((sda)); -extern short D_L00_0015F754_p __asm__("D_L00_0015F754") __attribute__((sda)); -extern short D_L00_0015F758_p __asm__("D_L00_0015F758") __attribute__((sda)); -extern short D_L00_0015F75C_p __asm__("D_L00_0015F75C") __attribute__((sda)); +extern short D_L00_0015F750_gp __asm__("D_L00_0015F750") __attribute__((sda)); +extern short D_L00_0015F754_gp __asm__("D_L00_0015F754") __attribute__((sda)); +extern short D_L00_0015F758_gp __asm__("D_L00_0015F758") __attribute__((sda)); +extern short D_L00_0015F75C_gp __asm__("D_L00_0015F75C") __attribute__((sda)); void FUN_L00_00235d80_c(HudElem_p *e) __asm__("FUN_L00_00235d80"); void FUN_L00_00236268(HudElem_p *e) { @@ -356,12 +356,12 @@ void FUN_L00_00236268(HudElem_p *e) { FUN_L00_00235d80_c(e); for (i = 0; i < 100; i++) { - v = *(float *)&D_L00_0015F750_p; + v = *(float *)&D_L00_0015F750_gp; if (i >= 10) { - v = *(float *)&D_L00_0015F754_p; - if (i >= 20) v = *(float *)&D_L00_0015F758_p; + v = *(float *)&D_L00_0015F754_gp; + if (i >= 20) v = *(float *)&D_L00_0015F758_gp; } - n = *(int *)&D_L00_0015F75C_p; + n = *(int *)&D_L00_0015F75C_gp; span = (232.0f - (v + v)) / (float)n; lo = (v - 116.0f) + (float)(i % n) * span; hi = lo + span; diff --git a/src/overlays/shared/ui/text/002377b8.c b/src/overlays/shared/ui/text/002377b8.c index 8d869a596f..0ed37c9efc 100644 --- a/src/overlays/shared/ui/text/002377b8.c +++ b/src/overlays/shared/ui/text/002377b8.c @@ -361,12 +361,12 @@ 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_r[] __asm__("D_00141EA0"); -extern SrcElem_p D_L00_00179AC0_p[] __asm__("D_L00_00179AC0"); +extern unsigned char D_00141EA0[]; +extern SrcElem_p D_L00_00179AC0[]; extern char *get_help_message_text(s32) __asm__("func_001FDD10"); -extern char D_0013D428_p[] __asm__("D_0013D428"); +extern char D_0013D428[]; extern char D_L00_0015F5CC_p[] __asm__("D_L00_0015F5CC"); -extern char D_L00_0015F7C8_p[] __asm__("D_L00_0015F7C8"); +extern char D_L00_0015F7C8[]; 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"); @@ -379,30 +379,28 @@ extern s32 sprintf(char *, const char *, ...); extern s32 truncate_float_to_s32_c2(f32) __asm__("func_001FA6D0"); extern short D_L00_0015F718_p __asm__("D_L00_0015F718") __attribute__((sda)); extern short D_L00_0015F71C_p __asm__("D_L00_0015F71C") __attribute__((sda)); -extern short D_L00_0015F720_p __asm__("D_L00_0015F720") __attribute__((sda)); -extern short D_L00_0015F724_p __asm__("D_L00_0015F724") __attribute__((sda)); -extern short D_L00_0015F72C_p __asm__("D_L00_0015F72C") __attribute__((sda)); +extern short D_L00_0015F720_gp __asm__("D_L00_0015F720") __attribute__((sda)); +extern short D_L00_0015F724_gp __asm__("D_L00_0015F724") __attribute__((sda)); +extern short D_L00_0015F72C_gp __asm__("D_L00_0015F72C") __attribute__((sda)); extern short D_L00_0015F780_p __asm__("D_L00_0015F780") __attribute__((sda)); -extern short D_L00_0015F78C_p __asm__("D_L00_0015F78C") __attribute__((sda)); -extern short D_L00_0015F790_p __asm__("D_L00_0015F790") __attribute__((sda)); -extern short D_L00_0015F794_p __asm__("D_L00_0015F794") __attribute__((sda)); -extern short D_L00_0015F798_p __asm__("D_L00_0015F798") __attribute__((sda)); -extern short D_L00_0015F79C_p __asm__("D_L00_0015F79C"); -extern short D_L00_0015F7A0_p __asm__("D_L00_0015F7A0") __attribute__((sda)); -extern short D_L00_0015F7A4_p __asm__("D_L00_0015F7A4") __attribute__((sda)); -extern short D_L00_0015F7A8_p __asm__("D_L00_0015F7A8") __attribute__((sda)); -extern short D_L00_0015F7AC_p __asm__("D_L00_0015F7AC"); -extern short D_L00_0015F7B0_p __asm__("D_L00_0015F7B0") __attribute__((sda)); -extern short D_L00_0015F7B4_p __asm__("D_L00_0015F7B4"); -extern short D_L00_0015F7B8_p __asm__("D_L00_0015F7B8"); -extern short D_L00_0015F7BC_p __asm__("D_L00_0015F7BC") __attribute__((sda)); +extern short D_L00_0015F78C_gp __asm__("D_L00_0015F78C") __attribute__((sda)); +extern short D_L00_0015F790_gp __asm__("D_L00_0015F790") __attribute__((sda)); +extern short D_L00_0015F794_gp __asm__("D_L00_0015F794") __attribute__((sda)); +extern short D_L00_0015F798_gp __asm__("D_L00_0015F798") __attribute__((sda)); +extern short D_L00_0015F79C; +extern short D_L00_0015F7A0_gp __asm__("D_L00_0015F7A0") __attribute__((sda)); +extern short D_L00_0015F7A4_gp __asm__("D_L00_0015F7A4") __attribute__((sda)); +extern short D_L00_0015F7A8_gp __asm__("D_L00_0015F7A8") __attribute__((sda)); +extern short D_L00_0015F7AC; +extern short D_L00_0015F7B0_gp __asm__("D_L00_0015F7B0") __attribute__((sda)); +extern short D_L00_0015F7B4; +extern short D_L00_0015F7B8; +extern short D_L00_0015F7BC_gp __asm__("D_L00_0015F7BC") __attribute__((sda)); extern short D_L00_0015F7C0_p __asm__("D_L00_0015F7C0"); -extern short D_L00_0015F7C4_p __asm__("D_L00_0015F7C4") __attribute__((sda)); +extern short D_L00_0015F7C4_gp __asm__("D_L00_0015F7C4") __attribute__((sda)); extern u32 strlen(const char *); -extern unsigned char D_00141EA0_p[] __asm__("D_00141EA0"); extern unsigned char D_L00_001C40B0_p[] __asm__("D_L00_001C40B0"); -extern void *D_L00_0015FAC0_v __asm__("D_L00_0015FAC0"); -extern unsigned char D_0013E520_b[] __asm__("D_0013E520"); +extern unsigned char D_0013E520[]; extern int D_L00_0015F5CC_i __asm__("D_L00_0015F5CC"); extern char D_L00_001C40B0_c[] __asm__("D_L00_001C40B0"); extern void FUN_L00_0023b120(char *, int, int, int, int, int); @@ -434,8 +432,8 @@ int FUN_L00_002382a0(HudElem_p *rec) { else if (fade < 0.0f) fade = 0.0f; { float phase, angle, radius; - phase = convert_integer_to_float_c2(D_L00_0015F5CC_i % GI(D_L00_0015F7B0_p)); - phase /= convert_integer_to_float_c2(GI(D_L00_0015F7B0_p)); + phase = convert_integer_to_float_c2(D_L00_0015F5CC_i % GI(D_L00_0015F7B0_gp)); + phase /= convert_integer_to_float_c2(GI(D_L00_0015F7B0_gp)); phase *= 6.28318f; angle = fast_sin(phase - 3.14159f); radius = open * 128.0f; @@ -459,51 +457,51 @@ int FUN_L00_002382a0(HudElem_p *rec) { for (i = 0; i < D_L00_0015FA90_p; i++) { angle = fast_add_rotations_c(((float)i + (float)i) * 3.1415927f / (float)D_L00_0015FA90_p - 3.1415927f, 1.5707964f); - icon_x = x + GI(D_L00_0015F720_p) + - (int)(GF(D_L00_0015F78C_p) * fast_cos(angle) * GF(D_L00_0015F7C4_p)); - icon_y = y + GI(D_L00_0015F724_p) + - (int)(GF(D_L00_0015F78C_p) * fast_sin(angle)); - if (rec->unk74 == i && ((E_238C30 **)D_L00_0015FAC0_v)[GI(D_L00_0015F72C_p)][i].id != 0) + icon_x = x + GI(D_L00_0015F720_gp) + + (int)(GF(D_L00_0015F78C_gp) * fast_cos(angle) * GF(D_L00_0015F7C4_gp)); + icon_y = y + GI(D_L00_0015F724_gp) + + (int)(GF(D_L00_0015F78C_gp) * fast_sin(angle)); + if (rec->unk74 == i && ((E_238C30 **)D_L00_0015FAC0)[GI(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_v)[GI(D_L00_0015F72C_p)][i].id != 0) { + if (((E_238C30 **)D_L00_0015FAC0)[GI(D_L00_0015F72C_gp)][i].id != 0) { int icon_alpha; if (i != rec->unk74) icon_alpha = truncate_float_to_s32_c2((float)alpha * GF(D_L00_0015F7C0_p)); else icon_alpha = alpha; - FUN_L00_0023b120((char *)rec, find_valid_animation_frame_index_alt(((E_238C30 **)D_L00_0015FAC0_v)[GI(D_L00_0015F72C_p)][i].id, - ((unsigned char *)D_0013E520_b)[((E_238C30 **)D_L00_0015FAC0_v)[GI(D_L00_0015F72C_p)][i].item] ? 4 : 0), icon_x, icon_y, 1, icon_alpha); + FUN_L00_0023b120((char *)rec, find_valid_animation_frame_index_alt(((E_238C30 **)D_L00_0015FAC0)[GI(D_L00_0015F72C_gp)][i].id, + ((unsigned char *)D_0013E520)[((E_238C30 **)D_L00_0015FAC0)[GI(D_L00_0015F72C_gp)][i].item] ? 4 : 0), icon_x, icon_y, 1, icon_alpha); } } selected = rec->unk74; - if (selected >= 0 && *(int *)(((char **)D_L00_0015FAC0_v)[GI(D_L00_0015F72C_p)] + selected * 0x1C) != 0) { - color = fast_tween_color_c(GI(D_L00_0015F798_p), GI(D_L00_0015F79C_p), open * fade); + if (selected >= 0 && *(int *)(((char **)D_L00_0015FAC0)[GI(D_L00_0015F72C_gp)] + selected * 0x1C) != 0) { + color = fast_tween_color_c(GI(D_L00_0015F798_gp), GI(D_L00_0015F79C), open * fade); { int id; - id = *(int *)((char *)D_00141EA0_r + selected * 4); + id = *(int *)((char *)D_00141EA0 + selected * 4); wr = D_L00_001C40B0_c + id * 24; if (*(unsigned short *)(wr + 8) != 0) { int shadow, item; - item = *(int *)(D_0013D428_p + id * 4); - sprintf(formatted, D_L00_0015F7C8_p, item, *(unsigned short *)(wr + 0xE)); + item = *(int *)(D_0013D428 + id * 4); + sprintf(formatted, D_L00_0015F7C8, item, *(unsigned short *)(wr + 0xE)); if (item != 0) - shadow = fast_tween_color_c(GI(D_L00_0015F7A8_p), GI(D_L00_0015F7AC_p), open * fade); + shadow = fast_tween_color_c(GI(D_L00_0015F7A8_gp), GI(D_L00_0015F7AC), open * fade); else - shadow = fast_tween_color_c(GI(D_L00_0015F7A0_p), GI(D_L00_0015F7A4_p), open * fade); - font_print_center(x + GI(D_L00_0015F720_p) + 1, y + GI(D_L00_0015F724_p) + 13, color, formatted, -1); - font_print_center(x + GI(D_L00_0015F720_p), y + GI(D_L00_0015F724_p) + 12, shadow, formatted, -1); + shadow = fast_tween_color_c(GI(D_L00_0015F7A0_gp), GI(D_L00_0015F7A4_gp), open * fade); + font_print_center(x + GI(D_L00_0015F720_gp) + 1, y + GI(D_L00_0015F724_gp) + 13, color, formatted, -1); + font_print_center(x + GI(D_L00_0015F720_gp), y + GI(D_L00_0015F724_gp) + 12, shadow, formatted, -1); } } prefix_length = 0; - shadow = fast_tween_color_c(GI(D_L00_0015F790_p), GI(D_L00_0015F794_p), open * fade); + shadow = fast_tween_color_c(GI(D_L00_0015F790_gp), GI(D_L00_0015F794_gp), open * fade); { int item, id; - item = *(int *)(((char **)D_L00_0015FAC0_v)[GI(D_L00_0015F72C_p)] + selected * 0x1C + 0x18); - if (((unsigned char *)D_0013E520_b)[item]) - id = ((TI_238C30 *)D_L00_00179AC0_p)[item].h48; + item = *(int *)(((char **)D_L00_0015FAC0)[GI(D_L00_0015F72C_gp)] + selected * 0x1C + 0x18); + if (((unsigned char *)D_0013E520)[item]) + id = ((TI_238C30 *)D_L00_00179AC0)[item].h48; else - id = ((TI_238C30 *)D_L00_00179AC0_p)[item].h46; + id = ((TI_238C30 *)D_L00_00179AC0)[item].h46; text = get_help_message_text(id); } if (text == 0) return rec->w; @@ -532,28 +530,28 @@ int FUN_L00_002382a0(HudElem_p *rec) { } } } - text_y = y + GI(D_L00_0015F724_p); + text_y = y + GI(D_L00_0015F724_gp); { int id; char *wr; - id = *(int *)((char *)D_00141EA0_r + selected * 4); + id = *(int *)((char *)D_00141EA0 + selected * 4); wr = D_L00_001C40B0_c + id * 24; if (*(unsigned short *)(wr + 8) != 0) - text_y += GI(D_L00_0015F7B4_p); + text_y += GI(D_L00_0015F7B4); else if (prefix_length != 0) - text_y += GI(D_L00_0015F7B8_p); + text_y += GI(D_L00_0015F7B8); else - text_y += GI(D_L00_0015F7BC_p); + text_y += GI(D_L00_0015F7BC_gp); } if (prefix_length != 0) { - font_print_center(x + GI(D_L00_0015F720_p) + 1, text_y + 1, color, (void *)text, prefix_length); - font_print_center(x + GI(D_L00_0015F720_p), text_y, shadow, (void *)text, prefix_length); + font_print_center(x + GI(D_L00_0015F720_gp) + 1, text_y + 1, color, (void *)text, prefix_length); + font_print_center(x + GI(D_L00_0015F720_gp), text_y, shadow, (void *)text, prefix_length); text_y += 16; - font_print_center(x + GI(D_L00_0015F720_p) + 1, text_y + 1, color, (void *)suffix, -1); - font_print_center(x + GI(D_L00_0015F720_p), text_y, shadow, (void *)suffix, -1); + font_print_center(x + GI(D_L00_0015F720_gp) + 1, text_y + 1, color, (void *)suffix, -1); + font_print_center(x + GI(D_L00_0015F720_gp), text_y, shadow, (void *)suffix, -1); } else { - font_print_center(x + GI(D_L00_0015F720_p) + 1, text_y + 1, color, (void *)text, -1); - font_print_center(x + GI(D_L00_0015F720_p), text_y, shadow, (void *)text, -1); + font_print_center(x + GI(D_L00_0015F720_gp) + 1, text_y + 1, color, (void *)text, -1); + font_print_center(x + GI(D_L00_0015F720_gp), text_y, shadow, (void *)text, -1); } } return rec->w; From c8f66386ccd2a1d331489b23e50853104380024a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Fri, 16 Oct 2026 23:17:02 +0000 Subject: [PATCH 10/33] chore: name more ported aliases by their labels --- src/overlays/l08/gameplay/entities/bomb.c | 84 +++++++++---------- src/overlays/l13/gameplay/entities/rocket.c | 27 +++--- .../shared/gameplay/entities/plasmabot.c | 73 ++++++++-------- 3 files changed, 88 insertions(+), 96 deletions(-) diff --git a/src/overlays/l08/gameplay/entities/bomb.c b/src/overlays/l08/gameplay/entities/bomb.c index 78d7407443..33586c7ce2 100644 --- a/src/overlays/l08/gameplay/entities/bomb.c +++ b/src/overlays/l08/gameplay/entities/bomb.c @@ -1513,25 +1513,23 @@ typedef struct { char pad0_p[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 Camera46_c D_L08_00167480_p __asm__("D_L08_00167480"); -extern f32 D_0015ED6C_p __asm__("D_0015ED6C"); -extern f32 D_0015ED70_p __asm__("D_0015ED70"); 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_p __asm__("D_L08_00161978") __attribute__((sda)); -extern float D_L08_0016197C_p __asm__("D_L08_0016197C") __attribute__((sda)); -extern float D_L08_00161988_p __asm__("D_L08_00161988") __attribute__((sda)); -extern float D_L08_0016198C_p __asm__("D_L08_0016198C") __attribute__((sda)); -extern float D_L08_00161990_p __asm__("D_L08_00161990") __attribute__((sda)); +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_p[] __asm__("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_p __asm__("D_L08_001619AC") __attribute__((sda)); -extern int D_L08_001619D0_p __asm__("D_L08_001619D0") __attribute__((sda)); +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 *); @@ -1550,16 +1548,14 @@ f32 compute_interpolated_record_value(void *anim) __asm__("FUN_0020c9e0"); s32 fun_00213928_c(void *obj, void *p, void *q, u32 flags, s32 *out, f32 *fp, s32 *kp, s32 idx) __asm__("FUN_00213928"); 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 char D_0013F350_p[] __asm__("D_0013F350"); -extern char D_001413D0_p[] __asm__("D_001413D0"); extern Hit_2D5FA8_c *find_2D5FA8_c(struct Moby *, int, int) __asm__("FUN_L00_0025a420"); -extern int damage_2D5FA8_c(struct Moby *, Hit_2D5FA8_c *, float *, int, int *, float *, int, int) __asm__("FUN_00213928"); -extern void animate_2D5FA8_c(struct Moby *, int, int, int) __asm__("FUN_00212f90"); +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 func_0020D830_x(struct Moby *) __asm__("FUN_0020c9e0"); +extern float FUN_0020c9e0(struct Moby *); extern void func_L00_002592B0_x(float, void *, void *, float, float, float) __asm__("FUN_L00_00258278"); extern Cam_DBF68 D_L08_00167500_c __asm__("D_L08_00167480"); @@ -1576,7 +1572,7 @@ void FUN_L08_002dabf0(struct Moby *moby) { struct Moby *old; damage = 0.0f; - func_L00_00264B40_x(moby, D_L08_001619AC_p, 3.0f, d->blk160); + func_L00_00264B40_x(moby, D_L08_001619AC_gp, 3.0f, d->blk160); if (moby->visible != 0) { if (fast_vec_dist(&moby->pos, D_L08_001675C0_p) < 29.0f) { FUN_L00_0025a120(moby); @@ -1589,13 +1585,13 @@ void FUN_L08_002dabf0(struct Moby *moby) { moby->flags |= 0x400; } if (moby->state == 100) { - float t = convert_integer_to_float_c(D_L08_001619D0_p); + float t = convert_integer_to_float_c(D_L08_001619D0_gp); int c = d->s132; - moby->alpha = func_001FA898_2D6C58((float)c + (float)-c * ((float)(D_L08_001619D0_p - d->s130) / t)); + moby->alpha = func_001FA898_2D6C58((float)c + (float)-c * ((float)(D_L08_001619D0_gp - d->s130) / t)); FUN_L04_002c46d0(moby); return; } - damage_2D5FA8_c(moby, find_2D5FA8_c(moby, 0x330000, 0), &d->health, 0, &hit, &damage, 0, 4); + FUN_00213928(moby, find_2D5FA8_c(moby, 0x330000, 0), &d->health, 0, &hit, &damage, 0, 4); if (hit != 1 && moby->state != 0x63) { moby->flags |= 0x1000; d->health -= damage; @@ -1604,13 +1600,13 @@ void FUN_L08_002dabf0(struct Moby *moby) { d->tint = 100; } else { char *base; - d->f80 = D_0015ED70_p * 30.0f; - d->f88 = D_0015ED6C_p * 5.0f; - d->f8C = D_0015ED6C_p * 7.0f; + d->f80 = frame_time_sq * 30.0f; + d->f88 = frame_time * 5.0f; + d->f8C = frame_time * 7.0f; d->i94 = 9; d->f84 = 0.0005f; d->bAD = 0; - base = ((char *)&D_0013F350_p); + base = ((char *)&D_0013F350); FUN_L00_0025c558(moby, d->blk70, fast_arc_tan_c2(moby->pos.x - *(float *)(base + 0x80), moby->pos.y - *(float *)(base + 0x84)), @@ -1624,11 +1620,11 @@ void FUN_L08_002dabf0(struct Moby *moby) { char *base; d->i94 = 9; d->f84 = 0.0005f; - d->f80 = D_0015ED70_p * 30.0f; - d->f88 = D_L08_0016198C_p * D_0015ED6C_p; - d->f8C = D_L08_00161990_p * D_0015ED6C_p; + d->f80 = frame_time_sq * 30.0f; + d->f88 = D_L08_0016198C_gp * frame_time; + d->f8C = D_L08_00161990_gp * frame_time; d->bAD = 0; - base = ((char *)&D_0013F350_p); + base = ((char *)&D_0013F350); FUN_L00_0025c558(moby, d->blk70, fast_arc_tan_c2(moby->pos.x - *(float *)(base + 0x80), moby->pos.y - *(float *)(base + 0x84)), @@ -1646,7 +1642,7 @@ void FUN_L08_002dabf0(struct Moby *moby) { moby->hit_slot = 0xFF; look.r44 = FUN_L08_0026a3d0(moby, 16.0f, &look); if (look.target == 0) { - look.target = *(struct Moby **)(((char *)&D_001413D0_p)); + look.target = *(struct Moby **)(((char *)&D_001413D0)); } target = look.target; switch (moby->state) { @@ -1660,7 +1656,7 @@ void FUN_L08_002dabf0(struct Moby *moby) { d->f10C = 0.03f; d->f110 = 0.3f; d->f114 = 0.25f; - d->fF4 = D_L08_00161978_p * D_0015ED6C_p; + d->fF4 = D_L08_00161978_gp * frame_time; d->b58 = func_001FA898_2D6C58(17.0f); d->b5A = func_001FA898_2D6C58(10.4f); clear_u64_value(d->v40); @@ -1668,7 +1664,7 @@ void FUN_L08_002dabf0(struct Moby *moby) { d->p120->command = 1; d->i128 = scale_game_frames_c2(0xB4); if (moby->prev_seq != 4) { - animate_2D5FA8_c(moby, 4, 0, 0); + FUN_00212f90(moby, 4, 0, 0); } moby->state = 1; d->i134 = scale_game_frames_c2(0xF0); @@ -1681,7 +1677,7 @@ void FUN_L08_002dabf0(struct Moby *moby) { d->p120->pos.y - moby->pos.y)) < 0.2617994f) { if (6.0f < vector_distance_xy_alt(&moby->pos, &target->pos)) { if (moby->prev_seq != 5) { - animate_2D5FA8_c(moby, 5, 0, 10); + FUN_00212f90(moby, 5, 0, 10); } moby->state = 6; break; @@ -1713,11 +1709,11 @@ void FUN_L08_002dabf0(struct Moby *moby) { case 6: FUN_L00_00259028((char *)moby, d->blkD0, (float *)&d->p120->pos, (char *)d->v40); if (moby->anim_flags & 2) { - animate_2D5FA8_c(d->p120, 1, 0, scale_game_frames_c2(6)); + FUN_00212f90(d->p120, 1, 0, scale_game_frames_c2(6)); qcopy(&moby->pos, &d->p120->pos); moby->pos.z -= 0.1f; if (moby->prev_seq != 1) { - animate_2D5FA8_c(moby, 1, 0, 10); + FUN_00212f90(moby, 1, 0, 10); } moby->state = 3; moby->flags &= 0xEFFF; @@ -1740,9 +1736,9 @@ void FUN_L08_002dabf0(struct Moby *moby) { break; } attack: - animate_2D5FA8_c(d->p120, 1, 0, scale_game_frames_c2(6)); + FUN_00212f90(d->p120, 1, 0, scale_game_frames_c2(6)); if (moby->prev_seq != 2) { - animate_2D5FA8_c(moby, 2, 0, scale_game_frames_c2(7)); + FUN_00212f90(moby, 2, 0, scale_game_frames_c2(7)); } moby->state = 4; moby->flags |= 0x1000; @@ -1769,13 +1765,13 @@ void FUN_L08_002dabf0(struct Moby *moby) { old->command = 0; d->p120->command = 1; if (moby->prev_seq != 4) { - animate_2D5FA8_c(moby, 4, 0, scale_game_frames_c2(7)); + FUN_00212f90(moby, 4, 0, scale_game_frames_c2(7)); } moby->state = 1; d->i134 = scale_game_frames_c2(0xF0); } else { if (moby->prev_seq != 3) { - animate_2D5FA8_c(moby, 3, 0, scale_game_frames_c2(6)); + FUN_00212f90(moby, 3, 0, scale_game_frames_c2(6)); } moby->state = 5; } @@ -1784,14 +1780,14 @@ void FUN_L08_002dabf0(struct Moby *moby) { case 5: func_L00_002592B0_x(fast_arc_tan_c2(target->pos.x - moby->pos.x, target->pos.y - moby->pos.y), moby, d->blk12C, 0.02f, 0.3f, 0.2f); - if (moby->seq == moby->prev_seq && func_0020D830_x(moby) == 19.0f) { + if (moby->seq == moby->prev_seq && FUN_0020c9e0(moby) == 19.0f) { float len, t; char *p; subtract_vector_xyz(v70, &target->pos, &moby->pos); v70[2] = 0.0f; len = fast_vec_length_c2(v70); - t = len / FUN_001f96b0(D_L08_0016197C_p); - len = len - (D_L08_00161988_p * t + 2.0f); + t = len / FUN_001f96b0(D_L08_0016197C_gp); + len = len - (D_L08_00161988_gp * t + 2.0f); if (10.0f < len) { len = 10.0f; } else if (len < 3.0f) { @@ -1802,7 +1798,7 @@ void FUN_L08_002dabf0(struct Moby *moby) { func_L00_00250800_2D6C58(moby, 9, v50); subtract_vector_xyz(v60, &target->pos, v50); set_vector_length_xy(v60, v60, t); - v60[2] = FUN_L00_0025abf0(v50, v70, &out, t, -(D_0015ED70_p * 15.0f)); + v60[2] = FUN_L00_0025abf0(v50, v70, &out, t, -(frame_time_sq * 15.0f)); p = FUN_L08_002d22e0_c((int)moby, (char *)v50, (char *)v60); d->p124 = (struct Moby *)p; if (p != 0) { @@ -1819,7 +1815,7 @@ void FUN_L08_002dabf0(struct Moby *moby) { if (moby->anim_flags & 2) { moby->state = 1; if (moby->prev_seq != 4) { - animate_2D5FA8_c(moby, 4, 0, 3); + FUN_00212f90(moby, 4, 0, 3); } d->i134 = scale_game_frames_c2(0xF0); } @@ -1827,7 +1823,7 @@ void FUN_L08_002dabf0(struct Moby *moby) { case 0x5B: if (moby->anim_flags & 2) { if (moby->prev_seq != 7) { - animate_2D5FA8_c(moby, 7, 0, 3); + FUN_00212f90(moby, 7, 0, 3); } moby->state = 0x5D; } @@ -1844,7 +1840,7 @@ void FUN_L08_002dabf0(struct Moby *moby) { d->p120->command = 1; } if (moby->prev_seq != 4) { - animate_2D5FA8_c(moby, 4, 0, 10); + FUN_00212f90(moby, 4, 0, 10); } moby->state = 1; d->i134 = scale_game_frames_c2(0xF0); @@ -1860,7 +1856,7 @@ void FUN_L08_002dabf0(struct Moby *moby) { moby->state = 100; moby->collision = 0; d->s132 = 0x28; - d->s130 = D_L08_001619D0_p; + d->s130 = D_L08_001619D0_gp; FUN_L04_002c46d0(moby); mark_moby_for_removal(moby); return; diff --git a/src/overlays/l13/gameplay/entities/rocket.c b/src/overlays/l13/gameplay/entities/rocket.c index f1268c2ce2..3cee62fa8f 100644 --- a/src/overlays/l13/gameplay/entities/rocket.c +++ b/src/overlays/l13/gameplay/entities/rocket.c @@ -805,19 +805,17 @@ 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 D_0015ED6C_p __asm__("D_0015ED6C"); -extern float D_0015ED70_p __asm__("D_0015ED70"); 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_p __asm__("D_L13_00161E70"); -extern int D_L13_00161E74_p __asm__("D_L13_00161E74") __attribute__((sda)); -extern int D_L13_00161E78_p __asm__("D_L13_00161E78") __attribute__((sda)); +extern int D_L13_00161E70; +extern int D_L13_00161E74_gp __asm__("D_L13_00161E74") __attribute__((sda)); +extern int D_L13_00161E78_gp __asm__("D_L13_00161E78") __attribute__((sda)); 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 short D_L13_00161E58_p __asm__("D_L13_00161E58") __attribute__((sda)); +extern short D_L13_00161E58_gp __asm__("D_L13_00161E58") __attribute__((sda)); 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"); @@ -835,7 +833,6 @@ 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_00161EE8_309330 __asm__("D_L13_00161E58") __attribute__((sda)); -extern int D_L13_00161F00_309330 __asm__("D_L13_00161E70"); extern float D_L13_00161F04_309330 __asm__("D_L13_00161E74") __attribute__((sda)); extern float D_L13_00161F08_309330 __asm__("D_L13_00161E78") __attribute__((sda)); extern void func_L00_002592B0_309330(struct Moby *, float, float *, float, float, float) __asm__("FUN_L13_00263fc8"); @@ -871,14 +868,14 @@ void FUN_L13_00307e98(struct Moby *moby) { vars->ctl.unkC = 0.5f; vars->ctl.unk0_p = func_001FA898_r(D_L13_00161EE8_309330 * 716.8f); vars->ctl.unk4 = D_L13_00161EE8_309330 * 0.7f; - vars->ctl.unk24 = D_L13_00161F08_309330 * D_0015ED6C_p * random_float_between(0.95f, 1.05f); + vars->ctl.unk24 = D_L13_00161F08_309330 * 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: FUN_L00_0025be00(&moby->rot.z, fast_arc_tan_c(target->pos.x - moby->pos.x, target->pos.y - moby->pos.y), - &vars->turn, D_0015ED70_p * 6.2831855f, D_0015ED70_p * 6.2831855f, D_0015ED6C_p * 3.1415927f); + &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_00161F04_309330 < dist) { @@ -924,7 +921,7 @@ void FUN_L13_00307e98(struct Moby *moby) { if (moby->prev_seq != 4) { blend_moby_animation_c(moby, 4, 0, scale_game_frames(20)); } - vars->timer = scale_game_frames(D_L13_00161F00_309330); + vars->timer = scale_game_frames(D_L13_00161E70); } else { moby->state = 1; if (moby->prev_seq != 0) { @@ -935,7 +932,7 @@ void FUN_L13_00307e98(struct Moby *moby) { break; 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, D_0015ED70_p * 6.2831855f, D_0015ED70_p * 6.2831855f, D_0015ED6C_p * 3.1415927f); + &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); @@ -957,7 +954,7 @@ void FUN_L13_00307e98(struct Moby *moby) { 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, D_0015ED70_p * 6.2831855f, D_0015ED70_p * 6.2831855f, D_0015ED6C_p * 3.1415927f); + &vars->turn, frame_time_sq * 6.2831855f, frame_time_sq * 6.2831855f, frame_time * 3.1415927f); FUN_L00_0024f7c8(moby, 0, &a); qcopy(&b, &moby->pos); b.f[2] += 0.3f; @@ -996,7 +993,7 @@ void FUN_L13_00307e98(struct Moby *moby) { 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, D_0015ED6C_p * 6.2831855f); + 0.05f, 0.3f, frame_time * 6.2831855f); a.f[0] = 2.0f * fast_cos(moby->rot.z); a.f[1] = 2.0f * fast_sin(moby->rot.z); a.f[2] = 0.0f; @@ -1036,7 +1033,7 @@ void FUN_L13_00307e98(struct Moby *moby) { near = 0; 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, - D_0015ED6C_p * 6.2831855f); + frame_time * 6.2831855f); a.f[0] = 2.0f * fast_cos(moby->rot.z); a.f[1] = 2.0f * fast_sin(moby->rot.z); a.f[2] = 0.0f; @@ -1090,7 +1087,7 @@ void FUN_L13_00307e98(struct Moby *moby) { 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, D_0015ED6C_p * 6.2831855f); + 0.3f, frame_time * 6.2831855f); a.f[0] = 2.0f * fast_cos(moby->rot.z); a.f[1] = 2.0f * fast_sin(moby->rot.z); a.f[2] = 0.0f; diff --git a/src/overlays/shared/gameplay/entities/plasmabot.c b/src/overlays/shared/gameplay/entities/plasmabot.c index ffde2a8e27..7942a7f6f9 100644 --- a/src/overlays/shared/gameplay/entities/plasmabot.c +++ b/src/overlays/shared/gameplay/entities/plasmabot.c @@ -330,12 +330,12 @@ struct Moby_00AC8_p { typedef struct Moby_00AC8_p Moby_00AC8_p; -extern char D_001413F4_p[] __asm__("D_001413F4"); -extern char D_L14_001FBB60_p[] __asm__("D_L14_001FBB60"); -extern char D_L14_001FBBA0_p[] __asm__("D_L14_001FBBA0"); -extern char D_L14_001FBBF8_p[] __asm__("D_L14_001FBBF8"); -extern char D_L14_001FBC38_p[] __asm__("D_L14_001FBC38"); -extern char D_L14_001FBC90_p[] __asm__("D_L14_001FBC90"); +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"); @@ -346,8 +346,7 @@ extern float D_0015ED70_p __asm__("D_0015ED70"); 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_001B0BB0_p[] __asm__("D_L14_001B0BB0"); -extern int D_L14_0015F5C4_p __asm__("D_L14_0015F5C4"); +extern int D_L14_0015F5C4; extern int FUN_001efa68(void *, void *, int, void *, void *); extern int FUN_001f9770(void *); extern int FUN_L00_0025c698(void *, void *); @@ -359,12 +358,12 @@ 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 short D_L14_001614E4_p __asm__("D_L14_001614E4") __attribute__((sda)); -extern short D_L14_001614E8_p __asm__("D_L14_001614E8") __attribute__((sda)); -extern short D_L14_001614EC_p __asm__("D_L14_001614EC") __attribute__((sda)); -extern short D_L14_001614F0_p __asm__("D_L14_001614F0"); -extern short D_L14_001614F4_p __asm__("D_L14_001614F4") __attribute__((sda)); -extern u8 D_L14_00174560_p[] __asm__("D_L14_00174560"); +extern short D_L14_001614E4_gp __asm__("D_L14_001614E4") __attribute__((sda)); +extern short D_L14_001614E8_gp __asm__("D_L14_001614E8") __attribute__((sda)); +extern short D_L14_001614EC_gp __asm__("D_L14_001614EC") __attribute__((sda)); +extern short D_L14_001614F0; +extern short 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); @@ -414,7 +413,7 @@ void FUN_L14_002b17d8(char *m) { owner = 0; FUN_L00_00263ac8(2.5f, m, 2, data + 0x120); if (*(int *)(data + 0x288) != 0) { - if (((unsigned char *)D_001413F4_p)[0] != 2) { + if (((unsigned char *)D_001413F4)[0] != 2) { *(unsigned short *)(m + 0x34) |= 0x41; *(int *)(m + 0x94) = 0; if (((unsigned char *)m)[0x53] == 5) { @@ -439,7 +438,7 @@ void FUN_L14_002b17d8(char *m) { FUN_L14_002b2ed8_c((struct Moby *)m); owner = *(char **)(data + 0x110); } - if (D_L14_0015F5C4_p == 2) { + if (D_L14_0015F5C4 == 2) { ((unsigned char *)m)[0x31] = 0; *(unsigned short *)(m + 0x34) |= 1; } else if (((unsigned char *)m)[0x20] != 1) { @@ -450,24 +449,24 @@ void FUN_L14_002b17d8(char *m) { case 0: { if (((unsigned char *)data)[0x24A] != 0) { if (*(int *)(data + 0x240) == -1) { - DebugPrint(D_L14_001FBB60_p, *(short *)(m + 0xB2)); + DebugPrint(D_L14_001FBB60, *(short *)(m + 0xB2)); { call_D678(m); return; } } - if (*D_L14_001B0BB0_p[*(int *)(data + 0x240)] == 0) { - DebugPrint(D_L14_001FBBA0_p, *(short *)(m + 0xB2)); + if (*D_L14_001B0BB0[*(int *)(data + 0x240)] == 0) { + DebugPrint(D_L14_001FBBA0, *(short *)(m + 0xB2)); { call_D678(m); return; } } } if (*(int *)(data + 0x244) == -1) { - DebugPrint(D_L14_001FBBF8_p, *(short *)(m + 0xB2)); + DebugPrint(D_L14_001FBBF8, *(short *)(m + 0xB2)); { call_D678(m); return; } } - if (*D_L14_001B0BB0_p[*(int *)(data + 0x244)] == 0) { - DebugPrint(D_L14_001FBC38_p, *(short *)(m + 0xB2)); + if (*D_L14_001B0BB0[*(int *)(data + 0x244)] == 0) { + DebugPrint(D_L14_001FBC38, *(short *)(m + 0xB2)); { call_D678(m); return; } } if (((unsigned char *)data)[0x24A] != 0 && *(int *)(data + 0x264) < 0) { - DebugPrint(D_L14_001FBC90_p, *(short *)(m + 0xB2)); + DebugPrint(D_L14_001FBC90, *(short *)(m + 0xB2)); { call_D678(m); return; } } if (random_integer_below(2) != 0) { @@ -475,7 +474,7 @@ void FUN_L14_002b17d8(char *m) { } FUN_L14_002b3358_c(m); if (*(int *)(data + 0x240) != -1) { - qcopy(m + 0x10, (char *)D_L14_001B0BB0_p[*(int *)(data + 0x240)] + 0x10); + qcopy(m + 0x10, (char *)D_L14_001B0BB0[*(int *)(data + 0x240)] + 0x10); } data[0x28] = 1; data[0x29] = 0; @@ -519,11 +518,11 @@ void FUN_L14_002b17d8(char *m) { if (FUN_001f9770(data + 0x248) == 0) return; if (FUN_L14_002d9870_c(*(int *)(data + 0x264)) == 0) return; if (call_4BF0(m) == 0) return; - *(short *)(data + 0x248) = scale_game_frames(*(int *)&D_L14_001614F0_p); + *(short *)(data + 0x248) = scale_game_frames(*(int *)&D_L14_001614F0); FUN_L14_002b3330_c(m); ((unsigned char *)m)[0x20] = 2; set_moby_animation_alt(m, 1, 0); - p = (float *)D_L14_001B0BB0_p[*(int *)(data + 0x240)]; + p = (float *)D_L14_001B0BB0[*(int *)(data + 0x240)]; *(float *)(m + 0x48) = fast_arc_tan_c(p[8] - p[4], p[9] - p[5]); *(int *)(data + 0x268) = 0; *(float *)(data + 0x27C) = 1.0f; @@ -548,7 +547,7 @@ void FUN_L14_002b17d8(char *m) { } break; case 9: { - float *p = (float *)D_L14_001B0BB0_p[*(int *)(data + 0x240)]; + float *p = (float *)D_L14_001B0BB0[*(int *)(data + 0x240)]; FUN_L00_0025b8c0((float *)(m + 0x10), (float *)(data + 0x254), p[4], 0.01f, 0.2f, 0.0f); FUN_L00_0025b8c0((float *)(m + 0x14), (float *)(data + 0x258), p[5], 0.01f, 0.2f, 0.0f); if ((m[0x70] & 2) && ((unsigned char *)m)[0x52] == ((unsigned char *)m)[0x53]) { @@ -595,7 +594,7 @@ void FUN_L14_002b17d8(char *m) { blend_moby_animation(m, 2, 0, scale_game_frames(10)); ((unsigned char *)m)[0x20] = 9; } else { - *(short *)(data + 0x248) = scale_game_frames(*(int *)&D_L14_001614F0_p); + *(short *)(data + 0x248) = scale_game_frames(*(int *)&D_L14_001614F0); ((unsigned char *)m)[0x20] = 0xD; } } @@ -621,7 +620,7 @@ void FUN_L14_002b17d8(char *m) { int n = *(int *)(data + 0x24C) - 1; char *pe; *(int *)(data + 0x24C) = n; - pe = (char *)D_L14_001B0BB0_p[*(int *)(data + 0x240)]; + pe = (char *)D_L14_001B0BB0[*(int *)(data + 0x240)]; *(float *)(data + 0x250) = *(float *)(pe + (n << 4) + 0x1C); } *(float *)(data + 0x27C) = -1.0f; @@ -640,14 +639,14 @@ void FUN_L14_002b17d8(char *m) { *(float *)(data + 0x278) = ang; ((unsigned char *)m)[0x20] = 5; blend_moby_animation(m, 4, 0, scale_game_frames(5)); - *(short *)(data + 0x262) = scale_game_frames(*(int *)&D_L14_001614EC_p); + *(short *)(data + 0x262) = scale_game_frames(*(int *)&D_L14_001614EC_gp); break; } case 5: { float ang; ang = fast_arc_tan_c(*(float *)(owner + 0x10) - *(float *)(m + 0x10), *(float *)(owner + 0x14) - *(float *)(m + 0x14)); - FUN_L14_002b35d8_c(m, 0, fast_subtract_rotations_c2(ang, *(float *)&D_L14_001614E8_p)); + FUN_L14_002b35d8_c(m, 0, fast_subtract_rotations_c2(ang, *(float *)&D_L14_001614E8_gp)); FUN_L14_002b37b0_c(m, ang); if ((m[0x70] & 2) && ((unsigned char *)m)[0x52] == ((unsigned char *)m)[0x53]) { blend_moby_animation(m, 5, 0, scale_game_frames(10)); @@ -665,8 +664,8 @@ void FUN_L14_002b17d8(char *m) { ang = fast_arc_tan_c(*(float *)(owner + 0x10) - *(float *)(m + 0x10), *(float *)(owner + 0x14) - *(float *)(m + 0x14)); t = convert_integer_to_float(*(short *)(data + 0x262)); - t = t / convert_integer_to_float(scale_game_frames(*(int *)&D_L14_001614EC_p)); - c = *(float *)&D_L14_001614E8_p; + t = t / convert_integer_to_float(scale_game_frames(*(int *)&D_L14_001614EC_gp)); + c = *(float *)&D_L14_001614E8_gp; f = fast_subtract_rotations_c2(*(float *)(data + 0x278), -c + (c + c) * t); if (((unsigned char *)data)[0x24B] != 0) { if (*(float *)(owner + 0x18) + 0.1f - *(float *)(m + 0x18) < 0.0f) { @@ -680,9 +679,9 @@ void FUN_L14_002b17d8(char *m) { if (flag == 0) { v[2] = 0.0f; } - fast_vec_normalize(v, v, *(float *)&D_L14_001614E4_p); + fast_vec_normalize(v, v, *(float *)&D_L14_001614E4_gp); add_vector_xyz_c3(hit, mat[3], v); - fast_vec_normalize(v, v, *(float *)&D_L14_001614F4_p); + fast_vec_normalize(v, v, *(float *)&D_L14_001614F4_gp); add_vector_xyz_c3(mat[3], mat[3], v); ray.moby = m; ray.flags = 0x10001; @@ -696,7 +695,7 @@ void FUN_L14_002b17d8(char *m) { ray.cls = *(unsigned short *)(m + 0xA6); ray.b98 = 0; if (FUN_001efa68(mat[3], hit, 0, m, &ray) != 0) { - qcopy(hit, D_L14_00174560_p); + qcopy(hit, D_L14_00174560); } FUN_L00_002e2190(m, mat, hit); if (FUN_001f9770(data + 0x262) != 0) { @@ -732,7 +731,7 @@ void FUN_L14_002b17d8(char *m) { FUN_L00_0024f7c8(m, 2, mat); FUN_L14_002dea98_c(m, (char *)mat); call_F4A8(m, data + 0x40, m + 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_p)[0] == 2) { + if (((unsigned char *)D_001413F4)[0] == 2) { FUN_L00_00257470(m, 0x200, -1); { call_D678(m); return; } } From 228c18a108585d9b75bc6ce93c8c234f7596a985 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Fri, 16 Oct 2026 23:22:25 +0000 Subject: [PATCH 11/33] chore: one name for the boot animation and hit helpers in three units --- src/overlays/l08/gameplay/entities/bomb.c | 3 +- src/overlays/l13/gameplay/entities/rocket.c | 43 +++++++++---------- .../shared/gameplay/entities/plasmabot.c | 19 ++++---- 3 files changed, 31 insertions(+), 34 deletions(-) diff --git a/src/overlays/l08/gameplay/entities/bomb.c b/src/overlays/l08/gameplay/entities/bomb.c index 33586c7ce2..64d5ca9139 100644 --- a/src/overlays/l08/gameplay/entities/bomb.c +++ b/src/overlays/l08/gameplay/entities/bomb.c @@ -720,7 +720,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"); @@ -1545,7 +1545,6 @@ 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"); -s32 fun_00213928_c(void *obj, void *p, void *q, u32 flags, s32 *out, f32 *fp, s32 *kp, s32 idx) __asm__("FUN_00213928"); 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"); diff --git a/src/overlays/l13/gameplay/entities/rocket.c b/src/overlays/l13/gameplay/entities/rocket.c index 3cee62fa8f..0da62bcb92 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"); @@ -828,7 +828,6 @@ 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 blend_moby_animation_c(void *, s32, s32, s32) __asm__("FUN_00212f90"); 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"); @@ -883,24 +882,24 @@ void FUN_L13_00307e98(struct Moby *moby) { target->pos.y - moby->pos.y)) < 0.2617994f) { moby->state = 2; if (moby->prev_seq != 3) { - blend_moby_animation_c(moby, 3, 0, scale_game_frames(10)); + blend_moby_animation(moby, 3, 0, scale_game_frames(10)); } } else { moby->state = 7; if (moby->prev_seq != 1) { - blend_moby_animation_c(moby, 1, 0, scale_game_frames(20)); + blend_moby_animation(moby, 1, 0, scale_game_frames(20)); } } } else { moby->state = 5; if (moby->prev_seq != 6) { - blend_moby_animation_c(moby, 6, 0, scale_game_frames(10)); + 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_c(moby, 1, 0, scale_game_frames(20)); + blend_moby_animation(moby, 1, 0, scale_game_frames(20)); } } break; @@ -909,7 +908,7 @@ void FUN_L13_00307e98(struct Moby *moby) { moby->state = 3; FUN_L13_00309370_c((char *)moby); if (moby->prev_seq != 5) { - blend_moby_animation_c(moby, 5, 0, scale_game_frames(10)); + blend_moby_animation(moby, 5, 0, scale_game_frames(10)); } } break; @@ -919,13 +918,13 @@ void FUN_L13_00307e98(struct Moby *moby) { if (vars->unk164 != 2 && dist < 15.0f) { moby->state = 4; if (moby->prev_seq != 4) { - blend_moby_animation_c(moby, 4, 0, scale_game_frames(20)); + 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_c(moby, 0, 0, scale_game_frames(20)); + blend_moby_animation(moby, 0, 0, scale_game_frames(20)); } } } @@ -937,18 +936,18 @@ void FUN_L13_00307e98(struct Moby *moby) { moby->state = 3; FUN_L13_00309370_c((char *)moby); if (moby->prev_seq != 5) { - blend_moby_animation_c(moby, 5, 0, scale_game_frames(5)); + blend_moby_animation(moby, 5, 0, scale_game_frames(5)); } } else if (vector_distance_xy_alt(&moby->pos, &target->pos) < D_L13_00161F04_309330) { FUN_L00_0024f7c8(moby, 0, &vars->unk1E0); moby->state = 5; if (moby->prev_seq != 6) { - blend_moby_animation_c(moby, 6, 0, scale_game_frames(10)); + 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_c(moby, 1, 0, scale_game_frames(20)); + blend_moby_animation(moby, 1, 0, scale_game_frames(20)); } } break; @@ -977,7 +976,7 @@ void FUN_L13_00307e98(struct Moby *moby) { moby->state = 6; moby->command = 1; if (moby->prev_seq != 2) { - blend_moby_animation_c(moby, 2, 0, scale_game_frames(10)); + blend_moby_animation(moby, 2, 0, scale_game_frames(10)); } } break; @@ -985,7 +984,7 @@ void FUN_L13_00307e98(struct Moby *moby) { if (moby->anim_flags & 2) { moby->state = moby->command; if (moby->prev_seq != 0) { - blend_moby_animation_c(moby, 0, 0, scale_game_frames(20)); + blend_moby_animation(moby, 0, 0, scale_game_frames(20)); } } break; @@ -1014,17 +1013,17 @@ void FUN_L13_00307e98(struct Moby *moby) { if (dist < 15.0f) { moby->state = 2; if (moby->prev_seq != 3) { - blend_moby_animation_c(moby, 3, 0, scale_game_frames(10)); + blend_moby_animation(moby, 3, 0, scale_game_frames(10)); } } else if (close != 0) { moby->state = 2; if (moby->prev_seq != 3) { - blend_moby_animation_c(moby, 3, 0, scale_game_frames(10)); + blend_moby_animation(moby, 3, 0, scale_game_frames(10)); } } else if (dist < D_L13_00161F04_309330) { moby->state = 5; if (moby->prev_seq != 6) { - blend_moby_animation_c(moby, 6, 0, scale_game_frames(10)); + blend_moby_animation(moby, 6, 0, scale_game_frames(10)); } } } @@ -1048,13 +1047,13 @@ void FUN_L13_00307e98(struct Moby *moby) { } else if (near != 0) { moby->state = 12; if (moby->prev_seq != 6) { - blend_moby_animation_c(moby, 6, 0, scale_game_frames(10)); + blend_moby_animation(moby, 6, 0, scale_game_frames(10)); } } else if (vector_distance_xy_alt(&moby->pos, &target->pos) < D_L13_00161F04_309330) { FUN_L00_0024f7c8(moby, 0, &vars->unk1E0); moby->state = 12; if (moby->prev_seq != 6) { - blend_moby_animation_c(moby, 6, 0, scale_game_frames(10)); + blend_moby_animation(moby, 6, 0, scale_game_frames(10)); } } break; @@ -1080,7 +1079,7 @@ void FUN_L13_00307e98(struct Moby *moby) { if (moby->anim_flags & 2) { moby->state = 11; if (moby->prev_seq != 1) { - blend_moby_animation_c(moby, 1, 0, scale_game_frames(20)); + blend_moby_animation(moby, 1, 0, scale_game_frames(20)); } } break; @@ -1099,7 +1098,7 @@ void FUN_L13_00307e98(struct Moby *moby) { if (fast_vec_dist(&vars->home, &moby->pos) < 1.0f) { moby->state = 1; if (moby->prev_seq != 0) { - blend_moby_animation_c(moby, 0, 0, scale_game_frames(20)); + blend_moby_animation(moby, 0, 0, scale_game_frames(20)); } } break; @@ -1109,7 +1108,7 @@ void FUN_L13_00307e98(struct Moby *moby) { qzero(&vars->vel); moby->state = 1; if (moby->prev_seq != 0) { - blend_moby_animation_c(moby, 0, 0, scale_game_frames(10)); + blend_moby_animation(moby, 0, 0, scale_game_frames(10)); } } else if (hit & 0x120) { mark_moby_for_removal_c2(moby); diff --git a/src/overlays/shared/gameplay/entities/plasmabot.c b/src/overlays/shared/gameplay/entities/plasmabot.c index 7942a7f6f9..ce2f0c15fc 100644 --- a/src/overlays/shared/gameplay/entities/plasmabot.c +++ b/src/overlays/shared/gameplay/entities/plasmabot.c @@ -374,7 +374,7 @@ 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_alt(void *, int, int) __asm__("FUN_00212ed8"); +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 x_p) __asm__("FUN_L14_002b35d8"); int FUN_L14_002b3418_c(char *moby) __asm__("FUN_L14_002b3418"); @@ -521,7 +521,7 @@ void FUN_L14_002b17d8(char *m) { *(short *)(data + 0x248) = scale_game_frames(*(int *)&D_L14_001614F0); FUN_L14_002b3330_c(m); ((unsigned char *)m)[0x20] = 2; - set_moby_animation_alt(m, 1, 0); + set_moby_animation(m, 1, 0); p = (float *)D_L14_001B0BB0[*(int *)(data + 0x240)]; *(float *)(m + 0x48) = fast_arc_tan_c(p[8] - p[4], p[9] - p[5]); *(int *)(data + 0x268) = 0; @@ -1338,7 +1338,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; @@ -1357,18 +1356,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; @@ -1377,19 +1376,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; } @@ -1414,7 +1413,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); From daacdec0fe08b24eb86b34be6d14066952171b7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Sat, 17 Oct 2026 06:54:38 +0000 Subject: [PATCH 12/33] chore: one name and type per global in the ported units Ported aliases take the header or main declaration of their label, with a cast at the use where the port read it as another type. Also names the map archive state fields from the main draft and the L08 bomb throw locals. --- .../gameplay/entities/veldin_robot_enemy.c | 6 +- src/overlays/l03/gameplay/entities/taxi.c | 24 +- .../l04/gameplay/entities/big_axebot.c | 5 +- src/overlays/l04/runtime/dma/002922d0.c | 5 +- .../l05/gameplay/entities/sharkigator.c | 6 +- src/overlays/l05/gameplay/hero/00239fc0.c | 5 +- src/overlays/l06/gameplay/entities/fred.c | 14 +- .../l07/gameplay/entities/taxi_platform.c | 30 ++- .../l08/gameplay/entities/bolt_thief.c | 27 +-- src/overlays/l08/gameplay/entities/bomb.c | 90 ++++---- src/overlays/l10/gameplay/entities/platform.c | 11 +- src/overlays/l10/gameplay/entities/screamer.c | 59 +++-- src/overlays/l12/gameplay/entities/003054b0.c | 22 +- src/overlays/l12/gameplay/entities/platform.c | 9 +- src/overlays/l13/gameplay/entities/elevator.c | 6 +- .../entities/qwarks_starfighter_part.c | 4 +- src/overlays/l13/gameplay/entities/rocket.c | 13 +- src/overlays/l14/gameplay/entities/platform.c | 5 +- .../l16/gameplay/entities/grindrail_gate.c | 56 +++-- src/overlays/l16/gameplay/entities/rocket.c | 4 +- src/overlays/l16/gameplay/hero/002097a0.c | 5 +- .../l17/gameplay/entities/blarg_ship.c | 4 +- src/overlays/l18/gameplay/entities/rocket.c | 4 +- src/overlays/shared/audio/voices/00276368.c | 8 +- .../gameplay/camera/follow_camera_setup.c | 10 +- .../shared/gameplay/entities/00264e40.c | 12 +- .../shared/gameplay/entities/00295100.c | 22 +- .../gameplay/entities/blarg_elite_commando.c | 11 +- .../gameplay/entities/blarg_space_commando.c | 4 +- src/overlays/shared/gameplay/entities/bomb.c | 9 +- .../shared/gameplay/entities/camera_object.c | 4 +- .../entities/gadgebot_spawn_container.c | 8 +- .../shared/gameplay/entities/nanotech_ball.c | 38 ++-- .../shared/gameplay/entities/plasmabot.c | 10 +- src/overlays/shared/gameplay/entities/rock.c | 4 +- .../shared/gameplay/entities/sandmouse.c | 37 ++-- .../shared/gameplay/entities/sentrybot.c | 4 +- .../gameplay/entities/trackdrive_left.c | 4 +- .../shared/gameplay/entities/trespasser.c | 6 +- .../shared/gameplay/entities/veldin_ship.c | 24 +- .../shared/gameplay/entities/walloper.c | 40 ++-- .../shared/gameplay/hero/hero_check_damage.c | 46 ++-- .../shared/gameplay/hero/hero_idle_sequence.c | 14 +- .../shared/gameplay/hero/hero_set_state.c | 10 +- src/overlays/shared/rendering/00245c28.c | 155 +++++++------ src/overlays/shared/rendering/002712b8.c | 4 +- .../shared/rendering/debug/001f36f8.c | 8 +- src/overlays/shared/ui/help/001ff938.c | 10 +- src/overlays/shared/ui/help/0021d0a0.c | 4 +- src/overlays/shared/ui/help/00237488.c | 208 +++++++++--------- src/overlays/shared/ui/map/0024e7a8.c | 4 +- src/overlays/shared/ui/text/002377b8.c | 11 +- 52 files changed, 557 insertions(+), 586 deletions(-) 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..26e2163c61 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) { @@ -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..55b54c12ff 100644 --- a/src/overlays/l05/gameplay/entities/sharkigator.c +++ b/src/overlays/l05/gameplay/entities/sharkigator.c @@ -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); 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..6379c56181 100644 --- a/src/overlays/l06/gameplay/entities/fred.c +++ b/src/overlays/l06/gameplay/entities/fred.c @@ -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 { diff --git a/src/overlays/l07/gameplay/entities/taxi_platform.c b/src/overlays/l07/gameplay/entities/taxi_platform.c index d394b8d8a2..03a656b470 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) { @@ -2613,7 +2612,6 @@ extern char D_L07_00211838[]; 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 D_0015ED60_p __asm__("D_0015ED60"); 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_p __asm__("D_L07_0015F5CC"); @@ -2650,7 +2648,6 @@ 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_p *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_001413D0_p[] __asm__("D_001413D0"); 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"); @@ -2777,14 +2774,14 @@ void FUN_L07_0030f5f0(unsigned char *moby) { if ((moby[0x70] & 2) && moby[0x53] != 0) { blend_moby_animation(moby, 0, 0, 10); } - if (inside && tgt.moby != 0 && tgt.moby == *(int *)(((char *)&D_001413D0_p)) && + if (inside && tgt.moby != 0 && tgt.moby == *(int *)(((char *)((char *)&D_001413D0))) && !FUN_L07_0030f540_c(moby, 4, 6)) { if (moby[0x53] != 1) { blend_moby_animation(moby, 1, 0, 10); } moby[0x20] = 4; } - if (tgt.moby != 0 && tgt.moby == *(int *)(((char *)&D_001413D0_p)) && + if (tgt.moby != 0 && tgt.moby == *(int *)(((char *)((char *)&D_001413D0))) && FUN_L07_0030f4d0_c(moby, tgt.moby, 1.5f)) { if (moby[0x53] != 2) { blend_moby_animation(moby, 2, 0, 2); @@ -2798,7 +2795,7 @@ void FUN_L07_0030f5f0(unsigned char *moby) { F(data, 0x13C) = random_angle_radians_c2(); moby[0x20] = 2; } - fast_vec_scale_c(data + 0xD0, data + 0xD0, D_0015ED60_p * (0.95f - 1.0f) + 1.0f); + 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 != 0xFF) { if (moby[0x53] != anim) { @@ -2811,7 +2808,7 @@ void FUN_L07_0030f5f0(unsigned char *moby) { if ((moby[0x70] & 2) && moby[0x53] != 1) { blend_moby_animation(moby, 1, 0, 10); } - if (inside && tgt.moby != 0 && tgt.moby == *(int *)(((char *)&D_001413D0_p))) { + if (inside && tgt.moby != 0 && tgt.moby == *(int *)(((char *)((char *)&D_001413D0)))) { if (!FUN_L07_0030f540_c(moby, 4, 6)) { if (moby[0x53] != 1) { blend_moby_animation(moby, 1, 0, 10); @@ -2843,7 +2840,7 @@ void FUN_L07_0030f5f0(unsigned char *moby) { *(int *)(data + 0x134) = rand() % 120 + 60; moby[0x20] = 1; } - if (tgt.moby != 0 && tgt.moby == *(int *)(((char *)&D_001413D0_p)) && + if (tgt.moby != 0 && tgt.moby == *(int *)(((char *)((char *)&D_001413D0))) && FUN_L07_0030f4d0_c(moby, tgt.moby, 1.5f)) { if (moby[0x53] != 2) { blend_moby_animation(moby, 2, 0, 2); @@ -2876,7 +2873,7 @@ void FUN_L07_0030f5f0(unsigned char *moby) { close = 0; } if (close) { - fast_vec_scale_c(data + 0xD0, data + 0xD0, D_0015ED60_p * (0.9f - 1.0f) + 1.0f); + fast_vec_scale_c(data + 0xD0, data + 0xD0, frame_scale * (0.9f - 1.0f) + 1.0f); } if (FUN_L07_0030f1e0_c((char *)moby, data, ang, 0.209439516f, frame_time_sq * 20.0f, 0.52359879f, frame_time_sq * three, frame_time * 20.0f, frame_time * 5.0f) && @@ -2917,7 +2914,7 @@ void FUN_L07_0030f5f0(unsigned char *moby) { ang = fast_arc_tan_c2(tgt.pos[0] - pos[0], tgt.pos[1] - pos[1]); func_L00_002592B0_t((char *)moby, ang, (float *)(data + 0x120), frame_time_sq * 12.566371f, frame_time_sq * 0.0f, frame_time * 12.566371f); - F(moby, 0x44) *= D_0015ED60_p * 0.7f; + F(moby, 0x44) *= frame_scale * 0.7f; F(data, 0x14C) += 0.028f; qcopy(old, mpos); subtract_vector_xyz(rel, &tgt, off); @@ -2986,7 +2983,7 @@ void FUN_L07_0030f5f0(unsigned char *moby) { F(data, 0x13C) = random_angle_radians_c2(); moby[0x20] = 8; } - fast_vec_scale_c(data + 0xD0, data + 0xD0, D_0015ED60_p * (0.95f - 1.0f) + 1.0f); + 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); @@ -3108,7 +3105,7 @@ void FUN_L07_0030f5f0(unsigned char *moby) { } goto end; case 16: - fast_vec_scale_c(data + 0xD0, data + 0xD0, D_0015ED60_p * (0.95f - 1.0f) + 1.0f); + 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) { @@ -3116,7 +3113,7 @@ void FUN_L07_0030f5f0(unsigned char *moby) { } goto end; case 15: - fast_vec_scale_c(data + 0xD0, data + 0xD0, D_0015ED60_p * (0.95f - 1.0f) + 1.0f); + 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 != 0xFF) { @@ -3127,7 +3124,7 @@ void FUN_L07_0030f5f0(unsigned char *moby) { } goto end; case 17: - fast_vec_scale_c(data + 0xD0, data + 0xD0, D_0015ED60_p * (0.95f - 1.0f) + 1.0f); + 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); } @@ -3164,7 +3161,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); @@ -3211,7 +3207,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 538c402c43..2cf0d4e4c1 100644 --- a/src/overlays/l08/gameplay/entities/bolt_thief.c +++ b/src/overlays/l08/gameplay/entities/bolt_thief.c @@ -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); @@ -2011,7 +2009,6 @@ float absolute_float(float input) __asm__("func_001F99C0"); int FUN_L00_00239df8(HudElem *m); void FUN_L00_00239cc8(HudElem *e); void FUN_L00_00239d00(void *o); -extern char D_0013F350_p[] __asm__("D_0013F350"); extern char D_0013F3D0[]; extern char D_0013F490[]; extern void func_L00_0023A658_4BE8(void) __asm__("FUN_L08_002444a8"); @@ -2092,8 +2089,8 @@ void FUN_L08_002e3870(struct Moby *m) { break; } } - if (absolute_float(m->pos.z - ((Hero *)(((char *)&D_0013F350_p)))->motion.pos.f[2]) < ((Hero *)(((char *)&D_0013F350_p)))->reach_distance - && vector_distance_xy_alt(&m->pos, ((Hero *)(((char *)&D_0013F350_p)))->motion.pos.f) < ((Hero *)(((char *)&D_0013F350_p)))->reach_height) { + if (absolute_float(m->pos.z - ((Hero *)(((char *)((char *)&hero))))->motion.pos.f[2]) < ((Hero *)(((char *)((char *)&hero))))->reach_distance + && vector_distance_xy_alt(&m->pos, ((Hero *)(((char *)((char *)&hero))))->motion.pos.f) < ((Hero *)(((char *)((char *)&hero))))->reach_height) { d->i68 = scale_game_frames_c(1); m->state = 2; } @@ -2174,8 +2171,8 @@ void FUN_L08_002e3870(struct Moby *m) { FUN_L00_0025bc00(&d->f60, t, 0.5235988f, 0); } else { - float t = fast_add_rotations_c4(fast_arc_tan(((Hero *)(((char *)&D_0013F350_p)))->motion.pos.f[0] - m->pos.x, - ((Hero *)(((char *)&D_0013F350_p)))->motion.pos.f[1] - m->pos.y), + float t = fast_add_rotations_c4(fast_arc_tan(((Hero *)(((char *)((char *)&hero))))->motion.pos.f[0] - m->pos.x, + ((Hero *)(((char *)((char *)&hero))))->motion.pos.f[1] - m->pos.y), 1.5707964f); FUN_L00_0025bc00(&d->f60, t, 0.08726646f, 0); @@ -2332,10 +2329,10 @@ void FUN_L08_002e3870(struct Moby *m) { mark_moby_for_removal_c3(m); return; } - if (m->pos.z < d->f60 - 4.0f && m->pos.z < ((Hero *)(((char *)&D_0013F350_p)))->motion.pos.f[2] - 4.0f) { + if (m->pos.z < d->f60 - 4.0f && m->pos.z < ((Hero *)(((char *)((char *)&hero))))->motion.pos.f[2] - 4.0f) { Vars_4BE8 *e = (Vars_4BE8 *)m->pvars; - *(u128_4BE8_p *)e->v10 = *(u128_4BE8_p *)((char *)&D_0013F350_p + 0x90); + *(u128_4BE8_p *)e->v10 = *(u128_4BE8_p *)((char *)((char *)&hero) + 0x90); e->i68 = scale_game_frames_c(1); m->state = 2; break; @@ -2379,8 +2376,8 @@ void FUN_L08_002e3870(struct Moby *m) { m->state = 5; d->i68 = n; d->u7C.i = D_L08_00174658_lui; - if (absolute_float(m->pos.z - ((Hero *)(((char *)&D_0013F350_p)))->motion.pos.f[2]) < ((Hero *)(((char *)&D_0013F350_p)))->reach_distance - && vector_distance_xy_alt(&m->pos, ((Hero *)(((char *)&D_0013F350_p)))->motion.pos.f) < ((Hero *)(((char *)&D_0013F350_p)))->reach_height) { + if (absolute_float(m->pos.z - ((Hero *)(((char *)((char *)&hero))))->motion.pos.f[2]) < ((Hero *)(((char *)((char *)&hero))))->reach_distance + && vector_distance_xy_alt(&m->pos, ((Hero *)(((char *)((char *)&hero))))->motion.pos.f) < ((Hero *)(((char *)((char *)&hero))))->reach_height) { Vars_4BE8 *e = (Vars_4BE8 *)m->pvars; e->i68 = scale_game_frames_c(1); @@ -2402,8 +2399,8 @@ void FUN_L08_002e3870(struct Moby *m) { int n; float inv; - if (absolute_float(m->pos.z - ((Hero *)(((char *)&D_0013F350_p)))->motion.pos.f[2]) < ((Hero *)(((char *)&D_0013F350_p)))->reach_distance - && vector_distance_xy_alt(&m->pos, ((Hero *)(((char *)&D_0013F350_p)))->motion.pos.f) < ((Hero *)(((char *)&D_0013F350_p)))->reach_height) { + if (absolute_float(m->pos.z - ((Hero *)(((char *)((char *)&hero))))->motion.pos.f[2]) < ((Hero *)(((char *)((char *)&hero))))->reach_distance + && vector_distance_xy_alt(&m->pos, ((Hero *)(((char *)((char *)&hero))))->motion.pos.f) < ((Hero *)(((char *)((char *)&hero))))->reach_height) { d->i68 = scale_game_frames_c(1); m->state = 2; break; diff --git a/src/overlays/l08/gameplay/entities/bomb.c b/src/overlays/l08/gameplay/entities/bomb.c index 169512cb44..d9c71dba3f 100644 --- a/src/overlays/l08/gameplay/entities/bomb.c +++ b/src/overlays/l08/gameplay/entities/bomb.c @@ -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; @@ -1512,7 +1511,6 @@ typedef struct { char pad0_p[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 Camera46_c D_L08_00167480_p __asm__("D_L08_00167480"); 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"); @@ -1561,12 +1559,12 @@ extern Cam_DBF68 D_L08_00167500_c __asm__("D_L08_00167480"); void FUN_L08_002dabf0(struct Moby *moby) { Data_DBF68 *d = (Data_DBF68 *)moby->pvars; Look_DBF68 look; - float v50[4]; - float v60[4]; - float v70[4]; + float point[4]; + float velocity[4]; + float aim[4]; int hit; float damage; - float out; + float scratch; struct Moby *target; struct Moby *old; @@ -1605,7 +1603,7 @@ void FUN_L08_002dabf0(struct Moby *moby) { d->i94 = 9; d->f84 = 0.0005f; d->bAD = 0; - base = ((char *)&D_0013F350); + base = ((char *)((char *)&hero)); FUN_L00_0025c558(moby, d->blk70, fast_arc_tan_c2(moby->pos.x - *(float *)(base + 0x80), moby->pos.y - *(float *)(base + 0x84)), @@ -1623,7 +1621,7 @@ void FUN_L08_002dabf0(struct Moby *moby) { d->f88 = D_L08_0016198C_gp * frame_time; d->f8C = D_L08_00161990_gp * frame_time; d->bAD = 0; - base = ((char *)&D_0013F350); + base = ((char *)((char *)&hero)); FUN_L00_0025c558(moby, d->blk70, fast_arc_tan_c2(moby->pos.x - *(float *)(base + 0x80), moby->pos.y - *(float *)(base + 0x84)), @@ -1745,12 +1743,12 @@ void FUN_L08_002dabf0(struct Moby *moby) { break; } case 4: - v50[0] = fast_cos_c4(moby->rot.z) * 2.0f; - v50[1] = fast_sin(moby->rot.z) * 2.0f; - v50[2] = 0.0f; - add_vector_xyz(v50, v50, &d->p120->pos); - if (0.2f < vector_distance_xy_alt(&moby->pos, v50)) { - FUN_L00_00259028((char *)moby, d->blkD0, v50, (char *)d->v40); + 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, &d->p120->pos); + if (0.2f < vector_distance_xy_alt(&moby->pos, point)) { + FUN_L00_00259028((char *)moby, d->blkD0, point, (char *)d->v40); } if (moby->anim_flags & 2) { Cam_DBF68 *cam; @@ -1780,31 +1778,31 @@ void FUN_L08_002dabf0(struct Moby *moby) { func_L00_002592B0_x(fast_arc_tan_c2(target->pos.x - moby->pos.x, target->pos.y - moby->pos.y), moby, d->blk12C, 0.02f, 0.3f, 0.2f); if (moby->seq == moby->prev_seq && FUN_0020c9e0(moby) == 19.0f) { - float len, t; - char *p; - subtract_vector_xyz(v70, &target->pos, &moby->pos); - v70[2] = 0.0f; - len = fast_vec_length_c2(v70); - t = len / FUN_001f96b0(D_L08_0016197C_gp); - len = len - (D_L08_00161988_gp * t + 2.0f); - if (10.0f < len) { - len = 10.0f; - } else if (len < 3.0f) { - len = 3.0f; + float distance, time; + char *next; + subtract_vector_xyz(aim, &target->pos, &moby->pos); + 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(v70, len); - add_vector_xyz(v70, v70, &moby->pos); - func_L00_00250800_2D6C58(moby, 9, v50); - subtract_vector_xyz(v60, &target->pos, v50); - set_vector_length_xy(v60, v60, t); - v60[2] = FUN_L00_0025abf0(v50, v70, &out, t, -(frame_time_sq * 15.0f)); - p = FUN_L08_002d22e0_c((int)moby, (char *)v50, (char *)v60); - d->p124 = (struct Moby *)p; - if (p != 0) { - char *pd = *(char **)(p + 0x78); - *(int *)(pd + 0x20) = scale_game_frames_c2(0xB4); - *(short *)(pd + 0xC) = scale_game_frames_c2(10); - *(short *)(pd + 0xE) = scale_game_frames_c2(10); + FUN_L00_0025f730(aim, distance); + add_vector_xyz(aim, aim, &moby->pos); + func_L00_00250800_2D6C58(moby, 9, point); + subtract_vector_xyz(velocity, &target->pos, point); + set_vector_length_xy(velocity, velocity, time); + 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); + d->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); d->p124->state = 1; d->p124->command |= 3; d->i128 = scale_game_frames_c2(0xB4); @@ -2021,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"); @@ -2059,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; diff --git a/src/overlays/l10/gameplay/entities/platform.c b/src/overlays/l10/gameplay/entities/platform.c index a86624bbc4..25750b49f3 100644 --- a/src/overlays/l10/gameplay/entities/platform.c +++ b/src/overlays/l10/gameplay/entities/platform.c @@ -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); @@ -421,7 +420,7 @@ 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 Ent *D_L10_0015FFD8_c __asm__("D_L10_0015FFD8"); +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"); @@ -451,7 +450,7 @@ extern void FUN_L00_002e8590(float, float); extern void FUN_L00_002e8648(void); extern void FUN_L00_002e8680(void); extern void fast_vec_normalize_c(void *, void *, f32) __asm__("FUN_001f9bf8"); -extern char *D_L10_00160058_00299818 __asm__("D_L10_0015FFD8"); +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) @@ -524,7 +523,7 @@ void FUN_L10_002be858(char *m) func_0022ED80_2BFBB8(0, 0, (int)m); { int di = *data << 8; - char *effect = D_L10_00160058_00299818 + di; + char *effect = (*(char * *)&D_L10_0015FFD8) + di; func_L00_00217718_2BFBB8(effect + 0x10, effect + 0x40, 0x43, 0); } { @@ -555,7 +554,7 @@ void FUN_L10_002be858(char *m) velocity[1] = func_001F9FA8_2BFBB8(func_00214158_2BFBB8()) * func_002140F8_2BFBB8(0.0f, 0.5f); velocity[2] = 0.0f; velocity[2] += func_002140F8_2BFBB8(0.0f, 0.5f); - func_L00_001FF240_2BFBB8(op, velocity, D_L10_00160058_00299818 + (*data << 8) + 0x10); + func_L00_001FF240_2BFBB8(op, 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)); diff --git a/src/overlays/l10/gameplay/entities/screamer.c b/src/overlays/l10/gameplay/entities/screamer.c index e93a95a85c..3c8272d1d6 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)); @@ -1265,8 +1264,8 @@ extern short 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[]; +#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"); @@ -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; } @@ -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; } } @@ -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 { @@ -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,7 +2283,7 @@ 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)); @@ -2305,7 +2303,7 @@ float FUN_L10_002e4840(struct Moby *self) { 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 *); @@ -2474,7 +2471,7 @@ void FUN_L10_002e4a88(Ship_5E48 *m) { 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; @@ -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; @@ -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 b58a95068f..6b05d90e87 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; @@ -485,7 +484,6 @@ void FUN_L12_003064e8(char *moby) { extern int D_L12_0015F5CC_p __asm__("D_L12_0015F5CC"); extern unsigned char * D_L12_0015FFD8; -extern struct Moby *D_L12_00160058_303CA8 __asm__("D_L12_0015FFD8"); void FUN_L12_00306828(char *moby) { int i; @@ -505,7 +503,7 @@ void FUN_L12_00306828(char *moby) { if (i == 17) { other = moby; } else { - other = (char *)D_L12_00160058_303CA8 + ((unsigned int)*(int *)(data + i * 0x30 + 0x20) << 8); + other = (char *)(*(struct Moby * *)&D_L12_0015FFD8_p) + ((unsigned int)*(int *)(data + i * 0x30 + 0x20) << 8); } if (*(short *)(other + 0xA6) == 0x4FE) continue; { @@ -570,7 +568,7 @@ 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[]; +#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 *); @@ -610,7 +608,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); @@ -979,7 +977,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 +994,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..459b41a403 100644 --- a/src/overlays/l12/gameplay/entities/platform.c +++ b/src/overlays/l12/gameplay/entities/platform.c @@ -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; diff --git a/src/overlays/l13/gameplay/entities/elevator.c b/src/overlays/l13/gameplay/entities/elevator.c index fda5130cfc..5850300252 100644 --- a/src/overlays/l13/gameplay/entities/elevator.c +++ b/src/overlays/l13/gameplay/entities/elevator.c @@ -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 0da62bcb92..9ee16e1a8c 100644 --- a/src/overlays/l13/gameplay/entities/rocket.c +++ b/src/overlays/l13/gameplay/entities/rocket.c @@ -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; @@ -1171,7 +1170,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"); @@ -1284,7 +1283,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) { @@ -2414,7 +2413,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)); @@ -2536,7 +2535,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..7f7cb69bd2 100644 --- a/src/overlays/l14/gameplay/entities/platform.c +++ b/src/overlays/l14/gameplay/entities/platform.c @@ -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..9f8a2392fc 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 { @@ -1894,7 +1891,7 @@ void FUN_L16_002e7a30(unsigned char *m, void *v) { 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; + size *= frame_time; normalize_vector_xyz(offset, m + 0xC0, -0.5f); add_vector_xyz(offset, offset, m + 0x10); a = random_angle_radians(); @@ -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..9446cd349f 100644 --- a/src/overlays/l16/gameplay/entities/rocket.c +++ b/src/overlays/l16/gameplay/entities/rocket.c @@ -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; 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..cd201dd9b2 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 && diff --git a/src/overlays/l18/gameplay/entities/rocket.c b/src/overlays/l18/gameplay/entities/rocket.c index 9edaa043e5..e0ca724af7 100644 --- a/src/overlays/l18/gameplay/entities/rocket.c +++ b/src/overlays/l18/gameplay/entities/rocket.c @@ -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; 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..66ac3c8b9e 100644 --- a/src/overlays/shared/gameplay/camera/follow_camera_setup.c +++ b/src/overlays/shared/gameplay/camera/follow_camera_setup.c @@ -1163,7 +1163,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 +1327,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 +1339,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..4cc19795fc 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 *); @@ -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); + (*(float *)&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); 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); + (((*(float *)&D_L02_001600DC) - (*(float *)&D_L02_001600E0)) * (travel / distance) + (*(float *)&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 7cc41d6356..fbcd41e4e5 100644 --- a/src/overlays/shared/gameplay/entities/00295100.c +++ b/src/overlays/shared/gameplay/entities/00295100.c @@ -831,11 +831,11 @@ void FUN_L00_00299560(s32 i) { } FUN_L00_002995d0(a, b, game_language); } -extern s32 movie_sector __asm__("D_L00_00161048") __attribute__((section(".sdata"))); -extern s32 movie_size __asm__("D_L00_0016104C") __attribute__((section(".sdata"))); -extern s32 movie_language __asm__("D_L00_00161050") __attribute__((section(".sdata"))); -extern s32 movie_buffer __asm__("D_L00_00161054") __attribute__((section(".sdata"))); -extern s32 movie_image_data __asm__("D_L00_00161058") __attribute__((section(".sdata"))); +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_00161048, D_L00_0016104C, 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"))); @@ -862,18 +862,18 @@ void FUN_L00_002995d0(s32 sector, s32 size, s32 language) { flush_cache(0); sound_stop_all_sounds(); music_stop(); - movie_sector = sector; - movie_size = size; - movie_language = language; + D_L00_00161048_macro = sector; + D_L00_0016104C_macro = size; + (*(s32 *)&D_L00_00161050_macro) = language; D_L00_0015F5D8 = 1; fade_to_black(4); FUN_L00_002039a0(); D_L00_0015F5C4_macro = 1; - movie_buffer = D_L00_00173E04_lui; - movie_image_data = D_L00_0015F40C_macro; + 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 = movie_image_data; + source = D_L00_00161058_macro; gs_address = gs_layout_macro[4]; i = 0; while (i < large_count) { diff --git a/src/overlays/shared/gameplay/entities/blarg_elite_commando.c b/src/overlays/shared/gameplay/entities/blarg_elite_commando.c index 49ff5b3691..9151b9c827 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. */ diff --git a/src/overlays/shared/gameplay/entities/blarg_space_commando.c b/src/overlays/shared/gameplay/entities/blarg_space_commando.c index 26ea1df65a..2cc4f3b3fc 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"); @@ -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. */ diff --git a/src/overlays/shared/gameplay/entities/bomb.c b/src/overlays/shared/gameplay/entities/bomb.c index 325c942de9..2451901caf 100644 --- a/src/overlays/shared/gameplay/entities/bomb.c +++ b/src/overlays/shared/gameplay/entities/bomb.c @@ -2245,7 +2245,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"); @@ -2256,7 +2255,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))); @@ -2874,7 +2873,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"))); @@ -2921,14 +2920,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..728fb40bd7 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; diff --git a/src/overlays/shared/gameplay/entities/gadgebot_spawn_container.c b/src/overlays/shared/gameplay/entities/gadgebot_spawn_container.c index 52030cf91c..6c010f907b 100644 --- a/src/overlays/shared/gameplay/entities/gadgebot_spawn_container.c +++ b/src/overlays/shared/gameplay/entities/gadgebot_spawn_container.c @@ -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; diff --git a/src/overlays/shared/gameplay/entities/nanotech_ball.c b/src/overlays/shared/gameplay/entities/nanotech_ball.c index cf257c4c23..577117874d 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) { diff --git a/src/overlays/shared/gameplay/entities/plasmabot.c b/src/overlays/shared/gameplay/entities/plasmabot.c index ce2f0c15fc..b8e3fea187 100644 --- a/src/overlays/shared/gameplay/entities/plasmabot.c +++ b/src/overlays/shared/gameplay/entities/plasmabot.c @@ -341,8 +341,6 @@ 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 D_0015ED6C_p __asm__("D_0015ED6C"); -extern float D_0015ED70_p __asm__("D_0015ED70"); 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); @@ -564,8 +562,8 @@ void FUN_L14_002b17d8(char *m) { float k; ang = fast_arc_tan_c(*(float *)(owner + 0x10) - *(float *)(m + 0x10), *(float *)(owner + 0x14) - *(float *)(m + 0x14)); - k = D_0015ED70_p * 12.566371f; - call_CE58((float *)(m + 0x48), ang, (float *)(data + 0x23C), k, k, D_0015ED6C_p * 6.2831855f); + k = frame_time_sq * 12.566371f; + call_CE58((float *)(m + 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 *)m)[0x20] = 3; @@ -606,8 +604,8 @@ void FUN_L14_002b17d8(char *m) { FUN_L14_002b3578_c(m); ang = fast_arc_tan_c(*(float *)(owner + 0x10) - *(float *)(m + 0x10), *(float *)(owner + 0x14) - *(float *)(m + 0x14)); - k = D_0015ED70_p * 12.566371f; - call_CE58((float *)(m + 0x48), ang, (float *)(data + 0x23C), k, k, D_0015ED6C_p * 6.2831855f); + k = frame_time_sq * 12.566371f; + call_CE58((float *)(m + 0x48), ang, (float *)(data + 0x23C), k, k, frame_time * 6.2831855f); aim = FUN_L14_002b35d8_c(m, 0, *(float *)(m + 0x48)); FUN_L14_002b37b0_c(m, ang); if (*(int *)(data + 0x114) == 2) { diff --git a/src/overlays/shared/gameplay/entities/rock.c b/src/overlays/shared/gameplay/entities/rock.c index 75cf8d143b..8e5e3c986b 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)); 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]; 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..8eaba3124d 100644 --- a/src/overlays/shared/gameplay/entities/sentrybot.c +++ b/src/overlays/shared/gameplay/entities/sentrybot.c @@ -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 diff --git a/src/overlays/shared/gameplay/entities/trackdrive_left.c b/src/overlays/shared/gameplay/entities/trackdrive_left.c index ffad467866..54a9c4e8fb 100644 --- a/src/overlays/shared/gameplay/entities/trackdrive_left.c +++ b/src/overlays/shared/gameplay/entities/trackdrive_left.c @@ -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 a4efa7e84a..c95661f16f 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; @@ -1981,7 +1981,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/veldin_ship.c b/src/overlays/shared/gameplay/entities/veldin_ship.c index 0ab4815765..fbaaec414a 100644 --- a/src/overlays/shared/gameplay/entities/veldin_ship.c +++ b/src/overlays/shared/gameplay/entities/veldin_ship.c @@ -1170,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) { @@ -1248,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; @@ -1823,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); @@ -1958,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); @@ -1967,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); @@ -2001,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; @@ -2012,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; @@ -2048,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; @@ -2059,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; @@ -2095,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; @@ -2106,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; @@ -3452,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"); @@ -3514,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 39df09b186..135cdae30f 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"); @@ -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,7 +1290,7 @@ 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); @@ -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); @@ -1807,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"); @@ -1877,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..672f715505 100644 --- a/src/overlays/shared/gameplay/hero/hero_check_damage.c +++ b/src/overlays/shared/gameplay/hero/hero_check_damage.c @@ -1335,7 +1335,7 @@ 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 void add_vector_xyz(void *, void *, void *) __asm__("FUN_001f9a10"); @@ -1344,7 +1344,7 @@ 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,7 +1373,7 @@ 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; } else if (*(int *)(b + 0x2084) == 2) { @@ -1384,7 +1384,7 @@ void FUN_L00_0020f160(char *arg) { } { - char *b = ((char *)&D_0013F350); + char *b = ((char *)((char *)&hero_lui)); if (*(int *)(b + 0x21C0) < *(int *)&D_L00_0015F694) { *(int *)(b + 0x21C0) = *(int *)(b + 0x21C0) + 1; } else if (*(int *)&D_L00_0015F694 < *(int *)(b + 0x21C0)) { @@ -1393,7 +1393,7 @@ void FUN_L00_0020f160(char *arg) { } { - 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..57fadc2bfb 100644 --- a/src/overlays/shared/gameplay/hero/hero_idle_sequence.c +++ b/src/overlays/shared/gameplay/hero/hero_idle_sequence.c @@ -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/rendering/00245c28.c b/src/overlays/shared/rendering/00245c28.c index 71cacf8a8f..63912d1849 100644 --- a/src/overlays/shared/rendering/00245c28.c +++ b/src/overlays/shared/rendering/00245c28.c @@ -300,18 +300,65 @@ void FUN_L00_00245c28(void) { } do_space_transition(); } -#ifndef NON_MATCHING +#include "rnc/storage/disc_table.h" + +typedef struct { + 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; + 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; + s32 loaded; + s32 transfer_bytes; + u8 pad238[4]; + s32 old_base; + u8 pad240[0x38]; + s32 start; + s32 buffer; + s32 old_end; + s32 zero_284; + s32 zero_288; + s32 slot_28c; + s32 level_slot; + s32 slot_294; + s32 slot_298; + s32 slot_29c; + s32 slot_2a0; + u8 pad2a4[4]; + 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 D_00137B80[]; extern char D_L00_0015FE00[]; extern char D_L00_001E8B00[]; extern float D_L00_00182810[]; extern float D_L00_00182A70[]; extern int *D_L00_00173E08[]; extern int D_L00_00183EF0[]; -extern int D_L00_001841F0_c[] __asm__("D_L00_001841F0"); +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"); @@ -323,13 +370,13 @@ 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 char D_00138438_c[] __asm__("D_00138438"); +extern struct DiscFile D_00138438[]; extern char D_001383A0[]; extern char D_00141EC0[]; void FUN_L00_002464a8(void) { int i, j; - int *gl; + RenderArchiveState *gl; int *q; int v; int *e; @@ -341,19 +388,17 @@ void FUN_L00_002464a8(void) { int x, y, w; float lim; unsigned char *pp; - extern int D_L00_001841F0_c[]; - extern char D_00137B80[]; - D_L00_001841F0_c[4] = 1; + D_L00_001841F0.initialized = 1; { int i; for (i = 0; i < 20; i++) { - D_L00_001841F0_c[0x41 + i] = D_L00_00183EF0[i * 2]; - ((float *)D_L00_001841F0_c)[0x2D + i] = 0.65f; - D_L00_001841F0_c[0x55 + i] = D_L00_00183EF0[i * 2 + 1]; + 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]; } } v = current_level_index; - D_L00_001841F0_c[0x8B] = -1; - D_L00_001841F0_c[0x89] = v > 18 ? 0 : v; + D_L00_001841F0.file_handle = -1; + D_L00_001841F0.archive_index = v > 18 ? 0 : v; { int i; for (i = 0; i < 19; i++) { float a = D_L00_00182810[i * 8], b = D_L00_00182810[i * 8 + 1], c = D_L00_00182810[i * 8 + 2], dd = D_L00_00182810[i * 8 + 3]; @@ -367,45 +412,45 @@ void FUN_L00_002464a8(void) { } } pp = (unsigned char *)D_0013D4C0; if (pp[0x21] != 0) { - D_L00_001841F0_c[0x8C] = 1; - e = (int *)(((char *)&D_00138438_c)) + D_L00_001841F0_c[0x89] * 2; + D_L00_001841F0.loaded = 1; + e = (int *)(((char *)((char *)&D_00138438))) + D_L00_001841F0.archive_index * 2; } else { - D_L00_001841F0_c[0x8C] = 0; - e = (int *)(((char *)&D_001383A0)) + D_L00_001841F0_c[0x89] * 2; + D_L00_001841F0.loaded = 0; + e = (int *)(((char *)&D_001383A0)) + D_L00_001841F0.archive_index * 2; } if (e[1] != 0) { - gl = D_L00_001841F0_c; - gl[10] = 1; + gl = &D_L00_001841F0; + gl->unk28 = 1; heap_tag = (int)D_L00_0015FE00; archive_base = D_L00_00173E08[0]; archive = (int *)((int)archive_base + 0x9A800); scratch = e[1] << 7; load(archive, e[0], e[1]); - gl[0x8B] = stash_send_data((int)archive, scratch, 0x4800, (int)D_L00_001E8B00); - gl[0x8D] = scratch; + gl->file_handle = stash_send_data((int)archive, scratch, 0x4800, (int)D_L00_001E8B00); + gl->transfer_bytes = scratch; FUN_L00_0024d8d0((int)archive, (int)archive_base); archive = archive_base; first_size = archive[1] - archive[0]; - gl[0] = hud_heap_alloc(first_size, 0, (char *)heap_tag, 0x2DB); - fast_mem_copy_alt((void *)gl[0], (char *)archive + archive[0], first_size); - gl[0] += 8; - gl[1] = gl[0]; + gl->first_data = hud_heap_alloc(first_size, 0, (char *)heap_tag, 0x2DB); + fast_mem_copy_alt((void *)gl->first_data, (char *)archive + archive[0], first_size); + gl->first_data += 8; + gl->second_data = gl->first_data; second_size = archive[2] - archive[1]; - gl[5] = hud_heap_alloc(second_size, 0, (char *)heap_tag, 0x2EC); - fast_mem_copy_alt((void *)gl[5], (char *)archive + archive[1], second_size); - gl[2] = hud_heap_alloc(0x1000, 0, (char *)heap_tag, 0x2F3); + gl->second_raw = hud_heap_alloc(second_size, 0, (char *)heap_tag, 0x2EC); + fast_mem_copy_alt((void *)gl->second_raw, (char *)archive + archive[1], second_size); + gl->scratch_data = hud_heap_alloc(0x1000, 0, (char *)heap_tag, 0x2F3); for (i = 0; i < 8; i++) { - D_L00_001841F0_c[12 + i * 4] = -1; - D_L00_001841F0_c[13 + i * 4] = -1; - D_L00_001841F0_c[14 + i * 4] = D_L00_001841F0_c[2] + i * 0x200; + 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; } w = hud_heap_alloc(0x8000, 0, D_L00_0015FE00, 0x2FC); - level_data = ((char *)&D_00141EC0) + D_L00_001841F0_c[0x89] * 0x800; - D_L00_001841F0_c[3] = w; + level_data = ((char *)&D_00141EC0) + D_L00_001841F0.archive_index * 0x800; + D_L00_001841F0.mask_data = w; if (level_data[0] != 0) { - load_map_chunk((void *)D_L00_001841F0_c[3], level_data, D_L00_001841F0_c[5]); + load_map_chunk((void *)D_L00_001841F0.mask_data, level_data, D_L00_001841F0.second_raw); } else { - decode_map_mask((int *)D_L00_001841F0_c[3], (unsigned char *)D_L00_001841F0_c[0], (short *)D_L00_001841F0_c[1]); + decode_map_mask((int *)D_L00_001841F0.mask_data, (unsigned char *)D_L00_001841F0.first_data, (short *)D_L00_001841F0.second_data); } lim = 256.0f; for (y = 0; y < 32; y++) { @@ -417,43 +462,13 @@ void FUN_L00_002464a8(void) { } } } else { - D_L00_001841F0_c[0] = 0; - D_L00_001841F0_c[2] = 0; - D_L00_001841F0_c[3] = 0; - D_L00_001841F0_c[1] = 0; - D_L00_001841F0_c[10] = 0; + 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; } } -#else -#endif -#include "rnc/storage/disc_table.h" - -typedef struct { - u8 pad0[0x24]; - s32 active; - u8 pad28[0x1fc]; - s32 archive_index; - s32 load_state; - s32 file_handle; - s32 loaded; - s32 transfer_bytes; - u8 pad238[4]; - s32 old_base; - u8 pad240[0x38]; - s32 start; - s32 buffer; - s32 old_end; - s32 zero_284; - s32 zero_288; - s32 slot_28c; - s32 level_slot; - s32 slot_294; - s32 slot_298; - s32 slot_29c; - s32 slot_2a0; - u8 pad2a4[4]; - s32 last_transfer_bytes; -} RenderArchiveState; extern RenderArchiveState D_L00_001841F0 __asm__("D_L00_001841F0"); extern u8 D_0013D4E1 __attribute__((section(".data"))); diff --git a/src/overlays/shared/rendering/002712b8.c b/src/overlays/shared/rendering/002712b8.c index 22dea5942e..ad7e67446e 100644 --- a/src/overlays/shared/rendering/002712b8.c +++ b/src/overlays/shared/rendering/002712b8.c @@ -2100,13 +2100,13 @@ typedef struct { P2_276078 e[20]; } T1_276078; -extern s32 D_L00_00173E08 __attribute__((section(".data"))); +extern s32 D_L00_00173E08_lui __asm__("D_L00_00173E08") __attribute__((section(".data"))); extern T1_276078 D_00137B80; extern u8 D_L00_001602D0[]; void Load(s32, s32, s32) __asm__("FUN_00216828"); s32 stash_send_data(s32, s32, s32, void *) __asm__("FUN_00232e40"); void FUN_L00_00276078(void) { - s32 h = D_L00_00173E08; + s32 h = D_L00_00173E08_lui; s32 i; for (i = 0; i < 20; i++) { s32 sz = D_00137B80.e[i].n << 7; 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 b3bffd47d0..b03c682403 100644 --- a/src/overlays/shared/ui/help/001ff938.c +++ b/src/overlays/shared/ui/help/001ff938.c @@ -156,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); @@ -217,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; @@ -230,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) { @@ -575,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/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 0ed37c9efc..d619d5837b 100644 --- a/src/overlays/shared/ui/text/002377b8.c +++ b/src/overlays/shared/ui/text/002377b8.c @@ -365,14 +365,14 @@ extern unsigned char D_00141EA0[]; extern SrcElem_p D_L00_00179AC0[]; extern char *get_help_message_text(s32) __asm__("func_001FDD10"); extern char D_0013D428[]; -extern char D_L00_0015F5CC_p[] __asm__("D_L00_0015F5CC"); +#include "rnc/overlay/level_labels.h" extern char D_L00_0015F7C8[]; 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 int D_L00_0015FA90_p __asm__("D_L00_0015FA90"); -extern int D_L00_0015FAC0_p __asm__("D_L00_0015FAC0"); +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 *, ...); @@ -399,14 +399,11 @@ extern short D_L00_0015F7BC_gp __asm__("D_L00_0015F7BC") __attribute__((sda)); extern short D_L00_0015F7C0_p __asm__("D_L00_0015F7C0"); extern short D_L00_0015F7C4_gp __asm__("D_L00_0015F7C4") __attribute__((sda)); extern u32 strlen(const char *); -extern unsigned char D_L00_001C40B0_p[] __asm__("D_L00_001C40B0"); extern unsigned char D_0013E520[]; extern int D_L00_0015F5CC_i __asm__("D_L00_0015F5CC"); -extern char D_L00_001C40B0_c[] __asm__("D_L00_001C40B0"); 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_p *rec, int *x, int *y) __asm__("FUN_L00_00235a70"); -extern int D_0014171B_i[] __asm__("D_L00_001C40B0"); #define GI(x) (*(int *)&(x)) #define GF(x) (*(float *)&(x)) @@ -480,7 +477,7 @@ int FUN_L00_002382a0(HudElem_p *rec) { { int id; id = *(int *)((char *)D_00141EA0 + selected * 4); - wr = D_L00_001C40B0_c + id * 24; + wr = ((char *)&D_L00_001C40B0) + id * 24; if (*(unsigned short *)(wr + 8) != 0) { int shadow, item; item = *(int *)(D_0013D428 + id * 4); @@ -535,7 +532,7 @@ int FUN_L00_002382a0(HudElem_p *rec) { int id; char *wr; id = *(int *)((char *)D_00141EA0 + selected * 4); - wr = D_L00_001C40B0_c + id * 24; + wr = ((char *)&D_L00_001C40B0) + id * 24; if (*(unsigned short *)(wr + 8) != 0) text_y += GI(D_L00_0015F7B4); else if (prefix_length != 0) From e8e7ce986fd43cad039121fc8c79cee3de2187e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Sat, 17 Oct 2026 06:57:38 +0000 Subject: [PATCH 13/33] chore: keep main's names in the sound update draft --- .../textbin/audio/voices/sound_update.c | 51 +++++++++---------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/src/assembly/textbin/audio/voices/sound_update.c b/src/assembly/textbin/audio/voices/sound_update.c index 7762cf33f1..a24f0f291f 100644 --- a/src/assembly/textbin/audio/voices/sound_update.c +++ b/src/assembly/textbin/audio/voices/sound_update.c @@ -77,18 +77,17 @@ typedef struct { extern VoiceRuntimeState D_0013E550; extern f32 D_0013F640[]; -extern f32 D_0015ED6C; -extern s32 D_0015F5E8; -extern s32 D_0015F604; -extern s32 D_0015F60C; +extern s32 boot_level_active __asm__("D_0015F5E8"); +extern s32 game_mode __asm__("D_0015F604"); +extern s32 world_update_time __asm__("D_0015F60C"); extern VoiceVector D_00187080; -extern u8 D_00187290[]; -extern s32 D_001872D4; +extern char camera_rows[] __asm__("D_00187290"); +extern s32 use_alt_fog __asm__("D_001872D4"); extern s32 ComputeByteStringHash(u8 *, s32); extern int snd_get_doppler_pitch_mod(int arg0); -extern void FillTransferWords(void *, s32, s32); -extern void ReadGlobalTableEntry(void); +extern void fill_transfer_words(void *, s32, s32) __asm__("func_001F97E8"); +extern void read_global_table_entry(void) __asm__("ReadGlobalTableEntry"); extern s32 snd_flush_sound_commands(void) __asm__("FUN_0012dc80"); extern void snd_set_master_volume(s32, s32) __asm__("FUN_0012e208"); extern void snd_play_sound_vol_pan_pmpb() __asm__("FUN_0012e308"); @@ -106,7 +105,7 @@ extern f32 vector_length_xyz(void *a) __asm__("FUN_001f9af0"); extern void normalize_vector_xyz(void *out, void *a, f32 len) __asm__("FUN_001f9bf8"); extern void func_001F9CF8(void *out, void *a, void *b) __asm__("FUN_001f9cf8"); extern void func_001FA2D8(void *out, void *a) __asm__("FUN_001fa2d8"); -extern f32 ConvertIntegerToFloat(s32) __asm__("func_001FA6C0"); +extern f32 convert_integer_to_float(s32) __asm__("func_001FA6C0"); extern s32 truncate_float_to_s32(f32) __asm__("FUN_001fa6d0"); extern void music_update() __asm__("FUN_00216290"); extern void clamp_voice_position_to_collision(void *) __asm__("FUN_0022c5a8"); @@ -154,7 +153,7 @@ s32 sound_update(void) { s32 command_flags; u8 * volatile occlusion_history; - underwater = D_001872D4; + underwater = use_alt_fog; water_height = 0.0f; if (underwater != 0) { water_height = D_0013F640[0]; @@ -171,7 +170,7 @@ s32 sound_update(void) { } D_0013E550.reverb_commands = 0; - if ((D_0015F604 == 0 || D_0015F604 == 2) && D_0015F5E8 == 0) { + if ((game_mode == 0 || game_mode == 2) && boot_level_active == 0) { clamp_voice_position_to_collision(&listener_occlusion_position); } @@ -189,7 +188,7 @@ s32 sound_update(void) { do { subtract_vector_xyz(&relative_velocity, &D_0013E550.listener_history[current_index], &D_0013E550.listener_history[previous_history_index]); - if (!(vector_length_xyz(&relative_velocity) < D_0015ED6C * 60.0f)) { + if (!(vector_length_xyz(&relative_velocity) < frame_time * 60.0f)) { break; } listener_sample_count++; @@ -200,10 +199,10 @@ s32 sound_update(void) { } if (listener_sample_count >= 2) { scale_vector_xyz(&listener_velocity, &listener_velocity, - 1.0f / ConvertIntegerToFloat(listener_sample_count)); + 1.0f / convert_integer_to_float(listener_sample_count)); } - if (D_0015F604 == 2) { + if (game_mode == 2) { snd_set_master_volume(1, 0); snd_set_master_volume(0, D_0013E550.group_0_volume / 2); snd_set_master_volume(3, D_0013E550.group_3_volume / 2); @@ -222,9 +221,9 @@ s32 sound_update(void) { voice_flags = flags; volumes = voice_volumes; - FillTransferWords(voice_flags, 0, 0x78); - FillTransferWords(volumes, 0, 0x78); - FillTransferWords(radial_velocities, 0, 0x78); + fill_transfer_words(voice_flags, 0, 0x78); + fill_transfer_words(volumes, 0, 0x78); + fill_transfer_words(radial_velocities, 0, 0x78); for (slot_index = 0; slot_index < 30; slot_index++) { if (D_0013E550.voices[slot_index].state != 7) { @@ -257,7 +256,7 @@ s32 sound_update(void) { voice_flags[slot_index] = 0x20; continue; } - if (D_0015F604 != 0 && D_0015F604 != 2 && D_0015F604 != 6 && + if (game_mode != 0 && game_mode != 2 && game_mode != 6 && D_0013E550.voices[slot_index].state != 7) { voice_flags[slot_index] = 0x10; continue; @@ -324,16 +323,16 @@ s32 sound_update(void) { continue; } if (D_0013E550.voices[slot_index].state == 7) { - if ((D_0015F604 != 0 && D_0015F604 != 2) || D_0015F5E8 != 0) { + if ((game_mode != 0 && game_mode != 2) || boot_level_active != 0) { continue; } occluded_samples = 0; - if (D_0015F60C != D_0013E550.occlusion_frame) { + if (world_update_time != D_0013E550.occlusion_frame) { for (sample_index = 0; sample_index < 6; sample_index++) { clamp_voice_position_to_collision( &D_0013E550.occlusion_samples[sample_index]); } - D_0013E550.occlusion_frame = D_0015F60C; + D_0013E550.occlusion_frame = world_update_time; } for (history_offset = 0, sample_index = 0; history_offset < 36; history_offset += 6, sample_index++) { @@ -354,13 +353,13 @@ s32 sound_update(void) { voice_volumes[slot_index] = (36 - occluded_samples) * voice_volumes[slot_index] / divisor; } } else { - if ((D_0015F604 == 0 || D_0015F604 == 2) && D_0015F5E8 == 0) { + if ((game_mode == 0 || game_mode == 2) && boot_level_active == 0) { D_0013E550.voices[slot_index].occlusion_history_position = (D_0013E550.voices[slot_index].occlusion_history_position + 1) % 36; /* Active sources test every other frame; other voices every fourth. */ - command_flags = (slot_index ^ D_0015F60C) & 1; + command_flags = (slot_index ^ world_update_time) & 1; if (!(D_0013E550.voices[slot_index].flags & 4)) { - command_flags = ((D_0015F60C ^ slot_index) & 3) == 0; + command_flags = ((world_update_time ^ slot_index) & 3) == 0; } if (command_flags) { D_0013E550.voices[slot_index].occlusion_history @@ -386,7 +385,7 @@ s32 sound_update(void) { } } - func_001FA2D8(listener_matrix, D_00187290); + func_001FA2D8(listener_matrix, camera_rows); for (slot_index = 0; slot_index < 30; slot_index++) { command_flags = voice_flags[slot_index]; if (command_flags == 0) { @@ -444,7 +443,7 @@ s32 sound_update(void) { music_update(); snd_reset_state_and_flush_commands(); snd_flush_sound_commands(); - ReadGlobalTableEntry(); + read_global_table_entry(); D_0013E550.pending_commands = 0; return 0; } From 24b2d0e4e468a93ac91e98d7f3f9b044b7e41083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Sat, 17 Oct 2026 07:04:09 +0000 Subject: [PATCH 14/33] chore: header names for two more globals --- src/overlays/l07/gameplay/entities/snagglebeast.c | 12 ++++++------ src/overlays/l08/gameplay/entities/bolt_thief.c | 1 - .../shared/gameplay/entities/nanotech_ball.c | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/overlays/l07/gameplay/entities/snagglebeast.c b/src/overlays/l07/gameplay/entities/snagglebeast.c index b3269814b5..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); @@ -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/l08/gameplay/entities/bolt_thief.c b/src/overlays/l08/gameplay/entities/bolt_thief.c index 2cf0d4e4c1..7a03ac183d 100644 --- a/src/overlays/l08/gameplay/entities/bolt_thief.c +++ b/src/overlays/l08/gameplay/entities/bolt_thief.c @@ -1947,7 +1947,6 @@ extern CollPos_4BE8 D_L08_00174660; extern KillFlags_4BE8 D_L08_001BADD0; extern KillFlags_4BE8 D_L08_001BBA30; extern struct Moby *D_L08_0015FFDC; -extern char D_0013E533_p[] __asm__("D_0013E533"); 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 *); diff --git a/src/overlays/shared/gameplay/entities/nanotech_ball.c b/src/overlays/shared/gameplay/entities/nanotech_ball.c index 577117874d..a9044fda44 100644 --- a/src/overlays/shared/gameplay/entities/nanotech_ball.c +++ b/src/overlays/shared/gameplay/entities/nanotech_ball.c @@ -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; From 3ea7994aa2d0681009c508e7f3376d2ed81c439b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Sat, 17 Oct 2026 07:09:39 +0000 Subject: [PATCH 15/33] chore: merge more duplicate global names --- .../l07/gameplay/entities/taxi_platform.c | 17 ++++++++--------- .../gameplay/camera/follow_camera_setup.c | 3 +-- src/overlays/shared/ui/text/002377b8.c | 12 +++++------- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/overlays/l07/gameplay/entities/taxi_platform.c b/src/overlays/l07/gameplay/entities/taxi_platform.c index 03a656b470..2029cced90 100644 --- a/src/overlays/l07/gameplay/entities/taxi_platform.c +++ b/src/overlays/l07/gameplay/entities/taxi_platform.c @@ -2603,9 +2603,8 @@ struct Tgt_3109D0_p { int kind; }; -extern Rec_30D8E8_p *D_L07_001612D0_p __asm__("D_L07_001612D0"); -extern Vec4_p D_L07_00173EE0_p __asm__("D_L07_00173EE0"); -extern char *D_L07_0015FFD8_p __asm__("D_L07_0015FFD8"); +extern Rec_30D8E8 * D_L07_001612D0; +extern char *D_L07_0015FFD8; extern char D_0013E533[]; extern char D_L07_002117F8[]; extern char D_L07_00211838[]; @@ -2615,7 +2614,7 @@ 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_p __asm__("D_L07_0015F5CC"); -extern int D_L07_001612D8_p __asm__("D_L07_001612D8"); +extern int D_L07_001612D8; extern int DebugPrint_alt() __asm__("FUN_001e93b0"); extern int FUN_001f0b58(void); extern int FUN_L00_00259740(void *, void *, int); @@ -2681,7 +2680,7 @@ void FUN_L07_0030f5f0(unsigned char *moby) { FUN_L00_00263ac8(moby, 0, data + 0x150, 2.2f); if (moby[0x20] == 0) { if (FUN_L07_0030ed30_c((char *)moby, data)) { - DebugPrint_alt(D_L07_002117F8, (int)((char *)moby - D_L07_0015FFD8_p) >> 8); + DebugPrint_alt(D_L07_002117F8, (int)((char *)moby - D_L07_0015FFD8) >> 8); mark_moby_for_removal_c4(moby); return; } @@ -2745,20 +2744,20 @@ void FUN_L07_0030f5f0(unsigned char *moby) { if (moby[0x20] == 0xE || moby[0x20] == 0xC) { s += s; } - if (0.5f < vector_distance_xy_alt(moby + 0x10, &D_L07_00173EE0_p)) { - f = vector_distance_xy_alt(moby + 0x10, &D_L07_00173EE0_p); + if (0.5f < vector_distance_xy_alt(moby + 0x10, &(*(Vec4_p *)&D_L07_00173EE0))) { + f = vector_distance_xy_alt(moby + 0x10, &(*(Vec4_p *)&D_L07_00173EE0)); f += f; } else { f = 1.0f; } if (D_L07_0015F5CC_p % 45 == *(short *)(moby + 0xB2) && random_integer_below(2) == 0) { - func_L00_002A5158_30D8E8(D_L07_001612D0_p, D_L07_001612D8_p, 1, F(moby, 0x10), F(moby, 0x14), f, s); + func_L00_002A5158_30D8E8((*(Rec_30D8E8_p * *)&D_L07_001612D0), D_L07_001612D8, 1, F(moby, 0x10), F(moby, 0x14), f, s); } if (D_L07_0015F5CC_p % ((rand() & 7) + 20) == 0) { float size = random_float_between_c2(1.5f, 2.4f); pos[0] += random_float_between_c2(-0.15f, 0.15f); pos[1] += random_float_between_c2(-0.15f, 0.15f); - pos[2] = resolve_camera_surface_height(&D_L07_00173EE0_p, 0); + pos[2] = resolve_camera_surface_height(&(*(Vec4_p *)&D_L07_00173EE0), 0); FUN_L00_002715e8(pos, 0, -1, size, 5250.0f); } } diff --git a/src/overlays/shared/gameplay/camera/follow_camera_setup.c b/src/overlays/shared/gameplay/camera/follow_camera_setup.c index 66ac3c8b9e..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) diff --git a/src/overlays/shared/ui/text/002377b8.c b/src/overlays/shared/ui/text/002377b8.c index d619d5837b..587f009787 100644 --- a/src/overlays/shared/ui/text/002377b8.c +++ b/src/overlays/shared/ui/text/002377b8.c @@ -371,7 +371,6 @@ 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 int D_L00_0015FA90_p __asm__("D_L00_0015FA90"); 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"); @@ -400,7 +399,6 @@ extern short D_L00_0015F7C0_p __asm__("D_L00_0015F7C0"); extern short D_L00_0015F7C4_gp __asm__("D_L00_0015F7C4") __attribute__((sda)); extern u32 strlen(const char *); extern unsigned char D_0013E520[]; -extern int D_L00_0015F5CC_i __asm__("D_L00_0015F5CC"); 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_p *rec, int *x, int *y) __asm__("FUN_L00_00235a70"); @@ -429,7 +427,7 @@ int FUN_L00_002382a0(HudElem_p *rec) { else if (fade < 0.0f) fade = 0.0f; { float phase, angle, radius; - phase = convert_integer_to_float_c2(D_L00_0015F5CC_i % GI(D_L00_0015F7B0_gp)); + phase = convert_integer_to_float_c2(D_L00_0015F5CC % GI(D_L00_0015F7B0_gp)); phase /= convert_integer_to_float_c2(GI(D_L00_0015F7B0_gp)); phase *= 6.28318f; angle = fast_sin(phase - 3.14159f); @@ -451,9 +449,9 @@ int FUN_L00_002382a0(HudElem_p *rec) { y, -half_w, half_h, alpha); draw_hud_sprite_c2(find_valid_animation_frame_index_alt(0xe934, 0), x, y + GI(D_L00_0015F71C_p), half_w, -half_h, alpha); - for (i = 0; i < D_L00_0015FA90_p; i++) { + for (i = 0; i < D_L00_0015FA90; i++) { angle = fast_add_rotations_c(((float)i + (float)i) * 3.1415927f / - (float)D_L00_0015FA90_p - 3.1415927f, 1.5707964f); + (float)D_L00_0015FA90 - 3.1415927f, 1.5707964f); icon_x = x + GI(D_L00_0015F720_gp) + (int)(GF(D_L00_0015F78C_gp) * fast_cos(angle) * GF(D_L00_0015F7C4_gp)); icon_y = y + GI(D_L00_0015F724_gp) + @@ -510,8 +508,8 @@ int FUN_L00_002382a0(HudElem_p *rec) { if (*(const unsigned char *)suffix == '-') { suffix++; /* Fakematch: touching the frame counter here gives retail's register order for the text position. */ - D_L00_0015F5CC_i++; - D_L00_0015F5CC_i--; + D_L00_0015F5CC++; + D_L00_0015F5CC--; prefix_length = j + 2; break; } From 3aecb951310a8d10c938629d17b2aa4a6073ee1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Sat, 17 Oct 2026 07:11:39 +0000 Subject: [PATCH 16/33] chore: real types for the hud star globals --- src/overlays/shared/ui/hud/hud_keep_visible.c | 39 +++++++++---------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/src/overlays/shared/ui/hud/hud_keep_visible.c b/src/overlays/shared/ui/hud/hud_keep_visible.c index 5b24b457b1..c5f79b44f8 100644 --- a/src/overlays/shared/ui/hud/hud_keep_visible.c +++ b/src/overlays/shared/ui/hud/hud_keep_visible.c @@ -342,11 +342,12 @@ typedef struct { } HudElem_p; extern f32 random_float_between(f32, f32) __asm__("FUN_002132a8"); -extern float D_L00_0017E660_c[][4] __asm__("D_L00_0017E660"); -extern short D_L00_0015F750_gp __asm__("D_L00_0015F750") __attribute__((sda)); -extern short D_L00_0015F754_gp __asm__("D_L00_0015F754") __attribute__((sda)); -extern short D_L00_0015F758_gp __asm__("D_L00_0015F758") __attribute__((sda)); -extern short D_L00_0015F75C_gp __asm__("D_L00_0015F75C") __attribute__((sda)); +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_00235d80_c(HudElem_p *e) __asm__("FUN_L00_00235d80"); void FUN_L00_00236268(HudElem_p *e) { @@ -356,35 +357,31 @@ void FUN_L00_00236268(HudElem_p *e) { FUN_L00_00235d80_c(e); for (i = 0; i < 100; i++) { - v = *(float *)&D_L00_0015F750_gp; + v = star_init_limit0_gp; if (i >= 10) { - v = *(float *)&D_L00_0015F754_gp; - if (i >= 20) v = *(float *)&D_L00_0015F758_gp; + v = star_init_limit1_gp; + if (i >= 20) v = star_init_limit2_gp; } - n = *(int *)&D_L00_0015F75C_gp; + n = D_L00_0015F75C_gp; span = (232.0f - (v + v)) / (float)n; lo = (v - 116.0f) + (float)(i % n) * span; hi = lo + span; - D_L00_0017E660_c[i][0] = random_float_between(v - 17.0f, 17.0f - v); - D_L00_0017E660_c[i][1] = random_float_between(lo, hi); - D_L00_0017E660_c[i][2] = random_float_between(-0.4f, 0.4f); - D_L00_0017E660_c[i][3] = random_float_between(-0.6f, 0.6f); - D_L00_0017E660_c[i][2] += random_float_between(-0.4f, 0.4f); - D_L00_0017E660_c[i][3] += random_float_between(-0.6f, 0.6f); - D_L00_0017E660_c[i][2] += random_float_between(-0.4f, 0.4f); - D_L00_0017E660_c[i][3] += random_float_between(-0.6f, 0.6f); + D_L00_0017E660[i].x = random_float_between(v - 17.0f, 17.0f - v); + 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 n live past the loop gives retail's schedule of the loop body. */ n++; n--; } -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 From 771b50d0eee0bb22714f565bb8c686603101ca71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Sat, 17 Oct 2026 07:15:56 +0000 Subject: [PATCH 17/33] chore: header type for the help screen global --- src/overlays/shared/ui/help/001ff938.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/overlays/shared/ui/help/001ff938.c b/src/overlays/shared/ui/help/001ff938.c index b03c682403..f3c6fd8cb7 100644 --- a/src/overlays/shared/ui/help/001ff938.c +++ b/src/overlays/shared/ui/help/001ff938.c @@ -15,7 +15,7 @@ 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 short D_0015EE18; +extern f32 D_0015EE18; extern unsigned char D_0013D4DC[]; extern unsigned char D_0013F350[]; extern struct { unsigned char b[8]; } D_0015EDB0_s __asm__("D_0015EDB0"); @@ -66,7 +66,7 @@ void FUN_L15_001ff938(void) { if (b0[0x20A4] == 2) { if (D_0015EDB0_s.b[3] != 0) - D_L15_0017C06C[0] = (*(float *)&D_0015EE18) * 1.4f; + D_L15_0017C06C[0] = (*(float *)&(*(short *)&D_0015EE18)) * 1.4f; FUN_L00_002059d8(); FUN_L00_002061f0(); { From 0cc0b6d44a8f4a3b63e2daa62360f34bc7b8b08f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Sat, 17 Oct 2026 07:16:27 +0000 Subject: [PATCH 18/33] chore: real types for the item menu layout globals --- src/overlays/shared/ui/text/002377b8.c | 118 ++++++++++++------------- 1 file changed, 58 insertions(+), 60 deletions(-) diff --git a/src/overlays/shared/ui/text/002377b8.c b/src/overlays/shared/ui/text/002377b8.c index 587f009787..4f78e4b057 100644 --- a/src/overlays/shared/ui/text/002377b8.c +++ b/src/overlays/shared/ui/text/002377b8.c @@ -376,35 +376,33 @@ 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 short D_L00_0015F718_p __asm__("D_L00_0015F718") __attribute__((sda)); -extern short D_L00_0015F71C_p __asm__("D_L00_0015F71C") __attribute__((sda)); -extern short D_L00_0015F720_gp __asm__("D_L00_0015F720") __attribute__((sda)); -extern short D_L00_0015F724_gp __asm__("D_L00_0015F724") __attribute__((sda)); -extern short D_L00_0015F72C_gp __asm__("D_L00_0015F72C") __attribute__((sda)); -extern short D_L00_0015F780_p __asm__("D_L00_0015F780") __attribute__((sda)); -extern short D_L00_0015F78C_gp __asm__("D_L00_0015F78C") __attribute__((sda)); -extern short D_L00_0015F790_gp __asm__("D_L00_0015F790") __attribute__((sda)); -extern short D_L00_0015F794_gp __asm__("D_L00_0015F794") __attribute__((sda)); -extern short D_L00_0015F798_gp __asm__("D_L00_0015F798") __attribute__((sda)); -extern short D_L00_0015F79C; -extern short D_L00_0015F7A0_gp __asm__("D_L00_0015F7A0") __attribute__((sda)); -extern short D_L00_0015F7A4_gp __asm__("D_L00_0015F7A4") __attribute__((sda)); -extern short D_L00_0015F7A8_gp __asm__("D_L00_0015F7A8") __attribute__((sda)); -extern short D_L00_0015F7AC; -extern short D_L00_0015F7B0_gp __asm__("D_L00_0015F7B0") __attribute__((sda)); -extern short D_L00_0015F7B4; -extern short D_L00_0015F7B8; -extern short D_L00_0015F7BC_gp __asm__("D_L00_0015F7BC") __attribute__((sda)); -extern short D_L00_0015F7C0_p __asm__("D_L00_0015F7C0"); -extern short D_L00_0015F7C4_gp __asm__("D_L00_0015F7C4") __attribute__((sda)); +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_p *rec, int *x, int *y) __asm__("FUN_L00_00235a70"); -#define GI(x) (*(int *)&(x)) -#define GF(x) (*(float *)&(x)) int FUN_L00_002382a0(HudElem_p *rec) { char *wr; @@ -419,16 +417,16 @@ int FUN_L00_002382a0(HudElem_p *rec) { unsigned char *q = rec->cnt; char formatted[80]; - open = convert_integer_to_float_c2(q[0]) / convert_integer_to_float_c2(GI(D_L00_0015F780_p)); + open = convert_integer_to_float_c2(q[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_c2(q[1]) / convert_integer_to_float_c2(GI(D_L00_0015F780_p)); + fade = convert_integer_to_float_c2(q[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; { float phase, angle, radius; - phase = convert_integer_to_float_c2(D_L00_0015F5CC % GI(D_L00_0015F7B0_gp)); - phase /= convert_integer_to_float_c2(GI(D_L00_0015F7B0_gp)); + 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; @@ -440,38 +438,38 @@ int FUN_L00_002382a0(HudElem_p *rec) { x = rec->unk50; y = rec->unk54; FUN_L00_00235a70_c3(rec, &x, &y); - half_w = GI(D_L00_0015F718_p) / 2; - half_h = GI(D_L00_0015F71C_p) / 2; + half_w = D_L00_0015F718_gp / 2; + half_h = D_L00_0015F71C_gp / 2; 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 + GI(D_L00_0015F718_p), - y + GI(D_L00_0015F71C_p), -half_w, -half_h, alpha); - draw_hud_sprite_c2(find_valid_animation_frame_index_alt(0xe934, 0), x + GI(D_L00_0015F718_p), + 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 + GI(D_L00_0015F71C_p), half_w, -half_h, alpha); + 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 + GI(D_L00_0015F720_gp) + - (int)(GF(D_L00_0015F78C_gp) * fast_cos(angle) * GF(D_L00_0015F7C4_gp)); - icon_y = y + GI(D_L00_0015F724_gp) + - (int)(GF(D_L00_0015F78C_gp) * fast_sin(angle)); - if (rec->unk74 == i && ((E_238C30 **)D_L00_0015FAC0)[GI(D_L00_0015F72C_gp)][i].id != 0) + 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)[GI(D_L00_0015F72C_gp)][i].id != 0) { + 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 * GF(D_L00_0015F7C0_p)); + 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)[GI(D_L00_0015F72C_gp)][i].id, - ((unsigned char *)D_0013E520)[((E_238C30 **)D_L00_0015FAC0)[GI(D_L00_0015F72C_gp)][i].item] ? 4 : 0), icon_x, icon_y, 1, icon_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 = rec->unk74; - if (selected >= 0 && *(int *)(((char **)D_L00_0015FAC0)[GI(D_L00_0015F72C_gp)] + selected * 0x1C) != 0) { - color = fast_tween_color_c(GI(D_L00_0015F798_gp), GI(D_L00_0015F79C), open * fade); + 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); @@ -481,18 +479,18 @@ int FUN_L00_002382a0(HudElem_p *rec) { item = *(int *)(D_0013D428 + id * 4); sprintf(formatted, D_L00_0015F7C8, item, *(unsigned short *)(wr + 0xE)); if (item != 0) - shadow = fast_tween_color_c(GI(D_L00_0015F7A8_gp), GI(D_L00_0015F7AC), open * fade); + shadow = fast_tween_color_c(D_L00_0015F7A8_gp, D_L00_0015F7AC, open * fade); else - shadow = fast_tween_color_c(GI(D_L00_0015F7A0_gp), GI(D_L00_0015F7A4_gp), open * fade); - font_print_center(x + GI(D_L00_0015F720_gp) + 1, y + GI(D_L00_0015F724_gp) + 13, color, formatted, -1); - font_print_center(x + GI(D_L00_0015F720_gp), y + GI(D_L00_0015F724_gp) + 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_c(GI(D_L00_0015F790_gp), GI(D_L00_0015F794_gp), open * fade); + shadow = fast_tween_color_c(D_L00_0015F790_gp, D_L00_0015F794_gp, open * fade); { int item, id; - item = *(int *)(((char **)D_L00_0015FAC0)[GI(D_L00_0015F72C_gp)] + selected * 0x1C + 0x18); + item = *(int *)(((char **)D_L00_0015FAC0)[D_L00_0015F72C_gp] + selected * 0x1C + 0x18); if (((unsigned char *)D_0013E520)[item]) id = ((TI_238C30 *)D_L00_00179AC0)[item].h48; else @@ -525,28 +523,28 @@ int FUN_L00_002382a0(HudElem_p *rec) { } } } - text_y = y + GI(D_L00_0015F724_gp); + text_y = y + D_L00_0015F724_gp; { int id; char *wr; id = *(int *)((char *)D_00141EA0 + selected * 4); wr = ((char *)&D_L00_001C40B0) + id * 24; if (*(unsigned short *)(wr + 8) != 0) - text_y += GI(D_L00_0015F7B4); + text_y += D_L00_0015F7B4; else if (prefix_length != 0) - text_y += GI(D_L00_0015F7B8); + text_y += D_L00_0015F7B8; else - text_y += GI(D_L00_0015F7BC_gp); + text_y += D_L00_0015F7BC_gp; } if (prefix_length != 0) { - font_print_center(x + GI(D_L00_0015F720_gp) + 1, text_y + 1, color, (void *)text, prefix_length); - font_print_center(x + GI(D_L00_0015F720_gp), text_y, shadow, (void *)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(x + GI(D_L00_0015F720_gp) + 1, text_y + 1, color, (void *)suffix, -1); - font_print_center(x + GI(D_L00_0015F720_gp), text_y, shadow, (void *)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(x + GI(D_L00_0015F720_gp) + 1, text_y + 1, color, (void *)text, -1); - font_print_center(x + GI(D_L00_0015F720_gp), text_y, shadow, (void *)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); } } return rec->w; From 5a997410285e9b571176fb6d866a618840b9b2f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Sat, 17 Oct 2026 07:17:59 +0000 Subject: [PATCH 19/33] chore: real types and names for bolt thief globals --- .../l08/gameplay/entities/bolt_thief.c | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/src/overlays/l08/gameplay/entities/bolt_thief.c b/src/overlays/l08/gameplay/entities/bolt_thief.c index 7a03ac183d..e5f8ee4594 100644 --- a/src/overlays/l08/gameplay/entities/bolt_thief.c +++ b/src/overlays/l08/gameplay/entities/bolt_thief.c @@ -1963,7 +1963,7 @@ 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_p __asm__("D_L08_00161CB8"); +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); @@ -1980,7 +1980,7 @@ 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 s32 D_0013DF38_p[] __asm__("D_0013DF38"); +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"); @@ -2013,7 +2013,6 @@ extern char D_0013F490[]; 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_0014C150_4BE8[][16] __asm__("D_0014C050"); extern int D_L08_00174658_lui __asm__("D_L08_00174658") __attribute__((section(".data"))); void FUN_L08_002e3870(struct Moby *m) { @@ -2030,13 +2029,13 @@ void FUN_L08_002e3870(struct Moby *m) { switch (m->oclass) { case 0x279: - m->scale = m->pclass->scale * *(float *)&D_L08_00161CB4_gp; + m->scale = m->pclass->scale * D_L08_00161CB4_gp; break; case 0x3DC: - m->scale = m->pclass->scale * *(float *)&D_L08_00161CB8_p; + m->scale = m->pclass->scale * D_L08_00161CB8; break; case 0x3DD: - m->scale = m->pclass->scale * *(float *)&D_L08_00161CBC_gp; + m->scale = m->pclass->scale * D_L08_00161CBC_gp; break; } linked = 0; @@ -2229,7 +2228,7 @@ void FUN_L08_002e3870(struct Moby *m) { m->alpha = (fast_vec_dist(b, &m->pos) + lim) * 128.0f / (lim + lim); } if (D_L08_00161CC4_gp != 0) { - m->scale = m->pclass->scale * *(float *)&D_L08_00161CB4_gp * (fast_vec_dist(b, &m->pos) + lim) / (lim + lim); + m->scale = m->pclass->scale * D_L08_00161CB4_gp * (fast_vec_dist(b, &m->pos) + lim) / (lim + lim); } } else { int value; @@ -2283,11 +2282,11 @@ void FUN_L08_002e3870(struct Moby *m) { D_0014D590[current_level_index][src->id].bolts += value; } D_0015ED98 += value; - D_0013DF38_p[current_level_index] += 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 (m < D_L08_0015FFDC) { D_L08_001BADD0.killed[(short)m->save_id] = m->mission + 2; - if (m->mission == 0xFF || (D_L08_0015FC88_macro[m->mission] != 0xFF && D_0014C150_4BE8[current_level_index][m->mission] == 0xFF)) { + if (m->mission == 0xFF || (D_L08_0015FC88_macro[m->mission] != 0xFF && D_0014C050[m->mission + current_level_index * 16] == 0xFF)) { D_L08_001BBA30.killed[(short)m->save_id] = m->mission + 2; } } @@ -2324,7 +2323,7 @@ void FUN_L08_002e3870(struct Moby *m) { D_0014D590[current_level_index][src->id].bolts += value; } D_0015ED98 += value; - D_0013DF38_p[current_level_index] += value; + level_bolts[current_level_index] += value; mark_moby_for_removal_c3(m); return; } @@ -2454,12 +2453,12 @@ 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 float D_L08_00161CB8 __attribute__((sda)); +extern float 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 float D_L08_00161CB4 __attribute__((sda)); extern short D_L08_00161C70 __attribute__((sda)); extern short D_L08_00161C74 __attribute__((sda)); extern void euler_rotation_matrix(float *, float *) __asm__("FUN_001fa050"); @@ -2483,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 = *(float *)&D_L08_00161C68 * D_L08_00161CB8; + sy = *(float *)&D_L08_00161C74 * D_L08_00161CB8; + sz = *(float *)&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 = *(float *)&D_L08_00161C6C * D_L08_00161CBC; + sy = *(float *)&D_L08_00161C78 * D_L08_00161CBC; + sz = *(float *)&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 = *(float *)&D_L08_00161C64 * D_L08_00161CB4; + sy = *(float *)&D_L08_00161C70 * D_L08_00161CB4; + sz = *(float *)&D_L08_00161C7C * D_L08_00161CB4; break; } euler_rotation_matrix(b, (float *)(data + 0x10)); From bc677401a0cff32e4104a8a6fd07e3eecaab300d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Sat, 17 Oct 2026 07:22:54 +0000 Subject: [PATCH 20/33] chore: header names and types for more shared globals --- .../l07/gameplay/entities/taxi_platform.c | 6 ++-- src/overlays/l08/gameplay/entities/bomb.c | 4 +-- src/overlays/l12/gameplay/entities/003054b0.c | 4 +-- src/overlays/l13/gameplay/entities/rocket.c | 27 +++++++-------- src/overlays/shared/gameplay/entities/bomb.c | 6 ++-- .../shared/gameplay/entities/trespasser.c | 34 +++++++++---------- src/overlays/shared/ui/help/001ff938.c | 6 ++-- 7 files changed, 41 insertions(+), 46 deletions(-) diff --git a/src/overlays/l07/gameplay/entities/taxi_platform.c b/src/overlays/l07/gameplay/entities/taxi_platform.c index 2029cced90..9761a0f5b1 100644 --- a/src/overlays/l07/gameplay/entities/taxi_platform.c +++ b/src/overlays/l07/gameplay/entities/taxi_platform.c @@ -2613,7 +2613,7 @@ 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_p __asm__("D_L07_0015F5CC"); +extern int D_L07_0015F5CC; extern int D_L07_001612D8; extern int DebugPrint_alt() __asm__("FUN_001e93b0"); extern int FUN_001f0b58(void); @@ -2750,10 +2750,10 @@ void FUN_L07_0030f5f0(unsigned char *moby) { } else { f = 1.0f; } - if (D_L07_0015F5CC_p % 45 == *(short *)(moby + 0xB2) && random_integer_below(2) == 0) { + if (D_L07_0015F5CC % 45 == *(short *)(moby + 0xB2) && random_integer_below(2) == 0) { func_L00_002A5158_30D8E8((*(Rec_30D8E8_p * *)&D_L07_001612D0), D_L07_001612D8, 1, F(moby, 0x10), F(moby, 0x14), f, s); } - if (D_L07_0015F5CC_p % ((rand() & 7) + 20) == 0) { + if (D_L07_0015F5CC % ((rand() & 7) + 20) == 0) { float size = random_float_between_c2(1.5f, 2.4f); pos[0] += random_float_between_c2(-0.15f, 0.15f); pos[1] += random_float_between_c2(-0.15f, 0.15f); diff --git a/src/overlays/l08/gameplay/entities/bomb.c b/src/overlays/l08/gameplay/entities/bomb.c index d9c71dba3f..a84dd225a8 100644 --- a/src/overlays/l08/gameplay/entities/bomb.c +++ b/src/overlays/l08/gameplay/entities/bomb.c @@ -1520,7 +1520,7 @@ 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_p[] __asm__("D_L08_001675C0"); +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"); @@ -1571,7 +1571,7 @@ void FUN_L08_002dabf0(struct Moby *moby) { damage = 0.0f; func_L00_00264B40_x(moby, D_L08_001619AC_gp, 3.0f, d->blk160); if (moby->visible != 0) { - if (fast_vec_dist(&moby->pos, D_L08_001675C0_p) < 29.0f) { + if (fast_vec_dist(&moby->pos, D_L08_001675C0) < 29.0f) { FUN_L00_0025a120(moby); moby->shadow_range = 0x17; } diff --git a/src/overlays/l12/gameplay/entities/003054b0.c b/src/overlays/l12/gameplay/entities/003054b0.c index 6b05d90e87..60332862a3 100644 --- a/src/overlays/l12/gameplay/entities/003054b0.c +++ b/src/overlays/l12/gameplay/entities/003054b0.c @@ -482,7 +482,7 @@ void FUN_L12_003064e8(char *moby) { } /* 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 int D_L12_0015F5CC_p __asm__("D_L12_0015F5CC"); +extern int D_L12_0015F5CC; extern unsigned char * D_L12_0015FFD8; void FUN_L12_00306828(char *moby) { @@ -509,7 +509,7 @@ void FUN_L12_00306828(char *moby) { { period = scale_game_frames(0xAA); divisor = convert_integer_to_float(period); - phase = (float)(D_L12_0015F5CC_p % period) / divisor; + phase = (float)(D_L12_0015F5CC % period) / divisor; sine = fast_sin((phase + phase) * 3.1415927f + -3.1415927f); color = sine * 70.0f; red = truncate_float_to_s32(color); diff --git a/src/overlays/l13/gameplay/entities/rocket.c b/src/overlays/l13/gameplay/entities/rocket.c index 9ee16e1a8c..e3c939b07d 100644 --- a/src/overlays/l13/gameplay/entities/rocket.c +++ b/src/overlays/l13/gameplay/entities/rocket.c @@ -799,7 +799,7 @@ typedef struct { u8 unk400[1]; } Vars_309330; -extern char D_L13_001670C0_p[] __asm__("D_L13_001670C0"); +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"); @@ -807,14 +807,11 @@ 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 D_L13_00161E74_gp __asm__("D_L13_00161E74") __attribute__((sda)); -extern int D_L13_00161E78_gp __asm__("D_L13_00161E78") __attribute__((sda)); 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 short D_L13_00161E58_gp __asm__("D_L13_00161E58") __attribute__((sda)); 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"); @@ -830,9 +827,9 @@ 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_00161EE8_309330 __asm__("D_L13_00161E58") __attribute__((sda)); -extern float D_L13_00161F04_309330 __asm__("D_L13_00161E74") __attribute__((sda)); -extern float D_L13_00161F08_309330 __asm__("D_L13_00161E78") __attribute__((sda)); +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"); void FUN_L13_00307e98(struct Moby *moby) { @@ -849,7 +846,7 @@ void FUN_L13_00307e98(struct Moby *moby) { 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_p) < 28.0f) { + if (moby->visible != 0 && fast_vec_dist(&moby->pos, D_L13_001670C0) < 28.0f) { FUN_L00_0025a120(moby); moby->shadow_range = 0x16; } @@ -864,9 +861,9 @@ void FUN_L13_00307e98(struct Moby *moby) { FUN_L01_0026d930(&vars->ctl); vars->ctl.unk8 = 2.0f; vars->ctl.unkC = 0.5f; - vars->ctl.unk0_p = func_001FA898_r(D_L13_00161EE8_309330 * 716.8f); - vars->ctl.unk4 = D_L13_00161EE8_309330 * 0.7f; - vars->ctl.unk24 = D_L13_00161F08_309330 * frame_time * random_float_between(0.95f, 1.05f); + vars->ctl.unk0_p = 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; @@ -876,7 +873,7 @@ void FUN_L13_00307e98(struct Moby *moby) { &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_00161F04_309330 < dist) { + 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; @@ -937,7 +934,7 @@ void FUN_L13_00307e98(struct Moby *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_00161F04_309330) { + } 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) { @@ -1019,7 +1016,7 @@ void FUN_L13_00307e98(struct Moby *moby) { if (moby->prev_seq != 3) { blend_moby_animation(moby, 3, 0, scale_game_frames(10)); } - } else if (dist < D_L13_00161F04_309330) { + } 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)); @@ -1048,7 +1045,7 @@ void FUN_L13_00307e98(struct Moby *moby) { 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_00161F04_309330) { + } 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) { diff --git a/src/overlays/shared/gameplay/entities/bomb.c b/src/overlays/shared/gameplay/entities/bomb.c index 2451901caf..879c631cde 100644 --- a/src/overlays/shared/gameplay/entities/bomb.c +++ b/src/overlays/shared/gameplay/entities/bomb.c @@ -1026,7 +1026,7 @@ 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"); -extern char D_0013E520_c[] __asm__("D_0013E520"); +#include "rnc/gameplay/state/item_state.h" char *FUN_L00_002caf70(char *a, char *vec, char *b, float unk18, float unk1C, float yaw, float pitch) { float tv[4]; @@ -1082,7 +1082,7 @@ char *FUN_L00_002caf70(char *a, char *vec, char *b, float unk18, float unk1C, fl *(int *)(d + 0x10) = 0; *(int *)(d + 0x14) = 0; r2 = scale_game_frames_c2(0x23); - p = (unsigned char *)((char *)&D_0013E520_c); + p = (unsigned char *)((char *)item_text_variant); r2 = r2 + p[0xF] * 10; *(int *)(d + 0x28) = 0; *(short *)(d + 0x24) = r2; @@ -1112,7 +1112,7 @@ char *FUN_L00_002caf70(char *a, char *vec, char *b, float unk18, float unk1C, fl r3 = FUN_L00_00257b90_c2(r, r2); FUN_L00_0026dd20(m + 0x10, (char *)v, 0x7F2F4F6F, r3, 30000.0f); } while (k >= 0); - p = (unsigned char *)((char *)&D_0013E520_c); + p = (unsigned char *)((char *)item_text_variant); if (p[0xF] == 0) { FUN_L00_002cbcc0_c(m, 0); mark_moby_for_removal_c2(m); diff --git a/src/overlays/shared/gameplay/entities/trespasser.c b/src/overlays/shared/gameplay/entities/trespasser.c index c95661f16f..9b4422f913 100644 --- a/src/overlays/shared/gameplay/entities/trespasser.c +++ b/src/overlays/shared/gameplay/entities/trespasser.c @@ -1165,10 +1165,8 @@ typedef struct { s32 timer58; s32 delay; } GloveVars_2c1ad0; -extern struct { u8 pad0[0x11]; u8 unk11; } D_0013E520_2c1ad0 __asm__("D_0013E520"); -extern struct { u8 pad0[0x88]; u16 deliveries; u16 unk8A; u32 levels; } D_00141680_s __asm__("D_00141680"); -extern struct { u8 pad0[0x18]; s32 moby; u8 pad1C[4]; Vec4 point; } coll_hit_2c1ad0 __asm__("D_L00_00173E40"); -extern Vec4 D_L00_00166DC0_v __asm__("D_L00_00166DC0"); +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"))); @@ -1234,7 +1232,7 @@ void FUN_L00_002c1ad0(struct Moby *moby) { if (vars->held != 0 && !hero.unk20AC) { out = (float *)vars->held->pvars; arc.q = 0; - arc.f[0] = frame_time_macro * (D_0013E520_2c1ad0.unk11 ? ((controller_state.held & 5) ? 12.0f : 4.0f) : ((controller_state.held & 5) ? 6.0f : 4.0f)); + 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; @@ -1247,7 +1245,7 @@ void FUN_L00_002c1ad0(struct Moby *moby) { add_vector_xyz(&target, &target, &pos); if (controller_state.held & 5) { probe.q = 0; - probe.f[2] = D_0013E520_2c1ad0.unk11 ? ((controller_state.held & 5) ? 12.0f : 4.0f) : ((controller_state.held & 5) ? 6.0f : 4.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; rotate_vector_2c1ad0(&arc, &arc, matrix); @@ -1256,23 +1254,23 @@ void FUN_L00_002c1ad0(struct Moby *moby) { 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, D_0013E520_2c1ad0.unk11 ? ((controller_state.held & 5) ? 12.0f : 4.0f) : ((controller_state.held & 5) ? 6.0f : 4.0f), angle, slope); + 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); { float distance = vector_length_xy_2c1ad0(&arc); float z = arc.f[2]; if (distance != 0.0f) horizontal = z / distance; else horizontal = z / 0.01f; } - root = square_root(frame_time_sq_macro * 9.8f * (D_0013E520_2c1ad0.unk11 ? ((controller_state.held & 5) ? 12.0f : 4.0f) : ((controller_state.held & 5) ? 6.0f : 4.0f)) * 0.5f); + 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 (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_v, &arc); - if (collision_line(&D_L00_00166DC0_v, &probe, 2, moby, 0) && coll_hit_2c1ad0.moby != (s32)hero.moby) { - qcopy(&target, &coll_hit_2c1ad0.point); + 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(target.f[0] - pos.f[0], target.f[1] - pos.f[1]); } @@ -1280,11 +1278,11 @@ void FUN_L00_002c1ad0(struct Moby *moby) { 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_v); + add_vector_xyz(&target, &target, &D_L00_00166DC0); } } } - FUN_L00_002c1928_f(frame_time_sq_macro * 9.8f, 1.0f, D_0013E520_2c1ad0.unk11 ? ((controller_state.held & 5) ? 12.0f : 4.0f) : ((controller_state.held & 5) ? 6.0f : 4.0f), pos.f, target.f, out); + 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: @@ -1300,15 +1298,15 @@ 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_s.deliveries <= 0xfffe) - ++D_00141680_s.deliveries; + if (D_00141680_2c1ad0.deliveries <= 0xfffe) + ++D_00141680_2c1ad0.deliveries; { s32 frames = scale_game_frames(D_0015EEA4_macro); frames /= 600; - if (D_00141680_s.unk8A < frames) - D_00141680_s.unk8A = scale_game_frames(D_0015EEA4_macro) / 600; + if (D_00141680_2c1ad0.unkA2 < frames) + D_00141680_2c1ad0.unkA2 = scale_game_frames(D_0015EEA4_macro) / 600; } - D_00141680_s.levels = (D_00141680_s.levels | (1u << current_level_index_macro)) | 0x80000000; + 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->timer54 = scale_game_frames(10); diff --git a/src/overlays/shared/ui/help/001ff938.c b/src/overlays/shared/ui/help/001ff938.c index f3c6fd8cb7..8355873b31 100644 --- a/src/overlays/shared/ui/help/001ff938.c +++ b/src/overlays/shared/ui/help/001ff938.c @@ -18,7 +18,7 @@ extern s32 truncate_float_to_s32(f32) __asm__("func_001FA6D0"); extern f32 D_0015EE18; extern unsigned char D_0013D4DC[]; extern unsigned char D_0013F350[]; -extern struct { unsigned char b[8]; } D_0015EDB0_s __asm__("D_0015EDB0"); +#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); @@ -65,7 +65,7 @@ void FUN_L15_001ff938(void) { FUN_L00_002484e0(b0 + 0x80); if (b0[0x20A4] == 2) { - if (D_0015EDB0_s.b[3] != 0) + if ((&big_head_cheat_enabled)[3] != 0) D_L15_0017C06C[0] = (*(float *)&(*(short *)&D_0015EE18)) * 1.4f; FUN_L00_002059d8(); FUN_L00_002061f0(); @@ -81,7 +81,7 @@ void FUN_L15_001ff938(void) { b1 = ((char *)&D_0013F350); if (b1[0x20A4] == 3) { - if (D_0015EDB0_s.b[1] != 0) + if ((&big_head_cheat_enabled)[1] != 0) D_L15_0017C1CC[0] = 1.9f; alpha = 0x80; period = scale_game_frames(0xAA); From 3efb114c9c9f4859ec0df876ae71f57151617392 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Sat, 17 Oct 2026 07:26:29 +0000 Subject: [PATCH 21/33] chore: last globals get one name and type each --- scripts/test_public_tools.py | 2 +- src/overlays/l07/gameplay/entities/taxi_platform.c | 6 ++---- src/overlays/l08/gameplay/entities/bolt_thief.c | 10 +++++----- src/overlays/l08/gameplay/entities/bomb.c | 6 +++--- src/overlays/shared/gameplay/entities/00295100.c | 6 +++--- src/overlays/shared/gameplay/entities/bomb.c | 7 +++---- src/overlays/shared/rendering/00245c28.c | 4 ++-- src/overlays/shared/rendering/002712b8.c | 4 ++-- src/overlays/shared/ui/text/002377b8.c | 14 ++++---------- 9 files changed, 25 insertions(+), 34 deletions(-) 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/overlays/l07/gameplay/entities/taxi_platform.c b/src/overlays/l07/gameplay/entities/taxi_platform.c index 9761a0f5b1..fba52cfce3 100644 --- a/src/overlays/l07/gameplay/entities/taxi_platform.c +++ b/src/overlays/l07/gameplay/entities/taxi_platform.c @@ -2604,7 +2604,6 @@ struct Tgt_3109D0_p { }; extern Rec_30D8E8 * D_L07_001612D0; -extern char *D_L07_0015FFD8; extern char D_0013E533[]; extern char D_L07_002117F8[]; extern char D_L07_00211838[]; @@ -2650,7 +2649,6 @@ void FUN_L07_0030f308_c(char *moby, char *obj, int state, int anim, int seq, int 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"); -extern int func_001F9908_30D8E8(int *) __asm__("FUN_001f9740"); #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) @@ -2680,7 +2678,7 @@ void FUN_L07_0030f5f0(unsigned char *moby) { FUN_L00_00263ac8(moby, 0, data + 0x150, 2.2f); if (moby[0x20] == 0) { if (FUN_L07_0030ed30_c((char *)moby, data)) { - DebugPrint_alt(D_L07_002117F8, (int)((char *)moby - D_L07_0015FFD8) >> 8); + DebugPrint_alt(D_L07_002117F8, (int)((char *)moby - (char *)level_mobys) >> 8); mark_moby_for_removal_c4(moby); return; } @@ -2689,7 +2687,7 @@ void FUN_L07_0030f5f0(unsigned char *moby) { FUN_L07_002886d8(moby, &tgt, 30.0f); FUN_L07_0030e998_c((char *)moby, data, (float *)(data + 0x20)); FUN_L00_0025d538(moby, data + 0x60); - wander = func_001F9908_30D8E8((int *)(data + 0x134)) != 0; + wander = tick_countdown_32_alt((int *)(data + 0x134)) != 0; if (*(int *)(data + 0x110) != 0 && moby[0x20] >= 7) { char *p = *(char **)(data + 0x148); inside = FUN_L00_00259740(&tgt, p + 0x10, *(int *)p) != 0; diff --git a/src/overlays/l08/gameplay/entities/bolt_thief.c b/src/overlays/l08/gameplay/entities/bolt_thief.c index e5f8ee4594..7db4fb3019 100644 --- a/src/overlays/l08/gameplay/entities/bolt_thief.c +++ b/src/overlays/l08/gameplay/entities/bolt_thief.c @@ -1943,7 +1943,7 @@ typedef struct { char pad10[0x10]; float n[4]; /* 0x20 */ } CollPos_4BE8; -extern CollPos_4BE8 D_L08_00174660; +extern float D_L08_00174660[]; extern KillFlags_4BE8 D_L08_001BADD0; extern KillFlags_4BE8 D_L08_001BBA30; extern struct Moby *D_L08_0015FFDC; @@ -2050,7 +2050,7 @@ void FUN_L08_002e3870(struct Moby *m) { fast_vec_scale_c(c, &m->rot_row2, -2.0f); add_vector_xyz(c, c, &m->pos); if (FUN_001efa68(b, c, 2, 0, 0) != 0) { - CollPos_4BE8 *hit = &D_L08_00174660; + CollPos_4BE8 *hit = (CollPos_4BE8 *)D_L08_00174660; qcopy(d->v0_p, hit->pos); linked = ((int *)hit)[-2]; fast_vec_normalize_c2(a, hit->n, 1.0f); @@ -2336,11 +2336,11 @@ void FUN_L08_002e3870(struct Moby *m) { break; } if (FUN_L00_001f0d60(0.25f, &m->pos, 0x22, m) != 0) { - subtract_vector_xyz(a, &m->pos, D_L08_00174660.pos); + subtract_vector_xyz(a, &m->pos, ((CollPos_4BE8 *)D_L08_00174660)->pos); FUN_L00_001ff660(d->v40, d->v40, a); if (fast_arc_tan(a[2], func_001F9CE8_2E16A0(a)) < 0.7853982f - && fast_arc_tan(((Coll_4BE8 *)((char *)&D_L08_00174660 - 0x20))->n[2], func_001F9CE8_2E16A0(D_L08_00174660.n)) < 0.7853982f) { - Coll_4BE8 *cl = (Coll_4BE8 *)((char *)&D_L08_00174660 - 0x20); + && 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 *cl = (Coll_4BE8 *)((char *)D_L08_00174660 - 0x20); int n; float inv; diff --git a/src/overlays/l08/gameplay/entities/bomb.c b/src/overlays/l08/gameplay/entities/bomb.c index a84dd225a8..8859bf3c40 100644 --- a/src/overlays/l08/gameplay/entities/bomb.c +++ b/src/overlays/l08/gameplay/entities/bomb.c @@ -1554,7 +1554,7 @@ extern void effects_update_2D5FA8_c(struct Moby *, short *) __asm__("FUN_L00_002 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 Cam_DBF68 D_L08_00167500_c __asm__("D_L08_00167480"); +extern char camera_state_bytes[] __asm__("D_L08_00167480"); void FUN_L08_002dabf0(struct Moby *moby) { Data_DBF68 *d = (Data_DBF68 *)moby->pvars; @@ -1724,7 +1724,7 @@ void FUN_L08_002dabf0(struct Moby *moby) { func_L00_002592B0_x(fast_arc_tan_c2(target->pos.x - moby->pos.x, target->pos.y - moby->pos.y), moby, d->blk12C, 0.02f, 0.3f, 0.2f); if (dist < 20.0f && 8.0f < dist && tick_countdown_32_alt(&d->i128) != 0) { - Cam_DBF68 *cam = &D_L08_00167500_c; + 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; } @@ -1753,7 +1753,7 @@ void FUN_L08_002dabf0(struct Moby *moby) { if (moby->anim_flags & 2) { Cam_DBF68 *cam; if (vector_distance_xy_alt(&moby->pos, &target->pos) < 6.0f - || (cam = &D_L08_00167500_c, + || (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 = d->p120; if ((d->p120 = (struct Moby *)FUN_L08_002daa10_c((char *)moby)) == 0) { diff --git a/src/overlays/shared/gameplay/entities/00295100.c b/src/overlays/shared/gameplay/entities/00295100.c index fbcd41e4e5..5a90404f6a 100644 --- a/src/overlays/shared/gameplay/entities/00295100.c +++ b/src/overlays/shared/gameplay/entities/00295100.c @@ -840,7 +840,7 @@ extern s32 D_L00_0015F40C_macro __asm__("D_L00_0015F40C") __attribute__((section 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 gs_layout_macro[6] __asm__("D_0015EE78") __attribute__((section(".sdata"))); +extern s32 D_0015EE78_macro[6] __asm__("D_0015EE78") MACRO_ADDR; extern void flush_cache(s32) __asm__("FUN_00118a80"); extern void sound_stop_all_sounds(void) __asm__("FUN_0022dcd0"); extern void music_stop(void) __asm__("FUN_00215ee8"); @@ -874,7 +874,7 @@ void FUN_L00_002995d0(s32 sector, s32 size, s32 language) { large_count = D_0015ED80 != 0 ? 0xE : 0xD; small_count = D_0015ED80 != 0 ? 0xE : 0x11; source = D_L00_00161058_macro; - gs_address = gs_layout_macro[4]; + gs_address = D_0015EE78_macro[4]; i = 0; while (i < large_count) { sceGsSetDefLoadImage(image, gs_address >> 8, 2, 1, 0, 0, 0x80, 0x80); @@ -885,7 +885,7 @@ void FUN_L00_002995d0(s32 sector, s32 size, s32 language) { source += 0xC000; wait_for_graphics_pipeline_idle(0, 0); } - gs_address = gs_layout_macro[0]; + gs_address = D_0015EE78_macro[0]; j = 0; while (j < small_count) { sceGsSetDefLoadImage(image, gs_address >> 8, 1, 0, 0, 0, 0x40, 0x40); diff --git a/src/overlays/shared/gameplay/entities/bomb.c b/src/overlays/shared/gameplay/entities/bomb.c index 879c631cde..263d7b45fa 100644 --- a/src/overlays/shared/gameplay/entities/bomb.c +++ b/src/overlays/shared/gameplay/entities/bomb.c @@ -1002,12 +1002,11 @@ 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 float D_L00_0015F580[] __attribute__((section(".sdata"))); +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_002141f8_c2(char *) __asm__("FUN_002141f8"); 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"); @@ -1068,7 +1067,7 @@ char *FUN_L00_002caf70(char *a, char *vec, char *b, float unk18, float unk1C, fl if (b != 0) { int rr; qcopy(d, b + 0x10); - rr = FUN_002141f8_c2(b); + rr = (int)FUN_002141f8(b); if (rr != 0) { *(float *)(d + 0x8) = *(float *)(d + 0x8) + *(float *)(rr + 0x10); } else { @@ -1132,7 +1131,7 @@ char *FUN_L00_002caf70(char *a, char *vec, char *b, float unk18, float unk1C, fl } else { FUN_L00_0026daa0(m, 0x2F4F7F7F, *(short *)(d + 0x24), -1, *(float *)&D_L00_00161888); for (i = 0; i < 17; i++) { - q = (char *)FUN_L00_00275158(m + 0x10, (char *)D_L00_0015F580, 1, 0.0f); + q = (char *)FUN_L00_00275158(m + 0x10, D_L00_0015F580, 1, 0.0f); if (q != 0) { *(float *)(q + 0xC) = random_float_between_c2(*(float *)&D_L00_00161870, *(float *)&D_L00_00161874); fi = convert_integer_to_float_c(i); diff --git a/src/overlays/shared/rendering/00245c28.c b/src/overlays/shared/rendering/00245c28.c index 63912d1849..dfd2b58294 100644 --- a/src/overlays/shared/rendering/00245c28.c +++ b/src/overlays/shared/rendering/00245c28.c @@ -356,7 +356,7 @@ extern char D_L00_0015FE00[]; extern char D_L00_001E8B00[]; extern float D_L00_00182810[]; extern float D_L00_00182A70[]; -extern int *D_L00_00173E08[]; +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(); @@ -422,7 +422,7 @@ void FUN_L00_002464a8(void) { gl = &D_L00_001841F0; gl->unk28 = 1; heap_tag = (int)D_L00_0015FE00; - archive_base = D_L00_00173E08[0]; + archive_base = ((int **)&D_L00_00173E08)[0]; archive = (int *)((int)archive_base + 0x9A800); scratch = e[1] << 7; load(archive, e[0], e[1]); diff --git a/src/overlays/shared/rendering/002712b8.c b/src/overlays/shared/rendering/002712b8.c index ad7e67446e..22dea5942e 100644 --- a/src/overlays/shared/rendering/002712b8.c +++ b/src/overlays/shared/rendering/002712b8.c @@ -2100,13 +2100,13 @@ typedef struct { P2_276078 e[20]; } T1_276078; -extern s32 D_L00_00173E08_lui __asm__("D_L00_00173E08") __attribute__((section(".data"))); +extern s32 D_L00_00173E08 __attribute__((section(".data"))); extern T1_276078 D_00137B80; extern u8 D_L00_001602D0[]; void Load(s32, s32, s32) __asm__("FUN_00216828"); s32 stash_send_data(s32, s32, s32, void *) __asm__("FUN_00232e40"); void FUN_L00_00276078(void) { - s32 h = D_L00_00173E08_lui; + s32 h = D_L00_00173E08; s32 i; for (i = 0; i < 20; i++) { s32 sz = D_00137B80.e[i].n << 7; diff --git a/src/overlays/shared/ui/text/002377b8.c b/src/overlays/shared/ui/text/002377b8.c index 4f78e4b057..26d4bb172e 100644 --- a/src/overlays/shared/ui/text/002377b8.c +++ b/src/overlays/shared/ui/text/002377b8.c @@ -351,20 +351,14 @@ typedef struct { void *unk80; } HudElem_p; -typedef struct { - char pad_00[0x38]; - unsigned short x38; - char pad_3A[0x4C - 0x3A]; -} SrcElem_p; 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 SrcElem_p D_L00_00179AC0[]; +extern E00237ae8 item_defs[] __asm__("D_L00_00179AC0"); extern char *get_help_message_text(s32) __asm__("func_001FDD10"); -extern char D_0013D428[]; #include "rnc/overlay/level_labels.h" extern char D_L00_0015F7C8[]; extern f32 convert_integer_to_float_c2(s32) __asm__("func_001FA6C0"); @@ -476,7 +470,7 @@ int FUN_L00_002382a0(HudElem_p *rec) { wr = ((char *)&D_L00_001C40B0) + id * 24; if (*(unsigned short *)(wr + 8) != 0) { int shadow, item; - item = *(int *)(D_0013D428 + id * 4); + item = weapon_ammo_counts[id]; sprintf(formatted, D_L00_0015F7C8, item, *(unsigned short *)(wr + 0xE)); if (item != 0) shadow = fast_tween_color_c(D_L00_0015F7A8_gp, D_L00_0015F7AC, open * fade); @@ -492,9 +486,9 @@ int FUN_L00_002382a0(HudElem_p *rec) { 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 *)D_L00_00179AC0)[item].h48; + id = ((TI_238C30 *)item_defs)[item].h48; else - id = ((TI_238C30 *)D_L00_00179AC0)[item].h46; + id = ((TI_238C30 *)item_defs)[item].h46; text = get_help_message_text(id); } if (text == 0) return rec->w; From 87b139db81feedcefdf61bdea83ca95186bfa85e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Sat, 17 Oct 2026 07:35:31 +0000 Subject: [PATCH 22/33] chore: keep the explicit sdata section on the gs layout global --- src/overlays/shared/gameplay/entities/00295100.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/overlays/shared/gameplay/entities/00295100.c b/src/overlays/shared/gameplay/entities/00295100.c index 5a90404f6a..1b3a9ae857 100644 --- a/src/overlays/shared/gameplay/entities/00295100.c +++ b/src/overlays/shared/gameplay/entities/00295100.c @@ -840,7 +840,7 @@ extern s32 D_L00_0015F40C_macro __asm__("D_L00_0015F40C") __attribute__((section 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") MACRO_ADDR; +extern s32 D_0015EE78_macro[6] __asm__("D_0015EE78") __attribute__((section(".sdata"))); extern void flush_cache(s32) __asm__("FUN_00118a80"); extern void sound_stop_all_sounds(void) __asm__("FUN_0022dcd0"); extern void music_stop(void) __asm__("FUN_00215ee8"); From 85c5b21f29f8875919fa77b446281d734e6857d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Sat, 17 Oct 2026 07:42:14 +0000 Subject: [PATCH 23/33] chore: names by use in the hud, map, movie and bomb functions --- .../shared/gameplay/entities/00295100.c | 4 +- src/overlays/shared/gameplay/entities/bomb.c | 206 +++++++++--------- src/overlays/shared/rendering/00245c28.c | 83 ++++--- src/overlays/shared/ui/hud/hud_keep_visible.c | 55 ++--- src/overlays/shared/ui/text/002377b8.c | 47 +--- 5 files changed, 172 insertions(+), 223 deletions(-) diff --git a/src/overlays/shared/gameplay/entities/00295100.c b/src/overlays/shared/gameplay/entities/00295100.c index 1b3a9ae857..4b64cda208 100644 --- a/src/overlays/shared/gameplay/entities/00295100.c +++ b/src/overlays/shared/gameplay/entities/00295100.c @@ -833,7 +833,7 @@ void FUN_L00_00299560(s32 i) { } 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_00161048, D_L00_0016104C, D_L00_00161050_macro __asm__("D_L00_00161050") __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"))); @@ -864,7 +864,7 @@ void FUN_L00_002995d0(s32 sector, s32 size, s32 language) { music_stop(); D_L00_00161048_macro = sector; D_L00_0016104C_macro = size; - (*(s32 *)&D_L00_00161050_macro) = language; + D_L00_00161050_macro = language; D_L00_0015F5D8 = 1; fade_to_black(4); FUN_L00_002039a0(); diff --git a/src/overlays/shared/gameplay/entities/bomb.c b/src/overlays/shared/gameplay/entities/bomb.c index 263d7b45fa..4a48dfc2b1 100644 --- a/src/overlays/shared/gameplay/entities/bomb.c +++ b/src/overlays/shared/gameplay/entities/bomb.c @@ -1027,127 +1027,125 @@ 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 *a, char *vec, char *b, float unk18, float unk1C, float yaw, float pitch) { - float tv[4]; - float lf[4]; - float out[4]; - float tmp[4]; - float v[4]; - unsigned char *m; - char *pos; - char *d; - char *q; - unsigned char *p; - int r; - int r2; - int r3; +char *FUN_L00_002caf70(char *owner, char *spawn_pos, char *target, float unk18, float unk1C, float yaw, float pitch) { + float start[4]; + float from[4]; + float direction[4]; + float jitter[4]; + float spark[4]; + unsigned char *moby; + char *vars; + char *trail; + unsigned char *variant; + int result; + int timer; + int lifetime; int i; - int k; - int *arr; - float len; - float ret; - float fi; + int sparks; + float length; + float curve; + float index; float fraction; - float *t; - - t = tv; - *(w128 *)tv = *(w128 *)vec; - m = func_0020D348_m(0x131); - if (m != 0) { - d = *(char **)(m + 0x78); - *(char **)(d + 0x20) = a; - m[0x30] = 0x7F; - *(short *)(m + 0x32) = 0x7F; - m[0x31] = 1; - *(long *)(m + 0x38) = *(long *)(a + 0x38); - *(float *)(m + 0x40) = D_L00_00161890_gp; - *(float *)(m + 0x44) = fast_add_rotations(pitch, (&D_L00_00161890_gp)[1]); - *(float *)(m + 0x48) = yaw; - qcopy(m + 0x10, t); - if (b != 0) { - int rr; - qcopy(d, b + 0x10); - rr = (int)FUN_002141f8(b); - if (rr != 0) { - *(float *)(d + 0x8) = *(float *)(d + 0x8) + *(float *)(rr + 0x10); + float *point; + + point = start; + *(w128 *)start = *(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, point); + 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 { - *(float *)(d + 0x8) = *(float *)(d + 0x8) + 0.5f; + *(float *)(vars + 0x8) = *(float *)(vars + 0x8) + 0.5f; } } else { - clear_u64_value_c(d); - } - *(float *)(d + 0x18) = unk18; - *(float *)(d + 0x1C) = unk1C; - *(int *)(d + 0x10) = 0; - *(int *)(d + 0x14) = 0; - r2 = scale_game_frames_c2(0x23); - p = (unsigned char *)((char *)item_text_variant); - r2 = r2 + p[0xF] * 10; - *(int *)(d + 0x28) = 0; - *(short *)(d + 0x24) = r2; - *(short *)(d + 0x26) = r2; - *(w128 *)lf = *(w128 *)(a + 0x10); - lf[2] = t[2]; - r = FUN_001efa68(lf, t, 0, (int)a, 0); - if (r != 0) { - build_spherical_offset(out, D_0015ED6C * 40.0f, *(float *)(m + 0x48), -*(float *)(m + 0x44)); - qcopy(m + 0x10, D_L00_00173E60_c); - t = tmp; - k = 4; + clear_u64_value_c(vars); + } + *(float *)(vars + 0x18) = unk18; + *(float *)(vars + 0x1C) = unk1C; + *(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 *)from = *(w128 *)(owner + 0x10); + from[2] = point[2]; + result = FUN_001efa68(from, point, 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); + point = jitter; + sparks = 4; do { - *(w128 *)v = 0; - v[0] = random_float_between_c2(-1.0f, 1.0f); - k--; - v[1] = random_float_between_c2(-1.0f, 1.0f); - v[2] = random_float_between_c2(-1.0f, 1.0f); - *(w128 *)tmp = *(w128 *)v; - FUN_L00_001ff660(v, out, D_L00_00173E80); - len = fast_vec_length(v); - fast_vec_normalize(t, t, len * 0.5f); - add_vector_xyz(v, v, t); - fast_vec_normalize(v, v, random_float_between_c2(D_0015ED6C * 3.0f, D_0015ED6C * 6.0f)); - r = scale_game_frames_c2(10); - r2 = scale_game_frames_c2(15); - r3 = FUN_L00_00257b90_c2(r, r2); - FUN_L00_0026dd20(m + 0x10, (char *)v, 0x7F2F4F6F, r3, 30000.0f); - } while (k >= 0); - p = (unsigned char *)((char *)item_text_variant); - if (p[0xF] == 0) { - FUN_L00_002cbcc0_c(m, 0); - mark_moby_for_removal_c2(m); + *(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 *)jitter = *(w128 *)spark; + FUN_L00_001ff660(spark, direction, D_L00_00173E80); + length = fast_vec_length(spark); + fast_vec_normalize(point, point, length * 0.5f); + add_vector_xyz(spark, spark, point); + 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 *)(d + 0x28) = *(int *)(d + 0x28) + 1; - if (p[0xF] + 5 < *(int *)(d + 0x28)) { - FUN_L00_002cbcc0_c(m, 1); - mark_moby_for_removal_c2(m); + *(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(out, out, D_L00_00173E80); - *(float *)(m + 0x48) = fast_arc_tan_c2(out[0], out[1]); - len = vector_length_xy(out); - *(float *)(m + 0x44) = -fast_arc_tan_c2(len, out[2]); - return m; + 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(m, 0x2F4F7F7F, *(short *)(d + 0x24), -1, *(float *)&D_L00_00161888); + FUN_L00_0026daa0(moby, 0x2F4F7F7F, *(short *)(vars + 0x24), -1, *(float *)&D_L00_00161888); for (i = 0; i < 17; i++) { - q = (char *)FUN_L00_00275158(m + 0x10, D_L00_0015F580, 1, 0.0f); - if (q != 0) { - *(float *)(q + 0xC) = random_float_between_c2(*(float *)&D_L00_00161870, *(float *)&D_L00_00161874); - fi = convert_integer_to_float_c(i); - fraction = fi / convert_integer_to_float_c(16); - ret = FUN_L00_00257e20(-1.5f, 0.0f, 1.0f, 0.0f, fraction); - *(float *)(q + 0xC) = *(float *)(q + 0xC) + (*(float *)&D_L00_00161878 - *(float *)(q + 0xC)) * ret; - r = truncate_float_to_s32_c(ret * -64.0f + 128.0f); - *(int *)(q + 4) = (r << 24) | 0xFFFFFF; - ((int *)(d + 0x2C))[i] = (int)q; + trail = (char *)FUN_L00_00275158(moby + 0x10, D_L00_0015F580, 1, 0.0f); + if (trail != 0) { + *(float *)(trail + 0xC) = random_float_between_c2(*(float *)&D_L00_00161870, *(float *)&D_L00_00161874); + index = convert_integer_to_float_c(i); + fraction = index / convert_integer_to_float_c(16); + curve = FUN_L00_00257e20(-1.5f, 0.0f, 1.0f, 0.0f, fraction); + *(float *)(trail + 0xC) = *(float *)(trail + 0xC) + (*(float *)&D_L00_00161878 - *(float *)(trail + 0xC)) * curve; + result = truncate_float_to_s32_c(curve * -64.0f + 128.0f); + *(int *)(trail + 4) = (result << 24) | 0xFFFFFF; + ((int *)(vars + 0x2C))[i] = (int)trail; } else { - ((int *)(d + 0x2C))[i] = 0; + ((int *)(vars + 0x2C))[i] = 0; } } } } - return m; + return moby; } /* Ported from rac1-decomp (src/overlays/shared/vendor_002C96D0.c: func_L00_002CC868), where it is exact; names translated to the US level program. */ diff --git a/src/overlays/shared/rendering/00245c28.c b/src/overlays/shared/rendering/00245c28.c index dfd2b58294..27567295ca 100644 --- a/src/overlays/shared/rendering/00245c28.c +++ b/src/overlays/shared/rendering/00245c28.c @@ -375,19 +375,16 @@ extern char D_001383A0[]; extern char D_00141EC0[]; void FUN_L00_002464a8(void) { - int i, j; - RenderArchiveState *gl; - int *q; - int v; - int *e; - int *data; - int n, len; + int i; + RenderArchiveState *state; + int level; + int *entry; int heap_tag, first_size, second_size, scratch; int *archive, *archive_base; - unsigned char *mask, *level_data; - int x, y, w; - float lim; - unsigned char *pp; + unsigned char *level_data; + int x, y, mask_buffer; + float radius_sq; + unsigned char *flags; D_L00_001841F0.initialized = 1; { int i; @@ -396,67 +393,67 @@ void FUN_L00_002464a8(void) { D_L00_001841F0.unkB4[i] = 0.65f; D_L00_001841F0.unk154[i] = D_L00_00183EF0[i * 2 + 1]; } } - v = current_level_index; + level = current_level_index; D_L00_001841F0.file_handle = -1; - D_L00_001841F0.archive_index = v > 18 ? 0 : v; + D_L00_001841F0.archive_index = level > 18 ? 0 : level; { int i; for (i = 0; i < 19; i++) { - float a = D_L00_00182810[i * 8], b = D_L00_00182810[i * 8 + 1], c = D_L00_00182810[i * 8 + 2], dd = D_L00_00182810[i * 8 + 3]; - float ee = D_L00_00182810[i * 8 + 4], f = D_L00_00182810[i * 8 + 5], gg = D_L00_00182810[i * 8 + 6], h = D_L00_00182810[i * 8 + 7]; - float p = (ee - gg) / (a - c); - float r = (f - h) / (b - dd); - D_L00_00182A70[i * 4 + 1] = p; - D_L00_00182A70[i * 4 + 3] = r; - D_L00_00182A70[i * 4] = ee - p * a; - D_L00_00182A70[i * 4 + 2] = f - r * b; + float world_x0 = D_L00_00182810[i * 8], world_y0 = D_L00_00182810[i * 8 + 1], world_x1 = D_L00_00182810[i * 8 + 2], world_y1 = D_L00_00182810[i * 8 + 3]; + float map_x0 = D_L00_00182810[i * 8 + 4], map_y0 = D_L00_00182810[i * 8 + 5], map_x1 = D_L00_00182810[i * 8 + 6], map_y1 = D_L00_00182810[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); + D_L00_00182A70[i * 4 + 1] = scale_x; + D_L00_00182A70[i * 4 + 3] = scale_y; + D_L00_00182A70[i * 4] = map_x0 - scale_x * world_x0; + D_L00_00182A70[i * 4 + 2] = map_y0 - scale_y * world_y0; } } - pp = (unsigned char *)D_0013D4C0; - if (pp[0x21] != 0) { + flags = (unsigned char *)D_0013D4C0; + if (flags[0x21] != 0) { D_L00_001841F0.loaded = 1; - e = (int *)(((char *)((char *)&D_00138438))) + D_L00_001841F0.archive_index * 2; + entry = (int *)&D_00138438 + D_L00_001841F0.archive_index * 2; } else { D_L00_001841F0.loaded = 0; - e = (int *)(((char *)&D_001383A0)) + D_L00_001841F0.archive_index * 2; + entry = (int *)&D_001383A0 + D_L00_001841F0.archive_index * 2; } - if (e[1] != 0) { - gl = &D_L00_001841F0; - gl->unk28 = 1; + if (entry[1] != 0) { + state = &D_L00_001841F0; + state->unk28 = 1; heap_tag = (int)D_L00_0015FE00; archive_base = ((int **)&D_L00_00173E08)[0]; archive = (int *)((int)archive_base + 0x9A800); - scratch = e[1] << 7; - load(archive, e[0], e[1]); - gl->file_handle = stash_send_data((int)archive, scratch, 0x4800, (int)D_L00_001E8B00); - gl->transfer_bytes = scratch; + scratch = entry[1] << 7; + load(archive, entry[0], entry[1]); + 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]; - gl->first_data = hud_heap_alloc(first_size, 0, (char *)heap_tag, 0x2DB); - fast_mem_copy_alt((void *)gl->first_data, (char *)archive + archive[0], first_size); - gl->first_data += 8; - gl->second_data = gl->first_data; + 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]; - gl->second_raw = hud_heap_alloc(second_size, 0, (char *)heap_tag, 0x2EC); - fast_mem_copy_alt((void *)gl->second_raw, (char *)archive + archive[1], second_size); - gl->scratch_data = hud_heap_alloc(0x1000, 0, (char *)heap_tag, 0x2F3); + 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; } - w = hud_heap_alloc(0x8000, 0, D_L00_0015FE00, 0x2FC); + mask_buffer = hud_heap_alloc(0x8000, 0, D_L00_0015FE00, 0x2FC); level_data = ((char *)&D_00141EC0) + D_L00_001841F0.archive_index * 0x800; - D_L00_001841F0.mask_data = w; + 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); } - lim = 256.0f; + 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) > lim) { + (15.5f - (float)y) * (15.5f - (float)y) > radius_sq) { D_L00_00184394[x / 8 + y * 4] |= 1 << (x - (x / 8) * 8); } } diff --git a/src/overlays/shared/ui/hud/hud_keep_visible.c b/src/overlays/shared/ui/hud/hud_keep_visible.c index c5f79b44f8..a3f1629f26 100644 --- a/src/overlays/shared/ui/hud/hud_keep_visible.c +++ b/src/overlays/shared/ui/hud/hud_keep_visible.c @@ -316,31 +316,9 @@ 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)); -/* fills 100 hud particle records with randomised positions and drift */ +/* 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. */ -typedef struct { - char pad0[0x8]; - int unk08; - int *unk0C; - char pad10[0x38]; - short unk48; - short unk4A; - char pad4C[0x4]; - int unk50; - int unk54; - int w; - int h; - int flags; - char pad64[0x8]; - int unk6C; - unsigned char cnt[4]; - int unk74; - int unk78; - int unk7C; - void *unk80; -} HudElem_p; - extern f32 random_float_between(f32, f32) __asm__("FUN_002132a8"); typedef struct { float x, y, vx, vy; @@ -348,25 +326,24 @@ typedef struct { extern Star_236458 D_L00_0017E660[]; extern int D_L00_0015F75C_gp __asm__("D_L00_0015F75C") __attribute__((sda)); -void FUN_L00_00235d80_c(HudElem_p *e) __asm__("FUN_L00_00235d80"); -void FUN_L00_00236268(HudElem_p *e) { +void FUN_L00_00236268(HudElem *elem) { int i; - float v, lo, span, hi; - int n; + float margin, lo, band, hi; + int bands; - FUN_L00_00235d80_c(e); + FUN_L00_00235d80(elem); for (i = 0; i < 100; i++) { - v = star_init_limit0_gp; + margin = star_init_limit0_gp; if (i >= 10) { - v = star_init_limit1_gp; - if (i >= 20) v = star_init_limit2_gp; + margin = star_init_limit1_gp; + if (i >= 20) margin = star_init_limit2_gp; } - n = D_L00_0015F75C_gp; - span = (232.0f - (v + v)) / (float)n; - lo = (v - 116.0f) + (float)(i % n) * span; - hi = lo + span; - D_L00_0017E660[i].x = random_float_between(v - 17.0f, 17.0f - v); + bands = D_L00_0015F75C_gp; + band = (232.0f - (margin + margin)) / (float)bands; + lo = (margin - 116.0f) + (float)(i % bands) * band; + hi = lo + band; + 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); @@ -375,9 +352,9 @@ void FUN_L00_00236268(HudElem_p *e) { 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 n live past the loop gives retail's schedule of the loop body. */ - n++; - n--; + /* Fakematch: keeping bands live past the loop gives retail's schedule of the loop body. */ + bands++; + bands--; } diff --git a/src/overlays/shared/ui/text/002377b8.c b/src/overlays/shared/ui/text/002377b8.c index 26d4bb172e..67b9d362b9 100644 --- a/src/overlays/shared/ui/text/002377b8.c +++ b/src/overlays/shared/ui/text/002377b8.c @@ -329,27 +329,6 @@ void FUN_L00_00237ba0(Obj *p) { } /* 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 { - char pad0[0x8]; - int unk08; - int *unk0C; - char pad10[0x38]; - short unk48; - short unk4A; - char pad4C[0x4]; - int unk50; - int unk54; - int w; - int h; - int flags; - char pad64[0x8]; - int unk6C; - unsigned char cnt[4]; - int unk74; - int unk78; - int unk7C; - void *unk80; -} HudElem_p; typedef struct { int id; char pad[0x14]; int item; } E_238C30; @@ -395,26 +374,24 @@ 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_p *rec, int *x, int *y) __asm__("FUN_L00_00235a70"); +int FUN_L00_00235a70_c3(HudElem *rec, int *x, int *y) __asm__("FUN_L00_00235a70"); -int FUN_L00_002382a0(HudElem_p *rec) { - char *wr; +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 entry_offset, marker_offset, normal_offset; int color, shadow, text_y, id, item, prefix_length, text_length, j; float open, fade, angle; const char *text, *suffix; - char *entry; - unsigned char *q = rec->cnt; + unsigned char *counters = rec->cnt; char formatted[80]; - open = convert_integer_to_float_c2(q[0]) / convert_integer_to_float_c2(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_c2(q[1]) / convert_integer_to_float_c2(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; { @@ -467,11 +444,11 @@ int FUN_L00_002382a0(HudElem_p *rec) { { int id; id = *(int *)((char *)D_00141EA0 + selected * 4); - wr = ((char *)&D_L00_001C40B0) + id * 24; - if (*(unsigned short *)(wr + 8) != 0) { + weapon_entry = ((char *)&D_L00_001C40B0) + id * 24; + if (*(unsigned short *)(weapon_entry + 8) != 0) { int shadow, item; item = weapon_ammo_counts[id]; - sprintf(formatted, D_L00_0015F7C8, item, *(unsigned short *)(wr + 0xE)); + sprintf(formatted, D_L00_0015F7C8, item, *(unsigned short *)(weapon_entry + 0xE)); if (item != 0) shadow = fast_tween_color_c(D_L00_0015F7A8_gp, D_L00_0015F7AC, open * fade); else @@ -520,10 +497,10 @@ int FUN_L00_002382a0(HudElem_p *rec) { text_y = y + D_L00_0015F724_gp; { int id; - char *wr; + char *weapon_entry; id = *(int *)((char *)D_00141EA0 + selected * 4); - wr = ((char *)&D_L00_001C40B0) + id * 24; - if (*(unsigned short *)(wr + 8) != 0) + 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; From dfdc1ce487c26ac269609878a8f3d42d3cea11e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Sat, 17 Oct 2026 07:43:27 +0000 Subject: [PATCH 24/33] chore: names by use in the taxi platform update --- .../l07/gameplay/entities/taxi_platform.c | 70 +++++++++---------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/src/overlays/l07/gameplay/entities/taxi_platform.c b/src/overlays/l07/gameplay/entities/taxi_platform.c index fba52cfce3..5a11e75370 100644 --- a/src/overlays/l07/gameplay/entities/taxi_platform.c +++ b/src/overlays/l07/gameplay/entities/taxi_platform.c @@ -2689,12 +2689,12 @@ void FUN_L07_0030f5f0(unsigned char *moby) { FUN_L00_0025d538(moby, data + 0x60); wander = tick_countdown_32_alt((int *)(data + 0x134)) != 0; if (*(int *)(data + 0x110) != 0 && moby[0x20] >= 7) { - char *p = *(char **)(data + 0x148); - inside = FUN_L00_00259740(&tgt, p + 0x10, *(int *)p) != 0; + char *area = *(char **)(data + 0x148); + inside = FUN_L00_00259740(&tgt, area + 0x10, *(int *)area) != 0; } else { - char *p = *(char **)(data + 0x148); - hero = ((char *)&D_0013F3D0); - inside = FUN_L00_00259740(hero, p + 0x10, *(int *)p) != 0; + char *area = *(char **)(data + 0x148); + hero = (char *)&D_0013F3D0; + inside = FUN_L00_00259740(hero, area + 0x10, *(int *)area) != 0; if (vector_distance_xy_alt(moby + 0x10, hero) < 30.0f) { tgt.moby = *(int *)(hero + 0x2000); qcopy(&tgt.pos, hero); @@ -2712,8 +2712,8 @@ void FUN_L07_0030f5f0(unsigned char *moby) { } } if (*(int *)(data + 0x110) != 0) { - char *p = *(char **)(data + 0x128); - FUN_L00_00259740(moby + 0x10, p + 0x10, *(int *)p); + char *area = *(char **)(data + 0x128); + FUN_L00_00259740(moby + 0x10, area + 0x10, *(int *)area); } prev = moby[0xBC]; next = 0xFF; @@ -2742,8 +2742,8 @@ void FUN_L07_0030f5f0(unsigned char *moby) { if (moby[0x20] == 0xE || moby[0x20] == 0xC) { s += s; } - if (0.5f < vector_distance_xy_alt(moby + 0x10, &(*(Vec4_p *)&D_L07_00173EE0))) { - f = vector_distance_xy_alt(moby + 0x10, &(*(Vec4_p *)&D_L07_00173EE0)); + if (0.5f < vector_distance_xy_alt(moby + 0x10, (Vec4_p *)&D_L07_00173EE0)) { + f = vector_distance_xy_alt(moby + 0x10, (Vec4_p *)&D_L07_00173EE0); f += f; } else { f = 1.0f; @@ -2755,12 +2755,12 @@ void FUN_L07_0030f5f0(unsigned char *moby) { float size = random_float_between_c2(1.5f, 2.4f); pos[0] += random_float_between_c2(-0.15f, 0.15f); pos[1] += random_float_between_c2(-0.15f, 0.15f); - pos[2] = resolve_camera_surface_height(&(*(Vec4_p *)&D_L07_00173EE0), 0); + pos[2] = resolve_camera_surface_height((Vec4_p *)&D_L07_00173EE0, 0); FUN_L00_002715e8(pos, 0, -1, size, 5250.0f); } } if (1.0f <= F(data, 0x14C)) { - *(u128_p *)(((char *)&D_0013F3D0)) = *(u128_p *)(moby + 0x10); + *(u128_p *)&D_0013F3D0 = *(u128_p *)(moby + 0x10); } switch (moby[0x20]) { @@ -2771,14 +2771,14 @@ void FUN_L07_0030f5f0(unsigned char *moby) { if ((moby[0x70] & 2) && moby[0x53] != 0) { blend_moby_animation(moby, 0, 0, 10); } - if (inside && tgt.moby != 0 && tgt.moby == *(int *)(((char *)((char *)&D_001413D0))) && + if (inside && tgt.moby != 0 && tgt.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 (tgt.moby != 0 && tgt.moby == *(int *)(((char *)((char *)&D_001413D0))) && + if (tgt.moby != 0 && tgt.moby == *(int *)&D_001413D0 && FUN_L07_0030f4d0_c(moby, tgt.moby, 1.5f)) { if (moby[0x53] != 2) { blend_moby_animation(moby, 2, 0, 2); @@ -2805,7 +2805,7 @@ void FUN_L07_0030f5f0(unsigned char *moby) { if ((moby[0x70] & 2) && moby[0x53] != 1) { blend_moby_animation(moby, 1, 0, 10); } - if (inside && tgt.moby != 0 && tgt.moby == *(int *)(((char *)((char *)&D_001413D0)))) { + if (inside && tgt.moby != 0 && tgt.moby == *(int *)&D_001413D0) { if (!FUN_L07_0030f540_c(moby, 4, 6)) { if (moby[0x53] != 1) { blend_moby_animation(moby, 1, 0, 10); @@ -2813,12 +2813,12 @@ void FUN_L07_0030f5f0(unsigned char *moby) { moby[0x20] = 4; } } else { - float a = 1.74532926f; - float b = 4.5378561f; + float stiffness = 1.74532926f; + float damping = 4.5378561f; FUN_L00_00258278((char *)moby, (float *)(data + 0x120), F(data, 0x13C), - frame_time_sq * a, frame_time_sq * b, frame_time * a); + 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 * a, frame_time_sq * b, frame_time * a); + 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); @@ -2837,7 +2837,7 @@ void FUN_L07_0030f5f0(unsigned char *moby) { *(int *)(data + 0x134) = rand() % 120 + 60; moby[0x20] = 1; } - if (tgt.moby != 0 && tgt.moby == *(int *)(((char *)((char *)&D_001413D0))) && + if (tgt.moby != 0 && tgt.moby == *(int *)&D_001413D0 && FUN_L07_0030f4d0_c(moby, tgt.moby, 1.5f)) { if (moby[0x53] != 2) { blend_moby_animation(moby, 2, 0, 2); @@ -2854,7 +2854,7 @@ void FUN_L07_0030f5f0(unsigned char *moby) { goto end; case 4: { float ang; - float d; + float pitch; int close = 1; float pi4 = 12.566371f; float three = 3.0f; @@ -2862,9 +2862,9 @@ void FUN_L07_0030f5f0(unsigned char *moby) { ang = fast_arc_tan_c2(tgt.pos[0] - F(moby, 0x10), tgt.pos[1] - F(moby, 0x14)); FUN_L00_00258278((char *)moby, (float *)(data + 0x120), ang, frame_time_sq * pi4, frame_time_sq * zero, frame_time * pi4); - d = vector_distance_xy_alt(moby + 0x10, &tgt); - d = fast_arc_tan_c2(d, tgt.pos[2] - F(moby, 0x18)); - F(moby, 0x44) = FUN_L00_00258110((float *)(data + 0x124), F(moby, 0x44), -d, + pitch = vector_distance_xy_alt(moby + 0x10, &tgt); + pitch = fast_arc_tan_c2(pitch, tgt.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; @@ -2883,9 +2883,9 @@ void FUN_L07_0030f5f0(unsigned char *moby) { F(data, 0x14C) = zero; qcopy(data + 0x100, moby + 0x10); } - ((struct { char p[0x138]; float f; } *)data)->f = tgt.pos[2] - 0.25f; + ((struct { char area[0x138]; float f; } *)data)->f = tgt.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 *)(((char *)&D_0013F65C)) == 0) { + if (!inside || *(short *)&D_0013F65C == 0) { if (moby[0x53] != 1) { blend_moby_animation(moby, 1, 0, 10); } @@ -2901,7 +2901,6 @@ void FUN_L07_0030f5f0(unsigned char *moby) { } case 5: { float ang; - float d; char *mpos; char *start; float one; @@ -2924,16 +2923,16 @@ void FUN_L07_0030f5f0(unsigned char *moby) { no_op_main_callback_alt(start, mpos); subtract_vector_xyz(data + 0xD0, mpos, old); if (one <= F(data, 0x14C)) { - char *g = ((char *)&D_0013F350); - *(int *)(g + 0x22A8) = 0; + char *hero_bytes = (char *)&D_0013F350; + *(int *)(hero_bytes + 0x22A8) = 0; FUN_L00_002223f8(0x3D, 1); - *(int *)(*(char **)(g + 0x2080) + 0x98) = -1; - g[0x20A5] = 1; + *(int *)(*(char **)(hero_bytes + 0x2080) + 0x98) = -1; + hero_bytes[0x20A5] = 1; moby[0x20] = 6; } else { F(data, 0x13C) = ang; } - if (inside || *(short *)(((char *)&D_0013F65C)) != 0) { + if (inside || *(short *)&D_0013F65C != 0) { goto end; } *(int *)(data + 0x14C) = 0; @@ -2999,12 +2998,12 @@ void FUN_L07_0030f5f0(unsigned char *moby) { } moby[0x20] = 9; } else { - float a = 0.785398185f; - float b = 1.57079637f; + float stiffness = 0.785398185f; + float damping = 1.57079637f; FUN_L00_00258278((char *)moby, (float *)(data + 0x120), F(data, 0x13C), - frame_time_sq * a, frame_time_sq * b, frame_time * a); + 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 * a, frame_time_sq * b, frame_time * a); + 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); @@ -3037,7 +3036,6 @@ void FUN_L07_0030f5f0(unsigned char *moby) { case 9: case 10: { float ang; - float d; float pi2 = 1.57079637f; ang = fast_arc_tan_c2(tgt.pos[0] - F(moby, 0x10), tgt.pos[1] - F(moby, 0x14)); func_L00_002592B0_t((char *)moby, ang, (float *)(data + 0x120), From 7aed17c3d573b6c99bd4e8522cc81cd195f267fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Sat, 17 Oct 2026 07:44:02 +0000 Subject: [PATCH 25/33] chore: names by use in the taxi platform update --- .../l07/gameplay/entities/taxi_platform.c | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/overlays/l07/gameplay/entities/taxi_platform.c b/src/overlays/l07/gameplay/entities/taxi_platform.c index 5a11e75370..86705e96e4 100644 --- a/src/overlays/l07/gameplay/entities/taxi_platform.c +++ b/src/overlays/l07/gameplay/entities/taxi_platform.c @@ -2726,30 +2726,30 @@ void FUN_L07_0030f5f0(unsigned char *moby) { } FUN_L00_0024f7c8(moby, 0, pos); if (FUN_L00_001f0d60(0.8f, pos, 1, moby) != 0 && FUN_001f0b58() == 0) { - float s; - float f; - s = **(float **)(data + 0x12C); - s -= F(data, 0x130); - s *= 0.5f; - if (s < absolute_float(F(moby, 0x18) - pos[2])) { - s = (**(float **)(data + 0x12C) - F(data, 0x130)) * 0.5f; + float height; + float scale; + height = **(float **)(data + 0x12C); + height -= F(data, 0x130); + height *= 0.5f; + if (height < absolute_float(F(moby, 0x18) - pos[2])) { + height = (**(float **)(data + 0x12C) - F(data, 0x130)) * 0.5f; } else { - s = absolute_float(F(moby, 0x18) - pos[2]); + height = absolute_float(F(moby, 0x18) - pos[2]); } if (F(data, 0xD8) < 0.0f) { - s = -s; + height = -height; } if (moby[0x20] == 0xE || moby[0x20] == 0xC) { - s += s; + height += height; } if (0.5f < vector_distance_xy_alt(moby + 0x10, (Vec4_p *)&D_L07_00173EE0)) { - f = vector_distance_xy_alt(moby + 0x10, (Vec4_p *)&D_L07_00173EE0); - f += f; + scale = vector_distance_xy_alt(moby + 0x10, (Vec4_p *)&D_L07_00173EE0); + scale += scale; } else { - f = 1.0f; + scale = 1.0f; } if (D_L07_0015F5CC % 45 == *(short *)(moby + 0xB2) && random_integer_below(2) == 0) { - func_L00_002A5158_30D8E8((*(Rec_30D8E8_p * *)&D_L07_001612D0), D_L07_001612D8, 1, F(moby, 0x10), F(moby, 0x14), f, s); + func_L00_002A5158_30D8E8((*(Rec_30D8E8_p * *)&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); @@ -2883,7 +2883,7 @@ void FUN_L07_0030f5f0(unsigned char *moby) { F(data, 0x14C) = zero; qcopy(data + 0x100, moby + 0x10); } - ((struct { char area[0x138]; float f; } *)data)->f = tgt.pos[2] - 0.25f; + ((struct { char pad[0x138]; float f; } *)data)->f = tgt.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) { From e6be3cf0c7b4b651b4b7cac51d57ceeff7963998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Sat, 17 Oct 2026 07:44:29 +0000 Subject: [PATCH 26/33] chore: names by use in the level 8 bomb update --- src/overlays/l08/gameplay/entities/bomb.c | 222 +++++++++++----------- 1 file changed, 111 insertions(+), 111 deletions(-) diff --git a/src/overlays/l08/gameplay/entities/bomb.c b/src/overlays/l08/gameplay/entities/bomb.c index 8859bf3c40..0432b183c6 100644 --- a/src/overlays/l08/gameplay/entities/bomb.c +++ b/src/overlays/l08/gameplay/entities/bomb.c @@ -1497,7 +1497,7 @@ typedef struct { char padF8[0x14]; float f10C, f110, f114; char pad118[8]; - struct Moby *p120; + struct Moby *waypoint; struct Moby *p124; int i128; char blk12C[4]; @@ -1557,7 +1557,7 @@ extern void func_L00_002592B0_x(float, void *, void *, float, float, float) __as extern char camera_state_bytes[] __asm__("D_L08_00167480"); void FUN_L08_002dabf0(struct Moby *moby) { - Data_DBF68 *d = (Data_DBF68 *)moby->pvars; + Data_DBF68 *vars = (Data_DBF68 *)moby->pvars; Look_DBF68 look; float point[4]; float velocity[4]; @@ -1566,10 +1566,10 @@ void FUN_L08_002dabf0(struct Moby *moby) { float damage; float scratch; struct Moby *target; - struct Moby *old; + struct Moby *old_waypoint; damage = 0.0f; - func_L00_00264B40_x(moby, D_L08_001619AC_gp, 3.0f, d->blk160); + 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); @@ -1582,96 +1582,96 @@ void FUN_L08_002dabf0(struct Moby *moby) { moby->flags |= 0x400; } if (moby->state == 100) { - float t = convert_integer_to_float_c(D_L08_001619D0_gp); - int c = d->s132; - moby->alpha = func_001FA898_2D6C58((float)c + (float)-c * ((float)(D_L08_001619D0_gp - d->s130) / t)); + 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_00213928(moby, find_2D5FA8_c(moby, 0x330000, 0), &d->health, 0, &hit, &damage, 0, 4); + 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; - d->health -= damage; - if (0.0f < d->health) { + vars->health -= damage; + if (0.0f < vars->health) { if (damage < 1.0f) { - d->tint = 100; + vars->tint = 100; } else { - char *base; - d->f80 = frame_time_sq * 30.0f; - d->f88 = frame_time * 5.0f; - d->f8C = frame_time * 7.0f; - d->i94 = 9; - d->f84 = 0.0005f; - d->bAD = 0; - base = ((char *)((char *)&hero)); - FUN_L00_0025c558(moby, d->blk70, - fast_arc_tan_c2(moby->pos.x - *(float *)(base + 0x80), - moby->pos.y - *(float *)(base + 0x84)), + 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); - d->fC0 = 6.0f; - d->fC4 = 10.0f; - d->tint = 0x78; + vars->fC0 = 6.0f; + vars->fC4 = 10.0f; + vars->tint = 0x78; moby->state = 0x5A; } } else { - char *base; - d->i94 = 9; - d->f84 = 0.0005f; - d->f80 = frame_time_sq * 30.0f; - d->f88 = D_L08_0016198C_gp * frame_time; - d->f8C = D_L08_00161990_gp * frame_time; - d->bAD = 0; - base = ((char *)((char *)&hero)); - FUN_L00_0025c558(moby, d->blk70, - fast_arc_tan_c2(moby->pos.x - *(float *)(base + 0x80), - moby->pos.y - *(float *)(base + 0x84)), + 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); - d->fC0 = 6.0f; - d->fC4 = 10.0f; + vars->fC0 = 6.0f; + vars->fC4 = 10.0f; explode_2D5FA8_c(moby, 0, -1); - d->tint = 0xFA; + vars->tint = 0xFA; moby->state = 0x63; moby->flags &= 0xEFFF; - d->p120->command = 0; + vars->waypoint->command = 0; } - effects_start_2D5FA8_c(moby, d->anim); + effects_start_2D5FA8_c(moby, vars->anim); } moby->hit_slot = 0xFF; look.r44 = FUN_L08_0026a3d0(moby, 16.0f, &look); if (look.target == 0) { - look.target = *(struct Moby **)(((char *)&D_001413D0)); + look.target = *(struct Moby **)&D_001413D0; } target = look.target; switch (moby->state) { case 0: moby->flags |= 0x1000; - d->b29 = 1; - d->health = 2.0f; - FUN_L01_0026d930(d->blkD0); - d->fDC = 2.0f; - d->fD8 = 2.0f; - d->f10C = 0.03f; - d->f110 = 0.3f; - d->f114 = 0.25f; - d->fF4 = D_L08_00161978_gp * frame_time; - d->b58 = func_001FA898_2D6C58(17.0f); - d->b5A = func_001FA898_2D6C58(10.4f); - clear_u64_value(d->v40); - d->p120 = (struct Moby *)FUN_L08_002daa10_c((char *)moby); - d->p120->command = 1; - d->i128 = scale_game_frames_c2(0xB4); + 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) { FUN_00212f90(moby, 4, 0, 0); } moby->state = 1; - d->i134 = scale_game_frames_c2(0xF0); + vars->i134 = scale_game_frames_c2(0xF0); break; case 1: - FUN_L00_00259028((char *)moby, d->blkD0, (float *)&d->p120->pos, (char *)d->v40); - if (fast_vec_dist(&moby->pos, &d->p120->pos) < 3.0f) { + 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(d->p120->pos.x - moby->pos.x, - d->p120->pos.y - moby->pos.y)) < 0.2617994f) { + 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); @@ -1679,35 +1679,35 @@ void FUN_L08_002dabf0(struct Moby *moby) { moby->state = 6; break; } - d->i134 = scale_game_frames_c2(0xF0); + vars->i134 = scale_game_frames_c2(0xF0); { - struct Moby *o = d->p120; - struct Moby *n = (struct Moby *)FUN_L08_002daa10_c((char *)moby); - d->p120 = n; - if (n == 0) { - d->p120 = o; + 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; } - o->command = 0; - d->p120->command = 1; + old_waypoint->command = 0; + vars->waypoint->command = 1; } break; } } - if (tick_countdown_32_alt(&d->i134) != 0) { - old = d->p120; - if ((d->p120 = (struct Moby *)FUN_L08_002daa10_c((char *)moby)) == 0) { - d->p120 = old; + 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->command = 0; - d->p120->command = 1; - d->i134 = scale_game_frames_c2(0xF0); + old_waypoint->command = 0; + vars->waypoint->command = 1; + vars->i134 = scale_game_frames_c2(0xF0); } break; case 6: - FUN_L00_00259028((char *)moby, d->blkD0, (float *)&d->p120->pos, (char *)d->v40); + FUN_L00_00259028((char *)moby, vars->blkD0, (float *)&vars->waypoint->pos, (char *)vars->v40); if (moby->anim_flags & 2) { - FUN_00212f90(d->p120, 1, 0, scale_game_frames_c2(6)); - qcopy(&moby->pos, &d->p120->pos); + 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); @@ -1715,25 +1715,25 @@ void FUN_L08_002dabf0(struct Moby *moby) { 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); - d->i128 = scale_game_frames_c2(0x78); + vars->i128 = scale_game_frames_c2(0x78); moby->collision = 0; } break; 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, d->blk12C, 0.02f, 0.3f, 0.2f); - if (dist < 20.0f && 8.0f < dist && tick_countdown_32_alt(&d->i128) != 0) { + 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 (d->i38 == 0 || !(0.5f < dist)) { + if (vars->i38 == 0 || !(0.5f < dist)) { break; } attack: - FUN_00212f90(d->p120, 1, 0, scale_game_frames_c2(6)); + 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)); } @@ -1746,26 +1746,26 @@ void FUN_L08_002dabf0(struct Moby *moby) { 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, &d->p120->pos); + add_vector_xyz(point, point, &vars->waypoint->pos); if (0.2f < vector_distance_xy_alt(&moby->pos, point)) { - FUN_L00_00259028((char *)moby, d->blkD0, point, (char *)d->v40); + 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 = d->p120; - if ((d->p120 = (struct Moby *)FUN_L08_002daa10_c((char *)moby)) == 0) { - d->p120 = old; + old_waypoint = vars->waypoint; + if ((vars->waypoint = (struct Moby *)FUN_L08_002daa10_c((char *)moby)) == 0) { + vars->waypoint = old_waypoint; } - old->command = 0; - d->p120->command = 1; + 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; - d->i134 = scale_game_frames_c2(0xF0); + vars->i134 = scale_game_frames_c2(0xF0); } else { if (moby->prev_seq != 3) { FUN_00212f90(moby, 3, 0, scale_game_frames_c2(6)); @@ -1776,7 +1776,7 @@ void FUN_L08_002dabf0(struct Moby *moby) { break; case 5: func_L00_002592B0_x(fast_arc_tan_c2(target->pos.x - moby->pos.x, target->pos.y - moby->pos.y), - moby, d->blk12C, 0.02f, 0.3f, 0.2f); + 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; @@ -1797,15 +1797,15 @@ void FUN_L08_002dabf0(struct Moby *moby) { set_vector_length_xy(velocity, velocity, time); 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); - d->p124 = (struct Moby *)next; + 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); - d->p124->state = 1; - d->p124->command |= 3; - d->i128 = scale_game_frames_c2(0xB4); + vars->p124->state = 1; + vars->p124->command |= 3; + vars->i128 = scale_game_frames_c2(0xB4); } break; } @@ -1814,7 +1814,7 @@ void FUN_L08_002dabf0(struct Moby *moby) { if (moby->prev_seq != 4) { FUN_00212f90(moby, 4, 0, 3); } - d->i134 = scale_game_frames_c2(0xF0); + vars->i134 = scale_game_frames_c2(0xF0); } break; case 0x5B: @@ -1828,19 +1828,19 @@ void FUN_L08_002dabf0(struct Moby *moby) { case 0x5A: case 0x5C: case 0x5D: - if (FUN_L00_0025c698(moby, d->blk70) & 0x40) { - old = d->p120; - if ((d->p120 = (struct Moby *)FUN_L08_002daa10_c((char *)moby)) == 0) { - d->p120 = old; + 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->command = 0; - d->p120->command = 1; + old_waypoint->command = 0; + vars->waypoint->command = 1; } if (moby->prev_seq != 4) { FUN_00212f90(moby, 4, 0, 10); } moby->state = 1; - d->i134 = scale_game_frames_c2(0xF0); + vars->i134 = scale_game_frames_c2(0xF0); } if (moby->pos.z < 5.0f) { mark_moby_for_removal(moby); @@ -1848,20 +1848,20 @@ void FUN_L08_002dabf0(struct Moby *moby) { } break; case 0x63: - if (FUN_L00_0025c698(moby, d->blk70) & 0x40) { + if (FUN_L00_0025c698(moby, vars->blk70) & 0x40) { moby->anim_speed = 0.0f; moby->state = 100; moby->collision = 0; - d->s132 = 0x28; - d->s130 = D_L08_001619D0_gp; + vars->s132 = 0x28; + vars->s130 = D_L08_001619D0_gp; FUN_L04_002c46d0(moby); mark_moby_for_removal(moby); return; } break; } - effects_update_2D5FA8_c(moby, d->anim); - d->i38 = 0; + effects_update_2D5FA8_c(moby, vars->anim); + vars->i38 = 0; } /* Pvars of the hero-carrying lift. */ typedef struct { From 7c13780946da33577ef5ff8904ea230178f448a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Sat, 17 Oct 2026 07:44:57 +0000 Subject: [PATCH 27/33] chore: names by use in the bolt thief update --- .../l08/gameplay/entities/bolt_thief.c | 464 +++++++++--------- 1 file changed, 232 insertions(+), 232 deletions(-) diff --git a/src/overlays/l08/gameplay/entities/bolt_thief.c b/src/overlays/l08/gameplay/entities/bolt_thief.c index 7db4fb3019..ddeb2a387f 100644 --- a/src/overlays/l08/gameplay/entities/bolt_thief.c +++ b/src/overlays/l08/gameplay/entities/bolt_thief.c @@ -2015,220 +2015,220 @@ extern void func_L00_0023A690_4BE8(void) __asm__("FUN_L08_002444e0"); extern void func_L00_0023A788_4BE8(void) __asm__("FUN_L08_002445d8"); extern int D_L08_00174658_lui __asm__("D_L08_00174658") __attribute__((section(".data"))); -void FUN_L08_002e3870(struct Moby *m) { +void FUN_L08_002e3870(struct Moby *moby) { char *cam; - float a[4]; - float b[4]; - float c[4]; - float mt[16]; + float direction[4]; + float point[4]; + float local[4]; + float matrix[16]; - switch (m->state) { + switch (moby->state) { case 0: { - Vars_4BE8 *d = (Vars_4BE8 *)m->pvars; + Vars_4BE8 *vars = (Vars_4BE8 *)moby->pvars; int linked; - switch (m->oclass) { + switch (moby->oclass) { case 0x279: - m->scale = m->pclass->scale * D_L08_00161CB4_gp; + moby->scale = moby->pclass->scale * D_L08_00161CB4_gp; break; case 0x3DC: - m->scale = m->pclass->scale * D_L08_00161CB8; + moby->scale = moby->pclass->scale * D_L08_00161CB8; break; case 0x3DD: - m->scale = m->pclass->scale * D_L08_00161CBC_gp; + moby->scale = moby->pclass->scale * D_L08_00161CBC_gp; break; } linked = 0; if (D_L08_00161CD4_gp > D_L08_0015F5CC) { D_L08_00161CD4_gp = D_L08_0015F5CC; } - m->flags &= ~0x100; - qcopy(d->v0_p, &m->pos); - if (d->s6E == 0) { - fast_vec_normalize_c2(b, &m->rot_row2, 0.1f); - add_vector_xyz(b, b, &m->pos); - fast_vec_scale_c(c, &m->rot_row2, -2.0f); - add_vector_xyz(c, c, &m->pos); - if (FUN_001efa68(b, c, 2, 0, 0) != 0) { + moby->flags &= ~0x100; + qcopy(vars->v0_p, &moby->pos); + if (vars->s6E == 0) { + fast_vec_normalize_c2(point, &moby->rot_row2, 0.1f); + add_vector_xyz(point, point, &moby->pos); + 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) { CollPos_4BE8 *hit = (CollPos_4BE8 *)D_L08_00174660; - qcopy(d->v0_p, hit->pos); + qcopy(vars->v0_p, hit->pos); linked = ((int *)hit)[-2]; - fast_vec_normalize_c2(a, hit->n, 1.0f); + fast_vec_normalize_c2(direction, hit->n, 1.0f); } else { - qcopy(d->v0_p, &m->pos); - clear_u64_value(a); - a[2] = 1.0f; + qcopy(vars->v0_p, &moby->pos); + clear_u64_value(direction); + direction[2] = 1.0f; } } - FUN_L08_002e4db8_c((char *)m, a); - d->f60 = random_angle_radians_c2(); - d->f64 = m->rot.x; - FUN_L08_002e4e90_c((char *)m, (float *)&m->pos, (float *)&m->rot); + FUN_L08_002e4db8_c((char *)moby, direction); + vars->f60 = random_angle_radians_c2(); + vars->f64 = moby->rot.x; + FUN_L08_002e4e90_c((char *)moby, (float *)&moby->pos, (float *)&moby->rot); if (linked != 0 && FUN_L00_002603d0(linked) != 0) { - d->u7C.i = linked; - FUN_L00_00260668(m, linked, d->v0_p, d->v10, d->v20, d->v30); + vars->u7C.i = linked; + FUN_L00_00260668(moby, linked, vars->v0_p, vars->v10, vars->v20, vars->v30); } - m->state = 1; - d->s6C = 0; - d->u70.i = truncate_float_to_s32_c5(random_float_between_c5(0.0f, (float)scale_game_frames_c(600))); - d->u78.i = D_L08_00161CCC_gp; + moby->state = 1; + vars->s6C = 0; + 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 *d = (Vars_4BE8 *)m->pvars; - - if (d->u7C.i != 0) { - FUN_L00_002604f0(m, d->u7C.i, d->v20, d->v30, d->v0_p, d->v10); - if ((signed char)((struct Moby *)d->u7C.i)->state < 0) { - d = (Vars_4BE8 *)m->pvars; - clear_u64_value(d->v40); - FUN_L08_0026a0f8(d, &m->rot_row1, D_L08_00161C98_gp * 0.017453292f * frame_time); - m->state = 4; + 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_p, vars->v10); + if ((signed char)((struct Moby *)vars->u7C.i)->state < 0) { + vars = (Vars_4BE8 *)moby->pvars; + clear_u64_value(vars->v40); + FUN_L08_0026a0f8(vars, &moby->rot_row1, D_L08_00161C98_gp * 0.017453292f * frame_time); + moby->state = 4; break; } } - if (absolute_float(m->pos.z - ((Hero *)(((char *)((char *)&hero))))->motion.pos.f[2]) < ((Hero *)(((char *)((char *)&hero))))->reach_distance - && vector_distance_xy_alt(&m->pos, ((Hero *)(((char *)((char *)&hero))))->motion.pos.f) < ((Hero *)(((char *)((char *)&hero))))->reach_height) { - d->i68 = scale_game_frames_c(1); - m->state = 2; + 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->i68 = scale_game_frames_c(1); + moby->state = 2; } - if (m->visible == 0) { - if (m > D_L08_0015FFDC && vector_distance_xy_alt(&m->pos, ((char *)&D_0013F3D0)) > 24.0f) { - mark_moby_for_removal_c3(m); + if (moby->visible == 0) { + 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 (m->oclass) { + switch (moby->oclass) { case 0x3DD: - d->f60 = fast_add_rotations_c4(d->f60, D_L08_00161CAC_gp * 0.017453292f * frame_time); - d->f64 = fast_add_rotations_c4(d->f64, D_L08_00161CB0 * 0.017453292f * frame_time); + 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: - d->f60 = fast_add_rotations_c4(d->f60, D_L08_00161CA4_gp * 0.017453292f * frame_time); - d->f64 = fast_add_rotations_c4(d->f64, D_L08_00161CA8 * 0.017453292f * frame_time); + 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: - d->f60 = fast_add_rotations_c4(d->f60, D_L08_00161C9C * 0.017453292f * frame_time); - d->f64 = fast_add_rotations_c4(d->f64, D_L08_00161CA0_gp * 0.017453292f * frame_time); + 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_c((char *)m, (float *)&m->pos, (float *)&m->rot); - if (d->s6C != 0) { - d->f74 = fast_add_rotations_c4(d->f74, frame_time * 5.2359877f); - if (d->u70.i > 12) { - d->u78.i += 0x5000000; + FUN_L08_002e4e90_c((char *)moby, (float *)&moby->pos, (float *)&moby->rot); + if (vars->s6C != 0) { + vars->f74 = fast_add_rotations_c4(vars->f74, frame_time * 5.2359877f); + if (vars->u70.i > 12) { + vars->u78.i += 0x5000000; } else { - d->u78.i -= 0x5000000; + vars->u78.i -= 0x5000000; } - if (tick_countdown_32_alt(&d->u70.i) != 0) { - d->s6C = 0; - d->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 (m->visible != 0 && D_L08_00161CC8 != 0) { - func_001F49B0_2E16A0(FUN_L08_002e5188_c, m); + if (tick_countdown_32_alt(&vars->u70.i) != 0) { + vars->s6C = 0; + 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_c, moby); return; } - } else if (tick_countdown_32_alt(&d->u70.i) != 0) { - d->u70.i = 24; - d->f74 = random_angle_radians_c2(); - d->s6C = 1; + } else if (tick_countdown_32_alt(&vars->u70.i) != 0) { + vars->u70.i = 24; + vars->f74 = random_angle_radians_c2(); + vars->s6C = 1; } break; } case 2: { - Vars_4BE8 *d = (Vars_4BE8 *)m->pvars; + Vars_4BE8 *vars = (Vars_4BE8 *)moby->pvars; - euler_rotation_matrix(mt, d->v10); - qcopy(a, mt + 8); - if (tick_countdown_32_alt(&d->i68) != 0) { - Vars_4BE8 *e = (Vars_4BE8 *)m->pvars; + euler_rotation_matrix(matrix, vars->v10); + qcopy(direction, matrix + 8); + if (tick_countdown_32_alt(&vars->i68) != 0) { + Vars_4BE8 *vars = (Vars_4BE8 *)moby->pvars; float k = 0.017453292f; char *hero_pos = D_0013F3D0; - subtract_vector_xyz(b, &m->pos, hero_pos); - fast_vec_normalize_c2(b, b, 1.0f); - cross_vectors_xyz(b, a, b); - FUN_L08_0026a0f8(e, b, D_L08_00161C94_gp * k * frame_time); - m->flags |= 0x100; - fast_vec_normalize_c2(e->v40, a, frame_time * 8.0f); - e->f74 = 0.0f; - e->u70.f = frame_time * 8.0f; - e->u78.p = *(char **)(hero_pos + 0x2000); - e->u7C.f = 0.5f; + 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 * k * frame_time); + moby->flags |= 0x100; + fast_vec_normalize_c2(vars->v40, direction, frame_time * 8.0f); + vars->f74 = 0.0f; + vars->u70.f = frame_time * 8.0f; + vars->u78.p = *(char **)(hero_pos + 0x2000); + vars->u7C.f = 0.5f; 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, m); - e->f64 = 0.0f; + allocate_voice_for_target_entry(0, 0x20, moby); + vars->f64 = 0.0f; } else { - e->f64 = random_float_between_c5(-30.0f, 30.0f) * k; + vars->f64 = random_float_between_c5(-30.0f, 30.0f) * k; } - m->state = 3; + moby->state = 3; } else { - if (scale_game_frames_c(10) < d->i68) { - float t = fast_add_rotations_c4(d->f60, fast_sin((float)(d->i68 % 8 - 4) * 0.7854f) * 0.17453292f); + if (scale_game_frames_c(10) < vars->i68) { + float yaw = fast_add_rotations_c4(vars->f60, fast_sin((float)(vars->i68 % 8 - 4) * 0.7854f) * 0.17453292f); - FUN_L00_0025bc00(&d->f60, t, 0.5235988f, 0); + FUN_L00_0025bc00(&vars->f60, yaw, 0.5235988f, 0); } else { - float t = fast_add_rotations_c4(fast_arc_tan(((Hero *)(((char *)((char *)&hero))))->motion.pos.f[0] - m->pos.x, - ((Hero *)(((char *)((char *)&hero))))->motion.pos.f[1] - m->pos.y), + float 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(&d->f60, t, 0.08726646f, 0); - if (func_001FA850_2E16A0(d->f60, t) < 0.08726646f) { - d->i68 = 0; + FUN_L00_0025bc00(&vars->f60, yaw, 0.08726646f, 0); + if (func_001FA850_2E16A0(vars->f60, yaw) < 0.08726646f) { + vars->i68 = 0; } } - FUN_L08_002e4e90_c((char *)m, (float *)&m->pos, (float *)&m->rot); + FUN_L08_002e4e90_c((char *)moby, (float *)&moby->pos, (float *)&moby->rot); } break; } case 3: { - Vars_4BE8 *d = (Vars_4BE8 *)m->pvars; + Vars_4BE8 *vars = (Vars_4BE8 *)moby->pvars; float dist; float lim; - if (d->u78.p == 0) { + if (vars->u78.p == 0) { break; } - fast_vec_normalize_c2(b, d->u78.p + 0xE0, d->u7C.f); - add_vector_xyz(b, b, d->u78.p + 0x10); - subtract_vector_xyz(a, b, &m->pos); - if (d->f64 != 0.0f) { - float s = fast_sin(d->f64); - float co = fast_cos(d->f64); - - a[0] = co * a[0] + s * a[1]; - a[1] = co * a[1] - s * a[0]; - } - dist = fast_vec_dist(b, &m->pos); - fast_vec_normalize_c2(d->v40, d->v40, d->u70.f); - add_vector_xyz(&m->pos, &m->pos, d->v40); - fast_vec_normalize_c2(a, a, d->f74); - add_vector_xyz(&m->pos, &m->pos, a); + fast_vec_normalize_c2(point, vars->u78.p + 0xE0, vars->u7C.f); + add_vector_xyz(point, point, vars->u78.p + 0x10); + subtract_vector_xyz(direction, point, &moby->pos); + if (vars->f64 != 0.0f) { + float sin_a = fast_sin(vars->f64); + float cos_a = fast_cos(vars->f64); + + direction[0] = cos_a * direction[0] + sin_a * direction[1]; + direction[1] = cos_a * direction[1] - sin_a * direction[0]; + } + dist = fast_vec_dist(point, &moby->pos); + fast_vec_normalize_c2(vars->v40, vars->v40, vars->u70.f); + add_vector_xyz(&moby->pos, &moby->pos, vars->v40); + fast_vec_normalize_c2(direction, direction, vars->f74); + add_vector_xyz(&moby->pos, &moby->pos, direction); cam = D_0013F490; - add_vector_xyz(&m->pos, &m->pos, cam); - subtract_vector_xyz(c, &m->pos, cam + 0x160); - transform_vector(c, c, cam - 0x100); - if (((struct Moby *)d->u78.p)->oclass != 0 || c[2] > 0.0f) { - func_00214D28_2E16A0(&d->u70.f, 0.0f, D_L08_00161C8C_gp * frame_time_sq); - func_00214D28_2E16A0(&d->f74, D_L08_00161C88_gp * frame_time, D_L08_00161C8C_gp * frame_time_sq); + 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 { - fast_vec_normalize_c2(mt, cam - 0x120, d->u70.f); - subtract_vector_xyz(mt + 4, mt, d->v40); - FUN_L00_0025f730_c(mt + 4, D_L08_00161C8C_gp * frame_time_sq); - add_vector_xyz(d->v40, d->v40, mt + 4); + fast_vec_normalize_c2(matrix, cam - 0x120, vars->u70.f); + subtract_vector_xyz(matrix + 4, matrix, vars->v40); + FUN_L00_0025f730_c(matrix + 4, D_L08_00161C8C_gp * frame_time_sq); + add_vector_xyz(vars->v40, vars->v40, matrix + 4); } - if (dist < d->f74) { - d->f74 = dist; + if (dist < vars->f74) { + vars->f74 = dist; } - lim = d->f74 * (float)scale_game_frames_c(20); + lim = vars->f74 * (float)scale_game_frames_c(20); if (dist < lim) { - if (fast_vec_dist(b, &m->pos) > 0.52f) { + if (fast_vec_dist(point, &moby->pos) > 0.52f) { if (D_L08_00161CC0 != 0) { - m->alpha = (fast_vec_dist(b, &m->pos) + lim) * 128.0f / (lim + lim); + moby->alpha = (fast_vec_dist(point, &moby->pos) + lim) * 128.0f / (lim + lim); } if (D_L08_00161CC4_gp != 0) { - m->scale = m->pclass->scale * D_L08_00161CB4_gp * (fast_vec_dist(b, &m->pos) + lim) / (lim + lim); + moby->scale = moby->pclass->scale * D_L08_00161CB4_gp * (fast_vec_dist(point, &moby->pos) + lim) / (lim + lim); } } else { int value; @@ -2237,13 +2237,13 @@ void FUN_L08_002e3870(struct Moby *m) { float size; BoltSource_4BE8 *src; - switch (m->oclass) { + switch (moby->oclass) { case 0x305: { int i; int j; int n; - D_0014BEC0[current_level_index][m->command] = 1; + D_0014BEC0[current_level_index][moby->command] = 1; n = 0; for (i = 0; i < 20; i++) { for (j = 0; j < 4; j++) { @@ -2266,48 +2266,48 @@ void FUN_L08_002e3870(struct Moby *m) { break; } k = 0.7f; - FUN_L00_00257d78(mt, frame_time * k, frame_time); - fast_vec_scale_c(mt + 4, mt, 10.0f); - add_vector_xyz(mt + 4, mt + 4, &m->pos); + FUN_L00_00257d78(matrix, frame_time * k, frame_time); + fast_vec_scale_c(matrix + 4, matrix, 10.0f); + add_vector_xyz(matrix + 4, matrix + 4, &moby->pos); spin = random_integer_below_c2(2); if (spin == 0) { spin--; } size = random_float_between_c5(0.4f, 0.5f); - FUN_L00_00272060(mt + 4, scale_game_frames_c(0x19), size * 0.2f, size, 0x7F207F7F, 0, spin, mt, 0.0f); + FUN_L00_00272060(matrix + 4, scale_game_frames_c(0x19), size * 0.2f, size, 0x7F207F7F, 0, spin, matrix, 0.0f); spin = -spin; - FUN_L00_00272060(mt + 4, scale_game_frames_c(0x19), size * 0.14f, size * k, 0x7F7F7F7F, 1, spin, mt, 0.0f); - src = m->parent; + FUN_L00_00272060(matrix + 4, scale_game_frames_c(0x19), size * 0.14f, size * k, 0x7F7F7F7F, 1, spin, matrix, 0.0f); + src = moby->parent; if (src && !(src->id & 0x80)) { D_0014D590[current_level_index][src->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 (m < D_L08_0015FFDC) { - D_L08_001BADD0.killed[(short)m->save_id] = m->mission + 2; - if (m->mission == 0xFF || (D_L08_0015FC88_macro[m->mission] != 0xFF && D_0014C050[m->mission + current_level_index * 16] == 0xFF)) { - D_L08_001BBA30.killed[(short)m->save_id] = m->mission + 2; + if (moby < D_L08_0015FFDC) { + D_L08_001BADD0.killed[(short)moby->save_id] = moby->mission + 2; + 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_c3(m); + mark_moby_for_removal_c3(moby); return; } } - multiply_matrix_basis_columns(&m->rot_row0, d, &m->rot_row0); + multiply_matrix_basis_columns(&moby->rot_row0, vars, &moby->rot_row0); break; } case 4: { - Vars_4BE8 *d = (Vars_4BE8 *)m->pvars; + Vars_4BE8 *vars = (Vars_4BE8 *)moby->pvars; - add_vector_xyz(&m->pos, &m->pos, d->v40); - d->v40[2] -= frame_time_sq * 10.8f; - multiply_matrix_basis_columns(&m->rot_row0, d, &m->rot_row0); - if (m->pos.z < 2.0f || m->pos.x > 510.0f || m->pos.x < 2.0f || m->pos.y > 510.0f || m->pos.y < 2.0f) { + add_vector_xyz(&moby->pos, &moby->pos, vars->v40); + vars->v40[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 value; BoltSource_4BE8 *src; - switch (m->oclass) { + switch (moby->oclass) { case 0x3DD: value = 10; break; @@ -2318,123 +2318,123 @@ void FUN_L08_002e3870(struct Moby *m) { value = 1; break; } - src = m->parent; + src = moby->parent; if (src && !(src->id & 0x80)) { D_0014D590[current_level_index][src->id].bolts += value; } D_0015ED98 += value; level_bolts[current_level_index] += value; - mark_moby_for_removal_c3(m); + mark_moby_for_removal_c3(moby); return; } - if (m->pos.z < d->f60 - 4.0f && m->pos.z < ((Hero *)(((char *)((char *)&hero))))->motion.pos.f[2] - 4.0f) { - Vars_4BE8 *e = (Vars_4BE8 *)m->pvars; + 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_p *)e->v10 = *(u128_4BE8_p *)((char *)((char *)&hero) + 0x90); - e->i68 = scale_game_frames_c(1); - m->state = 2; + *(u128_4BE8_p *)vars->v10 = *(u128_4BE8_p *)((char *)&hero + 0x90); + vars->i68 = scale_game_frames_c(1); + moby->state = 2; break; } - if (FUN_L00_001f0d60(0.25f, &m->pos, 0x22, m) != 0) { - subtract_vector_xyz(a, &m->pos, ((CollPos_4BE8 *)D_L08_00174660)->pos); - FUN_L00_001ff660(d->v40, d->v40, a); - if (fast_arc_tan(a[2], func_001F9CE8_2E16A0(a)) < 0.7853982f + if (FUN_L00_001f0d60(0.25f, &moby->pos, 0x22, moby) != 0) { + subtract_vector_xyz(direction, &moby->pos, ((CollPos_4BE8 *)D_L08_00174660)->pos); + FUN_L00_001ff660(vars->v40, vars->v40, 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 *cl = (Coll_4BE8 *)((char *)D_L08_00174660 - 0x20); + Coll_4BE8 *coll = (Coll_4BE8 *)((char *)D_L08_00174660 - 0x20); int n; float inv; - m->flags &= ~0x100; - d = (Vars_4BE8 *)m->pvars; + moby->flags &= ~0x100; + vars = (Vars_4BE8 *)moby->pvars; n = truncate_float_to_s32_c5(FUN_001f96b0(D_L08_00161CD0_gp + random_float_between_c5(-10.0f, 10.0f))); inv = 1.0f / convert_integer_to_float(n); - qcopy(d->v0_p, cl->pos); - matrix_to_euler(&m->rot_row0, &m->rot); - fast_vec_normalize_c2(a, cl->n, 1.0f); - FUN_L08_002e4db8_c((char *)m, a); - d->f60 = random_angle_radians_c2(); - d->f64 = random_angle_radians_c2(); - FUN_L08_002e4e90_c((char *)m, d->v20, d->v30); - subtract_vector_xyz(d->v40, d->v20, &m->pos); - fast_vec_scale_c(d->v40, d->v40, inv); - if (cl->moby != 0) { - unsigned char *q = FUN_L00_002603d0(cl->moby); - - if (q != 0) { - add_vector_xyz(d->v40, d->v40, q + 0x10); - fast_vec_scale_c(b, q + 0x10, convert_integer_to_float(n)); - add_vector_xyz(d->v20, d->v20, b); - add_vector_xyz(d->v0_p, d->v0_p, b); + qcopy(vars->v0_p, coll->pos); + matrix_to_euler(&moby->rot_row0, &moby->rot); + 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->v40, vars->v20, &moby->pos); + fast_vec_scale_c(vars->v40, vars->v40, inv); + if (coll->moby != 0) { + unsigned char *platform = FUN_L00_002603d0(coll->moby); + + if (platform != 0) { + add_vector_xyz(vars->v40, vars->v40, platform + 0x10); + fast_vec_scale_c(point, platform + 0x10, convert_integer_to_float(n)); + add_vector_xyz(vars->v20, vars->v20, point); + add_vector_xyz(vars->v0_p, vars->v0_p, point); } } - d->v40[2] += frame_time_sq * 10.8f * (float)(n >> 1); - d->f50 = fast_subtract_rotations_c2(d->v30[0], m->rot.x) * inv; - d->f54 = fast_subtract_rotations_c2(d->v30[1], m->rot.y) * inv; - d->f58 = fast_subtract_rotations_c2(d->v30[2], m->rot.z) * inv; - m->state = 5; - d->i68 = n; - d->u7C.i = D_L08_00174658_lui; - if (absolute_float(m->pos.z - ((Hero *)(((char *)((char *)&hero))))->motion.pos.f[2]) < ((Hero *)(((char *)((char *)&hero))))->reach_distance - && vector_distance_xy_alt(&m->pos, ((Hero *)(((char *)((char *)&hero))))->motion.pos.f) < ((Hero *)(((char *)((char *)&hero))))->reach_height) { - Vars_4BE8 *e = (Vars_4BE8 *)m->pvars; - - e->i68 = scale_game_frames_c(1); - m->state = 2; + vars->v40[2] += frame_time_sq * 10.8f * (float)(n >> 1); + vars->f50 = fast_subtract_rotations_c2(vars->v30[0], moby->rot.x) * inv; + vars->f54 = fast_subtract_rotations_c2(vars->v30[1], moby->rot.y) * inv; + vars->f58 = fast_subtract_rotations_c2(vars->v30[2], moby->rot.z) * inv; + moby->state = 5; + vars->i68 = n; + vars->u7C.i = D_L08_00174658_lui; + 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->i68 = scale_game_frames_c(1); + moby->state = 2; } } } break; } case 5: { - Vars_4BE8 *d = (Vars_4BE8 *)m->pvars; - - m->rot.x = fast_add_rotations_c4(m->rot.x, d->f50); - m->rot.y = fast_add_rotations_c4(m->rot.y, d->f54); - m->rot.z = fast_add_rotations_c4(m->rot.z, d->f58); - add_vector_xyz(&m->pos, &m->pos, d->v40); - d->v40[2] -= frame_time_sq * 10.8f; - if (tick_countdown_32_alt(&d->i68) != 0) { + Vars_4BE8 *vars = (Vars_4BE8 *)moby->pvars; + + moby->rot.x = fast_add_rotations_c4(moby->rot.x, vars->f50); + moby->rot.y = fast_add_rotations_c4(moby->rot.y, vars->f54); + moby->rot.z = fast_add_rotations_c4(moby->rot.z, vars->f58); + add_vector_xyz(&moby->pos, &moby->pos, vars->v40); + vars->v40[2] -= frame_time_sq * 10.8f; + if (tick_countdown_32_alt(&vars->i68) != 0) { int n; float inv; - if (absolute_float(m->pos.z - ((Hero *)(((char *)((char *)&hero))))->motion.pos.f[2]) < ((Hero *)(((char *)((char *)&hero))))->reach_distance - && vector_distance_xy_alt(&m->pos, ((Hero *)(((char *)((char *)&hero))))->motion.pos.f) < ((Hero *)(((char *)((char *)&hero))))->reach_height) { - d->i68 = scale_game_frames_c(1); - m->state = 2; + 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->i68 = scale_game_frames_c(1); + moby->state = 2; break; } - if (m->command != 0) { - m->state = 1; - if (d->u7C.i != 0) { - Vars_4BE8 *e = (Vars_4BE8 *)m->pvars; + if (moby->command != 0) { + moby->state = 1; + if (vars->u7C.i != 0) { + Vars_4BE8 *vars = (Vars_4BE8 *)moby->pvars; - FUN_L00_00260668(m, e->u7C.i, e->v0_p, e->v10, e->v20, e->v30); + FUN_L00_00260668(moby, vars->u7C.i, vars->v0_p, vars->v10, vars->v20, vars->v30); } else { - qcopy(&m->pos, d->v20); - qcopy(&m->rot, d->v30); + qcopy(&moby->pos, vars->v20); + qcopy(&moby->rot, vars->v30); } break; } n = truncate_float_to_s32_c5((float)scale_game_frames_c(20)); inv = 1.0f / convert_integer_to_float(n); - m->command++; - d->f50 = fast_subtract_rotations_c2(d->v30[0], m->rot.x) * inv; - d->f54 = fast_subtract_rotations_c2(d->v30[1], m->rot.y) * inv; - d->f58 = fast_subtract_rotations_c2(d->v30[2], m->rot.z) * inv; - subtract_vector_xyz(d->v40, d->v20, &m->pos); - fast_vec_scale_c(d->v40, d->v40, inv); - d->i68 = n; - if (d->u7C.i != 0) { - unsigned char *q = FUN_L00_002603d0(d->u7C.i); - - if (q != 0) { - add_vector_xyz(d->v40, d->v40, q + 0x10); - fast_vec_scale_c(a, q + 0x10, convert_integer_to_float(n)); - add_vector_xyz(d->v20, d->v20, a); - add_vector_xyz(d->v0_p, d->v0_p, a); + moby->command++; + vars->f50 = fast_subtract_rotations_c2(vars->v30[0], moby->rot.x) * inv; + vars->f54 = fast_subtract_rotations_c2(vars->v30[1], moby->rot.y) * inv; + vars->f58 = fast_subtract_rotations_c2(vars->v30[2], moby->rot.z) * inv; + subtract_vector_xyz(vars->v40, vars->v20, &moby->pos); + fast_vec_scale_c(vars->v40, vars->v40, inv); + vars->i68 = n; + if (vars->u7C.i != 0) { + unsigned char *platform = FUN_L00_002603d0(vars->u7C.i); + + if (platform != 0) { + add_vector_xyz(vars->v40, vars->v40, platform + 0x10); + fast_vec_scale_c(direction, platform + 0x10, convert_integer_to_float(n)); + add_vector_xyz(vars->v20, vars->v20, direction); + add_vector_xyz(vars->v0_p, vars->v0_p, direction); } } - d->v40[2] += frame_time_sq * 10.8f * (float)(n >> 1); + vars->v40[2] += frame_time_sq * 10.8f * (float)(n >> 1); } break; } From c0c52587dd1d2a7329eb2bd58232a0a7c0e8396c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Sat, 17 Oct 2026 07:45:14 +0000 Subject: [PATCH 28/33] chore: names by use in the level 10 platform update --- src/overlays/l10/gameplay/entities/platform.c | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/overlays/l10/gameplay/entities/platform.c b/src/overlays/l10/gameplay/entities/platform.c index 25750b49f3..13488c81b5 100644 --- a/src/overlays/l10/gameplay/entities/platform.c +++ b/src/overlays/l10/gameplay/entities/platform.c @@ -475,31 +475,31 @@ extern struct Moby * D_L10_0015FFD8; #define func_L00_002E9AF8_2BFBB8 FUN_L00_002e8648 #define func_L00_002E9A18_2BFBB8 FUN_L00_002e8568 -void FUN_L10_002be858(char *m) +void FUN_L10_002be858(char *moby) { - int *data = *(int **)(m + 0x78); + int *data = *(int **)(moby + 0x78); float position[4]; float velocity[4]; float offset[4]; float angle; - float *op; + float *offset_ptr; int i; - char *g; + char *hero_bytes; int life; - if (*(unsigned char *)(m + 0x20) == 0) { + if (*(unsigned char *)(moby + 0x20) == 0) { D_L10_001618A8 = 0; D_L10_001618A4 = func_001F9850_2BFBB8(D_L10_001618A4); D_L10_001618A0 = func_001F9850_2BFBB8(D_L10_001618A0); - *(unsigned char *)(m + 0x20) = 1; + *(unsigned char *)(moby + 0x20) = 1; } - g = D_0013F350; - if ((unsigned char)g[0x20A4] == 1 && *data != -1 && - func_001F9D48_2BFBB8(m + 0x10, g + 0x80) < 0.5f) { - op = offset; + hero_bytes = D_0013F350; + if ((unsigned char)hero_bytes[0x20A4] == 1 && *data != -1 && + func_001F9D48_2BFBB8(moby + 0x10, hero_bytes + 0x80) < 0.5f) { + offset_ptr = offset; i = 9; do { float size, size_scaled; - int red, green, blue, color, spin, gk; + int red, green, blue, color, spin, green_alpha; i--; size = func_002140F8_2BFBB8(0.1f, 1.0f); red = func_L00_00258BC8_2BFBB8(0x40, 0xff); @@ -509,38 +509,38 @@ void FUN_L10_002be858(char *m) velocity[1] = func_001F9FA8_2BFBB8(func_00214158_2BFBB8()) * func_002140F8_2BFBB8(0.0f, 0.5f); velocity[2] = 0.0f; velocity[2] += func_002140F8_2BFBB8(0.0f, 0.5f); - func_L00_001FF240_2BFBB8(op, velocity, D_0013F350 + 0x80); + func_L00_001FF240_2BFBB8(offset_ptr, 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)); - gk = (green << 8) | 0x7f000000; - color = (blue << 16) | gk | red; + green_alpha = (green << 8) | 0x7f000000; + color = (blue << 16) | green_alpha | red; size_scaled = size * 0.07f; size *= 0.7f; 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); - func_0022ED80_2BFBB8(0, 0, (int)m); + func_0022ED80_2BFBB8(0, 0, (int)moby); { - int di = *data << 8; - char *effect = (*(char * *)&D_L10_0015FFD8) + di; + int moby_offset = *data << 8; + char *effect = (*(char * *)&D_L10_0015FFD8) + moby_offset; func_L00_00217718_2BFBB8(effect + 0x10, effect + 0x40, 0x43, 0); } { - char *b180 = D_L10_00167100; - char *effect = *(char **)(b180 + 0x180); + char *table = D_L10_00167100; + char *effect = *(char **)(table + 0x180); D_L10_001618A8 = D_L10_001618A0; if (*(short *)(effect + 0x86) == 0) { - char *e = *(char **)(b180 + 0x180); - short *timer = (short *)(*(char **)(e + 0x70) + 0x20); + char *current = *(char **)(table + 0x180); + short *timer = (short *)(*(char **)(current + 0x70) + 0x20); *timer = func_001F9850_2BFBB8(0x5a); - qcopy(e + 0x40, e); + qcopy(current + 0x40, current); } } i = 9; do { float size, size_scaled; - int red, green, blue, color, spin, gk; + int red, green, blue, color, spin, green_alpha; *(Q_2BFBB8 *)velocity = 0; velocity[0] = func_002140F8_2BFBB8(-1.0f, 1.0f); i--; @@ -554,12 +554,12 @@ void FUN_L10_002be858(char *m) velocity[1] = func_001F9FA8_2BFBB8(func_00214158_2BFBB8()) * func_002140F8_2BFBB8(0.0f, 0.5f); velocity[2] = 0.0f; velocity[2] += func_002140F8_2BFBB8(0.0f, 0.5f); - func_L00_001FF240_2BFBB8(op, velocity, (*(char * *)&D_L10_0015FFD8) + (*data << 8) + 0x10); + func_L00_001FF240_2BFBB8(offset_ptr, 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)); - gk = (green << 8) | 0x7f000000; - color = (blue << 16) | gk | red; + green_alpha = (green << 8) | 0x7f000000; + color = (blue << 16) | green_alpha | red; size_scaled = size * 0.07f; size *= 0.7f; spin = func_002140B0_2BFBB8(2) ? 1 : -1; @@ -569,7 +569,7 @@ void FUN_L10_002be858(char *m) if (D_L10_0015F5CC % func_001F9850_2BFBB8(0x3c) == 0 && *data != -1) { for (i = 0; i < func_001FA898_2BFBB8(16.0f); i++) { char *effect; - *(Q_2BFBB8 *)position = *(Q_2BFBB8 *)(m + 0x10); + *(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) { @@ -587,7 +587,7 @@ void FUN_L10_002be858(char *m) angle = phase * 3.1415927f; } if (3.1415927f < angle) angle -= 6.2831855f; - *(unsigned int *)(m + 0x90) = func_001FA8A8_2BFBB8(0x80464646, 0x80828282, (func_001F9FA8_2BFBB8(angle) + 1.0f) * 0.5f); + *(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; From dd87fe7a2626f946d870a4c9426bc34bd8232f8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Sat, 17 Oct 2026 07:45:36 +0000 Subject: [PATCH 29/33] chore: names by use in the help screen and vendor updates --- .../shared/gameplay/vendor/003015d0.c | 36 +++---- src/overlays/shared/ui/help/001ff938.c | 94 +++++++++---------- 2 files changed, 65 insertions(+), 65 deletions(-) diff --git a/src/overlays/shared/gameplay/vendor/003015d0.c b/src/overlays/shared/gameplay/vendor/003015d0.c index 339402d7f2..7e6bfced3d 100644 --- a/src/overlays/shared/gameplay/vendor/003015d0.c +++ b/src/overlays/shared/gameplay/vendor/003015d0.c @@ -283,18 +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; - 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; @@ -304,7 +304,7 @@ void FUN_L14_00301de8(char *m) { do { next_i = i + 1; for (k = 2; k >= 0; k--) { - char *row = d + (i << 4) + (2 - k) * 0x40; + char *row = vars + (i << 4) + (2 - k) * 0x40; add_vector_xyz(row + 0x460, row + 0x460, row + 0x560); } i = next_i; @@ -314,21 +314,21 @@ 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; } } #ifndef NON_MATCHING diff --git a/src/overlays/shared/ui/help/001ff938.c b/src/overlays/shared/ui/help/001ff938.c index 8355873b31..dc37ad4f27 100644 --- a/src/overlays/shared/ui/help/001ff938.c +++ b/src/overlays/shared/ui/help/001ff938.c @@ -41,8 +41,8 @@ extern void FUN_L15_002044c8(void); extern void FUN_L15_0021d040(void); void FUN_L15_001ff938(void) { - unsigned char *b0, *b1, *b2, *b3, *b4, *b5, *b6; - unsigned char *moby; + 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; unsigned int color; @@ -52,101 +52,101 @@ void FUN_L15_001ff938(void) { FUN_L00_00211670(); FUN_L15_002044c8(); FUN_L15_0021d040(); - b0 = ((char *)&D_0013F350); - if (b0[0x20A4] == 0) + hero0 = ((char *)&D_0013F350); + if (hero0[0x20A4] == 0) return; FUN_L00_00216f10(); FUN_L00_002054e8(); - if (b0[0x20A4] == 0) + if (hero0[0x20A4] == 0) return; FUN_L00_00208a10(); FUN_L00_00207c48(); FUN_L00_00207a58(); - FUN_L00_002484e0(b0 + 0x80); + FUN_L00_002484e0(hero0 + 0x80); - if (b0[0x20A4] == 2) { + if (hero0[0x20A4] == 2) { if ((&big_head_cheat_enabled)[3] != 0) - D_L15_0017C06C[0] = (*(float *)&(*(short *)&D_0015EE18)) * 1.4f; + D_L15_0017C06C[0] = D_0015EE18 * 1.4f; FUN_L00_002059d8(); FUN_L00_002061f0(); { - unsigned char *m = *(unsigned char **)(b0 + 0x2080); - if (((*(unsigned short *)(m + 0x34) ^ 1) & 1) != 0) { - FUN_L00_0024f7c8(m, 6, copy); - qcopy(b0 + 0x1D80, copy); + unsigned char *hero_moby = *(unsigned char **)(hero0 + 0x2080); + if (((*(unsigned short *)(hero_moby + 0x34) ^ 1) & 1) != 0) { + FUN_L00_0024f7c8(hero_moby, 6, copy); + qcopy(hero0 + 0x1D80, copy); FUN_L00_00207d00(); } } } - b1 = ((char *)&D_0013F350); - if (b1[0x20A4] == 3) { + 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 *)(b1 + 0x22E0) == 2) + if (*(short *)(hero1 + 0x22E0) == 2) period = scale_game_frames(0x32); - else if (*(short *)(b1 + 0x22E0) == 1) + 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); - b2 = ((char *)&D_0013F350); - moby = *(unsigned char **)(b2 + 0x2080); + hero2 = ((char *)&D_0013F350); + hero_moby = *(unsigned char **)(hero2 + 0x2080); if (red > 0xFF) red = 0xFF; if (green > 0xFF) green = 0xFF; blue += 0x14; - *(unsigned short *)(moby + 0x34) |= 0x10; - if (*(short *)(b2 + 0x22E0) == 2) + *(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; - b3 = ((char *)&D_0013F350); - *(unsigned int *)(*(unsigned char **)(b3 + 0x2080) + 0x90) = - fast_tween_color(0.1f, *(unsigned int *)(*(unsigned char **)(b3 + 0x2080) + 0x90), color); + 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++) { - b4 = ((char *)&D_0013F350); - FUN_L00_0024f7c8(*(void **)(b4 + 0x2080), i, b4 + 0x1D50 + i * 16); + hero4 = ((char *)&D_0013F350); + FUN_L00_0024f7c8(*(void **)(hero4 + 0x2080), i, hero4 + 0x1D50 + i * 16); } alpha = 0x30; - b4 = ((char *)&D_0013F350); + hero4 = ((char *)&D_0013F350); { - unsigned char *mb = *(unsigned char **)(b4 + 0x2080); - blue = mb[0x92]; - green = mb[0x91]; - red = mb[0x90]; + unsigned char *hero_moby = *(unsigned char **)(hero4 + 0x2080); + blue = hero_moby[0x92]; + green = hero_moby[0x91]; + red = hero_moby[0x90]; } - if (*(short *)(b4 + 0x22DE) != 0) - alpha = truncate_float_to_s32((convert_integer_to_float(*(short *)(b4 + 0x22DE)) / convert_integer_to_float(0x12)) * (float)alpha); - *(unsigned int *)(b4 + 0x22E4) = (alpha << 24) | (blue << 16) | (green << 8) | red; + 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 *)(b4 + 0x22E0) = 0; - if (b4[0x20A4] == 3) { - int pending = *(int *)(b4 + 0x20B8); + *(short *)(hero4 + 0x22E0) = 0; + if (hero4[0x20A4] == 3) { + int pending = *(int *)(hero4 + 0x20B8); if (pending != 0 && pending != 0x1F) { - if (*(short *)(b4 + 0x22DE) == 0) { + if (*(short *)(hero4 + 0x22DE) == 0) { FUN_L00_00216de8(0x19, 0); - *(short *)(b4 + 0x22DE) = 0x12; - *(short *)(b4 + 0x22DC) = 1; + *(short *)(hero4 + 0x22DE) = 0x12; + *(short *)(hero4 + 0x22DC) = 1; } } else { - b5 = ((char *)&D_0013F350); - *(int *)(b5 + 0x20B8) = 0; - if (b5[0x12E7] != 0 && *(int *)(b5 + 0x300) != 0 && D_0013D4DC[0] != 0 && - *(short *)(b5 + 0x22DE) == 0) { + hero5 = ((char *)&D_0013F350); + *(int *)(hero5 + 0x20B8) = 0; + if (hero5[0x12E7] != 0 && *(int *)(hero5 + 0x300) != 0 && D_0013D4DC[0] != 0 && + *(short *)(hero5 + 0x22DE) == 0) { FUN_L00_00216de8(0x19, 0); - *(short *)(b5 + 0x22DE) = 0x12; - *(short *)(b5 + 0x22DC) = 1; + *(short *)(hero5 + 0x22DE) = 0x12; + *(short *)(hero5 + 0x22DC) = 1; } } } } FUN_L00_00208b60(); - b6 = ((char *)&D_0013F350); - FUN_L00_00257024(*(void **)(b6 + 0x2080)); + hero6 = ((char *)&D_0013F350); + FUN_L00_00257024(*(void **)(hero6 + 0x2080)); } #define NOT_SDA From dc8fa03ab76a3efb06adaf5beb3097e81f557cd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Sat, 17 Oct 2026 07:45:52 +0000 Subject: [PATCH 30/33] chore: names by use in the level 13 rocket update --- src/overlays/l13/gameplay/entities/rocket.c | 78 ++++++++++----------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/src/overlays/l13/gameplay/entities/rocket.c b/src/overlays/l13/gameplay/entities/rocket.c index e3c939b07d..c7348c41be 100644 --- a/src/overlays/l13/gameplay/entities/rocket.c +++ b/src/overlays/l13/gameplay/entities/rocket.c @@ -835,9 +835,9 @@ extern void func_L00_002592B0_309330(struct Moby *, float, float *, float, float void FUN_L13_00307e98(struct Moby *moby) { Vars_309330 *vars = (Vars_309330 *)moby->pvars; struct Moby *target; - Vec4 a; - Vec4 b; - Vec4 c; + Vec4 point; + Vec4 origin; + Vec4 direction; Shot_309330 shot; s32 near; s32 close; @@ -950,24 +950,24 @@ void FUN_L13_00307e98(struct Moby *moby) { 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, &a); - qcopy(&b, &moby->pos); - b.f[2] += 0.3f; + 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) { - c.f[0] = fast_cos(moby->rot.z); - c.f[1] = fast_sin(moby->rot.z); - c.f[2] = 1.0f; - c.f[3] = 5627.925f; - func_L00_0025A8C0_30A9B0(&shot, moby, 1, &c, 1.0f); + direction.f[0] = fast_cos(moby->rot.z); + direction.f[1] = fast_sin(moby->rot.z); + direction.f[2] = 1.0f; + direction.f[3] = 5627.925f; + func_L00_0025A8C0_30A9B0(&shot, moby, 1, &direction, 1.0f); shot.unk18 = 0; shot.unk19 = 1; shot.oclass = moby->oclass; - FUN_L00_00259d08(&a, &b, &vars->unk1E0, &b, moby, &shot, 5); + FUN_L00_00259d08(&point, &origin, &vars->unk1E0, &origin, moby, &shot, 5); } } - qcopy(&vars->unk1E0, &a); + qcopy(&vars->unk1E0, &point); if (moby->anim_flags & 2) { moby->state = 6; moby->command = 1; @@ -989,10 +989,10 @@ void FUN_L13_00307e98(struct Moby *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); - a.f[0] = 2.0f * fast_cos(moby->rot.z); - a.f[1] = 2.0f * fast_sin(moby->rot.z); - a.f[2] = 0.0f; - if (FUN_L00_00258b50(moby, &vars->ctl, &a, &b, 1.0f) & 2) { + 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(); vars->unk1A8 = convert_integer_to_float(-1) * 1.0995574f; } else { @@ -1000,8 +1000,8 @@ void FUN_L13_00307e98(struct Moby *moby) { } FUN_L00_00261d78(vars->path, &moby->pos, &moby->pos, 0.75f); close = 0; - if (FUN_L00_00261b48(vars->path, &moby->pos, &target->pos, &c) != 0 && - fast_vec_dist(&moby->pos, &c) < 0.8f) { + if (FUN_L00_00261b48(vars->path, &moby->pos, &target->pos, &direction) != 0 && + fast_vec_dist(&moby->pos, &direction) < 0.8f) { close = 1; } { @@ -1029,13 +1029,13 @@ void FUN_L13_00307e98(struct Moby *moby) { 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); - a.f[0] = 2.0f * fast_cos(moby->rot.z); - a.f[1] = 2.0f * fast_sin(moby->rot.z); - a.f[2] = 0.0f; - FUN_L00_00258b50(moby, &vars->ctl, &a, &b, 1.0f); + 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, &c) != 0 && - fast_vec_dist(&moby->pos, &c) < 0.8f) { + if (FUN_L00_00261b48(vars->path, &moby->pos, &target->pos, &direction) != 0 && + fast_vec_dist(&moby->pos, &direction) < 0.8f) { near = 1; } if (vars->unk184 == 0) { @@ -1054,24 +1054,24 @@ void FUN_L13_00307e98(struct Moby *moby) { } break; case 12: - FUN_L00_0024f7c8(moby, 0, &a); - qcopy(&b, &moby->pos); - b.f[2] += 1.5f; + 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) { - c.f[0] = fast_cos(moby->rot.z); - c.f[1] = fast_sin(moby->rot.z); - c.f[2] = 1.0f; - c.f[3] = 5627.925f; - func_L00_0025A8C0_30A9B0(&shot, moby, 1, &c, 1.0f); + direction.f[0] = fast_cos(moby->rot.z); + direction.f[1] = fast_sin(moby->rot.z); + direction.f[2] = 1.0f; + direction.f[3] = 5627.925f; + func_L00_0025A8C0_30A9B0(&shot, moby, 1, &direction, 1.0f); shot.unk18 = 0; shot.unk19 = 1; shot.oclass = moby->oclass; - FUN_L00_00259d08(&a, &b, &vars->unk1E0, &b, moby, &shot, 5); + FUN_L00_00259d08(&point, &origin, &vars->unk1E0, &origin, moby, &shot, 5); } } - qcopy(&vars->unk1E0, &a); + qcopy(&vars->unk1E0, &point); if (moby->anim_flags & 2) { moby->state = 11; if (moby->prev_seq != 1) { @@ -1083,12 +1083,12 @@ void FUN_L13_00307e98(struct Moby *moby) { 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); - a.f[0] = 2.0f * fast_cos(moby->rot.z); - a.f[1] = 2.0f * fast_sin(moby->rot.z); - a.f[2] = 0.0f; + 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, &a, &b, 1.0f); + 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) { From 58061275a03aa1a9ecb2a34774415d28e9b9cfb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Sat, 17 Oct 2026 07:49:17 +0000 Subject: [PATCH 31/33] chore: real int and float types for globals declared as short --- .../l04/gameplay/entities/big_axebot.c | 6 +- .../l05/gameplay/entities/sharkigator.c | 224 +++++----- src/overlays/l06/gameplay/entities/fred.c | 112 ++--- .../l08/gameplay/entities/bolt_thief.c | 44 +- src/overlays/l08/gameplay/entities/bomb.c | 66 +-- src/overlays/l10/gameplay/entities/platform.c | 24 +- src/overlays/l10/gameplay/entities/screamer.c | 58 +-- src/overlays/l12/gameplay/entities/003054b0.c | 24 +- src/overlays/l12/gameplay/entities/platform.c | 80 ++-- src/overlays/l13/gameplay/entities/elevator.c | 6 +- src/overlays/l13/gameplay/entities/rocket.c | 4 +- src/overlays/l14/gameplay/entities/platform.c | 4 +- .../l16/gameplay/entities/grindrail_gate.c | 12 +- src/overlays/l16/gameplay/entities/rocket.c | 56 +-- .../l17/gameplay/entities/blarg_ship.c | 14 +- src/overlays/l18/gameplay/entities/rocket.c | 158 +++---- .../shared/gameplay/entities/00264e40.c | 18 +- .../gameplay/entities/blarg_elite_commando.c | 4 +- .../gameplay/entities/blarg_space_commando.c | 90 ++-- src/overlays/shared/gameplay/entities/bomb.c | 14 +- .../shared/gameplay/entities/camera_object.c | 4 +- .../entities/gadgebot_spawn_container.c | 56 +-- .../shared/gameplay/entities/nanotech_ball.c | 18 +- .../shared/gameplay/entities/plasmabot.c | 396 +++++++++--------- src/overlays/shared/gameplay/entities/rock.c | 86 ++-- .../shared/gameplay/entities/sentrybot.c | 100 ++--- .../gameplay/entities/trackdrive_left.c | 18 +- .../gameplay/entities/underwater_ring.c | 4 +- .../shared/gameplay/entities/walloper.c | 6 +- .../shared/gameplay/hero/hero_check_damage.c | 12 +- .../shared/gameplay/hero/hero_idle_sequence.c | 2 +- .../shared/gameplay/vendor/003015d0.c | 22 +- 32 files changed, 871 insertions(+), 871 deletions(-) diff --git a/src/overlays/l04/gameplay/entities/big_axebot.c b/src/overlays/l04/gameplay/entities/big_axebot.c index 26e2163c61..1cc8a44f25 100644 --- a/src/overlays/l04/gameplay/entities/big_axebot.c +++ b/src/overlays/l04/gameplay/entities/big_axebot.c @@ -1231,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]; @@ -1258,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; } diff --git a/src/overlays/l05/gameplay/entities/sharkigator.c b/src/overlays/l05/gameplay/entities/sharkigator.c index 55b54c12ff..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" @@ -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/l06/gameplay/entities/fred.c b/src/overlays/l06/gameplay/entities/fred.c index 6379c56181..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: @@ -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/l08/gameplay/entities/bolt_thief.c b/src/overlays/l08/gameplay/entities/bolt_thief.c index ddeb2a387f..b9861a2df3 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++) { @@ -2449,18 +2449,18 @@ void FUN_L08_002e3870(struct 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 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 short D_L08_00161C84 __attribute__((sda)); -extern short D_L08_00161C68 __attribute__((sda)); -extern short D_L08_00161C6C __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 short D_L08_00161C70 __attribute__((sda)); -extern short D_L08_00161C74 __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"); @@ -2482,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 * D_L08_00161CB8; - sy = *(float *)&D_L08_00161C74 * D_L08_00161CB8; - sz = *(float *)&D_L08_00161C80 * 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 * D_L08_00161CBC; - sy = *(float *)&D_L08_00161C78 * D_L08_00161CBC; - sz = *(float *)&D_L08_00161C84 * 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 * D_L08_00161CB4; - sy = *(float *)&D_L08_00161C70 * D_L08_00161CB4; - sz = *(float *)&D_L08_00161C7C * 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 0432b183c6..c400696f02 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; @@ -293,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"); @@ -358,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; @@ -2806,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"); @@ -2841,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 13488c81b5..fe13660dc0 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); @@ -1623,8 +1623,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))); @@ -1635,8 +1635,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 3c8272d1d6..d1770241bb 100644 --- a/src/overlays/l10/gameplay/entities/screamer.c +++ b/src/overlays/l10/gameplay/entities/screamer.c @@ -1087,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) { @@ -1096,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); } } @@ -1258,12 +1258,12 @@ 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 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 *, @@ -1301,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; @@ -1336,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; @@ -1344,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; @@ -1484,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); @@ -1511,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) { @@ -1530,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) { @@ -1594,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; @@ -1606,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; } } @@ -1627,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; @@ -1713,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; @@ -1800,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; @@ -2286,7 +2286,7 @@ extern float FUN_001f9e90(float, float); #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]; @@ -2295,8 +2295,8 @@ 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); @@ -2415,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[]; @@ -2466,7 +2466,7 @@ 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); @@ -2542,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); @@ -2552,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); @@ -2600,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)); } @@ -2626,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) { diff --git a/src/overlays/l12/gameplay/entities/003054b0.c b/src/overlays/l12/gameplay/entities/003054b0.c index 60332862a3..0d718a1a35 100644 --- a/src/overlays/l12/gameplay/entities/003054b0.c +++ b/src/overlays/l12/gameplay/entities/003054b0.c @@ -565,9 +565,9 @@ 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 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); @@ -676,9 +676,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; @@ -696,9 +696,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); @@ -731,9 +731,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; diff --git a/src/overlays/l12/gameplay/entities/platform.c b/src/overlays/l12/gameplay/entities/platform.c index 459b41a403..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 { @@ -3003,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); @@ -3019,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; @@ -3068,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]; @@ -3123,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); @@ -3133,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 5850300252..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); diff --git a/src/overlays/l13/gameplay/entities/rocket.c b/src/overlays/l13/gameplay/entities/rocket.c index c7348c41be..a6e549f48c 100644 --- a/src/overlays/l13/gameplay/entities/rocket.c +++ b/src/overlays/l13/gameplay/entities/rocket.c @@ -1339,7 +1339,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 *); @@ -1354,7 +1354,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; diff --git a/src/overlays/l14/gameplay/entities/platform.c b/src/overlays/l14/gameplay/entities/platform.c index 7f7cb69bd2..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 { diff --git a/src/overlays/l16/gameplay/entities/grindrail_gate.c b/src/overlays/l16/gameplay/entities/grindrail_gate.c index 9f8a2392fc..c6307dabf4 100644 --- a/src/overlays/l16/gameplay/entities/grindrail_gate.c +++ b/src/overlays/l16/gameplay/entities/grindrail_gate.c @@ -1872,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]; @@ -1889,8 +1889,8 @@ 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; + 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); @@ -1898,7 +1898,7 @@ void FUN_L16_002e7a30(unsigned char *m, void *v) { 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)); diff --git a/src/overlays/l16/gameplay/entities/rocket.c b/src/overlays/l16/gameplay/entities/rocket.c index 9446cd349f..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: @@ -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/l17/gameplay/entities/blarg_ship.c b/src/overlays/l17/gameplay/entities/blarg_ship.c index cd201dd9b2..1e69672ba4 100644 --- a/src/overlays/l17/gameplay/entities/blarg_ship.c +++ b/src/overlays/l17/gameplay/entities/blarg_ship.c @@ -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 e0ca724af7..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. */ @@ -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/gameplay/entities/00264e40.c b/src/overlays/shared/gameplay/entities/00264e40.c index 4cc19795fc..00b1cc3642 100644 --- a/src/overlays/shared/gameplay/entities/00264e40.c +++ b/src/overlays/shared/gameplay/entities/00264e40.c @@ -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"); @@ -77,14 +77,14 @@ void FUN_L02_00264e70(char *slots, float *position, float *direction, float dist } acceleration = frame_time_sq_macro; advance_accelerated_scalar(&speed, &travel_step, travel, 1.0f, acceleration * 48.0f, - (*(float *)&D_L02_001600D0) * frame_time_macro); + (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)) * frame_time_macro); + (((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); diff --git a/src/overlays/shared/gameplay/entities/blarg_elite_commando.c b/src/overlays/shared/gameplay/entities/blarg_elite_commando.c index 9151b9c827..31439e3227 100644 --- a/src/overlays/shared/gameplay/entities/blarg_elite_commando.c +++ b/src/overlays/shared/gameplay/entities/blarg_elite_commando.c @@ -824,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); @@ -876,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 2cc4f3b3fc..f09a20d416 100644 --- a/src/overlays/shared/gameplay/entities/blarg_space_commando.c +++ b/src/overlays/shared/gameplay/entities/blarg_space_commando.c @@ -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; @@ -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 4a48dfc2b1..12c1b6543d 100644 --- a/src/overlays/shared/gameplay/entities/bomb.c +++ b/src/overlays/shared/gameplay/entities/bomb.c @@ -1010,10 +1010,10 @@ 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 short D_L00_00161870 __attribute__((sda)); -extern short D_L00_00161874 __attribute__((sda)); -extern short D_L00_00161878 __attribute__((sda)); -extern short D_L00_00161888 __attribute__((sda)); +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[]; @@ -1127,15 +1127,15 @@ char *FUN_L00_002caf70(char *owner, char *spawn_pos, char *target, float unk18, *(float *)(moby + 0x44) = -fast_arc_tan_c2(length, direction[2]); return moby; } else { - FUN_L00_0026daa0(moby, 0x2F4F7F7F, *(short *)(vars + 0x24), -1, *(float *)&D_L00_00161888); + 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(*(float *)&D_L00_00161870, *(float *)&D_L00_00161874); + *(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); curve = FUN_L00_00257e20(-1.5f, 0.0f, 1.0f, 0.0f, fraction); - *(float *)(trail + 0xC) = *(float *)(trail + 0xC) + (*(float *)&D_L00_00161878 - *(float *)(trail + 0xC)) * curve; + *(float *)(trail + 0xC) = *(float *)(trail + 0xC) + (D_L00_00161878 - *(float *)(trail + 0xC)) * curve; result = truncate_float_to_s32_c(curve * -64.0f + 128.0f); *(int *)(trail + 4) = (result << 24) | 0xFFFFFF; ((int *)(vars + 0x2C))[i] = (int)trail; diff --git a/src/overlays/shared/gameplay/entities/camera_object.c b/src/overlays/shared/gameplay/entities/camera_object.c index 728fb40bd7..9c88487be8 100644 --- a/src/overlays/shared/gameplay/entities/camera_object.c +++ b/src/overlays/shared/gameplay/entities/camera_object.c @@ -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 6c010f907b..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. */ @@ -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 a9044fda44..4c71b6a76f 100644 --- a/src/overlays/shared/gameplay/entities/nanotech_ball.c +++ b/src/overlays/shared/gameplay/entities/nanotech_ball.c @@ -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)); @@ -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 b8e3fea187..f3f86f09e0 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); } @@ -356,11 +356,11 @@ 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 short D_L14_001614E4_gp __asm__("D_L14_001614E4") __attribute__((sda)); -extern short D_L14_001614E8_gp __asm__("D_L14_001614E8") __attribute__((sda)); -extern short D_L14_001614EC_gp __asm__("D_L14_001614EC") __attribute__((sda)); -extern short D_L14_001614F0; -extern short D_L14_001614F4_gp __asm__("D_L14_001614F4") __attribute__((sda)); +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 *); @@ -397,82 +397,82 @@ void attach_manipulator(void *owner, s32 slot_index, void *manip) __asm__("FUN_0 #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 *m) { +void FUN_L14_002b17d8(char *moby) { char *data; char *owner; - int st; + int state; float mat[4][4]; - float v[4]; + float offset[4]; float hit[4]; Ray ray; int x_p; - data = *(char **)(m + 0x78); + data = *(char **)(moby + 0x78); owner = 0; - FUN_L00_00263ac8(2.5f, m, 2, data + 0x120); + FUN_L00_00263ac8(2.5f, moby, 2, data + 0x120); if (*(int *)(data + 0x288) != 0) { if (((unsigned char *)D_001413F4)[0] != 2) { - *(unsigned short *)(m + 0x34) |= 0x41; - *(int *)(m + 0x94) = 0; - if (((unsigned char *)m)[0x53] == 5) { - FUN_L00_002e2040(m); - FUN_L00_00257470(m, 0, -1); - { call_D678(m); return; } + *(unsigned short *)(moby + 0x34) |= 0x41; + *(int *)(moby + 0x94) = 0; + if (((unsigned char *)moby)[0x53] == 5) { + FUN_L00_002e2040(moby); + FUN_L00_00257470(moby, 0, -1); + { call_D678(moby); return; } } - ((unsigned char *)m)[0x30] = 0xFF; - *(unsigned short *)(m + 0x34) &= 0xEFFF; + ((unsigned char *)moby)[0x30] = 0xFF; + *(unsigned short *)(moby + 0x34) &= 0xEFFF; return; } - *(unsigned short *)(m + 0x34) &= 0xFFBE; - if (((unsigned char *)m)[0x20] != 0xB) { - *(int *)(m + 0x94) = *(int *)(*(char **)(m + 0x24) + 0x10); + *(unsigned short *)(moby + 0x34) &= 0xFFBE; + if (((unsigned char *)moby)[0x20] != 0xB) { + *(int *)(moby + 0x94) = *(int *)(*(char **)(moby + 0x24) + 0x10); } - ((unsigned char *)m)[0x30] = 0x40; - *(unsigned short *)(m + 0x34) |= 0x1000; + ((unsigned char *)moby)[0x30] = 0x40; + *(unsigned short *)(moby + 0x34) |= 0x1000; } - if (((unsigned char *)m)[0x20] != 0) { - FUN_L14_002b2f60_c(m); - FUN_L14_002b3268_c(m); - FUN_L14_002b2ed8_c((struct Moby *)m); + 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 (D_L14_0015F5C4 == 2) { - ((unsigned char *)m)[0x31] = 0; - *(unsigned short *)(m + 0x34) |= 1; - } else if (((unsigned char *)m)[0x20] != 1) { - ((unsigned char *)m)[0x31] = 1; - *(unsigned short *)(m + 0x34) &= 0xFFFE; + ((unsigned char *)moby)[0x31] = 0; + *(unsigned short *)(moby + 0x34) |= 1; + } else if (((unsigned char *)moby)[0x20] != 1) { + ((unsigned char *)moby)[0x31] = 1; + *(unsigned short *)(moby + 0x34) &= 0xFFFE; } - switch (((unsigned char *)m)[0x20]) { + switch (((unsigned char *)moby)[0x20]) { case 0: { if (((unsigned char *)data)[0x24A] != 0) { if (*(int *)(data + 0x240) == -1) { - DebugPrint(D_L14_001FBB60, *(short *)(m + 0xB2)); - { call_D678(m); return; } + DebugPrint(D_L14_001FBB60, *(short *)(moby + 0xB2)); + { call_D678(moby); return; } } if (*D_L14_001B0BB0[*(int *)(data + 0x240)] == 0) { - DebugPrint(D_L14_001FBBA0, *(short *)(m + 0xB2)); - { call_D678(m); return; } + DebugPrint(D_L14_001FBBA0, *(short *)(moby + 0xB2)); + { call_D678(moby); return; } } } if (*(int *)(data + 0x244) == -1) { - DebugPrint(D_L14_001FBBF8, *(short *)(m + 0xB2)); - { call_D678(m); return; } + DebugPrint(D_L14_001FBBF8, *(short *)(moby + 0xB2)); + { call_D678(moby); return; } } if (*D_L14_001B0BB0[*(int *)(data + 0x244)] == 0) { - DebugPrint(D_L14_001FBC38, *(short *)(m + 0xB2)); - { call_D678(m); return; } + DebugPrint(D_L14_001FBC38, *(short *)(moby + 0xB2)); + { call_D678(moby); return; } } if (((unsigned char *)data)[0x24A] != 0 && *(int *)(data + 0x264) < 0) { - DebugPrint(D_L14_001FBC90, *(short *)(m + 0xB2)); - { call_D678(m); return; } + DebugPrint(D_L14_001FBC90, *(short *)(moby + 0xB2)); + { call_D678(moby); return; } } if (random_integer_below(2) != 0) { - *(unsigned short *)(m + 0x34) |= 0x8000; + *(unsigned short *)(moby + 0x34) |= 0x8000; } - FUN_L14_002b3358_c(m); + FUN_L14_002b3358_c(moby); if (*(int *)(data + 0x240) != -1) { - qcopy(m + 0x10, (char *)D_L14_001B0BB0[*(int *)(data + 0x240)] + 0x10); + qcopy(moby + 0x10, (char *)D_L14_001B0BB0[*(int *)(data + 0x240)] + 0x10); } data[0x28] = 1; data[0x29] = 0; @@ -492,36 +492,36 @@ void FUN_L14_002b17d8(char *m) { *(int *)(data + 0x270) = 0; *(int *)(data + 0x274) = 0; if (((unsigned char *)data)[0x121] == 0) { - attach_manipulator(m, 2, data + 0x120); + attach_manipulator(moby, 2, data + 0x120); } if (((unsigned char *)data)[0x161] == 0) { - attach_manipulator(m, 3, data + 0x160); + attach_manipulator(moby, 3, data + 0x160); } if (((unsigned char *)data)[0x24A] != 0) { - FUN_L14_002b3318_c(m); - ((unsigned char *)m)[0x20] = 1; + FUN_L14_002b3318_c(moby); + ((unsigned char *)moby)[0x20] = 1; return; } - *(float *)(m + 0x18) = probe_ground_height(0.5f, m + 0x10, 0); + *(float *)(moby + 0x18) = probe_ground_height(0.5f, moby + 0x10, 0); if (*(int *)(data + 0x240) == -1) { - ((unsigned char *)m)[0x20] = 4; + ((unsigned char *)moby)[0x20] = 4; } else { - ((unsigned char *)m)[0x20] = 0xD; + ((unsigned char *)moby)[0x20] = 0xD; } return; } case 1: { - float *p; + float *path; if (*(int *)(data + 0x114) == 2) return; if (FUN_001f9770(data + 0x248) == 0) return; if (FUN_L14_002d9870_c(*(int *)(data + 0x264)) == 0) return; - if (call_4BF0(m) == 0) return; - *(short *)(data + 0x248) = scale_game_frames(*(int *)&D_L14_001614F0); - FUN_L14_002b3330_c(m); - ((unsigned char *)m)[0x20] = 2; - set_moby_animation(m, 1, 0); - p = (float *)D_L14_001B0BB0[*(int *)(data + 0x240)]; - *(float *)(m + 0x48) = fast_arc_tan_c(p[8] - p[4], p[9] - p[5]); + 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; *(float *)(data + 0x27C) = 1.0f; *(int *)(data + 0x26C) = 0; @@ -535,24 +535,24 @@ void FUN_L14_002b17d8(char *m) { return; } case 2: - if (compute_interpolated_record_value(m) >= 3.0f) { - FUN_L14_002b3418_c(m); + if (compute_interpolated_record_value(moby) >= 3.0f) { + FUN_L14_002b3418_c(moby); } - if ((m[0x70] & 2) && ((unsigned char *)m)[0x52] == ((unsigned char *)m)[0x53]) { - ((unsigned char *)m)[0x20] = 3; - blend_moby_animation(m, 3, 0, scale_game_frames(10)); - *(float *)(m + 0x58) = 1.0f; + 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: { - float *p = (float *)D_L14_001B0BB0[*(int *)(data + 0x240)]; - FUN_L00_0025b8c0((float *)(m + 0x10), (float *)(data + 0x254), p[4], 0.01f, 0.2f, 0.0f); - FUN_L00_0025b8c0((float *)(m + 0x14), (float *)(data + 0x258), p[5], 0.01f, 0.2f, 0.0f); - if ((m[0x70] & 2) && ((unsigned char *)m)[0x52] == ((unsigned char *)m)[0x53]) { - blend_moby_animation(m, 0, 0, scale_game_frames(10)); - ((unsigned char *)m)[0x20] = 1; - *(float *)(m + 0x58) = 1.0f; - FUN_L14_002b3318_c(m); + 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; @@ -560,15 +560,15 @@ void FUN_L14_002b17d8(char *m) { case 13: { float ang; float k; - ang = fast_arc_tan_c(*(float *)(owner + 0x10) - *(float *)(m + 0x10), - *(float *)(owner + 0x14) - *(float *)(m + 0x14)); + ang = fast_arc_tan_c(*(float *)(owner + 0x10) - *(float *)(moby + 0x10), + *(float *)(owner + 0x14) - *(float *)(moby + 0x14)); k = frame_time_sq * 12.566371f; - call_CE58((float *)(m + 0x48), ang, (float *)(data + 0x23C), k, k, frame_time * 6.2831855f); + 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 *)m)[0x20] = 3; - blend_moby_animation(m, 3, 0, scale_game_frames(10)); - *(float *)(m + 0x58) = 1.0f; + ((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; @@ -578,22 +578,22 @@ void FUN_L14_002b17d8(char *m) { break; } case 3: - if (FUN_L14_002b3418_c(m) != 0) { - blend_moby_animation(m, 0, 0, scale_game_frames(10)); - ((unsigned char *)m)[0x20] = 4; + 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 (((unsigned char *)data)[0x24A] != 0) { FUN_L14_002d9870_c(*(int *)(data + 0x264)); } - if (FUN_L14_002b3418_c(m) != 0) { + if (FUN_L14_002b3418_c(moby) != 0) { if (((unsigned char *)data)[0x24A] != 0) { - blend_moby_animation(m, 2, 0, scale_game_frames(10)); - ((unsigned char *)m)[0x20] = 9; + blend_moby_animation(moby, 2, 0, scale_game_frames(10)); + ((unsigned char *)moby)[0x20] = 9; } else { - *(short *)(data + 0x248) = scale_game_frames(*(int *)&D_L14_001614F0); - ((unsigned char *)m)[0x20] = 0xD; + *(short *)(data + 0x248) = scale_game_frames(D_L14_001614F0); + ((unsigned char *)moby)[0x20] = 0xD; } } break; @@ -601,157 +601,157 @@ void FUN_L14_002b17d8(char *m) { float ang; float k; float aim; - FUN_L14_002b3578_c(m); - ang = fast_arc_tan_c(*(float *)(owner + 0x10) - *(float *)(m + 0x10), - *(float *)(owner + 0x14) - *(float *)(m + 0x14)); + 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; - call_CE58((float *)(m + 0x48), ang, (float *)(data + 0x23C), k, k, frame_time * 6.2831855f); - aim = FUN_L14_002b35d8_c(m, 0, *(float *)(m + 0x48)); - FUN_L14_002b37b0_c(m, ang); + 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) break; - ((unsigned char *)m)[0x20] = 8; - if (((unsigned char *)m)[0x53] != 3) { - blend_moby_animation(m, 3, 0, scale_game_frames(0x14)); + ((unsigned char *)moby)[0x20] = 8; + if (((unsigned char *)moby)[0x53] != 3) { + blend_moby_animation(moby, 3, 0, scale_game_frames(0x14)); } { int n = *(int *)(data + 0x24C) - 1; - char *pe; + char *path; *(int *)(data + 0x24C) = n; - pe = (char *)D_L14_001B0BB0[*(int *)(data + 0x240)]; - *(float *)(data + 0x250) = *(float *)(pe + (n << 4) + 0x1C); + 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(m); + FUN_L00_002e2040(moby); break; } if (FUN_001f9770(data + 0x260) == 0) break; - if (FUN_L14_002b3920_c(((unsigned char *)m)[0x21]) >= 2) break; - if (FUN_L00_002e1f28(m, 1, 0) == 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 *)(m + 0x48), ang) < 0.017453292f)) 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), m + 0x10, owner + 0x10) != 0) break; - FUN_L14_002b3890_c(((unsigned char *)m)[0x21]); + 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 *)m)[0x20] = 5; - blend_moby_animation(m, 4, 0, scale_game_frames(5)); - *(short *)(data + 0x262) = scale_game_frames(*(int *)&D_L14_001614EC_gp); + ((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 ang; - ang = fast_arc_tan_c(*(float *)(owner + 0x10) - *(float *)(m + 0x10), - *(float *)(owner + 0x14) - *(float *)(m + 0x14)); - FUN_L14_002b35d8_c(m, 0, fast_subtract_rotations_c2(ang, *(float *)&D_L14_001614E8_gp)); - FUN_L14_002b37b0_c(m, ang); - if ((m[0x70] & 2) && ((unsigned char *)m)[0x52] == ((unsigned char *)m)[0x53]) { - blend_moby_animation(m, 5, 0, scale_game_frames(10)); - ((unsigned char *)m)[0x20] = 6; + 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: { int flag; float ang; - float t; - float c; - float f; + float progress; + float sweep; + float angle; flag = 0; - ang = fast_arc_tan_c(*(float *)(owner + 0x10) - *(float *)(m + 0x10), - *(float *)(owner + 0x14) - *(float *)(m + 0x14)); - t = convert_integer_to_float(*(short *)(data + 0x262)); - t = t / convert_integer_to_float(scale_game_frames(*(int *)&D_L14_001614EC_gp)); - c = *(float *)&D_L14_001614E8_gp; - f = fast_subtract_rotations_c2(*(float *)(data + 0x278), -c + (c + c) * t); + 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 *)(m + 0x18) < 0.0f) { + if (*(float *)(owner + 0x18) + 0.1f - *(float *)(moby + 0x18) < 0.0f) { flag = 1; } } - FUN_L14_002b35d8_c(m, flag, f); - FUN_L14_002b37b0_c(m, ang); - build_moby_bone_transform_c(m, 0, mat); - qcopy(v, mat[1]); + FUN_L14_002b35d8_c(moby, flag, angle); + FUN_L14_002b37b0_c(moby, ang); + build_moby_bone_transform_c(moby, 0, mat); + qcopy(offset, mat[1]); if (flag == 0) { - v[2] = 0.0f; + offset[2] = 0.0f; } - fast_vec_normalize(v, v, *(float *)&D_L14_001614E4_gp); - add_vector_xyz_c3(hit, mat[3], v); - fast_vec_normalize(v, v, *(float *)&D_L14_001614F4_gp); - add_vector_xyz_c3(mat[3], mat[3], v); - ray.moby = m; + fast_vec_normalize(offset, offset, D_L14_001614E4_gp); + add_vector_xyz_c3(hit, mat[3], offset); + fast_vec_normalize(offset, offset, D_L14_001614F4_gp); + add_vector_xyz_c3(mat[3], mat[3], offset); + ray.moby = moby; ray.flags = 0x10001; ray.f = 1; ray.e = 1.0f; - ray.a_p = fast_cos(*(float *)(m + 0x48)); - ray.b = fast_sin(*(float *)(m + 0x48)); + ray.a_p = fast_cos(*(float *)(moby + 0x48)); + ray.b = fast_sin(*(float *)(moby + 0x48)); ray.c = 1.0f; ray.d = 5627.9248f; ray.b99 = 1; - ray.cls = *(unsigned short *)(m + 0xA6); + ray.cls = *(unsigned short *)(moby + 0xA6); ray.b98 = 0; - if (FUN_001efa68(mat[3], hit, 0, m, &ray) != 0) { + if (FUN_001efa68(mat[3], hit, 0, moby, &ray) != 0) { qcopy(hit, D_L14_00174560); } - FUN_L00_002e2190(m, mat, hit); + FUN_L00_002e2190(moby, mat, hit); if (FUN_001f9770(data + 0x262) != 0) { - blend_moby_animation(m, 6, 0, scale_game_frames(10)); - ((unsigned char *)m)[0x20] = 7; - FUN_L00_002e2040(m); + blend_moby_animation(moby, 6, 0, scale_game_frames(10)); + ((unsigned char *)moby)[0x20] = 7; + FUN_L00_002e2040(moby); } break; } case 7: - if ((m[0x70] & 2) && ((unsigned char *)m)[0x52] == ((unsigned char *)m)[0x53]) { - blend_moby_animation(m, 0, 0, scale_game_frames(10)); - ((unsigned char *)m)[0x20] = 4; + 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; } break; case 10: { - long n = ((unsigned char *)m)[0x52]; - if ((m[0x70] & 2) && (unsigned char)n == ((unsigned char *)m)[0x53]) { + 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 *)m)[0x53] == 7) break; + if (((unsigned char *)moby)[0x53] == 7) break; idle: - blend_moby_animation(m, 0, 0, 10); - ((unsigned char *)m)[0x20] = 4; + blend_moby_animation(moby, 0, 0, 10); + ((unsigned char *)moby)[0x20] = 4; break; } case 11: { - if ((FUN_L00_0025c698(m, data + 0x60) & 0x160) == 0) return; - FUN_L00_002e2040(m); - FUN_L00_0024f7c8(m, 2, mat); - FUN_L14_002dea98_c(m, (char *)mat); - call_F4A8(m, data + 0x40, m + 0x10, 0.0f, 0.0f, 5, 2, 4, 2.0f, 1.0f, 9.0f, 1.0f, -1, 15.0f, 1, 1, -1, 0); + if ((FUN_L00_0025c698(moby, data + 0x60) & 0x160) == 0) return; + FUN_L00_002e2040(moby); + 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(m, 0x200, -1); - { call_D678(m); return; } + FUN_L00_00257470(moby, 0x200, -1); + { call_D678(moby); return; } } - FUN_L00_00257470(m, 0, -1); - { call_D678(m); return; } + FUN_L00_00257470(moby, 0, -1); + { call_D678(moby); return; } } case 12: { - FUN_L00_0024f7c8(m, 2, mat); - FUN_L14_002dea98_c(m, (char *)mat); + FUN_L00_0024f7c8(moby, 2, mat); + FUN_L14_002dea98_c(moby, (char *)mat); x_p = 0; - ((void (*)(char *, int *, int))FUN_L14_002e0170_c)(m, &x_p, 1); - FUN_L00_002e2040(m); - call_D678(m); + ((void (*)(char *, int *, int))FUN_L14_002e0170_c)(moby, &x_p, 1); + FUN_L00_002e2040(moby); + call_D678(moby); return; } } - st = ((unsigned char *)m)[0x20]; - if (!(st >= 4 && st <= 7) && st != 1) { - FUN_L14_002b35d8_c(m, 0, *(float *)(m + 0x48)); - FUN_L14_002b37b0_c(m, *(float *)(m + 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_c((struct Moby *)m); + FUN_L14_002b2600_c((struct Moby *)moby); } #include "rnc/math/vector.h" #include "rnc/gameplay/entities/moby.h" @@ -1152,14 +1152,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; @@ -1528,10 +1528,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; @@ -1551,12 +1551,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); @@ -1679,10 +1679,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; @@ -1716,13 +1716,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 8e5e3c986b..ece6302503 100644 --- a/src/overlays/shared/gameplay/entities/rock.c +++ b/src/overlays/shared/gameplay/entities/rock.c @@ -763,7 +763,7 @@ extern int cutscene_mode __asm__("D_L01_0015F5C4"); 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 && big_head_cheat_enabled != 0) { int 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/sentrybot.c b/src/overlays/shared/gameplay/entities/sentrybot.c index 8eaba3124d..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; @@ -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 54a9c4e8fb..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); } } } diff --git a/src/overlays/shared/gameplay/entities/underwater_ring.c b/src/overlays/shared/gameplay/entities/underwater_ring.c index f38a2e88e8..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); diff --git a/src/overlays/shared/gameplay/entities/walloper.c b/src/overlays/shared/gameplay/entities/walloper.c index 135cdae30f..f1a1992470 100644 --- a/src/overlays/shared/gameplay/entities/walloper.c +++ b/src/overlays/shared/gameplay/entities/walloper.c @@ -1219,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"); @@ -1296,7 +1296,7 @@ char *FUN_L00_002bc3b0(char *self, float *position, float *heading, float *pitch 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; @@ -1308,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) diff --git a/src/overlays/shared/gameplay/hero/hero_check_damage.c b/src/overlays/shared/gameplay/hero/hero_check_damage.c index 672f715505..82e1bf6445 100644 --- a/src/overlays/shared/gameplay/hero/hero_check_damage.c +++ b/src/overlays/shared/gameplay/hero/hero_check_damage.c @@ -1337,7 +1337,7 @@ typedef struct { float x, y, z, w; } __attribute__((aligned(16))) V4_F7F8; 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"); @@ -1375,19 +1375,19 @@ void FUN_L00_0020f160(char *arg) { { 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 *)((char *)&hero_lui)); - if (*(int *)(b + 0x21C0) < *(int *)&D_L00_0015F694) { + 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; } } diff --git a/src/overlays/shared/gameplay/hero/hero_idle_sequence.c b/src/overlays/shared/gameplay/hero/hero_idle_sequence.c index 57fadc2bfb..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]; diff --git a/src/overlays/shared/gameplay/vendor/003015d0.c b/src/overlays/shared/gameplay/vendor/003015d0.c index 7e6bfced3d..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); From ab14c77d8b03900b4354170e1bb96bd4ec55a079 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Sat, 17 Oct 2026 07:52:57 +0000 Subject: [PATCH 32/33] chore: drop duplicate port types and _p name suffixes --- .../l07/gameplay/entities/taxi_platform.c | 66 +++------- .../l08/gameplay/entities/bolt_thief.c | 24 ++-- src/overlays/l08/gameplay/entities/bomb.c | 10 +- src/overlays/l13/gameplay/entities/rocket.c | 9 +- .../shared/gameplay/entities/plasmabot.c | 115 ++---------------- .../shared/gameplay/entities/veldin_ship.c | 94 +++++++------- 6 files changed, 90 insertions(+), 228 deletions(-) diff --git a/src/overlays/l07/gameplay/entities/taxi_platform.c b/src/overlays/l07/gameplay/entities/taxi_platform.c index 86705e96e4..c6f1b4fe21 100644 --- a/src/overlays/l07/gameplay/entities/taxi_platform.c +++ b/src/overlays/l07/gameplay/entities/taxi_platform.c @@ -2555,50 +2555,12 @@ int FUN_L07_0030f540(unsigned char *moby, int lower, int upper) { /* 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. */ -typedef u32 VecQuad_p __attribute__((mode(TI), aligned(16))); -typedef union { - VecQuad_p q; - f32 f[4]; - s32 i[4]; -} Vec4_p; - -typedef struct { - float x; /* 0x00 */ - float y; /* 0x04 */ - float z; /* 0x08 */ - char padC[0x10]; - unsigned char b1C; /* 0x1C */ - unsigned char b1D; /* 0x1D */ - short h1E; /* 0x1E */ - char rest[0x1170]; -} Rec_30D8E8_p; - -typedef u32 u128_p __attribute__((mode(TI), aligned(16))); - -struct WalkerPath_p { - s32 count; - u8 pad4[0xC]; - Vec4_p pts[1]; -}; - -struct WalkerData_p { - u8 pad0[0xF0]; - Vec4_p goal; /* 0xF0 */ - u8 pad100[0x28]; - struct WalkerPath_p *path; /* 0x128 */ - u8 pad12C[8]; - s32 wander; /* 0x134 */ - u8 pad138[4]; - f32 heading; /* 0x13C */ - f32 turnStep; /* 0x140 */ -}; - -struct Tgt_3109D0_p { +struct WalkerTarget { float pos[4]; - u128_p q10; - u128_p q20; - u128_p q30; + u128 q10; + u128 q20; + u128 q30; int moby; int kind; }; @@ -2643,7 +2605,7 @@ int FUN_L07_0030f4d0_c(void *moby, int id, float scale) __asm__("FUN_L07_0030f4d 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_p *data) __asm__("FUN_L07_0030eee8"); +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[]; @@ -2654,7 +2616,7 @@ extern void func_L00_002A5158_30D8E8(void *, int, int, float, float, float, floa void FUN_L07_0030f5f0(unsigned char *moby) { char *data; - struct Tgt_3109D0_p tgt; + struct WalkerTarget tgt; float pos[4]; float off[4]; float rel[4]; @@ -2742,25 +2704,25 @@ void FUN_L07_0030f5f0(unsigned char *moby) { if (moby[0x20] == 0xE || moby[0x20] == 0xC) { height += height; } - if (0.5f < vector_distance_xy_alt(moby + 0x10, (Vec4_p *)&D_L07_00173EE0)) { - scale = vector_distance_xy_alt(moby + 0x10, (Vec4_p *)&D_L07_00173EE0); + 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((*(Rec_30D8E8_p * *)&D_L07_001612D0), D_L07_001612D8, 1, F(moby, 0x10), F(moby, 0x14), scale, height); + 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); pos[0] += random_float_between_c2(-0.15f, 0.15f); pos[1] += random_float_between_c2(-0.15f, 0.15f); - pos[2] = resolve_camera_surface_height((Vec4_p *)&D_L07_00173EE0, 0); + pos[2] = resolve_camera_surface_height((Vec4 *)&D_L07_00173EE0, 0); FUN_L00_002715e8(pos, 0, -1, size, 5250.0f); } } if (1.0f <= F(data, 0x14C)) { - *(u128_p *)&D_0013F3D0 = *(u128_p *)(moby + 0x10); + *(u128 *)&D_0013F3D0 = *(u128 *)(moby + 0x10); } switch (moby[0x20]) { @@ -2827,7 +2789,7 @@ void FUN_L07_0030f5f0(unsigned char *moby) { moby[0x20] = 1; } } - FUN_L07_0030eee8_c((struct Moby *)moby, (struct WalkerData_p *)data); + 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) { @@ -2946,7 +2908,7 @@ void FUN_L07_0030f5f0(unsigned char *moby) { float seven = 7.0f; float pi = 3.14159274f; float pi2 = 1.57079637f; - FUN_L07_0030eee8_c((struct Moby *)moby, (struct WalkerData_p *)data); + 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); @@ -3012,7 +2974,7 @@ void FUN_L07_0030f5f0(unsigned char *moby) { moby[0x20] = 7; } } - FUN_L07_0030eee8_c((struct Moby *)moby, (struct WalkerData_p *)data); + 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) { diff --git a/src/overlays/l08/gameplay/entities/bolt_thief.c b/src/overlays/l08/gameplay/entities/bolt_thief.c index b9861a2df3..5a523820ca 100644 --- a/src/overlays/l08/gameplay/entities/bolt_thief.c +++ b/src/overlays/l08/gameplay/entities/bolt_thief.c @@ -1897,7 +1897,7 @@ typedef struct Hero Hero; typedef int u128_4BE8_p __attribute__((mode(TI))); typedef struct { - float v0_p[4]; /* 0x00 */ + float anchor[4]; /* 0x00 */ float v10[4]; /* 0x10 */ float v20[4]; /* 0x20 */ float v30[4]; /* 0x30 */ @@ -1928,12 +1928,12 @@ typedef struct { } BoltSource_4BE8; typedef struct { - u16 unk0_p; + u16 unk0; u16 bolts; } BoltSourceStats_4BE8; typedef struct { - unsigned char pad_p[0x454]; + unsigned char pad[0x454]; unsigned char killed[1]; } KillFlags_4BE8; @@ -2043,7 +2043,7 @@ void FUN_L08_002e3870(struct Moby *moby) { D_L08_00161CD4_gp = D_L08_0015F5CC; } moby->flags &= ~0x100; - qcopy(vars->v0_p, &moby->pos); + qcopy(vars->anchor, &moby->pos); if (vars->s6E == 0) { fast_vec_normalize_c2(point, &moby->rot_row2, 0.1f); add_vector_xyz(point, point, &moby->pos); @@ -2051,11 +2051,11 @@ void FUN_L08_002e3870(struct Moby *moby) { add_vector_xyz(local, local, &moby->pos); if (FUN_001efa68(point, local, 2, 0, 0) != 0) { CollPos_4BE8 *hit = (CollPos_4BE8 *)D_L08_00174660; - qcopy(vars->v0_p, hit->pos); + qcopy(vars->anchor, hit->pos); linked = ((int *)hit)[-2]; fast_vec_normalize_c2(direction, hit->n, 1.0f); } else { - qcopy(vars->v0_p, &moby->pos); + qcopy(vars->anchor, &moby->pos); clear_u64_value(direction); direction[2] = 1.0f; } @@ -2066,7 +2066,7 @@ void FUN_L08_002e3870(struct Moby *moby) { 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_p, 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; @@ -2078,7 +2078,7 @@ void FUN_L08_002e3870(struct Moby *moby) { 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_p, vars->v10); + 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->v40); @@ -2348,7 +2348,7 @@ void FUN_L08_002e3870(struct Moby *moby) { vars = (Vars_4BE8 *)moby->pvars; n = truncate_float_to_s32_c5(FUN_001f96b0(D_L08_00161CD0_gp + random_float_between_c5(-10.0f, 10.0f))); inv = 1.0f / convert_integer_to_float(n); - qcopy(vars->v0_p, coll->pos); + qcopy(vars->anchor, coll->pos); matrix_to_euler(&moby->rot_row0, &moby->rot); fast_vec_normalize_c2(direction, coll->n, 1.0f); FUN_L08_002e4db8_c((char *)moby, direction); @@ -2364,7 +2364,7 @@ void FUN_L08_002e3870(struct Moby *moby) { add_vector_xyz(vars->v40, vars->v40, platform + 0x10); fast_vec_scale_c(point, platform + 0x10, convert_integer_to_float(n)); add_vector_xyz(vars->v20, vars->v20, point); - add_vector_xyz(vars->v0_p, vars->v0_p, point); + add_vector_xyz(vars->anchor, vars->anchor, point); } } vars->v40[2] += frame_time_sq * 10.8f * (float)(n >> 1); @@ -2408,7 +2408,7 @@ void FUN_L08_002e3870(struct Moby *moby) { if (vars->u7C.i != 0) { Vars_4BE8 *vars = (Vars_4BE8 *)moby->pvars; - FUN_L00_00260668(moby, vars->u7C.i, vars->v0_p, 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); @@ -2431,7 +2431,7 @@ void FUN_L08_002e3870(struct Moby *moby) { add_vector_xyz(vars->v40, vars->v40, platform + 0x10); fast_vec_scale_c(direction, platform + 0x10, convert_integer_to_float(n)); add_vector_xyz(vars->v20, vars->v20, direction); - add_vector_xyz(vars->v0_p, vars->v0_p, direction); + add_vector_xyz(vars->anchor, vars->anchor, direction); } } vars->v40[2] += frame_time_sq * 10.8f * (float)(n >> 1); diff --git a/src/overlays/l08/gameplay/entities/bomb.c b/src/overlays/l08/gameplay/entities/bomb.c index c400696f02..0356d2f3c4 100644 --- a/src/overlays/l08/gameplay/entities/bomb.c +++ b/src/overlays/l08/gameplay/entities/bomb.c @@ -1457,14 +1457,14 @@ char *FUN_L08_002daa10(struct Moby *moby) { /* 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_p[0x20]; struct Moby *moby; } Hit_2D5FA8_c; +typedef struct { char pad0[0x20]; struct Moby *moby; } Hit_2D5FA8_c; -typedef struct { char pad0_p[0x140]; float x, y; char pad148[0x10]; float f158; } Cam_DBF68; +typedef struct { char pad0[0x140]; float x, y; char pad148[0x10]; float f158; } Cam_DBF68; -typedef struct { char pad0_p[0x40]; struct Moby *target; int r44; } Look_DBF68; +typedef struct { char pad0[0x40]; struct Moby *target; int r44; } Look_DBF68; typedef struct { - char pad0_p[0x20]; + char pad0[0x20]; float health; char pad24[5]; unsigned char b29; @@ -1507,7 +1507,7 @@ typedef struct { char blk160[0x10]; } Data_DBF68; -typedef struct { char pad0_p[0x140]; float x,y,z,w; } Camera46_c; +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"); diff --git a/src/overlays/l13/gameplay/entities/rocket.c b/src/overlays/l13/gameplay/entities/rocket.c index a6e549f48c..7caaf5774b 100644 --- a/src/overlays/l13/gameplay/entities/rocket.c +++ b/src/overlays/l13/gameplay/entities/rocket.c @@ -744,10 +744,9 @@ void FUN_L13_00307b10(struct Moby *moby) { /* 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 u32 VecQuad_p __attribute__((mode(TI), aligned(16))); typedef struct { - u8 pad0_p[0x18]; + u8 pad0[0x18]; u8 unk18; u8 unk19; s16 oclass; @@ -755,7 +754,7 @@ typedef struct { } Shot_309330; typedef struct { - s32 unk0_p; + s32 unk0; f32 unk4; f32 unk8; f32 unkC; @@ -765,7 +764,7 @@ typedef struct { } Ctl_309330; typedef struct { - u8 pad0_p[0x20]; + u8 pad0[0x20]; f32 unk20; s16 unk24; u8 pad26[2]; @@ -861,7 +860,7 @@ void FUN_L13_00307e98(struct Moby *moby) { FUN_L01_0026d930(&vars->ctl); vars->ctl.unk8 = 2.0f; vars->ctl.unkC = 0.5f; - vars->ctl.unk0_p = func_001FA898_r(D_L13_00161E58_gp * 716.8f); + 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); diff --git a/src/overlays/shared/gameplay/entities/plasmabot.c b/src/overlays/shared/gameplay/entities/plasmabot.c index f3f86f09e0..b1ced6553e 100644 --- a/src/overlays/shared/gameplay/entities/plasmabot.c +++ b/src/overlays/shared/gameplay/entities/plasmabot.c @@ -218,18 +218,7 @@ unsigned char *FUN_L14_002ffaf8(unsigned char *owner, char *pos) { /* 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 { - char _pad00_p[0x10]; - unsigned char nframes; -} AnimSeq_2b17d8; - -typedef int u128_96938_p __attribute__((mode(TI))); - -struct Manip; - -typedef struct MobyClass MobyClass; - -typedef struct { - float a_p; + float a; float b; float c; float d; @@ -242,94 +231,6 @@ typedef struct { int f; } Ray; -typedef struct { - f32 x_p; - f32 y; - f32 z; - f32 w; -} Vec4f_00AC8; - -struct MobyClass_00AC8_p { - u8 pad_0[0xC]; - u8 seq_count; /* number of entries in seqs[] (menu previews clamp the sequence to it) */ - u8 pad_D[3]; - u32 collision; /* collision data; copied into struct Moby.collision when a_p moby is (re)classed */ - u8 pad_14[0x8]; - void *retarget_table; /* retarget table: word table, indexed id * 4 + 4 (0024eec0) */ - struct GifEntry *gifs; /* patched by patch_moby_gifs */ - f32 scale; /* default draw scale: copied into struct Moby.scale, divides it */ - s32 sound_defs; /* sound definitions, 0x20 bytes each */ - void **callbacks; /* function-pointer table, called with the moby */ - u8 pad_30[0x14]; - u16 flags; /* initial struct Moby.flags */ - s16 type; /* class type; 5 (a_p creature) is tested by targeting code */ - struct AnimSeq_2b17d8 *seqs[1]; /* animation sequences, indexed by struct Moby.seq */ -}; - -struct Moby_00AC8_p { - Vec4f_00AC8 bsphere; - Vec4f_00AC8 pos; - u8 state; /* >= 0xFE: dead, waiting to respawn */ - u8 group; /* linked group: index into the level moby-list table D_Lxx_001ABCC0 (0xFF: none) */ - u8 class_slot; /* class slot: pclass = D_L00_00197300[class_slot] (crate_update) */ - u8 alpha; /* 0x80 by default; 0x40 for the smoke trail FUN_L09_00307ba8 spawns */ - struct MobyClass_00AC8_p *pclass; - struct Moby_00AC8_p *next; - f32 scale; /* draw scale (FUN_L01_002fa068 halves it, FUN_L00_00215ef8 divides by it) */ - u8 update_dist; /* update distance; 0xFF (always) or 0x7F for beams, set by spawners */ - u8 visible; /* drawn last frame; set to 1 by spawners */ - s16 draw_dist; /* draw distance; 0xFF (0x7F for beams), set by spawners */ - u16 flags; - u16 occlusion; /* occlusion bits; 0x7F80 set by spawners */ - u64 spawn_frame; /* frame count at which it may respawn */ - Vec4f_00AC8 rot; /* z: yaw (FUN_L00_00266448 compares it with atan2 to the hero) */ - u8 frame; /* animation frame */ - u8 prev_frame; /* frame index in prev_seq */ - u8 seq; /* animation sequence id */ - u8 prev_seq; - f32 anim_time; - f32 anim_speed; - u8 pad5C[8]; - struct Manip *manips; - void *cur_frame_data; - void *prev_frame_data; - u8 anim_flags; - u8 unk71; /* set to 0xFF when a_p moby changes class */ - u8 unk72; - u8 unk73; - void (*update)(struct Moby_00AC8_p *moby); - u8 *pvars; - u8 unk7C; - u8 sound_slot; /* 0x7D: D_0013E550 slot of its looping sound, 0xFF: none (FUN_L00_00232670) */ - u8 anim_trigger_count; - u8 shadow_range; /* shadow range in units of 1024; 0x17 from FUN_L09_002c5990 near D_L09_00166F40 */ - u8 pad80[6]; - s16 unk86; - u8 pad88[8]; - s32 glow_color; /* glow colour (class header + 0x40) */ - u32 collision; /* collision data, from the class header (MobyClass.collision) */ - s32 collision_disable; /* per-primitive collision disable bits; 1 while a_p carrier holds the moby (FUN_L00_002c7a58) */ - u8 pad9C[8]; - u8 hit_slot; /* hit-message slot (0xFF: none) */ - u8 padA5; - s16 oclass; - u8 padA8[8]; - u8 mission; /* 0xB0: index into the level's D_0014C050 row (0xFF: not spawned) */ - u8 padB1; - u16 save_id; /* index into the level collected[]/killed[] tables and save bits D_0014C190[level][id >> 5] */ - s16 unkB4; - u8 padB6[2]; - void *parent; /* 0xB8: spawner (bolt source record); its byte 0xB1 is a_p per-level id (FUN_L00_002a6b70) */ - u8 command; /* external command byte */ - u8 padBD[3]; - Vec4f_00AC8 rot_row0; /* 0xC0: rows of the matrix built from rot (FUN_001fa030) */ - Vec4f_00AC8 rot_row1; - Vec4f_00AC8 rot_row2; - u8 padF0[0x10]; -}; - -typedef struct Moby_00AC8_p Moby_00AC8_p; - extern char D_001413F4[]; extern char D_L14_001FBB60[]; extern char D_L14_001FBBA0[]; @@ -365,7 +266,7 @@ 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_00AC8_p *, 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_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"); @@ -374,7 +275,7 @@ 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 x_p) __asm__("FUN_L14_002b35d8"); +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"); @@ -388,7 +289,7 @@ 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 *a_p, float x_p) __asm__("FUN_L14_002b37b0"); +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"); @@ -405,7 +306,7 @@ void FUN_L14_002b17d8(char *moby) { float offset[4]; float hit[4]; Ray ray; - int x_p; + int status; data = *(char **)(moby + 0x78); owner = 0; @@ -685,7 +586,7 @@ void FUN_L14_002b17d8(char *moby) { ray.flags = 0x10001; ray.f = 1; ray.e = 1.0f; - ray.a_p = fast_cos(*(float *)(moby + 0x48)); + ray.a = fast_cos(*(float *)(moby + 0x48)); ray.b = fast_sin(*(float *)(moby + 0x48)); ray.c = 1.0f; ray.d = 5627.9248f; @@ -739,8 +640,8 @@ void FUN_L14_002b17d8(char *moby) { case 12: { FUN_L00_0024f7c8(moby, 2, mat); FUN_L14_002dea98_c(moby, (char *)mat); - x_p = 0; - ((void (*)(char *, int *, int))FUN_L14_002e0170_c)(moby, &x_p, 1); + status = 0; + ((void (*)(char *, int *, int))FUN_L14_002e0170_c)(moby, &status, 1); FUN_L00_002e2040(moby); call_D678(moby); return; diff --git a/src/overlays/shared/gameplay/entities/veldin_ship.c b/src/overlays/shared/gameplay/entities/veldin_ship.c index fbaaec414a..438ef19490 100644 --- a/src/overlays/shared/gameplay/entities/veldin_ship.c +++ b/src/overlays/shared/gameplay/entities/veldin_ship.c @@ -531,9 +531,9 @@ 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; +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; @@ -545,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) @@ -566,19 +566,19 @@ void FUN_L00_002d09b8(M2d1428 *m, s32 hit, s32 source) { *(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 = m; + 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: @@ -602,28 +602,28 @@ void FUN_L00_002d09b8(M2d1428 *m, s32 hit, s32 source) { 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; + 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]); @@ -631,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 *)self + 0x94) = 0; - m->state = 3; - *(u16 *)((u8 *)m + 0x34) |= 1; - m->bBC = FUN_001fef20_2d09b8(15); + 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; @@ -678,15 +678,15 @@ 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); } } void FUN_L00_002d1428(M2d1428 *m) { From 6653aadff2ec5f8a9584fb39a0379b735f444e6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Sat, 17 Oct 2026 08:28:16 +0000 Subject: [PATCH 33/33] chore: keep main's names in the new functions Carries the local, field and function names main's drafts used into the exact code (taxi platform, bolt thief, bombs, platform, rocket, plasmabot, map setup, help and text screens). --- .../l07/gameplay/entities/taxi_platform.c | 216 +++++++++--------- .../l08/gameplay/entities/bolt_thief.c | 184 +++++++-------- src/overlays/l08/gameplay/entities/bomb.c | 12 +- src/overlays/l10/gameplay/entities/platform.c | 13 +- src/overlays/l12/gameplay/entities/003054b0.c | 17 +- src/overlays/l13/gameplay/entities/rocket.c | 28 +-- src/overlays/shared/gameplay/entities/bomb.c | 44 ++-- .../shared/gameplay/entities/plasmabot.c | 68 +++--- src/overlays/shared/rendering/00245c28.c | 34 +-- src/overlays/shared/ui/help/001ff938.c | 14 +- src/overlays/shared/ui/text/002377b8.c | 4 +- 11 files changed, 316 insertions(+), 318 deletions(-) diff --git a/src/overlays/l07/gameplay/entities/taxi_platform.c b/src/overlays/l07/gameplay/entities/taxi_platform.c index c6f1b4fe21..2c445ce8e5 100644 --- a/src/overlays/l07/gameplay/entities/taxi_platform.c +++ b/src/overlays/l07/gameplay/entities/taxi_platform.c @@ -2616,18 +2616,18 @@ extern void func_L00_002A5158_30D8E8(void *, int, int, float, float, float, floa void FUN_L07_0030f5f0(unsigned char *moby) { char *data; - struct WalkerTarget tgt; - float pos[4]; - float off[4]; - float rel[4]; - float step[4]; - float old[4]; + struct WalkerTarget target; + float point[4]; + float offset[4]; + float goal[4]; + float delta[4]; + float previous[4]; int wander; int inside; - int anim; - int next; - unsigned char prev; - unsigned char cur; + int next_sequence; + int next_state; + unsigned char old_command; + unsigned char command; char *hero; if (moby == 0) { @@ -2646,57 +2646,57 @@ void FUN_L07_0030f5f0(unsigned char *moby) { } goto end; } - FUN_L07_002886d8(moby, &tgt, 30.0f); + FUN_L07_002886d8(moby, &target, 30.0f); FUN_L07_0030e998_c((char *)moby, data, (float *)(data + 0x20)); FUN_L00_0025d538(moby, data + 0x60); wander = tick_countdown_32_alt((int *)(data + 0x134)) != 0; if (*(int *)(data + 0x110) != 0 && moby[0x20] >= 7) { - char *area = *(char **)(data + 0x148); - inside = FUN_L00_00259740(&tgt, area + 0x10, *(int *)area) != 0; + char *path = *(char **)(data + 0x148); + inside = FUN_L00_00259740(&target, path + 0x10, *(int *)path) != 0; } else { - char *area = *(char **)(data + 0x148); + char *path = *(char **)(data + 0x148); hero = (char *)&D_0013F3D0; - inside = FUN_L00_00259740(hero, area + 0x10, *(int *)area) != 0; + inside = FUN_L00_00259740(hero, path + 0x10, *(int *)path) != 0; if (vector_distance_xy_alt(moby + 0x10, hero) < 30.0f) { - tgt.moby = *(int *)(hero + 0x2000); - qcopy(&tgt.pos, hero); - qcopy(&tgt.q10, hero + 0x10); - qcopy(&tgt.q20, hero + 0x40); - qcopy(&tgt.q30, hero + 0x50); - tgt.kind = 0; + 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 { - tgt.moby = 0; - qzero(&tgt.pos); - qzero(&tgt.q10); - qzero(&tgt.q30); - qzero(&tgt.q20); - tgt.kind = 2; + target.moby = 0; + qzero(&target.pos); + qzero(&target.q10); + qzero(&target.q30); + qzero(&target.q20); + target.kind = 2; } } if (*(int *)(data + 0x110) != 0) { - char *area = *(char **)(data + 0x128); - FUN_L00_00259740(moby + 0x10, area + 0x10, *(int *)area); + char *path = *(char **)(data + 0x128); + FUN_L00_00259740(moby + 0x10, path + 0x10, *(int *)path); } - prev = moby[0xBC]; - next = 0xFF; - anim = 0xFF; + old_command = moby[0xBC]; + next_state = 0xFF; + next_sequence = 0xFF; moby[0xBC] = FUN_L07_0030ebc8_c((char *)moby, data); - cur = moby[0xBC]; - if (prev != cur) { - next = ((struct { unsigned char t[3][3]; } *)D_L07_00161B40_gp)->t[prev][cur]; - anim = ((struct { unsigned char t[3][3]; } *)D_L07_00161B50_gp)->t[prev][cur]; + command = moby[0xBC]; + if (old_command != command) { + 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, pos); - if (FUN_L00_001f0d60(0.8f, pos, 1, moby) != 0 && FUN_001f0b58() == 0) { + 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) - pos[2])) { + 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) - pos[2]); + height = absolute_float(F(moby, 0x18) - point[2]); } if (F(data, 0xD8) < 0.0f) { height = -height; @@ -2715,10 +2715,10 @@ void FUN_L07_0030f5f0(unsigned char *moby) { } if (D_L07_0015F5CC % ((rand() & 7) + 20) == 0) { float size = random_float_between_c2(1.5f, 2.4f); - pos[0] += random_float_between_c2(-0.15f, 0.15f); - pos[1] += random_float_between_c2(-0.15f, 0.15f); - pos[2] = resolve_camera_surface_height((Vec4 *)&D_L07_00173EE0, 0); - FUN_L00_002715e8(pos, 0, -1, size, 5250.0f); + 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)) { @@ -2733,15 +2733,15 @@ void FUN_L07_0030f5f0(unsigned char *moby) { if ((moby[0x70] & 2) && moby[0x53] != 0) { blend_moby_animation(moby, 0, 0, 10); } - if (inside && tgt.moby != 0 && tgt.moby == *(int *)&D_001413D0 && + 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 (tgt.moby != 0 && tgt.moby == *(int *)&D_001413D0 && - FUN_L07_0030f4d0_c(moby, tgt.moby, 1.5f)) { + 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); } @@ -2756,18 +2756,18 @@ void FUN_L07_0030f5f0(unsigned char *moby) { } 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 != 0xFF) { - if (moby[0x53] != anim) { - blend_moby_animation(moby, anim, 0, 6); + if (next_state != 0xFF) { + if (moby[0x53] != next_sequence) { + blend_moby_animation(moby, next_sequence, 0, 6); } - moby[0x20] = next; + moby[0x20] = next_state; } goto end; case 2: if ((moby[0x70] & 2) && moby[0x53] != 1) { blend_moby_animation(moby, 1, 0, 10); } - if (inside && tgt.moby != 0 && tgt.moby == *(int *)&D_001413D0) { + 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); @@ -2799,33 +2799,33 @@ void FUN_L07_0030f5f0(unsigned char *moby) { *(int *)(data + 0x134) = rand() % 120 + 60; moby[0x20] = 1; } - if (tgt.moby != 0 && tgt.moby == *(int *)&D_001413D0 && - FUN_L07_0030f4d0_c(moby, tgt.moby, 1.5f)) { + 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_c((char *)moby, data, frame_time_sq * 15.0f, frame_time_sq * 50.0f, frame_time * 8.0f); - if (next != 0xFF) { - if (moby[0x53] != anim) { - blend_moby_animation(moby, anim, 0, 6); + if (next_state != 0xFF) { + if (moby[0x53] != next_sequence) { + blend_moby_animation(moby, next_sequence, 0, 6); } - moby[0x20] = next; + moby[0x20] = next_state; } goto end; case 4: { - float ang; + float angle; float pitch; int close = 1; float pi4 = 12.566371f; float three = 3.0f; float zero = 0.0f; - ang = fast_arc_tan_c2(tgt.pos[0] - F(moby, 0x10), tgt.pos[1] - F(moby, 0x14)); - FUN_L00_00258278((char *)moby, (float *)(data + 0x120), ang, + 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, &tgt); - pitch = fast_arc_tan_c2(pitch, tgt.pos[2] - F(moby, 0x18)); + 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)) { @@ -2834,7 +2834,7 @@ void FUN_L07_0030f5f0(unsigned char *moby) { 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, ang, 0.209439516f, frame_time_sq * 20.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) { @@ -2845,7 +2845,7 @@ void FUN_L07_0030f5f0(unsigned char *moby) { F(data, 0x14C) = zero; qcopy(data + 0x100, moby + 0x10); } - ((struct { char pad[0x138]; float f; } *)data)->f = tgt.pos[2] - 0.25f; + ((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) { @@ -2853,37 +2853,37 @@ void FUN_L07_0030f5f0(unsigned char *moby) { } moby[0x20] = 2; } - if (next != 0xFF) { - if (moby[0x53] != anim) { - blend_moby_animation(moby, anim, 0, 6); + if (next_state != 0xFF) { + if (moby[0x53] != next_sequence) { + blend_moby_animation(moby, next_sequence, 0, 6); } - moby[0x20] = next; + moby[0x20] = next_state; } goto end; } case 5: { - float ang; + float angle; char *mpos; char *start; float one; - FUN_L00_0024f7c8(moby, 0, pos); + FUN_L00_0024f7c8(moby, 0, point); mpos = (char *)moby + 0x10; - subtract_vector_xyz(off, pos, mpos); - ang = fast_arc_tan_c2(tgt.pos[0] - pos[0], tgt.pos[1] - pos[1]); - func_L00_002592B0_t((char *)moby, ang, (float *)(data + 0x120), + 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(old, mpos); - subtract_vector_xyz(rel, &tgt, off); + qcopy(previous, mpos); + subtract_vector_xyz(goal, &target, offset); start = data + 0x100; - subtract_vector_xyz(step, rel, start); + subtract_vector_xyz(delta, goal, start); one = 1.0f; - fast_vec_scale_c(step, step, F(data, 0x14C) < one ? F(data, 0x14C) : one); - add_vector_xyz(mpos, step, start); - no_op_main_callback_alt(old, mpos); + 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, old); + subtract_vector_xyz(data + 0xD0, mpos, previous); if (one <= F(data, 0x14C)) { char *hero_bytes = (char *)&D_0013F350; *(int *)(hero_bytes + 0x22A8) = 0; @@ -2892,7 +2892,7 @@ void FUN_L07_0030f5f0(unsigned char *moby) { hero_bytes[0x20A5] = 1; moby[0x20] = 6; } else { - F(data, 0x13C) = ang; + F(data, 0x13C) = angle; } if (inside || *(short *)&D_0013F65C != 0) { goto end; @@ -2919,11 +2919,11 @@ void FUN_L07_0030f5f0(unsigned char *moby) { if ((moby[0x70] & 2) && moby[0x53] != 1) { blend_moby_animation(moby, 1, 0, 10); } - if (next != 0xFF) { - if (moby[0x53] != anim) { - blend_moby_animation(moby, anim, 0, 6); + if (next_state != 0xFF) { + if (moby[0x53] != next_sequence) { + blend_moby_animation(moby, next_sequence, 0, 6); } - moby[0x20] = next; + moby[0x20] = next_state; } goto end; } @@ -2946,11 +2946,11 @@ void FUN_L07_0030f5f0(unsigned char *moby) { 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 != 0xFF) { - if (moby[0x53] != anim) { - blend_moby_animation(moby, anim, 0, 6); + if (next_state != 0xFF) { + if (moby[0x53] != next_sequence) { + blend_moby_animation(moby, next_sequence, 0, 6); } - moby[0x20] = next; + moby[0x20] = next_state; } goto end; case 8: @@ -2988,23 +2988,23 @@ void FUN_L07_0030f5f0(unsigned char *moby) { 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 != 0xFF) { - if (moby[0x53] != anim) { - blend_moby_animation(moby, anim, 0, 6); + if (next_state != 0xFF) { + if (moby[0x53] != next_sequence) { + blend_moby_animation(moby, next_sequence, 0, 6); } - moby[0x20] = next; + moby[0x20] = next_state; } goto end; case 9: case 10: { - float ang; + float angle; float pi2 = 1.57079637f; - ang = fast_arc_tan_c2(tgt.pos[0] - F(moby, 0x10), tgt.pos[1] - F(moby, 0x14)); - func_L00_002592B0_t((char *)moby, ang, (float *)(data + 0x120), + 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, ang, 0.52359879f, frame_time_sq * 4.0f, + 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, &tgt) < 1.9f && moby[0x20] != 10) { + vector_distance_xy_alt(moby + 0x10, &target) < 1.9f && moby[0x20] != 10) { if (moby[0x53] != 5) { blend_moby_animation(moby, 5, 0, 2); } @@ -3022,7 +3022,7 @@ void FUN_L07_0030f5f0(unsigned char *moby) { } moby[0x20] = 8; } - ((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, tgt.moby); + ((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); @@ -3030,11 +3030,11 @@ void FUN_L07_0030f5f0(unsigned char *moby) { *(int *)(data + 0x134) = rand() % 200 + 300; moby[0x20] = 8; } - if (next != 0xFF) { - if (moby[0x53] != anim) { - blend_moby_animation(moby, anim, 0, 6); + if (next_state != 0xFF) { + if (moby[0x53] != next_sequence) { + blend_moby_animation(moby, next_sequence, 0, 6); } - moby[0x20] = next; + moby[0x20] = next_state; } goto end; } @@ -3073,11 +3073,11 @@ void FUN_L07_0030f5f0(unsigned char *moby) { 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 != 0xFF) { - if (moby[0x53] != anim) { - blend_moby_animation(moby, anim, 0, 6); + if (next_state != 0xFF) { + if (moby[0x53] != next_sequence) { + blend_moby_animation(moby, next_sequence, 0, 6); } - moby[0x20] = next; + moby[0x20] = next_state; } goto end; case 17: diff --git a/src/overlays/l08/gameplay/entities/bolt_thief.c b/src/overlays/l08/gameplay/entities/bolt_thief.c index 5a523820ca..0d5cf87ad9 100644 --- a/src/overlays/l08/gameplay/entities/bolt_thief.c +++ b/src/overlays/l08/gameplay/entities/bolt_thief.c @@ -1901,11 +1901,11 @@ typedef struct { float v10[4]; /* 0x10 */ float v20[4]; /* 0x20 */ float v30[4]; /* 0x30 */ - float v40[4]; /* 0x40: velocity */ - float f50, f54, f58; /* 0x50: spin */ + float velocity[4]; /* 0x40 */ + float spin_x, spin_y, spin_z; /* 0x50 */ int pad5C; float f60, f64; /* 0x60 */ - int i68; /* 0x68 */ + int timer; /* 0x68 */ short s6C, s6E; /* 0x6C */ union { int i; float f; } u70; float f74; /* 0x74 */ @@ -2020,7 +2020,7 @@ void FUN_L08_002e3870(struct Moby *moby) { float direction[4]; float point[4]; float local[4]; - float matrix[16]; + float scratch[16]; switch (moby->state) { case 0: { @@ -2081,7 +2081,7 @@ void FUN_L08_002e3870(struct Moby *moby) { 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->v40); + clear_u64_value(vars->velocity); FUN_L08_0026a0f8(vars, &moby->rot_row1, D_L08_00161C98_gp * 0.017453292f * frame_time); moby->state = 4; break; @@ -2089,7 +2089,7 @@ void FUN_L08_002e3870(struct Moby *moby) { } 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->i68 = scale_game_frames_c(1); + vars->timer = scale_game_frames_c(1); moby->state = 2; } if (moby->visible == 0) { @@ -2138,19 +2138,19 @@ void FUN_L08_002e3870(struct Moby *moby) { case 2: { Vars_4BE8 *vars = (Vars_4BE8 *)moby->pvars; - euler_rotation_matrix(matrix, vars->v10); - qcopy(direction, matrix + 8); - if (tick_countdown_32_alt(&vars->i68) != 0) { + euler_rotation_matrix(scratch, vars->v10); + qcopy(direction, scratch + 8); + if (tick_countdown_32_alt(&vars->timer) != 0) { Vars_4BE8 *vars = (Vars_4BE8 *)moby->pvars; - float k = 0.017453292f; + float deg_to_rad = 0.017453292f; char *hero_pos = D_0013F3D0; 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 * k * frame_time); + FUN_L08_0026a0f8(vars, point, D_L08_00161C94_gp * deg_to_rad * frame_time); moby->flags |= 0x100; - fast_vec_normalize_c2(vars->v40, direction, frame_time * 8.0f); + fast_vec_normalize_c2(vars->velocity, direction, frame_time * 8.0f); vars->f74 = 0.0f; vars->u70.f = frame_time * 8.0f; vars->u78.p = *(char **)(hero_pos + 0x2000); @@ -2160,22 +2160,22 @@ void FUN_L08_002e3870(struct Moby *moby) { allocate_voice_for_target_entry(0, 0x20, moby); vars->f64 = 0.0f; } else { - vars->f64 = random_float_between_c5(-30.0f, 30.0f) * k; + vars->f64 = random_float_between_c5(-30.0f, 30.0f) * deg_to_rad; } moby->state = 3; } else { - if (scale_game_frames_c(10) < vars->i68) { - float yaw = fast_add_rotations_c4(vars->f60, fast_sin((float)(vars->i68 % 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, yaw, 0.5235988f, 0); + FUN_L00_0025bc00(&vars->f60, goal_yaw, 0.5235988f, 0); } else { - float yaw = fast_add_rotations_c4(fast_arc_tan(hero.motion.pos.f[0] - moby->pos.x, + 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, yaw, 0.08726646f, 0); - if (func_001FA850_2E16A0(vars->f60, yaw) < 0.08726646f) { - vars->i68 = 0; + FUN_L00_0025bc00(&vars->f60, goal_yaw, 0.08726646f, 0); + if (func_001FA850_2E16A0(vars->f60, goal_yaw) < 0.08726646f) { + vars->timer = 0; } } FUN_L08_002e4e90_c((char *)moby, (float *)&moby->pos, (float *)&moby->rot); @@ -2185,7 +2185,7 @@ void FUN_L08_002e3870(struct Moby *moby) { case 3: { Vars_4BE8 *vars = (Vars_4BE8 *)moby->pvars; float dist; - float lim; + float fade_range; if (vars->u78.p == 0) { break; @@ -2194,15 +2194,15 @@ void FUN_L08_002e3870(struct Moby *moby) { add_vector_xyz(point, point, vars->u78.p + 0x10); subtract_vector_xyz(direction, point, &moby->pos); if (vars->f64 != 0.0f) { - float sin_a = fast_sin(vars->f64); - float cos_a = fast_cos(vars->f64); + float sine = fast_sin(vars->f64); + float cosine = fast_cos(vars->f64); - direction[0] = cos_a * direction[0] + sin_a * direction[1]; - direction[1] = cos_a * direction[1] - sin_a * direction[0]; + direction[0] = cosine * direction[0] + sine * direction[1]; + direction[1] = cosine * direction[1] - sine * direction[0]; } dist = fast_vec_dist(point, &moby->pos); - fast_vec_normalize_c2(vars->v40, vars->v40, vars->u70.f); - add_vector_xyz(&moby->pos, &moby->pos, vars->v40); + fast_vec_normalize_c2(vars->velocity, vars->velocity, vars->u70.f); + add_vector_xyz(&moby->pos, &moby->pos, vars->velocity); fast_vec_normalize_c2(direction, direction, vars->f74); add_vector_xyz(&moby->pos, &moby->pos, direction); cam = D_0013F490; @@ -2213,29 +2213,29 @@ void FUN_L08_002e3870(struct Moby *moby) { 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 { - fast_vec_normalize_c2(matrix, cam - 0x120, vars->u70.f); - subtract_vector_xyz(matrix + 4, matrix, vars->v40); - FUN_L00_0025f730_c(matrix + 4, D_L08_00161C8C_gp * frame_time_sq); - add_vector_xyz(vars->v40, vars->v40, matrix + 4); + fast_vec_normalize_c2(scratch, cam - 0x120, vars->u70.f); + subtract_vector_xyz(scratch + 4, scratch, vars->velocity); + 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; } - lim = vars->f74 * (float)scale_game_frames_c(20); - if (dist < lim) { + fade_range = vars->f74 * (float)scale_game_frames_c(20); + if (dist < fade_range) { if (fast_vec_dist(point, &moby->pos) > 0.52f) { if (D_L08_00161CC0 != 0) { - moby->alpha = (fast_vec_dist(point, &moby->pos) + lim) * 128.0f / (lim + lim); + moby->alpha = (fast_vec_dist(point, &moby->pos) + fade_range) * 128.0f / (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) + lim) / (lim + lim); + moby->scale = moby->pclass->scale * D_L08_00161CB4_gp * (fast_vec_dist(point, &moby->pos) + fade_range) / (fade_range + fade_range); } } else { int value; int spin; - float k; + float shrink; float size; - BoltSource_4BE8 *src; + BoltSource_4BE8 *source; switch (moby->oclass) { case 0x305: { @@ -2265,21 +2265,21 @@ void FUN_L08_002e3870(struct Moby *moby) { value = 1; break; } - k = 0.7f; - FUN_L00_00257d78(matrix, frame_time * k, frame_time); - fast_vec_scale_c(matrix + 4, matrix, 10.0f); - add_vector_xyz(matrix + 4, matrix + 4, &moby->pos); + shrink = 0.7f; + 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_c2(2); if (spin == 0) { spin--; } size = random_float_between_c5(0.4f, 0.5f); - FUN_L00_00272060(matrix + 4, scale_game_frames_c(0x19), size * 0.2f, size, 0x7F207F7F, 0, spin, matrix, 0.0f); + 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(matrix + 4, scale_game_frames_c(0x19), size * 0.14f, size * k, 0x7F7F7F7F, 1, spin, matrix, 0.0f); - src = moby->parent; - if (src && !(src->id & 0x80)) { - D_0014D590[current_level_index][src->id].bolts += value; + 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[current_level_index][source->id].bolts += value; } D_0015ED98 += value; level_bolts[current_level_index] += value; @@ -2300,12 +2300,12 @@ void FUN_L08_002e3870(struct Moby *moby) { case 4: { Vars_4BE8 *vars = (Vars_4BE8 *)moby->pvars; - add_vector_xyz(&moby->pos, &moby->pos, vars->v40); - vars->v40[2] -= frame_time_sq * 10.8f; + add_vector_xyz(&moby->pos, &moby->pos, vars->velocity); + 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 value; - BoltSource_4BE8 *src; + BoltSource_4BE8 *source; switch (moby->oclass) { case 0x3DD: @@ -2318,9 +2318,9 @@ void FUN_L08_002e3870(struct Moby *moby) { value = 1; break; } - src = moby->parent; - if (src && !(src->id & 0x80)) { - D_0014D590[current_level_index][src->id].bolts += value; + source = moby->parent; + if (source && !(source->id & 0x80)) { + D_0014D590[current_level_index][source->id].bolts += value; } D_0015ED98 += value; level_bolts[current_level_index] += value; @@ -2331,23 +2331,23 @@ void FUN_L08_002e3870(struct Moby *moby) { Vars_4BE8 *vars = (Vars_4BE8 *)moby->pvars; *(u128_4BE8_p *)vars->v10 = *(u128_4BE8_p *)((char *)&hero + 0x90); - vars->i68 = scale_game_frames_c(1); + 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(direction, &moby->pos, ((CollPos_4BE8 *)D_L08_00174660)->pos); - FUN_L00_001ff660(vars->v40, vars->v40, direction); + 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 n; - float inv; + int frames; + float per_frame; moby->flags &= ~0x100; vars = (Vars_4BE8 *)moby->pvars; - n = truncate_float_to_s32_c5(FUN_001f96b0(D_L08_00161CD0_gp + random_float_between_c5(-10.0f, 10.0f))); - inv = 1.0f / convert_integer_to_float(n); + 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->anchor, coll->pos); matrix_to_euler(&moby->rot_row0, &moby->rot); fast_vec_normalize_c2(direction, coll->n, 1.0f); @@ -2355,30 +2355,30 @@ void FUN_L08_002e3870(struct Moby *moby) { 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->v40, vars->v20, &moby->pos); - fast_vec_scale_c(vars->v40, vars->v40, inv); + subtract_vector_xyz(vars->velocity, vars->v20, &moby->pos); + fast_vec_scale_c(vars->velocity, vars->velocity, per_frame); if (coll->moby != 0) { - unsigned char *platform = FUN_L00_002603d0(coll->moby); + unsigned char *carrier = FUN_L00_002603d0(coll->moby); - if (platform != 0) { - add_vector_xyz(vars->v40, vars->v40, platform + 0x10); - fast_vec_scale_c(point, platform + 0x10, convert_integer_to_float(n)); + if (carrier != 0) { + add_vector_xyz(vars->velocity, vars->velocity, carrier + 0x10); + fast_vec_scale_c(point, carrier + 0x10, convert_integer_to_float(frames)); add_vector_xyz(vars->v20, vars->v20, point); add_vector_xyz(vars->anchor, vars->anchor, point); } } - vars->v40[2] += frame_time_sq * 10.8f * (float)(n >> 1); - vars->f50 = fast_subtract_rotations_c2(vars->v30[0], moby->rot.x) * inv; - vars->f54 = fast_subtract_rotations_c2(vars->v30[1], moby->rot.y) * inv; - vars->f58 = fast_subtract_rotations_c2(vars->v30[2], moby->rot.z) * inv; + 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->i68 = n; + vars->timer = frames; vars->u7C.i = D_L08_00174658_lui; 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->i68 = scale_game_frames_c(1); + vars->timer = scale_game_frames_c(1); moby->state = 2; } } @@ -2388,18 +2388,18 @@ void FUN_L08_002e3870(struct Moby *moby) { case 5: { Vars_4BE8 *vars = (Vars_4BE8 *)moby->pvars; - moby->rot.x = fast_add_rotations_c4(moby->rot.x, vars->f50); - moby->rot.y = fast_add_rotations_c4(moby->rot.y, vars->f54); - moby->rot.z = fast_add_rotations_c4(moby->rot.z, vars->f58); - add_vector_xyz(&moby->pos, &moby->pos, vars->v40); - vars->v40[2] -= frame_time_sq * 10.8f; - if (tick_countdown_32_alt(&vars->i68) != 0) { - int n; - float inv; + 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] -= 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.motion.pos.f[2]) < hero.reach_distance && vector_distance_xy_alt(&moby->pos, hero.motion.pos.f) < hero.reach_height) { - vars->i68 = scale_game_frames_c(1); + vars->timer = scale_game_frames_c(1); moby->state = 2; break; } @@ -2415,26 +2415,26 @@ void FUN_L08_002e3870(struct Moby *moby) { } break; } - n = truncate_float_to_s32_c5((float)scale_game_frames_c(20)); - inv = 1.0f / convert_integer_to_float(n); + frames = truncate_float_to_s32_c5((float)scale_game_frames_c(20)); + per_frame = 1.0f / convert_integer_to_float(frames); moby->command++; - vars->f50 = fast_subtract_rotations_c2(vars->v30[0], moby->rot.x) * inv; - vars->f54 = fast_subtract_rotations_c2(vars->v30[1], moby->rot.y) * inv; - vars->f58 = fast_subtract_rotations_c2(vars->v30[2], moby->rot.z) * inv; - subtract_vector_xyz(vars->v40, vars->v20, &moby->pos); - fast_vec_scale_c(vars->v40, vars->v40, inv); - vars->i68 = n; + 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); + fast_vec_scale_c(vars->velocity, vars->velocity, per_frame); + vars->timer = frames; if (vars->u7C.i != 0) { - unsigned char *platform = FUN_L00_002603d0(vars->u7C.i); + unsigned char *carrier = FUN_L00_002603d0(vars->u7C.i); - if (platform != 0) { - add_vector_xyz(vars->v40, vars->v40, platform + 0x10); - fast_vec_scale_c(direction, platform + 0x10, convert_integer_to_float(n)); + if (carrier != 0) { + add_vector_xyz(vars->velocity, vars->velocity, carrier + 0x10); + 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->v40[2] += frame_time_sq * 10.8f * (float)(n >> 1); + vars->velocity[2] += frame_time_sq * 10.8f * (float)(frames >> 1); } break; } diff --git a/src/overlays/l08/gameplay/entities/bomb.c b/src/overlays/l08/gameplay/entities/bomb.c index 0356d2f3c4..bf2ca6eda6 100644 --- a/src/overlays/l08/gameplay/entities/bomb.c +++ b/src/overlays/l08/gameplay/entities/bomb.c @@ -1461,7 +1461,7 @@ 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 r44; } Look_DBF68; +typedef struct { char pad0[0x40]; struct Moby *target; int result; } Look_DBF68; typedef struct { char pad0[0x20]; @@ -1558,7 +1558,7 @@ extern char camera_state_bytes[] __asm__("D_L08_00167480"); void FUN_L08_002dabf0(struct Moby *moby) { Data_DBF68 *vars = (Data_DBF68 *)moby->pvars; - Look_DBF68 look; + Look_DBF68 search; float point[4]; float velocity[4]; float aim[4]; @@ -1637,11 +1637,11 @@ void FUN_L08_002dabf0(struct Moby *moby) { effects_start_2D5FA8_c(moby, vars->anim); } moby->hit_slot = 0xFF; - look.r44 = FUN_L08_0026a3d0(moby, 16.0f, &look); - if (look.target == 0) { - look.target = *(struct Moby **)&D_001413D0; + search.result = FUN_L08_0026a3d0(moby, 16.0f, &search); + if (search.target == 0) { + search.target = *(struct Moby **)&D_001413D0; } - target = look.target; + target = search.target; switch (moby->state) { case 0: moby->flags |= 0x1000; diff --git a/src/overlays/l10/gameplay/entities/platform.c b/src/overlays/l10/gameplay/entities/platform.c index fe13660dc0..13f7fe7505 100644 --- a/src/overlays/l10/gameplay/entities/platform.c +++ b/src/overlays/l10/gameplay/entities/platform.c @@ -443,7 +443,7 @@ 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 FUN_L00_001ff290(void *, void *, void *); +extern void add_vectors(void *, void *, void *) __asm__("FUN_L00_001ff290"); extern void FUN_L00_00216f90(void *, void *, int, int); extern void FUN_L00_002e8568(int); extern void FUN_L00_002e8590(float, float); @@ -460,7 +460,6 @@ extern struct Moby * D_L10_0015FFD8; #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_001FF240_2BFBB8 ((void (*)(void *, void *, void *))FUN_L00_001ff290) #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 @@ -480,9 +479,9 @@ void FUN_L10_002be858(char *moby) int *data = *(int **)(moby + 0x78); float position[4]; float velocity[4]; - float offset[4]; + float offset_buffer[4]; float angle; - float *offset_ptr; + float *offset; int i; char *hero_bytes; int life; @@ -495,7 +494,7 @@ void FUN_L10_002be858(char *moby) hero_bytes = D_0013F350; if ((unsigned char)hero_bytes[0x20A4] == 1 && *data != -1 && func_001F9D48_2BFBB8(moby + 0x10, hero_bytes + 0x80) < 0.5f) { - offset_ptr = offset; + offset = offset_buffer; i = 9; do { float size, size_scaled; @@ -509,7 +508,7 @@ void FUN_L10_002be858(char *moby) velocity[1] = func_001F9FA8_2BFBB8(func_00214158_2BFBB8()) * func_002140F8_2BFBB8(0.0f, 0.5f); velocity[2] = 0.0f; velocity[2] += func_002140F8_2BFBB8(0.0f, 0.5f); - func_L00_001FF240_2BFBB8(offset_ptr, velocity, D_0013F350 + 0x80); + 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)); @@ -554,7 +553,7 @@ void FUN_L10_002be858(char *moby) velocity[1] = func_001F9FA8_2BFBB8(func_00214158_2BFBB8()) * func_002140F8_2BFBB8(0.0f, 0.5f); velocity[2] = 0.0f; velocity[2] += func_002140F8_2BFBB8(0.0f, 0.5f); - func_L00_001FF240_2BFBB8(offset_ptr, velocity, (*(char * *)&D_L10_0015FFD8) + (*data << 8) + 0x10); + 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)); diff --git a/src/overlays/l12/gameplay/entities/003054b0.c b/src/overlays/l12/gameplay/entities/003054b0.c index 0d718a1a35..dc43ec3643 100644 --- a/src/overlays/l12/gameplay/entities/003054b0.c +++ b/src/overlays/l12/gameplay/entities/003054b0.c @@ -485,12 +485,12 @@ void FUN_L12_003064e8(char *moby) { extern int D_L12_0015F5CC; extern unsigned char * D_L12_0015FFD8; -void FUN_L12_00306828(char *moby) { +void FUN_L12_00306828(struct Moby *moby) { int i; int alpha = 0x80000000; - char *data = *(char **)(moby + 0x78); + char *data = (char *)moby->pvars; for (i = 0; i < 18; i++) { - char *other; + struct Moby *other; int period; float sine; float color; @@ -503,9 +503,9 @@ void FUN_L12_00306828(char *moby) { if (i == 17) { other = moby; } else { - other = (char *)(*(struct Moby * *)&D_L12_0015FFD8_p) + ((unsigned int)*(int *)(data + i * 0x30 + 0x20) << 8); + other = (struct Moby *)((char *)(*(struct Moby * *)&D_L12_0015FFD8_p) + ((unsigned int)*(int *)(data + i * 0x30 + 0x20) << 8)); } - if (*(short *)(other + 0xA6) == 0x4FE) continue; + if (other->oclass == 0x4FE) continue; { period = scale_game_frames(0xAA); divisor = convert_integer_to_float(period); @@ -518,8 +518,8 @@ void FUN_L12_00306828(char *moby) { packed_color = ((blue + 0x46) << 16) | alpha | ((green + 0xB4 > 0xFF ? 0xFF : green + 0xB4) << 8) | (red + 0xB4 > 0xFF ? 0xFF : red + 0xB4); - *(unsigned short *)(other + 0x34) |= 0x10; - *(int *)(other + 0x90) = packed_color; + other->flags |= 0x10; + other->glow_color = packed_color; } } /* Fakematch: keeping alpha live past the loop gives retail's schedule of the loop body. */ @@ -590,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_u(struct Moby *moby) __asm__("FUN_L12_00306828"); 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"))); @@ -804,7 +803,7 @@ void FUN_L12_003069d0(char *moby) { FUN_L12_003064e8_c(moby); break; } - FUN_L12_00306828_u(moby); + FUN_L12_00306828(moby); if ((unsigned char)moby[0x20] >= 1 && (unsigned char)moby[0x20] <= 3) { if (*(int *)(d + 0x604) == -1) *(int *)(d + 0x604) = allocate_voice_for_target_entry(0, 4, moby); } else { diff --git a/src/overlays/l13/gameplay/entities/rocket.c b/src/overlays/l13/gameplay/entities/rocket.c index 7caaf5774b..15b6f72412 100644 --- a/src/overlays/l13/gameplay/entities/rocket.c +++ b/src/overlays/l13/gameplay/entities/rocket.c @@ -747,8 +747,8 @@ void FUN_L13_00307b10(struct Moby *moby) { typedef struct { u8 pad0[0x18]; - u8 unk18; - u8 unk19; + u8 active; + u8 valid; s16 oclass; u8 pad1C[0x14]; } Shot_309330; @@ -838,8 +838,8 @@ void FUN_L13_00307e98(struct Moby *moby) { Vec4 origin; Vec4 direction; Shot_309330 shot; - s32 near; - s32 close; + s32 blocked; + s32 path_blocked; s32 hit; FUN_L13_00308d10_c(moby); @@ -960,8 +960,8 @@ void FUN_L13_00307e98(struct Moby *moby) { direction.f[2] = 1.0f; direction.f[3] = 5627.925f; func_L00_0025A8C0_30A9B0(&shot, moby, 1, &direction, 1.0f); - shot.unk18 = 0; - shot.unk19 = 1; + shot.active = 0; + shot.valid = 1; shot.oclass = moby->oclass; FUN_L00_00259d08(&point, &origin, &vars->unk1E0, &origin, moby, &shot, 5); } @@ -998,10 +998,10 @@ void FUN_L13_00307e98(struct Moby *moby) { vars->unk1A8 = 0.0f; } FUN_L00_00261d78(vars->path, &moby->pos, &moby->pos, 0.75f); - close = 0; + path_blocked = 0; if (FUN_L00_00261b48(vars->path, &moby->pos, &target->pos, &direction) != 0 && fast_vec_dist(&moby->pos, &direction) < 0.8f) { - close = 1; + path_blocked = 1; } { f32 dist = vector_distance_xy_alt(&moby->pos, &target->pos); @@ -1010,7 +1010,7 @@ void FUN_L13_00307e98(struct Moby *moby) { if (moby->prev_seq != 3) { blend_moby_animation(moby, 3, 0, scale_game_frames(10)); } - } else if (close != 0) { + } else if (path_blocked != 0) { moby->state = 2; if (moby->prev_seq != 3) { blend_moby_animation(moby, 3, 0, scale_game_frames(10)); @@ -1024,7 +1024,7 @@ void FUN_L13_00307e98(struct Moby *moby) { } break; case 11: - near = 0; + blocked = 0; 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); @@ -1035,11 +1035,11 @@ void FUN_L13_00307e98(struct Moby *moby) { 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) { - near = 1; + blocked = 1; } if (vars->unk184 == 0) { moby->state = 13; - } else if (near != 0) { + } else if (blocked != 0) { moby->state = 12; if (moby->prev_seq != 6) { blend_moby_animation(moby, 6, 0, scale_game_frames(10)); @@ -1064,8 +1064,8 @@ void FUN_L13_00307e98(struct Moby *moby) { direction.f[2] = 1.0f; direction.f[3] = 5627.925f; func_L00_0025A8C0_30A9B0(&shot, moby, 1, &direction, 1.0f); - shot.unk18 = 0; - shot.unk19 = 1; + shot.active = 0; + shot.valid = 1; shot.oclass = moby->oclass; FUN_L00_00259d08(&point, &origin, &vars->unk1E0, &origin, moby, &shot, 5); } diff --git a/src/overlays/shared/gameplay/entities/bomb.c b/src/overlays/shared/gameplay/entities/bomb.c index 12c1b6543d..1d145c1370 100644 --- a/src/overlays/shared/gameplay/entities/bomb.c +++ b/src/overlays/shared/gameplay/entities/bomb.c @@ -1027,11 +1027,11 @@ 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 unk18, float unk1C, float yaw, float pitch) { - float start[4]; - float from[4]; +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 jitter[4]; + float scaled[4]; float spark[4]; unsigned char *moby; char *vars; @@ -1043,13 +1043,13 @@ char *FUN_L00_002caf70(char *owner, char *spawn_pos, char *target, float unk18, int i; int sparks; float length; - float curve; + float blend; float index; float fraction; - float *point; + float *start; - point = start; - *(w128 *)start = *(w128 *)spawn_pos; + start = start_position; + *(w128 *)start_position = *(w128 *)spawn_pos; moby = func_0020D348_m(0x131); if (moby != 0) { vars = *(char **)(moby + 0x78); @@ -1061,7 +1061,7 @@ char *FUN_L00_002caf70(char *owner, char *spawn_pos, char *target, float unk18, *(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, point); + qcopy(moby + 0x10, start); if (target != 0) { int bounds; qcopy(vars, target + 0x10); @@ -1074,8 +1074,8 @@ char *FUN_L00_002caf70(char *owner, char *spawn_pos, char *target, float unk18, } else { clear_u64_value_c(vars); } - *(float *)(vars + 0x18) = unk18; - *(float *)(vars + 0x1C) = unk1C; + *(float *)(vars + 0x18) = vx; + *(float *)(vars + 0x1C) = vy; *(int *)(vars + 0x10) = 0; *(int *)(vars + 0x14) = 0; timer = scale_game_frames_c2(0x23); @@ -1084,13 +1084,13 @@ char *FUN_L00_002caf70(char *owner, char *spawn_pos, char *target, float unk18, *(int *)(vars + 0x28) = 0; *(short *)(vars + 0x24) = timer; *(short *)(vars + 0x26) = timer; - *(w128 *)from = *(w128 *)(owner + 0x10); - from[2] = point[2]; - result = FUN_001efa68(from, point, 0, (int)owner, 0); + *(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); - point = jitter; + start = scaled; sparks = 4; do { *(w128 *)spark = 0; @@ -1098,11 +1098,11 @@ char *FUN_L00_002caf70(char *owner, char *spawn_pos, char *target, float unk18, sparks--; spark[1] = random_float_between_c2(-1.0f, 1.0f); spark[2] = random_float_between_c2(-1.0f, 1.0f); - *(w128 *)jitter = *(w128 *)spark; + *(w128 *)scaled = *(w128 *)spark; FUN_L00_001ff660(spark, direction, D_L00_00173E80); length = fast_vec_length(spark); - fast_vec_normalize(point, point, length * 0.5f); - add_vector_xyz(spark, spark, point); + 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); @@ -1134,9 +1134,9 @@ char *FUN_L00_002caf70(char *owner, char *spawn_pos, char *target, float unk18, *(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); - curve = FUN_L00_00257e20(-1.5f, 0.0f, 1.0f, 0.0f, fraction); - *(float *)(trail + 0xC) = *(float *)(trail + 0xC) + (D_L00_00161878 - *(float *)(trail + 0xC)) * curve; - result = truncate_float_to_s32_c(curve * -64.0f + 128.0f); + 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 { @@ -1147,7 +1147,7 @@ char *FUN_L00_002caf70(char *owner, char *spawn_pos, char *target, float unk18, } return moby; } -/* 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 { diff --git a/src/overlays/shared/gameplay/entities/plasmabot.c b/src/overlays/shared/gameplay/entities/plasmabot.c index b1ced6553e..7677c43dbb 100644 --- a/src/overlays/shared/gameplay/entities/plasmabot.c +++ b/src/overlays/shared/gameplay/entities/plasmabot.c @@ -218,18 +218,18 @@ unsigned char *FUN_L14_002ffaf8(unsigned char *owner, char *pos) { /* 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 a; - float b; - float c; - float d; + float x; + float y; + float scale; + float distance; char *moby; int flags; - unsigned char b98; - unsigned char b99; - unsigned short cls; - float e; - int f; -} Ray; + unsigned char mode; + unsigned char enabled; + unsigned short oclass; + float strength; + int count; +} LineInfo; extern char D_001413F4[]; extern char D_L14_001FBB60[]; @@ -246,7 +246,7 @@ extern float FUN_L00_0025b8c0(float *p, float *v, float t, float u1, float u2, f 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 FUN_001efa68(void *, void *, int, void *, void *); +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 *); @@ -303,9 +303,9 @@ void FUN_L14_002b17d8(char *moby) { char *owner; int state; float mat[4][4]; - float offset[4]; - float hit[4]; - Ray ray; + float direction[4]; + float end[4]; + LineInfo info; int status; data = *(char **)(moby + 0x78); @@ -574,29 +574,29 @@ void FUN_L14_002b17d8(char *moby) { FUN_L14_002b35d8_c(moby, flag, angle); FUN_L14_002b37b0_c(moby, ang); build_moby_bone_transform_c(moby, 0, mat); - qcopy(offset, mat[1]); + qcopy(direction, mat[1]); if (flag == 0) { - offset[2] = 0.0f; + direction[2] = 0.0f; } - fast_vec_normalize(offset, offset, D_L14_001614E4_gp); - add_vector_xyz_c3(hit, mat[3], offset); - fast_vec_normalize(offset, offset, D_L14_001614F4_gp); - add_vector_xyz_c3(mat[3], mat[3], offset); - ray.moby = moby; - ray.flags = 0x10001; - ray.f = 1; - ray.e = 1.0f; - ray.a = fast_cos(*(float *)(moby + 0x48)); - ray.b = fast_sin(*(float *)(moby + 0x48)); - ray.c = 1.0f; - ray.d = 5627.9248f; - ray.b99 = 1; - ray.cls = *(unsigned short *)(moby + 0xA6); - ray.b98 = 0; - if (FUN_001efa68(mat[3], hit, 0, moby, &ray) != 0) { - qcopy(hit, D_L14_00174560); + 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 = fast_cos(*(float *)(moby + 0x48)); + info.y = fast_sin(*(float *)(moby + 0x48)); + info.scale = 1.0f; + info.distance = 5627.9248f; + info.enabled = 1; + info.oclass = *(unsigned short *)(moby + 0xA6); + info.mode = 0; + if (coll_line_fix(mat[3], end, 0, moby, &info) != 0) { + qcopy(end, D_L14_00174560); } - FUN_L00_002e2190(moby, mat, hit); + 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; diff --git a/src/overlays/shared/rendering/00245c28.c b/src/overlays/shared/rendering/00245c28.c index 27567295ca..7aa10b7187 100644 --- a/src/overlays/shared/rendering/00245c28.c +++ b/src/overlays/shared/rendering/00245c28.c @@ -352,10 +352,10 @@ typedef struct { /* 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 D_L00_0015FE00[]; +extern char render_archive_source_file[] __asm__("D_L00_0015FE00"); extern char D_L00_001E8B00[]; -extern float D_L00_00182810[]; -extern float D_L00_00182A70[]; +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"); @@ -378,7 +378,7 @@ void FUN_L00_002464a8(void) { int i; RenderArchiveState *state; int level; - int *entry; + struct DiscFile *file; int heap_tag, first_size, second_size, scratch; int *archive, *archive_base; unsigned char *level_data; @@ -398,31 +398,31 @@ void FUN_L00_002464a8(void) { D_L00_001841F0.archive_index = level > 18 ? 0 : level; { int i; for (i = 0; i < 19; i++) { - float world_x0 = D_L00_00182810[i * 8], world_y0 = D_L00_00182810[i * 8 + 1], world_x1 = D_L00_00182810[i * 8 + 2], world_y1 = D_L00_00182810[i * 8 + 3]; - float map_x0 = D_L00_00182810[i * 8 + 4], map_y0 = D_L00_00182810[i * 8 + 5], map_x1 = D_L00_00182810[i * 8 + 6], map_y1 = D_L00_00182810[i * 8 + 7]; + 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); - D_L00_00182A70[i * 4 + 1] = scale_x; - D_L00_00182A70[i * 4 + 3] = scale_y; - D_L00_00182A70[i * 4] = map_x0 - scale_x * world_x0; - D_L00_00182A70[i * 4 + 2] = map_y0 - scale_y * world_y0; + 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; - entry = (int *)&D_00138438 + D_L00_001841F0.archive_index * 2; + file = (struct DiscFile *)D_00138438 + D_L00_001841F0.archive_index; } else { D_L00_001841F0.loaded = 0; - entry = (int *)&D_001383A0 + D_L00_001841F0.archive_index * 2; + file = (struct DiscFile *)D_001383A0 + D_L00_001841F0.archive_index; } - if (entry[1] != 0) { + if (file->size != 0) { state = &D_L00_001841F0; state->unk28 = 1; - heap_tag = (int)D_L00_0015FE00; + heap_tag = (int)render_archive_source_file; archive_base = ((int **)&D_L00_00173E08)[0]; archive = (int *)((int)archive_base + 0x9A800); - scratch = entry[1] << 7; - load(archive, entry[0], entry[1]); + 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); @@ -441,7 +441,7 @@ void FUN_L00_002464a8(void) { 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, D_L00_0015FE00, 0x2FC); + 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) { diff --git a/src/overlays/shared/ui/help/001ff938.c b/src/overlays/shared/ui/help/001ff938.c index dc37ad4f27..c7534c438c 100644 --- a/src/overlays/shared/ui/help/001ff938.c +++ b/src/overlays/shared/ui/help/001ff938.c @@ -30,12 +30,12 @@ extern void FUN_L00_00207c48(void); extern void FUN_L00_00207d00(void); extern void FUN_L00_00208a10(void); extern void FUN_L00_00208b60(void); -extern void FUN_L00_00211670(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 FUN_L00_0024f7c8(void *, int, void *); +extern void moby_point_position(void *, int, void *) __asm__("FUN_L00_0024f7c8"); extern void FUN_L00_00257024(void *); extern void FUN_L15_002044c8(void); extern void FUN_L15_0021d040(void); @@ -49,7 +49,7 @@ void FUN_L15_001ff938(void) { float pulse; FUN_L00_00232670(); - FUN_L00_00211670(); + hero_update(); FUN_L15_002044c8(); FUN_L15_0021d040(); hero0 = ((char *)&D_0013F350); @@ -72,7 +72,7 @@ void FUN_L15_001ff938(void) { { unsigned char *hero_moby = *(unsigned char **)(hero0 + 0x2080); if (((*(unsigned short *)(hero_moby + 0x34) ^ 1) & 1) != 0) { - FUN_L00_0024f7c8(hero_moby, 6, copy); + moby_point_position(hero_moby, 6, copy); qcopy(hero0 + 0x1D80, copy); FUN_L00_00207d00(); } @@ -109,7 +109,7 @@ void FUN_L15_001ff938(void) { for (i = 0; i < 3; i++) { hero4 = ((char *)&D_0013F350); - FUN_L00_0024f7c8(*(void **)(hero4 + 0x2080), i, hero4 + 0x1D50 + i * 16); + moby_point_position(*(void **)(hero4 + 0x2080), i, hero4 + 0x1D50 + i * 16); } alpha = 0x30; hero4 = ((char *)&D_0013F350); @@ -125,7 +125,7 @@ void FUN_L15_001ff938(void) { FUN_L00_00207d00(); *(short *)(hero4 + 0x22E0) = 0; if (hero4[0x20A4] == 3) { - int pending = *(int *)(hero4 + 0x20B8); + int pending = ((struct Hero *)hero4)->pending_item[0]; if (pending != 0 && pending != 0x1F) { if (*(short *)(hero4 + 0x22DE) == 0) { FUN_L00_00216de8(0x19, 0); @@ -134,7 +134,7 @@ void FUN_L15_001ff938(void) { } } else { hero5 = ((char *)&D_0013F350); - *(int *)(hero5 + 0x20B8) = 0; + ((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); diff --git a/src/overlays/shared/ui/text/002377b8.c b/src/overlays/shared/ui/text/002377b8.c index 67b9d362b9..243f05271c 100644 --- a/src/overlays/shared/ui/text/002377b8.c +++ b/src/overlays/shared/ui/text/002377b8.c @@ -709,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"); @@ -788,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);