0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-11-22 22:05:11 +00:00

Cleaned up a few demos

This commit is contained in:
neauoire 2022-03-14 09:55:31 -07:00
parent 6ffedca0b4
commit 4019add040
4 changed files with 70 additions and 124 deletions

View file

@ -1,15 +1,4 @@
(
Bifurcan
Every second, the Labyrinth reorganize itself to display the time.
)
%RTN { JMP2r }
%MOD { DUP2 DIV MUL SUB }
%TOS { #00 SWP }
%2// { #01 SFT2 }
%8** { #30 SFT2 }
( devices )
( Bifurcan )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ]
@ -17,17 +6,12 @@
|b0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ]
|80 @Controller [ &vector $2 &button $1 &key $1 ]
( variables )
|0000
@last $1
@style $1
@pointer [ &x $2 &y $2 ]
@center [ &x $2 &y $2 ]
@anchor [ &x $2 &y $2 ]
( program )
|0100 ( -> )
@ -35,16 +19,13 @@
#0f3a .System/r DEO2
#0fda .System/g DEO2
#0faa .System/b DEO2
( vectors )
;on-frame .Screen/vector DEO2
;on-mouse .Mouse/vector DEO2
;on-button .Controller/vector DEO2
( find center )
.Screen/width DEI2 2// .center/x STZ2
.Screen/height DEI2 2// .center/y STZ2
.Screen/width DEI2 #01 SFT2 .center/x STZ2
.Screen/height DEI2 #01 SFT2 .center/y STZ2
( background )
;tiles ;cover-pattern JSR2
;redraw JSR2
@ -54,8 +35,7 @@ BRK
@on-frame ( -> )
( only draw once per second )
.DateTime/second DEI .last LDZ NEQ #01 JCN [ BRK ]
.DateTime/second DEI .last LDZ NEQ JMP [ BRK ]
.DateTime/second DEI .last STZ
;redraw JSR2
@ -65,26 +45,27 @@ BRK
;draw-cursor JSR2
.Mouse/state DEI #00 EQU ,&no-touch JCN
( incr ) .style LDZ INC #03 MOD .style STZ
( bg ) ;tiles .style LDZ #40 SFT TOS ADD2 ;cover-pattern JSR2
( fg ) ;redraw JSR2
( release ) #00 .Mouse/state DEO
&no-touch
.Mouse/state DEI #00 NEQ JMP BRK
,select JSR
BRK
@on-button ( -> )
.Controller/button DEI #00 EQU ,&no-touch JCN
( incr ) .style LDZ INC #03 MOD .style STZ
( bg ) ;tiles .style LDZ #40 SFT TOS ADD2 ;cover-pattern JSR2
( fg ) ;redraw JSR2
( release ) #00 .Mouse/state DEO
&no-touch
.Controller/button DEI #00 NEQ JMP BRK
,select JSR
BRK
@select ( -- )
( incr ) .style LDZ INC #03 ;mod JSR2 .style STZ
( bg ) ;tiles [ #00 .style LDZ #40 SFT ] ADD2 ;cover-pattern JSR2
( fg ) ;redraw JSR2
( release ) #0000 .Mouse/state DEO .Controller/button DEO
JMP2r
@redraw ( -- )
( hrs )
@ -93,14 +74,14 @@ BRK
.DateTime/hour DEI #0a DIV ;draw-number JSR2
[ .center/x LDZ2 #0008 ADD2 ]
[ .center/y LDZ2 #0048 SUB2 ]
.DateTime/hour DEI #0a MOD ;draw-number JSR2
.DateTime/hour DEI #0a ;mod JSR2 ;draw-number JSR2
( min )
[ .center/x LDZ2 #0018 SUB2 ]
[ .center/y LDZ2 #0018 SUB2 ]
.DateTime/minute DEI #0a DIV ;draw-number JSR2
[ .center/x LDZ2 #0008 ADD2 ]
[ .center/y LDZ2 #0018 SUB2 ]
.DateTime/minute DEI #0a MOD ;draw-number JSR2
.DateTime/minute DEI #0a ;mod JSR2 ;draw-number JSR2
( sec )
[ .center/x LDZ2 #0018 SUB2 ]
[ .center/y LDZ2 #0018 ADD2 ]
@ -108,50 +89,47 @@ BRK
;draw-number JSR2
[ .center/x LDZ2 #0008 ADD2 ]
[ .center/y LDZ2 #0018 ADD2 ]
.DateTime/second DEI #0a MOD
.DateTime/second DEI #0a ;mod JSR2
;draw-number JSR2
RTN
JMP2r
@draw-number ( x* y* n -- )
STH
( save pos ) .anchor/y STZ2 .anchor/x STZ2
#00 #0f
,&digit STR ,&y STR2 ,&x STR2
#0f00
&loop
( save-x ) OVR #03 MOD TOS 8** .anchor/x LDZ2 ADD2 .Screen/x DEO2
( save-y ) OVR #03 DIV TOS 8** .anchor/y LDZ2 ADD2 .Screen/y DEO2
( get digit* ) OVR STHkr DUP ADD TOS ;digits ADD2 LDA2
( save-x ) DUP #03 ;mod JSR2 #00 SWP #30 SFT2 [ LIT2 &x $2 ] ADD2 .Screen/x DEO2
( save-y ) DUP #03 DIV #00 SWP #30 SFT2 [ LIT2 &y $2 ] ADD2 .Screen/y DEO2
( get digit* ) DUP [ LIT &digit $1 ] DUP ADD #00 SWP ;digits ADD2 LDA2
( get bit ) ROT #0e SWP SUB SFT2 #0001 AND2
( set tile ) 8** ;tiles ADD2
( set style ) .style LDZ #40 SFT TOS ADD2
.Screen/addr DEO2
( set tile ) #30 SFT2 ;tiles ADD2
( set style ) .style LDZ #40 SFT #00 SWP ADD2
.Screen/addr DEO2
( draw ) #01 .Screen/sprite DEO
( incr ) SWP INC SWP
LTHk ,&loop JCN
INC GTHk ,&loop JCN
POP2
POPr
RTN
JMP2r
@cover-pattern ( addr* -- )
( load ) .Screen/addr DEO2
#0000 .Screen/height DEI2
.Screen/addr DEO2
.Screen/height DEI2 #03 SFT2 NIP ,&h STR
.Screen/width DEI2 #03 SFT2 NIP ,&w STR
[ LIT &h $1 ] #00
&ver
( save ) OVR2 .Screen/y DEO2
#0000 .Screen/width DEI2
#00 OVR #30 SFT2 .Screen/y DEO2
[ LIT &w $1 ] #00
&hor
( save ) OVR2 .Screen/x DEO2
( draw ) #01 .Screen/sprite DEO
( incr ) SWP2 #0008 ADD2 SWP2
LTH2k ,&hor JCN
POP2 POP2
( incr ) SWP2 #0008 ADD2 SWP2
LTH2k ,&ver JCN
POP2 POP2
#00 OVR #30 SFT2 .Screen/x DEO2
#01 .Screen/sprite DEO
INC GTHk ,&hor JCN
POP2
INC GTHk ,&ver JCN
POP2
RTN
JMP2r
@draw-cursor ( -- )
@ -166,20 +144,22 @@ RTN
( colorize on state )
#41 [ .Mouse/state DEI #00 NEQ ] ADD .Screen/sprite DEO
RTN
JMP2r
@cursor [
80c0 e0f0 f8e0 1000 ]
@mod DUP2 DIV MUL SUB JMP2r
@digits [
@cursor
80c0 e0f0 f8e0 1000
@digits
7b6f 2492 73e7 73cf
5bc9 79cf 49ef 7249
7bef 7bc9 ]
7bef 7bc9
@tiles [
@tiles
0102 0408 1020 4080
8040 2010 0804 0201
0718 2040 4080 8080
0101 0102 0204 18e0
0808 0810 e304 0808
0808 0804 e310 0808 ]
0808 0804 e310 0808

View file

@ -1,20 +1,11 @@
( GUI Animation )
%2// { #01 SFT2 }
%AUTO-XADDR { #05 .Screen/auto DEO }
( devices )
( 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
( program )
@dvd &x $2 &y $2 &dx $1 &dy $1
|0100 ( -> )
@ -22,57 +13,41 @@
#4cfd .System/r DEO2
#4cf3 .System/g DEO2
#dcf2 .System/b DEO2
( vectors )
;on-frame .Screen/vector DEO2
( starting position )
.Screen/width DEI2 2// .dvd/x STZ2
.Screen/height DEI2 2// .dvd/y STZ2
AUTO-XADDR
#01 ;draw-dvd JSR2
.Screen/width DEI2 #01 SFT2 .dvd/x STZ2
.Screen/height DEI2 #01 SFT2 .dvd/y STZ2
#36 .Screen/auto DEO
#01 ,draw-dvd JSR
BRK
@on-frame ( -> )
#00 ;draw-dvd JSR2
#00 ,draw-dvd JSR
( case: hit-right ) .dvd/x LDZ2 .Screen/width DEI2 #0020 SUB2 EQU2
( case: hit-left ) .dvd/x LDZ2 #0000 EQU2
#0000 EQU2 ,&no-flipx JCN
.dvd/dx LDZk #00 EQU SWP STZ &no-flipx
.dvd/dx LDZk #00 EQU SWP STZ
&no-flipx
( case: hit-bottom ) .dvd/y LDZ2 .Screen/height DEI2 #0010 SUB2 EQU2
( case: hit-top ) .dvd/y LDZ2 #0000 EQU2
#0000 EQU2 ,&no-flipy JCN
.dvd/dy LDZk #00 EQU SWP STZ &no-flipy
.dvd/dy LDZk #00 EQU SWP STZ
&no-flipy
( incr ) .dvd/x LDZ2 #0001 #00 .dvd/dx LDZ #00 EQU DUP2 ADD2 SUB2 ADD2 .dvd/x STZ2
( incr ) .dvd/y LDZ2 #0001 #00 .dvd/dy LDZ #00 EQU DUP2 ADD2 SUB2 ADD2 .dvd/y STZ2
#01 ;draw-dvd JSR2
#01 ,draw-dvd JSR
BRK
@draw-dvd ( color -- )
STH
;dvd_icn .Screen/addr DEO2
.dvd/x LDZ2 .Screen/x DEO2
.dvd/y LDZ2 .Screen/y DEO2
#0800
&loop
DUP #04 NEQ ,&no-lb JCN
.Screen/x DEI2k #0020 SUB2 ROT DEO2
.Screen/y DEI2k #0008 ADD2 ROT DEO2
&no-lb
STHkr .Screen/sprite DEO
INC GTHk ,&loop JCN
POP2
POPr
.Screen/sprite DEOk DEO
JMP2r

View file

@ -4,14 +4,10 @@
|0020 @Screen &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|0080 @Controller &vector $2 &button $1 &key $1
( variables )
|0000
@slime $1
( init )
|0100 ( -> ) @program
( theme )

View file

@ -4,8 +4,6 @@
|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 &pad $3 &scrollx $2 &scrolly $2
( variables )
|0000
@cat
@ -13,8 +11,6 @@
@pointer
&x $2 &y $2
( program )
|0100 ( -> )
( theme )
@ -98,11 +94,10 @@ JMP2r
@draw-tail ( frame -- )
DUP ,&last LDR NEQ ,&changed JCN
POP JMP2r &changed
STHk ,&last LDR NEQ ,&changed JCN
POPr JMP2r &changed
( only redraw on change )
DUP
;frames ROT #00 SWP ADD2 LDA
STHr #00 OVR ;frames ADD2 LDA
#00 SWP #40 SFT2 ;body/tail ADD2
.Screen/addr DEO2
.cat/x LDZ2 .Screen/x DEO2