Skip to content

Commit

Permalink
Action more info when it doesn't match and fix first diff (#662)
Browse files Browse the repository at this point in the history
* Update linux-compile.yml

* fix first-diff

* Update first-diff.py

---------

Co-authored-by: MegaMech <[email protected]>
  • Loading branch information
coco875 and MegaMech authored Aug 16, 2024
1 parent 6885c23 commit 9f920f2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ jobs:
cp -r complementary_file/* .
echo "${{ secrets.AES_KEY }}" | openssl enc -d -aes-256-cbc -pass stdin -pbkdf2 -in baserom.us.z64.aes -out baserom.us.z64
make assets
make -j
make -j || ./first-diff.py
15 changes: 9 additions & 6 deletions first-diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os.path
import argparse
from subprocess import check_call
import re

# TODO: -S argument for shifted ROMs

Expand Down Expand Up @@ -118,8 +119,9 @@ def search_map(rom_addr):
if "noload" in line or "noload" in prev_line:
ram_offset = None
continue
ram = int(line[16 : 16 + 18], 0)
rom = int(line[59 : 59 + 18], 0)
hex_number = re.findall(r"0x[0-9a-fA-F]+", line)
ram = int(hex_number[0], 0) # int(line[16 : 16 + 18], 0)
rom = int(hex_number[2], 0)# int(line[59 : 59 + 18], 0)
ram_offset = ram - rom
continue
prev_line = line
Expand All @@ -131,10 +133,11 @@ def search_map(rom_addr):
or " 0x" not in line
):
continue
ram = int(line[16 : 16 + 18], 0)
hex_number = re.findall(r"0x[0-9a-fA-F]+", line)
ram = int(hex_number[0], 0) # int(line[16 : 16 + 18], 0)
rom = ram - ram_offset
fn = line.split()[-1]
if "0x" in fn:
if fn.startswith("0x"):
ram_offset = None
continue
if rom > rom_addr or (rom_addr & 0x80000000 and ram > rom_addr):
Expand Down Expand Up @@ -265,7 +268,7 @@ def hexbytes(bs):
map_search_diff.append(search_map(i))
if diffs == 0:
print("No differences!")
exit()
exit(0)
definite_shift = diffs > shift_cap
if not definite_shift:
if (diffs > 1):
Expand All @@ -288,7 +291,7 @@ def hexbytes(bs):
+ basemap
+ " and rerun this script."
)
exit()
exit(1)

if not map_diff():
print(f"No ROM shift{' (!?)' if definite_shift else ''}")
Expand Down

0 comments on commit 9f920f2

Please sign in to comment.