Fixing japanese

This commit is contained in:
Rodrigo Alfonso 2025-02-17 10:05:13 -03:00
parent 948bbef979
commit 25238c4ef4
4 changed files with 58 additions and 85 deletions

View File

@ -1,28 +1,25 @@
const iconv = require('iconv-lite'); // "^0.6.3"
function toFullWidth(str) {
const map = {
'A': '',
'B': '',
'(': '',
')': '',
'1': '',
'2': '',
'/': ''
};
return str.replace(/[AB\(\)1\/2]/g, ch => map[ch] || ch);
}
const data = {
"MSG_WAITING_GAME": "ゲームを待っています..."
"MSG_WAITING_NETWORK": "ネットワークを待っています",
"MSG_HANDSHAKE": "ハンドシェイクを実行中",
"MSG_REQUESTING_COMMAND": "コマンドを要求中",
"MSG_CONFIRMING_REQUEST": "要求の確認",
"MSG_SCAN_CARD": "カードをスキャンしてください",
"MSG_STARTING_TRANSFER": "転送を開始中",
"MSG_SENDING_BYTES": "バイトを送信中",
"MSG_CARD_SENT": "カードが送信されました",
"MSG_ERROR": "エラー",
"MSG_PRESS_A_TRY_AGAIN": "エーを押して再試行",
"MSG_PRESS_B_CANCEL": "ビーを押してキャンセル"
};
for (const key in data) {
const fixedStr = toFullWidth(data[key]);
const buf = iconv.encode(fixedStr, 'Shift_JIS');
const str = data[key];
const buf = iconv.encode(str, 'Shift_JIS');
const hexBytes = Array.from(buf).map(byte => '0x' + byte.toString(16).padStart(2, '0'));
hexBytes.push("0x00");
console.log(`/* "${fixedStr}" */`);
console.log(`/* "${str}" */`);
console.log(`const u8 ${key}[] = { ${hexBytes.join(', ')} };`);
console.log('');
}

View File

@ -6,84 +6,62 @@
// Japanese strings are encoded as Shift-JIS byte arrays.
#ifdef LANGUAGE_JAP
/* "ゲームを待っています..." */
const u8 MSG_WAITING_GAME[] = {0x83, 0x51, 0x81, 0x5b, 0x83, 0x80, 0x82, 0xf0,
0x91, 0xd2, 0x82, 0xc1, 0x82, 0xc4, 0x82, 0xa2,
0x82, 0xdc, 0x82, 0xb7, 0x2e, 0x2e, 0x2e, 0x00};
/* "ネットワークを待っています" */
const u8 MSG_WAITING_NETWORK[] = {0x83, 0x6c, 0x83, 0x62, 0x83, 0x67, 0x83,
0x8f, 0x81, 0x5b, 0x83, 0x4e, 0x82, 0xf0,
0x91, 0xd2, 0x82, 0xc1, 0x82, 0xc4, 0x82,
0xa2, 0x82, 0xdc, 0x82, 0xb7, 0x00};
/* "ハンドシェイク を実行中..." */
const u8 MSG_HANDSHAKE1[] = {0x83, 0x6e, 0x83, 0x93, 0x83, 0x68, 0x83, 0x56,
0x83, 0x46, 0x83, 0x43, 0x83, 0x4e, 0x20, 0x81,
0x69, 0x82, 0x50, 0x81, 0x5e, 0x82, 0x51, 0x81,
0x6a, 0x20, 0x82, 0xf0, 0x8e, 0xc0, 0x8d, 0x73,
0x92, 0x86, 0x2e, 0x2e, 0x2e, 0x00};
/* "ハンドシェイクを実行中" */
const u8 MSG_HANDSHAKE[] = {0x83, 0x6e, 0x83, 0x93, 0x83, 0x68, 0x83, 0x56,
0x83, 0x46, 0x83, 0x43, 0x83, 0x4e, 0x82, 0xf0,
0x8e, 0xc0, 0x8d, 0x73, 0x92, 0x86, 0x00};
/* "ハンドシェイク を実行中..." */
const u8 MSG_HANDSHAKE2[] = {0x83, 0x6e, 0x83, 0x93, 0x83, 0x68, 0x83, 0x56,
0x83, 0x46, 0x83, 0x43, 0x83, 0x4e, 0x20, 0x81,
0x69, 0x82, 0x51, 0x81, 0x5e, 0x82, 0x51, 0x81,
0x6a, 0x20, 0x82, 0xf0, 0x8e, 0xc0, 0x8d, 0x73,
0x92, 0x86, 0x2e, 0x2e, 0x2e, 0x00};
/* "コマンドを要求中" */
const u8 MSG_REQUESTING_COMMAND[] = {0x83, 0x52, 0x83, 0x7d, 0x83, 0x93,
0x83, 0x68, 0x82, 0xf0, 0x97, 0x76,
0x8b, 0x81, 0x92, 0x86, 0x00};
/* "コマンドを要求中..." */
const u8 MSG_REQUESTING_COMMAND[] = {0x83, 0x52, 0x83, 0x7d, 0x83, 0x93, 0x83,
0x68, 0x82, 0xf0, 0x97, 0x76, 0x8b, 0x81,
0x92, 0x86, 0x2e, 0x2e, 0x2e, 0x00};
/* "要求の確認" */
const u8 MSG_CONFIRMING_REQUEST[] = {0x97, 0x76, 0x8b, 0x81, 0x82, 0xcc,
0x8a, 0x6d, 0x94, 0x46, 0x00};
/* "要求の確認 ..." */
const u8 MSG_CONFIRMING_REQUEST1[] = {0x97, 0x76, 0x8b, 0x81, 0x82, 0xcc, 0x8a,
0x6d, 0x94, 0x46, 0x20, 0x81, 0x69, 0x82,
0x50, 0x81, 0x5e, 0x82, 0x51, 0x81, 0x6a,
0x2e, 0x2e, 0x2e, 0x00};
/* "要求の確認 ..." */
const u8 MSG_CONFIRMING_REQUEST2[] = {0x97, 0x76, 0x8b, 0x81, 0x82, 0xcc, 0x8a,
0x6d, 0x94, 0x46, 0x20, 0x81, 0x69, 0x82,
0x51, 0x81, 0x5e, 0x82, 0x51, 0x81, 0x6a,
0x2e, 0x2e, 0x2e, 0x00};
/* "カードをスキャンしてください!" */
/* "カードをスキャンしてください" */
const u8 MSG_SCAN_CARD[] = {0x83, 0x4a, 0x81, 0x5b, 0x83, 0x68, 0x82, 0xf0,
0x83, 0x58, 0x83, 0x4c, 0x83, 0x83, 0x83, 0x93,
0x82, 0xb5, 0x82, 0xc4, 0x82, 0xad, 0x82, 0xbe,
0x82, 0xb3, 0x82, 0xa2, 0x81, 0x49, 0x00};
0x82, 0xb3, 0x82, 0xa2, 0x00};
/* "転送を開始中..." */
const u8 MSG_STARTING_TRANSFER[] = {0x93, 0x5d, 0x91, 0x97, 0x82, 0xf0,
0x8a, 0x4a, 0x8e, 0x6e, 0x92, 0x86,
0x2e, 0x2e, 0x2e, 0x00};
/* "転送を開始中" */
const u8 MSG_STARTING_TRANSFER[] = {0x93, 0x5d, 0x91, 0x97, 0x82, 0xf0, 0x8a,
0x4a, 0x8e, 0x6e, 0x92, 0x86, 0x00};
/* "バイトを送信中..." */
const u8 MSG_SENDING_BYTES[] = {0x83, 0x6f, 0x83, 0x43, 0x83, 0x67,
0x82, 0xf0, 0x91, 0x97, 0x90, 0x4d,
0x92, 0x86, 0x2e, 0x2e, 0x2e, 0x00};
/* "バイトを送信中" */
const u8 MSG_SENDING_BYTES[] = {0x83, 0x6f, 0x83, 0x43, 0x83, 0x67, 0x82, 0xf0,
0x91, 0x97, 0x90, 0x4d, 0x92, 0x86, 0x00};
/* "カードが送信されました!" */
const u8 MSG_CARD_SENT[] = {0x83, 0x4a, 0x81, 0x5b, 0x83, 0x68, 0x82,
0xaa, 0x91, 0x97, 0x90, 0x4d, 0x82, 0xb3,
0x82, 0xea, 0x82, 0xdc, 0x82, 0xb5, 0x82,
0xbd, 0x81, 0x49, 0x00};
/* "カードが送信されました" */
const u8 MSG_CARD_SENT[] = {0x83, 0x4a, 0x81, 0x5b, 0x83, 0x68, 0x82, 0xaa,
0x91, 0x97, 0x90, 0x4d, 0x82, 0xb3, 0x82, 0xea,
0x82, 0xdc, 0x82, 0xb5, 0x82, 0xbd, 0x00};
/* "エラー" */
const u8 MSG_ERROR[] = {0x83, 0x47, 0x83, 0x89, 0x81, 0x5b, 0x81, 0x49, 0x00};
/* "エラー" */
const u8 MSG_ERROR[] = {0x83, 0x47, 0x83, 0x89, 0x81, 0x5b, 0x00};
/* "Aボタンを押して再試行" */
const u8 MSG_PRESS_A_TRY_AGAIN[] = {
0x82, 0x60, 0x83, 0x7b, 0x83, 0x5e, 0x83, 0x93, 0x82, 0xf0, 0x89, 0x9f,
0x82, 0xb5, 0x82, 0xc4, 0x8d, 0xc4, 0x8e, 0x8e, 0x8d, 0x73, 0x00};
/* "エーを押して再試行" */
const u8 MSG_PRESS_A_TRY_AGAIN[] = {0x83, 0x47, 0x81, 0x5b, 0x82, 0xf0, 0x89,
0x9f, 0x82, 0xb5, 0x82, 0xc4, 0x8d, 0xc4,
0x8e, 0x8e, 0x8d, 0x73, 0x00};
/* "Bボタンを押してキャンセル" */
const u8 MSG_PRESS_B_CANCEL[] = {0x82, 0x61, 0x83, 0x7b, 0x83, 0x5e, 0x83,
0x93, 0x82, 0xf0, 0x89, 0x9f, 0x82, 0xb5,
0x82, 0xc4, 0x83, 0x4c, 0x83, 0x83, 0x83,
0x93, 0x83, 0x5a, 0x83, 0x8b, 0x00};
/* "ビーを押してキャンセル" */
const u8 MSG_PRESS_B_CANCEL[] = {0x83, 0x72, 0x81, 0x5b, 0x82, 0xf0, 0x89, 0x9f,
0x82, 0xb5, 0x82, 0xc4, 0x83, 0x4c, 0x83, 0x83,
0x83, 0x93, 0x83, 0x5a, 0x83, 0x8b, 0x00};
#else
const char* MSG_WAITING_GAME = "Waiting for game...";
const char* MSG_HANDSHAKE1 = "Performing handshake (1/2)...";
const char* MSG_HANDSHAKE2 = "Performing handshake (2/2)...";
const char* MSG_WAITING_NETWORK = "Waiting for network...";
const char* MSG_HANDSHAKE = "Performing handshake...";
const char* MSG_REQUESTING_COMMAND = "Requesting command...";
const char* MSG_CONFIRMING_REQUEST1 = "Confirming request (1/2)...";
const char* MSG_CONFIRMING_REQUEST2 = "Confirming request (2/2)...";
const char* MSG_CONFIRMING_REQUEST = "Confirming request...";
const char* MSG_SCAN_CARD = "Scan a card!";
const char* MSG_STARTING_TRANSFER = "Starting transfer...";
const char* MSG_SENDING_BYTES = "Sending bytes...";
@ -136,13 +114,12 @@ int main() {
reset();
// handshake with game
print(MSG_WAITING_GAME);
print(MSG_WAITING_NETWORK);
if (!sendAndExpect(HANDSHAKE_1, HANDSHAKE_1, cancel))
continue;
print(MSG_HANDSHAKE1);
print(MSG_HANDSHAKE);
if (!sendAndExpect(HANDSHAKE_2, HANDSHAKE_2, cancel))
continue;
print(MSG_HANDSHAKE2);
if (!sendAndExpect(HANDSHAKE_3, HANDSHAKE_3, cancel))
continue;
@ -153,10 +130,9 @@ int main() {
goto error;
// confirm card request
print(MSG_CONFIRMING_REQUEST1);
print(MSG_CONFIRMING_REQUEST);
if (!sendAndExpect(GAME_ANIMATING, EREADER_ANIMATING, cancel))
continue;
print(MSG_CONFIRMING_REQUEST2);
if (!send(EREADER_ANIMATING, cancel))
continue;