uxn/projects/examples/devices/screen.tal

228 lines
4.9 KiB
Tal
Raw Normal View History

2021-04-24 13:15:47 -04:00
( dev/screen )
%RTN { JMP2r }
2021-08-17 22:40:07 -04:00
%2/ { #01 SFT }
%4/ { #02 SFT }
2021-04-24 13:15:47 -04:00
%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%AUTO-NONE { #00 .Screen/auto DEO }
%AUTO-X { #01 .Screen/auto DEO }
%AUTO-Y { #02 .Screen/auto DEO }
%AUTO-XY { #03 .Screen/auto DEO }
%AUTO-ADDR { #04 .Screen/auto DEO }
%AUTO-XADDR { #05 .Screen/auto DEO }
%AUTO-YADDR { #06 .Screen/auto DEO }
2021-04-24 13:15:47 -04:00
( devices )
2021-08-08 13:21:58 -04:00
|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
2021-04-24 13:15:47 -04:00
( variables )
|0000
2021-08-08 13:21:58 -04:00
@count $2
@center
&x $2 &y $2
2021-04-24 13:15:47 -04:00
( init )
|0100 ( -> )
2021-08-08 13:21:58 -04:00
( vector )
;on-frame .Screen/vector DEO2
( theme )
#f07f .System/r DEO2
#f0e0 .System/g DEO2
#f0c0 .System/b DEO2
2021-04-24 13:15:47 -04:00
( find screen center )
.Screen/width DEI2 #01 SFT2 #0020 -- .center/x STZ2
2021-08-01 14:00:07 -04:00
.Screen/height DEI2 #01 SFT2 .center/y STZ2
2021-04-24 13:15:47 -04:00
( draw )
2021-04-29 13:10:07 -04:00
;draw-table JSR2
2021-08-01 14:28:37 -04:00
;draw-sprites JSR2
2021-08-01 14:00:07 -04:00
;draw-1bpp JSR2
;draw-2bpp JSR2
;draw-pixels JSR2
;draw-autobytes JSR2
AUTO-NONE
2021-04-24 13:15:47 -04:00
BRK
2021-08-08 13:21:58 -04:00
@on-frame ( -> )
2022-03-06 14:00:02 -05:00
AUTO-X
2021-08-17 22:40:07 -04:00
.count LDZ2 INC2 [ DUP2 ] .count STZ2
.center/x LDZ2 #0048 ++ .Screen/x DEO2
.center/y LDZ2 #0050 -- .Screen/y DEO2
SWP
DUP #04 SFT [ #00 SWP ] #30 SFT2 ;font-hex ++ .Screen/addr DEO2
2022-03-06 14:00:02 -05:00
#01 .Screen/sprite DEO
#0f AND [ #00 SWP ] #30 SFT2 ;font-hex ++ .Screen/addr DEO2
2022-03-06 14:00:02 -05:00
#01 .Screen/sprite DEO
DUP #04 SFT [ #00 SWP ] #30 SFT2 ;font-hex ++ .Screen/addr DEO2
2022-03-06 14:00:02 -05:00
#01 .Screen/sprite DEO
#0f AND [ #00 SWP ] #30 SFT2 ;font-hex ++ .Screen/addr DEO2
2022-03-06 14:00:02 -05:00
#01 .Screen/sprite DEO
2021-08-08 13:21:58 -04:00
BRK
2021-04-29 13:10:07 -04:00
@draw-table ( -- )
2022-03-06 14:00:02 -05:00
.center/x LDZ2 #0040 -- .Screen/x DEO2
.center/y LDZ2 #0050 -- .Screen/y DEO2
;font-hex .Screen/addr DEO2
#f6 .Screen/auto DEO
#01 .Screen/sprite DEO
.center/x LDZ2 #0050 -- .Screen/x DEO2
.center/y LDZ2 #0040 -- .Screen/y DEO2
;font-hex .Screen/addr DEO2
#f5 .Screen/auto DEO
#01 .Screen/sprite DEO
AUTO-NONE
2021-04-29 13:10:07 -04:00
RTN
@draw-sprites ( -- )
;preview_icn .Screen/addr DEO2
#00 #00
&loop
( move ) DUP #0f AND #40 SFT 2/ #00 SWP
.center/x LDZ2 #0040 -- ++ .Screen/x DEO2
( move ) DUP #f0 AND 2/ #00 SWP
.center/y LDZ2 #0040 -- ++ .Screen/y DEO2
2021-08-02 11:59:16 -04:00
( draw ) DUP .Screen/sprite DEO
2021-08-17 22:40:07 -04:00
INC NEQk ,&loop JCN
POP2
RTN
2021-08-01 14:00:07 -04:00
@draw-1bpp ( -- )
2021-08-02 11:59:16 -04:00
#10 #00
2021-08-01 14:00:07 -04:00
&loop
2021-08-02 11:59:16 -04:00
( color ) STHk
2021-08-17 22:40:07 -04:00
( y ) DUP 4/ [ #00 SWP ] #40 SFT2
[ .center/y LDZ2 #0040 -- ++ ] STH2
( x ) DUP #03 AND [ #00 SWP ] #40 SFT2 #0040 ++
[ .center/x LDZ2 #0008 ++ ++ ]
2022-03-06 14:00:02 -05:00
STH2r STHr #00 ,draw-circle JSR
2021-08-17 22:40:07 -04:00
INC GTHk ,&loop JCN
2021-08-01 14:00:07 -04:00
POP2
RTN
@draw-2bpp ( -- )
2021-08-02 11:59:16 -04:00
#10 #00
2021-08-01 14:00:07 -04:00
&loop
2021-08-02 11:59:16 -04:00
( color ) STHk
2021-08-17 22:40:07 -04:00
( y ) DUP 4/ [ #00 SWP ] #40 SFT2
[ .center/y LDZ2 ++ ] STH2
( x ) DUP #03 AND [ #00 SWP ] #40 SFT2 #0040 ++
[ .center/x LDZ2 #0008 ++ ++ ]
2022-03-06 14:00:02 -05:00
STH2r STHr #80 ,draw-circle JSR
2021-08-17 22:40:07 -04:00
INC GTHk ,&loop JCN
2021-08-01 14:00:07 -04:00
POP2
2021-08-01 14:28:37 -04:00
2021-08-01 14:00:07 -04:00
RTN
2022-03-06 14:00:02 -05:00
@draw-circle ( x* y* color depth -- )
ADD STH
;preview_icn .Screen/addr DEO2
.Screen/y DEO2
.Screen/x DEO2
AUTO-X
STHr .Screen/sprite DEOk
AUTO-Y
SWP #10 + SWP DEOk
.Screen/x DEI2k #0008 -- ROT DEO2
AUTO-X
SWP #10 + SWP DEOk
SWP #10 + SWP DEO
RTN
@draw-autobytes ( -- )
.center/x LDZ2 #0090 ++ .Screen/x DEO2
.center/y LDZ2 #0040 -- .Screen/y DEO2
;23x-icns .Screen/addr DEO2
#16 .Screen/auto DEO
#04 .Screen/sprite DEOk DEOk DEO
.center/x LDZ2 #00a8 ++ .Screen/x DEO2
.center/y LDZ2 #0030 -- .Screen/y DEO2
;23y-icns .Screen/addr DEO2
#25 .Screen/auto DEO
#0c .Screen/sprite DEOk DEO
.center/x LDZ2 #00a0 ++ .Screen/x DEO2
.center/y LDZ2 #0040 -- .Screen/y DEO2
;32x-icns .Screen/addr DEO2
#26 .Screen/auto DEO
#01 .Screen/sprite DEOk DEO
.center/x LDZ2 #0090 ++ .Screen/x DEO2
.center/y LDZ2 #0028 -- .Screen/y DEO2
;32y-icns .Screen/addr DEO2
#15 .Screen/auto DEO
#03 .Screen/sprite DEOk DEOk DEO
RTN
@draw-pixels ( -- )
.center/y LDZ2 #0040 -- .Screen/y DEO2
.center/x LDZ2 #0048 ++ .Screen/x DEO2
2022-03-06 14:00:02 -05:00
AUTO-X
#00 .Screen/pixel DEO
#01 .Screen/pixel DEO
#02 .Screen/pixel DEO
#03 .Screen/pixel DEO
2021-04-29 13:10:07 -04:00
2021-04-24 13:15:47 -04:00
RTN
@preview_icn
0f38 675f dfbf bfbf 0007 1820 2344 4848
2021-04-29 13:10:07 -04:00
@font-hex
2021-04-29 13:10:07 -04:00
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
@23x-icns
0010 2847 2810 0001 0000 00e0 2040 8000
0204 080f 0000 0001 0000 00e0 2040 8000
0204 080f 0000 0000 0010 28c4 2810 0000
@23y-icns
0010 2844 2810 1111 1111 1111 1111 1111
1112 1418 0000 0000 0000 0030 5090 1010
1010 1010 1010 1010 1010 2844 2810 0000
@32x-icns
0010 2847 2810 0001 0000 00ff 0000 00ff
0000 00f0 1020 4080 0204 080f 0000 0000
0000 00ff 0000 0000 0010 28c4 2810 0000
@32y-icns
0010 2844 2810 1011 1214 1800 0000 0000
0000 0000 3050 9011 1214 1800 0000 0000
0000 0000 3050 9010 1010 2844 2810 0000