merge master

This commit is contained in:
engineer124
2022-10-05 13:54:29 -04:00
194 changed files with 2902 additions and 958 deletions
+5 -1
View File
@@ -1,5 +1,9 @@
Checks: '-*,readability-braces-around-statements'
Checks: '-*,readability-braces-around-statements,readability-inconsistent-declaration-parameter-name'
WarningsAsErrors: ''
HeaderFilterRegex: '(src|include)\/.*\.h$'
FormatStyle: 'file'
CheckOptions:
# Require argument names to match exactly (instead of allowing a name to be a prefix/suffix of another)
# Note: 'true' is expected by clang-tidy 12+ but '1' is used for compatibility with older versions
- key: readability-inconsistent-declaration-parameter-name.Strict
value: 1
@@ -0,0 +1,32 @@
<Root>
<!-- Assets for dungeon icons -->
<File Name="icon_item_dungeon_static" Segment="12">
<!-- Identical icons to OoT -->
<Texture Name="gDungeonMapBlankFloorButtonTex" OutName="dungeon_map_blank_floor_button" Format="ia8" Width="24" Height="16" Offset="0x0"/>
<Texture Name="gDungeonMap1FButtonTex" OutName="dungeon_map_1f_button" Format="ia8" Width="24" Height="16" Offset="0x180"/>
<Texture Name="gDungeonMap2FButtonTex" OutName="dungeon_map_2f_button" Format="ia8" Width="24" Height="16" Offset="0x300"/>
<Texture Name="gDungeonMap3FButtonTex" OutName="dungeon_map_3f_button" Format="ia8" Width="24" Height="16" Offset="0x480"/>
<Texture Name="gDungeonMap4FButtonTex" OutName="dungeon_map_4f_button" Format="ia8" Width="24" Height="16" Offset="0x600"/>
<Texture Name="gDungeonMap5FButtonTex" OutName="dungeon_map_5f_button" Format="ia8" Width="24" Height="16" Offset="0x780"/>
<Texture Name="gDungeonMap6FButtonTex" OutName="dungeon_map_6f_button" Format="ia8" Width="24" Height="16" Offset="0x900"/>
<Texture Name="gDungeonMap7FButtonTex" OutName="dungeon_map_7f_button" Format="ia8" Width="24" Height="16" Offset="0xA80"/>
<Texture Name="gDungeonMap8FButtonTex" OutName="dungeon_map_8f_button" Format="ia8" Width="24" Height="16" Offset="0xC00"/>
<Texture Name="gDungeonMapB1ButtonTex" OutName="dungeon_map_b1_button" Format="ia8" Width="24" Height="16" Offset="0xD80"/>
<Texture Name="gDungeonMapB2ButtonTex" OutName="dungeon_map_b2_button" Format="ia8" Width="24" Height="16" Offset="0xF00"/>
<Texture Name="gDungeonMapB3ButtonTex" OutName="dungeon_map_b3_button" Format="ia8" Width="24" Height="16" Offset="0x1080"/>
<Texture Name="gDungeonMapB4ButtonTex" OutName="dungeon_map_b4_button" Format="ia8" Width="24" Height="16" Offset="0x1200"/>
<Texture Name="gDungeonMapB5ButtonTex" OutName="dungeon_map_b5_button" Format="ia8" Width="24" Height="16" Offset="0x1380"/>
<Texture Name="gDungeonMapB6ButtonTex" OutName="dungeon_map_b6_button" Format="ia8" Width="24" Height="16" Offset="0x1500"/>
<Texture Name="gDungeonMapB7ButtonTex" OutName="dungeon_map_b7_button" Format="ia8" Width="24" Height="16" Offset="0x1680"/>
<Texture Name="gDungeonMapB8ButtonTex" OutName="dungeon_map_b8_button" Format="ia8" Width="24" Height="16" Offset="0x1800"/>
<!-- Skull has a slightly altered design compared to OoT -->
<Texture Name="gDungeonMapSkullTex" OutName="dungeon_map_skull" Format="rgba16" Width="16" Height="16" Offset="0x1980"/>
<!-- Similar to stray fairy icons in parameter_static, except facing forward -->
<Texture Name="gDungeonStrayFairyWoodfallIconTex" OutName="dungeon_stray_fairy_woodfall_icon" Format="rgba32" Width="32" Height="24" Offset="0x1B80"/>
<Texture Name="gDungeonStrayFairySnowheadIconTex" OutName="dungeon_stray_fairy_snowhead_icon" Format="rgba32" Width="32" Height="24" Offset="0x2780"/>
<Texture Name="gDungeonStrayFairyGreatBayIconTex" OutName="dungeon_stray_fairy_great_bay_icon" Format="rgba32" Width="32" Height="24" Offset="0x3380"/>
<Texture Name="gDungeonStrayFairyStoneTowerIconTex" OutName="dungeon_stray_fairy_stone_tower_icon" Format="rgba32" Width="32" Height="24" Offset="0x3F80"/>
</File>
</Root>
@@ -0,0 +1,40 @@
<Root>
<!-- Assets for the world map -->
<File Name="icon_item_field_static" Segment="12">
<!-- World map itself -->
<Texture Name="gWorldMapImageTex" OutName="world_map_image" Format="ci8" Width="216" Height="128" Offset="0x0" TlutOffset="0x6C00"/>
<Texture Name="gWorldMapImageTLUT" OutName="world_map_image_tlut" Format="rgba16" Width="16" Height="16" Offset="0x6C00"/>
<!-- Identical To OoT -->
<Texture Name="gWorldMapDotTex" OutName="world_map_dot" Format="ia8" Width="8" Height="8" Offset="0x6E00"/>
<Texture Name="gWorldMapAreaBox1Tex" OutName="world_map_area_box_1" Format="ia4" Width="32" Height="19" Offset="0x6E40"/>
<Texture Name="gWorldMapAreaBox2Tex" OutName="world_map_area_box_2" Format="ia4" Width="48" Height="38" Offset="0x6F70"/>
<Texture Name="gWorldMapAreaBox3Tex" OutName="world_map_area_box_3" Format="ia4" Width="32" Height="17" Offset="0x7300"/>
<Texture Name="gWorldMapAreaBox4Tex" OutName="world_map_area_box_4" Format="ia4" Width="32" Height="13" Offset="0x7410"/>
<Texture Name="gWorldMapAreaBox5Tex" OutName="world_map_area_box_5" Format="ia4" Width="32" Height="26" Offset="0x74E0"/>
<Texture Name="gWorldMapAreaBox6Tex" OutName="world_map_area_box_6" Format="ia4" Width="48" Height="19" Offset="0x7680"/>
<Texture Name="gWorldMapAreaBox7Tex" OutName="world_map_area_box_7" Format="ia4" Width="96" Height="59" Offset="0x7848"/>
<Texture Name="gWorldMapAreaBox8Tex" OutName="world_map_area_box_8" Format="ia4" Width="16" Height="16" Offset="0x8358"/>
<Texture Name="gWorldMapArrowTex" OutName="world_map_arrow" Format="ia8" Width="8" Height="8" Offset="0x83D8"/>
<!-- Cloud cover based on tingle maps -->
<Texture Name="gWorldMapClockTownCloud1Tex" OutName="world_map_clock_town_cloud_1" Format="ia8" Width="80" Height="40" Offset="0x8418"/>
<Texture Name="gWorldMapClockTownCloud2Tex" OutName="world_map_clock_town_cloud_2" Format="ia8" Width="64" Height="31" Offset="0x9098"/>
<Texture Name="gWorldMapRomaniRanchCloudTex" OutName="world_map_romani_ranch_cloud" Format="ia8" Width="48" Height="32" Offset="0x9858"/>
<Texture Name="gWorldMapGreatBayCloud1Tex" OutName="world_map_great_bay_cloud_1" Format="ia8" Width="64" Height="64" Offset="0x9E58"/>
<Texture Name="gWorldMapGreatBayCloud2Tex" OutName="world_map_great_bay_cloud_2" Format="ia8" Width="64" Height="64" Offset="0xAE58"/>
<Texture Name="gWorldMapGreatBayCloud3Tex" OutName="world_map_great_bay_cloud_3" Format="ia8" Width="64" Height="64" Offset="0xBE58"/>
<Texture Name="gWorldMapGreatBayCloud4Tex" OutName="world_map_great_bay_cloud_4" Format="ia8" Width="64" Height="64" Offset="0xCE58"/>
<Texture Name="gWorldMapSnowheadCloud1Tex" OutName="world_map_snowhead_cloud_1" Format="ia8" Width="64" Height="52" Offset="0xDE58"/>
<Texture Name="gWorldMapSnowheadCloud2Tex" OutName="world_map_snowhead_cloud_2" Format="ia8" Width="112" Height="35" Offset="0xEB58"/>
<Texture Name="gWorldMapSnowheadCloud3Tex" OutName="world_map_snowhead_cloud_3" Format="ia8" Width="112" Height="35" Offset="0xFAA8"/>
<Texture Name="gWorldMapStoneTowerCloud1Tex" OutName="world_map_stone_tower_cloud_1" Format="ia8" Width="48" Height="82" Offset="0x109F8"/>
<Texture Name="gWorldMapStoneTowerCloud2Tex" OutName="world_map_stone_tower_cloud_2" Format="ia8" Width="64" Height="61" Offset="0x11958"/>
<Texture Name="gWorldMapWoodfallCloud1Tex" OutName="world_map_woodfall_cloud_1" Format="ia8" Width="64" Height="53" Offset="0x12898"/>
<Texture Name="gWorldMapWoodfallCloud2Tex" OutName="world_map_woodfall_cloud_2" Format="ia8" Width="64" Height="53" Offset="0x135D8"/>
<Texture Name="gWorldMapWoodfallCloud3Tex" OutName="world_map_woodfall_cloud_3" Format="ia8" Width="16" Height="53" Offset="0x14318"/>
<!-- Face of an owl to indicate warp points -->
<Texture Name="gWorldMapOwlFaceTex" OutName="world_map_owl_face" Format="rgba32" Width="24" Height="12" Offset="0x14668"/>
</File>
</Root>
@@ -0,0 +1,31 @@
<Root>
<!-- Pause Menu: Language-Dependent Textures -->
<File Name="icon_item_jpn_static" Segment="13">
<!-- Pause Menu Dungeon Title Cards -->
<Texture Name="gPauseWoodfallTitleENGTex" OutName="pause_woodfall_title_eng" Format="ia8" Width="128" Height="16" Offset="0x0"/>
<Texture Name="gPauseSnowheadTitleENGTex" OutName="pause_snowhead_title_eng" Format="ia8" Width="128" Height="16" Offset="0x800"/>
<Texture Name="gPauseGreatBayTitleENGTex" OutName="pause_great_bay_title_eng" Format="ia8" Width="128" Height="16" Offset="0x1000"/>
<Texture Name="gPauseStoneTowerTitleENGTex" OutName="pause_stone_tower_title_eng" Format="ia8" Width="128" Height="16" Offset="0x1800"/>
<!-- Pause Menu Info Panel To-> Textures -->
<Texture Name="gPauseToEquipENGTex" OutName="pause_to_equip_eng" Format="ia4" Width="64" Height="16" Offset="0x2000"/>
<Texture Name="gPauseToDecideENGTex" OutName="pause_to_decide_eng" Format="ia4" Width="64" Height="16" Offset="0x2200"/>
<Texture Name="gPauseToPlayMelodyENGTex" OutName="pause_to_play_melody_eng" Format="ia4" Width="96" Height="16" Offset="0x2400"/>
<Texture Name="gPauseToSelectItemENGTex" OutName="pause_to_select_item_eng" Format="ia4" Width="128" Height="16" Offset="0x2700"/>
<Texture Name="gPauseToMapENGTex" OutName="pause_to_map_eng" Format="ia4" Width="128" Height="16" Offset="0x2B00"/>
<Texture Name="gPauseToQuestStatusENGTex" OutName="pause_to_quest_status_eng" Format="ia4" Width="128" Height="16" Offset="0x2F00"/>
<Texture Name="gPauseToMasksENGTex" OutName="pause_to_masks_eng" Format="ia4" Width="128" Height="16" Offset="0x3300"/>
<Texture Name="gPauseToViewNotebookENGTex" OutName="pause_to_view_notebook_eng" Format="ia4" Width="96" Height="16" Offset="0x3700"/>
<!-- Pause Menu Pages Background Textures -->
<!-- Divided into 3 columns (first digit) and 5 rows (second digit) -->
<Texture Name="gPauseMasks10ENGTex" OutName="pause_masks_1_0_eng" Format="ia8" Width="80" Height="32" Offset="0x3A00"/>
<Texture Name="gPauseSelectItem00ENGTex" OutName="pause_select_item_0_0_eng" Format="ia8" Width="80" Height="32" Offset="0x4400"/>
<Texture Name="gPauseSelectItem10ENGTex" OutName="pause_select_item_1_0_eng" Format="ia8" Width="80" Height="32" Offset="0x4E00"/>
<Texture Name="gPauseSelectItem20ENGTex" OutName="pause_select_item_2_0_eng" Format="ia8" Width="80" Height="32" Offset="0x5800"/>
<Texture Name="gPauseMap10ENGTex" OutName="pause_map_1_0_eng" Format="ia8" Width="80" Height="32" Offset="0x6200"/>
<Texture Name="gPauseQuestStatus00ENGTex" OutName="pause_quest_status_0_0_eng" Format="ia8" Width="80" Height="32" Offset="0x6C00"/>
<Texture Name="gPauseQuestStatus10ENGTex" OutName="pause_quest_status_1_0_eng" Format="ia8" Width="80" Height="32" Offset="0x7600"/>
<Texture Name="gPauseQuestStatus20ENGTex" OutName="pause_quest_status_2_0_eng" Format="ia8" Width="80" Height="32" Offset="0x8000"/>
</File>
</Root>
@@ -127,6 +127,7 @@
<Texture Name="gMinigameLetterTTex" OutName="minigame_letter_t" Format="i4" Width="32" Height="33" Offset="0x8578"/>
<Texture Name="gMinigameExclamationTex" OutName="minigame_exclamation" Format="i4" Width="32" Height="33" Offset="0x8788"/>
<!-- Similar to stray fairy icons in icon_item_dungeon_static, except with a turned head -->
<Texture Name="gStrayFairyWoodfallIconTex" OutName="stray_fairy_woodfall_icon" Format="rgba32" Width="32" Height="24" Offset="0x8998"/>
<Texture Name="gStrayFairySnowheadIconTex" OutName="stray_fairy_snowhead_icon" Format="rgba32" Width="32" Height="24" Offset="0x9598"/>
<Texture Name="gStrayFairyGreatBayIconTex" OutName="stray_fairy_great_bay_icon" Format="rgba32" Width="32" Height="24" Offset="0xA198"/>
+2 -2
View File
@@ -1,7 +1,7 @@
<Root>
<File Name="object_fusen" Segment="6">
<DList Name="object_fusen_DL_000A00" Offset="0xA00" />
<DList Name="object_fusen_DL_000D78" Offset="0xD78" />
<DList Name="gMajoraBalloonDL" Offset="0xA00" />
<DList Name="gMajoraBalloonKnotDL" Offset="0xD78" />
<Texture Name="object_fusen_Tex_000E08" OutName="tex_000E08" Format="rgba16" Width="32" Height="32" Offset="0xE08" />
<Collision Name="object_fusen_Colheader_002420" Offset="0x2420" />
</File>
+12
View File
@@ -0,0 +1,12 @@
<Root>
<ExternalFile XmlPath="objects/gameplay_keep.xml" OutPath="assets/objects/gameplay_keep/"/>
<File Name="ovl_Oceff_Storm" BaseAddress="0x80981760" RangeStart="0x830" RangeEnd="0x1BC0">
<Texture Name="sSongOfStormsEffectTex" OutName="song_of_storms_effect" Format="i8" Width="64" Height="64" Offset="0x830"/>
<DList Name="sSongOfStormsMaterialDL" Offset="0x1830"/>
<Array Name="sSongOfStormsCylinderVtx" Count="27" Offset="0x18D8">
<Vtx/>
</Array>
<DList Name="sSongOfStormsCylinderMaterialDL" Offset="0x1A88"/>
<DList Name="sSongOfStormsCylinderModelDL" Offset="0x1B30"/>
</File>
</Root>
+25 -3
View File
@@ -23,7 +23,7 @@
- [`tools/warnings_count/check_new_warnings.sh`](#toolswarnings_countcheck_new_warningssh)
- [`tools/warnings_count/update_current_warnings.sh`](#toolswarnings_countupdate_current_warningssh)
- [`fixle.sh`](#fixlesh)
- [`format.sh`](#formatsh)
- [`format.py`](#formatpy)
- [External tools](#external-tools)
- [mips_to_c](#mips_to_c)
- [Permuter](#permuter)
@@ -196,9 +196,31 @@ If you have to add new warnings, **and have permission from the leads**, run thi
Fixes line endings in the repo to Linux style (LF), which is required for the build process to work. (You may be better off creating a new clone directly in Linux/WSL, though)
### `format.sh`
### `format.py`
Formats all C files in the repo using `clang-format-11` (instructions on how to install this version are pinned in Discord if you can't get it from your package manager in the usual way). This will touch all files in the repo, so the next `make` will take longer.
Formats all C files in the repo using `clang-format-11`, `clang-tidy`, and `clang-apply-replacements` (when multiprocessing). This will touch all files in the repo, so the next `make` will take longer.
You can specify how many threads you would like this to run with by adding the `-jN` flag. Where N is the number of threads. By default this will run using 1 thread (i.e. `-j1`).
`clang-11` is available in many native package managers, but if not try:
Linux:
Download llvm's setup script, run it, than install normally
```bash
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 11
rm llvm.sh
sudo apt install clang-format-11 clang-tidy-11 clang-apply-replacements-11
```
Mac:
Install with brew, than create symlinks for `clang-tidy` and `clang-apply-replacements` to use properly
```bash
brew install llvm clang-format-11
ln -s "$(brew --prefix llvm)/bin/clang-tidy" "/usr/local/bin/clang-tidy"
ln -s "$(brew --prefix llvm)/bin/clang-apply-replacements" "/usr/local/bin/clang-apply-replacements"
```
## External tools
+1 -1
View File
@@ -401,7 +401,7 @@ There remains one thing we need to fix before trying to compile it, namely `*(&g
```C
/* 0x0EF8 */ u8 weekEventReg[100]; // "week_event_reg"
/* 0x0F5C */ u32 mapsVisited; // "area_arrival"
/* 0x0F5C */ u32 regionsVisited; // "area_arrival"
```
so it's somewhere in `weekEventReg`. `0xF37 - 0xEF8 = 0x3F = 63`, and it's a byte array, so the access is actually `gSaveContext.save.weekEventReg[63] & 0x80`. Now it will compile. We also don't use `!= 0` for flag comparisons: just `if (gSaveContext.save.weekEventReg[63] & 0x80)` will do.
Executable
+176
View File
@@ -0,0 +1,176 @@
#!/usr/bin/env python3
import argparse
import glob
import multiprocessing
import os
import re
import shutil
import subprocess
import sys
import tempfile
from functools import partial
from typing import List
# clang-format, clang-tidy and clang-apply-replacements default version
# Version 11 is used when available for more consistency between contributors
CLANG_VER = 11
# Clang-Format options (see .clang-format for rules applied)
FORMAT_OPTS = "-i -style=file"
# Clang-Tidy options (see .clang-tidy for checks enabled)
TIDY_OPTS = "-p ."
TIDY_FIX_OPTS = "--fix --fix-errors"
# Clang-Apply-Replacements options (used for multiprocessing)
APPLY_OPTS = ""
# Compiler options used with Clang-Tidy
# Normal warnings are disabled with -Wno-everything to focus only on tidying
INCLUDES = "-Iinclude -Isrc -Ibuild -I."
DEFINES = "-D_LANGUAGE_C -DNON_MATCHING"
COMPILER_OPTS = f"-fno-builtin -std=gnu90 -m32 -Wno-everything {INCLUDES} {DEFINES}"
def get_clang_executable(allowed_executables: List[str]):
for executable in allowed_executables:
try:
subprocess.check_call([executable, "--version"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
return executable
except FileNotFoundError or subprocess.CalledProcessError:
pass
return None
def get_tidy_version(tidy_executable: str):
tidy_version_run = subprocess.run([tidy_executable, "--version"], stdout=subprocess.PIPE, universal_newlines=True)
match = re.search(r"LLVM version ([0-9]+)", tidy_version_run.stdout)
return int(match.group(1))
CLANG_FORMAT = get_clang_executable([f"clang-format-{CLANG_VER}"])
if CLANG_FORMAT is None:
sys.exit(f"Error: clang-format-{CLANG_VER} found")
CLANG_TIDY = get_clang_executable([f"clang-tidy-{CLANG_VER}", "clang-tidy"])
if CLANG_TIDY is None:
sys.exit(f"Error: neither clang-tidy-{CLANG_VER} nor clang-tidy found")
CLANG_APPLY_REPLACEMENTS = get_clang_executable([f"clang-apply-replacements-{CLANG_VER}", "clang-apply-replacements"])
# Try to detect the clang-tidy version and add --fix-notes for version 13+
# This is used to ensure all fixes are applied properly in recent versions
if get_tidy_version(CLANG_TIDY) >= 13:
TIDY_FIX_OPTS += " --fix-notes"
def list_chunks(list: List, chunk_length: int):
for i in range(0, len(list), chunk_length):
yield list[i : i + chunk_length]
def run_clang_format(files: List[str]):
exec_str = f"{CLANG_FORMAT} {FORMAT_OPTS} {' '.join(files)}"
subprocess.run(exec_str, shell=True)
def run_clang_tidy(files: List[str]):
exec_str = f"{CLANG_TIDY} {TIDY_OPTS} {TIDY_FIX_OPTS} {' '.join(files)} -- {COMPILER_OPTS}"
subprocess.run(exec_str, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
def run_clang_tidy_with_export(tmp_dir: str, files: List[str]):
(handle, tmp_file) = tempfile.mkstemp(suffix=".yaml", dir=tmp_dir)
os.close(handle)
exec_str = f"{CLANG_TIDY} {TIDY_OPTS} --export-fixes={tmp_file} {' '.join(files)} -- {COMPILER_OPTS}"
subprocess.run(exec_str, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
def run_clang_apply_replacements(tmp_dir: str):
exec_str = f"{CLANG_APPLY_REPLACEMENTS} {APPLY_OPTS} {tmp_dir}"
subprocess.run(exec_str, shell=True)
def add_final_new_line(file: str):
# https://backreference.org/2010/05/23/sanitizing-files-with-no-trailing-newline/index.html
# "gets the last character of the file pipes it into read, which will exit with a nonzero exit
# code if it encounters EOF before newline (so, if the last character of the file isn't a newline).
# If read exits nonzero, then append a newline onto the file using echo (if read exits 0,
# that satisfies the ||, so the echo command isn't run)." (https://stackoverflow.com/a/34865616)
exec_str = f"tail -c1 {file} | read -r _ || echo >> {file}"
subprocess.run(exec_str, shell=True)
def format_files(src_files: List[str], extra_files: List[str], nb_jobs: int):
if nb_jobs != 1:
print(f"Formatting files with {nb_jobs} jobs")
else:
print(f"Formatting files with a single job (consider using -j to make this faster)")
# Format files in chunks to improve performance while still utilizing jobs
file_chunks = list(list_chunks(src_files, (len(src_files) // nb_jobs) + 1))
print("Running clang-format...")
# clang-format only applies changes in the given files, so it's safe to run in parallel
with multiprocessing.get_context("fork").Pool(nb_jobs) as pool:
pool.map(run_clang_format, file_chunks)
print("Running clang-tidy...")
if nb_jobs > 1:
# clang-tidy may apply changes in #included files, so when running it in parallel we use --export-fixes
# then we call clang-apply-replacements to apply all suggested fixes at the end
tmp_dir = tempfile.mkdtemp()
try:
with multiprocessing.get_context("fork").Pool(nb_jobs) as pool:
pool.map(partial(run_clang_tidy_with_export, tmp_dir), file_chunks)
run_clang_apply_replacements(tmp_dir)
finally:
shutil.rmtree(tmp_dir)
else:
run_clang_tidy(src_files)
print("Adding missing final new lines...")
# Adding final new lines is safe to do in parallel and can be applied to all types of files
with multiprocessing.get_context("fork").Pool(nb_jobs) as pool:
pool.map(add_final_new_line, src_files + extra_files)
print("Done formatting files.")
def main():
parser = argparse.ArgumentParser(description="Format files in the codebase to enforce most style rules")
parser.add_argument("files", metavar="file", nargs="*")
parser.add_argument(
"-j",
dest="jobs",
type=int,
nargs="?",
default=1,
help="number of jobs to run (default: 1 without -j, number of cpus with -j)",
)
args = parser.parse_args()
nb_jobs = args.jobs or multiprocessing.cpu_count()
if nb_jobs > 1:
if CLANG_APPLY_REPLACEMENTS is None:
sys.exit(
f"Error: neither clang-apply-replacements-{CLANG_VER} nor clang-apply-replacements found (required to use -j)"
)
if args.files:
files = args.files
extra_files = []
else:
files = glob.glob("src/**/*.c", recursive=True)
extra_files = glob.glob("assets/**/*.xml", recursive=True)
format_files(files, extra_files, nb_jobs)
if __name__ == "__main__":
main()
-46
View File
@@ -1,46 +0,0 @@
#!/usr/bin/env bash
FORMAT_VER="11"
FORMAT_OPTS="-i -style=file"
TIDY_OPTS="-p . --fix --fix-errors"
COMPILER_OPTS="-fno-builtin -std=gnu90 -Iinclude -Isrc -D_LANGUAGE_C -DNON_MATCHING"
# https://backreference.org/2010/05/23/sanitizing-files-with-no-trailing-newline/index.html
# "gets the last character of the file pipes it into read, which will exit with a nonzero exit code if it encounters EOF before newline (so, if the last character of the file isn't a newline). If read exits nonzero, then append a newline onto the file using echo (if read exits 0, that satisfies the ||, so the echo command isn't run)." (https://stackoverflow.com/a/34865616)
function add_final_newline () {
for file in "$@"
do
tail -c1 $file | read -r _ || echo >> $file
done
}
export -f add_final_newline
shopt -s globstar
if [ -z `command -v clang-format-${FORMAT_VER}` ]
then
echo "clang-format-${FORMAT_VER} not found. Exiting."
exit 1
fi
if (( $# > 0 )); then
echo "Formatting file(s) $*"
echo "Running clang-format..."
clang-format-${FORMAT_VER} ${FORMAT_OPTS} "$@"
echo "Running clang-tidy..."
clang-tidy ${TIDY_OPTS} "$@" -- ${COMPILER_OPTS} &> /dev/null
echo "Adding missing final new lines..."
add_final_newline "$@"
echo "Done formatting file(s) $*"
exit
fi
echo "Formatting C files. This will take a bit"
echo "Running clang-format..."
clang-format-${FORMAT_VER} ${FORMAT_OPTS} src/**/*.c
echo "Running clang-tidy..."
clang-tidy ${TIDY_OPTS} src/**/*.c -- ${COMPILER_OPTS} &> /dev/null
echo "Adding missing final new lines..."
find src/ -type f -name "*.c" -exec bash -c 'add_final_newline "$@"' bash {} +
find assets/xml/ -type f -name "*.xml" -exec bash -c 'add_final_newline "$@"' bash {} +
echo "Done formatting all files."
+2 -2
View File
@@ -3572,7 +3572,7 @@ _DW({ \
#define gDPLoadTextureBlock(pkt, timg, fmt, siz, width, height, \
pal, cms, cmt, masks, maskt, shifts, shiftt) \
{ \
_DW({ \
gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \
gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, 0, G_TX_LOADTILE, \
0 , cmt, maskt, shiftt, cms, masks, shifts); \
@@ -3588,7 +3588,7 @@ _DW({ \
gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, \
((width)-1) << G_TEXTURE_IMAGE_FRAC, \
((height)-1) << G_TEXTURE_IMAGE_FRAC); \
}
})
#define gDPLoadTextureBlockYuv(pkt, timg, fmt, siz, width, height, \
pal, cms, cmt, masks, maskt, shifts, shiftt) \
+179 -179
View File
File diff suppressed because it is too large Load Diff
+14 -14
View File
@@ -29,21 +29,21 @@ typedef struct GfxPrint {
/* 0x14 */ UNK_TYPE1 unk_14[0x1C]; // unused
} GfxPrint; // size = 0x30
void GfxPrint_Setup(GfxPrint* printer);
void GfxPrint_SetColor(GfxPrint* printer, u32 r, u32 g, u32 b, u32 a);
void GfxPrint_SetPosPx(GfxPrint* printer, s32 x, s32 y);
void GfxPrint_SetPos(GfxPrint* printer, s32 x, s32 y);
void GfxPrint_SetBasePosPx(GfxPrint* printer, s32 x, s32 y);
void GfxPrint_PrintCharImpl(GfxPrint* printer, u8 c);
void GfxPrint_PrintChar(GfxPrint* printer, u8 c);
void GfxPrint_PrintStringWithSize(GfxPrint* printer, const void* buffer, size_t charSize, size_t charCount);
void GfxPrint_PrintString(GfxPrint* printer, const char* str);
void GfxPrint_Setup(GfxPrint* this);
void GfxPrint_SetColor(GfxPrint* this, u32 r, u32 g, u32 b, u32 a);
void GfxPrint_SetPosPx(GfxPrint* this, s32 x, s32 y);
void GfxPrint_SetPos(GfxPrint* this, s32 x, s32 y);
void GfxPrint_SetBasePosPx(GfxPrint* this, s32 x, s32 y);
void GfxPrint_PrintCharImpl(GfxPrint* this, u8 c);
void GfxPrint_PrintChar(GfxPrint* this, u8 c);
void GfxPrint_PrintStringWithSize(GfxPrint* this, const void* buffer, size_t charSize, size_t charCount);
void GfxPrint_PrintString(GfxPrint* this, const char* str);
void* GfxPrint_Callback(void* arg, const char* str, size_t size);
void GfxPrint_Init(GfxPrint* printer);
void GfxPrint_Init(GfxPrint* this);
void GfxPrint_Destroy(GfxPrint* printer);
void GfxPrint_Open(GfxPrint* printer, Gfx* dList);
Gfx* GfxPrint_Close(GfxPrint* printer);
s32 GfxPrint_VPrintf(GfxPrint* printer, const char* fmt, va_list args);
s32 GfxPrint_Printf(GfxPrint* printer, const char* fmt, ...);
void GfxPrint_Open(GfxPrint* this, Gfx* dList);
Gfx* GfxPrint_Close(GfxPrint* this);
s32 GfxPrint_VPrintf(GfxPrint* this, const char* fmt, va_list args);
s32 GfxPrint_Printf(GfxPrint* this, const char* fmt, ...);
#endif
+8
View File
@@ -610,4 +610,12 @@ extern ActorInit Oceff_Wipe7_InitVars;
extern ActorInit Shot_Sun_InitVars;
extern ActorInit TG_Sw_InitVars;
extern TransitionInit TransitionFade_InitVars;
extern TransitionInit TransitionTriforce_InitVars;
extern TransitionInit TransitionWipe1_InitVars;
extern TransitionInit TransitionWipe3_InitVars;
extern TransitionInit TransitionWipe4_InitVars;
extern TransitionInit TransitionCircle_InitVars;
extern TransitionInit TransitionWipe5_InitVars;
#endif
+5 -5
View File
@@ -47,7 +47,7 @@ typedef struct {
/* 0x04 */ u16 transferMode;
/* 0x06 */ u16 blockNum;
/* 0x08 */ s32 sectorNum;
/* 0x0C */ u32 devAddr;
/* 0x0C */ uintptr_t devAddr;
/* 0x10 */ u32 bmCtlShadow;
/* 0x14 */ u32 seqCtlShadow;
/* 0x18 */ __OSBlockInfo block[2];
@@ -62,7 +62,7 @@ typedef struct OSPiHandle {
/* 0x07 */ u8 relDuration;
/* 0x08 */ u8 pulse;
/* 0x09 */ u8 domain;
/* 0x0C */ u32 baseAddress;
/* 0x0C */ uintptr_t baseAddress;
/* 0x10 */ u32 speed;
/* 0x14 */ __OSTranxInfo transferInfo;
} OSPiHandle; // size = 0x74
@@ -70,7 +70,7 @@ typedef struct OSPiHandle {
typedef struct {
/* 0x0 */ u8 type;
/* 0x4 */ u32 address;
/* 0x4 */ uintptr_t address;
} OSPiInfo; // size = 0x8
@@ -97,8 +97,8 @@ typedef struct {
/* 0x08 */ OSMesgQueue* cmdQueue;
/* 0x0C */ OSMesgQueue* evtQueue;
/* 0x10 */ OSMesgQueue* acsQueue;
/* 0x14 */ s32 (*piDmaCallback)(s32, u32, void*, size_t);
/* 0x18 */ s32 (*epiDmaCallback)(OSPiHandle*, s32, u32, void*, size_t);
/* 0x14 */ s32 (*piDmaCallback)(s32, uintptr_t, void*, size_t);
/* 0x18 */ s32 (*epiDmaCallback)(OSPiHandle*, s32, uintptr_t, void*, size_t);
} OSDevMgr; // size = 0x1C
typedef u64 OSTime;
+2 -2
View File
@@ -12,8 +12,8 @@ typedef struct {
/* 0x08 */ OSMesgQueue* cmdQueue;
/* 0x0C */ OSMesgQueue* eventQueue;
/* 0x10 */ OSMesgQueue* accessQueue;
/* 0x14 */ s32 (*piDmaCallback)(s32, u32, void*, size_t);
/* 0x18 */ s32 (*epiDmaCallback)(OSPiHandle*, s32, u32, void*, size_t);
/* 0x14 */ s32 (*piDmaCallback)(s32, uintptr_t, void*, size_t);
/* 0x18 */ s32 (*epiDmaCallback)(OSPiHandle*, s32, uintptr_t, void*, size_t);
} OSMgrArgs; // size = 0x1C
#endif
+1 -1
View File
@@ -29,7 +29,7 @@ void* __osMalloc(Arena* arena, size_t size);
void* __osMallocR(Arena* arena, size_t size);
void __osFree(Arena* arena, void* ptr);
void* __osRealloc(Arena* arena, void* ptr, size_t newSize);
void __osGetSizes(Arena* arena, size_t* maxFreeBlock, size_t* bytesFree, size_t* bytesAllocated);
void __osGetSizes(Arena* arena, size_t* outMaxFree, size_t* outFree, size_t* outAlloc);
s32 __osCheckArena(Arena* arena);
#endif
+8 -2
View File
@@ -48,8 +48,9 @@
#define R_ENABLE_ARENA_DBG SREG(0) // Same as OoT
#define R_UPDATE_RATE SREG(30)
#define R_PAUSE_MENU_MODE SREG(94)
#define R_C_UP_ICON_X YREG(88)
#define R_C_UP_ICON_Y YREG(89)
#define R_PAUSE_WORLD_MAP_YAW YREG(24)
#define R_PAUSE_WORLD_MAP_Y_OFFSET YREG(25)
#define R_PAUSE_WORLD_MAP_DEPTH YREG(26)
#define R_MAGIC_FILL_COLOR(i) ZREG(0 + i)
#define R_C_BTN_COLOR(i) ZREG(39 + i)
#define R_B_BTN_COLOR(i) ZREG(43 + i)
@@ -74,9 +75,14 @@
#define R_A_BTN_COLOR(i) XREG(22 + i)
#define R_A_BTN_Y_OFFSET XREG(31)
#define R_MAGIC_CONSUME_TIMER_GIANTS_MASK XREG(41)
#define R_PAUSE_DBG_MAP_CLOUD_ON XREG(50)
#define R_PAUSE_DBG_MAP_CLOUD_X XREG(52)
#define R_PAUSE_DBG_MAP_CLOUD_Y XREG(53)
#define R_MOON_CRASH_TIMER_Y XREG(80)
#define R_MOON_CRASH_TIMER_X XREG(81)
#define R_PAUSE_OWLWARP_ALPHA XREG(87)
#define R_STORY_FILL_SCREEN_ALPHA XREG(91)
#define R_REVERSE_FLOOR_INDEX XREG(94)
#define R_MINIMAP_DISABLED XREG(95)
#define R_B_LABEL_DD WREG(0)
#define R_OW_MINIMAP_X WREG(29)
+1 -1
View File
@@ -29,7 +29,7 @@ MtxF* Matrix_GetCurrent(void);
/* Basic operations */
void Matrix_Mult(MtxF* matrix, MatrixMode mode);
void Matrix_Mult(MtxF* mf, MatrixMode mode);
void Matrix_Translate(f32 x, f32 y, f32 z, MatrixMode mode);
void Matrix_Scale(f32 x, f32 y, f32 z, MatrixMode mode);
void Matrix_RotateXS(s16 x, MatrixMode mode);

Some files were not shown because too many files have changed in this diff Show More