@@ 1,42 1,17 @@
-(
- app/nasu : spritesheet editor
-
- arrows - move selection
- enter - insert tile
- backspace - delete tile
- left-click - add pixel, select tile
- right-click - remove pixel, clone tile
- 1 2 3 - select color
- q w - select tool
- space - toggle zoom
- ctrl+n - clear
- ctrl+r - rename
- ctrl+o - load
- ctrl+s - save
- ctrl+c - copy
- ctrl+v - paste
- )
+( Nasu )
~src/utils.tal
-( defines )
-
-%HOR { #10 } %VER { #10 }
-%LENGTH { #1000 }
-
%BANK-SPRITESHEET { #8000 }
%BANK-NAMETABLE { #9000 }
%BANK-COLOR { #9100 }
%STEP8 { #33 SFT2 }
-%80** { #70 SFT2 }
%100** { #80 SFT2 }
-%200** { #90 SFT2 }
%100MOD2 { #00ff AND2 }
%GET-ITER { OVR2 NIP OVR SWP }
-%GET-HEX-ADDR { TOS 8** ;font-hex ++ .Screen/addr DEO2 }
%GET-COLOR { .settings/color LDZ STHk 2/ + DEI #01 STHr #01 AND - 4* SFT #0f AND }
%GET-POSITION { .settings/focus LDZ2 BANK-SPRITESHEET -- DUP2 2// 100MOD2 SWP2 #0080 2** DIV2 8** }
%ADD-POSITIONS { ROT2 ++ ROT2 ROT2 ++ SWP2 }
@@ 72,7 47,7 @@
|0000
@state
- &timer $1 &blink $1 &changed $1
+ &timer $1 &changed $1
@settings
&depth $1 &color $1 &blend $1
&ratio $1 &tool $1 &focus $2
@@ 83,12 58,11 @@
&x1 $1 &y1 $1
&x2 $1 &y2 $1
&a $1
-@path
- &name $20 ( ext ) $4
@frame
&x1 $2 &y1 $2
&x2 $2 &y2 $2
&width $2 &height $2
+@filepath $40 ( ext ) $4
( interface )
@toolview [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
@@ 123,7 97,6 @@
;on-console .Console/vector DEO2
;on-button .Controller/vector DEO2
;on-mouse .Mouse/vector DEO2
- ;on-transfer .File/vector DEO2
;on-frame .Screen/vector DEO2
( set defaults )
@@ 135,22 108,19 @@
#32 .settings/ratio STZ
#01 .settings/tool STZ
#00 .settings/brush STZ
- #0000 ;select JSR2
+ #0000 ;set-focus JSR2
.Screen/width DEI2 #01 SFT2 .frame/width LDZ2 #01 SFT2 --
.Screen/height DEI2 #01 SFT2 .frame/height LDZ2 #01 SFT2 --
- .frame/width LDZ2 .frame/height LDZ2
- SIZE-TO-RECT ;frame SET-RECT
+ .frame/width LDZ2 .frame/height LDZ2 SIZE-TO-RECT ;frame SET-RECT
- .frame/x1 LDZ2 #0001 -- .frame/y1 LDZ2 #0030 ++ HOR TOS 8** #0080 SIZE-TO-RECT ;tileview SET-RECT
+ .frame/x1 LDZ2 #0001 -- .frame/y1 LDZ2 #0030 ++ #10 TOS 8** #0080 SIZE-TO-RECT ;tileview SET-RECT
.frame/x1 LDZ2 #0082 ++ .frame/y1 LDZ2 #0030 ++ #007f #007f SIZE-TO-RECT ;nametable SET-RECT
-
.frame/x1 LDZ2 #0001 -- .frame/y1 LDZ2 #0020 #0028 SIZE-TO-RECT ;zoomview SET-RECT
.frame/x1 LDZ2 #002f ++ .frame/y1 LDZ2 #0020 #0020 SIZE-TO-RECT ;preview SET-RECT
.frame/x1 LDZ2 #005f ++ .frame/y1 LDZ2 #0020 #0020 SIZE-TO-RECT ;colorview SET-RECT
.frame/x1 LDZ2 #008f ++ .frame/y1 LDZ2 #0020 #0028 SIZE-TO-RECT ;blendview SET-RECT
.frame/x1 LDZ2 #00bf ++ .frame/y1 LDZ2 #0048 #0020 SIZE-TO-RECT ;dataview SET-RECT
-
.tileview/x1 LDZ2 .tileview/y2 LDZ2 #0008 ++ #0100 #0008 SIZE-TO-RECT ;toolview SET-RECT
.frame/x1 LDZ2 #0002 -- .workspace-frame/x1 STZ2
@@ 168,177 138,126 @@
BRK
+@trap ( -- )
+
+ ;on-frame-trap .Screen/vector DEO2
+ ;on-button-trap .Controller/vector DEO2
+
+RTN
+
+@untrap ( -- )
+
+ ;on-frame .Screen/vector DEO2
+ ;on-button .Controller/vector DEO2
+
+RTN
+
@on-console ( -> )
- ( starting )
- [ LIT &trap $1 ] ,&started JCN
- #00 ;draw-filepath JSR2
- ;path/name #0020 ;mclr JSR2
- #01 ,&trap STR
- &started
- ( append )
- .Console/read DEI #20 < ,&validate JCN
- ;path/name ;slen JSR2 #0020 == ,&validate JCN
- ;path/name .Console/read DEI ;sput JSR2
- BRK
- &validate
- ( validate )
- ;load-file JSR2
+ #00 ;draw-filepath JSR2
+ ( start )
+ [ LIT &listening $1 ] ,&no-start JCN
+ #01 ,&listening STR
+ ;filepath #0040 ;mclr JSR2
+ &no-start
+ ( end )
+ .Console/read DEI
+ DUP IS-VALID ,&no-end JCN
+ #00 ,&listening STR
+ &no-end
+ ( capture )
+ ,capture-trap JSR
+ #01 ;draw-filepath JSR2
+
+BRK
+
+@on-button-trap ( -> )
+
+ #00 ;draw-filepath JSR2
+ .Controller/key DEI STANDARD-LB ,capture-trap JSR
#01 ;draw-filepath JSR2
- #00 ,&trap STR
BRK
+@capture-trap ( button -- )
+
+ DUP ,&no-null JCN POP RTN &no-null
+ [ #08 ] !~ ,&no-pop JCN ;filepath ;spop JSR2 POP RTN &no-pop
+ [ #0a ] !~ ,&no-load JCN ;load-file JSR2 &no-load
+ [ #7f ] !~ ,&no-delete JCN ;filepath #0040 ;mclr JSR2 POP RTN &no-delete
+ [ #20 ] >~ ,&no-special JCN ;untrap JSR2 POP RTN &no-special
+ ;filepath ;slen JSR2 NIP #3f = ,&no-push JCN
+ DUP ;filepath ROT ;sput JSR2
+ &no-push
+ POP
+
+RTN
+
@on-frame ( -> )
+
( inactive )
+
BRK
@on-frame-trap ( -> )
- .state/timer LDZ INC
+ .state/timer LDZ
DUP 8MOD ,&no-blink JCN
- .state/blink LDZ #00 =
- DUP 8* INC ;draw-filepath JSR2
- .state/blink STZ
+ DUP 8/ 2MOD 8* INC ;draw-filepath JSR2
&no-blink
- .state/timer STZ
-
-BRK
-
-@on-transfer ( -> )
-
- ;redraw JSR2
+ INC .state/timer STZ
BRK
@on-button ( -> )
.Controller/button DEI2 #0000 !! [ JMP BRK ]
-
- .Controller/button DEI #01 AND ;on-control JCN2
+ .Controller/button DEI #01 AND ;on-button-ctrl JCN2
+ .Controller/button DEI #f0 AND ;on-button-arrow JCN2
.Controller/key DEI
- #31 !~ ,&no-1 JCN
- ( color ) #00 .settings/color STZ ;draw-toolview JSR2 &no-1
- #32 !~ ,&no-2 JCN
- ( color ) #01 .settings/color STZ ;draw-toolview JSR2 &no-2
- #33 !~ ,&no-3 JCN
- ( color ) #02 .settings/color STZ ;draw-toolview JSR2 &no-3
- #34 !~ ,&no-4 JCN
- ( color ) #03 .settings/color STZ ;draw-toolview JSR2 &no-4
- #08 !~ ,&no-delete JCN
- ( delete ) ;op-erase ;run-selection JSR2 SET-STATE ;redraw JSR2 &no-delete
- #20 !~ ,&no-zoom JCN
- ( zoom ) .settings/zoom TOGGLE ;redraw JSR2 &no-zoom
- #71 !~ ,&no-tool0 JCN
- ( tool ) #00 .settings/tool STZ ;redraw JSR2 &no-tool0
- #77 !~ ,&no-tool1 JCN
- ( tool ) #01 .settings/tool STZ ;redraw JSR2 &no-tool1
- #1b !~ ,&no-escape JCN
- ( escape ) RESET-SELECTION ;redraw JSR2 &no-escape
+ [ LIT '1 ] !~ ,&no-1 JCN #00 ;set-color JSR2 &no-1
+ [ LIT '2 ] !~ ,&no-2 JCN #01 ;set-color JSR2 &no-2
+ [ LIT '3 ] !~ ,&no-3 JCN #02 ;set-color JSR2 &no-3
+ [ LIT '4 ] !~ ,&no-4 JCN #03 ;set-color JSR2 &no-4
+ [ LIT 'q ] !~ ,&no-tool0 JCN #00 ;set-tool JSR2 &no-tool0
+ [ LIT 'w ] !~ ,&no-tool1 JCN #01 ;set-tool JSR2 &no-tool1
+ [ #08 ] !~ ,&no-delete JCN ;op-erase ;run-selection JSR2 SET-STATE ;redraw JSR2 &no-delete
+ [ #20 ] !~ ,&no-zoom JCN ;toggle-zoom JSR2 &no-zoom
+ [ #1b ] !~ ,&no-escape JCN RESET-SELECTION ;redraw JSR2 &no-escape
POP
- ( release ) #00 .Controller/key DEO
+BRK
+
+@on-button-arrow ( -> )
.Controller/button DEI
( default )
- [ #10 ] !~ ,&no-up JCN
- #00 #ff ;mod-selection JSR2 POP BRK &no-up
- [ #20 ] !~ ,&no-down JCN
- #00 #01 ;mod-selection JSR2 POP BRK &no-down
- [ #40 ] !~ ,&no-left JCN
- #ff #00 ;mod-selection JSR2 POP BRK &no-left
- [ #80 ] !~ ,&no-right JCN
- #01 #00 ;mod-selection JSR2 POP BRK &no-right
+ [ #10 ] !~ ,&no-up JCN #00 #ff ;mod-selection JSR2 POP BRK &no-up
+ [ #20 ] !~ ,&no-down JCN #00 #01 ;mod-selection JSR2 POP BRK &no-down
+ [ #40 ] !~ ,&no-left JCN #ff #00 ;mod-selection JSR2 POP BRK &no-left
+ [ #80 ] !~ ,&no-right JCN #01 #00 ;mod-selection JSR2 POP BRK &no-right
( shift )
- [ #14 ] !~ ,&no-shift-up JCN
- #00 #ff ;scale-selection JSR2 POP BRK &no-shift-up
- [ #24 ] !~ ,&no-shift-down JCN
- #00 #01 ;scale-selection JSR2 POP BRK &no-shift-down
- [ #44 ] !~ ,&no-shift-left JCN
- #ff #00 ;scale-selection JSR2 POP BRK &no-shift-left
- [ #84 ] !~ ,&no-shift-right JCN
- #01 #00 ;scale-selection JSR2 POP BRK &no-shift-right
- POP
-
- ;redraw JSR2
-
-BRK
-
-@on-control ( -> )
-
- .Controller/key DEI
- DUP [ LIT 'a ] ! ,&no-expand JCN
- #00 .selection/x1 STZ
- #00 .selection/y1 STZ
- HOR #01 - .selection/x2 STZ
- VER #01 - .selection/y2 STZ
- ;clamp-selection JSR2
- ;redraw JSR2 POP BRK
- &no-expand
- DUP [ LIT 'c ] ! ,&no-copy JCN
- ;copy-snarf JSR2
- ;redraw JSR2 POP BRK
- &no-copy
- DUP [ LIT 'v ] ! ,&no-paste JCN
- ;paste-snarf JSR2 RESET-SELECTION
- ;redraw JSR2 POP BRK
- &no-paste
- DUP [ LIT 'x ] ! ,&no-cut JCN
- ;copy-snarf JSR2 ;op-erase ;run-selection JSR2 RESET-SELECTION
- ;redraw JSR2 POP BRK
- &no-cut
- DUP [ LIT 'r ] ! ,&no-name JCN
- #00 ;draw-filepath JSR2
- ;on-frame-trap .Screen/vector DEO2
- ;on-button-trap .Controller/vector DEO2
- POP BRK
- &no-name
- DUP [ LIT 'R ] ! ,&no-rename JCN
- #00 ;draw-filepath JSR2
- ;path/name #0020 ;mclr JSR2
- ;on-frame-trap .Screen/vector DEO2
- ;on-button-trap .Controller/vector DEO2
- POP BRK
- &no-rename
- DUP [ LIT 'n ] ! ,&no-new JCN
- ;new-file JSR2
- POP BRK &no-new
- DUP [ LIT 'o ] ! ,&no-open JCN
- ;load-file JSR2
- POP BRK &no-open
- DUP [ LIT 's ] ! ,&no-save JCN
- ;save-file JSR2
- ;save-theme JSR2
- ;draw-state JSR2 POP BRK &no-save
+ [ #14 ] !~ ,&no-shift-up JCN #00 #ff ;scale-selection JSR2 POP BRK &no-shift-up
+ [ #24 ] !~ ,&no-shift-down JCN #00 #01 ;scale-selection JSR2 POP BRK &no-shift-down
+ [ #44 ] !~ ,&no-shift-left JCN #ff #00 ;scale-selection JSR2 POP BRK &no-shift-left
+ [ #84 ] !~ ,&no-shift-right JCN #01 #00 ;scale-selection JSR2 POP BRK &no-shift-right
POP
BRK
-@on-button-trap ( -> )
+@on-button-ctrl ( -> )
.Controller/key DEI
- DUP ,&continue JCN
- POP BRK
- &continue
- ( backspace ) #08 !~ ,&no-edit-backspace JCN
- ( clamp ) ;path/name ;slen JSR2 NIP #00 = ,&edit-end JCN
- #00 ;draw-filepath JSR2
- ;path/name ;spop JSR2
- #01 ;draw-filepath JSR2
- POP BRK
- &no-edit-backspace
- ( special ) DUP IS-VALID ,&no-edit-enter JCN
- ;on-frame .Screen/vector DEO2
- ;on-button .Controller/vector DEO2
- #00 .state/blink STZ
- #01 ;draw-filepath JSR2
- POP BRK
- &no-edit-enter
- ( append ) ;path/name ;slen JSR2 NIP #1f = ,&edit-end JCN
- DUP ;path/name ROT ;sput JSR2
- #01 ;draw-filepath JSR2
- &edit-end
+ ( copy/paste/cut )
+ [ LIT 'c ] !~ ,&no-copy JCN ;copy-snarf JSR2 &no-copy
+ [ LIT 'v ] !~ ,&no-paste JCN ;paste-snarf JSR2 &no-paste
+ [ LIT 'x ] !~ ,&no-cut JCN ;cut-snarf JSR2 &no-cut
+ ( new/rename/open/save )
+ [ LIT 'n ] !~ ,&no-new JCN ;new-file JSR2 &no-new
+ [ LIT 'r ] !~ ,&no-name JCN ;trap JSR2 &no-name
+ [ LIT 'o ] !~ ,&no-open JCN ;load-file JSR2 &no-open
+ [ LIT 's ] !~ ,&no-save JCN ;save-file JSR2 &no-save
POP
BRK
@@ 347,22 266,18 @@ BRK
;draw-cursor JSR2
- .Mouse/x DEI2 .Mouse/y DEI2 .tileview ;within-rect JSR2
- ;on-touch-tileview JCN2
- .Mouse/x DEI2 .Mouse/y DEI2 .nametable ;within-rect JSR2
- ;on-touch-nametable JCN2
- .Mouse/x DEI2 .Mouse/y DEI2 .toolview ;within-rect JSR2
- ;on-touch-toolview JCN2
- .Mouse/x DEI2 .Mouse/y DEI2 .blendview ;within-rect JSR2
- ;on-touch-blendview JCN2
- .Mouse/x DEI2 .Mouse/y DEI2 .colorview ;within-rect JSR2
- ;on-touch-colorview JCN2
- .Mouse/x DEI2 .Mouse/y DEI2 .preview ;within-rect JSR2
- ;on-touch-preview JCN2
- .Mouse/x DEI2 .Mouse/y DEI2 .zoomview ;within-rect JSR2
- ;on-touch-zoomview JCN2
-
- ( release-record ) #0000 .Mouse/state DEO .cursor/last STZ
+ .Mouse/state DEI #00 = ,&no-touch JCN
+ .Mouse/x DEI2 .Mouse/y DEI2 .tileview ;within-rect JSR2 ;on-touch-tileview JCN2
+ .Mouse/x DEI2 .Mouse/y DEI2 .nametable ;within-rect JSR2 ;on-touch-nametable JCN2
+ .Mouse/x DEI2 .Mouse/y DEI2 .toolview ;within-rect JSR2 ;on-touch-toolview JCN2
+ .Mouse/x DEI2 .Mouse/y DEI2 .blendview ;within-rect JSR2 ;on-touch-blendview JCN2
+ .Mouse/x DEI2 .Mouse/y DEI2 .colorview ;within-rect JSR2 ;on-touch-colorview JCN2
+ .Mouse/x DEI2 .Mouse/y DEI2 .preview ;within-rect JSR2 ;on-touch-preview JCN2
+ .Mouse/x DEI2 .Mouse/y DEI2 .zoomview ;within-rect JSR2 ;on-touch-zoomview JCN2
+ &no-touch
+
+ ( release-record )
+ #0000 .Mouse/state DEO .cursor/last STZ
BRK
@@ 371,8 286,6 @@ BRK
.settings/zoom LDZ #01 = ;&zoomed JCN2
.settings/tool LDZ #01 = ;&select JCN2
- ( skip ) .Mouse/state DEI #00 ! [ JMP BRK ]
-
.Mouse/x DEI2 .tileview/x1 LDZ2 --
.Mouse/y DEI2 .tileview/y1 LDZ2 --
@@ 391,7 304,7 @@ BRK
BRK &no-brush-mouse2
DUP2 #0101 !! ,&no-select-mouse1 JCN ( select default )
POP2
- ;select JSR2
+ ;set-focus JSR2
;redraw JSR2
BRK &no-select-mouse1
DUP2 #0110 !! ,&no-select-mouse2 JCN ( select copy )
@@ 412,18 325,14 @@ BRK
DUP2 #0000 == ,&end JCN
DUP2 #0100 !! ,&no-down JCN
.Mouse/x DEI2 .tileview/x1 LDZ2 -- 8// NIP
- DUP .selection/x1 STZ .selection/x2 STZ
.Mouse/y DEI2 .tileview/y1 LDZ2 -- 8// NIP
- DUP .selection/y1 STZ .selection/y2 STZ
- ;clamp-selection JSR2
- .selection LDZ2 ;select JSR2
- ;redraw JSR2
+ ;set-selection-from JSR2
,&end JMP
&no-down
( release )
- .Mouse/x DEI2 .tileview/x1 LDZ2 -- 8// NIP .selection/x2 STZ
- .Mouse/y DEI2 .tileview/y1 LDZ2 -- 8// NIP .selection/y2 STZ
- ;clamp-selection JSR2 ;redraw JSR2
+ .Mouse/x DEI2 .tileview/x1 LDZ2 -- 8// NIP
+ .Mouse/y DEI2 .tileview/y1 LDZ2 -- 8// NIP
+ ;set-selection-to JSR2
&end
POP2
.cursor/last STZ
@@ 432,16 341,10 @@ BRK
&zoomed ( -> )
- ( skip ) .Mouse/state DEI #00 ! [ JMP BRK ]
-
- .Mouse/x DEI2 .tileview/x1 LDZ2 --
- .Mouse/y DEI2 .tileview/y1 LDZ2 --
- 8// SWP2 8// SWP2
+ .Mouse/x DEI2 .tileview/x1 LDZ2 -- 8//
+ .Mouse/y DEI2 .tileview/y1 LDZ2 -- 8//
GET-POSITION ADD-POSITIONS
- #00 .Mouse/state DEI #01 > ,&do-erase-zoom JCN
- POP .settings/color LDZ
- &do-erase-zoom
- ;put-pixel JSR2
+ .settings/color LDZ .Mouse/state DEI #01 = * ;put-pixel JSR2
SET-STATE
;redraw JSR2
@@ 449,95 352,44 @@ BRK
@on-touch-nametable ( -> )
- ( skip ) .Mouse/state DEI #00 ! [ JMP BRK ]
-
( get touch tile )
.Mouse/y DEI2 .nametable/y LDZ2 -- 8// 10**
.Mouse/x DEI2 .nametable/x LDZ2 -- 8// ++ STH2
-
( look for changes )
STH2kr BANK-NAMETABLE ++ LDA
.settings/focus LDZ2 BANK-SPRITESHEET -- 10// NIP
STH2kr BANK-COLOR ++ LDA
- .settings/blend LDZ
- !! ,&continue JCN
- POP2r BRK
- &continue
-
+ .settings/blend LDZ !! ,&continue JCN POP2r BRK &continue
( set sprite )
.settings/focus LDZ2 BANK-SPRITESHEET -- 10// NIP
STH2kr BANK-NAMETABLE ++ STA
-
( set color )
.settings/blend LDZ
STH2r BANK-COLOR ++ STA
-
;draw-nametable JSR2
-
SET-STATE
BRK
@on-touch-toolview ( -> )
-
- ( skip ) .Mouse/state DEI #00 ! [ JMP BRK ]
-
+
+ RELEASE-MOUSE
.Mouse/x DEI2 .toolview/x1 LDZ2 -- 8// NIP
- DUP #1f ! ,&no-save JCN
- ;save-file JSR2
- ;draw-state JSR2
- POP RELEASE-MOUSE BRK
- &no-save
- DUP #1d ! ,&no-load JCN
- ;load-file JSR2
- POP RELEASE-MOUSE BRK
- &no-load
- DUP #1c ! ,&no-name JCN
- ;new-file JSR2
- POP RELEASE-MOUSE BRK
- &no-name
- DUP #04 ! ,&no-brush JCN
- #00 .settings/tool STZ
- ;draw-toolview JSR2
- POP RELEASE-MOUSE BRK
- &no-brush
- DUP #05 ! ,&no-selector JCN
- #01 .settings/tool STZ
- ;draw-toolview JSR2
- POP RELEASE-MOUSE BRK
- &no-selector
- DUP #06 ! ,&no-zoom JCN
- .settings/zoom TOGGLE
- ;draw-tileview JSR2
- ;draw-toolview JSR2
- &no-zoom
- INCk .settings/color LDZ ! ,&no-eraser JCN
- #00 .settings/color STZ
- ;draw-colorview JSR2
- ;draw-toolview JSR2
- POP RELEASE-MOUSE BRK
- &no-eraser
- DUP #02 > ,&no-color JCN
- INCk .settings/color STZ
- ;draw-colorview JSR2
- ;draw-toolview JSR2
- POP RELEASE-MOUSE BRK
- &no-color
- DUP #08 < ,&no-rename JCN
- #00 ;draw-filepath JSR2
- ;on-frame-trap .Screen/vector DEO2
- ;on-button-trap .Controller/vector DEO2
- POP RELEASE-MOUSE BRK
- &no-rename
+ [ #1f ] !~ ,&no-save JCN ;save-file JSR2 POP BRK &no-save
+ [ #1d ] !~ ,&no-load JCN ;load-file JSR2 POP BRK &no-load
+ [ #1c ] !~ ,&no-name JCN ;new-file JSR2 POP BRK &no-name
+ [ #04 ] !~ ,&no-brush JCN #00 ;set-tool JSR2 POP BRK &no-brush
+ [ #05 ] !~ ,&no-selector JCN #01 ;set-tool JSR2 POP BRK &no-selector
+ [ #06 ] !~ ,&no-zoom JCN ;toggle-zoom JSR2 &no-zoom
+ INCk .settings/color LDZ ! ,&no-eraser JCN #00 ;set-color JSR2 POP BRK &no-eraser
+ [ #02 ] >~ ,&no-color JCN INCk ;set-color JSR2 POP BRK &no-color
+ [ #08 ] <~ ,&no-rename JCN ;trap JSR2 POP BRK &no-rename
POP
- RELEASE-MOUSE
BRK
@on-touch-zoomview ( -> )
- ( skip ) .Mouse/state DEI #00 ! [ JMP BRK ]
-
.Mouse/y DEI2 .zoomview/y1 LDZ2 -- 8// NIP #04 ! ;&no-mod JCN2
.Mouse/x DEI2 .zoomview/x1 LDZ2 -- 8// NIP
DUP #00 = .Mouse/state DEI #01 = #0101 !! ,&no-shiftup JCN
@@ 562,13 414,9 @@ BRK
.Mouse/y DEI2 .zoomview/y1 LDZ2 -- 4//
.settings/focus LDZ2 ++
( detect erase )
- #00 .Mouse/state DEI #01 > ,&do-erase JCN
- POP .settings/color LDZ &do-erase
- STH
- OVR2 OVR2
- STHkr #00 ;toggle-pixel JSR2
- #0008 ++
- STHr #01 ;toggle-pixel JSR2
+ .settings/color LDZ .Mouse/state DEI #01 = * STH
+ OVR2 OVR2 STHkr #00 ;toggle-pixel JSR2
+ #0008 ++ STHr #01 ;toggle-pixel JSR2
SET-STATE
&finish
@@ 579,8 427,6 @@ BRK
@on-touch-blendview ( -> )
- ( skip ) .Mouse/state DEI #00 ! [ JMP BRK ]
-
.Mouse/x DEI2 .blendview/x1 LDZ2 -- 8// NIP
.Mouse/y DEI2 .blendview/y1 LDZ2 -- 8// NIP 4* +
DUP #0f > ,&no-set JCN
@@ 601,8 447,6 @@ BRK
@on-touch-colorview ( -> )
- ( skip ) .Mouse/state DEI #00 ! [ JMP BRK ]
-
.Mouse/y DEI2 .colorview/y1 LDZ2 -- 8// NIP
DUP #00 ! ,&no-r JCN
@@ 637,8 481,6 @@ BRK
@on-touch-preview ( -> )
- ( skip ) .Mouse/state DEI #00 ! [ JMP BRK ]
-
( y ) .Mouse/y DEI2 .preview/y1 LDZ2 -- 8// NIP
( x ) .Mouse/x DEI2 .preview/x1 LDZ2 -- 8// NIP
@@ 653,7 495,48 @@ BRK
( operations )
-@select ( x y -- )
+@toggle-zoom ( -- )
+
+ .settings/zoom TOGGLE
+ ;draw-tileview JSR2
+ ;draw-toolview JSR2
+
+RTN
+
+@set-color ( color -- )
+
+ .settings/color STZ
+ ;draw-toolview JSR2
+
+RTN
+
+@set-tool ( tool -- )
+
+ .settings/tool STZ
+ ;draw-toolview JSR2
+
+RTN
+
+@set-selection-from ( x y -- )
+
+ DUP .selection/y1 STZ .selection/y2 STZ
+ DUP .selection/x1 STZ .selection/x2 STZ
+ ;clamp-selection JSR2
+ .selection LDZ2 ;set-focus JSR2
+ ;redraw JSR2
+
+RTN
+
+@set-selection-to ( x y -- )
+
+ .selection/y2 STZ
+ .selection/x2 STZ
+ ;clamp-selection JSR2
+ ;redraw JSR2
+
+RTN
+
+@set-focus ( x y -- )
DUP2
GET-ADDR .settings/focus STZ2
@@ 677,7 560,7 @@ RTN
.selection/y1 LDZ .selection/y2 STZ
&no-y
( focus )
- .selection LDZ2 ;select JSR2
+ .selection LDZ2 ;set-focus JSR2
;redraw JSR2
@@ 696,7 579,7 @@ RTN
.selection/y1 LDZ .selection/y2 STZ
&no-y
( focus )
- .selection LDZ2 ;select JSR2
+ .selection LDZ2 ;set-focus JSR2
;redraw JSR2
RTN
@@ 730,22 613,6 @@ RTN
RTN
-@clamp-selection ( -- )
-
- .selection/x1 LDZ HOR #01 - STHk < ,&ok-limitx1 JCN
- STHkr .selection/x1 STZ &ok-limitx1 POPr
- .selection/y1 LDZ VER #01 - STHk < ,&ok-limity1 JCN
- STHkr .selection/y1 STZ &ok-limity1 POPr
- .selection/x2 LDZ HOR #01 - STHk < ,&ok-limitx2 JCN
- STHkr .selection/x2 STZ &ok-limitx2 POPr
- .selection/y2 LDZ VER #01 - STHk < ,&ok-limity2 JCN
- STHkr .selection/y2 STZ &ok-limity2 POPr
- .selection/x2 LDZ .selection/x1 LDZ STHk > ,&ok-flipx JCN
- STHkr .selection/x2 STZ &ok-flipx POPr
- .selection/y2 LDZ .selection/y1 LDZ STHk > ,&ok-flipy JCN
- STHkr .selection/y2 STZ &ok-flipy POPr
-
-RTN
@op-shift-tile-up ( addr* -- )
@@ 821,6 688,24 @@ RTN
RTN
+@clamp-selection ( -- )
+
+ .selection/x1 LDZ #10 #01 - STHk < ,&ok-limitx1 JCN
+ STHkr .selection/x1 STZ &ok-limitx1 POPr
+ .selection/y1 LDZ #10 #01 - STHk < ,&ok-limity1 JCN
+ STHkr .selection/y1 STZ &ok-limity1 POPr
+ .selection/x2 LDZ #10 #01 - STHk < ,&ok-limitx2 JCN
+ STHkr .selection/x2 STZ &ok-limitx2 POPr
+ .selection/y2 LDZ #10 #01 - STHk < ,&ok-limity2 JCN
+ STHkr .selection/y2 STZ &ok-limity2 POPr
+ ( invert )
+ .selection/x2 LDZ .selection/x1 LDZ STHk > ,&ok-flipx JCN
+ STHkr .selection/x2 STZ &ok-flipx POPr
+ .selection/y2 LDZ .selection/y1 LDZ STHk > ,&ok-flipy JCN
+ STHkr .selection/y2 STZ &ok-flipy POPr
+
+RTN
+
@redraw ( -- )
;draw-toolview JSR2
@@ 832,7 717,7 @@ RTN
;draw-nametable JSR2
;draw-zoomview JSR2
- .frame/x1 LDZ2 #0080 ++ .tileview/y1 LDZ2 .tileview/y2 LDZ2 INC2 #03 ;line-ver JSR2
+ .frame/x1 LDZ2 #0080 ++ .tileview/y1 LDZ2 .tileview/y2 LDZ2 INC2 #03 ;line-ver-dashed JSR2
RTN
@@ 876,10 761,10 @@ RTN
( find focus ) GET-POSITION STH2 STH2
;pixel-icn .Screen/addr DEO2
- VER #00
+ #10 #00
&ver
DUP 8* TOS .tileview/y1 LDZ2 ++ .Screen/y DEO2
- HOR #00
+ #10 #00
&hor
DUP 8* TOS .tileview/x1 LDZ2 ++ .Screen/x DEO2
( get pixel offset ) GET-ITER SWP TOS ROT TOS
@@ 892,8 777,8 @@ RTN
POP2r POP2r
( guides )
- .tileview/x1 LDZ2 .tileview/x2 LDZ2 .tileview/y1 LDZ2 #003f ++ #02 ;line-hor JSR2
- .tileview/x1 LDZ2 #003f ++ .tileview/y1 LDZ2 .tileview/y2 LDZ2 #02 ;line-ver JSR2
+ .tileview/x1 LDZ2 .tileview/x2 LDZ2 .tileview/y1 LDZ2 #003f ++ #02 ;line-hor-dashed JSR2
+ .tileview/x1 LDZ2 #003f ++ .tileview/y1 LDZ2 .tileview/y2 LDZ2 #02 ;line-ver-dashed JSR2
RTN
@@ 917,10 802,20 @@ RTN
RTN
+( tools )
+
+@get-tile-addr ( x* y* -- addr* )
+
+ STEP8 100** 4// SWP2
+ STEP8 2** ++
+ BANK-SPRITESHEET ++
+
+RTN
+
@get-pixel ( x* y* -- color )
( channel 1 )
- OVR2 SWP2 ,get-addr JSR [ STH2k ] LDA
+ OVR2 SWP2 ,get-pixel-addr JSR [ STH2k ] LDA
ROT ROT NIP 8MOD [ STHk ]
#07 SWP - SFT #01 AND
( channel 2 )
@@ 931,7 826,7 @@ RTN
RTN
-@get-addr ( x* y* -- addr* )
+@get-pixel-addr ( x* y* -- addr* )
( get row )
DUP2 8MOD2
@@ 945,7 840,7 @@ RTN
@put-pixel ( x* y* color -- )
STH
- OVR2 SWP2 ,get-addr JSR
+ OVR2 SWP2 ,get-pixel-addr JSR
( ch1 )
OVR2 OVR2
STHkr #00 ,toggle-pixel JSR
@@ 971,14 866,6 @@ RTN
RTN
-@get-tile-addr ( x* y* -- addr* )
-
- STEP8 100** 4// SWP2
- STEP8 2** ++
- BANK-SPRITESHEET ++
-
-RTN
-
@copy-tile ( src* dst* -- )
STH2 STH2
@@ 994,6 881,19 @@ RTN
RTN
+@has-nametable ( -- bool )
+
+ BANK-NAMETABLE STH2k #0200 ++ STH2r
+ &loop
+ LDAk #00 = ,&continue JCN
+ POP2 POP2 #01 RTN
+ &continue
+ INC2 GTH2k ,&loop JCN
+ POP2 POP2
+ #00
+
+RTN
+
( panes )
@draw-zoomview ( -- )
@@ 1027,7 927,7 @@ RTN
.zoomview/x1 LDZ2 .Screen/x DEO2
;arrow-ver-icns .Screen/addr DEO2
#03 .Screen/sprite DEO
- .Screen/x DEI2 #0008 ++ .Screen/x DEO2
+ .Screen/x DEI2k #0008 ++ ROT DEO2
;arrow-hor-icns .Screen/addr DEO2
#03 .Screen/sprite DEO
@@ 1074,14 974,9 @@ RTN
.colorview/y2 LDZ2 INC2 .Screen/y DEO2
.colorview/x1 LDZ2 .Screen/x DEO2
- .System/r GET-COLOR GET-HEX-ADDR
- #03 .Screen/sprite DEO
- .Screen/x DEI2 #0008 ++ .Screen/x DEO2
- .System/g GET-COLOR GET-HEX-ADDR
- #03 .Screen/sprite DEO
- .Screen/x DEI2 #0008 ++ .Screen/x DEO2
- .System/b GET-COLOR GET-HEX-ADDR
- #03 .Screen/sprite DEO
+ .System/r GET-COLOR #03 ;draw-hex JSR2
+ .System/g GET-COLOR #03 ;draw-hex JSR2
+ .System/b GET-COLOR #03 ;draw-hex JSR2
.colorview/x1 LDZ2 .colorview/y1 LDZ2
[ .System/r GET-COLOR ] ,&slider JSR
@@ 1146,14 1041,16 @@ RTN
.dataview/x1 LDZ2 .Screen/x DEO2
.dataview/y2 LDZ2 INC2 .Screen/y DEO2
.selection/a LDZ #03 ;draw-byte JSR2
- ( depth1 )
+ .dataview/y1 LDZ2 .Screen/y DEO2
#04 #00
&loop
.dataview/x1 LDZ2 .Screen/x DEO2
- DUP 8* TOS .dataview/y1 LDZ2 ++ .Screen/y DEO2
- DUP 2* TOS .settings/focus LDZ2 ++ LDA2 #01 ;draw-short JSR2
- .dataview/x1 LDZ2 #0020 ++ .Screen/x DEO2
- DUP 2* TOS .settings/focus LDZ2 ++ #0008 ++ LDA2 #02 ;draw-short JSR2
+ DUP 2* TOS .settings/focus LDZ2 ++
+ ( ch1 ) LDA2k #01 ;draw-short JSR2
+ .Screen/x DEI2k #0004 ++ ROT DEO2
+ ( ch2 ) #0008 ++ LDA2 #02 ;draw-short JSR2
+ ( skip line )
+ .Screen/y DEI2k #0008 ++ ROT DEO2
INC GTHk ,&loop JCN
POP2
@@ 1218,10 1115,10 @@ RTN
.toolview/x1 LDZ2 #0040 ++ .Screen/x DEO2
.toolview/y1 LDZ2 .Screen/y DEO2
AUTO-X
- ;path/name
+ ;filepath
( scroll )
DUP2 ;slen JSR2 #0013 >> TOS
- ;path/name ;slen JSR2 #0013 -- ** ++
+ ;filepath ;slen JSR2 #0013 -- ** ++
&loop
LDAk #20 - TOS 8** ;font ++ .Screen/addr DEO2
STHkr .Screen/sprite DEO
@@ 1245,23 1142,30 @@ RTN
@draw-short ( short* color -- )
- ROT OVR ,draw-byte JSR
- .Screen/x DEI2 #0008 ++ .Screen/x DEO2
- ,draw-byte JSR
+ STH
+ SWP STHkr ,draw-byte JSR
+ STHr ,draw-byte JSR
RTN
@draw-byte ( byte color -- )
- STH
- DUP
- #04 SFT GET-HEX-ADDR
- ( draw ) STHkr .Screen/sprite DEO
- .Screen/x DEI2 #0008 ++ .Screen/x DEO2
- #0f AND GET-HEX-ADDR
- ( draw ) STHr .Screen/sprite DEO
+ STH DUP
+ #04 SFT STHkr ,draw-hex JSR
+ #0f AND STHr ,draw-hex JSR
+
+RTN
+
+@draw-hex ( char color -- )
+
+ SWP
+ ,&parse JSR TOS 8** ;font ++ .Screen/addr DEO2
+ .Screen/sprite DEO
+ .Screen/x DEI2k #0008 ++ ROT DEO2
RTN
+ &parse ( value -- char )
+ DUP #09 > ,&above JCN #10 + RTN &above #37 + RTN
( file )
@@ 1269,12 1173,12 @@ RTN
#00 ;draw-filepath JSR2
- BANK-SPRITESHEET LENGTH ;mclr JSR2
+ BANK-SPRITESHEET #1000 ;mclr JSR2
BANK-NAMETABLE #0200 ;mclr JSR2
( rename to untitled.txt )
- ;path/name #0020 ;mclr JSR2
- ;untitled-txt ;path/name #000c ;mcpy JSR2
+ ;filepath #0020 ;mclr JSR2
+ ;untitled-txt ;filepath #000c ;mcpy JSR2
RESET-STATE
;redraw JSR2
@@ 1283,20 1187,20 @@ RTN
@load-file ( -- )
- BANK-SPRITESHEET LENGTH ;mclr JSR2
+ BANK-SPRITESHEET #1000 ;mclr JSR2
BANK-NAMETABLE #0200 ;mclr JSR2
( spritesheet )
- ;path/name .File/name DEO2
- LENGTH .File/length DEO2
+ ;filepath .File/name DEO2
+ #1000 .File/length DEO2
BANK-SPRITESHEET .File/load DEO2
( nametable )
- ( append ) ;nametable-ext ;path/name ;scap JSR2 #0004 ;mcpy JSR2
- ;path/name .File/name DEO2
+ ;nametable-ext ;filepath ;scap JSR2 #0004 ;mcpy JSR2
+ ;filepath .File/name DEO2
#0200 .File/length DEO2
BANK-NAMETABLE .File/load DEO2
- ( remove ) ;path/name ;scap JSR2 #0004 -- #0004 ;mclr JSR2
+ ;filepath ;scap JSR2 #0004 -- #0004 ;mclr JSR2
RESET-STATE
;redraw JSR2
@@ 1306,19 1210,20 @@ RTN
@save-file ( -- )
( spritesheet )
- ;path/name .File/name DEO2
- LENGTH .File/length DEO2
+ ;filepath .File/name DEO2
+ #1000 .File/length DEO2
BANK-SPRITESHEET .File/save DEO2
( nametable )
- ( append ) ;nametable-ext ;path/name ;scap JSR2 #0004 ;mcpy JSR2
- ;path/name .File/name DEO2
- #0200 .File/length DEO2
- BANK-NAMETABLE .File/save DEO2
- ( remove ) ;path/name ;scap JSR2 #0004 -- #0004 ;mclr JSR2
+ ;has-nametable JSR2 #00 = ,&no-nametable JCN
+ ;nametable-ext ;filepath ;scap JSR2 #0004 ;mcpy JSR2
+ ;filepath .File/name DEO2
+ #0200 .File/length DEO2
+ BANK-NAMETABLE .File/save DEO2
+ ;filepath ;scap JSR2 #0004 -- #0004 ;mclr JSR2
+ &no-nametable
RESET-STATE
-
;save-theme JSR2
RTN
@@ 1369,6 1274,7 @@ RTN
POP2
INC GTHk ,&ver JCN
POP2
+ ;redraw JSR2
RTN
&buf $10
@@ 1386,6 1292,15 @@ RTN
POP2
INC GTHk ,&ver JCN
POP2
+ ;redraw JSR2
+
+RTN
+
+@cut-snarf ( -- )
+
+ ;copy-snarf JSR2
+ ;op-erase ;run-selection JSR2
+ RESET-SELECTION
RTN
@@ 1440,23 1355,23 @@ RTN
RTN
-@line-hor ( x0* x1* y* color -- )
+@line-hor-dashed ( x0* x1* y* color -- )
STH .Screen/y DEO2 SWP2
&loop
- ( save ) DUP2 .Screen/x DEO2
- ( draw ) STHkr .Screen/pixel DEO
+ DUP2 .Screen/x DEO2
+ STHkr .Screen/pixel DEO
INC2 INC2 GTH2k ,&loop JCN
POP2 POP2 POPr
RTN
-@line-ver ( x* y0* y1* color -- )
+@line-ver-dashed ( x* y0* y1* color -- )
STH ROT2 .Screen/x DEO2 SWP2
&loop
- ( save ) DUP2 .Screen/y DEO2
- ( draw ) STHkr .Screen/pixel DEO
+ DUP2 .Screen/y DEO2
+ STHkr .Screen/pixel DEO
INC2 INC2 GTH2k ,&loop JCN
POP2 POP2 POPr
@@ 1496,7 1411,7 @@ RTN
@scap ( str* -- str-end* )
- ( clamp ) LDAk #00 ! JMP RTN
+ LDAk #00 ! JMP RTN
&while INC2 LDAk ,&while JCN
RTN
@@ 1509,7 1424,8 @@ RTN
@spop ( str* -- )
- ( clamp ) LDAk #00 ! JMP RTN
+ LDAk ,&no-null JCN
+ POP2 RTN &no-null
#00 ROT ROT ,scap JSR #0001 -- STA
RTN
@@ 1529,87 1445,4 @@ RTN
@untitled-txt "untitled.chr $1
@nametable-ext ".tbl $1
-@tool-brush e0d0 8844 2212 0c00
-@tool-selector 80c0 e0f0 f8e0 1000
-@pixel-icn 7cfe fefe fefe 7c00
-@bigpixel-icn f0f0 f0f0 0000 0000
-@halftone-icn aa55 aa55 aa55 aa55
-@save-icn 1054 28c6 2854 1000
-@make-icn fe82 8282 848a f400
-@load-icn feaa d6aa d4aa f400
-
-@slider-icns
- f0f0 f0f0 f0f0 f000 ( full )
- 50a0 50a0 50a0 5000 ( empty )
-@circle-icns
- 3844 8282 8244 3800 ( full )
- 387c fefe fe7c 3800 ( line )
-@zoom-icns
- 3048 8484 4834 0200 ( in )
- 3245 8284 4834 0200 ( out )
-@arrow-hor-icns
- 0010 181c fe1c 1810
- 0010 3070 fe70 3010
-@arrow-ver-icns
- 0010 387c fe10 1010
- 0010 1010 fe7c 3810
-
-@font-hex ( 0-F )
- 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
-
-@font ( specter8-frag font )
- 0000 0000 0000 0000 0008 0808 0800 0800
- 0014 1400 0000 0000 0024 7e24 247e 2400
- 0008 1e28 1c0a 3c08 0000 2204 0810 2200
- 0030 4832 4c44 3a00 0008 1000 0000 0000
- 0004 0808 0808 0400 0020 1010 1010 2000
- 0000 2214 0814 2200 0000 0808 3e08 0800
- 0000 0000 0000 0810 0000 0000 3e00 0000
- 0000 0000 0000 0800 0000 0204 0810 2000
- 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
- 0000 0010 0000 1000 0000 1000 0010 1020
- 0000 0810 2010 0800 0000 003e 003e 0000
- 0000 1008 0408 1000 003c 420c 1000 1000
- 003c 4232 4a42 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 003c 4240 4642 3c00
- 0042 427e 4242 4200 001c 0808 0808 1c00
- 007e 0202 0242 3c00 0042 4478 4442 4200
- 0040 4040 4040 7e00 0042 665a 4242 4200
- 0042 6252 4a46 4200 003c 4242 4242 3c00
- 007c 4242 7c40 4000 003c 4242 4244 3a00
- 007c 4242 7c44 4200 003e 403c 0242 3c00
- 007e 0808 0808 1000 0042 4242 4244 3a00
- 0042 4242 4224 1800 0042 4242 5a66 4200
- 0042 423c 4242 4200 0042 423e 0242 3c00
- 007e 020c 3040 7e00 000c 0808 0808 0c00
- 0040 2010 0804 0200 0030 1010 1010 3000
- 0008 1400 0000 0000 0000 0000 0000 7e00
- 0008 0400 0000 0000 0000 3c02 3e42 3a00
- 0040 407c 4242 7c00 0000 3c42 4042 3c00
- 0002 023e 4242 3e00 0000 3c42 7e40 3e00
- 0000 3e40 7840 4000 0000 3c42 3e02 3c00
- 0040 405c 6242 4200 0008 0018 0808 0400
- 0008 0018 0808 4830 0040 4244 7844 4200
- 0010 1010 1010 0c00 0000 6c52 5252 5200
- 0000 5c62 4242 4200 0000 3c42 4242 3c00
- 0000 7c42 427c 4040 0000 3e42 423e 0202
- 0000 5c62 4040 4000 0000 3e40 3c02 7c00
- 0008 7e08 0808 1000 0000 4242 4244 3a00
- 0000 4242 4224 1800 0000 5252 5252 2e00
- 0000 4224 1824 4200 0000 4242 3e02 7c00
- 0000 7e02 3c40 7e00 000c 0810 1008 0c00
- 0008 0808 0808 0800 0030 1008 0810 3000
- 0000 0032 4c00 0000 3c42 99a1 a199 423c
+~src/assets.tal