~rabbits/nasu

2a81b588fff8b0567430c2a287f66103d46a4581 — neauoire 1 year, 3 months ago 5891f9d
Minor optimizations
1 files changed, 53 insertions(+), 36 deletions(-)

M src/main.tal
M src/main.tal => src/main.tal +53 -36
@@ 62,6 62,9 @@
%ROL { DUP #07 SFT SWP #10 SFT + }
%ROR { DUP #70 SFT SWP #01 SFT + }

%AUTO-X { #01 .Screen/auto DEO }
%AUTO-NONE { #00 .Screen/auto DEO }

( defines )

%HOR    { #10 }    %VER    { #10 } 


@@ 107,7 110,7 @@

|00 @System     [ &vector $2 &pad     $6 &r      $2 &g     $2 &b     $2 ]
|10 @Console    [ &vector $2 &read    $1 &pad    $5 &write $1 ]
|20 @Screen     [ &vector $2 &width   $2 &height $2 &pad   $2 &x     $2 &y $2 &addr $2 &pixel $1 &sprite $1 ]
|20 @Screen     [ &vector $2 &width   $2 &height $2 &auto $1 &pad   $1 &x     $2 &y $2 &addr $2 &pixel $1 &sprite $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 ]


@@ 121,12 124,13 @@
@settings
	&depth $1 &color $1 &blend $1 
	&ratio $1 &tool $1 &focus $2 
	&zoom $1
	&zoom $1 &brush $1
@cursor
	&x $2 &y $2 &last $1
@selection 
	&x1 $1 &y1 $1 
	&x2 $1 &y2 $1 
	&a $1
@path 
	&length $1 &name $20
@frame 


@@ 143,8 147,7 @@
@zoomview  [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
@tileview  
	&x1 $2 &y1 $2 
	&x2 $2 &y2 $2 
	&width $2 &height $2
	&x2 $2 &y2 $2
@nametable
	&x $2 &y $2 
	&x2 $2 &y2 $2


@@ 173,16 176,14 @@

	( set defaults )
	#0100 .frame/width STZ2
	#0080 #0040 ++ .frame/height STZ2
	#00c0 .frame/height STZ2
	#01 .settings/depth STZ
	#01 .settings/color STZ
	#81 .settings/blend STZ
	#32 .settings/ratio STZ
	#01 .settings/tool STZ
	BANK-SPRITESHEET .settings/focus STZ2

	#0100 .tileview/width STZ2
	#0080 .tileview/height STZ2
	#00 .settings/brush STZ
	#0000 ;select JSR2

	.Screen/width DEI2 #01 SFT2 .frame/width LDZ2 #01 SFT2 --
	.Screen/height DEI2 #01 SFT2 .frame/height LDZ2 #01 SFT2 --


@@ 442,7 443,7 @@ BRK
		BRK &no-brush-mouse2
	DUP2 #0101 !! ,&no-select-mouse1 JCN ( select default )
		POP2
		;get-tile-addr JSR2 .settings/focus STZ2
		;select JSR2
		;redraw JSR2
		BRK &no-select-mouse1
	DUP2 #0110 !! ,&no-select-mouse2 JCN ( select copy )


@@ 467,7 468,7 @@ BRK
				.Mouse/y DEI2 .tileview/y1 LDZ2 -- 8// NIP 
					DUP .selection/y1 STZ .selection/y2 STZ
				;clamp-selection JSR2 
				.selection LDZ2 GET-ADDR .settings/focus STZ2
				.selection LDZ2 ;select JSR2
				;redraw JSR2
				,&end JMP 
				&no-down


@@ 503,18 504,17 @@ BRK
	( skip ) .Mouse/state DEI #00 ! BRK?

	( get touch tile )
	
	.Mouse/y DEI2 .nametable/y LDZ2 -- 8// 10** 
	.Mouse/x DEI2 .nametable/x LDZ2 -- 8// ++ STH2

	( look for changes )

	( sprite ) STH2kr BANK-NAMETABLE ++ LDA
	( color ) STH2kr BANK-COLOR ++ LDA
	( sprite ) .settings/focus LDZ2 BANK-SPRITESHEET -- 10// NIP 
	( color ) .settings/blend LDZ 
	
	( stop ) NEQ2 ,&continue JCN POP2r BRK &continue
	STH2kr BANK-NAMETABLE ++ LDA
	.settings/focus LDZ2 BANK-SPRITESHEET -- 10// NIP 
	STH2kr BANK-COLOR ++ LDA
	.settings/blend LDZ 
		!! ,&continue JCN
			POP2r BRK 
			&continue

	( set sprite )
	.settings/focus LDZ2 BANK-SPRITESHEET -- 10// NIP 


@@ 525,6 525,7 @@ BRK
		STH2r BANK-COLOR ++ STA

	;draw-nametable JSR2

	SET-STATE

BRK


@@ 706,6 707,14 @@ BRK

( operations )

@select ( x y -- )

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

RTN

@mod-selection ( x y -- )

	DUP


@@ 722,7 731,8 @@ BRK
		.selection/y1 LDZ .selection/y2 STZ
		&no-y
	( focus )
	.selection LDZ2 GET-ADDR .settings/focus STZ2
	.selection LDZ2 ;select JSR2
	
	;redraw JSR2

RTN


@@ 740,7 750,7 @@ RTN
		.selection/y1 LDZ .selection/y2 STZ
		&no-y
	( focus )
	.selection LDZ2 GET-ADDR .settings/focus STZ2
	.selection LDZ2 ;select JSR2
	;redraw JSR2

RTN


@@ 906,20 916,21 @@ RTN

	.settings/zoom LDZ ;draw-tileview-zoom JCN2

	VER #00
	AUTO-X
	#1000
	&ver
		DUP TOS 8** .tileview/y1 LDZ2 ++ .Screen/y DEO2
		HOR #00
		.tileview/x1 LDZ2 .Screen/x DEO2
		#1000
		&hor
			DUP TOS 8** .tileview/x1 LDZ2 ++ .Screen/x DEO2
			GET-ITER
				DUP2 GET-ADDR .Screen/addr DEO2
			#0d00 SWP2 ;is-selected JSR2 SWP? POP
			#81 + .Screen/sprite DEO
				;is-selected JSR2 #0d * #81 + .Screen/sprite DEO
			INC GTHk ,&hor JCN
		POP2
		INC GTHk ,&ver JCN
	POP2
	AUTO-NONE

	.workspace-frame #03 ;line-rect JSR2



@@ 952,15 963,21 @@ RTN

@draw-nametable ( -- )

	#00
	&loop
		DUP TOS 
			DUP2 10MOD2 8** .nametable/x LDZ2 ++ .Screen/x DEO2
			DUP2 10// 8** .nametable/y LDZ2 ++ .Screen/y DEO2
			DUP2 BANK-NAMETABLE ++ LDA TOS 10** BANK-SPRITESHEET ++ .Screen/addr DEO2
			BANK-COLOR ++ LDA .Screen/sprite DEO
		INC DUP ,&loop JCN
	POP
	AUTO-X
	#1000
	&ver
		DUP TOS 8** .nametable/y LDZ2 ++ .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
			INC GTHk ,&hor JCN
		POP2
		INC GTHk ,&ver JCN
	POP2
	AUTO-NONE

RTN



@@ 1192,7 1209,7 @@ RTN
	( position )
	.dataview/x1 LDZ2 .Screen/x DEO2
	.dataview/y2 LDZ2 INC2 .Screen/y DEO2
	.settings/focus LDZ2 BANK-SPRITESHEET -- #03 ;draw-short JSR2
	.selection/a LDZ #03 ;draw-byte JSR2

	( depth1 )
	#04 #00