[SDL] fixed fullscreen in SDL2 build

This commit is contained in:
Clownacy 2018-07-01 23:44:24 +01:00
parent 0569355cb5
commit b68d016aa5

View File

@ -148,7 +148,7 @@ static int sdl_video_init()
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", "SDL Video initialization failed", sdl_video.window);
return 0;
}
sdl_video.window = SDL_CreateWindow("Genesis Plus GX", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, VIDEO_WIDTH, VIDEO_HEIGHT, 0);
sdl_video.window = SDL_CreateWindow("Genesis Plus GX", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, VIDEO_WIDTH, VIDEO_HEIGHT, fullscreen);
sdl_video.surf_screen = SDL_GetWindowSurface(sdl_video.window);
sdl_video.surf_bitmap = SDL_CreateRGBSurfaceWithFormat(SDL_SWSURFACE, 720, 576, SDL_BITSPERPIXEL(surface_format), surface_format);
sdl_video.frames_rendered = 0;
@ -181,22 +181,22 @@ static void sdl_video_update()
sdl_video.srect.h = bitmap.viewport.h+2*bitmap.viewport.y;
sdl_video.srect.x = 0;
sdl_video.srect.y = 0;
if (sdl_video.srect.w > VIDEO_WIDTH)
if (sdl_video.srect.w > sdl_video.surf_screen->w)
{
sdl_video.srect.x = (sdl_video.srect.w - VIDEO_WIDTH) / 2;
sdl_video.srect.w = VIDEO_WIDTH;
sdl_video.srect.x = (sdl_video.srect.w - sdl_video.surf_screen->w) / 2;
sdl_video.srect.w = sdl_video.surf_screen->w;
}
if (sdl_video.srect.h > VIDEO_HEIGHT)
if (sdl_video.srect.h > sdl_video.surf_screen->h)
{
sdl_video.srect.y = (sdl_video.srect.h - VIDEO_HEIGHT) / 2;
sdl_video.srect.h = VIDEO_HEIGHT;
sdl_video.srect.y = (sdl_video.srect.h - sdl_video.surf_screen->h) / 2;
sdl_video.srect.h = sdl_video.surf_screen->h;
}
/* destination bitmap */
sdl_video.drect.w = sdl_video.srect.w;
sdl_video.drect.h = sdl_video.srect.h;
sdl_video.drect.x = (VIDEO_WIDTH - sdl_video.drect.w) / 2;
sdl_video.drect.y = (VIDEO_HEIGHT - sdl_video.drect.h) / 2;
sdl_video.drect.x = (sdl_video.surf_screen->w - sdl_video.drect.w) / 2;
sdl_video.drect.y = (sdl_video.surf_screen->h - sdl_video.drect.h) / 2;
/* clear destination surface */
SDL_FillRect(sdl_video.surf_screen, 0, 0);
@ -334,7 +334,9 @@ static int sdl_control_update(SDL_Keycode keystate)
case SDLK_F2:
{
fullscreen = (fullscreen ? 0 : SDL_WINDOW_FULLSCREEN);
SDL_SetWindowFullscreen(sdl_video.window, fullscreen);
SDL_SetWindowFullscreen(sdl_video.window, fullscreen);
sdl_video.surf_screen = SDL_GetWindowSurface(sdl_video.window);
bitmap.viewport.changed = 1;
break;
}
@ -507,10 +509,10 @@ int sdl_input_update(void)
int state = SDL_GetMouseState(&x,&y);
/* X axis */
input.analog[joynum][0] = x - (VIDEO_WIDTH-bitmap.viewport.w)/2;
input.analog[joynum][0] = x - (sdl_video.surf_screen->w-bitmap.viewport.w)/2;
/* Y axis */
input.analog[joynum][1] = y - (VIDEO_HEIGHT-bitmap.viewport.h)/2;
input.analog[joynum][1] = y - (sdl_video.surf_screen->h-bitmap.viewport.h)/2;
/* TRIGGER, B, C (Menacer only), START (Menacer & Justifier only) */
if(state & SDL_BUTTON_LMASK) input.pad[joynum] |= INPUT_A;
@ -527,7 +529,7 @@ int sdl_input_update(void)
int state = SDL_GetMouseState(&x, NULL);
/* Range is [0;256], 128 being middle position */
input.analog[joynum][0] = x * 256 /VIDEO_WIDTH;
input.analog[joynum][0] = x * 256 /sdl_video.surf_screen->w;
/* Button I -> 0 0 0 0 0 0 0 I*/
if(state & SDL_BUTTON_LMASK) input.pad[joynum] |= INPUT_B;
@ -622,8 +624,8 @@ int sdl_input_update(void)
int state = SDL_GetMouseState(&x,&y);
/* Calculate X Y axis values */
input.analog[0][0] = 0x3c + (x * (0x17c-0x03c+1)) / VIDEO_WIDTH;
input.analog[0][1] = 0x1fc + (y * (0x2f7-0x1fc+1)) / VIDEO_HEIGHT;
input.analog[0][0] = 0x3c + (x * (0x17c-0x03c+1)) / sdl_video.surf_screen->w;
input.analog[0][1] = 0x1fc + (y * (0x2f7-0x1fc+1)) / sdl_video.surf_screen->h;
/* Map mouse buttons to player #1 inputs */
if(state & SDL_BUTTON_MMASK) pico_current = (pico_current + 1) & 7;
@ -640,8 +642,8 @@ int sdl_input_update(void)
int state = SDL_GetMouseState(&x,&y);
/* Calculate X Y axis values */
input.analog[0][0] = (x * 250) / VIDEO_WIDTH;
input.analog[0][1] = (y * 250) / VIDEO_HEIGHT;
input.analog[0][0] = (x * 250) / sdl_video.surf_screen->w;
input.analog[0][1] = (y * 250) / sdl_video.surf_screen->h;
/* Map mouse buttons to player #1 inputs */
if(state & SDL_BUTTON_RMASK) input.pad[0] |= INPUT_B;
@ -656,8 +658,8 @@ int sdl_input_update(void)
int state = SDL_GetMouseState(&x,&y);
/* Calculate X Y axis values */
input.analog[0][0] = (x * 255) / VIDEO_WIDTH;
input.analog[0][1] = (y * 255) / VIDEO_HEIGHT;
input.analog[0][0] = (x * 255) / sdl_video.surf_screen->w;
input.analog[0][1] = (y * 255) / sdl_video.surf_screen->h;
/* Map mouse buttons to player #1 inputs */
if(state & SDL_BUTTON_LMASK) input.pad[0] |= INPUT_GRAPHIC_PEN;