pokered/engine/overworld/card_key.asm

113 lines
1.8 KiB
NASM
Raw Normal View History

2014-05-22 22:13:20 +00:00
PrintCardKeyText: ; 52673 (14:6673)
ld hl, SilphCoMapList
ld a, [W_CURMAP]
ld b, a
2014-09-14 18:29:18 +00:00
.silphCoMapListLoop
2014-05-22 22:13:20 +00:00
ld a, [hli]
cp $ff
ret z
cp b
2014-09-14 18:29:18 +00:00
jr nz, .silphCoMapListLoop
2014-09-13 07:50:56 +00:00
predef GetTileAndCoordsInFrontOfPlayer
ld a, [wTileInFrontOfPlayer]
2014-05-22 22:13:20 +00:00
cp $18
2014-09-14 18:29:18 +00:00
jr z, .cardKeyDoorInFrontOfPlayer
2014-05-22 22:13:20 +00:00
cp $24
2014-09-14 18:29:18 +00:00
jr z, .cardKeyDoorInFrontOfPlayer
2014-05-22 22:13:20 +00:00
ld b, a
ld a, [W_CURMAP]
cp SILPH_CO_11F
ret nz
ld a, b
cp $5e
ret nz
2014-09-14 18:29:18 +00:00
.cardKeyDoorInFrontOfPlayer
2014-05-22 22:13:20 +00:00
ld b, CARD_KEY
call IsItemInBag
2014-09-14 18:29:18 +00:00
jr z, .noCardKey
call GetCoordsInFrontOfPlayer
2014-05-22 22:13:20 +00:00
push de
tx_pre_id CardKeySuccessText
2014-09-14 18:29:18 +00:00
ld [H_DOWNARROWBLINKCNT2], a
2014-05-22 22:13:20 +00:00
call PrintPredefTextID
pop de
srl d
ld a, d
ld b, a
2014-09-14 18:29:18 +00:00
ld [wCardKeyDoorY], a
2014-05-22 22:13:20 +00:00
srl e
ld a, e
ld c, a
2014-09-14 18:29:18 +00:00
ld [wCardKeyDoorX], a
ld a, [W_CURMAP]
2014-05-22 22:13:20 +00:00
cp SILPH_CO_11F
2014-09-14 18:29:18 +00:00
jr nz, .notSilphCo11F
2014-05-22 22:13:20 +00:00
ld a, $3
2014-09-14 18:29:18 +00:00
jr .replaceCardKeyDoorTileBlock
.notSilphCo11F
2014-05-22 22:13:20 +00:00
ld a, $e
2014-09-14 18:29:18 +00:00
.replaceCardKeyDoorTileBlock
ld [wd09f], a
2014-09-14 18:29:18 +00:00
predef ReplaceTileBlock
ld hl, wd126
2014-05-22 22:13:20 +00:00
set 5, [hl]
2015-07-19 08:46:12 +00:00
ld a, SFX_GO_INSIDE
2014-05-22 22:13:20 +00:00
jp PlaySound
2014-09-14 18:29:18 +00:00
.noCardKey
tx_pre_id CardKeyFailText
2014-09-14 18:29:18 +00:00
ld [H_DOWNARROWBLINKCNT2], a
2014-05-22 22:13:20 +00:00
jp PrintPredefTextID
SilphCoMapList: ; 526e3 (14:66e3)
db SILPH_CO_2F
db SILPH_CO_3F
db SILPH_CO_4F
db SILPH_CO_5F
db SILPH_CO_6F
db SILPH_CO_7F
db SILPH_CO_8F
db SILPH_CO_9F
db SILPH_CO_10F
db SILPH_CO_11F
db $FF
CardKeySuccessText: ; 526ee (14:66ee)
TX_FAR _CardKeySuccessText1
db $0b
TX_FAR _CardKeySuccessText2
db "@"
CardKeyFailText: ; 526f8 (14:66f8)
TX_FAR _CardKeyFailText
db "@"
2014-09-14 18:29:18 +00:00
; d = Y
; e = X
GetCoordsInFrontOfPlayer: ; 526fd (14:66fd)
ld a, [W_YCOORD]
2014-05-22 22:13:20 +00:00
ld d, a
2014-09-14 18:29:18 +00:00
ld a, [W_XCOORD]
2014-05-22 22:13:20 +00:00
ld e, a
2014-09-14 18:29:18 +00:00
ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
2014-05-22 22:13:20 +00:00
and a
2014-09-14 18:29:18 +00:00
jr nz, .notFacingDown
; facing down
2014-05-22 22:13:20 +00:00
inc d
ret
2014-09-14 18:29:18 +00:00
.notFacingDown
cp SPRITE_FACING_UP
jr nz, .notFacingUp
; facing up
2014-05-22 22:13:20 +00:00
dec d
ret
2014-09-14 18:29:18 +00:00
.notFacingUp
cp SPRITE_FACING_LEFT
jr nz, .notFacingLeft
; facing left
2014-05-22 22:13:20 +00:00
dec e
ret
2014-09-14 18:29:18 +00:00
.notFacingLeft
; facing right
2014-05-22 22:13:20 +00:00
inc e
ret