From 75575b4a41d693d3cf5a7b903bf1c970c980ddd4 Mon Sep 17 00:00:00 2001 From: archshift Date: Wed, 10 Dec 2014 22:16:52 -0800 Subject: [PATCH 1/3] Added common folder, with a new string helper file. --- Makefile | 2 +- source/{ => common}/scope_exit.h | 0 source/common/string_funcs.cpp | 25 +++++++++++++++++++++++++ source/common/string_funcs.h | 9 +++++++++ source/tests/fs/fs_sdmc.cpp | 2 +- 5 files changed, 36 insertions(+), 2 deletions(-) rename source/{ => common}/scope_exit.h (100%) create mode 100644 source/common/string_funcs.cpp create mode 100644 source/common/string_funcs.h diff --git a/Makefile b/Makefile index cfd75dd..9cc97b3 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ include $(DEVKITARM)/3ds_rules #--------------------------------------------------------------------------------- export TARGET := $(shell basename $(CURDIR)) BUILD := build -SOURCES := source source/tests source/tests/fs source/tests/cpu +SOURCES := source source/common source/tests source/tests/fs source/tests/cpu DATA := data INCLUDES := source #include diff --git a/source/scope_exit.h b/source/common/scope_exit.h similarity index 100% rename from source/scope_exit.h rename to source/common/scope_exit.h diff --git a/source/common/string_funcs.cpp b/source/common/string_funcs.cpp new file mode 100644 index 0000000..71fc65e --- /dev/null +++ b/source/common/string_funcs.cpp @@ -0,0 +1,25 @@ +#include "string_funcs.h" + +#include +#include +#include +#include + +namespace Common { + +std::string FormatString(const char* format, ...) +{ + va_list arguments; + char *va_str; + + va_start(arguments, format); + vasprintf(&va_str, format, arguments); + va_end(arguments); + + std::string out_str(va_str); + free(va_str); + + return out_str; +} + +} diff --git a/source/common/string_funcs.h b/source/common/string_funcs.h new file mode 100644 index 0000000..434b029 --- /dev/null +++ b/source/common/string_funcs.h @@ -0,0 +1,9 @@ +#pragma once + +#include + +namespace Common { + +std::string FormatString(const char* format, ...); + +} diff --git a/source/tests/fs/fs_sdmc.cpp b/source/tests/fs/fs_sdmc.cpp index 7dc6146..614b7f4 100644 --- a/source/tests/fs/fs_sdmc.cpp +++ b/source/tests/fs/fs_sdmc.cpp @@ -2,7 +2,7 @@ #include #include <3ds.h> -#include "scope_exit.h" +#include "common/scope_exit.h" #include "tests/test.h" #include "tests/fs/fs_sdmc.h" From 4709c969facd7ca4ba40e58106b1e4794ff64d7e Mon Sep 17 00:00:00 2001 From: archshift Date: Wed, 10 Dec 2014 22:24:26 -0800 Subject: [PATCH 2/3] General cleanups and conversion towards Common::FormatString --- source/common/string_funcs.cpp | 24 +++++++++ source/common/string_funcs.h | 10 ++++ source/main.cpp | 31 +++++------ source/output.cpp | 99 ++++++++++++---------------------- source/output.h | 9 ++-- source/tests/fs/fs.cpp | 7 --- source/tests/fs/fs_sdmc.cpp | 2 +- source/tests/test.cpp | 5 +- source/tests/test.h | 8 +-- 9 files changed, 99 insertions(+), 96 deletions(-) diff --git a/source/common/string_funcs.cpp b/source/common/string_funcs.cpp index 71fc65e..eea49d6 100644 --- a/source/common/string_funcs.cpp +++ b/source/common/string_funcs.cpp @@ -1,5 +1,6 @@ #include "string_funcs.h" +#include #include #include #include @@ -22,4 +23,27 @@ std::string FormatString(const char* format, ...) return out_str; } +int CountLines(const std::string& str) +{ + if (str.empty()) + return 0; + + return 1 + std::count_if(str.begin(), str.end(), [](char c) { return c == '\n'; }); +} + +void DeleteFirstLine(std::string* str) +{ + if (str->empty()) + return; + + size_t linebreak = str->find_first_of('\n'); + + if (linebreak == std::string::npos || linebreak + 1 > str->length()) { + *str = {}; + return; + } + + *str = str->substr(linebreak + 1); +} + } diff --git a/source/common/string_funcs.h b/source/common/string_funcs.h index 434b029..feaa852 100644 --- a/source/common/string_funcs.h +++ b/source/common/string_funcs.h @@ -6,4 +6,14 @@ namespace Common { std::string FormatString(const char* format, ...); +/** + * Returns the number of lines (broken by '\n') in the string + */ +int CountLines(const std::string& str); + +/** + * Deletes the first line (broken by '\n') from the string + */ +void DeleteFirstLine(std::string* str); + } diff --git a/source/main.cpp b/source/main.cpp index 0219966..91d8edf 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -1,52 +1,53 @@ -#include -#include #include <3ds.h> #include "output.h" +#include "tests/test.h" #include "tests/fs/fs.h" #include "tests/cpu/cputests.h" -static unsigned int testCounter = 0; -static void (*tests[]) (void) = { +static unsigned int test_counter = 0; +static TestCaller tests[] = { FS::TestAll, CPU::Integer::TestAll }; -int main() +int main(int argc, char** argv) { srvInit(); aptInit(); hidInit(NULL); gfxInit(); gfxSet3D(false); + fsInit(); - clearScreens(); - print(GFX_TOP, "Press A to begin...\n"); + ClearScreens(); + Print(GFX_TOP, "Press A to begin...\n"); while (aptMainLoop()) { - drawFrames(); + DrawFrames(); hidScanInput(); if (hidKeysDown() & KEY_START) { break; } else if (hidKeysDown() & KEY_A) { - clearScreen(GFX_TOP); + ClearScreen(GFX_TOP); - if (testCounter < (sizeof(tests) / sizeof(tests[0]))) { - tests[testCounter](); - testCounter++; + if (test_counter < (sizeof(tests) / sizeof(tests[0]))) { + tests[test_counter](); + test_counter++; } else { break; } - print(GFX_TOP, "\n"); - print(GFX_TOP, "Press A to continue...\n"); + Print(GFX_TOP, "\n"); + Print(GFX_TOP, "Press A to continue...\n"); } gspWaitForEvent(GSPEVENT_VBlank0, false); } - clearScreens(); + ClearScreens(); + fsExit(); gfxExit(); hidExit(); aptExit(); diff --git a/source/output.cpp b/source/output.cpp index 7c77ce5..f6ecb43 100644 --- a/source/output.cpp +++ b/source/output.cpp @@ -1,98 +1,69 @@ #include "output.h" -#include -#include -#include #include -#include -#include #include <3ds.h> #include "text.h" +#include "common/string_funcs.h" -static std::string bufferTop; -static std::string bufferBottom; +static std::string buffer_top; +static std::string buffer_bottom; -static int countLines(const std::string& str) +static std::string& GetTextBuffer(gfxScreen_t screen) { - if (str.empty()) - return 0; - - return 1 + std::count_if(str.begin(), str.end(), [](char c) { return c == '\n'; }); + switch (screen) { + case GFX_TOP: return buffer_top; + case GFX_BOTTOM: return buffer_bottom; + } + return buffer_top; } -static void deleteFirstLine(std::string* str) +static void DrawFrame(gfxScreen_t screen, char b, char g, char r) { - if (str->empty()) - return; - - size_t linebreak = str->find_first_of('\n'); - - if (linebreak == std::string::npos || linebreak + 1 > str->length()) { - *str = {}; - return; - } - - *str = str->substr(linebreak + 1); -} + int screen_height = 240; + int screen_width = (screen == GFX_TOP) ? 400 : 320; + std::string& text_buffer = GetTextBuffer(screen); -static void drawFrame(gfxScreen_t screen, char b, char g, char r) -{ - int screenHeight = 240; - int screenWidth = (screen == GFX_TOP) ? 400 : 320; - std::string& textBuffer = (screen == GFX_TOP) ? bufferTop : bufferBottom; - - u8* bufAdr = gfxGetFramebuffer(screen, GFX_LEFT, nullptr, nullptr); - for (int i = 0; i < screenWidth * screenHeight * 3; i += 3) { - bufAdr[i] = b; - bufAdr[i+1] = g; - bufAdr[i+2] = r; + u8* fb_addr = gfxGetFramebuffer(screen, GFX_LEFT, nullptr, nullptr); + for (int i = 0; i < screen_width * screen_height * 3; i += 3) { + fb_addr[i] = b; + fb_addr[i+1] = g; + fb_addr[i+2] = r; } - int lines = countLines(textBuffer); - while (lines > (screenHeight / fontDefault.height - 3)) { - deleteFirstLine(&textBuffer); + int lines = Common::CountLines(text_buffer); + while (lines > (screen_height / fontDefault.height - 3)) { + Common::DeleteFirstLine(&text_buffer); lines--; } - gfxDrawText(screen, GFX_LEFT, nullptr, textBuffer, screenHeight - fontDefault.height * 3, 10); + gfxDrawText(screen, GFX_LEFT, nullptr, text_buffer, screen_height - fontDefault.height * 3, 10); } -void drawFrames() +void DrawFrames() { - drawFrame(GFX_TOP, 0x88, 0x66, 0x00); - drawFrame(GFX_BOTTOM, 0x00, 0x00, 0x00); + DrawFrame(GFX_TOP, 0x88, 0x66, 0x00); + DrawFrame(GFX_BOTTOM, 0x00, 0x00, 0x00); gfxFlushBuffers(); gfxSwapBuffers(); } -void print(gfxScreen_t screen, const char* format, ...) +void Print(gfxScreen_t screen, const std::string& text) { - std::string& textBuffer = (screen == GFX_TOP) ? bufferTop : bufferBottom; - - va_list arguments; - char *vaStr; + GetTextBuffer(screen) += text; + svcOutputDebugString(text.c_str(), text.length()); - va_start(arguments, format); - vasprintf(&vaStr, format, arguments); - va_end(arguments); - - textBuffer += std::string(vaStr); - svcOutputDebugString(vaStr, strlen(vaStr)); - free(vaStr); - - drawFrames(); + DrawFrames(); } -void clearScreen(gfxScreen_t screen) +void ClearScreen(gfxScreen_t screen) { - std::string& textBuffer = (screen == GFX_TOP) ? bufferTop : bufferBottom; - textBuffer.clear(); - drawFrames(); + GetTextBuffer(screen).clear(); + DrawFrames(); } -void clearScreens() +void ClearScreens() { - clearScreen(GFX_TOP); - clearScreen(GFX_BOTTOM); + ClearScreen(GFX_TOP); + ClearScreen(GFX_BOTTOM); } diff --git a/source/output.h b/source/output.h index 6ce9cf8..5219bcd 100644 --- a/source/output.h +++ b/source/output.h @@ -1,8 +1,9 @@ #pragma once #include <3ds.h> +#include -void drawFrames(); -void print(gfxScreen_t screen, const char* format, ...); -void clearScreen(gfxScreen_t screen); -void clearScreens(); +void DrawFrames(); +void Print(gfxScreen_t screen, const std::string& text); +void ClearScreen(gfxScreen_t screen); +void ClearScreens(); diff --git a/source/tests/fs/fs.cpp b/source/tests/fs/fs.cpp index 3593245..1d8d020 100644 --- a/source/tests/fs/fs.cpp +++ b/source/tests/fs/fs.cpp @@ -1,6 +1,3 @@ -#include <3ds.h> - -#include "tests/test.h" #include "tests/fs/fs.h" #include "tests/fs/fs_sdmc.h" @@ -8,11 +5,7 @@ namespace FS { void TestAll() { - Test("FS", "Initializing service", fsInit(), 0L); - SDMC::TestAll(); - - Test("FS", "Exiting service", fsExit(), 0L); } } // namespace diff --git a/source/tests/fs/fs_sdmc.cpp b/source/tests/fs/fs_sdmc.cpp index 614b7f4..577cdfb 100644 --- a/source/tests/fs/fs_sdmc.cpp +++ b/source/tests/fs/fs_sdmc.cpp @@ -158,7 +158,7 @@ static bool TestDirRename(FS_archive sdmcArchive) void TestAll() { - FS_archive sdmcArchive = (FS_archive) { 0x00000009, { PATH_EMPTY, 1, (u8*) "" } }; + FS_archive sdmcArchive = { 0x00000009, { PATH_EMPTY, 1, (u8*) "" } }; Test("SDMC", "Opening archive", FSUSER_OpenArchive(NULL, &sdmcArchive), 0L); Test("SDMC", "Creating and deleting file", TestFileCreateDelete(sdmcArchive), true); diff --git a/source/tests/test.cpp b/source/tests/test.cpp index 12817bb..4a92cab 100644 --- a/source/tests/test.cpp +++ b/source/tests/test.cpp @@ -3,8 +3,9 @@ #include <3ds.h> #include "output.h" +#include "common/string_funcs.h" -void PrintSuccess(std::string group, std::string name, bool val) +void PrintSuccess(const std::string& group, const std::string& name, bool val) { - print(GFX_TOP, "%s: %s - %s\n", group.c_str(), name.c_str(), val ? "SUCCESS" : "FAILURE"); + Print(GFX_TOP, Common::FormatString("%s: %s - %s\n", group.c_str(), name.c_str(), val ? "SUCCESS" : "FAILURE")); } diff --git a/source/tests/test.h b/source/tests/test.h index 0954cef..c50c20e 100644 --- a/source/tests/test.h +++ b/source/tests/test.h @@ -1,14 +1,16 @@ #pragma once -#include +#include + +typedef void (*TestCaller)(void); // If the condition fails, return false #define SoftAssert(cond) do { if (!(cond)) { return false; } } while (0) -void PrintSuccess(std::string group, std::string name, bool val); +void PrintSuccess(const std::string& group, const std::string& name, bool val); template -bool Test(std::string group, std::string name, T result, T expected) +bool Test(const std::string& group, const std::string& name, T result, T expected) { PrintSuccess(group, name, result == expected); return result == expected; From f040fc54a4486d97fe43de337525bc1c86b2ccf6 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 14 Dec 2014 02:37:52 -0800 Subject: [PATCH 3/3] Add logging to file, and cleaned up text.h/cpp. --- source/{text.cpp => draw.cpp} | 38 +++++++++++----- source/draw.h | 18 ++++++++ source/main.cpp | 9 ++-- source/output.cpp | 81 ++++++++++++++++++++++------------- source/output.h | 20 +++++++-- source/tests/test.cpp | 8 +++- source/tests/test.h | 10 ++++- source/text.h | 9 ---- 8 files changed, 137 insertions(+), 56 deletions(-) rename source/{text.cpp => draw.cpp} (60%) create mode 100644 source/draw.h delete mode 100644 source/text.h diff --git a/source/text.cpp b/source/draw.cpp similarity index 60% rename from source/text.cpp rename to source/draw.cpp index 1dcf8aa..0d0cdce 100644 --- a/source/text.cpp +++ b/source/draw.cpp @@ -1,13 +1,20 @@ -#include -#include -#include +#include "draw.h" + +#include +#include +#include + #include <3ds.h> -#include "text.h" #include "font.h" -//this code is not meant to be readable -int drawCharacter(u8* fb, font_s* font, char c, s16 x, s16 y, u16 w, u16 h) +Rect GetScreenSize(gfxScreen_t screen) +{ + return { (screen == GFX_TOP) ? 400 : 320, 240 }; +} + +// This code is not meant to be readable -- Smea +int DrawCharacter(u8* fb, font_s* font, char c, s16 x, s16 y, u16 w, u16 h) { Glyph* cd = &font->desc[(int)c]; @@ -52,7 +59,7 @@ int drawCharacter(u8* fb, font_s* font, char c, s16 x, s16 y, u16 w, u16 h) return cd->xa; } -void drawString(u8* fb, font_s* f, const std::string& str, s16 x, s16 y, u16 w, u16 h) +void DrawString(u8* fb, font_s* f, const std::string& str, s16 x, s16 y, u16 w, u16 h) { if (!f || !fb) return; @@ -60,7 +67,7 @@ void drawString(u8* fb, font_s* f, const std::string& str, s16 x, s16 y, u16 w, int dx = 0, dy = 0; for (const char& c : str) { - dx += drawCharacter(fb, f, c, x + dx, y + dy, w, h); + dx += DrawCharacter(fb, f, c, x + dx, y + dy, w, h); if (c == '\n') { dx = 0; dy -= f->height; @@ -68,7 +75,7 @@ void drawString(u8* fb, font_s* f, const std::string& str, s16 x, s16 y, u16 w, } } -void gfxDrawText(gfxScreen_t screen, gfx3dSide_t side, font_s* font, const std::string& str, s16 x, s16 y) +void DrawText(gfxScreen_t screen, gfx3dSide_t side, font_s* font, const std::string& str, s16 x, s16 y) { if (!font) font = &fontDefault; @@ -76,5 +83,16 @@ void gfxDrawText(gfxScreen_t screen, gfx3dSide_t side, font_s* font, const std:: u16 fbWidth, fbHeight; u8* fbAdr = gfxGetFramebuffer(screen, side, &fbWidth, &fbHeight); - drawString(fbAdr, font, str, y, x, fbHeight, fbWidth); + DrawString(fbAdr, font, str, y, x, fbHeight, fbWidth); +} + +void FillScreen(gfxScreen_t screen, u8 bg_r, u8 bg_g, u8 bg_b) +{ + Rect screen_size = GetScreenSize(screen); + u8* fb_addr = gfxGetFramebuffer(screen, GFX_LEFT, nullptr, nullptr); + for (int i = 0; i < screen_size.w * screen_size.h * 3; i += 3) { + fb_addr[i] = bg_b; + fb_addr[i+1] = bg_g; + fb_addr[i+2] = bg_r; + } } diff --git a/source/draw.h b/source/draw.h new file mode 100644 index 0000000..c2b78ad --- /dev/null +++ b/source/draw.h @@ -0,0 +1,18 @@ +#pragma once + +#include + +#include <3ds.h> + +#include "font.h" + +struct Rect { + int w, h; +}; + +Rect GetScreenSize(gfxScreen_t screen); + +int DrawCharacter(u8* fb, font_s* f, char c, s16 x, s16 y, u16 w, u16 h); +void DrawString(u8* fb, font_s* f, const std::string& str, s16 x, s16 y, u16 w, u16 h); +void DrawText(gfxScreen_t screen, gfx3dSide_t side, font_s* f, const std::string& str, s16 x, s16 y); +void FillScreen(gfxScreen_t screen, u8 bg_r, u8 bg_g, u8 bg_b); diff --git a/source/main.cpp b/source/main.cpp index 91d8edf..b39d285 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -19,18 +19,19 @@ int main(int argc, char** argv) gfxInit(); gfxSet3D(false); fsInit(); + InitOutput(); ClearScreens(); Print(GFX_TOP, "Press A to begin...\n"); while (aptMainLoop()) { - DrawFrames(); + DrawBuffers(); hidScanInput(); if (hidKeysDown() & KEY_START) { break; } else if (hidKeysDown() & KEY_A) { - ClearScreen(GFX_TOP); + ClearScreens(); if (test_counter < (sizeof(tests) / sizeof(tests[0]))) { tests[test_counter](); @@ -39,7 +40,7 @@ int main(int argc, char** argv) break; } - Print(GFX_TOP, "\n"); + Log(GFX_TOP, "\n"); Print(GFX_TOP, "Press A to continue...\n"); } @@ -47,6 +48,8 @@ int main(int argc, char** argv) } ClearScreens(); + + DeinitOutput(); fsExit(); gfxExit(); hidExit(); diff --git a/source/output.cpp b/source/output.cpp index f6ecb43..aa9c937 100644 --- a/source/output.cpp +++ b/source/output.cpp @@ -1,12 +1,15 @@ +#include <3ds.h> + #include "output.h" #include +#include -#include <3ds.h> - -#include "text.h" +#include "draw.h" #include "common/string_funcs.h" +static FILE* log_file; + static std::string buffer_top; static std::string buffer_bottom; @@ -19,51 +22,71 @@ static std::string& GetTextBuffer(gfxScreen_t screen) return buffer_top; } -static void DrawFrame(gfxScreen_t screen, char b, char g, char r) +static void DrawBuffer(gfxScreen_t screen) { - int screen_height = 240; - int screen_width = (screen == GFX_TOP) ? 400 : 320; + Rect screen_size = GetScreenSize(screen); std::string& text_buffer = GetTextBuffer(screen); - u8* fb_addr = gfxGetFramebuffer(screen, GFX_LEFT, nullptr, nullptr); - for (int i = 0; i < screen_width * screen_height * 3; i += 3) { - fb_addr[i] = b; - fb_addr[i+1] = g; - fb_addr[i+2] = r; - } - int lines = Common::CountLines(text_buffer); - while (lines > (screen_height / fontDefault.height - 3)) { + while (lines > (screen_size.h / fontDefault.height - 3)) { Common::DeleteFirstLine(&text_buffer); lines--; } - gfxDrawText(screen, GFX_LEFT, nullptr, text_buffer, screen_height - fontDefault.height * 3, 10); + DrawText(screen, GFX_LEFT, nullptr, text_buffer, screen_size.h - fontDefault.height * 3, 10); } -void DrawFrames() +void InitOutput() { - DrawFrame(GFX_TOP, 0x88, 0x66, 0x00); - DrawFrame(GFX_BOTTOM, 0x00, 0x00, 0x00); + sdmcInit(); + log_file = fopen("hwtest_log.txt", "w"); +} + +void DrawBuffers() +{ + FillScreen(GFX_TOP, 0x00, 0x66, 0x88); + DrawBuffer(GFX_TOP); + + FillScreen(GFX_BOTTOM, 0x00, 0x00, 0x00); + DrawBuffer(GFX_BOTTOM); + gfxFlushBuffers(); gfxSwapBuffers(); } +void ClearScreen(gfxScreen_t screen, u8 bg_r, u8 bg_g, u8 bg_b) +{ + FillScreen(screen, bg_r, bg_g, bg_b); + GetTextBuffer(screen).clear(); + gfxFlushBuffers(); + gfxSwapBuffers(); +} + +void ClearScreens() +{ + ClearScreen(GFX_TOP, 0x00, 0x66, 0x88); + ClearScreen(GFX_BOTTOM, 0x00, 0x00, 0x00); +} + void Print(gfxScreen_t screen, const std::string& text) { GetTextBuffer(screen) += text; + DrawBuffers(); +} + +void Log(gfxScreen_t screen, const std::string& text) +{ + Print(screen, text); + LogToFile(text); +} + +void LogToFile(const std::string& text) +{ svcOutputDebugString(text.c_str(), text.length()); - - DrawFrames(); + fprintf(log_file, "%s", text.c_str()); } -void ClearScreen(gfxScreen_t screen) +void DeinitOutput() { - GetTextBuffer(screen).clear(); - DrawFrames(); -} - -void ClearScreens() -{ - ClearScreen(GFX_TOP); - ClearScreen(GFX_BOTTOM); + fclose(log_file); + sdmcExit(); } diff --git a/source/output.h b/source/output.h index 5219bcd..8c59056 100644 --- a/source/output.h +++ b/source/output.h @@ -1,9 +1,23 @@ #pragma once -#include <3ds.h> #include -void DrawFrames(); +#include <3ds.h> + +void InitOutput(); + +void DrawBuffers(); + +/// Prints `text` to `screen`. void Print(gfxScreen_t screen, const std::string& text); -void ClearScreen(gfxScreen_t screen); + +/// Prints `text` to `screen`, and logs it in the log file. +void Log(gfxScreen_t screen, const std::string& text); + +/// Logs `text` to the log file. +void LogToFile(const std::string& text); + +void ClearScreen(gfxScreen_t screen, u8 bg_r, u8 bg_g, u8 bg_b); void ClearScreens(); + +void DeinitOutput(); diff --git a/source/tests/test.cpp b/source/tests/test.cpp index 4a92cab..03df339 100644 --- a/source/tests/test.cpp +++ b/source/tests/test.cpp @@ -5,7 +5,13 @@ #include "output.h" #include "common/string_funcs.h" +void SoftAssertLog(const std::string& function, int line, const std::string& condition) +{ + LogToFile(Common::FormatString("SOFTASSERT FAILURE: `%s`\n", condition.c_str())); + LogToFile(Common::FormatString(" At `%s` L%i\n", function.c_str(), line)); +} + void PrintSuccess(const std::string& group, const std::string& name, bool val) { - Print(GFX_TOP, Common::FormatString("%s: %s - %s\n", group.c_str(), name.c_str(), val ? "SUCCESS" : "FAILURE")); + Log(GFX_TOP, Common::FormatString("%s: [%s] %s\n", val ? "SUCCESS" : "FAILURE", group.c_str(), name.c_str())); } diff --git a/source/tests/test.h b/source/tests/test.h index c50c20e..e0e1080 100644 --- a/source/tests/test.h +++ b/source/tests/test.h @@ -4,8 +4,16 @@ typedef void (*TestCaller)(void); +void SoftAssertLog(const std::string& function, int line, const std::string& condition); + // If the condition fails, return false -#define SoftAssert(cond) do { if (!(cond)) { return false; } } while (0) +#define SoftAssert(cond) \ + do { \ + if (!(cond)) { \ + SoftAssertLog(__PRETTY_FUNCTION__, __LINE__, #cond); \ + return false; \ + } \ + } while (0) void PrintSuccess(const std::string& group, const std::string& name, bool val); diff --git a/source/text.h b/source/text.h deleted file mode 100644 index 719d5c3..0000000 --- a/source/text.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#include - -#include "font.h" - -int drawCharacter(u8* fb, font_s* f, char c, s16 x, s16 y, u16 w, u16 h); -void drawString(u8* fb, font_s* f, const std::string& str, s16 x, s16 y, u16 w, u16 h); -void gfxDrawText(gfxScreen_t screen, gfx3dSide_t side, font_s* f, const std::string& str, s16 x, s16 y);