From bb8d99313bb8b2ed0458ac421d19ad5dfe7167de Mon Sep 17 00:00:00 2001 From: Julgodis <> Date: Fri, 24 Sep 2021 17:51:55 +0200 Subject: [PATCH] Added TColor.h --- include/JSystem/JUtility/JUTDirectPrint.h | 44 +++++++++++++++++++++++ include/JSystem/JUtility/TColor.h | 39 ++++++++++++++++++++ include/dolphin/types.h | 2 ++ libs/JSystem/JUtility/JUTDirectPrint.cpp | 26 -------------- 4 files changed, 85 insertions(+), 26 deletions(-) create mode 100644 include/JSystem/JUtility/TColor.h diff --git a/include/JSystem/JUtility/JUTDirectPrint.h b/include/JSystem/JUtility/JUTDirectPrint.h index d805d9cb825..b9b1fbef214 100644 --- a/include/JSystem/JUtility/JUTDirectPrint.h +++ b/include/JSystem/JUtility/JUTDirectPrint.h @@ -2,5 +2,49 @@ #define JUTDIRECTPRINT_H #include "dolphin/types.h" +#include "JSystem/JUtility/TColor.h" + +struct base_process_class {}; + +struct __va_list_struct {}; + +class JUTDirectPrint { +public: + /* 802E41E8 */ JUTDirectPrint(); + /* 802E4240 */ void start(); + /* 802E4288 */ void erase(int, int, int, int); + /* 802E431C */ void drawChar(int, int, int); + /* 802E456C */ void changeFrameBuffer(void*, u16, u16); + /* 802E45A4 */ void printSub(u16, u16, char const*, __va_list_struct*, bool); + /* 802E46D8 */ void drawString(u16, u16, char*); + /* 802E4708 */ void drawString_f(u16, u16, char const*, ...); + /* 802E47C8 */ void setCharColor(u8, u8, u8); + /* 802E4798 */ void setCharColor(JUtility::TColor); + + static u8 sAsciiTable[128]; + static void* sFontData[64]; + static void* sFontData2[77]; + static u8 sDirectPrint[4 + 4 /* padding */]; + +private: + /* 0x00 */ void* field_0x00; + /* 0x04 */ u16 mFrameBufferWidth; + /* 0x06 */ u16 mFrameBufferHeight; + /* 0x08 */ u16 field_0x08; + /* 0x0A */ u16 field_0x0A; + /* 0x0C */ size_t field_0x0C; + /* 0x10 */ u8 field_0x10[4]; + /* 0x14 */ void* mFrameBuffer; + /* 0x18 */ JUtility::TColor mCharColor; + /* 0x1C */ u16 field_0x1C; + /* 0x1E */ u16 field_0x1E; + /* 0x20 */ u16 field_0x20; + /* 0x22 */ u16 field_0x22; + /* 0x24 */ u16 field_0x24; + /* 0x26 */ u16 field_0x26; + /* 0x28 */ u16 field_0x28; + /* 0x2A */ u16 field_0x2A; + /* 0x2C */ +}; #endif /* JUTDIRECTPRINT_H */ diff --git a/include/JSystem/JUtility/TColor.h b/include/JSystem/JUtility/TColor.h new file mode 100644 index 00000000000..19719d2fd83 --- /dev/null +++ b/include/JSystem/JUtility/TColor.h @@ -0,0 +1,39 @@ +#ifndef TCOLOR_H +#define TCOLOR_H + +#include "dolphin/gx/GXTexture.h" +#include "dolphin/types.h" + +namespace JUtility { +class TColor { +public: + TColor(u8 r, u8 g, u8 b, u8 a) { set(r, g, b, a); } + TColor() { set(0xffffffff); } + TColor(u32 u32Color) { set(u32Color); } + TColor(_GXColor gxColor) { set(gxColor); } + + TColor(const TColor& other) { *this = other; } + TColor& operator=(const TColor& other) { + mColor = other.mColor; + return *this; + } + + operator u32() { return toUInt32(); } + u32 toUInt32() { return *(u32*)&mColor; } + + void set(u8 cR, u8 cG, u8 cB, u8 cA) { + mColor.r = cR; + mColor.g = cG; + mColor.b = cB; + mColor.a = cA; + } + + void set(u32 u32Color) { *(u32*)&mColor = u32Color; } + void set(_GXColor gxColor) { mColor = gxColor; } + +private: + _GXColor mColor; +}; +} // namespace JUtility + +#endif \ No newline at end of file diff --git a/include/dolphin/types.h b/include/dolphin/types.h index 87de0f11330..0144f699a6c 100644 --- a/include/dolphin/types.h +++ b/include/dolphin/types.h @@ -26,6 +26,8 @@ typedef volatile f64 vf64; typedef int BOOL; +typedef unsigned long size_t; + #define TRUE 1 #define FALSE 0 diff --git a/libs/JSystem/JUtility/JUTDirectPrint.cpp b/libs/JSystem/JUtility/JUTDirectPrint.cpp index 5b007623ccf..934a057f804 100644 --- a/libs/JSystem/JUtility/JUTDirectPrint.cpp +++ b/libs/JSystem/JUtility/JUTDirectPrint.cpp @@ -11,32 +11,6 @@ // Types: // -struct base_process_class {}; - -struct __va_list_struct {}; - -struct JUtility { - struct TColor {}; -}; - -struct JUTDirectPrint { - /* 802E41E8 */ JUTDirectPrint(); - /* 802E4240 */ void start(); - /* 802E4288 */ void erase(int, int, int, int); - /* 802E431C */ void drawChar(int, int, int); - /* 802E456C */ void changeFrameBuffer(void*, u16, u16); - /* 802E45A4 */ void printSub(u16, u16, char const*, __va_list_struct*, bool); - /* 802E46D8 */ void drawString(u16, u16, char*); - /* 802E4708 */ void drawString_f(u16, u16, char const*, ...); - /* 802E47C8 */ void setCharColor(u8, u8, u8); - /* 802E4798 */ void setCharColor(JUtility::TColor); - - static u8 sAsciiTable[128]; - static void* sFontData[64]; - static void* sFontData2[77]; - static u8 sDirectPrint[4 + 4 /* padding */]; -}; - namespace JStudio { struct TFunctionValue_list_parameter { /* 80283C24 */ ~TFunctionValue_list_parameter();