Introduce multi-version support
This commit is contained in:
parent
230473348b
commit
9f17b12316
90
Makefile
90
Makefile
|
@ -1,18 +1,47 @@
|
|||
# User configurable
|
||||
|
||||
REGION=ntsc
|
||||
RELEASE=final
|
||||
ROMID ?= ntsc-final
|
||||
PIRACYCHECKS ?= 1
|
||||
|
||||
QEMU_IRIX ?= tools/irix/qemu-irix
|
||||
IRIX_ROOT ?= tools/irix/root
|
||||
|
||||
################################################################################
|
||||
# Not user configurable
|
||||
|
||||
ROMID := $(REGION)-$(RELEASE)
|
||||
export ROMID
|
||||
|
||||
NTSC=0
|
||||
PAL=0
|
||||
JAP=0
|
||||
|
||||
ifeq ($(ROMID),ntsc-beta)
|
||||
NTSC=1
|
||||
VERSION=0
|
||||
endif
|
||||
ifeq ($(ROMID),ntsc-1.0)
|
||||
NTSC=1
|
||||
VERSION=1
|
||||
endif
|
||||
ifeq ($(ROMID),ntsc-final)
|
||||
NTSC=1
|
||||
VERSION=2
|
||||
endif
|
||||
ifeq ($(ROMID),pal-beta)
|
||||
PAL=1
|
||||
VERSION=3
|
||||
endif
|
||||
ifeq ($(ROMID),pal-final)
|
||||
PAL=1
|
||||
VERSION=4
|
||||
endif
|
||||
ifeq ($(ROMID),jap-final)
|
||||
JAP=1
|
||||
VERSION=5
|
||||
endif
|
||||
|
||||
E_DIR := extracted/$(ROMID)
|
||||
B_DIR := build/$(ROMID)
|
||||
|
||||
QEMU_IRIX := tools/irix/qemu-irix
|
||||
IRIX_ROOT := tools/irix/root
|
||||
|
||||
ifeq ($(shell type mips64-elf-ld >/dev/null 2>/dev/null; echo $$?), 0)
|
||||
TOOLCHAIN := mips64-elf
|
||||
else ifeq ($(shell type mips-linux-gnu-ld >/dev/null 2>/dev/null; echo $$?), 0)
|
||||
|
@ -23,27 +52,20 @@ else
|
|||
TOOLCHAIN := mips-elf
|
||||
endif
|
||||
|
||||
ifeq ($(REGION),ntsc)
|
||||
VERSION_CFLAGS := -DNTSC=1 -DPAL=0 -DJAP=0
|
||||
endif
|
||||
ifeq ($(REGION),pal)
|
||||
VERSION_CFLAGS := -DNTSC=0 -DPAL=1 -DJAP=0
|
||||
endif
|
||||
ifeq ($(REGION),jap)
|
||||
VERSION_CFLAGS := -DNTSC=0 -DPAL=0 -DJAP=1
|
||||
endif
|
||||
|
||||
ifeq ($(RELEASE),beta)
|
||||
RELEASE_CFLAGS := -DBETA=1 -DREL1=0 -DFINAL=0
|
||||
endif
|
||||
ifeq ($(RELEASE),1.0)
|
||||
RELEASE_CFLAGS := -DBETA=0 -DREL1=1 -DFINAL=0
|
||||
endif
|
||||
ifeq ($(RELEASE),final)
|
||||
RELEASE_CFLAGS := -DBETA=0 -DREL1=0 -DFINAL=1
|
||||
endif
|
||||
|
||||
CFLAGS := $(VERSION_CFLAGS) $(RELEASE_CFLAGS) -DPIRACYCHECKS=1 -Wo,-loopunroll,0 -Wab,-r4300_mul -non_shared -G 0 -Xcpluscomm -woff 649,819,820,821,838,852 -w2 -I src/include -mips2
|
||||
CFLAGS := -DVERSION=$(VERSION) \
|
||||
-DNTSC=$(NTSC) \
|
||||
-DPAL=$(PAL) \
|
||||
-DJAP=$(JAP) \
|
||||
-DPIRACYCHECKS=$(PIRACYCHECKS) \
|
||||
-Wo,-loopunroll,0 \
|
||||
-Wab,-r4300_mul \
|
||||
-non_shared \
|
||||
-G 0 \
|
||||
-Xcpluscomm \
|
||||
-woff 649,819,820,821,838,852 \
|
||||
-w2 \
|
||||
-I src/include \
|
||||
-mips2
|
||||
|
||||
C_FILES := $(shell find src -name '*.c')
|
||||
O_FILES := $(patsubst %.c, %.o, $(C_FILES))
|
||||
|
@ -133,7 +155,7 @@ pads: $(ASSET_BG_PADS_FILES)
|
|||
# BG tile files
|
||||
|
||||
src/files/bgdata/bg_%_tiles.o: src/files/bgdata/bg_%_tiles.s
|
||||
$(TOOLCHAIN)-as -march=vr4300 -mabi=32 -I src/include -EB -o $@ $<
|
||||
$(TOOLCHAIN)-as --defsym VERSION=$(VERSION) -march=vr4300 -mabi=32 -I src/include -EB -o $@ $<
|
||||
|
||||
$(B_DIR)/files/bgdata/bg_%_tiles.elf: src/files/bgdata/bg_%_tiles.o
|
||||
@mkdir -p $(B_DIR)/files/bgdata
|
||||
|
@ -268,13 +290,13 @@ gvars: $(B_DIR)/ucode/gvars.bin
|
|||
# Miscellaneous
|
||||
|
||||
extract:
|
||||
tools/extract $(ROMID)
|
||||
tools/extract
|
||||
|
||||
$(B_DIR)/ucode/gamezips.bin: $(B_DIR)/ucode/game.bin
|
||||
tools/mkgamezips
|
||||
|
||||
test: all
|
||||
@md5sum --quiet -c checksums.md5
|
||||
@md5sum --quiet -c checksums.$(ROMID).md5
|
||||
|
||||
$(B_DIR)/files/%.o: $(B_DIR)/files/%
|
||||
/bin/echo -e ".data\n.incbin \"$<\"" > $(B_DIR)/file.s
|
||||
|
@ -301,7 +323,7 @@ $(B_DIR)/ucode/filenames.bin: $(B_DIR)/ucode/filenames.elf
|
|||
$(TOOLCHAIN)-objcopy $< $@ -O binary
|
||||
|
||||
$(B_DIR)/pd.elf: $(O_FILES) $(ASSET_O_FILES) ld/pd.ld
|
||||
cpp -P ld/pd.ld -o $(B_DIR)/pd.ld
|
||||
cpp -DROMID=$(ROMID) -DVERSION=$(VERSION) -P ld/pd.ld -o $(B_DIR)/pd.ld
|
||||
$(TOOLCHAIN)-ld --no-check-sections -T $(B_DIR)/pd.ld --print-map -o $@ > $(B_DIR)/pd.map
|
||||
|
||||
$(B_DIR)/pd.bin: $(B_DIR)/pd.elf
|
||||
|
@ -312,12 +334,12 @@ all: $(UCODE_BIN_FILES) $(ASSET_O_FILES)
|
|||
|
||||
rom: $(UCODE_BIN_FILES) $(B_DIR)/ucode/gamezips.bin $(ASSET_O_FILES)
|
||||
TOOLCHAIN=$(TOOLCHAIN) tools/buildrom
|
||||
tools/checksum build/ntsc-final/pd.z64 --write
|
||||
tools/checksum $(B_DIR)/pd.z64 --write
|
||||
|
||||
clean:
|
||||
rm -rf build/*
|
||||
find src -name '*.o' -delete
|
||||
|
||||
binclean:
|
||||
rm -f build/ntsc-final/ucode/*.bin
|
||||
rm -f $(B_DIR)/ucode/*.bin
|
||||
find src/{boot,game,gvars,lib,inflate} -name '*.o' -delete
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -3,7 +3,7 @@
|
|||
varname = _filesSegmentRomStart + . - _filesSegmentRamStart; \
|
||||
__rompos = varname; \
|
||||
.file##id : AT(__rompos) { \
|
||||
build/ntsc-final/files/filename.o (.data); \
|
||||
build/ROMID/files/filename.o (.data); \
|
||||
} \
|
||||
__rompos += SIZEOF(.file##id)
|
||||
|
||||
|
|
|
@ -2020,6 +2020,7 @@
|
|||
#define SAVEFILEFLAG_41 0x41
|
||||
#define SAVEFILEFLAG_42 0x42
|
||||
#define SAVEFILEFLAG_43 0x43
|
||||
#define SAVEFILEFLAG_47 0x47
|
||||
|
||||
#define SCREENRATIO_NORMAL 0
|
||||
#define SCREENRATIO_16_9 1
|
||||
|
@ -2573,3 +2574,10 @@
|
|||
#define BODY_ELVISWAISTCOAT 0x94
|
||||
#define BODY_DARK_LEATHER 0x95
|
||||
#define BODY_DARK_NEGOTIATOR 0x96
|
||||
|
||||
#define VERSION_NTSC_BETA 0
|
||||
#define VERSION_NTSC_1_0 1
|
||||
#define VERSION_NTSC_FINAL 2
|
||||
#define VERSION_PAL_BETA 3
|
||||
#define VERSION_PAL_FINAL 4
|
||||
#define VERSION_JAP_FINAL 5
|
||||
|
|
|
@ -4,6 +4,13 @@
|
|||
|
||||
.data
|
||||
|
||||
.set VERSION_NTSC_BETA, 0
|
||||
.set VERSION_NTSC_1_0, 1
|
||||
.set VERSION_NTSC_FINAL, 2
|
||||
.set VERSION_PAL_BETA, 3
|
||||
.set VERSION_PAL_FINAL, 4
|
||||
.set VERSION_JAP_FINAL, 5
|
||||
|
||||
.macro tileabstract numverts, ai, flags, u4, u6, u8, ua, uc
|
||||
.short \numverts
|
||||
.byte \ai
|
||||
|
|
|
@ -5,7 +5,7 @@ import re
|
|||
import subprocess
|
||||
|
||||
def main():
|
||||
fd = open('build/ntsc-final/pd.z64', 'wb+')
|
||||
fd = open(bdir() + '/pd.z64', 'wb+')
|
||||
|
||||
# The retail ROM contains truncated duplicates of some segments.
|
||||
# For example, the real boot segment is at 0x1000 - 0x3050, but the tail end
|
||||
|
@ -56,22 +56,22 @@ def get_header():
|
|||
return binary
|
||||
|
||||
def get_rspboot():
|
||||
return getfilecontents('extracted/ntsc-final/ucode/rspboot.bin')
|
||||
return getfilecontents(edir() + '/ucode/rspboot.bin')
|
||||
|
||||
def get_boot():
|
||||
return getfilecontents('build/ntsc-final/ucode/boot.bin')
|
||||
return getfilecontents(bdir() + '/ucode/boot.bin')
|
||||
|
||||
def get_lib():
|
||||
return zip('build/ntsc-final/ucode/lib.bin')
|
||||
return zip(bdir() + '/ucode/lib.bin')
|
||||
|
||||
def get_gamedata():
|
||||
return zip('build/ntsc-final/ucode/gamedata.bin')
|
||||
return zip(bdir() + '/ucode/gamedata.bin')
|
||||
|
||||
def get_inflate():
|
||||
return getfilecontents('build/ntsc-final/ucode/inflate.bin')
|
||||
return getfilecontents(bdir() + '/ucode/inflate.bin')
|
||||
|
||||
def get_gamezips():
|
||||
return getfilecontents('build/ntsc-final/ucode/gamezips.bin')
|
||||
return getfilecontents(bdir() + '/ucode/gamezips.bin')
|
||||
|
||||
def get_unknown():
|
||||
return getfrombaserom(0x157120, 0x69b268)
|
||||
|
@ -80,19 +80,19 @@ def get_fonts():
|
|||
return getfrombaserom(0x7f2388, 0x17ec8)
|
||||
|
||||
def get_sfxctl():
|
||||
return getfilecontents('extracted/ntsc-final/audio/sfx.ctl')
|
||||
return getfilecontents(edir() + '/audio/sfx.ctl')
|
||||
|
||||
def get_sfxtbl():
|
||||
return getfilecontents('extracted/ntsc-final/audio/sfx.tbl')
|
||||
return getfilecontents(edir() + '/audio/sfx.tbl')
|
||||
|
||||
def get_seqctl():
|
||||
return getfilecontents('extracted/ntsc-final/audio/music.ctl')
|
||||
return getfilecontents(edir() + '/audio/music.ctl')
|
||||
|
||||
def get_seqtbl():
|
||||
return getfilecontents('extracted/ntsc-final/audio/music.tbl')
|
||||
return getfilecontents(edir() + '/audio/music.tbl')
|
||||
|
||||
def get_midi():
|
||||
return getfilecontents('extracted/ntsc-final/audio/sequences.bin')
|
||||
return getfilecontents(edir() + '/audio/sequences.bin')
|
||||
|
||||
def write_files(fd):
|
||||
start = getlinkervariable('_filesSegmentRomStart')
|
||||
|
@ -101,7 +101,7 @@ def write_files(fd):
|
|||
write_binary(fd, 0xed83a0, getfromldbin(start, end - start))
|
||||
|
||||
def get_filenames():
|
||||
return getfilecontents('build/ntsc-final/ucode/filenames.bin')
|
||||
return getfilecontents(bdir() + '/ucode/filenames.bin')
|
||||
|
||||
def get_textures():
|
||||
return getfrombaserom(0x01d65f40, 0x29a0c0)
|
||||
|
@ -113,14 +113,14 @@ def getfilecontents(filename):
|
|||
return binary
|
||||
|
||||
def getfrombaserom(offset, len):
|
||||
fd = open('pd.ntsc-final.z64', 'rb')
|
||||
fd = open('pd.%s.z64' % os.environ['ROMID'], 'rb')
|
||||
fd.seek(offset)
|
||||
binary = fd.read(len)
|
||||
fd.close()
|
||||
return binary
|
||||
|
||||
def getfromldbin(offset, len):
|
||||
fd = open('build/ntsc-final/pd.bin', 'rb')
|
||||
fd = open(bdir() + '/pd.bin', 'rb')
|
||||
fd.seek(offset)
|
||||
binary = fd.read(len)
|
||||
fd.close()
|
||||
|
@ -129,13 +129,19 @@ def getfromldbin(offset, len):
|
|||
def zip(filename):
|
||||
return subprocess.check_output(['tools/rarezip', filename])
|
||||
|
||||
def bdir():
|
||||
return 'build/%s' % os.environ['ROMID']
|
||||
|
||||
def edir():
|
||||
return 'extracted/%s' % os.environ['ROMID']
|
||||
|
||||
def getlinkervariable(varname):
|
||||
if 'TOOLCHAIN' in os.environ:
|
||||
cmd = '%s-objdump' % os.environ['TOOLCHAIN']
|
||||
else:
|
||||
cmd = 'mips64-elf-objdump'
|
||||
|
||||
objdump = subprocess.check_output([cmd, 'build/ntsc-final/pd.elf', '-t']).decode('utf-8')
|
||||
objdump = subprocess.check_output([cmd, bdir() + '/pd.elf', '-t']).decode('utf-8')
|
||||
|
||||
matches = re.findall(r'^([0-9a-f]+) .*? %s$' % varname, objdump, re.MULTILINE)
|
||||
return int(matches[0], 16)
|
||||
|
|
|
@ -1,20 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# Extract assets from a Perfect Dark ROM.
|
||||
#
|
||||
# Place ROM in the main project directory, named pd.<romid>.z64, then run this
|
||||
# with tools/extract <romid>. The directory extracted/<romid>/ will be created
|
||||
# and populated.
|
||||
#
|
||||
# Supported ROM IDs are:
|
||||
# ntsc-beta
|
||||
# ntsc-1.0
|
||||
# ntsc-final
|
||||
# pal-beta
|
||||
# pal-final
|
||||
# jap-final
|
||||
|
||||
import os, sys, zlib
|
||||
import os, zlib
|
||||
|
||||
class Extractor:
|
||||
def extract(self, romid):
|
||||
|
@ -280,5 +266,5 @@ class Extractor:
|
|||
}
|
||||
|
||||
extractor = Extractor()
|
||||
extractor.extract(sys.argv[1])
|
||||
extractor.extract(os.environ['ROMID'])
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ The format of the gamezips binary is:
|
|||
def main():
|
||||
zips = get_zips()
|
||||
|
||||
fd = open('build/ntsc-final/ucode/gamezips.bin', 'wb')
|
||||
fd = open('build/%s/ucode/gamezips.bin' % os.environ['ROMID'], 'wb')
|
||||
pos = len(zips) * 4 + 4
|
||||
|
||||
# Write pointer array
|
||||
|
@ -65,7 +65,7 @@ def get_filecontents(filename):
|
|||
return binary
|
||||
|
||||
def get_zips():
|
||||
binary = get_filecontents('build/ntsc-final/ucode/game.bin')
|
||||
binary = get_filecontents('build/%s/ucode/game.bin' % os.environ['ROMID'])
|
||||
parts = [binary[i:i+0x1000] for i in range(0, len(binary), 0x1000)]
|
||||
return [zip(part) for part in parts]
|
||||
|
||||
|
|
Loading…
Reference in New Issue