uxn

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

calc.tal (15354B)


      1 ( simple graphical calculator )
      2 
      3 |00 @System &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1
      4 |20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
      5 |30 @Audio0 &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1
      6 |80 @Controller &vector $2 &button $1 &key $1
      7 |90 @Mouse &vector $2 &x $2 &y $2 &state $1 &wheel $1
      8 |a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
      9 
     10 |0000
     11 
     12 @input &value $2 &mode $1
     13 @stack &length $1 &items $10
     14 @center &x $2 &y $2
     15 @pointer &x $2 &y $2 &last $1
     16 @keypad-frame &x $2 &y $2 &x2 $2 &y2 $2
     17 @modpad-frame &x $2 &y $2 &x2 $2 &y2 $2
     18 @bitpad-frame &x $2 &y $2 &x2 $2 &y2 $2
     19 @input-frame &x $2 &y $2 &x2 $2 &y2 $2
     20 
     21 |0100 ( -> )
     22 
     23 	( theme )
     24 	#0e7d .System/r DEO2
     25 	#0ec6 .System/g DEO2
     26 	#0e95 .System/b DEO2
     27 	( size )
     28 	#0090 .Screen/width DEO2
     29 	#0100 .Screen/height DEO2
     30 	( vectors )
     31 	;on-mouse .Mouse/vector DEO2
     32 	;on-button .Controller/vector DEO2
     33 	( setup synth )
     34 	#0112 .Audio0/adsr DEO2
     35 	;sin-pcm .Audio0/addr DEO2
     36 	#0100 .Audio0/length DEO2
     37 	#88 .Audio0/volume DEO
     38 	( center )
     39 	.Screen/width DEI2 #01 SFT2 .center/x STZ2
     40 	.Screen/height DEI2 #01 SFT2 .center/y STZ2
     41 	.center/x LDZ2 #0020 SUB2
     42 		DUP2 .keypad-frame/x STZ2 #003f ADD2 .keypad-frame/x2 STZ2
     43 	.center/y LDZ2 #0018 SUB2
     44 		DUP2 .keypad-frame/y STZ2 #003f ADD2 .keypad-frame/y2 STZ2
     45 	.keypad-frame/x LDZ2
     46 		DUP2 .modpad-frame/x STZ2 #003f ADD2 .modpad-frame/x2 STZ2
     47 	.keypad-frame/y LDZ2 #0040 ADD2
     48 		DUP2 .modpad-frame/y STZ2 #001f ADD2 .modpad-frame/y2 STZ2
     49 	.keypad-frame/x LDZ2
     50 		DUP2 .bitpad-frame/x STZ2 #003f ADD2 .bitpad-frame/x2 STZ2
     51 	.modpad-frame/y2 LDZ2 #0008 ADD2
     52 		DUP2 .bitpad-frame/y STZ2 #000f ADD2 .bitpad-frame/y2 STZ2
     53 	.center/x LDZ2 #0020 SUB2
     54 		DUP2 .input-frame/x STZ2 #003f ADD2 .input-frame/x2 STZ2
     55 	.center/y LDZ2 #002a SUB2
     56 		DUP2 .input-frame/y STZ2 #000f ADD2 .input-frame/y2 STZ2
     57 	( theme support )
     58 	;load-theme JSR2
     59 
     60 BRK
     61 
     62 @on-button ( -> )
     63 
     64 	.Controller/key DEI
     65 	( generics )
     66 	[ #00 ] NEQk NIP ,&no-empty JCN ;redraw JSR2 POP BRK &no-empty
     67 	[ #09 ] NEQk NIP ,&no-tab JCN ;toggle-mode JSR2 POP BRK &no-tab
     68 	[ #0d ] NEQk NIP ,&no-enter JCN ;do-push JSR2 POP BRK &no-enter
     69 	[ #1b ] NEQk NIP ,&no-esc JCN ;do-pop JSR2 POP BRK &no-esc
     70 	[ #08 ] NEQk NIP ,&no-backspace JCN ;do-erase JSR2 POP BRK &no-backspace
     71 	( arithmetic )
     72 	[ LIT "+ ] NEQk NIP ,&no-add JCN ;do-add JSR2 POP BRK &no-add
     73 	[ LIT "- ] NEQk NIP ,&no-sub JCN ;do-sub JSR2 POP BRK &no-sub
     74 	[ LIT "* ] NEQk NIP ,&no-mul JCN ;do-mul JSR2 POP BRK &no-mul
     75 	[ LIT "/ ] NEQk NIP ,&no-div JCN ;do-div JSR2 POP BRK &no-div
     76 	( bitwise )
     77 	[ LIT "& ] NEQk NIP ,&no-and JCN ;do-and JSR2 POP BRK &no-and
     78 	[ LIT "| ] NEQk NIP ,&no-ora JCN ;do-ora JSR2 POP BRK &no-ora
     79 	[ LIT "^ ] NEQk NIP ,&no-eor JCN ;do-eor JSR2 POP BRK &no-eor
     80 	[ LIT "~ ] NEQk NIP ,&no-not JCN ;do-not JSR2 POP BRK &no-not
     81 	( value )
     82 	;key-value JSR2 ;push-input JSR2
     83 
     84 BRK
     85 
     86 @on-mouse ( -> )
     87 
     88 	;pointer-icn .Screen/addr DEO2
     89 
     90 	( clear last cursor )
     91 	.pointer/x LDZ2 .Screen/x DEO2
     92 	.pointer/y LDZ2 .Screen/y DEO2
     93 	#40 .Screen/sprite DEO
     94 
     95 	( draw new cursor )
     96 	.Mouse/x DEI2 DUP2 .pointer/x STZ2 .Screen/x DEO2
     97 	.Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2
     98 	#41 .Mouse/state DEI #01 EQU ADD .Screen/sprite DEO
     99 
    100 	.Mouse/state DEI .pointer/last LDZ
    101 	( down )
    102 	DUP2 #0100 NEQ2 ,&no-down JCN
    103 		.Mouse/x DEI2 .Mouse/y DEI2
    104 		OVR2 OVR2 .keypad-frame ;within-rect JSR2 ;click-keypad JCN2
    105 		OVR2 OVR2 .input-frame ;within-rect JSR2 ;click-input JCN2
    106 		OVR2 OVR2 .modpad-frame ;within-rect JSR2 ;click-modpad JCN2
    107 		OVR2 OVR2 .bitpad-frame ;within-rect JSR2 ;click-bitpad JCN2
    108 		;toggle-mode JSR2
    109 		POP2 POP2
    110 		&no-down
    111 	( up )
    112 	DUP2 #0001 NEQ2 ,&no-up JCN
    113 		;redraw JSR2
    114 		&no-up
    115 	POP2
    116 	( record )
    117 	.Mouse/state DEI .pointer/last STZ
    118 
    119 BRK
    120 
    121 @click-keypad ( state* x* y* -> )
    122 
    123 	( y ) .keypad-frame/y LDZ2 SUB2 #24 SFT2
    124 	( x ) SWP2 .keypad-frame/x LDZ2 SUB2 #04 SFT2 #0003 AND2
    125 	( value ) ADD2 ;keypad/layout ADD2 LDA ;push-input JSR2
    126 	#00 .Mouse/state DEO POP2
    127 
    128 BRK
    129 
    130 @click-modpad ( state* x* y* -> )
    131 
    132 	( y ) .modpad-frame/y LDZ2 SUB2 #24 SFT2 NIP STH
    133 	( x ) .modpad-frame/x LDZ2 SUB2 #04 SFT2
    134 	( lookup ) STHr ADD DUP2 ADD2 ;keypad/ops ADD2 LDA2 JSR2
    135 	;draw-bitpad JSR2
    136 	#00 .Mouse/state DEO POP2
    137 
    138 BRK
    139 
    140 @click-input ( state* x* y* -> )
    141 
    142 	POP2
    143 	.input-frame/x LDZ2 SUB2 #03 SFT2 NIP
    144 	DUP ,&no-push JCN
    145 		;do-push JSR2 &no-push
    146 	DUP #01 NEQ ,&no-pop JCN
    147 		;do-pop JSR2 &no-pop
    148 	POP
    149 	#00 .Mouse/state DEO POP2
    150 
    151 BRK
    152 
    153 @click-bitpad ( state* x* y* -> )
    154 
    155 	( y ) .bitpad-frame/y LDZ2 SUB2 #33 SFT2 NIP STH
    156 	( x ) .bitpad-frame/x LDZ2 SUB2 #03 SFT2 NIP
    157 	( value ) STHr ADD STHk
    158 
    159 	#30 ADD .Audio0/pitch DEO
    160 
    161 	( toggle bit )
    162 	.input/value LDZ2 #0001
    163 		[ STHr #0f SWP SUB ] #40 SFT SFT2 EOR2
    164 		.input/value STZ2
    165 
    166 	;draw-bitpad JSR2
    167 	#ff ;draw-input JSR2
    168 	#00 .Mouse/state DEO POP2
    169 
    170 BRK
    171 
    172 @push-input ( key -- )
    173 
    174 	DUP #50 ADD .Audio0/pitch DEO
    175 	#00 OVR ;keypad/series ADD2 LDA ;draw-keypad JSR2
    176 	( hex/dec )
    177 	#00 SWP .input/value LDZ2 #00 [ #0a #10 .input/mode LDZ JMP SWP POP ] MUL2
    178 		ADD2 .input/value STZ2
    179 	#ff ;draw-input JSR2
    180 	;draw-bitpad JSR2
    181 
    182 JMP2r
    183 
    184 @push ( value* -- )
    185 
    186 	( store ) .stack/length LDZ DUP ADD .stack/items ADD STZ2
    187 	( INCZ ) .stack/length LDZk INC SWP STZ
    188 	( reset ) #0000 .input/value STZ2
    189 	#00 ;draw-input JSR2
    190 	;draw-stack JSR2
    191 
    192 JMP2r
    193 
    194 @pop ( -- value* )
    195 
    196 	.stack/length LDZ #01 SUB DUP ADD .stack/items ADD LDZ2
    197 	( clear ) #0000 [ .stack/length LDZ #01 SUB DUP ADD .stack/items ADD ] STZ2
    198 	( DECZ ) .stack/length LDZk #01 SUB SWP STZ
    199 	#01 ;draw-input JSR2
    200 	;draw-stack JSR2
    201 
    202 JMP2r
    203 
    204 @toggle-mode ( -- )
    205 
    206 	.input/mode LDZk #00 EQU SWP STZ
    207 	#30 .Audio0/pitch DEO
    208 	;redraw JSR2
    209 
    210 JMP2r
    211 
    212 @do-push ( -- )
    213 
    214 	.input/value LDZ2 #0000 GTH2 JMP JMP2r
    215 	.stack/length LDZ #07 LTH JMP JMP2r
    216 	#40 .Audio0/pitch DEO
    217 	.input/value LDZ2 ;push JSR2
    218 	;draw-bitpad JSR2
    219 
    220 JMP2r
    221 
    222 @do-pop ( -- )
    223 
    224 	#0000 .input/value STZ2
    225 	.stack/length LDZ #00 EQU ,&continue JCN
    226 		#41 .Audio0/pitch DEO
    227 		;pop JSR2 POP2
    228 		;draw-stack JSR2
    229 		&continue
    230 	#01 ;draw-input JSR2
    231 	;draw-bitpad JSR2
    232 
    233 JMP2r
    234 
    235 @do-add ( -- )
    236 
    237 	.input/value LDZ2 #0000 EQU2 ,&no-push JCN
    238 		;do-push JSR2
    239 		&no-push
    240 
    241 	( stack empty ) .stack/length LDZ #01 GTH JMP JMP2r
    242 
    243 	#42 .Audio0/pitch DEO
    244 	#00 ;draw-modpad JSR2
    245 	;pop JSR2 ;pop JSR2 SWP2 ADD2 ;push JSR2
    246 
    247 JMP2r
    248 
    249 @do-sub ( -- )
    250 
    251 	.input/value LDZ2 #0000 EQU2 ,&no-push JCN
    252 		;do-push JSR2
    253 		&no-push
    254 
    255 	( stack empty ) .stack/length LDZ #01 GTH JMP JMP2r
    256 
    257 	#43 .Audio0/pitch DEO
    258 	#01 ;draw-modpad JSR2
    259 	;pop JSR2 ;pop JSR2 SWP2 SUB2 ;push JSR2
    260 
    261 JMP2r
    262 
    263 @do-mul ( -- )
    264 
    265 	.input/value LDZ2 #0000 EQU2 ,&no-push JCN
    266 		;do-push JSR2
    267 		&no-push
    268 
    269 	( stack empty ) .stack/length LDZ #01 GTH JMP JMP2r
    270 
    271 	#44 .Audio0/pitch DEO
    272 	#02 ;draw-modpad JSR2
    273 	;pop JSR2 ;pop JSR2 SWP2 MUL2 ;push JSR2
    274 
    275 JMP2r
    276 
    277 @do-div ( -- )
    278 
    279 	.input/value LDZ2 #0000 EQU2 ,&no-push JCN
    280 		;do-push JSR2
    281 		&no-push
    282 
    283 	( stack empty ) .stack/length LDZ #01 GTH JMP JMP2r
    284 
    285 	#45 .Audio0/pitch DEO
    286 	#03 ;draw-modpad JSR2
    287 	;pop JSR2 ;pop JSR2 SWP2 DIV2 ;push JSR2
    288 
    289 JMP2r
    290 
    291 @do-and ( -- )
    292 
    293 	.input/value LDZ2 #0000 EQU2 ,&no-push JCN
    294 		;do-push JSR2
    295 		&no-push
    296 
    297 	( stack empty ) .stack/length LDZ #01 GTH JMP JMP2r
    298 
    299 	#46 .Audio0/pitch DEO
    300 	#04 ;draw-modpad JSR2
    301 	;pop JSR2 ;pop JSR2 SWP2 AND2 ;push JSR2
    302 
    303 JMP2r
    304 
    305 @do-ora ( -- )
    306 
    307 	.input/value LDZ2 #0000 EQU2 ,&no-push JCN
    308 		;do-push JSR2
    309 		&no-push
    310 
    311 	( stack empty ) .stack/length LDZ #01 GTH JMP JMP2r
    312 
    313 	#47 .Audio0/pitch DEO
    314 	#05 ;draw-modpad JSR2
    315 	;pop JSR2 ;pop JSR2 SWP2 ORA2 ;push JSR2
    316 
    317 JMP2r
    318 
    319 @do-eor ( -- )
    320 
    321 	.input/value LDZ2 #0000 EQU2 ,&no-push JCN
    322 		;do-push JSR2
    323 		&no-push
    324 
    325 	( stack empty ) .stack/length LDZ #01 GTH JMP JMP2r
    326 
    327 	#48 .Audio0/pitch DEO
    328 	#06 ;draw-modpad JSR2
    329 	;pop JSR2 ;pop JSR2 SWP2 EOR2 ;push JSR2
    330 
    331 JMP2r
    332 
    333 @do-not ( -- )
    334 
    335 	.input/value LDZ2 #0000 EQU2 ,&no-push JCN
    336 		;do-push JSR2
    337 		&no-push
    338 
    339 	( stack empty ) .stack/length LDZ #00 GTH JMP JMP2r
    340 
    341 	#49 .Audio0/pitch DEO
    342 	#07 ;draw-modpad JSR2
    343 	;pop JSR2 #ffff EOR2 ;push JSR2
    344 
    345 JMP2r
    346 
    347 @do-erase ( -- )
    348 
    349 	.input/value LDZ2 #04 SFT2 .input/value STZ2
    350 	#ff ;draw-input JSR2
    351 	;draw-bitpad JSR2
    352 
    353 JMP2r
    354 
    355 @key-value ( key -- value )
    356 
    357 	DUP #2f GTH OVR #3a LTH #0101 NEQ2 ,&no-num JCN
    358 		#30 SUB JMP2r &no-num
    359 	DUP #60 GTH OVR #67 LTH #0101 NEQ2 ,&no-lc JCN
    360 		#57 SUB JMP2r ( #61 - #0a ADD ) &no-lc
    361 	DUP #40 GTH OVR #47 LTH #0101 NEQ2 ,&no-uc JCN
    362 		#37 SUB JMP2r ( #41 - #0a ADD ) &no-uc
    363 	POP #00
    364 
    365 JMP2r
    366 
    367 @redraw ( -- )
    368 
    369 	#ff ;draw-keypad JSR2
    370 	#ff ;draw-modpad JSR2
    371 	#ff ;draw-input JSR2
    372 	;draw-bitpad JSR2
    373 	;draw-mode JSR2
    374 	;draw-stack JSR2
    375 
    376 	#0010 .Screen/x DEO2
    377 	#0010 .Screen/y DEO2
    378 
    379 JMP2r
    380 
    381 @draw-mode ( -- )
    382 
    383 	#26 .Screen/auto DEO
    384 	.input-frame/x LDZ2 .Screen/x DEO2
    385 	.input-frame/y LDZ2 #0014 SUB2 .Screen/y DEO2
    386 	;modes #00 .input/mode LDZ #0018 MUL2 ADD2 .Screen/addr DEO2
    387 	#02 .input/mode LDZ ADD .Screen/sprite DEO
    388 	#00 .Screen/auto DEO
    389 
    390 JMP2r
    391 
    392 @draw-stack ( -- )
    393 
    394 	#08 #00
    395 	&loop
    396 		.input-frame/x LDZ2 #0018 ADD2 .Screen/x DEO2
    397 		#00 OVR #30 SFT2 .input-frame/y LDZ2 ADD2 #004c SUB2 .Screen/y DEO2
    398 		( color ) DUP #08 .stack/length LDZ SUB #01 SUB GTH STH
    399 		( value ) DUP DUP ADD .stack/items ADD [ #10 .stack/length LDZ DUP ADD SUB SUB ] LDZ2
    400 			STHr ;draw-number JSR2
    401 		INC GTHk ,&loop JCN
    402 	POP2
    403 
    404 JMP2r
    405 
    406 @draw-input ( key -- )
    407 
    408 	STH
    409 	( draw value )
    410 	.input-frame/x LDZ2 #0018 ADD2 .Screen/x DEO2
    411 	.input-frame/y LDZ2 #0003 ADD2 .Screen/y DEO2
    412 	.input/value LDZ2 #02 ;draw-number JSR2
    413 	( controls )
    414 	.input-frame/x LDZ2
    415 	.input-frame/y LDZ2
    416 	;stack-icns/push [ STHkr #00 EQU ] #02
    417 		;draw-key-thin JSR2
    418 	.input-frame/x LDZ2 #0008 ADD2
    419 	.input-frame/y LDZ2
    420 	;stack-icns/pop [ STHkr #01 EQU ] #03
    421 		;draw-key-thin JSR2
    422 	( line )
    423 	.input-frame/x LDZ2
    424 	.input-frame/x2 LDZ2
    425 	.input-frame/y LDZ2 #0004 SUB2 #02
    426 		;line-hor-dotted JSR2
    427 	POPr
    428 
    429 JMP2r
    430 
    431 @draw-keypad ( key -- )
    432 
    433 	STH
    434 	#10 #00
    435 	&loop
    436 		( color ) #00 OVR ;keypad/color ADD2 LDA STH
    437 		( state ) DUP OVRr STHr EQU STH
    438 		( layout ) #00 OVR ;keypad/layout ADD2 LDA
    439 			( layout addr ) #00 SWP #30 SFT2 ;font-hex ADD2 STH2
    440 		( x ) #00 OVR #03 AND #40 SFT2 STH2
    441 		( y ) #00 OVR #42 SFT2
    442 		( origin-x ) STH2r .keypad-frame/x LDZ2 ADD2 SWP2
    443 		( origin-y ) .keypad-frame/y LDZ2 ADD2
    444 			STH2r STHr STHr ;draw-key JSR2
    445 		INC GTHk ,&loop JCN
    446 	POP2
    447 	POPr
    448 
    449 JMP2r
    450 
    451 @draw-modpad ( key -- )
    452 
    453 	STH
    454 	#08 #00
    455 	&loop
    456 		( state ) DUP STHkr EQU STH
    457 		( glyph ) #00 OVR #30 SFT2 ;mod-icns ADD2 STH2
    458 		( y ) #00 OVR #42 SFT2 .modpad-frame/y LDZ2 ADD2 STH2
    459 		( x ) #00 OVR #03 AND #40 SFT2 .modpad-frame/x LDZ2 ADD2
    460 		STH2r STH2r STHr #03 ;draw-key JSR2
    461 		INC GTHk ,&loop JCN
    462 	POP2
    463 	POPr
    464 
    465 JMP2r
    466 
    467 @draw-bitpad ( -- )
    468 
    469 	#1000
    470 	&loop
    471 		( y ) #00 OVR #33 SFT2 .bitpad-frame/y LDZ2 ADD2 .Screen/y DEO2
    472 		( x ) #00 OVR #07 AND #30 SFT2 .bitpad-frame/x LDZ2 ADD2 .Screen/x DEO2
    473 		( state ) DUP #0f SWP SUB .input/value LDZ2 ROT SFT2 #0001 AND2
    474 		( addr ) #30 SFT2 ;bit-icns ADD2 .Screen/addr DEO2
    475 		#01 .Screen/sprite DEO
    476 		INC GTHk ,&loop JCN
    477 	POP2
    478 
    479 JMP2r
    480 
    481 @draw-key ( x* y* glyph* state color -- )
    482 
    483 	STH2
    484 	#16 .Screen/auto DEO
    485 	SWP2 .Screen/y DEO2
    486 	SWP2 .Screen/x DEO2
    487 	( bg )
    488 	;button-icns [ #00 OVRr STHr #50 SFT2 ADD2 ] .Screen/addr DEO2
    489 	STHkr .Screen/sprite DEOk DEO
    490 	( fg )
    491 	.Screen/addr DEO2
    492 	#00 .Screen/auto DEO
    493 	.Screen/y DEI2k #000d SUB2 ROT DEO2
    494 	.Screen/x DEI2k #0004 ADD2 ROT DEO2
    495 	STHr [ STHr #09 MUL ADD ] .Screen/sprite DEO
    496 
    497 JMP2r
    498 
    499 @draw-key-thin ( x* y* glyph* state color -- )
    500 
    501 	#06 .Screen/auto DEO
    502 	,&color STR ,&state STR ,&glyph STR2
    503 	( frame )
    504 	;button-thin-icns #00 [ LIT &state $1 ] #40 SFT2 ADD2 .Screen/addr DEO2
    505 	.Screen/y DEO2 .Screen/x DEO2
    506 	[ LIT &color $1 ] .Screen/sprite DEOk DEO
    507 	( glyph )
    508 	[ LIT2 &glyph $2 ] .Screen/addr DEO2
    509 	.Screen/y DEI2 #000c SUB2 .Screen/y DEO2
    510 	#05 .Screen/sprite DEO
    511 	#00 .Screen/auto DEO
    512 
    513 JMP2r
    514 
    515 @draw-number ( number* color -- )
    516 
    517 	,&color STR
    518 	( reset zero pad )
    519 	#00 ;&zero STA
    520 	( hexadecimal )
    521 	.input/mode LDZ ,&decimal JCN
    522 		#01 .Screen/auto DEO
    523 		#00 ,&digit JSR
    524 		SWP ,&byte JSR
    525 	&byte
    526 		STHk #04 SFT ,&digit JSR
    527 		STHr #0f AND 
    528 	&digit ( num -- )
    529 		,&addr JSR .Screen/addr DEO2
    530 		[ LIT &color $1 ] .Screen/sprite DEO
    531 	JMP2r
    532 	&decimal ( num* -- )
    533 		#01 .Screen/auto DEO
    534 		#2710 DIV2k DUP2 NIP ,&digit JSR MUL2 SUB2
    535 		#03e8 DIV2k DUP2 NIP ,&digit JSR MUL2 SUB2
    536 		#0064 DIV2k DUP2 NIP ,&digit JSR MUL2 SUB2 NIP
    537 		#0a DIVk DUP ,&digit JSR MUL SUB
    538 		,&digit JSR
    539 		#00 .Screen/auto DEO
    540 	JMP2r
    541 	&addr ( num -- addr* )
    542 		,&zero LDR ,&padded JCN
    543 		DUP ,&no-blank JCN
    544 			POP ;blank-icn JMP2r
    545 			&no-blank
    546 		DUP ,&zero STR
    547 		&padded #30 SFT #00 SWP ;font-hex ADD2
    548 
    549 JMP2r
    550 	&zero $1
    551 
    552 ( theme )
    553 
    554 @theme-txt ".theme $1
    555 
    556 @load-theme ( -- )
    557 
    558 	;theme-txt .File/name DEO2
    559 	#0006 .File/length DEO2
    560 	#fffa .File/read DEO2
    561 
    562 	.File/success DEI2 #0006 NEQ2 ,&ignore JCN
    563 		#fffa LDA2 .System/r DEO2
    564 		#fffc LDA2 .System/g DEO2
    565 		#fffe LDA2 .System/b DEO2
    566 		&ignore
    567 	;redraw JSR2
    568 
    569 JMP2r
    570 
    571 @within-rect ( x* y* rect -- flag )
    572 	
    573 	STH
    574 	( y < rect.y1 ) DUP2 STHkr INC INC LDZ2 LTH2 ,&skip JCN
    575 	( y > rect.y2 ) DUP2 STHkr #06 ADD LDZ2 GTH2 ,&skip JCN
    576 	SWP2
    577 	( x < rect.x1 ) DUP2 STHkr LDZ2 LTH2 ,&skip JCN
    578 	( x > rect.x2 ) DUP2 STHkr #04 ADD LDZ2 GTH2 ,&skip JCN
    579 	POP2 POP2 POPr
    580 	#01
    581 JMP2r
    582 	&skip POP2 POP2 POPr #00 JMP2r
    583 
    584 @line-hor-dotted ( x0* x1* y* color -- )
    585 	
    586 	STH .Screen/y DEO2
    587 	SWP2
    588 	&loop
    589 		( save ) DUP2 .Screen/x DEO2
    590 		( draw ) STHkr .Screen/pixel DEO
    591 		INC2 INC2 GTH2k ,&loop JCN
    592 	POP2 POP2 POPr
    593 
    594 JMP2r
    595 
    596 ( assets )
    597 
    598 @keypad
    599 	&layout
    600 	0708 090f 0405 060e 0102 030d 000a 0b0c
    601 	&series
    602 	0c08 090a 0405 0600 0102 0d0e 0f0b 0703
    603 	&color
    604 	0101 0102 0101 0102 0101 0102 0102 0202
    605 	&ops
    606 	:do-add :do-sub :do-mul :do-div
    607 	:do-and :do-ora :do-eor :do-not
    608 
    609 @sin-pcm
    610 	8083 8689 8c8f 9295 989b 9ea1 a4a7 aaad
    611 	b0b3 b6b9 bbbe c1c3 c6c9 cbce d0d2 d5d7
    612 	d9db dee0 e2e4 e6e7 e9eb ecee f0f1 f2f4
    613 	f5f6 f7f8 f9fa fbfb fcfd fdfe fefe fefe
    614 	fffe fefe fefe fdfd fcfb fbfa f9f8 f7f6
    615 	f5f4 f2f1 f0ee eceb e9e7 e6e4 e2e0 dedb
    616 	d9d7 d5d2 d0ce cbc9 c6c3 c1be bbb9 b6b3
    617 	b0ad aaa7 a4a1 9e9b 9895 928f 8c89 8683
    618 	807d 7a77 7471 6e6b 6865 625f 5c59 5653
    619 	504d 4a47 4542 3f3d 3a37 3532 302e 2b29
    620 	2725 2220 1e1c 1a19 1715 1412 100f 0e0c
    621 	0b0a 0908 0706 0505 0403 0302 0202 0202
    622 	0102 0202 0202 0303 0405 0506 0708 090a
    623 	0b0c 0e0f 1012 1415 1719 1a1c 1e20 2225
    624 	2729 2b2e 3032 3537 3a3d 3f42 4547 4a4d
    625 	5053 5659 5c5f 6265 686b 6e71 7477 7a7d
    626 
    627 @font-hex
    628 	007c 8282 8282 827c 0030 1010 1010 1010
    629 	007c 8202 7c80 80fe 007c 8202 1c02 827c
    630 	000c 1424 4484 fe04 00fe 8080 7c02 827c
    631 	007c 8280 fc82 827c 00fe 0202 0408 1010
    632 	007c 8282 7c82 827c 007c 8282 7e02 827c
    633 	007c 8202 7e82 827e 00fc 8282 fc82 82fc
    634 	007c 8280 8080 827c 00fc 8282 8282 82fc
    635 	00fe 8080 fe80 80fe 00fe 8080 f080 8080
    636 
    637 @modes
    638 	( hex )
    639 	0082 8282 fe82 8282
    640 	00fe 8080 fe80 80fe
    641 	0082 4428 1028 4482
    642 	( dec )
    643 	00fc 8282 8282 82fc
    644 	00fe 8080 fe80 80fe
    645 	007c 8280 8080 827c
    646 
    647 @mod-icns
    648 	0010 1010 fe10 1010
    649 	0000 0000 fe00 0000
    650 	0082 4428 1028 4482
    651 	0002 0408 1020 4080
    652 	0070 8888 728a 847a
    653 	0010 1010 1010 1010
    654 	0000 1028 4482 0000
    655 	0000 0060 920c 0000
    656 
    657 @button-icns
    658 	( outline )
    659 	3f40 8080 8080 8080
    660 	f804 0202 0202 0202
    661 	8080 8080 8040 3f00
    662 	0202 0202 0204 f800
    663 	( full )
    664 	3f7f ffff ffff ffff
    665 	f8fc fefe fefe fefe
    666 	ffff ffff ff7f 3f00
    667 	fefe fefe fefc f800
    668 
    669 @button-thin-icns
    670 	( outline )
    671 	3844 8282 8282 8282
    672 	8282 8282 8244 3800
    673 	( full )
    674 	387c fefe fefe fefe
    675 	fefe fefe fe7c 3800
    676 
    677 @bit-icns
    678 	( outline )
    679 	3844 8282 8244 3800
    680 	( full )
    681 	387c fefe fe7c 3800
    682 
    683 @stack-icns
    684 	&push
    685 	0000 1028 1000 0000
    686 	&pop
    687 	0000 2810 2800 0000
    688 
    689 @pointer-icn
    690 	80c0 e0f0 f8e0 1000
    691 
    692 @blank-icn