Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ conker/ctx.c

tools/decomp-permuter
tools/gfxdis
venv/
.venv/
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ endif

### Targets

## REVERT ME - CI only uses the publish Docker container, so this is a workaround to install requirements. DO NOT MERGE THIS DO NOT MERGE THIS DO NOT MERGE THIS DO NOT MERGE THIS
pipinstall:
python3 -m pip install -r requirements.txt

default: all

all: dirs $(TARGET).z64 $(VERIFY)
Expand All @@ -55,7 +59,7 @@ really-clean: clean

check: .baserom.$(VERSION).ok

extract: check $(GAME_DIR)/$(BASENAME).$(VERSION).bin
extract: pipinstall check $(GAME_DIR)/$(BASENAME).$(VERSION).bin

decompress: $(EXTRACT_DIR)/00000000.bin

Expand Down Expand Up @@ -86,16 +90,16 @@ $(GAME_DIR)/$(BASENAME).$(VERSION).bin: $(BIN_DIR)/game.$(VERSION).bin
# game code is not compressed in ECTS ROM
ifeq ($(VERSION),ects)
$(BIN_DIR)/game.$(VERSION).bin: $(BASENAME).$(VERSION).yaml
$(PYTHON) tools/n64splat/split.py $<
$(PYTHON) -m splat split $<
else
$(BIN_DIR)/game.$(VERSION).bin: $(BIN_DIR)/game/rzip/data/0000.bin
cat $(BIN_DIR)/game/rzip/code/0*.bin $(BIN_DIR)/game/rzip/data/0000.bin > $@

$(BIN_DIR)/game/rzip/data/0000.bin: $(BIN_DIR)/game.$(VERSION).rzip.bin
$(PYTHON) tools/n64splat/split.py game.$(VERSION).rzip.yaml --modes bin rzip
$(PYTHON) -m splat split game.$(VERSION).rzip.yaml --modes bin rzip

$(BIN_DIR)/game.$(VERSION).rzip.bin: $(BASENAME).$(VERSION).yaml
$(PYTHON) tools/n64splat/split.py $<
$(PYTHON) -m splat split $<
endif

.baserom.$(VERSION).ok: baserom.$(VERSION).z64
Expand Down
3 changes: 2 additions & 1 deletion conker.us.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
sha1: 4cbadd3c4e0729dec46af64ad018050eada4f47a
options:
basename: conker
target_path: baserom.us.z64
platform: n64
base_path: .
compiler: IDO
extensions_path: tools/splat_ext
sha1: 4cbadd3c4e0729dec46af64ad018050eada4f47a
segments:
- name: header.us
type: bin
Expand Down
10 changes: 7 additions & 3 deletions conker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,11 @@ really-clean: clean
rm -f *auto.txt
rm -rf conker.us.bin conker.eu.bin conker.ects.bin conker.debug.bin

extract: $(BUILD_DIR)/splat
## REVERT ME - CI only uses the publish Docker container, so this is a workaround to install requirements. DO NOT MERGE THIS DO NOT MERGE THIS DO NOT MERGE THIS DO NOT MERGE THIS
pipinstall:
python3 -m pip install -r ../requirements.txt

extract: pipinstall $(BUILD_DIR)/splat

# sanity check base bin
check: $(BASENAME).$(VERSION).ok
Expand Down Expand Up @@ -201,7 +205,7 @@ $(GLOBAL_ASM_O_FILES): $(BUILD_DIR)/%.c.o: %.c include/variables.h include/struc
$(PYTHON) $(ASM_PROCESSOR_DIR)/asm_processor.py $(OPT_FLAGS) $< > $(BUILD_DIR)/$<
$(CC) -c -32 $(CFLAGS) $(OPT_FLAGS) $(LOOP_UNROLL) $(MIPSBIT) -o $@ $(BUILD_DIR)/$<
$(PYTHON) $(ASM_PROCESSOR_DIR)/asm_processor.py $(OPT_FLAGS) $< --post-process $@ \
--assembler "$(AS) $(ASFLAGS)" --asm-prelude $(ASM_PROCESSOR_DIR)/prelude.s
--assembler "$(AS) $(ASFLAGS)" --asm-prelude $(ASM_PROCESSOR_DIR)/prelude.inc
endif

$(BUILD_DIR)/%.c.o: %.c
Expand All @@ -218,7 +222,7 @@ $(TARGET).bin: $(TARGET).elf

# extract
$(BUILD_DIR)/splat: check $(BASENAME).$(VERSION).yaml
$(PYTHON) ../tools/n64splat/split.py $(BASENAME).$(VERSION).yaml
$(PYTHON) -m splat split $(BASENAME).$(VERSION).yaml

%.ok: %.bin
@echo "$$(cat $(BASENAME).$(VERSION).sha1) $<" | sha1sum --check
Expand Down
1 change: 1 addition & 0 deletions conker/conker.debug.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ options:
base_path: .
find_file_boundaries: yes
compiler: IDO
platform: n64
cpp_args:
- "-Iinclude"
- "-Iinclude/2.0L"
Expand Down
1 change: 1 addition & 0 deletions conker/conker.ects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ options:
base_path: .
find_file_boundaries: yes
compiler: IDO
platform: n64
cpp_args:
- "-Iinclude"
- "-Iinclude/2.0L"
Expand Down
1 change: 1 addition & 0 deletions conker/conker.eu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ options:
base_path: .
find_file_boundaries: yes
compiler: IDO
platform: n64
cpp_args:
- "-Iinclude"
- "-Iinclude/2.0L"
Expand Down
10 changes: 6 additions & 4 deletions conker/conker.us.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
sha1: 842e3d348e3c8ae0039e2ab367ad492f9b5266d8
options:
basename: conker
target_path: conker.us.bin
base_path: .
# find_file_boundaries: yes
compiler: IDO
platform: n64
generated_c_preamble: |
#include <ultra64.h>
#include "functions.h"
#include "variables.h"
create_detected_syms: yes
undefined_syms_path: undefined_syms.us.txt
symbol_addrs_path: symbol_addrs.us.txt
symbol_addrs_path: symbol_addrs.us.txt
symbol_name_format: $VRAM
symbol_name_format_no_rom: $VRAM
segments:
- name: header
type: header
Expand Down Expand Up @@ -47,7 +49,7 @@ segments:
- [0x50A0, c, init_50A0]
- [0x5570, asm, libultra/io/motor]
# - [0x57E0, asm] no file split here!
- [0x5AB0, c, init_5AB0]
- [0x5AB0, asm]
# - [0x6240, c]
# - [0x71D0, c]
- [0x8120, asm, libultra/os/maptlbrdb]
Expand Down
64 changes: 0 additions & 64 deletions conker/src/init_5AB0.c

This file was deleted.

7 changes: 1 addition & 6 deletions conker/symbol_addrs.us.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,7 @@ __osSpDeviceBusy = 0x10023e80;
__osSetTimerIntr = 0x100240B4;
__osInsertTimer = 0x10024128;
__osViInit = 0x100242b0;
__osGetActiveQueue = 0x10024400;
__osGetCurrFaultedThread = 0x10024400;
__osViGetCurrentContext = 0x10024400;
__osViGetNextContext = 0x10024400;
osPiGetDeviceType = 0x10024400;
__osGetActiveQueue = 0x10024400; // allow_duplicated:True
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can delete the dupes

__osViSwapContext = 0x10024410;
osGetCount = 0x10024770;
__osDequeueThread = 0x10024780;
Expand Down Expand Up @@ -219,7 +215,6 @@ corrupted_init2 = 0x151F1974;
corrupted2 = 0x151F1B28;
osPfsInit2 = 0x151EF450;
osContStartReadData2 = 0x151EFAA0;
__osPackReadData2 = 0x151EFC0C;
osContGetReadData2 = 0x151EFB64;
__osPackReadData2 = 0x151EFC0C;
guMtxXFML = 0x151F0080;
Expand Down
1 change: 1 addition & 0 deletions conker/undefined_funcs.us.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
__osDevMgrMain = 0x10002E50;
__n_CSPHandleMetaMsg = 0x10015044;
func_160036F0 = 0x160036F0;
2 changes: 0 additions & 2 deletions conker/undefined_syms.us.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,5 @@ D_8002BA44 = 0x8002BA44;
D_8002C080 = 0x8002C080;
D_8002C0A0 = 0x8002C0A0;
D_8002C410 = 0x8002C410;
D_8002C460 = 0x8002C460;
D_8002C4CC = 0x8002C4CC;
D_8002C520 = 0x8002C520;
D_80095A30 = 0x80095A30;
1 change: 1 addition & 0 deletions game.debug.rzip.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ options:
target_path: assets/game.debug.rzip.bin
base_path: .
asset_path: assets/game
platform: n64
extensions_path: tools/splat_ext
segments:
- name: code
Expand Down
1 change: 1 addition & 0 deletions game.eu.rzip.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ options:
target_path: assets/game.eu.rzip.bin
base_path: .
asset_path: assets/game
platform: n64
extensions_path: tools/splat_ext
segments:
- name: code
Expand Down
2 changes: 2 additions & 0 deletions game.us.rzip.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
options:
basename: conker
target_path: assets/game.us.rzip.bin
base_path: .
asset_path: assets/game
platform: n64
extensions_path: tools/splat_ext
segments:
- name: code
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ python-ranges
pyyaml
toml
watchdog
splat64[mips]>=0.34,<0.35
2 changes: 1 addition & 1 deletion tools/asm-processor
Submodule asm-processor updated 67 files
+291 −0 .github/workflows/release.yml
+31 −0 .github/workflows/test.yml
+3 −0 .gitignore
+51 −5 README.md
+4 −1 add-test.sh
+608 −216 asm_processor.py
+145 −0 build.py
+41 −0 compile-test.sh
+0 −19 compile.sh
+13 −0 dist-workspace.toml
+0 −2 include-stdin.c
+3 −0 mypy.ini
+55 −0 prelude.inc
+21 −2 run-tests.sh
+236 −0 rust/Cargo.lock
+24 −0 rust/Cargo.toml
+518 −0 rust/src/main.rs
+1,312 −0 rust/src/postprocess.rs
+966 −0 rust/src/preprocess.rs
+10 −0 tests/ascii.objdump
+1 −1 tests/comments.c
+8 −0 tests/comments.objdump
+17 −0 tests/custom-prelude.c
+21 −0 tests/custom-prelude.objdump
+6 −0 tests/custom-prelude.s
+3 −0 tests/euc_jp_wavedash.c
+26 −0 tests/euc_jp_wavedash.objdump
+17 −0 tests/force.c
+47 −0 tests/force.objdump
+12 −0 tests/include_file.asmproc.d
+8 −0 tests/include_file.c
+27 −0 tests/include_file.objdump
+7 −0 tests/include_file_1.s
+7 −0 tests/include_file_2.s
+7 −0 tests/include_file_3.s
+1 −0 tests/include_file_4.s
+93 −0 tests/kpic-o1.c
+46 −0 tests/kpic-o1.objdump
+92 −0 tests/kpic-o2.c
+46 −0 tests/kpic-o2.objdump
+14 −0 tests/label-sameline.objdump
+8 −0 tests/large.objdump
+20 −0 tests/late_rodata_align.objdump
+23 −0 tests/late_rodata_doubles.objdump
+86 −0 tests/late_rodata_doubles_mips1.c
+52 −0 tests/late_rodata_doubles_mips1.objdump
+76 −0 tests/late_rodata_jtbl.c
+101 −24 tests/late_rodata_jtbl.objdump
+155 −0 tests/late_rodata_jtbl_mips1.c
+110 −0 tests/late_rodata_jtbl_mips1.objdump
+23 −0 tests/late_rodata_misaligned_doubles.objdump
+1 −1 tests/line-continuation-separate-file.s
+3 −0 tests/line-continuation.asmproc.d
+10 −0 tests/line-continuation.objdump
+28 −0 tests/o0.c
+44 −0 tests/o0.objdump
+23 −0 tests/o2.objdump
+137 −0 tests/pascal.objdump
+95 −0 tests/pascal.p
+35 −0 tests/static-global.c
+60 −0 tests/static-global.objdump
+32 −0 tests/static.c
+58 −0 tests/static.objdump
+30 −0 tests/test1.objdump
+3 −3 tests/test2.c
+46 −2 tests/test2.objdump
+34 −0 tests/test3.objdump
2 changes: 1 addition & 1 deletion tools/n64splat
1 change: 0 additions & 1 deletion tools/splat_ext/rareunzip.py

This file was deleted.

24 changes: 24 additions & 0 deletions tools/splat_ext/rareunzip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import sys
import zlib


def runzip_with_leftovers(data):
d = zlib.decompressobj(wbits=-15) # raw deflate bytestream
res = d.decompress(data[4:]) # drop 4 byte length header
return (res, d.unused_data)

def runzip(data):
res, leftovers = runzip_with_leftovers(data)
return res

def main():
with open(sys.argv[1], "rb") as f:
with open(sys.argv[2], "wb") as o:
o.write(runzip(f.read()))


if __name__ == '__main__':
if len(sys.argv) < 3:
print("usage %s infile outfile" % sys.argv[0])
else:
main()
28 changes: 15 additions & 13 deletions tools/splat_ext/rzip.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@

from pathlib import Path

from segtypes.n64.segment import N64Segment
from util import options
from splat.util import options
from splat.segtypes.segment import Segment
import zlib

import sys
if options.get_extensions_path() not in sys.path:
sys.path.append('tools/splat_ext')
import rareunzip
# TODO: This is from rareunzip.py, but I can't get the relative import to work with splat.
# Figure out a way to import this function instead of copying it here.
def runzip_with_leftovers(data):
d = zlib.decompressobj(wbits=-15) # raw deflate bytestream
res = d.decompress(data[4:]) # drop 4 byte length header
return (res, d.unused_data)

# Rare zip format:
# 4 byte uncompressed length followed by deflate level 9 raw payload
class N64SegRzip(N64Segment):
def __init__(self, rom_start, rom_end, type, name, vram_start, extract, given_subalign, given_is_overlay, given_dir, args, yaml):
super().__init__(rom_start, rom_end, type, name, vram_start, extract, given_subalign, given_is_overlay, given_dir, args, yaml)
class N64SegRzip(Segment):
def __init__(self, rom_start, rom_end, type, name, vram_start, args, yaml):
super().__init__(rom_start, rom_end, type, name, vram_start, args=args, yaml=yaml)
self.has_subsegments = "subsegments" in yaml
self.yaml = yaml
self.xor = yaml.get("xor", None)

def get_default_name(self, addr):
Expand Down Expand Up @@ -92,7 +94,7 @@ def parse_subsegments(self):

ret = []
for i, split_file in enumerate(self.yaml["subsegments"]):
if type(split_file) is dict:
if isinstance(split_file, dict):
start = split_file["start"]
end = split_file["end"]
name = None if "name" not in split_file else split_file["name"]
Expand All @@ -115,7 +117,7 @@ def out_path(self) -> Path:
return self.out_dir() / f"{self.name}.bin"

def out_dir(self) -> Path:
return options.get_asset_path() / "rzip" / self.name
return options.opts.asset_path / "rzip" / self.name

def split(self, rom_bytes):
if self.has_subsegments:
Expand Down Expand Up @@ -155,7 +157,7 @@ def split(self, rom_bytes):
extension = "mp3"
else:
try:
result, padding = rareunzip.runzip_with_leftovers(data)
result, padding = runzip_with_leftovers(data)
except Exception as e:
print("Failed to decompress file", split_file, e)
# update total
Expand Down