Last active
January 28, 2017 22:28
-
-
Save flupe/af2a9ca368ad07f125102304c742907f to your computer and use it in GitHub Desktop.
bresenham please forgive me
This file contains hidden or 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
| main: | |
| call clear_screen | |
| letl r0 0xff | |
| leth r0 0b00000011 | |
| letl r1 3 | |
| letl r2 10 | |
| letl r3 100 | |
| letl r4 50 | |
| ; this should be cyan | |
| call draw | |
| jump 0 | |
| .align16 | |
| clear_screen: | |
| letl r1 11 | |
| lsl r1 r1 12 | |
| clear_loop: | |
| wmem r0 [r1] | |
| add r1 r1 1 | |
| snif r1 eq 0 | |
| jump clear_loop | |
| return | |
| .align16 | |
| draw: | |
| ; SETUP | |
| copy r8 r3 | |
| copy r9 r4 | |
| add r3 r2 1 | |
| lsl r4 r3 7 | |
| lsl r3 r3 5 | |
| add r3 r3 r4 | |
| sub r3 r3 r1 | |
| letl r4 0 | |
| sub r3 r4 r3 | |
| snif r1 gt r8 | |
| jump draw_right | |
| sub r4 r1 r8 | |
| letl r6 -1 | |
| jump draw_dy | |
| draw_right: | |
| sub r4 r8 r1 | |
| letl r6 1 | |
| draw_dy: | |
| snif r2 gt r9 | |
| jump draw_up | |
| sub r5 r2 r9 | |
| letl r7 160 | |
| leth r7 0 | |
| jump draw_switch | |
| draw_up: | |
| sub r5 r9 r2 | |
| letl r7 96 | |
| leth r7 0xff | |
| ; LOOPS | |
| draw_switch: | |
| snif r4 gt r5 | |
| jump draw_diry | |
| ; ALONG X | |
| letl r1 0 | |
| lsl r2 r5 1 | |
| sub r2 r2 r4 | |
| draw_loopx: | |
| wmem r0 [r3] | |
| snif r2 sgt 0 | |
| jump no_stepx | |
| add r3 r3 r7 | |
| sub r2 r2 r4 | |
| no_stepx: | |
| add r1 r1 1 | |
| add r2 r2 r5 | |
| add r3 r3 r6 | |
| snif r1 ge r4 | |
| jump draw_loopx | |
| return | |
| ; ALONG Y | |
| draw_diry: | |
| letl r1 0 | |
| lsl r2 r4 1 | |
| sub r2 r2 r5 | |
| draw_loopy: | |
| wmem r0 [r3] | |
| snif r2 sgt 0 | |
| jump no_stepy | |
| add r3 r3 r6 | |
| sub r2 r2 r5 | |
| no_stepy: | |
| add r1 r1 1 | |
| add r2 r2 r4 | |
| add r3 r3 r7 | |
| snif r1 ge r5 | |
| jump draw_loopy | |
| return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment