0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-11-23 06:15:10 +00:00

Improved polycat example

This commit is contained in:
neauoire 2021-02-23 17:57:57 -08:00
parent e157f7138b
commit 552d718b24
4 changed files with 38 additions and 33 deletions

View file

@ -101,7 +101,6 @@ A device that works like a NES controller, each button is a bit from a single by
- Line routine - Line routine
- Getting rid of IOR/IOW would be nice.. - Getting rid of IOR/IOW would be nice..
- Example of button pointing to a subroutine - Example of button pointing to a subroutine
- Labels should not have the trailing space
### Misc TODOs ### Misc TODOs

View file

@ -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 examples/window.usm bin/boot.rom ./bin/assembler examples/devmouse.usm bin/boot.rom
./bin/emulator bin/boot.rom ./bin/emulator bin/boot.rom

View file

@ -3,17 +3,24 @@
:dev/r fff8 ( std read port ) :dev/r fff8 ( std read port )
:dev/w fff9 ( std write port ) :dev/w fff9 ( std write port )
;mousex 2 ;mousey 2 &Point2d { x 2 y 2 }
;lastx 2 ;lasty 2
;catx 2 ;caty 2 ;mouse Point2d
;cat Point2d
;state 1 ;timer 1 ;state 1 ;timer 1
|0100 @RESET |0100 @RESET
#01 =dev/r ( set dev/read mouse )
( position cat )
#00 IOR2 #0002 DIV2 =cat.x
#02 IOR2 #0038 SUB2 =cat.y
#05 =dev/r ( set dev/read mouse ) #05 =dev/r ( set dev/read mouse )
#02 =dev/w ( set dev/write to sprite ) #02 =dev/w ( set dev/write to sprite )
( position cat )
#0050 =catx #0058 =caty
( draw polycat ) ( draw polycat )
,draw-polycat JSR ,draw-polycat JSR
@ -22,9 +29,9 @@ BRK
|c000 @FRAME |c000 @FRAME
( clear last cursor ) ( clear last cursor )
#10 ,clear_icn ~lastx ~lasty ,draw-sprite JSR #10 ,clear_icn ~mouse.x ~mouse.y ,draw-sprite JSR
( record mouse positions ) ( record mouse positions )
#00 IOR2 =mousex #02 IOR2 =mousey #00 IOR2 =mouse.x #02 IOR2 =mouse.y
( record mouse state ) ( record mouse state )
#04 IOR #11 ADD =state #04 IOR #11 ADD =state
( detect click ) ( detect click )
@ -32,11 +39,10 @@ BRK
#50 =timer #50 =timer
@no-click @no-click
( draw mouse ) ( draw mouse )
~state ,cursor_icn ~mousex ~mousey ,draw-sprite JSR ~state ,cursor_icn ~mouse.x ~mouse.y ,draw-sprite JSR
( animate ) ( animate )
,animate-polycat JSR ,animate-polycat JSR
( update last pos ) ( update last pos )
~mousex =lastx ~mousey =lasty
~timer #01 ADD =timer ~timer #01 ADD =timer
BRK BRK
@ -44,14 +50,14 @@ BRK
@draw-polycat @draw-polycat
( ears ) ( ears )
,polycat ~catx ~caty ,draw-sprite-chr JSR ,polycat ~cat.x ~cat.y ,draw-sprite-chr JSR
,polycat #0010 ADD2 ~catx #0008 ADD2 ~caty ,draw-sprite-chr JSR ,polycat #0010 ADD2 ~cat.x #0008 ADD2 ~cat.y ,draw-sprite-chr JSR
( eye ) ( eye )
,polycat #0020 ADD2 ~catx ~caty #0008 ADD2 ,draw-sprite-chr JSR ,polycat #0020 ADD2 ~cat.x ~cat.y #0008 ADD2 ,draw-sprite-chr JSR
,polycat #0030 ADD2 ~catx #0008 ADD2 ~caty #0008 ADD2 ,draw-sprite-chr JSR ,polycat #0030 ADD2 ~cat.x #0008 ADD2 ~cat.y #0008 ADD2 ,draw-sprite-chr JSR
( body ) ( body )
,polycat #00a0 ADD2 ~catx ~caty #0010 ADD2 ,draw-sprite-chr JSR ,polycat #00a0 ADD2 ~cat.x ~cat.y #0010 ADD2 ,draw-sprite-chr JSR
,polycat #00b0 ADD2 ~catx #0008 ADD2 ~caty #0010 ADD2 ,draw-sprite-chr JSR ,polycat #00b0 ADD2 ~cat.x #0008 ADD2 ~cat.y #0010 ADD2 ,draw-sprite-chr JSR
RTS RTS
@ -59,35 +65,35 @@ RTS
( tail ) ( tail )
~timer #50 NEQ ,animate-polycat-tail-next0 ROT JMP? POP2 ~timer #50 NEQ ,animate-polycat-tail-next0 ROT JMP? POP2
,polycat #00c0 ADD2 ~catx #0008 ADD2 ~caty #0010 ADD2 ,draw-sprite-chr JSR ,polycat #00c0 ADD2 ~cat.x #0008 ADD2 ~cat.y #0010 ADD2 ,draw-sprite-chr JSR
@animate-polycat-tail-next0 @animate-polycat-tail-next0
~timer #58 NEQ ,animate-polycat-tail-next1 ROT JMP? POP2 ~timer #58 NEQ ,animate-polycat-tail-next1 ROT JMP? POP2
,polycat #00d0 ADD2 ~catx #0008 ADD2 ~caty #0010 ADD2 ,draw-sprite-chr JSR ,polycat #00d0 ADD2 ~cat.x #0008 ADD2 ~cat.y #0010 ADD2 ,draw-sprite-chr JSR
@animate-polycat-tail-next1 @animate-polycat-tail-next1
~timer #60 NEQ ,animate-polycat-tail-next2 ROT JMP? POP2 ~timer #60 NEQ ,animate-polycat-tail-next2 ROT JMP? POP2
,polycat #00b0 ADD2 ~catx #0008 ADD2 ~caty #0010 ADD2 ,draw-sprite-chr JSR ,polycat #00b0 ADD2 ~cat.x #0008 ADD2 ~cat.y #0010 ADD2 ,draw-sprite-chr JSR
@animate-polycat-tail-next2 @animate-polycat-tail-next2
( look-at ) ( look-at )
~mousex ~catx #0008 ADD2 GTH2 ,animate-polycat-right ROT JMP? POP2 ~mouse.x ~cat.x #0008 ADD2 GTH2 ,animate-polycat-right ROT JMP? POP2
@animate-polycat-left @animate-polycat-left
~mousey ~caty #0008 ADD2 GTH2 ,animate-polycat-left-down ROT JMP? POP2 ~mouse.y ~cat.y #0008 ADD2 GTH2 ,animate-polycat-left-down ROT JMP? POP2
@animate-polycat-left-up @animate-polycat-left-up
,polycat #0040 ADD2 ~catx ~caty #0008 ADD2 ,draw-sprite-chr JSR ,polycat #0040 ADD2 ~cat.x ~cat.y #0008 ADD2 ,draw-sprite-chr JSR
,polycat #0050 ADD2 ~catx #0008 ADD2 ~caty #0008 ADD2 ,draw-sprite-chr JSR ,polycat #0050 ADD2 ~cat.x #0008 ADD2 ~cat.y #0008 ADD2 ,draw-sprite-chr JSR
RTS RTS
@animate-polycat-left-down @animate-polycat-left-down
,polycat #0020 ADD2 ~catx ~caty #0008 ADD2 ,draw-sprite-chr JSR ,polycat #0020 ADD2 ~cat.x ~cat.y #0008 ADD2 ,draw-sprite-chr JSR
,polycat #0030 ADD2 ~catx #0008 ADD2 ~caty #0008 ADD2 ,draw-sprite-chr JSR ,polycat #0030 ADD2 ~cat.x #0008 ADD2 ~cat.y #0008 ADD2 ,draw-sprite-chr JSR
RTS RTS
@animate-polycat-right @animate-polycat-right
~mousey ~caty #0008 ADD2 GTH2 ,animate-polycat-right-down ROT JMP? POP2 ~mouse.y ~cat.y #0008 ADD2 GTH2 ,animate-polycat-right-down ROT JMP? POP2
@animate-polycat-right-up @animate-polycat-right-up
,polycat #0060 ADD2 ~catx ~caty #0008 ADD2 ,draw-sprite-chr JSR ,polycat #0060 ADD2 ~cat.x ~cat.y #0008 ADD2 ,draw-sprite-chr JSR
,polycat #0070 ADD2 ~catx #0008 ADD2 ~caty #0008 ADD2 ,draw-sprite-chr JSR ,polycat #0070 ADD2 ~cat.x #0008 ADD2 ~cat.y #0008 ADD2 ,draw-sprite-chr JSR
RTS RTS
@animate-polycat-right-down @animate-polycat-right-down
,polycat #0080 ADD2 ~catx ~caty #0008 ADD2 ,draw-sprite-chr JSR ,polycat #0080 ADD2 ~cat.x ~cat.y #0008 ADD2 ,draw-sprite-chr JSR
,polycat #0090 ADD2 ~catx #0008 ADD2 ~caty #0008 ADD2 ,draw-sprite-chr JSR ,polycat #0090 ADD2 ~cat.x #0008 ADD2 ~cat.y #0008 ADD2 ,draw-sprite-chr JSR
RTS RTS
RTS RTS

View file

@ -101,8 +101,8 @@ RTS
=icon.y =icon.x =icon.sprite =icon.text =icon.y =icon.x =icon.sprite =icon.text
#01 =dev/w ( write to screen ) #01 =dev/w ( write to screen )
#02 =dev/w ( write to sprite ) #02 =dev/w ( write to sprite )
#01 =color #01 =color
~icon.text ~icon.x #0008 ADD2 ~icon.y #0020 ADD2 ,draw-label JSR ~icon.text ~icon.x #0008 ADD2 ~icon.y #0020 ADD2 ,draw-label JSR
#07 ~icon.sprite ~icon.x #0018 ADD2 ~icon.y #0008 ADD2 #07 ~icon.sprite ~icon.x #0018 ADD2 ~icon.y #0008 ADD2