fade.asm 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. ; These routines manage gradual fading
  2. ; (e.g., entering a doorway)
  3. LoadGBPal::
  4. ld a, [wMapPalOffset] ;tells if wCurMap is dark (requires HM5_FLASH?)
  5. ld b, a
  6. ld hl, FadePal4
  7. ld a, l
  8. sub b
  9. ld l, a
  10. jr nc, .ok
  11. dec h
  12. .ok
  13. ld a, [hli]
  14. ld [rBGP], a
  15. ld a, [hli]
  16. ld [rOBP0], a
  17. ld a, [hli]
  18. ld [rOBP1], a
  19. ret
  20. GBFadeInFromBlack::
  21. ld hl, FadePal1
  22. ld b, 4
  23. jr GBFadeIncCommon
  24. GBFadeOutToWhite::
  25. ld hl, FadePal6
  26. ld b, 3
  27. GBFadeIncCommon:
  28. ld a, [hli]
  29. ld [rBGP], a
  30. ld a, [hli]
  31. ld [rOBP0], a
  32. ld a, [hli]
  33. ld [rOBP1], a
  34. ld c, 8
  35. call DelayFrames
  36. dec b
  37. jr nz, GBFadeIncCommon
  38. ret
  39. GBFadeOutToBlack::
  40. ld hl, FadePal4 + 2
  41. ld b, 4
  42. jr GBFadeDecCommon
  43. GBFadeInFromWhite::
  44. ld hl, FadePal7 + 2
  45. ld b, 3
  46. GBFadeDecCommon:
  47. ld a, [hld]
  48. ld [rOBP1], a
  49. ld a, [hld]
  50. ld [rOBP0], a
  51. ld a, [hld]
  52. ld [rBGP], a
  53. ld c, 8
  54. call DelayFrames
  55. dec b
  56. jr nz, GBFadeDecCommon
  57. ret
  58. FadePal1:: db %11111111, %11111111, %11111111
  59. FadePal2:: db %11111110, %11111110, %11111000
  60. FadePal3:: db %11111001, %11100100, %11100100
  61. FadePal4:: db %11100100, %11010000, %11100000
  62. ; rBGP rOBP0 rOBP1
  63. FadePal5:: db %11100100, %11010000, %11100000
  64. FadePal6:: db %10010000, %10000000, %10010000
  65. FadePal7:: db %01000000, %01000000, %01000000
  66. FadePal8:: db %00000000, %00000000, %00000000