From be060d81da6db4273a53487e9f1ce73b4ba9bd10 Mon Sep 17 00:00:00 2001 From: Soar Qin Date: Tue, 22 Oct 2019 22:03:17 +0800 Subject: [PATCH] added hardware scale, popup menu by press POWER or L2 button now --- src/drivers/dingux-sdl/dingoo-video.cpp | 46 +++++++++---------- src/drivers/dingux-sdl/gui/gui.cpp | 8 ++++ src/drivers/dingux-sdl/gui/settings_menu.cpp | 4 -- src/drivers/dingux-sdl/gui/video_settings.cpp | 3 +- src/drivers/dingux-sdl/input.cpp | 10 ++-- src/drivers/dingux-sdl/keyscan.h | 2 + 6 files changed, 40 insertions(+), 33 deletions(-) diff --git a/src/drivers/dingux-sdl/dingoo-video.cpp b/src/drivers/dingux-sdl/dingoo-video.cpp index 7d59c1a22..50eea3c2d 100644 --- a/src/drivers/dingux-sdl/dingoo-video.cpp +++ b/src/drivers/dingux-sdl/dingoo-video.cpp @@ -103,6 +103,7 @@ int KillVideo() { SDL_FreeSurface(nes_screen); s_inited = 0; + s_VideoModeSet = false; return 0; } @@ -157,26 +158,16 @@ int InitVideo(FCEUGI *gi) { // initialize dingoo video mode if (!s_VideoModeSet) { - uint32 vm = 0; // 0 - 320x240, 1 - 400x240, 2 - 480x272 - - #define NUMOFVIDEOMODES 3 - struct { - uint32 x; - uint32 y; - } VModes[NUMOFVIDEOMODES] = { - {320, 240}, - {400, 240}, - {480, 272} - }; - - for(vm = NUMOFVIDEOMODES-1; vm >= 0; vm--) + int w, h; + if (s_fullscreen == 1) { + w = 256; h = PAL ? 240 : 224; + } else { + w = 320; h = 240; + } + if(SDL_VideoModeOK(w, h, 16, SDL_HWSURFACE | DINGOO_MULTIBUF) != 0) { - if(SDL_VideoModeOK(VModes[vm].x, VModes[vm].y, 16, SDL_HWSURFACE | DINGOO_MULTIBUF) != 0) - { - screen = SDL_SetVideoMode(VModes[vm].x, VModes[vm].y, 16, SDL_HWSURFACE | DINGOO_MULTIBUF); - s_VideoModeSet = true; - break; - } + screen = SDL_SetVideoMode(w, h, 16, SDL_HWSURFACE | DINGOO_MULTIBUF); + s_VideoModeSet = true; } } @@ -196,6 +187,14 @@ int InitVideo(FCEUGI *gi) { return 0; } +void InitGuiVideo() { + if (screen->w == 320 && screen->h == 240) return; + if(SDL_VideoModeOK(320, 240, 16, SDL_HWSURFACE | DINGOO_MULTIBUF) != 0) + { + screen = SDL_SetVideoMode(320, 240, 16, SDL_HWSURFACE | DINGOO_MULTIBUF); + } +} + /** * Toggles the full-screen display. */ @@ -330,19 +329,19 @@ void BlitScreen(uint8 *XBuf) { register uint8 *pBuf = XBuf; - if(s_fullscreen == 3) { // fullscreen smooth + if(s_fullscreen == 4) { // fullscreen smooth if (s_clipSides) { upscale_320x240_bilinearish_clip((uint32 *)screen->pixels, (uint8 *)XBuf + 256 * 8, 256); } else { upscale_320x240_bilinearish_noclip((uint32 *)screen->pixels, (uint8 *)XBuf + 256 * 8, 256); } - } else if(s_fullscreen == 2) { // fullscreen + } else if(s_fullscreen == 3) { // fullscreen switch(screen->w) { case 480: upscale_480x272((uint32 *)screen->pixels, (uint8 *)XBuf + 256 * 8); break; case 400: upscale_384x240((uint32 *)screen->pixels, (uint8 *)XBuf + 256 * 8); break; case 320: upscale_320x240((uint32 *)screen->pixels, (uint8 *)XBuf + 256 * 8); break; } - } else if(s_fullscreen == 1) { // aspect fullscreen + } else if(s_fullscreen == 2) { // aspect fullscreen switch(screen->w) { case 480: upscale_384x272((uint32 *)screen->pixels, (uint8 *)XBuf + 256 * 8); break; case 400: @@ -373,6 +372,7 @@ void BlitScreen(uint8 *XBuf) { } else { // native res //int pinc = (320 - NWIDTH) >> 1; int32 pinc = (screen->w - NWIDTH) >> 1; + int32 append = 256 - NWIDTH; //SDL_Rect dstrect; @@ -390,7 +390,7 @@ void BlitScreen(uint8 *XBuf) { //dest += (s_srendline * 320) + pinc >> 1; dest += (screen->w/2 * s_srendline) + pinc / 2 + ((screen->h - 240) / 4) * screen->w; - for (y = s_tlines; y; y--, pBuf += 256 - NWIDTH) { + for (y = s_tlines; y; y--, pBuf += append) { for (x = NWIDTH >> 3; x; x--) { __builtin_prefetch(dest + 4, 1); *dest++ = palettetranslate[*(uint16 *) pBuf]; diff --git a/src/drivers/dingux-sdl/gui/gui.cpp b/src/drivers/dingux-sdl/gui/gui.cpp index b5f97f06c..6cf837a8f 100644 --- a/src/drivers/dingux-sdl/gui/gui.cpp +++ b/src/drivers/dingux-sdl/gui/gui.cpp @@ -318,11 +318,15 @@ void FCEUGUI_Kill() { KillFont(); } +extern void InitGuiVideo(); + void FCEUGUI_Run() { static int index = 0; static int spy = 72; int done = 0, y, i; + InitGuiVideo(); + load_preview(); g_dirty = 1; @@ -445,6 +449,10 @@ void FCEUGUI_Run() { g_psdl = FCEUD_GetPaletteArray16(); + // Must update emulation core and drivers + UpdateEMUCore(g_config); + FCEUD_DriverReset(); + // Clear screen dingoo_clear_video(); diff --git a/src/drivers/dingux-sdl/gui/settings_menu.cpp b/src/drivers/dingux-sdl/gui/settings_menu.cpp index 275131f88..37b105c03 100644 --- a/src/drivers/dingux-sdl/gui/settings_menu.cpp +++ b/src/drivers/dingux-sdl/gui/settings_menu.cpp @@ -115,10 +115,6 @@ int RunSettingsMenu() { FCEUGUI_Flip(); } - // Must update emulation core and drivers - UpdateEMUCore(g_config); - FCEUD_DriverReset(); - // Clear screen dingoo_clear_video(); diff --git a/src/drivers/dingux-sdl/gui/video_settings.cpp b/src/drivers/dingux-sdl/gui/video_settings.cpp index 46b5be515..165485e17 100644 --- a/src/drivers/dingux-sdl/gui/video_settings.cpp +++ b/src/drivers/dingux-sdl/gui/video_settings.cpp @@ -7,6 +7,7 @@ extern Config *g_config; // Fullscreen mode static char *scale_tag[] = { "Original", + "Hardware", "Aspect", "FS Fast", "FS Smooth" @@ -17,7 +18,7 @@ static void fullscreen_update(unsigned long key) int val; g_config->getOption("SDL.Fullscreen", &val); - if (key == DINGOO_RIGHT) val = val < 3 ? val+1 : 3; + if (key == DINGOO_RIGHT) val = val < 4 ? val+1 : 4; if (key == DINGOO_LEFT) val = val > 0 ? val-1 : 0; g_config->setOption("SDL.Fullscreen", val); diff --git a/src/drivers/dingux-sdl/input.cpp b/src/drivers/dingux-sdl/input.cpp index 9e1245ba3..bfb9f5ff9 100644 --- a/src/drivers/dingux-sdl/input.cpp +++ b/src/drivers/dingux-sdl/input.cpp @@ -296,10 +296,9 @@ static void KeyboardCommands() { FCEUI_SetRenderPlanes(true, state); } - // L (SDLK_TAB), Start+Select or Power flick (SDLK_HOME) - enter GUI - if (_keyonly(DINGOO_L) - || MenuRequested - || (ispressed(DINGOO_START) && ispressed(DINGOO_SELECT))) { + // Power flick (SDLK_HOME) to enter GUI + if (_keyonly(DINGOO_L2) + || MenuRequested) { SilenceSound(1); MenuRequested = false; FCEUGUI_Run(); @@ -324,8 +323,9 @@ static void KeyboardCommands() { } if(_keyonly(DINGOO_X)) { // R + X toggle fullscreen extern int s_fullscreen; // from dingoo_video.cpp - s_fullscreen = (s_fullscreen + 1) % 4; + s_fullscreen = (s_fullscreen + 1) % 5; g_config->setOption("SDL.Fullscreen", s_fullscreen); + FCEUD_DriverReset(); dingoo_clear_video(); resetkey(DINGOO_X); } diff --git a/src/drivers/dingux-sdl/keyscan.h b/src/drivers/dingux-sdl/keyscan.h index e26fb6fd1..8fbf638d9 100644 --- a/src/drivers/dingux-sdl/keyscan.h +++ b/src/drivers/dingux-sdl/keyscan.h @@ -61,6 +61,8 @@ #define DINGOO_Y SDLK_LSHIFT #define DINGOO_L SDLK_TAB #define DINGOO_R SDLK_BACKSPACE +#define DINGOO_L2 SDLK_PAGEUP +#define DINGOO_R2 SDLK_PAGEDOWN #define DINGOO_START SDLK_RETURN #define DINGOO_SELECT SDLK_ESCAPE #define DINGOO_MENU SDLK_HOME