( controller )

:dev/r fff8 ( const read port )
:dev/w fff9 ( const write port )

;x 2 ;y 2

|0100 @RESET 

	#03 =dev/r ( set dev/read to controller ) 
	#02 =dev/w ( set dev/write to sprite ) 
	#0080 =x #0040 =y ( origin )
	#0101 ,cursor_icn ~x ~y ,putsprite JSR ( draw sprite )

BRK

|0200 @SPRITESHEET

@cursor_icn [ 80c0 e0f0 f8e0 1000 ]

BRK

|c000 @FRAME 

	#05 =dev/r ( set dev/read to mouse ) 

	#04 IOR #01 NEQ ,next0 ROT JMP? POP2
		#00 IOR2 =x #02 IOR2 =y

	@next0

	#03 =dev/r ( set dev/read to controller ) 

	#00 IOR #10 NEQ ,next1 ROT JMP? POP2
		~y #0001 SUB2 =y
	@next1

	#00 IOR #20 NEQ ,next2 ROT JMP? POP2
		~y #0001 ADD2 =y

	@next2
	#00 IOR #40 NEQ ,next3 ROT JMP? POP2
		~x #0001 SUB2 =x

	@next3
	#00 IOR #80 NEQ ,end ROT JMP? POP2
		~x #0001 ADD2 =x

	@end
	( redraw )
	#0101 ,cursor_icn ~x ~y ,putsprite JSR

BRK

@putsprite
	IOW2 ( y short )
	IOW2 ( x short )
	IOW2 ( sprite address )
	IOW2  ( redraw byte )
	RTS

|d000 @ERROR BRK 

|FFFA .RESET .FRAME .ERROR