~rabbits/nasu

e8de876760f6189514cdada9b03001a6567dc89d — neauoire 1 year, 9 months ago be2ca8f
Implemented zoom
1 files changed, 50 insertions(+), 20 deletions(-)

M nasu.usm
M nasu.usm => nasu.usm +50 -20
@@ 13,6 13,7 @@
		Zoom
		Draw guides
		Toggle guides
		Toggle zoom icon on click
)

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


@@ 42,7 43,9 @@
%DEBUG2 { .Console/short DEO2 #0a .Console/char DEO }

%BANK { #2000 }
%GET-COLOR { .settings/color LDZ STHk #02 / + DEI #01 STHr #01 AND - #04 * SFT #0f AND }
%GET-COLOR     { .settings/color LDZ STHk #02 / + DEI #01 STHr #01 AND - #04 * SFT #0f AND }
%GET-POSITION  { .settings/focus LDZ2 BANK -- DUP2 #0002 // WIDTH MOD2 SWP2 WIDTH #0002 ** // #0008 ** }
%ADD-POSITIONS { ROT2 ++ ROT2 ROT2 ++ SWP2 }
%RELEASE-MOUSE { #00 .Mouse/state DEO }

%SIZE-TO-RECT {


@@ 59,12 62,12 @@

( devices )

|00 @System     [ &vector $2 &pad     $6 &r $2 &g $2 &b $2 ]
|10 @Console    [ &vector $2 &pad     $6 &char $1 &byte $1 &short $2 &string $2 ]
|20 @Screen     [ &vector $2 &width   $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
|80 @Controller [ &vector $2 &button  $1 &key $1 ]
|90 @Mouse      [ &vector $2 &x       $2 &y $2 &state $1 &chord $1 ]
|a0 @File       [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ]
|00 @System     [ &vector $2 &pad     $6 &r      $2 &g     $2 &b     $2 ]
|10 @Console    [ &vector $2 &pad     $6 &char   $1 &byte  $1 &short $2 &string $2 ]
|20 @Screen     [ &vector $2 &width   $2 &height $2 &pad   $2 &x     $2 &y $2 &addr $2 &color $1 ]
|80 @Controller [ &vector $2 &button  $1 &key    $1 ]
|90 @Mouse      [ &vector $2 &x       $2 &y      $2 &state $1 &chord $1 ]
|a0 @File       [ &vector $2 &success $2 &offset $2 &pad   $2 &name  $2 &length $2 &load $2 &save $2 ]

( variables )



@@ 76,7 79,8 @@
	&blending $1 
	&ratio $1
	&tool $1
	&focus $2 ]
	&focus $2
	&zoom $1 ]

@frame [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 &width $2 &height $2 ]



@@ 239,7 243,6 @@ BRK
	
	DUP #02 > ,&no-color JCN
		DUP #01 + .settings/color STZ
		#00 .settings/tool STZ
		;draw-colorview JSR2
		;draw-toolview JSR2 POP BRK
		&no-color


@@ 248,6 251,11 @@ BRK
		DUP #04 - .settings/tool STZ
		;draw-toolview JSR2 POP BRK
		&no-tool
	DUP #08 ! ,&no-zoom JCN
		.settings/zoom LDZ #00 = .settings/zoom STZ
		;draw-tileview JSR2
		;draw-toolview JSR2
		&no-zoom
	POP
	&end



@@ 472,6 480,8 @@ RTN

@draw-tileview ( -- )
	
	.settings/zoom LDZ ;draw-tileview-zoom JCN2

	#00 VER
	&ver
		OVR DUP #08 * TOS .tileview/y1 LDZ2 ++ .Screen/y DEO2 STH


@@ 495,6 505,29 @@ RTN

RTN

@draw-tileview-zoom ( -- )
	
	( find focus ) GET-POSITION STH2 STH2
	;pixel-icn .Screen/addr DEO2
	#00 VER
	&ver
		OVR #08 * TOS .tileview/y1 LDZ2 ++ .Screen/y DEO2
		#00 HOR
		&hor
			OVR #08 * TOS .tileview/x1 LDZ2 ++ .Screen/x DEO2
			( get pixel offset ) GET-ITERATORS SWP TOS ROT TOS
			( add focus ) STH2kr SWP2r STH2kr SWP2r ADD-POSITIONS
			,get-pixel JSR #20 + .Screen/color DEO
			INCR
			LTHk ,&hor JCN
		POP2
		INCR
		LTHk ,&ver JCN
	POP2
	POP2r POP2r

RTN

@get-pixel ( x* y* -- color )
	
	( channel 1 )


@@ 577,18 610,15 @@ RTN
	;brush-icn .Screen/addr DEO2
	#21 .settings/tool LDZ #00 = + .Screen/color DEO
	.Screen/x DEI2 #0008 ++ .Screen/x DEO2
	;tool_selector .Screen/addr DEO2
	;tool-selector .Screen/addr DEO2
	#21 .settings/tool LDZ #01 = + .Screen/color DEO
	.Screen/x DEI2 #0008 ++ .Screen/x DEO2
	;tool_hand .Screen/addr DEO2
	;tool-hand .Screen/addr DEO2
	#21 .settings/tool LDZ #02 = + .Screen/color DEO
	.Screen/x DEI2 #0008 ++ .Screen/x DEO2
	;tool_eraser .Screen/addr DEO2
	#21 .settings/tool LDZ #03 = + .Screen/color DEO

	( misc )
	.Screen/x DEI2 #0010 ++ .Screen/x DEO2
	;zoom-icns .Screen/addr DEO2
	;zoom-icns [ .settings/zoom LDZ TOS #0008 ** ++ ] .Screen/addr DEO2
	#23 .Screen/color DEO
	.Screen/x DEI2 #0008 ++ .Screen/x DEO2
	;eye-icns .Screen/addr DEO2


@@ 657,7 687,7 @@ RTN
				( incr ) STH2r #0008 [ .settings/depth LDZ #08 * TOS ++ ] ++ STH2
				,&resume JMP
			&outside
			;halftone_icn .Screen/addr DEO2
			;halftone-icn .Screen/addr DEO2
			#23 .Screen/color DEO
			&resume
			( incr ) INCR


@@ 833,10 863,10 @@ RTN
RTN

@brush-icn     8040 e070 381c 0c00
@tool_selector 80c0 e0f0 f8e0 1000
@tool_hand     2020 20b8 7c7c 3838
@tool_eraser   2050 b87c 3e1c 0800
@halftone_icn  aa55 aa55 aa55 aa55
@tool-selector 80c0 e0f0 f8e0 1000
@tool-hand     2020 20b8 7c7c 3838
@halftone-icn  aa55 aa55 aa55 aa55
@pixel-icn     7cfe fefe fefe 7c00
@bigpixel-icn  f0f0 f0f0 0000 0000

@opshift-icn   0010 387c fe10 1000