nice working and testing
This commit is contained in:
6847
clannad_parser/00414.scr.txt
Normal file
6847
clannad_parser/00414.scr.txt
Normal file
File diff suppressed because it is too large
Load Diff
9314
clannad_parser/00416.scr.txt
Normal file
9314
clannad_parser/00416.scr.txt
Normal file
File diff suppressed because it is too large
Load Diff
11225
clannad_parser/00417.scr.txt
Normal file
11225
clannad_parser/00417.scr.txt
Normal file
File diff suppressed because it is too large
Load Diff
10127
clannad_parser/00418.scr.txt
Normal file
10127
clannad_parser/00418.scr.txt
Normal file
File diff suppressed because it is too large
Load Diff
6947
clannad_parser/00419.scr.txt
Normal file
6947
clannad_parser/00419.scr.txt
Normal file
File diff suppressed because it is too large
Load Diff
7963
clannad_parser/00420.scr.txt
Normal file
7963
clannad_parser/00420.scr.txt
Normal file
File diff suppressed because it is too large
Load Diff
10245
clannad_parser/00421.scr.txt
Normal file
10245
clannad_parser/00421.scr.txt
Normal file
File diff suppressed because it is too large
Load Diff
16973
clannad_parser/00422.scr.txt
Normal file
16973
clannad_parser/00422.scr.txt
Normal file
File diff suppressed because it is too large
Load Diff
16291
clannad_parser/00423.scr.txt
Normal file
16291
clannad_parser/00423.scr.txt
Normal file
File diff suppressed because it is too large
Load Diff
14209
clannad_parser/00424.scr.txt
Normal file
14209
clannad_parser/00424.scr.txt
Normal file
File diff suppressed because it is too large
Load Diff
9637
clannad_parser/00425.scr.txt
Normal file
9637
clannad_parser/00425.scr.txt
Normal file
File diff suppressed because it is too large
Load Diff
7545
clannad_parser/00429.scr.txt
Normal file
7545
clannad_parser/00429.scr.txt
Normal file
File diff suppressed because it is too large
Load Diff
12701
clannad_parser/02426.scr.txt
Normal file
12701
clannad_parser/02426.scr.txt
Normal file
File diff suppressed because it is too large
Load Diff
10268
clannad_parser/02509.scr.txt
Normal file
10268
clannad_parser/02509.scr.txt
Normal file
File diff suppressed because it is too large
Load Diff
13121
clannad_parser/04425.scr.txt
Normal file
13121
clannad_parser/04425.scr.txt
Normal file
File diff suppressed because it is too large
Load Diff
8831
clannad_parser/04503.scr.txt
Normal file
8831
clannad_parser/04503.scr.txt
Normal file
File diff suppressed because it is too large
Load Diff
9506
clannad_parser/04508.scr.txt
Normal file
9506
clannad_parser/04508.scr.txt
Normal file
File diff suppressed because it is too large
Load Diff
7885
clannad_parser/05424.scr.txt
Normal file
7885
clannad_parser/05424.scr.txt
Normal file
File diff suppressed because it is too large
Load Diff
10889
clannad_parser/05430.scr.txt
Normal file
10889
clannad_parser/05430.scr.txt
Normal file
File diff suppressed because it is too large
Load Diff
13128
clannad_parser/07400.scr.txt
Normal file
13128
clannad_parser/07400.scr.txt
Normal file
File diff suppressed because it is too large
Load Diff
12176
clannad_parser/07401.scr.txt
Normal file
12176
clannad_parser/07401.scr.txt
Normal file
File diff suppressed because it is too large
Load Diff
14175
clannad_parser/07500.scr.txt
Normal file
14175
clannad_parser/07500.scr.txt
Normal file
File diff suppressed because it is too large
Load Diff
13041
clannad_parser/07600.scr.txt
Normal file
13041
clannad_parser/07600.scr.txt
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,5 @@
|
||||
import sys
|
||||
import os
|
||||
|
||||
def parse_text_command(data, pos):
|
||||
# Читаем параметры в Little Endian
|
||||
@@ -17,18 +18,33 @@ def parse_text_command(data, pos):
|
||||
|
||||
# Декодируем UTF-16LE текст
|
||||
text = text_bytes.decode('utf-16le', errors='replace')
|
||||
total_size = 8 + len(text_bytes) + 2 # 8 байт заголовка + текст + 0000
|
||||
total_size = 8 + len(text_bytes) # 8 байт заголовка + текст + 0000
|
||||
return f"TextID: {text_id}, VoiceID: {voice_id}, Text: {text}", total_size
|
||||
|
||||
# База команд (идентификаторы в Big Endian)
|
||||
command_db = {
|
||||
0x0001: {
|
||||
"name": "Sprite",
|
||||
"size": 14,
|
||||
"handler": lambda data, pos: (f"ID: {int.from_bytes(data[pos+2:pos+4], 'little')} | " \
|
||||
+ f"MODE: {int.from_bytes(data[pos+4:pos+6], 'little')} | " \
|
||||
+ f"X: {int.from_bytes(data[pos+6:pos+8], 'big')} | " \
|
||||
+ f"Y: {int.from_bytes(data[pos+8:pos+10], 'big')} | " \
|
||||
+ f"fade: {int.from_bytes(data[pos+10:pos+12], 'big')}ms" \
|
||||
, 12)
|
||||
},
|
||||
0x1401: {
|
||||
"name": "PlayBGM",
|
||||
"name": "BGM",
|
||||
"size": 2,
|
||||
"handler": lambda data, pos: (f"BGM Track: {int.from_bytes(data[pos:pos+2], 'little')}", 2)
|
||||
},
|
||||
0x1600: {
|
||||
"name": "Pause",
|
||||
"size": 2,
|
||||
"handler": lambda data, pos: (f"{int.from_bytes(data[pos:pos+2], 'little')}ms", 2)
|
||||
},
|
||||
0x0A00: {
|
||||
"name": "ShowText",
|
||||
"name": "Text",
|
||||
"size": 8,
|
||||
"handler": parse_text_command
|
||||
}
|
||||
@@ -55,20 +71,51 @@ def parse_script(file_path):
|
||||
while pos % 4 != 0:
|
||||
pos += 1
|
||||
else:
|
||||
# output.append(f"[0x{pos:08X}][0x{cmd:04X}] UNKNOWN COMMAND")
|
||||
output.append(f"[0x{pos:08X}][0x{cmd:04X}] UNKNOWN COMMAND")
|
||||
pos += 2
|
||||
|
||||
# Сохраняем в файл
|
||||
with open("script" + file_path + ".txt", "w", encoding="utf-8") as f:
|
||||
output_file = file_path + ".txt"
|
||||
with open(output_file, "w", encoding="utf-8") as f:
|
||||
f.write("\n".join(output))
|
||||
|
||||
print(f"Обработан: {file_path} -> {output_file}")
|
||||
return output
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage: python parser.py <script.bin>")
|
||||
sys.exit(1)
|
||||
def batch_process_scr_files():
|
||||
# Получаем текущий каталог
|
||||
current_dir = os.getcwd()
|
||||
|
||||
results = parse_script(sys.argv[1])
|
||||
for line in results:
|
||||
print(line)
|
||||
# Ищем все файлы с расширением .scr
|
||||
scr_files = []
|
||||
for file_name in os.listdir(current_dir):
|
||||
if file_name.lower().endswith('.scr'):
|
||||
scr_files.append(file_name)
|
||||
|
||||
if not scr_files:
|
||||
print("Файлы с расширением .scr не найдены в текущем каталоге.")
|
||||
return []
|
||||
|
||||
print(f"Найдено {len(scr_files)} файлов .scr для обработки:")
|
||||
for file_name in scr_files:
|
||||
print(f" - {file_name}")
|
||||
|
||||
results = []
|
||||
for file_name in scr_files:
|
||||
try:
|
||||
file_results = parse_script(file_name)
|
||||
results.extend(file_results)
|
||||
except Exception as e:
|
||||
print(f"Ошибка при обработке файла {file_name}: {e}")
|
||||
|
||||
return results
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) > 1:
|
||||
# Если указан аргумент командной строки, обрабатываем указанный файл
|
||||
results = parse_script(sys.argv[1])
|
||||
for line in results:
|
||||
print(line)
|
||||
else:
|
||||
# Если аргументов нет, сканируем текущий каталог
|
||||
batch_process_scr_files()
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user