-
Notifications
You must be signed in to change notification settings - Fork 41
/
NS_01005F700DC56000_Piofiore_no_Banshou_-Ricordo-.js
75 lines (61 loc) · 1.94 KB
/
NS_01005F700DC56000_Piofiore_no_Banshou_-Ricordo-.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
// ==UserScript==
// @name [01005F700DC56000] Piofiore no Banshou -Ricordo-
// @version 1.0.0
// @author [DC]
// @description
// * Game Source Entertainment | Idea Factory
// * Otome
//
// ==/UserScript==
const gameVer = '1.0.0';
const { setHook } = require('./libYuzu.js');
const mainHandler = trans.send(s => s, '300+');
const choices = new Set();
var timerChoice;
setHook({
'1.0.0': {
[0x800141d0 - 0x80004000]: handlerMsg, // after advTalkMsgText
[0x8004ce20 - 0x80004000]: handlerName, // after&before advTalkName (late)
[0x8002be90 - 0x80004000]: handlerPrompt,
[0x8002bf50 - 0x80004000]: handlerPrompt,
[0x8002bfa0 - 0x80004000]: handlerPrompt,
}
}[globalThis.gameVer = globalThis.gameVer ?? gameVer]);
function handlerName(regs) {
const s = handler.call(this, regs, 2, "name");
mainHandler(s);
}
function handlerMsg(regs) {
const s = handler.call(this, regs, 0, "text");
setTimeout(mainHandler, 100, s);
}
function handlerPrompt(regs) {
const s = handler.call(this, regs, 0, "choice");
choices.add(s);
clearTimeout(timerChoice);
timerChoice = setTimeout(() => {
const s = [...choices].join('\r\n');
trans.send(s);
choices.clear();
}, 300);
}
function handler(regs, index, desc) {
console.warn('onEnter ' + desc);
const address = regs[index].value;
//console.log(hexdump(address, { header: false, ansi: false, length: 0x50 }));
let s = address.readCString()
// print rubi
const rubis = s.matchAll(/(#Ruby\[)([^,]+).([^\]]+)./g);
for (const rubi of rubis) {
console.log('rubi: ' + rubi[3]);
console.log('rube: ' + rubi[2]);
}
// remove rubi
s = s.replace(/(#Ruby\[)([^,]+).([^\]]+)./g, '$2');
// remove icon
// remove controls
s = s.replace(/#Color\[[\d]+\]/g, '');
s = s.replace(/( #n)+/g, '#n'); // \s?
s = s.replace(/#n+/g, ' '); // single line
return s;
}