Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/engine/overworld/ledges.asm
1271 views
1
HandleLedges::
2
ld a, [wMovementFlags]
3
bit BIT_LEDGE_OR_FISHING, a
4
ret nz
5
ld a, [wCurMapTileset]
6
and a ; OVERWORLD
7
ret nz
8
predef GetTileAndCoordsInFrontOfPlayer
9
ld a, [wSpritePlayerStateData1FacingDirection]
10
ld b, a
11
lda_coord 8, 9
12
ld c, a
13
ld a, [wTileInFrontOfPlayer]
14
ld d, a
15
ld hl, LedgeTiles
16
.loop
17
ld a, [hli]
18
cp $ff
19
ret z
20
cp b
21
jr nz, .nextLedgeTile1
22
ld a, [hli]
23
cp c
24
jr nz, .nextLedgeTile2
25
ld a, [hli]
26
cp d
27
jr nz, .nextLedgeTile3
28
ld a, [hl]
29
ld e, a
30
jr .foundMatch
31
.nextLedgeTile1
32
inc hl
33
.nextLedgeTile2
34
inc hl
35
.nextLedgeTile3
36
inc hl
37
jr .loop
38
.foundMatch
39
ldh a, [hJoyHeld]
40
and e
41
ret z
42
ld a, PAD_BUTTONS | PAD_CTRL_PAD
43
ld [wJoyIgnore], a
44
ld hl, wMovementFlags
45
set BIT_LEDGE_OR_FISHING, [hl]
46
call StartSimulatingJoypadStates
47
ld a, e
48
ld [wSimulatedJoypadStatesEnd], a
49
ld [wSimulatedJoypadStatesEnd + 1], a
50
ld a, $2
51
ld [wSimulatedJoypadStatesIndex], a
52
call LoadHoppingShadowOAM
53
ld a, SFX_LEDGE
54
call PlaySound
55
ret
56
57
INCLUDE "data/tilesets/ledge_tiles.asm"
58
59
LoadHoppingShadowOAM:
60
ld hl, vChars1 tile $7f
61
ld de, LedgeHoppingShadow
62
lb bc, BANK(LedgeHoppingShadow), (LedgeHoppingShadowEnd - LedgeHoppingShadow) / $8
63
call CopyVideoDataDouble
64
ld a, $9
65
lb bc, $54, $48 ; b, c = y, x coordinates of shadow
66
ld de, LedgeHoppingShadowOAMBlock
67
call WriteOAMBlock
68
ret
69
70
LedgeHoppingShadow:
71
INCBIN "gfx/overworld/shadow.1bpp"
72
LedgeHoppingShadowEnd:
73
74
LedgeHoppingShadowOAMBlock:
75
; tile ID, attributes
76
db $ff, OAM_PAL1
77
db $ff, OAM_XFLIP
78
db $ff, OAM_YFLIP
79
db $ff, OAM_XFLIP | OAM_YFLIP
80
81