Added channel selection to dev.audio

This commit is contained in:
neauoire 2021-04-03 09:52:56 -07:00
parent 77e2f0eea9
commit da338aade1
2 changed files with 124 additions and 72 deletions

View File

@ -28,7 +28,7 @@ else
fi
echo "Assembling.."
./bin/assembler projects/software/noodle.usm bin/boot.rom
./bin/assembler projects/examples/dev.audio.usm bin/boot.rom
echo "Running.."
if [ "${2}" = '--cli' ];

View File

@ -10,11 +10,13 @@
;pointer { x 2 y 2 }
;color { byte 1 }
;rect { x1 2 y1 2 x2 2 y2 2 }
;frame { x1 2 y1 2 x2 2 y2 2 }
;trkframe { x1 2 y1 2 x2 2 y2 2 }
;chnframe { x1 2 y1 2 x2 2 y2 2 }
;ctlframe { x1 2 y1 2 x2 2 y2 2 }
;label { x 2 y 2 color 1 addr 2 }
;knob { x 2 y 2 value 1 }
;head { pos 1 }
;track { ch1 20 ch2 20 ch3 20 ch4 20 }
;track { active 1 ch1 20 ch2 20 ch3 20 ch4 20 }
( devices )
@ -38,21 +40,25 @@
( theme ) #e0fa =System.r #30fa =System.g #30fa =System.b
~Screen.width #0002 DIV2 #0080 SUB2 =frame.x1
~Screen.height #0002 DIV2 #0038 SUB2 =frame.y1
~Screen.width #0002 DIV2 #0080 ADD2 =frame.x2
~Screen.height #0002 DIV2 #0038 ADD2 =frame.y2
~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
#0438 =Audio.ch1adsr
~trkframe.x1 =chnframe.x1 ~trkframe.y2 =chnframe.y1
~chnframe.x1 #0030 ADD2 =chnframe.x2 ~chnframe.y1 #0030 ADD2 =chnframe.y2
~chnframe.x2 =ctlframe.x1 ~chnframe.y1 =ctlframe.y1
~trkframe.x2 =ctlframe.x2 ~chnframe.y2 =ctlframe.y2
#048c =Audio.ch1adsr
#159d =Audio.ch2adsr
#26ae =Audio.ch3adsr
#37bf =Audio.ch4adsr
,draw-timeline JSR2
,draw-controls JSR2
~frame.x1 #0028 SUB2 ~frame.y2 #0010 ADD2 #06 ,ch1_txt ,draw-label JSR2
~frame.x1 #0028 SUB2 ~frame.y2 #0018 ADD2 #01 ,ch2_txt ,draw-label JSR2
~frame.x1 #0028 SUB2 ~frame.y2 #0020 ADD2 #01 ,ch3_txt ,draw-label JSR2
~frame.x1 #0028 SUB2 ~frame.y2 #0028 ADD2 #01 ,ch4_txt ,draw-label JSR2
,draw-channels JSR2
BRK
@ -63,28 +69,36 @@ BRK
~head.pos #08 MOD #00 NEQ ^$skip JNZ
,bang JSR2
,draw-position JSR2
$skip
~Mouse.state #00 EQU ,$click-end JNZ2
~Mouse.x ~frame.x1 GTH2 ~Mouse.x ~frame.x2 LTH2 #0101 EQU2
~Mouse.y ~frame.y1 GTH2 ~Mouse.y ~frame.y2 LTH2 #0101 EQU2
~Mouse.x ~trkframe.x1 GTH2 ~Mouse.x ~trkframe.x2 LTH2 #0101 EQU2
~Mouse.y ~trkframe.y1 GTH2 ~Mouse.y ~trkframe.y2 LTH2 #0101 EQU2
#0101 NEQ2 ,$no-track-click JNZ2
,clear-notes JSR2
( get note )
#0e ~Mouse.y ~frame.y1 SUB2 SWP POP #08 DIV SUB
#0e ~Mouse.y ~trkframe.y1 SUB2 SWP POP #08 DIV SUB
~Mouse.state #10 NEQ ^$no-erase JNZ
POP #00
$no-erase
( get track )
,track.ch1 #00 ~Mouse.x ~frame.x1 SUB2 SWP POP #08 DIV ADD2
,get-track JSR2 #00 ~Mouse.x ~trkframe.x1 SUB2 SWP POP #08 DIV ADD2
POK2
( release ) #00 =Mouse.state
,draw-notes JSR2
,draw-bars JSR2
$no-track-click
~Mouse.x ~chnframe.x1 GTH2 ~Mouse.x ~chnframe.x2 LTH2 #0101 EQU2
~Mouse.y ~chnframe.y1 #0008 ADD2 GTH2 ~Mouse.y ~chnframe.y2 #0008 SUB2 LTH2 #0101 EQU2
#0101 NEQ2 ,$no-channel-click JNZ2
,clear-notes JSR2
~Mouse.y ~chnframe.y1 SUB2 SWP POP #08 DIV #01 SUB =track.active
( release ) #00 =Mouse.state
,draw-channels JSR2
,draw-notes JSR2
$no-channel-click
$click-end
BRK
@ -93,41 +107,62 @@ BRK
BRK
@get-track ( -- track-addr )
,track.ch1 #00 ~track.active #0020 MUL2 ADD2
RTN
@bang ( -- )
( load )
,track.ch1 #00 ~head.pos #08 DIV ADD2 PEK2
#01 SUB
DUP #ff NEQ ^$skip JNZ
POP RTN
$skip
DUP #ff NEQ ^$skip1 JNZ
POP ^$listen2 JMP
$skip1
#00 SWP ,notes ADD2 PEK2
#0c #03 MUL SUB =Audio.ch1pitch
#11 =Audio.ch1vol
$listen2
,track.ch2 #00 ~head.pos #08 DIV ADD2 PEK2
#01 SUB
DUP #ff NEQ ^$skip2 JNZ
POP ^$listen3 JMP
$skip2
#00 SWP ,notes ADD2 PEK2
#0c #03 MUL SUB =Audio.ch2pitch
#11 =Audio.ch2vol
$listen3
,track.ch3 #00 ~head.pos #08 DIV ADD2 PEK2
#01 SUB
DUP #ff NEQ ^$skip3 JNZ
POP ^$end JMP
$skip3
#00 SWP ,notes ADD2 PEK2
#0c #03 MUL SUB =Audio.ch3pitch
#11 =Audio.ch3vol
$end
RTN
@move-head ( -- )
( clear )
~frame.y1 #0008 SUB2 =Sprite.y
~frame.x1 #00 ~head.pos ADD2 =Sprite.x
~trkframe.y1 #0008 SUB2 =Sprite.y
~trkframe.x1 #00 ~head.pos ADD2 =Sprite.x
,head_icn =Sprite.addr
#00 =Sprite.color
( incr ) ~head.pos #01 ADD =head.pos
( draw )
~frame.x1 #00 ~head.pos ADD2 =Sprite.x
~trkframe.x1 #00 ~head.pos ADD2 =Sprite.x
,head_icn =Sprite.addr
#01 =Sprite.color
RTN
@draw-position ( -- )
~frame.x2 #0008 SUB2 =Sprite.x
~frame.y1 #0010 SUB2 =Sprite.y
,font_hex #00 ~head.pos #10 DIV #0008 MUL2 ADD2 =Sprite.addr
#01 =Sprite.color
#01
( if note ) ,get-track JSR2 #00 ~head.pos #08 DIV ADD2 PEK2 #00 NEQ ADD
=Sprite.color
RTN
@ -135,10 +170,12 @@ RTN
#00 #20
$loop
( load ) OVR #00 SWP ,track.ch1 ADD2 PEK2
#00 SWP #0e SWP SUB #0008 MUL2 ~frame.y1 ADD2 =Sprite.y
OVR #00 SWP #0008 MUL2 ~frame.x1 ADD2 =Sprite.x
#00 =Sprite.color
( load ) OVR #00 SWP ,get-track JSR2 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
#00 =Sprite.color
$skip
( incr ) SWP #01 ADD SWP
DUP2 LTH ^$loop JNZ
POP2
@ -149,41 +186,42 @@ RTN
#00 #20
$notes-loop
( load ) OVR #00 SWP ,track.ch1 ADD2 PEK2
DUP STH #00 SWP #0e SWP SUB #0008 MUL2 ~frame.y1 ADD2 =Sprite.y
OVR #00 SWP #0008 MUL2 ~frame.x1 ADD2 =Sprite.x
( load ) OVR #00 SWP ,get-track JSR2 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
,note2_icn =Sprite.addr
#02 STHr #00 EQU SUB =Sprite.color
STHr #00 EQU ^$skip JNZ
#05 =Sprite.color
$skip
( incr ) SWP #01 ADD SWP
DUP2 LTH ^$notes-loop JNZ
POP2
,draw-bars JSR2
RTN
@draw-bars ( -- )
( draw notes )
~frame.x1 ~frame.y1 ~frame.x2 ~frame.y2 #01 ,line-rect JSR2
~trkframe.x1 ~trkframe.y1 ~trkframe.x2 ~trkframe.y2 #01 ,line-rect JSR2
( grid )
~frame.y1 #0010 SUB2 =Sprite.y
~trkframe.y1 #0010 SUB2 =Sprite.y
,font_hex =Sprite.addr
#0000 #0100
$loop
OVR2 SWP POP #02 DIV #0f AND #00 NEQ ^$skip JNZ
OVR2 ~frame.x1 ADD2 =Sprite.x
OVR2 ~trkframe.x1 ADD2 =Sprite.x
#01 =Sprite.color
~Sprite.addr 8+ =Sprite.addr
OVR2 ~frame.x1 ADD2 ~frame.y1 #0001 ADD2 ~frame.y2 #01 ,line-vertical-dotted JSR2
OVR2 ~trkframe.x1 ADD2 ~trkframe.y1 #0001 ADD2 ~trkframe.y2 #01 ,line-vertical-dotted JSR2
$skip
OVR2 ~frame.x1 ADD2 ~frame.y1 ~frame.y2 #01 ,line-vertical-dotted JSR2
OVR2 ~trkframe.x1 ADD2 ~trkframe.y1 ~trkframe.y2 #01 ,line-vertical-dotted JSR2
SWP2 #0008 ADD2 SWP2
OVR2 OVR2 LTH2 ^$loop JNZ
POP2
POP2
~frame.x1 ~frame.x2 ~frame.y1 #0008 SUB2 #0040 ADD2 #01 ,line-horizontal-dotted JSR2
~trkframe.x1 ~trkframe.x2 ~trkframe.y1 #0008 SUB2 #0040 ADD2 #01 ,line-horizontal-dotted JSR2
RTN
@ -211,20 +249,20 @@ RTN
@draw-octaves ( -- )
~frame.x1 #0018 SUB2 ~frame.y1 ,draw-octave JSR2
~frame.x1 #0018 SUB2 ~frame.y1 #0038 ADD2 ,draw-octave JSR2
~frame.x1 #0028 SUB2 =Sprite.x
~frame.y1 =Sprite.y
~trkframe.x1 #0018 SUB2 ~trkframe.y1 ,draw-octave JSR2
~trkframe.x1 #0018 SUB2 ~trkframe.y1 #0038 ADD2 ,draw-octave JSR2
~trkframe.x1 #0028 SUB2 =Sprite.x
~trkframe.y1 =Sprite.y
,font_hex #0060 ADD2 =Sprite.addr
#01 =Sprite.color
~frame.x1 #0030 SUB2 =Sprite.x
~trkframe.x1 #0030 SUB2 =Sprite.x
,font_hex #0020 ADD2 =Sprite.addr
#01 =Sprite.color
~frame.x1 #0028 SUB2 =Sprite.x
~frame.y1 #0038 ADD2 =Sprite.y
~trkframe.x1 #0028 SUB2 =Sprite.x
~trkframe.y1 #0038 ADD2 =Sprite.y
,font_hex #0060 ADD2 =Sprite.addr
#01 =Sprite.color
~frame.x1 #0030 SUB2 =Sprite.x
~trkframe.x1 #0030 SUB2 =Sprite.x
,font_hex #0018 ADD2 =Sprite.addr
#01 =Sprite.color
@ -274,17 +312,31 @@ RTN
@draw-controls ( -- )
~frame.x1 #0000 ADD2 ~frame.y2 #0010 ADD2 #01 ,env_txt ,draw-label JSR2
~ctlframe.x1 ~ctlframe.y1 ~ctlframe.x2 ~ctlframe.y2 #01 ,line-rect JSR2
~frame.x1 #0000 ADD2 ~frame.y2 #0020 ADD2 #00 ,draw-knob JSR2
~frame.x1 #0010 ADD2 ~frame.y2 #0020 ADD2 #02 ,draw-knob JSR2
~frame.x1 #0020 ADD2 ~frame.y2 #0020 ADD2 #0a ,draw-knob JSR2
~frame.x1 #0030 ADD2 ~frame.y2 #0020 ADD2 #0c ,draw-knob JSR2
~ctlframe.x1 #0008 ADD2 ~ctlframe.y1 #0008 ADD2 #01 ,env_txt ,draw-label JSR2
~frame.x1 #0050 ADD2 ~frame.y2 #0010 ADD2 #01 ,vol_txt ,draw-label JSR2
~ctlframe.x1 #0008 ADD2 ~ctlframe.y1 #0010 ADD2 #00 ,draw-knob JSR2
~ctlframe.x1 #0018 ADD2 ~ctlframe.y1 #0010 ADD2 #02 ,draw-knob JSR2
~ctlframe.x1 #0028 ADD2 ~ctlframe.y1 #0010 ADD2 #0a ,draw-knob JSR2
~ctlframe.x1 #0038 ADD2 ~ctlframe.y1 #0010 ADD2 #0c ,draw-knob JSR2
~frame.x1 #0050 ADD2 ~frame.y2 #0020 ADD2 #00 ,draw-knob JSR2
~frame.x1 #0060 ADD2 ~frame.y2 #0020 ADD2 #0f ,draw-knob JSR2
~ctlframe.x1 #0050 ADD2 ~ctlframe.y1 #0008 ADD2 #01 ,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
RTN
@draw-channels
~chnframe.x1 ~chnframe.y1 ~chnframe.x2 ~chnframe.y2 #01 ,line-rect JSR2
~track.active =Console.byte
~chnframe.x1 #0008 ADD2 ~chnframe.y1 #0008 ADD2 #01 ~track.active #00 EQU #07 MUL ADD ,ch1_txt ,draw-label JSR2
~chnframe.x1 #0008 ADD2 ~chnframe.y1 #0010 ADD2 #01 ~track.active #01 EQU #07 MUL ADD ,ch2_txt ,draw-label JSR2
~chnframe.x1 #0008 ADD2 ~chnframe.y1 #0018 ADD2 #01 ~track.active #02 EQU #07 MUL ADD ,ch3_txt ,draw-label JSR2
~chnframe.x1 #0008 ADD2 ~chnframe.y1 #0020 ADD2 #01 ~track.active #03 EQU #07 MUL ADD ,ch4_txt ,draw-label JSR2
RTN
@ -368,10 +420,10 @@ RTN
@note2_icn [ 0000 1c3e 3e3e 1c00 ]
@head_icn [ 0018 1818 7e3c 1800 ]
@ch1_txt [ SQR1 00 ]
@ch2_txt [ SQR2 00 ]
@ch3_txt [ TRI3 00 ]
@ch4_txt [ WAV4 00 ]
@ch1_txt [ CHN0 00 ]
@ch2_txt [ CHN1 00 ]
@ch3_txt [ CHN2 00 ]
@ch4_txt [ CHN3 00 ]
@env_txt [ Envelope 00 ]
@vol_txt [ Volume 00 ]