uxn/projects/examples/devices/screen.tal

177 lines
3.8 KiB
Tal
Raw Normal View History

( Screen:
Draws a table of all possible sprite arrangements. )
2021-04-24 17:15:47 +00: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 17:15:47 +00:00
|0000
2022-11-10 17:21:02 +00:00
@center &x $2 &y $2
2021-04-24 17:15:47 +00:00
|0100 ( -> )
2021-08-08 17:21:58 +00:00
( vector )
;on-frame .Screen/vector DEO2
( theme )
#f07f .System/r DEO2
#f0e0 .System/g DEO2
#f0c0 .System/b DEO2
2022-03-15 16:57:33 +00:00
( gba screen size 00f0 x 00a0 )
( nds screen size 0100 x 00c0 )
2023-01-10 03:14:31 +00:00
#0100 .Screen/width DEO2
#00b0 .Screen/height DEO2
2021-04-24 17:15:47 +00:00
( find screen center )
.Screen/width DEI2 #01 SFT2 .center/x STZ2
2021-08-01 18:00:07 +00:00
.Screen/height DEI2 #01 SFT2 .center/y STZ2
2021-04-24 17:15:47 +00:00
( draw )
2023-01-10 03:04:52 +00:00
;draw-size JSR2
2021-08-01 18:28:37 +00:00
;draw-sprites JSR2
2021-08-01 18:00:07 +00:00
;draw-1bpp JSR2
;draw-2bpp JSR2
2023-01-10 03:14:31 +00:00
2021-04-24 17:15:47 +00:00
BRK
2023-01-10 03:04:52 +00:00
(
@|vectors )
2021-08-08 17:21:58 +00:00
@on-frame ( -> )
2023-01-10 03:04:52 +00:00
.center/x LDZ2 #0070 SUB2 .Screen/x DEO2
.center/y LDZ2 #0048 SUB2 .Screen/y DEO2
2023-01-10 03:14:31 +00:00
;anim-chr #00 [ LIT &f $1 ] INCk ,&f STR
#02 SFT #07 AND #40 SFT ADD2 .Screen/addr DEO2
2023-01-10 03:04:52 +00:00
#81 .Screen/sprite DEO
2021-08-08 17:21:58 +00:00
BRK
2023-01-10 03:04:52 +00:00
(
@|drawing )
@draw-sprites ( -- )
2021-04-29 17:10:07 +00:00
2022-03-27 01:29:38 +00:00
( horizontal )
.center/x LDZ2 #0060 SUB2 .Screen/x DEO2
.center/y LDZ2 #0048 SUB2 .Screen/y DEO2
2023-01-10 03:14:31 +00:00
;font-icn .Screen/addr DEO2
2022-03-06 19:00:02 +00:00
#f6 .Screen/auto DEO
#01 .Screen/sprite DEO
2022-03-27 01:29:38 +00:00
( vertical )
.center/x LDZ2 #0070 SUB2 .Screen/x DEO2
.center/y LDZ2 #0038 SUB2 .Screen/y DEO2
2023-01-10 03:14:31 +00:00
;font-icn .Screen/addr DEO2
2022-03-27 01:29:38 +00:00
#f5 .Screen/auto DEO
#01 .Screen/sprite DEO
( table )
2023-01-10 03:14:31 +00:00
#00 .Screen/auto DEO
;preview-chr .Screen/addr DEO2
#00
&loop
2023-01-10 03:14:31 +00:00
( move ) #00 OVR #0f AND #30 SFT
2022-03-27 01:29:38 +00:00
.center/x LDZ2 #0060 SUB2 ADD2 .Screen/x DEO2
2022-11-10 17:21:02 +00:00
( move ) #00 OVR #f0 AND #01 SFT
.center/y LDZ2 #0038 SUB2 ADD2 .Screen/y DEO2
2021-08-02 15:59:16 +00:00
( draw ) DUP .Screen/sprite DEO
2023-01-10 03:14:31 +00:00
INC DUP ,&loop JCN
POP
JMP2r
2021-08-01 18:00:07 +00:00
@draw-1bpp ( -- )
2022-11-10 17:21:02 +00:00
#1000
2021-08-01 18:00:07 +00:00
&loop
2021-08-02 15:59:16 +00:00
( color ) STHk
2022-11-10 17:21:02 +00:00
( y ) #00 OVR #42 SFT2
.center/y LDZ2 #0038 SUB2 ADD2 STH2
( x ) #00 OVR #03 AND #40 SFT2 #0040 ADD2
.center/x LDZ2 #0010 SUB2 ADD2
2022-03-06 19:00:02 +00:00
STH2r STHr #00 ,draw-circle JSR
2021-08-18 02:40:07 +00:00
INC GTHk ,&loop JCN
2021-08-01 18:00:07 +00:00
POP2
JMP2r
2021-08-01 18:00:07 +00:00
@draw-2bpp ( -- )
2022-11-10 17:21:02 +00:00
#1000
2021-08-01 18:00:07 +00:00
&loop
2021-08-02 15:59:16 +00:00
( color ) STHk
2022-11-10 17:21:02 +00:00
( y ) #00 OVR #42 SFT2
.center/y LDZ2 #0008 ADD2 ADD2 STH2
( x ) #00 OVR #03 AND #40 SFT2 #0040 ADD2
.center/x LDZ2 #0010 SUB2 ADD2
2022-03-06 19:00:02 +00:00
STH2r STHr #80 ,draw-circle JSR
2021-08-18 02:40:07 +00:00
INC GTHk ,&loop JCN
2021-08-01 18:00:07 +00:00
POP2
2021-08-01 18:28:37 +00:00
JMP2r
2021-08-01 18:00:07 +00:00
2022-03-06 19:00:02 +00:00
@draw-circle ( x* y* color depth -- )
ADD STH
2023-01-10 03:14:31 +00:00
;preview-chr .Screen/addr DEO2
2022-03-06 19:00:02 +00:00
.Screen/y DEO2
.Screen/x DEO2
#01 .Screen/auto DEO
2022-03-06 19:00:02 +00:00
STHr .Screen/sprite DEOk
#02 .Screen/auto DEO
SWP #10 ADD SWP DEOk
.Screen/x DEI2k #0008 SUB2 ROT DEO2
#01 .Screen/auto DEO
SWP #10 ADD SWP DEOk
SWP #10 ADD SWP DEO
JMP2r
2023-01-10 03:04:52 +00:00
@draw-size ( -- )
2021-04-29 17:10:07 +00:00
2023-01-10 03:04:52 +00:00
#01 .Screen/auto DEO
.center/x LDZ2 #0030 ADD2 .Screen/x DEO2
.center/y LDZ2 #0048 SUB2 .Screen/y DEO2
.Screen/width DEI2 ;draw-dec JSR2
;x-icn .Screen/addr DEO2
#01 .Screen/sprite DEO
2023-01-10 03:04:52 +00:00
.Screen/height DEI2
@draw-dec ( short* -- )
#00 ,&z STR
#2710 ,&parse JSR
#03e8 ,&parse JSR
#0064 ,&parse JSR
#000a ,&parse JSR
NIP
&emit
DUP [ LIT &z $1 ] EQU ,&skip JCN
2023-01-10 03:14:31 +00:00
#ff ,&z STR #00 OVR #30 SFT ;font-icn ADD2 .Screen/addr DEO2
2023-01-10 03:04:52 +00:00
#01 .Screen/sprite DEO
&skip
POP
JMP2r
2023-01-10 03:04:52 +00:00
&parse DIV2k DUP ,&emit JSR MUL2 SUB2 JMP2r
(
@|assets )
2021-04-24 17:15:47 +00:00
2023-01-10 03:04:52 +00:00
@x-icn
0000 0018 1800 0000
2023-01-10 03:14:31 +00:00
@preview-chr
0f38 675f dfbf bfbf 0007 1820 2344 4848
2023-01-10 03:14:31 +00:00
@font-icn ( 0-f )
2021-04-29 17:10:07 +00: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
2023-01-10 03:04:52 +00:00
@anim-chr
0000 0018 1800 0000 c381 0000 0000 81c3 0000 183c 3c18 0000 0000 0000 0000 0000
0018 3c7e 7e3c 1800 0000 0000 0000 0000 3c7e ffe7 e7ff 7e3c 0000 0018 1800 0000
ffff e7c3 c3e7 ffff 0000 183c 3c18 0000 ffe7 c381 81c3 e7ff 0018 3c7e 7e3c 1800
c381 0000 0000 81c3 3c7e ffe7 e7ff 7e3c 0000 0000 0000 0000 ffff e7c3 c3e7 ffff
0000 0000 0000 0000 ffe7 c381 81c3 e7ff