Decompile remaining functions in region_map

This commit is contained in:
PikalaxALT 2017-11-01 00:34:57 -04:00
parent ee60ae7da9
commit e3005e88c7
6 changed files with 138 additions and 310 deletions

View File

@ -1,303 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
.text
thumb_func_start sub_8124CBC
sub_8124CBC: @ 8124CBC
push {lr}
adds r2, r0, 0
ldr r0, =gUnknown_0203A148
ldr r0, [r0]
ldrh r1, [r0, 0x8]
movs r3, 0x2E
ldrsh r0, [r2, r3]
cmp r1, r0
bne _08124D00
ldrh r0, [r2, 0x30]
adds r0, 0x1
strh r0, [r2, 0x30]
lsls r0, 16
asrs r0, 16
cmp r0, 0x10
ble _08124D0E
movs r0, 0
strh r0, [r2, 0x30]
adds r3, r2, 0
adds r3, 0x3E
ldrb r2, [r3]
lsrs r1, r2, 2
movs r0, 0x1
eors r1, r0
ands r1, r0
lsls r1, 2
movs r0, 0x5
negs r0, r0
ands r0, r2
orrs r0, r1
strb r0, [r3]
b _08124D0E
.pool
_08124D00:
movs r0, 0x10
strh r0, [r2, 0x30]
adds r2, 0x3E
ldrb r1, [r2]
subs r0, 0x15
ands r0, r1
strb r0, [r2]
_08124D0E:
pop {r0}
bx r0
thumb_func_end sub_8124CBC
thumb_func_start sub_8124D14
sub_8124D14: @ 8124D14
push {r4,lr}
sub sp, 0x4
ldr r4, =gUnknown_0203A148
ldr r0, [r4]
ldrh r1, [r0, 0x4]
cmp r1, 0
beq _08124D2C
cmp r1, 0x1
beq _08124D46
b _08124D56
.pool
_08124D2C:
movs r0, 0x1
negs r0, r0
str r1, [sp]
movs r1, 0
movs r2, 0x10
movs r3, 0
bl BeginNormalPaletteFade
ldr r1, [r4]
ldrh r0, [r1, 0x4]
adds r0, 0x1
strh r0, [r1, 0x4]
b _08124D56
_08124D46:
bl UpdatePaletteFade
lsls r0, 24
cmp r0, 0
bne _08124D56
ldr r0, =sub_8124D64
bl sub_81248F4
_08124D56:
add sp, 0x4
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_8124D14
thumb_func_start sub_8124D64
sub_8124D64: @ 8124D64
push {r4,lr}
ldr r0, =gUnknown_0203A148
ldr r0, [r0]
ldrh r0, [r0, 0x4]
cmp r0, 0
bne _08124DF8
bl sub_81230AC
lsls r0, 24
lsrs r0, 24
cmp r0, 0x5
bhi _08124DF8
lsls r0, 2
ldr r1, =_08124D90
adds r0, r1
ldr r0, [r0]
mov pc, r0
.pool
.align 2, 0
_08124D90:
.4byte _08124DF8
.4byte _08124DF8
.4byte _08124DF8
.4byte _08124DA8
.4byte _08124DAE
.4byte _08124DE0
_08124DA8:
bl sub_8124904
b _08124DF8
_08124DAE:
ldr r4, =gUnknown_0203A148
ldr r0, [r4]
ldrb r0, [r0, 0xA]
cmp r0, 0x2
beq _08124DBC
cmp r0, 0x4
bne _08124DF8
_08124DBC:
movs r0, 0x5
bl m4aSongNumStart
ldr r0, [r4]
ldr r1, =0x00000a72
adds r0, r1
movs r1, 0x1
strb r1, [r0]
ldr r0, =sub_8124E0C
bl sub_81248F4
b _08124DF8
.pool
_08124DE0:
movs r0, 0x5
bl m4aSongNumStart
ldr r0, =gUnknown_0203A148
ldr r0, [r0]
ldr r1, =0x00000a72
adds r0, r1
movs r1, 0
strb r1, [r0]
ldr r0, =sub_8124E0C
bl sub_81248F4
_08124DF8:
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_8124D64
thumb_func_start sub_8124E0C
sub_8124E0C: @ 8124E0C
push {r4,lr}
sub sp, 0x4
ldr r4, =gUnknown_0203A148
ldr r0, [r4]
ldrh r1, [r0, 0x4]
cmp r1, 0
beq _08124E24
cmp r1, 0x1
beq _08124E3E
b _08124F1A
.pool
_08124E24:
movs r0, 0x1
negs r0, r0
str r1, [sp]
movs r1, 0
movs r2, 0
movs r3, 0x10
bl BeginNormalPaletteFade
ldr r1, [r4]
ldrh r0, [r1, 0x4]
adds r0, 0x1
strh r0, [r1, 0x4]
b _08124F1A
_08124E3E:
bl UpdatePaletteFade
lsls r0, 24
cmp r0, 0
bne _08124F1A
bl FreeRegionMapIconResources
ldr r1, [r4]
ldr r2, =0x00000a72
adds r0, r1, r2
ldrb r0, [r0]
cmp r0, 0
beq _08124F00
ldrh r0, [r1, 0x8]
cmp r0, 0xF
beq _08124E98
cmp r0, 0xF
bgt _08124E6C
cmp r0, 0
beq _08124E84
b _08124EBC
.pool
_08124E6C:
cmp r0, 0x3A
beq _08124E7C
cmp r0, 0x49
bne _08124EBC
movs r0, 0x15
bl sub_8084CCC
b _08124EFA
_08124E7C:
movs r0, 0x16
bl sub_8084CCC
b _08124EFA
_08124E84:
ldr r0, =gSaveBlock2Ptr
ldr r0, [r0]
ldrb r0, [r0, 0x8]
movs r1, 0xD
cmp r0, 0
bne _08124EB0
movs r1, 0xC
b _08124EB0
.pool
_08124E98:
ldr r0, =0x000008b4
bl FlagGet
lsls r0, 24
movs r1, 0xB
cmp r0, 0
beq _08124EB0
ldr r0, [r4]
ldrb r0, [r0, 0xB]
cmp r0, 0
bne _08124EB0
movs r1, 0x14
_08124EB0:
adds r0, r1, 0
bl sub_8084CCC
b _08124EFA
.pool
_08124EBC:
ldr r3, =gUnknown_085A1E3C
ldr r0, =gUnknown_0203A148
ldr r0, [r0]
ldrh r1, [r0, 0x8]
lsls r0, r1, 1
adds r2, r0, r1
adds r0, r3, 0x2
adds r1, r2, r0
ldrb r0, [r1]
cmp r0, 0
beq _08124EE0
bl sub_8084CCC
b _08124EFA
.pool
_08124EE0:
adds r0, r2, r3
ldrb r0, [r0]
lsls r0, 24
asrs r0, 24
adds r1, r3, 0x1
adds r1, r2, r1
ldrb r1, [r1]
lsls r1, 24
asrs r1, 24
movs r2, 0x1
negs r2, r2
bl warp1_set_2
_08124EFA:
bl sub_80B69DC
b _08124F06
_08124F00:
ldr r0, =sub_81B58A8
bl SetMainCallback2
_08124F06:
ldr r4, =gUnknown_0203A148
ldr r0, [r4]
cmp r0, 0
beq _08124F16
bl Free
movs r0, 0
str r0, [r4]
_08124F16:
bl FreeAllWindowBuffers
_08124F1A:
add sp, 0x4
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_8124E0C
.align 2, 0 @ Don't pad with nop.

View File

@ -69,9 +69,10 @@ enum FieldEffectScriptIdx
FLDEFF_USE_TELEPORT
};
u8 FieldEffectStart(u8);
bool8 FieldEffectActiveListContains(u8 id);
extern u32 gFieldEffectArguments[8];
u8 FieldEffectStart(u8);
bool8 FieldEffectActiveListContains(u8 id);
void sub_80B69DC(void);
#endif //GUARD_FIELD_EFFECTS_H

View File

@ -61,5 +61,7 @@ void c2_exit_to_overworld_1_continue_scripts_restart_music(void);
void warp_in(void);
u8 get_map_light_level_by_bank_and_number(s8 mapGroup, s8 mapNum);
void sub_8086194(void);
void sub_8084CCC(u8 spawn);
void warp1_set_2(s8 grp, s8 num, s8 wrp);
#endif //GUARD_ROM4_H

View File

@ -2,5 +2,6 @@
#define GUARD_PARTY_MENU_H
bool8 pokemon_has_move(struct Pokemon *, u16);
void sub_81B58A8(void);
#endif // GUARD_PARTY_MENU_H

View File

@ -169,7 +169,6 @@ SECTIONS {
asm/dewford_trend.o(.text);
src/heal_location.o(.text);
src/region_map.o(.text);
asm/region_map.o(.text);
asm/cute_sketch.o(.text);
src/decoration.o(.text);
asm/slot_machine.o(.text);

View File

@ -6,6 +6,7 @@
#include "malloc.h"
#include "gpu_regs.h"
#include "palette.h"
#include "party_menu.h"
#include "trig.h"
#include "map_constants.h"
#include "overworld.h"
@ -18,6 +19,9 @@
#include "strings.h"
#include "text.h"
#include "text_window.h"
#include "songs.h"
#include "m4a.h"
#include "field_effect.h"
#include "region_map.h"
#define MAP_WIDTH 28
@ -47,7 +51,8 @@ EWRAM_DATA struct {
/*0x006*/ u16 mapSecId;
/*0x008*/ struct RegionMap regionMap;
/*0x88c*/ u8 unk_88c[0x1c0];
/*0xa4c*/ u8 unk_a4c[0x28];
/*0xa4c*/ u8 unk_a4c[0x26];
/*0xa72*/ bool8 unk_a72;
} *gUnknown_0203A148 = NULL; // a74
IWRAM_DATA bool32 gUnknown_03001180;
@ -83,8 +88,10 @@ void sub_8124904(void);
static void sub_8124A70(void);
static void sub_8124AD4(void);
static void sub_8124BE4(void);
void sub_8124CBC(struct Sprite *sprite);
void sub_8124D14(void);
static void sub_8124CBC(struct Sprite *sprite);
static void sub_8124D14(void);
static void sub_8124D64(void);
static void sub_8124E0C(void);
// .rodata
@ -123,6 +130,7 @@ extern const struct {
extern const struct SpritePalette gUnknown_085A1F10;
extern const u16 gUnknown_085A1F18[][2];
extern const struct SpriteTemplate gUnknown_085A1F7C;
extern const u8 gUnknown_085A1E3C[][3];
// .text
@ -1559,3 +1567,123 @@ static void sub_8124BE4(void)
}
}
}
static void sub_8124CBC(struct Sprite *sprite)
{
if (gUnknown_0203A148->regionMap.mapSecId == sprite->data0)
{
if (++ sprite->data1 > 16)
{
sprite->data1 = 0;
sprite->invisible = sprite->invisible ? FALSE : TRUE;
}
}
else
{
sprite->data1 = 16;
sprite->invisible = FALSE;
}
}
static void sub_8124D14(void)
{
switch (gUnknown_0203A148->unk_004)
{
case 0:
BeginNormalPaletteFade(-1, 0, 16, 0, 0);
gUnknown_0203A148->unk_004 ++;
break;
case 1:
if (!UpdatePaletteFade())
{
sub_81248F4(sub_8124D64);
}
break;
}
}
static void sub_8124D64(void)
{
if (gUnknown_0203A148->unk_004 == 0)
{
switch (sub_81230AC())
{
case INPUT_EVENT_NONE:
case INPUT_EVENT_MOVE_START:
case INPUT_EVENT_MOVE_CONT:
break;
case INPUT_EVENT_MOVE_END:
sub_8124904();
break;
case INPUT_EVENT_A_BUTTON:
if (gUnknown_0203A148->regionMap.iconDrawType == MAPSECTYPE_CITY_CANFLY || gUnknown_0203A148->regionMap.iconDrawType == MAPSECTYPE_BATTLE_FRONTIER)
{
m4aSongNumStart(SE_SELECT);
gUnknown_0203A148->unk_a72 = TRUE;
sub_81248F4(sub_8124E0C);
}
break;
case INPUT_EVENT_B_BUTTON:
m4aSongNumStart(SE_SELECT);
gUnknown_0203A148->unk_a72 = FALSE;
sub_81248F4(sub_8124E0C);
break;
}
}
}
static void sub_8124E0C(void)
{
switch (gUnknown_0203A148->unk_004)
{
case 0:
BeginNormalPaletteFade(-1, 0, 0, 16, 0);
gUnknown_0203A148->unk_004 ++;
break;
case 1:
if (!UpdatePaletteFade())
{
FreeRegionMapIconResources();
if (gUnknown_0203A148->unk_a72)
{
switch (gUnknown_0203A148->regionMap.mapSecId)
{
case MAPSEC_SOUTHERN_ISLAND:
sub_8084CCC(0x15);
break;
case MAPSEC_BATTLE_FRONTIER:
sub_8084CCC(0x16);
break;
case MAPSEC_LITTLEROOT_TOWN:
sub_8084CCC(gSaveBlock2Ptr->playerGender == MALE ? 0x0C : 0x0D);
break;
case MAPSEC_EVER_GRANDE_CITY:
sub_8084CCC(FlagGet(SYS_POKEMON_LEAGUE_FLY) && gUnknown_0203A148->regionMap.posWithinMapSec == 0 ? 0x14 : 0x0B);
break;
default:
if (gUnknown_085A1E3C[gUnknown_0203A148->regionMap.mapSecId][2] != 0)
{
sub_8084CCC(gUnknown_085A1E3C[gUnknown_0203A148->regionMap.mapSecId][2]);
}
else
{
warp1_set_2(gUnknown_085A1E3C[gUnknown_0203A148->regionMap.mapSecId][0], gUnknown_085A1E3C[gUnknown_0203A148->regionMap.mapSecId][1], -1);
}
break;
}
sub_80B69DC();
}
else
{
SetMainCallback2(sub_81B58A8);
}
if (gUnknown_0203A148 != NULL)
{
free(gUnknown_0203A148);
gUnknown_0203A148 = NULL;
}
FreeAllWindowBuffers();
}
break;
}
}