Skip to content

Commit

Permalink
added hardware scale, popup menu by press POWER or L2 button now
Browse files Browse the repository at this point in the history
  • Loading branch information
soarqin committed Oct 26, 2019
1 parent 896e12d commit be060d8
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 33 deletions.
46 changes: 23 additions & 23 deletions src/drivers/dingux-sdl/dingoo-video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ int KillVideo() {

SDL_FreeSurface(nes_screen);
s_inited = 0;
s_VideoModeSet = false;
return 0;
}

Expand Down Expand Up @@ -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;
}
}

Expand All @@ -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.
*/
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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;

Expand All @@ -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];
Expand Down
8 changes: 8 additions & 0 deletions src/drivers/dingux-sdl/gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down
4 changes: 0 additions & 4 deletions src/drivers/dingux-sdl/gui/settings_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,6 @@ int RunSettingsMenu() {
FCEUGUI_Flip();
}

// Must update emulation core and drivers
UpdateEMUCore(g_config);
FCEUD_DriverReset();

// Clear screen
dingoo_clear_video();

Expand Down
3 changes: 2 additions & 1 deletion src/drivers/dingux-sdl/gui/video_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ extern Config *g_config;
// Fullscreen mode
static char *scale_tag[] = {
"Original",
"Hardware",
"Aspect",
"FS Fast",
"FS Smooth"
Expand All @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions src/drivers/dingux-sdl/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions src/drivers/dingux-sdl/keyscan.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit be060d8

Please sign in to comment.