ledges.asm 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. HandleLedges:
  2. ld a, [wd736]
  3. bit 6, a ; already jumping down ledge
  4. ret nz
  5. ld a, [wCurMapTileset]
  6. and a ; OVERWORLD
  7. ret nz
  8. predef GetTileAndCoordsInFrontOfPlayer
  9. ld a, [wSpriteStateData1 + 9]
  10. ld b, a
  11. aCoord 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. ld a, [hJoyHeld]
  40. and e
  41. ret z
  42. ld a, $ff
  43. ld [wJoyIgnore], a
  44. ld hl, wd736
  45. set 6, [hl] ; jumping down ledge
  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. ; (player direction) (tile player standing on) (ledge tile) (input required)
  57. LedgeTiles:
  58. db SPRITE_FACING_DOWN, $2C,$37,D_DOWN
  59. db SPRITE_FACING_DOWN, $39,$36,D_DOWN
  60. db SPRITE_FACING_DOWN, $39,$37,D_DOWN
  61. db SPRITE_FACING_LEFT, $2C,$27,D_LEFT
  62. db SPRITE_FACING_LEFT, $39,$27,D_LEFT
  63. db SPRITE_FACING_RIGHT,$2C,$0D,D_RIGHT
  64. db SPRITE_FACING_RIGHT,$2C,$1D,D_RIGHT
  65. db SPRITE_FACING_RIGHT,$39,$0D,D_RIGHT
  66. db $FF
  67. LoadHoppingShadowOAM:
  68. ld hl, vChars1 + $7f0
  69. ld de, LedgeHoppingShadow
  70. lb bc, BANK(LedgeHoppingShadow), (LedgeHoppingShadowEnd - LedgeHoppingShadow) / $8
  71. call CopyVideoDataDouble
  72. ld a, $9
  73. lb bc, $54, $48 ; b, c = y, x coordinates of shadow
  74. ld de, LedgeHoppingShadowOAM
  75. call WriteOAMBlock
  76. ret
  77. LedgeHoppingShadow:
  78. INCBIN "gfx/ledge_hopping_shadow.1bpp"
  79. LedgeHoppingShadowEnd:
  80. LedgeHoppingShadowOAM:
  81. db $FF,$10,$FF,$20
  82. db $FF,$40,$FF,$60