mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-11-23 01:42:19 -05:00
09432ee7f4
* Initial Linux/GCC support commit * Add instructins for linux in the README * apply suggestions by @Erotemic and @Emill * Fix python 3.10 symlink line * Fix func_80041E80 type mismatch (#3) Type mismatch functions.h:664 * Makefile: clean OTRExporter/libultraship/ZAPDTR with distclean and fix CXX_FILES * Makefile: find C/CXX_FILES automatically * Makefile: remove ugly conditions in find commands * cleanup _MSC_VER usage * fix Windows build * cleanup extraction scripts * fix Windows build * Fix Windows path separator issue * fix rumble support for linux * use glew-cmake in dockerfile * add pulseaudio backend * fix ZAPDTR linkage * Check for "soh.elf" in directory (#6) hide second button if `soh.exe` or `soh.elf` is present * Fix hardcoded segment addresses (#5) * fix condition * hack lus -> soh dep for ZAPDTR Co-authored-by: sholdee <102821812+sholdee@users.noreply.github.com> Co-authored-by: qurious-pixel <62252937+qurious-pixel@users.noreply.github.com> Co-authored-by: GaryOderNichts <12049776+GaryOderNichts@users.noreply.github.com>
54 lines
1.3 KiB
Python
54 lines
1.3 KiB
Python
#!/usr/bin/python3
|
|
|
|
import os
|
|
import sys
|
|
import struct
|
|
from multiprocessing import Pool, cpu_count
|
|
from rom_info import Z64Rom
|
|
import rom_chooser
|
|
|
|
|
|
rom = None
|
|
|
|
def initialize_worker(input_rom):
|
|
global rom
|
|
rom = input_rom
|
|
|
|
def ExtractFunc(i):
|
|
|
|
dma_file = rom.getDmaEntryByIndex(i)
|
|
dma_data = rom.readDmaEntry(dma_file)
|
|
|
|
filename = '../soh/baserom/' + rom.version.file_table[i]
|
|
print('extracting ' + filename + " (0x%08X, 0x%08X)" % (dma_file.virtStart, dma_file.virtEnd))
|
|
|
|
try:
|
|
with open(filename, 'wb') as f:
|
|
f.write(dma_data)
|
|
except IOError:
|
|
print('failed to write file ' + filename)
|
|
|
|
# TODO: handle this better
|
|
if dma_file.compressed:
|
|
os.system('tools/yaz0 -d ' + filename + ' ' + filename)
|
|
|
|
#####################################################################
|
|
|
|
def main():
|
|
try:
|
|
os.mkdir('../soh/baserom')
|
|
except:
|
|
pass
|
|
|
|
rom_path = rom_chooser.chooseROM()
|
|
input_rom = Z64Rom(rom_path)
|
|
|
|
# extract files
|
|
num_cores = cpu_count()
|
|
print("Extracting baserom with " + str(num_cores) + " CPU cores.")
|
|
with Pool(num_cores, initialize_worker, (input_rom,)) as p:
|
|
p.map(ExtractFunc, range(len(input_rom.version.file_table)))
|
|
|
|
if __name__ == "__main__":
|
|
main()
|