From b6bb431ac23214a5c44d9284ec28f2ca60c8d822 Mon Sep 17 00:00:00 2001 From: David Schmenk Date: Sat, 24 Feb 2018 10:28:52 -0800 Subject: [PATCH] Remove apple II-isms from sndseq --- src/libsrc/apple/sndseq.pla | 48 +++++++++++++++++++++++++++---------- src/samplesrc/playseq.pla | 2 +- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/libsrc/apple/sndseq.pla b/src/libsrc/apple/sndseq.pla index 1989cd0..52f9d39 100755 --- a/src/libsrc/apple/sndseq.pla +++ b/src/libsrc/apple/sndseq.pla @@ -67,12 +67,14 @@ predef musicStop#0 predef spkrSequence(yield, func)#0 predef a2spkrTone(pitch, duration)#0 predef a2spkrPWM(sample, speed, len)#0 +predef a2keypressed // // Static sequencer values // export word musicSequence = @spkrSequence export word spkrTone = @a2spkrTone export word spkrPWM = @a2spkrPWM +word keypressed = @a2keypressed word instr[] // Overlay with other variables word seqTrack, seqEvent, seqTime, eventTime, updateTime @@ -328,6 +330,30 @@ asm a2spkrPWM(sample, speed, len)#0 INX RTS end +asm a2keypressed + INC $004E ; rndseed + BNE + + INC $004F ++ DEX + LDY #$00 + BIT $C000 + BPL + + DEY ++ STY ESTKL,X + STY ESTKH,X + RTS +end +def a3keypressed + byte count + byte params[5] + + params.0 = 3 + params.1 = cmdsys.devcons + params.2 = 5 + params:3 = @count + syscall($82, @params) + return count +end def a3spkrTone(pitch, duration)#0 byte env @@ -591,8 +617,7 @@ def mbSequence(yield, func)#0 // seqTime++ while !(mbVIA1->IFR & $40) // Wait for T1 interrupt - if ^$C000 > 127; quit = TRUE; break; fin - *rndseed++ + if a2keypressed(); quit = TRUE; break; fin loop mbVIA1->IFR = $40 // Clear interrupt if yieldTime <= seqTime; func()#0; yieldTime = seqTime + yield; fin @@ -703,7 +728,6 @@ def spkrSequence(yield, func)#0 if notes1[i] spkrTone(periods1[i], arpeggioDuration[numNotes])#0 fin - *rndseed++ next seqTime++ else @@ -713,13 +737,12 @@ def spkrSequence(yield, func)#0 period = periods1[i] break; fin - *rndseed++ next duration = eventTime - seqTime seqTime = duration + seqTime spkrTone(period, DUR16TH * duration)#0 fin - if ^$C000 > 127; return; fin + if keypressed(); return; fin if yieldTime <= seqTime; func()#0; yieldTime = seqTime + yield; fin until FALSE end @@ -737,9 +760,8 @@ def noSequence(yield, func)#0 repeat seqTime++ if seqTime < 0; seqTime = 1; fin // Capture wrap-around - *rndseed++ - a2spkrTone(0, DUR16TH) // Waste 16th of a second playing silence - if ^$C000 > 127; return; fin + spkrTone(0, DUR16TH) // Waste 16th of a second playing silence + if keypressed(); return; fin if yield == seqTime; func()#0; seqTime = 0; fin until FALSE end @@ -782,17 +804,17 @@ end // Play until keystroke // export def musicGetKey(yield, backgroundProc)#1 - while ^$C000 < 128 + while not keypressed() musicSequence(yield, backgroundProc)#0 // Call background proc every half second loop - ^$C010 - return ^$C000 + return getc end when MACHID & MACHID_MODEL is MACHID_III - spkrTone = @a3spkrTone - spkrPWM = @a3spkrPWM + spkrTone = @a3spkrTone + spkrPWM = @a3spkrPWM + keypressed = @a3keypressed break is MACHID_I puts("Sound unsupported.\n") diff --git a/src/samplesrc/playseq.pla b/src/samplesrc/playseq.pla index f3af6c6..087dad9 100644 --- a/src/samplesrc/playseq.pla +++ b/src/samplesrc/playseq.pla @@ -12,7 +12,7 @@ word ref // Sample background process to show it's working // def backgroundProc#0 - ^$0400++ + putc('.') end arg = argNext(argFirst)