chassis/plugin/cpuboard.cpp
2024-09-16 21:52:18 +01:00

60 lines
1.5 KiB
C++

#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;
}