Add support for supplying exiting CGFX and CWAV files to makebanner, add command for creating SMDH files.
This commit is contained in:
@@ -7,7 +7,14 @@ u8 TILE_ORDER[64] = { 0, 1, 8, 9, 2, 3, 10, 11, 16, 17, 24, 25, 18, 19, 26
|
||||
32, 33, 40, 41, 34, 35, 42, 43, 48, 49, 56, 57, 50, 51, 58, 59,
|
||||
36, 37, 44, 45, 38, 39, 46, 47, 52, 53, 60, 61, 54, 55, 62, 63 };
|
||||
|
||||
u8* image_to_tiles(const char* image, u32 width, u32 height, u32* size) {
|
||||
u16 rgba_to_rgb565(u8 r, u8 g, u8 b, u8 a) {
|
||||
r = (u8) (1.0f * r * a / 255.0f) >> 3;
|
||||
g = (u8) (1.0f * g * a / 255.0f) >> 2;
|
||||
b = (u8) (1.0f * b * a / 255.0f) >> 3;
|
||||
return (r << 11) | (g << 5) | b;
|
||||
}
|
||||
|
||||
u16* image_to_tiles(const char* image, u32 width, u32 height, u32* size) {
|
||||
unsigned char* img;
|
||||
unsigned int imgWidth, imgHeight;
|
||||
if(lodepng_decode32_file(&img, &imgWidth, &imgHeight, image)) {
|
||||
@@ -28,7 +35,7 @@ u8* image_to_tiles(const char* image, u32 width, u32 height, u32* size) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
u8* converted = (u8*) malloc(width * height * 2);
|
||||
u16* converted = (u16*) malloc(width * height * sizeof(u16));
|
||||
u32 n = 0;
|
||||
for(int y = 0; y < height; y += 8) {
|
||||
for(int x = 0; x < width; x += 8) {
|
||||
@@ -37,15 +44,26 @@ u8* image_to_tiles(const char* image, u32 width, u32 height, u32* size) {
|
||||
u32 yy = (u32) (TILE_ORDER[k] >> 3);
|
||||
|
||||
u8* pixel = img + (((y + yy) * width + (x + xx)) * 4);
|
||||
converted[n++] = ((pixel[2] >> 4) << 4) | (pixel[3] >> 4);
|
||||
converted[n++] = ((pixel[0] >> 4) << 4) | (pixel[1] >> 4);
|
||||
converted[n++] = rgba_to_rgb565(pixel[0], pixel[1], pixel[2], pixel[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(size != NULL) {
|
||||
*size = width * height * 2;
|
||||
*size = width * height * (u32) sizeof(u16);
|
||||
}
|
||||
|
||||
return converted;
|
||||
}
|
||||
|
||||
void utf8_to_utf16(u16* dst, const char* src, size_t max_len) {
|
||||
u8* u8dst = (u8*) dst;
|
||||
size_t n = 0;
|
||||
while(src[n]) {
|
||||
u8dst[n * 2] = (u8) src[n];
|
||||
u8dst[n * 2 + 1] = 0;
|
||||
if(n++ >= max_len) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user