diff options
Diffstat (limited to 'include/JSystem/JUtility')
| -rw-r--r-- | include/JSystem/JUtility/JUTFont.h | 93 | ||||
| -rw-r--r-- | include/JSystem/JUtility/JUTNameTab.h | 1 | ||||
| -rw-r--r-- | include/JSystem/JUtility/JUTPalette.h | 53 | ||||
| -rw-r--r-- | include/JSystem/JUtility/JUTResFont.h | 59 | ||||
| -rw-r--r-- | include/JSystem/JUtility/JUTTexture.h | 83 |
5 files changed, 239 insertions, 50 deletions
diff --git a/include/JSystem/JUtility/JUTFont.h b/include/JSystem/JUtility/JUTFont.h index 640143a768..b000764382 100644 --- a/include/JSystem/JUtility/JUTFont.h +++ b/include/JSystem/JUtility/JUTFont.h @@ -1,46 +1,82 @@ #ifndef JUTFONT_H #define JUTFONT_H +#include "JSystem/JUtility.h" #include "dolphin/gx/GX.h" #include "dolphin/types.h" -namespace JUtility { +struct ResFONT { + struct INF1 { + /* 0x00 */ u32 magic; + /* 0x04 */ u32 size; + /* 0x08 */ u16 fontType; + /* 0x0A */ u16 ascent; + /* 0x0C */ u16 descent; + /* 0x0E */ u16 width; + /* 0x10 */ u16 leading; + /* 0x12 */ u16 defaultCode; + }; -struct TColor : _GXColor { - TColor() { set(-1); } + struct WID1 { + /* 0x00 */ u32 magic; + /* 0x04 */ u32 size; + /* 0x08 */ u16 startCode; + /* 0x0A */ u16 endCode; + }; - TColor(u32 raw) { *(u32*)&r = raw; } + struct MAP1 { + /* 0x00 */ u32 magic; + /* 0x04 */ u32 size; + /* 0x08 */ u16 mappingMethod; + /* 0x0A */ u16 startCode; + /* 0x0C */ u16 endCode; + /* 0x0E */ u16 numEntries; + }; - void set(u32 col) { *(u32*)&r = col; } + struct GLY1 { + /* 0x00 */ u32 magic; + /* 0x04 */ u32 size; + /* 0x08 */ u16 startCode; + /* 0x0A */ u16 endCode; + /* 0x0C */ u16 cellWidth; + /* 0x0E */ u16 cellHeight; + /* 0x10 */ u32 textureSize; + /* 0x14 */ u16 textureFormat; + /* 0x16 */ u16 numRows; + /* 0x18 */ u16 numColumns; + /* 0x1A */ u16 textureWidth; + /* 0x1C */ u16 textureHeight; + }; - u32 toUInt32() const { return *(u32*)&r; } - - operator u32() const { return toUInt32(); } - void operator=(const TColor& rhs) { ((_GXColor*)this)->operator=(rhs); } + /* 0x00 */ u64 magic; + /* 0x08 */ u32 filesize; + /* 0x0C */ u32 numBlocks; + /* 0x10 */ u8 padding[0x10]; }; -} // namespace JUtility - class JUTFont { public: JUTFont(); virtual ~JUTFont() {} - struct TWidth {}; + struct TWidth { + u8 field_0x0; + u8 field_0x1; + }; - /* 0x0c */ virtual void setGX() = 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; + /* 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; + /* 0x24 */ virtual u16 getHeight() const = 0; + /* 0x28 */ virtual u16 getWidth() const = 0; + /* 0x2C */ virtual void getWidthEntry(int i_no, TWidth* width) const; + /* 0x30 */ virtual u16 getCellWidth() const; + /* 0x34 */ virtual u16 getCellHeight() const; + /* 0x38 */ virtual u16 getFontType() const = 0; + /* 0x3C */ virtual ResFONT* getResFont() const = 0; /* 0x40 */ virtual bool isLeadByte(int a1) const = 0; static bool isLeadByte_1Byte(int b); @@ -52,14 +88,13 @@ public: 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); - u8 unk4; - bool unk5; - int unk8; - JUtility::TColor mColor1; - JUtility::TColor mColor2; - JUtility::TColor mColor3; - JUtility::TColor mColor4; - int unk1C; + /* 0x04 */ bool mValid; + /* 0x05 */ bool mFixed; + /* 0x08 */ int mFixedWidth; + /* 0x0C */ JUtility::TColor mColor1; + /* 0x10 */ JUtility::TColor mColor2; + /* 0x14 */ JUtility::TColor mColor3; + /* 0x18 */ JUtility::TColor mColor4; }; #endif /* JUTFONT_H */ diff --git a/include/JSystem/JUtility/JUTNameTab.h b/include/JSystem/JUtility/JUTNameTab.h index ff0e7860e8..7f9d62dfde 100644 --- a/include/JSystem/JUtility/JUTNameTab.h +++ b/include/JSystem/JUtility/JUTNameTab.h @@ -26,6 +26,7 @@ public: s32 getIndex(char const*) const; const char* getName(u16 index) const; u16 calcKeyCode(char const* pName) const; + const ResNTAB* getResNameTable() const { return mpNameTable; } private: const ResNTAB* mpNameTable; diff --git a/include/JSystem/JUtility/JUTPalette.h b/include/JSystem/JUtility/JUTPalette.h index 64ef0ce53c..5de6c98ae6 100644 --- a/include/JSystem/JUtility/JUTPalette.h +++ b/include/JSystem/JUtility/JUTPalette.h @@ -1,6 +1,59 @@ #ifndef JUTPALETTE_H #define JUTPALETTE_H +#include "dolphin/gx/GX.h" #include "dolphin/types.h" +enum JUTTransparency { UNK0, UNK1 }; + +enum _GXTlut { + /* 0x00 */ GX_TLUT0, + /* 0x01 */ GX_TLUT1, + /* 0x02 */ GX_TLUT2, + /* 0x03 */ GX_TLUT3, + /* 0x04 */ GX_TLUT4, + /* 0x05 */ GX_TLUT5, + /* 0x06 */ GX_TLUT6, + /* 0x07 */ GX_TLUT7, + /* 0x08 */ GX_TLUT8, + /* 0x09 */ GX_TLUT9, + /* 0x0A */ GX_TLUT10, + /* 0x0B */ GX_TLUT11, + /* 0x0C */ GX_TLUT12, + /* 0x0D */ GX_TLUT13, + /* 0x0E */ GX_TLUT14, + /* 0x0F */ GX_TLUT15, + /* 0x10 */ GX_BIGTLUT0, + /* 0x11 */ GX_BIGTLUT1, + /* 0x12 */ GX_BIGTLUT2, + /* 0x13 */ GX_BIGTLUT3, +}; + +enum _GXTlutFmt { + /* 0x00 */ UNK, +}; + +struct ResTLUT { + u8 format; + u8 transparency; + u16 numColors; +}; + +class JUTPalette { +public: + /* 802DE890 */ void storeTLUT(_GXTlut, ResTLUT*); + /* 802DE91C */ void storeTLUT(_GXTlut, _GXTlutFmt, JUTTransparency, u16, void*); + /* 802DE95C */ bool load(); + + u8 getTlutName() const { return mTlutName; } + +private: + /* 0x00 */ _GXTlutObj mTlutObj; + /* 0x0C */ u8 mTlutName; + /* 0x0D */ u8 mFormat; + /* 0x10 */ ResTLUT* mColorTable; + /* 0x14 */ u16 mNumColors; + /* 0x16 */ u8 mTransparency; +}; + #endif /* JUTPALETTE_H */ diff --git a/include/JSystem/JUtility/JUTResFont.h b/include/JSystem/JUtility/JUTResFont.h index 848933805a..cf0398abd3 100644 --- a/include/JSystem/JUtility/JUTResFont.h +++ b/include/JSystem/JUtility/JUTResFont.h @@ -1,6 +1,65 @@ #ifndef JUTRESFONT_H #define JUTRESFONT_H +#include "JSystem/JKernel/JKRHeap.h" +#include "JSystem/JUtility/JUTFont.h" #include "dolphin/types.h" +class JUTResFont : public JUTFont { +public: + /* 802DF000 */ virtual ~JUTResFont(); + /* 802DF48C */ virtual void setGX(); + /* 802DF584 */ virtual void setGX(JUtility::TColor, JUtility::TColor); + /* 802DF7C4 */ virtual f32 drawChar_scale(f32, f32, f32, f32, int, bool); + /* 802DDFEC */ virtual u16 getLeading() const; + /* 802DE004 */ virtual u16 getAscent() const; + /* 802DE010 */ virtual u16 getDescent() const; + /* 802DE01C */ virtual u16 getHeight() const; + /* 802DDFF8 */ virtual u16 getWidth() const; + /* 802DFC64 */ virtual void getWidthEntry(int, JUTFont::TWidth*) const; + /* 802DFD0C */ virtual u16 getCellWidth() const; + /* 802DFD58 */ virtual u16 getCellHeight() const; + /* 802DDFE0 */ virtual u16 getFontType() const; + /* 802DDFD8 */ virtual ResFONT* getResFont() const; + /* 802DFDA4 */ virtual bool isLeadByte(int) const; + /* 802DFF60 */ virtual void loadImage(int, _GXTexMapID); + /* 802DF344 */ virtual void setBlock(); + + /* 802DEF94 */ JUTResFont(ResFONT const*, JKRHeap*); + /* 802DEF48 */ JUTResFont(); + /* 802DF08C */ void deleteMemBlocks_ResFont(); + /* 802DF0B0 */ void initialize_state(); + /* 802DF0DC */ bool initiate(ResFONT const*, JKRHeap*); + /* 802DF13C */ bool protected_initiate(ResFONT const*, JKRHeap*); + /* 802DF248 */ void countBlock(); + /* 802DFBE8 */ void loadFont(int, _GXTexMapID, JUTFont::TWidth*); + /* 802DFDD8 */ int getFontCode(int) const; + /* 802E00C4 */ void convertSjis(int, u16*) const; + + inline void delete_and_initialize() { + deleteMemBlocks_ResFont(); + initialize_state(); + } + + static void* const saoAboutEncoding_[3]; + + // some types uncertain, may need to be fixed + /* 0x1C */ void* field_0x1c; + /* 0x20 */ void* field_0x20; + /* 0x24 */ _GXTexObj field_0x24; + /* 0x44 */ int field_0x44; + /* 0x48 */ const ResFONT* mResFont; + /* 0x4C */ ResFONT::INF1* mInf1Ptr; + /* 0x50 */ void* field_0x50; + /* 0x54 */ ResFONT::WID1* mWid1Ptr; + /* 0x58 */ ResFONT::GLY1* mGly1Ptr; + /* 0x5C */ ResFONT::MAP1* mMap1Ptr; + /* 0x60 */ u16 mWid1BlockNum; + /* 0x62 */ u16 mGly1BlockNum; + /* 0x64 */ u16 mMap1BlockNum; + /* 0x66 */ u16 field_0x66; + /* 0x68 */ u16 field_0x68; + /* 0x6C */ void* field_0x6c; +}; + #endif /* JUTRESFONT_H */ diff --git a/include/JSystem/JUtility/JUTTexture.h b/include/JSystem/JUtility/JUTTexture.h index ad657caffb..113cdf923c 100644 --- a/include/JSystem/JUtility/JUTTexture.h +++ b/include/JSystem/JUtility/JUTTexture.h @@ -1,33 +1,74 @@ #ifndef JUTTEXTURE_H #define JUTTEXTURE_H +#include "JSystem/JUtility/JUTPalette.h" #include "dolphin/types.h" struct ResTIMG { /* Acts as the header to image data. Usually texture data immediately follows it, so any pointer arithmetic to go past the end of this structure is so that a variable sized allocated buffer can be accessed. */ - u8 texture_format; - bool is_alpha_enabled; - u16 texture_width; - u16 texture_height; - u8 wrap_s; - u8 wrap_t; - bool is_palettes_enabled; - u8 palette_format; - u16 palette_count; - u32 palette_offset; - bool is_mip_map_enabled; - bool do_edge_lod; - bool bias_clamp; - u8 max_anisotropy; - u8 min_filter; - u8 mag_filter; - u8 min_lod; - u8 max_lod; - u8 num_mipmaps; + u8 format; + bool alphaEnabled; + u16 width; + u16 height; + u8 wrapS; + u8 wrapT; + bool palettesEnabled; + u8 paletteFormat; + u16 paletteCount; + u32 paletteOffset; + bool mipmapEnabled; + bool doEdgeLOD; + bool biasClamp; + u8 maxAnisotropy; + u8 minFilter; + u8 magFilter; + u8 minLOD; + u8 maxLOD; + u8 mipmapCount; u8 unknown; - u16 lod_bias; - u32 texture_data_offset; + s16 LODBias; + u32 texDataOffset; +}; + +class JUTTexture { +public: + JUTTexture() { + setCaptureFlag(false); + mEmbPalette = NULL; + mTexInfo = NULL; + } + ~JUTTexture(); + void storeTIMG(ResTIMG const*, JUTPalette*, _GXTlut); + void storeTIMG(ResTIMG const*, u8); + void storeTIMG(ResTIMG const*, JUTPalette*); + void attachPalette(JUTPalette*); + void init(); + void initTexObj(_GXTlut); + void initTexObj(); + void load(_GXTexMapID); + + const ResTIMG* getTexInfo() const { return mTexInfo; } + void setCaptureFlag(bool flag) { mFlags &= 2 | flag; } + u8 getCaptureFlag() const { return mFlags & 1; } + u8 getEmbPaletteDelFlag() const { return mFlags & 2; } + +private: + /* 0x00 */ _GXTexObj mTexObj; + /* 0x20 */ const ResTIMG* mTexInfo; + /* 0x24 */ void* mTexData; + /* 0x28 */ JUTPalette* mEmbPalette; + /* 0x2C */ JUTPalette* field_0x2c; + /* 0x30 */ u8 mWrapS; + /* 0x31 */ u8 mWrapT; + /* 0x32 */ u8 mMinFilter; + /* 0x33 */ u8 mMagFilter; + /* 0x34 */ s16 mMinLOD; + /* 0x36 */ s16 mMaxLOD; + /* 0x38 */ s16 mLODBias; + /* 0x3A */ u8 mTlutName; + /* 0x3B */ u8 mFlags; + /* 0x3C */ void* field_0x3c; }; #endif /* JUTTEXTURE_H */ |
