more work on ground files

This commit is contained in:
Seth Barberee
2025-04-20 21:34:07 -07:00
parent 1517266c9d
commit 5558a5fc38
4 changed files with 147 additions and 239 deletions

View File

@@ -5,93 +5,6 @@
.text
thumb_func_start AllocGroundEffects
AllocGroundEffects:
push {r4,r5,lr}
ldr r4, _080ACBCC
movs r0, 0xE2
lsls r0, 5
movs r1, 0x6
bl MemoryAlloc
str r0, [r4]
adds r1, r0, 0
ldr r0, _080ACBD0
adds r5, r0, 0
movs r4, 0xE2
lsls r4, 1
movs r2, 0x80
lsls r2, 9
adds r3, r2, 0
_080ACBB0:
ldrh r0, [r1, 0x6]
orrs r0, r5
strh r0, [r1, 0x6]
adds r0, r2, 0
adds r2, r3
asrs r0, 16
adds r1, r4
cmp r0, 0xF
ble _080ACBB0
bl DeleteGroundEffects
pop {r4,r5}
pop {r0}
bx r0
.align 2, 0
_080ACBCC: .4byte gGroundEffects
_080ACBD0: .4byte 0x0000ffff
thumb_func_end AllocGroundEffects
thumb_func_start DeleteGroundEffects
DeleteGroundEffects:
push {r4-r6,lr}
ldr r0, _080ACC0C
ldr r4, [r0]
movs r1, 0
movs r6, 0x1
negs r6, r6
movs r5, 0x80
lsls r5, 9
_080ACBE4:
movs r2, 0x6
ldrsh r0, [r4, r2]
cmp r0, r6
beq _080ACBF2
adds r0, r1, 0
bl GroundEffect_Delete
_080ACBF2:
adds r0, r5, 0
movs r1, 0x80
lsls r1, 9
adds r5, r1
asrs r1, r0, 16
movs r2, 0xE2
lsls r2, 1
adds r4, r2
cmp r1, 0xF
ble _080ACBE4
pop {r4-r6}
pop {r0}
bx r0
.align 2, 0
_080ACC0C: .4byte gGroundEffects
thumb_func_end DeleteGroundEffects
thumb_func_start FreeGroundEffects
FreeGroundEffects:
push {r4,lr}
bl DeleteGroundEffects
ldr r4, _080ACC28
ldr r0, [r4]
bl MemoryFree
movs r0, 0
str r0, [r4]
pop {r4}
pop {r0}
bx r0
.align 2, 0
_080ACC28: .4byte gGroundEffects
thumb_func_end FreeGroundEffects
thumb_func_start GroundEffect_Select
GroundEffect_Select:
push {r4-r7,lr}

View File

@@ -5,155 +5,6 @@
.text
thumb_func_start AllocGroundLives
AllocGroundLives:
push {r4,r5,lr}
ldr r4, _080A7860
movs r0, 0xCE
lsls r0, 2
movs r1, 0x6
bl MemoryAlloc
str r0, [r4]
ldr r4, _080A7864
movs r0, 0xBA
lsls r0, 6
movs r1, 0x6
bl MemoryAlloc
str r0, [r4]
adds r1, r0, 0
ldr r0, _080A7868
adds r5, r0, 0
movs r4, 0xF8
lsls r4, 1
movs r2, 0x80
lsls r2, 9
adds r3, r2, 0
_080A7826:
ldrh r0, [r1, 0x2]
orrs r0, r5
strh r0, [r1, 0x2]
adds r0, r2, 0
adds r2, r3
asrs r0, 16
adds r1, r4
cmp r0, 0x17
ble _080A7826
ldr r4, _080A7860
ldr r1, [r4]
movs r0, 0xCB
lsls r0, 2
adds r1, r0
movs r0, 0
movs r2, 0x19
bl GetFunctionScript
ldr r0, [r4]
movs r1, 0xCC
lsls r1, 2
adds r0, r1
movs r1, 0x1
strh r1, [r0]
bl DeleteGroundLives
pop {r4,r5}
pop {r0}
bx r0
.align 2, 0
_080A7860: .4byte gGroundLivesMeta
_080A7864: .4byte gGroundLives
_080A7868: .4byte 0x0000ffff
thumb_func_end AllocGroundLives
thumb_func_start DeleteGroundLives
DeleteGroundLives:
push {r4-r6,lr}
ldr r0, _080A78E8
ldr r4, [r0]
movs r1, 0
movs r6, 0x1
negs r6, r6
movs r5, 0x80
lsls r5, 9
_080A787C:
movs r2, 0x2
ldrsh r0, [r4, r2]
cmp r0, r6
beq _080A788A
adds r0, r1, 0
bl GroundLives_Delete
_080A788A:
adds r0, r5, 0
movs r1, 0x80
lsls r1, 9
adds r5, r1
asrs r1, r0, 16
movs r2, 0xF8
lsls r2, 1
adds r4, r2
cmp r1, 0x17
ble _080A787C
ldr r3, _080A78EC
ldr r0, [r3]
movs r2, 0x1
negs r2, r2
str r2, [r0, 0x24]
adds r0, 0x28
movs r1, 0xFF
strb r1, [r0]
movs r5, 0
movs r4, 0
movs r1, 0x2
_080A78B4:
ldr r0, [r3]
adds r0, r4
str r2, [r0, 0x8]
str r5, [r0]
str r5, [r0, 0x4]
adds r4, 0xC
subs r1, 0x1
cmp r1, 0
bge _080A78B4
ldr r4, _080A78EC
movs r2, 0
movs r3, 0x2C
movs r1, 0x3F
_080A78CE:
ldr r0, [r4]
adds r0, r3
str r2, [r0]
str r2, [r0, 0x4]
str r2, [r0, 0x8]
adds r3, 0xC
subs r1, 0x1
cmp r1, 0
bge _080A78CE
pop {r4-r6}
pop {r0}
bx r0
.align 2, 0
_080A78E8: .4byte gGroundLives
_080A78EC: .4byte gGroundLivesMeta
thumb_func_end DeleteGroundLives
thumb_func_start FreeGroundLives
FreeGroundLives:
push {r4,r5,lr}
bl DeleteGroundLives
ldr r4, _080A7914
ldr r0, [r4]
bl MemoryFree
movs r5, 0
str r5, [r4]
ldr r4, _080A7918
ldr r0, [r4]
bl MemoryFree
str r5, [r4]
pop {r4,r5}
pop {r0}
bx r0
.align 2, 0
_080A7914: .4byte gGroundLives
_080A7918: .4byte gGroundLivesMeta
thumb_func_end FreeGroundLives
thumb_func_start GroundLives_Select
GroundLives_Select:
push {r4-r7,lr}

View File

@@ -1,3 +1,47 @@
#include "global.h"
#include "memory.h"
IWRAM_INIT void *gGroundEffects = NULL;
void DeleteGroundEffects(void);
// size must be 0x1c4
struct unkStruct_3001B8C {
u8 fill0[6];
s16 unk6;
u8 fill8[0x1c4 - 8];
};
IWRAM_INIT struct unkStruct_3001B8C* gGroundEffects = NULL; // size 16 array
void GroundEffect_Delete(s32);
void AllocGroundEffects()
{
s32 index;
struct unkStruct_3001B8C* current;
gGroundEffects = MemoryAlloc(16 * sizeof(struct unkStruct_3001B8C), 6);
current = gGroundEffects;
for (index = 0; index < 16; index = (s16) (index + 0x1), current++) {
current->unk6 = -1;
}
DeleteGroundEffects();
}
void DeleteGroundEffects(void)
{
s32 index;
struct unkStruct_3001B8C* current;
current = gGroundEffects;
for (index = 0; index < 16; index = (s16) (index + 0x1), current++) {
if(current->unk6 != -1)
GroundEffect_Delete(index);
}
}
void FreeGroundEffects(void)
{
DeleteGroundEffects();
MemoryFree(gGroundEffects);
gGroundEffects = NULL;
}

View File

@@ -1,4 +1,104 @@
#include "global.h"
#include "ground_script.h"
#include "memory.h"
IWRAM_INIT void *gGroundLivesMeta = NULL;
IWRAM_INIT void *gGroundLives = NULL;
struct GroundLivesMeta_Sub1
{
// size: 0xC
u32 unk0;
u32 unk4;
u32 unk8;
};
struct unkStruct_3001B80
{
// size: 0x338
struct GroundLivesMeta_Sub1 unk0[3];
u32 unk24;
u8 unk28;
struct GroundLivesMeta_Sub1 unk2C[0x40];
ScriptInfoSmall unk32C;
};
IWRAM_INIT struct unkStruct_3001B80 *gGroundLivesMeta = NULL;
struct unkStruct_3001B84_sub
{
// size: 0x1F0
u16 unk0;
s16 unk2;
u8 unk4[0x1F0 - 0x4];
};
struct unkStruct_3001B84
{
struct unkStruct_3001B84_sub array[0x18];
};
IWRAM_INIT struct unkStruct_3001B84 *gGroundLives = NULL;
extern void DeleteGroundLives(void);
void GroundLives_Delete(s32);
void AllocGroundLives(void)
{
s32 index;
struct unkStruct_3001B84_sub *ptr;
gGroundLivesMeta = MemoryAlloc(sizeof(struct unkStruct_3001B80),6);
gGroundLives = MemoryAlloc(sizeof(struct unkStruct_3001B84),6);
for(index = 0, ptr = &gGroundLives->array[index]; index < 0x18; index = (s16)(index + 1), ptr++)
{
ptr->unk2 = -1;
}
GetFunctionScript(0,&gGroundLivesMeta->unk32C,0x19);
gGroundLivesMeta->unk32C.state = 1;
DeleteGroundLives();
}
void DeleteGroundLives(void)
{
int index;
struct unkStruct_3001B84_sub *iVar4;
struct GroundLivesMeta_Sub1 *ptr;
iVar4 = &gGroundLives->array[0];
for(index = 0; index < 0x18; index = (s16)(index + 1), iVar4++)
{
if (iVar4->unk2 != -1) {
GroundLives_Delete(index);
}
}
gGroundLivesMeta->unk24 = -1;
gGroundLivesMeta->unk28 = -1;
for(index = 0; index < 3; ptr++, index++)
{
ptr = &gGroundLivesMeta->unk0[index];
ptr->unk8 = -1;
ptr->unk0 = 0;
ptr->unk4 = 0;
}
for(index = 0; index < 0x40; ptr++, index++)
{
ptr = &gGroundLivesMeta->unk2C[index];
ptr->unk0 = 0;
ptr->unk4 = 0;
ptr->unk8 = 0;
}
}
void FreeGroundLives(void)
{
DeleteGroundLives();
MemoryFree(gGroundLives);
gGroundLives = NULL;
MemoryFree(gGroundLivesMeta);
gGroundLivesMeta = NULL;
}