uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

screen.tal (4573B)


      1 ( Screen:
      2 	Draws a table of all possible sprite arrangements. )
      3 
      4 |00 @System &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1
      5 |20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
      6 |90 @Mouse &vector $2 &x $2 &y $2 &state $1 &chord $1
      7 
      8 |0000
      9 
     10 	@center &x $2 &y $2
     11 
     12 |0100 ( -> )
     13 
     14 	( vector )
     15 	;on-frame .Screen/vector DEO2
     16 	( theme )
     17 	#f07f .System/r DEO2
     18 	#f0e0 .System/g DEO2
     19 	#f0c0 .System/b DEO2
     20 	( gba screen size 00f0 x 00a0 )
     21 	( nds screen size 0100 x 00c0 )
     22 	#0100 .Screen/width DEO2
     23 	#00b0 .Screen/height DEO2
     24 	( find screen center )
     25 	.Screen/width DEI2 #01 SFT2 .center/x STZ2
     26 	.Screen/height DEI2 #01 SFT2 .center/y STZ2
     27 	( draw )
     28 	draw-size
     29 	draw-sprites
     30 	draw-1bpp
     31 	draw-2bpp
     32 
     33 BRK
     34 
     35 (
     36 @|vectors )
     37 
     38 @on-frame ( -> )
     39 
     40 	( scroll background )
     41 	[ LIT2 &f $2 ] INC2k ,&f STR2
     42 		#01 SFT2
     43 		#001f AND2
     44 		#0040 SUB2
     45 			DUP2 .Screen/x DEO2
     46 			.Screen/y DEO2
     47 	;patt-icn draw-fill
     48 
     49 	.center/x LDZ2 #0070 SUB2 .Screen/x DEO2
     50 	.center/y LDZ2 #0048 SUB2 .Screen/y DEO2
     51 	;anim-chr ,&f LDR2 #00ff AND2 #02 SFT #07 AND #40 SFT ADD2 .Screen/addr DEO2
     52 	#8f .Screen/sprite DEO
     53 
     54 	draw-size
     55 	draw-sprites
     56 	draw-1bpp
     57 	draw-2bpp
     58 
     59 BRK
     60 
     61 (
     62 @|drawing )
     63 
     64 @draw-sprites ( -- )
     65 
     66 	( horizontal )
     67 	.center/x LDZ2 #0060 SUB2 .Screen/x DEO2
     68 	.center/y LDZ2 #0048 SUB2 .Screen/y DEO2
     69 	;font-icn .Screen/addr DEO2
     70 	#f6 .Screen/auto DEO
     71 	#05 .Screen/sprite DEO
     72 	( vertical )
     73 	.center/x LDZ2 #0070 SUB2 .Screen/x DEO2
     74 	.center/y LDZ2 #0038 SUB2 .Screen/y DEO2
     75 	;font-icn .Screen/addr DEO2
     76 	#f5 .Screen/auto DEO
     77 	#05 .Screen/sprite DEO
     78 	( table )
     79 	#00 .Screen/auto DEO
     80 	;preview-chr .Screen/addr DEO2
     81 	#00
     82 	&loop
     83 		( move ) #00 OVR #0f AND #30 SFT
     84 			.center/x LDZ2 #0060 SUB2 ADD2 .Screen/x DEO2
     85 		( move ) #00 OVR #f0 AND #01 SFT
     86 			.center/y LDZ2 #0038 SUB2 ADD2 .Screen/y DEO2
     87 		( draw ) DUP .Screen/sprite DEO
     88 		INC DUP ?&loop
     89 	POP
     90 
     91 JMP2r
     92 
     93 @draw-1bpp ( -- )
     94 
     95 	#1000
     96 	&loop
     97 		( color ) STHk
     98 		( y ) #00 OVR #42 SFT2
     99 			.center/y LDZ2 #0038 SUB2 ADD2 STH2
    100 		( x ) #00 OVR #03 AND #40 SFT2 #0040 ADD2
    101 			.center/x LDZ2 #0010 SUB2 ADD2
    102 		STH2r STHr #00 draw-circle
    103 		INC GTHk ?&loop
    104 	POP2
    105 
    106 JMP2r
    107 
    108 @draw-2bpp ( -- )
    109 
    110 	#1000
    111 	&loop
    112 		( color ) STHk
    113 		( y ) #00 OVR #42 SFT2
    114 			.center/y LDZ2 #0008 ADD2 ADD2 STH2
    115 		( x ) #00 OVR #03 AND #40 SFT2 #0040 ADD2
    116 			.center/x LDZ2 #0010 SUB2 ADD2
    117 		STH2r STHr #80 draw-circle
    118 		INC GTHk ?&loop
    119 	POP2
    120 
    121 JMP2r
    122 
    123 @draw-circle ( x* y* color depth -- )
    124 
    125 	ADD STH
    126 	;preview-chr .Screen/addr DEO2
    127 	.Screen/y DEO2
    128 	.Screen/x DEO2
    129 	#01 .Screen/auto DEO
    130 	STHr .Screen/sprite DEOk
    131 	#02 .Screen/auto DEO
    132 	SWP #10 ADD SWP DEOk
    133 	.Screen/x DEI2k #0008 SUB2 ROT DEO2
    134 	#01 .Screen/auto DEO
    135 	SWP #10 ADD SWP DEOk
    136 	SWP #10 ADD SWP DEO
    137 
    138 JMP2r
    139 
    140 @draw-fill ( patt* color -- )
    141 
    142 	.Screen/addr DEO2
    143 	[ LIT2 01 -Screen/auto ] DEO
    144 	.Screen/x DEI2 ,&anchor STR2
    145 	.Screen/width DEI2 #03 SFT2 NIP #08 ADD ,&x STR
    146 	.Screen/height DEI2 #03 SFT2 NIP #08 ADD #00
    147 	&h
    148 		DUP #02 SFT STH
    149 		[ LIT &x $1 ] #00
    150 		&w
    151 			DUP #02 SFT STHkr ADD #01 AND .Screen/sprite DEO
    152 			INC GTHk ?&w
    153 			.Screen/y DEI2k #0008 ADD2 ROT DEO2
    154 			[ LIT2 &anchor $2 ] .Screen/x DEO2
    155 		POP2 POPr
    156 		INC GTHk ?&h
    157 	POP2
    158 
    159 JMP2r
    160 
    161 @draw-size ( -- )
    162 
    163 	#01 .Screen/auto DEO
    164 	.center/x LDZ2 #0030 ADD2 .Screen/x DEO2
    165 	.center/y LDZ2 #0048 SUB2 .Screen/y DEO2
    166 	.Screen/width DEI2 draw-dec
    167 	;x-icn .Screen/addr DEO2
    168 	#01 .Screen/sprite DEO
    169 	.Screen/height DEI2
    170 
    171 @draw-dec ( short* -- )
    172 
    173 	#00 ,&z STR
    174 	#2710 draw-dec/parse
    175 	#03e8 draw-dec/parse
    176 	#0064 draw-dec/parse
    177 	#000a draw-dec/parse
    178 	NIP
    179 	&emit
    180 		DUP [ LIT &z $1 ] EQU ?&skip
    181 			#ff ,&z STR #00 OVR #30 SFT ;font-icn ADD2 .Screen/addr DEO2
    182 			#01 .Screen/sprite DEO
    183 			&skip
    184 	POP
    185 
    186 JMP2r
    187 	&parse DIV2k DUP ,&emit JSR MUL2 SUB2 JMP2r
    188 
    189 (
    190 @|assets )
    191 
    192 @patt-icn [
    193 	aa55 aa55 aa55 aa55 ]
    194 @x-icn [
    195 	0000 0018 1800 0000 ]
    196 @preview-chr [
    197 	0f38 675f dfbf bfbf 0007 1820 2344 4848 ]
    198 @font-icn ( 0-f ) [
    199 	007c 8282 8282 827c 0030 1010 1010 1010
    200 	007c 8202 7c80 80fe 007c 8202 1c02 827c
    201 	000c 1424 4484 fe04 00fe 8080 7c02 827c
    202 	007c 8280 fc82 827c 007c 8202 1e02 0202
    203 	007c 8282 7c82 827c 007c 8282 7e02 827c
    204 	007c 8202 7e82 827e 00fc 8282 fc82 82fc
    205 	007c 8280 8080 827c 00fc 8282 8282 82fc
    206 	007c 8280 f080 827c 007c 8280 f080 8080 [
    207 @anim-chr [
    208 	0000 0018 1800 0000 c381 0000 0000 81c3 
    209 	0000 183c 3c18 0000 0000 0000 0000 0000
    210 	0018 3c7e 7e3c 1800 0000 0000 0000 0000 
    211 	3c7e ffe7 e7ff 7e3c 0000 0018 1800 0000
    212 	ffff e7c3 c3e7 ffff 0000 183c 3c18 0000 
    213 	ffe7 c381 81c3 e7ff 0018 3c7e 7e3c 1800
    214 	c381 0000 0000 81c3 3c7e ffe7 e7ff 7e3c 
    215 	0000 0000 0000 0000 ffff e7c3 c3e7 ffff
    216 	0000 0000 0000 0000 ffe7 c381 81c3 e7ff ]
    217