Last active
February 27, 2023 19:48
-
-
Save ImanCol/be4b327e68e6df204922ba7f2c789b2d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
set /p rpt_ID=Ingresa el archivo dump de IDs | |
:: set /p rpt_RDRAM=Ingresa el archivo dump de RDRAM | |
"tools/xxd.exe" -e -g4 "%rpt_ID%" | "tools/xxd.exe" -r > database_IDs.bin | |
:: "tools/xxd.exe" -e -g4 "%rpt_RDRAM%" | "tools/xxd.exe" -r > database_RDRAM.bin | |
pause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##No se python :) | |
##Si tu sabes python, te invito a mejorar esto | |
##Basado en el codigo original de conversion de texturas rpt, incluye implementaciones propias | |
import struct,glob,os,zlib | |
from PIL import Image | |
offset = 0xb8 | |
OUTDIR='out_png' | |
if not os.path.exists(OUTDIR): | |
os.mkdir(OUTDIR) | |
for x in range(500): | |
#print(name) | |
with open('database_IDs.bin', 'rb') as f: | |
RPT_offset = offset | |
data_id=(f.read()) | |
#print(hex(RPT_offset * x)) | |
#print(data_id) | |
RPT_offset = RPT_offset * x | |
imagetype = data_id[0x1B+RPT_offset] | |
##GET DATA RPT | |
ID_Group = ('{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}'.format(data_id[0x30+RPT_offset],data_id[0x31+RPT_offset],data_id[0x32+RPT_offset],data_id[0x33+RPT_offset],data_id[0x34+RPT_offset],data_id[0x35+RPT_offset],data_id[0x36+RPT_offset],data_id[0x37+RPT_offset])) | |
ID_Group = int(ID_Group, 16) | |
#086c805510040100 | |
#086c805510040300 | |
ID_1 = ('{:02x}{:02x}{:02x}{:02x}'.format(data_id[0x40+RPT_offset],data_id[0x41+RPT_offset],data_id[0x42+RPT_offset],data_id[0x43+RPT_offset])) | |
ID_1 = int(ID_1, 16) | |
ID_2 = ('{:02x}{:02x}{:02x}{:02x}'.format(data_id[0x44+RPT_offset],data_id[0x45+RPT_offset],data_id[0x46+RPT_offset],data_id[0x47+RPT_offset])) | |
ID_2 = int(ID_2, 16) | |
Addrss_RDRAM = ('{:02x}{:02x}{:02x}{:02x}'.format(data_id[0x10+RPT_offset],data_id[0x11+RPT_offset],data_id[0x12+RPT_offset],data_id[0x13+RPT_offset])) | |
Addrss_RDRAM = int(Addrss_RDRAM, 16) | |
w = ('{:02x}'.format(data_id[0x0F+RPT_offset])) | |
h = ('{:02x}'.format(data_id[0x0D+RPT_offset])) | |
w = int(w, 16) | |
h = int(h, 16) | |
ID_Group_Len = "" | |
ID_1_Len = "" | |
ID_2_Len = "" | |
ID_Group_Len = len("{:x}".format(ID_Group)) | |
ID_1_Len = len("{:x}".format(ID_1)) | |
ID_2_Len = len("{:x}".format(ID_2)) | |
if ID_Group_Len == 16: | |
ID_Group_Len = "" | |
if ID_Group_Len == 15: | |
ID_Group_Len = "0" | |
if ID_Group_Len == 14: | |
ID_Group_Len = "00" | |
if ID_Group_Len == 13: | |
ID_Group_Len = "000" | |
if ID_1_Len == 0: | |
ID_1_Len = "00000000" | |
if ID_1_Len == 1: | |
ID_1_Len = "0000000" | |
if ID_1_Len == 2: | |
ID_1_Len = "000000" | |
if ID_1_Len == 3: | |
ID_1_Len = "00000" | |
if ID_1_Len == 4: | |
ID_1_Len = "0000" | |
if ID_1_Len == 5: | |
ID_1_Len = "000" | |
if ID_1_Len == 6: | |
ID_1_Len = "00" | |
if ID_1_Len == 7: | |
ID_1_Len = "0" | |
if ID_1_Len == 8: | |
ID_1_Len = "" | |
if ID_2_Len == 0: | |
ID_2_Len = "00000000" | |
if ID_2_Len == 1: | |
ID_2_Len = "0000000" | |
if ID_2_Len == 2: | |
ID_2_Len = "000000" | |
if ID_2_Len == 3: | |
ID_2_Len = "00000" | |
if ID_2_Len == 4: | |
ID_2_Len = "0000" | |
if ID_2_Len == 5: | |
ID_2_Len = "000" | |
if ID_2_Len == 6: | |
ID_2_Len = "00" | |
if ID_2_Len == 7: | |
ID_2_Len = "0" | |
if ID_2_Len == 8: | |
ID_2_Len = "" | |
#type_format = "" | |
outpath=os.path.join('out_png/w{}-h{}-{}{:0x}-{}{:0x}-{}{:0x}'.format(w,h,ID_Group_Len,ID_Group,ID_1_Len,ID_1,ID_2_Len,ID_2)+".png") | |
log_png=os.path.join('w{}-h{}-{}{:0x}-{}{:0x}-{}{:0x}'.format(w,h,ID_Group_Len,ID_Group,ID_1_Len,ID_1,ID_2_Len,ID_2)+".png\n") | |
#log2=os.path.join('w{} h{} GroupID:0{:0x} ID1:{:0x} ID2:{:0x} RDRAM Addrss:{:0x} '.format(w,h,ID_Group,ID_1,ID_2,Addrss_RDRAM)) | |
log_rpt=os.path.join('Type Image:{}\nWidth:{}\nHeight:{}\nGroupID:{}{:0x}\nID1:{}{:0x}\nID2:{}{:0x}\nRDRAM Offset:{:0x}\n-------------\n'.format(imagetype,w,h,ID_Group_Len,ID_Group,ID_1_Len,ID_1,ID_2_Len,ID_2,Addrss_RDRAM)) | |
##Info de tipo de imagen no precisa. | |
#if imagetype == 0x1: | |
# type_format = "rgba16" | |
# outpath=os.path.join('out/w{}_h{}_{}_0{:0x}_{:0x}_{:0x}'.format(w,h,type_format,ID_Group,ID_1,ID_2)+".png") | |
#if imagetype == 0x2: | |
# type_format = "ia8" | |
# outpath=os.path.join('out/w{}_h{}_{}_0{:0x}_{:0x}_{:0x}'.format(w,h,type_format,ID_Group,ID_1,ID_2)+".png") | |
#if imagetype == 0x3: | |
# type_format = "ia16" | |
# outpath=os.path.join('out/w{}_h{}_{}_0{:0x}_{:0x}_{:0x}'.format(w,h,type_format,ID_Group,ID_1,ID_2)+".png") | |
#if imagetype == 0x4: | |
# type_format = "i8" | |
# outpath=os.path.join('out/w{}_h{}_{}_0{:0x}_{:0x}_{:0x}'.format(w,h,type_format,ID_Group,ID_1,ID_2)+".png") | |
if os.path.exists(outpath): | |
print(outpath+" Ya hay un archivo") | |
print('Index:',x) | |
#print("Type Image",imagetype) | |
print('ID Group:',hex(ID_Group)) | |
print('ID 1:',hex(ID_1)) | |
print('ID 2:',hex(ID_2)) | |
print('Width:{}'.format(w)) | |
print('Height:{}'.format(h)) | |
print('RDRAM Addrss:',hex(Addrss_RDRAM)) | |
print("----------") | |
continue | |
##PRINT LOG | |
if Addrss_RDRAM == 0xffffffff: | |
print("Posiblemente ya exista un rpt para:") | |
print('Index:',x) | |
#print("Type Image",imagetype) | |
print('ID Group:',hex(ID_Group)) | |
print('ID 1:',hex(ID_1)) | |
print('ID 2:',hex(ID_2)) | |
print('Width:{}'.format(w)) | |
print('Height:{}'.format(h)) | |
print('RDRAM Addrss: Ninguna') | |
print("----------") | |
continue | |
if Addrss_RDRAM == 0x00000000: | |
print("Llegastes al final?") | |
print("----------") | |
continue | |
print('Index:',x) | |
#print("Type Image",imagetype) | |
print('ID Group:',hex(ID_Group)) | |
print('ID 1:',hex(ID_1)) | |
print('ID 2:',hex(ID_2)) | |
print('RDRAM Addrss:',hex(Addrss_RDRAM)) | |
print('Width:{}'.format(w)) | |
print('Height:{}'.format(h)) | |
with open('database_RDRAM.bin','rb') as f: | |
f.seek(Addrss_RDRAM) | |
data_rdram = f.read() | |
if w==0 or h==0: | |
print('Bad image!') | |
continue | |
img = Image.frombytes('RGBA', (w,h), data_rdram[0x00:0x00+w*h*4]) | |
img.save(outpath) | |
#print("save:"+outpath) | |
print(outpath) | |
print("----------") | |
with open('database_png.txt','a') as f: | |
f.writelines(log_png) | |
f.close() | |
with open('database_rpt.txt','a') as f: | |
f.writelines(log_rpt) | |
f.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
set /p rpt_in=Ingresa la carpeta de tus rpt | |
set /p rpt_out=Ingresa la carpeta donde se descomprimiran | |
"tools/offzip.exe" -a -r "%rpt_in%" "%rpt_out%" 0 | |
pause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import struct,glob,os,zlib | |
from PIL import Image | |
OUTDIR='out' | |
if not os.path.exists(OUTDIR): | |
os.mkdir(OUTDIR) | |
for name in glob.glob('*.rpt'): | |
outpath=os.path.join(OUTDIR,name+'.png') | |
if os.path.exists(outpath): | |
continue | |
print(name) | |
with open(name, 'rb') as f: | |
#data=zlib.decompress(f.read()) | |
data=(f.read()) | |
with open(name,'rb') as f: | |
imagetype = data[0x19] | |
w,_,h = struct.unpack('>HHH',data[0x22:0x28]) | |
print('Type: {:02x} w:{} h:{}'.format(imagetype,w,h)) | |
print('outpath'.format(data)) | |
if w==0 or h==0: | |
print('Bad image!') | |
continue | |
img = Image.frombytes('RGBA', (w,h), data[0x40:0x40+w*h*4]) | |
img.save(outpath) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Revision of this script by foone: https://gist.github.com/foone/469e3c0912a405011bee1e146bf07a55 | |
#I had some problem with his script so I did a revison for Python 3.8 | |
import struct,glob,os,zlib | |
OUTDIR='out' | |
if not os.path.exists(OUTDIR): | |
os.mkdir(OUTDIR) | |
for name in glob.glob('*.rpt'): | |
outpath=os.path.join(OUTDIR,name) | |
if os.path.exists(outpath): | |
continue | |
print(name) | |
with open(name, 'rb') as f: | |
data=zlib.decompress(f.read()) | |
f=open(outpath,"wb") | |
f.write(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"C:\Program Files\AdoptOpenJDK\jdk-8.0.282.8-hotspot\bin\javaw.exe" -jar "C:\Program Files\WebScarab\webscarab.jar" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment