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.

71 lines
1.3KB

  1. ;----------------------
  2. ; Utility Subroutines
  3. ;----------------------
  4. SECTION "Util Subs", ROM0
  5. ; MemCpy assumes:
  6. ; hl contains destination address
  7. ; de contains source address
  8. ; bc contains number of bytes to copy
  9. MemCpy:
  10. .copy
  11. ld a, [de]
  12. ld [hli], a
  13. inc de
  14. dec bc
  15. ld a, b
  16. or c
  17. jr nz, .copy
  18. ret
  19. ; Read_Pad will set the variable _PAD
  20. ; such that bits are as follows:
  21. ; 7 - 4: down up left right
  22. ; 3 - 0: start select b a
  23. Read_Pad:
  24. ld a,P1F_BUTTONS
  25. call .onenibble
  26. ld b,a ; B7-4 = 1; B3-0 = unpressed buttons
  27. ld a,P1F_DPAD
  28. call .onenibble
  29. swap a ; A3-0 = unpressed directions; A7-4 = 1
  30. xor b ; A = pressed buttons + directions
  31. ld b,a ; B = pressed buttons + directions
  32. ; check illegal buttons
  33. and %11000000 ; Up and Down buttons
  34. cp %11000000
  35. jr nz, .legalUpDown
  36. ld a, b
  37. and %00111111
  38. ld b, a
  39. .legalUpDown
  40. and %00110000 ; Left and Right buttons
  41. cp %00110000
  42. jr nz, .legalLeftRight
  43. ld a, b
  44. and %11001111
  45. .legalLeftRight
  46. ld a,P1F_NONE
  47. ld [rP1],a
  48. ldh a,[hCurKeys]
  49. xor b ; A = keys that changed state
  50. and b ; A = keys that changed to pressed
  51. ldh [hNewKeys],a
  52. ld a,b
  53. ldh [hCurKeys],a
  54. ret
  55. .onenibble:
  56. ldh [rP1],a
  57. ldh a,[rP1]
  58. ldh a,[rP1]
  59. ldh a,[rP1]
  60. or $F0
  61. ret