1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-01-10 21:30:04 +00:00

Remove apple II-isms from sndseq

This commit is contained in:
David Schmenk 2018-02-24 10:28:52 -08:00
parent e79d17c14a
commit b6bb431ac2
2 changed files with 36 additions and 14 deletions

View File

@ -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")

View File

@ -12,7 +12,7 @@ word ref
// Sample background process to show it's working
//
def backgroundProc#0
^$0400++
putc('.')
end
arg = argNext(argFirst)