uxn/projects/software/noodle.usm

629 lines
15 KiB
Plaintext
Raw Normal View History

2021-03-17 13:18:43 -04:00
(
app/noodle : illustration program
2021-03-18 19:05:10 -04:00
2021-03-19 16:41:59 -04:00
right-click - erase
2021-03-18 19:05:10 -04:00
alt-click - drag canvas
2021-03-19 16:41:59 -04:00
arrows - move zoom
space - toogle zoom
backspace - blank canvas
2021-03-18 13:13:55 -04:00
TODO
2021-03-18 13:54:54 -04:00
- Only draw-canvas when mouse has changed
- Only draw-canvas target tile
2021-03-18 22:01:33 -04:00
- Resize buttons
2021-03-19 14:29:46 -04:00
- Clear all button
2021-03-19 12:41:23 -04:00
- Limit size
- Draw point inbetween
2021-03-19 14:29:46 -04:00
- Pixel cleanup brush
2021-03-19 16:41:59 -04:00
BUGS
- If canvas is higher than 0, mouse picking fails
2021-03-17 13:18:43 -04:00
)
%RTN { JMP2r }
%RTN? { JMP2r? }
2021-03-18 13:13:55 -04:00
%++ { #0001 ADD2 } %-- { #0001 SUB2 }
2021-03-19 14:49:57 -04:00
%2/ { #0001 SHR2 }
2021-03-18 13:13:55 -04:00
%8/ { #0003 SHR2 } %8* { #0003 SHL2 }
2021-03-19 14:49:57 -04:00
%8+ { #0008 ADD2 }
2021-03-18 13:13:55 -04:00
%MOD8 { #0007 AND2 }
2021-03-17 13:18:43 -04:00
2021-03-18 19:05:10 -04:00
;center { x 2 y 2 }
;toolbar { x1 2 y1 2 x2 2 y2 2 }
2021-03-19 16:41:59 -04:00
;cursor { x 2 y 2 x0 2 y0 2 size 1 patt 1 drag 1 }
;zoom { active 1 x 2 y 2 }
2021-03-18 13:13:55 -04:00
;rect { x1 2 y1 2 x2 2 y2 2 }
2021-03-19 15:09:55 -04:00
;origin { x1 2 y1 2 x2 2 y2 2 }
2021-03-18 13:13:55 -04:00
;color { byte 1 }
2021-03-19 16:41:59 -04:00
;pt0 { x 2 y 2 }
;pt1 { x 2 y 2 }
2021-03-18 13:54:54 -04:00
;px { x 1 y 1 }
2021-03-17 13:18:43 -04:00
|0100 @RESET
2021-03-18 13:13:55 -04:00
2021-03-19 14:49:57 -04:00
( default canvas )
2021-03-19 17:07:17 -04:00
#002a =canvas.w #001a =canvas.h
2021-03-19 14:49:57 -04:00
( default brush )
#04 =cursor.size
2021-03-18 19:05:10 -04:00
( load file )
2021-03-19 14:29:46 -04:00
,filepath ,load-file JSR2
2021-03-18 19:05:10 -04:00
( find screen center )
~Screen.width #0002 DIV2 =center.x
~Screen.height #0002 DIV2 =center.y
2021-03-18 23:53:47 -04:00
#0010 =toolbar.x1 #0010 =toolbar.y1
2021-03-18 19:05:10 -04:00
2021-03-18 23:53:47 -04:00
( center canvas )
~center.x ~canvas.w 8* 2/ SUB2 =canvas.x1
~center.y ~canvas.h 8* 2/ SUB2 =canvas.y1
2021-03-18 19:05:10 -04:00
2021-03-18 23:53:47 -04:00
,draw-background JSR2
2021-03-18 19:05:10 -04:00
,fit-canvas JSR2
2021-03-19 14:29:46 -04:00
2021-03-19 12:41:23 -04:00
( fit toolbar )
~toolbar.x1 #0010 ADD2 =toolbar.x2
~toolbar.y1 #0040 ADD2 =toolbar.y2
,draw-toolbar JSR2
2021-03-17 13:18:43 -04:00
BRK
@FRAME
,draw-cursor JSR2
2021-03-18 19:05:10 -04:00
( release drag )
,$no-release ~Mouse.state #00 EQU ~cursor.drag #01 EQU #0101 NEQ2 JMP2?
2021-03-19 15:09:55 -04:00
~origin.x1 #0002 SUB2 ~origin.y1 #0002 SUB2 ~origin.x2 #0002 ADD2 ~origin.y2 #0002 ADD2 #00 ,fill-rect JSR2
2021-03-18 19:05:10 -04:00
~canvas.x1 -- ~canvas.y1 -- ~canvas.x2 ~canvas.y2 #10 ,line-rect JSR2
,draw-background JSR2
,fit-canvas JSR2
2021-03-19 12:41:23 -04:00
,draw-toolbar JSR2
2021-03-18 19:05:10 -04:00
#00 =cursor.drag
$no-release
,$no-touch ~Mouse.state #00 EQU JMP2?
( drag )
,$no-drag ~Controller #02 NEQ JMP2?
2021-03-19 15:09:55 -04:00
,$no-drag-start ~cursor.drag #00 NEQ JMP2?
~canvas.x1 =origin.x1
~canvas.y1 =origin.y1
~canvas.x2 =origin.x2
~canvas.y2 =origin.y2
$no-drag-start
2021-03-18 19:05:10 -04:00
~canvas.x1 -- ~canvas.y1 -- ~canvas.x2 ~canvas.y2 #10 ,line-rect JSR2
~canvas.x1 ~Mouse.x ~cursor.x0 SUB2 ADD2 =canvas.x1
~canvas.y1 ~Mouse.y ~cursor.y0 SUB2 ADD2 =canvas.y1
~canvas.w 8* ~canvas.x1 ADD2 =canvas.x2
~canvas.h 8* ~canvas.y1 ADD2 =canvas.y2
~canvas.x1 -- ~canvas.y1 -- ~canvas.x2 ~canvas.y2 #13 ,line-rect JSR2
#01 =cursor.drag
,$touch-end JMP2
$no-drag
( in toolbar )
,$no-touch-toolbar ~Mouse.x CLN2r ~toolbar.x1 GTH2 STH2r ~toolbar.x2 LTH2 #0101 NEQ2 JMP2?
,$no-touch-toolbar ~Mouse.y CLN2r ~toolbar.y1 GTH2 STH2r ~toolbar.y2 LTH2 #0101 NEQ2 JMP2?
2021-03-18 22:01:33 -04:00
( release ) #00 =Mouse.state
2021-03-18 19:05:10 -04:00
,$no-touch-size ~Mouse.x ~toolbar.x1 SUB2 8/ #0000 NEQ2 JMP2?
~Mouse.y ~toolbar.y1 SUB2 8/ SWP POP =cursor.size
2021-03-18 22:01:33 -04:00
( draw ) ,draw-toolbar JSR2
2021-03-18 19:05:10 -04:00
,$touch-end JMP2
$no-touch-size
2021-03-18 22:01:33 -04:00
,$no-touch-brush ~Mouse.x ~toolbar.x1 SUB2 8/ #0001 NEQ2 JMP2?
~Mouse.y ~toolbar.y1 SUB2 8/ SWP POP =cursor.patt
( draw ) ,draw-toolbar JSR2
,$touch-end JMP2
$no-touch-brush
2021-03-18 19:05:10 -04:00
$no-touch-toolbar
( in canvas )
,$no-touch-canvas ~Mouse.x CLN2r ~canvas.x1 GTH2 STH2r ~canvas.x2 LTH2 #0101 NEQ2 JMP2?
,$no-touch-canvas ~Mouse.y CLN2r ~canvas.y1 GTH2 STH2r ~canvas.y2 LTH2 #0101 NEQ2 JMP2?
~Mouse.x ~canvas.x1 SUB2 ~Mouse.y ~canvas.y1 SUB2 ,paint JSR2
$no-touch-canvas
2021-03-18 23:53:47 -04:00
( background interface )
~Mouse.x ~Screen.width #0020 SUB2 SUB2 8/
DUP2
2021-03-19 12:41:23 -04:00
#0000 NEQ2 ,$no-toggle-zoom ROT JMP2?
2021-03-19 16:41:59 -04:00
~zoom.active #00 EQU =zoom.active
2021-03-18 23:53:47 -04:00
( release ) #00 =Mouse.state
2021-03-19 12:41:23 -04:00
,redraw JSR2
$no-toggle-zoom
2021-03-18 23:53:47 -04:00
DUP2
#0001 NEQ2 ,$no-load-button ROT JMP2?
2021-03-19 14:49:57 -04:00
,filepath ,load-file JSR2
2021-03-19 15:09:55 -04:00
,draw-canvas JSR2
2021-03-18 23:53:47 -04:00
( release ) #00 =Mouse.state
$no-load-button
DUP2
#0002 NEQ2 ,$no-save-button ROT JMP2?
2021-03-19 14:49:57 -04:00
,filepath ,save-file JSR2
2021-03-18 23:53:47 -04:00
( release ) #00 =Mouse.state
$no-save-button
POP2
2021-03-18 19:05:10 -04:00
$touch-end
2021-03-18 13:13:55 -04:00
2021-03-18 19:05:10 -04:00
$no-touch
2021-03-18 13:13:55 -04:00
2021-03-19 16:41:59 -04:00
~Controller.buttons #f0 AND
DUP #04 SHR #01 AND #01 NEQ ,$no-up ROT JMP2?
( move ) ~zoom.y -- =zoom.y $no-up
DUP #05 SHR #01 AND #01 NEQ ,$no-down ROT JMP2?
( move ) ~zoom.y ++ =zoom.y $no-down
DUP #06 SHR #01 AND #01 NEQ ,$no-left ROT JMP2?
( move ) ~zoom.x -- =zoom.x $no-left
DUP #07 SHR #01 AND #01 NEQ ,$no-right ROT JMP2?
( move ) ~zoom.x ++ =zoom.x $no-right
#00 NEQ ,draw-canvas ROT JSR2?
2021-03-19 15:43:29 -04:00
,$no-keys ~Keys #00 EQU JMP2?
,$no-keys-toogle-zoom ~Keys #20 NEQ JMP2?
2021-03-19 16:41:59 -04:00
~zoom.active #00 EQU =zoom.active
2021-03-19 15:43:29 -04:00
,redraw JSR2
$no-keys-toogle-zoom
( release ) #00 =Keys
$no-keys
2021-03-18 19:05:10 -04:00
~Mouse.x =cursor.x0
~Mouse.y =cursor.y0
2021-03-18 13:13:55 -04:00
2021-03-18 19:05:10 -04:00
BRK
2021-03-18 13:54:54 -04:00
2021-03-18 19:05:10 -04:00
@load-file ( path )
2021-03-18 13:13:55 -04:00
2021-03-19 14:49:57 -04:00
=File.name ~canvas.w ~canvas.h MUL2 #0008 MUL2 =File.length ,data =File.load
RTN
@save-file
=File.name ~canvas.w ~canvas.h MUL2 #0008 MUL2 =File.length ,data =File.save
2021-03-18 13:13:55 -04:00
2021-03-18 19:05:10 -04:00
RTN
2021-03-17 13:18:43 -04:00
2021-03-19 14:29:46 -04:00
@fit-canvas
~canvas.w 8* ~canvas.x1 ADD2 =canvas.x2
~canvas.h 8* ~canvas.y1 ADD2 =canvas.y2
~canvas.x1 -- ~canvas.y1 -- ~canvas.x2 ~canvas.y2 #01 ,line-rect JSR2
,draw-canvas JSR2
RTN
2021-03-18 13:13:55 -04:00
@paint ( x y )
2021-03-18 23:53:47 -04:00
,erase ~Mouse.state #10 EQU JMP2?
2021-03-17 13:18:43 -04:00
2021-03-19 16:41:59 -04:00
#0003 SUB2 =pt0.y #0003 SUB2 =pt0.x ( cursor offset )
2021-03-18 13:54:54 -04:00
2021-03-19 14:29:46 -04:00
( trim if zoomed )
2021-03-19 16:41:59 -04:00
,$no-zoom ~zoom.active #01 NEQ JMP2?
~pt0.x 8/ ~zoom.x ADD2 #0003 SUB2 =pt0.x
~pt0.y 8/ ~zoom.y ADD2 #0003 SUB2 =pt0.y
2021-03-19 14:29:46 -04:00
$no-zoom
( center zoom on paint )
2021-03-19 16:41:59 -04:00
,$no-follow ~zoom.active JMP2?
~pt0.x ~canvas.w 2/ SUB2 #0003 ADD2 =zoom.x
~pt0.y ~canvas.h 2/ SUB2 #0003 ADD2 =zoom.y
2021-03-19 14:29:46 -04:00
$no-follow
2021-03-18 13:54:54 -04:00
#00 =px.x #00 =px.y
$ver
#00 =px.x
$hor
2021-03-18 22:01:33 -04:00
( addr ) ,size_icn #00 ~cursor.size 8* ADD2
2021-03-18 19:05:10 -04:00
( byte ) #00 ~px.y ADD2 LDR #07 ~px.x SUB SHR #01 AND
2021-03-18 13:54:54 -04:00
#00 EQU ,$no-pixel ROT JMP2?
2021-03-18 22:01:33 -04:00
,$no-pixel ,patternize JSR2 #00 EQU JMP2?
2021-03-19 16:41:59 -04:00
~pt0.x #00 ~px.x ADD2 ~pt0.y #00 ~px.y ADD2 ,add-pixel JSR2
2021-03-18 13:54:54 -04:00
$no-pixel
( incr ) ~px.x #01 ADD =px.x
,$hor ~px.x #08 LTH JMP2?
( incr ) ~px.y #01 ADD =px.y
,$ver ~px.y #08 LTH JMP2?
2021-03-18 19:05:10 -04:00
,draw-canvas JSR2
,draw-toolbar JSR2
2021-03-18 13:54:54 -04:00
2021-03-18 19:05:10 -04:00
RTN
2021-03-18 13:54:54 -04:00
2021-03-18 23:53:47 -04:00
@erase ( x y )
2021-03-19 16:41:59 -04:00
#0003 SUB2 =pt0.y #0003 SUB2 =pt0.x ( cursor offset )
2021-03-18 23:53:47 -04:00
2021-03-19 14:29:46 -04:00
( trim if zoomed )
2021-03-19 16:41:59 -04:00
,$no-zoom ~zoom.active #01 NEQ JMP2?
~pt0.x 8/ ~zoom.x ADD2 #0003 SUB2 =pt0.x
~pt0.y 8/ ~zoom.y ADD2 #0003 SUB2 =pt0.y
2021-03-19 14:29:46 -04:00
$no-zoom
( center zoom on paint )
2021-03-19 16:41:59 -04:00
,$no-follow ~zoom.active JMP2?
~pt0.x ~canvas.w 2/ SUB2 #0003 ADD2 =zoom.x
~pt0.y ~canvas.h 2/ SUB2 #0003 ADD2 =zoom.y
2021-03-19 14:29:46 -04:00
$no-follow
2021-03-19 14:49:57 -04:00
2021-03-18 23:53:47 -04:00
#00 =px.x #00 =px.y
$ver
#00 =px.x
$hor
( addr ) ,size_icn #00 ~cursor.size 8* ADD2
( byte ) #00 ~px.y ADD2 LDR #07 ~px.x SUB SHR #01 AND
#00 EQU ,$no-pixel ROT JMP2?
,$no-pixel ,patternize JSR2 #00 EQU JMP2?
2021-03-19 16:41:59 -04:00
~pt0.x #00 ~px.x ADD2 ~pt0.y #00 ~px.y ADD2 ,remove-pixel JSR2
2021-03-18 23:53:47 -04:00
$no-pixel
( incr ) ~px.x #01 ADD =px.x
,$hor ~px.x #08 LTH JMP2?
( incr ) ~px.y #01 ADD =px.y
,$ver ~px.y #08 LTH JMP2?
,draw-canvas JSR2
,draw-toolbar JSR2
RTN
2021-03-18 22:01:33 -04:00
@patternize
,$noplain ~cursor.patt #00 NEQ JMP2?
#01 RTN
$noplain
,$notone1 ~cursor.patt #01 NEQ JMP2?
2021-03-19 16:41:59 -04:00
~pt0.x #00 ~px.x ADD2 ~pt0.y #00 ~px.y ADD2 ADD2 #0001 AND2 #0000 EQU2
~pt0.x #00 ~px.x ADD2 ~pt0.y #00 ~px.y ADD2 SUB2 #0001 AND2 #0000 EQU2
2021-03-18 22:01:33 -04:00
#0101 EQU2
RTN
$notone1
,$notone2 ~cursor.patt #02 NEQ JMP2?
2021-03-19 16:41:59 -04:00
~pt0.x #00 ~px.x ADD2 ~pt0.y #00 ~px.y ADD2 ADD2 #0003 AND2 #0000 EQU2
~pt0.x #00 ~px.x ADD2 ~pt0.y #00 ~px.y ADD2 SUB2 #0003 AND2 #0000 EQU2
2021-03-18 22:01:33 -04:00
#0101 EQU2
RTN
$notone2
,$notone3 ~cursor.patt #03 NEQ JMP2?
2021-03-19 16:41:59 -04:00
~pt0.x #00 ~px.x ADD2 ~pt0.y #00 ~px.y ADD2 ADD2 #0005 AND2 #0000 EQU2
~pt0.x #00 ~px.x ADD2 ~pt0.y #00 ~px.y ADD2 SUB2 #0005 AND2 #0000 EQU2
2021-03-18 22:01:33 -04:00
#0101 EQU2
RTN
$notone3
,$notone4 ~cursor.patt #04 NEQ JMP2?
2021-03-19 16:41:59 -04:00
~pt0.x #00 ~px.x ADD2 ~pt0.y #00 ~px.y ADD2 ADD2 #0003 AND2 #0000 EQU2
2021-03-18 22:01:33 -04:00
RTN
$notone4
,$notone5 ~cursor.patt #05 NEQ JMP2?
2021-03-19 16:41:59 -04:00
~pt0.x #00 ~px.x ADD2 ~pt0.y #00 ~px.y ADD2 SUB2 #0003 AND2 #0000 EQU2
2021-03-18 22:01:33 -04:00
RTN
$notone5
,$notone6 ~cursor.patt #06 NEQ JMP2?
2021-03-19 16:41:59 -04:00
~pt0.x #00 ~px.x ADD2 #0001 AND2 SWP POP RTN
2021-03-18 22:01:33 -04:00
$notone6
,$notone7 ~cursor.patt #07 NEQ JMP2?
2021-03-19 16:41:59 -04:00
~pt0.y #00 ~px.y ADD2 #0001 AND2 SWP POP RTN
2021-03-18 22:01:33 -04:00
$notone7
#00
RTN
2021-03-19 14:29:46 -04:00
@get-pixel ( x y )
SWP POP #07 AND =px.y
SWP POP #07 AND =px.x
2021-03-19 16:41:59 -04:00
( get tile ) ~pt1.x 8/ ~pt1.y 8/ ~canvas.w MUL2 ADD2 8*
2021-03-19 14:29:46 -04:00
( add addr ) ,data ADD2
#00 ~px.y ADD2 LDR #07 ~px.x SUB SHR #01 AND
RTN
2021-03-18 13:54:54 -04:00
@add-pixel ( x y )
2021-03-17 13:18:43 -04:00
2021-03-19 16:41:59 -04:00
=pt1.y =pt1.x
( get tile addr ) ,data ~pt1.x 8/ ~pt1.y 8/ ~canvas.w MUL2 ADD2 8* ~pt1.y MOD8 ADD2 ADD2
2021-03-18 23:53:47 -04:00
( load ) DUP2 LDR
2021-03-19 16:41:59 -04:00
( mask ) #01 #07 ~pt1.x MOD8 SWP POP SUB SHL ORA
2021-03-18 23:53:47 -04:00
( save ) ROT ROT STR
RTN
2021-03-17 13:18:43 -04:00
2021-03-18 23:53:47 -04:00
@remove-pixel ( x y )
2021-03-19 16:41:59 -04:00
=pt1.y =pt1.x
( get tile addr ) ,data ~pt1.x 8/ ~pt1.y 8/ ~canvas.w MUL2 ADD2 8* ~pt1.y MOD8 ADD2 ADD2
2021-03-18 13:13:55 -04:00
( load ) DUP2 LDR
2021-03-19 16:41:59 -04:00
( mask ) #01 #07 ~pt1.x MOD8 SWP POP SUB SHL #ff XOR AND
2021-03-18 13:13:55 -04:00
( save ) ROT ROT STR
2021-03-17 13:18:43 -04:00
2021-03-18 13:13:55 -04:00
RTN
2021-03-19 12:41:23 -04:00
( Drawing )
@redraw
,draw-background JSR2
,draw-canvas JSR2
,draw-toolbar JSR2
RTN
2021-03-18 13:54:54 -04:00
@draw-canvas
2021-03-17 13:18:43 -04:00
2021-03-19 16:41:59 -04:00
,draw-canvas-zoom ~zoom.active #01 EQU JMP2?
2021-03-19 14:29:46 -04:00
2021-03-18 13:13:55 -04:00
~canvas.y1 =Sprite.y
,data =Sprite.addr
$ver
~canvas.x1 =Sprite.x
$hor
( draw ) #09 =Sprite.color
( incr ) ~Sprite.x 8+ =Sprite.x
( incr ) ~Sprite.addr 8+ =Sprite.addr
2021-03-18 23:53:47 -04:00
,$hor ~Sprite.x ~canvas.x2 NEQ2 JMP2?
2021-03-18 13:13:55 -04:00
( incr ) ~Sprite.y 8+ =Sprite.y
2021-03-18 23:53:47 -04:00
,$ver ~Sprite.y ~canvas.y2 NEQ2 JMP2?
2021-03-18 13:13:55 -04:00
RTN
2021-03-17 13:18:43 -04:00
2021-03-19 14:29:46 -04:00
@draw-canvas-zoom
2021-03-19 16:41:59 -04:00
~zoom.y =pt1.y
2021-03-19 14:29:46 -04:00
~canvas.y1 =Sprite.y
,data =Sprite.addr
$ver
~canvas.x1 =Sprite.x
2021-03-19 16:41:59 -04:00
~zoom.x =pt1.x
2021-03-19 14:29:46 -04:00
$hor
2021-03-19 16:41:59 -04:00
( incr ) ,bigpixel_icn #0008 #00 ~pt1.x ~pt1.y ,get-pixel JSR2 MUL2 ADD2 =Sprite.addr
2021-03-19 14:29:46 -04:00
( draw ) #09 =Sprite.color
( incr ) ~Sprite.x 8+ =Sprite.x
2021-03-19 16:41:59 -04:00
( incr ) ~pt1.x ++ =pt1.x
2021-03-19 14:29:46 -04:00
,$hor ~Sprite.x ~canvas.x2 NEQ2 JMP2?
( incr ) ~Sprite.y 8+ =Sprite.y
2021-03-19 16:41:59 -04:00
( incr ) ~pt1.y ++ =pt1.y
2021-03-19 14:29:46 -04:00
,$ver ~Sprite.y ~canvas.y2 NEQ2 JMP2?
RTN
2021-03-17 13:18:43 -04:00
@draw-cursor
~cursor.x ~Mouse.x NEQU2
~cursor.y ~Mouse.y NEQU2
2021-03-19 12:41:23 -04:00
#0000 EQU2
~Mouse.state
#00 NEQ
#0101 EQU2 RTN? ( Return if unchanged )
2021-03-17 13:18:43 -04:00
2021-03-19 12:41:23 -04:00
,blank_icn =Sprite.addr
2021-03-17 13:18:43 -04:00
2021-03-19 12:41:23 -04:00
( clear brush size )
2021-03-18 23:53:47 -04:00
~cursor.x #0003 SUB2 =Sprite.x
~cursor.y #0003 SUB2 =Sprite.y
#10 =Sprite.color
2021-03-17 13:18:43 -04:00
( clear last cursor )
~cursor.x =Sprite.x
~cursor.y =Sprite.y
#10 =Sprite.color
( record cursor positions )
~Mouse.x =cursor.x
~Mouse.y =cursor.y
( draw new cursor )
2021-03-18 23:53:47 -04:00
,$outside-canvas ~Mouse.x CLN2r ~canvas.x1 GTH2 STH2r ~canvas.x2 LTH2 #0101 NEQ2 JMP2?
2021-03-19 15:09:55 -04:00
,$outside-canvas ~Mouse.y CLN2r ~canvas.y1 GTH2 STH2r ~canvas.y2 LTH2 #0101 NEQ2 JMP2?
,$outside-canvas ~Controller #02 EQU JMP2?
2021-03-18 23:53:47 -04:00
~cursor.x #0003 SUB2 =Sprite.x
~cursor.y #0003 SUB2 =Sprite.y
2021-03-19 12:41:23 -04:00
,brush_view #00 ~cursor.size 8* ADD2 =Sprite.addr
#11 ~Mouse.state #02 MUL ADD =Sprite.color
,$outside-canvas ~Mouse.state #00 EQU JMP2?
RTN
2021-03-18 23:53:47 -04:00
$outside-canvas
2021-03-17 13:18:43 -04:00
~cursor.x =Sprite.x
~cursor.y =Sprite.y
2021-03-19 14:49:57 -04:00
,pointers_icn #00 ~Controller #02 EQU 8* ADD2 =Sprite.addr
2021-03-18 23:53:47 -04:00
#1f =Sprite.color
2021-03-18 13:13:55 -04:00
RTN
@draw-toolbar
2021-03-19 17:07:17 -04:00
~toolbar.x1 -- ~toolbar.y1 -- ~toolbar.x2 ~toolbar.y2 #00 ,line-rect JSR2
2021-03-18 23:53:47 -04:00
~toolbar.x1 #0002 SUB2 ~toolbar.y1 #0002 SUB2 ~toolbar.x2 ~toolbar.y2 #01 ,line-rect JSR2
2021-03-18 13:13:55 -04:00
2021-03-18 19:05:10 -04:00
~toolbar.x1 =Sprite.x
~toolbar.y1 =Sprite.y
2021-03-18 22:01:33 -04:00
,size_icn =Sprite.addr
2021-03-18 13:13:55 -04:00
( draw brush sizes )
$sizes
2021-03-19 17:07:17 -04:00
( draw ) #01 ~Sprite.y ~toolbar.y1 SUB2 8/ SWP POP ~cursor.size EQU #02 MUL ADD =Sprite.color
2021-03-18 13:13:55 -04:00
( incr ) ~Sprite.y 8+ =Sprite.y
( incr ) ~Sprite.addr 8+ =Sprite.addr
2021-03-18 19:05:10 -04:00
,$sizes ~Sprite.y ~toolbar.y1 #0040 ADD2 LTH2 JMP2?
2021-03-18 13:13:55 -04:00
2021-03-18 22:01:33 -04:00
( draw brush patterns )
2021-03-18 13:13:55 -04:00
2021-03-18 19:05:10 -04:00
~toolbar.x1 8+ =Sprite.x
~toolbar.y1 =Sprite.y
2021-03-18 22:01:33 -04:00
,pattern_icn =Sprite.addr
$patterns
2021-03-19 17:07:17 -04:00
( draw ) #01 ~Sprite.y ~toolbar.y1 SUB2 8/ SWP POP ~cursor.patt EQU #02 MUL ADD =Sprite.color
2021-03-18 22:01:33 -04:00
( incr ) ~Sprite.y 8+ =Sprite.y
( incr ) ~Sprite.addr 8+ =Sprite.addr
,$patterns ~Sprite.y ~toolbar.y1 #0040 ADD2 LTH2 JMP2?
2021-03-18 19:05:10 -04:00
RTN
@draw-background
( draw hor line )
#0000 =Screen.x ~center.y =Screen.y
#0000 ~Screen.width ( from/to )
$draw-hor NOP
( draw ) #01 =Screen.color
( incr ) SWP2 #0002 ADD2 DUP2 =Screen.x SWP2
OVR2 OVR2 LTH2 ^$draw-hor SWP JMP?
POP2 POP2
( draw ver line )
~center.x =Screen.x #0000 =Screen.y
#0000 ~Screen.height ( from/to )
$draw-ver NOP
( draw ) #01 =Screen.color
( incr ) SWP2 #0002 ADD2 DUP2 =Screen.y SWP2
OVR2 OVR2 LTH2 ^$draw-ver SWP JMP?
POP2 POP2
2021-03-18 23:53:47 -04:00
( draw save/load/guides icons )
2021-03-18 19:05:10 -04:00
~Screen.width #0018 SUB2 =Sprite.x
~Screen.height #0010 SUB2 =Sprite.y
,load_icn =Sprite.addr
#01 =Sprite.color
~Screen.width #0010 SUB2 =Sprite.x
,save_icn =Sprite.addr
#01 =Sprite.color
2021-03-18 23:53:47 -04:00
~Screen.width #0020 SUB2 =Sprite.x
2021-03-19 16:41:59 -04:00
,zoom_icn #00 ~zoom.active 8* ADD2 =Sprite.addr
2021-03-18 23:53:47 -04:00
#01 =Sprite.color
2021-03-18 19:05:10 -04:00
( draw width )
2021-03-18 23:53:47 -04:00
~Screen.width #0048 SUB2 =Sprite.x
2021-03-18 19:05:10 -04:00
,font_hex ~canvas.w #f0 AND #04 SHR #08 MUL ADD2 =Sprite.addr
( draw ) #02 =Sprite.color
~Sprite.x 8+ =Sprite.x
,font_hex ~canvas.w #0f AND #08 MUL ADD2 =Sprite.addr
( draw ) #02 =Sprite.color
~Sprite.x 8+ =Sprite.x
( draw height )
,font_hex ~canvas.h #f0 AND #04 SHR #08 MUL ADD2 =Sprite.addr
( draw ) #02 =Sprite.color
~Sprite.x 8+ =Sprite.x
,font_hex ~canvas.h #0f AND #08 MUL ADD2 =Sprite.addr
( draw ) #02 =Sprite.color
2021-03-18 13:13:55 -04:00
RTN
2021-03-19 14:29:46 -04:00
( Generics )
2021-03-19 12:41:23 -04:00
@line-rect ( x1 y1 x2 y2 color )
( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1
$hor
( incr ) ~Screen.x ++ =Screen.x
( draw ) ~rect.y1 =Screen.y ~color =Screen.color
( draw ) ~rect.y2 =Screen.y ~color =Screen.color
,$hor ~Screen.x ~rect.x2 NEQ2 JMP2?
~rect.y1 =Screen.y
$ver
( draw ) ~rect.x1 =Screen.x ~color =Screen.color
( draw ) ~rect.x2 =Screen.x ~color =Screen.color
( incr ) ~Screen.y ++ =Screen.y
,$ver ~Screen.y ~rect.y2 ++ NEQ2 JMP2?
RTN
@fill-rect ( x1 y1 x2 y2 color )
( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1
$ver
~rect.x1 =Screen.x
$hor
( draw ) ~color =Screen.color
( incr ) ~Screen.x ++ =Screen.x
,$hor ~Screen.x ~rect.x2 NEQ2 JMP2?
( incr ) ~Screen.y ++ =Screen.y
,$ver ~Screen.y ~rect.y2 NEQ2 JMP2?
RTN
2021-03-18 22:01:33 -04:00
@size_icn
[ 0000 0010 0000 0000 ]
2021-03-19 16:41:59 -04:00
[ 0000 1038 1000 0000 ]
[ 0000 3838 3800 0000 ]
[ 0010 387c 3810 0000 ]
[ 0038 7c7c 7c38 0000 ]
[ 1038 7cfe 7c38 1000 ]
[ 387c fefe fe7c 3800 ]
[ 7cfe fefe fefe 7c00 ]
2021-03-18 22:01:33 -04:00
@pattern_icn
[ fe82 baba ba82 fe00 ]
[ fed6 aad6 aad6 fe00 ]
[ fe92 82d6 8292 fe00 ]
[ fe82 92aa 9282 fe00 ]
[ fea6 ca92 a6ca fe00 ]
[ feca a692 caa6 fe00 ]
[ feaa aaaa aaaa fe00 ]
[ fe82 fe82 fe82 fe00 ]
2021-03-18 13:13:55 -04:00
2021-03-18 23:53:47 -04:00
@brush_view
[ 0000 0010 0000 0000 ]
[ 0000 1028 1000 0000 ]
[ 0000 3828 3800 0000 ]
[ 0010 2844 2810 0000 ]
[ 0038 4444 4438 0000 ]
[ 1028 4482 4428 1000 ]
[ 3844 8282 8244 3800 ]
[ 7c82 8282 8282 7c00 ]
2021-03-19 16:41:59 -04:00
[ 7cfe fefe fefe 7c00 ]
2021-03-18 23:53:47 -04:00
2021-03-19 12:41:23 -04:00
@zoom_icn
[ 3048 8484 4834 0200 ]
[ 3245 8284 4834 0200 ]
2021-03-19 14:29:46 -04:00
@bigpixel_icn
[ 5580 0080 0080 0080 ]
[ 55ff 7fff 7fff 7fff ]
2021-03-19 14:49:57 -04:00
@pointers_icn
[ 80c0 e0f0 f8e0 1000 ]
[ 4040 4070 f8f8 f870 ]
2021-03-18 23:53:47 -04:00
2021-03-18 19:05:10 -04:00
@load_icn [ feaa d6aa d4aa f400 ]
@save_icn [ fe82 8282 848a f400 ]
2021-03-18 13:13:55 -04:00
2021-03-18 19:05:10 -04:00
@blank_icn [ 0000 0000 0000 0000 ]
2021-03-19 17:07:17 -04:00
@filepath [ projects/picture2a1a.bit 00 ]
2021-03-18 19:05:10 -04:00
2021-03-19 12:41:23 -04:00
@font_hex
2021-03-18 19:05:10 -04:00
[
003c 464a 5262 3c00 0018 0808 0808 1c00
003c 4202 3c40 7e00 003c 421c 0242 3c00
000c 1424 447e 0400 007e 407c 0242 3c00
003c 407c 4242 3c00 007e 0204 0810 1000
003c 423c 4242 3c00 003c 4242 3e02 3c00
003c 4242 7e42 4200 007c 427c 4242 7c00
003c 4240 4042 3c00 007c 4242 4242 7c00
007e 4078 4040 7e00 007e 4078 4040 4000
]
2021-03-18 13:13:55 -04:00
2021-03-18 19:05:10 -04:00
|2000 ;canvas { w 2 h 2 x1 2 y1 2 x2 2 y2 2 }
|3000 @data [ ]
2021-03-17 13:18:43 -04:00
|F000 @ERROR BRK
|FF00 ;Console { pad 8 char 1 byte 1 short 2 }
|FF10 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|FF30 ;Controller { buttons 1 }
|FF40 ;Keys { key 1 }
|FF50 ;Mouse { x 2 y 2 state 1 chord 1 }
|FF60 ;File { pad 8 name 2 length 2 load 2 save 2 }
|FFF0 .RESET .FRAME .ERROR ( vectors )
2021-03-19 17:07:17 -04:00
|FFF8 [ d0df d03f d02f ] ( palette )