match sub_803E490

This commit is contained in:
Seth Barberee 2024-08-04 10:54:13 -07:00
parent cf4d5c2539
commit 909ae92090
8 changed files with 159 additions and 276 deletions

View File

@ -1,199 +0,0 @@
#include "asm/constants/gba_constants.inc"
#include "asm/macros.inc"
.syntax unified
.text
thumb_func_start sub_803E490
sub_803E490:
push {r4,r5,lr}
sub sp, 0x8
ldr r1, _0803E4D8
ldr r0, [r1]
adds r0, 0x1
str r0, [r1]
bl xxx_draw_string_80524F0
bl sub_8085F78
movs r0, 0x1
bl sub_803F580
ldr r2, _0803E4DC
ldr r1, [r2]
ldr r3, _0803E4E0
adds r0, r1, r3
ldrb r0, [r0]
cmp r0, 0
beq _0803E4EC
ldr r4, _0803E4E4
adds r1, r4
movs r0, 0x2
strb r0, [r1]
ldr r1, [r2]
ldr r2, _0803E4E8
adds r0, r1, r2
movs r3, 0
ldrsh r0, [r0, r3]
subs r4, 0x16
adds r1, r4
movs r2, 0
ldrsh r1, [r1, r2]
bl SetBG2RegOffsets
b _0803E4FC
.align 2, 0
_0803E4D8: .4byte gUnknown_202EDD4
_0803E4DC: .4byte gDungeon
_0803E4E0: .4byte 0x0001821a
_0803E4E4: .4byte 0x00018208
_0803E4E8: .4byte 0x000181f0
_0803E4EC:
ldr r3, _0803E628
adds r1, r3
movs r0, 0x3
strb r0, [r1]
movs r0, 0
movs r1, 0
bl SetBG2RegOffsets
_0803E4FC:
ldr r4, _0803E62C
ldr r2, [r4]
ldr r5, _0803E630
adds r0, r2, r5
movs r1, 0
ldrsh r0, [r0, r1]
ldr r3, _0803E634
adds r1, r2, r3
movs r3, 0
ldrsh r1, [r1, r3]
ldr r3, _0803E638
adds r2, r3
ldr r2, [r2]
subs r1, r2
bl SetBG3RegOffsets
bl sub_806CC10
bl sub_804522C
bl sub_803F9CC
ldr r0, [r4]
adds r0, r5
bl sub_800F7D0
ldr r1, [r4]
ldrh r2, [r1, 0x12]
movs r3, 0x12
ldrsh r0, [r1, r3]
cmp r0, 0x63
bgt _0803E540
adds r0, r2, 0x1
strh r0, [r1, 0x12]
_0803E540:
ldr r0, [r4]
adds r0, r5
bl sub_800E90C
bl sub_8042E5C
ldr r0, _0803E63C
ldr r0, [r0]
cmp r0, 0
beq _0803E562
cmp r0, 0x3
beq _0803E562
ldr r0, _0803E640
ldr r0, [r0]
ldrb r0, [r0, 0x4]
cmp r0, 0x6
bne _0803E566
_0803E562:
bl sub_8040894
_0803E566:
bl sub_803ECE0
bl sub_803EDF0
ldr r0, _0803E62C
ldr r3, [r0]
ldr r4, _0803E644
adds r0, r3, r4
ldrb r0, [r0]
cmp r0, 0
beq _0803E5A2
ldr r1, _0803E648
adds r0, r3, r1
ldr r0, [r0]
cmp r0, 0x3
beq _0803E5A2
ldr r0, _0803E64C
ldrb r0, [r0]
ldr r1, _0803E650
ldr r2, _0803E654
ldr r2, [r2]
str r2, [sp]
movs r4, 0xBE
lsls r4, 1
adds r2, r3, r4
str r2, [sp, 0x4]
movs r2, 0xA0
movs r3, 0x20
bl sub_8004AF0
_0803E5A2:
ldr r0, _0803E640
ldr r0, [r0]
ldrb r0, [r0, 0xA]
bl nullsub_8
bl sub_8005180
bl nullsub_12
bl sub_80060EC
ldr r1, _0803E658
ldr r0, [r1]
adds r0, 0x1
str r0, [r1]
ldr r0, _0803E65C
ldr r0, [r0]
bl IncrementPlayTime
bl sub_800CB20
bl LoadBufferedInputs
bl CopySpritesToOam
bl nullsub_13
bl sub_8005304
bl nullsub_14
bl TransferBGPaletteBuffer
bl sub_8009908
bl xxx_call_update_bg_vram
bl sub_8040788
bl xxx_call_update_bg_sound_input
ldr r0, _0803E62C
ldr r0, [r0]
ldr r1, _0803E660
adds r0, r1
movs r1, 0
strb r1, [r0]
bl UpdateDungeonMusic
bl sub_8011860
bl sub_8040B60
movs r0, 0
bl ResetSprites
movs r0, 0
bl nullsub_10
ldr r1, _0803E664
ldr r0, [r1]
subs r0, 0x1
str r0, [r1]
add sp, 0x8
pop {r4,r5}
pop {r0}
bx r0
.align 2, 0
_0803E628: .4byte 0x00018208
_0803E62C: .4byte gDungeon
_0803E630: .4byte 0x000181f0
_0803E634: .4byte 0x000181f2
_0803E638: .4byte 0x000181fc
_0803E63C: .4byte gUnknown_202EDD0
_0803E640: .4byte gGameOptionsRef
_0803E644: .4byte 0x00018215
_0803E648: .4byte 0x0001c06c
_0803E64C: .4byte gUnknown_203B40D
_0803E650: .4byte gUnknown_202EE8C
_0803E654: .4byte gUnknown_202EDC8
_0803E658: .4byte gUnknown_202EDCC
_0803E65C: .4byte gPlayTimeRef
_0803E660: .4byte 0x00018213
_0803E664: .4byte gUnknown_202EDD4
thumb_func_end sub_803E490
@ https://decomp.me/scratch/biQXr (kermalis 100%) `void sub_803E668(u32)`
.align 2, 0

View File

@ -2,15 +2,7 @@
#define GUARD_CODE_8004AA0_H
#include "file_system.h"
// size: 0x4
typedef struct RGB
{
// IDK which is R G B
u8 unk0;
u8 unk1;
u8 unk2;
} RGB;
#include "structs/rgb.h"
// size: 0x18
typedef struct unkStruct_202EE8C
@ -24,6 +16,8 @@ typedef struct unkStruct_202EE8C
RGB unk14;
} unkStruct_202EE8C;
extern unkStruct_202EE8C gUnknown_202EE8C[32];
// size: Variable
typedef struct unkDataFor8004AA4
{
@ -38,4 +32,4 @@ bool8 sub_8004AF0(bool8, unkStruct_202EE8C *, s32, s32, s32, u8 *);
bool8 sub_8004D14(unkStruct_202EE8C *, s32);
bool8 sub_8004D40(unkStruct_202EE8C *, s32);
#endif // GUARD_CODE_8004AA0_H
#endif // GUARD_CODE_8004AA0_H

View File

@ -2,15 +2,7 @@
#define GUARD_CODE_8010EF0_H
#include "file_system.h"
// size: 0x4
typedef struct RGB
{
// IDK which is R G B
u8 unk0;
u8 unk1;
u8 unk2;
} RGB;
#include "structs/rgb.h"
// size: 0x18
typedef struct unkStruct_202EE8C

12
include/structs/rgb.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef GUARD_RGB_H
#define GUARD_RGB_H
typedef struct RGB
{
// IDK which is R G B
u8 unk0;
u8 unk1;
u8 unk2;
} RGB;
#endif // GUARD_RGB_H

View File

@ -270,7 +270,9 @@ typedef struct Dungeon
/* 0x17B44 */ OpenedFile *sprites[MONSTER_MAX];
/* 0x181E4 */ OpenedFile *paletFile;
/* 0x181E8 */ unkDungeonGlobal_unk181E8_sub unk181e8;
u8 fill18220[0x1C570 - 0x18220];
u8 fill18220[0x1C06C - 0x18220];
u32 unk1C06C;
u8 fill1C070[0x1C570 - 0x1C070];
u8 unk1C570;
u8 unk1C571;
u8 fill1C572[0x1C578 - 0x1C572];

View File

@ -203,8 +203,6 @@ SECTIONS {
src/code_803D0D8.o(.text);
asm/code_803D110.o(.text);
src/code_803E46C.o(.text);
asm/code_803E490.o(.text);
src/code_803E668.o(.text);
asm/code_803E724.o(.text);
src/code_8040094.o(.text);
asm/code_8040094.o(.text);

View File

@ -1,11 +1,44 @@
#include "global.h"
#include "structs/str_dungeon.h"
#include "code_803E46C.h"
#include "code_8004AA0.h"
#include "code_800558C.h"
#include "code_8009804.h"
#include "code_800C9CC.h"
#include "code_80118A4.h"
#include "code_803E668.h"
#include "bg_palette_buffer.h"
#include "bg_control.h"
#include "dungeon_music.h"
#include "game_options.h"
#include "input.h"
#include "play_time.h"
#include "sprite.h"
extern u8 gUnknown_203B40C;
extern u8 gUnknown_203B40D;
extern u32 gUnknown_202EDC8;
extern s32 gUnknown_202EDCC;
extern u32 gUnknown_202EDD0;
extern s32 gUnknown_202EDD4;
extern void sub_803E490(u32);
void xxx_draw_string_80524F0(void);
void sub_8085F78(void);
void sub_803F580(s32);
void sub_806CC10();
void sub_804522C();
void sub_803F9CC();
extern void xxx_call_update_bg_vram(void);
void sub_8040894();
void sub_803ECE0();
void sub_803EDF0();
void sub_800E90C();
void sub_8042E5C();
void sub_8040B60();
void sub_8040788();
void sub_800F7D0(Position *);
void sub_803E46C(u32 a0)
{
@ -14,3 +47,108 @@ void sub_803E46C(u32 a0)
else
sub_803E668(a0);
}
void sub_803E490(u32 unused)
{
gUnknown_202EDD4++;
xxx_draw_string_80524F0();
sub_8085F78();
sub_803F580(1);
if(gDungeon->unk181e8.unk1821A)
{
gDungeon->unk181e8.unk18208 = 2;
SetBG2RegOffsets(gDungeon->unk181e8.cameraPixelPos.x, gDungeon->unk181e8.cameraPixelPos.y);
}
else
{
gDungeon->unk181e8.unk18208 = 3;
SetBG2RegOffsets(0, 0);
}
SetBG3RegOffsets(gDungeon->unk181e8.cameraPixelPos.x, gDungeon->unk181e8.cameraPixelPos.y - gDungeon->unk181e8.unk181FC);
sub_806CC10();
sub_804522C();
sub_803F9CC();
sub_800F7D0(&gDungeon->unk181e8.cameraPixelPos);
if(gDungeon->unk12 <= 0x63)
gDungeon->unk12++;
sub_800E90C(&gDungeon->unk181e8.cameraPixelPos);
sub_8042E5C();
if(gUnknown_202EDD0 == 0 || gUnknown_202EDD0 == 3 || gGameOptionsRef->mapOption == TOP_MAP_AND_TEAM_NO_BOTTOM)
sub_8040894();
sub_803ECE0();
sub_803EDF0();
if(gDungeon->unk181e8.unk18215 != 0 && gDungeon->unk1C06C != 3)
sub_8004AF0(gUnknown_203B40D, gUnknown_202EE8C, 0xA0, 0x20, gUnknown_202EDC8, (u8 *)gDungeon->unk17C);
nullsub_8(gGameOptionsRef->unkA);
sub_8005180();
nullsub_12();
sub_80060EC();
gUnknown_202EDCC++;
IncrementPlayTime(gPlayTimeRef);
sub_800CB20();
LoadBufferedInputs();
CopySpritesToOam();
nullsub_13();
sub_8005304();
nullsub_14();
TransferBGPaletteBuffer();
sub_8009908();
xxx_call_update_bg_vram();
sub_8040788();
xxx_call_update_bg_sound_input();
gDungeon->unk181e8.unk18213 = 0;
UpdateDungeonMusic();
sub_8011860();
sub_8040B60();
ResetSprites(FALSE);
nullsub_10(FALSE);
gUnknown_202EDD4--;
}
void sub_803E668(u32 unused)
{
gUnknown_202EDD4++;
nullsub_8(gGameOptionsRef->unkA);
sub_8005180();
nullsub_12();
sub_8005838(NULL, 0);
sub_80060EC();
gUnknown_202EDCC++;
IncrementPlayTime(gPlayTimeRef);
sub_800CB20();
LoadBufferedInputs();
CopySpritesToOam();
nullsub_13();
sub_8005304();
nullsub_14();
TransferBGPaletteBuffer();
sub_8009908();
xxx_call_update_bg_vram();
xxx_call_update_bg_sound_input();
gDungeon->unk181e8.unk18213 = 0;
sub_8011860();
ResetSprites(FALSE);
nullsub_10(FALSE);
gUnknown_202EDD4--;
}
void sub_803E708(s32 a0, u32 a1)
{
while (a0 != 0) {
sub_803E46C(a1);
a0--;
}
}

View File

@ -1,54 +0,0 @@
#include "global.h"
#include "code_803E668.h"
#include "bg_palette_buffer.h"
#include "code_800558C.h"
#include "code_8009804.h"
#include "code_800C9CC.h"
#include "code_80118A4.h"
#include "code_803E46C.h"
#include "game_options.h"
#include "input.h"
#include "play_time.h"
#include "sprite.h"
#include "structs/str_dungeon.h"
extern s32 gUnknown_202EDCC;
extern s32 gUnknown_202EDD4;
extern void xxx_call_update_bg_vram(void);
void sub_803E668(u32 a0)
{
gUnknown_202EDD4++;
nullsub_8(gGameOptionsRef->unkA);
sub_8005180();
nullsub_12();
sub_8005838(NULL, 0);
sub_80060EC();
gUnknown_202EDCC++;
IncrementPlayTime(gPlayTimeRef);
sub_800CB20();
LoadBufferedInputs();
CopySpritesToOam();
nullsub_13();
sub_8005304();
nullsub_14();
TransferBGPaletteBuffer();
sub_8009908();
xxx_call_update_bg_vram();
xxx_call_update_bg_sound_input();
gDungeon->unk181e8.unk18213 = 0;
sub_8011860();
ResetSprites(FALSE);
nullsub_10(FALSE);
gUnknown_202EDD4--;
}
void sub_803E708(s32 a0, u32 a1)
{
while (a0 != 0) {
sub_803E46C(a1);
a0--;
}
}