Make level selection menu landmarks universal (#4) (#12)

This commit is contained in:
xCrystal 2023-08-20 12:08:24 +02:00
parent 222b46896c
commit fc2e757c57
11 changed files with 61 additions and 84 deletions

View File

@ -1,6 +1,10 @@
; Landmarks indexes (see data/maps/landmarks.asm)
const_def
const LANDMARK_LEVEL_1 ; 00
const LANDMARK_LEVEL_2 ; 01
const LANDMARK_LEVEL_3 ; 02
const LANDMARK_LEVEL_4 ; 03
const LANDMARK_LEVEL_5 ; 04
DEF NUM_LANDMARKS EQU const_value
; used in CaughtData

View File

@ -1,6 +1,6 @@
; TILE_WIDTH represents the top/left border tile, $8/$10 represent the OAM screen position offsets, and 10 are custom offsets
DEF LEVELSELECTIONMENU_LANDMARK_OFFSET_X EQU TILE_WIDTH + $8 + 10
DEF LEVELSELECTIONMENU_LANDMARK_OFFSET_Y EQU TILE_WIDTH + $10 + 10
; TILE_WIDTH represents the top/left border tile, $8/$10 represent the OAM screen position offsets, and 4 are custom offsets
DEF LEVELSELECTIONMENU_LANDMARK_OFFSET_X EQU TILE_WIDTH + $8 + 4
DEF LEVELSELECTIONMENU_LANDMARK_OFFSET_Y EQU TILE_WIDTH + $10 + 4
MACRO level_selection_menu_landmark
; page number, xcoord (in tiles), ycoord (in tiles), ptr to name, spawn point (SPAWN_*)
@ -13,12 +13,18 @@ ENDM
LevelSelectionMenu_Landmarks:
.landmark1
level_selection_menu_landmark 0, 16, 11, DefaultLandmarkName, SPAWN_LEVEL_1
level_selection_menu_landmark 0, 16, 11, .Level1LandmarkName, SPAWN_LEVEL_1
.landmark2
level_selection_menu_landmark 0, 11, 9, DefaultLandmarkName, SPAWN_LEVEL_1
level_selection_menu_landmark 0, 9, 11, DefaultLandmarkName, SPAWN_LEVEL_1
level_selection_menu_landmark 1, 16, 11, DefaultLandmarkName, SPAWN_LEVEL_1
level_selection_menu_landmark 2, 9, 5, DefaultLandmarkName, SPAWN_LEVEL_1
level_selection_menu_landmark 0, 11, 9, .Level2LandmarkName, SPAWN_LEVEL_1
level_selection_menu_landmark 0, 9, 11, .Level3LandmarkName, SPAWN_LEVEL_1
level_selection_menu_landmark 1, 16, 11, .Level4LandmarkName, SPAWN_LEVEL_1
level_selection_menu_landmark 2, 9, 5, .Level5LandmarkName, SPAWN_LEVEL_1
.Level1LandmarkName: db "LEVEL 1@"
.Level2LandmarkName: db "LEVEL 2@"
.Level3LandmarkName: db "LEVEL 3@"
.Level4LandmarkName: db "LEVEL 4@"
.Level5LandmarkName: db "LEVEL 5@"
LevelSelectionMenu_PageGrid:
db -1, -1, -1, -1
@ -27,5 +33,3 @@ LevelSelectionMenu_PageGrid:
db -1, -1, -1, -1
DEF LEVELSELECTIONMENU_PAGE_GRID_WIDTH EQU 4
DefaultLandmarkName: db "LANDMARK NAME@"

View File

@ -1,13 +0,0 @@
MACRO landmark
; x, y, name
db \1 + 8, \2 + 16
dw \3
ENDM
Landmarks:
; entries correspond to constants/landmark_constants.asm
table_width 4, Landmarks
landmark 140, 100, Level1LandmarkName
assert_table_length NUM_LANDMARKS
Level1LandmarkName: db "LEVEL 1@"

View File

@ -218,7 +218,7 @@ GetCaughtLocation:
cp LANDMARK_GIFT
jr z, .fail
ld e, a
farcall GetLandmarkName
farcall LevelSelectionMenu_GetLandmarkName
ld hl, wStringBuffer1
ld de, wSeerCaughtLocation
ld bc, 17

View File

@ -86,7 +86,7 @@ LevelSelectionMenu_GetLandmarkPage:
pop hl
ret
LevelSelectionMenu_GetLandmarkCoords:
LevelSelectionMenu_GetLandmarkCoords::
; Return coordinates (d, e) of landmark e.
push hl
push bc
@ -101,6 +101,35 @@ LevelSelectionMenu_GetLandmarkCoords:
pop hl
ret
LevelSelectionMenu_GetLandmarkName::
; Copy the name of landmark e to wStringBuffer1.
push hl
push de
push bc
ld hl, LevelSelectionMenu_Landmarks + $3
ld bc, LevelSelectionMenu_Landmarks.landmark2 - LevelSelectionMenu_Landmarks.landmark1
ld a, e
call AddNTimes
ld a, [hli]
ld h, [hl]
ld l, a
ld de, wStringBuffer1
ld c, 18
.copy
ld a, [hli]
ld [de], a
inc de
dec c
jr nz, .copy
pop bc
pop de
pop hl
ret
INCLUDE "data/level_selection_menu.asm"
LevelSelectionMenuGFX:

View File

@ -1,46 +0,0 @@
GetLandmarkCoords:
; Return coordinates (d, e) of landmark e.
push hl
ld l, e
ld h, 0
add hl, hl
add hl, hl
ld de, Landmarks
add hl, de
ld a, [hli]
ld e, a
ld d, [hl]
pop hl
ret
GetLandmarkName::
; Copy the name of landmark e to wStringBuffer1.
push hl
push de
push bc
ld l, e
ld h, 0
add hl, hl
add hl, hl
ld de, Landmarks + 2
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
ld de, wStringBuffer1
ld c, 18
.copy
ld a, [hli]
ld [de], a
inc de
dec c
jr nz, .copy
pop bc
pop de
pop hl
ret
INCLUDE "data/maps/landmarks.asm"

View File

@ -1623,7 +1623,7 @@ Script_getcurlandmarkname:
ConvertLandmarkToText:
ld e, a
farcall GetLandmarkName
farcall LevelSelectionMenu_GetLandmarkName
ld de, wStringBuffer1
jp GetStringBuffer

View File

@ -679,7 +679,7 @@ GetCallerLocation:
push bc
call GetWorldMapLocation
ld e, a
farcall GetLandmarkName
farcall LevelSelectionMenu_GetLandmarkName
pop bc
pop de
ret

View File

@ -574,7 +574,7 @@ PokegearMap_InitPlayerIcon:
pop af
ld e, a
push bc
farcall GetLandmarkCoords
farcall LevelSelectionMenu_GetLandmarkCoords
pop bc
ld hl, SPRITEANIMSTRUCT_XCOORD
add hl, bc
@ -609,7 +609,7 @@ PokegearMap_UpdateLandmarkName:
pop af
ld e, a
push de
farcall GetLandmarkName
farcall LevelSelectionMenu_GetLandmarkName
pop de
farcall TownMap_ConvertLineBreakCharacters
hlcoord 8, 0
@ -619,7 +619,7 @@ PokegearMap_UpdateLandmarkName:
PokegearMap_UpdateCursorPosition:
push bc
ld e, a
farcall GetLandmarkCoords
farcall LevelSelectionMenu_GetLandmarkCoords
pop bc
ld hl, SPRITEANIMSTRUCT_XCOORD
add hl, bc
@ -1986,7 +1986,7 @@ TownMapBubble:
ld de, Flypoints
add hl, de
ld e, [hl]
farcall GetLandmarkName
farcall LevelSelectionMenu_GetLandmarkName
hlcoord 2, 1
ld de, wStringBuffer1
call PlaceString
@ -2000,7 +2000,7 @@ GetMapCursorCoordinates:
ld de, Flypoints
add hl, de
ld e, [hl]
farcall GetLandmarkCoords
farcall LevelSelectionMenu_GetLandmarkCoords
ld a, [wTownMapCursorCoordinates]
ld c, a
ld a, [wTownMapCursorCoordinates + 1]
@ -2231,7 +2231,7 @@ Pokedex_GetArea:
push de
ld e, a
push hl
farcall GetLandmarkCoords
farcall LevelSelectionMenu_GetLandmarkCoords
pop hl
; load into OAM
ld a, d
@ -2261,7 +2261,7 @@ Pokedex_GetArea:
ret c
ld a, [wTownMapPlayerIconLandmark]
ld e, a
farcall GetLandmarkCoords
farcall LevelSelectionMenu_GetLandmarkCoords
ld c, e
ld b, d
ld de, .PlayerOAM
@ -2472,7 +2472,7 @@ TownMapPlayerIcon:
pop af
ld e, a
push bc
farcall GetLandmarkCoords
farcall LevelSelectionMenu_GetLandmarkCoords
pop bc
ld hl, SPRITEANIMSTRUCT_XCOORD
add hl, bc

View File

@ -266,7 +266,7 @@ endr
pop bc
call GetWorldMapLocation
ld e, a
farcall GetLandmarkName
farcall LevelSelectionMenu_GetLandmarkName
ld hl, OPT_OakText1
call CopyRadioTextToRAM
ld a, OAKS_POKEMON_TALK_5
@ -1249,7 +1249,7 @@ PeoplePlaces6: ; Places
ld c, [hl]
call GetWorldMapLocation
ld e, a
farcall GetLandmarkName
farcall LevelSelectionMenu_GetLandmarkName
ld hl, PnP_Text5
ld a, PLACES_AND_PEOPLE_7
jp NextRadioLine

View File

@ -430,7 +430,6 @@ SECTION "Miscellaneous Text", ROMX
INCLUDE "data/items/names.asm"
INCLUDE "engine/items/print_item_description.asm"
INCLUDE "data/moves/names.asm"
INCLUDE "engine/overworld/landmarks.asm"
SECTION "Print Party", ROMX