Can now force window aspect ratio to 4:3.

This commit is contained in:
SarahW 2017-05-02 16:08:17 +01:00
commit e87a362f1f
6 changed files with 72 additions and 0 deletions

View file

@ -639,6 +639,7 @@ void loadconfig(char *fn)
else strcpy(iso_path, "");
vid_resize = config_get_int(NULL, "vid_resize", 0);
video_force_aspect_ration = config_get_int(NULL, "vid_force_aspect_ratio", 0);
vid_api = config_get_int(NULL, "vid_api", 0);
video_fullscreen_scale = config_get_int(NULL, "video_fullscreen_scale", 0);
video_fullscreen_first = config_get_int(NULL, "video_fullscreen_first", 1);
@ -741,6 +742,7 @@ void saveconfig()
config_set_int(NULL, "cdrom_channel", cdrom_channel);
config_set_string(NULL, "cdrom_path", iso_path);
config_set_int(NULL, "vid_resize", vid_resize);
config_set_int(NULL, "vid_force_aspect_ratio", video_force_aspect_ration);
config_set_int(NULL, "vid_api", vid_api);
config_set_int(NULL, "video_fullscreen_scale", video_fullscreen_scale);
config_set_int(NULL, "video_fullscreen_first", video_fullscreen_first);

View file

@ -36,6 +36,7 @@ BEGIN
POPUP "&Video"
BEGIN
MENUITEM "&Resizeable window",IDM_VID_RESIZE
MENUITEM "Force 4:3 &aspect ration",IDM_VID_ASPECT
MENUITEM "Remember size && position",IDM_VID_REMEMBER
MENUITEM SEPARATOR
MENUITEM "&DirectDraw", IDM_VID_DDRAW

View file

@ -14,6 +14,7 @@
#define IDM_STATUS 40030
#define IDM_VID_RESIZE 40050
#define IDM_VID_REMEMBER 40051
#define IDM_VID_ASPECT 40052
#define IDM_VID_DDRAW 40060
#define IDM_VID_D3D 40061
#define IDM_VID_FULLSCREEN 40070

View file

@ -156,6 +156,7 @@ int video_get_video_from_internal_name(char *s)
}
int video_fullscreen = 0, video_fullscreen_scale, video_fullscreen_first;
int video_force_aspect_ration = 0;
uint32_t *video_15to32, *video_16to32;
int egareads=0,egawrites=0;

View file

@ -40,6 +40,7 @@ char *video_get_internal_name(int card);
int video_get_video_from_internal_name(char *s);
extern int video_fullscreen, video_fullscreen_scale, video_fullscreen_first;
extern int video_force_aspect_ration;
enum
{

View file

@ -124,6 +124,16 @@ void updatewindowsize(int x, int y)
{
if (vid_resize) return;
if (video_force_aspect_ration)
{
float aspect = (float)x / (float)y;
if (aspect > 1.33)
y = (x * 3) / 4;
else
x = (y * 4) / 3;
}
winsizex=x; winsizey=y;
win_doresize = 1;
}
@ -579,6 +589,8 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
CheckMenuItem(menu, IDM_CDROM_REAL + cdrom_drive, MF_CHECKED);
}
if (vid_resize) CheckMenuItem(menu, IDM_VID_RESIZE, MF_CHECKED);
if (video_force_aspect_ration)
CheckMenuItem(menu, IDM_VID_ASPECT, MF_CHECKED);
CheckMenuItem(menu, IDM_VID_DDRAW + vid_api, MF_CHECKED);
CheckMenuItem(menu, IDM_VID_FS_FULL + video_fullscreen_scale, MF_CHECKED);
CheckMenuItem(menu, IDM_VID_REMEMBER, window_remember ? MF_CHECKED : MF_UNCHECKED);
@ -963,6 +975,11 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
SetWindowPos(hwnd, 0, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER | SWP_FRAMECHANGED);
saveconfig();
break;
case IDM_VID_ASPECT:
video_force_aspect_ration = !video_force_aspect_ration;
CheckMenuItem(hmenu, IDM_VID_ASPECT, video_force_aspect_ration ? MF_CHECKED : MF_UNCHECKED);
saveconfig();
break;
case IDM_VID_REMEMBER:
window_remember = !window_remember;
CheckMenuItem(hmenu, IDM_VID_REMEMBER, window_remember ? MF_CHECKED : MF_UNCHECKED);
@ -1290,6 +1307,55 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
// if (key[KEY_ALT] || key[KEY_ALTGR]) return 0;
break;
case WM_SIZING:
if (video_force_aspect_ration && vid_resize)
{
RECT *r = (RECT *)lParam;
int x = r->right - r->left;
int y = r->bottom - r->top;
float aspect = (float)x / (float)y;
switch (wParam)
{
case WMSZ_LEFT:
case WMSZ_RIGHT:
r->bottom = r->top + ((x * 3) / 4);
break;
case WMSZ_TOP:
case WMSZ_BOTTOM:
r->right = r->left + ((y * 4) / 3);
break;
case WMSZ_TOPLEFT:
if (aspect > 1.33)
r->top = r->bottom - ((x * 3) / 4);
else
r->left = r->right - ((y * 4) / 3);
break;
case WMSZ_TOPRIGHT:
if (aspect > 1.33)
r->top = r->bottom - ((x * 3) / 4);
else
r->right = r->left + ((y * 4) / 3);
break;
case WMSZ_BOTTOMLEFT:
if (aspect > 1.33)
r->bottom = r->top + ((x * 3) / 4);
else
r->left = r->right - ((y * 4) / 3);
break;
case WMSZ_BOTTOMRIGHT:
if (aspect > 1.33)
r->bottom = r->top + ((x * 3) / 4);
else
r->right = r->left + ((y * 4) / 3);
break;
}
return TRUE;
}
break;
case WM_SIZE:
winsizex=lParam&0xFFFF;
winsizey=lParam>>16;