~rabbits/nasu

be2ca8f3ab86db55f75f86f60a4f31053c75d8f2 — neauoire 1 year, 9 months ago 2b156ad
Added copy brush
1 files changed, 51 insertions(+), 42 deletions(-)

M nasu.usm
M nasu.usm => nasu.usm +51 -42
@@ 2,10 2,11 @@
	app/nasu : spritesheet editor

	arrows - move selection
	ctrl+arrows - change page
	backspace - delete tile
	enter - insert tile
	left-click  - add pixel
	right-click  - remove pixel
	1 2 3  - select brush
	1 2 3  - select color

	TODO:
		Save/load/rename


@@ 152,7 153,11 @@ BRK
			( color ) #02 .settings/color STZ ;draw-toolview JSR2 &no-3
		DUP #34 ! ,&no-4 JCN
			( color ) #03 .settings/color STZ ;draw-toolview JSR2 &no-4
		POP
		DUP #08 ! ,&no-delete JCN
			( delete ) .settings/focus LDZ2 ;op-shift-memory-left JSR2 ;redraw JSR2 &no-delete
		DUP #0d ! ,&no-insert JCN
			( insert ) .settings/focus LDZ2 ;op-shift-memory-right JSR2 ;redraw JSR2 &no-insert
	POP

	( release ) #00 .Controller/key DEO



@@ 169,7 174,7 @@ BRK
		DUP #07 SFT #01 AND #01 ! ,&no-right JCN
			( clamp ) .settings/focus LDZ2 BANK LENGTH #0020 -- ++ >> ,&no-right JCN
			( right ) .settings/focus LDZ2 #0010 ++ .settings/focus STZ2 &no-right
		POP
	POP

	;redraw JSR2 



@@ 182,19 187,17 @@ BRK
	( skip ) .Mouse/state DEI #00 ! #01 JCN [ BRK ]

	.Mouse/x DEI2 .Mouse/y DEI2 .tileview ;within-rect JSR2
		 ;on-touch-tileview JCN2
		;on-touch-tileview JCN2
	.Mouse/x DEI2 .Mouse/y DEI2 .toolview ;within-rect JSR2
		 ;on-touch-toolview JCN2
	.Mouse/x DEI2 .Mouse/y DEI2 .dataview ;within-rect JSR2
		 ;on-touch-dataview JCN2
		;on-touch-toolview JCN2
	.Mouse/x DEI2 .Mouse/y DEI2 .blendview ;within-rect JSR2
		 ;on-touch-blendview JCN2
		;on-touch-blendview JCN2
	.Mouse/x DEI2 .Mouse/y DEI2 .colorview ;within-rect JSR2
		 ;on-touch-colorview JCN2
		;on-touch-colorview JCN2
	.Mouse/x DEI2 .Mouse/y DEI2 .preview ;within-rect JSR2
		 ;on-touch-preview JCN2
		;on-touch-preview JCN2
	.Mouse/x DEI2 .Mouse/y DEI2 .zoomview ;within-rect JSR2
		 ;on-touch-zoomview JCN2
		;on-touch-zoomview JCN2

BRK



@@ 217,20 220,14 @@ BRK
		;get-tile-addr JSR2 .settings/focus STZ2
		;redraw JSR2
		BRK &no-selector
	DUP #02 = .Mouse/state DEI #01 = #0101 !! ,&no-insert JCN
		POP
		;get-tile-addr JSR2
		;shift-memory-right JSR2
		;redraw JSR2
		RELEASE-MOUSE
		BRK &no-insert
	DUP #02 = .Mouse/state DEI #10 = #0101 !! ,&no-delete JCN
	DUP #02 ! ,&no-copy JCN
		POP
		;get-tile-addr JSR2
		;shift-memory-left JSR2
		.settings/focus LDZ2 SWP2
		;op-copy-tile JSR2
		;redraw JSR2
		RELEASE-MOUSE
		BRK &no-delete
		BRK &no-copy
	POP
	POP2 POP2



@@ 258,32 255,26 @@ BRK

BRK

@on-touch-dataview ( -> )
	
	RELEASE-MOUSE

BRK

@on-touch-zoomview ( -> )
	
	.Mouse/y DEI2 .zoomview/y1 LDZ2 -- #0008 // TOB #04 ! ;&no-mod JCN2
		.Mouse/x DEI2 .zoomview/x1 LDZ2 -- #0008 // TOB 
		DUP #00 = .Mouse/state DEI #01 = #0101 !! ,&no-shiftup JCN
			.settings/focus LDZ2 
			DUP2 ;op-shiftup JSR2
			#0008 ++ ;op-shiftup JSR2 &no-shiftup
			DUP2 ;op-shift-tile-up JSR2
			#0008 ++ ;op-shift-tile-up JSR2 &no-shiftup
		DUP #00 = .Mouse/state DEI #10 = #0101 !! ,&no-shiftdown JCN
			.settings/focus LDZ2 
			DUP2 ;op-shiftdown JSR2
			#0008 ++ ;op-shiftdown JSR2 &no-shiftdown
			DUP2 ;op-shift-tile-down JSR2
			#0008 ++ ;op-shift-tile-down JSR2 &no-shiftdown
		DUP #01 = .Mouse/state DEI #01 = #0101 !! ,&no-shiftright JCN
			.settings/focus LDZ2 
			DUP2 ;op-shiftright JSR2
			#0008 ++ ;op-shiftright JSR2 &no-shiftright
			DUP2 ;op-shift-tile-right JSR2
			#0008 ++ ;op-shift-tile-right JSR2 &no-shiftright
		DUP #01 = .Mouse/state DEI #10 = #0101 !! ,&no-shiftleft JCN
			.settings/focus LDZ2 
			DUP2 ;op-shiftleft JSR2
			#0008 ++ ;op-shiftleft JSR2 &no-shiftleft
			DUP2 ;op-shift-tile-left JSR2
			#0008 ++ ;op-shift-tile-left JSR2 &no-shiftleft
		POP
		RELEASE-MOUSE
		,&finish JMP


@@ 367,7 358,9 @@ BRK

BRK

@shift-memory-left ( addr* -- )
( operations )

@op-shift-memory-left ( addr* -- )

	DUP2 LENGTH ++
	&loop


@@ 379,7 372,7 @@ BRK
	
RTN

@shift-memory-right ( addr* -- )
@op-shift-memory-right ( addr* -- )

	DUP2 LENGTH ++ SWP2 #0001 --
	&loop


@@ 391,7 384,7 @@ RTN
	
RTN

@op-shiftup ( addr* -- )
@op-shift-tile-up ( addr* -- )
	
	STH2
	STH2kr LDA


@@ 406,7 399,7 @@ RTN

RTN

@op-shiftdown ( addr* -- )
@op-shift-tile-down ( addr* -- )
	
	STH2
	STH2kr #0007 ++ LDA


@@ 421,7 414,7 @@ RTN

RTN

@op-shiftleft ( addr* -- )
@op-shift-tile-left ( addr* -- )
	
	STH2
	#00 #08


@@ 435,7 428,7 @@ RTN

RTN

@op-shiftright ( addr* -- )
@op-shift-tile-right ( addr* -- )
	
	STH2
	#00 #08


@@ 449,6 442,22 @@ RTN

RTN

@op-copy-tile ( from* to* -- )
	
	STH2 STH2
	#00 #10
	&loop
		( get )
		OVR TOS DUP2 STH2kr ++ LDA 
		( put )
		ROT ROT SWP2r STH2kr SWP2r ++ STA
		INCR
		LTHk ,&loop JCN
	POP2
	POP2r POP2r

RTN

@redraw ( -- )
	
	;draw-toolview JSR2