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.

61 lines
1.2KB

  1. ;------------------
  2. ; DMA Subroutines
  3. ;------------------
  4. ; In order to use, simply put your destination
  5. ; address into the `a` register, and call `hOAMDMA`
  6. ; Here we copy our DMA Routine into
  7. ; HRAM, which it needs to be in so
  8. ; it can function.
  9. ; Note: we can only copy into HRAM
  10. ; while the screen /ISN'T/ updating
  11. SECTION "OAM DMA Routine", ROM0
  12. ; A DMA Transfor takes 160 microseconds
  13. ; to complete, which is 40 machine cycles.
  14. ; here we copy the high bit of our destination
  15. ; address (stored in a) to the DMA register
  16. ; then wait the time needed for the copy to
  17. ; complete.
  18. DMARoutine:
  19. ldh [rDMA], a
  20. ld a, 40
  21. .wait
  22. dec a
  23. jr nz, .wait
  24. ret
  25. .end
  26. CopyDMARoutine:
  27. ld hl, DMARoutine
  28. ld b, DMARoutine.end - DMARoutine
  29. ld c, LOW(hOAMDMA)
  30. .copy
  31. ld a, [hli]
  32. ldh [c], a
  33. inc c
  34. dec b
  35. jr nz, .copy
  36. ret
  37. ; We reserve space in HRAM to keep our
  38. ; DMA routine.
  39. SECTION "OAM DMA", HRAM
  40. hOAMDMA:
  41. ds DMARoutine.end - DMARoutine
  42. ; We also reserve space to have a copy
  43. ; of OAM that we can write to at any time
  44. ; The DMA will then mirror this data to
  45. ; the real OAM.
  46. SECTION "Shadow OAM", WRAM0,ALIGN[8]
  47. wShadowOAM::
  48. ds 4*40
  49. wShadowOAMEnd::