forked from 0xDC00/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NS_010021D01474E000_Kimi_wa_Yukima_ni_Koinegau.js
77 lines (63 loc) · 1.93 KB
/
NS_010021D01474E000_Kimi_wa_Yukima_ni_Koinegau.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
68
69
70
71
72
73
74
75
76
77
// ==UserScript==
// @name [010021D01474E000] Kimi wa Yukima ni Koinegau (君は雪間に希う)
// @version 1.0.0
// @author Mansive
// @description Yuzu, Ryujinx
// * Otomate
// * Idea Factory Co., Ltd.
// ==/UserScript==
const gameVer = "1.0.0";
const { setHook } = require("./libYuzu.js");
const mainHandler = trans.send(handler, "200+");
const mainHandler2 = trans.send(handler2, "250+");
const dictHandler = trans.send(handler, -200);
setHook(
{
"1.0.0": {
[0x8013a0f0 - 0x80004000]: mainHandler.bind_(null, 0, "text"),
[0x800319f8 - 0x80004000]: mainHandler2.bind_(null, 0, "soliloquy"), // outputs all at once
[0x800488e4 - 0x80004000]: mainHandler.bind_(null, 1, "choices"),
[0x800bdb84 - 0x80004000]: dictHandler.bind_(null, 0, "popup"),
[0x800e4540 - 0x80004000]: dictHandler.bind_(null, 0, "menu"),
},
}[(globalThis.gameVer = globalThis.gameVer ?? gameVer)]
);
let previous = "";
let open = false;
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
.readUtf32StringLE()
.replace(/\u3000/gu, "") // remove fullwidth whitespace
.replace(/\n/g, ""); // single line
if (s === "――独白――") {
// 独白 starting, enable other handler
open = true;
return null;
} else if (s === previous) {
return null;
} else {
open = false;
}
previous = s;
return s;
}
function handler2(regs, index, hookname) {
if (open === false) {
return null;
}
const address = regs[index].value;
// console.log("onEnter: " + hookname);
let s = address
.readUtf32StringLE()
.replace(/\u3000/gu, "") // remove fullwidth whitespace
// .replace(/\n/g, "") // single line
.replace(/#\w.+?\)|#\w+/g, "");
if (s === previous) {
return null;
}
previous = s;
return s;
}