Skip to content

Instantly share code, notes, and snippets.

View NWPlayer123's full-sized avatar

NWPlayer123 NWPlayer123

View GitHub Profile
from struct import pack, unpack
import sys
#.bss
left9 = [0] * 0x400 #u16
right9 = [0] * 0x400 #u16
left12 = [0] * 0x10000 #u16
right12 = [0] * 0x10000 #u16
stack = [0] * 0x100 #u32
#.sbss
@NWPlayer123
NWPlayer123 / decode_ash.c
Created January 31, 2023 06:33
decompression code from My Pokemon Ranch, seems similar to the ash used by the Wii Menu
//.bss
u16 left9[0x400]; //8067E830
u16 right9[0x400]; //8067F030
u16 left12[0x10000]; //8067F830
u16 right12[0x10000]; //8069F830
u32 stack[0x100]; //806BF830
//.sbss
s32 bitlen[2];
s32 ccnt[2];
@NWPlayer123
NWPlayer123 / extract_fpk.py
Created August 23, 2022 00:51
Extract Compressed Data from Monster Hunter G (Wii) fpk files
from struct import unpack
from os import makedirs
from os.path import exists
sortme = [] #I don't trust that this is sorted
with open("0000.fpk", "rb") as f:
#read header, make sure it's valid
unknown, entry_count, header_size, total_size = unpack(">4I", f.read(0x10))
f.seek(0, 2)
assert total_size == f.tell()
@NWPlayer123
NWPlayer123 / extract_wmbt2.py
Created September 7, 2021 07:59
see original description
from struct import unpack
import sys
def align(value):
return value + (0x10 - (value % 0x10))
def full(f):
return unpack("<I", f.read(4))[0]
def LBL1(f):
@NWPlayer123
NWPlayer123 / extract_wmbt.py
Created September 7, 2021 07:31
for WarioWare: Get It Together!, Python 2, no warranty if it breaks on some file
from struct import unpack
import sys
def align(value):
return value + (0x10 - (value % 0x10))
def full(f):
return unpack("<I", f.read(4))[0]
def LBL1(f):
@NWPlayer123
NWPlayer123 / decrypt_tad.py
Created September 11, 2020 01:55
Tool for decrypting DSi TADs (not the ones listed on dsibrew, that's wrong, the installable ones that are closer to WADs), py2/3
from io import BytesIO
from struct import unpack
from binascii import hexlify, unhexlify
from Crypto.Cipher import AES #pip install pycryptodome
import sys
def generate_key(string):
key_hex = int(string, 16)
key_add = int(b"1" * 32, 16)
combine = key_hex + key_add
@NWPlayer123
NWPlayer123 / scrape_data.py
Created March 31, 2020 04:35
Animal Crossing New Horizons data scraping (to show fixer algo)
from bcsv_reader import BCSV
from msbt_reader import MSBT
from binascii import hexlify
from os import listdir
import sys, string, codecs
'''reload(sys)
sys.setdefaultencoding('utf8')'''
msg_path = "../message1.1"
bcsv_path = "."
@NWPlayer123
NWPlayer123 / read_ispy_text.py
Created December 29, 2019 06:56
Ultimate I Spy for Wii
from struct import unpack
with open("enUS.dat", "rb") as f:
header = unpack("<5I", f.read(0x14))
table1 = unpack("<%sI" % header[2], f.read(4 * header[2]))
table1 += tuple([header[3] - (4 * header[2])])
strings1 = []
for i in range(len(table1) - 1):
strings1.append(f.read((table1[i+1] & 0xFFFFFF) - (table1[i] & 0xFFFFFF)).rstrip("\x00"))
table2 = []
@NWPlayer123
NWPlayer123 / checkpoint_ftp_dl.py
Created November 21, 2019 07:37
download all Checkpoint save folders for a game
#change local_ip to whatever NX-Shell/other FTP homebrew says
#saves_folder can be changed to whatever, this is just Pokemon Shield
#only recurses one directory so you gotta select a specific game's folder
from ftplib import FTP
from os.path import exists
from os import mkdir
local_ip = "192.168.0.13"
saves_folder = "/switch/Checkpoint/saves/0x01008DB008C2C000 0x01008DB008C2C000/"
Restore Health (Down + B) [NWPlayer123]
04004BF0 7C7F1B78
04004BF4 7C9E2378
04004BF8 3C60804D
04004BFC 3863AFD0
04004C00 A0630000
04004C04 28030204
04004C08 40820008
04004C0C 3BC00064
04004C10 7FE3FB78