emotion_bubbles.asm 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. EmotionBubble:
  2. ld a, [wWhichEmotionBubble]
  3. ld c, a
  4. ld b, 0
  5. ld hl, EmotionBubblesPointerTable
  6. add hl, bc
  7. add hl, bc
  8. ld e, [hl]
  9. inc hl
  10. ld d, [hl]
  11. ld hl, vChars1 + $780
  12. lb bc, BANK(EmotionBubbles), $04
  13. call CopyVideoData
  14. ld a, [wUpdateSpritesEnabled]
  15. push af
  16. ld a, $ff
  17. ld [wUpdateSpritesEnabled], a
  18. ld a, [wd736]
  19. bit 6, a ; are the last 4 OAM entries reserved for a shadow or fishing rod?
  20. ld hl, wOAMBuffer + 4 * 35 + $3 ; $8f
  21. ld de, wOAMBuffer + 4 * 39 + $3 ; $9f
  22. jr z, .next
  23. ld hl, wOAMBuffer + 4 * 31 + $3 ; $7f
  24. ld de, wOAMBuffer + 4 * 35 + $3 ; $8f
  25. ; Copy OAM data 16 bytes forward to make room for emotion bubble OAM data at the
  26. ; start of the OAM buffer.
  27. .next
  28. ld bc, $90
  29. .loop
  30. ld a, [hl]
  31. ld [de], a
  32. dec hl
  33. dec de
  34. dec bc
  35. ld a, c
  36. or b
  37. jr nz, .loop
  38. ; get the screen coordinates of the sprite the bubble is to be displayed above
  39. ld hl, wSpriteStateData1 + 4
  40. ld a, [wEmotionBubbleSpriteIndex]
  41. swap a
  42. ld c, a
  43. ld b, 0
  44. add hl, bc
  45. ld a, [hli]
  46. ld b, a
  47. inc hl
  48. ld a, [hl]
  49. add $8
  50. ld c, a
  51. ld de, EmotionBubblesOAM
  52. xor a
  53. call WriteOAMBlock
  54. ld c, 60
  55. call DelayFrames
  56. pop af
  57. ld [wUpdateSpritesEnabled], a
  58. call DelayFrame
  59. jp UpdateSprites
  60. EmotionBubblesPointerTable:
  61. dw EmotionBubbles
  62. dw EmotionBubbles + $40
  63. dw EmotionBubbles + $80
  64. EmotionBubblesOAM:
  65. db $F8,$00,$F9,$00
  66. db $FA,$00,$FB,$00
  67. EmotionBubbles:
  68. INCBIN "gfx/emotion_bubbles.2bpp"