# World Map Split The world map split consists of three routines (along with their hooks). ## World Map Loading Routine This routine changes the loading of the world map to account for the extra tilesets. Assemble and put into aligned freespace: ``` .text .align 2 .thumb .thumb_func .global worldtileset main: mov r0, #0x0 @ r0: table offset ldr r1, mapheader @ r1: map header ldrb r1, [r1, #0x14] cmp r1, #0x8E bls loadtileset mov r0, #0x4 ldr r2, maparrays loop: ldrb r3, [r2] cmp r3, #0xC5 beq next cmp r3, r1 beq loadtileset add r2, #0x1 b loop next: add r0, #0x4 cmp r0, #0x8 bgt loadtileset add r2, #0x1 b loop loadtileset: ldr r1, table ldr r1, [r1, r0] mov r4, #0x0 @ restore original code str r4, [sp] mov r0, #0x0 mov r2, #0x0 ldr r3, return bx r3 .align 2 mapheader: .word 0x02036DFC maparrays: .word 0x083F1AA4 table: .word 0x08FFFFFF return: .word 0x080C030D ``` You should point the `FF FF FF 08` in the assembled code to a table of 4 pointers (one for each tileset). Hook: `00 48 00 47 FF FF FF 08` at `080C0304`, where `FF FF FF 08` is the pointer to the routine + 1. ## Town Map Loading Routine This routine hooks into switching pages of the town map. Assemble and put into aligned freespace: ``` .text .align 2 .thumb .thumb_func .global townmap main: ldr r3, return push {r3} ldr r2, key1 ldr r5, key2 ldr r0, [r5] ldr r4, constant add r0, r4 ldrb r0, [r0] push {r0-r2} ldr r2, table lsl r0, #0x2 add r0, r2 ldr r0, [r0] ldr r1, vram swi 0x12 pop {r0-r2, pc} .align 2 key1: .word 0x020399D4 key2: .word 0x020399D8 constant: .word 0x1CCA table: .word 0x08FFFFFF vram: .word 0x06000000 return: .word 0x080C1615 ``` You should point the `FF FF FF 08` in the assembled code to the same table. Make triple sure all the pointers are correct, because this calls `swi 0x12` directly and will probably kill the GBA if a tileset is missing or not compressed. Hook: `00 4D 28 47 FF FF FF 08` at `080C1608`, where `FF FF FF 08` is the pointer to the routine + 1. ## Town Map Cancel Routine This routine swaps in the original tileset when you cancel page switching with the B button. Assemble and put into aligned freespace: ``` .text .align 2 .thumb .thumb_func .global townmapcancel main: ldr r5, return push {r5} ldr r0, [r4] ldr r2, constant add r1, r0, r2 ldrb r1, [r1] push {r0-r2} ldr r2, table lsl r0, r1, #0x2 add r0, r2 ldr r0, [r0] ldr r1, vram swi 0x12 pop {r0-r2, pc} .align 2 constant: .word 0x1CCB table: .word 0x08FFFFFF vram: .word 0x06000000 return: .word 0x080C15BD ``` You should point the `FF FF FF 08` in the assembled code to the same table. Again, this calls `swi 0x12` directly and will probably kill the GBA if a tileset is missing or not compressed. Hook: `01 4D 28 47 C0 46 FF FF FF 08` at `080C15B2`, where `FF FF FF 08` is the pointer to the routine + 1.