diff --git a/plugin/Makefile b/plugin/Makefile index e636350..08e43d9 100644 --- a/plugin/Makefile +++ b/plugin/Makefile @@ -12,6 +12,7 @@ NAME = chassis FILES_DSP = \ parameters.cpp \ voicecpu.cpp \ + cpuboard.cpp \ chassis.cpp \ voice.cpp diff --git a/plugin/chassis.cpp b/plugin/chassis.cpp index ef92e13..a8a7f00 100644 --- a/plugin/chassis.cpp +++ b/plugin/chassis.cpp @@ -19,6 +19,9 @@ #include "chassis.hpp" #include "patches.hpp" +#include "cpuboard.hpp" + +Assigner ic1; START_NAMESPACE_DISTRHO @@ -61,6 +64,19 @@ void Chassis::deactivate() { void Chassis::noteOn(uint8_t note) { uint32_t i; + + ic1.ram[0x4e] = 0x90; + ic1.ram[0x3e] = note; + + + ic1.noteOn(); + + for (uint8_t i=0x40; i<0x4f; i++) { + printf("%02x ", ic1.ram[i]); + } + printf("\n"); + + s.keyon = true; for (i = 0; i < NUM_VOICES; i++) { vPtr++; diff --git a/plugin/cpuboard.cpp b/plugin/cpuboard.cpp new file mode 100644 index 0000000..e49adce --- /dev/null +++ b/plugin/cpuboard.cpp @@ -0,0 +1,60 @@ +#include "cpuboard.hpp" + +#include + +void Assigner::noteOn() { + + // called from serial interrupt handler + // sets or clears a bit in the "MIDI Key pressed" bitfield + + // note that RAM addresses normally set to 0xff40 are reduced to 0x0040 + + printf("starting noteon %02x %02x\n", ram[0x4e], ram[0x3e]); + + // 06ca + a = ram[0x3e]; // first byte is note value + c = 0x40; // fake velocity + + // bring note into range + // 06cc + if (a <= 0x17) a += 12; + // 06d0 + if (a >= 0x6d) a -= 12; + + // 06d4 subtract transpose from ffbe + + // 06d7 mov b,a; slr b; slr b; slr b + b = a >> 3; + a &= 0x07; + + // 06e0 note on? + if (ram[0x4e] != 0x90) goto h06f9; // no, skip to note off + // 06e4 velocity zero? + if (c == 0) goto h06f9; // yes, skip to note off + + // otherwise handle note on + // 06e8 lxi hl,$0008; ldax (a+hl) for table of bits + a = 1 << a; + printf("A=%02x\n", a); + c = a; + hl = 0x0040; // note bit flags + a = ram[hl + b]; // byte pointed to by upper part + a |= c; // or in the bit value + ram[hl+b] = a; // save it in RAM + + // 06f4 mviw $003f, $01 expect two bytes; jre $064c return from interrupt + return; + + h06f9: // note off + printf("went to note off\n"); + + a = 0xff ^ (1 << a); + c = a; + hl = 0x0040; // note bit flags + a = ram[hl + b]; // byte pointed to by upper part + a &= c; // mask off the bit + ram[hl+b] = a; // save it in RAM + + return; + +} \ No newline at end of file diff --git a/plugin/cpuboard.hpp b/plugin/cpuboard.hpp new file mode 100644 index 0000000..f5746f7 --- /dev/null +++ b/plugin/cpuboard.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include + +class Assigner { + public: + uint8_t ram[256]; + uint16_t a = 0, b=0, c=0; + uint32_t bc, de, hl, ea = 0; + + void noteOn(); + +}; \ No newline at end of file diff --git a/plugin/voice.cpp b/plugin/voice.cpp index 48153f1..3a3abc8 100644 --- a/plugin/voice.cpp +++ b/plugin/voice.cpp @@ -55,7 +55,7 @@ void Voice::run(Synth &s, float *buffer, uint32_t samples) { float gain = 0.5*powf(2, (4*s.patchRam.vca / 127.0f) - 1.0f); - printf("%f %f\n",s.patchRam.vca / 127.0f, gain); + //printf("%f %f\n",s.patchRam.vca / 127.0f, gain); float vcaEnv = (s.patchRam.switch2 & 0x04) ? (float)ff11 : (env / 16384.0f);