From fc410da89121cdf61c7471f760afbab2abfda1d8 Mon Sep 17 00:00:00 2001 From: Mateusz Faderewski Date: Fri, 26 Apr 2024 23:04:19 +0200 Subject: [PATCH] clang-format WIP --- .clang-format | 20 ++++++++++++++++++++ Makefile | 7 +++++++ src/menu/cart_load.c | 7 +++---- src/menu/rom_info.c | 3 +++ src/menu/views/browser.c | 5 +++-- 5 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..41c4bdbb --- /dev/null +++ b/.clang-format @@ -0,0 +1,20 @@ +BasedOnStyle: LLVM + +AlignAfterOpenBracket: BlockIndent +AlignEscapedNewlines: DontAlign +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortCaseLabelsOnASingleLine: true +AllowShortEnumsOnASingleLine: false +AllowShortFunctionsOnASingleLine: InlineOnly +AlwaysBreakBeforeMultilineStrings: true +BinPackArguments: false +BinPackParameters: false +BreakBeforeBraces: Attach +ColumnLimit: 120 +IndentWidth: 4 +SpaceBeforeParens: Custom +SpaceBeforeParensOptions: + AfterControlStatements: true + AfterFunctionDeclarationName: true + AfterFunctionDefinitionName: true +UseTab: Never diff --git a/Makefile b/Makefile index fed6ed87..dcebf60c 100644 --- a/Makefile +++ b/Makefile @@ -138,6 +138,13 @@ clean: @rm -rf ./$(BUILD_DIR) ./$(OUTPUT_DIR) .PHONY: clean +format: + @find ./$(SOURCE_DIR) \ + -path \./$(SOURCE_DIR)/libs -prune \ + -o -iname *.c -print \ + -o -iname *.h -print \ + | xargs clang-format -i + run: $(OUTPUT_DIR)/$(PROJECT_NAME).n64 ifeq ($(OS),Windows_NT) ./localdeploy.bat diff --git a/src/menu/cart_load.c b/src/menu/cart_load.c index 13ef7aca..f7b341ab 100644 --- a/src/menu/cart_load.c +++ b/src/menu/cart_load.c @@ -19,10 +19,9 @@ static bool is_64dd_connected (void) { - return ( - ((io_read(0x05000540) & 0x0000FFFF) == 0x0000) || - (io_read(0x06001010) == 0x2129FFF8) - ); + bool is_64dd_io_present = ((io_read(0x05000540) & 0x0000FFFF) == 0x0000); + bool is_64dd_ipl_present = (io_read(0x06001010) == 0x2129FFF8); + return (is_64dd_io_present || is_64dd_ipl_present); } static bool create_saves_subdirectory (path_t *path) { diff --git a/src/menu/rom_info.c b/src/menu/rom_info.c index b9711701..4713eee7 100644 --- a/src/menu/rom_info.c +++ b/src/menu/rom_info.c @@ -141,6 +141,8 @@ typedef struct { // List shamelessly stolen from https://github.com/ares-emulator/ares/blob/master/mia/medium/nintendo-64.cpp + +// clang-format off static const match_t database[] = { MATCH_HOMEBREW_HEADER("ED"), // Homebrew header (ED) @@ -576,6 +578,7 @@ static const match_t database[] = { MATCH_END, }; +// clang-format on static void fix_rom_header_endianness (rom_header_t *rom_header, rom_info_t *rom_info) { diff --git a/src/menu/views/browser.c b/src/menu/views/browser.c index 8cca0201..b5c46e0d 100644 --- a/src/menu/views/browser.c +++ b/src/menu/views/browser.c @@ -11,7 +11,8 @@ static const char *rom_extensions[] = { "z64", "n64", "v64", "rom", NULL }; static const char *disk_extensions[] = { "ndd", NULL }; static const char *emulator_extensions[] = { "nes", "sfc", "smc", "gb", "gbc", "sms", "gg", "sg", NULL }; -static const char *save_extensions[] = { "sav", NULL }; // TODO: "eep", "sra", "srm", "fla" could be used if transfered from different flashcarts. +// TODO: "eep", "sra", "srm", "fla" could be used if transfered from different flashcarts. +static const char *save_extensions[] = { "sav", NULL }; static const char *image_extensions[] = { "png", NULL }; static const char *text_extensions[] = { "txt", "ini", "yml", "yaml", NULL }; static const char *music_extensions[] = { "mp3", NULL }; @@ -24,7 +25,7 @@ static const char *hidden_paths[] = { "/OS64P.v64", "/sc64menu.n64", "/System Volume Information", - NULL + NULL, };