Skip to content

Commit

Permalink
New workflow complete. Support mips64-ultra-elf toolchain.
Browse files Browse the repository at this point in the history
  • Loading branch information
joeydumont committed Jul 10, 2019
1 parent b55bf44 commit c98e22a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 22 deletions.
30 changes: 16 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@

# Binaries
ARMIPS := armips
CROSS ?= mips64-
TOOLS_PREFIX ?= /opt/n64/bin/
CC := $(CROSS)gcc
CXX := $(CROSS)g++
LD := $(CROSS)g++
OBJCOPY := $(CROSS)objcopy
NM := $(CROSS)nm
CROSS ?= mips64
TOOLS_PREFIX ?= /usr/bin/
CC := $(CROSS)-gcc
CXX := $(CROSS)-g++
LD := $(CROSS)-g++
OBJCOPY := $(CROSS)-objcopy
NM := $(CROSS)-nm
PYTHON := python3
PARSEHOOKS := python/ParseHooks.py
GENERATEHOOKS := python/GenerateHooks.py
GRC := AS=$(CROSS)as $(TOOLS_PREFIX)grc
GRC := AS=$(CROSS)-as $(TOOLS_PREFIX)grc
N64CHECKSUM := n64cksum
XDELTA := xdelta3

# Compiler/linker flags (verify that -mabi=32 is necessary).
N64_SYSROOT ?= /opt/n64/mips64/n64-sysroot/usr/
# Compiler/linker flags.
N64_SYSROOT ?= /usr/$(CROSS)/n64-sysroot/usr/
CFLAGS = -std=gnu11 -Wall -O1 -mtune=vr4300 -march=vr4300 -mabi=32 \
-mno-check-zero-division -mdivide-breaks \
$(GBI_VERSION) \
$(GBI_VERSION) \
-DZ64_VERSION=Z64_OOT10 \
-DSETTINGS_HEADER=../../../src/settings.h \
-I ${N64_SYSROOT}/include/ \
Expand All @@ -37,6 +37,8 @@ CXXFLAGS = -std=gnu++14 -Wall -O1 -mtune=vr4300 -march=vr4300 -mabi=32\
$(GBI_VERSION)
LDSCRIPT = $(N64_SYSROOT)/lib/gl-n64.ld
LDFLAGS = -T $(LDSCRIPT) -nostartfiles -specs=nosys.specs \
-march=vr4300 -mtune=vr4300 -mabi=32 -mdivide-breaks \
-mno-check-zero-division \
-Wl,--gc-sections \
-Wl,--defsym,start=0x80400000

Expand All @@ -57,8 +59,8 @@ USS64FILES = $(SRCDIR)/uss64_commands.c $(SRCDIR)/uss64.c \
$(SRCDIR)/settings.c $(SRCDIR)/uss64_settings.c \
$(SRCDIR)/uss64_warps.c $(SRCDIR)/uss64_timer.c
STDFILES = $(N64_SYSROOT)/include/grc.c \
$(N64_SYSROOT)/include/vector/vector.c \
$(N64_SYSROOT)/include/startup.c \
$(N64_SYSROOT)/include/vector/vector.c \
$(N64_SYSROOT)/include/startup.c \
$(N64_SYSROOT)/include/list/list.c
STDHEADERS := $(patsubst %.c, %.h, $(STDFILES))
STDHEADERS += $(N64_SYSROOT)/include/n64.h
Expand Down Expand Up @@ -195,7 +197,7 @@ $$(GZ_OBJECTS-$(1)) : GBI_VERSION += -DF3D_BETA
endif

GenerateHooks-$(1) : $$(ELF-$(1)) | $$(DEBUG_SCRIPTS_OUT)/ $$(PATCHDIR)/
$$(PYTHON) $$(GENERATEHOOKS) -vv --elf $$(ELF-$(1)) --version $$(VERSION-$(1)) --mips64-nm $$(CROSS)nm --sm64-hooks sm64_hooks.yml --uss64-hooks uss64_hooks.yml
$$(PYTHON) $$(GENERATEHOOKS) --elf $$(ELF-$(1)) --version $$(VERSION-$(1)) --mips64-nm $$(CROSS)-nm --sm64-hooks sm64_hooks.yml --uss64-hooks uss64_hooks.yml

.ONESHELL:
patch-$(1) : GenerateHooks-$(1)
Expand Down
13 changes: 9 additions & 4 deletions python/GenerateHooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@

# ------------------------------ MAIN FUNCTION ------------------------------ #
# -- Change directory to where the script is located.
callPath =os.getcwd()
callPath = os.getcwd()
os.chdir(sys.path[0])

# ----------------------------- Argument Parsing ---------------------------- #
# -- Parse arguments
parser = argparse.ArgumentParser()
parser.add_argument("--verbose", "-v",
action="count",
help="Increase the verbosity of the script.")
help="Increase the verbosity of the script.",
default=0)
parser.add_argument("--mips64-nm",
type=str,
default="mips64-nm",
Expand All @@ -51,13 +52,17 @@
help="Version of the game to hook into.")
args = parser.parse_args()

# -- Cleanup arguments
args.sm64_hooks = os.path.join(callPath, args.sm64_hooks)
args.uss64_hooks = os.path.join(callPath, args.uss64_hooks)
args.elf = os.path.join(callPath, args.elf)
if (args.verbose == 1):
print(args.version)

# ---------------------------- Parse Hooks Files ---------------------------- #

hooksParser = HooksParser.HooksParser(os.path.join(callPath,args.sm64_hooks),
os.path.join(callPath,args.uss64_hooks))
hooksParser = HooksParser.HooksParser(args.sm64_hooks,
args.uss64_hooks)

# -- Parse the addresses of the hooks.
uss64_hooks = hooksParser.getUSS64Hooks()
Expand Down
4 changes: 2 additions & 2 deletions python/HooksParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ def __init__(self, sm64_hooks, uss64_hooks):
uss64_hooks_f = uss64_hooks

with open(sm64_hooks_f, 'r') as sm64_hooks_h:
self.sm64_hooks = yaml.load(sm64_hooks_h.read())
self.sm64_hooks = yaml.load(sm64_hooks_h.read(),Loader=yaml.FullLoader)

with open(uss64_hooks_f, 'r') as uss64_hooks_h:
self.uss64_hooks = yaml.load(uss64_hooks_h.read())
self.uss64_hooks = yaml.load(uss64_hooks_h.read(),Loader=yaml.FullLoader)

# -- Determine the maximum lengths of some sets of strings
# -- in order to be able to pretty print.
Expand Down
5 changes: 3 additions & 2 deletions python/ParseHooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
callPath = os.getcwd()
os.chdir(sys.path[0])

hooksParser = HooksParser.HooksParser(callPath+'sm64_hooks.yml',
callPath+'uss64_hooks.yml')
hooksParser = HooksParser.HooksParser(os.path.join(callPath,'sm64_hooks.yml'),
os.path.join(callPath,'uss64_hooks.yml')
)

sm64_h = hooksParser.generateSM64Header()
sm64_c = hooksParser.generateSM64CFile()
Expand Down

0 comments on commit c98e22a

Please sign in to comment.