Skip to content

Commit 49b1508

Browse files
Some update
+ Many known commands. + Revise for some previously known commands. + Mapped and corrected many structures. + Some system update. + Some connected with string arguments defined. === + Better support of Kusarihime. + Partial support for Inganock. Choices still may work incorrectly. + Partial support for Hiragumo-chan (well, the tool still can not do new commands insertion here correctly... And not because of strings. The correction may take some time). *(I think the tool may have the same issue with all Liar-soft games about time as Hiragumo and later time). === *Still don't know about raiL-soft games.*
1 parent 051d9b6 commit 49b1508

File tree

1 file changed

+128
-59
lines changed

1 file changed

+128
-59
lines changed

gscScriptCompAndDecompiler.py

Lines changed: 128 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,14 @@ class GscFile:
5050
CommandsLibrary = ((0x03, 'i', 'JUMP_UNLESS'),
5151
(0x05, 'i', 'JUMP'),
5252
(0x0D, 'i', 'PAUSE'),
53-
(0x14, 'ii', 'IMAGE_DEF'),
54-
(0x1A, '', 'SCENE_SET'), #IMAGE_SET?
53+
(0x0C, 'ii', 'CALL_SCRIPT'), #[имя скрипта без начальных нулей, ???]
54+
(0x14, 'ii', 'IMAGE_GET'),
55+
(0x1A, '', 'IMAGE_SET'),
5556
(0x1C, 'iii', 'BLEND_IMG'),
57+
(0x1E, 'iiiiii', 'IMAGE_DEF'),
5658
(0x51, 'iiiiiii', 'MESSAGE'),
59+
(0x52, 'iiiiii', 'APPEND_MESSAGE'),
60+
(0x79, 'ii', 'GET_DIRECTORY'),
5761
(0xC8, 'iiiiiiiiiii', 'READ_SCENARIO'), #??? Подправить число аргументов?
5862
(0xFF, 'iiiii', 'SPRITE'),
5963
(0x3500, 'hhh', 'AND'),
@@ -62,10 +66,10 @@ class GscFile:
6266
(0xAA00, 'hhh', 'ADD'),
6367
(0xF100, 'hh', 'ASSIGN'),
6468
(0x04, 'i', ''),
69+
(0x08, '', ''),
6570
(0x09, 'h', ''),
66-
(0x0A, '', ''),
71+
(0x0A, '', ''), #h в другом типе? Хм-м... #WAIT_FOR_CLICK?
6772
(0x0B, '', ''),
68-
(0x0C, 'ii', ''),
6973
(0x0E, 'hiiiiiiiiiiiiii', ''), #???
7074
(0x0F, 'iiiiiiiiiiii', ''), #??? #Массив? Подправить число аргументов?
7175
(0x10, 'i', ''),
@@ -79,14 +83,13 @@ class GscFile:
7983
(0x19, 'ii', ''),
8084
(0x1B, '', ''),
8185
(0x1D, 'ii', ''),
82-
(0x1E, 'iiiiii', ''),
8386
(0x20, 'iiiiii', ''),
8487
(0x21, 'iiiii', ''),
8588
(0x22, 'iiiii', ''),
8689
(0x23, 'ii', ''),
8790
(0x24, 'ii', ''),
8891
(0x25, 'ii', ''),
89-
(0x26, 'iiii', ''),
92+
(0x26, 'iiii', ''), #Возможно, где-то 'iii'?
9093
(0x27, 'iii', ''),
9194
(0x28, 'ii', ''),
9295
(0x29, 'ii', ''),
@@ -96,7 +99,7 @@ class GscFile:
9699
(0x2D, 'ii', ''),
97100
(0x2E, 'i', ''),
98101
(0x2F, 'ii', ''),
99-
(0x30, 'iii', ''),
102+
(0x30, 'iii', ''), #Возможно, где-то 'ii'?
100103
(0x31, 'ii', ''),
101104
(0x32, '', ''),
102105
(0x33, '', ''),
@@ -125,8 +128,6 @@ class GscFile:
125128
(0x4B, 'iiiii', ''),
126129
(0x4D, 'iiii', ''),
127130
(0x50, 'i', ''),
128-
(0x51, 'iiiiiii', ''),
129-
(0x52, 'iiiiii', ''),
130131
(0x53, 'i', ''),
131132
(0x5A, 'iii', ''),
132133
(0x5B, 'iiiii', ''),
@@ -144,6 +145,7 @@ class GscFile:
144145
(0x67, 'ii', ''),
145146
(0x68, 'iiii', ''),
146147
(0x69, 'ii', ''),
148+
(0x6A, 'iiiii', ''),#TEMP!
147149
(0x6E, 'iii', ''),
148150
(0x6F, 'iii', ''),
149151
(0x70, 'i', ''),
@@ -153,7 +155,6 @@ class GscFile:
153155
(0x74, 'ii', ''),
154156
(0x75, 'ii', ''),
155157
(0x78, 'ii', ''),
156-
(0x79, 'ii', ''),
157158
(0x82, 'iiii', ''),
158159
(0x83, 'iiiii', ''),
159160
(0x84, 'ii', ''),
@@ -184,12 +185,51 @@ class GscFile:
184185
(0xE6, 'i', ''),
185186
(0xE7, 'i', ''),
186187
(0x1800, 'hhh', ''),
188+
(0x1810, 'hhh', ''), #!!!
189+
(0x1900, 'hhh', ''),
190+
(0x1910, 'hhh', ''),
191+
(0x2500, 'hhh', ''),
192+
(0x1A01, 'hhh', ''), #!!!
193+
(0x1A00, 'hhh', ''),
194+
(0x4400, 'hhh', ''),
195+
(0x4810, 'hhh', ''), #!!!
196+
(0x4900, 'hhh', ''),
187197
(0x5800, 'hhh', ''),
188-
(0x7800, 'hhh', ''))
189-
#Библиотека команд, двумерный массив.
190-
#[n][0] - команда;
191-
#[n][1] - структура;
192-
#[n][2] - определение (может быть пустым.
198+
(0x6800, 'hhh', ''),
199+
(0x7800, 'hhh', ''),
200+
(0x8800, 'hhh', ''),
201+
(0x8A00, 'hhh', ''),
202+
(0x9800, 'hhh', ''),
203+
(0x9810, 'hhh', ''), #!!!
204+
(0x9A00, 'hhh', ''),
205+
(0xA100, 'hhh', ''),
206+
(0xA201, 'hhh', ''), #!!
207+
(0xA400, 'hhh', ''),
208+
(0xA500, 'hhh', ''),
209+
(0xA600, 'hhh', ''),
210+
(0xA800, 'hhh', ''),
211+
(0xA810, 'hhh', ''), #!!!
212+
(0xB400, 'hhh', ''),
213+
(0xB800, 'hhh', ''),
214+
(0xB900, 'hhh', ''),
215+
(0xC400, 'hhh', ''),
216+
(0xC800, 'hhh', ''),
217+
(0xD400, 'hhh', ''),
218+
(0xD800, 'hhh', ''),
219+
(0xE400, 'hhh', ''),
220+
(0xE800, 'hhh', ''))
221+
#Библиотека команд, двумерный кортеж.
222+
#(n)(0) - команда;
223+
#(n)(1) - структура;
224+
#(n)(2) - определение (может быть пустым.
225+
226+
ConnectedStringsLibrary = [[0x0F, [1]],
227+
[0x51, [-3, -2]],
228+
[0x52, [-2]],
229+
[0x79, [1]]]
230+
#Библиотека связанных со строками аргументов.
231+
#(n)(0) - команда;
232+
#(n)(1) - кортеж связанных аргументов.
193233

194234
def __init__(self, FileName, Mode):
195235
self.FileName = FileName
@@ -357,20 +397,31 @@ def DecompileGscToTxt(self):
357397
CommandName = self.CommandsLibrary[i][2]
358398
else:
359399
CommandName = str(self.Commands[CommandNumber])
360-
if (self.Commands[CommandNumber] == 0x51):
361-
MessageKostil = 1
362-
if (MessageKostil == 1):
363-
MessageArgsTrue = self.CommandArgs[CommandNumber]
364-
MessageNum = MessageArgsTrue[-2]
365-
MessageArgsTrue[-2] = -1
366-
while (StringCount < MessageNum):
367-
self.File.write('>' + str(StringCount) + '\n')
368-
self.File.write(self.FileStrings[StringCount].replace('^n', '\n') + '\n')
400+
401+
ConStr = 0
402+
kk = 0
403+
for kk in range(0, len(self.ConnectedStringsLibrary)):
404+
if (self.Commands[CommandNumber] == self.ConnectedStringsLibrary[kk][0]):
405+
ConStr = 1
406+
break
407+
408+
if (ConStr > 0):
409+
kkk = 0
410+
StringsNew = []
411+
for kkk in range(len(self.ConnectedStringsLibrary[kk][1])):
412+
MessageArgsTrue = self.CommandArgs[CommandNumber]
413+
MessageNum = MessageArgsTrue[self.ConnectedStringsLibrary[kk][1][kkk]]
414+
MessageArgsTrue[self.ConnectedStringsLibrary[kk][1][kkk]] = -1
415+
StringsNew.append(self.FileStrings[MessageNum].replace('^n', '\n'))
416+
while (StringCount < MessageNum):
417+
self.File.write('>' + str(StringCount) + '\n')
418+
self.File.write(self.FileStrings[StringCount].replace('^n', '\n') + '\n')
369419
StringCount += 1
420+
370421
self.File.write("#" + CommandName + '\n')
371422
self.File.write(str(self.CommandArgs[CommandNumber]))
372-
self.File.write("\n>-1\n" + self.FileStrings[MessageNum].replace('^n', '\n'))
373-
StringCount += 1
423+
for z in StringsNew:
424+
self.File.write("\n>-1\n" + z)
374425
else:
375426
self.File.write("#" + CommandName)
376427
self.File.write("\n")
@@ -436,33 +487,43 @@ def CompileTxtToGsc(self):
436487
CommandNEW.append(int(CommandCTR[ii]))
437488
self.CommandArgs.append(CommandNEW)
438489
i += 1
439-
if (CommandType == 0x51):
440-
String = ''
441-
i += 1
442-
KostilPer = 1
443-
while (i < len(Lines)):
444-
if (len(Lines[i]) == 0):
490+
491+
ConStr = 0
492+
kk = 0
493+
for kk in range(0, len(self.ConnectedStringsLibrary)):
494+
if (CommandType == self.ConnectedStringsLibrary[kk][0]):
495+
ConStr = 1
496+
break
497+
498+
if (ConStr > 0):
499+
kkk = 0
500+
for kkk in range(len(self.ConnectedStringsLibrary[kk][1])):
501+
String = ''
502+
i += 1
503+
KostilPer = 1
504+
while (i < len(Lines)):
505+
if (len(Lines[i]) == 0):
506+
if (KostilPer == 1):
507+
KostilPer = 0
508+
else:
509+
String = String + '^n'
510+
i += 1
511+
continue
512+
if (Lines[i][0] == '<'): #Комментарии.
513+
i += 1
514+
continue
515+
if ((Lines[i][0] == '#') or (Lines[i][0] == '>')):
516+
break
445517
if (KostilPer == 1):
446518
KostilPer = 0
447519
else:
448520
String = String + '^n'
521+
if (i >= len(Lines)):
522+
i -= 1
523+
String = String + Lines[i]
449524
i += 1
450-
continue
451-
if (Lines[i][0] == '<'): #Комментарии.
452-
i += 1
453-
continue
454-
if ((Lines[i][0] == '#') or (Lines[i][0] == '>')):
455-
break
456-
if (KostilPer == 1):
457-
KostilPer = 0
458-
else:
459-
String = String + '^n'
460-
if (i >= len(Lines)):
461-
i -= 1
462-
String = String + Lines[i]
463-
i += 1
464-
self.FileStrings.append(String)
465-
self.CommandArgs[-1][-2] = (len(self.FileStrings) - 1)
525+
self.FileStrings.append(String)
526+
self.CommandArgs[-1][self.ConnectedStringsLibrary[kk][1][kkk]] = (len(self.FileStrings) - 1)
466527
else:
467528
i += 1
468529
continue
@@ -602,7 +663,7 @@ def __init__(self):
602663
self.root.resizable(width=False, height=False)
603664

604665
self.root.geometry("400x420+{}+{}".format((self.root.winfo_screenwidth()-400)//2, (self.root.winfo_screenheight()-420)//2))
605-
self.root.title("GscScriptCompAndDecompiler by Tester")
666+
self.root.title("GscScriptCompAndDecompiler by Tester 2.0")
606667

607668
self.LeftSide = Frame(self.root, width=400, heigh=600)
608669
self.LeftSide.pack(side='left')
@@ -657,7 +718,7 @@ def InitLeftSide(self):
657718
#Техническое:
658719
def SetLangRus(self):
659720
self.Language = "RUS"
660-
self.root.title("GscScriptCompAndDecompiler от Tester-а")
721+
self.root.title("GscScriptCompAndDecompiler от Tester-а 2.0")
661722
self.Definer['text'] = " ОПРЕДЕЛИТЬ"
662723
self.Clearer['text'] = " ОЧИСТИТЬ "
663724
self.Undefiner['text'] = "РАЗОПРЕДЕЛИТЬ "
@@ -675,7 +736,7 @@ def SetLangRus(self):
675736
self.Outer['state'] = DISABLED
676737
def SetLangEng(self):
677738
self.Language = "ENG"
678-
self.root.title("GscScriptCompAndDecompiler by Tester")
739+
self.root.title("GscScriptCompAndDecompiler by Tester 2.0")
679740
self.Definer['text'] = " DEFINE"
680741
self.Clearer['text'] = " CLEAR "
681742
self.Undefiner['text'] = "UNDEFINE "
@@ -774,11 +835,15 @@ def RebuildGscFromGsc(self):
774835
self.Outer.insert(1.0, "Something went wrong...\nCouldn't rebuilt this .gsc...")
775836
self.Outer['state'] = DISABLED
776837
def DecompileToTxt(self):
838+
NewScript = GscFile(self.FileName, 0)
839+
NewScript.ReinitAll()
840+
NewScript.FileName = self.FileName
841+
NewScript.DecompileGscToTxt()
777842
try:
778-
NewScript = GscFile(self.FileName, 0)
779-
NewScript.ReinitAll()
780-
NewScript.FileName = self.FileName
781-
NewScript.DecompileGscToTxt()
843+
#NewScript = GscFile(self.FileName, 0)
844+
#NewScript.ReinitAll()
845+
#NewScript.FileName = self.FileName
846+
#NewScript.DecompileGscToTxt()
782847
self.Outer['state'] = NORMAL
783848
self.Outer.delete(1.0, END)
784849
if (self.Language == 'RUS'):
@@ -795,11 +860,15 @@ def DecompileToTxt(self):
795860
self.Outer.insert(1.0, "Something went wrong...\nCouldn't decompile this .gsc...")
796861
self.Outer['state'] = DISABLED
797862
def CompileFromTxt(self):
863+
NewScript = GscFile(self.FileName, 1)
864+
NewScript.ReinitAll()
865+
NewScript.FileName = self.FileName
866+
NewScript.CompileTxtToGsc()
798867
try:
799-
NewScript = GscFile(self.FileName, 1)
800-
NewScript.ReinitAll()
801-
NewScript.FileName = self.FileName
802-
NewScript.CompileTxtToGsc()
868+
#NewScript = GscFile(self.FileName, 1)
869+
#NewScript.ReinitAll()
870+
#NewScript.FileName = self.FileName
871+
#NewScript.CompileTxtToGsc()
803872
self.Outer['state'] = NORMAL
804873
self.Outer.delete(1.0, END)
805874
if (self.Language == 'RUS'):

0 commit comments

Comments
 (0)