tweaking pandora frontend

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@874 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2010-05-31 22:12:46 +00:00
parent 03065bb617
commit be672de78d
16 changed files with 378 additions and 144 deletions

View file

@ -187,11 +187,11 @@ static void menu_draw_selection(int x, int y, int w)
if (menu_sel_color < 0) return; // no selection hilight
if (y > 0) y--;
dest = (unsigned short *)g_screen_ptr + x + y * g_screen_width + 14;
dest = (unsigned short *)g_screen_ptr + x + y * g_screen_width + me_mfont_w * 2 - 2;
for (h = me_mfont_h + 1; h > 0; h--)
{
dst = dest;
for (i = w - 14; i > 0; i--)
for (i = w - (me_mfont_w * 2 - 2); i > 0; i--)
*dst++ = menu_sel_color;
dest += g_screen_width;
}
@ -268,12 +268,13 @@ void menu_init(void)
// load custom font and selector (stored as 1st symbol in font table)
emu_make_path(buff, "skin/font.png", sizeof(buff));
readpng(menu_font_data, buff, READPNG_FONT);
readpng(menu_font_data, buff, READPNG_FONT,
MENU_X2 ? 256 : 128, MENU_X2 ? 320 : 160);
// default selector symbol is '>'
memcpy(menu_font_data, menu_font_data + ((int)'>') * me_mfont_w * me_mfont_h / 2,
me_mfont_w * me_mfont_h / 2);
emu_make_path(buff, "skin/selector.png", sizeof(buff));
readpng(menu_font_data, buff, READPNG_SELECTOR);
readpng(menu_font_data, buff, READPNG_SELECTOR, MENU_X2 ? 16 : 8, MENU_X2 ? 20 : 10);
// load custom colors
emu_make_path(buff, "skin/skin.txt", sizeof(buff));
@ -343,7 +344,7 @@ static void menu_enter(int is_rom_loaded)
// should really only happen once, on startup..
emu_make_path(buff, "skin/background.png", sizeof(buff));
if (readpng(g_menubg_ptr, buff, READPNG_BG) < 0)
if (readpng(g_menubg_ptr, buff, READPNG_BG, g_screen_width, g_screen_height) < 0)
memset(g_menubg_ptr, 0, g_screen_width * g_screen_height * 2);
}
@ -378,11 +379,11 @@ static int me_count(const menu_entry *ent)
static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void))
{
const menu_entry *ent;
const menu_entry *ent, *ent_sel = entries;
int x, y, w = 0, h = 0;
int offs, col2_offs = 27 * me_mfont_w;
int vi_sel_ln = 0;
const char *name;
int asel = 0;
int i, n;
/* calculate size of menu rect */
@ -393,8 +394,10 @@ static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void))
if (!ent->enabled)
continue;
if (i == sel)
asel = n;
if (i == sel) {
ent_sel = ent;
vi_sel_ln = n;
}
name = NULL;
wt = strlen(ent->name) * me_mfont_w;
@ -450,7 +453,7 @@ static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void))
/* draw */
plat_video_menu_begin();
menu_draw_selection(x, y + asel * me_mfont_h, w);
menu_draw_selection(x, y + vi_sel_ln * me_mfont_h, w);
x += me_mfont_w * 2;
for (ent = entries; ent->name; ent++)
@ -517,13 +520,13 @@ static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void))
if (plat_get_ticks_ms() - menu_error_time > 2048)
menu_error_msg[0] = 0;
}
else if (entries[asel].help != NULL) {
const char *tmp = entries[asel].help;
else if (ent_sel->help != NULL) {
const char *tmp = ent_sel->help;
int l;
for (l = 0; tmp != NULL && *tmp != 0; l++)
tmp = strchr(tmp + 1, '\n');
if (h >= l * me_sfont_h + 4)
for (tmp = entries[asel].help; l > 0; l--, tmp = strchr(tmp, '\n') + 1)
for (tmp = ent_sel->help; l > 0; l--, tmp = strchr(tmp, '\n') + 1)
smalltext_out16(5, g_screen_height - (l * me_sfont_h + 4), tmp, 0xffff);
}

View file

@ -4,15 +4,7 @@
#include "readpng.h"
#include "lprintf.h"
#ifdef PSP
#define BG_WIDTH 480
#define BG_HEIGHT 272
#else
#define BG_WIDTH 320
#define BG_HEIGHT 240
#endif
int readpng(void *dest, const char *fname, readpng_what what)
int readpng(void *dest, const char *fname, readpng_what what, int req_w, int req_h)
{
FILE *fp;
png_structp png_ptr = NULL;
@ -71,9 +63,11 @@ int readpng(void *dest, const char *fname, readpng_what what)
break;
}
height = info_ptr->height;
if (height > BG_HEIGHT) height = BG_HEIGHT;
if (height > req_h)
height = req_h;
width = info_ptr->width;
if (width > BG_WIDTH) width = BG_WIDTH;
if (width > req_w)
width = req_w;
for (h = 0; h < height; h++)
{
@ -88,7 +82,7 @@ int readpng(void *dest, const char *fname, readpng_what what)
#endif
src += 3;
}
dst += BG_WIDTH - width;
dst += req_w - width;
}
break;
}
@ -97,10 +91,10 @@ int readpng(void *dest, const char *fname, readpng_what what)
{
int x, y, x1, y1;
unsigned char *dst = dest;
if (info_ptr->width != 128 || info_ptr->height != 160)
if (info_ptr->width != req_w || info_ptr->height != req_h)
{
lprintf(__FILE__ ": unexpected font image size %ix%i, needed 128x160\n",
(int)info_ptr->width, (int)info_ptr->height);
lprintf(__FILE__ ": unexpected font image size %dx%d, needed %dx%d\n",
(int)info_ptr->width, (int)info_ptr->height, req_w, req_h);
break;
}
if (info_ptr->pixel_depth != 8)
@ -112,10 +106,13 @@ int readpng(void *dest, const char *fname, readpng_what what)
{
for (x = 0; x < 16; x++)
{
for (y1 = 0; y1 < 10; y1++)
/* 16x16 grid of syms */
int sym_w = req_w / 16;
int sym_h = req_h / 16;
for (y1 = 0; y1 < sym_h; y1++)
{
unsigned char *src = row_ptr[y*10 + y1] + x*8;
for (x1 = 8/2; x1 > 0; x1--, src+=2)
unsigned char *src = row_ptr[y*sym_h + y1] + x*sym_w;
for (x1 = sym_w/2; x1 > 0; x1--, src+=2)
*dst++ = ((src[0]^0xff) & 0xf0) | ((src[1]^0xff) >> 4);
}
}
@ -127,10 +124,10 @@ int readpng(void *dest, const char *fname, readpng_what what)
{
int x1, y1;
unsigned char *dst = dest;
if (info_ptr->width != 8 || info_ptr->height != 10)
if (info_ptr->width != req_w || info_ptr->height != req_h)
{
lprintf(__FILE__ ": unexpected selector image size %ix%i, needed 8x10\n",
(int)info_ptr->width, (int)info_ptr->height);
lprintf(__FILE__ ": unexpected selector image size %ix%i, needed %dx%d\n",
(int)info_ptr->width, (int)info_ptr->height, req_w, req_h);
break;
}
if (info_ptr->pixel_depth != 8)
@ -138,20 +135,18 @@ int readpng(void *dest, const char *fname, readpng_what what)
lprintf(__FILE__ ": selector image uses %ibpp, needed 8bpp\n", info_ptr->pixel_depth);
break;
}
for (y1 = 0; y1 < 10; y1++)
for (y1 = 0; y1 < req_h; y1++)
{
unsigned char *src = row_ptr[y1];
for (x1 = 8/2; x1 > 0; x1--, src+=2)
for (x1 = req_w/2; x1 > 0; x1--, src+=2)
*dst++ = ((src[0]^0xff) & 0xf0) | ((src[1]^0xff) >> 4);
}
break;
}
case READPNG_320_24:
case READPNG_480_24:
case READPNG_24:
{
int height, width, h;
int needw = (what == READPNG_480_24) ? 480 : 320;
unsigned char *dst = dest;
if (info_ptr->pixel_depth != 24)
{
@ -159,15 +154,17 @@ int readpng(void *dest, const char *fname, readpng_what what)
break;
}
height = info_ptr->height;
if (height > 240) height = 240;
if (height > req_h)
height = req_h;
width = info_ptr->width;
if (width > needw) width = needw;
if (width > req_w)
width = req_w;
for (h = 0; h < height; h++)
{
int len = width;
unsigned char *src = row_ptr[h];
dst += (needw - width) * 3;
dst += (req_w - width) * 3;
for (len = width; len > 0; len--, dst+=3, src+=3)
dst[0] = src[2], dst[1] = src[1], dst[2] = src[0];
}

View file

@ -3,8 +3,7 @@ typedef enum
READPNG_BG = 1,
READPNG_FONT,
READPNG_SELECTOR,
READPNG_320_24,
READPNG_480_24
READPNG_24,
}
readpng_what;
@ -12,7 +11,7 @@ readpng_what;
extern "C" {
#endif
int readpng(void *dest, const char *fname, readpng_what what);
int readpng(void *dest, const char *fname, readpng_what what, int w, int h);
#ifdef __cplusplus
}