Skip to content

Commit 9101ad4

Browse files
committed
Initial commit
0 parents  commit 9101ad4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+15859
-0
lines changed

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# directories
2+
3+
__pycache__/
4+
asm/
5+
bin/
6+
build/
7+
ido/ido5.3_compiler
8+
ido/ido7.1_compiler
9+
10+
# files
11+
12+
*.z64
13+
conker.ld
14+
undefined_funcs.txt

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "tools/n64splat"]
2+
path = tools/n64splat
3+
url = https://github.com/ethteck/n64splat.git
4+
[submodule "tools/asm-differ"]
5+
path = tools/asm-differ
6+
url = https://github.com/simonlindholm/asm-differ

Dockerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
FROM ubuntu:20.04 as build
2+
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
5+
RUN apt-get update && \
6+
apt-get install -y \
7+
binutils-mips-linux-gnu \
8+
build-essential \
9+
less \
10+
libglib2.0 \
11+
python3 \
12+
python3-pip \
13+
unzip \
14+
wget
15+
16+
RUN python3 -m pip install \
17+
capstone pyyaml pycparser \
18+
colorama ansiwrap watchdog python-Levenshtein cxxfilt
19+
20+
RUN wget \
21+
https://github.com/n64decomp/qemu-irix/releases/download/v2.11-deb/qemu-irix-2.11.0-2169-g32ab296eef_amd64.deb \
22+
-O qemu.deb && \
23+
echo "8170f37cf03a08cc2d7c1c58f10d650ea0d158f711f6916da9364f6d8c85f741 qemu.deb" | sha256sum --check && \
24+
dpkg -i qemu.deb && \
25+
rm qemu.deb
26+
27+
RUN mkdir /conker
28+
WORKDIR /conker

Makefile

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
2+
VERSION := us
3+
4+
BUILD_DIR = build
5+
ASM_DIRS := asm
6+
DATA_DIRS := bin
7+
SRC_DIRS := src
8+
9+
# IRIX_ROOT := ido/ido5.3_compiler
10+
IRIX_ROOT := ido/ido7.1_compiler
11+
QEMU_IRIX := $(shell which qemu-irix 2>/dev/null)
12+
13+
ifeq ($(QEMU_IRIX),)
14+
$(error ERROR: qemu-irix not found. Get it from https://github.com/n64decomp/sm64/releases.)
15+
endif
16+
17+
S_FILES := $(foreach dir,$(ASM_DIRS),$(wildcard $(dir)/*.s))
18+
C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c))
19+
BIN_FILES := $(foreach dir,$(DATA_DIRS),$(wildcard $(dir)/*.bin))
20+
21+
# Object files
22+
O_FILES := $(foreach file,$(S_FILES),$(BUILD_DIR)/$(file:.s=.o)) \
23+
$(foreach file,$(C_FILES),$(BUILD_DIR)/$(file:.c=.o)) \
24+
$(foreach file,$(BIN_FILES),$(BUILD_DIR)/$(file:.bin=.o))
25+
26+
TARGET = $(BUILD_DIR)/conker.$(VERSION)
27+
LD_SCRIPT = conker.ld
28+
29+
##################### Compiler Options #######################
30+
CROSS = mips-linux-gnu-
31+
AS = $(CROSS)as
32+
# CC = $(CROSS)gcc
33+
# CC = tools/ido_recomp/linux/7.1/cc
34+
# CC = tools/ido5.3_cc/usr/bin/cc
35+
CC := $(QEMU_IRIX) -L $(IRIX_ROOT) $(IRIX_ROOT)/usr/bin/cc
36+
37+
LD = $(CROSS)ld
38+
OBJDUMP = $(CROSS)objdump
39+
OBJCOPY = $(CROSS)objcopy
40+
PYTHON = python3
41+
42+
OPT_FLAGS :=
43+
44+
INCLUDE_CFLAGS := -I include -I include/2.0L -I include/2.0L/PR
45+
46+
ASFLAGS = -EB -mtune=vr4300 -march=vr4300 -mabi=32 -I include
47+
48+
CFLAGS := -G 0 -Xfullwarn -Xcpluscomm -signed -g -nostdinc -non_shared -Wab,-r4300_mul
49+
CFLAGS += -D_LANGUAGE_C
50+
CFLAGS += $(INCLUDE_CFLAGS)
51+
52+
LDFLAGS = -T undefined_funcs.txt -T $(LD_SCRIPT) -T undefined_syms.txt -Map $(TARGET).map --no-check-sections
53+
######################## Targets #############################
54+
55+
$(foreach dir,$(SRC_DIRS) $(ASM_DIRS) $(DATA_DIRS) $(COMPRESSED_DIRS) $(MAP_DIRS) $(BGM_DIRS),$(shell mkdir -p build/$(dir)))
56+
57+
default: all
58+
59+
all: check $(BUILD_DIR) $(TARGET).z64 verify
60+
61+
check:
62+
@echo "$$(cat conker.$(VERSION).sha1) baserom.$(VERSION).z64" | sha1sum --check
63+
64+
clean:
65+
rm -rf asm
66+
rm -rf bin
67+
rm -rf build
68+
69+
extract:
70+
$(PYTHON) tools/n64splat/split.py baserom.$(VERSION).z64 conker.$(VERSION).yaml .
71+
72+
$(BUILD_DIR):
73+
mkdir $(BUILD_DIR)
74+
75+
$(TARGET).elf: $(O_FILES) $(LD_SCRIPT)
76+
@$(LD) $(LDFLAGS) -o $@ $(O_FILES)
77+
78+
$(BUILD_DIR)/src/code_3920.o: OPT_FLAGS := -O2 -g3
79+
$(BUILD_DIR)/src/code_39B0.o: OPT_FLAGS := -O2 -g3
80+
$(BUILD_DIR)/src/code_23DA0.o: OPT_FLAGS := -O2 -g3
81+
$(BUILD_DIR)/src/code_1E480.o: OPT_FLAGS := -O2 -g3
82+
83+
$(BUILD_DIR)/%.o: %.c
84+
$(CC) -c $(CFLAGS) $(OPT_FLAGS) -o $@ $<
85+
86+
$(BUILD_DIR)/%.o: %.s
87+
$(AS) $(ASFLAGS) -o $@ $<
88+
89+
$(BUILD_DIR)/%.o: %.bin
90+
$(LD) -r -b binary -o $@ $<
91+
92+
$(TARGET).bin: $(TARGET).elf
93+
$(OBJCOPY) $< $@ -O binary
94+
95+
$(TARGET).z64: $(TARGET).bin
96+
@cp $< $@
97+
98+
verify: $(TARGET).z64
99+
@echo "$$(cat conker.$(VERSION).sha1) $(TARGET).z64" | sha1sum --check
100+
101+
.PHONY: all clean default

README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Conkers Bad Fur Day Decompilation
2+
3+
A WIP decompilation of Conker's Bad Fur Day.
4+
5+
Note: To use this repository, you must already have a copy of the game.
6+
7+
# Building
8+
9+
Place the US Conker's Bad Fur Day ROM in the root of this repository, name it `baserom.us.z64`.
10+
11+
## Preamble
12+
13+
The assumption is that you will be using [Docker](https://www.docker.com/products/docker-desktop) for the building process.
14+
If this is not the case, check the `Dockerfile` for the expected prerequisites.
15+
16+
## Install prerequisites
17+
18+
```sh
19+
# decomp uses ido 7.1
20+
wget https://github.com/n64decomp/oot/releases/download/0.1/ido7.1_compiler.zip
21+
unzip -d ido ido7.1_compiler.zip
22+
```
23+
24+
## Build Docker image
25+
26+
```sh
27+
docker build . -t conker
28+
```
29+
30+
## Apply patches
31+
32+
```sh
33+
# adjust cpp_args as headers are in include/2.0L
34+
patch -p1 -i patches/n64splat.patch
35+
```
36+
37+
## Sanity check ROM checksum
38+
39+
```sh
40+
docker run --rm -v $(pwd):/conker conker make check
41+
```
42+
43+
## Extract assets from ROM
44+
45+
```sh
46+
docker run --rm -v $(pwd):/conker conker make extract
47+
```
48+
49+
## Compile
50+
51+
```sh
52+
docker run --rm -v $(pwd):/conker conker make
53+
```
54+
55+
# Contributing
56+
57+
TBD.
58+
59+
# Tools
60+
61+
This repo makes use of the following tools:
62+
63+
- [asm-differ](https://github.com/simonlindholm/asm-differ)
64+
- [n64splat](https://github.com/ethteck/n64splat)

conker.eu.sha1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ee7bc6656fd1e1d9ffb3d19add759f28b88df710

conker.us.sha1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4cbadd3c4e0729dec46af64ad018050eada4f47a

conker.us.yaml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: "Conker Bfd (North America)"
2+
basename: "conker"
3+
options:
4+
- "find-file-boundaries"
5+
6+
segments:
7+
- name: header
8+
type: header
9+
start: 0x00000000
10+
- name: boot
11+
type: bin
12+
start: 0x00000040
13+
- name: code
14+
type: code
15+
start: 0x00001000
16+
vram: 0x80001000
17+
files:
18+
- [0x1000, "asm"]
19+
- [0x1050, "asm"]
20+
- [0x2DB0, "asm"] #[0x2DB0, "c", "code_2DB0"]
21+
- [0x2E50, "asm"]
22+
- [0x3220, "asm"]
23+
- [0x38C0, "asm"]
24+
- [0x3920, "asm"]
25+
- [0x39B0, "c", "code_39B0"]
26+
- [0x39C0, "asm"]
27+
- [0x3BD0, "asm"]
28+
- [0x4470, "asm"]
29+
- [0x49E0, "asm"]
30+
- [0x50A0, "asm"]
31+
- [0x5570, "asm"]
32+
- [0x57E0, "asm"]
33+
- [0x5AB0, "asm"]
34+
- [0x8120, "asm"]
35+
- [0x8180, "asm"]
36+
- [0x8F90, "asm"]
37+
- [0xA420, "asm"]
38+
- [0xEB00, "asm"]
39+
- [0x11FA0, "asm"]
40+
- [0x12820, "asm"]
41+
- [0x128D0, "asm"]
42+
- [0x13320, "asm"]
43+
- [0x15550, "asm"]
44+
- [0x17870, "asm"]
45+
- [0x17AA0, "c", "code_17AA0"]
46+
- [0x17AF0, "asm"]
47+
- [0x17DF0, "asm"]
48+
- [0x17EC0, "asm"]
49+
- [0x17F10, "asm"]
50+
- [0x18C60, "c", "code_18C60"]
51+
- [0x18CB0, "asm"]
52+
- [0x18DA0, "asm"]
53+
- [0x18E60, "asm"]
54+
- [0x19AB0, "asm"]
55+
- [0x19B50, "asm"]
56+
- [0x1AAE0, "asm"]
57+
- [0x1C060, "asm"]
58+
- [0x1C690, "asm"]
59+
- [0x1C9E0, "asm"]
60+
- [0x1D900, "asm"]
61+
- [0x1DBA0, "asm"]
62+
- [0x1E170, "asm"]
63+
- [0x1E2A0, "asm"]
64+
- [0x1E480, "c", "code_1E480"]
65+
- [0x1E4A0, "asm"]
66+
- [0x1E530, "asm"]
67+
- [0x20000, "asm"]
68+
- [0x210C0, "asm"]
69+
- [0x214F0, "asm"]
70+
- [0x22040, "asm"]
71+
- [0x22460, "asm"]
72+
- [0x226F0, "asm"]
73+
- [0x22790, "asm"]
74+
- [0x22A50, "asm"]
75+
- [0x22D10, "asm"]
76+
- [0x22DC0, "asm"]
77+
- [0x22E00, "asm"]
78+
- [0x22F60, "asm"]
79+
- [0x230F0, "asm"]
80+
- [0x23390, "asm"]
81+
- [0x23440, "asm"]
82+
- [0x23580, "asm"]
83+
- [0x23830, "asm"]
84+
- [0x23850, "asm"]
85+
- [0x23DA0, "asm"]
86+
- [0x23DF0, "asm"]
87+
- [0x23E80, "asm"]
88+
- [0x24400, "asm"]
89+
- [0x24780, "asm"]
90+
- [0x24830, "asm"]
91+
- [0x24B20, "asm"]
92+
- [0x24E20, "asm"]
93+
- [0x24F10, "asm"]
94+
- [0x24F40, "asm"]
95+
- [0x24FD0, "asm"]
96+
- [0x25870, "asm"]
97+
- [0x25C20, "asm"]
98+
- [0x25FD0, "asm"]
99+
- [0x26250, "asm"]
100+
- [0x26310, "asm"]
101+
- [0x263D0, "asm"]
102+
- [0x26540, "asm"]
103+
- [0x267A0, "asm"]
104+
- [0x26800, "asm"]
105+
- [0x273D0, "asm"]
106+
- [0x27490, "asm"]
107+
- [0x274A0, "asm"]
108+
- [0x27620, "asm"]
109+
- [0x28670, "asm"]
110+
- [0x290D0, "bin"]
111+
- start: 0x4000000 #0x4000000 # not actually the end

diff_settings.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env python3
2+
3+
def apply(config, args):
4+
config['baseimg'] = 'baserom.us.z64'
5+
config['myimg'] = 'build/conker.us.z64'
6+
config['mapfile'] = 'build/conker.us.map'
7+
config['source_directories'] = ['.']

ido/readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extract ido_compiler7.1 here

0 commit comments

Comments
 (0)