pokered/engine/overworld/ledges.asm
2020-06-27 21:43:32 -04:00

76 lines
1.4 KiB
NASM
Executable file

HandleLedges::
ld a, [wd736]
bit 6, a ; already jumping down ledge
ret nz
ld a, [wCurMapTileset]
and a ; OVERWORLD
ret nz
predef GetTileAndCoordsInFrontOfPlayer
ld a, [wSpriteStateData1 + 9]
ld b, a
aCoord 8, 9
ld c, a
ld a, [wTileInFrontOfPlayer]
ld d, a
ld hl, LedgeTiles
.loop
ld a, [hli]
cp $ff
ret z
cp b
jr nz, .nextLedgeTile1
ld a, [hli]
cp c
jr nz, .nextLedgeTile2
ld a, [hli]
cp d
jr nz, .nextLedgeTile3
ld a, [hl]
ld e, a
jr .foundMatch
.nextLedgeTile1
inc hl
.nextLedgeTile2
inc hl
.nextLedgeTile3
inc hl
jr .loop
.foundMatch
ld a, [hJoyHeld]
and e
ret z
ld a, $ff
ld [wJoyIgnore], a
ld hl, wd736
set 6, [hl] ; jumping down ledge
call StartSimulatingJoypadStates
ld a, e
ld [wSimulatedJoypadStatesEnd], a
ld [wSimulatedJoypadStatesEnd + 1], a
ld a, $2
ld [wSimulatedJoypadStatesIndex], a
call LoadHoppingShadowOAM
ld a, SFX_LEDGE
call PlaySound
ret
INCLUDE "data/ledge_tiles.asm"
LoadHoppingShadowOAM:
ld hl, vChars1 + $7f0
ld de, LedgeHoppingShadow
lb bc, BANK(LedgeHoppingShadow), (LedgeHoppingShadowEnd - LedgeHoppingShadow) / $8
call CopyVideoDataDouble
ld a, $9
lb bc, $54, $48 ; b, c = y, x coordinates of shadow
ld de, LedgeHoppingShadowOAM
call WriteOAMBlock
ret
LedgeHoppingShadow:
INCBIN "gfx/overworld/shadow.1bpp"
LedgeHoppingShadowEnd:
LedgeHoppingShadowOAM:
db $FF,$10,$FF,$20
db $FF,$40,$FF,$60