( enfer ) %RTN { JMP2r } %8+ { #0008 ADD2 } %8/ { #0008 DIV2 } %2/ { #0002 DIV2 } %2* { #0002 MUL2 } %++ { #0001 ADD2 } %TOS { #00 SWP } %MOD { DUP2 DIV MUL SUB } %VIEW-WIDTH { #0110 } %VIEW-HEIGHT { #0038 } %PRINT-BYTE { .Console/byte DEO #0d .Console/char DEO } %PRINT-SHORT { .Console/short DEO2 #0d .Console/char DEO } ( devices ) |00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] |10 @Console [ &pad $8 &char $1 &byte $1 &short $2 &string $2 ] |20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] |30 @Audio0 [ &vector $2 &output $1 &pad $5 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ] |40 @Audio1 [ &vector $2 &output $1 &pad $5 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ] |50 @Audio2 [ &vector $2 &output $1 &pad $5 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ] |60 @Audio3 [ &vector $2 &output $1 &pad $5 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ] |70 @Midi [ &vector $2 &channel $1 ¬e $1 &velocity $1 ] |80 @Controller [ &vector $2 &button $1 &key $1 ] |90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &chord $1 ] |a0 @File [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ] |b0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ] ( variables ) |0000 @addr $2 @color $1 @center [ &x $2 &y $2 ] @pointer [ &x $2 &y $2 ] @rect [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ] @knob [ &x $2 &y $2 &value $1 ] @ch0-view [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 &device $1 ] @ch1-view [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 &device $1 ] @ch2-view [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 &device $1 ] @ch3-view [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 &device $1 ] ( program ) |0100 ( -> ) ( theme ) #20fe .System/r DEO2 #c0f3 .System/g DEO2 #a0f2 .System/b DEO2 ( vectors ) ;on-mouse .Mouse/vector DEO2 ;on-frame .Screen/vector DEO2 ;on-midi .Midi/vector DEO2 ( find center ) .Screen/width DEI2 2/ .center/x POK2 .Screen/height DEI2 2/ .center/y POK2 ( place views ) .center/x PEK2 VIEW-WIDTH 2/ SUB2 .ch0-view/x1 POK2 .center/y PEK2 VIEW-HEIGHT 2* SUB2 .ch0-view/y1 POK2 .ch0-view/x1 PEK2 VIEW-WIDTH ADD2 .ch0-view/x2 POK2 .ch0-view/y1 PEK2 VIEW-HEIGHT ADD2 .ch0-view/y2 POK2 .ch0-view/x1 PEK2 .ch1-view/x1 POK2 .ch0-view/y1 PEK2 VIEW-HEIGHT ADD2 .ch1-view/y1 POK2 .ch0-view/x2 PEK2 .ch1-view/x2 POK2 .ch0-view/y2 PEK2 VIEW-HEIGHT ADD2 .ch1-view/y2 POK2 .ch1-view/x1 PEK2 .ch2-view/x1 POK2 .ch1-view/y1 PEK2 VIEW-HEIGHT ADD2 .ch2-view/y1 POK2 .ch1-view/x2 PEK2 .ch2-view/x2 POK2 .ch1-view/y2 PEK2 VIEW-HEIGHT ADD2 .ch2-view/y2 POK2 .ch2-view/x1 PEK2 .ch3-view/x1 POK2 .ch2-view/y1 PEK2 VIEW-HEIGHT ADD2 .ch3-view/y1 POK2 .ch2-view/x2 PEK2 .ch3-view/x2 POK2 .ch2-view/y2 PEK2 VIEW-HEIGHT ADD2 .ch3-view/y2 POK2 .Audio0 .ch0-view/device POK .Audio1 .ch1-view/device POK .Audio2 .ch2-view/device POK .Audio3 .ch3-view/device POK #88 .Audio0/volume DEO #88 .Audio1/volume DEO #88 .Audio2/volume DEO #88 .Audio3/volume DEO ( defaults ) ;wave0 .Audio0/addr DEO2 ;wave1 .Audio1/addr DEO2 ;wave2 .Audio2/addr DEO2 ;wave3 .Audio3/addr DEO2 #00a8 .Audio0/length DEO2 #00a8 .Audio1/length DEO2 #00a8 .Audio2/length DEO2 #00a8 .Audio3/length DEO2 #012c .Audio0/adsr DEO2 #012c .Audio1/adsr DEO2 #0113 .Audio2/adsr DEO2 #112c .Audio3/adsr DEO2 ;redraw JSR2 BRK @on-frame ( -> ) .ch0-view ;draw-meter JSR2 .ch1-view ;draw-meter JSR2 .ch2-view ;draw-meter JSR2 .ch3-view ;draw-meter JSR2 BRK @on-midi ( -> ) .Midi/note DEI #00 NEQ ,¬e-on JNZ BRK ¬e-on .Midi/note DEI .Audio0/pitch .Midi/channel DEI #04 MOD #10 MUL ADD DEO BRK @on-mouse ( -> ) ;draw-cursor JSR2 .Mouse/state DEI #00 NEQ ,&on-touch JNZ BRK &on-touch ( get channel id ) .Mouse/y DEI2 .ch0-view/y1 PEK2 SUB2 VIEW-HEIGHT DIV2 SWP POP #10 MUL .Audio0/pitch ADD #3c SWP DEO ( release ) #00 .Mouse/state DEO BRK @redraw ( -- ) .ch0-view ;draw-view JSR2 .ch1-view ;draw-view JSR2 .ch2-view ;draw-view JSR2 .ch3-view ;draw-view JSR2 RTN @draw-meter ( view* -- ) STH ( y1 ) DUPr STHr #02 ADD PEK2 .Screen/y DEO2 ( x1 ) DUPr STHr PEK2 #0010 ADD2 .Screen/x DEO2 ( device ) DUPr STHr #08 ADD PEK ( get addr ) #02 ADD DEI #04 SFT TOS #0008 MUL2 ;meter ADD2 .Screen/addr DEO2 #21 .Screen/color DEO ( x1 ) DUPr STHr PEK2 #0018 ADD2 .Screen/x DEO2 ( device ) DUPr STHr #08 ADD PEK ( get addr ) #02 ADD DEI #04 AND TOS #0008 MUL2 ;meter ADD2 .Screen/addr DEO2 #21 .Screen/color DEO POPr RTN @draw-view ( view* -- ) STH ( device id ) ( x1 ) DUPr STHr PEK2 .Screen/x DEO2 ( y1 ) DUPr STHr #02 ADD PEK2 .Screen/y DEO2 ( device ) DUPr STHr #08 ADD PEK #23 ;draw-byte JSR2 ( x1 ) DUPr STHr PEK2 #0028 ADD2 .Screen/x DEO2 ;repeat .Screen/addr DEO2 #23 .Screen/color DEO ( addr ) ( addr controls ) ( x1 ) DUPr STHr PEK2 #0060 ADD2 .Screen/x DEO2 ( device ) DUPr STHr #08 ADD PEK ( get addr ) #0c ADD DEI #21 ;draw-byte JSR2 ( x1 ) .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2 ( device ) DUPr STHr #08 ADD PEK ( get addr ) #0d ADD DEI #21 ;draw-byte JSR2 ( waveform ) ( volume knob ) ( x1 ) DUPr STHr PEK2 ( y1 ) DUPr STHr #02 ADD PEK2 #0010 ADD2 ( device ) DUPr STHr #08 ADD PEK ( get length ) #0e ADD DEI #04 SFT ;draw-knob JSR2 ( adsr knobs ) ( x1 ) DUPr STHr PEK2 #0018 ADD2 ( y1 ) DUPr STHr #02 ADD PEK2 #0010 ADD2 ( device ) DUPr STHr #08 ADD PEK ( get length ) #08 ADD DEI #04 SFT ;draw-knob JSR2 ( x1 ) DUPr STHr PEK2 #0028 ADD2 ( y1 ) DUPr STHr #02 ADD PEK2 #0010 ADD2 ( device ) DUPr STHr #08 ADD PEK ( get length ) #08 ADD DEI #0f AND ;draw-knob JSR2 ( x1 ) DUPr STHr PEK2 #0038 ADD2 ( y1 ) DUPr STHr #02 ADD PEK2 #0010 ADD2 ( device ) DUPr STHr #08 ADD PEK ( get length ) #09 ADD DEI #04 SFT ;draw-knob JSR2 ( x1 ) DUPr STHr PEK2 #0048 ADD2 ( y1 ) DUPr STHr #02 ADD PEK2 #0010 ADD2 ( device ) DUPr STHr #08 ADD PEK ( get length ) #09 ADD DEI #0f AND ;draw-knob JSR2 ( meter ) ( test button ) ( outline ) ( x1 ) DUPr STHr PEK2 #0006 SUB2 ( y1 ) DUPr STHr #02 ADD PEK2 #0006 SUB2 ( x2 ) DUPr STHr #04 ADD PEK2 ( y2 ) DUPr STHr #06 ADD PEK2 #000a SUB2 #02 ;line-rect JSR2 ( x1 ) DUPr STHr PEK2 #0060 ADD2 .Screen/x DEO2 ( waveform ) #00 #a8 &loop ( dotted line ) OVR #01 AND ,&no-dot JNZ ( y1 ) DUPr STHr #02 ADD PEK2 [ ] #0018 ADD2 .Screen/y DEO2 #03 .Screen/color DEO &no-dot OVR TOS ( device ) DUPr STHr #08 ADD PEK ( get addr ) #0c ADD DEI2 ADD2 GET #02 DIV #40 ADD DUP #07 SFT #80 MUL SUB TOS #0004 DIV2 ( y1 ) DUPr STHr #02 ADD PEK2 [ ] ADD2 #0008 ADD2 .Screen/y DEO2 .Screen/x DEI2 ++ .Screen/x DEO2 ( draw ) #01 .Screen/color DEO ( incr ) SWP #01 ADD SWP DUP2 LTH ,&loop JNZ POP2 ( loop button ) POPr RTN @draw-knob ( x* y* value -- ) ( load ) .knob/value POK .knob/y POK2 .knob/x POK2 .knob/x PEK2 .Screen/x DEO2 .knob/y PEK2 .Screen/y DEO2 ;knob_icns .Screen/addr DEO2 #21 .Screen/color DEO .knob/x PEK2 8+ .Screen/x DEO2 ;knob_icns 8+ .Screen/addr DEO2 #21 .Screen/color DEO .knob/y PEK2 8+ .Screen/y DEO2 ;knob_icns #0018 ADD2 .Screen/addr DEO2 #21 .Screen/color DEO .knob/x PEK2 .Screen/x DEO2 ;knob_icns #0010 ADD2 .Screen/addr DEO2 #21 .Screen/color DEO .knob/x PEK2 #00 #00 .knob/value PEK ;knob-offsetx ADD2 GET ADD2 .Screen/x DEO2 .knob/y PEK2 #00 #00 .knob/value PEK ;knob-offsety ADD2 GET ADD2 .Screen/y DEO2 ;knob_icns #0020 ADD2 .Screen/addr DEO2 #25 .Screen/color DEO .knob/x PEK2 #0004 ADD2 .Screen/x DEO2 .knob/y PEK2 #0010 ADD2 .Screen/y DEO2 ;font-hex #00 .knob/value PEK #08 MUL ADD2 .Screen/addr DEO2 #21 .Screen/color DEO RTN @draw-cursor ( -- ) ( clear last cursor ) ;clear .Screen/addr DEO2 .pointer/x PEK2 .Screen/x DEO2 .pointer/y PEK2 .Screen/y DEO2 #30 .Screen/color DEO ( record pointer positions ) .Mouse/x DEI2 .pointer/x POK2 .Mouse/y DEI2 .pointer/y POK2 ( draw new cursor ) ;cursor .Screen/addr DEO2 .pointer/x PEK2 .Screen/x DEO2 .pointer/y PEK2 .Screen/y DEO2 ( colorize on state ) #31 [ .Mouse/state DEI #00 NEQ ] ADD .Screen/color DEO RTN @draw-short ( short color -- ) .color POK .addr POK2 ;font-hex #00 ;addr GET #f0 AND #04 SFT #08 MUL ADD2 .Screen/addr DEO2 ( draw ) DUPr STHr .Screen/color DEO .Screen/x DEI2 8+ .Screen/x DEO2 ;font-hex #00 ;addr GET #0f AND #08 MUL ADD2 .Screen/addr DEO2 ( draw ) DUPr STHr .Screen/color DEO .Screen/x DEI2 8+ .Screen/x DEO2 ;font-hex #00 ;addr ++ GET #f0 AND #04 SFT #08 MUL ADD2 .Screen/addr DEO2 ( draw ) DUPr STHr .Screen/color DEO .Screen/x DEI2 8+ .Screen/x DEO2 ;font-hex STHr ;addr ++ GET #0f AND #08 MUL ADD2 .Screen/addr DEO2 ( draw ) #22 .Screen/color DEO RTN @draw-byte ( byte color -- ) .color POK STH ;font-hex #00 DUPr STHr #f0 AND #04 SFT #08 MUL ADD2 .Screen/addr DEO2 ( draw ) .color PEK .Screen/color DEO .Screen/x DEI2 8+ .Screen/x DEO2 ;font-hex #00 STHr #0f AND #08 MUL ADD2 .Screen/addr DEO2 ( draw ) .color PEK .Screen/color DEO RTN @line-rect ( x1 y1 x2 y2 color -- ) ( load ) .color POK DUP2 STH2 .rect/y2 POK2 .rect/x2 POK2 DUP2 STH2 .rect/y1 POK2 .rect/x1 POK2 STH2r STH2r &ver ( save ) OVR2 .Screen/y DEO2 ( draw ) .rect/x1 PEK2 .Screen/x DEO2 .color PEK DUP .Screen/color DEO ( draw ) .rect/x2 PEK2 .Screen/x DEO2 .Screen/color DEO ( incr ) SWP2 ++ SWP2 OVR2 OVR2 LTS2 ,&ver JNZ POP2 POP2 .rect/x1 PEK2 .rect/x2 PEK2 &hor ( save ) OVR2 .Screen/x DEO2 ( draw ) .rect/y1 PEK2 .Screen/y DEO2 .color PEK DUP .Screen/color DEO ( draw ) .rect/y2 PEK2 .Screen/y DEO2 .Screen/color DEO ( incr ) SWP2 ++ SWP2 OVR2 OVR2 ++ LTS2 ,&hor JNZ POP2 POP2 RTN @repeat [ 0038 4482 9282 4438 ] @clear [ 0000 0000 0000 0000 ] @cursor [ 80c0 e0f0 f8e0 1000 ] @knob_icns [ 0003 0c10 2020 4040 00c0 3008 0404 0202 4040 2020 100c 0300 0202 0404 0830 c000 0000 183c 3c18 0000 ] @knob-offsetx [ 01 00 00 00 00 01 02 03 05 06 07 08 08 08 08 07 ] @knob-offsety [ 07 06 05 03 02 01 00 00 00 00 01 02 03 05 06 07 ] @meter [ 0000 0000 0000 0000 0000 0000 0000 0070 0000 0000 0000 007e 0000 0000 0000 707e 0000 0000 0070 7e7e 0000 0000 007e 7e7e 0000 0000 707e 7e7e 0000 0000 7e7e 7e7e 0000 0070 7e7e 7e7e 0000 007e 7e7e 7e7e 0000 707e 7e7e 7e7e 0000 7e7e 7e7e 7e7e 0070 7e7e 7e7e 7e7e 007e 7e7e 7e7e 7e7e 707e 7e7e 7e7e 7e7e 7e7e 7e7e 7e7e 7e7e ] @font-hex ( 0-F ) [ 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 ] @wave0 ( 0-F ) [ 0004 090e 1217 1c20 2529 2e32 363b 3f43 474b 4e52 5659 5c60 6365 686b 6d70 7274 7677 797a 7b7c 7d7e 7e7e 7e7e 7e7e 7d7c 7b7a 7978 7674 7270 6e6b 6966 6360 5d5a 5753 4f4c 4844 403c 3833 2f2a 2621 1d18 140f 0a05 01fc f7f2 eee9 e4e0 dbd7 d2ce cac5 c1bd b9b5 b1ae aaa7 a3a0 9d9a 9795 9290 8e8c 8a88 8785 8483 8282 8181 8181 8181 8282 8384 8687 898a 8c8e 9193 9598 9b9e a1a4 a8ab afb2 b6ba bec2 c6cb cfd3 d8dc e1e6 eaef f4f8 ] @wave1 ( 0-F ) [ 0002 0406 080a 0c0e 1012 1416 181a 1c1e 2022 2426 282a 2c2e 3032 3436 383a 3c3e 4041 4345 4749 4b4d 4f51 5355 5759 5b5d 5f61 6365 6769 6b6d 6f71 7375 7779 7b7d 7f7d 7b79 7775 7371 6f6d 6b69 6765 6361 5f5d 5b59 5755 5351 4f4d 4b49 4745 4341 403e 3c3a 3836 3432 302e 2c2a 2826 2422 201e 1c1a 1816 1412 100e 0c0a 0806 0402 00fe fcfa f8f6 f4f2 f0ee ecea e8e6 e4e2 e0de dcda d8d6 d4d2 d0ce ccca c8c6 c4c2 c1bf bdbb b9b7 b5b3 ] @wave2 ( 0-F ) [ 4f4d 4b49 4745 4341 c1bf bdbb b9b7 b5b3 403e 3c3a 3836 3432 302e 2c2a 2826 2422 201e 1c1a 1816 1412 100e 0c0a 0806 0402 00fe fcfa f8f6 f4f2 f0ee ecea e8e6 e4e2 e0de dcda d8d6 d4d2 d0ce ccca c8c6 c4c2 7b7a 7978 7674 7270 6e6b 6966 6360 5d5a 5753 4f4c 4844 403c 3833 2f2a 2621 1d18 140f 0a05 01fc f7f2 eee9 e4e0 dbd7 d2ce cac5 c1bd b9b5 b1ae aaa7 a3a0 9d9a 9795 9290 8e8c 8a88 8785 8483 8282 8181 8181 8181 8282 8384 8687 898a 8c8e 9193 9598 9b9e a1a4 a8ab afb2 ] @wave3 ( 0-F ) [ 0004 090e 1217 1c20 2529 2e32 363b 3f43 5753 4f4c 4844 403c 3833 2f2a 2621 1d18 140f 0a05 01fc f7f2 eee9 e4e0 dbd7 d2ce cac5 c1bd b9b5 b1ae aaa7 a3a0 9d9a 9795 5753 4f4c 4844 403c 3833 2f2a 2621 1d18 140f 0a05 01fc f7f2 eee9 e4e0 dbd7 d2ce cac5 c1bd b9b5 b1ae aaa7 a3a0 9d9a 9795 9290 8e8c 8a88 8785 8483 8282 8181 8181 8181 8282 8384 8687 898a 8c8e 9193 9598 9b9e a1a4 a8ab afb2 b6ba bec2 c6cb cfd3 d8dc e1e6 eaef f4f8 ]