~rabbits/uxn-playdate

eef020c697fcc72a47a1e7411cdd55c129758215 — neauoire 5 months ago ff99984
Passing controller test
6 files changed, 390 insertions(+), 18 deletions(-)

A build.sh
D etc/controller.rom
A etc/dvd.tal
A etc/format-c.tal
A etc/screen.tal
M src/main.c
A build.sh => build.sh +11 -0
@@ 0,0 1,11 @@
#!/bin/sh -e

TARGET=etc/controller.tal

rm -rf bin
mkdir bin

uxnasm $TARGET bin/program.rom
uxnasm etc/format-c.tal bin/format-c.rom
uxncli bin/format-c.rom bin/program.rom


D etc/controller.rom => etc/controller.rom +0 -0
A etc/dvd.tal => etc/dvd.tal +64 -0
@@ 0,0 1,64 @@
( DVD Bounce )

|00 @System &vector $2 &wst $1 &rst $1 &eaddr $2 &ecode $1 &pad $1 &r $2 &g $2 &b $2 &debug $1 &halt $1
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1

|0000

@dvd &x $2 &y $2 &dx $1 &dy $1

|0100 ( -> )
	
	( theme )
	#4cfd .System/r DEO2
	#4cf3 .System/g DEO2
	#dcf2 .System/b DEO2
	( vectors )
	;on-frame .Screen/vector DEO2
	( starting position )
	.Screen/width DEI2 #01 SFT2 .dvd/x STZ2
	.Screen/height DEI2 #01 SFT2 .dvd/y STZ2
	( set collisions )
	.Screen/width DEI2 #0020 SUB2 ;on-frame/hit-hor STA2
	.Screen/height DEI2 #0010 SUB2 ;on-frame/hit-ver STA2
	( drawing mode )
	#36 .Screen/auto DEO
	#01 ,draw-dvd JSR
	
BRK

@on-frame ( -> )

	#00 ,draw-dvd JSR
	( x )
	.dvd/x LDZ2
		STH2k #0000 EQU2 ,&flip-x JCN
		STH2kr [ LIT2 &hit-hor $2 ] EQU2 ,&flip-x JCN
	&no-x
	STH2r [ #00 .dvd/dx LDZ ] DUP2 ADD2 ADD2 #ffff ADD2 .dvd/x STZ2
	( y )
	.dvd/y LDZ2
		STH2k #0000 EQU2 ,&flip-y JCN
		STH2kr [ LIT2 &hit-ver $2 ] EQU2 ,&flip-y JCN
	&no-y
	STH2r [ #00 .dvd/dy LDZ ] DUP2 ADD2 ADD2 #ffff ADD2 .dvd/y STZ2
	#01 ,draw-dvd JSR

BRK
	&flip-x .dvd/dx LDZk #00 EQU SWP STZ ,&no-x JMP
	&flip-y .dvd/dy LDZk #00 EQU SWP STZ ,&no-y JMP

@draw-dvd ( color -- )
	
	;dvd_icn .Screen/addr DEO2
	.dvd/x LDZ2 .Screen/x DEO2
	.dvd/y LDZ2 .Screen/y DEO2
	.Screen/sprite DEOk DEO

JMP2r

@dvd_icn ( 4 x 2 )
	001f 3f38 3838 787f 00fe fe7e 7777 e3c3
	000f 1f3b 7b77 e7c7 00fc fe8f 8707 0efc
	7f00 000f ff7f 0700 0301 00ff f0f8 ff00
	8700 00ff 7f7f ff00 f000 00e0 fcfc 8000

A etc/format-c.tal => etc/format-c.tal +92 -0
@@ 0,0 1,92 @@
( usage: uxncli format-js.rom file.bin )

|10 @Console &vector $2 &read $1 &pad $5 &write $1 &error $1
|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2

|0000

	@src $40

|0100 ( -> )

	;on-console .Console/vector DEO2

BRK

@on-console ( -> )

	;src STH2
	( read input )
	.Console/read DEI
	DUP #20 LTH OVR #7f GTH ORA ,&end JCN
	STH2kr ;slen JSR2 #003f GTH2 ,&end JCN
		STH2kr ;scap JSR2 STA POP2r BRK
		&end
	POP
	STH2r ,print-program JSR
	#010f DEO

BRK

@print-program ( src* -- )

	.File/name DEO2
	#0001 .File/length DEO2
	;header-txt ;print-str JSR2
	LIT2r 0000
	&stream
		#00 ,&buf STR
		;&buf .File/read DEO2
		.File/success DEI2 #0000 EQU2 ,&end JCN
		LIT "0 #18 DEO 
		LIT "x #18 DEO
		[ LIT &buf $1 ] ,print/byte JSR 
		LIT ", #18 DEO 
		#2018 DEO
		INC2r
		( linebreak )
		STH2kr #000f AND2 ORA ,&no-lb JCN
			#0a18 DEO #0918 DEO
			&no-lb
		.File/success DEI2 ORA ,&stream JCN
	&end
	POP2r
	#0a18 DEO
	;footer-txt ;print-str JSR2
	#0a18 DEO

JMP2r

@slen ( str* -- len* )

	DUP2 ,scap JSR SWP2 SUB2

JMP2r

@scap ( str* -- end* )

	LDAk #00 NEQ JMP JMP2r
	&while
		INC2 LDAk ,&while JCN

JMP2r

@print ( short* -- )

	SWP ,&byte JSR
	&byte ( byte -- ) DUP #04 SFT ,&char JSR
	&char ( char -- ) #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO

JMP2r

@print-str ( str* -- )

	&while
		LDAk #18 DEO
		INC2 LDAk ,&while JCN
	POP2

JMP2r

@header-txt "unsigned 20 "char 20 "rom[] 20 "= 20 "{ 0a 09 00
@footer-txt "}; 00

A etc/screen.tal => etc/screen.tal +148 -0
@@ 0,0 1,148 @@
( Screen:
	Draws a table of all possible sprite arrangements. )

|00 @System &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1

|0000

@count $2
@center &x $2 &y $2

|0100 ( -> )
	
	( vector )
	;on-frame .Screen/vector DEO2
	( theme )
	#f07f .System/r DEO2
	#f0e0 .System/g DEO2
	#f0c0 .System/b DEO2
	( gba screen size 00f0 x 00a0 )
	( nds screen size 0100 x 00c0 )
	#00f0 .Screen/width DEO2
	#00a0 .Screen/height DEO2
	( find screen center )
	.Screen/width DEI2 #01 SFT2 .center/x STZ2
	.Screen/height DEI2 #01 SFT2 .center/y STZ2
	( draw )
	;draw-sprites JSR2
	;draw-1bpp JSR2
	;draw-2bpp JSR2
	#00 .Screen/auto DEO
	
BRK

@on-frame ( -> )

	#01 .Screen/auto DEO
	.count LDZ2 INC2 [ DUP2 ] .count STZ2
	.center/x LDZ2 #0050 ADD2 .Screen/x DEO2
	.center/y LDZ2 #0048 SUB2 .Screen/y DEO2
	;draw-short JSR2

BRK

@draw-sprites ( -- )
	
	( horizontal )
	.center/x LDZ2 #0060 SUB2 .Screen/x DEO2
	.center/y LDZ2 #0048 SUB2 .Screen/y DEO2
	;font-hex .Screen/addr DEO2
	#f6 .Screen/auto DEO
	#01 .Screen/sprite DEO
	( vertical )
	.center/x LDZ2 #0070 SUB2 .Screen/x DEO2
	.center/y LDZ2 #0038 SUB2 .Screen/y DEO2
	;font-hex .Screen/addr DEO2
	#f5 .Screen/auto DEO
	#01 .Screen/sprite DEO

	#00 .Screen/auto DEO
	( table )
	;preview_icn .Screen/addr DEO2
	#00 #00
	&loop
		( move ) DUP #0f AND #40 SFT #01 SFT #00 SWP
			.center/x LDZ2 #0060 SUB2 ADD2 .Screen/x DEO2
		( move ) DUP #f0 AND #01 SFT #00 SWP
			.center/y LDZ2 #0038 SUB2 ADD2 .Screen/y DEO2
		( draw ) DUP .Screen/sprite DEO
		INC NEQk ,&loop JCN
	POP2
	
JMP2r

@draw-1bpp ( -- )

	#10 #00
	&loop
		( color ) STHk
		( y ) DUP #02 SFT [ #00 SWP ] #40 SFT2
			[ .center/y LDZ2 #0038 SUB2 ADD2 ] STH2
		( x ) DUP #03 AND [ #00 SWP ] #40 SFT2 #0040 ADD2
			[ .center/x LDZ2 #0010 SUB2 ADD2 ]
		STH2r STHr #00 ,draw-circle JSR
		INC GTHk ,&loop JCN
	POP2
	
JMP2r

@draw-2bpp ( -- )

	#10 #00
	&loop
		( color ) STHk
		( y ) DUP #02 SFT [ #00 SWP ] #40 SFT2
			[ .center/y LDZ2 #0008 ADD2 ADD2 ] STH2
		( x ) DUP #03 AND [ #00 SWP ] #40 SFT2 #0040 ADD2
			[ .center/x LDZ2 #0010 SUB2 ADD2 ]
		STH2r STHr #80 ,draw-circle JSR
		INC GTHk ,&loop JCN
	POP2
	
JMP2r

@draw-circle ( x* y* color depth -- )
	
	ADD STH
	;preview_icn .Screen/addr DEO2
	.Screen/y DEO2
	.Screen/x DEO2
	#01 .Screen/auto DEO
	STHr .Screen/sprite DEOk
	#02 .Screen/auto DEO
	SWP #10 ADD SWP DEOk
	.Screen/x DEI2k #0008 SUB2 ROT DEO2
	#01 .Screen/auto DEO
	SWP #10 ADD SWP DEOk
	SWP #10 ADD SWP DEO

JMP2r

@draw-short ( short* -- )

	SWP ,draw-byte JSR

@draw-byte ( byte -- )

	DUP #04 SFT ,draw-hex JSR #0f AND

@draw-hex ( char -- )

	#00 SWP #30 SFT2 ;font-hex ADD2 .Screen/addr DEO2
	#01 .Screen/sprite DEO

JMP2r

@preview_icn
	0f38 675f dfbf bfbf 0007 1820 2344 4848

@font-hex
	007c 8282 8282 827c 0030 1010 1010 1010
	007c 8202 7c80 80fe 007c 8202 1c02 827c
	000c 1424 4484 fe04 00fe 8080 7c02 827c
	007c 8280 fc82 827c 007c 8202 1e02 0202
	007c 8282 7c82 827c 007c 8282 7e02 827c
	007c 8202 7e82 827e 00fc 8282 fc82 82fc
	007c 8280 8080 827c 00fc 8282 8282 82fc
	007c 8280 f080 827c 007c 8280 f080 8080

M src/main.c => src/main.c +75 -18
@@ 9,23 9,58 @@ Uxn u;
Ppu ppu;

unsigned char rom[] = {
	0xa0, 0x4c, 0xfd, 0x80, 0x08, 0x37, 0xa0, 0x4c, 0xf3, 0x80, 0x0a, 0x37, 0xa0, 0xdc, 0xf2, 0x80, 
	0x0c, 0x37, 0xa0, 0x01, 0x4b, 0x80, 0x20, 0x37, 0x80, 0x22, 0x36, 0x80, 0x01, 0x3f, 0x80, 0x00, 
	0x31, 0x80, 0x24, 0x36, 0x80, 0x01, 0x3f, 0x80, 0x02, 0x31, 0x80, 0x22, 0x36, 0xa0, 0x00, 0x20, 
	0x39, 0xa0, 0x01, 0x5d, 0x35, 0x80, 0x24, 0x36, 0xa0, 0x00, 0x10, 0x39, 0xa0, 0x01, 0x80, 0x35, 
	0x80, 0x36, 0x80, 0x26, 0x17, 0x80, 0x01, 0x80, 0x68, 0x0e, 0x00, 0x80, 0x00, 0x80, 0x62, 0x0e, 
	0x80, 0x00, 0x30, 0xaf, 0xa0, 0x00, 0x00, 0x28, 0x80, 0x41, 0x0d, 0xef, 0xa0, 0x00, 0x00, 0x28, 
	0x80, 0x39, 0x0d, 0x6f, 0x80, 0x00, 0x80, 0x04, 0x10, 0x26, 0x38, 0x38, 0xa0, 0xff, 0xff, 0x38, 
	0x80, 0x00, 0x31, 0x80, 0x02, 0x30, 0xaf, 0xa0, 0x00, 0x00, 0x28, 0x80, 0x29, 0x0d, 0xef, 0xa0, 
	0x00, 0x00, 0x28, 0x80, 0x21, 0x0d, 0x6f, 0x80, 0x00, 0x80, 0x05, 0x10, 0x26, 0x38, 0x38, 0xa0, 
	0xff, 0xff, 0x38, 0x80, 0x02, 0x31, 0x80, 0x01, 0x80, 0x17, 0x0e, 0x00, 0x80, 0x04, 0x90, 0x80, 
	0x00, 0x08, 0x04, 0x11, 0x80, 0xbc, 0x0c, 0x80, 0x05, 0x90, 0x80, 0x00, 0x08, 0x04, 0x11, 0x80, 
	0xd4, 0x0c, 0xa0, 0x01, 0xc9, 0x80, 0x2c, 0x37, 0x80, 0x00, 0x30, 0x80, 0x28, 0x37, 0x80, 0x02, 
	0x30, 0x80, 0x2a, 0x37, 0x80, 0x2f, 0x97, 0x17, 0x6c, 0x00, 0x1f, 0x3f, 0x38, 0x38, 0x38, 0x78, 
	0x7f, 0x00, 0xfe, 0xfe, 0x7e, 0x77, 0x77, 0xe3, 0xc3, 0x00, 0x0f, 0x1f, 0x3b, 0x7b, 0x77, 0xe7, 
	0xc7, 0x00, 0xfc, 0xfe, 0x8f, 0x87, 0x07, 0x0e, 0xfc, 0x7f, 0x00, 0x00, 0x0f, 0xff, 0x7f, 0x07, 
	0x00, 0x03, 0x01, 0x00, 0xff, 0xf0, 0xf8, 0xff, 0x00, 0x87, 0x00, 0x00, 0xff, 0x7f, 0x7f, 0xff, 
	0x00, 0xf0, 0x00, 0x00, 0xe0, 0xfc, 0xfc, 0x80, 0x00, 
	0xa0, 0x0f, 0xff, 0x80, 0x08, 0x37, 0xa0, 0x0f, 0x0f, 0x80, 0x0a, 0x37, 0xa0, 0x0f, 0x0f, 0x80, 
	0x0c, 0x37, 0x80, 0x22, 0x36, 0x80, 0x01, 0x3f, 0x80, 0x00, 0x31, 0x80, 0x24, 0x36, 0x80, 0x01, 
	0x3f, 0x80, 0x02, 0x31, 0xa0, 0x00, 0x68, 0x80, 0x04, 0x31, 0xa0, 0x00, 0x30, 0x80, 0x06, 0x31, 
	0x80, 0x00, 0x30, 0x80, 0x04, 0x30, 0x80, 0x01, 0x3f, 0x39, 0x80, 0x08, 0x31, 0x80, 0x02, 0x30, 
	0x80, 0x06, 0x30, 0x80, 0x01, 0x3f, 0x39, 0x80, 0x0a, 0x31, 0x80, 0x08, 0x30, 0x80, 0x04, 0x30, 
	0x38, 0x80, 0x0c, 0x31, 0x80, 0x0a, 0x30, 0x80, 0x06, 0x30, 0x38, 0x80, 0x0e, 0x31, 0xa0, 0x01, 
	0x7a, 0x80, 0x80, 0x37, 0x80, 0x08, 0x30, 0x80, 0x0a, 0x30, 0x80, 0x0c, 0x30, 0x80, 0x0e, 0x30, 
	0x80, 0x03, 0xa0, 0x03, 0x22, 0x2e, 0x80, 0x11, 0x0e, 0x00, 0x80, 0x0d, 0x0e, 0x80, 0x82, 0x16, 
	0x80, 0x08, 0x08, 0x0c, 0x00, 0xa0, 0x01, 0x0e, 0x17, 0x00, 0x80, 0x82, 0x16, 0x0f, 0x80, 0x08, 
	0x30, 0xa0, 0x00, 0x10, 0x38, 0x80, 0x28, 0x37, 0x80, 0x0a, 0x30, 0xa0, 0x00, 0x10, 0x38, 0x80, 
	0x2a, 0x37, 0xa0, 0x03, 0x8e, 0x80, 0x2c, 0x37, 0x80, 0x03, 0xcf, 0x80, 0x04, 0x1f, 0x80, 0x01, 
	0x1c, 0x19, 0x80, 0x2f, 0x17, 0x80, 0x2a, 0x36, 0xa0, 0x00, 0x10, 0x38, 0x80, 0x2a, 0x37, 0xa0, 
	0x03, 0x96, 0x80, 0x2c, 0x37, 0x80, 0x03, 0xcf, 0x80, 0x05, 0x1f, 0x80, 0x01, 0x1c, 0x19, 0x80, 
	0x2f, 0x17, 0x80, 0x2a, 0x36, 0xa0, 0x00, 0x08, 0x39, 0x80, 0x2a, 0x37, 0x80, 0x28, 0x36, 0xa0, 
	0x00, 0x08, 0x39, 0x80, 0x28, 0x37, 0xa0, 0x03, 0x9e, 0x80, 0x2c, 0x37, 0x80, 0x03, 0xcf, 0x80, 
	0x06, 0x1f, 0x80, 0x01, 0x1c, 0x19, 0x80, 0x2f, 0x17, 0x80, 0x28, 0x36, 0xa0, 0x00, 0x10, 0x38, 
	0x80, 0x28, 0x37, 0xa0, 0x03, 0xa6, 0x80, 0x2c, 0x37, 0x80, 0x03, 0xcf, 0x80, 0x07, 0x1f, 0x80, 
	0x01, 0x1c, 0x19, 0x80, 0x2f, 0x17, 0x80, 0x28, 0x36, 0xa0, 0x00, 0x08, 0x39, 0x80, 0x28, 0x37, 
	0xa0, 0x03, 0x86, 0x80, 0x2c, 0x37, 0x80, 0x03, 0x80, 0x2f, 0x17, 0x80, 0x02, 0x30, 0xa0, 0x00, 
	0x09, 0x38, 0x80, 0x2a, 0x37, 0x80, 0x00, 0x30, 0xa0, 0x00, 0x09, 0x39, 0x80, 0x28, 0x37, 0xa0, 
	0x03, 0xae, 0x80, 0x2c, 0x37, 0x80, 0x03, 0xcf, 0x80, 0x03, 0x1f, 0x80, 0x01, 0x1c, 0x19, 0x80, 
	0x2f, 0x17, 0x80, 0x00, 0x30, 0xa0, 0x00, 0x04, 0x38, 0x80, 0x28, 0x37, 0xa0, 0x03, 0xae, 0x80, 
	0x2c, 0x37, 0x80, 0x03, 0xcf, 0x80, 0x02, 0x1f, 0x80, 0x01, 0x1c, 0x19, 0x80, 0x2f, 0x17, 0x80, 
	0x02, 0x30, 0x80, 0x2a, 0x37, 0x80, 0x00, 0x30, 0xa0, 0x00, 0x18, 0x38, 0x80, 0x28, 0x37, 0xa0, 
	0x03, 0xb6, 0x80, 0x2c, 0x37, 0x80, 0x03, 0xcf, 0x80, 0x01, 0x1f, 0x80, 0x01, 0x1c, 0x19, 0x80, 
	0x2f, 0x17, 0x80, 0x2a, 0x36, 0xa0, 0x00, 0x0a, 0x38, 0x80, 0x2a, 0x37, 0xa0, 0x04, 0x16, 0x80, 
	0x2c, 0x37, 0x80, 0x03, 0x80, 0x2f, 0x17, 0x80, 0x02, 0x30, 0x80, 0x2a, 0x37, 0x80, 0x00, 0x30, 
	0xa0, 0x00, 0x24, 0x38, 0x80, 0x28, 0x37, 0xa0, 0x03, 0xb6, 0x80, 0x2c, 0x37, 0x80, 0x03, 0x4f, 
	0x80, 0x01, 0x1c, 0x19, 0x80, 0x2f, 0x17, 0x80, 0x2a, 0x36, 0xa0, 0x00, 0x0a, 0x38, 0x80, 0x2a, 
	0x37, 0xa0, 0x04, 0x0e, 0x80, 0x2c, 0x37, 0x80, 0x03, 0x80, 0x2f, 0x17, 0x80, 0x00, 0x30, 0xa0, 
	0x00, 0x10, 0x39, 0x80, 0x28, 0x37, 0x80, 0x02, 0x30, 0xa0, 0x00, 0x10, 0x39, 0x80, 0x2a, 0x37, 
	0x80, 0x01, 0x80, 0x26, 0x17, 0x80, 0x82, 0x36, 0x80, 0x06, 0x0e, 0x80, 0x00, 0x80, 0x26, 0x17, 
	0x6c, 0x04, 0x80, 0x00, 0x0e, 0x06, 0x80, 0x04, 0x1f, 0x80, 0x00, 0x0e, 0x80, 0x00, 0x04, 0x80, 
	0x0f, 0x1c, 0x80, 0x30, 0x3f, 0xa0, 0x03, 0xbe, 0x38, 0x80, 0x2c, 0x37, 0x80, 0x03, 0x80, 0x2f, 
	0x17, 0x6c, 0x0f, 0x26, 0x80, 0x3c, 0x33, 0x80, 0x2b, 0x33, 0x26, 0x80, 0x49, 0x33, 0x80, 0x0f, 
	0x33, 0x26, 0x80, 0x31, 0x33, 0x80, 0x13, 0x33, 0x26, 0x80, 0x31, 0x33, 0x80, 0x05, 0x33, 0xa0, 
	0x00, 0x00, 0x21, 0xa0, 0x00, 0x00, 0x26, 0x80, 0x28, 0x37, 0xa0, 0x00, 0x00, 0x80, 0x2a, 0x37, 
	0xcf, 0x80, 0x2e, 0x97, 0xa0, 0x00, 0x00, 0x80, 0x2a, 0x37, 0x17, 0x21, 0xaa, 0x80, 0xe6, 0x0d, 
	0x22, 0x22, 0xa0, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x26, 0x80, 0x2a, 0x37, 0xa0, 0x00, 0x00, 0x80, 
	0x28, 0x37, 0xcf, 0x80, 0x2e, 0x97, 0xa0, 0x00, 0x00, 0x80, 0x28, 0x37, 0x17, 0x21, 0xaa, 0x80, 
	0xe6, 0x0d, 0x22, 0x22, 0x42, 0x6c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7e, 0xff, 
	0xe7, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc3, 0xe7, 0xff, 0x7e, 0x7f, 0xff, 
	0xef, 0xcf, 0xcf, 0xef, 0xff, 0x7f, 0xfe, 0xff, 0xf7, 0xf3, 0xf3, 0xf7, 0xff, 0xfe, 0x00, 0x00, 
	0x7e, 0xff, 0xff, 0x7e, 0x00, 0x00, 0x3c, 0x7e, 0xff, 0xff, 0xff, 0xff, 0x7e, 0x3c, 0x00, 0x7c, 
	0x82, 0x82, 0x82, 0x82, 0x82, 0x7c, 0x00, 0x30, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x7c, 
	0x82, 0x02, 0x7c, 0x80, 0x80, 0xfe, 0x00, 0x7c, 0x82, 0x02, 0x1c, 0x02, 0x82, 0x7c, 0x00, 0x0c, 
	0x14, 0x24, 0x44, 0x84, 0xfe, 0x04, 0x00, 0xfe, 0x80, 0x80, 0x7c, 0x02, 0x82, 0x7c, 0x00, 0x7c, 
	0x82, 0x80, 0xfc, 0x82, 0x82, 0x7c, 0x00, 0xfe, 0x02, 0x02, 0x04, 0x08, 0x10, 0x10, 0x00, 0x7c, 
	0x82, 0x82, 0x7c, 0x82, 0x82, 0x7c, 0x00, 0x7c, 0x82, 0x82, 0x7e, 0x02, 0x82, 0x7c, 0x00, 0x7c, 
	0x82, 0x02, 0x7e, 0x82, 0x82, 0x7e, 0x00, 0xfc, 0x82, 0x82, 0xfc, 0x82, 0x82, 0xfc, 0x00, 0x7c, 
	0x82, 0x80, 0x80, 0x80, 0x82, 0x7c, 0x00, 0xfc, 0x82, 0x82, 0x82, 0x82, 0x82, 0xfc, 0x00, 0xfe, 
	0x80, 0x80, 0xfe, 0x80, 0x80, 0xfe, 0x00, 0xfe, 0x80, 0x80, 0xf0, 0x80, 0x80, 0x80, 
};

/* Varvara */


@@ 195,6 230,27 @@ emu_start (void){

/* Misc */

void
read_buttons(void)
{
	PDButtons pushed, current, released;
	pd->system->getButtonState(&current, &pushed, &released);
	if(pushed || released){
		Uint8 state = 0x00;
		state |= !!(current & 0x20);
		state |= !!(current & 0x10) << 0x1;
		state |= !!(current & 0x40) << 0x2;
		state |= !!(current & 0x80) << 0x3;
		state |= !!(current & 0x04) << 0x4;
		state |= !!(current & 0x08) << 0x5;
		state |= !!(current & 0x01) << 0x6;
		state |= !!(current & 0x02) << 0x7;
		u.dev[0x82] = state;
		pd->system->logToConsole("%02x -> %02x", current, state);
		uxn_eval(&u, GETVEC(&u.dev[0x80]));
	}
}

static int update(void* userdata);
const char* fontpath = "/System/Fonts/Asheville-Sans-14-Bold.pft";
LCDFont* font = NULL;


@@ 211,9 267,9 @@ int eventHandler(PlaydateAPI* playdate, PDSystemEvent event, uint32_t arg)
	{
		pd = playdate;
		pd->display->setRefreshRate(60);
		pd->graphics->clear(kColorBlack);
		if(!emu_start())
			emu_error("Varvara", "Start failed.");
		pd->graphics->clear(kColorBlack);
		const char* err;
		font = pd->graphics->loadFont(fontpath, &err);
		if ( font == NULL )


@@ 235,6 291,7 @@ int dy = 2;
static int update(void* userdata)
{
	pd = userdata;
	read_buttons();
	uxn_eval(&u, GETVEC(&u.dev[0x20]));
	pd->system->drawFPS(0,0);
	return 1;