Skip to content

Commit

Permalink
A fully compliant peakHold impl in SC-8850.
Browse files Browse the repository at this point in the history
Funnily enough SC still has bugs... Maybe I should just copy the code from SC-8850 to SC.
  • Loading branch information
PoneyClairDeLune committed Oct 20, 2024
1 parent 4dc2e3f commit fe2e71d
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/disp/disp_sc8850.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ let Sc8850Display = class extends RootDisplay {
#bmdb = new Uint8Array(totalPixelCount);
#linger = new Uint8Array(allocated.ch);
#lingerExtra = new Uint8Array(allocated.ch);
#lingerPress = new Uint8Array(allocated.ch);
#ch = 0;
#range = 0;
#start = 255; // start port
Expand Down Expand Up @@ -124,6 +125,14 @@ let Sc8850Display = class extends RootDisplay {
upThis.device.addEventListener("letter", (ev) => {
upThis.#letterMode = upThis.#mode;
});
upThis.device.addEventListener("note", (ev) => {
if (ev.data) {
let data = ev.data;
if (data.state == 3 && data.velo) {
upThis.#lingerPress[data.part] = 1;
};
};
});
upThis.bootBm.load(`RsrcName\tBitmap\nboot_mr\t009e003efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffffe3ffffffffffffffffffe0007fffffffffffffff8ffffffffffffffffffe0000fffffe3ffffffffffffffffffffffffffff01e01fffff8ffffffffffffffffffffffffffff03ff07f83f007c0787e187f01ffffffffffffff83ffe0f003803800e1f8e3e003fffffffffffffe1fff83838787c18187c70f0607fffffffffffff07ffe0c3f3e3e1f861e3c787e1fffffffffffffc3fff863fff0f1fe1871e1c7f87ffffffffffffe0fffc10fffc787f8e18f8e1fe3fffffffffffff83fff0c7fff1e3fe3847e38ff8fffffffffffffe0fff831fff878ff0e03f0e3fc3fffffffffffffc1ff81c7f3e3e3f8781fc78fe1ffffffffffffff00f01f06070f8301e0fe1e0c07fffffffffffffe0000fe003c7e000f83f8f8003ffffffffffffffc000ffc07e1fe063e1fc3f818fffffffffffffffe01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\nbs_0\t000700073880000000000\nbs_1\t000700073888081020000\nbs_2\t0007000738080810288e0\nbs_3\t00070007388a0c18288e0\nbs_4\t00070007000a0c18288e0\nbs_5\t0007000700020408088e0\nbs_6\t000700070002040808000\nbs_7\t000700070000000000000`);
(async () => {
await Promise.all([upThis.font55.loaded.wait(), upThis.font56.loaded.wait(), upThis.font7a.loaded.wait()]);
Expand Down Expand Up @@ -419,7 +428,14 @@ let Sc8850Display = class extends RootDisplay {
strengthHeight = (35 - renderRange + 1) / renderRange,
strengthDivider = 256 / strengthHeight;
sum.velo.forEach(function (e, i) {
if (e >= upThis.#linger[i]) {
if (upThis.#lingerPress[i]) {
upThis.#lingerPress[i] --;
upThis.#lingerExtra[i] = 127;
if (scConf.peakHold == 3 && e < upThis.#linger[i]) {
upThis.#linger[i] = e;
};
};
if (e > upThis.#linger[i]) {
upThis.#linger[i] = e;
upThis.#lingerExtra[i] = 127;
} else {
Expand All @@ -430,6 +446,9 @@ let Sc8850Display = class extends RootDisplay {
let val;
switch (scConf.peakHold) {
case 3: {
if (upThis.#linger[i] == 0) {
break;
};
val = upThis.#linger[i] + 2 * renderRange;
if (val > 255) {
val = 0;
Expand Down

0 comments on commit fe2e71d

Please sign in to comment.