diff --git a/Makefile b/Makefile index 8a1e407..b184c75 100644 --- a/Makefile +++ b/Makefile @@ -105,6 +105,11 @@ distclean: clean setup: clean distclean split +diff-init: all + $(RM) -rf expected/ + mkdir -p expected/ + cp -r $(BUILD_DIR) expected/$(BUILD_DIR) + split: $(V)$(SPLAT) @touch $(SPLAT_TIMESTAMP) diff --git a/splat.yaml b/splat.yaml index 425498a..e2d9c67 100644 --- a/splat.yaml +++ b/splat.yaml @@ -5,7 +5,7 @@ options: target_path: baserom.z64 base_path: . compiler: GCC - find_file_boundaries: True + find_file_boundaries: False header_encoding: ASCII platform: n64 asm_inc_header: "" @@ -39,7 +39,7 @@ segments: start: 0x1000 vram: 0x80070C00 subsegments: - - [0x1000, asm, entry] + - [0x1000, asm, "entry_code"] - name: main type: code @@ -60,6 +60,7 @@ segments: - [0xFF10, asm] - [0x10110, asm] - [0x10190, asm] + - [0x10190, asm] - [0x10250, asm] - [0x102E0, asm] - [0x10340, asm] @@ -408,6 +409,7 @@ segments: - { start: 0x66E10, type: bss, vram: 0x80190F10 } - [0x66E10, bin] + # __SOME_OVERLAY_TABLE[0] # - type: code # dir: overlay_66E10 @@ -462,24 +464,24 @@ segments: # - { start: 0x71280, type: bss, vram: 0x8019A790 } - # - type: code - # dir: overlay_71280 - # start: 0x71280 - # vram: 0x8019A7A0 - # bss_size: 0x40 - # symbol_name_format: overlay_71280_$VRAM_$ROM - # exclusive_ram_id: test_overlapping - # subsegments: - # - [0x71280, asm] + - type: code + dir: overlay_71280 + start: 0x71280 + vram: 0x8019A7A0 + bss_size: 0x40 + symbol_name_format: overlay_71280_$VRAM_$ROM + exclusive_ram_id: test_overlapping + subsegments: + - [0x71280, asm] - # - [0x783A0, rodata] - # - [0x78410, rodata] - # - [0x785D0, rodata] - # - [0x790F0, rodata] - # - [0x79160, rodata] - # - [0x793F0, rodata] + - [0x783A0, rodata, "71280"] + - [0x78410, rodata] + - [0x785D0, rodata] + - [0x790F0, rodata] + - [0x79160, rodata] + - [0x793F0, rodata] - # - { start: 0x79730, type: bss, vram: 0x8019A790 } + # - { start: 0x79730, type: bss, vram: 0x801A2C50 } - type: code dir: overlay_79730 diff --git a/symbol_addrs.txt b/symbol_addrs.txt index 06a173f..317298d 100644 --- a/symbol_addrs.txt +++ b/symbol_addrs.txt @@ -9,6 +9,8 @@ __OVERLAY_INFO_71280_65CA0 = 0x8018FDA0; __setup_overlay_71280_51940 = 0x8017BA40; // rom:0x51940 __OVERLAY_INFO_71280_65C8C = 0x8018FD8C; +__get_overlay_info_71280_65C8C = 0x8017B5E0; + __setup_overlay_71280_51674 = 0x8017B774; // rom:0x51674 __OVERLAY_INFO_8018FAE4 = 0x8018FAE4; diff --git a/tools/first_diff.py b/tools/first_diff.py new file mode 100644 index 0000000..db7c7cc --- /dev/null +++ b/tools/first_diff.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python3 + +# SPDX-FileCopyrightText: © 2022 AngheloAlf +# SPDX-License-Identifier: MIT + +from __future__ import annotations + +import argparse +import mapfile_parser +from pathlib import Path +import rabbitizer + + +def decodeInstruction(bytesDiff: bytes, mapFile: mapfile_parser.MapFile) -> str: + word = (bytesDiff[0] << 24) | (bytesDiff[1] << 16) | (bytesDiff[2] << 8) | (bytesDiff[3] << 0) + instr = rabbitizer.Instruction(word) + immOverride = None + + if instr.isJumpWithAddress(): + # Instruction is a function call (jal) + + # Get the embedded address of the function call + symAddress = instr.getInstrIndexAsVram() + + # Search for the address in the mapfile + symInfo = mapFile.findSymbolByVramOrVrom(symAddress) + if symInfo is not None: + # Use the symbol from the mapfile instead of a raw value + immOverride = symInfo.symbol.name + + return instr.disassemble(immOverride=immOverride, extraLJust=-20) + +def firstDiffMain(): + parser = argparse.ArgumentParser(description="Find the first difference(s) between the built ROM and the base ROM.") + + parser.add_argument("-c", "--count", type=int, default=5, help="find up to this many instruction difference(s)") +# parser.add_argument("-v", "--version", help="Which version should be processed", default="us") + parser.add_argument("-a", "--add-colons", action='store_true', help="Add colon between bytes" ) + + args = parser.parse_args() + + buildFolder = Path("build") + + BUILTROM = buildFolder / f"ogrebattle64.z64" + BUILTMAP = buildFolder / f"ogrebattle64.map" + + EXPECTEDROM = "expected" / BUILTROM + EXPECTEDMAP = "expected" / BUILTMAP + + mapfile_parser.frontends.first_diff.doFirstDiff(BUILTMAP, EXPECTEDMAP, BUILTROM, EXPECTEDROM, args.count, mismatchSize=True, addColons=args.add_colons, bytesConverterCallback=decodeInstruction) + +if __name__ == "__main__": + firstDiffMain() diff --git a/tools/splat b/tools/splat index c6e925f..e0fb798 160000 --- a/tools/splat +++ b/tools/splat @@ -1 +1 @@ -Subproject commit c6e925fc9b610a4b0a76f16773595ccaa67d2ffe +Subproject commit e0fb79806748ef400c225b6841403078df5b9986