Monday 5 June 2023

1Up Arcade Mod: Demo of Kiosk FCEUX (NES)

The Demo of nothing more classic than Super Mario Bros (that I own the cart, a NES, two NES classics).

Using Ubuntu 22 with SDL2 Qt5, if I set full screen mode while using any window manager, I do get full screen. However, if I launch with only X11, the max window size is not set, and the position is unknown. This manifests as a non-resizable SDL window with the original pixel dimensions of the console. Changing/flipping the fullscreen mode does nothing, as you will not get a resize event without a window manager.

My fix in Qt ConsoleWindow.cpp is to ask SDL for its current device height and width (doesn't need a window id, because we don't have a valid one yet) and then set the origin and dimension to device extents. (This assumes we have one device.) If I am not fullscreen, I use whatever was previously saved in the config. Paste this code in the ./drivers/Qt/ConsoleWindow.cpp file over where it gets the window size from the config.

SDL_DisplayMode mode;
int err = SDL_GetCurrentDisplayMode(0,&mode);
g_config->getOption( "SDL.Fullscreen", &setFullScreen );
if( setFullScreen )
{
        xWinPos = 0;
        yWinPos = 0;
        xWinSize = mode.w;
        yWinSize = mode.h;
}
else {
        g_config->getOption( "SDL.WinPosX" , &xWinPos );
        g_config->getOption( "SDL.WinPosY" , &yWinPos );
        g_config->getOption( "SDL.WinSizeX", &xWinSize );
        g_config->getOption( "SDL.WinSizeY", &yWinSize );
}
        if ( (xWinSize >= 256) && (yWinSize >= 224) )
        ...
        

this allows me to directly launch fceux with startx