From df8bfc1d4c92bf9ae7917bed5d39aa8c82475058 Mon Sep 17 00:00:00 2001 From: Nihilazo Date: Fri, 18 Jun 2021 11:09:20 +0100 Subject: [PATCH] decouple editor from specific channel, start working on polyphony --- main.tal | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/main.tal b/main.tal index 8b37007..4b5a893 100644 --- a/main.tal +++ b/main.tal @@ -70,9 +70,19 @@ ( speed - how many ticks we play a note every ) #10 .Playback/speed STZ +( for the sake of testing, play pattern 0-3 on ch 0-3 ) #00 .Channel0/pattern-index STZ - .Channel0/pattern-index LDZ .Channel0/pattern-addr ;alloc-load-pattern JSR2 +#01 .Channel1/pattern-index STZ +.Channel1/pattern-index LDZ .Channel1/pattern-addr ;alloc-load-pattern JSR2 +#02 .Channel2/pattern-index STZ +.Channel2/pattern-index LDZ .Channel2/pattern-addr ;alloc-load-pattern JSR2 +#03 .Channel3/pattern-index STZ +.Channel3/pattern-index LDZ .Channel3/pattern-addr ;alloc-load-pattern JSR2 + +( init editor to pattern 0 ) +#00 .Edit/pattern-index STZ +.Edit/pattern-index LDZ .Edit/pattern-addr ;alloc-load-pattern JSR2 ( display/audio init ) ;on-frame .Screen/vector DEO2 @@ -97,11 +107,9 @@ BRK @get-selected-addr ( -- addr* ) ( get the address of the current selection in the pattern ) - .Channel0/pattern-addr LDZ2 #00 .Edit/selection-x LDZ ADD2 #00 .Edit/selection-y LDZ PTN_WIDTH MUL2 ADD2 + .Edit/pattern-addr LDZ2 #00 .Edit/selection-x LDZ ADD2 #00 .Edit/selection-y LDZ PTN_WIDTH MUL2 ADD2 RTN -( TODO make these relative to the channel alloc/loading to ) - @alloc-load-pattern ( index addr -- ) ( alloc a pattern and load it ) STH ( stash target addr ) DUP ( leave the index number on the stack ) @@ -210,7 +218,7 @@ RTN &end RTN -@on-button ( -> ) ( TODO fix stack overflow when doing directional inputs ) +@on-button ( -> ) .Controller/button DEI ( get button ) ;handle-cursor JSR2 .Controller/key DEI DUP @@ -224,13 +232,13 @@ RTN BRK &next POP - .Channel0/pattern-index LDZ #01 ADD .Channel0/pattern-index STZ - .Channel0/pattern-index LDZ .Channel0/pattern-addr ;alloc-load-pattern JSR2 + .Edit/pattern-index LDZ #01 ADD .Edit/pattern-index STZ + .Edit/pattern-index LDZ .Edit/pattern-addr ;alloc-load-pattern JSR2 BRK &prev POP - .Channel0/pattern-index LDZ #01 SUB .Channel0/pattern-index STZ - .Channel0/pattern-index LDZ .Channel0/pattern-addr ;alloc-load-pattern JSR2 + .Edit/pattern-index LDZ #01 SUB .Edit/pattern-index STZ + .Edit/pattern-index LDZ .Edit/pattern-addr ;alloc-load-pattern JSR2 BRK &pause POP @@ -256,6 +264,9 @@ BRK @pause ( pause playback ) #00 .Playback/tick STZ #ff .Audio0/pitch DEO + #ff .Audio1/pitch DEO + #ff .Audio2/pitch DEO + #ff .Audio3/pitch DEO ( kill audio output on all channels ) #0000 .Playback/position STZ2 RTN @@ -374,10 +385,10 @@ RTN ;draw-playhead JSR2 #0000 .Screen/x DEO2 #0000 .Screen/y DEO2 - .Channel0/pattern-index LDZ ;draw-byte JSR2 + .Edit/pattern-index LDZ ;draw-byte JSR2 .Draw/pattern-x LDZ2 .Screen/x DEO2 .Draw/pattern-y LDZ2 .Screen/y DEO2 - .Channel0/pattern-addr LDZ2 ;draw-pattern JSR2 + .Edit/pattern-addr LDZ2 ;draw-pattern JSR2 RTN @play-line ( addr ch ) ( plays the pattern line at addr on the channel ch )