pokecrystal/engine/events/map_name_sign.asm

260 lines
3.9 KiB
NASM
Raw Normal View History

2018-01-12 04:50:44 +00:00
MAP_NAME_SIGN_START EQU $60
InitMapNameSign::
2018-01-12 04:50:44 +00:00
xor a
ldh [hBGMapMode], a
2018-01-12 04:50:44 +00:00
farcall .inefficient_farcall ; this is a waste of 6 ROM bytes and 6 stack bytes
ret
; should have just been a fallthrough
2018-06-24 14:09:41 +00:00
.inefficient_farcall
2018-01-23 22:39:09 +00:00
ld a, [wMapGroup]
2018-01-12 04:50:44 +00:00
ld b, a
2018-01-23 22:39:09 +00:00
ld a, [wMapNumber]
2018-01-12 04:50:44 +00:00
ld c, a
call GetWorldMapLocation
2018-09-09 19:09:51 +00:00
ld [wCurLandmark], a
2018-01-12 04:50:44 +00:00
call .CheckNationalParkGate
jr z, .gate
2018-01-12 04:50:44 +00:00
call GetMapEnvironment
cp GATE
jr nz, .not_gate
.gate
2018-01-12 04:50:44 +00:00
ld a, -1
2018-09-09 19:09:51 +00:00
ld [wCurLandmark], a
2018-01-12 04:50:44 +00:00
.not_gate
ld hl, wEnteredMapFromContinue
bit 1, [hl]
res 1, [hl]
jr nz, .dont_do_map_sign
call .CheckMovingWithinLandmark
jr z, .dont_do_map_sign
2018-09-09 19:09:51 +00:00
ld a, [wCurLandmark]
2018-09-09 19:27:23 +00:00
ld [wPrevLandmark], a
2018-01-12 04:50:44 +00:00
call .CheckSpecialMap
jr z, .dont_do_map_sign
; Display for 60 frames
ld a, 60
ld [wLandmarkSignTimer], a
call LoadMapNameSignGFX
call InitMapNameFrame
farcall HDMATransfer_OnlyTopFourRows
ret
.dont_do_map_sign
2018-09-09 19:09:51 +00:00
ld a, [wCurLandmark]
2018-09-09 19:27:23 +00:00
ld [wPrevLandmark], a
2018-01-12 04:50:44 +00:00
ld a, $90
ldh [rWY], a
ldh [hWY], a
2018-01-12 04:50:44 +00:00
xor a
ldh [hLCDCPointer], a
2018-01-12 04:50:44 +00:00
ret
2018-06-24 14:09:41 +00:00
.CheckMovingWithinLandmark:
2018-09-09 19:09:51 +00:00
ld a, [wCurLandmark]
2018-01-12 04:50:44 +00:00
ld c, a
2018-09-09 19:27:23 +00:00
ld a, [wPrevLandmark]
2018-01-12 04:50:44 +00:00
cp c
ret z
cp LANDMARK_SPECIAL
2018-01-12 04:50:44 +00:00
ret
2018-06-24 14:09:41 +00:00
.CheckSpecialMap:
2018-01-12 04:50:44 +00:00
; These landmarks do not get pop-up signs.
cp -1
ret z
cp LANDMARK_SPECIAL ; redundant check
2018-01-12 04:50:44 +00:00
ret z
cp LANDMARK_RADIO_TOWER
2018-01-12 04:50:44 +00:00
ret z
cp LANDMARK_LAV_RADIO_TOWER
2018-01-12 04:50:44 +00:00
ret z
cp LANDMARK_UNDERGROUND_PATH
2018-01-12 04:50:44 +00:00
ret z
cp LANDMARK_INDIGO_PLATEAU
2018-01-12 04:50:44 +00:00
ret z
cp LANDMARK_POWER_PLANT
2018-01-12 04:50:44 +00:00
ret z
2018-02-04 18:16:40 +00:00
ld a, 1
2018-01-12 04:50:44 +00:00
and a
ret
2018-06-24 14:09:41 +00:00
.CheckNationalParkGate:
2018-01-23 22:39:09 +00:00
ld a, [wMapGroup]
2018-01-12 04:50:44 +00:00
cp GROUP_ROUTE_35_NATIONAL_PARK_GATE
ret nz
2018-01-23 22:39:09 +00:00
ld a, [wMapNumber]
2018-01-12 04:50:44 +00:00
cp MAP_ROUTE_35_NATIONAL_PARK_GATE
ret z
cp MAP_ROUTE_36_NATIONAL_PARK_GATE
ret
2018-06-24 14:09:41 +00:00
PlaceMapNameSign::
2018-01-12 04:50:44 +00:00
ld hl, wLandmarkSignTimer
ld a, [hl]
and a
jr z, .disappear
dec [hl]
cp 60
ret z
cp 59
jr nz, .already_initialized
2018-01-12 04:50:44 +00:00
call InitMapNameFrame
call PlaceMapNameCenterAlign
farcall HDMATransfer_OnlyTopFourRows
.already_initialized
2018-01-12 04:50:44 +00:00
ld a, $80
ld a, $70
ldh [rWY], a
ldh [hWY], a
2018-01-12 04:50:44 +00:00
ret
.disappear
ld a, $90
ldh [rWY], a
ldh [hWY], a
2018-01-12 04:50:44 +00:00
xor a
ldh [hLCDCPointer], a
2018-01-12 04:50:44 +00:00
ret
2018-06-24 14:09:41 +00:00
LoadMapNameSignGFX:
2018-01-12 04:50:44 +00:00
ld de, MapEntryFrameGFX
ld hl, vTiles2 tile MAP_NAME_SIGN_START
lb bc, BANK(MapEntryFrameGFX), 14
call Get2bpp
ret
2018-06-24 14:09:41 +00:00
InitMapNameFrame:
2018-01-12 04:50:44 +00:00
hlcoord 0, 0
ld b, 2
ld c, 18
call InitMapSignAttrmap
2018-01-12 04:50:44 +00:00
call PlaceMapNameFrame
ret
2018-06-24 14:09:41 +00:00
PlaceMapNameCenterAlign:
2018-09-09 19:09:51 +00:00
ld a, [wCurLandmark]
2018-01-12 04:50:44 +00:00
ld e, a
farcall GetLandmarkName
call .GetNameLength
ld a, SCREEN_WIDTH
sub c
srl a
ld b, $0
ld c, a
hlcoord 0, 2
add hl, bc
2018-01-23 22:39:09 +00:00
ld de, wStringBuffer1
2018-01-12 04:50:44 +00:00
call PlaceString
ret
2018-06-24 14:09:41 +00:00
.GetNameLength:
2018-01-12 04:50:44 +00:00
ld c, 0
push hl
2018-01-23 22:39:09 +00:00
ld hl, wStringBuffer1
2018-01-12 04:50:44 +00:00
.loop
ld a, [hli]
cp "@"
jr z, .stop
cp "%"
jr z, .loop
inc c
jr .loop
.stop
pop hl
ret
InitMapSignAttrmap:
ld de, wAttrmap - wTilemap
2018-01-12 04:50:44 +00:00
add hl, de
inc b
inc b
inc c
inc c
ld a, PAL_BG_TEXT | PRIORITY
.loop
push bc
push hl
.inner_loop
ld [hli], a
dec c
jr nz, .inner_loop
pop hl
ld de, SCREEN_WIDTH
add hl, de
pop bc
dec b
jr nz, .loop
ret
2018-06-24 14:09:41 +00:00
PlaceMapNameFrame:
2018-01-12 04:50:44 +00:00
hlcoord 0, 0
; top left
ld a, MAP_NAME_SIGN_START + 1
ld [hli], a
; top row
ld a, MAP_NAME_SIGN_START + 2
call .FillTopBottom
; top right
ld a, MAP_NAME_SIGN_START + 4
ld [hli], a
; left, first line
ld a, MAP_NAME_SIGN_START + 5
ld [hli], a
; first line
call .FillMiddle
; right, first line
ld a, MAP_NAME_SIGN_START + 11
ld [hli], a
; left, second line
ld a, MAP_NAME_SIGN_START + 6
ld [hli], a
; second line
call .FillMiddle
; right, second line
ld a, MAP_NAME_SIGN_START + 12
ld [hli], a
; bottom left
ld a, MAP_NAME_SIGN_START + 7
ld [hli], a
; bottom
ld a, MAP_NAME_SIGN_START + 8
call .FillTopBottom
; bottom right
ld a, MAP_NAME_SIGN_START + 10
ld [hl], a
ret
2018-06-24 14:09:41 +00:00
.FillMiddle:
2018-01-12 04:50:44 +00:00
ld c, SCREEN_WIDTH - 2
ld a, MAP_NAME_SIGN_START + 13
.loop
ld [hli], a
dec c
jr nz, .loop
ret
2018-06-24 14:09:41 +00:00
.FillTopBottom:
2019-01-18 15:17:50 +00:00
ld c, (SCREEN_WIDTH - 2) / 4 + 1
2018-01-12 04:50:44 +00:00
jr .enterloop
.continueloop
ld [hli], a
ld [hli], a
.enterloop
inc a
ld [hli], a
ld [hli], a
dec a
dec c
jr nz, .continueloop
ret