Skip to content

Commit cb9db9c

Browse files
committed
- '-bg2tim' now extracts font and selection images
1 parent b278ff8 commit cb9db9c

1 file changed

Lines changed: 48 additions & 6 deletions

File tree

DriverImageTool/image_tool.cpp

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,10 @@ void ConvertBackgroundRaw(const char* filename, const char* extraFilename)
209209

210210
// convert background image and store
211211
{
212-
ubyte timData[64*6 * 2 * 512];
212+
ubyte timData[64*6 * 512];
213213

214-
int rect_w;
215-
int rect_h;
216-
rect_w = 64;
217-
rect_h = 256;
214+
int rect_w = 64;
215+
int rect_h = 256;
218216

219217
for (int i = 0; i < 6; i++)
220218
{
@@ -234,7 +232,51 @@ void ConvertBackgroundRaw(const char* filename, const char* extraFilename)
234232
}
235233

236234
SaveTIM_4bit(varargs("%s.TIM", filename),
237-
timData, 64 * 6 * 512, 0, 0, 384*2, 512, (ubyte*)imageClut, 1);
235+
timData, 64 * 6 * 512, 0, 0, 384*2, 512, imageClut, 1);
236+
237+
// String str = String::fromCString(filename).toLowerCase();
238+
239+
// check if it's GFX.RAW
240+
// if(str.find("gfx"))
241+
{
242+
imageClut = bgData + 0x30000 + 5 * 0x8000 + 128;
243+
244+
// extract font
245+
ubyte* bgImagePiece = bgData + 0x30000;
246+
247+
SaveTIM_4bit(varargs("%s_FONT.TIM", filename),
248+
bgImagePiece, 64*2*256, 0, 0, 256, 256, imageClut, 1);
249+
250+
imageClut += 128;
251+
bgImagePiece += 0x8000;
252+
253+
// extract selection texture
254+
SaveTIM_4bit(varargs("%s_SEL.TIM", filename),
255+
bgImagePiece, 64 * 2 * 36, 0, 0, 256, 36, imageClut, 1);
256+
}
257+
/*else // pointless to have font and selection texture as tpage, but i'll leave it here as reference code
258+
{
259+
// try extract the rest
260+
for (int i = 0; i < 6; i++)
261+
{
262+
ubyte* bgImagePiece = bgData + 0x30000 + i * 0x8000;
263+
264+
int rect_y = i / 3;
265+
int rect_x = (i - (rect_y & 1) * 3) * 128;
266+
rect_y *= 256;
267+
268+
for (int y = 0; y < rect_h; y++)
269+
{
270+
for (int x = 0; x < rect_w * 2; x++)
271+
{
272+
timData[(rect_y + y) * 64 * 6 + rect_x + x] = bgImagePiece[y * 128 + x];
273+
}
274+
}
275+
}
276+
277+
SaveTIM_4bit(varargs("%s_REST.TIM", filename),
278+
timData, 64 * 6 * 512, 0, 0, 384 * 2, 512, (ubyte*)imageClut, 1);
279+
}*/
238280
}
239281

240282
// load extra file if specified

0 commit comments

Comments
 (0)