mirror of
https://github.com/kichikuou/xsystem35-sdl2.git
synced 2026-09-29 02:08:01 +03:00
Use s2utbl as a fallback of TextDecoder
This commit is contained in:
+1
-1
@@ -9,7 +9,7 @@ EMFLAGS += -O2
|
||||
EMFLAGS += -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1
|
||||
|
||||
LFLAGS := $(EMFLAGS)
|
||||
LFLAGS += -s EXPORTED_FUNCTIONS="['_main','_ags_setAntialiasedStringMode', '_ald_getdata', '_ald_freedata']"
|
||||
LFLAGS += -s EXPORTED_FUNCTIONS="['_main','_ags_setAntialiasedStringMode', '_ald_getdata', '_ald_freedata', '_sjis2unicode']"
|
||||
|
||||
WASMFLAGS := -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s "BINARYEN_TRAP_MODE='allow'"
|
||||
ASMJSFLAGS := -s TOTAL_MEMORY=100663296
|
||||
|
||||
+8
-5
@@ -26,15 +26,17 @@ function SJISArrayToString(buffer: DataView): string {
|
||||
if (typeof TextDecoder !== 'undefined')
|
||||
return new TextDecoder('shift_jis').decode(buffer);
|
||||
|
||||
let out = '';
|
||||
let out = [];
|
||||
for (let i = 0; i < buffer.byteLength; i++) {
|
||||
let c = buffer.getUint8(i);
|
||||
if (c < 128)
|
||||
out += String.fromCharCode(c);
|
||||
if (c >= 0xa0 && c <= 0xdf)
|
||||
out.push(0xff60 + c - 0xa0);
|
||||
else if (c < 0x80)
|
||||
out.push(c);
|
||||
else
|
||||
out += '%' + c.toString(16);
|
||||
out.push(_sjis2unicode(c, buffer.getUint8(++i)));
|
||||
}
|
||||
return out;
|
||||
return String.fromCharCode.apply(null, out);
|
||||
}
|
||||
|
||||
declare var WebAssembly: any;
|
||||
@@ -44,6 +46,7 @@ declare function _musfade_setvolval_all(vol: number): void;
|
||||
declare function _ags_setAntialiasedStringMode(on: number): void;
|
||||
declare function _ald_getdata(type: number, no: number): number;
|
||||
declare function _ald_freedata(data: number): void;
|
||||
declare function _sjis2unicode(byte1: number, byte2: number): void;
|
||||
|
||||
declare namespace Module {
|
||||
let noInitialRun: boolean;
|
||||
|
||||
@@ -133,3 +133,12 @@ BYTE *sjis_toupper2(BYTE *src) {
|
||||
sjis_toupper(dst);
|
||||
return dst;
|
||||
}
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
extern unsigned short *s2u[];
|
||||
|
||||
int sjis2unicode(int byte1, int byte2) {
|
||||
return s2u[byte1 - 0x80][byte2 - 0x40];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user