NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
lyt_resources.h
1#ifndef NW4R_LYT_RESOURCES_H
2#define NW4R_LYT_RESOURCES_H
3#include <nw4r/types_nw4r.h>
4
5#include <nw4r/lyt/lyt_types.h>
6
7namespace nw4r {
8namespace lyt {
9namespace res {
10
11/******************************************************************************
12 *
13 * BinaryFileHeader
14 *
15 ******************************************************************************/
17 char signature[4]; // at 0x0
18 u16 byteOrder; // at 0x4
19 u16 version; // at 0x6
20 ulong fileSize; // at 0x8
21 u16 headerSize; // at 0xC
22 u16 dataBlocks; // at 0xE
23};
24
25/******************************************************************************
26 *
27 * DataBlockHeader
28 *
29 ******************************************************************************/
31 char kind[4]; // at 0x0
32 ulong size; // at 0x4
33};
34
35enum ExtUserDataType {
36 TYPE_STRING,
37 TYPE_INT,
38 TYPE_FLOAT,
39};
40
42 inline const char *GetString() const {
43 return detail::ConvertOffsToPtr<const char>(this, datOffs);
44 }
45
46 inline float GetFloat() const {
47 return *detail::ConvertOffsToPtr<float>(this, datOffs);
48 }
49
50 inline int GetInt() const {
51 return *detail::ConvertOffsToPtr<int>(this, datOffs);
52 }
53
54 inline const char *GetName() const {
55 return nameOffs != 0 ? detail::ConvertOffsToPtr<const char>(this, nameOffs) : nullptr;
56 }
57
58 inline ExtUserDataType GetType() const {
59 return (ExtUserDataType)type;
60 }
61
62 u32 nameOffs; // at 0x00
63 u32 datOffs; // at 0x04
64 u16 numEntries; // at 0x08
65 u8 type; // at 0x0A
66 u8 padding; // at 0x0B
67};
68
69/******************************************************************************
70 *
71 * Texture
72 *
73 ******************************************************************************/
74struct Texture {
75 ulong nameStrOffset; // at 0x0
76 u8 type; // at 0x4
77 u8 PADDING_0x5[0x8 - 0x5]; // at 0x5
78};
79/******************************************************************************
80 *
81 * TextureList
82 *
83 ******************************************************************************/
85 res::DataBlockHeader blockHeader; // at 0x0
86 u16 texNum; // at 0x8
87 u8 PADDING_0xA[0xC - 0xA]; // at 0xA
88};
89
90/******************************************************************************
91 *
92 * Font
93 *
94 ******************************************************************************/
95struct Font {
96 ulong nameStrOffset; // at 0x0
97 u8 type; // at 0x4
98 u8 PADDING_0x5[0x8 - 0x5]; // at 0x5
99};
100/******************************************************************************
101 *
102 * FontList
103 *
104 ******************************************************************************/
105struct FontList {
106 res::DataBlockHeader blockHeader; // at 0x0
107 u16 fontNum; // at 0x8
108 u8 PADDING_0xA[0xC - 0xA]; // at 0xA
109};
110
111/******************************************************************************
112 *
113 * MaterialList
114 *
115 ******************************************************************************/
117 res::DataBlockHeader blockHeader; // at 0x0
118 u16 materialNum; // at 0x8
119 u8 PADDING_0xA[0xC - 0xA]; // at 0xA
120};
121
122/******************************************************************************
123 *
124 * TexMap
125 *
126 ******************************************************************************/
127struct TexMap {
128 u16 texIdx; // at 0x0
129 u8 wrapS; // at 0x2
130 u8 wrapT; // at 0x3
131};
132
133} // namespace res
134
135/******************************************************************************
136 *
137 * ResBlockSet
138 *
139 ******************************************************************************/
141 const res::TextureList* pTextureList; // at 0x0
142 const res::FontList* pFontList; // at 0x4
143 const res::MaterialList* pMaterialList; // at 0x8
144 ResourceAccessor* pResAccessor; // at 0xC
145};
146
147/******************************************************************************
148 *
149 * MaterialResourceNum
150 *
151 ******************************************************************************/
153 ulong bits;
154
155 u8 GetTexMapNum() const {
156 return detail::GetBits(bits, 0, 4);
157 }
158 u8 GetTexSRTNum() const {
159 return detail::GetBits(bits, 4, 4);
160 }
161 u8 GetTexCoordGenNum() const {
162 return detail::GetBits(bits, 8, 4);
163 }
164 bool HasTevSwapTable() const {
165 return detail::TestBit(bits, 12);
166 }
167 u8 GetIndTexSRTNum() const {
168 return detail::GetBits(bits, 13, 2);
169 }
170 u8 GetIndTexStageNum() const {
171 return detail::GetBits(bits, 15, 3);
172 }
173 u8 GetTevStageNum() const {
174 return detail::GetBits(bits, 18, 5);
175 }
176 bool HasAlphaCompare() const {
177 return detail::TestBit(bits, 23);
178 }
179 bool HasBlendMode() const {
180 return detail::TestBit(bits, 24);
181 }
182 u8 GetChanCtrlNum() const {
183 return detail::GetBits(bits, 25, 1);
184 }
185 u8 GetMatColNum() const {
186 return detail::GetBits(bits, 27, 1);
187 }
188};
189
190} // namespace lyt
191} // namespace nw4r
192
193#endif
2D graphics drawing library.