Rewrote the snake example
This commit is contained in:
parent
481a318732
commit
c549a6c710
2
build.sh
2
build.sh
|
@ -20,5 +20,5 @@ cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werr
|
||||||
# cc uxn.c emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -o bin/emulator
|
# cc uxn.c emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -o bin/emulator
|
||||||
|
|
||||||
# run
|
# run
|
||||||
./bin/assembler projects/software/left.usm bin/boot.rom
|
./bin/assembler projects/examples/dev.controller.usm bin/boot.rom
|
||||||
./bin/emulator bin/boot.rom
|
./bin/emulator bin/boot.rom
|
||||||
|
|
|
@ -1,62 +1,57 @@
|
||||||
( Controller )
|
( Controller )
|
||||||
|
|
||||||
|
%INCR2 { #0001 ADD2 }
|
||||||
|
%DECR2 { #0001 SUB2 }
|
||||||
|
%HALF2 { #0002 DIV2 }
|
||||||
|
|
||||||
;slime { color 1 }
|
;slime { color 1 }
|
||||||
|
|
||||||
|0100 @RESET
|
|0100 @RESET
|
||||||
|
|
||||||
( set origin )
|
( set origin )
|
||||||
~Screen.width #0002 DIV2 =Sprite.x
|
~Screen.width HALF2 =Sprite.x
|
||||||
~Screen.height #0002 DIV2 =Sprite.y
|
~Screen.height HALF2 =Sprite.y
|
||||||
,default_icn =Sprite.addr
|
,default_icn =Sprite.addr
|
||||||
#11 =Sprite.color
|
#11 =Sprite.color
|
||||||
#0a =slime
|
#0a =slime
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
|c000 @FRAME
|
@FRAME
|
||||||
|
|
||||||
|
~Controller.buttons #f0 AND #00 EQU BRK?
|
||||||
|
|
||||||
#0a =slime
|
#0a =slime
|
||||||
|
|
||||||
( hold ctrl key to change slime color )
|
( hold ctrl key to change slime color )
|
||||||
,no-ctrl ~Controller.buttons #0f AND #01 NEQ JMP2? POP2
|
|
||||||
#05 =slime
|
~Controller.buttons #0f AND
|
||||||
@no-ctrl
|
DUP #01 NEQ ,$no-ctrl ROT JMP2? POP2 #05 =slime $no-ctrl
|
||||||
( hold alt key to change slime color )
|
DUP #02 NEQ ,$no-alt ROT JMP2? POP2 #0f =slime $no-alt
|
||||||
,no-alt ~Controller.buttons #0f AND #02 NEQ JMP2? POP2
|
POP
|
||||||
#0f =slime
|
|
||||||
@no-alt
|
( clear ) #10 =Sprite.color
|
||||||
|
|
||||||
( detect movement )
|
( detect movement )
|
||||||
,no-up ~Controller.buttons #f0 AND #10 NEQ JMP2? POP2
|
~Controller.buttons #f0 AND
|
||||||
( clear ) #10 =Sprite.color
|
DUP #04 ROR #01 AND #01 NEQ ,$no-up ROT JMP2? POP2
|
||||||
( move ) ~Sprite.y #0001 SUB2 =Sprite.y ,up_icn =Sprite.addr
|
( move ) ~Sprite.y DECR2 =Sprite.y ,up_icn =Sprite.addr $no-up
|
||||||
( draw ) ,redraw JSR2 BRK
|
DUP #05 ROR #01 AND #01 NEQ ,$no-down ROT JMP2? POP2
|
||||||
@no-up
|
( move ) ~Sprite.y INCR2 =Sprite.y ,down_icn =Sprite.addr $no-down
|
||||||
,no-down ~Controller.buttons #f0 AND #20 NEQ JMP2? POP2
|
DUP #06 ROR #01 AND #01 NEQ ,$no-left ROT JMP2? POP2
|
||||||
( clear ) #10 =Sprite.color
|
( move ) ~Sprite.x DECR2 =Sprite.x ,left_icn =Sprite.addr $no-left
|
||||||
( move ) ~Sprite.y #0001 ADD2 =Sprite.y ,down_icn =Sprite.addr
|
DUP #07 ROR #01 AND #01 NEQ ,$no-right ROT JMP2? POP2
|
||||||
( draw ) ,redraw JSR2 BRK
|
( move ) ~Sprite.x INCR2 =Sprite.x ,right_icn =Sprite.addr $no-right
|
||||||
@no-down
|
POP
|
||||||
,no-left ~Controller.buttons #f0 AND #40 NEQ JMP2? POP2
|
|
||||||
( clear ) #10 =Sprite.color
|
|
||||||
( move ) ~Sprite.x #0001 SUB2 =Sprite.x ,left_icn =Sprite.addr
|
|
||||||
( draw ) ,redraw JSR2 BRK
|
|
||||||
@no-left
|
|
||||||
,no-right ~Controller.buttons #f0 AND #80 NEQ JMP2? POP2
|
|
||||||
( clear ) #10 =Sprite.color
|
|
||||||
( move ) ~Sprite.x #0001 ADD2 =Sprite.x ,right_icn =Sprite.addr
|
|
||||||
( draw ) ,redraw JSR2 BRK
|
|
||||||
@no-right
|
|
||||||
|
|
||||||
BRK
|
|
||||||
|
|
||||||
@redraw
|
|
||||||
|
|
||||||
( draw face )
|
( draw face )
|
||||||
#11 =Sprite.color
|
#11 =Sprite.color
|
||||||
|
|
||||||
( draw slime )
|
( draw slime )
|
||||||
,slime_icn =Sprite.addr
|
,slime_icn =Sprite.addr
|
||||||
~slime =Sprite.color
|
~slime =Sprite.color
|
||||||
|
|
||||||
RTN
|
BRK
|
||||||
|
|
||||||
@default_icn [ 3c7e ffdb ffe7 7e3c ]
|
@default_icn [ 3c7e ffdb ffe7 7e3c ]
|
||||||
@up_icn [ 2466 e7db ffff 7e3c ]
|
@up_icn [ 2466 e7db ffff 7e3c ]
|
||||||
|
@ -67,6 +62,7 @@ RTN
|
||||||
|
|
||||||
|d000 @ERROR BRK
|
|d000 @ERROR BRK
|
||||||
|
|
||||||
|
|FF00 ;Console { pad 8 char 1 byte 1 short 2 }
|
||||||
|FF10 ;Screen { width 2 height 2 pad 4 y 2 x 2 color 1 }
|
|FF10 ;Screen { width 2 height 2 pad 4 y 2 x 2 color 1 }
|
||||||
|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
||||||
|FF30 ;Controller { buttons 1 }
|
|FF30 ;Controller { buttons 1 }
|
||||||
|
|
Loading…
Reference in New Issue