diff options
author | kdx <kikoodx@paranoici.org> | 2023-04-14 14:04:37 +0200 |
---|---|---|
committer | kdx <kikoodx@paranoici.org> | 2023-04-14 14:04:37 +0200 |
commit | 21eaa6a2f9dae7469c4c593b92398a9385ec7655 (patch) | |
tree | 2a3d0afe26fe9fa9617fc4774f3f4532cdecf7bb | |
parent | 25e74dfd1f67eaac9ed608d351da992695969c2b (diff) | |
download | orga-21eaa6a2f9dae7469c4c593b92398a9385ec7655.tar.gz |
move a pixel around
-rw-r--r-- | samples/move.orgaasm | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/samples/move.orgaasm b/samples/move.orgaasm new file mode 100644 index 0000000..2a32cfc --- /dev/null +++ b/samples/move.orgaasm @@ -0,0 +1,74 @@ +@main + SLP + /input/update + /player/erase + /player/update + /player/draw + JMP ,main + +@input.kleft 0000 +@input.kright 0000 +@input.kup 0000 +@input.kdown 0000 +@input/update ( -- ) + -Input LDA + DUP #0010 AND #0000 NEQ -input.kup STA + DUP #0020 AND #0000 NEQ -input.kdown STA + DUP #0040 AND #0000 NEQ -input.kleft STA + #0080 AND #0000 NEQ -input.kright STA + RET + +@player.x 0040 +@player.y 0040 + +@player/update ( -- ) +@player/update/movex + #0004 #007b + -player.x LDA + -input.kleft LDA SUB + -input.kright LDA ADD + /clamp -player.x STA +@player/update/movey + #0004 #007b + -player.y LDA + -input.kup LDA SUB + -input.kdown LDA ADD + /clamp -player.y STA + RET + +@player/erase ( -- ) + -player.x LDA + -player.y LDA + #0000 /draw/pixel + RET + +@player/draw ( -- ) + -player.x LDA + -player.y LDA + #ffff /draw/pixel + RET + +@draw/pixel ( x y col -- ) + ROT ROT + #0080 MUL ADD -Screen ADD + STA + RET + +@clamp ( min max a -- b ) + /min /max RET + +@min ( a b -- a < b ? a : b ) + OVR OVR LTH + JNZ ,min/morethan + SWP +@min/morethan + POP + RET + +@max ( a b -- a > b ? a : b ) + OVR OVR GTH + JNZ ,max/lessthan + SWP +@max/lessthan + POP + RET |