( dev/screen )

%RTN { JMP2r }
%MOD { DUP2 DIV MUL SUB }

( devices )

|00 @System     [ &vector $2 &pad      $6 &r      $2 &g     $2 &b      $2 ]
|20 @Screen     [ &vector $2 &width    $2 &height $2 &pad   $2 &x      $2 &y     $2 &addr $2 &color $1 ]

( variables )

|0000

@center [ &x $2 &y $2 ]

( init )

|0100 ( -> )
	
	( theme ) 
	#0c5f .System/r DEO2
	#022f .System/g DEO2 
	#0da4 .System/b DEO2 

	( find screen center )
	.Screen/width DEI2 #0002 DIV2 .center/x POK2
	.Screen/height DEI2 #0002 DIV2 .center/y POK2

	( draw )
	;draw-sprites JSR2
	
BRK

@draw-sprites ( -- )
	
	;preview_icn .Screen/addr DEO2

	#00 #ff
	&loop
		( move ) OVR #0f AND #40 SFT #02 DIV #00 SWP 
			.center/x PEK2 #0040 SUB2 ADD2 .Screen/x DEO2
		( move ) OVR #f0 AND #02 DIV #00 SWP 
			.center/y PEK2 #0018 SUB2 ADD2 .Screen/y DEO2
		( draw ) OVR .Screen/color DEO
		( incr ) SWP #01 ADD SWP
		DUP2 LTH ,&loop JNZ
	POP2
	
RTN

@preview_icn  [ 183c 66db db66 3c18 0000 183c 3c18 0000 ]