only allow drawing on canvas
This commit is contained in:
parent
ddf4abf52e
commit
47e07b4e28
1 changed files with 37 additions and 10 deletions
|
@ -8,39 +8,66 @@
|
||||||
|58 @canvas-width
|
|58 @canvas-width
|
||||||
|1f @canvas-height
|
|1f @canvas-height
|
||||||
|
|
||||||
|
( zero page vars )
|
||||||
|
|00
|
||||||
|
@x $2
|
||||||
|
@y $2
|
||||||
|
|
||||||
(to run gui: `./run_ui.sh one_line_canvas.tal`)
|
(to run gui: `./run_ui.sh one_line_canvas.tal`)
|
||||||
(to run debugger: `../uxn/bin/uxnasm one_line_canvas.tal one_line_canvas.rom && ../uxn/bin/uxnemu ../beetbug.rom ./one_line_canvas.rom`)
|
(to run debugger: `../uxn/bin/uxnasm one_line_canvas.tal one_line_canvas.rom && ../uxn/bin/uxnemu ../beetbug.rom ./one_line_canvas.rom`)
|
||||||
%dbug { #01 .System/debug DEO }
|
%dbug { #01 .System/debug DEO }
|
||||||
%PX { #01 .Screen/pixel DEO }
|
%PX { #01 .Screen/pixel DEO }
|
||||||
%ADD1 { #01 ADD }
|
|
||||||
|
|
||||||
|0100
|
|0100
|
||||||
@on-reset
|
@on-reset
|
||||||
setup-gui
|
setup-gui
|
||||||
( draw canvas bounds )
|
( draw canvas bounds )
|
||||||
.canvas-width ADD1 .canvas-width ADD1 .canvas-height ADD1 draw-h-line
|
( top line )
|
||||||
.canvas-width ADD1 .canvas-width ADD1 .canvas-height ADD1 #02 MUL draw-h-line
|
.canvas-width #01 ADD .canvas-width .canvas-height #01 SUB draw-h-line
|
||||||
.canvas-height ADD1 .canvas-width ADD1 .canvas-height ADD1 draw-v-line
|
( bot line )
|
||||||
.canvas-height ADD1 .canvas-width ADD1 #02 MUL .canvas-height ADD1 draw-v-line
|
.canvas-width #01 ADD .canvas-width .canvas-height #02 MUL #01 ADD draw-h-line
|
||||||
|
( left line )
|
||||||
|
.canvas-height #01 ADD .canvas-width #01 SUB .canvas-height draw-v-line
|
||||||
|
( right line )
|
||||||
|
.canvas-height #01 ADD .canvas-width #02 MUL #01 ADD .canvas-height draw-v-line
|
||||||
;on-mouse .Mouse/vector DEO2
|
;on-mouse .Mouse/vector DEO2
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
|
@add-px-to-drawing
|
||||||
|
( figure out if px on on canvas )
|
||||||
|
( x too small )
|
||||||
|
LIT2 =canvas-width .x LDZ2 GTH2 ?/end
|
||||||
|
( x too big )
|
||||||
|
LIT2 =canvas-width #0002 MUL2 .x LDZ2 LTH2 ?/end
|
||||||
|
( y too small )
|
||||||
|
LIT2 =canvas-height .y LDZ2 GTH2 ?/end
|
||||||
|
( y too big )
|
||||||
|
LIT2 =canvas-height #0002 MUL2 .y LDZ2 LTH2 ?/end
|
||||||
|
( draw px to screen )
|
||||||
|
.x LDZ2 .Screen/x DEO2
|
||||||
|
.y LDZ2 .Screen/y DEO2
|
||||||
|
#01 .Screen/pixel DEO
|
||||||
|
&end
|
||||||
|
JMP2r
|
||||||
|
|
||||||
@on-mouse ( -> )
|
@on-mouse ( -> )
|
||||||
.Mouse/x DEI2
|
.Mouse/x DEI2 .x STZ2
|
||||||
.Mouse/y DEI2
|
.Mouse/y DEI2 .y STZ2
|
||||||
draw-cursor
|
draw-cursor
|
||||||
|
add-px-to-drawing
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
@draw-cursor ( x* y* )
|
@draw-cursor
|
||||||
( clear fg )
|
( clear fg )
|
||||||
LIT2 0000 .Screen/x DEO2
|
LIT2 0000 .Screen/x DEO2
|
||||||
LIT2 0000 .Screen/y DEO2
|
LIT2 0000 .Screen/y DEO2
|
||||||
#c0 .Screen/pixel DEO
|
#c0 .Screen/pixel DEO
|
||||||
( draw cursor sprite to fg )
|
( draw cursor sprite to fg )
|
||||||
.Screen/y DEO2 ( x* )
|
.x LDZ2 .Screen/x DEO2
|
||||||
.Screen/x DEO2 ( )
|
.y LDZ2 .Screen/y DEO2
|
||||||
;cursor-sprite .Screen/addr DEO2
|
;cursor-sprite .Screen/addr DEO2
|
||||||
#41 .Screen/sprite DEO
|
#41 .Screen/sprite DEO
|
||||||
|
JMP2r
|
||||||
|
|
||||||
@draw-v-line ( l x y )
|
@draw-v-line ( l x y )
|
||||||
SWP ( l y x )
|
SWP ( l y x )
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue