Merge pull request #422 from tgsm/map_header

Document more of map_header
This commit is contained in:
Akira Akashi
2021-07-04 20:43:35 +01:00
committed by GitHub
17 changed files with 107 additions and 91 deletions
+2 -2
View File
@@ -341,7 +341,7 @@ _0203529A:
_020352AC:
ldr r0, [r5, #0x1c]
ldr r0, [r0, #0x0]
bl FUN_020349CC
bl MapHeader_MapIsAmitySquare
cmp r0, #0x1
bne _020352BC
mov r0, #0x6
@@ -2145,7 +2145,7 @@ _02036170:
add r7, r0, #0x0
ldr r0, [r5, #0x1c]
ldr r0, [r0, #0x0]
bl FUN_02034A04
bl MapHeader_GetMapEvolutionMethod
strh r0, [r7, #0x2]
mov r0, #0x0
strb r0, [r7, #0x1]
+2 -2
View File
@@ -536,7 +536,7 @@ FUN_02047A78: ; 0x02047A78
str r0, [r5, r1]
ldr r0, [r4, #0x1c]
ldr r0, [r0, #0x0]
bl FUN_02034A04
bl MapHeader_GetMapEvolutionMethod
mov r1, #0x59
lsl r1, r1, #0x2
str r0, [r5, r1]
@@ -1161,7 +1161,7 @@ FUN_0204806C: ; 0x0204806C
add r6, r0, #0x0
ldr r0, [r4, #0x1c]
ldr r0, [r0, #0x0]
bl MapHeader_GetField17_0
bl MapHeader_GetBattleBg
mov r1, #0x15
lsl r1, r1, #0x4
str r0, [r5, r1]
+2 -2
View File
@@ -506,7 +506,7 @@ FUN_02048CDC: ; 0x02048CDC
add r4, r0, #0x0
ldr r0, [r4, #0x1c]
ldr r0, [r0, #0x0]
bl FUN_020349E4
bl MapHeader_MapIsPokemonCenterSecondFloor
cmp r0, #0x0
beq _02048CFE
ldr r1, [r4, #0x1c]
@@ -860,7 +860,7 @@ FUN_02048FC8: ; 0x02048FC8
add r4, r0, #0x0
ldr r0, [r4, #0x1c]
ldr r0, [r0, #0x0]
bl FUN_02034998
bl MapHeader_MapIsUnionRoom
cmp r0, #0x0
bne _02049000
add r0, r4, #0x0
+4 -4
View File
@@ -440,7 +440,7 @@ FUN_0205D170: ; 0x0205D170
pop {r3-r5, pc}
_0205D184:
ldr r0, [r5, #0x0]
bl MapHeader_MapIsOnOverworldMatrix
bl MapHeader_MapIsOnMainMatrix
cmp r0, #0x0
bne _0205D194
mov r0, #0x0
@@ -1178,7 +1178,7 @@ _0205D730: .word 0x000022F6
FUN_0205D734: ; 0x0205D734
push {r3, lr}
ldr r0, [r0, #0x0]
bl MapHeader_MapIsOnOverworldMatrix
bl MapHeader_MapIsOnMainMatrix
cmp r0, #0x0
beq _0205D744
mov r0, #0x0
@@ -1595,7 +1595,7 @@ _0205DA8E:
cmp r0, #0x1
bne _0205DAA6
ldr r0, [r4, #0x0]
bl MapHeader_GetField17_6
bl MapHeader_IsEscapeRopeAllowed
cmp r0, #0x1
bne _0205DAA6
mov r0, #0x0
@@ -1675,7 +1675,7 @@ _0205DB1A:
pop {r3-r5, pc}
_0205DB30:
ldr r0, [r4, #0x0]
bl FUN_020349D8
bl MapHeader_MapIsSpearPillar
cmp r0, #0x0
beq _0205DB3E
mov r0, #0x0
+1 -1
View File
@@ -55,7 +55,7 @@ FUN_0205F7A0: ; 0x0205F7A0
asr r1, r1, #0x5
asr r2, r2, #0x5
bl FUN_0203451C
bl MapHeader_MapIsOnOverworldMatrix
bl MapHeader_MapIsOnMainMatrix
cmp r0, #0x0
beq _0205F806
str r4, [r5, #0x0]
+1 -1
View File
@@ -122,7 +122,7 @@ _0206377C:
_02063786:
ldr r0, [r5, #0x1c]
ldr r0, [r0, #0x0]
bl MapHeader_MapIsOnOverworldMatrix
bl MapHeader_MapIsOnMainMatrix
cmp r0, #0x0
beq _020637A6
ldr r0, [r5, #0xc]
+1 -1
View File
@@ -1129,7 +1129,7 @@ _020641BE:
cmp r0, #0x1
bne _020641D2
ldr r0, [r4, #0x0]
bl MapHeader_GetField17_6
bl MapHeader_IsEscapeRopeAllowed
cmp r0, #0x1
beq _020641D6
_020641D2:
+1 -1
View File
@@ -2248,7 +2248,7 @@ _02076814:
ldr r0, [r0, #0x1c]
ldr r0, [r0, #0x1c]
ldr r0, [r0, #0x0]
bl FUN_02034A04
bl MapHeader_GetMapEvolutionMethod
add r3, r0, #0x0
ldr r0, _02076878 ; =0x000005A4
lsl r3, r3, #0x10
+10 -10
View File
@@ -2504,23 +2504,23 @@
.extern MapHeader_GetMapSec
.extern MapHeader_GetWeatherType
.extern MapHeader_GetCameraType
.extern MapHeader_GetField17_0
.extern MapHeader_GetField17_6
.extern MapHeader_GetBattleBg
.extern MapHeader_IsEscapeRopeAllowed
.extern MapHeader_IsFlyAllowed
.extern MapHeader_IsBikeAllowed
.extern FUN_020348E4
.extern MapHeader_MapIsOnOverworldMatrix
.extern MapHeader_MapIsOnMainMatrix
.extern FUN_02034930
.extern FUN_02034944
.extern FUN_02034964
.extern FUN_02034984
.extern FUN_02034998
.extern FUN_020349AC
.extern FUN_020349B8
.extern FUN_020349CC
.extern FUN_020349D8
.extern FUN_020349E4
.extern FUN_02034A04
.extern MapHeader_MapIsUnionRoom
.extern MapHeader_MapIsMtCoronetFeebasRoom
.extern MapHeader_MapIsTrophyGarden
.extern MapHeader_MapIsAmitySquare
.extern MapHeader_MapIsSpearPillar
.extern MapHeader_MapIsPokemonCenterSecondFloor
.extern MapHeader_GetMapEvolutionMethod
.extern FUN_02034A28
.extern FUN_02034A48
.extern FUN_02034A60
+1 -1
View File
@@ -542,7 +542,7 @@ MOD05_021D79B4: ; 0x021D79B4
add r5, r0, #0
ldr r0, [r5, #0x1c]
ldr r0, [r0]
bl MapHeader_MapIsOnOverworldMatrix
bl MapHeader_MapIsOnMainMatrix
cmp r0, #0
beq _021D79FE
ldr r0, [r5, #0xc]
+4 -4
View File
@@ -2216,11 +2216,11 @@ MOD05_021D9290: ; 0x021D9290
beq _021D92DA
ldr r0, [r4, #0x1c]
ldr r0, [r0]
bl MapHeader_MapIsOnOverworldMatrix
bl MapHeader_MapIsOnMainMatrix
cmp r0, #1
bne _021D931C
ldr r0, [sp, #8]
bl MapHeader_MapIsOnOverworldMatrix
bl MapHeader_MapIsOnMainMatrix
cmp r0, #0
bne _021D931C
ldr r0, [r4, #0x38]
@@ -2246,11 +2246,11 @@ _021D92DA:
beq _021D931C
ldr r0, [r4, #0x1c]
ldr r0, [r0]
bl MapHeader_MapIsOnOverworldMatrix
bl MapHeader_MapIsOnMainMatrix
cmp r0, #1
bne _021D931C
ldr r0, [sp, #8]
bl MapHeader_MapIsOnOverworldMatrix
bl MapHeader_MapIsOnMainMatrix
cmp r0, #0
bne _021D931C
ldr r0, [r4, #0x38]
+2 -2
View File
@@ -4775,7 +4775,7 @@ MOD06_0223B9A8: ; 0x0223B9A8
ldr r0, [r0]
add r6, r2, #0
add r7, r3, #0
bl FUN_020349B8
bl MapHeader_MapIsTrophyGarden
cmp r0, #0
beq _0223B9FC
add r1, sp, #0
@@ -5248,7 +5248,7 @@ _0223BD8A:
ldr r0, [sp, #8]
ldr r0, [r0, #0x1c]
ldr r0, [r0]
bl FUN_020349AC
bl MapHeader_MapIsMtCoronetFeebasRoom
cmp r0, #0
beq _0223BDFC
ldr r0, [sp, #8]
+1 -1
View File
@@ -5037,7 +5037,7 @@ MOD07_02214720: ; 0x02214720
mov r0, #0x57
lsl r0, r0, #2
ldr r0, [r1, r0]
bl FUN_02034998
bl MapHeader_MapIsUnionRoom
cmp r0, #1
bne _0221479C
mov r0, #1
+2 -2
View File
@@ -139,7 +139,7 @@ _02254932:
add r6, r0, #0
ldr r0, [r4, #0x1c]
ldr r0, [r0]
bl MapHeader_MapIsOnOverworldMatrix
bl MapHeader_MapIsOnMainMatrix
cmp r0, #0
beq _02254984
ldr r0, [r4, #0x1c]
@@ -527,7 +527,7 @@ MOD42_02254C04: ; 0x02254C04
add r6, r0, #0
ldr r0, [r4, #0x1c]
ldr r0, [r0]
bl MapHeader_MapIsOnOverworldMatrix
bl MapHeader_MapIsOnMainMatrix
cmp r0, #0
beq _02254C3C
ldr r1, [r4, #0x1c]
+2 -2
View File
@@ -62,7 +62,7 @@ MOD43_0225489C: ; 0x0225489C
add r6, r0, #0
ldr r0, [r4, #0x1c]
ldr r0, [r0]
bl MapHeader_MapIsOnOverworldMatrix
bl MapHeader_MapIsOnMainMatrix
cmp r0, #0
beq _022548E0
ldr r0, [r4, #0x1c]
@@ -395,7 +395,7 @@ MOD43_02254AF8: ; 0x02254AF8
add r7, r0, #0
ldr r0, [r4, #0x1c]
ldr r0, [r0]
bl MapHeader_MapIsOnOverworldMatrix
bl MapHeader_MapIsOnMainMatrix
cmp r0, #0
beq _02254B36
ldr r1, [r4, #0x1c]
+58 -42
View File
@@ -1,39 +1,55 @@
#include "global.h"
#include "map_header.h"
#include "constants/map_sections.h"
#include "pokemon.h"
#pragma thumb on
// Static decls
u32 MapNumberBoundsCheck(u32 mapno);
const u16 UNK_020EED54[] = {
0x01A5, 0x01AD, 0x01B4, 0x01BC, 0x01C5, 0x01CC, 0x0007, 0x0025,
0x0031, 0x01EF, 0x0046, 0x0066, 0x007C, 0x0087, 0x0098, 0x00A9,
0x00AE, 0x00BE
static const u16 sPokemonCenterSecondFloorMaps[] = {
421,
429,
436,
444,
453,
460,
7,
37,
49,
495,
70,
102,
124,
135,
152,
169,
174,
190
};
const u16 UNK_020EED78[] = {
0x0181, 0x001A,
0x00CB, 0x0019,
0x00CF, 0x0018,
0x00D0, 0x0018,
0x00D1, 0x0018,
0x00D2, 0x0018,
0x00D3, 0x0018,
0x00D4, 0x0018,
0x00D5, 0x0018,
0x00D6, 0x0018,
0x00D7, 0x0018,
0x00D8, 0x0018,
0x00D9, 0x0018,
0x00DA, 0x0018,
0x00DB, 0x0018,
0x00DC, 0x0018,
0x00DD, 0x0018,
static const u16 sMapEvolutionMethods[] = {
385, EVO_ROUTE217,
203, EVO_ETERNA,
207, EVO_CORONET,
208, EVO_CORONET,
209, EVO_CORONET,
210, EVO_CORONET,
211, EVO_CORONET,
212, EVO_CORONET,
213, EVO_CORONET,
214, EVO_CORONET,
215, EVO_CORONET,
216, EVO_CORONET,
217, EVO_CORONET,
218, EVO_CORONET,
219, EVO_CORONET,
220, EVO_CORONET,
221, EVO_CORONET,
};
const struct MapHeader sMapHeaders[] = {
static const struct MapHeader sMapHeaders[] = {
{ 0x0, 0x0, 0x0, 0x170, 0x33b, 0x12, 0x3e8, 0x3e8, 0xffff, 0x0, MAPSEC_MYSTERY_ZONE, 0x0, 0x0, 0x2, 3, TRUE, TRUE, TRUE, FALSE },
{ 0x0, 0x0, 0x0, 0x170, 0x33b, 0x12, 0x3e8, 0x3e8, 0xffff, 0x0, MAPSEC_MYSTERY_ZONE, 0x0, 0x0, 0x0, 3, FALSE, FALSE, FALSE, FALSE },
{ 0x2, 0x2, 0x2, 0x413, 0x3ca, 0x236, 0x424, 0x424, 0xffff, 0x1, MAPSEC_MYSTERY_ZONE, 0x0, 0x0, 0x6, 3, FALSE, FALSE, FALSE, FALSE },
@@ -694,16 +710,16 @@ u8 MapHeader_GetCameraType(u32 mapno)
return sMapHeaders[mapno].camera_type;
}
u8 MapHeader_GetField17_0(u32 mapno)
u8 MapHeader_GetBattleBg(u32 mapno)
{
mapno = MapNumberBoundsCheck(mapno);
return sMapHeaders[mapno].unk17_0;
return sMapHeaders[mapno].battle_bg;
}
u8 MapHeader_GetField17_6(u32 mapno)
u8 MapHeader_IsEscapeRopeAllowed(u32 mapno)
{
mapno = MapNumberBoundsCheck(mapno);
return sMapHeaders[mapno].unk17_6;
return sMapHeaders[mapno].is_escape_rope_allowed;
}
u8 MapHeader_IsFlyAllowed(u32 mapno)
@@ -733,7 +749,7 @@ BOOL FUN_020348E4(u32 mapno)
return FALSE;
}
BOOL MapHeader_MapIsOnOverworldMatrix(u32 mapno)
BOOL MapHeader_MapIsOnMainMatrix(u32 mapno)
{
return MapHeader_GetMatrixId(mapno) == 0;
}
@@ -760,56 +776,56 @@ BOOL FUN_02034964(u32 mapno)
BOOL FUN_02034984(u32 mapno)
{
return !!FUN_0203491C(mapno);
return FUN_0203491C(mapno) != FALSE;
}
BOOL FUN_02034998(u32 mapno)
BOOL MapHeader_MapIsUnionRoom(u32 mapno)
{
return mapno == 466;
}
BOOL FUN_020349AC(u32 mapno)
BOOL MapHeader_MapIsMtCoronetFeebasRoom(u32 mapno)
{
return mapno == 219;
}
BOOL FUN_020349B8(u32 mapno)
BOOL MapHeader_MapIsTrophyGarden(u32 mapno)
{
return mapno == 287;
}
BOOL FUN_020349CC(u32 mapno)
BOOL MapHeader_MapIsAmitySquare(u32 mapno)
{
return mapno == 253;
}
BOOL FUN_020349D8(u32 mapno)
BOOL MapHeader_MapIsSpearPillar(u32 mapno)
{
return mapno == 220;
}
BOOL FUN_020349E4(u16 a0)
BOOL MapHeader_MapIsPokemonCenterSecondFloor(u32 mapno)
{
int i;
for (i = 0; i < NELEMS(UNK_020EED54); i++)
for (i = 0; i < NELEMS(sPokemonCenterSecondFloorMaps); i++)
{
if (a0 == UNK_020EED54[i])
if (mapno == sPokemonCenterSecondFloorMaps[i])
return TRUE;
}
return FALSE;
}
u16 FUN_02034A04(u16 a0)
u16 MapHeader_GetMapEvolutionMethod(u32 mapno)
{
int i;
for (i = 0; i < NELEMS(UNK_020EED78); i += 2)
for (i = 0; i < NELEMS(sMapEvolutionMethods); i += 2)
{
if (a0 == UNK_020EED78[i + 0])
return UNK_020EED78[i + 1];
if (mapno == sMapEvolutionMethods[i + 0])
return sMapEvolutionMethods[i + 1];
}
return 0;
return EVO_NONE;
}
+13 -13
View File
@@ -17,10 +17,10 @@ struct MapHeader
u8 weather_type;
u8 camera_type;
u8 unk16;
u8 unk17_0:4;
u8 battle_bg:4;
u8 is_bike_allowed:1;
u8 unk17_5:1;
u8 unk17_6:1;
u8 is_running_allowed:1; // unused
u8 is_escape_rope_allowed:1;
u8 is_fly_allowed:1;
};
@@ -38,24 +38,24 @@ u16 MapHeader_GetEventsBank(u32 mapno);
u16 MapHeader_GetMapSec(u32 mapno);
u8 MapHeader_GetWeatherType(u32 mapno);
u8 MapHeader_GetCameraType(u32 mapno);
u8 MapHeader_GetField17_0(u32 mapno);
u8 MapHeader_GetField17_6(u32 mapno);
u8 MapHeader_GetBattleBg(u32 mapno);
u8 MapHeader_IsEscapeRopeAllowed(u32 mapno);
u8 MapHeader_IsFlyAllowed(u32 mapno);
u8 MapHeader_IsBikeAllowed(u32 mapno);
u8 MapHeader_GetField16(u32 mapno);
BOOL FUN_020348E4(u32 mapno);
BOOL MapHeader_MapIsOnOverworldMatrix(u32 mapno);
BOOL MapHeader_MapIsOnMainMatrix(u32 mapno);
BOOL FUN_0203491C(u32 mapno);
BOOL FUN_02034930(u32 mapno);
BOOL FUN_02034944(u32 mapno);
BOOL FUN_02034964(u32 mapno);
BOOL FUN_02034984(u32 mapno);
BOOL FUN_02034998(u32 mapno);
BOOL FUN_020349AC(u32 mapno);
BOOL FUN_020349B8(u32 mapno);
BOOL FUN_020349CC(u32 mapno);
BOOL FUN_020349D8(u32 mapno);
BOOL FUN_020349E4(u16 a0);
u16 FUN_02034A04(u16 a0);
BOOL MapHeader_MapIsUnionRoom(u32 mapno);
BOOL MapHeader_MapIsMtCoronetFeebasRoom(u32 mapno);
BOOL MapHeader_MapIsTrophyGarden(u32 mapno);
BOOL MapHeader_MapIsAmitySquare(u32 mapno);
BOOL MapHeader_MapIsSpearPillar(u32 mapno);
BOOL MapHeader_MapIsPokemonCenterSecondFloor(u32 mapno);
u16 MapHeader_GetMapEvolutionMethod(u32 mapno);
#endif //POKEDIAMOND_MAP_HEADER_H