Advertisement
Guest User

Untitled

a guest
May 26th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. translatePositions: // Iterates through Z (positions) to translate into matrix
  2. cp length, loopcounter
  3. breq exit2
  4. nop
  5. ld temp1, Z+
  6. mov temp2, temp1
  7. andi temp2, 0b11110000 // Mask out X-value (first 4 bits)
  8. lsr temp2 // Shift 4 steps right to make compares easier
  9. lsr temp2
  10. lsr temp2
  11. lsr temp2
  12. cpi temp2, 0
  13. breq X_0
  14. nop
  15. cpi temp2, 1
  16. breq X_1
  17. nop
  18. cpi temp2, 2
  19. breq X_2
  20. nop
  21. cpi temp2, 3
  22. breq X_3
  23. nop
  24. cpi temp2, 4
  25. breq X_4
  26. nop
  27. cpi temp2, 5
  28. breq X_5
  29. nop
  30. cpi temp2, 6
  31. breq X_6
  32. nop
  33. cpi temp2, 7
  34. breq X_7
  35. nop
  36.  
  37. exit1:
  38. subi loopcounter, -1 // increment i
  39. //subi ZL, -1 // increase pointer (next position is to be read)
  40. jmp translatePositions
  41. nop
  42. exit2:
  43. ldi ZL, LOW(snakebody) // reset pointer before returning to main
  44. ret
  45. nop
  46. X_0:
  47. ldi temp3, 0b00000001
  48. jmp calcYPos
  49. nop
  50. X_1:
  51. ldi temp3, 0b00000010
  52. jmp calcYPos
  53. nop
  54. X_2:
  55. ldi temp3, 0b00000100
  56. jmp calcYPos
  57. nop
  58. X_3:
  59. ldi temp3, 0b00001000
  60. jmp calcYPos
  61. nop
  62. X_4:
  63. ldi temp3, 0b00010000
  64. jmp calcYPos
  65. nop
  66. X_5:
  67. ldi temp3, 0b00100000
  68. jmp calcYPos
  69. nop
  70. X_6:
  71. ldi temp3, 0b01000000
  72. jmp calcYPos
  73. nop
  74. X_7:
  75. ldi temp3, 0b10000000
  76. jmp calcYPos
  77. nop
  78. calcYPos: // Calculate which Y position in matrix to draw to
  79. mov temp4, temp1
  80. andi temp4, 0b00001111
  81. cpi temp4, 0
  82. breq Y_0
  83. nop
  84. cpi temp4, 1
  85. breq Y_1
  86. nop
  87. cpi temp4, 2
  88. breq Y_2
  89. nop
  90. cpi temp4, 3
  91. breq Y_3
  92. nop
  93. cpi temp4, 4
  94. breq Y_4
  95. nop
  96. cpi temp4, 5
  97. breq Y_5
  98. nop
  99. cpi temp4, 6
  100. breq Y_6
  101. nop
  102. cpi temp4, 7
  103. breq Y_7
  104. nop
  105. Y_0: // Save previous value of matrix row and insert new
  106. ld temp4, Y
  107. or temp3, temp4
  108. st Y, temp3
  109. jmp exit1
  110. nop
  111. Y_1:
  112. ldd temp4, Y+1
  113. or temp3, temp4
  114. std Y+1, temp3
  115. jmp exit1
  116. nop
  117. Y_2:
  118. ldd temp4, Y+2
  119. or temp3, temp4
  120. std Y+2, temp3
  121. jmp exit1
  122. nop
  123. Y_3:
  124. ldd temp4, Y+3
  125. or temp3, temp4
  126. std Y+3, temp3
  127. jmp exit1
  128. nop
  129. Y_4:
  130. ldd temp4, Y+4
  131. or temp3, temp4
  132. std Y+4, temp3
  133. jmp exit1
  134. nop
  135. Y_5:
  136. ldd temp4, Y+5
  137. or temp3, temp4
  138. std Y+5, temp3
  139. jmp exit1
  140. nop
  141. Y_6:
  142. ldd temp4, Y+6
  143. or temp3, temp4
  144. std Y+6, temp3
  145. jmp exit1
  146. nop
  147. Y_7:
  148. ldd temp4, Y+7
  149. or temp3, temp4
  150. std Y+7, temp3
  151. jmp exit1
  152. nop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement