through GetRegionMapSectionIdAt

This commit is contained in:
PikalaxALT
2017-10-30 08:58:43 -04:00
parent f6a55433a2
commit c324722987
4 changed files with 49 additions and 92 deletions
+1 -1
View File
@@ -10886,7 +10886,7 @@ sub_81CC6A4: @ 81CC6A4
bl TransferPlttBuffer bl TransferPlttBuffer
bl LoadOam bl LoadOam
bl ProcessSpriteCopyRequests bl ProcessSpriteCopyRequests
bl sub_81237B4 bl UpdateRegionMapVideoRegs
pop {r0} pop {r0}
bx r0 bx r0
thumb_func_end sub_81CC6A4 thumb_func_end sub_81CC6A4
+3 -77
View File
@@ -5,80 +5,6 @@
.text .text
thumb_func_start sub_8123824
sub_8123824: @ 8123824
push {r4,r5,lr}
sub sp, 0xC
lsls r0, 16
asrs r4, r0, 16
lsls r1, 16
asrs r5, r1, 16
movs r0, 0x80
lsls r0, 1
str r0, [sp]
str r0, [sp, 0x4]
movs r0, 0
str r0, [sp, 0x8]
adds r0, r4, 0
adds r1, r5, 0
movs r2, 0x38
movs r3, 0x48
bl CalcZoomScrollParams
bl sub_81237B4
ldr r0, =gRegionMap
ldr r2, [r0]
ldr r1, [r2, 0x20]
cmp r1, 0
beq _08123860
negs r0, r4
strh r0, [r1, 0x24]
ldr r1, [r2, 0x20]
negs r0, r5
strh r0, [r1, 0x26]
_08123860:
add sp, 0xC
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end sub_8123824
thumb_func_start sub_812386C
sub_812386C: @ 812386C
push {lr}
lsls r0, 16
lsrs r3, r0, 16
lsls r1, 16
ldr r0, =0xfffe0000
adds r1, r0
lsrs r2, r1, 16
cmp r2, 0xE
bhi _08123886
cmp r3, 0
beq _08123886
cmp r3, 0x1C
bls _08123890
_08123886:
movs r0, 0xD5
b _081238A4
.pool
_08123890:
subs r0, r3, 0x1
lsls r0, 16
lsrs r3, r0, 16
ldr r1, =gUnknown_085A096C
lsls r0, r2, 3
subs r0, r2
lsls r0, 2
adds r0, r3, r0
adds r0, r1
ldrb r0, [r0]
_081238A4:
pop {r1}
bx r1
.pool
thumb_func_end sub_812386C
thumb_func_start sub_81238AC thumb_func_start sub_81238AC
sub_81238AC: @ 81238AC sub_81238AC: @ 81238AC
push {r4-r7,lr} push {r4-r7,lr}
@@ -826,7 +752,7 @@ sub_8123E9C: @ 8123E9C
lsrs r0, 16 lsrs r0, 16
lsls r1, 16 lsls r1, 16
lsrs r1, 16 lsrs r1, 16
bl sub_812386C bl GetRegionMapSectionIdAt
lsls r0, 16 lsls r0, 16
lsrs r0, 16 lsrs r0, 16
pop {r1} pop {r1}
@@ -1007,7 +933,7 @@ _08123FE6:
lsrs r4, r0, 16 lsrs r4, r0, 16
adds r0, r4, 0 adds r0, r4, 0
adds r1, r5, 0 adds r1, r5, 0
bl sub_812386C bl GetRegionMapSectionIdAt
ldr r1, =gRegionMap ldr r1, =gRegionMap
ldr r1, [r1] ldr r1, [r1]
lsls r0, 16 lsls r0, 16
@@ -1063,7 +989,7 @@ _08124058:
_0812405A: _0812405A:
adds r0, r4, 0 adds r0, r4, 0
adds r1, r5, 0 adds r1, r5, 0
bl sub_812386C bl GetRegionMapSectionIdAt
ldr r1, =gRegionMap ldr r1, =gRegionMap
ldr r1, [r1] ldr r1, [r1]
lsls r0, 16 lsls r0, 16
+2 -1
View File
@@ -218,7 +218,8 @@ enum {
MAPSEC_DESERT_UNDERPASS, MAPSEC_DESERT_UNDERPASS,
MAPSEC_ALTERING_CAVE_2, MAPSEC_ALTERING_CAVE_2,
MAPSEC_NAVEL_ROCK2, MAPSEC_NAVEL_ROCK2,
MAPSEC_TRAINER_HILL MAPSEC_TRAINER_HILL,
MAPSEC_NONE2
}; };
struct RegionMap { struct RegionMap {
+43 -13
View File
@@ -8,6 +8,13 @@
#include "trig.h" #include "trig.h"
#include "region_map.h" #include "region_map.h"
#define MAP_WIDTH 28
#define MAP_HEIGHT 15
#define MAPCURSOR_X_MIN 1
#define MAPCURSOR_Y_MIN 2
#define MAPCURSOR_X_MAX (MAPCURSOR_X_MIN + MAP_WIDTH - 1)
#define MAPCURSOR_Y_MAX (MAPCURSOR_Y_MIN + MAP_HEIGHT - 1)
// Static type declarations // Static type declarations
struct UnkStruct_0203A148 { struct UnkStruct_0203A148 {
@@ -26,12 +33,12 @@ static u8 MoveRegionMapCursor_Full(void);
static u8 ProcessRegionMapInput_Zoomed(void); static u8 ProcessRegionMapInput_Zoomed(void);
static u8 MoveRegionMapCursor_Zoomed(void); static u8 MoveRegionMapCursor_Zoomed(void);
void CalcZoomScrollParams(s16 scrollX, s16 scrollY, s16 c, s16 d, u16 e, u16 f, u8 rotation); void CalcZoomScrollParams(s16 scrollX, s16 scrollY, s16 c, s16 d, u16 e, u16 f, u8 rotation);
void sub_81237B4(void); void UpdateRegionMapVideoRegs(void);
void sub_81238AC(void); void sub_81238AC(void);
u8 get_flagnr_blue_points(u16 mapSecId); u8 get_flagnr_blue_points(u16 mapSecId);
u16 sub_8123EB4(u16 mapSecId); u16 sub_8123EB4(u16 mapSecId);
void sub_8123FB0(void); void sub_8123FB0(void);
u16 sub_812386C(u16 x, u16 y); u16 GetRegionMapSectionIdAt(u16 x, u16 y);
void sub_812378C(s16 x, s16 y); void sub_812378C(s16 x, s16 y);
void sub_8124238(void); void sub_8124238(void);
void sub_81243B0(void); void sub_81243B0(void);
@@ -39,11 +46,12 @@ void sub_81243DC(void);
// .rodata // .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_0859F60C[];
extern const u8 gUnknown_0859F650[]; extern const u8 gUnknown_0859F650[];
extern const u16 gUnknown_0859F73C[];
extern const u8 gUnknown_0859F77C[];
extern const u8 gUnknown_085A04E0[];
extern const u8 gUnknown_085A096C[];
// .text // .text
@@ -146,7 +154,7 @@ bool8 sub_8122DB0(void)
break; break;
case 7: case 7:
sub_8123FB0(); sub_8123FB0();
sub_81237B4(); UpdateRegionMapVideoRegs();
gRegionMap->cursorSprite = NULL; gRegionMap->cursorSprite = NULL;
gRegionMap->playerIconSprite = NULL; gRegionMap->playerIconSprite = NULL;
gRegionMap->cursorMovementFrameCounter = 0; gRegionMap->cursorMovementFrameCounter = 0;
@@ -202,22 +210,22 @@ static u8 ProcessRegionMapInput_Full(void)
input = INPUT_EVENT_NONE; input = INPUT_EVENT_NONE;
gRegionMap->cursorDeltaX = 0; gRegionMap->cursorDeltaX = 0;
gRegionMap->cursorDeltaY = 0; gRegionMap->cursorDeltaY = 0;
if (gMain.heldKeys & DPAD_UP && gRegionMap->cursorPosY > 2) if (gMain.heldKeys & DPAD_UP && gRegionMap->cursorPosY > MAPCURSOR_Y_MIN)
{ {
gRegionMap->cursorDeltaY = -1; gRegionMap->cursorDeltaY = -1;
input = INPUT_EVENT_MOVE_START; input = INPUT_EVENT_MOVE_START;
} }
if (gMain.heldKeys & DPAD_DOWN && gRegionMap->cursorPosY < 16) if (gMain.heldKeys & DPAD_DOWN && gRegionMap->cursorPosY < MAPCURSOR_Y_MAX)
{ {
gRegionMap->cursorDeltaY = +1; gRegionMap->cursorDeltaY = +1;
input = INPUT_EVENT_MOVE_START; input = INPUT_EVENT_MOVE_START;
} }
if (gMain.heldKeys & DPAD_LEFT && gRegionMap->cursorPosX > 1) if (gMain.heldKeys & DPAD_LEFT && gRegionMap->cursorPosX > MAPCURSOR_X_MIN)
{ {
gRegionMap->cursorDeltaX = -1; gRegionMap->cursorDeltaX = -1;
input = INPUT_EVENT_MOVE_START; input = INPUT_EVENT_MOVE_START;
} }
if (gMain.heldKeys & DPAD_RIGHT && gRegionMap->cursorPosX < 28) if (gMain.heldKeys & DPAD_RIGHT && gRegionMap->cursorPosX < MAPCURSOR_X_MAX)
{ {
gRegionMap->cursorDeltaX = +1; gRegionMap->cursorDeltaX = +1;
input = INPUT_EVENT_MOVE_START; input = INPUT_EVENT_MOVE_START;
@@ -262,7 +270,7 @@ static u8 MoveRegionMapCursor_Full(void)
{ {
gRegionMap->cursorPosY --; gRegionMap->cursorPosY --;
} }
mapSecId = sub_812386C(gRegionMap->cursorPosX, gRegionMap->cursorPosY); mapSecId = GetRegionMapSectionIdAt(gRegionMap->cursorPosX, gRegionMap->cursorPosY);
gRegionMap->unk_002 = get_flagnr_blue_points(mapSecId); gRegionMap->unk_002 = get_flagnr_blue_points(mapSecId);
if (mapSecId != gRegionMap->mapSecId) if (mapSecId != gRegionMap->mapSecId)
{ {
@@ -335,7 +343,7 @@ static u8 MoveRegionMapCursor_Zoomed(void)
{ {
gRegionMap->unk_064 = x; gRegionMap->unk_064 = x;
gRegionMap->unk_066 = y; gRegionMap->unk_066 = y;
mapSecId = sub_812386C(x, y); mapSecId = GetRegionMapSectionIdAt(x, y);
gRegionMap->unk_002 = get_flagnr_blue_points(mapSecId); gRegionMap->unk_002 = get_flagnr_blue_points(mapSecId);
if (mapSecId != gRegionMap->mapSecId) if (mapSecId != gRegionMap->mapSecId)
{ {
@@ -477,7 +485,7 @@ void sub_812378C(s16 x, s16 y)
gRegionMap->needUpdateVideoRegs = TRUE; gRegionMap->needUpdateVideoRegs = TRUE;
} }
void sub_81237B4(void) void UpdateRegionMapVideoRegs(void)
{ {
if (gRegionMap->needUpdateVideoRegs) if (gRegionMap->needUpdateVideoRegs)
{ {
@@ -492,3 +500,25 @@ void sub_81237B4(void)
gRegionMap->needUpdateVideoRegs = FALSE; gRegionMap->needUpdateVideoRegs = FALSE;
} }
} }
void sub_8123824(s16 x, s16 y)
{
CalcZoomScrollParams(x, y, 0x38, 0x48, 0x100, 0x100, 0);
UpdateRegionMapVideoRegs();
if (gRegionMap->playerIconSprite != NULL)
{
gRegionMap->playerIconSprite->pos2.x = -x;
gRegionMap->playerIconSprite->pos2.y = -y;
}
}
u16 GetRegionMapSectionIdAt(u16 x, u16 y)
{
if (y < MAPCURSOR_Y_MIN || y > MAPCURSOR_Y_MAX || x < MAPCURSOR_X_MIN || x > MAPCURSOR_X_MAX)
{
return MAPSEC_NONE2;
}
y -= MAPCURSOR_Y_MIN;
x -= MAPCURSOR_X_MIN;
return gUnknown_085A096C[x + y * MAP_WIDTH];
}