mirror of
https://github.com/stenzek/duckstation.git
synced 2024-11-26 23:50:31 +00:00
Add script to pad a BIOS image
Mainly useful for openbios.
This commit is contained in:
parent
419726f4cc
commit
4cc2883224
28
scripts/pad-bios.py
Normal file
28
scripts/pad-bios.py
Normal file
@ -0,0 +1,28 @@
|
||||
import sys
|
||||
import os
|
||||
|
||||
def pad_bios(in_name, out_name):
|
||||
print("Reading %s..." % in_name)
|
||||
with open(in_name, "rb") as f:
|
||||
indata = f.read()
|
||||
if len(indata) > (512 * 1024):
|
||||
print("Input file %s is too large (%u bytes)", in_name, len(indata))
|
||||
sys.exit(1)
|
||||
|
||||
padding_size = (512 * 1024) - len(indata)
|
||||
padding = b'\0' * padding_size
|
||||
print("Padding with %u bytes" % padding_size)
|
||||
|
||||
print("Writing %s..." % out_name)
|
||||
with open(out_name, "wb") as f:
|
||||
f.write(indata)
|
||||
f.write(padding)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 3:
|
||||
print("Usage: %s <input filename> <output filename>" % sys.argv[0])
|
||||
sys.exit(1)
|
||||
|
||||
pad_bios(sys.argv[1], sys.argv[2])
|
||||
sys.exit(0)
|
Loading…
Reference in New Issue
Block a user