From 45d820041c534c38212b688fe9516a5512ab7e31 Mon Sep 17 00:00:00 2001 From: rozlette Date: Sun, 15 Dec 2019 23:06:39 -0600 Subject: [PATCH] Add README.md. Minor makefile cleanup. --- .gitignore | 4 +- Makefile | 27 +++++------- README | 6 --- README.md | 87 +++++++++++++++++++++++++++++++++++++++ requirements.txt | 2 +- tables/functions.py | 2 +- tools/disasm.py | 1 + tools/dmadata.py | 1 + tools/extract_rom.py | 1 + tools/extract_textures.py | 1 + tools/makerom.py | 1 + tools/parse_actor_init.py | 1 + tools/print_mdebug.py | 1 + tools/split_asm.py | 1 + tools/yaz0.py | 1 + 15 files changed, 112 insertions(+), 25 deletions(-) delete mode 100644 README create mode 100644 README.md diff --git a/.gitignore b/.gitignore index 22955a9aad..ff4d8e4fce 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,6 @@ __pychahe__/* test.txt *.xlsx src/test.c -*.dump \ No newline at end of file +*.dump +tools/ido5.3_compiler/* +tools/ido7.1_compiler/* \ No newline at end of file diff --git a/Makefile b/Makefile index b20429cc46..db7acad94d 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,10 @@ # TODO think about how to split this up -MIPS_BINUTILS := mips-linux-gnu- - AS := $(MIPS_BINUTILS)as LD := $(MIPS_BINUTILS)ld -#QEMU_IRIX := ~/irixemu/mips-linux-user/qemu-mips -QEMU_IRIX := ~/qemu-irix -IRIX_71_ROOT := ./ido/71/ -IRIX_62_ROOT := ./ido/62/ -IRIX_53_ROOT := ./ido/53_patched/ +IRIX_71_ROOT := ./tools/ido7.1_compiler/ +IRIX_53_ROOT := ./tools/ido5.3_compiler/ CFLAGS := -G 0 -non_shared -Xfullwarn -Xcpluscomm ASFLAGS := -march=vr4300 -32 @@ -32,9 +27,9 @@ test.txt: CFLAGS := $(CFLAGS) -Wab,-r4300_mul CC := $(QEMU_IRIX) -L $(IRIX_71_ROOT) $(IRIX_71_ROOT)/usr/bin/cc -test.txt: CC := python3 ./tools/preprocess.py $(CC) -- $(AS) $(ASFLAGS) -- -build/src/boot_O2_g3/%: CC := python3 ./tools/preprocess.py $(CC) -- $(AS) $(ASFLAGS) -- -build/src/code/%: CC := python3 ./tools/preprocess.py $(CC) -- $(AS) $(ASFLAGS) -- +test.txt: CC := ./tools/preprocess.py $(CC) -- $(AS) $(ASFLAGS) -- +build/src/boot_O2_g3/%: CC := ./tools/preprocess.py $(CC) -- $(AS) $(ASFLAGS) -- +build/src/code/%: CC := ./tools/preprocess.py $(CC) -- $(AS) $(ASFLAGS) -- BASEROM_FILES := $(wildcard baserom/*) # Exclude dmadata, it will be generated right before packing the rom @@ -84,7 +79,7 @@ check: $(ROM) @md5sum -c checksum.md5 $(ROM): $(ROM_FILES) - @python3 ./tools/makerom.py ./tables/dmadata_table.py $@ + @./tools/makerom.py ./tables/dmadata_table.py $@ build/boot_pre_dmadata.bin: build/code_pre_dmadata.elf $(MIPS_BINUTILS)objcopy --dump-section boot=$@ $< @@ -116,7 +111,7 @@ linker_scripts/dmadata_script.txt: $(DECOMP_PRE_DMADATA_FILES) $(BASEROM_PRE_DMA mv build/decomp build/decomp_temp mv build/baserom_pre_dmadata build/baserom mv build/decomp_pre_dmadata build/decomp - python3 ./tools/dmadata.py ./tables/dmadata_table.py /dev/null -u -l linker_scripts/dmadata_script.txt + ./tools/dmadata.py ./tables/dmadata_table.py /dev/null -u -l linker_scripts/dmadata_script.txt mv build/baserom build/baserom_pre_dmadata mv build/decomp build/decomp_pre_dmadata mv build/baserom_temp build/baserom @@ -129,7 +124,7 @@ clean: rm $(ROM) -r build build/baserom/dmadata: $(COMP_FILES) $(DECOMP_FILES) $(BASEROM_BUILD_FILES) - python3 ./tools/dmadata.py ./tables/dmadata_table.py $@ + ./tools/dmadata.py ./tables/dmadata_table.py $@ build/baserom/boot: build/boot.bin cp $< $@ @@ -151,9 +146,9 @@ build/decomp_pre_dmadata/ovl_title: build/ovl_title_pre_dmadata.bin disasm: - @python3 ./tools/disasm.py -d ./asm -e ./include -u . -l ./tables/files.py -f ./tables/functions.py -o ./tables/objects.py -v ./tables/variables.py -v ./tables/vrom_variables.py -v ./tables/object_addr_variables.py -v ./tables/pre_boot_variables.py + @./tools/disasm.py -d ./asm -e ./include -u . -l ./tables/files.py -f ./tables/functions.py -o ./tables/objects.py -v ./tables/variables.py -v ./tables/vrom_variables.py -v ./tables/object_addr_variables.py -v ./tables/pre_boot_variables.py @while read -r file; do \ - python3 ./tools/split_asm.py ./asm/$$file.asm ./asm/nonmatching/$$file; \ + ./tools/split_asm.py ./asm/$$file.asm ./asm/nonmatching/$$file; \ done < ./tables/files_with_nonmatching.txt # Recipes @@ -177,5 +172,5 @@ build/decomp_pre_dmadata/%: decomp/% cp $< $@ build/comp/%.yaz0: build/decomp/% - python3 ./tools/yaz0.py $< $@ + ./tools/yaz0.py $< $@ diff --git a/README b/README deleted file mode 100644 index 111ac6cfaa..0000000000 --- a/README +++ /dev/null @@ -1,6 +0,0 @@ -WIP Majora's Mask decomp, proper docs and README will be made later. - -Basic steps (assuming you already have IDO and irixqemu): -Run extract_rom.py with a USA Majora's Mask ROM named baserom.z64 (will need to get libyaz0 first, I'll set up the dependency file eventually) -Run disasm.py -Run Make (edit the makefile with the paths to ido, etc. I'll make it use evironment variables eventually) \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000000..ac0ac50ccc --- /dev/null +++ b/README.md @@ -0,0 +1,87 @@ +# Legend of Zelda: Majora's Mask (U) 1.0 + +This is a disassembly of Legend of Zelda: Majora's Mask (U) 1.0 + +It builds the following ROM: +* rom.z64 `md5: 2a0a8acb61538235bc1094d297fb6556` + +# Installation + +## Step 1: + +If you're running Windows 10, [install WSL](https://docs.microsoft.com/en-us/windows/wsl/install-win10). If you're running an older version of Windows, install a Linux VM. If you're already running a Linux OS, you're good to go. + +## Step 2: + +Using sudo apt-get, install the following packages: + +``` +make +git +binutils-mips-linux-gnu +python3 +``` + +## Step 2: +Download build_tools.zip from the Releases section and extract it to the tools folder. + +## Step 3: + +Open up your .bashrc file (~/.bashrc), scroll to the bottom, and add the following, replacing `/path/to/qemu-mips` with the location the qemu-mips you extracted from the build tools: + +``` +export QEMU_IRIX="/path/to/qemu-mips" +export MIPS_BINUTILS_PREFIX=mips-linux-gnu- +``` + +Save and close/reopen your terminal window. + +## Step 4: +Make a fork of the main repository https://github.com/Rozelette/Majora-Unmasked.git and clone your fork. + +## Step 5: + +Navigate to the Majora-Unmasked folder you just cloned. Type the following commands: + +``` +git submodule update --init --recursive +pip install -r requirements.txt +``` + +## Step 6: + +You will need to acquire a copy of the ROM. The md5 of this ROM should be `2a0a8acb61538235bc1094d297fb6556`. + +Once this has been done, type, replacing `` with the name of your ROM: +``` +./tools/extract_baserom.py +``` + +This will extract all the individual files in the ROM into a newly created baserom folder, as well as decompress the compressed files in a newly created decomp folder. + +Next, type: +``` +make disasm +``` + +This will create the build folders as well as a newly created asm folder containing the disassemblies of nearly all the files containing code. + +## Step 7: + +Type the following: +``` +make +``` + +If all goes well, a ROM rom.z64 should be built and the following text should be printed: + +`rom.z64: OK ` + +If you instead see the following: + +``` +rom.z64: FAILED +md5sum: WARNING: 1 computed checksum did NOT match +``` + +This means that something is wrong with the ROM's contents. Either the baserom files are incorrect due to a bad ROM, or some piece of code is not matching. \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 86410682bc..b1b2eb1a01 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -libyaz0 +libyaz0==0.5 diff --git a/tables/functions.py b/tables/functions.py index ef946f2726..8fe11c4c34 100644 --- a/tables/functions.py +++ b/tables/functions.py @@ -1605,7 +1605,7 @@ 0x800EFBFC:("func_800EFBFC","void","GlobalContext* ctxt, s16 index"), 0x800EFD44:("func_800EFD44","void","GlobalContext* ctxt, s16 index"), 0x800EFE60:("EffFootmark_Init","void","GlobalContext* ctxt"), - 0x800EFF04:("EffFootmark_Add","void","GlobalContext* ctxt, z_Matrix* displayMatrix, Actor* actor, char id, Vector3f* location, u16 size, u8 red, u8 green, u8 blue, u16 alpha, u16 alphaChange, u16 fadeoutDelay"), + 0x800EFF04:("EffFootmark_Add","void","GlobalContext* ctxt, z_Matrix* displayMatrix, Actor* actor, u8 id, Vector3f* location, u16 size, u8 red, u8 green, u8 blue, u16 alpha, u16 alphaChange, u16 fadeoutDelay"), 0x800F00BC:("EffFootmark_Update","void","GlobalContext* ctxt"), 0x800F01C8:("EffFootmark_Draw","void","GlobalContext* ctxt"), 0x800F0390:("func_800F0390","void","GlobalContext* ctxt"), diff --git a/tools/disasm.py b/tools/disasm.py index 6a33593bed..4c13c08663 100644 --- a/tools/disasm.py +++ b/tools/disasm.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 import argparse, os, struct, ast SPLIT_FILES = True # TODO this should be a flag somewhere diff --git a/tools/dmadata.py b/tools/dmadata.py index 45f7dcf05c..0f4817db56 100644 --- a/tools/dmadata.py +++ b/tools/dmadata.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 import os, struct, sys, ast, argparse def align_up(base, align_to): diff --git a/tools/extract_rom.py b/tools/extract_rom.py index f4f5418550..1d41084ff8 100644 --- a/tools/extract_rom.py +++ b/tools/extract_rom.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 import struct, os, sys, argparse from libyaz0 import decompress diff --git a/tools/extract_textures.py b/tools/extract_textures.py index fc1a8c6ae5..742ffea2f8 100644 --- a/tools/extract_textures.py +++ b/tools/extract_textures.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 import struct; from tkinter import *; from tkinter.ttk import * diff --git a/tools/makerom.py b/tools/makerom.py index 7c7c9c6765..d88cf2fc77 100644 --- a/tools/makerom.py +++ b/tools/makerom.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 import os, struct, sys, ast, argparse def read_uint32_be(data, offset): diff --git a/tools/parse_actor_init.py b/tools/parse_actor_init.py index ae9e7578d2..d8a190c623 100644 --- a/tools/parse_actor_init.py +++ b/tools/parse_actor_init.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # TODO generalize data = [ diff --git a/tools/print_mdebug.py b/tools/print_mdebug.py index 1a70459474..7082240a2c 100644 --- a/tools/print_mdebug.py +++ b/tools/print_mdebug.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 ''' Resources: http://www.cs.unibo.it/~solmi/teaching/arch_2002-2003/AssemblyLanguageProgDoc.pdf diff --git a/tools/split_asm.py b/tools/split_asm.py index 000921e121..a240b31d96 100644 --- a/tools/split_asm.py +++ b/tools/split_asm.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 import argparse, os if __name__ == '__main__': diff --git a/tools/yaz0.py b/tools/yaz0.py index ef72ae46cc..67042f6333 100644 --- a/tools/yaz0.py +++ b/tools/yaz0.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 import os, sys, argparse def read_file(name):