Skip to content

Commit

Permalink
Supported SC display types in SC-8850.
Browse files Browse the repository at this point in the history
  • Loading branch information
PoneyClairDeLune committed Jun 20, 2024
1 parent 5b49fab commit db14709
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/disp/disp_sc.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ let ScDisplay = class extends RootDisplay {
ctx.fillText("KEY SHIFT", 21, 233);
ctx.fillText("MIDI CH", 154, 233);
ctx.textAlign = "center";
ctx.font = '600 16px "Arial Web"';
ctx.textRendering = "auto";
for (let c = 1; c <= 16; c ++) {
ctx.fillText(`${c}`, 308 + cmpHeightX * c, 300);
};
Expand Down
67 changes: 59 additions & 8 deletions src/disp/disp_sc8850.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ let Sc8850Display = class extends RootDisplay {
let upThis = this;
let timeNow = Date.now();
let fullRefresh = false;
let scConf = upThis.device.modelEx.sc;
upThis.#nmdb.fill(0);
// Prepare the canvas
if (timeNow - upThis.#lastBg >= 3600000) {
Expand Down Expand Up @@ -333,12 +334,31 @@ let Sc8850Display = class extends RootDisplay {
upThis.#linger[i] = e;
upThis.#lingerExtra[i] = 127;
} else {
if (upThis.#lingerExtra[i] >> 4) {
upThis.#lingerExtra[i] -= 16;
let shouldKeep = upThis.#lingerExtra[i] >> 4;
if (shouldKeep) {
upThis.#lingerExtra[i] -= 6;
} else {
let val = upThis.#linger[i] - 4 * renderRange;
if (val < 0) {
val = 0;
let val;
switch (scConf.peakHold) {
case 3: {
val = upThis.#linger[i] + 2 * renderRange;
if (val > 255) {
val = 0;
};
break;
};
case 2: {
val = 0;
break;
};
case 1:
case 0: {
val = upThis.#linger[i] - 4 * renderRange;
if (val < 0) {
val = 0;
};
break;
};
};
upThis.#linger[i] = val;
};
Expand All @@ -364,11 +384,42 @@ let Sc8850Display = class extends RootDisplay {
for (let i1 = 0; i1 < 16; i1 ++) {
let ch = chStart + i1;
let strength = Math.floor(sum.strength[ch] / strengthDivider) + 1;
let linger = Math.floor(upThis.#linger[ch] / strengthDivider) + 1;
fillBitsInBuffer(upThis.#nmdb, totalWidth, 49 + 6 * i1, 48 - i0 * strengthHeight - strength - i0, 5, strength);
fillBitsInBuffer(upThis.#nmdb, totalWidth, 49 + 6 * i1, 48 - i0 * strengthHeight - linger - i0, 5, 1);
if (scConf.showBar) {
if (scConf.invBar) {
fillBitsInBuffer(upThis.#nmdb, totalWidth, 49 + 6 * i1, 13 + i0 * strengthHeight + i0, 5, strength);
} else {
fillBitsInBuffer(upThis.#nmdb, totalWidth, 49 + 6 * i1, 48 - i0 * strengthHeight - strength - i0, 5, strength);
};
} else {
if (scConf.invBar) {
fillBitsInBuffer(upThis.#nmdb, totalWidth, 49 + 6 * i1, 12 + i0 * strengthHeight + strength + i0, 5, 1);
if (strength) {
fillBitsInBuffer(upThis.#nmdb, totalWidth, 49 + 6 * i1, 13 + i0, 5, 1);
};
} else {
fillBitsInBuffer(upThis.#nmdb, totalWidth, 49 + 6 * i1, 48 - i0 * strengthHeight - strength - i0, 5, 1);
if (strength) {
fillBitsInBuffer(upThis.#nmdb, totalWidth, 49 + 6 * i1, 47 - i0, 5, 1);
};
};
};
if (scConf.peakHold) {
let linger = Math.floor(upThis.#linger[ch] / strengthDivider) + 1;
if (scConf.invBar) {
if (linger) {
fillBitsInBuffer(upThis.#nmdb, totalWidth, 49 + 6 * i1, 12 + i0 * strengthHeight + linger + i0, 5, 1);
};
} else {
if (linger) {
fillBitsInBuffer(upThis.#nmdb, totalWidth, 49 + 6 * i1, 48 - i0 * strengthHeight - linger - i0, 5, 1);
};
};
};
};
};
if (scConf.invDisp) {
flipBitsInBuffer(upThis.#nmdb, totalWidth, 48, 12, 97, 44);
};
};
// EFX and bank?
if (upThis.device.getEffectSink()[upThis.#ch]) {
Expand Down

0 comments on commit db14709

Please sign in to comment.