sub_8122DB0

This commit is contained in:
PikalaxALT 2017-10-29 20:49:49 -04:00
parent 76bb397e83
commit 6f68e5af95
4 changed files with 138 additions and 317 deletions

View File

@ -5,310 +5,6 @@
.text
thumb_func_start sub_8122D88
sub_8122D88: @ 8122D88
push {r4,lr}
ldr r4, =gUnknown_0203A144
str r0, [r4]
bl sub_81238AC
ldr r2, [r4]
adds r0, r2, 0
adds r0, 0x54
ldrh r1, [r0]
adds r0, 0x20
strh r1, [r0]
subs r0, 0x1E
ldrh r1, [r0]
adds r0, 0x20
strh r1, [r0]
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_8122D88
thumb_func_start sub_8122DB0
sub_8122DB0: @ 8122DB0
push {r4,r5,lr}
sub sp, 0xC
ldr r0, =gUnknown_0203A144
ldr r0, [r0]
adds r0, 0x79
ldrb r0, [r0]
cmp r0, 0x7
bls _08122DC2
b _0812300C
_08122DC2:
lsls r0, 2
ldr r1, =_08122DD4
adds r0, r1
ldr r0, [r0]
mov pc, r0
.pool
.align 2, 0
_08122DD4:
.4byte _08122DF4
.4byte _08122E2C
.4byte _08122E78
.4byte _08122E94
.4byte _08122EB0
.4byte _08122ECC
.4byte _08122F10
.4byte _08122F8C
_08122DF4:
ldr r0, =gUnknown_0203A144
ldr r1, [r0]
adds r0, r1, 0
adds r0, 0x83
ldrb r0, [r0]
cmp r0, 0
beq _08122E18
adds r0, r1, 0
adds r0, 0x80
ldrb r0, [r0]
ldr r1, =gUnknown_0859F77C
movs r2, 0
str r2, [sp]
b _08122E52
.pool
_08122E18:
ldr r0, =gUnknown_0859F77C
ldr r1, =0x06008000
bl LZ77UnCompVram
b _08123014
.pool
_08122E2C:
ldr r4, =gUnknown_0203A144
ldr r0, [r4]
adds r0, 0x83
ldrb r0, [r0]
cmp r0, 0
beq _08122E64
bl free_temp_tile_data_buffers_if_possible
lsls r0, 24
cmp r0, 0
beq _08122E44
b _08123014
_08122E44:
ldr r0, [r4]
adds r0, 0x80
ldrb r0, [r0]
ldr r1, =gUnknown_085A04E0
movs r2, 0x1
str r2, [sp]
movs r2, 0
_08122E52:
movs r3, 0
bl decompress_and_copy_tile_data_to_vram
b _08123014
.pool
_08122E64:
ldr r0, =gUnknown_085A04E0
ldr r1, =0x0600e000
bl LZ77UnCompVram
b _08123014
.pool
_08122E78:
bl free_temp_tile_data_buffers_if_possible
lsls r0, 24
cmp r0, 0
beq _08122E84
b _08123014
_08122E84:
ldr r0, =gUnknown_0859F73C
movs r1, 0x70
movs r2, 0x60
bl LoadPalette
b _08123014
.pool
_08122E94:
ldr r0, =gUnknown_0859F60C
ldr r1, =gUnknown_0203A144
ldr r1, [r1]
movs r2, 0xC2
lsls r2, 1
adds r1, r2
bl LZ77UnCompWram
b _08123014
.pool
_08122EB0:
ldr r0, =gUnknown_0859F650
ldr r1, =gUnknown_0203A144
ldr r1, [r1]
movs r5, 0xA1
lsls r5, 2
adds r1, r5
bl LZ77UnCompWram
b _08123014
.pool
_08122ECC:
bl sub_81238AC
ldr r4, =gUnknown_0203A144
ldr r2, [r4]
adds r0, r2, 0
adds r0, 0x54
ldrh r1, [r0]
adds r0, 0x20
strh r1, [r0]
subs r0, 0x1E
ldrh r0, [r0]
adds r1, r2, 0
adds r1, 0x76
strh r0, [r1]
ldrh r0, [r2]
bl sub_8123EB4
ldr r1, [r4]
strh r0, [r1]
ldrh r0, [r1]
bl get_flagnr_blue_points
ldr r1, [r4]
strb r0, [r1, 0x2]
ldr r1, [r4]
adds r0, r1, 0x4
ldrh r1, [r1]
movs r2, 0x10
bl GetMapName
b _08123014
.pool
_08122F10:
ldr r0, =gUnknown_0203A144
ldr r4, [r0]
adds r0, r4, 0
adds r0, 0x78
ldrb r1, [r0]
cmp r1, 0
bne _08122F3C
movs r0, 0x80
lsls r0, 1
str r0, [sp]
str r0, [sp, 0x4]
str r1, [sp, 0x8]
movs r0, 0
movs r1, 0
movs r2, 0
movs r3, 0
bl sub_81236C4
b _08123014
.pool
_08122F3C:
adds r1, r4, 0
adds r1, 0x54
ldrh r0, [r1]
lsls r0, 3
subs r0, 0x34
adds r2, r4, 0
adds r2, 0x5C
movs r3, 0
strh r0, [r2]
movs r0, 0x56
adds r0, r4
mov r12, r0
ldrh r0, [r0]
lsls r0, 3
subs r0, 0x44
adds r5, r4, 0
adds r5, 0x5E
strh r0, [r5]
ldrh r1, [r1]
adds r0, r4, 0
adds r0, 0x64
strh r1, [r0]
mov r0, r12
ldrh r1, [r0]
adds r0, r4, 0
adds r0, 0x66
strh r1, [r0]
movs r1, 0
ldrsh r0, [r2, r1]
movs r2, 0
ldrsh r1, [r5, r2]
movs r2, 0x80
str r2, [sp]
str r2, [sp, 0x4]
str r3, [sp, 0x8]
movs r2, 0x38
movs r3, 0x48
bl sub_81236C4
b _08123014
_08122F8C:
bl sub_8123FB0
bl sub_81237B4
ldr r4, =gUnknown_0203A144
ldr r0, [r4]
movs r1, 0
str r1, [r0, 0x1C]
str r1, [r0, 0x20]
adds r0, 0x7A
strb r1, [r0]
ldr r0, [r4]
adds r0, 0x7E
strb r1, [r0]
ldr r1, [r4]
adds r0, r1, 0
adds r0, 0x83
ldrb r0, [r0]
cmp r0, 0
beq _08123002
adds r0, r1, 0
adds r0, 0x80
ldrb r0, [r0]
movs r1, 0x3
movs r2, 0x2
bl SetBgAttribute
ldr r1, [r4]
adds r0, r1, 0
adds r0, 0x80
ldrb r0, [r0]
adds r1, 0x81
ldrb r2, [r1]
movs r1, 0x1
bl SetBgAttribute
ldr r1, [r4]
adds r0, r1, 0
adds r0, 0x80
ldrb r0, [r0]
adds r1, 0x82
ldrb r2, [r1]
movs r1, 0x2
bl SetBgAttribute
ldr r0, [r4]
adds r0, 0x80
ldrb r0, [r0]
movs r1, 0x6
movs r2, 0x1
bl SetBgAttribute
ldr r0, [r4]
adds r0, 0x80
ldrb r0, [r0]
movs r1, 0x4
movs r2, 0x1
bl SetBgAttribute
_08123002:
ldr r1, [r4]
adds r1, 0x79
ldrb r0, [r1]
adds r0, 0x1
strb r0, [r1]
_0812300C:
movs r0, 0
b _08123022
.pool
_08123014:
ldr r0, =gUnknown_0203A144
ldr r1, [r0]
adds r1, 0x79
ldrb r0, [r1]
adds r0, 0x1
strb r0, [r1]
movs r0, 0x1
_08123022:
add sp, 0xC
pop {r4,r5}
pop {r1}
bx r1
.pool
thumb_func_end sub_8122DB0
thumb_func_start sub_8123030
sub_8123030: @ 8123030
push {lr}

View File

@ -226,28 +226,45 @@ struct UnkStruct_8122CF8 {
};
struct RegionMap {
/*0x000*/ u8 unk_00;
/*0x001*/ u8 unk_01;
/*0x002*/ bool8 unk_02;
/*0x003*/ u8 unk_03;
/*0x000*/ u16 mapSecId;
/*0x002*/ u8 unk_002;
/*0x003*/ u8 unk_003;
/*0x004*/ u8 mapSecName[0x14];
/*0x018*/ u8 (*inputCallback)(void);
/*0x01c*/ u8 filler_01c[0x5c];
/*0x01c*/ u32 unk_01c;
/*0x020*/ u32 unk_020;
/*0x024*/ u8 filler_024[0x30];
/*0x054*/ u16 unk_054;
/*0x056*/ u16 unk_056;
/*0x058*/ u8 filler_058[0x4];
/*0x05c*/ s16 unk_05c;
/*0x05e*/ s16 unk_05e;
/*0x060*/ u8 filler_060[0x4];
/*0x064*/ u16 unk_064;
/*0x066*/ u16 unk_066;
/*0x068*/ u8 filler_068[0xc];
/*0x074*/ u16 unk_074;
/*0x076*/ u16 unk_076;
/*0x078*/ u8 unk_078;
/*0x079*/ bool8 unk_079;
/*0x07a*/ u8 filler_07a[6];
/*0x079*/ u8 unk_079;
/*0x07a*/ u8 unk_07a;
/*0x07b*/ u8 filler_07b[3];
/*0x07e*/ u8 unk_07e;
/*0x07f*/ u8 filler_07f[1];
/*0x080*/ u8 unk_080;
/*0x081*/ u8 unk_081;
/*0x082*/ u8 unk_082;
/*0x083*/ bool8 unk_083;
/*0x084*/ u8 filler_084[0x800];
/*0x084*/ u8 filler_084[0x100];
/*0x184*/ u8 unk_184[0x100];
/*0x284*/ u8 unk_284[0x600];
}; // size = 0x884
// Exported RAM declarations
// Exported ROM declarations
void GetMapName(u8 *, u16, u16);
void sub_8122CDC(struct RegionMap *regionMap, bool8 argument);
void sub_8122CDC(struct RegionMap *regionMap, u8 argument);
void sub_8124288(u16 x, u16 y);
void sub_81240D4(u16 x, u16 y);
u8 sub_81230AC(void);

View File

@ -120,7 +120,7 @@ void sub_8170290(void)
switch (gUnknown_0203BCD0->state)
{
case 0:
sub_8122CDC(&gUnknown_0203BCD0->regionMap, FALSE);
sub_8122CDC(&gUnknown_0203BCD0->regionMap, 0);
sub_8124288(0, 0);
sub_81240D4(1, 1);
gUnknown_0203BCD0->state ++;
@ -181,7 +181,7 @@ void sub_8170290(void)
static void sub_8170428(void)
{
if (gUnknown_0203BCD0->regionMap.unk_02)
if (gUnknown_0203BCD0->regionMap.unk_002 != 0)
{
FillWindowPixelBuffer(0, 0x11);
PrintTextOnWindow(0, 1, gUnknown_0203BCD0->regionMap.mapSecName, 0, 1, 0, NULL);

View File

@ -2,6 +2,9 @@
// Includes
#include "global.h"
#include "region_map.h"
#include "menu.h"
#include "palette.h"
#include "bg.h"
// Static type declarations
@ -20,18 +23,30 @@ void sub_8122CF8(struct RegionMap *regionMap, struct UnkStruct_8122CF8 *arg1, bo
bool8 sub_8122DB0(void);
u8 sub_8123254(void);
u8 sub_81230C4(void);
void sub_81238AC(void);
u16 sub_8123EB4(u16 mapSecId);
u8 get_flagnr_blue_points(u16 mapSecId);
void sub_81236C4(s32 a0, s32 a1, s32 a2, s32 a3, u16 a4, u16 a5, u16 a6);
void sub_8123FB0(void);
void sub_81237B4(void);
// .rodata
extern const u8 gUnknown_0859F77C[];
extern const u8 gUnknown_085A04E0[];
extern const u16 gUnknown_0859F73C[];
extern const u8 gUnknown_0859F60C[];
extern const u8 gUnknown_0859F650[];
// .text
void sub_8122CDC(struct RegionMap *regionMap, bool8 argument)
void sub_8122CDC(struct RegionMap *regionMap, u8 argument)
{
sub_8122CF8(regionMap, NULL, argument);
while (sub_8122DB0());
}
void sub_8122CF8(struct RegionMap *regionMap, struct UnkStruct_8122CF8 *arg1, bool8 arg2)
void sub_8122CF8(struct RegionMap *regionMap, struct UnkStruct_8122CF8 *arg1, u8 arg2)
{
gUnknown_0203A144 = regionMap;
gUnknown_0203A144->unk_079 = 0;
@ -52,3 +67,96 @@ void sub_8122CF8(struct RegionMap *regionMap, struct UnkStruct_8122CF8 *arg1, bo
gUnknown_0203A144->unk_083 = FALSE;
}
}
void sub_8122D88(struct RegionMap *regionMap)
{
gUnknown_0203A144 = regionMap;
sub_81238AC();
gUnknown_0203A144->unk_074 = gUnknown_0203A144->unk_054;
gUnknown_0203A144->unk_076 = gUnknown_0203A144->unk_056;
}
bool8 sub_8122DB0(void)
{
switch (gUnknown_0203A144->unk_079)
{
case 0:
if (gUnknown_0203A144->unk_083)
{
decompress_and_copy_tile_data_to_vram(gUnknown_0203A144->unk_080, gUnknown_0859F77C, 0, 0, 0);
}
else
{
LZ77UnCompVram(gUnknown_0859F77C, (u16 *)BG_SCREEN_ADDR(16));
}
break;
case 1:
if (gUnknown_0203A144->unk_083)
{
if (!free_temp_tile_data_buffers_if_possible())
{
decompress_and_copy_tile_data_to_vram(gUnknown_0203A144->unk_080, gUnknown_085A04E0, 0, 0, 1);
}
}
else
{
LZ77UnCompVram(gUnknown_085A04E0, (u16 *)BG_SCREEN_ADDR(28));
}
break;
case 2:
if (!free_temp_tile_data_buffers_if_possible())
{
LoadPalette(gUnknown_0859F73C, 0x70, 0x60);
}
break;
case 3:
LZ77UnCompWram(gUnknown_0859F60C, gUnknown_0203A144->unk_184);
break;
case 4:
LZ77UnCompWram(gUnknown_0859F650, gUnknown_0203A144->unk_284);
break;
case 5:
sub_81238AC();
gUnknown_0203A144->unk_074 = gUnknown_0203A144->unk_054;
gUnknown_0203A144->unk_076 = gUnknown_0203A144->unk_056;
gUnknown_0203A144->mapSecId = sub_8123EB4(gUnknown_0203A144->mapSecId);
gUnknown_0203A144->unk_002 = get_flagnr_blue_points(gUnknown_0203A144->mapSecId);
GetMapName(gUnknown_0203A144->mapSecName, gUnknown_0203A144->mapSecId, 16);
break;
case 6:
if (gUnknown_0203A144->unk_078 == 0)
{
sub_81236C4(0, 0, 0, 0, 0x100, 0x100, 0);
}
else
{
gUnknown_0203A144->unk_05c = gUnknown_0203A144->unk_054 * 8 - 0x34;
gUnknown_0203A144->unk_05e = gUnknown_0203A144->unk_056 * 8 - 0x44;
gUnknown_0203A144->unk_064 = gUnknown_0203A144->unk_054;
gUnknown_0203A144->unk_066 = gUnknown_0203A144->unk_056;
sub_81236C4(gUnknown_0203A144->unk_05c, gUnknown_0203A144->unk_05e, 0x38, 0x48, 0x80, 0x80, 0);
}
break;
case 7:
sub_8123FB0();
sub_81237B4();
gUnknown_0203A144->unk_01c = 0;
gUnknown_0203A144->unk_020 = 0;
gUnknown_0203A144->unk_07a = 0;
gUnknown_0203A144->unk_07e = 0;
if (gUnknown_0203A144->unk_083)
{
SetBgAttribute(gUnknown_0203A144->unk_080, BG_CTRL_ATTR_MAPBASEINDEX, 2);
SetBgAttribute(gUnknown_0203A144->unk_080, BG_CTRL_ATTR_VISIBLE, gUnknown_0203A144->unk_081);
SetBgAttribute(gUnknown_0203A144->unk_080, BG_CTRL_ATTR_CHARBASEINDEX, gUnknown_0203A144->unk_082);
SetBgAttribute(gUnknown_0203A144->unk_080, BG_CTRL_ATTR_PRIORITY, 1);
SetBgAttribute(gUnknown_0203A144->unk_080, BG_CTRL_ATTR_SCREENSIZE, 1);
}
gUnknown_0203A144->unk_079 ++;
return FALSE;
default:
return FALSE;
}
gUnknown_0203A144->unk_079 ++;
return TRUE;
}