diff --git a/projects/examples/dev.audio.usm b/projects/examples/dev.audio.usm index a0d7847..3e5aa35 100644 --- a/projects/examples/dev.audio.usm +++ b/projects/examples/dev.audio.usm @@ -4,6 +4,7 @@ %8+ { #0008 ADD2 } %8- { #0008 SUB2 } %++ { #0001 ADD2 } %MOD { DUP2 DIV MUL SUB } +%TRACK { ,track.ch1 #00 ~track.active #0020 MUL2 ADD2 } ( variables ) @@ -17,7 +18,6 @@ ;knob { x 2 y 2 value 1 } ;head { pos 1 } ;track { active 1 ch1 20 ch2 20 ch3 20 ch4 20 } -;pt { x 1 y 1 } ( devices ) @@ -41,10 +41,10 @@ ( theme ) #e0fa =System.r #30fa =System.g #30fa =System.b - ~Screen.width #0002 DIV2 #0080 SUB2 =trkframe.x1 - ~Screen.height #0002 DIV2 #0038 SUB2 #0010 SUB2 =trkframe.y1 - ~Screen.width #0002 DIV2 #0080 ADD2 =trkframe.x2 - ~Screen.height #0002 DIV2 #0038 ADD2 #0010 SUB2 =trkframe.y2 + ~Screen.width #0002 DIV2 DUP2 #0080 SUB2 =trkframe.x1 + #0080 ADD2 =trkframe.x2 + ~Screen.height #0002 DIV2 DUP2 #0038 SUB2 #0010 SUB2 =trkframe.y1 + #0038 ADD2 #0010 SUB2 =trkframe.y2 ~trkframe.x1 =chnframe.x1 ~trkframe.y2 =chnframe.y1 ~chnframe.x1 #0030 ADD2 =chnframe.x2 ~chnframe.y1 #0030 ADD2 =chnframe.y2 @@ -52,6 +52,7 @@ ~chnframe.x2 =ctlframe.x1 ~chnframe.y1 =ctlframe.y1 ~trkframe.x2 =ctlframe.x2 ~chnframe.y2 =ctlframe.y2 + ( default envs ) #048c =Audio.ch1adsr #159d =Audio.ch2adsr #26ae =Audio.ch3adsr @@ -94,12 +95,9 @@ BRK ,clear-notes JSR2 ( get note ) #0e ~Mouse.y ~trkframe.y1 SUB2 SWP POP #08 DIV SUB - ~Mouse.state #10 NEQ ^$no-erase JNZ - POP #00 - $no-erase - ( get track ) - ,get-track JSR2 #00 ~Mouse.x ~trkframe.x1 SUB2 SWP POP #08 DIV ADD2 - POK2 + ~Mouse.state #10 NEQ ^$no-erase JNZ POP #00 $no-erase + ( edit note ) + TRACK #00 ~Mouse.x ~trkframe.x1 SUB2 SWP POP #08 DIV ADD2 POK2 ( release ) #00 =Mouse.state ,draw-notes JSR2 @@ -108,7 +106,7 @@ BRK @touch-chn ( -- ) ,clear-notes JSR2 - ~Mouse.y ~chnframe.y1 SUB2 SWP POP #08 DIV #01 SUB =track.active + ( save ) ~Mouse.y ~chnframe.y1 SUB2 SWP POP #08 DIV #01 SUB =track.active ( release ) #00 =Mouse.state ,draw-channels JSR2 ,draw-notes JSR2 @@ -118,43 +116,30 @@ BRK @touch-ctl ( -- ) - ~Mouse.x ~ctlframe.x1 SUB2 #0008 SUB2 #0008 DIV2 SWP POP #02 DIV =pt.x - ~Mouse.y ~ctlframe.y1 SUB2 #0008 SUB2 #0008 DIV2 SWP POP #02 DIV =pt.y - - ~pt.x #00 NEQ ^$no-a JNZ + ~Mouse.x ~ctlframe.x1 SUB2 #0008 SUB2 #0008 DIV2 SWP POP #02 DIV + DUP #00 NEQ ^$no-a JNZ ,Audio #00 ~track.active #02 MUL ADD2 PEK2 - #10 ADD ,Audio #00 ~track.active #02 MUL ADD2 POK2 - $no-a + #10 ADD ,Audio #00 ~track.active #02 MUL ADD2 POK2 $no-a - ~pt.x #01 NEQ ^$no-d JNZ + DUP #01 NEQ ^$no-d JNZ ,Audio #00 ~track.active #02 MUL ADD2 PEK2 DUP #f0 AND STH #01 ADD #0f AND STHr ADD - ,Audio #00 ~track.active #02 MUL ADD2 POK2 - $no-d + ,Audio #00 ~track.active #02 MUL ADD2 POK2 $no-d - ~pt.x #02 NEQ ^$no-s JNZ + DUP #02 NEQ ^$no-s JNZ ,Audio #00 ~track.active #02 MUL ADD2 #0001 ADD2 PEK2 - #10 ADD ,Audio #00 ~track.active #02 MUL ADD2 #0001 ADD2 POK2 - $no-s + #10 ADD ,Audio #00 ~track.active #02 MUL ADD2 #0001 ADD2 POK2 $no-s - ~pt.x #03 NEQ ^$no-r JNZ + DUP #03 NEQ ^$no-r JNZ ,Audio #00 ~track.active #02 MUL ADD2 #0001 ADD2 PEK2 DUP #f0 AND STH #01 ADD #0f AND STHr ADD - ,Audio #00 ~track.active #02 MUL ADD2 #0001 ADD2 POK2 - $no-r - + ,Audio #00 ~track.active #02 MUL ADD2 #0001 ADD2 POK2 $no-r + POP ( release ) #00 =Mouse.state - ,draw-controls JSR2 BRK -@get-track ( -- track-addr ) - - ,track.ch1 #00 ~track.active #0020 MUL2 ADD2 - -RTN - @bang ( -- ) ,track.ch1 #00 ~head.pos #08 DIV ADD2 PEK2 @@ -198,13 +183,9 @@ RTN ,head_icn =Sprite.addr #00 =Sprite.color ( incr ) ~head.pos #01 ADD =head.pos - ( draw ) ~trkframe.x1 #00 ~head.pos ADD2 =Sprite.x - ,head_icn =Sprite.addr - - #01 - ( if note ) ,get-track JSR2 #00 ~head.pos #08 DIV ADD2 PEK2 #00 NEQ ADD - =Sprite.color + ,head_icn =Sprite.addr + #01 ( if note ) TRACK #00 ~head.pos #08 DIV ADD2 PEK2 #00 NEQ ADD =Sprite.color RTN @@ -212,7 +193,7 @@ RTN #00 #20 $loop - ( load ) OVR #00 SWP ,get-track JSR2 ADD2 PEK2 + ( load ) OVR #00 SWP TRACK ADD2 PEK2 DUP STH #00 SWP #0e SWP SUB #0008 MUL2 ~trkframe.y1 ADD2 =Sprite.y OVR #00 SWP #0008 MUL2 ~trkframe.x1 ADD2 =Sprite.x STHr #00 EQU ^$skip JNZ @@ -228,7 +209,7 @@ RTN #00 #20 $notes-loop - ( load ) OVR #00 SWP ,get-track JSR2 ADD2 PEK2 + ( load ) OVR #00 SWP TRACK ADD2 PEK2 DUP STH #00 SWP #0e SWP SUB #0008 MUL2 ~trkframe.y1 ADD2 =Sprite.y OVR #00 SWP #0008 MUL2 ~trkframe.x1 ADD2 =Sprite.x ,note_icn =Sprite.addr @@ -272,7 +253,6 @@ RTN =Sprite.y =Sprite.x ,octave_icn =Sprite.addr - ~Sprite.y ~Sprite.y #0038 ADD2 $loop OVR2 =Sprite.y @@ -291,8 +271,8 @@ RTN @draw-octaves ( -- ) - ~trkframe.x1 #0018 SUB2 ~trkframe.y1 ,draw-octave JSR2 - ~trkframe.x1 #0018 SUB2 ~trkframe.y1 #0038 ADD2 ,draw-octave JSR2 + ~trkframe.x1 #0018 SUB2 DUP2 ~trkframe.y1 ,draw-octave JSR2 + ~trkframe.y1 #0038 ADD2 ,draw-octave JSR2 ~trkframe.x1 #0028 SUB2 =Sprite.x ~trkframe.y1 =Sprite.y ,font_hex #0060 ADD2 =Sprite.addr @@ -319,21 +299,16 @@ RTN @draw-knob ( x* y* value -- ) - =knob.value - =knob.y - =knob.x - + ( load ) =knob.value =knob.y =knob.x ~knob.x =Sprite.x ~knob.y =Sprite.y ,knob_icns =Sprite.addr #01 =Sprite.color ~knob.x 8+ =Sprite.x ,knob_icns 8+ =Sprite.addr #01 =Sprite.color ~knob.y 8+ =Sprite.y ,knob_icns #0018 ADD2 =Sprite.addr #01 =Sprite.color ~knob.x =Sprite.x ,knob_icns #0010 ADD2 =Sprite.addr #01 =Sprite.color - ~knob.x #00 #00 ~knob.value ,knob_offsetx ADD2 PEK2 ADD2 =Sprite.x ~knob.y #00 #00 ~knob.value ,knob_offsety ADD2 PEK2 ADD2 =Sprite.y ,knob_icns #0020 ADD2 =Sprite.addr #05 =Sprite.color - ~knob.x #0004 ADD2 =Sprite.x ~knob.y #0010 ADD2 =Sprite.y ,font_hex #00 ~knob.value #08 MUL ADD2 =Sprite.addr @@ -344,26 +319,20 @@ RTN @draw-controls ( -- ) ~ctlframe.x1 ~ctlframe.y1 ~ctlframe.x2 ~ctlframe.y2 #01 ,line-rect JSR2 - ~ctlframe.x1 #0008 ADD2 ~ctlframe.y1 #0008 ADD2 #02 ,env_txt ,draw-label JSR2 - ~ctlframe.x1 #0008 ADD2 ~ctlframe.y1 #0010 ADD2 ,Audio #00 ~track.active #02 MUL ADD2 PEK2 #04 SFT - ,draw-knob JSR2 - + ,draw-knob JSR2 ~ctlframe.x1 #0018 ADD2 ~ctlframe.y1 #0010 ADD2 ,Audio #00 ~track.active #02 MUL ADD2 PEK2 #0f AND - ,draw-knob JSR2 - + ,draw-knob JSR2 ~ctlframe.x1 #0028 ADD2 ~ctlframe.y1 #0010 ADD2 ,Audio #00 ~track.active #02 MUL ADD2 #0001 ADD2 PEK2 #04 SFT - ,draw-knob JSR2 + ,draw-knob JSR2 ~ctlframe.x1 #0038 ADD2 ~ctlframe.y1 #0010 ADD2 ,Audio #00 ~track.active #02 MUL ADD2 #0001 ADD2 PEK2 #0f AND - ,draw-knob JSR2 - + ,draw-knob JSR2 ~ctlframe.x1 #0050 ADD2 ~ctlframe.y1 #0008 ADD2 #02 ,vol_txt ,draw-label JSR2 - ~ctlframe.x1 #0050 ADD2 ~ctlframe.y1 #0010 ADD2 #00 ,draw-knob JSR2 ~ctlframe.x1 #0060 ADD2 ~ctlframe.y1 #0010 ADD2 #0f ,draw-knob JSR2 @@ -386,10 +355,8 @@ RTN ~pointer.x =Sprite.x ~pointer.y =Sprite.y #10 =Sprite.color - ( record pointer positions ) ~Mouse.x =pointer.x ~Mouse.y =pointer.y - ( draw new cursor ) ,cursor_icn =Sprite.addr ~pointer.x =Sprite.x @@ -452,12 +419,6 @@ RTN RTN -@clear_icn [ 0000 0000 0000 0000 ] -@cursor_icn [ 80c0 e0f0 f8e0 1000 ] - -@note_icn [ 0000 1c3e 3e3e 1c00 ] -@head_icn [ 0018 1818 7e3c 1800 ] - @ch1_txt [ CHN0 00 ] @ch2_txt [ CHN1 00 ] @ch3_txt [ CHN2 00 ] @@ -465,6 +426,11 @@ RTN @env_txt [ Envelope 00 ] @vol_txt [ Volume 00 ] +@clear_icn [ 0000 0000 0000 0000 ] +@cursor_icn [ 80c0 e0f0 f8e0 1000 ] +@note_icn [ 0000 1c3e 3e3e 1c00 ] +@head_icn [ 0018 1818 7e3c 1800 ] + @notes [ 60 62 64 65 67 69 71 72 74 76 77 79 81 83 @@ -478,16 +444,6 @@ RTN 0000 183c 3c18 0000 ] -@piano-white [ - ffc0 8080 80c0 ff00 - fc02 0202 0202 fc00 -] - -@piano-black [ - ffff fefe feff ff00 - f008 0808 0808 f000 -] - @octave_icn [ ff00 0000 fefe fffe ff01 0101 0102 fc00 @@ -505,14 +461,14 @@ RTN ff01 0101 0102 fc00 ] -@knob_offsetx -[ - 04 05 06 07 08 07 06 05 04 04 03 02 01 00 01 02 03 +@knob_offsetx [ + 04 05 06 07 08 07 06 05 + 04 04 03 02 01 00 01 02 ] -@knob_offsety -[ - 00 01 02 03 04 05 06 07 08 07 06 05 04 04 03 02 01 +@knob_offsety [ + 00 01 02 03 04 05 06 07 + 08 07 06 05 04 04 03 02 ] @font_hex ( 0-F )