mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-13 06:34:23 -04:00
fusee_cpp: add logic for loading mtc overlays
This commit is contained in:
parent
4480e7a8a5
commit
3bcdd0c3c8
157 changed files with 2222 additions and 47 deletions
61
fusee_cpp/program/split_bin.py
Normal file
61
fusee_cpp/program/split_bin.py
Normal file
|
@ -0,0 +1,61 @@
|
|||
#!/usr/bin/env python
|
||||
import sys, lz4
|
||||
from struct import unpack as up
|
||||
|
||||
def lz4_compress(data):
|
||||
try:
|
||||
import lz4.block as block
|
||||
except ImportError:
|
||||
block = lz4.LZ4_compress
|
||||
return block.compress(data, 'high_compression', store_size=False)
|
||||
|
||||
def read_file(fn):
|
||||
with open(fn, 'rb') as f:
|
||||
return f.read()
|
||||
|
||||
def pad(data, size):
|
||||
return (data + '\x00' * size)[:size]
|
||||
|
||||
def get_overlay(program, i):
|
||||
return program[0x2B000 + 0x14000 * i:0x2B000 + 0x14000 * (i+1)]
|
||||
|
||||
def main(argc, argv):
|
||||
if argc == 2:
|
||||
target = argv[1]
|
||||
if len(target) == 0:
|
||||
target = ''
|
||||
elif argc == 1:
|
||||
target = ''
|
||||
else:
|
||||
print('Usage: %s target' % argv[0])
|
||||
return 1
|
||||
with open('../../program%s.bin' % target, 'rb') as f:
|
||||
data = f.read()
|
||||
with open('../../program%s.lz4' % target, 'wb') as f:
|
||||
f.write(lz4_compress(data[:0x2B000] + get_overlay(data, 0)[:0x11000]))
|
||||
with open('../../fusee-boogaloo%s.bin' % target, 'wb') as f:
|
||||
# TODO: Write header
|
||||
f.write('\xCC'*0x800)
|
||||
# TODO: Write warmboot
|
||||
f.write('\xCC'*0x1800)
|
||||
# Write TSEC Keygen
|
||||
f.write(pad(read_file('../../tsec_keygen/tsec_keygen.bin'), 0x2000))
|
||||
# TODO: Write Mariko Fatal
|
||||
f.write('\xCC'*0x1C000)
|
||||
# Write Erista MTC
|
||||
f.write(get_overlay(data, 1))
|
||||
# Write Mariko MTC
|
||||
f.write(get_overlay(data, 2))
|
||||
# TODO: Write exosphere
|
||||
f.write('\xCC'*0x10000)
|
||||
# TODO: Write mesosphere
|
||||
f.write('\xCC'*0xA8000)
|
||||
# TODO: Write kips
|
||||
f.write('\xCC'*0x300000)
|
||||
# Write Splash Screen
|
||||
f.write(pad(read_file('../../splash_screen/splash_screen.bin'), 0x3C0000))
|
||||
|
||||
return 0
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(len(sys.argv), sys.argv))
|
Loading…
Add table
Add a link
Reference in a new issue