Remove uses of MATCHING environment variable and make patchpiracysums offer advice when it fails

This commit is contained in:
Ryan Dwyer 2020-11-01 09:16:35 +10:00
parent 810f86cc19
commit 2de0ef3028
3 changed files with 12 additions and 11 deletions

View File

@ -1,7 +1,6 @@
# User configurable
ROMID ?= ntsc-final
MATCHING ?= 1
PIRACYCHECKS ?= 1
QEMU_IRIX ?= tools/irix/qemu-irix
@ -152,7 +151,7 @@ $(B_DIR)/pd.z64: $(B_DIR)/stage3.bin $(ASSET_FILES)
# the ROM to 32MB.
$(B_DIR)/stage3.bin: $(B_DIR)/stage2.bin $(B_DIR)/segments/gamezips.bin
@cp $< $@.tmp
MATCHING=$(MATCHING) tools/packrom $@.tmp && mv $@.tmp $@
tools/packrom $@.tmp && mv $@.tmp $@
# Stage2 takes stage1 and calculates the piracy checksums.
$(B_DIR)/stage2.bin: $(B_DIR)/stage1.bin

View File

@ -132,15 +132,13 @@ def main():
fd = open(sys.argv[1], 'rb+')
if os.environ['MATCHING'] == '1':
write_garbage(fd, locations)
write_garbage(fd, locations)
pack_lib(fd, locations)
pack_data(fd, locations)
pack_game(fd, locations)
if os.environ['MATCHING'] == '1':
fill_tail(fd)
fill_tail(fd)
# Truncate to 32MB
fd.seek(0)

View File

@ -165,10 +165,14 @@ class Tool:
pos += 4
if upperpos is None or lowerpos is None:
print('0x%08x' % checksum)
raise ValueError('Unable to find checksum location in %s (upperpos=%s, lowerpos=%s)' % (
patchfunc, upperpos, lowerpos
))
print('Unable to find placeholder checksum in %s.' % patchfunc)
print('This can happen if you\'ve turned PIRACYCHECKS off, built the files, then turned it on without rebuilding.')
print('To fix, try running the following:')
print('')
print(' touch $(grep -lr PIRACYCHECKS src)')
print(' make')
print('')
exit(1)
self.fd.seek(upperpos)
self.fd.write((0x3c010000 | (checksum >> 16)).to_bytes(4, 'big'))
@ -200,7 +204,7 @@ class Tool:
self.fd.close()
if os.environ['PIRACYCHECKS']:
if os.environ['PIRACYCHECKS'] == '1':
tool = Tool()
tool.run()