Skip to content

Instantly share code, notes, and snippets.

@foone
Created September 19, 2020 04:11
Show Gist options
  • Save foone/469e3c0912a405011bee1e146bf07a55 to your computer and use it in GitHub Desktop.
Save foone/469e3c0912a405011bee1e146bf07a55 to your computer and use it in GitHub Desktop.
RPT decoder for Super Mario 64 RPT textures from Super Mario 3D All-Stars
# To use:
# 1. extract the NCAs from the NSP (I used NSCB)
# 2. extract the contents of 5977df9d4848858cbde157c6723dd1de.nca
# 3. inside 1 [romfs]\rom\Stardust_JP\Textures you'll find texture_pack.cpio. Extract it (I uzed 7zip)
# 4. run this python 2.7 script in the directory with all the .rpt files. It'll create a out folder containing all the PNGs
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())
with open(name,'rb') as f:
imagetype = ord(data[0x19])
w,_,h = struct.unpack('>HHH',data[0x22:0x28])
print 'Type: {:02x} w:{} h:{}'.format(imagetype,w,h)
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)
@ROGsamurai
Copy link

update for nso rpt's?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment