From aa6224c14008b4b420475ddd0203fba7c06e1c6b Mon Sep 17 00:00:00 2001 From: David Schmenk Date: Wed, 1 Nov 2017 14:07:56 -0700 Subject: [PATCH] Remove interrupt enable for MB --- src/mockingboard/mbtest.pla | 174 ++++++++++++++++++------------------ 1 file changed, 85 insertions(+), 89 deletions(-) diff --git a/src/mockingboard/mbtest.pla b/src/mockingboard/mbtest.pla index 6f77108..6916338 100755 --- a/src/mockingboard/mbtest.pla +++ b/src/mockingboard/mbtest.pla @@ -52,13 +52,6 @@ struc t_event byte perchanvol // Percussion ? EnvDur:7-0 : Channel:7,Volume:3-0 end // -// Tone test sequence -// -byte[] toneTrack -include "test.seq" -byte = $00 // Stop -byte = $00, 00 -// // Octave Basis Frequencies (starting at MIDI note #12) // Notes will be encoded as basis note (LSNibble) and octave (MSNibble)) // @@ -73,6 +66,12 @@ word heap word[] mbVIAs // Treat this as an array of VIA ptrs word mbVIA1, mbVIA2 // +// Tone test sequence +// +asm toneTrack +include "test.seq" +end +// // Write PSG Registers // asm psgWriteTone(pVIA, reg, freq, vol)#0 @@ -197,9 +196,9 @@ asm getStatus#1 end asm setStatus(stat)#0 LDA ESTKL,X + INX PHA PLP - DEX RTS end asm disableInts#0 @@ -272,7 +271,7 @@ end // def mbInstallIRQ#0 byte params[4] - + params.0 = 2 params.1 = 1 params:2 = @mbIRQ @@ -280,7 +279,7 @@ def mbInstallIRQ#0 end def mbUninstallIRQ#0 byte params[2] - + params.0 = 1 params.1 = 1 syscall($41, @params) @@ -335,7 +334,7 @@ def mbSearch return 0 end def psgSetup(pVIA) - psgWrite(pVIA, MIXER, $00) // Turn everything off + psgWrite(pVIA, MIXER, $3F) // Turn everything off psgWrite(pVIA, AENVAMP, $00) psgWrite(pVIA, BENVAMP, $00) psgWrite(pVIA, CENVAMP, $10) @@ -399,94 +398,92 @@ def mbSequence(track) mbVIA1=>T1L = $F9C2 // 16 Ints/sec mbVIA1=>T1C = $F9C2 // 16 Ints/sec mbVIA1->IFR = $40 // Clear interrupt - mbVIA1->IER = $C0 // Enable Timer1 interrupt +// mbVIA1->IER = $C0 // Enable Timer1 interrupt //enableInts repeat //puts("seqTime = "); puti(seqTime); puts(" eventTime = "); puti(eventTime); putln - if eventTime <= seqTime - repeat - note = seqEvent->percnote - if note & $80 + while eventTime == seqTime + note = seqEvent->percnote + if note & $80 + // + // Note event + // + volume = seqEvent->perchanvol + channel = (volume & mbVIA2.LSB) >> 7 // Clever - mbVIA2.0 will be $80 if it exists + if volume & $0F // - // Note event + // Note on // - volume = seqEvent->perchanvol - channel = (volume & mbVIA2.LSB) >> 7 // Clever - mbVIA2.0 will be $80 if it exists - if volume & $0F + for i = 0 to MAX_CHAN_NOTES-1 // - // Note on + // Look for available slot in active note table // - for i = 0 to MAX_CHAN_NOTES-1 - // - // Look for available slot in active note table - // - if !notes[channel, i].LSB //or notes[channel, i] == note - break - fin - next - // - // Full note table, kick one out - // - if i == MAX_CHAN_NOTES - i = overflow - overflow = (overflow + 1) % MAX_CHAN_NOTES - //puts("Full note table on channel: "); puti(channel); putln - else - numNotes++ + if !notes[channel, i].LSB //or notes[channel, i] == note + break fin - notes[channel, i] = note | (volume << 8) - periods[channel, i] = mbOctave0[note & $0F] >> ((note >> 4) & $07) - //puts("Insert note ");puti((note>>4)&$7);putc(':');puti(note&$0F) - //puts(" in table[");puti(channel);putc(',');puti(i);puts("]\n") + next + // + // Full note table, kick one out + // + if i == MAX_CHAN_NOTES + i = overflow + overflow = (overflow + 1) % MAX_CHAN_NOTES + //puts("Full note table on channel: "); puti(channel); putln else - // - // Note off - // - for i = 0 to MAX_CHAN_NOTES-1 - // - // Remove from active note table - // - if notes[channel, i].LSB == note - notes[channel, i] = 0 - numNotes-- - break - fin - next - //puts("Remove note ");puti((note>>4)&$7);putc(':');puti(note&$0F) - //puts(" from table[");puti(channel);putc(',');puti(i);puts("]\n") + numNotes++ fin - updateTime = seqTime + notes[channel, i] = note | (volume << 8) + periods[channel, i] = mbOctave0[note & $0F] >> ((note >> 4) & $07) + //puts("Insert note ");puti((note>>4)&$7);putc(':');puti(note&$0F) + //puts(" in table[");puti(channel);putc(',');puti(i);puts("]\n") else // - // Percussion event + // Note off // - period = seqEvent->perchanvol - if period - psgWrite(mbVIA1, MIXER, $1C) // NG on C, Tone on B, A - psgWrite(mbVIA1, CENVAMP, $10) - psgWrite(mbVIA1, NGFREQ, note) - psgWrite(mbVIA1, ENVPERIOD+1, period) - psgWrite(mbVIA1, ENVSHAPE, $00) // Single decay - if mbVIA2 - psgWrite(mbVIA2, MIXER, $1C) // NG on C, Tone on B, A - psgWrite(mbVIA2, CENVAMP, $10) - psgWrite(mbVIA2, NGFREQ, note) - psgWrite(mbVIA2, ENVPERIOD+1, period) - psgWrite(mbVIA2, ENVSHAPE, $00) // Single decay + for i = 0 to MAX_CHAN_NOTES-1 + // + // Remove from active note table + // + if notes[channel, i].LSB == note + notes[channel, i] = 0 + numNotes-- + break fin - else - eventTime = -1 // Exit out - seqEvent = 0 // Signal end of track - break - fin + next + //puts("Remove note ");puti((note>>4)&$7);putc(':');puti(note&$0F) + //puts(" from table[");puti(channel);putc(',');puti(i);puts("]\n") fin + updateTime = seqTime + else // - // Next event + // Percussion event // - seqEvent = seqEvent + t_event - eventTime = eventTime + seqEvent->deltatime - until seqEvent->deltatime - fin + period = seqEvent->perchanvol + if period + psgWrite(mbVIA1, MIXER, $1C) // NG on C, Tone on B, A + psgWrite(mbVIA1, CENVAMP, $10) + psgWrite(mbVIA1, NGFREQ, note) + psgWrite(mbVIA1, ENVPERIOD+1, period) + psgWrite(mbVIA1, ENVSHAPE, $00) // Single decay + if mbVIA2 + psgWrite(mbVIA2, MIXER, $1C) // NG on C, Tone on B, A + psgWrite(mbVIA2, CENVAMP, $10) + psgWrite(mbVIA2, NGFREQ, note) + psgWrite(mbVIA2, ENVPERIOD+1, period) + psgWrite(mbVIA2, ENVSHAPE, $00) // Single decay + fin + else + eventTime = -1 // Exit out + seqEvent = 0 // Signal end of track + break + fin + fin + // + // Next event + // + seqEvent = seqEvent + t_event + eventTime = seqEvent->deltatime + eventTime + loop if updateTime <= seqTime // // Time slice active note tables (arpeggio) @@ -498,7 +495,7 @@ def mbSequence(track) i = indexA[channel] repeat i = (i + 3) % MAX_CHAN_NOTES - n = notes[channel, i] + n = notes[channel, i] if n // Non-zero volume break fin @@ -515,7 +512,7 @@ def mbSequence(track) i = indexB[channel] repeat i = (i + 3) % MAX_CHAN_NOTES - n = notes[channel, i] + n = notes[channel, i] if n // Non-zero volume break fin @@ -532,7 +529,7 @@ def mbSequence(track) i = indexC[channel] repeat i = (i + 3) % MAX_CHAN_NOTES - n = notes[channel, i] + n = notes[channel, i] if n // Non-zero volume break fin @@ -551,13 +548,12 @@ def mbSequence(track) // Increment time tick // //while !(^timerInc) - while !(mbVIA1->IFR & $40) // Wait for T1 interrupt - if ^$C000 > 127; eventTime = -1; break; fin - loop //seqTime = seqTime + ^timerInc //^timerInc = 0 seqTime++ - if updateTime < seqTime; updateTime = seqTime; fin + while !(mbVIA1->IFR & $40) // Wait for T1 interrupt + if ^$C000 > 127; eventTime = -1; break; fin + loop mbVIA1->IFR = $40 // Clear interrupt until eventTime < 0 psgWrite(mbVIA1, MIXER, $FF) // Turn everything off