uxn/projects/software/nasu.usm

756 lines
19 KiB
Plaintext
Raw Normal View History

2021-03-05 14:08:19 -05:00
(
app/nasu : spritesheet editor
2021-03-03 14:49:26 -05:00
2021-03-05 14:08:19 -05:00
arrows - move selection
2021-04-16 14:34:08 -04:00
ctrl+arrows - change page
2021-03-20 15:25:26 -04:00
left-click - add pixel
right-click - remove pixel
1 2 3 - select brush
2021-04-15 13:19:59 -04:00
TODO:
2021-04-17 01:42:00 -04:00
Save/load/rename
Select paint color for 2-bit mode
2021-03-05 13:38:18 -05:00
)
2021-03-16 14:25:26 -04:00
%RTN { JMP2r }
2021-03-20 00:22:51 -04:00
%STEP8 { #0033 SFT2 }
2021-03-16 14:25:26 -04:00
2021-04-15 13:19:59 -04:00
%++ { #0001 ADD2 } %-- { #0001 SUB2 }
2021-03-20 00:13:09 -04:00
%2/ { #0001 SFT2 } %2* { #0010 SFT2 }
%8/ { #0003 SFT2 } %8* { #0030 SFT2 }
2021-03-16 14:25:26 -04:00
%8- { #0008 SUB2 } %8+ { #0008 ADD2 }
2021-03-20 00:00:41 -04:00
%SFL { #40 SFT SFT }
%MOD { DUP2 DIV MUL SUB }
2021-04-15 13:19:59 -04:00
%SIZE-TO-RECT {
STH2 STH2 OVR2 STH2r ADD2 OVR2 STH2r ADD2
} ( x y w h -- x1 y1 x2 y2 )
%SET-RECT {
DUP2 ROT2 SWP2 #0006 ADD2 STR2
DUP2 ROT2 SWP2 #0004 ADD2 STR2
DUP2 ROT2 SWP2 #0002 ADD2 STR2
DUP2 ROT2 SWP2 STR2
POP2
} ( x1 y1 x2 y2 addr -- )
%BANK { #2000 }
2021-03-16 00:29:44 -04:00
2021-03-21 16:58:32 -04:00
( variables )
2021-04-17 16:32:07 -04:00
;settings { blending 1 depth 1 brush 1 page 2 }
2021-04-15 13:19:59 -04:00
2021-04-17 16:32:07 -04:00
;frame { x1 2 y1 2 x2 2 y2 2 width 2 height 2 }
;bankview { x 2 y 2 mode 1 selection 1 }
2021-03-13 20:34:08 -05:00
;tileview { x 2 y 2 addr 2 }
2021-04-17 01:42:00 -04:00
;colorview { x1 2 y1 2 x2 2 y2 2 }
2021-04-15 13:19:59 -04:00
;blendview { x1 2 y1 2 x2 2 y2 2 }
2021-04-17 20:27:24 -04:00
;dataview { x1 2 y1 2 x2 2 y2 2 }
2021-03-13 20:34:08 -05:00
;rect { x1 2 y1 2 x2 2 y2 2 }
;mouse { x 2 y 2 }
;color { byte 1 }
;i { byte 1 }
;pt { x 1 y 1 }
;addr { short 2 }
;pos { x 2 y 2 }
2021-03-03 14:49:26 -05:00
2021-03-21 16:58:32 -04:00
( devices )
2021-04-05 14:39:08 -04:00
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 }
|0110 ;Console { vector 2 pad 6 char 1 byte 1 short 2 string 2 }
2021-04-09 13:01:53 -04:00
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 }
2021-04-10 22:39:32 -04:00
|0140 ;Controller { vector 2 button 1 key 1 }
2021-04-05 16:30:26 -04:00
|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 }
2021-04-17 16:49:33 -04:00
|0170 ;File { vector 2 success 2 offset 2 pad 2 name 2 length 2 load 2 save 2 }
2021-03-28 13:19:06 -04:00
2021-03-21 16:58:32 -04:00
( program )
2021-04-10 22:39:32 -04:00
|0200
( theme ) #0efc =System.r #03cc =System.g #03ac =System.b
2021-04-06 13:51:13 -04:00
( vectors ) ,on-button =Controller.vector
( vectors ) ,on-mouse =Mouse.vector
( vectors ) ,on-transfer =File.vector
2021-04-05 14:39:08 -04:00
2021-04-17 16:32:07 -04:00
( set frame )
2021-04-17 20:27:24 -04:00
#0130 =frame.width
#00a8 =frame.height
2021-04-17 16:32:07 -04:00
#01 =settings.brush
~Screen.width 2/ ~frame.width 2/ SUB2
2021-04-17 20:27:24 -04:00
~Screen.height 2/ ~frame.height 2/ SUB2 #0010 ADD2
2021-04-17 16:32:07 -04:00
~frame.width ~frame.height
SIZE-TO-RECT ,frame SET-RECT
2021-04-17 20:27:24 -04:00
~frame.x1 #0010 ADD2 =bankview.x
~frame.y1 =bankview.y
2021-04-16 14:34:08 -04:00
BANK =settings.page
2021-03-04 12:07:33 -05:00
2021-04-17 20:27:24 -04:00
~frame.x2 #0098 SUB2 =tileview.x
~frame.y1 =tileview.y
BANK #0448 ADD2 =tileview.addr
2021-03-20 15:25:26 -04:00
2021-04-17 20:27:24 -04:00
~frame.x1 #0010 ADD2 ~frame.y2 #0020 SUB2 #0020 #0020 SIZE-TO-RECT ,blendview SET-RECT
~frame.x1 #0038 ADD2 ~frame.y2 #0020 SUB2 #0020 #0020 SIZE-TO-RECT ,colorview SET-RECT
~frame.x2 #0010 SUB2 ~frame.y1 #0010 #0080 SIZE-TO-RECT ,dataview SET-RECT
2021-04-15 13:19:59 -04:00
#01 =settings.blending
,filepath1 =File.name #0800 =File.length BANK =File.load
,filepath2 =File.name #0800 =File.length BANK #0800 ADD2 =File.load
,filepath3 =File.name #1000 =File.length BANK #1000 ADD2 =File.load
2021-04-15 13:19:59 -04:00
,filepath4 =File.name #1000 =File.length BANK #2000 ADD2 =File.load
2021-04-17 01:42:00 -04:00
,filepath5 =File.name #1000 =File.length BANK #2800 ADD2 =File.load
2021-04-17 16:32:07 -04:00
,filepath6 =File.name #1000 =File.length BANK #3800 ADD2 =File.load
2021-03-03 14:49:26 -05:00
2021-04-17 20:27:24 -04:00
#40 DUP =bankview.selection ,select-tile JSR2
2021-03-03 14:49:26 -05:00
2021-04-17 16:32:07 -04:00
( ~frame.x1 ~frame.y1 ~frame.x2 ~frame.y2 #01 ,line-rect JSR2 )
2021-03-03 14:49:26 -05:00
BRK
@on-transfer ( -> )
,redraw JSR2
BRK
@on-button ( -> )
2021-04-06 13:51:13 -04:00
2021-04-16 14:34:08 -04:00
( arrow button )
~Controller.button #00 EQU ,$no-button JNZ2
~Controller.button #11 NEQ ^$no-pageup JNZ ~settings.page
#0800 SUB2 =settings.page ,redraw JSR2 BRK $no-pageup
~Controller.button #21 NEQ ^$no-pagedown JNZ ~settings.page
#0800 ADD2 =settings.page ,redraw JSR2 BRK $no-pagedown
~Controller.button #f0 AND
DUP #04 SFT #01 AND #01 NEQ ^$no-up JNZ
( move ) ~bankview.selection #10 SUB =bankview.selection $no-up
DUP #05 SFT #01 AND #01 NEQ ^$no-down JNZ
( move ) ~bankview.selection #10 ADD =bankview.selection $no-down
DUP #06 SFT #01 AND #01 NEQ ^$no-left JNZ
( move ) ~bankview.selection #01 SUB =bankview.selection $no-left
DUP #07 SFT #01 AND #01 NEQ ^$no-right JNZ
( move ) ~bankview.selection #01 ADD =bankview.selection $no-right
POP
~bankview.selection ,select-tile JSR2
$no-button
~Controller.key #00 EQU ^$no-key JNZ
~Controller.key #31 LTH ^$no-number JNZ
~Controller.key #33 GTH ^$no-number JNZ
( select ) ~Controller.key #31 SUB =bankview.mode
,redraw JSR2
$no-number
~Controller.key #20 NEQ ^$no-space JNZ
2021-04-17 01:42:00 -04:00
,toggle-depth JSR2
2021-04-16 14:34:08 -04:00
,redraw JSR2
$no-space
$no-key
2021-03-03 16:49:25 -05:00
2021-04-06 13:51:13 -04:00
BRK
2021-03-04 12:07:33 -05:00
@on-mouse ( -> )
2021-04-06 13:51:13 -04:00
2021-04-16 14:34:08 -04:00
,draw-cursor JSR2
2021-04-17 20:27:24 -04:00
~Mouse.state #00 NEQ ^$no-touch JNZ BRK $no-touch
( toolbar )
~Mouse.y ~bankview.y #0010 SUB2 SUB2 8/ #0000 NEQ2 ,$no-toolbar-click JNZ2
( brush )
~Mouse.x ~bankview.x SUB2 8/ #000d LTH2 ^$no-brush-click JNZ
~Mouse.x ~bankview.x SUB2 8/ #000f GTH2 ^$no-brush-click JNZ
( select ) ~mouse.x ~bankview.x SUB2 8/ #000d SUB2 SWP POP =bankview.mode
$no-brush-click
~Mouse.x ~bankview.x SUB2 8/ #0005 NEQ2 ^$no-toggle-depth JNZ
,toggle-depth JSR2
$no-toggle-depth
( release ) #00 =Mouse.state
,redraw JSR2 BRK
$no-toolbar-click
( bankview )
~Mouse.x ~bankview.x GTH2 ~Mouse.x ~bankview.x #0080 ADD2 LTH2 #0101 EQU2
~Mouse.y ~bankview.y GTH2 ~Mouse.y ~bankview.y #0080 ADD2 LTH2 #0101 EQU2
#0101 EQU2 ,on-touch-bankview JNZ2
( tileview )
~Mouse.x ~tileview.x GTH2 ~Mouse.x ~tileview.x #0080 ADD2 LTH2 #0101 EQU2
~Mouse.y ~tileview.y GTH2 ~Mouse.y ~tileview.y #0080 ADD2 LTH2 #0101 EQU2
#0101 EQU2 ,on-touch-tileview JNZ2
( dataview )
~Mouse.x DUP2 ~dataview.x1 GTH2 ROT ROT ~dataview.x2 LTH2 #0101 EQU2
~Mouse.y DUP2 ~dataview.y1 GTH2 ROT ROT ~dataview.y2 LTH2 #0101 EQU2
#0101 EQU2 ,on-touch-dataview JNZ2
( blendbiew )
~Mouse.x DUP2 ~blendview.x1 GTH2 ROT ROT ~blendview.x2 LTH2 #0101 EQU2
~Mouse.y DUP2 ~blendview.y1 GTH2 ROT ROT ~blendview.y2 LTH2 #0101 EQU2
#0101 EQU2 ,on-touch-blendview JNZ2
( colorview )
~Mouse.x DUP2 ~colorview.x1 GTH2 ROT ROT ~colorview.x2 LTH2 #0101 EQU2
~Mouse.y DUP2 ~colorview.y1 GTH2 ROT ROT ~colorview.y2 LTH2 #0101 EQU2
#0101 EQU2 ,on-touch-colorview JNZ2
2021-03-03 14:49:26 -05:00
2021-04-16 14:34:08 -04:00
BRK
@on-touch-bankview ( -> )
~bankview.mode #01 NEQ ^$not-copy-mode JNZ
#00 =i
$copy-loop
( load ) ~tileview.addr ~i ADD PEK2
( get touch addr )
~Mouse.x ~bankview.x SUB2 STEP8
~Mouse.y ~bankview.y SUB2 STEP8 #0010 MUL2 ADD2
( 2-bit mode ) #00 ~settings.depth #01 ADD MUL2
~settings.page ADD2 #00 ~i ADD2 POK2
( incr ) ~i #01 ADD =i
~i #08 LTH ^$copy-loop JNZ
,redraw JSR2 BRK
$not-copy-mode
~bankview.mode #02 NEQ ^$not-erase-mode JNZ
#00 =i
$erase-loop
#00
( get touch addr )
~Mouse.x ~bankview.x SUB2 STEP8
~Mouse.y ~bankview.y SUB2 STEP8 #0010 MUL2 ADD2
( 2-bit mode ) #00 ~settings.depth #01 ADD MUL2
~settings.page ADD2 #00 ~i ADD2 POK2
( incr ) ~i #01 ADD =i
~i #08 LTH ^$erase-loop JNZ
,redraw JSR2 BRK
$not-erase-mode
( select )
~Mouse.x ~bankview.x SUB2 8/ SWP POP
~Mouse.y ~bankview.y SUB2 8/ SWP POP #40 SFT ADD
DUP =bankview.selection
,select-tile JSR2
2021-03-03 14:49:26 -05:00
2021-03-04 23:15:01 -05:00
BRK
2021-03-03 14:49:26 -05:00
2021-04-17 20:27:24 -04:00
@on-touch-tileview ( -> )
~Mouse.x ~tileview.x SUB2 STEP8 #0040 DIV2
~Mouse.y ~tileview.y SUB2 STEP8 #0040 DIV2 2* ADD2
8*
~tileview.addr ADD2 =addr ( addr offset )
~Mouse.x ~tileview.x SUB2 ~Mouse.x ~tileview.x SUB2 #0040 DIV2 #0040 MUL2 SUB2 =pos.x
~Mouse.y ~tileview.y SUB2 ~Mouse.y ~tileview.y SUB2 #0040 DIV2 #0040 MUL2 SUB2 =pos.y
~Mouse.state #10 NEQ ^$no-erase-mode JNZ
( load ) ~addr ~pos.y 8/ ADD2 PEK2
( mask ) #01 #07 ~pos.x 8/ SWP POP SUB SFL
#ff EOR AND
( save ) ~addr ~pos.y 8/ ADD2 POK2
,redraw JSR2 BRK
$no-erase-mode
( load ) ~addr ~pos.y 8/ ADD2 PEK2
( mask ) #01 #07 ~pos.x 8/ SWP POP SUB SFL
ORA
( save ) ~addr ~pos.y 8/ ADD2 POK2
,redraw JSR2
BRK
@on-touch-dataview ( -> )
~Mouse.y ~dataview.y1 SUB2 STEP8 SWP POP #60 EQU ^$skip JNZ BRK $skip
~Mouse.x ~dataview.x1 SUB2 #0008 DIV2 SWP POP
DUP #00 NEQ ^$no-move-up JNZ
,op_shiftup JSR2
( release ) #00 =Mouse.state
,redraw JSR2 POP BRK $no-move-up
DUP #01 NEQ ^$no-move-down JNZ
,op_shiftdown JSR2
( release ) #00 =Mouse.state
,redraw JSR2 POP BRK $no-move-down
POP
BRK
2021-04-15 13:19:59 -04:00
@on-touch-blendview ( -> )
~Mouse.x ~blendview.x1 SUB2 8/ SWP POP
~Mouse.y ~blendview.y1 SUB2 8/ SWP POP #04 MUL ADD
=settings.blending
( release ) #00 =Mouse.state
,redraw JSR2
BRK
2021-04-17 01:42:00 -04:00
@on-touch-colorview ( -> )
( channel ) ~Mouse.y ~colorview.y1 SUB2 8/ SWP POP STH
( rgb ) ~Mouse.x ~colorview.x1 SUB2 8/ SWP POP
2021-04-17 16:32:07 -04:00
DUP #00 NEQ ^$no-brush JNZ
DUPr STHr =settings.brush $no-brush
2021-04-17 01:42:00 -04:00
DUP #01 NEQ ^$no-red JNZ
DUPr STHr ,System.r ,set-color JSR2 $no-red
DUP #02 NEQ ^$no-green JNZ
DUPr STHr ,System.g ,set-color JSR2 $no-green
DUP #03 NEQ ^$no-blue JNZ
DUPr STHr ,System.b ,set-color JSR2 $no-blue
POP POPr
( release ) #00 =Mouse.state
,redraw JSR2
BRK
@set-color ( color rgb -- )
STH2
DUP #00 NEQ ^$no-red0 JNZ
2021-04-17 16:32:07 -04:00
DUP2r STH2r PEK2 DUP #04 SFT #01 ADD
( add/sub ) ~Mouse.state #10 EQU #fe MUL ADD
( resume ) #40 SFT SWP #0f AND ADD DUP2r STH2r POK2
2021-04-17 01:42:00 -04:00
$no-red0
DUP #01 NEQ ^$no-red1 JNZ
2021-04-17 16:32:07 -04:00
DUP2r STH2r PEK2 DUP #0f AND #01 ADD
( add/sub ) ~Mouse.state #10 EQU #fe MUL ADD
( resume ) #0f AND SWP #f0 AND ADD DUP2r STH2r POK2
2021-04-17 01:42:00 -04:00
$no-red1
DUP #02 NEQ ^$no-red2 JNZ
2021-04-17 16:32:07 -04:00
DUP2r STH2r #0001 ADD2 PEK2 DUP #04 SFT #01 ADD
( add/sub ) ~Mouse.state #10 EQU #fe MUL ADD
( resume ) #40 SFT SWP #0f AND ADD DUP2r STH2r #0001 ADD2 POK2
2021-04-17 01:42:00 -04:00
$no-red2
DUP #03 NEQ ^$no-red3 JNZ
2021-04-17 16:32:07 -04:00
DUP2r STH2r #0001 ADD2 PEK2 DUP #0f AND #01 ADD
( add/sub ) ~Mouse.state #10 EQU #fe MUL ADD
( resume ) #0f AND SWP #f0 AND ADD DUP2r STH2r #0001 ADD2 POK2
2021-04-17 01:42:00 -04:00
$no-red3
POP
POP2r
RTN
2021-04-16 14:34:08 -04:00
@select-tile ( pos -- )
( x y ) DUP #0f AND SWP #04 SFT
( y ) #10 MOD #10 MUL #00 SWP 8*
( x ) ROT #10 MOD #00 SWP 8* ADD2
( 2-bit mode ) #00 ~settings.depth #01 ADD MUL2
( offset ) ~settings.page ADD2 =tileview.addr
,redraw JSR2
RTN
2021-04-17 01:42:00 -04:00
@toggle-depth ( -- )
~bankview.selection
~settings.depth #00 EQU =settings.depth
,select-tile JSR2
RTN
2021-03-06 14:44:18 -05:00
@op_shiftup
2021-03-24 12:39:19 -04:00
~tileview.addr PEK2
~tileview.addr #0001 ADD2 PEK2 ~tileview.addr POK2
~tileview.addr #0002 ADD2 PEK2 ~tileview.addr #0001 ADD2 POK2
~tileview.addr #0003 ADD2 PEK2 ~tileview.addr #0002 ADD2 POK2
~tileview.addr #0004 ADD2 PEK2 ~tileview.addr #0003 ADD2 POK2
~tileview.addr #0005 ADD2 PEK2 ~tileview.addr #0004 ADD2 POK2
~tileview.addr #0006 ADD2 PEK2 ~tileview.addr #0005 ADD2 POK2
~tileview.addr #0007 ADD2 PEK2 ~tileview.addr #0006 ADD2 POK2
~tileview.addr #0007 ADD2 POK2
2021-03-06 14:44:18 -05:00
2021-03-14 17:26:17 -04:00
RTN
2021-03-06 14:44:18 -05:00
@op_shiftdown
2021-03-24 12:39:19 -04:00
~tileview.addr #0007 ADD2 PEK2
~tileview.addr #0006 ADD2 PEK2 ~tileview.addr #0007 ADD2 POK2
~tileview.addr #0005 ADD2 PEK2 ~tileview.addr #0006 ADD2 POK2
~tileview.addr #0004 ADD2 PEK2 ~tileview.addr #0005 ADD2 POK2
~tileview.addr #0003 ADD2 PEK2 ~tileview.addr #0004 ADD2 POK2
~tileview.addr #0002 ADD2 PEK2 ~tileview.addr #0003 ADD2 POK2
~tileview.addr #0001 ADD2 PEK2 ~tileview.addr #0002 ADD2 POK2
~tileview.addr PEK2 ~tileview.addr #0001 ADD2 POK2
~tileview.addr POK2
2021-03-06 14:44:18 -05:00
2021-03-14 17:26:17 -04:00
RTN
2021-03-06 14:44:18 -05:00
2021-03-03 16:49:25 -05:00
@redraw
2021-03-10 22:41:46 -05:00
,draw-bankview JSR2
,draw-tileview JSR2
2021-04-15 13:19:59 -04:00
,draw-blendview JSR2
2021-04-17 01:42:00 -04:00
,draw-colorview JSR2
2021-04-17 20:27:24 -04:00
,draw-dataview JSR2
2021-03-03 16:49:25 -05:00
2021-03-14 17:26:17 -04:00
RTN
2021-03-03 16:49:25 -05:00
2021-03-03 14:49:26 -05:00
@draw-bankview
2021-03-10 22:41:46 -05:00
~bankview.x #0002 SUB2 ~bankview.y #0002 SUB2 ~bankview.x #0081 ADD2 ~bankview.y #0081 ADD2 #03 ,line-rect JSR2
2021-03-03 14:49:26 -05:00
( position )
2021-04-09 13:01:53 -04:00
~bankview.x =Screen.x
~bankview.y #0010 SUB2 =Screen.y
2021-04-16 14:34:08 -04:00
~settings.page ,draw-short JSR2
2021-03-03 14:49:26 -05:00
2021-03-04 12:07:33 -05:00
( toolbar )
2021-04-09 13:01:53 -04:00
~bankview.y #0010 SUB2 =Screen.y
~bankview.x #0028 ADD2 =Screen.x
2021-04-17 01:42:00 -04:00
,depth_icns #00 ~settings.depth 8* ADD2 =Screen.addr
#23 =Screen.color
~bankview.x #0068 ADD2 =Screen.x
2021-04-09 13:01:53 -04:00
,tool_selector =Screen.addr
#21 ~bankview.mode #00 EQU ADD =Screen.color
2021-03-04 12:07:33 -05:00
2021-04-09 13:01:53 -04:00
~Screen.x 8+ =Screen.x
,tool_hand =Screen.addr
#21 ~bankview.mode #01 EQU ADD =Screen.color
2021-03-04 12:07:33 -05:00
2021-04-09 13:01:53 -04:00
~Screen.x 8+ =Screen.x
,tool_eraser =Screen.addr
#21 ~bankview.mode #02 EQU ADD =Screen.color
2021-03-04 12:07:33 -05:00
2021-03-03 14:49:26 -05:00
( guides )
2021-04-17 20:27:24 -04:00
~bankview.x #0010 SUB2 =Screen.x
~bankview.y =Screen.y
,font_hex =Screen.addr
#00 #10
2021-03-11 18:47:28 -05:00
$guides
2021-04-17 20:27:24 -04:00
( draw ) OVR ~bankview.selection #04 SFT EQU #22 ADD =Screen.color
2021-04-09 13:01:53 -04:00
~Screen.addr 8+ =Screen.addr
2021-04-17 20:27:24 -04:00
~Screen.y 8+ =Screen.y
SWP #01 ADD SWP
DUP2 LTH ^$guides JNZ
POP2
2021-03-03 14:49:26 -05:00
2021-04-16 14:34:08 -04:00
( draw page )
( load ) ~settings.page =Screen.addr
~bankview.y DUP2 #0080 ADD2
2021-03-11 18:47:28 -05:00
$ver
( save ) OVR2 =Screen.y
~bankview.x DUP2 #0080 ADD2
$hor
( save ) OVR2 =Screen.x
2021-04-15 13:19:59 -04:00
( get selected ) ~Screen.addr ~tileview.addr EQU2
( get blending ) ~settings.blending
( get depth ) ~settings.depth #20 MUL
( draw ) #20 ADD ADD ADD =Screen.color
( incr ) SWP2 8+ SWP2
2021-04-15 13:19:59 -04:00
( incr ) ~Screen.addr 8+ #00 ~settings.depth #0008 MUL2 ADD2 =Screen.addr
OVR2 OVR2 LTH2 ^$hor JNZ
POP2 POP2
( incr ) SWP2 8+ SWP2
OVR2 OVR2 LTH2 ^$ver JNZ
POP2 POP2
2021-03-03 14:49:26 -05:00
2021-03-14 17:26:17 -04:00
RTN
2021-03-03 14:49:26 -05:00
@draw-tileview
2021-03-10 22:41:46 -05:00
~tileview.x #0002 SUB2 ~tileview.y #0002 SUB2 ~tileview.x #0080 ADD2 ~tileview.y #0081 ADD2 #03 ,line-rect JSR2
2021-03-03 20:43:39 -05:00
2021-04-09 13:01:53 -04:00
~tileview.x #0028 ADD2 =Screen.x
~tileview.y #0010 SUB2 =Screen.y
~tileview.addr =Screen.addr
2021-04-17 16:32:07 -04:00
( get blending ) ~settings.blending
( get depth ) ~settings.depth #20 MUL
( draw ) #20 ADD ADD =Screen.color
2021-03-03 14:49:26 -05:00
( position )
2021-04-09 13:01:53 -04:00
~tileview.x =Screen.x
~tileview.y #0010 SUB2 =Screen.y
2021-03-10 22:41:46 -05:00
~tileview.addr ,draw-short JSR2
2021-03-03 14:49:26 -05:00
( body )
2021-04-09 13:01:53 -04:00
~tileview.x =Screen.x
~tileview.y =Screen.y
2021-03-03 16:49:25 -05:00
~tileview.addr =tileview.addr
2021-03-10 22:41:46 -05:00
,draw-tileview-icn JSR2
2021-03-03 14:49:26 -05:00
2021-04-09 13:01:53 -04:00
~tileview.x #0040 ADD2 =Screen.x
~tileview.y =Screen.y
2021-03-16 14:25:26 -04:00
~tileview.addr 8+ =tileview.addr
2021-03-10 22:41:46 -05:00
,draw-tileview-icn JSR2
2021-03-03 14:49:26 -05:00
2021-04-09 13:01:53 -04:00
~tileview.x =Screen.x
~tileview.y #0040 ADD2 =Screen.y
2021-03-16 14:25:26 -04:00
~tileview.addr 8+ =tileview.addr
2021-03-10 22:41:46 -05:00
,draw-tileview-icn JSR2
2021-03-03 14:49:26 -05:00
2021-04-09 13:01:53 -04:00
~tileview.x #0040 ADD2 =Screen.x
~tileview.y #0040 ADD2 =Screen.y
2021-03-16 14:25:26 -04:00
~tileview.addr 8+ =tileview.addr
2021-03-10 22:41:46 -05:00
,draw-tileview-icn JSR2
2021-03-03 14:49:26 -05:00
2021-03-03 20:43:39 -05:00
( line hor )
2021-03-20 15:25:26 -04:00
~tileview.y #003f ADD2 =Screen.y
~tileview.x =Screen.x
2021-03-11 18:47:28 -05:00
$line-hor
2021-03-20 15:25:26 -04:00
( draw ) #03 =Screen.color
( incr ) ~Screen.x #0002 ADD2 =Screen.x
2021-03-26 21:18:16 -04:00
~Screen.x ~tileview.x #0082 ADD2 LTH2 ^$line-hor JNZ
2021-03-03 14:49:26 -05:00
2021-03-03 20:43:39 -05:00
( line ver )
2021-03-20 15:25:26 -04:00
~tileview.y =Screen.y
~tileview.x #003f ADD2 =Screen.x
2021-03-11 18:47:28 -05:00
$line-ver
2021-03-20 15:25:26 -04:00
( draw ) #03 =Screen.color
( incr ) ~Screen.y #0002 ADD2 =Screen.y
2021-03-26 21:18:16 -04:00
~Screen.y ~tileview.y #0081 ADD2 LTH2 ^$line-ver JNZ
2021-03-03 14:49:26 -05:00
2021-03-03 20:43:39 -05:00
( rewind ) ~tileview.addr #0018 SUB2 =tileview.addr
2021-03-03 16:49:25 -05:00
2021-03-14 17:26:17 -04:00
RTN
2021-03-03 14:49:26 -05:00
@draw-tileview-icn
#00 =pt.x #00 =pt.y
2021-03-11 18:47:28 -05:00
$ver
2021-03-03 14:49:26 -05:00
#00 =pt.x
2021-03-11 18:47:28 -05:00
$hor
2021-03-03 14:49:26 -05:00
( get bit )
2021-03-03 20:43:39 -05:00
,blank_icn #00
2021-03-24 12:39:19 -04:00
~tileview.addr #00 ~pt.y ADD2 PEK2 #07 ~pt.x SUB SFT #01 AND ( get bit )
2021-04-09 13:01:53 -04:00
8* ADD2 =Screen.addr ( add *8 )
( draw ) #21 =Screen.color
( incr ) ~Screen.x 8+ =Screen.x
2021-03-03 14:49:26 -05:00
( incr ) ~pt.x #01 ADD =pt.x
2021-03-26 14:19:19 -04:00
~pt.x #08 LTH ,$hor JNZ2
2021-04-09 13:01:53 -04:00
( incr ) ~Screen.y 8+ =Screen.y
2021-03-03 14:49:26 -05:00
( incr ) ~pt.y #01 ADD =pt.y
2021-04-09 13:01:53 -04:00
~Screen.x #0040 SUB2 =Screen.x
2021-03-26 14:19:19 -04:00
~pt.y #08 LTH ,$ver JNZ2
2021-03-03 14:49:26 -05:00
2021-03-14 17:26:17 -04:00
RTN
2021-03-03 14:49:26 -05:00
2021-04-15 13:19:59 -04:00
@draw-blendview ( -- )
2021-04-17 16:32:07 -04:00
~blendview.x1 #0002 SUB2 ~blendview.y1 #0002 SUB2 ~blendview.x2 #0001 ADD2 ~blendview.y2 #0001 ADD2 #03 ,line-rect JSR2
2021-04-15 13:19:59 -04:00
~tileview.addr =Screen.addr
#00 #10
$loop
OVR #04 MOD #00 SWP #0008 MUL2 ~blendview.x1 ADD2 =Screen.x
OVR #04 DIV #00 SWP #0008 MUL2 ~blendview.y1 ADD2 =Screen.y
#20 =Screen.color
OVR #20 ADD ~settings.depth #20 MUL ADD =Screen.color
SWP #01 ADD SWP
DUP2 LTH ^$loop JNZ
2021-04-16 14:34:08 -04:00
POP2
2021-04-17 16:32:07 -04:00
~blendview.x1 #0002 SUB2 ~blendview.y2 #0001 ADD2 ~blendview.x1 #000e ADD2 ~blendview.y2 #0009 ADD2 #03 ,line-rect JSR2
~blendview.x1 #0001 SUB2 =Screen.x
~blendview.y2 #0001 ADD2 =Screen.y
2021-04-16 14:34:08 -04:00
( get blending ) ~settings.blending
( get depth ) ~settings.depth #20 MUL
2021-04-17 16:32:07 -04:00
( draw ) #20 ADD ADD #2c ,draw-byte JSR2
2021-04-15 13:19:59 -04:00
RTN
2021-04-17 20:27:24 -04:00
@draw-dataview ( -- )
( bytes )
~tileview.y #0018 ADD2 =Screen.y
#00 =i
$bytes
~tileview.x #0088 ADD2 =Screen.x
~tileview.addr #00 ~i ADD2 PEK2 #22 ,draw-byte JSR2
( incr ) ~i #01 ADD =i
( incr ) ~Screen.y 8+ =Screen.y
~i #08 LTH ,$bytes JNZ2
( operations )
~Screen.y 8+ =Screen.y
,movedown_icn =Screen.addr
#21 =Screen.color
~Screen.x 8- =Screen.x
,moveup_icn =Screen.addr
#21 =Screen.color
( draw tiles 2x2 )
~tileview.y =Screen.y
#00 =pt.x #00 =pt.y ~tileview.addr =Screen.addr
$tiles-ver
#00 =pt.x
~tileview.x #0088 ADD2 =Screen.x
$tiles-hor
( draw ) #23 =Screen.color
( incr ) ~Screen.x 8+ =Screen.x
( incr ) ~Screen.addr 8+ =Screen.addr
( incr ) ~pt.x #01 ADD =pt.x
~pt.x #02 LTH ,$tiles-hor JNZ2
( incr ) ~pt.y #01 ADD =pt.y
( incr ) ~Screen.y 8+ =Screen.y
~pt.y #02 LTH ,$tiles-ver JNZ2
RTN
2021-04-17 01:42:00 -04:00
@draw-colorview ( -- )
~colorview.y1 #18 ADD =Screen.y
~colorview.x1 #08 ADD =Screen.x
~System.r ,draw-color-code JSR2
~colorview.y1 #18 ADD =Screen.y
~colorview.x1 #10 ADD =Screen.x
~System.g ,draw-color-code JSR2
~colorview.y1 #18 ADD =Screen.y
~colorview.x1 #18 ADD =Screen.x
~System.b ,draw-color-code JSR2
~colorview.x1 =Screen.x
2021-04-17 16:32:07 -04:00
,circle_icns =Screen.addr
2021-04-17 01:42:00 -04:00
#00 #04
$loop
2021-04-17 16:32:07 -04:00
OVR ~settings.brush EQU #00 SWP #0008 MUL2 ,circle_icns ADD2 =Screen.addr
2021-04-17 01:42:00 -04:00
OVR ~colorview.y1 ROT #00 SWP #0008 MUL2 ADD2 =Screen.y
OVR #20 ADD =Screen.color
SWP #01 ADD SWP
DUP2 LTH ^$loop JNZ
POP2
RTN
@draw-color-code ( color* -- )
DUP ,font_hex ROT #0f AND #08 MUL #00 SWP ADD2 =Screen.addr
( draw ) #22 =Screen.color
~colorview.y1 #10 ADD =Screen.y
,font_hex ROT #04 SFT #08 MUL #00 SWP ADD2 =Screen.addr
( draw ) #22 =Screen.color
~colorview.y1 #08 ADD =Screen.y
DUP ,font_hex ROT #0f AND #08 MUL #00 SWP ADD2 =Screen.addr
( draw ) #22 =Screen.color
~colorview.y1 =Screen.y
,font_hex ROT #04 SFT #08 MUL #00 SWP ADD2 =Screen.addr
( draw ) #22 =Screen.color
RTN
2021-03-03 14:49:26 -05:00
@draw-cursor
( clear last cursor )
2021-04-09 13:01:53 -04:00
~mouse.x =Screen.x
~mouse.y =Screen.y
,blank_icn =Screen.addr
#30 =Screen.color
2021-03-04 12:07:33 -05:00
2021-03-03 14:49:26 -05:00
( record mouse positions )
2021-03-20 15:25:26 -04:00
~Mouse.x =mouse.x
~Mouse.y =mouse.y
2021-03-04 12:07:33 -05:00
( draw new cursor )
2021-04-09 13:01:53 -04:00
~mouse.x =Screen.x
~mouse.y =Screen.y
,tool_selector #00 ~bankview.mode #08 MUL ADD2 =Screen.addr
#32 ~Mouse.state #00 NEQ ADD =Screen.color
2021-03-03 14:49:26 -05:00
2021-03-14 17:26:17 -04:00
RTN
2021-03-03 14:49:26 -05:00
2021-04-17 16:32:07 -04:00
@draw-byte ( byte color -- )
2021-04-16 14:34:08 -04:00
2021-04-17 16:32:07 -04:00
=color STH
2021-04-16 14:34:08 -04:00
,font_hex #00 DUPr STHr #f0 AND #04 SFT #08 MUL ADD2 =Screen.addr
2021-04-17 16:32:07 -04:00
( draw ) ~color =Screen.color
2021-04-16 14:34:08 -04:00
~Screen.x 8+ =Screen.x
,font_hex #00 STHr #0f AND #08 MUL ADD2 =Screen.addr
2021-04-17 16:32:07 -04:00
( draw ) ~color =Screen.color
2021-04-16 14:34:08 -04:00
RTN
@draw-short ( short -- )
2021-03-03 14:49:26 -05:00
=addr
2021-04-09 13:01:53 -04:00
,font_hex #00 ,addr PEK2 #f0 AND #04 SFT #08 MUL ADD2 =Screen.addr
( draw ) #22 =Screen.color
~Screen.x 8+ =Screen.x
,font_hex #00 ,addr PEK2 #0f AND #08 MUL ADD2 =Screen.addr
( draw ) #22 =Screen.color
~Screen.x 8+ =Screen.x
,font_hex #00 ,addr ++ PEK2 #f0 AND #04 SFT #08 MUL ADD2 =Screen.addr
( draw ) #22 =Screen.color
~Screen.x 8+ =Screen.x
,font_hex #00 ,addr ++ PEK2 #0f AND #08 MUL ADD2 =Screen.addr
( draw ) #22 =Screen.color
2021-03-03 14:49:26 -05:00
2021-03-14 17:26:17 -04:00
RTN
2021-03-03 14:49:26 -05:00
( Utils )
@line-rect ( x1 y1 x2 y2 color -- )
2021-03-03 14:49:26 -05:00
( load ) =color DUP2 STH2 =rect.y2 =rect.x2 DUP2 STH2 =rect.y1 =rect.x1
STH2r STH2r
2021-03-26 21:18:16 -04:00
$ver
( save ) OVR2 =Screen.y
( draw ) ~rect.x1 =Screen.x ~color DUP =Screen.color
( draw ) ~rect.x2 =Screen.x =Screen.color
( incr ) SWP2 ++ SWP2
OVR2 OVR2 LTS2 ^$ver JNZ
POP2 POP2
~rect.x1 ~rect.x2
$hor
( save ) OVR2 =Screen.x
( draw ) ~rect.y1 =Screen.y ~color DUP =Screen.color
( draw ) ~rect.y2 =Screen.y =Screen.color
( incr ) SWP2 ++ SWP2
OVR2 OVR2 ++ LTS2 ^$hor JNZ
POP2 POP2
2021-03-03 14:49:26 -05:00
2021-03-14 17:26:17 -04:00
RTN
2021-03-03 14:49:26 -05:00
2021-04-17 16:32:07 -04:00
@circle_icns
[ 0038 7cfe fefe 7c38 ] ( full )
[ 0038 4482 8282 4438 ] ( line )
2021-04-17 20:27:24 -04:00
@eye_icns
[ 0038 4492 2810 0000 ] ( open )
[ 0000 0082 4438 0000 ] ( closed )
2021-03-03 20:43:39 -05:00
@tool_selector [ 80c0 e0f0 f8e0 1000 ]
@tool_hand [ 4040 4070 f8f8 f870 ]
2021-03-04 13:08:42 -05:00
@tool_eraser [ 2050 b87c 3e1c 0800 ]
2021-04-17 20:27:24 -04:00
@moveup_icn [ 0010 387c fe10 1000 ]
@movedown_icn [ 0010 1010 fe7c 3810 ]
@blank_icn [
0000 0000 0000 0000
7cfe fefe fefe 7c00
]
2021-04-17 01:42:00 -04:00
@depth_icns [
00fe 8282 fe82 82fe
00fe 9292 fe92 92fe
]
2021-04-10 22:39:32 -04:00
@filepath1 [ projects/fonts/specter8.bit 00 ]
@filepath2 [ projects/pictures/cibo.bit 00 ]
@filepath3 [ projects/pictures/zerotwo10x10.chr 00 ]
2021-04-15 13:19:59 -04:00
@filepath4 [ projects/fonts/katahira8.bit 00 ]
2021-04-17 16:32:07 -04:00
@filepath5 [ projects/pictures/ako10x10.chr 00 ]
@filepath6 [ projects/pictures/cyr4x4.chr 00 ]
2021-03-03 14:49:26 -05:00
@font_hex ( 0-F )
[
2021-03-06 14:44:18 -05:00
007c 8282 8282 827c 0030 1010 1010 1010
007c 8202 7c80 80fe 007c 8202 1c02 827c
000c 1424 4484 fe04 00fe 8080 7c02 827c
007c 8280 fc82 827c 007c 8202 1e02 0202
007c 8282 7c82 827c 007c 8282 7e02 827c
007c 8202 7e82 827e 00fc 8282 fc82 82fc
007c 8280 8080 827c 00fc 8282 8282 82fc
007c 8280 f080 827c 007c 8280 f080 8080
2021-03-03 14:49:26 -05:00
]