sprite animation testing
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

180 lines
2.6KB

  1. Player_To_OAM:
  2. ; -- first loop --
  3. ld hl, wShadowOAM
  4. ld a, [dPlayerHeight]
  5. ld b, a
  6. ld d, 16
  7. ld a, [rPlayerY]
  8. add d ; d has the base Y value (counting offsets)
  9. ld d, a
  10. .fouter
  11. ld a, [dPlayerWidth]
  12. ld c, a ; c is finner counter
  13. .finner
  14. ld a, d
  15. ld [hl], a
  16. ld a, 4
  17. call .add4hl
  18. ; end of finner loop
  19. dec c
  20. jr nz, .finner
  21. ld a, d
  22. ld d, 8
  23. add d
  24. ld d, a
  25. ; end of fouter loop
  26. dec b
  27. jr nz, .fouter
  28. ; -- second loop --
  29. ld hl, wShadowOAM+1
  30. ld a, [dPlayerHeight]
  31. ld b, a
  32. .souter
  33. ld d, 8
  34. ld a, [rPlayerX]
  35. add d
  36. ld d, a
  37. ld a, [dPlayerWidth]
  38. ld c, a
  39. .sinner
  40. ld a, d
  41. ld [hl], a
  42. add 8
  43. ld d, a
  44. ld a, 4
  45. call .add4hl
  46. dec c
  47. jr nz, .sinner
  48. dec b
  49. jr nz, .souter
  50. ; -- third loop --
  51. ld hl, wShadowOAM+2
  52. ld de, dPlayerSpriteTiles
  53. ld a, [dPlayerHeight]
  54. ld b, a
  55. ld a, [dPlayerWidth]
  56. ld c, a
  57. xor a
  58. .tloop1
  59. add b
  60. dec c
  61. jr nz, .tloop1
  62. ld c, a
  63. .tloop2
  64. ld a, [de]
  65. ld [hl], a
  66. ld a, 4
  67. call .add4hl
  68. inc de
  69. dec c
  70. jr nz, .tloop2
  71. ; -- fourth loop --
  72. ld hl, wShadowOAM+3
  73. ld a, [dPlayerHeight]
  74. ld b, a
  75. ld a, [dPlayerWidth]
  76. ld c, a
  77. xor a
  78. .lloop1
  79. add b
  80. dec c
  81. jr nz, .lloop1
  82. ld c, a
  83. .lloop2
  84. xor a
  85. ld [hl], a
  86. ld a, 4
  87. call .add4hl
  88. dec c
  89. jr nz, .lloop2
  90. ret
  91. .add4hl:
  92. add a, l ; a = low + old_l
  93. ld l, a ; a = low + old_l = new_l
  94. adc a, h ; a = new_l + old_h + carry
  95. sub l ; a = old_h + carry
  96. ld h, a
  97. ret
  98. PC_Update:
  99. ld b, 0
  100. ld c, 0
  101. ld a, [hCurKeys]
  102. and %10000000
  103. cp %10000000 ; 0 if down pressed
  104. jr nz, .up
  105. ld b, 1
  106. .up:
  107. ld a, [hCurKeys]
  108. and %01000000
  109. cp %01000000 ; 0 if up pressed
  110. jr nz, .left
  111. ld b, 255
  112. .left:
  113. ld a, [hCurKeys]
  114. and %00100000
  115. cp %00100000 ; 0 if down pressed
  116. jr nz, .right
  117. ld c, 255
  118. .right:
  119. ld a, [hCurKeys]
  120. and %00010000
  121. cp %00010000 ; 0 if up pressed
  122. jr nz, .last
  123. ld c, 1
  124. .last:
  125. ld a, [rPlayerX]
  126. add c
  127. ld [rPlayerX], a
  128. ld a, [rPlayerY]
  129. add b
  130. ld [rPlayerY], a
  131. .end:
  132. ret
  133. Clear_OAM:
  134. ld hl, wShadowOAM
  135. ld bc, wShadowOAMEnd - wShadowOAM
  136. .loop:
  137. xor a
  138. ld [hli], a
  139. dec bc
  140. ld a, b
  141. or c
  142. jr nz, .loop
  143. ret
  144. Clear_Map:
  145. ld hl, _SCRN0
  146. ld bc, _SCRN0_END - _SCRN0
  147. .loop:
  148. xor a
  149. ld [hli], a
  150. dec bc
  151. ld a, b
  152. or c
  153. jr nz, .loop
  154. ret
  155. Load_Tiles:
  156. ld hl, _BGTILES
  157. ld de, parecivo_tile_data
  158. ld bc, parecivo_tile_data_size
  159. call MemCpy
  160. ld hl, _VRAM
  161. ld de, parecivo_tile_data
  162. ld bc, parecivo_tile_data_size
  163. call MemCpy
  164. ret
  165. Load_Map:
  166. ld hl, _SCRN0
  167. ld de, Map
  168. ld bc, Map_Size
  169. call MemCpy
  170. ret