Fixed CustomizedDisplay: hex value of multi-byte char in format string
This commit is contained in:
parent
b4a9a443fe
commit
3fa675ecea
3 changed files with 9 additions and 5 deletions
|
@ -1,4 +1,8 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
## Feb 06, 2023
|
||||||
|
### Fixed 'Customized Display'
|
||||||
|
Fixed the hex value of multi-byte char in format string
|
||||||
|
|
||||||
## Feb 05, 2023
|
## Feb 05, 2023
|
||||||
### Created 'Controller Input Display'
|
### Created 'Controller Input Display'
|
||||||
Display controller input
|
Display controller input
|
||||||
|
|
|
@ -39,8 +39,8 @@ export default function codegen(version) {
|
||||||
const asm = [];
|
const asm = [];
|
||||||
|
|
||||||
for (const config of configs) {
|
for (const config of configs) {
|
||||||
const { fmt, bgA } = config;
|
const { fmt: fmtRaw, bgA } = config;
|
||||||
const { preview, format, fields } = parseFormat(fmt, version);
|
const { preview, format, fields } = parseFormat(fmtRaw, version);
|
||||||
|
|
||||||
// fill_rect
|
// fill_rect
|
||||||
if (bgA) {
|
if (bgA) {
|
||||||
|
@ -48,7 +48,7 @@ export default function codegen(version) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// drawText
|
// drawText
|
||||||
if (fmt.trim()) {
|
if (format.trim()) {
|
||||||
const { insts, sp } = drawText(version, config, format, fields);
|
const { insts, sp } = drawText(version, config, format, fields);
|
||||||
stackFrameSize = Math.max(stackFrameSize, sp);
|
stackFrameSize = Math.max(stackFrameSize, sp);
|
||||||
asm.push(...insts);
|
asm.push(...insts);
|
||||||
|
|
|
@ -195,8 +195,8 @@ export function str2bytes(s, version) {
|
||||||
/** @type {Record<string, (typeof charInfoJP)[' ']>} */
|
/** @type {Record<string, (typeof charInfoJP)[' ']>} */
|
||||||
const charInfo = version.startsWith('GMSJ') ? charInfoJP : charInfoEU; // TODO US
|
const charInfo = version.startsWith('GMSJ') ? charInfoJP : charInfoEU; // TODO US
|
||||||
const fmtbuf = Array.from(s).flatMap((c) => {
|
const fmtbuf = Array.from(s).flatMap((c) => {
|
||||||
const code = charInfo[c]?.code ?? c.charCodeAt(0);
|
const code = charInfo[c]?.code ?? c.charCodeAt(0); // TODO multi-byte invalid char
|
||||||
return code >= 0x100 ? [code >> 16, code & 0xff] : [code];
|
return code >= 0x100 ? [code >> 8, code & 0xff] : [code];
|
||||||
});
|
});
|
||||||
fmtbuf.push(0); // NUL terminated
|
fmtbuf.push(0); // NUL terminated
|
||||||
return fmtbuf;
|
return fmtbuf;
|
||||||
|
|
Loading…
Reference in a new issue