(GX) support more resolution modes, attempt fix at clearing garbage left during screen switch

This commit is contained in:
Toad King 2012-09-12 09:36:18 -04:00
parent 50d8520085
commit c69b3ca938
3 changed files with 60 additions and 52 deletions

View File

@ -38,24 +38,34 @@
#ifdef GEKKO #ifdef GEKKO
enum enum
{ {
GX_RESOLUTIONS_224 = 0, GX_RESOLUTIONS_384_224 = 0,
GX_RESOLUTIONS_239, GX_RESOLUTIONS_512_224,
GX_RESOLUTIONS_240, GX_RESOLUTIONS_640_224,
GX_RESOLUTIONS_288, GX_RESOLUTIONS_512_239,
GX_RESOLUTIONS_448, GX_RESOLUTIONS_512_240,
GX_RESOLUTIONS_478, GX_RESOLUTIONS_640_240,
GX_RESOLUTIONS_640_288,
GX_RESOLUTIONS_384_448,
GX_RESOLUTIONS_512_448,
GX_RESOLUTIONS_640_448,
GX_RESOLUTIONS_512_478,
GX_RESOLUTIONS_DEFAULT, GX_RESOLUTIONS_DEFAULT,
GX_RESOLUTIONS_LAST, GX_RESOLUTIONS_LAST,
}; };
unsigned rgui_gx_resolutions[GX_RESOLUTIONS_LAST] = { unsigned rgui_gx_resolutions[GX_RESOLUTIONS_LAST][2] = {
224, { 384, 224 },
239, { 512, 224 },
240, { 640, 224 },
288, { 512, 239 },
448, { 512, 240 },
478, { 640, 240 },
0, { 640, 288 },
{ 384, 448 },
{ 512, 448 },
{ 640, 448 },
{ 512, 478 },
{ 0, 0 }
}; };
unsigned rgui_current_gx_resolution = GX_RESOLUTIONS_DEFAULT; unsigned rgui_current_gx_resolution = GX_RESOLUTIONS_DEFAULT;
@ -568,7 +578,7 @@ static void rgui_settings_toggle_setting(rgui_file_type_t setting, rgui_action_t
if(rgui_current_gx_resolution > 0) if(rgui_current_gx_resolution > 0)
{ {
rgui_current_gx_resolution--; rgui_current_gx_resolution--;
gx_set_video_mode(rgui_gx_resolutions[rgui_current_gx_resolution]); gx_set_video_mode(rgui_gx_resolutions[rgui_current_gx_resolution][0], rgui_gx_resolutions[rgui_current_gx_resolution][1]);
} }
} }
else if (action == RGUI_ACTION_RIGHT) else if (action == RGUI_ACTION_RIGHT)
@ -576,7 +586,7 @@ static void rgui_settings_toggle_setting(rgui_file_type_t setting, rgui_action_t
if(rgui_current_gx_resolution < GX_RESOLUTIONS_LAST - 1) if(rgui_current_gx_resolution < GX_RESOLUTIONS_LAST - 1)
{ {
rgui_current_gx_resolution++; rgui_current_gx_resolution++;
gx_set_video_mode(rgui_gx_resolutions[rgui_current_gx_resolution]); gx_set_video_mode(rgui_gx_resolutions[rgui_current_gx_resolution][0], rgui_gx_resolutions[rgui_current_gx_resolution][1]);
} }
} }
break; break;

View File

@ -83,16 +83,14 @@ static void retrace_callback(u32 retrace_count)
LWP_ThreadSignal(g_video_cond); LWP_ThreadSignal(g_video_cond);
} }
void gx_set_video_mode(unsigned lines) void gx_set_video_mode(unsigned fbWidth, unsigned lines)
{ {
VIDEO_SetBlack(true); VIDEO_SetBlack(true);
VIDEO_ClearFrameBuffer(&gx_mode, g_framebuf[0], COLOR_BLACK);
VIDEO_ClearFrameBuffer(&gx_mode, g_framebuf[1], COLOR_BLACK);
VIDEO_Flush(); VIDEO_Flush();
gx_video_t *gx = (gx_video_t*)driver.video_data; gx_video_t *gx = (gx_video_t*)driver.video_data;
unsigned fbWidth = 640;
unsigned modetype; unsigned modetype;
unsigned viHeightMultiplier = 1; unsigned viHeightMultiplier = 1;
unsigned viWidth = 640;
#if defined(HW_RVL) #if defined(HW_RVL)
bool progressive = CONF_GetProgressiveScan() > 0 && VIDEO_HaveComponentCable(); bool progressive = CONF_GetProgressiveScan() > 0 && VIDEO_HaveComponentCable();
unsigned tvmode; unsigned tvmode;
@ -137,40 +135,36 @@ void gx_set_video_mode(unsigned lines)
break; break;
} }
switch (lines) if (lines == 0 || fbWidth == 0)
{ {
case 224: VIDEO_GetPreferredMode(&gx_mode);
case 239: goto config;
fbWidth = 512; }
modetype = VI_NON_INTERLACE;
viHeightMultiplier = 2;
break;
case 448:
case 478:
fbWidth = 512;
modetype = (progressive) ? VI_PROGRESSIVE : VI_INTERLACE;
break;
case 240:
case 288:
// don't do 288 progressive on NTSC or EURGB60, but the video corruption it makes is pretty awesome
if (lines == 288 && (tvmode == VI_NTSC || tvmode == VI_EURGB60))
lines = 240;
modetype = VI_NON_INTERLACE; if (lines <= max_height / 2)
viHeightMultiplier = 2; {
break; modetype = VI_NON_INTERLACE;
default: viHeightMultiplier = 2;
gx_mode = *VIDEO_GetPreferredMode(NULL); }
goto config; else
{
modetype = (progressive) ? VI_PROGRESSIVE : VI_INTERLACE;
}
if (lines > max_height)
lines = max_height;
if (fbWidth > max_width)
{
fbWidth = viWidth = max_width;
} }
gx_mode.viTVMode = VI_TVMODE(tvmode, modetype); gx_mode.viTVMode = VI_TVMODE(tvmode, modetype);
gx_mode.fbWidth = fbWidth; gx_mode.fbWidth = fbWidth;
gx_mode.efbHeight = lines; gx_mode.efbHeight = lines;
gx_mode.xfbHeight = lines; gx_mode.xfbHeight = lines;
gx_mode.viXOrigin = (max_width - 640) / 2; gx_mode.viWidth = viWidth;
gx_mode.viWidth = 640;
gx_mode.viHeight = lines * viHeightMultiplier; gx_mode.viHeight = lines * viHeightMultiplier;
gx_mode.viXOrigin = (max_width - gx_mode.viWidth) / 2;
if (viHeightMultiplier == 2) if (viHeightMultiplier == 2)
gx_mode.viYOrigin = (max_height / 2 - gx_mode.viHeight / 2) / 2; gx_mode.viYOrigin = (max_height / 2 - gx_mode.viHeight / 2) / 2;
else else
@ -221,7 +215,9 @@ config:
RGUI_WIDTH = 400; RGUI_WIDTH = 400;
VIDEO_Configure(&gx_mode); VIDEO_Configure(&gx_mode);
VIDEO_SetNextFramebuffer(g_framebuf[g_current_framebuf]); VIDEO_ClearFrameBuffer(&gx_mode, g_framebuf[0], COLOR_BLACK);
VIDEO_ClearFrameBuffer(&gx_mode, g_framebuf[1], COLOR_BLACK);
VIDEO_SetNextFramebuffer(g_framebuf[0]);
VIDEO_SetPostRetraceCallback(retrace_callback); VIDEO_SetPostRetraceCallback(retrace_callback);
VIDEO_SetBlack(false); VIDEO_SetBlack(false);
VIDEO_Flush(); VIDEO_Flush();
@ -246,8 +242,8 @@ config:
const char *gx_get_video_mode() const char *gx_get_video_mode()
{ {
static char format[5]; static char format[16];
snprintf(format, sizeof(format), "%.3u%c", gx_mode.efbHeight, (gx_mode.viTVMode & 3) == VI_INTERLACE ? 'i' : 'p'); snprintf(format, sizeof(format), "%.3ux%.3u%c", gx_mode.fbWidth, gx_mode.efbHeight, (gx_mode.viTVMode & 3) == VI_INTERLACE ? 'i' : 'p');
return format; return format;
} }
@ -276,8 +272,8 @@ static void setup_video_mode()
g_orientation = ORIENTATION_NORMAL; g_orientation = ORIENTATION_NORMAL;
LWP_InitQueue(&g_video_cond); LWP_InitQueue(&g_video_cond);
gx_mode = *VIDEO_GetPreferredMode(NULL); VIDEO_GetPreferredMode(&gx_mode);
gx_set_video_mode(0); gx_set_video_mode(0, 0);
} }
static void init_texture(unsigned width, unsigned height) static void init_texture(unsigned width, unsigned height)
@ -790,6 +786,7 @@ static bool gx_frame(void *data, const void *frame,
gx_video_t *gx = (gx_video_t*)driver.video_data; gx_video_t *gx = (gx_video_t*)driver.video_data;
bool menu_render = gx->menu_render; bool menu_render = gx->menu_render;
bool should_resize = gx->should_resize; bool should_resize = gx->should_resize;
u8 clear_efb = GX_FALSE;
(void)data; (void)data;
@ -811,6 +808,7 @@ static bool gx_frame(void *data, const void *frame,
if(should_resize) if(should_resize)
{ {
gx_resize(gx); gx_resize(gx);
clear_efb = GX_TRUE;
} }
while ((g_vsync || menu_render) && !g_draw_done) while ((g_vsync || menu_render) && !g_draw_done)
@ -861,7 +859,7 @@ static bool gx_frame(void *data, const void *frame,
#endif #endif
} }
GX_CopyDisp(g_framebuf[g_current_framebuf], GX_FALSE); GX_CopyDisp(g_framebuf[g_current_framebuf], clear_efb);
GX_Flush(); GX_Flush();
VIDEO_SetNextFramebuffer(g_framebuf[g_current_framebuf]); VIDEO_SetNextFramebuffer(g_framebuf[g_current_framebuf]);
VIDEO_Flush(); VIDEO_Flush();

View File

@ -29,7 +29,7 @@ typedef struct gx_video
char msg[128]; char msg[128];
} gx_video_t; } gx_video_t;
void gx_set_video_mode(unsigned lines); void gx_set_video_mode(unsigned fbWidth, unsigned lines);
const char *gx_get_video_mode(); const char *gx_get_video_mode();
void gx_set_aspect_ratio(void *data, unsigned aspectratio_idx); void gx_set_aspect_ratio(void *data, unsigned aspectratio_idx);