~rabbits/nasu

3714dabdde870a5e148f71eb618827b1a5dec1cb — neauoire 1 year, 8 months ago d01132a
Added state change
1 files changed, 39 insertions(+), 12 deletions(-)

M nasu.tal
M nasu.tal => nasu.tal +39 -12
@@ 4,10 4,10 @@
	arrows - move selection
	enter     - insert tile
	backspace - delete tile
	left-click  - add pixel
	right-click - remove pixel
	left-click  - add pixel, select tile
	right-click - remove pixel, clone tile
	1 2 3 - select color
	q w e - select tool
	q w - select tool
)

%+  { ADD } %-   { SUB }  %*  { MUL } %/   { DIV }


@@ 44,6 44,9 @@
%ADD-POSITIONS { ROT2 ++ ROT2 ROT2 ++ SWP2 }
%RELEASE-MOUSE { #00 .Mouse/state DEO }

%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 ++
} ( x y w h -- x1 y1 x2 y2 )


@@ 73,6 76,7 @@
	&timer $1
	&trap $1
	&blink $1
	&changed $1

@settings
	&depth $1


@@ 181,9 185,11 @@ BRK
		DUP #34 ! ,&no-4 JCN
			( color ) #03 .settings/color STZ ;draw-toolview JSR2 &no-4
		DUP #08 ! ,&no-delete JCN
			( delete ) .settings/focus LDZ2 ;op-shift-memory-left JSR2 ;redraw JSR2 &no-delete
			( delete ) .settings/focus LDZ2 ;op-shift-memory-left JSR2 
			SET-STATE ;redraw JSR2 &no-delete
		DUP #0d ! ,&no-insert JCN
			( insert ) .settings/focus LDZ2 ;op-shift-memory-right JSR2 ;redraw JSR2 &no-insert
			( insert ) .settings/focus LDZ2 ;op-shift-memory-right JSR2 
			SET-STATE ;redraw JSR2 &no-insert
		DUP #20 ! ,&no-zoom JCN
			( zoom ) .settings/zoom TOGGLE ;redraw JSR2 &no-zoom
		DUP #71 ! ,&no-tool0 JCN


@@ 270,6 276,7 @@ BRK
		#00 .Mouse/state DEI #10 = ,&do-erase-zoom JCN 
			POP .settings/color LDZ &do-erase-zoom 
			;put-pixel JSR2
			SET-STATE
			;redraw JSR2
		BRK
	&no-zoom


@@ 278,12 285,14 @@ BRK
	DUP2 #0001 !! ,&no-brush-mouse1 JCN ( brush default )
		POP2
		.settings/color LDZ ;put-pixel JSR2
		SET-STATE
		;draw-tileview JSR2 
		;draw-preview JSR2
		BRK &no-brush-mouse1
	DUP2 #0010 !! ,&no-brush-mouse2 JCN ( brush erase )
		POP2
		#00 ;put-pixel JSR2
		SET-STATE
		;draw-tileview JSR2 
		;draw-preview JSR2
		BRK &no-brush-mouse2


@@ 295,6 304,7 @@ BRK
	DUP2 #0110 !! ,&no-select-mouse2 JCN ( select copy )
		POP2
		;get-tile-addr JSR2 .settings/focus LDZ2 SWP2 ;op-copy-tile JSR2
		SET-STATE
		;redraw JSR2
		BRK &no-select-mouse2
	POP2


@@ 309,6 319,7 @@ BRK
	
	DUP HOR SWP - #01 ! ,&no-save JCN
		;save-file JSR2
		;draw-state JSR2
		&no-save
	DUP HOR SWP - #03 ! ,&no-load JCN
		;load-file JSR2


@@ 364,19 375,23 @@ BRK
		DUP #00 = .Mouse/state DEI #01 = #0101 !! ,&no-shiftup JCN
			.settings/focus LDZ2 
			DUP2 ;op-shift-tile-up JSR2
			#0008 ++ ;op-shift-tile-up JSR2 &no-shiftup
			#0008 ++ ;op-shift-tile-up JSR2 
			SET-STATE &no-shiftup
		DUP #00 = .Mouse/state DEI #10 = #0101 !! ,&no-shiftdown JCN
			.settings/focus LDZ2 
			DUP2 ;op-shift-tile-down JSR2
			#0008 ++ ;op-shift-tile-down JSR2 &no-shiftdown
			#0008 ++ ;op-shift-tile-down JSR2 
			SET-STATE &no-shiftdown
		DUP #01 = .Mouse/state DEI #01 = #0101 !! ,&no-shiftright JCN
			.settings/focus LDZ2 
			DUP2 ;op-shift-tile-right JSR2
			#0008 ++ ;op-shift-tile-right JSR2 &no-shiftright
			#0008 ++ ;op-shift-tile-right JSR2 
			SET-STATE &no-shiftright
		DUP #01 = .Mouse/state DEI #10 = #0101 !! ,&no-shiftleft JCN
			.settings/focus LDZ2 
			DUP2 ;op-shift-tile-left JSR2
			#0008 ++ ;op-shift-tile-left JSR2 &no-shiftleft
			#0008 ++ ;op-shift-tile-left JSR2 
			SET-STATE &no-shiftleft
		POP
		RELEASE-MOUSE
		,&finish JMP


@@ 394,6 409,7 @@ BRK
		STHkr #00 ;toggle-pixel JSR2
	#0008 ++ 
		STHr #01 ;toggle-pixel JSR2
	SET-STATE

	&finish



@@ 754,9 770,8 @@ RTN
	#21 .settings/zoom LDZ + .Screen/color DEO

	( file i/o )
	.toolview/x2 LDZ2 #0008 -- .Screen/x DEO2
	;save-icn .Screen/addr DEO2
	#21 .Screen/color DEO
	,draw-state JSR

	.Screen/x DEI2 #0010 -- .Screen/x DEO2
	;load-icn .Screen/addr DEO2
	#21 .Screen/color DEO


@@ 769,6 784,15 @@ RTN

RTN

@draw-state ( -- )
	
	.toolview/x2 LDZ2 #0008 -- .Screen/x DEO2
	.toolview/y1 LDZ2 .Screen/y DEO2
	;save-icn .Screen/addr DEO2
	#25 .state/changed LDZ #0a * + .Screen/color DEO

RTN

@draw-blendview ( -- )
	
	( value )


@@ 1036,6 1060,7 @@ RTN
		LTHk ,&loop JCN
	.path/length STZ POP 
	POP2r
	RESET-STATE

RTN



@@ 1045,6 1070,7 @@ RTN
	;path/name .File/name DEO2 
	#2000 .File/length DEO2 
	BANK .File/load DEO2
	RESET-STATE

RTN



@@ 1053,6 1079,7 @@ RTN
	;path/name .File/name DEO2 
	#2000 .File/length DEO2 
	BANK .File/save DEO2
	RESET-STATE

RTN