Skip to content

Commit

Permalink
Patched alternate text renderer for GS text.
Browse files Browse the repository at this point in the history
  • Loading branch information
PoneyClairDeLune committed Sep 26, 2023
1 parent afeece0 commit 32fb22a
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 25 deletions.
4 changes: 2 additions & 2 deletions data/bitmaps/korg/font.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ CdPt Bitmap
0039 6092929478
003a 006c6c0000
003b 006a6c0000
003c 0010284400
003c 0010284482
003d 0028282800
003e 0044281000
003e 8244281000
003f 40808a9060
0040 4c929e827e
0041 7e8888887e
Expand Down
6 changes: 3 additions & 3 deletions data/map/gs.10.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ LPRearPk LPRearPick
MidT.Gtr MidToneGtr
TCMuteGt TCMutedGt.
Funk Gtr FunkGuitar
OvrDrGt2 OvrDrvGt.2
OvrDrGt3 OvrDrvGt.3
MoDrvGtr Mo.DriveGt
OvrDrGt2 Overdrv. 2
OvrDrGt3 Overdrv. 3
MoDrvGtr More Drive
LPOvrDr2 LPOverDrv2
Rokabily Rockabilly
WildAcBa WildAcBass
Expand Down
6 changes: 3 additions & 3 deletions data/map/gs.12.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ LPRearPk LP Rear Pick
MidT.Gtr Mid Tone Gtr
TCMuteGt TCMuted Gtr.
Funk Gtr Funk Guitar
OvrDrGt2 OvrDrvGtr. 2
OvrDrGt3 OvrDrvGtr. 3
MoDrvGtr MoreDrive Gt
OvrDrGt2 Overdriven 2
OvrDrGt3 Overdriven 3
MoDrvGtr More Drive G
LPOvrDr2 LPOverdrive2
WildAcBa Wild Ac.Bass
AtkAcoBa AtkAcou.Bass
Expand Down
51 changes: 40 additions & 11 deletions src/disp/disp_sc.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ let ScDisplay = class extends RootDisplay {
// 0 ~ 664: Text display
// 665 ~ 1399: Param display
// 1400 ~ 1656: Bitmap display
#sysMsg;
#sysTime = 0;
#pixelLit = 255;
#pixelOff = 0;
#nmdb = new Uint8Array(1656);
Expand All @@ -41,7 +43,13 @@ let ScDisplay = class extends RootDisplay {
xgFont = new MxFont40("./data/bitmaps/korg/font.tsv", "./data/bitmaps/xg/font.tsv");
constructor(conf) {
super(new OctaviaDevice(), 0, 0.875);
this.useBlur = !!conf?.useBlur;
let upThis = this;
upThis.useBlur = !!conf?.useBlur;
upThis.addEventListener("mode", function (ev) {
upThis.#sysMsg = `Sys:${{"?":"Init","g2":"GM2","mt32":"MT-32","ag10":"AG-10","05rw":"05R/W","k11":"GMega","krs":"KROSS 2","s90es":"S90 ES","motif":"Motif ES"}[ev.data]||ev.data.toUpperCase()}`;
upThis.#sysTime = Date.now() + 800;
//this.device.setLetterDisplay(textArr);
});
};
setCh(ch) {
this.#ch = ch;
Expand Down Expand Up @@ -129,19 +137,27 @@ let ScDisplay = class extends RootDisplay {
let part = minCh >> 4;
minCh = part << 4;
maxCh = ((maxCh >> 4) << 4) + 15;
if (this.#ch > maxCh) {
this.#ch = minCh + this.#ch & 15;
if (upThis.#ch > maxCh) {
upThis.#ch = minCh + upThis.#ch & 15;
};
if (this.#ch < minCh) {
this.#ch = maxCh - 15 + (this.#ch & 15);
if (upThis.#ch < minCh) {
upThis.#ch = maxCh - 15 + (upThis.#ch & 15);
};
let chOff = this.#ch * ccToPos.length;
let chOff = upThis.#ch * ccToPos.length;
// Text matrix display
let infoTxt, isTextNull = sum.letter.text.trim();
while (isTextNull.indexOf(" ") > -1) {
isTextNull = isTextNull.replaceAll(" ", " ");
};
if (timeNow <= sum.letter.expire) {
if (timeNow <= upThis.#sysTime) {
upThis.xgFont.getStr(upThis.#sysMsg || "No system text!").forEach(function (e0, i0) {
e0.forEach(function (e1, i1) {
let pX = i0 * 6 + i1 % 5,
pY = Math.floor(i1 / 5);
upThis.#nmdb[pY * 95 + pX] = e1 ? upThis.#pixelLit : upThis.#pixelOff;
});
});
} else if (timeNow <= sum.letter.expire && (sum.mode != "gs" || sum.letter.text?.length <= 16)) {
infoTxt = isTextNull;
let original = sum.letter.text,
leftTrim = original.length - original.trimLeft().length,
Expand Down Expand Up @@ -173,7 +189,7 @@ let ScDisplay = class extends RootDisplay {
};
};
//console.debug(`"${infoTxt}"`);
this.xgFont.getStr(infoTxt).forEach(function (e0, i0) {
upThis.xgFont.getStr(infoTxt).forEach(function (e0, i0) {
e0.forEach(function (e1, i1) {
let pX = i0 * 6 + i1 % 5 + xShift,
pY = Math.floor(i1 / 5);
Expand Down Expand Up @@ -214,8 +230,21 @@ let ScDisplay = class extends RootDisplay {
infoTxt += "+";
};
};
infoTxt += upThis.getMapped(upThis.getChVoice(this.#ch).name).slice(0, 12).padEnd(12, " ");
this.xgFont.getStr(infoTxt).forEach(function (e0, i0) {
infoTxt += upThis.getMapped(upThis.getChVoice(upThis.#ch).name).slice(0, 12).padEnd(12, " ");
let timeOff = 0;
if (sum.mode == "gs" && timeNow < sum.letter.set + 15000) { // 50 * 300ms
let critTxt = `${infoTxt}<${sum.letter.text}<${infoTxt}`;
let critOff = sum.letter.set + (critTxt.length - 16) * 300
if (timeNow < critOff) {
infoTxt = critTxt;
timeOff = critOff - timeNow;
};
};
if (timeOff) {
let textWindow = infoTxt.length - Math.floor(timeOff / 300);
infoTxt = infoTxt.slice(Math.max(0, textWindow - 16), Math.max(16, textWindow));
};
upThis.xgFont.getStr(infoTxt).forEach(function (e0, i0) {
e0.forEach(function (e1, i1) {
let pX = i0 * 6 + i1 % 5,
pY = Math.floor(i1 / 5);
Expand Down Expand Up @@ -287,7 +316,7 @@ let ScDisplay = class extends RootDisplay {
for (let c = minCh; c <= maxCh; c ++) {
let rendPart = rendPos >> 4;
let strSmooth = sum.strength[c] >> (4 + rendMode),
lingered = this.#linger[c] >> (4 + rendMode);
lingered = upThis.#linger[c] >> (4 + rendMode);
if (rendMode == 2) {
let offY = 4 * (3 - rendPart);
for (let d = 3 - strSmooth; d < 4; d ++) {
Expand Down
6 changes: 0 additions & 6 deletions src/fakeSc/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,6 @@ visualizer.addEventListener("reset", function (e) {
// Listen to mode switches
visualizer.addEventListener("mode", function (ev) {
stSwitch.to(stSwitchMode.indexOf(ev.data));
let textArr;
textArr = Array.from(`Sys:${{"?":"Init","g2":"GM2","mt32":"MT-32","ag10":"AG-10","05rw":"05R/W","k11":"GMega","krs":"KROSS 2","s90es":"S90 ES","motif":"Motif ES"}[ev.data]||ev.data.toUpperCase()}`);
textArr.forEach((e, i, a) => {
a[i] = e.charCodeAt(0);
});
visualizer.device.setLetterDisplay(textArr);
});
visualizer.addEventListener("meta", function (ev) {
if (!title) {
Expand Down
3 changes: 3 additions & 0 deletions src/state/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ let OctaviaDevice = class extends CustomEventSource {
#convertLastSyllable = 0;
#letterDisp = "";
#letterExpire = 0;
#letterSet = 0;
#selectPort = 0;
#receiveRS = true; // Receive remote switch
#modeKaraoke = false;
Expand Down Expand Up @@ -1128,6 +1129,7 @@ let OctaviaDevice = class extends CustomEventSource {
getLetter() {
return {
text: this.#letterDisp,
set: this.#letterSet,
expire: this.#letterExpire
};
};
Expand Down Expand Up @@ -1245,6 +1247,7 @@ let OctaviaDevice = class extends CustomEventSource {
invalidCp.add(e);
};
});
upThis.#letterSet = Date.now();
upThis.#letterExpire = Date.now() + delay;
//upThis.#letterDisp = upThis.#letterDisp.padEnd(16, " ");
if (invalidCp) {
Expand Down

0 comments on commit 32fb22a

Please sign in to comment.