decomp more of the ground select funcs

This commit is contained in:
Seth Barberee
2025-05-03 18:37:50 -07:00
parent 0323e1f24a
commit 495a95e81b
7 changed files with 206 additions and 372 deletions

View File

@@ -5,121 +5,6 @@
.text
thumb_func_start GroundEffect_Select
GroundEffect_Select:
push {r4-r7,lr}
sub sp, 0x4
adds r4, r0, 0
lsls r4, 16
asrs r4, 16
lsls r1, 16
asrs r7, r1, 16
lsls r2, 24
asrs r6, r2, 24
ldr r1, _080ACC90
adds r0, r4, 0
bl GetGroundScript
adds r5, r0, 0
ldr r1, _080ACC94
str r6, [sp]
movs r0, 0
adds r2, r4, 0
adds r3, r7, 0
bl Log
lsls r1, r7, 3
ldr r0, [r5, 0x4]
adds r0, r1
lsls r1, r6, 2
adds r1, r6
lsls r1, 3
ldr r0, [r0, 0x4]
adds r0, r1
ldr r5, [r0, 0x14]
ldr r0, [r0, 0x10]
cmp r0, 0
ble _080ACC86
adds r4, r0, 0
_080ACC70:
movs r0, 0x1
negs r0, r0
adds r1, r5, 0
adds r2, r7, 0
adds r3, r6, 0
bl GroundEffect_Add
subs r4, 0x1
adds r5, 0xC
cmp r4, 0
bne _080ACC70
_080ACC86:
add sp, 0x4
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_080ACC90: .4byte gUnknown_8118610
_080ACC94: .4byte gUnknown_811861C
thumb_func_end GroundEffect_Select
thumb_func_start GroundEffect_Cancel
GroundEffect_Cancel:
push {r4-r7,lr}
mov r7, r8
push {r7}
lsls r0, 16
asrs r7, r0, 16
lsls r1, 24
asrs r5, r1, 24
ldr r1, _080ACD00
movs r0, 0
adds r2, r7, 0
bl Log
movs r1, 0
ldr r0, _080ACD04
ldr r4, [r0]
movs r0, 0x1
negs r0, r0
mov r8, r0
movs r6, 0x80
lsls r6, 9
_080ACCC0:
movs r2, 0x6
ldrsh r0, [r4, r2]
cmp r0, r8
beq _080ACCE2
movs r2, 0x8
ldrsh r0, [r4, r2]
cmp r0, r7
bne _080ACCE2
cmp r5, 0
blt _080ACCDC
movs r0, 0xA
ldrsb r0, [r4, r0]
cmp r0, r5
bne _080ACCE2
_080ACCDC:
adds r0, r1, 0
bl GroundEffect_Delete
_080ACCE2:
adds r0, r6, 0
movs r1, 0x80
lsls r1, 9
adds r6, r1
asrs r1, r0, 16
movs r2, 0xE2
lsls r2, 1
adds r4, r2
cmp r1, 0xF
ble _080ACCC0
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_080ACD00: .4byte gUnknown_8118640
_080ACD04: .4byte gGroundEffects
thumb_func_end GroundEffect_Cancel
thumb_func_start GroundEffect_CancelBlank
GroundEffect_CancelBlank:
push {r4-r7,lr}

View File

@@ -5,120 +5,6 @@
.text
thumb_func_start GroundEvent_Select
GroundEvent_Select:
push {r4-r7,lr}
sub sp, 0x4
adds r4, r0, 0
lsls r4, 16
asrs r4, 16
lsls r1, 16
asrs r7, r1, 16
lsls r2, 24
asrs r6, r2, 24
ldr r1, _080ADA88
adds r0, r4, 0
bl GetGroundScript
adds r5, r0, 0
ldr r1, _080ADA8C
str r6, [sp]
movs r0, 0
adds r2, r4, 0
adds r3, r7, 0
bl Log
lsls r1, r7, 3
ldr r0, [r5, 0x4]
adds r0, r1
lsls r1, r6, 2
adds r1, r6
lsls r1, 3
ldr r0, [r0, 0x4]
adds r0, r1
ldr r5, [r0, 0x1C]
ldr r0, [r0, 0x18]
cmp r0, 0
ble _080ADA7E
adds r4, r0, 0
_080ADA68:
movs r0, 0x1
negs r0, r0
adds r1, r5, 0
adds r2, r7, 0
adds r3, r6, 0
bl GroundEvent_Add
subs r4, 0x1
adds r5, 0xC
cmp r4, 0
bne _080ADA68
_080ADA7E:
add sp, 0x4
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_080ADA88: .4byte gUnknown_81187DC
_080ADA8C: .4byte gGroundEventSelectText
thumb_func_end GroundEvent_Select
thumb_func_start GroundEvent_Cancel
GroundEvent_Cancel:
push {r4-r7,lr}
mov r7, r8
push {r7}
lsls r0, 16
asrs r7, r0, 16
lsls r1, 24
asrs r5, r1, 24
ldr r1, _080ADAF8
movs r0, 0
adds r2, r7, 0
adds r3, r5, 0
bl Log
movs r1, 0
ldr r0, _080ADAFC
ldr r4, [r0]
movs r0, 0x1
negs r0, r0
mov r8, r0
movs r6, 0x80
lsls r6, 9
_080ADABA:
movs r2, 0x2
ldrsh r0, [r4, r2]
cmp r0, r8
beq _080ADADC
movs r2, 0x4
ldrsh r0, [r4, r2]
cmp r0, r7
bne _080ADADC
cmp r5, 0
blt _080ADAD6
movs r0, 0x6
ldrsb r0, [r4, r0]
cmp r0, r5
bne _080ADADC
_080ADAD6:
adds r0, r1, 0
bl GroundEvent_Delete
_080ADADC:
adds r0, r6, 0
movs r1, 0x80
lsls r1, 9
adds r6, r1
asrs r1, r0, 16
adds r4, 0x20
cmp r1, 0x1F
ble _080ADABA
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_080ADAF8: .4byte gGroundEventCancelText
_080ADAFC: .4byte gGroundEvents
thumb_func_end GroundEvent_Cancel
thumb_func_start GroundEvent_Add
GroundEvent_Add:
push {r4-r7,lr}

View File

@@ -5,122 +5,6 @@
.text
thumb_func_start GroundLives_Select
GroundLives_Select:
push {r4-r7,lr}
sub sp, 0x4
adds r4, r0, 0
lsls r4, 16
asrs r4, 16
lsls r1, 16
asrs r7, r1, 16
lsls r2, 24
asrs r6, r2, 24
ldr r1, _080A7980
adds r0, r4, 0
bl GetGroundScript
adds r5, r0, 0
ldr r1, _080A7984
str r6, [sp]
movs r0, 0
adds r2, r4, 0
adds r3, r7, 0
bl Log
lsls r1, r7, 3
ldr r0, [r5, 0x4]
adds r0, r1
lsls r1, r6, 2
adds r1, r6
lsls r1, 3
ldr r0, [r0, 0x4]
adds r0, r1
ldr r5, [r0, 0x4]
ldr r0, [r0]
cmp r0, 0
ble _080A7976
adds r4, r0, 0
_080A7960:
movs r0, 0x1
negs r0, r0
adds r1, r5, 0
adds r2, r7, 0
adds r3, r6, 0
bl GroundLives_Add
subs r4, 0x1
adds r5, 0x18
cmp r4, 0
bne _080A7960
_080A7976:
add sp, 0x4
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_080A7980: .4byte gUnknown_811808C
_080A7984: .4byte gUnknown_8118098
thumb_func_end GroundLives_Select
thumb_func_start GroundLives_Cancel
GroundLives_Cancel:
push {r4-r7,lr}
mov r7, r8
push {r7}
lsls r0, 16
asrs r7, r0, 16
lsls r1, 24
asrs r5, r1, 24
ldr r1, _080A79F4
movs r0, 0
adds r2, r7, 0
adds r3, r5, 0
bl Log
movs r1, 0
ldr r0, _080A79F8
ldr r4, [r0]
movs r0, 0x1
negs r0, r0
mov r8, r0
movs r6, 0x80
lsls r6, 9
_080A79B2:
movs r2, 0x2
ldrsh r0, [r4, r2]
cmp r0, r8
beq _080A79D4
movs r2, 0x4
ldrsh r0, [r4, r2]
cmp r0, r7
bne _080A79D4
cmp r5, 0
blt _080A79CE
movs r0, 0x6
ldrsb r0, [r4, r0]
cmp r0, r5
bne _080A79D4
_080A79CE:
adds r0, r1, 0
bl GroundLives_Delete
_080A79D4:
adds r0, r6, 0
movs r1, 0x80
lsls r1, 9
adds r6, r1
asrs r1, r0, 16
movs r2, 0xF8
lsls r2, 1
adds r4, r2
cmp r1, 0x17
ble _080A79B2
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_080A79F4: .4byte gUnknown_81180BC
_080A79F8: .4byte gGroundLives
thumb_func_end GroundLives_Cancel
thumb_func_start GroundLives_CancelBlank_1
GroundLives_CancelBlank_1:
push {r4-r7,lr}

View File

@@ -1,24 +1,33 @@
#include "global.h"
#include "ground_script.h"
#include "debug.h"
#include "memory.h"
void DeleteGroundEffects(void);
// size must be 0x1c4
struct unkStruct_3001B8C {
typedef struct GroundEffect {
u8 fill0[6];
s16 unk6;
u8 fill8[0x1c4 - 8];
};
s16 unk8;
s8 unkA;
u8 fillB[0x1c4 - 0xB];
} GroundEffect;
IWRAM_INIT struct unkStruct_3001B8C* gGroundEffects = NULL; // size 16 array
IWRAM_INIT GroundEffect* gGroundEffects = NULL; // size 16 array
void GroundEffect_Delete(s32);
const struct GroundScriptHeader *GetGroundScript(s16 a0, DebugLocation *);
extern DebugLocation gUnknown_8118610;
extern u8 gUnknown_811861C[];
extern u8 gUnknown_8118640[];
s16 GroundEffect_Add(s32 id, const GroundEffectData*, s32 group, s32 sector);
void AllocGroundEffects()
{
s32 index;
struct unkStruct_3001B8C* current;
GroundEffect* current;
gGroundEffects = MemoryAlloc(16 * sizeof(struct unkStruct_3001B8C), 6);
gGroundEffects = MemoryAlloc(16 * sizeof(GroundEffect), 6);
current = gGroundEffects;
for (index = 0; index < 16; index = (s16) (index + 0x1), current++) {
current->unk6 = -1;
@@ -30,7 +39,7 @@ void AllocGroundEffects()
void DeleteGroundEffects(void)
{
s32 index;
struct unkStruct_3001B8C* current;
GroundEffect* current;
current = gGroundEffects;
for (index = 0; index < 16; index = (s16) (index + 0x1), current++) {
@@ -45,3 +54,57 @@ void FreeGroundEffects(void)
MemoryFree(gGroundEffects);
gGroundEffects = NULL;
}
void GroundEffect_Select(s32 scriptID, s32 group, s32 sector)
{
const struct GroundScriptHeader *scriptPtr;
const struct GroundScriptSector *sectorPtr;
const struct GroundScriptGroup *groupPtr;
s32 i;
s32 size;
const GroundEffectData *effectData;
s32 sector_s32;
s32 group_s32;
s32 scriptID_s32;
scriptID_s32 = (s16)scriptID;
group_s32 = (s16)group;
sector_s32 = (s8)sector;
scriptPtr = GetGroundScript(scriptID_s32, &gUnknown_8118610);
Log('\0',gUnknown_811861C, scriptID_s32, group_s32, sector_s32);
groupPtr = &scriptPtr->groups[group_s32];
sectorPtr = &groupPtr->sectors[sector_s32];
effectData = sectorPtr->effects;
size = sectorPtr->nEffects;
for (i = 0; i < size; i++, effectData++)
{
GroundEffect_Add(-1,effectData,group_s32,sector_s32);
}
}
void GroundEffect_Cancel(s32 scriptID, s32 sector)
{
s32 index;
GroundEffect *ptr;
s32 sector_s32;
s32 scriptID_s32;
scriptID_s32 = (s16)scriptID;
sector_s32 = (s8) sector;
Log('\0',gUnknown_8118640, scriptID_s32);
index = 0;
ptr = &gGroundEffects[0];
for(; index < 0x10; index = (s16)(index + 1), ptr++)
{
if((ptr->unk6 != -1) && (ptr->unk8 == scriptID_s32))
if(sector_s32 < 0 || ptr->unkA == sector_s32)
GroundEffect_Delete(index);
}
}

View File

@@ -1,30 +1,33 @@
#include "global.h"
#include "ground_script.h"
#include "debug.h"
#include "memory.h"
struct GroundEvent_sub
typedef struct GroundEvent
{
s16 unk0;
s16 unk2;
u8 unk4[0x20 - 0x4];
};
s16 unk4; // scriptID
s8 unk6; // sector
u8 unk7[0x20 - 0x7];
} GroundEvent;
struct GroundEvents
{
// size: 0x400
struct GroundEvent_sub arr[0x20];
};
IWRAM_INIT struct GroundEvents *gGroundEvents = NULL;
IWRAM_INIT GroundEvent *gGroundEvents = NULL;
void DeleteGroundEvents(void);
void GroundEvent_Delete(s32);
const struct GroundScriptHeader *GetGroundScript(s16 a0, DebugLocation *);
s16 GroundEvent_Add(s32 id, const GroundEventData*, s32 group, s32 sector);
extern DebugLocation gUnknown_81187DC;
extern u8 gGroundEventSelectText[];
extern u8 gGroundEventCancelText[];
void AllocGroundEvents(void) {
s32 ind;
struct GroundEvent_sub *ptr;
gGroundEvents = MemoryAlloc(sizeof(struct GroundEvents), 0x6);
GroundEvent *ptr;
gGroundEvents = MemoryAlloc(sizeof(GroundEvent) * 0x20, 0x6);
for(ind = 0, ptr = &gGroundEvents->arr[ind]; ind < 0x20; ind = (s16)(ind + 1), ptr++)
for(ind = 0, ptr = &gGroundEvents[ind]; ind < 0x20; ind = (s16)(ind + 1), ptr++)
{
ptr->unk2 |= -1;
}
@@ -33,9 +36,9 @@ void AllocGroundEvents(void) {
void DeleteGroundEvents(void) {
s32 v1;
struct GroundEvent_sub* current;
GroundEvent* current;
current = &gGroundEvents->arr[0];
current = &gGroundEvents[0];
for (v1 = 0; v1 < 0x20; v1 = (s16) (v1 + 0x1), current++) {
if(current->unk2 != -1)
GroundEvent_Delete(v1);
@@ -49,3 +52,56 @@ void FreeGroundEvents(void)
gGroundEvents = NULL;
}
void GroundEvent_Select(s32 scriptID, s32 group, s32 sector)
{
const struct GroundScriptHeader *scriptPtr;
const struct GroundScriptSector *sectorPtr;
const struct GroundScriptGroup *groupPtr;
s32 i;
s32 size;
const GroundEventData *eventData;
s32 sector_s32;
s32 group_s32;
s32 scriptID_s32;
scriptID_s32 = (s16)scriptID;
group_s32 = (s16)group;
sector_s32 = (s8)sector;
scriptPtr = GetGroundScript(scriptID_s32, &gUnknown_81187DC);
Log('\0',gGroundEventSelectText, scriptID_s32, group_s32, sector_s32);
groupPtr = &scriptPtr->groups[group_s32];
sectorPtr = &groupPtr->sectors[sector_s32];
eventData = sectorPtr->events;
size = sectorPtr->nEvents;
for (i = 0; i < size; i++, eventData++)
{
GroundEvent_Add(-1,eventData,group_s32,sector_s32);
}
}
void GroundEvent_Cancel(s32 scriptID, s32 sector)
{
s32 index;
GroundEvent *ptr;
s32 sector_s32;
s32 scriptID_s32;
scriptID_s32 = (s16)scriptID;
sector_s32 = (s8) sector;
Log('\0',gGroundEventCancelText, scriptID_s32, sector_s32);
index = 0;
ptr = &gGroundEvents[0];
for(; index < 0x20; index = (s16)(index + 1), ptr++)
{
if((ptr->unk2 != -1) && (ptr->unk4 == scriptID_s32))
if(sector_s32 < 0 || ptr->unk6 == sector_s32)
GroundEvent_Delete(index);
}
}

View File

@@ -26,7 +26,9 @@ struct unkStruct_3001B84_sub
// size: 0x1F0
u16 unk0;
s16 unk2;
u8 unk4[0x1F0 - 0x4];
s16 unk4;
s8 unk6;
u8 unk8[0x1F0 - 0x8];
};
struct unkStruct_3001B84
@@ -38,6 +40,11 @@ IWRAM_INIT struct unkStruct_3001B84 *gGroundLives = NULL;
extern void DeleteGroundLives(void);
void GroundLives_Delete(s32);
s16 GroundLives_Add(s32 id, const GroundLivesData*, s32 group, s32 sector);
const struct GroundScriptHeader *GetGroundScript(s16 a0, DebugLocation *);
extern DebugLocation gUnknown_811808C;
extern u8 gUnknown_8118098[];
extern u8 gUnknown_81180BC[];
void AllocGroundLives(void)
{
@@ -102,3 +109,56 @@ void FreeGroundLives(void)
MemoryFree(gGroundLivesMeta);
gGroundLivesMeta = NULL;
}
void GroundLives_Select(s32 scriptID, s32 group, s32 sector)
{
const struct GroundScriptHeader *scriptPtr;
const struct GroundScriptSector *sectorPtr;
const struct GroundScriptGroup *groupPtr;
s32 i;
s32 size;
const GroundLivesData *livesData;
s32 sector_s32;
s32 group_s32;
s32 scriptID_s32;
scriptID_s32 = (s16)scriptID;
group_s32 = (s16)group;
sector_s32 = (s8)sector;
scriptPtr = GetGroundScript(scriptID_s32, &gUnknown_811808C);
Log('\0',gUnknown_8118098, scriptID_s32, group_s32, sector_s32);
groupPtr = &scriptPtr->groups[group_s32];
sectorPtr = &groupPtr->sectors[sector_s32];
livesData = sectorPtr->lives;
size = sectorPtr->nLives;
for (i = 0; i < size; i++, livesData++)
{
GroundLives_Add(-1,livesData,group_s32,sector_s32);
}
}
void GroundLives_Cancel(s32 scriptID, s32 sector)
{
s32 index;
struct unkStruct_3001B84_sub *ptr;
s32 sector_s32;
s32 scriptID_s32;
scriptID_s32 = (s16)scriptID;
sector_s32 = (s8) sector;
Log('\0',gUnknown_81180BC, scriptID_s32, sector_s32);
index = 0;
ptr = &gGroundLives->array[0];
for(; index < 0x18; index = (s16)(index + 1), ptr++)
{
if((ptr->unk2 != -1) && (ptr->unk4 == scriptID_s32))
if(sector_s32 < 0 || ptr->unk6 == sector_s32)
GroundLives_Delete(index);
}
}

View File

@@ -47,10 +47,10 @@ void GroundMap_GetStationScript(ScriptInfoSmall *out, s16, s32, s32);
void GroundLives_ExecuteScript(s32, s16 *, ScriptInfoSmall *);
void GroundObject_ExecuteScript(s32, s16 *, ScriptInfoSmall *);
void GroundEffect_ExecuteScript(s32, s16 *, ScriptInfoSmall *);
void GroundLives_Select(s16, s32 group, s32 sector);
void GroundObject_Select(s16, s32 group, s32 sector);
void GroundEffect_Select(s16, s32 group, s32 sector);
void GroundEvent_Select(s16, s32 group, s32 sector);
void GroundLives_Select(s32, s32 group, s32 sector);
void GroundObject_Select(s32, s32 group, s32 sector);
void GroundEffect_Select(s32, s32 group, s32 sector);
void GroundEvent_Select(s32, s32 group, s32 sector);
void GroundLives_Cancel(s32 group, s32 sector);
void GroundObject_Cancel(s32 group, s32 sector);
void GroundEffect_Cancel(s32 group, s32 sector);