Banners should use RGBA4444 color.
This commit is contained in:
parent
d7e741c9b3
commit
65d12313e6
5 changed files with 32 additions and 20 deletions
|
@ -31,7 +31,7 @@ u8* build_cbmd_data(CBMD cbmd, u32* size, bool bnr) {
|
||||||
|
|
||||||
u32 pad = 0;
|
u32 pad = 0;
|
||||||
if(bnr) {
|
if(bnr) {
|
||||||
pad = 16 - (offset % 16);
|
pad = 0x10 - (offset % 0x10);
|
||||||
offset += pad;
|
offset += pad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,6 @@ typedef struct {
|
||||||
u32 totalChannels;
|
u32 totalChannels;
|
||||||
} InfoHeader;
|
} InfoHeader;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
char magic[4] = {'D', 'A', 'T', 'A'};
|
|
||||||
u32 length;
|
|
||||||
} DataHeader;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u32 flags = 0x7100;
|
u32 flags = 0x7100;
|
||||||
u32 offset;
|
u32 offset;
|
||||||
|
@ -48,6 +43,11 @@ typedef struct {
|
||||||
u32 padding = 0;
|
u32 padding = 0;
|
||||||
} ChannelData;
|
} ChannelData;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char magic[4] = {'D', 'A', 'T', 'A'};
|
||||||
|
u32 length;
|
||||||
|
} DataHeader;
|
||||||
|
|
||||||
u8* build_cwav(WAV wav, u32* size) {
|
u8* build_cwav(WAV wav, u32* size) {
|
||||||
Header header;
|
Header header;
|
||||||
u32 offset = sizeof(Header);
|
u32 offset = sizeof(Header);
|
||||||
|
|
|
@ -7,14 +7,23 @@ 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,
|
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 };
|
36, 37, 44, 45, 38, 39, 46, 47, 52, 53, 60, 61, 54, 55, 62, 63 };
|
||||||
|
|
||||||
u16 rgba_to_rgb565(u8 r, u8 g, u8 b, u8 a) {
|
u16 pack_color(u8 r, u8 g, u8 b, u8 a, PixelFormat format) {
|
||||||
r = (u8) (1.0f * r * a / 255.0f) >> 3;
|
if(format == RGB565) {
|
||||||
g = (u8) (1.0f * g * a / 255.0f) >> 2;
|
float alpha = a / 255.0f;
|
||||||
b = (u8) (1.0f * b * a / 255.0f) >> 3;
|
r = (u8) (r * alpha) >> 3;
|
||||||
return (r << 11) | (g << 5) | b;
|
g = (u8) (g * alpha) >> 2;
|
||||||
|
b = (u8) (b * alpha) >> 3;
|
||||||
|
return (r << 11) | (g << 5) | b;
|
||||||
|
} else if(format == RGBA4444) {
|
||||||
|
r >>= 4;
|
||||||
|
g >>= 4;
|
||||||
|
b >>= 4;
|
||||||
|
a >>= 4;
|
||||||
|
return r << 12 | g << 8 | b << 4 | a;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u16* image_to_tiles(const char* image, u32 width, u32 height, u32* size) {
|
u16* image_to_tiles(const char* image, u32 width, u32 height, PixelFormat format, u32* size) {
|
||||||
unsigned char* img;
|
unsigned char* img;
|
||||||
unsigned int imgWidth, imgHeight;
|
unsigned int imgWidth, imgHeight;
|
||||||
if(lodepng_decode32_file(&img, &imgWidth, &imgHeight, image)) {
|
if(lodepng_decode32_file(&img, &imgWidth, &imgHeight, image)) {
|
||||||
|
@ -44,7 +53,7 @@ u16* image_to_tiles(const char* image, u32 width, u32 height, u32* size) {
|
||||||
u32 yy = (u32) (TILE_ORDER[k] >> 3);
|
u32 yy = (u32) (TILE_ORDER[k] >> 3);
|
||||||
|
|
||||||
u8* pixel = img + (((y + yy) * width + (x + xx)) * 4);
|
u8* pixel = img + (((y + yy) * width + (x + xx)) * 4);
|
||||||
converted[n++] = rgba_to_rgb565(pixel[0], pixel[1], pixel[2], pixel[3]);
|
converted[n++] = pack_color(pixel[0], pixel[1], pixel[2], pixel[3], format);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,11 +66,9 @@ u16* image_to_tiles(const char* image, u32 width, u32 height, u32* size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void utf8_to_utf16(u16* dst, const char* src, size_t max_len) {
|
void utf8_to_utf16(u16* dst, const char* src, size_t max_len) {
|
||||||
u8* u8dst = (u8*) dst;
|
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
while(src[n]) {
|
while(src[n]) {
|
||||||
u8dst[n * 2] = (u8) src[n];
|
dst[n] = (u16) src[n] << 8;
|
||||||
u8dst[n * 2 + 1] = 0;
|
|
||||||
if(n++ >= max_len) {
|
if(n++ >= max_len) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,13 @@
|
||||||
|
|
||||||
#include "../types.h"
|
#include "../types.h"
|
||||||
|
|
||||||
u16 rgba_to_rgb565(u8 r, u8 g, u8 b, u8 a);
|
typedef enum {
|
||||||
u16* image_to_tiles(const char* image, u32 width, u32 height, u32* size);
|
RGB565,
|
||||||
|
RGBA4444
|
||||||
|
} PixelFormat;
|
||||||
|
|
||||||
|
u16 pack_color(u8 r, u8 g, u8 b, u8 a, PixelFormat format);
|
||||||
|
u16* image_to_tiles(const char* image, u32 width, u32 height, PixelFormat format, u32* size);
|
||||||
void utf8_to_utf16(u16* dst, const char* src, size_t max_len);
|
void utf8_to_utf16(u16* dst, const char* src, size_t max_len);
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
u8* convert_to_cgfx(const char* image, u32 width, u32 height, u32* size) {
|
u8* convert_to_cgfx(const char* image, u32 width, u32 height, u32* size) {
|
||||||
u32 convertedSize = 0;
|
u32 convertedSize = 0;
|
||||||
u16* converted = image_to_tiles(image, width, height, &convertedSize);
|
u16* converted = image_to_tiles(image, width, height, RGBA4444, &convertedSize);
|
||||||
if(converted == NULL) {
|
if(converted == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ int make_banner(const char* image, const char* audio, char* cgfxFile, char* cwav
|
||||||
}
|
}
|
||||||
|
|
||||||
int make_smdh(char* shortDescription, char* longDescription, char* publisher, char* icon, char* output) {
|
int make_smdh(char* shortDescription, char* longDescription, char* publisher, char* icon, char* output) {
|
||||||
u16* icon48 = image_to_tiles(icon, 48, 48, NULL);
|
u16* icon48 = image_to_tiles(icon, 48, 48, RGB565, NULL);
|
||||||
if(icon48 == NULL) {
|
if(icon48 == NULL) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue