How Expand Map Names Table
2.12
Unfortunately this is limited to "only" 55 new entries in the table, I (think to have) thoroughly checked if there could be a way to expand it more but long story short it's not possible, unless you make a couple "drastic" changes a la CFRU but then HMA won't read some data properly, thus setting a map's name would become a bit complicated.
Knowing that Hoenn has 86 map sections, Kanto has 55 and Sevii Islands have 54, you should be able to add a new map region to your romhack!
Credits
Defa
I apologize for the many steps needed, expanding map names is this complicated! -Defa
Step 1
Go to data.maps.names ( 3F1CAC ) Click Add 1 New
Click Repoint this one
Leave its name blank. DO NOT use this entry for map names. Subsequent entries are safe to use.
Step 2
To add a new map name, click Add 1 New
Click Repoint this one and set a name
Step 3
Go to 13B83C
Select 8 bytes and click on the Insert Thumb Hook button on the left (change Code Type to Thumb if you dont see it)
You will be moved to free space with an ASM routine on the left
Delete that routine and place the following routine one in its place
ldr r1, =(0x0813B84F)
mov r14, r1
mov r1, #168
lsl r1, r1, #24
add r0, r0, r1
lsr r0, r0, #24
cmp r0, #165
bhs false
cmp r0, #109
beq false
mov r0, #1
b end
false:
mov r0, #0
end:
bx r14Step 4
Go to 0C4D8A and change 6C to A4
Step 5
Go to graphics.townmap.catchmap.shape ( 463580 ) Click Add 1 New
Note the index of the entry you just added
NOTE: you will have to experiment with shape, x and y, you have to find the values that will make the red circle appear in the correct spot on the map shown by the Pokédex when examining the habitat of a Pokémon
See Guide 5.20 on how to edit the catchmap
Step 6
Go to graphics.townmap.catchmap.conversion.kanto ( 464148 )
Click Add 1 New
Choose the new map name and set the catchmap field to the index noted in Step 5
Step 7
Go to graphics.townmap.annotations.kanto ( 3F2490 )
Add your new map name in all sections covered by that map
NOTE:
If it is a Town/Route, change the sections in the map layer (upper map)
If it is a Dungeon, change the sections on the dungeon layer (lower map)
Step 8
Go to data.maps.names
Select the new map name at the bottom
On the left, change the following parameters:
fly.connections
Set all 3 fields to 0
They will automatically update if you add a Fly spot in the map
namesoverlay.widthheight
These should correspond to the number of map sections occupied by the new map from Step 7
NOTE: Town/Cities have 1-1, Routes have one field set to 1 and the other is equal to the occupied section (one row or one column)
namesoverlay.xy
These coordinates correspond to the top-left most/left most map section from Step 7
Step 9
Go to free space and add the following anchor:
^data.xpnmapnames[map.data.maps.names region. flag:|h x: y:]1Every time you add a new map name, add an entry to this table
map: the new map name you assign the other fields to
region: number corresponding to region map (what page of the town map this will show up on)
0 = Kanto
1 = Sevii 1-2-3
2 = Sevii 4-5
3 = Sevii 6-7
flag: world map flag assigned to the map
World map flags are used for Town/City and dungeon maps
Add a Transition map script and add setworldmapflag 0xAAAA where AAAA is the value set in this field
If you want to use consecutive unused flags, you can start from 08C3 (https://github.com/pret/pokefirered/blob/bf6bfbd2ed5ead6319cb8efcb537ac14d2b128d7/include/constants/flags.h#L1464)
This is also used to determine whether Fly is unlocked for this map
DO NOT use the flag for anything else!
x,y: player icon position override
Normally the player icon is position automatically when opening the town map or Fly map, but there are overrides for some vanilla maps
Usually you need an override for dungeon maps and maps that have a name not set in any map section in graphics.townmap.annotations
Set both fields to 0 if you do not need an override
Step 10
Go to free space and add the following routine
Note the offset
ldr r4, =(0x080C0071)
mov r14, r4
cmp r0, #198
bge expanded
ldr r4, =(0x083F1AA4)
mov r12, r4
mov r10, r12
mov r9, r2
bx r14
expanded:
sub r0, r0, #88 @MAPSECS_KANTO
ldr r1, emn
loop:
ldrb r2, [r1]
cmp r2, #255 @FF byte, table end
beq failsafe
cmp r0, r2
beq match
add r1, r1, #8 @next row
b loop
failsafe:
mov r7, #0 @REGIONMAP_KANTO
b end
match:
ldrb r7, [r1, #1] @region field
end:
ldr r6, =(0x080C00D9)
bx r6
emn: .word <data.xpnmapnames>Go to 0C0068 and change 14 4C A4 46 E2 46 91 46 to 00 4C 20 47 XX XX XX 08
XX XX XX is the noted offset +1 in little endian
Step 11
Go to free space and add the following routine
Note the offset
push {lr}
lsl r0, r0, #24
lsr r0, r0, #24
sub r0, r0, #88
cmp r0, #109
bls switch
b expanded
switch:
lsl r0, r0, #2
ldr r1, =(0x080C35F8) @switch-case
add r0, r0, r1
ldr r0, [r0, #0]
mov r15, r0
expanded:
ldr r1, emn
loop:
ldrb r2, [r1]
cmp r2, #255 @FF byte, table end
beq back
cmp r0, r2
beq match
add r1, r1, #8 @next row
b loop
match:
ldrh r0, [r1, #2] @flag field
cmp r0, #0 @is a Route
beq back
ldr r1, =(0x080C385B) @back to FlagGet
bx r1
back:
ldr r1, =(0x080C3871) @back to default switch-case
bx r1
emn: .word <data.xpnmapnames>Go to 0C35DC and change 00 B5 00 06 00 0E 58 38 to 00 49 08 47 XX XX XX 08 XX XX XX is the noted offset +1 in little endian
Step 12
Go to free space and add the following routine
Note the offset
push {lr}
lsl r0, r0, #24
lsr r0, r0, #24
sub r0, r0, #126
cmp r0, #71
bls switch
b expanded
switch:
lsl r0, r0, #2
ldr r1, =(0x080C3894) @switch-case
add r0, r0, r1
ldr r0, [r0, #0]
mov r15, r0
expanded:
add r0, r0, #38 @-126 above becomes -88, MAPSECS_KANTO
ldr r1, emn
loop:
ldrb r2, [r1]
cmp r2, #255 @FF byte, table end
beq back
cmp r0, r2
beq match
add r1, r1, #8 @next row
b loop
match:
ldrh r0, [r1, #2] @flag field
ldr r1, =(0x080C3AAB) @back to FlagGet
bx r1
back:
ldr r1, =(0x080C3AC1) @back to default switch-case
bx r1
emn: .word <data.xpnmapnames>Go to 0C3878 and change 00 B5 00 06 00 0E 7E 38 to 00 49 08 47 XX XX XX 08
XX XX XX is the noted offset +1 in little endian
Step 13
Go to free space and add the following routine
Note the offset
push {r4-r5, lr}
ldr r3, =(0x080C3B01) @GetPlayerCurrentMapSectionId
bl linker
lsl r0, r0, #16
lsr r0, r0, #16
sub r0, r0, #102
cmp r0, #92
bls switch
b expanded
switch:
lsl r0, r0, #2
ldr r1, =(0x080C3D60)
add r0, r0, r1
ldr r0, [r0, #0]
mov r15, r0
expanded:
add r0, r0, #14 @-102 above becomes -88, MAPSECS_KANTO
ldr r1, emn
loop:
ldrb r2, [r1]
cmp r2, #255 @FF bye, table end
beq back
cmp r0, r2
bne next
ldrh r2, [r1, #4] @x field
ldrh r3, [r1, #6] @y field
cmp r2, #0
bne set
cmp r3, #0
bne set
b back
next:
add r1, r1, #8 @next row
b loop
set:
ldr r0, =(0x020399E4) @sMapCursor
ldr r1, [r0, #0]
strh r2, [r1, #0] @->x
strh r3, [r1, #2] @->y
ldr r3, =(0x080C4137) @back to after switch-case
bl linker
back:
ldr r3, =(0x080C4133) @back to default switch-case
linker: bx r3
emn: .word <data.xpnmapnames>Go to 0C3D40 and change 30 B5 FF F7 DD FE 00 04 to 00 4B 18 47 XX XX XX 08
XX XX XX is the noted offset +1 in little endian
Whenever you want to add a new map name, repeat steps 2, 5, 6, 7, 8, and 9 (in step 9 just add a new entry, not another anchor)
NOTE: at offsets 3F1CAC, 463580, and 464148 you will have free space due to repointed tables. Don't let this space go to waste!
NOTE: The index of the final entry allowed in data.maps.names will be 164
Happy Hacking!


