From c4a92571b291852fddaf5739c30698756c383a1b Mon Sep 17 00:00:00 2001 From: Tyler Wilding Date: Tue, 12 Apr 2022 18:48:27 -0400 Subject: [PATCH] Improve `ASSERT` macro, fix linux file paths in `Taskfile` and hopefully fix the windows release (#1295) * ci: fix windows releases (hopefully) * scripts: fix Taskfile file references for linux * asserts: add `ASSERT_MSG` macro and ensure `stdout` is flushed before `abort`ing * asserts: refactor all `assert(false);` with a preceeding message instances * lint: format * temp... * fix compiler errors * assert: allow for string literals in `ASSERT_MSG` * lint: formatting * revert temp change for testing --- .github/workflows/linter-workflow.yaml | 4 ++- .github/workflows/windows-workflow.yaml | 2 +- Taskfile.yml | 8 ++--- common/audio/audio_formats.cpp | 3 +- common/custom_data/TFrag3Data.cpp | 11 ++++--- common/dma/dma.cpp | 4 +-- common/dma/dma.h | 4 +-- common/util/Assert.cpp | 29 ++++++++++++++++-- common/util/Assert.h | 14 ++++++++- common/util/FileUtil.cpp | 3 +- common/util/compress.cpp | 7 ++--- decompiler/Disasm/InstructionParser.cpp | 10 +++---- decompiler/Disasm/Register.cpp | 6 ++-- decompiler/Function/CfgVtx.cpp | 3 +- decompiler/IR2/Form.cpp | 8 ++--- decompiler/ObjectFile/LinkedObjectFile.cpp | 10 +++---- .../ObjectFile/LinkedObjectFileCreation.cpp | 3 +- decompiler/VuDisasm/VuDisassembler.cpp | 15 ++++------ decompiler/analysis/type_analysis.cpp | 3 +- .../config/jak1_ntsc_black_label/hacks.jsonc | 2 +- .../jak1_ntsc_black_label/label_types.jsonc | 4 +-- .../jak1_ntsc_black_label/type_casts.jsonc | 30 ++++++------------- decompiler/data/LinkedWordReader.h | 3 +- decompiler/data/game_text.cpp | 3 +- decompiler/data/tpage.cpp | 3 +- decompiler/level_extractor/BspHeader.cpp | 5 ++-- decompiler/level_extractor/extract_level.cpp | 5 ++-- decompiler/level_extractor/extract_shrub.cpp | 18 +++++------ decompiler/level_extractor/extract_tfrag.cpp | 29 ++++++++---------- decompiler/level_extractor/extract_tie.cpp | 21 ++++++------- .../opengl_renderer/DirectRenderer.cpp | 15 ++++------ .../opengl_renderer/DirectRenderer2.cpp | 8 ++--- .../opengl_renderer/GenericProgram.cpp | 5 ++-- .../opengl_renderer/GenericRenderer.cpp | 23 ++++++-------- game/graphics/opengl_renderer/MercProgram.cpp | 3 +- .../graphics/opengl_renderer/MercRenderer.cpp | 3 +- .../opengl_renderer/ShadowRenderer.cpp | 9 +++--- game/graphics/opengl_renderer/Shadow_PS2.cpp | 9 ++---- game/graphics/opengl_renderer/Sprite3.cpp | 3 +- .../opengl_renderer/SpriteRenderer.cpp | 3 +- .../foreground/Generic2_DMA.cpp | 5 ++-- .../foreground/Generic2_OpenGL.cpp | 5 ++-- .../opengl_renderer/ocean/OceanMid.cpp | 8 ++--- .../opengl_renderer/ocean/OceanNear.cpp | 5 ++-- game/kernel/klink.cpp | 10 +++---- game/kernel/kscheme.cpp | 3 +- game/mips2c/functions/generic_merc.cpp | 6 ++-- game/overlord/srpc.cpp | 7 ++--- goalc/debugger/Debugger.cpp | 4 +-- goalc/emitter/CodeTester.cpp | 4 +-- goalc/regalloc/Allocator.cpp | 5 ++-- 51 files changed, 187 insertions(+), 226 deletions(-) diff --git a/.github/workflows/linter-workflow.yaml b/.github/workflows/linter-workflow.yaml index 5f02880af..77e7bd74f 100644 --- a/.github/workflows/linter-workflow.yaml +++ b/.github/workflows/linter-workflow.yaml @@ -21,7 +21,9 @@ jobs: uses: actions/checkout@v2 - name: Get Package Dependencies - run: sudo apt install clang-format clang-tidy + run: | + sudo apt install clang-format clang-tidy + clang-format -version - name: Check Clang-Formatting run: | diff --git a/.github/workflows/windows-workflow.yaml b/.github/workflows/windows-workflow.yaml index 3f4d5ec07..b155db1cf 100644 --- a/.github/workflows/windows-workflow.yaml +++ b/.github/workflows/windows-workflow.yaml @@ -85,7 +85,7 @@ jobs: run: | mkdir -p ./ci-artifacts/out ./.github/scripts/releases/extract_build_windows.sh ./ci-artifacts/out ./ - 7z a -tzip ./ci-artifacts/windows.zip ./ci-artfacts/out + 7z a -tzip ./ci-artifacts/windows.zip ./ci-artifacts/out - name: Upload Assets and Potential Publish Release if: github.repository == 'open-goal/jak-project' && startsWith(github.ref, 'refs/tags/') && matrix.compiler == 'clang' diff --git a/Taskfile.yml b/Taskfile.yml index 22e82f5a9..2c4244c2e 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -13,19 +13,19 @@ tasks: - '{{.DECOMP_BIN_RELEASE_DIR}}/decompiler "./decompiler/config/jak1_ntsc_black_label.jsonc" "./iso_data" "./decompiler_out" "decompile_code=false"' boot-game: preconditions: - - sh: test -f {{.DECOMP_BIN_RELEASE_DIR}}/gk{{.EXE_FILE_EXTENSION}} + - sh: test -f {{.GK_BIN_RELEASE_DIR}}/gk{{.EXE_FILE_EXTENSION}} msg: "Couldn't locate runtime executable -- Have you compiled in release mode?" cmds: - "{{.GK_BIN_RELEASE_DIR}}/gk -boot -fakeiso -debug -v" run-game: preconditions: - - sh: test -f {{.DECOMP_BIN_RELEASE_DIR}}/gk{{.EXE_FILE_EXTENSION}} + - sh: test -f {{.GK_BIN_RELEASE_DIR}}/gk{{.EXE_FILE_EXTENSION}} msg: "Couldn't locate runtime executable -- Have you compiled in release mode?" cmds: - "{{.GK_BIN_RELEASE_DIR}}/gk -fakeiso -debug -v" run-game-quiet: preconditions: - - sh: test -f {{.DECOMP_BIN_RELEASE_DIR}}/gk{{.EXE_FILE_EXTENSION}} + - sh: test -f {{.GK_BIN_RELEASE_DIR}}/gk{{.EXE_FILE_EXTENSION}} msg: "Couldn't locate runtime executable -- Have you compiled in release mode?" cmds: - "{{.GK_BIN_RELEASE_DIR}}/gk -fakeiso" @@ -33,7 +33,7 @@ tasks: env: OPENGOAL_DECOMP_DIR: "jak1/" preconditions: - - sh: test -f {{.DECOMP_BIN_RELEASE_DIR}}/goalc{{.EXE_FILE_EXTENSION}} + - sh: test -f {{.GOALC_BIN_RELEASE_DIR}}/goalc{{.EXE_FILE_EXTENSION}} msg: "Couldn't locate compiler executable -- Have you compiled in release mode?" cmds: - "{{.GOALC_BIN_RELEASE_DIR}}/goalc" diff --git a/common/audio/audio_formats.cpp b/common/audio/audio_formats.cpp index db2a10410..33abd67a2 100644 --- a/common/audio/audio_formats.cpp +++ b/common/audio/audio_formats.cpp @@ -289,8 +289,7 @@ void test_encode_adpcm(const std::vector& samples, for (int i = 0; i < 5; i++) { fmt::print(" [{}] {} {}\n", i, filter_errors[i], filter_shifts[i]); } - fmt::print("prev: {} {}\n", prev_block_samples[0], prev_block_samples[1]); - ASSERT(false); + ASSERT_MSG(false, fmt::format("prev: {} {}", prev_block_samples[0], prev_block_samples[1])); } prev_block_samples[0] = samples.at(block_idx * 28 + 27); diff --git a/common/custom_data/TFrag3Data.cpp b/common/custom_data/TFrag3Data.cpp index 8774a93e5..cd46ba29e 100644 --- a/common/custom_data/TFrag3Data.cpp +++ b/common/custom_data/TFrag3Data.cpp @@ -236,9 +236,8 @@ void Texture::serialize(Serializer& ser) { void Level::serialize(Serializer& ser) { ser.from_ptr(&version); if (ser.is_loading() && version != TFRAG3_VERSION) { - fmt::print("version mismatch when loading tfrag3 data. Got {}, expected {}\n", version, - TFRAG3_VERSION); - ASSERT(false); + ASSERT_MSG(false, fmt::format("version mismatch when loading tfrag3 data. Got {}, expected {}", + version, TFRAG3_VERSION)); } ser.from_str(&level_name); @@ -285,9 +284,9 @@ void Level::serialize(Serializer& ser) { ser.from_ptr(&version2); if (ser.is_loading() && version2 != TFRAG3_VERSION) { - fmt::print("version mismatch when loading tfrag3 data (at end). Got {}, expected {}\n", - version2, TFRAG3_VERSION); - ASSERT(false); + ASSERT_MSG(false, fmt::format( + "version mismatch when loading tfrag3 data (at end). Got {}, expected {}", + version2, TFRAG3_VERSION)); } } diff --git a/common/dma/dma.cpp b/common/dma/dma.cpp index 4e8ed3f62..e05a2cdd7 100644 --- a/common/dma/dma.cpp +++ b/common/dma/dma.cpp @@ -115,10 +115,8 @@ std::string VifCode::print() { } default: - fmt::print("Unhandled vif code {}\n", (int)kind); - result = "???"; - ASSERT(false); + ASSERT_MSG(false, fmt::format("Unhandled vif code {}", (int)kind)); break; } // TODO: the rest of the VIF code. diff --git a/common/dma/dma.h b/common/dma/dma.h index 984b890e1..46a4823e1 100644 --- a/common/dma/dma.h +++ b/common/dma/dma.h @@ -9,6 +9,7 @@ #include #include "common/common_types.h" #include "common/util/Assert.h" +#include "third-party/fmt/core.h" struct DmaStats { double sync_time_ms = 0; @@ -91,8 +92,7 @@ inline void emulate_dma(const void* source_base, void* dest_base, u32 tadr, u32 // does this transfer anything in TTE??? return; default: - printf("bad tag: %d\n", (int)tag.kind); - ASSERT(false); + ASSERT_MSG(false, fmt::format("bad tag: {}", (int)tag.kind)); } } } diff --git a/common/util/Assert.cpp b/common/util/Assert.cpp index 3d923e9be..1f8d63020 100644 --- a/common/util/Assert.cpp +++ b/common/util/Assert.cpp @@ -2,8 +2,33 @@ #include #include "Assert.h" +#include -void private_assert_failed(const char* expr, const char* file, int line, const char* function) { - fprintf(stderr, "%s:%d: Assertion failed: %s\nFunction: %s\n", file, line, expr, function); +void private_assert_failed(const char* expr, + const char* file, + int line, + const char* function, + const char* msg) { + if (!msg || msg[0] == '\0') { + fprintf(stderr, "Assertion failed: '%s'\n\tSource: %s:%d\n\tFunction: %s\n", expr, file, line, + function); + } else { + fprintf(stderr, "Assertion failed: '%s'\n\tMessage: %s\n\tSource: %s:%d\n\tFunction: %s\n", + expr, msg, file, line, function); + } + fflush(stdout); // ensure any stdout logs are flushed before we terminate + fflush(stderr); abort(); } + +void private_assert_failed(const char* expr, + const char* file, + int line, + const char* function, + const std::string_view& msg) { + if (msg.empty()) { + private_assert_failed(expr, file, line, function); + } else { + private_assert_failed(expr, file, line, function, msg.data()); + } +} diff --git a/common/util/Assert.h b/common/util/Assert.h index 40f6750dd..e7b8f9a68 100644 --- a/common/util/Assert.h +++ b/common/util/Assert.h @@ -5,10 +5,19 @@ #pragma once +#include + [[noreturn]] void private_assert_failed(const char* expr, const char* file, int line, - const char* function); + const char* function, + const char* msg = ""); + +[[noreturn]] void private_assert_failed(const char* expr, + const char* file, + int line, + const char* function, + const std::string_view& msg); #ifdef _WIN32 #define __PRETTY_FUNCTION__ __FUNCSIG__ @@ -16,3 +25,6 @@ #define ASSERT(EX) \ (void)((EX) || (private_assert_failed(#EX, __FILE__, __LINE__, __PRETTY_FUNCTION__), 0)) + +#define ASSERT_MSG(EXPR, STR) \ + (void)((EXPR) || (private_assert_failed(#EXPR, __FILE__, __LINE__, __PRETTY_FUNCTION__, STR), 0)) diff --git a/common/util/FileUtil.cpp b/common/util/FileUtil.cpp index ece3fc595..1de428a36 100644 --- a/common/util/FileUtil.cpp +++ b/common/util/FileUtil.cpp @@ -425,8 +425,7 @@ void MakeISOName(char* dst, const char* src) { void assert_file_exists(const char* path, const char* error_message) { if (!std::filesystem::exists(path)) { - fprintf(stderr, "File %s was not found: %s\n", path, error_message); - ASSERT(false); + ASSERT_MSG(false, fmt::format("File {} was not found: {}", path, error_message)); } } diff --git a/common/util/compress.cpp b/common/util/compress.cpp index a31a19f47..fb931db3c 100644 --- a/common/util/compress.cpp +++ b/common/util/compress.cpp @@ -4,6 +4,7 @@ #include "compress.h" #include "third-party/zstd/lib/zstd.h" #include "common/util/Assert.h" +#include "third-party/fmt/core.h" namespace compression { @@ -17,8 +18,7 @@ std::vector compress_zstd(const void* data, size_t size) { auto compressed_size = ZSTD_compress(result.data() + sizeof(size_t), max_compressed, data, size, 1); if (ZSTD_isError(compressed_size)) { - printf("ZSTD error: %s\n", ZSTD_getErrorName(compressed_size)); - ASSERT(false); + ASSERT_MSG(false, fmt::format("ZSTD error: {}", ZSTD_getErrorName(compressed_size))); } result.resize(sizeof(size_t) + compressed_size); return result; @@ -38,8 +38,7 @@ std::vector decompress_zstd(const void* data, size_t size) { auto decomp_size = ZSTD_decompress(result.data(), decompressed_size, (const u8*)data + sizeof(size_t), compressed_size); if (ZSTD_isError(decomp_size)) { - printf("ZSTD error: %s\n", ZSTD_getErrorName(compressed_size)); - ASSERT(false); + ASSERT_MSG(false, fmt::format("ZSTD error: {}", ZSTD_getErrorName(compressed_size))); } ASSERT(decomp_size == decompressed_size); diff --git a/decompiler/Disasm/InstructionParser.cpp b/decompiler/Disasm/InstructionParser.cpp index 91d555663..1c62bbd70 100644 --- a/decompiler/Disasm/InstructionParser.cpp +++ b/decompiler/Disasm/InstructionParser.cpp @@ -4,6 +4,7 @@ #include "common/common_types.h" #include "InstructionParser.h" #include "common/util/Assert.h" +#include "third-party/fmt/core.h" namespace decompiler { InstructionParser::InstructionParser() { @@ -383,8 +384,7 @@ Instruction InstructionParser::parse_single_instruction( } else if (thing == "ni") { instr.il = 0; } else { - printf("Bad interlock specification. Got %s\n", thing.c_str()); - ASSERT(false); + ASSERT_MSG(false, fmt::format("Bad interlock specification. Got {}", thing.c_str())); } } break; @@ -399,14 +399,12 @@ Instruction InstructionParser::parse_single_instruction( } else if (thing == "w") { instr.cop2_bc = 3; } else { - printf("Bad broadcast. Got %s\n", thing.c_str()); - ASSERT(false); + ASSERT_MSG(false, fmt::format("Bad broadcast. Got {}", thing.c_str())); } } break; default: - printf("missing DecodeType: %d\n", (int)step.decode); - ASSERT(false); + ASSERT_MSG(false, fmt::format("missing DecodeType: {}", (int)step.decode)); } } diff --git a/decompiler/Disasm/Register.cpp b/decompiler/Disasm/Register.cpp index ba25b290b..674fd6410 100644 --- a/decompiler/Disasm/Register.cpp +++ b/decompiler/Disasm/Register.cpp @@ -125,14 +125,12 @@ Register::Register(Reg::RegisterKind kind, uint32_t num) { case Reg::COP0: case Reg::VI: if (num > 32) { - fmt::print("RegisterKind: {}, greater than 32: {}\n", kind, num); - ASSERT(false); + ASSERT_MSG(false, fmt::format("RegisterKind: {}, greater than 32: {}", kind, num)); } break; case Reg::SPECIAL: if (num > 4) { - fmt::print("Special RegisterKind: {}, greater than 4: {}\n", kind, num); - ASSERT(false); + ASSERT_MSG(false, fmt::format("Special RegisterKind: {}, greater than 4: {}", kind, num)); } break; default: diff --git a/decompiler/Function/CfgVtx.cpp b/decompiler/Function/CfgVtx.cpp index 37f84f69e..b00961a10 100644 --- a/decompiler/Function/CfgVtx.cpp +++ b/decompiler/Function/CfgVtx.cpp @@ -1307,8 +1307,7 @@ bool ControlFlowGraph::clean_up_asm_branches() { // build new sequence replaced = true; if (!b0->succ_branch) { - fmt::print("asm missing branch in block {}\n", b0->to_string()); - ASSERT(false); + ASSERT_MSG(false, fmt::format("asm missing branch in block {}", b0->to_string())); } m_blocks.at(b0->succ_branch->get_first_block_id())->needs_label = true; diff --git a/decompiler/IR2/Form.cpp b/decompiler/IR2/Form.cpp index f4559f169..9412b4c90 100644 --- a/decompiler/IR2/Form.cpp +++ b/decompiler/IR2/Form.cpp @@ -626,8 +626,8 @@ goos::Object TranslatedAsmBranch::to_form_internal(const Env& env) const { if (m_branch_delay) { if (m_branch_delay->parent_element != this) { - fmt::print("bad ptr. Parent is {}\n", m_branch_delay->parent_element->to_string(env)); - ASSERT(false); + ASSERT_MSG(false, fmt::format("bad ptr. Parent is {}", + m_branch_delay->parent_element->to_string(env))); } ASSERT(m_branch_delay->parent_element->parent_form); @@ -667,8 +667,8 @@ void TranslatedAsmBranch::collect_vars(RegAccessSet& vars, bool recursive) const m_branch_condition->collect_vars(vars, recursive); if (m_branch_delay) { if (m_branch_delay->parent_element != this) { - fmt::print("bad ptr. Parent is {}\n", (void*)m_branch_delay->parent_element); - ASSERT(false); + ASSERT_MSG(false, + fmt::format("bad ptr. Parent is {}", (void*)m_branch_delay->parent_element)); } for (auto& elt : m_branch_delay->elts()) { diff --git a/decompiler/ObjectFile/LinkedObjectFile.cpp b/decompiler/ObjectFile/LinkedObjectFile.cpp index ccd043958..dc805fdf6 100644 --- a/decompiler/ObjectFile/LinkedObjectFile.cpp +++ b/decompiler/ObjectFile/LinkedObjectFile.cpp @@ -530,8 +530,8 @@ void LinkedObjectFile::process_fp_relative_links() { } break; default: - printf("unknown fp using op: %s\n", instr.to_string(labels).c_str()); - ASSERT(false); + ASSERT_MSG(false, + fmt::format("unknown fp using op: {}", instr.to_string(labels).c_str())); } } } @@ -912,16 +912,14 @@ goos::Object LinkedObjectFile::to_form_script_object(int seg, } else { std::string debug; append_word_to_string(debug, word); - printf("don't know how to print %s\n", debug.c_str()); - ASSERT(false); + ASSERT_MSG(false, fmt::format("don't know how to print {}", debug.c_str())); } } break; case 2: // bad, a pair snuck through. default: // pointers should be aligned! - printf("align %d\n", byte_idx & 7); - ASSERT(false); + ASSERT_MSG(false, fmt::format("align {}", byte_idx & 7)); } return result; diff --git a/decompiler/ObjectFile/LinkedObjectFileCreation.cpp b/decompiler/ObjectFile/LinkedObjectFileCreation.cpp index 6f96eb7bb..395b43d95 100644 --- a/decompiler/ObjectFile/LinkedObjectFileCreation.cpp +++ b/decompiler/ObjectFile/LinkedObjectFileCreation.cpp @@ -807,8 +807,7 @@ LinkedObjectFile to_linked_object_file(const std::vector& data, } else if (header->version == 5) { link_v5(result, data, name, dts); } else { - printf("Unsupported version %d\n", header->version); - ASSERT(false); + ASSERT_MSG(false, fmt::format("Unsupported version {}", header->version)); } return result; diff --git a/decompiler/VuDisasm/VuDisassembler.cpp b/decompiler/VuDisasm/VuDisassembler.cpp index dbbbc06dd..84f099fee 100644 --- a/decompiler/VuDisasm/VuDisassembler.cpp +++ b/decompiler/VuDisasm/VuDisassembler.cpp @@ -297,15 +297,13 @@ VuInstrK VuDisassembler::lower_kind(u32 in) { case 0b11110'1111'11: return VuInstrK::WAITP; } - fmt::print("Unknown lower special: 0b{:b}\n", in); - ASSERT(false); + ASSERT_MSG(false, fmt::format("Unknown lower special: 0b{:b}", in)); } else { ASSERT((op & 0b1000000) == 0); ASSERT(op < 64); auto elt = m_lower_op6_table[(int)op]; if (!elt.known) { - fmt::print("Invalid lower op6: 0b{:b} 0b{:b} 0x{:x}\n", op, in, in); - ASSERT(false); + ASSERT_MSG(false, fmt::format("Invalid lower op6: 0b{:b} 0b{:b} 0x{:x}", op, in, in)); } return elt.kind; } @@ -370,13 +368,11 @@ VuInstrK VuDisassembler::upper_kind(u32 in) { break; default: - fmt::print("Invalid op11: 0b{:b}\n", upper_op11(in)); - ASSERT(false); + ASSERT_MSG(false, fmt::format("Invalid op11: 0b{:b}", upper_op11(in))); } } if (!upper_info.known) { - fmt::print("Invalid upper op6: 0b{:b}\n", upper_op6(in)); - ASSERT(false); + ASSERT_MSG(false, fmt::format("Invalid upper op6: 0b{:b}", upper_op6(in))); } return upper_info.kind; } @@ -434,8 +430,7 @@ VuInstruction VuDisassembler::decode(VuInstrK kind, u32 data, int instr_idx) { instr.kind = kind; auto& inst = info(kind); if (!inst.known) { - fmt::print("instr idx {} is unknown\n", (int)kind); - ASSERT(false); + ASSERT_MSG(false, fmt::format("instr idx {} is unknown", (int)kind)); } for (auto& step : inst.decode) { s64 value = -1; diff --git a/decompiler/analysis/type_analysis.cpp b/decompiler/analysis/type_analysis.cpp index f1b7a1be2..b3ab4e50b 100644 --- a/decompiler/analysis/type_analysis.cpp +++ b/decompiler/analysis/type_analysis.cpp @@ -49,8 +49,7 @@ void modify_input_types_for_casts( state->get(cast.reg) = type_from_cast; } } catch (std::exception& e) { - printf("failed to parse hint: %s\n", e.what()); - ASSERT(false); + ASSERT_MSG(false, fmt::format("failed to parse hint: {}", e.what())); } } } diff --git a/decompiler/config/jak1_ntsc_black_label/hacks.jsonc b/decompiler/config/jak1_ntsc_black_label/hacks.jsonc index 254a73b49..17244b1ac 100644 --- a/decompiler/config/jak1_ntsc_black_label/hacks.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/hacks.jsonc @@ -424,7 +424,7 @@ "draw-drawable-tree-ice-tfrag": [6, 8, 13, 15], "draw-drawable-tree-instance-tie": [10, 12, 18, 20, 26, 28, 37, 39], "draw-drawable-tree-instance-shrub": [5, 7, 9, 11], - + "birth-pickup-at-point": [0], "draw-bones": [0, 1, 2, 8, 81], "draw-bones-hud": [7, 8], diff --git a/decompiler/config/jak1_ntsc_black_label/label_types.jsonc b/decompiler/config/jak1_ntsc_black_label/label_types.jsonc index 1fb182359..4f0e23cb2 100644 --- a/decompiler/config/jak1_ntsc_black_label/label_types.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/label_types.jsonc @@ -2128,9 +2128,7 @@ ], "generic-vu0": [["L1", "vu-function"]], - "shrubbery": [ - ["L133", "vu-function"] - ], + "shrubbery": [["L133", "vu-function"]], // please do not add things after this entry! git is dumb. "object-file-that-doesnt-actually-exist-and-i-just-put-this-here-to-prevent-merge-conflicts-with-this-file": [] diff --git a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc index ba4a567d5..1f7095f66 100644 --- a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc @@ -7587,7 +7587,7 @@ [[30, 38], "a2", "dma-packet"] ], - "draw-bones-shadow" : [ + "draw-bones-shadow": [ [10, "t0", "terrain-context"], [[36, 100], "t0", "shadow-dma-packet"], [[53, 58], "t6", "(inline-array vector)"], @@ -7595,7 +7595,7 @@ [[103, 106], "v1", "dma-packet"] ], - "shadow-execute-all" : [ + "shadow-execute-all": [ [108, "gp", "shadow-dcache"], [113, "gp", "shadow-dcache"], [118, "gp", "shadow-dcache"], @@ -7606,7 +7606,7 @@ "shadow-dma-init": [ [[25, 29], "t6", "dma-packet"], - [[34,37], "t6", "gs-gif-tag"], + [[34, 37], "t6", "gs-gif-tag"], [41, "t4", "(pointer gs-reg)"], [43, "t4", "(pointer gs-reg)"], [45, "t4", "(pointer gs-test)"], @@ -7691,9 +7691,7 @@ [273, "t0", "(pointer uint64)"], [275, "t0", "(pointer gs-reg64)"] ], - "test-func": [ - [7, "f1", "float"] - ], + "test-func": [[7, "f1", "float"]], "(method 14 drawable-tree-instance-shrub)": [ [[12, 151], "gp", "prototype-bucket-shrub"], @@ -7705,9 +7703,7 @@ [151, "gp", "(inline-array prototype-bucket-shrub)"] ], - "(method 10 drawable-tree-instance-shrub)": [ - [3, "a1", "terrain-context"] - ], + "(method 10 drawable-tree-instance-shrub)": [[3, "a1", "terrain-context"]], "draw-prototype-inline-array-shrub": [ [[13, 55], "v1", "prototype-bucket-shrub"], @@ -7741,13 +7737,9 @@ [540, "v1", "terrain-context"] ], - "(method 8 drawable-tree-instance-shrub)": [ - [54, "v1", "drawable-group"] - ], + "(method 8 drawable-tree-instance-shrub)": [[54, "v1", "drawable-group"]], - "draw-drawable-tree-instance-shrub": [ - [85, "a0", "drawable-group"] - ], + "draw-drawable-tree-instance-shrub": [[85, "a0", "drawable-group"]], "shrub-init-frame": [ [[6, 12], "a0", "dma-packet"], @@ -7767,9 +7759,7 @@ [54, "v1", "(pointer uint32)"] ], - "shrub-upload-view-data": [ - [[3, 16], "a0", "dma-packet"] - ], + "shrub-upload-view-data": [[[3, 16], "a0", "dma-packet"]], "shrub-upload-model": [ [[17, 26], "a3", "dma-packet"], @@ -7777,8 +7767,6 @@ [[47, 55], "a0", "dma-packet"] ], - "(method 12 effect-control)": [ - ["_stack_", 112, "res-tag"] - ], + "(method 12 effect-control)": [["_stack_", 112, "res-tag"]], "placeholder-do-not-add-below": [] } diff --git a/decompiler/data/LinkedWordReader.h b/decompiler/data/LinkedWordReader.h index 83c533664..7371b5306 100644 --- a/decompiler/data/LinkedWordReader.h +++ b/decompiler/data/LinkedWordReader.h @@ -17,8 +17,7 @@ class LinkedWordReader { m_offset++; return result; } else { - ASSERT(false); - throw std::runtime_error("LinkedWordReader::get_type_tag failed"); + ASSERT_MSG(false, "LinkedWordReader::get_type_tag failed"); } } diff --git a/decompiler/data/game_text.cpp b/decompiler/data/game_text.cpp index 7fbe7e83a..759da032f 100644 --- a/decompiler/data/game_text.cpp +++ b/decompiler/data/game_text.cpp @@ -125,8 +125,7 @@ GameTextResult process_game_text(ObjectFileData& data, GameTextVersion version) if (read_words[i] < 1) { std::string debug; data.linked_data.append_word_to_string(debug, words.at(i)); - printf("[%d] %d 0x%s\n", i, int(read_words[i]), debug.c_str()); - ASSERT(false); + ASSERT_MSG(false, fmt::format("[{}] {} 0x{}", i, int(read_words[i]), debug.c_str())); } } diff --git a/decompiler/data/tpage.cpp b/decompiler/data/tpage.cpp index 78b6b2ff9..0774e4371 100644 --- a/decompiler/data/tpage.cpp +++ b/decompiler/data/tpage.cpp @@ -276,8 +276,7 @@ Texture read_texture(ObjectFileData& data, const std::vector& words, auto kv = psms.find(tex.psm); if (kv == psms.end()) { - printf("Got unsupported texture 0x%x!\n", tex.psm); - ASSERT(false); + ASSERT_MSG(false, fmt::format("Got unsupported texture 0x{:x}!", tex.psm)); } return tex; diff --git a/decompiler/level_extractor/BspHeader.cpp b/decompiler/level_extractor/BspHeader.cpp index 9b9c75b4a..e27016785 100644 --- a/decompiler/level_extractor/BspHeader.cpp +++ b/decompiler/level_extractor/BspHeader.cpp @@ -298,8 +298,7 @@ void tfrag_debug_print_unpack(Ref start, int qwc_total) { case VifCode::Kind::NOP: break; default: - fmt::print("unknown: {}\n", next.print()); - ASSERT(false); + ASSERT_MSG(false, fmt::format("unknown: {}", next.print())); } } fmt::print("-------------------------------------------\n"); @@ -1677,4 +1676,4 @@ std::string BspHeader::print(const PrintSettings& settings) const { result += drawable_tree_array.print(settings, next_indent); return result; } -} // namespace level_tools \ No newline at end of file +} // namespace level_tools diff --git a/decompiler/level_extractor/extract_level.cpp b/decompiler/level_extractor/extract_level.cpp index 39c6fb7e2..2ea8d28d3 100644 --- a/decompiler/level_extractor/extract_level.cpp +++ b/decompiler/level_extractor/extract_level.cpp @@ -120,9 +120,8 @@ void confirm_textures_identical(TextureDB& tex_db) { } else { bool ok = it->second == tex.second.rgba_bytes; if (!ok) { - fmt::print("BAD duplicate: {} {} vs {}\n", name, tex.second.rgba_bytes.size(), - it->second.size()); - ASSERT(false); + ASSERT_MSG(false, fmt::format("BAD duplicate: {} {} vs {}", name, + tex.second.rgba_bytes.size(), it->second.size())); } } } diff --git a/decompiler/level_extractor/extract_shrub.cpp b/decompiler/level_extractor/extract_shrub.cpp index 422465605..dd56d633a 100644 --- a/decompiler/level_extractor/extract_shrub.cpp +++ b/decompiler/level_extractor/extract_shrub.cpp @@ -129,8 +129,7 @@ u32 remap_texture(u32 original, const std::vector& ma auto masked = original & 0xffffff00; for (auto& t : map) { if (t.original_texid == masked) { - fmt::print("OKAY! remapped!\n"); - ASSERT(false); + ASSERT_MSG(false, "OKAY! remapped!"); return t.new_texid | 20; } } @@ -502,14 +501,13 @@ void make_draws(tfrag3::Level& lev, // we're missing a texture, just use the first one. tex_it = tdb.textures.begin(); } else { - fmt::print( - "texture {} wasn't found. make sure it is loaded somehow. You may need to " - "include " - "ART.DGO or GAME.DGO in addition to the level DGOs for shared textures.\n", - combo_tex); - fmt::print("tpage is {}\n", combo_tex >> 16); - fmt::print("id is {} (0x{:x})\n", combo_tex & 0xffff, combo_tex & 0xffff); - ASSERT(false); + ASSERT_MSG( + false, + fmt::format( + "texture {} wasn't found. make sure it is loaded somehow. You may need to " + "include ART.DGO or GAME.DGO in addition to the level DGOs for shared " + "textures. tpage is {} id is {} (0x{:x})", + combo_tex, combo_tex >> 16, combo_tex & 0xffff, combo_tex & 0xffff)); } } // add a new texture to the level data diff --git a/decompiler/level_extractor/extract_tfrag.cpp b/decompiler/level_extractor/extract_tfrag.cpp index 65fb5767c..2af87aa9d 100644 --- a/decompiler/level_extractor/extract_tfrag.cpp +++ b/decompiler/level_extractor/extract_tfrag.cpp @@ -1760,10 +1760,9 @@ void update_mode_from_alpha1(u64 val, DrawMode& mode) { mode.set_alpha_blend(DrawMode::AlphaBlend::SRC_0_FIX_DST); // src plus dest } else { - fmt::print("unsupported blend: a {} b {} c {} d {}\n", (int)reg.a_mode(), (int)reg.b_mode(), - (int)reg.c_mode(), (int)reg.d_mode()); mode.set_alpha_blend(DrawMode::AlphaBlend::SRC_DST_SRC_DST); - ASSERT(false); + ASSERT_MSG(false, fmt::format("unsupported blend: a {} b {} c {} d {}", (int)reg.a_mode(), + (int)reg.b_mode(), (int)reg.c_mode(), (int)reg.d_mode())); } } @@ -1786,9 +1785,8 @@ void update_mode_from_test1(u64 val, DrawMode& mode) { mode.set_alpha_test(DrawMode::AlphaTest::NEVER); break; default: - fmt::print("Alpha test: {} not supported\n", (int)test.alpha_test()); mode.set_alpha_test(DrawMode::AlphaTest::ALWAYS); - ASSERT(false); + ASSERT_MSG(false, fmt::format("Alpha test: {} not supported", (int)test.alpha_test())); } // AREF @@ -1909,8 +1907,7 @@ void process_draw_mode(std::vector& all_draws, break; case GsRegisterAddress::CLAMP_1: if (!(val == 0b101 || val == 0 || val == 1 || val == 0b100)) { - fmt::print("clamp: 0x{:x}\n", val); - ASSERT(false); + ASSERT_MSG(false, fmt::format("clamp: 0x{:x}", val)); } // this isn't quite right, but I'm hoping it's enough! @@ -2014,13 +2011,14 @@ void make_tfrag3_data(std::map>& draws, // we're missing a texture, just use the first one. tex_it = tdb.textures.begin(); } else { - fmt::print( - "texture {} wasn't found. make sure it is loaded somehow. You may need to include " - "ART.DGO or GAME.DGO in addition to the level DGOs for shared textures.\n", - combo_tex_id); - fmt::print("tpage is {}\n", combo_tex_id >> 16); - fmt::print("id is {} (0x{:x})\n", combo_tex_id & 0xffff, combo_tex_id & 0xffff); - ASSERT(false); + ASSERT_MSG( + false, + fmt::format("texture {} wasn't found. make sure it is loaded somehow. You may need " + "to include " + "ART.DGO or GAME.DGO in addition to the level DGOs for shared textures." + "tpage is {}. id is {} (0x{:x})", + combo_tex_id, combo_tex_id >> 16, combo_tex_id & 0xffff, + combo_tex_id & 0xffff)); } } tfrag3_tex_id = texture_pool.size(); @@ -2239,8 +2237,7 @@ void extract_tfrag(const level_tools::DrawableTreeTfrag* tree, } else if (tree->my_type() == "drawable-tree-trans-tfrag") { this_tree.kind = tfrag3::TFragmentTreeKind::TRANS; } else { - fmt::print("unknown tfrag tree kind: {}\n", tree->my_type()); - ASSERT(false); + ASSERT_MSG(false, fmt::format("unknown tfrag tree kind: {}", tree->my_type())); } ASSERT(tree->length == (int)tree->arrays.size()); diff --git a/decompiler/level_extractor/extract_tie.cpp b/decompiler/level_extractor/extract_tie.cpp index 4d444fe78..8dbf0597a 100644 --- a/decompiler/level_extractor/extract_tie.cpp +++ b/decompiler/level_extractor/extract_tie.cpp @@ -464,8 +464,7 @@ u32 remap_texture(u32 original, const std::vector& ma auto masked = original & 0xffffff00; for (auto& t : map) { if (t.original_texid == masked) { - fmt::print("OKAY! remapped!\n"); - ASSERT(false); + ASSERT_MSG(false, "OKAY! remapped!"); return t.new_texid | 20; } } @@ -2012,8 +2011,7 @@ DrawMode process_draw_mode(const AdgifInfo& info, bool use_atest, bool use_decal // the clamp matters if (!(info.clamp_val == 0b101 || info.clamp_val == 0 || info.clamp_val == 1 || info.clamp_val == 0b100)) { - fmt::print("clamp: 0x{:x}\n", info.clamp_val); - ASSERT(false); + ASSERT_MSG(false, fmt::format("clamp: 0x{:x}", info.clamp_val)); } mode.set_clamp_s_enable(info.clamp_val & 0b1); @@ -2104,14 +2102,13 @@ void add_vertices_and_static_draw(tfrag3::TieTree& tree, // we're missing a texture, just use the first one. tex_it = tdb.textures.begin(); } else { - fmt::print( - "texture {} wasn't found. make sure it is loaded somehow. You may need to " - "include " - "ART.DGO or GAME.DGO in addition to the level DGOs for shared textures.\n", - combo_tex); - fmt::print("tpage is {}\n", combo_tex >> 16); - fmt::print("id is {} (0x{:x})\n", combo_tex & 0xffff, combo_tex & 0xffff); - ASSERT(false); + ASSERT_MSG( + false, + fmt::format( + "texture {} wasn't found. make sure it is loaded somehow. You may need to " + "include ART.DGO or GAME.DGO in addition to the level DGOs for shared " + "textures. tpage is {}. id is {} (0x{:x})", + combo_tex, combo_tex >> 16, combo_tex & 0xffff, combo_tex & 0xffff)); } } // add a new texture to the level data diff --git a/game/graphics/opengl_renderer/DirectRenderer.cpp b/game/graphics/opengl_renderer/DirectRenderer.cpp index 410731f7e..04cc45885 100644 --- a/game/graphics/opengl_renderer/DirectRenderer.cpp +++ b/game/graphics/opengl_renderer/DirectRenderer.cpp @@ -253,8 +253,7 @@ void DirectRenderer::update_gl_prim(SharedRenderState* render_state) { case GsTest::AlphaTest::NEVER: break; default: - fmt::print("unknown alpha test: {}\n", (int)m_test_state.alpha_test); - ASSERT(false); + ASSERT_MSG(false, fmt::format("unknown alpha test: {}", (int)m_test_state.alpha_test)); } } @@ -618,9 +617,8 @@ void DirectRenderer::render_gif(const u8* data, if (size != UINT32_MAX) { if ((offset + 15) / 16 != size / 16) { - fmt::print("DirectRenderer size failed in {}\n", name_and_id()); - fmt::print("expected: {}, got: {}\n", size, offset); - ASSERT(false); + ASSERT_MSG(false, fmt::format("DirectRenderer size failed in {}. expected: {}, got: {}", + name_and_id(), size, offset)); } } @@ -693,8 +691,7 @@ void DirectRenderer::handle_ad(const u8* data, } break; default: - fmt::print("Address {} is not supported\n", register_address_name(addr)); - ASSERT(false); + ASSERT_MSG(false, fmt::format("Address {} is not supported", register_address_name(addr))); } } @@ -1053,8 +1050,8 @@ void DirectRenderer::handle_xyzf2_common(u32 x, } } break; default: - fmt::print("prim type {} is unsupported in {}.\n", (int)m_prim_building.kind, name_and_id()); - ASSERT(false); + ASSERT_MSG(false, fmt::format("prim type {} is unsupported in {}.", (int)m_prim_building.kind, + name_and_id())); } } diff --git a/game/graphics/opengl_renderer/DirectRenderer2.cpp b/game/graphics/opengl_renderer/DirectRenderer2.cpp index b495c29df..c535eb177 100644 --- a/game/graphics/opengl_renderer/DirectRenderer2.cpp +++ b/game/graphics/opengl_renderer/DirectRenderer2.cpp @@ -235,8 +235,7 @@ void DirectRenderer2::setup_opengl_for_draw_mode(const Draw& draw, case DrawMode::AlphaTest::NEVER: break; default: - fmt::print("unknown alpha test: {}\n", (int)draw.mode.get_alpha_test()); - ASSERT(false); + ASSERT_MSG(false, fmt::format("unknown alpha test: {}", (int)draw.mode.get_alpha_test())); } } @@ -540,8 +539,7 @@ void DirectRenderer2::handle_ad(const u8* data) { case GsRegisterAddress::TEXFLUSH: break; default: - fmt::print("Address {} is not supported\n", register_address_name(addr)); - ASSERT(false); + ASSERT_MSG(false, fmt::format("Address {} is not supported", register_address_name(addr))); } } @@ -827,4 +825,4 @@ void DirectRenderer2::handle_alpha1(u64 val) { // ASSERT(false); } } -} \ No newline at end of file +} diff --git a/game/graphics/opengl_renderer/GenericProgram.cpp b/game/graphics/opengl_renderer/GenericProgram.cpp index 3ac988665..f9e460a9a 100644 --- a/game/graphics/opengl_renderer/GenericProgram.cpp +++ b/game/graphics/opengl_renderer/GenericProgram.cpp @@ -358,8 +358,7 @@ void GenericRenderer::mscal_dispatch(int imm, SharedRenderState* render_state, S mscal_noclip_nopipe(render_state, prof); return; default: - fmt::print("Generic dispatch mscal: {}\n", imm); - ASSERT(false); + ASSERT_MSG(false, fmt::format("Generic dispatch mscal: {}", imm)); } L33: // R @@ -1094,4 +1093,4 @@ void GenericRenderer::mscal_dispatch(int imm, SharedRenderState* render_state, S // nop | nop 1093 return; -} \ No newline at end of file +} diff --git a/game/graphics/opengl_renderer/GenericRenderer.cpp b/game/graphics/opengl_renderer/GenericRenderer.cpp index 1f66576c0..308cdcae6 100644 --- a/game/graphics/opengl_renderer/GenericRenderer.cpp +++ b/game/graphics/opengl_renderer/GenericRenderer.cpp @@ -51,8 +51,7 @@ void GenericRenderer::render(DmaFollower& dma, case VifCode::Kind::NOP: break; default: - fmt::print("unknown vifcode0 empty tag: {}\n", v0.print()); - ASSERT(false); + ASSERT_MSG(false, fmt::format("unknown vifcode0 empty tag: {}", v0.print())); } switch (v1.kind) { case VifCode::Kind::STCYCL: @@ -64,8 +63,7 @@ void GenericRenderer::render(DmaFollower& dma, mscal(v1.immediate, render_state, prof); break; default: - fmt::print("unknown vifcode1 empty tag: {}\n", v1.print()); - ASSERT(false); + ASSERT_MSG(false, fmt::format("unknown vifcode1 empty tag: {}", v1.print())); } } else if (v0.kind == VifCode::Kind::FLUSHA && v1.kind == VifCode::Kind::DIRECT) { if (render_state->use_direct2) { @@ -129,11 +127,9 @@ void GenericRenderer::render(DmaFollower& dma, ASSERT(false); } } else { - fmt::print("Generic encountered unknown DMA.\n"); - fmt::print("Size bytes: {}\n", data.size_bytes); - fmt::print("VIF0: {}\n", data.vifcode0().print()); - fmt::print("VIF1: {}\n", data.vifcode1().print()); - ASSERT(false); + ASSERT_MSG(false, + fmt::format("Generic encountered unknown DMA. Size bytes: {}. VIF0: {}. VIF1: {}", + data.size_bytes, data.vifcode0().print(), data.vifcode1().print())); } m_skipped_tags++; } @@ -182,10 +178,9 @@ void GenericRenderer::handle_dma_stream(const u8* data, mscal(vc.immediate, render_state, prof); break; default: - fmt::print("Generic encountered unknown DMA in handle_dma_stream.\n"); - fmt::print("Bytes remaining: {}\n", bytes); - fmt::print("VIF: {}\n", vc.print()); - ASSERT(false); + ASSERT_MSG(false, fmt::format("Generic encountered unknown DMA in handle_dma_stream. Bytes " + "remaining: {}. VIF: {}", + bytes, vc.print())); } } } @@ -320,4 +315,4 @@ void GenericRenderer::xgkick(u16 addr, SharedRenderState* render_state, ScopedPr } } m_xgkick_idx++; -} \ No newline at end of file +} diff --git a/game/graphics/opengl_renderer/MercProgram.cpp b/game/graphics/opengl_renderer/MercProgram.cpp index a95bec927..4a149472d 100644 --- a/game/graphics/opengl_renderer/MercProgram.cpp +++ b/game/graphics/opengl_renderer/MercProgram.cpp @@ -3141,8 +3141,7 @@ ASSERT(false); case 0x539: goto JUMP_539; default: - fmt::print("bad jump to {:x}\n", vu.vi08); - ASSERT(false); + ASSERT_MSG(false, fmt::format("bad jump to {:x}", vu.vi08)); } L94: // 3072.0 | mulax.xyzw ACC, vf01, vf11 :i diff --git a/game/graphics/opengl_renderer/MercRenderer.cpp b/game/graphics/opengl_renderer/MercRenderer.cpp index ce52d2895..1411958d0 100644 --- a/game/graphics/opengl_renderer/MercRenderer.cpp +++ b/game/graphics/opengl_renderer/MercRenderer.cpp @@ -247,8 +247,7 @@ void MercRenderer::handle_merc_chain(DmaFollower& dma, } break; default: - fmt::print("unknown mscal: {}\n", mscal_addr); - ASSERT(false); + ASSERT_MSG(false, fmt::format("unknown mscal: {}", mscal_addr)); } // while (true) { diff --git a/game/graphics/opengl_renderer/ShadowRenderer.cpp b/game/graphics/opengl_renderer/ShadowRenderer.cpp index 6245f35f6..163dedef9 100644 --- a/game/graphics/opengl_renderer/ShadowRenderer.cpp +++ b/game/graphics/opengl_renderer/ShadowRenderer.cpp @@ -96,8 +96,8 @@ void ShadowRenderer::xgkick(u16 imm) { // fmt::print("rgba: {} {} {} {}: {}\n", rgba[0], rgba[1], rgba[2], rgba[3], Q); } break; default: - fmt::print("Address {} is not supported\n", register_address_name(addr)); - ASSERT(false); + ASSERT_MSG(false, fmt::format("Address {} is not supported", + register_address_name(addr))); } } break; case GifTag::RegisterDescriptor::ST: { @@ -308,8 +308,7 @@ void ShadowRenderer::render(DmaFollower& dma, dma.read_and_advance(); } else { - fmt::print("{} {}\n", next.vifcode0().print(), next.vifcode1().print()); - ASSERT(false); + ASSERT_MSG(false, fmt::format("{} {}", next.vifcode0().print(), next.vifcode1().print())); } } @@ -423,4 +422,4 @@ void ShadowRenderer::draw(SharedRenderState* render_state, ScopedProfilerNode& p glDepthMask(GL_TRUE); glDisable(GL_STENCIL_TEST); -} \ No newline at end of file +} diff --git a/game/graphics/opengl_renderer/Shadow_PS2.cpp b/game/graphics/opengl_renderer/Shadow_PS2.cpp index fed663f0b..285cbb8f9 100644 --- a/game/graphics/opengl_renderer/Shadow_PS2.cpp +++ b/game/graphics/opengl_renderer/Shadow_PS2.cpp @@ -131,8 +131,7 @@ void ShadowRenderer::handle_jalr_to_end_block(u16 val, u32& first_flag, u32& sec // nop | nop 739 return; default: - fmt::print("unhandled end block: {}\n", val); - ASSERT(false); + ASSERT_MSG(false, fmt::format("unhandled end block: {}", val)); } } @@ -1715,8 +1714,7 @@ void ShadowRenderer::run_mscal_vu2c(u16 imm) { case 699: goto INSTR_699; default: - fmt::print("unknown vu.vi15 @ L46: {}\n", vu.vi15); - ASSERT(false); + ASSERT_MSG(false, fmt::format("unknown vu.vi15 @ L46: {}", vu.vi15)); } // clang-format off // nop | nop 663 @@ -1890,7 +1888,6 @@ void ShadowRenderer::run_mscal_vu2c(u16 imm) { case 527: goto INSTR_527; default: - fmt::print("unknown vu.vi15 @ 722: {}\n", vu.vi15); - ASSERT(false); + ASSERT_MSG(false, fmt::format("unknown vu.vi15 @ 722: {}", vu.vi15)); } } diff --git a/game/graphics/opengl_renderer/Sprite3.cpp b/game/graphics/opengl_renderer/Sprite3.cpp index 2b91d9c51..0dd2fc466 100644 --- a/game/graphics/opengl_renderer/Sprite3.cpp +++ b/game/graphics/opengl_renderer/Sprite3.cpp @@ -577,8 +577,7 @@ void Sprite3::handle_clamp(u64 val, SharedRenderState* /*render_state*/, ScopedProfilerNode& /*prof*/) { if (!(val == 0b101 || val == 0 || val == 1 || val == 0b100)) { - fmt::print("clamp: 0x{:x}\n", val); - ASSERT(false); + ASSERT_MSG(false, fmt::format("clamp: 0x{:x}", val)); } m_current_mode.set_clamp_s_enable(val & 0b001); diff --git a/game/graphics/opengl_renderer/SpriteRenderer.cpp b/game/graphics/opengl_renderer/SpriteRenderer.cpp index ab51fd48b..4e26d6951 100644 --- a/game/graphics/opengl_renderer/SpriteRenderer.cpp +++ b/game/graphics/opengl_renderer/SpriteRenderer.cpp @@ -526,8 +526,7 @@ void SpriteRenderer::handle_clamp(u64 val, SharedRenderState* /*render_state*/, ScopedProfilerNode& /*prof*/) { if (!(val == 0b101 || val == 0 || val == 1 || val == 0b100)) { - fmt::print("clamp: 0x{:x}\n", val); - ASSERT(false); + ASSERT_MSG(false, fmt::format("clamp: 0x{:x}", val)); } m_adgif_state.reg_clamp = val; diff --git a/game/graphics/opengl_renderer/foreground/Generic2_DMA.cpp b/game/graphics/opengl_renderer/foreground/Generic2_DMA.cpp index 2278d493f..3f61a57c8 100644 --- a/game/graphics/opengl_renderer/foreground/Generic2_DMA.cpp +++ b/game/graphics/opengl_renderer/foreground/Generic2_DMA.cpp @@ -180,8 +180,7 @@ u32 Generic2::handle_fragments_after_unpack_v4_32(const u8* data, // continue in this transfer off += first_unpack_bytes; if (off == end_of_vif) { - fmt::print("nothing after header upload\n"); - ASSERT(false); + ASSERT_MSG(false, "nothing after header upload"); } // the next thing is the vertex positions. @@ -379,4 +378,4 @@ void Generic2::process_dma(DmaFollower& dma, u32 next_bucket) { } } } -} \ No newline at end of file +} diff --git a/game/graphics/opengl_renderer/foreground/Generic2_OpenGL.cpp b/game/graphics/opengl_renderer/foreground/Generic2_OpenGL.cpp index b65b2c7e2..4ca157dc0 100644 --- a/game/graphics/opengl_renderer/foreground/Generic2_OpenGL.cpp +++ b/game/graphics/opengl_renderer/foreground/Generic2_OpenGL.cpp @@ -106,8 +106,7 @@ void Generic2::setup_opengl_for_draw_mode(const DrawMode& draw_mode, case DrawMode::AlphaTest::NEVER: break; default: - fmt::print("unknown alpha test: {}\n", (int)draw_mode.get_alpha_test()); - ASSERT(false); + ASSERT_MSG(false, fmt::format("unknown alpha test: {}", (int)draw_mode.get_alpha_test())); } } @@ -315,4 +314,4 @@ void Generic2::do_draws(SharedRenderState* render_state, ScopedProfilerNode& pro do_hud_draws(render_state, prof); } -} \ No newline at end of file +} diff --git a/game/graphics/opengl_renderer/ocean/OceanMid.cpp b/game/graphics/opengl_renderer/ocean/OceanMid.cpp index 9be7a481f..0e192fa22 100644 --- a/game/graphics/opengl_renderer/ocean/OceanMid.cpp +++ b/game/graphics/opengl_renderer/ocean/OceanMid.cpp @@ -122,12 +122,10 @@ void OceanMid::run(DmaFollower& dma, SharedRenderState* render_state, ScopedProf run_call43_vu2c(); break; default: - fmt::print("unknown call2: {}\n", v0.immediate); - ASSERT(false); + ASSERT_MSG(false, fmt::format("unknown call2: {}", v0.immediate)); } } else { - fmt::print("{} {}\n", data.vifcode0().print(), data.vifcode1().print()); - ASSERT(false); + ASSERT_MSG(false, fmt::format("{} {}", data.vifcode0().print(), data.vifcode1().print())); } } m_common_ocean_renderer.flush_mid(render_state, prof); @@ -139,4 +137,4 @@ void OceanMid::run_call0() { void OceanMid::xgkick(u16 addr) { m_common_ocean_renderer.kick_from_mid((const u8*)&m_vu_data[addr]); -} \ No newline at end of file +} diff --git a/game/graphics/opengl_renderer/ocean/OceanNear.cpp b/game/graphics/opengl_renderer/ocean/OceanNear.cpp index 554f5901c..d6a0e76a0 100644 --- a/game/graphics/opengl_renderer/ocean/OceanNear.cpp +++ b/game/graphics/opengl_renderer/ocean/OceanNear.cpp @@ -102,8 +102,7 @@ void OceanNear::render(DmaFollower& dma, run_call39_vu2c(); break; default: - fmt::print("unknown ocean near call: {}\n", v0.immediate); - ASSERT(false); + ASSERT_MSG(false, fmt::format("unknown ocean near call: {}", v0.immediate)); } } } @@ -117,4 +116,4 @@ void OceanNear::render(DmaFollower& dma, void OceanNear::xgkick(u16 addr) { m_common_ocean_renderer.kick_from_near((const u8*)&m_vu_data[addr]); -} \ No newline at end of file +} diff --git a/game/kernel/klink.cpp b/game/kernel/klink.cpp index 6094a2d59..38d0b1bca 100644 --- a/game/kernel/klink.cpp +++ b/game/kernel/klink.cpp @@ -18,6 +18,7 @@ #include "common/goal_constants.h" #include "game/mips2c/mips2c_table.h" #include "common/util/Assert.h" +#include "third-party/fmt/core.h" namespace { // turn on printf's for debugging linking issues. @@ -143,8 +144,7 @@ void link_control::begin(Ptr object_file, } } } else { - printf("UNHANDLED OBJECT FILE VERSION\n"); - ASSERT(false); + ASSERT_MSG(false, "UNHANDLED OBJECT FILE VERSION"); } if ((m_flags & LINK_FLAG_FORCE_DEBUG) && MasterDebug && !DiskBoot) { @@ -254,8 +254,7 @@ uint32_t link_control::work() { ASSERT(!m_opengoal); rv = work_v2(); } else { - printf("UNHANDLED OBJECT FILE VERSION %d IN WORK!\n", m_version); - ASSERT(false); + ASSERT_MSG(false, fmt::format("UNHANDLED OBJECT FILE VERSION {} IN WORK!", m_version)); return 0; } @@ -502,8 +501,7 @@ uint32_t link_control::work_v3() { lp = lp + ptr_link_v3(lp, ofh, m_segment_process); break; default: - printf("unknown link table thing %d\n", *lp); - ASSERT(false); + ASSERT_MSG(false, fmt::format("unknown link table thing {}", *lp)); break; } } diff --git a/game/kernel/kscheme.cpp b/game/kernel/kscheme.cpp index 5280e60ff..c64322042 100644 --- a/game/kernel/kscheme.cpp +++ b/game/kernel/kscheme.cpp @@ -1213,8 +1213,7 @@ u64 call_method_of_type_arg2(u32 arg, Ptr type, u32 method_id, u32 a1, u32 (*type_tag).offset); } } - printf("[ERROR] call_method_of_type_arg2 failed!\n"); - ASSERT(false); + ASSERT_MSG(false, "[ERROR] call_method_of_type_arg2 failed!"); return arg; } diff --git a/game/mips2c/functions/generic_merc.cpp b/game/mips2c/functions/generic_merc.cpp index 4174d4cce..5131f0c50 100644 --- a/game/mips2c/functions/generic_merc.cpp +++ b/game/mips2c/functions/generic_merc.cpp @@ -1921,8 +1921,7 @@ void vcallms_311(ExecutionContext* c, u16* vis) { vcallms_311_case_427(c, vis); break; default: - fmt::print("BAD JUMP {}\n", vis[vi01]); - ASSERT(false); + ASSERT_MSG(false, fmt::format("BAD JUMP {}", vis[vi01])); } } @@ -1955,8 +1954,7 @@ void vcallms_311_reference(ExecutionContext* c, u16* vis) { case 427: goto JUMP_427; default: - fmt::print("BAD JUMP {}\n", vis[vi01]); - ASSERT(false); + ASSERT_MSG(false, fmt::format("BAD JUMP {}", vis[vi01])); } JUMP_314: diff --git a/game/overlord/srpc.cpp b/game/overlord/srpc.cpp index 2e594d28f..b028b162e 100644 --- a/game/overlord/srpc.cpp +++ b/game/overlord/srpc.cpp @@ -10,6 +10,7 @@ #include "sbank.h" #include "iso_api.h" #include "common/util/Assert.h" +#include "third-party/fmt/core.h" using namespace iop; @@ -322,8 +323,7 @@ void* RPC_Player(unsigned int /*fno*/, void* data, int size) { // TODO ShutdownFilingSystem(); } break; default: { - printf("Unhandled RPC Player command %d\n", (int)cmd->command); - ASSERT(false); + ASSERT_MSG(false, fmt::format("Unhandled RPC Player command {}", (int)cmd->command)); } break; } n_messages--; @@ -410,8 +410,7 @@ void* RPC_Loader(unsigned int /*fno*/, void* data, int size) { // SignalSema(gSema); } break; default: - printf("Unhandled RPC Loader command %d\n", (int)cmd->command); - ASSERT(false); + ASSERT_MSG(false, fmt::format("Unhandled RPC Loader command {}", (int)cmd->command)); } n_messages--; cmd++; diff --git a/goalc/debugger/Debugger.cpp b/goalc/debugger/Debugger.cpp index 897d93de8..4d462f076 100644 --- a/goalc/debugger/Debugger.cpp +++ b/goalc/debugger/Debugger.cpp @@ -763,8 +763,8 @@ void Debugger::watcher() { break; #endif default: - printf("[Debugger] unhandled signal in watcher: %d\n", int(signal_info.kind)); - ASSERT(false); + ASSERT_MSG(false, fmt::format("[Debugger] unhandled signal in watcher: {}", + int(signal_info.kind))); } { diff --git a/goalc/emitter/CodeTester.cpp b/goalc/emitter/CodeTester.cpp index 225a289ca..542df8945 100644 --- a/goalc/emitter/CodeTester.cpp +++ b/goalc/emitter/CodeTester.cpp @@ -15,6 +15,7 @@ #include #include "CodeTester.h" #include "IGen.h" +#include "third-party/fmt/core.h" namespace emitter { @@ -133,8 +134,7 @@ void CodeTester::init_code_buffer(int capacity) { code_buffer = (u8*)mmap(nullptr, capacity, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0); if (code_buffer == (u8*)(-1)) { - printf("[CodeTester] Failed to map memory!\n"); - ASSERT(false); + ASSERT_MSG(false, "[CodeTester] Failed to map memory!"); } code_buffer_capacity = capacity; diff --git a/goalc/regalloc/Allocator.cpp b/goalc/regalloc/Allocator.cpp index 986247d1a..5c85be8bb 100644 --- a/goalc/regalloc/Allocator.cpp +++ b/goalc/regalloc/Allocator.cpp @@ -569,8 +569,7 @@ bool try_spill_coloring(int var, RegAllocCache* cache, const AllocationInput& in } if (spill_assignment.reg == -1) { - printf("SPILLING FAILED BECAUSE WE COULDN'T FIND A TEMP REGISTER!\n"); - ASSERT(false); + ASSERT_MSG(false, "SPILLING FAILED BECAUSE WE COULDN'T FIND A TEMP REGISTER!"); return false; } @@ -844,4 +843,4 @@ AllocationResult allocate_registers(const AllocationInput& input) { result.num_spills = cache.stats.num_spill_ops; return result; -} \ No newline at end of file +}