diff options
| author | notyourav <65437533+notyourav@users.noreply.github.com> | 2021-01-06 17:36:27 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-06 20:36:27 -0500 |
| commit | b8ecef0ddba85486fba72729b19d304e407b4247 (patch) | |
| tree | 55695a03d1bb9552ad90c501347fb631435f57a3 /include | |
| parent | 88fca194f819728591935b3de9dd8fcd1cd4e827 (diff) | |
Refactor JUTFont symbols (#71)
* fix JUTFont args
* fix
Co-authored-by: Pheenoh <pheenoh@gmail.com>
Diffstat (limited to 'include')
| -rw-r--r-- | include/JSystem/JUtility/JUTFont/JUTFont.h | 74 | ||||
| -rw-r--r-- | include/JSystem/JUtility/JUTResFont.h | 80 | ||||
| -rw-r--r-- | include/JSystem/JUtility/asm/JUTResFont__drawChar_scale.s | 2 | ||||
| -rw-r--r-- | include/JSystem/JUtility/asm/JUTResFont__getFontCode.s | 2 | ||||
| -rw-r--r-- | include/JSystem/JUtility/asm/JUTResFont__getWidthEntry.s | 2 | ||||
| -rw-r--r-- | include/functions.h | 32 | ||||
| -rw-r--r-- | include/gx/GX.h | 56 |
7 files changed, 146 insertions, 102 deletions
diff --git a/include/JSystem/JUtility/JUTFont/JUTFont.h b/include/JSystem/JUtility/JUTFont/JUTFont.h index 82c7489aed..c4a0d6f616 100644 --- a/include/JSystem/JUtility/JUTFont/JUTFont.h +++ b/include/JSystem/JUtility/JUTFont/JUTFont.h @@ -2,61 +2,63 @@ #define JSYSTEM_JUTILITY_JUTFONT_H #include "global.h" +#include "gx/GX.h" -static const unsigned int CLR_WHITE = 0xFFFFFFFF; -static const unsigned int CLR_BLACK = 0; +namespace JUtility { -typedef const char* ResFONT; - -struct TColor { - TColor() { *(u32*)&r = 0xFFFFFFFF; } +struct TColor : _GXColor { + TColor() { set(-1); } TColor(u32 raw) { *(u32*)&r = raw; } - u32 Raw() { return *(u32*)&r; } + void set(u32 col) { *(u32*)&r = col; } + + u32 toUInt32() const { return *(u32*)&r; } - u8 r; - u8 g; - u8 b; - u8 a; + operator u32() const { return toUInt32(); } + void operator=(const TColor& rhs) { ((_GXColor*)this)->operator=(rhs); } }; +} // namespace JUtility + class JUTFont { public: JUTFont(); - virtual ~JUTFont(); + virtual ~JUTFont() {} struct TWidth {}; - virtual void setGX() = 0; - virtual void setGX(TColor col1, TColor col2); - - virtual void drawChar_scale(float a1, float a2, float a3, float a4, int a5, bool a6); - virtual u16 getLeading() = 0; - virtual u16 getAscent() = 0; - virtual u16 getDescent() = 0; - virtual u32 getHeight() = 0; - virtual u32 getWidth() = 0; - virtual void getWidthEntry(s32 i_no, TWidth* width); - virtual u32 getCellWidth(); - virtual u32 getCellHeight(); - virtual u32 getFontType() = 0; - virtual TColor getResFont() = 0; - virtual bool isLeadByte(s32 a1) = 0; + /* 0x0c */ virtual void setGX() = 0; + /* 0x10 */ virtual void setGX(JUtility::TColor col1, JUtility::TColor col2); + /* 0x14 */ virtual f32 drawChar_scale(f32 a1, f32 a2, f32 a3, f32 a4, int a5, bool a6) = 0; + /* 0x18 */ virtual u16 getLeading() const = 0; + /* 0x1c */ virtual u16 getAscent() const = 0; + /* 0x20 */ virtual u16 getDescent() const = 0; + /* 0x24 */ virtual u32 getHeight() const = 0; + /* 0x28 */ virtual u32 getWidth() const = 0; + /* 0x2c */ virtual void getWidthEntry(int i_no, TWidth* width) const; + /* 0x30 */ virtual u32 getCellWidth() const; + /* 0x34 */ virtual u32 getCellHeight() const; + /* 0x38 */ virtual u32 getFontType() const = 0; + /* 0x3c */ virtual void getResFont() const = 0; + /* 0x40 */ virtual bool isLeadByte(int a1) const = 0; + + static bool isLeadByte_1Byte(int b); + static bool isLeadByte_2Byte(int b); + static bool isLeadByte_ShiftJIS(int b); void initialize_state(); - void setCharColor(TColor col1); - void setGradColor(TColor col1, TColor col2); - float drawString_size_scale(float a1, float a2, float a3, float a4, char* a5, unsigned long usz, - bool a7); + void setCharColor(JUtility::TColor col1); + void setGradColor(JUtility::TColor col1, JUtility::TColor col2); + f32 drawString_size_scale(f32 a1, f32 a2, f32 a3, f32 a4, const char* a5, u32 usz, bool a7); - bool unk4; + u8 unk4; bool unk5; int unk8; - TColor mColor1; - TColor mColor2; - TColor mColor3; - TColor mColor4; + JUtility::TColor mColor1; + JUtility::TColor mColor2; + JUtility::TColor mColor3; + JUtility::TColor mColor4; int unk1C; }; diff --git a/include/JSystem/JUtility/JUTResFont.h b/include/JSystem/JUtility/JUTResFont.h index ab27062c7c..24bd39c02b 100644 --- a/include/JSystem/JUtility/JUTResFont.h +++ b/include/JSystem/JUtility/JUTResFont.h @@ -4,54 +4,72 @@ #include "JSystem/JKernel/JKRHeap/JKRHeap.h" #include "JSystem/JUtility/JUTFont/JUTFont.h" +// todo: move +inline u8 JSUHiByte(u16 i) { + return i >> 8; +} +inline u8 JSULoByte(u16 i) { + return i & 0xff; +} + +struct ResFONT {}; + class JUTResFont : JUTFont { public: JUTResFont(); - JUTResFont(ResFONT font, JKRHeap* heap); + JUTResFont(const ResFONT* font, JKRHeap* heap); ~JUTResFont(); struct Unknown { - struct Unknown2 { + struct Cell { u32 filler0; u32 filler4; u32 filler8; - u16 unkC; - u16 unkE; + u16 width; + u16 height; }; - Unknown2* unk0; + Cell* cell; }; - virtual void setGX(); - virtual void setGX(TColor col1, TColor col2); - virtual void drawChar_scale(float a1, float a2, float a3, float a4, int a5, bool a6); - virtual void getWidthEntry(s32 i_no, TWidth* width); - virtual u32 getCellWidth(); - virtual u32 getCellHeight(); - virtual bool isLeadByte(s32 a1); + // virtuals + /* 0x0c */ virtual void setGX(); + /* 0x10 */ virtual void setGX(JUtility::TColor col1, JUtility::TColor col2); + /* 0x14 */ virtual f32 drawChar_scale(f32 a1, f32 a2, f32 a3, f32 a4, int a5, bool a6); - virtual void loadImage(s32 a1, u32 a2); - virtual void setBlock(); + /* 0x2c */ virtual void getWidthEntry(int i_no, TWidth* width) const; + /* 0x30 */ virtual u32 getCellWidth() const; + /* 0x34 */ virtual u32 getCellHeight() const; + /* 0x40 */ virtual bool isLeadByte(int a1) const; + /* 0x44 */ virtual void loadImage(int a1, GXTexMapID a2); + /* 0x48 */ virtual void setBlock(); + // inlines + void delete_and_initialize() { + deleteMemBlocks_ResFont(); + initialize_state(); + } + + // member functions void deleteMemBlocks_ResFont(); void initialize_state(); - bool initiate(ResFONT font, JKRHeap* heap); - bool protected_initiate(ResFONT font, JKRHeap* heap); + bool initiate(const ResFONT* font, JKRHeap* heap); + bool protected_initiate(const ResFONT* font, JKRHeap* heap); u32 countBlock(); - void loadFont(s32 a1, u32 a2, TWidth* a3); - u32 getFontCode(s32 a1); - s32 convertSjis(s32 a1, u16* a2); - - u32 unk20; - u8 filler24[0x20]; - u32 unk44; - u32 unk48; - u32 filler4C; - JKRHeap* unk50; - u32 unk54; - Unknown* unk58; - u32 unk5C; - u8 filler60[0xC]; - bool (**unk6C)(s32 a1); + void loadFont(int a1, GXTexMapID a2, TWidth* a3); + int getFontCode(int a1) const; + u32 convertSjis(int a1, u16* a2) const; + + /* 0x20 */ u32 unk20; + /* 0x24 */ u8 filler24[0x20]; + /* 0x44 */ u32 unk44; + /* 0x48 */ const ResFONT* pFontFile; + /* 0x4c */ u32 filler4C; + /* 0x50 */ JKRHeap* pMemBlocks; + /* 0x54 */ u32 unk54; + /* 0x58 */ Unknown* unk58; + /* 0x5c */ u32 unk5C; + /* 0x60 */ u16 mBlockCounts[6]; + /* 0x6c */ bool (**unk6C)(int a1); }; #endif // JSYSTEM_JUTILITY_JUT_RES_FONT diff --git a/include/JSystem/JUtility/asm/JUTResFont__drawChar_scale.s b/include/JSystem/JUtility/asm/JUTResFont__drawChar_scale.s index 12e2cc5c56..15085669b3 100644 --- a/include/JSystem/JUtility/asm/JUTResFont__drawChar_scale.s +++ b/include/JSystem/JUtility/asm/JUTResFont__drawChar_scale.s @@ -23,7 +23,7 @@ /* 802DF81C 002DC75C 7C BB 2B 78 */ mr r27, r5 /* 802DF820 002DC760 38 A0 00 00 */ li r5, 0 /* 802DF824 002DC764 38 C1 00 08 */ addi r6, r1, 8 -/* 802DF828 002DC768 48 00 03 C1 */ bl loadFont__10JUTResFontFlUlPQ27JUTFont6TWidth +/* 802DF828 002DC768 48 00 03 C1 */ bl loadFont__10JUTResFontFi11_GXTexMapIDPQ27JUTFont6TWidth /* 802DF82C 002DC76C 88 1E 00 05 */ lbz r0, 5(r30) /* 802DF830 002DC770 28 00 00 00 */ cmplwi r0, 0 /* 802DF834 002DC774 40 82 00 0C */ bne lbl_802DF840 diff --git a/include/JSystem/JUtility/asm/JUTResFont__getFontCode.s b/include/JSystem/JUtility/asm/JUTResFont__getFontCode.s index 4a4eea0d6b..fdba27b38b 100644 --- a/include/JSystem/JUtility/asm/JUTResFont__getFontCode.s +++ b/include/JSystem/JUtility/asm/JUTResFont__getFontCode.s @@ -94,7 +94,7 @@ lbl_802DFF0C: lbl_802DFF28: /* 802DFF28 002DCE68 7F A3 EB 78 */ mr r3, r29 /* 802DFF2C 002DCE6C 7F C4 F3 78 */ mr r4, r30 -/* 802DFF30 002DCE70 48 00 01 95 */ bl convertSjis__10JUTResFontFlPUs +/* 802DFF30 002DCE70 48 00 01 95 */ bl convertSjis__10JUTResFontCFiPUs /* 802DFF34 002DCE74 7C 7F 1B 78 */ mr r31, r3 /* 802DFF38 002DCE78 48 00 00 0C */ b lbl_802DFF44 lbl_802DFF3C: diff --git a/include/JSystem/JUtility/asm/JUTResFont__getWidthEntry.s b/include/JSystem/JUtility/asm/JUTResFont__getWidthEntry.s index 66d3fb9843..b3edf09cf3 100644 --- a/include/JSystem/JUtility/asm/JUTResFont__getWidthEntry.s +++ b/include/JSystem/JUtility/asm/JUTResFont__getWidthEntry.s @@ -5,7 +5,7 @@ /* 802DFC74 002DCBB4 93 C1 00 08 */ stw r30, 8(r1) /* 802DFC78 002DCBB8 7C 7E 1B 78 */ mr r30, r3 /* 802DFC7C 002DCBBC 7C BF 2B 78 */ mr r31, r5 -/* 802DFC80 002DCBC0 48 00 01 59 */ bl getFontCode__10JUTResFontFl +/* 802DFC80 002DCBC0 48 00 01 59 */ bl getFontCode__10JUTResFontCFi /* 802DFC84 002DCBC4 38 A0 00 00 */ li r5, 0 /* 802DFC88 002DCBC8 98 BF 00 00 */ stb r5, 0(r31) /* 802DFC8C 002DCBCC 80 9E 00 4C */ lwz r4, 0x4c(r30) diff --git a/include/functions.h b/include/functions.h index d0d0eaf8e0..b88076a052 100644 --- a/include/functions.h +++ b/include/functions.h @@ -500,38 +500,6 @@ void __dla__FPv(void); } extern "C" { -struct TColor; - -extern void GXBegin(u8, u8, u16); -extern void GXLoadTexObj(u32*, s32); -extern void GXInitTexObjLOD(f32, f32, f32, u32*, s32, s32, u32, u8, u32); -extern void GXInitTexObj(u32*, u32, u32, u32, u32, u32, u8); - -extern void GXSetNumChans(u32); -extern void GXSetNumTevStages(u32); -extern void GXSetNumTexGens(u32); -extern void GXSetTevOrder(u32, u32, u32, u32); -extern void GXSetChanCtrl(u32, u32, u32, u32, u32, u32, s32); -extern void GXSetTevOp(s32, s32); -extern void GXSetTevColor(s32, TColor); -extern void GXSetTevColorIn(s32, u32, u32, u32, u32); -extern void GXSetTevAlphaIn(s32, u32, u32, u32, u32); -extern void GXSetTevColorOp(s32, u32, u32, u32, u32, u32); -extern void GXSetTevAlphaOp(s32, u32, u32, u32, u32, u32); -extern void GXSetBlendMode(u32, u32, u32, u32); -extern void GXSetVtxAttrFmt(u32, u32, u32, u32, u32); -extern void GXClearVtxDesc(); -extern void GXSetVtxDesc(u32, u32); -typedef void (*GXDrawDoneCallback)(void); -extern void GXSetDrawDoneCallback(GXDrawDoneCallback); -extern void GXDrawDone(void); -extern void GXAbortFrame(void); -extern void GXFlush(void); -extern OSThread* GXSetCurrentGXThread(void); -extern OSThread* GXGetCurrentGXThread(void); -} - -extern "C" { void VIWaitForRetrace(void); void VISetBlack(s32); void VIFlush(void); diff --git a/include/gx/GX.h b/include/gx/GX.h index d7c5f80ca8..0886d761ec 100644 --- a/include/gx/GX.h +++ b/include/gx/GX.h @@ -3,6 +3,34 @@ #include "dolphin/types.h" +typedef enum _GXTexMapID { + GX_TEXMAP1 = 1, + GX_TEXMAP2 = 2, + GX_TEXMAP0 = 0, + GX_TEXMAP5 = 5, + GX_TEXMAP6 = 6, + GX_TEXMAP3 = 3, + GX_TEXMAP4 = 4, + GX_TEXMAP_NULL = 255, + GX_TEX_DISABLE = 256, + GX_TEXMAP7 = 7, + GX_MAX_TEXMAP = 8 +} GXTexMapID; + +struct _GXColor { + void operator=(const _GXColor& rhs) { + r = rhs.r; + g = rhs.g; + b = rhs.b; + a = rhs.a; + } + + u8 r; + u8 g; + u8 b; + u8 a; +}; + struct GXRenderModeObj { s32 vi_tv_mode; u16 fb_width; @@ -22,6 +50,34 @@ struct GXRenderModeObj { extern "C" { f32 GXGetYScaleFactor(u16 efb_height, u16 xfb_height); u16 GXGetNumXfbLines(u32 efb_height, f32 y_scale); + +void GXBegin(u8, u8, u16); +void GXLoadTexObj(u32*, s32); +void GXInitTexObjLOD(f32, f32, f32, u32*, s32, s32, u32, u8, u32); +void GXInitTexObj(u32*, u32, u32, u32, u32, u32, u8); + +void GXSetNumChans(u32); +void GXSetNumTevStages(u32); +void GXSetNumTexGens(u32); +void GXSetTevOrder(u32, u32, u32, u32); +void GXSetChanCtrl(u32, u32, u32, u32, u32, u32, s32); +void GXSetTevOp(s32, s32); +void GXSetTevColor(s32, _GXColor); +void GXSetTevColorIn(s32, u32, u32, u32, u32); +void GXSetTevAlphaIn(s32, u32, u32, u32, u32); +void GXSetTevColorOp(s32, u32, u32, u32, u32, u32); +void GXSetTevAlphaOp(s32, u32, u32, u32, u32, u32); +void GXSetBlendMode(u32, u32, u32, u32); +void GXSetVtxAttrFmt(u32, u32, u32, u32, u32); +void GXClearVtxDesc(); +void GXSetVtxDesc(u32, u32); +typedef void (*GXDrawDoneCallback)(void); +void GXSetDrawDoneCallback(GXDrawDoneCallback); +void GXDrawDone(void); +void GXAbortFrame(void); +void GXFlush(void); +OSThread* GXSetCurrentGXThread(void); +OSThread* GXGetCurrentGXThread(void); } #endif
\ No newline at end of file |
