@@ 1,30 1,39 @@
( Nasu )
-~src/utils.tal
+%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
+%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
+%-- { SUB2 } %** { MUL2 } %// { DIV2 }
+
+%2* { #10 SFT } %2/ { #01 SFT } %2** { #10 SFT2 } %2// { #01 SFT2 }
+%4* { #20 SFT } %4/ { #02 SFT } %4** { #20 SFT2 } %4// { #02 SFT2 }
+%8* { #30 SFT } %8/ { #03 SFT } %8** { #30 SFT2 } %8// { #03 SFT2 }
+%10* { #40 SFT } %10/ { #04 SFT } %10** { #40 SFT2 } %10// { #04 SFT2 }
+%20* { #50 SFT } %20/ { #05 SFT } %20** { #50 SFT2 } %20// { #05 SFT2 }
+%40* { #60 SFT } %40/ { #06 SFT } %40** { #60 SFT2 }
+
+%RELEASE-MOUSE { #0096 DEO }
+
+%AUTO-NONE { #00 .Screen/auto DEO }
+%AUTO-X { #01 .Screen/auto DEO }
+%AUTO-Y { #02 .Screen/auto DEO }
+%AUTO-ADDR { #04 .Screen/auto DEO }
+%AUTO-Y-ADDR { #06 .Screen/auto DEO }
%BANK-SPRITESHEET { #8000 }
%BANK-NAMETABLE { #9000 }
%BANK-COLOR { #9100 }
-%GET-ITER { OVR2 NIP OVR SWP }
-
-%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// #00ff AND2 SWP2 #0080 2** DIV2 8** }
-%ADD-POSITIONS { ROT2 ++ ROT2 ROT2 ++ SWP2 }
-%RESET-SELECTION { .selection/x1 LDZ2 .selection/x2 STZ2 }
-%GET-ADDR { TOS 10** ROT TOS ++ 10** BANK-SPRITESHEET ++ } ( x y -- addr* )
-
%SET-STATE { #01 .state/changed STZ ;draw-state JSR2 }
%RESET-STATE { #00 .state/changed STZ ;draw-state JSR2 }
%SIZE-TO-RECT {
- STH2 STH2 OVR2 STH2r ++ OVR2 STH2r ++
+ STH2 STH2 OVR2 STH2r ADD2 OVR2 STH2r ADD2
} ( x y w h -- x1 y1 x2 y2 )
%SET-RECT {
- DUP2 ROT2 SWP2 #0006 ++ STA2
- DUP2 ROT2 SWP2 #0004 ++ STA2
- DUP2 ROT2 SWP2 #0002 ++ STA2
+ DUP2 ROT2 SWP2 #0006 ADD2 STA2
+ DUP2 ROT2 SWP2 #0004 ADD2 STA2
+ DUP2 ROT2 SWP2 #0002 ADD2 STA2
DUP2 ROT2 SWP2 STA2
POP2
} ( x1 y1 x2 y2 addr -- )
@@ 109,23 118,23 @@
.Screen/height DEI2 #01 SFT2 .frame/height LDZ2 #01 SFT2 --
.frame/width LDZ2 .frame/height LDZ2 SIZE-TO-RECT ;frame 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 #0030 ADD2 #10 #00 SWP 8** #0080 SIZE-TO-RECT ;tileview SET-RECT
+ .frame/x1 LDZ2 #0082 ADD2 .frame/y1 LDZ2 #0030 ADD2 #007f #007f SIZE-TO-RECT ;nametable SET-RECT
.frame/x1 LDZ2 #0001 -- .frame/y1 LDZ2 #001f #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 #002f ADD2 .frame/y1 LDZ2 #0020 #0020 SIZE-TO-RECT ;preview SET-RECT
+ .frame/x1 LDZ2 #005f ADD2 .frame/y1 LDZ2 #0020 #0020 SIZE-TO-RECT ;colorview SET-RECT
+ .frame/x1 LDZ2 #008f ADD2 .frame/y1 LDZ2 #0020 #0028 SIZE-TO-RECT ;blendview SET-RECT
+ .frame/x1 LDZ2 #00bf ADD2 .frame/y1 LDZ2 #0048 #0020 SIZE-TO-RECT ;dataview SET-RECT
+ .tileview/x1 LDZ2 .tileview/y2 LDZ2 #0008 ADD2 #0100 #0008 SIZE-TO-RECT ;toolview SET-RECT
.frame/x1 LDZ2 #0002 -- .workspace-frame/x1 STZ2
.tileview/y1 LDZ2 #0001 -- .workspace-frame/y1 STZ2
- .frame/x2 LDZ2 #0002 ++ .workspace-frame/x2 STZ2
+ .frame/x2 LDZ2 #0002 ADD2 .workspace-frame/x2 STZ2
.tileview/y2 LDZ2 INC2 .workspace-frame/y2 STZ2
.zoomview/x1 LDZ2 #0001 -- .zoomview-frame/x1 STZ2
.zoomview/y1 LDZ2 #0001 -- .zoomview-frame/y1 STZ2
- .zoomview/x2 LDZ2 #0002 ++ .zoomview-frame/x2 STZ2
+ .zoomview/x2 LDZ2 #0002 ADD2 .zoomview-frame/x2 STZ2
.zoomview/y2 LDZ2 #0007 -- .zoomview-frame/y2 STZ2
;new-file JSR2
@@ 141,7 150,7 @@ BRK
#01 ;draw-filepath JSR2
RELEASE-MOUSE
-RTN
+JMP2r
@trap ( -- )
@@ 154,7 163,7 @@ RTN
#40 .Screen/sprite DEO
RELEASE-MOUSE
-RTN
+JMP2r
@on-console ( -> )
@@ 166,7 175,7 @@ RTN
&no-start
( end )
.Console/read DEI
- DUP IS-VALID ,&no-end JCN
+ DUP DUP #1f > SWP #7f < AND ,&no-end JCN
#00 ,&listening STR
&no-end
( capture )
@@ 178,24 187,24 @@ BRK
@on-button-trap ( -> )
#00 ;draw-filepath JSR2
- .Controller/key DEI STANDARD-LB ,capture-trap JSR
+ .Controller/key DEI DUP #0d = #03 * - ,capture-trap JSR
#01 ;draw-filepath JSR2
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
+ DUP ,&no-null JCN POP JMP2r &no-null
+ [ #08 ] NEQk NIP ,&no-pop JCN ;filepath ;spop JSR2 POP JMP2r &no-pop
+ [ #0a ] NEQk NIP ,&no-load JCN ;load-file JSR2 &no-load
+ [ #7f ] NEQk NIP ,&no-delete JCN ;filepath #0040 ;mclr JSR2 POP JMP2r &no-delete
+ [ #20 ] GTHk NIP ,&no-special JCN ;untrap JSR2 POP JMP2r &no-special
;filepath ;slen JSR2 NIP #3f = ,&no-push JCN
DUP ;filepath ROT ;sput JSR2
&no-push
POP
-RTN
+JMP2r
@on-mouse-trap ( -> )
@@ 215,8 224,8 @@ BRK
@on-frame-trap ( -> )
.state/timer LDZ
- DUP 8MOD ,&no-blink JCN
- DUP 8/ 2MOD 8* INC ;draw-filepath JSR2
+ DUP #07 AND ,&no-blink JCN
+ DUP 8/ #01 AND 8* INC ;draw-filepath JSR2
&no-blink
INC .state/timer STZ
@@ 224,21 233,21 @@ BRK
@on-button ( -> )
- .Controller/button DEI2 #0000 !! [ JMP BRK ]
+ .Controller/button DEI2 #0000 NEQ2 [ JMP BRK ]
.Controller/button DEI #01 AND ;on-button-ctrl JCN2
.Controller/button DEI #f0 AND ;on-button-arrow JCN2
.Controller/key DEI
- [ 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
- [ LIT 'e ] !~ ,&no-tool2 JCN #02 ;set-tool JSR2 &no-tool2
- [ #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
+ [ LIT '1 ] NEQk NIP ,&no-1 JCN #00 ;set-color JSR2 &no-1
+ [ LIT '2 ] NEQk NIP ,&no-2 JCN #01 ;set-color JSR2 &no-2
+ [ LIT '3 ] NEQk NIP ,&no-3 JCN #02 ;set-color JSR2 &no-3
+ [ LIT '4 ] NEQk NIP ,&no-4 JCN #03 ;set-color JSR2 &no-4
+ [ LIT 'q ] NEQk NIP ,&no-tool0 JCN #00 ;set-tool JSR2 &no-tool0
+ [ LIT 'w ] NEQk NIP ,&no-tool1 JCN #01 ;set-tool JSR2 &no-tool1
+ [ LIT 'e ] NEQk NIP ,&no-tool2 JCN #02 ;set-tool JSR2 &no-tool2
+ [ #08 ] NEQk NIP ,&no-delete JCN ;op-erase ;run-selection JSR2 SET-STATE ;redraw JSR2 &no-delete
+ [ #20 ] NEQk NIP ,&no-zoom JCN ;toggle-zoom JSR2 &no-zoom
+ [ #1b ] NEQk NIP ,&no-escape JCN .selection/x1 LDZ2 .selection/x2 STZ2 ;redraw JSR2 &no-escape
POP
BRK
@@ 247,15 256,15 @@ BRK
.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 ] NEQk NIP ,&no-up JCN #00 #ff ;mod-selection JSR2 POP BRK &no-up
+ [ #20 ] NEQk NIP ,&no-down JCN #00 #01 ;mod-selection JSR2 POP BRK &no-down
+ [ #40 ] NEQk NIP ,&no-left JCN #ff #00 ;mod-selection JSR2 POP BRK &no-left
+ [ #80 ] NEQk NIP ,&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
+ [ #14 ] NEQk NIP ,&no-shift-up JCN #00 #ff ;scale-selection JSR2 POP BRK &no-shift-up
+ [ #24 ] NEQk NIP ,&no-shift-down JCN #00 #01 ;scale-selection JSR2 POP BRK &no-shift-down
+ [ #44 ] NEQk NIP ,&no-shift-left JCN #ff #00 ;scale-selection JSR2 POP BRK &no-shift-left
+ [ #84 ] NEQk NIP ,&no-shift-right JCN #01 #00 ;scale-selection JSR2 POP BRK &no-shift-right
POP
BRK
@@ 264,14 273,14 @@ BRK
.Controller/key DEI
( 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
+ [ LIT 'c ] NEQk NIP ,&no-copy JCN ;copy-snarf JSR2 &no-copy
+ [ LIT 'v ] NEQk NIP ,&no-paste JCN ;paste-snarf JSR2 &no-paste
+ [ LIT 'x ] NEQk NIP ,&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
+ [ LIT 'n ] NEQk NIP ,&no-new JCN ;new-file JSR2 &no-new
+ [ LIT 'r ] NEQk NIP ,&no-name JCN ;trap JSR2 &no-name
+ [ LIT 'o ] NEQk NIP ,&no-open JCN ;load-file JSR2 &no-open
+ [ LIT 's ] NEQk NIP ,&no-save JCN ;save-file JSR2 &no-save
POP
BRK
@@ 326,8 335,8 @@ BRK
&zoomed ( -> )
- .Mouse/x DEI2 .tileview/x1 LDZ2 -- 8// #00 .selection/zx LDZ ++
- .Mouse/y DEI2 .tileview/y1 LDZ2 -- 8// #00 .selection/zy LDZ ++
+ .Mouse/x DEI2 .tileview/x1 LDZ2 -- 8// #00 .selection/zx LDZ ADD2
+ .Mouse/y DEI2 .tileview/y1 LDZ2 -- 8// #00 .selection/zy LDZ ADD2
.settings/color LDZ .Mouse/state DEI #01 = * ;put-pixel JSR2
SET-STATE
;redraw JSR2
@@ 337,8 346,8 @@ BRK
&select ( -> )
.Mouse/state DEI DUP .cursor/last LDZ
- DUP2 #0000 == ,&end JCN
- DUP2 #0100 !! ,&no-down JCN
+ DUP2 #0000 EQU2 ,&end JCN
+ DUP2 #0100 NEQ2 ,&no-down JCN
.Mouse/x DEI2 .tileview/x1 LDZ2 -- 8// NIP
.Mouse/y DEI2 .tileview/y1 LDZ2 -- 8// NIP
( select zoom )
@@ 361,18 370,18 @@ BRK
( get touch tile )
.Mouse/y DEI2 .nametable/y LDZ2 -- 8// 10**
- .Mouse/x DEI2 .nametable/x LDZ2 -- 8// ++ STH2
+ .Mouse/x DEI2 .nametable/x LDZ2 -- 8// ADD2 STH2
( look for changes )
- STH2kr BANK-NAMETABLE ++ LDA
+ STH2kr BANK-NAMETABLE ADD2 LDA
.settings/focus LDZ2 BANK-SPRITESHEET -- 10// NIP
- STH2kr BANK-COLOR ++ LDA
- .settings/blend LDZ !! ,&continue JCN POP2r BRK &continue
+ STH2kr BANK-COLOR ADD2 LDA
+ .settings/blend LDZ NEQ2 ,&continue JCN POP2r BRK &continue
( set sprite )
.settings/focus LDZ2 BANK-SPRITESHEET -- 10// NIP
- STH2kr BANK-NAMETABLE ++ STA
+ STH2kr BANK-NAMETABLE ADD2 STA
( set color )
.settings/blend LDZ
- STH2r BANK-COLOR ++ STA
+ STH2r BANK-COLOR ADD2 STA
;draw-nametable JSR2
SET-STATE
@@ 382,15 391,15 @@ BRK
RELEASE-MOUSE
.Mouse/x DEI2 .toolview/x1 LDZ2 -- 8// NIP
- [ #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-tool0 JCN #00 ;set-tool JSR2 POP BRK &no-tool0
- [ #05 ] !~ ,&no-tool1 JCN #01 ;set-tool JSR2 POP BRK &no-tool1
- [ #06 ] !~ ,&no-tool2 JCN #02 ;set-tool JSR2 &no-tool2
+ [ #1f ] NEQk NIP ,&no-save JCN ;save-file JSR2 POP BRK &no-save
+ [ #1d ] NEQk NIP ,&no-load JCN ;load-file JSR2 POP BRK &no-load
+ [ #1c ] NEQk NIP ,&no-name JCN ;new-file JSR2 POP BRK &no-name
+ [ #04 ] NEQk NIP ,&no-tool0 JCN #00 ;set-tool JSR2 POP BRK &no-tool0
+ [ #05 ] NEQk NIP ,&no-tool1 JCN #01 ;set-tool JSR2 POP BRK &no-tool1
+ [ #06 ] NEQk NIP ,&no-tool2 JCN #02 ;set-tool JSR2 &no-tool2
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
+ [ #02 ] GTHk NIP ,&no-color JCN INCk ;set-color JSR2 POP BRK &no-color
+ [ #08 ] LTHk NIP ,&no-rename JCN ;trap JSR2 POP BRK &no-rename
POP
BRK
@@ 399,16 408,16 @@ 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
+ DUP #00 = .Mouse/state DEI #01 = #0101 NEQ2 ,&no-shiftup JCN
;op-shift-tile-up ;run-selection JSR2
SET-STATE &no-shiftup
- DUP #00 = .Mouse/state DEI #01 > #0101 !! ,&no-shiftdown JCN
+ DUP #00 = .Mouse/state DEI #01 > #0101 NEQ2 ,&no-shiftdown JCN
;op-shift-tile-down ;run-selection JSR2
SET-STATE &no-shiftdown
- DUP #01 = .Mouse/state DEI #01 = #0101 !! ,&no-shiftright JCN
+ DUP #01 = .Mouse/state DEI #01 = #0101 NEQ2 ,&no-shiftright JCN
;op-shift-tile-right ;run-selection JSR2
SET-STATE &no-shiftright
- DUP #01 = .Mouse/state DEI #01 > #0101 !! ,&no-shiftleft JCN
+ DUP #01 = .Mouse/state DEI #01 > #0101 NEQ2 ,&no-shiftleft JCN
;op-shift-tile-left ;run-selection JSR2
SET-STATE &no-shiftleft
POP
@@ 419,11 428,11 @@ BRK
( paint )
.Mouse/x DEI2 .zoomview/x1 LDZ2 -- 4//
.Mouse/y DEI2 .zoomview/y1 LDZ2 -- 4//
- .settings/focus LDZ2 ++
+ .settings/focus LDZ2 ADD2
( detect erase )
.settings/color LDZ .Mouse/state DEI #01 = * STH
OVR2 OVR2 STHkr #00 ;toggle-pixel JSR2
- #0008 ++ STHr #01 ;toggle-pixel JSR2
+ #0008 ADD2 STHr #01 ;toggle-pixel JSR2
SET-STATE
&finish
@@ 476,13 485,13 @@ BRK
&set-color
.settings/color LDZ STHk 2/ + DEI
- STHr 2MOD STHk
+ STHr #01 AND STHk
#0f SWP [ 40* SFT ] AND
STHr #00 =
.Mouse/x DEI2 .colorview/x1 LDZ2 -- 2// NIP
( clamp to #0f ) DUP #01 > -
SWP [ 40* SFT ] +
- RTN
+ JMP2r
BRK
@@ 504,11 513,11 @@ BRK
@toggle-zoom ( -- )
- .settings/zoom TOGGLE
+ .settings/zoom LDZk #00 = SWP STZ
;draw-tileview JSR2
;draw-toolview JSR2
-RTN
+JMP2r
@set-color ( color -- )
@@ 516,21 525,21 @@ RTN
;draw-toolview JSR2
;draw-colorview JSR2
-RTN
+JMP2r
@set-tool ( tool -- )
.settings/tool STZ
;draw-toolview JSR2
-RTN
+JMP2r
@set-selection-zoom ( x y -- )
#7f AND .selection/zy STZ
#7f AND .selection/zx STZ
-RTN
+JMP2r
@set-selection-from ( x y -- )
@@ 540,7 549,7 @@ RTN
.selection LDZ2 ;set-focus JSR2
;redraw JSR2
-RTN
+JMP2r
@set-selection-to ( x y -- )
@@ 549,27 558,27 @@ RTN
;clamp-selection JSR2
;redraw JSR2
-RTN
+JMP2r
@set-focus ( x y -- )
( set zoom )
DUP2
- GET-ADDR .settings/focus STZ2
+ ;get-tile-addr JSR2 .settings/focus STZ2
#40 SFT + .selection/a STZ
-RTN
+JMP2r
@mod-selection ( x y -- )
.settings/zoom LDZ ;mod-selection-zoom JCN2
DUP
- .selection/y2 LDZ + 10MOD .selection/y2 STZ
- .selection/y1 LDZ + 10MOD .selection/y1 STZ
+ .selection/y2 LDZ + #0f AND .selection/y2 STZ
+ .selection/y1 LDZ + #0f AND .selection/y1 STZ
DUP
- .selection/x2 LDZ + 10MOD .selection/x2 STZ
- .selection/x1 LDZ + 10MOD .selection/x1 STZ
+ .selection/x2 LDZ + #0f AND .selection/x2 STZ
+ .selection/x1 LDZ + #0f AND .selection/x1 STZ
( clamp )
.selection/x2 LDZ .selection/x1 LDZ GTH ,&no-x JCN
.selection/x1 LDZ .selection/x2 STZ
@@ 585,7 594,7 @@ RTN
;redraw JSR2
-RTN
+JMP2r
@mod-selection-zoom ( x y -- )
@@ 599,12 608,12 @@ RTN
;set-selection-from JSR2
;draw-tileview-zoom JSR2
-RTN
+JMP2r
@scale-selection ( x y -- )
- .selection/y2 LDZ + 10MOD .selection/y2 STZ
- .selection/x2 LDZ + 10MOD .selection/x2 STZ
+ .selection/y2 LDZ + #0f AND .selection/y2 STZ
+ .selection/x2 LDZ + #0f AND .selection/x2 STZ
( clamp )
.selection/x2 LDZ .selection/x1 LDZ GTH ,&no-x JCN
@@ 617,7 626,7 @@ RTN
.selection LDZ2 ;set-focus JSR2
;redraw JSR2
-RTN
+JMP2r
@run-selection ( op* -- )
@@ 626,14 635,14 @@ RTN
&ver
.selection/x2 LDZ INC .selection/x1 LDZ
&hor
- ( write char ) GET-ITER GET-ADDR STH2kr JSR2
+ ( write char ) OVR2 NIP OVR SWP ;get-tile-addr JSR2 STH2kr JSR2
INC GTHk ,&hor JCN
POP2
INC GTHk ,&ver JCN
POP2
POP2r
-RTN
+JMP2r
@op-erase ( addr* -- )
@@ 641,25 650,25 @@ RTN
#10 #00
&loop
( get )
- DUP TOS STH2kr ++ #00 ROT ROT STA
+ DUP #00 SWP STH2kr ADD2 #00 ROT ROT STA
INC GTHk ,&loop JCN
POP2
POP2r
-RTN
+JMP2r
@op-shift-tile-up ( addr* -- )
DUP2
- DUP2 #0007 ++ SWP2 LDAk STH
+ DUP2 #0007 ADD2 SWP2 LDAk STH
&ch1
INC2k LDA STH
DUP2 STHr ROT ROT STA
INC2 GTH2k ,&ch1 JCN
POP2
( cap ) STHr ROT ROT STA
- #0008 ++ DUP2 #0007 ++ SWP2 LDAk STH
+ #0008 ADD2 DUP2 #0007 ADD2 SWP2 LDAk STH
&ch2
INC2k LDA STH
DUP2 STHr ROT ROT STA
@@ 667,19 676,19 @@ RTN
POP2
( cap ) STHr ROT ROT STA
-RTN
+JMP2r
@op-shift-tile-down ( addr* -- )
DUP2
- DUP2 #0007 ++ LDAk STH
+ DUP2 #0007 ADD2 LDAk STH
&ch1
DUP2 #0001 -- LDA STH
DUP2 STHr ROT ROT STA
#0001 -- LTH2k ,&ch1 JCN
POP2
( cap ) STHr ROT ROT STA
- #0008 ++ DUP2 #0007 ++ LDAk STH
+ #0008 ADD2 DUP2 #0007 ADD2 LDAk STH
&ch2
DUP2 #0001 -- LDA STH
DUP2 STHr ROT ROT STA
@@ 687,7 696,7 @@ RTN
POP2
( cap ) STHr ROT ROT STA
-RTN
+JMP2r
@op-shift-tile-left ( addr* -- )
@@ 695,16 704,16 @@ RTN
#08 #00
&loop
( ch1 )
- DUP TOS STH2kr ++ DUP2
- LDA [ ROL ] ROT ROT STA
+ DUP #00 SWP STH2kr ADD2 DUP2
+ LDA [ ;rol JSR2 ] ROT ROT STA
( ch2 )
- DUP TOS STH2kr #0008 ++ ++ DUP2
- LDA [ ROL ] ROT ROT STA
+ DUP #00 SWP STH2kr #0008 ADD2 ADD2 DUP2
+ LDA [ ;rol JSR2 ] ROT ROT STA
INC GTHk ,&loop JCN
POP2
POP2r
-RTN
+JMP2r
@op-shift-tile-right ( addr* -- )
@@ 712,16 721,16 @@ RTN
#08 #00
&loop
( ch1 )
- DUP TOS STH2kr ++ DUP2
- LDA [ ROR ] ROT ROT STA
+ DUP #00 SWP STH2kr ADD2 DUP2
+ LDA [ ;ror JSR2 ] ROT ROT STA
( ch2 )
- DUP TOS STH2kr #0008 ++ ++ DUP2
- LDA [ ROR ] ROT ROT STA
+ DUP #00 SWP STH2kr #0008 ADD2 ADD2 DUP2
+ LDA [ ;ror JSR2 ] ROT ROT STA
INC GTHk ,&loop JCN
POP2
POP2r
-RTN
+JMP2r
@clamp-selection ( -- )
@@ 739,7 748,7 @@ RTN
.selection/y2 LDZ .selection/y1 LDZ STHk > ,&ok-flipy JCN
STHkr .selection/y2 STZ &ok-flipy POPr
-RTN
+JMP2r
@redraw ( -- )
@@ 752,9 761,9 @@ RTN
;draw-nametable JSR2
;draw-zoomview JSR2
- .frame/x1 LDZ2 #0080 ++ .tileview/y1 LDZ2 .tileview/y2 LDZ2 INC2 #03 ;line-ver-dashed JSR2
+ .frame/x1 LDZ2 #0080 ADD2 .tileview/y1 LDZ2 .tileview/y2 LDZ2 INC2 #03 ;line-ver-dashed JSR2
-RTN
+JMP2r
@is-selected ( x y -- flag )
@@ 762,11 771,11 @@ RTN
OVR .selection/x2 LDZ > ,&end JCN
DUP .selection/y1 LDZ < ,&end JCN
DUP .selection/y2 LDZ > ,&end JCN
- POP2 #01 RTN
+ POP2 #01 JMP2r
&end
POP2 #00
-RTN
+JMP2r
@draw-tileview ( -- )
@@ 775,12 784,12 @@ RTN
AUTO-X
#1000
&ver
- DUP TOS 8** .tileview/y1 LDZ2 ++ .Screen/y DEO2
+ DUP #00 SWP 8** .tileview/y1 LDZ2 ADD2 .Screen/y DEO2
.tileview/x1 LDZ2 .Screen/x DEO2
#1000
&hor
- GET-ITER
- DUP2 GET-ADDR .Screen/addr DEO2
+ OVR2 NIP OVR SWP
+ DUP2 ;get-tile-addr JSR2 .Screen/addr DEO2
;is-selected JSR2 #0d * #81 + .Screen/sprite DEO
INC GTHk ,&hor JCN
POP2
@@ 790,21 799,21 @@ RTN
.workspace-frame #03 ;line-rect JSR2
-RTN
+JMP2r
@draw-tileview-zoom ( -- )
- ( find focus ) GET-POSITION STH2 STH2
+ ( find focus ) .settings/focus LDZ2 BANK-SPRITESHEET -- DUP2 2// #00ff AND2 SWP2 #0080 2** DIV2 8** STH2 STH2
;pixel-icn .Screen/addr DEO2
#10 #00
&ver
- DUP 8* TOS .tileview/y1 LDZ2 ++ .Screen/y DEO2
+ DUP 8* #00 SWP .tileview/y1 LDZ2 ADD2 .Screen/y DEO2
#10 #00
&hor
- DUP 8* TOS .tileview/x1 LDZ2 ++ .Screen/x DEO2
- GET-ITER
- ( y ) .selection/zy LDZ + TOS
- ( x ) ROT .selection/zx LDZ + TOS SWP2
+ DUP 8* #00 SWP .tileview/x1 LDZ2 ADD2 .Screen/x DEO2
+ OVR2 NIP OVR SWP
+ ( y ) .selection/zy LDZ + #00 SWP
+ ( x ) ROT .selection/zx LDZ + #00 SWP SWP2
;get-pixel JSR2 .Screen/sprite DEO
INC GTHk ,&hor JCN
POP2
@@ 812,72 821,78 @@ RTN
POP2
POP2r POP2r
( guides )
- #00 #07 .selection/zy LDZ - 8MOD2 8** #0001 -- #0008 ++ STH2
- .tileview/x1 LDZ2 .tileview/x2 LDZ2 .tileview/y1 LDZ2 STH2kr ++ #02 ;line-hor-dashed JSR2
- .tileview/x1 LDZ2 .tileview/x2 LDZ2 .tileview/y1 LDZ2 STH2r ++ #0040 ++ #02 ;line-hor-dashed JSR2
- #00 #07 .selection/zx LDZ - 8MOD2 8** #0001 -- #0008 ++ STH2
- .tileview/x1 LDZ2 STH2kr ++ .tileview/y1 LDZ2 .tileview/y2 LDZ2 #02 ;line-ver-dashed JSR2
- .tileview/x1 LDZ2 STH2r ++ #0040 ++ .tileview/y1 LDZ2 .tileview/y2 LDZ2 #02 ;line-ver-dashed JSR2
+ #00 #07 .selection/zy LDZ - #0007 AND2 8** #0001 -- #0008 ADD2 STH2
+ .tileview/x1 LDZ2 .tileview/x2 LDZ2 .tileview/y1 LDZ2 STH2kr ADD2 #02 ;line-hor-dashed JSR2
+ .tileview/x1 LDZ2 .tileview/x2 LDZ2 .tileview/y1 LDZ2 STH2r ADD2 #0040 ADD2 #02 ;line-hor-dashed JSR2
+ #00 #07 .selection/zx LDZ - #0007 AND2 8** #0001 -- #0008 ADD2 STH2
+ .tileview/x1 LDZ2 STH2kr ADD2 .tileview/y1 LDZ2 .tileview/y2 LDZ2 #02 ;line-ver-dashed JSR2
+ .tileview/x1 LDZ2 STH2r ADD2 #0040 ADD2 .tileview/y1 LDZ2 .tileview/y2 LDZ2 #02 ;line-ver-dashed JSR2
-RTN
+JMP2r
@draw-nametable ( -- )
AUTO-X
#1000
&ver
- DUP TOS 8** .nametable/y LDZ2 ++ .Screen/y DEO2
+ DUP #00 SWP 8** .nametable/y LDZ2 ADD2 .Screen/y DEO2
.nametable/x LDZ2 .Screen/x DEO2
#1000
&hor
- GET-ITER [ #40 SFT + ] #00 SWP
- DUP2 BANK-NAMETABLE ++ LDA TOS 10** BANK-SPRITESHEET ++ .Screen/addr DEO2
- BANK-COLOR ++ LDA .Screen/sprite DEO
+ OVR2 NIP OVR SWP [ #40 SFT + ] #00 SWP
+ DUP2 BANK-NAMETABLE ADD2 LDA #00 SWP 10** BANK-SPRITESHEET ADD2 .Screen/addr DEO2
+ BANK-COLOR ADD2 LDA .Screen/sprite DEO
INC GTHk ,&hor JCN
POP2
INC GTHk ,&ver JCN
POP2
AUTO-NONE
-RTN
+JMP2r
( tools )
+@get-tile-addr ( x y -- addr* )
+
+ #00 SWP 10** ROT #00 SWP ADD2 10** BANK-SPRITESHEET ADD2
+
+JMP2r
+
@get-pixel ( x* y* -- color )
( channel 1 )
OVR2 SWP2 ,get-pixel-addr JSR [ STH2k ] LDA
- ROT ROT NIP 8MOD [ STHk ]
+ ROT ROT NIP #07 AND [ STHk ]
#07 SWP - SFT #01 AND
( channel 2 )
- [ STHr ] [ STH2r ] #0008 ++ LDA SWP
+ [ STHr ] [ STH2r ] #0008 ADD2 LDA SWP
#07 SWP - SFT #01 AND
2*
+
-RTN
+JMP2r
@get-pixel-addr ( x* y* -- addr* )
( clamp )
#007f AND2 SWP2 #007f AND2 SWP2
( get row )
- DUP2 8MOD2
+ DUP2 #0007 AND2
( get tile )
- SWP2 #83 SFT2 ++
- SWP2 #43 SFT2 ++
- BANK-SPRITESHEET ++
+ SWP2 #83 SFT2 ADD2
+ SWP2 #43 SFT2 ADD2
+ BANK-SPRITESHEET ADD2
-RTN
+JMP2r
@put-pixel ( x* y* color -- )
STH
OVR2 SWP2 ,get-pixel-addr JSR
( ch1 ) OVR2 OVR2 STHkr #00 ,toggle-pixel JSR
- ( ch2 ) #0008 ++ STHr #01 ,toggle-pixel JSR
+ ( ch2 ) #0008 ADD2 STHr #01 ,toggle-pixel JSR
-RTN
+JMP2r
@toggle-pixel ( x* addr* color -- )
@@ 886,27 901,27 @@ RTN
STH SWP2 NIP
STHr SWP
STH2r SFT #01 AND ,&do-set JCN
- ( mask ) #01 #07 ROT 8MOD - #40 SFT SFT #ff EOR AND
+ ( mask ) #01 #07 ROT #07 AND - #40 SFT SFT #ff EOR AND
( save ) ROT ROT STA
- RTN
+ JMP2r
&do-set
- ( mask ) #01 #07 ROT 8MOD - #40 SFT SFT ORA
+ ( mask ) #01 #07 ROT #07 AND - #40 SFT SFT ORA
( save ) ROT ROT STA
-RTN
+JMP2r
@has-nametable ( -- bool )
- BANK-NAMETABLE STH2k #0200 ++ STH2r
+ BANK-NAMETABLE STH2k #0200 ADD2 STH2r
&loop
LDAk #00 = ,&continue JCN
- POP2 POP2 #01 RTN
+ POP2 POP2 #01 JMP2r
&continue
INC2 GTH2k ,&loop JCN
POP2 POP2
#00
-RTN
+JMP2r
( panes )
@@ 915,17 930,17 @@ RTN
;bigpixel-icn .Screen/addr DEO2
#08 #00
&ver
- DUP 4* TOS .zoomview/y1 LDZ2 ++ .Screen/y DEO2
+ DUP 4* #00 SWP .zoomview/y1 LDZ2 ADD2 .Screen/y DEO2
#08 #00
&hor
- DUP 4* TOS .zoomview/x1 LDZ2 ++ .Screen/x DEO2
+ DUP 4* #00 SWP .zoomview/x1 LDZ2 ADD2 .Screen/x DEO2
( get pixel )
- GET-ITER
+ OVR2 NIP OVR SWP
( ch 1 )
- TOS .settings/focus LDZ2 ++ [ STH2k ] LDA
+ #00 SWP .settings/focus LDZ2 ADD2 [ STH2k ] LDA
SWP [ STHk ] #07 SWP - SFT #01 AND
( ch2 )
- [ STHr ] [ STH2r ] #0008 ++ LDA SWP
+ [ STHr ] [ STH2r ] #0008 ADD2 LDA SWP
#07 SWP - SFT #01 AND
2* +
.Screen/sprite DEO
@@ 937,15 952,15 @@ RTN
.zoomview-frame #03 ;line-rect JSR2
( label )
- .zoomview/y1 LDZ2 #0021 ++ .Screen/y DEO2
+ .zoomview/y1 LDZ2 #0021 ADD2 .Screen/y DEO2
.zoomview/x1 LDZ2 .Screen/x DEO2
;arrow-ver-icns .Screen/addr DEO2
#03 .Screen/sprite DEO
- .Screen/x DEI2k #0008 ++ ROT DEO2
+ .Screen/x DEI2k #0008 ADD2 ROT DEO2
;arrow-hor-icns .Screen/addr DEO2
#03 .Screen/sprite DEO
-RTN
+JMP2r
@draw-preview ( -- )
@@ 953,19 968,19 @@ RTN
.settings/focus LDZ2 STH2k .Screen/addr DEO2
#04 #00
&ver
- DUP 8* TOS .preview/y1 LDZ2 ++ .Screen/y DEO2
+ DUP 8* #00 SWP .preview/y1 LDZ2 ADD2 .Screen/y DEO2
#04 #00
&hor
- DUP 8* TOS .preview/x1 LDZ2 ++ .Screen/x DEO2
+ DUP 8* #00 SWP .preview/x1 LDZ2 ADD2 .Screen/x DEO2
( get x,y )
- GET-ITER
+ OVR2 NIP OVR SWP
( check if within ratio )
.settings/ratio LDZ #0f AND < STH
.settings/ratio LDZ #04 SFT < STHr
- #0101 !! ,&outside JCN
+ #0101 NEQ2 ,&outside JCN
( get tile ) STH2kr .Screen/addr DEO2
( get blending ) .settings/blend LDZ .Screen/sprite DEO
- ( incr ) STH2r #0008 [ .settings/depth LDZ 8* TOS ++ ] ++ STH2
+ ( incr ) STH2r #0008 [ .settings/depth LDZ 8* #00 SWP ADD2 ] ADD2 STH2
,&resume JMP
&outside
;halftone-icn .Screen/addr DEO2
@@ 982,24 997,24 @@ RTN
.preview/y2 LDZ2 INC2 .Screen/y DEO2
.settings/ratio LDZ #03 ;draw-byte JSR2
-RTN
+JMP2r
@draw-colorview ( -- )
.colorview/y2 LDZ2 INC2 .Screen/y DEO2
.colorview/x1 LDZ2 .Screen/x DEO2
- .System/r GET-COLOR #03 ;draw-hex JSR2
- .System/g GET-COLOR #03 ;draw-hex JSR2
- .System/b GET-COLOR #03 ;draw-hex JSR2
+ .System/r ,&get-color JSR #03 ;draw-hex JSR2
+ .System/g ,&get-color JSR #03 ;draw-hex JSR2
+ .System/b ,&get-color JSR #03 ;draw-hex JSR2
.colorview/x1 LDZ2 .colorview/y1 LDZ2
- [ .System/r GET-COLOR ] ,&slider JSR
- .colorview/x1 LDZ2 .colorview/y1 LDZ2 #0008 ++
- [ .System/g GET-COLOR ] ,&slider JSR
- .colorview/x1 LDZ2 .colorview/y1 LDZ2 #0010 ++
- [ .System/b GET-COLOR ] ,&slider JSR
+ [ .System/r ,&get-color JSR ] ,&slider JSR
+ .colorview/x1 LDZ2 .colorview/y1 LDZ2 #0008 ADD2
+ [ .System/g ,&get-color JSR ] ,&slider JSR
+ .colorview/x1 LDZ2 .colorview/y1 LDZ2 #0010 ADD2
+ [ .System/b ,&get-color JSR ] ,&slider JSR
- RTN
+ JMP2r
&slider ( x* y* value -- )
STH
@@ 1007,22 1022,25 @@ RTN
.Screen/x DEO2
#10 #00
&loop
- DUP STHkr > 8* TOS ;slider-icns ++ .Screen/addr DEO2
+ DUP STHkr > 8* #00 SWP ;slider-icns ADD2 .Screen/addr DEO2
#02 .Screen/sprite DEO
.Screen/x DEI2k INC2 INC2 ROT DEO2
INC GTHk ,&loop JCN
POP2
POPr
-RTN
+JMP2r
+ &get-color
+ .settings/color LDZ STHk 2/ + DEI #01 STHr #01 AND - 4* SFT #0f AND
+ JMP2r
@draw-blendview ( -- )
.settings/focus LDZ2 .Screen/addr DEO2
#10 #00
&loop
- DUP 4MOD TOS 8** .blendview/x1 LDZ2 ++ .Screen/x DEO2
- DUP 4/ TOS 8** .blendview/y1 LDZ2 ++ .Screen/y DEO2
+ DUP #03 AND #00 SWP 8** .blendview/x1 LDZ2 ADD2 .Screen/x DEO2
+ DUP 4/ #00 SWP 8** .blendview/y1 LDZ2 ADD2 .Screen/y DEO2
#00 .Screen/sprite DEO
DUP .settings/blend LDZ #b0 AND + .Screen/sprite DEO
INC GTHk ,&loop JCN
@@ 1034,20 1052,20 @@ RTN
( get blending ) .settings/blend LDZ #03 ;draw-byte JSR2
( y )
- .blendview/x1 LDZ2 #0010 ++ .Screen/x DEO2
- .blendview/y1 LDZ2 #0021 ++ .Screen/y DEO2
+ .blendview/x1 LDZ2 #0010 ADD2 .Screen/x DEO2
+ .blendview/y1 LDZ2 #0021 ADD2 .Screen/y DEO2
.settings/blend LDZ #20 AND #00 ! STH
- ;arrow-ver-icns STHkr TOS 8** ++ .Screen/addr DEO2
+ ;arrow-ver-icns STHkr #00 SWP 8** ADD2 .Screen/addr DEO2
#02 STHr - .Screen/sprite DEO
( x )
- .blendview/x1 LDZ2 #0018 ++ .Screen/x DEO2
- .blendview/y1 LDZ2 #0021 ++ .Screen/y DEO2
+ .blendview/x1 LDZ2 #0018 ADD2 .Screen/x DEO2
+ .blendview/y1 LDZ2 #0021 ADD2 .Screen/y DEO2
.settings/blend LDZ #10 AND #00 ! STH
- ;arrow-hor-icns STHkr TOS 8** ++ .Screen/addr DEO2
+ ;arrow-hor-icns STHkr #00 SWP 8** ADD2 .Screen/addr DEO2
#02 STHr - .Screen/sprite DEO
-RTN
+JMP2r
@draw-dataview ( -- )
@@ 1059,39 1077,39 @@ RTN
#04 #00
&loop
.dataview/x1 LDZ2 .Screen/x DEO2
- DUP 2* TOS .settings/focus LDZ2 ++
+ DUP 2* #00 SWP .settings/focus LDZ2 ADD2
( ch1 ) LDA2k #01 ;draw-short JSR2
- .Screen/x DEI2k #0004 ++ ROT DEO2
- ( ch2 ) #0008 ++ LDA2 #02 ;draw-short JSR2
+ .Screen/x DEI2k #0004 ADD2 ROT DEO2
+ ( ch2 ) #0008 ADD2 LDA2 #02 ;draw-short JSR2
( skip line )
- .Screen/y DEI2k #0008 ++ ROT DEO2
+ .Screen/y DEI2k #0008 ADD2 ROT DEO2
INC GTHk ,&loop JCN
POP2
-RTN
+JMP2r
@draw-toolview ( -- )
.toolview/y1 LDZ2 .Screen/y DEO2
( colors )
.toolview/x1 LDZ2 STH2k .Screen/x DEO2
- ;circle-icns [ .settings/color LDZ #01 = TOS 8** ] ++ .Screen/addr DEO2
+ ;circle-icns [ .settings/color LDZ #01 = #00 SWP 8** ] ADD2 .Screen/addr DEO2
#01 .Screen/sprite DEO
- STH2kr #0008 ++ .Screen/x DEO2
- ;circle-icns [ .settings/color LDZ #02 = TOS 8** ] ++ .Screen/addr DEO2
+ STH2kr #0008 ADD2 .Screen/x DEO2
+ ;circle-icns [ .settings/color LDZ #02 = #00 SWP 8** ] ADD2 .Screen/addr DEO2
#02 .Screen/sprite DEO
- STH2kr #0010 ++ .Screen/x DEO2
- ;circle-icns [ .settings/color LDZ #03 = TOS 8** ] ++ .Screen/addr DEO2
+ STH2kr #0010 ADD2 .Screen/x DEO2
+ ;circle-icns [ .settings/color LDZ #03 = #00 SWP 8** ] ADD2 .Screen/addr DEO2
#03 .Screen/sprite DEO
( tools )
- STH2kr #0020 ++ .Screen/x DEO2
+ STH2kr #0020 ADD2 .Screen/x DEO2
;tool-brush .Screen/addr DEO2
#01 [ .settings/tool LDZ #00 = ] + .Screen/sprite DEO
- STH2kr #0029 ++ .Screen/x DEO2
+ STH2kr #0029 ADD2 .Screen/x DEO2
;tool-selector .Screen/addr DEO2
#01 [ .settings/tool LDZ #01 = ] + .Screen/sprite DEO
- STH2r #0030 ++ .Screen/x DEO2
- ;zoom-icns [ .settings/zoom LDZ TOS 8** ++ ] .Screen/addr DEO2
+ STH2r #0030 ADD2 .Screen/x DEO2
+ ;zoom-icns [ .settings/zoom LDZ #00 SWP 8** ADD2 ] .Screen/addr DEO2
#01 [ .settings/tool LDZ #02 = ] + .Screen/sprite DEO
( file i/o )
;draw-state JSR2
@@ 1104,7 1122,7 @@ RTN
( filepath )
#01 ;draw-filepath JSR2
-RTN
+JMP2r
@draw-cursor ( -- )
@@ 1116,10 1134,10 @@ RTN
.Mouse/x DEI2 DUP2 .cursor/x STZ2 .Screen/x DEO2
.Mouse/y DEI2 DUP2 .cursor/y STZ2 .Screen/y DEO2
( draw new cursor )
- ;tool-brush #00 .settings/tool LDZ 8* ++ .Screen/addr DEO2
+ ;tool-brush #00 .settings/tool LDZ 8* ADD2 .Screen/addr DEO2
#42 .Mouse/state DEI #00 ! + .Screen/sprite DEO
-RTN
+JMP2r
@draw-state ( -- )
@@ 1128,22 1146,22 @@ RTN
;save-icn .Screen/addr DEO2
#05 .state/changed LDZ #0a * + .Screen/sprite DEO
-RTN
+JMP2r
@draw-filepath ( color -- )
STH
- .toolview/x1 LDZ2 #0040 ++ .Screen/x DEO2
+ .toolview/x1 LDZ2 #0040 ADD2 .Screen/x DEO2
.toolview/y1 LDZ2 .Screen/y DEO2
;filepath
( scroll )
- DUP2 ;slen JSR2 #0013 >> TOS
- ;filepath ;slen JSR2 #0013 -- ** ++
+ DUP2 ;slen JSR2 #0013 GTH2 #00 SWP
+ ;filepath ;slen JSR2 #0013 -- ** ADD2
STHr ,draw-text JSR
-RTN
+JMP2r
( drawing primitives )
@@ 1156,7 1174,7 @@ RTN
POP2
POPr
-RTN
+JMP2r
@draw-short ( short* color -- )
@@ 1172,11 1190,11 @@ RTN
@draw-char ( char color -- )
- SWP #20 - TOS 8** ;font ++ .Screen/addr DEO2
+ SWP #20 - #00 SWP 8** ;font ADD2 .Screen/addr DEO2
.Screen/sprite DEO
- .Screen/x DEI2k #0008 ++ ROT DEO2
+ .Screen/x DEI2k #0008 ADD2 ROT DEO2
-RTN
+JMP2r
( file )
@@ 1194,7 1212,7 @@ RTN
RESET-STATE
;redraw JSR2
-RTN
+JMP2r
@load-file ( -- )
@@ 1216,7 1234,7 @@ RTN
RESET-STATE
;redraw JSR2
-RTN
+JMP2r
@save-file ( -- )
@@ 1237,7 1255,7 @@ RTN
RESET-STATE
;save-theme JSR2
-RTN
+JMP2r
( theme )
@@ 1246,14 1264,14 @@ RTN
;&path .File/name DEO2
#0006 .File/length DEO2
#fffa .File/load DEO2
- .File/success DEI2 #0006 !! ,&ignore JCN
+ .File/success DEI2 #0006 NEQ2 ,&ignore JCN
#fffa LDA2 .System/r DEO2
#fffc LDA2 .System/g DEO2
#fffe LDA2 .System/b DEO2
&ignore
;redraw JSR2
-RTN
+JMP2r
&path ".theme $1
@save-theme ( -- )
@@ 1265,7 1283,7 @@ RTN
#0006 .File/length DEO2
#fffa .File/save DEO2
-RTN
+JMP2r
( snarf )
@@ 1279,7 1297,7 @@ RTN
&ver
.selection/x2 LDZ INC .selection/x1 LDZ
&hor
- GET-ITER GET-ADDR ;&buf #0010 ;mcpy JSR2
+ OVR2 NIP OVR SWP ;get-tile-addr JSR2 ;&buf #0010 ;mcpy JSR2
;&buf .File/save DEO2
INC GTHk ,&hor JCN
POP2
@@ 1287,7 1305,7 @@ RTN
POP2
;redraw JSR2
-RTN
+JMP2r
&buf $10
@paste-snarf ( -- )
@@ 1298,22 1316,22 @@ RTN
&ver
.selection/x2 LDZ INC .selection/x1 LDZ
&hor
- GET-ITER GET-ADDR .File/load DEO2
+ OVR2 NIP OVR SWP ;get-tile-addr JSR2 .File/load DEO2
INC GTHk ,&hor JCN
POP2
INC GTHk ,&ver JCN
POP2
;redraw JSR2
-RTN
+JMP2r
@cut-snarf ( -- )
;copy-snarf JSR2
;op-erase ;run-selection JSR2
- RESET-SELECTION
+ .selection/x1 LDZ2 .selection/x2 STZ2
-RTN
+JMP2r
( generics )
@@ 1327,12 1345,12 @@ RTN
( x > rect.x2 ) DUP2 STHkr #04 ADD LDZ2 GTH2 ,&skip JCN
POP2 POP2 POPr
#01
-RTN
+JMP2r
&skip
POP2 POP2 POPr
#00
-RTN
+JMP2r
@line-rect ( rect color -- )
@@ 1364,7 1382,7 @@ RTN
.Screen/y DEO2
STHr .Screen/pixel DEO
-RTN
+JMP2r
@line-hor-dashed ( x0* x1* y* color -- )
@@ 1375,7 1393,7 @@ RTN
INC2 INC2 GTH2k ,&loop JCN
POP2 POP2 POPr
-RTN
+JMP2r
@line-ver-dashed ( x* y0* y1* color -- )
@@ 1386,31 1404,31 @@ RTN
INC2 INC2 GTH2k ,&loop JCN
POP2 POP2 POPr
-RTN
+JMP2r
( memory generics )
@mclr ( addr* len* -- )
- OVR2 ++ SWP2
+ OVR2 ADD2 SWP2
&loop
STH2k #00 STH2r STA
INC2 GTH2k ,&loop JCN
POP2 POP2
-RTN
+JMP2r
@mcpy ( src* dst* len* -- )
SWP2 STH2
- OVR2 ++ SWP2
+ OVR2 ADD2 SWP2
&loop
LDAk STH2kr STA INC2r
INC2 GTH2k ,&loop JCN
POP2 POP2
POP2r
-RTN
+JMP2r
( string generics )
@@ 1418,38 1436,116 @@ RTN
DUP2 ,scap JSR SWP2 --
-RTN
+JMP2r
@scap ( str* -- str-end* )
- LDAk #00 ! JMP RTN
+ LDAk #00 ! JMP JMP2r
&while INC2 LDAk ,&while JCN
-RTN
+JMP2r
@sput ( str* char -- )
ROT ROT ,scap JSR STA
-RTN
+JMP2r
@spop ( str* -- )
LDAk ,&no-null JCN
- POP2 RTN &no-null
- #00 ROT ROT ,scap JSR #0001 -- STA
+ POP2 JMP2r &no-null
+ #00 ROT ROT ,scap JSR #0001 SUB2 STA
-RTN
+JMP2r
+
+@rol ( byte -- byte ) DUP #07 SFT SWP #10 SFT + JMP2r
+@ror ( byte -- byte ) DUP #70 SFT SWP #01 SFT + JMP2r
@print ( short* -- )
&short ( short* -- ) SWP ,&byte JSR
&byte ( byte -- ) DUP #04 SFT ,&char JSR
- &char ( char -- ) #0f AND DUP #09 GTH #27 MUL ADD #30 ADD EMIT
+ &char ( char -- ) #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO
-RTN
+JMP2r
@untitled-txt "untitled.chr $1
@nametable-ext ".tbl $1
-~src/assets.tal
+@tool-brush e0d0 8844 2212 0c00
+@tool-selector 80c0 e0f0 f8e0 1000
+@tool-zoom 3048 8484 4834 0200
+@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 ( 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
+