Start decompiling field_region_map

This commit is contained in:
PikalaxALT 2017-10-29 10:38:25 -04:00
parent 4049ed7e2c
commit 0a060ae254
5 changed files with 89 additions and 103 deletions

View File

@ -5,107 +5,6 @@
.text .text
thumb_func_start sub_817018C
sub_817018C: @ 817018C
push {r4,r5,lr}
adds r5, r0, 0
movs r0, 0
bl SetVBlankCallback
ldr r4, =gUnknown_0203BCD0
movs r0, 0x89
lsls r0, 4
bl Alloc
str r0, [r4]
ldr r1, =0x0000088c
adds r2, r0, r1
movs r1, 0
strh r1, [r2]
str r5, [r0]
ldr r0, =sub_81701C4
bl SetMainCallback2
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end sub_817018C
thumb_func_start sub_81701C4
sub_81701C4: @ 81701C4
push {lr}
movs r0, 0
movs r1, 0
bl SetGpuReg
movs r0, 0x10
movs r1, 0
bl SetGpuReg
movs r0, 0x12
movs r1, 0
bl SetGpuReg
movs r0, 0x14
movs r1, 0
bl SetGpuReg
movs r0, 0x16
movs r1, 0
bl SetGpuReg
movs r0, 0x18
movs r1, 0
bl SetGpuReg
movs r0, 0x1A
movs r1, 0
bl SetGpuReg
movs r0, 0x1C
movs r1, 0
bl SetGpuReg
movs r0, 0x1E
movs r1, 0
bl SetGpuReg
bl ResetSpriteData
bl FreeAllSpritePalettes
movs r0, 0
bl ResetBgsAndClearDma3BusyFlags
ldr r1, =gUnknown_085E5068
movs r0, 0x1
movs r2, 0x2
bl InitBgsFromTemplates
ldr r0, =gUnknown_085E5070
bl InitWindows
bl DeactivateAllTextPrinters
movs r0, 0
movs r1, 0x27
movs r2, 0xD0
bl sub_809882C
bl clear_scheduled_bg_copies_to_vram
ldr r0, =sub_8170274
bl SetMainCallback2
ldr r0, =sub_8170260
bl SetVBlankCallback
pop {r0}
bx r0
.pool
thumb_func_end sub_81701C4
thumb_func_start sub_8170260
sub_8170260: @ 8170260
push {lr}
bl LoadOam
bl ProcessSpriteCopyRequests
bl TransferPlttBuffer
pop {r0}
bx r0
thumb_func_end sub_8170260
thumb_func_start sub_8170274
sub_8170274: @ 8170274
push {lr}
bl sub_8170290
bl AnimateSprites
bl BuildOamBuffer
bl UpdatePaletteFade
bl do_scheduled_bg_tilemap_copies_to_vram
pop {r0}
bx r0
thumb_func_end sub_8170274
thumb_func_start sub_8170290 thumb_func_start sub_8170290
sub_8170290: @ 8170290 sub_8170290: @ 8170290
push {r4,r5,lr} push {r4,r5,lr}

View File

@ -28,5 +28,7 @@ bool8 free_temp_tile_data_buffers_if_possible(void);
u64 sub_8198A50(struct WindowTemplate*, u8, u8, u8, u8, u8, u8, u16); // returns something but it isn't used, fix when menu.s is decomp'd u64 sub_8198A50(struct WindowTemplate*, u8, u8, u8, u8, u8, u8, u16); // returns something but it isn't used, fix when menu.s is decomp'd
void CreateYesNoMenu(const struct WindowTemplate *windowTemplate, u16 borderFirstTileNum, u8 borderPalette, u8 initialCursorPos); void CreateYesNoMenu(const struct WindowTemplate *windowTemplate, u16 borderFirstTileNum, u8 borderPalette, u8 initialCursorPos);
s8 sub_8198C58(void); s8 sub_8198C58(void);
void do_scheduled_bg_tilemap_copies_to_vram(void);
void clear_scheduled_bg_copies_to_vram(void);
#endif // GUARD_MENU_H #endif // GUARD_MENU_H

View File

@ -212,6 +212,7 @@ SECTIONS {
asm/player_pc.o(.text); asm/player_pc.o(.text);
asm/intro.o(.text); asm/intro.o(.text);
src/reset_save_heap.o(.text); src/reset_save_heap.o(.text);
src/field_region_map.o(.text);
asm/field_region_map.o(.text); asm/field_region_map.o(.text);
asm/battle_anim_8170478.o(.text); asm/battle_anim_8170478.o(.text);
asm/hall_of_fame.o(.text); asm/hall_of_fame.o(.text);
@ -433,6 +434,7 @@ SECTIONS {
data/battle_controller_wally.o(.rodata); data/battle_controller_wally.o(.rodata);
data/player_pc.o(.rodata); data/player_pc.o(.rodata);
data/intro.o(.rodata); data/intro.o(.rodata);
src/field_region_map.o(.rodata);
data/field_region_map.o(.rodata); data/field_region_map.o(.rodata);
data/battle_anim_8170478.o(.rodata); data/battle_anim_8170478.o(.rodata);
data/hall_of_fame.o(.rodata); data/hall_of_fame.o(.rodata);

84
src/field_region_map.c Normal file
View File

@ -0,0 +1,84 @@
// Includes
#include "global.h"
#include "main.h"
#include "malloc.h"
#include "gpu_regs.h"
#include "bg.h"
#include "text.h"
#include "window.h"
#include "text_window.h"
#include "palette.h"
#include "menu.h"
// Static type declarations
// Static RAM declarations
EWRAM_DATA struct {
MainCallback callback;
u8 filler_004[0x888];
u16 unk_88c;
} *gUnknown_0203BCD0 = NULL;
// Static ROM declarations
static void sub_81701C4(void);
static void sub_8170260(void);
static void sub_8170274(void);
void sub_8170290(void);
// .rodata
extern const struct BgTemplate gUnknown_085E5068[];
extern const struct WindowTemplate gUnknown_085E5070[];
// .text
void sub_817018C(MainCallback callback)
{
SetVBlankCallback(NULL);
gUnknown_0203BCD0 = malloc(sizeof(*gUnknown_0203BCD0));
gUnknown_0203BCD0->unk_88c = 0;
gUnknown_0203BCD0->callback = callback;
SetMainCallback2(sub_81701C4);
}
static void sub_81701C4(void)
{
SetGpuReg(REG_OFFSET_DISPCNT, 0);
SetGpuReg(REG_OFFSET_BG0HOFS, 0);
SetGpuReg(REG_OFFSET_BG0VOFS, 0);
SetGpuReg(REG_OFFSET_BG1HOFS, 0);
SetGpuReg(REG_OFFSET_BG1VOFS, 0);
SetGpuReg(REG_OFFSET_BG2HOFS, 0);
SetGpuReg(REG_OFFSET_BG2VOFS, 0);
SetGpuReg(REG_OFFSET_BG3HOFS, 0);
SetGpuReg(REG_OFFSET_BG3VOFS, 0);
ResetSpriteData();
FreeAllSpritePalettes();
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(1, gUnknown_085E5068, 2);
InitWindows(gUnknown_085E5070);
DeactivateAllTextPrinters();
sub_809882C(0, 0x27, 0xd0);
clear_scheduled_bg_copies_to_vram();
SetMainCallback2(sub_8170274);
SetVBlankCallback(sub_8170260);
}
static void sub_8170260(void)
{
LoadOam();
ProcessSpriteCopyRequests();
TransferPlttBuffer();
}
static void sub_8170274(void)
{
sub_8170290();
AnimateSprites();
BuildOamBuffer();
UpdatePaletteFade();
do_scheduled_bg_tilemap_copies_to_vram();
}

View File

@ -1410,8 +1410,7 @@ gUnknown_0203BCC8: @ 203BCC8
gUnknown_0203BCCC: @ 203BCCC gUnknown_0203BCCC: @ 203BCCC
.space 0x4 .space 0x4
gUnknown_0203BCD0: @ 203BCD0 .include "src/field_region_map.o"
.space 0x4
gUnknown_0203BCD4: @ 203BCD4 gUnknown_0203BCD4: @ 203BCD4
.space 0x4 .space 0x4