From d81054c43da0f3227ac94e57a14ee9cdbf395293 Mon Sep 17 00:00:00 2001 From: mike8699 Date: Wed, 1 Jan 2025 21:18:21 -0500 Subject: [PATCH 1/6] Add `clang-format` pre-commit hook --- .pre-commit-config.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..ee5c697b --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,5 @@ +repos: + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v19.1.5 + hooks: + - id: clang-format From 88c72f047043dc57617bce1a979a534ababeb134 Mon Sep 17 00:00:00 2001 From: mike8699 Date: Wed, 1 Jan 2025 21:18:50 -0500 Subject: [PATCH 2/6] Add `pre-commit-hooks` to pre-commit config --- .pre-commit-config.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ee5c697b..705d42f3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,21 @@ repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-case-conflict + - id: check-executables-have-shebangs + - id: check-illegal-windows-names + - id: check-json + - id: check-merge-conflict + - id: check-yaml + args: + - --allow-multiple-documents + - id: debug-statements + - id: destroyed-symlinks + - id: mixed-line-ending + - id: requirements-txt-fixer + - id: trailing-whitespace + - repo: https://github.com/pre-commit/mirrors-clang-format rev: v19.1.5 hooks: From 83e058a8a11e9764d5674100a77310b5f10fee7c Mon Sep 17 00:00:00 2001 From: mike8699 Date: Wed, 1 Jan 2025 21:19:30 -0500 Subject: [PATCH 3/6] Run `pre-commit` formatting --- INSTALL.md | 2 +- docs/actors.md | 4 ++-- docs/build_system.md | 2 +- docs/decompiling.md | 4 ++-- extract/README.md | 2 +- include/System/SysNew.hpp | 2 +- tools/configure.py | 4 ++-- tools/mangle.py | 2 +- tools/requirements.txt | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 22a4f1fb..e6df2e4b 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -46,7 +46,7 @@ Now you can run `ninja` to build a ROM for the chosen version. First, [extract the ARM7 BIOS from your DS device](https://wiki.ds-homebrew.com/ds-index/ds-bios-firmware-dump). Put the ARM7 BIOS in the root directory of this repository, and verify that your dumped BIOS matches the one below: -| File name | SHA1 | +| File name | SHA1 | | --------------- | ------------------------------------------ | | `arm7_bios.bin` | `6ee830c7f552c5bf194c20a2c13d5bb44bdb5c03` | diff --git a/docs/actors.md b/docs/actors.md index d0efbc13..49300936 100644 --- a/docs/actors.md +++ b/docs/actors.md @@ -253,12 +253,12 @@ translations. Feel free to contribute to this list! `EVIC` | Event Icon | Exclamation point icon on the map screen `EQAR` | Earthquake Area `FMSG` | Freestanding? Message | Freestanding textbox -`ITGE` | Item Generator | Spawns an item, such as a small key +`ITGE` | Item Generator | Spawns an item, such as a small key `NCMA` | NPC Conversation Message? `NCM2` | NPC Conversation Message 2? `NMSG` | Navi Message | Starts dialogue with the fairy `RMTG` | Room Tag | Midpoint of small rooms, such as houses -`SWDS` | +`SWDS` | `SWOB` | Switch Object | Causes an event when one or more switches are active `VOCA` | Voice Area | Listens for microphone volume while Link is in the area `WNAR` | Wind Area | Creates gusts of wind that push Link diff --git a/docs/build_system.md b/docs/build_system.md index 8b40d3ab..82d32c6b 100644 --- a/docs/build_system.md +++ b/docs/build_system.md @@ -32,7 +32,7 @@ files to the project. Each `delinks.txt` file belongs to one module, such as the ARM9 program, the ITCM, the DTCM or an overlay. > [!NOTE] -> For interested readers: +> For interested readers: > All modules are loaded into RAM. This is different from the DS predecessor, the Game Boy Advance (GBA), in which all code was > simply on the ROM at all times. As a result, the GBA's RAM only consisted of variable data. > diff --git a/docs/decompiling.md b/docs/decompiling.md index c572e6f2..6eb32c39 100644 --- a/docs/decompiling.md +++ b/docs/decompiling.md @@ -24,9 +24,9 @@ We use the object diffing tool [`objdiff`](https://github.com/encounter/objdiff) 1. [Download the latest release.](https://github.com/encounter/objdiff/releases/latest) 1. Run `configure.py ` and `ninja` to generate `objdiff.json` in the repository root. 1. In `objdiff`, set the project directory to the repository root. -1. Select your source file in the left sidebar: +1. Select your source file in the left sidebar: ![List of objects in objdiff](images/objdiff_objects.png) -5. See the list of functions and data to decompile: +5. See the list of functions and data to decompile: ![List of symbols in objdiff](images/objdiff_symbols.png) > [!NOTE] diff --git a/extract/README.md b/extract/README.md index cb6f93a5..1aa8c5c2 100644 --- a/extract/README.md +++ b/extract/README.md @@ -2,7 +2,7 @@ This repository does not include any of the game's assets, and you will need an Put the base ROM(s) in this directory. Please verify that your dumped ROM matches one of the versions below: -| Version | File name | SHA1 | +| Version | File name | SHA1 | | ------- | -------------------- | ------------------------------------------ | | EUR | `baserom_ph_eur.nds` | `02be55db55cf254bd064d2b3eb368b92a5b4156d` | | USA | `baserom_ph_usa.nds` | `4c8f52dd719918bbcd46e73a8bae8628139c1b85` | diff --git a/include/System/SysNew.hpp b/include/System/SysNew.hpp index 20d4a46f..78f3b290 100644 --- a/include/System/SysNew.hpp +++ b/include/System/SysNew.hpp @@ -4,6 +4,6 @@ class SysObject { public: - static void* operator new(unsigned long length, u32 *id, u32 idLength); + static void *operator new(unsigned long length, u32 *id, u32 idLength); static void operator delete(void *ptr); }; diff --git a/tools/configure.py b/tools/configure.py index dbfb4f16..b1416e0f 100644 --- a/tools/configure.py +++ b/tools/configure.py @@ -158,7 +158,7 @@ def main(): command="./dsd rom build --config $in --rom $out $arm7_bios_flag" ) n.newline() - + n.rule( name="objdiff", command=f"./dsd objdiff --config-path $config_path {DSD_OBJDIFF_ARGS}" @@ -258,7 +258,7 @@ def add_mwcc_builds(n: ninja_syntax.Writer, game_version: str, game_build: Path) } ) n.newline() - + extension = source_file.suffix ctx_file = str(game_build / source_file.with_suffix(f".ctx{extension}")) n.build( diff --git a/tools/mangle.py b/tools/mangle.py index d14bec54..68d2aeb3 100644 --- a/tools/mangle.py +++ b/tools/mangle.py @@ -46,7 +46,7 @@ try: except subprocess.CalledProcessError as e: print(e.stdout.decode()) exit(1) - + output = output.decode() # print(output) diff --git a/tools/requirements.txt b/tools/requirements.txt index c0988481..7edbb58e 100644 --- a/tools/requirements.txt +++ b/tools/requirements.txt @@ -1,2 +1,2 @@ -requests pyperclip +requests From 2d8b257711ec638ec77bde1674df089d9d75dadf Mon Sep 17 00:00:00 2001 From: mike8699 Date: Wed, 1 Jan 2025 21:22:40 -0500 Subject: [PATCH 4/6] Run clang-format/other pre-commit checks in CI --- .github/workflows/ci.yaml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..e24acd17 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,31 @@ +name: CI +on: + push: + branches: + - main + pull_request: +jobs: + lint: + name: Linting/style checks + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.13' + check-latest: true + + - name: Install pre-commit + run: pip install pre-commit + + - name: Cache pre-commit hooks + uses: actions/cache@v4 + with: + path: ~/.cache/pre-commit/ + # Invalidate the cache if the pre-commit config changes or the Python version changes + key: pre-commit-cache|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} + + - name: Run pre-commit checks + run: pre-commit run --all-files --verbose From 53bd73e89c73f18ec8788baf45f43c0fdb02e145 Mon Sep 17 00:00:00 2001 From: Aetias Date: Mon, 6 Jan 2025 17:25:50 +0100 Subject: [PATCH 5/6] pre-commit: Allow hard linebreaks in Markdown --- .pre-commit-config.yaml | 2 ++ docs/build_system.md | 2 +- docs/decompiling.md | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 705d42f3..8b2ebb4c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,6 +15,8 @@ repos: - id: mixed-line-ending - id: requirements-txt-fixer - id: trailing-whitespace + args: + - --markdown-linebreak-ext=md - repo: https://github.com/pre-commit/mirrors-clang-format rev: v19.1.5 diff --git a/docs/build_system.md b/docs/build_system.md index 82d32c6b..8b40d3ab 100644 --- a/docs/build_system.md +++ b/docs/build_system.md @@ -32,7 +32,7 @@ files to the project. Each `delinks.txt` file belongs to one module, such as the ARM9 program, the ITCM, the DTCM or an overlay. > [!NOTE] -> For interested readers: +> For interested readers: > All modules are loaded into RAM. This is different from the DS predecessor, the Game Boy Advance (GBA), in which all code was > simply on the ROM at all times. As a result, the GBA's RAM only consisted of variable data. > diff --git a/docs/decompiling.md b/docs/decompiling.md index 6eb32c39..c572e6f2 100644 --- a/docs/decompiling.md +++ b/docs/decompiling.md @@ -24,9 +24,9 @@ We use the object diffing tool [`objdiff`](https://github.com/encounter/objdiff) 1. [Download the latest release.](https://github.com/encounter/objdiff/releases/latest) 1. Run `configure.py ` and `ninja` to generate `objdiff.json` in the repository root. 1. In `objdiff`, set the project directory to the repository root. -1. Select your source file in the left sidebar: +1. Select your source file in the left sidebar: ![List of objects in objdiff](images/objdiff_objects.png) -5. See the list of functions and data to decompile: +5. See the list of functions and data to decompile: ![List of symbols in objdiff](images/objdiff_symbols.png) > [!NOTE] From 820b8fefdc0b42a644dc5af2cc564169d0534db4 Mon Sep 17 00:00:00 2001 From: Aetias Date: Mon, 6 Jan 2025 17:27:31 +0100 Subject: [PATCH 6/6] pre-commit: Install instructions --- INSTALL.md | 8 ++++++-- tools/requirements.txt | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index e6df2e4b..45113307 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -21,11 +21,15 @@ Contents: ```shell python -m pip install -r tools/requirements.txt ``` -4. Run the setup script: +4. Install pre-commit hooks: +```shell +pre-commit install +``` +5. Run the setup script: ```shell python tools/setup.py ``` -5. Run the Ninja configure script: +6. Run the Ninja configure script: ```shell python tools/configure.py ``` diff --git a/tools/requirements.txt b/tools/requirements.txt index 7edbb58e..4682190e 100644 --- a/tools/requirements.txt +++ b/tools/requirements.txt @@ -1,2 +1,3 @@ +pre-commit pyperclip requests