Skip to content

Commit

Permalink
Merge branch 'main' into pal
Browse files Browse the repository at this point in the history
  • Loading branch information
ethteck committed Jul 30, 2023
2 parents 8e4b329 + b9cc734 commit f0c02fc
Show file tree
Hide file tree
Showing 631 changed files with 9,565 additions and 9,127 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:

jobs:
cpp_lint:
name: Format and lint
name: C format and lint
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/python.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Python Formatting & Linting
on:
pull_request:

jobs:
py_format:
name: black formatting
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black
- name: Run black
run: |
black . --check
4 changes: 2 additions & 2 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
},
"includePath": [
"${workspaceFolder}/include",
"${workspaceFolder}/ver/us/build/include",
"${workspaceFolder}/ver/pal/build/include",
"${workspaceFolder}/src",
"${workspaceFolder}/assets/us"
"${workspaceFolder}/assets/pal"
],
"defines": [
"F3DEX_GBI_2",
Expand Down
18 changes: 14 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
"docs/doxygen": true,
"expected": true,
"ver/jp/expected": true,
"ver/us/expected": true
"ver/us/expected": true,
"ver/pal/expected": true,
"ver/ique/expected": true
},
"python.autoComplete.extraPaths": [
"./tools"
Expand All @@ -47,6 +49,7 @@
"*.h": "c",
},
"C_Cpp.autoAddFileAssociations": false,
"C_Cpp.default.cStandard": "c89",
"files.exclude": {
"**/.git": true,
"**/.splat_cache": true,
Expand All @@ -56,7 +59,14 @@
"**/*.i": true,
"docs/doxygen": true
},
"C_Cpp.default.cStandard": "c89",
"python.linting.mypyEnabled": true,
"python.linting.enabled": true,
"[python]": {
"editor.formatOnType": true,
"editor.wordBasedSuggestions": false,
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "modifications",
"editor.defaultFormatter": "ms-python.black-formatter",
},
"black-formatter.args": [
"-l 120"
],
}
24 changes: 14 additions & 10 deletions coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,36 @@
import sys
from pathlib import Path


def strip_c_comments(text):
def replacer(match):
s = match.group(0)
if s.startswith('/'):
if s.startswith("/"):
return " "
else:
return s

pattern = re.compile(
r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"',
re.DOTALL | re.MULTILINE
re.DOTALL | re.MULTILINE,
)
return re.sub(pattern, replacer, text)

c_func_pattern = re.compile(
r"^(static\s+)?[^\s]+\s+([^\s(]+)\(([^;)]*)\)[^;]+{",
re.MULTILINE
)

c_func_pattern = re.compile(r"^(static\s+)?[^\s]+\s+([^\s(]+)\(([^;)]*)\)[^;]+{", re.MULTILINE)


def funcs_in_c(text):
return (match.group(2) for match in c_func_pattern.finditer(text))

asm_func_pattern = re.compile(
r"INCLUDE_ASM\([^,]+, [^,]+, ([^,)]+)",
re.MULTILINE
)

asm_func_pattern = re.compile(r"INCLUDE_ASM\([^,]+, [^,]+, ([^,)]+)", re.MULTILINE)


def include_asms_in_c(text):
return (match.group(1) for match in asm_func_pattern.finditer(text))


def stuff(version):
DIR = os.path.dirname(__file__)
NONMATCHINGS_DIR = Path(os.path.join(DIR, "ver", version, "asm", "nonmatchings"))
Expand Down Expand Up @@ -76,6 +79,7 @@ def stuff(version):
if not os.listdir(folder[0]):
os.removedirs(folder[0])


stuff("jp")
stuff("us")
stuff("pal")
Expand Down
29 changes: 11 additions & 18 deletions diff_evt.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
from old.update_evts import parse_symbol_addrs
from tools.disasm_script import ScriptDisassembler, get_constants

parser = argparse.ArgumentParser(
description="Diff EVT macros."
)
parser = argparse.ArgumentParser(description="Diff EVT macros.")

parser.add_argument(
"start",
Expand All @@ -26,21 +24,13 @@
"-w",
"--watch",
action="store_true",
help="Watch for file changes and update the diff automatically."
help="Watch for file changes and update the diff automatically.",
)

parser.add_argument(
"-m",
"--make",
action="store_true",
help="Run ninja automatically."
)
parser.add_argument("-m", "--make", action="store_true", help="Run ninja automatically.")

parser.add_argument("-o", action="store_true", help="Ignored for compatibility with diff.py.")

parser.add_argument(
"-o",
action="store_true",
help="Ignored for compatibility with diff.py."
)

class EvtDisplay(Display):
def __init__(self, start):
Expand Down Expand Up @@ -106,18 +96,21 @@ def run_diff(self):
refresh_key = (current, target)
return (output, refresh_key)

class FakeConfig():

class FakeConfig:
def __init__(self, args):
self.make = args.make
self.source_extensions = ["c", "h"]


def run_ninja():
return subprocess.run(
["ninja", "ver/current/build/papermario.z64"],
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
)


def main():
args = parser.parse_args()
get_constants()
Expand Down Expand Up @@ -153,8 +146,7 @@ def main():
ret = run_ninja()
if ret.returncode != 0:
display.update(
ret.stderr.decode("utf-8-sig", "replace")
or ret.stdout.decode("utf-8-sig", "replace"),
ret.stderr.decode("utf-8-sig", "replace") or ret.stdout.decode("utf-8-sig", "replace"),
error=True,
)
continue
Expand All @@ -164,5 +156,6 @@ def main():
else:
display.run_sync()


if __name__ == "__main__":
main()
10 changes: 5 additions & 5 deletions first_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
action="store",
default=False,
const="prompt",
help="run diff.py on the result with the provided arguments"
help="run diff.py on the result with the provided arguments",
)
parser.add_argument(
"-m", "--make", help="run ninja before finding difference(s)", action="store_true"
Expand Down Expand Up @@ -101,7 +101,9 @@ def search_rom_address(target_addr):
continue

if rom > target_addr:
return f"{prev_sym} (RAM 0x{prev_ram:X}, ROM 0x{prev_rom:X}, {prev_file})"
return (
f"{prev_sym} (RAM 0x{prev_ram:X}, ROM 0x{prev_rom:X}, {prev_file})"
)

prev_ram = ram
prev_rom = rom
Expand Down Expand Up @@ -214,9 +216,7 @@ def hexbytes(bs):
if len(found_instr_diff) > 0:
for i in found_instr_diff:
print(f"Instruction difference at ROM addr 0x{i:X}, {search_rom_address(i)}")
print(
f"Bytes: {hexbytes(mybin[i : i + 4])} vs {hexbytes(basebin[i : i + 4])}"
)
print(f"Bytes: {hexbytes(mybin[i : i + 4])} vs {hexbytes(basebin[i : i + 4])}")
print()

definite_shift = diffs > shift_cap
Expand Down
Loading

0 comments on commit f0c02fc

Please sign in to comment.