Skip to content

Commit

Permalink
Switched from forEach to fill for buffer init
Browse files Browse the repository at this point in the history
  • Loading branch information
PoneyClairDeLune committed Jun 25, 2024
1 parent f18a00d commit 20ff314
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
27 changes: 18 additions & 9 deletions src/disp/disp_mu.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const exDuration = 1000,
exExhaust = 400,
blinkSpeedMode = 400;

const blank256Buffer = new Uint8Array(256);

const modeGroup = {
"?": 0,
"gm": 0,
Expand Down Expand Up @@ -173,6 +175,9 @@ let MuDisplay = class extends RootDisplay {
inWB = false;
#waveBuffer = new Uint8Array(8);
#panStrokes = new Uint8Array(7);
#booted = 0;
#bootFrame = 0;
trueFont = new MxFont40("./data/bitmaps/korg/font.tsv", "./data/bitmaps/xg/font.tsv");
xgFont = new MxFont40("./data/bitmaps/xg/font.tsv");
sysBm = new MxBm256("./data/bitmaps/xg/system.tsv");
voxBm = new MxBm256("./data/bitmaps/xg/voices.tsv");
Expand Down Expand Up @@ -231,6 +236,10 @@ let MuDisplay = class extends RootDisplay {
return Date.now() / 1000;
}
};
(async () => {
await Promise.all([upThis.trueFont.loaded.wait(), upThis.xgFont.loaded.wait(), upThis.sysBm.loaded.wait(), upThis.aniBm.loaded.wait()]);
upThis.#booted = 1;
})();
};
setCh(ch) {
this.#ch = ch;
Expand All @@ -252,6 +261,14 @@ let MuDisplay = class extends RootDisplay {
let sum = super.render(time);
let upThis = this;
let timeNow = Date.now();
// Fill with green
//ctx.fillStyle = "#af2";
ctx.fillStyle = `${backlight.grYellow}64`;
ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
// Main matrix display
upThis.#mmdb.fill(0);
// Part display
upThis.#pmdb.fill(0);
if (upThis.#scheduledEx) {
upThis.#scheduledEx = false;
if (timeNow - upThis.#promptEx > exExhaust) {
Expand All @@ -262,14 +279,6 @@ let MuDisplay = class extends RootDisplay {
};
//upThis.#awaitEx = timeNow;
};
// Fill with green
//ctx.fillStyle = "#af2";
ctx.fillStyle = `${backlight.grYellow}64`;
ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
// Main matrix display
upThis.#mmdb.forEach((e, i, a) => {a[i] = 0});
// Part display
upThis.#pmdb.forEach((e, i, a) => {a[i] = 0});
// Strength
let alreadyMin = false;
let minCh = 0, maxCh = 0;
Expand Down Expand Up @@ -522,7 +531,7 @@ let MuDisplay = class extends RootDisplay {
if (!useBm) {
useBm = upThis.sysBm.getBm("no_abm");
};
useBm = useBm.slice();
useBm = useBm?.slice() || blank256Buffer;
let exBlink = timeNow - upThis.#promptEx;
if (exBlink <= exDuration) {
upThis.sysBm.getBm("sysex_m").forEach((e, i) => {
Expand Down
2 changes: 1 addition & 1 deletion src/disp/disp_sc.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ let ScDisplay = class extends RootDisplay {
let timeOff = 0;
if (sum.mode == "gs" && sum.letter.text.length > 16 && timeNow < sum.letter.set + 15000) { // 50 * 300ms
let critTxt = `${infoTxt}<${sum.letter.text}<${infoTxt}`;
let critOff = sum.letter.set + (critTxt.length - 16) * 300
let critOff = sum.letter.set + (critTxt.length - 16) * 300;
if (timeNow < critOff) {
infoTxt = critTxt;
timeOff = critOff - timeNow;
Expand Down

0 comments on commit 20ff314

Please sign in to comment.