From 2be1c21c8a490bb96413f1137b07c45aa9d51b68 Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 20 Oct 2017 07:00:48 +0200 Subject: [PATCH] Fixed the window resizes function in win_video.c, fixes window resizes with non-resizable window (ie. the main window is no longer stuck in 640x480); Fixed the Force 4:3, Enable EGA/(S)VGA overscan, and Scale options; Fixed a bug regarding register 0 of the SMC FDC37C665 Super I/O chip; Commented out some excess logging. --- src/network/net_ne2000.c | 2 + src/pc.c | 8 +- src/sio_fdc37c665.c | 6 ++ src/video/vid_cga.c | 5 +- src/video/vid_ega.c | 5 +- src/video/vid_genius.c | 5 +- src/video/vid_hercules.c | 5 +- src/video/vid_herculesplus.c | 5 +- src/video/vid_incolor.c | 5 +- src/video/vid_mda.c | 5 +- src/video/vid_olivetti_m24.c | 5 +- src/video/vid_pc1512.c | 5 +- src/video/vid_pcjr.c | 5 +- src/video/vid_svga.c | 19 ++--- src/video/vid_svga_render.c | 138 +++++++---------------------------- src/video/vid_tandy.c | 5 +- src/video/vid_tandysl.c | 5 +- src/video/vid_wy700.c | 5 +- src/video/video.c | 15 ++++ src/video/video.h | 2 + src/win/win.c | 3 + src/win/win_video.c | 29 ++++++-- 22 files changed, 139 insertions(+), 148 deletions(-) diff --git a/src/network/net_ne2000.c b/src/network/net_ne2000.c index feee01a34..c929171b3 100644 --- a/src/network/net_ne2000.c +++ b/src/network/net_ne2000.c @@ -1881,7 +1881,9 @@ nic_init(device_t *info) uint32_t mac; wchar_t *rom; nic_t *dev; +#ifdef ENABLE_NIC_LOG int i; +#endif /* Get the desired debug level. */ #ifdef ENABLE_NIC_LOG diff --git a/src/pc.c b/src/pc.c index fa5b28520..177c6d123 100644 --- a/src/pc.c +++ b/src/pc.c @@ -195,7 +195,9 @@ set_screen_size(int x, int y) int efscrnsz_y; /* Make sure we keep usable values. */ +#if 0 pclog("SetScreenSize(%d, %d) resize=%d\n", x, y, vid_resize); +#endif if (x < 320) x = 320; if (y < 200) y = 200; if (x > 2048) x = 2048; @@ -216,10 +218,10 @@ set_screen_size(int x, int y) dty = (double)temp_overscan_y; /* Account for possible overscan. */ - if (temp_overscan_y == 16) { + if (!(VGA) && (temp_overscan_y == 16)) { /* CGA */ dy = (((dx - dtx) / 4.0) * 3.0) + dty; - } else if (temp_overscan_y < 16) { + } else if (!(VGA) && (temp_overscan_y < 16)) { /* MDA/Hercules */ dy = (x / 4.0) * 3.0; } else { @@ -816,7 +818,7 @@ pc_thread(void *param) while (! *quitp) { /* Update the Stat(u)s window with the current info. */ if (status_update_needed) { -#if 1 +#if 0 pclog("Updating STATS window..\n"); // ui_status_update(); #endif diff --git a/src/sio_fdc37c665.c b/src/sio_fdc37c665.c index abceb6d2b..d140da5e2 100644 --- a/src/sio_fdc37c665.c +++ b/src/sio_fdc37c665.c @@ -177,6 +177,8 @@ void fdc37c665_write(uint16_t port, uint8_t val, void *priv) if (val == 0xaa) write_lock(val); else + fdc37c665_curreg = val; +#if 0 if (fdc37c665_curreg != 0) { fdc37c665_curreg = val & 0xf; @@ -186,9 +188,13 @@ void fdc37c665_write(uint16_t port, uint8_t val, void *priv) /* Hardcode the IDE to AT type. */ fdc37c665_curreg = (val & 0xf) | 2; } +#endif } else { + if (fdc37c665_curreg > 15) + return; + valxor = val ^ fdc37c665_regs[fdc37c665_curreg]; fdc37c665_regs[fdc37c665_curreg] = val; diff --git a/src/video/vid_cga.c b/src/video/vid_cga.c index 7f6ad068f..8a52723aa 100644 --- a/src/video/vid_cga.c +++ b/src/video/vid_cga.c @@ -396,13 +396,16 @@ void cga_poll(void *p) if (cga->cgamode & 1) x = (cga->crtc[1] << 3) + 16; else x = (cga->crtc[1] << 4) + 16; cga->lastline++; - if (x != xsize || (cga->lastline - cga->firstline) != ysize) + if ((x != xsize) || ((cga->lastline - cga->firstline) != ysize) || video_force_resize_get()) { xsize = x; ysize = cga->lastline - cga->firstline; if (xsize < 64) xsize = 656; if (ysize < 32) ysize = 200; set_screen_size(xsize, (ysize << 1) + 16); + + if (video_force_resize_get()) + video_force_resize_set(0); } if (cga->composite) diff --git a/src/video/vid_ega.c b/src/video/vid_ega.c index e3f494950..06fa96fa6 100644 --- a/src/video/vid_ega.c +++ b/src/video/vid_ega.c @@ -664,7 +664,7 @@ void ega_poll(void *p) if (ega->interlace && !ega->oddeven) ega->lastline++; if (ega->interlace && ega->oddeven) ega->firstline--; - if ((x != xsize || (ega->lastline - ega->firstline + 1) != ysize) || update_overscan) + if ((x != xsize || (ega->lastline - ega->firstline + 1) != ysize) || update_overscan || video_force_resize_get()) { xsize = x; ysize = ega->lastline - ega->firstline + 1; @@ -690,6 +690,9 @@ void ega_poll(void *p) set_screen_size(xsize + x_add_ex, (ysize << 1) + y_add_ex); else set_screen_size(xsize + x_add_ex, ysize + y_add_ex); + + if (video_force_resize_get()) + video_force_resize_set(0); } if (enable_overscan) diff --git a/src/video/vid_genius.c b/src/video/vid_genius.c index 20ab61790..9c7098e33 100644 --- a/src/video/vid_genius.c +++ b/src/video/vid_genius.c @@ -551,13 +551,16 @@ void genius_poll(void *p) if (genius->displine == 1008) { /* Hardcode GENIUS_XSIZE * GENIUS_YSIZE window size */ - if (GENIUS_XSIZE != xsize || GENIUS_YSIZE != ysize) + if ((GENIUS_XSIZE != xsize) || (GENIUS_YSIZE != ysize) || video_force_resize_get()) { xsize = GENIUS_XSIZE; ysize = GENIUS_YSIZE; if (xsize < 64) xsize = 656; if (ysize < 32) ysize = 200; set_screen_size(xsize, ysize); + + if (video_force_resize_get()) + video_force_resize_set(0); } video_blit_memtoscreen_8(0, 0, xsize, ysize); diff --git a/src/video/vid_hercules.c b/src/video/vid_hercules.c index 738a1c63f..35da6f4ae 100644 --- a/src/video/vid_hercules.c +++ b/src/video/vid_hercules.c @@ -283,7 +283,7 @@ void hercules_poll(void *p) if ((hercules->ctrl & 2) && (hercules->ctrl2 & 1)) x = hercules->crtc[1] << 4; else x = hercules->crtc[1] * 9; hercules->lastline++; - if (x != xsize || (hercules->lastline - hercules->firstline) != ysize) + if ((x != xsize) || ((hercules->lastline - hercules->firstline) != ysize) || video_force_resize_get()) { xsize = x; ysize = hercules->lastline - hercules->firstline; @@ -291,6 +291,9 @@ void hercules_poll(void *p) if (xsize < 64) xsize = 656; if (ysize < 32) ysize = 200; set_screen_size(xsize, ysize); + + if (video_force_resize_get()) + video_force_resize_set(0); } video_blit_memtoscreen_8(0, hercules->firstline, xsize, ysize); frames++; diff --git a/src/video/vid_herculesplus.c b/src/video/vid_herculesplus.c index a9bf93229..918686339 100644 --- a/src/video/vid_herculesplus.c +++ b/src/video/vid_herculesplus.c @@ -633,13 +633,16 @@ void herculesplus_poll(void *p) x = herculesplus->crtc[1] * 9; } herculesplus->lastline++; - if (x != xsize || (herculesplus->lastline - herculesplus->firstline) != ysize) + if ((x != xsize) || ((herculesplus->lastline - herculesplus->firstline) != ysize) || video_force_resize_get()) { xsize = x; ysize = herculesplus->lastline - herculesplus->firstline; if (xsize < 64) xsize = 656; if (ysize < 32) ysize = 200; set_screen_size(xsize, ysize); + + if (video_force_resize_get()) + video_force_resize_set(0); } video_blit_memtoscreen(0, herculesplus->firstline, 0, herculesplus->lastline - herculesplus->firstline, xsize, herculesplus->lastline - herculesplus->firstline); frames++; diff --git a/src/video/vid_incolor.c b/src/video/vid_incolor.c index 18e8b7879..fbcdd1b52 100644 --- a/src/video/vid_incolor.c +++ b/src/video/vid_incolor.c @@ -980,13 +980,16 @@ void incolor_poll(void *p) x = incolor->crtc[1] * 9; } incolor->lastline++; - if (x != xsize || (incolor->lastline - incolor->firstline) != ysize) + if ((x != xsize) || ((incolor->lastline - incolor->firstline) != ysize) || video_force_resize_get()) { xsize = x; ysize = incolor->lastline - incolor->firstline; if (xsize < 64) xsize = 656; if (ysize < 32) ysize = 200; set_screen_size(xsize, ysize); + + if (video_force_resize_get()) + video_force_resize_set(0); } video_blit_memtoscreen(0, incolor->firstline, 0, incolor->lastline - incolor->firstline, xsize, incolor->lastline - incolor->firstline); frames++; diff --git a/src/video/vid_mda.c b/src/video/vid_mda.c index dc350ff3b..691c6bd07 100644 --- a/src/video/vid_mda.c +++ b/src/video/vid_mda.c @@ -243,13 +243,16 @@ void mda_poll(void *p) { x = mda->crtc[1] * 9; mda->lastline++; - if (x != xsize || (mda->lastline - mda->firstline) != ysize) + if ((x != xsize) || ((mda->lastline - mda->firstline) != ysize) || video_force_resize_get()) { xsize = x; ysize = mda->lastline - mda->firstline; if (xsize < 64) xsize = 656; if (ysize < 32) ysize = 200; set_screen_size(xsize, ysize); + + if (video_force_resize_get()) + video_force_resize_set(0); } video_blit_memtoscreen_8(0, mda->firstline, xsize, mda->lastline - mda->firstline); frames++; diff --git a/src/video/vid_olivetti_m24.c b/src/video/vid_olivetti_m24.c index 90398d7fc..d5d38df99 100644 --- a/src/video/vid_olivetti_m24.c +++ b/src/video/vid_olivetti_m24.c @@ -404,13 +404,16 @@ void m24_poll(void *p) if (m24->cgamode & 1) x = (m24->crtc[1] << 3) + 16; else x = (m24->crtc[1] << 4) + 16; m24->lastline++; - if (x != xsize || (m24->lastline - m24->firstline) != ysize) + if ((x != xsize) || ((m24->lastline - m24->firstline) != ysize) || video_force_resize_get()) { xsize = x; ysize = m24->lastline - m24->firstline; if (xsize < 64) xsize = 656; if (ysize < 32) ysize = 200; set_screen_size(xsize, ysize + 16); + + if (video_force_resize_get()) + video_force_resize_set(0); } video_blit_memtoscreen_8(0, m24->firstline - 8, xsize, (m24->lastline - m24->firstline) + 16); diff --git a/src/video/vid_pc1512.c b/src/video/vid_pc1512.c index ffb5c6fb4..0e8ef21c8 100644 --- a/src/video/vid_pc1512.c +++ b/src/video/vid_pc1512.c @@ -413,13 +413,16 @@ static void pc1512_poll(void *p) x = 640 + 16; pc1512->lastline++; - if (x != xsize || (pc1512->lastline - pc1512->firstline) != ysize) + if ((x != xsize) || ((pc1512->lastline - pc1512->firstline) != ysize) || video_force_resize_get()) { xsize = x; ysize = pc1512->lastline - pc1512->firstline; if (xsize < 64) xsize = 656; if (ysize < 32) ysize = 200; set_screen_size(xsize, (ysize << 1) + 16); + + if (video_force_resize_get()) + video_force_resize_set(0); } video_blit_memtoscreen_8(0, pc1512->firstline - 4, xsize, (pc1512->lastline - pc1512->firstline) + 8); diff --git a/src/video/vid_pcjr.c b/src/video/vid_pcjr.c index 76be08f20..938202a20 100644 --- a/src/video/vid_pcjr.c +++ b/src/video/vid_pcjr.c @@ -503,13 +503,16 @@ void pcjr_poll(void *p) if (pcjr->array[0] & 1) x = (pcjr->crtc[1] << 3) + 16; else x = (pcjr->crtc[1] << 4) + 16; pcjr->lastline++; - if (x != xsize || (pcjr->lastline - pcjr->firstline) != ysize) + if ((x != xsize) || ((pcjr->lastline - pcjr->firstline) != ysize) || video_force_resize_get()) { xsize = x; ysize = pcjr->lastline - pcjr->firstline; if (xsize < 64) xsize = 656; if (ysize < 32) ysize = 200; set_screen_size(xsize, (ysize << 1) + 16); + + if (video_force_resize_get()) + video_force_resize_set(0); } if (pcjr->composite) diff --git a/src/video/vid_svga.c b/src/video/vid_svga.c index f7b68a226..bcc703065 100644 --- a/src/video/vid_svga.c +++ b/src/video/vid_svga.c @@ -1617,7 +1617,7 @@ void svga_doblit(int y1, int y2, int wx, int wy, svga_t *svga) return; } - if (((wx!=xsize) || ((wy+1)!=ysize))) + if ((wx != xsize) || ((wy + 1) != ysize) || video_force_resize_get()) { /* Screen res has changed.. fix up, and let them know. */ xsize = wx; @@ -1625,18 +1625,13 @@ void svga_doblit(int y1, int y2, int wx, int wy, svga_t *svga) if (xsize<64) xsize = 640; if (ysize<32) ysize = 200; - if ((xsize > 2032) || (ysize > 2032)) - { - x_add = 0; - y_add = 0; - suppress_overscan = 1; - } - else - { - suppress_overscan = 0; - } - set_screen_size(xsize+x_add,ysize+y_add); + + if (video_force_resize_get()) + { + pclog("Scroll: %02X (%i, %i, %i, %i, %i, %i)\n", (svga->crtc[8] & 0x1f), enable_overscan, suppress_overscan, wx, wy + 1, x_add, y_add); + video_force_resize_set(0); + } } if (enable_overscan && !suppress_overscan) diff --git a/src/video/vid_svga_render.c b/src/video/vid_svga_render.c index 216efed29..1b08ecceb 100644 --- a/src/video/vid_svga_render.c +++ b/src/video/vid_svga_render.c @@ -134,7 +134,7 @@ uint32_t svga_color_transform(uint32_t color) int svga_display_line(svga_t *svga) { - int y_add = (enable_overscan) ? 16 : 0; + int y_add = enable_overscan ? (overscan_y >> 1) : 0; unsigned int dl = svga->displine; if (svga->crtc[9] & 0x1f) { @@ -147,75 +147,9 @@ int svga_display_line(svga_t *svga) void svga_render_blank(svga_t *svga) { -#if 0 int x, xx; - int y_add = (enable_overscan) ? 16 : 0; - int x_add = y_add >> 1; - int dl = svga_display_line(svga); - uint32_t *p; - - if (svga->firstline_draw == 2000) - svga->firstline_draw = svga->displine; - svga->lastline_draw = svga->displine; - - if (dl >= 2046) - { - return; - } - - for (x = 0; x < svga->hdisp; x++) - { - switch (svga->seqregs[1] & 9) - { - case 0: - for (xx = 0; xx < 9; xx++) - { - p = ((uint32_t *)buffer32->line[dl]); - if (&(p[(x * 9) + xx + 32 + x_add]) != NULL) - { - p[(x * 9) + xx + 32 + x_add] = svga_color_transform(0); - } - } - break; - - case 1: - for (xx = 0; xx < 8; xx++) - { - p = ((uint32_t *)buffer32->line[dl]); - if (&(p[(x * 8) + xx + 32 + x_add]) != NULL) - { - p[(x * 8) + xx + 32 + x_add] = svga_color_transform(0); - } - } - break; - - case 8: - for (xx = 0; xx < 18; xx++) - { - p = ((uint32_t *)buffer32->line[dl]); - if (&(p[(x * 18) + xx + 32 + x_add]) != NULL) - { - p[(x * 18) + xx + 32 + x_add] = svga_color_transform(0); - } - } - break; - - case 9: - for (xx = 0; xx < 16; xx++) - { - p = ((uint32_t *)buffer32->line[dl]); - if (&(p[(x * 16) + xx + 32 + x_add]) != NULL) - { - p[(x * 16) + xx + 32 + x_add] = svga_color_transform(0); - } - } - break; - } - } -#endif - int x, xx; - int y_add = (enable_overscan) ? 16 : 0; - int x_add = y_add >> 1; + int y_add = enable_overscan ? (overscan_y >> 1) : 0; + int x_add = enable_overscan ? 8 : 0; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -243,8 +177,7 @@ void svga_render_blank(svga_t *svga) void svga_render_text_40(svga_t *svga) { - int y_add = (enable_overscan) ? 16 : 0; - int x_add = y_add >> 1; + int x_add = enable_overscan ? 8 : 0; int dl = svga_display_line(svga); if (svga->firstline_draw == 2000) @@ -311,8 +244,7 @@ void svga_render_text_40(svga_t *svga) #if 0 void svga_render_text_40_12(svga_t *svga) { - int y_add = (enable_overscan) ? 16 : 0; - int x_add = (enable_overscan) ? 12 : 0; + int x_add = enable_overscan ? 12 : 0; int dl = svga_display_line(svga); if (svga->firstline_draw == 2000) @@ -368,8 +300,7 @@ void svga_render_text_40_12(svga_t *svga) void svga_render_text_80(svga_t *svga) { - int y_add = (enable_overscan) ? 16 : 0; - int x_add = y_add >> 1; + int x_add = enable_overscan ? 8 : 0; int dl = svga_display_line(svga); if (svga->firstline_draw == 2000) @@ -436,8 +367,7 @@ void svga_render_text_80(svga_t *svga) #if 0 void svga_render_text_80_12(svga_t *svga) { - int y_add = (enable_overscan) ? 16 : 0; - int x_add = (enable_overscan) ? 12 : 0; + int x_add = enable_overscan ? 12 : 0; int dl = svga_display_line(svga); if (svga->firstline_draw == 2000) @@ -495,8 +425,7 @@ void svga_render_text_80_12(svga_t *svga) void svga_render_2bpp_lowres(svga_t *svga) { int changed_offset; - int y_add = (enable_overscan) ? 16 : 0; - int x_add = y_add >> 1; + int x_add = enable_overscan ? 8 : 0; int dl = svga_display_line(svga); if (svga->sc & 1 && !(svga->crtc[0x17] & 1)) @@ -548,8 +477,7 @@ void svga_render_2bpp_lowres(svga_t *svga) void svga_render_2bpp_highres(svga_t *svga) { int changed_offset; - int y_add = (enable_overscan) ? 16 : 0; - int x_add = y_add >> 1; + int x_add = enable_overscan ? 8 : 0; int dl = svga_display_line(svga); if (svga->sc & 1 && !(svga->crtc[0x17] & 1)) @@ -601,8 +529,7 @@ void svga_render_2bpp_highres(svga_t *svga) void svga_render_4bpp_lowres(svga_t *svga) { int x; - int y_add = (enable_overscan) ? 16 : 0; - int x_add = y_add >> 1; + int x_add = enable_overscan ? 8 : 0; int dl = svga_display_line(svga); int offset; uint32_t *p; @@ -649,8 +576,7 @@ void svga_render_4bpp_highres(svga_t *svga) { int changed_offset; int changed_offset2; - int y_add = (enable_overscan) ? 16 : 0; - int x_add = y_add >> 1; + int x_add = enable_overscan ? 8 : 0; int dl = svga_display_line(svga); int x; int offset; @@ -709,8 +635,7 @@ void svga_render_4bpp_highres(svga_t *svga) void svga_render_8bpp_lowres(svga_t *svga) { - int y_add = (enable_overscan) ? 16 : 0; - int x_add = y_add >> 1; + int x_add = enable_overscan ? 8 : 0; int dl = svga_display_line(svga); if (svga->changedvram[svga->ma >> 12] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 1, svga)] || svga->fullchange) @@ -741,8 +666,7 @@ void svga_render_8bpp_lowres(svga_t *svga) void svga_render_8bpp_highres(svga_t *svga) { - int y_add = (enable_overscan) ? 16 : 0; - int x_add = y_add >> 1; + int x_add = enable_overscan ? 8 : 0; int dl = svga_display_line(svga); if (svga->changedvram[svga->ma >> 12] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 1, svga)] || svga->fullchange) @@ -779,8 +703,7 @@ void svga_render_8bpp_highres(svga_t *svga) void svga_render_15bpp_lowres(svga_t *svga) { - int y_add = (enable_overscan) ? 16 : 0; - int x_add = y_add >> 1; + int x_add = enable_overscan ? 8 : 0; int dl = svga_display_line(svga); if (svga->changedvram[svga->ma >> 12] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 1, svga)] || svga->fullchange) @@ -826,8 +749,7 @@ void svga_render_15bpp_lowres(svga_t *svga) void svga_render_15bpp_highres(svga_t *svga) { - int y_add = (enable_overscan) ? 16 : 0; - int x_add = y_add >> 1; + int x_add = enable_overscan ? 8 : 0; int dl = svga_display_line(svga); if (svga->changedvram[svga->ma >> 12] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 1, svga)] || svga->fullchange) @@ -865,8 +787,7 @@ void svga_render_15bpp_highres(svga_t *svga) void svga_render_16bpp_lowres(svga_t *svga) { - int y_add = (enable_overscan) ? 16 : 0; - int x_add = y_add >> 1; + int x_add = enable_overscan ? 8 : 0; int dl = svga_display_line(svga); if (svga->changedvram[svga->ma >> 12] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 1, svga)] || svga->fullchange) @@ -912,8 +833,7 @@ void svga_render_16bpp_lowres(svga_t *svga) void svga_render_16bpp_highres(svga_t *svga) { - int y_add = (enable_overscan) ? 16 : 0; - int x_add = y_add >> 1; + int x_add = enable_overscan ? 8 : 0; int dl = svga_display_line(svga); if (svga->changedvram[svga->ma >> 12] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 1, svga)] || svga->fullchange) @@ -953,8 +873,7 @@ void svga_render_24bpp_lowres(svga_t *svga) { int x, offset; uint32_t fg; - int y_add = (enable_overscan) ? 16 : 0; - int x_add = y_add >> 1; + int x_add = enable_overscan ? 8 : 0; int dl = svga_display_line(svga); if (svga->changedvram[svga->ma >> 12] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 1, svga)] || svga->fullchange) @@ -977,8 +896,7 @@ void svga_render_24bpp_lowres(svga_t *svga) void svga_render_24bpp_highres(svga_t *svga) { - int y_add = (enable_overscan) ? 16 : 0; - int x_add = y_add >> 1; + int x_add = enable_overscan ? 8 : 0; int dl = svga_display_line(svga); if (svga->changedvram[svga->ma >> 12] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 1, svga)] || svga->fullchange) @@ -1015,8 +933,7 @@ void svga_render_32bpp_lowres(svga_t *svga) { int x, offset; uint32_t fg; - int y_add = (enable_overscan) ? 16 : 0; - int x_add = y_add >> 1; + int x_add = enable_overscan ? 8 : 0; int dl = svga_display_line(svga); if (svga->changedvram[svga->ma >> 12] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 1, svga)] || svga->fullchange) @@ -1041,8 +958,7 @@ void svga_render_32bpp_lowres(svga_t *svga) 91%*/ void svga_render_32bpp_highres(svga_t *svga) { - int y_add = (enable_overscan) ? 16 : 0; - int x_add = y_add >> 1; + int x_add = enable_overscan ? 8 : 0; int dl = svga_display_line(svga); if (svga->changedvram[svga->ma >> 12] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 1, svga)] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 2, svga)] || svga->fullchange) @@ -1067,8 +983,7 @@ void svga_render_32bpp_highres(svga_t *svga) void svga_render_ABGR8888_lowres(svga_t *svga) { - int y_add = (enable_overscan) ? 16 : 0; - int x_add = y_add >> 1; + int x_add = enable_overscan ? 8 : 0; int dl = svga_display_line(svga); if (svga->changedvram[svga->ma >> 12] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 1, svga)] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 2, svga)] || svga->fullchange) @@ -1093,8 +1008,7 @@ void svga_render_ABGR8888_lowres(svga_t *svga) void svga_render_ABGR8888_highres(svga_t *svga) { - int y_add = (enable_overscan) ? 16 : 0; - int x_add = y_add >> 1; + int x_add = enable_overscan ? 8 : 0; int dl = svga_display_line(svga); if (svga->changedvram[svga->ma >> 12] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 1, svga)] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 2, svga)] || svga->fullchange) @@ -1119,8 +1033,7 @@ void svga_render_ABGR8888_highres(svga_t *svga) void svga_render_RGBA8888_lowres(svga_t *svga) { - int y_add = (enable_overscan) ? 16 : 0; - int x_add = y_add >> 1; + int x_add = enable_overscan ? 8 : 0; int dl = svga_display_line(svga); if (svga->changedvram[svga->ma >> 12] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 1, svga)] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 2, svga)] || svga->fullchange) @@ -1145,8 +1058,7 @@ void svga_render_RGBA8888_lowres(svga_t *svga) void svga_render_RGBA8888_highres(svga_t *svga) { - int y_add = (enable_overscan) ? 16 : 0; - int x_add = y_add >> 1; + int x_add = enable_overscan ? 8 : 0; int dl = svga_display_line(svga); if (svga->changedvram[svga->ma >> 12] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 1, svga)] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 2, svga)] || svga->fullchange) diff --git a/src/video/vid_tandy.c b/src/video/vid_tandy.c index 1029665f3..e4625836f 100644 --- a/src/video/vid_tandy.c +++ b/src/video/vid_tandy.c @@ -540,13 +540,16 @@ void tandy_poll(void *p) if (tandy->mode & 1) x = (tandy->crtc[1] << 3) + 16; else x = (tandy->crtc[1] << 4) + 16; tandy->lastline++; - if (x != xsize || (tandy->lastline - tandy->firstline) != ysize) + if ((x != xsize) || ((tandy->lastline - tandy->firstline) != ysize) || video_force_resize_get()) { xsize = x; ysize = tandy->lastline - tandy->firstline; if (xsize < 64) xsize = 656; if (ysize < 32) ysize = 200; set_screen_size(xsize, (ysize << 1) + 16); + + if (video_force_resize_get()) + video_force_resize_set(0); } if (tandy->composite) diff --git a/src/video/vid_tandysl.c b/src/video/vid_tandysl.c index 354963472..db317e3e0 100644 --- a/src/video/vid_tandysl.c +++ b/src/video/vid_tandysl.c @@ -609,13 +609,16 @@ static void tandysl_poll(void *p) if (tandy->mode & 1) x = (tandy->crtc[1] << 3) + 16; else x = (tandy->crtc[1] << 4) + 16; tandy->lastline++; - if (x != xsize || (tandy->lastline - tandy->firstline) != ysize) + if ((x != xsize) || ((tandy->lastline - tandy->firstline) != ysize) || video_force_resize_get()) { xsize = x; ysize = tandy->lastline - tandy->firstline; if (xsize < 64) xsize = 656; if (ysize < 32) ysize = 200; set_screen_size(xsize, (ysize << 1) + 16); + + if (video_force_resize_get()) + video_force_resize_set(0); } video_blit_memtoscreen_8(0, tandy->firstline-4, xsize, (tandy->lastline - tandy->firstline) + 8); diff --git a/src/video/vid_wy700.c b/src/video/vid_wy700.c index 76724b3fd..9add7225d 100644 --- a/src/video/vid_wy700.c +++ b/src/video/vid_wy700.c @@ -860,13 +860,16 @@ void wy700_poll(void *p) if (wy700->displine == 800) { /* Hardcode 1280x800 window size */ - if (WY700_XSIZE != xsize || WY700_YSIZE != ysize) + if ((WY700_XSIZE != xsize) || (WY700_YSIZE != ysize) || video_force_resize_get()) { xsize = WY700_XSIZE; ysize = WY700_YSIZE; if (xsize < 64) xsize = 656; if (ysize < 32) ysize = 200; set_screen_size(xsize, ysize); + + if (video_force_resize_get()) + video_force_resize_set(0); } video_blit_memtoscreen_8(0, 0, xsize, ysize); diff --git a/src/video/video.c b/src/video/video.c index 6081b660b..4c1dacefd 100644 --- a/src/video/video.c +++ b/src/video/video.c @@ -110,6 +110,7 @@ int video_timing[6][4] = { { VIDEO_BUS, 4, 5, 10 }, { VIDEO_BUS, 3, 3, 4 } }; +static int video_force_resize; PALETTE cgapal = { {0,0,0}, {0,42,0}, {42,0,0}, {42,21,0}, {0,0,0}, {0,42,42}, {42,0,42}, {42,42,42}, @@ -574,6 +575,20 @@ video_reset(void) } +uint8_t +video_force_resize_get(void) +{ + return video_force_resize; +} + + +void +video_force_resize_set(uint8_t res) +{ + video_force_resize = res; +} + + void loadfont(wchar_t *s, int format) { diff --git a/src/video/video.h b/src/video/video.h index bbdb9f0eb..4fff657b4 100644 --- a/src/video/video.h +++ b/src/video/video.h @@ -107,6 +107,8 @@ extern void updatewindowsize(int x, int y); extern void video_init(void); extern void video_close(void); extern void video_reset(void); +extern uint8_t video_force_resize_get(void); +extern void video_force_resize_set(uint8_t res); extern void video_reset_device(int, int); extern void video_update_timing(void); diff --git a/src/win/win.c b/src/win/win.c index 15fafa5b7..78a5374cb 100644 --- a/src/win/win.c +++ b/src/win/win.c @@ -420,11 +420,13 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) scale = LOWORD(wParam) - IDM_VID_SCALE_1X; CheckMenuItem(hmenu, IDM_VID_SCALE_1X + scale, MF_CHECKED); device_force_redraw(); + video_force_resize_set(1); config_save(); break; case IDM_VID_FORCE43: video_toggle_option(hmenu, &force_43, IDM_VID_FORCE43); + video_force_resize_set(1); break; case IDM_VID_INVERT: @@ -434,6 +436,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) case IDM_VID_OVERSCAN: update_overscan = 1; video_toggle_option(hmenu, &enable_overscan, IDM_VID_OVERSCAN); + video_force_resize_set(1); break; case IDM_VID_CGACON: diff --git a/src/win/win_video.c b/src/win/win_video.c index 7696f37cc..e2bdc2114 100644 --- a/src/win/win_video.c +++ b/src/win/win_video.c @@ -18,6 +18,7 @@ #define BITMAP WINDOWS_BITMAP #include #include +#include #undef BITMAP #include #include @@ -277,17 +278,31 @@ endblit(void) void plat_resize(int x, int y) { + int sb_borders[3]; + RECT r; + +#if 0 pclog("PLAT: VID[%d,%d] resizing to %dx%d\n", video_fullscreen, vid_api, x, y); +#endif /* First, see if we should resize the UI window. */ - if (vid_resize) { - /* Move the main window. */ + if (!vid_resize) { + SendMessage(hwndSBAR, SB_GETBORDERS, 0, (LPARAM) sb_borders); + GetWindowRect(hwndMain, &r); + MoveWindow(hwndRender, 0, 0, x, y, TRUE); + GetWindowRect(hwndRender, &r); + MoveWindow(hwndSBAR, + 0, r.bottom + GetSystemMetrics(SM_CYEDGE), + x, 17, TRUE); + GetWindowRect(hwndMain, &r); - /* Move the status bar with it. */ - MoveWindow(hwndSBAR, 0, y+6, x, 17, TRUE); + MoveWindow(hwndMain, r.left, r.top, + x + (GetSystemMetrics(vid_resize ? SM_CXSIZEFRAME : SM_CXFIXEDFRAME) * 2), + y + (GetSystemMetrics(SM_CYEDGE) * 2) + (GetSystemMetrics(vid_resize ? SM_CYSIZEFRAME : SM_CYFIXEDFRAME) * 2) + GetSystemMetrics(SM_CYMENUSIZE) + GetSystemMetrics(SM_CYCAPTION) + 17 + sb_borders[1] + 1, + TRUE); - /* Move the render window if we have one. */ - if (vid_apis[0][vid_api].local && (hwndRender != NULL)) { - MoveWindow(hwndRender, 0, 0, x, y, TRUE); + if (mousecapture) { + GetWindowRect(hwndRender, &r); + ClipCursor(&r); } }