Skip to content

Commit

Permalink
Added bitmap display support for Octavia SC-8850.
Browse files Browse the repository at this point in the history
  • Loading branch information
PoneyClairDeLune committed May 10, 2024
1 parent 470513d commit 6215693
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
7 changes: 4 additions & 3 deletions src/disp/disp_n5.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,14 @@ let Ns5rDisplay = class extends RootDisplay {
};
};
// Actual bitmap
let colUnit = (sum.bitmap.bitmap.length == 512) ? 1 : 2;
let colUnit = (sum.bitmap.bitmap.length > 256) ? 1 : 2;
for (let i = 0; i < 512; i += colUnit) {
let x = i & 31, y = i >> 5;
let realX = x + 80, realY = y + 21;
this.#nmdb[realY * 144 + realX] = sum.bitmap.bitmap[i / colUnit] ? this.#pixelLit : this.#pixelOff;
let bit = sum.bitmap.bitmap[i >> (colUnit - 1)] ? this.#pixelLit : this.#pixelOff;
this.#nmdb[realY * 144 + realX] = bit;
if (colUnit == 2) {
this.#nmdb[realY * 144 + realX + 1] = sum.bitmap.bitmap[i / colUnit] ? this.#pixelLit : this.#pixelOff;
this.#nmdb[realY * 144 + realX + 1] = bit;
};
};
};
Expand Down
39 changes: 27 additions & 12 deletions src/disp/disp_sc8850.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ let flipBitsInBuffer = (buf, bWidth, startX, startY, width, height) => {
};
};
};
let fillBitsInBuffer = (buf, bWidth, startX, startY, width, height) => {
let fillBitsInBuffer = (buf, bWidth, startX, startY, width, height, bit = 255) => {
let endX = startX + width, endY = startY + height;
for (let pY = startY; pY < endY; pY ++) {
let lineOff = pY * bWidth;
for (let pX = startX; pX < endX; pX ++) {
buf[lineOff + pX] = 255;
buf[lineOff + pX] = bit;
};
};
};
Expand Down Expand Up @@ -274,11 +274,12 @@ let Sc8850Display = class extends RootDisplay {
switch (upThis.#mode) {
case "?":
case "gs":
case "sc": {
case "sc":
case "gm": {
break;
};
default: {
let mode = (twoLetterMode[upThis.#mode] || upThis.#mode).toUpperCase();
let mode = (twoLetterMode[upThis.device.getChMode(upThis.#ch)] || upThis.device.getChMode(upThis.#ch)).toUpperCase();
upThis.font56.getStr(mode).forEach((e0, i0) => {
let offsetX = i0 * 6;
e0.forEach((e1, i1) => {
Expand Down Expand Up @@ -342,14 +343,28 @@ let Sc8850Display = class extends RootDisplay {
});
//console.debug(renderRange, strengthHeight, strengthDivider);
// Render meters
for (let i0 = 0; i0 < renderRange; i0 ++) {
let chStart = minCh + (i0 << 4);
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 (timeNow < sum.bitmap.expire) {
// Actual bitmap
let colUnit = (sum.bitmap.bitmap.length > 256) ? 1 : 2;
for (let i = 0; i < 512; i += colUnit) {
let x = i & 31, y = i >> 5;
let realX = x * 3 + 49, realY = (y << 1) + 15;
let bit = sum.bitmap.bitmap[i >> (colUnit - 1)] ? upThis.#pixelLit : upThis.#pixelOff;
fillBitsInBuffer(upThis.#nmdb, totalWidth, realX, realY, 2, 2, bit);
if (colUnit == 2) {
fillBitsInBuffer(upThis.#nmdb, totalWidth, realX + 2, realY, 3, 2, bit);
};
};
} else {
for (let i0 = 0; i0 < renderRange; i0 ++) {
let chStart = minCh + (i0 << 4);
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);
};
};
};
// EFX and bank?
Expand Down

0 comments on commit 6215693

Please sign in to comment.