start nim game (drawing dots)

This commit is contained in:
Travis Shears 2024-07-13 14:55:56 +02:00
parent b9ea93351a
commit 9eeb186b49
4 changed files with 110 additions and 0 deletions

16
lines.tal Normal file
View file

@ -0,0 +1,16 @@
|00 @System &vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|0100
LIT "B #18 DEO
#0064 .Screen/width DEO2
#0064 .Screen/height DEO2
( set system colors )
#2ce9 .System/r DEO2
#01c0 .System/g DEO2
#2ce5 .System/b DEO2
( draw a pixel in the screen )
#0032 .Screen/x DEO2
#0032 .Screen/y DEO2
#41 .Screen/pixel DEO ( fg layer, color1 )

72
nim.tal Normal file
View file

@ -0,0 +1,72 @@
|00 @System &vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &chord $1 &pad $4 &scrolly &scrolly-hb $1 &scrolly-lb $1
|0000
@pointer &x $2 &y $2
@heap &a $1 &b $1 &c $1 &d $1
|0100
@on-reset
( set the screen size )
#00c8 .Screen/width DEO2
#00c8 .Screen/height DEO2
( set system colors )
#29bd .System/r DEO2
#29a7 .System/g DEO2
#297a .System/b DEO2
;on-mouse .Mouse/vector DEO2
( step 1 - fill the heaps )
draw-game
BRK
@draw-game
LIT2r 0000
&l
#0014 #0014 STH2kr #0028 MUL2 ADD2 draw-heap-row
INC2r
STH2kr #0004 NEQ2 ?&l
POP2r
JMP2r
@draw-heap-row ( x* y* -- )
LITr 00
&l
SWP2 ( y* x* )
#0014 ADD2 ( y* x* + 20 )
SWP2 ( x* + 20 y* )
OVR2 OVR2 ( x* + 20 y* x* + 20 y* )
draw-el
INCr
STHkr #07 NEQ ?&l
POPr
POP2 POP2
JMP2r
@draw-el ( x, y )
.Screen/y DEO2
.Screen/x DEO2
#01 .Screen/pixel DEO
JMP2r
@on-mouse ( -> )
( draw the pixel )
.Mouse/x DEI2 .Screen/x DEO2
.Mouse/y DEI2 .Screen/y DEO2
#41 .Screen/pixel DEO
( clear the old pixel )
.pointer/x LDZ2 .Screen/x DEO2
.pointer/y LDZ2 .Screen/y DEO2
#40 .Screen/pixel DEO
( store current pos )
.Mouse/x DEI2 .pointer/x STZ2
.Mouse/y DEI2 .pointer/y STZ2
BRK
( draw a pixel in the screen )
( #0032 .Screen/x DEO2 )
( #0032 .Screen/y DEO2 )
( #41 .Screen/pixel DEO ( fg layer, color1 ) )

16
play.tal Normal file
View file

@ -0,0 +1,16 @@
|00 @System &vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
|0100
@on-reset
#01 ( 1 )
LITr 00 ( `0, 1 )
&l
#01 ADDk NIP ( 1, 2 )
LITr 01 ADDr ( `1 )
STHkr ( `1 1, 2, 1 )
#08 NEQ ?&l
POPr
BRK

6
run_ui.sh Executable file
View file

@ -0,0 +1,6 @@
#!/bin/sh
filename="${1%.*}"
rom_filename="${filename}.rom"
../uxn/bin/uxnasm $1 $rom_filename && ../uxn/bin/uxnemu $rom_filename