Skip to content

Commit 73b5269

Browse files
authored
Merge pull request #6 from CommitteeOfZero/steins-gate
Steins gate
2 parents aa87f02 + afb4d77 commit 73b5269

8 files changed

Lines changed: 30695 additions & 30 deletions

File tree

mgs-spec-bank/charset/steins_gate_hd.json

Lines changed: 30486 additions & 0 deletions
Large diffs are not rendered by default.

mgs-spec-bank/data.yaml

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ instructions:
1414
- instructions/chaos_child.yaml
1515
- instructions/chaos_head_lcc.yaml
1616
- instructions/iwakura_aria.yaml
17+
- instructions/steins_gate_hd.yaml
1718

1819
macros:
1920
- macros/chaos_head_noah.yaml
@@ -36,6 +37,7 @@ charset:
3637
iwakura_aria: charset/iwakura_aria.json
3738
lcc_double_pack: charset/lcc_double_pack.json
3839
lcc_double_pack-extended: charset/lcc_double_pack-extended.json
40+
steins_gate_hd: charset/steins_gate_hd.json
3941

4042
flags:
4143
memories_off_6_old:
@@ -130,6 +132,7 @@ flags:
130132
new_setevflag: no
131133
new_setflag: no
132134
new_sseplay: no
135+
new_sseinit: no
133136
new_titlemenu: no
134137
new_voiceplay: no
135138
new_voicestop: no
@@ -428,4 +431,37 @@ flags:
428431
return_labels: yes
429432
multisystemmes: no
430433
option_default_arg: no
431-
stringid_16: no
434+
stringid_16: no
435+
436+
steins_gate_hd:
437+
game_sghd: yes
438+
439+
new_bgmplay: yes
440+
new_bgmstop: yes
441+
new_createsurface: yes
442+
new_createthread: no
443+
new_messetid: no
444+
new_playmovie: no
445+
new_presence: yes
446+
new_pressstart: yes
447+
new_resetflag: no
448+
new_save: yes
449+
new_scriptload: no
450+
new_seplay: yes
451+
new_setdic: yes
452+
new_setevflag: no
453+
new_setflag: no
454+
new_sseplay: no
455+
new_sseinit: no
456+
new_titlemenu: yes
457+
new_voiceplay: no
458+
new_voicestop: yes
459+
add_contents: no
460+
bgrelease: yes
461+
462+
achchktitle: no
463+
effyuge: no
464+
chaload: yes
465+
mescls: yes
466+
movie_01_27: yes
467+
return_labels: yes

mgs-spec-bank/instructions/base/base_10.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,16 @@
663663
operands: []
664664
flags: []
665665

666+
- pattern: 10 3F 0F
667+
name: MouseMode_0F
668+
operands: []
669+
flags: []
670+
671+
- pattern: 10 3F 10
672+
name: MouseMode_10
673+
operands: []
674+
flags: []
675+
666676
- pattern: 10 3F 11
667677
name: MouseModeSetSysMenu
668678
operands: []
@@ -703,6 +713,16 @@
703713
operands: []
704714
flags: []
705715

716+
- pattern: 10 3F 19
717+
name: MouseMode_19
718+
operands: []
719+
flags: []
720+
721+
- pattern: 10 3F 1A
722+
name: MouseMode_1A
723+
operands: []
724+
flags: []
725+
706726
- pattern: 10 3F 1B
707727
name: MouseModeSetClearList
708728
operands: []
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
- pattern: 10 37 00
2+
name: PhoneSG_00
3+
operands: [int8, expr]
4+
flags: [game_sghd]
5+
6+
- pattern: 10 37 01
7+
name: PhoneSG_01
8+
operands: [int8, expr]
9+
flags: [game_sghd]
10+
11+
- pattern: 10 37 02
12+
name: PhoneSG_02
13+
operands: [int8, expr, int16]
14+
flags: [game_sghd]
15+
16+
- pattern: 10 37 03
17+
name: PhoneSG_03
18+
operands: [int8, expr, int16]
19+
flags: [game_sghd]
20+
21+
- pattern: 10 37 04
22+
name: PhoneSG_04
23+
operands: [int16, int16, int16, int16, int16, int16]
24+
flags: [game_sghd]
25+
26+
- pattern: 10 37 05
27+
name: PhoneSG_05
28+
operands: []
29+
flags: [game_sghd]
30+
31+
- pattern: 10 37 06
32+
name: PhoneSG_06
33+
operands: []
34+
flags: [game_sghd]
35+
36+
- pattern: 10 37 07
37+
name: PhoneSG_07
38+
operands: []
39+
flags: [game_sghd]
40+
41+
- pattern: 10 37 08
42+
name: PhoneSG_08
43+
operands: []
44+
flags: [game_sghd]
45+
46+
- pattern: 10 37 09
47+
name: PhoneSG_09
48+
operands: []
49+
flags: [game_sghd]
50+
51+
- pattern: 10 37 0F
52+
name: PhoneSG_0F
53+
operands: [expr]
54+
flags: [game_sghd]
55+
56+
- pattern: 10 37 10
57+
name: PhoneSG_10
58+
operands: [expr]
59+
flags: [game_sghd]
60+
61+
- pattern: 10 37 11
62+
name: PhoneSG_11
63+
operands: []
64+
flags: [game_sghd]
65+
66+
- pattern: 10 37 12
67+
name: PhoneSG_12
68+
operands: [expr, expr]
69+
flags: [game_sghd]
70+
71+
- pattern: 10 37 13
72+
name: PhoneSG_13
73+
operands: []
74+
flags: [game_sghd]
75+
76+
- pattern: 10 37 14
77+
name: PhoneSG_14
78+
operands: [expr, expr, expr, expr]
79+
flags: [game_sghd]
80+
81+
- pattern: 10 37 15
82+
name: PhoneSG_15
83+
operands: [expr, expr, expr, expr]
84+
flags: [game_sghd]
85+
86+
- pattern: 10 37 16
87+
name: PhoneSG_16
88+
operands: []
89+
flags: [game_sghd]
90+
91+
- pattern: 10 37 17
92+
name: PhoneSG_17
93+
operands: []
94+
flags: [game_sghd]
95+
96+
- pattern: 10 37 18
97+
name: PhoneSG_18
98+
operands: []
99+
flags: [game_sghd]
100+
101+
- pattern: 10 37 19
102+
name: PhoneSG_19
103+
operands: []
104+
flags: [game_sghd]
105+
106+
- pattern: 10 37 1A
107+
name: PhoneSG_1A
108+
operands: []
109+
flags: [game_sghd]

src/MagesScriptTool/ParseUtils.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ public static bool TrySkip(TextStream reader, char c) {
1010
}
1111

1212
public static bool TrySkip(TextStream reader, string s) {
13-
if (!reader.Has(s.Length - 1)) {
14-
return false;
15-
}
16-
for (int i = 0; i < s.Length; i++) {
17-
if (reader.Peek(i) != s[i]) {
18-
return false;
19-
}
20-
}
21-
reader.Skip(s.Length);
22-
return true;
23-
}
13+
var runes = s.EnumerateRunes();
14+
int i = 0;
15+
foreach (var rune in runes) {
16+
if (!reader.Has(i) || reader.PeekRune(i) != rune) {
17+
return false;
18+
}
19+
i++;
20+
}
21+
reader.Skip(i);
22+
return true;
23+
}
2424

2525
public static bool SkipSpaceComments(TextStream reader) {
2626
bool consumed = false;

src/MagesScriptTool/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@ static async Task<int> DoDecompile(Tool tool) {
211211
continue;
212212
}
213213
string extension = Path.GetExtension(compiledPath);
214-
if (extension == tool.CompiledScriptPackageExtension) {
214+
if (extension.ToLower() == tool.CompiledScriptPackageExtension) {
215215
errorOccurred |= !await DecompileScriptPackage(tool, compiledName);
216216
}
217-
if (extension == tool.CompiledStringTableExtension) {
217+
if (extension.ToLower() == tool.CompiledStringTableExtension) {
218218
errorOccurred |= !await DecompileStringTable(tool, compiledName);
219219
}
220220
}

src/MagesScriptTool/SpecBank.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,24 @@ static ImmutableArray<GlyphSpec> toGlyphSpecs(JsonElement json) {
7373
GlyphStyle? style = toStyle(parametersJson.GetProperty("style"));
7474

7575
List<GlyphSpec> glyphs = [];
76-
foreach (JsonElement glyphJson in json.GetProperty("glyphs").EnumerateArray()) {
77-
ImmutableArray<int> units = toUnits(glyphJson.GetProperty("units"));
78-
string text = toText(glyphJson.GetProperty("text"));
79-
glyphs.Add(new(units, text, style));
76+
JsonElement glyphsJson = json.GetProperty("glyphs");
77+
if(glyphsJson.ValueKind == JsonValueKind.Object) {
78+
Int16 unitsOffset = glyphsJson.GetProperty("unitsOffset").GetInt16();
79+
string text = toText(glyphsJson.GetProperty("text"));
80+
int index = 0;
81+
TextElementEnumerator charEnum = StringInfo.GetTextElementEnumerator(text);
82+
while (charEnum.MoveNext()) {
83+
glyphs.Add(new([unitsOffset + index], charEnum.GetTextElement(), style));
84+
index++;
85+
}
86+
} else if (glyphsJson.ValueKind == JsonValueKind.Array) {
87+
foreach (JsonElement glyphJson in glyphsJson.EnumerateArray()) {
88+
ImmutableArray<int> units = toUnits(glyphJson.GetProperty("units"));
89+
string text = toText(glyphJson.GetProperty("text"));
90+
glyphs.Add(new(units, text, style));
91+
}
92+
} else {
93+
throw new NotImplementedException($"{glyphsJson.ValueKind} is not implemented.");
8094
}
8195
return [..glyphs];
8296
}

src/MagesScriptTool/UncompiledStringSyntax.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,28 +102,28 @@ public UncompiledStringParser(TextStream reader) {
102102
public ImmutableArray<StringToken> Parse() {
103103
List<StringToken> tokens = [];
104104
GlyphStyle style = GlyphStyle.Normal;
105-
while (_reader.Has(0) && _reader.Peek(0) != '\n') {
106-
if (_reader.Peek(0) == '〔') {
107-
_reader.Next();
105+
while (_reader.Has(0) && _reader.PeekRune(0) != new Rune('\n')) {
106+
if (_reader.PeekRune(0) == new Rune('〔')) {
107+
_reader.NextRune();
108108
tokens.Add(new StringTokenTag("nameStart", []));
109-
} else if (_reader.Peek(0) == '〕') {
110-
_reader.Next();
109+
} else if (_reader.PeekRune(0) == new Rune('〕')) {
110+
_reader.NextRune();
111111
tokens.Add(new StringTokenTag("nameEnd", []));
112-
} else if (_reader.Peek(0) == '\\') {
113-
if (_reader.Has(1) && _reader.Peek(1) is '\\' or '〔' or '〕') {
112+
} else if (_reader.PeekRune(0) == new Rune('\\')) {
113+
if (_reader.Has(1) && (_reader.PeekRune(1) == new Rune('\\') || _reader.PeekRune(1) == new Rune('〔') || _reader.PeekRune(1) == new Rune('〕'))) {
114114
_reader.Skip(1);
115115
tokens.Add(new StringTokenRune(_reader.NextRune(), style));
116116
} else {
117-
tokens.Add(ParseTag());
117+
tokens.Add(ParseTag());
118118
}
119119
} else if (ParseUtils.TrySkip(_reader, "<i>")) {
120-
style = GlyphStyle.Italic;
120+
style = GlyphStyle.Italic;
121121
} else if (ParseUtils.TrySkip(_reader, "</i>")) {
122-
style = GlyphStyle.Normal;
122+
style = GlyphStyle.Normal;
123123
} else {
124-
tokens.Add(new StringTokenRune(_reader.NextRune(), style));
124+
tokens.Add(new StringTokenRune(_reader.NextRune(), style));
125125
}
126-
}
126+
}
127127
return [..tokens];
128128
}
129129

0 commit comments

Comments
 (0)