diff --git a/README.md b/README.md
index 773b30c6df..84655aea5e 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,7 @@
A work-in-progress, byte-matching decompilation of Ratchet & Clank (2002) for PlayStation 2.
- Reconstructing the original game code in readable C, with a native Rust port as the long-term goal.
+ Reconstructing the original game code in readable C.
> [!NOTE]
diff --git a/config/overlays/us/functions.tsv b/config/overlays/us/functions.tsv
index 9d5490a128..855bb3defc 100644
--- a/config/overlays/us/functions.tsv
+++ b/config/overlays/us/functions.tsv
@@ -1431,7 +1431,7 @@ FUN_L00_0029b4d8 shared 420 f6bd7d4eb7e066c6 19 00:0029B4D8,01:002AF248,02:0029A
FUN_L00_0029b680 shared 1012 42ecfa94c474cf92 19 00:0029B680,01:002AF3F0,02:0029AE88,03:00287FC8,04:0028C578,05:002C3DD0,06:002A8778,07:002C2328,08:002A3AA0,09:002B7FD0,10:0028C180,11:002BE578,12:002B1F08,13:002A5D10,14:002A1A28,15:002895C8,16:002945F0,17:002938E0,18:0029B228
FUN_L00_0029ba78 shared 3024 ea879e90198c5508 19 00:0029BA78,01:002AF7E8,02:0029B280,03:002883C0,04:0028C970,05:002C41C8,06:002A8B70,07:002C2720,08:002A3E98,09:002B83C8,10:0028C578,11:002BE970,12:002B2300,13:002A6108,14:002A1E20,15:002899C0,16:002949E8,17:00293CD8,18:0029B620
FUN_L00_0029c648 shared 5244 6972649e56ecfe91 19 00:0029C648,01:002B03B8,02:0029BE50,03:00288F90,04:0028D540,05:002C4D98,06:002A9740,07:002C32F0,08:002A4A68,09:002B8F98,10:0028D148,11:002BF540,12:002B2ED0,13:002A6CD8,14:002A29F0,15:0028A590,16:002955B8,17:002948A8,18:0029C1F0
-FUN_00238310 exe 528 e7b9592024c2ef78 19 00:0029DAC8,01:002B1838,02:0029D2D0,03:0028A410,04:0028E9C0,05:002C6218,06:002AABC0,07:002C4770,08:002A5EE8,09:002BA418,10:0028E5C8,11:002C09C0,12:002B4350,13:002A8158,14:002A3E70,15:0028BA10,16:00296A38,17:00295D28,18:0029D670 assembly/textbin/gameplay/vendor/render_capture_scrolling_text
+FUN_00238310 exe 528 e7b9592024c2ef78 19 00:0029DAC8,01:002B1838,02:0029D2D0,03:0028A410,04:0028E9C0,05:002C6218,06:002AABC0,07:002C4770,08:002A5EE8,09:002BA418,10:0028E5C8,11:002C09C0,12:002B4350,13:002A8158,14:002A3E70,15:0028BA10,16:00296A38,17:00295D28,18:0029D670 gameplay/vendor/render_capture_scrolling_text
FUN_00238520 exe 268 09201b9e429a440f 19 00:0029DCD8,01:002B1A48,02:0029D4E0,03:0028A620,04:0028EBD0,05:002C6428,06:002AADD0,07:002C4980,08:002A60F8,09:002BA628,10:0028E7D8,11:002C0BD0,12:002B4560,13:002A8368,14:002A4080,15:0028BC20,16:00296C48,17:00295F38,18:0029D880 ui/text/update_scrolling_status_message
FUN_00238630 exe 88 9f7732daf2d50bb8 19 00:0029DDE8,01:002B1B58,02:0029D5F0,03:0028A730,04:0028ECE0,05:002C6538,06:002AAEE0,07:002C4A90,08:002A6208,09:002BA738,10:0028E8E8,11:002C0CE0,12:002B4670,13:002A8478,14:002A4190,15:0028BD30,16:00296D58,17:00296048,18:0029D990 gameplay/vendor/render_capture_effect_pass
FUN_00238688 exe 96 eece735c70eaf8fc 19 00:0029DE40,01:002B1BB0,02:0029D648,03:0028A788,04:0028ED38,05:002C6590,06:002AAF38,07:002C4AE8,08:002A6260,09:002BA790,10:0028E940,11:002C0D38,12:002B46C8,13:002A84D0,14:002A41E8,15:0028BD88,16:00296DB0,17:002960A0,18:0029D9E8 ui/menus/format_scaled_display_value
@@ -1860,7 +1860,7 @@ FUN_0023be20 exe 244 fa7c0cdffd0cf27f 19 00:002EF790,01:0031BCC8,02:002FE3F0,03:
FUN_0023bf18 exe 84 8d9715497dea8151 19 00:002EF888,01:0031BDC0,02:002FE4E8,03:002EF5F8,04:002F3620,05:0032D910,06:00318550,07:0032B538,08:00318EC8,09:00317948,10:002F8B18,11:0032AB00,12:003188C8,13:0031A260,14:00318DB0,15:002FAFA0,16:002F7A38,17:00302A80,18:00308C78 video/decoder/vi_buf_end_put
FUN_0023bf70 exe 508 efc91c0b417bd644 19 00:002EF8E0,01:0031BE18,02:002FE540,03:002EF650,04:002F3678,05:0032D968,06:003185A8,07:0032B590,08:00318F20,09:003179A0,10:002F8B70,11:0032AB58,12:00318920,13:0031A2B8,14:00318E08,15:002FAFF8,16:002F7A90,17:00302AD8,18:00308CD0 video/decoder/vi_buf_add_dma
FUN_0023c170 exe 272 a93436f5763282f2 19 00:002EFAE0,01:0031C018,02:002FE740,03:002EF850,04:002F3878,05:0032DB68,06:003187A8,07:0032B790,08:00319120,09:00317BA0,10:002F8D70,11:0032AD58,12:00318B20,13:0031A4B8,14:00319008,15:002FB1F8,16:002F7C90,17:00302CD8,18:00308ED0 video/decoder/vi_buf_stop_dma
-FUN_0023c280 exe 824 fbf5afdb23892730 19 00:002EFBF0,01:0031C128,02:002FE850,03:002EF960,04:002F3988,05:0032DC78,06:003188B8,07:0032B8A0,08:00319230,09:00317CB0,10:002F8E80,11:0032AE68,12:00318C30,13:0031A5C8,14:00319118,15:002FB308,16:002F7DA0,17:00302DE8,18:00308FE0 assembly/textbin/video/decoder/vi_buf_restart_dma
+FUN_0023c280 exe 824 fbf5afdb23892730 19 00:002EFBF0,01:0031C128,02:002FE850,03:002EF960,04:002F3988,05:0032DC78,06:003188B8,07:0032B8A0,08:00319230,09:00317CB0,10:002F8E80,11:0032AE68,12:00318C30,13:0031A5C8,14:00319118,15:002FB308,16:002F7DA0,17:00302DE8,18:00308FE0 video/decoder/vi_buf_restart_dma
FUN_0023c5b8 exe 88 8f29da4aa55c648f 19 00:002EFF28,01:0031C460,02:002FEB88,03:002EFC98,04:002F3CC0,05:0032DFB0,06:00318BF0,07:0032BBD8,08:00319568,09:00317FE8,10:002F91B8,11:0032B1A0,12:00318F68,13:0031A900,14:00319450,15:002FB640,16:002F80D8,17:00303120,18:00309318 video/decoder/vi_buf_delete
FUN_0023c610 exe 76 e57a0e9579deb0b4 19 00:002EFF80,01:0031C4B8,02:002FEBE0,03:002EFCF0,04:002F3D18,05:0032E008,06:00318C48,07:0032BC30,08:003195C0,09:00318040,10:002F9210,11:0032B1F8,12:00318FC0,13:0031A958,14:003194A8,15:002FB698,16:002F8130,17:00303178,18:00309370 video/decoder/vi_buf_count
FUN_0023c660 exe 84 cf13363f867141a2 19 00:002EFFD0,01:0031C508,02:002FEC30,03:002EFD40,04:002F3D68,05:0032E058,06:00318C98,07:0032BC80,08:00319610,09:00318090,10:002F9260,11:0032B248,12:00319010,13:0031A9A8,14:003194F8,15:002FB6E8,16:002F8180,17:003031C8,18:003093C0 video/decoder/vi_buf_flush
diff --git a/config/us/recovered_names.json b/config/us/recovered_names.json
index b215c3e819..1eed1cf75b 100644
--- a/config/us/recovered_names.json
+++ b/config/us/recovered_names.json
@@ -16525,8 +16525,8 @@
"logical_group_confidence": "unresolved"
},
{
- "unit": "textbin/gameplay/vendor/render_capture_scrolling_text",
- "source_path": "src/assembly/textbin/gameplay/vendor/render_capture_scrolling_text.c",
+ "unit": "gameplay/vendor/render_capture_scrolling_text",
+ "source_path": "src/gameplay/vendor/render_capture_scrolling_text.c",
"address": "0x00238310",
"current_name": "FUN_00238310",
"proposed_name": "render_capture_scrolling_text",
@@ -17564,8 +17564,8 @@
"logical_group_confidence": "medium"
},
{
- "unit": "textbin/video/decoder/vi_buf_restart_dma",
- "source_path": "src/assembly/textbin/video/decoder/vi_buf_restart_dma.c",
+ "unit": "video/decoder/vi_buf_restart_dma",
+ "source_path": "src/video/decoder/vi_buf_restart_dma.c",
"address": "0x0023c280",
"current_name": "FUN_0023c280",
"proposed_name": "vi_buf_restart_dma",
diff --git a/config/us/rnc1.us.yaml b/config/us/rnc1.us.yaml
index afa373bbea..88058f13f3 100644
--- a/config/us/rnc1.us.yaml
+++ b/config/us/rnc1.us.yaml
@@ -549,7 +549,7 @@ segments:
- [0x25624, textbin, text_gap_00124510_post_sdk_worker]
- [0x25628, c, sdk/library/sceDbcSetWorkAddr]
- [0x25694, textbin, text_gap_001246a8_post_sdk_worker]
- - [0x25698, c, assembly/sdk/library/sceDbcCreateSocket]
+ - [0x25698, c, sdk/library/sceDbcCreateSocket]
- [0x25760, c, sdk/library/sceDbcGetDepNumber]
- [0x258a8, textbin, text_gap_001247e0_post_sdk_worker]
- [0x258b0, c, sdk/library/scedbcreceivedata]
@@ -2052,7 +2052,7 @@ segments:
- [0x138e4c, textbin, text_gap_00237ecc_after_fun_00237e90]
- [0x138e50, c, gameplay/vendor/fun_00237ed0]
- [0x139274, textbin, text_gap_002382f4_before_fun_00238310]
- - [0x139290, c, assembly/textbin/gameplay/vendor/render_capture_scrolling_text]
+ - [0x139290, c, gameplay/vendor/render_capture_scrolling_text]
- [0x1394a0, c, ui/text/update_scrolling_status_message]
- [0x1395ac, textbin, text_gap_0023862c_before_fun_00238630]
- [0x1395b0, c, gameplay/vendor/render_capture_effect_pass]
@@ -2151,7 +2151,7 @@ segments:
- [0x13cef0, c, video/decoder/vi_buf_add_dma]
- [0x13d0ec, textbin, text_gap_0023c16c_before_fun_0023c170]
- [0x13d0f0, c, video/decoder/vi_buf_stop_dma]
- - [0x13d200, c, assembly/textbin/video/decoder/vi_buf_restart_dma]
+ - [0x13d200, c, video/decoder/vi_buf_restart_dma]
- [0x13d538, c, video/decoder/vi_buf_delete]
- [0x13d590, c, video/decoder/vi_buf_count]
- [0x13d5dc, textbin, text_gap_0023c65c_before_fun_0023c660]
diff --git a/configure.py b/configure.py
index b7e99ce4c3..7e5c1ca6a7 100755
--- a/configure.py
+++ b/configure.py
@@ -257,6 +257,7 @@
"l11/gameplay/hero/0023c7a0.c",
"l11/gameplay/hero/00253a18.c",
"l11/gameplay/hero/hero_set_state.c",
+ "l12/gameplay/entities/003054b0.c",
"l12/gameplay/entities/hoven_turret.c",
"l12/gameplay/entities/platform.c",
"l12/gameplay/entities/water_reservoir.c",
@@ -301,7 +302,9 @@
"shared/audio/voices/00276368.c",
"shared/gameplay/camera/001fc008.c",
"shared/gameplay/camera/follow_camera_setup.c",
+ "shared/gameplay/camera/follow_camera_update.c",
"shared/gameplay/camera/init_camera_system.c",
+ "shared/gameplay/entities/00264e40.c",
"shared/gameplay/entities/00295100.c",
"shared/gameplay/entities/0029f990.c",
"shared/gameplay/entities/002aee30.c",
@@ -488,7 +491,7 @@
"assembly/textbin/rendering/effects/build_resident_indexed_texture_warp_meshes": (0x1D9A10, 0xDA990, 32),
"assembly/textbin/ui/map/draw_level_selection_map": (0x1DDE28, 0xDEDA8, 320),
"assembly/textbin/rendering/register_object_render_class": (0x1E1900, 0xE2880, 256),
- "assembly/textbin/gameplay/vendor/render_capture_scrolling_text": (0x1E6018, 0xE6F98, 512),
+ "gameplay/vendor/render_capture_scrolling_text": (0x1E6018, 0xE6F98, 512),
"assembly/textbin/gameplay/vendor/render_vendor_capture_pass_sequence": (0x1E6218, 0xE7198, 96),
"textbin/render_vendor_capture_texture_overlays_pass": (0x1E6620, 0xE75A0, 64),
"textbin/rebuild_configured_text_label_list": (0x1E8728, 0xE96A8, 60),
@@ -2109,13 +2112,14 @@ def build_overlays() -> Path:
ninja_path = OVERLAYS_BUILD / "build.ninja"
ninja = ninja_syntax.Writer(open(str(ninja_path), "w"), width=9999)
# obj/ only checks that the file compiles as written; its code is never
- # compared. -G0 keeps GNU as from relaxing bare symbol accesses, which
- # it asserts on (tc-mips.c:11454) when one sits in a noreorder delay slot
- # and an unsized symbol is loaded later in the same frag.
+ # compared. GNU as can assert (tc-mips.c:11454) on a bare symbol access
+ # in a noreorder delay slot, with -G0 on some files and without it on
+ # others, so a file passes when it assembles either way.
+ overlay_cc = f"{game_root}/ee-gcc -c {includes} {LANG_DEFINE} {COMPILER_FLAGS} $in -o $out"
ninja.rule(
"overlay-cc",
description="overlay-cc $in",
- command=f"{game_root}/ee-gcc -c {includes} -Wa,-G0 {LANG_DEFINE} {COMPILER_FLAGS} $in -o $out",
+ command=f"{overlay_cc.replace(' -c ', ' -c -Wa,-G0 ', 1)} 2>/dev/null || {overlay_cc}",
)
ninja.rule(
"c-only",
diff --git a/game/README.md b/game/README.md
deleted file mode 100644
index ca6fb6611f..0000000000
--- a/game/README.md
+++ /dev/null
@@ -1,7 +0,0 @@
-# game
-
-```
-XbuPLxyGsbjUFfkPN00DWZEUAZjNCORNKpkNN0kNQLNUF00DVDjTIpjUPuuPpxyGZbON
-```
-
-
diff --git a/include/rnc/ui/vendor/vendor_capture.h b/include/rnc/ui/vendor/vendor_capture.h
index cb22c91df6..98720f5142 100644
--- a/include/rnc/ui/vendor/vendor_capture.h
+++ b/include/rnc/ui/vendor/vendor_capture.h
@@ -21,7 +21,7 @@ struct CaptureBoundsAdjustment {
};
extern struct VendorItemPricing vendor_item_prices[43] __asm__("D_001DFFB0");
-extern volatile s32 capture_glyph_coordinates[64] __asm__("D_001E6018");
+extern s32 capture_glyph_coordinates[64] __asm__("D_001E6018");
extern s32 capture_glyph_advances[64] __asm__("D_001E6118");
extern struct CaptureBoundsAdjustment capture_bounds_adjustments[6] __asm__("D_001E6218");
diff --git a/scripts/test_public_tools.py b/scripts/test_public_tools.py
index f4bb2d1c5e..c66379afcd 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 = 610
+ KNOWN_CONFLICTS = 602
def test_no_new_conflicting_declarations(self):
decls = load_module("rnc_data_decls", ROOT / "scripts" / "data-decls.py")
diff --git a/src/assembly/sdk/library/sceDbcCreateSocket.c b/src/assembly/sdk/library/sceDbcCreateSocket.c
deleted file mode 100644
index f76037035b..0000000000
--- a/src/assembly/sdk/library/sceDbcCreateSocket.c
+++ /dev/null
@@ -1,61 +0,0 @@
-#include "asm.h"
-
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/expected/asm/assembly/sdk/library/sceDbcCreateSocket/sceDbcCreateSocket.s",
- sceDbcCreateSocket);
-#else
-#include "types.h"
-struct DbcRpcBuffer {
- s32 unk0;
- s32 unk4;
- s32 unk8;
- s32 unkC;
- s32 unk10;
- u8 pad_14[0x10];
- s32 unk24;
- s32 unk28;
- s32 unk2C;
-};
-struct DbcSocketParams {
- s32 unk0;
- s32 unk4;
- s32 unk8;
- s32 unkC;
- s32 unk10;
- u8 name[0x10];
-};
-extern u8 D_00153578[];
-extern u8 D_0015B008[];
-extern struct DbcRpcBuffer D_0015B080;
-extern s32 sceSifCallRpc();
-extern s32 debug_print_stub() __asm__("func_00124A20");
-s32 sceDbcCreateSocket(struct DbcSocketParams *arg0, s32 arg1, s32 arg2) {
- u8 *source_name = arg0->name;
- struct DbcRpcBuffer *state = &D_0015B080;
- s32 i = 0;
- s32 even;
- u8 *target_name;
- state->unk28 = arg1;
- arg1 = arg0->unk0;
- state->unk2C = arg2;
- state->unk0 = arg1;
- even = arg0->unk4;
- state->unk4 = even;
- state->unk8 = arg0->unk8;
- state->unkC = arg0->unkC;
- state->unk10 = arg0->unk10;
- target_name = state->pad_14;
- do {
- even = source_name[i];
- target_name[i] = even;
- i++;
- } while (i < 0x10);
- if (sceSifCallRpc(D_0015B008, 0x80000901, 0, &D_0015B080, 0x400, &D_0015B080, 0x400, 0, 0) <
- 0) {
- debug_print_stub(D_00153578);
- return 0;
- }
- return state->unk24;
-}
-
-#endif /* NON_MATCHING */
diff --git a/src/assembly/textbin/video/decoder/vi_buf_restart_dma.c b/src/assembly/textbin/video/decoder/vi_buf_restart_dma.c
deleted file mode 100644
index 92b1039ca4..0000000000
--- a/src/assembly/textbin/video/decoder/vi_buf_restart_dma.c
+++ /dev/null
@@ -1,142 +0,0 @@
-#include "types.h"
-#include "asm.h"
-
-#ifndef NON_MATCHING
-INCLUDE_ASM(
- "config/us/expected/asm/assembly/textbin/video/decoder/vi_buf_restart_dma/FUN_0023c280.s",
- FUN_0023c280);
-#else
-#include "types.h"
-
-typedef struct {
- u32 data;
- u32 tag;
- s32 n;
- s32 dmaStart;
- s32 readBytes;
- u8 pad14[8];
- u32 d4_madr;
- u32 d4_tadr;
- u32 d4_qwc;
- u32 d4_chcr;
- u32 d3_madr;
- u32 d3_qwc;
- u32 d3_chcr;
- u32 ipu_bp;
- u32 ipu_ctrl;
- s32 sema;
- s32 active;
-} ViBuf;
-
-#define DGET(a) (*(volatile u32 *)(a))
-
-extern s32 WaitSema(s32);
-extern s32 SignalSema(s32);
-extern s32 get_fifo_index(ViBuf *, s32) __asm__("func_0023BAF8");
-extern void set_d3_chcr(s32) __asm__("func_0023BB40");
-extern void set_d4_chcr(s32) __asm__("func_0023BBB0");
-
-s32 vi_buf_restart_dma(ViBuf *f) __asm__("FUN_0023c280");
-
-s32 vi_buf_restart_dma(ViBuf *f) {
- s32 off;
- s32 ifc;
- s32 chcr;
- s32 dir;
- s32 r;
- s32 t;
- s32 u;
- s32 r1;
- s32 r2;
- u32 dmaAddress;
- u32 dmaTadr;
- u32 dmaQwc;
- u32 dmaChcr;
- u32 bp;
-
- ifc = (f->ipu_bp >> 8) & 0xF;
- off = (f->ipu_bp >> 16) & 3;
- off = off + ifc;
- dmaAddress = f->d4_madr - (off << 4);
- dmaQwc = f->d4_qwc + off;
- dmaChcr = f->d4_chcr | 0x100;
- dmaTadr = f->d4_tadr;
- bp = f->ipu_bp & 0x7F;
-
- WaitSema(f->sema);
-
- if (dmaAddress < f->data) {
- s32 datasize;
- datasize = f->n << 11;
- dmaQwc = (f->data - dmaAddress) >> 4;
- dmaTadr = f->tag & 0x0FFFFFFF;
- dmaAddress = dmaAddress + datasize;
- r = 0;
- if (f->d4_madr != f->data) {
- r = 3;
- if (f->d4_madr == f->data + datasize) {
- r = 0;
- }
- }
- r = r << 28;
- dmaChcr = (f->d4_chcr & 0x0FFFFFFF) | r | 0x100;
- datasize = f->n - f->dmaStart;
- if (datasize % f->n < 0 || datasize % f->n >= f->readBytes) {
- f->dmaStart = f->n - 1;
- f->readBytes = f->readBytes + 1;
- }
- } else {
- s32 datasize;
- r1 = get_fifo_index(f, f->d4_madr);
- r2 = get_fifo_index(f, dmaAddress);
- if (r1 != r2) {
- dmaQwc = (f->data + (r1 << 11) - dmaAddress) >> 4;
- dmaTadr = ((r1 << 4) + f->tag) & 0x0FFFFFFF;
- dir = 3;
- datasize = f->n << 11;
- t = (f->d4_madr - f->data) % (u32)datasize;
- u = (f->dmaStart + f->readBytes) % f->n;
- if (((f->data + t) ^ (f->data + (u << 11))) == 0) {
- dir = 0;
- }
- chcr = f->d4_chcr & 0x0FFFFFFF;
- dir = dir << 28;
- dmaChcr = chcr | dir | 0x100;
- r = ((r2 + f->n) - f->dmaStart) % f->n;
- if (r < 0 || (((r2 + f->n) - f->dmaStart) % f->n) >= f->readBytes) {
- f->readBytes = f->readBytes + 1;
- f->dmaStart = r2;
- }
- }
- }
-
- if (f->d3_madr != 0) {
- if (f->d3_qwc != 0) {
- DGET(0x1000B010) = f->d3_madr;
- DGET(0x1000B020) = f->d3_qwc;
- set_d3_chcr(f->d3_chcr | 0x100);
- }
- }
- if (f->readBytes != 0) {
- if (*(volatile s32 *)0x10002010 < 0) {
- while (*(volatile s32 *)0x10002010 < 0) {
- }
- }
- DGET(0x10002000) = bp;
- if (*(volatile s32 *)0x10002010 < 0) {
- while (*(volatile s32 *)0x10002010 < 0) {
- }
- }
- }
- DGET(0x1000B410) = dmaAddress;
- DGET(0x1000B430) = dmaTadr;
- DGET(0x1000B420) = dmaQwc;
- if (f->readBytes != 0) {
- set_d4_chcr(dmaChcr);
- }
- DGET(0x10002010) = f->ipu_ctrl;
- f->active = 1;
- SignalSema(f->sema);
- return 1;
-}
-#endif /* NON_MATCHING */
diff --git a/src/assembly/textbin/gameplay/vendor/render_capture_scrolling_text.c b/src/gameplay/vendor/render_capture_scrolling_text.c
similarity index 52%
rename from src/assembly/textbin/gameplay/vendor/render_capture_scrolling_text.c
rename to src/gameplay/vendor/render_capture_scrolling_text.c
index a00f06d898..e716e2bd1c 100644
--- a/src/assembly/textbin/gameplay/vendor/render_capture_scrolling_text.c
+++ b/src/gameplay/vendor/render_capture_scrolling_text.c
@@ -1,14 +1,8 @@
#include "types.h"
-#include "asm.h"
+#include "sda.h"
#include "rnc/ui/vendor/vendor_capture.h"
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/expected/asm/assembly/textbin/gameplay/vendor/render_capture_scrolling_text/FUN_00238310.s", FUN_00238310);
-#else
-#include "types.h"
-#include "rnc/ui/vendor/vendor_capture.h"
-
-extern s32 game_frame_counter __asm__("D_0015F438");
+extern s32 game_frame_counter __asm__("D_0015F438") MACRO_ADDR;
extern void draw_textured_quad(s32, s32, s32, s32, s32, s32, s32, s32, s64,
s64) __asm__("func_001F5450");
extern s32 scale_game_frames(s32) __asm__("func_001F96F8");
@@ -37,6 +31,7 @@ void render_capture_scrolling_text(char *text, s32 start_x, s32 start_y, f32 sca
s32 texture_u;
s32 glyph_width;
s32 glyph_height;
+ s32 *glyph_entry;
u8 character;
blink_next_glyph = 0;
@@ -47,11 +42,10 @@ void render_capture_scrolling_text(char *text, s32 start_x, s32 start_y, f32 sca
for (;;) {
skip_draw = 0;
- character = (u8)*cursor_text;
- if (character == 0) {
+ if (*(u8 *)cursor_text == 0) {
return;
}
- cursor_text++;
+ character = (u8)*cursor_text++;
glyph_index = (s32)character - 0x20;
if (glyph_index == 0x42) {
@@ -64,55 +58,46 @@ void render_capture_scrolling_text(char *text, s32 start_x, s32 start_y, f32 sca
}
if (glyph_index < 0x3B) {
- {
- volatile s32 *glyph_entry;
- glyph_entry = capture_glyph_coordinates + glyph_index;
- if (*glyph_entry != -1 || glyph_index == 0) {
- if (blink_next_glyph != 0) {
- skip_draw = 0;
- blink_next_glyph = 0;
- long_blink_period = scale_game_frames(0x1E);
- short_blink_period = scale_game_frames(0xA);
- blink_period = long_blink_period + short_blink_period;
- blink_remainder = game_frame_counter % blink_period;
- long_blink_period = scale_game_frames(0xA);
- if (blink_remainder < long_blink_period) {
- skip_draw = 1;
- }
+ glyph_entry = capture_glyph_coordinates + glyph_index;
+ if (*glyph_entry != -1 || glyph_index == 0) {
+ if (blink_next_glyph != 0) {
+ skip_draw = 0;
+ blink_next_glyph = 0;
+ long_blink_period = scale_game_frames(0x1E);
+ short_blink_period = scale_game_frames(0xA);
+ blink_period = long_blink_period + short_blink_period;
+ blink_remainder = game_frame_counter % blink_period;
+ long_blink_period = scale_game_frames(0xA);
+ if (blink_remainder < long_blink_period) {
+ skip_draw = 1;
}
+ }
- if (glyph_index != 0 && skip_draw == 0) {
- packed_coordinates = *glyph_entry;
- texture_v = (u32)packed_coordinates >> 0x14;
- texture_u = (packed_coordinates & 0xFFFF) >> 4;
+ if (glyph_index != 0 && skip_draw == 0) {
+ packed_coordinates = *glyph_entry;
+ texture_v = (u32)packed_coordinates >> 0x14;
+ texture_u = (packed_coordinates & 0xFFFF) >> 4;
- if (cursor_x + 9 > 0) {
- if (cursor_x < 0x100) {
- glyph_width =
- convert_float_to_integer(convert_integer_to_float(9) * scale);
- glyph_height =
- convert_float_to_integer(convert_integer_to_float(9) * scale);
- draw_textured_quad(cursor_x, cursor_y, glyph_width, glyph_height,
- texture_u, texture_v, 9, 9, (s64)0x80404040,
- texture);
- }
+ if (cursor_x + 9 > 0) {
+ if (cursor_x < 0x100) {
+ glyph_width = convert_float_to_integer(convert_integer_to_float(9) * scale);
+ glyph_height = convert_float_to_integer(convert_integer_to_float(9) * scale);
+ draw_textured_quad(cursor_x, cursor_y, glyph_width, glyph_height,
+ texture_u, texture_v, 9, 9, (s64)0x80404040, texture);
}
}
-
- cursor_x += convert_float_to_integer(
- convert_integer_to_float(capture_glyph_advances[glyph_index]) * scale);
}
+
+ cursor_x += convert_float_to_integer(
+ convert_integer_to_float(capture_glyph_advances[glyph_index]) * scale);
}
}
}
}
-extern __typeof__(render_capture_scrolling_text) func_00238310
- __attribute__((alias("FUN_00238310")));
+extern __typeof__(render_capture_scrolling_text) func_00238310 __attribute__((alias("FUN_00238310")));
-#endif /* NON_MATCHING */
-
-volatile s32 capture_glyph_coordinates[64] = {
+s32 capture_glyph_coordinates[64] = {
-1, 0x2400120, -1, -1, -1, -1, -1, 0x2d00000,
-1, -1, -1, -1, 0x24001b0, 0x24002d0, 0x2400240, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
@@ -122,7 +107,6 @@ volatile s32 capture_glyph_coordinates[64] = {
0x12001b0, 0x1200240, 0x12002d0, 0x1b00000, 0x1b00090, 0x1b00120, 0x1b001b0, 0x1b00240,
0x1b002d0, 0x2400000, 0x2400090, -1, -1, -1, -1, -1,
};
-
s32 capture_glyph_advances[64] = {
9, 5, 0xa, 0xa, 0xa, 0xa, 0xa, 5,
0xa, 0xa, 0xa, 0xa, 5, 9, 5, 0xa,
diff --git a/src/overlays/l05/gameplay/entities/sharkigator.c b/src/overlays/l05/gameplay/entities/sharkigator.c
index 6cb645cb7e..1bab844988 100644
--- a/src/overlays/l05/gameplay/entities/sharkigator.c
+++ b/src/overlays/l05/gameplay/entities/sharkigator.c
@@ -162,7 +162,7 @@ int FUN_L05_00307470(int arg) {
/* Ported from rac1-decomp (src/overlays/l05_rilgar/vendor_002D28D0.c: func_L05_003088D8), where it is exact; names translated to the US level program. */
extern int FUN_L05_00307470(int);
-void blend_moby_animation(MobyAnim *arg0, int arg1, int arg2, int arg3) __asm__("FUN_00212f90");
+extern void blend_moby_animation(void *, int, int, int) __asm__("FUN_00212f90");
void FUN_L05_00307480(char *moby, int a1, int a2, int a3) {
char *data;
@@ -1042,405 +1042,431 @@ void FUN_L05_002db238(void *moby, void *dir) {
}
}
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L05_00301f48.s", FUN_L05_00301f48);
-#else
-extern void spawn_particle_305178(void *, int, void *, void *, int, int, float, void *, void *, void *) __asm__("FUN_L00_00263fd8");
-extern int D_L05_0015F5C4;
-extern int D_L05_00161A84 __attribute__((sda));
-extern float D_L05_00161A98_gp __asm__("D_L05_00161A98") __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 int D_001404A8;
-extern float distance_2d1688(void *, void *) __asm__("FUN_001f9b48");
-extern float distance_to_2d1688(void *, void *) __asm__("FUN_001f9b80");
-extern float absolute_2d1688(float) __asm__("FUN_001f99c0");
-extern void fast_vec_add(void *, void *, void *) __asm__("FUN_001f9a10");
-extern void mark_moby_2d1688(char *) __asm__("FUN_0020c828");
+/* Extermibot update: wakes from its dormant pose, walks its path, closes in on the target and strikes it, bursts into sparks between strikes, and dies on a hit. */
+/* Ported from rac1-decomp (src/overlays/l05_rilgar/vendor_002D28D0.c: func_L05_003033A0), where it is exact; names translated to the US level program. */
+
+typedef struct Moby Moby;
+
+extern char D_L05_0015F580[] __attribute__((section(".sdata")));
extern char D_L05_001671C0[];
-extern float D_0013F3D0[4];
-extern void FUN_L01_0026d930(char *);
-extern int FUN_L00_00258b50(void *, void *, void *, void *, float);
-extern void FUN_L05_0028be78(void *, int, int);
-extern void FUN_L05_00303390(struct Moby *);
-extern void FUN_L05_00303b08(struct Moby *, int, float);
-extern void FUN_L00_00263b38(void *, float);
-extern void FUN_L00_0025a120(void *);
-extern int follow_path(void *, int, int, void *, int, void *, float) __asm__("FUN_L01_00276fe8");
-extern float angle_diff(float, float) __asm__("FUN_001fa688");
-extern float approach_value(float *, float, float) __asm__("FUN_00213ed8");
-extern float approach_angle(float *, float, float *, float, float, float) __asm__("FUN_L00_0025be00");
-extern int FUN_L00_00261d78(int, void *, void *, float);
-extern int FUN_L00_00261b48(int, void *, void *, void *);
-extern int FUN_L00_0025c698(void *, void *);
-extern int is_point_inside_clip_volume(void *, int) __asm__("FUN_00214720");
-extern void moby_point_position(void *, int, void *) __asm__("FUN_L00_0024f7c8");
-extern float FUN_0020c9e0(struct Moby *);
+extern f32 approach_value(f32 *, f32, f32);
+extern f32 fast_arc_tan(f32, f32) __asm__("func_001F9E90");
+extern f32 fast_cos_c4(f32) __asm__("func_001F9DC8");
+extern f32 fast_sin_c6(f32) __asm__("func_001F9DE0");
+extern f32 random_angle_radians_c4(void) __asm__("func_00213308");
+extern f32 random_float_between_c3(f32, f32) __asm__("func_002132A8");
+extern float FUN_001f96b0(float);
+extern float fast_add_rotations_c4(float, float) __asm__("func_001FA580");
+extern float fast_difference_between_rotations(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_L05_0015FFD8;
+extern int D_L05_0015F5C4;
extern int FUN_001f9770(void *);
+extern int FUN_L00_0025c698(void *, void *);
+extern int FUN_L00_00261b48(int, void *, void *, void *);
+extern int is_point_inside_clip_volume(void *arg0, int arg1) __asm__("func_00214720");
+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 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 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);
+extern void FUN_L00_0025a120(void *);
extern void FUN_L00_0025f090(void *, void *, int, float, float);
-#define F301(p,o) (*(float *)((char *)(p)+(o)))
-#define I301(p,o) (*(int *)((char *)(p)+(o)))
-#define H301(p,o) (*(unsigned short *)((char *)(p)+(o)))
-#define S301(p,o) (*(short *)((char *)(p)+(o)))
-#define B301(p,o) (*(unsigned char *)((char *)(p)+(o)))
-void FUN_L05_00301f48(struct Moby *moby) {
- char *data = (char *)moby->pvars;
- struct Moby *target;
- float v[4] __attribute__((aligned(16)));
- float w[4] __attribute__((aligned(16)));
- float point[4] __attribute__((aligned(16)));
- float pos[4] __attribute__((aligned(16)));
- float distance, angle;
- float *rotation;
- float height_limit;
- float height;
- int timer, i, n1, n2, n3;
- int blocked;
- FUN_L00_00263b38(data + 0x170, 2.5f);
- if (D_L05_0015F5C4 == 2) {
- if (((moby->flags ^ 1) & 1) == 0) goto check_freeze;
- I301(data,0x2dc) = 1;
- moby->flags |= 0x41;
- goto freeze_done;
- }
-check_freeze:
- if (I301(data,0x2dc) != 0 && D_L05_0015F5C4 == 0) {
- I301(data,0x2dc) = 0;
- moby->flags &= 0xffbe;
- }
-freeze_done:
- if (moby->visible && distance_2d1688((char *)moby + 0x10, D_L05_001671C0) < 28.0f) {
- FUN_L00_0025a120(moby);
- moby->shadow_range = 0x16;
- }
- FUN_L05_00303390(moby);
- target = *(struct Moby **)(data + 0x160);
- moby->scale = moby->pclass->scale * D_L05_00161A98_gp;
- switch (moby->state) {
+extern void FUN_L00_00261d78(int, void *, void *, float);
+extern void FUN_L00_00263b38(void *, float);
+extern void FUN_L00_00263fd8_c(void *, int, void *, void *, int, int, float, void *, void *, void *) __asm__("FUN_L00_00263fd8");
+extern void FUN_L05_0028be78(int *, int, int);
+extern void blend_moby_animation(void *, int, int, int) __asm__("FUN_00212f90");
+extern void mark_moby_for_removal_c2(void *) __asm__("func_0020C828");
+f32 compute_interpolated_record_value(void *anim) __asm__("FUN_0020c9e0");
+float absolute_float(float input) __asm__("func_001F99C0");
+void FUN_L05_00303390_c(Moby *m) __asm__("FUN_L05_00303390");
+void FUN_L05_00303b08_c(struct Moby *m, s32 node, f32 side) __asm__("FUN_L05_00303b08");
+extern float D_0013F3D0[];
+extern char D_001404A8[];
+
+void FUN_L05_00301f48(unsigned char *m) {
+ char *d = *(char **)(m + 0x78);
+ char *t;
+ float dir[4];
+ float out[4];
+ float hit[4];
+ float pos[4];
+ int i;
+ int j;
+ float *rot;
+ float yaw;
+ unsigned char *pos0;
+ extern float fast_vec_dist(void *, void *);
+
+ FUN_L00_00263b38(d + 0x170, 2.5f);
+ if (D_L05_0015F5C4 == 2 && ((*(unsigned short *)(m + 0x34) ^ 1) & 1)) {
+ *(int *)(d + 0x2DC) = 1;
+ *(unsigned short *)(m + 0x34) |= 0x41;
+ } else if (*(int *)(d + 0x2DC) != 0 && D_L05_0015F5C4 == 0) {
+ *(int *)(d + 0x2DC) = 0;
+ *(unsigned short *)(m + 0x34) &= 0xFFBE;
+ }
+ if (m[0x31] != 0 && fast_vec_dist((float *)(m + 0x10), (float *)D_L05_001671C0) < 28.0f) {
+ FUN_L00_0025a120(m);
+ m[0x7F] = 0x16;
+ }
+ FUN_L05_00303390_c((Moby *)m);
+ t = *(char **)(d + 0x160);
+ *(float *)(m + 0x2C) = *(float *)(*(char **)(m + 0x24) + 0x24) * (D_L05_00161A98);
+ switch (m[0x20]) {
case 0:
- moby->flags |= 0x1000;
- qcopy(data + 0x270, (char *)moby + 0x10);
- F301(data,0x20) = 2.0f;
- B301(data,0x29) = 0;
- I301(data,0x2b0) = 0;
- B301(data,0x28) = 1;
- F301(data,0x30) = 1.0f;
- S301(data,0x24) = 2;
- B301(data,0x58) = func_001FA898_r(14.0f);
- B301(data,0x5a) = func_001FA898_r(11.2f);
- FUN_L01_0026d930(data + 0xd0);
- distance = D_L05_00161A98_gp * 409.6f;
- F301(data,0xdc) = 2.0f;
- F301(data,0xd8) = 2.0f;
- timer = func_001FA898_r(distance);
+ *(unsigned short *)(m + 0x34) |= 0x1000;
+ qcopy(d + 0x270, m + 0x10);
+ *(float *)(d + 0x20) = 2.0f;
+ d[0x29] = 0;
+ *(int *)(d + 0x2B0) = 0;
+ d[0x28] = 1;
+ *(float *)(d + 0x30) = 1.0f;
+ *(short *)(d + 0x24) = 2;
+ d[0x58] = truncate_float_to_s32_c4(14.0f);
+ d[0x5A] = truncate_float_to_s32_c4(11.2f);
+ FUN_L01_0026d930(d + 0xD0);
{
- float speed = frame_time * 6.0f;
- I301(data,0xd0) = timer;
- F301(data,0xf4) = speed;
- }
- F301(data,0x2d8) = random_angle_radians();
- if (random_integer_below(2)) moby->flags |= 0x8000;
- else moby->flags &= 0x7fff;
- if (I301(data,0x2b4)) {
- moby->state = 12;
- moby->visible = 0;
- moby->flags &= 0xefff;
- moby->pos.z -= 20.0f;
- moby->collision = 0;
- moby->draw_dist = 0;
+ float q = D_L05_00161A98;
+ *(float *)(d + 0xDC) = 2.0f;
+ *(float *)(d + 0xD8) = 2.0f;
+ {
+ int r0 = truncate_float_to_s32_c4(q * 409.6f);
+ float e6 = D_0015ED6C * 6.0f;
+ *(int *)(d + 0xD0) = r0;
+ *(float *)(d + 0xF4) = e6;
+ }
+ }
+ *(float *)(d + 0x2D8) = random_angle_radians_c4();
+ if (random_integer_below_c2(2) != 0) {
+ *(unsigned short *)(m + 0x34) |= 0x8000;
} else {
- if (*(long *)(data + 0x2b8) != -1) {
- moby->state = 15;
- moby->flags &= 0xefff;
- if (moby->prev_seq) blend_moby_animation(moby,0,0,0);
- } else {
- moby->state = 1;
- if (moby->prev_seq) blend_moby_animation(moby,0,0,0);
- }
+ *(unsigned short *)(m + 0x34) &= 0x7FFF;
+ }
+ if (*(int *)(d + 0x2B4) != 0) {
+ m[0x20] = 0xC;
+ m[0x31] = 0;
+ *(int *)(m + 0x94) = 0;
+ *(unsigned short *)(m + 0x34) &= 0xEFFF;
+ *(float *)(m + 0x18) -= 20.0f;
+ *(short *)(m + 0x32) = 0;
+ } else if (*(long *)(d + 0x2B8) != -1) {
+ *(unsigned short *)(m + 0x34) &= 0xEFFF;
+ m[0x20] = 0xF;
+ if (m[0x53] != 0) blend_moby_animation(m, 0, 0, 0);
+ } else {
+ m[0x20] = 1;
+ if (m[0x53] != 0) blend_moby_animation(m, 0, 0, 0);
}
- FUN_L05_0028be78(data + 0x2c0,1,I301(data,0x2c4));
+ FUN_L05_0028be78((int *)(d + 0x2C0), 1, *(int *)(d + 0x2C4));
break;
case 1:
- if (I301(data,0x164) != 2) {
- if (random_integer_below(9) == 0) {
- if (follow_path(data+0x2c0,1,I301(data,0x2c4),(char *)moby+0x10,(int)((char *)target+0x10),v,D_L05_00161A98_gp*0.4f) != 0) {
- if (random_integer_below(0x100)&1) F301(data,0x298) = -F301(data,0x298);
- F301(data,0x294) = F301(data,0x298)*0.017453292f;
- I301(data,0x2ac) = FUN_001f96f8((int)random_float_between(30.0f,90.0f));
- moby->state = 4;
- if (moby->prev_seq != 1) blend_moby_animation(moby,1,0,FUN_001f96f8(10));
- } else {
- I301(data,0x164) = 2;
+ if (*(int *)(d + 0x164) != 2 && random_integer_below_c2(9) == 0) {
+ if (FUN_L01_00276fe8(d + 0x2C0, 1, *(int *)(d + 0x2C4), m + 0x10, (s32)(t + 0x10), dir,
+ (D_L05_00161A98) * 0.4f) != 0) {
+ if (random_integer_below_c2(0x100) & 1) {
+ *(float *)(d + 0x298) = -*(float *)(d + 0x298);
}
+ *(float *)(d + 0x294) = *(float *)(d + 0x298) * 0.017453292f;
+ *(int *)(d + 0x2AC) = scale_game_frames((int)random_float_between_c3(30.0f, 90.0f));
+ m[0x20] = 4;
+ if (m[0x53] != 1) blend_moby_animation(m, 1, 0, scale_game_frames(10));
+ } else {
+ *(int *)(d + 0x164) = 2;
}
}
-check_mode:
- if (I301(data,0x164) == 2 && I301(data,0x2b0)) {
- moby->state = 6;
- if (moby->prev_seq != 1) blend_moby_animation(moby,1,0,FUN_001f96f8(10));
- goto done;
- }
- if (!(moby->anim_flags&2)) break;
- if (moby->visible && (random_integer_below(255)&1)) {
- random_vector((float *)(data+0x280),0.0f,4.0f);
- F301(data,0x288) = 0.0f;
- fast_vec_add(data+0x280,data+0x280,data+0x270);
- H301(data,0x2d2) = 0;
- moby->command = moby->state;
- moby->state = 2;
- if (moby->prev_seq != 1) blend_moby_animation(moby,1,0,FUN_001f96f8(10));
- goto done;
+ if (*(int *)(d + 0x164) == 2 && *(int *)(d + 0x2B0) != 0) {
+ m[0x20] = 6;
+ if (m[0x53] != 1) blend_moby_animation(m, 1, 0, scale_game_frames(10));
+ } else if (m[0x70] & 2) {
+ if (m[0x31] != 0 && (random_integer_below_c2(0xFF) & 1)) {
+ FUN_L00_00257d78((float *)(d + 0x280), 0.0f, 4.0f);
+ *(float *)(d + 0x288) = 0.0f;
+ add_vector_xyz(d + 0x280, d + 0x280, d + 0x270);
+ *(short *)(d + 0x2D2) = 0;
+ m[0xBC] = m[0x20];
+ m[0x20] = 2;
+ if (m[0x53] != 1) blend_moby_animation(m, 1, 0, scale_game_frames(10));
+ } else if (m[0x53] != 0) {
+ blend_moby_animation(m, 0, 0, scale_game_frames(10));
+ }
}
- if (moby->prev_seq != 0) blend_moby_animation(moby,0,0,FUN_001f96f8(10));
- goto done;
+ break;
case 2:
- rotation=&moby->rot.z;
- angle = FUN_001f9e90(F301(data,0x280)-moby->pos.x,F301(data,0x284)-moby->pos.y);
- approach_angle(rotation,angle,(float *)(data+0x290),frame_time_sq*6.2831855f,frame_time_sq*6.2831855f,frame_time*6.2831855f);
- if (angle_diff(moby->rot.z,FUN_001f9e90(F301(data,0x280)-moby->pos.x,F301(data,0x284)-moby->pos.y)) < 1.5707964f) {
- v[0] = FUN_001f9dc8(moby->rot.z); v[0] += v[0];
- v[1] = FUN_001f9de0(moby->rot.z); v[1] += v[1];
- v[2] = 0.0f;
- FUN_L00_00258b50(moby,data+0xd0,v,w,1.0f);
- FUN_L00_00261d78(I301(data,0x2c0),(char *)moby+0x10,(char *)moby+0x10,D_L05_00161A98_gp*0.4f);
- }
- H301(data,0x2d2) += 1;
- distance=distance_to_2d1688((char *)moby+0x10,data+0x280);
- timer=S301(data,0x2d2);
- if (distance < 1.0f) {
- if (timer > FUN_001f96f8(60)) goto finish_wander;
- timer=S301(data,0x2d2);
- }
- if (timer <= FUN_001f96f8(180)) break;
-finish_wander:
- moby->state = moby->command;
- if (moby->prev_seq != 0) blend_moby_animation(moby,0,0,FUN_001f96f8(20));
- goto done;
- case 6:
- rotation=&moby->rot.z;
- approach_value((float *)(data+0xf4),frame_time*6.0f,frame_time_sq*6.0f);
- angle=FUN_001f9e90(target->pos.x-moby->pos.x,target->pos.y-moby->pos.y);
- approach_angle(rotation,angle,(float *)(data+0x290),frame_time_sq*6.2831855f,frame_time_sq*6.2831855f,frame_time*6.2831855f);
- if (angle_diff(moby->rot.z,FUN_001f9e90(target->pos.x-moby->pos.x,target->pos.y-moby->pos.y)) < 1.5707964f) {
- v[0]=FUN_001f9dc8(moby->rot.z); v[0]+=v[0];
- v[1]=FUN_001f9de0(moby->rot.z); v[1]+=v[1];
- v[2]=0.0f;
- FUN_L00_00258b50(moby,data+0xd0,v,w,1.0f);
- FUN_L00_00261d78(I301(data,0x2c0),(char *)moby+0x10,(char *)moby+0x10,D_L05_00161A98_gp*0.4f);
- }
- blocked = 0;
- if (FUN_L00_00261b48(I301(data,0x2c0),(char *)moby+0x10,(char *)target+0x10,point) && distance_2d1688((char *)moby+0x10,point)<1.5f) blocked = 1;
- if (blocked) {
- moby->state=5;
- if (moby->prev_seq != 4) blend_moby_animation(moby,4,0,FUN_001f96f8(20));
- goto done;
- }
- if (I301(data,0x2b0)==0) { moby->state=10; break; }
- if (distance_to_2d1688((char *)moby+0x10,(char *)target+0x10)<3.0f) {
- moby->state=7;
- H301(data,0x2d0)=FUN_001f96f8(D_L05_00161AC8);
- if (moby->prev_seq != 2) blend_moby_animation(moby,2,0,FUN_001f96f8(10));
- goto done;
+ rot = (float *)(m + 0x48);
+ pos0 = m + 0x10;
+ yaw = fast_arc_tan(*(float *)(d + 0x280) - *(float *)(m + 0x10),
+ *(float *)(d + 0x284) - *(float *)(m + 0x14));
+ FUN_L00_0025be00(rot, (float *)(d + 0x290), yaw,
+ D_0015ED70 * 6.2831855f, D_0015ED70 * 6.2831855f, D_0015ED6C * 6.2831855f);
+ if (fast_difference_between_rotations(*(float *)(m + 0x48),
+ fast_arc_tan(*(float *)(d + 0x280) - *(float *)(m + 0x10),
+ *(float *)(d + 0x284) - *(float *)(m + 0x14))) < 1.5707964f) {
+ dir[0] = fast_cos_c4(*(float *)(m + 0x48)) * 2.0f;
+ dir[1] = fast_sin_c6(*(float *)(m + 0x48)) * 2.0f;
+ dir[2] = 0.0f;
+ FUN_L00_00258b50(m, d + 0xD0, dir, out, 1.0f);
+ FUN_L00_00261d78(*(int *)(d + 0x2C0), pos0, pos0, (D_L05_00161A98) * 0.4f);
+ }
+ (*(short *)(d + 0x2D2))++;
+ if ((vector_distance_xy_alt(pos0, d + 0x280) < 1.0f && *(short *)(d + 0x2D2) > scale_game_frames(0x3C))
+ || *(short *)(d + 0x2D2) > scale_game_frames(0xB4)) {
+ m[0x20] = m[0xBC];
+ if (m[0x53] != 0) blend_moby_animation(m, 0, 0, scale_game_frames(20));
}
break;
- case 5:
- if (I301(data,0x2b0)==0) {
- F301(data,0xf4)=0.0f;
- moby->state=10;
- if (moby->prev_seq != 1) blend_moby_animation(moby,1,0,FUN_001f96f8(20));
- goto done;
+ case 6: {
+ int near;
+ rot = (float *)(m + 0x48);
+ pos0 = m + 0x10;
+ approach_value((float *)(d + 0xF4), D_0015ED6C * 6.0f, D_0015ED70 * 6.0f);
+ yaw = fast_arc_tan(*(float *)(t + 0x10) - *(float *)(m + 0x10),
+ *(float *)(t + 0x14) - *(float *)(m + 0x14));
+ FUN_L00_0025be00(rot, (float *)(d + 0x290), yaw,
+ D_0015ED70 * 6.2831855f, D_0015ED70 * 6.2831855f, D_0015ED6C * 6.2831855f);
+ if (fast_difference_between_rotations(*(float *)(m + 0x48),
+ fast_arc_tan(*(float *)(t + 0x10) - *(float *)(m + 0x10),
+ *(float *)(t + 0x14) - *(float *)(m + 0x14))) < 1.5707964f) {
+ dir[0] = fast_cos_c4(*(float *)(m + 0x48)) * 2.0f;
+ dir[1] = fast_sin_c6(*(float *)(m + 0x48)) * 2.0f;
+ dir[2] = 0.0f;
+ FUN_L00_00258b50(m, d + 0xD0, dir, out, 1.0f);
+ FUN_L00_00261d78(*(int *)(d + 0x2C0), pos0, pos0, (D_L05_00161A98) * 0.4f);
+ }
+ near = 0;
+ if (FUN_L00_00261b48(*(int *)(d + 0x2C0), pos0, t + 0x10, hit) != 0
+ && fast_vec_dist((float *)pos0, hit) < 1.5f) {
+ near = 1;
+ }
+ if (near) {
+ m[0x20] = 5;
+ if (m[0x53] != 4) blend_moby_animation(m, 4, 0, scale_game_frames(20));
+ } 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);
+ if (m[0x53] != 2) blend_moby_animation(m, 2, 0, scale_game_frames(10));
+ }
+ } else {
+ m[0x20] = 10;
}
- if (distance_to_2d1688((char *)moby+0x10,(char *)target+0x10) < 3.0f) {
- moby->state=7;
- H301(data,0x2d0)=FUN_001f96f8(D_L05_00161AC8);
- if (moby->prev_seq != 2) blend_moby_animation(moby,2,0,FUN_001f96f8(10));
+ break;
+ }
+ case 5:
+ if (*(int *)(d + 0x2B0) == 0) {
+ *(float *)(d + 0xF4) = 0.0f;
+ m[0x20] = 10;
+ 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);
+ if (m[0x53] != 2) blend_moby_animation(m, 2, 0, scale_game_frames(10));
}
break;
case 15:
- if ((I301(data,0x2b8)!=-1 && B301(((char *)D_L05_0015FFD8_7920)+I301(data,0x2b8)*256,0xbc)) || (I301(data,0x2bc)!=-1 && is_point_inside_clip_volume(D_0013F3D0,I301(data,0x2bc)))) {
- moby->draw_dist=0x40; moby->state=1; moby->flags|=0x1000;
- break;
+ if ((*(int *)(d + 0x2B8) != -1 && ((unsigned char *)*(int *)&D_L05_0015FFD8)[*(int *)(d + 0x2B8) * 256 + 0xBC] != 0)
+ || (*(int *)(d + 0x2BC) != -1 && is_point_inside_clip_volume(((char *)D_0013F3D0), *(int *)(d + 0x2BC)) != 0)) {
+ *(short *)(m + 0x32) = 0x40;
+ *(unsigned short *)(m + 0x34) |= 0x1000;
+ m[0x20] = 1;
+ } else if (m[0x70] & 2) {
+ if (random_integer_below_c2(0xFF) & 1) {
+ FUN_L00_00257d78((float *)(d + 0x280), 0.0f, 4.0f);
+ *(float *)(d + 0x288) = 0.0f;
+ add_vector_xyz(d + 0x280, d + 0x280, d + 0x270);
+ *(short *)(d + 0x2D2) = scale_game_frames(0x5A);
+ m[0xBC] = m[0x20];
+ m[0x20] = 2;
+ if (m[0x53] != 1) blend_moby_animation(m, 1, 0, scale_game_frames(10));
+ } else if (m[0x53] != 0) {
+ blend_moby_animation(m, 0, 0, scale_game_frames(10));
+ }
}
- if (!(moby->anim_flags&2)) break;
- if (random_integer_below(255)&1) {
- random_vector((float *)(data+0x280),0.0f,4.0f);
- F301(data,0x288)=0.0f;
- fast_vec_add(data+0x280,data+0x280,data+0x270);
- H301(data,0x2d2)=FUN_001f96f8(90);
- moby->command=moby->state; moby->state=2;
- if (moby->prev_seq != 1) blend_moby_animation(moby,1,0,FUN_001f96f8(10));
- goto done;
- }
- if (moby->prev_seq != 0) blend_moby_animation(moby,0,0,FUN_001f96f8(10));
- goto done;
- case 4:
- distance=distance_to_2d1688((char *)moby+0x10,(char *)target+0x10);
- FUN_L05_00303b08(moby,(int)((char *)target+0x10),F301(data,0x294));
- if (distance < 3.0f && angle_diff(moby->rot.z,FUN_001f9e90(target->pos.x-moby->pos.x,target->pos.y-moby->pos.y)) < 0.7853982f) {
- moby->state=7;
- H301(data,0x2d0)=FUN_001f96f8(D_L05_00161AC8);
- if (moby->prev_seq!=2) blend_moby_animation(moby,2,0,FUN_001f96f8(10));
- }
- if (I301(data,0x164)==2) moby->state=10;
break;
- case 7: {
- float angle;
- float zero;
- rotation=&moby->rot.z;
- angle=FUN_001f9e90(target->pos.x-moby->pos.x,target->pos.y-moby->pos.y);
- approach_angle(rotation,angle,(float *)(data+0x290),frame_time_sq*12.566371f,frame_time_sq*12.566371f,frame_time*25.132742f);
- if ((moby->anim_flags&2) && moby->prev_seq==2) blend_moby_animation(moby,7,0,FUN_001f96f8(5));
- if (!FUN_001f9770(data+0x2d0)) break;
- moby->state=8;
- H301(data,0x2d0)=0;
- if (moby->prev_seq!=3) blend_moby_animation(moby,3,0,FUN_001f96f8(1));
- zero=0.0f;
- angle=FUN_001fa580(moby->rot.z,zero);
- v[0]=FUN_001f9dc8(angle)*(D_L05_00161AB8*frame_time);
- v[1]=FUN_001f9de0(angle)*(D_L05_00161AB8*frame_time);
- v[2]=zero; v[3]=D_L05_00161AC0;
- w[2]=zero; w[3]=D_L05_00161AC4;
- moby_point_position(moby,0,point);
- i = 29;
- do {
- qcopy(pos,point);
- distance=random_float_between(-0.065f,0.065f);
- i--;
- pos[0]+=distance;
- pos[1]+=random_float_between(-0.065f,0.065f);
- pos[2]+=random_float_between(-0.065f,0.065f);
- w[0]=random_float_between(-frame_time,frame_time);
- w[1]=random_float_between(-frame_time,frame_time);
- w[2]=random_float_between(-(D_L05_00161ABC*frame_time),D_L05_00161ABC*frame_time);
- n1=func_001FA898_r(multiply_global_factor_ed64(random_float_between(D_L05_00161AAC,D_L05_00161AAC+D_L05_00161AAC)));
- n2=func_001FA898_r(multiply_global_factor_ed64(random_float_between(D_L05_00161AB0,D_L05_00161AB0*1.2f)));
- n3=func_001FA898_r(multiply_global_factor_ed64(random_float_between(D_L05_00161AB4,D_L05_00161AB4*1.2f)));
- spawn_spark(pos,v,w,D_L05_00161A9C,D_L05_00161AA0,n1,n2,n3,-1);
- } while (i >= 0);
- v[3]=D_L05_00161AC0*0.1f; w[3]=D_L05_00161AC4*0.1f;
- {
- int i = 29;
- do {
- qcopy(pos,point);
- distance=random_float_between(-0.065f,0.065f);
- i--;
- pos[0]+=distance;
- pos[1]+=random_float_between(-0.065f,0.065f);
- pos[2]+=random_float_between(-0.065f,0.065f);
- w[0]=random_float_between(-frame_time,frame_time);
- w[1]=random_float_between(-frame_time,frame_time);
- w[2]=random_float_between(-(D_L05_00161ABC*frame_time),D_L05_00161ABC*frame_time);
- n1=func_001FA898_r(multiply_global_factor_ed64(random_float_between(D_L05_00161AAC,D_L05_00161AAC+D_L05_00161AAC)));
- n2=func_001FA898_r(multiply_global_factor_ed64(random_float_between(D_L05_00161AB0,D_L05_00161AB0*1.2f)));
- n3=func_001FA898_r(multiply_global_factor_ed64(random_float_between(D_L05_00161AB4,D_L05_00161AB4*1.2f)));
- spawn_spark(pos,v,w,D_L05_00161AA4,D_L05_00161AA8,n1,n2,n3,-1);
- } while (i >= 0);
+ case 4: {
+ float dist = vector_distance_xy_alt(m + 0x10, t + 0x10);
+ FUN_L05_00303b08_c((struct Moby *)m, (s32)(t + 0x10), *(float *)(d + 0x294));
+ if (dist < 3.0f
+ && fast_difference_between_rotations(*(float *)(m + 0x48),
+ 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);
+ if (m[0x53] != 2) blend_moby_animation(m, 2, 0, scale_game_frames(10));
+ }
+ if (*(int *)(d + 0x164) == 2) {
+ m[0x20] = 10;
}
break;
}
+ case 7:
+ rot = (float *)(m + 0x48);
+ yaw = fast_arc_tan(*(float *)(t + 0x10) - *(float *)(m + 0x10),
+ *(float *)(t + 0x14) - *(float *)(m + 0x14));
+ FUN_L00_0025be00(rot, (float *)(d + 0x290), yaw,
+ D_0015ED70 * 12.566371f, D_0015ED70 * 12.566371f, D_0015ED6C * 25.132742f);
+ if ((m[0x70] & 2) && m[0x53] == 2) {
+ blend_moby_animation(m, 7, 0, scale_game_frames(5));
+ }
+ if (FUN_001f9770(d + 0x2D0) != 0) {
+ float a;
+ m[0x20] = 8;
+ *(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[2] = 0.0f;
+ dir[3] = *(float *)&D_L05_00161AC0;
+ out[2] = 0.0f;
+ out[3] = *(float *)&D_L05_00161AC4;
+ FUN_L00_0024f7c8(m, 0, hit);
+ for (i = 0x1D; i >= 0; i--) {
+ int c1, c2;
+ qcopy(pos, hit);
+ pos[0] += random_float_between_c3(-0.065f, 0.065f);
+ pos[1] += random_float_between_c3(-0.065f, 0.065f);
+ 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);
+ }
+ dir[3] = *(float *)&D_L05_00161AC0 * 0.1f;
+ out[3] = *(float *)&D_L05_00161AC4 * 0.1f;
+ for (j = 0x1D; j >= 0; j--) {
+ int c1, c2;
+ qcopy(pos, hit);
+ pos[0] += random_float_between_c3(-0.065f, 0.065f);
+ pos[1] += random_float_between_c3(-0.065f, 0.065f);
+ 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);
+ }
+ }
+ break;
case 8: {
- int flags;
- angle=FUN_001fa580(moby->rot.z,0.0f);
- if (FUN_0020c9e0(moby)<1.5f && angle_diff(angle,FUN_001f9e90(target->pos.x-moby->pos.x,target->pos.y-moby->pos.y))<0.2617994f && distance_to_2d1688((char *)moby+0x10,(char *)target+0x10)<3.0f && absolute_2d1688(target->pos.z-moby->pos.z)<2.0f) {
- v[0]=FUN_001f9dc8(moby->rot.z);
- v[1]=FUN_001f9de0(moby->rot.z);
- v[2]=0.0f; v[3]=5627.925f;
- qcopy(w,(char *)target+0x10);
- flags=0x10000;
- if (D_001404A8!=6) flags=0x10001;
- w[2]+=0.75f;
- FUN_L00_00259bc8(target,(int)moby,flags,w,v,1.0f);
- }
- if (moby->anim_flags&2) { moby->state=9; if (moby->prev_seq != 4) blend_moby_animation(moby,4,0,FUN_001f96f8(10));
- goto done; }
+ int fl;
+ float a = fast_add_rotations_c4(*(float *)(m + 0x48), 0.0f);
+ if (compute_interpolated_record_value(m) < 1.5f
+ && fast_difference_between_rotations(a, fast_arc_tan(*(float *)(t + 0x10) - *(float *)(m + 0x10),
+ *(float *)(t + 0x14) - *(float *)(m + 0x14))) < 0.2617994f
+ && vector_distance_xy_alt(m + 0x10, t + 0x10) < 3.0f
+ && absolute_float(*(float *)(t + 0x18) - *(float *)(m + 0x18)) < 2.0f) {
+ dir[0] = fast_cos_c4(*(float *)(m + 0x48));
+ dir[1] = fast_sin_c6(*(float *)(m + 0x48));
+ dir[2] = 0.0f;
+ dir[3] = 5627.9248f;
+ qcopy(out, t + 0x10);
+ out[2] += 0.75f;
+ FUN_L00_00259bc8(t, (int)m, *(int *)(((char *)&D_001404A8)) != 6 ? 0x10001 : 0x10000, out, dir, 1.0f);
+ }
+ if (m[0x70] & 2) {
+ m[0x20] = 9;
+ if (m[0x53] != 4) blend_moby_animation(m, 4, 0, scale_game_frames(10));
+ }
break;
}
case 9:
- if (!(moby->anim_flags&2)) break;
- if (distance_to_2d1688((char *)moby+0x10,(char *)target+0x10)<3.0f && angle_diff(moby->rot.z,FUN_001f9e90(target->pos.x-moby->pos.x,target->pos.y-moby->pos.y))<0.2617994f) {
- moby->state=7; H301(data,0x2d0)=FUN_001f96f8(D_L05_00161AC8);
- if (moby->prev_seq != 7) blend_moby_animation(moby,7,0,FUN_001f96f8(5));
- goto done;
- }
- F301(data,0xf4)=0.0f; moby->state=4;
- if (moby->prev_seq != 1) blend_moby_animation(moby,1,0,FUN_001f96f8(10));
- goto done;
+ if (m[0x70] & 2) {
+ if (vector_distance_xy_alt(m + 0x10, t + 0x10) < 3.0f
+ && fast_difference_between_rotations(*(float *)(m + 0x48),
+ 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);
+ if (m[0x53] != 7) blend_moby_animation(m, 7, 0, scale_game_frames(5));
+ } else {
+ *(float *)(d + 0xF4) = 0.0f;
+ m[0x20] = 4;
+ if (m[0x53] != 1) blend_moby_animation(m, 1, 0, scale_game_frames(10));
+ }
+ }
+ break;
case 10:
- FUN_L05_00303b08(moby,(int)(data+0x270),0.0f);
- if (distance_to_2d1688((char *)moby+0x10,data+0x270)<1.0f) {
- moby->state=1; if (moby->prev_seq != 0) blend_moby_animation(moby,0,0,FUN_001f96f8(3));
- goto done;
- }
- if (I301(data,0x164)!=2) {
- moby->state=4; if (moby->prev_seq != 1) blend_moby_animation(moby,1,0,FUN_001f96f8(3));
- goto done;
- } else {
- if (I301(data,0x2b0)) moby->state=6;
+ FUN_L05_00303b08_c((struct Moby *)m, (s32)(d + 0x270), 0.0f);
+ if (vector_distance_xy_alt(m + 0x10, d + 0x270) < 1.0f) {
+ m[0x20] = 1;
+ if (m[0x53] != 0) blend_moby_animation(m, 0, 0, scale_game_frames(3));
+ } else if (*(int *)(d + 0x164) != 2) {
+ m[0x20] = 4;
+ if (m[0x53] != 1) blend_moby_animation(m, 1, 0, scale_game_frames(3));
+ } else if (*(int *)(d + 0x2B0) != 0) {
+ m[0x20] = 6;
}
break;
case 11:
- if (FUN_L00_0025c698(moby,data+0x70)&0x60) {
- if (follow_path(data+0x2c0,1,I301(data,0x2c4),(char *)moby+0x10,(int)(data+0x270),v,D_L05_00161A98_gp*0.4f)!=0) {
- moby->state=4;
- if (moby->prev_seq != 1) blend_moby_animation(moby,1,0,FUN_001f96f8(10));
- goto done;
+ if (FUN_L00_0025c698(m, d + 0x70) & 0x60) {
+ if (FUN_L01_00276fe8(d + 0x2C0, 1, *(int *)(d + 0x2C4), m + 0x10, (s32)(d + 0x270), dir,
+ (D_L05_00161A98) * 0.4f) != 0) {
+ m[0x20] = 4;
+ if (m[0x53] != 1) blend_moby_animation(m, 1, 0, scale_game_frames(10));
+ break;
}
- FUN_L00_0025f090(moby,(char *)moby+0x10,-1,0.5f,13.0f);
- goto remove;
+ FUN_L00_0025f090(m, m + 0x10, -1, 0.5f, 13.0f);
+ mark_moby_for_removal_c2(m);
+ return;
+ }
+ if (*(float *)(m + 0x18) < 2.0f) {
+ mark_moby_for_removal_c2(m);
+ return;
}
- height_limit=2.0f;
- height=moby->pos.z;
- goto check_height;
+ break;
case 13:
- if (moby->anim_flags&2) { moby->state=1; if (moby->prev_seq != 0) blend_moby_animation(moby,0,0,FUN_001f96f8(10));
- goto done; }
+ if (m[0x70] & 2) {
+ m[0x20] = 1;
+ if (m[0x53] != 0) blend_moby_animation(m, 0, 0, scale_game_frames(10));
+ }
break;
case 14:
- if (FUN_L00_0025c698(moby,data+0x70)&0x60) {
- FUN_L00_0025f090(moby,(char *)moby+0x10,-1,0.5f,13.0f);
- spawn_particle_305178((char *)moby,0x6da,(float *)((char *)moby+0x10),(char *)moby+0x40,0,0,0.0f,(float *)D_L05_0015F580_macro,(float *)D_L05_0015F580_macro,(float *)D_L05_0015F580_macro);
- spawn_particle_305178((char *)moby,0x6db,(float *)((char *)moby+0x10),(char *)moby+0x40,0,0,0.0f,(float *)D_L05_0015F580_macro,(float *)D_L05_0015F580_macro,(float *)D_L05_0015F580_macro);
- spawn_particle_305178((char *)moby,0x6dc,(float *)((char *)moby+0x10),(char *)moby+0x40,0,0,0.0f,(float *)D_L05_0015F580_macro,(float *)D_L05_0015F580_macro,(float *)D_L05_0015F580_macro);
- goto remove;
- }
- height=moby->pos.z;
- height_limit=0.0f;
- goto check_height;
- }
- goto done;
-check_height:
- if (height_limit>height) goto remove;
- goto done;
-remove:
- mark_moby_2d1688((char *)moby);
- return;
-done:
- D_L05_00161A84=*(volatile int *)0x10000000;
+ if (FUN_L00_0025c698(m, d + 0x70) & 0x60) {
+ FUN_L00_0025f090(m, m + 0x10, -1, 0.5f, 13.0f);
+ FUN_L00_00263fd8_c(m, 0x6DA, m + 0x10, m + 0x40, 0, 0, 0.0f, D_L05_0015F580, D_L05_0015F580, D_L05_0015F580);
+ FUN_L00_00263fd8_c(m, 0x6DB, m + 0x10, m + 0x40, 0, 0, 0.0f, D_L05_0015F580, D_L05_0015F580, D_L05_0015F580);
+ FUN_L00_00263fd8_c(m, 0x6DC, m + 0x10, m + 0x40, 0, 0, 0.0f, D_L05_0015F580, D_L05_0015F580, D_L05_0015F580);
+ mark_moby_for_removal_c2(m);
+ return;
+ }
+ if (*(float *)(m + 0x18) < 0.0f) {
+ mark_moby_for_removal_c2(m);
+ return;
+ }
+ break;
+ }
+ *(int *)&D_L05_00161A84 = *(volatile int *)0x10000000;
}
-#undef F301
-#undef I301
-#undef H301
-#undef S301
-#undef B301
-#endif
#include "rnc/math/vector.h"
/* Level 5 moby update (a flying enemy): takes hits through func_L00_0025B4D0 and reacts per hit kind, then
follows its path, retargets the closest moby and turns its head toward the hero. */
/* Ported from rac1-decomp (src/overlays/l05_rilgar/vendor_002D28D0.c: func_L05_003047E8), where it is exact; names translated to the US level program. */
-typedef struct Moby Moby;
typedef int u128_3047E8 __attribute__((mode(TI)));
@@ -1569,8 +1595,8 @@ extern float func_001FA790_3047E8(float, float) __asm__("FUN_001fa5c8");
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_0013E633_3047E8[] __asm__("D_0013F420");
-extern Moby *D_001413D0_3047E8 __asm__("D_001413D0") __attribute__((section(".data")));
+extern char D_0013F420[];
+extern int D_001413D0[] __attribute__((section(".data")));
void FUN_L05_00303390(Moby *m) {
Vec_3047E8 v0;
@@ -1593,7 +1619,7 @@ void FUN_L05_00303390(Moby *m) {
v0[2] = v0[2] + 0.5f;
if (r->who != 0) {
if (r->who->oclass == 0x47) {
- qcopy(v10, D_0013E633_3047E8);
+ qcopy(v10, D_0013F420);
} else if ((*(struct Moby **)&r->who->pclass != 0 && *(short *)((u8 *)((struct Moby *)r->who->pclass) + 0x46) == 5) || r->who->oclass == 0xBA) {
qcopy(v10, v0);
} else {
@@ -1693,13 +1719,13 @@ void FUN_L05_00303390(Moby *m) {
}
}
if (d->target == 0) {
- d->target = D_001413D0_3047E8;
+ d->target = (*(Moby * *)D_001413D0);
}
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 == D_001413D0_3047E8) {
+ if (k >= 4 && d->target == (*(Moby * *)D_001413D0)) {
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);
@@ -1946,350 +1972,315 @@ f32 FUN_L05_00304058(s32 path_index, void *input, void *output, f32 distance) {
qcopy(out, &working);
return best;
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L05_00304320.s", FUN_L05_00304320);
-#else
-extern char D_L05_001671C0[];
-extern char *D_L05_001B0930[];
-extern float D_0013F3D0[4];
-extern int frame_number __asm__("D_L05_0015F5CC");
-extern float distance_2d1688(void *, void *) __asm__("FUN_001f9b48");
-extern float distance_to_2d1688(void *, void *) __asm__("FUN_001f9b80");
-extern float absolute_2d1688(float) __asm__("FUN_001f99c0");
-extern void mark_moby_2d1688(char *) __asm__("FUN_0020c828");
-extern void moby_point_position(void *, int, void *) __asm__("FUN_L00_0024f7c8");
-extern float FUN_001fa5c8(float, float);
-extern float scale_particle_time(float) __asm__("FUN_L05_0022dbc8");
-extern float random_float_between(float, float) __asm__("FUN_002132a8");
-extern int func_001FA898_r(float) __asm__("FUN_001fa6d0");
-extern char *spawn_spark(void *, void *, void *, int, int, int, int, int, int) __asm__("FUN_00218888");
-extern void FUN_L00_0025a120(void *);
-extern void FUN_L01_0026d930(char *);
-extern void FUN_L05_00305178(char *);
-extern void FUN_L05_00305898(char *);
-extern int FUN_L00_00259028(char *, char *, void *, char *);
-extern int point_in_path_xy(void *, void *, int) __asm__("FUN_L00_00259740");
-extern int collision_line_304320(void *, void *, int, void *, int) __asm__("FUN_001efa68");
-extern float smooth_angle_304320(float, float, void *, int) __asm__("FUN_L00_0025bc00");
-extern void rotate_axis_304320(float, void *, int) __asm__("FUN_L00_001fff28");
-extern void attach_manipulator_304320(void *, int, void *) __asm__("FUN_0020cb10");
-extern void clear_vector_305178(void *) __asm__("FUN_001f99f8");
-extern Moby *D_001413D0_3047E8 __asm__("D_001413D0") __attribute__((section(".data")));
-extern float D_L05_00161AF8 __attribute__((sda));
-extern float D_L05_00161AFC __attribute__((sda));
-extern float D_L05_00161B00 __attribute__((sda));
-extern float D_L05_00161B04 __attribute__((sda));
-extern float D_L05_00161B08 __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 float D_L05_00161B70 __attribute__((sda));
-extern int scale_frames_304320(int) __asm__("FUN_L05_0022dbd8");
-extern float D_L05_00161B78 __attribute__((sda));
-extern float D_L05_00161B7C __attribute__((sda));
-void FUN_L05_00304320(char *moby) {
- char *data = *(char **)(moby + 0x78);
- struct Hero *base;
- char *path;
- char *child;
- char *position;
- char *path_position;
- int state;
- int *path_entry;
- int direction;
- int index;
- int last;
- int offset;
- int i;
- int j;
- int n1, n2, n3;
- char *particle;
- float angle;
- float turn;
- float point[4] __attribute__((aligned(16)));
- float v[4] __attribute__((aligned(16)));
- float w[4] __attribute__((aligned(16)));
- float pos[4] __attribute__((aligned(16)));
- void *matrix0;
- void *matrix1;
- void *rotation0;
- void *rotation1;
- FUN_L05_00305178(moby);
- FUN_L05_00305898(moby);
- if ((*(unsigned char *)((char *)(data)+(0x2e))) == 2) {
- if (*(char **)(data+0x184)) mark_moby_2d1688(*(char **)(data+0x184));
- if (*(char **)(data+0x188)) mark_moby_2d1688(*(char **)(data+0x188));
- mark_moby_2d1688(moby);
+/* Extermitank update: spawns its two parts, follows its path, turns its turret toward the hero and sprays particles while firing. */
+/* Ported from rac1-decomp (src/overlays/l05_rilgar/vendor_002D28D0.c: func_L05_00305778), where it is exact; names translated to the US level program. */
+
+extern char *func_0020D348_m(int);
+extern f32 fast_cos_c5(f32) __asm__("func_001F9DC8");
+extern f32 fast_sin_c7(f32) __asm__("func_001F9DE0");
+extern f32 random_float_between_c4(f32, f32) __asm__("func_002132A8");
+extern float D_0015ED6C_gp __asm__("D_0015ED6C") __attribute__((section(".sdata")));
+extern float FUN_L00_0025bc00(float *, int, float, float);
+extern float fast_add_rotations_c5(float, float) __asm__("func_001FA580");
+extern int frame_number_gp __asm__("D_L05_0015F5CC") __attribute__((section(".sdata")));
+extern int FUN_001efa68(void *, void *, int, void *, void *);
+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 short D_L05_00161B78 __attribute__((sda));
+extern short 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");
+extern void mark_moby_for_removal_c3(void *) __asm__("func_0020C828");
+float absolute_float(float input) __asm__("func_001F99C0");
+void FUN_L05_00305178_c(char *moby) __asm__("FUN_L05_00305178");
+void FUN_L05_00305898_c(char *m) __asm__("FUN_L05_00305898");
+void attach_manipulator(void *owner, s32 slot_index, void *manip) __asm__("FUN_0020cb10");
+extern char D_0013F350[];
+extern float D_0013F3D0[];
+extern char D_0013E533[];
+
+typedef char *(*Spawn_305778)(void *, void *, void *, int, int, long, long, long, int);
+
+void FUN_L05_00304320(unsigned char *m) {
+ char *d = *(char **)(m + 0x78);
+ float v10[4];
+ float v20[4];
+ float v30[4];
+ float v40[4];
+
+ FUN_L05_00305178_c((char *)m);
+ FUN_L05_00305898_c((char *)m);
+ if (*(unsigned char *)(d + 0x2E) == 2) {
+ if (*(char **)(d + 0x184) != 0) mark_moby_for_removal_c3(*(char **)(d + 0x184));
+ if (*(char **)(d + 0x188) != 0) mark_moby_for_removal_c3(*(char **)(d + 0x188));
+ mark_moby_for_removal_c3(m);
return;
}
- if ((*(unsigned char *)((char *)(moby)+(0x31)))) {
- if (distance_2d1688(moby+0x10,D_L05_001671C0) < 27.0f) {
- FUN_L00_0025a120(moby);
- (*(unsigned char *)((char *)(moby)+(0x7f)))=0x15;
+ if (m[0x31] != 0) {
+ if (fast_vec_dist(m + 0x10, D_L05_001671C0) < 27.0f) {
+ FUN_L00_0025a120(m);
+ m[0x7F] = 0x15;
}
}
- state=(*(unsigned char *)((char *)(moby)+(0x20)));
- switch (state) {
- case 0: goto state_zero;
- case 1: goto state_one;
- case 2: goto state_two;
- case 3: goto state_three;
- default: return;
- }
-state_zero:
- position=moby+0x10;
- if (*(char **)(data+0x184)==0) {
- *(char **)(data+0x184)=create_moby(0x368);
- (*(unsigned char *)((char *)(*(char **)(data+0x184))+(0x30)))=0x40;
- (*(unsigned short *)((char *)(*(char **)(data+0x184))+(0x32)))=0x40;
- (*(unsigned char *)((char *)(*(char **)(data+0x184))+(0x31)))=1;
- base=&hero;
- *(unsigned long *)(*(char **)(data+0x184)+0x38)=*(unsigned long *)((char *)*(Moby **)((char *)base+0x2080)+0x38);
- (*(unsigned short *)((char *)(*(char **)(data+0x184))+(0x34)))=0x4000;
- {
- char *child=*(char **)(data+0x184);
- qcopy(child+0x10,position);
- (*(int *)((char *)(child)+(0x94)))=0;
- }
- FUN_L00_00250df8(*(char **)(data+0x184));
- }
- if (*(char **)(data+0x188)==0) {
- *(char **)(data+0x188)=create_moby(0x369);
- (*(unsigned char *)((char *)(*(char **)(data+0x188))+(0x30)))=0x40;
- (*(unsigned short *)((char *)(*(char **)(data+0x188))+(0x32)))=0x40;
- (*(unsigned char *)((char *)(*(char **)(data+0x188))+(0x31)))=1;
- base=&hero;
- *(unsigned long *)(*(char **)(data+0x188)+0x38)=*(unsigned long *)((char *)*(Moby **)((char *)base+0x2080)+0x38);
- (*(unsigned short *)((char *)(*(char **)(data+0x188))+(0x34)))=0x4000;
- {
- char *child=*(char **)(data+0x188);
- qcopy(child+0x10,position);
- (*(int *)((char *)(child)+(0x94)))=0;
- }
- FUN_L00_00250df8(*(char **)(data+0x188));
- }
- attach_manipulator_304320(moby,0,data+0xf0);
- attach_manipulator_304320(moby,1,data+0x130);
- (*(unsigned short *)((char *)(moby)+(0x34)))|=0x1000;
- base=&hero;
- *(unsigned long *)(moby+0x38)=*(unsigned long *)((char *)*(Moby **)((char *)base+0x2080)+0x38);
- FUN_L01_0026d930(data+0x70);
- (*(int *)((char *)(data)+(0x70)))=0x38d;
- (*(float *)((char *)(data)+(0x7c)))=2.0f;
- (*(float *)((char *)(data)+(0x78)))=4.0f;
- (*(float *)((char *)(data)+(0xac)))=0.01f;
- (*(float *)((char *)(data)+(0xb0)))=0.3f;
- (*(float *)((char *)(data)+(0xb4)))=0.1f;
- path=D_L05_001B0930[(*(int *)((char *)(data)+(0xd4)))];
- *(int *)(data+0xc0)=1;
- *(char **)(data+0xd0)=path;
- qcopy(position,path+0x10);
- (*(unsigned char *)((char *)(moby)+(0x20)))=1;
- if ((*(unsigned char *)((char *)(moby)+(0x53)))) blend_moby_animation(moby,0,0,0);
- (*(float *)((char *)(data)+(0x94)))=D_L05_00161AF8*frame_time;
- clear_vector_305178(data+0x40);
- (*(unsigned char *)((char *)(data)+(0x2e)))=1;
- (*(unsigned char *)((char *)(data)+(0x29)))=0;
- (*(unsigned short *)((char *)(data)+(0x24)))=6;
- (*(unsigned char *)((char *)(data)+(0x28)))=3;
- (*(float *)((char *)(data)+(0x20)))=6.0f;
- (*(unsigned short *)((char *)(data)+(0x3e)))|=2;
- (*(int *)((char *)(data)+(0x180)))=scale_frames_304320(60);
- (*(float *)((char *)(data)+(0x198)))=0.0f;
- (*(float *)((char *)(data)+(0x194)))=(*(float *)((char *)(moby)+(0x48)));
- (*(unsigned char *)((char *)(data)+(0x58)))=func_001FA898_r(D_L05_00161B78);
- (*(unsigned char *)((char *)(data)+(0x5a)))=func_001FA898_r(D_L05_00161B7C*8.0f);
- return;
-state_one:
- {
- int count;
- path_entry=(int *)(data+0xc0);
- count=**(int **)((char *)path_entry+0x10);
- direction=*(signed char *)((char *)path_entry+4);
- last=0;
- if (direction>=0) last=count-1;
- index=*path_entry+count;
- index+=direction;
- index%=count;
- path_position=moby+0x10;
- position=path_position;
- offset=index*16;
- offset+=16;
- FUN_L00_00259028(moby,data+0x70,*(char **)((char *)path_entry+0x10)+offset,data+0x40);
- if (distance_to_2d1688(path_position,*(char **)((char *)path_entry+0x10)+offset)<1.0f) {
- if (index==last) {
- path=*(char **)((char *)path_entry+0x10);
- if (distance_2d1688(path+*(int *)path*16,path+16)>5.0f)
- *(signed char *)((char *)path_entry+4)=-*(signed char *)((char *)path_entry+4);
+ switch (m[0x20]) {
+ case 0: {
+ char *c;
+ char *g;
+ if (*(char **)(d + 0x184) == 0) {
+ *(char **)(d + 0x184) = func_0020D348_m(0x368);
+ (*(char **)(d + 0x184))[0x30] = 0x40;
+ *(short *)(*(char **)(d + 0x184) + 0x32) = 0x40;
+ (*(char **)(d + 0x184))[0x31] = 1;
+ {
+ char *g2 = ((char *)&D_0013F350);
+ *(long *)(*(char **)(d + 0x184) + 0x38) = *(long *)(*(char **)(g2 + 0x2080) + 0x38);
}
- *path_entry=index;
- }
- }
- if (distance_to_2d1688(position,hero.motion.pos.f)<(*(float *)((char *)(data)+(0x174))) &&
- absolute_2d1688((*(float *)((char *)(moby)+(0x18)))-hero.motion.pos.f[2])<4.0f &&
- ((*(int *)((char *)(data)+(0x190)))==-1 || point_in_path_xy(hero.motion.pos.f,D_L05_001B0930[(*(int *)((char *)(data)+(0x190)))]+16,*(int *)D_L05_001B0930[(*(int *)((char *)(data)+(0x190)))]))) {
- qcopy(point,position);
- point[2]+=3.0f;
- if (!collision_line_304320(point,(char *)&hero+0xd0,2,moby,0)) {
- if ((*(unsigned char *)((char *)(moby)+(0x53)))) blend_moby_animation(moby,0,0,3);
- (*(unsigned char *)((char *)(moby)+(0x20)))=2;
+ *(short *)(*(char **)(d + 0x184) + 0x34) = 0x4000;
+ c = *(char **)(d + 0x184);
+ qcopy(c + 0x10, m + 0x10);
+ *(int *)(c + 0x94) = 0;
+ FUN_L00_00250df8(*(char **)(d + 0x184));
+ }
+ if (*(char **)(d + 0x188) == 0) {
+ *(char **)(d + 0x188) = func_0020D348_m(0x369);
+ (*(char **)(d + 0x188))[0x30] = 0x40;
+ *(short *)(*(char **)(d + 0x188) + 0x32) = 0x40;
+ (*(char **)(d + 0x188))[0x31] = 1;
+ {
+ char *g2 = ((char *)&D_0013F350);
+ *(long *)(*(char **)(d + 0x188) + 0x38) = *(long *)(*(char **)(g2 + 0x2080) + 0x38);
+ }
+ *(short *)(*(char **)(d + 0x188) + 0x34) = 0x4000;
+ c = *(char **)(d + 0x188);
+ qcopy(c + 0x10, m + 0x10);
+ *(int *)(c + 0x94) = 0;
+ FUN_L00_00250df8(*(char **)(d + 0x188));
+ }
+ attach_manipulator((char *)m, 0, (unsigned char *)(d + 0xF0));
+ attach_manipulator((char *)m, 1, (unsigned char *)(d + 0x130));
+ *(unsigned short *)(m + 0x34) |= 0x1000;
+ g = ((char *)&D_0013F350);
+ *(long *)(m + 0x38) = *(long *)(*(char **)(g + 0x2080) + 0x38);
+ FUN_L01_0026d930(d + 0x70);
+ *(float *)(d + 0x7C) = 2.0f;
+ *(float *)(d + 0x78) = 4.0f;
+ *(int *)(d + 0x70) = 0x38D;
+ *(float *)(d + 0xAC) = 0.01f;
+ *(float *)(d + 0xB0) = 0.3f;
+ *(float *)(d + 0xB4) = 0.1f;
+ *(char **)(d + 0xD0) = D_L05_001B0930[*(int *)(d + 0xD4)];
+ *(int *)(d + 0xC0) = 1;
+ 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;
+ clear_u64_value(d + 0x40);
+ *(unsigned short *)(d + 0x3E) |= 2;
+ d[0x2E] = 1;
+ d[0x29] = 0;
+ *(short *)(d + 0x24) = 6;
+ d[0x28] = 3;
+ *(float *)(d + 0x20) = 6.0f;
+ *(int *)(d + 0x180) = scale_game_frames(0x3C);
+ *(int *)(d + 0x198) = 0;
+ {
+ float t = *(volatile float *)&D_L05_00161B78;
+ *(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);
+ break;
}
- if (distance_to_2d1688(position,hero.motion.pos.f)<16.0f) {
- angle=FUN_001f9e90(hero.motion.pos.f[0]-(*(float *)((char *)(moby)+(0x10))),hero.motion.pos.f[1]-(*(float *)((char *)(moby)+(0x14))));
- smooth_angle_304320(angle,frame_time*1.5707964f,data+0x194,0);
- smooth_angle_304320(0.08726646f,frame_time*1.5707964f,data+0x198,0);
- } else {
- smooth_angle_304320((*(float *)((char *)(moby)+(0x48))),frame_time*1.5707964f,data+0x194,0);
- smooth_angle_304320(0.0f,frame_time*1.5707964f,data+0x198,0);
- }
- child=data+0x100;
- rotate_axis_304320((*(float *)((char *)(data)+(0x198))),data+0x140,1);
- angle=FUN_001fa5c8((*(float *)((char *)(data)+(0x194))),(*(float *)((char *)(moby)+(0x48))));
- rotate_axis_304320(angle,child,2);
- return;
-state_two:
- {
- int count;
- path_entry=(int *)(data+0xc0);
- count=**(int **)((char *)path_entry+0x10);
- direction=*(signed char *)((char *)path_entry+4);
- last=0;
- if (direction>=0) last=count-1;
- index=*path_entry+count;
- index+=direction;
- index%=count;
- path_position=moby+0x10;
- position=path_position;
- offset=index*16;
- offset+=16;
- FUN_L00_00259028(moby,data+0x70,*(char **)((char *)path_entry+0x10)+offset,data+0x40);
- if (distance_to_2d1688(path_position,*(char **)((char *)path_entry+0x10)+offset)<1.0f) {
- if (index==last) {
- path=*(char **)((char *)path_entry+0x10);
- if (distance_2d1688(path+*(int *)path*16,path+16)>5.0f)
- *(signed char *)((char *)path_entry+4)=-*(signed char *)((char *)path_entry+4);
+ case 1: {
+ char *pp = d + 0xC0;
+ char *path = *(char **)(pp + 0x10);
+ int n = *(int *)path;
+ signed char dir = *(signed char *)(pp + 4);
+ int last = 0;
+ int idx;
+ char *h;
+ if (dir >= 0) last = n - 1;
+ idx = (*(int *)(d + 0xC0) + n + dir) % n;
+ FUN_L00_00259028((char *)m, d + 0x70, (float *)(path + (idx * 16 + 0x10)), d + 0x40);
+ if (vector_distance_xy_alt(m + 0x10, *(char **)(pp + 0x10) + (idx * 16 + 0x10)) < 1.0f) {
+ if (idx == last) {
+ char *q = *(char **)(pp + 0x10);
+ if (5.0f < fast_vec_dist(q + *(int *)q * 16, q + 0x10)) {
+ int t = -*(signed char *)(pp + 4);
+ *(signed char *)(pp + 4) = t;
+ }
+ }
+ *(int *)pp = idx;
+ }
+ h = ((char *)&D_0013F350 + 0x80);
+ if (vector_distance_xy_alt(m + 0x10, h) < *(float *)(d + 0x174)) {
+ if (absolute_float(*(float *)(m + 0x18) - *(float *)(h + 8)) < 4.0f) {
+ if (*(int *)(d + 0x190) == -1
+ || FUN_L00_00259740(h, D_L05_001B0930[*(int *)(d + 0x190)] + 0x10,
+ *(int *)D_L05_001B0930[*(int *)(d + 0x190)]) != 0) {
+ qcopy(v10, m + 0x10);
+ v10[2] = v10[2] + 3.0f;
+ if (FUN_001efa68(v10, h + 0x50, 2, m, 0) == 0) {
+ if (m[0x53] != 0) blend_moby_animation(m, 0, 0, 3);
+ m[0x20] = 2;
+ }
+ }
}
- *path_entry=index;
}
+ if (vector_distance_xy_alt(m + 0x10, ((char *)&D_0013F350 + 0x80)) < 16.0f) {
+ char *g = ((char *)&D_0013F350);
+ float a = fast_arc_tan(*(float *)(g + 0x80) - *(float *)(m + 0x10), *(float *)(g + 0x84) - *(float *)(m + 0x14));
+ FUN_L00_0025bc00((float *)(d + 0x194), 0, a, D_0015ED6C_gp * 1.5707964f);
+ FUN_L00_0025bc00((float *)(d + 0x198), 0, 0.08726646f, D_0015ED6C_gp * 1.5707964f);
+ } else {
+ FUN_L00_0025bc00((float *)(d + 0x194), 0, *(float *)(m + 0x48), D_0015ED6C_gp * 1.5707964f);
+ FUN_L00_0025bc00((float *)(d + 0x198), 0, 0.0f, D_0015ED6C_gp * 1.5707964f);
+ }
+ FUN_L00_001fff28(d + 0x140, 1, *(float *)(d + 0x198));
+ FUN_L00_001fff28(d + 0x100, 2, fast_subtract_rotations(*(float *)(d + 0x194), *(float *)(m + 0x48)));
+ break;
}
- {
- int count;
- v[3]=D_L05_00161B30;
- w[3]=D_L05_00161B34;
- moby_point_position(moby,2,point);
- i=0;
- do {
- qcopy(pos,point);
- pos[0]+=random_float_between(-0.065f,0.065f);
- pos[1]+=random_float_between(-0.065f,0.065f);
- pos[2]+=random_float_between(-0.065f,0.065f);
- v[0]=FUN_001f9dc8((*(float *)((char *)(data)+(0x194))))*(D_L05_00161B20*frame_time);
- v[1]=FUN_001f9de0((*(float *)((char *)(data)+(0x194))))*(D_L05_00161B20*frame_time);
- v[2]=0.0f;
- v[2]=random_float_between(D_L05_00161B24*frame_time*0.9f,D_L05_00161B24*frame_time*1.1f);
- turn=random_float_between(-D_L05_00161B38,D_L05_00161B38)*0.017453292f;
- w[0]=FUN_001f9dc8(FUN_001fa580((*(float *)((char *)(data)+(0x194))),turn))*(D_L05_00161B28*frame_time);
- w[1]=FUN_001f9de0(FUN_001fa580((*(float *)((char *)(data)+(0x194))),turn))*(D_L05_00161B28*frame_time);
- w[2]=0.0f;
- w[2]=random_float_between(D_L05_00161B2C*frame_time*0.9f,D_L05_00161B2C*frame_time*1.1f);
- n1=func_001FA898_r(scale_particle_time(random_float_between(D_L05_00161B14,D_L05_00161B14+D_L05_00161B14)));
- n2=func_001FA898_r(scale_particle_time(random_float_between(D_L05_00161B18,D_L05_00161B18*1.2f)));
- n3=func_001FA898_r(scale_particle_time(random_float_between(D_L05_00161B1C,D_L05_00161B1C*1.2f)));
- particle=spawn_spark(pos,v,w,D_L05_00161B0C,D_L05_00161B10,n1,n2,n3,-1);
- count=i+1;
- if (!(frame_number&7) && particle && i==0) {
- count=1;
- j=0;
- if (*(char **)(data+0x1a0)==0) *(char **)(data+0x1a0)=particle;
- else {
- do {
- j++;
- if (j>=8) goto slots_done;
- path_position=data+0x1a0+j*4;
- } while (*(char **)(data+0x1a0+j*4));
- *(char **)path_position=particle;
+ case 2: {
+ char *pp = d + 0xC0;
+ char *path = *(char **)(pp + 0x10);
+ int n = *(int *)path;
+ signed char dir = *(signed char *)(pp + 4);
+ int last = 0;
+ int idx;
+ int i;
+ int k;
+ char *h;
+ if (dir >= 0) last = n - 1;
+ idx = (*(int *)(d + 0xC0) + n + dir) % n;
+ FUN_L00_00259028((char *)m, d + 0x70, (float *)(path + (idx * 16 + 0x10)), d + 0x40);
+ if (vector_distance_xy_alt(m + 0x10, *(char **)(pp + 0x10) + (idx * 16 + 0x10)) < 1.0f) {
+ if (idx == last) {
+ char *q = *(char **)(pp + 0x10);
+ if (5.0f < fast_vec_dist(q + *(int *)q * 16, q + 0x10)) {
+ int t = -*(signed char *)(pp + 4);
+ *(signed char *)(pp + 4) = t;
}
}
-slots_done:
- i=count;
- } while (i<2);
+ *(int *)pp = idx;
+ }
+ v20[3] = *(float *)&D_L05_00161B30;
+ v30[3] = *(float *)&D_L05_00161B34;
+ FUN_L00_0024f7c8(m, 2, v10);
+ for (i = 0; i < 2; i++) {
+ int a, b, e;
+ float ang;
+ char *r;
+ qcopy(v40, v10);
+ 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[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);
+ 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);
+ if ((frame_number_gp & 7) == 0 && r != 0 && i == 0) {
+ int j;
+ for (j = 0; j < 8; j++) {
+ int o = j * 4;
+ char *s = d + 0x1A0;
+ if (*(char **)(s + o) == 0) {
+ *(char **)(s + o) = r;
+ break;
+ }
+ }
+ }
+ }
+ v20[3] = *(float *)&D_L05_00161B60;
+ v30[3] = *(float *)&D_L05_00161B64;
+ for (k = 1; k >= 0; k--) {
+ int a, b, e;
+ float ang;
+ qcopy(v40, v10);
+ 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);
+ 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);
+ 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);
+ }
+ qcopy(v40, m + 0x10);
+ v40[2] = v40[2] + 3.0f;
+ h = ((char *)&D_0013F350 + 0x80);
+ if (*(float *)(d + 0x174) < vector_distance_xy_alt(m + 0x10, h)
+ || 4.0f <= absolute_float(*(float *)(m + 0x18) - *(float *)(h + 8))
+ || (*(int *)(d + 0x190) != -1
+ && FUN_L00_00259740(h, D_L05_001B0930[*(int *)(d + 0x190)] + 0x10,
+ *(int *)D_L05_001B0930[*(int *)(d + 0x190)]) == 0)
+ || FUN_001efa68(v40, D_0013E533 + 0xEED, 2, m, 0) != 0) {
+ if (m[0x53] != 0) blend_moby_animation(m, 0, 0, 3);
+ m[0x20] = 1;
+ }
+ {
+ char *g = ((char *)&D_0013F350);
+ float a = fast_arc_tan(*(float *)(g + 0x80) - *(float *)(m + 0x10), *(float *)(g + 0x84) - *(float *)(m + 0x14));
+ FUN_L00_0025bc00((float *)(d + 0x194), 0, a, D_0015ED6C_gp * 1.5707964f);
+ FUN_L00_0025bc00((float *)(d + 0x198), 0, 0.08726646f, D_0015ED6C_gp * 1.5707964f);
+ }
+ FUN_L00_001fff28(d + 0x140, 1, *(float *)(d + 0x198));
+ FUN_L00_001fff28(d + 0x100, 2, fast_subtract_rotations(*(float *)(d + 0x194), *(float *)(m + 0x48)));
+ break;
+ }
+ case 3:
+ if (*(char **)(d + 0x184) != 0) mark_moby_for_removal_c3(*(char **)(d + 0x184));
+ if (*(char **)(d + 0x188) != 0) mark_moby_for_removal_c3(*(char **)(d + 0x188));
+ mark_moby_for_removal_c3(m);
+ break;
}
- v[3]=D_L05_00161B60;
- w[3]=D_L05_00161B64;
- last=1;
- do {
- qcopy(pos,point);
- pos[0]+=random_float_between(-0.2f,0.2f);
- pos[1]+=random_float_between(-0.2f,0.2f);
- pos[2]+=random_float_between(-0.2f,0.2f);
- last--;
- turn=random_float_between(-D_L05_00161B6C,D_L05_00161B6C)*0.017453292f;
- v[0]=FUN_001f9dc8(FUN_001fa580((*(float *)((char *)(data)+(0x194))),turn))*(D_L05_00161B50*frame_time);
- v[1]=FUN_001f9de0(FUN_001fa580((*(float *)((char *)(data)+(0x194))),turn))*(D_L05_00161B50*frame_time);
- v[2]=0.0f;
- v[2]=random_float_between(D_L05_00161B54*frame_time*0.7f,D_L05_00161B54*frame_time*1.5f);
- turn=random_float_between(-D_L05_00161B68,D_L05_00161B68)*0.017453292f;
- w[0]=FUN_001f9dc8(FUN_001fa580((*(float *)((char *)(data)+(0x194))),turn))*(D_L05_00161B58*frame_time);
- w[1]=FUN_001f9de0(FUN_001fa580((*(float *)((char *)(data)+(0x194))),turn))*(D_L05_00161B58*frame_time);
- w[2]=0.0f;
- w[2]=random_float_between(D_L05_00161B5C*frame_time*0.7f,D_L05_00161B5C*frame_time*1.5f);
- n1=func_001FA898_r(scale_particle_time(random_float_between(D_L05_00161B44,D_L05_00161B44+D_L05_00161B44)));
- n2=func_001FA898_r(scale_particle_time(random_float_between(D_L05_00161B48,D_L05_00161B48*1.2f)));
- n3=func_001FA898_r(scale_particle_time(random_float_between(D_L05_00161B4C,D_L05_00161B4C*1.2f)));
- particle=spawn_spark(pos,v,w,D_L05_00161B3C,D_L05_00161B40,n1,n2,n3,-1);
- } while (last>=0);
- qcopy(pos,position);
- pos[2]+=3.0f;
- if ((*(float *)((char *)(data)+(0x174)))rot.x = 0.0f;
moby->rot.y = 0.0f;
moby->rot.z = FUN_001f9e90(path->points[1].x - path->points[0].x, path->points[1].y - path->points[0].y);
- data->cruise_speed = D_0015ED6C_c * 17.0f + (float)data->racer_index * (D_0015ED6C_c * 1.55f);
- data->launch_speed = D_0015ED6C_c * 24.0f + (float)data->racer_index * (D_0015ED6C_c * 1.55f);
+ data->cruise_speed = D_0015ED6C_gp * 17.0f + (float)data->racer_index * (D_0015ED6C_gp * 1.55f);
+ data->launch_speed = D_0015ED6C_gp * 24.0f + (float)data->racer_index * (D_0015ED6C_gp * 1.55f);
if (D_0013D388[0] == 0) {
float handicap = (float)(D_0015EE38_macro - 4);
@@ -2870,7 +2861,7 @@ void FUN_L05_00307910(Moby *moby) {
FUN_L05_00307570_c((unsigned char *)moby);
FUN_L05_00306d30_c((char *)moby, data->point_index, path_point);
FUN_L00_0025bc98(&moby->rot.z, FUN_001f9e90(path_point[0] - moby->pos.x, path_point[1] - moby->pos.y), &data->yaw_speed, 0,
- frame_scale_sq_macro * 0.035f, frame_scale_sq_macro * 0.3f, D_0015ED6C_c * 6.981317f);
+ frame_scale_sq_macro * 0.035f, frame_scale_sq_macro * 0.3f, D_0015ED6C_gp * 6.981317f);
if (data->pos[2] < path_point[2] - 5.0f) {
data->pos[2] = path_point[2];
}
@@ -2904,16 +2895,16 @@ void FUN_L05_00307910(Moby *moby) {
Hero *hero;
if (ground < data->pos[2]) {
- target = D_0015ED6C_c * 19.0f;
+ target = D_0015ED6C_gp * 19.0f;
}
hero = (Hero *)(((char *)&D_0013F350));
if (hero->unk894 < scale_game_frames_alt(0x2BC)) {
- target += D_0015ED6C_c * 3.0f;
+ target += D_0015ED6C_gp * 3.0f;
}
if (hero->unk7C0[data->racer_index] < hero->unk8C0) {
- target -= D_0015ED6C_c * 1.5f;
+ target -= D_0015ED6C_gp * 1.5f;
} else {
- target += D_0015ED6C_c;
+ target += D_0015ED6C_gp;
}
if (target < data->speed) {
approach_value(&data->speed, target, frame_time_sq_macro * 7.0f);
@@ -2928,7 +2919,7 @@ void FUN_L05_00307910(Moby *moby) {
data->jump_frames = 0;
}
FUN_L00_00263b38(&data->m[3], 3.0f);
- max_turn = D_0015ED6C_c * 2.6179938f;
+ max_turn = D_0015ED6C_gp * 2.6179938f;
turn = data->yaw_speed;
if (max_turn < turn) {
turn = max_turn;
@@ -2951,7 +2942,7 @@ void FUN_L05_00307910(Moby *moby) {
FUN_L00_002628d8((char *)moby, (char *)&data->m[1], 2, frame_scale_sq_macro * 0.015f, frame_scale_sq_macro * 0.3f);
qcopy(((float *)&moby->pos), data->pos);
moby->pos.z += 0.25f;
- data->bob_phase = fast_add_rotations_c3(data->bob_phase, D_0015ED6C_c * 6.108652f);
+ data->bob_phase = fast_add_rotations_c3(data->bob_phase, D_0015ED6C_gp * 6.108652f);
moby->pos.z += fast_sin_c5(data->bob_phase) * 0.08f;
if (data->child != 0) {
Moby *child;
@@ -3056,8 +3047,8 @@ void FUN_L05_0030bf98(char *moby)
break;
}
}
-extern float frame_time_30ca80 __asm__("D_0015ED6C") __attribute__((section(".sdata")));
-extern float frame_time_sq_30ca80 __asm__("D_0015ED70");
+extern float D_0015ED6C_gp __asm__("D_0015ED6C") __attribute__((section(".sdata")));
+extern float D_0015ED70;
extern void enqueue_callback_list_1_30ca80(void (*)(void), void *) __asm__("FUN_001f4600");
extern int scale_game_frames_30ca80(int) __asm__("FUN_001f96f8");
extern float distance_xyz_30ca80(void *, void *) __asm__("FUN_001f9b48");
@@ -3264,7 +3255,7 @@ void FUN_L05_0030ca80(struct Moby *moby) {
}
}
if (d->moving != 0) {
- advance_accelerated_scalar_30ca80(&moby->pos.z, &d->speed, d->lowered_z, move_speed * frame_time_sq_30ca80, move_speed * frame_time_sq_30ca80, move_accel * frame_time_30ca80);
+ advance_accelerated_scalar_30ca80(&moby->pos.z, &d->speed, d->lowered_z, move_speed * D_0015ED70, move_speed * D_0015ED70, move_accel * D_0015ED6C_gp);
update_group_30ca80((char *)moby);
}
moby->command = 1;
@@ -3283,7 +3274,7 @@ void FUN_L05_0030ca80(struct Moby *moby) {
moby->command = 2;
}
if (d->moving != 0) {
- advance_accelerated_scalar_30ca80(&moby->pos.z, &d->speed, d->raised_z, move_speed * frame_time_sq_30ca80, move_speed * frame_time_sq_30ca80, move_accel * frame_time_30ca80);
+ advance_accelerated_scalar_30ca80(&moby->pos.z, &d->speed, d->raised_z, move_speed * D_0015ED70, move_speed * D_0015ED70, move_accel * D_0015ED6C_gp);
update_group_30ca80((char *)moby);
}
if (random_integer_below_30ca80(0xC8) == 0) {
@@ -3341,7 +3332,7 @@ void FUN_L05_0030ca80(struct Moby *moby) {
d->timer = scale_game_frames_30ca80(rise_frames[rise_step]);
}
}
- moby->pos.z += rise_speeds[rise_step] * frame_time_30ca80;
+ moby->pos.z += rise_speeds[rise_step] * D_0015ED6C_gp;
update_group_30ca80((char *)moby);
water = moby->pos.z;
{
diff --git a/src/overlays/l06/gameplay/entities/fred.c b/src/overlays/l06/gameplay/entities/fred.c
index c5b87552de..e8d38475c4 100644
--- a/src/overlays/l06/gameplay/entities/fred.c
+++ b/src/overlays/l06/gameplay/entities/fred.c
@@ -364,7 +364,7 @@ void FUN_L06_002ffc38(int idx) {
}
}
-extern char D_0013F3D0_ffcb0[] __asm__("D_0013F3D0");
+extern char D_0013F3D0[];
extern unsigned char *D_L06_0015FFD8_ffcb0 __asm__("D_L06_0015FFD8");
extern char *D_L06_001600EC_ffcb0 __asm__("D_L06_001600EC");
extern float D_L06_0015F3FC __asm__("D_L06_0015F3FC");
@@ -416,7 +416,7 @@ void FUN_L06_002ffcb0(char *moby) {
if ((data[2] < 0 || (unsigned char)D_L06_0015FFD8_ffcb0[(data[2] << 8) + 0xbc] == 0) && data[8] != -1) {
break;
}
- if (vector_distance_ffcb0(moby + 0x10, D_0013F3D0_ffcb0) < 32.0f) {
+ if (vector_distance_ffcb0(moby + 0x10, D_0013F3D0) < 32.0f) {
moby[0x20] = 2;
data[9] = scale_frames_ffcb0(30);
} else {
@@ -488,7 +488,7 @@ void FUN_L06_002ffcb0(char *moby) {
state = data[3];
state <<= 7;
base = (int)D_L06_001600EC_ffcb0;
- qcopy((void *)(state + base + 0x30), D_0013F3D0_ffcb0);
+ qcopy((void *)(state + base + 0x30), D_0013F3D0);
*(float *)(state + base + 0x38) -= 0.5f;
}
data[3] = -1;
@@ -508,11 +508,11 @@ void FUN_L06_002ffcb0(char *moby) {
qcopy(from, (void *)(state + base + 0x70));
}
from[0] = D_L06_00162050 * 0.017453292f;
- qcopy(rot, D_0013F3D0_ffcb0);
- qcopy(target, D_0013F3D0_ffcb0 + 16);
+ qcopy(rot, D_0013F3D0);
+ qcopy(target, D_0013F3D0 + 16);
/* Retail takes this component from the camera rotation, not the hero position. */
target[1] = from[1];
- normalize_2fd1a0(offset, D_0013F3D0_ffcb0 - 0x80, -2.0f);
+ normalize_2fd1a0(offset, D_0013F3D0 - 0x80, -2.0f);
vec_add_ffcb0(rot, rot, offset);
rot[2] += 0.85f;
lerp_vector_ffcb0(pos, pos, rot, *(float *)(data + 6));
@@ -522,11 +522,11 @@ void FUN_L06_002ffcb0(char *moby) {
}
break;
case 4:
- if (vector_distance_ffcb0(moby + 0x10, D_0013F3D0_ffcb0) < 16.0f) {
+ if (vector_distance_ffcb0(moby + 0x10, D_0013F3D0) < 16.0f) {
state = data[3];
state <<= 7;
base = (int)D_L06_001600EC_ffcb0;
- qcopy((void *)(state + base + 0x30), D_0013F3D0_ffcb0);
+ qcopy((void *)(state + base + 0x30), D_0013F3D0);
*(float *)(state + base + 0x38) -= 0.5f;
data[3] = -1;
moby[0x20] = 5;
@@ -869,7 +869,7 @@ extern void build_spherical_offset_301070(void *, float, float, float) __asm__("
extern float vector_length_xy_301070(void *) __asm__("FUN_001f9b20");
extern void update_joint_animation_301070(float, float, void *, void *, int) __asm__("FUN_L00_002628d8");
-extern char D_L06_00167540_301070[] __asm__("D_L06_00167540");
+extern float D_L06_00167540[];
extern int D_L06_0015F5C4_macro __asm__("D_L06_0015F5C4") __attribute__((section(".sdata")));
extern float D_L06_0015F3FC_macro __asm__("D_L06_0015F3FC") __attribute__((section(".sdata")));
extern s32 D_L06_00179B90[] __asm__("D_L06_00179B90");
@@ -889,7 +889,7 @@ void FUN_L06_00301070(struct Moby *m) {
float rate, head_rate;
int tracking;
FUN_L03_002db480_301070((char *)m);
- if (m->visible != 0 && distance_xyz_301070(((float *)&m->pos), D_L06_00167540_301070) < 24.0f) {
+ if (m->visible != 0 && distance_xyz_301070(((float *)&m->pos), ((char *)D_L06_00167540)) < 24.0f) {
FUN_L00_0025a120_301070(m);
m->shadow_range = 0x13;
}
@@ -2114,7 +2114,7 @@ typedef struct {
extern Cut_304098 *D_L06_001600EC_304098 __asm__("D_L06_001600EC");
extern struct Moby *D_L06_0015FFD8_304098 __asm__("D_L06_0015FFD8");
-extern char D_0013F3D0_304098[] __asm__("D_0013F3D0") __attribute__((section(".data")));
+extern char D_0013F3D0[] __attribute__((section(".data")));
extern float D_L06_0015F3FC __asm__("D_L06_0015F3FC");
typedef struct { char pad0[0x160]; float f160; int pad164; int f168; } Fx_304098;
extern Fx_304098 D_L06_00167400_304098 __asm__("D_L06_00167400") __attribute__((section(".data")));
@@ -2190,7 +2190,7 @@ void FUN_L06_00304098(struct Moby *moby) {
break;
}
case 3:
- if (vector_distance_304098(D_0013F3D0_304098, &moby->pos) < 3.7f) {
+ if (vector_distance_304098(D_0013F3D0, &moby->pos) < 3.7f) {
help_message_available = try_set_help_message_304098(4, 0x1783) != 0;
if ((*(int *)(D_0013A5E0 + 0x2504) & 0x10) && help_message_available) {
allocate_voice_for_target_entry_304098(2, 0, moby);
@@ -2289,7 +2289,7 @@ void FUN_L06_00304098(struct Moby *moby) {
/* Ported from rac1-decomp (src/overlays/l06_blarg/vendor_002FE5D0.c: func_L06_00305BF8), where it is exact; names translated to the US level program. */
-extern void allocate_voice_for_target_entry(int, int, void *) __asm__("FUN_0022da68");
+extern int allocate_voice_for_target_entry(int, int, void *) __asm__("FUN_0022da68");
/* Moves the moby from state 1 to 2 and gives it a voice. */
void FUN_L06_003047b8(char *arg) {
@@ -2350,200 +2350,192 @@ void FUN_L06_00304818(int unused, void *obj) {
} while (i < *(int *)&D_L06_001621B8);
}
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L06_003049f8.s", FUN_L06_003049f8);
-#else
+/* Level 06 update for moby class 1123: waits for its partner, animates four ribbons, then bursts into particles. */
+/* Ported from rac1-decomp (src/overlays/l06_blarg/vendor_002FE5D0.c: func_L06_00305E38), where it is exact; names translated to the US level program. */
-#include "rnc/audio/voice_pool.h"
-extern float D_L06_001621F8_gp __asm__("D_L06_001621F8") __attribute__((sda));
-extern float D_L06_001621FC __attribute__((sda));
+typedef struct {
+ float a[4][30][4];
+ float b[4][30][4];
+ int timer[4];
+ int f10;
+ int f14;
+ int f18;
+} Data_305E38;
+
+extern char D_0013E550[];
+extern float D_L06_00167540[];
+extern float D_0015ED6C;
extern float D_L06_00162200 __attribute__((sda));
-extern float D_L06_00162204 __attribute__((sda));
-extern float D_L06_00162208_gp __asm__("D_L06_00162208") __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 float D_L06_001FE890[];
+extern float FUN_L00_00257c48(float lo, float hi);
+extern float fast_vec_dist(void *, void *);
extern int D_L06_00162234;
extern int D_L06_00162238;
-extern float D_L06_001FE890[];
-extern float D_L06_00167540[];
-extern char *D_L06_0015FFD8_u __asm__("D_L06_0015FFD8");
+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_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 void FUN_001f9ff8(float *, float);
+extern void FUN_L00_00257d78(void *, float, float);
extern void FUN_L06_00217300(void *);
-extern void normalize_vector_3049f8(void *, void *, float) __asm__("FUN_001f9bf8");
-extern int voice_active_3049f8(char *, int) __asm__("FUN_L00_0028d8c0");
-extern int allocate_voice_3049f8(int, int, char *) __asm__("FUN_0022da68");
-extern void release_voice_3049f8(int) __asm__("FUN_0022d798");
-extern void FUN_L06_00305000(char *);
-extern void set_scale_matrix(float *, float) __asm__("FUN_001f9ff8");
-extern void multiply_matrix(void *, void *, void *) __asm__("FUN_001fa378");
+extern void add_vector_xyz_c(void *, void *, void *) __asm__("FUN_001f9a10");
+extern int allocate_voice_for_target_entry(int, int, void *) __asm__("FUN_0022da68");
+extern void enqueue_callback_list_1(int, char *);
extern void euler_rotation_matrix(float *, float *) __asm__("FUN_001fa050");
-extern void FUN_001f9a10(void *, void *, void *);
-extern void random_vector_3049f8(float *, float, float) __asm__("FUN_L00_00257d78");
-extern void scale_vector_3049f8(void *, void *, float) __asm__("FUN_001f9a68");
-extern float distance_3049f8(void *, void *) __asm__("FUN_001f9b48");
-extern void enqueue_callback_3049f8(int, char *) __asm__("FUN_L06_00210fc8");
-extern float random_float_3049f8(float, float) __asm__("FUN_L00_00257c48");
-extern float random_float_between_3049f8(float, float) __asm__("FUN_002132a8");
-extern int random_byte_3049f8(int) __asm__("FUN_00213260");
-extern int fast_tween_color_3049f8(float, int, int) __asm__("FUN_001fa6e0");
-extern int truncate_float_to_s32_3049f8(float) __asm__("FUN_001fa6d0");
-extern int scale_game_frames_3049f8(int) __asm__("FUN_001f96f8");
-extern void spawn_particle_3049f8(float, void *, void *, int, int, int, int) __asm__("FUN_L00_002730e0");
-
-void FUN_L06_003049f8(char *m) {
- char *data = *(char **)(m + 0x78);
- unsigned char state = m[0x20];
- switch (state) {
- case 0: {
- *(float *)(m + 0x2c) = *(float *)(*(char **)(m + 0x24) + 0x24) * D_L06_00162210;
+extern void fast_vec_normalize_c(void *, void *, f32) __asm__("FUN_001f9bf8");
+extern void fast_vec_scale_c(void *, void *, f32) __asm__("func_001F9A68");
+extern void multiply_matrix(void *, void *, void *) __asm__("FUN_001fa378");
+extern void release_voice_slot(s32) __asm__("FUN_0022d798");
+unsigned char *FUN_L00_002730e0(float *pos, void *vel, int color, u8 life, u8 b, int mode, float scale);
+void FUN_L06_00305000_c(char *m) __asm__("FUN_L06_00305000");
+void FUN_L06_00305170_c(char *m) __asm__("FUN_L06_00305170");
+extern int allocate_voice_for_target_entry(int, int, void *) __asm__("FUN_0022da68");
+extern void func_L00_00273F80_r(void *, void *, int, float, int, int, int) __asm__("FUN_L00_002730e0");
+
+void FUN_L06_003049f8(char *moby)
+{
+ Data_305E38 *d = *(Data_305E38 **)(moby + 0x78);
+ union {
+ float tmp[30][4];
+ struct {
+ float a[16];
+ float b[16];
+ float pos[4];
+ float vel[4];
+ } m;
+ } u;
+
+ switch ((unsigned char)moby[0x20]) {
+ case 0:
+ *(float *)(moby + 0x2C) = *(float *)(*(char **)(moby + 0x24) + 0x24) * *(float *)&D_L06_00162210;
D_L06_00162238 = 0x16;
- D_L06_00162234 = 0x2d;
- *(int *)(data + 0xf04) = 0xb;
- *(int *)(data + 0xf08) = 0x17;
- *(int *)(data + 0xf0c) = 0x22;
- *(int *)(data + 0xf00) = 0;
- *(int *)(data + 0xf18) = -1;
- if (*(int *)(data + 0xf10) != -1) {
- m[0x20] = 1;
- *(int *)(m + 0x94) = 0;
- return;
+ D_L06_00162234 = 0x2D;
+ d->timer[1] = 0xB;
+ d->timer[2] = 0x17;
+ d->timer[3] = 0x22;
+ d->timer[0] = 0;
+ d->f18 = -1;
+ if (d->f10 != -1) {
+ moby[0x20] = 1;
+ *(int *)(moby + 0x94) = 0;
+ } else {
+ moby[0x20] = 2;
}
- m[0x20] = 2;
- return;
- }
+ break;
case 1: {
- char *target = D_L06_0015FFD8_u + (*(int *)(data + 0xf10) << 8);
- if (*(short *)(target + 0xa6) == 0x463 && (unsigned char)target[0x20] < 3) return;
- m[0x20] = 2;
- *(int *)(m + 0x94) = *(int *)(*(char **)(m + 0x24) + 0x10);
- return;
+ char *e = D_L06_0015FFD8_301070 + (d->f10 << 8);
+ if (*(short *)(e + 0xA6) == 0x463 && (unsigned char)e[0x20] < 3) {
+ return;
+ }
+ moby[0x20] = 2;
+ *(int *)(moby + 0x94) = *(int *)(*(char **)(moby + 0x24) + 0x10);
+ break;
}
case 2: {
- int *timers;
- float increment;
- float position;
+ float f20;
+ float f21;
+ float v;
int i;
- if (voice_active_3049f8(m, *(int *)(data + 0xf18)) == 0)
- *(int *)(data + 0xf18) = allocate_voice_3049f8(0, 4, m);
- FUN_L06_00305000(m);
- D_L06_001621F8_gp += D_L06_001621FC * frame_time;
- if (D_L06_001621F8_gp > 1.0f) D_L06_001621F8_gp -= 1.0f;
- timers = (int *)(data + 0xf00);
- increment = D_L06_00162204 / 30.0f;
- position = -(D_L06_00162204 * 0.5f);
+ int j;
+ int k;
+ int l;
+
+ if (FUN_L00_0028d8c0(moby, d->f18) == 0) {
+ 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;
+ 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);
for (i = 0; i < 4; i++) {
- if (timers[i] == 0) {
- float scratch[120];
- float *points = (float *)(data + i * 0x1e0);
- float *paths;
- float *p = points;
- float *q = scratch;
- int j;
- int index;
- for (index = 29; index >= 0; index--) {
- float scale;
- FUN_L06_00217300(p);
- p += 4;
- scale = D_L06_00162200 * frame_time;
- *points = position;
- points += 4;
- position += increment;
- random_vector_3049f8(q, 0.0f, scale);
- q += 4;
+ if (d->timer[i] == 0) {
+ for (j = 0; j < 30; j++) {
+ FUN_L06_00217300(d->a[i][j]);
+ d->a[i][j][0] = f20;
+ FUN_L00_00257d78(u.tmp[j], 0.0f, D_L06_00162200 * D_0015ED6C);
+ f20 += f21;
}
- {
- /* The completed countdown is -1: these cursors start at
- * the second and third scratch vectors. */
- float *second, *third;
- index += 2;
- second = scratch + index * 4;
- third = scratch + (index + 1) * 4;
- q = scratch;
- paths = (float *)(data + i * 0x1e0 + 0x790);
- for (j = 27; j >= 0; j--) {
- FUN_001f9a10(paths, q, second);
- q += 4;
- second += 4;
- FUN_001f9a10(paths, paths, third);
- third += 4;
- scale_vector_3049f8(paths, paths, 0.333f);
- paths += 4;
- }
+ for (k = 1; k < 29; k++) {
+ add_vector_xyz_c(d->b[i][k], u.tmp[k - 1], u.tmp[k]);
+ add_vector_xyz_c(d->b[i][k], d->b[i][k], u.tmp[k + 1]);
+ fast_vec_scale_c(d->b[i][k], d->b[i][k], 0.333f);
}
- timers[i] = D_L06_00162234;
+ d->timer[i] = D_L06_00162234;
} else {
- float *points = (float *)(data + i * 0x1e0 + 0x10);
- float *paths = (float *)(data + i * 0x1e0 + 0x790);
- int j;
- for (j = 27; j >= 0; j--) {
- FUN_001f9a10(points, points, paths);
- points += 4;
- paths += 4;
+ for (l = 1; l < 29; l++) {
+ add_vector_xyz_c(d->a[i][l], d->a[i][l], d->b[i][l]);
}
- timers[i]--;
+ d->timer[i]--;
}
}
- if (distance_3049f8(m + 0x10, D_L06_00167540) < 48.0f)
- enqueue_callback_3049f8(0x305170, m);
- if (*(int *)(data + 0xf14) < 0) return;
- if ((unsigned char)D_L06_0015FFD8_u[(*(int *)(data + 0xf14) << 8) + 0xbc] == 0) return;
- *(int *)(m + 0x94) = 0;
- m[0x20] = 3;
- {
- int index = *(int *)(data + 0xf18);
- if (index != -1 && ((VoicePoolWindow *)((char *)&voice_pool + index * 0x70))->voice.owner == (VoiceMoby *)m &&
- ((VoicePoolWindow *)((char *)&voice_pool + index * 0x70))->voice.state != 0)
- release_voice_3049f8(index);
+ if (fast_vec_dist(moby + 0x10, ((char *)D_L06_00167540)) < 48.0f) {
+ enqueue_callback_list_1((int)FUN_L06_00305170_c, moby);
}
- *(int *)(data + 0xf18) = -1;
- allocate_voice_3049f8(1, 0, m);
- return;
+ if (d->f14 >= 0 && *(unsigned char *)(D_L06_0015FFD8_301070 + 0xBC + (d->f14 << 8)) != 0) {
+ int h;
+ *(int *)(moby + 0x94) = 0;
+ moby[0x20] = 3;
+ h = d->f18;
+ if (h != -1) {
+ char *e = D_0013E550 + h * 0x70;
+ if (*(char **)(e + 0x88) == moby && *(unsigned char *)(e + 0x74) != 0) {
+ release_voice_slot(h);
+ }
+ }
+ d->f18 = -1;
+ allocate_voice_for_target_entry(1, 0, moby);
+ }
+ break;
}
case 3: {
- float scratch[120];
- float *b, *d, *e;
int i;
- euler_rotation_matrix(scratch, (float *)(m + 0x40));
- b = scratch + 16;
- set_scale_matrix(b, D_L06_00162208_gp);
- multiply_matrix(scratch, scratch, b);
- e = scratch + 36;
- d = scratch + 32;
+ int j;
+
+ euler_rotation_matrix(u.m.a, (float *)(moby + 0x40));
+ FUN_001f9ff8(u.m.b, D_L06_00162208);
+ multiply_matrix(u.m.a, u.m.a, u.m.b);
for (i = 0; i < 4; i++) {
- int j;
- euler_rotation_matrix(b, D_L06_001FE890 + i * 4);
- multiply_matrix(b, scratch, b);
- /* Retail reads this scratch vector before initializing it. */
- FUN_001f9a10(scratch + 28, scratch + 28, m + 0x10);
- scratch[30] += (float)i * 1.7f + 0.6f;
- scratch[31] = 1.0f;
- j = 49;
- do {
- float angle = random_float_3049f8(0.0f, D_L06_00162204 * 0.75f);
- normalize_vector_3049f8(d, scratch + 16, angle);
- FUN_001f9a10(d, d, scratch + 28);
- {
- int v = fast_tween_color_3049f8(random_float_between_3049f8(0.0f, 1.0f), D_L06_00162214, D_L06_00162218);
- float f = random_float_between_3049f8(D_L06_0016221C, D_L06_00162220);
- int n = truncate_float_to_s32_3049f8(random_float_between_3049f8((float)D_L06_00162224, (float)D_L06_00162228));
- random_vector_3049f8(e, D_L06_0016222C * frame_time, D_L06_00162230 * frame_time);
- spawn_particle_3049f8(f, d, e, v, scale_game_frames_3049f8(n) & 0xff, random_byte_3049f8(0xff) & 0xff, 0);
- }
- } while (--j >= 0);
+ euler_rotation_matrix(u.m.b, &D_L06_001FE890[i * 4]);
+ multiply_matrix(u.m.b, u.m.a, u.m.b);
+ add_vector_xyz_c(u.m.b + 12, u.m.b + 12, moby + 0x10);
+ u.m.b[14] += (float)i * 1.7f + 0.6f;
+ u.m.b[15] = 1.0f;
+ for (j = 0; j < 50; j++) {
+ int color;
+ 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));
+ 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);
+ 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);
+ }
}
- m[0x20] = 4;
-
+ moby[0x20] = 4;
break;
}
}
}
-#endif
/* Ported from rac1-decomp (src/overlays/l06_blarg/vendor_002FE5D0.c: func_L06_00306440), where it is exact; names translated to the US level program. */
extern int coll_line_fix(void *, void *, int, int, int) __asm__("FUN_001efa68");
diff --git a/src/overlays/l07/gameplay/entities/taxi_platform.c b/src/overlays/l07/gameplay/entities/taxi_platform.c
index 002348a1b3..cc014801ef 100644
--- a/src/overlays/l07/gameplay/entities/taxi_platform.c
+++ b/src/overlays/l07/gameplay/entities/taxi_platform.c
@@ -153,7 +153,7 @@ void FUN_L07_0030e0e0(char *a, char *b, char *c) {
extern char *D_L07_0015FFE4;
extern int FUN_L07_0030e0e0_c() __asm__("FUN_L07_0030e0e0");
extern s32 truncate_float_to_s32(f32) __asm__("FUN_001fa6d0");
-extern void FUN_L07_0030dcf0(unsigned char *);
+extern void FUN_L07_0030dcf0_u(unsigned char *) __asm__("FUN_L07_0030dcf0");
void enqueue_callback_list_1(s32 arg0, s32 arg1) __asm__("FUN_001f4600");
void delete_moby(struct Obj *obj) __asm__("FUN_0020c828");
extern int func_001FA898_r(float) __asm__("FUN_001fa6d0");
@@ -176,7 +176,7 @@ void FUN_L07_0030e1f8(unsigned char *m) {
delete_moby(m);
return;
}
- enqueue_callback_list_1((void *)FUN_L07_0030dcf0, m);
+ enqueue_callback_list_1((void *)FUN_L07_0030dcf0_u, m);
FUN_L07_0030e0e0_c(*(void **)(D_0013E533 + 0x2E9D), m, d);
for (p = D_L07_0015FFE4; p; p = *(char **)(p + 0x28)) {
FUN_L07_0030e0e0_c(p, m, d);
@@ -371,7 +371,7 @@ extern int FUN_001f9740(int *counter);
extern int FUN_0022da68(int, int, int);
extern int FUN_L07_0030e370_c() __asm__("FUN_L07_0030e370");
extern void FUN_L00_001ff600(float, void *, void *);
-extern void FUN_L07_00311eb8(float, void *, void *, short, void *, short, unsigned int, int);
+extern void FUN_L07_00311eb8_u(float, void *, void *, short, void *, short, unsigned int, int) __asm__("FUN_L07_00311eb8");
int FUN_L07_003122b0(void *mp, char *obj, float *vec) {
unsigned char *moby = mp;
@@ -387,7 +387,7 @@ int FUN_L07_003122b0(void *mp, char *obj, float *vec) {
fast_vec_normalize(B, B, frame_time * 9.0f);
FUN_L07_0030e370_c(A, B, moby);
FUN_0022da68(0, 0, (int)moby);
- FUN_L07_00311eb8(10.0f, moby, obj, 0, A, FUN_001f96f8(0x1E), 0x800060FF, 0);
+ FUN_L07_00311eb8_u(10.0f, moby, obj, 0, A, FUN_001f96f8(0x1E), 0x800060FF, 0);
*(int *)(obj + 0x160) = FUN_001f96f8(9);
if (++*(int *)(obj + 0x164) >= 0x15) {
*(short *)(obj + 0x198) = FUN_001f96f8(0x23);
@@ -405,7 +405,7 @@ extern char *D_L07_001B0530[];
extern float multiply_global_factor_ed64(float) __asm__("FUN_001f96b0");
extern int FUN_L00_0028d8c0(void *, int);
extern int FUN_L01_00277fb8(void *);
-extern s32 allocate_voice_for_target_entry(s32, s32, void *) __asm__("func_0022DA68");
+extern int allocate_voice_for_target_entry(int, int, void *) __asm__("func_0022DA68");
extern s32 scale_game_frames(s32) __asm__("func_001F96F8");
extern int hero_set_state(int, int) __asm__("FUN_L00_002223f8");
extern void FUN_L00_00227638(void);
@@ -565,7 +565,7 @@ extern char *D_L07_001B0530[];
extern float multiply_global_factor_ed64(float) __asm__("FUN_001f96b0");
extern int FUN_L00_0028d8c0(void *, int);
extern int FUN_L01_00277fb8(void *);
-extern s32 allocate_voice_for_target_entry(s32, s32, void *) __asm__("func_0022DA68");
+extern int allocate_voice_for_target_entry(int, int, void *) __asm__("func_0022DA68");
extern s32 scale_game_frames(s32) __asm__("func_001F96F8");
extern unsigned char D_L07_0015FC88[] __attribute__((section(".sdata")));
extern int hero_set_state(int, int) __asm__("FUN_L00_002223f8");
@@ -1782,153 +1782,233 @@ void FUN_L07_0030cf90(struct Moby *moby) {
break;
}
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L07_0030d4d8.s", FUN_L07_0030d4d8);
-#else
#include "qzero.h"
-/* The EE ABI assigns integer and float arguments to separate register banks.
- * Keep each bank in retail order; this placement reproduces effect call setup. */
-extern void FUN_L00_0025e450_l07(struct Moby *, void *, s32, f32, f32, f32, f32, f32, f32, f32, s32, s32, s32, s32, s32, s32, s32, s32) __asm__("FUN_L00_0025e450");
-extern float D_0015ED6C __attribute__((section(".data")));
+
+/* Ported from rac1-decomp (src/overlays/l07_umbris/vendor_002CE470.c: func_L07_0030E8B8), where it is exact; names translated to the US level program. */
+
+char *FUN_L07_0030ba90_c(char *pos, char *vec, int c, short d) __asm__("FUN_L07_0030ba90");
+extern char *FUN_L00_0025a420(void *, int, int);
+extern f32 fast_arc_tan_c(f32, f32) __asm__("func_001F9E90");
+extern f32 fast_subtract_rotations(f32, f32) __asm__("func_001FA5C8");
+extern f32 random_angle_radians_c(void) __asm__("func_00213308");
+extern f32 random_float_between_c(f32, f32) __asm__("func_002132A8");
+extern float D_0015ED6C_gp __asm__("D_0015ED6C") __attribute__((section(".sdata")));
+extern float D_0015ED70 __attribute__((section(".sdata")));
+extern float D_L07_0015F580[] __attribute__((section(".sdata")));
+extern float FUN_L00_0025abf0(void *, void *, void *, float, float);
+extern float fast_add_rotations_c(float, float) __asm__("func_001FA580");
+extern float fast_difference_between_rotations_c(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_L07_0015F5CC __attribute__((section(".sdata")));
-extern float D_L07_0015F580[] __attribute__((section(".data")));
-extern void attach_manipulator(void *, int, void *) __asm__("FUN_0020cb10");
+extern int FUN_L00_00257b90(int, int);
+extern int allocate_voice_for_target_entry(int, int, void *) __asm__("func_0022DA68");
+extern int fun_00213928(void *, void *, void *, int, int *, float *, int, int);
+extern void *FUN_L00_00263fd8(char *, int, float *, void *, int, int, float, float *, float *, float *);
+extern void FUN_L00_001fff28(void *, int, float);
+extern void FUN_L00_0024f7c8(void *, int, void *);
extern void FUN_L00_00257470(void *, int, int);
extern void FUN_L00_0025a120(void *);
-extern void FUN_L00_00263fd8(void *, int, void *, void *, int, int, float, void *, void *, void *);
-extern int FUN_L07_002886d8(void *, void *, float);
-extern void euler_rotation_matrix(void *, void *) __asm__("FUN_001fa050");
-extern void transform_vector(void *, void *, void *) __asm__("FUN_001f9d20");
-extern float FUN_L00_0025abf0(void *, void *, void *, float, float);
-extern float fast_subtract_rotations(float, float) __asm__("FUN_001fa5c8");
-extern void FUN_L00_001fff28(void *, int, float);
+extern void FUN_L00_0025d458(void *, short *);
+extern void FUN_L00_0025d538(void *, void *);
+extern void FUN_L00_0025e450_c(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_L07_002886d8(void *, void *, float);
+extern void clear_u64_value(void *) __asm__("func_001F99F8");
+extern void euler_rotation_matrix(float *, float *) __asm__("FUN_001fa050");
+extern void fast_vec_normalize_c(void *, void *, f32) __asm__("FUN_001f9bf8");
+extern void mark_moby_for_removal_c3(void *) __asm__("func_0020C828");
+extern void transform_vector(void *, void *, void *) __asm__("func_001F9D20");
+void attach_manipulator(void *owner, s32 slot_index, void *manip) __asm__("FUN_0020cb10");
+
+void FUN_L07_0030d4d8(char *m) {
+ char *d;
+ char *s16;
+ char *t;
+ int ia;
+ int r;
-void FUN_L07_0030d4d8(struct Moby *moby) {
- char *data;
- char *src;
- float *health;
- Vec4 offset;
- /* The target helper writes four vectors, a moby pointer and a result kind. */
- float target[18] __attribute__((aligned(16)));
- Vec4 rotation, velocity, position;
- float matrix[16] __attribute__((aligned(16)));
- Vec4 best, point;
- int hit;
- Vec4 *position_ptr;
- int i, frames, delay;
- float angle, turn, best_difference;
- if (moby == 0) return;
- data = moby->pvars;
- if (moby->visible && distance_xyz(&moby->pos, D_L07_00166E40) < 27.0f) {
- FUN_L00_0025a120(moby);
- *((u8 *)moby + 0x7f) = 0x15;
- }
- if (data == 0) return;
- health = (float *)(data + 0x20);
- src = FUN_L00_0025a420(moby, 0x230000, 0);
- switch (FUN_00213928(moby, src, health, 0, &hit, 0, 0, 4)) {
- case 1: case 2: *health = 0.0f; break;
- case 0: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: break;
- }
- if (hit > 1) {
- if (src && *(char **)(src + 0x20) && *(short *)(*(char **)(src + 0x20) + 0xa6) == 0x372) goto animate;
- /* Retail still reads damage at address 0x2c when src is null. */
- if (*health <= *(float *)(src + 0x2c)) {
- void *color;
- void *effect_rotation = &moby->rot;
- void *effect_position = &moby->pos;
- FUN_L00_00257470(moby, 0, -1);
- *(float *)(data + 0x20) = 0.0f;
- clear_u64_value(&offset);
- color = D_L07_0015F580;
- /* clear_u64_value clears all four components to positive zero. */
- FUN_L00_0025e450_l07(moby, &offset, 0, 0.0f, 0.0f, 4.0f, 2.0f, 9.0f, 1.0f, 15.0f, 10, 3, 16, 1, 1, 1, -1, 0);
- FUN_L00_00263fd8(moby, 0x621, effect_position, effect_rotation, 0, 0, 0.0f, color, color, color);
- FUN_L00_00263fd8(moby, 0x622, effect_position, effect_rotation, 0, 0, 0.0f, color, color, color);
- mark_moby_for_removal(moby);
- return;
+ float lim;
+ float tv;
+ float v20[4];
+ float v30[20];
+ float v80[4];
+ float v90[4];
+ float vA0[4];
+ float vB0[16];
+ float vF0[4];
+ float v100[4];
+
+ if (m == 0) {
+ return;
+ }
+ d = *(char **)(m + 0x78);
+ if (((unsigned char *)m)[0x31] != 0) {
+ if (fast_vec_dist(m + 0x10, D_L07_00166E40) < 27.0f) {
+ FUN_L00_0025a120(m);
+ m[0x7F] = 0x15;
}
- *health -= *(float *)(src + 0x2c);
- ((u8 *)data)[0x67] = 0xfa;
- *(short *)(data + 0x26) = scale_game_frames(60);
- FUN_L00_0025d458(moby, (short *)(data + 0x60));
}
-animate:
- moby->hit_slot = 0xff;
- FUN_L00_0025d538(moby, data + 0x60);
- FUN_L07_002886d8(moby, target, 20.0f);
- switch (moby->state) {
+ if (d == 0) {
+ return;
+ }
+ s16 = FUN_L00_0025a420(m, 0x230000, 0);
+ t = d + 0x20;
+ r = fun_00213928(m, s16, t, 0, &ia, 0, 0, 4);
+ switch (r) {
case 0:
- frames = scale_game_frames(*(int *)(data + 0xb0));
- delay = scale_game_frames(random_int_between(0, 10));
- *(int *)(data + 0xb4) = D_L07_0015F5CC + frames + delay;
- attach_manipulator(moby, 0, data + 0x70);
- *(float *)(data + 0xc0) = 0.0f;
- FUN_0022da68(0, 4, (int)moby);
- moby->state = 1;
- *(int *)(data + 0xc4) = 0;
break;
case 1:
- if (*(int *)(data + 0xb4) <= D_L07_0015F5CC) {
- frames = scale_game_frames(180);
- delay = D_L07_0015F5CC + frames;
- *(short *)(data + 0xb8) = 0;
- *(int *)(data + 0xb4) = delay;
- *(float *)(data + 0xbc) = random_angle_radians();
- *(short *)(data + 0xba) = 0;
- moby->state = 2;
- }
+ *(int *)t = 0;
break;
case 2:
- if (FUN_001f9770(data + 0xb8)) {
- *(short *)(data + 0xb8) = scale_game_frames(7);
- if (moby->visible || (vector_distance(&moby->pos, D_L07_00166E40) < 90.0f && (*(u32 *)(data + 0xc4) & 1)) || vector_distance(&moby->pos, D_L07_00166E40) < 40.0f) {
- *(u32 *)(data + 0xc4) ^= 1;
- if (vector_distance(&moby->pos, target) < 20.0f)
- *(float *)(data + 0xbc) = fast_arc_tan(target[0] - moby->pos.x, target[1] - moby->pos.y);
- best_difference = 3.1415927f;
- offset.f[0] = random_float_between(3.0f, 11.0f);
- offset.f[1] = random_float_between(-2.0f, 2.0f);
- /* Retail initializes only w before selecting a point. */
- best.f[3] = -1.0f;
- offset.f[2] = 0.0f;
- for (i = 1; i < 4; i++) {
- moby_point_position(moby, i, &point);
- angle = fast_arc_tan(point.f[0] - moby->pos.x, point.f[1] - moby->pos.y);
- turn = fast_subtract_rotations(*(float *)(data + 0xbc), D_0015ED6C * 17.802359f);
- angle = fast_difference_between_rotations(angle, turn);
- if (angle < best_difference) {
- qcopy(&best, &point);
- best_difference = angle;
- }
+ *(int *)t = 0;
+ break;
+ case 3:
+ break;
+ case 4:
+ break;
+ case 5:
+ break;
+ case 6:
+ break;
+ case 7:
+ break;
+ case 8:
+ break;
+ case 9:
+ break;
+ case 10:
+ break;
+ case 11:
+ break;
+ }
+
+ if (ia >= 2) {
+ char *o;
+ if (s16 == 0) {
+ lim = *(float *)(s16 + 0x2C);
+ } else {
+ o = *(char **)(s16 + 0x20);
+ if (o == 0) {
+ lim = *(float *)(s16 + 0x2C);
+ } else {
+ if (*(short *)(o + 0xA6) == 0x372) {
+ goto eb20;
}
- qcopy(&position, &best);
- qzero(&rotation);
- rotation.f[2] = *(float *)(data + 0xbc);
- euler_rotation_matrix(matrix, &rotation);
- transform_vector(&offset, &offset, matrix);
- normalize_vector_xyz(&velocity, &offset, D_0015ED6C * 7.0f);
- add_vector_xyz(&offset, &offset, &moby->pos);
- position_ptr = &position;
- velocity.f[2] = FUN_L00_0025abf0(position_ptr, &offset, 0, D_0015ED6C * 7.0f, -(frame_time_sq * 9.8f));
- add_vector_xyz(position_ptr, position_ptr, &velocity);
- FUN_L07_0030ba90((char *)position_ptr, (char *)&velocity, (int)moby, *(short *)(data + 0xba));
- *(short *)(data + 0xba) += 1;
+ lim = *(float *)(s16 + 0x2C);
}
}
- if (*(int *)(data + 0xb4) <= D_L07_0015F5CC) {
- frames = scale_game_frames(120);
- *(int *)(data + 0xb4) = D_L07_0015F5CC + frames;
- moby->state = 1;
+ tv = *(float *)t;
+ if (tv <= lim) {
+ FUN_L00_00257470(m, 0, -1);
+ *(float *)t = 0.0f;
+ clear_u64_value(v20);
+ FUN_L00_0025e450_c(m, v20, 0, 0.0f, 0.0f, 10, 3, 16, 4.0f, 2.0f, 9.0f, 1.0f, 1, 15.0f, 1, 1, -1, 0);
+ FUN_L00_00263fd8(m, 0x621, (float *)(m + 0x10), m + 0x40, 0, 0, 0.0f, D_L07_0015F580, D_L07_0015F580, D_L07_0015F580);
+ FUN_L00_00263fd8(m, 0x622, (float *)(m + 0x10), m + 0x40, 0, 0, 0.0f, D_L07_0015F580, D_L07_0015F580, D_L07_0015F580);
+ mark_moby_for_removal_c3(m);
+ return;
}
+ tv -= lim;
+ *(float *)t = tv;
+ *(unsigned char *)(d + 0x67) = 0xFA;
+ *(short *)(d + 0x26) = scale_game_frames(60);
+ FUN_L00_0025d458(m, (short *)(d + 0x60));
+ }
+eb20:
+ ((unsigned char *)m)[0xA4] = 0xFF;
+ FUN_L00_0025d538(m, d + 0x60);
+ FUN_L07_002886d8(m, v30, 20.0f);
+ switch (((unsigned char *)m)[0x20]) {
+ case 0: {
+ int r1 = scale_game_frames(*(int *)(d + 0xB0));
+ int r2;
+ int r3;
+ r2 = FUN_L00_00257b90(0, 10);
+ r3 = scale_game_frames(r2);
+ *(int *)(d + 0xB4) = D_L07_0015F5CC + r1 + r3;
+ attach_manipulator(m, 0, d + 0x70);
+ *(int *)(d + 0xC0) = 0;
+ allocate_voice_for_target_entry(0, 4, (int)m);
+ m[0x20] = 1;
+ *(int *)(d + 0xC4) = 0;
break;
}
- if (moby->state) {
- *(float *)(data + 0xc0) = fast_add_rotations(*(float *)(data + 0xc0), frame_time * 17.802359f);
- FUN_L00_001fff28(data + 0x80, 2, *(float *)(data + 0xc0));
+ case 1: {
+ if (*(int *)(d + 0xB4) <= D_L07_0015F5CC) {
+ int r9 = scale_game_frames(0xB4);
+ *(int *)(d + 0xB4) = D_L07_0015F5CC + r9;
+ *(short *)(d + 0xB8) = 0;
+ *(float *)(d + 0xBC) = random_angle_radians_c();
+ *(short *)(d + 0xBA) = 0;
+ m[0x20] = 2;
+ }
+ break;
+ }
+ case 2: {
+ int i;
+ if (FUN_001f9770(d + 0xB8) != 0) {
+ *(short *)(d + 0xB8) = scale_game_frames(7);
+ if (((unsigned char *)m)[0x31] == 0) {
+ if (!(vector_distance_xy_alt(m + 0x10, D_L07_00166E40) < 90.0f && (*(int *)(d + 0xC4) & 1) != 0)) {
+ if (!(vector_distance_xy_alt(m + 0x10, D_L07_00166E40) < 40.0f)) {
+ goto eeE4;
+ }
+ }
+ }
+ *(int *)(d + 0xC4) ^= 1;
+ if (vector_distance_xy_alt(m + 0x10, v30) < 20.0f) {
+ *(float *)(d + 0xBC) = fast_arc_tan_c(v30[0] - *(float *)(m + 0x10), v30[1] - *(float *)(m + 0x14));
+ }
+ v20[0] = random_float_between_c(3.0f, 11.0f);
+ v20[1] = random_float_between_c(-2.0f, 2.0f);
+ v20[2] = 0.0f;
+ vF0[3] = -1.0f;
+ {
+ float best = 3.1415927f;
+ float h;
+ for (i = 1; i < 4; i++) {
+ float f;
+ float g;
+ FUN_L00_0024f7c8(m, i, v100);
+ f = fast_arc_tan_c(v100[0] - *(float *)(m + 0x10), v100[1] - *(float *)(m + 0x14));
+ g = fast_subtract_rotations(*(float *)(d + 0xBC), D_0015ED6C_gp * 17.80235863f);
+ f = fast_difference_between_rotations_c(f, g);
+ if (f < best) {
+ qcopy(vF0, v100);
+ best = f;
+ }
+ }
+ qcopy(vA0, vF0);
+ }
+ qzero(v80);
+ v80[2] = *(float *)(d + 0xBC);
+ euler_rotation_matrix(vB0, v80);
+ transform_vector(v20, v20, vB0);
+ fast_vec_normalize_c(v90, v20, D_0015ED6C_gp * 7.0f);
+ add_vector_xyz(v20, v20, m + 0x10);
+ v90[2] = FUN_L00_0025abf0(vA0, v20, 0, D_0015ED6C_gp * 7.0f, -(D_0015ED70 * 9.8f));
+ add_vector_xyz(vA0, vA0, v90);
+ FUN_L07_0030ba90_c(vA0, v90, (int)m, *(short *)(d + 0xBA));
+ *(short *)(d + 0xBA) = *(short *)(d + 0xBA) + 1;
+ }
+ eeE4:
+ if (*(int *)(d + 0xB4) <= D_L07_0015F5CC) {
+ int r9 = scale_game_frames(0x78);
+ *(int *)(d + 0xB4) = D_L07_0015F5CC + r9;
+ m[0x20] = 1;
+ }
+ break;
+ }
+ }
+
+ if (((unsigned char *)m)[0x20] != 0) {
+ float f = D_0015ED6C_gp * 17.80235863f;
+ float g = fast_add_rotations_c(*(float *)(d + 0xC0), f);
+ *(float *)(d + 0xC0) = g;
+ FUN_L00_001fff28(d + 0x80, 2, g);
}
}
-#endif
/* Ported from rac1-decomp (src/overlays/l07_umbris/vendor_002CE470.c: func_L07_0030EF90), where it is exact; names translated to the US level program. */
extern s32 scale_game_frames(s32) __asm__("func_001F96F8");
@@ -1963,98 +2043,104 @@ unsigned char *FUN_L07_0030dbb0(int a, void *pos, int b, float f0, float f1, flo
}
return moby;
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L07_0030dcf0.s", FUN_L07_0030dcf0);
-#else
-extern unsigned long long get_effect_texture_l07(int) __asm__("FUN_001f44b8");
-extern float convert_integer_to_float_l07(int) __asm__("FUN_001fa6c0");
-extern float wrap_effect_phase_l07(float, void *) __asm__("FUN_L00_00200228");
-extern float fast_cos_l07(float) __asm__("FUN_001f9dc8");
-extern float fast_sin_l07(float) __asm__("FUN_001f9de0");
-extern void draw_effect_quad_l07(void *, int, int) __asm__("FUN_001f7d30");
+/* Ported from rac1-decomp (src/overlays/l07_umbris/vendor_002CE470.c: func_L07_0030F0D0), where it is exact; names translated to the US level program. */
+
+typedef u32 u128_0F0D0 __attribute__((mode(TI), aligned(16)));
+
+typedef struct { char b[0x90]; } __attribute__((aligned(16))) Pkt_0F0D0;
+
+extern float FUN_L00_00200228(void *, float);
extern int D_L07_0015F5CC;
+extern s64 get_effect_texture(s32) __asm__("func_001F44B8");
+extern void fast_draw_quad_real(void *, int, int) __asm__("func_001F7D30");
void FUN_L07_0030dcf0(unsigned char *moby) {
char packet[0x90] __attribute__((aligned(16)));
char second[0x90] __attribute__((aligned(16)));
char phase_work[0x10] __attribute__((aligned(16)));
+ unsigned int alpha = (unsigned int)moby[0x23] / 5u;
int index = 0;
unsigned int green = 0x80;
float band = 0.0f;
- int alpha = ((unsigned char)(moby[0x23] / 5) << 24) | 0x80;
char *data = *(char **)(moby + 0x78);
- unsigned int green_step = (green / 11) & 0xff;
+ unsigned int green_step = (green / 11) & 0xFF;
float radius_threshold = 0.9f;
float inner_scale = 0.96f;
- *(unsigned long long *)(packet + 0x78) = get_effect_texture_l07(*(int *)(data + 0x18));
- *(unsigned long long *)(packet + 0x80) = 0xff9000000260ULL;
- *(unsigned long long *)(packet + 0x70) = 4;
- *(unsigned long long *)(packet + 0x88) = 0x8000000048ULL;
+ float pi = 3.1415927f;
+ *(long *)(packet + 0x78) = get_effect_texture(*(int *)(data + 0x18));
+ *(long *)(packet + 0x80) = 0xFF9000000260L;
+ *(long *)(packet + 0x70) = 4;
+ *(long *)(packet + 0x88) = 0x8000000048L;
do {
- float radius;
- float side;
- float center;
- float angle;
- float angle_limit = 3.1415927f;
- float inner_radius;
- float width;
- float phase;
- int color = alpha | (green << 8) | (green << 16);
- *(int *)(packet + 0x40) = *(int *)(packet + 0x44) =
- *(int *)(packet + 0x48) = *(int *)(packet + 0x4c) = color;
+ float zero, radius, side, center, angle, inner_radius, width, phase, ft;
+ unsigned int gb = (green << 8) | 0x80;
+ int color = ((alpha & 0xFF) << 24) | gb | (green << 16);
+ *(int *)(packet + 0x4C) = color;
+ *(int *)(packet + 0x48) = color;
+ *(int *)(packet + 0x44) = color;
+ *(int *)(packet + 0x40) = color;
if (*(float *)(data + 8) < radius_threshold)
radius = *(float *)(data + 8) * band;
- else radius = *(float *)(data + 8) - band * radius_threshold;
+ else
+ radius = *(float *)(data + 8) - band * radius_threshold;
side = (1.0f - band * 0.5f) * *(float *)(data + 0x10);
- phase = wrap_effect_phase_l07(convert_integer_to_float_l07(D_L07_0015F5CC) /
- (band * 40.0f + 40.0f), phase_work);
- if ((index & 1) == 0) phase = -phase;
+ ft = convert_integer_to_float(D_L07_0015F5CC);
+ phase = FUN_L00_00200228(phase_work, ft / (band * 40.0f + 40.0f));
+ if ((index & 1) == 0)
+ phase = -phase;
*(float *)(packet + 0x50) = phase;
*(float *)(packet + 0x60) = phase;
- width = convert_integer_to_float_l07((int)(index + 1) > 5 ? 5 : index + 1);
- green = green - green_step;
+ width = convert_integer_to_float((index + 1) < 6 ? index + 1 : 5);
center = *(float *)(moby + 0x10);
- *(float *)(packet + 0x5c) = 0.0f;
- *(float *)(packet + 0x28) = *(float *)(packet + 0x38) = *(float *)(moby + 0x18);
- *(float *)(packet + 0x68) = *(float *)(packet + 0x58) = *(float *)(packet + 0x50) + width;
- *(float *)(packet + 0x34) = *(float *)(packet + 0x14) = *(float *)(moby + 0x14);
- *(float *)(packet + 0x6c) = *(float *)(packet + 0x64) = 1.0f;
+ *(float *)(packet + 0x58) = *(float *)(packet + 0x50) + width;
+ {int iz = 0; zero = *(float *)&iz;}
+ *(float *)(packet + 0x54) = zero;
+ *(float *)(packet + 0x64) = 1.0f;
+ *(float *)(packet + 0x14) = *(float *)(moby + 0x14);
+ *(float *)(packet + 0x18) = side + *(float *)(moby + 0x18);
+ *(float *)(packet + 0x38) = *(float *)(moby + 0x18);
*(float *)(packet + 0x10) = center - radius * (inner_scale - band * 0.03f);
- *(float *)(packet + 0x54) = 0.0f;
- *(float *)(packet + 0x08) = *(float *)(packet + 0x18) = side + *(float *)(moby + 0x18);
+ *(float *)(packet + 0x6C) = 1.0f;
+ *(float *)(packet + 0x34) = *(float *)(packet + 0x14);
*(float *)(packet + 0x30) = center - radius;
- __builtin_memcpy(second, packet, 0x90);
- *(float *)(second + 8) = *(float *)(second + 0x18) = *(float *)(moby + 0x18) - 5.0f;
+ *(float *)(packet + 0x68) = *(float *)(packet + 0x58);
+ *(float *)(packet + 0x5C) = zero;
+ *(float *)(packet + 0x08) = side + *(float *)(moby + 0x18);
+ *(float *)(packet + 0x28) = *(float *)(moby + 0x18);
+ *(Pkt_0F0D0 *)second = *(Pkt_0F0D0 *)packet;
+ *(float *)(second + 0x18) = *(float *)(moby + 0x18) - 5.0f;
+ *(float *)(second + 8) = *(float *)(second + 0x18);
angle = -2.8274336f;
do {
- float x, y;
- *(u128 *)(packet + 0) = *(u128 *)(packet + 0x10);
- *(u128 *)(packet + 0x20) = *(u128 *)(packet + 0x30);
- x = fast_cos_l07(angle);
- inner_radius = radius * (inner_scale - band * 0.03f);
+ float x, y, rr;
+ *(u128_0F0D0 *)(packet + 0) = *(u128_0F0D0 *)(packet + 0x10);
+ *(u128_0F0D0 *)(packet + 0x20) = *(u128_0F0D0 *)(packet + 0x30);
+ x = fast_cos(angle);
+ rr = band * 0.03f;
+ inner_radius = radius * (inner_scale - rr);
*(float *)(packet + 0x10) = *(float *)(moby + 0x10) + inner_radius * x;
- x = fast_cos_l07(angle);
+ x = fast_cos(angle);
*(float *)(packet + 0x30) = *(float *)(moby + 0x10) + radius * x;
- y = fast_sin_l07(angle);
+ y = fast_sin(angle);
*(float *)(packet + 0x14) = *(float *)(moby + 0x14) + inner_radius * y;
- y = fast_sin_l07(angle);
+ y = fast_sin(angle);
+ angle = angle + 0.31415927f;
*(float *)(packet + 0x34) = *(float *)(moby + 0x14) + radius * y;
- draw_effect_quad_l07(packet, 0, 1);
- *(u128 *)(second + 0) = *(u128 *)(second + 0x10);
- *(u128 *)(second + 0x20) = *(u128 *)(second + 0x30);
+ fast_draw_quad_real(packet, 0, 1);
+ *(u128_0F0D0 *)(second + 0) = *(u128_0F0D0 *)(second + 0x10);
+ *(u128_0F0D0 *)(second + 0x20) = *(u128_0F0D0 *)(second + 0x30);
*(float *)(second + 0x30) = *(float *)(packet + 0x30);
*(float *)(second + 0x34) = *(float *)(packet + 0x34);
*(float *)(second + 0x10) = *(float *)(packet + 0x10);
*(float *)(second + 0x14) = *(float *)(packet + 0x14);
- draw_effect_quad_l07(second, 0, 1);
- angle = angle + 0.31415927f;
- } while (angle < angle_limit);
+ fast_draw_quad_real(second, 0, 1);
+ } while (angle < pi);
index++;
band = band + 0.1f;
- green &= 0xff;
+ green = green - green_step;
+ green &= 0xFF;
} while (band < 1.0f);
}
-#endif
#define NOT_SDA
@@ -2070,8 +2156,7 @@ extern int FUN_001efa68(void *, void *, int, int, int);
extern int FUN_L00_001f0d60(float, void *, int, void *);
extern int FUN_L00_0025e450();
extern void FUN_L07_0029b8d8(char *, int, float, float);
-s32 allocate_voice_for_target_entry(s32 entry_index, s32 flags,
- void *target) __asm__("FUN_0022da68");
+extern int allocate_voice_for_target_entry(int, int, void *) __asm__("func_0022DA68");
void mark_moby_for_removal(void *obj) __asm__("FUN_0020c828");
extern int func_L00_001F10E0_f(float, void *, int, int) __asm__("FUN_L00_001f0d60");
extern void func_L00_0025F4A8_alt(void *, void *, void *, float, float, int, int, int, float, float,
@@ -3126,77 +3211,76 @@ void FUN_L07_00311bc8(char *m) {
subtract_vector_xyz(v, m + 0x10, prev);
FUN_L00_00260738(d + 0x60, v, m + 0x40, m + 0x40);
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L07_00311eb8.s", FUN_L07_00311eb8);
-#else
-#include "eetypes.h"
-
-extern short FUN_L00_0023e5e0_l07(void *, float, float, int) __asm__("FUN_L00_0023e5e0");
-extern float FUN_001fa6c0_l07(int) __asm__("FUN_001fa6c0");
-
-void FUN_L07_00311eb8(float size, void *moby, void *state, short sequence, void *position,
- short duration, unsigned int color, int next_color) {
- char *s = state;
- char *effect;
- u128 spawn_position;
- unsigned short slot;
- short handle;
- short old_duration;
- int faded_duration;
-
- if (position == 0)
- qcopy(&spawn_position, (char *)moby + 0x10);
- else
- qcopy(&spawn_position, position);
- handle = *(short *)(s + 0x280);
- slot = *(unsigned short *)(s + 0x280);
- if (handle == -1) {
- if (duration > 0) {
- if (size == -1.0f)
- size = 15.0f;
- if ((int)color == -1)
- color = 0x80004080;
- if (next_color == -1)
- next_color = 0;
- handle = FUN_L00_0023e5e0_l07(&spawn_position, size, 0.0f, color);
- *(short *)(s + 0x280) = handle;
- *(short *)(s + 0x284) = 0;
- }
- handle = *(short *)(s + 0x280);
- slot = *(unsigned short *)(s + 0x280);
- if (handle == -1)
- return;
- }
- effect = D_L07_00180340 + ((int)(short)slot << 5);
- if (*(short *)(s + 0x282) != sequence || sequence == -1 ||
- (old_duration = *(short *)(s + 0x284)) == 0) {
- if (duration != -1) {
- *(short *)(s + 0x284) = duration;
- *(short *)(s + 0x286) = duration;
- }
- } else if (duration != -1) {
- faded_duration = (*(short *)(s + 0x286) * 7) / 8;
- if (old_duration <= faded_duration)
- *(short *)(s + 0x284) = faded_duration;
- }
- if (size != -1.0f)
- *(float *)(effect + 0x1c) = size;
- if ((int)color != -1) {
- *(int *)(s + 0x288) = color;
- *(float *)(effect + 0) = FUN_001fa6c0_l07(color & 0xff) * 0.0078125f;
- *(float *)(effect + 4) = FUN_001fa6c0_l07(((int)color >> 8) & 0xff) * 0.0078125f;
- *(float *)(effect + 8) = FUN_001fa6c0_l07(((int)color >> 16) & 0xff) * 0.0078125f;
- }
- if (next_color != -1)
- *(int *)(s + 0x28c) = next_color;
- if (position) {
- effect += 0x10;
- qcopy(effect, position);
- }
- if (sequence != -1)
- *(short *)(s + 0x282) = sequence;
+/* Ported from rac1-decomp (src/overlays/l07_umbris/vendor_002CE470.c: func_L07_00313298), where it is exact; names translated to the US level program. */
+
+extern int FUN_L00_0023e5e0(float *, float, float, int);
+
+void FUN_L07_00311eb8(float radius, void *moby_, void *obj_, short pa, void *pos, short b, unsigned int color, int ca) {
+ char *moby = moby_;
+ char *obj = obj_;
+ float v[4];
+ char *e;
+ int y;
+ if (pos == 0) {
+ qcopy(v, moby + 0x10);
+ } else {
+ qcopy(v, pos);
+ }
+ if (*(short *)(obj + 0x280) == -1) {
+ if (b > 0) {
+ if (radius == -1.0f) {
+ radius = 15.0f;
+ }
+ if ((int)color == -1) {
+ color = 0x80004080U;
+ }
+ if (ca == -1) {
+ ca = 0;
+ }
+ *(short *)(obj + 0x280) = FUN_L00_0023e5e0(v, radius, 0.0f, color);
+ *(short *)(obj + 0x284) = 0;
+ }
+ }
+ if (*(short *)(obj + 0x280) != -1) {
+ e = D_L07_00180340 + (*(short *)(obj + 0x280) << 5);
+ if (*(short *)(obj + 0x282) == pa && (pa == -1 || *(short *)(obj + 0x284) == 0) || *(short *)(obj + 0x282) != pa) {
+ if (b != -1) {
+ *(short *)(obj + 0x284) = b;
+ *(short *)(obj + 0x286) = b;
+ }
+ if (radius != -1.0f) {
+ *(float *)(e + 0x1C) = radius;
+ }
+ } else {
+ if (b != -1) {
+ y = *(short *)(obj + 0x286) * 7 / 8;
+ if (!(y < *(short *)(obj + 0x284))) {
+ *(short *)(obj + 0x284) = y;
+ }
+ if (radius != -1.0f) {
+ *(float *)(e + 0x1C) = radius;
+ }
+ } else if (radius != -1.0f) {
+ *(float *)(e + 0x1C) = radius;
+ }
+ }
+ if ((int)color != -1) {
+ *(int *)(obj + 0x288) = color;
+ *(float *)e = convert_integer_to_float(color & 0xFF) * 0.0078125f;
+ *(float *)(e + 4) = convert_integer_to_float(((int)color >> 8) & 0xFF) * 0.0078125f;
+ *(float *)(e + 8) = convert_integer_to_float(((int)color >> 16) & 0xFF) * 0.0078125f;
+ }
+ if (ca != -1) {
+ *(int *)(obj + 0x28C) = ca;
+ }
+ if (pos != 0) {
+ qcopy(e + 0x10, pos);
+ }
+ if (pa != -1) {
+ *(short *)(obj + 0x282) = pa;
+ }
+ }
}
-#endif
/* Ported from rac1-decomp src/overlays/l07_umbris/vendor_002CE470.c (func_L07_00313800) */
#include "sda.h"
@@ -3230,7 +3314,7 @@ typedef struct Packet_313800 {
long x138;
} Packet_313800;
-extern int D_L07_0015F5CC_c __asm__("D_L07_0015F5CC");
+extern int D_L07_0015F5CC_lui __asm__("D_L07_0015F5CC");
extern s64 get_effect_texture(s32) __asm__("func_001F44B8");
extern void cross_vectors_xyz(void *, void *, void *) __asm__("func_001F9AD8");
extern void draw_geometry_quad(void *, int, int) __asm__("func_001F7D30");
@@ -3258,7 +3342,7 @@ void FUN_L07_00312420(struct Moby *arg)
int k;
Packet_313800 pkt;
- f20 = FUN_001fa6c0_2cd2b0(D_L07_0015F5CC_c);
+ f20 = FUN_001fa6c0_2cd2b0(D_L07_0015F5CC_lui);
qcopy(v50, p->f140);
t = FUN_001f9dc8_2cd2b0(FUN_L00_0025e310_2cd2b0(f20 / 11.0f));
f20 = f20 / 10.0f;
diff --git a/src/overlays/l08/gameplay/entities/bolt_thief.c b/src/overlays/l08/gameplay/entities/bolt_thief.c
index 71a3edf746..156789c318 100644
--- a/src/overlays/l08/gameplay/entities/bolt_thief.c
+++ b/src/overlays/l08/gameplay/entities/bolt_thief.c
@@ -155,7 +155,7 @@ void FUN_L08_002e8788(char *moby) {
/* Re-aims the twelve child mobys of a parent, adjusts the parent's spin, then runs the children's follow-up. */
/* Ported from rac1-decomp (src/overlays/l08_batalia/vendor_002E0258.c: func_L08_002E9F78), where it is exact; names translated to the US level program. */
-extern float D_0015ED6C_d __asm__("D_0015ED6C");
+extern float D_0015ED6C;
extern float fast_add_rotations(float, float) __asm__("FUN_001fa580");
extern void FUN_001f9a10(void *, void *, void *);
extern void FUN_001f9a28(void *, void *, void *);
@@ -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);
+ *(float *)&D_L08_00161D28 * DEG_TO_RAD * D_0015ED6C);
}
for (i = 0; i < 12; i++) {
char *m = *(char **)(base + 0x10 + i * 16);
@@ -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);
+ *(float *)&D_L08_00161D38 * DEG_TO_RAD * D_0015ED6C);
}
p = parts + 0x10;
for (i = 0; i < 16; i++) {
@@ -597,7 +597,7 @@ extern f32 random_float_between_c3(f32, f32) __asm__("func_002132A8");
extern f32 vector_length_xy(void *) __asm__("FUN_001f9b20");
extern f32 vector_length_xyz(void *) __asm__("FUN_001f9af0");
extern float D_0015ED6C;
-extern float D_0015ED70_c __asm__("D_0015ED70");
+extern float D_0015ED70;
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 */
@@ -653,10 +653,10 @@ extern char D_0013A5E0_2E16A0[] __asm__("D_0013CAE4");
extern unsigned char visited52[][16] __asm__("D_0014C050");
extern int invert52 __asm__("D_0015EDDC");
extern char *D_L08_0015FFD8;
-extern int D_0015EE84_2E16A0 __asm__("D_0015ED84");
-extern float D_0015EE60_2E16A0 __asm__("D_0015ED60");
-extern float D_0015EE6C_2E16A0 __asm__("D_0015ED6C");
-extern float D_0015EE70_2E16A0 __asm__("D_0015ED70");
+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");
extern short D_L08_00161B20_2E16A0 __asm__("D_L08_00161A90") __attribute__((sda));
extern short D_L08_00161BA0_2E16A0 __asm__("D_L08_00161B10") __attribute__((sda));
@@ -744,8 +744,8 @@ void FUN_L08_002e0328(Moby *moby) {
func_L08_00307FF0_2E16A0((char *)node, 0);
return;
}
- if (visited52[D_0015EE84_2E16A0][moby->mission] != 0xFF && (hero52.interact & 1)) func_L00_00211908_2E16A0();
- if (((*(int *)D_0013A5E0_2E16A0 & 0x10) || (*(unsigned char *)(D_0014095F) & 1)) && visited52[D_0015EE84_2E16A0][moby->mission] == 0xFF) {
+ if (visited52[D_0015ED84][moby->mission] != 0xFF && (hero52.interact & 1)) func_L00_00211908_2E16A0();
+ if (((*(int *)D_0013A5E0_2E16A0 & 0x10) || (*(unsigned char *)(D_0014095F) & 1)) && visited52[D_0015ED84][moby->mission] == 0xFF) {
hero52.interact = 0;
hero_state52(0, 1);
moby->command = 2; (*(float (*)[4])&moby->rot)[1] = 0.0f;
@@ -779,7 +779,7 @@ void FUN_L08_002e0328(Moby *moby) {
moby->command = 0;
data->exit_timer = func_001F9850_2E16A0(60);
}
- } else if (visited52[D_0015EE84_2E16A0][moby->mission] == 0xFF) {
+ } else if (visited52[D_0015ED84][moby->mission] == 0xFF) {
if (func_001F9D48_2E16A0(position, (*(float (*)[4])&hero52.moby->pos)) < 1.0f && hero52.pos[2] - (*(float (*)[4])&moby->pos)[2] < 7.0f && data->exit_timer == 0 && data->health > 0) {
moby->command = 1;
hero_state52(50, 1);
@@ -800,7 +800,7 @@ void FUN_L08_002e0328(Moby *moby) {
indices = (int *)&data->linked[7]; count = 7;
do { *indices-- = 0; } while (--count >= 0);
data->wave_timer = func_001F9850_2E16A0(180); data->target_timer = 0; data->target_index = 0;
- if (visited52[D_0015EE84_2E16A0][moby->mission] != 0xFF) data->visual_angle = 0.0f;
+ if (visited52[D_0015ED84][moby->mission] != 0xFF) data->visual_angle = 0.0f;
else data->visual_angle = 1.5707964f;
break;
}
@@ -810,14 +810,14 @@ void FUN_L08_002e0328(Moby *moby) {
work[1] = invert52 ? hero52.input[1] : -hero52.input[1];
magnitude = func_001F9CE8_2E16A0(work);
if (magnitude > 1.0f) func_L00_001FF328_2E16A0(work, work, magnitude);
- yaw = D_L08_00161AE8_gp * 0.017453292f * D_0015EE6C_2E16A0 * -work[0];
- pitch = -(D_L08_00161AEC_gp * 0.017453292f * D_0015EE6C_2E16A0) * work[1];
+ yaw = D_L08_00161AE8_gp * 0.017453292f * D_0015ED6C * -work[0];
+ pitch = -(D_L08_00161AEC_gp * 0.017453292f * D_0015ED6C) * work[1];
if ((data->yaw_step >= 0.0f && data->yaw_step < yaw) || (data->yaw_step <= 0.0f && yaw < data->yaw_step))
- func_00214D28_2E16A0(&data->yaw_step, yaw, D_L08_00161AF0_gp * 0.017453292f * D_0015EE70_2E16A0);
- else func_00214D28_2E16A0(&data->yaw_step, yaw, D_L08_00161AF8_gp * 0.017453292f * D_0015EE70_2E16A0);
+ func_00214D28_2E16A0(&data->yaw_step, yaw, D_L08_00161AF0_gp * 0.017453292f * D_0015ED70);
+ else func_00214D28_2E16A0(&data->yaw_step, yaw, D_L08_00161AF8_gp * 0.017453292f * D_0015ED70);
if ((data->pitch_step >= 0.0f && data->pitch_step < pitch) || (data->pitch_step <= 0.0f && pitch < data->pitch_step))
- func_00214D28_2E16A0(&data->pitch_step, pitch, D_L08_00161AF4_gp * 0.017453292f * D_0015EE70_2E16A0);
- else func_00214D28_2E16A0(&data->pitch_step, pitch, D_L08_00161AFC_gp * 0.017453292f * D_0015EE70_2E16A0);
+ func_00214D28_2E16A0(&data->pitch_step, pitch, D_L08_00161AF4_gp * 0.017453292f * D_0015ED70);
+ else func_00214D28_2E16A0(&data->pitch_step, pitch, D_L08_00161AFC_gp * 0.017453292f * D_0015ED70);
(*(float (*)[4])&moby->rot)[2] = func_001FA748_2E16A0((*(float (*)[4])&moby->rot)[2], data->yaw_step);
(*(float (*)[4])&moby->rot)[1] = func_001FA748_2E16A0((*(float (*)[4])&moby->rot)[1], data->pitch_step);
if ((*(float (*)[4])&moby->rot)[1] < -0.7853982f) (*(float (*)[4])&moby->rot)[1] = -0.7853982f;
@@ -830,7 +830,7 @@ void FUN_L08_002e0328(Moby *moby) {
if ((*(int *)D_0013CAE0 & 0x20) && data->fire_timer == 0) {
if (data->barrel == 1) {
int count;
- func_00215C00_2E16A0(direction, D_L08_00161B00_gp * D_0015EE6C_2E16A0, (*(float (*)[4])&moby->rot)[2], -(*(float (*)[4])&moby->rot)[1]);
+ func_00215C00_2E16A0(direction, D_L08_00161B00_gp * D_0015ED6C, (*(float (*)[4])&moby->rot)[2], -(*(float (*)[4])&moby->rot)[1]);
func_00213DE0_2E16A0(data->guns[0], 1, 0, 0);
func_001F9EC0_2E16A0(muzzle, &D_L08_00161BC0_2E16A0, (*(float (*)[16])&moby->rot_row0));
fast_vec_add(muzzle, (*(float (*)[4])&moby->pos), muzzle);
@@ -848,18 +848,18 @@ 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_0015EE60_2E16A0 * -0.35000002f + 1.0f));
+ fast_vec_normalize(scatter, scatter, fast_vec_length(direction) * (D_0015ED60 * -0.35000002f + 1.0f));
fast_vec_add(scatter, direction, scatter);
- fast_vec_normalize(scatter, scatter, func_002140F8_2E16A0(D_0015EE6C_2E16A0 * 3.0f, D_0015EE6C_2E16A0 * 6.0f));
+ fast_vec_normalize(scatter, scatter, func_002140F8_2E16A0(D_0015ED6C * 3.0f, D_0015ED6C * 6.0f));
min_life = func_001F9850_2E16A0(5);
func_L00_0026EBC0_2E16A0((char *)muzzle, (char *)scatter, 0x5F2F4F6F, func_L00_00258BC8_2E16A0(min_life, func_001F9850_2E16A0(10)), 50000.0f);
} while (--count >= 0);
- fast_vec_normalize(direction, direction, D_0015EE6C_2E16A0 * 0.5f);
+ fast_vec_normalize(direction, direction, D_0015ED6C * 0.5f);
min_life = func_001F9850_2E16A0(4);
func_L00_0026EBC0_2E16A0((char *)muzzle, (char *)direction, 0x2F4F7F7F, func_L00_00258BC8_2E16A0(min_life,func_001F9850_2E16A0(7)),500000.0f);
} else {
int count;
- func_00215C00_2E16A0(direction, D_L08_00161B00_gp * D_0015EE6C_2E16A0, (*(float (*)[4])&moby->rot)[2], -(*(float (*)[4])&moby->rot)[1]);
+ func_00215C00_2E16A0(direction, D_L08_00161B00_gp * D_0015ED6C, (*(float (*)[4])&moby->rot)[2], -(*(float (*)[4])&moby->rot)[1]);
func_00213DE0_2E16A0(data->guns[1], 1, 0, 0);
func_001F9EC0_2E16A0(muzzle, &D_L08_00161BD0_2E16A0, (*(float (*)[16])&moby->rot_row0));
fast_vec_add(muzzle, (*(float (*)[4])&moby->pos), muzzle);
@@ -877,13 +877,13 @@ 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_0015EE60_2E16A0 * -0.35000002f + 1.0f));
+ fast_vec_normalize(scatter, scatter, fast_vec_length(direction) * (D_0015ED60 * -0.35000002f + 1.0f));
fast_vec_add(scatter, direction, scatter);
- fast_vec_normalize(scatter, scatter, func_002140F8_2E16A0(D_0015EE6C_2E16A0 * 3.0f, D_0015EE6C_2E16A0 * 6.0f));
+ fast_vec_normalize(scatter, scatter, func_002140F8_2E16A0(D_0015ED6C * 3.0f, D_0015ED6C * 6.0f));
min_life = func_001F9850_2E16A0(5);
func_L00_0026EBC0_2E16A0((char *)muzzle, (char *)scatter, 0x5F2F4F6F, func_L00_00258BC8_2E16A0(min_life, func_001F9850_2E16A0(10)), 50000.0f);
} while (--count >= 0);
- fast_vec_normalize(direction, direction, D_0015EE6C_2E16A0 * 0.5f);
+ fast_vec_normalize(direction, direction, D_0015ED6C * 0.5f);
min_life = func_001F9850_2E16A0(4);
func_L00_0026EBC0_2E16A0((char *)muzzle, (char *)direction, 0x2F4F7F7F, func_L00_00258BC8_2E16A0(min_life,func_001F9850_2E16A0(7)),500000.0f);
}
@@ -921,7 +921,7 @@ void FUN_L08_002e0328(Moby *moby) {
case 2: data->range = 15.0f; data->wave_timer = func_001F9850_2E16A0(195); break;
case 3: data->range = 17.5f; data->wave_timer = func_001F9850_2E16A0(150); break;
case 4:
- if (visited52[D_0015EE84_2E16A0][moby->mission] != 0xFF) {
+ if (visited52[D_0015ED84][moby->mission] != 0xFF) {
Moby *node;
(*(float (*)[4])&moby->rot)[1] = 0.0f; moby->command = 2;
func_L00_002EC0C8_2E16A0(0); moby->state = 4;
@@ -1047,7 +1047,7 @@ extern f32 fast_cos(f32) __asm__("func_001F9DC8");
extern f32 fast_sin(f32) __asm__("func_001F9DE0");
extern f32 random_angle_radians_c(void) __asm__("func_00213308");
extern f32 random_float_between_c2(f32, f32) __asm__("func_002132A8");
-extern float D_0015ED6C_c __asm__("D_0015ED6C") __attribute__((section(".sdata")));
+extern float D_0015ED6C_gp __asm__("D_0015ED6C") __attribute__((section(".sdata")));
extern float D_0015ED70 __attribute__((section(".sdata")));
extern float FUN_001f96b0_c(float) __asm__("FUN_001f96b0");
extern int D_L08_00161C00 __attribute__((sda));
@@ -1084,8 +1084,8 @@ void FUN_L08_002e16c0(Moby_2E2A38 *m) {
switch (m->state) {
case 1:
- d->spin_x = random_float_between_c2(-(D_0015ED6C_c * 1.5707964f), D_0015ED6C_c * 1.5707964f);
- d->spin_y = random_float_between_c2(-(D_0015ED6C_c * 1.5707964f), D_0015ED6C_c * 1.5707964f);
+ d->spin_x = random_float_between_c2(-(D_0015ED6C_gp * 1.5707964f), D_0015ED6C_gp * 1.5707964f);
+ d->spin_y = random_float_between_c2(-(D_0015ED6C_gp * 1.5707964f), D_0015ED6C_gp * 1.5707964f);
d->life = (int)random_float_between_c2((float)scale_game_frames_alt(0x5A), (float)scale_game_frames_alt(0x96));
m->state = 2;
case 2:
@@ -1114,7 +1114,7 @@ void FUN_L08_002e16c0(Moby_2E2A38 *m) {
b = FUN_L00_00257b90(lo, scale_game_frames_alt(30));
}
func_L00_0026B890_2E2A38(m->pos, v10, 0x2F3F3F7F, *q, a, b, 0, 0, 400000.0f,
- random_float_between_c2(8.0f, 16.0f) * D_0015ED6C_c);
+ random_float_between_c2(8.0f, 16.0f) * D_0015ED6C_gp);
}
if (m->pos[2] < 15.2f) {
for (i = 0; i < D_L08_00161C00; i++) {
@@ -1125,10 +1125,10 @@ void FUN_L08_002e16c0(Moby_2E2A38 *m) {
qcopy(a40, m->pos);
a40[0] += random_float_between_c2(-3.0f, 3.0f);
a40[1] += random_float_between_c2(-3.0f, 3.0f);
- v10[2] = D_L08_00161C0C * D_0015ED6C_c;
+ v10[2] = D_L08_00161C0C * D_0015ED6C_gp;
v10[0] += fast_cos(ang) * D_L08_00161C14;
v10[1] += fast_sin(ang) * D_L08_00161C14;
- v30[2] = D_L08_00161C10 * D_0015ED6C_c;
+ v30[2] = D_L08_00161C10 * D_0015ED6C_gp;
v30[0] += fast_cos(ang) * D_L08_00161C18;
v30[1] += fast_sin(ang) * D_L08_00161C18;
v10[3] = D_L08_00161C28;
@@ -1275,13 +1275,13 @@ void FUN_L08_002e2078(struct Moby *m) {
}
}
if (v->links[7].part != 0) {
- v->links[7].part->rot.x = fast_add_rotations(v->links[7].part->rot.x, D_L08_00161C3C * DEG_TO_RAD * D_0015ED6C_d);
+ v->links[7].part->rot.x = fast_add_rotations(v->links[7].part->rot.x, D_L08_00161C3C * DEG_TO_RAD * D_0015ED6C);
}
if (v->links[8].part != 0) {
- v->links[8].part->rot.x = fast_add_rotations(v->links[8].part->rot.x, -(D_L08_00161C3C * DEG_TO_RAD * D_0015ED6C_d));
+ v->links[8].part->rot.x = fast_add_rotations(v->links[8].part->rot.x, -(D_L08_00161C3C * DEG_TO_RAD * D_0015ED6C));
}
if (v->links[9].part != 0) {
- v->links[9].part->rot.x = fast_add_rotations(v->links[9].part->rot.x, D_L08_00161C3C * DEG_TO_RAD * D_0015ED6C_d);
+ v->links[9].part->rot.x = fast_add_rotations(v->links[9].part->rot.x, D_L08_00161C3C * DEG_TO_RAD * D_0015ED6C);
}
if (v->links[3].part != 0) {
v->links[3].part->rot.z = FUN_001f9e90(hero.motion.pos.f[0] - v->links[3].part->pos.x, hero.motion.pos.f[1] - v->links[3].part->pos.y);
@@ -1292,102 +1292,79 @@ void FUN_L08_002e2078(struct Moby *m) {
}
}
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L08_002e2250.s", FUN_L08_002e2250);
-#else
-extern int target_board_check_hit(struct Moby *, int, int) __asm__("FUN_L00_0025a420");
-extern void FUN_L00_0025f090(void *, void *, s32, f32, f32);
-extern void FUN_001f9a28(void *, void *, void *);
-extern void normalize_vector_xyz(void *, void *, f32) __asm__("FUN_001f9bf8");
-extern f32 random_float_between(f32, f32) __asm__("FUN_002132a8");
-extern s32 truncate_float_to_s32(f32) __asm__("FUN_001fa6d0");
+/* Selects a damaged child moby, launches it, and advances the parent's state. */
+/* Ported from rac1-decomp (src/overlays/l08_batalia/vendor_002E0258.c: func_L08_002E35C8), where it is exact; names translated to the US level program. */
+
+extern f32 random_float_between_c4(f32, f32) __asm__("func_002132A8");
extern s32 allocate_voice_for_target_entry(s32, s32, struct Moby *) __asm__("FUN_0022da68");
-extern float D_0015ED6C;
+extern s32 truncate_float_to_s32_c4(f32) __asm__("func_001FA6D0");
+extern void *FUN_L00_0025a420(void *, int, int);
+extern void FUN_L00_0025f090_c(void *, void *, int, float, float) __asm__("FUN_L00_0025f090");
+extern void fast_vec_normalize_c(void *, void *, f32) __asm__("FUN_001f9bf8");
+extern void subtract_vector_xyz(void *, void *, void *) __asm__("FUN_001f9a28");
void FUN_L08_002e2250(struct Moby *moby) {
- u8 mark = 0xff;
- int selected = 0;
- TargetBoardVars *vars = (TargetBoardVars *)moby->pvars;
- TargetSlot *slots = vars->slots;
- TargetSlot *slot;
- int i = 0;
- int hits = 0;
- int sound = -1;
- int total;
-
- slot = slots;
- do {
- if (slot->moby != 0) {
- if (target_board_check_hit(slot->moby, 0x10000, 0) != 0) {
- if (i < 7) {
- if (hits < 1) {
- hits = 1;
- sound = 1;
- goto mark_hit;
- }
- } else if (i < 10) {
- if (hits < 2) {
- hits = 2;
- sound = 1;
- goto mark_hit;
- }
- } else if (hits < 4) {
- hits += 4;
- selected = i;
- sound = 2;
- goto mark_hit;
- }
-mark_hit:
- slot->moby->hit_slot = mark;
+ char *data = *(char **)((char *)moby + 0x78);
+ char *entries = data + 0x60;
+ char *p = entries;
+ int i;
+ int score = 0;
+ int state = -1;
+ int chosen = 0;
+ char *base;
+ for (i = 0; i < 34; i++, p += 16) {
+ char *m = *(char **)p;
+ if (m != 0 && FUN_L00_0025a420(m, 0x10000, 0) != 0) {
+ if (i < 7) {
+ if (score <= 0) { score = 1; state = 1; }
+ } else if (i < 10) {
+ if (score < 2) { score = 2; state = 1; }
+ } else {
+ if (score < 4) { score += 4; chosen = i; state = 2; }
}
+ (*(unsigned char **)p)[0xA4] = 0xFF;
}
- i++;
- slot++;
- } while (i < 34);
- vars->points = (u16)vars->points + hits;
- total = vars->points;
- if (total >= 8) {
- vars->points = total - (total / 8) * 8;
- sound = 0;
- if (selected != 0) {
- u8 *vector;
- slots += selected;
- slot = slots;
- vector = slot->moby->pvars;
- FUN_L00_0025f090(moby, &slot->moby->pos, -1, 2.0f, 13.0f);
- FUN_001f9a28(vector, &slot->moby->pos, &vars->slots[selected].anchor->pos);
- normalize_vector_xyz(vector, vector, D_0015ED6C * 10.0f);
- slot->moby->state = 1;
- slot->moby = 0;
+ }
+ *(short *)(data + 0x28C) += score;
+ if (*(short *)(data + 0x28C) >= 8) {
+ state = 0;
+ *(short *)(data + 0x28C) = *(short *)(data + 0x28C) % 8;
+ if (chosen != 0) {
+ int off = chosen * 16;
+ char *entry;
+ char *v;
+ base = entries;
+ entry = base + off;
+ v = *(char **)(*(char **)entry + 0x78);
+ FUN_L00_0025f090_c(moby, *(char **)entry + 0x10, -1, 2.0f, 13.0f);
+ subtract_vector_xyz(v, *(char **)entry + 0x10, *(char **)(data + off + 0x64) + 0x10);
+ fast_vec_normalize_c(v, v, D_0015ED6C * 10.0f);
+ (*(char **)entry)[0x20] = 1;
+ *(char **)entry = 0;
return;
- }
- {
- int start = truncate_float_to_s32(random_float_between(0.0f, 23.0f));
- TargetSlot *base = slots;
- i = 0;
- do {
- int index = (int)((unsigned int)i + (unsigned int)start) % 24 + 10;
- slots = base + index;
- slot = slots;
- i++;
- if (slot->moby != 0) {
- u8 *vector = slot->moby->pvars;
- FUN_L00_0025f090(moby, &slot->moby->pos, -1, 2.0f, 13.0f);
- FUN_001f9a28(vector, &slot->moby->pos, &vars->slots[index].anchor->pos);
- normalize_vector_xyz(vector, vector, D_0015ED6C * 10.0f);
- slot->moby->state = 1;
- slot->moby = 0;
+ } else {
+ int start = truncate_float_to_s32_c4(random_float_between_c4(0.0f, 23.0f));
+ for (i = 0; i < 24; i++) {
+ int off = ((i + start) % 24 + 10) * 16;
+ char *entry;
+ char *v;
+ base = entries;
+ entry = base + off;
+ if (*(char **)entry != 0) {
+ v = *(char **)(*(char **)entry + 0x78);
+ FUN_L00_0025f090_c(moby, *(char **)entry + 0x10, -1, 2.0f, 13.0f);
+ subtract_vector_xyz(v, *(char **)entry + 0x10, *(char **)(data + off + 0x64) + 0x10);
+ fast_vec_normalize_c(v, v, D_0015ED6C * 10.0f);
+ (*(char **)entry)[0x20] = 1;
+ *(char **)entry = 0;
return;
}
- } while (i < 24);
- moby->state = 99;
+ }
+ ((char *)moby)[0x20] = 99;
}
}
-play_sound:
- if (sound >= 0)
- allocate_voice_for_target_entry(sound, 0, moby);
+ if (state >= 0) allocate_voice_for_target_entry(state, 0, moby);
}
-#endif /* NON_MATCHING */
#include "rnc/overlay/swarm_path.h"
/* Gun turret on a gunship: cruises one path firing at its target, or circles a second path firing at random. */
@@ -1430,7 +1407,7 @@ extern void FUN_L00_00258278(struct Moby *, f32, f32 *, f32, f32, f32);
extern float FUN_L00_0025be00(float *, float *, float, float, float, float);
extern void FUN_L00_0025f090(void *, void *, s32, f32, f32);
extern struct Moby *FUN_L08_002de3e0(void *, struct Moby *, void *, f32, f32);
-extern void FUN_L08_002e2250(struct Moby *);
+extern void FUN_L08_002e2250_u(struct Moby *) __asm__("FUN_L08_002e2250");
void FUN_L08_002e24e8(struct Moby *moby) {
GunshipVars *vars = (GunshipVars *)moby->pvars;
@@ -1484,7 +1461,7 @@ void FUN_L08_002e24e8(struct Moby *moby) {
FUN_001f9e90(vars->follow[0].path->points[waypoint].f[0] - moby->pos.x,
vars->follow[0].path->points[waypoint].f[1] - moby->pos.y),
&vars->turn_speed, 0.004f, 0.3f, 0.02f);
- FUN_L08_002e2250(moby);
+ FUN_L08_002e2250_u(moby);
FUN_L08_002e2078(moby);
qcopy(&point, &vars->follow[0].path->points[waypoint]);
if (FUN_001f9b48(&moby->pos, &point) < 0.5f) {
@@ -2046,7 +2023,7 @@ 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 char D_0013F350_3870[] __asm__("D_0013F350");
+extern int D_0013F350;
extern char D_0013F3D0[];
extern char D_0013F490[];
extern float func_001FA850_2E16A0(float, float) __asm__("FUN_001fa688");
@@ -2129,8 +2106,8 @@ void FUN_L08_002e3870(Moby *moby) {
break;
}
}
- if (absolute_float(moby->pos.z - ((Hero *)(((char *)&D_0013F350_3870)))->motion.pos.f[2]) < ((Hero *)(((char *)&D_0013F350_3870)))->reach_distance
- && FUN_001f9b80(&moby->pos, ((Hero *)(((char *)&D_0013F350_3870)))->motion.pos.f) < ((Hero *)(((char *)&D_0013F350_3870)))->reach_height) {
+ 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;
}
@@ -2210,8 +2187,8 @@ void FUN_L08_002e3870(Moby *moby) {
FUN_L00_0025bc00(&vars->f60, goal_yaw, 0.5235988f, 0);
} else {
- float goal_yaw = fast_add_rotations(FUN_001f9e90(((Hero *)(((char *)&D_0013F350_3870)))->motion.pos.f[0] - moby->pos.x,
- ((Hero *)(((char *)&D_0013F350_3870)))->motion.pos.f[1] - moby->pos.y),
+ 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),
1.5707964f);
FUN_L00_0025bc00(&vars->f60, goal_yaw, 0.08726646f, 0);
@@ -2370,10 +2347,10 @@ void FUN_L08_002e3870(Moby *moby) {
mark_moby_for_removal(moby);
return;
}
- if (moby->pos.z < vars->f60 - 4.0f && moby->pos.z < ((Hero *)(((char *)&D_0013F350_3870)))->motion.pos.f[2] - 4.0f) {
+ 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;
- *(u128_4BE8 *)vars->v10 = *(u128_4BE8 *)((char *)&D_0013F350_3870 + 0x90);
+ *(u128_4BE8 *)vars->v10 = *(u128_4BE8 *)((char *)D_0013F350 + 0x90);
vars->timer = scale_game_frames_alt(1);
moby->state = 2;
break;
@@ -2417,8 +2394,8 @@ void FUN_L08_002e3870(Moby *moby) {
moby->state = 5;
vars->timer = frames;
vars->u7C.i = D_L08_00174658_lui;
- if (absolute_float(moby->pos.z - ((Hero *)(((char *)&D_0013F350_3870)))->motion.pos.f[2]) < ((Hero *)(((char *)&D_0013F350_3870)))->reach_distance
- && FUN_001f9b80(&moby->pos, ((Hero *)(((char *)&D_0013F350_3870)))->motion.pos.f) < ((Hero *)(((char *)&D_0013F350_3870)))->reach_height) {
+ 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);
@@ -2440,8 +2417,8 @@ void FUN_L08_002e3870(Moby *moby) {
int frames;
float per_frame;
- if (absolute_float(moby->pos.z - ((Hero *)(((char *)&D_0013F350_3870)))->motion.pos.f[2]) < ((Hero *)(((char *)&D_0013F350_3870)))->reach_distance
- && FUN_001f9b80(&moby->pos, ((Hero *)(((char *)&D_0013F350_3870)))->motion.pos.f) < ((Hero *)(((char *)&D_0013F350_3870)))->reach_height) {
+ 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;
break;
diff --git a/src/overlays/l08/gameplay/entities/bomb.c b/src/overlays/l08/gameplay/entities/bomb.c
index 73a2f8696e..dc65336cfe 100644
--- a/src/overlays/l08/gameplay/entities/bomb.c
+++ b/src/overlays/l08/gameplay/entities/bomb.c
@@ -121,7 +121,7 @@ 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_0013F450_2B94B0[] __asm__("D_0013F350");
+extern char D_0013F350[];
extern s32 D_0013DF38_arr[] __asm__("D_0013DF38");
void FUN_L08_002b82a0(Moby_2B94B0 *m)
@@ -186,12 +186,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_0013F450_2B94B0)->f208C == 15) {
- if (vector_distance(((Hero_2B94B0 *)D_0013F450_2B94B0)->v510, m->pos) < 0.5f) hit = 1;
- if (vector_distance(((Hero_2B94B0 *)D_0013F450_2B94B0)->v520, m->pos) < 0.5f) hit = 1;
- if (vector_distance(((Hero_2B94B0 *)D_0013F450_2B94B0)->v530, m->pos) < 0.5f) hit = 1;
- } else if (vector_distance(m->pos, ((Hero_2B94B0 *)D_0013F450_2B94B0)->pos) < ((Hero_2B94B0 *)D_0013F450_2B94B0)->f2288) {
- if (absolute_float(m->pos[2] - ((Hero_2B94B0 *)D_0013F450_2B94B0)->pos[2]) < ((Hero_2B94B0 *)D_0013F450_2B94B0)->f228C) hit = 1;
+ 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 (hit == 0) break;
if (d->target != 0) d->target->fA = 0;
@@ -249,203 +249,214 @@ char *FUN_L08_002d22e0(int arg, char *pos, char *vec) {
}
return m;
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L08_002d23f0.s", FUN_L08_002d23f0);
-#else
-#include "rnc/overlay/quad.h"
-extern int coll_sphere(float, void *, int, void *) __asm__("FUN_L00_001f0d60");
-extern int FUN_001efa68(void *, void *, int, void *, void *);
-extern void FUN_L00_001f2868(float, void *, int, void *, void *);
-extern int scale_game_frames(int) __asm__("FUN_001f96f8");
-extern int FUN_001f9740(int *) __asm__("FUN_001f9740");
-extern void add_vector_xyz(void *, void *, void *) __asm__("FUN_001f9a10");
-extern void scale_vector_xyz(void *, void *, float) __asm__("FUN_001f9a68");
-extern void fast_vec_cross(void *, void *, void *) __asm__("FUN_001f9ad8");
-extern float vector_length_xyz(void *) __asm__("FUN_001f9af0");
-extern void rotate_vector_2d23f0(void *, void *, void *) __asm__("FUN_L00_001ff660");
-extern int random_integer_below(int) __asm__("FUN_00213260");
-extern float random_float_between(float, float) __asm__("FUN_002132a8");
-extern void FUN_L00_00259fe8(float, void *);
-extern int allocate_voice_for_target_entry(int, int, void *) __asm__("FUN_0022da68");
-extern void FUN_L00_0025d458(void *, void *);
-extern void FUN_L00_0025d538(s32, void *);
-extern void effect_2d23f0(float, float, float, float, float, float, float,
- void *, void *, int, int, int, int, int, int, int, int, int) __asm__("FUN_L00_0025e450");
-extern void FUN_L00_0025f090(void *, void *, int, float, float);
-extern void FUN_L00_00269958(void *, void *, int, int, int, int, int, int);
-extern void mark_moby_for_removal(void *) __asm__("FUN_0020c828");
-extern void FUN_0022da68(void *, void *);
-extern float D_0015ED6C;
-extern float D_0015ED70;
-extern f32 D_L08_00161868_bytes[] __asm__("D_L08_00161868");
-extern int D_L08_00174658;
-extern int D_L08_00174658_data __asm__("D_L08_00174658") __attribute__((section(".data")));
-extern float D_L08_00174660[4];
-extern float D_L08_00174680_vec[4] __asm__("D_L08_00174680");
-extern f32 D_L08_0015F580[];
-extern float D_L08_0016144C;
+/* Bomb (class 248) update: fuse, bounce and blast state machine on the moby's state byte */
+/* Ported from rac1-decomp (src/overlays/l08_batalia/vendor_002B9438.c: func_L08_002D36F8), where it is exact; names translated to the US level program. */
-extern float D_L08_00161860 __attribute__((sda));
+typedef int v128_36F8 __attribute__((mode(TI)));
-void FUN_L08_002d23f0(char *moby) {
- char *data = *(char **)(moby + 0x78);
- char *position;
- char *velocity;
- char *collision_result;
+typedef struct { char b[16]; } blk16;
+
+struct Probe_36F8 { float v[4]; void *moby; int flags; int pad; float f; int st; };
+
+struct Ray_36F8 { float start[4]; float end[4]; struct Probe_36F8 x; };
+
+union Coll_36F8 { struct Ray_36F8 r; struct Probe_36F8 p; };
+
+typedef int OvlQuad_c __attribute__((mode(TI)));
+
+typedef struct {
+ u8 pad0[0x18];
+ s32 moby; /* 0x18: passed to FUN_002141f8 (reads moby+0x34, moby+0x78); 0 when no moby was hit */
+ s32 unk1C; /* 0x1C: > 0 gates copying point and the normal into the hero (shared/ui/help/00226f10.c) */
union {
- struct {
- float from[4];
- struct {
- float position[4];
- float velocity[4];
- char *owner;
- int flags;
- int pad;
- float scale;
- int state;
- } collision;
- } motion;
- struct {
- float vector[4];
- char *owner;
- int flags;
- int pad;
- float scale;
- int other;
- } effect;
- } record;
- float direction[4];
- float impulse[4];
- float particle[4];
- int state;
- int time;
- int index;
-
- if (*(unsigned char *)(moby + 0x20) != 0x37 && coll_sphere(0.5f, position = moby + 0x10, 0x11, moby)) {
- if (D_L08_00174658_data != 0 &&
- (D_L08_00174658_data != *(int *)(data + 0x30) || *(int *)(data + 0x24) != 0)) {
- collision_result = (char *)D_L08_00174660;
- if (!(*(unsigned char *)(moby + 0xbc) & 2)) moby[0x20] = 0x62;
- else moby[0x20] = 0x63;
- qcopy(position, collision_result);
- rotate_vector_2d23f0(data + 0x10, data + 0x10, collision_result + 0x20);
- normalize_vector_xyz(data + 0x10, data + 0x10, D_0015ED6C + D_0015ED6C);
+ OvlQuad_c q;
+ f32 f[4];
+ } point; /* 0x20: f[2] is read as the ground height */
+ u8 pad30[0x10]; /* 0x30: position after push-out (copied into hero.motion.pos) */
+ f32 normal_x; /* 0x40: start of the surface normal; its angle is tested against 50 degrees (0.87266463) */
+ f32 normal_y; /* 0x44: FUN_001f9e90 (atan2) of normal_x, normal_y is stored in the hero */
+ f32 normal_z; /* 0x48: ledge probes compare atan2(normal_z, xy length) with 20 degrees */
+} CollisionHit_2d23f0;
+
+#include "rnc/overlay/collision.h"
+extern CollisionHit D_L08_00174640;
+extern blk16 D_L08_00161868;
+extern float D_0015ED6C __attribute__((section(".sdata")));
+extern float D_0015ED70_gp __asm__("D_0015ED70") __attribute__((section(".sdata")));
+extern f32 fast_vec_length_c(void *) __asm__("func_001F9AF0");
+extern f32 random_float_between_c5(f32, f32) __asm__("func_002132A8");
+extern float fast_add_rotations_c(float, float) __asm__("func_001FA580");
+extern float D_L08_00174660[];
+extern int FUN_001efa68(void *, void *, int, void *, int);
+extern int FUN_L00_001f0d60(float, void *, int, void *);
+extern int FUN_L00_001f2868(void *, float, int, void *, void *);
+extern int allocate_voice_for_target_entry(int, int, void *) __asm__("FUN_0022da68");
+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 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");
+extern void FUN_L00_0025d538_c(void *, void *) __asm__("FUN_L00_0025d538");
+extern void FUN_L00_0025e450_c3(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_0025f090_c(void *, void *, int, float, float) __asm__("FUN_L00_0025f090");
+extern void FUN_L00_00269958_c(void *, void *, int, int, int, int, int, int) __asm__("FUN_L00_00269958");
+extern void cross_vectors_xyz(void *, void *, void *) __asm__("func_001F9AD8");
+extern void fast_vec_normalize_c(void *, void *, f32) __asm__("FUN_001f9bf8");
+extern void fast_vec_scale_c(void *, void *, f32) __asm__("func_001F9A68");
+extern void fast_vec_normalize(void *, void *, float) __asm__("FUN_001f9bf8");
+extern float D_0015ED70_gp __asm__("D_0015ED70") __attribute__((section(".sdata")));
+extern float D_0015ED6C __attribute__((section(".sdata")));
+extern float D_L08_0015F580_macro[] __asm__("D_L08_0015F580") __attribute__((section(".sdata")));
+extern float D_L08_00174660[];
+
+void FUN_L08_002d23f0(char *moby) {
+ union Coll_36F8 c;
+ blk16 t70;
+ float t80[4];
+ float t90[4];
+ char *d;
+ int st;
+ int two;
+ float f20;
+
+ d = *(char **)(moby + 0x78);
+ if (*(unsigned char *)(moby + 0x20) != 0x37) {
+ if (FUN_L00_001f0d60(0.5f, moby + 0x10, 0x11, moby)) {
+ int g = D_L08_001746D8_2B94B0i;
+ if (g != 0 && (g != *(int *)(d + 0x30) || *(int *)(d + 0x24) != 0)) {
+ if (!(*(unsigned char *)(moby + 0xBC) & 2)) *(unsigned char *)(moby + 0x20) = 0x62; else *(unsigned char *)(moby + 0x20) = 0x63;
+ qcopy((moby + 0x10), ((char *)D_L08_00174660));
+ FUN_L00_001ff660_c(d + 0x10, d + 0x10, ((char *)D_L08_00174660) + 0x20);
+ fast_vec_normalize(d + 0x10, d + 0x10, D_0015ED6C + D_0015ED6C);
+ }
}
}
- state = *(unsigned char *)(moby + 0x20);
- switch (state) {
+ st = *(unsigned char *)(moby + 0x20);
+ two = 2;
+ switch (st) {
case 1: {
- position = moby + 0x10;
- velocity = data + 0x10;
- *(float *)(moby + 0x40) = fast_add_rotations(*(float *)(moby + 0x40), vector_length_xyz(velocity) * 0.5f);
- if (*(int *)(data + 0x24) == 0) {
- __builtin_memcpy(direction, D_L08_00161868_bytes, 16);
- *(OvlQuad *)impulse = 0;
- impulse[0] = random_float_between(-1.0f, 1.0f);
- impulse[1] = random_float_between(-1.0f, 1.0f);
- impulse[2] = random_float_between(-1.0f, 1.0f);
- *(volatile OvlQuad *)particle = *(OvlQuad *)impulse;
- normalize_vector_xyz(particle, particle, D_0015ED6C);
- index = ((int *)direction)[random_integer_below(4)];
- time = scale_game_frames(0x2d);
- FUN_L00_00269958(position, particle, index, 0x4fff, time, 0x32, 0x78, 1);
+ float t;
+ t = fast_vec_length_c((d + 0x10));
+ *(float *)(moby + 0x40) = fast_add_rotations_c(*(float *)(moby + 0x40), t * 0.5f);
+ if (*(int *)(d + 0x24) == 0) {
+ float lo = -1.0f;
+ float hi = 1.0f;
+ int *q;
+ t70 = D_L08_00161868;
+ *(v128_36F8 *)t90 = 0;
+ t90[0] = random_float_between_c5(lo, hi);
+ t90[1] = random_float_between_c5(lo, hi);
+ t90[2] = random_float_between_c5(lo, hi);
+ *(v128_36F8 *)t80 = *(v128_36F8 *)t90;
+ fast_vec_normalize(t80, t80, D_0015ED6C);
+ q = (int *)t70.b + random_integer_below_c3(4);
+ FUN_L00_00269958_c((moby + 0x10), t80, *q, 0x4FFF, scale_game_frames_c(0x2D), 0x32, 0x78, 1);
}
- qcopy(record.motion.from, position);
- record.motion.from[2] -= 0.16f;
- add_vector_xyz(position, position, velocity);
- *(float *)(data + 0x18) -= D_0015ED70 * D_L08_00161860;
- *(OvlQuad *)record.motion.collision.position = *(OvlQuad *)position;
- record.motion.collision.position[2] -= 0.16f;
- record.motion.collision.flags = 0x810000;
- record.motion.collision.state = state;
- record.motion.collision.scale = 1.0f;
- record.motion.collision.owner = moby;
- qcopy(record.motion.collision.velocity, velocity);
- if (FUN_001efa68(record.motion.from, &record.motion.collision, 0, moby, 0)) {
- collision_result = (char *)&D_L08_00174658 - 0x18;
- if (*(int *)(collision_result + 0x18) != 0) {
- if (*(int *)(collision_result + 0x18) == *(int *)(data + 0x30) && *(int *)(data + 0x24) == 0) goto finish;
- if (*(unsigned char *)(moby + 0xbc) & 2) moby[0x20] = 0x63;
- else moby[0x20] = 0x62;
- qcopy(position, collision_result + 0x20);
- rotate_vector_2d23f0(velocity, velocity, collision_result + 0x40);
- normalize_vector_xyz(velocity, velocity, D_0015ED6C + D_0015ED6C);
- goto finish;
- } else {
- if (*(int *)(collision_result + 0x1c) <= 0) goto finish;
- if (*(unsigned char *)(moby + 0xbc) & 1) {
+ qcopy(c.r.start, moby + 0x10);
+ 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;
+ qcopy(c.r.end, moby + 0x10);
+ c.r.end[2] -= f20;
+ c.r.x.moby = moby;
+ c.r.x.flags = 0x810000;
+ c.r.x.st = st;
+ c.r.x.f = 1.0f;
+ qcopy(c.r.x.v, d + 0x10);
+ if (FUN_001efa68(c.r.start, c.r.end, 0, moby, 0)) {
+ char *tbl = (char *)&D_L08_00174640;
+ int v = *(int *)(tbl + 0x18);
+ if (v != 0) {
+ if (v != *(int *)(d + 0x30) || *(int *)(d + 0x24) != 0) {
+ if (!(*(unsigned char *)(moby + 0xBC) & 2)) *(unsigned char *)(moby + 0x20) = 0x62; else *(unsigned char *)(moby + 0x20) = 0x63;
+ qcopy((moby + 0x10), ((char *)D_L08_00174660));
+ {
+ char *v = d + 0x10;
+ FUN_L00_001ff660_c(v, v, ((char *)D_L08_00174660) + 0x20);
+ fast_vec_normalize(v, v, D_0015ED6C + D_0015ED6C);
+ }
+ }
+ } else if (*(int *)(tbl + 0x1C) > 0) {
+ if (*(unsigned char *)(moby + 0xBC) & 1) {
+ float k;
allocate_voice_for_target_entry(1, 0, moby);
- qcopy(position, collision_result + 0x20);
- *(float *)(moby + 0x18) += 0.16f;
- rotate_vector_2d23f0(velocity, velocity, collision_result + 0x40);
- fast_vec_cross(impulse, velocity, collision_result + 0x40);
- normalize_vector_xyz(impulse, impulse, random_float_between(-(D_0015ED6C * 1.5f), D_0015ED6C * 1.5f));
- add_vector_xyz(velocity, velocity, impulse);
- scale_vector_xyz(velocity, velocity, 0.4f);
- ++*(int *)(data + 0x24);
- *(int *)(data + 0x20) = scale_game_frames(0xb4);
- if (vector_length_xyz(velocity) < D_0015ED6C) {
- moby[0x20] = 2;
- time = scale_game_frames(0x78);
- *(int *)(data + 0x20) = time;
- *(float *)(data + 0x28) = 254.0f / (float)time;
- clear_u64_value(velocity);
+ qcopy((moby + 0x10), tbl + 0x20);
+ *(float *)(moby + 0x18) += f20;
+ FUN_L00_001ff660_c((d + 0x10), (d + 0x10), tbl + 0x40);
+ cross_vectors_xyz(&t70, (d + 0x10), tbl + 0x40);
+ k = D_0015ED6C * 1.5f;
+ fast_vec_normalize(&t70, &t70, random_float_between_c5(-k, k));
+ add_vector_xyz((d + 0x10), (d + 0x10), &t70);
+ fast_vec_scale_c((d + 0x10), (d + 0x10), 0.4f);
+ *(int *)(d + 0x24) += 1;
+ *(int *)(d + 0x20) = scale_game_frames_c(0xB4);
+ if (fast_vec_length_c((d + 0x10)) < D_0015ED6C) {
+ int r;
+ *(unsigned char *)(moby + 0x20) = two;
+ r = scale_game_frames_c(0x78);
+ *(int *)(d + 0x20) = r;
+ *(float *)(d + 0x28) = 254.0f / (float)r;
+ clear_u64_value((d + 0x10));
}
- goto finish;
+ } else {
+ *(unsigned char *)(moby + 0x20) = 0x62;
+ qcopy((moby + 0x10), tbl + 0x20);
+ FUN_L00_001ff660_c((d + 0x10), (d + 0x10), tbl + 0x40);
+ fast_vec_normalize((d + 0x10), (d + 0x10), D_0015ED6C + D_0015ED6C);
}
- moby[0x20] = 0x62;
}
- qcopy(position, collision_result + 0x20);
- rotate_vector_2d23f0(velocity, velocity, collision_result + 0x40);
- normalize_vector_xyz(velocity, velocity, D_0015ED6C + D_0015ED6C);
- } else if (FUN_001f9740((int *)(data + 0x20))) {
- if (*(unsigned char *)(moby + 0xbc) & 2) moby[0x20] = 0x63;
- else moby[0x20] = 0x62;
+ } else if (tick_countdown_32_alt(d + 0x20)) {
+ if (*(unsigned char *)(moby + 0xBC) & 2) {
+ *(unsigned char *)(moby + 0x20) = 0x63;
+ } else {
+ *(unsigned char *)(moby + 0x20) = 0x62;
+ }
}
- } break;
- case 2: {
- if (FUN_001f9740((int *)(data + 0x20))) {
- moby[0x20] = 0x63;
- } else if (*(int *)(data + 0x20) == scale_game_frames(0x3c) ||
- *(int *)(data + 0x20) == scale_game_frames(0x28) ||
- *(int *)(data + 0x20) == scale_game_frames(0x14)) {
- *(unsigned char *)(data + 7) = 0xfa;
- FUN_L00_0025d458(moby, data);
+ break;
+ }
+ case 2:
+ if (tick_countdown_32_alt(d + 0x20)) {
+ *(unsigned char *)(moby + 0x20) = 0x63;
+ } else if (*(int *)(d + 0x20) == scale_game_frames_c(0x3C)
+ || *(int *)(d + 0x20) == scale_game_frames_c(0x28)
+ || *(int *)(d + 0x20) == scale_game_frames_c(0x14)) {
+ *(unsigned char *)(d + 7) = 0xFA;
+ FUN_L00_0025d458_c(moby, (short *)d);
}
- FUN_L00_0025d538((s32)moby, data);
- } break;
- case 0x62: {
+ FUN_L00_0025d538_c(moby, d);
+ break;
+ case 0x62:
allocate_voice_for_target_entry(0, 0, moby);
- record.effect.owner = moby;
- record.effect.flags = 0x810001;
- record.effect.scale = 1.0f;
- clear_u64_value(&record.effect.vector);
- record.effect.other = 0;
- FUN_L00_001f2868(1.0f, moby + 0x10, 0x10, moby, &record.effect);
- effect_2d23f0(0.0f, 0.0f, 3.0f, 1.7f, 4.0f, 1.0f, 7.0f,
- moby, D_L08_0015F580, 0, 7, 10, 0x14, -1, 0, 7, -1, 0);
+ c.p.moby = moby;
+ c.p.flags = 0x810001;
+ c.p.f = 1.0f;
+ clear_u64_value(&c.p);
+ c.p.st = 0;
+ FUN_L00_001f2868(moby + 0x10, 1.0f, 0x10, moby, &c.p);
+ FUN_L00_0025e450_c3(moby, D_L08_0015F580_macro, 0, 0.0f, 0.0f, 7, 10, 20, 3.0f, 1.7f, 4.0f, 1.0f, -1, 7.0f, 0, 7, -1, 0);
mark_moby_for_removal(moby);
return;
- }
case 0x63: {
+ char *p;
allocate_voice_for_target_entry(0, 0, moby);
- record.effect.owner = moby;
- record.effect.flags = 0x810001;
- record.effect.scale = 1.0f;
- clear_u64_value(&record.effect.vector);
- record.effect.other = 0;
- FUN_L00_001f2868(1.0f, moby + 0x10, 0x10, moby, &record.effect);
- FUN_L00_0025f090(moby, moby + 0x10, -1, 0.5f, 13.0f);
+ p = moby + 0x10;
+ c.p.moby = moby;
+ c.p.flags = 0x810001;
+ c.p.f = 1.0f;
+ clear_u64_value(&c.p);
+ c.p.st = 0;
+ FUN_L00_001f2868(p, 1.0f, 0x10, moby, &c.p);
+ FUN_L00_0025f090_c(moby, p, -1, 0.5f, 13.0f);
mark_moby_for_removal(moby);
return;
}
- default: break;
}
-finish:
- FUN_L00_00259fe8(0.2f, moby);
+ FUN_L00_00259fe8(moby, 0.2f);
}
-#endif
#ifndef NON_MATCHING
INCLUDE_ASM("config/us/overlays/asm/FUN_L08_002d42d8.s", FUN_L08_002d42d8);
#else
@@ -472,7 +483,7 @@ extern float fast_cos(float) __asm__("FUN_001f9dc8");
void FUN_L08_002d4ca0(struct Moby *moby);
void FUN_L08_002d55c8(struct Moby *moby, int path_id);
void FUN_L08_002d5950(char *moby, int joint, int count);
-void FUN_L08_002d5d08(struct Moby *moby);
+void FUN_L08_002d5d08_u(struct Moby *moby) __asm__("FUN_L08_002d5d08");
void FUN_L08_002d6450(struct Moby *moby);
char *FUN_L08_002dc8a0(char *src, char *pos, char *vec);
@@ -627,7 +638,7 @@ void FUN_L08_002d42d8(struct Moby *moby) {
goto restore_collision;
state14:
if (*(int *)(data + 0xf4) == 2) goto finish;
- FUN_L08_002d5d08(moby);
+ FUN_L08_002d5d08_u(moby);
target = (struct Moby *)D_0013D388;
if (((unsigned char *)target)[0x2e] != 0) allocate_voice_for_target_entry(6, 0, moby);
((unsigned char *)target)[0x2e] = 1;
@@ -724,15 +735,14 @@ void *FUN_L00_00263fd8(char *src, int cls, float *pos, void *mat, int a8, int a9
void FUN_L00_00257470(unsigned char *m, int flags, int arg);
void FUN_L00_0025d458(void *a, void *s);
void FUN_L00_0025d538(s32 id, void *s);
-extern int D_0015EE84_2D5FA8 __asm__("D_0015ED84");
-extern float D_0015EE70_2D5FA8 __asm__("D_0015ED70");
-extern float D_0015EE6C_2D5FA8 __asm__("D_0015ED6C");
+extern int D_0015ED84;
+extern float D_0015ED70;
+extern float D_0015ED6C_lui __asm__("D_0015ED6C");
extern int D_L08_0015F694_2D5FA8 __asm__("D_L08_0015F5B0");
extern int D_L08_0015F698_2D5FA8 __asm__("D_L08_0015F5B4") __attribute__((sda));
extern int D_L08_0015F6A0_2D5FA8 __asm__("D_L08_0015F5BC") __attribute__((sda));
-extern float D_L08_0015F580_macro[] __asm__("D_L08_0015F580") __attribute__((section(".sdata")));
extern Path_2D5FA8 *D_L08_001B0FB0_2D5FA8[] __asm__("D_L08_001B0CB0");
-extern char D_0013E633_2D5FA8[] __asm__("D_001413D0");
+extern char D_001413D0[];
extern unsigned char D_0013D50F_2D5FA8[] __asm__("D_0013D408");
extern Hit_2D5FA8 *find_2D5FA8(Moby *, int, int) __asm__("FUN_L00_0025a420");
extern Hit_2D5FA8 *pick_2D5FA8(Hit_2D5FA8 *, Hit_2D5FA8 *, Hit_2D5FA8 *, int) __asm__("FUN_L05_002899f8");
@@ -826,7 +836,7 @@ void FUN_L08_002d4ca0(Moby *moby) {
data->health = 6.0f;
data->flags &= 0xFFFD;
} else {
- if (D_0015EE84_2D5FA8 == 8) {
+ if (D_0015ED84 == 8) {
int part = data->part_id;
if (part != 0 && source != 0 && source->moby != 0 && source->moby->oclass == 0x661) {
if (part == one) D_L08_0015F694_2D5FA8 = one;
@@ -867,7 +877,7 @@ void FUN_L08_002d4ca0(Moby *moby) {
if (data->partB != 0) data->partB->hit_slot = 0xFF;
follow_2D5FA8(100.0f, moby, data->target, 0, 0, D_L08_001B0FB0_2D5FA8[data->path]->list, D_L08_001B0FB0_2D5FA8[data->path]->count);
- if (data->fF0 == 0) data->fF0 = *(int *)D_0013E633_2D5FA8;
+ if (data->fF0 == 0) data->fF0 = *(int *)D_001413D0;
if (data->mode != 2) {
float yaw, distance, pitch;
fast_vec_sub(vec, data->target, (float *)&moby->pos);
@@ -881,11 +891,11 @@ void FUN_L08_002d4ca0(Moby *moby) {
pitch = -0.7853982f;
}
yaw = angle_delta_2D5FA8(yaw, moby->rot.z);
- approach_2D5FA8(&data->yaw, yaw, &data->yaw_speed, D_0015EE70_2D5FA8 * 12.566371f, D_0015EE70_2D5FA8 * 12.566371f, D_0015EE6C_2D5FA8 * 9.424778f);
- approach_2D5FA8(&data->pitch, pitch, &data->pitch_speed, D_0015EE70_2D5FA8 * 12.566371f, D_0015EE70_2D5FA8 * 12.566371f, D_0015EE6C_2D5FA8 * 9.424778f);
+ approach_2D5FA8(&data->yaw, yaw, &data->yaw_speed, D_0015ED70 * 12.566371f, D_0015ED70 * 12.566371f, D_0015ED6C_lui * 9.424778f);
+ approach_2D5FA8(&data->pitch, pitch, &data->pitch_speed, D_0015ED70 * 12.566371f, D_0015ED70 * 12.566371f, D_0015ED6C_lui * 9.424778f);
} else {
- approach_2D5FA8(&data->yaw, 0.0f, &data->yaw_speed, D_0015EE70_2D5FA8 * 12.566371f, D_0015EE70_2D5FA8 * 12.566371f, D_0015EE6C_2D5FA8 * 9.424778f);
- approach_2D5FA8(&data->pitch, 0.0f, &data->pitch_speed, D_0015EE70_2D5FA8 * 12.566371f, D_0015EE70_2D5FA8 * 12.566371f, D_0015EE6C_2D5FA8 * 9.424778f);
+ approach_2D5FA8(&data->yaw, 0.0f, &data->yaw_speed, D_0015ED70 * 12.566371f, D_0015ED70 * 12.566371f, D_0015ED6C_lui * 9.424778f);
+ approach_2D5FA8(&data->pitch, 0.0f, &data->pitch_speed, D_0015ED70 * 12.566371f, D_0015ED70 * 12.566371f, D_0015ED6C_lui * 9.424778f);
}
rotation_2D5FA8(vec, 1, data->pitch);
rotation_2D5FA8(data->f110, 2, data->yaw);
@@ -1098,190 +1108,134 @@ void FUN_L08_002d5950(char *moby, int joint, int count) {
func_00219780_2D6C58(joint_pos, velocity, t70, D_L08_001618D4, D_L08_001618D8, frames1, frames2, frames3, -1);
}
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L08_002d5d08.s", FUN_L08_002d5d08);
-#else
+/* Spawns debris mobys while the level counter allows, then scatters or bursts the group's other mobys. */
+/* Ported from rac1-decomp (src/overlays/l08_batalia/vendor_002B9438.c: func_L08_002D7010), where it is exact; names translated to the US level program. */
+
+typedef int u128_7010 __attribute__((mode(TI)));
+
+typedef struct { char pad0[0x21]; unsigned char group; char pad22[0xDE]; } Blk_7010;
+
+typedef struct { char pad0[0x140]; float x,y,z,w; } Camera46;
+
+extern Camera46 D_L08_00167480;
+extern char *D_L08_0015FFD8;
+extern char *D_L08_001600EC;
+extern float D_0015ED6C_lui __asm__("D_0015ED6C");
+extern f32 fast_arc_tan_c(f32, f32) __asm__("func_001F9E90");
+extern f32 fast_cos_c3(f32) __asm__("func_001F9DC8");
+extern f32 random_angle_radians_c4(void) __asm__("func_00213308");
+extern f32 random_float_between_c4(f32, f32) __asm__("func_002132A8");
+extern float fast_difference_between_rotations_c2(float, float) __asm__("func_001FA688");
+extern int D_L08_0015FFBC;
+extern s32 random_integer_below_c2(s32) __asm__("func_00213260");
extern short *D_L08_001AC040[];
-extern int D_L08_0015FFBC __attribute__((section(".data")));
-extern int D_L08_0015FFBC_gp __asm__("D_L08_0015FFBC") __attribute__((sda));
-extern void *D_L08_001600EC;
-extern float D_L08_001675C0[];
-extern struct Moby *create_moby(s32) __asm__("FUN_0020c4f8");
-extern float random_angle_radians(void) __asm__("FUN_00213308");
-extern float fast_cos(float) __asm__("FUN_001f9dc8");
-extern float fast_difference_between_rotations(float, float) __asm__("FUN_001fa688");
-extern int FUN_001fa6d0(float);
-extern void transform_vector(void *, void *, void *) __asm__("FUN_001f9d20");
-extern void FUN_001f99f8(void *);
-extern void FUN_L05_00318648(void *, int, void *, void *, int);
-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 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_L05_00318648(void*,int,void*,void*,int);
+extern void transform_vector(void *, void *, void *) __asm__("func_001F9D20");
-/* Launch the selected group and a bounded burst of newly allocated mobys. */
-void FUN_L08_002d5d08(struct Moby *moby)
-{
- char *data = (char *)moby->pvars;
- short *list = D_L08_001AC040[((struct Moby *)D_L08_0015FFD8)[*(int *)(data + 0x144)].group];
- short *next;
- unsigned int index;
- struct Moby *other, *spawned;
+void FUN_L08_002d5d08(char *moby) {
+ float a[4];
+ float b[4];
+ float c[4];
+ char *d = *(char **)(moby + 0x78);
+ short *list = D_L08_001AC040[((Blk_7010 *)D_L08_0015FFD8 + *(int *)(d + 0x144))->group];
+ char *other;
+ unsigned short index;
int i;
- float position[4], offset[4], velocity[4];
- struct { char pad[0x140]; float x, y; } *center;
- extern char camera_state_bytes[] __asm__("D_L08_00167480");
- float angle, launch_yaw, center_yaw, min_frames, max_frames;
+
if (list == 0) return;
- i = 0;
- next = list + 1;
- index = *list & 0x7fff;
- other = (struct Moby *)D_L08_0015FFD8 + index;
- if (D_L08_0015FFBC > 49) {
- do {
- if (random_integer_below(0xff) & 1) spawned = create_moby(0x310);
- else spawned = create_moby(0x311);
- if (spawned != 0) {
- float angle;
- spawned->draw_dist = 0x40;
- spawned->update_dist = 0xff;
- spawned->visible = 1;
- spawned->rot.x = random_angle_radians();
- spawned->rot.y = random_angle_radians();
- spawned->rot.z = random_angle_radians();
- position[0] = random_float_between(-1.0f, 1.0f);
- position[1] = random_float_between(-1.0f, 1.0f);
- position[2] = random_float_between(-1.0f, 1.0f);
- position[3] = 1.0f;
- transform_vector(position, position, (char *)D_L08_001600EC + *(int *)(data + 0x148) * 0x80);
- qcopy(&spawned->pos, position);
- angle = random_float_between(-0.2617994f, 0.2617994f);
- FUN_001f99f8(offset);
- velocity[0] = fast_cos(angle) * (D_0015ED6C * 15.0f);
- velocity[1] = fast_sin(angle) * (D_0015ED6C * 15.0f);
- velocity[2] = 0;
- velocity[2] = random_float_between(D_0015ED6C * 8.0f, D_0015ED6C * 12.0f);
- FUN_L05_00318648(spawned, (int)moby, velocity, offset,
- FUN_001fa6d0(random_float_between(60.0f, 90.0f)));
- }
- if (++i < 40 && D_L08_0015FFBC_gp > 49) continue;
- break;
- } while (1);
+ index = *list & 0x7FFF;
+ other = (char *)((Blk_7010 *)D_L08_0015FFD8 + index);
+ for (i = 0; i < 40 && D_L08_0015FFBC >= 50; i++) {
+ char *m;
+ if (random_integer_below_c2(0xFF) & 1) m = func_0020D348_m(0x310); else m = func_0020D348_m(0x311);
+ if (m != 0) {
+ float ang;
+ *(short *)(m + 0x32) = 0x40;
+ *(unsigned char *)(m + 0x30) = 0xFF;
+ m[0x31] = 1;
+ *(float *)(m + 0x40) = func_00214158_2D6C58();
+ *(float *)(m + 0x44) = func_00214158_2D6C58();
+ *(float *)(m + 0x48) = func_00214158_2D6C58();
+ a[0] = random_float_between_c4(-1.0f, 1.0f);
+ a[1] = random_float_between_c4(-1.0f, 1.0f);
+ a[2] = random_float_between_c4(-1.0f, 1.0f);
+ a[3] = 1.0f;
+ transform_vector(a, a, D_L08_001600EC + (*(int *)(d + 0x148) << 7));
+ qcopy(m + 0x10, a);
+ ang = random_float_between_c4(-0.2617994f, 0.2617994f);
+ clear_u64_value(b);
+ c[0] = fast_cos_c3(ang) * (D_0015ED6C_lui * 15.0f);
+ c[1] = fast_sin(ang) * (D_0015ED6C_lui * 15.0f);
+ c[2] = 0.0f;
+ c[2] = random_float_between_c4(D_0015ED6C_lui * 8.0f, D_0015ED6C_lui * 12.0f);
+ FUN_L05_00318648(m, (int)moby, c, b, func_001FA898_2D6C58(random_float_between_c4(60.0f, 90.0f)));
+ }
}
- for (;;) {
- if (other->state < 0x7f && other != moby) {
- if ((unsigned int)((unsigned short)other->oclass - 0x24c) < 11) {
- angle = random_float_between(-0.2617994f, 0.2617994f);
- position[0] = fast_cos(angle) * (D_0015ED6C * 15.0f);
- position[1] = fast_sin(angle) * (D_0015ED6C * 15.0f);
- position[2] = 0;
- position[2] = random_float_between(D_0015ED6C * 8.0f, D_0015ED6C * 12.0f);
- switch ((short)(other->oclass - 0x24c)) {
+ while (1) {
+ if (*(unsigned char *)(other + 0x20) < 0x7F && other != moby) {
+ unsigned short cls = *(unsigned short *)(other + 0xA6);
+ if ((unsigned short)(cls - 0x24C) < 0xB) {
+ float ang;
+ float lo, hi;
+ ang = random_float_between_c4(-0.2617994f, 0.2617994f);
+ a[0] = fast_cos_c3(ang) * (D_0015ED6C_lui * 15.0f);
+ a[1] = fast_sin(ang) * (D_0015ED6C_lui * 15.0f);
+ a[2] = 0.0f;
+ a[2] = random_float_between_c4(D_0015ED6C_lui * 8.0f, D_0015ED6C_lui * 12.0f);
+ switch ((short)(*(unsigned short *)(other + 0xA6) - 0x24C)) {
case 0:
- *(u128 *)velocity = 0;
- velocity[0] = 1.629f;
- velocity[1] = -1.341f;
- velocity[2] = 11.48f;
- qcopy(offset, velocity);
- break;
+ *(u128_7010 *)c = 0; c[0] = 1.629f; c[1] = -1.341f; c[2] = 11.48f;
+ qcopy(b, c); break;
case 1:
- velocity[3] = 0.0f;
- *(u128 *)velocity = 0;
- velocity[0] = 1.299f;
- velocity[1] = -5.558f;
- velocity[2] = 11.48f;
- qcopy(offset, velocity);
- break;
+ *(u128_7010 *)c = 0; c[0] = 1.299f; c[1] = -5.558f; c[2] = 11.48f;
+ qcopy(b, c); break;
case 2:
- *(u128 *)velocity = 0;
- velocity[0] = 0.629f;
- velocity[1] = -2.527f;
- velocity[2] = 3.409f;
- qcopy(offset, velocity);
- break;
+ *(u128_7010 *)c = 0; c[0] = 0.629f; c[1] = -2.527f; c[2] = 3.409f;
+ qcopy(b, c); break;
case 3:
- velocity[3] = 0.0f;
- *(u128 *)velocity = 0;
- velocity[0] = 0.019f;
- velocity[1] = -6.19f;
- velocity[2] = 3.409f;
- qcopy(offset, velocity);
- break;
+ *(u128_7010 *)c = 0; c[0] = 0.019f; c[1] = -6.19f; c[2] = 3.409f;
+ qcopy(b, c); break;
case 4:
- *(u128 *)velocity = 0;
- velocity[0] = 3.196f;
- velocity[1] = -2.105f;
- velocity[2] = 7.784f;
- qcopy(offset, velocity);
- break;
+ *(u128_7010 *)c = 0; c[0] = 3.196f; c[1] = -2.105f; c[2] = 7.784f;
+ qcopy(b, c); break;
case 5:
- velocity[3] = 0.0f;
- *(u128 *)velocity = 0;
- velocity[0] = 2.11f;
- velocity[1] = -3.013f;
- velocity[2] = 2.625f;
- qcopy(offset, velocity);
- break;
+ *(u128_7010 *)c = 0; c[0] = 2.11f; c[1] = -3.013f; c[2] = 2.625f;
+ qcopy(b, c); break;
case 6:
- *(u128 *)velocity = 0;
- velocity[0] = 4.33f;
- velocity[1] = -6.449f;
- velocity[2] = 7.397f;
- qcopy(offset, velocity);
- break;
+ *(u128_7010 *)c = 0; c[0] = 4.33f; c[1] = -6.449f; c[2] = 7.397f;
+ qcopy(b, c); break;
case 7:
- velocity[3] = 0.0f;
- *(u128 *)velocity = 0;
- velocity[0] = 3.286f;
- velocity[1] = -6.925f;
- velocity[2] = 2.96f;
- qcopy(offset, velocity);
- break;
+ *(u128_7010 *)c = 0; c[0] = 3.286f; c[1] = -6.925f; c[2] = 2.96f;
+ qcopy(b, c); break;
case 8:
- *(u128 *)velocity = 0;
- velocity[0] = 1.539f;
- velocity[1] = -1.071f;
- velocity[2] = 13.144f;
- qcopy(offset, velocity);
- break;
+ *(u128_7010 *)c = 0; c[0] = 1.539f; c[1] = -1.071f; c[2] = 13.144f;
+ qcopy(b, c); break;
case 9:
- velocity[3] = 0.0f;
- *(u128 *)velocity = 0;
- velocity[0] = 1.596f;
- velocity[1] = -2.512f;
- velocity[2] = 8.359f;
- qcopy(offset, velocity);
- break;
+ *(u128_7010 *)c = 0; c[0] = 1.596f; c[1] = -2.512f; c[2] = 8.359f;
+ qcopy(b, c); break;
case 10:
- *(u128 *)velocity = 0;
- velocity[0] = 0.885f;
- velocity[1] = -5.824f;
- velocity[2] = 8.224f;
- qcopy(offset, velocity);
- break;
+ *(u128_7010 *)c = 0; c[0] = 0.885f; c[1] = -5.824f; c[2] = 8.224f;
+ qcopy(b, c); break;
}
- launch_yaw = fast_arc_tan(position[0], position[1]);
- center = (void *)camera_state_bytes;
- center_yaw = fast_arc_tan(center->x - moby->pos.x, center->y - moby->pos.y);
- if (fast_difference_between_rotations(launch_yaw, center_yaw) < 0.2617994f) {
- min_frames = 10.0f; max_frames = 20.0f;
+ if (fast_difference_between_rotations_c2(fast_arc_tan_c(a[0], a[1]),
+ fast_arc_tan_c(D_L08_00167480.x - *(float *)(moby + 0x10),
+ D_L08_00167480.y - *(float *)(moby + 0x14))) < 0.2617994f) {
+ FUN_L05_00318648(other, (int)moby, a, b, func_001FA898_2D6C58(random_float_between_c4(10.0f, 20.0f)));
} else {
- min_frames = 30.0f; max_frames = 45.0f;
+ FUN_L05_00318648(other, (int)moby, a, b, func_001FA898_2D6C58(random_float_between_c4(30.0f, 45.0f)));
}
- FUN_L05_00318648(other, (int)moby, position, offset,
- FUN_001fa6d0(random_float_between(min_frames, max_frames)));
- } else if (other->oclass == 0x1d8) {
- FUN_001f99f8(position);
- FUN_L00_0025e450(other, position, &other->pos, 0.0f, 0.0f,
- 50, 60, 60, 12.0f, 8.0f, 9.0f, 1.0f, -1, 15.0f, 1, 1, -1, 0);
+ } else if ((short)cls == 0x1D8) {
+ clear_u64_value(a);
+ FUN_L00_0025e450_c2(other, a, other + 0x10, 0.0f, 0.0f, 0x32, 0x3C, 0x3C, 12.0f, 8.0f, 9.0f, 1.0f, -1, 15.0f, 1, 1, -1, 0);
mark_moby_for_removal(other);
}
}
- if (*list < -1) return;
- index = *next & 0x7fff;
- other = (struct Moby *)D_L08_0015FFD8 + index;
- list = next;
- next++;
+ if (*list++ < -1) break;
+ index = *list & 0x7FFF;
+ other = (char *)((Blk_7010 *)D_L08_0015FFD8 + index);
}
}
-#endif
extern char *D_L08_0015FFD8;
extern short *D_L08_001AC040[];
@@ -2048,15 +2002,15 @@ void FUN_L08_002dc180(struct Moby *moby) {
/* Ported from rac1-decomp (src/overlays/l08_batalia/vendor_002B9438.c: func_L08_002DD9C0), where it is exact; names translated to the US level program. */
extern f32 advance_accelerated_scalar(f32 *, f32 *, f32, f32, f32, f32) __asm__("FUN_00213f38");
-extern float D_0015ED6C_q __asm__("D_0015ED6C");
-extern float D_0015ED70_q __asm__("D_0015ED70");
+extern float D_0015ED6C_lui __asm__("D_0015ED6C");
+extern float D_0015ED70;
extern void sample_camera_path(void *, s32, void *, void *, s32, f32) __asm__("FUN_00214e58");
int FUN_L08_002dc648(struct Moby *m) {
char *d = (char *)m->pvars;
int *path;
- float a = D_0015ED70_q * 0.1f;
- float b = D_0015ED6C_q * 0.08f;
+ float a = D_0015ED70 * 0.1f;
+ float b = D_0015ED6C_lui * 0.08f;
path = *(int **)(d + 0x120);
advance_accelerated_scalar((float *)(d + 0xE4), (float *)(d + 0xE8), *(float *)(d + 0x104), a,
a, b);
@@ -2067,8 +2021,8 @@ int FUN_L08_002dc648(struct Moby *m) {
*(int *)(d + 0x74) = 0;
if (absolute_float(*(float *)(d + 0xE4) - *(float *)(d + 0x104)) < 0.2f) {
advance_accelerated_scalar((float *)(d + 0x108), (float *)(d + 0x10C), 3.14159f,
- D_0015ED70_q * 2.0943952f, D_0015ED70_q * 2.0943952f,
- D_0015ED6C_q * 6.2831855f);
+ D_0015ED70 * 2.0943952f, D_0015ED70 * 2.0943952f,
+ D_0015ED6C_lui * 6.2831855f);
} else {
*(int *)(d + 0x108) = 0;
}
@@ -2141,8 +2095,8 @@ extern void FUN_L08_002dc9a8_emit(void *, void *, int, int, float, int, int) __a
extern void FUN_L08_002dc9a8_special(void *, float, float, float) __asm__("FUN_00214db0");
extern void FUN_L08_002dc9a8_start(int, int, void *) __asm__("FUN_0022da68");
extern void FUN_L08_002dc9a8_finish(void *) __asm__("FUN_0020c828");
-extern float D_0015ED6C_2DC9A8 __asm__("D_0015ED6C");
-extern float D_0015ED70_2DC9A8 __asm__("D_0015ED70");
+extern float D_0015ED6C_lui __asm__("D_0015ED6C");
+extern float D_0015ED70;
#include "rnc/overlay/collision.h"
extern int D_L08_00174658_2DC9A8 __asm__("D_L08_00174658") __attribute__((section(".data")));
@@ -2184,7 +2138,7 @@ void FUN_L08_002dc9a8(struct Moby *moby) {
position = (float *)(m + 0x10);
qcopy(original, position);
FUN_L08_002dc9a8_transform(position, position, data);
- *(float *)(data + 8) -= D_0015ED70_2DC9A8 * 10.8f;
+ *(float *)(data + 8) -= D_0015ED70 * 10.8f;
qcopy(record.pos, position);
record.owner = m;
record.flags = 0x810000;
@@ -2197,16 +2151,16 @@ void FUN_L08_002dc9a8(struct Moby *moby) {
m[0x20] = 99;
qcopy(position, D_L08_00174640.point.f);
FUN_L08_002dc9a8_add(data, data, &D_L08_00174640.normal_x);
- FUN_L08_002dc9a8_scale(D_0015ED6C_2DC9A8 + D_0015ED6C_2DC9A8, data, data);
+ FUN_L08_002dc9a8_scale(D_0015ED6C_lui + D_0015ED6C_lui, data, data);
}
} else {
if (FUN_L08_002dc9a8_test(data + 0x10) != 0) m[0x20] = 99;
}
} break;
case 99: {
- record.pos[0] = D_0015ED6C_2DC9A8 * 14.0f;
- record.pos[1] = D_0015ED6C_2DC9A8 * 22.0f;
- record.pos[2] = D_0015ED6C_2DC9A8 * 12.0f;
+ record.pos[0] = D_0015ED6C_lui * 14.0f;
+ record.pos[1] = D_0015ED6C_lui * 22.0f;
+ record.pos[2] = D_0015ED6C_lui * 12.0f;
record.pos[3] = 0.0f;
*(EffectVectorCopy_2DC9A8 *)original = *(EffectVectorCopy_2DC9A8 *)record.pos;
record.owner = m;
@@ -2219,11 +2173,11 @@ void FUN_L08_002dc9a8(struct Moby *moby) {
for (i = 0; i < 50; i++) {
axis = i % 4;
*(u128 *)velocity = 0;
- velocity[0] = FUN_L08_002dc9a8_random(D_0015ED6C_2DC9A8 * -0.5f,
- D_0015ED6C_2DC9A8 * 0.5f);
- velocity[1] = FUN_L08_002dc9a8_random(D_0015ED6C_2DC9A8 * -0.5f,
- D_0015ED6C_2DC9A8 * 0.5f);
- velocity[2] = FUN_L08_002dc9a8_random(D_0015ED6C_2DC9A8 * 4.0f,
+ velocity[0] = FUN_L08_002dc9a8_random(D_0015ED6C_lui * -0.5f,
+ D_0015ED6C_lui * 0.5f);
+ velocity[1] = FUN_L08_002dc9a8_random(D_0015ED6C_lui * -0.5f,
+ D_0015ED6C_lui * 0.5f);
+ velocity[2] = FUN_L08_002dc9a8_random(D_0015ED6C_lui * 4.0f,
original[axis]);
*(u128 *)effect = *(u128 *)velocity;
radius = FUN_L08_002dc9a8_random(0.0f, 0.25f);
@@ -2232,7 +2186,7 @@ void FUN_L08_002dc9a8(struct Moby *moby) {
record.pos[1] = FUN_L08_002dc9a8_cos(angle) * radius;
record.pos[2] = 0.0f;
FUN_L08_002dc9a8_transform(record.pos, record.pos, m + 0x10);
- frame_time = radius * D_0015ED6C_2DC9A8;
+ frame_time = radius * D_0015ED6C_lui;
radius *= 0.717f;
record.pos[2] -= radius;
effect[2] -= frame_time * 8.0f;
@@ -2260,7 +2214,7 @@ void FUN_L08_002dc9a8(struct Moby *moby) {
0x7f000000, 0x7f182030);
color2 = FUN_L08_002dc9a8_color(FUN_L08_002dc9a8_random(0.5f, 1.0f),
0, 0x5f5f5f);
- radius = FUN_L08_002dc9a8_random(0.0f, 1.0f) * D_0015ED6C_2DC9A8;
+ radius = FUN_L08_002dc9a8_random(0.0f, 1.0f) * D_0015ED6C_lui;
FUN_L08_002dc9a8_special(position, radius, angle,
FUN_L08_002dc9a8_random_word());
radius = FUN_L08_002dc9a8_random(150000.0f, 200000.0f);
@@ -2319,7 +2273,6 @@ typedef struct { int waypoint; signed char direction; char pad5[0xB]; Route_2dd4
typedef struct { char pad0[0x2C]; unsigned char active; } Persistent46;
-typedef struct { char pad0[0x140]; float x,y,z,w; } Camera46;
extern Camera46 D_L08_00167480;
extern char *D_L08_0015FFD8_macro __asm__("D_L08_0015FFD8") __attribute__((section(".sdata")));
@@ -2329,7 +2282,7 @@ extern f32 distance_xyz_c(void *, void *) __asm__("func_001F9B48");
extern f32 fast_cos_c2(f32) __asm__("func_001F9DC8");
extern f32 random_angle_radians_c2(void) __asm__("func_00213308");
extern f32 random_float_between_c2(f32, f32) __asm__("func_002132A8");
-extern float D_0015ED6C_c __asm__("D_0015ED6C") __attribute__((section(".sdata")));
+extern float D_0015ED6C __attribute__((section(".sdata")));
extern float frame_time_sq_macro __asm__("D_0015ED70") __attribute__((section(".sdata")));
extern float D_L08_00161A00 __attribute__((sda));
extern float D_L08_00161A04 __attribute__((sda));
@@ -2353,7 +2306,7 @@ extern void FUN_L00_0025f730(void*,float);
extern void FUN_L00_00262cf0(void*,void*,float,float,float);
extern void FUN_L00_00269958(void*,void*,int,int,int,int,int,int);
extern void FUN_L05_00318648(void*,int,void*,void*,int);
-extern void FUN_L08_002de528(void*,int,int,int);
+extern void FUN_L08_002de528_u(void*,int,int,int) __asm__("FUN_L08_002de528");
extern void build_spherical_offset(void *, f32, f32, f32) __asm__("func_00214DB0");
extern void tick_countdown_32(s32 *) __asm__("func_001F9740");
extern Route_2dd4f8_2dd3c0 *D_L08_001B0FB0_r_c[] __asm__("D_L08_001B0CB0");
@@ -2388,13 +2341,13 @@ void FUN_L08_002dd3c0(M46 *moby) {
D46 *target_data=data->target->data;
int life,size0,size1;
float yaw,pitch,radius,angle;
- moby->rotation[0]=fast_add_rotations(moby->rotation[0],D_0015ED6C_c*6.2831855f);
+ moby->rotation[0]=fast_add_rotations(moby->rotation[0],D_0015ED6C*6.2831855f);
qcopy(target,data->target->position); target[2]+=5.0f;
yaw=fast_arc_tan(moby->position[0]-target[0],moby->position[1]-target[1]);
pitch=fast_arc_tan(FUN_001f9b80(target,moby->position),moby->position[2]-target[2]);
FUN_L00_00262cf0(target,target,data->roll,data->yaw,data->pitch);
subtract_vector_xyz(delta,target,moby->position);
- FUN_L00_0025f730(delta,target_data->speed*D_0015ED6C_c);
+ FUN_L00_0025f730(delta,target_data->speed*D_0015ED6C);
subtract_vector_xyz(accel,delta,data->velocity);
FUN_L00_0025f730(accel,D_L08_00161A04*frame_time_sq_macro);
add_vector_xyz(data->velocity,data->velocity,accel);
@@ -2402,7 +2355,7 @@ void FUN_L08_002dd3c0(M46 *moby) {
moby->rotation[1]=-fast_arc_tan(vector_length_xy(data->velocity),data->velocity[2]);
moby->rotation[2]=fast_arc_tan(data->velocity[0],data->velocity[1]);
if (fast_difference_between_rotations_c(yaw,data->yaw)<0.08726646f && fast_difference_between_rotations_c(pitch,data->pitch)<0.08726646f) moby->state=2;
- radius=random_float_between_c2(0.0f,D_L08_00161A14)*D_0015ED6C_c;
+ radius=random_float_between_c2(0.0f,D_L08_00161A14)*D_0015ED6C;
angle=random_angle_radians_c2();
normalize_vector_xyz(effect,moby->matrix[2],radius*fast_cos_c2(angle));
normalize_vector_xyz(aux,moby->matrix[1],radius*fast_sin(angle));
@@ -2417,12 +2370,12 @@ void FUN_L08_002dd3c0(M46 *moby) {
D46 *target_data=data->target->data;
int life,size0,size1;
float scale,radius,angle;
- moby->rotation[0]=fast_add_rotations(moby->rotation[0],D_0015ED6C_c*6.2831855f);
+ moby->rotation[0]=fast_add_rotations(moby->rotation[0],D_0015ED6C*6.2831855f);
scale=moby->model->scale*3.0f;
approach_value(&moby->scale,scale,moby->model->scale/(float)scale_game_frames_alt(180));
qcopy(target,data->target->position); target[2]+=5.0f;
subtract_vector_xyz(delta,target,moby->position);
- FUN_L00_0025f730(delta,target_data->speed*D_0015ED6C_c);
+ FUN_L00_0025f730(delta,target_data->speed*D_0015ED6C);
subtract_vector_xyz(accel,delta,data->velocity);
FUN_L00_0025f730(accel,D_L08_00161A04*4.0f*frame_time_sq_macro);
add_vector_xyz(data->velocity,data->velocity,accel);
@@ -2432,7 +2385,7 @@ void FUN_L08_002dd3c0(M46 *moby) {
if (distance_xyz_c(moby->position,data->target->position)health-=60; clear_u64_value(data->velocity); allocate_voice_for_target_entry_alt(0,0,moby); moby->state=6;
}
- radius=random_float_between_c2(0.0f,D_L08_00161A14)*D_0015ED6C_c;
+ radius=random_float_between_c2(0.0f,D_L08_00161A14)*D_0015ED6C;
angle=random_angle_radians_c2();
normalize_vector_xyz(effect,moby->matrix[2],radius*fast_cos_c2(angle));
normalize_vector_xyz(aux,moby->matrix[1],radius*fast_sin(angle));
@@ -2465,18 +2418,18 @@ void FUN_L08_002dd3c0(M46 *moby) {
if (route->waypoint!=route->path->count-1) {
int life0,life1,size1;
subtract_vector_xyz(delta,target,moby->position);
- normalize_vector_xyz(delta,delta,D_L08_00161A08*D_0015ED6C_c);
+ normalize_vector_xyz(delta,delta,D_L08_00161A08*D_0015ED6C);
add_vector_xyz(moby->position,moby->position,delta);
if (distance_xyz_c(moby->position,target)<0.5f) route->waypoint=next;
*(Q46*)effect=(Q46)0;
effect[0]=random_float_between_c2(-1.0f,1.0f); effect[1]=random_float_between_c2(-1.0f,1.0f); effect[2]=random_float_between_c2(-1.0f,1.0f);
- *(Q46*)accel=*(Q46*)effect; FUN_L00_0025f730(accel,D_0015ED6C_c+D_0015ED6C_c);
+ *(Q46*)accel=*(Q46*)effect; FUN_L00_0025f730(accel,D_0015ED6C+D_0015ED6C);
life0=scale_game_frames_alt(FUN_L00_00257b90(30,45));
size1=FUN_L00_00257b90(40,70);
FUN_L00_00269958(moby->position,accel,0x6F00AFFF,0xFF,life0,40,size1,1);
*(Q46*)aux=(Q46)0;
aux[0]=random_float_between_c2(-1.0f,1.0f); aux[1]=random_float_between_c2(-1.0f,1.0f); aux[2]=random_float_between_c2(-1.0f,1.0f);
- *(Q46*)effect=*(Q46*)aux; FUN_L00_0025f730(effect,D_0015ED6C_c+D_0015ED6C_c);
+ *(Q46*)effect=*(Q46*)aux; FUN_L00_0025f730(effect,D_0015ED6C+D_0015ED6C);
life1=scale_game_frames_alt(FUN_L00_00257b90(60,120));
size1=FUN_L00_00257b90(100,150);
FUN_L00_00269958(moby->position,effect,0x1FFFFFFF,0x4F4F4F,life1,40,size1,0);
@@ -2508,8 +2461,8 @@ void FUN_L08_002dd3c0(M46 *moby) {
float launch_yaw,center_yaw,min_frames,max_frames,angle_delta;
float *launch_offset;
subtract_vector_xyz(accel,other->position,moby->position); accel[2]=0.0f;
- normalize_vector_xyz(accel,accel,D_0015ED6C_c*12.0f);
- accel[2]=random_float_between_c2(D_0015ED6C_c*8.0f,D_0015ED6C_c*12.0f);
+ normalize_vector_xyz(accel,accel,D_0015ED6C*12.0f);
+ accel[2]=random_float_between_c2(D_0015ED6C*8.0f,D_0015ED6C*12.0f);
other->animation=0;
launch_yaw=fast_arc_tan(accel[0],accel[1]);
center_yaw=fast_arc_tan(D_L08_00167480.x-moby->position[0],D_L08_00167480.y-moby->position[1]);
@@ -2530,17 +2483,17 @@ void FUN_L08_002dd3c0(M46 *moby) {
other=(M46*)(D_L08_0015FFD8_macro+(index<<8));
goto linked_object;
}
- if (special) FUN_L08_002de528(moby,data->effect_path,30,1);
- else FUN_L08_002de528(moby,data->effect_path,30,0);
+ if (special) FUN_L08_002de528_u(moby,data->effect_path,30,1);
+ else FUN_L08_002de528_u(moby,data->effect_path,30,0);
allocate_voice_for_target_entry_alt(2,0,moby); moby->state=6;
}
return;
}
case 5:
- FUN_L00_0025bc00(&moby->rotation[2],0,data->yaw,D_0015ED6C_c*0.5235988f);
- FUN_L00_0025bc00(&moby->rotation[1],0,-data->pitch,D_0015ED6C_c*0.5235988f);
- moby->rotation[0]=fast_add_rotations(moby->rotation[0],D_0015ED6C_c*6.2831855f);
- build_spherical_offset(data->velocity,(D_L08_00161A00+D_L08_00161A00)*D_0015ED6C_c,moby->rotation[2],-moby->rotation[1]);
+ FUN_L00_0025bc00(&moby->rotation[2],0,data->yaw,D_0015ED6C*0.5235988f);
+ FUN_L00_0025bc00(&moby->rotation[1],0,-data->pitch,D_0015ED6C*0.5235988f);
+ moby->rotation[0]=fast_add_rotations(moby->rotation[0],D_0015ED6C*6.2831855f);
+ build_spherical_offset(data->velocity,(D_L08_00161A00+D_L08_00161A00)*D_0015ED6C,moby->rotation[2],-moby->rotation[1]);
add_vector_xyz(moby->position,moby->position,data->velocity);
if (FUN_L08_002025d0(moby->position,0x400,2,moby,0) || moby->position[0]<5.0f || moby->position[0]>500.0f || moby->position[1]<5.0f || moby->position[1]>500.0f || moby->position[2]<5.0f || moby->position[2]>500.0f || distance_xyz_c(D_0013F3D0,moby->position)<16.0f) moby->state=6;
return;
@@ -2595,79 +2548,59 @@ struct Moby *FUN_L08_002de3e0(void *pos, struct Moby *target, void *velocity, fl
}
return moby;
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L08_002de528.s", FUN_L08_002de528);
-#else
-extern void effect_2de528(void *, void *, void *, float, float, int, int, int,
- float, float, float, float, int, float, int, int, int, int)
- __asm__("FUN_L00_0025e450");
-extern int random_integer_below(int) __asm__("FUN_00213260");
-extern float random_angle_radians(void) __asm__("FUN_00213308");
-extern struct Moby *create_moby(s32) __asm__("FUN_0020c4f8");
-extern void transform_vector(void *, void *, void *) __asm__("FUN_001f9d20");
-extern void FUN_001f99f8(void *);
-extern void FUN_001f9a28(void *, void *, void *);
-extern void set_vector_length_xy(float, void *, void *) __asm__("FUN_001f9c48");
-extern int FUN_001fa6d0(float);
-extern void *D_L08_001600EC;
-
-void FUN_L08_002de528(void *moby, int index, int count, int variant) {
- int i;
- int table_offset;
- char *spawned;
- char *origin;
- float position[4];
- float axis[4];
- float velocity[4];
- float speed;
- float angle;
+/* Ported from rac1-decomp (src/overlays/l08_batalia/vendor_002B9438.c: func_L08_002DF8A0), where it is exact; names translated to the US level program. */
+
+extern char *D_L08_001600EC;
+extern float D_0015ED6C_lui __asm__("D_0015ED6C");
+extern f32 random_angle_radians_c3(void) __asm__("func_00213308");
+extern f32 random_float_between_c3(f32, f32) __asm__("func_002132A8");
+extern s32 random_integer_below_c(s32) __asm__("func_00213260");
+extern s32 truncate_float_to_s32_c3(f32) __asm__("func_001FA6D0");
+extern void FUN_L00_0025e450_c(void *, void *, void *, float, float, int, int, int, float, float, float, float, int, float, int, int, int, int) __asm__("FUN_L00_0025e450");
+extern void set_vector_length_xy(void *, void *, f32) __asm__("FUN_001f9c48");
+extern void transform_vector(void *, void *, void *) __asm__("func_001F9D20");
+
+void FUN_L08_002de528(char *moby, int a, int n, int flag) {
+ float vec[4];
+ float vec2[4];
+ float vec3[4];
char *data = *(char **)(moby + 0x78);
+ int i;
- if (variant != 0) {
- effect_2de528(moby, data + 0x20, moby + 0x10, 0.0f, 0.0f,
- 0x1e, 0x14, 0x14, 6.0f, 4.0f, 9.0f, 1.0f, -1, 15.0f, 1, 1, -1, 0);
+ if (flag) {
+ FUN_L00_0025e450_c(moby, data + 0x20, moby + 0x10, 0.0f, 0.0f, 0x1E, 0x14, 0x14, 6.0f, 4.0f, 9.0f, 1.0f, -1, 15.0f, 1, 1, -1, 0);
} else {
- effect_2de528(moby, data + 0x20, moby + 0x10, 0.0f, 0.0f,
- 0x2d, 0x1e, 0x1e, 10.0f, 6.0f, 9.0f, 1.0f, -1, 15.0f, 1, 1, -1, 0);
+ FUN_L00_0025e450_c(moby, data + 0x20, moby + 0x10, 0.0f, 0.0f, 0x2D, 0x1E, 0x1E, 10.0f, 6.0f, 9.0f, 1.0f, -1, 15.0f, 1, 1, -1, 0);
}
- origin = moby + 0x10;
- if (count > 0) {
- i = count;
- table_offset = index << 7;
- do {
- if (variant != 0) {
- if ((random_integer_below(0xff) & 1) != 0) spawned = (char *)create_moby(0x30e);
- else spawned = (char *)create_moby(0x30f);
+ for (i = 0; i < n; i++) {
+ {
+ char *m;
+ if (flag) {
+ if (random_integer_below_c(0xFF) & 1) m = func_0020D348_m(0x30E); else m = func_0020D348_m(0x30F);
} else {
- if ((random_integer_below(0xff) & 1) != 0) spawned = (char *)create_moby(0x310);
- else spawned = (char *)create_moby(0x311);
+ if (random_integer_below_c(0xFF) & 1) m = func_0020D348_m(0x310); else m = func_0020D348_m(0x311);
}
- *(short *)(spawned + 0x32) = 0x40;
- spawned[0x31] = 1;
- spawned[0x30] = 0x40;
- *(long long *)(spawned + 0x38) = *(long long *)(moby + 0x38);
- *(float *)(spawned + 0x40) = random_angle_radians();
- *(float *)(spawned + 0x44) = random_angle_radians();
- *(float *)(spawned + 0x48) = random_angle_radians();
- position[0] = random_float_between(-1.0f, 1.0f);
- position[1] = random_float_between(-1.0f, 1.0f);
- position[2] = random_float_between(-1.0f, 1.0f);
- position[3] = 1.0f;
- transform_vector(position, position, (char *)D_L08_001600EC + table_offset);
- qcopy(spawned + 0x10, position);
- FUN_001f99f8(axis);
- FUN_001f9a28(velocity, position, origin);
- speed = random_float_between(frame_time * 12.0f, frame_time * 15.0f);
- set_vector_length_xy(speed, velocity, velocity);
- angle = random_float_between(frame_time * 6.0f, frame_time * 18.0f);
- velocity[2] = angle;
- speed = random_float_between(60.0f, 90.0f);
- FUN_L05_00318648(spawned, (int)moby, velocity, axis, FUN_001fa6d0(speed));
- } while (--i != 0);
+ *(short *)(m + 0x32) = 0x40;
+ m[0x31] = 1;
+ m[0x30] = 0x40;
+ *(long *)(m + 0x38) = *(long *)(moby + 0x38);
+ *(float *)(m + 0x40) = random_angle_radians_c3();
+ *(float *)(m + 0x44) = random_angle_radians_c3();
+ *(float *)(m + 0x48) = random_angle_radians_c3();
+ vec[0] = random_float_between_c3(-1.0f, 1.0f);
+ vec[1] = random_float_between_c3(-1.0f, 1.0f);
+ vec[2] = random_float_between_c3(-1.0f, 1.0f);
+ vec[3] = 1.0f;
+ transform_vector(vec, vec, D_L08_001600EC + (a << 7));
+ qcopy(m + 0x10, vec);
+ clear_u64_value(vec2);
+ subtract_vector_xyz(vec3, vec, moby + 0x10);
+ set_vector_length_xy(vec3, vec3, random_float_between_c3(D_0015ED6C_lui * 12.0f, D_0015ED6C_lui * 15.0f));
+ vec3[2] = random_float_between_c3(D_0015ED6C_lui * 6.0f, D_0015ED6C_lui * 18.0f);
+ FUN_L05_00318648(m, (int)moby, vec3, vec2, func_001FA898_r(random_float_between_c3(60.0f, 90.0f)));
+ }
}
}
-
-#endif /* NON_MATCHING */
/* Ported from rac1-decomp src/overlays/l08_batalia/vendor_002B9438.c (func_L08_002DFBC0) */
/* Update function: switch on the state byte at +0x20. State 0 reads the table D_L08_001B0FB0[*data] (deleting
@@ -2676,7 +2609,7 @@ void FUN_L08_002de528(void *moby, int index, int count, int variant) {
extern f32 vector_length_xy(void *) __asm__("FUN_001f9b20");
extern float D_0015ED6C;
-extern float D_0015ED70_c __asm__("D_0015ED70");
+extern float D_0015ED70;
extern int D_001413D4 __attribute__((section(".data")));
extern int coll_sphere(float, void *, int, void *) __asm__("FUN_L00_001f0d60");
extern float D_L08_00161A44 __attribute__((sda));
@@ -2729,7 +2662,7 @@ void FUN_L08_002de848(char *m) {
float g;
char *v = d + 0x10;
g = D_0015ED6C * 7.3303828f;
- *(float *)(d + 0x18) = *(float *)(d + 0x18) - D_0015ED70_c * c15;
+ *(float *)(d + 0x18) = *(float *)(d + 0x18) - D_0015ED70 * c15;
dd = fast_add_rotations(*(float *)(m + 0x40), g);
*(float *)(m + 0x40) = *(float *)(m + 0x40) + dd;
*(float *)(m + 0x44) = -fast_arc_tan(vector_length_xy(v), *(float *)(d + 0x18));
diff --git a/src/overlays/l10/gameplay/entities/screamer.c b/src/overlays/l10/gameplay/entities/screamer.c
index e272e0b678..e93a95a85c 100644
--- a/src/overlays/l10/gameplay/entities/screamer.c
+++ b/src/overlays/l10/gameplay/entities/screamer.c
@@ -293,8 +293,8 @@ typedef struct Anim_2DFC38 { char pad0[0x30]; float f30[4], f40[4]; char pad50[0
typedef struct Path_2DFC38 { int count; char pad4[0xC]; float pts[4]; } Path_2DFC38;
extern Anim_2DFC38 *D_L10_001600EC_2DFC38 __asm__("D_L10_001600EC");
extern Path_2DFC38 *D_L10_001B0C30_2DFC38[] __asm__("D_L10_001B0930");
-extern char D_0013E633_2DFC38[] __asm__("D_0013F3D0");
-extern int D_001414D0_2DFC38[] __asm__("D_001413D0");
+extern char D_0013F3D0[];
+extern int D_001413D0[];
extern float D_0015ED6C, D_0015ED70;
extern float angle_atan2(float, float) __asm__("FUN_001f9e90");
extern void blend_moby_animation(void *, int, int, int) __asm__("FUN_00212f90");
@@ -380,7 +380,7 @@ void FUN_L10_002dfc38(struct Moby *moby) {
r19 = ahead_f(data->f180, moby, data->fC0);
if (r19 != 2) {
Anim_2DFC38 *bp = &D_L10_001600EC_2DFC38[data->f194];
- subtract_vector_xyz(v, D_0013E633_2DFC38, bp->f30);
+ subtract_vector_xyz(v, D_0013F3D0, bp->f30);
v[3] = 0.0f;
transform_vector_by_basis(w, v, bp->f40);
if (w[0] <= -1.0f || 0.0f <= w[0] || w[1] <= -1.0f || 1.0f <= w[1] || w[2] <= -1.0f || 1.0f <= w[2]) data->f104 = 2;
@@ -398,7 +398,7 @@ void FUN_L10_002dfc38(struct Moby *moby) {
if (data->f180 < vector_distance(data->f130, data->fC0)) data->f104 = 2;
else if (moby->visible == 0) data->f104 = 2;
}
- if (data->f100 == 0) data->f100 = D_001414D0_2DFC38[0];
+ if (data->f100 == 0) data->f100 = D_001413D0[0];
}
#define NOT_SDA
@@ -529,8 +529,8 @@ 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 hero_2D9988[] __asm__("D_0013F350");
-extern float frame_time_sq_2D9988 __asm__("D_0015ED70");
+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");
extern void func_001F9BD8_2E0630(void *, void *, void *) __asm__("FUN_001f9a10");
@@ -595,7 +595,7 @@ void FUN_L10_002e01a8(Moby *moby) {
case 2:
moby->anim_speed = 4.0f;
if (func_00214D88_2E0630(&moby->pos.z, vars->home.z + 2.0f, &vars->velocity.z,
- frame_time_sq_2D9988 * 18.0f, frame_time_sq_2D9988 * 18.0f, frame_time_x * 6.0f) == 0.0f) {
+ D_0015ED70 * 18.0f, D_0015ED70 * 18.0f, frame_time_x * 6.0f) == 0.0f) {
moby->state = 3;
}
break;
@@ -609,9 +609,9 @@ void FUN_L10_002e01a8(Moby *moby) {
dist = func_001F9D10_2E0630(&vars->goal, &moby->pos);
travelled = 0.0f;
func_L00_0025CE58_2E0630(&moby->rot.z, func_L00_001FF860_2E0630(vars->goal.x - moby->pos.x, vars->goal.y - moby->pos.y), &vars->turn_speed,
- frame_time_sq_2D9988 * 25.132742f, frame_time_sq_2D9988 * 25.132742f, frame_time_x * 50.265484f);
+ D_0015ED70 * 25.132742f, D_0015ED70 * 25.132742f, frame_time_x * 50.265484f);
if (func_001FA850_2E0630(func_L00_001FF860_2E0630(vars->goal.x - moby->pos.x, vars->goal.y - moby->pos.y), moby->rot.z) < 0.78539819f) {
- func_00214D88_2E0630(&travelled, dist, &speed, frame_time_sq_2D9988 * 20.0f, frame_time_sq_2D9988 * 20.0f, frame_time_x * 20.0f);
+ func_00214D88_2E0630(&travelled, dist, &speed, D_0015ED70 * 20.0f, D_0015ED70 * 20.0f, frame_time_x * 20.0f);
func_001F9BF0_2E0630(&vars->velocity, &vars->goal, &moby->pos);
func_L00_002607A8_2E0630(&vars->velocity, speed);
} else {
@@ -690,7 +690,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 *)hero_2D9988)->motion.pos.f[2]) < 2.0f) {
+ if (absolute_float_2e01a8(moby->pos.z - ((Hero_2e01a8 *)D_0013F350)->motion.pos.f[2]) < 2.0f) {
func_0022ED80_2E1568(0, 0, moby);
moby->state = 8;
func_001F9BC0_2E0630(&vars->velocity);
@@ -836,7 +836,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 *)(hero_2D9988 + 0x208C) == 7
+ || *(int *)(D_0013F350 + 0x208C) == 7
|| (moby->anim_flags & 2)) {
moby->state = 12;
if (moby->prev_seq != 3) func_00213DE0_2E0630(moby, 3, 0, func_001F9850_2E0630(2));
@@ -990,8 +990,8 @@ extern void trooper_anim_finish(void *, void *) __asm__("FUN_L00_0025d538");
extern int ahead_f(float, void *, void *) __asm__("FUN_L01_00274b78");
extern int activate_effect_l08(float, void *, void *, int, int, void *, int) __asm__("FUN_L00_0025ff38");
extern float vector_distance(void *, void *) __asm__("FUN_001f9b80");
-extern char D_0013E633_2E2B80[] __asm__("D_0013F3D0");
-extern int D_001414D0_2E2B80[] __asm__("D_001413D0");
+extern char D_0013F3D0[];
+extern int D_001413D0[];
extern Path_2E2B80 *D_L10_001B0C30_2E2B80[] __asm__("D_L10_001B0930");
void FUN_L10_002e17c0(struct Moby *moby)
@@ -1059,7 +1059,7 @@ void FUN_L10_002e17c0(struct Moby *moby)
r19 = ahead_f(data->f180, moby, data->fC0);
if (r19 != 2) {
Anim_2E2B80 *bp = &D_L10_001600EC[data->f194];
- subtract_vector_xyz(v, D_0013E633_2E2B80, bp->f30);
+ subtract_vector_xyz(v, D_0013F3D0, bp->f30);
v[3] = 0.0f;
transform_vector_by_basis(w, v, bp->f40);
if (w[0] <= -1.0f || 1.0f <= w[0] || w[1] <= -1.0f || 1.0f <= w[1] || w[2] <= -1.0f || 1.0f <= w[2]) {
@@ -1081,7 +1081,7 @@ void FUN_L10_002e17c0(struct Moby *moby)
}
}
if (data->f100 == 0) {
- data->f100 = D_001414D0_2E2B80[0];
+ data->f100 = D_001413D0[0];
}
}
/* Stores a value into each table entry listed for this moby's index. */
@@ -2082,7 +2082,7 @@ 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_hero_2E52B0[] __asm__("D_0013F350");
+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 +2102,8 @@ void FUN_L10_002e3ef0(void *mv) {
Moby *q;
int v21;
- if (((Hero *)(D_hero_2E52B0))->items[0].item_id == 0x15) {
- if (((D_2E52B0 *)((Hero *)(D_hero_2E52B0))->items[0].moby->pvars)->f10 == m) {
+ if (((Hero *)(D_0013F350))->items[0].item_id == 0x15) {
+ if (((D_2E52B0 *)((Hero *)(D_0013F350))->items[0].moby->pvars)->f10 == m) {
func_L10_002E14F8_2E52B0(m);
if (m->state == 1) m->state = 2;
}
@@ -2131,9 +2131,9 @@ void FUN_L10_002e3ef0(void *mv) {
v21 = 11;
if (B < 3.0f) B = 0.0f;
}
- if (((Hero *)(D_hero_2E52B0))->state.current == 32
- || (((Hero *)(D_hero_2E52B0))->state.prev == 32
- && ((Hero *)(D_hero_2E52B0))->state_timer < func_001F9850_2E52B0(30))) {
+ if (((Hero *)(D_0013F350))->state.current == 32
+ || (((Hero *)(D_0013F350))->state.prev == 32
+ && ((Hero *)(D_0013F350))->state_timer < func_001F9850_2E52B0(30))) {
if (2.0f < B) B = 2.0f;
}
if (r->h2A == m->oclass) {
@@ -2141,14 +2141,14 @@ void FUN_L10_002e3ef0(void *mv) {
v21 = 11;
}
if ((unsigned int)(m->prev_seq - 6) < 2) {
- if (((Hero *)(D_hero_2E52B0))->vehicle_mode == 1
- && r->f20 == ((Hero *)(D_hero_2E52B0))->moby) {
+ if (((Hero *)(D_0013F350))->vehicle_mode == 1
+ && r->f20 == ((Hero *)(D_0013F350))->moby) {
B = 0.0f;
v21 = 11;
}
}
if (r->h2A == 0x47) {
- *(u128_2E52B0 *)&vA = *(u128_2E52B0 *)(D_hero_2E52B0 + 0x80);
+ *(u128_2E52B0 *)&vA = *(u128_2E52B0 *)(D_0013F350 + 0x80);
*(u128_2E52B0 *)&vB = *(u128_2E52B0 *)((V_2E52B0 *)&m->pos);
vA.z += 1.0f;
vB.z += 1.0f;
@@ -2205,7 +2205,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_hero_2E52B0))->vehicle_mode == 1 ? 1.0f : 3.0f;
+ s = ((Hero *)(D_0013F350))->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 +2235,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_hero_2E52B0))->unk240) || m == ((Moby *)((Hero *)(D_hero_2E52B0))->coll_hit_moby)) {
+ if (m == ((Moby *)((Hero *)(D_0013F350))->unk240) || m == ((Moby *)((Hero *)(D_0013F350))->coll_hit_moby)) {
d->f1A0 = 6.0f;
} else {
d->f1A0 = 0.0f;
}
- if (((Hero *)(D_hero_2E52B0))->vehicle_mode == 1) func_L10_002E14F8_2E52B0(m);
+ if (((Hero *)(D_0013F350))->vehicle_mode == 1) func_L10_002E14F8_2E52B0(m);
} else {
d->f1A0 = D_L10_00161E40_gp;
}
@@ -2262,7 +2262,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_hero_2E52B0))->vehicle_mode != 1) {
+ } else if (((Hero *)(D_0013F350))->vehicle_mode != 1) {
m->state = 1;
if (m->prev_seq != 0) func_00213DE0_2E52B0(m, 0, 0, func_001F9850_2E52B0(20));
}
@@ -2270,7 +2270,7 @@ void FUN_L10_002e3ef0(void *mv) {
} else {
d->f1D4 = 0;
}
- if (d->f160 == 0) d->f160 = ((Hero *)(D_hero_2E52B0))->moby;
+ if (d->f160 == 0) d->f160 = ((Hero *)(D_0013F350))->moby;
}
#define NOT_SDA
@@ -2326,270 +2326,342 @@ float FUN_L10_002e4840(struct Moby *self) {
return fast_add_rotations(
fast_add_rotations(lo, fast_difference_between_rotations(hi, lo) * 0.5f), ang);
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L10_002e4a88.s", FUN_L10_002e4a88);
-#else
-extern void FUN_L10_002e5968(Moby *);
-extern float scale_time_4a88(float) __asm__("FUN_L10_001f2578");
-extern void scale_vector_xyz(float *, float *, float) __asm__("FUN_001f9a68");
-extern f32 frame_time_absolute_4a88 __asm__("D_L10_0015ED6C") __attribute__((section(".sdata")));
+/* Update for the blarg ship (moby class 1229): rise, follow its path, hover and fire at the target, fly off or explode. */
+/* Ported from rac1-decomp (src/overlays/l10_orxon/vendor_002E30F8.c: func_L10_002E5E48), where it is exact; names translated to the US level program. */
-extern void debug_print(const char *, ...) __asm__("FUN_001e93b0");
+typedef struct Ship_5E48 {
+ char p00[0x10];
+ V_2E52B0 pos;
+ unsigned char state;
+ char p21[3];
+ char *p24;
+ char p28[4];
+ float f2C;
+ char p30;
+ unsigned char b31;
+ short s32;
+ unsigned short s34;
+ char p36[0xE];
+ float f44;
+ float f48;
+ char p4C[6];
+ unsigned char b52;
+ unsigned char b53;
+ char p54[4];
+ float f58;
+ char p5C[0x14];
+ unsigned char b70;
+ char p71[7];
+ struct ShipD_5E48 *d;
+ char p7C[3];
+ unsigned char b7F;
+ char p80[0x14];
+ int i94;
+ char p98[0xE];
+ short sA6;
+ unsigned short hA8;
+ char pAA[6];
+ unsigned char bB0;
+ char pB1[0xB];
+ unsigned char bBC;
+} Ship_5E48;
+
+typedef struct ShipD_5E48 {
+ char p0[0x20];
+ float f20;
+ short s24;
+ char p26[2];
+ unsigned char b28;
+ unsigned char b29;
+ char p2A[0x16];
+ char a40[0xB0];
+ V_2E52B0 vF0;
+ char p100[0x10];
+ Ship_5E48 *tgt;
+ int i114;
+ char p118[8];
+ V_2E52B0 a120;
+ char p130[0x10];
+ int i140;
+ int i144;
+ int i148;
+ char p14C[0xC];
+ int i158;
+ char p15C[4];
+ float f160;
+ float f164;
+ int i168;
+ char p16C[0x2A];
+ short s196;
+ float f198;
+ float f19C;
+ char p1A0[0x10];
+ int i1B0;
+ char p1B4[0x1C];
+ unsigned char a1D0[4];
+} ShipD_5E48;
+
+extern Ship_5E48 *D_L10_001742D8 __attribute__((section(".data")));
+extern char *FUN_L10_002cc1b8(void *vel, void *pos, int a, int b, int c, float scale);
+extern char D_L10_00179890[];
extern char D_L10_001DD390[];
-extern s32 D_L10_00161EE4 __attribute__((sda));
-extern f32 D_L10_00161EE8 __attribute__((sda));
-extern f32 D_L10_00161EEC __attribute__((sda));
-extern f32 frame_time_gp_4a88 __asm__("D_0015ED6C") __attribute__((sda));
-extern char D_L10_00179910_2E9978[] __asm__("D_L10_00179890");
-extern s32 D_L10_001798B4;
-extern s32 D_L10_001742D8 __attribute__((section(".data")));
+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 *);
+extern float probe_ground_height_c2(void *, int, float) __asm__("func_00213508");
+extern float vector_distance_xy_alt(void *, void *) __asm__("FUN_001f9b80");
+extern int FUN_L00_00203908_c(int a, int b) __asm__("FUN_L00_00203908");
+extern int is_point_inside_clip_volume(void *arg0, int arg1) __asm__("func_00214720");
+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 unsigned char D_0013D4CB[];
extern unsigned char D_001413F4[];
+extern unsigned char D_0014161B[];
extern unsigned char D_00141C48[];
-extern unsigned char D_0013D4CB[];
-extern int is_point_inside_clip_volume(void *, int) __asm__("FUN_00214720");
-extern int is_value_within_interpolated_window(Moby *, float) __asm__("FUN_00214cc8");
-extern float FUN_L00_00258110(float *, float, float, float, float, float);
-extern void normalize_vector_xyz(void *, void *, float) __asm__("FUN_001f9bf8");
-extern void build_spherical_offset(float *, float, float, float) __asm__("FUN_00214db0");
-extern void FUN_L03_00250ae8(void *, void *, int);
-extern void FUN_L10_002cc1b8(float, void *, void *, void *, void *, int);
-extern int FUN_L00_00203908(int, int);
+extern void *FUN_L00_00263fd8_c(char *, int, float *, void *, int, int, float, float *, float *, float *) __asm__("FUN_L00_00263fd8");
+extern void DebugPrint(char *, ...);
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 FUN_L00_0025f730_c(void *, float) __asm__("FUN_L00_0025f730");
+extern void FUN_L03_00250ae8(void *, void *, int);
+extern void FUN_L10_002e5968_c(char *m) __asm__("FUN_L10_002e5968");
+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_spherical_offset_c(void *, f32, f32, f32) __asm__("func_00214DB0");
+extern void fast_vec_normalize_c(void *, void *, f32) __asm__("FUN_001f9bf8");
+extern void fast_vec_scale(void *, void *, f32) __asm__("func_001F9A68");
+extern void mark_moby_for_removal_c2(void *) __asm__("func_0020C828");
+s32 is_value_within_interpolated_window(void *anim, f32 value) __asm__("FUN_00214cc8");
+extern int D_0015ED84;
+extern void fast_vec_normalize(void *, void *, float) __asm__("FUN_001f9bf8");
-void FUN_L10_002e4a88(Moby *moby)
-{
- Vec4 waypoint, velocity, position, offset, end;
- unsigned char *data = moby->pvars;
- Moby *target;
- int node_index;
- int a, b;
- float angle, distance, timer;
- float *moby_position;
-
- FUN_L00_00263ac8(2.5f, (int)moby, 2, data + 0x1D0);
- if (*(int *)(data + 0x140) == -1) {
- debug_print(D_L10_001DD390, moby->oclass, *(unsigned short *)moby->padA8);
- goto remove;
- }
- FUN_L10_002e5968(moby);
- target = *(Moby **)(data + 0x110);
- switch (moby->state) {
+void FUN_L10_002e4a88(Ship_5E48 *m) {
+ ShipD_5E48 *d = m->d;
+ Ship_5E48 *tgt;
+ V_2E52B0 A;
+ V_2E52B0 B;
+ V_2E52B0 C;
+ V_2E52B0 E;
+ V_2E52B0 D;
+ float a;
+ float b;
+
+ FUN_L00_00263ac8(2.5f, (int)m, 2, d->a1D0);
+ if (d->i140 == -1) {
+ DebugPrint(D_L10_001DD390, m->sA6, m->hA8);
+ goto del;
+ }
+ FUN_L10_002e5968_c((char *)m);
+ tgt = d->tgt;
+ switch (m->state) {
case 0:
- moby->flags |= 0x1000;
- *(float *)(data + 0x20) = 9.0f;
- *(short *)(data + 0x24) = truncate_float_to_s32(9.0f);
- data[0x28] = 3;
- data[0x29] = 0;
- *(float *)(data + 0x19C) = 0.0f;
- moby->draw_dist = 0x7F;
- qcopy(&moby->pos, ((int **)D_L10_001B0C30_2E52B0)[*(int *)(data + 0x140)] + 4);
- *(short *)(data + 0x196) = scale_game_frames(D_L10_00161EE4);
- moby->collision = 0;
- moby->flags |= 0x41;
- if (moby->prev_seq != 0) blend_moby_animation(moby, 0, 0, 0);
- moby->state = 1;
- if (D_0014C050[moby->mission + current_level_index * 16] != 0xFF) goto update_visibility;
- goto remove;
+ m->s34 |= 0x1000;
+ d->f20 = 9.0f;
+ d->s24 = truncate_float_to_s32_c2(9.0f);
+ d->b28 = 3;
+ d->b29 = 0;
+ 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);
+ m->i94 = 0;
+ m->s34 |= 0x41;
+ if (m->b53 != 0) blend_moby_animation(m, 0, 0, 0);
+ m->state = 1;
+ if (D_0014C050[m->bB0 + (D_0015ED84 << 4)] != 0xFF) break;
+ goto del;
case 1:
- if (is_point_inside_clip_volume(&target->pos, *(int *)(data + 0x148))) {
- moby->state = 2;
- if (moby->prev_seq != 1) blend_moby_animation(moby, 1, 0, scale_game_frames(20));
- moby->flags &= 0xFFBE;
- moby->collision = *(int *)((char *)moby->pclass + 0x10);
- if (*(int *)D_L10_00179910_2E9978 == 0 && *(int *)(D_L10_00179910_2E9978 + 0x24) == -1 && D_001413F4[0] == 0 &&
- *(unsigned short *)D_00141C48 == 0 && D_0013D4CB[0] == 0) FUN_L00_00203908(10005, 92);
+ if (!is_point_inside_clip_volume(&tgt->pos, d->i148)) break;
+ m->state = 2;
+ if (m->b53 != 1) blend_moby_animation(m, 1, 0, scale_game_frames_c2(20));
+ m->s34 &= 0xFFBE;
+ m->i94 = *(int *)(m->p24 + 0x10);
+ if (*(int *)D_L10_00179890 == 0 && *(int *)(D_L10_00179890 + 0x24) == -1
+ && D_001413F4[0] == 0 && *(unsigned short *)D_00141C48 == 0
+ && D_0013D4CB[0] == 0) {
+ FUN_L00_00203908_c(0x2715, 0x5C);
}
break;
- case 2: {
- float timer;
- float *moby_position;
- moby_position = &moby->pos.x;
- angle = FUN_001f9e90(target->pos.x - moby->pos.x, target->pos.y - moby->pos.y);
- FUN_L00_00258278((char *)moby, (float *)(data + 0x198), angle, 0.02f, 0.3f, frame_time_absolute_4a88 * 3.1415927f);
- distance = FUN_001f9b80(moby_position, &target->pos);
- angle = FUN_001f9e90(distance, target->pos.z - moby->pos.z);
- moby->rot.y = FUN_L00_00258110((float *)(data + 0x19C), moby->rot.y, -angle, 0.02f, 0.3f, frame_time_absolute_4a88 * 3.1415927f);
- if ((moby->anim_flags & 2) != 0) {
- timer = frame_time_gp_4a88;
- if (moby->prev_seq != 1) goto rise;
- blend_moby_animation(moby, 2, 0, scale_game_frames(20));
- }
- timer = frame_time_absolute_4a88;
-rise:
- moby->pos.z += timer * 4.0f;
- if (FUN_001f9b48(&moby->pos, ((int **)D_L10_001B0C30_2E52B0)[*(int *)(data + 0x140)] + 4) < 0.5f) {
- moby->state = 3;
- if (moby->prev_seq != 2) blend_moby_animation(moby, 2, 0, scale_game_frames(10));
+ case 2:
+ a = fast_arc_tan(tgt->pos.x - m->pos.x, tgt->pos.y - m->pos.y);
+ FUN_L00_00258278((char *)m, &d->f198, a, 0.02f, 0.3f, D_0015ED6C * 3.1415927f);
+ b = fast_arc_tan(vector_distance_xy_alt(&m->pos, &tgt->pos), tgt->pos.z - m->pos.z);
+ m->f44 = FUN_L00_00258110_c(&d->f19C, m->f44, -b, 0.02f, 0.3f, D_0015ED6C * 3.1415927f);
+ if ((m->b70 & 2) && m->b53 == 1) blend_moby_animation(m, 2, 0, scale_game_frames_c2(20));
+ m->pos.z += D_0015ED6C * 4.0f;
+ if (fast_vec_dist(&m->pos, &D_L10_001B0C30_2E52B0[d->i140]->nodes[0]) < 0.5f) {
+ m->state = 3;
+ if (m->b53 != 2) blend_moby_animation(m, 2, 0, scale_game_frames_c2(10));
}
break;
- }
- case 3: {
- int node_index;
- float *moby_position;
- qcopy(&waypoint, ((int **)D_L10_001B0C30_2E52B0)[*(int *)(data + 0x140)] + *(int *)(data + 0x158) * 4 + 4);
- moby_position = &moby->pos.x;
- angle = FUN_001f9e90(waypoint.f[0] - moby->pos.x, waypoint.f[1] - moby->pos.y);
- FUN_L00_00258278((char *)moby, (float *)(data + 0x198), angle, 0.02f, 0.3f, frame_time_absolute_4a88 * 12.566371f);
- distance = FUN_001f9b80(moby_position, &target->pos);
- angle = FUN_001f9e90(distance, target->pos.z - moby->pos.z);
- moby->rot.y = FUN_L00_00258110((float *)(data + 0x19C), moby->rot.y, -angle, 0.02f, 0.3f, frame_time_absolute_4a88 * 3.1415927f);
- fast_vec_sub(&velocity, &waypoint, moby_position);
- normalize_vector_xyz(data + 0x120, &velocity, frame_time_absolute_4a88 * 8.0f);
- fast_vec_add(moby_position, moby_position, data + 0x120);
- if (!(fast_vec_length(&velocity) < 0.5f)) break;
- node_index = *(int *)(data + 0x158) + 1;
- if (node_index < *((int **)D_L10_001B0C30_2E52B0)[*(int *)(data + 0x140)]) {
- *(int *)(data + 0x158) = node_index;
- } else {
- *(int *)(data + 0x158) = 0;
- moby->state = 4;
- timer = *(float *)(data + 0x160) * 60.0f;
- goto set_timer;
+ case 3:
+ qcopy(&A, &D_L10_001B0C30_2E52B0[d->i140]->nodes[d->i158]);
+ a = fast_arc_tan(A.x - m->pos.x, A.y - m->pos.y);
+ FUN_L00_00258278((char *)m, &d->f198, a, 0.02f, 0.3f, D_0015ED6C * 12.566371f);
+ b = fast_arc_tan(vector_distance_xy_alt(&m->pos, &tgt->pos), tgt->pos.z - m->pos.z);
+ m->f44 = FUN_L00_00258110_c(&d->f19C, m->f44, -b, 0.02f, 0.3f, D_0015ED6C * 3.1415927f);
+ func_001F9BF0_2E52B0(&B, &A, &m->pos);
+ fast_vec_normalize(&d->a120, &B, D_0015ED6C * 8.0f);
+ add_vector_xyz_c3(&m->pos, &m->pos, &d->a120);
+ if (fast_vec_length_c(&B) < 0.5f) {
+ int n = d->i158 + 1;
+ if (n < D_L10_001B0C30_2E52B0[d->i140]->count) {
+ d->i158 = n;
+ } else {
+ d->i158 = 0;
+ m->state = 4;
+ d->i168 = truncate_float_to_s32_c2(FUN_001f96b0(d->f160 * 60.0f));
+ }
}
break;
- }
case 4:
- if (is_point_inside_clip_volume(&hero.motion.pos, *(int *)(data + 0x1B0))) {
- moby->state = 6;
+ if (is_point_inside_clip_volume(&(&hero)->motion.pos, d->i1B0)) {
+ m->state = 6;
break;
}
- waypoint.q = *(u128 *)&target->pos;
- if (hero.vehicle_mode != 1) {
- waypoint.q = *(u128 *)(data + 0xF0);
- moby_position = &moby->pos.x;
- FUN_001efa68(moby_position, &waypoint, 0, moby, 0);
+ *(u128_2E52B0 *)&A = *(u128_2E52B0 *)&tgt->pos;
+ if ((&hero)->vehicle_mode != 1) {
+ *(u128_2E52B0 *)&A = *(u128_2E52B0 *)&d->vF0;
+ FUN_001efa68(&m->pos, &A, 0, m, 0);
} else {
- if (hero.moby == target) {
- scale_vector_xyz(position.f, hero.motion.displacement.f, (float)scale_game_frames(20));
- velocity.q = position.q;
- FUN_L00_001ff290(&position, &waypoint, &velocity);
- waypoint.f[2] = probe_ground_height(&waypoint, 0, 0.5f);
+ if ((Ship_5E48 *)(&hero)->moby == tgt) {
+ fast_vec_scale(&C, &(&hero)->motion.displacement, (float)scale_game_frames_c2(20));
+ *(u128_2E52B0 *)&B = *(u128_2E52B0 *)&C;
+ FUN_L00_001ff290(&C, &A, &B);
+ A.z = probe_ground_height_c2(&A, 0, 0.5f);
}
- waypoint.f[2] += 0.2f;
- D_L10_001742D8 = (int)target;
- moby_position = &moby->pos.x;
- }
- angle = FUN_001f9e90(target->pos.x - moby->pos.x, target->pos.y - moby->pos.y);
- FUN_L00_00258278((char *)moby, (float *)(data + 0x198), angle, 0.02f, 0.3f, frame_time_absolute_4a88 * 12.566371f);
- distance = FUN_001f9b80(moby_position, &waypoint);
- angle = FUN_001f9e90(distance, waypoint.f[2] - moby->pos.z);
- moby->rot.y = FUN_L00_00258110((float *)(data + 0x19C), moby->rot.y, -angle, 0.02f, 0.3f, frame_time_absolute_4a88 * 3.1415927f);
- angle = FUN_001f9e90(target->pos.x - moby->pos.x, target->pos.y - moby->pos.y);
- if (fast_difference_between_rotations(moby->rot.z, angle) < 0.17453292f) {
- if (moby->prev_seq != 3) blend_moby_animation(moby, 3, 0, scale_game_frames(6));
- moby->anim_speed = D_L10_00161EEC;
- }
- if (moby->seq == 3) {
- if (*(int *)(data + 0x114) != 2 && D_L10_001742D8 == (int)target) {
- a = is_value_within_interpolated_window(moby, 1.0f);
- b = is_value_within_interpolated_window(moby, 16.0f);
- if (a || b) {
- moby_point_position(moby, b == 0, &position);
- build_spherical_offset(velocity.f, 1.0f, moby->rot.z, -moby->rot.y);
- FUN_L00_001ff290(&end, &position, &velocity);
- fast_vec_sub(&velocity, &waypoint, &position);
- normalize_vector_xyz(&velocity, &velocity, D_L10_00161EE8 * frame_time);
- scale_vector_xyz(offset.f, velocity.f, scale_time_4a88(3.0f));
- FUN_L00_001ff290(&end, &offset, &position);
- FUN_L03_00250ae8(moby, &offset, 0);
- FUN_L10_002cc1b8(1.0f, &velocity, &position, moby, target, scale_game_frames(300));
- }
- } else {
- if (moby->seq == 3 && moby->prev_seq != 2) blend_moby_animation(moby, 2, 0, scale_game_frames(10));
+ A.z += 0.2f;
+ D_L10_001742D8 = tgt;
+ }
+ a = fast_arc_tan(tgt->pos.x - m->pos.x, tgt->pos.y - m->pos.y);
+ FUN_L00_00258278((char *)m, &d->f198, a, 0.02f, 0.3f, D_0015ED6C * 12.566371f);
+ b = fast_arc_tan(vector_distance_xy_alt(&m->pos, &A), A.z - m->pos.z);
+ 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;
+ }
+ if (m->b52 == 3 && d->i114 != 2 && D_L10_001742D8 == tgt) {
+ int near = is_value_within_interpolated_window((char *)m, 1.0f);
+ int far = is_value_within_interpolated_window((char *)m, 16.0f);
+ if (near || far) {
+ FUN_L00_0024f7c8(m, far == 0, &C);
+ 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_scale(&E, &B, FUN_001f96b0(3.0f));
+ FUN_L00_001ff290(&D, &E, &C);
+ FUN_L03_00250ae8(m, &E, 0);
+ FUN_L10_002cc1b8(&B, &C, (int)m, (int)tgt, scale_game_frames_c2(300), 1.0f);
}
+ } else if (m->b52 == 3 && m->b53 != 2) {
+ blend_moby_animation(m, 2, 0, scale_game_frames_c2(10));
}
- if (tick_countdown_32(data + 0x168)) {
- if (moby->prev_seq != 2) blend_moby_animation(moby, 2, 0, scale_game_frames(10));
- moby->state = 5;
- timer = *(float *)(data + 0x164) * 60.0f;
- goto set_move_timer;
+ if (tick_countdown_32_alt(&d->i168)) {
+ if (m->b53 != 2) blend_moby_animation(m, 2, 0, scale_game_frames_c2(10));
+ m->state = 5;
+ d->i168 = truncate_float_to_s32_c2(FUN_001f96b0(d->f164 * 60.0f));
+ }
+ qcopy(&B, &D_L10_001B0C30_2E52B0[d->i144]->nodes[d->i158]);
+ func_001F9BF0_2E52B0(&C, &B, &m->pos);
+ FUN_L00_0025f730_c(&C, D_0015ED6C * 8.0f);
+ add_vector_xyz_c3(&m->pos, &m->pos, &C);
+ if (fast_vec_length_c(&C) < D_0015ED6C) {
+ int n = d->i158 + 1;
+ if (n < D_L10_001B0C30_2E52B0[d->i144]->count) d->i158 = n;
}
- goto move_path;
+ break;
case 5:
- if (is_point_inside_clip_volume(&hero.motion.pos, *(int *)(data + 0x1B0))) {
- moby->state = 6;
+ if (is_point_inside_clip_volume(&(&hero)->motion.pos, d->i1B0)) {
+ m->state = 6;
break;
}
- waypoint.q = *(u128 *)&target->pos;
- if (hero.vehicle_mode != 1) {
- waypoint.q = *(u128 *)(data + 0xF0);
- moby_position = &moby->pos.x;
- FUN_001efa68(moby_position, &waypoint, 0, moby, 0);
+ *(u128_2E52B0 *)&A = *(u128_2E52B0 *)&tgt->pos;
+ if ((&hero)->vehicle_mode != 1) {
+ *(u128_2E52B0 *)&A = *(u128_2E52B0 *)&d->vF0;
+ FUN_001efa68(&m->pos, &A, 0, m, 0);
} else {
- if (hero.moby == target) {
- scale_vector_xyz(position.f, hero.motion.displacement.f, (float)scale_game_frames(20));
- velocity.q = position.q;
- FUN_L00_001ff290(&position, &waypoint, &velocity);
- waypoint.f[2] = probe_ground_height(&waypoint, 0, 0.5f);
+ if ((Ship_5E48 *)(&hero)->moby == tgt) {
+ fast_vec_scale(&C, &(&hero)->motion.displacement, (float)scale_game_frames_c2(20));
+ *(u128_2E52B0 *)&B = *(u128_2E52B0 *)&C;
+ FUN_L00_001ff290(&C, &A, &B);
+ A.z = probe_ground_height_c2(&A, 0, 0.5f);
}
- waypoint.f[2] += 0.2f;
- D_L10_001742D8 = (int)target;
- moby_position = &moby->pos.x;
- }
- angle = FUN_001f9e90(target->pos.x - moby->pos.x, target->pos.y - moby->pos.y);
- FUN_L00_00258278((char *)moby, (float *)(data + 0x198), angle, 0.02f, 0.3f, frame_time_absolute_4a88 * 12.566371f);
- distance = FUN_001f9b80(moby_position, &waypoint);
- angle = FUN_001f9e90(distance, waypoint.f[2] - moby->pos.z);
- moby->rot.y = FUN_L00_00258110((float *)(data + 0x19C), moby->rot.y, -angle, 0.02f, 0.3f, frame_time_absolute_4a88 * 3.1415927f);
- if (tick_countdown_32(data + 0x168)) {
- blend_moby_animation(moby, 3, 0, scale_game_frames(10));
- moby->state = 4;
- moby->anim_speed = D_L10_00161EEC;
- timer = *(float *)(data + 0x160) * 60.0f;
-set_move_timer:
- *(int *)(data + 0x168) = truncate_float_to_s32(scale_time_4a88(timer));
- }
-move_path:
- qcopy(&velocity, ((int **)D_L10_001B0C30_2E52B0)[*(int *)(data + 0x144)] + *(int *)(data + 0x158) * 4 + 4);
- fast_vec_sub(&position, &velocity, moby_position);
- FUN_L00_0025f730(&position, frame_time_absolute_4a88 * 8.0f);
- fast_vec_add(moby_position, moby_position, &position);
- if (!(fast_vec_length(&position) < frame_time_absolute_4a88)) break;
- node_index = *(int *)(data + 0x158) + 1;
- if (node_index < *((int **)D_L10_001B0C30_2E52B0)[*(int *)(data + 0x144)]) *(int *)(data + 0x158) = node_index;
+ A.z += 0.2f;
+ D_L10_001742D8 = tgt;
+ }
+ a = fast_arc_tan(tgt->pos.x - m->pos.x, tgt->pos.y - m->pos.y);
+ FUN_L00_00258278((char *)m, &d->f198, a, 0.02f, 0.3f, D_0015ED6C * 12.566371f);
+ b = fast_arc_tan(vector_distance_xy_alt(&m->pos, &A), A.z - m->pos.z);
+ 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->state = 4;
+ d->i168 = truncate_float_to_s32_c2(FUN_001f96b0(d->f160 * 60.0f));
+ }
+ qcopy(&B, &D_L10_001B0C30_2E52B0[d->i144]->nodes[d->i158]);
+ func_001F9BF0_2E52B0(&C, &B, &m->pos);
+ FUN_L00_0025f730_c(&C, D_0015ED6C * 8.0f);
+ add_vector_xyz_c3(&m->pos, &m->pos, &C);
+ if (fast_vec_length_c(&C) < D_0015ED6C) {
+ int n = d->i158 + 1;
+ if (n < D_L10_001B0C30_2E52B0[d->i144]->count) d->i158 = n;
+ }
break;
case 6:
- moby->pos.z += frame_time_absolute_4a88 * 10.0f;
- moby->scale *= frame_scale * -0.015299976f + 1.0f;
- if (250.0f < moby->pos.z || moby->scale < 0.01f) goto remove;
- break;
- case 7:
- if (moby->seq != 4 || !(moby->anim_flags & 2)) break;
- node_index = moby->command;
- if (node_index == 4) {
- blend_moby_animation(moby, 3, 0, scale_game_frames(10));
- moby->state = node_index;
- moby->anim_speed = D_L10_00161EEC;
- timer = *(float *)(data + 0x160) * 60.0f;
- } else if (node_index == 6) {
- blend_moby_animation(moby, 2, 0, scale_game_frames(10));
- moby->state = node_index;
- break;
+ m->pos.z += D_0015ED6C * 10.0f;
+ m->f2C *= D_0015ED60 * -0.015299976f + 1.0f;
+ if (250.0f < m->pos.z) goto del;
+ if (!(m->f2C < 0.01f)) break;
+ goto del;
+ case 7: {
+ unsigned char next;
+ if (m->b52 != 4) break;
+ if (!(m->b70 & 2)) break;
+ next = m->bBC;
+ if (next == 4) {
+ blend_moby_animation(m, 3, 0, scale_game_frames_c2(10));
+ m->f58 = *(float *)&D_L10_00161EEC;
+ m->state = next;
+ d->i168 = truncate_float_to_s32_c2(FUN_001f96b0(d->f160 * 60.0f));
+ } else if (next == 6) {
+ blend_moby_animation(m, 2, 0, scale_game_frames_c2(10));
+ m->state = next;
} else {
- blend_moby_animation(moby, 2, 0, scale_game_frames(10));
- moby->state = 5;
- timer = *(float *)(data + 0x164) * 60.0f;
+ blend_moby_animation(m, 2, 0, scale_game_frames_c2(10));
+ m->state = 5;
+ d->i168 = truncate_float_to_s32_c2(FUN_001f96b0(d->f164 * 60.0f));
}
-set_timer:
- *(int *)(data + 0x168) = truncate_float_to_s32(scale_time_4a88(timer));
break;
- case 8:
- moby_position = &moby->pos.x;
- FUN_L00_0025e450(moby, data + 0x40, moby_position, 0.0f, 0.0f, 5, 2, 4, 2.0f, 1.0f, 9.0f, 1.0f, 5, 15.0f, 1, 1, -1, 0);
- FUN_L00_00257470(moby, 0, -1);
- FUN_L00_00263fd8((char *)moby, 0x5FD, moby_position, &moby->rot, 0, 0, 0.0f, D_L10_0015F580, D_L10_0015F580, D_L10_0015F580);
- FUN_L00_00263fd8((char *)moby, 0x5FE, moby_position, &moby->rot, 0, 0, 0.0f, D_L10_0015F580, D_L10_0015F580, D_L10_0015F580);
-remove:
- mark_moby_for_removal_c(moby);
+ }
+ case 8: {
+ float z = 0.0f;
+ FUN_L00_0025e450(m, d->a40, &m->pos, z, z, 5, 2, 4, 2.0f, 1.0f, 9.0f, 1.0f, 5, 15.0f, 1, 1, -1, 0);
+ FUN_L00_00257470(m, 0, -1);
+ FUN_L00_00263fd8_c((char *)m, 0x5FD, (float *)&m->pos, (char *)m + 0x40, 0, 0, 0.0f, D_L10_0015F580, D_L10_0015F580, D_L10_0015F580);
+ FUN_L00_00263fd8_c((char *)m, 0x5FE, (float *)&m->pos, (char *)m + 0x40, 0, 0, 0.0f, D_L10_0015F580, D_L10_0015F580, D_L10_0015F580);
+ mark_moby_for_removal_c2(m);
return;
+ del:
+ mark_moby_for_removal_c2(m);
+ return;
+ }
}
-update_visibility:
- if (moby->visible != 0 && FUN_001f9b48(&moby->pos, D_L10_00167240) < 28.0f) {
- FUN_L00_0025a120(moby);
- moby->shadow_range = 0x16;
+ if (m->b31 != 0) {
+ if (fast_vec_dist(&m->pos, D_L10_00167240) < 28.0f) {
+ FUN_L00_0025a120(m);
+ m->b7F = 0x16;
+ }
}
}
-#endif
/* Hit handling and path following for a level 10 vendor moby. */
extern char *info_5968(void *, int, int) __asm__("FUN_L00_0025a420");
extern void seek_5968(float, void *, void *) __asm__("FUN_L06_002f34d8");
@@ -2883,7 +2955,7 @@ extern int func_00215570_2E9978(void *arg0, int arg1) __asm__("FUN_00214720");
extern int func_L00_00203F20_2E9978(int a, int b) __asm__("FUN_L00_00203908");
extern float func_001F9D48_2E9978(void *, void *) __asm__("FUN_001f9b80");
extern int func_001F9850_2E9978(int) __asm__("FUN_001f96f8");
-extern char D_L10_00179910_2E9978[] __asm__("D_L10_00179890");
+extern char D_L10_00179890[];
extern char D_0013E633_2E9978[] __asm__("D_00141B20");
extern unsigned char D_0014171B_2E9978[] __asm__("D_0013D504");
extern unsigned char D_0013D5CA_2E9978[] __asm__("D_0015EEA4") __attribute__((sda));
@@ -2914,15 +2986,15 @@ void FUN_L10_002e85b8(Moby *moby)
case 1:
if (func_00215570_2E9978(D_0013F3D0_r, data->f0) != 0
&& (((HeroPos_2E9978 *)(D_0013F3D0_r))->f200C < 2 || ((HeroPos_2E9978 *)(D_0013F3D0_r))->f200C == 9)
- && ((Msg_2E9978 *)D_L10_00179910_2E9978)->f0 == 0
- && ((Msg_2E9978 *)D_L10_00179910_2E9978)->f24 == -1
+ && ((Msg_2E9978 *)D_L10_00179890)->f0 == 0
+ && ((Msg_2E9978 *)D_L10_00179890)->f24 == -1
&& *(unsigned short *)(D_00141B10) == 0) {
func_L00_00203F20_2E9978(0x2710, 0x35);
}
if (func_00215570_2E9978(D_0013F3D0_r, data->f4) != 0
&& (((HeroPos_2E9978 *)(D_0013F3D0_r))->f200C < 2 || ((HeroPos_2E9978 *)(D_0013F3D0_r))->f200C == 9)
- && ((Msg_2E9978 *)D_L10_00179910_2E9978)->f0 == 0
- && ((Msg_2E9978 *)D_L10_00179910_2E9978)->f24 == -1) {
+ && ((Msg_2E9978 *)D_L10_00179890)->f0 == 0
+ && ((Msg_2E9978 *)D_L10_00179890)->f24 == -1) {
if (((Flags_2E9978 *)(D_0013D388_r))->f4 == 0) {
if (*(unsigned short *)(D_00141B20_r) == 0) {
func_L00_00203F20_2E9978(0x2712, 0x37);
@@ -2934,16 +3006,16 @@ void FUN_L10_002e85b8(Moby *moby)
}
}
if (D_L10_0015F5C4_vendor == 0 && D_0013D504_r[0] != 0
- && ((Msg_2E9978 *)D_L10_00179910_2E9978)->f0 == 0
- && ((Msg_2E9978 *)D_L10_00179910_2E9978)->f24 == -1
+ && ((Msg_2E9978 *)D_L10_00179890)->f0 == 0
+ && ((Msg_2E9978 *)D_L10_00179890)->f24 == -1
&& *(unsigned short *)(D_00141B18) == 0) {
func_L00_00203F20_2E9978(0x2711, 0x36);
}
if (func_00215570_2E9978(D_0013F3D0_r, data->f8) != 0
&& (((HeroPos_2E9978 *)(D_0013F3D0_r))->f200C < 2 || ((HeroPos_2E9978 *)(D_0013F3D0_r))->f200C == 9)
&& D_0013D4CB[0] == 0
- && ((Msg_2E9978 *)D_L10_00179910_2E9978)->f0 == 0
- && ((Msg_2E9978 *)D_L10_00179910_2E9978)->f24 == -1
+ && ((Msg_2E9978 *)D_L10_00179890)->f0 == 0
+ && ((Msg_2E9978 *)D_L10_00179890)->f24 == -1
&& *(unsigned short *)(D_00141C48) == 0) {
func_L00_00203F20_2E9978(0x2715, 0x5C);
}
diff --git a/src/overlays/l12/gameplay/entities/003054b0.c b/src/overlays/l12/gameplay/entities/003054b0.c
new file mode 100644
index 0000000000..e7fbd920c1
--- /dev/null
+++ b/src/overlays/l12/gameplay/entities/003054b0.c
@@ -0,0 +1,1338 @@
+#include "rnc/gameplay/hero.h"
+#include "rnc/audio/voice_pool.h"
+#include "types.h"
+#include "rnc/overlay/level_globals.h"
+#include "rnc/globals.h"
+#include "rnc/gameplay/entities/moby.h"
+#include "asm.h"
+#include "rnc/overlay/entities.h"
+
+#include "rnc/math/vector.h"
+
+#include "qcopy.h"
+
+typedef struct Moby Moby;
+
+extern float D_0015ED6C;
+extern char *D_L12_0015FFD8_gp __asm__("D_L12_0015FFD8") __attribute__((section(".sdata")));
+
+/* Hoven turret battery update: aims each manned gun at the hero, fires, takes hits and smokes when damaged. */
+/* Ported from rac1-decomp (src/overlays/l12_hoven/vendor_002EDAA0.c: func_L12_00306890), where it is exact; names translated to the US level program. */
+
+typedef struct Hero Hero;
+
+typedef struct {
+ char pad0[0x60];
+ float f60;
+ char pad64[0x1C];
+ float f80;
+ int w84;
+ char pad88[4];
+ float f8C;
+ short h90;
+ char b92;
+ char b93;
+ char pad94[4];
+ short h98;
+ short h9A;
+ short h9C;
+ short h9E;
+} Gun_306890;
+
+extern char *FUN_L00_0025a420(void *, int, int);
+extern char 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");
+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_c(f32, f32) __asm__("func_002132A8");
+extern float D_0015ED64 __attribute__((section(".sdata")));
+extern float D_0015ED6C_gp __asm__("D_0015ED6C") __attribute__((section(".sdata")));
+extern float FUN_L00_00257c48(float, float);
+extern float FUN_L00_0025bc00(float *, float, int, float);
+extern float FUN_L00_0025bc98(void *, float, void *, int, float, float, float);
+extern float fast_add_rotations(float, float) __asm__("func_001FA580");
+extern float fast_difference_between_rotations(float, float) __asm__("func_001FA688");
+extern float vector_distance_xy_alt(void *, void *) __asm__("FUN_001f9b80");
+extern int D_L12_00161F00;
+extern int D_L12_00161F04;
+extern int D_L12_00161F20 __attribute__((section(".sdata")));
+extern int D_L12_00161F24 __attribute__((section(".sdata")));
+extern int D_L12_00161F34 __attribute__((sda));
+extern int D_L12_001FB670[];
+extern int D_L12_001FB688[];
+extern int FUN_001f9770(void *);
+extern int FUN_L00_001fefc8(void *);
+extern int FUN_L00_00257b90(int, int);
+extern int tick_countdown_32_alt(int *) __asm__("FUN_001f9740");
+extern s32 scale_game_frames(s32) __asm__("func_001F96F8");
+extern s32 truncate_float_to_s32(f32) __asm__("func_001FA6D0");
+extern void *FUN_L04_002aee30(void *, void *, void *, int);
+extern void FUN_L00_0024f7c8(void *, int, void *);
+extern void FUN_L00_002628d8(char *, char *, int, float, float);
+extern void FUN_L00_00269958(void *, void *, int, int, int, int, int, int);
+extern void FUN_L00_0026ced0(void *, void *, int, int, float, int);
+extern void FUN_L12_003064e8_c2(char *) __asm__("FUN_L12_003064e8");
+extern int allocate_voice_for_target_entry(int, int, void *) __asm__("FUN_0022da68");
+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");
+extern int func_001FA898_3055F8(float) __asm__("FUN_001fa6d0");
+extern float func_001FA888_3055F8(int) __asm__("FUN_001fa6c0");
+extern float D_0015ED64 __attribute__((section(".sdata")));
+extern int D_L12_00161F00_gp __asm__("D_L12_00161F00") __attribute__((section(".sdata")));
+extern int D_L12_00161F04_gp __asm__("D_L12_00161F04") __attribute__((section(".sdata")));
+extern int D_L12_00161F20 __attribute__((sda));
+extern int D_L12_00161F24 __attribute__((sda));
+extern int allocate_voice_for_target_entry(int, int, void *) __asm__("FUN_0022da68");
+
+void FUN_L12_003054b0(char *moby) {
+ char *d = *(char **)(moby + 0x78);
+ int i;
+ float v0[4];
+ float v1[4];
+ float v2[4];
+ float v3[4];
+ float *pv1;
+ float *hp;
+
+ for (i = 0; i < 5; i++) {
+ int idx;
+ char *ent;
+ char *m;
+ Gun_306890 *md;
+ float yaw;
+ float dist;
+ float dz;
+ int flag;
+ float ang;
+ float s;
+
+ if (*(int *)(d - -(i * 4) + 0x5D0) != -1) {
+ idx = *(int *)(d - -(i * 4) + 0x5D0);
+ ent = d + idx * 0x30;
+ m = (char *)(D_L12_0015FFD8_gp + (*(int *)(ent + 0x20) << 8));
+ md = *(Gun_306890 **)(m + 0x78);
+ qcopy(v0, D_L12_00167240);
+ pv1 = v1;
+ v0[2] -= 0.7f;
+ qcopy_nc(pv1, m + 0x10);
+ 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)),
+ -1.5707964f),
+ *(float *)(moby + 0x48));
+ if (md->h90 == 0) {
+ if (FUN_L00_0025bc00((float *)(ent + 0x18), yaw, 0,
+ D_0015ED6C_gp * 0.5235988f + D_0015ED6C_gp * 0.17453292f * (float)i) < 0.08726646f) {
+ md->h90 = 1;
+ md->f8C = 1.0f;
+ if (i & 1) {
+ md->f8C = -1.0f;
+ }
+ }
+ } else {
+ float a = fast_add_rotations(yaw, md->f8C * 0.55850536f);
+ if (func_001F9B88_304310(FUN_L00_0025bc98(ent + 0x18, a, (char *)md + 0x94, 0, D_0015ED64 * 0.022f, D_0015ED64 * 0.3f,
+ D_0015ED6C_gp * 0.2617994f + (float)i * (D_0015ED6C_gp * 0.05235988f)))
+ < 0.017453292f) {
+ md->f8C = -md->f8C;
+ }
+ }
+ flag = 0;
+ hp = (float *)(D_0013F350 + 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) {
+ if (dist < 80.0f && dz < 4.0f) {
+ flag = 1;
+ }
+ }
+ if (dist > 90.0f || dz > 7.0f) {
+ D_L12_00161F34 = 0;
+ }
+ if ((D_L12_00161F00_gp != 0 || flag) && md->f80 > 0.0f) {
+ FUN_001f9770(&md->h98);
+ FUN_001f9770(&md->h9C);
+ if (md->h98 == 0) {
+ if (fast_difference_between_rotations(*(float *)(d + idx * 0x30 + 0x18), yaw) < 0.06981317f) {
+ md->h9E = scale_game_frames(0x14);
+ }
+ if (FUN_001f9770(&md->h9E) == 0) {
+ if (FUN_L00_001fefc8(&md->b92) == 0) {
+ if (FUN_L00_001fefc8(&md->b93) != 0) {
+ allocate_voice_for_target_entry(0, 0, m);
+ md->b93 = scale_game_frames(9);
+ }
+ }
+ if (FUN_001f9770(&md->h9C) != 0) {
+ float rz;
+ float pitch;
+ int n;
+ FUN_L00_0024f7c8(m, md->h9A + 1, v0);
+ md->h9A = md->h9A == 0;
+ rz = fast_add_rotations(*(float *)(m + 0x48), 1.5707964f);
+ if (D_L12_00161F00_gp != 0) {
+ qcopy(v2, D_L12_00167240);
+ v2[2] += random_float_between_c(-1.5f, 0.3f);
+ } else {
+ qcopy(v2, &((Hero *)D_0013F350)->motion.unkD0);
+ v2[2] += FUN_L00_00257c48(0.0f, 0.5f);
+ }
+ n = D_L12_00161F20 - 3;
+ if (scale_game_frames(5) < n) {
+ n = scale_game_frames(5);
+ }
+ if (n < 0) {
+ n = 0;
+ }
+ v2[2] += random_float_between_c((float)n * -0.3f, (float)n * 0.3f);
+ pitch = fast_arc_tan(vector_distance_xy_alt(v0, v2), v2[2] - v0[2]);
+ build_spherical_offset(v1, D_0015ED6C_gp * 80.0f, rz, pitch);
+ if (FUN_L04_002aee30(m, v0, v1, scale_game_frames(0x96)) != 0) {
+ int j;
+ md->b92 = scale_game_frames(0x14);
+ for (j = 0; j < 9; j++) {
+ int c0;
+ int c1;
+ int life;
+ v3[0] = FUN_L00_00257c48(0.0f, D_0015ED6C_gp * 1.7f);
+ v3[1] = FUN_L00_00257c48(0.0f, D_0015ED6C_gp * 1.7f);
+ v3[2] = FUN_L00_00257c48(0.0f, D_0015ED6C_gp * 1.7f);
+ c0 = FUN_L00_00257b90(0xAA, 0xF0);
+ c1 = FUN_L00_00257b90(0x6E, 0xC8);
+ c1 = 0x7F000000 | (c1 << 8) | c0;
+ life = scale_game_frames(FUN_L00_00257b90(0xF, 0x1E));
+ FUN_L00_00269958(v0, v3, c1, 0xFF, life, 0x37, FUN_L00_00257b90(0xB4, 0x10E), 1);
+ }
+ }
+ md->h9C = scale_game_frames(7);
+ n = D_L12_00161F20;
+ if (scale_game_frames(0xB) < n) {
+ n = scale_game_frames(0xB);
+ }
+ if (n < 0) {
+ n = 0;
+ }
+ md->h9C += n;
+ }
+ }
+ }
+ }
+ if (D_L12_00161F04_gp == 0 && md->f80 > 0.0f) {
+ if (func_001F9908_304920(&md->w84) != 0) {
+ float dmg = 1.0f;
+ char *r = FUN_L00_0025a420(m, 0x50000, 0);
+ if (r == 0) {
+ int k = D_L12_001FB670[i];
+ char *t = 0;
+ if (k == 0x11) {
+ t = moby;
+ } else {
+ int id = *(int *)(d + k * 0x30 + 0x20);
+ if (id != -1) {
+ t = (char *)(D_L12_0015FFD8_gp + (id << 8));
+ }
+ }
+ if (t != 0) {
+ dmg = 0.2f;
+ r = FUN_L00_0025a420(t, 0x50000, 0);
+ ((unsigned char *)t)[0xA4] = 0xFF;
+ }
+ if (r == 0) {
+ goto done;
+ }
+ }
+ if (D_L12_00161F00_gp == 0) {
+ D_L12_00161F34 = scale_game_frames(0xFA0);
+ goto done;
+ }
+ md->w84 = scale_game_frames(0x14);
+ md->f80 -= dmg;
+ if (md->f80 <= 0.0f) {
+ int j;
+ int k;
+ *(short *)(d + 0x5FC) -= 0x14;
+ if (*(short *)(d + 0x5FC) < 0) {
+ *(short *)(d + 0x5FC) = 0;
+ }
+ allocate_voice_for_target_entry(1, 0, m);
+ if (*(short *)(d + 0x5FC) > 0) {
+ int k = D_L12_001FB670[i];
+ if (k != 0x11) {
+ D_L12_001FB688[k] = *(int *)(d + k * 0x30 + 0x20);
+ *(int *)(d + k * 0x30 + 0x20) = -1;
+ } else {
+ D_L12_001FB688[0x11] = 1;
+ }
+ FUN_L12_00306350_c2((struct Moby *)moby, k);
+ if (i == 4) {
+ for (j = 0; j < 0x11; j++) {
+ int id = *(int *)(d + j * 0x30 + 0x20);
+ if (id != -1 && *(short *)((id << 8) + (int)D_L12_0015FFD8_gp + 0xA6) == 0x4FD) {
+ D_L12_001FB688[j] = id;
+ *(int *)(d + j * 0x30 + 0x20) = -1;
+ FUN_L12_00306350_c2((struct Moby *)moby, j);
+ }
+ }
+ }
+ }
+ for (k = 0; k < 0x82; k++) {
+ int c;
+ qcopy(v0, m + 0x10);
+ v0[2] += random_float_between_c(0.1f, 0.5f);
+ ang = random_angle_radians();
+ s = random_float_between_c(0.1f, 0.8f);
+ v0[0] += fast_cos(ang) * s;
+ v0[1] += fast_sin(ang) * s;
+ c = FUN_L00_00257b90(scale_game_frames(0x5A), scale_game_frames(0xB4));
+ s = random_float_between_c(D_0015ED6C_gp * 0.7f, D_0015ED6C_gp * 1.5f);
+ v1[0] = fast_cos(ang) * s;
+ v1[1] = fast_sin(ang) * s;
+ v1[2] = 0.0f;
+ v1[2] = random_float_between_c(D_0015ED6C_gp, D_0015ED6C_gp * 5.5f);
+ FUN_L00_0026ced0(v0, v1, 0x500A1414, 0xA0A0A, 420000.0f, c);
+ }
+ *(int *)(m + 0x94) = 0;
+ *(unsigned short *)(m + 0x34) |= 0x41;
+ }
+ }
+ done:
+ ((unsigned char *)m)[0xA4] = 0xFF;
+ } else {
+ ((unsigned char *)m)[0xA4] = 0xFF;
+ }
+ if (md->f80 > 0.0f && md->f80 < 10.0f) {
+ int lvl = (9 - func_001FA898_3055F8(md->f80)) / 2;
+ int j;
+ int n = lvl + 3;
+ for (j = 0; j < n; j++) {
+ int c;
+ qcopy(v0, m + 0x10);
+ v0[2] += 0.7f;
+ ang = random_angle_radians();
+ s = random_float_between_c(0.1f, 0.4f);
+ v0[0] += fast_cos(ang) * s;
+ v0[1] += fast_sin(ang) * s;
+ c = FUN_L00_00257b90(scale_game_frames(0x19), scale_game_frames(0x37));
+ s = random_float_between_c(D_0015ED6C_gp * 0.5f, D_0015ED6C_gp * 3.0f);
+ v1[0] = fast_cos(ang) * s;
+ v1[1] = fast_sin(ang) * s;
+ v1[2] = 0.0f;
+ v1[2] = random_float_between_c(D_0015ED6C_gp * 7.0f, D_0015ED6C_gp * 17.0f) * func_001FA888_3055F8(lvl) * 1.5f
+ / func_001FA888_3055F8(5);
+ FUN_L00_0026ced0(v0, v1, (FUN_L00_00257b90(0x46, 0xCD) << 8) | 0x460A00AA, 0xA0A46, 420000.0f, c);
+ }
+ for (j = 0; j < 3; j++) {
+ int c;
+ qcopy(v0, m + 0x10);
+ ang = random_angle_radians();
+ s = random_float_between_c(0.1f, 0.8f);
+ v0[0] += fast_cos(ang) * s;
+ v0[1] += fast_sin(ang) * s;
+ c = FUN_L00_00257b90(scale_game_frames(0x28), scale_game_frames(0x46));
+ s = random_float_between_c(D_0015ED6C_gp * 0.1f, D_0015ED6C_gp * 0.4f);
+ v1[0] = fast_cos(ang) * s;
+ v1[1] = fast_sin(ang) * s;
+ v1[2] = 0.0f;
+ v1[2] = random_float_between_c(D_0015ED6C_gp * 2.4f, D_0015ED6C_gp * 5.5f);
+ FUN_L00_0026ced0(v0, v1, 0x460A1414, 0xA0A0A, 504000.03f, c);
+ }
+ }
+ }
+ }
+ FUN_L12_003064e8_c2(moby);
+ if (*(short *)(d + 0x5FC) <= 0 && D_L12_00161F04_gp == 0) {
+ D_L12_00161F24 = 1;
+ moby[0x20] = 4;
+ moby[0xBC] = 0;
+ }
+}
+extern int D_L12_001FB688[];
+extern float random_float_between(float, float) __asm__("FUN_002132a8");
+extern float randf_sym(float, float) __asm__("FUN_L00_00257c48");
+
+void FUN_L12_00306350(struct Moby *moby, int slot) {
+ char *data = (char *)moby->pvars;
+ struct Moby *selected;
+ float *speed;
+ int offset;
+ float initial_speed;
+ float angle_scale;
+ float first_angle;
+ float second_scale;
+ char *slot_data;
+
+ if (slot == 0x11) {
+ selected = moby;
+ offset = 0x44;
+ } else {
+ selected = (struct Moby *)(D_L12_0015FFD8_p + D_L12_001FB688[slot] * 0x100);
+ offset = slot * 4;
+ }
+
+ initial_speed = random_float_between(frame_time_sq * 3.7f, frame_time_sq * 5.0f);
+ angle_scale = frame_time;
+ {
+ char *base = data + 0x570;
+ speed = (float *)(base + offset);
+ }
+ *speed = initial_speed;
+ first_angle = randf_sym(angle_scale * 0.05235988f, angle_scale * 0.13962634f);
+ second_scale = frame_time;
+ slot_data = data + slot * 0x10;
+ *(float *)(slot_data + 0x450) = first_angle;
+ *(float *)(slot_data + 0x454) = randf_sym(second_scale * 0.05235988f, second_scale * 0.17453292f);
+ if (selected->oclass == 0x4fd) {
+ float variation = random_float_between(0.001f, 0.0045f);
+ float speed_scale = frame_time_sq;
+ *(float *)(slot_data + 0x45c) = variation;
+ *speed = random_float_between(speed_scale * 5.5f, speed_scale * 9.0f);
+ } else if (selected->oclass == 0x500) {
+ *speed = frame_time_sq * 13.0f;
+ }
+}
+/* Ported from rac1-decomp (src/overlays/l12_hoven/vendor_002EDAA0.c: func_L12_003078C8), where it is exact; names translated to the US level program. */
+
+extern float D_L12_00161F40;
+extern float D_L12_00161F50;
+extern float D_L12_00161F60;
+extern float D_L12_00161F70;
+extern float FUN_L00_0025bc98(void *, float, void *, int, float, float, float);
+extern float fast_add_rotations_c4(float, float) __asm__("func_001FA580");
+extern void FUN_L00_00250df8_c(void *) __asm__("FUN_L00_00250df8");
+extern void mark_moby_for_removal_c(void *) __asm__("func_0020C828");
+
+void FUN_L12_003064e8(char *moby) {
+ int i;
+ int off;
+ char *data = *(char **)(moby + 0x78);
+ int last = 17;
+ for (i = 0, off = 0; i < 18; i++, off += 4) {
+ int s = D_L12_001FB688[i];
+ char *obj;
+ float f1;
+ if (s == 0) {
+ continue;
+ }
+ if (i == last) {
+ obj = moby;
+ } else {
+ if (s == -1) {
+ continue;
+ }
+ obj = (char *)(D_L12_0015FFD8_gp + (s << 8));
+ }
+ if (i == last) {
+ f1 = D_L12_00161F40;
+ if (f1 == -1.0f) {
+ qcopy((char *)&D_L12_00161F40, obj + 0x10);
+ qcopy((char *)&D_L12_00161F50, obj + 0x40);
+ }
+ qcopy((char *)&D_L12_00161F60, obj + 0x10);
+ qcopy((char *)&D_L12_00161F70, obj + 0x40);
+ qcopy(obj + 0x10, (char *)&D_L12_00161F40);
+ qcopy(obj + 0x40, (char *)&D_L12_00161F50);
+ f1 = *(float *)(obj + 0x18);
+ } else {
+ f1 = *(float *)(obj + 0x18);
+ }
+ if (f1 < 20.0f) {
+ if (i == last) {
+ return;
+ }
+ mark_moby_for_removal_c(obj);
+ D_L12_001FB688[i] = -1;
+ }
+ f1 = *(float *)(data + 0x338 + i * 16) - *(float *)(data + off + 0x570);
+ *(float *)(data + 0x338 + i * 16) = f1;
+ *(float *)(obj + 0x18) = *(float *)(obj + 0x18) + f1;
+ if (*(short *)(obj + 0xA6) == 0x500) {
+ *(float *)(obj + 0x40) = fast_add_rotations_c4(*(float *)(obj + 0x40), D_0015ED6C * 0.34906584f);
+ FUN_L00_0025bc98(obj + 0x44, 1.5707964f, data + 0x454 + i * 16, 0, 0.00200000009f, 0.3f, 0.0f);
+ } else if (*(short *)(obj + 0xA6) == 0x4FD) {
+ *(float *)(obj + 0x40) = fast_add_rotations_c4(*(float *)(obj + 0x40), *(float *)(data + 0x450 + i * 16));
+ FUN_L00_0025bc98(obj + 0x44, -1.5707964f, (float *)(data + 0x450 + i * 16) + 1, 0, *(float *)(data + 0x45C + i * 16), 0.3f, 0.0f);
+ } else if (*(short *)(obj + 0xA6) == 0x4FA) {
+ float t;
+ *(float *)(obj + 0x40) = fast_add_rotations_c4(*(float *)(obj + 0x40), D_0015ED6C * -0.87266463f);
+ t = fast_add_rotations_c4(*(float *)(obj + 0x44), *(float *)(data + 0x454 + i * 16));
+ *(float *)(obj + 0x14) = *(float *)(obj + 0x14) + D_0015ED6C * -4.0f;
+ *(float *)(obj + 0x44) = t;
+ } else {
+ *(float *)(obj + 0x14) = *(float *)(obj + 0x14) + D_0015ED6C * -4.0f;
+ *(float *)(obj + 0x40) = fast_add_rotations_c4(*(float *)(obj + 0x40), *(float *)(data + 0x450 + i * 16));
+ *(float *)(obj + 0x44) = fast_add_rotations_c4(*(float *)(obj + 0x44), *(float *)(data + 0x454 + i * 16));
+ }
+ if (i == last) {
+ qcopy((char *)&D_L12_00161F40, obj + 0x10);
+ qcopy((char *)&D_L12_00161F50, obj + 0x40);
+ }
+ 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");
+
+extern char *D_L12_0015FFD8_lui __asm__("D_L12_0015FFD8") __attribute__((section(".data")));
+
+void FUN_L12_00306828(struct Moby *moby) {
+ int i;
+ int alpha = 0x80000000;
+ char *data = (char *)moby->pvars;
+ for (i = 0; i < 18; i++) {
+ struct Moby *other;
+ int period;
+ float sine;
+ float color;
+ unsigned 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 (other->oclass != 0x4FE) {
+ period = scale_ticks(0xAA);
+ divisor = convert_integer_to_float(period);
+ 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);
+ 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;
+ }
+ }
+}
+#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. */
+
+typedef struct { float v[4]; } P_7DB0;
+
+typedef struct { char pad[0x80]; float f80; } F80_7DB0;
+
+typedef struct { char pad[0x34]; unsigned short flags; } M34_7DB0;
+
+typedef struct { unsigned char pad0[0x74]; unsigned char active; unsigned char pad75[0x13]; char *owner; } Voice_7DB0;
+
+extern char D_0013E550[];
+extern char *D_L12_001600EC __attribute__((section(".sdata")));
+extern char D_0013F3D0[] __attribute__((section(".data")));
+extern char D_L12_00167240[];
+extern f32 advance_accelerated_scalar(f32 *, f32 *, f32, f32, f32, f32) __asm__("func_00213F38");
+extern f32 fast_arc_tan(f32, f32) __asm__("func_001F9E90");
+extern f32 fast_subtract_rotations(f32, f32) __asm__("func_001FA5C8");
+extern float D_0015ED64 __attribute__((section(".sdata")));
+extern float D_0015ED6C_gp __asm__("D_0015ED6C") __attribute__((section(".sdata")));
+extern float D_0015ED70 __attribute__((section(".sdata")));
+extern float D_L12_00161F40_gp __asm__("D_L12_00161F40") __attribute__((section(".sdata")));
+extern float D_L12_00161F60_gp __asm__("D_L12_00161F60") __attribute__((section(".sdata")));
+extern float D_L12_00161F70_gp __asm__("D_L12_00161F70") __attribute__((section(".sdata")));
+extern float approach_value(float *, float, float);
+extern float fast_add_rotations(float, float) __asm__("func_001FA580");
+extern float fast_difference_between_rotations(float, float) __asm__("func_001FA688");
+extern float vector_distance_xy_alt(void *, void *) __asm__("FUN_001f9b80");
+extern int D_L12_001619A0 __attribute__((section(".sdata")));
+extern int D_L12_001619B4 __attribute__((section(".sdata")));
+extern int D_L12_00161F00;
+extern int D_L12_00161F24 __attribute__((section(".sdata")));
+extern int D_L12_00161F34 __attribute__((sda));
+extern int D_L12_001B0930;
+extern int D_L12_0015F404 __attribute__((section(".sdata")));
+extern int is_point_inside_clip_volume_c(void *arg0, int arg1) __asm__("func_00214720");
+extern int tick_countdown_32_alt(int *) __asm__("FUN_001f9740");
+extern s32 scale_game_frames(s32) __asm__("func_001F96F8");
+
+extern short D_L12_00161F28 __attribute__((sda));
+extern short D_L12_00161F2C __attribute__((sda));
+extern short D_L12_00161F30 __attribute__((sda));
+extern unsigned char D_0014C050[];
+extern 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 *);
+extern void FUN_L00_00262b80(void *, char *, char *, float, float, float);
+extern void FUN_L00_00298840(int);
+extern void FUN_L00_002ea9d8(void *);
+extern void FUN_L00_002eaa30(void *);
+extern void FUN_L00_002eac18(int);
+extern void FUN_L12_0027b268(char *, void *, int);
+extern void FUN_L12_0027b370(char *, char *, int);
+extern void FUN_L12_003064e8_c(char *) __asm__("FUN_L12_003064e8");
+extern void add_vector_xyz(void *, void *, void *) __asm__("FUN_001f9a10");
+extern int allocate_voice_for_target_entry(int, int, void *) __asm__("FUN_0022da68");
+extern void clear_u64_value(void *) __asm__("func_001F99F8");
+extern void fast_vec_normalize(void *, void *, f32) __asm__("FUN_001f9bf8");
+extern void lerp_vector(void *, void *, void *, f32) __asm__("func_001F9A40");
+extern void mark_moby_for_removal_c2(void *) __asm__("func_0020C828");
+extern void release_voice_slot(s32) __asm__("FUN_0022d798");
+extern void subtract_vector_xyz(void *, void *, void *) __asm__("FUN_001f9a28");
+void FUN_L12_003054b0_u(void *moby) __asm__("FUN_L12_003054b0");
+void FUN_L12_00306350_c(struct Moby *moby, int slot) __asm__("FUN_L12_00306350");
+void FUN_L12_00306828(struct Moby *moby);
+extern int current_level_index_gp __asm__("D_0015ED84") __attribute__((section(".sdata")));
+extern char D_0013F3D0[];
+extern int D_L12_00161F00_gp __asm__("D_L12_00161F00") __attribute__((section(".sdata")));
+extern int allocate_voice_for_target_entry(int, int, void *) __asm__("FUN_0022da68");
+extern int D_L12_001B0930;
+
+void FUN_L12_003069d0(char *moby) {
+ float v[4];
+ float w[4];
+ char *d = *(char **)(moby + 0x78);
+ if (((unsigned char *)moby)[0x20] != 0 && D_L12_001FB688[17] != 0) {
+ qcopy(moby + 0x10, (char *)&D_L12_00161F60_gp);
+ qcopy(moby + 0x40, (char *)&D_L12_00161F70_gp);
+ }
+ switch ((unsigned char)moby[0x20]) {
+ case 0:
+ D_L12_001619B4 = 0;
+ if (D_0014C050[(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);
+ if (s != -1) mark_moby_for_removal_c2((char *)D_L12_0015FFD8_gp + (s << 8));
+ }
+ mark_moby_for_removal_c2(moby);
+ return;
+ } else {
+ P_7DB0 *path;
+ int i;
+ int j;
+ D_L12_00161F24 = 0;
+ FUN_L12_0027b268(moby, d, 0x11);
+ path = ((P_7DB0 * *)&D_L12_001B0930)[*(int *)(d + 0x5C0)];
+ qcopy(moby + 0x10, path + 1);
+ *(float *)(d + 0x618) = *(float *)(moby + 0x18);
+ *(float *)(moby + 0x48) = fast_arc_tan(path[2].v[0] - path[1].v[0], path[2].v[1] - path[1].v[1]);
+ if (*(float *)(D_0013F3D0 + 0x8) < 52.0f) {
+ *(float *)(moby + 0x18) = *(float *)(moby + 0x18) + 3.0f;
+ }
+ for (i = 0; i < 5; i++) {
+ int k = *(int *)(d + 0x5D0 + i * 4);
+ char *o = (char *)D_L12_0015FFD8_gp + (*(int *)(d + k * 0x30 + 0x20) << 8);
+ (*(F80_7DB0 **)(o + 0x78))->f80 = 10.0f;
+ }
+ D_L12_00161F40_gp = -1.0f;
+ for (j = 17; j >= 0; j--) D_L12_001FB688[j] = 0;
+ *(int *)(d + 0x604) = -1;
+ *(short *)(d + 0x5FC) = 100;
+ moby[0x20] = 1;
+ }
+ break;
+ case 1: {
+ char *h;
+ int r;
+ if (is_point_inside_clip_volume_c(D_L12_00167240, *(int *)(d + 0x624))) {
+ int i;
+ char *base = (char *)D_L12_0015FFD8_gp;
+ *(unsigned short *)(moby + 0x34) |= 0x41;
+ for (i = 0; i < 17; i++) {
+ int s = *(int *)(d + i * 0x30 + 0x20);
+ if (s != -1) ((M34_7DB0 *)(base + (s << 8)))->flags |= 0x41;
+ }
+ } else {
+ int i;
+ char *base = (char *)D_L12_0015FFD8_gp;
+ *(unsigned short *)(moby + 0x34) &= ~0x41;
+ for (i = 0; i < 17; i++) {
+ int s = *(int *)(d + i * 0x30 + 0x20);
+ if (s != -1) ((M34_7DB0 *)(base + (s << 8)))->flags &= ~0x41;
+ }
+ }
+ h = D_0013F3D0;
+ r = is_point_inside_clip_volume_c(h, *(int *)(d + 0x628));
+ if (*(float *)(h + 8) > 52.0f && r == 0) {
+ approach_value((float *)(moby + 0x18), *(float *)(d + 0x618), D_0015ED6C_gp + D_0015ED6C_gp);
+ } else {
+ float add = 3.0f;
+ if (r) add = 10.0f;
+ if (is_point_inside_clip_volume_c(D_0013F3D0, *(int *)(d + 0x61C))) {
+ *(int *)(d + 0x620) = scale_game_frames(0x5A);
+ }
+ if (!tick_countdown_32_alt((int *)(d + 0x620))) add = 19.0f;
+ FUN_L00_0025b8c0((float *)(moby + 0x18), (float *)(d + 0x62C), *(float *)(d + 0x618) + add,
+ 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_L12_0027b370(moby, d, 0x11);
+ if (is_point_inside_clip_volume_c(D_0013F3D0, *(int *)(d + 0x5EC)) || D_L12_00161F00_gp) {
+ int i;
+ D_L12_001619B4 = 1;
+ for (i = 0; i < 5; i++) {
+ int k = *(int *)(d + 0x5D0 + i * 4);
+ ((unsigned char *)D_L12_0015FFD8_gp + (*(int *)(d + k * 0x30 + 0x20) << 8))[0xA4] = 0xFF;
+ }
+ moby[0x20] = 2;
+ }
+ break;
+ }
+ case 2: {
+ P_7DB0 *path;
+ 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);
+ 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);
+ } else {
+ approach_value((float *)(d + 0x5F0), 0.0f, D_0015ED70 * 8.0f);
+ if (*(float *)(d + 0x5F0) == 0.0f) {
+ moby[0x20] = 3;
+ break;
+ }
+ }
+ nx = (*(short *)(d + 0x5F8) + 1) % *(int *)path;
+ subtract_vector_xyz(v, &path[nx + 1], &path[*(short *)(d + 0x5F8) + 1]);
+ fast_vec_normalize(v, v, *(float *)(d + 0x5F0));
+ add_vector_xyz(moby + 0x10, moby + 0x10, v);
+ f = fast_arc_tan(*(float *)((char *)path + (nx << 4) + 0x10) - *(float *)((char *)path + (*(short *)(d + 0x5F8) << 4) + 0x10),
+ *(float *)((char *)path + (nx << 4) + 0x14) - *(float *)((char *)path + (*(short *)(d + 0x5F8) << 4) + 0x14));
+ if (*(int *)path - 20 < *(short *)(d + 0x5F8)) f = 3.0543261f;
+ FUN_L00_00258278(moby, f, (float *)(d + 0x5F4), D_0015ED64 * 0.0015f, D_0015ED64 * 0.3f, D_0015ED6C_gp * 0.17453292f);
+ if (vector_distance_xy_alt(moby + 0x10, &path[*(short *)(d + 0x5F8) + 1]) < 5.0f
+ || fast_difference_between_rotations(*(float *)(moby + 0x48),
+ fast_arc_tan(*(float *)((char *)path + (*(short *)(d + 0x5F8) << 4) + 0x10) - *(float *)(moby + 0x10),
+ *(float *)((char *)path + (*(short *)(d + 0x5F8) << 4) + 0x14) - *(float *)(moby + 0x14))) > 1.5707964f) {
+ *(short *)(d + 0x5F8) = (*(short *)(d + 0x5F8) + 1) % *(int *)path;
+ }
+ FUN_L12_0027b370(moby, d, 0x11);
+ FUN_L12_003054b0_u(moby);
+ break;
+ }
+ case 3:
+ 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_L12_0027b370(moby, d, 0x11);
+ FUN_L12_003054b0_u(moby);
+ break;
+ case 4:
+ if (*(int *)(d + 0x608) != -1 && *(int *)(d + 0x60C) != -1) {
+ switch ((unsigned char)moby[0xBC]) {
+ case 0:
+ moby[0xBC] = 1;
+ FUN_L00_002ea9d8(D_L12_001600EC + *(int *)(d + 0x608) * 128 + 0x30);
+ FUN_L00_002eaa30(D_L12_001600EC + *(int *)(d + 0x608) * 128 + 0x70);
+ D_L12_0015F404 = 1;
+ D_L12_001619A0 = 1;
+ break;
+ case 1:
+ if (*(float *)(d + 0x610) < 1.0f) {
+ advance_accelerated_scalar((float *)(d + 0x610), (float *)(d + 0x614), 1.0f,
+ D_0015ED70 * 0.666f, D_0015ED70 * 0.666f, D_0015ED6C_gp * 0.4f);
+ lerp_vector(v, D_L12_001600EC + *(int *)(d + 0x608) * 128 + 0x30,
+ D_L12_001600EC + *(int *)(d + 0x60C) * 128 + 0x30, *(float *)(d + 0x610));
+ clear_u64_value(w);
+ w[0] = fast_subtract_rotations(*(float *)(D_L12_001600EC + *(int *)(d + 0x60C) * 128 + 0x70),
+ *(float *)(D_L12_001600EC + *(int *)(d + 0x608) * 128 + 0x70)) * *(float *)(d + 0x610);
+ w[0] = fast_add_rotations(*(float *)(D_L12_001600EC + *(int *)(d + 0x608) * 128 + 0x70), w[1]);
+ w[1] = fast_subtract_rotations(*(float *)(D_L12_001600EC + *(int *)(d + 0x60C) * 128 + 0x74),
+ *(float *)(D_L12_001600EC + *(int *)(d + 0x608) * 128 + 0x74)) * *(float *)(d + 0x610);
+ w[1] = fast_add_rotations(*(float *)(D_L12_001600EC + *(int *)(d + 0x608) * 128 + 0x74), w[1]);
+ w[2] = fast_subtract_rotations(*(float *)(D_L12_001600EC + *(int *)(d + 0x60C) * 128 + 0x78),
+ *(float *)(D_L12_001600EC + *(int *)(d + 0x608) * 128 + 0x78)) * *(float *)(d + 0x610);
+ w[2] = fast_add_rotations(*(float *)(D_L12_001600EC + *(int *)(d + 0x608) * 128 + 0x78), w[2]);
+ FUN_L00_002ea9d8(v);
+ FUN_L00_002eaa30(w);
+ } else {
+ moby[0xBC] = 2;
+ D_L12_0015F404 = 0;
+ FUN_L00_002eac18(3);
+ }
+ break;
+ case 2: {
+ int i;
+ for (i = 0; i < 17; i++) {
+ int s = *(int *)(d + i * 0x30 + 0x20);
+ if (s != -1) {
+ char *o = (char *)D_L12_0015FFD8_gp + (s << 8);
+ if (o[0x20] >= 0) mark_moby_for_removal_c2(o);
+ *(int *)(d + i * 0x30 + 0x20) = -1;
+ } else if (D_L12_001FB688[i] > 0) {
+ char *o = (char *)D_L12_0015FFD8_gp + (D_L12_001FB688[i] << 8);
+ if (o[0x20] >= 0) mark_moby_for_removal_c2(o);
+ }
+ }
+ D_L12_001619B4 = 0;
+ FUN_L00_00298840(7);
+ mark_moby_for_removal_c2(moby);
+ return;
+ }
+ }
+ }
+ if (*(short *)(d + 0x5FA) == 0) {
+ int i;
+ for (i = 0; i < 17; i++) {
+ if (D_L12_001FB688[i] == 0) D_L12_001FB688[i] = *(int *)(d + i * 0x30 + 0x20);
+ *(int *)(d + i * 0x30 + 0x20) = -1;
+ }
+ D_L12_001FB688[17] = 1;
+ for (i = 0; i < 18; i++) FUN_L12_00306350_c((struct Moby *)moby, i);
+ }
+ *(short *)(d + 0x5FA) = *(short *)(d + 0x5FA) + 1;
+ FUN_L12_003064e8_c(moby);
+ break;
+ }
+ 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 {
+ int s = *(int *)(d + 0x604);
+ if (s != -1) {
+ Voice_7DB0 *e = (Voice_7DB0 *)(((unsigned char *)D_0013E550) + s * 0x70);
+ if (e->owner == moby && e->active != 0) release_voice_slot(s);
+ }
+ *(int *)(d + 0x604) = -1;
+ }
+}
+#include "qcopy.h"
+
+/* Spawns the next linked moby at this one's spot, sets it up and gives it a random spin. */
+extern void FUN_L00_00250df8(unsigned char *);
+extern float random_float_between(float, float) __asm__("FUN_002132a8");
+extern void FUN_L00_0026de90(char *, int, float);
+extern short *FUN_002141f8(unsigned char *);
+
+void FUN_L12_003076e0(struct Moby *m) {
+ char *d = (char *)m->pvars;
+ int *s = (int *)(d + (*(int *)(d + 0xF0) << 2));
+ struct Moby *o = (struct Moby *)((unsigned char *)D_L12_0015FFD8_p + (s[0x30] << 8));
+ struct MobyClass *p;
+ short *r;
+ int i;
+ qcopy(&o->pos, &m->pos);
+ o->pos.z -= 0.35f;
+ o->state = 0;
+ o->command = 0;
+ p = o->pclass;
+ o->flags = p->flags;
+ o->scale = p->scale;
+ o->update_dist = 0xFF;
+ o->visible = 1;
+ o->occlusion = 0x7F80;
+ o->draw_dist = 0xFF;
+ o->unk71 = 0xFF;
+ o->unk72 = 0xFF;
+ o->hit_slot = 0xFF;
+ o->collision = p->collision;
+ o->spawn_frame = m->spawn_frame;
+ FUN_L00_00250df8(o);
+ o->parent = m;
+ for (i = 0; i < 14; i++) {
+ FUN_L00_0026de90(&m->pos, 0, random_float_between(frame_time * 3.0f, frame_time * 5.0f));
+ }
+ r = FUN_002141f8(o);
+ if (r != 0) {
+ *(float *)r = r[2];
+ }
+}
+
+#define NOT_SDA
+
+#define MACRO_ADDR
+
+/* Door/switch moby: clears its linked mobys, waits for the hero, opens, fires its list one by one, closes. */
+/* Ported from rac1-decomp (src/overlays/l12_hoven/vendor_002EDAA0.c: func_L12_00308C20), where it is exact; names translated to the US level program. */
+
+extern float FUN_001f9b80(void *, void *);
+extern int FUN_001f9770(void *);
+extern s32 scale_game_frames(s32) __asm__("func_001F96F8");
+void FUN_L12_003076e0(struct Moby *m);
+extern void FUN_L12_00307ab8(struct Moby *m);
+extern void blend_moby_animation(void *, int, int, int) __asm__("FUN_00212f90");
+void mark_moby_for_removal(void *obj) __asm__("FUN_0020c828");
+
+void FUN_L12_00307840(struct Moby *m) {
+ char *d = (char *)m->pvars;
+ int *slots;
+ int i;
+ FUN_L12_00307ab8(m);
+ slots = (int *)(d + 0xC0);
+ switch (m->state) {
+ case 0:
+ for (i = 0; i < 12; i++) {
+ if (slots[i] != -1) {
+ char *o = (D_L12_0015FFD8_p + (slots[i] << 8));
+ if (o != 0 && ((unsigned char *)o)[0x20] != 0xFE &&
+ ((unsigned char *)o)[0x20] != 0xFD) {
+ mark_moby_for_removal(o);
+ }
+ }
+ }
+ m->state = 1;
+ break;
+ case 1:
+ if (*(int *)(d + 0xB4) != 2) {
+ if (FUN_001f9b80(&m->pos, d + 0x70) < *(float *)(d + 0xF8)) {
+ m->state = 2;
+ }
+ }
+ break;
+ case 2:
+ if (m->prev_seq != 1) {
+ blend_moby_animation(m, 1, 0, scale_game_frames(2));
+ }
+ if (m->anim_flags & 2) {
+ if (m->prev_seq != 2) {
+ blend_moby_animation(m, 2, 0, scale_game_frames(2));
+ }
+ m->state = 3;
+ }
+ break;
+ case 3:
+ if (FUN_001f9770(d + 0xFC)) {
+ if (slots[*(int *)(d + 0xF0)] != -1) {
+ FUN_L12_003076e0(m);
+ m->command = m->command == 0;
+ *(short *)(d + 0xFC) = scale_game_frames(0x28);
+ }
+ *(int *)(d + 0xF0) += 1;
+ }
+ if (*(int *)(d + 0xF0) == 12 || slots[*(int *)(d + 0xF0)] == -1) {
+ m->state = 4;
+ }
+ break;
+ case 4:
+ m->flags &= 0xEFFF;
+ if (m->prev_seq != 3) {
+ blend_moby_animation(m, 3, 0, scale_game_frames(2));
+ }
+ if (m->anim_flags & 2) {
+ if (m->prev_seq != 0) {
+ blend_moby_animation(m, 0, 0, scale_game_frames(2));
+ }
+ m->state = 5;
+ }
+ break;
+ case 5:
+ break;
+ }
+}
+#include "qcopy.h"
+
+/* per-frame update of a moby's timer and approach state */
+/* Ported from rac1-decomp (src/overlays/l12_hoven/vendor_002EDAA0.c: func_L12_00308E98), where it is exact; names translated to the US level program. */
+
+extern char D_0013E533[];
+extern int FUN_001f96f8(int);
+extern int FUN_001f9770(void *);
+extern int FUN_L00_0025fcb8(char *, char *, float);
+float absolute_float(float input) __asm__("func_001F99C0");
+
+void FUN_L12_00307ab8(struct Moby *m) {
+ char *d = (char *)m->pvars;
+ char *pad;
+ if (m->state != 0) {
+ if (*(int *)(d + 0x38) != 0) {
+ *(short *)(d + 0xFE) = FUN_001f96f8(0xB4);
+ }
+ *(int *)(d + 0x38) = 0;
+ if (FUN_001f9770(d + 0xFE)) {
+ *(float *)(d + 0xF8) = *(float *)(d + 0xF4);
+ } else {
+ *(float *)(d + 0xF8) = *(float *)(d + 0xF4) + 5.0f;
+ }
+ if (FUN_L00_0025fcb8(m, d + 0x70, *(float *)(d + 0xF8)) != 2) {
+ if (absolute_float(m->pos.z - *(float *)(d + 0x78)) > 3.0f) {
+ *(int *)(d + 0xB4) = 2;
+ }
+ }
+ if (*(int *)(d + 0xB0) == 0) {
+ pad = D_0013E533 + 0xE1D;
+ *(int *)(d + 0xB0) = *(int *)(pad + 0x2080);
+ qcopy(d + 0x70, pad + 0x80);
+ }
+ }
+}
+#include "rnc/gameplay/entities/moby.h"
+
+extern unsigned char D_0014C050[];
+
+extern int FUN_L01_00275690(void *, float);
+extern int FUN_0022da68(int, int, void *);
+extern void release_voice_slot(int) __asm__("FUN_0022d798");
+extern void enqueue_callback_list_1(void *, void *) __asm__("FUN_001f4600");
+extern void FUN_L00_002502a0(int);
+extern void FUN_L12_00308350(struct Moby *);
+
+/* Pvars: d[0] is the moby to watch, d[1] the voice slot held for this moby. */
+void FUN_L12_003081b0(struct Moby *m) {
+ int st = m->state;
+ int vis;
+ int *d = (int *)m->pvars;
+
+ switch (st) {
+ case 0:
+ if (m->mission != 0xFF && D_0014C050[m->mission + current_level_index * 16] == 0xFF) {
+ mark_moby_for_removal(m);
+ break;
+ }
+ m->state = 1;
+ break;
+ case 1:
+ vis = 1;
+ if (FUN_L01_00275690(m, 48.0f) == -1) {
+ vis = 0;
+ }
+ if (vis) {
+ enqueue_callback_list_1(FUN_L12_00308350, m);
+ }
+ if (d[1] == -1) {
+ d[1] = FUN_0022da68(0, 4, m);
+ }
+ if (d[0] >= 0) {
+ int i = d[1];
+ if (i != -1) {
+ char *e = ((char *)&voice_pool) + i * 0x70;
+ if (*(struct Moby **)(e + 0x88) == m && *(unsigned char *)(e + 0x74) != 0) {
+ release_voice_slot(i);
+ }
+ }
+ d[1] = -1;
+ if (((unsigned char *)D_L12_0015FFD8_p)[(d[0] << 8) + 0x20] == 7) {
+ if (m->mission != 0xFF) {
+ FUN_L00_002502a0(m->mission);
+ }
+ FUN_0022da68(1, 0, m);
+ m->collision = 0;
+ m->state = 2;
+ }
+ }
+ break;
+ }
+}
+#ifndef NON_MATCHING
+INCLUDE_ASM("config/us/overlays/asm/FUN_L12_00308350.s", FUN_L12_00308350);
+#else
+#include "eetypes.h"
+
+typedef struct {
+ u128 vertices[4];
+ int color[4];
+ float uv[4][2];
+ long tag;
+ long texture;
+ long texture_state;
+ long gs_state;
+} VendorDrawPacket;
+
+extern int D_L12_00161FBC __attribute__((sda));
+extern int D_L12_00161FC0 __attribute__((sda));
+extern int D_L12_00161FC4 __attribute__((sda));
+extern int D_L12_00161FC8 __attribute__((sda));
+extern int D_L12_00161FCC __attribute__((sda));
+extern int D_L12_00161FD0 __attribute__((sda));
+extern int D_L12_00161FD4 __attribute__((sda));
+extern int D_L12_00161FD8 __attribute__((sda));
+extern unsigned int D_L12_00161F90 __attribute__((sda));
+extern unsigned int D_L12_00161F94 __attribute__((sda));
+extern float D_L12_001FB6D0[4][2];
+extern u128 D_L12_001FB6F0[4];
+extern u128 D_L12_001FB730[4];
+extern void copy_moby_matrix(void *, void *) __asm__("FUN_001fa298");
+extern long get_effect_texture(int) __asm__("FUN_001f44b8");
+extern void draw_geometry_quad_l12(void *, void *, int) __asm__("FUN_001f7d30");
+
+void FUN_L12_00308350(struct Moby *m) {
+ VendorDrawPacket first, second;
+ float matrix[4][4] __attribute__((aligned(16)));
+ void *matrix_ptr;
+ int i, j;
+ int vertex;
+ long flags, second_flags;
+
+ matrix_ptr = matrix;
+ copy_moby_matrix(matrix, &m->rot_row0);
+ qcopy(&matrix[3], &m->pos);
+ matrix[3][3] = 1.0f;
+ first.texture = second.texture = get_effect_texture(0xe);
+ first.texture_state = second.texture_state = 0xFF9000000260L;
+ first.gs_state = (long)D_L12_00161FBC | ((long)D_L12_00161FC0 << 2) | ((long)D_L12_00161FC4 << 4) | ((long)D_L12_00161FC8 << 6) | 0x8000000000L;
+ second.gs_state = (long)D_L12_00161FCC | ((long)D_L12_00161FD0 << 2) | ((long)D_L12_00161FD4 << 4) | ((long)D_L12_00161FD8 << 6) | 0x8000000000L;
+ second.tag = 0;
+ first.tag = 0;
+ first.color[0] = first.color[1] = first.color[2] = first.color[3] = D_L12_00161F90;
+ second.color[0] = second.color[1] = second.color[2] = second.color[3] = D_L12_00161F94;
+ vertex = 0;
+ do {
+ float x, y;
+ qcopy(&second.vertices[vertex], &D_L12_001FB6F0[vertex]);
+ qcopy(&first.vertices[vertex], &D_L12_001FB730[vertex]);
+ x = D_L12_001FB6D0[vertex][0];
+ y = D_L12_001FB6D0[vertex][1];
+ first.uv[vertex][0] = x;
+ ((float *)first.uv)[vertex * 2 + 1] = y;
+ second.uv[vertex][0] = x;
+ second.uv[vertex][1] = y;
+ vertex++;
+ } while (vertex < 4);
+ i = 0;
+ do {
+ float x_offset;
+ float jitter;
+ int row;
+ u128 *first_vertex;
+ u128 *second_vertex;
+ x_offset = random_float_between(-0.5f, 0.5f);
+ first_vertex = first.vertices;
+ second_vertex = second.vertices;
+ for (j = 0; j < 4; j++) {
+ ((float *)&first.vertices[j])[2] += 1.0f;
+ ((float *)&second_vertex[j])[2] += 1.0f;
+ first.uv[j][0] = D_L12_001FB6D0[j][0] + x_offset;
+ first.uv[j][1] = D_L12_001FB6D0[j][1];
+ }
+ jitter = 0.0f;
+ for (row = -3; row < 3; row++) {
+ float x = (float)row + jitter;
+ ((float *)&first.vertices[0])[1] = x;
+ ((float *)&first.vertices[1])[1] = x;
+ jitter = row < 4 ? random_float_between(-0.2f, 0.2f) : 0.0f;
+ x = (float)(row + 1) + jitter;
+ ((float *)&first.vertices[2])[1] = x;
+ ((float *)&first.vertices[3])[1] = x;
+ draw_geometry_quad_l12(&first, matrix, 0);
+ }
+ i++;
+ } while (i < 5);
+}
+#endif
+#include "sda.h"
+
+/* Vendor-counter moby update: once the shared block is ready, latch its data and copy two vectors. */
+/* Ported from rac1-decomp (src/overlays/l12_hoven/vendor_002EDAA0.c: func_L12_0030A7A8), where it is exact; names translated to the US level program. */
+
+typedef struct {
+ char pad0[0x10];
+ char pos[0x10];
+ unsigned char b20;
+ char pad21[0xB];
+ float f2C;
+ unsigned char b30;
+ unsigned char b31;
+ short s32;
+ unsigned short h34;
+ char pad36[0x12];
+ float f48;
+ char pad4C[0x2C];
+ Child *child;
+ char pad7C[0x14];
+ int f90;
+} Obj;
+
+extern char D_0013D388[];
+extern char D_L12_0016CCF0[];
+extern int D_L12_0015F5C4;
+extern int D_L12_0015F5CC;
+extern void FUN_L00_00298840(int);
+extern int is_point_inside_clip_volume(void *, int) __asm__("FUN_00214720");
+
+void FUN_L12_003093c8(struct Moby *moby) {
+ char *data = (char *)moby->pvars;
+ char *base;
+ char *p;
+ char *q;
+ if (D_L12_0015F5CC != 0 && D_L12_0015F5C4 == 0) {
+ base = D_0013D388;
+ if (*(unsigned char *)(*(int *)(data + 4) + base + 0x5C) != 0) {
+ mark_moby_for_removal(moby);
+ return;
+ }
+ p = (char *)&hero.motion.pos;
+ if (is_point_inside_clip_volume(p, *(int *)data) != 0) {
+ *(char *)(*(int *)(data + 4) + base + 0x5C) = 1;
+ qcopy(D_L12_0016CCF0, p);
+ q = D_L12_0016CCF0 - 0x10;
+ *(float *)(q + 0x18) = *(float *)(p + 0x258);
+ qcopy(D_L12_0016CCF0 + 0x10, p + 0x10);
+ *(short *)(q + 0x46) = 1;
+ FUN_L00_00298840(*(int *)(data + 8));
+ }
+ }
+}
+#ifndef NON_MATCHING
+INCLUDE_ASM("config/us/overlays/asm/FUN_L12_003094a0.s", FUN_L12_003094a0);
+#else
+typedef struct {
+ char pad0[0x30];
+ int phase;
+ char pad34[0x144];
+ int mobys[1];
+} L12VendorMobyList;
+extern L12VendorMobyList D_L12_0016CCE0;
+extern void FUN_L00_002637f8(int);
+
+void FUN_L12_003094a0(struct Moby *moby) {
+ int state = moby->state;
+ int phase;
+ int index;
+
+ switch (state) {
+ case 0:
+ moby->update_dist = 0xff;
+ moby->state = 1;
+ break;
+ case 1:
+ if (D_L12_0015F5C4 != 2) break;
+
+ phase = D_L12_0016CCE0.phase;
+ switch (phase) {
+ case 7: index = 0; break;
+ case 1: index = 2; break;
+ default: return;
+ }
+ FUN_L00_002637f8(D_L12_0016CCE0.mobys[index]);
+ break;
+ }
+}
+#endif
+
+#define NOT_SDA
+
+#define MACRO_ADDR
+
+/* Draws the moby's 10-piece overlay when its trigger is visible, with its own GS state. */
+/* Ported from rac1-decomp (src/overlays/l12_hoven/vendor_002EDAA0.c: func_L12_0030D248), where it is exact; names translated to the US level program. */
+
+extern float D_L12_00162108[2] __attribute__((section(".sdata")));
+extern char D_L12_00208B00[];
+extern int D_L12_001620D4;
+extern int D_L12_001FBD10[];
+extern int D_L12_002059E0[];
+extern int D_L12_00205A08[];
+extern int D_L12_00205A58[];
+extern int is_point_inside_clip_volume(void *, int) __asm__("FUN_00214720");
+extern s64 get_effect_texture(s32) __asm__("func_001F44B8");
+extern void FUN_L00_001fde98(int, int, int, void *, int);
+extern void FUN_L08_00258090(void *, int, int, void *);
+extern void FUN_L08_002f0c18(int);
+extern void vu1_add_g_sregister(s32, unsigned long) __asm__("func_00233980");
+void font_queue_vu_state(void) __asm__("FUN_001f76a0");
+
+void FUN_L12_0030be68(struct Moby *m) {
+ int *d = (int *)m->pvars;
+ int i;
+ font_queue_vu_state();
+ vu1_add_g_sregister(0x42, 0x7F00000064L);
+ vu1_add_g_sregister(8, 0);
+ vu1_add_g_sregister(0x14, 0xFF9000000260L);
+ vu1_add_g_sregister(0x47, 0x5360A);
+ if (is_point_inside_clip_volume(D_L12_00167240, d[0])) {
+ vu1_add_g_sregister(6, get_effect_texture(0x2C));
+ for (i = 0; i < 10; i++) {
+ FUN_L08_00258090(D_L12_00208B00, D_L12_00205A08[i], D_L12_001FBD10[i], D_L12_00162108);
+ FUN_L00_001fde98(D_L12_001FBD10[i], D_L12_002059E0[i], D_L12_00205A58[i],
+ D_L12_00208B00, 1);
+ }
+ }
+ vu1_add_g_sregister(6, get_effect_texture(0x2F));
+ FUN_L08_002f0c18(0);
+ vu1_add_g_sregister(0x42, ((long)D_L12_001620D4 << 32) | 0x68);
+ vu1_add_g_sregister(6, get_effect_texture(0x30));
+ FUN_L08_002f0c18(1);
+}
+/* Builds the colour tables once, then scrolls two pairs of wrapped phases each frame. */
+extern int D_L12_001620F0 __attribute__((sda));
+/* The ready flag is followed, 8 bytes on, by two pairs of phases. */
+extern float D_L12_001620E0[1] __attribute__((sda));
+extern float D_L12_001620D8[2] __attribute__((sda));
+extern float frame_delta_time __asm__("D_0015ED7C") __attribute__((section(".sdata")));
+extern int *D_L12_00208AE0[];
+extern int D_L12_00205A80[];
+extern void FUN_L08_002f0f68(void *, int, void *, float, float, float, float, int);
+extern void enqueue_callback_list_1(void *, void *) __asm__("FUN_001f4600");
+
+typedef struct {
+ char p[0x20];
+ unsigned char state;
+ char q[0xF];
+ unsigned char b30;
+ char r;
+ short h32;
+} M_bff0;
+
+void FUN_L12_0030bff0(M_bff0 *m) {
+ int i;
+ switch (m->state) {
+ case 0:
+ if (D_L12_001620F0 == 0) {
+ FUN_L08_002f0f68(D_L12_00208AE0, 5, D_L12_00205A80, 0.1f, 0.5f, 0.4f, 0.5f, 1);
+ FUN_L08_002f0f68(D_L12_00205A58, 10, D_L12_001FBD10, 0.1f, 0.6f, 0.4f, 0.5f, 1);
+ D_L12_001620F0 = 1;
+ }
+ m->state = 1;
+ m->b30 = 0xFF;
+ m->h32 = 0xFF;
+ for (i = 0; i < 2; i++) {
+ ((float *)&D_L12_001620F0)[i * 2 + 2] = 0.0f;
+ ((float *)&D_L12_001620F0)[i * 2 + 3] = 0.0f;
+ }
+ break;
+ case 1:
+ for (i = 0; i < 2; i++) {
+ ((float *)&D_L12_001620F0)[i * 2 + 2] += D_L12_001620E0[i * 2] * frame_delta_time;
+ if (((float *)&D_L12_001620F0)[i * 2 + 2] > 1.0f) {
+ ((float *)&D_L12_001620F0)[i * 2 + 2] -= 1.0f;
+ }
+ if (((float *)&D_L12_001620F0)[i * 2 + 2] < -1.0f) {
+ ((float *)&D_L12_001620F0)[i * 2 + 2] += 1.0f;
+ }
+ ((float *)&D_L12_001620F0)[i * 2 + 3] += D_L12_001620E0[i * 2 + 1] * frame_delta_time;
+ if (((float *)&D_L12_001620F0)[i * 2 + 3] > 1.0f) {
+ ((float *)&D_L12_001620F0)[i * 2 + 3] -= 1.0f;
+ }
+ if (((float *)&D_L12_001620F0)[i * 2 + 3] < -1.0f) {
+ ((float *)&D_L12_001620F0)[i * 2 + 3] += 1.0f;
+ }
+ }
+ D_L12_00162108[0] += D_L12_001620D8[0] * frame_delta_time;
+ if (D_L12_00162108[0] > 1.0f) {
+ D_L12_00162108[0] -= 1.0f;
+ }
+ if (D_L12_00162108[0] < -1.0f) {
+ D_L12_00162108[0] += 1.0f;
+ }
+ D_L12_00162108[1] += D_L12_001620D8[1] * frame_delta_time;
+ if (D_L12_00162108[1] > 1.0f) {
+ D_L12_00162108[1] -= 1.0f;
+ }
+ if (D_L12_00162108[1] < -1.0f) {
+ D_L12_00162108[1] += 1.0f;
+ }
+ enqueue_callback_list_1(FUN_L12_0030be68, m);
+ break;
+ }
+}
diff --git a/src/overlays/l12/gameplay/entities/hoven_turret.c b/src/overlays/l12/gameplay/entities/hoven_turret.c
index 32f79f084e..cd75f85ec6 100644
--- a/src/overlays/l12/gameplay/entities/hoven_turret.c
+++ b/src/overlays/l12/gameplay/entities/hoven_turret.c
@@ -259,7 +259,7 @@ extern float func_L00_001FF860_304310(float, float) __asm__("FUN_001f9e90");
extern float func_001F9D10_304310(void *, void *) __asm__("FUN_001f9b48");
extern float func_001FA748_304310(float, float) __asm__("FUN_001fa580");
extern float func_001F9FA8_304310(float) __asm__("FUN_001f9de0");
-extern float func_001F9B88_304310(float) __asm__("FUN_001f99c0");
+extern float absolute_float(float) __asm__("FUN_001f99c0");
extern void func_L00_0025C710_304310(void *, void *, void *, float) __asm__("FUN_L00_0025b6b8");
extern float func_001F9D48_304310(void *, void *) __asm__("FUN_001f9b80");
extern void func_001F9BD8_304310(void *, void *, void *) __asm__("FUN_001f9a10");
@@ -316,7 +316,7 @@ void FUN_L12_00302f30(Moby *moby) {
if (1.0f < swing) {
swing = swing - 2.0f;
}
- swing = func_001F9B88_304310(swing);
+ swing = absolute_float(swing);
start.q = row->v10;
end.q = row->v20;
func_L00_0025C710_304310(((float *)&moby->pos), &start, &end, swing);
@@ -505,7 +505,7 @@ extern f32 fast_add_rotations_c3(f32, f32) __asm__("func_001FA580");
extern f32 fast_subtract_rotations(f32, f32) __asm__("func_001FA5C8");
extern f32 random_float_between_c(f32, f32) __asm__("func_002132A8");
extern f32 vector_length_xyz(void *) __asm__("FUN_001f9af0");
-extern float D_0015ED6C_c __asm__("D_0015ED6C") __attribute__((section(".sdata")));
+extern float D_0015ED6C_gp __asm__("D_0015ED6C") __attribute__((section(".sdata")));
extern float D_L12_00161E60 __attribute__((sda));
extern float D_L12_00161E64 __attribute__((sda));
extern float D_L12_00161EA8 __attribute__((sda));
@@ -557,13 +557,13 @@ extern void set_moby_animation(void *, s32, s32) __asm__("func_00212ED8");
extern void tick_countdown_32(s32 *) __asm__("func_001F9740");
void FUN_L12_003032e8_c(struct Moby *moby) __asm__("FUN_L12_003032e8");
extern int D_0013A5E0_e[] __asm__("D_0013CAE0") __attribute__((section(".data")));
-extern int D_0015EE84_e __asm__("D_0015ED84") __attribute__((section(".sdata")));
-extern char D_0013E633_304920[] __asm__("D_0013E533");
+extern int current_level_index __asm__("D_0015ED84") __attribute__((section(".sdata")));
+extern char D_0013E533[];
extern unsigned char D_0014171B_304920[] __asm__("D_0014C050");
extern int D_0015EED0_304920[] __asm__("D_0015EDDC") __attribute__((section(".sdata")));
-extern int D_L12_00160058_m __asm__("D_L12_0015FFD8") __attribute__((section(".sdata")));
+extern Moby *D_L12_0015FFD8_gp __asm__("D_L12_0015FFD8") __attribute__((section(".sdata")));
extern char D_L12_00167180_304920[] __asm__("D_L12_00167100");
-extern int func_001F9908_304920(void *) __asm__("FUN_001f9740");
+extern int fast_dec_timer(void *) __asm__("FUN_001f9740");
extern int func_0020BFC8_304920(int, int) __asm__("FUN_0020b178");
extern f32 frame_scale_macro __asm__("D_0015ED60") __attribute__((section(".sdata")));
@@ -571,12 +571,12 @@ extern f32 frame_time_sq_macro __asm__("D_0015ED70") __attribute__((section(".sd
void FUN_L12_00303540(struct Moby *moby) {
Data_304920 *data = *(Data_304920 **)&moby->pvars;
- ((Snd_304920 *)(D_0013E633_304920 + 0x1D))->f6C = moby;
+ ((Snd_304920 *)(D_0013E533 + 0x1D))->f6C = moby;
switch (moby->state) {
case 0:
D_L12_00161F00 = 0;
D_L12_00161F04 = 0;
- if (D_0014171B_304920[moby->mission + (D_0015EE84_e << 4)] == 0xFF) {
+ if (D_0014171B_304920[moby->mission + (current_level_index << 4)] == 0xFF) {
moby->state = 6;
} else {
attach_manipulator(moby, 0, data);
@@ -590,7 +590,7 @@ void FUN_L12_00303540(struct Moby *moby) {
data->fA0 = moby->pos.z;
data->f98 = -1;
moby->rot.z = 3.1415927f;
- ((Snd_304920 *)(D_0013E633_304920 + 0x1D))->f6C = moby;
+ ((Snd_304920 *)(D_0013E533 + 0x1D))->f6C = moby;
}
break;
case 3: {
@@ -599,23 +599,23 @@ void FUN_L12_00303540(struct Moby *moby) {
FUN_L00_0024f7c8(moby, 3, out);
}
- if (FUN_001f9b80(((float *)&moby->pos), ((Hero *)(D_0013E633_304920 + 0xE1D))->motion.pos.f) < 7.0f
- || ((Hero *)(D_0013E633_304920 + 0xE1D))->ground_moby == moby) {
+ if (FUN_001f9b80(((float *)&moby->pos), ((Hero *)(D_0013E533 + 0xE1D))->motion.pos.f) < 7.0f
+ || ((Hero *)(D_0013E533 + 0xE1D))->ground_moby == moby) {
moby->pos.z = moby->pos.z + ((data->fA0 - 1.2f) - moby->pos.z) * 0.11f;
- data->fA4 = fast_add_rotations_c3(data->fA4, fast_add_rotations_c3(fast_subtract_rotations(FUN_001f9e90(((Hero *)(D_0013E633_304920 + 0xE1D))->motion.pos.f[0] - moby->pos.x, ((Hero *)(D_0013E633_304920 + 0xE1D))->motion.pos.f[1] - moby->pos.y), moby->rot.z), 1.5707964f) * 0.01f) * 0.9f;
+ data->fA4 = fast_add_rotations_c3(data->fA4, fast_add_rotations_c3(fast_subtract_rotations(FUN_001f9e90(((Hero *)(D_0013E533 + 0xE1D))->motion.pos.f[0] - moby->pos.x, ((Hero *)(D_0013E533 + 0xE1D))->motion.pos.f[1] - moby->pos.y), moby->rot.z), 1.5707964f) * 0.01f) * 0.9f;
moby->rot.z = fast_add_rotations_c3(moby->rot.z, data->fA4);
} else {
if (moby->pos.z < data->fA0) {
- moby->pos.z = moby->pos.z + D_0015ED6C_c;
+ moby->pos.z = moby->pos.z + D_0015ED6C_gp;
} else {
moby->pos.z = data->fA0;
}
- if (((Hero *)(D_0013E633_304920 + 0xE1D))->ground_moby != moby && data->f98 != -1) {
+ if (((Hero *)(D_0013E533 + 0xE1D))->ground_moby != moby && data->f98 != -1) {
allocate_voice_for_target_entry_alt(2, 0, (int)moby);
}
}
- if (FUN_001f9b80(((float *)&moby->pos), ((float *)&((Hero *)(D_0013E633_304920 + 0xE1D))->moby->pos)) < 1.3f) {
- if (scale_game_frames_alt(0xF) < ((Hero *)(D_0013E633_304920 + 0xE1D))->grounded_frames) {
+ if (FUN_001f9b80(((float *)&moby->pos), ((float *)&((Hero *)(D_0013E533 + 0xE1D))->moby->pos)) < 1.3f) {
+ if (scale_game_frames_alt(0xF) < ((Hero *)(D_0013E533 + 0xE1D))->grounded_frames) {
FUN_L00_002eaaa0(((float *)&moby->pos), ((float *)&moby->rot), 1, 0, 0);
if (moby->prev_seq != 5) {
set_moby_animation(moby, 5, 0);
@@ -632,14 +632,14 @@ void FUN_L12_00303540(struct Moby *moby) {
}
case 4:
D_L12_00161F00 = 1;
- ((Hero *)(D_0013E633_304920 + 0xE1D))->unk20A5 = 1;
- ((Hero *)(D_0013E633_304920 + 0xE1D))->unk1CC = scale_game_frames_alt(0x78);
- ((Hero *)(D_0013E633_304920 + 0xE1D))->invulnerable_frames = scale_game_frames_alt(0x78);
+ ((Hero *)(D_0013E533 + 0xE1D))->unk20A5 = 1;
+ ((Hero *)(D_0013E533 + 0xE1D))->unk1CC = scale_game_frames_alt(0x78);
+ ((Hero *)(D_0013E533 + 0xE1D))->invulnerable_frames = scale_game_frames_alt(0x78);
if (D_L12_0015F5C4_macro != 2 && D_L12_001619A0 == 0) {
enqueue_callback_list_1(FUN_L12_00304218_c, moby);
}
FUN_L12_00303370(moby);
- if (func_001F9908_304920(&data->f90)) {
+ if (fast_dec_timer(&data->f90)) {
Hit_304920 *hit = (Hit_304920 *)FUN_L00_0025a420(moby, 0x10000, 0);
if (hit != 0) {
data->f90 = scale_game_frames_alt(4);
@@ -648,11 +648,11 @@ void FUN_L12_00303540(struct Moby *moby) {
moby->hit_slot = 0xFF;
}
if (D_L12_00161F24 == 0) {
- if (((Hero *)(D_0013E633_304920 + 0xE1D))->ship_flags & 1) {
+ if (((Hero *)(D_0013E533 + 0xE1D))->ship_flags & 1) {
if (data->f8C > 100.0f) {
D_L12_00161F20--;
}
- ((Hero *)(D_0013E633_304920 + 0xE1D))->ship_flags = 0;
+ ((Hero *)(D_0013E533 + 0xE1D))->ship_flags = 0;
FUN_L00_00211250();
}
if (data->f8C <= 0.0f) {
@@ -662,7 +662,7 @@ void FUN_L12_00303540(struct Moby *moby) {
break;
}
}
- if (data->f94 != -1 && (signed char)((struct Moby *)((data->f94 << 8) + D_L12_00160058_m))->state < 0) {
+ if (data->f94 != -1 && (signed char)((struct Moby *)((data->f94 << 8) + (*(int *)&D_L12_0015FFD8_gp)))->state < 0) {
if (D_L12_0015F5C4_macro == 2) {
if (data->b1 != 0) {
detach_manipulator(moby, data);
@@ -703,20 +703,20 @@ void FUN_L12_00303540(struct Moby *moby) {
float tgt;
float tgt2;
- joy[0] = ((Hero *)(D_0013E633_304920 + 0xE1D))->stick_x;
- y = ((Hero *)(D_0013E633_304920 + 0xE1D))->stick_y;
+ joy[0] = ((Hero *)(D_0013E533 + 0xE1D))->stick_x;
+ y = ((Hero *)(D_0013E533 + 0xE1D))->stick_y;
if (D_0015EED0_304920[0] == 0) {
y = -y;
}
joy[1] = y;
- tgt = D_L12_00161ED0 * 0.017453292f * D_0015ED6C_c * -joy[0];
+ tgt = D_L12_00161ED0 * 0.017453292f * D_0015ED6C_gp * -joy[0];
if ((data->f7C >= 0.0f && data->f7C < tgt) || (data->f7C <= 0.0f && tgt < data->f7C)) {
approach_value(&data->f7C, tgt, D_L12_00161ED8 * 0.017453292f * frame_time_sq_macro);
} else {
approach_value(&data->f7C, tgt, D_L12_00161EE0 * 0.017453292f * frame_time_sq_macro);
}
moby->rot.z = fast_add_rotations_c3(moby->rot.z, data->f7C);
- tgt2 = -(D_L12_00161ED4 * 0.017453292f * D_0015ED6C_c) * -joy[1];
+ tgt2 = -(D_L12_00161ED4 * 0.017453292f * D_0015ED6C_gp) * -joy[1];
if ((data->f78 >= 0.0f && data->f78 < tgt2) || (data->f78 <= 0.0f && tgt2 < data->f78)) {
approach_value(&data->f78, tgt2, D_L12_00161EDC * 0.017453292f * frame_time_sq_macro);
} else {
@@ -742,7 +742,7 @@ void FUN_L12_00303540(struct Moby *moby) {
blend_moby_animation_c(moby, data->f80 == 1 ? 4 : 3, 0, 1);
yaw = fast_add_rotations_c3(moby->rot.z, 1.5707964f);
- build_spherical_offset(dir, D_L12_00161EE8 * D_0015ED6C_c, yaw, data->f74);
+ build_spherical_offset(dir, D_L12_00161EE8 * D_0015ED6C_gp, yaw, data->f74);
if (data->f80 == 1) {
data->f80 = 0;
FUN_L00_0024f7c8(moby, 2, muz);
@@ -771,10 +771,10 @@ void FUN_L12_00303540(struct Moby *moby) {
*(u128 *)vel = *(u128 *)rnd;
normalize_vector_xyz(vel, vel, vector_length_xyz(dir) * (frame_scale_macro * (0.65f - 1.0f) + 1.0f));
add_vector_xyz(vel, dir, vel);
- normalize_vector_xyz(vel, vel, random_float_between_c(D_0015ED6C_c * 3.0f, D_0015ED6C_c * 6.0f));
+ normalize_vector_xyz(vel, vel, random_float_between_c(D_0015ED6C_gp * 3.0f, D_0015ED6C_gp * 6.0f));
FUN_L00_0026dd20(muz, vel, 0x5F2F4F6F, random_int_between(scale_game_frames_alt(5), scale_game_frames_alt(0xA)), 50000.0f);
}
- normalize_vector_xyz(dir, dir, D_0015ED6C_c * 0.5f);
+ normalize_vector_xyz(dir, dir, D_0015ED6C_gp * 0.5f);
FUN_L00_0026dd20(muz, dir, 0x2F4F7F7F, random_int_between(scale_game_frames_alt(4), scale_game_frames_alt(7)), 500000.0f);
}
if (D_L12_001619A0 == 0) {
@@ -869,9 +869,9 @@ extern int D_L12_00161F14 __attribute__((sda));
extern void vu1_add_g_sregister_c(s32, u64) __asm__("func_00233980");
void FUN_L02_0020bc88(long *m, int *b, int *a, long c, int flag);
extern long func_001F4868_3055F8(int) __asm__("FUN_001f44b8");
-extern int func_001FA898_3055F8(float) __asm__("FUN_001fa6d0");
+extern int truncate_float_to_s32(float) __asm__("FUN_001fa6d0");
extern float func_001FA7D8_3055F8(float) __asm__("FUN_001fa610");
-extern float func_001FA888_3055F8(int) __asm__("FUN_001fa6c0");
+extern float convert_integer_to_float(int) __asm__("FUN_001fa6c0");
extern void func_L02_0020BF88_3055F8(void *, void *, void *, long, int) __asm__("FUN_L02_0020bc88");
void FUN_L12_00304218(Moby *moby) {
@@ -914,14 +914,14 @@ void FUN_L12_00304218(Moby *moby) {
xy[2] = 0xFFFFF000000000L;
xy[1] = 0xFFFFF000000000L;
xy[0] = 0xFFFFF000000000L;
- xy[0] += (u32)((func_001FA898_3055F8((*(float *)&D_L12_00161E18 + *(float *)&D_L12_00161E20 * sign_y) * 16.0f) << 16) - (int)0x80000000);
- xy[0] += (func_001FA898_3055F8(*(float *)&D_L12_00161E14 + *(float *)&D_L12_00161E1C * sign_x) << 4) + 0x8000;
- xy[1] += (u32)((func_001FA898_3055F8(*(float *)&D_L12_00161E18 * 16.0f) << 16) - (int)0x80000000);
- xy[1] += (func_001FA898_3055F8(*(float *)&D_L12_00161E14 + *(float *)&D_L12_00161E1C * sign_x) << 4) + 0x8000;
- xy[2] += (u32)((func_001FA898_3055F8((*(float *)&D_L12_00161E18 + *(float *)&D_L12_00161E20 * sign_y) * 16.0f) << 16) - (int)0x80000000);
- xy[2] += (func_001FA898_3055F8(*(float *)&D_L12_00161E14) << 4) + 0x8000;
- xy[3] += (u32)((func_001FA898_3055F8(*(float *)&D_L12_00161E18 * 16.0f) << 16) - (int)0x80000000);
- xy[3] += (func_001FA898_3055F8(*(float *)&D_L12_00161E14) << 4) + 0x8000;
+ xy[0] += (u32)((truncate_float_to_s32((*(float *)&D_L12_00161E18 + *(float *)&D_L12_00161E20 * sign_y) * 16.0f) << 16) - (int)0x80000000);
+ xy[0] += (truncate_float_to_s32(*(float *)&D_L12_00161E14 + *(float *)&D_L12_00161E1C * sign_x) << 4) + 0x8000;
+ xy[1] += (u32)((truncate_float_to_s32(*(float *)&D_L12_00161E18 * 16.0f) << 16) - (int)0x80000000);
+ xy[1] += (truncate_float_to_s32(*(float *)&D_L12_00161E14 + *(float *)&D_L12_00161E1C * sign_x) << 4) + 0x8000;
+ xy[2] += (u32)((truncate_float_to_s32((*(float *)&D_L12_00161E18 + *(float *)&D_L12_00161E20 * sign_y) * 16.0f) << 16) - (int)0x80000000);
+ xy[2] += (truncate_float_to_s32(*(float *)&D_L12_00161E14) << 4) + 0x8000;
+ xy[3] += (u32)((truncate_float_to_s32(*(float *)&D_L12_00161E18 * 16.0f) << 16) - (int)0x80000000);
+ xy[3] += (truncate_float_to_s32(*(float *)&D_L12_00161E14) << 4) + 0x8000;
func_L02_0020BF88_3055F8(xy, uv, colors, texture, 1);
}
texture = func_001F4868_3055F8(6);
@@ -934,7 +934,7 @@ void FUN_L12_00304218(Moby *moby) {
} else {
color = FUN_001fa6e0(0x600000FF, 0x6000FFFF, data->f8C / 100.0f);
}
- filled = func_001FA898_3055F8((1.0f - data->f8C / 200.0f) * 32.0f);
+ filled = truncate_float_to_s32((1.0f - data->f8C / 200.0f) * 32.0f);
dim_color = (color & 0xFFFFFF) + 0x20000000;
for (j = 0; j < 32; j++) {
float start_angle, end_angle;
@@ -952,28 +952,28 @@ void FUN_L12_00304218(Moby *moby) {
}
start_angle = func_001FA7D8_3055F8((float)j * 0.19634955f);
end_angle = fast_add_rotations_c2(start_angle, 0.19634955f);
- x0 = func_001FA898_3055F8(*(float *)&D_L12_00161E24 * fast_sin(start_angle));
- y0 = func_001FA898_3055F8(*(float *)&D_L12_00161E28 * -fast_cos(start_angle));
- x1 = func_001FA898_3055F8(*(float *)&D_L12_00161E24 * fast_sin(end_angle));
- y1 = func_001FA898_3055F8(*(float *)&D_L12_00161E28 * -fast_cos(end_angle));
+ x0 = truncate_float_to_s32(*(float *)&D_L12_00161E24 * fast_sin(start_angle));
+ y0 = truncate_float_to_s32(*(float *)&D_L12_00161E28 * -fast_cos(start_angle));
+ x1 = truncate_float_to_s32(*(float *)&D_L12_00161E24 * fast_sin(end_angle));
+ y1 = truncate_float_to_s32(*(float *)&D_L12_00161E28 * -fast_cos(end_angle));
xy[3] = 0xFFFFF000000000L;
xy[2] = 0xFFFFF000000000L;
xy[1] = 0xFFFFF000000000L;
xy[0] = 0xFFFFF000000000L;
- xy[0] += (u32)((func_001FA898_3055F8((*(float *)&D_L12_00161E18 + (float)y1) * 16.0f) << 16) - (int)0x80000000);
- xy[0] += (func_001FA898_3055F8(*(float *)&D_L12_00161E14 + (float)x1) << 4) + 0x8000;
- xy[1] += (u32)((func_001FA898_3055F8(*(float *)&D_L12_00161E18 * 16.0f) << 16) - (int)0x80000000);
- xy[1] += (func_001FA898_3055F8(*(float *)&D_L12_00161E14) << 4) + 0x8000;
- xy[2] += (u32)((func_001FA898_3055F8((*(float *)&D_L12_00161E18 + (float)y0) * 16.0f) << 16) - (int)0x80000000);
- xy[2] += (func_001FA898_3055F8(*(float *)&D_L12_00161E14 + (float)x0) << 4) + 0x8000;
- xy[3] += (u32)((func_001FA898_3055F8(*(float *)&D_L12_00161E18 * 16.0f) << 16) - (int)0x80000000);
- xy[3] += (func_001FA898_3055F8(*(float *)&D_L12_00161E14) << 4) + 0x8000;
+ xy[0] += (u32)((truncate_float_to_s32((*(float *)&D_L12_00161E18 + (float)y1) * 16.0f) << 16) - (int)0x80000000);
+ xy[0] += (truncate_float_to_s32(*(float *)&D_L12_00161E14 + (float)x1) << 4) + 0x8000;
+ xy[1] += (u32)((truncate_float_to_s32(*(float *)&D_L12_00161E18 * 16.0f) << 16) - (int)0x80000000);
+ xy[1] += (truncate_float_to_s32(*(float *)&D_L12_00161E14) << 4) + 0x8000;
+ xy[2] += (u32)((truncate_float_to_s32((*(float *)&D_L12_00161E18 + (float)y0) * 16.0f) << 16) - (int)0x80000000);
+ xy[2] += (truncate_float_to_s32(*(float *)&D_L12_00161E14 + (float)x0) << 4) + 0x8000;
+ xy[3] += (u32)((truncate_float_to_s32(*(float *)&D_L12_00161E18 * 16.0f) << 16) - (int)0x80000000);
+ xy[3] += (truncate_float_to_s32(*(float *)&D_L12_00161E14) << 4) + 0x8000;
func_L02_0020BF88_3055F8(xy, uv, colors, texture, 1);
}
if (scale_game_frames_alt(0xF) < data->f88) {
- color = FUN_001fa6e0(0x5000FFFF, 0x500000FF, func_001FA888_3055F8(data->f88 - scale_game_frames_alt(0xF)) / (float)scale_game_frames_alt(0xF));
+ color = FUN_001fa6e0(0x5000FFFF, 0x500000FF, convert_integer_to_float(data->f88 - scale_game_frames_alt(0xF)) / (float)scale_game_frames_alt(0xF));
} else {
- color = FUN_001fa6e0(0x5000FF00, 0x5000FFFF, func_001FA888_3055F8(data->f88) / (float)scale_game_frames_alt(0xF));
+ color = FUN_001fa6e0(0x5000FF00, 0x5000FFFF, convert_integer_to_float(data->f88) / (float)scale_game_frames_alt(0xF));
}
uv[0] = D_L12_00161E4C;
uv[1] = D_L12_00161E50;
@@ -988,34 +988,34 @@ void FUN_L12_00304218(Moby *moby) {
xy[1] = 0xFFFFF000000000L;
xy[0] = 0xFFFFF000000000L;
angle = func_001FA7D8_3055F8(fast_add_rotations_c2(moby->rot.z * 4.0f, 0.0f));
- xy[0] += (u32)((func_001FA898_3055F8(fast_sin(angle) * *(float *)&D_L12_00161E48 * 16.0f) << 16) - (int)0x80000000);
- xy[0] += func_001FA898_3055F8(fast_cos(angle) * *(float *)&D_L12_00161E44 * 16.0f) + 0x8000;
+ xy[0] += (u32)((truncate_float_to_s32(fast_sin(angle) * *(float *)&D_L12_00161E48 * 16.0f) << 16) - (int)0x80000000);
+ xy[0] += truncate_float_to_s32(fast_cos(angle) * *(float *)&D_L12_00161E44 * 16.0f) + 0x8000;
angle = func_001FA7D8_3055F8(fast_add_rotations_c2(moby->rot.z * 4.0f, 1.5707964f));
- xy[1] += (u32)((func_001FA898_3055F8(fast_sin(angle) * *(float *)&D_L12_00161E48 * 16.0f) << 16) - (int)0x80000000);
- xy[1] += func_001FA898_3055F8(fast_cos(angle) * *(float *)&D_L12_00161E44 * 16.0f) + 0x8000;
+ xy[1] += (u32)((truncate_float_to_s32(fast_sin(angle) * *(float *)&D_L12_00161E48 * 16.0f) << 16) - (int)0x80000000);
+ xy[1] += truncate_float_to_s32(fast_cos(angle) * *(float *)&D_L12_00161E44 * 16.0f) + 0x8000;
angle = func_001FA7D8_3055F8(fast_add_rotations_c2(moby->rot.z * 4.0f, -1.5707964f));
- xy[2] += (u32)((func_001FA898_3055F8(fast_sin(angle) * *(float *)&D_L12_00161E48 * 16.0f) << 16) - (int)0x80000000);
- xy[2] += func_001FA898_3055F8(fast_cos(angle) * *(float *)&D_L12_00161E44 * 16.0f) + 0x8000;
+ xy[2] += (u32)((truncate_float_to_s32(fast_sin(angle) * *(float *)&D_L12_00161E48 * 16.0f) << 16) - (int)0x80000000);
+ xy[2] += truncate_float_to_s32(fast_cos(angle) * *(float *)&D_L12_00161E44 * 16.0f) + 0x8000;
angle = func_001FA7D8_3055F8(fast_add_rotations_c2(moby->rot.z * 4.0f, 3.1415927f));
- xy[3] += (u32)((func_001FA898_3055F8(fast_sin(angle) * *(float *)&D_L12_00161E48 * 16.0f) << 16) - (int)0x80000000);
- xy[3] += func_001FA898_3055F8(fast_cos(angle) * *(float *)&D_L12_00161E44 * 16.0f) + 0x8000;
+ xy[3] += (u32)((truncate_float_to_s32(fast_sin(angle) * *(float *)&D_L12_00161E48 * 16.0f) << 16) - (int)0x80000000);
+ xy[3] += truncate_float_to_s32(fast_cos(angle) * *(float *)&D_L12_00161E44 * 16.0f) + 0x8000;
func_L02_0020BF88_3055F8(xy, uv, colors, get_effect_texture(D_L12_00161E3C), 1);
xy[3] = 0xFFFFF000000000L;
xy[2] = 0xFFFFF000000000L;
xy[1] = 0xFFFFF000000000L;
xy[0] = 0xFFFFF000000000L;
angle = func_001FA7D8_3055F8(fast_add_rotations_c2(data->f74 * 8.0f, 0.0f));
- xy[0] += (u32)((func_001FA898_3055F8(fast_sin(angle) * *(float *)&D_L12_00161E48 * 16.0f) << 16) - (int)0x80000000);
- xy[0] += func_001FA898_3055F8(fast_cos(angle) * *(float *)&D_L12_00161E44 * 16.0f) + 0x8000;
+ xy[0] += (u32)((truncate_float_to_s32(fast_sin(angle) * *(float *)&D_L12_00161E48 * 16.0f) << 16) - (int)0x80000000);
+ xy[0] += truncate_float_to_s32(fast_cos(angle) * *(float *)&D_L12_00161E44 * 16.0f) + 0x8000;
angle = func_001FA7D8_3055F8(fast_add_rotations_c2(data->f74 * 8.0f, 1.5707964f));
- xy[1] += (u32)((func_001FA898_3055F8(fast_sin(angle) * *(float *)&D_L12_00161E48 * 16.0f) << 16) - (int)0x80000000);
- xy[1] += func_001FA898_3055F8(fast_cos(angle) * *(float *)&D_L12_00161E44 * 16.0f) + 0x8000;
+ xy[1] += (u32)((truncate_float_to_s32(fast_sin(angle) * *(float *)&D_L12_00161E48 * 16.0f) << 16) - (int)0x80000000);
+ xy[1] += truncate_float_to_s32(fast_cos(angle) * *(float *)&D_L12_00161E44 * 16.0f) + 0x8000;
angle = func_001FA7D8_3055F8(fast_add_rotations_c2(data->f74 * 8.0f, -1.5707964f));
- xy[2] += (u32)((func_001FA898_3055F8(fast_sin(angle) * *(float *)&D_L12_00161E48 * 16.0f) << 16) - (int)0x80000000);
- xy[2] += func_001FA898_3055F8(fast_cos(angle) * *(float *)&D_L12_00161E44 * 16.0f) + 0x8000;
+ xy[2] += (u32)((truncate_float_to_s32(fast_sin(angle) * *(float *)&D_L12_00161E48 * 16.0f) << 16) - (int)0x80000000);
+ xy[2] += truncate_float_to_s32(fast_cos(angle) * *(float *)&D_L12_00161E44 * 16.0f) + 0x8000;
angle = func_001FA7D8_3055F8(fast_add_rotations_c2(data->f74 * 8.0f, 3.1415927f));
- xy[3] += (u32)((func_001FA898_3055F8(fast_sin(angle) * *(float *)&D_L12_00161E48 * 16.0f) << 16) - (int)0x80000000);
- xy[3] += func_001FA898_3055F8(fast_cos(angle) * *(float *)&D_L12_00161E44 * 16.0f) + 0x8000;
+ xy[3] += (u32)((truncate_float_to_s32(fast_sin(angle) * *(float *)&D_L12_00161E48 * 16.0f) << 16) - (int)0x80000000);
+ xy[3] += truncate_float_to_s32(fast_cos(angle) * *(float *)&D_L12_00161E44 * 16.0f) + 0x8000;
func_L02_0020BF88_3055F8(xy, uv, colors, get_effect_texture(D_L12_00161E40), 1);
}
extern int scale_ticks(int) __asm__("FUN_001f96f8");
@@ -1183,1284 +1183,3 @@ void FUN_L12_00304e00(struct Moby *moby) {
}
FUN_L00_00259fe8(1.0f, moby);
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L12_003054b0.s", FUN_L12_003054b0);
-#else
-extern char *D_L12_0015FFD8_gp __asm__("D_L12_0015FFD8") __attribute__((sda));
-extern int D_L12_001FB670[], D_L12_001FB688[];
-extern int D_L12_00161F34 __attribute__((sda));
-extern int D_L12_00161F20 __attribute__((sda));
-extern int D_L12_00161F24 __attribute__((sda));
-extern float D_0013F420[];
-extern int FUN_L00_001fefc8(void *);
-extern float random_float_between(float, float) __asm__("FUN_002132a8");
-extern float random_angle(void) __asm__("FUN_00213308");
-extern float fast_difference_between_rotations(float, float) __asm__("FUN_001fa688");
-extern float steer_rotation_l12(float *, int, float, float) __asm__("FUN_L00_0025bc00");
-extern float accelerate_rotation_l12(void *, float, void *, int, float, float, float) __asm__("FUN_L00_0025bc98");
-extern void FUN_L00_002628d8(void *, void *, int, float, float);
-extern void FUN_L00_00269958(void *, void *, int, int, int, int, int, int);
-extern void FUN_L00_0026ced0(void *, void *, int, int, float, int);
-extern int FUN_L04_002aee30(void *, void *, void *, int);
-extern int D_L12_00161F00_lui __asm__("D_L12_00161F00") __attribute__((section(".data")));
-extern int D_L12_00161F04_lui __asm__("D_L12_00161F04") __attribute__((section(".data")));
-extern void FUN_L12_00306350(struct Moby *, int);
-extern void FUN_L12_003064e8(void *);
-
-void FUN_L12_003054b0(void *moby) {
- float position[4] __attribute__((aligned(16)));
- float velocity[4] __attribute__((aligned(16)));
- float target[4] __attribute__((aligned(16)));
- float particle[4] __attribute__((aligned(16)));
- char *data = (char *)((struct Moby *)moby)->pvars;
- float *velocity_ptr = velocity;
- float *target_ptr = target;
- int index;
- for (index = 0; index < 5; index++) {
- int slot = *(int *)(data + 0x5d0 + index * 4);
- char *slot_data;
- struct Moby *other;
- char *other_data;
- float yaw, pitch, distance, height, amount, angle, radius, speed;
- int active, state, count, i, life, color, red, green;
- if (slot == -1) continue;
- slot_data = data + slot * 0x30;
- other = (struct Moby *)(D_L12_0015FFD8_gp + *(int *)(slot_data + 0x20) * 0x100);
- other_data = (char *)other->pvars;
- *(u128 *)position = *(u128 *)D_L12_00167240;
- position[2] -= 0.7f;
- qcopy(velocity_ptr, &other->pos);
- velocity[2] += 1.5f;
- distance = FUN_001f9b80(velocity_ptr, position);
- pitch = FUN_001f9e90(distance, position[2] - velocity[2]);
- speed = frame_scale_sq;
- amount = speed * 0.3f;
- radius = speed * 0.008f;
- *(float *)(other_data + 0x60) = pitch;
- FUN_L00_002628d8(other, other_data, 0, radius, amount);
- yaw = FUN_001f9e90(hero.motion.pos.f[0] - other->pos.x, hero.motion.pos.f[1] - other->pos.y);
- yaw = fast_add_rotations(yaw, -1.5707964f);
- yaw = fast_subtract_rotations(yaw, ((struct Moby *)moby)->rot.z);
- if (*(short *)(other_data + 0x90) == 0) {
- if (steer_rotation_l12((float *)(slot_data + 0x18), 0, yaw,
- frame_time * 0.5235988f + frame_time * 0.17453292f * (float)index) < 0.08726646f) {
- *(short *)(other_data + 0x90) = 1;
- *(float *)(other_data + 0x8c) = 1.0f;
- if (index & 1) *(float *)(other_data + 0x8c) = -1.0f;
- }
- } else {
- angle = fast_add_rotations(yaw, *(float *)(other_data + 0x8c) * 0.55850536f);
- angle = accelerate_rotation_l12(slot_data + 0x18, angle, other_data + 0x94, 0,
- frame_scale_sq * 0.022f, frame_scale_sq * 0.3f,
- frame_time * 0.2617994f + (float)index * (frame_time * 0.05235988f));
- if (absolute_float(angle) < 0.017453292f) *(float *)(other_data + 0x8c) = -*(float *)(other_data + 0x8c);
- }
- {
- float *position = D_0013F4D0_304310;
- active = 0;
- distance = FUN_001f9b80(&((struct Moby *)moby)->pos, position);
- height = absolute_float(position[2] - ((struct Moby *)moby)->pos.z);
- if (scale_game_frames_alt(1200) < D_L12_00161F34 && distance < 80.0f && height < 4.0f) active = 1;
- if (distance > 90.0f || height > 7.0f) {
- D_L12_00161F34 = 0;
- state = D_L12_00161F00_lui;
- } else state = D_L12_00161F00;
- }
- if ((state || active) && *(float *)(other_data + 0x80) > 0.0f) {
- FUN_001f9770(other_data + 0x98);
- FUN_001f9770(other_data + 0x9c);
- state = D_L12_00161F04;
- if (*(short *)(other_data + 0x98) == 0) {
- if (fast_difference_between_rotations(*(float *)(data + slot * 0x30 + 0x18), yaw) < 0.06981317f)
- *(short *)(other_data + 0x9e) = scale_game_frames_alt(20);
- if (!FUN_001f9770(other_data + 0x9e)) {
- state = D_L12_00161F04;
- if (!FUN_L00_001fefc8(other_data + 0x92) && FUN_L00_001fefc8(other_data + 0x93)) {
- FUN_0022da68(0, 0, other);
- *(char *)(other_data + 0x93) = scale_game_frames_alt(9);
- }
- if (FUN_001f9770(other_data + 0x9c)) {
- FUN_L00_0024f7c8(other, *(short *)(other_data + 0x9a) + 1, position);
- *(short *)(other_data + 0x9a) = *(short *)(other_data + 0x9a) == 0;
- angle = fast_add_rotations(other->rot.z, 1.5707964f);
- if (D_L12_00161F00_lui) {
- qcopy(target_ptr, D_L12_00167240);
- target[2] += random_float_between(-1.5f, 0.3f);
- } else {
- qcopy(target_ptr, D_0013F420);
- target[2] += randf_sym(0.0f, 0.5f);
- }
- count = D_L12_00161F20 - 3;
- if (scale_game_frames_alt(5) < count) count = scale_game_frames_alt(5);
- if (count < 0) count = 0;
- target[2] += random_float_between((float)count * -0.3f, (float)count * 0.3f);
- distance = FUN_001f9b80(position, target);
- pitch = FUN_001f9e90(distance, target[2] - position[2]);
- build_spherical_offset(velocity, frame_time * 80.0f, angle, pitch);
- life = scale_game_frames_alt(150);
- if (FUN_L04_002aee30(other, position, velocity, life)) {
- *(char *)(other_data + 0x92) = scale_game_frames_alt(20);
- i = 8;
- do {
- i--;
- particle[0] = randf_sym(0.0f, frame_time * 1.7f);
- particle[1] = randf_sym(0.0f, frame_time * 1.7f);
- particle[2] = randf_sym(0.0f, frame_time * 1.7f);
- red = random_int_between(170, 240);
- green = random_int_between(110, 200);
- color = (green << 8) | (red | 0x7f000000);
- life = scale_game_frames_alt(random_int_between(15, 30));
- count = random_int_between(180, 270);
- FUN_L00_00269958(position, particle, color, 255, life, 55, count, 1);
- } while (i >= 0);
- }
- *(short *)(other_data + 0x9c) = scale_game_frames_alt(7);
- count = D_L12_00161F20;
- if (scale_game_frames_alt(11) < count) count = scale_game_frames_alt(11);
- if (count < 0) count = 0;
- *(short *)(other_data + 0x9c) += count;
- state = D_L12_00161F04_lui;
- } else state = D_L12_00161F04_lui;
- }
- }
- }
- else state = D_L12_00161F04_lui;
- if (!state && *(float *)(other_data + 0x80) > 0.0f && tick_countdown_32_alt((int *)(other_data + 0x84))) {
- amount = 1.0f;
- if (!FUN_L00_0025a420(other, 0x50000, 0)) {
- int linked_slot = D_L12_001FB670[index];
- struct Moby *selected = (struct Moby *)moby;
- if (linked_slot != 17) {
- int linked = *(int *)(data + linked_slot * 0x30 + 0x20);
- selected = 0;
- if (linked != -1) selected = (struct Moby *)(D_L12_0015FFD8_gp + linked * 0x100);
- }
- if (!selected) goto hit_done;
- amount = 0.2f;
- active = FUN_L00_0025a420(selected, 0x50000, 0) != 0;
- selected->hit_slot = 255;
- if (!active) goto hit_done;
- }
- if (!D_L12_00161F00) D_L12_00161F34 = scale_game_frames_alt(4000);
- else {
- *(int *)(other_data + 0x84) = scale_game_frames_alt(20);
- *(float *)(other_data + 0x80) -= amount;
- if (*(float *)(other_data + 0x80) <= 0.0f) {
- *(short *)(data + 0x5fc) -= 20;
- if (*(short *)(data + 0x5fc) < 0) *(short *)(data + 0x5fc) = 0;
- FUN_0022da68(1, 0, other);
- if (*(short *)(data + 0x5fc) > 0) {
- int linked_slot = D_L12_001FB670[index];
- if (linked_slot != 17) {
- char *linked_data = data + linked_slot * 0x30;
- D_L12_001FB688[linked_slot] = *(int *)(linked_data + 0x20);
- *(int *)(linked_data + 0x20) = -1;
- }
- else D_L12_001FB688[17] = 1;
- FUN_L12_00306350(moby, linked_slot);
- if (index == 4) {
- char *linked_data = data;
- int *saved = D_L12_001FB688;
- for (i = 0; i < 17; i++, saved++, linked_data += 0x30) {
- int linked = *(int *)(linked_data + 0x20);
- if (linked != -1 && ((struct Moby *)(D_L12_0015FFD8_gp + linked * 0x100))->oclass == 0x4fd) {
- *saved = linked;
- *(int *)(linked_data + 0x20) = -1;
- FUN_L12_00306350(moby, i);
- }
- }
- }
- }
- i = 129;
- do {
- qcopy(position, &other->pos);
- i--;
- position[2] += random_float_between(0.1f, 0.5f);
- angle = random_angle();
- radius = random_float_between(0.1f, 0.8f);
- position[0] += fast_cos(angle) * radius;
- position[1] += fast_sin(angle) * radius;
- red = scale_game_frames_alt(90);
- green = scale_game_frames_alt(180);
- life = random_int_between(red, green);
- radius = random_float_between(frame_time * 0.7f, frame_time * 1.5f);
- velocity[0] = fast_cos(angle) * radius;
- velocity[1] = fast_sin(angle) * radius;
- velocity[2] = 0.0f;
- velocity[2] = random_float_between(frame_time, frame_time * 5.5f);
- FUN_L00_0026ced0(position, velocity, 0x500a1414, 0xa0a0a, 420000.0f, life);
- } while (i >= 0);
- other->collision = 0;
- other->flags |= 0x41;
- }
- }
- }
-hit_done:
- other->hit_slot = 255;
- if (*(float *)(other_data + 0x80) > 0.0f && *(float *)(other_data + 0x80) < 10.0f) {
- int count, life, red, green, color;
- int i;
- count = (9 - truncate_float_to_s32(*(float *)(other_data + 0x80))) / 2;
- if (count + 3 > 0) {
- i = count + 3;
- do {
- qcopy(position, &other->pos);
- i--;
- position[2] += 0.7f;
- angle = random_angle();
- radius = random_float_between(0.1f, 0.4f);
- position[0] += fast_cos(angle) * radius;
- position[1] += fast_sin(angle) * radius;
- red = scale_game_frames_alt(25);
- green = scale_game_frames_alt(55);
- life = random_int_between(red, green);
- radius = random_float_between(frame_time * 0.5f, frame_time * 3.0f);
- velocity[0] = fast_cos(angle) * radius;
- velocity[1] = fast_sin(angle) * radius;
- velocity[2] = 0.0f;
- radius = random_float_between(frame_time * 7.0f, frame_time * 17.0f);
- height = convert_integer_to_float(count);
- amount = convert_integer_to_float(5);
- radius = radius * height;
- radius = radius * 1.5f;
- radius = radius / amount;
- velocity[2] = radius;
- color = random_int_between(70, 205);
- FUN_L00_0026ced0(position, velocity, (color << 8) | 0x460a00aa, 0xa0a46, 420000.0f, life);
- } while (i != 0);
- }
- i = 2;
- do {
- qcopy(position, &other->pos);
- i--;
- angle = random_angle();
- radius = random_float_between(0.1f, 0.8f);
- position[0] += fast_cos(angle) * radius;
- position[1] += fast_sin(angle) * radius;
- red = scale_game_frames_alt(40);
- green = scale_game_frames_alt(70);
- life = random_int_between(red, green);
- radius = random_float_between(frame_time * 0.1f, frame_time * 0.4f);
- velocity[0] = fast_cos(angle) * radius;
- velocity[1] = fast_sin(angle) * radius;
- velocity[2] = 0.0f;
- velocity[2] = random_float_between(frame_time * 2.4f, frame_time * 5.5f);
- FUN_L00_0026ced0(position, velocity, 0x460a1414, 0xa0a0a, 504000.03125f, life);
- } while (i >= 0);
- }
- }
- FUN_L12_003064e8(moby);
- if (*(short *)(data + 0x5fc) < 1 && !D_L12_00161F04_lui) {
- D_L12_00161F24 = 1;
- ((struct Moby *)moby)->state = 4;
- ((struct Moby *)moby)->command = 0;
- }
-}
-#endif
-extern int D_L12_001FB688[];
-extern float random_float_between(float, float) __asm__("FUN_002132a8");
-extern float randf_sym(float, float) __asm__("FUN_L00_00257c48");
-
-void FUN_L12_00306350(struct Moby *moby, int slot) {
- char *data = (char *)moby->pvars;
- struct Moby *selected;
- float *speed;
- int offset;
- float initial_speed;
- float angle_scale;
- float first_angle;
- float second_scale;
- char *slot_data;
-
- if (slot == 0x11) {
- selected = moby;
- offset = 0x44;
- } else {
- selected = (struct Moby *)(D_L12_0015FFD8_p + D_L12_001FB688[slot] * 0x100);
- offset = slot * 4;
- }
-
- initial_speed = random_float_between(frame_time_sq * 3.7f, frame_time_sq * 5.0f);
- angle_scale = frame_time;
- {
- char *base = data + 0x570;
- speed = (float *)(base + offset);
- }
- *speed = initial_speed;
- first_angle = randf_sym(angle_scale * 0.05235988f, angle_scale * 0.13962634f);
- second_scale = frame_time;
- slot_data = data + slot * 0x10;
- *(float *)(slot_data + 0x450) = first_angle;
- *(float *)(slot_data + 0x454) = randf_sym(second_scale * 0.05235988f, second_scale * 0.17453292f);
- if (selected->oclass == 0x4fd) {
- float variation = random_float_between(0.001f, 0.0045f);
- float speed_scale = frame_time_sq;
- *(float *)(slot_data + 0x45c) = variation;
- *speed = random_float_between(speed_scale * 5.5f, speed_scale * 9.0f);
- } else if (selected->oclass == 0x500) {
- *speed = frame_time_sq * 13.0f;
- }
-}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L12_003064e8.s", FUN_L12_003064e8);
-#else
-extern float D_L12_00161F40;
-extern float D_L12_00161F50[4];
-extern float D_L12_00161F60[4], D_L12_00161F70[4];
-extern float FUN_L00_0025bc98(void *, void *, int, float, float, float, float);
-extern void FUN_L00_00250df8(unsigned char *);
-
-void FUN_L12_003064e8(void *moby) {
- char *data;
- int *saved = D_L12_001FB688;
- int i = 0;
- int offset = 0;
- char *slot_data;
- float *speed;
- data = (char *)((struct Moby *)moby)->pvars;
- speed = (float *)(data + 0x454);
- slot_data = data;
- do {
- int index = *saved;
- if (index != 0) {
- struct Moby *other;
- float height;
- int slot_offset;
- if (i == 17) {
- other = (struct Moby *)moby;
- } else {
- if (index == -1) goto next_slot;
- other = (struct Moby *)(D_L12_0015FFD8_p + index * 0x100);
- }
- if (i == 17) {
- /* Retail stores the saved rotation 16 bytes after the saved position. */
- if (D_L12_00161F40 == -1.0f) {
- qcopy(&D_L12_00161F40, &other->pos);
- qcopy((char *)&D_L12_00161F40 + 16, &other->rot);
- }
- qcopy(D_L12_00161F60, &other->pos);
- qcopy(D_L12_00161F70, &other->rot);
- qcopy(&other->pos, &D_L12_00161F40);
- qcopy(&other->rot, (char *)&D_L12_00161F40 + 16);
- }
- if (other->pos.z < 20.0f) {
- if (i == 17) return;
- mark_moby_for_removal(other);
- *saved = -1;
- }
- slot_offset = i << 4;
- height = *(float *)(slot_data + 0x338) - *(float *)(data + offset + 0x570);
- *(float *)(slot_data + 0x338) = height;
- other->pos.z += height;
- if (other->oclass == 0x500) {
- other->rot.x = fast_add_rotations(other->rot.x, D_0015ED6C * 0.34906584f);
- FUN_L00_0025bc98(&other->rot.y, speed, 0, 1.5707964f, 0.002f, 0.3f, 0.0f);
- } else if (other->oclass == 0x4fd) {
- other->rot.x = fast_add_rotations(other->rot.x, *(float *)(slot_data + 0x450));
- FUN_L00_0025bc98(&other->rot.y, (char *)((int)data + slot_offset) + 0x454, 0, -1.5707964f, *(float *)(slot_data + 0x45c), 0.3f, 0.0f);
- } else if (other->oclass == 0x4fa) {
- other->rot.x = fast_add_rotations(other->rot.x, frame_time * -0.87266463f);
- other->rot.y = fast_add_rotations(other->rot.y, *(float *)(slot_data + 0x454));
- other->pos.y += D_0015ED6C * -4.0f;
- } else {
- other->pos.y += frame_time * -4.0f;
- other->rot.x = fast_add_rotations(other->rot.x, *(float *)(slot_data + 0x450));
- other->rot.y = fast_add_rotations(other->rot.y, *(float *)(slot_data + 0x454));
- }
- if (i == 17) {
- qcopy(&D_L12_00161F40, &other->pos);
- qcopy((char *)&D_L12_00161F40 + 16, &other->rot);
- }
- FUN_L00_00250df8((unsigned char *)other);
- }
-next_slot:
- i++;
- speed += 4;
- slot_data += 0x10;
- offset += 4;
- saved++;
- } while (i < 18);
-}
-#endif
-#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");
-
-extern struct Moby *D_L12_0015FFD8_lui __asm__("D_L12_0015FFD8") __attribute__((section(".data")));
-
-void FUN_L12_00306828(struct Moby *moby) {
- int i;
- int alpha = 0x80000000;
- char *data = (char *)moby->pvars;
- for (i = 0; i < 18; i++) {
- struct Moby *other;
- int period;
- float sine;
- float color;
- unsigned 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 (other->oclass != 0x4FE) {
- period = scale_ticks(0xAA);
- divisor = convert_integer_to_float(period);
- 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);
- 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;
- }
- }
-}
-#endif /* NON_MATCHING */
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L12_003069d0.s", FUN_L12_003069d0);
-#else
-extern float FUN_L00_0025b8c0(float *, float *, float, float, float, float);
-extern float fast_difference_between_rotations(float, float) __asm__("FUN_001fa688");
-extern int D_L12_001619B4;
-extern int D_L12_001FB6CC;
-extern float D_L12_00161F40;
-extern float D_L12_00161F60[4], D_L12_00161F70[4];
-extern float D_L12_00161F28 __attribute__((sda));
-extern float D_L12_00161F2C __attribute__((sda));
-extern float D_L12_00161F30 __attribute__((sda));
-extern int D_L12_00161F34 __attribute__((sda));
-extern int D_L12_0015F404 __attribute__((sda));
-extern char *D_L12_001600EC;
-extern unsigned char D_0014C050[];
-extern void FUN_L12_0027b268(void *, void *, int);
-extern void FUN_L12_0027b370(void *, void *, int);
-extern void FUN_L00_00262b00(void *, void *, void *, float, float);
-extern void FUN_L00_00262b80(void *, void *, void *, float, float, float);
-extern float FUN_L00_00258278(void *, void *, float, float, float, float);
-extern float FUN_L00_0025bc98(void *, void *, int, float, float, float, float);
-extern float advance_accelerated_scalar_l12(void *, void *, float, float, float, float) __asm__("FUN_00213f38");
-extern void FUN_001f9a28(void *, void *, void *);
-extern void FUN_001f9bf8(void *, void *, float);
-extern void FUN_001f9a40(void *, void *, void *, float);
-extern void FUN_L00_002eac18(int);
-extern int FUN_00214720(void *, int);
-extern void FUN_L12_003054b0(void *);
-extern void FUN_L12_003064e8(void *);
-extern int FUN_0022da68(int, int, void *);
-extern void release_voice_slot(int) __asm__("FUN_0022d798");
-
-extern int D_L12_00161F00_lui __asm__("D_L12_00161F00") __attribute__((section(".data")));
-extern struct Moby *D_L12_0015FFD8_lui __asm__("D_L12_0015FFD8") __attribute__((section(".data")));
-extern int D_L12_001619A0_lui __asm__("D_L12_001619A0") __attribute__((section(".data")));
-extern int D_L12_001619B4_gp __asm__("D_L12_001619B4") __attribute__((sda));
-extern int D_L12_001619B4_lui __asm__("D_L12_001619B4") __attribute__((section(".data")));
-void FUN_L12_003069d0(struct Moby *moby) {
- float direction[4] __attribute__((aligned(16)));
- float rotation[4] __attribute__((aligned(16)));
- char *data = (char *)moby->pvars;
- int i;
- int next;
- int *slot;
- int *saved;
- struct Moby *other;
- float height, angle, distance;
- int triggered;
-
- if (moby->state != 0 && D_L12_001FB688[17] != 0) {
- float *slot = (float *)&moby->pos;
- float *saved = D_L12_00161F60;
- qcopy(slot, saved);
- slot = (float *)&moby->rot;
- saved = D_L12_00161F70;
- qcopy(slot, saved);
- }
- switch (moby->state) {
- case 0: {
- char *row;
- D_L12_001619B4_lui = 0;
- if (D_0014C050[moby->mission + current_level_index * 16] == 0xff) {
- slot = (int *)(data + 0x20);
- i = 16;
- do {
- if (*slot != -1) mark_moby_for_removal(D_L12_0015FFD8_p + *slot * 0x100);
- i--;
- slot += 12;
- } while (i >= 0);
- goto remove_moby;
- }
- D_L12_00161F24 = 0;
- FUN_L12_0027b268(moby, data, 17);
- row = ((char **)&D_L12_001B0930)[*(int *)(data + 0x5c0)];
- qcopy(&moby->pos, row + 0x10);
- *(float *)(data + 0x618) = moby->pos.z;
- moby->rot.z = FUN_001f9e90(*(float *)(row + 0x20) - *(float *)(row + 0x10),
- *(float *)(row + 0x24) - *(float *)(row + 0x14));
- {
- char *moby_base = D_L12_0015FFD8_p;
- if ((D_0013F4D0_304310)[2] < 52.0f) {
- moby->pos.z += 3.0f;
- moby_base = (char *)D_L12_0015FFD8_lui;
- }
- {
- int *slot = (int *)(data + 0x5d0);
- int i = 4;
- do {
- int index = *slot++;
- other = (struct Moby *)(moby_base + *(int *)(data + index * 0x30 + 0x20) * 0x100);
- *(float *)(other->pvars + 0x80) = 10.0f;
- i--;
- } while (i >= 0);
- }
- }
- D_L12_00161F40 = -1.0f;
- {
- int *saved = D_L12_001FB688;
- int i = 17;
- saved += 17;
- do { *saved-- = 0; i--; } while (i >= 0);
- }
- *(int *)(data + 0x604) = -1;
- *(short *)(data + 0x5fc) = 100;
- moby->state = 1;
- break;
- }
- case 1: {
- int i;
- int *slot;
- char *moby_base;
- struct Moby *other;
- triggered = FUN_00214720(D_L12_00167240, *(int *)(data + 0x624));
- if (triggered) {
- moby->flags |= 0x41;
- moby_base = (char *)D_L12_0015FFD8_lui;
- slot = (int *)(data + 0x20);
- i = 16;
- do {
- if (*slot != -1) {
- other = (struct Moby *)(moby_base + *slot * 0x100);
- other->flags |= 0x41;
- }
- i--; slot += 12;
- } while (i >= 0);
- } else {
- moby->flags &= 0xffbe;
- moby_base = (char *)D_L12_0015FFD8_lui;
- slot = (int *)(data + 0x20);
- i = 16;
- do {
- if (*slot != -1) {
- other = (struct Moby *)(moby_base + *slot * 0x100);
- other->flags &= 0xffbe;
- }
- i--; slot += 12;
- } while (i >= 0);
- }
- triggered = FUN_00214720(D_0013F4D0_304310, *(int *)(data + 0x628));
- if (52.0f < D_0013F4D0_304310[2] && !triggered) {
- approach_value(&moby->pos.z, *(float *)(data + 0x618), frame_time + frame_time);
- angle = frame_time;
- } else {
- height = 3.0f;
- if (triggered) height = 10.0f;
- if (FUN_00214720(D_0013F4D0_304310, *(int *)(data + 0x61c)))
- *(int *)(data + 0x620) = scale_ticks(90);
- if (!tick_countdown_32_alt((int *)(data + 0x620))) height = 19.0f;
- distance = frame_scale_sq;
- FUN_L00_0025b8c0(&moby->pos.z, data + 0x62c, *(float *)(data + 0x618) + height,
- distance * 0.03f, distance * 0.3f, frame_time * 2.7f);
- angle = frame_time;
- }
- FUN_L00_00262b00(moby, data + 0x5cc, data + 0x5c8, 0.7f, angle * 1.2217305f);
- FUN_L00_00262b80(moby, data + 0x5e4, data + 0x5e8, D_L12_00161F30,
- D_L12_00161F28 * 0.017453292f * frame_time, D_L12_00161F2C * 0.017453292f * frame_time);
- FUN_L12_0027b370(moby, data, 17);
- if (FUN_00214720(D_0013F4D0_304310, *(int *)(data + 0x5ec)) || D_L12_00161F00_lui) {
- D_L12_001619B4_lui = 1;
- {
- int *slot = (int *)(data + 0x5d0);
- int i = 4;
- do {
- int index = *slot++;
- other = (struct Moby *)((char *)D_L12_0015FFD8_lui + *(int *)(data + index * 0x30 + 0x20) * 0x100);
- other->hit_slot = 0xff;
- i--;
- } while (i >= 0);
- }
- moby->state = 2;
- }
- break;
- }
- case 2: {
- char *row;
- FUN_L00_00262b00(moby, data + 0x5cc, data + 0x5c8, 0.7f, frame_time * 1.2217305f);
- FUN_L00_00262b80(moby, data + 0x5e4, data + 0x5e8, D_L12_00161F30,
- D_L12_00161F28 * 0.017453292f * frame_time, D_L12_00161F2C * 0.017453292f * frame_time);
- row = ((char **)&D_L12_001B0930)[*(int *)(data + 0x5c0)];
- if (*(short *)(data + 0x5f8) < *(int *)row - 11) {
- approach_value((float *)(data + 0x5f0), frame_time * 8.0f, frame_time_sq * 10.0f);
- } else {
- approach_value((float *)(data + 0x5f0), 0.0f, frame_time_sq * 8.0f);
- if (*(float *)(data + 0x5f0) == 0.0f) { moby->state = 3; break; }
- }
- next = (*(short *)(data + 0x5f8) + 1) % *(int *)row;
- FUN_001f9a28(direction, row + (next + 1) * 16, row + (*(short *)(data + 0x5f8) + 1) * 16);
- FUN_001f9bf8(direction, direction, *(float *)(data + 0x5f0));
- FUN_001f9a10(&moby->pos, &moby->pos, direction);
- angle = FUN_001f9e90(*(float *)(row + (next + 1) * 16) - *(float *)(row + (*(short *)(data + 0x5f8) + 1) * 16),
- *(float *)(row + (next + 1) * 16 + 4) - *(float *)(row + (*(short *)(data + 0x5f8) + 1) * 16 + 4));
- if (*(int *)row - 20 < *(short *)(data + 0x5f8)) angle = 3.054326f;
- distance = frame_scale_sq;
- height = frame_time;
- FUN_L00_00258278(moby, data + 0x5f4, angle, distance * 0.0015f, distance * 0.3f, height * 0.17453292f);
- distance = FUN_001f9b80(&moby->pos, row + (*(short *)(data + 0x5f8) + 1) * 16);
- if (!(distance < 5.0f)) {
- angle = FUN_001f9e90(*(float *)(row + (*(short *)(data + 0x5f8) + 1) * 16) - moby->pos.x,
- *(float *)(row + (*(short *)(data + 0x5f8) + 1) * 16 + 4) - moby->pos.y);
- if (!(1.5707964f < fast_difference_between_rotations(moby->rot.z, angle))) goto update_linked;
- }
- *(short *)(data + 0x5f8) = (*(short *)(data + 0x5f8) + 1) % *(int *)row;
- goto update_linked;
- }
- case 3:
- D_L12_00161F34++;
- FUN_L00_0025bc98(&moby->rot.z, data + 0x5f4, -1, 3.054326f,
- frame_scale_sq * 0.0015f, frame_scale_sq * 0.3f, frame_time * 0.17453292f);
- FUN_L00_00262b00(moby, data + 0x5cc, data + 0x5c8, 0.7f, frame_time * 1.2217305f);
- FUN_L00_00262b80(moby, data + 0x5e4, data + 0x5e8, D_L12_00161F30,
- D_L12_00161F28 * 0.017453292f * frame_time, D_L12_00161F2C * 0.017453292f * frame_time);
-update_linked:
- FUN_L12_0027b370(moby, data, 17);
- FUN_L12_003054b0(moby);
- break;
- case 4:
- if (*(int *)(data + 0x608) != -1 && *(int *)(data + 0x60c) != -1) {
- switch (moby->command) {
- case 0: {
- moby->command = 1;
- FUN_L00_002ea9d8(D_L12_001600EC + *(int *)(data + 0x608) * 128 + 0x30);
- FUN_L00_002eaa30(D_L12_001600EC + *(int *)(data + 0x608) * 128 + 0x70);
- D_L12_001619A0_lui = 1;
- D_L12_0015F404 = 1;
- break;
- }
- case 1:
- if (*(float *)(data + 0x610) < 1.0f) {
- advance_accelerated_scalar_l12(data + 0x610, data + 0x614, 1.0f,
- frame_time_sq * 0.666f, frame_time_sq * 0.666f, frame_time * 0.4f);
- FUN_001f9a40(direction,
- D_L12_001600EC + *(int *)(data + 0x608) * 128 + 0x30,
- D_L12_001600EC + *(int *)(data + 0x60c) * 128 + 0x30,
- *(float *)(data + 0x610));
- clear_u64_value(rotation);
- angle = fast_subtract_rotations(*(float *)(D_L12_001600EC + *(int *)(data + 0x60c) * 128 + 0x70),
- *(float *)(D_L12_001600EC + *(int *)(data + 0x608) * 128 + 0x70));
- rotation[0] = angle * *(float *)(data + 0x610);
- /* Retail uses the zero second component here, discarding the first delta. */
- rotation[0] = fast_add_rotations(*(float *)(D_L12_001600EC + *(int *)(data + 0x608) * 128 + 0x70), rotation[1]);
- angle = fast_subtract_rotations(*(float *)(D_L12_001600EC + *(int *)(data + 0x60c) * 128 + 0x74),
- *(float *)(D_L12_001600EC + *(int *)(data + 0x608) * 128 + 0x74));
- rotation[1] = angle * *(float *)(data + 0x610);
- rotation[1] = fast_add_rotations(*(float *)(D_L12_001600EC + *(int *)(data + 0x608) * 128 + 0x74), rotation[1]);
- angle = fast_subtract_rotations(*(float *)(D_L12_001600EC + *(int *)(data + 0x60c) * 128 + 0x78),
- *(float *)(D_L12_001600EC + *(int *)(data + 0x608) * 128 + 0x78));
- rotation[2] = angle * *(float *)(data + 0x610);
- rotation[2] = fast_add_rotations(*(float *)(D_L12_001600EC + *(int *)(data + 0x608) * 128 + 0x78), rotation[2]);
- FUN_L00_002ea9d8(direction);
- FUN_L00_002eaa30(rotation);
- } else {
- moby->command = 2;
- D_L12_0015F404 = 0;
- FUN_L00_002eac18(3);
- }
- break;
- case 2: {
- char *slot_data = data;
- int i;
- int *saved;
- int index;
- saved = D_L12_001FB688;
- i = 16;
- do {
- index = *(int *)(slot_data + 0x20);
- if (index != -1) {
- other = (struct Moby *)(D_L12_0015FFD8_p + index * 256);
- if ((signed char)other->state >= 0) mark_moby_for_removal(other);
- *(int *)(slot_data + 0x20) = -1;
- } else if (*saved > 0) {
- other = (struct Moby *)(D_L12_0015FFD8_p + *saved * 256);
- if ((signed char)other->state >= 0) mark_moby_for_removal(other);
- }
- saved++; i--; slot_data += 0x30;
- } while (i >= 0);
- D_L12_001619B4_gp = 0;
- FUN_L00_00298840(7);
-remove_moby:
- mark_moby_for_removal(moby);
- return;
- }
- }
- }
- if (*(short *)(data + 0x5fa) == 0) {
- int *slot = (int *)(data + 0x20);
- int *saved = D_L12_001FB688;
- int i = 16;
- do {
- if (*saved == 0) *saved = *slot;
- *slot = -1;
- saved++; i--; slot += 12;
- } while (i >= 0);
- saved = D_L12_001FB688;
- saved[17] = 1;
- for (i = 0; i < 18; i++) FUN_L12_00306350(moby, i);
- }
- *(short *)(data + 0x5fa) += 1;
- FUN_L12_003064e8(moby);
- break;
- }
- FUN_L12_00306828(moby);
- if ((unsigned int)(moby->state - 1) < 3) {
- if (*(int *)(data + 0x604) == -1) *(int *)(data + 0x604) = FUN_0022da68(0, 4, moby);
- } else {
- int index = *(int *)(data + 0x604);
- if (index != -1) {
- char *entry = voice_pool + index * 0x70;
- if (*(struct Moby **)(entry + 0x88) == moby && *(unsigned char *)(entry + 0x74))
- release_voice_slot(index);
- }
- *(int *)(data + 0x604) = -1;
- }
-}
-#endif
-#include "qcopy.h"
-
-/* Spawns the next linked moby at this one's spot, sets it up and gives it a random spin. */
-extern void FUN_L00_00250df8(unsigned char *);
-extern float random_float_between(float, float) __asm__("FUN_002132a8");
-extern void FUN_L00_0026de90(char *, int, float);
-extern short *FUN_002141f8(unsigned char *);
-
-void FUN_L12_003076e0(struct Moby *m) {
- char *d = (char *)m->pvars;
- int *s = (int *)(d + (*(int *)(d + 0xF0) << 2));
- struct Moby *o = (struct Moby *)((unsigned char *)D_L12_0015FFD8_p + (s[0x30] << 8));
- struct MobyClass *p;
- short *r;
- int i;
- qcopy(&o->pos, &m->pos);
- o->pos.z -= 0.35f;
- o->state = 0;
- o->command = 0;
- p = o->pclass;
- o->flags = p->flags;
- o->scale = p->scale;
- o->update_dist = 0xFF;
- o->visible = 1;
- o->occlusion = 0x7F80;
- o->draw_dist = 0xFF;
- o->unk71 = 0xFF;
- o->unk72 = 0xFF;
- o->hit_slot = 0xFF;
- o->collision = p->collision;
- o->spawn_frame = m->spawn_frame;
- FUN_L00_00250df8(o);
- o->parent = m;
- for (i = 0; i < 14; i++) {
- FUN_L00_0026de90(&m->pos, 0, random_float_between(frame_time * 3.0f, frame_time * 5.0f));
- }
- r = FUN_002141f8(o);
- if (r != 0) {
- *(float *)r = r[2];
- }
-}
-
-#define NOT_SDA
-
-#define MACRO_ADDR
-
-/* Door/switch moby: clears its linked mobys, waits for the hero, opens, fires its list one by one, closes. */
-/* Ported from rac1-decomp (src/overlays/l12_hoven/vendor_002EDAA0.c: func_L12_00308C20), where it is exact; names translated to the US level program. */
-
-extern float FUN_001f9b80(void *, void *);
-extern int D_L12_0015FFD8_m __asm__("D_L12_0015FFD8");
-extern int FUN_001f9770(void *);
-extern s32 scale_game_frames(s32) __asm__("func_001F96F8");
-void FUN_L12_003076e0(struct Moby *m);
-extern void FUN_L12_00307ab8(struct Moby *m);
-extern void blend_moby_animation(void *, int, int, int) __asm__("FUN_00212f90");
-void mark_moby_for_removal(void *obj) __asm__("FUN_0020c828");
-
-void FUN_L12_00307840(struct Moby *m) {
- char *d = (char *)m->pvars;
- int *slots;
- int i;
- FUN_L12_00307ab8(m);
- slots = (int *)(d + 0xC0);
- switch (m->state) {
- case 0:
- for (i = 0; i < 12; i++) {
- if (slots[i] != -1) {
- char *o = (char *)(D_L12_0015FFD8_m + (slots[i] << 8));
- if (o != 0 && ((unsigned char *)o)[0x20] != 0xFE &&
- ((unsigned char *)o)[0x20] != 0xFD) {
- mark_moby_for_removal(o);
- }
- }
- }
- m->state = 1;
- break;
- case 1:
- if (*(int *)(d + 0xB4) != 2) {
- if (FUN_001f9b80(&m->pos, d + 0x70) < *(float *)(d + 0xF8)) {
- m->state = 2;
- }
- }
- break;
- case 2:
- if (m->prev_seq != 1) {
- blend_moby_animation(m, 1, 0, scale_game_frames(2));
- }
- if (m->anim_flags & 2) {
- if (m->prev_seq != 2) {
- blend_moby_animation(m, 2, 0, scale_game_frames(2));
- }
- m->state = 3;
- }
- break;
- case 3:
- if (FUN_001f9770(d + 0xFC)) {
- if (slots[*(int *)(d + 0xF0)] != -1) {
- FUN_L12_003076e0(m);
- m->command = m->command == 0;
- *(short *)(d + 0xFC) = scale_game_frames(0x28);
- }
- *(int *)(d + 0xF0) += 1;
- }
- if (*(int *)(d + 0xF0) == 12 || slots[*(int *)(d + 0xF0)] == -1) {
- m->state = 4;
- }
- break;
- case 4:
- m->flags &= 0xEFFF;
- if (m->prev_seq != 3) {
- blend_moby_animation(m, 3, 0, scale_game_frames(2));
- }
- if (m->anim_flags & 2) {
- if (m->prev_seq != 0) {
- blend_moby_animation(m, 0, 0, scale_game_frames(2));
- }
- m->state = 5;
- }
- break;
- case 5:
- break;
- }
-}
-#include "qcopy.h"
-
-/* per-frame update of a moby's timer and approach state */
-/* Ported from rac1-decomp (src/overlays/l12_hoven/vendor_002EDAA0.c: func_L12_00308E98), where it is exact; names translated to the US level program. */
-
-extern char D_0013E533[];
-extern int FUN_001f96f8(int);
-extern int FUN_001f9770(void *);
-extern int FUN_L00_0025fcb8(char *, char *, float);
-float absolute_float(float input) __asm__("func_001F99C0");
-
-void FUN_L12_00307ab8(struct Moby *m) {
- char *d = (char *)m->pvars;
- char *pad;
- if (m->state != 0) {
- if (*(int *)(d + 0x38) != 0) {
- *(short *)(d + 0xFE) = FUN_001f96f8(0xB4);
- }
- *(int *)(d + 0x38) = 0;
- if (FUN_001f9770(d + 0xFE)) {
- *(float *)(d + 0xF8) = *(float *)(d + 0xF4);
- } else {
- *(float *)(d + 0xF8) = *(float *)(d + 0xF4) + 5.0f;
- }
- if (FUN_L00_0025fcb8(m, d + 0x70, *(float *)(d + 0xF8)) != 2) {
- if (absolute_float(m->pos.z - *(float *)(d + 0x78)) > 3.0f) {
- *(int *)(d + 0xB4) = 2;
- }
- }
- if (*(int *)(d + 0xB0) == 0) {
- pad = D_0013E533 + 0xE1D;
- *(int *)(d + 0xB0) = *(int *)(pad + 0x2080);
- qcopy(d + 0x70, pad + 0x80);
- }
- }
-}
-#include "rnc/gameplay/entities/moby.h"
-
-extern unsigned char D_0014C050[];
-extern char D_0013E550[];
-extern int FUN_L01_00275690(void *, float);
-extern int FUN_0022da68(int, int, void *);
-extern unsigned char *moby_bytes __asm__("D_L12_0015FFD8");
-extern void release_voice_slot(int) __asm__("FUN_0022d798");
-extern void enqueue_callback_list_1(void *, void *) __asm__("FUN_001f4600");
-extern void FUN_L00_002502a0(int);
-extern void FUN_L12_00308350(struct Moby *);
-
-/* Pvars: d[0] is the moby to watch, d[1] the voice slot held for this moby. */
-void FUN_L12_003081b0(struct Moby *m) {
- int st = m->state;
- int vis;
- int *d = (int *)m->pvars;
-
- switch (st) {
- case 0:
- if (m->mission != 0xFF && D_0014C050[m->mission + current_level_index * 16] == 0xFF) {
- mark_moby_for_removal(m);
- break;
- }
- m->state = 1;
- break;
- case 1:
- vis = 1;
- if (FUN_L01_00275690(m, 48.0f) == -1) {
- vis = 0;
- }
- if (vis) {
- enqueue_callback_list_1(FUN_L12_00308350, m);
- }
- if (d[1] == -1) {
- d[1] = FUN_0022da68(0, 4, m);
- }
- if (d[0] >= 0) {
- int i = d[1];
- if (i != -1) {
- char *e = D_0013E550 + i * 0x70;
- if (*(struct Moby **)(e + 0x88) == m && *(unsigned char *)(e + 0x74) != 0) {
- release_voice_slot(i);
- }
- }
- d[1] = -1;
- if (moby_bytes[(d[0] << 8) + 0x20] == 7) {
- if (m->mission != 0xFF) {
- FUN_L00_002502a0(m->mission);
- }
- FUN_0022da68(1, 0, m);
- m->collision = 0;
- m->state = 2;
- }
- }
- break;
- }
-}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L12_00308350.s", FUN_L12_00308350);
-#else
-#include "eetypes.h"
-
-typedef struct {
- u128 vertices[4];
- int color[4];
- float uv[4][2];
- long tag;
- long texture;
- long texture_state;
- long gs_state;
-} VendorDrawPacket;
-
-extern int D_L12_00161FBC __attribute__((sda));
-extern int D_L12_00161FC0 __attribute__((sda));
-extern int D_L12_00161FC4 __attribute__((sda));
-extern int D_L12_00161FC8 __attribute__((sda));
-extern int D_L12_00161FCC __attribute__((sda));
-extern int D_L12_00161FD0 __attribute__((sda));
-extern int D_L12_00161FD4 __attribute__((sda));
-extern int D_L12_00161FD8 __attribute__((sda));
-extern unsigned int D_L12_00161F90 __attribute__((sda));
-extern unsigned int D_L12_00161F94 __attribute__((sda));
-extern float D_L12_001FB6D0[4][2];
-extern u128 D_L12_001FB6F0[4];
-extern u128 D_L12_001FB730[4];
-extern void copy_moby_matrix(void *, void *) __asm__("FUN_001fa298");
-extern long get_effect_texture_l12(int) __asm__("FUN_001f44b8");
-extern void draw_geometry_quad_l12(void *, void *, int) __asm__("FUN_001f7d30");
-
-void FUN_L12_00308350(struct Moby *m) {
- VendorDrawPacket first, second;
- float matrix[4][4] __attribute__((aligned(16)));
- void *matrix_ptr;
- int i, j;
- int vertex;
- long flags, second_flags;
-
- matrix_ptr = matrix;
- copy_moby_matrix(matrix, &m->rot_row0);
- qcopy(&matrix[3], &m->pos);
- matrix[3][3] = 1.0f;
- first.texture = second.texture = get_effect_texture_l12(0xe);
- first.texture_state = second.texture_state = 0xFF9000000260L;
- first.gs_state = (long)D_L12_00161FBC | ((long)D_L12_00161FC0 << 2) | ((long)D_L12_00161FC4 << 4) | ((long)D_L12_00161FC8 << 6) | 0x8000000000L;
- second.gs_state = (long)D_L12_00161FCC | ((long)D_L12_00161FD0 << 2) | ((long)D_L12_00161FD4 << 4) | ((long)D_L12_00161FD8 << 6) | 0x8000000000L;
- second.tag = 0;
- first.tag = 0;
- first.color[0] = first.color[1] = first.color[2] = first.color[3] = D_L12_00161F90;
- second.color[0] = second.color[1] = second.color[2] = second.color[3] = D_L12_00161F94;
- vertex = 0;
- do {
- float x, y;
- qcopy(&second.vertices[vertex], &D_L12_001FB6F0[vertex]);
- qcopy(&first.vertices[vertex], &D_L12_001FB730[vertex]);
- x = D_L12_001FB6D0[vertex][0];
- y = D_L12_001FB6D0[vertex][1];
- first.uv[vertex][0] = x;
- ((float *)first.uv)[vertex * 2 + 1] = y;
- second.uv[vertex][0] = x;
- second.uv[vertex][1] = y;
- vertex++;
- } while (vertex < 4);
- i = 0;
- do {
- float x_offset;
- float jitter;
- int row;
- u128 *first_vertex;
- u128 *second_vertex;
- x_offset = random_float_between(-0.5f, 0.5f);
- first_vertex = first.vertices;
- second_vertex = second.vertices;
- for (j = 0; j < 4; j++) {
- ((float *)&first.vertices[j])[2] += 1.0f;
- ((float *)&second_vertex[j])[2] += 1.0f;
- first.uv[j][0] = D_L12_001FB6D0[j][0] + x_offset;
- first.uv[j][1] = D_L12_001FB6D0[j][1];
- }
- jitter = 0.0f;
- for (row = -3; row < 3; row++) {
- float x = (float)row + jitter;
- ((float *)&first.vertices[0])[1] = x;
- ((float *)&first.vertices[1])[1] = x;
- jitter = row < 4 ? random_float_between(-0.2f, 0.2f) : 0.0f;
- x = (float)(row + 1) + jitter;
- ((float *)&first.vertices[2])[1] = x;
- ((float *)&first.vertices[3])[1] = x;
- draw_geometry_quad_l12(&first, matrix, 0);
- }
- i++;
- } while (i < 5);
-}
-#endif
-#include "sda.h"
-
-/* Vendor-counter moby update: once the shared block is ready, latch its data and copy two vectors. */
-/* Ported from rac1-decomp (src/overlays/l12_hoven/vendor_002EDAA0.c: func_L12_0030A7A8), where it is exact; names translated to the US level program. */
-
-typedef struct {
- char pad0[0x10];
- char pos[0x10];
- unsigned char b20;
- char pad21[0xB];
- float f2C;
- unsigned char b30;
- unsigned char b31;
- short s32;
- unsigned short h34;
- char pad36[0x12];
- float f48;
- char pad4C[0x2C];
- Child *child;
- char pad7C[0x14];
- int f90;
-} Obj;
-
-extern char D_0013D388[];
-extern char D_L12_0016CCF0[];
-extern int D_L12_0015F5C4;
-extern int D_L12_0015F5CC;
-extern void FUN_L00_00298840(int);
-s32 is_point_inside_clip_volume_u(s32 arg0, s32 arg1) __asm__("FUN_00214720");
-
-void FUN_L12_003093c8(struct Moby *moby) {
- char *data = (char *)moby->pvars;
- char *base;
- char *p;
- char *q;
- if (D_L12_0015F5CC != 0 && D_L12_0015F5C4 == 0) {
- base = D_0013D388;
- if (*(unsigned char *)(*(int *)(data + 4) + base + 0x5C) != 0) {
- mark_moby_for_removal(moby);
- return;
- }
- p = (char *)&hero.motion.pos;
- if (is_point_inside_clip_volume_u(p, *(int *)data) != 0) {
- *(char *)(*(int *)(data + 4) + base + 0x5C) = 1;
- qcopy(D_L12_0016CCF0, p);
- q = D_L12_0016CCF0 - 0x10;
- *(float *)(q + 0x18) = *(float *)(p + 0x258);
- qcopy(D_L12_0016CCF0 + 0x10, p + 0x10);
- *(short *)(q + 0x46) = 1;
- FUN_L00_00298840(*(int *)(data + 8));
- }
- }
-}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L12_003094a0.s", FUN_L12_003094a0);
-#else
-typedef struct {
- char pad0[0x30];
- int phase;
- char pad34[0x144];
- int mobys[1];
-} L12VendorMobyList;
-extern L12VendorMobyList D_L12_0016CCE0;
-extern void FUN_L00_002637f8(int);
-
-void FUN_L12_003094a0(struct Moby *moby) {
- int state = moby->state;
- int phase;
- int index;
-
- switch (state) {
- case 0:
- moby->update_dist = 0xff;
- moby->state = 1;
- break;
- case 1:
- if (D_L12_0015F5C4 != 2) break;
-
- phase = D_L12_0016CCE0.phase;
- switch (phase) {
- case 7: index = 0; break;
- case 1: index = 2; break;
- default: return;
- }
- FUN_L00_002637f8(D_L12_0016CCE0.mobys[index]);
- break;
- }
-}
-#endif
-
-#define NOT_SDA
-
-#define MACRO_ADDR
-
-/* Draws the moby's 10-piece overlay when its trigger is visible, with its own GS state. */
-/* Ported from rac1-decomp (src/overlays/l12_hoven/vendor_002EDAA0.c: func_L12_0030D248), where it is exact; names translated to the US level program. */
-
-extern float D_L12_00162108[2] __attribute__((section(".sdata")));
-extern char D_L12_00208B00[];
-extern int D_L12_001620D4;
-extern int D_L12_001FBD10[];
-extern int D_L12_002059E0[];
-extern int D_L12_00205A08[];
-extern int D_L12_00205A58[];
-extern int is_point_inside_clip_volume(void *arg0, int arg1) __asm__("FUN_00214720");
-extern s64 get_effect_texture(s32) __asm__("func_001F44B8");
-extern void FUN_L00_001fde98(int, int, int, void *, int);
-extern void FUN_L08_00258090(void *, int, int, void *);
-extern void FUN_L08_002f0c18(int);
-extern void vu1_add_g_sregister(s32, unsigned long) __asm__("func_00233980");
-void font_queue_vu_state(void) __asm__("FUN_001f76a0");
-
-void FUN_L12_0030be68(struct Moby *m) {
- int *d = (int *)m->pvars;
- int i;
- font_queue_vu_state();
- vu1_add_g_sregister(0x42, 0x7F00000064L);
- vu1_add_g_sregister(8, 0);
- vu1_add_g_sregister(0x14, 0xFF9000000260L);
- vu1_add_g_sregister(0x47, 0x5360A);
- if (is_point_inside_clip_volume(D_L12_00167240, d[0])) {
- vu1_add_g_sregister(6, get_effect_texture(0x2C));
- for (i = 0; i < 10; i++) {
- FUN_L08_00258090(D_L12_00208B00, D_L12_00205A08[i], D_L12_001FBD10[i], D_L12_00162108);
- FUN_L00_001fde98(D_L12_001FBD10[i], D_L12_002059E0[i], D_L12_00205A58[i],
- D_L12_00208B00, 1);
- }
- }
- vu1_add_g_sregister(6, get_effect_texture(0x2F));
- FUN_L08_002f0c18(0);
- vu1_add_g_sregister(0x42, ((long)D_L12_001620D4 << 32) | 0x68);
- vu1_add_g_sregister(6, get_effect_texture(0x30));
- FUN_L08_002f0c18(1);
-}
-/* Builds the colour tables once, then scrolls two pairs of wrapped phases each frame. */
-extern int D_L12_001620F0 __attribute__((sda));
-/* The ready flag is followed, 8 bytes on, by two pairs of phases. */
-extern float D_L12_001620E0[1] __attribute__((sda));
-extern float D_L12_001620D8[2] __attribute__((sda));
-extern float frame_delta_time __asm__("D_0015ED7C") __attribute__((section(".sdata")));
-extern int *D_L12_00208AE0[];
-extern int D_L12_00205A80[];
-extern void FUN_L08_002f0f68(void *, int, void *, float, float, float, float, int);
-extern void enqueue_callback_list_1(void *, void *) __asm__("FUN_001f4600");
-
-typedef struct {
- char p[0x20];
- unsigned char state;
- char q[0xF];
- unsigned char b30;
- char r;
- short h32;
-} M_bff0;
-
-void FUN_L12_0030bff0(M_bff0 *m) {
- int i;
- switch (m->state) {
- case 0:
- if (D_L12_001620F0 == 0) {
- FUN_L08_002f0f68(D_L12_00208AE0, 5, D_L12_00205A80, 0.1f, 0.5f, 0.4f, 0.5f, 1);
- FUN_L08_002f0f68(D_L12_00205A58, 10, D_L12_001FBD10, 0.1f, 0.6f, 0.4f, 0.5f, 1);
- D_L12_001620F0 = 1;
- }
- m->state = 1;
- m->b30 = 0xFF;
- m->h32 = 0xFF;
- for (i = 0; i < 2; i++) {
- ((float *)&D_L12_001620F0)[i * 2 + 2] = 0.0f;
- ((float *)&D_L12_001620F0)[i * 2 + 3] = 0.0f;
- }
- break;
- case 1:
- for (i = 0; i < 2; i++) {
- ((float *)&D_L12_001620F0)[i * 2 + 2] += D_L12_001620E0[i * 2] * frame_delta_time;
- if (((float *)&D_L12_001620F0)[i * 2 + 2] > 1.0f) {
- ((float *)&D_L12_001620F0)[i * 2 + 2] -= 1.0f;
- }
- if (((float *)&D_L12_001620F0)[i * 2 + 2] < -1.0f) {
- ((float *)&D_L12_001620F0)[i * 2 + 2] += 1.0f;
- }
- ((float *)&D_L12_001620F0)[i * 2 + 3] += D_L12_001620E0[i * 2 + 1] * frame_delta_time;
- if (((float *)&D_L12_001620F0)[i * 2 + 3] > 1.0f) {
- ((float *)&D_L12_001620F0)[i * 2 + 3] -= 1.0f;
- }
- if (((float *)&D_L12_001620F0)[i * 2 + 3] < -1.0f) {
- ((float *)&D_L12_001620F0)[i * 2 + 3] += 1.0f;
- }
- }
- D_L12_00162108[0] += D_L12_001620D8[0] * frame_delta_time;
- if (D_L12_00162108[0] > 1.0f) {
- D_L12_00162108[0] -= 1.0f;
- }
- if (D_L12_00162108[0] < -1.0f) {
- D_L12_00162108[0] += 1.0f;
- }
- D_L12_00162108[1] += D_L12_001620D8[1] * frame_delta_time;
- if (D_L12_00162108[1] > 1.0f) {
- D_L12_00162108[1] -= 1.0f;
- }
- if (D_L12_00162108[1] < -1.0f) {
- D_L12_00162108[1] += 1.0f;
- }
- enqueue_callback_list_1(FUN_L12_0030be68, m);
- break;
- }
-}
diff --git a/src/overlays/l13/gameplay/entities/rocket.c b/src/overlays/l13/gameplay/entities/rocket.c
index e714f16cf6..1a6ab62e6c 100644
--- a/src/overlays/l13/gameplay/entities/rocket.c
+++ b/src/overlays/l13/gameplay/entities/rocket.c
@@ -300,183 +300,160 @@ char *FUN_L13_003061c8(float speed, float *pos, float *dir, void *arg) {
}
return m;
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L13_00306300.s", FUN_L13_00306300);
-#else
-extern void add_vector_xyz(void *, void *, void *) __asm__("FUN_001f9a10");
-extern void subtract_vector_xyz(void *, void *, void *) __asm__("FUN_001f9a28");
-extern void normalize_vector_xyz_6300(void *, void *, float) __asm__("FUN_001f9c48");
-extern void scale_vector_xyz_6300(void *, void *, float) __asm__("FUN_001f9bf8");
-extern float vector_length_xyz(void *) __asm__("FUN_001f9af0");
-extern float fast_vec_dist(void *, void *) __asm__("FUN_001f9b48");
-extern float vector_distance(void *, void *) __asm__("FUN_001f9b80");
-extern int FUN_001f9740(int *);
-extern int FUN_001efa68(void *, void *, int, void *, void *);
-extern void mark_moby_for_removal(void *) __asm__("FUN_0020c828");
-extern void FUN_L00_00259888(void *, struct Moby *, int, void *, float);
-extern void FUN_L00_00259a88(void *, void *);
-extern float random_float_between(float, float) __asm__("FUN_002132a8");
-extern int random_int_between(int, int) __asm__("FUN_L00_00257b90");
-extern int scale_game_frames(int) __asm__("FUN_001f96f8");
-extern void FUN_L00_001ff660(void *, void *, void *);
-extern void FUN_L00_0026dd20(void *, void *, int, int, float);
-extern void allocate_voice_for_target_entry(int, int, void *) __asm__("FUN_0022da68");
-extern void FUN_L07_0029a2a0(void *, void *);
-extern unsigned char D_00141346;
-extern char D_0013F3D0[];
-extern float D_0015ED6C;
+#include "qzero.h"
-typedef struct {
- float x, y, z, w;
-} __attribute__((aligned(16))) L13Vector_6300;
+/* Ported from rac1-decomp (src/overlays/l13_gemlik/vendor_002EBD00.c: func_L13_00307798), where it is exact; names translated to the US level program. */
-typedef struct {
- L13Vector_6300 vector;
- float unk10, unk14;
- unsigned char active, valid;
- unsigned short oclass;
- char pad1C[0x14];
-} __attribute__((aligned(16))) L13Hit_6300;
+typedef struct Moby Moby;
-typedef struct {
- char pad00[0x24];
- unsigned int flags;
- unsigned char active, valid;
- unsigned short oclass;
- float value;
- char pad30[4];
- struct Moby *moby;
+typedef int OvlQuad_p __attribute__((mode(TI)));
+
+typedef struct { float x, y, z, w; } __attribute__((aligned(16))) L13Vec_p;
+
+
+struct L13Ent00178480 {
+ char pad0[0x24];
+ int i24;
+ unsigned char b28;
+ unsigned char b29;
+ unsigned short s2A;
+ float f2C;
+ int pad30;
+ char *p34;
char pad38[8];
-} L13TargetRow_6300;
+};
+
+extern char D_0013E533[];
+extern f32 fast_vec_length_c(void *) __asm__("func_001F9AF0");
+extern f32 random_float_between(f32, f32) __asm__("func_002132A8");
+extern float fast_vec_dist(void *, void *);
+extern float vector_distance_xy_alt(void *, void *) __asm__("FUN_001f9b80");
+extern int FUN_L00_00257b90(int, int);
+extern int allocate_voice_for_target_entry(int, int, void *) __asm__("FUN_0022da68");
+extern int tick_countdown_32_alt(void *) __asm__("FUN_001f9740");
+extern s32 scale_game_frames(s32) __asm__("func_001F96F8");
+extern struct L13Ent00178480 D_L13_00178400[];
+extern void FUN_L00_00259888_c(void *, struct Moby *, int, float, void *) __asm__("FUN_L00_00259888");
+extern void FUN_L00_00259a88(void *, void *);
+extern void add_vector_xyz(void *, void *, void *) __asm__("FUN_001f9a10");
+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;
char *data = (char *)moby->pvars;
struct {
- L13Vector_6300 old_pos;
- L13Hit_6300 hit;
- L13Vector_6300 direction;
- L13Vector_6300 velocity;
- L13Vector_6300 random_direction;
+ L13Vec_p old_pos;
+ char hit[48];
+ L13Vec_p velocity;
+ L13Vec_p direction;
+ L13Vec_p random_direction;
} work;
- extern L13TargetRow_6300 D_L13_00178400[];
- int stationary;
+ int i;
int flags;
- float length;
- extern struct { char pad[0x18]; struct Moby *moby; int pad1; L13Vector_6300 pos; L13Vector_6300 pad2; L13Vector_6300 matrix; } D_L13_00174140;
+ int stationary;
+ unsigned char *base;
+ char *ent;
+ struct L13Ent00178480 *e;
- qcopy_nc(&work.old_pos, &moby->pos);
+ qcopy(&work.old_pos, &moby->pos);
add_vector_xyz(&moby->pos, &moby->pos, data);
- qcopy_nc(&work.direction, data);
- work.direction.z = 0.0f;
- normalize_vector_xyz_6300(&work.direction, &work.direction, 1.0f);
- work.direction.z = 1.0f;
+ qcopy(&work.velocity, data);
+ work.velocity.z = 0.0f;
+ set_vector_length_xy_c(&work.velocity, &work.velocity, 1.0f);
+ work.velocity.z = 1.0f;
flags = 0x10001;
- /* Retail checks ammo_used and proximity to hero.motion.pos. */
- if (hero.ammo_used != 0 && *(float *)(data + 0xc) != 31337.602f &&
- fast_vec_dist(&moby->pos, &hero.motion.pos) < 2.0f) {
- int i;
- scale_vector_xyz_6300(data, data, 0.5f);
+ base = (unsigned char *)((char *)&D_0013F350);
+ 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);
subtract_vector_xyz(&moby->pos, &moby->pos, data);
- /* Clear all four vector words in address order before writing the sentinel. */
- ((volatile int *)data)[0] = 0;
- ((volatile int *)data)[1] = 0;
- ((volatile int *)data)[2] = 0;
- ((volatile int *)data)[3] = 0;
- *(int *)(data + 0x2c) = 5;
- /* Store the exact retail float sentinel bits, 0x46f4d334. */
- *(unsigned int *)(data + 0xc) = 0x46f4d334;
- /* hero.unk2020 starts 0x1fa0 bytes after the existing position symbol. */
+ qzero(data);
+ *(int *)(data + 0x2C) = 5;
+ *(float *)(data + 0xC) = 31337.6015625f;
for (i = 0; i < 6; i++) {
- struct Moby *target = (struct Moby *)((struct Moby **)(D_0013F3D0 + 0x1fa0))[i];
- if (target != 0) {
- FUN_L00_00259888(&work.hit, moby, flags | 1, &work.direction, 1.0f);
- work.hit.oclass = moby->oclass;
- work.hit.active = 1;
- work.hit.valid = 1;
- {
- L13TargetRow_6300 *previous;
- if (target->hit_slot == 0xff)
- goto attach_hit;
- previous = &D_L13_00178400[target->hit_slot];
- if (previous->moby == target)
- goto update_hit;
-attach_hit:
- FUN_L00_00259a88(target, &work.hit);
- break;
-update_hit:
- previous->value += 1.0f;
- D_L13_00178400[target->hit_slot].active = 1;
- D_L13_00178400[target->hit_slot].valid = 1;
- D_L13_00178400[target->hit_slot].oclass = moby->oclass;
- previous = &D_L13_00178400[target->hit_slot];
- previous->flags = flags | 1;
+ unsigned char *b = (unsigned char *)((char *)&D_0013F350);
+ ent = ((char **)(b + 0x2020))[i];
+ if (ent != 0) {
+ int f2 = flags | 1;
+ FUN_L00_00259888_c(work.hit, moby, f2, 1.0f, &work.velocity);
+ work.hit[0x18] = 1;
+ *(unsigned short *)(work.hit + 0x1A) = *(unsigned short *)((char *)moby + 0xA6);
+ work.hit[0x19] = 1;
+ if ((unsigned char)ent[0xA4] == 0xFF || (e = &D_L13_00178400[(unsigned char)ent[0xA4]])->p34 != ent) {
+ FUN_L00_00259a88(ent, work.hit);
+ } else {
+ e->f2C += 1.0f;
+ D_L13_00178400[(unsigned char)ent[0xA4]].b28 = 1;
+ D_L13_00178400[(unsigned char)ent[0xA4]].b29 = 1;
+ D_L13_00178400[(unsigned char)ent[0xA4]].s2A = *(unsigned short *)((char *)moby + 0xA6);
+ { struct L13Ent00178480 *t = &D_L13_00178400[(unsigned char)ent[0xA4]]; t->i24 = f2; }
}
break;
}
}
}
- FUN_L00_00259888(&work.hit, moby, 0x10001, &work.direction, 1.0f);
- work.hit.oclass = moby->oclass;
- work.hit.active = 1;
- work.hit.valid = 1;
+
+ FUN_L00_00259888_c(work.hit, moby, 0x10001, 1.0f, &work.velocity);
+ *(unsigned short *)(work.hit + 0x1A) = *(unsigned short *)((char *)moby + 0xA6);
+ work.hit[0x18] = 1;
+ work.hit[0x19] = 1;
stationary = *(int *)(data + 0x24) == 0;
- if (!(*(float *)(data + 0x28) < vector_distance(&moby->pos, data + 0x10)) &&
- FUN_001f9740((int *)(data + 0x2c)) == 0)
- goto collision;
- if (moby->visible != 0) {
- int i;
- L13Vector_6300 *velocity = &work.velocity;
- for (i = 0; i < 3; i++) {
- *(OvlQuad *)&work.random_direction = 0;
- work.random_direction.x = random_float_between(-1.0f, 1.0f);
- work.random_direction.y = random_float_between(-1.0f, 1.0f);
- work.random_direction.z = random_float_between(-1.0f, 1.0f);
- *(OvlQuad *)&work.velocity = *(OvlQuad *)&work.random_direction;
- length = vector_length_xyz(&work.random_direction);
- scale_vector_xyz_6300(velocity, velocity, length * 0.1f);
- add_vector_xyz(velocity, &work.random_direction, velocity);
- scale_vector_xyz_6300(velocity, velocity,
- random_float_between(D_0015ED6C + D_0015ED6C, D_0015ED6C * 4.0f));
- FUN_L07_0029a2a0(&moby->pos, velocity);
+ if (*(float *)(data + 0x28) < vector_distance_xy_alt(&moby->pos, data + 0x10) || tick_countdown_32_alt(data + 0x2C) != 0) {
+ if (moby->visible != 0) {
+ int i;
+ for (i = 0; i < 3; i++) {
+ *(OvlQuad_p *)&work.random_direction = 0;
+ work.random_direction.x = random_float_between(-1.0f, 1.0f);
+ work.random_direction.y = random_float_between(-1.0f, 1.0f);
+ work.random_direction.z = random_float_between(-1.0f, 1.0f);
+ *(OvlQuad_p *)&work.direction = *(OvlQuad_p *)&work.random_direction;
+ fast_vec_normalize_c(&work.direction, &work.direction, fast_vec_length_c(&work.random_direction) * 0.1f);
+ add_vector_xyz(&work.direction, &work.random_direction, &work.direction);
+ fast_vec_normalize_c(&work.direction, &work.direction,
+ random_float_between(D_0015ED6C + D_0015ED6C, D_0015ED6C * 4.0f));
+ FUN_L07_0029a2a0(&moby->pos, &work.direction);
+ }
}
+ goto remove;
}
- mark_moby_for_removal(moby);
- return;
-collision:
- if (FUN_001efa68(&work.old_pos, &moby->pos, stationary,
- (void *)*(int *)(data + 0x20), &work.hit) == 0)
+ if (FUN_001efa68(&work.old_pos, &moby->pos, stationary, *(void **)(data + 0x20), work.hit) == 0)
goto bounds;
qcopy(&moby->pos, &D_L13_00174140.pos);
if (moby->visible != 0) {
int i;
for (i = 0; i < 5; i++) {
- *(OvlQuad *)&work.random_direction = 0;
+ *(OvlQuad_p *)&work.random_direction = 0;
work.random_direction.x = random_float_between(-1.0f, 1.0f);
work.random_direction.y = random_float_between(-1.0f, 1.0f);
work.random_direction.z = random_float_between(-1.0f, 1.0f);
- *(OvlQuad *)&work.velocity = *(OvlQuad *)&work.random_direction;
+ *(OvlQuad_p *)&work.direction = *(OvlQuad_p *)&work.random_direction;
FUN_L00_001ff660(&work.random_direction, data, &D_L13_00174140.matrix);
- length = vector_length_xyz(&work.random_direction);
- scale_vector_xyz_6300(&work.velocity, &work.velocity, length * 0.5f);
- add_vector_xyz(&work.velocity, &work.random_direction, &work.velocity);
- scale_vector_xyz_6300(&work.velocity, &work.velocity,
+ fast_vec_normalize_c(&work.direction, &work.direction, fast_vec_length_c(&work.random_direction) * 0.5f);
+ add_vector_xyz(&work.direction, &work.random_direction, &work.direction);
+ fast_vec_normalize_c(&work.direction, &work.direction,
random_float_between(D_0015ED6C * 3.0f, D_0015ED6C * 6.0f));
- FUN_L00_0026dd20(&moby->pos, &work.velocity, 0x7f2f4f6f,
- random_int_between(scale_game_frames(10), scale_game_frames(15)), 30000.0f);
+ FUN_L00_0026dd20(&moby->pos, &work.direction, 0x7F2F4F6F,
+ FUN_L00_00257b90(scale_game_frames(10), scale_game_frames(15)), 30000.0f);
}
}
- if (D_L13_00174140.moby != 0 &&
- (D_L13_00174140.moby)->oclass == 0)
- allocate_voice_for_target_entry(0, 0, moby);
- mark_moby_for_removal(moby);
+ {
+ struct Moby *target = D_L13_00174140.moby;
+ if (target != 0 && *(short *)((char *)target + 0xA6) == 0)
+ allocate_voice_for_target_entry(0, 0, (int)moby);
+ }
+remove:
+ mark_moby_for_removal_c(moby);
return;
bounds:
if (moby->pos.x < 2.0f || moby->pos.x > 1021.0f ||
moby->pos.y < 2.0f || moby->pos.y > 1021.0f ||
moby->pos.z < 2.0f || moby->pos.z > 1021.0f)
- mark_moby_for_removal(moby);
+ mark_moby_for_removal_c(moby);
}
-#endif
#ifndef NON_MATCHING
INCLUDE_ASM("config/us/overlays/asm/FUN_L13_003073c8.s", FUN_L13_003073c8);
#else
@@ -1121,7 +1098,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 s32 D_001413D0_8d10 __asm__("D_001413D0") __attribute__((section(".data")));
+extern int 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");
@@ -1234,7 +1211,7 @@ void FUN_L13_00308d10(struct Moby *moby) {
}
}
if (vars->start_frame == 0) {
- vars->start_frame = D_001413D0_8d10;
+ vars->start_frame = D_001413D0;
}
ground = probe_ground_height_8d10(&moby->pos, 0, 0.5f);
if (ground != 0.0f) {
@@ -2500,7 +2477,7 @@ extern void FUN_L00_0025d538(void *, void *);
extern int FUN_L01_0026e008(int, int);
extern void allocate_voice_for_bank_entry(int, int, int) __asm__("FUN_0022db10");
extern void queue_dialogue_message(int, int) __asm__("FUN_L00_00263d40");
-extern void allocate_voice_for_target_entry(int, int, void *) __asm__("FUN_0022da68");
+extern int allocate_voice_for_target_entry(int, int, void *) __asm__("FUN_0022da68");
extern void FUN_L01_002787a0(void *);
extern void FUN_L00_0025f8e0(void *, float);
extern void FUN_001f9a10(void *, void *, void *);
diff --git a/src/overlays/l18/gameplay/entities/rocket.c b/src/overlays/l18/gameplay/entities/rocket.c
index d41dadf0f4..9edaa043e5 100644
--- a/src/overlays/l18/gameplay/entities/rocket.c
+++ b/src/overlays/l18/gameplay/entities/rocket.c
@@ -687,7 +687,7 @@ extern f32 approach_value(f32 *, f32, f32) __asm__("FUN_00213ed8");
extern float FUN_001f9b48(void *, void *);
extern float fast_cos(float) __asm__("func_001F9DC8");
extern int D_001413D0[];
-extern float D_0015ED70_b __asm__("D_0015ED70");
+extern float D_0015EE70 __asm__("D_0015ED70");
extern int FUN_L00_0025fcb8(char *, char *, float);
extern int FUN_L00_002dc9f0(void *, void *);
extern int scale_game_frames_i(int) __asm__("FUN_001f96f8");
@@ -758,7 +758,7 @@ void FUN_L18_002d5918(struct Moby *moby) {
float lim = frame_time_sq * 6.0f;
qcopy(b, &moby->pos);
subtract_vector_xyz(v, *(char **)(buf + 0x40) + 0x10, &moby->pos);
- v[2] = -(D_0015ED70_b * 10.0f);
+ v[2] = -(D_0015EE70 * 10.0f);
if (lim < vector_length_xy(v)) {
set_vector_length_xy(v, v, lim);
}
@@ -818,7 +818,7 @@ typedef struct {
unsigned char unk70; /* 0x70 */
} MobyAnim_q;
-extern float D_0015ED70_q __asm__("D_0015ED70");
+extern float D_0015EE70 __asm__("D_0015ED70");
extern float angle_atan2(float, float) __asm__("FUN_001f9e90");
extern float FUN_L00_0025abf0_q(float *a, float *b, float *out, float speed,
float g) __asm__("FUN_L00_0025abf0");
@@ -881,7 +881,7 @@ char *FUN_L18_002d5cf8(float f, int a0, int idx, float *p6, float *p7, int a8) {
subtract_vector_xyz(data + 0x180, v, p6);
*(int *)(data + 0x188) = 0;
normalize_vector_xyz(data + 0x180, data + 0x180, f);
- g = D_0015ED70_q * 10.0f;
+ g = D_0015EE70 * 10.0f;
*(short *)(data + 0xC8) = 0;
*(float *)(data + 0x188) = FUN_L00_0025abf0_q(p6, v, 0, f, -g);
*(float *)(moby + 0x48) =
@@ -1109,8 +1109,8 @@ typedef struct {
extern char *D_L18_00174858_q __asm__("D_L18_00174858") __attribute__((section(".data")));
extern char *func_0020D348_m_q(int) __asm__("FUN_0020c4f8");
-extern float D_0015ED6C_q __asm__("D_0015ED6C");
-extern float D_0015ED70_d __asm__("D_0015ED70");
+extern short D_L18_00161A6C __asm__("D_0015ED6C");
+extern float D_0015EE70 __asm__("D_0015ED70");
extern float FUN_001fa580_q(float, float) __asm__("FUN_001fa580");
extern float advance_accelerated_scalar(float *, float *, float, float, float, float) __asm__("FUN_00213f38");
extern int D_L18_0015F5C4_d __asm__("D_L18_0015F5C4");
@@ -1211,20 +1211,20 @@ void FUN_L18_002d6600(char *moby) {
}
if (d->f24 != 0.0f) {
if (d->f20 != d->f24) {
- advance_accelerated_scalar(&d->f20, &d->f28, d->f24, D_0015ED70_d * 4.0f, D_0015ED70_d * 4.0f,
- D_0015ED6C_q * 4.0f);
+ advance_accelerated_scalar(&d->f20, &d->f28, d->f24, D_0015EE70 * 4.0f, D_0015EE70 * 4.0f,
+ (*(float *)&D_L18_00161A6C) * 4.0f);
} else {
- float k = D_0015ED70_d;
+ float k = D_0015EE70;
advance_accelerated_scalar(&d->f34, &d->f28, *(float *)&D_L18_0016199C, k * 16.0f, k * 4.0f,
- D_0015ED6C_q * 8.0f);
+ (*(float *)&D_L18_00161A6C) * 8.0f);
}
} else if (d->f34 != *(float *)&D_L18_001619A0) {
- float k = D_0015ED70_d;
+ float k = D_0015EE70;
advance_accelerated_scalar(&d->f34, &d->f28, *(float *)&D_L18_001619A0, k * 16.0f, k * 4.0f,
- D_0015ED6C_q * 8.0f);
+ (*(float *)&D_L18_00161A6C) * 8.0f);
} else {
- advance_accelerated_scalar(&d->f20, &d->f28, d->f24, D_0015ED70_d * 4.0f, D_0015ED70_d * 4.0f,
- D_0015ED6C_q * 4.0f);
+ advance_accelerated_scalar(&d->f20, &d->f28, d->f24, D_0015EE70 * 4.0f, D_0015EE70 * 4.0f,
+ (*(float *)&D_L18_00161A6C) * 4.0f);
}
if (d->p14 != 0) {
FUN_001f9bf8_q(d->p14 + 0x10, d->p14 + 0xD0, -d->f20);
@@ -2141,7 +2141,7 @@ void FUN_L18_002dc4b8(char *moby) {
/* Ported from rac1-decomp (src/overlays/l18_veldin2/vendor_002A8400.c: func_L18_002E09F8), where it is exact; names translated to the US level program. */
extern char D_001413D4_q[] __asm__("D_001413D4") __attribute__((section(".data")));
-extern float D_0015ED6C_d __asm__("D_0015ED6C");
+extern short D_L18_00161A6C __asm__("D_0015ED6C");
extern float D_L18_0015F3FC_d __asm__("D_L18_0015F3FC");
extern float fast_subtract_rotations(float, float) __asm__("FUN_001fa5c8");
extern int give_reward(int a, int b) __asm__("FUN_L00_00203908");
@@ -2165,7 +2165,7 @@ void FUN_L18_002df608(struct Moby *moby) {
break;
case 2:
D_L18_0017EF08 = 1;
- approach_value((float *)(data + 0x6C), 1.0f, D_0015ED6C_d * 4.0f);
+ approach_value((float *)(data + 0x6C), 1.0f, (*(float *)&D_L18_00161A6C) * 4.0f);
{
float t = *(float *)(data + 0x6C);
if (D_L18_0015F3FC_d < t) {
@@ -2203,7 +2203,7 @@ void FUN_L18_002df608(struct Moby *moby) {
v[6] = FUN_001fa580_q(*(float *)(data + 0x28), v[6]);
FUN_L00_002ea9d8_q(v);
FUN_L00_002ea9d8_q_002eaa30(v + 4);
- approach_value((float *)(data + 0x6C), 0.0f, D_0015ED6C_d * 4.0f);
+ approach_value((float *)(data + 0x6C), 0.0f, (*(float *)&D_L18_00161A6C) * 4.0f);
{
float d = *(float *)(data + 0x60);
D_L18_0015F3FC_d = *(float *)(data + 0x6C);
@@ -2242,7 +2242,7 @@ void FUN_L18_002df608(struct Moby *moby) {
(0.2f < *(float *)(data + 0x60) && D_L18_00179E10[0] == 0 &&
D_L18_00179E10[9] == -1)) {
float t;
- approach_value((float *)(data + 0x6C), 1.0f, D_0015ED6C_d * 4.0f);
+ approach_value((float *)(data + 0x6C), 1.0f, (*(float *)&D_L18_00161A6C) * 4.0f);
t = *(float *)(data + 0x6C);
D_L18_0015F3FC_d = t;
if (1.0f <= t) {
@@ -2260,13 +2260,13 @@ void FUN_L18_002df608(struct Moby *moby) {
FUN_L00_00216f90_q(data + 0x40, v + 8, 0x72, 1);
return;
} else {
- approach_value((float *)(data + 0x6C), 0.0f, D_0015ED6C_d * 4.0f);
+ approach_value((float *)(data + 0x6C), 0.0f, (*(float *)&D_L18_00161A6C) * 4.0f);
D_L18_0015F3FC_d = *(float *)(data + 0x6C);
}
break;
case 5:
if (0.0f < *(float *)(data + 0x6C)) {
- approach_value((float *)(data + 0x6C), 0.0f, D_0015ED6C_d * 4.0f);
+ approach_value((float *)(data + 0x6C), 0.0f, (*(float *)&D_L18_00161A6C) * 4.0f);
D_L18_0015F3FC_d = *(float *)(data + 0x6C);
} else {
moby->state = 1;
@@ -2330,10 +2330,10 @@ extern int hit_test_9768(float, float *, int, void *) __asm__("FUN_L00_001f0d60"
extern void remove_moby_9768(void *) __asm__("FUN_0020c828");
extern void spawn_particle_9768(void *, void *, int, int, int, int, float, float, int, int) __asm__("FUN_L00_0026a9f0");
extern void spawn_particle_alt_9768(float, void *, void *, int, int, int) __asm__("FUN_L00_0026a4c8");
-extern float D_0015ED70_9768 __asm__("D_0015ED70");
+extern float D_0015EE70 __asm__("D_0015ED70");
extern int D_L18_0015F580;
-extern float D_0013F3D0_9768[4] __asm__("D_0013F3D0");
-extern int D_0014C050_9768[] __asm__("D_0014C050");
+extern float D_0013F3D0[4];
+extern unsigned char D_0014C050[];
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 *)D_0014C050_9768)[unkB0] == 0xff) goto remove;
+ if (((unsigned char *)((int *)D_0014C050))[unkB0] == 0xff) goto remove;
}
moby->state = 1;
if (*(int *)data != 0) *(int *)(*(int *)data) = 3;
@@ -2434,7 +2434,7 @@ void FUN_L18_002e9768(struct Moby *moby) {
moby->state = 3;
data[2] = FUN_L00_00257c48(0.0f, 90.0f) * DEG_TO_RAD * frame_time;
data[3] = FUN_L00_00257c48(0.0f, 90.0f) * DEG_TO_RAD * frame_time;
- subtract_vector_9768(data + 4, &moby->pos.x, D_0013F3D0_9768);
+ subtract_vector_9768(data + 4, &moby->pos.x, D_0013F3D0);
data[6] = 0.0f;
scale_vector_9768(data + 4, data + 4, speed);
vector_from_angles_9768(vector, speed, speed);
@@ -2448,7 +2448,7 @@ void FUN_L18_002e9768(struct Moby *moby) {
float *pos = &moby->pos.x;
moby->rot.x = fast_add_rotations_9768(moby->rot.x, data[2]);
moby->rot.y = fast_add_rotations_9768(moby->rot.y, data[2]);
- data[6] -= D_0015ED70_9768 * 20.0f;
+ data[6] -= D_0015EE70 * 20.0f;
add_vector_9768(pos, pos, data + 4);
if (data[7] - 16.0f > moby->pos.z ||
hit_test_9768(1.0f, pos, 2, moby)) {
@@ -2467,7 +2467,7 @@ extern float approach_value_alt(float *p, float target, float maxstep) __asm__("
extern float fast_add_rotations_c(float, float) __asm__("func_001FA580");
extern float probe_ground_height_c(void *, int, float) __asm__("func_00213508");
extern void FUN_L15_002d8710(char *);
-extern void FUN_L18_002ea1f8(struct Moby *);
+extern void FUN_L18_002ea1f8_u(struct Moby *) __asm__("FUN_L18_002ea1f8");
extern void FUN_L18_002ea800(void *);
void FUN_L18_002eacd8(struct Moby *m);
extern void FUN_L18_002eaea0_u(void *) __asm__("FUN_L18_002eaea0");
@@ -2528,107 +2528,95 @@ void FUN_L18_002e9e70(struct Moby *moby) {
break;
}
}
- enqueue_callback_list_1(FUN_L18_002ea1f8, moby);
+ enqueue_callback_list_1(FUN_L18_002ea1f8_u, moby);
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L18_002ea1f8.s", FUN_L18_002ea1f8);
-#else
-typedef struct {
- float x, y, z, w;
-} __attribute__((aligned(16))) L18FlareVector;
-typedef struct {
- float u, v;
-} L18FlareUV;
+/* Ported from rac1-decomp (src/overlays/l18_veldin2/vendor_002A8400.c: func_L18_002EB5E8), where it is exact; names translated to the US level program. */
+
typedef struct {
- L18FlareVector corner[4];
- unsigned int color[4];
- L18FlareUV uv[4];
- unsigned long long zero, texture, state, flags;
-} L18FlarePacket;
+ float vtx[4][4];
+ int color[4];
+ float uv[4][2];
+ long a;
+ long b;
+ long c;
+ long d;
+} Pkt;
+
+extern f32 fast_arc_tan_c(f32, f32) __asm__("func_001F9E90");
typedef struct { char pad[0x140]; float position[4]; } L18FlareView;
-extern L18FlareView D_L18_00167680;
-extern float D_L18_001677C0_flare[] __asm__("D_L18_001677C0");
-extern L18FlareUV D_L18_001D9B50_flare[] __asm__("D_L18_001D9B50");
-extern L18FlareVector D_L18_001D9B70_flare[] __asm__("D_L18_001D9B70") __attribute__((section(".sdata")));
-extern int D_L18_00161EE4_flare __asm__("D_L18_00161EE4") __attribute__((sda));
-extern int D_L18_00161EE8_flare __asm__("D_L18_00161EE8") __attribute__((sda));
-extern int D_L18_00161EEC_flare __asm__("D_L18_00161EEC") __attribute__((sda));
-extern int D_L18_00161EF0_flare __asm__("D_L18_00161EF0") __attribute__((sda));
-extern int D_L18_00161EF8_flare __asm__("D_L18_00161EF8") __attribute__((sda));
-extern int D_L18_00161F08_flare __asm__("D_L18_00161F08") __attribute__((sda));
-extern void clear_flare_vector(void *) __asm__("FUN_001f99f8");
-extern float flare_length(float, float) __asm__("FUN_001f9e90");
-extern float flare_dot(void *, void *) __asm__("FUN_001f9b80");
-extern void copy_flare_vector(void *, void *) __asm__("FUN_001fa050");
-extern int tween_flare_color(float, int, int) __asm__("FUN_001fa6e0");
-extern void draw_flare_packet(void *, void *, int) __asm__("FUN_001f7d30");
-
-void FUN_L18_002ea1f8(struct Moby *moby) {
- L18FlarePacket packet[4];
- L18FlareVector axis;
- L18FlareVector basis[4][4];
- float *data = (float *)moby->pvars;
+extern L18FlareView D_L18_00167680 __attribute__((section(".data")));
+extern float D_L18_001D9B50[][2];
+extern float D_L18_001D9B70[][4][4];
+extern float vector_distance_xy_alt(void *, void *) __asm__("FUN_001f9b80");
+extern s32 fast_tween_color_c(s32, s32, f32) __asm__("func_001FA6E0");
+extern s64 get_effect_texture_c(s32) __asm__("func_001F44B8");
+extern int D_L18_00161EE4 __attribute__((sda));
+extern int D_L18_00161EE8 __attribute__((sda));
+extern int D_L18_00161EEC __attribute__((sda));
+extern int D_L18_00161EF0 __attribute__((sda));
+extern int D_L18_00161EF8 __attribute__((sda));
+extern int D_L18_00161F08 __attribute__((sda));
+extern void clear_u64_value_c(void *) __asm__("func_001F99F8");
+extern void euler_rotation_matrix(float *, float *) __asm__("FUN_001fa050");
+extern void fast_draw_quad_real(void *, void *, int);
+extern void fast_vec_scale_c(void *, void *, f32) __asm__("func_001F9A68");
+
+void FUN_L18_002ea1f8(char *moby) {
+ Pkt pkt[4];
+ float rot[4];
+ float m[4][4][4];
+ char *data = *(char **)(moby + 0x78);
+
+ clear_u64_value_c(rot);
+ rot[2] = fast_arc_tan_c(D_L18_00167680.position[0] - *(float *)(moby + 0x10), D_L18_00167680.position[1] - *(float *)(moby + 0x14));
+ rot[1] = -fast_arc_tan_c(vector_distance_xy_alt(moby + 0x10, &D_L18_00167680.position[0]), D_L18_00167680.position[2] - *(float *)(moby + 0x18));
+ euler_rotation_matrix(m[0][0], rot);
+ euler_rotation_matrix(m[1][0], rot);
+ fast_vec_scale_c(m[1][1], m[1][1], *(float *)(data + 0x24));
+ fast_vec_scale_c(m[1][2], m[1][2], *(float *)(data + 0x24));
+ qcopy(m[0][3], moby + 0x10);
+ qcopy(m[1][3], moby + 0x10);
+ rot[0] = *(float *)(data + 0x2C);
+ euler_rotation_matrix(m[2][0], rot);
+ fast_vec_scale_c(m[2][1], m[2][1], *(float *)(data + 0x24));
+ fast_vec_scale_c(m[2][2], m[2][2], *(float *)(data + 0x24));
+ qcopy(m[2][3], moby + 0x10);
+ rot[0] = *(float *)(data + 0x30);
+ euler_rotation_matrix(m[3][0], rot);
+ fast_vec_scale_c(m[3][1], m[3][1], *(float *)(data + 0x24));
+ fast_vec_scale_c(m[3][2], m[3][2], *(float *)(data + 0x24));
+ qcopy(m[3][3], moby + 0x10);
+ {
int i;
- unsigned int j;
- L18FlareVector *corner;
- float x, y;
- void *pos = &moby->pos;
- clear_flare_vector(&axis);
- x = moby->pos.x;
- y = moby->pos.y;
- x = D_L18_00167680.position[0] - x;
- y = D_L18_00167680.position[1] - y;
- axis.z = flare_length(x, y);
- axis.y = -flare_length(flare_dot(pos, D_L18_00167680.position),
- D_L18_00167680.position[2] - moby->pos.z);
- copy_flare_vector(&basis[0][0], &axis);
- copy_flare_vector(&basis[1][0], &axis);
- scale_vector_xyz(&basis[1][1], &basis[1][1], data[9]);
- scale_vector_xyz(&basis[1][2], &basis[1][2], data[9]);
- qcopy(&basis[0][3], pos);
- qcopy(&basis[1][3], pos);
- axis.x = data[11];
- copy_flare_vector(&basis[2][0], &axis);
- scale_vector_xyz(&basis[2][1], &basis[2][1], data[9]);
- scale_vector_xyz(&basis[2][2], &basis[2][2], data[9]);
- qcopy(&basis[2][3], pos);
- axis.x = data[12];
- copy_flare_vector(&basis[3][0], &axis);
- scale_vector_xyz(&basis[3][1], &basis[3][1], data[9]);
- scale_vector_xyz(&basis[3][2], &basis[3][2], data[9]);
- qcopy(&basis[3][3], pos);
- i = 0;
- do {
- packet[i].texture = get_effect_texture((&D_L18_00161F08_flare)[i]);
- packet[i].state = 0xff9000000260ULL;
- packet[i].flags = D_L18_00161EE4_flare | ((unsigned long long)D_L18_00161EE8_flare << 2);
- packet[i].flags |= (unsigned long long)D_L18_00161EEC_flare << 4;
- packet[i].flags |= (unsigned long long)D_L18_00161EF0_flare << 6;
- packet[i].flags |= 0x8000000000ULL;
- packet[i].zero = 0;
- corner = &D_L18_001D9B70_flare[i * 4];
- j = 0;
- do {
- packet[i].uv[j].u = D_L18_001D9B50_flare[j].u;
- packet[i].uv[j].v = D_L18_001D9B50_flare[j].v;
+ int j;
+ Pkt *p;
+ for (i = 0; i < 4; i++) {
+ {
+ long r = ((long (*)(int))get_effect_texture_c)(((int *)&(*(short *)&D_L18_00161F08))[i]);
+ p = &pkt[i];
+ p->b = r;
+ }
+ p->c = 0xFF9000000260;
+ p->d = (D_L18_00161EE4) | (long)(D_L18_00161EE8) << 2 | (long)(D_L18_00161EEC) << 4 |
+ (long)(D_L18_00161EF0) << 6 | 0x8000L << 24;
+ p->a = 0;
+ for (j = 0; j < 4; j++) {
+ pkt[i].uv[j][0] = D_L18_001D9B50[j][0];
+ pkt[i].uv[j][1] = D_L18_001D9B50[j][1];
if (i == 0) {
- packet[i].color[j] = tween_flare_color(data[9],
- (&D_L18_00161EF8_flare)[i] & 0xffffff, (&D_L18_00161EF8_flare)[i]);
+ pkt[0].color[j] = fast_tween_color_c(D_L18_00161EF8 & 0xFFFFFF, D_L18_00161EF8, *(float *)(data + 0x24));
} else {
- packet[i].color[j] = (&D_L18_00161EF8_flare)[i];
+ pkt[i].color[j] = ((int *)&(*(short *)&D_L18_00161EF8))[i];
}
- qcopy(&packet[i].corner[j], corner);
- j++;
- corner++;
- } while (j < 4);
- i++;
- } while (i < 4);
- draw_flare_packet(&packet[0], &basis[0][0], 0);
- draw_flare_packet(&packet[1], &basis[1][0], 0);
- draw_flare_packet(&packet[2], &basis[2][0], 0);
- draw_flare_packet(&packet[3], &basis[3][0], 0);
+ qcopy(pkt[i].vtx[j], D_L18_001D9B70[i][j]);
+ }
+ }
+ }
+ fast_draw_quad_real(&pkt[0], m[0], 0);
+ fast_draw_quad_real(&pkt[1], m[1], 0);
+ fast_draw_quad_real(&pkt[2], m[2], 0);
+ fast_draw_quad_real(&pkt[3], m[3], 0);
}
-#endif
/* Ported from rac1-decomp (src/overlays/l18_veldin2/vendor_002A8400.c: func_L18_002EB988), where it is exact; names translated to the US level program. */
extern char *spawn_spark(void *, void *, void *, int, int, int, int, int, int) __asm__("FUN_00218888");
@@ -2911,7 +2899,7 @@ extern P_ec290 D_L18_001DA160[];
extern V_ec290 D_L18_001D9CF0[];
extern V_ec290 D_L18_001D9D00[2][20];
extern V_ec290 D_L18_001D9FD0[];
-extern char D_0013F5E0_c[] __asm__("D_0013F5E0");
+extern char D_0013F5E0[];
extern f32 distance_xyz(void *, void *) __asm__("func_001F9B48");
extern f32 fast_cos_c(f32) __asm__("func_001F9DC8");
extern f32 fast_sin_c(f32) __asm__("func_001F9DE0");
@@ -2978,7 +2966,7 @@ void FUN_L18_002eaea0(void *moby) {
}
subtract_vector_xyz(&s[0], data + 0x10, (char *)moby + 0x10);
normalize_vector_xyz(&s[0], &s[0], 1.0f);
- cross_vectors_xyz(&s[1], &s[0], D_0013F5E0_c);
+ cross_vectors_xyz(&s[1], &s[0], D_0013F5E0);
build_look_at_matrix(&s[0], &s[0], &s[1], 0.17453292f);
scale_vector_xyz_c(&s[3], &s[0], scale);
qcopy(D_L18_001D9D00[0], (char *)moby + 0x10);
@@ -3053,9 +3041,9 @@ void FUN_L18_002eaea0(void *moby) {
qcopy(&s[4], &D_L18_001D9FD0[i]);
}
}
- cross_vectors_xyz(&s[6], &s[0], D_0013F5E0_c);
+ cross_vectors_xyz(&s[6], &s[0], D_0013F5E0);
normalize_vector_xyz(&s[6], &s[6], 1.0f);
- normalize_vector_xyz(&s[7], D_0013F5E0_c, 1.0f);
+ normalize_vector_xyz(&s[7], D_0013F5E0, 1.0f);
for (k = 0; k < 4; k++) {
float t;
if (k < 2) {
diff --git a/src/overlays/shared/gameplay/camera/follow_camera_update.c b/src/overlays/shared/gameplay/camera/follow_camera_update.c
index aa58613210..47d100c603 100644
--- a/src/overlays/shared/gameplay/camera/follow_camera_update.c
+++ b/src/overlays/shared/gameplay/camera/follow_camera_update.c
@@ -1323,109 +1323,91 @@ void FUN_L00_002ebb00(O002ebb00 *o) {
FUN_L00_001eb0c8(o->x50, m2 + 0x14, 0.0f);
FUN_L00_002eb3b0_u(o);
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L00_002ebbd8.s", FUN_L00_002ebbd8);
-#else
-extern int FUN_001fef20_2ebbd8(int) __asm__("FUN_001f96f8");
-extern void FUN_001ff260_2ebbd8(void *) __asm__("FUN_001f99f8");
-extern float FUN_001ff7e8_2ebbd8(float) __asm__("FUN_001f9dc8");
-extern float FUN_001ff800_2ebbd8(float) __asm__("FUN_001f9de0");
-extern void FUN_001ff2a8_2ebbd8(void *, void *, void *) __asm__("FUN_001f9a28");
-extern void FUN_001ff500_2ebbd8(void *, void *, float) __asm__("FUN_001f9bf8");
-extern float FUN_001ff8b0_2ebbd8(float, float) __asm__("FUN_001f9e90");
+/* Sets up the camera activation moby: tuning floats, then the pose copied from the current camera. */
+/* Ported from rac1-decomp (src/overlays/shared/vendor_002EB0D8.c: func_L00_002ED088), where it is exact; names translated to the US level program. */
+
+extern char D_0013F350[] __attribute__((section(".data")));
+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 int D_0015ED84 __attribute__((section(".sdata")));
+extern s32 scale_game_frames_c(s32) __asm__("func_001F96F8");
+extern void clear_u64_value_c(void *) __asm__("func_001F99F8");
+extern void fast_vec_normalize(void *, void *, f32) __asm__("FUN_001f9bf8");
+extern void subtract_vector_xyz_c(void *, void *, void *) __asm__("FUN_001f9a28");
void FUN_L00_002ebbd8(void *arg) {
- O002ebb00 *o = (O002ebb00 *)arg;
- char *m;
- char *p;
- struct Hero *g;
- char *cam;
- char *tail;
- char *source;
- char *q;
- int state = current_level_index;
- float scale = 1.5f;
- int frames;
- int next;
-
- {
- char *m = (char *)o->m;
- p = m + 0x40;
- }
+ char *m = arg;
+ char *g;
+ int lvl0 = D_0015ED84;
+ int lvl;
+ char *p = *(char **)(m + 0x70) + 0x40;
+ float f;
+ char *t, *q, *r, *w, *s19, *src;
+ char *gg, *gg0, *h;
*(int *)(p + 0x40) = 0;
- if (state == 14) {
- if ((unsigned)(hero.state.current - 0x2c) >= 2) {
- *(float *)(p + 0x4c) = scale;
- goto scale_done;
- }
- scale = 2.0f;
- }
- *(float *)(p + 0x4c) = scale;
-scale_done:
- g = &hero;
- *(float *)(p + 0x48) = 0.20943952f;
- *(float *)(p + 0x58) = 0.0017453292f;
- *(float *)(p + 0x5c) = -0.004363323f;
- *(int *)(p + 0x44) = ((int)g->moby);
- {
- char *m = (char *)((volatile O002ebb00 *)o)->m + 0xa0;
- *(float *)(m + 0) = 4.64f;
- *(float *)(m + 4) = 0.5f;
- *(float *)(m + 0x10) = 2.0f;
- *(float *)(m + 0x14) = 0.05f;
- }
- {
- char *m = (char *)((volatile O002ebb00 *)o)->m;
- *(int *)(m + 0x18) = 0;
- *(float *)(m + 0x10) = 0.01f;
- *(float *)(m + 0x14) = 0.3f;
- frames = FUN_001fef20_2ebbd8(0x78);
- *(short *)(m + 0x1c) = 0;
- *(short *)(m + 0x1e) = frames;
- FUN_001ff260_2ebbd8(m);
- }
- {
- char *m = (char *)((volatile O002ebb00 *)o)->m + 0x30;
- *(float *)(m + 4) = 0.02f;
- *(float *)(m + 8) = 0.2f;
- *(int *)(m + 0xc) = 0;
- *(int *)m = 0;
- }
- m = (char *)((volatile O002ebb00 *)o)->m;
- tail = m + 0xb8;
- *(int *)(tail + 4) = 0;
+ f = 1.5f;
+ if (lvl0 == 0xE && (h = D_0013F350, (unsigned)(*(int *)(h + 0x2084) - 0x2C) < 2))
+ *(float *)(p + 0x4C) = 2.0f;
+ else
+ *(float *)(p + 0x4C) = 1.5f;
+ g = D_0013F350;
+ *(float *)(p + 0x48) = 0.20943951606750488f;
+ *(float *)(p + 0x58) = 0.001745329238474369f;
+ *(float *)(p + 0x5C) = -0.004363323096185923f;
+ *(int *)(p + 0x44) = *(int *)(g + 0x2080);
{
- char *cam = D_00166C80_c;
- source = *(char **)(cam + 0x184);
- }
- q = (char *)o + 0x30;
- qcopy(q, source + 0x30);
- qcopy(o, source);
- qcopy((char *)o + 0x10, source + 0x10);
- qcopy((char *)o + 0x20, source + 0x20);
- qcopy((char *)o + 0x40, o);
- *(short *)((char *)o + 0x7e) = 0;
- if ((unsigned)(g->state.current - 0x2c) < 2) {
- *(float *)(p + 0x30) = FUN_001ff7e8_2ebbd8(g->unk9AC);
- *(float *)(p + 0x34) = FUN_001ff800_2ebbd8(g->unk9AC);
+ char *q0 = *(char **)(m + 0x70);
+ *(float *)(q0 + 0xA0) = 4.639999866485596f;
+ q0 += 0xA0;
+ *(float *)(q0 + 4) = 0.5f;
+ *(float *)(q0 + 0x10) = 2.0f;
+ *(float *)(q0 + 0x14) = 0.05f;
+ }
+ r = *(char **)(m + 0x70);
+ *(int *)(r + 0x18) = 0;
+ *(float *)(r + 0x10) = 0.01f;
+ *(float *)(r + 0x14) = 0.3f;
+ *(short *)(r + 0x1E) = scale_game_frames_c(0x78);
+ *(short *)(r + 0x1C) = 0;
+ clear_u64_value_c(r);
+ q = *(char **)(m + 0x70);
+ t = q + 0x30;
+ *(float *)(t + 4) = 0.02f;
+ *(float *)(t + 8) = 0.2f;
+ *(int *)(t + 0xC) = 0;
+ *(int *)(q + 0x30) = 0;
+ s19 = *(char **)(m + 0x70);
+ w = s19 + 0xB8;
+ *(int *)(w + 4) = 0;
+ gg0 = (char *)&D_L00_00166C80;
+ src = *(char **)(gg0 + 0x184);
+ qcopy(m + 0x30, src + 0x30);
+ qcopy(m, src);
+ qcopy(m + 0x10, src + 0x10);
+ qcopy(m + 0x20, src + 0x20);
+ qcopy(m + 0x40, m);
+ *(short *)(m + 0x7E) = 0;
+ lvl = *(int *)(g + 0x2084);
+ if ((unsigned)(lvl - 0x2C) < 2) {
+ *(float *)(p + 0x30) = fast_cos(*(float *)(g + 0x9AC));
+ *(float *)(p + 0x34) = fast_sin(*(float *)(g + 0x9AC));
*(int *)(p + 0x38) = 0;
- *(float *)(m + 0xb8) = g->unk9AC;
- *(int *)(tail + 8) = (int)g->unk994;
+ *(float *)(s19 + 0xB8) = *(float *)(g + 0x9AC);
+ *(int *)(w + 8) = *(int *)(g + 0x994);
} else {
- FUN_001ff2a8_2ebbd8(p + 0x30, ((char *)g->unk964) + 0x10, q);
+ subtract_vector_xyz_c(p + 0x30, *(char **)(g + 0x964) + 0x10, m + 0x30);
*(int *)(p + 0x38) = 0;
- *(int *)(p + 0x3c) = 0;
- FUN_001ff500_2ebbd8(p + 0x30, p + 0x30, 1.0f);
- *(float *)(m + 0xb8) =
- FUN_001ff8b0_2ebbd8(*(float *)(p + 0x30), *(float *)(p + 0x34));
- *(int *)(tail + 8) = (int)g->unk964;
- }
- cam = D_00166C80_c;
- *(char *)(cam + 0x273) = 2;
- *(short *)(cam + 0x270) = 1;
- *(int *)(cam + 0x2f4) = FUN_001fef20_2ebbd8(0x3c);
+ *(int *)(p + 0x3C) = 0;
+ fast_vec_normalize(p + 0x30, p + 0x30, 1.0f);
+ *(float *)(s19 + 0xB8) = fast_arc_tan_c(*(float *)(p + 0x30), *(float *)(p + 0x34));
+ *(int *)(w + 8) = *(int *)(g + 0x964);
+ }
+ gg = (char *)&D_L00_00166C80;
+ *(char *)(gg + 0x273) = 2;
+ *(short *)(gg + 0x270) = 1;
+ *(int *)(gg + 0x2F4) = scale_game_frames_c(0x3C);
}
-#endif
#ifndef NON_MATCHING
INCLUDE_ASM("config/us/overlays/asm/FUN_L00_002ebe70.s", FUN_L00_002ebe70);
#else
@@ -1589,7 +1571,7 @@ void FUN_L00_002ec4a8(unsigned char *m) {
/* Ported from rac1-decomp (src/overlays/shared/vendor_002EB0D8.c: func_L00_002EDB70), where it is exact; names translated to the US level program. */
extern int scale_game_frames(int) __asm__("FUN_001f96f8");
-extern void FUN_L00_002ebbd8(void *);
+extern void FUN_L00_002ebbd8_u(void *) __asm__("FUN_L00_002ebbd8");
void refresh_point_light(s32 arg0) __asm__("FUN_00201f58");
extern char D_L00_00166D80_c[] __asm__("D_L00_00166C80");
@@ -1617,7 +1599,7 @@ void FUN_L00_002ec6c0(char *m) {
qcopy(r, m);
qcopy(r + 0x10, m + 0x10);
qcopy(r + 0x20, m + 0x20);
- FUN_L00_002ebbd8(m);
+ FUN_L00_002ebbd8_u(m);
*(int *)(g + 0x2F4) = scale_game_frames(0x2D);
}
done:
diff --git a/src/overlays/shared/gameplay/entities/00264e40.c b/src/overlays/shared/gameplay/entities/00264e40.c
index 0e4aa976fa..c1010b15fe 100644
--- a/src/overlays/shared/gameplay/entities/00264e40.c
+++ b/src/overlays/shared/gameplay/entities/00264e40.c
@@ -16,33 +16,34 @@ void FUN_L02_00264e40(char *moby) {
}
*(short *)(moby + 0x1C) = 0;
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L02_00264e70.s", FUN_L02_00264e70);
-#else
#include "qcopy.h"
-extern int D_L02_0015F5CC;
-extern float D_0015ED6C;
-extern float frame_time_sq __asm__("D_0015ED70");
-extern float D_L02_00174460[] __attribute__((section(".data")));
-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));
+
+/* Ported from rac1-decomp (src/overlays/shared/mobyutil_0025D750.c: func_L02_00265E88), where it is exact; names translated to the US level program. */
+
+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 float D_L02_00174460[];
+extern float FUN_001f96b0(float);
+extern float fast_vec_dist(void *, void *);
+extern int D_L02_0015F5CC __attribute__((section(".sdata")));
extern int FUN_001efa68(void *, void *, int, int, int);
-extern float fast_vec_dist(void *, void *) __asm__("FUN_001f9b48");
-extern void fast_vec_normalize(void *, void *, float) __asm__("FUN_001f9bf8");
-extern void add_vector_xyz(void *, void *, void *) __asm__("FUN_001f9a10");
-extern void fast_vec_scale(void *, void *, float) __asm__("FUN_001f9a68");
-extern void advance_accelerated_scalar(float *, float *, float, float, float, float) __asm__("FUN_00213f38");
-extern void random_vector(float *, float, float) __asm__("FUN_L00_00257d78");
-extern float random_float_between(float, float) __asm__("FUN_002132a8");
-extern float multiply_global_factor_ed64(float) __asm__("FUN_001f96b0");
-extern float scale_timer_random(float) __asm__("FUN_L02_0020ff48");
-extern int truncate_float_to_s32(float) __asm__("FUN_001fa6d0");
extern int FUN_001f9770(void *);
-extern char *FUN_L00_0026b230(void *, void *, unsigned long long, float);
+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 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");
+extern void advance_accelerated_scalar(float *, float *, float, float, float, float) __asm__("FUN_00213f38");
+extern void fast_vec_normalize(void *, void *, f32) __asm__("FUN_001f9bf8");
+extern void fast_vec_scale(void *, void *, f32) __asm__("func_001F9A68");
void FUN_L02_00264e70(char *slots, float *position, float *direction, float distance) {
float origin[4] __attribute__((aligned(16)));
@@ -50,19 +51,21 @@ void FUN_L02_00264e70(char *slots, float *position, float *direction, float dist
float adjusted[4] __attribute__((aligned(16)));
float velocity[4] __attribute__((aligned(16)));
float offset[4] __attribute__((aligned(16)));
- float speed;
- float travel_step;
+ float travel_step = 0.0f;
+ float speed = 0.0f;
float travel;
float acceleration;
- int count;
+ int n;
int first_count;
int i;
int save_shot;
char *shot;
+ unsigned long fl;
- travel_step = 0.0f;
- speed = 0.0f;
- save_shot = (D_L02_0015F5CC % 4) == 0;
+ {
+ int phase = D_L02_0015F5CC & 3;
+ save_shot = phase == 0;
+ }
qcopy(origin, position);
fast_vec_normalize(adjusted, direction, distance + 0.75f);
add_vector_xyz(end, adjusted, origin);
@@ -72,43 +75,42 @@ void FUN_L02_00264e70(char *slots, float *position, float *direction, float dist
} else {
travel = distance;
}
- acceleration = D_L02_001600D0 * D_0015ED6C;
- advance_accelerated_scalar(&speed, &travel_step, travel, 1.0f, frame_time_sq * 48.0f,
- acceleration);
- fast_vec_normalize(adjusted, adjusted, travel_step);
- first_count = D_L02_001600D4;
- count = D_L02_001600D8;
+ acceleration = D_0015ED70;
+ advance_accelerated_scalar(&speed, &travel_step, travel, 1.0f, acceleration * 48.0f,
+ (*(float *)&D_L02_001600D0) * D_0015ED6C);
+ ((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 < count + first_count; i++) {
- random_vector(offset, 0.0f,
- ((D_L02_001600DC - D_L02_001600E0) * (travel / distance) + D_L02_001600E0) * D_0015ED6C);
+ 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);
add_vector_xyz(offset, offset, adjusted);
fast_vec_scale(velocity, adjusted, random_float_between(0.0f, 1.0f));
add_vector_xyz(velocity, velocity, origin);
- shot = FUN_L00_0026b230(velocity, offset, i < first_count ? 1ULL : (unsigned long long)(i < first_count), travel);
+ if (i < first_count) fl = 1; else fl = 0;
+ shot = FUN_L00_0026b230(velocity, offset, fl, travel);
if (i == 2 && save_shot) {
int j;
- char **slot = (char **)slots;
for (j = 0; j < 7; j++) {
- if (*(char **)((char *)slot + (j << 2)) == 0) {
- *(char **)((char *)slot + (j << 2)) = shot;
+ if (((Slots_265E88 *)slots)->p[j] == 0) {
+ ((Slots_265E88 *)slots)->p[j] = shot;
break;
}
}
}
}
if (FUN_001f9770(slots + 0x1c)) {
- int timer = truncate_float_to_s32(scale_timer_random(random_float_between(10.0f, 30.0f)));
- acceleration = D_0015ED6C + D_0015ED6C;
- *(short *)(slots + 0x1c) = timer;
- random_vector(offset, 0.0f, acceleration);
+ 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);
fast_vec_scale(velocity, adjusted, random_float_between(0.5f, 0.1f));
add_vector_xyz(velocity, velocity, offset);
velocity[3] = 0.0f;
FUN_L00_0026d598(position, velocity, 0);
}
}
-#endif
/* Ported from rac1-decomp (src/overlays/shared/mobyutil_0025D750.c: func_L02_002661E8), where it is exact; names translated to the US level program. */
extern int collect_mobies_in_sphere(float, void *, int, int, int) __asm__("FUN_L00_001f2868");
diff --git a/src/overlays/shared/gameplay/entities/00295100.c b/src/overlays/shared/gameplay/entities/00295100.c
index c8190f9eaa..dfc68546eb 100644
--- a/src/overlays/shared/gameplay/entities/00295100.c
+++ b/src/overlays/shared/gameplay/entities/00295100.c
@@ -340,12 +340,12 @@ extern struct {
int x0, x4, x8;
} D_L00_00173E00_298840 __asm__("D_L00_00173E00") __attribute__((section(".data")));
extern int D_L00_0015F5A0_298840 __asm__("D_L00_0015F5A0");
-extern float D_L00_0015F3FC_298840 __asm__("D_L00_0015F3FC");
+extern float fade_level __asm__("D_L00_0015F3FC");
extern int D_L00_0015F400 __asm__("D_L00_0015F400");
extern O_298840 *D_L00_0015FFDC_298840 __asm__("D_L00_0015FFDC");
void f211250_298840(void) __asm__("FUN_L00_00211250");
void f216050_298840(int) __asm__("FUN_00216050");
-void update_audio_stream_until_idle(int) __asm__("FUN_002168a8");
+extern int update_audio_stream_until_idle(int) __asm__("FUN_002168a8");
void memset_298840(void *, int, int) __asm__("FUN_001f97e8");
void f2039a0_298840(void) __asm__("FUN_L00_002039a0");
extern int hero_set_state(int, int) __asm__("FUN_L00_002223f8");
@@ -387,7 +387,7 @@ void FUN_L00_00298840(int a) {
D_L00_0016C860_298840.x58 = D_L00_00173E00_298840.x4 + t;
D_L00_0016C860_298840.x5c = D_L00_00173E00_298840.x8 + t;
f2039a0_298840();
- D_L00_0015F3FC_298840 = 1.0f;
+ fade_level = 1.0f;
D_L00_0015F5C0_m[1] = 2;
D_L00_0015F400 = 0;
hero_set_state(100, 2);
@@ -454,7 +454,7 @@ extern struct {
} D_001516D0_298b18 __asm__("D_001516D0");
extern int D_L00_0015F5D8 __asm__("D_L00_0015F5D8");
extern float D_L00_0016CAF0_lui __asm__("D_L00_0016CAF0") __attribute__((section(".data")));
-extern int D_L00_0015F3FC_298b18 __asm__("D_L00_0015F3FC");
+extern float fade_level __asm__("D_L00_0015F3FC");
extern O_298b18 *D_L00_0015FFDC_298b18 __asm__("D_L00_0015FFDC");
extern C_298b18 D_L00_0016C860_298b18 __asm__("D_L00_0016C860") __attribute__((section(".data")));
void f2335a0_298b18(void) __asm__("FUN_002335a0");
@@ -480,7 +480,7 @@ void FUN_L00_00298b18(void) {
f1f4a58_298b18(0xC);
D_L00_0015F5C0_m[1] = 0;
D_L00_0016CAF0_lui = 0.63f;
- D_L00_0015F3FC_298b18 = 0;
+ (*(int *)&fade_level) = 0;
f1f2d98_298b18();
for (i = 0; i < D_L00_0016C860_298b18.n; i++) {
M_298b18 *m = D_L00_0016C860_298b18.m[i];
@@ -800,7 +800,7 @@ typedef struct {
P2_002994f8 x[5];
P2_002994f8 y[5];
} Tab_002994f8;
-extern Tab_002994f8 D_00137B80_002994f8 __asm__("D_00137B80");
+extern Tab D_00137B80;
void FUN_L00_002995d0(s32, s32, s32);
/* Passes disc table entry i at 0x1A28 (0x1A50 while D_0015ED80 is set) to FUN_L00_002995d0. */
void FUN_L00_002994f8(s32 i) {
@@ -808,11 +808,11 @@ void FUN_L00_002994f8(s32 i) {
if (i < 0)
return;
if (D_0015ED80) {
- a = D_00137B80_002994f8.y[i].a;
- b = D_00137B80_002994f8.y[i].b;
+ a = (*(Tab_002994f8 *)&D_00137B80).y[i].a;
+ b = (*(Tab_002994f8 *)&D_00137B80).y[i].b;
} else {
- a = D_00137B80_002994f8.x[i].a;
- b = D_00137B80_002994f8.x[i].b;
+ a = (*(Tab_002994f8 *)&D_00137B80).x[i].a;
+ b = (*(Tab_002994f8 *)&D_00137B80).x[i].b;
}
FUN_L00_002995d0(a, b, 0);
}
@@ -911,14 +911,14 @@ INCLUDE_ASM("config/us/overlays/asm/FUN_L00_002997c8.s", FUN_L00_002997c8);
#else
typedef struct { u8 pad[0x38]; s16 h38; } S_2997c8;
typedef struct { u8 pad[0x6B]; u8 f; } M_2997c8;
-extern s32 D_0015ED80_2997c8 __asm__("D_0015ED80");
+extern int D_0015ED80;
extern s32 D_0015EE88_2997c8 __asm__("D_0015EE88");
extern s32 D_0015EE78_2997c8 __asm__("D_0015EE78");
extern s32 D_0015EED8_2997c8 __asm__("D_0015EED8");
extern S_2997c8 D_001516D0_2997c8 __asm__("D_001516D0") __attribute__((section(".data")));
extern s32 D_L00_0015F5C4_2997c8 __asm__("D_L00_0015F5C4");
extern struct ActiveSceneTrigger active_scene_trigger_lui __asm__("D_L00_00179100") __attribute__((section(".data")));
-extern M_2997c8 D_0013E550_2997c8 __asm__("D_0013E550") __attribute__((section(".data")));
+extern char D_0013E550[] __attribute__((section(".data")));
int FUN_00122298_2997c8(s32) __asm__("FUN_00122298");
void FUN_00120558_2997c8(s32, s32) __asm__("FUN_00120558");
void FUN_00122e68_2997c8(void *) __asm__("FUN_00122e68");
@@ -937,8 +937,8 @@ void FUN_L00_002997c8(void) {
FUN_00122298_2997c8(0);
FUN_00120558_2997c8(0, 0);
FUN_00122e68_2997c8(FUN_0012f1c8_2997c8);
- large_count = D_0015ED80_2997c8 ? 14 : 13;
- small_count = D_0015ED80_2997c8 ? 14 : 17;
+ large_count = D_0015ED80 ? 14 : 13;
+ small_count = D_0015ED80 ? 14 : 17;
src = D_L00_00161058;
vram = D_0015EE88_2997c8;
for (i = 0; i < large_count; i++) {
@@ -972,7 +972,7 @@ void FUN_L00_002997c8(void) {
active->trigger = 0;
FUN_00216c48_2997c8(moby, trigger, 1);
}
- D_0013E550_2997c8.f |= 0x10;
+ (*(M_2997c8 *)D_0013E550).f |= 0x10;
}
#endif
/* Stop sound, wait for the loader to go idle, then start the movie load. */
@@ -1008,63 +1008,51 @@ void FUN_L00_002999a8(void) {
sceCdSync_alt(0);
FUN_L00_002997c8();
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L00_00299a68.s", FUN_L00_00299a68);
-#else
-extern int FUN_L00_002660c0(s32);
-extern void FUN_L00_001ff040(void *, s32, s32);
-extern void FUN_L00_00265fa0(s32, s32, s32);
+/* starts the slideshow: resets state, rebases the level data pointers, and starts the first two streams */
+/* Ported from rac1-decomp (src/overlays/shared/tieproc_00299108.c: func_L00_0029ADD8), where it is exact; names translated to the US level program. */
-/* The retail record bases are 0x16A8 and 0x1748 within disc_table.
- * This view preserves those offsets separately from the signed index.
- * The spacing does not establish the number of valid records. */
-typedef struct {
- char pad[0x16A8];
- struct DiscFile records[20];
- struct DiscFile records_alt[20];
-} DiscTableRecords;
+typedef struct { int a; int b; } LL9;
-void FUN_L00_00299a68(void) {
+typedef struct { char pad[0x16A8]; LL9 normal[20]; LL9 alt[20]; } G9;
- s32 offset;
- s32 first_destination, second_destination;
- s32 index;
+extern Tab D_00137B80;
+extern float fade_level_gp __asm__("D_L00_0015F3FC") __attribute__((section(".sdata")));
+extern int D_L00_0015F5C4 __attribute__((section(".sdata")));
+extern int D_L00_0015F5D8_gp __asm__("D_L00_0015F5D8") __attribute__((section(".sdata")));
+extern short D_L00_0015F620 __attribute__((section(".sdata")));
+extern int D_L00_00173E00[];
+extern int D_L00_001611CC __attribute__((section(".sdata")));
+extern int update_audio_stream_until_idle(int) __asm__("FUN_002168a8");
+extern int D_0015ED80_gp __asm__("D_0015ED80") __attribute__((section(".sdata")));
+extern s32 start_audio_stream_read(s32 dst, s32 sector, s32 sector_count) __asm__("FUN_00216788");
+extern void FillTransferWords(void *, s32, s32);
+extern void fade_to_black(s32 n) __asm__("FUN_001f4a58");
- FUN_L00_002660c0(0);
- FUN_L00_001f9838(8);
- D_L00_0015F5D8 = 1;
- D_L00_0015F3FC_298840 = 1.0f;
- FUN_L00_001ff040((D_L00_0015F5C4 = 7, (char *)&D_L00_0015F622 - 2), 0, 0x10);
- offset = D_L00_001611CC - 0xE0000;
- first_destination = D_L00_00173E00_298840.x4 + offset;
- second_destination = D_L00_00173E00_298840.x8 + offset;
- D_L00_0015F62C = second_destination;
- D_L00_001611CC = offset;
- *(volatile s32 *)&D_L00_0015F628 = first_destination;
- if (pal_mode != 0) {
- index = (s16)D_L00_0015F622;
- FUN_L00_00265fa0(first_destination, ((DiscTableRecords *)&disc_table)->records_alt[index].sector,
- ((DiscTableRecords *)&disc_table)->records_alt[index].size);
+void FUN_L00_00299a68(void) {
+ int t;
+ update_audio_stream_until_idle(0);
+ fade_to_black(8);
+ D_L00_0015F5D8_gp = 1;
+ fade_level_gp = 1.0f;
+ D_L00_0015F5C4 = 7;
+ FillTransferWords(((int *)&D_L00_0015F620), 0, 16);
+ t = D_L00_001611CC - 0xE0000;
+ ((int *)&D_L00_0015F620)[2] = D_L00_00173E00[1] + t;
+ ((int *)&D_L00_0015F620)[3] = D_L00_00173E00[2] + t;
+ D_L00_001611CC = t;
+ if (D_0015ED80_gp != 0) {
+ start_audio_stream_read(((int *)&D_L00_0015F620)[2], (*(G9 *)&D_00137B80).alt[((short *)((int *)&D_L00_0015F620))[1]].a, (*(G9 *)&D_00137B80).alt[((short *)((int *)&D_L00_0015F620))[1]].b);
} else {
- index = (s16)D_L00_0015F622;
- FUN_L00_00265fa0(first_destination, ((DiscTableRecords *)&disc_table)->records[index].sector,
- ((DiscTableRecords *)&disc_table)->records[index].size);
- }
- FUN_L00_002660c0(1);
- index = D_L00_0015F622 + 1;
- D_L00_0015F622 = index;
- index = (s32)((u32)index << 16);
- if (pal_mode != 0) {
- second_destination = D_L00_0015F62C;
- FUN_L00_00265fa0(second_destination, ((DiscTableRecords *)&disc_table)->records_alt[index >> 16].sector,
- ((DiscTableRecords *)&disc_table)->records_alt[index >> 16].size);
+ start_audio_stream_read(((int *)&D_L00_0015F620)[2], (*(G9 *)&D_00137B80).normal[((short *)((int *)&D_L00_0015F620))[1]].a, (*(G9 *)&D_00137B80).normal[((short *)((int *)&D_L00_0015F620))[1]].b);
+ }
+ update_audio_stream_until_idle(1);
+ ((short *)((int *)&D_L00_0015F620))[1]++;
+ if (D_0015ED80_gp != 0) {
+ start_audio_stream_read(((int *)&D_L00_0015F620)[3], (*(G9 *)&D_00137B80).alt[((short *)((int *)&D_L00_0015F620))[1]].a, (*(G9 *)&D_00137B80).alt[((short *)((int *)&D_L00_0015F620))[1]].b);
} else {
- second_destination = D_L00_0015F62C;
- FUN_L00_00265fa0(second_destination, ((DiscTableRecords *)&disc_table)->records[index >> 16].sector,
- ((DiscTableRecords *)&disc_table)->records[index >> 16].size);
+ start_audio_stream_read(((int *)&D_L00_0015F620)[3], (*(G9 *)&D_00137B80).normal[((short *)((int *)&D_L00_0015F620))[1]].a, (*(G9 *)&D_00137B80).normal[((short *)((int *)&D_L00_0015F620))[1]].b);
}
}
-#endif
extern s32 D_L00_0015F3FC;
void FUN_L00_002a09d8(s32);
void fade_to_black(s32) __asm__("FUN_001f4a58");
@@ -1105,7 +1093,7 @@ void FUN_L00_00299c48(void) {
if (fade_level < 0.0f) {
fade_level = 0.0f;
}
- stage = D_L00_0015F620;
+ stage = ((int *)&D_L00_0015F620);
active = 1;
pal = D_0013D1D2 == 'A';
if (stage == 0) {
@@ -1119,7 +1107,7 @@ void FUN_L00_00299c48(void) {
}
if ((s16)D_L00_0015F622 < 0x2b) {
D_L00_0015F624 = -1;
- D_L00_0015F620 = 1;
+ ((int *)&D_L00_0015F620) = 1;
} else {
FUN_L00_00299c00();
return;
@@ -1156,7 +1144,7 @@ void FUN_L00_00299c48(void) {
D_L00_0015F626 = 0x32b4;
}
}
- D_L00_0015F620 = 0;
+ ((int *)&D_L00_0015F620) = 0;
index = (s16)(D_L00_0015F622 + 1);
D_L00_0015F624 = -1;
D_L00_0015F622 = index;
@@ -1353,9 +1341,9 @@ extern s32 D_0015ED98_29a6b0 __asm__("D_0015ED98");
extern s32 weapon_ammo_counts[] __asm__("D_0013D428");
extern s32 D_L00_00173E00_29a6b0[] __asm__("D_L00_00173E00");
extern s32 D_L00_0015F5D8 __asm__("D_L00_0015F5D8");
-extern f32 D_L00_0015F3FC_29a6b0 __asm__("D_L00_0015F3FC");
+extern float fade_level __asm__("D_L00_0015F3FC");
extern s32 D_L00_0015F400 __asm__("D_L00_0015F400");
-extern u8 D_0013F350_29a6b0[] __asm__("D_0013F350");
+extern unsigned char D_0013F350[];
extern Vec4 D_L00_00180260_29a6b0 __asm__("D_L00_00180260");
extern s32 D_L00_00161188;
extern s32 D_L00_0016118C;
@@ -1463,12 +1451,12 @@ void FUN_L00_0029a6b0(VendorMoby_29a6b0 *m) {
FUN_001f4a58_29a6b0(4);
}
FUN_L00_002039a0_29a6b0();
- D_L00_0015F3FC_29a6b0 = 1.0f;
+ fade_level = 1.0f;
D_L00_0015F5C4 = 5;
D_L00_0015F400 = 0;
FUN_L00_002223f8_29a6b0(100, 1);
- D_0013F350_29a6b0[0x20AC] = 1;
- D_0013F350_29a6b0[0x20A5] = 1;
+ D_0013F350[0x20AC] = 1;
+ D_0013F350[0x20A5] = 1;
FUN_L00_00232fe8_29a6b0();
if (vendor_29a6b0.mode != 0) {
FUN_00212ed8_29a6b0(m, 3, 0);
diff --git a/src/overlays/shared/gameplay/entities/0029f990.c b/src/overlays/shared/gameplay/entities/0029f990.c
index 8f0c4d1725..5f64899693 100644
--- a/src/overlays/shared/gameplay/entities/0029f990.c
+++ b/src/overlays/shared/gameplay/entities/0029f990.c
@@ -158,91 +158,70 @@ void FUN_L00_0029fcd0(void *m) {
FUN_0020d330_29fcd0(m, 1);
FUN_001f5450_29fcd0(w, h, x, y, 0, 0, x, y, 0x80808080L, D_0015EED0_29fcd0);
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L00_0029ff58.s", FUN_L00_0029ff58);
-#else
-typedef struct {
- float position[4][4];
- int color[4];
+/* Draws the four quads of the hologram cone, scrolling the texture coordinates. */
+/* Ported from rac1-decomp (src/overlays/shared/vendor_0029FD68.c: func_L00_002A11E8), where it is exact; names translated to the US level program. */
+
+struct Quad { int a, b, c, d; };
+
+struct HoloPacket {
+ float pos[4][4];
+ int col[4];
float uv[4][2];
- long extra[4];
-} L00Quad29ff58;
+ long hdr[4];
+};
+extern float D_L00_001CA380[][4];
+extern float D_L00_001CA410[][2];
+extern int D_L00_001CA458[] __attribute__((section(".data")));
+extern int D_L00_001CA4C0_lui[] __asm__("D_L00_001CA4C0") __attribute__((section(".data")));
+extern s64 get_effect_texture_c(s32) __asm__("func_001F44B8");
extern float D_L00_00161184 __attribute__((sda));
-extern int D_L00_001CA480[4][4];
-extern float D_L00_001CA380[16][4];
-extern float D_L00_001CA410[8][2];
-extern int D_L00_001CA458[];
-typedef struct {
- char pad[0x1c];
- char *f1C;
-} L00ObjectState29ff58;
-extern L00ObjectState29ff58 D_L00_001CA4C0_29ff58 __asm__("D_L00_001CA4C0");
-extern long FUN_001f44b8_29ff58(int) __asm__("FUN_001f44b8");
-extern void FUN_001f9cf8_29ff58(void *, void *, void *) __asm__("FUN_001f9cf8");
-extern void FUN_001f7d30_29ff58(void *, int, int) __asm__("FUN_001f7d30");
+extern struct Quad D_L00_001CA480[] __attribute__((section(".data")));
+extern void fast_draw_quad_real(void *, void *, int);
+extern void transform_vector_by_basis(void *, void *, void *) __asm__("func_001F9CF8");
void FUN_L00_0029ff58(void) {
- L00Quad29ff58 q;
- float transformed[4][4];
- float *position;
-
- int offset;
+ struct HoloPacket s;
+ float v[4][4];
int i;
- int index0, index1, index2, index3;
- int *indices, *second, *third;
D_L00_00161184 = D_L00_00161184 + 0.01f;
- if (1.0f < D_L00_00161184) {
- D_L00_00161184 = D_L00_00161184 - 1.0f;
- }
- q.extra[0] = 0;
- q.extra[3] = 0x4000000044L;
- indices = D_L00_001CA480[0];
- q.extra[2] = 1;
- q.extra[1] = FUN_001f44b8_29ff58(0x18);
- i = 0;
- while (1) {
- offset = i * 16;
- i++;
- FUN_001f9cf8_29ff58(transformed[0], D_L00_001CA380[indices[0]], D_L00_001CA4C0_29ff58.f1C + 0xc0);
- /* Each row is 16 bytes, so the low offset bits select its fields. */
- second = (int *)((int)D_L00_001CA480 + (offset | 4));
- FUN_001f9cf8_29ff58(transformed[1], D_L00_001CA380[*second], D_L00_001CA4C0_29ff58.f1C + 0xc0);
- third = (int *)((int)D_L00_001CA480 + (offset | 8));
- FUN_001f9cf8_29ff58(transformed[2], D_L00_001CA380[*third], D_L00_001CA4C0_29ff58.f1C + 0xc0);
- FUN_001f9cf8_29ff58(transformed[3], D_L00_001CA380[indices[3]], D_L00_001CA4C0_29ff58.f1C + 0xc0);
- position = (float *)(D_L00_001CA4C0_29ff58.f1C);
-#define SET_POSITION(n) \
- q.position[n][0] = position[4] + transformed[n][0]; \
- q.position[n][1] = position[5] + transformed[n][1]; \
- q.position[n][2] = position[6] + transformed[n][2]
- SET_POSITION(0);
- SET_POSITION(1);
- SET_POSITION(2);
- SET_POSITION(3);
-#undef SET_POSITION
- index0 = indices[0];
- index1 = *second;
- index2 = *third;
- index3 = indices[3];
- q.color[0] = D_L00_001CA458[index0];
- q.color[1] = D_L00_001CA458[index1];
- q.color[2] = D_L00_001CA458[index2];
- q.color[3] = D_L00_001CA458[index3];
- q.uv[0][0] = D_L00_001CA410[index0][0];
- q.uv[0][1] = D_L00_001CA410[index0][1] + D_L00_00161184;
- q.uv[1][0] = D_L00_001CA410[index1][0];
- q.uv[1][1] = D_L00_001CA410[index1][1] + D_L00_00161184;
- q.uv[2][0] = D_L00_001CA410[index2][0];
- q.uv[2][1] = D_L00_001CA410[index2][1] + D_L00_00161184;
- q.uv[3][0] = D_L00_001CA410[index3][0];
- q.uv[3][1] = D_L00_001CA410[index3][1] + D_L00_00161184;
- indices += 4;
- FUN_001f7d30_29ff58(&q, 0, 1);
- if (i >= 4) break;
+ if (D_L00_00161184 > 1.0f) D_L00_00161184 = D_L00_00161184 - 1.0f;
+ s.hdr[2] = 1;
+ s.hdr[3] = 0x4000000044L;
+ s.hdr[0] = 0;
+ s.hdr[1] = get_effect_texture_c(0x18);
+ for (i = 0; i < 4; i++) {
+ transform_vector_by_basis(v[0], D_L00_001CA380[D_L00_001CA480[i].a], (char *)D_L00_001CA4C0_lui[7] + 0xC0);
+ transform_vector_by_basis(v[1], D_L00_001CA380[*(int *)((char *)D_L00_001CA480 + i * 16 + 4)], (char *)D_L00_001CA4C0_lui[7] + 0xC0);
+ transform_vector_by_basis(v[2], D_L00_001CA380[*(int *)((char *)D_L00_001CA480 + i * 16 + 8)], (char *)D_L00_001CA4C0_lui[7] + 0xC0);
+ transform_vector_by_basis(v[3], D_L00_001CA380[D_L00_001CA480[i].d], (char *)D_L00_001CA4C0_lui[7] + 0xC0);
+ s.pos[0][0] = *(float *)((char *)D_L00_001CA4C0_lui[7] + 0x10) + v[0][0];
+ s.pos[0][1] = *(float *)((char *)D_L00_001CA4C0_lui[7] + 0x14) + v[0][1];
+ s.pos[0][2] = *(float *)((char *)D_L00_001CA4C0_lui[7] + 0x18) + v[0][2];
+ s.pos[1][0] = *(float *)((char *)D_L00_001CA4C0_lui[7] + 0x10) + v[1][0];
+ s.pos[1][1] = *(float *)((char *)D_L00_001CA4C0_lui[7] + 0x14) + v[1][1];
+ s.pos[1][2] = *(float *)((char *)D_L00_001CA4C0_lui[7] + 0x18) + v[1][2];
+ s.pos[2][0] = *(float *)((char *)D_L00_001CA4C0_lui[7] + 0x10) + v[2][0];
+ s.pos[2][1] = *(float *)((char *)D_L00_001CA4C0_lui[7] + 0x14) + v[2][1];
+ s.pos[2][2] = *(float *)((char *)D_L00_001CA4C0_lui[7] + 0x18) + v[2][2];
+ s.pos[3][0] = *(float *)((char *)D_L00_001CA4C0_lui[7] + 0x10) + v[3][0];
+ s.pos[3][1] = *(float *)((char *)D_L00_001CA4C0_lui[7] + 0x14) + v[3][1];
+ s.pos[3][2] = *(float *)((char *)D_L00_001CA4C0_lui[7] + 0x18) + v[3][2];
+ s.col[0] = D_L00_001CA458[D_L00_001CA480[i].a];
+ s.col[1] = D_L00_001CA458[*(int *)((char *)D_L00_001CA480 + i * 16 + 4)];
+ s.col[2] = D_L00_001CA458[*(int *)((char *)D_L00_001CA480 + i * 16 + 8)];
+ s.col[3] = D_L00_001CA458[D_L00_001CA480[i].d];
+ s.uv[0][0] = D_L00_001CA410[D_L00_001CA480[i].a][0];
+ s.uv[0][1] = D_L00_001CA410[D_L00_001CA480[i].a][1] + D_L00_00161184;
+ s.uv[1][0] = D_L00_001CA410[*(int *)((char *)D_L00_001CA480 + i * 16 + 4)][0];
+ s.uv[1][1] = D_L00_001CA410[*(int *)((char *)D_L00_001CA480 + i * 16 + 4)][1] + D_L00_00161184;
+ s.uv[2][0] = D_L00_001CA410[*(int *)((char *)D_L00_001CA480 + i * 16 + 8)][0];
+ s.uv[2][1] = D_L00_001CA410[*(int *)((char *)D_L00_001CA480 + i * 16 + 8)][1] + D_L00_00161184;
+ s.uv[3][0] = D_L00_001CA410[D_L00_001CA480[i].d][0];
+ s.uv[3][1] = D_L00_001CA410[D_L00_001CA480[i].d][1] + D_L00_00161184;
+ fast_draw_quad_real(&s, 0, 1);
}
}
-#endif
#include "eetypes.h"
#include "qzero.h"
typedef struct {
@@ -322,7 +301,7 @@ extern void draw_mobys_setup(void) __asm__("FUN_0020d278");
extern void init_moby_class_dists(void) __asm__("FUN_0020d1f0");
extern void stash_moby_class_dists(void) __asm__("FUN_0020d218");
extern void draw_moby_list(void *, s32) __asm__("FUN_0020d330");
-extern void FUN_L00_0029ff58(void);
+extern void FUN_L00_0029ff58_u(void) __asm__("FUN_L00_0029ff58");
extern void render_vendor_capture_pass_sequence(s32) __asm__("FUN_00239780");
extern void FUN_L00_0029fcd0_c(void *) __asm__("FUN_L00_0029fcd0");
extern void FUN_00233980(s32, s64);
@@ -435,7 +414,7 @@ void FUN_L00_002a02b0(void) {
}
draw_moby_list(p->f1C, 1);
if (p->f40 == 0) {
- FUN_L00_0029ff58();
+ FUN_L00_0029ff58_u();
}
render_vendor_capture_pass_sequence(p->f1C);
if (p->f5C != 0) {
diff --git a/src/overlays/shared/gameplay/entities/blarg_space_commando.c b/src/overlays/shared/gameplay/entities/blarg_space_commando.c
index 944f343990..26ea1df65a 100644
--- a/src/overlays/shared/gameplay/entities/blarg_space_commando.c
+++ b/src/overlays/shared/gameplay/entities/blarg_space_commando.c
@@ -107,7 +107,7 @@ extern void FUN_L00_00261d78(s32, void *, void *, f32);
extern void FUN_L00_00263ac8(struct Moby *, s32, void *, f32);
extern void FUN_L00_00263fd8(struct Moby *, s32, void *, void *, s32, s32, f32, f32 *, f32 *, f32 *);
extern void FUN_L01_0026d930(MoveCtl *);
-extern void FUN_L06_002feb40(struct Moby *);
+extern void FUN_L06_002feb40_u(struct Moby *) __asm__("FUN_L06_002feb40");
extern void FUN_L06_002ff100_u(struct Moby *) __asm__("FUN_L06_002ff100");
void FUN_L06_002fdbd0(struct Moby *moby) {
@@ -125,7 +125,7 @@ void FUN_L06_002fdbd0(struct Moby *moby) {
f32 frame;
f32 cur_frame;
- FUN_L06_002feb40(moby);
+ FUN_L06_002feb40_u(moby);
target = vars->target;
FUN_L00_00263ac8(moby, 1, vars->unk420, 2.5f);
if (moby->visible != 0 && FUN_001f9b48(&moby->pos, &D_L06_00167540) < 27.0f) {
@@ -408,84 +408,83 @@ void FUN_L06_002fdbd0(struct Moby *moby) {
}
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L06_002feb40.s", FUN_L06_002feb40);
-#else
-extern f32 D_L06_00161FA8 __attribute__((sda));
-extern f32 D_L06_00161FAC __attribute__((sda));
-extern f32 D_L06_00161FB0 __attribute__((sda));
-extern f32 D_L06_00161FB4 __attribute__((sda));
-extern f32 D_L06_00161FB8 __attribute__((sda));
-extern f32 D_L06_00161FBC __attribute__((sda));
-extern f32 D_0015ED6C __asm__("D_0015ED6C");
-extern s32 D_001413D0[] __asm__("D_001413D0");
-#include "rnc/gameplay/state/item_state.h"
-extern f32 random_float_between(f32, f32) __asm__("FUN_002132a8");
-extern f32 scale_time_for_update(f32) __asm__("FUN_001f96b0");
-extern s32 FUN_002182f0(f32) __asm__("FUN_001fa6d0");
-extern void FUN_00217000(void *) __asm__("FUN_001f9740");
-extern struct Moby *FUN_00269230(struct Moby *, s32, s32) __asm__("FUN_L00_0025a420");
-extern s32 FUN_00269288(struct Moby *, struct Moby *, void *, s32, s32 *, f32 *, s32, s32) __asm__("FUN_00213928");
-extern void FUN_0029ae30(s32, s32, s32) __asm__("FUN_0022db10");
-extern void FUN_00272ad8(s32, s32) __asm__("FUN_L00_00263d40");
-extern void FUN_0026b368(f32, struct Moby *, void *, s32, s32, s32) __asm__("FUN_L00_0025c558");
-extern void FUN_00266130(struct Moby *, s32, s32) __asm__("FUN_L00_00257470");
-extern void FUN_0026c268(struct Moby *, void *) __asm__("FUN_L00_0025d458");
-extern void FUN_0026c348(struct Moby *, void *) __asm__("FUN_L00_0025d538");
-extern s32 FUN_0026eac8(f32, struct Moby *, void *, s32, s32, void *, s32) __asm__("FUN_L00_0025ff38");
-extern f32 FUN_00217528(void *, void *) __asm__("FUN_001f9b80");
-extern f32 FUN_002172b0(f32) __asm__("FUN_001f99c0");
-extern f32 FUN_00266908(f32, f32) __asm__("FUN_L00_00257c48");
-extern f32 FUN_00266970(void) __asm__("FUN_00213308");
-extern void FUN_L06_002ff2c8(char *);
-extern unsigned char *FUN_L06_00300c60(char *, f32 *, f32 *);
-
-void FUN_L06_002feb40(struct Moby *moby) {
- Moby1068Vars *vars = (Moby1068Vars *)moby->pvars;
- struct Moby *other;
- struct Moby *fragment;
- s32 collision;
-
- struct {
- f32 position[4];
- f32 velocity[4];
- s32 hit_type;
- f32 motion[3];
- } scratch;
- f32 angle;
- f32 speed;
- f32 remaining;
- s32 *route;
- s16 frames;
- f32 *vel;
-
- moby->scale = moby->pclass->scale * D_L06_00161FA8;
- FUN_L06_002ff2c8((char *)moby);
- if (*(s32 *)((char *)vars + 0x38) != 0) {
- vars->unk188 = FUN_002182f0(scale_time_for_update(random_float_between(180.0f, 240.0f)));
- *(s32 *)((char *)vars + 0x38) = 0;
+/* Ported from rac1-decomp (src/overlays/shared/vendor_002FF000.c: func_L06_002FFF70), where it is exact; names translated to the US level program. */
+
+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[];
+extern f32 D_0015ED6C;
+extern f32 fast_arc_tan(f32, f32) __asm__("func_001F9E90");
+extern f32 fast_cos(f32) __asm__("func_001F9DC8");
+extern f32 fast_sin_c2(f32) __asm__("func_001F9DE0");
+extern f32 random_angle_radians_c(void) __asm__("func_00213308");
+extern f32 random_float_between_c(f32, f32) __asm__("func_002132A8");
+extern f32 vector_distance_xy_alt(void *, void *) __asm__("FUN_001f9b80");
+extern float FUN_001f96b0(float);
+extern float FUN_L00_00257c48(float lo, float hi);
+extern int FUN_L00_0025ff38(float, char *, void *, int, int, void *, int);
+extern int fun_00213928(void *, void *, void *, int, int *, float *, int, int);
+extern int *D_L06_001B0C30[];
+extern s32 scale_game_frames_c(s32) __asm__("func_001F96F8");
+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 unsigned char D_0013D408[];
+extern void FUN_L00_00257470(void *, int, int);
+extern void FUN_L00_0025c558(void *, void *, float, int, int, int);
+extern void FUN_L00_0025d458(void *m, short *p);
+extern void FUN_L00_0025d538(void *, void *);
+extern void FUN_L00_00263d40(int, int);
+extern void FUN_L06_002ff2c8(void *);
+extern void allocate_voice_for_bank_entry(int, int, int) __asm__("FUN_0022db10");
+float absolute_float(float input) __asm__("func_001F99C0");
+
+void FUN_L06_002feb40(char *m) {
+ extern unsigned char D_0013D408[];
+ char *d;
+ char *t;
+ char *p;
+ int *e;
+ int r;
+ int k;
+ int bits;
+ float vv[4];
+ float vec2[4];
+ int hit;
+ float dt;
+ float f;
+ float lo, hi, spd, off, pull;
+
+ d = *(char **)(m + 0x78);
+ *(float *)(m + 0x2C) = *(float *)(*(char **)(m + 0x24) + 0x24) * D_L06_00161FA8;
+ FUN_L06_002ff2c8(m);
+ if (*(int *)(d + 0x38) != 0) {
+ *(int *)(d + 0x188) = truncate_float_to_s32_c(FUN_001f96b0(random_float_between_c(180.0f, 240.0f)));
+ *(int *)(d + 0x38) = 0;
}
- FUN_00217000(&vars->unk188);
- scratch.motion[0] = 0.0f;
- other = (struct Moby *)FUN_00269230(moby, 0x330000, 0);
- collision = FUN_00269288(moby, other, &vars->unk20, 0, &scratch.hit_type, scratch.motion, 0, 4);
- if (scratch.hit_type != 1 && moby->state != 16) {
- if (current_level_index == 10 && other != 0 && *(struct Moby **)((char *)other + 0x20) != 0 &&
- (*(struct Moby **)((char *)other + 0x20))->oclass == 0x31a && item_unlocked[0x11] == 0) {
- item_unlocked[0x11] = 1;
- FUN_0029ae30(1, 0, 0);
- FUN_00272ad8(0x53d6, -1);
- }
- remaining = vars->unk20 - scratch.motion[0];
- vars->unk20 = remaining;
- if (remaining <= 0.0f) {
- collision = 1;
+ tick_countdown_32_alt((s32 *)(d + 0x188));
+ *(int *)&dt = 0;
+ t = FUN_L00_0025a420(m, 0x330000, 0);
+ r = fun_00213928(m, t, d + 0x20, 0, &hit, &dt, 0, 4);
+ if (hit != 1 && (unsigned char)m[0x20] != 0x10) {
+ if (current_level_index_gp == 0xA && t != 0 && *(char **)(t + 0x20) != 0 &&
+ *(short *)(*(char **)(t + 0x20) + 0xA6) == 0x31A && D_0013D408[0x11] == 0) {
+ D_0013D408[0x11] = 1;
+ allocate_voice_for_bank_entry(1, 0, 0);
+ FUN_L00_00263d40(0x53D6, -1);
}
- *(s32 *)((char *)vars + 0x80) = 500;
- *(f32 *)((char *)vars + 0x88) = 0.5f;
- switch (collision) {
- case 0:
- break;
+ f = *(float *)(d + 0x20) - dt;
+ *(float *)(d + 0x20) = f;
+ if (f <= 0.0f) r = 1;
+ *(int *)(d + 0x80) = 0x1F4;
+ *(float *)(d + 0x88) = 0.5f;
+ switch (r) {
case 3:
case 4:
case 5:
@@ -494,89 +493,101 @@ void FUN_L06_002feb40(struct Moby *moby) {
case 8:
case 9:
case 10:
- {
- f32 speed;
- f32 remaining;
- moby->state = 15;
- vel = vars->vel.f;
- frames = scale_game_frames(60);
- speed = D_L06_00161FB0 * D_0015ED6C;
- remaining = D_L06_00161FB4 * D_0015ED6C;
- *(s16 *)((char *)vars + 0x26) = frames;
- *(f32 *)((char *)vars + 0x78) = speed;
- *(f32 *)((char *)vars + 0x7c) = remaining;
- *(f32 *)((char *)vars + 0xb0) = 8.0f;
- *(f32 *)((char *)vars + 0xb4) = 15.0f;
- }
- angle = FUN_001f9e90(other->pos.x, other->pos.y);
- FUN_0026b368(angle, moby, vel, 7, 1, 0);
- *(u8 *)((char *)vars + 0x117) = 0xfa;
+ {
+ char *q;
+ int n;
+ float b, a;
+ 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;
+ *(short *)(d + 0x26) = n;
+ *(float *)(d + 0x7C) = b;
+ *(float *)(d + 0x78) = a;
+ *(float *)(d + 0xB0) = 8.0f;
+ *(float *)(d + 0xB4) = 15.0f;
+ FUN_L00_0025c558(m, q, fast_arc_tan(*(float *)(t + 0x10), *(float *)(t + 0x14)), 7, 1, 0);
+ *(unsigned char *)(d + 0x117) = 0xFA;
break;
+ }
case 1:
case 2:
- {
- f32 speed;
- moby->state = 16;
- vel = vars->vel.f;
- speed = D_L06_00161FB8 * D_0015ED6C;
- remaining = D_L06_00161FBC * D_0015ED6C;
- moby->flags &= ~0x1000;
- *(f32 *)((char *)vars + 0xb0) = 9.0f;
- *(f32 *)((char *)vars + 0xb4) = 18.0f;
- *(f32 *)((char *)vars + 0x7c) = remaining;
- *(f32 *)((char *)vars + 0x78) = speed;
- }
- angle = FUN_001f9e90(other->pos.x, other->pos.y);
- FUN_0026b368(angle, moby, vel, 9, 1, 0);
- vel = scratch.velocity;
- for (collision = 9; collision >= 0; collision--) {
- qcopy(scratch.position, &moby->pos);
- scratch.position[2] += 2.5f;
- scratch.position[0] += FUN_00266908(0.0f, 0.2f);
- scratch.position[1] += FUN_00266908(0.0f, 0.2f);
- scratch.position[2] += FUN_00266908(0.0f, 0.2f);
- angle = FUN_00266970();
- speed = random_float_between(3.0f, 5.7f) * D_0015ED6C;
- vel[0] = FUN_001f9dc8(angle) * speed;
- vel[1] = FUN_001f9de0(angle) * speed;
- vel[2] = 0.0f;
- angle = FUN_001f9e90(other->pos.x, other->pos.y);
- vel[0] += FUN_001f9dc8(angle) * (D_0015ED6C * 7.0f);
- angle = FUN_001f9e90(other->pos.x, other->pos.y);
- vel[1] += FUN_001f9de0(angle) * (D_0015ED6C * 7.0f);
- vel[2] = random_float_between(3.0f, 8.5f) * D_0015ED6C;
- fragment = (struct Moby *)FUN_L06_00300c60((char *)moby, scratch.position, vel);
- if (fragment != 0) {
- fragment->scale *= 0.4f;
+ {
+ char *q;
+ float a, b;
+ m[0x20] = 0x10;
+ q = d + 0x60;
+ a = *(float *)&D_L06_00161FB8 * D_0015ED6C;
+ b = *(float *)&D_L06_00161FBC * D_0015ED6C;
+ *(unsigned short *)(m + 0x34) &= 0xEFFF;
+ *(float *)(d + 0x78) = a;
+ *(float *)(d + 0x7C) = b;
+ *(float *)(d + 0xB0) = 9.0f;
+ *(float *)(d + 0xB4) = 18.0f;
+ bits = 0;
+ lo = *(float *)&bits;
+ bits = 0x3E4CCCCD;
+ hi = *(float *)&bits;
+ a = fast_arc_tan(*(float *)(t + 0x10), *(float *)(t + 0x14));
+ bits = 0x40400000;
+ off = *(float *)&bits;
+ FUN_L00_0025c558(m, q, a, 9, 1, 0);
+ bits = 0x40E00000;
+ pull = *(float *)&bits;
+ for (k = 0; k < 10; k++) {
+ float ang;
+ qcopy(vv, m + 0x10);
+ vv[2] = vv[2] + 2.5f;
+ vv[0] = vv[0] + FUN_L00_00257c48(lo, hi);
+ vv[1] = vv[1] + FUN_L00_00257c48(lo, hi);
+ vv[2] = vv[2] + FUN_L00_00257c48(lo, hi);
+ ang = random_angle_radians_c();
+ spd = random_float_between_c(off, 5.7f) * D_0015ED6C;
+ vec2[0] = fast_cos(ang) * spd;
+ vec2[1] = fast_sin_c2(ang) * spd;
+ vec2[2] = lo;
+ vec2[0] = vec2[0] + fast_cos(fast_arc_tan(*(float *)(t + 0x10), *(float *)(t + 0x14))) * (D_0015ED6C * pull);
+ vec2[1] = vec2[1] + fast_sin_c2(fast_arc_tan(*(float *)(t + 0x10), *(float *)(t + 0x14))) * (D_0015ED6C * pull);
+ vec2[2] = random_float_between_c(off, 8.5f) * D_0015ED6C;
+ p = FUN_L06_00300c60_c((int)m, (char *)vv, (char *)vec2);
+ if (p != 0) {
+ *(float *)(p + 0x2C) = *(float *)(p + 0x2C) * 0.4f;
}
}
- *(u8 *)((char *)vars + 0x117) = 0xfa;
- FUN_00266130(moby, 0, -1);
+ *(unsigned char *)(d + 0x117) = 0xFA;
+ FUN_L00_00257470(m, 0, -1);
break;
+ }
+ case 0:
case 11:
+ default:
break;
}
- FUN_0026c268(moby, (char *)vars + 0x110);
+ FUN_L00_0025d458(m, (short *)(d + 0x110));
}
- moby->hit_slot = 0xff;
- FUN_0026c348(moby, (char *)vars + 0x110);
- if (vars->unk188 != 0) {
- *(f32 *)((char *)vars + 0x198) = D_L06_00161FAC + 6.0f;
+ *(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;
} else {
- *(f32 *)((char *)vars + 0x198) = D_L06_00161FAC;
+ *(float *)(d + 0x198) = *(float *)&D_L06_00161FAC;
}
- route = D_L06_001B0C30[*(s32 *)((char *)vars + 0x180)];
- if (FUN_0026eac8(*(f32 *)((char *)vars + 0x198), moby, (char *)vars + 0x120, 0, 0, route + 4, *route) != 2) {
- if (FUN_00217528(&vars->home, (char *)vars + 0x120) > *(f32 *)((char *)vars + 0x198) ||
- FUN_002172b0(moby->pos.z - *(f32 *)((char *)vars + 0x128)) > 3.0f) {
- vars->unk164 = 2;
+ {
+ char *q = d + 0x120;
+ e = D_L06_001B0C30[*(int *)(d + 0x180)];
+ if (FUN_L00_0025ff38(*(float *)(d + 0x198), m, q, 0, 0, e + 4, *e) != 2) {
+ if (*(float *)(d + 0x198) < vector_distance_xy_alt(d + 0x170, d + 0x120)) {
+ *(int *)(d + 0x164) = 2;
+ } else if (3.0f < absolute_float(*(float *)(m + 0x18) - *(float *)(d + 0x128))) {
+ *(int *)(d + 0x164) = 2;
}
}
- if (vars->target == 0) {
- vars->target = (struct Moby *)D_001413D0[0];
+ }
+ if (*(int *)(d + 0x160) == 0) {
+ *(int *)(d + 0x160) = *(int *)(D_001413D0);
}
}
-#endif
/* Ported from rac1-decomp (src/overlays/shared/vendor_002FF000.c: func_L06_00300530), where it is exact; names translated to the US level program. */
extern char D_L06_00174600_d[] __asm__("D_L06_00174600") __attribute__((section(".data")));
diff --git a/src/overlays/shared/gameplay/entities/bomb.c b/src/overlays/shared/gameplay/entities/bomb.c
index 60e87d5d88..a1d6c431c2 100644
--- a/src/overlays/shared/gameplay/entities/bomb.c
+++ b/src/overlays/shared/gameplay/entities/bomb.c
@@ -25,9 +25,9 @@ typedef struct {
} ThrowVars_2c8440;
extern s32 D_L00_0015F5C4_2c8440 __asm__("D_L00_0015F5C4"); /* nonzero: no throws */
-extern f32 D_0015ED6C_2c8440 __asm__("D_0015ED6C") __attribute__((section(".sdata"))); /* frame-rate scale */
-extern f32 D_0015ED70_2c8440 __asm__("D_0015ED70") __attribute__((section(".sdata")));
-extern CollisionHit coll_hit_2c8440 __asm__("D_L00_00173E40") __attribute__((section(".data")));
+extern float D_0015ED6C __attribute__((section(".sdata"))); /* frame-rate scale */
+extern float D_0015ED70 __attribute__((section(".sdata")));
+extern CollisionHit coll_hit __asm__("D_L00_00173E40") __attribute__((section(".data")));
/* coll_hit_2c8440's normal as a whole quadword (CollisionHit names only x/y/z) */
extern Vec4 coll_hit_normal_2c8440 __asm__("D_L00_00173E80") __attribute__((section(".data")));
extern Vec4 D_L00_00166DC0_2c8440 __asm__("D_L00_00166DC0") __attribute__((section(".data")));
@@ -92,22 +92,22 @@ s32 FUN_L00_002c8440(ThrowVars_2c8440 *v, struct Moby *m, s32 mode)
v->unk46 = 1;
}
}
- e.f[2] -= D_0015ED6C_2c8440 * 0.5f;
+ e.f[2] -= D_0015ED6C * 0.5f;
q.q = ((Vec4 *)&hero.moby->pos)->q;
q.f[2] = d.f[2];
if (collision_line_2c8440(&q, &d, 0x10, hero.moby, 0) && (FUN_001f0b58_2c8440() || 0.0f < e.f[2])) {
- if (coll_hit_2c8440.moby != 0 && coll_hit_2c8440.unk1C <= 0) {
- if (((struct Moby *)coll_hit_2c8440.moby != hero.moby && (struct Moby *)coll_hit_2c8440.moby != v->holder)
+ if (coll_hit.moby != 0 && coll_hit.unk1C <= 0) {
+ if (((struct Moby *)coll_hit.moby != hero.moby && (struct Moby *)coll_hit.moby != v->holder)
|| t < scale_game_frames_2c8440(300) - scale_game_frames_2c8440(10)) {
w.q = 0;
w.f[2] = 0.5f;
- qcopy(&v->landing, &((struct Moby *)coll_hit_2c8440.moby)->pos);
+ qcopy(&v->landing, &((struct Moby *)coll_hit.moby)->pos);
found = 1;
add_vector_xyz_2c8440(&w, &w, &v->landing);
FUN_00213508_2c8440(&w, 0, 0.5f);
}
- } else if (coll_hit_2c8440.unk1C > 0) {
- qcopy(&v->landing, &coll_hit_2c8440.point);
+ } else if (coll_hit.unk1C > 0) {
+ qcopy(&v->landing, &coll_hit.point);
found = 1;
}
}
@@ -115,36 +115,36 @@ s32 FUN_L00_002c8440(ThrowVars_2c8440 *v, struct Moby *m, s32 mode)
qcopy(&a, &d);
for (i = 9; i >= 0; i--) {
add_vector_xyz_2c8440(&d, &d, &e);
- e.f[2] -= D_0015ED70_2c8440 * 9.0f;
+ e.f[2] -= D_0015ED70 * 9.0f;
}
if (!collision_line_2c8440(&a, &d, 0x10, m, 0))
continue;
if (!FUN_001f0b58_2c8440() && 0.0f < e.f[2])
continue;
- if (coll_hit_2c8440.moby != 0 && coll_hit_2c8440.unk1C <= 0) {
- if (((struct Moby *)coll_hit_2c8440.moby == hero.moby || (struct Moby *)coll_hit_2c8440.moby == v->holder)
+ if (coll_hit.moby != 0 && coll_hit.unk1C <= 0) {
+ if (((struct Moby *)coll_hit.moby == hero.moby || (struct Moby *)coll_hit.moby == v->holder)
&& !(t < scale_game_frames_2c8440(300) - scale_game_frames_2c8440(10)))
continue;
w.q = 0;
w.f[2] = 0.5f;
- qcopy(&v->landing, &((struct Moby *)coll_hit_2c8440.moby)->pos);
+ qcopy(&v->landing, &((struct Moby *)coll_hit.moby)->pos);
add_vector_xyz_2c8440(&w, &w, &v->landing);
FUN_00213508_2c8440(&w, 0, 0.5f);
break;
- } else if (coll_hit_2c8440.unk1C > 0) {
- qcopy(&v->landing, &coll_hit_2c8440.point);
+ } else if (coll_hit.unk1C > 0) {
+ qcopy(&v->landing, &coll_hit.point);
break;
}
}
if (t == 0)
return 0;
if (mode == 0) {
- if (coll_hit_2c8440.moby == 0)
+ if (coll_hit.moby == 0)
return 0;
- if (FUN_L00_002603d0_2c8440(coll_hit_2c8440.moby) == 0)
+ if (FUN_L00_002603d0_2c8440(coll_hit.moby) == 0)
goto ret0;
}
- if (mode != 2 || coll_hit_2c8440.moby == 0 || !FUN_L00_002603d0_2c8440(coll_hit_2c8440.moby))
+ if (mode != 2 || coll_hit.moby == 0 || !FUN_L00_002603d0_2c8440(coll_hit.moby))
FUN_001f4600_2c8440(FUN_L00_002c7df8_2c8440, m);
v->normal.q = coll_hit_normal_2c8440.q;
subtract_vector_xyz_2c8440(&a, &v->landing, &D_L00_00166DC0_2c8440);
@@ -234,7 +234,7 @@ void FUN_L00_002c89e8(struct Moby *m)
*(s32 *)v->pad_34 = scale_game_frames_2c8440(4);
FUN_L00_0026ed28(m);
}
- v->vel.f[2] -= D_0015ED70_2c8440 * 9.0f;
+ v->vel.f[2] -= D_0015ED70 * 9.0f;
add_vector_xyz_2c8440(&d, &m->pos, v);
FUN_L00_001ff290_2c89e8(&q, &m->pos, &hero.motion.platform_carry);
qcopy_nc(&e, &m->pos);
@@ -246,7 +246,7 @@ void FUN_L00_002c89e8(struct Moby *m)
qcopy_nc(&q, &d);
q.f[2] += f * 0.2f;
if (FUN_001f0d60_2c89e8(f * 0.3f, &q, 4, hero.moby)) {
- collision_point = (u8 *)&coll_hit_2c8440 + 0x30;
+ collision_point = (u8 *)&coll_hit + 0x30;
qcopy_nc(&m->pos, collision_point);
m->pos.z -= f * 0.2f;
collision_point += 0x10;
@@ -255,7 +255,7 @@ void FUN_L00_002c89e8(struct Moby *m)
if (!collision_line_2c8440(&e, &a, 0, hero.moby, 0)) {
goto collision_miss;
}
- collision_point = (u8 *)&coll_hit_2c8440 + 0x20;
+ collision_point = (u8 *)&coll_hit + 0x20;
qcopy_nc(&m->pos, collision_point);
m->pos.z += (frame_scale * 0.15f * m->scale) / m->pclass->scale;
collision_point += 0x20;
@@ -273,7 +273,7 @@ void FUN_L00_002c89e8(struct Moby *m)
settle:
timer = (u16)v->timer + 1;
v->timer = timer;
- if (!coll_hit_2c8440.moby || coll_hit_2c8440.unk1C > 0 ||
+ if (!coll_hit.moby || coll_hit.unk1C > 0 ||
(timer = (s16)timer, scale_game_frames_2c8440(240) < timer)) {
m->state = 3;
v->timer = 0;
@@ -293,8 +293,8 @@ void FUN_L00_002c89e8(struct Moby *m)
case 3: {
f32 f;
f = probe_ground_height(&m->pos, 0, 0.5f);
- if (f != 0.0f && coll_hit_2c8440.moby)
- FUN_L00_00260400(m, coll_hit_2c8440.moby, &m->pos, &m->rot, &m->pos, &m->rot);
+ if (f != 0.0f && coll_hit.moby)
+ FUN_L00_00260400(m, coll_hit.moby, &m->pos, &m->rot, &m->pos, &m->rot);
if (tick_timer_2cb418(&v->timer)) {
count = 0;
for (p = (struct Moby *)D_L00_0015FFE4; p; p = p->next)
@@ -331,8 +331,8 @@ void FUN_L00_002c89e8(struct Moby *m)
m->alpha -= 4;
m->scale *= 0.92f;
f = probe_ground_height(&m->pos, 0, 0.5f);
- if (f != 0.0f && coll_hit_2c8440.moby)
- FUN_L00_00260400(m, coll_hit_2c8440.moby, &m->pos, &m->rot, &m->pos, &m->rot);
+ if (f != 0.0f && coll_hit.moby)
+ FUN_L00_00260400(m, coll_hit.moby, &m->pos, &m->rot, &m->pos, &m->rot);
if (m->alpha) return;
remove:
mark_moby_for_removal(m);
@@ -674,7 +674,7 @@ void FUN_L00_002c97e0(struct Moby *m)
build_spherical_offset_2c97e0(&offset, f, g, FUN_L00_00257cb0_2c97e0());
offset.f[2] += random_float_between(0.25f, 0.5f) * scale;
add_vector_xyz_2c8440(&offset, &offset, &old_pos);
- f = random_float_between(D_0015ED6C_2c8440 * 0.1f, D_0015ED6C_2c8440) * scale;
+ f = random_float_between(D_0015ED6C * 0.1f, D_0015ED6C) * scale;
g = FUN_L00_00257cb0_2c97e0(); h = FUN_L00_00257cb0_2c97e0();
build_spherical_offset_2c97e0(&velocity, f, g, h);
{
@@ -710,11 +710,11 @@ void FUN_L00_002c97e0(struct Moby *m)
add_vector_xyz_2c8440(&offset, &offset, &old_pos);
{
f32 f;
- f = random_float_between(D_L00_0016185C_2c97e0 * D_0015ED6C_2c8440, D_L00_00161860_2c97e0 * D_0015ED6C_2c8440);
+ f = random_float_between(D_L00_0016185C_2c97e0 * D_0015ED6C, D_L00_00161860_2c97e0 * D_0015ED6C);
g = FUN_L00_00257cb0_2c97e0();
build_spherical_offset_2c97e0(&velocity, f, g, D_L00_00161858_2c97e0 * rotation);
}
- velocity.f[2] = random_float_between(3.5f, 5.5f) * D_0015ED6C_2c8440;
+ velocity.f[2] = random_float_between(3.5f, 5.5f) * D_0015ED6C;
FUN_L00_002cbf68_2c97e0(m, &offset, &velocity);
}
}
@@ -733,7 +733,7 @@ void FUN_L00_002c97e0(struct Moby *m)
s2->unk64 = FUN_L00_00257b90(a, b);
}
if (s2->unk70 < 0) speed = 0.333f;
- else speed = (D_0015ED6C_2c8440 + D_0015ED6C_2c8440) * scale;
+ else speed = (D_0015ED6C + D_0015ED6C) * scale;
switch (m->state) {
case 1:
if (m->anim_flags & 2) {
@@ -742,8 +742,8 @@ void FUN_L00_002c97e0(struct Moby *m)
FUN_L00_00257880_2c97e0(m, a, 0, b);
}
if (tick_timer_2cb418(&s2->unk66) && distance_xy_2c97e0(&m->pos, &hero.motion.pos) < scale * 5.0f) {
- next_pos.f[0] = fast_cos(m->rot.z) * D_0015ED6C_2c8440 * scale;
- next_pos.f[1] = fast_sin(m->rot.z) * D_0015ED6C_2c8440 * scale;
+ next_pos.f[0] = fast_cos(m->rot.z) * D_0015ED6C * scale;
+ next_pos.f[1] = fast_sin(m->rot.z) * D_0015ED6C * scale;
next_pos.f[2] = 0.0f;
add_vector_xyz_2c8440(&next_pos, &next_pos, &old_pos);
result = FUN_L00_00258490_2c97e0(m, &old_pos, &next_pos, 0, scale * 0.2f, scale * 0.5f, speed, 0.2617994f);
@@ -763,16 +763,16 @@ void FUN_L00_002c97e0(struct Moby *m)
break;
case 2:
rotation = 0.5f;
- FUN_L00_00258278_2c97e0(m, (u8 *)s2 + 0x68, angle, D_0015ED70_2c8440 * 0.7853982f, D_0015ED70_2c8440 * 1.5707964f, D_0015ED6C_2c8440 * 0.7853982f);
+ FUN_L00_00258278_2c97e0(m, (u8 *)s2 + 0x68, angle, D_0015ED70 * 0.7853982f, D_0015ED70 * 1.5707964f, D_0015ED6C * 0.7853982f);
FUN_L00_00258490_2c97e0(m, &old_pos, &old_pos, 0, scale * 0.2f, scale * rotation, speed, 0.2617994f);
if (tick_timer_2cb418(&s2->unk66) && distance_xy_2c97e0(&m->pos, &hero.motion.pos) < scale * 5.0f) {
- next_pos.f[0] = fast_cos(m->rot.z) * D_0015ED6C_2c8440 * scale;
- next_pos.f[1] = fast_sin(m->rot.z) * D_0015ED6C_2c8440 * scale;
+ next_pos.f[0] = fast_cos(m->rot.z) * D_0015ED6C * scale;
+ next_pos.f[1] = fast_sin(m->rot.z) * D_0015ED6C * scale;
next_pos.f[2] = 0.0f;
add_vector_xyz_2c8440(&next_pos, &next_pos, &old_pos);
f = probe_ground_height(&next_pos, 0, rotation);
f = fabs_2c97e0(f - next_pos.f[2]);
- if (f <= (D_0015ED6C_2c8440 + D_0015ED6C_2c8440) * scale) {
+ if (f <= (D_0015ED6C + D_0015ED6C) * scale) {
m->state = 3; a = scale_game_frames(10); FUN_L00_00257880_2c97e0(m, 3, 0, a); break;
}
break;
@@ -790,16 +790,16 @@ void FUN_L00_002c97e0(struct Moby *m)
goto idle_move;
}
if (!(distance_xy_2c97e0(&m->pos, &hero.motion.pos) < scale * 3.0f)) {
- FUN_L00_00258278_2c97e0(m, (u8 *)s2 + 0x68, angle, D_0015ED70_2c8440 * 0.7853982f, D_0015ED70_2c8440 * 1.5707964f, D_0015ED6C_2c8440 * 0.7853982f);
+ FUN_L00_00258278_2c97e0(m, (u8 *)s2 + 0x68, angle, D_0015ED70 * 0.7853982f, D_0015ED70 * 1.5707964f, D_0015ED6C * 0.7853982f);
rotation = 1.5707964f;
- next_pos.f[0] = fast_cos(m->rot.z) * D_0015ED6C_2c8440 * scale;
- next_pos.f[1] = fast_sin(m->rot.z) * D_0015ED6C_2c8440;
+ next_pos.f[0] = fast_cos(m->rot.z) * D_0015ED6C * scale;
+ next_pos.f[1] = fast_sin(m->rot.z) * D_0015ED6C;
goto move_scaled;
}
- FUN_L00_00258278_2c97e0(m, (u8 *)s2 + 0x68, angle, D_0015ED70_2c8440 * 0.7853982f, D_0015ED70_2c8440 * 1.5707964f, D_0015ED6C_2c8440 * 0.7853982f);
+ FUN_L00_00258278_2c97e0(m, (u8 *)s2 + 0x68, angle, D_0015ED70 * 0.7853982f, D_0015ED70 * 1.5707964f, D_0015ED6C * 0.7853982f);
rotation = 1.5707964f;
- next_pos.f[0] = fast_cos(m->rot.z) * (D_0015ED6C_2c8440 + D_0015ED6C_2c8440);
- next_pos.f[1] = fast_sin(m->rot.z) * (D_0015ED6C_2c8440 + D_0015ED6C_2c8440);
+ next_pos.f[0] = fast_cos(m->rot.z) * (D_0015ED6C + D_0015ED6C);
+ next_pos.f[1] = fast_sin(m->rot.z) * (D_0015ED6C + D_0015ED6C);
next_pos.f[2] = 0.0f;
add_vector_xyz_2c8440(&next_pos, &next_pos, &old_pos);
result = FUN_L00_00258490_2c97e0(m, &old_pos, &next_pos, 0, scale * 0.2f, scale * 0.5f, speed, 0.2617994f);
@@ -812,10 +812,10 @@ void FUN_L00_002c97e0(struct Moby *m)
case 4:
result = tick_timer_2cb418(&s2->unk66);
if (result && scale * 4.0f < distance_xy_2c97e0(&m->pos, &hero.motion.pos)) {
- FUN_L00_00258278_2c97e0(m, (u8 *)s2 + 0x68, angle, D_0015ED70_2c8440 * 0.7853982f, D_0015ED70_2c8440 * 1.5707964f, D_0015ED6C_2c8440 * 0.7853982f);
+ FUN_L00_00258278_2c97e0(m, (u8 *)s2 + 0x68, angle, D_0015ED70 * 0.7853982f, D_0015ED70 * 1.5707964f, D_0015ED6C * 0.7853982f);
rotation = 1.5707964f;
- next_pos.f[0] = fast_cos(m->rot.z) * D_0015ED6C_2c8440 * scale;
- next_pos.f[1] = fast_sin(m->rot.z) * D_0015ED6C_2c8440 * scale;
+ next_pos.f[0] = fast_cos(m->rot.z) * D_0015ED6C * scale;
+ next_pos.f[1] = fast_sin(m->rot.z) * D_0015ED6C * scale;
next_pos.f[2] = 0.0f;
add_vector_xyz_2c8440(&next_pos, &next_pos, &old_pos);
result = FUN_L00_00258490_2c97e0(m, &old_pos, &next_pos, 0, scale * 0.2f, scale * 0.5f, speed, 0.2617994f);
@@ -826,10 +826,10 @@ void FUN_L00_002c97e0(struct Moby *m)
}
m->state = 3; a = scale_game_frames(10); FUN_L00_00257880_2c97e0(m, 3, 0, a); break;
}
- FUN_L00_00258278_2c97e0(m, (u8 *)s2 + 0x68, angle, D_0015ED70_2c8440 * 0.7853982f, D_0015ED70_2c8440 * 1.5707964f, D_0015ED6C_2c8440 * 0.7853982f);
+ FUN_L00_00258278_2c97e0(m, (u8 *)s2 + 0x68, angle, D_0015ED70 * 0.7853982f, D_0015ED70 * 1.5707964f, D_0015ED6C * 0.7853982f);
rotation = 1.5707964f;
- next_pos.f[0] = fast_cos(m->rot.z) * (D_0015ED6C_2c8440 + D_0015ED6C_2c8440) * scale;
- next_pos.f[1] = fast_sin(m->rot.z) * (D_0015ED6C_2c8440 + D_0015ED6C_2c8440);
+ next_pos.f[0] = fast_cos(m->rot.z) * (D_0015ED6C + D_0015ED6C) * scale;
+ next_pos.f[1] = fast_sin(m->rot.z) * (D_0015ED6C + D_0015ED6C);
move_scaled:
next_pos.f[1] *= scale;
next_pos.f[2] = 0.0f;
@@ -865,11 +865,11 @@ void FUN_L00_002c97e0(struct Moby *m)
add_vector_xyz_2c8440(&offset, &offset, &old_pos);
{
f32 f;
- f = random_float_between(D_L00_0016185C_2c97e0 * D_0015ED6C_2c8440, D_L00_00161860_2c97e0 * D_0015ED6C_2c8440);
+ f = random_float_between(D_L00_0016185C_2c97e0 * D_0015ED6C, D_L00_00161860_2c97e0 * D_0015ED6C);
g = FUN_L00_00257cb0_2c97e0();
build_spherical_offset_2c97e0(&velocity, f, g, D_L00_00161858_2c97e0 * 0.017453292f);
}
- velocity.f[2] = random_float_between(3.5f, 5.5f) * D_0015ED6C_2c8440;
+ velocity.f[2] = random_float_between(3.5f, 5.5f) * D_0015ED6C;
FUN_L00_002cbf68_2c97e0(m, &offset, &velocity);
return;
}
@@ -878,16 +878,16 @@ void FUN_L00_002c97e0(struct Moby *m)
if (!result) {
subtract_vector_xyz_2c8440(&velocity, &old_pos, &m->pos);
f = vector_length_xyz_2cb418(&velocity);
- if (D_0015ED6C_2c8440 * scale < f)
- normalize_2c97e0(&velocity, &velocity, D_0015ED6C_2c8440 * scale);
+ if (D_0015ED6C * scale < f)
+ normalize_2c97e0(&velocity, &velocity, D_0015ED6C * scale);
add_vector_xyz_2c8440(&old_pos, &m->pos, &velocity);
f = FUN_L00_00259710_2c97e0(&old_pos);
g = fabs_2c97e0(f - m->pos.z);
- f = D_0015ED70_2c8440;
- if (!(g <= D_0015ED6C_2c8440 * scale)) goto gravity;
+ f = D_0015ED70;
+ if (!(g <= D_0015ED6C * scale)) goto gravity;
}
qcopy(&m->pos, &old_pos);
- f = D_0015ED70_2c8440;
+ f = D_0015ED70;
gravity:
*(f32 *)((u8 *)s2 + 0x6c) += f * 9.8f;
m->pos.z -= *(f32 *)((u8 *)s2 + 0x6c);
@@ -911,9 +911,9 @@ void FUN_L00_002c97e0(struct Moby *m)
g = -atan2_f_2c8440(square_root(offset.f[0] * offset.f[0] + offset.f[2] * offset.f[2]), offset.f[1]);
angle = atan2_f_2c8440(offset.f[2], offset.f[0]);
g = rotation_delta_2c97e0(g, m->rot.x);
- m->rot.x = fast_add_rotations_2c8440(m->rot.x, g * (D_0015ED6C_2c8440 * scale));
+ m->rot.x = fast_add_rotations_2c8440(m->rot.x, g * (D_0015ED6C * scale));
f = rotation_delta_2c97e0(angle, m->rot.y);
- m->rot.y = fast_add_rotations_2c8440(m->rot.y, f * (D_0015ED6C_2c8440 * scale));
+ m->rot.y = fast_add_rotations_2c8440(m->rot.y, f * (D_0015ED6C * scale));
}
}
if (!(m->pos.z < 0.0f)) { m->anim_speed = anim_speed; return; }
@@ -1070,9 +1070,9 @@ struct Moby *FUN_L00_002caf70(struct Moby *source, OvlVec4 *position, struct Mob
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_2c8440 * 40.0f,
+ FUN_00262c50_2caf70(&offset, D_0015ED6C * 40.0f,
*(f32 *)((u8 *)m + 0x48), -*(f32 *)((u8 *)m + 0x44));
- qcopy(&m->pos, &coll_hit_2c8440.point);
+ qcopy(&m->pos, &coll_hit.point);
{
s32 i = 4;
do {
@@ -1085,7 +1085,7 @@ struct Moby *FUN_L00_002caf70(struct Moby *source, OvlVec4 *position, struct Mob
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_2c8440 * 3.0f, D_0015ED6C_2c8440 * 6.0f));
+ 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--;
@@ -1179,14 +1179,14 @@ typedef struct {
} ShotQuery_2cb418;
extern u8 D_0013E520_2cb418[] __asm__("D_0013E520");
-extern char coll_hit_pos_2cb418[] __asm__("D_L00_00173E60"); /* +0x20: hit normal */
+extern unsigned char D_L00_00173E60[]; /* +0x20: hit normal */
extern char D_L00_00166DC0_2cb418[] __asm__("D_L00_00166DC0");
extern char D_L00_00166FF0_2cb418[] __asm__("D_L00_00166FF0");
-extern char D_0013F3D0_2cb418[] __asm__("D_0013F3D0");
+extern char D_0013F3D0[];
extern Moby *D_001403E0_2cb418 __asm__("D_001403E0") __attribute__((section(".data")));
/* D_L00_00161894 again, through the symbol below it: retail's second load stays lui */
-extern f32 D_0015ED70_2cb418 __asm__("D_0015ED70");
-extern f32 D_0015ED6C_2cb418 __asm__("D_0015ED6C");
+extern float D_0015ED70_lui __asm__("D_0015ED70");
+extern float D_0015ED6C_lui __asm__("D_0015ED6C");
extern void FUN_L00_002cbcc0_2cb418(Moby *, s32) __asm__("FUN_L00_002cbcc0");
extern f32 vector_distance_2cb418(void *, void *) __asm__("FUN_001f9b80");
extern s32 random_int_between_2cb418(s32, s32) __asm__("FUN_L00_00257b90");
@@ -1252,13 +1252,13 @@ void FUN_L00_002cb418(Moby *m) {
pitch = -atan2_f_2cb418(vector_distance_2cb418((Vec4A *)&m->pos, vars), vars->target_z - m->pos.z);
}
if (vector_length_xyz_2cb418(vars) < 0.1f) {
- m->rot.z = turn_toward_2cb418(&vars->yaw_rate, m->rot.z, yaw, D_0015ED70_2cb418 * 6.2831855f, D_0015ED70_2cb418 * 3.1415927f, D_0015ED6C_2cb418 * 6.2831855f);
- m->rot.y = turn_toward_2cb418(&vars->pitch_rate, m->rot.y, pitch, D_0015ED70_2cb418 * 6.2831855f, D_0015ED70_2cb418 * 3.1415927f, D_0015ED6C_2cb418 * 6.2831855f);
+ m->rot.z = turn_toward_2cb418(&vars->yaw_rate, m->rot.z, yaw, D_0015ED70_lui * 6.2831855f, D_0015ED70_lui * 3.1415927f, D_0015ED6C_lui * 6.2831855f);
+ m->rot.y = turn_toward_2cb418(&vars->pitch_rate, m->rot.y, pitch, D_0015ED70_lui * 6.2831855f, D_0015ED70_lui * 3.1415927f, D_0015ED6C_lui * 6.2831855f);
} else {
- m->rot.z = turn_toward_2cb418(&vars->yaw_rate, m->rot.z, yaw, D_0015ED70_2cb418 * 6.2831855f, D_0015ED70_2cb418 * 3.1415927f, D_0015ED6C_2cb418 * 4.712389f);
- m->rot.y = turn_toward_2cb418(&vars->pitch_rate, m->rot.y, pitch, D_0015ED70_2cb418 * 6.2831855f, D_0015ED70_2cb418 * 3.1415927f, D_0015ED6C_2cb418 * 4.712389f);
+ m->rot.z = turn_toward_2cb418(&vars->yaw_rate, m->rot.z, yaw, D_0015ED70_lui * 6.2831855f, D_0015ED70_lui * 3.1415927f, D_0015ED6C_lui * 4.712389f);
+ m->rot.y = turn_toward_2cb418(&vars->pitch_rate, m->rot.y, pitch, D_0015ED70_lui * 6.2831855f, D_0015ED70_lui * 3.1415927f, D_0015ED6C_lui * 4.712389f);
}
- build_spherical_offset_2cb418(&step, D_0015ED6C_2cb418 * 40.0f, m->rot.z, -m->rot.y);
+ build_spherical_offset_2cb418(&step, D_0015ED6C_lui * 40.0f, m->rot.z, -m->rot.y);
qcopy(&start, (Vec4A *)&m->pos);
add_vector_xyz_2cb418((Vec4A *)&m->pos, (Vec4A *)&m->pos, &step);
if (m->pos.x < 0.0f || m->pos.y < 0.0f || m->pos.z < 0.0f
@@ -1271,7 +1271,7 @@ void FUN_L00_002cb418(Moby *m) {
query.radius = 0.25f;
query.moby = m;
query.i20 = 1;
- subtract_vector_xyz_2cb418(&query, (Vec4A *)&m->pos, D_0013F3D0_2cb418);
+ subtract_vector_xyz_2cb418(&query, (Vec4A *)&m->pos, D_0013F3D0);
FUN_001f9c48_2cb418(&query, &query, 1.0f);
query.dir.z = 1.0f;
query.b18 = 1;
@@ -1289,17 +1289,17 @@ void FUN_L00_002cb418(Moby *m) {
vars->timer = scale_game_frames_2cb418(3);
}
} else {
- qcopy((Vec4A *)&m->pos, coll_hit_pos_2cb418);
+ qcopy((Vec4A *)&m->pos, ((char *)D_L00_00173E60));
for (i = 0; i < 5; i++) {
*(u128 *)&b = 0;
b.x = random_float_between_2cb418(-1.0f, 1.0f);
b.y = random_float_between_2cb418(-1.0f, 1.0f);
b.z = random_float_between_2cb418(-1.0f, 1.0f);
*(u128 *)&a = *(u128 *)&b;
- reflect_vector_2cb418(&b, &step, coll_hit_pos_2cb418 + 0x20);
+ reflect_vector_2cb418(&b, &step, ((char *)D_L00_00173E60) + 0x20);
normalize_vector_xyz_2cb418(&a, &a, vector_length_xyz_2cb418(&b) * 0.5f);
add_vector_xyz_2cb418(&b, &b, &a);
- normalize_vector_xyz_2cb418(&b, &b, random_float_between_2cb418(D_0015ED6C_2cb418 * 3.0f, D_0015ED6C_2cb418 * 6.0f));
+ normalize_vector_xyz_2cb418(&b, &b, random_float_between_2cb418(D_0015ED6C_lui * 3.0f, D_0015ED6C_lui * 6.0f));
spawn_spark_2cb418((Vec4A *)&m->pos, &b, 0x7F2F4F6F, random_int_between_2cb418(scale_game_frames_2cb418(10), scale_game_frames_2cb418(15)), 30000.0f);
}
if (D_0013E520_2cb418[15] == 0) {
@@ -1324,13 +1324,13 @@ void FUN_L00_002cb418(Moby *m) {
mark_moby_for_removal_2cb418(m);
return;
}
- reflect_vector_2cb418(&a, &step, coll_hit_pos_2cb418 + 0x20);
+ reflect_vector_2cb418(&a, &step, ((char *)D_L00_00173E60) + 0x20);
m->rot.z = atan2_f_2cb418(a.x, a.y);
m->rot.y = -atan2_f_2cb418(vector_length_xy_2cb418(&a), a.z);
vars->yaw_rate = 0.0f;
vars->pitch_rate = 0.0f;
- normalize_vector_xyz_2cb418(&b, coll_hit_pos_2cb418 + 0x20, 0.05f);
- add_vector_xyz_2cb418((Vec4A *)&m->pos, coll_hit_pos_2cb418, &b);
+ normalize_vector_xyz_2cb418(&b, ((char *)D_L00_00173E60) + 0x20, 0.05f);
+ add_vector_xyz_2cb418((Vec4A *)&m->pos, ((char *)D_L00_00173E60), &b);
if (D_001403E0_2cb418 != 0 && D_001403E0_2cb418->oclass == 0xA8
&& D_001403E0_2cb418->state != 0xFE && D_001403E0_2cb418->state != 0xFD) {
play_sound_2cb418(4, 0, D_001403E0_2cb418);
@@ -1372,7 +1372,7 @@ void FUN_L00_002cb418(Moby *m) {
if (len == 0.0f) {
return;
}
- scale_vector_xyz_2cb418(&c, &b, random_float_between_2cb418(D_0015ED6C_2cb418 * 0.5f, D_0015ED6C_2cb418 + D_0015ED6C_2cb418) / len);
+ scale_vector_xyz_2cb418(&c, &b, random_float_between_2cb418(D_0015ED6C_lui * 0.5f, D_0015ED6C_lui + D_0015ED6C_lui) / len);
spawn_spark_2cb418((Vec4A *)&m->pos, &c, 0x7F2F4F6F, random_int_between_2cb418(scale_game_frames_2cb418(10), scale_game_frames_2cb418(15)), 30000.0f);
}
extern void FUN_00267a08_2cbcc0(void *) __asm__("FUN_L00_00267a08");
@@ -1383,8 +1383,8 @@ extern s32 FUN_001fef20_2cbcc0(s32) __asm__("FUN_L00_001fef20");
extern void FUN_001ff500_2cbcc0(void *, void *, f32) __asm__("FUN_L00_001ff500");
extern void *FUN_0026dd20_2cbcc0(void *, void *, u32, s32, f32) __asm__("FUN_L00_0026dd20");
extern u8 *FUN_0026d000_2cbcc0(f32, f32, f32, f32, void *, s32, void *, u32) __asm__("FUN_L00_0026d000");
-extern f32 D_0015ED6C_2cbcc0 __asm__("D_0015ED6C");
-extern f32 D_0015ED60_2cbcc0 __asm__("D_0015ED60");
+extern float D_0015ED6C_lui __asm__("D_0015ED6C");
+extern float D_0015ED60;
void FUN_L00_002cbcc0(u8 *m, s32 enabled)
{
@@ -1416,7 +1416,7 @@ void FUN_L00_002cbcc0(u8 *m, s32 enabled)
vectors[1].f[2] = FUN_L00_00257be8_2cbcc0(-1.0f, 1.0f);
vectors[0].q = vectors[1].q;
FUN_001ff500_2cbcc0(vector, &vectors[0],
- FUN_L00_00257be8_2cbcc0(D_0015ED6C_2cbcc0 * 3.0f, D_0015ED6C_2cbcc0 * 6.0f));
+ FUN_L00_00257be8_2cbcc0(D_0015ED6C_lui * 3.0f, D_0015ED6C_lui * 6.0f));
lifetime = FUN_L00_00257b90_2cbcc0(FUN_001fef20_2cbcc0(10), FUN_001fef20_2cbcc0(15));
FUN_0026dd20_2cbcc0(pos, vector, 0x7f2f4f6f, lifetime, 35000.0f);
}
@@ -1430,7 +1430,7 @@ void FUN_L00_002cbcc0(u8 *m, s32 enabled)
vectors[0].q = 0;
vectors[0].f[2] = 1.0f;
vectors[0].f[3] = 1.0f;
- vectors[0].f[2] = FUN_L00_00257be8_2cbcc0(0.01f, 0.025f) * D_0015ED60_2cbcc0;
+ vectors[0].f[2] = FUN_L00_00257be8_2cbcc0(0.01f, 0.025f) * D_0015ED60;
effect = FUN_0026d000_2cbcc0(0.2f, 1.0f, 1.02f, 140000.0f,
pos, sign, &vectors[0], color);
if (effect != 0) {
@@ -1452,7 +1452,7 @@ void FUN_L00_002cbcc0(u8 *m, s32 enabled)
}
#include "qcopy.h"
#include "rnc/overlay/quad.h"
-extern float D_0015ED6C_2cbf68 __asm__("D_0015ED6C");
+extern float D_0015ED6C_lui __asm__("D_0015ED6C");
extern unsigned char D_0013E535_2cbf68 __asm__("D_0013E535") __attribute__((section(".data")));
unsigned char *FUN_0020c4f8_2cbf68(int) __asm__("FUN_0020c4f8");
float rndf_2cbf68(float, float) __asm__("FUN_002132a8");
@@ -1487,7 +1487,7 @@ unsigned char *FUN_L00_002cbf68(int unused, void *pos, float *vel) {
*(float *)(m + 0x44) = rnd_2cbf68(0.17453292f, 0.5235988f);
*(float *)(m + 0x40) = rndf_2cbf68(0.17453292f, 0.7853982f);
{
- float t = rndf_2cbf68(200.0f, 370.0f) * DEG_TO_RAD * D_0015ED6C_2cbf68;
+ float t = rndf_2cbf68(200.0f, 370.0f) * DEG_TO_RAD * D_0015ED6C_lui;
*(int *)(v + 0x24) = -1;
*(float *)(v + 0x2C) = t;
}
@@ -1496,7 +1496,7 @@ unsigned char *FUN_L00_002cbf68(int unused, void *pos, float *vel) {
*(float *)(m + 0x44) = -*(float *)(m + 0x44);
}
*(float *)(m + 0x48) = rnda_2cbf68();
- *(float *)(v + 0x28) = -(rndf_2cbf68(200.0f, 550.0f) * DEG_TO_RAD * D_0015ED6C_2cbf68);
+ *(float *)(v + 0x28) = -(rndf_2cbf68(200.0f, 550.0f) * DEG_TO_RAD * D_0015ED6C_lui);
*(float *)(v + 0x10) = rnda_2cbf68();
{
float r = rnda_2cbf68();
@@ -1512,13 +1512,13 @@ unsigned char *FUN_L00_002cbf68(int unused, void *pos, float *vel) {
}
if (D_0013E535_2cbf68)
*(float *)(m + 0x2C) *= 2.0f;
- *(float *)(v + 0x20) = rndf_2cbf68(-1.2f, -0.4f) * D_0015ED6C_2cbf68;
+ *(float *)(v + 0x20) = rndf_2cbf68(-1.2f, -0.4f) * D_0015ED6C_lui;
FUN_L00_00250df8_2cbf68(m);
FUN_L00_0025d1b8_2cbf68(m);
}
return m;
}
-extern float D_0015ED70_2cc210 __asm__("D_0015ED70");
+extern float D_0015ED70_lui __asm__("D_0015ED70");
void FUN_001f9a10_2cc210(void *, void *, void *) __asm__("FUN_001f9a10");
float FUN_001fa580_2cc210(float, float) __asm__("FUN_001fa580");
float FUN_001f99c0_2cc210(float) __asm__("FUN_001f99c0");
@@ -1531,7 +1531,7 @@ void FUN_L00_002cc210(unsigned char *m) {
float *v = *(float **)(m + 0x78);
float sc;
FUN_001f9a10_2cc210(m + 0x10, m + 0x10, v);
- v[2] -= D_0015ED70_2cc210 * 15.0f;
+ v[2] -= D_0015ED70_lui * 15.0f;
sc = D_L00_001618A8;
v[0] *= sc;
v[1] *= sc;
@@ -1661,11 +1661,11 @@ typedef struct {
} Ryno_2cc608;
typedef struct { float radius; char pad4[0xC]; float height; } Bounds_2cc608;
-extern char camera_2cc608[] __asm__("D_L00_00166C80");
+extern char D_L00_00166C80[];
extern Vec4 camera_rot_2cc608 __asm__("D_L00_00166DD0");
extern float camera_pos_2cc608[] __asm__("D_L00_00166DC0");
extern int play_frames_2cc608 __asm__("D_0015EEA4") __attribute__((section(".sdata")));
-extern int current_level_index_2cc608 __asm__("D_0015ED84") __attribute__((section(".sdata")));
+extern int D_0015ED84 __attribute__((section(".sdata")));
extern struct UsageStats item_usage_2cc608 __asm__("D_00141680");
extern void matcopy_2cc608(void *, void *) __asm__("FUN_001fa2b8");
extern void transpose_2cc608(void *, void *) __asm__("FUN_001fa2d8");
@@ -1705,7 +1705,7 @@ void FUN_L00_002cc608(struct Moby *m) {
float yaw, pitch;
int i;
- matcopy_2cc608(&cam, camera_2cc608);
+ matcopy_2cc608(&cam, D_L00_00166C80);
transpose_2cc608(&view, &cam);
if ((unsigned int)(m->state - 2) < 2) {
if (timer32_2cc608(&d->lock_timer) || d->target == 0 || d->target->state == 0xFE || d->target->state == 0xFD) {
@@ -1761,7 +1761,7 @@ void FUN_L00_002cc608(struct Moby *m) {
if (s->stat[23].count <= 0xFFFE) s->stat[23].count++;
per = 600;
if (ticks_2cc608(play_frames_2cc608) / per > s->stat[23].unk2) s->stat[23].unk2 = ticks_2cc608(play_frames_2cc608) / 600;
- s->stat[23].level_mask = s->stat[23].level_mask | (1 << current_level_index_2cc608) | 0x80000000;
+ s->stat[23].level_mask = s->stat[23].level_mask | (1 << D_0015ED84) | 0x80000000;
}
hero.items[0].unk1C = 2;
m->state = 4;
@@ -1790,7 +1790,7 @@ void FUN_L00_002cc608(struct Moby *m) {
if (s->stat[23].count <= 0xFFFE) s->stat[23].count++;
per = 600;
if (ticks_2cc608(play_frames_2cc608) / per > s->stat[23].unk2) s->stat[23].unk2 = ticks_2cc608(play_frames_2cc608) / 600;
- s->stat[23].level_mask = s->stat[23].level_mask | (1 << current_level_index_2cc608) | 0x80000000;
+ s->stat[23].level_mask = s->stat[23].level_mask | (1 << D_0015ED84) | 0x80000000;
}
hero.items[0].unk1C = 2;
m->state = 4;
@@ -1874,8 +1874,8 @@ typedef union {
OvlQuad q;
float f[4];
} V_2ccee0;
-extern float D_0015ED60_2ccee0 __asm__("D_0015ED60");
-extern float D_0015ED6C_2ccee0 __asm__("D_0015ED6C");
+extern float D_0015ED60;
+extern float D_0015ED6C_lui __asm__("D_0015ED6C");
extern unsigned char *D_001413D0_2ccee0 __asm__("D_001413D0") __attribute__((section(".data")));
extern unsigned char D_L00_00173E60_2ccee0[] __asm__("D_L00_00173E60")
__attribute__((section(".data")));
@@ -1938,18 +1938,18 @@ unsigned char *FUN_L00_002ccee0(int a, V_2ccee0 *pos, unsigned char *tgt, float
*(int *)(v + 0x44) = 0;
*(float *)(v + 0x48) = FUN_002132a8_2ccee0(-3.1415927f, 3.1415927f);
f = FUN_002132a8_2ccee0(-3.1415927f, 3.1415927f);
- t = D_0015ED60_2ccee0;
+ t = D_0015ED60;
t *= 0.00967f;
*(float *)(v + 0x4C) = f;
f = FUN_002132a8_2ccee0(-t, t);
- t = D_0015ED60_2ccee0;
+ t = D_0015ED60;
t *= 0.02406f;
*(float *)(v + 0x50) = f;
*(float *)(v + 0x54) = FUN_002132a8_2ccee0(-t, t);
FUN_L00_00250df8_2ccee0(m);
FUN_0022da68_2ccee0(1, 0, m);
z.q = 0;
- z.f[2] = D_0015ED6C_2ccee0 * 8.0f;
+ z.f[2] = D_0015ED6C_lui * 8.0f;
p = D_001413D0_2ccee0;
dir.q = z.q;
s.q = ((V_2ccee0 *)(p + 0x10))->q;
@@ -1960,7 +1960,7 @@ unsigned char *FUN_L00_002ccee0(int a, V_2ccee0 *pos, unsigned char *tgt, float
FUN_00214db0_2ccee0(&w, *(float *)(v + 0x30), *(float *)(m + 0x48),
-*(float *)(m + 0x44));
FUN_L00_001ff660_2ccee0(&dir, &w, D_L00_00173E60_2ccee0 + 0x20);
- FUN_001f9bf8_2ccee0(&dir, &dir, D_0015ED6C_2ccee0 + D_0015ED6C_2ccee0);
+ FUN_001f9bf8_2ccee0(&dir, &dir, D_0015ED6C_lui + D_0015ED6C_lui);
FUN_L00_0025e450_2ccee0(m, &dir, 0, 0.0f, 0.0f, 10, 3, 9, 4.0f, 2.0f, 9.0f, 1.0f, 0,
15.0f, 1, 1, -1, 0);
FUN_0020c828_2ccee0(m);
@@ -1969,218 +1969,252 @@ unsigned char *FUN_L00_002ccee0(int a, V_2ccee0 *pos, unsigned char *tgt, float
}
return m;
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L00_002cd1f0.s", FUN_L00_002cd1f0);
-#else
-typedef struct {
- V_2ccee0 position;
- V_2ccee0 offset;
- struct Moby *owner;
- s32 timer;
- struct Moby *target;
- f32 height;
- f32 radius;
- f32 yaw_velocity;
- f32 pitch_velocity;
- u8 pad3c[8];
- f32 strength;
- f32 yaw;
- f32 pitch;
- f32 yaw_step;
- f32 pitch_step;
- s32 target_oclass;
-} Vars_2cd1f0;
-extern void FUN_001ff500_2cd1f0(void *, void *, f32) __asm__("FUN_L00_001ff500");
-extern void FUN_00262c50_2cd1f0(void *, f32, f32, f32) __asm__("FUN_L00_00262c50");
-extern f32 FUN_002000e8_2cd1f0(f32, f32) __asm__("FUN_L00_002000e8");
-extern f32 FUN_001ff430_2cd1f0(void *) __asm__("FUN_L00_001ff430");
-extern f32 FUN_001ff1e0_2cd1f0(f32) __asm__("FUN_L00_001ff1e0");
-extern void FUN_001ff300_2cd1f0(f32, void *, void *) __asm__("FUN_L00_001ff300");
-extern f32 FUN_001ff8b0_2cd1f0(f32, f32) __asm__("FUN_L00_001ff8b0");
-extern f32 FUN_001ff408_2cd1f0(void *) __asm__("FUN_L00_001ff408");
-extern f32 FUN_001ff488_2cd1f0(void *, void *) __asm__("FUN_L00_001ff488");
-extern f32 FUN_001ff3d8_2cd1f0(void *) __asm__("FUN_L00_001ff3d8");
-extern f32 FUN_001ff800_2cd1f0(f32) __asm__("FUN_L00_001ff800");
-extern f32 FUN_001ff7e8_2cd1f0(f32) __asm__("FUN_L00_001ff7e8");
-extern void FUN_001ffa70_2cd1f0(void *, void *) __asm__("FUN_L00_001ffa70");
-extern void FUN_001ff6f8_2cd1f0(void *, void *, void *) __asm__("FUN_L00_001ff6f8");
-extern void FUN_001ff550_2cd1f0(void *, void *, f32) __asm__("FUN_L00_001ff550");
-extern f32 FUN_00257be8_2cd1f0(f32, f32) __asm__("FUN_L00_00257be8");
-extern s32 FUN_00257b90_2cd1f0(s32, s32) __asm__("FUN_L00_00257b90");
-extern void FUN_00269958_2cd1f0(void *, void *, u32, u32, s32, s32, s32, s32) __asm__("FUN_L00_00269958");
-extern f32 FUN_00258110_2cd1f0(f32 *, f32, f32, f32, f32, f32) __asm__("FUN_L00_00258110");
-extern s32 FUN_001fef20_2cd1f0(s32) __asm__("FUN_001f96f8");
-extern s32 FUN_001fef68_2cd1f0(void *) __asm__("FUN_001f9740");
-extern s32 FUN_001160d8_2cd1f0(void) __asm__("FUN_001160d8");
-extern void FUN_001ff660_2cd1f0(void *, void *, void *) __asm__("FUN_L00_001ff660");
-/* EE float and integer argument banks retain their separate retail order. */
-extern void FUN_0025e450_2cd1f0(f32, void *, void *, void *, f32, s32, s32, s32, f32, f32, f32, f32, s32, f32, s32, s32, s32, s32) __asm__("FUN_L00_0025e450");
-extern void FUN_0024eb68_2cd1f0(void *) __asm__("FUN_L00_0024eb68");
-
-void FUN_L00_002cd1f0(struct Moby *m)
-{
- Vars_2cd1f0 *v;
- V_2ccee0 start;
- /* These phases reuse the same stack storage in retail. */
- union { V_2ccee0 direction, bounce; } vector_scratch;
- V_2ccee0 velocity, query;
- union { struct { V_2ccee0 rotation, delta, target, end; } tracking; u8 collision_data[0x30]; } collision_scratch;
- V_2ccee0 matrix[4];
- f32 a, b, c, root, radius, f;
- s32 hit;
-
- if (m == 0 || (v = (Vars_2cd1f0 *)m->pvars) == 0)
- return;
- velocity.q = 0;
- velocity.f[2] = frame_time * 8.0f;
- vector_scratch.direction.q = velocity.q;
- m->scale += (m->pclass->scale - m->scale) * (frame_scale * 0.05f);
- v->radius += (frame_time * 20.0f - v->radius) * (frame_scale * 0.1f) * frame_scale_sq;
-
- if (v->timer < FUN_001fef20_2cd1f0(250) - FUN_001fef20_2cd1f0(5)) {
- struct Moby *t = v->target;
- f32 rate = frame_scale;
- if (t == 0 || (s16)t->oclass != v->target_oclass || t->state == 0xfe || (rate = *(volatile f32 *)&D_0015ED60_2ccee0, t->state == 0xfd)) {
- v->target = 0;
- v->strength += rate * 0.1f;
- if (v->timer < FUN_001fef20_2cd1f0(250) - FUN_001fef20_2cd1f0(100))
- m->rot.y = FUN_002000e8_2cd1f0(m->rot.y, FUN_001ff800_2cd1f0(v->yaw) * (frame_scale * 0.04f));
- m->rot.z = FUN_002000e8_2cd1f0(m->rot.z, FUN_001ff7e8_2cd1f0(v->yaw) * (frame_scale * 0.05f));
+/* Rocket moby update: steers the rocket toward its target, moves it with collision retries, then checks hits and range. */
+/* Ported from rac1-decomp (src/overlays/shared/vendor_002C96D0.c: func_L00_002CE6A0), where it is exact; names translated to the US level program. */
+
+typedef int u128_cd __attribute__((mode(TI)));
+
+typedef struct { float f[4]; } __attribute__((aligned(16))) V4_cd;
+
+typedef struct { float x, y, z, w; char *p; int c; unsigned char b18; unsigned char b19; unsigned short s; float e; int i; } RocketHit;
+
+extern f32 fast_arc_tan_c(f32, f32) __asm__("func_001F9E90");
+extern f32 fast_cos_c(f32) __asm__("func_001F9DC8");
+extern f32 fast_sin_c(f32) __asm__("func_001F9DE0");
+extern f32 fast_vec_length(void *) __asm__("func_001F9AF0");
+extern f32 random_float_between_c(f32, f32) __asm__("func_002132A8");
+extern f32 square_root_scalar(f32) __asm__("func_001F9988");
+extern f32 vector_length_xy(void *) __asm__("FUN_001f9b20");
+extern float D_0015ED60;
+extern float D_0015ED64;
+extern float D_0015ED6C;
+extern float D_0015ED70;
+extern float FUN_L00_001ff430(void *);
+extern float FUN_L00_00258110(float *vel, float cur, float target, float k, float d, float max);
+extern float fast_add_rotations(float, float) __asm__("func_001FA580");
+extern float vector_distance_xy_alt(void *, void *) __asm__("FUN_001f9b80");
+extern Data D_L00_00173E40;
+extern int FUN_001efa68(void *, void *, int, int, int);
+extern int FUN_L00_00257b90_c(int, int) __asm__("FUN_L00_00257b90");
+extern int tick_countdown_32_alt(int *) __asm__("FUN_001f9740");
+extern s32 rand(void);
+extern s32 scale_game_frames_c(s32) __asm__("func_001F96F8");
+extern void FUN_L00_001ff660(void *, void *, void *);
+extern void FUN_L00_00269958(void *, void *, int, int, int, int, int, int);
+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 euler_rotation_matrix(float *, float *) __asm__("FUN_001fa050");
+extern void fast_vec_normalize(void *, void *, f32) __asm__("FUN_001f9bf8");
+extern void fast_vec_scale(void *, void *, f32) __asm__("func_001F9A68");
+extern void mark_moby_for_removal_c(void *) __asm__("func_0020C828");
+extern void set_vector_length_xy(void *, void *, f32) __asm__("FUN_001f9c48");
+extern void subtract_vector_xyz(void *, void *, void *) __asm__("FUN_001f9a28");
+extern void transform_vector(void *, void *, void *) __asm__("func_001F9D20");
+void FUN_L00_0025e450(char *m, void *unused, char *pos, float fA, float fB, int n, int k8, int k9, float fC, float fD, float fE, float fF, int k10, float fG, int k11, int s16, int s18, unsigned char flag);
+extern void func_L00_0025F4A8_alt(void *, void *, void *, float, float, int, int, int, float, float, float, float, int, float, int, int, int, int) __asm__("FUN_L00_0025e450");
+
+void FUN_L00_002cd1f0(char *m) {
+ char *d;
+ char *q;
+ char *p;
+ char *gg;
+ V4_cd v20;
+ V4_cd dir;
+ V4_cd z;
+ V4_cd v50;
+ union { struct { V4_cd a; V4_cd b; V4_cd c; } v; RocketHit h; } u;
+ V4_cd v90;
+ V4_cd va0[4];
+ int r;
+ unsigned char flag;
+ float t;
+ float s;
+ float k;
+ float k60;
+ float a;
+ float g;
+ float sp;
+ float zf;
+
+ if (m == 0) return;
+ d = *(char **)(m + 0x78);
+ if (d == 0) return;
+
+ a = *(float *)(m + 0x2C);
+ k = D_0015ED6C;
+ *(u128_cd *)&z = 0;
+ z.f[2] = k * 8.0f;
+ *(u128_cd *)&dir = *(u128_cd *)&z;
+ k60 = D_0015ED60;
+ {
+ float k64 = D_0015ED64;
+ *(float *)(m + 0x2C) = a + (*(float *)(*(char **)(m + 0x24) + 0x24) - a) * (k60 * 0.05f);
+ {
+ float e = *(float *)(d + 0x30);
+ *(float *)(d + 0x30) = e + (k * 20.0f - e) * (k60 * 0.1f) * k64;
+ }
+ }
+ r = scale_game_frames_c(250);
+ r -= scale_game_frames_c(5);
+ if (*(int *)(d + 0x24) < r) {
+ q = *(char **)(d + 0x28);
+ if (q == 0 || *(short *)(q + 0xA6) != *(int *)(d + 0x58) || *(unsigned char *)(q + 0x20) == 0xFE || *(unsigned char *)(q + 0x20) == 0xFD) {
+ *(float *)(d + 0x44) = *(float *)(d + 0x44) + D_0015ED60 * 0.1f;
+ *(int *)(d + 0x28) = 0;
+ r = scale_game_frames_c(250);
+ r -= scale_game_frames_c(100);
+ if (*(int *)(d + 0x24) < r) {
+ *(float *)(m + 0x44) = fast_add_rotations(*(float *)(m + 0x44), fast_sin_c(*(float *)(d + 0x48)) * (D_0015ED60 * 0.04f));
+ }
+ *(float *)(m + 0x48) = fast_add_rotations(*(float *)(m + 0x48), fast_cos_c(*(float *)(d + 0x48)) * (D_0015ED60 * 0.05f));
} else {
- qcopy(&collision_scratch.tracking.target, &t->pos);
- collision_scratch.tracking.target.f[2] += v->height;
- subtract_vector_xyz_2c8440(&collision_scratch.tracking.delta, &collision_scratch.tracking.target, &v->position);
- subtract_vector_xyz_2c8440(&collision_scratch.tracking.rotation, &collision_scratch.tracking.target, &v->offset);
- qcopy(&v->position, &collision_scratch.tracking.target);
- a = v->radius * v->radius - FUN_001ff430_2cd1f0(&collision_scratch.tracking.delta);
- b = (collision_scratch.tracking.delta.f[0] * collision_scratch.tracking.rotation.f[0] + collision_scratch.tracking.delta.f[1] * collision_scratch.tracking.rotation.f[1] + collision_scratch.tracking.delta.f[2] * collision_scratch.tracking.rotation.f[2]) * -2.0f;
- c = -FUN_001ff430_2cd1f0(&collision_scratch.tracking.rotation);
- root = FUN_001ff1e0_2cd1f0(b * b - a * 4.0f * c);
+ qcopy(&u.v.c, q + 0x10);
+ u.v.c.f[2] = u.v.c.f[2] + *(float *)(d + 0x2C);
+ subtract_vector_xyz(&u.v.b, &u.v.c, d);
+ subtract_vector_xyz(&u.v.a, &u.v.c, d + 0x10);
+ qcopy(d, &u.v.c);
{
- f32 c;
- c = (-b + root) / (a + a);
- radius = (-b - root) / (a + a);
- {
- f32 f;
- if (c > 0.0f && radius > 0.0f)
- f = radius < c ? c : radius;
- else
- f = c > 0.0f ? c : radius > 0.0f ? radius : -1.0f;
- if (f > 0.0f) {
- FUN_001ff300_2cd1f0(f, &collision_scratch.tracking.end, &collision_scratch.tracking.delta);
- add_vector_xyz_2c8440(&collision_scratch.tracking.end, &collision_scratch.tracking.end, &collision_scratch.tracking.rotation);
- root = FUN_001ff8b0_2cd1f0(collision_scratch.tracking.end.f[0], collision_scratch.tracking.end.f[1]);
- m->rot.z = FUN_00258110_2cd1f0(&v->yaw_velocity, m->rot.z, root, frame_time_sq * 188.49556f, 0.0f, 0.0f);
- root = -FUN_001ff8b0_2cd1f0(FUN_001ff408_2cd1f0(&collision_scratch.tracking.end), collision_scratch.tracking.end.f[2]);
- m->rot.y = FUN_00258110_2cd1f0(&v->pitch_velocity, m->rot.y, root, frame_time_sq * 188.49556f, 0.0f, 0.0f);
- }
+ float r1 = FUN_L00_001ff430(&u.v.b);
+ float fB = (u.v.b.f[0] * u.v.a.f[0] + u.v.b.f[1] * u.v.a.f[1] + u.v.b.f[2] * u.v.a.f[2]) * -2.0f;
+ float fA = *(float *)(d + 0x30) * *(float *)(d + 0x30) - r1;
+ float r2f = FUN_L00_001ff430(&u.v.a);
+ float sq = square_root_scalar(fB * fB - (4.0f * fA) * (-r2f));
+ float t1 = (-fB + sq) / (fA + fA);
+ float t2 = (-fB - sq) / (fA + fA);
+ if (0.0f < t1 && 0.0f < t2) {
+ t = (t2 < t1) ? t1 : t2;
+ } else if (0.0f < t1) {
+ t = t1;
+ } else if (0.0f < t2) {
+ t = t2;
+ } else {
+ t = -1.0f;
}
}
- f = FUN_001ff3d8_2cd1f0(&collision_scratch.tracking.rotation);
- if (f < 6.0f)
- v->strength *= f / 6.0f;
- else
- v->strength += frame_scale * 0.1f;
- }
- }
- FUN_00262c50_2cd1f0(&query, v->radius, m->rot.z, -m->rot.y);
- collision_scratch.tracking.delta.q = 0;
- collision_scratch.tracking.delta.f[0] = FUN_00257be8_2cd1f0(-1.0f, 1.0f);
- collision_scratch.tracking.delta.f[1] = FUN_00257be8_2cd1f0(-1.0f, 1.0f);
- collision_scratch.tracking.delta.f[2] = FUN_00257be8_2cd1f0(-1.0f, 1.0f);
- collision_scratch.tracking.rotation.q = collision_scratch.tracking.delta.q;
- FUN_001ff500_2cd1f0(&collision_scratch.tracking.rotation, &collision_scratch.tracking.rotation, FUN_00257be8_2cd1f0(0.1f, 0.2f) * frame_time);
- FUN_001ff500_2cd1f0(&velocity, &query, -FUN_00257be8_2cd1f0(frame_time * 0.1f, frame_time));
- add_vector_xyz_2c8440(&collision_scratch.tracking.rotation, &collision_scratch.tracking.rotation, &velocity);
- FUN_001ff500_2cd1f0(&velocity, &query, FUN_00257be8_2cd1f0(0.0f, 1.0f) * v->radius);
- add_vector_xyz_2c8440(&velocity, &velocity, &m->pos);
- FUN_00269958_2cd1f0(&velocity, &collision_scratch.tracking.rotation, 0x6f00afff, 0x100000ff,
- FUN_001fef20_2cd1f0(FUN_00257b90_2cd1f0(28, 40)), 40,
- FUN_00257b90_2cd1f0(40, 70), 1);
- qcopy(&start, &m->pos);
- add_vector_xyz_2c8440(&v->offset, &v->offset, &query);
- v->yaw = FUN_002000e8_2cd1f0(v->yaw, v->yaw_step);
- v->pitch = FUN_002000e8_2cd1f0(v->pitch, v->pitch_step);
- v->yaw = FUN_002000e8_2cd1f0(v->yaw, FUN_001ff800_2cd1f0(v->pitch) * 0.15f);
- if (v->strength > 0.9f)
- v->strength = 0.9f;
- hit = 0;
- goto move;
-retry:
- if (!(v->strength > 0.1f))
- goto moved;
-move:
- {
- collision_scratch.tracking.rotation.f[1] = v->strength * FUN_001ff800_2cd1f0(v->yaw) * FUN_001ff7e8_2cd1f0(v->pitch);
- collision_scratch.tracking.rotation.f[2] = v->strength * FUN_001ff7e8_2cd1f0(v->yaw) * FUN_001ff7e8_2cd1f0(v->pitch);
- collision_scratch.tracking.rotation.f[0] = collision_scratch.tracking.rotation.f[3] = 0.0f;
- FUN_001ffa70_2cd1f0(matrix, &m->rot);
- FUN_001ff6f8_2cd1f0(&collision_scratch.tracking.rotation, &collision_scratch.tracking.rotation, matrix);
- add_vector_xyz_2c8440(&m->pos, &v->offset, &collision_scratch.tracking.rotation);
- if (!collision_line_2c8440(&start, &m->pos, 6, m, 0))
- goto moved;
- hit = 1;
- v->strength *= 0.7f;
- goto retry;
- }
-moved:
- if (hit) {
- m->rot.z = FUN_001ff8b0_2cd1f0(m->pos.x - start.f[0], m->pos.y - start.f[1]);
- m->rot.y = -FUN_001ff8b0_2cd1f0(FUN_001ff488_2cd1f0(&start, &m->pos), m->pos.z - start.f[2]);
- v->yaw_velocity = 0.0f;
- v->pitch_velocity = 0.0f;
- }
- if (m->pos.x < 0.0f || m->pos.y < 0.0f || m->pos.z < 0.0f)
- goto cleanup;
- {
- *(struct Moby **)(collision_scratch.collision_data + 0x10) = m;
- *(u32 *)(collision_scratch.collision_data + 0x14) = 0x00830000;
- *(f32 *)(collision_scratch.collision_data + 0x1c) = 3.0f;
- *(s32 *)(collision_scratch.collision_data + 0x20) = 1;
- qcopy(collision_scratch.collision_data, &query);
- FUN_001ff550_2cd1f0(collision_scratch.collision_data, collision_scratch.collision_data, 1.0f);
- *(f32 *)(collision_scratch.collision_data + 8) = 1.0f;
- *(f32 *)(collision_scratch.collision_data + 12) = 5627.9248046875f;
- collision_scratch.collision_data[0x18] = 3;
- collision_scratch.collision_data[0x19] = 3;
- *(u16 *)(collision_scratch.collision_data + 0x1a) = m->oclass;
- if (collision_line_2c8440(&start, &m->pos, 0, m, collision_scratch.collision_data)) {
- if (coll_hit_2c8440.moby != 0) {
- struct Moby *other = (struct Moby *)coll_hit_2c8440.moby;
- u8 *player = D_001413D0_2ccee0;
- if (other == (struct Moby *)player || other == v->owner || other->oclass == 0x1c9 || other->oclass == 0)
- goto bounce_only;
- m->command = 2;
- qcopy(&m->pos, &coll_hit_2c8440.point);
- FUN_001ff660_2cd1f0(&vector_scratch.bounce, &query, &coll_hit_2c8440.normal_x);
- FUN_001ff500_2cd1f0(&vector_scratch.bounce, &vector_scratch.bounce, frame_time + frame_time);
- FUN_0025e450_2cd1f0(0.0f, m, &vector_scratch.bounce, 0, 0.0f, 10, 3, 9, 4.0f, 2.0f, 9.0f, 1.0f, 0, 15.0f, 1, 1, -1, 0);
+ if (0.0f < t) {
+ fast_vec_scale(&v90, &u.v.b, t);
+ add_vector_xyz(&v90, &v90, &u.v.a);
+ g = fast_arc_tan_c(v90.f[0], v90.f[1]);
+ *(float *)(m + 0x48) = FUN_L00_00258110((float *)(d + 0x34), *(float *)(m + 0x48), g, D_0015ED70 * 188.49556f, 0.0f, 0.0f);
+ g = fast_arc_tan_c(vector_length_xy(&v90), v90.f[2]);
+ *(float *)(m + 0x44) = FUN_L00_00258110((float *)(d + 0x38), *(float *)(m + 0x44), -g, D_0015ED70 * 188.49556f, 0.0f, 0.0f);
+ }
+ s = fast_vec_length(&u.v.a);
+ if (s < 6.0f) {
+ *(float *)(d + 0x44) = *(float *)(d + 0x44) * (s / 6.0f);
} else {
- if (coll_hit_2c8440.unk1C <= 0)
- goto bounce_only;
- m->command = 1;
- qcopy(&m->pos, &coll_hit_2c8440.point);
- FUN_001ff660_2cd1f0(&vector_scratch.bounce, &query, &coll_hit_2c8440.normal_x);
- FUN_001ff500_2cd1f0(&vector_scratch.bounce, &vector_scratch.bounce, frame_time + frame_time);
- FUN_0025e450_2cd1f0(0.0f, m, &vector_scratch.bounce, 0, 1.0f, 10, 3, 9, 4.0f, 2.0f, 9.0f, 1.0f, 0, 15.0f, 1, 1, -1, 0);
+ *(float *)(d + 0x44) = *(float *)(d + 0x44) + D_0015ED60 * 0.1f;
}
- } else if (!FUN_001fef68_2cd1f0(&v->timer) && !(200.0f < FUN_001ff488_2cd1f0(&m->pos, D_001413D0_2ccee0 + 0x10))) {
- goto bounce_only;
}
}
-cleanup:
- FUN_0024eb68_2cd1f0(m);
- return;
-bounce_only:
- if (v->timer % FUN_001fef20_2cd1f0(32) != 0)
- return;
- if (FUN_001160d8_2cd1f0() & 1)
- v->yaw_step *= FUN_00257be8_2cd1f0(-0.7f, -1.5f);
- if (FUN_001160d8_2cd1f0() & 1)
- v->pitch_step *= FUN_00257be8_2cd1f0(-0.6f, -1.6f);
+
+ build_spherical_offset(&v50, *(float *)(d + 0x30), *(float *)(m + 0x48), -*(float *)(m + 0x44));
+ *(u128_cd *)&u.v.b = 0;
+ u.v.b.f[0] = random_float_between_c(-1.0f, 1.0f);
+ u.v.b.f[1] = random_float_between_c(-1.0f, 1.0f);
+ u.v.b.f[2] = random_float_between_c(-1.0f, 1.0f);
+ *(u128_cd *)&u.v.a = *(u128_cd *)&u.v.b;
+ fast_vec_normalize(&u.v.a, &u.v.a, random_float_between_c(0.1f, 0.2f) * D_0015ED6C);
+ fast_vec_normalize(&z, &v50, -random_float_between_c(D_0015ED6C * 0.1f, D_0015ED6C));
+ add_vector_xyz(&u.v.a, &u.v.a, &z);
+ fast_vec_normalize(&z, &v50, random_float_between_c(0.0f, 1.0f) * *(float *)(d + 0x30));
+ add_vector_xyz(&z, &z, m + 0x10);
+ {
+ int c1 = scale_game_frames_c(FUN_L00_00257b90_c(0x1C, 0x28));
+ FUN_L00_00269958(&z, &u.v.a, 0x6F00AFFF, 0x100000FF, c1, 0x28, FUN_L00_00257b90_c(0x28, 0x46), 1);
+ }
+ qcopy(&v20, m + 0x10);
+ add_vector_xyz(d + 0x10, d + 0x10, &v50);
+ *(float *)(d + 0x48) = fast_add_rotations(*(float *)(d + 0x48), *(float *)(d + 0x50));
+ *(float *)(d + 0x4C) = fast_add_rotations(*(float *)(d + 0x4C), *(float *)(d + 0x54));
+ *(float *)(d + 0x48) = fast_add_rotations(*(float *)(d + 0x48), fast_sin_c(*(float *)(d + 0x4C)) * 0.15f);
+ if (0.9f < *(float *)(d + 0x44)) *(float *)(d + 0x44) = 0.9f;
+
+ flag = 0;
+ goto body;
+ for (;;) {
+ float a1;
+ if (!(0.1f < sp)) goto done;
+ body:
+ a1 = fast_sin_c(*(float *)(d + 0x48));
+ u.v.a.f[1] = *(float *)(d + 0x44) * a1 * fast_cos_c(*(float *)(d + 0x4C));
+ a1 = fast_cos_c(*(float *)(d + 0x48));
+ u.v.a.f[2] = *(float *)(d + 0x44) * a1 * fast_cos_c(*(float *)(d + 0x4C));
+ zf = 0.0f;
+ u.v.a.f[3] = zf;
+ u.v.a.f[0] = zf;
+ euler_rotation_matrix(va0, m + 0x40);
+ transform_vector(&u.v.a, &u.v.a, va0);
+ add_vector_xyz(m + 0x10, d + 0x10, &u.v.a);
+ if (FUN_001efa68(&v20, m + 0x10, 6, (int)m, 0) == 0) goto done;
+ goto hit;
+ top:;
+ }
+hit:
+ flag = 1;
+ sp = *(float *)(d + 0x44) * 0.7f;
+ *(float *)(d + 0x44) = sp;
+ goto top;
+done:
+
+ if (flag) {
+ *(float *)(m + 0x48) = fast_arc_tan_c(*(float *)(m + 0x10) - v20.f[0], *(float *)(m + 0x14) - v20.f[1]);
+ *(float *)(m + 0x44) = -fast_arc_tan_c(vector_distance_xy_alt(&v20, m + 0x10), *(float *)(m + 0x18) - v20.f[2]);
+ *(int *)(d + 0x34) = 0;
+ *(int *)(d + 0x38) = 0;
+ }
+
+ if (*(float *)(m + 0x10) < 0.0f || *(float *)(m + 0x14) < 0.0f || *(float *)(m + 0x18) < 0.0f) goto del;
+ u.h.c = 0x830000;
+ u.h.e = 3.0f;
+ u.h.p = m;
+ u.h.i = 1;
+ qcopy(&u.v.a, &v50);
+ set_vector_length_xy(&u.v.a, &u.v.a, 1.0f);
+ u.h.z = 1.0f;
+ u.h.b18 = 3;
+ u.h.w = 5627.925f;
+ u.h.b19 = 3;
+ u.h.s = *(unsigned short *)(m + 0xA6);
+ if (FUN_001efa68(&v20, m + 0x10, 0, (int)m, (int)&u.v.a)) {
+ gg = (char *)((int *)&D_L00_00173E40);
+ p = *(char **)(gg + 0x18);
+ if (p != 0) {
+ if (p == (char *)D_001413D0_2ccee0 || p == *(char **)(d + 0x20)
+ || *(short *)(p + 0xA6) == 0x1C9 || *(short *)(p + 0xA6) == 0) goto keep;
+ m[0xBC] = 2;
+ qcopy(m + 0x10, gg + 0x20);
+ FUN_L00_001ff660(&dir, &v50, gg + 0x40);
+ fast_vec_normalize(&dir, &dir, D_0015ED6C + D_0015ED6C);
+ func_L00_0025F4A8_alt(m, &dir, 0, 0.0f, 0.0f, 10, 3, 9, 4.0f, 2.0f, 9.0f, 1.0f, 0, 15.0f, 1, 1, -1, 0);
+ mark_moby_for_removal_c(m);
+ return;
+ } else {
+ if (*(int *)(gg + 0x1C) <= 0) goto keep;
+ m[0xBC] = 1;
+ qcopy(m + 0x10, gg + 0x20);
+ FUN_L00_001ff660(&dir, &v50, gg + 0x40);
+ fast_vec_normalize(&dir, &dir, D_0015ED6C + D_0015ED6C);
+ func_L00_0025F4A8_alt(m, &dir, 0, 0.0f, 1.0f, 10, 3, 9, 4.0f, 2.0f, 9.0f, 1.0f, 0, 15.0f, 1, 1, -1, 0);
+ mark_moby_for_removal_c(m);
+ return;
+ }
+ } else {
+ if (tick_countdown_32_alt((int *)(d + 0x24)) == 0
+ && !(200.0f < vector_distance_xy_alt(m + 0x10, (char *)D_001413D0_2ccee0 + 0x10))) goto keep;
+ }
+del:
+ mark_moby_for_removal_c(m);
return;
+keep:
+ if (*(int *)(d + 0x24) % scale_game_frames_c(0x20) != 0) return;
+ if (rand() & 1) {
+ *(float *)(d + 0x50) = *(float *)(d + 0x50) * random_float_between_c(-0.7f, -1.5f);
+ }
+ if (rand() & 1) {
+ *(float *)(d + 0x54) = *(float *)(d + 0x54) * random_float_between_c(-0.6f, -1.6f);
+ }
}
-#endif
#include "qcopy.h"
typedef unsigned int u128_2cdcc0 __attribute__((mode(TI), aligned(16)));
typedef struct {
@@ -2200,7 +2234,7 @@ typedef struct {
unsigned short hC2;
unsigned int wC4;
} S_2cdcc0;
-extern P_2cdcc0 D_0013F350_2cdcc0 __asm__("D_0013F350");
+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");
@@ -2211,7 +2245,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 = &D_0013F350_2cdcc0;
+ P_2cdcc0 *p = &(*(P_2cdcc0 *)D_0013F350);
S_2cdcc0 *s;
float d[4] __attribute__((aligned(16)));
float v[4] __attribute__((aligned(16)));
@@ -2420,7 +2454,7 @@ extern void FUN_0025e450_2ce358(f32, f32, f32, f32, f32, f32, f32, void *, void
extern void FUN_0022da68_2ce358(s32, s32, void *) __asm__("FUN_0022da68");
extern s32 FUN_001160d8_2ce358(void) __asm__("FUN_001160d8");
extern void FUN_0024eb68_2ce358(void *) __asm__("FUN_0020c828");
-extern f32 D_0015ED70_2ce358 __asm__("D_0015ED70");
+extern float D_0015ED70_lui __asm__("D_0015ED70");
extern V4 D_L00_00166DC0_2ce358 __asm__("D_L00_00166DC0");
extern V4 D_L00_00166FF0_2ce358 __asm__("D_L00_00166FF0");
extern V4 D_L00_00166FD0_2ce358 __asm__("D_L00_00166FD0");
@@ -2616,7 +2650,7 @@ void FUN_L00_002ce358(struct Moby *m)
v->height = v->height + (target_pos.f[2] - v->height) * (frame_scale * 0.05f);
target_pos.f[2] = v->height + scratch.vectors.direction.f[2];
subtract_vector_xyz_2c8440(&target_pos, &target_pos, &m->pos);
- FUN_001ff598_2ce358(&target_pos, &target_pos, D_0015ED6C_2c8440 * 10.0f);
+ FUN_001ff598_2ce358(&target_pos, &target_pos, D_0015ED6C * 10.0f);
if (FUN_00258830_2ce358(0.0f, 0.18f, 0.0f, m, &target_pos, 0) & 1) {
if (!m->visible) {
V4 *hit = &D_L00_00166DC0_2ce358;
@@ -2626,12 +2660,12 @@ void FUN_L00_002ce358(struct Moby *m)
}
qcopy(&collision_data[0], &m->pos);
if (FUN_001f0d60_2ce358(0.2f, &collision_data[0], 0, m)) {
- other = (struct Moby *)coll_hit_2c8440.moby;
+ other = (struct Moby *)coll_hit.moby;
if (other && other->oclass == 0 && other->state != 0xfe && other->state != 0xfd)
goto update_rotations;
- other = (struct Moby *)((volatile CollisionHit *)&coll_hit_2c8440)->moby;
+ other = (struct Moby *)((volatile CollisionHit *)&coll_hit)->moby;
category = other && other->pclass ? *(u8 *)((u8 *)other->pclass + 0x46) : 0;
- other = (struct Moby *)((volatile CollisionHit *)&coll_hit_2c8440)->moby;
+ other = (struct Moby *)((volatile CollisionHit *)&coll_hit)->moby;
if (other && other->state != 0xfe && other->state != 0xfd &&
(category == 5 || category == 7 || category == 8)) {
FUN_00259858_2ce358(1.0f, scratch.effect, m, 0x10000);
@@ -2641,9 +2675,9 @@ void FUN_L00_002ce358(struct Moby *m)
scratch.effect[0x18] = 1;
scratch.effect[0x19] = 2;
*(u16 *)(scratch.effect + 0x1a) = m->oclass;
- FUN_00259a88_2ce358((struct Moby *)coll_hit_2c8440.moby, scratch.effect);
+ FUN_00259a88_2ce358((struct Moby *)coll_hit.moby, scratch.effect);
if (category == 5) {
- if (coll_hit_2c8440.moby && ((struct Moby *)coll_hit_2c8440.moby)->oclass == 0x4d6 && (health = v->health) > 0) {
+ if (coll_hit.moby && ((struct Moby *)coll_hit.moby)->oclass == 0x4d6 && (health = v->health) > 0) {
random = FUN_00200250_2ce358(*(f32 *)(scratch.effect + 0x1c));
if (random > 0)
random = health - FUN_00200250_2ce358(*(f32 *)(scratch.effect + 0x1c));
@@ -2662,8 +2696,8 @@ void FUN_L00_002ce358(struct Moby *m)
distance = FUN_001ff8b0_2ce358(m->pos.x - old_pos.f[0], m->pos.y - old_pos.f[1]);
f = FUN_001ff488_2ce358(&old_pos, &m->pos);
f = -FUN_001ff8b0_2ce358(f, m->pos.z - old_pos.f[2]);
- m->rot.z = FUN_00258110_2ce358(&v->yaw_velocity, m->rot.z, distance, D_0015ED70_2ce358 * 6.2831855f, D_0015ED70_2ce358 * 3.1415927f, D_0015ED6C_2c8440 * 6.2831855f);
- m->rot.y = FUN_00258110_2ce358(&v->pitch_velocity, m->rot.y, f, D_0015ED70_2ce358 * 6.2831855f, D_0015ED70_2ce358 * 3.1415927f, D_0015ED6C_2c8440 * 6.2831855f);
+ m->rot.z = FUN_00258110_2ce358(&v->yaw_velocity, m->rot.z, distance, D_0015ED70_lui * 6.2831855f, D_0015ED70_lui * 3.1415927f, D_0015ED6C * 6.2831855f);
+ m->rot.y = FUN_00258110_2ce358(&v->pitch_velocity, m->rot.y, f, D_0015ED70_lui * 6.2831855f, D_0015ED70_lui * 3.1415927f, D_0015ED6C * 6.2831855f);
goto update_effects;
}
state3:
@@ -2691,7 +2725,7 @@ void FUN_L00_002ce358(struct Moby *m)
qcopy(&v->offset, &target_pos);
qcopy(&collision_data[0], &m->pos);
if (FUN_001f0d60_2ce358(0.25f, &collision_data[0], 0, m)) {
- other = (struct Moby *)coll_hit_2c8440.moby;
+ other = (struct Moby *)coll_hit.moby;
if (!other || other->state == 0xfe || other->state == 0xfd || other != v->target || other->oclass == 0) {
qcopy(&m->pos, &D_L00_00173E70_2ce358);
} else {
@@ -2703,9 +2737,9 @@ void FUN_L00_002ce358(struct Moby *m)
scratch.effect[0x18] = 1;
scratch.effect[0x19] = 2;
*(u16 *)(scratch.effect + 0x1a) = m->oclass;
- FUN_00259a88_2ce358((struct Moby *)coll_hit_2c8440.moby, scratch.effect);
+ FUN_00259a88_2ce358((struct Moby *)coll_hit.moby, scratch.effect);
if (category == 5) {
- if (coll_hit_2c8440.moby && ((struct Moby *)coll_hit_2c8440.moby)->oclass == 0x4d6 && (health = v->health) > 0) {
+ if (coll_hit.moby && ((struct Moby *)coll_hit.moby)->oclass == 0x4d6 && (health = v->health) > 0) {
random = FUN_00200250_2ce358(*(f32 *)(scratch.effect + 0x1c));
if (random > 0)
random = health - FUN_00200250_2ce358(*(f32 *)(scratch.effect + 0x1c));
diff --git a/src/overlays/shared/gameplay/entities/camera_object.c b/src/overlays/shared/gameplay/entities/camera_object.c
index 15afb78484..c050d9842b 100644
--- a/src/overlays/shared/gameplay/entities/camera_object.c
+++ b/src/overlays/shared/gameplay/entities/camera_object.c
@@ -2112,92 +2112,97 @@ void wrench_update(WrenchMoby *m) {
default: break;
}
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L00_002a96f8.s", FUN_L00_002a96f8);
-#else
-typedef union { u128 q; f32 f[4]; } V_2a96f8;
-typedef struct { V_2a96f8 v0; void *p10; s32 i14; void *p18; f32 f1C; s32 i20; s32 i24; s32 i28; f32 f2C; f32 f30; f32 f34; s32 i38; s16 h3C; s16 h3E; } O_2a96f8;
-typedef struct { u8 pad[0x10]; V_2a96f8 v10; u8 b20; u8 pad2[0x2C - 0x21]; f32 f2C; u8 b30; u8 b31; s16 h32; u8 pad3[0x44 - 0x34]; f32 f44; f32 f48; u8 pad4[0x78 - 0x4C]; O_2a96f8 *p78; u8 pad5[0xBC - 0x7C]; u8 bBC; } M_2a96f8;
-typedef struct { u8 pad[0xB]; u8 bB; u8 bC; u8 pad2[0x1E - 0xD]; u16 h1E; } R_2a96f8;
-typedef struct { u8 pad[0x10]; V_2a96f8 v10; } T_2a96f8;
-extern f32 D_0015ED6C_2a96f8 __asm__("D_0015ED6C");
-extern f32 D_L00_001613C4_2a96f8 __asm__("D_L00_001613C4") __attribute__((sda));
-extern u8 D_0013F490_2a96f8[] __asm__("D_0013F490");
-extern void *D_001413D0_2a96f8 __asm__("D_001413D0") __attribute__((section(".data")));
-extern V_2a96f8 D_L00_00173E60_2a96f8[] __asm__("D_L00_00173E60") __attribute__((section(".data")));
-extern s16 D_L00_001B0770_lui[] __asm__("D_L00_001B0770") __attribute__((section(".data")));
-M_2a96f8 *FUN_0020c4f8_2a96f8(s32) __asm__("FUN_0020c4f8");
-void FUN_00214db0_2a96f8(void *, f32, f32, f32) __asm__("FUN_00214db0");
-T_2a96f8 *FUN_L00_002630c8_2a96f8(void *, void *, void *, f32, f32 *, f32 *, f32 *) __asm__("FUN_L00_002630c8");
-R_2a96f8 *FUN_L00_0025c338_2a96f8(void *) __asm__("FUN_002141f8");
-s32 FUN_001f96f8_2a96f8(s32) __asm__("FUN_001f96f8");
-f32 FUN_001f9af0_2a96f8(void *) __asm__("FUN_001f9af0");
-s32 FUN_L00_001efc70_2a96f8(void *, void *, s32, void *, s32) __asm__("FUN_001efa68");
-void FUN_L00_00250df8_2a96f8(void *) __asm__("FUN_L00_00250df8");
-void FUN_L00_0025f780_2a96f8(void *, void *, s32) __asm__("FUN_L00_0025f780");
-M_2a96f8 *FUN_L00_002a96f8(T_2a96f8 *src, V_2a96f8 *pos, T_2a96f8 *tgt, f32 x, f32 y, f32 z, f32 w, f32 v) {
- M_2a96f8 *moby;
- O_2a96f8 *vars;
- R_2a96f8 *target_info;
- V_2a96f8 dir, start;
- f32 player_speed;
- s32 delay;
- moby = FUN_0020c4f8_2a96f8(0x100);
- if (moby) {
- moby->b30 = 0xFF;
- moby->b31 = 1;
- moby->b20 = 0;
- moby->h32 = 0xFF;
- moby->f2C *= D_L00_001613C4_2a96f8;
- vars = moby->p78;
- moby->f48 = w;
- moby->f44 = v;
- if (!tgt) {
- FUN_00214db0_2a96f8(&dir, 20.0f * D_0015ED6C_2a96f8, w, v);
- start.q = pos->q;
- tgt = FUN_L00_002630c8_2a96f8(src, &start, &dir, 0.34906585f, &x, &y, &z);
- }
- vars->p10 = src;
- qcopy(&moby->v10, pos);
- vars->i38 = 1;
- vars->f34 = D_0015ED6C_2a96f8 * 100.0f;
- vars->i24 = 0;
- vars->i28 = 0;
- vars->i20 = 0;
- vars->p18 = tgt;
- if (tgt) {
- target_info = FUN_L00_0025c338_2a96f8(tgt);
- if (target_info) {
- target_info->h1E |= 0x80;
- if (target_info->bB) vars->i38 = 0;
- if (target_info->bC) vars->f34 = target_info->bC * D_0015ED6C_2a96f8;
+/* Spawns a homing bolt (class 0x100) from owner at pos, aimed at tgt or at whatever lies along its heading. */
+/* Ported from rac1-decomp (src/overlays/shared/vendor_002A5138.c: func_L00_002AA998), where it is exact; names translated to the US level program. */
+
+typedef float V[4] __attribute__((aligned(16)));
+
+typedef int Q_2aa998 __attribute__((mode(TI)));
+
+typedef union { Q_2aa998 q; float f[4]; } BoltVector_2AA998;
+
+typedef struct { char pad[0x10]; BoltVector_2AA998 position; } BoltOwner_2AA998;
+
+extern V D_L00_00173E60;
+extern char *FUN_L00_002630c8(void *, void *, void *, float *, float *, float *, float);
+extern char *func_0020D348_m(int);
+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 short D_L00_001B0770[];
+extern void FUN_L00_00250df8_c(void *) __asm__("FUN_L00_00250df8");
+extern void FUN_L00_0025f780(void *, short *, int);
+
+char *FUN_L00_002a96f8(void *owner, void *pos, float a, float b, float c, char *tgt, float rz, float ry) {
+ char *m;
+ char *d;
+ BoltVector_2AA998 t;
+ BoltVector_2AA998 p;
+ m = (char *)func_0020D348_m(0x100);
+ if (m != 0) {
+ ((unsigned char *)m)[0x30] = 0xFF;
+ m[0x31] = 1;
+ m[0x20] = 0;
+ *(float *)(m + 0x2C) *= *(float *)&D_L00_001613C4;
+ *(short *)(m + 0x32) = 0xFF;
+ d = *(char **)(m + 0x78);
+ *(float *)(m + 0x48) = rz;
+ *(float *)(m + 0x44) = ry;
+ if (tgt == 0) {
+ build_spherical_offset(&t, D_0015ED6C * 20.0f, rz, ry);
+ p.q = *(Q_2aa998 *)pos;
+ tgt = FUN_L00_002630c8(owner, &p, &t, &a, &b, &c, 0.34906584f);
+ }
+ *(void **)(d + 0x10) = owner;
+ qcopy(m + 0x10, pos);
+ *(float *)(d + 0x34) = D_0015ED6C * 100.0f;
+ *(int *)(d + 0x38) = 1;
+ *(int *)(d + 0x24) = 0;
+ *(int *)(d + 0x28) = 0;
+ *(int *)(d + 0x20) = 0;
+ *(char **)(d + 0x18) = tgt;
+ if (tgt != 0) {
+ unsigned char *e = (unsigned char *)FUN_002141f8(tgt);
+ if (e != 0) {
+ *(unsigned short *)(e + 0x1E) |= 0x80;
+ if (e[0xB] != 0) *(int *)(d + 0x38) = 0;
+ if (e[0xC] != 0) *(float *)(d + 0x34) = (float)e[0xC] * D_0015ED6C;
+ }
+ }
+ *(float *)(d + 0x2C) = a;
+ *(float *)(d + 0x30) = b;
+ *(int *)(d + 0x14) = scale_game_frames_c(0x96);
+ if (tgt != 0) {
+ qcopy(d, tgt + 0x10);
+ *(float *)(d + 8) += c;
+ *(float *)(d + 0x1C) = c;
+ }
+ {
+ int r;
+ if (fast_vec_length((float *)(D_0013F490)) > D_0015ED6C * 0.1f) {
+ r = scale_game_frames_c(0x3C);
+ *(short *)(d + 0x3E) = r;
+ *(short *)(d + 0x3C) = r;
+ } else {
+ r = scale_game_frames_c(1);
+ *(short *)(d + 0x3E) = r;
+ *(short *)(d + 0x3C) = r;
}
}
- vars->f2C = x;
- vars->f30 = y;
- vars->i14 = FUN_001f96f8_2a96f8(0x96);
- if (tgt) {
- qcopy(&vars->v0, &tgt->v10);
- vars->v0.f[2] += z;
- vars->f1C = z;
- }
- player_speed = FUN_001f9af0_2a96f8(D_0013F490_2a96f8);
- delay = FUN_001f96f8_2a96f8(D_0015ED6C_2a96f8 * 0.1f < player_speed ? 0x3C : 1);
- vars->h3E = delay;
- vars->h3C = delay;
- dir.f[2] = pos->f[2];
- dir.q = src->v10.q;
- if (FUN_L00_001efc70_2a96f8(&dir, pos, 0, D_001413D0_2a96f8, 0)) {
- moby->bBC = 1;
- qcopy(&moby->v10, &D_L00_00173E60_2a96f8[0]);
- }
- FUN_L00_00250df8_2a96f8(moby);
- FUN_L00_0025f780_2a96f8(moby, D_L00_001B0770_lui, 0x1F);
- moby->f2C += moby->f2C;
+ t.q = ((BoltOwner_2AA998 *)owner)->position.q;
+ t.f[2] = ((float *)pos)[2];
+ if (FUN_001efa68(&t, pos, 0, *(int *)(((char *)&D_001413D0)), 0) != 0) {
+ m[0xBC] = 1;
+ qcopy(m + 0x10, &D_L00_00173E60);
+ }
+ FUN_L00_00250df8_c(m);
+ FUN_L00_0025f780(m, D_L00_001B0770, 0x1F);
+ *(float *)(m + 0x2C) += *(float *)(m + 0x2C);
}
- return moby;
+ return m;
}
-#endif
/* Creates a moby at a position with a scale, colour and a few data fields. */
/* Ported from rac1-decomp (src/overlays/shared/vendor_002A5138.c: func_L00_002AAC50), where it is exact; names translated to the US level program. */
@@ -2560,7 +2565,6 @@ void FUN_L00_002aa008(V_2aa008 *pos, N_2aa008 *self, void *arg) {
}
/* Ported from rac1-decomp (src/overlays/shared/vendor_002A5138.c: func_L00_002AB548), where it is exact; names translated to the US level program. */
-typedef float V[4] __attribute__((aligned(16)));
extern V D_L00_00166DC0;
diff --git a/src/overlays/shared/gameplay/entities/gadgebot_spawn_container.c b/src/overlays/shared/gameplay/entities/gadgebot_spawn_container.c
index fdfe673cde..52030cf91c 100644
--- a/src/overlays/shared/gameplay/entities/gadgebot_spawn_container.c
+++ b/src/overlays/shared/gameplay/entities/gadgebot_spawn_container.c
@@ -360,8 +360,8 @@ extern f32 fast_sin_c(f32) __asm__("func_001F9DE0");
extern f32 random_angle_radians_c(void) __asm__("func_00213308");
extern f32 random_float_between_c(f32, f32) __asm__("func_002132A8");
extern f32 vector_length_xy_c(void *) __asm__("FUN_001f9b20");
-extern float D_0015ED6C_c2 __asm__("D_0015ED6C") __attribute__((section(".sdata")));
-extern float D_0015ED70_c __asm__("D_0015ED70") __attribute__((section(".sdata")));
+extern float D_0015ED6C_gp __asm__("D_0015ED6C") __attribute__((section(".sdata")));
+extern float D_0015ED70 __attribute__((section(".sdata")));
extern float FUN_001f9b80(void *, void *);
extern float FUN_L00_0025abf0(void *, void *, void *, float, float);
extern float probe_ground_height_c(void *, int, float) __asm__("func_00213508");
@@ -454,7 +454,7 @@ void FUN_L06_002e8678(unsigned char *moby) {
qcopy(data + 0x220, moby + 0x40);
*(short *)(data + 0x208) = 0;
wait = random_float_between_c(0.5f, 3.0f);
- *(float *)(data + 0x130) = D_0015ED70_c * 20.0f;
+ *(float *)(data + 0x130) = D_0015ED70 * 20.0f;
*(int *)(data + 0x148) = 0;
*(int *)(data + 0x134) = 0;
*(int *)(data + 0x140) = 0x200;
@@ -519,7 +519,7 @@ void FUN_L06_002e8678(unsigned char *moby) {
subtract_vector_xyz(A, B, moby + 0x10);
FUN_L06_002e9aa8_c((char *)moby);
FUN_L06_002e9998_c((char *)moby, (float *)D_L06_00174600, A);
- normalize_vector_xyz(C, moby + 0xC0, *(float *)(data + 0x1E4) * D_0015ED6C_c2);
+ normalize_vector_xyz(C, moby + 0xC0, *(float *)(data + 0x1E4) * D_0015ED6C_gp);
FUN_L06_002e9b60_c(moby, C, 0, 0.3f, 0.3f);
transform_vector_by_basis(A, A, moby + 0xC0);
if (vector_length_xy_c(A) < 0.5f) {
@@ -589,7 +589,7 @@ void FUN_L06_002e8678(unsigned char *moby) {
subtract_vector_xyz(C, data + 0x230, moby + 0x10);
FUN_L06_002e9aa8_c((char *)moby);
FUN_L06_002e9998_c((char *)moby, (float *)D_L06_00174600, C);
- normalize_vector_xyz(B, moby + 0xC0, *(float *)(data + 0x1E4) * D_0015ED6C_c2);
+ normalize_vector_xyz(B, moby + 0xC0, *(float *)(data + 0x1E4) * D_0015ED6C_gp);
FUN_L06_002e9b60_c(moby, B, 1, 0.3f, 0.3f);
}
if (*(int *)(data + 0x1C4) != 2 && random_integer_below(9) == 0) {
@@ -609,7 +609,7 @@ void FUN_L06_002e8678(unsigned char *moby) {
B[2] = 0.0f;
FUN_L06_002e9aa8_c((char *)moby);
FUN_L06_002e9998_c((char *)moby, (float *)D_L06_00174600, B);
- normalize_vector_xyz(A, moby + 0xC0, *(float *)(data + 0x1E4) * D_0015ED6C_c2);
+ normalize_vector_xyz(A, moby + 0xC0, *(float *)(data + 0x1E4) * D_0015ED6C_gp);
FUN_L06_002e9b60_c(moby, A, 1, 0.3f, 0.3f);
if (FUN_001f9b80(moby + 0x10, target + 0x10) < 2.0f) {
moby[0x20] = 0xC;
@@ -629,7 +629,7 @@ void FUN_L06_002e8678(unsigned char *moby) {
near = 0;
FUN_L06_002e9aa8_c((char *)moby);
FUN_L06_002e9998_c((char *)moby, (float *)D_L06_00174600, B);
- normalize_vector_xyz(A, moby + 0xC0, *(float *)(data + 0x1E4) * D_0015ED6C_c2);
+ normalize_vector_xyz(A, moby + 0xC0, *(float *)(data + 0x1E4) * D_0015ED6C_gp);
FUN_L06_002e9b60_c(moby, A, 1, 0.3f, 0.3f);
if (FUN_L00_00261b48(*(int *)(data + 0x1EC), moby + 0x10, target + 0x10, D) != 0
&& distance_xyz(moby + 0x10, D) < *(float *)(data + 0x244)) {
@@ -660,7 +660,7 @@ void FUN_L06_002e8678(unsigned char *moby) {
FUN_L06_002e9998_c((char *)moby, (float *)(moby + 0xE0), B);
wait = compute_interpolated_record_value_c(moby);
if (moby[0x52] == moby[0x53] && wait >= 10.0f && wait <= 15.0f && *(int *)(((char *)&D_001413D4)) != 0x51) {
- normalize_vector_xyz(A, moby + 0xC0, (*(float *)(data + 0x1E4) + *(float *)(data + 0x1E4)) * D_0015ED6C_c2);
+ normalize_vector_xyz(A, moby + 0xC0, (*(float *)(data + 0x1E4) + *(float *)(data + 0x1E4)) * D_0015ED6C_gp);
FUN_L06_002e9b60_c(moby, A, 1, 0.3f, 0.3f);
FUN_L00_002599e8(moby, 0, 1, 0.333f, 1.0f, 1.0f, 0, 1, 0);
return;
@@ -675,7 +675,7 @@ void FUN_L06_002e8678(unsigned char *moby) {
subtract_vector_xyz(B, data + 0x210, moby + 0x10);
FUN_L06_002e9aa8_c((char *)moby);
FUN_L06_002e9998_c((char *)moby, (float *)D_L06_00174600, B);
- normalize_vector_xyz(A, moby + 0xC0, *(float *)(data + 0x1E4) * D_0015ED6C_c2);
+ normalize_vector_xyz(A, moby + 0xC0, *(float *)(data + 0x1E4) * D_0015ED6C_gp);
FUN_L06_002e9b60_c(moby, A, 1, 0.3f, 0.3f);
if (FUN_001f9b80(moby + 0x10, data + 0x210) < 2.0f) {
moby[0x20] = 8;
@@ -1338,7 +1338,7 @@ typedef struct {
char *FUN_L06_002d8510(char *owner);
char *FUN_L06_002d8b98(char *owner);
extern GbHit D_L06_001745C0;
-extern GbMoby *D_L06_0015FFD8_u __asm__("D_L06_0015FFD8");
+extern Moby *D_L06_0015FFD8;
extern GbMoby *D_L06_001745D8 __attribute__((section(".data")));
extern GbStats D_L06_0017EC58;
extern char *FUN_L00_0026daa0(float, char *, int, int, int);
@@ -1613,7 +1613,7 @@ void FUN_L06_002f0040(GbMoby *moby) {
}
ta = &d->f2A0[j];
tb = &d->f2C0[j];
- m = &D_L06_0015FFD8_u[*ta];
+ m = &(*(GbMoby * *)&D_L06_0015FFD8)[*ta];
if (m->cls_id == 0x3F7 && m->state != 4 &&
is_point_inside_clip_volume(((GbMoby *)hero.moby)->pos, *tb) != 0 &&
is_point_inside_clip_volume(moby->pos, *tb) == 0) {
@@ -2420,140 +2420,149 @@ void FUN_L06_002f2910(void *moby_arg) {
}
d->target_searched = 1;
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L06_002f2c28.s", FUN_L06_002f2c28);
-#else
-extern float fast_normalize_angle(float) __asm__("FUN_001fa610");
-
-int FUN_L06_002f2c28(GbMoby *moby, GbVars *d, GbMoby *candidate, int flag, int *out) {
- GbVec origin;
- GbVec vel;
- GbVec displacement;
- GbVec pos;
- GbVec end;
- int count;
- int *vars;
- int index;
- GbMoby *target;
- float angle;
- float s, fa, fb;
- int cr, cg, cb, t;
- int *id, *node, *cursor;
- int i;
+/* Ported from rac1-decomp (src/overlays/shared/vendor_002D9548.c: func_L06_002F4058), where it is exact; names translated to the US level program. */
+
+typedef int u128_F4058 __attribute__((mode(TI)));
+
+extern Moby *D_L06_0015FFD8;
+extern f32 convert_integer_to_float(s32) __asm__("func_001FA6C0");
+extern f32 fast_cos_c2(f32) __asm__("func_001F9DC8");
+extern f32 fast_normalize_angle(f32) __asm__("func_001FA610");
+extern f32 fast_sin_c2(f32) __asm__("func_001F9DE0");
+extern f32 random_angle_radians_c2(void) __asm__("func_00213308");
+extern f32 random_float_between_c2(f32, f32) __asm__("func_002132A8");
+extern float D_0015ED70;
+extern float fast_add_rotations_c2(float, float) __asm__("func_001FA580");
+extern float vector_distance_xy_alt(void *, void *) __asm__("FUN_001f9b80");
+extern int FUN_L00_00257b90(int, int);
+extern s32 scale_game_frames(s32) __asm__("func_001F96F8");
+extern void fast_vec_normalize_c(void *, void *, f32) __asm__("FUN_001f9bf8");
+extern float fast_sin(float) __asm__("FUN_001f9de0");
+extern float fast_normalize_angle(f32) __asm__("FUN_001fa610");
+extern Moby *D_L06_0015FFD8;
- if (candidate->cls_id != 0x515 && candidate->cls_id != 0x15f) {
- add_vector_xyz(&origin, candidate->pos, candidate->fC0);
+int FUN_L06_002f2c28(char *ctx, char *ow, char *moby, int flag, int *out) {
+ float v0[4];
+ float vB[4];
+ float vA[4];
+ float vC[4];
+ float vD[4];
+ int v58;
+ int k;
+ char *st;
+ char *g;
+ float f20;
+
+ if (*(short *)(moby + 0xA6) != 0x515 && *(short *)(moby + 0xA6) != 0x15F) {
+ add_vector_xyz(v0, moby + 0x10, moby + 0xC0);
} else {
- origin.q = *(OvlQuad *)candidate->pos;
+ *(u128_F4058 *)v0 = *(u128_F4058 *)(moby + 0x10);
}
- switch (candidate->cls_id) {
- case 0x15f:
- case 0x3b1:
+
+ switch (*(short *)(moby + 0xA6)) {
+ case 0x15F:
+ case 0x3B1:
case 0x515:
- break;
+ if (!(vector_distance_xy_alt(ctx + 0x10, v0) < 1.0f)) return 0;
+ st = *(char **)(moby + 0x78);
+ if (*(int *)st < 0) return 0;
+ v58 = 0;
+ if (*(short *)(moby + 0xA6) == 0x3B1) {
+ v58 = *(int *)(st + 4);
+ *(int *)(st + 4) = v58 + 1;
+ } else if (*(short *)(moby + 0xA6) == 0x515 || *(short *)(moby + 0xA6) == 0x15F) {
+ v58 = *(int *)(st + 4);
+ *(int *)(st + 4) = v58 + 1;
+ }
+ if (*(short *)(moby + 0xA6) == 0x515) {
+ FUN_L00_0028dc90(0, 0, (int)moby, 0x515);
+ }
+
+ for (k = 0; k < 10; k++) {
+ int r16, r17, r18, r2, gc;
+ float f0, lift, f20, f21;
+ f21 = random_float_between_c2(0.1f, 1.0f);
+ r18 = FUN_L00_00257b90(0x40, 0xFF);
+ r17 = FUN_L00_00257b90(0x40, 0xFF);
+ r16 = FUN_L00_00257b90(0x40, 0xFF);
+ f20 = fast_cos_c2(random_angle_radians_c2()) * random_float_between_c2(0.0f, 0.25f);
+ vA[0] = f20;
+ f20 = fast_sin(random_angle_radians_c2());
+ f20 = f20 * random_float_between_c2(0.0f, 0.25f);
+ vA[2] = 0.0f;
+ vA[1] = f20;
+ lift = vA[2] + random_float_between_c2(0.0f, 0.5f);
+ vA[2] = lift;
+ FUN_L00_001ff290(vC, vA, ctx + 0x10);
+ f0 = random_float_between_c2(0.0f, D_0015ED6C);
+ fast_vec_normalize_c(vB, vB, f0);
+ f0 = random_float_between_c2(D_0015ED6C * 2.5f, D_0015ED6C * 5.0f);
+ vB[2] = f0;
+ r2 = scale_game_frames(FUN_L00_00257b90(0xF, 0x1E));
+ gc = (r17 << 8) | 0x7F000000;
+ FUN_L00_00272060(vA, r2, f21 * 0.07f, f21 * 0.7f, (r16 << 16) | gc | r18, 0, random_integer_below(2) ? 1 : -1, D_0015ED70 * 15.0f, vB);
+ }
+
+ g = (*(char * *)&D_L06_0015FFD8) + (*(int *)st << 8);
+ f20 = fast_normalize_angle(convert_integer_to_float(v58) * 60.0f * 0.017453292f);
+ vB[0] = fast_cos_c2(fast_add_rotations_c2(*(float *)(g + 0x48), f20));
+ vB[1] = fast_sin(fast_add_rotations_c2(*(float *)(g + 0x48), f20));
+ vB[2] = 0.0f;
+ add_vector_xyz(ctx + 0x10, vB, g + 0x10);
+ *(u128_F4058 *)(ow + 0x2F0) = *(u128_F4058 *)(ow + 0x2E0) = *(u128_F4058 *)(ctx + 0x10);
+
+ for (k = 0; k < 10; k++) {
+ int r16, r17, r18, r2, gc;
+ float f0, lift, f20, f21;
+ f21 = random_float_between_c2(0.1f, 1.0f);
+ r18 = FUN_L00_00257b90(0x40, 0xFF);
+ r17 = FUN_L00_00257b90(0x40, 0xFF);
+ r16 = FUN_L00_00257b90(0x40, 0xFF);
+ f20 = fast_cos_c2(random_angle_radians_c2()) * random_float_between_c2(0.0f, 0.25f);
+ vC[0] = f20;
+ f20 = fast_sin(random_angle_radians_c2());
+ f20 = f20 * random_float_between_c2(0.0f, 0.25f);
+ vC[2] = 0.0f;
+ vC[1] = f20;
+ lift = vC[2] + random_float_between_c2(0.0f, 0.5f);
+ vC[2] = lift;
+ FUN_L00_001ff290(vD, vC, ctx + 0x10);
+ f0 = random_float_between_c2(0.0f, D_0015ED6C);
+ fast_vec_normalize_c(vA, vA, f0);
+ f0 = random_float_between_c2(D_0015ED6C * 2.5f, D_0015ED6C * 5.0f);
+ vA[2] = f0;
+ r2 = scale_game_frames(FUN_L00_00257b90(0xF, 0x1E));
+ gc = (r17 << 8) | 0x7F000000;
+ FUN_L00_00272060(vC, r2, f21 * 0.07f, f21 * 0.7f, (r16 << 16) | gc | r18, 0, random_integer_below(2) ? 1 : -1, D_0015ED70 * 15.0f, vA);
+ }
+
+ *(char *)(ctx + 0x20) = 4;
+ *out = 1;
+ if (*(int *)(ow + 0x310) >= 2) {
+ int idx;
+ int *ids = (int *)(ow + 0x1E0);
+ int *cnt = (int *)(ow + 0x220);
+ for (idx = 0; idx < 16; idx++) {
+ if (ids[idx] >= 0) {
+ if (FUN_L01_00276a48(0.0f, (int *)(ow + 0x1E0) + idx, 1, cnt[idx], ctx + 0x10) != 0) {
+ *(int *)(ow + 0x27C) = idx;
+ }
+ }
+ }
+ }
+ return 0;
case 0x400:
case 0x516:
- goto special;
- default:
+ if (flag != 0) return 0;
+ if (*(unsigned char *)(moby + 0x20) == 2) return 0;
+ if (!(vector_distance_xy_alt(ctx + 0x10, v0) < 1.0f)) return 0;
+ *(char *)(ctx + 0x20) = 8;
+ *(int *)(ow + 0x304) = (int)moby;
+ *out = 2;
return 0;
}
- if (!(vector_distance(moby->pos, &origin) < 1.0f)) return 0;
- vars = candidate->vars;
- if (vars[0] < 0) return 0;
- index = 0;
- if (candidate->cls_id == 0x3b1) {
- index = vars[1];
- vars[1] = index + 1;
- } else if (candidate->cls_id == 0x515 || candidate->cls_id == 0x15f) {
- index = vars[1];
- vars[1] = index + 1;
- }
- if (candidate->cls_id == 0x515) FUN_L00_0028dc90(0, 0, (int)candidate, 0x515);
- count = 9;
- do {
- count--;
- s = random_float_between(0.1f, 1.0f);
- cr = random_int_between(0x40, 0xff);
- cg = random_int_between(0x40, 0xff);
- cb = random_int_between(0x40, 0xff);
- fa = fast_cos(random_angle_radians());
- fa *= random_float_between(0.0f, 0.25f);
- displacement.f[0] = fa;
- fa = fast_sin(random_angle_radians());
- fa *= random_float_between(0.0f, 0.25f);
- displacement.f[1] = fa;
- displacement.f[2] = 0.0f;
- displacement.f[2] += random_float_between(0.0f, 0.5f);
- FUN_L00_001ff290(&pos, &displacement, moby->pos);
- /* Retail reads this stack vector before its xyz are initialized. */
- normalize_vector_xyz(&vel, &vel, random_float_between(0.0f, frame_time));
- vel.f[2] = random_float_between(frame_time * 2.5f, frame_time * 5.0f);
- t = scale_game_frames(random_int_between(0xf, 0x1e));
- cg = (cg << 8) | 0x7f000000;
- fa = s * 0.07f;
- fb = s * 0.7f;
- /* Retail passes displacement, even though pos holds the translated point. */
- FUN_L00_00272060(&displacement, t, fa, fb, (cb << 16) | cg | cr, 0,
- random_integer_below(2) ? 1 : -1, frame_time_sq * 15.0f, &vel);
- } while (count >= 0);
- target = &D_L06_0015FFD8_u[vars[0]];
- count = 9;
- angle = fast_normalize_angle(convert_integer_to_float(index) * 60.0f * 0.017453292f);
- vel.f[0] = fast_cos(fast_add_rotations(target->rot, angle));
- vel.f[1] = fast_sin(fast_add_rotations(target->rot, angle));
- vel.f[2] = 0.0f;
- add_vector_xyz(moby->pos, &vel, target->pos);
- d->f2F0.q = d->f2E0.q = *(OvlQuad *)moby->pos;
- do {
- count--;
- s = random_float_between(0.1f, 1.0f);
- cr = random_int_between(0x40, 0xff);
- cg = random_int_between(0x40, 0xff);
- cb = random_int_between(0x40, 0xff);
- fa = fast_cos(random_angle_radians());
- fa *= random_float_between(0.0f, 0.25f);
- pos.f[0] = fa;
- fa = fast_sin(random_angle_radians());
- fa *= random_float_between(0.0f, 0.25f);
- pos.f[1] = fa;
- pos.f[2] = 0.0f;
- pos.f[2] += random_float_between(0.0f, 0.5f);
- FUN_L00_001ff290(&end, &pos, moby->pos);
- normalize_vector_xyz(&displacement, &displacement, random_float_between(0.0f, frame_time));
- displacement.f[2] = random_float_between(frame_time * 2.5f, frame_time * 5.0f);
- t = scale_game_frames(random_int_between(0xf, 0x1e));
- cg = (cg << 8) | 0x7f000000;
- fa = s * 0.07f;
- fb = s * 0.7f;
- FUN_L00_00272060(&pos, t, fa, fb, (cb << 16) | cg | cr, 0,
- random_integer_below(2) ? 1 : -1, frame_time_sq * 15.0f, &displacement);
- } while (count >= 0);
- moby->state = 4;
- *out = 1;
- if (d->f310 > 1) {
- id = d->paths.id;
- i = 0;
- node = d->paths.node;
- cursor = id;
- do {
- if (*id >= 0 && FUN_L01_00276a48(0.0f, cursor, 1, *node, moby->pos)) d->f27C = i;
- i++;
- node++;
- cursor++;
- id++;
- } while (i < 16);
- }
- return 0;
-special:
- if (flag != 0) return 0;
- if (candidate->state == 2) return 0;
- if (!(vector_distance(moby->pos, &origin) < 1.0f)) return 0;
- moby->state = 8;
- d->f304 = candidate;
- *out = 2;
return 0;
}
-#endif
extern int FUN_L00_002591d0_c(int *, int, int, int) __asm__("FUN_L00_002591d0");
extern int FUN_L00_002592b8_c(int *, int, int, int) __asm__("FUN_L00_002592b8");
extern int FUN_L06_002f2c28_c(char *, char *, int, int, int *) __asm__("FUN_L06_002f2c28");
@@ -2952,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 char D_0014171B_aa35[] __asm__("D_0014C050");
+extern unsigned char D_0014C050[];
void FUN_L06_002f7288(char *m) {
char *d = *(char **)(m + 0x78);
@@ -2964,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 *)D_0014171B_aa35,
+ (current_level_index != 10 || (q = (unsigned char *)((char *)D_0014C050),
(q + ((unsigned char *)m)[0xB0]))[0xA0] == 0xFF)) {
m[0x20] = 2;
m[0xBC] = 1;
@@ -3175,7 +3184,7 @@ typedef struct {
extern char *find_moby_hit(void *, int, int) __asm__("FUN_L00_0025a420");
extern char D_0013E550[];
extern f32 fast_add_rotations(f32 a, f32 b) __asm__("FUN_001fa580");
-extern float D_0015ED6C_c __asm__("D_0015ED6C");
+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));
@@ -3213,13 +3222,13 @@ void FUN_L06_002f7ab8(struct Moby *m) {
m->flags |= 0x20;
*(int *)(d + 0x60) = -1;
case 1: {
- float a0 = *(float *)&D_L06_00161E74 * DEG_TO_RAD * D_0015ED6C_c;
+ float a0 = *(float *)&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_c;
+ a1 = *(float *)&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_c;
+ a2 = *(float *)&D_L06_00161E7C * DEG_TO_RAD * D_0015ED6C;
m->rot.y = x;
m->rot.z = fast_add_rotations(m->rot.z, a2);
}
diff --git a/src/overlays/shared/gameplay/entities/nanotech_ball.c b/src/overlays/shared/gameplay/entities/nanotech_ball.c
index 7e247aa615..af573177e0 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 G_2d81b8 D_L00_00173E40_2d81b8 __asm__("D_L00_00173E40") __attribute__((section(".data")));
+extern int 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 = &D_L00_00173E40_2d81b8;
+ G_2d81b8 *g = &(*(G_2d81b8 *)D_L00_00173E40);
if (g->o) {
if (FUN_L00_0025e3b8_2d81b8(g->o)) {
*(float *)(m + 0x10) = d->f10 = g->o->x;
@@ -261,7 +261,7 @@ typedef struct {
u8 p0[0xF8];
u8 *pF8;
} T_2d8510;
-extern V_2d8510 D_L00_00166DC0_2d8510 __asm__("D_L00_00166DC0") __attribute__((section(".data")));
+extern char g_debug_camera[] __asm__("D_L00_00166DC0") __attribute__((section(".data")));
extern T_2d8510 D_L00_001B2080_2d8510 __asm__("D_L00_001B2080") __attribute__((section(".data")));
extern s32 D_L00_00161A58_gp __asm__("D_L00_00161A58") __attribute__((sda));
void FUN_001f9a28_2d8510(void *, void *, void *) __asm__("FUN_001f9a28");
@@ -288,7 +288,7 @@ s32 FUN_L00_002d8510(M_2d8510 *m) {
f32 z, t, f;
u8 *p;
o = m->p78;
- FUN_001f9a28_2d8510(&a, &D_L00_00166DC0_2d8510, &m->v10);
+ FUN_001f9a28_2d8510(&a, &(*(V_2d8510 *)g_debug_camera), &m->v10);
ret = 0;
fast_vec_normalize(&a, &a, -0.3f);
fast_vec_normalize(&b, &a, 0.1f);
@@ -818,7 +818,7 @@ extern int D_L00_00161AE4_002d9810 __asm__("D_L00_00161AE4") __attribute__((sda)
extern float D_L00_00161AE8_002d9810 __asm__("D_L00_00161AE8") __attribute__((sda));
extern float D_L00_00161AEC_002d9810 __asm__("D_L00_00161AEC") __attribute__((sda));
extern char D_L00_00161AF0_002d9810[] __asm__("D_L00_00161AF0") __attribute__((section(".data")));
-extern char D_L00_00166DC0_002d9810[] __asm__("D_L00_00166DC0");
+extern char g_debug_camera[] __asm__("D_L00_00166DC0");
extern char D_L00_001E14C0_002d9810[] __asm__("D_L00_001E14C0");
extern char D_L00_001E3DA0_002d9810[] __asm__("D_L00_001E3DA0");
extern char D_L00_001E2FF0_002d9810[] __asm__("D_L00_001E2FF0");
@@ -878,7 +878,7 @@ void FUN_L00_002d9810(u8 *m) {
((float *)&position)[2] += data[0];
((float *)&position)[3] = 1.0f;
FUN_001f9a10_002d9810(&position, &position, D_L00_00161AF0_002d9810);
- FUN_001f9a28_002d9810(&rotated, D_L00_00166DC0_002d9810, &position);
+ FUN_001f9a28_002d9810(&rotated, g_debug_camera, &position);
FUN_001f9bf8_002d9810(1.0f, shiftedVector, &rotated);
shape = *(char **)((char *)data + 0xc);
FUN_001f9ad8_002d9810(&cross, shiftedVector, shape + 0xe0);
@@ -975,7 +975,7 @@ void FUN_L00_002d9810(u8 *m) {
for (j = 3; j >= 0; j--) {
FUN_001f9d20_002d9810(source, D_L00_001E3B80_002d9810 + (*indices++) * 16,
shiftedVector);
- FUN_001f9a28_002d9810(projection, source, D_L00_00166DC0_002d9810);
+ FUN_001f9a28_002d9810(projection, source, g_debug_camera);
source += 16;
projection[1] = projection[2];
FUN_001f9c48_002d9810(D_L00_00161AE8_002d9810, projection, projection);
@@ -1127,8 +1127,7 @@ typedef struct {
char p1[0x350 - 0x15C];
char m350[0x40];
} C_002da250;
-extern C_002da250 D_L00_00166C80_002da250 __asm__("D_L00_00166C80")
- __attribute__((section(".data")));
+extern char D_L00_00166C80[] __attribute__((section(".data")));
typedef struct {
f32 x, y, z, w;
} __attribute__((aligned(16))) V_002da250;
@@ -1138,7 +1137,7 @@ void FUN_L00_002da250(u8 *a, f32 *b, f32 *c, f32 *d) {
FUN_L00_0024f7c8_002da250(a, 0, d);
if (hero_data.state.current == 1 || hero_data.state.current == 0x1E) {
V_002da250 v;
- C_002da250 *cam = &D_L00_00166C80_002da250;
+ C_002da250 *cam = &(*(C_002da250 *)D_L00_00166C80);
v.y = 0;
v.x = 1.2f;
*b = cam->f158;
@@ -1986,181 +1985,188 @@ s32 FUN_L00_002dbe20(u8 *m) {
}
return 0;
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L00_002dbf28.s", FUN_L00_002dbf28);
-#else
-extern u128 D_L00_001EA0B0_002dbf28[] __asm__("D_L00_001EA0B0");
-extern u8 D_L00_001EA100_002dbf28[] __asm__("D_L00_001EA100");
-extern u8 D_L00_001EA118_002dbf28[] __asm__("D_L00_001EA118");
-extern char D_L00_00166DC0_002dbf28[] __asm__("D_L00_00166DC0");
-extern char D_L00_00177F00_002dbf28[] __asm__("D_L00_00177F00");
-extern float FUN_001fa6c0_002dbf28(int) __asm__("FUN_001fa6c0");
-extern int FUN_001fa6d0_002dbf28(float) __asm__("FUN_001fa6d0");
-extern void FUN_001f9a68_002dbf28(float, void *, void *) __asm__("FUN_001f9a68");
-extern void FUN_001f9a28_002dbf28(void *, void *, void *) __asm__("FUN_001f9a28");
-extern void FUN_001f9c90_002dbf28(void *, void *, float) __asm__("FUN_001f9c90");
-extern float fast_vec_dot(void *, void *) __asm__("FUN_001f9ab0");
-extern void FUN_001f9bf8_002dbf28(float, void *, void *) __asm__("FUN_001f9bf8");
-extern void FUN_001f9a10_002dbf28(void *, void *, void *) __asm__("FUN_001f9a10");
-extern float fast_vec_length(void *) __asm__("FUN_001f9af0");
-extern float FUN_002132a8_002dbf28(float, float) __asm__("FUN_002132a8");
-extern int FUN_00213260_002dbf28(int) __asm__("FUN_00213260");
-extern int FUN_001f96f8_002dbf28(int) __asm__("FUN_001f96f8");
-extern int FUN_L00_00257b90_002dbf28(int, int) __asm__("FUN_L00_00257b90");
-extern void FUN_L00_002af450_002dbf28(void *, void *, int, int, int) __asm__("FUN_L00_002af450");
-extern int FUN_L00_0025c0e8_002dbf28(int, int) __asm__("FUN_L00_0025c0e8");
-extern void FUN_L00_0025c088_002dbf28(int *, int *, int *, int) __asm__("FUN_L00_0025c088");
-extern void FUN_L00_0026a9f0_002dbf28(float, float, void *, void *, int, int, int, int, int, int) __asm__("FUN_L00_0026a9f0");
-extern void FUN_L00_002df808_002dbf28(float, void *, void *, void *, int, int, int, int, int) __asm__("FUN_L00_002df808");
-extern void FUN_L00_002d3838_002dbf28(void *, void *, int, int) __asm__("FUN_L00_002d3838");
-extern int FUN_L00_001f2868_002dbf28(float, void *, int, void *, int) __asm__("FUN_L00_001f2868");
-extern void FUN_L00_0025a9f8_002dbf28(float, float, float, void *, void *, void *, int, int, int, int, int) __asm__("FUN_L00_0025a9f8");
+/* Explosion burst for a moby: debris sprays, sparks, coloured flashes, camera shake and an optional damage area. */
+/* Ported from rac1-decomp (src/overlays/shared/vendor_002D9438.c: func_L00_002DD3D8), where it is exact; names translated to the US level program. */
-typedef struct {
- char pad[0x160];
- float f160;
- int i164, i168;
-} G_002dbf28;
-extern G_002dbf28 D_L00_00166C80_002dbf28 __asm__("D_L00_00166C80");
-
-void FUN_L00_002dbf28(char *moby) {
- u128 matrix[5];
- Q_WORDDATA origin, position, axis, temporary, scaled, displacement;
- u32 first_colors[8], second_colors[8];
- float magnitude, range, deficit, speed;
- int multiplier, count, i, a, b, red, green, blue;
- char *center;
- G_002dbf28 *owner;
-
- __builtin_memcpy(matrix, D_L00_001EA0B0_002dbf28, 80);
- axis.ul128 = 0;
- axis.fl32[2] = frame_time + frame_time;
- position.ul128 = axis.ul128;
- axis.ul128 = 0;
- axis.fl32[2] = 1.0f;
- center = moby + 0x10;
- magnitude = FUN_001fa6c0_002dbf28(item_text_variant.b9) + 1.0f;
- multiplier = 1;
- if (!item_text_variant.b9) multiplier = 2;
- FUN_001f9a68_002dbf28(magnitude, &position, &position);
- FUN_001f9a28_002dbf28(&origin, D_L00_00166DC0_002dbf28, center);
- range = fast_vec_length(&origin);
+typedef int u128_DD3D8 __attribute__((mode(TI)));
+
+typedef struct { u128_DD3D8 v[5]; } B50_DD3D8;
+
+typedef struct { int v[6]; } I6_DD3D8;
+typedef struct { char p0[0x160]; float f160; int p164; int i168; } Cam_DD3D8;
+
+extern B50_DD3D8 D_L00_001EA0B0;
+extern I6_DD3D8 D_L00_001EA100;
+extern I6_DD3D8 D_L00_001EA118;
+extern char *FUN_L00_002af450(char *, char *, int, int, int);
+extern char *FUN_L00_002d3838(char *, char *, int, char *);
+extern f32 fast_vec_dot(void *a, void *b) __asm__("func_001F9AB0");
+extern f32 fast_vec_length(void *) __asm__("func_001F9AF0");
+extern float D_0015ED6C;
+extern int *D_L00_00177F00[];
+extern int FUN_L00_001f2868();
+extern int FUN_L00_00257b90_c(int, int) __asm__("FUN_L00_00257b90");
+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_c2(f32) __asm__("func_001FA6D0");
+extern unsigned FUN_L00_0025c0e8(unsigned, int);
+extern void FUN_L00_0025a9f8(void *, void *, void *, int, int, int, int, int, float, float, float);
+extern void FUN_L00_0025c088(int *, int *, int *, int);
+extern void FUN_L00_0026a9f0(void *, void *, int, int, float, int, int, int, int, float);
+extern void clamp_vector_length(void *, void *, float) __asm__("FUN_001f9c90");
+extern void fast_vec_normalize_c(void *, void *, f32) __asm__("FUN_001f9bf8");
+extern void fast_vec_scale_c(void *, void *, f32) __asm__("func_001F9A68");
+extern void subtract_vector_xyz_c3(void *, void *, void *) __asm__("FUN_001f9a28");
+unsigned char *FUN_L00_002df808(int owner, void *position, void *vector, int flags, unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha, float scale);
+extern int func_001FA898_r(float) __asm__("FUN_001fa6d0");
+extern char *func_L00_002E0CB8_DD3D8(float, void *, void *, void *, int, unsigned char, unsigned char, unsigned char, unsigned char) __asm__("FUN_L00_002df808");
+extern char D_L00_00166C80[];
+extern int func_L00_001F2BE8_DD3D8(float, void *, int, void *, void *) __asm__("FUN_L00_001f2868");
+
+void FUN_L00_002dbf28(char *self, char *q) {
+ B50_DD3D8 blk;
+ float a[4];
+ float b[4];
+ float c[4];
+ float d[4];
+ float e[4];
+ float g[4];
+ I6_DD3D8 t1;
+ I6_DD3D8 t2;
+ int r0, g0, b0;
+ int r1, g1, b1;
+ float f22, dist, f24, sc, dt;
+ int step, i, j, k;
+
+ blk = D_L00_001EA0B0;
+ *(u128_DD3D8 *)c = 0;
+ c[2] = D_0015ED6C + D_0015ED6C;
i = 0;
- if (10 / multiplier > 0) do {
- int a, b;
- displacement.ul128 = 0;
- displacement.fl32[0] = FUN_002132a8_002dbf28(-1.0f, 1.0f);
- displacement.fl32[1] = FUN_002132a8_002dbf28(-1.0f, 1.0f);
- scaled.ul128 = displacement.ul128;
- FUN_001f9bf8_002dbf28(fast_vec_dot(&scaled, &axis), &temporary, &axis);
- FUN_001f9a28_002dbf28(&scaled, &scaled, &temporary);
- FUN_001f9bf8_002dbf28(FUN_002132a8_002dbf28(0.0f, 1.0f), &temporary, &axis);
- FUN_001f9a10_002dbf28(&scaled, &scaled, &temporary);
- speed = magnitude * FUN_002132a8_002dbf28(3.5f, 6.5f);
- FUN_001f9bf8_002dbf28(speed * frame_time, &scaled, &scaled);
- FUN_001f9a10_002dbf28(&scaled, &scaled, &position);
- a = FUN_001f96f8_002dbf28(60);
- b = FUN_001f96f8_002dbf28(120);
- FUN_L00_002af450_002dbf28(center, &scaled, FUN_L00_00257b90_002dbf28(a, b), 0, item_text_variant.b9);
- i++;
- } while (i < 10 / multiplier);
- for (i = 0; i < 4 / multiplier; i++) {
- int a, b;
- displacement.ul128 = 0;
- displacement.fl32[0] = FUN_002132a8_002dbf28(-1.0f, 1.0f);
- displacement.fl32[1] = FUN_002132a8_002dbf28(-1.0f, 1.0f);
- scaled.ul128 = displacement.ul128;
- FUN_001f9bf8_002dbf28(fast_vec_dot(&scaled, &axis), &temporary, &axis);
- FUN_001f9a28_002dbf28(&scaled, &scaled, &temporary);
- FUN_001f9bf8_002dbf28(FUN_002132a8_002dbf28(0.0f, 1.0f), &temporary, &axis);
- FUN_001f9a10_002dbf28(&scaled, &scaled, &temporary);
- deficit = magnitude * FUN_002132a8_002dbf28(6.5f, 10.0f);
- FUN_001f9bf8_002dbf28(deficit * frame_time, &scaled, &scaled);
- FUN_001f9a10_002dbf28(&scaled, &scaled, &position);
- a = FUN_001f96f8_002dbf28(60);
- b = FUN_001f96f8_002dbf28(90);
- FUN_L00_002af450_002dbf28(center, &scaled, FUN_L00_00257b90_002dbf28(a, b), 1, item_text_variant.b9);
+ *(u128_DD3D8 *)b = *(u128_DD3D8 *)c;
+ *(u128_DD3D8 *)c = 0;
+ c[2] = 1.0f;
+ f22 = convert_integer_to_float((&D_0013E520)->b9) + 1.0f;
+ step = 1;
+ if ((&D_0013E520)->b9 == 0) step = 2;
+ fast_vec_scale_c(b, b, f22);
+ subtract_vector_xyz_c3(a, D_L00_00166DC0, self + 0x10);
+ dist = fast_vec_length(a);
+ for (; i < 10 / step; i++) {
+ *(u128_DD3D8 *)g = 0;
+ g[0] = random_float_between(-1.0f, 1.0f);
+ g[1] = random_float_between(-1.0f, 1.0f);
+ *(u128_DD3D8 *)e = *(u128_DD3D8 *)g;
+ dt = fast_vec_dot(e, c);
+ fast_vec_normalize_c(d, c, dt);
+ subtract_vector_xyz_c3(e, e, d);
+ fast_vec_normalize_c(d, c, random_float_between(0.0f, 1.0f));
+ add_vector_xyz(e, e, d);
+ fast_vec_normalize_c(e, e, f22 * random_float_between(3.5f, 6.5f) * D_0015ED6C);
+ add_vector_xyz(e, e, b);
+ {
+ int h = scale_game_frames_c(60);
+ FUN_L00_002af450(self + 0x10, (char *)e, FUN_L00_00257b90_c(h, scale_game_frames_c(120)), 0, (&D_0013E520)->b9);
+ }
+ }
+ for (j = 0; j < 4 / step; j++) {
+ *(u128_DD3D8 *)g = 0;
+ g[0] = random_float_between(-1.0f, 1.0f);
+ g[1] = random_float_between(-1.0f, 1.0f);
+ *(u128_DD3D8 *)e = *(u128_DD3D8 *)g;
+ dt = fast_vec_dot(e, c);
+ fast_vec_normalize_c(d, c, dt);
+ subtract_vector_xyz_c3(e, e, d);
+ fast_vec_normalize_c(d, c, random_float_between(0.0f, 1.0f));
+ add_vector_xyz(e, e, d);
+ fast_vec_normalize_c(e, e, f22 * random_float_between(6.5f, 10.0f) * D_0015ED6C);
+ add_vector_xyz(e, e, b);
+ {
+ int h = scale_game_frames_c(60);
+ FUN_L00_002af450(self + 0x10, (char *)e, FUN_L00_00257b90_c(h, scale_game_frames_c(90)), 1, (&D_0013E520)->b9);
+ }
+ }
+ *(u128_DD3D8 *)g = 0;
+ g[0] = random_float_between(-1.0f, 1.0f);
+ g[1] = random_float_between(-1.0f, 1.0f);
+ g[2] = random_float_between(-1.0f, 1.0f);
+ *(u128_DD3D8 *)e = *(u128_DD3D8 *)g;
+ a[2] += dist * 0.5f;
+ fast_vec_normalize_c(e, e, dist / 5.0f * D_0015ED6C);
+ fast_vec_normalize_c(a, a, (dist + dist) * D_0015ED6C);
+ add_vector_xyz(e, e, a);
+ clamp_vector_length(e, e, D_0015ED6C * 10.0f);
+ {
+ int h = scale_game_frames_c(60);
+ FUN_L00_002af450(self + 0x10, (char *)e, FUN_L00_00257b90_c(h, scale_game_frames_c(90)), 1, (&D_0013E520)->b9);
+ }
+ if (dist < 6.0f) {
+ k = func_001FA898_r(dist) + 1;
+ } else {
+ k = 4;
+ }
+ f24 = 0.0f;
+ if (dist < 7.0f) {
+ f24 = 7.0f - dist;
+ }
+ if (k > 0) {
+ int cnt = k;
+ do {
+ float sh = f22 * random_float_between(8.0f, 10.0f) * D_0015ED6C - f24 * D_0015ED6C;
+ int A, B, r1, r2;
+ float big;
+ t1 = D_L00_001EA100;
+ t2 = D_L00_001EA118;
+ A = FUN_L00_0025c0e8(t1.v[random_integer_below_c2(6)], (&D_0013E520)->b9);
+ B = FUN_L00_0025c0e8(t2.v[random_integer_below_c2(6)], (&D_0013E520)->b9);
+ big = f22 * 400000.0f;
+ r1 = FUN_L00_00257b90_c(scale_game_frames_c(15), scale_game_frames_c(20));
+ r2 = FUN_L00_00257b90_c(scale_game_frames_c(25), scale_game_frames_c(30));
+ FUN_L00_0026a9f0(self + 0x10, b, A, B, big, r1, r2, 0, 0, sh);
+ } while (--cnt);
}
- deficit = range + range;
- displacement.ul128 = 0;
- displacement.fl32[0] = FUN_002132a8_002dbf28(-1.0f, 1.0f);
- displacement.fl32[1] = FUN_002132a8_002dbf28(-1.0f, 1.0f);
- displacement.fl32[2] = FUN_002132a8_002dbf28(-1.0f, 1.0f);
- origin.fl32[2] += range * 0.5f;
- scaled.ul128 = displacement.ul128;
- FUN_001f9bf8_002dbf28((range / 5.0f) * frame_time, &scaled, &scaled);
- FUN_001f9bf8_002dbf28(deficit * frame_time, &origin, &origin);
- FUN_001f9a10_002dbf28(&scaled, &scaled, &origin);
- FUN_001f9c90_002dbf28(&scaled, &scaled, frame_time * 10.0f);
- a = FUN_001f96f8_002dbf28(60);
- b = FUN_001f96f8_002dbf28(90);
- FUN_L00_002af450_002dbf28(center, &scaled, FUN_L00_00257b90_002dbf28(a, b), 1, item_text_variant.b9);
-
- count = 4;
- if (range < 6.0f) count = FUN_001fa6d0_002dbf28(range) + 1;
- deficit = 0.0f;
- if (range < 7.0f) deficit = 7.0f - range;
- for (i = 0; i < count; i++) {
- int a, b;
- int red, green, blue;
- float effect_magnitude;
- float speed;
- speed = FUN_002132a8_002dbf28(8.0f, 10.0f);
- __builtin_memcpy(first_colors, D_L00_001EA100_002dbf28, 24);
- __builtin_memcpy(second_colors, D_L00_001EA118_002dbf28, 24);
- speed = magnitude * speed * frame_time - deficit * frame_time;
- a = FUN_00213260_002dbf28(6);
- red = FUN_L00_0025c0e8_002dbf28(first_colors[a], item_text_variant.b9);
- a = FUN_00213260_002dbf28(6);
- green = FUN_L00_0025c0e8_002dbf28(second_colors[a], item_text_variant.b9);
- effect_magnitude = magnitude * 400000.0f;
- a = FUN_001f96f8_002dbf28(15);
- b = FUN_001f96f8_002dbf28(20);
- blue = FUN_L00_00257b90_002dbf28(a, b);
- a = FUN_001f96f8_002dbf28(25);
- b = FUN_001f96f8_002dbf28(30);
- FUN_L00_0026a9f0_002dbf28(effect_magnitude, speed, center, &position,
- red, green, blue, FUN_L00_00257b90_002dbf28(a, b), 0, 0);
+ if (dist > 9.0f) {
+ float size = f22 * 4.0f;
+ func_L00_002E0CB8_DD3D8(size, self, self + 0x10, b, scale_game_frames_c(15), 0x7F, 0x7F, 0x7F, 0x20);
+ r0 = 0x7F;
+ g0 = 0x20;
+ b0 = 0;
+ FUN_L00_0025c088(&r0, &g0, &b0, (&D_0013E520)->b9);
+ func_L00_002E0CB8_DD3D8(size, self, self + 0x10, b, scale_game_frames_c(24), r0, g0, b0, 0x20);
}
- if (range > 9.0f) {
- int effect_red, effect_green, effect_blue;
- speed = magnitude * 4.0f;
- a = FUN_001f96f8_002dbf28(15);
- FUN_L00_002df808_002dbf28(speed, moby, center, &position, a, 127, 127, 127, 32);
- effect_red = 127; effect_green = 32; effect_blue = 0;
- FUN_L00_0025c088_002dbf28(&effect_red, &effect_green, &effect_blue, item_text_variant.b9);
- a = FUN_001f96f8_002dbf28(24);
- FUN_L00_002df808_002dbf28(speed, moby, center, &position, a, (u8)effect_red, (u8)effect_green, (u8)effect_blue, 32);
+ r1 = 0x7F;
+ g1 = 0x3F;
+ b1 = 0;
+ FUN_L00_0025c088(&r1, &g1, &b1, (&D_0013E520)->b9);
+ {
+ float s = f22 * 4.0f;
+ func_L00_002E0CB8_DD3D8(s, self, self + 0x10, b, scale_game_frames_c(20), r1, g1, b1, 0x30);
+ }
+ r1 = 0x60;
+ g1 = 0x10;
+ b1 = 0;
+ FUN_L00_0025c088(&r1, &g1, &b1, (&D_0013E520)->b9);
+ {
+ float s = f22 * 3.5f;
+ func_L00_002E0CB8_DD3D8(s, self, self + 0x10, b, scale_game_frames_c(27), r1, g1, b1, 0x40);
}
- red = 127; green = 63; blue = 0;
- FUN_L00_0025c088_002dbf28(&red, &green, &blue, item_text_variant.b9);
- speed = magnitude * 4.0f;
- a = FUN_001f96f8_002dbf28(20);
- FUN_L00_002df808_002dbf28(speed, moby, center, &position, a, (u8)red, (u8)green, (u8)blue, 48);
- red = 96; green = 16; blue = 0;
- FUN_L00_0025c088_002dbf28(&red, &green, &blue, item_text_variant.b9);
- speed = magnitude * 3.5f;
- a = FUN_001f96f8_002dbf28(27);
- FUN_L00_002df808_002dbf28(speed, moby, center, &position, a, (u8)red, (u8)green, (u8)blue, 64);
- red = 32; green = 0; blue = 0;
- FUN_L00_0025c088_002dbf28(&red, &green, &blue, item_text_variant.b9);
- speed = magnitude * 3.0f;
- a = FUN_001f96f8_002dbf28(29);
- FUN_L00_002df808_002dbf28(speed, moby, center, &position, a, (u8)red, (u8)green, (u8)blue, 32);
- owner = &D_L00_00166C80_002dbf28;
- if (range < 20.0f) owner->f160 = 0.4f - range * 0.0175f;
- else owner->f160 = 0.050000012f;
- D_L00_00166C80_002dbf28.i168 = FUN_001f96f8_002dbf28(25);
- FUN_L00_002d3838_002dbf28(matrix, center, 0, 0);
- if (item_text_variant.b9) {
- a = FUN_L00_001f2868_002dbf28(3.0f, center, 16, moby, 0);
- scaled.ul128 = *(u128 *)(moby + 0x10);
- FUN_L00_0025a9f8_002dbf28(2.0f, 1.0f, 1.0f, moby, &scaled,
- D_L00_00177F00_002dbf28, a, 0, 0x830000, 2, 1);
+ r1 = 0x20;
+ g1 = 0;
+ b1 = 0;
+ FUN_L00_0025c088(&r1, &g1, &b1, (&D_0013E520)->b9);
+ {
+ float s = f22 * 3.0f;
+ func_L00_002E0CB8_DD3D8(s, self, self + 0x10, b, scale_game_frames_c(29), r1, g1, b1, 0x20);
+ }
+ (*(Cam_DD3D8 *)D_L00_00166C80).f160 = (dist < 20.0f) ? 0.4f - dist * 0.0175f : 0.050000012f;
+ (*(Cam_DD3D8 *)D_L00_00166C80).i168 = scale_game_frames_c(25);
+ FUN_L00_002d3838((char *)&blk, self + 0x10, 0, 0);
+ if ((&D_0013E520)->b9) {
+ k = func_L00_001F2BE8_DD3D8(3.0f, self + 0x10, 0x10, self, 0);
+ *(u128_DD3D8 *)e = *(u128_DD3D8 *)(self + 0x10);
+ FUN_L00_0025a9f8(self, e, D_L00_00177F00, k, 0, 0x830000, 2, 1, 2.0f, 1.0f, 1.0f);
}
}
-#endif
#include "qzero.h"
typedef struct {
int v[16];
@@ -2277,7 +2283,7 @@ void FUN_L00_00258ad0(int a, int b, float x, float y, int c, int d);
void FUN_L00_0026c3d0(void *pos, void *mat);
void FUN_L00_002dc938_c(char *p, char *q, int flag) __asm__("FUN_L00_002dc938");
void no_op_main_callback(void *) __asm__("FUN_001e93e8");
-extern float D_0015EE60_2DDEA0 __asm__("D_0015ED60") __attribute__((section(".sdata")));
+extern float frame_scale __asm__("D_0015ED60") __attribute__((section(".sdata")));
extern float frame_scale_sq_macro __asm__("D_0015ED64") __attribute__((section(".sdata")));
extern float frame_time_sq_macro __asm__("D_0015ED70") __attribute__((section(".sdata")));
extern unsigned char D_0013E629_2DDEA0[] __asm__("D_0013E529");
@@ -2285,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 char D_L00_00173F40_2DDEA0[] __asm__("D_L00_00173E40");
+extern int D_L00_00173E40[];
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");
@@ -2351,7 +2357,7 @@ int FUN_L00_002dc9f0(struct Moby *moby, char *vars) {
float yaw, tolerance;
tolerance = 0.01f;
yaw = func_001FA748_2DDEA0(func_L00_001FF860_2DDEA0(record->x - moby->pos.x, record->y - moby->pos.y), 3.1415927f);
- func_L00_002592B0_2DDEA0(moby, vars + 0x44, yaw, frame_scale_sq_macro * 0.19634955f, frame_scale_sq_macro * 0.19634955f, D_0015EE60_2DDEA0 * 0.3927f);
+ func_L00_002592B0_2DDEA0(moby, vars + 0x44, yaw, frame_scale_sq_macro * 0.19634955f, frame_scale_sq_macro * 0.19634955f, frame_scale * 0.3927f);
if (func_001FA790_2DDEA0(yaw, tolerance) < moby->rot.z && moby->rot.z < func_001FA748_2DDEA0(yaw, tolerance)) {
record->state = 2;
record->f6C = 0.0f;
@@ -2363,7 +2369,7 @@ int FUN_L00_002dc9f0(struct Moby *moby, char *vars) {
moby->anim_speed = record->f6C + 1.0f;
record->f6C = record->f6C + 1.0f / func_001FA888_2DDEA0(func_001F9850_2DDEA0(1));
if (1.0f < record->f6C) record->f6C = 1.0f;
- moby->pos.z += record->f6C / 100.0f * D_0015EE60_2DDEA0;
+ moby->pos.z += record->f6C / 100.0f * frame_scale;
func_00215328_2DDEA0(&record->q20, &moby->rot_row0);
func_001F9BC0_2DDEA0(&record->vel);
break;
@@ -2393,7 +2399,7 @@ int FUN_L00_002dc9f0(struct Moby *moby, char *vars) {
distance = func_001F9D48_2DDEA0(&moby->pos, &work.v[0]);
moby->scale = ((Cls_2DDEA0 *)moby->pclass)->f24 * (distance / (record->f64 + record->f64) + half);
record->f98 = record->f98 + frame_scale_sq_macro * 0.11f;
- if (D_0015EE60_2DDEA0 * 0.75f < record->f98) record->f98 = D_0015EE60_2DDEA0 * 0.75f;
+ if (frame_scale * 0.75f < record->f98) record->f98 = frame_scale * 0.75f;
if (distance < record->f98 * 70.0f) {
func_00213DE0_2DDEA0(record->owner, 4, 0, func_001F9850_2DDEA0(2));
}
@@ -2458,7 +2464,7 @@ int FUN_L00_002dc9f0(struct Moby *moby, char *vars) {
return 0;
}
work.q = *(u128 *)&record->vel;
- moby->scale = moby->scale + ((Cls_2DDEA0 *)moby->pclass)->f24 * (record->f7C * D_0015EE60_2DDEA0);
+ moby->scale = moby->scale + ((Cls_2DDEA0 *)moby->pclass)->f24 * (record->f7C * frame_scale);
if (((Cls_2DDEA0 *)moby->pclass)->f24 < moby->scale) moby->scale = ((Cls_2DDEA0 *)moby->pclass)->f24;
if (record->target != 0 && record->target->state != 0xFE && record->target->state != 0xFD) {
int max_life = func_001F9850_2DDEA0(0x12C);
@@ -2509,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_00173F40_2DDEA0)->v30);
- func_001F9BF0_2DDEA0(&record->v50, &((Coll_2DDEA0 *)D_L00_00173F40_2DDEA0)->v20, &moby->pos);
+ qcopy_nc(&moby->pos, &((Coll_2DDEA0 *)D_L00_00173E40)->v30);
+ func_001F9BF0_2DDEA0(&record->v50, &((Coll_2DDEA0 *)D_L00_00173E40)->v20, &moby->pos);
}
- if (((Coll_2DDEA0 *)D_L00_00173F40_2DDEA0)->hit != 0 && ((Coll_2DDEA0 *)D_L00_00173F40_2DDEA0)->hit->oclass == 0) hit_wall = 0;
+ if (((Coll_2DDEA0 *)D_L00_00173E40)->hit != 0 && ((Coll_2DDEA0 *)D_L00_00173E40)->hit->oclass == 0) hit_wall = 0;
if (record->state == 6) {
moby->flags &= 0x7FFF;
moby->collision = ((Cls_2DDEA0 *)moby->pclass)->i10;
@@ -2537,17 +2543,17 @@ int FUN_L00_002dc9f0(struct Moby *moby, char *vars) {
}
if (hit_wall != 0) {
surface = 0;
- if (((Coll_2DDEA0 *)D_L00_00173F40_2DDEA0)->hit != 0 && ((Cls_2DDEA0 *)((Coll_2DDEA0 *)D_L00_00173F40_2DDEA0)->hit->pclass) != 0) {
- surface = ((Cls_2DDEA0 *)((Coll_2DDEA0 *)D_L00_00173F40_2DDEA0)->hit->pclass)->h46;
+ 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;
}
- func_L00_001FF4B0_2DDEA0(&((Coll_2DDEA0 *)D_L00_00173F40_2DDEA0)->v40, &((Coll_2DDEA0 *)D_L00_00173F40_2DDEA0)->v40, 1.0f);
+ func_L00_001FF4B0_2DDEA0(&((Coll_2DDEA0 *)D_L00_00173E40)->v40, &((Coll_2DDEA0 *)D_L00_00173E40)->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_00173F40_2DDEA0)->v40.z, func_001F9CE8_2DDEA0(&((Coll_2DDEA0 *)D_L00_00173F40_2DDEA0)->v40))) {
+ if (0.87266463f < func_L00_001FF860_2DDEA0(((Coll_2DDEA0 *)D_L00_00173E40)->v40.z, func_001F9CE8_2DDEA0(&((Coll_2DDEA0 *)D_L00_00173E40)->v40))) {
if (record->h9E >= 0) func_0022ED80_2DDEA0(record->h9E, 0, moby);
func_L00_002DDDE8_2DDEA0(moby, record, 1);
return 0;
@@ -2557,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_00173F40_2DDEA0)->v40.z;
+ work.v[1].z = ((Coll_2DDEA0 *)D_L00_00173E40)->v40.z;
func_L00_001FF610_2DDEA0(&record->vel, &record->vel, &work.v[1]);
}
if (func_001F9908_2DDEA0(&record->i94) != 0) {
@@ -2568,7 +2574,7 @@ int FUN_L00_002dc9f0(struct Moby *moby, char *vars) {
func_L00_002DDDE8_2DDEA0(moby, record, 1);
return 0;
}
- if (func_001F9CB8_2DDEA0(&record->vel) < D_0015EE60_2DDEA0 * 0.01f) {
+ if (func_001F9CB8_2DDEA0(&record->vel) < frame_scale * 0.01f) {
func_L00_002DDDE8_2DDEA0(moby, record, 1);
return 0;
}
@@ -2613,206 +2619,194 @@ int FUN_L00_002dc9f0(struct Moby *moby, char *vars) {
}
return 0;
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L00_002dd8e8.s", FUN_L00_002dd8e8);
-#else
+/* Ported from rac1-decomp (src/overlays/shared/vendor_002D9438.c: func_L00_002DED98), where it is exact; names translated to the US level program. */
+
typedef struct {
- u128 points[4];
- u32 colors[4];
- float texcoords[8];
- u64 texture[4];
-} __attribute__((aligned(16))) Quad_002dd8e8;
-extern float D_L00_00161B48_002dd8e8 __asm__("D_L00_00161B48") __attribute__((section(".data")));
-extern char D_L00_001E6020_lui[] __asm__("D_L00_001E6020") __attribute__((section(".data")));
-extern char D_L00_001E5EE0_002dd8e8[] __asm__("D_L00_001E5EE0") __attribute__((section(".data")));
-u64 FUN_001f9298_002dd8e8(int) __asm__("FUN_L00_001f9298");
-void FUN_001ff2a8_002dd8e8(void *, void *, void *) __asm__("FUN_L00_001ff2a8");
-void FUN_001ff3c0_002dd8e8(void *, void *, void *) __asm__("FUN_L00_001ff3c0");
-float FUN_001ff398_002dd8e8(void *, void *) __asm__("FUN_L00_001ff398");
-void FUN_001fd228_002dd8e8(void *, int, int) __asm__("FUN_L00_001fd228");
-void FUN_002a0ba8_002dd8e8(int, int) __asm__("FUN_L00_002a0ba8");
+ float q[4][4];
+ unsigned int col[4];
+ float x0, y0, x1, y1, x2, y2, x3, y3;
+ long word0, word1, word2, word3;
+} Pkt;
+
+extern char g_debug_camera[] __asm__("D_L00_00166DC0") __attribute__((section(".data")));
+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_00161B50 __attribute__((sda));
+extern short D_L00_001E6008[] __attribute__((section(".data")));
+extern void fast_draw_quad_real(void *, void *, int);
+extern void subtract_vector_xyz_c4(void *, void *, void *) __asm__("FUN_001f9a28");
+extern void vu1_add_g_sregister(s32, u64) __asm__("func_00233980");
void FUN_L00_002dd8e8(void) {
- Quad_002dd8e8 quad;
- u128 following, edge, outward, normal;
- float phase, next_phase, offset, step, dot;
- float previous_phase, wrapped_phase;
- int row, segment, next_segment, value, previous_value;
- int current, segment_offset;
- char *prior; u32 *colors;
-
- quad.texture[1] = FUN_001f9298_002dd8e8(0x15);
- quad.texture[3] = 0x8000000048ULL;
- quad.texture[2] = 0xff9000000260ULL;
- quad.texture[0] = 0;
- phase = ((float *)&D_L00_00161B48_002dd8e8)[-2];
- wrapped_phase = phase + 0.001f;
- if (wrapped_phase > 7.0f) wrapped_phase -= 7.0f;
- ((float *)&D_L00_00161B48_002dd8e8)[-2] = wrapped_phase;
- step = 0.05f;
- for (row = 1; row < 10; row++) {
- offset = ((float *)&D_L00_00161B48_002dd8e8)[-1];
- phase += 0.3f;
- ((float *)&D_L00_00161B48_002dd8e8)[-1] += D_L00_00161B48_002dd8e8;
- if (((float *)&D_L00_00161B48_002dd8e8)[-1] > 7.0f)
- ((float *)&D_L00_00161B48_002dd8e8)[-1] -= 7.0f;
- next_phase = phase + 0.3f;
- current = row * 0x140;
- prior = D_L00_001E5EE0_002dd8e8;
- for (segment = 0; segment < 20; segment++) {
- segment_offset = segment * 16;
- qcopy(&quad.points[0], D_L00_001E6020_lui + (current + segment_offset));
- next_segment = ((segment + 1) % 20) * 16;
- qcopy(&quad.points[1], D_L00_001E6020_lui + (current + next_segment));
- qcopy(&quad.points[2], prior + (current + segment_offset));
- qcopy(&quad.points[3], prior + (current + next_segment));
- FUN_001ff2a8_002dd8e8(&edge, &quad.points[0], &quad.points[1]);
- FUN_001ff2a8_002dd8e8(&outward, &quad.points[2], &quad.points[1]);
- FUN_001ff3c0_002dd8e8(&normal, &outward, &edge);
- FUN_001ff2a8_002dd8e8(&following, &quad.points[1], g_debug_camera);
- dot = FUN_001ff398_002dd8e8(&normal, &following);
+ Pkt s;
+ float vc[4];
+ float vd[4];
+ float ve[4];
+ float vf[4];
+ float a, a2, am, b, b2, dot;
+ float step;
+ short *pv;
+ int i, j, k, v;
+ unsigned short y;
+ s.word1 = get_effect_texture(0x15);
+ s.word2 = 0x0000FF9000000260L;
+ s.word3 = 0x8000000048L;
+ s.word0 = 0;
+ a = D_L00_00161B48;
+ D_L00_00161B48 = a + 0.001f;
+ if (D_L00_00161B48 > 7.0f) D_L00_00161B48 -= 7.0f;
+ 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;
+ a2 = a + step;
+ for (j = 0; j < 20; j++) {
+ qcopy(s.q[0], D_L00_001E6020 + (j * 16 + i * 0x140));
+ qcopy(s.q[1], D_L00_001E6020 + ((j + 1) % 20 * 16 + i * 0x140));
+ qcopy(s.q[2], D_L00_001E5EE0 + (j * 16 + i * 0x140));
+ qcopy(s.q[3], D_L00_001E5EE0 + ((j + 1) % 20 * 16 + i * 0x140));
+ subtract_vector_xyz_c4(vc, s.q[0], s.q[1]);
+ subtract_vector_xyz_c4(vd, s.q[2], s.q[1]);
+ cross_vectors_xyz(ve, vd, vc);
+ subtract_vector_xyz_c4(vf, s.q[1], g_debug_camera);
+ dot = fast_vec_dot(ve, vf);
if (0.0f <= dot) {
- offset += step;
- continue;
+ b += 0.05f;
+ } else {
+ b2 = b + 0.05f;
+ am = a - step;
+ y = D_L00_001E6008[i - 1];
+ pv = &D_L00_001E6008[i];
+ v = *pv;
+ for (k = 0; k < 2; k++) {
+ if (v < 0) v = 0;
+ if (v > 0x40) v = 0x40;
+ v = (v << 24) | 0x404040;
+ s.col[k * 2] = v;
+ s.col[k * 2 + 1] = v;
+ v = (short)y;
+ }
+ if (i == 1) {
+ s.col[3] = 0x20404040;
+ s.col[2] = 0x20404040;
+ } else if (i == 9) {
+ s.col[1] = 0x404040;
+ s.col[0] = 0x404040;
+ }
+ s.x0 = a;
+ s.y0 = b;
+ s.x1 = a;
+ s.y1 = b2;
+ s.x2 = am;
+ s.y2 = b;
+ s.x3 = am;
+ s.y3 = b2;
+ b = b2;
+ fast_draw_quad_real(&s, 0, 0);
}
- previous_phase = phase - 0.3f;
- dot = offset + step;
- previous_value = ((short *)(D_L00_001E6020_lui - 0x18))[row - 1];
- value = ((short *)(D_L00_001E6020_lui - 0x18))[row];
- if (value > 0x40) value = 0x40;
- if (value < 0) value = 0;
- if (previous_value > 0x40) previous_value = 0x40;
- if (previous_value < 0) previous_value = 0;
- colors = quad.colors;
- *colors++ = (value << 24) | 0x404040;
- *colors++ = (value << 24) | 0x404040;
- *colors++ = (previous_value << 24) | 0x404040;
- *colors = (previous_value << 24) | 0x404040;
- if (row == 1)
- quad.colors[2] = quad.colors[3] = 0x20404040;
- else if (row == 9)
- quad.colors[0] = quad.colors[1] = 0x00404040;
- quad.texcoords[0] = phase;
- quad.texcoords[1] = offset;
- quad.texcoords[2] = phase;
- quad.texcoords[3] = dot;
- quad.texcoords[4] = previous_phase;
- quad.texcoords[5] = offset;
- quad.texcoords[6] = previous_phase;
- quad.texcoords[7] = dot;
- offset = dot;
- FUN_001fd228_002dd8e8(&quad, 0, 0);
}
- phase = next_phase;
+ a = a2;
}
- FUN_002a0ba8_002dd8e8(0x47, 0x5360b);
+ vu1_add_g_sregister(0x47, 0x5360B);
}
-#endif
extern int D_L00_00161B44_gp __asm__("D_L00_00161B44") __attribute__((sda));
extern int D_L00_00161B40_gp __asm__("D_L00_00161B40") __attribute__((sda));
-extern short D_L00_001E6008_002ddca0 __asm__("D_L00_001E6008") __attribute__((section(".data")));
+extern short D_L00_001E6008[] __attribute__((section(".data")));
/* Sets D_L00_00161B40_gp and D_L00_00161B44_gp to 1 and clears D_L00_001E6008. */
void FUN_L00_002ddca0(void) {
D_L00_00161B40_gp = 1;
D_L00_00161B44_gp = 1;
- D_L00_001E6008_002ddca0 = 0;
+ (*(short *)D_L00_001E6008) = 0;
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L00_002ddcb8.s", FUN_L00_002ddcb8);
-#else
-extern float D_L00_00161B80_lui __asm__("D_L00_00161B80") __attribute__((section(".data")));
-extern float D_L00_00161B84_gp __asm__("D_L00_00161B84") __attribute__((sda));
-extern float D_L00_00161B50_gp __asm__("D_L00_00161B50") __attribute__((sda));
-extern int D_L00_00161B54_002ddcb8 __asm__("D_L00_00161B54") __attribute__((sda));
-extern int D_L00_00161B58_002ddcb8 __asm__("D_L00_00161B58") __attribute__((sda));
-extern char D_L00_00166FD0_002ddcb8[] __asm__("D_L00_00166FD0");
-extern char D_L00_001E5F40_002ddcb8[] __asm__("D_L00_001E5F40");
-extern char D_L00_001E5F30[];
-extern char D_L00_00161B60_002ddcb8[] __asm__("D_L00_00161B60");
-extern char D_L00_00161B70_002ddcb8[] __asm__("D_L00_00161B70");
-void FUN_001ff300_002ddcb8(void *, void *, float) __asm__("FUN_L00_001ff300");
-void FUN_001ff500_002ddcb8(void *, void *, float) __asm__("FUN_L00_001ff500");
-void FUN_001ff278_002ddcb8(void *, void *, void *) __asm__("FUN_L00_001ff278");
-void FUN_001ff260_002ddcb8(void *) __asm__("FUN_L00_001ff260");
-float FUN_00257cb0_002ddcb8(void) __asm__("FUN_L00_00257cb0");
-void FUN_0025fc08_002ddcb8(void *, float, void *, void *) __asm__("FUN_L00_0025fc08");
-typedef union {
- unsigned int bits __attribute__((mode(TI)));
- float f[4];
-} __attribute__((aligned(16))) V_002ddcb8;
+/* Ported from rac1-decomp (src/overlays/shared/vendor_002D9438.c: func_L00_002DF168), where it is exact; names translated to the US level program. */
-void FUN_L00_002ddcb8(char *frame_context, void *initial_vector) {
- V_002ddcb8 first, second, third, scaled_first, scaled_third, temp1, temp2;
- V_002ddcb8 *next;
- char *global;
- char *vector_source;
- float sampled;
- int i;
- char *record;
- short *halfword;
+typedef struct { char pad[0x2084]; int f; int pad2; int mode; } G_c;
- if (!*(int *)((char *)&D_L00_00161B84_gp - 0x44))
- return;
- D_L00_00161B84_gp = 1.7f;
- *(int *)((char *)&D_L00_00161B84_gp - 0x44) = 0;
- global = (char *)&D_0013F350_c;
- {
- int i = *(int *)(global + 0x2084);
- if ((i == 30 || i == 1) &&
- (*(u16 *)(*(char **)(global + 0x2080) + 0x34) & 1)) {
- qcopy(&first, D_L00_00166FD0_002ddcb8);
- qcopy(&second, D_L00_00166FD0_002ddcb8 + 0x10);
- qcopy(&third, D_L00_00166FD0_002ddcb8 + 0x20);
- } else if (*(short *)(global + 0x22c8) == 1) {
- FUN_001ff300_002ddcb8(&first, frame_context + 0xd0, -1.0f);
- qcopy(&second, frame_context + 0xc0);
- qcopy(&third, frame_context + 0xe0);
+typedef int u128_DF168 __attribute__((mode(TI)));
+
+typedef struct { int pad[5]; int f14; } E04_DF168;
+
+typedef struct { short idx; short pad; float f; int pad2[3]; char *p; } E04;
+
+extern E04 D_L00_001E4C80[];
+extern char D_L00_00161B60[] __attribute__((section(".sdata")));
+extern char D_L00_00161B70[] __attribute__((section(".sdata")));
+extern char D_L00_00166FD0[];
+extern char D_L00_001E5F30[];
+extern char D_L00_001E5F40[];
+extern f32 random_angle_radians(void) __asm__("func_00213308");
+extern float D_L00_00161B80 __attribute__((section(".sdata")));
+extern float D_L00_00161B84 __attribute__((section(".sdata")));
+extern int D_L00_00161B40 __attribute__((sda));
+extern int D_L00_00161B44 __attribute__((sda));
+extern int D_L00_00161B54 __attribute__((sda));
+extern int D_L00_00161B58 __attribute__((sda));
+extern short D_L00_001E6008[];
+extern void build_look_at_matrix_c2(void *, void *, float, void *) __asm__("build_look_at_matrix");
+extern void clear_u64_value_c2(void *) __asm__("func_001F99F8");
+extern void fast_vec_normalize_c2(void *, void *, f32) __asm__("FUN_001f9bf8");
+extern void fast_vec_scale_c2(void *, void *, f32) __asm__("func_001F9A68");
+
+void FUN_L00_002ddcb8(char *a, char *b) {
+ u128_DF168 s[7];
+ char *v;
+ short *w;
+ int i, st, j;
+ if (D_L00_00161B40 == 0) return;
+ D_L00_00161B84 = 1.7f;
+ D_L00_00161B40 = 0;
+ st = (*(Hero *)D_0013F350_c2).state.current;
+ if ((st == 0x1E || st == 1) && ((*(Hero *)D_0013F350_c2).moby->flags & 1)) {
+ qcopy((char *)s, D_L00_00166FD0);
+ qcopy((char *)s + 0x10, D_L00_00166FD0 + 0x10);
+ qcopy((char *)s + 0x20, D_L00_00166FD0 + 0x20);
+ v = (char *)s + 0x20;
+ } else {
+ if ((*(Hero *)D_0013F350_c2).unk22C8 == 1) {
+ fast_vec_scale_c2(s, a + 0xD0, -1.0f);
+ qcopy((char *)s + 0x10, a + 0xC0);
+ qcopy((char *)s + 0x20, a + 0xE0);
+ v = (char *)s + 0x20;
} else {
- vector_source = global + 0x640;
- qcopy_nc(&first, vector_source);
- qcopy_nc(&second, vector_source + 0x10);
- qcopy_nc(&third, vector_source + 0x20);
+ qcopy((char *)s, &(*(Hero *)D_0013F350_c2).basis[0]);
+ qcopy((char *)s + 0x10, &(*(Hero *)D_0013F350_c2).basis[1]);
+ qcopy((char *)s + 0x20, &(*(Hero *)D_0013F350_c2).basis[2]);
+ v = (char *)s + 0x20;
}
}
- FUN_001ff500_002ddcb8(&scaled_first, &first, *(volatile float *)&D_L00_00161B84_gp);
- FUN_001ff500_002ddcb8(&scaled_third, &third, 1.0f);
- *(V_002ddcb8 *)D_L00_001E5F40_002ddcb8 = *(V_002ddcb8 *)initial_vector;
- *(short *)(D_L00_001E5F40_002ddcb8 + 0xc8) = 0;
- next = (V_002ddcb8 *)(D_L00_001E5F40_002ddcb8 + 0x10);
- record = D_L00_001E5F30 + 0x10;
- halfword = (short *)(D_L00_001E5F40_002ddcb8 + 0xca);
- i = 9;
- do {
- FUN_001ff278_002ddcb8(next, record, &scaled_first);
- ++next;
- *halfword++ = 0;
- record += 0x10;
- } while (--i != 0);
- FUN_001ff260_002ddcb8(D_L00_00161B60_002ddcb8);
- temp1.bits = 0;
- temp2.bits = 0;
- *(volatile float *)&temp2.f[3] = 1.0f;
- *(volatile float *)&temp1.f[2] = 0.1f;
- *(volatile float *)&temp1.f[3] = 1.0f;
- temp2.f[0] = 1.0f;
- sampled = FUN_00257cb0_002ddcb8();
- FUN_0025fc08_002ddcb8(D_L00_00161B70_002ddcb8, sampled, &temp1, &temp2);
- D_L00_00161B80_lui = sampled;
- D_L00_00161B50_gp = 0.006f;
- D_L00_00161B54_002ddcb8 = 0;
- D_L00_00161B58_002ddcb8 = 0;
- if (*(int *)((char *)&D_L00_00161B84_gp - 0x40)) {
- *(int *)((char *)&D_L00_00161B84_gp - 0x40) = 0;
- record = D_L00_001E5F30 + 0xC;
- {
- int i;
- for (i = 199; i >= 0; --i) {
- *(int *)(D_L00_001E5F30 + 0xC - (199 - i) * 0x18) = 0;
- }
- }
+ fast_vec_normalize_c2((char *)s + 0x30, s, D_L00_00161B84);
+ fast_vec_normalize_c2((char *)s + 0x40, v, 1.0f);
+ qcopy(D_L00_001E5F40, b);
+ D_L00_001E6008[0] = 0;
+ for (i = 1; i < 10; i++) {
+ add_vector_xyz(D_L00_001E5F40 + i * 0x10, D_L00_001E5F30 + i * 0x10, (char *)s + 0x30);
+ D_L00_001E6008[i] = 0;
+ }
+ clear_u64_value_c2(D_L00_00161B60);
+ s[5] = 0;
+ s[6] = 0;
+ *(float *)((char *)s + 0x58) = 0.1f;
+ *(float *)((char *)s + 0x5C) = 1.0f;
+ *(float *)((char *)s + 0x60) = 1.0f;
+ *(float *)((char *)s + 0x6C) = 1.0f;
+ {
+ float f = random_angle_radians();
+ build_look_at_matrix_c2(D_L00_00161B70, (char *)s + 0x50, f, (char *)s + 0x60);
+ D_L00_00161B80 = f;
+ }
+ D_L00_00161B50 = 0.006f;
+ D_L00_00161B54 = 0;
+ D_L00_00161B58 = 0;
+ if (D_L00_00161B44 != 0) {
+ D_L00_00161B44 = 0;
+ for (j = 199; j >= 0; j--) ((E04_DF168 *)D_L00_001E4C80)[j].f14 = 0;
}
}
-#endif
#ifndef NON_MATCHING
INCLUDE_ASM("config/us/overlays/asm/FUN_L00_002ddf60.s", FUN_L00_002ddf60);
#else
@@ -2821,13 +2815,13 @@ extern float D_L00_00161B80_lui __asm__("D_L00_00161B80") __attribute__((section
extern float D_L00_00161B80_gp __asm__("D_L00_00161B80") __attribute__((sda));
extern float D_L00_00161B84_gp __asm__("D_L00_00161B84") __attribute__((sda));
extern float D_L00_00161B50_gp __asm__("D_L00_00161B50") __attribute__((sda));
-extern int D_L00_00161B54_002ddcb8 __asm__("D_L00_00161B54") __attribute__((sda));
-extern int D_L00_00161B58_002ddcb8 __asm__("D_L00_00161B58") __attribute__((sda));
+extern int D_L00_00161B54 __attribute__((sda));
+extern int D_L00_00161B58 __attribute__((sda));
extern char D_L00_00166FD0_002ddcb8[] __asm__("D_L00_00166FD0");
extern char D_L00_001E5F40_002ddcb8[] __asm__("D_L00_001E5F40");
extern char D_L00_001E5F30[];
-extern char D_L00_00161B60_002ddcb8[] __asm__("D_L00_00161B60");
-extern char D_L00_00161B70_002ddcb8[] __asm__("D_L00_00161B70");
+extern char D_L00_00161B60_lui[] __asm__("D_L00_00161B60");
+extern char D_L00_00161B70_lui[] __asm__("D_L00_00161B70");
void FUN_001ff300_002ddcb8(void *, void *, float) __asm__("FUN_L00_001ff300");
void FUN_001ff500_002ddcb8(void *, void *, float) __asm__("FUN_L00_001ff500");
void FUN_001ff278_002ddcb8(void *, void *, void *) __asm__("FUN_L00_001ff278");
@@ -2835,13 +2829,12 @@ void FUN_001ff260_002ddcb8(void *) __asm__("FUN_L00_001ff260");
float FUN_00257cb0_002ddcb8(void) __asm__("FUN_L00_00257cb0");
void FUN_0025fc08_002ddcb8(void *, float, void *, void *) __asm__("FUN_L00_0025fc08");
extern char D_L00_001E4B40[];
-extern char D_L00_001E4C80_002ddf60[] __asm__("D_L00_001E4C80");
extern char D_L00_001E6020[] __asm__("D_L00_001E6020");
extern char D_L00_001E5FE0[];
-extern short D_L00_001E6008_002ddca0 __asm__("D_L00_001E6008") __attribute__((section(".data")));
-extern char D_L00_00173E60_002ddf60[] __asm__("D_L00_00173E60");
-void FUN_L00_002ddcb8(char *, void *);
-void FUN_L00_002dd8e8(void);
+extern short D_L00_001E6008[] __attribute__((section(".data")));
+extern unsigned char 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");
void FUN_001ff2d8_002ddf60(void *, void *, void *, float) __asm__("FUN_001f9a40");
void FUN_001ff3c0_002ddf60(void *, void *, void *) __asm__("FUN_001f9ad8");
@@ -2876,7 +2869,7 @@ void FUN_L00_002ddf60(void *frame_context, void *initial_vector) {
float fraction, sampled, length, value;
int next_row;
- FUN_L00_002ddcb8(frame_context, initial_vector);
+ FUN_L00_002ddcb8_u(frame_context, initial_vector);
global = (char *)&D_0013F350_c + 0xcb0;
{
int i = *(int *)(global + (0x2084 - 0xcb0));
@@ -2900,7 +2893,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 - 0xcb0)), 0)) {
- i = truncate_float_to_s32(FUN_001ff488_002ddf60(D_L00_00173E60_002ddf60, initial_vector) / D_L00_00161B84_lui);
+ i = truncate_float_to_s32(FUN_001ff488_002ddf60(((char *)D_L00_00173E60), initial_vector) / D_L00_00161B84_lui);
if (i < 10) {
halfword = (short *)(D_L00_001E5F40_002ddcb8 + 0xc8) + i;
j = i;
@@ -2923,19 +2916,19 @@ void FUN_L00_002ddf60(void *frame_context, void *initial_vector) {
i = 8;
do { --i; *halfword = (unsigned short)halfword[-1] - 32; ++halfword; } while (i >= 0);
}
- FUN_001ff6d0_002ddf60(&start, D_L00_00161B60_002ddcb8, &first);
+ FUN_001ff6d0_002ddf60(&start, D_L00_00161B60_lui, &first);
FUN_001ff278_002ddcb8(&start, &start, &scaled_first);
- FUN_001ff6d0_002ddf60(&end, D_L00_00161B70_002ddcb8, &first);
+ FUN_001ff6d0_002ddf60(&end, D_L00_00161B70_lui, &first);
FUN_001ff278_002ddcb8(&end, &end, &scaled_first);
sampled = FUN_00200240_002ddf60(FUN_001fef20_002ddf60(60));
- fraction = (float)D_L00_00161B54_002ddcb8;
- ++D_L00_00161B54_002ddcb8;
+ fraction = (float)D_L00_00161B54;
+ ++D_L00_00161B54;
fraction = fraction / sampled;
scaled_first[0] = start[0] + (end[0] - start[0]) * fraction;
scaled_first[2] = start[2] + (end[2] - start[2]) * fraction;
scaled_first[1] = start[1] + (end[1] - start[1]) * fraction;
- if (FUN_001fef20_002ddf60(60) <= D_L00_00161B54_002ddcb8) {
- qcopy(D_L00_00161B60_002ddcb8, D_L00_00161B70_002ddcb8);
+ if (FUN_001fef20_002ddf60(60) <= D_L00_00161B54) {
+ qcopy(D_L00_00161B60_lui, D_L00_00161B70_lui);
FUN_001ff500_002ddcb8(&axis, &first, D_L00_00161B84_lui);
*(u128 *)&temp1 = 0;
*(u128 *)&temp2 = 0;
@@ -2944,11 +2937,11 @@ void FUN_L00_002ddf60(void *frame_context, void *initial_vector) {
temp1[3] = 1.0f;
temp2[0] = 1.0f;
sampled = fast_add_rotations(D_L00_00161B80_lui, FUN_00257be8_002ddf60(45.0f, 315.0f) * 0.017453292f);
- FUN_0025fc08_002ddcb8(D_L00_00161B70_002ddcb8, sampled, &temp1, &temp2);
+ FUN_0025fc08_002ddcb8(D_L00_00161B70_lui, sampled, &temp1, &temp2);
D_L00_00161B80_lui = sampled;
- D_L00_00161B54_002ddcb8 = 0;
+ D_L00_00161B54 = 0;
}
- *(float *)&D_L00_00161B58_002ddcb8 = fast_add_rotations(*(float *)&D_L00_00161B58_002ddcb8, 0.1f);
+ *(float *)&D_L00_00161B58 = fast_add_rotations(*(float *)&D_L00_00161B58, 0.1f);
qcopy(&axis, &third);
qcopy(&basis, &axis);
FUN_001ff3c0_002ddf60(&cross, &scaled_first, &basis);
@@ -3007,7 +3000,7 @@ void FUN_L00_002ddf60(void *frame_context, void *initial_vector) {
do {
float value = spread + 0.1f;
++j;
- sampled = fast_add_rotations(*(float *)&D_L00_00161B58_002ddcb8 + phase, 0.0f);
+ sampled = fast_add_rotations(*(float *)&D_L00_00161B58 + phase, 0.0f);
sampled = FUN_001ff800_002ddf60(sampled);
FUN_001ff300_002ddcb8(&ring[0], prior, value + sampled * 0.1f);
FUN_001ff6d0_002ddf60(&ring[0], &ring[0], &following);
@@ -3018,13 +3011,13 @@ void FUN_L00_002ddf60(void *frame_context, void *initial_vector) {
FUN_001ff500_002ddcb8(&scaled_first, &offset, D_L00_00161B84_lui);
row = next_row;
} while (row < 10);
- FUN_001f9598_002ddf60(FUN_L00_002dd8e8, frame_context);
+ FUN_001f9598_002ddf60(FUN_L00_002dd8e8_u, frame_context);
count = 0;
small_count = 0;
i = 0;
do {
j = i + 1;
- record = D_L00_001E4C80_002ddf60 + (i * 3 << 3);
+ record = (char *)D_L00_001E4C80 + (i * 3 << 3);
if (!*(char **)(record + 20) && count < 5) {
row = 9;
if (((short *)(D_L00_001E5F40_002ddcb8 + 0xc8))[9] < 64) {
@@ -3090,7 +3083,7 @@ void FUN_L00_002ddf60(void *frame_context, void *initial_vector) {
}
}
if (*(char **)(record + 20)) {
- record = D_L00_001E4C80_002ddf60 + (i * 3 << 3);
+ record = (char *)D_L00_001E4C80 + (i * 3 << 3);
fraction = *(float *)(record + 4) / length;
if (*(short *)record == 2) *(short *)(*(char **)(record + 20) + 10) = 100;
else if (*(short *)record < 2) {
@@ -3098,7 +3091,7 @@ void FUN_L00_002ddf60(void *frame_context, void *initial_vector) {
if (*(short *)(*(char **)(record + 20) + 10) < 61) *(short *)(*(char **)(record + 20) + 10) = 60;
}
i = (i * 3 << 3);
- record = D_L00_001E4C80_002ddf60 + i;
+ record = (char *)D_L00_001E4C80 + i;
if (*(short *)record == 1) {
effect = *(char **)(record + 20);
FUN_001ff2a8_002ddf60(&temp2, initial_vector, effect + 16);
@@ -3144,7 +3137,7 @@ void FUN_L00_002ddf60(void *frame_context, void *initial_vector) {
/* Ported from rac1-decomp (src/overlays/shared/vendor_002D9438.c: func_L00_002E0490), where it is exact; names translated to the US level program. */
extern short D_L00_001E6008[];
-extern void FUN_L00_002dd8e8(void);
+extern void FUN_L00_002dd8e8_u(void) __asm__("FUN_L00_002dd8e8");
void enqueue_callback_list_1(s32 arg0, s32 arg1) __asm__("FUN_001f4600");
/* When D_L00_001E6008[0] > 0: caps the ten counters at 0x40, lowers each by 4, queues 002dd8e8. */
@@ -3156,7 +3149,7 @@ void FUN_L00_002defe0(int arg0) {
D_L00_001E6008[i] = 0x40;
D_L00_001E6008[i] = (unsigned short)D_L00_001E6008[i] - 4;
}
- enqueue_callback_list_1(FUN_L00_002dd8e8, arg0);
+ enqueue_callback_list_1(FUN_L00_002dd8e8_u, arg0);
}
}
@@ -3167,13 +3160,6 @@ void FUN_L00_002defe0(int arg0) {
/* pull each active entry's marker toward its target, then update the rest */
/* Ported from rac1-decomp (src/overlays/shared/vendor_002D9438.c: func_L00_002E04F8), where it is exact; names translated to the US level program. */
-typedef struct {
- short idx;
- short pad;
- float f;
- int pad2[3];
- char *p;
-} E04;
typedef float VQ[4] __attribute__((aligned(16)));
@@ -3246,7 +3232,7 @@ typedef struct {
u8 pad2[3];
T_2df1e0 *p24;
} O_2df1e0;
-extern s16 D_L00_001E6008_2df1e0[] __asm__("D_L00_001E6008") __attribute__((section(".data")));
+extern short D_L00_001E6008[] __attribute__((section(".data")));
extern u8 D_L00_001E5F40_2df1e0[][16] __asm__("D_L00_001E5F40") __attribute__((section(".data")));
s32 random_integer_below(s32) __asm__("FUN_00213260");
s32 FUN_L00_0025e3f8(O_2df1e0 *);
@@ -3268,7 +3254,7 @@ void FUN_L00_002df1e0(O_2df1e0 *p) {
return;
if (!(FUN_001f9b48(p->v10, &hero.motion.pos) < 30.0f))
return;
- for (i = 0; i < 10 && D_L00_001E6008_2df1e0[i] >= 8; i++) {
+ for (i = 0; i < 10 && D_L00_001E6008[i] >= 8; i++) {
f = i * 0.3f + 0.1f;
if (f < 2.0f)
f = 2.0f;
diff --git a/src/overlays/shared/gameplay/entities/novalis_elevator.c b/src/overlays/shared/gameplay/entities/novalis_elevator.c
index bfa6976c26..3a4f16cda5 100644
--- a/src/overlays/shared/gameplay/entities/novalis_elevator.c
+++ b/src/overlays/shared/gameplay/entities/novalis_elevator.c
@@ -219,7 +219,7 @@ extern float FUN_001f9b48(void *, void *);
extern int FUN_001f9770(void *);
extern int FUN_L00_0028d8c0(void *, int);
extern int FUN_L01_00277fb8(void *);
-extern s32 allocate_voice_for_target_entry(s32, s32, void *) __asm__("func_0022DA68");
+extern int allocate_voice_for_target_entry(int, int, void *) __asm__("func_0022DA68");
extern s32 scale_game_frames(s32) __asm__("func_001F96F8");
extern s32 truncate_float_to_s32(f32) __asm__("FUN_001fa6d0");
extern int hero_set_state(int, int) __asm__("FUN_L00_002223f8");
@@ -525,7 +525,7 @@ void FUN_L01_002c7530(char *moby) {
break;
}
}
-extern int D_0015ED84_r __asm__("D_0015ED84");
+extern int D_0015ED84;
extern unsigned char menu_item_enabled_1_lui __asm__("D_0013D395") __attribute__((section(".data")));
/* On level 1, when a state-5 moby of type 0x118 has sub-id 0x34 or 0x35, sets the matching flag byte (D_0013D394 / D_0013D395). */
void FUN_L01_002e0bd8(char *moby)
@@ -536,7 +536,7 @@ void FUN_L01_002e0bd8(char *moby)
*(short *)(moby + 0xA6) == 0x118 &&
(unsigned char)moby[0x20] == 5) {
menu_item_enabled_0 = level;
- level = D_0015ED84_r;
+ level = D_0015ED84;
}
if (level == 1 && *(short *)(moby + 0xB2) == 0x35 &&
*(short *)(moby + 0xA6) == 0x118 &&
@@ -1622,7 +1622,7 @@ void FUN_L01_002eda00(char *m) {
}
extern void FUN_L00_00263ac8(float, void *, int, void *);
extern void FUN_L00_0025a120(void *);
-extern void FUN_L01_002eec68(char *);
+extern void FUN_L01_002eec68_u(char *) __asm__("FUN_L01_002eec68");
extern void FUN_L01_002ef560(unsigned char *);
extern void FUN_L01_002ef770(unsigned char *, float *);
extern int FUN_L01_00276fe8(int *, int, int, float, void *, void *, void *);
@@ -1653,7 +1653,7 @@ extern int FUN_001f96f8(int);
extern int FUN_001fa6d0(float);
extern float compute_interpolated_record_value(void *) __asm__("FUN_0020c9e0");
extern void FUN_0020c828(void *);
-extern float D_0015ED6C __attribute__((section(".sdata")));
+extern float frame_time_gp __asm__("D_0015ED6C") __attribute__((section(".sdata")));
extern float D_0015ED70 __attribute__((section(".sdata")));
extern float D_0013F420[4];
extern float D_L01_0015F580[] __attribute__((section(".sdata")));
@@ -1683,7 +1683,7 @@ void FUN_L01_002edca0(unsigned char *moby) {
FUN_L00_0025a120(moby);
moby[0x7f] = 0x16;
}
- FUN_L01_002eec68((char *)moby);
+ FUN_L01_002eec68_u((char *)moby);
target = *(char **)(data + 0x200);
switch (moby[0x20]) {
case 0:
@@ -1724,7 +1724,7 @@ void FUN_L01_002edca0(unsigned char *moby) {
*(float *)(data + 0x17c) = 2.0f;
*(float *)(data + 0x178) = 2.0f;
result = FUN_001fa6d0(*(float *)(data + 0x250) * 0.8f * 1024.0f);
- angle = *(float *)(data + 0x23c) * D_0015ED6C;
+ angle = *(float *)(data + 0x23c) * frame_time_gp;
*(int *)(data + 0x170) = result;
*(float *)(data + 0x194) = angle;
if (*(int *)(data + 0x230) != 0) {
@@ -1764,7 +1764,7 @@ void FUN_L01_002edca0(unsigned char *moby) {
blend_moby_animation(moby, 1, 0, 5);
return;
}
- *(float *)(data + 0x194) = *(float *)(data + 0x23c) * 0.5f * D_0015ED6C;
+ *(float *)(data + 0x194) = *(float *)(data + 0x23c) * 0.5f * frame_time_gp;
if (moby[0x53] != 1)
blend_moby_animation(moby, 1, 0, 5);
moby[0x20] = 2;
@@ -1774,7 +1774,7 @@ void FUN_L01_002edca0(unsigned char *moby) {
*(float *)(data + 0x214) - *(float *)(moby + 0x14));
FUN_L00_0025be00((float *)(moby + 0x48), (float *)(data + 0x220), angle,
D_0015ED70 * 1.0471976f, D_0015ED70 * 1.0471976f,
- D_0015ED6C * 3.1415927f);
+ frame_time_gp * 3.1415927f);
move[0] = FUN_001f9dc8(*(float *)(moby + 0x48));
move[1] = FUN_001f9de0(*(float *)(moby + 0x48));
move[2] = 0.0f;
@@ -1790,7 +1790,7 @@ void FUN_L01_002edca0(unsigned char *moby) {
blend_moby_animation(moby, 0, 0, FUN_001f96f8(10));
clear_u64_value(data + 0x40);
angle = random_float_between(-0.34906584f, 0.34906584f);
- distance = *(float *)(data + 0x23c) * D_0015ED6C;
+ distance = *(float *)(data + 0x23c) * frame_time_gp;
*(float *)(data + 0x234) = angle;
*(float *)(data + 0x194) = distance;
} else {
@@ -1810,7 +1810,7 @@ void FUN_L01_002edca0(unsigned char *moby) {
*(float *)(target + 0x14) - *(float *)(moby + 0x14));
FUN_L00_0025be00((float *)(moby + 0x48), (float *)(data + 0x220), angle,
D_0015ED70 * 1.0471976f, D_0015ED70 * 1.0471976f,
- D_0015ED6C * 3.1415927f);
+ frame_time_gp * 3.1415927f);
move[0] = FUN_001f9dc8(*(float *)(moby + 0x48));
move[1] = FUN_001f9de0(*(float *)(moby + 0x48));
move[2] = 0.0f;
@@ -1843,7 +1843,7 @@ void FUN_L01_002edca0(unsigned char *moby) {
distance = FUN_001f9b80(moby + 0x10, target_position);
if (distance < D_L01_001619AC) {
moby[0x20] = 6;
- *(float *)(data + 0x194) = (*(float *)(data + 0x23c) + *(float *)(data + 0x23c)) * D_0015ED6C;
+ *(float *)(data + 0x194) = (*(float *)(data + 0x23c) + *(float *)(data + 0x23c)) * frame_time_gp;
if (moby[0x53] != 2)
blend_moby_animation(moby, 2, 0, FUN_001f96f8(10));
return;
@@ -1859,7 +1859,7 @@ void FUN_L01_002edca0(unsigned char *moby) {
angle = FUN_001fa580(angle, *(float *)(data + 0x234));
FUN_L00_0025be00((float *)(moby + 0x48), (float *)(data + 0x220), angle,
D_0015ED70 * 12.566371f, D_0015ED70 * 12.566371f,
- D_0015ED6C * 25.132742f);
+ frame_time_gp * 25.132742f);
move[0] = FUN_001f9dc8(*(float *)(moby + 0x48));
move[0] += move[0];
move[1] = FUN_001f9de0(*(float *)(moby + 0x48));
@@ -1881,7 +1881,7 @@ void FUN_L01_002edca0(unsigned char *moby) {
*(float *)(target + 0x14) - *(float *)(moby + 0x14));
FUN_L00_0025be00(rotation, (float *)(data + 0x220), angle,
D_0015ED70 * 12.566371f, D_0015ED70 * 12.566371f,
- D_0015ED6C * 25.132742f);
+ frame_time_gp * 25.132742f);
distance = compute_interpolated_record_value(moby);
if (moby[0x52] == moby[0x53] && 10.0f <= distance && distance <= 16.0f) {
move[0] = FUN_001f9dc8(*rotation);
@@ -1907,7 +1907,7 @@ void FUN_L01_002edca0(unsigned char *moby) {
moby[0x20] = 7;
if (moby[0x53] != 3)
blend_moby_animation(moby, 3, 0, FUN_001f96f8(10));
- *(float *)(data + 0x194) = *(float *)(data + 0x23c) * D_0015ED6C;
+ *(float *)(data + 0x194) = *(float *)(data + 0x23c) * frame_time_gp;
}
break;
}
@@ -1937,7 +1937,7 @@ void FUN_L01_002edca0(unsigned char *moby) {
angle = FUN_001fa580(angle, *(float *)(data + 0x234));
FUN_L00_0025be00((float *)(moby + 0x48), (float *)(data + 0x220), angle,
D_0015ED70 * 12.566371f, D_0015ED70 * 12.566371f,
- D_0015ED6C * 25.132742f);
+ frame_time_gp * 25.132742f);
move[0] = FUN_001f9dc8(*(float *)(moby + 0x48));
move[0] += move[0];
move[1] = FUN_001f9de0(*(float *)(moby + 0x48));
@@ -1958,7 +1958,7 @@ void FUN_L01_002edca0(unsigned char *moby) {
moby + 0x10, data + 0x210, move);
if (path_hit != 0) {
FUN_0022da68(4, 0, (char *)moby);
- *(float *)(data + 0x194) = *(float *)(data + 0x23c) * D_0015ED6C;
+ *(float *)(data + 0x194) = *(float *)(data + 0x23c) * frame_time_gp;
moby[0x20] = 9;
if (moby[0x53] != 5)
blend_moby_animation(moby, 5, 4, FUN_001f96f8(10));
@@ -1979,7 +1979,7 @@ void FUN_L01_002edca0(unsigned char *moby) {
blend_moby_animation(moby, 1, 0, FUN_001f96f8(10));
clear_u64_value(data + 0x40);
angle = random_float_between(-0.34906584f, 0.34906584f);
- distance = *(float *)(data + 0x23c) * D_0015ED6C;
+ distance = *(float *)(data + 0x23c) * frame_time_gp;
*(float *)(data + 0x234) = angle;
*(float *)(data + 0x194) = distance;
}
@@ -2010,233 +2010,237 @@ void FUN_L01_002edca0(unsigned char *moby) {
break;
}
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L01_002eec68.s", FUN_L01_002eec68);
-#else
-extern char *FUN_L00_0025a420(char *, int, int);
-extern void fun_00213928(char *, char *, char *, int, int *, float *, int, int) __asm__("FUN_00213928");
-extern void FUN_L00_0025ab48(void *, void *, void *, void *);
-extern void FUN_L00_0025c558(float, char *, char *, int, int, int);
-extern int FUN_L00_0025ff38(float, char *, char *, int, int, void *, int);
-extern float fast_subtract_rotations(float, float) __asm__("FUN_001fa5c8");
-extern float FUN_001fa580(float, float);
-extern float FUN_001f9de0(float);
-extern float FUN_001f9b48(void *, void *);
-extern float FUN_001f9b80(void *, void *);
-extern float FUN_001f99c0(float);
-extern void clear_vector(void *) __asm__("FUN_001f99f8");
-extern int FUN_001efa68(void *, void *, int, int, int);
-extern void FUN_0022da68(int, int, char *);
-extern int FUN_001f9740(void *);
-extern int FUN_001f96f8(int);
-extern int FUN_001fa6d0(float);
-extern int fast_tween_color(float, int, int) __asm__("FUN_001fa6e0");
-extern char *FUN_L01_002ef350(char *);
-extern char *FUN_L01_002ef478(char *, int);
-extern void FUN_L01_002ef770(unsigned char *, float *);
-extern void mark_moby_for_removal(void *) __asm__("FUN_0020c828");
-extern float D_L01_0015ED6C __asm__("D_0015ED6C");
-extern float D_0013F420[4];
-extern char *D_L01_001612D0;
-extern char *D_L01_0015FFD8 __attribute__((sda));
-extern float D_L01_001619A0 __attribute__((sda));
-extern float D_L01_001619A4 __attribute__((sda));
-extern int D_L01_00161998 __attribute__((sda));
-extern int D_L01_0016199C __attribute__((sda));
-extern float frame_time __attribute__((sda));
-extern s32 D_001413D0[];
-extern char *D_L01_001B0930[];
-
-void FUN_L01_002eec68(char *moby) {
- char *data = *(char **)(moby + 0x78);
- char *hit;
- float origin[4] __attribute__((aligned(16)));
- float target[4] __attribute__((aligned(16)));
- float smoke_angle;
- float first_angle;
- float second_angle;
+/* Moby update: hit test against a target, hurt/debris on a hit, else path search and bob. */
+/* Ported from rac1-decomp (src/overlays/shared/vendor_002B90A8.c: func_L01_002F0040), where it is exact; names translated to the US level program. */
+
+typedef int u128_2F0040 __attribute__((mode(TI)));
+
+typedef union { u128_2F0040 q; float f[4]; } V_2F0040;
+
+extern char *FUN_L00_0025a420(void *, int, int);
+extern char *FUN_L01_002ef350(void *);
+extern char *FUN_L01_002ef478_c(char *, int) __asm__("FUN_L01_002ef478");
+extern char D_0013E533[];
+extern f32 fast_sin_c(f32) __asm__("func_001F9DE0");
+extern f32 fast_subtract_rotations(f32, f32) __asm__("func_001FA5C8");
+
+extern float fast_add_rotations_c(float, float) __asm__("func_001FA580");
+extern float fast_vec_dist(void *, void *);
+extern float vector_distance_xy_alt(void *, void *) __asm__("FUN_001f9b80");
+extern char *D_L01_0015FFD8;
+extern int D_L01_001612D0;
+extern float D_L01_001619A0;
+extern float D_L01_001619A4;
+extern int FUN_L00_0025ff38(float, char *, void *, int, int, void *, int);
+extern int fast_tween_color(float, int, int);
+extern int fun_00213928(void *, void *, void *, int, int *, float *, int, int);
+extern s32 truncate_float_to_s32_c(f32) __asm__("func_001FA6D0");
+extern short D_L01_00161998 __attribute__((sda));
+extern short D_L01_0016199C __attribute__((sda));
+extern void FUN_L00_0025ab48(void *, float *, void *, void *);
+extern void FUN_L00_0025c558(void *, void *, float, int, int, int);
+extern int allocate_voice_for_target_entry(int, int, void *) __asm__("func_0022DA68");
+extern void clear_u64_value_c(void *) __asm__("func_001F99F8");
+extern void mark_moby_for_removal_c(void *) __asm__("func_0020C828");
+float absolute_float(float input) __asm__("func_001F99C0");
+extern float D_0013F420[];
+extern int D_001413D0[];
+extern char *D_L01_0015FFD8;
+extern const float D_L01_001619A0_gp __asm__("D_L01_001619A0") __attribute__((sda));
+extern const float D_L01_001619A4_gp __asm__("D_L01_001619A4") __attribute__((sda));
+extern const float frame_time_macro __asm__("D_0015ED6C") MACRO_ADDR;
+
+void FUN_L01_002eec68(char *m) {
+ V_2F0040 v;
+ V_2F0040 w;
+ int flag;
+ float amount;
+ float a1;
+ float a2;
+ char *d;
+ char *t;
+ char *p;
+ char *x;
+ char *e;
+ char *spawned;
+ char *q;
+ char *cand;
+ u128_2F0040 *wp;
+ int c;
+ char *p2;
+ char *x2;
+ char *b;
+ int c258;
+ int c260;
+ float f20;
+ float rate;
+ float fixed_scale;
+ float f24;
float dist;
- int hit_type;
- int effect;
- char *other;
- char *other_data;
- int *shape;
- int selected;
- float angle_step;
+ float ang;
+ float k;
+ float seven;
- smoke_angle = 0.0f;
- hit = FUN_L00_0025a420(moby, 0x330000, 0);
- if (hit != 0) {
- char *other;
- qcopy(origin, moby + 0x10);
- origin[2] += 0.5f;
- other = *(char **)(hit + 0x20);
- if (other != 0) {
- if (*(short *)(other + 0xa6) == 0x47) {
- qcopy(target, D_0013F420);
- } else if ((*(char **)(other + 0x24) != 0 &&
- *(short *)(*(char **)(other + 0x24) + 0x46) == 5) ||
- *(short *)(other + 0xa6) == 0xba) {
- qcopy(target, origin);
+ amount = 0.0f;
+ d = *(char **)(m + 0x78);
+ t = FUN_L00_0025a420(m, 0x330000, 0);
+ if (t != 0) {
+ qcopy(&v, m + 0x10);
+ v.f[2] = v.f[2] + 0.5f;
+ p = *(char **)(t + 0x20);
+ if (p != 0) {
+ short cls = *(short *)(p + 0xA6);
+ if (cls == 0x47) {
+ qcopy(&w, ((char *)D_0013F420));
+ wp = &w.q;
} else {
- qcopy(target, other + 0x10);
+ x = *(char **)(p + 0x24);
+ if ((x != 0 && *(short *)(x + 0x46) == 5) || cls == 0xBA) {
+ qcopy(&w, &v);
+ wp = &w.q;
+ } else {
+ qcopy(&w, p + 0x10);
+ wp = &w.q;
+ }
}
} else {
- qcopy(target, hit);
- }
- if (FUN_001f9b48(origin, target) < 24.0f &&
- FUN_001efa68(origin, target, 2, (int)moby, 0) != 0) {
- hit = 0;
- }
- }
- fun_00213928(moby, hit, data + 0x20, 0, &hit_type, &smoke_angle, 0, 4);
- if (hit_type != 1 && smoke_angle != 0.0f &&
- (u8)moby[0x20] != 11 && (u8)moby[0x20] != 10 && (u8)moby[0x20] != 8) {
- FUN_0022da68(0, 0, moby);
- data[0x9d] = 0;
- *(float *)(data + 0x70) = 0.008f;
- *(int *)(data + 0x84) = 8;
- *(float *)(data + 0x20) -= 1.0f;
- *(int *)(data + 0x80) = FUN_001fa6d0(*(float *)(data + 0x250) * 0.8f * 1024.0f);
- *(float *)(data + 0x88) = *(float *)(data + 0x250) * 0.8f;
- FUN_L01_002ef770((unsigned char *)moby, (float *)(hit + 0x10));
- if (!(0.0f < *(float *)(data + 0x20))) goto depleted;
- other = FUN_L01_002ef350(moby);
- if (other != 0) {
- other_data = *(char **)(other + 0x78);
- other_data[0x9d] = 3;
- *(float *)(other_data + 0x70) = 0.008f;
- *(int *)(other_data + 0x84) = 8;
- *(int *)(other_data + 0x80) = FUN_001fa6d0(*(float *)(data + 0x250) * 0.8f * 1024.0f);
- {
- float scale = *(volatile float *)&D_L01_0015ED6C;
- float speed = *(volatile float *)(data + 0x250);
- float first_scale = D_L01_001619A0;
- float second_scale = D_L01_001619A4;
- speed *= 0.8f;
- first_scale *= scale;
- second_scale *= scale;
- effect = *(u32 *)(other_data + 0x84) | 4;
- *(volatile float *)(other_data + 0x88) = speed;
- *(volatile float *)(other_data + 0x78) = first_scale;
- *(volatile float *)(other_data + 0xb0) = 7.0f;
- *(float *)(other_data + 0xb4) = 13.0f;
- *(volatile float *)(other_data + 0x7c) = second_scale;
- }
- *(u32 *)(other_data + 0x84) = effect;
- *(u128 *)origin = *(u128 *)(hit + 0x10);
- FUN_L00_0025ab48(origin, &first_angle, other_data + 0x78, other_data + 0x7c);
- first_angle = fast_subtract_rotations(first_angle, 0.7853982f);
- FUN_L00_0025c558(first_angle, other, other_data + 0x60, 4, 8, 0);
- other[0x20] = 8;
- *(float *)(other + 0x58) = 1.0f;
- }
- other = FUN_L01_002ef350(moby);
- if (other != 0) {
- other_data = *(char **)(other + 0x78);
- *(float *)(other_data + 0x70) = 0.008f;
- other_data[0x9d] = 3;
- *(int *)(other_data + 0x84) = 8;
- *(int *)(other_data + 0x80) = FUN_001fa6d0(*(float *)(data + 0x250) * 0.8f * 1024.0f);
- {
- float scale = *(volatile float *)&D_L01_0015ED6C;
- float speed = *(volatile float *)(data + 0x250);
- float first_scale = D_L01_001619A0;
- float second_scale = D_L01_001619A4;
- speed *= 0.8f;
- first_scale *= scale;
- second_scale *= scale;
- effect = *(u32 *)(other_data + 0x84) | 4;
- *(volatile float *)(other_data + 0x88) = speed;
- *(volatile float *)(other_data + 0x78) = first_scale;
- *(volatile float *)(other_data + 0xb0) = 7.0f;
- *(float *)(other_data + 0xb4) = 13.0f;
- *(volatile float *)(other_data + 0x7c) = second_scale;
- }
- *(u32 *)(other_data + 0x84) = effect;
- *(u128 *)origin = *(u128 *)(hit + 0x10);
- FUN_L00_0025ab48(origin, &second_angle, other_data + 0x78, other_data + 0x7c);
- second_angle = FUN_001fa580(second_angle, 0.7853982f);
- FUN_L00_0025c558(second_angle, other, other_data + 0x60, 4, 8, 0);
- other[0x20] = 8;
- *(float *)(other + 0x58) = 1.0f;
- }
- if (*(char **)(hit + 0x20) != 0 &&
- *(char **)(*(char **)(hit + 0x20) + 0x24) != 0 &&
- *(short *)(*(char **)(*(char **)(hit + 0x20) + 0x24) + 0x46) == 5) {
- FUN_L00_00257470(moby, 0x800, -1);
- } else {
- FUN_L00_00257470(moby, 0, -1);
+ qcopy(&w, t);
+ wp = &w.q;
+ }
+ if (fast_vec_dist(&v, wp) < 24.0f) {
+ if (func_L00_001EFFF0_t(&v, wp, 2, m, 0) != 0) {
+ t = 0;
+ }
+ }
+ }
+ fun_00213928(m, t, d + 0x20, 0, &flag, &amount, 0, 4);
+ if (flag != 1 && amount != 0.0f && *(unsigned char *)(m + 0x20) != 0xB && *(unsigned char *)(m + 0x20) != 0xA && *(unsigned char *)(m + 0x20) != 8) {
+ f20 = 0.8f;
+ allocate_voice_for_target_entry(0, 0, m);
+ f24 = 1.0f;
+ fixed_scale = 1024.0f;
+ rate = 0.008f;
+ *(float *)(d + 0x20) = *(float *)(d + 0x20) - f24;
+ d[0x9D] = 0;
+ *(float *)(d + 0x70) = rate;
+ *(int *)(d + 0x84) = 8;
+ *(int *)(d + 0x80) = truncate_float_to_s32_c(*(float *)(d + 0x250) * f20 * fixed_scale);
+ *(float *)(d + 0x88) = *(float *)(d + 0x250) * f20;
+ FUN_L01_002ef770((unsigned char *)m, (float *)(t + 0x10));
+ if (0.0f < *(float *)(d + 0x20)) {
+ spawned = FUN_L01_002ef350(m);
+ if (spawned != 0) {
+ q = *(char **)(spawned + 0x78);
+ q[0x9D] = 3;
+ *(float *)(q + 0x70) = rate;
+ *(int *)(q + 0x84) = 8;
+ *(int *)(q + 0x80) = truncate_float_to_s32_c(*(float *)(d + 0x250) * f20 * fixed_scale);
+ k = frame_time_macro;
+ seven = 7.0f;
+ *(float *)(q + 0x88) = *(float *)(d + 0x250) * f20;
+ *(float *)(q + 0x78) = D_L01_001619A0_gp * k;
+ *(float *)(q + 0x7C) = D_L01_001619A4_gp * k;
+ *(int *)(q + 0x84) = *(int *)(q + 0x84) | 4;
+ *(float *)(q + 0xB0) = seven;
+ *(float *)(q + 0xB4) = 13.0f;
+ v.q = *(u128_2F0040 *)(t + 0x10);
+ FUN_L00_0025ab48(&v, &a1, q + 0x78, q + 0x7C);
+ a1 = fast_subtract_rotations(a1, 0.7853982f);
+ FUN_L00_0025c558(spawned, q + 0x60, a1, 4, 8, 0);
+ spawned[0x20] = 8;
+ *(float *)(spawned + 0x58) = f24;
+ }
+ spawned = FUN_L01_002ef350(m);
+ if (spawned != 0) {
+ q = *(char **)(spawned + 0x78);
+ *(float *)(q + 0x70) = rate;
+ q[0x9D] = 3;
+ *(int *)(q + 0x84) = 8;
+ *(int *)(q + 0x80) = truncate_float_to_s32_c(*(float *)(d + 0x250) * f20 * fixed_scale);
+ k = frame_time_macro;
+ seven = 7.0f;
+ *(float *)(q + 0x88) = *(float *)(d + 0x250) * f20;
+ *(float *)(q + 0x78) = D_L01_001619A0_gp * k;
+ *(float *)(q + 0x7C) = D_L01_001619A4_gp * k;
+ *(int *)(q + 0x84) = *(int *)(q + 0x84) | 4;
+ *(float *)(q + 0xB0) = seven;
+ *(float *)(q + 0xB4) = 13.0f;
+ v.q = *(u128_2F0040 *)(t + 0x10);
+ FUN_L00_0025ab48(&v, &a2, q + 0x78, q + 0x7C);
+ a2 = fast_add_rotations_c(a2, 0.7853982f);
+ FUN_L00_0025c558(spawned, q + 0x60, a2, 4, 8, 0);
+ spawned[0x20] = 8;
+ *(float *)(spawned + 0x58) = f24;
+ }
+ p2 = *(char **)(t + 0x20);
+ if (p2 != 0 && (x2 = *(char **)(p2 + 0x24)) != 0 && *(short *)(x2 + 0x46) == 5) {
+ FUN_L00_00257470(m, 0x800, -1);
+ } else {
+ FUN_L00_00257470(m, 0, -1);
+ }
+ mark_moby_for_removal_c(m);
+ return;
}
- mark_moby_for_removal(moby);
- return;
- depleted:
- *(u16 *)(moby + 0x34) &= 0xefff;
- mark_moby_for_removal(moby);
+ *(unsigned short *)(m + 0x34) = *(unsigned short *)(m + 0x34) & 0xEFFF;
+ mark_moby_for_removal_c(m);
return;
}
- ((u8 *)moby)[0xa4] = 0xff;
- if (*(int *)(data + 0x258) != 0 && ((u8 *)moby)[0x20] != 0 &&
- *(float *)(moby + 0x18) <
- *(float *)(D_L01_001612D0 + *(int *)(data + 0x258) * 0x1190 + 8)) {
- clear_vector(origin);
- FUN_L01_002ef770((unsigned char *)moby, origin);
- mark_moby_for_removal(moby);
+ *(unsigned char *)(m + 0xA4) = 0xFF;
+ c258 = *(int *)(d + 0x258);
+ if (c258 != 0 && *(unsigned char *)(m + 0x20) != 0
+ && *(float *)(m + 0x18) < *(float *)(c258 * 0x1190 + D_L01_001612D0 + 8)) {
+ clear_u64_value_c(&v);
+ FUN_L01_002ef770((unsigned char *)m, (float *)&v);
+ mark_moby_for_removal_c(m);
return;
}
- if (*(int *)(data + 0x38) != 0) {
- *(int *)(data + 0x22c) = FUN_001f96f8(0xf0);
- *(int *)(data + 0x38) = 0;
- }
- if (FUN_001f9740(data + 0x22c) != 0) {
- *(float *)(data + 0x228) = *(float *)(data + 0x224);
- } else {
- *(float *)(data + 0x228) = *(float *)(data + 0x224) + 20.0f;
- }
- if (*(int *)(data + 0x260) <= 0 ||
- ((u8 *)D_L01_0015FFD8)[*(int *)(data + 0x260) * 0x100 + 0xbc] != 0) {
- shape = (int *)D_L01_001B0930[*(int *)(data + 0x24c)];
- if (FUN_L00_0025ff38(*(float *)(data + 0x228), moby, data + 0x1c0,
- 0, 0, shape + 4, *shape) != 2) {
- if (FUN_001f9b80(data + 0x210, data + 0x1c0) > *(float *)(data + 0x228) ||
- FUN_001f99c0(*(float *)(moby + 0x18) - *(float *)(data + 0x1c8)) > 3.0f) {
- *(int *)(data + 0x204) = 2;
- }
- }
+ if (*(int *)(d + 0x38) != 0) {
+ *(int *)(d + 0x22C) = scale_game_frames(0xF0);
+ *(int *)(d + 0x38) = 0;
}
- selected = *(int *)(data + 0x248);
- if (selected < 0) {
- effect = *(int *)(data + 0x200);
+ if (tick_countdown_32_alt(d + 0x22C) != 0) {
+ *(float *)(d + 0x228) = *(float *)(d + 0x224);
} else {
- char *other;
- other = FUN_L01_002ef478(moby, selected);
- if (other != 0) {
- dist = FUN_001f9b80(moby + 0x10, other + 0x10);
- if (dist < *(float *)(data + 0x228)) {
- if (*(int *)(data + 0x204) == 2 ||
- FUN_001f9b80(moby + 0x10, *(char **)(data + 0x200) + 0x10) > dist) {
- *(char **)(data + 0x200) = other;
- *(int *)(data + 0x204) = 1;
+ *(float *)(d + 0x228) = *(float *)(d + 0x224) + 20.0f;
+ }
+ c260 = *(int *)(d + 0x260);
+ if (c260 <= 0 || *(unsigned char *)((c260 << 8) + (*(int *)&D_L01_0015FFD8) + 0xBC) != 0) {
+ e = D_L01_001B0930[*(int *)(d + 0x24C)];
+ b = d + 0x1C0;
+ if (FUN_L00_0025ff38(*(float *)(d + 0x228), m, b, 0, 0, e + 0x10, *(int *)e) != 2) {
+ if (*(float *)(d + 0x228) < vector_distance_xy_alt(d + 0x210, b)
+ || 3.0f < absolute_float(*(float *)(m + 0x18) - *(float *)(d + 0x1C8))) {
+ *(int *)(d + 0x204) = 2;
+ }
+ }
+ }
+ c = *(int *)(d + 0x248);
+ if (c >= 0) {
+ cand = FUN_L01_002ef478_c(m, c);
+ if (cand != 0) {
+ dist = vector_distance_xy_alt(m + 0x10, cand + 0x10);
+ if (dist < *(float *)(d + 0x228)) {
+ if (*(int *)(d + 0x204) == 2
+ || dist < vector_distance_xy_alt(m + 0x10, *(char **)(d + 0x200) + 0x10)) {
+ *(char **)(d + 0x200) = cand;
+ *(int *)(d + 0x204) = 1;
}
}
}
- effect = *(int *)(data + 0x200);
}
- angle_step = frame_time;
- if (effect == 0) {
- *(char **)(data + 0x200) = (char *)D_001413D0[0];
- angle_step = D_L01_0015ED6C;
+ if (*(int *)(d + 0x200) == 0) {
+ *(int *)(d + 0x200) = *(int *)(((char *)((char (*))D_001413D0)));
}
- *(float *)(data + 0x254) = FUN_001fa580(*(float *)(data + 0x254), angle_step * 9.424778f);
- *(int *)(moby + 0x90) = fast_tween_color((FUN_001f9de0(*(float *)(data + 0x254)) + 1.0f) * 0.5f,
- D_L01_00161998, D_L01_0016199C);
+ ang = fast_add_rotations_c(*(float *)(d + 0x254), frame_time * 9.424778f);
+ *(float *)(d + 0x254) = ang;
+ *(int *)(m + 0x90) = fast_tween_color((fast_sin_c(ang) + 1.0f) * 0.5f,
+ *(int *)&D_L01_00161998, *(int *)&D_L01_0016199C);
}
-#endif
#ifndef NON_MATCHING
INCLUDE_ASM("config/us/overlays/asm/FUN_L01_002ef350.s", FUN_L01_002ef350);
#else
extern short *lists_2ef478[] __asm__("D_L01_001ABCC0");
-extern char *ents_2ef478 __asm__("D_L01_0015FFD8");
+extern char *D_L01_0015FFD8;
extern void FUN_L00_00250df8(void *);
char *FUN_L01_002ef350(char *self) {
@@ -2252,7 +2256,7 @@ char *FUN_L01_002ef350(char *self) {
entry = *(volatile unsigned char *)(self + 0x21);
entities = (char *)(lists_2ef478 + entry);
list = *(short **)entities;
- entities = ents_2ef478;
+ entities = D_L01_0015FFD8;
if (list == 0) return 0;
goto scan;
do {
@@ -2306,8 +2310,8 @@ typedef struct {
extern float dist_2ef478(void *, void *) __asm__("FUN_001f9b48");
extern short *lists_2ef478[] __asm__("D_L01_001ABCC0");
-extern Ent_2ef478 *ents_m_2ef478 __asm__("D_L01_0015FFD8");
-extern char *ents_2ef478 __asm__("D_L01_0015FFD8");
+extern char *D_L01_0015FFD8;
+extern char *D_L01_0015FFD8;
/* Nearest live entity of type 0x26F in list idx within 120 units of self, or 0. */
char *FUN_L01_002ef478(char *self, int idx) {
@@ -2319,13 +2323,13 @@ char *FUN_L01_002ef478(char *self, int idx) {
}
while (1) {
int i = *(unsigned short *)list & 0x7FFF;
- if (ents_m_2ef478[i].flags & 0x1000) {
- if (ents_m_2ef478[i].type == 0x26F) {
- if (ents_m_2ef478[i].state < 0x7F) {
- float d = dist_2ef478(ents_m_2ef478[i].pos, self + 0x10);
+ if ((*(Ent_2ef478 * *)&D_L01_0015FFD8)[i].flags & 0x1000) {
+ if ((*(Ent_2ef478 * *)&D_L01_0015FFD8)[i].type == 0x26F) {
+ if ((*(Ent_2ef478 * *)&D_L01_0015FFD8)[i].state < 0x7F) {
+ float d = dist_2ef478((*(Ent_2ef478 * *)&D_L01_0015FFD8)[i].pos, self + 0x10);
if (d < best) {
best = d;
- res = ents_2ef478 + (i << 8);
+ res = D_L01_0015FFD8 + (i << 8);
}
}
}
@@ -2412,7 +2416,7 @@ extern s32 D_L01_00161A2C __attribute__((sda));
extern s32 D_L01_00161A30 __attribute__((sda));
extern s32 D_L01_00161A34 __attribute__((sda));
extern f32 D_L01_00161A38 __attribute__((sda));
-extern f32 D_0015ED6C;
+
extern f32 D_0015ED70;
extern void FUN_L00_0025f8e0(void *, f32);
extern int fast_tween_color(f32, s32, s32) __asm__("FUN_001fa6e0");
@@ -2442,13 +2446,13 @@ void FUN_L01_002ef770(unsigned char *moby, f32 *mode) {
radius = random_float_between_alt(D_L01_00161A00, D_L01_00161A04);
lateral = random_float_between_alt(D_L01_00161A08, D_L01_00161A0C);
vertical = random_float_between_alt(0.0f, D_L01_00161A38);
- scale_vector_xyz(origin_copy, mode, vertical * D_0015ED6C);
+ scale_vector_xyz(origin_copy, mode, vertical * frame_time_gp);
scale = fast_cos(angle);
- origin[0] += scale * (radius * D_0015ED6C);
+ origin[0] += scale * (radius * frame_time_gp);
scale = fast_sin(angle);
- scaled_radius = radius * D_0015ED6C;
+ scaled_radius = radius * frame_time_gp;
origin[1] += scale * scaled_radius;
- scaled_vertical = lateral * D_0015ED6C;
+ scaled_vertical = lateral * frame_time_gp;
origin[2] += scaled_vertical;
qcopy(velocity, origin_copy);
next = i + 1;
@@ -2458,7 +2462,7 @@ void FUN_L01_002ef770(unsigned char *moby, f32 *mode) {
origin[3] = scale * D_L01_00161A14;
velocity[3] = scale * D_L01_00161A18;
FUN_L00_0025f8e0(pos, D_L01_001619F8);
- FUN_L00_0025f8e0(velocity, D_L01_001619FC * D_0015ED6C);
+ FUN_L00_0025f8e0(velocity, D_L01_001619FC * frame_time_gp);
lower = fast_tween_color(random_float_between_alt(0.0f, 1.0f), D_L01_00161A1C, D_L01_00161A24);
upper = fast_tween_color(random_float_between_alt(0.0f, 1.0f), D_L01_00161A20, D_L01_00161A28);
first = scale_game_frames(D_L01_00161A2C);
@@ -2535,7 +2539,7 @@ extern float FUN_L00_00258110_w7(float *vel, float cur, float target, float k, f
float max) __asm__("FUN_L00_00258110");
extern int FUN_001f96f8_w7(int) __asm__("FUN_001f96f8");
extern void blend_moby_animation_w7(void *m, int a, int b, int c) __asm__("FUN_00212f90");
-extern float D_0015ED70_w7 __asm__("D_0015ED70");
+extern float D_0015ED70_lui __asm__("D_0015ED70");
void FUN_L01_002f2b68(unsigned char *m) {
char *d;
@@ -2546,7 +2550,7 @@ void FUN_L01_002f2b68(unsigned char *m) {
if (m[0x20] != 0) {
if (D_0013D4C5 != 0) {
if (hero.items[2].item_id == 5) {
- float s = D_0015ED70_w7;
+ float s = D_0015ED70_lui;
*(float *)(m + 0x48) =
FUN_L00_00258110_w7((float *)(d + 4), *(float *)(m + 0x48), *(float *)d,
s * 6.2831855f, s * 5.7595863f, 0.0f);
@@ -2651,7 +2655,7 @@ typedef struct {
s32 count; /* spawn budget; the moby is deleted when it runs out */
} AreaVars_2f2eb8;
-extern s32 D_0015ED84_2f2eb8 __asm__("D_0015ED84");
+extern int D_0015ED84;
extern s32 *D_L01_001B0930_2f2eb8[] __asm__("D_L01_001B0930");
extern void FUN_0020c828_2f2eb8(struct Moby *) __asm__("FUN_0020c828");
extern s32 FUN_L00_00259740_2f2eb8(void *, void *, s32) __asm__("FUN_L00_00259740");
@@ -2675,8 +2679,8 @@ void FUN_L01_002f2eb8(struct Moby *m) {
qcopy(&v->home, &m->pos);
m->flags |= 0x41;
m->state = 1;
- if (m->command == 0 && D_0015ED84_2f2eb8 < 20) {
- k = D_0014BF10[D_L01_00161AF0 / 2 + D_0015ED84_2f2eb8 * 16];
+ if (m->command == 0 && D_0015ED84 < 20) {
+ k = D_0014BF10[D_L01_00161AF0 / 2 + D_0015ED84 * 16];
if (D_L01_00161AF0 & 1) {
k &= 0xF;
} else {
@@ -2909,7 +2913,7 @@ void FUN_L01_002f5168(char *moby) {
if (F2(data, 0x130) > 500.0f) F2(data, 0x130) = FUN_0026c9c8_2f5168(-1.0f, 1.0f) * F2(data, 0x130) / 1000.0f;
if (F2(data, 0x134) > 500.0f) F2(data, 0x134) = FUN_0026c9c8_2f5168(-1.0f, 1.0f) * F2(data, 0x134) / 1000.0f;
if (path_state->path_id == -1) { B2(moby, 0x20) = 2; return; }
- B2(data, 0x121) = (((((int)moby - (int)D_L01_0015FFD8) >> 8) + (int)((unsigned int)((int)moby - (int)D_L01_0015FFD8) >> 31)) >> 1) % 7;
+ B2(data, 0x121) = (((((int)moby - (int)(*(int *)&D_L01_0015FFD8)) >> 8) + (int)((unsigned int)((int)moby - (int)(*(int *)&D_L01_0015FFD8)) >> 31)) >> 1) % 7;
FUN_L01_0028b410((char *)path_state);
if (path_state->state == 0) {
if (path_state->index <= 0) {
@@ -2951,7 +2955,7 @@ void FUN_L01_002f5168(char *moby) {
link = (int *)(data + 0x140);
for (; i < 4; ++i, node += 0x10, ++link) {
if ((B2(data, 0x120) & (2 << i)) && *link != -1) {
- child = D_L01_0015FFD8 + (*link << 8);
+ child = (*(int *)&D_L01_0015FFD8) + (*link << 8);
if (child && (child_data = *(char **)(child + 0x78)) != 0) {
I2(child_data, 0x70) |= 0x1000;
FUN_002645a8_2f5168(moby, i, node);
@@ -3042,7 +3046,7 @@ void FUN_L01_002f5168(char *moby) {
if (!(B2(data, 0x120) & 1)) {
j = *(int *)(data + link_offset + 0x140);
if (j != -1) {
- child = D_L01_0015FFD8 + (j << 8);
+ child = (*(int *)&D_L01_0015FFD8) + (j << 8);
if (child && (child_data = *(char **)(child + 0x78)) != 0) {
FUN_00221410_2f5168(work, work, 1.0f);
I2(child_data, 0x70) |= 0x1000;
diff --git a/src/overlays/shared/gameplay/entities/plasmabot.c b/src/overlays/shared/gameplay/entities/plasmabot.c
index 9dc3e9d8cc..d13f5d4399 100644
--- a/src/overlays/shared/gameplay/entities/plasmabot.c
+++ b/src/overlays/shared/gameplay/entities/plasmabot.c
@@ -657,7 +657,7 @@ extern f32 D_L14_001614B4 __attribute__((sda));
extern f32 D_L14_001614B8 __attribute__((sda));
extern void FUN_L14_002b3a20_c(struct Moby *) __asm__("FUN_L14_002b3a20");
-extern void FUN_L14_002b2928(struct Moby *);
+extern void FUN_L14_002b2928_u(struct Moby *) __asm__("FUN_L14_002b2928");
extern void enqueue_callback_list_1(void (*)(struct Moby *), struct Moby *) __asm__("FUN_001f4600");
extern void moby_point_position(struct Moby *, s32, void *) __asm__("FUN_L00_0024f7c8");
extern void build_moby_bone_transform(struct Moby *, s32, void *) __asm__("FUN_0020cca8");
@@ -729,172 +729,155 @@ void FUN_L14_002b2600(struct Moby *m)
FUN_001f9a10(&pv->beam_start, &pv->beam_start, &dz);
fast_vec_scale(&dy, &dy, -2.0f);
FUN_001f9a10(&pv->beam_end, &pv->beam_start, &dy);
- enqueue_callback_list_1(FUN_L14_002b2928, m);
+ enqueue_callback_list_1(FUN_L14_002b2928_u, m);
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L14_002b2928.s", FUN_L14_002b2928);
-#else
-#include "rnc/rendering/geometry_quad.h"
-
-extern Vec4 D_0013F5E0;
-extern Vec4 D_L14_001D8850[4];
-extern f32 D_L14_001614AC __attribute__((sda));
-extern f32 D_L14_001614BC __attribute__((sda));
-extern f32 D_L14_001614C0 __attribute__((sda));
-extern u64 get_effect_texture_l14(s32) __asm__("FUN_001f44b8");
-extern void draw_geometry_quad_l14(struct GeometryQuad *, s32, s32) __asm__("FUN_001f7d30");
-extern void cross_vectors_l14(void *, void *, void *) __asm__("FUN_001f9ad8");
-extern void transform_vector_l14(void *, void *, void *) __asm__("FUN_001f9d20");
-
-void FUN_L14_002b2928(struct Moby *m)
-{
- struct GeometryQuad quad;
- Vec4 basis[3];
- Vec4 pos;
- Vec4 offset;
- ShipVars *pv = (ShipVars *)m->pvars;
- Vec4 *corner;
- Vec4 *template;
- Vec4 *beam_start;
- Vec4 *beam_end;
- s32 color;
- s32 i;
+/* Ported from rac1-decomp (src/overlays/shared/vendor_002B2A28.c: func_L14_002B3B78), where it is exact; names translated to the US level program. */
- {
- Vec4 *corner;
- Vec4 *template;
- s32 i;
- qcopy(&pos, &pv->exhaust);
- pos.f[3] = 1.0f;
- FUN_001f9a28(&basis[0], &D_L14_001674C0, &pos);
- i = 3;
- fast_vec_normalize(&basis[0], &basis[0], 1.0f);
- cross_vectors_l14(&basis[1], &basis[0], &D_0013F5E0);
- fast_vec_normalize(&basis[1], &basis[1], -1.0f);
- cross_vectors_l14(&basis[2], &basis[1], &basis[0]);
- quad.texture = get_effect_texture_l14(11);
- quad.primitive = 0x8000000048LL;
- quad.texture_state = 0xFF9000000260LL;
- quad.reserved.value = 5;
- quad.colors[3] = 0x80FFFFFF;
- quad.colors[2] = 0x80FFFFFF;
- quad.colors[1] = 0x80FFFFFF;
- quad.colors[0] = 0x80FFFFFF;
- quad.texture_coordinates[0][0] = 0.0f;
- quad.texture_coordinates[0][1] = 0.0f;
- quad.texture_coordinates[1][0] = 0.0f;
- quad.texture_coordinates[1][1] = 1.0f;
- quad.texture_coordinates[2][0] = 1.0f;
- quad.texture_coordinates[2][1] = 0.0f;
- quad.texture_coordinates[3][0] = 1.0f;
- quad.texture_coordinates[3][1] = 1.0f;
- corner = &quad.positions[0];
- do {
- template = &D_L14_001D8850[3 - i];
- fast_vec_scale(corner, template, 0.4f);
- transform_vector_l14(corner, corner, &basis[0]);
- corner++;
- i--;
- } while (i >= 0);
- draw_geometry_quad_l14(&quad, 0, 0);
- }
-
- qcopy(&pos, &pv->joint6);
- beam_end = &pv->beam_end;
- FUN_001f9a28(&basis[0], &D_L14_001674C0, &pos);
- beam_start = &pv->beam_start;
- fast_vec_normalize(&basis[0], &basis[0], 1.0f);
- cross_vectors_l14(&basis[1], &basis[0], &D_0013F5E0);
- fast_vec_normalize(&basis[1], &basis[1], -1.0f);
- cross_vectors_l14(&basis[2], &basis[1], &basis[0]);
- quad.colors[3] = 0x202020FF;
- quad.colors[2] = 0x202020FF;
- quad.colors[1] = 0x202020FF;
- quad.colors[0] = 0x202020FF;
- i = 3;
- corner = &quad.positions[0];
- do {
- template = &D_L14_001D8850[3 - i];
- fast_vec_scale(corner, template, 0.2f);
- transform_vector_l14(corner, corner, &basis[0]);
- corner++;
- i--;
- } while (i >= 0);
- draw_geometry_quad_l14(&quad, 0, 0);
-
- qcopy(&pos, &pv->nozzle);
- FUN_001f9a28(&basis[0], &D_L14_001674C0, &pos);
- fast_vec_normalize(&basis[0], &basis[0], 1.0f);
- cross_vectors_l14(&basis[1], &basis[0], &D_0013F5E0);
- fast_vec_normalize(&basis[1], &basis[1], -1.0f);
- cross_vectors_l14(&basis[2], &basis[1], &basis[0]);
- fast_vec_scale(&offset, &basis[0], D_L14_001614AC);
- FUN_001f9a10(&pos, &pos, &offset);
- quad.colors[3] = 0x4020FF20;
- quad.colors[2] = 0x4020FF20;
- quad.colors[1] = 0x4020FF20;
- quad.colors[0] = 0x4020FF20;
- i = 3;
- corner = &quad.positions[0];
- do {
- template = &D_L14_001D8850[3 - i];
- fast_vec_scale(corner, template, 0.2f);
- transform_vector_l14(corner, corner, &basis[0]);
- corner++;
- i--;
- } while (i >= 0);
- draw_geometry_quad_l14(&quad, 0, 0);
-
- qcopy(&pos, beam_start);
- FUN_001f9a28(&basis[0], &D_L14_001674C0, &pos);
- fast_vec_normalize(&basis[0], &basis[0], 1.0f);
- cross_vectors_l14(&basis[1], &basis[0], &D_0013F5E0);
- fast_vec_normalize(&basis[1], &basis[1], -1.0f);
- cross_vectors_l14(&basis[2], &basis[1], &basis[0]);
- fast_vec_scale(&offset, &basis[0], D_L14_001614BC);
- FUN_001f9a10(&pos, &pos, &offset);
- /* The preceding four-corner loop leaves i == -1, so this shifts by 24. */
- color = 0x40;
- color <<= i + 25;
- quad.colors[3] = color | 0xFF2020;
- quad.colors[2] = color | 0xFF2020;
- quad.colors[1] = color | 0xFF2020;
- quad.colors[0] = color | 0xFF2020;
- i = 3;
- corner = &quad.positions[0];
- do {
- template = &D_L14_001D8850[3 - i];
- fast_vec_scale(corner, template, D_L14_001614C0);
- transform_vector_l14(corner, corner, &basis[0]);
- corner++;
- i--;
- } while (i >= 0);
- draw_geometry_quad_l14(&quad, 0, 0);
-
- qcopy(&pos, beam_end);
- FUN_001f9a28(&basis[0], &D_L14_001674C0, &pos);
- fast_vec_normalize(&basis[0], &basis[0], 1.0f);
- cross_vectors_l14(&basis[1], &basis[0], &D_0013F5E0);
- fast_vec_normalize(&basis[1], &basis[1], -1.0f);
- cross_vectors_l14(&basis[2], &basis[1], &basis[0]);
- fast_vec_scale(&offset, &basis[0], D_L14_001614BC);
- FUN_001f9a10(&pos, &pos, &offset);
- quad.colors[3] = color | 0xFF2020;
- quad.colors[2] = color | 0xFF2020;
- quad.colors[1] = color | 0xFF2020;
- quad.colors[0] = color | 0xFF2020;
- i = 3;
- corner = &quad.positions[0];
- do {
- template = &D_L14_001D8850[3 - i];
- fast_vec_scale(corner, template, D_L14_001614C0);
- transform_vector_l14(corner, corner, &basis[0]);
- corner++;
- i--;
- } while (i >= 0);
- draw_geometry_quad_l14(&quad, 0, 0);
+typedef u32 VecQuad __attribute__((mode(TI), aligned(16)));
+
+typedef union {
+ VecQuad q;
+ f32 f[4];
+ s32 i[4];
+} Vec4_2b2928;
+
+extern Vec4_2b2928 D_L14_001D8850_lui[] __asm__("D_L14_001D8850") __attribute__((section(".data")));
+extern char D_0013F5E0[] __attribute__((section(".data")));
+extern Vec4 D_L14_001674C0 __attribute__((section(".data")));
+extern float D_L14_001614AC __attribute__((sda)); /* no foreign declaration */
+extern float D_L14_001614BC __attribute__((sda)); /* no foreign declaration */
+extern float D_L14_001614C0 __attribute__((sda)); /* no foreign declaration */
+extern s64 get_effect_texture(s32) __asm__("func_001F44B8");
+extern void add_vector_xyz_c2(void *, void *, void *) __asm__("FUN_001f9a10");
+extern void cross_vectors_xyz(void *, void *, void *) __asm__("func_001F9AD8");
+extern void fast_draw_quad_real(void *, void *, s32);
+extern void fast_vec_scale_c(void *, void *, f32) __asm__("func_001F9A68");
+extern void subtract_vector_xyz_c3(void *, void *, void *) __asm__("FUN_001f9a28");
+extern void transform_vector(void *, void *, void *) __asm__("func_001F9D20");
+extern float D_L14_001614AC_lui __asm__("D_L14_001614AC");
+extern float D_L14_001614BC_lui __asm__("D_L14_001614BC");
+extern float D_L14_001614C0_lui __asm__("D_L14_001614C0");
+
+void FUN_L14_002b2928(char *moby) {
+ char *data = *(char **)(moby + 0x78);
+ struct {
+ Vec4_2b2928 o[4];
+ unsigned int c[4];
+ float g[8];
+ u64 t[4];
+ } pk;
+ Vec4_2b2928 m[4];
+ Vec4_2b2928 w;
+ char *pp;
+ char *q;
+ char *r;
+ int i;
+ int j;
+ int a;
+
+ qcopy(&m[3], data + 0x1E0);
+ m[3].f[3] = 1.0f;
+ subtract_vector_xyz_c3(&m[0], ((char *)&D_L14_001674C0), &m[3]);
+ fast_vec_normalize(&m[0], &m[0], 1.0f);
+ cross_vectors_xyz(&m[1], &m[0], D_0013F5E0);
+ fast_vec_normalize(&m[1], &m[1], -1.0f);
+ cross_vectors_xyz(&m[2], &m[1], &m[0]);
+ pk.t[1] = get_effect_texture(11);
+ pk.t[3] = 0x8000000048ULL;
+ pk.t[2] = 0xFF9000000260ULL;
+ pk.t[0] = 5;
+ pk.c[3] = 0x80FFFFFF;
+ pk.c[2] = 0x80FFFFFF;
+ pk.c[1] = 0x80FFFFFF;
+ pk.c[0] = 0x80FFFFFF;
+ pk.g[0] = 0.0f;
+ pk.g[1] = 0.0f;
+ pk.g[2] = 0.0f;
+ pk.g[3] = 1.0f;
+ pk.g[4] = 1.0f;
+ pk.g[5] = 0.0f;
+ pk.g[6] = 1.0f;
+ pk.g[7] = 1.0f;
+ for (i = 0; i < 4; i++) {
+ fast_vec_scale_c(&pk.o[i], &D_L14_001D8850_lui[i], 0.4f);
+ transform_vector(&pk.o[i], &pk.o[i], &m[0]);
+ }
+ fast_draw_quad_real(&pk, 0, 0);
+
+ qcopy(&m[3], data + 0x200);
+ pp = data + 0x220;
+ subtract_vector_xyz_c3(&m[0], ((char *)&D_L14_001674C0), &m[3]);
+ r = data + 0x210;
+ q = data + 0x1F0;
+ fast_vec_normalize(&m[0], &m[0], 1.0f);
+ cross_vectors_xyz(&m[1], &m[0], D_0013F5E0);
+ fast_vec_normalize(&m[1], &m[1], -1.0f);
+ cross_vectors_xyz(&m[2], &m[1], &m[0]);
+ pk.c[3] = 0x202020FF;
+ pk.c[2] = 0x202020FF;
+ pk.c[1] = 0x202020FF;
+ pk.c[0] = 0x202020FF;
+ for (j = 0; j < 4; j++) {
+ fast_vec_scale_c(&pk.o[j], &D_L14_001D8850_lui[j], 0.2f);
+ transform_vector(&pk.o[j], &pk.o[j], &m[0]);
+ }
+ fast_draw_quad_real(&pk, 0, 0);
+
+ qcopy(&m[3], q);
+ subtract_vector_xyz_c3(&m[0], ((char *)&D_L14_001674C0), &m[3]);
+ fast_vec_normalize(&m[0], &m[0], 1.0f);
+ cross_vectors_xyz(&m[1], &m[0], D_0013F5E0);
+ fast_vec_normalize(&m[1], &m[1], -1.0f);
+ cross_vectors_xyz(&m[2], &m[1], &m[0]);
+ fast_vec_scale_c(&w, &m[0], D_L14_001614AC_lui);
+ add_vector_xyz_c2(&m[3], &m[3], &w);
+ pk.c[3] = 0x4020FF20;
+ pk.c[2] = 0x4020FF20;
+ pk.c[1] = 0x4020FF20;
+ pk.c[0] = 0x4020FF20;
+ a = 0x40;
+ for (j = 0; j < 4; j++) {
+ fast_vec_scale_c(&pk.o[j], &D_L14_001D8850_lui[j], 0.2f);
+ transform_vector(&pk.o[j], &pk.o[j], &m[0]);
+ }
+ fast_draw_quad_real(&pk, 0, 0);
+
+ qcopy(&m[3], r);
+ subtract_vector_xyz_c3(&m[0], ((char *)&D_L14_001674C0), &m[3]);
+ fast_vec_normalize(&m[0], &m[0], 1.0f);
+ cross_vectors_xyz(&m[1], &m[0], D_0013F5E0);
+ fast_vec_normalize(&m[1], &m[1], -1.0f);
+ cross_vectors_xyz(&m[2], &m[1], &m[0]);
+ fast_vec_scale_c(&w, &m[0], D_L14_001614BC_lui);
+ add_vector_xyz_c2(&m[3], &m[3], &w);
+ pk.c[3] = (a << 24) | 0xFF2020;
+ pk.c[2] = (a << 24) | 0xFF2020;
+ pk.c[1] = (a << 24) | 0xFF2020;
+ pk.c[0] = (a << 24) | 0xFF2020;
+ for (j = 0; j < 4; j++) {
+ fast_vec_scale_c(&pk.o[j], &D_L14_001D8850_lui[j], D_L14_001614C0_lui);
+ transform_vector(&pk.o[j], &pk.o[j], &m[0]);
+ }
+ fast_draw_quad_real(&pk, 0, 0);
+
+ qcopy(&m[3], pp);
+ subtract_vector_xyz_c3(&m[0], ((char *)&D_L14_001674C0), &m[3]);
+ fast_vec_normalize(&m[0], &m[0], 1.0f);
+ cross_vectors_xyz(&m[1], &m[0], D_0013F5E0);
+ fast_vec_normalize(&m[1], &m[1], -1.0f);
+ cross_vectors_xyz(&m[2], &m[1], &m[0]);
+ fast_vec_scale_c(&w, &m[0], D_L14_001614BC_lui);
+ add_vector_xyz_c2(&m[3], &m[3], &w);
+ pk.c[3] = (a << 24) | 0xFF2020;
+ pk.c[2] = (a << 24) | 0xFF2020;
+ pk.c[1] = (a << 24) | 0xFF2020;
+ pk.c[0] = (a << 24) | 0xFF2020;
+ for (j = 0; j < 4; j++) {
+ fast_vec_scale_c(&pk.o[j], &D_L14_001D8850_lui[j], D_L14_001614C0_lui);
+ transform_vector(&pk.o[j], &pk.o[j], &m[0]);
+ }
+ fast_draw_quad_real(&pk, 0, 0);
}
-#endif
#include "sda.h"
#include "rnc/gameplay/entities/moby.h"
@@ -945,7 +928,7 @@ extern float D_L14_001614C8 __attribute__((sda));
extern void FUN_L00_00257470(void *, int, int);
extern void FUN_L00_0025d458(void *m, short *p);
extern void FUN_L00_0025d538(void *, void *);
-extern char D_0013E633_x[] __asm__("D_0013E533");
+extern char D_0013E533[];
extern void func_L00_0025D5B0_i(void *, void *, float, int, int, int) __asm__("FUN_L00_0025c558");
void FUN_L14_002b2f60(char *moby) {
@@ -1013,7 +996,7 @@ void FUN_L14_002b2f60(char *moby) {
y = fast_arc_tan(*(float *)(hit_info + 0x10), *(float *)(hit_info + 0x14));
func_L00_0025D5B0_i(moby, state + 0x60, y, 8, scale_game_frames(5), 0);
((unsigned char *)state)[0xC7] = 0xFA;
- if (((unsigned char *)D_0013E633_x)[0x2EC1] == 2) {
+ if (((unsigned char *)D_0013E533)[0x2EC1] == 2) {
FUN_L00_00257470(moby, 0x200, -1);
} else {
FUN_L00_00257470(moby, 0, -1);
@@ -1152,7 +1135,7 @@ typedef struct {
unsigned long a, b, c, d;
} Pk_2af4a0;
-extern char D_L14_001674C0_d[] __asm__("D_L14_001674C0") __attribute__((section(".data")));
+extern Vec4 D_L14_001674C0 __attribute__((section(".data")));
extern float D_L14_001D8890[4][4];
extern float D_L14_001614F8 __attribute__((sda));
extern float D_L14_001614FC __attribute__((sda));
@@ -1184,7 +1167,7 @@ void FUN_L14_002b3a20(char *m) {
pk.a = 0;
vu1_add_g_sregister(0x4A, 0);
vu1_add_g_sregister(0x47, 0x51001);
- subtract_vector_xyz(v, D_L14_001674C0_d, pos);
+ subtract_vector_xyz(v, ((char *)&D_L14_001674C0), pos);
len = vector_length_xyz(v);
if (0.0f < len) {
float s = D_L14_001614FC;
@@ -1312,7 +1295,7 @@ int FUN_L14_002d9870(int i) {
data[2] = FUN_001f96f8(0x3C);
return r;
}
-extern f32 D_0015ED60_de670 __asm__("D_0015ED60");
+extern float D_0015ED60;
#define DE670_THRESHOLD D_L14_00161B20
#define DE670_DAMPING D_L14_00161B1C
#define DE670_GRAVITY D_L14_00161B18
@@ -1353,15 +1336,15 @@ void FUN_L14_002de670(struct Moby *moby) {
}
FUN_001f9a10(&moby->pos, &moby->pos, velocity);
absolute_velocity = absolute_float(velocity[0]);
- if (DE670_THRESHOLD * D_0015ED60_de670 < absolute_velocity) {
- velocity[0] *= (DE670_DAMPING - 1.0f) * D_0015ED60_de670 + 1.0f;
+ if (DE670_THRESHOLD * D_0015ED60 < absolute_velocity) {
+ velocity[0] *= (DE670_DAMPING - 1.0f) * D_0015ED60 + 1.0f;
}
absolute_velocity = absolute_float(velocity[1]);
- if (DE670_THRESHOLD * D_0015ED60_de670 < absolute_velocity) {
- velocity[1] *= (DE670_DAMPING - 1.0f) * D_0015ED60_de670 + 1.0f;
+ if (DE670_THRESHOLD * D_0015ED60 < absolute_velocity) {
+ velocity[1] *= (DE670_DAMPING - 1.0f) * D_0015ED60 + 1.0f;
}
if (velocity[2] > 0.0f) {
- velocity[2] *= (DE670_DAMPING - 1.0f) * D_0015ED60_de670 + 1.0f;
+ velocity[2] *= (DE670_DAMPING - 1.0f) * D_0015ED60 + 1.0f;
}
velocity[2] -= DE670_GRAVITY * frame_scale_sq;
moby->rot.x = fast_add_rotations(moby->rot.x, velocity[4]);
diff --git a/src/overlays/shared/gameplay/entities/sentrybot.c b/src/overlays/shared/gameplay/entities/sentrybot.c
index b1270b739e..568e7c5ed7 100644
--- a/src/overlays/shared/gameplay/entities/sentrybot.c
+++ b/src/overlays/shared/gameplay/entities/sentrybot.c
@@ -1483,7 +1483,7 @@ void FUN_L15_0029aba8(char *m) {
#include "rnc/overlay/quad.h"
extern char D_L15_001673C0_y[] __asm__("D_L15_001673C0");
extern int D_L15_00174458_y[] __asm__("D_L15_00174458");
-extern float D_0015ED6C_y __asm__("D_0015ED6C");
+extern float D_0015ED6C;
extern float dist_y(void *, void *) __asm__("FUN_001f9b48");
extern int sound_y(int, int, void *, int) __asm__("FUN_L00_0028dc90");
extern float addrot_y(float, float) __asm__("FUN_001fa580");
@@ -1512,7 +1512,7 @@ void FUN_L15_0029ac30(unsigned char *m) {
if (m[0x20] != 0)
return;
s = 1.0f;
- *(float *)(m + 0x40) = addrot_y(*(float *)(m + 0x40), D_0015ED6C_y * 6.2831855f);
+ *(float *)(m + 0x40) = addrot_y(*(float *)(m + 0x40), D_0015ED6C * 6.2831855f);
add_y(next, m + 0x10, d);
scale_y(back, d, -2.0f);
add_y(back, back, m + 0x10);
@@ -1534,7 +1534,7 @@ void FUN_L15_0029ac30(unsigned char *m) {
/* Ported from rac1-decomp (src/overlays/shared/vendor_00298BB8.c: func_L15_0029BFF8), where it is exact; names translated to the US level program. */
extern char *spawn_spark(void *, void *, void *, int, int, int, int, int, int) __asm__("FUN_00218888");
-extern float D_0015ED6C_c __asm__("D_0015ED6C");
+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");
@@ -1559,31 +1559,31 @@ extern void scale_vector_xyz(void *out, void *a, f32 s) __asm__("FUN_001f9a68");
extern int func_001FA898_r(float) __asm__("FUN_001fa6d0");
void FUN_L15_0029ae18(char *moby) {
- float v2[4];
- float v0[4];
- float v1[4];
+ float noise[4];
+ float spark_a[4];
+ float spark_b[4];
char *data = *(char **)(moby + 0x78);
float s;
int a, b, c;
s = *(float *)&D_L15_00161440;
- s *= D_0015ED6C_c;
- scale_vector_xyz(v0, data, *(float *)&D_L15_00161448);
- random_vector(v2, s, s);
- add_vector_xyz(v0, v0, v2);
+ s *= D_0015ED6C;
+ scale_vector_xyz(spark_a, data, *(float *)&D_L15_00161448);
+ random_vector(noise, s, s);
+ add_vector_xyz(spark_a, spark_a, noise);
s = *(float *)&D_L15_00161444;
- s *= D_0015ED6C_c;
- scale_vector_xyz(v1, data, *(float *)&D_L15_0016144C);
- random_vector(v2, s, s);
- add_vector_xyz(v1, v1, v2);
- v0[3] = *(float *)&D_L15_00161420;
- v1[3] = *(float *)&D_L15_00161424;
+ s *= D_0015ED6C;
+ scale_vector_xyz(spark_b, data, *(float *)&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;
a = func_001FA898_r(multiply_global_factor_ed64(
random_float_between_alt(*(float *)&D_L15_00161428, *(float *)&D_L15_0016142C)));
b = func_001FA898_r(multiply_global_factor_ed64(
random_float_between_alt(*(float *)&D_L15_00161430, *(float *)&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, v0, v1, *(int *)&D_L15_00161418, *(int *)&D_L15_0016141C, a, b, c,
+ spawn_spark(moby + 0x10, spark_a, spark_b, *(int *)&D_L15_00161418, *(int *)&D_L15_0016141C, a, b, c,
*(int *)&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. */
@@ -1603,7 +1603,454 @@ void FUN_L15_0029af88(char *moby) {
spawn_glow_particle(moby, pos, (int)&D_L15_0015F580, t, *(float *)&D_L15_00161458,
D_L15_00161464, D_L15_00161468, D_L15_0016146C, D_L15_00161460);
}
-INCLUDE_ASM("config/us/overlays/asm/FUN_L15_0029d6c0.s", FUN_L15_0029d6c0);
+/* update of moby class 256: a homing missile that leads its target, trails smoke and explodes on contact */
+/* Ported from rac1-decomp (src/overlays/shared/vendor_00298BB8.c: func_L15_0029E8A0), where it is exact; names translated to the US level program. */
+
+typedef int u128_29E8A0 __attribute__((mode(TI)));
+
+typedef struct { int w[20]; } __attribute__((aligned(16))) Tbl_29E8A0;
+
+typedef struct { int c[6]; } Cols_29E8A0;
+
+typedef struct { char pad0[2]; unsigned char f2; unsigned char f3; } Part_29E8A0;
+
+typedef struct {
+ float v[4];
+ char *moby;
+ int flags;
+ char kind;
+ char one;
+ unsigned short id;
+ float radius;
+ int count;
+} Coll_29E8A0;
+
+typedef struct {
+ float v[4];
+ char *owner;
+ int timer;
+ struct M_29E8A0 *target;
+ float zoff;
+ float speed;
+ float yawvel;
+ float pitchvel;
+ float yaw0;
+ float pitch0;
+ float speed_end;
+ int f38;
+ short f3C;
+ short f3E;
+} D_29E8A0;
+
+typedef struct M_29E8A0 {
+ char pad0[0x10];
+ float pos[4];
+ signed char state;
+ char pad21[0x1F];
+ float rot[4];
+ char pad50[0x28];
+ D_29E8A0 *data;
+ char pad7C[0x2A];
+ unsigned short id;
+ char padA8[0x14];
+ unsigned char bc;
+ char padBD[3];
+ float mtx[16];
+} M_29E8A0;
+
+extern Cols_29E8A0 D_L15_001E2660;
+extern Cols_29E8A0 D_L15_001E2678;
+extern Tbl_29E8A0 D_L15_001E2610;
+extern int D_L15_00178500[];
+extern char *FUN_L00_002af450(char *, char *, int, int, int);
+extern char D_0013E533[];
+typedef struct {
+ char pad[0x140];
+ float position[4];
+} LevelView;
+extern LevelView D_L15_00167280;
+extern char D_L15_00174440[];
+extern char D_L15_001B0D70[];
+extern f32 convert_integer_to_float_c2(s32) __asm__("func_001FA6C0");
+extern f32 fast_arc_tan(f32, f32) __asm__("func_001F9E90");
+extern f32 fast_cos_c3(f32) __asm__("func_001F9DC8");
+extern f32 fast_sin_c3(f32) __asm__("func_001F9DE0");
+extern f32 fast_vec_length(void *) __asm__("func_001F9AF0");
+extern f32 random_angle_radians(void) __asm__("func_00213308");
+extern f32 random_float_between(f32, f32) __asm__("func_002132A8");
+extern f32 square_root_scalar(f32) __asm__("func_001F9988");
+extern f32 vector_length_xy_c2(void *) __asm__("FUN_001f9b20");
+extern float D_0015ED64;
+extern float D_0015ED6C;
+extern float D_0015ED70;
+extern float D_L15_0015F5D0;
+extern float FUN_L00_001ff430(void *);
+extern float FUN_L00_00258110(float *vel, float cur, float target, float k, float d, float max);
+extern float fast_vec_dist(void *, void *);
+extern float vector_distance_xy_alt(float *, float *) __asm__("FUN_001f9b80");
+extern int D_L15_0015F30C;
+extern int FUN_001f9770(void *);
+extern int FUN_L00_001f2868(void *, float, int, void *, void *);
+extern int FUN_L00_00257b90(int, int);
+extern int allocate_voice_for_target_entry(int, int, int) __asm__("FUN_0022da68");
+extern int tick_countdown_32_alt(void *) __asm__("FUN_001f9740");
+extern s32 random_integer_below_c3(s32) __asm__("func_00213260");
+extern s32 truncate_float_to_s32_c4(f32) __asm__("func_001FA6D0");
+extern unsigned char *D_L15_001B26DC __attribute__((section(".data")));
+extern unsigned char *FUN_L00_002712b8(void *pos, float *vec, int s, int a, int col, int n, float x, float y, float z, float w, float pw);
+extern void *FUN_L00_0026bb70_c(void *, void *, int, int, float, int, int, int, int) __asm__("FUN_L00_0026bb70");
+extern void FUN_L00_001edf60(void *, int, float, float, void *, int, int, float, int);
+extern void FUN_L00_001ff290(void *, void *, void *);
+extern void FUN_L00_001ff2c0(void *, void *, void *);
+extern void FUN_L00_001ff660(void *, void *, void *);
+extern void FUN_L00_001ffd48(void *, void *, float);
+extern void FUN_L00_001ffe20(void *, void *, void *);
+extern void FUN_L00_0025a9f8(void *, void *, void *, int, int, int, int, int, float, float, float);
+extern void FUN_L00_0025f800(void *, void *);
+extern void FUN_L00_0026a4c8(void *pos, void *vel, int color, int tag, int life, float size);
+extern void FUN_L00_0026a9f0(void *, void *, int, int, float, int, int, float, int, int);
+extern void FUN_L00_0026cbb0(void *, void *, int, int, int, int, float);
+extern void FUN_L00_002ac910(char *, char *, int, int, float, int, int, int, int);
+extern void FUN_L00_002d3838(void *, void *, int, int);
+extern void build_look_at_matrix(void *out, void *dir, void *axis, f32 ang) __asm__("FUN_00214890");
+extern void build_spherical_offset_c(void *, f32, f32, f32) __asm__("func_00214DB0");
+extern void clamp_vector_length(void *, void *, float) __asm__("FUN_001f9c90");
+extern void fast_vec_normalize(void *, void *, f32) __asm__("FUN_001f9bf8");
+extern void fast_vec_scale(void *, void *, f32) __asm__("func_001F9A68");
+extern void mark_moby_for_removal_c3(void *) __asm__("func_0020C828");
+extern void multiply_matrix(void *, void *, void *) __asm__("FUN_001fa378");
+extern void set_identity_matrix(void *) __asm__("FUN_001f9fc8");
+extern void set_vector_length_xy(void *, void *, f32) __asm__("FUN_001f9c48");
+extern void subtract_vector_xyz_c2(void *, void *, void *) __asm__("FUN_001f9a28");
+extern void transform_vector_c(void *, void *, void *) __asm__("func_001F9D20");
+extern void transform_vector_by_basis(void *, void *, void *) __asm__("func_001F9CF8");
+float absolute_float(float input) __asm__("func_001F99C0");
+extern char D_0013F490[];
+extern char D_0013F350[];
+
+void FUN_L15_0029d6c0(M_29E8A0 *m) {
+ Tbl_29E8A0 tbl;
+ float v50[4];
+ float v60[4];
+ float v70[4];
+ float v80[4];
+ float v90[4];
+ float vel[4];
+ float vB0[4];
+ float up[4];
+ char *owner;
+ D_29E8A0 *d;
+ M_29E8A0 *t;
+ char *hero;
+ float yaw;
+ float pitch;
+ int k;
+
+ tbl = D_L15_001E2610;
+ owner = 0;
+ *(u128_29E8A0 *)v80 = 0;
+ v80[2] = D_0015ED6C * 8.0f;
+ *(u128_29E8A0 *)v70 = *(u128_29E8A0 *)v80;
+ *(u128_29E8A0 *)v80 = 0;
+ v80[2] = 1.0f;
+ d = m->data;
+ t = d->target;
+ d->speed = d->speed + (d->speed_end - d->speed) / 10.0f * D_0015ED64;
+ FUN_001f9770(&d->f3C);
+ {
+ float a = convert_integer_to_float_c2(d->f3C);
+ float b = convert_integer_to_float_c2(d->f3E);
+ fast_vec_scale(up, ((char *)&D_0013F490), a / b);
+ }
+ {
+ float delta[4];
+ float dv[4];
+ float tp[4];
+ float ip[4];
+ if (D_L15_0015F30C != 0 && t != 0) {
+ float f = fast_vec_dist(D_L15_001673C0, t->pos) / 50.0f;
+ qcopy(delta, t->pos);
+ delta[2] = delta[2] + d->zoff;
+ FUN_L00_001edf60(m, 0xFF0FFFFF, absolute_float(0.5f - f * 0.35f), 0.0f, delta, 0xD, -1, 90.0f, 4);
+ }
+ if (t != 0 && d->timer < scale_game_frames(0x96) - scale_game_frames(0) && t->state >= 0) {
+ float s = 0.0f;
+ qcopy(tp, t->pos);
+ tp[2] = tp[2] + d->zoff;
+ subtract_vector_xyz_c2(delta, tp, m->pos);
+ if (d->f38 != 0) {
+ float a, b, c, r1, r2, q;
+ subtract_vector_xyz_c2(dv, tp, d->v);
+ FUN_L00_001ff2c0(ip, dv, up);
+ qcopy(d->v, tp);
+ c = FUN_L00_001ff430(dv);
+ b = (dv[0] * delta[0] + dv[1] * delta[1] + dv[2] * delta[2]) * -2.0f;
+ a = d->speed * d->speed - c;
+ c = -FUN_L00_001ff430(delta);
+ q = square_root_scalar(b * b - a * 4.0f * c);
+ r1 = (-b + q) / (a + a);
+ r2 = (-b - q) / (a + a);
+ if (r1 > 0.0f && r2 > 0.0f) {
+ if (r2 < r1) s = r1;
+ else s = r2;
+ } else if (r1 > 0.0f) {
+ s = r1;
+ } else if (r2 > 0.0f) {
+ s = r2;
+ } else {
+ s = -1.0f;
+ }
+ }
+ if (s > 0.0f && s < (float)scale_game_frames(0x96)) {
+ fast_vec_scale(ip, dv, s);
+ add_vector_xyz(ip, ip, delta);
+ yaw = fast_arc_tan(ip[0], ip[1]);
+ pitch = -fast_arc_tan(vector_length_xy_c2(ip), ip[2]);
+ } else {
+ yaw = fast_arc_tan(delta[0], delta[1]);
+ pitch = -fast_arc_tan(vector_length_xy_c2(delta), delta[2]);
+ }
+ } else {
+ if (d->timer < scale_game_frames(0x96) - scale_game_frames(0)) {
+ yaw = d->yaw0;
+ pitch = d->pitch0;
+ } else {
+ yaw = m->rot[2];
+ pitch = m->rot[1];
+ }
+ }
+ if (t != 0) {
+ m->rot[2] = FUN_L00_00258110(&d->yawvel, m->rot[2], yaw,
+ D_0015ED70 * 6.2831855f, D_0015ED70 * 3.1415927f, D_0015ED6C * 6.2831855f);
+ m->rot[1] = FUN_L00_00258110(&d->pitchvel, m->rot[1], pitch,
+ D_0015ED70 * 6.2831855f, D_0015ED70 * 3.1415927f, D_0015ED6C * 6.2831855f);
+ } else {
+ m->rot[2] = FUN_L00_00258110(&d->yawvel, m->rot[2], yaw,
+ D_0015ED70 * 6.2831855f, D_0015ED70 * 3.1415927f, D_0015ED6C * 4.712389f);
+ m->rot[1] = FUN_L00_00258110(&d->pitchvel, m->rot[1], pitch,
+ D_0015ED70 * 6.2831855f, D_0015ED70 * 3.1415927f, D_0015ED6C * 4.712389f);
+ }
+ {
+ Part_29E8A0 *p;
+ build_spherical_offset_c(vel, d->speed, m->rot[2], -m->rot[1]);
+ *(u128_29E8A0 *)dv = 0;
+ dv[0] = random_float_between(-1.0f, 1.0f);
+ dv[1] = random_float_between(-1.0f, 1.0f);
+ dv[2] = random_float_between(-1.0f, 1.0f);
+ *(u128_29E8A0 *)delta = *(u128_29E8A0 *)dv;
+ fast_vec_normalize(delta, delta, random_float_between(0.1f, 0.2f) * D_0015ED6C);
+ fast_vec_normalize(v90, vel, -random_float_between(D_0015ED6C * 0.1f, D_0015ED6C));
+ add_vector_xyz(delta, delta, v90);
+ fast_vec_normalize(v90, vel, random_float_between(0.0f, 1.0f) * d->speed);
+ add_vector_xyz(v90, v90, m->pos);
+ p = (Part_29E8A0 *)FUN_L00_002712b8(v90, delta, scale_game_frames(0x3C), 0x7F, 0x606060, 3,
+ 40000.0f, 1000.0f, 1.0f, -0.0002f, 0.0f);
+ if (p != 0) {
+ p->f2 = *D_L15_001B26DC;
+ p->f3 = 0x44;
+ }
+ FUN_L00_002712b8(m->pos, delta, scale_game_frames(6), 0x7F, 0xB0B0B0, 3, 40000.0f, 1000.0f, 1.0f, -0.0004f, 0.0f);
+ *(u128_29E8A0 *)dv = 0;
+ dv[2] = 0.02f;
+ transform_vector_by_basis(dv, dv, m->mtx);
+ build_look_at_matrix(dv, dv, m->mtx, random_angle_radians());
+ FUN_L00_0026cbb0(v90, dv, 0x4F007FFF, 0x1FFFFFFF, scale_game_frames(5), 1, 20000.0f);
+ qcopy(v60, m->pos);
+ FUN_L00_001ff290(delta, vel, up);
+ }
+ }
+ add_vector_xyz(m->pos, m->pos, vel);
+ if (m->pos[0] < 0.0f || m->pos[1] < 0.0f || m->pos[2] < 0.0f) {
+ FUN_L00_0025f800(m, D_L15_001B0D70);
+ mark_moby_for_removal_c3(m);
+ return;
+ }
+ {
+ Coll_29E8A0 coll;
+ coll.flags = 0x830000;
+ coll.radius = 3.0f;
+ coll.moby = (char *)m;
+ coll.count = 1;
+ qcopy(coll.v, vel);
+ set_vector_length_xy(coll.v, coll.v, 1.0f);
+ hero = ((char *)&D_0013F350);
+ coll.v[3] = 5627.9248f;
+ coll.kind = 3;
+ coll.id = m->id;
+ coll.v[2] = 1.0f;
+ coll.one = 1;
+ if (FUN_001efa68(v60, m->pos, 0, *(char **)(hero + 0x2080), &coll) != 0) {
+ char *hit = D_L15_00174440;
+ char *hm = *(char **)(hit + 0x18);
+ if (hm != 0) {
+ if (hm != *(char **)(hero + 0x2080) && hm != d->owner) {
+ m->bc = 2;
+ qcopy(m->pos, hit + 0x20);
+ subtract_vector_xyz_c2(vB0, hit + 0x50, hit + 0x60);
+ owner = (char *)m;
+ fast_vec_normalize(vB0, vB0, 1.0f);
+ FUN_L00_001ff660(v70, vel, hit + 0x40);
+ fast_vec_normalize(v70, v70, D_0015ED6C + D_0015ED6C);
+ fast_vec_normalize(v80, hit + 0x40, 1.0f);
+ }
+ } else if (*(int *)(hit + 0x1C) > 0) {
+ m->bc = 1;
+ qcopy(m->pos, hit + 0x20);
+ subtract_vector_xyz_c2(vB0, hit + 0x50, hit + 0x60);
+ fast_vec_normalize(vB0, vB0, 1.0f);
+ FUN_L00_001ff660(v70, vel, hit + 0x40);
+ fast_vec_normalize(v70, v70, D_0015ED6C + D_0015ED6C);
+ fast_vec_normalize(v80, hit + 0x40, 1.0f);
+ }
+ } else if (tick_countdown_32_alt(&d->timer) != 0 || vector_distance_xy_alt(m->pos, (float *)(hero + 0x80)) > 260.0f) {
+ FUN_L00_0025f800(m, D_L15_001B0D70);
+ mark_moby_for_removal_c3(m);
+ return;
+ }
+ if (m->bc != 0) {
+ float v100[4];
+ float dist;
+ char *cam;
+ int i, j;
+ int r = FUN_L00_001f2868(m->pos, 2.0f, 0x10, m, 0);
+ *(u128_29E8A0 *)v100 = *(u128_29E8A0 *)m->pos;
+ FUN_L00_0025a9f8(m, v100, ((char * *)D_L15_00178500), r, (int)owner, 0x810000, 3, 1, 3.0f, 1.0f, 1.0f);
+ {
+ float K[16];
+ float K2[16];
+ float M3[16];
+ float M2[16];
+ float M1[16];
+ float ny;
+ K[4] = -v80[2];
+ K[1] = v80[2];
+ K[0] = 0.0f;
+ K[8] = v80[1];
+ ny = -v80[1];
+ K[9] = -v80[0];
+ K[2] = ny;
+ K[6] = v80[0];
+ K[12] = 0.0f;
+ K[5] = 0.0f;
+ K[13] = 0.0f;
+ K[10] = 0.0f;
+ K[14] = 0.0f;
+ K[3] = 0.0f;
+ K[7] = 0.0f;
+ K[11] = 0.0f;
+ K[15] = 0.0f;
+ multiply_matrix(K2, K, K);
+ for (k = 0; k < 10; k++) {
+ if (m->bc == 1) {
+ float ang = random_angle_radians();
+ FUN_L00_001ffd48(M1, K2, 1.0f - fast_cos_c3(ang));
+ FUN_L00_001ffd48(M2, K, fast_sin_c3(ang));
+ FUN_L00_001ffe20(M2, M2, M1);
+ set_identity_matrix(M1);
+ FUN_L00_001ffe20(M3, M2, M1);
+ transform_vector_c(v100, vB0, M3);
+ fast_vec_normalize(v100, v100, random_float_between(8.5f, 16.5f) * D_0015ED6C);
+ } else {
+ float sp = random_float_between(8.5f, 16.5f) * D_0015ED6C;
+ float a1 = random_angle_radians();
+ build_spherical_offset_c(v100, sp, a1, random_angle_radians());
+ }
+ v100[2] = v100[2] + D_0015ED6C * 5.0f;
+ add_vector_xyz(v100, v100, v70);
+ FUN_L00_0026bb70_c(m->pos, v100, 0x4F007FFF, 0x1F00007F, 40000.0f,
+ FUN_L00_00257b90(scale_game_frames(0x3C), scale_game_frames(0x78)), 1, -1, -1);
+ }
+ {
+ float r4[4];
+ {
+ *(u128_29E8A0 *)r4 = 0;
+ r4[0] = random_float_between(-1.0f, 1.0f);
+ r4[1] = random_float_between(-1.0f, 1.0f);
+ r4[2] = random_float_between(-1.0f, 1.0f);
+ *(u128_29E8A0 *)v100 = *(u128_29E8A0 *)r4;
+ }
+ }
+ subtract_vector_xyz_c2(v50, D_L15_001673C0, m->pos);
+ dist = fast_vec_length(v50);
+ v50[2] = v50[2] + dist * 0.5f;
+ fast_vec_normalize(v100, v100, dist / 5.0f * D_0015ED6C);
+ fast_vec_normalize(v50, v50, (dist + dist) * D_0015ED6C);
+ add_vector_xyz(v100, v100, v50);
+ clamp_vector_length(v100, v100, D_0015ED6C * 10.0f);
+ FUN_L00_002af450((char *)m->pos, (char *)v100, FUN_L00_00257b90(scale_game_frames(0x3C), scale_game_frames(0x5A)), 0, 0);
+ {
+ int n;
+ float under;
+ if (dist < 6.0f) {
+ n = truncate_float_to_s32_c4(dist) / 2;
+ } else {
+ n = 3;
+ }
+ under = 0.0f;
+ if (dist < 7.0f) under = 7.0f - dist;
+ i = 0;
+ while (i < n) {
+ float sz = random_float_between(8.0f, 10.0f) * D_0015ED6C - under * D_0015ED6C;
+ Cols_29E8A0 c1 = D_L15_001E2660;
+ Cols_29E8A0 c2 = D_L15_001E2678;
+ int *p1 = &c1.c[random_integer_below_c3(6)];
+ int *p2 = &c2.c[random_integer_below_c3(6)];
+ int l1 = FUN_L00_00257b90(scale_game_frames(0xF), scale_game_frames(0x14));
+ int l2 = FUN_L00_00257b90(scale_game_frames(0x19), scale_game_frames(0x1E));
+ int l3, l4;
+ FUN_L00_0026a9f0(m->pos, v70, *p1, *p2, 400000.0f, l1, l2, sz, 0, 0);
+ l3 = FUN_L00_00257b90(scale_game_frames(5), scale_game_frames(0xA));
+ l4 = FUN_L00_00257b90(scale_game_frames(0xF), scale_game_frames(0x14));
+ FUN_L00_0026a9f0(m->pos, v70, 0x7FFFFFFF, 0xFFFFFF, 400000.0f, l3, l4, sz * 0.5f, 0, 0);
+ i++;
+ }
+ }
+ for (j = 0; j < 10; j++) {
+ Cols_29E8A0 c1 = D_L15_001E2660;
+ Cols_29E8A0 c2 = D_L15_001E2678;
+ float dir[4];
+ {
+ float r5[4];
+ *(u128_29E8A0 *)r5 = 0;
+ r5[0] = random_float_between(-1.0f, 1.0f);
+ r5[1] = random_float_between(-1.0f, 1.0f);
+ r5[2] = random_float_between(-1.0f, 1.0f);
+ *(u128_29E8A0 *)dir = *(u128_29E8A0 *)r5;
+ }
+ fast_vec_normalize(dir, dir, random_float_between(0.0f, 3.0f) * D_0015ED6C);
+ {
+ int *p1 = &c1.c[random_integer_below_c3(6)];
+ int *p2 = &c2.c[random_integer_below_c3(6)];
+ FUN_L00_0026a4c8(m->pos, dir, *p1, *p2, FUN_L00_00257b90(scale_game_frames(0x14), scale_game_frames(0x23)), 200000.0f);
+ }
+ }
+ if (D_L15_0015F5D0 < 0.95f && 9.0f < dist) {
+ ((void (*)(void *, void *, void *, float, int, int, int, int, int))FUN_L00_002ac910)(m, m->pos, v70, 4.0f, scale_game_frames(0xF), 0x7F, 0x7F, 0x7F, 0x20);
+ ((void (*)(void *, void *, void *, float, int, int, int, int, int))FUN_L00_002ac910)(m, m->pos, v70, 4.0f, scale_game_frames(0x18), 0x7F, 0x7F, 0x7F, 0x20);
+ }
+ ((void (*)(void *, void *, void *, float, int, int, int, int, int))FUN_L00_002ac910)(m, m->pos, v70, 4.0f, scale_game_frames(0x14), 0x7F, 0x7F, 0, 0x30);
+ ((void (*)(void *, void *, void *, float, int, int, int, int, int))FUN_L00_002ac910)(m, m->pos, v70, 2.0f, scale_game_frames(0x13), 0xFF, 0xFF, 0xFF, 0x20);
+ vel[0] = 0.0f;
+ cam = (char *)&D_L15_00167280;
+ m->bc = 0;
+ if (dist < 20.0f) {
+ *(float *)(cam + 0x160) = 0.4f - dist * 0.0175f;
+ } else {
+ *(float *)(cam + 0x160) = 0.050000012f;
+ }
+ {
+ int sh = scale_game_frames(0x19);
+ char *cam2 = (char *)&D_L15_00167280;
+ *(int *)(cam2 + 0x168) = sh;
+ }
+ allocate_voice_for_target_entry(0, 0, (int)m);
+ FUN_L00_002d3838(&tbl, m->pos, 0, 0);
+ FUN_L00_0025f800(m, D_L15_001B0D70);
+ mark_moby_for_removal_c3(m);
+ }
+ }
+ }
+}
/* update: scale and fade a moby, spawn an effect, delete it when done */
/* Ported from rac1-decomp (src/overlays/shared/vendor_00298BB8.c: func_L15_0029FCB0), where it is exact; names translated to the US level program. */
@@ -1921,8 +2368,8 @@ void FUN_L15_002a2488(char *moby) {
float g;
float r0;
float r;
- float f20;
- float f21;
+ float yaw;
+ float target_z;
float fd;
int state;
int ret;
@@ -1982,14 +2429,14 @@ void FUN_L15_002a2488(char *moby) {
c = (char *)&hero;
fa = *(float *)(c + 0x80) - *(float *)(moby + 0x10);
fb = *(float *)(c + 0x84) - *(float *)(moby + 0x14);
- f20 = fast_add_rotations_c(*(float *)(data + 0x64), FUN_001f9e90(fa, fb));
- f21 = *(float *)(c + 0xC8);
- g = fast_cos_c(f20);
+ yaw = fast_add_rotations_c(*(float *)(data + 0x64), FUN_001f9e90(fa, fb));
+ target_z = *(float *)(c + 0xC8);
+ g = fast_cos_c(yaw);
va[0] = g * (*(float *)&D_L15_001614B4 * D_0015ED6C);
- r0 = fast_sin_c(f20);
+ r0 = fast_sin_c(yaw);
va[1] = r0 * (*(float *)&D_L15_001614B4 * D_0015ED6C);
va[2] = 0.0f;
- fd = *(float *)(moby + 0x18) - f21;
+ fd = *(float *)(moby + 0x18) - target_z;
if (0.6f < fd) {
va[2] = -(D_0015ED6C * 3.0f);
} else if (fd < 0.4f) {
@@ -2063,11 +2510,6 @@ typedef struct {
extern float D_L15_001CE110[4][4][4];
extern float D_L15_001CE210[8];
-typedef struct {
- char pad[0x140];
- float position[4];
-} LevelView;
-extern LevelView D_L15_00167280;
extern int D_L15_001614C8 __attribute__((sda));
extern long long get_effect_texture(int) __asm__("FUN_001f44b8");
extern void clear_vector(void *) __asm__("FUN_001f99f8");
@@ -2148,7 +2590,7 @@ extern int FUN_L15_002a3138();
unsigned char *FUN_L15_002647f0(void *pos, float *p, float *c, int d, int e, int f, int g, int h, char *owner);
extern KillFlags_2A3DD0 D_L15_001BBB40_2A3DD0 __asm__("D_L15_001BB830");
extern unsigned char D_0013E650_2A3DD0[] __asm__("D_0013E550");
-extern char D_0013E633_2A3DD0[] __asm__("D_0013F420");
+extern char D_0013F420[];
extern float func_002140F8_2A3DD0(float, float) __asm__("FUN_002132a8");
extern int func_002140B0_2A3DD0(int) __asm__("FUN_00213260");
extern int func_001F9850_2A3DD0(int) __asm__("FUN_001f96f8");
@@ -2201,7 +2643,7 @@ void FUN_L15_002a2bf0(unsigned char *moby) {
if (e->owner != (char *)moby || e->active == 0) {
moby[0xBC] = func_0022ED80_2A3DD0(0, 4, moby);
}
- func_001F9BF0_2A3DD0(V, D_0013E633_2A3DD0, moby + 0x10);
+ func_001F9BF0_2A3DD0(V, D_0013F420, moby + 0x10);
func_001FA4A0_2A3DD0(W, moby + 0xC0);
func_001F9EE8_2A3DD0(V, V, W);
V[0] = 0.0f;
@@ -2436,195 +2878,189 @@ void FUN_L15_002a35d8(int addr) {
m->command = 0xFF;
m->state = 2;
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L15_002a6e68.s", FUN_L15_002a6e68);
-#else
-#endif
-#ifdef NON_MATCHING
-extern void build_look_at_matrix(void *, void *, void *, float) __asm__("FUN_00214890");
-extern void normalize_vector_triplet(void *) __asm__("FUN_00214128");
-extern void copy_matrix(void *, void *) __asm__("FUN_001fa2b8");
-extern void build_spherical_offset(void *, float, float, float) __asm__("FUN_00214db0");
-extern void transform_vector(void *, void *, void *) __asm__("FUN_001f9cf8");
-extern float wrap_rotation(float) __asm__("FUN_001fa610");
-extern unsigned int rand(void) __asm__("FUN_001160d8");
-extern float multiply_global_factor_ed68(float) __asm__("FUN_L15_001f8648");
-extern void enqueue_callback_list_1_2a6e68(void (*)(void), void *) __asm__("FUN_L15_001f2ac8");
-extern unsigned char D_L15_00174460[];
-extern int D_L15_00161558 __attribute__((sda));
-extern float D_L15_0016155C __attribute__((sda));
-extern float D_L15_00161560 __attribute__((sda));
-extern void FUN_L00_001ff290(void *, void *, void *);
-void FUN_L15_002a7628(char *moby);
+/* Spiderbot update: steps the walk/turn state, then probes ahead and sprays sparks along the path. */
+/* Ported from rac1-decomp (src/overlays/shared/vendor_00298BB8.c: func_L15_002A8090), where it is exact; names translated to the US level program. */
+
+typedef int u128_2A8090 __attribute__((mode(TI)));
typedef struct {
- void *moby;
+ float v[2];
+ float f8;
+ float fC;
+ unsigned char *moby;
int flags;
- unsigned char enabled, mode;
- unsigned short id;
- float scale;
- int active;
-} MotionQuery;
+ unsigned char b18;
+ unsigned char b19;
+ short h1A;
+ float f1C;
+ int i20;
+ int pad24[3];
+} Ray_2A8090;
+
+extern f32 convert_integer_to_float_c3(s32) __asm__("func_001FA6C0");
+extern f32 fast_cos_c4(f32) __asm__("func_001F9DC8");
+extern f32 fast_normalize_angle(f32) __asm__("func_001FA610");
+extern f32 fast_sin_c4(f32) __asm__("func_001F9DE0");
+extern float D_0015ED6C;
+extern float FUN_001f96b0(float);
+extern float fast_add_rotations_c2(float, float) __asm__("func_001FA580");
+extern s32 rand(void);
+extern s32 random_integer_below_c4(s32) __asm__("func_00213260");
+extern s32 truncate_float_to_s32_c5(f32) __asm__("func_001FA6D0");
+extern int D_L15_00161558 __attribute__((sda));
+extern float D_L15_0016155C __attribute__((sda));
+extern float D_L15_00161560 __attribute__((sda));
+extern u8 D_L15_00174460[];
+extern void FUN_L15_002a7628_c() __asm__("FUN_L15_002a7628");
+extern void build_look_at_matrix(void *out, void *dir, void *axis, f32 ang) __asm__("FUN_00214890");
+extern void build_spherical_offset(void *, f32, f32, f32) __asm__("func_00214DB0");
+extern void copy_matrix3x4(void *, void *) __asm__("func_001FA2B8");
+extern void euler_rotation_matrix(float *, float *) __asm__("FUN_001fa050");
+extern void subtract_vector_xyz_c3(void *, void *, void *) __asm__("FUN_001f9a28");
+void normalize_vector_triplet(f32 *vectors) __asm__("FUN_00214128");
+extern unsigned char *func_L00_00273F80_r(float *pos, char *vel, int color, unsigned char life, unsigned char b, int mode, float scale) __asm__("FUN_L00_002730e0");
void FUN_L15_002a6e68(unsigned char *moby) {
- Vec4 position;
- Vec4 endpoint;
- Vec4 offset;
- Vec4 axis;
- /* The four-row matrix shares storage with the later query and scratch. */
- struct {
- Vec4 angles;
- union {
- Vec4 rotation[4];
- struct {
- MotionQuery query;
- unsigned char pad[12];
- Vec4 temporary[2];
- } motion;
- } work;
- } collision;
- Vec4 next;
- void * volatile position_ptr;
- unsigned char *data;
- float old_offset, angle, sign, length, speed;
- unsigned int life;
- unsigned char alpha, life_byte;
- int i;
- Vec4 *endpoint_ptr;
-
- position.q = *(u128 *)(moby + 0x10);
- data = *(unsigned char **)(moby + 0x78);
+ float old[4];
+ float A[4];
+ float B[4];
+ float C[4];
+ unsigned char *d = *(unsigned char **)(moby + 0x78);
+ *(u128_2A8090 *)old = *(u128_2A8090 *)(moby + 0x10);
+ {
+ float D[4];
+ float M[16];
+ float T[4];
switch (moby[0x20]) {
case 0:
- *(u128 *)data = position.q;
- *(float *)(moby + 0x58) = *(float *)(data + 0x30) / 1.5f;
- *(float *)(data + 0x28) *= DEG_TO_RAD;
- if (*(int *)(data + 0x20) == 0) {
+ *(u128_2A8090 *)d = *(u128_2A8090 *)old;
+ *(float *)(moby + 0x58) = *(float *)(d + 0x30) / 1.5f;
+ *(float *)(d + 0x28) = *(float *)(d + 0x28) * 0.017453292f;
+ if (*(int *)(d + 0x20) == 0) {
moby[0x20] = 1;
- *(float *)(data + 0x2c) = *(float *)(moby + 0x48);
- } else if (*(int *)(data + 0x20) >= 3) {
+ *(float *)(d + 0x2C) = *(float *)(moby + 0x48);
+ } else if (*(int *)(d + 0x20) >= 3) {
moby[0x20] = 2;
- *(float *)(data + 0x2c) = *(float *)(moby + 0x48);
+ *(float *)(d + 0x2C) = *(float *)(moby + 0x48);
} else {
moby[0x20] = 3;
}
break;
- case 1:
- axis.q = 0;
- axis.f[2] = *(float *)(data + 0x24);
- collision.angles.q = 0;
- offset.q = axis.q;
- *(float *)(data + 0x28) = fast_add_rotations(*(float *)(data + 0x28),
- (360.0f / ((*(float *)(data + 0x24) * 6.2831855f) / *(float *)(data + 0x30))) * DEG_TO_RAD * D_0015ED6C);
- *(float *)(moby + 0x58) = *(float *)(data + 0x30) / 1.5f;
- axis.f[0] = fast_cos(*(float *)(data + 0x2c));
- axis.f[1] = fast_sin(*(float *)(data + 0x2c));
- axis.f[2] = 0.0f;
- build_look_at_matrix(&endpoint, &offset, &axis, *(float *)(data + 0x28));
- add_vector_xyz(&next, data, &endpoint);
- *(u128 *)(moby + 0x10) = next.q;
- collision.angles.f[2] = fast_add_rotations(*(float *)(data + 0x2c), 1.5707964f);
- collision.angles.f[1] = fast_add_rotations(-*(float *)(data + 0x28), 3.1415927f);
- rotation_matrix_from_euler(&collision.work, &collision.angles);
- copy_matrix(moby + 0xc0, &collision.work);
- normalize_vector_triplet(moby + 0xc0);
+ case 1: {
+ *(u128_2A8090 *)C = 0;
+ C[2] = *(float *)(d + 0x24);
+ *(u128_2A8090 *)D = 0;
+ *(u128_2A8090 *)B = *(u128_2A8090 *)C;
+ *(float *)(d + 0x28) = fast_add_rotations_c2(*(float *)(d + 0x28),
+ 360.0f / (*(float *)(d + 0x24) * 6.2831855f / *(float *)(d + 0x30)) * 0.017453292f * D_0015ED6C);
+ *(float *)(moby + 0x58) = *(float *)(d + 0x30) / 1.5f;
+ C[0] = fast_cos_c4(*(float *)(d + 0x2C));
+ C[1] = fast_sin_c4(*(float *)(d + 0x2C));
+ C[2] = 0.0f;
+ build_look_at_matrix(A, B, C, *(float *)(d + 0x28));
+ add_vector_xyz(T, d, A);
+ *(u128_2A8090 *)(moby + 0x10) = *(u128_2A8090 *)T;
+ D[2] = fast_add_rotations_c2(*(float *)(d + 0x2C), 1.5707964f);
+ D[1] = fast_add_rotations_c2(-*(float *)(d + 0x28), 3.1415927f);
+ euler_rotation_matrix(M, D);
+ copy_matrix3x4(moby + 0xC0, M);
+ normalize_vector_triplet(moby + 0xC0);
*(unsigned short *)(moby + 0x34) |= 0x100;
break;
+ }
case 2: {
- float angle, old_offset;
- float half_pi = 1.5707964f;
- axis.q = 0;
- axis.f[2] = -*(float *)(data + 0x24);
- collision.angles.q = 0;
- offset.q = axis.q;
- angle = fast_add_rotations(wrap_rotation(fast_cos(*(float *)(data + 0x28)) * half_pi),
- *(int *)(data + 0x20) == 4 ? half_pi : 0.0f);
- *(float *)(data + 0x28) = fast_add_rotations(*(float *)(data + 0x28),
- (360.0f / ((*(float *)(data + 0x24) * 6.2831855f) / *(float *)(data + 0x30))) * DEG_TO_RAD * D_0015ED6C);
- old_offset = fast_add_rotations(wrap_rotation(fast_cos(*(float *)(data + 0x28)) * half_pi),
- *(int *)(data + 0x20) == 4 ? half_pi : 0.0f);
- speed = fast_subtract_rotations(old_offset, angle);
- *(float *)(moby + 0x58) = (*(float *)(data + 0x24) * speed) / (D_0015ED6C * 1.5f);
- axis.f[0] = fast_cos(*(float *)(data + 0x2c));
- axis.f[1] = fast_sin(*(float *)(data + 0x2c));
- axis.f[2] = 0.0f;
- build_look_at_matrix(&endpoint, &offset, &axis, old_offset);
- add_vector_xyz(&next, data, &endpoint);
- *(u128 *)(moby + 0x10) = next.q;
- collision.angles.f[2] = fast_add_rotations(*(float *)(data + 0x2c), half_pi);
- collision.angles.f[1] = fast_add_rotations(-old_offset, 0.0f);
- rotation_matrix_from_euler(&collision.work, &collision.angles);
- copy_matrix(moby + 0xc0, &collision.work);
- normalize_vector_triplet(moby + 0xc0);
+ float b1;
+ float b2;
+ *(u128_2A8090 *)C = 0;
+ C[2] = -*(float *)(d + 0x24);
+ *(u128_2A8090 *)D = 0;
+ *(u128_2A8090 *)B = *(u128_2A8090 *)C;
+ b1 = fast_add_rotations_c2(fast_normalize_angle(fast_cos_c4(*(float *)(d + 0x28)) * 1.5707964f),
+ *(int *)(d + 0x20) == 4 ? 1.5707964f : 0.0f);
+ *(float *)(d + 0x28) = fast_add_rotations_c2(*(float *)(d + 0x28),
+ 360.0f / (*(float *)(d + 0x24) * 6.2831855f / *(float *)(d + 0x30)) * 0.017453292f * D_0015ED6C);
+ b2 = fast_add_rotations_c2(fast_normalize_angle(fast_cos_c4(*(float *)(d + 0x28)) * 1.5707964f),
+ *(int *)(d + 0x20) == 4 ? 1.5707964f : 0.0f);
+ *(float *)(moby + 0x58) = *(float *)(d + 0x24) * fast_subtract_rotations(b2, b1) / (D_0015ED6C * 1.5f);
+ C[0] = fast_cos_c4(*(float *)(d + 0x2C));
+ C[1] = fast_sin_c4(*(float *)(d + 0x2C));
+ C[2] = 0.0f;
+ build_look_at_matrix(A, B, C, b2);
+ add_vector_xyz(T, d, A);
+ *(u128_2A8090 *)(moby + 0x10) = *(u128_2A8090 *)T;
+ D[2] = fast_add_rotations_c2(*(float *)(d + 0x2C), 1.5707964f);
+ D[1] = fast_add_rotations_c2(-b2, 0.0f);
+ euler_rotation_matrix(M, D);
+ copy_matrix3x4(moby + 0xC0, M);
+ normalize_vector_triplet(moby + 0xC0);
*(unsigned short *)(moby + 0x34) |= 0x100;
break;
}
- case 3:
- old_offset = fast_cos(*(float *)(data + 0x28)) * *(float *)(data + 0x24);
- *(float *)(data + 0x28) = fast_add_rotations(*(float *)(data + 0x28),
- (360.0f / ((*(float *)(data + 0x24) * 6.2831855f) / *(float *)(data + 0x30))) * DEG_TO_RAD * D_0015ED6C);
- angle = fast_cos(*(float *)(data + 0x28)) * *(float *)(data + 0x24);
- *(float *)(moby + 0x58) = (angle - old_offset) / (D_0015ED6C * 1.5f);
- build_spherical_offset(&endpoint, angle, *(int *)(data + 0x20) == 2 ? 0.0f : *(float *)(moby + 0x48),
- *(int *)(data + 0x20) == 2 ? 1.5707964f : 0.0f);
- add_vector_xyz(&offset, data, &endpoint);
- *(u128 *)(moby + 0x10) = offset.q;
+ case 3: {
+ float w;
+ float x;
+ w = fast_cos_c4(*(float *)(d + 0x28)) * *(float *)(d + 0x24);
+ *(float *)(d + 0x28) = fast_add_rotations_c2(*(float *)(d + 0x28),
+ 360.0f / (*(float *)(d + 0x24) * 6.2831855f / *(float *)(d + 0x30)) * 0.017453292f * D_0015ED6C);
+ x = fast_cos_c4(*(float *)(d + 0x28)) * *(float *)(d + 0x24);
+ *(float *)(moby + 0x58) = (x - w) / (D_0015ED6C * 1.5f);
+ build_spherical_offset(A, x, *(int *)(d + 0x20) != 2 ? *(float *)(moby + 0x48) : 0.0f,
+ *(int *)(d + 0x20) == 2 ? 1.5707964f : 0.0f);
+ add_vector_xyz(B, d, A);
+ *(u128_2A8090 *)(moby + 0x10) = *(u128_2A8090 *)B;
break;
}
- offset.q = 0;
- offset.f[2] = 12.0f;
- transform_vector(&offset, &offset, moby + 0xc0);
- position_ptr = moby + 0x10;
- add_vector_xyz(&collision.angles, moby + 0x10, &offset);
- collision.work.motion.query.flags = 0x10001;
- endpoint.q = collision.angles.q;
- collision.work.motion.query.moby = moby;
- collision.work.motion.query.scale = 1.0f;
- collision.work.motion.query.active = 1;
- normalize_vector_xyz(&collision.angles, &offset, 1.0f);
- collision.work.motion.query.id = *(unsigned short *)(moby + 0xa6);
- collision.angles.f[2] = 1.0f;
- collision.angles.f[3] = 5627.925f;
- collision.work.motion.query.enabled = 1;
- collision.work.motion.query.mode = 1;
- subtract_vector_xyz(collision.work.motion.temporary, moby + 0x10, &position);
- axis.q = collision.work.motion.temporary[0].q;
- FUN_001efa68(moby + 0x10, &endpoint, 9, moby, &collision.angles);
- if (FUN_001efa68(moby + 0x10, &endpoint, 2, 0, 0) != 0)
- *(u128 *)(data + 0x10) = *(u128 *)D_L15_00174460;
- else
- *(u128 *)(data + 0x10) = endpoint.q;
- endpoint_ptr = &endpoint;
- i = 0;
- if (D_L15_00161558 > 0) {
- do {
- sign = -1.0f;
- if (rand() & 1) sign = 1.0f;
- life = truncate_float_to_s32_u(multiply_global_factor_ed68(random_float_between(D_L15_00161560 * 0.5f, D_L15_00161560)));
- subtract_vector_xyz(collision.work.motion.temporary, data + 0x10, position_ptr);
- offset.q = collision.work.motion.temporary[0].q;
- scale_vector_xyz(&offset, &offset, sign);
- length = vector_length_xyz(&offset);
- if (sign < 0.0f) endpoint.q = *(u128 *)(data + 0x10);
- else endpoint.q = *(u128 *)(moby + 0x10);
- life_byte = life & 0xff;
- i++;
- scale_vector_xyz(&offset, &offset, random_float_between(0.0f, 0.9f));
- /* The checked helper adds offset into its second argument, endpoint_ptr. */
- FUN_L00_001ff290(collision.work.motion.temporary, endpoint_ptr, &offset);
- speed = D_0015ED6C * 10.0f;
- speed = random_float_between(speed, length / convert_integer_to_float(life << 2));
- normalize_vector_xyz(&offset, &offset, speed);
- alpha = random_integer_below(255);
- /* Retail returns the allocated effect pointer; this call ignores it. */
- ((unsigned char *(*)(float *, char *, int, unsigned char, unsigned char, int, float))
- FUN_L00_002730e0)((float *)endpoint_ptr, (char *)&offset, 0x604040ff,
- life_byte, alpha, 0, D_L15_0016155C);
- } while (i < D_L15_00161558);
- }
- enqueue_callback_list_1_2a6e68((void (*)(void))FUN_L15_002a7628, moby);
+ }
+ }
+ {
+ Ray_2A8090 R;
+ float T2[4];
+ int i;
+ *(u128_2A8090 *)B = 0;
+ B[2] = 12.0f;
+ func_001F9EC0_2A3DD0(B, B, moby + 0xC0);
+ add_vector_xyz(R.v, moby + 0x10, B);
+ *(u128_2A8090 *)A = *(u128_2A8090 *)R.v;
+ R.flags = 0x10001;
+ R.moby = moby;
+ R.f1C = 1.0f;
+ R.i20 = 1;
+ fast_vec_normalize(R.v, B, 1.0f);
+ R.h1A = *(unsigned short *)(moby + 0xA6);
+ R.f8 = 1.0f;
+ R.fC = 5627.9248f;
+ R.b18 = 1;
+ R.b19 = 1;
+ subtract_vector_xyz_c3(T2, moby + 0x10, old);
+ *(u128_2A8090 *)C = *(u128_2A8090 *)T2;
+ FUN_001efa68(moby + 0x10, A, 9, moby, &R);
+ if (FUN_001efa68(moby + 0x10, A, 2, 0, 0)) {
+ *(u128_2A8090 *)(d + 0x10) = *(u128_2A8090 *)D_L15_00174460;
+ } else {
+ *(u128_2A8090 *)(d + 0x10) = *(u128_2A8090 *)A;
+ }
+ for (i = 0; i < D_L15_00161558; i++) {
+ float s;
+ float len;
+ int k;
+ unsigned char life;
+ s = -1.0f;
+ if (rand() & 1) s = 1.0f;
+ k = truncate_float_to_s32_c5(FUN_001f96b0(random_float_between(D_L15_00161560 * 0.5f, D_L15_00161560)));
+ subtract_vector_xyz_c3(T2, d + 0x10, moby + 0x10);
+ *(u128_2A8090 *)B = *(u128_2A8090 *)T2;
+ fast_vec_scale(B, B, s);
+ len = fast_vec_length(B);
+ *(u128_2A8090 *)A = s < 0.0f ? *(u128_2A8090 *)(d + 0x10) : *(u128_2A8090 *)(moby + 0x10);
+ life = k;
+ fast_vec_scale(B, B, random_float_between(0.0f, 0.9f));
+ FUN_L00_001ff290(T2, A, B);
+ fast_vec_normalize(B, B, random_float_between(D_0015ED6C * 10.0f, len / convert_integer_to_float_c3(k * 4)));
+ func_L00_00273F80_r(A, (char *)B, 0x604040FF, life, random_integer_below_c4(0xFF), 0, D_L15_0016155C);
+ }
+ }
+ enqueue_callback_list_1_alt(FUN_L15_002a7628_c, moby);
}
-#endif
/* Builds a screen-space quad from the moby's offset and draws it. */
/* Ported from rac1-decomp (src/overlays/shared/vendor_00298BB8.c: func_L15_002A8850), where it is exact; names translated to the US level program. */
@@ -3021,7 +3457,7 @@ void FUN_L15_002cbba0(unsigned char *moby) {
extern int allocate_voice_for_target_entry(int, int, int) __asm__("FUN_0022da68");
extern int FUN_L00_0028d8c0(void *, int);
extern int FUN_L15_002cbac0_u() __asm__("FUN_L15_002cbac0");
-extern short D_0015ED84_d __asm__("D_0015ED84");
+extern int D_0015ED84;
extern s32 D_L15_00161AB8 ;
extern short D_L15_00161ABC_gp __asm__("D_L15_00161ABC") __attribute__((sda));
extern s32 D_L15_00161AC0_gp __asm__("D_L15_00161AC0") __attribute__((sda));
@@ -3036,7 +3472,7 @@ void FUN_L15_002cbc30(void *arg) {
approach_value(&D_L15_00161ABC_gp, 0.0f, frame_time * 2);
FUN_L15_002cbac0_u(arg, 0);
} else if (*(int *)&D_L15_00161AB8 != 0 &&
- (*(int *)&D_0015ED84_d != 0xF || 240.0f < base->motion.pos.f[1])) {
+ (D_0015ED84 != 0xF || 240.0f < base->motion.pos.f[1])) {
approach_value(&D_L15_00161ABC_gp, 1.0f, frame_time * 2);
} else {
approach_value(&D_L15_00161ABC_gp, 0.0f, frame_time * 2);
diff --git a/src/overlays/shared/gameplay/entities/thruster_pack_lock.c b/src/overlays/shared/gameplay/entities/thruster_pack_lock.c
index 8cb13e6912..81d29713a1 100644
--- a/src/overlays/shared/gameplay/entities/thruster_pack_lock.c
+++ b/src/overlays/shared/gameplay/entities/thruster_pack_lock.c
@@ -170,128 +170,126 @@ void FUN_L11_0030ee00(Lock_3102C8 *moby)
break;
}
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L11_00310cf8.s", FUN_L11_00310cf8);
-#else
-#define FUN_L11_00310cf8 FUN_L11_00310cf8_c
-void FUN_L11_00310cf8_c(float, float, float, float, float, int, int, long long, int,
- unsigned char, unsigned char, unsigned char, unsigned char)
- __asm__("FUN_L11_00310cf8");
-typedef unsigned int u128_quad __attribute__((mode(TI)));
-extern int D_L11_001611C0_g __asm__("D_L11_001611C0");
-extern int screen_extent[] __asm__("D_0013E500");
-extern int ftoi_g(float) __asm__("FUN_001fa6d0");
+#include "qcopy.h"
+
+/* Builds one GIF packet for a rotated textured sprite and advances the packet pointer. */
+/* Ported from rac1-decomp (src/overlays/shared/vendor_002C99E0.c: func_L11_003121C0), where it is exact; names translated to the US level program. */
+
+extern int D_L11_001611C0 __attribute__((section(".sdata")));
+extern unsigned char screen_extent_c[] __asm__("D_0013E500");
extern void add_vector_xyz(void *, void *, void *) __asm__("FUN_001f9a10");
extern void subtract_vector_xyz(void *, void *, void *) __asm__("FUN_001f9a28");
-extern float fast_cos(float) __asm__("FUN_001f9dc8");
+extern int ftoi(float) __asm__("FUN_001fa6d0");
extern float fast_sin(float) __asm__("FUN_001f9de0");
+extern float fast_cos(float) __asm__("FUN_001f9dc8");
void FUN_L11_00310cf8(float x, float y, float width, float height, float angle, int texture_width,
- int texture_height, long long texture, int z_and_fog, unsigned char red,
- unsigned char green, unsigned char blue, unsigned char alpha) {
+ int texture_height, long texture, int z_and_fog, int red, int green, int blue,
+ int alpha) {
float vertical[4];
float horizontal[4];
float center[4];
float top_left[4];
float bottom_left[4];
float top_right[4];
- struct { float bottom_right[4]; volatile int saved_depth[2]; } saved __attribute__((aligned(16)));
- int *tag;
- unsigned long long *q;
- unsigned long long packed_depth;
+ float bottom_right[4];
+ unsigned long rgba;
+ unsigned long green_bits;
+ unsigned long blue_bits;
+ unsigned long alpha_bits;
+ unsigned long tex0;
+ int depth;
+ unsigned long packed_depth;
+ unsigned long gif_tag;
+ unsigned long gif_regs;
+ unsigned long prim;
+ unsigned long tex_size;
+ int gif_dma_tag;
+ int u_end;
+ int v_end;
+ char *tag;
+ unsigned long *packet;
+ int *extent;
float scale;
- union { volatile int bits; volatile float scale; } saved_scale;
- saved.saved_depth[0] = z_and_fog;
+ rgba = red & 0xFF;
+ green_bits = green & 0xFF;
+ blue_bits = blue & 0xFF;
+ alpha_bits = alpha & 0xFF;
+ tex0 = texture;
+ depth = z_and_fog;
+
center[0] = x;
center[1] = y;
vertical[0] = height * fast_sin(angle);
vertical[1] = height * fast_cos(angle);
horizontal[0] = width * fast_cos(angle);
- width = -width;
- horizontal[1] = width * fast_sin(angle);
+ horizontal[1] = -width * fast_sin(angle);
add_vector_xyz(top_left, center, vertical);
subtract_vector_xyz(top_left, top_left, horizontal);
add_vector_xyz(bottom_left, center, vertical);
subtract_vector_xyz(top_right, center, horizontal);
- *(u128_quad *)saved.bottom_right = *(u128_quad *)center;
-
- tag = (int *)D_L11_001611C0_g;
- ((int *)(*(volatile int *)&D_L11_001611C0_g))[0] = 0x10000007;
- ((int *)(*(volatile int *)&D_L11_001611C0_g))[1] = 0;
- ((int *)(*(volatile int *)&D_L11_001611C0_g))[2] = 0;
- packed_depth = (unsigned long long)saved.saved_depth[0] << 32;
- saved_scale.bits = 0x41800000;
- scale = saved_scale.scale;
- ((int *)(*(volatile int *)&D_L11_001611C0_g))[3] = 0x50000007;
- tag = (int *)(*(volatile int *)&D_L11_001611C0_g);
- q = (unsigned long long *)(tag + 4);
- D_L11_001611C0_g = (int)q;
- q[0] = 0xB400000000008001ULL;
- q[1] = 0x53535353106ULL;
- q[2] = (unsigned long long)texture;
- q[3] = 0x154;
- q[4] = (unsigned long long)(red & 0xff) | ((unsigned long long)(green & 0xff) << 8) |
- ((unsigned long long)(blue & 0xff) << 16) | ((unsigned long long)(alpha & 0xff) << 24);
- q[5] = 0x100010;
- texture_width <<= 4;
- texture_height <<= 20;
+ qcopy(bottom_right, center);
+
+ *(int *)(D_L11_001611C0 + 0) = 0x10000007;
+ green_bits = green_bits << 8;
+ rgba = rgba | green_bits;
+ gif_dma_tag = 0x50000007;
+ gif_regs = 0x53535353106;
+ *(int *)(D_L11_001611C0 + 4) = 0;
+ blue_bits = blue_bits << 16;
+ rgba = rgba | blue_bits;
+ alpha_bits = alpha_bits << 24;
+ prim = 0x154;
+ tex_size = 0x100010;
+ gif_tag = 0xB400000000008001;
+ rgba = rgba | alpha_bits;
+ *(int *)(D_L11_001611C0 + 8) = 0;
+ scale = 16.0f;
+ u_end = texture_width << 4;
+ v_end = texture_height << 20;
+ packed_depth = (unsigned long)depth << 32;
+ *(int *)(D_L11_001611C0 + 12) = gif_dma_tag;
+ tag = (char *)D_L11_001611C0;
+ packet = (unsigned long *)(tag + 0x10);
+ D_L11_001611C0 = (int)packet;
+ *(unsigned long *)(tag + 0x10) = gif_tag;
+ packet[1] = gif_regs;
+ packet[2] = tex0;
+ packet[3] = prim;
+ packet[4] = rgba;
+ packet[5] = tex_size;
+
{
- int sx, sy;
- unsigned long long packed_position;
- sx = ftoi_g(top_left[0] * scale);
- sy = ftoi_g(top_left[1] * scale);
- sy = sy + screen_extent[5] - 8;
- sx = sx + screen_extent[4] - 8;
- q[7] = texture_width;
- packed_position = (unsigned long long)sx;
- packed_position |= (unsigned long long)sy << 16;
- packed_position |= packed_depth;
- q[6] = packed_position;
+ int a = ftoi(top_left[0] * scale);
+ int b = ftoi(top_left[1] * scale);
+ extent = (int *)(screen_extent_c);
+ packet[6] = (unsigned long)(a + extent[4] - 8) | ((unsigned long)(b + extent[5] - 8) << 16) | packed_depth;
+ packet[7] = u_end;
}
{
- int sx, sy;
- unsigned long long packed_position;
- sx = ftoi_g(bottom_left[0] * scale);
- sy = ftoi_g(bottom_left[1] * scale);
- sy = sy + screen_extent[5] - 8;
- sx = sx + screen_extent[4] - 8;
- q[9] = texture_height;
- packed_position = (unsigned long long)sx;
- packed_position |= (unsigned long long)sy << 16;
- packed_position |= packed_depth;
- q[8] = packed_position;
+ int a = ftoi(bottom_left[0] * scale);
+ int b = ftoi(bottom_left[1] * scale);
+ packet[8] = (unsigned long)(a + extent[4] - 8) | ((unsigned long)(b + extent[5] - 8) << 16) | packed_depth;
+ packet[9] = v_end;
}
{
- int sx, sy;
- unsigned long long packed_position;
- sx = ftoi_g(top_right[0] * scale);
- sy = ftoi_g(top_right[1] * scale);
- sy = sy + screen_extent[5] - 8;
- sx = sx + screen_extent[4] - 8;
- q[11] = (texture_height) + (texture_width);
- packed_position = (unsigned long long)sx;
- packed_position |= (unsigned long long)sy << 16;
- packed_position |= packed_depth;
- q[10] = packed_position;
+ int a = ftoi(top_right[0] * scale);
+ int b = ftoi(top_right[1] * scale);
+ v_end = v_end + u_end;
+ packet[10] = (unsigned long)(a + extent[4] - 8) | ((unsigned long)(b + extent[5] - 8) << 16) | packed_depth;
+ packet[11] = v_end;
}
{
- int sx, sy;
- unsigned long long packed_position;
- sx = ftoi_g(saved.bottom_right[0] * scale);
- sy = ftoi_g(saved.bottom_right[1] * scale);
- sy = sy + screen_extent[5] - 8;
- sx = sx + screen_extent[4] - 8;
- q[13] = 0;
- packed_position = (unsigned long long)sx;
- packed_position |= (unsigned long long)sy << 16;
- packed_position |= packed_depth;
- q[12] = packed_position;
+ int a = ftoi(bottom_right[0] * scale);
+ int b = ftoi(bottom_right[1] * scale);
+ packet[12] = (unsigned long)(a + extent[4] - 8) | ((unsigned long)(b + extent[5] - 8) << 16) | packed_depth;
+ packet[13] = 0;
}
- D_L11_001611C0_g = (*(volatile int *)&D_L11_001611C0_g) + 0x70;
+
+ /* Fakematch: the store through the address keeps the reload after the last packet store. */
+ *(char **)&D_L11_001611C0 += 0x70;
}
-#undef FUN_L11_00310cf8
-#endif
#define NOT_SDA
#define MACRO_ADDR
@@ -301,8 +299,6 @@ void FUN_L11_00310cf8(float x, float y, float width, float height, float angle,
extern float fast_add_rotations(float, float) __asm__("FUN_001fa580");
extern s32 get_effect_texture() __asm__("FUN_001f44b8");
-extern void FUN_L11_00310cf8(float, float, float, float, float, int, int, int, int, int, int, int,
- int);
void FUN_L11_00311048(unsigned char a, unsigned char b, unsigned char c, unsigned char d, float x,
float y, float s, float ang) {
@@ -657,7 +653,7 @@ void FUN_L11_0031a1c0(char *m) {
/* Queues a GIF packet that draws a line strip through the given points, scaled and offset to the screen. */
typedef unsigned int u128_ad0 __attribute__((mode(TI)));
-extern int D_L11_001611C0_g __asm__("D_L11_001611C0");
+extern int D_L11_001611C0_lui __asm__("D_L11_001611C0");
extern int screen_extent[] __asm__("D_0013E500");
extern float itof_g(int) __asm__("FUN_001fa6c0");
extern int ftoi_g(float) __asm__("FUN_001fa6d0");
@@ -669,36 +665,36 @@ void FUN_L11_00310ad0(short *pts, int n, float x0, float y0, unsigned int col, u
unsigned long long *o;
int x, y;
int i;
- *(int *)(D_L11_001611C0_g + 0) = q | 0x10000000;
- *(int *)(D_L11_001611C0_g + 4) = 0;
- *(int *)(D_L11_001611C0_g + 8) = 0;
- *(int *)(D_L11_001611C0_g + 12) = q | 0x50000000;
+ *(int *)(D_L11_001611C0 + 0) = q | 0x10000000;
+ *(int *)(D_L11_001611C0 + 4) = 0;
+ *(int *)(D_L11_001611C0 + 8) = 0;
+ *(int *)(D_L11_001611C0 + 12) = q | 0x50000000;
{
- char *t1 = (char *)D_L11_001611C0_g;
- D_L11_001611C0_g = (int)(t1 + 0x10);
- qcopy((void *)D_L11_001611C0_g, &D_L11_001608E0);
+ char *t1 = (char *)D_L11_001611C0;
+ D_L11_001611C0 = (int)(t1 + 0x10);
+ qcopy((void *)D_L11_001611C0, &D_L11_001608E0);
*(short *)(t1 + 0x10) = -0x7FFF;
}
{
- unsigned long long *t2 = (unsigned long long *)((char *)D_L11_001611C0_g + 0x10);
- D_L11_001611C0_g = (int)t2;
+ unsigned long long *t2 = (unsigned long long *)((char *)D_L11_001611C0 + 0x10);
+ D_L11_001611C0 = (int)t2;
t2[0] = 0x144;
t2[1] = prim;
}
{
- char *t3 = (char *)D_L11_001611C0_g;
- D_L11_001611C0_g = (int)(t3 + 0x10);
- qcopy((void *)D_L11_001611C0_g, &D_L11_001608F0);
+ char *t3 = (char *)D_L11_001611C0;
+ D_L11_001611C0 = (int)(t3 + 0x10);
+ qcopy((void *)D_L11_001611C0, &D_L11_001608F0);
*(short *)(t3 + 0x10) = n - 0x8000;
}
- D_L11_001611C0_g += 0x10;
- o = (unsigned long long *)D_L11_001611C0_g;
+ D_L11_001611C0 += 0x10;
+ o = (unsigned long long *)D_L11_001611C0;
for (i = 0; i < n; i++) {
x = ftoi_g((itof_g(pts[i * 2]) * scale + x0) * 16.0f);
y = ftoi_g((itof_g(pts[i * 2 + 1]) * scale + y0) * 16.0f);
o[i] = (unsigned long long)(x + screen_extent[4] - 8) | ((unsigned long long)(y + screen_extent[5] - 8) << 16) | ((unsigned long long)col << 32);
}
- D_L11_001611C0_g += ((n + 1) / 2) * 16;
+ D_L11_001611C0 += ((n + 1) / 2) * 16;
}
extern void clear_u64_value(void *) __asm__("FUN_001f99f8");
extern void add_vector_xyz(void *, void *, void *) __asm__("FUN_001f9a10");
diff --git a/src/overlays/shared/gameplay/entities/veldin_ship.c b/src/overlays/shared/gameplay/entities/veldin_ship.c
index f29a5dec1e..b69153ba04 100644
--- a/src/overlays/shared/gameplay/entities/veldin_ship.c
+++ b/src/overlays/shared/gameplay/entities/veldin_ship.c
@@ -58,7 +58,7 @@ typedef struct { s32 count; s32 pad_4[3]; struct { s32 pad_0[3]; s32 state; } en
typedef struct { u8 p0[0x18]; M_2cfcb8 *moby; u8 p1c[0x28 - 0x1C]; f32 point_z; } H_2cfcb8;
extern s32 D_0014EE90_lui[] __asm__("D_0014EE90") __attribute__((section(".data")));
-extern H_2cfcb8 coll_hit_2cfcb8 __asm__("D_L00_00173E40") __attribute__((section(".data")));
+extern int D_L00_00173E40 __attribute__((section(".data")));
extern R_2cfcb8 *D_L00_001B04B0_2cfcb8[] __asm__("D_L00_001B04B0") __attribute__((section(".data")));
extern s32 FUN_00213260_2cfcb8(s32) __asm__("FUN_00213260");
@@ -112,19 +112,19 @@ void FUN_L00_002cfcb8(M_2cfcb8 *moby) {
vars->pA4 = 0;
return;
}
- if (coll_hit_2cfcb8.moby == 0) {
- moby->pos.z = coll_hit_2cfcb8.point_z;
+ if ((*(H_2cfcb8 *)&D_L00_00173E40).moby == 0) {
+ moby->pos.z = (*(H_2cfcb8 *)&D_L00_00173E40).point_z;
vars->pA4 = 0;
return;
}
- if (FUN_L00_0025e3b8_2cfcb8(coll_hit_2cfcb8.moby) != 0) return;
+ if (FUN_L00_0025e3b8_2cfcb8((*(H_2cfcb8 *)&D_L00_00173E40).moby) != 0) return;
vars->pA4 = 0;
vars->flags |= 8;
- if (FUN_L00_002603d0_2cfcb8(coll_hit_2cfcb8.moby) != 0) {
+ if (FUN_L00_002603d0_2cfcb8((*(H_2cfcb8 *)&D_L00_00173E40).moby) != 0) {
if (moby != 0) moby->occlusion = 0x7F80;
- FUN_L00_00260668_2cfcb8(member, coll_hit_2cfcb8.moby, &moby->pos, &moby->rot_x, &vars->link_pos, &vars->link_rot);
+ FUN_L00_00260668_2cfcb8(member, (*(H_2cfcb8 *)&D_L00_00173E40).moby, &moby->pos, &moby->rot_x, &vars->link_pos, &vars->link_rot);
vars->stack_level = 0;
- vars->standing_on = coll_hit_2cfcb8.moby;
+ vars->standing_on = (*(H_2cfcb8 *)&D_L00_00173E40).moby;
}
return;
}
@@ -151,24 +151,24 @@ void FUN_L00_002cfcb8(M_2cfcb8 *moby) {
if (FUN_001efa68_2cfcb8(&probe_top, &probe_bottom, 2, 0, 0) == 0) {
vars->pA4 = 0;
} else {
- if (coll_hit_2cfcb8.moby == 0) {
- moby->pos.z = coll_hit_2cfcb8.point_z;
+ if ((*(H_2cfcb8 *)&D_L00_00173E40).moby == 0) {
+ moby->pos.z = (*(H_2cfcb8 *)&D_L00_00173E40).point_z;
vars->pA4 = 0;
- } else if (FUN_L00_0025e3b8_2cfcb8(coll_hit_2cfcb8.moby) == 0 && (u16)(coll_hit_2cfcb8.moby->oclass - 0x128) >= 2) {
+ } else if (FUN_L00_0025e3b8_2cfcb8((*(H_2cfcb8 *)&D_L00_00173E40).moby) == 0 && (u16)((*(H_2cfcb8 *)&D_L00_00173E40).moby->oclass - 0x128) >= 2) {
vars->pA4 = 0;
moby->update_dist = 0xFF;
vars->flags |= 8;
- } else if (coll_hit_2cfcb8.moby->vars == 0) {
+ } else if ((*(H_2cfcb8 *)&D_L00_00173E40).moby->vars == 0) {
vars->pA4 = 0;
- } else if (coll_hit_2cfcb8.moby->group != moby->group) {
+ } else if ((*(H_2cfcb8 *)&D_L00_00173E40).moby->group != moby->group) {
vars->pA4 = 0;
- } else if (FUN_L00_0025e3b8_2cfcb8(coll_hit_2cfcb8.moby) != 0) {
- vars->pA4 = coll_hit_2cfcb8.moby;
+ } else if (FUN_L00_0025e3b8_2cfcb8((*(H_2cfcb8 *)&D_L00_00173E40).moby) != 0) {
+ vars->pA4 = (*(H_2cfcb8 *)&D_L00_00173E40).moby;
src3 = &moby->pos;
- below = coll_hit_2cfcb8.moby;
+ below = (*(H_2cfcb8 *)&D_L00_00173E40).moby;
qcopy(src3, &below->pos);
FUN_001f9a10_2cfcb8(src3, src3, (u8 *)below + 0xE0);
- vars = coll_hit_2cfcb8.moby->vars;
+ vars = (*(H_2cfcb8 *)&D_L00_00173E40).moby->vars;
if (FUN_L00_0025e3b8_2cfcb8(moby) != 0) {
vars->next_member = moby;
} else {
@@ -178,7 +178,7 @@ void FUN_L00_002cfcb8(M_2cfcb8 *moby) {
} else {
vars->pA4 = 0;
vars->iCC = 0;
- moby->pos.z = coll_hit_2cfcb8.point_z;
+ moby->pos.z = (*(H_2cfcb8 *)&D_L00_00173E40).point_z;
}
}
}
@@ -196,11 +196,11 @@ void FUN_L00_002cfcb8(M_2cfcb8 *moby) {
probe_up.z += vars->height * 0.5f;
probe_down.z = 0.1f;
if (FUN_001efa68_2cfcb8(&probe_up, &probe_down, 2, moby, 0) != 0) {
- if (coll_hit_2cfcb8.moby != 0 && FUN_L00_002603d0_2cfcb8(coll_hit_2cfcb8.moby) != 0) {
+ if ((*(H_2cfcb8 *)&D_L00_00173E40).moby != 0 && FUN_L00_002603d0_2cfcb8((*(H_2cfcb8 *)&D_L00_00173E40).moby) != 0) {
if (moby != 0) moby->occlusion = 0x7F80;
- FUN_L00_00260668_2cfcb8(member, coll_hit_2cfcb8.moby, &member->pos, &member->rot_x, &vars->link_pos, &vars->link_rot);
+ FUN_L00_00260668_2cfcb8(member, (*(H_2cfcb8 *)&D_L00_00173E40).moby, &member->pos, &member->rot_x, &vars->link_pos, &vars->link_rot);
vars->stack_level = 0;
- vars->standing_on = coll_hit_2cfcb8.moby;
+ vars->standing_on = (*(H_2cfcb8 *)&D_L00_00173E40).moby;
vars->flags |= 8;
}
}
@@ -268,11 +268,11 @@ typedef struct {
typedef struct {
f32 f[4];
} V_2d0538;
-extern s32 D_0015ED84_2d0538 __asm__("D_0015ED84");
+extern int D_0015ED84;
extern s32 D_L00_0015F598 __asm__("D_L00_0015F598");
extern volatile f32 D_0015ED6C_a[1] __asm__("D_0015ED6C");
#define D_0015ED6C_2d0538 D_0015ED6C_a[0]
-extern f32 D_0015ED70_2d0538 __asm__("D_0015ED70");
+extern float D_0015ED70;
extern u8 *D_L00_001B04B0_2d0538[] __asm__("D_L00_001B04B0") __attribute__((section(".data")));
void clear_u64_value(void *) __asm__("FUN_001f99f8");
void FUN_L00_00260400_2d0538(u8 *, s32, void *, void *, void *, void *) __asm__("FUN_L00_00260400");
@@ -320,7 +320,7 @@ void crate_drop_bolts(u8 *a) {
FUN_L00_00260400_2d0538(a, *(s32 *)(b + 0xF0), a + 0x10, a + 0x40, &v30, &v40);
subtract_vector_xyz(&v20, &v30, a + 0x10);
}
- if (D_0015ED84_2d0538 == 0xF && absolute_float(*(f32 *)(a + 0x10) - 166.0f) < 6.0f &&
+ if (D_0015ED84 == 0xF && absolute_float(*(f32 *)(a + 0x10) - 166.0f) < 6.0f &&
absolute_float(*(f32 *)(a + 0x14) - 193.0f) < 6.0f) {
s32 save = D_L00_0015F598;
D_L00_0015F598 = 0;
@@ -392,8 +392,8 @@ void crate_drop_bolts(u8 *a) {
}
if (*(s32 *)(b + 0xC0) >= 0) {
s32 k = FUN_L00_002595a0_2d0538(
- &f54, &f58, D_0015ED70_2d0538 * 10.8f * -0.5f,
- *(f32 *)(q + 0x18) - D_0015ED70_2d0538 * 10.8f * -0.5f,
+ &f54, &f58, D_0015ED70 * 10.8f * -0.5f,
+ *(f32 *)(q + 0x18) - D_0015ED70 * 10.8f * -0.5f,
*(f32 *)(p + 0x18) -
*(f32 *)(D_L00_001B04B0_2d0538[*(s32 *)(b + 0xC0)] + 0x18));
e = 120.0f;
@@ -500,9 +500,9 @@ extern s32 D_L00_0015FFBC __asm__("D_L00_0015FFBC");
extern f32 D_0015ED6C_2d09b8 __asm__("D_0015ED6C");
extern f32 D_L00_0015F5D0 __asm__("D_L00_0015F5D0");
extern s32 D_001413DC_2d09b8 __asm__("D_001413DC") __attribute__((section(".data")));
-extern u8 *D_001413D0_2d09b8 __asm__("D_001413D0") __attribute__((section(".data")));
+extern int D_001413D0[] __attribute__((section(".data")));
extern f32 D_L00_00166C80_2d19b0[] __asm__("D_L00_00166C80");
-extern V2d09b8 D_L00_00166DC0_2d09b8 __asm__("D_L00_00166DC0");
+extern char camera_position[] __asm__("D_L00_00166DC0");
extern V2d09b8 D_L00_001DE6F0_2d09b8[] __asm__("D_L00_001DE6F0");
extern V2d09b8 D_L00_001DE750_2d09b8[] __asm__("D_L00_001DE750");
extern u32 D_L00_001E9E80_2d09b8[] __asm__("D_L00_001E9E80");
@@ -578,7 +578,7 @@ void FUN_L00_002d09b8(M2d1428 *m, s32 hit, s32 source) {
if (source)
qcopy(&b, (u8 *)source + 0x10);
else
- FUN_001ff2a8_2d09b8(&b, &m->pos, D_001413D0_2d09b8 + 0x10);
+ FUN_001ff2a8_2d09b8(&b, &m->pos, (*(u8 * *)D_001413D0) + 0x10);
switch ((s16)((u16)m->oclass - 500)) {
case 1: kind = 0x15C; break;
case 3: kind = 0x15F; break;
@@ -650,7 +650,7 @@ void FUN_L00_002d09b8(M2d1428 *m, s32 hit, s32 source) {
vars[0xCA] = 1;
FUN_001ff500_2d09b8(0.5f, &a, (u8 *)m + 0xE0);
FUN_001ff278_2d09b8(&a, &a, &m->pos);
- FUN_001ff2a8_2d09b8(&d, &D_L00_00166DC0_2d09b8, &m->pos);
+ FUN_001ff2a8_2d09b8(&d, &(*(V2d09b8 *)camera_position), &m->pos);
FUN_001ff260_2d09b8(&e);
distance = FUN_001ff3d8_2d09b8(&d);
choice = 10;
@@ -810,7 +810,7 @@ extern s32 D_L00_001618EC __attribute__((sda));
extern s32 D_L00_001618F0 __attribute__((sda));
extern s32 D_L00_001618F4 __attribute__((sda));
extern f32 D_L00_00166C80_2d19b0[] __asm__("D_L00_00166C80");
-extern Vec_2d19b0 D_L00_00166DC0_loop_2d19b0 __asm__("D_L00_00166DC0");
+extern char camera_position[] __asm__("D_L00_00166DC0");
extern Vec_2d19b0 D_L00_001DE7B0_2d19b0[] __asm__("D_L00_001DE7B0");
extern s16 D_L00_001DEE10_2d19b0[] __asm__("D_L00_001DEE10");
extern Vec_2d19b0 D_L00_001DF9A0_2d19b0[] __asm__("D_L00_001DF9A0");
@@ -863,7 +863,7 @@ void FUN_L00_002d19b0(u8 *m) {
old_uv = D_L00_001E0E30_2d19b0;
for (i = 0; i < 0x66; i++) {
transform_vector_2d19b0(&D_L00_001E04A0_2d19b0[i], &D_L00_001DE7B0_2d19b0[i], vars);
- subtract_vector_2d19b0(&b, &D_L00_001E04A0_2d19b0[i], &D_L00_00166DC0_loop_2d19b0);
+ subtract_vector_2d19b0(&b, &D_L00_001E04A0_2d19b0[i], &(*(Vec_2d19b0 *)camera_position));
normalize_vector_2d19b0(&b, &b, 1.0f);
transform_vector_2d19b0(&a, &D_L00_001DF9A0_2d19b0[i], vars);
normalize_vector_2d19b0(&a, &a, 0.1f);
@@ -943,7 +943,7 @@ typedef struct M2d1e80 {
} M2d1e80;
extern s32 D_L00_0015F5C4;
extern s32 D_L00_0016C890[];
-void build_moby_bone_transform(void *, s32, void *) __asm__("FUN_0020cca8");
+extern void build_moby_bone_transform(void *, int, void *) __asm__("FUN_0020cca8");
void enqueue_callback_list_1(void *, void *) __asm__("FUN_001f4600");
void FUN_L00_002d19b0(void);
void FUN_L00_002d1e80(M2d1e80 *m) {
@@ -1000,14 +1000,14 @@ typedef float Mat3_2D3608[3][4] __attribute__((aligned(16)));
extern unsigned char D_001413D0_r[] __asm__("D_001413D0");
extern char D_0013F990[];
-extern char D_L00_00166DC0_c[] __asm__("D_L00_00166DC0");
+extern char camera_position[] __asm__("D_L00_00166DC0");
extern f32 fast_add_rotations_c(f32, f32) __asm__("func_001FA580");
extern f32 fast_cos_c(f32) __asm__("func_001F9DC8");
extern f32 fast_sin_c(f32) __asm__("func_001F9DE0");
extern f32 fast_subtract_rotations_c(f32, f32) __asm__("func_001FA5C8");
extern f32 square_root_scalar(f32) __asm__("func_001F9988");
extern f32 vector_length_xy(void *) __asm__("FUN_001f9b20");
-extern float D_0015ED70_c __asm__("D_0015ED70");
+extern float D_0015ED70;
extern float FUN_001f9e90_c(float, float) __asm__("FUN_001f9e90");
extern int D_0013C940;
extern int D_L00_00166C80;
@@ -1022,11 +1022,11 @@ extern void transform_vector(void *, void *, void *) __asm__("func_001F9D20");
extern void transform_vector_by_basis(void *, void *, void *) __asm__("func_001F9CF8");
void FUN_L00_002c7320(void *pos, void *tgt, f32 *out, f32 speed, f32 unused, f32 range);
extern char player_camera_2D3608[] __asm__("D_L00_00166C80");
-extern char camera_pos_2D3608[] __asm__("D_L00_00166DC0");
-extern char coll_hit_2D3608[] __asm__("D_L00_00173E40");
+extern char camera_position[] __asm__("D_L00_00166DC0");
+extern int D_L00_00173E40;
extern char D_0013F990_2D3608[] __asm__("D_0013F990");
extern char controller_state_2D3608[] __asm__("D_0013C940");
-extern float frame_time_sq_2D3608 __asm__("D_0015ED70");
+extern float D_0015ED70;
extern void func_001FA480_2D3608(void *, void *) __asm__("FUN_001fa2b8");
extern void func_001FA4A0_2D3608(void *, void *) __asm__("FUN_001fa2d8");
extern void func_001F9EC0_2D3608(void *, void *, void *) __asm__("FUN_001f9cf8");
@@ -1098,17 +1098,17 @@ void FUN_L00_002d2158(int collision_arg, Moby_2D3608 *carrier, float *position)
value = rise / 0.00999999978f;
}
}
- fall_time = func_001F9B50_2D3608(frame_time_sq_2D3608 * 9.0f * ((((PadState *)controller_state_2D3608)->held & 5) ? 3.5f : 2.5f) * 0.5f);
- distance = (fall_time + fall_time) * fall_time * (1.0f - value) / (frame_time_sq_2D3608 * 9.0f);
+ fall_time = func_001F9B50_2D3608(D_0015ED70 * 9.0f * ((((PadState *)controller_state_2D3608)->held & 5) ? 3.5f : 2.5f) * 0.5f);
+ distance = (fall_time + fall_time) * fall_time * (1.0f - value) / (D_0015ED70 * 9.0f);
vertical = value * distance;
if (0.0f < distance) {
launch[0] = func_001F9F90_2D3608(heading) * distance;
launch[1] = func_001F9FA8_2D3608(heading) * distance;
launch[2] = vertical;
- func_001F9BD8_2D3608(endpoint, camera_pos_2D3608, launch);
- if (func_L00_001EFFF0_2D3608(camera_pos_2D3608, endpoint, 2, collision_arg, 0)
- && ((Hit_2D3608 *)coll_hit_2D3608)->moby != *(void **)(D_001413D0_r)) {
- qcopy(aim, ((Hit_2D3608 *)coll_hit_2D3608)->point);
+ func_001F9BD8_2D3608(endpoint, camera_position, launch);
+ if (func_L00_001EFFF0_2D3608(camera_position, endpoint, 2, collision_arg, 0)
+ && ((Hit_2D3608 *)((char *)&D_L00_00173E40))->moby != *(void **)(D_001413D0_r)) {
+ qcopy(aim, ((Hit_2D3608 *)((char *)&D_L00_00173E40))->point);
hit = 1;
heading = func_L00_001FF860_2D3608(aim[0] - anchor_ptr[0], aim[1] - anchor_ptr[1]);
}
@@ -1117,142 +1117,173 @@ void FUN_L00_002d2158(int collision_arg, Moby_2D3608 *carrier, float *position)
aim[0] = func_001F9F90_2D3608(heading) * distance * value;
aim[1] = func_001F9FA8_2D3608(heading) * distance * value;
aim[2] = vertical * value;
- func_001F9BD8_2D3608(aim, aim, camera_pos_2D3608);
+ func_001F9BD8_2D3608(aim, aim, camera_position);
}
}
} else {
*(int *)(D_0013F990_2D3608 + 0x410) = 0;
}
}
- func_L00_002C8680_2D3608(anchor_ptr, aim, output + 4, frame_time_sq_2D3608 * 9.0f, 0.00000999999975f,
+ func_L00_002C8680_2D3608(anchor_ptr, aim, output + 4, D_0015ED70 * 9.0f, 0.00000999999975f,
(((PadState *)controller_state_2D3608)->held & 5) ? 3.5f : 2.5f);
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L00_002d2670.s", FUN_L00_002d2670);
-#else
-#include "rnc/gameplay/state/usage_stats.h"
-typedef union { u32 word[4]; f32 f[4]; int q __attribute__((mode(TI))); } __attribute__((aligned(16))) V2d2670;
-extern u8 D_0013E539;
-extern u8 D_001413F8, D_001413FC;
-extern s32 D_0013F50C, D_0013F4E8;
-extern u32 D_0013CAE4 __attribute__((section(".data")));
-extern s32 D_0015EEA4;
-extern struct UsageStat D_00141748;
-extern u8 D_00141680[] __attribute__((section(".data")));
-extern void FUN_L00_0024f7c8_2d2670(void *, s32, void *) __asm__("FUN_L00_0024f7c8");
-extern void FUN_L00_0024f728(void *, s32, void *);
-extern void FUN_001ff6f8_2d2670(void *, void *, void *) __asm__("FUN_001f9d20");
-extern void FUN_001ff278_2d2670(void *, void *, void *) __asm__("FUN_001f9a10");
+#include "qzero.h"
+
+/* Decoy glove update: state machine on moby[0x20], per-object data block at moby[0x78]. */
+/* Ported from rac1-decomp (src/overlays/shared/vendor_002D1168.c: func_L00_002D3B20), where it is exact; names translated to the US level program. */
+
+typedef struct {
+ f32 x;
+ f32 y;
+ f32 z;
+ f32 w;
+} Vec4f_2d2670;
+
+typedef int u128_D3B20 __attribute__((mode(TI)));
+
+extern char D_0013A4E0[];
+extern char D_0013E533[];
+extern unsigned char D_0014161B;
+extern int D_0015ED84;
+extern int D_0015EEA4;
+extern int FUN_L00_00216de8(int, int);
+extern int FUN_L00_00233db8(int, int);
+extern int FUN_L00_00233e98(int);
+extern int FUN_L00_002c35c0(void *, void *, void *);
+extern int tick_countdown_32_alt(int *) __asm__("FUN_001f9740");
+extern s32 scale_game_frames_c2(s32) __asm__("func_001F96F8");
+extern short D_L00_001B0830[];
+extern void FUN_L00_002223f8(int, int);
+extern void FUN_L00_0024f7c8(void *, int, void *);
extern void FUN_L00_0025f800(void *, void *);
-extern void FUN_0020c828_2d2670(void *) __asm__("FUN_0020c828");
-extern u8 *FUN_L00_002c35c0(s32, void *, void *);
-extern void FUN_L00_002223f8(s32, s32);
-extern s32 FUN_001fef68_2d2670(s32 *) __asm__("FUN_001f9740");
-extern s32 FUN_001fef20_2d2670(s32) __asm__("FUN_001f96f8");
-extern s32 get_ammo(s32) __asm__("FUN_L00_00233e98");
-extern void FUN_L00_00216de8(s32, s32);
-extern int use_ammo(s32, s32) __asm__("FUN_L00_00233db8");
-extern void FUN_L00_002d2158_u(void *, void *, void *) __asm__("FUN_L00_002d2158");
-extern void FUN_0022da68_2d2670(s32, s32, void *) __asm__("FUN_0022da68");
-extern void FUN_L00_002c3888(void *, void *, void *);
-extern s16 D_L00_001B0830[];
-
-void FUN_L00_002d2670(u8 *moby) {
- u8 *vars, *target;
- V2d2670 position, offset, difference;
- u8 start[64] __attribute__((aligned(16)));
- V2d2670 velocity;
- s32 value;
- struct { u8 pad[0xc8]; struct UsageStat stat; } *stat;
+extern void FUN_L00_002c3888(float *, char *, void *);
+extern int allocate_voice_for_target_entry(int, int, void *) __asm__("FUN_0022da68");
+extern void mark_moby_for_removal() __asm__("FUN_0020c828");
+extern void transform_vector_alt() __asm__("FUN_001f9d20");
+void FUN_L00_002d2158_c(int collision_arg, Moby_2D3608 *carrier, float *position) __asm__("FUN_L00_002d2158");
+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[];
+extern void build_moby_bone_transform(void *, int, void *) __asm__("FUN_0020cca8");
+
+void FUN_L00_002d2670(unsigned char *moby) {
+ extern void mark_moby_for_removal();
+ extern void transform_vector_alt();
+ extern int allocate_voice_for_target_entry(int, int, void *);
+ char *d;
+ char *p;
+ char *g;
+ float vb[4];
+ float va[4];
+ float vc[4];
+ float vd[4];
+ float pad0[4];
+ float pad1[4];
+ float pad2[4];
+ u128_D3B20 loc;
if (moby == 0) return;
- vars = *(u8 **)(moby + 0x78);
- if (vars == 0) return;
- offset.q = 0;
- offset.f[1] = -0.19f;
- offset.f[2] = -0.11f;
- FUN_L00_0024f7c8_2d2670(moby, 0, &position);
- FUN_L00_0024f728(moby, 0, &start);
- FUN_001ff6f8_2d2670(&difference, &offset, &start);
- FUN_001ff278_2d2670(vars + 0x40, &position, &difference);
- target = *(u8 **)(vars + 0x50);
- if (target != 0) {
- value = 1;
- *(s32 *)(target + 0x98) = value;
- if (D_0013E539 && *(s16 *)(*(u8 **)(vars + 0x50) + 0xa6) != 0x76c) {
- *(u64 *)&velocity = 0;
- *((u64 *)&velocity + 1) = 0;
- FUN_L00_0025f800(*(u8 **)(vars + 0x50), D_L00_001B0830);
- FUN_0020c828_2d2670(*(u8 **)(vars + 0x50));
- *(u8 **)(vars + 0x50) = FUN_L00_002c35c0((s32)moby, vars + 0x40, &velocity);
- }
- if (*(u8 **)(vars + 0x50) != 0 &&
- (*(u8 **)(vars + 0x50))[0x20] != 0xfe &&
- (*(u8 **)(vars + 0x50))[0x20] != 0xfd)
+ d = *(char **)(moby + 0x78);
+ if (d == 0) return;
+ *(u128_D3B20 *)va = 0;
+ va[1] = -0.19f;
+ va[2] = -0.11f;
+ FUN_L00_0024f7c8(moby, 0, vb);
+ build_moby_bone_transform(moby, 0, vd);
+ transform_vector_alt(vc, va, vd);
+ add_vector_xyz(d + 0x40, vb, vc);
+
+ p = *(char **)(d + 0x50);
+ if (p) {
+ *(int *)(p + 0x98) = 1;
+ if (D_0013E539_lui && *(short *)(*(char **)(d + 0x50) + 0xA6) != 0x76C) {
+ qzero(&loc);
+ FUN_L00_0025f800(*(char **)(d + 0x50), D_L00_001B0830);
+ ((void (*)(void *))mark_moby_for_removal)(*(char **)(d + 0x50));
+ *(int *)(d + 0x50) = FUN_L00_002c35c0(moby, d + 0x40, &loc);
+ }
+ if (*(char **)(d + 0x50) != 0 &&
+ *(unsigned char *)(*(char **)(d + 0x50) + 0x20) != 0xFE &&
+ *(unsigned char *)(*(char **)(d + 0x50) + 0x20) != 0xFD)
goto target_valid;
}
- *(u8 **)(vars + 0x50) = 0;
+ *(int *)(d + 0x50) = 0;
target_valid:
- if (hero.state.current == 1) FUN_L00_002223f8(0x1e, 1);
- if (FUN_001fef68_2d2670((s32 *)(vars + 0x54)) && hero.unk20AC == 0) {
- if ((hero.unk20A8 && hero.unk1BC == FUN_001fef20_2d2670(0x11)) ||
- ((D_0013CAE4 & hero.items[0].button_mask) && hero.state.current == 0x1e && get_ammo(-1)) ||
- (hero.state.current == 0x23 && hero.state_timer == FUN_001fef20_2d2670(0x10))) {
- FUN_L00_00216de8(0x1a, 0);
- use_ammo(-1, 1);
- value = 3;
- moby[0x20] = value;
- }
- }
- velocity.q = ((V2d2670 *)(vars + 0x40))->q;
- FUN_L00_002d2158_u(moby, vars, &velocity);
+ g = ((char *)&hero);
+ if (*(int *)(g + 0x2084) == 1) FUN_L00_002223f8(0x1E, 1);
+ if (tick_countdown_32_alt((int *)(d + 0x54))) {
+ if (*(unsigned char *)(g + 0x20AC) == 0) {
+ if (*(unsigned char *)(g + 0x20A8) && *(int *)(g + 0x1BC) == scale_game_frames_c2(0x11)) goto L3D10;
+ if (*(int *)(((char *)&D_0013CAE4)) & *(int *)(g + 0x10A0)) {
+ if (*(int *)(g + 0x2084) == 0x1E && FUN_L00_00233e98(-1)) goto L3D10;
+ }
+ g = ((char *)&hero);
+ if (*(int *)(g + 0x2084) == 0x23 && *(int *)(g + 0x198) == scale_game_frames_c2(0x10)) goto L3D10;
+ }
+ }
+ goto L3D34;
+L3D10:
+ FUN_L00_00216de8(0x1A, 0);
+ FUN_L00_00233db8(-1, 1);
+ moby[0x20] = 3;
+L3D34:
+ *(u128_D3B20 *)&loc = *(u128_D3B20 *)(d + 0x40);
+ FUN_L00_002d2158_c((int)moby, (void *)d, (float *)&loc);
+
switch (moby[0x20]) {
case 0:
- *(u8 **)(vars + 0x50) = 0;
+ *(int *)(d + 0x50) = 0;
if (!(moby[0x70] & 2)) moby[0x20] = 1; else moby[0x20] = 2;
case 1:
if (moby[0x70] & 2) moby[0x20] = 2;
break;
+ case 2:
+ break;
case 3:
- if (*(u8 **)(vars + 0x50) != 0) {
- stat = (void *)D_00141680;
- if (stat->stat.count < 0xffff) stat->stat.count++;
- value = FUN_001fef20_2d2670(D_0015EEA4) / 600;
- if (stat->stat.unk2 < value) stat->stat.unk2 = FUN_001fef20_2d2670(D_0015EEA4) / 600;
- stat->stat.level_mask = (stat->stat.level_mask | (1 << current_level_index)) | 0x80000000;
- FUN_L00_002c3888(vars + 0x40, *(u8 **)(vars + 0x50),
- *(u8 **)(*(u8 **)(vars + 0x50) + 0x78) + 0x10);
- *(u8 **)(vars + 0x50) = 0;
+ if (*(char **)(d + 0x50)) {
+ char *stats = ((char *)&D_00141680);
+ 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;
+ *(unsigned int *)(stats + 0xCC) = (*(unsigned int *)(stats + 0xCC) | (1 << D_0015ED84)) | 0x80000000;
+ FUN_L00_002c3888((float *)(d + 0x40), *(char **)(d + 0x50), *(char **)(*(char **)(d + 0x50) + 0x78) + 0x10);
+ *(int *)(d + 0x50) = 0;
} else {
- FUN_0022da68_2d2670(0, 0, moby);
+ allocate_voice_for_target_entry(0, 0, (int)moby);
}
moby[0x20] = 4;
- *(s32 *)(vars + 0x54) = FUN_001fef20_2d2670(0x14);
+ *(int *)(d + 0x54) = scale_game_frames_c2(0x14);
break;
- case 4:
- if (hero.state.current != 0x23 && hero.unk20A8 == 0) {
- moby[0x20] = 2;
- break;
- }
+ case 4: {
+ char *h = ((char *)&hero);
+ if (*(int *)(h + 0x2084) != 0x23 && *(unsigned char *)(h + 0x20A8) == 0) moby[0x20] = 2;
break;
+ }
case 5:
moby[0x20] = 6;
break;
case 6:
return;
+ default:
+ break;
+ }
+
+ if (*(char **)(d + 0x50)) {
+ qcopy(*(char **)(d + 0x50) + 0x10, d + 0x40);
+ return;
}
- if (*(u8 **)(vars + 0x50) != 0) {
- ((V2d2670 *)(*(u8 **)(vars + 0x50) + 0x10))->q = ((V2d2670 *)(vars + 0x40))->q;
+ if (FUN_L00_00233e98(-1)) {
+ qzero(&loc);
+ *(int *)(d + 0x50) = FUN_L00_002c35c0(moby, d + 0x40, &loc);
} else {
- if (!get_ammo(-1)) {
- if (!hero.unk20A8) return;
- *(volatile u64 *)&velocity = 0;
- *((u64 *)&velocity + 1) = 0;
- } else velocity.q = 0;
- *(u8 **)(vars + 0x50) = FUN_L00_002c35c0((s32)moby, vars + 0x40, &velocity);
+ char *h = ((char *)&hero);
+ if (*(unsigned char *)(h + 0x20A8)) {
+ qzero(&loc);
+ *(int *)(d + 0x50) = FUN_L00_002c35c0(moby, d + 0x40, &loc);
+ }
}
}
-#endif
/* Ported from rac1-decomp src/overlays/shared/vendor_002D1168.c (func_L00_002D3F40) */
#include "sda.h"
@@ -1466,7 +1497,7 @@ extern void matrix_to_quaternion(void *, void *) __asm__("FUN_00214260");
extern void FUN_L00_00259f50(void *, void *);
extern void quaternion_nlerp(void *, void *, void *, f32) __asm__("FUN_001fa400");
extern s32 FUN_L00_0028d8c0(struct Moby *, s32);
-extern s32 allocate_voice_for_target_entry(s32, s32, void *) __asm__("FUN_0022da68");
+extern int allocate_voice_for_target_entry(int, int, void *) __asm__("FUN_0022da68");
extern void FUN_L00_0028df38(s32, s32);
extern f32 random_float_between(f32, f32) __asm__("FUN_002132a8");
extern void FUN_L00_0025f8e0(void *, f32);
@@ -1778,275 +1809,339 @@ unsigned char *FUN_L00_002d3838(unsigned char *s, void *b, int c, void *d) {
}
return m;
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L00_002d3a10.s", FUN_L00_002d3a10);
-#else
-extern u8 *D_0015FFD8_2d3a10 __asm__("D_L00_0015FFD8");
-extern f32 D_0015ED60_2d3a10 __asm__("D_0015ED60");
-extern u8 D_L00_001802C0_2d3a10[] __asm__("D_L00_001802C0");
-extern s32 FUN_001fef68_2d3a10(void *) __asm__("FUN_001f9740");
-extern s32 FUN_001fef98_2d3a10(void *) __asm__("FUN_001f9770");
-extern s32 FUN_001fef20_2d3a10(s32) __asm__("FUN_001f96f8");
-extern s32 FUN_001fefc8_2d3a10(void *) __asm__("FUN_L00_001fefc8");
-extern f32 FUN_00200240_2d3a10(s32) __asm__("FUN_001fa6c0");
-extern s32 FUN_00200250_2d3a10(f32) __asm__("FUN_001fa6d0");
-extern s32 FUN_002002e0_2d3a10(f32, void *) __asm__("FUN_001fa728");
-extern f32 FUN_00257be8_2d3a10(f32, f32) __asm__("FUN_002132a8");
-extern void FUN_001ff300_2d3a10(f32, void *, void *) __asm__("FUN_001f9a68");
-extern void FUN_001ff6d0_2d3a10(void *, void *, void *) __asm__("FUN_001f9cf8");
-extern void FUN_001ff278_2d3a10(void *, void *, void *) __asm__("FUN_001f9a10");
-extern void FUN_0023e838_2d3a10(s32) __asm__("FUN_L00_0023e838");
-extern s32 FUN_0023e738_2d3a10(f32, f32, f32, f32, f32, void *) __asm__("FUN_L00_0023e738");
-extern void FUN_0024eb68_2d3a10(u8 *) __asm__("FUN_0020c828");
-typedef union { u32 word[4]; f32 f[4]; int q __attribute__((mode(TI))); } __attribute__((aligned(16))) V2d3a10;
-
-void FUN_L00_002d3a10(u8 *moby) {
- u8 *vars, *row, *moby_position;
- V2d3a10 position, target, offset;
- s32 flags, active, changed;
- f32 value, limit, step;
- s32 i;
- if (!moby) return;
- vars = *(u8 **)(moby + 0x78);
- changed = 0;
- if (!vars) return;
- if (!moby[0x20]) {
- moby[0x30] = 0xff;
- moby[0xbc] = vars[0x1c];
- qcopy(vars + 0x10, moby + 0x10);
+/* moby class 639 update: runs its state machine and eases its tracked values toward their targets */
+/* Ported from rac1-decomp (src/overlays/shared/vendor_002D1168.c: func_L00_002D4EC0), where it is exact; names translated to the US level program. */
+
+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);
+extern int tick_countdown_32_alt(int *) __asm__("FUN_001f9740");
+extern s32 scale_game_frames_c(s32) __asm__("func_001F96F8");
+extern unsigned char D_L00_001802C0[];
+extern void FUN_L00_0023e838(int);
+extern void fast_vec_scale_c(void *, void *, f32) __asm__("func_001F9A68");
+extern void mark_moby_for_removal() __asm__("FUN_0020c828");
+int FUN_001fa728(Vec4f *, float);
+extern int fast_bsphere_check(void *, float) __asm__("FUN_001fa728");
+extern void mark_moby_for_removal() __asm__("FUN_0020c828");
+extern int scale_game_frames(int) __asm__("FUN_001f96f8");
+extern int func_001FA898_r(float) __asm__("FUN_001fa6d0");
+
+void FUN_L00_002d3a10(unsigned char *m) {
+ unsigned char *o;
+ Vx tp;
+ Vx t2;
+ Vx t3;
+ unsigned char *v21;
+ void *v20;
+ void *v19;
+ int c0;
+ int c1 = 0;
+ int c2 = 0;
+ int c3 = 0;
+ int r;
+
+ if (m == 0) return;
+ o = *(unsigned char **)(m + 0x78);
+ c0 = 0;
+ if (o == 0) return;
+ if (m[0x20] == 0) {
+ unsigned char b1c;
+ m[0x30] = 0xFF;
+ b1c = o[0x1C];
+ m[0xBC] = b1c;
+ qcopy(o + 0x10, m + 0x10);
+ *(int *)(o + 0x50) = -1;
+ o[0x1C] = b1c;
+ *(int *)(o + 0xC) = *(int *)(o + 0x4C);
+ *(short *)(o + 0x74) = *(unsigned short *)(o + 0x6C);
+ *(short *)(o + 0x76) = *(unsigned short *)(o + 0x6E);
+ *(short *)(o + 0x78) = *(unsigned short *)(o + 0x70);
+ *(short *)(o + 0x7A) = *(unsigned short *)(o + 0x72);
+ *(float *)(o + 0x54) = convert_integer_to_float_c(o[0x25]) / 100.0f;
+ *(float *)(o + 0x58) = convert_integer_to_float_c(o[0x2A]) / 100.0f;
{
- u16 first_timer = *(u16 *)(vars + 0x6e);
- u16 second_timer = *(u16 *)(vars + 0x6c);
- u16 third_timer = *(u16 *)(vars + 0x70);
- u16 fourth_timer = *(u16 *)(vars + 0x72);
- u32 flags = *(u32 *)(vars + 0x4c);
- *(u16 *)(vars + 0x76) = first_timer;
- vars[0x1c] = moby[0xbc];
- *(u32 *)(vars + 0xc) = flags;
- *(u16 *)(vars + 0x74) = second_timer;
- *(u16 *)(vars + 0x78) = third_timer;
- *(u16 *)(vars + 0x7a) = fourth_timer;
- *(s32 *)(vars + 0x50) = -1;
- }
- *(f32 *)(vars + 0x54) = FUN_00200240_2d3a10(vars[0x25]) / 100.0f;
- *(f32 *)(vars + 0x58) = FUN_00200240_2d3a10(vars[0x2a]) / 100.0f;
- *(f32 *)(vars + 0x5c) = FUN_00200240_2d3a10(vars[0x2f]) / 100.0f;
- *(f32 *)(vars + 0x60) = *(f32 *)(vars + 0x34);
- if (*(s32 *)(vars + 0x64) != -1)
- *(u8 **)(vars + 0x20) = D_0015FFD8_2d3a10 + (*(s32 *)(vars + 0x64) << 8);
- if (*(f32 *)(vars + 0x40) < 0.0f) *(f32 *)(vars + 0x40) = -*(f32 *)(vars + 0x40);
- if (*(f32 *)(vars + 0x44) < 0.0f) *(f32 *)(vars + 0x44) = -*(f32 *)(vars + 0x44);
- moby[0x20] = 1;
- }
- if (moby[0xbc]) { moby[0xbc]--; return; }
- if (*(s32 *)(vars + 0x48) != -1 && FUN_001fef68_2d3a10(vars + 0x48)) {
- active = *(s32 *)(vars + 0x50);
- if (active != -1) { FUN_0023e838_2d3a10(active); *(s32 *)(vars + 0x50) = -1; }
- FUN_0024eb68_2d3a10(moby);
+ float f5 = convert_integer_to_float_c(o[0x2F]) / 100.0f;
+ *(float *)(o + 0x60) = *(float *)(o + 0x34);
+ *(float *)(o + 0x5C) = f5;
+ }
+ if (*(int *)(o + 0x64) != -1) {
+ *(char **)(o + 0x20) = moby_table + (*(int *)(o + 0x64) << 8);
+ }
+ if (*(float *)(o + 0x40) < 0.0f) *(float *)(o + 0x40) = -*(float *)(o + 0x40);
+ if (*(float *)(o + 0x44) < 0.0f) *(float *)(o + 0x44) = -*(float *)(o + 0x44);
+ m[0x20] = 1;
+ }
+ if (m[0xBC] != 0) {
+ m[0xBC] = m[0xBC] - 1;
return;
}
- moby_position = moby + 0x10;
- qcopy(&position, moby_position);
- position.f[3] = *(f32 *)(vars + 0x60);
- if (FUN_002002e0_2d3a10(255.0f, &position) == -1) {
- active = *(s32 *)(vars + 0x50);
- if (active != -1) { FUN_0023e838_2d3a10(active); *(s32 *)(vars + 0x50) = -1; }
+ if (*(int *)(o + 0x48) != -1 && tick_countdown_32_alt((int *)(o + 0x48))) {
+ if (*(int *)(o + 0x50) != -1) {
+ FUN_L00_0023e838(*(int *)(o + 0x50));
+ *(int *)(o + 0x50) = -1;
+ }
+ mark_moby_for_removal(m);
return;
}
- row = *(u8 **)(vars + 0x20);
- if (row) target = *(V2d3a10 *)(row + 0x10); else target = *(V2d3a10 *)(vars + 0x10);
- flags = *(s32 *)(vars + 0x4c);
- if (!(flags & 0x800000)) {
- if (flags & 0x100000) {
- if (flags & 0x200000) {
- offset.f[0] = FUN_00257be8_2d3a10(-*(f32 *)(vars + 0x0), *(f32 *)(vars + 0x0));
- offset.f[1] = FUN_00257be8_2d3a10(-*(f32 *)(vars + 0x4), *(f32 *)(vars + 0x4));
- offset.f[2] = FUN_00257be8_2d3a10(-*(f32 *)(vars + 0x8), *(f32 *)(vars + 0x8));
+ {
+ unsigned char *s = m + 0x10;
+ qcopy(&tp, s);
+ tp.w = *(float *)(o + 0x60);
+ v21 = s;
+ s = (unsigned char *)&tp;
+ r = fast_bsphere_check(s, 255.0f);
+ }
+ if (r != -1) {
+ if (*(unsigned char **)(o + 0x20) != 0) {
+ qcopy(&t2, *(unsigned char **)(o + 0x20) + 0x10);
+ } else {
+ qcopy(&t2, o + 0x10);
+ }
+ v20 = &t2;
+ if (!(*(int *)(o + 0x4C) & 0x800000)) {
+ if (*(int *)(o + 0x4C) & 0x100000) {
+ if (*(int *)(o + 0x4C) & 0x200000) {
+ t3.x = random_float_between_c(-*(float *)(o + 0x0), *(float *)(o + 0x0));
+ t3.y = random_float_between_c(-*(float *)(o + 0x4), *(float *)(o + 0x4));
+ t3.z = random_float_between_c(-*(float *)(o + 0x8), *(float *)(o + 0x8));
+ v19 = &t3;
+ } else {
+ int c = *(int *)(o + 0xC);
+ void *p = &t3;
+ *(int *)(o + 0xC) = 0;
+ fast_vec_scale_c(p, o, random_float_between_c(*(float *)(o + 0xC), 1.0f));
+ *(int *)(o + 0xC) = c;
+ v19 = p;
+ }
} else {
- u32 w = *(u32 *)(vars + 0xc);
- *(u32 *)(vars + 0xc) = 0;
- FUN_001ff300_2d3a10(FUN_00257be8_2d3a10(*(f32 *)(vars + 0xc), 1.0f), &offset, vars);
- *(u32 *)(vars + 0xc) = w;
+ int c = *(int *)(o + 0xC);
+ void *p = &t3;
+ *(int *)(o + 0xC) = 0;
+ qcopy(p, o);
+ *(int *)(o + 0xC) = c;
+ v19 = p;
}
+ if (*(int *)(o + 0x4C) & 0x400000) {
+ if (*(unsigned char **)(o + 0x20) != 0) {
+ transform_vector_by_basis(v19, v19, *(unsigned char **)(o + 0x20) + 0xC0);
+ }
+ }
+ add_vector_xyz(v21, v20, v19);
} else {
- u32 w = *(u32 *)(vars + 0xc);
- *(u32 *)(vars + 0xc) = 0;
- qcopy(&offset, vars);
- *(u32 *)(vars + 0xc) = w;
- }
- if ((*(s32 *)(vars + 0x4c) & 0x400000) && row)
- FUN_001ff6d0_2d3a10(&offset, &offset, row + 0xc0);
- FUN_001ff278_2d3a10(moby_position, &target, &offset);
- } else qcopy(moby_position, &target);
- if (*(u16 *)(vars + 0x72) && FUN_001fef98_2d3a10(vars + 0x7a)) {
- *(u16 *)(vars + 0x7a) = FUN_001fef20_2d3a10(*(u16 *)(vars + 0x72));
- if (*(s32 *)(vars + 0x4c) & 4) {
- changed = 1;
- *(f32 *)(vars + 0x60) = *(f32 *)(vars + 0x3c);
- *(s32 *)(vars + 0x4c) &= (u32)~8U;
- }
- }
- flags = *(s32 *)(vars + 0x4c);
- if (!(flags & 0x80000)) {
- if ((*(u64 *)(vars + 0x48) & 0x300000000ULL) == 0x200000000ULL) *(s32 *)(vars + 0x4c) ^= 2;
- {
- s32 flags = *(s32 *)(vars + 0x4c);
- if (!(flags & 2)) {
- if (flags & 8) {
- *(f32 *)(vars + 0x60) = *(f32 *)(vars + 0x60) - *(f32 *)(vars + 0x44) * D_0015ED60_2d3a10;
- if (*(f32 *)(vars + 0x60) <= *(f32 *)(vars + 0x3c)) {
- *(f32 *)(vars + 0x60) = *(f32 *)(vars + 0x3c);
- if (flags & 4) {
- if (FUN_001fef20_2d3a10(*(u16 *)(vars + 0x72))) goto after_position;
- *(s32 *)(vars + 0x4c) ^= 8;
+ qcopy(v21, &t2);
+ }
+ if (*(unsigned short *)(o + 0x72) != 0) {
+ if (FUN_001f9770(o + 0x7A)) {
+ *(short *)(o + 0x7A) = scale_game_frames(*(unsigned short *)(o + 0x72));
+ if (*(int *)(o + 0x4C) & 4) {
+ c0 = 1;
+ *(float *)(o + 0x60) = *(float *)(o + 0x3C);
+ *(int *)(o + 0x4C) &= 0xFFFFFFF7;
+ }
+ }
+ }
+ if (!(*(int *)(o + 0x4C) & 0x80000)) {
+ s64 q = *(s64 *)(o + 0x48);
+ 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 *)(o + 0x60) = t;
+ if (t <= *(float *)(o + 0x3C)) {
+ *(float *)(o + 0x60) = *(float *)(o + 0x3C);
+ if (*(int *)(o + 0x4C) & 0x4) {
+ if (scale_game_frames(*(unsigned short *)(o + 0x72)) == 0) *(int *)(o + 0x4C) ^= 0x8;
}
}
} else {
- *(f32 *)(vars + 0x60) = *(f32 *)(vars + 0x60) + *(f32 *)(vars + 0x40) * D_0015ED60_2d3a10;
- if (*(f32 *)(vars + 0x38) <= *(f32 *)(vars + 0x60)) {
- *(f32 *)(vars + 0x60) = *(f32 *)(vars + 0x38);
- if (!(flags & 1)) *(s32 *)(vars + 0x4c) ^= 8;
- else { vars[0x7f] = FUN_001fef20_2d3a10(vars[0x6b]); *(s32 *)(vars + 0x4c) = (*(s32 *)(vars + 0x4c) | 2) ^ 8; }
+ float t = *(float *)(o + 0x60) + *(float *)(o + 0x40) * D_0015ED60;
+ *(float *)(o + 0x60) = t;
+ if (*(float *)(o + 0x38) <= t) {
+ *(float *)(o + 0x60) = *(float *)(o + 0x38);
+ if (!(*(int *)(o + 0x4C) & 0x1)) {
+ *(int *)(o + 0x4C) ^= 0x8;
+ } else {
+ *(unsigned char *)(o + 0x7F) = scale_game_frames(*(unsigned char *)(o + 0x6B));
+ *(int *)(o + 0x4C) = (*(int *)(o + 0x4C) | 0x2) ^ 0x8;
+ }
}
}
- } else if (vars[0x6b] && FUN_001fefc8_2d3a10(vars + 0x7f)) *(s32 *)(vars + 0x4c) ^= 2;
- }
- } else if (!*(u16 *)(vars + 0x72) || changed == 1)
- *(f32 *)(vars + 0x60) = FUN_00257be8_2d3a10(*(f32 *)(vars + 0x3c), *(f32 *)(vars + 0x38));
-after_position:
- if (*(u16 *)(vars + 0x6c) && FUN_001fef98_2d3a10(vars + 0x74)) {
- *(u16 *)(vars + 0x74) = FUN_001fef20_2d3a10(*(u16 *)(vars + 0x6c));
- *(s32 *)(vars + 0x4c) &= (u32)~0x80U;
- *(f32 *)(vars + 0x54) = (f32)vars[0x27];
- }
- flags = *(s32 *)(vars + 0x4c);
- if (!(*(s32 *)(vars + 0x4c) & 0x10000)) {
- if ((*(u64 *)(vars + 0x48) & 0x3000000000ULL) == 0x2000000000ULL) *(s32 *)(vars + 0x4c) ^= 0x20;
- {
- s32 flags = *(s32 *)(vars + 0x4c);
- if (!(flags & 0x20)) {
- if (*(s32 *)(vars + 0x4c) & 0x80) {
- limit = FUN_00200240_2d3a10(vars[0x27]) / 100.0f;
- *(f32 *)(vars + 0x54) = *(f32 *)(vars + 0x54) - (FUN_00200240_2d3a10(vars[0x29]) / 100.0f) * D_0015ED60_2d3a10;
- if (*(f32 *)(vars + 0x54) <= limit) {
- *(f32 *)(vars + 0x54) = limit;
- if (*(s32 *)(vars + 0x4c) & 0x40) {
- if (*(u16 *)(vars + 0x6c)) goto after_red;
- *(s32 *)(vars + 0x4c) ^= 0x80;
+ } else {
+ if (*(unsigned char *)(o + 0x6B) != 0 && FUN_L00_001fefc8(o + 0x7F)) *(int *)(o + 0x4C) ^= 0x2;
+ }
+ } else {
+ if (*(unsigned short *)(o + 0x72) == 0 || c0 == 1) {
+ *(float *)(o + 0x60) = random_float_between_c(*(float *)(o + 0x3C), *(float *)(o + 0x38));
+ }
+ }
+ if (*(unsigned short *)(o + 0x6C) != 0) {
+ if (FUN_001f9770(o + 0x74)) {
+ *(short *)(o + 0x74) = scale_game_frames(*(unsigned short *)(o + 0x6C));
+ *(int *)(o + 0x4C) &= 0xFFFFFF7F;
+ *(float *)(o + 0x54) = (float)*(unsigned char *)(o + 0x27);
+ }
+ }
+ if (!(*(int *)(o + 0x4C) & 0x10000)) {
+ s64 q = *(s64 *)(o + 0x48);
+ if ((q & (0xC000L << 22)) == (0x8000L << 22)) *(int *)(o + 0x4C) ^= 0x20;
+ if (!(*(int *)(o + 0x4C) & 0x20)) {
+ 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 *)(o + 0x54) = t;
+ if (t <= a) {
+ *(float *)(o + 0x54) = a;
+ if (*(int *)(o + 0x4C) & 0x40) {
+ if (*(unsigned short *)(o + 0x6C) == 0) *(int *)(o + 0x4C) ^= 0x80;
}
}
} else {
- limit = FUN_00200240_2d3a10(vars[0x26]) / 100.0f;
- *(f32 *)(vars + 0x54) = *(f32 *)(vars + 0x54) + (FUN_00200240_2d3a10(vars[0x28]) / 100.0f) * D_0015ED60_2d3a10;
- if (limit <= *(f32 *)(vars + 0x54)) {
- *(f32 *)(vars + 0x54) = limit;
- if (!(*(s32 *)(vars + 0x4c) & 0x10)) *(s32 *)(vars + 0x4c) ^= 0x80;
- else { vars[0x7c] = FUN_001fef20_2d3a10(vars[0x68]); *(s32 *)(vars + 0x4c) = (*(s32 *)(vars + 0x4c) | 0x20) ^ 0x80; }
+ 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 *)(o + 0x54) = t;
+ if (a <= t) {
+ *(float *)(o + 0x54) = a;
+ if (!(*(int *)(o + 0x4C) & 0x10)) {
+ *(int *)(o + 0x4C) ^= 0x80;
+ } else {
+ *(unsigned char *)(o + 0x7C) = scale_game_frames(o[0x68]);
+ *(int *)(o + 0x4C) = (*(int *)(o + 0x4C) | 0x20) ^ 0x80;
+ }
}
}
- } else if (vars[0x68] && FUN_001fefc8_2d3a10(vars + 0x7c)) *(s32 *)(vars + 0x4c) ^= 0x20;
- }
- } else if (!*(u16 *)(vars + 0x6c)) {
- step = 100.0f;
- value = (f32)(s16)FUN_00200250_2d3a10((f32)vars[0x27]) / step;
- limit = (f32)FUN_00200250_2d3a10((f32)vars[0x26]) / step;
- *(f32 *)(vars + 0x54) = FUN_00257be8_2d3a10(value, limit);
- }
-after_red:
- if (*(u16 *)(vars + 0x6e) && FUN_001fef98_2d3a10(vars + 0x76)) {
- *(u16 *)(vars + 0x76) = FUN_001fef20_2d3a10(*(u16 *)(vars + 0x6e));
- *(s32 *)(vars + 0x4c) &= (u32)~0x800U;
- *(f32 *)(vars + 0x58) = (f32)vars[0x2c];
- }
- flags = *(s32 *)(vars + 0x4c);
- if (!(*(s32 *)(vars + 0x4c) & 0x20000)) {
- if ((*(u64 *)(vars + 0x48) & 0x30000000000ULL) == 0x20000000000ULL) *(s32 *)(vars + 0x4c) ^= 0x200;
- {
- s32 flags = *(s32 *)(vars + 0x4c);
- if (!(flags & 0x200)) {
- if (*(s32 *)(vars + 0x4c) & 0x800) {
- limit = FUN_00200240_2d3a10(vars[0x2c]) / 100.0f;
- *(f32 *)(vars + 0x58) = *(f32 *)(vars + 0x58) - (FUN_00200240_2d3a10(vars[0x2e]) / 100.0f) * D_0015ED60_2d3a10;
- if (*(f32 *)(vars + 0x58) <= limit) {
- *(f32 *)(vars + 0x58) = limit;
- if (*(s32 *)(vars + 0x4c) & 0x400) {
- if (*(u16 *)(vars + 0x6e)) goto after_green;
- *(s32 *)(vars + 0x4c) ^= 0x800;
+ } else {
+ if (o[0x68] != 0 && FUN_L00_001fefc8(o + 0x7C)) *(int *)(o + 0x4C) ^= 0x20;
+ }
+ } else {
+ if (*(unsigned short *)(o + 0x6C) == 0 || c1 == 1) {
+ float a = (float)func_001FA898_r((float)o[0x27]) / 100.0f;
+ float b = (float)func_001FA898_r((float)o[0x26]) / 100.0f;
+ *(float *)(o + 0x54) = random_float_between_c(a, b);
+ }
+ }
+ if (*(unsigned short *)(o + 0x6E) != 0) {
+ if (FUN_001f9770(o + 0x76)) {
+ *(short *)(o + 0x76) = scale_game_frames(*(unsigned short *)(o + 0x6E));
+ *(int *)(o + 0x4C) &= 0xFFFFF7FF;
+ *(float *)(o + 0x58) = (float)o[0x2C];
+ }
+ }
+ if (!(*(int *)(o + 0x4C) & 0x20000)) {
+ s64 q = *(s64 *)(o + 0x48);
+ if ((q & (0xC000L << 26)) == (0x8000L << 26)) *(int *)(o + 0x4C) ^= 0x200;
+ if (!(*(int *)(o + 0x4C) & 0x200)) {
+ 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 *)(o + 0x58) = t;
+ if (t <= a) {
+ *(float *)(o + 0x58) = a;
+ if (*(int *)(o + 0x4C) & 0x400) {
+ if (*(unsigned short *)(o + 0x6E) == 0) *(int *)(o + 0x4C) ^= 0x800;
}
}
} else {
- limit = FUN_00200240_2d3a10(vars[0x2b]) / 100.0f;
- *(f32 *)(vars + 0x58) = *(f32 *)(vars + 0x58) + (FUN_00200240_2d3a10(vars[0x2d]) / 100.0f) * D_0015ED60_2d3a10;
- if (limit <= *(f32 *)(vars + 0x58)) {
- *(f32 *)(vars + 0x58) = limit;
- if (!(*(s32 *)(vars + 0x4c) & 0x100)) *(s32 *)(vars + 0x4c) ^= 0x800;
- else { vars[0x7d] = FUN_001fef20_2d3a10(vars[0x69]); *(s32 *)(vars + 0x4c) = (*(s32 *)(vars + 0x4c) | 0x200) ^ 0x800; }
+ 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 *)(o + 0x58) = t;
+ if (a <= t) {
+ *(float *)(o + 0x58) = a;
+ if (!(*(int *)(o + 0x4C) & 0x100)) {
+ *(int *)(o + 0x4C) ^= 0x800;
+ } else {
+ *(unsigned char *)(o + 0x7D) = scale_game_frames(o[0x69]);
+ *(int *)(o + 0x4C) = (*(int *)(o + 0x4C) | 0x200) ^ 0x800;
+ }
}
}
- } else if (vars[0x69] && FUN_001fefc8_2d3a10(vars + 0x7d)) *(s32 *)(vars + 0x4c) ^= 0x200;
- }
- } else if (!*(u16 *)(vars + 0x6e)) {
- step = 100.0f;
- value = (f32)(s16)FUN_00200250_2d3a10((f32)vars[0x2c]) / step;
- limit = (f32)FUN_00200250_2d3a10((f32)vars[0x2b]) / step;
- *(f32 *)(vars + 0x58) = FUN_00257be8_2d3a10(value, limit);
- }
-after_green:
- if (*(u16 *)(vars + 0x70) && FUN_001fef98_2d3a10(vars + 0x78)) {
- *(u16 *)(vars + 0x78) = FUN_001fef20_2d3a10(*(u16 *)(vars + 0x70));
- *(s32 *)(vars + 0x4c) &= (u32)~0x8000U;
- *(f32 *)(vars + 0x5c) = (f32)vars[0x31];
- }
- flags = *(s32 *)(vars + 0x4c);
- if (!(*(s32 *)(vars + 0x4c) & 0x40000)) {
- if ((*(u64 *)(vars + 0x48) & 0x300000000000ULL) == 0x200000000000ULL) *(s32 *)(vars + 0x4c) ^= 0x2000;
- {
- s32 flags = *(s32 *)(vars + 0x4c);
- if (!(flags & 0x2000)) {
- if (*(s32 *)(vars + 0x4c) & 0x8000) {
- limit = FUN_00200240_2d3a10(vars[0x31]) / 100.0f;
- *(f32 *)(vars + 0x5c) = *(f32 *)(vars + 0x5c) - (FUN_00200240_2d3a10(vars[0x33]) / 100.0f) * D_0015ED60_2d3a10;
- if (*(f32 *)(vars + 0x5c) <= limit) {
- *(f32 *)(vars + 0x5c) = limit;
- if (*(s32 *)(vars + 0x4c) & 0x4000) {
- if (*(u16 *)(vars + 0x70)) goto after_blue;
- *(s32 *)(vars + 0x4c) ^= 0x8000;
+ } else {
+ if (o[0x69] != 0 && FUN_L00_001fefc8(o + 0x7D)) *(int *)(o + 0x4C) ^= 0x200;
+ }
+ } else {
+ if (*(unsigned short *)(o + 0x6E) == 0 || c2 == 1) {
+ float a = (float)func_001FA898_r((float)o[0x2C]) / 100.0f;
+ float b = (float)func_001FA898_r((float)o[0x2B]) / 100.0f;
+ *(float *)(o + 0x58) = random_float_between_c(a, b);
+ }
+ }
+ if (*(unsigned short *)(o + 0x70) != 0) {
+ if (FUN_001f9770(o + 0x78)) {
+ *(short *)(o + 0x78) = scale_game_frames(*(unsigned short *)(o + 0x70));
+ *(int *)(o + 0x4C) &= 0xFFFF7FFF;
+ *(float *)(o + 0x5C) = (float)o[0x31];
+ }
+ }
+ if (!(*(int *)(o + 0x4C) & 0x40000)) {
+ s64 q = *(s64 *)(o + 0x48);
+ if ((q & (0xC000L << 30)) == (0x8000L << 30)) *(int *)(o + 0x4C) ^= 0x2000;
+ if (!(*(int *)(o + 0x4C) & 0x2000)) {
+ 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 *)(o + 0x5C) = t;
+ if (t <= a) {
+ *(float *)(o + 0x5C) = a;
+ if (*(int *)(o + 0x4C) & 0x4000) {
+ if (*(unsigned short *)(o + 0x70) == 0) *(int *)(o + 0x4C) ^= 0x8000;
}
}
} else {
- limit = FUN_00200240_2d3a10(vars[0x30]) / 100.0f;
- *(f32 *)(vars + 0x5c) = *(f32 *)(vars + 0x5c) + (FUN_00200240_2d3a10(vars[0x32]) / 100.0f) * D_0015ED60_2d3a10;
- if (limit <= *(f32 *)(vars + 0x5c)) {
- *(f32 *)(vars + 0x5c) = limit;
- if (!(*(s32 *)(vars + 0x4c) & 0x1000)) *(s32 *)(vars + 0x4c) ^= 0x8000;
- else { vars[0x7e] = FUN_001fef20_2d3a10(vars[0x6a]); *(s32 *)(vars + 0x4c) = (*(s32 *)(vars + 0x4c) | 0x2000) ^ 0x8000; }
+ 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 *)(o + 0x5C) = t;
+ if (a <= t) {
+ *(float *)(o + 0x5C) = a;
+ if (!(*(int *)(o + 0x4C) & 0x1000)) {
+ *(int *)(o + 0x4C) ^= 0x8000;
+ } else {
+ *(unsigned char *)(o + 0x7E) = scale_game_frames(o[0x6A]);
+ *(int *)(o + 0x4C) = (*(int *)(o + 0x4C) | 0x2000) ^ 0x8000;
+ }
}
}
- } else if (vars[0x6a] && FUN_001fefc8_2d3a10(vars + 0x7e)) *(s32 *)(vars + 0x4c) ^= 0x2000;
- }
- } else if (!*(u16 *)(vars + 0x70)) {
- step = 100.0f;
- value = (f32)(s16)FUN_00200250_2d3a10((f32)vars[0x31]) / step;
- limit = (f32)FUN_00200250_2d3a10((f32)vars[0x30]) / step;
- *(f32 *)(vars + 0x5c) = FUN_00257be8_2d3a10(value, limit);
- }
-after_blue:
- i = *(s32 *)(vars + 0x50);
- if (i == -1) {
- active = FUN_0023e738_2d3a10(*(f32 *)(vars + 0x60), FUN_00200240_2d3a10(vars[0x24]) / 100.0f,
- *(f32 *)(vars + 0x54), *(f32 *)(vars + 0x58), *(f32 *)(vars + 0x5c), moby_position);
- *(s32 *)(vars + 0x50) = active;
+ } else {
+ if (o[0x6A] != 0 && FUN_L00_001fefc8(o + 0x7E)) *(int *)(o + 0x4C) ^= 0x2000;
+ }
+ } else {
+ if (*(unsigned short *)(o + 0x70) == 0 || c3 == 1) {
+ float a = (float)func_001FA898_r((float)o[0x31]) / 100.0f;
+ float b = (float)func_001FA898_r((float)o[0x30]) / 100.0f;
+ *(float *)(o + 0x5C) = random_float_between_c(a, b);
+ }
+ }
+ r = *(int *)(o + 0x50);
+ if (r == -1) {
+ float kk = convert_integer_to_float_c(o[0x24]) / 100.0f;
+ *(int *)(o + 0x50) = FUN_L00_0023e738((float *)v21, *(float *)(o + 0x60), kk, *(float *)(o + 0x54), *(float *)(o + 0x58), *(float *)(o + 0x5C));
+ } else {
+ unsigned char *e = D_L00_001802C0 + (r << 5);
+ qcopy(e + 0x10, v21);
+ *(float *)(e + 0x1C) = *(float *)(o + 0x60);
+ *(float *)(e + 0x0) = *(float *)(o + 0x54);
+ *(float *)(e + 0x4) = *(float *)(o + 0x58);
+ *(float *)(e + 0x8) = *(float *)(o + 0x5C);
+ *(float *)(e + 0xC) = convert_integer_to_float_c(o[0x24]) / 100.0f;
+ }
} else {
- u8 *row = D_L00_001802C0_2d3a10 + i * 0x20;
- qcopy(row + 0x10, moby_position);
- *(f32 *)(row + 0x1c) = *(f32 *)(vars + 0x60);
- *(f32 *)(row + 0x0) = *(f32 *)(vars + 0x54);
- *(f32 *)(row + 0x4) = *(f32 *)(vars + 0x58);
- *(f32 *)(row + 0x8) = *(f32 *)(vars + 0x5c);
- *(f32 *)(row + 0xc) = FUN_00200240_2d3a10(vars[0x24]) / 100.0f;
+ if (*(int *)(o + 0x50) != -1) {
+ FUN_L00_0023e838(*(int *)(o + 0x50));
+ *(int *)(o + 0x50) = r;
+ }
}
}
-#endif
typedef struct Moby Moby;
extern void FUN_00212f90_2d4610(void *, int, int, int) __asm__("FUN_00212f90");
extern int scale_game_frames(int) __asm__("FUN_001f96f8");
@@ -2338,7 +2433,7 @@ INCLUDE_ASM("config/us/overlays/asm/FUN_L00_002d5160.s", FUN_L00_002d5160);
#else
extern s32 D_L00_0015F5C4_2d5160 __asm__("D_L00_0015F5C4");
extern f32 D_0015ED6C_2d5160 __asm__("D_0015ED6C");
-extern f32 D_0015ED70_2d5160 __asm__("D_0015ED70");
+extern float D_0015ED70;
extern f32 D_L00_00161970_2d5160 __asm__("D_L00_00161970") __attribute__((sda));
extern f32 D_L00_00161974_2d5160 __asm__("D_L00_00161974") __attribute__((sda));
extern f32 D_L00_00161978_2d5160 __asm__("D_L00_00161978") __attribute__((sda));
@@ -2389,8 +2484,8 @@ void FUN_L00_002d5160(unsigned char *m) {
hit = FUN_L00_0025a420_2d5160(m, 0x330000, 0);
FUN_L00_0025a478_2d5160(m, hit, v + 0x20, 0, &result, &damage, 0, 4);
if (result != 1 && m[0x20] != 12 && damage != 0.0f) {
- forceX = D_L00_00161970_2d5160 * D_0015ED70_2d5160;
- forceY = D_L00_00161974_2d5160 * D_0015ED70_2d5160;
+ forceX = D_L00_00161970_2d5160 * D_0015ED70;
+ forceY = D_L00_00161974_2d5160 * D_0015ED70;
forceZ = D_L00_00161978_2d5160 * D_0015ED6C_2d5160;
forceW = D_L00_0016197C_2d5160 * D_0015ED6C_2d5160;
health = *(f32 *)(v + 0x20) - damage;
@@ -2630,16 +2725,16 @@ void FUN_L00_002d5988(Obj_2d5988 *o, Path_2d5988 *path, s32 p) {
s = D_0015ED70_2d5988 * 16.0f;
c = st->v60;
if (l <= (c * c) / (s + s)) {
- f32 a1 = c - s;
+ f32 low = c - s;
f32 b1 = D_L00_00161990 * D_0015ED6C_2d5988;
- st->v60 = a1;
- if (a1 < b1)
+ st->v60 = low;
+ if (low < b1)
st->v60 = b1;
} else {
- f32 a2 = c + s;
+ f32 high = c + s;
f32 b2 = D_0015ED6C_2d5988 * 16.0f;
- st->v60 = a2;
- if (b2 < a2)
+ st->v60 = high;
+ if (b2 < high)
st->v60 = b2;
}
idx = truncate_float_to_s32(w_ / path->a[0].f[3]);
@@ -3098,7 +3193,7 @@ typedef struct {
int c[4];
float d[4];
} P_2d6cd0;
-extern char D_166DC0_2d6cd0[] __asm__("D_L00_00166DC0") __attribute__((section(".data")));
+extern char camera_position[] __asm__("D_L00_00166DC0") __attribute__((section(".data")));
extern int D_15F5C4_2d6cd0 __asm__("D_L00_0015F5C4");
extern void ff500_2d6cd0(void *, void *, float) __asm__("FUN_001f9bf8");
extern int fast_dec_timer(void *) __asm__("FUN_001f9740");
@@ -3125,7 +3220,7 @@ void FUN_L00_002d6cd0(char *o) {
}
v.q = *(OvlQuad *)(o + 0x10);
v.f[2] += 0.333000004f;
- subtract_vector_xyz(d, D_166DC0_2d6cd0, o + 0x10);
+ subtract_vector_xyz(d, camera_position, o + 0x10);
ff500_2d6cd0(d, d, -0.3f);
ff500_2d6cd0(e, d, 0.1f);
add_vector_xyz(d, d, o + 0x10);
@@ -3160,7 +3255,7 @@ typedef struct {
s16 count; /* 02 */
int idx; /* 04 */
char pad08[0x18];
- float f20, f24, f28; /* 20 24 28 */
+ float unk20, unk24, unk28; /* 20 24 28 */
s16 h2C, h2E; /* 2C 2E */
int x30, x34; /* 30 34 */
int col; /* 38 */
@@ -3226,7 +3321,7 @@ int FUN_L00_002a4dc8(int);
int FUN_00213260_c(int) __asm__("FUN_00213260");
void FUN_L00_002d7bf0(P *, int);
void FUN_L00_002d7d58_c(P *, int) __asm__("FUN_L00_002d7d58");
-int fast_bsphere_check(V *, float) __asm__("FUN_001fa728");
+extern int fast_bsphere_check(void *, float) __asm__("FUN_001fa728");
float FUN_001f9b80(void *, void *);
float FUN_L00_00257c48(float, float);
void FUN_001f9d20(V *, V *, void *);
@@ -3300,8 +3395,8 @@ void FUN_L00_002d6f28(P *p) {
b.z += 0.5f;
a.x = FUN_L00_00257c48(0.0f, frame_time * 0.25f);
a.y = FUN_L00_00257c48(0.0f, frame_time * 0.25f);
- a.z = q->f20 * frame_time;
- f = random_float_between(q->f24, q->f28);
+ a.z = q->unk20 * frame_time;
+ f = random_float_between(q->unk24, q->unk28);
col = FUN_L00_00257b90(q->h2C, q->h2E) << 24 | D_L00_001619C8;
r = FUN_L00_00257b90(D_L00_001619C0, D_L00_001619C4);
ent = FUN_L00_0026d000(&b, r, D_L00_001619B4, 1.0f, &a, D_L00_001619B8, col, f);
@@ -3351,8 +3446,8 @@ 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_2d73e8 __asm__("D_0015ED60");
-extern V D_L00_00166DC0_2d73e8 __asm__("D_L00_00166DC0");
+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");
void FUN_001ff500_2d73e8(float, void *, void *) __asm__("FUN_001f9bf8");
@@ -3392,7 +3487,7 @@ void FUN_L00_002d73e8(P *p) {
position.w = 1.0f;
*(u128 *)&zero_vector = 0;
zero_vector.z = 1.0f;
- FUN_001ff2a8_2d73e8(&positive_transform[0], &D_L00_00166DC0_2d73e8, &position);
+ FUN_001ff2a8_2d73e8(&positive_transform[0], &(*(V *)camera_position), &position);
FUN_001ff500_2d73e8(1.0f, &positive_transform[0], &positive_transform[0]);
FUN_001ff3c0_2d73e8(&positive_transform[1], &positive_transform[0], &zero_vector);
FUN_001ff500_2d73e8(1.0f, &positive_transform[1], &positive_transform[1]);
@@ -3413,7 +3508,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_2d73e8 * speed;
+ f -= D_0015ED60 * 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 924a19941d..423eee33eb 100644
--- a/src/overlays/shared/gameplay/entities/walloper.c
+++ b/src/overlays/shared/gameplay/entities/walloper.c
@@ -19,7 +19,7 @@ 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[];
extern char *D_L00_00173E58;
-extern Vec4 collision_position_2b94d0 __asm__("D_L00_00173E60");
+extern Vec4 collision_hit_point __asm__("D_L00_00173E60");
extern float D_L00_00161594 __attribute__((sda));
extern float D_L00_00161598 __attribute__((sda));
extern float D_L00_0016159C __attribute__((sda));
@@ -284,9 +284,9 @@ next_candidate:;
}
}
if (hit_result) {
- qcopy(point, &collision_position_2b94d0);
+ qcopy(point, &collision_hit_point);
*(short *)(v + 0x3e) = i;
- qcopy(v + 0x10, &collision_position_2b94d0);
+ qcopy(v + 0x10, &collision_hit_point);
if (!D_L00_00173E58 || FUN_L00_00259830(D_L00_00173E58)) {
*(char **)(v + 0x20) = 0; *(short *)(v + 0x40) = 0;
}
@@ -592,8 +592,8 @@ typedef struct {
long unk70, tex, unk80, unk88;
} Q_2bb0b0;
extern unsigned int D_L00_001615F8_2bb0b0 __asm__("D_L00_001615F8") __attribute__((sda));
-extern V_2bb0b0 D_L00_00166DC0_2bb0b0 __asm__("D_L00_00166DC0") __attribute__((section(".data")));
-extern V_2bb0b0 D_0013F5E0_2bb0b0 __asm__("D_0013F5E0");
+extern float g_debug_camera[] __asm__("D_L00_00166DC0") __attribute__((section(".data")));
+extern char D_0013F5E0[];
void vsub_2bb0b0(void *, void *, void *) __asm__("FUN_001f9a28");
void vadd_2bb0b0(void *, void *, void *) __asm__("FUN_001f9a10");
void fast_vec_normalize(void *, void *, float) __asm__("FUN_001f9bf8");
@@ -619,13 +619,13 @@ void FUN_L00_002bb0b0(void *mv) {
quad.unk88 = 0x8000000048L;
quad.unk80 = 0xFF9000000260L;
quad.unk70 = 0;
- vsub_2bb0b0(&mat[3], &D_L00_00166DC0_2bb0b0, pos);
+ vsub_2bb0b0(&mat[3], &(*(V_2bb0b0 *)g_debug_camera), pos);
fast_vec_normalize(&mat[3], &mat[3], 0.3f);
vadd_2bb0b0(&mat[3], &mat[3], pos);
mat[3].f[3] = 1.0f;
- vsub_2bb0b0(&mat[0], &D_L00_00166DC0_2bb0b0, &mat[3]);
+ vsub_2bb0b0(&mat[0], &(*(V_2bb0b0 *)g_debug_camera), &mat[3]);
fast_vec_normalize(&mat[0], &mat[0], 1.0f);
- cross_2bb0b0(&mat[1], &mat[0], &D_0013F5E0_2bb0b0);
+ cross_2bb0b0(&mat[1], &mat[0], &(*(V_2bb0b0 *)D_0013F5E0));
fast_vec_normalize(&mat[1], &mat[1], -1.0f);
cross_2bb0b0(&mat[2], &mat[1], &mat[0]);
c = D_L00_00161640;
@@ -1135,8 +1135,8 @@ typedef struct {
float unk68, unk6C;
long unk70, tex, unk80, unk88;
} Q_2bc1a0;
-extern V_2bc1a0 D_L00_00166DC0_2bc1a0 __asm__("D_L00_00166DC0") __attribute__((section(".data")));
-extern V_2bc1a0 D_0013F5E0_2bc1a0 __asm__("D_0013F5E0");
+extern float g_debug_camera[] __asm__("D_L00_00166DC0") __attribute__((section(".data")));
+extern char D_0013F5E0[];
void FUN_001f9a68_2bc1a0(float, void *, void *) __asm__("FUN_001f9a68");
void FUN_001f9a10_2bc1a0(void *, void *, void *) __asm__("FUN_001f9a10");
void FUN_001f9a28_2bc1a0(void *, void *, void *) __asm__("FUN_001f9a28");
@@ -1187,9 +1187,9 @@ void FUN_L00_002bc1a0(void *mv) {
quad.color[2] = c;
quad.color[1] = c;
quad.color[0] = c;
- FUN_001f9a28_2bc1a0(&e, &D_L00_00166DC0_2bc1a0, &mat[3]);
+ FUN_001f9a28_2bc1a0(&e, &(*(V_2bc1a0 *)g_debug_camera), &mat[3]);
FUN_001f9bf8_2bc1a0(&mat[0], &e, 1.0f);
- FUN_001f9ad8_2bc1a0(&mat[1], &mat[0], &D_0013F5E0_2bc1a0);
+ FUN_001f9ad8_2bc1a0(&mat[1], &mat[0], &(*(V_2bc1a0 *)D_0013F5E0));
FUN_001f9bf8_2bc1a0(&mat[1], &mat[1], -1.0f);
FUN_001f9ad8_2bc1a0(&mat[2], &mat[1], &mat[0]);
FUN_001f9a68_2bc1a0(0.2f, &e, &mat[0]);
@@ -1200,32 +1200,30 @@ void FUN_L00_002bc1a0(void *mv) {
}
FUN_001f7d30_2bc1a0(&quad, 0, 0);
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L00_002bc3b0.s", FUN_L00_002bc3b0);
-#else
+#include "rnc/math/vector.h"
+#include "rnc/gameplay/entities/moby.h"
+
+/* Ported from rac1-decomp (src/overlays/shared/vendor_002BA7C8.c: func_L00_002BD6B8), where it is exact; names translated to the US level program. */
+
+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_0013F3D0[];
-extern float D_0013F634;
-extern float D_L00_001616D8 __attribute__((sda));
-extern float D_L00_001616DC_gp __asm__("D_L00_001616DC") __attribute__((sda));
-extern u128 D_L00_00173E60_2bc3b0 __asm__("D_L00_00173E60") __attribute__((section(".data")));
-extern char *D_L00_00173E58;
-extern struct {
- char pad[0x18];
- char *moby;
-} D_L00_00173E40_2bc3b0 __asm__("D_L00_00173E40") __attribute__((section(".data")));
-extern float D_L00_00161660_f[];
-extern float fast_arc_tan(float, float) __asm__("FUN_001f9e90");
-extern float vector_distance_xy(void *, void *) __asm__("FUN_001f9b80");
-extern float fast_vec_dist(void *, void *) __asm__("FUN_001f9b48");
-extern float FUN_001fa688(float, float);
-extern float FUN_001f99c0(float);
-extern float fast_arc_sin(float) __asm__("FUN_001f9df8");
-extern float FUN_001fa6c0(int);
-extern void FUN_001f9a10(void *, void *, void *);
-extern int FUN_002141f8();
-extern void build_spherical_offset(void *, float, float, float) __asm__("FUN_00214db0");
-extern int FUN_001efa68_2bc3b0(void *, void *, int, void *, int) __asm__("FUN_001efa68");
+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");
+extern float fast_difference_between_rotations_c(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_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 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");
char *FUN_L00_002bc3b0(char *self, float *position, float *heading, float *pitch) {
float start[4] __attribute__((aligned(16)));
@@ -1236,47 +1234,55 @@ char *FUN_L00_002bc3b0(char *self, float *position, float *heading, float *pitch
char *data;
char *moby;
int collision;
- char *best;
+ int a0s[1];
+ int res[1];
float distance, angle, elevation, headingError, limit, apparentAngle, radius, reduction;
- char **i;
-
- limit = D_L00_001616DC_gp;
- *(u128 *)start = *(u128 *)position;
- *(u128 *)end = *(u128 *)((char *)hero.moby + 0x10);
+ int i;
+ char *g;
+ char *m0;
+
+ limit = D_L00_001616DC;
+ a0s[0] = (int)self;
+ *(VecQuad *)start = *(VecQuad *)position;
+ g = D_0013F350;
+ m0 = *(char **)(g + 0x2080);
+ *(VecQuad *)end = *(VecQuad *)(m0 + 0x10);
position = start;
end[2] = position[2];
- collision = FUN_001efa68_2bc3b0(end, position, 6, hero.moby, 0);
- best = 0;
+ collision = collision_line((Vec4f *)end, (Vec4f *)position, 6, m0, 0);
+ res[0] = 0;
if (collision) {
- qcopy(position, &D_L00_00173E60_2bc3b0);
+ qcopy(position, &collision_hit_point);
return 0;
}
- for (i = active_mobies; (candidate = *i) != 0; i++) {
- if (*(s8 *)(candidate + 0x20) < 0 || *(s16 *)(candidate + 0xA6) == 0x58E ||
- *(s16 *)(candidate + 0xA6) == 0x452)
+ i = 0;
+ if ((candidate = active_mobies[i]) != 0) do {
+ if (*(signed char *)(candidate + 0x20) < 0 || *(short *)(candidate + 0xA6) == 0x58E ||
+ *(short *)(candidate + 0xA6) == 0x452)
continue;
qcopy(target, candidate + 0x10);
- data = (char *)FUN_002141f8(candidate);
+ data = (char *)fun_002141f8(candidate);
if (!data)
continue;
target[2] += *(float *)(data + 0x10);
if (!candidate || !*(char **)(candidate + 0x24) ||
- *(s16 *)(*(char **)(candidate + 0x24) + 0x46) != 5)
+ *(short *)(*(char **)(candidate + 0x24) + 0x46) != 5)
continue;
- angle = fast_arc_tan(target[0] - position[0], target[1] - position[1]);
- distance = vector_distance_xy(position, target);
- elevation = fast_arc_tan(distance, target[2] - position[2]);
- headingError = FUN_001fa688(*heading, angle);
+ angle = fast_arc_tan_c(target[0] - position[0], target[1] - position[1]);
+ distance = vector_distance_xy_alt(position, target);
+ elevation = fast_arc_tan_c(distance, target[2] - position[2]);
+ headingError = fast_difference_between_rotations_c(*heading, angle);
distance = fast_vec_dist(position, target);
if (distance < 2.5f) {
float toward;
- moby = (char *)hero.moby;
- toward = fast_arc_tan(*(float *)(candidate + 0x10) - hero.motion.pos.f[0],
- *(float *)(candidate + 0x14) - hero.motion.pos.f[1]);
- if (FUN_001fa688(*(float *)(moby + 0x48), toward) < 1.0471976f &&
- FUN_001f99c0(position[2] - target[2]) < 2.0f &&
- !FUN_001efa68_2bc3b0(position, target, 6, hero.moby, 0)) {
- best = candidate;
+ char *g1 = D_0013F350;
+ moby = *(char **)(g1 + 0x2080);
+ toward = fast_arc_tan_c(*(float *)(candidate + 0x10) - *(float *)(g1 + 0x80),
+ *(float *)(candidate + 0x14) - *(float *)(g1 + 0x84));
+ if (fast_difference_between_rotations_c(*(float *)(moby + 0x48), toward) < 1.0471976f &&
+ absolute_float(position[2] - target[2]) < 2.0f &&
+ !collision_line((Vec4f *)position, (Vec4f *)target, 6, *(char **)(g1 + 0x2080), 0)) {
+ res[0] = (int)candidate;
*pitch = -elevation;
*heading = angle;
goto done;
@@ -1284,14 +1290,17 @@ char *FUN_L00_002bc3b0(char *self, float *position, float *heading, float *pitch
}
if (distance > limit)
continue;
- build_spherical_offset(offset, distance, *heading, *pitch + hero.ground_pitch.f * 0.5f);
- FUN_001f9a10(offset, offset, position);
+ {
+ char *g2 = D_0013F350;
+ build_spherical_offset(offset, distance, *heading, *pitch + *(float *)(g2 + 0x2E4) * 0.5f);
+ }
+ add_vector_xyz_c4(offset, offset, position);
apparentAngle = fast_arc_sin(fast_vec_dist(offset, target) / (distance + distance));
apparentAngle += apparentAngle;
- if (D_L00_001616D8 * 0.017453292f < apparentAngle) {
- data = (char *)FUN_002141f8(candidate);
+ if (*(float *)&D_L00_001616D8 * 0.017453292f < apparentAngle) {
+ data = (char *)fun_002141f8(candidate);
if (data) {
- radius = FUN_001fa6c0(*(u8 *)(data + 10)) * 0.125f;
+ radius = convert_integer_to_float(*(unsigned char *)(data + 10)) * 0.125f;
reduction = fast_arc_sin(radius / distance);
if (radius < distance) {
apparentAngle -= reduction;
@@ -1300,10 +1309,10 @@ char *FUN_L00_002bc3b0(char *self, float *position, float *heading, float *pitch
}
}
}
- if (apparentAngle < D_L00_001616D8 * 0.017453292f) {
+ if (apparentAngle < *(float *)&D_L00_001616D8 * 0.017453292f) {
int valid = 1;
- if (FUN_001efa68_2bc3b0(position, target, 6, self, 0)) {
- if (!D_L00_00173E40_2bc3b0.moby || D_L00_00173E40_2bc3b0.moby != candidate)
+ if (collision_line((Vec4f *)position, (Vec4f *)target, 6, self, 0)) {
+ if (!D_L00_00173E40[6] || (char *)D_L00_00173E40[6] != candidate)
valid = 0;
}
if (valid) {
@@ -1311,14 +1320,13 @@ char *FUN_L00_002bc3b0(char *self, float *position, float *heading, float *pitch
limit = distance;
if (headingError < 0.17453292f)
*heading = angle;
- best = candidate;
+ res[0] = (int)candidate;
}
}
- }
+ } while ((candidate = active_mobies[++i]) != 0);
done:
- return best;
+ return (char *)res[0];
}
-#endif
#include "rnc/math/vector.h"
#include "rnc/gameplay/entities/moby.h"
#include "rnc/overlay/hud.h"
@@ -1373,7 +1381,7 @@ typedef struct Voice_2BDAF0 {
Moby *owner;
} Voice_2BDAF0;
-char *FUN_L00_002bc3b0(char *self, float *position, float *heading, float *pitch);
+char *FUN_L00_002bc3b0_u(char *self, float *position, float *heading, float *pitch) __asm__("FUN_L00_002bc3b0");
extern unsigned char D_00141680_r[] __asm__("D_00141680");
extern f32 convert_integer_to_float(s32) __asm__("func_001FA6C0");
extern f32 vector_length_xy(void *) __asm__("FUN_001f9b20");
@@ -1417,13 +1425,13 @@ 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_0013F450_2BDAF0[] __asm__("D_0013F350");
+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");
extern char voice_pool[] __asm__("D_0013E550");
extern char D_L00_001803C0_2BDAF0[] __asm__("D_L00_001802C0");
-extern char D_L00_00166D80_2BDAF0[] __asm__("D_L00_00166C80");
+extern char D_L00_00166C80[];
extern float func_0020D830_2BDAF0(void *) __asm__("FUN_0020c9e0");
extern int func_001F9938_2BDAF0(void *) __asm__("FUN_001f9770");
extern void func_L00_0020EB60_2BDAF0(void) __asm__("FUN_L00_0020e4c8");
@@ -1471,7 +1479,7 @@ void FUN_L00_002bc7e8(Moby *moby) {
int now;
busy = 0;
- if (((Hero *)D_0013F450_2BDAF0)->items[0].state == 3) {
+ if (((Hero *)D_0013F350)->items[0].state == 3) {
busy = 1;
}
data = (struct Ray_2BDAF0 *)moby->pvars;
@@ -1486,11 +1494,11 @@ void FUN_L00_002bc7e8(Moby *moby) {
in_range = 0;
}
func_001F9938_2BDAF0(&data->timer);
- if ((((unsigned int)((Hero *)D_0013F450_2BDAF0)->state.control_mode < 2 || ((Hero *)D_0013F450_2BDAF0)->state.control_mode == 12
- || ((Hero *)D_0013F450_2BDAF0)->state.control_mode == 4 || ((Hero *)D_0013F450_2BDAF0)->state.control_mode == 5))
- && (*(int *)D_0013A5E0_2BDAF0 & ((Hero *)D_0013F450_2BDAF0)->items[0].button_mask) != 0
+ 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
&& !busy && in_range) {
- if (((Hero *)D_0013F450_2BDAF0)->unk20A8 == 0) {
+ if (((Hero *)D_0013F350)->unk20A8 == 0) {
func_L00_0020EB60_2BDAF0();
}
if (data->seen == 0) {
@@ -1508,21 +1516,21 @@ void FUN_L00_002bc7e8(Moby *moby) {
data->timer = func_001F9850_2BDAF0(15);
}
func_L00_00250800_2BDAF0(moby, 0, data);
- if (((Hero *)D_0013F450_2BDAF0)->state.current == 1) {
+ if (((Hero *)D_0013F350)->state.current == 1) {
func_L00_00222B80_2BDAF0(30, 1);
}
*(u128_2BDAF0 *)&direction = 0;
- if (((Hero *)D_0013F450_2BDAF0)->state.current == 30
- && (*(unsigned short *)((char *)((Hero *)D_0013F450_2BDAF0)->moby + 0x34) & 1)) {
- func_001FA480_2BDAF0(points, D_L00_00166D80_2BDAF0);
+ if (((Hero *)D_0013F350)->state.current == 30
+ && (*(unsigned short *)((char *)((Hero *)D_0013F350)->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_0013F450_2BDAF0)->unk22C8 == 1) {
+ } else if (((Hero *)D_0013F350)->unk22C8 == 1) {
func_001F9C30_2BDAF0(&direction, &moby->rot_row1, -1.0f);
} else {
direction.x = 1.0f;
- func_001F9EC0_2BDAF0(&direction, &direction, ((Hero *)D_0013F450_2BDAF0)->basis[0].f);
+ func_001F9EC0_2BDAF0(&direction, &direction, ((Hero *)D_0013F350)->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);
@@ -1767,8 +1775,8 @@ extern float D_L00_00161838_2BE3A8 __asm__("D_L00_00161768") __attribute__((sda)
extern signed char D_L00_00161833_2BE3A8[] __asm__("D_L00_00161763") __attribute__((section(".sdata")));
extern float D_L00_001617CC_macro __asm__("D_L00_001617CC") __attribute__((section(".sdata")));
extern int D_L00_00161824_macro __asm__("D_L00_00161824") __attribute__((section(".sdata")));
-extern float D_0015EE60_2BE3A8 __asm__("D_0015ED60") __attribute__((section(".sdata")));
-extern float D_0015EE6C_2BE3A8 __asm__("D_0015ED6C") __attribute__((section(".sdata")));
+extern float frame_scale __asm__("D_0015ED60") __attribute__((section(".sdata")));
+extern float D_0015ED6C_gp __asm__("D_0015ED6C") __attribute__((section(".sdata")));
extern int D_L00_001618A8_2BE3A8[3] __asm__("D_L00_001617D8") __attribute__((section(".sdata")));
extern float D_L00_001618B8_2BE3A8[3] __asm__("D_L00_001617E8") __attribute__((section(".sdata")));
extern float D_L00_001618C8_2BE3A8[3] __asm__("D_L00_001617F8") __attribute__((section(".sdata")));
@@ -1801,7 +1809,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_0013E633_2BE3A8[] __asm__("D_001413D0");
+extern char D_001413D0[];
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");
@@ -1871,7 +1879,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_0013E633_2BE3A8, 0) != 0) {
+ if (func_L00_001EFFF0_2BE3A8(data, &beam_end, 20, *(void **)D_001413D0, 0) != 0) {
beam_length = func_001F9D48_2BE3A8(&D_L00_00173F60_2BE3A8, data);
}
} else {
@@ -1952,7 +1960,7 @@ void FUN_L00_002bd0a0(struct Moby *moby) {
func_L00_00272F00_2BE3A8(&point, func_001F9850_2BE3A8(30), 0x7F7F7F7F, 1, sign, D_L00_0015F660_2BE3A8, spark_size * 0.07f, spark_size * 0.7f, 0.003f);
}
func_001F9BF0_2BE3A8(&dir, &D_L00_001DC260_2BE3A8[1], &D_L00_001DC260_2BE3A8[0]);
- func_L00_001FF4B0_2BE3A8(&dir, &dir, D_L00_00161804_2BE3A8 * D_0015EE60_2BE3A8);
+ func_L00_001FF4B0_2BE3A8(&dir, &dir, D_L00_00161804_2BE3A8 * frame_scale);
if (func_002140B0_2BE3A8(2) == 0) {
func_L00_001FF4B0_2BE3A8(&side, &moby->rot_row1, D_L00_00161810_2BE3A8);
func_001F9BD8_2BE3A8(&point, &D_L00_001DC260_2BE3A8[0], &side);
@@ -1967,7 +1975,7 @@ void FUN_L00_002bd0a0(struct Moby *moby) {
func_002156E0_2BE3A8(&out, &dir, D_0013F5E0_r, func_L00_00258C80_2BE3A8(0.0f, D_L00_0016180C_2BE3A8));
func_001F9CA0_2BE3A8(&up, &dir, D_0013F5E0_r);
func_002156E0_2BE3A8(&out, &out, &up, wave_width);
- node_index = func_001FA898_2BE3A8(beam_length * 1.2f / (D_L00_00161804_2BE3A8 * D_0015EE60_2BE3A8));
+ node_index = func_001FA898_2BE3A8(beam_length * 1.2f / (D_L00_00161804_2BE3A8 * frame_scale));
if (data->target != 0) {
node_index = node_index * 3;
}
@@ -2010,7 +2018,7 @@ void FUN_L00_002bd0a0(struct Moby *moby) {
if (D_L00_001618A8_2BE3A8[pulse] < D_L00_00161820_2BE3A8) {
D_L00_001618B8_2BE3A8[pulse] = D_L00_001618B8_2BE3A8[pulse] - D_L00_00161838_2BE3A8;
}
- dt = D_L00_00161818_2BE3A8 * D_0015EE6C_2BE3A8;
+ dt = D_L00_00161818_2BE3A8 * D_0015ED6C_gp;
travelled = D_L00_001618C8_2BE3A8[pulse] + dt;
max_length = D_L00_001616DC_gp;
ratio = travelled / max_length;
@@ -2072,7 +2080,7 @@ extern float D_L00_00161790 __attribute__((sda));
extern int D_L00_00161794 __attribute__((sda));
extern int D_L00_00161798 __attribute__((sda));
extern int D_L00_0016179C __attribute__((sda));
-extern OvlVec4 D_L00_00166DC0_v __asm__("D_L00_00166DC0") __attribute__((section(".data")));
+extern float g_debug_camera[] __asm__("D_L00_00166DC0") __attribute__((section(".data")));
extern OvlVec4 D_L00_001DC020[] __attribute__((section(".data")));
extern OvlVec4 D_L00_001DC0E0[] __attribute__((section(".data")));
extern OvlQuad D_L00_001DC060[][20] __attribute__((section(".data")));
@@ -2129,7 +2137,7 @@ void FUN_L00_002bdc50(void *o) {
FUN_001f9a28(&d1, &quad.corner[0], &quad.corner[1]);
FUN_001f9a28(&d2, &quad.corner[2], &quad.corner[1]);
FUN_001f9ad8(&n, &d2, &d1);
- FUN_001f9a28(&e, &quad.corner[1], &D_L00_00166DC0_v);
+ FUN_001f9a28(&e, &quad.corner[1], &(*(OvlVec4 *)g_debug_camera));
if (FUN_001f9ab0(&n, &e) >= 0.0f) {
a += D_L00_00161714;
b += D_L00_00161714;
@@ -2308,7 +2316,7 @@ typedef struct {
long tex, unk80, unk88;
} Q_2be650;
extern OvlVec4 D_L00_001DBF20_2be650[] __asm__("D_L00_001DBF20") __attribute__((section(".data")));
-extern OvlVec4 D_0013F5E0_2be650 __asm__("D_0013F5E0");
+extern char D_0013F5E0[];
extern int D_L00_00161760 __attribute__((sda));
extern int D_L00_00161764 __attribute__((sda));
extern long tex_2be650(int) __asm__("FUN_001f44b8");
@@ -2367,7 +2375,7 @@ void FUN_L00_002be650(void *o) {
quad.color[0] = c;
qcopy(state.vertexTarget, &((u128 *)&D_L00_001DD0A0)[i]);
qcopy(&scaled, &((u128 *)&D_L00_001DD0D0)[i]);
- vmul_2be650(-1.0f, &negativeUp, &D_0013F5E0_2be650);
+ vmul_2be650(-1.0f, &negativeUp, &(*(OvlVec4 *)D_0013F5E0));
cross_2be650(&axis, &scaled, &negativeUp);
normalize_2be650(&axis, &axis, 1.0f);
cross_2be650(&negativeUp, &axis, &scaled);
@@ -2393,9 +2401,9 @@ typedef struct {
float unk68, unk6C;
long unk70, tex, unk80, unk88;
} Q_2be890;
-extern V_2be890 D_L00_00166DC0_2be890 __asm__("D_L00_00166DC0") __attribute__((section(".data")));
+extern float g_debug_camera[] __asm__("D_L00_00166DC0") __attribute__((section(".data")));
extern V_2be890 D_L00_001DBF60_2be890 __asm__("D_L00_001DBF60") __attribute__((section(".data")));
-extern V_2be890 D_0013F5E0_2be890 __asm__("D_0013F5E0");
+extern char D_0013F5E0[];
void FUN_001f9a68_2be890(float, void *, void *) __asm__("FUN_001f9a68");
void FUN_001f9a10_2be890(void *, void *, void *) __asm__("FUN_001f9a10");
void FUN_001f9a28_2be890(void *, void *, void *) __asm__("FUN_001f9a28");
@@ -2436,9 +2444,9 @@ void FUN_L00_002be890(void *mv) {
quad.unk6C = 1.0f;
FUN_001f9bf8_2be890(&e, m + 0xD0, D_L00_001617B4);
FUN_001f9a10_2be890(&mat[3], &D_L00_001DBF60_2be890, &e);
- FUN_001f9a28_2be890(&e, &D_L00_00166DC0_2be890, &mat[3]);
+ FUN_001f9a28_2be890(&e, &(*(V_2be890 *)g_debug_camera), &mat[3]);
FUN_001f9bf8_2be890(&mat[0], &e, 1.0f);
- FUN_001f9ad8_2be890(&mat[1], &mat[0], &D_0013F5E0_2be890);
+ FUN_001f9ad8_2be890(&mat[1], &mat[0], &(*(V_2be890 *)D_0013F5E0));
FUN_001f9bf8_2be890(&mat[1], &mat[1], -1.0f);
FUN_001f9ad8_2be890(&mat[2], &mat[1], &mat[0]);
for (i = 3; i >= 0; i--) {
@@ -2568,8 +2576,7 @@ typedef struct {
u8 pad2[0xC];
float f28;
} S173E40_2bec80;
-extern S173E40_2bec80 D_L00_00173E40_002bec80 __asm__("D_L00_00173E40")
- __attribute__((section(".data")));
+extern int D_L00_00173E40[] __attribute__((section(".data")));
int FUN_001efa68_002bec80(Vec4_2bec80 *, Vec4_2bec80 *, int, void *, int) __asm__("FUN_001efa68");
unsigned int FUN_001f0b58_002bec80(void) __asm__("FUN_001f0b58");
float FUN_L00_002bec80(Vec4_2bec80 *p, void *q) {
@@ -2585,9 +2592,9 @@ float FUN_L00_002bec80(Vec4_2bec80 *p, void *q) {
a.f[2] = f;
b.f[2] = f + 6.0f;
if (FUN_001efa68_002bec80(&b, &a, 6, q, 0)) {
- char *o = D_L00_00173E40_002bec80.o18;
+ char *o = (*(S173E40_2bec80 *)D_L00_00173E40).o18;
if (o && *(char **)(o + 0x24) && *(short *)(*(char **)(o + 0x24) + 0x46) == 5) {
- return D_L00_00173E40_002bec80.f28;
+ return (*(S173E40_2bec80 *)D_L00_00173E40).f28;
}
switch (FUN_001f0b58_002bec80()) {
case 0:
@@ -2599,7 +2606,7 @@ float FUN_L00_002bec80(Vec4_2bec80 *p, void *q) {
case 13:
break;
default:
- return D_L00_00173E40_002bec80.f28;
+ return (*(S173E40_2bec80 *)D_L00_00173E40).f28;
}
}
return 0.0f;
@@ -2705,7 +2712,7 @@ typedef struct {
} XD;
extern Hit *D_L00_00173E58_bf __asm__("D_L00_00173E58") NOT_SDA;
-extern XD D_L00_00173E40_c __asm__("D_L00_00173E40");
+extern int D_L00_00173E40[];
extern VU D_L00_00173E60;
extern s32 FUN_001fa6d0_c(f32) __asm__("FUN_001fa6d0");
@@ -2803,9 +2810,9 @@ f32 FUN_L00_002bf050(Mob *m, VU *pos, f32 *tgt, f32 *out, f32 ang, f32 arc, f32
}
}
} else {
- if (D_L00_00173E40_c.unk18 == x->p38 ||
- (D_L00_00173E40_c.unk18 != 0 && D_L00_00173E40_c.unk18->p24 != 0 &&
- D_L00_00173E40_c.unk18->p24->h46 == 5)) {
+ if ((*(XD *)D_L00_00173E40).unk18 == x->p38 ||
+ ((*(XD *)D_L00_00173E40).unk18 != 0 && (*(XD *)D_L00_00173E40).unk18->p24 != 0 &&
+ (*(XD *)D_L00_00173E40).unk18->p24->h46 == 5)) {
*out = 100.0f;
return arc;
}
diff --git a/src/overlays/shared/gameplay/hero/hero_check_damage.c b/src/overlays/shared/gameplay/hero/hero_check_damage.c
index 64456675b8..5256302260 100644
--- a/src/overlays/shared/gameplay/hero/hero_check_damage.c
+++ b/src/overlays/shared/gameplay/hero/hero_check_damage.c
@@ -929,7 +929,7 @@ typedef struct {
u8 p0[0x18];
s32 f18;
u8 p1[0x24 - 0x1C];
- s32 f24;
+ s32 unk24;
s32 f28;
s32 f2C;
s32 f30;
@@ -954,7 +954,7 @@ void FUN_L00_0020e4c8(void) {
return;
P = &hero;
P->unk2298 = t;
- v19 = D_L00_00179AC0_c[t].f24;
+ v19 = D_L00_00179AC0_c[t].unk24;
v21 = D_L00_00179AC0_c[t].f28;
if ((s32)P->state.control_mode == 12)
v21 = D_L00_00179AC0_c[t].f2C;
@@ -1330,143 +1330,134 @@ float FUN_L00_0020f0b8(float *a, float *b) {
}
return s;
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L00_0020f160.s", FUN_L00_0020f160);
-#else
-extern volatile s32 D_00141508 __attribute__((section(".data")));
-extern s32 D_0014150C __attribute__((section(".data")));
-extern s32 D_00141510 __attribute__((section(".data")));
-extern volatile s32 D_0013F694 __attribute__((sda));
-extern u8 D_00140640[] __asm__("D_00140640") __attribute__((section(".data")));
-extern void copy_matrix(void *, void *) __asm__("FUN_001fa2b8");
-extern void normalize_vector_triplet(void *) __asm__("FUN_00214128");
-extern void FUN_001ff260_f160(void *) __asm__("FUN_001f99f8");
-extern void FUN_001ff278_f160(void *, void *, void *) __asm__("FUN_001f9a10");
-extern void FUN_001ff300_f160(void *, void *, f32) __asm__("FUN_001f9a68");
-extern void FUN_0025d330_f160(void *, void *) __asm__("FUN_00214598");
-
-void FUN_L00_0020f160(void *moby, void *matrix)
-{
- u8 sum[0x40] __attribute__((aligned(16)));
- /* Retail adds distances to these stack values without initializing them. */
- f32 scores[16];
- s32 i, j, n, chosen, ring, limit;
- s32 count;
- void *output;
- f32 * volatile score_ptr;
- s64 negative_one = -1;
- f32 maximum;
- u8 *record;
- f32 *score;
+/* Advances the 16-slot history ring, scores slots against each other and averages the agreeing ones into arg+0x40. */
+/* Ported from rac1-decomp (src/overlays/shared/help_0020CDF0.c: func_L00_0020F7F8), where it is exact; names translated to the US level program. */
+
+typedef struct { float x, y, z, w; } __attribute__((aligned(16))) V4_F7F8;
+
+extern char 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");
+extern void clear_u64_value_c(void *) __asm__("func_001F99F8");
+extern void copy_matrix3x4_alt() __asm__("FUN_001fa2b8");
+extern void fast_vec_scale(void *, void *, f32) __asm__("func_001F9A68");
+extern void matrix_to_euler(void *, void *) __asm__("FUN_00214598");
+void normalize_vector_triplet(f32 *vectors) __asm__("FUN_00214128");
+extern char D_0013F350[] __attribute__((section(".data")));
+
+void FUN_L00_0020f160(char *arg) {
+ V4_F7F8 vv[4];
+ float fa[16];
+ int ri;
+ int cnt;
+ float *sums;
+ char *out;
+ int n, i, k, acc;
+ float mx;
{
- /* Retail: hero + 0x12F0 ring; counters at +0x21B8..+0x21C0. */
- struct Hero *hero_ptr = &hero;
- u8 *records = hero_ptr->pad_12EF + 1;
- record = records + (*(volatile s32 *)hero_ptr->pad_21B8) * 0x30;
- copy_matrix(record, matrix);
- record = records + (*(volatile s32 *)hero_ptr->pad_21B8) * 0x30;
- normalize_vector_triplet(record);
- ring = (*(volatile s32 *)hero_ptr->pad_21B8) + 1;
- (*(s32 *)hero_ptr->pad_21B8) = ring % 16;
- (*(s32 *)(hero_ptr->pad_21B8 + 4))++;
- if ((*(s32 *)(hero_ptr->pad_21B8 + 4)) > 16)
- (*(s32 *)(hero_ptr->pad_21B8 + 4)) = 16;
+ 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);
+
+ *(int *)(b + 0x21B8) = (*(int *)(b + 0x21B8) + 1) % 16;
+ *(int *)(b + 0x21BC) = *(int *)(b + 0x21BC) + 1;
+ if (*(int *)(b + 0x21BC) > 16) {
+ *(int *)(b + 0x21BC) = 16;
+ }
}
+
+ for (k = 0; k < 3; k++) {
+ clear_u64_value_c(&vv[k]);
+ }
+
{
- u8 *record = sum;
- i = 2;
- do {
- FUN_001ff260_f160(record);
- i--;
- record += 16;
- } while (i >= 0);
+ char *b = ((char *)&D_0013F350);
+ if (*(int *)(b + 0x208C) == 0x16) {
+ *(int *)&D_L00_0015F694 = 14;
+ } else if (*(int *)(b + 0x2084) == 2) {
+ *(int *)&D_L00_0015F694 = 5;
+ } else {
+ *(int *)&D_L00_0015F694 = 11;
+ }
}
- if (hero.state.control_mode == 22)
- D_0013F694 = 14;
- else if (hero.state.current == 2)
- D_0013F694 = 5;
- else
- D_0013F694 = 11;
{
- struct Hero *hero_ptr = &hero;
- s32 limit = D_0013F694;
- if ((*(s32 *)(hero_ptr->pad_21B8 + 8)) < limit)
- (*(s32 *)(hero_ptr->pad_21B8 + 8))++;
- else if ((*(s32 *)(hero_ptr->pad_21B8 + 8)) > limit)
- (*(s32 *)(hero_ptr->pad_21B8 + 8))--;
+ char *b = ((char *)&D_0013F350);
+ if (*(int *)(b + 0x21C0) < *(int *)&D_L00_0015F694) {
+ *(int *)(b + 0x21C0) = *(int *)(b + 0x21C0) + 1;
+ } else if (*(int *)&D_L00_0015F694 < *(int *)(b + 0x21C0)) {
+ *(int *)(b + 0x21C0) = *(int *)(b + 0x21C0) - 1;
+ }
}
+
{
- struct Hero *hero_ptr = &hero;
- n = (*(s32 *)(hero_ptr->pad_21B8 + 8));
- if (n < 2)
- n = 2;
- if ((*(s32 *)(hero_ptr->pad_21B8 + 4)) < n)
- return;
+ char *b = ((char *)&D_0013F350);
+ n = *(int *)(b + 0x21C0);
+ if (n < 2) {
+ n = 2;
+ }
+ if (*(int *)(b + 0x21BC) < n) {
+ return;
+ }
+ }
+
+ out = arg + 0x40;
+ cnt = 0;
+
+ for (i = 0; i < n; i++) {
+ char *b = ((char *)&D_0013F350);
+ 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);
+ 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));
+ }
+ }
}
- /* The completed triplet countdown leaves the signed remainder sentinel. */
- negative_one = i;
- output = (u8 *)moby + 0x40;
- count = 0;
- if (n > 0)
- score_ptr = scores;
+ mx = 0.0f;
for (i = 0; i < n; i++) {
- s32 a = (s32)((s64)(*(volatile s32 *)(hero.pad_21B8)) - (s64)(i - 15));
- a %= 16;
+ if (mx < fa[i]) {
+ mx = fa[i];
+ }
+ }
- if (n > 0) {
- score = score_ptr;
- score += i;
- j = 0;
- do {
- if (i != j) {
- s32 b = (*(volatile s32 *)(hero.pad_21B8)) - (j - 15);
- {
- s32 ring = b + 15;
- if (negative_one < b)
- ring = b;
- b -= (ring >> 4) * 16;
- }
- *score += FUN_L00_0020f0b8((f32 *)((hero.pad_12EF + 1) + a * 0x30),
- (f32 *)((hero.pad_12EF + 1) + b * 0x30));
- }
- j++;
- } while (j < n);
+ for (i = 0; i < n; i++) {
+ if (mx * 0.2f < fa[i]) {
+ cnt++;
}
}
- maximum = 0.0f;
- for (i = 0; i < n; i++)
- if (maximum < scores[i])
- maximum = scores[i];
- if (n > 0) {
- score_ptr = scores;
- i = n;
- do {
- if (maximum * 0.2f < *score_ptr)
- count++;
- i--;
- score_ptr++;
- } while (i != 0);
- }
- chosen = 0;
- limit = count < 3;
+
+ acc = 0;
for (i = 0; i < n; i++) {
- if (!(maximum * 0.2f < scores[i]) || count < 1 || !limit) {
- s32 a = (s32)((s64)(*(volatile s32 *)(hero.pad_21B8)) - (s64)(i - 15));
- a %= 16;
- record = (hero.pad_12EF + 1) + a * 0x30;
- chosen++;
- for (j = 0; j < 3; j++)
- FUN_001ff278_f160(sum + j * 16, sum + j * 16, record + j * 16);
+ if (mx * 0.2f < fa[i] && cnt > 0 && cnt < 3) {
+ continue;
+ }
+ acc++;
+ {
+ char *b = ((char *)&D_0013F350);
+ 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);
+ }
}
}
- for (i = 0; i < 3; i++)
- FUN_001ff300_f160(sum + i * 16, sum + i * 16, 1.0f / (f32)chosen);
- FUN_0025d330_f160(sum, output);
+
+ for (k = 0; k < 3; k++) {
+ fast_vec_scale(&vv[k], &vv[k], 1.0f / (float)acc);
+ }
+ matrix_to_euler(vv, out);
}
-#endif
#ifndef NON_MATCHING
INCLUDE_ASM("config/us/overlays/asm/FUN_L00_0020f580.s", FUN_L00_0020f580);
#else
@@ -1764,7 +1755,7 @@ s32 FUN_L00_0020fe30(void) {
typedef struct {
char pad[0x20];
- int f20;
+ int unk20;
char pad2[0x28];
} ItemDef;
@@ -1964,7 +1955,7 @@ void hero_switch_item(int i) {
((int *)(D_00141660))[i] = w;
g->selected_item[i] = w;
if (i == 0) {
- item_defs[g->selected_item[0]].f20 = 0x20;
+ item_defs[g->selected_item[0]].unk20 = 0x20;
}
changed = 1;
}
@@ -2024,7 +2015,7 @@ void hero_switch_item(int i) {
}
if (i == 0) {
struct Hero *k = &hero;
- item_defs[k->selected_item[0]].f20 = 0x20;
+ item_defs[k->selected_item[0]].unk20 = 0x20;
}
}
changed = 1;
@@ -3357,12 +3348,12 @@ void FUN_L00_00212ff0(void) {
float v[4];
if (globals->unk20B3 != 0) {
float f2 = dot_vectors_xyz(&globals->motion.velocity, &globals->unk270);
- float f1;
+ float ground_dist;
float len;
if (globals->air_frames.s != 0) return;
- f1 = globals->ground_distance;
- if (!(f1 < 0.0f)) return;
- if (f1 < f2 + 0.0001f || globals->state.current == 0x3E) {
+ ground_dist = globals->ground_distance;
+ if (!(ground_dist < 0.0f)) return;
+ if (ground_dist < f2 + 0.0001f || globals->state.current == 0x3E) {
qcopy(&globals->motion.pos, &globals->ground_point);
return;
}
diff --git a/src/overlays/shared/gameplay/hero/hero_idle_sequence.c b/src/overlays/shared/gameplay/hero/hero_idle_sequence.c
index 82a0ba9996..6ab3aabfef 100644
--- a/src/overlays/shared/gameplay/hero/hero_idle_sequence.c
+++ b/src/overlays/shared/gameplay/hero/hero_idle_sequence.c
@@ -983,147 +983,101 @@ void FUN_L00_00206cf8(void) {
if (n >= 9)
give_reward(0x4E26, 0x50);
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L00_00206e00.s", FUN_L00_00206e00);
-#else
-extern s32 D_0015EEA0 MACRO_ADDR;
-extern s32 alternate_animation_sequence __asm__("D_0015EE20") MACRO_ADDR;
-extern u8 D_0015EDB4 MACRO_ADDR;
-extern u8 big_head_cheat_enabled[] __asm__("D_0015EDB0") MACRO_ADDR;
-extern u8 selector_available[] __asm__("D_0015EDC0") MACRO_ADDR;
-extern s32 FUN_001f96f8(s32);
-extern void queue_dialogue_message(s32, s32) __asm__("FUN_L00_00263d40");
+/* Ported from rac1-decomp (src/overlays/shared/help_00203E98.c: func_L00_00207418), where it is exact; names translated to the US level program. */
+
+extern int alternate_animation_sequence __asm__("D_0015EE20") __attribute__((section(".sdata")));
+extern int D_0015EEA0 __attribute__((section(".sdata")));
+extern s32 scale_game_frames_c2(s32) __asm__("func_001F96F8");
+extern unsigned char D_0015EDB0[] __attribute__((section(".sdata")));
+extern unsigned char D_0015EDB4[4] __attribute__((section(".sdata")));
+extern unsigned char D_0015EDC0[] __attribute__((section(".sdata")));
+extern void FUN_L00_00263d40(int, int);
void FUN_L00_00206e00(void) {
- struct Hero *g;
- /* Retail appends at hero +0x21C4 and reloads the count at +0x21D4. */
- struct {
- u8 pad[0x21C4];
- u8 history[16];
- volatile s32 history_count;
- } *history_view;
- s32 input;
- u32 state;
- s32 level;
- s32 i, length, position, offset;
- u32 j;
- u8 *end;
- u8 *sequence;
- u8 *history;
- volatile s32 *history_count;
- if (D_0015EEA0 == 0 && alternate_animation_sequence == 0)
- return;
- g = &hero;
- level = FUN_001f96f8(15);
- input = 0;
- if (g->state_timer == level) {
- if (g->state.control_mode == 4) {
- if (g->state.current == HERO_STATE_HIGH_JUMP) {
- if (g->unk450 == 0) {
- input = 1;
- if (D_0015EDB4)
- input = 2;
- goto append;
- }
- if (g->unk450 == 1) {
- input = 2;
- if (D_0015EDB4)
- input = 1;
- goto append;
+ char *g;
+ int s;
+ int i;
+ if (D_0015EEA0 == 0 && alternate_animation_sequence == 0) return;
+ g = (char *)&hero;
+ s = 0;
+ if (*(int *)(g + 0x198) == scale_game_frames_c2(0xF)) {
+ if (*(int *)(g + 0x208C) == 4) {
+ int b = *(int *)(g + 0x2084);
+ if (b == 0xB) {
+ int c = *(int *)(g + 0x450);
+ if (c == 0) {
+ s = 1;
+ if (D_0015EDB4[0]) s = 2;
+ } else if (c == 1) {
+ s = 2;
+ if (D_0015EDB4[0]) s = 1;
+ } else if (c == 3) {
+ s = 3;
}
- state = g->unk450 ^ 3;
- input = 3;
- goto reject;
- } else if (g->state.current == 0x11) {
- input = 9;
- goto append;
- } else if (g->state.current == HERO_STATE_PACK_JUMP) {
- input = 10;
- goto append;
- } else {
- state = g->state.current ^ 0xE;
- input = 5;
- goto reject;
- }
- } else if (g->state.control_mode == 6) {
- if (g->state.current == HERO_STATE_WRENCH_SLAM) {
- input = 6;
- goto append;
+ } else if (b == 0x11) {
+ s = 9;
+ } else if (b == 0xA) {
+ s = 0xA;
+ } else if (b == 0xE) {
+ s = 5;
}
- if (g->state.current == HERO_STATE_WRENCH_COMBO) {
- input = g->attack_record + 12;
- goto append;
+ } else if (*(int *)(g + 0x208C) == 6) {
+ int b = *(int *)(g + 0x2084);
+ if (b == 0x14) {
+ s = 6;
+ } else if (b == 0x13) {
+ s = *(int *)(g + 0xA60) + 0xC;
+ } else if (b == 0x15) {
+ s = 4;
}
- state = g->state.current ^ HERO_STATE_CROUCH_SWING;
- input = 4;
- goto reject;
- } else {
- state = g->state.current ^ 0x22;
- input = 11;
- goto reject;
+ } else if (*(int *)(g + 0x2084) == 0x22) {
+ s = 0xB;
}
- } else {
- level = FUN_001f96f8(0x3C);
- if (g->state_timer == level) {
- if (g->state.current == HERO_STATE_CROUCH) {
- input = 7;
- goto append;
- }
- state = g->state.current ^ HERO_STATE_LAND;
- input = 8;
- goto reject;
+ } else if (*(int *)(g + 0x198) == scale_game_frames_c2(0x3C)) {
+ if (*(int *)(g + 0x2084) == 4) {
+ s = 7;
+ } else if (*(int *)(g + 0x2084) == 8) {
+ s = 8;
}
}
- goto append;
-reject:
- if (state != 0) input = 0;
-append:
- if (input == 0)
- return;
- history_view = (void *)&hero;
- history_count = &history_view->history_count;
- history = history_view->history;
- history[*history_count] = input;
- (*history_count)++;
- sequence = D_L00_00179700;
- for (i = 0, offset = 0; i < 12; i++, sequence += 16, offset += 16) {
- length = 0;
- if (*sequence != 0) {
- end = D_L00_00179700 + offset;
- do { end++; length++; } while (*end != 0);
- }
- if (length != 0) {
- position = *history_count - length;
- if (position < 0)
- position += 16;
- j = 0;
- if (length > 0) {
- if (*(u8 *)(position + (s32)history) == sequence[0]) {
- do {
- position++;
- j++;
- if (position > 15)
- position -= 16;
- if ((s32)j >= length)
- goto scan_result;
- } while (sequence[j] == *(u8 *)(position + (s32)history));
- }
+ if (s == 0) return;
+ {
+ char *q = (char *)&hero;
+ unsigned char *b0 = (unsigned char *)q + 0x21C4;
+ b0[*(int *)(q + 0x21D4)] = s;
+ *(int *)(q + 0x21D4) += 1;
+ for (i = 0; i < 12; i++) {
+ char *g2 = (char *)&hero;
+ unsigned char *b = (unsigned char *)g2 + 0x21C4;
+ int n = 0;
+ int j;
+ int k;
+ while (D_L00_00179700[n + i * 16] != 0) n++;
+ if (n == 0) continue;
+ k = *(int *)(g2 + 0x21D4) - n;
+ if (k < 0) k += 16;
+ for (j = 0; j < n; j++) {
+ if (*(unsigned char *)(k + (int)b) != D_L00_00179700[j + i * 16]) {
j = -1;
- }
-scan_result:
- if ((s32)j == length) {
- selector_available[i] = 1;
- big_head_cheat_enabled[i] = !big_head_cheat_enabled[i];
- queue_dialogue_message(big_head_cheat_enabled[i] ? 0x4FBE : 0x4FBF, -1);
break;
}
+ k++;
+ if (k >= 16) k -= 16;
+ }
+ if (j == n) {
+ int t = D_0015EDB0[i] == 0;
+ D_0015EDC0[i] = 1;
+ D_0015EDB0[i] = t;
+ FUN_L00_00263d40(t ? 0x4FBE : 0x4FBF, -1);
+ break;
}
}
- history_view = (void *)&hero;
- if (history_view->history_count > 15)
- history_view->history_count = 0;
+ }
+ {
+ char *r = (char *)&hero;
+ if (*(int *)(r + 0x21D4) >= 16) *(int *)(r + 0x21D4) = 0;
+ }
}
-#endif
int FUN_001f96f8(int);
void fade_to_black(int) __asm__("FUN_001f4a58");
void FUN_L00_002062b0(void);
@@ -1139,7 +1093,7 @@ void FUN_L00_0020b1d8_u(void) __asm__("FUN_L00_0020b1d8");
void FUN_L00_0020a318(void);
void FUN_L00_0020a540_u(void) __asm__("FUN_L00_0020a540");
void FUN_L00_0020ac98_u(void) __asm__("FUN_L00_0020ac98");
-void FUN_L00_0020a9e8(void);
+void FUN_L00_0020a9e8_u(void) __asm__("FUN_L00_0020a9e8");
void FUN_L00_002056a8(void);
void FUN_L00_002059d8(void);
void FUN_L00_00214fe8(void);
@@ -1153,7 +1107,7 @@ void FUN_L00_00207a58(void);
void FUN_L00_00206cf8(void);
void FUN_L00_00205ea8(void);
void FUN_L00_00206080(void);
-void FUN_L00_00206e00(void);
+void FUN_L00_00206e00_u(void) __asm__("FUN_L00_00206e00");
void noop_main_callback(int) __asm__("FUN_001e93e8");
void FUN_L00_002484e0(void *);
void FUN_L00_00257024(int);
@@ -1190,7 +1144,7 @@ void FUN_L00_002070d0(void) {
FUN_L00_0020a318();
FUN_L00_0020a540_u();
FUN_L00_0020ac98_u();
- FUN_L00_0020a9e8();
+ FUN_L00_0020a9e8_u();
FUN_L00_002056a8();
FUN_L00_002059d8();
FUN_L00_00214fe8();
@@ -1204,7 +1158,7 @@ void FUN_L00_002070d0(void) {
FUN_L00_00206cf8();
FUN_L00_00205ea8();
FUN_L00_00206080();
- FUN_L00_00206e00();
+ FUN_L00_00206e00_u();
noop_main_callback((int)g->moby);
if (g->state.control_mode != 0x16 && g->state.current != 0x32)
FUN_L00_002484e0(&g->motion.pos);
@@ -1406,7 +1360,7 @@ typedef struct {
char *w2080;
int w2084;
} S13F350_2078a8;
-extern float D_0015ED6C_002078a8 __asm__("D_0015ED6C");
+extern float D_0015ED6C;
void FUN_L00_00262b00_002078a8(char *, float *, float *, float, float) __asm__("FUN_L00_00262b00");
void transform_vector_by_basis(void *, void *, void *) __asm__("FUN_001f9cf8");
void rotation_matrix(void *, void *) __asm__("FUN_001fa050");
@@ -1419,11 +1373,11 @@ void FUN_L00_002078a8(void) {
float m[16] __attribute__((aligned(16)));
if (P->state.current == 0x7F) {
FUN_L00_00262b00_002078a8(P->moby, &P->unk6A8, &P->unk6AC, 0.3f,
- D_0015ED6C_002078a8 * 6.981317f);
+ D_0015ED6C * 6.981317f);
}
if (P->state.current == 0x6B && P->unk8BC == 0) {
FUN_L00_00262b00_002078a8(P->moby, &P->unk6A8, &P->unk6AC, 1.1f,
- D_0015ED6C_002078a8 * 5.2359877f);
+ D_0015ED6C * 5.2359877f);
if (P->unk86C) {
char *s = P->moby;
qcopy(((char *)P->unk86C) + 0x10, s + 0x10);
@@ -1657,7 +1611,7 @@ extern void transform_vector_by_basis_2080b0(void *, void *, void *) __asm__("FU
extern void add_vector_xyz_2080b0(void *, void *, void *) __asm__("FUN_001f9a10");
extern int truncate_float_to_s32_2080b0(float) __asm__("FUN_001fa6d0");
extern int scale_game_frames_2080b0(int) __asm__("FUN_001f96f8");
-extern float frame_time_2080b0 __asm__("D_0015ED6C") __attribute__((section(".sdata")));
+extern float D_0015ED6C_gp __asm__("D_0015ED6C") __attribute__((section(".sdata")));
// Hero gadget glow: pulses the colour of the hero's gadget moby (hero state 13, 16, 17, 19, 20) and
// queues its glow sprites. c and g are shared by cases 17 and 20 (one pseudo each, retail's $s0/$s1).
@@ -1677,7 +1631,7 @@ void FUN_L00_002080b0(void) {
}
}
- hero.glow_phase = fast_add_rotations_2080b0(hero.glow_phase, frame_time_2080b0 * 2.26892805f);
+ hero.glow_phase = fast_add_rotations_2080b0(hero.glow_phase, D_0015ED6C_gp * 2.26892805f);
hero.moby->glow_color = fast_tween_color_2080b0(0x806E8C6E, 0x805A3232, fast_sin_2080b0(hero.glow_phase) * 0.5f + 0.5f);
m = hero.items[0].moby;
@@ -1689,7 +1643,7 @@ void FUN_L00_002080b0(void) {
int c5;
int x1, x2, col;
float fr;
- float f = fast_add_rotations_2080b0(hero.items[0].glow_phase, frame_time_2080b0 * 4.36332321f);
+ float f = fast_add_rotations_2080b0(hero.items[0].glow_phase, D_0015ED6C_gp * 4.36332321f);
c5 = 0x28C8C8C8;
hero.items[0].glow_phase = f;
if (0.0f < f && f < 2.26892805f) c5 = 0x280A0A0A;
@@ -1718,8 +1672,8 @@ void FUN_L00_002080b0(void) {
if (scale_game_frames_2080b0(50) < hero.items[0].unk20) {
float k, f;
int r, g, b, a, col, col1, bs, gs;
- k = frame_time_2080b0 * 3.14159274f;
- if (hero.unk20A8 != 0) k = frame_time_2080b0 * 4.71238899f;
+ k = D_0015ED6C_gp * 3.14159274f;
+ if (hero.unk20A8 != 0) k = D_0015ED6C_gp * 4.71238899f;
f = fast_add_rotations_2080b0(hero.items[0].glow_phase, k);
hero.items[0].glow_phase = f;
r = truncate_float_to_s32_2080b0(fast_sin_2080b0(f) * 20.0f) + 30;
@@ -1746,8 +1700,8 @@ void FUN_L00_002080b0(void) {
case 19: {
float k, f;
int r, g, b, col;
- k = frame_time_2080b0 * 2.26892805f;
- if (hero.unk20A8 != 0) k = frame_time_2080b0 * 7.33038282f;
+ k = D_0015ED6C_gp * 2.26892805f;
+ if (hero.unk20A8 != 0) k = D_0015ED6C_gp * 7.33038282f;
f = fast_add_rotations_2080b0(hero.items[0].glow_phase, k);
hero.items[0].glow_phase = f;
if (hero.unk20A8 != 0) {
@@ -1770,7 +1724,7 @@ void FUN_L00_002080b0(void) {
int c5;
int x1, x2, col;
float fr;
- float f = fast_add_rotations_2080b0(hero.items[0].glow_phase, frame_time_2080b0 * 4.36332321f);
+ float f = fast_add_rotations_2080b0(hero.items[0].glow_phase, D_0015ED6C_gp * 4.36332321f);
c5 = 0xDCDCDC;
hero.items[0].glow_phase = f;
if (0.0f < f && f < 2.44346094f) c5 = 0xA0A0A;
@@ -1797,7 +1751,7 @@ void FUN_L00_002080b0(void) {
}
case 13: {
int c5;
- float f = fast_add_rotations_2080b0(hero.items[0].glow_phase, frame_time_2080b0 * 4.71238899f);
+ float f = fast_add_rotations_2080b0(hero.items[0].glow_phase, D_0015ED6C_gp * 4.71238899f);
c5 = 0x2814D214;
hero.items[0].glow_phase = f;
if (0.0f < f && f < 2.09439516f) c5 = 0x281414D2;
@@ -1940,7 +1894,7 @@ typedef struct {
f32 f28;
} U_208b60;
extern G_208b60 D_0013F350_208b60 __asm__("D_0013F350");
-extern U_208b60 D_L00_00173E40_208b60 __asm__("D_L00_00173E40");
+extern int D_L00_00173E40[];
f32 fast_subtract_rotations(f32, f32) __asm__("FUN_001fa5c8");
f32 fast_add_rotations(f32, f32) __asm__("FUN_001fa580");
void FUN_0020d510_208b60(M_208b60 *, V_208b60 *) __asm__("FUN_0020d510");
@@ -2011,7 +1965,7 @@ void FUN_L00_00208b60(void) {
t = D_L00_0017C300;
for (i = 3; i >= 0; i--, t++) {
M_208b60 *m;
- U_208b60 *u = &D_L00_00173E40_208b60;
+ U_208b60 *u = &(*(U_208b60 *)D_L00_00173E40);
m = G.m2080;
sc = m->fC * 0.0009765625f;
FUN_001f9a68_208b60(pw, m, 0.0009765625f);
@@ -2178,13 +2132,13 @@ typedef struct {
s32 v[9];
} T00209240;
extern T00209240 D_L00_001E7C10;
-extern s32 D_001413D0_00209240 __asm__("D_001413D0") __attribute__((section(".data")));
+extern int D_001413D0[] __attribute__((section(".data")));
void FUN_L00_0024f8f0(s32, s32, T00209240 *, void *);
/* Calls 0024f8f0 with mode 9 and a copy of D_L00_001E7C10 on a, or on D_001413D0 when a is 0. */
void FUN_L00_00209240(s32 a) {
T00209240 t;
if (a == 0)
- a = D_001413D0_00209240;
+ a = (*(s32 *)D_001413D0);
t = D_L00_001E7C10;
FUN_L00_0024f8f0(a, 9, &t, (((char *)&hero) + 0xac0));
}
@@ -2233,7 +2187,7 @@ void pack_pose(s32 *joints, PackedPose *pose, u8 *model, s32 padding, s32 contex
u64 value;
if (context == 0)
- context = D_001413D0_00209240;
+ context = (*(s32 *)D_001413D0);
out = (u64 *)(pose + 1);
FUN_00254b58_002092c8(context);
pose->root_rotation = PACKED_IDENTITY;
@@ -2317,7 +2271,7 @@ void FUN_L00_00209540(int a, int lim) {
g->cnt = FUN_00213260_00209540(a);
}
}
-extern float D_0015ED6C_209638 __asm__("D_0015ED6C");
+extern float D_0015ED6C;
extern float FUN_001fa580_209638(float, float) __asm__("FUN_001fa580");
extern float FUN_001fa5c8_209638(float, float) __asm__("FUN_001fa5c8");
extern float FUN_002132a8_209638(float, float) __asm__("FUN_002132a8");
@@ -2340,14 +2294,14 @@ void FUN_L00_00209638(int seed, int limit) {
ang = FUN_001fa5c8_209638(hero.motion.rot.f[2], 0.785398f);
}
p = &hero;
- v[0] = fast_cos(ang) * (D_0015ED6C_209638 * 0.6f);
- v[1] = fast_sin(ang) * (D_0015ED6C_209638 * 0.6f);
+ v[0] = fast_cos(ang) * (D_0015ED6C * 0.6f);
+ v[1] = fast_sin(ang) * (D_0015ED6C * 0.6f);
v[2] = 0.0f;
pos[0] = p->motion.pos.f[0] + v[0] * 18.0f;
pos[1] = p->motion.pos.f[1] + v[1] * 18.0f;
pos[2] = p->water_surface_z;
- v[0] -= fast_cos(p->motion.rot.f[2]) * (D_0015ED6C_209638 * 1.5f);
- v[1] -= fast_sin(p->motion.rot.f[2]) * (D_0015ED6C_209638 * 1.5f);
+ v[0] -= fast_cos(p->motion.rot.f[2]) * (D_0015ED6C * 1.5f);
+ v[1] -= fast_sin(p->motion.rot.f[2]) * (D_0015ED6C * 1.5f);
{
float r = FUN_002132a8_209638(0.4f, 0.5f);
float d = -2.0f;
@@ -2366,7 +2320,7 @@ void FUN_L00_00209638(int seed, int limit) {
typedef struct {
float x, y, z, w;
} __attribute__((aligned(16))) V_209848;
-extern float D_0015ED6C_209848 __asm__("D_0015ED6C");
+extern float D_0015ED6C;
float FUN_002132a8_209848(float, float) __asm__("FUN_002132a8");
float FUN_00213308_209848(void) __asm__("FUN_00213308");
int random_int_between(int, int) __asm__("FUN_L00_00257b90");
@@ -2385,10 +2339,10 @@ void FUN_L00_00209848(int n, int lim) {
t.y = y;
}
a = FUN_00213308_209848();
- r = FUN_002132a8_209848(D_0015ED6C_209848 * 0.0f, D_0015ED6C_209848 * 3.0f);
+ r = FUN_002132a8_209848(D_0015ED6C * 0.0f, D_0015ED6C * 3.0f);
v.x = fast_cos(a) * r + P->motion.displacement.f[0] * 0.75f;
v.y = fast_sin(a) * r + P->motion.displacement.f[1] * 0.75f;
- v.z = FUN_002132a8_209848(D_0015ED6C_209848 * 3.0f, D_0015ED6C_209848 * 6.5f);
+ v.z = FUN_002132a8_209848(D_0015ED6C * 3.0f, D_0015ED6C * 6.5f);
k = random_int_between(0x5A, 0x78);
if (P->unk22A4 < 0.25f)
FUN_L00_0026f548_209848(&t, &v, 3, k);
@@ -2405,7 +2359,7 @@ typedef union {
OvlQuad q;
float f[4];
} V_209a40;
-extern float D_0015ED6C_209a40 __asm__("D_0015ED6C");
+extern float D_0015ED6C;
extern float FUN_002132a8_209a40(float, float) __asm__("FUN_002132a8");
extern void FUN_L00_0024f7c8_209a40(void *, int, void *) __asm__("FUN_L00_0024f7c8");
extern int random_integer_below_cf(void *, void *, float, float) __asm__("FUN_L00_0026f080");
@@ -2443,15 +2397,15 @@ void FUN_L00_00209a40(int n, int mode) {
} else {
scale_vector_xyz(&v, &v, 0.7f);
}
- v.f[0] += FUN_002132a8_209a40(D_0015ED6C_209a40 * -0.4f, D_0015ED6C_209a40 * 0.4f);
- v.f[1] += FUN_002132a8_209a40(D_0015ED6C_209a40 * -0.4f, D_0015ED6C_209a40 * 0.4f);
- v.f[2] += FUN_002132a8_209a40(-D_0015ED6C_209a40, D_0015ED6C_209a40 * 0.0f);
+ v.f[0] += FUN_002132a8_209a40(D_0015ED6C * -0.4f, D_0015ED6C * 0.4f);
+ v.f[1] += FUN_002132a8_209a40(D_0015ED6C * -0.4f, D_0015ED6C * 0.4f);
+ v.f[2] += FUN_002132a8_209a40(-D_0015ED6C, D_0015ED6C * 0.0f);
random_integer_below_cf(pos, &v, FUN_002132a8_209a40(4200.0f, 7350.0f), -1.0f);
}
}
#include "rnc/math/circle_offset.h"
-extern f32 D_0015ED6C_c __asm__("D_0015ED6C");
+extern float D_0015ED6C;
extern f32 random_float_between(f32 a, f32 b) __asm__("FUN_002132a8");
extern f32 random_angle_radians(void) __asm__("FUN_00213308");
extern s32 FUN_L00_00257b90(s32, s32);
@@ -2486,10 +2440,10 @@ void FUN_L00_00209ca8(s32 puffs, s32 debris, s32 flash) {
}
for (i = 0; i < debris; i++) {
ang = random_angle_radians();
- speed = random_float_between(D_0015ED6C_c * 0.0f, D_0015ED6C_c * 3.0f);
+ speed = random_float_between(D_0015ED6C * 0.0f, D_0015ED6C * 3.0f);
v.f[0] = fast_cos(ang) * speed;
v.f[1] = fast_sin(ang) * speed;
- v.f[2] = random_float_between(D_0015ED6C_c * 3.0f, D_0015ED6C_c * 8.0f);
+ v.f[2] = random_float_between(D_0015ED6C * 3.0f, D_0015ED6C * 8.0f);
start.f[0] = hero.motion.pos.f[0] + v.f[0] * 8.0f;
start.f[1] = hero.motion.pos.f[1] + v.f[0] * 8.0f;
start.f[2] = hero.water_surface_z - random_float_between(0.0f, 0.2f);
@@ -2499,7 +2453,7 @@ void FUN_L00_00209ca8(s32 puffs, s32 debris, s32 flash) {
}
}
extern struct Hero hero_data __asm__("D_0013F350") __attribute__((section(".data")));
-extern float D_0015ED6C_209ec8 __asm__("D_0015ED6C");
+extern float D_0015ED6C;
int fast_dec_timer(void *) __asm__("FUN_001f9770");
float FUN_001fa580_209ec8(float, float) __asm__("FUN_001fa580");
float spread_k(float, float) __asm__("FUN_L00_00257c48");
@@ -2517,7 +2471,7 @@ void FUN_L00_00209ec8(void) {
OvlQuad w[1];
char *g;
char *base;
- float a, r, r0, f, a1, a2;
+ float a, r, r0, f, theta, phi;
int t, c, col, life, n1, n2, k;
OvlQuad *pt;
g = D_0013F7EE;
@@ -2525,7 +2479,7 @@ void FUN_L00_00209ec8(void) {
qcopy(v, g - 0x41E);
base = g - 0x49E;
a = FUN_001fa580_209ec8(*(float *)(base + 0x98), 1.5707963705062866f);
- r0 = spread_k(D_0015ED6C_209ec8 * 0.2f, D_0015ED6C_209ec8 * 0.7f);
+ r0 = spread_k(D_0015ED6C * 0.2f, D_0015ED6C * 0.7f);
((float *)w)[0] = fast_cos(a) * r0;
((float *)w)[1] = fast_sin(a) * r0;
((int *)w)[2] = 0;
@@ -2550,11 +2504,11 @@ void FUN_L00_00209ec8(void) {
for (k = 0x38; k >= 0; k--) {
n1 = FUN_001fa6d0_209ec8(FUN_002132a8_209ec8(4200.0f, 7350.0f) / 1000.0f);
n2 = FUN_001fa6d0_209ec8(FUN_002132a8_209ec8(21000.0f, 31500.001953125f) / 1000.0f);
- r = FUN_002132a8_209ec8(D_0015ED6C_209ec8 * 0.15f, D_0015ED6C_209ec8 * 0.57f);
+ r = FUN_002132a8_209ec8(D_0015ED6C * 0.15f, D_0015ED6C * 0.57f);
qcopy(v, g - 0x41E);
- a1 = FUN_00213308_209ec8();
- a2 = FUN_00213308_209ec8();
- build_spherical_offset(pt, r, a1, a2);
+ theta = FUN_00213308_209ec8();
+ phi = FUN_00213308_209ec8();
+ build_spherical_offset(pt, r, theta, phi);
spark_v(v, pt, col, 0x70F0, life, n1, n2, 1);
}
t = random_int_between(FUN_001f96f8_209ec8(3), FUN_001f96f8_209ec8(7));
@@ -2583,13 +2537,12 @@ typedef struct G0020a240 {
u8 v80[0x1b4];
f32 f234;
} G0020a240;
-extern G0020a240 D_0013F350_c __asm__("D_0013F350");
extern u8 D_L00_00173E60[];
extern void FUN_L00_002335c8(V0020a240 *, f32, f32, f32);
extern s32 FUN_001efa68(V0020a240 *, V0020a240 *, s32, s32, s32);
extern f32 vector_distance_xy(void *, void *) __asm__("FUN_001f9b80");
s32 FUN_L00_0020a240(f32 *out, f32 a, f32 b) {
- G0020a240 *g = &D_0013F350_c;
+ G0020a240 *g = (G0020a240 *)&hero;
V0020a240 p;
V0020a240 q;
@@ -2800,86 +2753,62 @@ void FUN_L00_0020a540(void) {
P.f118 = P.f278 * 0.52f;
P.f114 = P.f274 * 0.55f;
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L00_0020a9e8.s", FUN_L00_0020a9e8);
-#else
-extern s32 FUN_001fef68_a9e8(s32 *) __asm__("FUN_L00_001fef68");
-extern s32 FUN_001fef20_a9e8(s32) __asm__("FUN_L00_001fef20");
-extern f32 FUN_L00_00257be8_a9e8(f32, f32) __asm__("FUN_L00_00257be8");
-
-void FUN_L00_0020a9e8(void) {
- struct Hero *g = &hero;
- char *base = (char *)g;
- s32 *timers;
- s32 *check_timer;
- s32 *store_timer;
- char *record;
- struct HeroEase *output;
- s32 i;
+/* Re-rolls four random motion parameters and copies each pair into its 0xB0-byte record. */
+/* Ported from rac1-decomp (src/overlays/shared/help_00203E98.c: func_L00_0020B060), where it is exact; names translated to the US level program. */
- if (g->state.current != 0 || *(u8 *)((char *)g->moby + 0x53) != 0)
- return;
+extern f32 random_float_between_c(f32, f32) __asm__("func_002132A8");
+extern float FUN_L00_00257c48(float lo, float hi);
+extern int tick_countdown_32_alt_c(int *) __asm__("FUN_001f9740");
+extern s32 scale_game_frames_c(s32) __asm__("func_001F96F8");
+extern char D_001403B0[];
- timers = (s32 *)(base + 0x1060);
- output = D_L00_0017A680_002054e8;
- i = 0;
- check_timer = timers;
- record = base;
- store_timer = check_timer;
- do {
- s32 j;
- f32 y, x;
- if (FUN_001fef68_a9e8(check_timer) != 0) {
- s32 low, high;
+void FUN_L00_0020a9e8(void) {
+ char *base = (char *)((char *)&D_0013F350_002062b0);
+ int *q;
+ char *g;
+ int i, j;
+ char *tbl;
+
+ if (*(int *)(base + 0x2084) != 0) return;
+ if (*(unsigned char *)(*(int *)(base + 0x2080) + 0x53) != 0) return;
+ q = (int *)(base + 0x1060);
+ g = base;
+ tbl = ((char *)D_L00_0017A680_c);
+ for (i = 0; i < 4; i++) {
+ char *f;
+ if (tick_countdown_32_alt_c(&q[i])) {
if (i == 0) {
- *(f32 *)&hero.unk1028 = FUN_L00_00257c48_a540(0.17453292f, 0.5235988f);
- low = FUN_001fef20_a9e8(0x46);
- high = FUN_001fef20_a9e8(0x96);
- *(s32 *)((char *)&hero + 0x1060) = FUN_L00_00257b90_a540(low, high);
+ int *s;
+ *(float *)(g + 0x1028) = FUN_L00_00257c48(0.17453292f, 0.5235988f);
+ s = (int *)(((char *)&D_001403B0));
+ *s = FUN_L00_00257b90(scale_game_frames_c(0x46), scale_game_frames_c(0x96));
} else if (i == 1) {
- *(f32 *)((char *)timers - 0x28) = FUN_L00_00257c48_a540(0.17453292f, 0.5235988f);
- low = FUN_001fef20_a9e8(0x28);
- high = FUN_001fef20_a9e8(0x5A);
- timers[1] = FUN_L00_00257b90_a540(low, high);
+ *(float *)((char *)q - 0x28) = FUN_L00_00257c48(0.17453292f, 0.5235988f);
+ q[1] = FUN_L00_00257b90(scale_game_frames_c(0x28), scale_game_frames_c(0x5A));
} else if (i == 2) {
- *(f32 *)((char *)timers - 0x18) = FUN_L00_00257c48_a540(0.2617994f, 0.87266463f);
- low = FUN_001fef20_a9e8(0x28);
- high = FUN_001fef20_a9e8(0x5A);
- timers[2] = FUN_L00_00257b90_a540(low, high);
+ *(float *)((char *)q - 0x18) = FUN_L00_00257c48(0.2617994f, 0.87266463f);
+ q[2] = FUN_L00_00257b90(scale_game_frames_c(0x28), scale_game_frames_c(0x5A));
} else {
- f32 old;
- f32 value;
- f32 first = FUN_L00_00257be8_a9e8(-0.08726646f, 0.5235988f);
- old = *(f32 *)(record + 0x1028);
- *(f32 *)(record + 0x1024) = first;
- value = FUN_L00_00257c48_a540(0.34906584f, 0.9599311f);
- *(f32 *)(record + 0x1028) = value;
- if (old <= 0.0f && value <= 0.0f)
- goto negate_fourth;
- if (old >= 0.0f && value >= 0.0f)
- goto negate_fourth;
- goto fourth_sign_done;
-negate_fourth:
- *(f32 *)(record + 0x1028) = -*(f32 *)(record + 0x1028);
-fourth_sign_done:
- low = FUN_001fef20_a9e8(0x23);
- high = FUN_001fef20_a9e8(0x46);
- *store_timer = FUN_L00_00257b90_a540(low, high);
+ float old, nw;
+ *(float *)(g + i * 0x10 + 0x1024) = random_float_between_c(-0.08726646f, 0.5235988f);
+ old = *(float *)(g + i * 0x10 + 0x1028);
+ nw = FUN_L00_00257c48(0.34906584f, 0.95993108f);
+ *(float *)(g + i * 0x10 + 0x1028) = nw;
+ if ((old <= 0 && nw <= 0) || (old >= 0 && nw >= 0))
+ *(float *)(g + i * 0x10 + 0x1028) = -*(float *)(g + i * 0x10 + 0x1028);
+ q[i] = FUN_L00_00257b90(scale_game_frames_c(0x23), scale_game_frames_c(0x46));
}
}
+ f = g + i * 0x10;
j = i + 13;
- y = *(f32 *)(record + 0x1028);
- x = *(f32 *)(record + 0x1024);
- output[j].rot_target.f[2] = y;
- output[j].rot_target.f[1] = x;
- record += 0x10;
- store_timer++;
- check_timer++;
- i++;
- } while (i < 4);
+ base = (char *)(j * 0xB0);
+ {
+ char *r = tbl + (int)base;
+ *(float *)(r + 0x68) = *(float *)(f + 0x1028);
+ *(float *)(r + 0x64) = *(float *)(f + 0x1024);
+ }
+ }
}
-
-#endif
/* Ported from rac1-decomp (src/overlays/shared/help_00203E98.c: func_L00_0020B310), where it is exact; names translated to the US level program. */
extern char *D_L00_001ABD80[] __asm__("D_L00_001ABA00");
@@ -2907,7 +2836,7 @@ void FUN_L00_0020ac98(void) {
float v[8];
char *q;
char *info, *info2, *p, *t;
- float f20, f21, s;
+ float yaw_delta, pitch, s;
int mode = *(int *)(g1 + 0x208C);
if (mode != 1 && mode != 4 && mode != 2 && mode != 7 && mode != 0) {
*(int *)(g1 + 0x2274) = 0;
@@ -2976,28 +2905,28 @@ void FUN_L00_0020ac98(void) {
if (info2 != 0)
v[2] += (float)*(unsigned char *)(info2 + 0x3A) * 0.125f;
FUN_L00_00233660(&v[4], 0.3f, 0.0f, 0.85f);
- f20 = fast_subtract_rotations(FUN_001f9e90_c(v[0] - v[4], v[1] - v[5]), *(float *)(g5 + 0x98));
- f21 = FUN_001f9e90_c(vector_distance(v, q), v[6] - v[2]);
- if (f20 > 1.02974427f)
- f20 = 1.02974427f;
- else if (f20 < -1.02974427f)
- f20 = -1.02974427f;
- if (f21 > 0.610865235f)
- f21 = 0.610865235f;
- if (f21 < -0.436332315f)
- f21 = -0.436332315f;
+ yaw_delta = fast_subtract_rotations(FUN_001f9e90_c(v[0] - v[4], v[1] - v[5]), *(float *)(g5 + 0x98));
+ pitch = FUN_001f9e90_c(vector_distance(v, q), v[6] - v[2]);
+ if (yaw_delta > 1.02974427f)
+ yaw_delta = 1.02974427f;
+ else if (yaw_delta < -1.02974427f)
+ yaw_delta = -1.02974427f;
+ if (pitch > 0.610865235f)
+ pitch = 0.610865235f;
+ if (pitch < -0.436332315f)
+ pitch = -0.436332315f;
g6 = (char *)hero_pos - 0x80;
if (scale_game_frames(0x4D) - scale_game_frames(0x32) < *(int *)(g6 + 0x1C0)) {
- if (f20 > 0.296705961f)
- f20 = 0.296705961f;
- else if (f20 < -0.296705961f)
- f20 = -0.296705961f;
- f21 = 0.0f;
+ if (yaw_delta > 0.296705961f)
+ yaw_delta = 0.296705961f;
+ else if (yaw_delta < -0.296705961f)
+ yaw_delta = -0.296705961f;
+ pitch = 0.0f;
}
FUN_L00_0020a228(frame_scale_sq * 0.021f, frame_scale_sq * 0.27f);
p = D_L00_0017A780;
- *(float *)(p + 0x274) = f21;
- *(float *)(p + 0x278) = f20 * 0.7f;
+ *(float *)(p + 0x274) = pitch;
+ *(float *)(p + 0x278) = yaw_delta * 0.7f;
FUN_L00_0020a210(frame_scale_sq * 0.014f, frame_scale_sq * 0.3f);
*(float *)(p + 0x1C8) = *(float *)(p + 0x278) * 0.55f;
}
@@ -3110,7 +3039,7 @@ typedef struct {
f32 x, y;
} S2_20b5b8;
-extern f32 D_0015ED6C_20b5b8 __asm__("D_0015ED6C");
+extern float D_0015ED6C;
extern V4_20b5b8 coll_hit_normal[] __asm__("D_L00_00173E80");
extern f32 gravity_z(void *) __asm__("FUN_L00_00233a78");
@@ -3140,7 +3069,7 @@ void FUN_L00_0020b5b8(void) {
if (g->ground_distance < 0.4f) {
return;
}
- if (gravity_z(&g->motion.velocity) < D_0015ED6C_20b5b8 * -20.0f) {
+ if (gravity_z(&g->motion.velocity) < D_0015ED6C * -20.0f) {
return;
}
if (g->unk4E8 != 0) {
@@ -3440,8 +3369,8 @@ extern unsigned char D_0013F350[];
f32 FUN_001f9e90_c2(f32, f32) __asm__("FUN_001f9e90");
void FUN_L00_00259508(void *a, void *b, void *c, int d, float f);
extern char D_0013F450_20C568[] __asm__("D_0013F350");
-extern char D_L00_00173F40_20C568[] __asm__("D_L00_00173E40");
-extern float D_0015EE6C_20C568 __asm__("D_0015ED6C");
+extern int D_L00_00173E40[];
+extern float D_0015ED6C;
extern int func_001F9850_20C568(int) __asm__("FUN_001f96f8");
extern void func_L00_0025A540_20C568(void *a, void *b, void *c, int d, float f) __asm__("FUN_L00_00259508");
extern float func_001F9F90_20C568(float) __asm__("FUN_001f9dc8");
@@ -3469,11 +3398,11 @@ void FUN_L00_0020bed0(void) {
if (((Hero *)D_0013F450_20C568)->unk1B0 != 0) return;
can_grab = 0;
if (((Hero *)D_0013F450_20C568)->vehicle_mode == 0) {
- if ((((Hero *)D_0013F450_20C568)->state.control_mode == 4 && (((Hero *)D_0013F450_20C568)->unk41E != 0 || ((Hero *)D_0013F450_20C568)->motion.velocity.f[2] < D_0015EE6C_20C568 * 3.5f)) || ((Hero *)D_0013F450_20C568)->state.control_mode == 2 || ((Hero *)D_0013F450_20C568)->state.current == 8 || ((Hero *)D_0013F450_20C568)->state.current == 0x1A || ((Hero *)D_0013F450_20C568)->state.current == 0x1B) can_grab = 1;
+ if ((((Hero *)D_0013F450_20C568)->state.control_mode == 4 && (((Hero *)D_0013F450_20C568)->unk41E != 0 || ((Hero *)D_0013F450_20C568)->motion.velocity.f[2] < D_0015ED6C * 3.5f)) || ((Hero *)D_0013F450_20C568)->state.control_mode == 2 || ((Hero *)D_0013F450_20C568)->state.current == 8 || ((Hero *)D_0013F450_20C568)->state.current == 0x1A || ((Hero *)D_0013F450_20C568)->state.current == 0x1B) can_grab = 1;
if (((Hero *)D_0013F450_20C568)->state.current == 0xE && ((Hero *)D_0013F450_20C568)->anim_frame < 37.0f) can_grab = 0;
}
if (((Hero *)D_0013F450_20C568)->vehicle_mode == 1) {
- if ((((Hero *)D_0013F450_20C568)->state.control_mode == 4 && (((Hero *)D_0013F450_20C568)->unk41E != 0 || ((Hero *)D_0013F450_20C568)->motion.velocity.f[2] < D_0015EE6C_20C568 * 2.5f)) || ((Hero *)D_0013F450_20C568)->state.control_mode == 2 || ((Hero *)D_0013F450_20C568)->state.current == 0x4F || ((Hero *)D_0013F450_20C568)->state.current == 0x4D || ((Hero *)D_0013F450_20C568)->state.current == 0x4E) can_grab = 1;
+ if ((((Hero *)D_0013F450_20C568)->state.control_mode == 4 && (((Hero *)D_0013F450_20C568)->unk41E != 0 || ((Hero *)D_0013F450_20C568)->motion.velocity.f[2] < D_0015ED6C * 2.5f)) || ((Hero *)D_0013F450_20C568)->state.control_mode == 2 || ((Hero *)D_0013F450_20C568)->state.current == 0x4F || ((Hero *)D_0013F450_20C568)->state.current == 0x4D || ((Hero *)D_0013F450_20C568)->state.current == 0x4E) can_grab = 1;
}
if (!can_grab) return;
@@ -3510,16 +3439,16 @@ void FUN_L00_0020bed0(void) {
if (func_L00_001EFFF0_20C568(ledge, ray_end, 4, (int)((Hero *)D_0013F450_20C568)->moby, 0)) {
surface = func_L00_001F3958_20C568();
if (surface != 9 && surface != 12 && surface != 0) {
- if (func_L00_001FF860_20C568(((Hit_20C568 *)D_L00_00173F40_20C568)->v40[2], func_001F9CE8_20C568(((Hit_20C568 *)D_L00_00173F40_20C568)->v40)) < 0.3490658402442932f) found = 1;
+ if (func_L00_001FF860_20C568(((Hit_20C568 *)((char *)D_L00_00173E40))->v40[2], func_001F9CE8_20C568(((Hit_20C568 *)((char *)D_L00_00173E40))->v40)) < 0.3490658402442932f) found = 1;
}
}
}
if (!found) return;
- if (((Hit_20C568 *)D_L00_00173F40_20C568)->m18 != 0) {
+ if (((Hit_20C568 *)((char *)D_L00_00173E40))->m18 != 0) {
grabbable = 0;
- moby_info = func_L00_0025D390_20C568(((Hit_20C568 *)D_L00_00173F40_20C568)->m18);
- moby_props = FUN_L00_002603d0(((Hit_20C568 *)D_L00_00173F40_20C568)->m18);
+ moby_info = func_L00_0025D390_20C568(((Hit_20C568 *)((char *)D_L00_00173E40))->m18);
+ moby_props = FUN_L00_002603d0(((Hit_20C568 *)((char *)D_L00_00173E40))->m18);
if (moby_info != 0 && (moby_info->h1E & 1)) {
grabbable = 1;
} else if (moby_props != 0) {
@@ -3527,15 +3456,15 @@ void FUN_L00_0020bed0(void) {
}
if (!grabbable) return;
}
- ((Hero *)D_0013F450_20C568)->unk4F8 = (s32)(((Hit_20C568 *)D_L00_00173F40_20C568)->m18);
- if (((Hero *)D_0013F450_20C568)->motion.pos.f[2] + up < ((Hit_20C568 *)D_L00_00173F40_20C568)->v20[2]) return;
- qcopy(ledge, ((Hit_20C568 *)D_L00_00173F40_20C568)->v20);
- qcopy(ray_end, ((Hit_20C568 *)D_L00_00173F40_20C568)->v20);
+ ((Hero *)D_0013F450_20C568)->unk4F8 = (s32)(((Hit_20C568 *)((char *)D_L00_00173E40))->m18);
+ if (((Hero *)D_0013F450_20C568)->motion.pos.f[2] + up < ((Hit_20C568 *)((char *)D_L00_00173E40))->v20[2]) return;
+ qcopy(ledge, ((Hit_20C568 *)((char *)D_L00_00173E40))->v20);
+ qcopy(ray_end, ((Hit_20C568 *)((char *)D_L00_00173E40))->v20);
ray_end[2] += 0.05f;
qcopy_nc(hero_level, ((Hero *)D_0013F450_20C568)->motion.pos.f);
hero_level[2] = ray_end[2];
if (func_L00_001EFFF0_20C568(hero_level, ray_end, 4, (int)((Hero *)D_0013F450_20C568)->moby, 0)) return;
- qcopy(clearance, ((Hit_20C568 *)D_L00_00173F40_20C568)->v20);
+ qcopy(clearance, ((Hit_20C568 *)((char *)D_L00_00173E40))->v20);
clearance[2] += 0.6f;
if (func_L00_001F1D20_20C568(0.45f, 0.6f, clearance, 4, (int)((Hero *)D_0013F450_20C568)->moby)) {
((Hero *)D_0013F450_20C568)->unk4F4 |= 1;
@@ -3559,7 +3488,7 @@ void FUN_L00_0020bed0(void) {
edge_start[2] = edge_end[2];
if (func_L00_001EFFF0_20C568(edge_start, edge_end, 2, 0, 0)) {
edge = 1;
- ((Hero *)D_0013F450_20C568)->unk4E4 = func_L00_001FF860_20C568(((Hit_20C568 *)D_L00_00173F40_20C568)->v40[0], ((Hit_20C568 *)D_L00_00173F40_20C568)->v40[1]);
+ ((Hero *)D_0013F450_20C568)->unk4E4 = func_L00_001FF860_20C568(((Hit_20C568 *)((char *)D_L00_00173E40))->v40[0], ((Hit_20C568 *)((char *)D_L00_00173E40))->v40[1]);
break;
}
}
diff --git a/src/overlays/shared/gameplay/state/00261968.c b/src/overlays/shared/gameplay/state/00261968.c
index 51baceeb9e..4b8793bf13 100644
--- a/src/overlays/shared/gameplay/state/00261968.c
+++ b/src/overlays/shared/gameplay/state/00261968.c
@@ -66,79 +66,91 @@ s32 FUN_L00_00261968(s32 path_index, OvlVec4 *start, OvlVec4 *end) {
}
return 0;
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L00_00261b48.s", FUN_L00_00261b48);
-#else
+/* Ported from rac1-decomp (src/overlays/shared/mobyutil_00261B00.c: func_L00_00262BC0), where it is exact; names translated to the US level program. */
+
+typedef u32 VecQuad __attribute__((mode(TI), aligned(16)));
+
+typedef union {
+ VecQuad q;
+ f32 f[4];
+ s32 i[4];
+} Vec4_261b48;
+
typedef struct {
s32 count;
u8 pad[12];
- OvlVec4 points[1];
-} SegmentPath_261b48;
+ Vec4_261b48 points[1];
+} SegmentPath_2629E0;
-extern SegmentPath_261b48 *D_L00_001B04B0_261b48[] __asm__("D_L00_001B04B0");
-extern void FUN_001ff2a8_261b48(OvlVec4 *, OvlVec4 *, OvlVec4 *) __asm__("FUN_001f9a28");
-extern f32 FUN_001ff3d8_261b48(OvlVec4 *) __asm__("FUN_001f9af0");
-extern void FUN_001ff500_261b48(OvlVec4 *, OvlVec4 *, f32) __asm__("FUN_001f9bf8");
-extern void FUN_001ff260_261b48(OvlVec4 *) __asm__("FUN_001f99f8");
-extern void FUN_001ff6d0_261b48(OvlVec4 *, OvlVec4 *, OvlVec4 *) __asm__("FUN_001f9cf8");
-extern void FUN_001ff2d8_261b48(OvlVec4 *, OvlVec4 *, OvlVec4 *, f32) __asm__("FUN_001f9a40");
+typedef int OvlQuad_261b48 __attribute__((mode(TI)));
-s32 FUN_L00_00261b48(s32 path_index, OvlVec4 *start, OvlVec4 *end, OvlVec4 *out) {
- OvlVec4 direction;
- OvlVec4 axis;
- OvlVec4 origin;
- OvlVec4 first;
- OvlVec4 next;
- OvlVec4 *previous;
- OvlVec4 *current;
- SegmentPath_261b48 **entry;
- s32 i;
- s32 offset;
- s32 found;
- f32 nearest;
- f32 crossing;
- f32 zero;
+typedef union {
+ OvlQuad_261b48 q;
+ f32 f[4];
+ s32 i[4];
+} OvlVec4_261b48;
- FUN_001ff2a8_261b48(&direction, end, start);
- direction.i[2] = 0;
- FUN_001ff500_261b48(&direction, &direction, 1.0f / FUN_001ff3d8_261b48(&direction));
- FUN_001ff260_261b48(&axis);
- axis.f[0] = direction.f[1];
- axis.f[1] = -direction.f[0];
- FUN_001ff260_261b48(&origin);
- entry = &D_L00_001B04B0_261b48[path_index];
- found = 0;
- i = 1;
- origin.f[2] = 1.0f;
- nearest = origin.f[2];
- FUN_001ff2a8_261b48(&first, &(*entry)->points[0], start);
- FUN_001ff6d0_261b48(&first, &first, &direction);
- previous = &first;
- current = &next;
- if (i < (*entry)->count) {
+typedef struct {
+ s32 count;
+ u8 pad[12];
+ OvlVec4_261b48 points[1];
+} SegmentPath_261d78_261b48;
+
+extern f32 fast_vec_length(void *) __asm__("func_001F9AF0");
+extern void clear_u64_value(void *) __asm__("func_001F99F8");
+extern void fast_vec_normalize(void *, void *, f32) __asm__("FUN_001f9bf8");
+extern void lerp_vector(void *, void *, void *, f32) __asm__("func_001F9A40");
+extern void fast_vec_sub(void *, void *, void *) __asm__("FUN_001f9a28");
+extern void transform_vector_by_basis(void *, void *, void *) __asm__("func_001F9CF8");
+
+int FUN_L00_00261b48(int idx, void *a, void *b, void *c) {
+ float v[4], w[4], z[4], t[4], u[4];
+ float best;
+ float zero;
+ int found = 0;
+ int i = 1;
+ int offset;
+ float *prev;
+ float *cur;
+ fast_vec_sub(v, b, a);
+ v[2] = 0;
+ fast_vec_normalize(v, v, 1.0f / fast_vec_length(v));
+ clear_u64_value(w);
+ w[0] = v[1];
+ w[1] = -v[0];
+ clear_u64_value(z);
+ z[2] = 1.0f;
+ best = 1.0f;
+ fast_vec_sub(t, (char *)((SegmentPath_2629E0 * *)D_L00_001B04B0_261968)[idx] + 0x10, a);
+ transform_vector_by_basis(t, t, v);
+ prev = t;
+ cur = u;
+ if (i < ((SegmentPath_2629E0 * *)D_L00_001B04B0_261968)[idx]->count) {
offset = 0x20;
zero = 0.0f;
do {
- FUN_001ff2a8_261b48(current, (OvlVec4 *)((u8 *)*entry + offset), start);
- FUN_001ff6d0_261b48(current, current, &direction);
- if (first.f[3] != zero || next.f[3] != zero) {
- if (next.f[1] * first.f[1] < 0.0f) {
- crossing = (first.f[0] - next.f[0]) / (first.f[1] - next.f[1]) * -next.f[1] + next.f[0];
- if (crossing > 0.0f && crossing < nearest) {
- nearest = crossing;
+ fast_vec_sub(cur, (char *)((SegmentPath_2629E0 * *)D_L00_001B04B0_261968)[idx] + offset, a);
+ transform_vector_by_basis(cur, cur, v);
+ if (t[3] != zero || u[3] != zero) {
+ if (u[1] * t[1] < 0.0f) {
+ float x = (t[0] - u[0]) / (t[1] - u[1]) * -u[1] + u[0];
+ if (x > 0.0f && x < best) {
+ best = x;
found = 1;
+ qcopy(prev, cur);
+ goto next;
}
}
}
- qcopy(previous, current);
+ qcopy(prev, cur);
+ next:
i++;
offset += 0x10;
- } while (i < (*entry)->count);
+ } while (i < ((SegmentPath_2629E0 * *)D_L00_001B04B0_261968)[idx]->count);
}
- FUN_001ff2d8_261b48(out, start, end, nearest);
+ lerp_vector(c, a, b, best);
return found;
}
-#endif
#include "rnc/overlay/quad.h"
typedef struct {
@@ -216,7 +228,7 @@ typedef struct {
} SegmentPath_262030;
extern SegmentPath_262030 *D_L00_001B04B0_262030[] __asm__("D_L00_001B04B0");
-extern OvlVec4 D_0013F5E0_262030 __asm__("D_0013F5E0");
+extern char D_0013F5E0[];
extern f32 FUN_001ff218_262030(f32) __asm__("FUN_001f99c0");
extern void FUN_001ff278_262030(OvlVec4 *, OvlVec4 *, OvlVec4 *) __asm__("FUN_001f9a10");
extern void FUN_001ff2a8_262030(OvlVec4 *, OvlVec4 *, OvlVec4 *) __asm__("FUN_001f9a28");
@@ -249,7 +261,7 @@ s32 FUN_L00_00262030(f32 distance, s32 path_index, OvlVec4 *point, OvlVec4 *out)
saved_out = out;
qcopy(&working, point);
entry = D_L00_001B04B0_262030[path_index];
- offset = (s32)&D_0013F5E0_262030;
+ offset = (s32)&(*(OvlVec4 *)D_0013F5E0);
original_height = FUN_001ff398_262030(&working, (OvlVec4 *)offset);
i = 0;
if (entry->count - 1 > found) {
@@ -295,8 +307,8 @@ s32 FUN_L00_00262030(f32 distance, s32 path_index, OvlVec4 *point, OvlVec4 *out)
} while (i < entry->count - 1);
}
if ((i = found)) {
- projection = FUN_001ff398_262030(&working, &D_0013F5E0_262030);
- FUN_001ff500_262030(original_height - projection, &segment, &D_0013F5E0_262030);
+ projection = FUN_001ff398_262030(&working, &(*(OvlVec4 *)D_0013F5E0));
+ FUN_001ff500_262030(original_height - projection, &segment, &(*(OvlVec4 *)D_0013F5E0));
FUN_001ff278_262030(saved_out, &working, &segment);
}
return found;
diff --git a/src/overlays/shared/gameplay/vendor/002de370.c b/src/overlays/shared/gameplay/vendor/002de370.c
index dc86105984..70d477f65e 100644
--- a/src/overlays/shared/gameplay/vendor/002de370.c
+++ b/src/overlays/shared/gameplay/vendor/002de370.c
@@ -38,45 +38,50 @@ void FUN_L03_002de370(char *moby) {
mark_moby_for_removal(moby);
}
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L03_002e8628.s", FUN_L03_002e8628);
-#else
#include "qcopy.h"
+
+/* Ported from rac1-decomp (src/overlays/shared/vendor_00292AC0.c: func_L03_002E99F0), where it is exact; names translated to the US level program. */
+
+typedef struct { char pad0[0x40]; int x40; char pad1[8]; float x4C; } CamSub;
+
+typedef struct { char pad0[4]; float f4; float f8; int fC; CamSub sub; char pad1[0x20]; int x80; } CamInfo;
+
extern int D_L03_0015EF50;
-extern void raise_kernel_trap(void) __asm__("FUN_001f97b0");
-extern void rotation_matrix(void *, void *) __asm__("FUN_001fa050");
-
-void FUN_L03_002e8628(char *moby) {
- float angles[4] __attribute__((aligned(16)));
- float matrix[16] __attribute__((aligned(16)));
- int table = D_L03_0015EF50;
- char *data = *(char **)(moby + 0x70);
- char *params = data + 0x10;
- char *entry;
- char *sub;
-
- *(float *)(params + 0x4c) = 1.5f;
- *(int *)(*(char **)(moby + 0x70) + 0x80) = *(int *)(params + 0x40) = 0;
- data = *(char **)(moby + 0x70);
- *(float *)(data + 4) = 0.02f;
- *(float *)(data + 8) = 0.1f;
- *(int *)(data + 0xc) = 0;
- entry = (char *)(table + (*(short *)(moby + 0x84) << 5));
- sub = *(char **)(entry + 0x1c);
- if (*(short *)(moby + 0x84) < 0)
- raise_kernel_trap();
- else
- *(float *)(params + 0x4c) = *(float *)(sub + 0x18);
- qcopy(moby + 0x30, entry);
- qcopy(&angles, entry + 0x10);
- rotation_matrix(matrix, &angles);
- qcopy(moby, matrix);
- qcopy(moby + 0x10, matrix + 4);
- qcopy(moby + 0x20, matrix + 8);
- qcopy(moby + 0x40, moby);
- *(short *)(moby + 0x7e) = 0;
+extern void RaiseKernelTrap();
+extern void euler_rotation_matrix(float *, float *) __asm__("FUN_001fa050");
+
+void FUN_L03_002e8628(char *cam) {
+ float v[4] __attribute__((aligned(16)));
+ float mat[16] __attribute__((aligned(16)));
+ CamSub *a = &(*(CamInfo **)(cam + 0x70))->sub;
+ CamInfo *d;
+ char *ent;
+ int idx;
+ char *p;
+ a->x4C = 1.5f;
+ a->x40 = 0;
+ (*(CamInfo **)(cam + 0x70))->x80 = 0;
+ d = *(CamInfo **)(cam + 0x70);
+ d->f4 = 0.02f;
+ d->f8 = 0.1f;
+ d->fC = 0;
+ idx = *(short *)(cam + 0x84);
+ ent = (char *)D_L03_0015EF50 + (idx << 5);
+ p = *(char **)(ent + 0x1C);
+ if (idx < 0) {
+ RaiseKernelTrap();
+ } else {
+ a->x4C = *(float *)(p + 0x18);
+ }
+ qcopy(cam + 0x30, ent);
+ qcopy(v, ent + 0x10);
+ euler_rotation_matrix(mat, v);
+ qcopy(cam, mat);
+ qcopy(cam + 0x10, mat + 4);
+ qcopy(cam + 0x20, mat + 8);
+ qcopy(cam + 0x40, cam);
+ *(short *)(cam + 0x7E) = 0;
}
-#endif
#include "sda.h"
#include "qcopy.h"
diff --git a/src/overlays/shared/math/vectors/0025c230.c b/src/overlays/shared/math/vectors/0025c230.c
index 223b68ecc6..0914c63cc6 100644
--- a/src/overlays/shared/math/vectors/0025c230.c
+++ b/src/overlays/shared/math/vectors/0025c230.c
@@ -15,11 +15,11 @@ extern void transpose_rotation_matrix(void *, void *) __asm__("FUN_001fa2d8");
/* Returns component d of c - a transformed by the matrix transpose_rotation_matrix builds from b. */
float FUN_L00_0025c230(void *a, void *b, void *c, int d) {
- float v0[4], v1[4], v2[16];
+ float delta[4], v1[4], v2[16];
float *w = v1;
- subtract_vector_xyz(v0, c, a);
+ subtract_vector_xyz(delta, c, a);
transpose_rotation_matrix(v2, b);
- transform_vector(w, v0, v2);
+ transform_vector(w, delta, v2);
return w[d];
}
#define NOT_SDA
@@ -141,187 +141,231 @@ void FUN_L00_0025c558(u8 *a, B_25c558 *b, int c, int d, int e, float f) {
else
FUN_00212f90_0025c558(a, c, e, d);
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L00_0025c698.s", FUN_L00_0025c698);
-#else
-extern float FUN_001f9b20_0025c698(void *) __asm__("FUN_001f9b20");
-extern void FUN_L00_0025b868_0025c698(float, float, float *) __asm__("FUN_00213ed8");
-extern void FUN_001f9af0_0025c698(float, void *, void *) __asm__("FUN_001f9c48");
-extern void FUN_001f9a68_0025c698(void *, void *, void *) __asm__("FUN_001f9a10");
-extern float FUN_L00_00259698_0025c698(void *, int, float) __asm__("FUN_00213508");
-extern int FUN_001f35d8_0025c698(void) __asm__("FUN_001f0b58");
-extern float FUN_L00_00259710_0025c698(void *) __asm__("FUN_L00_00259710");
-extern void FUN_L00_002d7e90_0025c698(float, void *) __asm__("FUN_L00_002d7e90");
-extern void FUN_001ff300_0025c698(float, void *, void *) __asm__("FUN_001f9a68");
-extern float FUN_0024edc8_0025c698(void *) __asm__("FUN_0020c9e0");
-extern float FUN_001ff218_0025c698(float) __asm__("FUN_001f99c0");
-extern int FUN_L00_002595a0_0025c698(float, float, float, float *, float *) __asm__("FUN_L00_002595a0");
-extern void FUN_L00_00258278_0025c698(float, float, float, float, void *, void *) __asm__("FUN_L00_00258278");
-extern float FUN_00200240_0025c698(int) __asm__("FUN_001fa6c0");
-extern int FUN_L00_001f2868_0025c698(float, void *, int, void *, int) __asm__("FUN_L00_001f2868");
-extern int FUN_L00_0025e3b8_0025c698(int) __asm__("FUN_L00_0025e3b8");
-extern void FUN_L00_00259bc8_0025c698(float, int, void *, int, void *, void *) __asm__("FUN_L00_00259bc8");
-extern float FUN_001ff3d8_0025c698(void *) __asm__("FUN_001f9af0");
-extern void FUN_001efc70_0025c698(void *, void *, int, void *, int) __asm__("FUN_001efa68");
-extern int FUN_L00_001f0d60_0025c698(float, void *, int, void *) __asm__("FUN_L00_001f0d60");
-extern void FUN_001f9bf8_0025c698(void *, void *, float) __asm__("FUN_001f9bf8");
-extern float FUN_001f9ab0_0025c698(void *, void *) __asm__("FUN_001f9ab0");
-extern void FUN_001f9a28_0025c698(void *, void *, void *) __asm__("FUN_001f9a28");
-extern float D_0015ED60_0025c698 __asm__("D_0015ED60");
-extern float D_00158160_0025c698 __asm__("D_00158160");
-extern int D_00177F00_0025c698[] __asm__("D_L00_00177F00");
-extern V4 D_00173E60_0025c698 __asm__("D_L00_00173E60");
-extern V4 D_00173E70_0025c698 __asm__("D_L00_00173E70");
-extern V4 D_00173E80_0025c698 __asm__("D_L00_00173E80");
-extern int D_00173E58_0025c698 __asm__("D_L00_00173E58");
+#include "rnc/math/vector.h"
-#define F_25C698(p, o) (*(float *)((u8 *)(p) + (o)))
-#define I_25C698(p, o) (*(int *)((u8 *)(p) + (o)))
-#define H_25C698(p, o) (*(s16 *)((u8 *)(p) + (o)))
-#define B_25C698(p, o) (*(u8 *)((u8 *)(p) + (o)))
+#include "qcopy.h"
-int FUN_L00_0025c698(void *moby, void *motion) {
- V4 moved, prior, probe, surface, normal, impulse;
- float speed, height, smoothing, target, duration, limit, time, value;
- float output, scratch;
- float dot;
- int result = 0, count, *hit, state;
+/* Steps moby MOBY's motion from state ST and returns the flag bits it set. */
+/* Ported from rac1-decomp (src/overlays/shared/mobyutil_00258BC8.c: func_L00_0025D6F0), where it is exact; names translated to the US level program. */
- F_25C698(motion, 8) -= F_25C698(motion, 0x10);
- if (B_25C698(motion, 0x2e) == 1 && B_25C698(motion, 0x2f) != 0)
- FUN_L00_0025c398(moby, motion, (void *)(int)B_25C698(motion, 0x2f));
- speed = FUN_001f9b20_0025c698(motion);
- target = H_25C698(motion, 0x3e) == 2 ? 0.0f : F_25C698(motion, 0x4c);
- FUN_L00_0025b868_0025c698(target, F_25C698(motion, 0x14), &speed);
- FUN_001f9af0_0025c698(speed, motion, motion);
- if (F_25C698(motion, 0x1c) < F_25C698(motion, 8))
- F_25C698(motion, 8) = F_25C698(motion, 0x1c);
+extern Vec4 D_L00_00173E70;
+extern char *FUN_L00_002d7e90(void *, float);
+extern f32 convert_integer_to_float(s32) __asm__("func_001FA6C0");
+extern f32 fast_vec_dot_c(void *a, void *b) __asm__("func_001F9AB0");
+extern f32 fast_vec_length(void *) __asm__("func_001F9AF0");
+extern f32 vector_length_xy(void *) __asm__("FUN_001f9b20");
+extern float approach_value(float *p, float target, float maxstep);
+extern int *D_L00_00177F00[];
+extern float frame_scale __asm__("D_0015ED60") __attribute__((section(".sdata")));
+extern Vec4 D_94C8_60 __asm__("D_L00_00173E60"); /* no foreign declaration */
+extern int FUN_001efa68(void *, void *, int, int, int);
+extern int FUN_001f0b58(void);
+extern int FUN_L00_001f0d60();
+extern int FUN_L00_001f2868(void *, float, int, void *, void *);
+extern int FUN_L00_0025e3b8(void *);
+extern void add_vector_xyz_c(void *, void *, void *) __asm__("FUN_001f9a10");
+extern void fast_vec_normalize_c(void *, void *, f32) __asm__("FUN_001f9bf8");
+extern void fast_vec_scale_c(void *, void *, f32) __asm__("func_001F9A68");
+extern float probe_ground_height(void *, int, float) __asm__("FUN_00213508");
+extern void set_vector_length_xy(void *, void *, f32) __asm__("FUN_001f9c48");
+f32 compute_interpolated_record_value(void *anim) __asm__("FUN_0020c9e0");
+float absolute_float(float input) __asm__("func_001F99C0");
+int FUN_L00_002595a0(float *r0, float *r1, float a, float b, float c);
+void FUN_L00_00258278(unsigned char *m, float *ptr, float t, float b, float c, float limit);
+void FUN_L00_00259710(void *a);
+void FUN_L00_00259bc8(char *, float, int, int, void *, void *);
+void FUN_L00_0025c398_c(void *a0, void *a1, void *a2) __asm__("FUN_L00_0025c398");
+extern Vec4 D_94C8_60 __asm__("D_L00_00173E60");
+extern float func_L00_0025A748_f(void *) __asm__("FUN_L00_00259710");
+extern int collision_line(void *, void *, int, void *, int) __asm__("FUN_001efa68");
+extern int func_L00_001F10E0_l(void *, float, int, void *) __asm__("FUN_L00_001f0d60");
+extern float probe_ground_height(void *, int, float) __asm__("FUN_00213508");
+extern float frame_scale __asm__("D_0015ED60") __attribute__((section(".sdata")));
+extern int func_L00_001F2BE8_d6f0(float, void *, int, void *, void *) __asm__("FUN_L00_001f2868");
- prior = *(V4 *)((u8 *)moby + 0x10);
- prior.v[2] = F_25C698(motion, 0x28) + prior.v[2];
- height = FUN_L00_00259698_0025c698(&prior, 0, 0.5f);
- if (FUN_001f35d8_0025c698() == 0) {
- if (F_25C698(motion, 0x5c) == 0.0f && height <= prior.v[2] &&
- prior.v[2] + F_25C698(motion, 8) < height) {
- F_25C698(motion, 0x5c) = 1.0f;
- prior.v[2] = height;
- FUN_L00_002d7e90_0025c698(3.0f, &prior);
+int FUN_L00_0025c698(char *moby, char *st) {
+ float eye[4];
+ float v10[4];
+ float v20[4];
+ float v30[4];
+ float v40[4];
+ float v50[4];
+ float f60, f64, f68, f6c;
+
+ Vec4 *g;
+ char *q;
+ int flags = 0;
+
+ float sc, f21, f20, f12, t, r, rr, one;
+ int n, i;
+
+ *(float *)(st + 0x8) = *(float *)(st + 0x8) - *(float *)(st + 0x10);
+ if (*(unsigned char *)(st + 0x2E) == 1) {
+ if (*(unsigned char *)(st + 0x2F) != 0) {
+ FUN_L00_0025c398_c(moby, st, (void *)(int)*(unsigned char *)(st + 0x2F));
+ }
+ }
+
+ f60 = vector_length_xy(st);
+ t = (*(short *)(st + 0x3E) == 2) ? 0.0f : *(float *)(st + 0x4C);
+ approach_value(&f60, t, *(float *)(st + 0x14));
+ set_vector_length_xy((float *)st, (float *)st, f60);
+ if (*(float *)(st + 0x1C) < *(float *)(st + 0x8)) {
+ *(float *)(st + 0x8) = *(float *)(st + 0x1C);
+ }
+
+ qcopy(v10, moby + 0x10);
+ v10[2] = v10[2] + *(float *)(st + 0x28);
+ f21 = probe_ground_height(v10, 0, 0.5f);
+ if (FUN_001f0b58() == 0) {
+ if (*(float *)(st + 0x5C) == 0.0f && f21 <= v10[2] && v10[2] + *(float *)(st + 0x8) < f21) {
+ *(float *)(st + 0x5C) = 1.0f;
+ v10[2] = f21;
+ FUN_L00_002d7e90(v10, 3.0f);
+ }
+ f21 = func_L00_0025A748_f((moby + 0x10));
+ } else {
+ if ((*(int *)(st + 0x24) & 0x10) || *(short *)(st + 0x3E) == 2) {
+ add_vector_xyz_c(v20, (moby + 0x10), st);
+ if (func_L00_0025A748_f(v20) < f21 - 0.25f) {
+ set_vector_length_xy((float *)st, (float *)st, 0.0f);
+ }
}
- height = FUN_L00_00259710_0025c698((u8 *)moby + 0x10);
- } else if ((I_25C698(motion, 0x24) & 0x10) || H_25C698(motion, 0x3e) == 2) {
- FUN_001f9a68_0025c698(&probe, (u8 *)moby + 0x10, motion);
- if (FUN_L00_00259710_0025c698(&probe) < height - 0.25f)
- FUN_001f9af0_0025c698(0.0f, motion, motion);
}
- if (F_25C698(motion, 0x5c) != 0.0f) {
- if (F_25C698(motion, 0x5c) < 4.0f)
- FUN_001ff300_0025c698(0.7f, motion, motion);
- if (F_25C698(motion, 0x5c) < 7.0f) {
- F_25C698(motion, 0x5c) += 1.0f;
- F_25C698(motion, 0x10) *= 0.75f;
+
+ if (*(float *)(st + 0x5C) != 0.0f) {
+ if (*(float *)(st + 0x5C) < 4.0f) {
+ fast_vec_scale_c(st, st, 0.7f);
+ }
+ if (*(float *)(st + 0x5C) < 7.0f) {
+ *(float *)(st + 0x5C) = *(float *)(st + 0x5C) + 1.0f;
+ *(float *)(st + 0x10) = *(float *)(st + 0x10) * 0.75f;
}
}
- if (F_25C698(moby, 0x10) < 2.0f || F_25C698(moby, 0x10) > 1021.0f ||
- F_25C698(moby, 0x14) < 2.0f || F_25C698(moby, 0x14) > 1021.0f ||
- F_25C698(moby, 0x18) < 2.0f || F_25C698(moby, 0x18) > 1021.0f)
- result = 0x100;
+ if (*(float *)(moby + 0x10) < 2.0f || 1021.0f < *(float *)(moby + 0x10)
+ || *(float *)(moby + 0x14) < 2.0f || 1021.0f < *(float *)(moby + 0x14)
+ || *(float *)(moby + 0x18) < 2.0f || 1021.0f < *(float *)(moby + 0x18)) {
+ flags = 0x100;
+ }
- if (F_25C698(motion, 0x54) != -1.0f && F_25C698(motion, 0x50) != -1.0f) {
- switch (H_25C698(motion, 0x3e)) {
+ if (*(float *)(st + 0x54) != -1.0f && *(float *)(st + 0x50) != -1.0f) {
+ switch (*(short *)(st + 0x3E)) {
case 0: {
- duration = FUN_001ff218_0025c698(F_25C698(motion, 8) / F_25C698(motion, 0x10));
- if (duration > 2.0f) {
- time = (F_25C698(motion, 0x50) - FUN_0024edc8_0025c698(moby)) / duration;
- if (time > 0.0f)
- FUN_L00_0025b868_0025c698(time, D_00158160_0025c698 * 0.1f, (float *)((u8 *)moby + 0x58));
+ float ratio;
+ ratio = absolute_float(*(float *)(st + 0x8) / *(float *)(st + 0x10));
+ if (2.0f < ratio) {
+ t = compute_interpolated_record_value(moby);
+ rr = (*(float *)(st + 0x50) - t) / ratio;
+ if (0.0f < rr) {
+ approach_value((float *)(moby + 0x58), rr, frame_scale * 0.1f);
+ }
}
- break;
+ break;
}
- case 1: {
- if (F_25C698(motion, 0x54) <= FUN_0024edc8_0025c698(moby)) {
- I_25C698(moby, 0x58) = 0;
+ case 1:
+ t = compute_interpolated_record_value(moby);
+ if (*(float *)(st + 0x54) <= t) {
+ *(int *)(moby + 0x58) = 0;
} else {
- value = F_25C698(motion, 0x10) * -0.5f;
- output = 60.0f;
- if (FUN_L00_002595a0_0025c698(value, F_25C698(motion, 8) - value,
- F_25C698(moby, 0x18) - height, &scratch, &limit) > 0 &&
- scratch > 0.0f && scratch < 60.0f)
- output = scratch;
- if (output < 0.0001f) output = 0.0001f;
- time = (F_25C698(motion, 0x54) - FUN_0024edc8_0025c698(moby)) / output;
- if (time > 2.0f) time = 2.0f;
- else if (time < 0.0f) time = 0.0f;
- FUN_L00_0025b868_0025c698(time, D_0015ED60_0025c698 * 0.1f, (float *)((u8 *)moby + 0x58));
+ float h = *(float *)(st + 0x10) * -0.5f;
+ f20 = 60.0f;
+ n = FUN_L00_002595a0(&f64, &f68, h, *(float *)(st + 0x8) - h, *(float *)(moby + 0x18) - f21);
+ if (n > 0 && 0.0f < f64 && f64 < f20) {
+ f20 = f64;
+ }
+ if (f20 < 0.0001f) {
+ f20 = 0.0001f;
+ }
+ t = compute_interpolated_record_value(moby);
+ rr = (*(float *)(st + 0x54) - t) / f20;
+ if (2.0f < rr) {
+ rr = 2.0f;
+ } else if (rr < 0.0f) {
+ rr = 0.0f;
+ }
+ approach_value((float *)(moby + 0x58), rr, frame_scale * 0.1f);
}
- break;
- }
- case 2: {
- F_25C698(moby, 0x58) = 1.0f;
break;
- }
+ case 2:
+ *(float *)(moby + 0x58) = 1.0f;
+ break;
}
}
- if (B_25C698(moby, 0x70) & 2) result |= 0x40;
- if (!(I_25C698(motion, 0x24) & 4))
- FUN_L00_00258278_0025c698(F_25C698(motion, 0x40), 0.02f, 0.3f,
- F_25C698(motion, 0x48), moby, (u8 *)motion + 0x44);
- moved = *(V4 *)((u8 *)moby + 0x10);
- moved.v[2] += F_25C698(motion, 0x28);
- FUN_001f9a68_0025c698((u8 *)moby + 0x10, (u8 *)moby + 0x10, motion);
- probe = *(V4 *)((u8 *)moby + 0x10);
- probe.v[2] += F_25C698(motion, 0x28);
- FUN_001f9a68_0025c698(&surface, &probe, motion);
- count = FUN_L00_001f2868_0025c698(FUN_00200240_0025c698(I_25C698(motion, 0x20)) * 0.0010742188f,
- &surface, 0x10, moby, 0);
- state = count;
- hit = D_00177F00_0025c698;
- /* The query returns zero or a logical-right-shifted hit count. */
- while (state-- > 0) {
- if (FUN_L00_0025e3b8_0025c698(*hit) == 0) {
- if ((I_25C698(motion, 0x24) & 0x20) && H_25C698(motion, 0x3e) == 2)
- result |= 0x100;
- } else {
- FUN_L00_00259bc8_0025c698(1.0f, *hit, moby, 0x10000, (u8 *)moby + 0x10, motion);
- }
- hit++;
+ if (*(unsigned char *)(moby + 0x70) & 2) {
+ flags |= 0x40;
+ }
+ if (!(*(int *)(st + 0x24) & 4)) {
+ FUN_L00_00258278(moby, (float *)(st + 0x44), *(float *)(st + 0x40), 0.02f, 0.3f, *(float *)(st + 0x48));
}
- smoothing = FUN_001ff3d8_0025c698(motion);
- if ((float)I_25C698(motion, 0x20) * 0.0009765625f < smoothing) {
- FUN_001efc70_0025c698(&moved, &probe, 0x24, moby, 0);
- probe = D_00173E60_0025c698;
+
+ i = 0;
+ qcopy(eye, (moby + 0x10));
+ eye[2] = eye[2] + *(float *)(st + 0x28);
+ add_vector_xyz_c((moby + 0x10), (moby + 0x10), st);
+ qcopy(v20, (moby + 0x10));
+ v20[2] = v20[2] + *(float *)(st + 0x28);
+ add_vector_xyz_c(v30, v20, st);
+ n = func_L00_001F2BE8_d6f0(convert_integer_to_float(*(int *)(st + 0x20)) * 0.0010742187732830644f, v30, 16, moby, 0);
+ if (i < n) {
+ int **pp = D_L00_00177F00;
+ int k = n;
+ do {
+ if (FUN_L00_0025e3b8(*pp) == 0) {
+ if (*(int *)(st + 0x24) & 0x20) {
+ if (*(short *)(st + 0x3E) == 2) {
+ flags |= 0x100;
+ }
+ }
+ } else {
+ FUN_L00_00259bc8((char *)*pp, 1.0f, (int)moby, 0x10000, (moby + 0x10), st);
+ }
+ pp++;
+ } while (--k != 0);
}
- if (FUN_L00_001f0d60_0025c698(FUN_00200240_0025c698(I_25C698(motion, 0x20)) * 0.0009765625f,
- &probe, 0x24, moby)) {
- result |= 2;
- *(V4 *)((u8 *)moby + 0x10) = D_00173E70_0025c698;
- F_25C698(moby, 0x18) -= F_25C698(motion, 0x28);
- FUN_001f9bf8_0025c698(&normal, &D_00173E80_0025c698, 1.0f);
- if (normal.v[2] >= 0.707f) {
- dot = FUN_001f9ab0_0025c698(motion, &normal);
- if (dot < 0.0f) {
- if (D_00173E58_0025c698 == 0 || *(&D_00173E58_0025c698 + 1) > 0) {
- result |= 1;
- H_25C698(motion, 0x3e) = 2;
+
+ sc = 0.0009765625f;
+ t = fast_vec_length(st);
+ if ((float)*(int *)(st + 0x20) * sc < t) {
+ collision_line(eye, v20, 36, moby, 0);
+ qcopy(v20, &D_94C8_60);
+ }
+ if (func_L00_001F10E0_l(v20, convert_integer_to_float(*(int *)(st + 0x20)) * sc, 36, moby) != 0) {
+ flags |= 2;
+ g = &D_L00_00173E70;
+ qcopy((moby + 0x10), g);
+ one = 1.0f;
+ *(float *)(moby + 0x18) = *(float *)(moby + 0x18) - *(float *)(st + 0x28);
+ fast_vec_normalize_c(v40, (char *)g + 0x10, one);
+ if (0.7070000171661377f <= v40[2]) {
+ float e = fast_vec_dot_c(st, v40);
+ if (e < 0.0f) {
+ q = (char *)g - 0x30;
+ if (*(int *)(q + 0x18) == 0 || *(int *)(q + 0x1C) > 0) {
+ flags |= 1;
+ *(short *)(st + 0x3E) = 2;
}
- FUN_001f9bf8_0025c698(&impulse, &normal, dot);
- FUN_001f9a28_0025c698(motion, motion, &impulse);
- if (H_25C698(motion, 0x3e) == 2) {
- float vertical = FUN_001ff3d8_0025c698(motion);
- FUN_L00_0025b868_0025c698(0.0f, F_25C698(motion, 0x10), &vertical);
- FUN_001f9bf8_0025c698(motion, motion, vertical);
+ fast_vec_normalize_c(v50, v40, e);
+ subtract_vector_xyz(st, st, v50);
+ if (*(short *)(st + 0x3E) == 2) {
+ f6c = fast_vec_length(st);
+ approach_value(&f6c, 0.0f, *(float *)(st + 0x10));
+ fast_vec_normalize_c(st, st, f6c);
}
}
} else {
- dot = FUN_001f9ab0_0025c698(motion, &normal);
- if (dot < 0.0f) {
- FUN_001f9bf8_0025c698(&impulse, &normal, dot * -(F_25C698(motion, 0x30) + 1.0f));
- FUN_001f9a68_0025c698(motion, motion, &impulse);
+ float d = fast_vec_dot_c(st, v40);
+ if (d < 0.0f) {
+ d = d * -(*(float *)(st + 0x30) + one);
+ fast_vec_normalize_c(v50, v40, d);
+ add_vector_xyz_c(st, st, v50);
}
}
}
- if (H_25C698(motion, 0x3e) == 0 && F_25C698(motion, 8) < 0.0f)
- H_25C698(motion, 0x3e) = 1;
- return result;
+ if (*(short *)(st + 0x3E) == 0) {
+ if (*(float *)(st + 0x8) < 0.0f) {
+ *(short *)(st + 0x3E) = 1;
+ }
+ }
+ return flags;
}
-#endif
diff --git a/src/overlays/shared/rendering/00269290.c b/src/overlays/shared/rendering/00269290.c
index 455d53a38f..072a4455b1 100644
--- a/src/overlays/shared/rendering/00269290.c
+++ b/src/overlays/shared/rendering/00269290.c
@@ -94,7 +94,7 @@ extern s32 truncate_float_to_s32(f32) __asm__("FUN_001fa6d0");
extern void FUN_001f9a10(void *, void *, void *);
extern void FUN_L00_00267a08(void *);
float absolute_float(float input) __asm__("FUN_001f99c0");
-extern int func_001FA898_r(float) __asm__("FUN_001fa6d0");
+extern int truncate_float_to_s32(float) __asm__("FUN_001fa6d0");
void FUN_L00_002694f8(char *m) {
char *p = m + 0x20;
@@ -167,9 +167,9 @@ void FUN_L00_002694f8(char *m) {
if (d < 8.0f || d > 96.0f)
goto kill;
if (d < 16.0f) {
- k = func_001FA898_r(convert_integer_to_float_c(k) * (d - 8.0f) * 0.125f);
+ k = truncate_float_to_s32(convert_integer_to_float_c(k) * (d - 8.0f) * 0.125f);
} else if (d > 80.0f) {
- k = func_001FA898_r(convert_integer_to_float_c(k) * (96.0f - d) * 0.0625f);
+ k = truncate_float_to_s32(convert_integer_to_float_c(k) * (96.0f - d) * 0.0625f);
}
*(int *)(m + 4) = (k << 24) | (*(int *)(m + 4) & 0xFFFFFF);
if (FUN_001f9770(m + 0xA)) {
@@ -264,7 +264,7 @@ extern f32 convert_integer_to_float(s32) __asm__("func_001FA6C0");
extern int D_L00_001B2094 __attribute__((section(".data")));
extern s32 truncate_float_to_s32(f32) __asm__("func_001FA6D0");
extern void *FUN_L00_002678b8(int);
-extern int func_001FA898_r(float) __asm__("FUN_001fa6d0");
+extern int truncate_float_to_s32(float) __asm__("FUN_001fa6d0");
void FUN_L00_00269b70(void *pos, unsigned char red, unsigned char green, unsigned char blue, int target, float a, float b) {
char *particle;
@@ -275,7 +275,7 @@ void FUN_L00_00269b70(void *pos, unsigned char red, unsigned char green, unsigne
qcopy(particle + 0x10, pos);
*(int *)(particle + 4) = 0x7F000000 | (blue << 16) | (green << 8) | red;
q = (float *)(particle + 0x20);
- particle[9] = func_001FA898_r(4.0f) - 0x60;
+ particle[9] = truncate_float_to_s32(4.0f) - 0x60;
particle[3] = 0x48;
*(float *)(particle + 0xC) = b;
particle[1] = 0;
@@ -657,7 +657,7 @@ extern void FUN_001f9a68(void *, void *, float);
extern void fast_vec_normalize(void *, void *, float) __asm__("FUN_001f9bf8");
extern void FUN_L00_0026a9f0_u(void *, void *, int, int, int, int, int, float, int,
float) __asm__("FUN_L00_0026a9f0");
-extern int func_001FA898_r(float) __asm__("FUN_001fa6d0");
+extern int truncate_float_to_s32(float) __asm__("FUN_001fa6d0");
void FUN_L00_0026ac78(char *m) {
char *p = m + 0x20;
@@ -674,10 +674,10 @@ void FUN_L00_0026ac78(char *m) {
s = 0.6f;
FUN_001f9a68(p, p, s);
}
- if (*(short *)(m + 0xA) == func_001FA898_r((float)(unsigned char)p[0x1B] * 0.85f) &&
+ if (*(short *)(m + 0xA) == truncate_float_to_s32((float)(unsigned char)p[0x1B] * 0.85f) &&
(unsigned char)p[0x1A] < 2 && !(p[0x19] & 4)) {
for (i = 4; i >= 0; i--) {
- int a = func_001FA898_r((float)(unsigned char)p[0x1B] *
+ int a = truncate_float_to_s32((float)(unsigned char)p[0x1B] *
random_float_between_alt(0.9f, 1.1f));
int k = (unsigned char)p[0x18];
float g = random_float_between_alt(0.85f, 1.0f);
@@ -735,8 +735,8 @@ void FUN_L00_0026ac78(char *m) {
}
}
} else {
- int n1 = func_001FA898_r((float)(unsigned char)p[0x1B] * 0.75f) + 1;
- int n2 = func_001FA898_r((float)(unsigned char)p[0x1B] * 0.25f) + 1;
+ int n1 = truncate_float_to_s32((float)(unsigned char)p[0x1B] * 0.75f) + 1;
+ int n2 = truncate_float_to_s32((float)(unsigned char)p[0x1B] * 0.25f) + 1;
int life;
*(float *)(p + 8) += frame_time_sq * 3.0f;
FUN_001f9a10(m + 0x10, m + 0x10, p);
@@ -848,76 +848,62 @@ unsigned char *FUN_L00_0026b230(void *pos, void *vel, unsigned char flags, float
}
return particle;
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L00_0026b500.s", FUN_L00_0026b500);
-#else
-extern void FUN_001f9a10_26b500(void *, void *, void *) __asm__("FUN_001f9a10");
-extern float FUN_001f9af0_26b500(void *) __asm__("FUN_001f9af0");
-extern void FUN_001f9bf8_26b500(void *, void *, float) __asm__("FUN_001f9bf8");
-extern void advance_accelerated_scalar_26b500(float, float, float, float, float *, float *)
- __asm__("FUN_00213f38");
-extern float FUN_001fa6c0_26b500(int) __asm__("FUN_001fa6c0");
-extern int FUN_001fa6e0_26b500(int, int, float) __asm__("FUN_001fa6e0");
-extern int FUN_001f96f8_26b500(int) __asm__("FUN_001f96f8");
-extern int FUN_001f9770_26b500(void *) __asm__("FUN_001f9770");
-extern void FUN_L00_00267a08_26b500(void *) __asm__("FUN_L00_00267a08");
-extern unsigned char D_0013E530_26b500 __asm__("D_0013E530") __attribute__((section(".data")));
-extern float D_L00_001601B8_gp __asm__("D_L00_001601B8") __attribute__((sda));
-extern float D_L00_001601BC_26b500 __asm__("D_L00_001601BC") __attribute__((sda));
-extern float D_L00_001601D8_gp __asm__("D_L00_001601D8") __attribute__((sda));
-extern float D_L00_001601DC_26b500 __asm__("D_L00_001601DC") __attribute__((sda));
-extern float D_L00_001601E8_gp __asm__("D_L00_001601E8") __attribute__((sda));
-extern float D_L00_001601EC_26b500 __asm__("D_L00_001601EC") __attribute__((sda));
+/* per-frame update of a spinning particle: fades, scales and kills it when out of range */
+/* Ported from rac1-decomp (src/overlays/shared/partupd_0026A130.c: func_L00_0026C3A0), where it is exact; names translated to the US level program. */
+
+extern f32 advance_accelerated_scalar(f32 *, f32 *, f32, f32, f32, f32) __asm__("func_00213F38");
+extern f32 fast_vec_length_c(void *) __asm__("func_001F9AF0");
+extern float D_0015ED6C;
+extern float D_0015ED70;
+extern s32 fast_tween_color_c(s32, s32, f32) __asm__("func_001FA6E0");
+extern s32 scale_game_frames_c(s32) __asm__("func_001F96F8");
+extern float D_L00_001601B8 __attribute__((sda));
+extern float D_L00_001601BC __attribute__((sda));
+extern float D_L00_001601D8 __attribute__((sda));
+extern float D_L00_001601DC __attribute__((sda));
+extern float D_L00_001601E8 __attribute__((sda));
+extern float D_L00_001601EC __attribute__((sda));
+extern unsigned char D_0013E05A[];
+extern void add_vector_xyz(void *, void *, void *) __asm__("FUN_001f9a10");
+extern void fast_vec_normalize_c(void *, void *, f32) __asm__("FUN_001f9bf8");
void FUN_L00_0026b500(unsigned char *m) {
unsigned char *p = m + 0x20;
- float rotation;
- float scale = 1.0f;
- float life, duration, start, end;
- float t;
-
- m[8] += p[0x1e];
- if (p[0x1f] & 4)
- scale += FUN_001fa6c0_26b500(D_0013E530_26b500) * 0.5f;
-
- FUN_001f9a10_26b500(m + 0x10, m + 0x10, p);
- rotation = -FUN_001f9af0_26b500(p);
- advance_accelerated_scalar_26b500(0.0f, 0.0f,
- D_L00_001601E8_gp * frame_time_sq,
- rotation, (float *)(p + 0x10), &rotation);
- FUN_001f9bf8_26b500(p, p, -rotation);
- *(float *)(m + 0x18) += D_L00_001601EC_26b500 * frame_time;
-
- life = FUN_001fa6c0_26b500(*(short *)(m + 0xa));
- duration = FUN_001fa6c0_26b500(p[0x1d]);
- t = life / duration;
- end = D_L00_001601B8_gp;
- start = D_L00_001601BC_26b500;
- if (p[0x1f] & 1) {
- end = D_L00_001601D8_gp;
- start = D_L00_001601DC_26b500;
- }
- scale = start * scale;
- *(float *)(m + 0xc) = ((end - scale) * t + scale) * 210000.0f;
- *(int *)(m + 4) = FUN_001fa6e0_26b500(*(int *)(p + 0x18), *(int *)(p + 0x14), t);
- if (*(short *)(m + 0xa) < FUN_001f96f8_26b500(15)) {
- int color;
- life = FUN_001fa6c0_26b500(*(short *)(m + 0xa));
- duration = FUN_001fa6c0_26b500(FUN_001f96f8_26b500(10));
- color = *(int *)(m + 4);
- *(int *)(m + 4) = FUN_001fa6e0_26b500(color & 0xffffff, color, life / duration);
- }
-
- if (*(float *)(m + 0x10) < 2.0f || 1021.0f < *(float *)(m + 0x10) ||
- *(float *)(m + 0x14) < 2.0f || 1021.0f < *(float *)(m + 0x14) ||
- *(float *)(m + 0x18) < 2.0f || 1021.0f < *(float *)(m + 0x18) ||
- FUN_001f9770_26b500(m + 0xa)) {
- FUN_L00_00267a08_26b500(m);
+ float r;
+ float w = 1.0f;
+ float ratio;
+ m[8] = m[8] + p[0x1E];
+ if (p[0x1F] & 4) {
+ w = convert_integer_to_float(D_0013E05A[0x4D6]) * 0.5f + w;
+ }
+ add_vector_xyz(m + 0x10, m + 0x10, p);
+ r = -fast_vec_length_c(p);
+ advance_accelerated_scalar((float *)(m + 0x30), &r, 0.0f, 0.0f, D_L00_001601E8 * D_0015ED70, r);
+ fast_vec_normalize_c(p, p, -r);
+ *(float *)(m + 0x18) = *(float *)(m + 0x18) + D_L00_001601EC * D_0015ED6C;
+ ratio = convert_integer_to_float(*(short *)(m + 0xA)) / convert_integer_to_float(p[0x1D]);
+ if (p[0x1F] & 1) {
+ float lo = D_L00_001601DC * w;
+ *(float *)(m + 0xC) = ((D_L00_001601D8 - lo) * ratio + lo) * 210000.0f;
+ } else {
+ float lo = D_L00_001601BC * w;
+ *(float *)(m + 0xC) = ((D_L00_001601B8 - lo) * ratio + lo) * 210000.0f;
+ }
+ *(int *)(m + 4) = fast_tween_color_c(*(int *)(p + 0x18), *(int *)(p + 0x14), ratio);
+ if (*(short *)(m + 0xA) < scale_game_frames_c(15)) {
+ float q = convert_integer_to_float(*(short *)(m + 0xA));
+ float t = q / convert_integer_to_float(scale_game_frames_c(10));
+ *(int *)(m + 4) = fast_tween_color_c(*(int *)(m + 4) & 0xFFFFFF, *(int *)(m + 4), t);
+ }
+ if (*(float *)(m + 0x10) < 2.0f || *(float *)(m + 0x10) > 1021.0f ||
+ *(float *)(m + 0x14) < 2.0f || *(float *)(m + 0x14) > 1021.0f ||
+ *(float *)(m + 0x18) < 2.0f || *(float *)(m + 0x18) > 1021.0f ||
+ FUN_001f9770(m + 0xA) != 0) {
+ FUN_L00_00267a08(m);
} else if (*(float *)(p + 0x10) < 0.01f) {
- *(short *)(m + 0xa) -= 1;
+ *(short *)(m + 0xA) = *(short *)(m + 0xA) - 1;
}
}
-#endif
unsigned char *FUN_L00_002678b8_26b790(int) __asm__("FUN_L00_002678b8");
int FUN_001fa6d0_26b790(float) __asm__("FUN_001fa6d0");
float FUN_L00_00257c48_26b790(float, float) __asm__("FUN_L00_00257c48");
@@ -1492,7 +1478,7 @@ char *FUN_L00_0026cbb0(void *pos, void *dir, int c, int d, int n, int k, float f
if (p) {
qcopy(p + 0x10, pos);
*(int *)(p + 4) = c;
- v = func_001FA898_r(4.0f) - 0x60;
+ v = truncate_float_to_s32(4.0f) - 0x60;
p[1] = 0;
*(float *)(p + 0xC) = f;
p[3] = 0x48;
@@ -3025,7 +3011,7 @@ typedef struct {
s32 f14;
s32 f18;
f32 f1C;
- s32 f20;
+ s32 unk20;
char pad[0xC];
} S_26ff10;
@@ -3123,7 +3109,7 @@ void FUN_L00_0026ff10(Moby_26ff10 *p) {
c.v_26ff10.q_26ff10 = *(U128 *)pv;
if (fl & 0x40)
FUN_001f99f8_26ff10(&c);
- c.f20 = 1;
+ c.unk20 = 1;
col = pv->f1C;
aux = &c;
pa = v1u.f;
@@ -3236,7 +3222,7 @@ void *FUN_L00_00270758(char *a, char *b, unsigned char c, int d) {
qcopy(p + 0x10, a);
qcopy(q, b);
*(int *)(p + 4) = FUN_L00_0025bfe0(0.7f, 0.7f, 0.7f, 0.08f);
- p[9] = (char)(func_001FA898_r(4.0f) + 0x40);
+ p[9] = (char)(truncate_float_to_s32(4.0f) + 0x40);
p[1] = 0;
p[3] = 0x44;
f = random_float_between_alt(0.0f, 1.0f);
@@ -3401,11 +3387,11 @@ void FUN_L00_00270948(M_270948 *m) {
e->v.f[1] *= 0.95f;
}
{
- u8 f2 = e->b18;
+ u8 flags = e->b18;
s = -1.0f;
- if (f2 & 1)
+ if (flags & 1)
s = 1.0f;
- if (f2 & 8) {
+ if (flags & 8) {
e->v.f[2] += frame_scale_sq * 0.008f;
e->x10 += s * (D_0015ED60 * -0.01f) / FUN_001fa6c0_c(e->h16);
} else {
diff --git a/src/overlays/shared/rendering/002712b8.c b/src/overlays/shared/rendering/002712b8.c
index 7a3d91e503..8f7d95e6d4 100644
--- a/src/overlays/shared/rendering/002712b8.c
+++ b/src/overlays/shared/rendering/002712b8.c
@@ -495,7 +495,7 @@ void FUN_L00_0025a9f8_272438(void *, void *, void *, int, void *, int, int, int,
float) __asm__("FUN_L00_0025a9f8");
typedef struct {
int i0;
- float f4, f8, fc;
+ float unk4, unk8, fc;
int i10;
void *p14;
} Q_272438;
@@ -507,8 +507,8 @@ void FUN_L00_00272438(unsigned char *m) {
float x, y;
int r;
old = *pos;
- q->f4 += q->f8;
- FUN_L00_00262360_272438(q->i0, &x, &y, pos, q->f4, q->fc);
+ q->unk4 += q->unk8;
+ FUN_L00_00262360_272438(q->i0, &x, &y, pos, q->unk4, q->fc);
if (fast_dec_timer(m + 0xA)) {
free_effect_particle(m);
return;
@@ -541,7 +541,7 @@ typedef struct {
s32 wC;
u8 v10[16];
u8 v20[12];
- f32 f2C;
+ f32 unk2C;
S_2725d8 s;
} P_2725d8;
extern u8 *D_L00_001B215C __attribute__((section(".data")));
@@ -563,7 +563,7 @@ P_2725d8 *FUN_L00_002725d8(u8 *a0, u8 *a1, s32 a2, s32 a3, f32 a4, f32 a5) {
p->b2 = *D_L00_001B215C;
add_vector_xyz_cf(a0, a1, p->v10);
qcopy(p->v20, p->v10);
- p->f2C = a5;
+ p->unk2C = a5;
*(f32 *)((u8 *)p + 0x1C) = a4;
s = &p->s;
p->s.o = a0;
@@ -584,7 +584,7 @@ typedef struct {
u8 pad0[0x10];
u128_2726d8 pos;
u8 pad20[0xC];
- f32 f2C;
+ f32 unk2C;
Q_2726d8 q;
} P_2726d8;
void FUN_L00_00267a08(void *);
@@ -604,7 +604,7 @@ void FUN_L00_002726d8(P_2726d8 *p) {
return;
}
sc = q->xC * random_float_between(0.5f, 1.0f);
- save = p->f2C;
+ save = p->unk2C;
qcopy(&t, &p->pos);
moby_point_position(p->q.owner, q->x4, &p->pos);
FUN_001f9a28(&t, &t, &p->pos);
@@ -617,7 +617,7 @@ void FUN_L00_002726d8(P_2726d8 *p) {
fast_vec_normalize(&t, &t, f);
FUN_001f9a10((u8 *)p + 0x20, &p->pos, &t);
*(f32 *)((u8 *)p + 0x1C) = sc;
- p->f2C = save;
+ p->unk2C = save;
}
void fast_vec_scale(void *, void *, f32) __asm__("FUN_001f9a68");
void FUN_001f9a10(void *, void *, void *);
@@ -706,11 +706,11 @@ unsigned char *FUN_L00_002729c8(void *pos, unsigned char a, unsigned char b, uns
typedef float V_272bc0[4] __attribute__((aligned(16)));
typedef struct {
char p0[0x88];
- float f88;
+ float unk88;
char p1[0x2080 - 0x8C];
int i2080;
} P_272bc0;
-extern V_272bc0 D_0013F3D0_272bc0 __asm__("D_0013F3D0") __attribute__((section(".data")));
+extern char D_0013F3D0[] __attribute__((section(".data")));
extern unsigned char *D_L00_0016016C_272bc0 __asm__("D_L00_0016016C");
extern float FUN_001fa6c0_272bc0(int) __asm__("FUN_001fa6c0");
extern int fast_tween_color(float, int, int) __asm__("FUN_001fa6e0");
@@ -766,10 +766,10 @@ void FUN_L00_00272bc0(unsigned char *p) {
if (fast_dec_timer(p + 0xA)) {
free_effect_particle(p);
}
- c = (unsigned char *)D_0013F3D0_272bc0;
+ c = (unsigned char *)(*(V_272bc0 *)D_0013F3D0);
if (vector_distance(p + 0x10, c) < 0.3f) {
g = (P_272bc0 *)(c - 0x80);
- if (g->f88 < *(float *)(p + 0x18) + 1.2f) {
+ if (g->unk88 < *(float *)(p + 0x18) + 1.2f) {
subtract_vector_xyz(t, c, p + 0x10);
normalize_vector_xyz(t, t, 1.0f);
t[2] = 1.0f;
@@ -801,7 +801,7 @@ void FUN_L00_00272bc0(unsigned char *p) {
break;
}
}
-extern char D_0013F3D0_00272f68[] __asm__("D_0013F3D0") __attribute__((section(".data")));
+extern char D_0013F3D0[] __attribute__((section(".data")));
int FUN_001fa6d0_00272f68(float) __asm__("FUN_001fa6d0");
extern unsigned char *D_L00_001B2080_lui[] __asm__("D_L00_001B2080") __attribute__((section(".data")));
unsigned char *FUN_L00_00272f68(u128 *a, int c, unsigned char b, int idx, int flag, int n, int mode,
@@ -811,7 +811,7 @@ unsigned char *FUN_L00_00272f68(u128 *a, int c, unsigned char b, int idx, int fl
int *e = (int *)(m + 0x20);
e[4] = mode;
if (mode == 1)
- subtract_vector_xyz(e, a, D_0013F3D0_00272f68);
+ subtract_vector_xyz(e, a, D_0013F3D0);
qcopy(m + 0x10, a);
*(int *)(m + 4) = c;
m[9] = FUN_001fa6d0_00272f68(1.0f) + 0x20;
@@ -876,7 +876,7 @@ typedef struct {
u8 b8;
u8 p9;
s16 hA;
- f32 fC;
+ f32 unkC;
f32 x, y, z;
} Part_273298;
typedef struct {
@@ -922,24 +922,24 @@ typedef struct {
} T_273448;
typedef struct {
T_273448 *m;
- f32 f4;
- f32 f8;
+ f32 unk4;
+ f32 unk8;
s16 hC;
s16 hE;
- f32 f10;
- f32 f14;
+ f32 unk10;
+ f32 unk14;
} E_273448;
typedef struct {
u8 b0, b1, b2, b3;
u32 w4;
u8 b8, b9;
s16 hA;
- f32 fC;
+ f32 unkC;
f32 pos[4] __attribute__((aligned(16)));
E_273448 e;
} P_273448;
extern u8 *tab_273448 __asm__("D_L00_001B2174") __attribute__((section(".data")));
-extern f32 org_273448[4] __asm__("D_L00_00166DC0") __attribute__((section(".data")));
+extern float g_debug_camera[4] __asm__("D_L00_00166DC0") __attribute__((section(".data")));
extern s32 tick_273448(void *) __asm__("FUN_001f9770");
extern s32 truncate_float_to_s32(f32) __asm__("FUN_001fa6d0");
extern void pos_273448(void *, s32, void *) __asm__("FUN_L00_0024f7c8");
@@ -958,31 +958,31 @@ void FUN_L00_00273448(P_273448 *p) {
goto kill;
}
e->hC = (e->hC + 1) & 0xF;
- if (p->fC < 159600.0f) {
- p->fC += frame_scale * 3989.99976f;
- if (159600.0f < p->fC) {
- p->fC = 159600.0f;
+ if (p->unkC < 159600.0f) {
+ p->unkC += frame_scale * 3989.99976f;
+ if (159600.0f < p->unkC) {
+ p->unkC = 159600.0f;
}
- } else if (159600.0f < p->fC) {
- p->fC -= frame_scale * 15959.999f;
- if (p->fC < 159600.0f) {
- p->fC = 159600.0f;
+ } else if (159600.0f < p->unkC) {
+ p->unkC -= frame_scale * 15959.999f;
+ if (p->unkC < 159600.0f) {
+ p->unkC = 159600.0f;
}
}
- e->f8 += frame_scale * 0.001f;
- p->b8 = truncate_float_to_s32(e->f8 * 255.0f);
+ e->unk8 += frame_scale * 0.001f;
+ p->b8 = truncate_float_to_s32(e->unk8 * 255.0f);
p->b2 = tab_273448[e->hC];
- if (p->fC <= 159600.0f || 0.0f < e->f10) {
- f32 *q = &e->f4;
+ if (p->unkC <= 159600.0f || 0.0f < e->unk10) {
+ f32 *q = &e->unk4;
*q += q[3];
}
{
f32 x;
- if (p->fC <= 159600.0f) {
- x = e->f4;
+ if (p->unkC <= 159600.0f) {
+ x = e->unk4;
lim = 0.3f;
} else {
- x = e->f4;
+ x = e->unk4;
lim = 0.15f;
}
if (!(lim < x)) {
@@ -992,15 +992,15 @@ void FUN_L00_00273448(P_273448 *p) {
return;
}
} else {
- e->f10 = -e->f10;
- e->f4 = x + e->f10;
+ e->unk10 = -e->unk10;
+ e->unk4 = x + e->unk10;
}
}
- p->w4 = (p->w4 & 0xFFFFFF) + (truncate_float_to_s32(e->f4 * 256.0f) << 24);
- e->f14 += (1.0f - e->f14) * (frame_scale * 0.175f);
+ p->w4 = (p->w4 & 0xFFFFFF) + (truncate_float_to_s32(e->unk4 * 256.0f) << 24);
+ e->unk14 += (1.0f - e->unk14) * (frame_scale * 0.175f);
pos_273448(e->m, e->hE, a);
- subtract_vector_xyz(v, org_273448, a);
- vscl_273448(v, v, e->f14);
+ subtract_vector_xyz(v, g_debug_camera, a);
+ vscl_273448(v, v, e->unk14);
vadd_273448(p->pos, a, v);
}
/* Ported from rac1-decomp (src/overlays/shared/partupd_00272158.c: func_L00_002745A8), where it is exact; names translated to the US level program. */
@@ -1180,7 +1180,7 @@ void FUN_L00_00273a68(struct EmberParticle *p) {
}
FUN_L00_00267a08(p);
}
-extern u128 D_L00_00173E60_273ee0[] __asm__("D_L00_00173E60") __attribute__((section(".data")));
+extern V00271d20 D_L00_00173E60 __attribute__((section(".data")));
void FUN_001f9a10_273ee0(void *, void *, void *) __asm__("FUN_001f9a10");
int collision_line(void *, void *, int, void *, int) __asm__("FUN_001efa68");
void clear_u64_value(void *) __asm__("FUN_001f99f8");
@@ -1198,7 +1198,7 @@ void FUN_L00_00273ee0(unsigned char *o) {
FUN_001f9a10_273ee0(out, b, c);
if (*(float *)(o + 0x20) != 0.0f || c[1] != 0.0f || c[2] != 0.0f) {
if (collision_line(o + 0x10, out, 2, o, 0)) {
- *(u128 *)(o + 0x10) = D_L00_00173E60_273ee0[0];
+ *(u128 *)(o + 0x10) = ((u128 *)&D_L00_00173E60)[0];
clear_u64_value(c);
*(float *)(o + 0xC) += *(float *)(o + 0xC);
} else {
@@ -1332,10 +1332,10 @@ typedef struct {
f32 x, y, z, w;
} __attribute__((aligned(16))) V_274518;
typedef struct {
- f32 f0, f4, f8;
+ f32 unk0, unk4, unk8;
u8 *iC;
- f32 f10;
- f32 f14;
+ f32 unk10;
+ f32 unk14;
s16 h18;
s16 h1A;
s16 h1C;
@@ -1375,9 +1375,9 @@ void FUN_L00_00274518(M_274518 *m) {
goto kill;
if (r->iC == 0)
return;
- a.x = m->r.f0;
- a.y = r->f4;
- a.z = r->f8;
+ a.x = m->r.unk0;
+ a.y = r->unk4;
+ a.z = r->unk8;
FUN_001f9a68_274518(&a, &a, convert_integer_to_float(r->h18));
FUN_001f9a10_274518(m->v10, r->iC + 0x10, &a);
return;
@@ -1395,9 +1395,9 @@ void FUN_L00_00274518(M_274518 *m) {
z = 0.0f;
FUN_L00_002743a8_274518(0, m->v10, FUN_001f96f8_274518(10), z, z, 0, m->b7, 0);
} else {
- a.x = r->f0;
- a.y = r->f4;
- a.z = r->f8;
+ a.x = r->unk0;
+ a.y = r->unk4;
+ a.z = r->unk8;
z = 0.0f;
p = FUN_L00_002743a8_274518((s32)r->iC, m->v10, FUN_001f96f8_274518(10), z, z, 0, m->b7,
&a);
@@ -1408,32 +1408,32 @@ void FUN_L00_00274518(M_274518 *m) {
return;
qcopy(m->v10, r->iC + 0x10);
k1 = 2.25f;
- a.x = FUN_001f9dc8_274518(r->f10) * k1;
+ a.x = FUN_001f9dc8_274518(r->unk10) * k1;
k2 = 0.28f;
- a.y = FUN_001f9de0_274518(r->f10) * k1;
+ a.y = FUN_001f9de0_274518(r->unk10) * k1;
a.z = a.x;
a.x = 0.0f;
- b.x = FUN_001f9dc8_274518(r->f14) * k2;
- b.y = FUN_001f9de0_274518(r->f14) * k2;
+ b.x = FUN_001f9dc8_274518(r->unk14) * k2;
+ b.y = FUN_001f9de0_274518(r->unk14) * k2;
b.z = b.x;
b.x = 0.0f;
clear_u64_value(&c);
- c.y = r->f10;
+ c.y = r->unk10;
rotation_matrix(mat, &c);
transform_vector(&b, &b, mat);
FUN_001f9a10_274518(&a, &a, &b);
FUN_001f9cf8_274518(&a, &a, r->iC + 0xC0);
FUN_001f9a10_274518(m->v10, m->v10, &a);
- r->f10 = fast_add_rotations(r->f10, frame_time * 0.9599310755729675f);
- r->f14 = fast_add_rotations(r->f14, frame_time * 4.363323211669922f);
+ r->unk10 = fast_add_rotations(r->unk10, frame_time * 0.9599310755729675f);
+ r->unk14 = fast_add_rotations(r->unk14, frame_time * 4.363323211669922f);
}
typedef struct {
void *o;
u8 b4;
u8 b5;
s16 h6;
- float f8;
- float fC;
+ float unk8;
+ float unkC;
} S_274818;
extern float FUN_002132a8_274818(float, float) __asm__("FUN_002132a8");
extern void FUN_L00_0024f7c8_274818(void *, int, void *) __asm__("FUN_L00_0024f7c8");
@@ -1454,13 +1454,13 @@ void FUN_L00_00274818(char *p) {
}
v = p + 0x10;
one = 1.0f;
- f = s->f8 * FUN_002132a8_274818(0.05f, one);
+ f = s->unk8 * FUN_002132a8_274818(0.05f, one);
save = *(float *)(p + 0x2C);
FUN_L00_0024f7c8_274818(s->o, s->b4, v);
FUN_0020cca8_274818(s->o, s->b4, a);
x = FUN_001fa6c0_274818(s->b5);
x = FUN_002132a8_274818(-x, x);
- normalize_vector_xyz(&b, a, (x / 100.0f - one) * s->fC);
+ normalize_vector_xyz(&b, a, (x / 100.0f - one) * s->unkC);
FUN_001f9a10_274818(p + 0x20, v, &b);
*(float *)(p + 0x1C) = f;
*(float *)(p + 0x2C) = save;
@@ -1606,7 +1606,7 @@ typedef struct {
V_274e48 v10;
R_274e48 r;
} M_274e48;
-extern V_274e48 D_0013F420_274e48 __asm__("D_0013F420");
+extern float D_0013F420[];
f32 distance_xyz(void *, void *) __asm__("FUN_001f9b48");
f32 vector_length_xyz(void *) __asm__("FUN_001f9af0");
void FUN_001f9bf8_274e48(void *, void *, f32) __asm__("FUN_001f9bf8");
@@ -1623,7 +1623,7 @@ void FUN_L00_00274e48(M_274e48 *m) {
s32 c;
if (D_L00_0015F5CC & 1)
m->b8++;
- d = distance_xyz(&m->v10, &D_0013F420_274e48);
+ d = distance_xyz(&m->v10, &(*(V_274e48 *)D_0013F420));
if (d < 5.0f && 0.0f < r->p18[2]) {
subtract_vector_xyz(&a, r->p18, &m->v10);
if (0.5f < vector_length_xyz(&a)) {
@@ -1678,7 +1678,7 @@ typedef struct {
int n;
int i14;
int i18;
- float f1C;
+ float unk1C;
} Q_275158;
extern unsigned char *D_L00_001B21A0 __attribute__((section(".data")));
@@ -1704,9 +1704,9 @@ unsigned char *FUN_L00_00275158(void *a, void *b, int n, float f) {
q->i14 = 0;
q->i18 = FUN_00213260_275158(0xC) - 6;
((float *)q)[3] = f;
- q->f1C = *(float *)(m + 0xC) * 0.1f;
+ q->unk1C = *(float *)(m + 0xC) * 0.1f;
if (n >= 0) {
- q->f1C = *(float *)(m + 0xC) * 0.05f;
+ q->unk1C = *(float *)(m + 0xC) * 0.05f;
if (FUN_00213260_275158(0x1E) == 0) {
q->i14 = -0x28;
} else if (FUN_00213260_275158(0x1E) == 0) {
@@ -1963,80 +1963,72 @@ unsigned char *FUN_L00_00275910(OvlQuad *pos, int s, int col, int mode, int b, f
}
return m;
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L00_00275aa0.s", FUN_L00_00275aa0);
-#else
-extern float FUN_001fa6c0_275aa0(int) __asm__("FUN_001fa6c0");
-extern int FUN_001fa6d0_275aa0(float) __asm__("FUN_001fa6d0");
-extern void FUN_001f9a10_275aa0(void *, void *, void *) __asm__("FUN_001f9a10");
-extern void cross_vectors_xyz(void *, void *, void *) __asm__("FUN_001f9ad8");
-extern float FUN_001f9af0_275aa0(void *) __asm__("FUN_001f9af0");
-extern float D_0015964C_275aa0 __asm__("D_0015964C") __attribute__((section(".sdata")));
-
-void FUN_L00_00275aa0(unsigned char *m) {
- unsigned char *q = m + 0x20;
- float v[4];
- float d[4];
- float t[4];
- float f;
- float alpha;
- int h;
- int originalAlpha;
- float *velocity;
-
- m[8] += q[0xa];
- h = *(short *)(q + 8);
- if (h - *(short *)(m + 0xa) < 6) {
- f = (float)(h - *(short *)(m + 0xa)) / 5.0f;
- *(float *)(m + 0xc) = *(float *)(q + 4) +
- ((*(float *)q + *(float *)(q + 4)) * 0.5f - *(float *)(q + 4)) * f;
- originalAlpha = q[0xb];
- h = originalAlpha;
- h = (unsigned int)h >> 1;
- h -= originalAlpha;
- alpha = (float)h;
- alpha *= f;
- f = (float)originalAlpha + alpha;
- alpha = f;
+/* Ported from rac1-decomp (src/overlays/shared/partupd_00272158.c: func_L00_00276940), where it is exact; names translated to the US level program. */
+
+extern f32 fast_vec_length(void *) __asm__("func_001F9AF0");
+extern s32 truncate_float_to_s32_c(f32) __asm__("func_001FA6D0");
+extern short D_L00_0016024C __attribute__((sda));
+extern char D_0013F5E0[] __attribute__((section(".data")) );
+extern void add_vector_xyz_c(void *, void *, void *) __asm__("FUN_001f9a10");
+extern void cross_vectors_xyz(void *, void *, void *) __asm__("func_001F9AD8");
+extern void fast_vec_normalize_c(void *, void *, f32) __asm__("FUN_001f9bf8");
+
+static __inline__ void vcopy_276940(float *d, float *s) {
+ d[0] = s[0];
+ d[1] = s[1];
+ d[2] = s[2];
+ *(int *)&d[3] = 0;
+}
+
+void FUN_L00_00275aa0(char *m) {
+ char *v = m + 0x20;
+ char *p;
+ float f4;
+ float a[4] __attribute__((aligned(16)));
+ float d[4] __attribute__((aligned(16)));
+ float e[4] __attribute__((aligned(16)));
+ float *w;
+ int al;
+ m[8] += v[0xA];
+ if (*(short *)(v + 8) - *(short *)(m + 0xA) < 6) {
+ int c;
+ int c2;
+ f4 = (float)(*(short *)(v + 8) - *(short *)(m + 0xA)) / 5.0f;
+ *(float *)(m + 0xC) = *(float *)(v + 4) + ((*(float *)(m + 0x20) + *(float *)(v + 4)) * 0.5f - *(float *)(v + 4)) * f4;
+ c2 = (unsigned char)v[0xB] >> 1;
+ c = (unsigned char)v[0xB];
+ al = truncate_float_to_s32_c((float)c + (float)(c2 - c) * f4);
} else {
- f = (float)*(short *)(m + 0xa) / FUN_001fa6c0_275aa0(h - 6);
- *(float *)(m + 0xc) = *(float *)q +
- ((*(float *)q + *(float *)(q + 4)) * 0.5f - *(float *)q) * f;
- alpha = (float)(q[0xb] >> 1);
- alpha *= f;
- alpha += 0.0f;
- }
- h = FUN_001fa6d0_275aa0(alpha);
- originalAlpha = *(int *)(m + 4);
- originalAlpha &= 0xffffff;
- h = (h << 24) | originalAlpha;
- *(int *)(m + 4) = h;
- velocity = (float *)(q + 0xc);
- *(volatile float *)&v[0] = *(volatile float *)(q + 0xc);
- *(volatile float *)&v[1] = *(volatile float *)(q + 0x10);
- v[2] = *(float *)(q + 0x14);
- *(volatile int *)&v[3] = 0;
- FUN_001f9a10_275aa0(m + 0x10, m + 0x10, v);
- if (*(int *)(q + 0x18)) {
- subtract_vector_xyz(d, (char *)*(int *)(q + 0x18) + 0x10, m + 0x10);
+ f4 = (float)*(short *)(m + 0xA) / convert_integer_to_float(*(short *)(v + 8) - 6);
+ *(float *)(m + 0xC) = *(float *)(m + 0x20) + ((*(float *)(m + 0x20) + *(float *)(v + 4)) * 0.5f - *(float *)(m + 0x20)) * f4;
+ al = truncate_float_to_s32_c((float)((unsigned char)v[0xB] >> 1) * f4 + 0.0f);
+ }
+ p = m + 0x10;
+ *(int *)(m + 4) = (al << 24) | (*(int *)(m + 4) & 0xFFFFFF);
+ vcopy_276940(a, (float *)(v + 0xC));
+ add_vector_xyz_c(p, p, a);
+ if (*(int *)(v + 0x18) != 0) {
+ subtract_vector_xyz(d, *(char **)(v + 0x18) + 0x10, p);
if (d[0] <= 2.0f && d[1] <= 2.0f) {
- cross_vectors_xyz(t, d, hero.gravity_dir.f);
- normalize_vector_xyz(t, t, D_0015964C_275aa0);
- FUN_001f9a10_275aa0(m + 0x10, m + 0x10, t);
- if (d[0] <= 0.5f && d[1] <= 0.5f)
- normalize_vector_xyz(v, d, 0.03f);
- else
- normalize_vector_xyz(v, d, FUN_001f9af0_275aa0(v));
- v[2] += 0.02f;
- *(float *)(q + 0xc) = v[0];
- velocity[1] = v[1];
- velocity[2] = v[2];
+ cross_vectors_xyz(e, d, ((unsigned char *)D_0013F5E0));
+ fast_vec_normalize_c(e, e, *(float *)&D_L00_0016024C);
+ add_vector_xyz_c(p, p, e);
+ if (d[0] <= 0.5f && d[1] <= 0.5f) {
+ fast_vec_normalize_c(a, d, 0.03f);
+ } else {
+ fast_vec_normalize_c(a, d, fast_vec_length(a));
+ }
+ w = (float *)(v + 0xC);
+ *(float *)(v + 0xC) = a[0];
+ w[1] = a[1];
+ a[2] = a[2] + 0.02f;
+ w[2] = a[2];
}
}
- if (fast_dec_timer(m + 0xa))
- free_effect_particle(m);
+ if (FUN_001f9770(m + 0xA)) {
+ FUN_L00_00267a08(m);
+ }
}
-#endif
extern float FUN_001fa6c0(int);
void FUN_L00_00275d68(unsigned char *m) {
@@ -2074,10 +2066,10 @@ typedef struct {
u8 b8;
u8 p9;
s16 hA;
- f32 fC;
- f32 f10;
- f32 f14;
- f32 f18;
+ f32 unkC;
+ f32 unk10;
+ f32 unk14;
+ f32 unk18;
u8 p1C[4];
int w20;
} Part_275eb0;
@@ -2085,17 +2077,17 @@ int FUN_001f9770_00275eb0(s16 *) __asm__("FUN_001f9770");
u32 FUN_001fa6e0_00275eb0(u32, u32, f32) __asm__("FUN_001fa6e0");
void FUN_L00_00275eb0(Part_275eb0 *p) {
float a;
- if (p->f10 < 2.0f || 1021.0f < p->f10 || p->f14 < 2.0f || 1021.0f < p->f14 || p->f18 < 2.0f ||
- 1021.0f < p->f18 || FUN_001f9770_00275eb0(&p->hA)) {
+ if (p->unk10 < 2.0f || 1021.0f < p->unk10 || p->unk14 < 2.0f || 1021.0f < p->unk14 || p->unk18 < 2.0f ||
+ 1021.0f < p->unk18 || FUN_001f9770_00275eb0(&p->hA)) {
free_effect_particle(p);
return;
}
if (p->w20) {
- p->fC *= 0.99f;
+ p->unkC *= 0.99f;
a = convert_integer_to_float(p->hA - 1);
p->w4 = FUN_001fa6e0_00275eb0(0x30FFFFFF, p->w4, a / convert_integer_to_float(p->hA));
} else {
- p->fC *= 0.95f;
+ p->unkC *= 0.95f;
a = convert_integer_to_float(p->hA - 1);
p->w4 = FUN_001fa6e0_00275eb0(0x603F1008, p->w4, a / convert_integer_to_float(p->hA));
}
diff --git a/src/overlays/shared/ui/fonts/001fc558.c b/src/overlays/shared/ui/fonts/001fc558.c
index 7cac120e3d..9e78337f09 100644
--- a/src/overlays/shared/ui/fonts/001fc558.c
+++ b/src/overlays/shared/ui/fonts/001fc558.c
@@ -2,56 +2,56 @@
#include "types.h"
#include "asm.h"
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L00_001fc558.s", FUN_L00_001fc558);
-#else
-extern s32 frame_size[] __asm__("D_0013E504");
-extern s32 draw_buffer_address __asm__("D_0015EE84");
-extern u8 *D_L00_001611C0;
-void FUN_L00_002a0d90(void);
+/* Ported from rac1-decomp (src/game/draw.c: func_001F7680), where it is exact; names translated to the US level program. */
-void FUN_L00_001fc558(u32 source) {
- s32 remaining = frame_size[0];
- s32 destination = draw_buffer_address >> 8;
- u64 count;
- u64 transfer;
- u8 *packet;
- u64 *words;
+extern unsigned char *D_L00_001611C0;
+extern int frame_size[] __asm__("D_0013E504");
+extern int draw_buffer_address __asm__("D_0015EE84");
+extern void vu1_tex_flush(void) __asm__("func_00233B68");
+
+#define PK ((unsigned char *)(*(int * *)&D_L00_001611C0))
+
+void FUN_L00_001fc558(unsigned int source) {
+ int remaining = frame_size[0];
+ int destination = draw_buffer_address >> 8;
+ unsigned long count;
+ unsigned long transfer;
+ unsigned char *packet;
+ unsigned long *words;
do {
- count = (s64)remaining;
+ count = (long)remaining;
if (count > 0x80)
count = 0x80;
- *(u32 *)(D_L00_001611C0 + 0) = 0x10000006;
+ *(unsigned int *)(PK + 0) = 0x10000006;
remaining -= 0x80;
- *(u32 *)(D_L00_001611C0 + 4) = 0;
- *(u32 *)(D_L00_001611C0 + 8) = 0;
- *(u32 *)(D_L00_001611C0 + 12) = 0x50000006;
- packet = D_L00_001611C0;
- D_L00_001611C0 = packet + 0x10;
- transfer = (u64)count << 7;
- words = (u64 *)(packet + 0x10);
- words[0] = 0x4000000000000001ULL;
+ *(unsigned int *)(PK + 4) = 0;
+ *(unsigned int *)(PK + 8) = 0;
+ *(unsigned int *)(PK + 12) = 0x50000006;
+ packet = PK;
+ (*(int * *)&D_L00_001611C0) = (int *)(packet + 0x10);
+ transfer = (unsigned long)count << 7;
+ words = (unsigned long *)(packet + 0x10);
+ words[0] = 0x4000000000000001UL;
words[1] = 0x0eeeeeee;
- words[2] = ((u64)(u32)destination << 32) | 0x8000000000000ULL;
+ words[2] = ((unsigned long)(unsigned int)destination << 32) | 0x8000000000000UL;
words[3] = 0x50;
words[4] = 0;
words[5] = 0x51;
- words[6] = ((u64)count << 32) | 0x200;
+ words[6] = ((unsigned long)count << 32) | 0x200;
words[7] = 0x52;
words[8] = 0;
words[9] = 0x53;
- words[10] = transfer | 0x0800000000008000ULL;
+ words[10] = transfer | 0x0800000000008000UL;
words[11] = 0;
- destination += (s32)((count << 35) >> 32);
- D_L00_001611C0 = packet + 0x70;
- *(u32 *)(packet + 0x70) = (u32)(s64)(s32)(transfer | 0x30000000);
- *(u32 *)(D_L00_001611C0 + 4) = source;
- source += (s32)(count * 0x800);
- *(u32 *)(D_L00_001611C0 + 8) = 0;
- *(u32 *)(D_L00_001611C0 + 12) = (u32)transfer | 0x50000000;
- D_L00_001611C0 += 0x10;
+ (*(int * *)&D_L00_001611C0) = (int *)(packet + 0x70);
+ *(unsigned int *)(packet + 0x70) = (unsigned int)(long)(int)(transfer | 0x30000000);
+ *(unsigned int *)(PK + 4) = source;
+ source += (int)(count * 0x800);
+ destination += (int)(count * 8);
+ *(unsigned int *)(PK + 8) = 0;
+ *(unsigned int *)(PK + 12) = (unsigned int)transfer | 0x50000000;
+ (*(int * *)&D_L00_001611C0) = (int *)(PK + 0x10);
} while (remaining > 0);
- FUN_L00_002a0d90();
+ vu1_tex_flush();
}
-#endif /* NON_MATCHING */
diff --git a/src/overlays/shared/ui/help/00237488.c b/src/overlays/shared/ui/help/00237488.c
index 5cf7ac09e3..023fa3bffa 100644
--- a/src/overlays/shared/ui/help/00237488.c
+++ b/src/overlays/shared/ui/help/00237488.c
@@ -67,7 +67,7 @@ int FUN_L05_0023b378(int id, float *out) {
typedef struct {
char pad[0x20];
- int f20;
+ int unk20;
char pad2[0x28];
} ItemDef;
@@ -275,7 +275,7 @@ void FUN_L05_0023dc88(int i) {
((int *)(D_00141660))[i] = w;
g->selected_item[i] = w;
if (i == 0) {
- D_L05_00179F20[g->selected_item[0]].f20 = 0x20;
+ D_L05_00179F20[g->selected_item[0]].unk20 = 0x20;
}
changed = 1;
}
@@ -335,7 +335,7 @@ void FUN_L05_0023dc88(int i) {
}
if (i == 0) {
struct Hero *k = &hero;
- D_L05_00179F20[k->selected_item[0]].f20 = 0x20;
+ D_L05_00179F20[k->selected_item[0]].unk20 = 0x20;
}
}
changed = 1;
@@ -503,8 +503,8 @@ int FUN_L05_002515d0(void) {
struct Hero *q;
struct Hero *u;
int r;
- float v1[4];
- float v2[4];
+ float ray_start[4];
+ float ray_end[4];
float t;
float scale;
if ((unsigned)(p->state.control_mode - 0x15) < 2) {
@@ -563,13 +563,13 @@ int FUN_L05_002515d0(void) {
if ((frame_number & 0x3F) == 0) {
scale = 16.0f;
}
- hero_get_collision_ray_endpoints(v1, v2, 0, scale, 1.3f);
- if (func_L00_001EFFF0(v1, v2, 2, *(int *)&u->moby, 0) != 0) {
+ hero_get_collision_ray_endpoints(ray_start, ray_end, 0, scale, 1.3f);
+ if (func_L00_001EFFF0(ray_start, ray_end, 2, *(int *)&u->moby, 0) != 0) {
int s = collision_hit_material();
u->ground_type = s;
if ((short)s == 0) {
- v1[2] = D_L05_00174268 - 0.01f;
- if (func_L00_001EFFF0(v1, v2, 2, *(int *)&u->moby, 0) == 0) {
+ ray_start[2] = D_L05_00174268 - 0.01f;
+ if (func_L00_001EFFF0(ray_start, ray_end, 2, *(int *)&u->moby, 0) == 0) {
hero_set_state(0x34, 1);
return 1;
}
@@ -634,7 +634,7 @@ 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 Hero D_0013F450_h2523C8 __asm__("D_0013F350");
+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");
@@ -644,7 +644,7 @@ extern int func_L05_0024D680_2523C8(int, int) __asm__("FUN_L05_0024cee8");
extern int func_001F9908_2523C8(int *) __asm__("FUN_001f9740");
extern Moby *D_L05_00160098_2523C8 __asm__("D_L05_0015FFD8") __attribute__((section(".sdata")));
extern int D_0015EEA4_macro __asm__("D_0015EEA4") __attribute__((section(".sdata")));
-extern int D_0015EE84_2523C8 __asm__("D_0015ED84") __attribute__((section(".sdata")));
+extern int D_0015ED84_gp __asm__("D_0015ED84") __attribute__((section(".sdata")));
int FUN_L05_00251be8(void) {
float joint_pos[4];
@@ -652,32 +652,32 @@ int FUN_L05_00251be8(void) {
int start_timer;
int mask;
- if (D_0013F450_h2523C8.unk20AC != 0 && D_0013F450_h2523C8.items[0].item_id != 0x24 && (D_0013F450_h2523C8.items[0].item_id != 8 || D_0013F450_h2523C8.unk308 != 1)) {
+ 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)) {
return 0;
}
- if (D_0013F450_h2523C8.vehicle_mode != 0) {
+ if ((*(Hero *)D_0013F350).vehicle_mode != 0) {
return 0;
}
- if (((Moby *)D_0013F450_h2523C8.items[0].moby) == 0) {
+ if (((Moby *)(*(Hero *)D_0013F350).items[0].moby) == 0) {
return 0;
}
- if (D_0013F450_h2523C8.items[0].state != 2) {
+ if ((*(Hero *)D_0013F350).items[0].state != 2) {
return 0;
}
- start_timer = D_0013F450_h2523C8.state_timer;
- mask = D_0013F450_h2523C8.items[0].button_mask;
- switch (D_0013F450_h2523C8.items[0].item_id) {
+ start_timer = (*(Hero *)D_0013F350).state_timer;
+ mask = (*(Hero *)D_0013F350).items[0].button_mask;
+ switch ((*(Hero *)D_0013F350).items[0].item_id) {
case 8:
- if (D_0013F450_h2523C8.state.control_mode < 2U || (D_0013F450_h2523C8.state.control_mode == 4 && D_0013F450_h2523C8.unk418 != 0)) {
+ if ((*(Hero *)D_0013F350).state.control_mode < 2U || ((*(Hero *)D_0013F350).state.control_mode == 4 && (*(Hero *)D_0013F350).unk418 != 0)) {
Moby *item;
- if (D_0013F450_h2523C8.on_slip_ground != 0) {
+ if ((*(Hero *)D_0013F350).on_slip_ground != 0) {
break;
}
if (!FUN_L00_00266d60(mask, scale_game_frames_alt(7), &press_time0)) {
break;
}
- item = (Moby *)D_0013F450_h2523C8.items[0].moby;
+ item = (Moby *)(*(Hero *)D_0013F350).items[0].moby;
if (item == 0) {
break;
}
@@ -687,75 +687,75 @@ int FUN_L05_00251be8(void) {
if (item->state != 0) {
break;
}
- if ((D_0013CA40_p2523C8.held & 0xA) || ((D_0013F450_h2523C8.state.current == 1 || D_0013F450_h2523C8.state.current == 0x1E) && D_0013F450_h2523C8.state_timer > scale_game_frames_alt(0x14))) {
- if ((D_0013F450_h2523C8.state.current == 1 || D_0013F450_h2523C8.state.current == 0x1E) && D_0013F450_h2523C8.state_timer > scale_game_frames_alt(0x14)) {
+ 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)) {
FUN_L00_00217658();
break;
}
func_L05_0024D680_2523C8(0x15, 1);
break;
}
- if (D_0013F450_h2523C8.unk308 == 1) {
+ if ((*(Hero *)D_0013F350).unk308 == 1) {
func_L05_0024D680_2523C8(0x70, 1);
} else {
func_L05_0024D680_2523C8(0x13, 1);
}
break;
}
- if (D_0013F450_h2523C8.state.current == 7 || D_0013F450_h2523C8.state.current == 9 || D_0013F450_h2523C8.state.current == 8 || D_0013F450_h2523C8.state.current == 6
- || (D_0013F450_h2523C8.state.current == 0xE && D_0013F450_h2523C8.anim_frame > 32.0f)
- || (D_0013F450_h2523C8.state.current == 0xB && D_0013F450_h2523C8.unk450 != 3 && D_0013F450_h2523C8.anim_frame > 18.0f) || (D_0013F450_h2523C8.state.current == 0xB && D_0013F450_h2523C8.unk450 == 3 && D_0013F450_h2523C8.anim_frame > 20.0f)
- || D_0013F450_h2523C8.state.current == 0x2D || D_0013F450_h2523C8.state.current == 0x11) {
- if (D_0013F450_h2523C8.state_timer > scale_game_frames_alt(0xA)) {
+ 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)) {
int window = scale_game_frames_alt(0xA);
- if (D_0013F450_h2523C8.state.current == 0xB || D_0013F450_h2523C8.state.current == 0xE) {
+ if ((*(Hero *)D_0013F350).state.current == 0xB || (*(Hero *)D_0013F350).state.current == 0xE) {
window = scale_game_frames_alt(0x12);
}
if (!FUN_L00_00266d60(mask, window, 0)) {
break;
}
- if ((D_0013F450_h2523C8.unk41E == 0 && D_0013F450_h2523C8.ground_distance > 0.1f) || (D_0013F450_h2523C8.unk41E != 0 && D_0013F450_h2523C8.ground_distance > 0.57f)
- || (D_0013F450_h2523C8.state.current == 8 && D_0013F450_h2523C8.ground_distance > 0.57f)) {
+ 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)) {
func_L05_0024D680_2523C8(0x14, 1);
break;
}
- if (D_0013F450_h2523C8.on_slip_ground != 0) {
+ if ((*(Hero *)D_0013F350).on_slip_ground != 0) {
break;
}
func_L05_0024D680_2523C8(0x13, 1);
break;
}
}
- if (D_0013F450_h2523C8.state.control_mode == 6) {
- Rec2C_2523C8 *rec = &D_L05_0017C188_2523C8[D_0013F450_h2523C8.attack_record];
+ if ((*(Hero *)D_0013F350).state.control_mode == 6) {
+ Rec2C_2523C8 *rec = &D_L05_0017C188_2523C8[(*(Hero *)D_0013F350).attack_record];
int window;
- if (D_0013F450_h2523C8.state.current == 0x15) {
- if (D_0013F450_h2523C8.state_timer > scale_game_frames_alt(0x1E)) {
- if (D_0013F450_h2523C8.unkA9C != 0) {
+ if ((*(Hero *)D_0013F350).state.current == 0x15) {
+ if ((*(Hero *)D_0013F350).state_timer > scale_game_frames_alt(0x1E)) {
+ if ((*(Hero *)D_0013F350).unkA9C != 0) {
break;
}
- if (D_0013F450_h2523C8.anim_frame >= (float)rec->f10 && (D_0013CA40_p2523C8.held & 0xA) && FUN_L00_00266d60(mask, scale_game_frames_alt(0xF), 0)) {
+ if ((*(Hero *)D_0013F350).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 (D_0013F450_h2523C8.unkA9C != 0) {
+ if ((*(Hero *)D_0013F350).unkA9C != 0) {
break;
}
- if (!(D_0013F450_h2523C8.anim_frame >= (float)rec->f10)) {
+ if (!((*(Hero *)D_0013F350).anim_frame >= (float)rec->f10)) {
break;
}
- window = (truncate_float_to_s32(D_0013F450_h2523C8.anim_frame) - rec->fC) * 2;
+ window = (truncate_float_to_s32((*(Hero *)D_0013F350).anim_frame) - rec->fC) * 2;
if (window <= 0) {
window = 1;
}
if (window > scale_game_frames_alt(0xF)) {
window = scale_game_frames_alt(0xF);
}
- if (D_0013F450_h2523C8.on_slip_ground != 0) {
+ if ((*(Hero *)D_0013F350).on_slip_ground != 0) {
break;
}
if (!FUN_L00_00266d60(mask, window, 0)) {
@@ -765,7 +765,7 @@ int FUN_L05_00251be8(void) {
func_L05_0024D680_2523C8(0x15, 1);
break;
}
- if (D_0013F450_h2523C8.unk308 == 1) {
+ if ((*(Hero *)D_0013F350).unk308 == 1) {
func_L05_0024D680_2523C8(0x70, 1);
} else {
func_L05_0024D680_2523C8(0x13, 1);
@@ -779,26 +779,26 @@ int FUN_L05_00251be8(void) {
FUN_L00_00221ee0();
FUN_L00_00222158();
window = scale_game_frames_alt(5);
- if (D_0013F450_h2523C8.air_frames.s != 0) {
+ if ((*(Hero *)D_0013F350).air_frames.s != 0) {
window = scale_game_frames_alt(8);
}
- if (D_0013F450_h2523C8.state.control_mode < 2U || D_0013F450_h2523C8.state.control_mode == 4 || D_0013F450_h2523C8.state.control_mode == 2 || D_0013F450_h2523C8.state.control_mode == 0xF
- || D_0013F450_h2523C8.state.control_mode == 5 || D_0013F450_h2523C8.state.current == 0x1E) {
- if (FUN_L00_00266d60(mask, window, 0) || ((D_0013CA40_p2523C8.held & mask) && D_0013F450_h2523C8.items[0].unk20 > scale_game_frames_alt(0xF))) {
- if (D_0013F450_h2523C8.unk99E != 0) {
- if (D_0013F450_h2523C8.unk968 != 0) {
- if (D_0013F450_h2523C8.unk998 < D_0013F450_h2523C8.unk984) {
- D_0013F450_h2523C8.unk968 = 0;
+ 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;
} else {
- D_0013F450_h2523C8.unk99E = 0;
+ (*(Hero *)D_0013F350).unk99E = 0;
}
}
- if (D_0013F450_h2523C8.unk99E != 0 && D_0013F450_h2523C8.unk1E6 == 0 && D_0013F450_h2523C8.state.current != 0x2C) {
+ if ((*(Hero *)D_0013F350).unk99E != 0 && (*(Hero *)D_0013F350).unk1E6 == 0 && (*(Hero *)D_0013F350).state.current != 0x2C) {
func_L05_0024D680_2523C8(0x2C, 1);
break;
}
}
- if (D_0013F450_h2523C8.unk968 != 0 && D_0013F450_h2523C8.unk1E6 == 0) {
+ if ((*(Hero *)D_0013F350).unk968 != 0 && (*(Hero *)D_0013F350).unk1E6 == 0) {
func_L05_0024D680_2523C8(0x24, 1);
}
}
@@ -806,7 +806,7 @@ int FUN_L05_00251be8(void) {
}
break;
case 31:
- if (D_0013F450_h2523C8.vehicle_mode != 0) {
+ if ((*(Hero *)D_0013F350).vehicle_mode != 0) {
break;
}
if (!FUN_L00_0020fe30_c()) {
@@ -818,35 +818,35 @@ int FUN_L05_00251be8(void) {
if (D_00141760_2523C8 != 0x1F) {
break;
}
- if (((Moby *)D_0013F450_h2523C8.items[0].moby)->oclass != 0x1E3) {
+ if (((Moby *)(*(Hero *)D_0013F350).items[0].moby)->oclass != 0x1E3) {
break;
}
- if (D_0013F450_h2523C8.unk22DE != 0) {
+ if ((*(Hero *)D_0013F350).unk22DE != 0) {
break;
}
FUN_L00_00216de8(0x18, 0);
- D_0013F450_h2523C8.unk22DE = 0x12;
- D_0013F450_h2523C8.unk22DC = 1;
+ (*(Hero *)D_0013F350).unk22DE = 0x12;
+ (*(Hero *)D_0013F350).unk22DC = 1;
break;
case 32:
- if (D_0013F450_h2523C8.state.control_mode < 3U || D_0013F450_h2523C8.state.control_mode == 4 || D_0013F450_h2523C8.state.control_mode == 5) {
+ if ((*(Hero *)D_0013F350).state.control_mode < 3U || (*(Hero *)D_0013F350).state.control_mode == 4 || (*(Hero *)D_0013F350).state.control_mode == 5) {
if (FUN_L00_00266d60(mask, scale_game_frames_alt(8), 0)) {
FUN_L00_0029a6b0(0);
}
}
break;
case 15:
- if (D_0013F450_h2523C8.state.control_mode < 2U || D_0013F450_h2523C8.state.control_mode == 0xC || D_0013F450_h2523C8.state.control_mode == 2 || D_0013F450_h2523C8.state.control_mode == 4
- || D_0013F450_h2523C8.state.control_mode == 5 || D_0013F450_h2523C8.state.control_mode == 0xF || D_0013F450_h2523C8.state.current == 0x1E) {
+ 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) {
PVar_2523C8 *pv;
- if (((Moby *)D_0013F450_h2523C8.items[0].moby) == 0) {
+ if (((Moby *)(*(Hero *)D_0013F350).items[0].moby) == 0) {
break;
}
- pv = (PVar_2523C8 *)((Moby *)D_0013F450_h2523C8.items[0].moby)->pvars;
- if (((D_0013CA40_p2523C8.held & mask) && D_0013F450_h2523C8.items[0].unk20 > scale_game_frames_alt(5)) || (D_0013CA40_p2523C8.pressed & mask)) {
+ 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)) {
if (FUN_L00_00233e98(-1)) {
- if (D_0013F450_h2523C8.unk20A8 == 0) {
+ if ((*(Hero *)D_0013F350).unk20A8 == 0) {
FUN_L00_0020e4c8();
}
break;
@@ -854,8 +854,8 @@ int FUN_L05_00251be8(void) {
}
if (D_0013CA40_p2523C8.held & mask) {
if (!FUN_L00_00233e98(-1)) {
- if (!FUN_L00_0028d8c0((Moby *)D_0013F450_h2523C8.items[0].moby, pv->fC)) {
- pv->fC = allocate_voice_for_target_entry_alt(0, 0, (int)((Moby *)D_0013F450_h2523C8.items[0].moby));
+ 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));
}
}
}
@@ -866,45 +866,45 @@ int FUN_L05_00251be8(void) {
case 20:
case 24:
case 25:
- if ((D_0013F450_h2523C8.state.control_mode == 0 && D_0013F450_h2523C8.state.current != 0x1E) || D_0013F450_h2523C8.state.control_mode == 1 || D_0013F450_h2523C8.state.control_mode == 0xC
- || D_0013F450_h2523C8.state.control_mode == 5 || D_0013F450_h2523C8.state.control_mode == 0xF || (D_0013F450_h2523C8.state.control_mode == 4 && D_0013F450_h2523C8.unk4AC != 0)
- || (D_0013F450_h2523C8.state.current == 0x23 && D_0013F450_h2523C8.anim_frame > 25.0f)) {
+ 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)) {
int window;
int held_frames;
- if (D_0013F450_h2523C8.unk20A8 != 0) {
+ if ((*(Hero *)D_0013F350).unk20A8 != 0) {
break;
}
window = scale_game_frames_alt(7);
- held_frames = D_0013F450_h2523C8.items[0].unk20;
+ held_frames = (*(Hero *)D_0013F350).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 (D_0013F450_h2523C8.state.control_mode == 0xC || D_0013F450_h2523C8.state.control_mode == 0 || D_0013F450_h2523C8.state.current == 3
- || (D_0013F450_h2523C8.state.control_mode == 1 && D_0013F450_h2523C8.unk229C < 0.7f)) {
+ 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)) {
func_L05_0024D680_2523C8(0x23, 1);
} else {
FUN_L00_0020e4c8();
}
break;
}
- if (((Moby *)D_0013F450_h2523C8.items[0].moby) != 0) {
- allocate_voice_for_target_entry_alt(0, 0, (int)((Moby *)D_0013F450_h2523C8.items[0].moby));
+ 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));
}
}
}
break;
case 18:
- if (D_0013F450_h2523C8.state.control_mode < 2U || (D_0013F450_h2523C8.state.control_mode == 4 && D_0013F450_h2523C8.unk418 != 0)) {
- if (D_0013F450_h2523C8.state.current != 1) {
+ 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) {
int window = scale_game_frames_alt(0xA);
- int held_frames = D_0013F450_h2523C8.items[0].unk20;
+ int held_frames = (*(Hero *)D_0013F350).items[0].unk20;
if (FUN_L00_00266d60(mask, window <= held_frames ? window : held_frames, &press_time2)) {
- if (((Moby *)D_0013F450_h2523C8.items[0].moby) != 0) {
+ if (((Moby *)(*(Hero *)D_0013F350).items[0].moby) != 0) {
func_L05_0024D680_2523C8(0x20, 1);
- if (((Moby *)D_0013F450_h2523C8.items[0].moby) != 0) {
- allocate_voice_for_target_entry_alt(0, 0, (int)((Moby *)D_0013F450_h2523C8.items[0].moby));
+ 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));
}
}
}
@@ -912,7 +912,7 @@ int FUN_L05_00251be8(void) {
}
break;
case 21:
- if (((Moby *)D_0013F450_h2523C8.items[0].moby) != 0) {
+ if (((Moby *)(*(Hero *)D_0013F350).items[0].moby) != 0) {
if (D_0013CA40_p2523C8.pressed & mask) {
FUN_L00_0020e4c8();
}
@@ -925,32 +925,32 @@ int FUN_L05_00251be8(void) {
struct UsageStats *stats;
int play_time, unit;
- if (D_0013F450_h2523C8.unk8CE != 0) {
+ if ((*(Hero *)D_0013F350).unk8CE != 0) {
if (D_00141D80[0] == 0 && D_00141920[0] == 0) {
- if (++D_0013F450_h2523C8.unk8CA > (int)((float)scale_game_frames_alt(0x14) * 60.0f)) {
+ if (++(*(Hero *)D_0013F350).unk8CA > (int)((float)scale_game_frames_alt(0x14) * 60.0f)) {
help_request(0x3E81, 0x83);
}
}
}
- item = (Moby *)D_0013F450_h2523C8.items[0].moby;
+ item = (Moby *)(*(Hero *)D_0013F350).items[0].moby;
if (item == 0) {
break;
}
- if (FUN_L00_001fefc8(&D_0013F450_h2523C8.unk8CF) == 2 && D_0013F450_h2523C8.unk8CE != 0) {
- D_0013F450_h2523C8.unk8CE--;
+ if (FUN_L00_001fefc8(&(*(Hero *)D_0013F350).unk8CF) == 2 && (*(Hero *)D_0013F350).unk8CE != 0) {
+ (*(Hero *)D_0013F350).unk8CE--;
}
- if (D_0013F450_h2523C8.unk8CE == 0) {
+ if ((*(Hero *)D_0013F350).unk8CE == 0) {
break;
}
- if (D_0013F450_h2523C8.unk8CF != 0) {
+ if ((*(Hero *)D_0013F350).unk8CF != 0) {
break;
}
if (!FUN_L00_00266d60(mask, scale_game_frames_alt(7), 0)) {
break;
}
best = 0;
- if (((Moby *)D_0013F450_h2523C8.unk86C) != 0) {
- PVar_2523C8 *pv = (PVar_2523C8 *)((Moby *)D_0013F450_h2523C8.unk86C)->pvars;
+ if (((Moby *)(*(Hero *)D_0013F350).unk86C) != 0) {
+ PVar_2523C8 *pv = (PVar_2523C8 *)((Moby *)(*(Hero *)D_0013F350).unk86C)->pvars;
float best_score = 9999999.0f;
int i;
@@ -965,11 +965,11 @@ int FUN_L05_00251be8(void) {
continue;
}
candidate = (Moby *)((char *)D_L05_00160098_2523C8 + (id << 8));
- yaw_error = fast_difference_between_rotations(D_0013F450_h2523C8.motion.rot.f[2], fast_arc_tan(candidate->pos.x - D_0013F450_h2523C8.motion.pos.f[0], candidate->pos.y - D_0013F450_h2523C8.motion.pos.f[1]));
+ 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]));
if (!(yaw_error > 0.7853982f)) {
- pitch_error = fast_difference_between_rotations(fast_arc_tan(vector_distance_xy(D_0013F450_h2523C8.motion.pos.f, &candidate->pos), candidate->pos.z - D_0013F450_h2523C8.motion.pos.f[2]), 0.0f);
+ 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);
if (!(pitch_error > 0.7853982f)) {
- distance = vector_distance_xy(&candidate->pos, D_0013F450_h2523C8.motion.pos.f);
+ distance = vector_distance_xy(&candidate->pos, (*(Hero *)D_0013F350).motion.pos.f);
score = distance;
score += distance * yaw_error * 2.0f;
score += distance * pitch_error * 2.0f;
@@ -984,7 +984,7 @@ int FUN_L05_00251be8(void) {
}
stats = &usage_stats;
item->command = scale_game_frames_alt(7);
- D_0013F450_h2523C8.unk8CF = scale_game_frames_alt(0x32);
+ (*(Hero *)D_0013F350).unk8CF = scale_game_frames_alt(0x32);
if (stats->stat[27].count < 0xFFFF) {
stats->stat[27].count++;
}
@@ -993,33 +993,33 @@ int FUN_L05_00251be8(void) {
if (play_time / unit > stats->stat[27].unk2) {
stats->stat[27].unk2 = scale_game_frames_alt(D_0015EEA4_macro) / 600;
}
- stats->stat[27].level_mask = stats->stat[27].level_mask | (1 << D_0015EE84_2523C8) | 0x80000000;
+ 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, D_0013F450_h2523C8.motion.rot.f[2], D_0013F450_h2523C8.motion.rot.f[1]);
+ FUN_L05_002d4168(item, joint_pos, best, (*(Hero *)D_0013F350).motion.rot.f[2], (*(Hero *)D_0013F350).motion.rot.f[1]);
}
break;
}
- if (D_0013F450_h2523C8.state_timer == start_timer) {
- if (FUN_L00_0020d498(3) == 3 && D_0013F450_h2523C8.state.current != 0x81 && (D_0013F450_h2523C8.unk308 == 0 || D_0013D5C8_2523C8[0] == 0)
- && D_0013F450_h2523C8.unk22D8 == 0) {
+ 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) {
func_001F9908_2523C8(&D_L05_0015F674_g);
if (D_L05_0015F674_g != 0) {
- if (D_0013F450_h2523C8.state.control_mode < 2U || D_0013F450_h2523C8.state.control_mode == 0xC
- || ((D_0013F450_h2523C8.state.control_mode == 2 || D_0013F450_h2523C8.state.control_mode == 4) && D_0013F450_h2523C8.grounded_frames != 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 ((D_0013CA40_p2523C8.held & 8) && (D_0013CA40_p2523C8.pressed & 8)) {
func_L05_0024D680_2523C8(0x81, 1);
}
}
}
- if ((D_0013CA40_p2523C8.pressed & 8) && D_0013F450_h2523C8.state.current != 0x81) {
+ if ((D_0013CA40_p2523C8.pressed & 8) && (*(Hero *)D_0013F350).state.current != 0x81) {
D_L05_0015F674_g = scale_game_frames_alt(0x1E);
}
- } else if (D_0013F450_h2523C8.state.current != 0x13 && D_0013F450_h2523C8.state.current != 0x81 && D_0013F450_h2523C8.state.current != 0x15 && D_0013F450_h2523C8.state.current != 0x16) {
- D_0013F450_h2523C8.unk22CA = 0;
+ } 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;
}
}
- return D_0013F450_h2523C8.state_timer < start_timer;
+ return (*(Hero *)D_0013F350).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. */
@@ -1318,98 +1318,79 @@ void FUN_L05_00254058(void) {
}
}
#endif
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L05_00254358.s", FUN_L05_00254358);
-#else
+/* Finds the nearest path node ahead of the hero (behind the facing test) and returns its position and heading. */
+/* Ported from rac1-decomp (src/overlays/shared/help_00237B00.c: func_L05_00254B38), where it is exact; names translated to the US level program. */
+
+extern f32 fast_arc_tan_c(f32, f32) __asm__("func_001F9E90");
+extern float probe_ground_height(void *, int, float) __asm__("func_00213508");
+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[];
-extern f32 fast_arc_tan(f32, f32) __asm__("FUN_001f9e90");
-extern f32 fast_difference_between_rotations(f32, f32) __asm__("FUN_001fa688");
-extern f32 vector_distance_xy(void *, void *) __asm__("FUN_001f9b80");
-extern void clear_u64_value(void *) __asm__("FUN_001f99f8");
-extern f32 find_ground_height(f32, void *, s32) __asm__("FUN_00213508");
-extern s32 current_level_index __asm__("D_0015ED84") __attribute__((sda));
-typedef struct {
- f32 x, y, z, w;
-} __attribute__((aligned(16))) HelpPathPoint;
+void FUN_L05_00254358(float *out, float *rot) {
+ char *g = (char *)((char *)&D_0013F350);
+ char *m = *(char **)(g + 0x86C);
+ char *path;
+ float distance;
+ int i, best;
+ float tmp[4] __attribute__((aligned(16)));
-typedef struct {
- s32 count;
- u8 pad[12];
- HelpPathPoint points[1];
-} HelpPath;
-
-void FUN_L05_00254358(f32 *position, f32 *direction) {
- struct Hero *g;
- HelpPath *path;
- f32 height_limit;
- f32 best;
- s32 index;
- s32 selected;
- HelpPathPoint point;
- HelpPathPoint *p;
- HelpPath *cursor;
-
-
- if (hero.unk86C == 0) {
- qcopy(position, (char *)&hero + 0x80);
- qcopy(direction, (char *)&hero + 0x90);
+ if (m == 0) {
+ qcopy(out, g + 0x80);
+ qcopy(rot, g + 0x90);
return;
}
- path = (HelpPath *)D_L05_001B0930[*(s32 *)(*(char **)(hero.unk86C + 0x78) + 0x24)];
- best = 9999999.0f;
- index = 0;
- selected = 0;
-
- if (path->count > 0) {
- height_limit = 4.0f;
- p = path->points;
- cursor = path;
- do {
- f32 a;
- s32 next;
- s32 count;
- f32 b;
- g = &hero;
- a = fast_arc_tan(cursor->points[0].x - g->motion.pos.f[0], cursor->points[0].y - g->motion.pos.f[1]);
- count = path->count;
- next = (s32)((u32)count + 2U);
- next = (s32)((u32)index + (u32)next) % count;
- b = fast_arc_tan(path->points[next].x - cursor->points[0].x, path->points[next].y - cursor->points[0].y);
- if (!(fast_difference_between_rotations(a, b) > 1.5707964f)) goto next_point;
- {
- if (current_level_index == 0x10 && g->unk8B4 != 0) {
- f32 a = ((HelpPath *)g->unk8B4)->points[*(s16 *)((char *)g + 0x8C8)].z;
- f32 b = ((HelpPath *)g->unk8B4)->points[g->unk898].z;
- f32 high = cursor->points[0].z;
- if (a < b) high = b - high;
- else high = a - high;
- if (absolute_float(high) > height_limit) {
- goto next_point;
+ path = D_L05_001B0930[*(int *)(*(char **)(m + 0x78) + 0x24)];
+ distance = 9999999.0f;
+ best = 0;
+ for (i = 0; i < *(int *)path; i += 2) {
+ char *h = (char *)((char *)&D_0013F350);
+ 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));
+ int n2 = *(int *)path + 2;
+ int next = (i + n2) % *(int *)path;
+ char *q = path + next * 16;
+ if (fast_difference_between_rotations(angle, fast_arc_tan_c(*(float *)(q + 0x10) - *(float *)(p + 0x10), *(float *)(q + 0x14) - *(float *)(p + 0x14))) > 1.5707964f) {
+ float d;
+ if (D_0015ED84_gp == 0x10 && *(char **)(h + 0x8B4) != 0) {
+ char *verts = *(char **)(h + 0x8B4);
+ char *v1 = verts + *(short *)(h + 0x8C8) * 16;
+ char *v2 = verts + *(short *)(h + 0x898) * 16;
+ float z1 = *(float *)(v1 + 0x18);
+ float z2 = *(float *)(v2 + 0x18);
+ if (z1 < z2) {
+ if (absolute_float_c(z2 - *(float *)(p + 0x18)) > limit)
+ goto next_point;
+ } else {
+ if (absolute_float_c(z1 - *(float *)(p + 0x18)) > limit)
+ goto next_point;
}
}
- {
- f32 distance = vector_distance_xy((char *)&hero + 0x80, p);
- if (distance < best) {
- best = distance;
- selected = index;
- }
+ d = vector_distance_xy_alt(((char *)&D_0013F3D0), path + i * 16 + 0x10);
+ if (d < distance) {
+ distance = d;
+ best = i;
}
}
-next_point:
- index += 2;
- p += 2;
- cursor = (HelpPath *)((char *)cursor + 0x20);
- } while (index < path->count);
- }
- qcopy(position, &path->points[selected]);
- qcopy(&point, position);
- point.z += 2.0f;
- position[2] = find_ground_height(0.5f, &point, 0);
- clear_u64_value(direction);
- direction[2] = fast_arc_tan(path->points[selected + 1].x - path->points[selected].x, path->points[selected + 1].y - path->points[selected].y);
+ next_point:;
+ }
+ qcopy(out, path + best * 16 + 0x10);
+ qcopy(tmp, out);
+ tmp[2] += 2.0f;
+ out[2] = probe_ground_height(tmp, 0, 0.5f);
+ clear_u64_value(rot);
+ {
+ float *a = (float *)(path + best * 16);
+ float *b = (float *)(path + (best + 1) * 16);
+ rot[2] = fast_arc_tan_c(b[4] - a[4], b[5] - a[5]);
+ }
}
-#endif
extern int D_0015ED84_lui __asm__("D_0015ED84") __attribute__((section(".sdata")));
extern int FUN_001f96f8_254608(int) __asm__("FUN_001f96f8");
typedef int u128_254608 __attribute__((mode(TI)));
@@ -1417,8 +1398,8 @@ typedef struct { float x, y, z, w; } __attribute__((aligned(16))) Node_254608;
typedef struct { int n; int pad[3]; Node_254608 p[1]; } Path_254608;
typedef struct {
char pad0[0x20];
- int f20;
- int f24;
+ int unk20;
+ int unk24;
int f28;
int f2C[5];
int f40;
@@ -1437,7 +1418,7 @@ typedef struct { char pad0[9]; unsigned char f9; } Flags_254608;
extern unsigned char D_0013D388_254608[] __asm__("D_0013D388") __attribute__((section(".data")));
extern unsigned char D_0013D408_254608[] __asm__("D_0013D408") __attribute__((section(".data")));
extern unsigned char D_0013D4DF_254608 __asm__("D_0013D4DF") __attribute__((section(".data")));
-extern Path_254608 *D_L05_001B0930_254608[] __asm__("D_L05_001B0930");
+extern char *D_L05_001B0930[];
extern Ent_254608 *D_L05_0015FFD8_254608 __asm__("D_L05_0015FFD8") __attribute__((section(".sdata")));
extern int D_0015EE38_macro __asm__("D_0015EE38") __attribute__((section(".sdata")));
extern int D_0015EE3C_macro __asm__("D_0015EE3C") __attribute__((section(".sdata")));
@@ -1480,10 +1461,10 @@ void FUN_L05_00254608(void) {
return;
}
d = (Data_254608 *)((struct Moby *)hero.unk86C)->pvars;
- if (d->f20 == -1) {
+ if (d->unk20 == -1) {
return;
}
- path = D_L05_001B0930_254608[d->f20];
+ path = ((Path_254608 * *)D_L05_001B0930)[d->unk20];
hero.unk8B4 = (void *)path;
if (D_0015ED84_lui == 0x10) {
*(u128_254608 *)v0 = 0;
diff --git a/src/overlays/shared/ui/menus/0027a6e0.c b/src/overlays/shared/ui/menus/0027a6e0.c
index 067f9e8b0d..d2652694be 100644
--- a/src/overlays/shared/ui/menus/0027a6e0.c
+++ b/src/overlays/shared/ui/menus/0027a6e0.c
@@ -12,79 +12,79 @@ int FUN_L00_0027a6e0(char *menu) {
return 0;
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L00_002831c0.s", FUN_L00_002831c0);
-#else
-#include "rnc/input/pad_state.h"
+/* Ported from rac1-decomp (src/overlays/shared/pause_00277208.c: func_L00_00284410), where it is exact; names translated to the US level program. */
-extern struct PadState D_0013C940;
-#define D_0015EF78 (*(s32 *)0x0015ef78)
-extern s16 D_L00_001BA4A8[];
-extern u8 D_L00_001B9BA0[];
-extern u8 items_acquired[] __asm__("D_0013D4E8");
-extern u8 D_0013D4C0[];
-extern u8 D_0013D388[];
-extern u8 D_0013D408[];
-extern void unlock_planet(s32) __asm__("FUN_L00_002607d0");
-extern void FUN_L00_0028dd40(s32, s32, s32) __asm__("FUN_0022db10");
-extern void queue_dialogue_message(s32, s32) __asm__("FUN_L00_00263d40");
+extern char D_0013D408[];
+extern char D_0013D4C0[];
+extern unsigned char items_acquired[] __asm__("D_0013D4E8");
+extern char D_0013D388[];
+extern short D_L00_001603F8 __attribute__((sda));
+extern short D_L00_001BA4A8[];
+extern unsigned char D_0013A4E0[];
+extern unsigned char D_0013C940[];
+extern unsigned char D_L00_001B9BA0[];
+extern void FUN_L00_002607d0(int);
+extern void FUN_L00_00263d40(int, int);
+s32 allocate_voice_for_bank_entry(s32 entry_index, s32 flags, s32 owner) __asm__("FUN_0022db10");
void FUN_L00_002831c0(void) {
- s32 pressed;
- s32 direction;
- s32 count;
- s32 code;
- s32 index;
- s32 matched;
+ char *pad = (char *)((char *)&D_0013C940);
+ int lim0, lim;
+ int va, vb, vc;
+ int pressed, direction, count, j, code, index, matched;
+ if ((*(long *)(pad + 0x1C0) & 0xF) == 6) {
+ pressed = *(int *)(pad + 0x1C4);
+ if (!(pressed & 0xF0A0)) return;
- if (((*(u64 *)&D_0013C940.held_unmasked) & 15) == 6) {
- pressed = D_0013C940.pressed_unmasked;
- if ((pressed & 0xF0A0) && (D_0015EF78 < 20)) {
- count = D_0015EF78;
- if (pressed & 0x1000) direction = 0;
- else if (pressed & 0x4000) direction = 1;
- else if (pressed & 0x8000) direction = 2;
- else if (pressed & 0x2000) direction = 3;
- else direction = (pressed & 0x80) ? 4 : 5;
- D_0015EF78 = count + 1;
- D_L00_001BA4A8[count] = direction;
- if (count + 1 != 20) return;
-
- code = -1;
- for (index = 2; index < 0x93; index++) {
- if (D_L00_001BA4A8[0] == D_L00_001B9BA0[index & 0xff]) {
- matched = 1;
- count = 1;
- do {
- if (D_L00_001BA4A8[count] != D_L00_001B9BA0[(index * count + index) & 0xff]) {
- matched = 0;
- break;
- }
- count++;
- } while (count < 20);
- if (matched) {
- code = index - 2;
- break;
- }
+ if (*(int *)&D_L00_001603F8 >= 20) return;
+ if (pressed & 0x1000) direction = 0;
+ else if (pressed & 0x4000) direction = 1;
+ else if (pressed & 0x8000) direction = 2;
+ else if (pressed & 0x2000) direction = 3;
+ else direction = (pressed & 0x80) ? 4 : 5;
+ count = *(int *)&D_L00_001603F8;
+ D_L00_001BA4A8[count++] = direction;
+ *(int *)&D_L00_001603F8 = count;
+ if (count != 20) return;
+ code = -1;
+ index = 2;
+ /* Fakematch: the bound read back through memory stays a register compare */
+ lim0 = 0x93;
+ lim = *(int *)&lim0;
+ for (; index < lim; index++) {
+ matched = 1;
+ for (j = 0; j < 20; j++) {
+ if (D_L00_001BA4A8[j] != D_L00_001B9BA0[(j * index + index) & 0xff]) {
+ matched = 0;
+ break;
}
}
- if (code < 0) return;
- if (code < 0x25) {
- D_0013D4C0[code] = 1;
- items_acquired[code] = 1;
- } else if (code < 0x37) {
- unlock_planet(code - 0x24);
- } else if (code < 0x3d) {
- D_0013D388[code - 0x37] = 1;
- } else if (code < 0x5b) {
- u8 *flag = &D_0013D408[code - 0x3d];
- if (!*flag) {
- *flag = 1;
- FUN_L00_0028dd40(1, 0, 0);
- queue_dialogue_message(0x53d6, -1);
- }
+ if (matched) {
+ code = index - 2;
+ break;
+ }
+ }
+ if (code == -1) return;
+ va = code - 0x24;
+ vb = code - 0x37;
+ vc = code - 0x3d;
+ if (code < 0x25) {
+ D_0013D4C0[code] = 1;
+ ((char *)items_acquired)[code] = 1;
+ } else if ((unsigned)(code - 0x25) < 0x12) {
+ FUN_L00_002607d0(va);
+ } else if ((unsigned)vb < 6) {
+ char *p3 = D_0013D388;
+ p3[vb] = 1;
+ } else if ((unsigned)vc < 0x1e) {
+ unsigned char *q = (unsigned char *)D_0013D408 + vc;
+ if (!*q) {
+ *q = 1;
+ allocate_voice_for_bank_entry(1, 0, 0);
+ FUN_L00_00263d40(0x53D6, -1);
}
}
- } else D_0015EF78 = 0;
+ } else {
+ *(int *)&D_L00_001603F8 = 0;
+ }
}
-#endif
diff --git a/src/overlays/shared/ui/menus/0027f448.c b/src/overlays/shared/ui/menus/0027f448.c
index ff577e8f7e..b0f1b89f8b 100644
--- a/src/overlays/shared/ui/menus/0027f448.c
+++ b/src/overlays/shared/ui/menus/0027f448.c
@@ -36,36 +36,24 @@ int FUN_L00_0027f448(P_27f448 *p) {
}
INCLUDE_ASM("config/us/overlays/asm/FUN_L00_0027f700.s", FUN_L00_0027f700);
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L00_00284d90.s", FUN_L00_00284d90);
-#else
-extern short bolt_source_stats[][64][2] __asm__("D_0014D590");
-int FUN_L00_00284d90(int groupIndex, int itemIndex) {
- int slotIndex = -1;
- int value, current;
- short *slot, *writeSlot;
- if (itemIndex >= 0) {
- value = itemIndex + 1;
- slot = &bolt_source_stats[groupIndex][0][0];
- slotIndex = 63;
- current = *(writeSlot = slot + 126);
- slot = writeSlot;
- if (current == value) goto store;
- if (current == 0) goto store;
- do {
- slotIndex--;
- slot -= 2;
- if (slotIndex < 0) break;
- writeSlot = slot;
- current = *writeSlot;
- if (current == value) goto store;
- } while (current != 0);
- if (slotIndex >= 0) goto store;
+/* Ported from rac1-decomp (src/overlays/shared/pause_00277208.c: func_L00_00286068), where it is exact; names translated to the US level program. */
+
+typedef struct { short uid; short bolts; } BoltSourceStats;
+
+extern BoltSourceStats D_0014D590[][64];
+
+int FUN_L00_00284d90(int lvl, int uid) {
+ int k = -1;
+
+ if (uid >= 0) {
+ uid++;
+ k = 63;
+ while (k >= 0 && D_0014D590[lvl][k].uid != uid && D_0014D590[lvl][k].uid != 0) {
+ k--;
+ }
+ if (k >= 0) {
+ D_0014D590[lvl][k].uid = uid;
+ }
}
- goto done;
-store:
- *writeSlot = value;
-done:
- return slotIndex;
+ return k;
}
-#endif /* NON_MATCHING */
diff --git a/src/overlays/shared/ui/text/002377b8.c b/src/overlays/shared/ui/text/002377b8.c
index ac72eb8042..bbab3c374d 100644
--- a/src/overlays/shared/ui/text/002377b8.c
+++ b/src/overlays/shared/ui/text/002377b8.c
@@ -23,72 +23,90 @@ void FUN_L00_002377b8(char *p) {
*(int *)(p + 0x7C) = 30;
}
}
-#ifndef NON_MATCHING
-INCLUDE_ASM("config/us/overlays/asm/FUN_L00_00237840.s", FUN_L00_00237840);
-#else
+/* Draws a HUD gauge frame. */
+/* Ported from rac1-decomp (src/overlays/shared/hud_00235960.c: func_L00_002381D0), 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_237840;
+
+extern s32 find_valid_animation_frame_index_alt(s32, s32) __asm__("func_001FF960");
extern int D_L00_0015F760 __attribute__((sda));
extern int D_L00_0015F764 __attribute__((sda));
-extern int FUN_L00_00235a70(char *, int *, int *);
-extern void FUN_L00_00235ad8(char *, int *, int *, int, int);
-extern void FUN_L00_0023caa8(int, int, int, int, unsigned long, int);
-extern int FUN_L00_0023b208(int, int);
+extern void FUN_L00_00235ad8_c(HudElem_237840 *, int *, int *, int, int) __asm__("FUN_L00_00235ad8");
extern void FUN_L00_0023bac0(int, int, int, int, int, int);
+extern void append_screen_rect_packet(s32, s32, s32, s32, u64, s32) __asm__("func_00200E08");
+int FUN_L00_00235a70_c2(HudElem_237840 *rec, int *x, int *y) __asm__("FUN_L00_00235a70");
-int FUN_L00_00237840(char *rec) {
- int x, y;
- int left, top, right, bottom;
- int w, h, bar_height, step, i, xbase, ybase;
+int FUN_L00_00237840(HudElem_237840 *e) {
+ int pos[2];
+ int left, top, right, bottom, w, h, bh, step, i;
{
- int w, h;
- w = D_L00_0015F760;
- h = D_L00_0015F764;
- x = *(int *)(rec + 0x50);
- y = *(int *)(rec + 0x54);
- *(int *)(rec + 0x5c) = h;
- *(int *)(rec + 0x58) = w;
+ int ww = D_L00_0015F760;
+ pos[0] = e->unk50;
+ pos[1] = e->unk54;
+ e->w = ww;
+ {
+ int *src = (int *)&(*(short *)&D_L00_0015F764);
+ int *dst = &e->h;
+ __builtin_memcpy(dst, src, 4);
+ }
}
- FUN_L00_00235a70(rec, &x, &y);
- FUN_L00_00235ad8(rec, &x, &y, *(int *)(rec + 0x6c), 0);
- w = D_L00_0015F760 * 0xd0;
- h = D_L00_0015F764 * 0xa0;
- bar_height = D_L00_0015F760 * 0x260;
- bottom = D_L00_0015F764 * 0xea0;
- left = (x + *(short *)(rec + 0x48)) << 4;
- top = (y + *(short *)(rec + 0x4a)) << 4;
+ FUN_L00_00235a70_c2(e, &pos[0], &pos[1]);
+ FUN_L00_00235ad8_c(e, &pos[0], &pos[1], e->unk6C, 0);
+ w = D_L00_0015F760 * 0xD0;
+ h = D_L00_0015F764 * 0xA0;
+ bh = D_L00_0015F760 * 0x260;
+ bottom = D_L00_0015F764 * 0xEA0;
+ left = (pos[0] + e->unk48) << 4;
+ top = (pos[1] + e->unk4A) << 4;
left += w / 64;
top += h / 256;
- right = left + bar_height / 64;
+ right = left + bh / 64;
bottom = top + bottom / 256;
- FUN_L00_0023caa8(left, top, right, bottom, 0x80000000UL, 1);
+ append_screen_rect_packet(left, top, right, bottom, 0x80000000, 1);
{
- int step;
- step = D_L00_0015F764 * 0xea0;
+ int st = D_L00_0015F764 * 0xEA0;
h = D_L00_0015F764;
- top = (y + *(short *)(rec + 0x4a)) << 4;
- top += (h * 0xf40) / 256;
- bar_height = (*(int *)(rec + 0x74) * step) / (*(int *)(rec + 8) << 8);
- FUN_L00_0023caa8(left, top, right, top - bar_height, 0x80829e00UL, 1);
+ top = (pos[1] + e->unk4A) << 4;
+ top += (h * 0xF40) / 256;
+ bh = (e->unk74 * st) / (e->unk08 << 8);
+ append_screen_rect_packet(left, top, right, top - bh, 0x80829E00, 1);
}
i = 1;
- if (i < *(int *)(rec + 0x74)) do {
- int h;
- h = D_L00_0015F764;
- top = (y + *(short *)(rec + 0x4a)) << 4;
- top += (h * 0xf40) / 256;
- step = D_L00_0015F764 * 0xea0;
- step = i * step / (*(int *)(rec + 8) << 8);
+ if (i < e->unk74) do {
+ int hh = D_L00_0015F764;
+ top = (pos[1] + e->unk4A) << 4;
+ top += (hh * 0xF40) / 256;
+ step = D_L00_0015F764 * 0xEA0;
+ step = i * step / (e->unk08 << 8);
i++;
top -= step;
top -= 16;
- FUN_L00_0023caa8(left, top, right, top + 32, 0x80000000UL, 1);
-
- } while (i < *(int *)(rec + 0x74));
- w = FUN_L00_0023b208(*(int *)rec, 0);
- FUN_L00_0023bac0(w, x + *(short *)(rec + 0x48), y + *(short *)(rec + 0x4a),
- D_L00_0015F760, D_L00_0015F764, 0x80);
- return *(int *)(rec + 0x58);
+ append_screen_rect_packet(left, top, right, top + 32, 0x80000000, 1);
+ } while (i < e->unk74);
+ w = find_valid_animation_frame_index_alt(*(int *)e, 0);
+ FUN_L00_0023bac0(w, pos[0] + e->unk48, pos[1] + e->unk4A, D_L00_0015F760, D_L00_0015F764, 0x80);
+ return e->w;
}
-#endif
typedef struct {
u8 pad[0x48];
s16 x48;
@@ -147,7 +165,7 @@ void FUN_L00_00237ae8(O00237ae8 *o) {
}
}
typedef struct {
- int f0, f4, f8, fC, f10, f14, f18;
+ int unk0, unk4, unk8, unkC, unk10, unk14, unk18;
} Ent;
typedef struct {
u8 p0[0x64];
@@ -163,8 +181,8 @@ typedef struct {
} Obj;
typedef struct {
u8 p0[0x148];
- float f148;
- float f14C;
+ float unk148;
+ float unk14C;
u8 p150[0x70];
int w1C0;
int w1C4;
@@ -225,8 +243,8 @@ void FUN_L00_00237ba0(Obj *p) {
p->w7C = FUN_001f96f8(0xB4);
p->w6C = 0x18;
if (fast_dec_timer_s16(D_00141622)) D_0013C940.w1CC = 2;
- x = D_0013C940.f148;
- y = D_0013C940.f14C;
+ x = D_0013C940.unk148;
+ y = D_0013C940.unk14C;
mag = square_root(x * x + y * y);
if (mag != 0.0f) {
x /= mag;
@@ -262,18 +280,18 @@ void FUN_L00_00237ba0(Obj *p) {
} else if (D_0013C940.w1D8 == 0 && (D_0013C940.w1C4 & 0xF000)) {
int w;
w = old;
- if (D_0013C940.w1C4 & 0x1000) { int t; if (w == -1) t = D_L00_0017DC20; else t = D_L00_0015FAC0_c[D_L00_0015F72C][w].f10; w = t; }
- if (D_0013C940.w1C4 & 0x4000) { int t; if (w == -1) t = D_L00_0017DC24; else t = D_L00_0015FAC0_c[D_L00_0015F72C][w].f14; w = t; }
- if (D_0013C940.w1C4 & 0x8000) { int t; if (w == -1) t = D_L00_0017DC18; else t = D_L00_0015FAC0_c[D_L00_0015F72C][w].f8; w = t; }
- if (D_0013C940.w1C4 & 0x2000) { int t; if (w == -1) t = D_L00_0017DC1C; else t = D_L00_0015FAC0_c[D_L00_0015F72C][w].fC; w = t; }
+ if (D_0013C940.w1C4 & 0x1000) { int t; if (w == -1) t = D_L00_0017DC20; else t = D_L00_0015FAC0_c[D_L00_0015F72C][w].unk10; w = t; }
+ if (D_0013C940.w1C4 & 0x4000) { int t; if (w == -1) t = D_L00_0017DC24; else t = D_L00_0015FAC0_c[D_L00_0015F72C][w].unk14; w = t; }
+ if (D_0013C940.w1C4 & 0x8000) { int t; if (w == -1) t = D_L00_0017DC18; else t = D_L00_0015FAC0_c[D_L00_0015F72C][w].unk8; w = t; }
+ if (D_0013C940.w1C4 & 0x2000) { int t; if (w == -1) t = D_L00_0017DC1C; else t = D_L00_0015FAC0_c[D_L00_0015F72C][w].unkC; w = t; }
p->w74 = w;
}
{
Ent *t = D_L00_0015FAC0_c[D_L00_0015F72C];
int cur = p->w74;
- if (t[cur].f0 == 0 && n != 0) {
+ if (t[cur].unk0 == 0 && n != 0) {
k = (cur + n) % D_L00_0015FA90;
- if (t[k].f0 != 0) p->w74 = k;
+ if (t[k].unk0 != 0) p->w74 = k;
}
}
}
@@ -281,7 +299,7 @@ void FUN_L00_00237ba0(Obj *p) {
else if (c[1] < D_L00_0015F780_gp) c[1]++;
if (!(D_0013C940.w1C0 & 0x10)) {
int sel = p->w74;
- if (sel >= 0 && (id = D_L00_0015FAC0_c[D_L00_0015F72C][sel].f18) != 0) {
+ if (sel >= 0 && (id = D_L00_0015FAC0_c[D_L00_0015F72C][sel].unk18) != 0) {
VendorItemInfo *rr;
int ri = id;
if (hero_lui.items[0].item_id != id) {
@@ -414,10 +432,10 @@ s32 FUN_L00_002382a0(char *rec) {
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]))->f0 != 0)
+ ((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]))->f0 != 0) {
+ 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);
@@ -425,8 +443,8 @@ s32 FUN_L00_002382a0(char *rec) {
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->f0,
- D_0013E520[entry->f18] ? 4 : 0), icon_x, icon_y, 1, icon_alpha);
+ 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;
@@ -434,7 +452,7 @@ s32 FUN_L00_002382a0(char *rec) {
}
}
selected = *(s32 *)(rec + 0x74);
- if (selected >= 0 && D_L00_0015FAC0_c[D_L00_0015F72C][selected].f0 != 0) {
+ if (selected >= 0 && D_L00_0015FAC0_c[D_L00_0015F72C][selected].unk0 != 0) {
f32 opacity;
open *= fade;
opacity = open;
@@ -455,7 +473,7 @@ s32 FUN_L00_002382a0(char *rec) {
shadow = fast_tween_color_alpha_first(opacity, D_L00_0015F790, D_L00_0015F794);
{
s32 item, id;
- item = D_L00_0015FAC0_c[D_L00_0015F72C][selected].f18;
+ item = D_L00_0015FAC0_c[D_L00_0015F72C][selected].unk18;
if (D_0013E520[item])
id = ((TitleItem_2382a0 *)D_L00_00179AC0)[item].h48;
else
@@ -547,8 +565,8 @@ void FUN_L00_00238b80(Obj *o) {
o->w7C = FUN_001f96f8(0xB4);
o->w6C = 0x18;
D_0013C940.w1CC = 2;
- x = D_0013C940.f148;
- y = D_0013C940.f14C;
+ x = D_0013C940.unk148;
+ y = D_0013C940.unk14C;
len = square_root(x * x + y * y);
if (len != 0.0f) {
x /= len;
@@ -575,28 +593,28 @@ void FUN_L00_00238b80(Obj *o) {
if (cur == -1)
t = D_L00_0017DC40;
else
- t = D_L00_0015FAC0_c[D_L00_0015F72C][cur].f10;
+ t = D_L00_0015FAC0_c[D_L00_0015F72C][cur].unk10;
cur = t;
}
if (D_0013C940.w1C4 & 0x4000) {
if (cur == -1)
t = D_L00_0017DC44;
else
- t = D_L00_0015FAC0_c[D_L00_0015F72C][cur].f14;
+ t = D_L00_0015FAC0_c[D_L00_0015F72C][cur].unk14;
cur = t;
}
if (D_0013C940.w1C4 & 0x8000) {
if (cur == -1)
t = D_L00_0017DC38;
else
- t = D_L00_0015FAC0_c[D_L00_0015F72C][cur].f8;
+ t = D_L00_0015FAC0_c[D_L00_0015F72C][cur].unk8;
cur = t;
}
if (D_0013C940.w1C4 & 0x2000) {
if (cur == -1)
t = D_L00_0017DC3C;
else
- t = D_L00_0015FAC0_c[D_L00_0015F72C][cur].fC;
+ t = D_L00_0015FAC0_c[D_L00_0015F72C][cur].unkC;
cur = t;
}
o->w74 = cur;
@@ -611,7 +629,7 @@ void FUN_L00_00238b80(Obj *o) {
if (o->w74 == -1)
D_00141610[0] = 0;
else
- D_00141610[0] = D_L00_0015FAC0_c[D_L00_0015F72C][o->w74].f18;
+ D_00141610[0] = D_L00_0015FAC0_c[D_L00_0015F72C][o->w74].unk18;
if (c[0] != 0)
c[0]--;
} else if (c[0] < D_L00_0015F780_gp) {
@@ -653,11 +671,11 @@ typedef struct {
void *unk80;
} HudElem_238f88;
-typedef struct { int f0, f4, f8, fC, f10, f14, f18; } Ent_239918;
+typedef struct { int unk0, unk4, unk8, unkC, unk10, unk14, unk18; } Ent_239918;
typedef struct { int v[4]; } Ids_239918;
-typedef struct { char pad0[0x2C]; int f2C; } Arena_239918;
+typedef struct { char pad0[0x2C]; int unk2C; } Arena_239918;
typedef struct {
char pad0[0x50];
@@ -765,26 +783,26 @@ int FUN_L00_00238f88(Elem_239918 *element) {
float angle = func_001FA748_239918((float)i * 2.0f * 3.1415927f / (float)D_L00_0015FA90 - 3.1415927f, 1.5707964f);
icon_x = x + D_L00_0015F720 + (int)(D_L00_0015F78C * func_001F9F90_239918(angle) * D_L00_0015F7C4);
icon_y = y + D_L00_0015F724 + (int)(D_L00_0015F78C * func_001F9FA8_239918(angle));
- if (element->sel == i && D_L00_0015FAC0_c2[D_L00_0015F72C][i].f0 != 0) {
+ if (element->sel == i && D_L00_0015FAC0_c2[D_L00_0015F72C][i].unk0 != 0) {
func_00200468_239918(func_00200198_239918(0xE99C, 0), icon_x - 0x13, icon_y - 0x13, 0x26, 0x26, pulse_alpha);
}
- if (D_L00_0015FAC0_c2[D_L00_0015F72C][i].f0 != 0) {
+ if (D_L00_0015FAC0_c2[D_L00_0015F72C][i].unk0 != 0) {
if (i != element->sel) {
alpha = func_001FA898_239918((float)frame_alpha * D_L00_0015F7C0);
} else {
alpha = frame_alpha;
}
- if (((Arena_239918 *)D_L00_0017E5D8_239918)->f2C != 0) {
- func_L00_0023BAB8_239918(element, func_00200198_239918(D_L00_0015FAC0_c2[D_L00_0015F72C][i].f0, D_L00_0015FAC0_c2[D_L00_0015F72C][i].f4), icon_x, icon_y, 1, alpha);
+ if (((Arena_239918 *)D_L00_0017E5D8_239918)->unk2C != 0) {
+ func_L00_0023BAB8_239918(element, func_00200198_239918(D_L00_0015FAC0_c2[D_L00_0015F72C][i].unk0, D_L00_0015FAC0_c2[D_L00_0015F72C][i].unk4), icon_x, icon_y, 1, alpha);
} else {
- func_L00_0023BAB8_239918(element, func_00200198_239918(D_L00_0015FAC0_c2[D_L00_0015F72C][i].f0, D_L00_0015FAC0_c2[D_L00_0015F72C][i].f4 + 4), icon_x, icon_y, 1, frame_alpha);
+ func_L00_0023BAB8_239918(element, func_00200198_239918(D_L00_0015FAC0_c2[D_L00_0015F72C][i].unk0, D_L00_0015FAC0_c2[D_L00_0015F72C][i].unk4 + 4), icon_x, icon_y, 1, frame_alpha);
}
}
}
selected = element->sel;
- if (selected >= 0 && D_L00_0015FAC0_c2[D_L00_0015F72C][selected].f0 != 0) {
+ 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].f0 != 0) {
+ if (D_L00_0015FAC0_c2[D_L00_0015F72C][selected].unk0 != 0) {
text = func_001FE540_239918(text_ids.v[selected]);
if (text != 0 && func_00116810_239918(text) != 0) {
float fade = text_fade * open_fade;
@@ -921,7 +939,7 @@ extern s32 FUN_001ff960_c(s32, s32) __asm__("FUN_001ff960");
extern void draw_hud_sprite_flipped(s32, s32, s32, s32, s32, s32) __asm__("FUN_001ffe18");
extern void FUN_001ffc30_c(s32, s32, s32, s32, s32, s32) __asm__("FUN_001ffc30");
extern void FUN_L00_0023b120_c(Hud *, s32, s32, s32, s32, s32) __asm__("FUN_L00_0023b120");
-extern s32 D_0015ED80_c __asm__("D_0015ED80");
+extern int pal_mode __asm__("D_0015ED80");
extern s32 hero_max_health __asm__("D_0015EDA0");
extern s32 D_L00_0015F808 __attribute__((sda));
extern s32 D_L00_0015F7F0_gp __asm__("D_L00_0015F7F0") __attribute__((sda));
@@ -937,8 +955,8 @@ s32 FUN_L00_00239810(Hud *m) {
s32 x;
s32 y;
s32 cnt;
- f32 f21;
- f32 f22;
+ f32 ratio_x;
+ f32 ratio_y;
s32 alpha;
s32 w;
s16 *p;
@@ -961,7 +979,7 @@ s32 FUN_L00_00239810(Hud *m) {
if (hero.state.current == 0x32)
goto out;
x = m->x;
- if (D_0015ED80_c != 0)
+ if (pal_mode != 0)
y = D_L00_0015F808 + 10;
else
y = D_L00_0015F808 + 0x12;
@@ -969,18 +987,18 @@ s32 FUN_L00_00239810(Hud *m) {
q = m->ab;
if (q[0] == 0)
goto out;
- f21 = FUN_001fa6c0(q[0]) / FUN_001fa6c0(D_L00_0015F7F0_gp);
- if (1.0f < f21)
- f21 = 1.0f;
- else if (f21 < 0.0f)
- f21 = 0.0f;
- f22 = FUN_001fa6c0(q[1]) / FUN_001fa6c0(D_L00_0015F7F0_gp);
- if (1.0f < f22)
- f22 = 1.0f;
- else if (f22 < 0.0f)
- f22 = 0.0f;
- alpha = truncate_float_to_s32(f22 * 128.0f);
- w = truncate_float_to_s32((f32)D_L00_0015F820 * f21);
+ ratio_x = FUN_001fa6c0(q[0]) / FUN_001fa6c0(D_L00_0015F7F0_gp);
+ if (1.0f < ratio_x)
+ ratio_x = 1.0f;
+ else if (ratio_x < 0.0f)
+ ratio_x = 0.0f;
+ ratio_y = FUN_001fa6c0(q[1]) / FUN_001fa6c0(D_L00_0015F7F0_gp);
+ if (1.0f < ratio_y)
+ ratio_y = 1.0f;
+ else if (ratio_y < 0.0f)
+ ratio_y = 0.0f;
+ alpha = truncate_float_to_s32(ratio_y * 128.0f);
+ w = truncate_float_to_s32((f32)D_L00_0015F820 * ratio_x);
p = m->p;
sel = p[0] >> 1;
mode = hero_max_health;
@@ -990,16 +1008,16 @@ s32 FUN_L00_00239810(Hud *m) {
mode = hero.health.unk22AC;
if (mode == 8) {
tab = D_L00_0017E478;
- a = truncate_float_to_s32(f21 * 48.0f);
- b = truncate_float_to_s32(f21 * 48.0f);
+ a = truncate_float_to_s32(ratio_x * 48.0f);
+ b = truncate_float_to_s32(ratio_x * 48.0f);
} else if (mode == 5) {
tab = D_L00_0017E460;
- a = truncate_float_to_s32(f21 * 32.0f);
- b = truncate_float_to_s32(f21 * 16.0f);
+ a = truncate_float_to_s32(ratio_x * 32.0f);
+ b = truncate_float_to_s32(ratio_x * 16.0f);
} else {
b = 0;
tab = (Pt *)D_L00_0015F7F8;
- a = truncate_float_to_s32(f21 * 48.0f);
+ a = truncate_float_to_s32(ratio_x * 48.0f);
}
yy = y + D_L00_0015F810;
h1 = FUN_001ff960_c(0x7580, 1);
@@ -1022,7 +1040,7 @@ s32 FUN_L00_00239810(Hud *m) {
FUN_L00_0023b120_c(m, r, x + tab[i].x, y + tab[i].y, 1, alpha);
r = FUN_001ff960_c(0x7536, 0x1F);
FUN_001ffc30_c(r, x + tab[i].x + 0xE, y + tab[i].y - 0x11, 0x22, 0x22,
- truncate_float_to_s32((f32)(p[1] >> 4) * f22));
+ truncate_float_to_s32((f32)(p[1] >> 4) * ratio_y));
if (cnt == i + 1)
sel = 0x1E;
else
diff --git a/src/sdk/library/sceDbcCreateSocket.c b/src/sdk/library/sceDbcCreateSocket.c
new file mode 100644
index 0000000000..2b58729dd6
--- /dev/null
+++ b/src/sdk/library/sceDbcCreateSocket.c
@@ -0,0 +1,33 @@
+/* Ported from rac1-decomp (src/core/001236F0.c, func_00124858). */
+#include "types.h"
+
+extern s32 D_0015B080[];
+extern u8 D_0015B008[];
+extern u8 D_00153578[];
+extern s32 sceSifCallRpc();
+extern void debug_print_stub(u8 *) __asm__("func_00124A20");
+
+/* The header words are copied as pointers: their alias set differs from
+ the int port/mode stores, so the header loads need not wait for them. */
+s32 sceDbcCreateSocket(void *params, s32 port, s32 mode) {
+ s32 *buf = D_0015B080;
+ u8 *name_source = (u8 *)params + 0x14;
+ u8 *name_target = (u8 *)buf + 0x14;
+ s32 i;
+
+ buf[10] = port;
+ buf[11] = mode;
+ ((void **)buf)[0] = ((void **)params)[0];
+ ((void **)buf)[1] = ((void **)params)[1];
+ ((void **)buf)[2] = ((void **)params)[2];
+ ((void **)buf)[3] = ((void **)params)[3];
+ ((void **)buf)[4] = ((void **)params)[4];
+ for (i = 0; i < 0x10; i++) {
+ name_target[i] = name_source[i];
+ }
+ if (sceSifCallRpc(D_0015B008, 0x80000901, 0, D_0015B080, 0x400, D_0015B080, 0x400, 0, 0) < 0) {
+ debug_print_stub(D_00153578);
+ return 0;
+ }
+ return buf[9];
+}
diff --git a/src/video/decoder/vi_buf_restart_dma.c b/src/video/decoder/vi_buf_restart_dma.c
new file mode 100644
index 0000000000..a630f3d2a6
--- /dev/null
+++ b/src/video/decoder/vi_buf_restart_dma.c
@@ -0,0 +1,84 @@
+#include "types.h"
+#include "rnc/video/decoder/vi_buf.h"
+#define DGET(a) (*(volatile u32 *)(a))
+#define BLOCK_IN_DMA_RANGE(i, start, n_dma, n) \
+ ((((i) + (n) - (start)) % (n)) >= 0 && (((i) + (n) - (start)) % (n)) < (n_dma))
+extern s32 WaitSema(s32);
+extern s32 SignalSema(s32);
+extern s32 get_fifo_index(struct ViBuf *, u32) __asm__("FUN_0023baf8");
+extern void set_d3_chcr(u32) __asm__("FUN_0023bb40");
+extern void set_d4_chcr(u32) __asm__("FUN_0023bbb0");
+s32 vi_buf_restart_dma(struct ViBuf *f) __asm__("FUN_0023c280");
+
+/* Backs channel 4 up by the qwords still in the IPU FIFO, restarts channels 3 and 4
+ and the IPU bit position saved by vi_buf_stop_dma. */
+s32 vi_buf_restart_dma(struct ViBuf *f) {
+ s32 bp = f->ipu_bp & 0x7F;
+ s32 fifo_qwords = ((f->ipu_bp >> 16) & 3) + ((f->ipu_bp >> 8) & 0xF);
+ u32 madr = f->d4_madr - (fifo_qwords << 4);
+ u32 qwc = f->d4_qwc + fifo_qwords;
+ u32 chcr = f->d4_chcr | 0x100;
+ u32 tadr = f->d4_tadr;
+
+ WaitSema(f->sema);
+
+ if (madr < (u32)f->data) {
+ s32 tag_id;
+ qwc = ((u32)f->data - madr) >> 4;
+ tadr = (u32)f->tag & 0x0FFFFFFF;
+ madr += f->n << 11;
+ tag_id = (f->d4_madr != (u32)f->data && f->d4_madr != (u32)f->data + (f->n << 11)) ? 3 : 0;
+ chcr = (f->d4_chcr & 0x0FFFFFFF) | (tag_id << 28) | 0x100;
+ if (!BLOCK_IN_DMA_RANGE(0, f->dma_start, f->dma_n, f->n)) {
+ f->dma_start = f->n - 1;
+ f->dma_n++;
+ }
+ } else {
+ s32 saved_block = get_fifo_index(f, f->d4_madr);
+ s32 block = get_fifo_index(f, madr);
+ if (saved_block != block) {
+ s32 tag_id;
+ s32 size = f->n << 11;
+ qwc = ((u32)f->data + (saved_block << 11) - madr) >> 4;
+ tadr = ((saved_block << 4) + (u32)f->tag) & 0x0FFFFFFF;
+ tag_id = ((u32)f->data + (f->d4_madr - (u32)f->data) % size
+ == (u32)f->data + (((f->dma_start + f->dma_n) % f->n) << 11)) ? 0 : 3;
+ chcr = (f->d4_chcr & 0x0FFFFFFF) | (tag_id << 28) | 0x100;
+ if (!BLOCK_IN_DMA_RANGE(block, f->dma_start, f->dma_n, f->n)) {
+ f->dma_start = block;
+ f->dma_n++;
+ }
+ }
+ }
+
+ if (f->d3_madr != 0 && f->d3_qwc != 0) {
+ DGET(0x1000B010) = f->d3_madr;
+ DGET(0x1000B020) = f->d3_qwc;
+ set_d3_chcr(f->d3_chcr | 0x100);
+ }
+ if (f->dma_n != 0) {
+ for (;;) {
+ if (*(volatile s32 *)0x10002010 >= 0) {
+ break;
+ }
+ }
+ DGET(0x10002000) = bp;
+ for (;;) {
+ if (*(volatile s32 *)0x10002010 >= 0) {
+ break;
+ }
+ }
+ }
+ DGET(0x1000B410) = madr;
+ DGET(0x1000B430) = tadr;
+ DGET(0x1000B420) = qwc;
+ if (f->dma_n != 0) {
+ set_d4_chcr(chcr);
+ }
+ DGET(0x10002010) = f->ipu_ctrl;
+ f->is_active = 1;
+ SignalSema(f->sema);
+ return 1;
+}
+
+extern __typeof__(vi_buf_restart_dma) func_0023C280 __attribute__((alias("FUN_0023c280")));