diff --git a/src/pc.c b/src/pc.c index 07395a7..b69ecdb 100644 --- a/src/pc.c +++ b/src/pc.c @@ -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); diff --git a/src/pc.rc b/src/pc.rc index bcd1cf2..5aaf68d 100644 --- a/src/pc.rc +++ b/src/pc.rc @@ -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 diff --git a/src/resources.h b/src/resources.h index 1fa1217..55b485e 100644 --- a/src/resources.h +++ b/src/resources.h @@ -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 diff --git a/src/video.c b/src/video.c index d18aab6..30b6c9e 100644 --- a/src/video.c +++ b/src/video.c @@ -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; diff --git a/src/video.h b/src/video.h index 6d71cb5..72b38c1 100644 --- a/src/video.h +++ b/src/video.h @@ -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 { diff --git a/src/win.c b/src/win.c index bd4b865..690f42d 100644 --- a/src/win.c +++ b/src/win.c @@ -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;