forked from 0xDC00/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNS_010061300DF48000_Dairoku_Ayakashimori.js
67 lines (52 loc) · 1.81 KB
/
NS_010061300DF48000_Dairoku_Ayakashimori.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// ==UserScript==
// @name [010061300DF48000] Dairoku: Ayakashimori (DAIROKU:AYAKASHIMORI)
// @version 1.0.1
// @author Mansive
// @description Ryujinx
// * Otomate & Regista
// * Idea Factory Co., Ltd.
// ==/UserScript==
const gameVer = "1.0.1";
const { setHook } = require("./libYuzu.js");
const mainHandler = trans.send(handler, "250++");
const choiceHandler = trans.send(handler, "200+");
const dictHandler = trans.send(handler2, "200+");
setHook(
{
"1.0.1": {
[0x800e35ec - 0x80004000]: mainHandler.bind_(null, 0, "text"),
[0x800d103c - 0x80004000]: choiceHandler.bind_(null, 0, "choices"),
[0x800f1320 - 0x80004000]: dictHandler.bind_(null, 0, "dictionary"), // x0 - word, x1 - meaning
},
}[(globalThis.gameVer = globalThis.gameVer ?? gameVer)]
);
function handler(regs, index, hookname) {
const address = regs[index].value;
// console.log("onEnter: " + hookname);
// console.log(hexdump(address, { header: false, ansi: false, length: 0x50 }));
let s = address
.readUtf8String()
.replace(/%\w+/g, "")
.replace(/\u3000/gu, ""); // remove fullwidth whitespace
return s;
}
let previousWord = "";
let previousMeaning = "";
function handler2(regs, index, hookname) {
const address1 = regs[0].value;
let address2 = regs[1].value;
// console.log("onEnter: " + hookname);
// console.log(hexdump(address, { header: false, ansi: false, length: 0x50 }));
let word = address1.readUtf8String().replace(/\w+\.\w+/g, "");
// unknown number of nulls?
do {
address2 = address2.add(1);
} while (address2.readU8() === 0);
let meaning = address2.readUtf8String().replace(/%\w+/g, "");
if (word === previousWord || meaning === previousMeaning) {
return null;
}
previousWord = word;
previousMeaning = meaning;
return word + "\n" + meaning;
}