(GX) change menu buffer back to 16-bit

This commit is contained in:
Toad King 2012-08-24 21:29:05 -04:00
parent 2554ec311d
commit 492e474826
4 changed files with 46 additions and 66 deletions

View File

@ -41,7 +41,7 @@
struct rgui_handle
{
uint32_t *frame_buf;
uint16_t *frame_buf;
size_t frame_buf_pitch;
const uint8_t *font_buf;
@ -56,8 +56,8 @@ struct rgui_handle
char path_buf[PATH_MAX];
uint32_t font_white[256][FONT_HEIGHT][FONT_WIDTH];
uint32_t font_green[256][FONT_HEIGHT][FONT_WIDTH];
uint16_t font_white[256][FONT_HEIGHT][FONT_WIDTH];
uint16_t font_green[256][FONT_HEIGHT][FONT_WIDTH];
};
static const char *rgui_device_labels[] = {
@ -96,8 +96,8 @@ static inline bool rgui_is_viewport_menu(rgui_file_type_t menu_type)
return (menu_type == RGUI_SETTINGS_CUSTOM_VIEWPORT || menu_type == RGUI_SETTINGS_CUSTOM_VIEWPORT_2);
}
static void copy_glyph(uint32_t glyph_white[FONT_HEIGHT][FONT_WIDTH],
uint32_t glyph_green[FONT_HEIGHT][FONT_WIDTH],
static void copy_glyph(uint16_t glyph_white[FONT_HEIGHT][FONT_WIDTH],
uint16_t glyph_green[FONT_HEIGHT][FONT_WIDTH],
const uint8_t *buf)
{
for (int y = 0; y < FONT_HEIGHT; y++)
@ -109,8 +109,8 @@ static void copy_glyph(uint32_t glyph_white[FONT_HEIGHT][FONT_WIDTH],
((uint32_t)buf[3 * (-y * 256 + x) + 1] << 8) |
((uint32_t)buf[3 * (-y * 256 + x) + 2] << 16);
glyph_white[y][x] = col == 0xff ? 0 : 0xffffffff;
glyph_green[y][x] = col == 0xff ? 0 : (255 << 24) | (40 << 16) | (160 << 8) | (40 << 0);
glyph_white[y][x] = (col == 0xff) ? 0 : 0x7fff;
glyph_green[y][x] = (col == 0xff) ? 0 : (3 << 0) | (10 << 4) | (3 << 8) | (7 << 12);
}
}
}
@ -128,7 +128,7 @@ static void init_font(rgui_handle_t *rgui, const char *path)
}
rgui_handle_t *rgui_init(const char *base_path,
uint32_t *buf, size_t buf_pitch,
uint16_t *buf, size_t buf_pitch,
const uint8_t *font_buf,
rgui_folder_enum_cb_t folder_cb, void *userdata)
{
@ -157,28 +157,26 @@ void rgui_free(rgui_handle_t *rgui)
free(rgui);
}
static uint32_t gray_filler(unsigned x, unsigned y)
static uint16_t gray_filler(unsigned x, unsigned y)
{
x >>= 1;
y >>= 1;
unsigned col = ((x + y) & 1) + 1;
col <<= 4;
return (224 << 24) | (col << 16) | (col << 8) | (col << 0);
return (6 << 12) | (col << 8) | (col << 4) | (col << 0);
}
static uint32_t green_filler(unsigned x, unsigned y)
static uint16_t green_filler(unsigned x, unsigned y)
{
x >>= 1;
y >>= 1;
unsigned col = ((x + y) & 1) + 1;
col <<= 3;
return (224 << 24) | (col << 16) | (col << 10) | (col << 0);
return (6 << 12) | (col << 8) | (col << 5) | (col << 0);
}
static void fill_rect(uint32_t *buf, unsigned pitch,
static void fill_rect(uint16_t *buf, unsigned pitch,
unsigned x, unsigned y,
unsigned width, unsigned height,
uint32_t (*col)(unsigned x, unsigned y))
uint16_t (*col)(unsigned x, unsigned y))
{
for (unsigned j = y; j < y + height; j++)
for (unsigned i = x; i < x + width; i++)
@ -194,7 +192,7 @@ static void blit_line(rgui_handle_t *rgui,
{
for (unsigned i = 0; i < FONT_WIDTH; i++)
{
uint32_t col = green ?
uint16_t col = green ?
rgui->font_green[(unsigned char)*message][j][i] :
rgui->font_white[(unsigned char)*message][j][i];

View File

@ -103,7 +103,7 @@ typedef bool (*rgui_folder_enum_cb_t)(const char *directory,
#define RGUI_HEIGHT 240
rgui_handle_t *rgui_init(const char *base_path,
uint32_t *framebuf, size_t framebuf_pitch,
uint16_t *framebuf, size_t framebuf_pitch,
const uint8_t *font_buf,
rgui_folder_enum_cb_t folder_cb, void *userdata);

View File

@ -49,7 +49,7 @@
FILE * log_fp;
#endif
uint32_t menu_framebuf[320 * 240];
uint16_t menu_framebuf[320 * 240];
rgui_handle_t *rgui;
#if defined(HAVE_LOGGER) || defined(HAVE_FILE_LOGGER)
@ -423,7 +423,7 @@ int main(void)
driver.video = &video_gx;
gx_video_t *gx = (gx_video_t*)driver.video_data;
gx->menu_data = menu_framebuf;
gx->menu_data = (uint32_t *) menu_framebuf;
char tmp_path[PATH_MAX];
const char *extension = default_paths.executable_extension;

View File

@ -41,7 +41,7 @@ struct
struct
{
uint32_t data[240 * 320];
uint32_t data[240 * 160];
GXTexObj obj;
} menu_tex ATTRIBUTE_ALIGN(32);
@ -155,7 +155,7 @@ static void init_texture(unsigned width, unsigned height)
GX_InitTexObj(&g_tex.obj, g_tex.data, width, height, GX_TF_RGB5A3, GX_CLAMP, GX_CLAMP, GX_FALSE);
GX_InitTexObjLOD(&g_tex.obj, g_filter, g_filter, 0, 0, 0, GX_TRUE, GX_FALSE, GX_ANISO_1);
GX_InitTexObj(&menu_tex.obj, menu_tex.data, 320, 240, GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE);
GX_InitTexObj(&menu_tex.obj, menu_tex.data, 320, 240, GX_TF_RGB5A3, GX_CLAMP, GX_CLAMP, GX_FALSE);
GX_InitTexObjLOD(&menu_tex.obj, g_filter, g_filter, 0, 0, 0, GX_TRUE, GX_FALSE, GX_ANISO_1);
GX_InvalidateTexAll();
}
@ -299,12 +299,10 @@ static void gx_start(void)
#ifdef ASM_BLITTER
static __attribute__ ((noinline)) void update_texture_asm(const uint32_t *src,
unsigned width, unsigned height, unsigned pitch)
static __attribute__ ((noinline)) void update_texture_asm(const uint32_t *src, const uint32_t *dst,
unsigned width, unsigned height, unsigned pitch, unsigned ormask)
{
register uint32_t tmp0, tmp1, tmp2, tmp3, line2, line2b, line3, line3b, line4, line4b, line5;
register uint32_t ormask = 0x80008000u;
register uint32_t *dst = g_tex.data;
__asm__ __volatile__ (
" srwi %[width], %[width], 2 \n"
@ -379,12 +377,9 @@ static __attribute__ ((noinline)) void update_texture_asm(const uint32_t *src,
#endif
// Set MSB to get full RGB555.
#define RGB15toRGB5A3(col) ((col) | 0x80008000u)
#define BLIT_LINE(off) \
{ \
const uint32_t *tmp_src = src; \
const uint32_t *tmp_src = src2; \
uint32_t *tmp_dst = dst; \
for (unsigned x = 0; x < width2; x += 8, tmp_src += 8, tmp_dst += 32) \
{ \
@ -397,21 +392,7 @@ static __attribute__ ((noinline)) void update_texture_asm(const uint32_t *src,
tmp_dst[24 + off] = RGB15toRGB5A3(tmp_src[6]); \
tmp_dst[25 + off] = RGB15toRGB5A3(tmp_src[7]); \
} \
src += pitch; \
}
#define BLIT_16(x) \
{ \
block[0 + 0 ] = line[x][0]; \
block[0 + 16] = line[x][1]; \
block[1 + 0 ] = line[x][2]; \
block[1 + 16] = line[x][3]; \
block[2 + 0 ] = line[x][4]; \
block[2 + 16] = line[x][5]; \
block[3 + 0 ] = line[x][6]; \
block[3 + 16] = line[x][7]; \
block += 4; \
line[x] += 8; \
src2 += tmp_pitch; \
}
static void update_texture(const uint32_t *src,
@ -421,51 +402,52 @@ static void update_texture(const uint32_t *src,
#ifdef ASM_BLITTER
if (width && height && !(width & 3) && !(height & 3))
{
update_texture_asm(src, width, height, pitch);
update_texture_asm(src, g_tex.data, width, height, pitch, 0x80008000U);
}
else
#endif
{
pitch >>= 2;
width &= ~15;
height &= ~3;
unsigned tmp_pitch = pitch >> 2;
unsigned width2 = width >> 1;
// Texture data is 4x4 tiled @ 15bpp.
// Use 32-bit to transfer more data per cycle.
const uint32_t *src2 = src;
uint32_t *dst = g_tex.data;
for (unsigned i = 0; i < height; i += 4, dst += 4 * width2)
{
// Set MSB to get full RGB555.
#define RGB15toRGB5A3(col) ((col) | 0x80008000u)
BLIT_LINE(0)
BLIT_LINE(2)
BLIT_LINE(4)
BLIT_LINE(6)
#undef RGB15toRGB5A3
}
}
if(gx->menu_render)
{
uint16_t *block = (uint16_t *) menu_tex.data;
uint16_t *line[4];
for (uint32_t y = 0; y < 240; y += 4)
{
uint32_t *menu_data = gx->menu_data;
// fetch the next 4 scanlines
line[0] = (uint16_t *) &menu_data[(y + 0) * 320];
line[1] = (uint16_t *) &menu_data[(y + 1) * 320];
line[2] = (uint16_t *) &menu_data[(y + 2) * 320];
line[3] = (uint16_t *) &menu_data[(y + 3) * 320];
#ifdef ASM_BLITTER
update_texture_asm(gx->menu_data, menu_tex.data, 320, 240, 320 * 2, 0x00000000U);
#else
unsigned tmp_pitch = (320 * 2) >> 2;
unsigned width2 = 320 >> 1;
for (unsigned x = 0; x < 320; x += 4)
const uint32_t *src2 = gx->menu_data;
uint32_t *dst = menu_tex.data;
for (unsigned i = 0; i < 240; i += 4, dst += 4 * width2)
{
BLIT_16(0)
BLIT_16(1)
BLIT_16(2)
BLIT_16(3)
block += 16;
}
#define RGB15toRGB5A3(col) (col)
BLIT_LINE(0)
BLIT_LINE(2)
BLIT_LINE(4)
BLIT_LINE(6)
#undef RGB15toRGB5A3
}
#endif
}
init_texture(width, height);