initial CPU board

This commit is contained in:
Gordon JC Pearce 2024-09-16 21:52:18 +01:00
parent 3636ae356a
commit 31c8b46cf4
5 changed files with 91 additions and 1 deletions

View File

@ -12,6 +12,7 @@ NAME = chassis
FILES_DSP = \
parameters.cpp \
voicecpu.cpp \
cpuboard.cpp \
chassis.cpp \
voice.cpp

View File

@ -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++;

60
plugin/cpuboard.cpp Normal file
View File

@ -0,0 +1,60 @@
#include "cpuboard.hpp"
#include <cstdio>
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;
}

13
plugin/cpuboard.hpp Normal file
View File

@ -0,0 +1,13 @@
#pragma once
#include <cstdint>
class Assigner {
public:
uint8_t ram[256];
uint16_t a = 0, b=0, c=0;
uint32_t bc, de, hl, ea = 0;
void noteOn();
};

View File

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