Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- translatePositions: // Iterates through Z (positions) to translate into matrix
- cp length, loopcounter
- breq exit2
- nop
- ld temp1, Z+
- mov temp2, temp1
- andi temp2, 0b11110000 // Mask out X-value (first 4 bits)
- lsr temp2 // Shift 4 steps right to make compares easier
- lsr temp2
- lsr temp2
- lsr temp2
- cpi temp2, 0
- breq X_0
- nop
- cpi temp2, 1
- breq X_1
- nop
- cpi temp2, 2
- breq X_2
- nop
- cpi temp2, 3
- breq X_3
- nop
- cpi temp2, 4
- breq X_4
- nop
- cpi temp2, 5
- breq X_5
- nop
- cpi temp2, 6
- breq X_6
- nop
- cpi temp2, 7
- breq X_7
- nop
- exit1:
- subi loopcounter, -1 // increment i
- //subi ZL, -1 // increase pointer (next position is to be read)
- jmp translatePositions
- nop
- exit2:
- ldi ZL, LOW(snakebody) // reset pointer before returning to main
- ret
- nop
- X_0:
- ldi temp3, 0b00000001
- jmp calcYPos
- nop
- X_1:
- ldi temp3, 0b00000010
- jmp calcYPos
- nop
- X_2:
- ldi temp3, 0b00000100
- jmp calcYPos
- nop
- X_3:
- ldi temp3, 0b00001000
- jmp calcYPos
- nop
- X_4:
- ldi temp3, 0b00010000
- jmp calcYPos
- nop
- X_5:
- ldi temp3, 0b00100000
- jmp calcYPos
- nop
- X_6:
- ldi temp3, 0b01000000
- jmp calcYPos
- nop
- X_7:
- ldi temp3, 0b10000000
- jmp calcYPos
- nop
- calcYPos: // Calculate which Y position in matrix to draw to
- mov temp4, temp1
- andi temp4, 0b00001111
- cpi temp4, 0
- breq Y_0
- nop
- cpi temp4, 1
- breq Y_1
- nop
- cpi temp4, 2
- breq Y_2
- nop
- cpi temp4, 3
- breq Y_3
- nop
- cpi temp4, 4
- breq Y_4
- nop
- cpi temp4, 5
- breq Y_5
- nop
- cpi temp4, 6
- breq Y_6
- nop
- cpi temp4, 7
- breq Y_7
- nop
- Y_0: // Save previous value of matrix row and insert new
- ld temp4, Y
- or temp3, temp4
- st Y, temp3
- jmp exit1
- nop
- Y_1:
- ldd temp4, Y+1
- or temp3, temp4
- std Y+1, temp3
- jmp exit1
- nop
- Y_2:
- ldd temp4, Y+2
- or temp3, temp4
- std Y+2, temp3
- jmp exit1
- nop
- Y_3:
- ldd temp4, Y+3
- or temp3, temp4
- std Y+3, temp3
- jmp exit1
- nop
- Y_4:
- ldd temp4, Y+4
- or temp3, temp4
- std Y+4, temp3
- jmp exit1
- nop
- Y_5:
- ldd temp4, Y+5
- or temp3, temp4
- std Y+5, temp3
- jmp exit1
- nop
- Y_6:
- ldd temp4, Y+6
- or temp3, temp4
- std Y+6, temp3
- jmp exit1
- nop
- Y_7:
- ldd temp4, Y+7
- or temp3, temp4
- std Y+7, temp3
- jmp exit1
- nop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement