aboutsummaryrefslogtreecommitdiffstats
path: root/engine/events/card_key.asm
diff options
context:
space:
mode:
authordannye <33dannye@gmail.com>2020-11-04 00:06:44 -0600
committerdannye <33dannye@gmail.com>2020-11-04 00:06:44 -0600
commit5647ca687b92954dcf37a6ea6bfbc9a341c32de4 (patch)
treedde1937a1bfdb3a835f4155e1c2eb8f1aaf86f63 /engine/events/card_key.asm
parentMerge pull request #55 from Deokishisu/patch-1 (diff)
downloadpokeyellow-5647ca687b92954dcf37a6ea6bfbc9a341c32de4.tar.gz
pokeyellow-5647ca687b92954dcf37a6ea6bfbc9a341c32de4.tar.xz
pokeyellow-5647ca687b92954dcf37a6ea6bfbc9a341c32de4.zip
Sync with pokered
Diffstat (limited to 'engine/events/card_key.asm')
-rwxr-xr-xengine/events/card_key.asm102
1 files changed, 102 insertions, 0 deletions
diff --git a/engine/events/card_key.asm b/engine/events/card_key.asm
new file mode 100755
index 00000000..de5f402e
--- /dev/null
+++ b/engine/events/card_key.asm
@@ -0,0 +1,102 @@
+PrintCardKeyText:
+ ld hl, SilphCoMapList
+ ld a, [wCurMap]
+ ld b, a
+.silphCoMapListLoop
+ ld a, [hli]
+ cp -1
+ ret z
+ cp b
+ jr nz, .silphCoMapListLoop
+; does not check for tile in front of player. This might be buggy
+ ;predef GetTileAndCoordsInFrontOfPlayer
+ ld a, [wTileInFrontOfPlayer]
+ cp $18
+ jr z, .cardKeyDoorInFrontOfPlayer
+ cp $24
+ jr z, .cardKeyDoorInFrontOfPlayer
+ ld b, a
+ ld a, [wCurMap]
+ cp SILPH_CO_11F
+ ret nz
+ ld a, b
+ cp $5e
+ ret nz
+.cardKeyDoorInFrontOfPlayer
+ ld b, CARD_KEY
+ call IsItemInBag
+ jr z, .noCardKey
+ xor a
+ ld [wPlayerMovingDirection], a
+ tx_pre_id CardKeySuccessText
+ ldh [hSpriteIndexOrTextID], a
+ call PrintPredefTextID
+ call GetCoordsInFrontOfPlayer
+ srl d
+ ld a, d
+ ld b, a
+ ld [wCardKeyDoorY], a
+ srl e
+ ld a, e
+ ld c, a
+ ld [wCardKeyDoorX], a
+ ld a, [wCurMap]
+ cp SILPH_CO_11F
+ jr nz, .notSilphCo11F
+ ld a, $3
+ jr .replaceCardKeyDoorTileBlock
+.notSilphCo11F
+ ld a, $e
+.replaceCardKeyDoorTileBlock
+ ld [wNewTileBlockID], a
+ predef ReplaceTileBlock
+ ld hl, wCurrentMapScriptFlags
+ set 5, [hl]
+ ld a, SFX_GO_INSIDE
+ jp PlaySound
+.noCardKey
+ tx_pre_id CardKeyFailText
+ ldh [hSpriteIndexOrTextID], a
+ jp PrintPredefTextID
+
+INCLUDE "data/events/card_key_maps.asm"
+
+CardKeySuccessText::
+ text_far _CardKeySuccessText1
+ sound_get_item_1
+ text_far _CardKeySuccessText2
+ text_end
+
+CardKeyFailText::
+ text_far _CardKeyFailText
+ text_end
+
+; d = Y
+; e = X
+GetCoordsInFrontOfPlayer:
+ ld a, [wYCoord]
+ ld d, a
+ ld a, [wXCoord]
+ ld e, a
+ ld a, [wSpritePlayerStateData1FacingDirection]
+ and a
+ jr nz, .notFacingDown
+; facing down
+ inc d
+ ret
+.notFacingDown
+ cp SPRITE_FACING_UP
+ jr nz, .notFacingUp
+; facing up
+ dec d
+ ret
+.notFacingUp
+ cp SPRITE_FACING_LEFT
+ jr nz, .notFacingLeft
+; facing left
+ dec e
+ ret
+.notFacingLeft
+; facing right
+ inc e
+ ret