Match sub_80A62F0 and GroundSprite_Reset

This commit is contained in:
Kermalis
2023-08-12 11:57:50 -04:00
parent 02b6c6bd46
commit 7bcc6e0ea6
12 changed files with 166 additions and 186 deletions

View File

@@ -5,178 +5,6 @@
.text
thumb_func_start sub_80A62F0
sub_80A62F0:
push {r4-r7,lr}
ldr r4, _080A6378
movs r0, 0x88
lsls r0, 1
movs r1, 0x6
bl MemoryAlloc
str r0, [r4]
ldr r0, _080A637C
ldr r1, _080A6380
bl OpenFileAndGetFileDataPtr
ldr r1, _080A6384
str r0, [r1]
movs r0, 0x1
bl sub_800DAC0
ldr r4, [r4]
ldr r1, _080A6388
movs r0, 0x16
str r0, [r1]
ldr r1, _080A638C
movs r0, 0x1
strb r0, [r1]
movs r0, 0
movs r2, 0
movs r1, 0x80
lsls r1, 9
adds r3, r1, 0
_080A632A:
str r2, [r4]
lsls r0, 4
str r0, [r4, 0x4]
str r2, [r4, 0x8]
adds r0, r1, 0
adds r1, r3
asrs r0, 16
adds r4, 0xC
cmp r0, 0x15
ble _080A632A
ldr r0, _080A6378
ldr r0, [r0]
movs r1, 0x84
lsls r1, 1
adds r4, r0, r1
movs r6, 0
movs r7, 0
movs r5, 0xE8
lsls r5, 13
_080A6350:
strh r7, [r4]
strh r7, [r4, 0x2]
lsrs r0, r5, 16
movs r1, 0
bl sub_80997F4
movs r0, 0x80
lsls r0, 9
adds r5, r0
adds r6, 0x1
adds r4, 0x4
cmp r6, 0x1
ble _080A6350
movs r0, 0x1
negs r0, r0
bl GroundSprite_Reset
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_080A6378: .4byte gUnknown_3001B7C
_080A637C: .4byte gUnknown_81177CC
_080A6380: .4byte gDungeonFileArchive
_080A6384: .4byte gUnknown_203B4B4
_080A6388: .4byte gUnknown_2039DD4
_080A638C: .4byte gUnknown_2039DD0
thumb_func_end sub_80A62F0
thumb_func_start GroundSprite_Reset
GroundSprite_Reset:
push {r4-r7,lr}
mov r7, r9
mov r6, r8
push {r6,r7}
lsls r0, 16
asrs r0, 16
mov r9, r0
ldr r1, _080A641C
movs r0, 0
bl Log
ldr r0, _080A6420
movs r1, 0
mov r8, r1
strh r1, [r0]
ldr r0, _080A6424
strh r1, [r0]
bl sub_80A6460
mov r0, r9
bl sub_80A4D48
lsls r0, 24
movs r1, 0x2
cmp r0, 0
beq _080A63C6
movs r1, 0x3
_080A63C6:
movs r0, 0xF8
lsls r0, 1
bl sub_808E53C
ldr r5, _080A6428
adds r0, r5, 0
bl sub_8004E8C
ldr r4, _080A642C
adds r0, r4, 0
bl sub_8004E8C
ldrh r1, [r4, 0x4]
ldr r6, _080A6430
adds r0, r6, 0
ands r0, r1
strh r0, [r4, 0x4]
ldrh r1, [r4, 0xA]
adds r0, r6, 0
ands r0, r1
movs r2, 0x80
lsls r2, 4
adds r7, r2, 0
orrs r0, r7
strh r0, [r4, 0xA]
mov r0, r9
bl sub_80A4D48
lsls r0, 24
cmp r0, 0
beq _080A6434
ldrh r1, [r5, 0x4]
adds r0, r6, 0
ands r0, r1
strh r0, [r5, 0x4]
ldrh r1, [r5, 0xA]
adds r0, r6, 0
ands r0, r1
movs r2, 0xC0
lsls r2, 4
adds r1, r2, 0
orrs r0, r1
b _080A6444
.align 2, 0
_080A641C: .4byte gUnknown_81177D8
_080A6420: .4byte gUnknown_2039DCC
_080A6424: .4byte gUnknown_2039DCE
_080A6428: .4byte gUnknown_2039DB0
_080A642C: .4byte gUnknown_2039DC0
_080A6430: .4byte 0x0000f3ff
_080A6434:
ldrh r1, [r5, 0x4]
adds r0, r6, 0
ands r0, r1
strh r0, [r5, 0x4]
ldrh r1, [r5, 0xA]
adds r0, r6, 0
ands r0, r1
orrs r0, r7
_080A6444:
strh r0, [r5, 0xA]
movs r0, 0x1
bl ResetSprites
movs r0, 0x1
bl nullsub_10
pop {r3,r4}
mov r8, r3
mov r9, r4
pop {r4-r7}
pop {r0}
bx r0
thumb_func_end GroundSprite_Reset
thumb_func_start sub_80A6460
sub_80A6460:
push {r4-r7,lr}

6
include/code_800558C_1.h Normal file
View File

@@ -0,0 +1,6 @@
#ifndef GUARD_CODE_800558C_1_H
#define GUARD_CODE_800558C_1_H
void nullsub_10(bool8);
#endif // GUARD_CODE_800558C_1_H

6
include/code_800DAC0.h Normal file
View File

@@ -0,0 +1,6 @@
#ifndef GUARD_CODE_800DAC0_H
#define GUARD_CODE_800DAC0_H
void sub_800DAC0(u32);
#endif // GUARD_CODE_800DAC0_H

6
include/ground_map_1.h Normal file
View File

@@ -0,0 +1,6 @@
#ifndef GUARD_GROUND_MAP_1_H
#define GUARD_GROUND_MAP_1_H
bool8 sub_80A4D48(s16);
#endif // GUARD_GROUND_MAP_1_H

37
include/ground_sprite.h Normal file
View File

@@ -0,0 +1,37 @@
#ifndef GUARD_GROUND_SPRITE_H
#define GUARD_GROUND_SPRITE_H
// size: 0xC
struct unkStruct_2039DB0
{
u16 unk0;
s16 unk2;
u16 unk4;
u16 unk6;
u16 unk8;
u16 unkA;
};
// size: 0xC
struct unkStruct_3001B7C_sub0
{
u32 unk0;
s32 unk4;
u32 unk8;
};
// size: 0x4
struct unkStruct_3001B7C_sub108
{
u16 unk0;
u16 unk2;
};
// size: 0x110
struct unkStruct_3001B7C
{
struct unkStruct_3001B7C_sub0 unk0[22];
struct unkStruct_3001B7C_sub108 unk108[2];
};
void GroundSprite_Reset(s16);
#endif // GUARD_GROUND_SPRITE_H

View File

@@ -1,6 +1,7 @@
#ifndef GUARD_SPRITE_H
#define GUARD_SPRITE_H
#include "ground_sprite.h"
#include "position.h"
// size: 0x8
@@ -30,17 +31,6 @@ struct SpriteList
u32 unk804;
};
// size: 0xC
struct unkStruct_2039DB0
{
u16 unk0;
s16 unk2;
s16 unk4;
u16 unk6;
u16 unk8;
u16 unkA;
};
void BlinkSavingIcon(void);
void CopySpritesToOam(void);
void InitSprites(void);

View File

@@ -315,6 +315,7 @@ SECTIONS {
src/ground_map_1.o(.text);
asm/ground_map_1.o(.text);
src/ground_map_2.o(.text);
src/ground_sprite.o(.text);
asm/ground_sprite.o(.text);
src/code_80A7714.o(.text);
asm/ground_lives.o(.text);

View File

@@ -1,4 +1,5 @@
#include "global.h"
#include "code_800558C_1.h"
extern u8 gUnknown_2026E38;
extern u32 gUnknown_2026E3C;
@@ -36,7 +37,7 @@ void nullsub_8(void)
void nullsub_9(void)
{}
void nullsub_10(void)
void nullsub_10(bool8 a0)
{}
void nullsub_144(void)

View File

@@ -1,4 +1,5 @@
#include "global.h"
#include "code_800DAC0.h"
#include "file_system.h"
#include "memory.h"

View File

@@ -1,5 +1,6 @@
#include "global.h"
#include "debug.h"
#include "ground_map_1.h"
#include "ground_script.h"
extern struct GroundScript_ExecutePP_1 *gUnknown_3001B6C;

103
src/ground_sprite.c Normal file
View File

@@ -0,0 +1,103 @@
#include "global.h"
#include "code_800558C_1.h"
#include "code_800DAC0.h"
#include "debug.h"
#include "file_system.h"
#include "ground_map_1.h"
#include "ground_sprite.h"
#include "memory.h"
#include "sprite.h"
extern struct unkStruct_2039DB0 gUnknown_2039DB0;
extern struct unkStruct_2039DB0 gUnknown_2039DC0;
extern u16 gUnknown_2039DCC;
extern u16 gUnknown_2039DCE;
extern u8 gUnknown_2039DD0;
extern u32 gUnknown_2039DD4;
extern struct OpenedFile *gUnknown_203B4B4;
extern struct unkStruct_3001B7C *gUnknown_3001B7C;
extern const struct FileArchive gDungeonFileArchive;
extern const u8 gUnknown_81177CC[];
extern const u8 gUnknown_81177D8[];
// code_8098BDC.s
extern void sub_80997F4(u16, u16);
// pokemon_2.s
extern void sub_808E53C(u32, u32);
// ground_sprite.s
extern void sub_80A6460(void);
void sub_80A62F0(void)
{
s32 r0;
struct unkStruct_3001B7C_sub0 *sub0;
struct unkStruct_3001B7C_sub108 *sub108;
s32 r6;
gUnknown_3001B7C = MemoryAlloc(sizeof(struct unkStruct_3001B7C), 6);
gUnknown_203B4B4 = OpenFileAndGetFileDataPtr(gUnknown_81177CC, &gDungeonFileArchive);
sub_800DAC0(1);
sub0 = gUnknown_3001B7C->unk0;
gUnknown_2039DD4 = 22;
gUnknown_2039DD0 = 1;
for (r0 = 0; r0 < 22; r0 = (s16)(r0 + 1), sub0++)
{
sub0->unk0 = 0;
sub0->unk4 = r0 * 16;
sub0->unk8 = 0;
}
sub108 = gUnknown_3001B7C->unk108;
for (r6 = 0; r6 < 2; r6++, sub108++) {
sub108->unk0 = 0;
sub108->unk2 = 0;
sub_80997F4(r6 + 29, 0);
}
GroundSprite_Reset(-1);
}
void GroundSprite_Reset(s16 a0)
{
s32 uVar2;
struct unkStruct_2039DB0 *bee;
struct unkStruct_2039DB0 *see;
uVar2 = a0;
Log(0, gUnknown_81177D8);
gUnknown_2039DCC = 0;
gUnknown_2039DCE = 0;
sub_80A6460();
sub_808E53C(496, sub_80A4D48(uVar2) ? 3 : 2);
bee = &gUnknown_2039DB0;
sub_8004E8C(bee);
see = &gUnknown_2039DC0;
sub_8004E8C(see);
see->unk4 &= ~(0x400 | 0x800);
see->unkA &= ~(0x400 | 0x800);
see->unkA |= 0x800;
if (sub_80A4D48(a0)) {
bee->unk4 &= ~(0x400 | 0x800);
bee->unkA &= ~(0x400 | 0x800);
bee->unkA |= (0x400 | 0x800);
}
else {
bee->unk4 &= ~(0x400 | 0x800);
bee->unkA &= ~(0x400 | 0x800);
bee->unkA |= 0x800;
}
ResetSprites(TRUE);
nullsub_10(TRUE);
}

View File

@@ -123,7 +123,7 @@ void sub_8004E8C(struct unkStruct_2039DB0 *a0)
{
a0->unk0 = 0xFFFF;
a0->unk2 = -1;
a0->unk4 = -1;
a0->unk4 = 0xFFFF;
a0->unk6 = 0;
a0->unk8 = 0;
a0->unkA = 0;
@@ -394,8 +394,8 @@ void sub_8004EA8(s32 a0, s16 *a1, u32 *a2, u16 *a3)
"_080050AC: .4byte gUnknown_20256A0");
}
#ifdef NONMATCHING // https://decomp.me/scratch/YCfKG
// a2 and a3 are always called with NULL lol
#ifdef NONMATCHING // https://decomp.me/scratch/YCfKG
void AddSprite(struct unkSprite *a0, s32 a1, u32 *a2, struct unkStruct_2039DB0 *a3)
{
u16 uVar1;