Twilight Princess
Decompilation of The Legend of Zelda: Twilight Princess
Loading...
Searching...
No Matches
JUTFont.h
Go to the documentation of this file.
1#ifndef JUTFONT_H
2#define JUTFONT_H
3
5#include "string.h"
6
11struct ResFONT {
12 struct INF1 {
13 /* 0x00 */ u32 magic;
14 /* 0x04 */ u32 size;
15 /* 0x08 */ u16 fontType;
16 /* 0x0A */ u16 ascent;
17 /* 0x0C */ u16 descent;
18 /* 0x0E */ u16 width;
19 /* 0x10 */ u16 leading;
20 /* 0x12 */ u16 defaultCode;
21 };
22
23 struct WID1 {
24 /* 0x00 */ u32 magic;
25 /* 0x04 */ u32 size;
26 /* 0x08 */ u16 startCode;
27 /* 0x0A */ u16 endCode;
28 /* 0x0C */ u8 mChunkNum[4];
29 };
30
31 struct MAP1 {
32 /* 0x00 */ u32 magic;
33 /* 0x04 */ u32 size;
34 /* 0x08 */ u16 mappingMethod;
35 /* 0x0A */ u16 startCode;
36 /* 0x0C */ u16 endCode;
37 /* 0x0E */ u16 numEntries;
38 /* 0x10 */ u16 mLeading;
39 };
40
41 struct GLY1 {
42 /* 0x00 */ u32 magic;
43 /* 0x04 */ u32 size;
44 /* 0x08 */ u16 startCode;
45 /* 0x0A */ u16 endCode;
46 /* 0x0C */ u16 cellWidth;
47 /* 0x0E */ u16 cellHeight;
48 /* 0x10 */ u32 textureSize;
49 /* 0x14 */ u16 textureFormat;
50 /* 0x16 */ u16 numRows;
51 /* 0x18 */ u16 numColumns;
52 /* 0x1A */ u16 textureWidth;
53 /* 0x1C */ u16 textureHeight;
54 /* 0x1E */ u16 padding;
55 /* 0x20 */ u8 data[];
56 };
57
58 /* 0x00 */ u64 magic;
59 /* 0x08 */ u32 filesize;
60 /* 0x0C */ u32 numBlocks;
61 /* 0x10 */ u8 padding[0x10];
62 /* 0x20 */ u8 data[];
63};
64
69class JUTFont {
70public:
71 JUTFont();
72 virtual ~JUTFont() {}
73
78
79 /* 0x0C */ virtual void setGX() = 0;
80 /* 0x10 */ virtual void setGX(JUtility::TColor col1, JUtility::TColor col2) { setGX(); }
81 /* 0x14 */ virtual f32 drawChar_scale(f32 a1, f32 a2, f32 a3, f32 a4, int a5, bool a6) = 0;
82 /* 0x18 */ virtual int getLeading() const = 0;
83 /* 0x1C */ virtual s32 getAscent() const = 0;
84 /* 0x20 */ virtual s32 getDescent() const = 0;
85 /* 0x24 */ virtual s32 getHeight() const = 0;
86 /* 0x28 */ virtual s32 getWidth() const = 0;
87 /* 0x2C */ virtual void getWidthEntry(int i_no, TWidth* width) const = 0;
88 /* 0x30 */ virtual s32 getCellWidth() const { return getWidth(); }
89 /* 0x34 */ virtual s32 getCellHeight() const { return getHeight(); }
90 /* 0x38 */ virtual int getFontType() const = 0;
91 /* 0x3C */ virtual ResFONT* getResFont() const = 0;
92 /* 0x40 */ virtual bool isLeadByte(int a1) const = 0;
93
94 static bool isLeadByte_1Byte(int b) {
95 return false;
96 }
97 static bool isLeadByte_2Byte(int b) {
98 return true;
99 }
100 static bool isLeadByte_ShiftJIS(int b) {
101 return (b >= 0x81 && b <= 0x9f) || (b >= 0xe0 && b <= 0xfc);
102 }
103 static bool isLeadByte_EUC(int b) {
104 return (b >= 0xA1 && b <= 0xFE) || b == 0x8E;
105 }
106
107 void initialize_state();
110 f32 drawString_size_scale(f32 posX, f32 posY, f32 width, f32 height, const char* str, u32 usz,
111 bool visible);
112
113 void drawString(int posX, int posY, const char* str, bool visible) {
114 drawString_size(posX, posY, str, strlen(str), visible);
115 }
116
117 void drawString_size(int posX, int posY, const char* str, u32 len, bool visible) {
118 drawString_size_scale(posX, posY, getWidth(), getHeight(), str, len, visible);
119 }
120
121 void drawString_scale(f32 posX, f32 posY, f32 width, f32 height, const char* str,
122 bool visible) {
123 drawString_size_scale(posX, posY, width, height, str, strlen(str), visible);
124 }
125
126 int getWidth(int i_no) const {
127 TWidth width;
128 getWidthEntry(i_no, &width);
129 return width.field_0x1;
130 }
131
132 bool isValid() const { return mValid; }
133 bool isFixed() const { return mFixed; }
134 int getFixedWidth() const { return mFixedWidth; }
135
136 /* 0x04 */ bool mValid;
137 /* 0x05 */ bool mFixed;
138 /* 0x08 */ int mFixedWidth;
143};
144
145#endif /* JUTFONT_H */
T cLib_calcTimer(T *value)
Definition c_lib.h:74
Definition JUTFont.h:69
virtual void setGX()=0
void drawString_scale(f32 posX, f32 posY, f32 width, f32 height, const char *str, bool visible)
Definition JUTFont.h:121
virtual ResFONT * getResFont() const =0
JUtility::TColor mColor2
Definition JUTFont.h:140
void initialize_state()
Definition JUTFont.cpp:14
virtual s32 getAscent() const =0
virtual s32 getDescent() const =0
int getWidth(int i_no) const
Definition JUTFont.h:126
bool isFixed() const
Definition JUTFont.h:133
bool isValid() const
Definition JUTFont.h:132
void drawString_size(int posX, int posY, const char *str, u32 len, bool visible)
Definition JUTFont.h:117
virtual s32 getHeight() const =0
bool mValid
Definition JUTFont.h:136
virtual ~JUTFont()
Definition JUTFont.h:72
void drawString(int posX, int posY, const char *str, bool visible)
Definition JUTFont.h:113
static bool isLeadByte_EUC(int b)
Definition JUTFont.h:103
bool mFixed
Definition JUTFont.h:137
void setCharColor(JUtility::TColor col1)
Definition JUTFont.cpp:22
void setGradColor(JUtility::TColor col1, JUtility::TColor col2)
Definition JUTFont.cpp:31
static bool isLeadByte_ShiftJIS(int b)
Definition JUTFont.h:100
static bool isLeadByte_1Byte(int b)
Definition JUTFont.h:94
f32 drawString_size_scale(f32 posX, f32 posY, f32 width, f32 height, const char *str, u32 usz, bool visible)
Definition JUTFont.cpp:40
int mFixedWidth
Definition JUTFont.h:138
virtual f32 drawChar_scale(f32 a1, f32 a2, f32 a3, f32 a4, int a5, bool a6)=0
virtual s32 getCellHeight() const
Definition JUTFont.h:89
JUtility::TColor mColor1
Definition JUTFont.h:139
virtual void getWidthEntry(int i_no, TWidth *width) const =0
virtual void setGX(JUtility::TColor col1, JUtility::TColor col2)
Definition JUTFont.h:80
virtual s32 getCellWidth() const
Definition JUTFont.h:88
JUtility::TColor mColor4
Definition JUTFont.h:142
JUtility::TColor mColor3
Definition JUTFont.h:141
static bool isLeadByte_2Byte(int b)
Definition JUTFont.h:97
virtual bool isLeadByte(int a1) const =0
JUTFont()
Definition JUTFont.cpp:9
int getFixedWidth() const
Definition JUTFont.h:134
virtual int getFontType() const =0
virtual int getLeading() const =0
virtual s32 getWidth() const =0
void strlen()
Definition JUTFont.h:74
u8 field_0x1
Definition JUTFont.h:76
u8 field_0x0
Definition JUTFont.h:75
Definition TColor.h:12
Definition JUTFont.h:41
u16 cellWidth
Definition JUTFont.h:46
u32 size
Definition JUTFont.h:43
u16 textureWidth
Definition JUTFont.h:52
u16 padding
Definition JUTFont.h:54
u16 endCode
Definition JUTFont.h:45
u16 numRows
Definition JUTFont.h:50
u16 numColumns
Definition JUTFont.h:51
u32 magic
Definition JUTFont.h:42
u16 cellHeight
Definition JUTFont.h:47
u16 startCode
Definition JUTFont.h:44
u32 textureSize
Definition JUTFont.h:48
u16 textureHeight
Definition JUTFont.h:53
u8 data[]
Definition JUTFont.h:55
u16 textureFormat
Definition JUTFont.h:49
Definition JUTFont.h:12
u32 magic
Definition JUTFont.h:13
u16 descent
Definition JUTFont.h:17
u16 defaultCode
Definition JUTFont.h:20
u16 width
Definition JUTFont.h:18
u16 leading
Definition JUTFont.h:19
u32 size
Definition JUTFont.h:14
u16 fontType
Definition JUTFont.h:15
u16 ascent
Definition JUTFont.h:16
Definition JUTFont.h:31
u16 startCode
Definition JUTFont.h:35
u16 mLeading
Definition JUTFont.h:38
u16 mappingMethod
Definition JUTFont.h:34
u16 endCode
Definition JUTFont.h:36
u16 numEntries
Definition JUTFont.h:37
u32 size
Definition JUTFont.h:33
u32 magic
Definition JUTFont.h:32
Definition JUTFont.h:23
u8 mChunkNum[4]
Definition JUTFont.h:28
u16 startCode
Definition JUTFont.h:26
u16 endCode
Definition JUTFont.h:27
u32 size
Definition JUTFont.h:25
u32 magic
Definition JUTFont.h:24
Definition JUTFont.h:11
u64 magic
Definition JUTFont.h:58
u8 data[]
Definition JUTFont.h:62
u32 numBlocks
Definition JUTFont.h:60
u8 padding[0x10]
Definition JUTFont.h:61
u32 filesize
Definition JUTFont.h:59
unsigned long u32
Definition types.h:10
float f32
Definition types.h:22
unsigned short u16
Definition types.h:9
unsigned long long u64
Definition types.h:11
signed long s32
Definition types.h:6
unsigned char u8
Definition types.h:8