This commit is contained in:
unknown
2020-08-29 17:54:55 -04:00
commit c5e2415773
736 changed files with 1014201 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
# Compiler binaries
mwcc_compiler/
# Build artifacts
build/
*.o
*.elf
*.map
*.dol
# Temporary files
*.swp
*.dump
# IDE
.vscode/
# ASM
new.asm
+119
View File
@@ -0,0 +1,119 @@
ifneq ($(findstring MINGW,$(shell uname)),)
WINDOWS := 1
endif
ifneq ($(findstring MSYS,$(shell uname)),)
WINDOWS := 1
endif
#-------------------------------------------------------------------------------
# Files
#-------------------------------------------------------------------------------
TARGET_COL := wii
TARGET := dolzel2
BUILD_DIR := build/$(TARGET)
SRC_DIRS := src
ASM_DIRS := asm
# Inputs
LDSCRIPT := $(BUILD_DIR)/ldscript.lcf
# Outputs
DOL := $(BUILD_DIR)/main.dol
ELF := $(DOL:.dol=.elf)
MAP := $(BUILD_DIR)/dolzel2.map
include obj_files.mk
O_FILES := $(INIT_O_FILES) $(EXTAB_O_FILES) $(EXTABINDEX_O_FILES) $(TEXT_O_FILES) \
$(CTORS_O_FILES) $(DTORS_O_FILES) $(RODATA_O_FILES) $(DATA_O_FILES) \
$(BSS_O_FILES) $(SDATA_O_FILES) $(SBSS_O_FILES) \
$(SDATA2_O_FILES) $(SBSS2_O_FILES)
#-------------------------------------------------------------------------------
# Tools
#-------------------------------------------------------------------------------
MWCC_VERSION := 1.2.5
# Programs
ifeq ($(WINDOWS),1)
WINE :=
else
WINE := wine
endif
AS := $(DEVKITPPC)/bin/powerpc-eabi-as
OBJCOPY := $(DEVKITPPC)/bin/powerpc-eabi-objcopy
CPP := cpp -P
CC := $(WINE) tools/mwcc_compiler/$(MWCC_VERSION)/mwcceppc.exe
LD := $(WINE) tools/mwcc_compiler/$(MWCC_VERSION)/mwldeppc.exe
ELF2DOL := tools/elf2dol
SHA1SUM := sha1sum
PYTHON := python3
POSTPROC := tools/postprocess.py
# Options
INCLUDES := -i include -i include/dolphin/ -i include/dolphin/mtx/ -i src -i src/msl -i src/msl/ppc_eabi -i src/runtime/ -i src/sysdolphin/
ASFLAGS := -mgekko -I include
LDFLAGS := -map $(MAP) -fp hard -nodefaults -w off
CFLAGS := -Cpp_exceptions off -proc gekko -fp hard -O4,p -nodefaults -msgstyle gcc $(INCLUDES)
# for postprocess.py
PROCFLAGS := -fprologue-fixup=old_stack
# elf2dol needs to know these in order to calculate sbss correctly.
SDATA_PDHR := 9
SBSS_PDHR := 10
#-------------------------------------------------------------------------------
# Recipes
#-------------------------------------------------------------------------------
### Default target ###
default: all
all: $(DOL)
ALL_DIRS := build $(BUILD_DIR) $(addprefix $(BUILD_DIR)/,$(SRC_DIRS) $(ASM_DIRS))
# Make sure build directory exists before compiling anything
DUMMY != mkdir -p $(ALL_DIRS)
.PHONY: tools
$(LDSCRIPT): ldscript.lcf
$(CPP) -MMD -MP -MT $@ -MF $@.d -I include/ -I . -DBUILD_DIR=$(BUILD_DIR) -o $@ $<
$(DOL): $(ELF) | tools
$(ELF2DOL) $< $@ $(SDATA_PDHR) $(SBSS_PDHR) $(TARGET_COL)
$(SHA1SUM) -c $(TARGET).sha1
clean:
rm -f -d -r build
$(MAKE) -C tools clean
tools:
$(MAKE) -C tools
$(ELF): $(O_FILES) $(LDSCRIPT)
$(LD) $(LDFLAGS) -o $@ -lcf $(LDSCRIPT) $(O_FILES)
# The Metrowerks linker doesn't generate physical addresses in the ELF program headers. This fixes it somehow.
$(OBJCOPY) $@ $@
$(BUILD_DIR)/%.o: %.s
$(AS) $(ASFLAGS) -o $@ $<
$(BUILD_DIR)/%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
# TODO: See if this is necessary after actually adding some C code
# $(PYTHON) $(POSTPROC) $(PROCFLAGS) $@
### Debug Print ###
print-% : ; $(info $* is a $(flavor $*) variable set to [$($*)]) @true
+27
View File
@@ -0,0 +1,27 @@
# The Legend of Zelda: Twilight Princess
This repo contains a WIP decompilation of The Legend of Zelda: Twilight Princess (GCN USA).
It builds the following DOL:
main.dol - `sha1: 4997D93B9692620C40E90374A0F1DBF0E4889395`
And will eventually build all the [RELs](./rels_sha1.md).
## Windows Prerequisites
1. Download and run the latest release of the [Windows devkitpro installer](https://github.com/devkitPro/installer/releases)
2. Run the executable located at `devkitPro\msys2\msys2.exe`
3. Update pacman by running the following command: `pacman -Syu`
4. Install the necessary dependencies by running the following command: `pacman -S python3-pip base-devel gcc vim cmake`
5. Change to the directory of where you cloned this repository and you are ready to build!
## Build Instructions
1. Obtain a clean DOL of TP (GCN USA) and place it at the root of the repo and name it `baserom.dol`.
2. Obtain a copy of the MWCC PowerPC (from GC CW 3.0) and place it in tools/mwcc_compiler/3.0/ folder in tools/. (NOTE: This compiler's executables [mwcceppc.exe mwasmeppc.exe and mwldeppc.exe] can be installed with Codewarrior 3.0 for Gamecube, but no license or crack is provided with this project. If you can't find it on your own just DM me Pheenoh#0001).
4. Run `make` at the root of the repo
## Contributions
Contributions and PRs are welcome.
+1111
View File
File diff suppressed because it is too large Load Diff
+4
View File
@@ -0,0 +1,4 @@
.section .ctors, "wa" # 0x803737C0 - 0x80373980
.global lbl_803737C0
lbl_803737C0:
.incbin "baserom.dol", 0x3707C0, 0x1C0
+3874
View File
File diff suppressed because it is too large Load Diff
+4
View File
@@ -0,0 +1,4 @@
.section .dtors, "wa" # 0x80373980 - 0x803739A0
.global lbl_80373980
lbl_80373980:
.incbin "baserom.dol", 0x370980, 0x20
+3
View File
@@ -0,0 +1,3 @@
.section extab_, "wa" # 0x80005600 - 0x80005660
.incbin "baserom.dol", 0x370700, 0x60
+5
View File
@@ -0,0 +1,5 @@
.section extabindex_, "wa" # 0x80005660 - 0x800056BC
.incbin "baserom.dol", 0x370760, 0x3C
.global lbl_8000569C
lbl_8000569C:
.incbin "baserom.dol", 0x37079C, 0x24
+2458
View File
File diff suppressed because it is too large Load Diff
+1739
View File
File diff suppressed because it is too large Load Diff
+2575
View File
File diff suppressed because it is too large Load Diff
+67
View File
@@ -0,0 +1,67 @@
.include "macros.inc"
.section .sbss2, "a" # 0x80456B60 - 0x80456BC8
.global lbl_80456B60
lbl_80456B60:
.skip 0x8
.global lbl_80456B68
lbl_80456B68:
.skip 0x8
.global lbl_80456B70
lbl_80456B70:
.skip 0x8
.global lbl_80456B78
lbl_80456B78:
.skip 0x8
.global lbl_80456B80
lbl_80456B80:
.skip 0x4
.global lbl_80456B84
lbl_80456B84:
.skip 0x4
.global lbl_80456B88
lbl_80456B88:
.skip 0x8
.global lbl_80456B90
lbl_80456B90:
.skip 0x4
.global lbl_80456B94
lbl_80456B94:
.skip 0x4
.global lbl_80456B98
lbl_80456B98:
.skip 0x4
.global lbl_80456B9C
lbl_80456B9C:
.skip 0x4
.global lbl_80456BA0
lbl_80456BA0:
.skip 0x4
.global lbl_80456BA4
lbl_80456BA4:
.skip 0x4
.global lbl_80456BA8
lbl_80456BA8:
.skip 0x4
.global lbl_80456BAC
lbl_80456BAC:
.skip 0x4
.global lbl_80456BB0
lbl_80456BB0:
.skip 0x4
.global lbl_80456BB4
lbl_80456BB4:
.skip 0x4
.global lbl_80456BB8
lbl_80456BB8:
.skip 0x4
.global lbl_80456BBC
lbl_80456BBC:
.skip 0x4
.global lbl_80456BC0
lbl_80456BC0:
.skip 0x4
.global lbl_80456BC4
lbl_80456BC4:
.skip 0x4
+793
View File
File diff suppressed because it is too large Load Diff
+12709
View File
File diff suppressed because it is too large Load Diff
+986306
View File
File diff suppressed because it is too large Load Diff
+7
View File
@@ -0,0 +1,7 @@
#!/bin/bash
OBJDUMP="$DEVKITPPC/bin/powerpc-eabi-objdump -D -bbinary -EB -mpowerpc -M gekko"
OPTIONS="--start-address=$(($1)) --stop-address=$(($1 + $2))"
$OBJDUMP $OPTIONS baserom.dol > baserom.dump
$OBJDUMP $OPTIONS main.dol > main.dump
diff -u --color=always baserom.dump main.dump
+1
View File
@@ -0,0 +1 @@
4997D93B9692620C40E90374A0F1DBF0E4889395 build/dolzel2/main.dol
+34
View File
@@ -0,0 +1,34 @@
#ifndef __TYPES_H__
#define __TYPES_H__
typedef signed char s8;
typedef signed short s16;
typedef signed long s32;
typedef signed long long s64;
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned long u32;
typedef unsigned long long u64;
typedef volatile u8 vu8;
typedef volatile u16 vu16;
typedef volatile u32 vu32;
typedef volatile u64 vu64;
typedef volatile s8 vs8;
typedef volatile s16 vs16;
typedef volatile s32 vs32;
typedef volatile s64 vs64;
typedef float f32;
typedef double f64;
typedef volatile f32 vf32;
typedef volatile f64 vf64;
typedef int BOOL;
#define TRUE 1
#define FALSE 0
#define NULL ((void*)0)
#endif
+94
View File
@@ -0,0 +1,94 @@
/*
Code sections:
.text0: 0x00000100 0x80003100 0x80005600
.text1: 0x00002600 0x800056C0 0x803737C0
Data sections:
.data0: 0x00370700 0x80005600 0x80005660
.data1: 0x00370760 0x80005660 0x800056C0
.data2: 0x003707C0 0x803737C0 0x80373980
.data3: 0x00370980 0x80373980 0x803739A0
.data4: 0x003709A0 0x803739A0 0x803A2EE0
.data5: 0x0039FEE0 0x803A2EE0 0x803D32E0
.data6: 0x003D02E0 0x80450580 0x80450B00
.data7: 0x003D0860 0x80451A00 0x80456B60
BSS section:
.bss: 0x00000000 0x803D32E0 0x80456BC8
Entry Point: 0x80003154
*/
# PowerPC Register Constants
.set r0, 0
.set r1, 1
.set r2, 2
.set r3, 3
.set r4, 4
.set r5, 5
.set r6, 6
.set r7, 7
.set r8, 8
.set r9, 9
.set r10, 10
.set r11, 11
.set r12, 12
.set r13, 13
.set r14, 14
.set r15, 15
.set r16, 16
.set r17, 17
.set r18, 18
.set r19, 19
.set r20, 20
.set r21, 21
.set r22, 22
.set r23, 23
.set r24, 24
.set r25, 25
.set r26, 26
.set r27, 27
.set r28, 28
.set r29, 29
.set r30, 30
.set r31, 31
.set f0, 0
.set f1, 1
.set f2, 2
.set f3, 3
.set f4, 4
.set f5, 5
.set f6, 6
.set f7, 7
.set f8, 8
.set f9, 9
.set f10, 10
.set f11, 11
.set f12, 12
.set f13, 13
.set f14, 14
.set f15, 15
.set f16, 16
.set f17, 17
.set f18, 18
.set f19, 19
.set f20, 20
.set f21, 21
.set f22, 22
.set f23, 23
.set f24, 24
.set f25, 25
.set f26, 26
.set f27, 27
.set f28, 28
.set f29, 29
.set f30, 30
.set f31, 31
.set qr0, 0
.set qr1, 1
.set qr2, 2
.set qr3, 3
.set qr4, 4
.set qr5, 5
.set qr6, 6
.set qr7, 7
# Small Data Area (read/write) Base
.set _SDA_BASE_, 0x80458580
# Small Data Area (read only) Base
.set _SDA2_BASE_, 0x80459A00

Some files were not shown because too many files have changed in this diff Show More