From 0971e561f1e59004c008cce7c5b9cfec53751d1d Mon Sep 17 00:00:00 2001 From: _checkra1n <97061690+devcheckra1n@users.noreply.github.com> Date: Sat, 29 Aug 2026 18:49:07 -0400 Subject: [PATCH 01/14] world: decompile fifteen setup, list and dispatch functions Three list initialisers: func_800A59A0 and func_800A60D8 thread the 0x40 WorldListNode entries at D_800E582C and the 0x20 WorldChunkHeader entries at D_80109A38, and func_800B392C threads the 32 0x74-byte records at D_8010CB24 backwards from its last element. func_800A0BE4 is the bump allocator over the buffer D_800D05DC points at, taking the panic path when the 0x20800-byte arena would overflow. func_800A7EA4, func_800B5274 and func_800B667C are subsystem resets. The rest: func_800A5B88 walks the loaded chunks for the one whose 9-column grid index matches, func_800AD928 reports whether any actor still has a script running, func_800AD970 packs an actor's position, type and direction into a two-word display record, func_800AF110 picks the light and colour matrices for the current mode, func_800B65E0 drives the AKAO fade commands, func_800B6C84 and func_800B7620 handle the streamed read for slot 2 and report its timing, and func_800B7AC0 copies a name out of the table func_800A40F0 indexes. D_8009A000, D_800E582C and D_80109A38 gain real types; the two ascending free-list loops derive their &array[1] base from the array itself, so the symbols splat named there need no declaration. func_800B6AEC, func_800B6DCC and func_800BBA34 gain prototypes because their addresses are taken. --- src/world/world.c | 264 +++++++++++++++++++++++++++++++++++++++++++--- src/world/world.h | 46 ++++++++ 2 files changed, 295 insertions(+), 15 deletions(-) diff --git a/src/world/world.c b/src/world/world.c index 5807b752..7c64effb 100644 --- a/src/world/world.c +++ b/src/world/world.c @@ -54,7 +54,21 @@ void WmSetRenderBuffers(void) { static s32 WmGetCurrRenderBufferId(void) { return D_800D05E8; } -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A0BE4); +u32* func_800A0BE4(s32 arg0) { + u32* cur; + u32* next; + u32* ret; + + cur = D_800D05E0; + next = (u32*)((arg0 * 0x28) + (s32)cur); + if (next < (u32*)((u8*)D_800D05DC + 0x20800)) { + D_800D05E0 = next; + ret = cur; + } else { + func_800A0B40(1); + } + return ret; +} INCLUDE_ASM("asm/us/world/nonmatchings/world", WmLoadTxzFile); @@ -432,7 +446,17 @@ s16 WmGetNumberOfMapToLoad(void) { return count; } -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A59A0); +void func_800A59A0(void) { + s16 i; + + for (i = 0; i < 0x3F; i++) { + D_800E582C[i].next = &D_800E582C[i + 1]; + } + D_800E582C[i].next = NULL; + D_800E5A30 = D_800E582C; + D_800E5A2C = 0; + D_800E5A34 = 0; +} INCLUDE_ASM("asm/us/world/nonmatchings/world", WmGetElementWithBlockIdAndSetItFirst); @@ -440,7 +464,19 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A5A94); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A5AD8); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A5B88); +void func_800A5B88(WorldListNode* arg0) { + WorldChunkHeader* c; + + c = D_80109D40; + if (c != NULL) { + do { + if ((((c->z >> 2) * 9) + (c->x >> 2)) == arg0->unk4) { + func_800A5AD8(c); + } + c = c->next; + } while (c != NULL); + } +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A5C08); @@ -450,7 +486,17 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A5E28); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A5FB4); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A60D8); +void func_800A60D8(void) { + s16 i; + + for (i = 0; i < 0x1F; i++) { + D_80109A38[i].next = &D_80109A38[i + 1]; + } + D_80109A38[i].next = NULL; + D_80109D38 = D_80109A38; + D_80109D40 = NULL; + D_80109D3C = 0; +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A6168); @@ -557,7 +603,19 @@ static void func_800A7E8C(s32 arg0) { D_80109D6C = arg0; } static void func_800A7E9C(void) {} -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A7EA4); +void func_800A7EA4(void) { + func_800A4DDC(); + func_800A59A0(); + func_800A60D8(); + D_80109D54 = 0; + D_80109D58 = 0; + D_80109D5C = NULL; + D_80109D60 = NULL; + D_800E5828 = 1; + D_80109D64 = 0; + D_80109D68 = 0; + D_80109D6C = 0; +} void WmAbortMapLoadingWrapper(void) { WmAbortMapLoading(); } @@ -1725,9 +1783,35 @@ void WmScriptRunAll(void) { INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AD804); -INCLUDE_ASM("asm/us/world/nonmatchings/world", WmScriptIsAnyScriptRuns); +s32 func_800AD928(void) { + WorldActor* a; + s32 flag; + + flag = D_80109DBA != 0; + a = D_8010AD38; + if (a != NULL && flag == 0) { + do { + flag |= a->scriptIdx != 0; + a = a->next; + } while (a != NULL && flag == 0); + } + return flag; +} + +void func_800AD970(WorldActor* actor) { + u8 type; + u8 slot; + s32* out; -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AD970); + type = actor->actorType; + slot = D_800C6748[type]; + if (slot < 6) { + out = (s32*)((slot * 8) + D_8010AD50); + out[0] = (actor->altPos.vx & 0x7FFFF) | ((type << 19) & 0xF80000) | + ((actor->direction << 20) & 0xFF000000); + out[1] = (actor->altPos.vz & 0x3FFFF) | (actor->altPos.vy << 18); + } +} void func_800ADA08(void) { WorldActor* var_s0; @@ -1886,7 +1970,33 @@ void func_800AF0B0(void) { WmSetGteColourSettings(); } -INCLUDE_ASM("asm/us/world/nonmatchings/world", WmSetGteColourSettings); +void func_800AF110(void) { + MATRIX* m; + s32 mode; + s32 r; + s32 g; + s32 b; + + mode = 2; + if (func_800A1DE0() == mode) { + m = &D_800C6828; + } else { + m = &D_800C6808; + } + SetLightMatrix(m); + if (func_800A1DE0() == mode) { + r = 0x20; + g = 0x20; + b = 0x30; + } else { + r = 0x40; + g = 0x40; + b = 0x40; + } + SetBackColor(r, g, b); + SetColorMatrix(&D_800C6848); + SetFarColor(0, 0, 0); +} void func_800AF1A8(u32 arg0, s32 arg1) { Unk8010B178* temp_v1; @@ -2153,7 +2263,31 @@ void func_800B37E0(s32* arg0, s32* arg1) { INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B3828); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B392C); +void func_800B392C(void) { + s32 off; + s32 next; + s32 i; + + next = (s32)&D_8010D930; + off = 0xD98; + do { + *(s32*)&D_8010CB24[off] = next; + off -= 0x74; + next -= 0x74; + } while (off >= 0); + + i = 4; + D_8010D930 = 0; + D_8010D9A4 = D_8010CB24; + D_8010D9B0 = 0; + D_8010D9AC = 0; + D_8010D9A8 = 0; + D_8010D9B4 = 0; + do { + D_8010D9BA[i] = 0; + i -= 4; + } while (i >= 0); +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B39B4); @@ -2167,7 +2301,22 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B4244); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B45DC); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B5274); +void func_800B5274(void) { + u8* p; + + *(s16*)0x1F800010 = 0; + *(s16*)0x1F800012 = 0x32; + *(s16*)0x1F800014 = 0; + *(s16*)0x1F800020 = 0; + func_800AA0E0(0x1F800000); + *(s16*)0x1F80001C = 0; + *(s16*)0x1F80001A = 0; + *(s16*)0x1F800018 = 0; + func_800B39B4(0, 0, 7, 0); + p = &D_800C6A10[D_800C6940 * 0xC]; + p[3] = 0x10; + p[2] = 0x10; +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B5314); @@ -2227,9 +2376,46 @@ void func_800B65A4(u32 arg0, s32 arg1) { SystemAkaoExecute(); } -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B65E0); +void func_800B65E0(s32 arg0) { + if (D_8010CB20 < arg0) { + D_8009A000[0] = 0x20; + D_8010CB20 = arg0; + D_8009A004[0] = 0x40; + D_8009A008[0] = arg0; + } else if (arg0 == -D_8010CB20) { + D_8010CB20 = 0; + D_8009A000[0] = 0xF1; + SystemAkaoExecute(); + D_8009A000[0] = 0xBC; + D_8009A004[0] = 0; + } else { + return; + } + SystemAkaoExecute(); +} + +void func_800B667C(void) { + s32 i; -INCLUDE_ASM("asm/us/world/nonmatchings/world", WmInitModelVariablesAndArray); + i = 0; + do { + D_801159E8[i] = -1; + D_80115A14[i] = 0; + i++; + } while (i < 0x2B); + D_80115A40 = NULL; + D_80115A44 = 0; + D_80115A50 = 0; + D_80115A4C = 0; + D_80115A48 = 0; + D_80115A54 = 0; + D_80115A64 = 0; + D_80115A5C = 0; + D_80115A60 = 0; + D_80115A58 = 0; + D_80115A68 = 0; + D_800C80BC = D_80115A6C; +} INCLUDE_ASM("asm/us/world/nonmatchings/world", WmCalculateBonesAndLighting); @@ -2247,7 +2433,18 @@ void WmPcCharModelLoadFileCallback(void) { INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B6B28); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B6C84); +void func_800B6C84(void) { + if (D_80115A60 == 0) { + func_800A7F38(); + D_80115A40 = (u_long*)func_800A86C4(2); + if (func_800ADC80(2) != 0) { + D_80115A60 = 1; + D_80115A50 = 0; + DS_read(D_800C74DC, D_800C74E0, D_80115A40, func_800B6DCC); + SystemCdromReadChain(); + } + } +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B6D10); @@ -2332,7 +2529,27 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B7228); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B7480); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B7620); +void func_800B7620(s32* arg0, s32* arg1, s32* arg2) { + u16* p; + s32 flags; + + if (arg0 != NULL) { + *arg0 = D_8011626C; + } + if (arg1 != NULL) { + *arg1 = D_80116270; + } + if (arg2 != NULL) { + flags = D_80116274; + if (D_80116278 != 0) { + flags |= 0x20000000; + } + *arg2 = flags; + } + p = &D_8009D2A6; + *p |= 0x300; + func_800B7480(); +} void func_800B76A8(void) { u32 var_a0; @@ -2418,7 +2635,24 @@ s32 WmGetPcCharModelIdFromParty(void) { INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B7A40); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B7AC0); +void func_800B7AC0(s16 arg0) { + u8* src; + u8* base; + u8* dst; + u8* end; + s32 term; + u8 c; + + src = (u8*)func_800A40F0(arg0); + term = 0xFF; + base = (u8*)D_8009D288; + dst = base + 0x368; + end = base + 0x380; + do { + c = *src++; + *dst++ = c; + } while (c != term && (s32)dst < (s32)end); +} void func_800B7B1C(u8 arg0) { D_8009D684 = arg0; } diff --git a/src/world/world.h b/src/world/world.h index 122fcb73..da80f148 100644 --- a/src/world/world.h +++ b/src/world/world.h @@ -178,6 +178,8 @@ s32 func_800B7200(); void WmSetFieldToLoad(s32); void func_800B77A8(s32); s32 WmGetPcCharModelIdFromParty(); +void func_800BBA34(s32); +s32 func_800B79B8(); static void func_800B7C44(void); s32 func_800B7C7C(); void func_800B7838(); @@ -250,6 +252,7 @@ extern s32 D_80109D6C; extern WorldActor D_80109D74[0x10]; // World map actor heap, TODO: Confirm size extern WorldActor D_80109E54; extern WorldActor* D_8010AD34; +extern s16 D_80109DBA; extern WorldActor* D_8010AD38; extern WorldActor* D_8010AD3C; // Active Actor extern WorldActor* D_8010AD40; // Player Actor @@ -312,6 +315,10 @@ extern s32 D_8010CB18; extern s32 D_8010CB1C; extern s32 D_801159DC; extern s32 D_801159E0; +extern s32 D_800C74DC; +extern s32 D_800C74E0; +extern u_long* D_80115A40; +void func_800B6DCC(void); extern s32 D_80115A50; extern s32 D_80115A58; extern s32 D_80115A60; @@ -322,6 +329,18 @@ typedef struct WorldListNode { /* 0x4 */ s16 unk4; } WorldListNode; +extern u8 D_800C68E8[]; +extern u8 D_800C68FC[]; +extern u8 D_800C6910[]; +extern WorldChunkHeader D_80109A38[0x20]; +extern WorldChunkHeader* D_80109D38; +extern s32 D_80109D3C; +extern WorldChunkHeader* D_80109D40; +void func_800A5AD8(WorldChunkHeader*); +extern WorldListNode D_800E582C[0x40]; +extern s32 D_800E5A2C; +extern WorldListNode* D_800E5A30; + extern WorldListNode* D_800E5768; extern s16 D_800BE5F0[]; extern s32 D_8010B488[]; @@ -356,7 +375,34 @@ extern s16 D_800832A2[]; extern s32 D_80109D64; extern s32 D_80109D68; extern u8 D_8010D9B8[]; +extern u8 D_8010CB24[]; +extern s32 D_8010D930; +extern u8* D_8010D9A4; +extern s32 D_8010D9A8; +extern s32 D_8010D9AC; +extern s32 D_8010D9B0; +extern s32 D_8010D9B4; +extern s32 D_80115A44; +extern s32 D_80115A4C; +extern s32 D_80115A54; +extern u8 D_80115A6C[]; +extern u8* D_800C80BC; +extern u32 D_8014A608; +extern s32 D_8014A610; +extern s32 D_800C74C4[][2]; +extern s32 D_80115A48; +extern s32 D_80115A5C; +void func_800B6AEC(void); +extern u8 D_800C6940; +extern u8 D_800C6A10[]; +extern MATRIX D_800C6808; +extern MATRIX D_800C6828; +extern MATRIX D_800C6848; +extern s32 D_8010CB20; +extern u8 D_800C6748[]; +extern s32 D_8010AD50; extern u8 D_8010D9BA[]; +extern u16 D_8009D2A6; extern s32 D_80116274; extern s16 D_80116288; extern s16 D_8011628C; From 71dc6e602b3bda1a9d192f1fa78c8c6f6ffc4dfb Mon Sep 17 00:00:00 2001 From: _checkra1n <97061690+devcheckra1n@users.noreply.github.com> Date: Sun, 30 Aug 2026 16:34:32 -0400 Subject: [PATCH 02/14] world: decompile the camera transform, heading blend and actor placement --- src/world/world.c | 72 +++++++++++++++++++++++++++++++++++++++++++++-- src/world/world.h | 1 + 2 files changed, 70 insertions(+), 3 deletions(-) diff --git a/src/world/world.c b/src/world/world.c index 7c64effb..60ef2ee2 100644 --- a/src/world/world.c +++ b/src/world/world.c @@ -139,7 +139,20 @@ static s32 WmGetWmId(void) { return D_800E5634; } INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A1DF0); -INCLUDE_ASM("asm/us/world/nonmatchings/world", WmSetTranslationVectorInScreenSpace); +void func_800A1FAC(SVECTOR* arg0) { + MATRIX m; + SVECTOR v; + VECTOR out; + int flag; + + v = *arg0; + v.vy = -D_80116508; + SetRotMatrix(&D_800E5698); + SetTransMatrix(&D_800E56B8); + RotTrans(&v, &out, &flag); + TransMatrix(&m, &out); + SetTransMatrix(&m); +} void func_800A2040(void) { SetRotMatrix(&D_800E5698); @@ -984,7 +997,26 @@ void func_800A9678(s16 arg0) { func_800A9520(D_8010AD3C, arg0); } void func_800A96A4(s16 arg0) { func_800A9520(D_8010AD40, arg0); } -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A96D0); +void func_800A96D0(s16 arg0) { + WorldActor* actor; + u32 blend; + + if (D_8010AD3C != NULL) { + actor = D_8010AD3C; + if (D_8011650C == 1) { + if (actor->flags1 & 1) { + blend = (u32)(((s16)actor->unk3E * 15) + arg0) >> 4; + } else { + blend = (u32)(((s16)actor->unk3E * 3) + arg0) >> 2; + } + } else if (actor->flags1 & 1) { + blend = (u32)(((s16)actor->unk3E * 7) + arg0) >> 3; + } else { + blend = (u32)((s16)actor->unk3E + arg0) >> 1; + } + actor->unk3E = blend; + } +} s16 func_800A97A8(void) { return D_8010AD3C == NULL ? 0 : D_8010AD3C->unk3C + D_8010AD3C->unk3E; } @@ -1821,7 +1853,41 @@ void func_800ADA08(void) { func_800AD970(var_s0); } -INCLUDE_ASM("asm/us/world/nonmatchings/world", WmRestoreEntityPosAndDirFromSavemap); +void func_800ADA64(WorldActor* arg0) { + s32* p; + s32* end; + s32 t; + s16 f; + s32 type; + + p = (s32*)D_8010AD50; + end = (s32*)(D_8010AD50 + 0x30); + if (p < end) { + type = arg0->actorType; + while (p < end) { + if (((*p >> 19) & 0x1F) == type) { + break; + } + p += 2; + } + if (p < (s32*)(D_8010AD50 + 0x30) && arg0 != NULL) { + t = p[0] & 0x7FFFF; + arg0->altPos.vx = t; + arg0->pos.vx = t; + t = p[1] >> 18; + arg0->altPos.vy = t; + arg0->pos.vy = t; + t = p[1] & 0x3FFFF; + arg0->altPos.vz = t; + arg0->pos.vz = t; + f = (p[0] >> 20) & 0xFF0; + arg0->unk3E = 0; + arg0->direction = f; + arg0->unk3C = f; + arg0->facing = f; + } + } +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800ADB30); diff --git a/src/world/world.h b/src/world/world.h index da80f148..160c87d1 100644 --- a/src/world/world.h +++ b/src/world/world.h @@ -315,6 +315,7 @@ extern s32 D_8010CB18; extern s32 D_8010CB1C; extern s32 D_801159DC; extern s32 D_801159E0; +extern u16 D_80116508; extern s32 D_800C74DC; extern s32 D_800C74E0; extern u_long* D_80115A40; From 5e6e700f0ff4f8ea6ae6a3a703f4ebed8b488ba8 Mon Sep 17 00:00:00 2001 From: _checkra1n <97061690+devcheckra1n@users.noreply.github.com> Date: Sun, 30 Aug 2026 16:57:33 -0400 Subject: [PATCH 03/14] world: decompile the akao cue, actor collision, minigame state and chunk registration --- src/world/world.c | 209 +++++++++++++++++++++++++++++++++++++++++++--- src/world/world.h | 9 +- 2 files changed, 206 insertions(+), 12 deletions(-) diff --git a/src/world/world.c b/src/world/world.c index 60ef2ee2..83679ef3 100644 --- a/src/world/world.c +++ b/src/world/world.c @@ -517,7 +517,39 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A63FC); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A64AC); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A67A8); +WorldChunkHeader* func_800A67A8(void) { + WorldChunkHeader* chunk; + WorldChunkHeader* prev; + WorldChunkHeader* head; + + chunk = NULL; + if (D_80109D38 != NULL) { + chunk = D_80109D38; + D_80109D38 = chunk->next; + } else if (D_80109D3C != NULL) { + chunk = D_80109D3C; + prev = NULL; + if (chunk->next != NULL) { + do { + prev = chunk; + chunk = chunk->next; + } while (chunk->next != NULL); + } + if (prev != NULL) { + prev->next = NULL; + } else { + D_80109D3C = NULL; + } + func_800A9064(chunk->x, chunk->z); + } + if (chunk != NULL) { + head = D_80109D40; + D_80109D40 = chunk; + chunk->numVerts = 0; + chunk->next = head; + } + return chunk; +} void WmExtractLoopCoordsTopBottomParts(VECTOR* arg0, SVECTOR* arg1, s16* arg2, s16* arg3) { if (arg2 != NULL) { @@ -1198,15 +1230,39 @@ static void func_800AA2E4(s8 arg0) { INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA304); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA580); +WorldActor* func_800AA580(WorldActor* arg0) { + WorldActor* hit; + s32 rc; + + rc = 0; + hit = NULL; + if (D_8010AD3C != NULL) { + if (D_8010AD3C->actorType != 0xD || func_800A1DE0() != 0) { + hit = D_8010AD38; + if (hit != NULL) { + do { + rc = func_800AA304(D_8010AD3C, hit); + if (rc != 0) { + break; + } + hit = hit->next; + } while (hit != NULL); + if (hit != NULL) { + D_8010AD3C->collide = hit; + } + } + } + } + return rc < 2 ? hit : NULL; +} s32 func_800AA640(void) { - s32 temp_v0; + WorldActor* temp_v0; temp_v0 = func_800AA580(D_8010AD3C); - if (temp_v0 != 0) + if (temp_v0 != NULL) func_800AA1B8(); - return temp_v0; + return (s32)temp_v0; } WorldActor* func_800AA684(void) { return D_8010AD3C != NULL ? D_8010AD3C->collide : NULL; } @@ -1263,7 +1319,42 @@ void func_800AA8D8(s16 arg0, s16 arg1, s16 arg2) { INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA8F8); -INCLUDE_ASM("asm/us/world/nonmatchings/world", WmGetBuggyMoveAnimationId); +s32 func_800AAA00(u8* arg0) { + s32 prev; + s32 event; + + prev = D_80109D70; + event = func_800A9A44(); + switch (D_80109D70) { + case 1: + if (event == 0xB) { + D_80109D70 = 2; + } + break; + case 2: + if (*arg0 >= 6) { + D_80109D70 = 3; + } + break; + case 3: + if (event != 4 && event != 0xB) { + D_80109D70 = 4; + } + break; + case 4: + if (*arg0 >= 6) { + D_80109D70 = 1; + } + break; + default: + D_80109D70 = 1; + break; + } + if (D_80109D70 != prev) { + *arg0 = 0; + } + return D_80109D70; +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AAB18); @@ -1813,7 +1904,32 @@ void WmScriptRunAll(void) { WmScriptRunOne(D_8010ADE4 = D_8010AD3C = var_s0); } -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AD804); +void func_800AD804(void) { + s32 kind; + + if (D_8010ADEC != 0 || (D_8010AD40->flags1 & 8)) { + return; + } + if (func_800A91A4(0x2000) != 0) { + if ((D_8010AD40->pos.vy - D_8010AD40->unk42) >= 0x1F4) { + return; + } + } else if (D_8010AD40->flags1 & 0x80) { + return; + } + kind = func_800A9AD0(); + if (kind >= 3) { + if (D_8010ADF0 != kind) { + D_8010ADF0 = kind; + func_800ABA78(kind - 3, 0); + } + if (kind == 7 && func_800A91A4(0x2000) == 0) { + func_800AA238(); + } + } else { + D_8010ADF0 = 0; + } +} s32 func_800AD928(void) { WorldActor* a; @@ -1895,7 +2011,23 @@ void func_800ADC3C(VECTOR* arg0) { D_8010AE34 = *arg0; } void func_800ADC70(void) { D_8010AE54 = 0; } -INCLUDE_ASM("asm/us/world/nonmatchings/world", WmAddMutexPriority); +s32 func_800ADC80(s16 arg0) { + if ((D_8010AE54 >> arg0) & 1) { + if (!((-1 << (arg0 + 1)) & D_8010AE54)) { + return 1; + } + } + if (D_8010AE54 < (1 << arg0)) { + if (D_8010AE54 == 1) { + func_800A7F38(); + } else if (D_8010AE54 & 4) { + func_800B7134(); + } + D_8010AE54 |= 1 << arg0; + return 1; + } + return 0; +} void WmRemoveMutexPriority(s16 arg0) { u32 var_v1; @@ -2222,7 +2354,42 @@ void func_800B104C(void) { D_8010CAF4 = 0; } -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B10AC); +void func_800B10AC(WorldChunkHeader* arg0) { + WorldChunkHeader** slot; + WorldTriangle* t; + u8* p; + + if (arg0 == NULL) { + return; + } + slot = D_8010CA24; + if (slot < D_8010CA74) { + while (slot < D_8010CA74) { + if (*slot == arg0) { + break; + } + slot++; + } + if (slot < D_8010CA74) { + return; + } + } + if (D_8010CA74 >= &D_8010CA24[20]) { + func_800A0B40(0x47); + } + slot = D_8010CA74; + D_8010CA74 = slot + 1; + *slot = arg0; + t = arg0->tris; + if (t < arg0->tris + arg0->numTris) { + p = (u8*)t + 0xB; + do { + *p &= 0xBF; + t++; + p += 0xC; + } while (t < arg0->tris + arg0->numTris); + } +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B11C4); @@ -2415,7 +2582,29 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B6348); static void func_800B63E0(s32 arg0) { D_801159DC = arg0; } -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B63F0); +void func_800B63F0(s32 arg0) { + s16* cmd; + s32 prev; + + if (D_801159DC != 0) { + cmd = D_8009A000; + if (arg0 != 1) { + s16 mode = 0x10; + if (D_801159E0 == 1) { + mode = 0x14; + } + *cmd = mode; + } else { + *cmd = 0x18; + } + D_8009A004[0] = D_801159BC[arg0]; + D_8009A008[0] = 4; + SystemAkaoExecute(); + } + prev = D_801159E0; + D_801159E0 = arg0; + D_80116510 = prev; +} void func_800B64A0(void) { func_800B63F0(D_801159E0); } diff --git a/src/world/world.h b/src/world/world.h index 160c87d1..782914a7 100644 --- a/src/world/world.h +++ b/src/world/world.h @@ -151,7 +151,7 @@ s32 WmGetPcEntityTerrainId(void); s32 func_800A9B04(s16, u8); void func_800A9C64(WorldActor*, VECTOR*); s32 func_800AA304(WorldActor*, WorldActor*); -s32 func_800AA580(WorldActor*); +WorldActor* func_800AA580(WorldActor*); void func_800AAB18(WorldActor*); void func_800AB398(WorldActor*); void func_800AB48C(WorldActor*); @@ -249,6 +249,7 @@ extern VECTOR D_80109D44; extern s32 D_80109D54; extern s32 D_80109D58; extern s32 D_80109D6C; +extern s32 D_80109D70; extern WorldActor D_80109D74[0x10]; // World map actor heap, TODO: Confirm size extern WorldActor D_80109E54; extern WorldActor* D_8010AD34; @@ -272,6 +273,7 @@ extern Unk8010AD70 D_8010AD70[1]; // todo: size extern Unk8010AD70* D_8010AD90; extern u8* D_8010AD94[4]; extern s32 D_8010ADEC; +extern s16 D_8010ADF0; extern s32 D_8010AE24; extern s32 D_8010AE28; extern s32 D_8010AE2C; @@ -293,7 +295,8 @@ extern s32 D_8010C804; extern s32 D_8010C808; extern s32 D_8010CA1C; extern s32 D_8010CA20; -extern s32 D_8010CA74; +extern WorldChunkHeader* D_8010CA24[20]; +extern WorldChunkHeader** D_8010CA74; extern s32 D_8010CA78; extern s32 D_8010CA8C; extern s32 D_8010CAC0; @@ -313,9 +316,11 @@ extern s16 D_8010CB10; extern u32 D_8010CB14; extern s32 D_8010CB18; extern s32 D_8010CB1C; +extern s32 D_801159BC[]; extern s32 D_801159DC; extern s32 D_801159E0; extern u16 D_80116508; +extern s32 D_80116510; extern s32 D_800C74DC; extern s32 D_800C74E0; extern u_long* D_80115A40; From 7dcad70dc6cda0a5ec0da7d7e00c40a1f51db7c4 Mon Sep 17 00:00:00 2001 From: _checkra1n <97061690+devcheckra1n@users.noreply.github.com> Date: Sun, 30 Aug 2026 17:37:20 -0400 Subject: [PATCH 04/14] world: decompile the chunk/triangle record, draw-mode setup and free-list handling --- src/world/world.c | 310 +++++++++++++++++++++++++++++++++++++++++++--- src/world/world.h | 30 ++++- 2 files changed, 321 insertions(+), 19 deletions(-) diff --git a/src/world/world.c b/src/world/world.c index 83679ef3..77c36d5a 100644 --- a/src/world/world.c +++ b/src/world/world.c @@ -198,7 +198,19 @@ void func_800A31C0(s16 arg0) { D_800E5668 = arg0 - 0x800 + D_800E5608; } s32 func_800A31E8(void) { return !D_800E5628; } -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A31F8); +void func_800A31F8(void) { + s32 level; + + if (D_800E5650 == 0) { + level = 120 - ((D_800E5660 * 30) >> 8); + } else { + level = 160 - ((D_800E5660 * 70) >> 8); + } + D_800E55F0 = level; + D_800C65EC = 400 - ((D_800E5660 * 200) >> 8); + D_800E5614 = 10000 - ((D_800E5660 * 6000) >> 8); + D_800E5678 = 5000 - ((D_800E5660 * 2500) >> 8); +} s32 func_800A32F4(void) { return D_800E5678; } @@ -340,7 +352,34 @@ void func_800A41E8(s32 arg0) { D_800E56F4 = arg0; } -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A4268); +void func_800A4268(void) { + s32 slot; + s32 vsync; + + slot = func_800A0BD4(); + switch (D_800E56F4) { + case 1: + if (func_800B0240() != 0) { + D_800E56F4 = 2; + } + break; + case 2: + vsync = VSync(-1); + D_800C6648[slot].v0 = ((vsync >> 2) & 0x10) - 128; + addPrim(D_800BD130, &D_800C6648[slot]); + addPrim(D_800BD130, &D_800E56DC[slot]); + if ((u32)((vsync - D_800C84F0) - 4) < 2) { + D_800E56F4 = 3; + } + D_800C84F0 = vsync; + break; + case 3: + D_800C6648[slot].v0 = 160; + addPrim(D_800BD130, &D_800C6648[slot]); + addPrim(D_800BD130, &D_800E56DC[slot]); + break; + } +} void func_800A4494(s32 arg0) { D_800E561C = arg0; } @@ -413,25 +452,111 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A4F78); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A5208); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A52A4); +WorldListNode* func_800A52A4(void) { + WorldListNode* node; + WorldListNode* prev; + WorldListNode* head; + + if (D_800E5760 != NULL) { + node = D_800E5760; + D_800E5760 = node->next; + } else { + node = D_800E5764; + if (node != NULL) { + prev = NULL; + if (node->next != NULL) { + do { + prev = node; + node = node->next; + } while (node->next != NULL); + } + if (prev != NULL) { + prev->next = NULL; + } else { + node = NULL; + } + } + } + if (node != NULL) { + head = D_800E5768; + D_800E5768 = node; + node->next = head; + } + return node; +} -void func_800A5348(void* arg0, void** arg1) { - void* tmp; +void func_800A5348(WorldListNode* arg0, WorldListNode* arg1) { + WorldListNode* tmp; if (arg1 != NULL) { - *arg1 = *(void**)arg0; + arg1->next = arg0->next; } else { - D_800E5810 = *(s32*)arg0; + D_800E5810 = arg0->next; } WmStartLoadingMapFileBlock(arg0); tmp = D_800E580C; D_800E580C = arg0; - *(void**)arg0 = tmp; + arg0->next = tmp; +} + +void func_800A53A8(s16 arg0, s16 arg1) { + WorldListNode* node; + WorldListNode* prev; + WorldListNode* best; + WorldListNode* bestPrev; + s32 bestDist; + s32 dist; + s32 dx; + s32 dz; + s32 row; + s32 col; + s16 idx; + + if (D_800E5814 == 0 && D_800E5810 != NULL) { + if (func_800ADC80(0) != 0) { + bestPrev = NULL; + best = NULL; + bestDist = 0x7FFF; + node = D_800E5810; + prev = NULL; + if (node != NULL) { + do { + idx = node->unk4; + row = idx / 4; + col = idx - row * 4; + dx = col - arg0; + if (dx <= 0) { + dx = arg0 - col; + } + if (dx >= 0x13) { + dx = 0x24 - dx; + } + dz = row - arg1; + if (dz <= 0) { + dz = arg1 - row; + } + if (dz >= 0xF) { + dz = 0x1C - dz; + } + dist = dx + dz; + if (dist < bestDist) { + bestDist = dist; + best = node; + bestPrev = prev; + } + prev = node; + node = node->next; + } while (node != NULL); + } + if (best == NULL) { + func_800A0B40(0x22); + } + func_800A5348(best, bestPrev); + } + } } -INCLUDE_ASM("asm/us/world/nonmatchings/world", WmLoadClosestMapFileBlock); - INCLUDE_ASM("asm/us/world/nonmatchings/world", WmStartLoadingMapFileBlock); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A57C8); @@ -664,7 +789,42 @@ void func_800A7EA4(void) { void WmAbortMapLoadingWrapper(void) { WmAbortMapLoading(); } -INCLUDE_ASM("asm/us/world/nonmatchings/world", WmAbortMapLoading); +void func_800A7F38(void) { + WorldListNode* node; + WorldListNode* prev; + WorldListNode* head; + + D_800E5828 = 0; + if (D_800E5820 >= 0) { + if (D_800E5814 >= D_8011650C * 5) { + prev = NULL; + SystemCdromAbortLoading(); + node = D_800E5768; + if (node != NULL) { + while (node != NULL) { + if (node == &D_800E5718[D_800E5820]) { + break; + } + prev = node; + node = node->next; + } + } + if (node == NULL) { + func_800A0B40(0xD); + } + if (prev != NULL) { + prev->next = node->next; + } else { + D_800E5768 = node->next; + } + head = D_800E5760; + D_800E5760 = node; + D_800E5814 = 0; + D_800E5820 = -1; + node->next = head; + } + } +} static void func_800A8048(void) { D_800E5828 = 1; } @@ -2272,9 +2432,61 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", WmFadeInit); INCLUDE_ASM("asm/us/world/nonmatchings/world", WmFadeRender); -INCLUDE_ASM("asm/us/world/nonmatchings/world", WmSetFadeIn); +void func_800AFFBC(s32 arg0, s32 arg1) { + s32 i; + s32 tpage; -INCLUDE_ASM("asm/us/world/nonmatchings/world", WmSetFadeOut); + if (D_8010B488[0] > 0) { + D_8010B47C = -arg0; + i = 0; + do { + if (GetGraphType() == 1 || GetGraphType() == 2) { + tpage = 0xA6; + if (arg1 == 1) { + tpage = 0x126; + } + } else { + tpage = 0x36; + if (arg1 == 1) { + tpage = 0x56; + } + } + SetDrawMode( + (DR_MODE*)((i * 0x24) + (s32)D_8010B434), 0, 1, tpage, NULL); + i++; + } while (i < 2); + } else { + D_8010B47C = 0; + } +} + +void func_800B0098(s32 arg0, s32 arg1) { + s32 i; + s32 tpage; + + if (D_8010B488[0] < D_8010B494[0]) { + D_8010B47C = arg0; + i = 0; + do { + if (GetGraphType() == 1 || GetGraphType() == 2) { + tpage = 0xA6; + if (arg1 == 1) { + tpage = 0x126; + } + } else { + tpage = 0x36; + if (arg1 == 1) { + tpage = 0x56; + } + } + SetDrawMode( + (DR_MODE*)((i * 0x24) + (s32)D_8010B434), 0, 1, tpage, NULL); + i++; + } while (i < 2); + } else { + D_8010B47C = 0; + } +} void WmFadeInSnow(s32 arg0) { (&D_8010B47C)[arg0] = (D_8010B488[arg0] < D_8010B494[arg0]) << 4; } @@ -2399,13 +2611,59 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B190C); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B1C80); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B21E4); +void func_800B21E4(WorldChunkHeader* arg0, WorldTriangle* arg1) { + VECTOR pos; + s32 inside; + s32 zoff; + + if (D_8010CA8C == 0 || D_8010CA8C == 2 || D_8010CA8C == 3) { + D_8010CA1C = &D_8010C83C; + D_8010C83C.chunk = arg0; + D_8010C83C.tri = arg1; + D_8010C83C.unk8 = 0; + D_8010CA20 = 0; + D_8010CA78 = 0; + D_8010CA74 = D_8010CA24; + func_800B10AC(arg0); + if (arg1 != NULL) { + *((u8*)arg1 + 0xB) |= 0x40; + } + D_800BD144 = 0; + D_8010CA8C = 1; + func_800AA0E0(&pos); + inside = 0; + if ((u32)(pos.vx - 0x36000) <= 0x9FFF) { + zoff = pos.vz - 0x1C000; + inside = (u32)zoff <= 0x9FFF; + } + D_8010CAF8 = inside; + } +} static void func_800B22E4(void) { func_800B190C(); } INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B2304); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B2638); +void func_800B2638(WorldTriangleRef* arg0, VECTOR* arg1) { + WorldTriangle* tri; + WorldChunkHeader* chunk; + SVECTOR* verts; + + if (arg1 != NULL) { + tri = arg0->tri; + chunk = arg0->chunk; + verts = chunk->verts; + arg1->vx = ((verts[tri->vert[0]].vx + verts[tri->vert[1]].vx + + verts[tri->vert[2]].vx) / + 3) + + (chunk->x << 13); + arg1->vy = 0; + arg1->vz = ((verts[tri->vert[0]].vz + verts[tri->vert[1]].vz + + verts[tri->vert[2]].vz) / + 3) + + (arg0->chunk->z << 13); + } +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B271C); @@ -2443,7 +2701,27 @@ void func_800B28CC(s32 arg0) { INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B29CC); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B2E90); +void func_800B2E90(void) { + func_800B22E4(); + if (D_8010CAF4 != 0) { + if (D_8010CA8C == 3) { + D_8010CAF4 = 0; + D_8010CA8C = 0; + func_800A2108(1, 5); + } else if (D_8010CA8C == 2) { + func_800A1D54(1); + func_800A45C4(6000); + func_800A45D4(1500); + func_800ABA18(8); + D_8010CAF4 = 0; + } + } + if (D_8010CAF0 == 3 && (D_8010CA8C == 2 || D_8010CA8C == 3) && + D_8010CACC == 0 && D_8010CAD0 == 0) { + func_800B271C(3); + } + func_800B29CC(); +} static void func_800B2F94(s32 arg0) { D_8010CAF0 = arg0; } diff --git a/src/world/world.h b/src/world/world.h index 782914a7..06bcb71e 100644 --- a/src/world/world.h +++ b/src/world/world.h @@ -36,6 +36,12 @@ typedef struct WorldChunkHeader { /* 0x16 */ s16 numVerts; } WorldChunkHeader; // size: 0x18 +typedef struct { + /* 0x0 */ WorldChunkHeader* chunk; + /* 0x4 */ WorldTriangle* tri; + /* 0x8 */ s8 unk8; +} WorldTriangleRef; // size: 0xC + typedef struct { /* 0x00 */ s16 scriptIdx; /* 0x02 */ u8 waitFrames; @@ -127,6 +133,8 @@ typedef struct { } Unk8010AD70; void WmSetRenderBuffers(); +void func_800A0B48(); +s32 GetGraphType(void); void func_800A19FC(WorldChunkHeader*, SVECTOR*, WorldStoredTriangle*, s16*, s32, s16*, s32); void func_800A31C0(s16); void func_800A368C(s32); @@ -165,7 +173,12 @@ void WmScriptRunOne(WorldActor*); void func_800AD970(WorldActor*); void WmRemoveMutexPriority(s16); s16 WmGetRotFromVector(s32, s32, s32); +void func_800ADD4C(s16); +s16 func_800AE180(s32, s32, s32); +s32 func_800B0240(void); void func_800B0D98(WorldChunkHeader*); +void func_800B271C(s32); +void func_800B29CC(void); void func_800B1C80(WorldChunkHeader*); void func_800B5274(); void func_800B5C7C(WorldActor*); @@ -224,12 +237,14 @@ extern s32 D_800E5630; // WM earthquake extern s32 D_800E5634; extern s32 D_800E5638; extern s32 D_800E563C; +extern s32 D_800E5614; extern s32 D_800E5644; extern s32 D_800E5648; extern s32 D_800E564C; extern s32 D_800E5650; extern s32 D_800E5654; extern s32 D_800E5658; +extern s32 D_800E5660; extern s32 D_800E5668; extern s32 D_800E566C; extern s32 D_800E5670; @@ -238,6 +253,7 @@ extern s32 D_800E5678; extern MATRIX D_800E5698; extern MATRIX D_800E56B8; extern s16 D_800E56D8; +extern DR_MODE D_800E56DC[]; extern s32 D_800E56F4; extern s32 D_800E56F8; extern s32 D_800E5814; @@ -287,18 +303,21 @@ extern s32 D_8010B080; extern s32 D_8010B174; extern Unk8010B178 D_8010B178[1]; // TODO: determine size extern Unk8010B3B8* D_8010B3B8; +extern u8 D_8010B434[]; extern s32 D_8010B47C; extern WorldZolomSegment D_8010C2AC[0x30]; extern WorldZolomSegment* D_8010C42C; extern s16 D_8010C7F0; extern s32 D_8010C804; extern s32 D_8010C808; -extern s32 D_8010CA1C; +extern WorldTriangleRef D_8010C83C; +extern WorldTriangleRef* D_8010CA1C; extern s32 D_8010CA20; extern WorldChunkHeader* D_8010CA24[20]; extern WorldChunkHeader** D_8010CA74; extern s32 D_8010CA78; extern s32 D_8010CA8C; +extern s32 D_8010CAF8; extern s32 D_8010CAC0; extern s32 D_8010CAC4; extern s32 D_8010CAC8; @@ -347,6 +366,9 @@ extern WorldListNode D_800E582C[0x40]; extern s32 D_800E5A2C; extern WorldListNode* D_800E5A30; +extern WorldListNode D_800E5718[]; +extern WorldListNode* D_800E5760; +extern WorldListNode* D_800E5764; extern WorldListNode* D_800E5768; extern s16 D_800BE5F0[]; extern s32 D_8010B488[]; @@ -362,14 +384,16 @@ extern u8 D_800C752C; extern u8* D_80109D60; extern u8* D_80109D5C; extern u8 D_800BF5F0[]; +extern SPRT D_800C6648[]; +extern s32 D_800C84F0; extern s16 D_8009ABF6; extern s16 D_8009ABF8; extern s16 D_8009ABFA; extern s16 D_8009AC16; extern s16 D_8009AC18; extern u8* D_8009C6DC; -extern s32 D_800E5810; -extern void* D_800E580C; +extern WorldListNode* D_800E5810; +extern WorldListNode* D_800E580C; extern u16 D_80083278[]; extern u16 D_8008327A[]; extern s16 D_80083286[]; From ecd4f1ae15f2e0c0d6b8938ccaf8f8bf824c74ca Mon Sep 17 00:00:00 2001 From: _checkra1n <97061690+devcheckra1n@users.noreply.github.com> Date: Sun, 30 Aug 2026 20:50:34 -0400 Subject: [PATCH 05/14] world: decompile the chunk cache, list searches and zolom segment lookup --- src/world/world.c | 191 ++++++++++++++++++++++++++++++++++++++++++++-- src/world/world.h | 23 ++++-- 2 files changed, 200 insertions(+), 14 deletions(-) diff --git a/src/world/world.c b/src/world/world.c index 77c36d5a..84f5b1c9 100644 --- a/src/world/world.c +++ b/src/world/world.c @@ -559,7 +559,47 @@ void func_800A53A8(s16 arg0, s16 arg1) { INCLUDE_ASM("asm/us/world/nonmatchings/world", WmStartLoadingMapFileBlock); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A57C8); +void func_800A57C8(void) { + WorldListNode* node; + WorldListNode* prev; + WorldListNode* head; + s32 tick; + + if (D_800E5814 >= D_8011650C * 5) { + SystemCdromReadChain(); + } + if (D_800E5814 < D_8011650C * 5 && D_800E5820 >= 0) { + node = D_800E5768; + prev = NULL; + if (node != NULL) { + while (node != NULL) { + if (node == &D_800E5718[D_800E5820]) { + break; + } + prev = node; + node = node->next; + } + } + if (node == NULL) { + func_800A0B40(0xB); + } + if (prev != NULL) { + prev->next = node->next; + } else { + D_800E5768 = node->next; + } + head = D_800E5764; + D_800E5764 = node; + node->next = head; + func_800A5B88(node); + D_800E5820 = -1; + } + tick = 0; + if (D_800E5814 != 0) { + tick = D_800E5814 < D_8011650C * 5; + } + D_800E5814 -= tick; +} void WmMapLoadFinishedCallback(void) { if (D_800E5820 >= 0) { @@ -596,9 +636,47 @@ void func_800A59A0(void) { D_800E5A34 = 0; } -INCLUDE_ASM("asm/us/world/nonmatchings/world", WmGetElementWithBlockIdAndSetItFirst); +WorldListNode* func_800A5A20(s16 arg0) { + WorldListNode* node; + WorldListNode* prev; + WorldListNode* head; + WorldListNode* next; -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A5A94); + node = D_800E5764; + prev = NULL; + if (node != NULL) { + while (node != NULL) { + if (node->unk4 == arg0) { + break; + } + prev = node; + node = node->next; + } + if (node != NULL && prev != NULL) { + next = node->next; + head = D_800E5764; + D_800E5764 = node; + prev->next = next; + node->next = head; + } + } + return node; +} + +s32 func_800A5A94(s16 arg0) { + WorldListNode* node; + + node = D_800E5768; + if (node != NULL) { + while (node != NULL) { + if (node->unk4 == arg0) { + break; + } + node = node->next; + } + } + return node != NULL; +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A5AD8); @@ -622,7 +700,67 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A5D00); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A5E28); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A5FB4); +s32 func_800A5FB4(void) { + WorldChunkHeader* chunk; + WorldChunkHeader* prev; + WorldChunkNode* node; + WorldChunkNode* nodePrev; + WorldChunkHeader* freeChunk; + WorldChunkNode* freeNode; + s32 live; + u16 age; + + live = 0; + chunk = D_80109D40; + prev = NULL; + if (chunk != NULL) { + do { + age = chunk->numVerts; + chunk->numVerts = age + 1; + if ((s16)age >= 0x96) { + if (prev != NULL) { + prev->next = chunk->next; + } else { + D_80109D40 = chunk->next; + } + node = D_800E5A2C; + freeChunk = D_80109D38; + nodePrev = NULL; + D_80109D38 = chunk; + chunk->next = freeChunk; + if (node != NULL) { + while (node != NULL) { + if (node->chunk == chunk) { + break; + } + nodePrev = node; + node = node->next; + } + if (node != NULL) { + if (nodePrev != NULL) { + nodePrev->next = node->next; + } else { + D_800E5A2C = node->next; + } + freeNode = D_800E5A30; + D_800E5A30 = node; + node->next = freeNode; + } + } + if (prev != NULL) { + chunk = prev->next; + } else { + chunk = D_80109D40; + } + } else { + prev = chunk; + chunk = chunk->next; + live++; + } + } while (chunk != NULL); + } + return live; +} void func_800A60D8(void) { s16 i; @@ -836,7 +974,20 @@ static void func_800A82DC(void) { D_80109D54 = 1; } s32 func_800A82F0(void) { return D_80109D58; } -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A8300); +s32 func_800A8300(s16 arg0, s16 arg1) { + WorldChunkHeader* chunk; + + chunk = D_80109D3C; + if (chunk != NULL) { + while (chunk != NULL) { + if (chunk->x == arg0 && chunk->z == arg1) { + break; + } + chunk = chunk->next; + } + } + return chunk != NULL; +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A835C); @@ -2548,7 +2699,27 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B0810); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B0BF4); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B0D98); +void func_800B0D98(WorldChunkHeader* arg0) { + VECTOR pos; + SVECTOR dir; + s16 chunkX; + s16 chunkZ; + s32 hit; + + if (func_800B0794() != 0) { + pos.vx = D_8010C42C->x + 0x34000; + pos.vz = D_8010C42C->z + 0x20000; + func_800A6884(&pos, &dir, &chunkX, &chunkZ); + if (chunkX == arg0->x && chunkZ == arg0->z) { + hit = func_800A19FC( + arg0, &dir, D_8010C80C, &D_8010C42C->z2, 0, NULL, 0x64); + D_8010C800 = hit; + if (hit == 0) { + D_8010C42C->z2 = 0; + } + } + } +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B0E84); @@ -3298,7 +3469,13 @@ void WmDialogSetMessageToShowForId0(u8 arg0) { } } -INCLUDE_ASM("asm/us/world/nonmatchings/world", WmDialogSetAskToShowForId0); +void func_800B851C(s32 arg0, s16 arg1, s16 arg2) { + if (g_WindowData[0].state == WSTATE_INIT) { + D_80116288 = arg1; + D_8011628C = arg2; + func_800B90C0(0, arg0, D_80116288, D_8011628C, &D_80116290); + } +} static s32 WmDialogIsWindowWithId0Showing(void) { return g_WindowData[0].state != WSTATE_INIT; } diff --git a/src/world/world.h b/src/world/world.h index 06bcb71e..f5b8c983 100644 --- a/src/world/world.h +++ b/src/world/world.h @@ -42,6 +42,11 @@ typedef struct { /* 0x8 */ s8 unk8; } WorldTriangleRef; // size: 0xC +typedef struct WorldChunkNode { + /* 0x0 */ struct WorldChunkNode* next; + /* 0x4 */ WorldChunkHeader* chunk; +} WorldChunkNode; // size: 0x8 + typedef struct { /* 0x00 */ s16 scriptIdx; /* 0x02 */ u8 waitFrames; @@ -85,8 +90,8 @@ typedef struct WorldActor { } WorldActor; // size: 0xE0 typedef struct { - /* 0x00 */ s16 x; - /* 0x02 */ s16 z; + /* 0x00 */ u16 x; + /* 0x02 */ u16 z; /* 0x04 */ s16 x2; /* 0x06 */ s16 z2; } WorldZolomSegment; // size: 0x8 @@ -135,7 +140,7 @@ typedef struct { void WmSetRenderBuffers(); void func_800A0B48(); s32 GetGraphType(void); -void func_800A19FC(WorldChunkHeader*, SVECTOR*, WorldStoredTriangle*, s16*, s32, s16*, s32); +s32 func_800A19FC(WorldChunkHeader*, SVECTOR*, WorldStoredTriangle*, s16*, s32, s16*, s32); void func_800A31C0(s16); void func_800A368C(s32); void WmExtractLoopCoordsTopBottomParts(VECTOR*, SVECTOR*, s16*, s16*); @@ -179,6 +184,7 @@ s32 func_800B0240(void); void func_800B0D98(WorldChunkHeader*); void func_800B271C(s32); void func_800B29CC(void); +s32 func_800B90C0(u8, u8, u8, u8, s16*); void func_800B1C80(WorldChunkHeader*); void func_800B5274(); void func_800B5C7C(WorldActor*); @@ -308,8 +314,10 @@ extern s32 D_8010B47C; extern WorldZolomSegment D_8010C2AC[0x30]; extern WorldZolomSegment* D_8010C42C; extern s16 D_8010C7F0; +extern s32 D_8010C800; extern s32 D_8010C804; extern s32 D_8010C808; +extern WorldStoredTriangle D_8010C80C[]; extern WorldTriangleRef D_8010C83C; extern WorldTriangleRef* D_8010CA1C; extern s32 D_8010CA20; @@ -359,12 +367,12 @@ extern u8 D_800C68FC[]; extern u8 D_800C6910[]; extern WorldChunkHeader D_80109A38[0x20]; extern WorldChunkHeader* D_80109D38; -extern s32 D_80109D3C; +extern WorldChunkHeader* D_80109D3C; extern WorldChunkHeader* D_80109D40; void func_800A5AD8(WorldChunkHeader*); -extern WorldListNode D_800E582C[0x40]; -extern s32 D_800E5A2C; -extern WorldListNode* D_800E5A30; +extern WorldChunkNode D_800E582C[0x40]; +extern WorldChunkNode* D_800E5A2C; +extern WorldChunkNode* D_800E5A30; extern WorldListNode D_800E5718[]; extern WorldListNode* D_800E5760; @@ -436,6 +444,7 @@ extern u16 D_8009D2A6; extern s32 D_80116274; extern s16 D_80116288; extern s16 D_8011628C; +extern s16 D_80116290; extern s32 D_8011626C; extern s32 D_80116270; extern s32 D_80116278; From 98bc3ec471893606df0479d7120dc125867791ee Mon Sep 17 00:00:00 2001 From: _checkra1n <97061690+devcheckra1n@users.noreply.github.com> Date: Sun, 30 Aug 2026 22:09:21 -0400 Subject: [PATCH 06/14] world: name 22 of the decompiled functions --- config/sym_ovl_export.us.txt | 62 ++++++------ config/symbols.world.txt | 182 +++++------------------------------ src/world/world.c | 70 +++++++------- src/world/world.h | 8 +- 4 files changed, 95 insertions(+), 227 deletions(-) diff --git a/config/sym_ovl_export.us.txt b/config/sym_ovl_export.us.txt index ddf91d64..15d13f10 100644 --- a/config/sym_ovl_export.us.txt +++ b/config/sym_ovl_export.us.txt @@ -1885,10 +1885,10 @@ RestoreCharacterMateria = 0x801d3138; func_801D3260 = 0x801d3260; g_MateriaPriority = 0x801d3834; g_MateriaStealLoot = 0x801d3f60; -WmSetRenderBuffers = 0x800a0b48; -func_800A0BE4 = 0x800a0be4; -WmLoadTxzFile = 0x800a0c54; -WmLoadTxzDataAndInit = 0x800a0d2c; +func_800A0B48 = 0x800a0b48; +AllocPrims = 0x800a0be4; +func_800A0C54 = 0x800a0c54; +func_800A0D2C = 0x800a0d2c; func_800A12AC = 0x800a12ac; WmPrepareForRender = 0x800a1370; WmRenderAll = 0x800a141c; @@ -1941,29 +1941,29 @@ WmInitLoadMapFileStruct = 0x800a4ddc; WmGetBlockIdByXZForPlanet = 0x800a4f08; func_800A4F78 = 0x800a4f78; func_800A5208 = 0x800a5208; -func_800A52A4 = 0x800a52a4; +AllocRegionNode = 0x800a52a4; func_800A5348 = 0x800a5348; -WmLoadClosestMapFileBlock = 0x800a53a8; -WmStartLoadingMapFileBlock = 0x800a54f0; -func_800A57C8 = 0x800a57c8; -WmMapLoadFinishedCallback = 0x800a5924; -WmGetNumberOfMapToLoad = 0x800a5970; -func_800A59A0 = 0x800a59a0; -WmGetElementWithBlockIdAndSetItFirst = 0x800a5a20; -func_800A5A94 = 0x800a5a94; +StartNearestRegionLoad = 0x800a53a8; +func_800A54F0 = 0x800a54f0; +UpdateRegionLoad = 0x800a57c8; +func_800A5924 = 0x800a5924; +func_800A5970 = 0x800a5970; +InitChunkNodePool = 0x800a59a0; +FindResidentRegion = 0x800a5a20; +IsRegionLoading = 0x800a5a94; func_800A5AD8 = 0x800a5ad8; func_800A5B88 = 0x800a5b88; func_800A5C08 = 0x800a5c08; func_800A5D00 = 0x800a5d00; func_800A5E28 = 0x800a5e28; -func_800A5FB4 = 0x800a5fb4; -func_800A60D8 = 0x800a60d8; +ExpireChunks = 0x800a5fb4; +InitChunkPool = 0x800a60d8; func_800A6168 = 0x800a6168; func_800A63FC = 0x800a63fc; func_800A64AC = 0x800a64ac; -func_800A67A8 = 0x800a67a8; -WmExtractLoopCoordsTopBottomParts = 0x800a6884; -WmLoopCoordsAroundWorld = 0x800a692c; +AllocChunk = 0x800a67a8; +func_800A6884 = 0x800a6884; +func_800A692C = 0x800a692c; func_800A6994 = 0x800a6994; func_800A6B8C = 0x800a6b8c; func_800A6BCC = 0x800a6bcc; @@ -1971,12 +1971,12 @@ func_800A6C00 = 0x800a6c00; func_800A6C3C = 0x800a6c3c; func_800A6FC0 = 0x800a6fc0; func_800A71E8 = 0x800a71e8; -func_800A7EA4 = 0x800a7ea4; -WmAbortMapLoadingWrapper = 0x800a7f18; -WmAbortMapLoading = 0x800a7f38; +InitWorldState = 0x800a7ea4; +func_800A7F18 = 0x800a7f18; +AbortRegionLoad = 0x800a7f38; func_800A806C = 0x800a806c; func_800A82F0 = 0x800a82f0; -func_800A8300 = 0x800a8300; +IsChunkLoaded = 0x800a8300; func_800A835C = 0x800a835c; func_800A86C4 = 0x800a86c4; func_800A886C = 0x800a886c; @@ -2019,7 +2019,7 @@ func_800A94F4 = 0x800a94f4; func_800A9520 = 0x800a9520; func_800A9678 = 0x800a9678; func_800A96A4 = 0x800a96a4; -func_800A96D0 = 0x800a96d0; +BlendActorFacing = 0x800a96d0; func_800A97A8 = 0x800a97a8; WmGetPcEntityTotalRot = 0x800a97e4; func_800A9820 = 0x800a9820; @@ -2051,7 +2051,7 @@ func_800AA1B8 = 0x800aa1b8; func_800AA238 = 0x800aa238; func_800AA2B8 = 0x800aa2b8; func_800AA304 = 0x800aa304; -func_800AA580 = 0x800aa580; +FindCollidingActor = 0x800aa580; func_800AA640 = 0x800aa640; func_800AA684 = 0x800aa684; func_800AA6A4 = 0x800aa6a4; @@ -2082,10 +2082,10 @@ WmScriptOpcode300Handle = 0x800ac700; WmScriptRunOne = 0x800ad63c; WmScriptRunAll = 0x800ad788; func_800AD804 = 0x800ad804; -WmScriptIsAnyScriptRuns = 0x800ad928; -func_800AD970 = 0x800ad970; +IsAnyScriptRunning = 0x800ad928; +SaveActorState = 0x800ad970; func_800ADA08 = 0x800ada08; -WmRestoreEntityPosAndDirFromSavemap = 0x800ada64; +RestoreActorState = 0x800ada64; func_800ADB30 = 0x800adb30; func_800ADC3C = 0x800adc3c; func_800ADC70 = 0x800adc70; @@ -2136,14 +2136,14 @@ func_800B0BF4 = 0x800b0bf4; func_800B0D98 = 0x800b0d98; func_800B0E84 = 0x800b0e84; func_800B104C = 0x800b104c; -func_800B10AC = 0x800b10ac; +RegisterChunk = 0x800b10ac; func_800B11C4 = 0x800b11c4; func_800B1650 = 0x800b1650; func_800B190C = 0x800b190c; func_800B1C80 = 0x800b1c80; -func_800B21E4 = 0x800b21e4; +SetCurrentTriangle = 0x800b21e4; func_800B2304 = 0x800b2304; -func_800B2638 = 0x800b2638; +GetTriangleCenter = 0x800b2638; func_800B271C = 0x800b271c; func_800B28CC = 0x800b28cc; func_800B29CC = 0x800b29cc; @@ -2214,7 +2214,7 @@ func_800B786C = 0x800b786c; func_800B787C = 0x800b787c; WmGetPcCharModelIdFromParty = 0x800b79b8; func_800B7A40 = 0x800b7a40; -func_800B7AC0 = 0x800b7ac0; +CopyAreaName = 0x800b7ac0; func_800B7B1C = 0x800b7b1c; func_800B7B3C = 0x800b7b3c; func_800B7B54 = 0x800b7b54; diff --git a/config/symbols.world.txt b/config/symbols.world.txt index 3808386d..7bf2cd0e 100644 --- a/config/symbols.world.txt +++ b/config/symbols.world.txt @@ -1,163 +1,25 @@ -WmSetRenderBuffers = 0x800A0B48; -WmGetCurrRenderBufferId = 0x800A0BD4; -WmLoadTxzFile = 0x800A0C54; -WmLoadTxzDataAndInit = 0x800A0D2C; -WmPrepareForRender = 0x800A1370; -WmRenderAll = 0x800A141C; -WmSetShaking = 0x800A16D0; -WmIsTerrainPassableByModel = 0x800A1710; -WmGetRealCamRot = 0x800A1D14; -WmSetDesiredCamRot = 0x800A1D24; -WmSetCamRot = 0x800A1D38; -WmGetWmId = 0x800A1DE0; -WmSetTranslationVectorInScreenSpace = 0x800A1FAC; -WmSetCamView = 0x800A2088; -WmHandleButtons = 0x800A21B4; -WmSubmarineFloatToPlanet = 0x800A3DFC; -WmSubmarineSubmergeUnderwater = 0x800A3E4C; -WmResetGame = 0x800A4008; -WmMain = 0x800A460C; -WmInitLoadMapFileStruct = 0x800A4DDC; -WmGetBlockIdByXZForPlanet = 0x800A4F08; -WmLoadClosestMapFileBlock = 0x800A53A8; -WmStartLoadingMapFileBlock = 0x800A54F0; -WmMapLoadFinishedCallback = 0x800A5924; -WmGetNumberOfMapToLoad = 0x800A5970; -WmGetElementWithBlockIdAndSetItFirst = 0x800A5A20; -WmExtractLoopCoordsTopBottomParts = 0x800A6884; -WmLoopCoordsAroundWorld = 0x800A692C; -WmAbortMapLoadingWrapper = 0x800A7F18; -WmAbortMapLoading = 0x800A7F38; -WmSetWorldProgress = 0x800A8888; -WmInitAllEntityStructs = 0x800A891C; -WmInsertInEntityStructList = 0x800A8A1C; -WmCleanEntityStruct = 0x800A8ABC; -WmUnlinkEntityAndInsertAsNew = 0x800A8AF4; -WmUnlinkEntityFromAll = 0x800A8B30; -WmInsertStructInEntityStructList = 0x800A8C70; -WmLinkPcToActiveEntity = 0x800A8CE4; -WmUnlinkPcEntityFromAll = 0x800A8F74; -WmUnlinkActiveEntityFromAll = 0x800A8FA0; -WmUnlinkPcLinkedEntityFromAll = 0x800A8FCC; -WmSetPcEntityAsActiveEntity = 0x800A90EC; -WmSetActiveEntityAsPcEntity = 0x800A9110; -WmGetModelIdFromActiveEntity = 0x800A9154; -WmGetModelIdFromPcEntity = 0x800A9174; -WmIsPcEntityModelInMask = 0x800A91A4; -WmInitActiveEntityStruct = 0x800A9334; -WmSetActiveEntityDirectionAndRot = 0x800A9480; -WmGetPcEntityTotalRot = 0x800A97E4; -WmIsPcEntityPosNeedRecalculation = 0x800A98E4; -WmGetPcEntityOriginalY = 0x800A9910; -WmSetActiveEntityWithModelId = 0x800A993C; -WmSetPcEntityTerrainData = 0x800A9A24; -WmGetPcEntityTerrainId = 0x800A9A44; -WmGetPosFromActiveEntity = 0x800AA098; -WmGetPosFromPcEntity = 0x800AA0E0; -WmGetPos2FromActiveEntity = 0x800AA128; -WmGetPos2FromPcEntity = 0x800AA170; -WmMoveActiveEntity = 0x800AA7DC; -WmGetBuggyMoveAnimationId = 0x800AAA00; -WmPrepareEntities = 0x800AB4F4; -WmScriptInitVariables = 0x800AB5E4; -WmScriptRunFunction = 0x800AB6E4; -WmScriptDisableForPcEntity = 0x800AB8EC; -WmScriptPopStack = 0x800ABB24; -WmScriptWriteBank = 0x800ABE58; -WmScriptOpcode000Handle = 0x800ABFC0; -WmScriptOpcode100Handle = 0x800AC3C0; -WmScriptOpcode200Handle = 0x800AC484; -WmScriptOpcode300Handle = 0x800AC700; -WmScriptRunOne = 0x800AD63C; -WmScriptRunAll = 0x800AD788; -WmScriptIsAnyScriptRuns = 0x800AD928; -WmRestoreEntityPosAndDirFromSavemap = 0x800ADA64; -WmAddMutexPriority = 0x800ADC80; -WmRemoveMutexPriority = 0x800ADD4C; -WmRandomTwiddle = 0x800ADE30; -WmRandomInit = 0x800ADEA8; -WmGetDistanceBetweenPoints = 0x800AE024; -WmRotateVectorByYAngle = 0x800AE0BC; -WmGetRotFromVector = 0x800AE180; -WmGetRotFromEntityToEntity = 0x800AE47C; -WmCreateSkyboxOverlayRenderBuffers = 0x800AE4B8; -WmGetSkyboxOverlayCurrRenderBuffer = 0x800AE5B8; -WmGetSkyboxOverlayCurrTextureSettingBuffer = 0x800AE5F0; -WmUpdateSkyboxOverlayVertexes = 0x800AE638; -WmSetGteColourSettings = 0x800AF110; -WmSetActivePointMeshCoords = 0x800AF1E8; -WmSetActivePointCoordsInMesh = 0x800AF24C; -WmSetActivePointColour = 0x800AF2A4; -WmSetActivePointSkyColour = 0x800AF324; -WmUpdateLightingFromPoints = 0x800AF3A4; -WmGetDistanceToActivePoint = 0x800AF96C; -WmFadeInit = 0x800AF9DC; -WmFadeRender = 0x800AFCC8; -WmSetFadeIn = 0x800AFFBC; -WmSetFadeOut = 0x800B0098; -WmFadeInSnow = 0x800B017C; -WmFadeOutSnow = 0x800B01C4; -WmFadeStartSnow = 0x800B0200; -WmFadeIsStopped = 0x800B0240; -WmSnowReset = 0x800B3044; -WmSnowUpdate = 0x800B307C; -WmCreateShadowPacket = 0x800B58F8; -WmSetCalculateAllPartsLighting = 0x800B5DD8; -WmUpdateModelByAnimationFrame = 0x800B5E28; -WmSetMusicVolume = 0x800B6570; -WmInitModelVariablesAndArray = 0x800B667C; -WmCalculateBonesAndLighting = 0x800B6724; -WmLoadPcCharModelFile = 0x800B69A4; -WmLoadPcCharModelIntoMemory = 0x800B6A4C; -WmPcCharModelLoadFileCallback = 0x800B6AEC; -WmPackModelLoadFileCallback = 0x800B6DCC; -WmGetModelDataByModelId = 0x800B6EFC; -WmAbortModelLoading = 0x800B7134; -WmSetFieldToLoad = 0x800B7714; -WmGetPcCharModelIdFromParty = 0x800B79B8; -WmDialogsInit = 0x800B8488; -WmDialogSetMessageToShowForId0 = 0x800B84D8; -WmDialogSetAskToShowForId0 = 0x800B851C; -WmDialogIsWindowWithId0Showing = 0x800B857C; -WmDialogSetWindowWithId0ToClose = 0x800B858C; -WmDialogUpdate = 0x800B85D4; -WmDialogGetAskResult = 0x800B86C4; -WmDialogSetPosAndSizeForId0 = 0x800B86E8; -WmDialogSetModeAndPermanencyForId0 = 0x800B8720; -WmDialogPrintParam = 0x800B8750; -WmDialogPrintNoParam = 0x800B8758; -WmDialog0ResetAndPointerInit = 0x800B8760; -WmDialogReset = 0x800B87D8; -WmDialogSetWindowToCloseIfPossible = 0x800B89C4; -WmDialogSetModeAndPermanency = 0x800B8A5C; -WmDialogsReset = 0x800B8A98; -WmDialogSetPosAndSize = 0x800B8B00; -WmDialogAddPos = 0x800B8CBC; -WmDialogSetHeight = 0x800B8D20; -WmDialogSetMessageToShow = 0x800B8D4C; -WmDialogSetAskToShow = 0x800B90C0; -WmDialogPlaySound = 0x800B95E8; -WmDialogInitWindow = 0x800B962C; -WmDialogInscreaseWindow = 0x800B98F0; -WmDialogStringOutput = 0x800B9B2C; -WmDialogTextScrollByRow = 0x800BA938; -WmDialogTextScrollDuringOk = 0x800BAA00; -WmDialogStartText = 0x800BAB60; -WmDialogDiscreaseWindow = 0x800BAC70; -WmDialogAddDigitWithoutLeadingSpace = 0x800BB350; -WmDialogAddDigitWithLeadingSpace = 0x800BB450; -WmDialogAddHexDigitWithoutLeadingSpace = 0x800BB568; -WmDialogCopyStringIntoCharName = 0x800BB7DC; -WmMovePcEntityByDistance = 0x800BB8E8; -WmScriptPushToStoreStack = 0x800BB9A0; -WmScriptPopFromStoreStack = 0x800BB9D0; -WmScriptGetTopFromStoreStack = 0x800BBA0C; -WmScriptSetFirstToStoreStack = 0x800BBA34; -WmScriptIsDataInStoreStack = 0x800BBA44; -WmUiMapCreate = 0x800BC1CC; -WmUiMapUpdate = 0x800BC420; -WmSetCamMode = 0x800BC9E8; -WmGetCamMode = 0x800BCA38; +AllocPrims = 0x800A0BE4; +AllocRegionNode = 0x800A52A4; +StartNearestRegionLoad = 0x800A53A8; +UpdateRegionLoad = 0x800A57C8; +InitChunkNodePool = 0x800A59A0; +FindResidentRegion = 0x800A5A20; +IsRegionLoading = 0x800A5A94; +ExpireChunks = 0x800A5FB4; +InitChunkPool = 0x800A60D8; +AllocChunk = 0x800A67A8; +InitWorldState = 0x800A7EA4; +AbortRegionLoad = 0x800A7F38; +IsChunkLoaded = 0x800A8300; +BlendActorFacing = 0x800A96D0; +FindCollidingActor = 0x800AA580; +IsAnyScriptRunning = 0x800AD928; +SaveActorState = 0x800AD970; +RestoreActorState = 0x800ADA64; +RegisterChunk = 0x800B10AC; +SetCurrentTriangle = 0x800B21E4; +GetTriangleCenter = 0x800B2638; +CopyAreaName = 0x800B7AC0; func_800BD124 = 0x800BD124; WmLoadModelPacketAndScale = 0x800BFBF0; WmCreatePacketForModelPart = 0x800BFCAC; diff --git a/src/world/world.c b/src/world/world.c index 84f5b1c9..dd9f8b57 100644 --- a/src/world/world.c +++ b/src/world/world.c @@ -2,9 +2,9 @@ #include "world.h" #include -void WmSetActiveEntityDirectionAndRot(s16 arg0); -void WmGetPosFromPcEntity(VECTOR* arg0); -void WmRestoreEntityPosAndDirFromSavemap(WorldActor*); +void func_800A9480(s16 arg0); +void func_800AA0E0(VECTOR* arg0); +void RestoreActorState(WorldActor*); s32 func_800ADFC0(void); static s32 func_800B0800(void); void WmCreateShadowPacket(u8*, RECT*); @@ -54,7 +54,7 @@ void WmSetRenderBuffers(void) { static s32 WmGetCurrRenderBufferId(void) { return D_800D05E8; } -u32* func_800A0BE4(s32 arg0) { +u32* AllocPrims(s32 arg0) { u32* cur; u32* next; u32* ret; @@ -452,7 +452,7 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A4F78); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A5208); -WorldListNode* func_800A52A4(void) { +WorldListNode* AllocRegionNode(void) { WorldListNode* node; WorldListNode* prev; WorldListNode* head; @@ -500,7 +500,7 @@ void func_800A5348(WorldListNode* arg0, WorldListNode* arg1) { arg0->next = tmp; } -void func_800A53A8(s16 arg0, s16 arg1) { +void StartNearestRegionLoad(s16 arg0, s16 arg1) { WorldListNode* node; WorldListNode* prev; WorldListNode* best; @@ -559,7 +559,7 @@ void func_800A53A8(s16 arg0, s16 arg1) { INCLUDE_ASM("asm/us/world/nonmatchings/world", WmStartLoadingMapFileBlock); -void func_800A57C8(void) { +void UpdateRegionLoad(void) { WorldListNode* node; WorldListNode* prev; WorldListNode* head; @@ -624,7 +624,7 @@ s16 WmGetNumberOfMapToLoad(void) { return count; } -void func_800A59A0(void) { +void InitChunkNodePool(void) { s16 i; for (i = 0; i < 0x3F; i++) { @@ -636,7 +636,7 @@ void func_800A59A0(void) { D_800E5A34 = 0; } -WorldListNode* func_800A5A20(s16 arg0) { +WorldListNode* FindResidentRegion(s16 arg0) { WorldListNode* node; WorldListNode* prev; WorldListNode* head; @@ -663,7 +663,7 @@ WorldListNode* func_800A5A20(s16 arg0) { return node; } -s32 func_800A5A94(s16 arg0) { +s32 IsRegionLoading(s16 arg0) { WorldListNode* node; node = D_800E5768; @@ -700,7 +700,7 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A5D00); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A5E28); -s32 func_800A5FB4(void) { +s32 ExpireChunks(void) { WorldChunkHeader* chunk; WorldChunkHeader* prev; WorldChunkNode* node; @@ -762,7 +762,7 @@ s32 func_800A5FB4(void) { return live; } -void func_800A60D8(void) { +void InitChunkPool(void) { s16 i; for (i = 0; i < 0x1F; i++) { @@ -780,7 +780,7 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A63FC); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A64AC); -WorldChunkHeader* func_800A67A8(void) { +WorldChunkHeader* AllocChunk(void) { WorldChunkHeader* chunk; WorldChunkHeader* prev; WorldChunkHeader* head; @@ -911,10 +911,10 @@ static void func_800A7E8C(s32 arg0) { D_80109D6C = arg0; } static void func_800A7E9C(void) {} -void func_800A7EA4(void) { +void InitWorldState(void) { func_800A4DDC(); - func_800A59A0(); - func_800A60D8(); + InitChunkNodePool(); + InitChunkPool(); D_80109D54 = 0; D_80109D58 = 0; D_80109D5C = NULL; @@ -925,9 +925,9 @@ void func_800A7EA4(void) { D_80109D6C = 0; } -void WmAbortMapLoadingWrapper(void) { WmAbortMapLoading(); } +void func_800A7F18(void) { AbortRegionLoad(); } -void func_800A7F38(void) { +void AbortRegionLoad(void) { WorldListNode* node; WorldListNode* prev; WorldListNode* head; @@ -974,7 +974,7 @@ static void func_800A82DC(void) { D_80109D54 = 1; } s32 func_800A82F0(void) { return D_80109D58; } -s32 func_800A8300(s16 arg0, s16 arg1) { +s32 IsChunkLoaded(s16 arg0, s16 arg1) { WorldChunkHeader* chunk; chunk = D_80109D3C; @@ -1297,8 +1297,8 @@ void WmInitActiveEntityStruct(s32 arg0) { rect.h = 0xF; D_8010AD3C->unk58 = 0x20; } - WmCreateShadowPacket(D_8010AD3C->unk90, &rect); - WmRestoreEntityPosAndDirFromSavemap(D_8010AD3C); + func_800B58F8(D_8010AD3C->unk90, &rect); + RestoreActorState(D_8010AD3C); } } @@ -1340,7 +1340,7 @@ void func_800A9678(s16 arg0) { func_800A9520(D_8010AD3C, arg0); } void func_800A96A4(s16 arg0) { func_800A9520(D_8010AD40, arg0); } -void func_800A96D0(s16 arg0) { +void BlendActorFacing(s16 arg0) { WorldActor* actor; u32 blend; @@ -1541,7 +1541,7 @@ static void func_800AA2E4(s8 arg0) { INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA304); -WorldActor* func_800AA580(WorldActor* arg0) { +WorldActor* FindCollidingActor(WorldActor* arg0) { WorldActor* hit; s32 rc; @@ -1570,7 +1570,7 @@ WorldActor* func_800AA580(WorldActor* arg0) { s32 func_800AA640(void) { WorldActor* temp_v0; - temp_v0 = func_800AA580(D_8010AD3C); + temp_v0 = FindCollidingActor(D_8010AD3C); if (temp_v0 != NULL) func_800AA1B8(); return (s32)temp_v0; @@ -2242,7 +2242,7 @@ void func_800AD804(void) { } } -s32 func_800AD928(void) { +s32 IsAnyScriptRunning(void) { WorldActor* a; s32 flag; @@ -2257,7 +2257,7 @@ s32 func_800AD928(void) { return flag; } -void func_800AD970(WorldActor* actor) { +void SaveActorState(WorldActor* actor) { u8 type; u8 slot; s32* out; @@ -2277,10 +2277,10 @@ void func_800ADA08(void) { for (var_s0 = D_8010AD38; var_s0 != NULL; var_s0 = var_s0->next) if (!(var_s0->flags1 & 8)) - func_800AD970(var_s0); + SaveActorState(var_s0); } -void func_800ADA64(WorldActor* arg0) { +void RestoreActorState(WorldActor* arg0) { s32* p; s32* end; s32 t; @@ -2330,7 +2330,7 @@ s32 func_800ADC80(s16 arg0) { } if (D_8010AE54 < (1 << arg0)) { if (D_8010AE54 == 1) { - func_800A7F38(); + AbortRegionLoad(); } else if (D_8010AE54 & 4) { func_800B7134(); } @@ -2737,7 +2737,7 @@ void func_800B104C(void) { D_8010CAF4 = 0; } -void func_800B10AC(WorldChunkHeader* arg0) { +void RegisterChunk(WorldChunkHeader* arg0) { WorldChunkHeader** slot; WorldTriangle* t; u8* p; @@ -2782,7 +2782,7 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B190C); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B1C80); -void func_800B21E4(WorldChunkHeader* arg0, WorldTriangle* arg1) { +void SetCurrentTriangle(WorldChunkHeader* arg0, WorldTriangle* arg1) { VECTOR pos; s32 inside; s32 zoff; @@ -2795,7 +2795,7 @@ void func_800B21E4(WorldChunkHeader* arg0, WorldTriangle* arg1) { D_8010CA20 = 0; D_8010CA78 = 0; D_8010CA74 = D_8010CA24; - func_800B10AC(arg0); + RegisterChunk(arg0); if (arg1 != NULL) { *((u8*)arg1 + 0xB) |= 0x40; } @@ -2815,7 +2815,7 @@ static void func_800B22E4(void) { func_800B190C(); } INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B2304); -void func_800B2638(WorldTriangleRef* arg0, VECTOR* arg1) { +void GetTriangleCenter(WorldTriangleRef* arg0, VECTOR* arg1) { WorldTriangle* tri; WorldChunkHeader* chunk; SVECTOR* verts; @@ -3139,7 +3139,7 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B6B28); void func_800B6C84(void) { if (D_80115A60 == 0) { - func_800A7F38(); + AbortRegionLoad(); D_80115A40 = (u_long*)func_800A86C4(2); if (func_800ADC80(2) != 0) { D_80115A60 = 1; @@ -3339,7 +3339,7 @@ s32 WmGetPcCharModelIdFromParty(void) { INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B7A40); -void func_800B7AC0(s16 arg0) { +void CopyAreaName(s16 arg0) { u8* src; u8* base; u8* dst; diff --git a/src/world/world.h b/src/world/world.h index f5b8c983..4b1a29d4 100644 --- a/src/world/world.h +++ b/src/world/world.h @@ -164,7 +164,7 @@ s32 WmGetPcEntityTerrainId(void); s32 func_800A9B04(s16, u8); void func_800A9C64(WorldActor*, VECTOR*); s32 func_800AA304(WorldActor*, WorldActor*); -WorldActor* func_800AA580(WorldActor*); +WorldActor* FindCollidingActor(WorldActor*); void func_800AAB18(WorldActor*); void func_800AB398(WorldActor*); void func_800AB48C(WorldActor*); @@ -178,6 +178,12 @@ void WmScriptRunOne(WorldActor*); void func_800AD970(WorldActor*); void WmRemoveMutexPriority(s16); s16 WmGetRotFromVector(s32, s32, s32); +void func_800ABFC0(u16); +void func_800AC3C0(u16); +s32 func_800AC484(u16); +s32 func_800AC700(u16); +void func_800AD63C(WorldActor*); +void SaveActorState(WorldActor*); void func_800ADD4C(s16); s16 func_800AE180(s32, s32, s32); s32 func_800B0240(void); From 6f9f4f046124b3f5a20d2477417c8b7492c10bfa Mon Sep 17 00:00:00 2001 From: _checkra1n <97061690+devcheckra1n@users.noreply.github.com> Date: Tue, 1 Sep 2026 06:35:07 -0400 Subject: [PATCH 07/14] world: name the remaining 21 functions No func_ADDR left in the file's decompiled half. Most are clear from the code -- the fog ranges, the two bounded layer scrolls, the AKAO track and ambient calls, the stream state and its read. UpdateWorldMode, ResetEffectState and GetSavedParams describe what the code does rather than claim a purpose I could not pin down. --- config/sym_ovl_export.us.txt | 134 +++++++++++++++++------------------ config/symbols.world.txt | 21 ++++++ src/world/world.c | 90 +++++++++++------------ src/world/world.h | 8 +-- 4 files changed, 137 insertions(+), 116 deletions(-) diff --git a/config/sym_ovl_export.us.txt b/config/sym_ovl_export.us.txt index 15d13f10..a51434e9 100644 --- a/config/sym_ovl_export.us.txt +++ b/config/sym_ovl_export.us.txt @@ -1899,7 +1899,7 @@ WmGetRealCamRot = 0x800a1d14; WmSetCamRot = 0x800a1d38; func_800A1D54 = 0x800a1d54; func_800A1DF0 = 0x800a1df0; -WmSetTranslationVectorInScreenSpace = 0x800a1fac; +SetPointTransform = 0x800a1fac; func_800A2040 = 0x800a2040; WmSetCamView = 0x800a2088; func_800A2108 = 0x800a2108; @@ -1907,7 +1907,7 @@ func_800A21A4 = 0x800a21a4; WmHandleButtons = 0x800a21b4; func_800A31C0 = 0x800a31c0; func_800A31E8 = 0x800a31e8; -func_800A31F8 = 0x800a31f8; +UpdateFogRanges = 0x800a31f8; func_800A32F4 = 0x800a32f4; func_800A3304 = 0x800a3304; func_800A368C = 0x800a368c; @@ -1927,7 +1927,7 @@ func_800A40B8 = 0x800a40b8; func_800A40F0 = 0x800a40f0; func_800A4138 = 0x800a4138; func_800A41E8 = 0x800a41e8; -func_800A4268 = 0x800a4268; +UpdateFadeOverlay = 0x800a4268; func_800A4494 = 0x800a4494; func_800A44A4 = 0x800a44a4; func_800A44B4 = 0x800a44b4; @@ -1942,7 +1942,7 @@ WmGetBlockIdByXZForPlanet = 0x800a4f08; func_800A4F78 = 0x800a4f78; func_800A5208 = 0x800a5208; AllocRegionNode = 0x800a52a4; -func_800A5348 = 0x800a5348; +FreeListNode = 0x800a5348; StartNearestRegionLoad = 0x800a53a8; func_800A54F0 = 0x800a54f0; UpdateRegionLoad = 0x800a57c8; @@ -1952,7 +1952,7 @@ InitChunkNodePool = 0x800a59a0; FindResidentRegion = 0x800a5a20; IsRegionLoading = 0x800a5a94; func_800A5AD8 = 0x800a5ad8; -func_800A5B88 = 0x800a5b88; +RegisterChunksForNode = 0x800a5b88; func_800A5C08 = 0x800a5c08; func_800A5D00 = 0x800a5d00; func_800A5E28 = 0x800a5e28; @@ -2059,7 +2059,7 @@ func_800AA6D0 = 0x800aa6d0; WmMoveActiveEntity = 0x800aa7dc; func_800AA8D8 = 0x800aa8d8; func_800AA8F8 = 0x800aa8f8; -WmGetBuggyMoveAnimationId = 0x800aaa00; +UpdateEventState = 0x800aaa00; func_800AAB18 = 0x800aab18; func_800AB36C = 0x800ab36c; func_800AB398 = 0x800ab398; @@ -2073,15 +2073,15 @@ func_800AB92C = 0x800ab92c; func_800AB988 = 0x800ab988; func_800ABA18 = 0x800aba18; func_800ABA78 = 0x800aba78; -WmScriptPopStack = 0x800abb24; -WmScriptWriteBank = 0x800abe58; -WmScriptOpcode000Handle = 0x800abfc0; -WmScriptOpcode100Handle = 0x800ac3c0; -WmScriptOpcode200Handle = 0x800ac484; -WmScriptOpcode300Handle = 0x800ac700; -WmScriptRunOne = 0x800ad63c; -WmScriptRunAll = 0x800ad788; -func_800AD804 = 0x800ad804; +func_800ABB24 = 0x800abb24; +func_800ABE58 = 0x800abe58; +func_800ABFC0 = 0x800abfc0; +func_800AC3C0 = 0x800ac3c0; +func_800AC484 = 0x800ac484; +func_800AC700 = 0x800ac700; +func_800AD63C = 0x800ad63c; +func_800AD788 = 0x800ad788; +UpdateSurfaceEffect = 0x800ad804; IsAnyScriptRunning = 0x800ad928; SaveActorState = 0x800ad970; func_800ADA08 = 0x800ada08; @@ -2089,10 +2089,10 @@ RestoreActorState = 0x800ada64; func_800ADB30 = 0x800adb30; func_800ADC3C = 0x800adc3c; func_800ADC70 = 0x800adc70; -WmAddMutexPriority = 0x800adc80; -WmRemoveMutexPriority = 0x800add4c; -WmRandomTwiddle = 0x800ade30; -WmRandomInit = 0x800adea8; +TryAcquireLoadSlot = 0x800adc80; +func_800ADD4C = 0x800add4c; +func_800ADE30 = 0x800ade30; +func_800ADEA8 = 0x800adea8; func_800ADFC0 = 0x800adfc0; WmGetDistanceBetweenPoints = 0x800ae024; WmRotateVectorByYAngle = 0x800ae0bc; @@ -2107,7 +2107,7 @@ func_800AE8AC = 0x800ae8ac; func_800AEA48 = 0x800aea48; func_800AF0A0 = 0x800af0a0; func_800AF0B0 = 0x800af0b0; -WmSetGteColourSettings = 0x800af110; +SetupLighting = 0x800af110; func_800AF1A8 = 0x800af1a8; WmSetActivePointMeshCoords = 0x800af1e8; WmSetActivePointCoordsInMesh = 0x800af24c; @@ -2117,14 +2117,14 @@ func_800AF364 = 0x800af364; WmUpdateLightingFromPoints = 0x800af3a4; WmGetDistanceToActivePoint = 0x800af96c; func_800AF9A0 = 0x800af9a0; -WmFadeInit = 0x800af9dc; -WmFadeRender = 0x800afcc8; -WmSetFadeIn = 0x800affbc; -WmSetFadeOut = 0x800b0098; -WmFadeInSnow = 0x800b017c; -WmFadeOutSnow = 0x800b01c4; -WmFadeStartSnow = 0x800b0200; -WmFadeIsStopped = 0x800b0240; +func_800AF9DC = 0x800af9dc; +func_800AFCC8 = 0x800afcc8; +ScrollLayerBack = 0x800affbc; +ScrollLayerForward = 0x800b0098; +func_800B017C = 0x800b017c; +func_800B01C4 = 0x800b01c4; +func_800B0200 = 0x800b0200; +func_800B0240 = 0x800b0240; func_800B0250 = 0x800b0250; func_800B0334 = 0x800b0334; func_800B04AC = 0x800b04ac; @@ -2133,7 +2133,7 @@ func_800B075C = 0x800b075c; func_800B0794 = 0x800b0794; func_800B0810 = 0x800b0810; func_800B0BF4 = 0x800b0bf4; -func_800B0D98 = 0x800b0d98; +UpdateZolomGroundHeight = 0x800b0d98; func_800B0E84 = 0x800b0e84; func_800B104C = 0x800b104c; RegisterChunk = 0x800b10ac; @@ -2147,7 +2147,7 @@ GetTriangleCenter = 0x800b2638; func_800B271C = 0x800b271c; func_800B28CC = 0x800b28cc; func_800B29CC = 0x800b29cc; -func_800B2E90 = 0x800b2e90; +UpdateWorldMode = 0x800b2e90; func_800B2FA4 = 0x800b2fa4; func_800B2FD0 = 0x800b2fd0; func_800B3018 = 0x800b3018; @@ -2159,13 +2159,13 @@ func_800B338C = 0x800b338c; func_800B3418 = 0x800b3418; func_800B37E0 = 0x800b37e0; func_800B3828 = 0x800b3828; -func_800B392C = 0x800b392c; +InitEffectPool = 0x800b392c; func_800B39B4 = 0x800b39b4; func_800B3C40 = 0x800b3c40; func_800B40B4 = 0x800b40b4; func_800B4244 = 0x800b4244; func_800B45DC = 0x800b45dc; -func_800B5274 = 0x800b5274; +ResetEffectState = 0x800b5274; func_800B5314 = 0x800b5314; func_800B579C = 0x800b579c; func_800B57C0 = 0x800b57c0; @@ -2177,20 +2177,20 @@ WmSetCalculateAllPartsLighting = 0x800b5dd8; WmUpdateModelByAnimationFrame = 0x800b5e28; func_800B624C = 0x800b624c; func_800B6348 = 0x800b6348; -func_800B63F0 = 0x800b63f0; +PlayMusicTrack = 0x800b63f0; func_800B64A0 = 0x800b64a0; func_800B64D8 = 0x800b64d8; func_800B650C = 0x800b650c; WmSetMusicVolume = 0x800b6570; func_800B65A4 = 0x800b65a4; -func_800B65E0 = 0x800b65e0; -WmInitModelVariablesAndArray = 0x800b667c; -WmCalculateBonesAndLighting = 0x800b6724; -WmLoadPcCharModelFile = 0x800b69a4; -WmLoadPcCharModelIntoMemory = 0x800b6a4c; -WmPcCharModelLoadFileCallback = 0x800b6aec; +ToggleAmbientSound = 0x800b65e0; +InitStreamState = 0x800b667c; +func_800B6724 = 0x800b6724; +func_800B69A4 = 0x800b69a4; +func_800B6A4C = 0x800b6a4c; +func_800B6AEC = 0x800b6aec; func_800B6B28 = 0x800b6b28; -func_800B6C84 = 0x800b6c84; +StartStreamRead = 0x800b6c84; func_800B6D10 = 0x800b6d10; WmPackModelLoadFileCallback = 0x800b6dcc; func_800B6E08 = 0x800b6e08; @@ -2202,7 +2202,7 @@ func_800B717C = 0x800b717c; func_800B7200 = 0x800b7200; func_800B7228 = 0x800b7228; func_800B7480 = 0x800b7480; -func_800B7620 = 0x800b7620; +GetSavedParams = 0x800b7620; func_800B76A8 = 0x800b76a8; WmSetFieldToLoad = 0x800b7714; func_800B77A8 = 0x800b77a8; @@ -2225,32 +2225,32 @@ func_800B7BD8 = 0x800b7bd8; func_800B7C1C = 0x800b7c1c; func_800B7C7C = 0x800b7c7c; func_800B832C = 0x800b832c; -WmDialogsInit = 0x800b8488; -WmDialogSetMessageToShowForId0 = 0x800b84d8; -WmDialogSetAskToShowForId0 = 0x800b851c; -WmDialogSetWindowWithId0ToClose = 0x800b858c; -WmDialogUpdate = 0x800b85d4; -WmDialogGetAskResult = 0x800b86c4; -WmDialogSetPosAndSizeForId0 = 0x800b86e8; -WmDialogSetModeAndPermanencyForId0 = 0x800b8720; -WmDialog0ResetAndPointerInit = 0x800b8760; -WmDialogReset = 0x800b87d8; -WmDialogSetWindowToCloseIfPossible = 0x800b89c4; -WmDialogSetModeAndPermanency = 0x800b8a5c; -WmDialogsReset = 0x800b8a98; -WmDialogSetPosAndSize = 0x800b8b00; -WmDialogAddPos = 0x800b8cbc; -WmDialogSetHeight = 0x800b8d20; -WmDialogSetMessageToShow = 0x800b8d4c; -WmDialogSetAskToShow = 0x800b90c0; -WmDialogPlaySound = 0x800b95e8; -WmDialogInitWindow = 0x800b962c; -WmDialogInscreaseWindow = 0x800b98f0; -WmDialogStringOutput = 0x800b9b2c; -WmDialogTextScrollByRow = 0x800ba938; -WmDialogTextScrollDuringOk = 0x800baa00; -WmDialogStartText = 0x800bab60; -WmDialogDiscreaseWindow = 0x800bac70; +func_800B8488 = 0x800b8488; +func_800B84D8 = 0x800b84d8; +OpenWorldWindow = 0x800b851c; +func_800B858C = 0x800b858c; +func_800B85D4 = 0x800b85d4; +func_800B86C4 = 0x800b86c4; +func_800B86E8 = 0x800b86e8; +func_800B8720 = 0x800b8720; +func_800B8760 = 0x800b8760; +func_800B87D8 = 0x800b87d8; +func_800B89C4 = 0x800b89c4; +func_800B8A5C = 0x800b8a5c; +func_800B8A98 = 0x800b8a98; +func_800B8B00 = 0x800b8b00; +func_800B8CBC = 0x800b8cbc; +func_800B8D20 = 0x800b8d20; +func_800B8D4C = 0x800b8d4c; +func_800B90C0 = 0x800b90c0; +func_800B95E8 = 0x800b95e8; +func_800B962C = 0x800b962c; +func_800B98F0 = 0x800b98f0; +func_800B9B2C = 0x800b9b2c; +func_800BA938 = 0x800ba938; +func_800BAA00 = 0x800baa00; +func_800BAB60 = 0x800bab60; +func_800BAC70 = 0x800bac70; func_800BAE60 = 0x800bae60; WmDialogAddDigitWithoutLeadingSpace = 0x800bb350; WmDialogAddDigitWithLeadingSpace = 0x800bb450; diff --git a/config/symbols.world.txt b/config/symbols.world.txt index 7bf2cd0e..37cb56ad 100644 --- a/config/symbols.world.txt +++ b/config/symbols.world.txt @@ -1,10 +1,15 @@ AllocPrims = 0x800A0BE4; +SetPointTransform = 0x800A1FAC; +UpdateFogRanges = 0x800A31F8; +UpdateFadeOverlay = 0x800A4268; AllocRegionNode = 0x800A52A4; +FreeListNode = 0x800A5348; StartNearestRegionLoad = 0x800A53A8; UpdateRegionLoad = 0x800A57C8; InitChunkNodePool = 0x800A59A0; FindResidentRegion = 0x800A5A20; IsRegionLoading = 0x800A5A94; +RegisterChunksForNode = 0x800A5B88; ExpireChunks = 0x800A5FB4; InitChunkPool = 0x800A60D8; AllocChunk = 0x800A67A8; @@ -13,13 +18,29 @@ AbortRegionLoad = 0x800A7F38; IsChunkLoaded = 0x800A8300; BlendActorFacing = 0x800A96D0; FindCollidingActor = 0x800AA580; +UpdateEventState = 0x800AAA00; +UpdateSurfaceEffect = 0x800AD804; IsAnyScriptRunning = 0x800AD928; SaveActorState = 0x800AD970; RestoreActorState = 0x800ADA64; +TryAcquireLoadSlot = 0x800ADC80; +SetupLighting = 0x800AF110; +ScrollLayerBack = 0x800AFFBC; +ScrollLayerForward = 0x800B0098; +UpdateZolomGroundHeight = 0x800B0D98; RegisterChunk = 0x800B10AC; SetCurrentTriangle = 0x800B21E4; GetTriangleCenter = 0x800B2638; +UpdateWorldMode = 0x800B2E90; +InitEffectPool = 0x800B392C; +ResetEffectState = 0x800B5274; +PlayMusicTrack = 0x800B63F0; +ToggleAmbientSound = 0x800B65E0; +InitStreamState = 0x800B667C; +StartStreamRead = 0x800B6C84; +GetSavedParams = 0x800B7620; CopyAreaName = 0x800B7AC0; +OpenWorldWindow = 0x800B851C; func_800BD124 = 0x800BD124; WmLoadModelPacketAndScale = 0x800BFBF0; WmCreatePacketForModelPart = 0x800BFCAC; diff --git a/src/world/world.c b/src/world/world.c index dd9f8b57..c09849c6 100644 --- a/src/world/world.c +++ b/src/world/world.c @@ -139,7 +139,7 @@ static s32 WmGetWmId(void) { return D_800E5634; } INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A1DF0); -void func_800A1FAC(SVECTOR* arg0) { +void SetPointTransform(SVECTOR* arg0) { MATRIX m; SVECTOR v; VECTOR out; @@ -198,7 +198,7 @@ void func_800A31C0(s16 arg0) { D_800E5668 = arg0 - 0x800 + D_800E5608; } s32 func_800A31E8(void) { return !D_800E5628; } -void func_800A31F8(void) { +void UpdateFogRanges(void) { s32 level; if (D_800E5650 == 0) { @@ -254,7 +254,7 @@ void WmSubmarineFloatToPlanet(void) { D_800E5644 = 0x14; WmSetFieldToLoad(0); func_800A2108(0, 0); - WmSetFadeOut(0x10, 1); + ScrollLayerForward(0x10, 1); } void WmSubmarineSubmergeUnderwater(void) { @@ -262,7 +262,7 @@ void WmSubmarineSubmergeUnderwater(void) { D_800E5644 = -0x14; WmSetFieldToLoad(0); func_800A2108(0, 0); - WmSetFadeOut(0x10, 1); + ScrollLayerForward(0x10, 1); } void func_800A3E9C(s32 arg0) { @@ -341,18 +341,18 @@ void func_800A41E8(s32 arg0) { switch (arg0) { case 1: func_800A2108(0, 4); - WmSetFadeOut(4, 1); + ScrollLayerForward(4, 1); break; case 4: func_800A2108(1, 4); - WmSetFadeIn(0x10, 1); + ScrollLayerBack(0x10, 1); arg0 = 0; break; } D_800E56F4 = arg0; } -void func_800A4268(void) { +void UpdateFadeOverlay(void) { s32 slot; s32 vsync; @@ -485,7 +485,7 @@ WorldListNode* AllocRegionNode(void) { return node; } -void func_800A5348(WorldListNode* arg0, WorldListNode* arg1) { +void FreeListNode(WorldListNode* arg0, WorldListNode* arg1) { WorldListNode* tmp; if (arg1 != NULL) { @@ -514,7 +514,7 @@ void StartNearestRegionLoad(s16 arg0, s16 arg1) { s16 idx; if (D_800E5814 == 0 && D_800E5810 != NULL) { - if (func_800ADC80(0) != 0) { + if (TryAcquireLoadSlot(0) != 0) { bestPrev = NULL; best = NULL; bestDist = 0x7FFF; @@ -552,7 +552,7 @@ void StartNearestRegionLoad(s16 arg0, s16 arg1) { if (best == NULL) { func_800A0B40(0x22); } - func_800A5348(best, bestPrev); + FreeListNode(best, bestPrev); } } } @@ -591,7 +591,7 @@ void UpdateRegionLoad(void) { head = D_800E5764; D_800E5764 = node; node->next = head; - func_800A5B88(node); + RegisterChunksForNode(node); D_800E5820 = -1; } tick = 0; @@ -680,7 +680,7 @@ s32 IsRegionLoading(s16 arg0) { INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A5AD8); -void func_800A5B88(WorldListNode* arg0) { +void RegisterChunksForNode(WorldListNode* arg0) { WorldChunkHeader* c; c = D_80109D40; @@ -896,7 +896,7 @@ void func_800A6BCC(SVECTOR* arg0) { void func_800A6C00(s32 arg0) { if (func_800A1DB0() != 2) - WmSetTranslationVectorInScreenSpace(arg0); + SetPointTransform(arg0); } INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A6C3C); @@ -1602,7 +1602,7 @@ void func_800AA6D0(WorldChunkHeader* arg0) { } } - func_800B0D98(arg0); + UpdateZolomGroundHeight(arg0); func_800B1C80(arg0); } @@ -1630,7 +1630,7 @@ void func_800AA8D8(s16 arg0, s16 arg1, s16 arg2) { INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA8F8); -s32 func_800AAA00(u8* arg0) { +s32 UpdateEventState(u8* arg0) { s32 prev; s32 event; @@ -2215,7 +2215,7 @@ void WmScriptRunAll(void) { WmScriptRunOne(D_8010ADE4 = D_8010AD3C = var_s0); } -void func_800AD804(void) { +void UpdateSurfaceEffect(void) { s32 kind; if (D_8010ADEC != 0 || (D_8010AD40->flags1 & 8)) { @@ -2322,7 +2322,7 @@ void func_800ADC3C(VECTOR* arg0) { D_8010AE34 = *arg0; } void func_800ADC70(void) { D_8010AE54 = 0; } -s32 func_800ADC80(s16 arg0) { +s32 TryAcquireLoadSlot(s16 arg0) { if ((D_8010AE54 >> arg0) & 1) { if (!((-1 << (arg0 + 1)) & D_8010AE54)) { return 1; @@ -2463,7 +2463,7 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AEA48); void func_800AF0A0(s32 arg0) { D_8010B174 = arg0; } void func_800AF0B0(void) { - void WmSetGteColourSettings(void); + void SetupLighting(void); s32 i; s32 offset; @@ -2476,10 +2476,10 @@ void func_800AF0B0(void) { } D_8010B3B8 = NULL; - WmSetGteColourSettings(); + SetupLighting(); } -void func_800AF110(void) { +void SetupLighting(void) { MATRIX* m; s32 mode; s32 r; @@ -2583,7 +2583,7 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", WmFadeInit); INCLUDE_ASM("asm/us/world/nonmatchings/world", WmFadeRender); -void func_800AFFBC(s32 arg0, s32 arg1) { +void ScrollLayerBack(s32 arg0, s32 arg1) { s32 i; s32 tpage; @@ -2611,7 +2611,7 @@ void func_800AFFBC(s32 arg0, s32 arg1) { } } -void func_800B0098(s32 arg0, s32 arg1) { +void ScrollLayerForward(s32 arg0, s32 arg1) { s32 i; s32 tpage; @@ -2699,7 +2699,7 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B0810); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B0BF4); -void func_800B0D98(WorldChunkHeader* arg0) { +void UpdateZolomGroundHeight(WorldChunkHeader* arg0) { VECTOR pos; SVECTOR dir; s16 chunkX; @@ -2872,7 +2872,7 @@ void func_800B28CC(s32 arg0) { INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B29CC); -void func_800B2E90(void) { +void UpdateWorldMode(void) { func_800B22E4(); if (D_8010CAF4 != 0) { if (D_8010CA8C == 3) { @@ -2945,7 +2945,7 @@ void func_800B37E0(s32* arg0, s32* arg1) { INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B3828); -void func_800B392C(void) { +void InitEffectPool(void) { s32 off; s32 next; s32 i; @@ -2983,7 +2983,7 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B4244); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B45DC); -void func_800B5274(void) { +void ResetEffectState(void) { u8* p; *(s16*)0x1F800010 = 0; @@ -3031,7 +3031,7 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B6348); static void func_800B63E0(s32 arg0) { D_801159DC = arg0; } -void func_800B63F0(s32 arg0) { +void PlayMusicTrack(s32 arg0) { s16* cmd; s32 prev; @@ -3055,7 +3055,7 @@ void func_800B63F0(s32 arg0) { D_80116510 = prev; } -void func_800B64A0(void) { func_800B63F0(D_801159E0); } +void func_800B64A0(void) { PlayMusicTrack(D_801159E0); } static s32 func_800B64C8(void) { return D_801159E0; } @@ -3080,7 +3080,7 @@ void func_800B65A4(u32 arg0, s32 arg1) { SystemAkaoExecute(); } -void func_800B65E0(s32 arg0) { +void ToggleAmbientSound(s32 arg0) { if (D_8010CB20 < arg0) { D_8009A000[0] = 0x20; D_8010CB20 = arg0; @@ -3098,7 +3098,7 @@ void func_800B65E0(s32 arg0) { SystemAkaoExecute(); } -void func_800B667C(void) { +void InitStreamState(void) { s32 i; i = 0; @@ -3137,11 +3137,11 @@ void WmPcCharModelLoadFileCallback(void) { INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B6B28); -void func_800B6C84(void) { +void StartStreamRead(void) { if (D_80115A60 == 0) { AbortRegionLoad(); D_80115A40 = (u_long*)func_800A86C4(2); - if (func_800ADC80(2) != 0) { + if (TryAcquireLoadSlot(2) != 0) { D_80115A60 = 1; D_80115A50 = 0; DS_read(D_800C74DC, D_800C74E0, D_80115A40, func_800B6DCC); @@ -3233,7 +3233,7 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B7228); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B7480); -void func_800B7620(s32* arg0, s32* arg1, s32* arg2) { +void GetSavedParams(s32* arg0, s32* arg1, s32* arg2) { u16* p; s32 flags; @@ -3469,7 +3469,7 @@ void WmDialogSetMessageToShowForId0(u8 arg0) { } } -void func_800B851C(s32 arg0, s16 arg1, s16 arg2) { +void OpenWorldWindow(s32 arg0, s16 arg1, s16 arg2) { if (g_WindowData[0].state == WSTATE_INIT) { D_80116288 = arg1; D_8011628C = arg2; @@ -4576,8 +4576,8 @@ static void func_800BBA5C(void) { func_800A6994(&sp10, WmGetModelIdFromActiveEntity() == 3 ? -1 : 1); WmScriptPushToStoreStack(WmGetModelIdFromPcEntity()); if (func_800A929C()) { - WmLinkPcToActiveEntity(); - func_800B63F0(2); + func_800A8CE4(); + PlayMusicTrack(2); return; } WmUnlinkPcLinkedEntityFromAll(); @@ -4587,13 +4587,13 @@ static void func_800BBA5C(void) { case 3: func_800A98A4(1); func_800A368C(1); - func_800B5274(); + ResetEffectState(); if (func_800B64C8() < 6) { - func_800B63F0(func_800B7200() ? 1 : 3); + PlayMusicTrack(func_800B7200() ? 1 : 3); } break; case 6: - func_800B65E0(0x1EC); + ToggleAmbientSound(0x1EC); break; } } @@ -4707,8 +4707,8 @@ void func_800BBD20(s32 arg0) { WmSetActiveEntityAsPcEntity(); func_800AA2E4(2); - WmSetActiveEntityDirectionAndRot(temp_v0); - func_800B63F0(1); + func_800A9480(temp_v0); + PlayMusicTrack(1); func_800A2108(0, 6); if (temp_s1 == 4) func_800A82DC(); @@ -4734,14 +4734,14 @@ void func_800BBD20(s32 arg0) { } func_800A9DB4(&sp10); if (func_800A9240() != 0) - func_800B63F0(2); + PlayMusicTrack(2); else - func_800B63F0(1); + PlayMusicTrack(1); if (temp_s1 == 6) - func_800B65E0(-0x1EC); + ToggleAmbientSound(-0x1EC); else if (temp_s1 == 5) - func_800B65E0(-0x1ED); + ToggleAmbientSound(-0x1ED); func_800A6994(&sp10, 1); } diff --git a/src/world/world.h b/src/world/world.h index 4b1a29d4..60992910 100644 --- a/src/world/world.h +++ b/src/world/world.h @@ -187,16 +187,16 @@ void SaveActorState(WorldActor*); void func_800ADD4C(s16); s16 func_800AE180(s32, s32, s32); s32 func_800B0240(void); -void func_800B0D98(WorldChunkHeader*); +void UpdateZolomGroundHeight(WorldChunkHeader*); void func_800B271C(s32); void func_800B29CC(void); s32 func_800B90C0(u8, u8, u8, u8, s16*); void func_800B1C80(WorldChunkHeader*); -void func_800B5274(); +void ResetEffectState(); void func_800B5C7C(WorldActor*); void func_800B624C(u16, s32); -void func_800B63F0(s32); -void func_800B65E0(s32); +void PlayMusicTrack(s32); +void ToggleAmbientSound(s32); void func_800B6B28(s16); void func_800B6E08(); s32 func_800B7200(); From 26f10baaec7860acc7860822f7d50793e4ca939f Mon Sep 17 00:00:00 2001 From: _checkra1n <97061690+devcheckra1n@users.noreply.github.com> Date: Thu, 3 Sep 2026 22:39:35 -0400 Subject: [PATCH 08/14] world: apply review feedback on loop shape, early returns and header order Rewrite the hand-expanded do/while loops as plain for and while, invert the guard conditions into early returns, drop the redundant chunk-search guard, give D_8010B434 a real struct so the draw-mode setup indexes it, and put the added externs in address order with the stray prototypes back in the prototype block. --- config/symbols.world.txt | 20 +-- src/world/world.c | 353 ++++++++++++++++++--------------------- src/world/world.h | 43 +++-- 3 files changed, 191 insertions(+), 225 deletions(-) diff --git a/config/symbols.world.txt b/config/symbols.world.txt index 37cb56ad..73ab8cc1 100644 --- a/config/symbols.world.txt +++ b/config/symbols.world.txt @@ -42,22 +42,4 @@ GetSavedParams = 0x800B7620; CopyAreaName = 0x800B7AC0; OpenWorldWindow = 0x800B851C; func_800BD124 = 0x800BD124; -WmLoadModelPacketAndScale = 0x800BFBF0; -WmCreatePacketForModelPart = 0x800BFCAC; -WmLoadTexturesToVram = 0x800C0808; -WmUpdateModelPacket2 = 0x800C08A8; -WmUpdatePacketForModelPartWithoutMatrixes = 0x800C0B48; -WmCalculateBoneMatrixes = 0x800C1490; -WmScaleModelAll = 0x800C1D58; -WmScaleModelVertexes = 0x800C1FD8; -WmScaleModelAnimations = 0x800C2130; -WmApplyModelLightingToPacket = 0x800C2450; -WmApplyPolyLightingToPacket = 0x800C2524; -WmCalculateModelLighting = 0x800C31F0; -WmCalculatePartLighting = 0x800C3948; -WmUpdatePartTransparency = 0x800C3DB0; -WmUpdateModelPacket = 0x800C4148; -WmUpdatePacketForModelPartWithMatrixes = 0x800C4FB4; -WmUpdateModelLighting = 0x800C5CD4; -WmUpdatePartLighting = 0x800C6104; -WmGetModelTotalRenderPacketSize = 0x800C6598; +D_8010B434 = 0x8010B434; // size:0x24 diff --git a/src/world/world.c b/src/world/world.c index c09849c6..c76af98f 100644 --- a/src/world/world.c +++ b/src/world/world.c @@ -513,48 +513,48 @@ void StartNearestRegionLoad(s16 arg0, s16 arg1) { s32 col; s16 idx; - if (D_800E5814 == 0 && D_800E5810 != NULL) { - if (TryAcquireLoadSlot(0) != 0) { - bestPrev = NULL; - best = NULL; - bestDist = 0x7FFF; - node = D_800E5810; - prev = NULL; - if (node != NULL) { - do { - idx = node->unk4; - row = idx / 4; - col = idx - row * 4; - dx = col - arg0; - if (dx <= 0) { - dx = arg0 - col; - } - if (dx >= 0x13) { - dx = 0x24 - dx; - } - dz = row - arg1; - if (dz <= 0) { - dz = arg1 - row; - } - if (dz >= 0xF) { - dz = 0x1C - dz; - } - dist = dx + dz; - if (dist < bestDist) { - bestDist = dist; - best = node; - bestPrev = prev; - } - prev = node; - node = node->next; - } while (node != NULL); - } - if (best == NULL) { - func_800A0B40(0x22); - } - FreeListNode(best, bestPrev); + if (D_800E5814 != 0 || D_800E5810 == NULL) { + return; + } + if (TryAcquireLoadSlot(0) == 0) { + return; + } + bestPrev = NULL; + best = NULL; + bestDist = 0x7FFF; + node = D_800E5810; + prev = NULL; + while (node != NULL) { + idx = node->unk4; + row = idx / 4; + col = idx - row * 4; + dx = col - arg0; + if (dx <= 0) { + dx = arg0 - col; + } + if (dx >= 0x13) { + dx = 0x24 - dx; + } + dz = row - arg1; + if (dz <= 0) { + dz = arg1 - row; } + if (dz >= 0xF) { + dz = 0x1C - dz; + } + dist = dx + dz; + if (dist < bestDist) { + bestDist = dist; + best = node; + bestPrev = prev; + } + prev = node; + node = node->next; + } + if (best == NULL) { + func_800A0B40(0x22); } + FreeListNode(best, bestPrev); } INCLUDE_ASM("asm/us/world/nonmatchings/world", WmStartLoadingMapFileBlock); @@ -684,13 +684,11 @@ void RegisterChunksForNode(WorldListNode* arg0) { WorldChunkHeader* c; c = D_80109D40; - if (c != NULL) { - do { - if ((((c->z >> 2) * 9) + (c->x >> 2)) == arg0->unk4) { - func_800A5AD8(c); - } - c = c->next; - } while (c != NULL); + while (c != NULL) { + if ((((c->z >> 2) * 9) + (c->x >> 2)) == arg0->unk4) { + func_800A5AD8(c); + } + c = c->next; } } @@ -713,51 +711,49 @@ s32 ExpireChunks(void) { live = 0; chunk = D_80109D40; prev = NULL; - if (chunk != NULL) { - do { - age = chunk->numVerts; - chunk->numVerts = age + 1; - if ((s16)age >= 0x96) { - if (prev != NULL) { - prev->next = chunk->next; - } else { - D_80109D40 = chunk->next; + while (chunk != NULL) { + age = chunk->numVerts; + chunk->numVerts = age + 1; + if ((s16)age >= 0x96) { + if (prev != NULL) { + prev->next = chunk->next; + } else { + D_80109D40 = chunk->next; + } + node = D_800E5A2C; + freeChunk = D_80109D38; + nodePrev = NULL; + D_80109D38 = chunk; + chunk->next = freeChunk; + if (node != NULL) { + while (node != NULL) { + if (node->chunk == chunk) { + break; + } + nodePrev = node; + node = node->next; } - node = D_800E5A2C; - freeChunk = D_80109D38; - nodePrev = NULL; - D_80109D38 = chunk; - chunk->next = freeChunk; if (node != NULL) { - while (node != NULL) { - if (node->chunk == chunk) { - break; - } - nodePrev = node; - node = node->next; + if (nodePrev != NULL) { + nodePrev->next = node->next; + } else { + D_800E5A2C = node->next; } - if (node != NULL) { - if (nodePrev != NULL) { - nodePrev->next = node->next; - } else { - D_800E5A2C = node->next; - } - freeNode = D_800E5A30; - D_800E5A30 = node; - node->next = freeNode; - } - } - if (prev != NULL) { - chunk = prev->next; - } else { - chunk = D_80109D40; + freeNode = D_800E5A30; + D_800E5A30 = node; + node->next = freeNode; } + } + if (prev != NULL) { + chunk = prev->next; } else { - prev = chunk; - chunk = chunk->next; - live++; + chunk = D_80109D40; } - } while (chunk != NULL); + } else { + prev = chunk; + chunk = chunk->next; + live++; + } } return live; } @@ -978,13 +974,11 @@ s32 IsChunkLoaded(s16 arg0, s16 arg1) { WorldChunkHeader* chunk; chunk = D_80109D3C; - if (chunk != NULL) { - while (chunk != NULL) { - if (chunk->x == arg0 && chunk->z == arg1) { - break; - } - chunk = chunk->next; + while (chunk != NULL) { + if (chunk->x == arg0 && chunk->z == arg1) { + break; } + chunk = chunk->next; } return chunk != NULL; } @@ -1344,21 +1338,22 @@ void BlendActorFacing(s16 arg0) { WorldActor* actor; u32 blend; - if (D_8010AD3C != NULL) { - actor = D_8010AD3C; - if (D_8011650C == 1) { - if (actor->flags1 & 1) { - blend = (u32)(((s16)actor->unk3E * 15) + arg0) >> 4; - } else { - blend = (u32)(((s16)actor->unk3E * 3) + arg0) >> 2; - } - } else if (actor->flags1 & 1) { - blend = (u32)(((s16)actor->unk3E * 7) + arg0) >> 3; + if (D_8010AD3C == NULL) { + return; + } + actor = D_8010AD3C; + if (D_8011650C == 1) { + if (actor->flags1 & 1) { + blend = (u32)(((s16)actor->unk3E * 15) + arg0) >> 4; } else { - blend = (u32)((s16)actor->unk3E + arg0) >> 1; + blend = (u32)(((s16)actor->unk3E * 3) + arg0) >> 2; } - actor->unk3E = blend; + } else if (actor->flags1 & 1) { + blend = (u32)(((s16)actor->unk3E * 7) + arg0) >> 3; + } else { + blend = (u32)((s16)actor->unk3E + arg0) >> 1; } + actor->unk3E = blend; } s16 func_800A97A8(void) { return D_8010AD3C == NULL ? 0 : D_8010AD3C->unk3C + D_8010AD3C->unk3E; } @@ -1550,17 +1545,15 @@ WorldActor* FindCollidingActor(WorldActor* arg0) { if (D_8010AD3C != NULL) { if (D_8010AD3C->actorType != 0xD || func_800A1DE0() != 0) { hit = D_8010AD38; - if (hit != NULL) { - do { - rc = func_800AA304(D_8010AD3C, hit); - if (rc != 0) { - break; - } - hit = hit->next; - } while (hit != NULL); - if (hit != NULL) { - D_8010AD3C->collide = hit; + while (hit != NULL) { + rc = func_800AA304(D_8010AD3C, hit); + if (rc != 0) { + break; } + hit = hit->next; + } + if (hit != NULL) { + D_8010AD3C->collide = hit; } } } @@ -2248,11 +2241,9 @@ s32 IsAnyScriptRunning(void) { flag = D_80109DBA != 0; a = D_8010AD38; - if (a != NULL && flag == 0) { - do { - flag |= a->scriptIdx != 0; - a = a->next; - } while (a != NULL && flag == 0); + while (a != NULL && flag == 0) { + flag |= a->scriptIdx != 0; + a = a->next; } return flag; } @@ -2589,8 +2580,7 @@ void ScrollLayerBack(s32 arg0, s32 arg1) { if (D_8010B488[0] > 0) { D_8010B47C = -arg0; - i = 0; - do { + for (i = 0; i < 2; i++) { if (GetGraphType() == 1 || GetGraphType() == 2) { tpage = 0xA6; if (arg1 == 1) { @@ -2602,10 +2592,8 @@ void ScrollLayerBack(s32 arg0, s32 arg1) { tpage = 0x56; } } - SetDrawMode( - (DR_MODE*)((i * 0x24) + (s32)D_8010B434), 0, 1, tpage, NULL); - i++; - } while (i < 2); + SetDrawMode(&D_8010B434[i].mode, 0, 1, tpage, NULL); + } } else { D_8010B47C = 0; } @@ -2617,8 +2605,7 @@ void ScrollLayerForward(s32 arg0, s32 arg1) { if (D_8010B488[0] < D_8010B494[0]) { D_8010B47C = arg0; - i = 0; - do { + for (i = 0; i < 2; i++) { if (GetGraphType() == 1 || GetGraphType() == 2) { tpage = 0xA6; if (arg1 == 1) { @@ -2630,10 +2617,8 @@ void ScrollLayerForward(s32 arg0, s32 arg1) { tpage = 0x56; } } - SetDrawMode( - (DR_MODE*)((i * 0x24) + (s32)D_8010B434), 0, 1, tpage, NULL); - i++; - } while (i < 2); + SetDrawMode(&D_8010B434[i].mode, 0, 1, tpage, NULL); + } } else { D_8010B47C = 0; } @@ -2706,17 +2691,18 @@ void UpdateZolomGroundHeight(WorldChunkHeader* arg0) { s16 chunkZ; s32 hit; - if (func_800B0794() != 0) { - pos.vx = D_8010C42C->x + 0x34000; - pos.vz = D_8010C42C->z + 0x20000; - func_800A6884(&pos, &dir, &chunkX, &chunkZ); - if (chunkX == arg0->x && chunkZ == arg0->z) { - hit = func_800A19FC( - arg0, &dir, D_8010C80C, &D_8010C42C->z2, 0, NULL, 0x64); - D_8010C800 = hit; - if (hit == 0) { - D_8010C42C->z2 = 0; - } + if (func_800B0794() == 0) { + return; + } + pos.vx = D_8010C42C->x + 0x34000; + pos.vz = D_8010C42C->z + 0x20000; + func_800A6884(&pos, &dir, &chunkX, &chunkZ); + if (chunkX == arg0->x && chunkZ == arg0->z) { + hit = func_800A19FC( + arg0, &dir, D_8010C80C, &D_8010C42C->z2, 0, NULL, 0x64); + D_8010C800 = hit; + if (hit == 0) { + D_8010C42C->z2 = 0; } } } @@ -2740,22 +2726,19 @@ void func_800B104C(void) { void RegisterChunk(WorldChunkHeader* arg0) { WorldChunkHeader** slot; WorldTriangle* t; - u8* p; if (arg0 == NULL) { return; } slot = D_8010CA24; - if (slot < D_8010CA74) { - while (slot < D_8010CA74) { - if (*slot == arg0) { - break; - } - slot++; - } - if (slot < D_8010CA74) { - return; + while (slot < D_8010CA74) { + if (*slot == arg0) { + break; } + slot++; + } + if (slot < D_8010CA74) { + return; } if (D_8010CA74 >= &D_8010CA24[20]) { func_800A0B40(0x47); @@ -2763,14 +2746,8 @@ void RegisterChunk(WorldChunkHeader* arg0) { slot = D_8010CA74; D_8010CA74 = slot + 1; *slot = arg0; - t = arg0->tris; - if (t < arg0->tris + arg0->numTris) { - p = (u8*)t + 0xB; - do { - *p &= 0xBF; - t++; - p += 0xC; - } while (t < arg0->tris + arg0->numTris); + for (t = arg0->tris; t < arg0->tris + arg0->numTris; t++) { + *((u8*)&t->textureAndLocationAndFlags + 1) &= ~0x40; } } @@ -2797,13 +2774,13 @@ void SetCurrentTriangle(WorldChunkHeader* arg0, WorldTriangle* arg1) { D_8010CA74 = D_8010CA24; RegisterChunk(arg0); if (arg1 != NULL) { - *((u8*)arg1 + 0xB) |= 0x40; + *((u8*)&arg1->textureAndLocationAndFlags + 1) |= 0x40; } D_800BD144 = 0; D_8010CA8C = 1; func_800AA0E0(&pos); inside = 0; - if ((u32)(pos.vx - 0x36000) <= 0x9FFF) { + if (pos.vx >= 0x36000 && pos.vx <= 0x3FFFF) { zoff = pos.vz - 0x1C000; inside = (u32)zoff <= 0x9FFF; } @@ -2820,20 +2797,21 @@ void GetTriangleCenter(WorldTriangleRef* arg0, VECTOR* arg1) { WorldChunkHeader* chunk; SVECTOR* verts; - if (arg1 != NULL) { - tri = arg0->tri; - chunk = arg0->chunk; - verts = chunk->verts; - arg1->vx = ((verts[tri->vert[0]].vx + verts[tri->vert[1]].vx + - verts[tri->vert[2]].vx) / - 3) + - (chunk->x << 13); - arg1->vy = 0; - arg1->vz = ((verts[tri->vert[0]].vz + verts[tri->vert[1]].vz + - verts[tri->vert[2]].vz) / - 3) + - (arg0->chunk->z << 13); + if (arg1 == NULL) { + return; } + tri = arg0->tri; + chunk = arg0->chunk; + verts = chunk->verts; + arg1->vx = ((verts[tri->vert[0]].vx + verts[tri->vert[1]].vx + + verts[tri->vert[2]].vx) / + 3) + + (chunk->x << 13); + arg1->vy = 0; + arg1->vz = ((verts[tri->vert[0]].vz + verts[tri->vert[1]].vz + + verts[tri->vert[2]].vz) / + 3) + + (arg0->chunk->z << 13); } INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B271C); @@ -3101,12 +3079,10 @@ void ToggleAmbientSound(s32 arg0) { void InitStreamState(void) { s32 i; - i = 0; - do { + for (i = 0; i < 0x2B; i++) { D_801159E8[i] = -1; D_80115A14[i] = 0; - i++; - } while (i < 0x2B); + } D_80115A40 = NULL; D_80115A44 = 0; D_80115A50 = 0; @@ -3138,15 +3114,16 @@ void WmPcCharModelLoadFileCallback(void) { INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B6B28); void StartStreamRead(void) { - if (D_80115A60 == 0) { - AbortRegionLoad(); - D_80115A40 = (u_long*)func_800A86C4(2); - if (TryAcquireLoadSlot(2) != 0) { - D_80115A60 = 1; - D_80115A50 = 0; - DS_read(D_800C74DC, D_800C74E0, D_80115A40, func_800B6DCC); - SystemCdromReadChain(); - } + if (D_80115A60 != 0) { + return; + } + AbortRegionLoad(); + D_80115A40 = (u_long*)func_800A86C4(2); + if (TryAcquireLoadSlot(2) != 0) { + D_80115A60 = 1; + D_80115A50 = 0; + DS_read(D_800C74DC, D_800C74E0, D_80115A40, func_800B6DCC); + SystemCdromReadChain(); } } diff --git a/src/world/world.h b/src/world/world.h index 60992910..a04dcb36 100644 --- a/src/world/world.h +++ b/src/world/world.h @@ -145,6 +145,9 @@ void func_800A31C0(s16); void func_800A368C(s32); void WmExtractLoopCoordsTopBottomParts(VECTOR*, SVECTOR*, s16*, s16*); void WmLoopCoordsAroundWorld(VECTOR*); +void func_800A5AD8(WorldChunkHeader*); +void func_800A6884(VECTOR*, SVECTOR*, s16*, s16*); +void func_800A692C(VECTOR*); void func_800A6994(VECTOR*, s32); void WmCleanEntityStruct(WorldActor*); void WmUnlinkEntityFromAll(WorldActor*); @@ -190,6 +193,8 @@ s32 func_800B0240(void); void UpdateZolomGroundHeight(WorldChunkHeader*); void func_800B271C(s32); void func_800B29CC(void); +void func_800B6AEC(void); +void func_800B6DCC(void); s32 func_800B90C0(u8, u8, u8, u8, s16*); void func_800B1C80(WorldChunkHeader*); void ResetEffectState(); @@ -315,7 +320,12 @@ extern s32 D_8010B080; extern s32 D_8010B174; extern Unk8010B178 D_8010B178[1]; // TODO: determine size extern Unk8010B3B8* D_8010B3B8; -extern u8 D_8010B434[]; +typedef struct { + /* 0x00 */ DR_MODE mode; + /* 0x0C */ u8 unk0C[0x18]; +} Unk8010B434; // size:0x24 + +extern Unk8010B434 D_8010B434[2]; extern s32 D_8010B47C; extern WorldZolomSegment D_8010C2AC[0x30]; extern WorldZolomSegment* D_8010C42C; @@ -357,7 +367,6 @@ extern s32 D_80116510; extern s32 D_800C74DC; extern s32 D_800C74E0; extern u_long* D_80115A40; -void func_800B6DCC(void); extern s32 D_80115A50; extern s32 D_80115A58; extern s32 D_80115A60; @@ -375,7 +384,6 @@ extern WorldChunkHeader D_80109A38[0x20]; extern WorldChunkHeader* D_80109D38; extern WorldChunkHeader* D_80109D3C; extern WorldChunkHeader* D_80109D40; -void func_800A5AD8(WorldChunkHeader*); extern WorldChunkNode D_800E582C[0x40]; extern WorldChunkNode* D_800E5A2C; extern WorldChunkNode* D_800E5A30; @@ -419,6 +427,17 @@ extern s16 D_800832A2[]; extern s32 D_80109D64; extern s32 D_80109D68; extern u8 D_8010D9B8[]; +extern u16 D_8009D2A6; +extern u8 D_800C6748[]; +extern MATRIX D_800C6808; +extern MATRIX D_800C6828; +extern MATRIX D_800C6848; +extern u8 D_800C6940; +extern u8 D_800C6A10[]; +extern s32 D_800C74C4[][2]; +extern u8* D_800C80BC; +extern s32 D_8010AD50; +extern s32 D_8010CB20; extern u8 D_8010CB24[]; extern s32 D_8010D930; extern u8* D_8010D9A4; @@ -427,30 +446,18 @@ extern s32 D_8010D9AC; extern s32 D_8010D9B0; extern s32 D_8010D9B4; extern s32 D_80115A44; +extern s32 D_80115A48; extern s32 D_80115A4C; extern s32 D_80115A54; +extern s32 D_80115A5C; extern u8 D_80115A6C[]; -extern u8* D_800C80BC; +extern s16 D_80116290; extern u32 D_8014A608; extern s32 D_8014A610; -extern s32 D_800C74C4[][2]; -extern s32 D_80115A48; -extern s32 D_80115A5C; -void func_800B6AEC(void); -extern u8 D_800C6940; -extern u8 D_800C6A10[]; -extern MATRIX D_800C6808; -extern MATRIX D_800C6828; -extern MATRIX D_800C6848; -extern s32 D_8010CB20; -extern u8 D_800C6748[]; -extern s32 D_8010AD50; extern u8 D_8010D9BA[]; -extern u16 D_8009D2A6; extern s32 D_80116274; extern s16 D_80116288; extern s16 D_8011628C; -extern s16 D_80116290; extern s32 D_8011626C; extern s32 D_80116270; extern s32 D_80116278; From 26507a6ddb34fc85f83248f0a92540c5fafd4205 Mon Sep 17 00:00:00 2001 From: _checkra1n <97061690+devcheckra1n@users.noreply.github.com> Date: Fri, 4 Sep 2026 23:58:47 -0400 Subject: [PATCH 09/14] world: reflow to the new 120 column limit --- src/world/world.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/world/world.c b/src/world/world.c index c76af98f..a1f48038 100644 --- a/src/world/world.c +++ b/src/world/world.c @@ -2257,8 +2257,7 @@ void SaveActorState(WorldActor* actor) { slot = D_800C6748[type]; if (slot < 6) { out = (s32*)((slot * 8) + D_8010AD50); - out[0] = (actor->altPos.vx & 0x7FFFF) | ((type << 19) & 0xF80000) | - ((actor->direction << 20) & 0xFF000000); + out[0] = (actor->altPos.vx & 0x7FFFF) | ((type << 19) & 0xF80000) | ((actor->direction << 20) & 0xFF000000); out[1] = (actor->altPos.vz & 0x3FFFF) | (actor->altPos.vy << 18); } } @@ -2698,8 +2697,7 @@ void UpdateZolomGroundHeight(WorldChunkHeader* arg0) { pos.vz = D_8010C42C->z + 0x20000; func_800A6884(&pos, &dir, &chunkX, &chunkZ); if (chunkX == arg0->x && chunkZ == arg0->z) { - hit = func_800A19FC( - arg0, &dir, D_8010C80C, &D_8010C42C->z2, 0, NULL, 0x64); + hit = func_800A19FC(arg0, &dir, D_8010C80C, &D_8010C42C->z2, 0, NULL, 0x64); D_8010C800 = hit; if (hit == 0) { D_8010C42C->z2 = 0; @@ -2803,15 +2801,10 @@ void GetTriangleCenter(WorldTriangleRef* arg0, VECTOR* arg1) { tri = arg0->tri; chunk = arg0->chunk; verts = chunk->verts; - arg1->vx = ((verts[tri->vert[0]].vx + verts[tri->vert[1]].vx + - verts[tri->vert[2]].vx) / - 3) + - (chunk->x << 13); + arg1->vx = ((verts[tri->vert[0]].vx + verts[tri->vert[1]].vx + verts[tri->vert[2]].vx) / 3) + (chunk->x << 13); arg1->vy = 0; - arg1->vz = ((verts[tri->vert[0]].vz + verts[tri->vert[1]].vz + - verts[tri->vert[2]].vz) / - 3) + - (arg0->chunk->z << 13); + arg1->vz = + ((verts[tri->vert[0]].vz + verts[tri->vert[1]].vz + verts[tri->vert[2]].vz) / 3) + (arg0->chunk->z << 13); } INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B271C); @@ -2865,8 +2858,7 @@ void UpdateWorldMode(void) { D_8010CAF4 = 0; } } - if (D_8010CAF0 == 3 && (D_8010CA8C == 2 || D_8010CA8C == 3) && - D_8010CACC == 0 && D_8010CAD0 == 0) { + if (D_8010CAF0 == 3 && (D_8010CA8C == 2 || D_8010CA8C == 3) && D_8010CACC == 0 && D_8010CAD0 == 0) { func_800B271C(3); } func_800B29CC(); From adee19b738e18a2e84f9e1d424d5cebf9b6aede0 Mon Sep 17 00:00:00 2001 From: _checkra1n <97061690+devcheckra1n@users.noreply.github.com> Date: Sat, 5 Sep 2026 09:15:29 -0400 Subject: [PATCH 10/14] world: adopt the names #142 and #141 landed #142 named 13 of the same functions this branch did, and named 27 more that it calls; take upstream's names for all of them rather than renaming merged work. #141 renamed DS_read to SysCdromStartLoadLzs. --- config/sym_ovl_export.us.txt | 136 ++++++++++++------------- config/symbols.world.txt | 192 ++++++++++++++++++++++++++++++++--- src/world/world.c | 94 ++++++++--------- src/world/world.h | 21 +--- 4 files changed, 299 insertions(+), 144 deletions(-) diff --git a/config/sym_ovl_export.us.txt b/config/sym_ovl_export.us.txt index a51434e9..fa2857fa 100644 --- a/config/sym_ovl_export.us.txt +++ b/config/sym_ovl_export.us.txt @@ -1885,10 +1885,10 @@ RestoreCharacterMateria = 0x801d3138; func_801D3260 = 0x801d3260; g_MateriaPriority = 0x801d3834; g_MateriaStealLoot = 0x801d3f60; -func_800A0B48 = 0x800a0b48; +WmSetRenderBuffers = 0x800a0b48; AllocPrims = 0x800a0be4; -func_800A0C54 = 0x800a0c54; -func_800A0D2C = 0x800a0d2c; +WmLoadTxzFile = 0x800a0c54; +WmLoadTxzDataAndInit = 0x800a0d2c; func_800A12AC = 0x800a12ac; WmPrepareForRender = 0x800a1370; WmRenderAll = 0x800a141c; @@ -1899,7 +1899,7 @@ WmGetRealCamRot = 0x800a1d14; WmSetCamRot = 0x800a1d38; func_800A1D54 = 0x800a1d54; func_800A1DF0 = 0x800a1df0; -SetPointTransform = 0x800a1fac; +WmSetTranslationVectorInScreenSpace = 0x800a1fac; func_800A2040 = 0x800a2040; WmSetCamView = 0x800a2088; func_800A2108 = 0x800a2108; @@ -1943,13 +1943,13 @@ func_800A4F78 = 0x800a4f78; func_800A5208 = 0x800a5208; AllocRegionNode = 0x800a52a4; FreeListNode = 0x800a5348; -StartNearestRegionLoad = 0x800a53a8; -func_800A54F0 = 0x800a54f0; +WmLoadClosestMapFileBlock = 0x800a53a8; +WmStartLoadingMapFileBlock = 0x800a54f0; UpdateRegionLoad = 0x800a57c8; -func_800A5924 = 0x800a5924; -func_800A5970 = 0x800a5970; +WmMapLoadFinishedCallback = 0x800a5924; +WmGetNumberOfMapToLoad = 0x800a5970; InitChunkNodePool = 0x800a59a0; -FindResidentRegion = 0x800a5a20; +WmGetElementWithBlockIdAndSetItFirst = 0x800a5a20; IsRegionLoading = 0x800a5a94; func_800A5AD8 = 0x800a5ad8; RegisterChunksForNode = 0x800a5b88; @@ -1962,8 +1962,8 @@ func_800A6168 = 0x800a6168; func_800A63FC = 0x800a63fc; func_800A64AC = 0x800a64ac; AllocChunk = 0x800a67a8; -func_800A6884 = 0x800a6884; -func_800A692C = 0x800a692c; +WmExtractLoopCoordsTopBottomParts = 0x800a6884; +WmLoopCoordsAroundWorld = 0x800a692c; func_800A6994 = 0x800a6994; func_800A6B8C = 0x800a6b8c; func_800A6BCC = 0x800a6bcc; @@ -1972,8 +1972,8 @@ func_800A6C3C = 0x800a6c3c; func_800A6FC0 = 0x800a6fc0; func_800A71E8 = 0x800a71e8; InitWorldState = 0x800a7ea4; -func_800A7F18 = 0x800a7f18; -AbortRegionLoad = 0x800a7f38; +WmAbortMapLoadingWrapper = 0x800a7f18; +WmAbortMapLoading = 0x800a7f38; func_800A806C = 0x800a806c; func_800A82F0 = 0x800a82f0; IsChunkLoaded = 0x800a8300; @@ -2059,7 +2059,7 @@ func_800AA6D0 = 0x800aa6d0; WmMoveActiveEntity = 0x800aa7dc; func_800AA8D8 = 0x800aa8d8; func_800AA8F8 = 0x800aa8f8; -UpdateEventState = 0x800aaa00; +WmGetBuggyMoveAnimationId = 0x800aaa00; func_800AAB18 = 0x800aab18; func_800AB36C = 0x800ab36c; func_800AB398 = 0x800ab398; @@ -2073,26 +2073,26 @@ func_800AB92C = 0x800ab92c; func_800AB988 = 0x800ab988; func_800ABA18 = 0x800aba18; func_800ABA78 = 0x800aba78; -func_800ABB24 = 0x800abb24; -func_800ABE58 = 0x800abe58; -func_800ABFC0 = 0x800abfc0; -func_800AC3C0 = 0x800ac3c0; -func_800AC484 = 0x800ac484; -func_800AC700 = 0x800ac700; -func_800AD63C = 0x800ad63c; -func_800AD788 = 0x800ad788; +WmScriptPopStack = 0x800abb24; +WmScriptWriteBank = 0x800abe58; +WmScriptOpcode000Handle = 0x800abfc0; +WmScriptOpcode100Handle = 0x800ac3c0; +WmScriptOpcode200Handle = 0x800ac484; +WmScriptOpcode300Handle = 0x800ac700; +WmScriptRunOne = 0x800ad63c; +WmScriptRunAll = 0x800ad788; UpdateSurfaceEffect = 0x800ad804; -IsAnyScriptRunning = 0x800ad928; +WmScriptIsAnyScriptRuns = 0x800ad928; SaveActorState = 0x800ad970; func_800ADA08 = 0x800ada08; -RestoreActorState = 0x800ada64; +WmRestoreEntityPosAndDirFromSavemap = 0x800ada64; func_800ADB30 = 0x800adb30; func_800ADC3C = 0x800adc3c; func_800ADC70 = 0x800adc70; -TryAcquireLoadSlot = 0x800adc80; -func_800ADD4C = 0x800add4c; -func_800ADE30 = 0x800ade30; -func_800ADEA8 = 0x800adea8; +WmAddMutexPriority = 0x800adc80; +WmRemoveMutexPriority = 0x800add4c; +WmRandomTwiddle = 0x800ade30; +WmRandomInit = 0x800adea8; func_800ADFC0 = 0x800adfc0; WmGetDistanceBetweenPoints = 0x800ae024; WmRotateVectorByYAngle = 0x800ae0bc; @@ -2107,7 +2107,7 @@ func_800AE8AC = 0x800ae8ac; func_800AEA48 = 0x800aea48; func_800AF0A0 = 0x800af0a0; func_800AF0B0 = 0x800af0b0; -SetupLighting = 0x800af110; +WmSetGteColourSettings = 0x800af110; func_800AF1A8 = 0x800af1a8; WmSetActivePointMeshCoords = 0x800af1e8; WmSetActivePointCoordsInMesh = 0x800af24c; @@ -2117,14 +2117,14 @@ func_800AF364 = 0x800af364; WmUpdateLightingFromPoints = 0x800af3a4; WmGetDistanceToActivePoint = 0x800af96c; func_800AF9A0 = 0x800af9a0; -func_800AF9DC = 0x800af9dc; -func_800AFCC8 = 0x800afcc8; -ScrollLayerBack = 0x800affbc; -ScrollLayerForward = 0x800b0098; -func_800B017C = 0x800b017c; -func_800B01C4 = 0x800b01c4; -func_800B0200 = 0x800b0200; -func_800B0240 = 0x800b0240; +WmFadeInit = 0x800af9dc; +WmFadeRender = 0x800afcc8; +WmSetFadeIn = 0x800affbc; +WmSetFadeOut = 0x800b0098; +WmFadeInSnow = 0x800b017c; +WmFadeOutSnow = 0x800b01c4; +WmFadeStartSnow = 0x800b0200; +WmFadeIsStopped = 0x800b0240; func_800B0250 = 0x800b0250; func_800B0334 = 0x800b0334; func_800B04AC = 0x800b04ac; @@ -2184,11 +2184,11 @@ func_800B650C = 0x800b650c; WmSetMusicVolume = 0x800b6570; func_800B65A4 = 0x800b65a4; ToggleAmbientSound = 0x800b65e0; -InitStreamState = 0x800b667c; -func_800B6724 = 0x800b6724; -func_800B69A4 = 0x800b69a4; -func_800B6A4C = 0x800b6a4c; -func_800B6AEC = 0x800b6aec; +WmInitModelVariablesAndArray = 0x800b667c; +WmCalculateBonesAndLighting = 0x800b6724; +WmLoadPcCharModelFile = 0x800b69a4; +WmLoadPcCharModelIntoMemory = 0x800b6a4c; +WmPcCharModelLoadFileCallback = 0x800b6aec; func_800B6B28 = 0x800b6b28; StartStreamRead = 0x800b6c84; func_800B6D10 = 0x800b6d10; @@ -2225,32 +2225,32 @@ func_800B7BD8 = 0x800b7bd8; func_800B7C1C = 0x800b7c1c; func_800B7C7C = 0x800b7c7c; func_800B832C = 0x800b832c; -func_800B8488 = 0x800b8488; -func_800B84D8 = 0x800b84d8; -OpenWorldWindow = 0x800b851c; -func_800B858C = 0x800b858c; -func_800B85D4 = 0x800b85d4; -func_800B86C4 = 0x800b86c4; -func_800B86E8 = 0x800b86e8; -func_800B8720 = 0x800b8720; -func_800B8760 = 0x800b8760; -func_800B87D8 = 0x800b87d8; -func_800B89C4 = 0x800b89c4; -func_800B8A5C = 0x800b8a5c; -func_800B8A98 = 0x800b8a98; -func_800B8B00 = 0x800b8b00; -func_800B8CBC = 0x800b8cbc; -func_800B8D20 = 0x800b8d20; -func_800B8D4C = 0x800b8d4c; -func_800B90C0 = 0x800b90c0; -func_800B95E8 = 0x800b95e8; -func_800B962C = 0x800b962c; -func_800B98F0 = 0x800b98f0; -func_800B9B2C = 0x800b9b2c; -func_800BA938 = 0x800ba938; -func_800BAA00 = 0x800baa00; -func_800BAB60 = 0x800bab60; -func_800BAC70 = 0x800bac70; +WmDialogsInit = 0x800b8488; +WmDialogSetMessageToShowForId0 = 0x800b84d8; +WmDialogSetAskToShowForId0 = 0x800b851c; +WmDialogSetWindowWithId0ToClose = 0x800b858c; +WmDialogUpdate = 0x800b85d4; +WmDialogGetAskResult = 0x800b86c4; +WmDialogSetPosAndSizeForId0 = 0x800b86e8; +WmDialogSetModeAndPermanencyForId0 = 0x800b8720; +WmDialog0ResetAndPointerInit = 0x800b8760; +WmDialogReset = 0x800b87d8; +WmDialogSetWindowToCloseIfPossible = 0x800b89c4; +WmDialogSetModeAndPermanency = 0x800b8a5c; +WmDialogsReset = 0x800b8a98; +WmDialogSetPosAndSize = 0x800b8b00; +WmDialogAddPos = 0x800b8cbc; +WmDialogSetHeight = 0x800b8d20; +WmDialogSetMessageToShow = 0x800b8d4c; +WmDialogSetAskToShow = 0x800b90c0; +WmDialogPlaySound = 0x800b95e8; +WmDialogInitWindow = 0x800b962c; +WmDialogInscreaseWindow = 0x800b98f0; +WmDialogStringOutput = 0x800b9b2c; +WmDialogTextScrollByRow = 0x800ba938; +WmDialogTextScrollDuringOk = 0x800baa00; +WmDialogStartText = 0x800bab60; +WmDialogDiscreaseWindow = 0x800bac70; func_800BAE60 = 0x800bae60; WmDialogAddDigitWithoutLeadingSpace = 0x800bb350; WmDialogAddDigitWithLeadingSpace = 0x800bb450; diff --git a/config/symbols.world.txt b/config/symbols.world.txt index 73ab8cc1..8f31f440 100644 --- a/config/symbols.world.txt +++ b/config/symbols.world.txt @@ -1,45 +1,211 @@ +WmSetRenderBuffers = 0x800A0B48; +WmGetCurrRenderBufferId = 0x800A0BD4; AllocPrims = 0x800A0BE4; -SetPointTransform = 0x800A1FAC; +WmLoadTxzFile = 0x800A0C54; +WmLoadTxzDataAndInit = 0x800A0D2C; +WmPrepareForRender = 0x800A1370; +WmRenderAll = 0x800A141C; +WmSetShaking = 0x800A16D0; +WmIsTerrainPassableByModel = 0x800A1710; +WmGetRealCamRot = 0x800A1D14; +WmSetDesiredCamRot = 0x800A1D24; +WmSetCamRot = 0x800A1D38; +WmGetWmId = 0x800A1DE0; +WmSetTranslationVectorInScreenSpace = 0x800A1FAC; +WmSetCamView = 0x800A2088; +WmHandleButtons = 0x800A21B4; UpdateFogRanges = 0x800A31F8; +WmSubmarineFloatToPlanet = 0x800A3DFC; +WmSubmarineSubmergeUnderwater = 0x800A3E4C; +WmResetGame = 0x800A4008; UpdateFadeOverlay = 0x800A4268; +WmMain = 0x800A460C; +WmInitLoadMapFileStruct = 0x800A4DDC; +WmGetBlockIdByXZForPlanet = 0x800A4F08; AllocRegionNode = 0x800A52A4; FreeListNode = 0x800A5348; -StartNearestRegionLoad = 0x800A53A8; +WmLoadClosestMapFileBlock = 0x800A53A8; +WmStartLoadingMapFileBlock = 0x800A54F0; UpdateRegionLoad = 0x800A57C8; +WmMapLoadFinishedCallback = 0x800A5924; +WmGetNumberOfMapToLoad = 0x800A5970; InitChunkNodePool = 0x800A59A0; -FindResidentRegion = 0x800A5A20; +WmGetElementWithBlockIdAndSetItFirst = 0x800A5A20; IsRegionLoading = 0x800A5A94; RegisterChunksForNode = 0x800A5B88; ExpireChunks = 0x800A5FB4; InitChunkPool = 0x800A60D8; AllocChunk = 0x800A67A8; +WmExtractLoopCoordsTopBottomParts = 0x800A6884; +WmLoopCoordsAroundWorld = 0x800A692C; InitWorldState = 0x800A7EA4; -AbortRegionLoad = 0x800A7F38; +WmAbortMapLoadingWrapper = 0x800A7F18; +WmAbortMapLoading = 0x800A7F38; IsChunkLoaded = 0x800A8300; +WmSetWorldProgress = 0x800A8888; +WmInitAllEntityStructs = 0x800A891C; +WmInsertInEntityStructList = 0x800A8A1C; +WmCleanEntityStruct = 0x800A8ABC; +WmUnlinkEntityAndInsertAsNew = 0x800A8AF4; +WmUnlinkEntityFromAll = 0x800A8B30; +WmInsertStructInEntityStructList = 0x800A8C70; +WmLinkPcToActiveEntity = 0x800A8CE4; +WmUnlinkPcEntityFromAll = 0x800A8F74; +WmUnlinkActiveEntityFromAll = 0x800A8FA0; +WmUnlinkPcLinkedEntityFromAll = 0x800A8FCC; +WmSetPcEntityAsActiveEntity = 0x800A90EC; +WmSetActiveEntityAsPcEntity = 0x800A9110; +WmGetModelIdFromActiveEntity = 0x800A9154; +WmGetModelIdFromPcEntity = 0x800A9174; +WmIsPcEntityModelInMask = 0x800A91A4; +WmInitActiveEntityStruct = 0x800A9334; +WmSetActiveEntityDirectionAndRot = 0x800A9480; BlendActorFacing = 0x800A96D0; +WmGetPcEntityTotalRot = 0x800A97E4; +WmIsPcEntityPosNeedRecalculation = 0x800A98E4; +WmGetPcEntityOriginalY = 0x800A9910; +WmSetActiveEntityWithModelId = 0x800A993C; +WmSetPcEntityTerrainData = 0x800A9A24; +WmGetPcEntityTerrainId = 0x800A9A44; +WmGetPosFromActiveEntity = 0x800AA098; +WmGetPosFromPcEntity = 0x800AA0E0; +WmGetPos2FromActiveEntity = 0x800AA128; +WmGetPos2FromPcEntity = 0x800AA170; FindCollidingActor = 0x800AA580; -UpdateEventState = 0x800AAA00; +WmMoveActiveEntity = 0x800AA7DC; +WmGetBuggyMoveAnimationId = 0x800AAA00; +WmPrepareEntities = 0x800AB4F4; +WmScriptInitVariables = 0x800AB5E4; +WmScriptRunFunction = 0x800AB6E4; +WmScriptDisableForPcEntity = 0x800AB8EC; +WmScriptPopStack = 0x800ABB24; +WmScriptWriteBank = 0x800ABE58; +WmScriptOpcode000Handle = 0x800ABFC0; +WmScriptOpcode100Handle = 0x800AC3C0; +WmScriptOpcode200Handle = 0x800AC484; +WmScriptOpcode300Handle = 0x800AC700; +WmScriptRunOne = 0x800AD63C; +WmScriptRunAll = 0x800AD788; UpdateSurfaceEffect = 0x800AD804; -IsAnyScriptRunning = 0x800AD928; +WmScriptIsAnyScriptRuns = 0x800AD928; SaveActorState = 0x800AD970; -RestoreActorState = 0x800ADA64; -TryAcquireLoadSlot = 0x800ADC80; -SetupLighting = 0x800AF110; -ScrollLayerBack = 0x800AFFBC; -ScrollLayerForward = 0x800B0098; +WmRestoreEntityPosAndDirFromSavemap = 0x800ADA64; +WmAddMutexPriority = 0x800ADC80; +WmRemoveMutexPriority = 0x800ADD4C; +WmRandomTwiddle = 0x800ADE30; +WmRandomInit = 0x800ADEA8; +WmGetDistanceBetweenPoints = 0x800AE024; +WmRotateVectorByYAngle = 0x800AE0BC; +WmGetRotFromVector = 0x800AE180; +WmGetRotFromEntityToEntity = 0x800AE47C; +WmCreateSkyboxOverlayRenderBuffers = 0x800AE4B8; +WmGetSkyboxOverlayCurrRenderBuffer = 0x800AE5B8; +WmGetSkyboxOverlayCurrTextureSettingBuffer = 0x800AE5F0; +WmUpdateSkyboxOverlayVertexes = 0x800AE638; +WmSetGteColourSettings = 0x800AF110; +WmSetActivePointMeshCoords = 0x800AF1E8; +WmSetActivePointCoordsInMesh = 0x800AF24C; +WmSetActivePointColour = 0x800AF2A4; +WmSetActivePointSkyColour = 0x800AF324; +WmUpdateLightingFromPoints = 0x800AF3A4; +WmGetDistanceToActivePoint = 0x800AF96C; +WmFadeInit = 0x800AF9DC; +WmFadeRender = 0x800AFCC8; +WmSetFadeIn = 0x800AFFBC; +WmSetFadeOut = 0x800B0098; +WmFadeInSnow = 0x800B017C; +WmFadeOutSnow = 0x800B01C4; +WmFadeStartSnow = 0x800B0200; +WmFadeIsStopped = 0x800B0240; UpdateZolomGroundHeight = 0x800B0D98; RegisterChunk = 0x800B10AC; SetCurrentTriangle = 0x800B21E4; GetTriangleCenter = 0x800B2638; UpdateWorldMode = 0x800B2E90; +WmSnowReset = 0x800B3044; +WmSnowUpdate = 0x800B307C; InitEffectPool = 0x800B392C; ResetEffectState = 0x800B5274; +WmCreateShadowPacket = 0x800B58F8; +WmSetCalculateAllPartsLighting = 0x800B5DD8; +WmUpdateModelByAnimationFrame = 0x800B5E28; PlayMusicTrack = 0x800B63F0; +WmSetMusicVolume = 0x800B6570; ToggleAmbientSound = 0x800B65E0; -InitStreamState = 0x800B667C; +WmInitModelVariablesAndArray = 0x800B667C; +WmCalculateBonesAndLighting = 0x800B6724; +WmLoadPcCharModelFile = 0x800B69A4; +WmLoadPcCharModelIntoMemory = 0x800B6A4C; +WmPcCharModelLoadFileCallback = 0x800B6AEC; StartStreamRead = 0x800B6C84; +WmPackModelLoadFileCallback = 0x800B6DCC; +WmGetModelDataByModelId = 0x800B6EFC; +WmAbortModelLoading = 0x800B7134; GetSavedParams = 0x800B7620; +WmSetFieldToLoad = 0x800B7714; +WmGetPcCharModelIdFromParty = 0x800B79B8; CopyAreaName = 0x800B7AC0; -OpenWorldWindow = 0x800B851C; +WmDialogsInit = 0x800B8488; +WmDialogSetMessageToShowForId0 = 0x800B84D8; +WmDialogSetAskToShowForId0 = 0x800B851C; +WmDialogIsWindowWithId0Showing = 0x800B857C; +WmDialogSetWindowWithId0ToClose = 0x800B858C; +WmDialogUpdate = 0x800B85D4; +WmDialogGetAskResult = 0x800B86C4; +WmDialogSetPosAndSizeForId0 = 0x800B86E8; +WmDialogSetModeAndPermanencyForId0 = 0x800B8720; +WmDialogPrintParam = 0x800B8750; +WmDialogPrintNoParam = 0x800B8758; +WmDialog0ResetAndPointerInit = 0x800B8760; +WmDialogReset = 0x800B87D8; +WmDialogSetWindowToCloseIfPossible = 0x800B89C4; +WmDialogSetModeAndPermanency = 0x800B8A5C; +WmDialogsReset = 0x800B8A98; +WmDialogSetPosAndSize = 0x800B8B00; +WmDialogAddPos = 0x800B8CBC; +WmDialogSetHeight = 0x800B8D20; +WmDialogSetMessageToShow = 0x800B8D4C; +WmDialogSetAskToShow = 0x800B90C0; +WmDialogPlaySound = 0x800B95E8; +WmDialogInitWindow = 0x800B962C; +WmDialogInscreaseWindow = 0x800B98F0; +WmDialogStringOutput = 0x800B9B2C; +WmDialogTextScrollByRow = 0x800BA938; +WmDialogTextScrollDuringOk = 0x800BAA00; +WmDialogStartText = 0x800BAB60; +WmDialogDiscreaseWindow = 0x800BAC70; +WmDialogAddDigitWithoutLeadingSpace = 0x800BB350; +WmDialogAddDigitWithLeadingSpace = 0x800BB450; +WmDialogAddHexDigitWithoutLeadingSpace = 0x800BB568; +WmDialogCopyStringIntoCharName = 0x800BB7DC; +WmMovePcEntityByDistance = 0x800BB8E8; +WmScriptPushToStoreStack = 0x800BB9A0; +WmScriptPopFromStoreStack = 0x800BB9D0; +WmScriptGetTopFromStoreStack = 0x800BBA0C; +WmScriptSetFirstToStoreStack = 0x800BBA34; +WmScriptIsDataInStoreStack = 0x800BBA44; +WmUiMapCreate = 0x800BC1CC; +WmUiMapUpdate = 0x800BC420; +WmSetCamMode = 0x800BC9E8; +WmGetCamMode = 0x800BCA38; func_800BD124 = 0x800BD124; +WmLoadModelPacketAndScale = 0x800BFBF0; +WmCreatePacketForModelPart = 0x800BFCAC; +WmLoadTexturesToVram = 0x800C0808; +WmUpdateModelPacket2 = 0x800C08A8; +WmUpdatePacketForModelPartWithoutMatrixes = 0x800C0B48; +WmCalculateBoneMatrixes = 0x800C1490; +WmScaleModelAll = 0x800C1D58; +WmScaleModelVertexes = 0x800C1FD8; +WmScaleModelAnimations = 0x800C2130; +WmApplyModelLightingToPacket = 0x800C2450; +WmApplyPolyLightingToPacket = 0x800C2524; +WmCalculateModelLighting = 0x800C31F0; +WmCalculatePartLighting = 0x800C3948; +WmUpdatePartTransparency = 0x800C3DB0; +WmUpdateModelPacket = 0x800C4148; +WmUpdatePacketForModelPartWithMatrixes = 0x800C4FB4; +WmUpdateModelLighting = 0x800C5CD4; +WmUpdatePartLighting = 0x800C6104; +WmGetModelTotalRenderPacketSize = 0x800C6598; D_8010B434 = 0x8010B434; // size:0x24 diff --git a/src/world/world.c b/src/world/world.c index a1f48038..f75b6be5 100644 --- a/src/world/world.c +++ b/src/world/world.c @@ -2,9 +2,9 @@ #include "world.h" #include -void func_800A9480(s16 arg0); -void func_800AA0E0(VECTOR* arg0); -void RestoreActorState(WorldActor*); +void WmSetActiveEntityDirectionAndRot(s16 arg0); +void WmGetPosFromPcEntity(VECTOR* arg0); +void WmRestoreEntityPosAndDirFromSavemap(WorldActor*); s32 func_800ADFC0(void); static s32 func_800B0800(void); void WmCreateShadowPacket(u8*, RECT*); @@ -139,7 +139,7 @@ static s32 WmGetWmId(void) { return D_800E5634; } INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A1DF0); -void SetPointTransform(SVECTOR* arg0) { +void WmSetTranslationVectorInScreenSpace(SVECTOR* arg0) { MATRIX m; SVECTOR v; VECTOR out; @@ -254,7 +254,7 @@ void WmSubmarineFloatToPlanet(void) { D_800E5644 = 0x14; WmSetFieldToLoad(0); func_800A2108(0, 0); - ScrollLayerForward(0x10, 1); + WmSetFadeOut(0x10, 1); } void WmSubmarineSubmergeUnderwater(void) { @@ -262,7 +262,7 @@ void WmSubmarineSubmergeUnderwater(void) { D_800E5644 = -0x14; WmSetFieldToLoad(0); func_800A2108(0, 0); - ScrollLayerForward(0x10, 1); + WmSetFadeOut(0x10, 1); } void func_800A3E9C(s32 arg0) { @@ -341,11 +341,11 @@ void func_800A41E8(s32 arg0) { switch (arg0) { case 1: func_800A2108(0, 4); - ScrollLayerForward(4, 1); + WmSetFadeOut(4, 1); break; case 4: func_800A2108(1, 4); - ScrollLayerBack(0x10, 1); + WmSetFadeIn(0x10, 1); arg0 = 0; break; } @@ -356,10 +356,10 @@ void UpdateFadeOverlay(void) { s32 slot; s32 vsync; - slot = func_800A0BD4(); + slot = WmGetCurrRenderBufferId(); switch (D_800E56F4) { case 1: - if (func_800B0240() != 0) { + if (WmFadeIsStopped() != 0) { D_800E56F4 = 2; } break; @@ -500,7 +500,7 @@ void FreeListNode(WorldListNode* arg0, WorldListNode* arg1) { arg0->next = tmp; } -void StartNearestRegionLoad(s16 arg0, s16 arg1) { +void WmLoadClosestMapFileBlock(s16 arg0, s16 arg1) { WorldListNode* node; WorldListNode* prev; WorldListNode* best; @@ -516,7 +516,7 @@ void StartNearestRegionLoad(s16 arg0, s16 arg1) { if (D_800E5814 != 0 || D_800E5810 == NULL) { return; } - if (TryAcquireLoadSlot(0) == 0) { + if (WmAddMutexPriority(0) == 0) { return; } bestPrev = NULL; @@ -636,7 +636,7 @@ void InitChunkNodePool(void) { D_800E5A34 = 0; } -WorldListNode* FindResidentRegion(s16 arg0) { +WorldListNode* WmGetElementWithBlockIdAndSetItFirst(s16 arg0) { WorldListNode* node; WorldListNode* prev; WorldListNode* head; @@ -892,7 +892,7 @@ void func_800A6BCC(SVECTOR* arg0) { void func_800A6C00(s32 arg0) { if (func_800A1DB0() != 2) - SetPointTransform(arg0); + WmSetTranslationVectorInScreenSpace(arg0); } INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A6C3C); @@ -908,7 +908,7 @@ static void func_800A7E8C(s32 arg0) { D_80109D6C = arg0; } static void func_800A7E9C(void) {} void InitWorldState(void) { - func_800A4DDC(); + WmInitLoadMapFileStruct(); InitChunkNodePool(); InitChunkPool(); D_80109D54 = 0; @@ -921,9 +921,9 @@ void InitWorldState(void) { D_80109D6C = 0; } -void func_800A7F18(void) { AbortRegionLoad(); } +void WmAbortMapLoadingWrapper(void) { WmAbortMapLoading(); } -void AbortRegionLoad(void) { +void WmAbortMapLoading(void) { WorldListNode* node; WorldListNode* prev; WorldListNode* head; @@ -1291,8 +1291,8 @@ void WmInitActiveEntityStruct(s32 arg0) { rect.h = 0xF; D_8010AD3C->unk58 = 0x20; } - func_800B58F8(D_8010AD3C->unk90, &rect); - RestoreActorState(D_8010AD3C); + WmCreateShadowPacket(D_8010AD3C->unk90, &rect); + WmRestoreEntityPosAndDirFromSavemap(D_8010AD3C); } } @@ -1543,7 +1543,7 @@ WorldActor* FindCollidingActor(WorldActor* arg0) { rc = 0; hit = NULL; if (D_8010AD3C != NULL) { - if (D_8010AD3C->actorType != 0xD || func_800A1DE0() != 0) { + if (D_8010AD3C->actorType != 0xD || WmGetWmId() != 0) { hit = D_8010AD38; while (hit != NULL) { rc = func_800AA304(D_8010AD3C, hit); @@ -1623,12 +1623,12 @@ void func_800AA8D8(s16 arg0, s16 arg1, s16 arg2) { INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA8F8); -s32 UpdateEventState(u8* arg0) { +s32 WmGetBuggyMoveAnimationId(u8* arg0) { s32 prev; s32 event; prev = D_80109D70; - event = func_800A9A44(); + event = WmGetPcEntityTerrainId(); switch (D_80109D70) { case 1: if (event == 0xB) { @@ -2214,7 +2214,7 @@ void UpdateSurfaceEffect(void) { if (D_8010ADEC != 0 || (D_8010AD40->flags1 & 8)) { return; } - if (func_800A91A4(0x2000) != 0) { + if (WmIsPcEntityModelInMask(0x2000) != 0) { if ((D_8010AD40->pos.vy - D_8010AD40->unk42) >= 0x1F4) { return; } @@ -2227,7 +2227,7 @@ void UpdateSurfaceEffect(void) { D_8010ADF0 = kind; func_800ABA78(kind - 3, 0); } - if (kind == 7 && func_800A91A4(0x2000) == 0) { + if (kind == 7 && WmIsPcEntityModelInMask(0x2000) == 0) { func_800AA238(); } } else { @@ -2235,7 +2235,7 @@ void UpdateSurfaceEffect(void) { } } -s32 IsAnyScriptRunning(void) { +s32 WmScriptIsAnyScriptRuns(void) { WorldActor* a; s32 flag; @@ -2270,7 +2270,7 @@ void func_800ADA08(void) { SaveActorState(var_s0); } -void RestoreActorState(WorldActor* arg0) { +void WmRestoreEntityPosAndDirFromSavemap(WorldActor* arg0) { s32* p; s32* end; s32 t; @@ -2312,7 +2312,7 @@ void func_800ADC3C(VECTOR* arg0) { D_8010AE34 = *arg0; } void func_800ADC70(void) { D_8010AE54 = 0; } -s32 TryAcquireLoadSlot(s16 arg0) { +s32 WmAddMutexPriority(s16 arg0) { if ((D_8010AE54 >> arg0) & 1) { if (!((-1 << (arg0 + 1)) & D_8010AE54)) { return 1; @@ -2320,9 +2320,9 @@ s32 TryAcquireLoadSlot(s16 arg0) { } if (D_8010AE54 < (1 << arg0)) { if (D_8010AE54 == 1) { - AbortRegionLoad(); + WmAbortMapLoading(); } else if (D_8010AE54 & 4) { - func_800B7134(); + WmAbortModelLoading(); } D_8010AE54 |= 1 << arg0; return 1; @@ -2453,7 +2453,7 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AEA48); void func_800AF0A0(s32 arg0) { D_8010B174 = arg0; } void func_800AF0B0(void) { - void SetupLighting(void); + void WmSetGteColourSettings(void); s32 i; s32 offset; @@ -2466,10 +2466,10 @@ void func_800AF0B0(void) { } D_8010B3B8 = NULL; - SetupLighting(); + WmSetGteColourSettings(); } -void SetupLighting(void) { +void WmSetGteColourSettings(void) { MATRIX* m; s32 mode; s32 r; @@ -2477,13 +2477,13 @@ void SetupLighting(void) { s32 b; mode = 2; - if (func_800A1DE0() == mode) { + if (WmGetWmId() == mode) { m = &D_800C6828; } else { m = &D_800C6808; } SetLightMatrix(m); - if (func_800A1DE0() == mode) { + if (WmGetWmId() == mode) { r = 0x20; g = 0x20; b = 0x30; @@ -2573,7 +2573,7 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", WmFadeInit); INCLUDE_ASM("asm/us/world/nonmatchings/world", WmFadeRender); -void ScrollLayerBack(s32 arg0, s32 arg1) { +void WmSetFadeIn(s32 arg0, s32 arg1) { s32 i; s32 tpage; @@ -2598,7 +2598,7 @@ void ScrollLayerBack(s32 arg0, s32 arg1) { } } -void ScrollLayerForward(s32 arg0, s32 arg1) { +void WmSetFadeOut(s32 arg0, s32 arg1) { s32 i; s32 tpage; @@ -2695,7 +2695,7 @@ void UpdateZolomGroundHeight(WorldChunkHeader* arg0) { } pos.vx = D_8010C42C->x + 0x34000; pos.vz = D_8010C42C->z + 0x20000; - func_800A6884(&pos, &dir, &chunkX, &chunkZ); + WmExtractLoopCoordsTopBottomParts(&pos, &dir, &chunkX, &chunkZ); if (chunkX == arg0->x && chunkZ == arg0->z) { hit = func_800A19FC(arg0, &dir, D_8010C80C, &D_8010C42C->z2, 0, NULL, 0x64); D_8010C800 = hit; @@ -2776,7 +2776,7 @@ void SetCurrentTriangle(WorldChunkHeader* arg0, WorldTriangle* arg1) { } D_800BD144 = 0; D_8010CA8C = 1; - func_800AA0E0(&pos); + WmGetPosFromPcEntity(&pos); inside = 0; if (pos.vx >= 0x36000 && pos.vx <= 0x3FFFF) { zoff = pos.vz - 0x1C000; @@ -2960,7 +2960,7 @@ void ResetEffectState(void) { *(s16*)0x1F800012 = 0x32; *(s16*)0x1F800014 = 0; *(s16*)0x1F800020 = 0; - func_800AA0E0(0x1F800000); + WmGetPosFromPcEntity(0x1F800000); *(s16*)0x1F80001C = 0; *(s16*)0x1F80001A = 0; *(s16*)0x1F800018 = 0; @@ -3068,7 +3068,7 @@ void ToggleAmbientSound(s32 arg0) { SystemAkaoExecute(); } -void InitStreamState(void) { +void WmInitModelVariablesAndArray(void) { s32 i; for (i = 0; i < 0x2B; i++) { @@ -3109,12 +3109,12 @@ void StartStreamRead(void) { if (D_80115A60 != 0) { return; } - AbortRegionLoad(); + WmAbortMapLoading(); D_80115A40 = (u_long*)func_800A86C4(2); - if (TryAcquireLoadSlot(2) != 0) { + if (WmAddMutexPriority(2) != 0) { D_80115A60 = 1; D_80115A50 = 0; - DS_read(D_800C74DC, D_800C74E0, D_80115A40, func_800B6DCC); + SysCdromStartLoadLzs(D_800C74DC, D_800C74E0, D_80115A40, WmPackModelLoadFileCallback); SystemCdromReadChain(); } } @@ -3438,11 +3438,11 @@ void WmDialogSetMessageToShowForId0(u8 arg0) { } } -void OpenWorldWindow(s32 arg0, s16 arg1, s16 arg2) { +void WmDialogSetAskToShowForId0(s32 arg0, s16 arg1, s16 arg2) { if (g_WindowData[0].state == WSTATE_INIT) { D_80116288 = arg1; D_8011628C = arg2; - func_800B90C0(0, arg0, D_80116288, D_8011628C, &D_80116290); + WmDialogSetAskToShow(0, arg0, D_80116288, D_8011628C, &D_80116290); } } @@ -4545,7 +4545,7 @@ static void func_800BBA5C(void) { func_800A6994(&sp10, WmGetModelIdFromActiveEntity() == 3 ? -1 : 1); WmScriptPushToStoreStack(WmGetModelIdFromPcEntity()); if (func_800A929C()) { - func_800A8CE4(); + WmLinkPcToActiveEntity(); PlayMusicTrack(2); return; } @@ -4676,7 +4676,7 @@ void func_800BBD20(s32 arg0) { WmSetActiveEntityAsPcEntity(); func_800AA2E4(2); - func_800A9480(temp_v0); + WmSetActiveEntityDirectionAndRot(temp_v0); PlayMusicTrack(1); func_800A2108(0, 6); if (temp_s1 == 4) diff --git a/src/world/world.h b/src/world/world.h index a04dcb36..0b73db38 100644 --- a/src/world/world.h +++ b/src/world/world.h @@ -138,7 +138,6 @@ typedef struct { } Unk8010AD70; void WmSetRenderBuffers(); -void func_800A0B48(); s32 GetGraphType(void); s32 func_800A19FC(WorldChunkHeader*, SVECTOR*, WorldStoredTriangle*, s16*, s32, s16*, s32); void func_800A31C0(s16); @@ -146,8 +145,6 @@ void func_800A368C(s32); void WmExtractLoopCoordsTopBottomParts(VECTOR*, SVECTOR*, s16*, s16*); void WmLoopCoordsAroundWorld(VECTOR*); void func_800A5AD8(WorldChunkHeader*); -void func_800A6884(VECTOR*, SVECTOR*, s16*, s16*); -void func_800A692C(VECTOR*); void func_800A6994(VECTOR*, s32); void WmCleanEntityStruct(WorldActor*); void WmUnlinkEntityFromAll(WorldActor*); @@ -181,21 +178,14 @@ void WmScriptRunOne(WorldActor*); void func_800AD970(WorldActor*); void WmRemoveMutexPriority(s16); s16 WmGetRotFromVector(s32, s32, s32); -void func_800ABFC0(u16); -void func_800AC3C0(u16); -s32 func_800AC484(u16); -s32 func_800AC700(u16); -void func_800AD63C(WorldActor*); void SaveActorState(WorldActor*); -void func_800ADD4C(s16); -s16 func_800AE180(s32, s32, s32); -s32 func_800B0240(void); +s32 WmFadeIsStopped(void); void UpdateZolomGroundHeight(WorldChunkHeader*); void func_800B271C(s32); void func_800B29CC(void); -void func_800B6AEC(void); -void func_800B6DCC(void); -s32 func_800B90C0(u8, u8, u8, u8, s16*); +void WmPcCharModelLoadFileCallback(void); +void WmPackModelLoadFileCallback(void); +s32 WmDialogSetAskToShow(u8, u8, u8, u8, s16*); void func_800B1C80(WorldChunkHeader*); void ResetEffectState(); void func_800B5C7C(WorldActor*); @@ -208,8 +198,7 @@ s32 func_800B7200(); void WmSetFieldToLoad(s32); void func_800B77A8(s32); s32 WmGetPcCharModelIdFromParty(); -void func_800BBA34(s32); -s32 func_800B79B8(); +void WmScriptSetFirstToStoreStack(s32); static void func_800B7C44(void); s32 func_800B7C7C(); void func_800B7838(); From 7393d39347569e6b28424ee3250a8cb69066773b Mon Sep 17 00:00:00 2001 From: mex <97061690+devcheckra1n@users.noreply.github.com> Date: Mon, 7 Sep 2026 00:16:55 -0400 Subject: [PATCH 11/14] world: recover InitSpritePrims, the skybox and shadow-quad prim setup from parkedfuncs Three of the four functions parkedfuncs had beyond what PR #134 shipped: InitSpritePrims needed plain array indexing over a hand-rolled byte offset, the skybox quad setup needed explicit address bindings for two new CVECTOR globals nothing had referenced before, and the shadow quad setup matched as-is. The fourth, WmLoadTxzFile (parkedfuncs called it ReadFileRetry), was a bad parked claim -- retail branches on useDsRead before calling a specifically-named SysCdromStartLoadLzs, not a function-pointer dispatch between two generic readers -- so it stays INCLUDE_ASM. --- config/sym_ovl_export.us.txt | 2 +- config/symbols.world.txt | 3 ++ src/world/world.c | 72 ++++++++++++++++++++++++++++++++++-- src/world/world.h | 2 + 4 files changed, 75 insertions(+), 4 deletions(-) diff --git a/config/sym_ovl_export.us.txt b/config/sym_ovl_export.us.txt index fa2857fa..2e1a246b 100644 --- a/config/sym_ovl_export.us.txt +++ b/config/sym_ovl_export.us.txt @@ -1925,7 +1925,7 @@ WmResetGame = 0x800a4008; func_800A4080 = 0x800a4080; func_800A40B8 = 0x800a40b8; func_800A40F0 = 0x800a40f0; -func_800A4138 = 0x800a4138; +InitSpritePrims = 0x800a4138; func_800A41E8 = 0x800a41e8; UpdateFadeOverlay = 0x800a4268; func_800A4494 = 0x800a4494; diff --git a/config/symbols.world.txt b/config/symbols.world.txt index 8f31f440..523d744f 100644 --- a/config/symbols.world.txt +++ b/config/symbols.world.txt @@ -18,6 +18,7 @@ UpdateFogRanges = 0x800A31F8; WmSubmarineFloatToPlanet = 0x800A3DFC; WmSubmarineSubmergeUnderwater = 0x800A3E4C; WmResetGame = 0x800A4008; +InitSpritePrims = 0x800A4138; UpdateFadeOverlay = 0x800A4268; WmMain = 0x800A460C; WmInitLoadMapFileStruct = 0x800A4DDC; @@ -208,4 +209,6 @@ WmUpdatePacketForModelPartWithMatrixes = 0x800C4FB4; WmUpdateModelLighting = 0x800C5CD4; WmUpdatePartLighting = 0x800C6104; WmGetModelTotalRenderPacketSize = 0x800C6598; +D_800C6768 = 0x800C6768; +D_800C676C = 0x800C676C; D_8010B434 = 0x8010B434; // size:0x24 diff --git a/src/world/world.c b/src/world/world.c index f75b6be5..a0fb8b7e 100644 --- a/src/world/world.c +++ b/src/world/world.c @@ -335,7 +335,23 @@ s32 func_800A40F0(s16 arg0) { return (s32)D_800BE5F0 + D_800BE5F0[arg0 + 1]; } -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A4138); +void InitSpritePrims(void) { + s32 i; + s32 tpage; + + D_800E56F4 = 0; + i = 0; + do { + setSprt(&D_800C6648[i]); + if (GetGraphType() == 1 || GetGraphType() == 2) { + tpage = 0x29; + } else { + tpage = 0x19; + } + SetDrawMode((DR_MODE*)((i * 0xC) + (s32)D_800E56DC), 0, 0, tpage, NULL); + i++; + } while (i < 2); +} void func_800A41E8(s32 arg0) { switch (arg0) { @@ -2436,7 +2452,30 @@ s16 WmGetRotFromEntityToEntity(VECTOR* arg0, VECTOR* arg1) { return WmGetRotFromVector(arg1->vx - arg0->vx, arg1->vz - arg0->vz, arg1->vx); } -INCLUDE_ASM("asm/us/world/nonmatchings/world", WmCreateSkyboxOverlayRenderBuffers); +void WmCreateSkyboxOverlayRenderBuffers(void) { + CVECTOR* a; + CVECTOR* b; + POLY_G4* p; + s32 i; + + i = 0; + a = &D_800C6768; + b = &D_800C676C; + do { + p = (POLY_G4*)((i * 0x24) + (s32)D_800C6770); + p->r0 = p->r1 = a->r; + p->g0 = p->g1 = a->g; + p->b0 = p->b1 = a->b; + p->r2 = p->r3 = b->r; + p->g2 = p->g3 = b->g; + p->b2 = p->b3 = b->b; + setlen(p, 8); + setcode(p, 0x38); + SetDrawMode((DR_MODE*)((i * 0xC) + (s32)D_8010B068), 0, 1, 0, NULL); + i++; + } while (i < 2); + D_8010B080 = 0; +} void* WmGetSkyboxOverlayCurrRenderBuffer(void) { return (WmGetCurrRenderBufferId() * 0x24) + &D_800C6770; } @@ -2985,7 +3024,34 @@ void func_800B57C0(s32 arg0) { D_8010D9BA[arg0 * 4] = 0; } INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B57DC); -INCLUDE_ASM("asm/us/world/nonmatchings/world", WmCreateShadowPacket); +void WmCreateShadowPacket(u8* prims, RECT* rect) { + POLY_FT4* p; + s32 i; + s32 tpage; + + if (prims != NULL && rect != NULL) { + i = 0; + p = (POLY_FT4*)prims; + do { + setlen(p, 9); + setcode(p, 0x2E); + p->r0 = p->g0 = p->b0 = 0x20; + p->clut = 0x7CC4; + if (GetGraphType() == 1 || GetGraphType() == 2) { + tpage = 0x129; + } else { + tpage = 0x59; + } + p->tpage = tpage; + p->u0 = p->u2 = rect->x; + p->v0 = p->v1 = rect->y; + p->u1 = p->u3 = rect->x + rect->w; + p->v2 = p->v3 = rect->y + rect->h; + p++; + i++; + } while (i < 2); + } +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B59F4); diff --git a/src/world/world.h b/src/world/world.h index 0b73db38..df3d6129 100644 --- a/src/world/world.h +++ b/src/world/world.h @@ -216,6 +216,8 @@ extern s32 D_800BE1E8[1]; // TODO: size unknown extern s32 D_800C65EC; extern s32 D_800C6628; extern s32 D_800C6638; +extern CVECTOR D_800C6768; +extern CVECTOR D_800C676C; extern u8 D_800C6770[1]; // TODO: size unknown extern s16 D_800C68EE; extern s16 D_800C6902; From a248107d364d0b3abd3366eac306e964b7fbeab7 Mon Sep 17 00:00:00 2001 From: mex <97061690+devcheckra1n@users.noreply.github.com> Date: Mon, 7 Sep 2026 10:12:28 -0400 Subject: [PATCH 12/14] world: apply review feedback on loop shape, range check and casts InitSpritePrims and the walk-to-tail loops become plain for/while, the tpage vsync window check drops the unsigned-subtract trick for a readable range, and func_800AA640 drops a redundant cast. Kept the (s16) cast on ExpireChunks' age compare; removing it (as asked, with a question mark) breaks the match, verified by rebuild. --- src/world/world.c | 116 ++++++++++++++++++++-------------------------- 1 file changed, 50 insertions(+), 66 deletions(-) diff --git a/src/world/world.c b/src/world/world.c index a0fb8b7e..fd8ae9a8 100644 --- a/src/world/world.c +++ b/src/world/world.c @@ -340,8 +340,7 @@ void InitSpritePrims(void) { s32 tpage; D_800E56F4 = 0; - i = 0; - do { + for (i = 0; i < 2; i++) { setSprt(&D_800C6648[i]); if (GetGraphType() == 1 || GetGraphType() == 2) { tpage = 0x29; @@ -349,8 +348,7 @@ void InitSpritePrims(void) { tpage = 0x19; } SetDrawMode((DR_MODE*)((i * 0xC) + (s32)D_800E56DC), 0, 0, tpage, NULL); - i++; - } while (i < 2); + } } void func_800A41E8(s32 arg0) { @@ -384,7 +382,7 @@ void UpdateFadeOverlay(void) { D_800C6648[slot].v0 = ((vsync >> 2) & 0x10) - 128; addPrim(D_800BD130, &D_800C6648[slot]); addPrim(D_800BD130, &D_800E56DC[slot]); - if ((u32)((vsync - D_800C84F0) - 4) < 2) { + if ((vsync - D_800C84F0) >= 4 && (vsync - D_800C84F0) <= 5) { D_800E56F4 = 3; } D_800C84F0 = vsync; @@ -480,11 +478,9 @@ WorldListNode* AllocRegionNode(void) { node = D_800E5764; if (node != NULL) { prev = NULL; - if (node->next != NULL) { - do { - prev = node; - node = node->next; - } while (node->next != NULL); + while (node->next != NULL) { + prev = node; + node = node->next; } if (prev != NULL) { prev->next = NULL; @@ -587,14 +583,12 @@ void UpdateRegionLoad(void) { if (D_800E5814 < D_8011650C * 5 && D_800E5820 >= 0) { node = D_800E5768; prev = NULL; - if (node != NULL) { - while (node != NULL) { - if (node == &D_800E5718[D_800E5820]) { - break; - } - prev = node; - node = node->next; + while (node != NULL) { + if (node == &D_800E5718[D_800E5820]) { + break; } + prev = node; + node = node->next; } if (node == NULL) { func_800A0B40(0xB); @@ -660,21 +654,19 @@ WorldListNode* WmGetElementWithBlockIdAndSetItFirst(s16 arg0) { node = D_800E5764; prev = NULL; - if (node != NULL) { - while (node != NULL) { - if (node->unk4 == arg0) { - break; - } - prev = node; - node = node->next; - } - if (node != NULL && prev != NULL) { - next = node->next; - head = D_800E5764; - D_800E5764 = node; - prev->next = next; - node->next = head; + while (node != NULL) { + if (node->unk4 == arg0) { + break; } + prev = node; + node = node->next; + } + if (node != NULL && prev != NULL) { + next = node->next; + head = D_800E5764; + D_800E5764 = node; + prev->next = next; + node->next = head; } return node; } @@ -683,13 +675,11 @@ s32 IsRegionLoading(s16 arg0) { WorldListNode* node; node = D_800E5768; - if (node != NULL) { - while (node != NULL) { - if (node->unk4 == arg0) { - break; - } - node = node->next; + while (node != NULL) { + if (node->unk4 == arg0) { + break; } + node = node->next; } return node != NULL; } @@ -741,24 +731,22 @@ s32 ExpireChunks(void) { nodePrev = NULL; D_80109D38 = chunk; chunk->next = freeChunk; - if (node != NULL) { - while (node != NULL) { - if (node->chunk == chunk) { - break; - } - nodePrev = node; - node = node->next; + while (node != NULL) { + if (node->chunk == chunk) { + break; } - if (node != NULL) { - if (nodePrev != NULL) { - nodePrev->next = node->next; - } else { - D_800E5A2C = node->next; - } - freeNode = D_800E5A30; - D_800E5A30 = node; - node->next = freeNode; + nodePrev = node; + node = node->next; + } + if (node != NULL) { + if (nodePrev != NULL) { + nodePrev->next = node->next; + } else { + D_800E5A2C = node->next; } + freeNode = D_800E5A30; + D_800E5A30 = node; + node->next = freeNode; } if (prev != NULL) { chunk = prev->next; @@ -804,11 +792,9 @@ WorldChunkHeader* AllocChunk(void) { } else if (D_80109D3C != NULL) { chunk = D_80109D3C; prev = NULL; - if (chunk->next != NULL) { - do { - prev = chunk; - chunk = chunk->next; - } while (chunk->next != NULL); + while (chunk->next != NULL) { + prev = chunk; + chunk = chunk->next; } if (prev != NULL) { prev->next = NULL; @@ -950,14 +936,12 @@ void WmAbortMapLoading(void) { prev = NULL; SystemCdromAbortLoading(); node = D_800E5768; - if (node != NULL) { - while (node != NULL) { - if (node == &D_800E5718[D_800E5820]) { - break; - } - prev = node; - node = node->next; + while (node != NULL) { + if (node == &D_800E5718[D_800E5820]) { + break; } + prev = node; + node = node->next; } if (node == NULL) { func_800A0B40(0xD); @@ -1582,7 +1566,7 @@ s32 func_800AA640(void) { temp_v0 = FindCollidingActor(D_8010AD3C); if (temp_v0 != NULL) func_800AA1B8(); - return (s32)temp_v0; + return temp_v0; } WorldActor* func_800AA684(void) { return D_8010AD3C != NULL ? D_8010AD3C->collide : NULL; } From c1ffd83d0aa4f99c828e22fd21e38baa28abc34e Mon Sep 17 00:00:00 2001 From: mex <97061690+devcheckra1n@users.noreply.github.com> Date: Mon, 7 Sep 2026 16:56:30 -0400 Subject: [PATCH 13/14] world: give D_800C6770 its real POLY_G4 type --- src/world/world.c | 4 ++-- src/world/world.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/world/world.c b/src/world/world.c index fd8ae9a8..59fe030d 100644 --- a/src/world/world.c +++ b/src/world/world.c @@ -2446,7 +2446,7 @@ void WmCreateSkyboxOverlayRenderBuffers(void) { a = &D_800C6768; b = &D_800C676C; do { - p = (POLY_G4*)((i * 0x24) + (s32)D_800C6770); + p = &D_800C6770[i]; p->r0 = p->r1 = a->r; p->g0 = p->g1 = a->g; p->b0 = p->b1 = a->b; @@ -2461,7 +2461,7 @@ void WmCreateSkyboxOverlayRenderBuffers(void) { D_8010B080 = 0; } -void* WmGetSkyboxOverlayCurrRenderBuffer(void) { return (WmGetCurrRenderBufferId() * 0x24) + &D_800C6770; } +void* WmGetSkyboxOverlayCurrRenderBuffer(void) { return &D_800C6770[WmGetCurrRenderBufferId()]; } void* WmGetSkyboxOverlayCurrTextureSettingBuffer(void) { return (WmGetCurrRenderBufferId() * 0xC) + D_8010B068; } diff --git a/src/world/world.h b/src/world/world.h index df3d6129..29e4b531 100644 --- a/src/world/world.h +++ b/src/world/world.h @@ -218,7 +218,7 @@ extern s32 D_800C6628; extern s32 D_800C6638; extern CVECTOR D_800C6768; extern CVECTOR D_800C676C; -extern u8 D_800C6770[1]; // TODO: size unknown +extern POLY_G4 D_800C6770[1]; extern s16 D_800C68EE; extern s16 D_800C6902; extern s16 D_800C6916; From 2ebfc7d2f41e84b21476a5a0366ad7d5230f09dd Mon Sep 17 00:00:00 2001 From: mex <97061690+devcheckra1n@users.noreply.github.com> Date: Mon, 7 Sep 2026 17:01:22 -0400 Subject: [PATCH 14/14] world: early returns, drop unnecessary locals, real POLY_FT4 type on WmCreateShadowPacket --- src/world/world.c | 133 +++++++++++++++++++++------------------------- 1 file changed, 62 insertions(+), 71 deletions(-) diff --git a/src/world/world.c b/src/world/world.c index 59fe030d..718c6df7 100644 --- a/src/world/world.c +++ b/src/world/world.c @@ -7,7 +7,7 @@ void WmGetPosFromPcEntity(VECTOR* arg0); void WmRestoreEntityPosAndDirFromSavemap(WorldActor*); s32 func_800ADFC0(void); static s32 func_800B0800(void); -void WmCreateShadowPacket(u8*, RECT*); +void WmCreateShadowPacket(POLY_FT4*, RECT*); static s32 func_800B716C(void); static s32 func_800B7B2C(void); s32 func_800B7B3C(void); @@ -2279,30 +2279,31 @@ void WmRestoreEntityPosAndDirFromSavemap(WorldActor* arg0) { p = (s32*)D_8010AD50; end = (s32*)(D_8010AD50 + 0x30); - if (p < end) { - type = arg0->actorType; - while (p < end) { - if (((*p >> 19) & 0x1F) == type) { - break; - } - p += 2; - } - if (p < (s32*)(D_8010AD50 + 0x30) && arg0 != NULL) { - t = p[0] & 0x7FFFF; - arg0->altPos.vx = t; - arg0->pos.vx = t; - t = p[1] >> 18; - arg0->altPos.vy = t; - arg0->pos.vy = t; - t = p[1] & 0x3FFFF; - arg0->altPos.vz = t; - arg0->pos.vz = t; - f = (p[0] >> 20) & 0xFF0; - arg0->unk3E = 0; - arg0->direction = f; - arg0->unk3C = f; - arg0->facing = f; + if (p >= end) { + return; + } + type = arg0->actorType; + while (p < end) { + if (((*p >> 19) & 0x1F) == type) { + break; } + p += 2; + } + if (p < (s32*)(D_8010AD50 + 0x30) && arg0 != NULL) { + t = p[0] & 0x7FFFF; + arg0->altPos.vx = t; + arg0->pos.vx = t; + t = p[1] >> 18; + arg0->altPos.vy = t; + arg0->pos.vy = t; + t = p[1] & 0x3FFFF; + arg0->altPos.vz = t; + arg0->pos.vz = t; + f = (p[0] >> 20) & 0xFF0; + arg0->unk3E = 0; + arg0->direction = f; + arg0->unk3C = f; + arg0->facing = f; } } @@ -2495,9 +2496,6 @@ void func_800AF0B0(void) { void WmSetGteColourSettings(void) { MATRIX* m; s32 mode; - s32 r; - s32 g; - s32 b; mode = 2; if (WmGetWmId() == mode) { @@ -2507,15 +2505,10 @@ void WmSetGteColourSettings(void) { } SetLightMatrix(m); if (WmGetWmId() == mode) { - r = 0x20; - g = 0x20; - b = 0x30; + SetBackColor(0x20, 0x20, 0x30); } else { - r = 0x40; - g = 0x40; - b = 0x40; + SetBackColor(0x40, 0x40, 0x40); } - SetBackColor(r, g, b); SetColorMatrix(&D_800C6848); SetFarColor(0, 0, 0); } @@ -2785,28 +2778,29 @@ void SetCurrentTriangle(WorldChunkHeader* arg0, WorldTriangle* arg1) { s32 inside; s32 zoff; - if (D_8010CA8C == 0 || D_8010CA8C == 2 || D_8010CA8C == 3) { - D_8010CA1C = &D_8010C83C; - D_8010C83C.chunk = arg0; - D_8010C83C.tri = arg1; - D_8010C83C.unk8 = 0; - D_8010CA20 = 0; - D_8010CA78 = 0; - D_8010CA74 = D_8010CA24; - RegisterChunk(arg0); - if (arg1 != NULL) { - *((u8*)&arg1->textureAndLocationAndFlags + 1) |= 0x40; - } - D_800BD144 = 0; - D_8010CA8C = 1; - WmGetPosFromPcEntity(&pos); - inside = 0; - if (pos.vx >= 0x36000 && pos.vx <= 0x3FFFF) { - zoff = pos.vz - 0x1C000; - inside = (u32)zoff <= 0x9FFF; - } - D_8010CAF8 = inside; + if (D_8010CA8C != 0 && D_8010CA8C != 2 && D_8010CA8C != 3) { + return; + } + D_8010CA1C = &D_8010C83C; + D_8010C83C.chunk = arg0; + D_8010C83C.tri = arg1; + D_8010C83C.unk8 = 0; + D_8010CA20 = 0; + D_8010CA78 = 0; + D_8010CA74 = D_8010CA24; + RegisterChunk(arg0); + if (arg1 != NULL) { + *((u8*)&arg1->textureAndLocationAndFlags + 1) |= 0x40; + } + D_800BD144 = 0; + D_8010CA8C = 1; + WmGetPosFromPcEntity(&pos); + inside = 0; + if (pos.vx >= 0x36000 && pos.vx <= 0x3FFFF) { + zoff = pos.vz - 0x1C000; + inside = (u32)zoff <= 0x9FFF; } + D_8010CAF8 = inside; } static void func_800B22E4(void) { func_800B190C(); } @@ -3008,30 +3002,28 @@ void func_800B57C0(s32 arg0) { D_8010D9BA[arg0 * 4] = 0; } INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B57DC); -void WmCreateShadowPacket(u8* prims, RECT* rect) { - POLY_FT4* p; +void WmCreateShadowPacket(POLY_FT4* prims, RECT* rect) { s32 i; s32 tpage; if (prims != NULL && rect != NULL) { i = 0; - p = (POLY_FT4*)prims; do { - setlen(p, 9); - setcode(p, 0x2E); - p->r0 = p->g0 = p->b0 = 0x20; - p->clut = 0x7CC4; + setlen(prims, 9); + setcode(prims, 0x2E); + prims->r0 = prims->g0 = prims->b0 = 0x20; + prims->clut = 0x7CC4; if (GetGraphType() == 1 || GetGraphType() == 2) { tpage = 0x129; } else { tpage = 0x59; } - p->tpage = tpage; - p->u0 = p->u2 = rect->x; - p->v0 = p->v1 = rect->y; - p->u1 = p->u3 = rect->x + rect->w; - p->v2 = p->v3 = rect->y + rect->h; - p++; + prims->tpage = tpage; + prims->u0 = prims->u2 = rect->x; + prims->v0 = prims->v1 = rect->y; + prims->u1 = prims->u3 = rect->x + rect->w; + prims->v2 = prims->v3 = rect->y + rect->h; + prims++; i++; } while (i < 2); } @@ -3106,16 +3098,15 @@ void ToggleAmbientSound(s32 arg0) { D_8010CB20 = arg0; D_8009A004[0] = 0x40; D_8009A008[0] = arg0; + SystemAkaoExecute(); } else if (arg0 == -D_8010CB20) { D_8010CB20 = 0; D_8009A000[0] = 0xF1; SystemAkaoExecute(); D_8009A000[0] = 0xBC; D_8009A004[0] = 0; - } else { - return; + SystemAkaoExecute(); } - SystemAkaoExecute(); } void WmInitModelVariablesAndArray(void) {