Skip to content

Commit 35b93e4

Browse files
committed
Merge branch 'Dev' into Dev-R
2 parents a999184 + 4808da6 commit 35b93e4

File tree

222 files changed

+47017
-35314
lines changed

Some content is hidden

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

222 files changed

+47017
-35314
lines changed

.github/workflows/release.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Python
2+
3+
on:
4+
push:
5+
branches: [ "release" ]
6+
pull_request:
7+
branches: [ "release" ]
8+
9+
jobs:
10+
release_ci_checks:
11+
name: Release CI Checks
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: ["3.x"]
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
- name: Run checks
24+
run: python CI.py --no_unit_tests --release

ASM/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/inject
22
/roms/*
3+
/tools/*
34
/c/*.o
45
armips*
56
!.gitkeep

ASM/Makefile

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
CC = mips64-gcc
22
LD = mips64-ld
33
OBJDUMP = mips64-objdump
4+
OBJCOPY = mips64-objcopy
45

5-
CFLAGS = -O1 -fno-reorder-blocks -march=vr4300 -mtune=vr4300 -mabi=32 -mno-gpopt -mdivide-breaks \
6+
CFLAGS = -O1 -G0 -fno-reorder-blocks -march=vr4300 -mtune=vr4300 -mabi=32 -mno-gpopt -mdivide-breaks \
67
-mexplicit-relocs
78
CPPFLAGS = -DF3DEX_GBI_2
89

@@ -11,8 +12,12 @@ OBJDIR := build/bin
1112
SRCDIR := c
1213
vpath %.c c
1314
vpath %.h c
15+
RESOURCEDIR := resources
16+
17+
UC = $(shell echo '$1' | tr '[:lower:]' '[:upper:]')
1418

1519
OBJECTS = $(patsubst $(SRCDIR)/%.c,$(OBJDIR)/%.o,$(sort $(wildcard $(SRCDIR)/*.c)))
20+
RESOURCES = $(patsubst $(RESOURCEDIR)/%.bin,$(OBJDIR)/%_bin.o,$(sort $(wildcard $(RESOURCEDIR)/*.bin)))
1621

1722
.PHONY: all clean bundle symbols
1823

@@ -28,10 +33,22 @@ endif
2833
$(OBJDIR):
2934
mkdir -p $@
3035

36+
$(OBJDIR)/%_bin.o: $(RESOURCEDIR)/%.bin
37+
$(OBJCOPY) -I binary -O elf32-bigmips --rename-section .data=.rodata,alloc,load,readonly,data,contents $< $@
38+
$(OBJCOPY) --redefine-sym _binary_resources_$*_bin_start=$(call UC,$*)_RESOURCE $@
39+
$(OBJCOPY) --redefine-sym _binary_resources_$*_bin_end=$(call UC,$*)_RESOURCE_END $@
40+
$(OBJCOPY) --redefine-sym _binary_resources_$*_bin_size=$(call UC,$*)_RESOURCE_SIZE $@
41+
42+
43+
$(RESOURCEDIR):
44+
mkdir -p $@
45+
3146
$(OBJECTS): | $(OBJDIR)
3247

33-
bundle: $(OBJECTS)
34-
$(LD) -o $(OUTDIR)/bundle.o -i -L. $(patsubst %.o,-l:%.o,$(OBJECTS))
48+
$(RESOURCES): | $(RESOURCEDIR)
49+
50+
bundle: $(RESOURCES) $(OBJECTS)
51+
$(LD) -T linker_script.ld -T ootSymbols.ld -o $(OUTDIR)/bundle.o -i -L. $(patsubst %.o,-l:%.o,$(OBJECTS) $(RESOURCES))
3552

3653
symbols: bundle
3754
$(OBJDUMP) -t $(OUTDIR)/bundle.o | tr -d '\015' > $(OUTDIR)/c_symbols.txt

ASM/README.md

Lines changed: 66 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,72 @@
1-
- Download the armips assembler: <https://github.com/Kingcom/armips>, build it if necessary, and put the executable in the `tools` directory, or somewhere in your PATH.
1+
Advanced modifications to the Randomzier source require a bit more software than what is needed for running it.
2+
3+
## Assembly: armips
4+
### Windows Prerequisite
5+
- Download and install the [Visual Studio 2015-202x Visual C++ Redistributable](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170#visual-studio-2015-2017-2019-and-2022) package.
6+
- You will want the x64 Architecture version.
7+
- This is to run the automated build of armips. If you plan to compile it yourself you can ignore this, but that is an advanced setup not covered here.
8+
### Running
9+
- Download the armips assembler: <https://github.com/Kingcom/armips>
10+
- [Windows automated builds](https://buildbot.orphis.net/armips/)
11+
- On other platforms you'll need either `clang` or `gcc`, `cmake`, and either `ninja` or `make` installed. All of these should be available in the package repositories of every major Linux distribution and Homebrew on macOS. After, follow the [building from source instructions](https://github.com/Kingcom/armips#22-building-from-source).
12+
- Put the armips executable in the `tools` directory, or somewhere in your PATH.
213
- Put the ROM you want to patch at `roms/base.z64`. This needs to be an uncompressed ROM; OoTRandomizer will produce one at ZOOTDEC.z64 when you run it with a compressed ROM.
3-
- Run `python build.py`, which will:
14+
- Run `python build.py --no-compile-c`, which will:
415
- create `roms/patched.z64`
516
- update some `txt` files in `build/` and in `../data/generated/`. Check `git status` to see which ones have changed. Make sure you submit them all together!
617

7-
To recompile the C modules, use the `--compile-c` option. This requires the N64 development tools to be installed: <https://github.com/glankk/n64>
18+
## C: n64 toolchain
19+
### Prerequisites
20+
Recompiling the C code for randomizer requires the N64 development tools to be installed: <https://github.com/glankk/n64>. There are several ways to do this depending on your platform.
21+
- **Windows**:
22+
- **Without WSL**: [Download this zip archive](https://discord.com/channels/274180765816848384/442752384834469908/1085678948614144081) and extract the `n64` folder into the `tools` directory alongside armips.
23+
- Download and install [MSYS2](https://www.msys2.org/#installation).
24+
1. Accept the defaults in the installer.
25+
2. After the installer completes a terminal window will open.
26+
3. In the terminal type `pacman -Syy make` and press Enter.
27+
4. Make sure it lists `make` for installation and press Enter again to confirm.
28+
5. After the installation finishes you can close the terminal window.
29+
6. In the Start search bar type "Environment Variables" and click "Edit the system environment variables".
30+
7. Near the bottom click on the button labeled "Environment Variables...".
31+
8. In the new window in the top section look for the variable called "Path" and click it.
32+
9. Click the "Edit..." button below the box you selected "Path" in.
33+
10. Click on "New" on the right side of the new window.
34+
11. Type `C:\msys64\usr\bin` and press Enter.
35+
12. Click "OK" on all three windows.
36+
13. You will now be able to compile the randomizer's C code from CMD, PowerShell, and MSYS2's terminal.
37+
- **Using WSL**: Install the latest Debian Linux from the Windows Store and follow the below instructions for Debian.
38+
- **Debian**: [Follow this how-to](https://practicerom.com/public/packages/debian/howto.txt) on adding the toolchain's package repository and installing the pre-built binaries.
39+
- You will also need to run `apt install build-essential` or `apt install make` if `make` is not installed.
40+
- **Any platform with a gcc compiler**: Build from source from the [glankk/n64](https://github.com/glankk/n64) repository. Simply follow the readme.
41+
- The dependency install script may not install all the necessary libraries depending on your OS version. Take a look at the output from the configure step to see if anything is missing.
42+
- It is easiest if you use `--prefix=/the/path/to/OoT-Randomizer/ASM/tools` for the `./configure` step. This will install all the toolchain in a way the build script can use, however this is inconvenient if you plan to use the toolchain for other projects as well.
43+
- If you are trying to update the toolchain this way, it is easiest to just delete your local copy of the repository and clone it again to ensure all the packages get updated and are compatible.
44+
45+
46+
You can substitute using the `tools` folder with adding the `n64/bin` folder to your environment PATH if you need an advanced setup.
47+
### Running
48+
To recompile the C modules, use `python build.py` in this directory, or adjust the path to `build.py` relative to your terminal's working directory.
49+
50+
## Debugging Symbols for Project64
51+
To generate symbols for the Project64 debugger, use the `--pj64sym` option:
52+
53+
python build.py --pj64sym 'path_to_pj64/Saves/THE LEGEND OF ZELDA.sym'
54+
55+
You'll need to disable `Unique Game Save Directory` in Project64 for these to work without copying them into each unique save folder. Remember that some changes in code will not be reflected in an existing save, and they need to be deleted and a new save created with this setting disabled.
856

9-
To generate symbols for the Project 64 debugger, use the `--pj64sym` option:
57+
--------------------------------------------------------------------------
1058

11-
python build.py --pj64sym 'path_to_pj64/Saves/THE LEGEND OF ZELDA.sym'
59+
How to use the Debug mode:
60+
- First put the DEBUG_MODE variable at 1 in debug.h.
61+
- You will then have access to a hidden menu with the following options:
62+
- Instant warps to Dungeons, Bosses or Overworld locations
63+
- Item inventory edits
64+
- Instant age switch with the current location kept
65+
- Bunny Hood applied on
66+
The menu will appear if you press either L+R or Dpad-Up according to what you set for the menu_not_on_dup variable in debug.c.
67+
Use Dpad-Left/Dpad-Right and A/B to navigate it.
68+
The L Button will also allow you to levitate.
69+
The warps and items are easily customizable with the code at the top of debug.c.
70+
- Additionally, you can call functions to print numbers on screen, to help you debug new features.
71+
Call either draw_debug_int or draw_debug_float in your code, with the first argument being the number wanted to be displayed, and the
72+
second argument its place on the screen (up to 10 values).

ASM/build.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,25 @@
1212
from crc import calculate_crc
1313

1414
parser = argparse.ArgumentParser()
15-
parser.add_argument('--pj64sym', help="Output path for PJ64 debugging symbols")
16-
parser.add_argument('--compile-c', action='store_true', help="Recompile C modules")
17-
parser.add_argument('--dump-obj', action='store_true', help="Dumps extra object info for debugging purposes. Does nothing without --compile-c")
15+
parser.add_argument('--pj64sym', help="Output path for Project64 debugging symbols")
16+
parser.add_argument('--compile-c', action='store_true', help="Recompile C modules. This is the default")
17+
parser.add_argument('--no-compile-c', action='store_true', help="Do not recompile C modules")
18+
parser.add_argument('--dump-obj', action='store_true', help="Dumps extra object info for debugging purposes. Does nothing with --no-compile-c")
1819
parser.add_argument('--diff-only', action='store_true', help="Creates diff output without running armips")
1920

2021
args = parser.parse_args()
2122
pj64_sym_path = args.pj64sym
22-
compile_c = args.compile_c
23+
compile_c = not args.no_compile_c
2324
dump_obj = args.dump_obj
2425
diff_only = args.diff_only
2526

2627
root_dir = os.path.dirname(os.path.realpath(__file__))
2728
tools_dir = os.path.join(root_dir, 'tools')
28-
os.environ['PATH'] = tools_dir + os.pathsep + os.environ['PATH']
29+
# Makes it possible to use the "tools" directory as the prefix for the toolchain
30+
tools_bin_dir = os.path.join(tools_dir, 'bin')
31+
# Makes it possible to copy the full toolchain prefix into the "tools" directory
32+
n64_bin_dir = os.path.join(tools_dir, "n64", "bin")
33+
os.environ['PATH'] = os.pathsep.join([tools_dir, tools_bin_dir, n64_bin_dir, os.environ['PATH']])
2934

3035
run_dir = root_dir
3136

@@ -62,7 +67,7 @@
6267

6368
with open('build/c_symbols.txt', 'r') as f:
6469
for line in f:
65-
m = re.match('''
70+
m = re.match(r'''
6671
^
6772
[0-9a-fA-F]+
6873
.*

0 commit comments

Comments
 (0)