uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit c191c7ea3dcbbe7b8f6d25b491dae770feca651a
parent 5eedfea8e6f8164ba4e857d681d8efd99355a3b2
Author: neauoire <aliceffekt@gmail.com>
Date:   Mon, 22 Mar 2021 09:42:48 -0700

Added circle to shapes

Diffstat:
Mbuild.sh | 2+-
Mprojects/examples/dev.screen.usm | 8++++----
Dprojects/examples/gui.bezier.usm | 145-------------------------------------------------------------------------------
Aprojects/examples/gui.ripples.usm | 94+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mprojects/examples/gui.shapes.usm | 37+++++++++++++++++++++++++++++++++++++
5 files changed, 136 insertions(+), 150 deletions(-)

diff --git a/build.sh b/build.sh @@ -20,5 +20,5 @@ cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werr # cc uxn.c emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -o bin/emulator # run -./bin/assembler projects/software/noodle.usm bin/boot.rom +./bin/assembler projects/examples/gui.ripples.usm bin/boot.rom ./bin/emulator bin/boot.rom diff --git a/projects/examples/dev.screen.usm b/projects/examples/dev.screen.usm @@ -52,16 +52,16 @@ BRK ( update colors every 40 frames ) ~timer #40 NEQ ,skip1 ROT JMP2? - #0fac #fffa STR2 #f0bb #fffc STR2 #f053 #fff8 STR2 + #0fac #01fa STR2 #f0bb #01fc STR2 #f053 #01f8 STR2 @skip1 ~timer #80 NEQ ,skip2 ROT JMP2? - #00fc #fffc STR2 #f0bb #fff8 STR2 #f053 #fffa STR2 + #00fc #01fc STR2 #f0bb #01f8 STR2 #f053 #01fa STR2 @skip2 ~timer #c0 NEQ ,skip3 ROT JMP2? - #000f #fff8 STR2 #0f0f #fffa STR2 #ff00 #fffc STR2 + #000f #01f8 STR2 #0f0f #01fa STR2 #0100 #01fc STR2 @skip3 ~timer #00 NEQ ,skip4 ROT JMP2? - #f0ac #fff8 STR2 #f0bb #fffa STR2 #f053 #fffc STR2 + #f0ac #01f8 STR2 #f0bb #01fa STR2 #f053 #01fc STR2 @skip4 ~timer #01 ADD =timer diff --git a/projects/examples/gui.bezier.usm b/projects/examples/gui.bezier.usm @@ -1,145 +0,0 @@ -( draw bezier ) - -%RTN { JMP2r } -%2/ { #0002 DIV2 } -%ABS2 { DUP2 #000f SFT2 #ffff SWP2 SWP POP MUL2? } -%STEP8 { #0033 SFT2 } -%STEP4 { #0022 SFT2 } - -;pt1 { x 2 y 2 } -;pt2 { x 2 y 2 } -;pt3 { x 2 y 2 } -;pta { x 2 y 2 } -;ptb { x 2 y 2 } -;line { x0 2 y0 2 x 2 y 2 sx 2 sy 2 dx 2 dy 2 e1 2 e2 2 } -;color { byte 1 } -;pointer { x 2 y 2 } -;i { byte 1 } -;j { byte 1 } - -( devices ) - -|0100 ;Console { pad 8 char 1 byte 1 short 2 } -|0110 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 } -|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 } -|0150 ;Mouse { x 2 y 2 state 1 chord 1 } -|01F0 .RESET .FRAME .ERROR ( vectors ) -|01F8 [ 13fd 1ef3 1bf2 ] ( palette ) - -|0200 @RESET - - #0020 #0020 =pt1.y =pt1.x - #0040 #0080 =pt2.y =pt2.x - #00f0 #00a0 =pt3.y =pt3.x - - ,redraw JSR2 - -BRK - -@FRAME - - ,draw-cursor JSR2 - - ,$no-touch ~Mouse.state #00 EQU JMP2? - - ~Mouse.x STEP4 =pt2.x - ~Mouse.y STEP4 =pt2.y - ,redraw JSR2 - - $no-touch - -BRK - -@redraw - - #0000 =Sprite.y - $ver - #0000 =Sprite.x - $hor - ( draw ) #00 =Sprite.color - ( incr ) ~Sprite.x #0008 ADD2 =Sprite.x - ( incr ) #0000 =Sprite.addr - ,$hor ~Sprite.x ~Screen.width LTH2 JMP2? - ( incr ) ~Sprite.y #0008 ADD2 =Sprite.y - ,$ver ~Sprite.y ~Screen.height LTH2 JMP2? - - ~pt1.x ~pt1.y ~pt2.x ~pt2.y #03 ,draw-line JSR2 - ~pt2.x ~pt2.y ~pt3.x ~pt3.y #03 ,draw-line JSR2 - - ~pt1.x ~pt1.y #0a ,draw-point JSR2 - ~pt2.x ~pt2.y #0a ,draw-point JSR2 - ~pt3.x ~pt3.y #0a ,draw-point JSR2 - - #00 =i - - $loop - ~pt1.x ~pt2.x ~pt1.x SUB2 #0008 DIV2 #00 ~i MUL2 ADD2 =pta.x - ~pt1.y ~pt2.y ~pt1.y SUB2 #0008 DIV2 #00 ~i MUL2 ADD2 =pta.y - ~pt2.x ~pt3.x ~pt2.x SUB2 #0008 DIV2 #00 ~i MUL2 ADD2 =ptb.x - ~pt2.y ~pt3.y ~pt2.y SUB2 #0008 DIV2 #00 ~i MUL2 ADD2 =ptb.y - ~pta.x ~pta.y ~ptb.x ~ptb.y #0a ,draw-line JSR2 - ( incr ) ~i #01 ADD =i - ,$loop ~i #08 LTH JMP2? - -RTN - -@draw-point ( x y color ) - - =color - #0003 SUB2 =Sprite.y - #0003 SUB2 =Sprite.x - ,handle =Sprite.addr - ~color =Sprite.color - -RTN - -@draw-line ( x1 y1 x2 y2 color ) - - ( load ) =color =line.y0 =line.x0 =line.y =line.x - ~line.x0 ~line.x SUB2 ABS2 =line.dx - ~line.y0 ~line.y SUB2 ABS2 #0000 SWP2 SUB2 =line.dy - #ffff #00 ~line.x ~line.x0 LTS2 #0002 MUL2 ADD2 =line.sx - #ffff #00 ~line.y ~line.y0 LTS2 #0002 MUL2 ADD2 =line.sy - ~line.dx ~line.dy ADD2 =line.e1 - $loop - ~line.x =Screen.x ~line.y =Screen.y ~color =Screen.color - ,$end ~line.x ~line.x0 EQU2 ~line.y ~line.y0 EQU2 #0101 EQU2 JMP2? - ~line.e1 #0002 MUL2 =line.e2 - ,$skipy ~line.e2 ~line.dy LTS2 JMP2? - ~line.e1 ~line.dy ADD2 =line.e1 - ~line.x ~line.sx ADD2 =line.x - $skipy - ,$skipx ~line.e2 ~line.dx GTS2 JMP2? - ~line.e1 ~line.dx ADD2 =line.e1 - ~line.y ~line.sy ADD2 =line.y - $skipx - ,$loop JMP2 - - $end - -RTN - -@draw-cursor - - ( clear last cursor ) - ,clear_icn =Sprite.addr - ~pointer.x =Sprite.x - ~pointer.y =Sprite.y - #10 =Sprite.color - - ( record pointer positions ) - ~Mouse.x =pointer.x ~Mouse.y =pointer.y - - ( draw new cursor ) - ,cursor_icn =Sprite.addr - ~pointer.x =Sprite.x - ~pointer.y =Sprite.y - #11 =Sprite.color - -RTN - -@handle [ 0010 2844 2810 0000 ] -@clear_icn [ 0000 0000 0000 0000 ] -@cursor_icn [ 80c0 e0f0 f8e0 1000 ] - -@ERROR BRK diff --git a/projects/examples/gui.ripples.usm b/projects/examples/gui.ripples.usm @@ -0,0 +1,93 @@ +( draw routines ) + +%RTN { JMP2r } +%++ { #0001 ADD2 } +%-- { #0001 SUB2 } +%8+ { #0008 ADD2 } +%ABS2 { DUP2 #000f SFT2 #ffff SWP2 SWP POP MUL2? } + +;color { byte 1 } +;pointer { x 2 y 2 } +;circle { xc 2 yc 2 x 2 y 2 r 2 d 2 } + +|0110 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 } +|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 } +|0150 ;Mouse { x 2 y 2 state 1 chord 1 } +|01F0 .RESET .FRAME .ERROR ( vectors ) +|01F8 [ 13fd 1ef3 1bf2 ] ( palette ) + +|0200 @RESET + +BRK + +@FRAME + + ( clear ) + ~circle.xc ~circle.yc ~circle.r #00 ,draw-circle JSR2 + + ,draw-cursor JSR2 + + ,$no-touch ~Mouse.state #00 EQU JMP2? + ~Mouse.x =circle.xc + ~Mouse.y =circle.yc + #0000 =circle.r + $no-touch + + ( draw ) + ~circle.xc ~circle.yc ~circle.r #0001 ADD2 #03 ,draw-circle JSR2 + +BRK + +@draw-cursor + + ( clear last cursor ) + ,clear_icn =Sprite.addr + ~pointer.x =Sprite.x + ~pointer.y =Sprite.y + #10 =Sprite.color + + ( record pointer positions ) + ~Mouse.x =pointer.x ~Mouse.y =pointer.y + + ( draw new cursor ) + ,cursor_icn =Sprite.addr + ~pointer.x =Sprite.x + ~pointer.y =Sprite.y + #11 =Sprite.color + +RTN + +@draw-circle ( xc yc r color ) + + ( load ) =color =circle.r =circle.yc =circle.xc + #0000 =circle.x ~circle.r =circle.y + ~circle.r #0002 MUL2 #0003 SUB2 =circle.d + ( draw ) ,$seg JSR2 + $loop + ( incr ) ~circle.x ++ =circle.x + ,$else ~circle.d #0000 #0001 ADD2 LTS2 JMP2? + ( decr ) ~circle.y -- =circle.y + ~circle.x ~circle.y SUB2 #0004 MUL2 ~circle.d ADD2 #000a ADD2 =circle.d + ,$end JMP2 + $else + ~circle.x #0004 MUL2 ~circle.d ADD2 #0006 ADD2 =circle.d + $end + ( draw ) ,$seg JSR2 + ,$loop ~circle.y ~circle.x #0001 SUB2 GTS2 JMP2? + RTN + $seg + ~circle.xc ~circle.x ADD2 =Screen.x ~circle.yc ~circle.y ADD2 =Screen.y ~color =Screen.color + ~circle.xc ~circle.x SUB2 =Screen.x ~circle.yc ~circle.y ADD2 =Screen.y ~color =Screen.color + ~circle.xc ~circle.x ADD2 =Screen.x ~circle.yc ~circle.y SUB2 =Screen.y ~color =Screen.color + ~circle.xc ~circle.x SUB2 =Screen.x ~circle.yc ~circle.y SUB2 =Screen.y ~color =Screen.color + ~circle.xc ~circle.y ADD2 =Screen.x ~circle.yc ~circle.x ADD2 =Screen.y ~color =Screen.color + ~circle.xc ~circle.y SUB2 =Screen.x ~circle.yc ~circle.x ADD2 =Screen.y ~color =Screen.color + ~circle.xc ~circle.y ADD2 =Screen.x ~circle.yc ~circle.x SUB2 =Screen.y ~color =Screen.color + ~circle.xc ~circle.y SUB2 =Screen.x ~circle.yc ~circle.x SUB2 =Screen.y ~color =Screen.color + +RTN + +@ERROR BRK + +@clear_icn [ 0000 0000 0000 0000 ] +@cursor_icn [ 80c0 e0f0 f8e0 1000 ] +\ No newline at end of file diff --git a/projects/examples/gui.shapes.usm b/projects/examples/gui.shapes.usm @@ -2,6 +2,7 @@ %RTN { JMP2r } %++ { #0001 ADD2 } +%-- { #0001 SUB2 } %8+ { #0008 ADD2 } %ABS2 { DUP2 #000f SFT2 #ffff SWP2 SWP POP MUL2? } @@ -11,6 +12,8 @@ ;line { x0 2 y0 2 x 2 y 2 sx 2 sy 2 dx 2 dy 2 e1 2 e2 2 } ;color { byte 1 } +;circle { xc 2 yc 2 x 2 y 2 r 2 d 2 } + |0110 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 } |0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 } |01F0 .RESET .FRAME .ERROR ( vectors ) @@ -39,6 +42,10 @@ #0020 #0080 #0070 #0030 #02 ,draw-line JSR2 #00a0 #0020 #0050 #00b0 #03 ,draw-line JSR2 #00b0 #0090 #0030 #0010 #01 ,draw-line JSR2 + + #0040 #0040 #0030 #01 ,draw-circle JSR2 + #0070 #0030 #0040 #02 ,draw-circle JSR2 + #0050 #0080 #0050 #03 ,draw-circle JSR2 BRK @@ -126,6 +133,36 @@ RTN RTN +@draw-circle ( xc yc r color ) + + ( load ) =color =circle.r =circle.yc =circle.xc + #0000 =circle.x ~circle.r =circle.y + ~circle.r #0002 MUL2 #0003 SUB2 =circle.d + ( draw ) ,$seg JSR2 + $loop + ( incr ) ~circle.x ++ =circle.x + ,$else ~circle.d #0000 #0001 ADD2 LTS2 JMP2? + ( decr ) ~circle.y -- =circle.y + ~circle.x ~circle.y SUB2 #0004 MUL2 ~circle.d ADD2 #000a ADD2 =circle.d + ,$end JMP2 + $else + ~circle.x #0004 MUL2 ~circle.d ADD2 #0006 ADD2 =circle.d + $end + ( draw ) ,$seg JSR2 + ,$loop ~circle.y ~circle.x #0001 SUB2 GTS2 JMP2? + RTN + $seg + ~circle.xc ~circle.x ADD2 =Screen.x ~circle.yc ~circle.y ADD2 =Screen.y ~color =Screen.color + ~circle.xc ~circle.x SUB2 =Screen.x ~circle.yc ~circle.y ADD2 =Screen.y ~color =Screen.color + ~circle.xc ~circle.x ADD2 =Screen.x ~circle.yc ~circle.y SUB2 =Screen.y ~color =Screen.color + ~circle.xc ~circle.x SUB2 =Screen.x ~circle.yc ~circle.y SUB2 =Screen.y ~color =Screen.color + ~circle.xc ~circle.y ADD2 =Screen.x ~circle.yc ~circle.x ADD2 =Screen.y ~color =Screen.color + ~circle.xc ~circle.y SUB2 =Screen.x ~circle.yc ~circle.x ADD2 =Screen.y ~color =Screen.color + ~circle.xc ~circle.y ADD2 =Screen.x ~circle.yc ~circle.x SUB2 =Screen.y ~color =Screen.color + ~circle.xc ~circle.y SUB2 =Screen.x ~circle.yc ~circle.x SUB2 =Screen.y ~color =Screen.color + +RTN + @pict_small [ ff80 8080 8080 8088 ffff fffc f8f9 f1f4