Skip to content

Commit

Permalink
2.1 update.
Browse files Browse the repository at this point in the history
+ Partial support of Inganok's choices (with two variants).
+ Fix a great problem: there wasn't a possibility to add commands in many scripts of latter versions of codeXRScript.
  • Loading branch information
TesterTesterov committed Jun 26, 2020
1 parent 59208d9 commit da1d30e
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions gscScriptCompAndDecompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class GscFile:
(0x05, 'i', 'JUMP'),
(0x0D, 'i', 'PAUSE'),
(0x0C, 'ii', 'CALL_SCRIPT'), #[имя скрипта без начальных нулей, ???]
(0x0E, 'hiiiiiiiiiiiiii', 'CHOICE'),
(0x14, 'ii', 'IMAGE_GET'),
(0x1A, '', 'IMAGE_SET'),
(0x1C, 'iii', 'BLEND_IMG'),
Expand All @@ -70,7 +71,6 @@ class GscFile:
(0x09, 'h', ''),
(0x0A, '', ''), #h в другом типе? Хм-м... #WAIT_FOR_CLICK?
(0x0B, '', ''),
(0x0E, 'hiiiiiiiiiiiiii', ''), #???
(0x0F, 'iiiiiiiiiiii', ''), #??? #Массив? Подправить число аргументов?
(0x10, 'i', ''),
(0x11, '', ''),
Expand Down Expand Up @@ -197,18 +197,21 @@ class GscFile:
(0x5800, 'hhh', ''),
(0x6800, 'hhh', ''),
(0x7800, 'hhh', ''),
(0x7A00, 'hhh', ''),
(0x8800, 'hhh', ''),
(0x8A00, 'hhh', ''),
(0x9800, 'hhh', ''),
(0x9810, 'hhh', ''), #!!!
(0x9A00, 'hhh', ''),
(0xA100, 'hhh', ''),
(0xA200, 'hhh', ''),
(0xA201, 'hhh', ''), #!!
(0xA400, 'hhh', ''),
(0xA500, 'hhh', ''),
(0xA600, 'hhh', ''),
(0xA800, 'hhh', ''),
(0xA810, 'hhh', ''), #!!!
(0xA900, 'hhh', ''),
(0xB400, 'hhh', ''),
(0xB800, 'hhh', ''),
(0xB900, 'hhh', ''),
Expand All @@ -223,18 +226,20 @@ class GscFile:
#(n)(1) - структура;
#(n)(2) - определение (может быть пустым).

ConnectedStringsLibrary = [[0x0F, [1]],
ConnectedStringsLibrary = [[0x0E, [7, 8]],
[0x0F, [1]],
[0x51, [-3, -2]],
[0x52, [-2]],
[0x79, [1]]]
[0x79, [1]]] #!!!
#Библиотека связанных со строками аргументов.
#(n)(0) - команда;
#(n)(1) - список связанных аргументов.

#Далее костыли по связанным со смещениям аргументам.

ConnectedOffsetsLibrary = [[0x03, [0]],
[0x05, [0]]]
[0x05, [0]],
[0xC8, [0]]]
Labels = []
#[0] - индекс метки, [1] - смещение метки.

Expand Down Expand Up @@ -568,7 +573,7 @@ def CompileTxtToGsc(self):
if (Lines[i] == ''):
i += 1
continue
if (Lines[i][0] == '<'): #Комментарии.
if (Lines[i][0] == '$'): #Комментарии.
i += 1
continue
if (Lines[i][0] == '@'): #Метки (забираются раньше).
Expand All @@ -586,7 +591,7 @@ def CompileTxtToGsc(self):
String = String + '^n'
i += 1
continue
if (Lines[i][0] == '<'): #Комментарии.
if (Lines[i][0] == '$'): #Комментарии.
i += 1
continue
if ((Lines[i][0] == '#') or (Lines[i][0] == '>') or (Lines[i][0] == '@')):
Expand Down Expand Up @@ -654,7 +659,7 @@ def CompileTxtToGsc(self):
String = String + '^n'
i += 1
continue
if (Lines[i][0] == '<'): #Комментарии.
if (Lines[i][0] == '$'): #Комментарии.
i += 1
continue
if ((Lines[i][0] == '#') or (Lines[i][0] == '>') or (Lines[i][0] == '@')):
Expand Down Expand Up @@ -950,14 +955,14 @@ def CommonHelp(self):
mb.showwarning("Common help", """This program was developed for correctly working with .gsc files of the engine codeX Rscript, which also called as Liar-soft Engine and raiL-soft Engine. The engine is rather simple much like it's formats, for example .gsc, with which through may be some problematic moments. Still the moments are ceasing by the specific decompile and compile. But the scheme can also cause problems it some situations.\n\nThis program allow you to:\n1. Rebuild .gsc-files from themselves so you can optimize them, for in many of .gsc-files there may be some trash elements. For example some number of zeros in the end. But this command is not garantee that all trash elements will be removed. This command also allow you to see .gsc-file's parametrs and unknown commands. It may be useful for code analysis.\2. .gsc to .txt decomple. It allow you to edit scripts as you like (with limitations of syntax, of course). For example, with this tool you can easily add new message.\n3. .txt to .gsc compile. This allow you to rebuild .gsc from decompiled and may be edited ealier code. It doesn't need an ealier .gsc to present for run.\n\nFor usage:\n1. Drag the .gsc script or .txt with decompiled data to the tool directory.\n2. Write the file name in the tool entry and push the "DEFINE".\n3. Use the commands below.""")
def CommandHelp(self):
if (self.Language == "RUS"):
mb.showwarning("Помощь по командам", """Увы, команд известно мало (но не их структур), а их аргументов ещё меньше. Что, впрочем, может измениться в будущем. Всякая известная команда в файле обозначена некоторой строкой.\n\nИтак, приведём базовые известные команды с аргументами:\n\n3 (0x03): JUMP_UNLESS.\nАргументы: [???]\n5 (0x05): JUMP.\nАргументы: [смещение от начала блока команд].\n13 (0x0D): PAUSE.\nАргументы: [время в секундах].\n20 (0x14): IMAGE_DEF.\nАргументы: [индекс картинки (из имени), ???].\n26 (0x1A): SCENE_SET.\nАргументы: [].\n28 (0x1C): BLEND_IMG.\nАргументы: [???, тип1, тип2].\n81 (0x51): MESSAGE.\nАргументы: [???, индекс гласа (из имени), ???, ???, -1, ???].\nВ самом .gsc вместо "-1" номер сообщения!\n200 (0xC8): READ_SCENARIO.\nАргументы: [???, ???, ???, ???, ???, ???, ???, ???, ???, ???, ???].\n255 (0xFF): SPRITE.\nАргументы: [режим, позиция, индекс картинки, ???, ???].\n13568 (0x3500): AND.\nАргументы: [???, ???, ???].\n18432 (0x4800): EQUALS.\nАргументы: [???, ???, ???].\n21504 (0x5400): GREATER_EQUALS.\nАргументы: [???, ???, ???].\n43520 (0xAA00): ADD.\nАргументы: [???, ???, ???].\n61696 (0xF100): ASSIGN.\nАргументы: [???, ???].""")
mb.showwarning("Помощь по командам", """Увы, команд известно мало (но не их структур), а их аргументов ещё меньше. Что, впрочем, может измениться в будущем. Всякая известная команда в файле обозначена некоторой строкой.\n\nИтак, приведём базовые известные команды с аргументами:\n\n3 (0x03): JUMP_UNLESS.\nАргументы: [метка].\n5 (0x05): JUMP.\nАргументы: [метка].\n12 (0x0C): CALL_SCRIPT.\nАргументы: [номер скрипта, ???]\n13 (0x0D): PAUSE.\nАргументы: [время в секундах].\n14 (0x0E): CHOICE.\nАргументы: [???, ???, ???, ???, ???, ???, ???, -1, -1, ???, ???, ???, ???, ???, ???].\n20 (0x14): IMAGE_GET.\nАргументы: [индекс картинки (из имени), ???].\n26 (0x1A): IMAGE_SET.\nАргументы: [].\n28 (0x1C): BLEND_IMG.\nАргументы: [???, тип1, тип2].\n30 (0x1E): IMAGE_DEF.\nАргументы: [???, ???, ???, ???, ???, ???].\n81 (0x51): MESSAGE.\nАргументы: [???, индекс гласа (из имени), ???, -1, -1, ???].\n82 (0x52): APPEND_MESSAGE.\nАргументы: [???, ???, ???, ???, -1, ???].\n121 (0x79): GET_DIRECTORY.\nАргументы: [???, -1].\n200 (0xC8): READ_SCENARIO.\nАргументы: [???, ???, ???, ???, ???, ???, ???, ???, ???, ???, ???].\n255 (0xFF): SPRITE.\nАргументы: [режим, позиция, индекс картинки, ???, ???].\n13568 (0x3500): AND.\nАргументы: [???, ???, ???].\n18432 (0x4800): EQUALS.\nАргументы: [???, ???, ???].\n21504 (0x5400): GREATER_EQUALS.\nАргументы: [???, ???, ???].\n43520 (0xAA00): ADD.\nАргументы: [???, ???, ???].\n61696 (0xF100): ASSIGN.\nАргументы: [???, ???].""")
else:
mb.showwarning("Command help", """Unfortunately, the number of known commands aren't big (but not of the structures). It may change it the future. All known commands are defined in decomilated file as a string.\n\nWell, let's show you a basic known commands with the arguments:\n\n3 (0x03): JUMP_UNLESS.\nArguments: [???]\n5 (0x05): JUMP.\nArguments: [offset from the beginning of command block].\n13 (0x0D): PAUSE.\nArguments: [time in seconds].\n20 (0x14): IMAGE_DEF.\nArguments: [image index (from the name), ???].\n26 (0x1A): SCENE_SET.\nArguments: [].\n28 (0x1C): BLEND_IMG.\nArguments: [???, type1, type2].\n81 (0x51): MESSAGE.\nArguments: [???, voice index (from the name), ???, ???, -1, ???].\nIn a .gsc itself is not a -1, but a message number.\n200 (0xC8): READ_SCENARIO.\nArguments: [???, ???, ???, ???, ???, ???, ???, ???, ???, ???, ???].\n255 (0xFF): SPRITE.\nArguments: [mode, position, image index, ???, ???].\n13568 (0x3500): AND.\nArguments: [???, ???, ???].\n18432 (0x4800): EQUALS.\nArguments: [???, ???, ???].\n21504 (0x5400): GREATER_EQUALS.\nArguments: [???, ???, ???].\n43520 (0xAA00): ADD.\nArguments: [???, ???, ???].\n61696 (0xF100): ASSIGN.\nArguments: [???, ???].""")
mb.showwarning("Command help", """Unfortunately, the number of known commands aren't big (but not of the structures). It may change it the future. All known commands are defined in decomilated file as a string.\n\nWell, let's show you a basic known commands with the arguments:\n\n3 (0x03): JUMP_UNLESS.\nArguments: [label]\n5 (0x05): JUMP.\nArguments: [label].\n12 (0x0C): CALL_SCRIPT.\nArguments: [script number, ???]0\n13 (0x0D): PAUSE.\nArguments: [time in seconds].\n14 (0x0E): CHOICE.\nArguments: [???, ???, ???, ???, ???, ???, ???, -1, -1, ???, ???, ???, ???, ???, ???].\n20 (0x14): IMAGE_GET.\nArguments: [image index (from the name), ???].\n26 (0x1A): IMAGE_SET.\nArguments: [].\n28 (0x1C): BLEND_IMG.\nArguments: [???, type1, type2].\n30 (0x1E): IMAGE_DEF.\nArguments: [???, ???, ???, ???, ???, ???].\n81 (0x51): MESSAGE.\nArguments: [???, voice index (from the name), ???, -1, -1, ???].\n82 (0x52): APPEND_MESSAGE.\nArguments: [???, ???, ???, ???, -1, ???].\n121 (0x79): GET_DIRECTORY.\nArguments: [???, -1].\n200 (0xC8): READ_SCENARIO.\nArguments: [???, ???, ???, ???, ???, ???, ???, ???, ???, ???, ???].\n255 (0xFF): SPRITE.\nArguments: [mode, position, image index, ???, ???].\n13568 (0x3500): AND.\nArguments: [???, ???, ???].\n18432 (0x4800): EQUALS.\nArguments: [???, ???, ???].\n21504 (0x5400): GREATER_EQUALS.\nArguments: [???, ???, ???].\n43520 (0xAA00): ADD.\nArguments: [???, ???, ???].\n61696 (0xF100): ASSIGN.\nArguments: [???, ???].""")
def SyntaxHelp(self):
if (self.Language == "RUS"):
mb.showwarning("Помощь по синтаксису", """Для тех, кто скрипты именно редактировать жаждет, сие крайне важно знать. Синтаксис в целом прост, но имеет ряд особенностей.\n\n|"<" в начале строки обозначает однострочный комментарий.\n"#" в начале строки есть определение команды.\n\n"[..., ..., ...]" есть форма описания аргументов функции (разделяются запятой) и следует сразу после определения команды.\n\nАргумент "-1" значит, что он связан с индексом следующей строки.\n\n">" обозначает строк начало.\nПосле сего идёт либо показатель изначального индекса строки, либо -1. -1 значит, что строка связанная. Связанные строки всегда следуют после задачи связанных аргументов.\nВАЖНО: ИНДЕКСЫ ПОСЛЕ ">" ОТОБРАЖАЮТ ЛИШЬ ИЗНАЧАЛЬНЫЕ ИНДЕКСЫ! ПРИ КОМПИЛЯЦИИ ИНДЕКС СТРОКИ БЕРЁТСЯ ЛИШЬ ИЗ НОМЕРА ">" В СКРИПТЕ!\nВАЖНО: НЕ ВСЕ СВЯЗНАННЫЕ ИНДЕКСЫ БЫЛИ НАЙДЕНЫ!""")
mb.showwarning("Помощь по синтаксису", """Для тех, кто скрипты именно редактировать жаждет, сие крайне важно знать. Синтаксис в целом прост, но имеет ряд особенностей.\n\n|"$" в начале строки обозначает однострочный комментарий.\n"#" в начале строки есть определение команды.\n\n"[..., ..., ...]" есть форма описания аргументов функции (разделяются запятой) и следует сразу после определения команды.\n\n"@" есть метка, на кою ссылаются некоторые команды.\n\nАргумент "-1" значит, что он связан с индексом следующей строки.\n\n">" обозначает строк начало.\nПосле сего идёт либо показатель изначального индекса строки, либо -1. -1 значит, что строка связанная. Связанные строки всегда следуют после задачи связанных аргументов.\nВАЖНО: ИНДЕКСЫ ПОСЛЕ ">" ОТОБРАЖАЮТ ЛИШЬ ИЗНАЧАЛЬНЫЕ ИНДЕКСЫ! ПРИ КОМПИЛЯЦИИ ИНДЕКС СТРОКИ БЕРЁТСЯ ЛИШЬ ИЗ НОМЕРА ">" В СКРИПТЕ!\nВАЖНО: НЕ ВСЕ СВЯЗНАННЫЕ ИНДЕКСЫ БЫЛИ НАЙДЕНЫ!""")
else:
mb.showwarning("Syntax help", """For those who desire for scripts to edit it's very important. The syntax is rather simple, but it have some specific moments.\n\n"<" is the string's beginning is for one-string comment.\n\n"#" in the string's beginning is for defination of command.\n\n"[..., ..., ...]" is for function argument's splitted with "," form. It goes strictly on the next line after the command defination.\n\nA "-1" argument means it connected with next string index.\n\n">" is for string beginning.\nAfter its goes mark of primar index of string or -1. If it's -1, the string is connected. Connected strings always goes after the defination of connected arguments.\nDO NOTE: INDEXES AFTER ">" SHOWS ONLY PRIMAR INDEXES! THEN COMPILE PROGRAM TAKE A STRING INDEX ONLY FROM THE NUMBER OF ">" IN SCRIPT!\nDO NOTE: NOT AN ALL OF CONNECTED INDEXES WAS FOUND!""")
mb.showwarning("Syntax help", """For those who desire for scripts to edit it's very important. The syntax is rather simple, but it have some specific moments.\n\n"$" is the string's beginning is for one-string comment.\n\n"#" in the string's beginning is for defination of command.\n\n"[..., ..., ...]" is for function argument's splitted with "," form. It goes strictly on the next line after the command defination.\n\n"@" is a label, to which some arguments are connecting.\n\nA "-1" argument means it connected with next string index.\n\n">" is for string beginning.\nAfter its goes mark of primar index of string or -1. If it's -1, the string is connected. Connected strings always goes after the defination of connected arguments.\nDO NOTE: INDEXES AFTER ">" SHOWS ONLY PRIMAR INDEXES! THEN COMPILE PROGRAM TAKE A STRING INDEX ONLY FROM THE NUMBER OF ">" IN SCRIPT!\nDO NOTE: NOT AN ALL OF CONNECTED INDEXES WAS FOUND!""")
#Связь с .gsc:
def RebuildGscFromGsc(self):
try:
Expand Down

0 comments on commit da1d30e

Please sign in to comment.