-
Notifications
You must be signed in to change notification settings - Fork 1k
Map legend in save infobox
From Generation 3 onwards, the save and continue dialog display information on where the player is located at the time of the save.
Let's try implementing it here—but with an exception: whereas those games display the name of the precise map the player was in, here we're enlisting the help of the Town Map mechanism. It may be less precise, since it will display the name of the connecting outdoor map, but we'll go with this for now to keep things simple.
First, let's add a helper in engine/items/town_map.asm. All it does is provide something to be called easily from the main menu to print the current map name into wNameBuffer
in RAM, which will then be printed out to the dialog box.
ld l, a
ret
+GetMapName::
+ ld a, e
+ call LoadTownMapEntry
+ ld de, wNameBuffer
+ ld bc, NAME_BUFFER_LENGTH
+ call CopyData
+ ret
+
INCLUDE "data/maps/town_map_entries.asm"
INCLUDE "data/maps/names.asm"
Next, let's head over to engine/menus/main_menu.asm and widen the info boxes in both the Continue screen and the Save dialog to make room for the new row (and also make room for the longest map name (UNDERGROUND PATH):
DisplayContinueGameInfo:
xor a
ldh [hAutoBGTransferEnabled], a
- hlcoord 4, 7
- ld b, 8
- ld c, 14
+ hlcoord 2, 6
+ ld b, 10
+ ld c, 16
call TextBoxBorder
- hlcoord 5, 9
+ hlcoord 3, 10
ld de, SaveScreenInfoText
call PlaceString
- hlcoord 12, 9
+ hlcoord 12, 10
ld de, wPlayerName
call PlaceString
- hlcoord 17, 11
+ hlcoord 17, 12
call PrintNumBadges
- hlcoord 16, 13
+ hlcoord 16, 14
call PrintNumOwnedMons
- hlcoord 13, 15
+ hlcoord 13, 16
call PrintPlayTime
ld a, 1
ldh [hAutoBGTransferEnabled], a
PrintSaveScreenText:
xor a
ldh [hAutoBGTransferEnabled], a
- hlcoord 4, 0
- ld b, $8
- ld c, $e
+ hlcoord 2, 0
+ ld b, 10
+ ld c, 16
call TextBoxBorder
call LoadTextBoxTilePatterns
call UpdateSprites
- hlcoord 5, 2
+ hlcoord 3, 4
ld de, SaveScreenInfoText
call PlaceString
- hlcoord 12, 2
+ hlcoord 12, 4
ld de, wPlayerName
call PlaceString
- hlcoord 17, 4
+ hlcoord 17, 6
call PrintNumBadges
- hlcoord 16, 6
+ hlcoord 16, 8
call PrintNumOwnedMons
- hlcoord 13, 8
+ hlcoord 13, 10
call PrintPlayTime
ld a, $1
ldh [hAutoBGTransferEnabled], a
Finally, in the same file, add in the code to display the map info:
DisplayContinueGameInfo:
xor a
ldh [hAutoBGTransferEnabled], a
hlcoord 2, 6
ld b, 10
ld c, 16
call TextBoxBorder
+; show map legend
+ ld a, [wCurMap]
+ ld e, a
+ farcall GetMapName
+ hlcoord 3, 8
+ ld de, wNameBuffer
+ call PlaceString
+
+; show normal info
hlcoord 3, 10
ld de, SaveScreenInfoText
call PlaceString
hlcoord 12, 10
ld de, wPlayerName
call PlaceString
PrintSaveScreenText:
xor a
ldh [hAutoBGTransferEnabled], a
hlcoord 2, 0
ld b, 10
ld c, 16
call TextBoxBorder
call LoadTextBoxTilePatterns
call UpdateSprites
+; show map legend
+ ld a, [wCurMap]
+ ld e, a
+ farcall GetMapName
+ hlcoord 3, 2
+ ld de, wNameBuffer
+ call PlaceString
+
+; show normal info
hlcoord 3, 4
ld de, SaveScreenInfoText
call PlaceString
hlcoord 12, 4
ld de, wPlayerName
call PlaceString