diff --git a/src/common/api.c b/src/common/api.c index 425b207..fb72236 100644 --- a/src/common/api.c +++ b/src/common/api.c @@ -384,6 +384,18 @@ SDL_Surface* GFX_resize(int w, int h, int pitch) { return gfx.screen; } +int GFX_autosize(SDL_Surface** screen, int* dirty) { + static int had_hdmi = -1; + int has_hdmi = GetHDMI(); + if (had_hdmi==has_hdmi) return 0; + + *dirty = 1; + if (has_hdmi) *screen = GFX_resize(HDMI_MENU_WIDTH,FIXED_HEIGHT,HDMI_MENU_WIDTH*FIXED_BPP); + else *screen = GFX_resize(FIXED_WIDTH,FIXED_HEIGHT,FIXED_PITCH); + had_hdmi = has_hdmi; + + return 1; +} static void POW_flipOverlay(void); void GFX_flip(SDL_Surface* screen) { // point framebuffer at the first line of the backbuffer diff --git a/src/common/api.h b/src/common/api.h index ab506ae..df44aad 100644 --- a/src/common/api.h +++ b/src/common/api.h @@ -98,6 +98,7 @@ enum { SDL_Surface* GFX_init(int mode); SDL_Surface* GFX_resize(int width, int height, int pitch); +int GFX_autosize(SDL_Surface** screen, int* dirty); void GFX_setMode(int mode); void GFX_clear(SDL_Surface* screen); void GFX_clearAll(void); diff --git a/src/minarch/main.c b/src/minarch/main.c index 48488cf..f12d13e 100644 --- a/src/minarch/main.c +++ b/src/minarch/main.c @@ -2995,12 +2995,15 @@ static int Menu_message(char* message) { if (PAD_justPressed(BTN_A) || PAD_justPressed(BTN_B)) break; POW_update(&dirty, NULL, Menu_beforeSleep, Menu_afterSleep); + + int resized = GFX_autosize(&screen, &dirty); if (dirty) { - dirty = 0; + if (!resized) GFX_clear(screen); // resizing clears the screen GFX_clear(screen); GFX_blitMessage(message, screen, NULL); GFX_blitButtonGroup((char*[]){ "A","OKAY", NULL }, screen, 1); GFX_flip(screen); + dirty = 0; } else GFX_sync(); } @@ -3458,8 +3461,9 @@ static int Menu_options(MenuList* list) { POW_update(&dirty, &show_settings, Menu_beforeSleep, Menu_afterSleep); + int resized = GFX_autosize(&screen, &dirty); if (dirty) { - dirty = 0; + if (!resized) GFX_clear(screen); // resizing clears the screen GFX_clear(screen); GFX_blitHardwareGroup(screen, show_settings); @@ -3676,6 +3680,7 @@ static int Menu_options(MenuList* list) { } GFX_flip(screen); + dirty = 0; } else GFX_sync(); } @@ -3711,13 +3716,13 @@ static void Menu_loop(void) { // TODO: can we use renderer.src_w/h to reverse the stretch regardless of HDMI status? // because we need an undeformed copy for save state screenshots SDL_Surface* backing = GFX_getBufferCopy(); - SDL_Surface* resized = SDL_CreateRGBSurface(SDL_SWSURFACE, FIXED_WIDTH,FIXED_HEIGHT,FIXED_DEPTH,0,0,0,0); + SDL_Surface* snapshot = SDL_CreateRGBSurface(SDL_SWSURFACE, FIXED_WIDTH,FIXED_HEIGHT,FIXED_DEPTH,0,0,0,0); if (backing->w==FIXED_WIDTH && backing->h==FIXED_HEIGHT) { - SDL_BlitSurface(backing, NULL, resized, NULL); + SDL_BlitSurface(backing, NULL, snapshot, NULL); } else { - downsample(backing->pixels,resized->pixels,backing->w,backing->h,backing->pitch,resized->pitch); + downsample(backing->pixels,snapshot->pixels,backing->w,backing->h,backing->pitch,snapshot->pitch); } // TODO: move this to right before if (dirty) {} like in minui.elf @@ -3903,7 +3908,7 @@ static void Menu_loop(void) { state_slot = menu.slot; State_write(); status = STATUS_SAVE; - SDL_Surface* preview = Menu_thumbnail(resized); + SDL_Surface* preview = Menu_thumbnail(snapshot); SDL_RWops* out = SDL_RWFromFile(bmp_path, "wb"); if (total_discs) { char* disc_path = disc_paths[disc]; @@ -3950,9 +3955,11 @@ static void Menu_loop(void) { POW_update(&dirty, &show_setting, Menu_beforeSleep, Menu_afterSleep); + int resized = GFX_autosize(&screen, &dirty); if (dirty) { - SDL_FillRect(screen, NULL, 0); - SDL_BlitSurface(resized, NULL, screen, NULL); + if (!resized) GFX_clear(screen); // resizing clears the screen + + SDL_BlitSurface(snapshot, NULL, screen, NULL); SDL_BlitSurface(menu.overlay, NULL, screen, NULL); int ox, oy; @@ -4114,7 +4121,7 @@ static void Menu_loop(void) { } SDL_FreeSurface(backing); - SDL_FreeSurface(resized); + SDL_FreeSurface(snapshot); POW_disableAutosleep(); POW_warn(1); } @@ -4212,8 +4219,6 @@ int main(int argc , char* argv[]) { Game_open(rom_path); if (!game.is_open) goto finish; - LOG_info("no way\n"); - // restore configs Config_read(); setOverclock(overclock); diff --git a/src/minui/main.c b/src/minui/main.c index 1116ca8..6c07b17 100644 --- a/src/minui/main.c +++ b/src/minui/main.c @@ -1325,21 +1325,9 @@ int main (int argc, char *argv[]) { POW_update(&dirty, &show_setting, NULL, NULL); - static int had_hdmi = -1; - int has_hdmi = GetHDMI(); - if (had_hdmi!=has_hdmi) dirty = 1; - + int resized = GFX_autosize(&screen, &dirty); if (dirty) { - if (had_hdmi!=has_hdmi) { - if (has_hdmi) { - screen = GFX_resize(HDMI_MENU_WIDTH,FIXED_HEIGHT,HDMI_MENU_WIDTH*FIXED_BPP); - } - else { - screen = GFX_resize(FIXED_WIDTH,FIXED_HEIGHT,FIXED_PITCH); - } - had_hdmi = has_hdmi; - } - else GFX_clear(screen); // resizing clears the screen + if (!resized) GFX_clear(screen); // resizing clears the screen int ox; int oy; diff --git a/todo.txt b/todo.txt index 1638ed3..c360a4f 100644 --- a/todo.txt +++ b/todo.txt @@ -29,14 +29,17 @@ create a clean image to flash and install over add most recent uImage/kernel changes hdmi + minarch menus don't update when connected to hdmi + need to figureout how to create a 4:3 thumb from a distorted framebuffer + should be able to reconstruct it with screen->w|h and renderer.(src|dst)_(w|h) + just need to downsample to a cropped region of the source + does clock need GFX_autosize? ignore brightness shortcut when on hdmi - figure out how to handle renderng the menus - 856x480 will get round circles but it's still blurry... - it would be better if we could just go the full 1280x720 and change SCREEN_SCALE to 3... + still getting through somehow... audio minarch - zip support + can I support changing discs in multi-disc pbps? figure out how to handle different button mappings for cores with different modes eg. GG or SMS with picodrive move overrides to a text file that lives in the pak?