Created
November 27, 2011 00:55
-
-
Save FireyFly/1396668 to your computer and use it in GitHub Desktop.
NIC programs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Program that moves around a 0xff word a 2D array with a | |
// width of 16 and a height of 8 occupying the memory pos- | |
// itions 0x80 - 0xff (inclusive), bouncing off edges. | |
// | |
// Author : Jonas Hoglund | |
// Date : 2011-11-21 | |
// | |
// Constants | |
loadc re 0x00 | |
loadc rf 0xff // -1 | |
// Variables | |
loadc r3 0x88 // Position pointer | |
loadc r5 0x10 // dy = 16 (+/- 0x10 moves one "row" up/down) | |
loadc r6 0x02 // dx = 2 (+/- 0x02 moves one word left/right) | |
Loop: move r5 r1 | |
add r1 r1 r6 // r1 = delta pointer | |
// Clear old, update position pointer, draw new cell | |
storer re r3 | |
add r3 r3 r1 | |
storer rf r3 | |
// if (a & 0x0f == 0x0e || a & 0x0f == 0x00) | |
// flip horizontal delta | |
loadc r0 0x0f | |
and r1 r3 r0 // r1 = a & 0x0f | |
loadc r0 0x0e | |
jumpe r1 Next1 // == 0x0e ? | |
loadc r0 0x00 | |
jumpn r1 Chek2 // == 0x00 ? | |
Next1: mul r6 r6 rf // flip horizontal delta | |
// if (a & 0xf0 == 0xf0 || a & 0xf0 == 0x80) | |
// flip vertical delta | |
Chek2: loadc r0 0xf0 | |
and r1 r3 r0 // r1 = a & 0xf0 | |
jumpe r1 Next2 // == 0xf0 ? | |
loadc r0 0x80 | |
jumpn r1 Loop // == 0x80 ? | |
Next2: mul r5 r5 rf // flip vertical delta | |
jump Loop // Repeat ad infinitum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment