Guest User

[CC] [CHIPER] Moving Pixel

a guest
Mar 30th, 2017
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. ; refresh screen
  2. ld I, $FFF
  3. ld (I), $1
  4. ; ---------------------
  5.  
  6. ; set screen text color to black
  7. ld I, $FFD
  8. ld (I), $F
  9. ; ---------------------
  10.  
  11. .loop
  12.  
  13. ; this will fix any trailing behind the pixel
  14. ld A, $20
  15. ld I, $FFE
  16. ld (I), A
  17. ; ---------------------
  18.  
  19. call updatePixel ; call the update pixel function
  20.  
  21. ; show the pixel
  22. ld A, $81 ; this is the pixel HEX value
  23. ld I, $FFE
  24. ld (I), A
  25. ; ---------------------
  26.  
  27. ; refresh screen
  28. ld I, $FFF
  29. ld (I), $1
  30. ; ---------------------
  31.  
  32. jmp loop ; loop back
  33.  
  34. .updatePixel
  35.  
  36. ld I, $FF9 ; load the current key pressed
  37. ld A, (I) ; store it in register A
  38. ld B, #0 ; reset B to 0 (so we would not add B always)
  39. add B, A ; move A to B
  40. eql A, $3 ; check if its Left key
  41. call left ; if true call .left
  42. eql A, $4 ; check if its Right key
  43. call right ; if true call .right
  44. eql A, $1 ; check if its Up key
  45. call up ; if true call .up
  46. eql A, $2 ; check if its down key
  47. call down ; if true call .down
  48.  
  49. ret
  50.  
  51. .left ; left movement
  52.  
  53. ; load screen X pos and update it
  54. ld I, $FFA
  55. ld A, (I)
  56. sub A, #1
  57. ld (I), A
  58. ; ---------------------
  59.  
  60. call resetKey ; reset the key
  61. ret
  62.  
  63. .right ; right movement
  64.  
  65. ; load screen X pos and update it
  66. ld I, $FFA
  67. ld A, (I)
  68. add A, #1
  69. ld (I), A
  70. ; ---------------------
  71.  
  72. call resetKey ; reset the key
  73. ret
  74.  
  75. .up ; up movement
  76.  
  77. ; load screen Y pos and update it
  78. ld I, $FFB
  79. ld A, (I)
  80. sub A, #1
  81. ld (I), A
  82. ; ---------------------
  83.  
  84. call resetKey ; reset the key
  85. ret
  86.  
  87. .down ; down movement
  88.  
  89. ; load screen Y pos and update it
  90. ld I, $FFB
  91. ld A, (I)
  92. add A, #1
  93. ld (I), A
  94. ; ---------------------
  95.  
  96. call resetKey ; reset the key
  97. ret
  98.  
  99. .resetKey
  100.  
  101. ; moves B value to A
  102. ld A, #0
  103. add A, B
  104. ret
Advertisement
Add Comment
Please, Sign In to add comment