~rabbits/nasu

421c141530b752e1ee4447f1a1b39245b577a75d — neauoire 1 year, 1 month ago 4d1f677
Improved zoom
1 files changed, 34 insertions(+), 10 deletions(-)

M src/main.tal
M src/main.tal => src/main.tal +34 -10
@@ 57,6 57,7 @@
@selection
	&x1 $1 &y1 $1
	&x2 $1 &y2 $1
	&zx $1 &zy $1 ( zoom )
	&a $1
@frame
	&x1 $2 &y1 $2


@@ 302,7 303,8 @@ BRK

		.Mouse/x DEI2 .tileview/x1 LDZ2 -- 8// NIP
		.Mouse/y DEI2 .tileview/y1 LDZ2 -- 8// NIP
			;set-focus JSR2
			DUP2 8* SWP 8* SWP ;set-selection-zoom JSR2
			;set-selection-from JSR2
		;toggle-zoom JSR2
		;redraw JSR2
		RELEASE-MOUSE


@@ 311,9 313,8 @@ BRK

	&zoomed ( -> )

		.Mouse/x DEI2 .tileview/x1 LDZ2 -- 8//
		.Mouse/y DEI2 .tileview/y1 LDZ2 -- 8//
		GET-POSITION ADD-POSITIONS
		.Mouse/x DEI2 .tileview/x1 LDZ2 -- 8// #00 .selection/zx LDZ ++
		.Mouse/y DEI2 .tileview/y1 LDZ2 -- 8// #00 .selection/zy LDZ ++
		.settings/color LDZ .Mouse/state DEI #01 = * ;put-pixel JSR2
		SET-STATE
		;redraw JSR2


@@ 507,6 508,13 @@ RTN

RTN

@set-selection-zoom ( x y -- )
 
	.selection/zy STZ 
	.selection/zx STZ 

RTN

@set-selection-from ( x y -- )

	DUP .selection/y1 STZ .selection/y2 STZ


@@ 528,6 536,7 @@ RTN

@set-focus ( x y -- )

	( set zoom )
	DUP2
		GET-ADDR .settings/focus STZ2
		#40 SFT + .selection/a STZ


@@ 536,6 545,8 @@ RTN

@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


@@ 556,6 567,15 @@ RTN

RTN

@mod-selection-zoom ( x y -- )

	.selection/zy LDZ + .selection/zy STZ
	.selection/zx LDZ + .selection/zx STZ
	.selection/zx LDZ 8/ .selection/zy LDZ 8/ ;set-selection-from JSR2
	;draw-tileview-zoom JSR2

RTN

@scale-selection ( x y -- )

	.selection/y2 LDZ + 10MOD .selection/y2 STZ


@@ 757,18 777,22 @@ RTN
		#10 #00
		&hor
			DUP 8* TOS .tileview/x1 LDZ2 ++ .Screen/x DEO2
			( get pixel offset ) GET-ITER SWP TOS ROT TOS
			( add focus ) STH2kr SWP2r STH2kr SWP2r ADD-POSITIONS
			;get-pixel JSR2 #00 + .Screen/sprite DEO
			GET-ITER 
			( y ) .selection/zy LDZ + TOS
			( x ) ROT .selection/zx LDZ + TOS SWP2
				;get-pixel JSR2 .Screen/sprite DEO
			INC GTHk ,&hor JCN
		POP2
		INC GTHk ,&ver JCN
	POP2
	POP2r POP2r

	( guides )
	.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
	#00 #08 .selection/zy LDZ - 8MOD2 8** #0001 -- 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 #08 .selection/zx LDZ - 8MOD2 8** #0001 -- 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

RTN