From 8b316f869b3ede2ab1b4da2c0656525a59714cae Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Thu, 9 Sep 2021 23:51:26 +0600 Subject: [PATCH 1/9] Include SDL.h before anything else This also cleans up the unnecessary source-level defines --- src/unix/unix.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/unix/unix.c b/src/unix/unix.c index ec71dee84..93d3ede73 100644 --- a/src/unix/unix.c +++ b/src/unix/unix.c @@ -2,10 +2,7 @@ #define _FILE_OFFSET_BITS 64 #define _LARGEFILE64_SOURCE 1 #endif -#define _POSIX_C_SOURCE 200809L -#ifdef __APPLE__ -#define _DARWIN_C_SOURCE 1 -#endif +#include #include #include #include @@ -20,7 +17,7 @@ #include #include #include -#include + #include <86box/86box.h> #include <86box/keyboard.h> #include <86box/mouse.h> From 2092f1dceb9a97800f7a4c1c442bc42fcd9e3b33 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Fri, 10 Sep 2021 18:01:21 +0600 Subject: [PATCH 2/9] Update unix_sdl.c --- src/unix/unix_sdl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/unix_sdl.c b/src/unix/unix_sdl.c index e5abdcd32..ff31e5786 100644 --- a/src/unix/unix_sdl.c +++ b/src/unix/unix_sdl.c @@ -367,7 +367,7 @@ sdl_init_common(int flags) } sdl_mutex = SDL_CreateMutex(); - sdl_win = SDL_CreateWindow("86Box", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, scrnsz_x, scrnsz_y, SDL_WINDOW_OPENGL); + sdl_win = SDL_CreateWindow("86Box", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, scrnsz_x, scrnsz_y, SDL_WINDOW_OPENGL | (vid_resize & 1 ? SDL_WINDOW_RESIZABLE : 0)); sdl_set_fs(video_fullscreen); if (!(video_fullscreen & 1)) { From 2e58958f38cb2497aebb69f63141494c6465e800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Fri, 10 Sep 2021 20:31:04 +0200 Subject: [PATCH 3/9] mark us as win10 compatible --- src/win/86Box.manifest | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/win/86Box.manifest b/src/win/86Box.manifest index 454e1df65..045e12dbf 100644 --- a/src/win/86Box.manifest +++ b/src/win/86Box.manifest @@ -32,4 +32,18 @@ UTF-8 + + + + + + + + + + + + + + From 916b66e305301d1707affce97cf42413e5e79eed Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 11 Sep 2021 04:16:39 +0200 Subject: [PATCH 4/9] Removed the unused "table array" from fdd_86f.c. --- src/floppy/fdd_86f.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/floppy/fdd_86f.c b/src/floppy/fdd_86f.c index f0326d3d3..5ff02adb3 100644 --- a/src/floppy/fdd_86f.c +++ b/src/floppy/fdd_86f.c @@ -235,7 +235,6 @@ static d86f_t *d86f[FDD_NUM]; static uint16_t CRCTable[256]; static fdc_t *d86f_fdc; uint64_t poly = 0x42F0E1EBA9EA3693ll; /* ECMA normal */ -uint64_t table[256]; uint16_t d86f_side_flags(int drive); From 04e48a071e4b5ec59ab7c7a01b743d82510c68a4 Mon Sep 17 00:00:00 2001 From: TC1995 Date: Sat, 11 Sep 2021 22:02:31 +0200 Subject: [PATCH 5/9] S3 changes part 3: Added the Phoenix S3 Vision968 (IBM RGB) and the MiroCRYSTAL 20SD VLB (864, SDAC) (alongside their BIOSes). Added the vendor specific bits of CRTC5c used by the MiroVIDEO 40SV Ergo (968), Phoenix 868 and Phoenix 968. Restored FIFO in the pre-964 cards, but without threading (Warning, code might be bloated for this). Fixed horizontal issue with the SPEA Mercury P64V (968). --- src/include/86box/video.h | 6 +- src/video/vid_s3.c | 642 +++++++++++++++++++++++++++++++------- src/video/vid_table.c | 5 +- 3 files changed, 544 insertions(+), 109 deletions(-) diff --git a/src/include/86box/video.h b/src/include/86box/video.h index 2232667ef..be7591dc7 100644 --- a/src/include/86box/video.h +++ b/src/include/86box/video.h @@ -349,6 +349,7 @@ extern const device_t s3_phoenix_trio64vplus_pci_device; extern const device_t s3_phoenix_trio64vplus_onboard_pci_device; extern const device_t s3_mirocrystal_20sv_964_vlb_device; extern const device_t s3_mirocrystal_20sv_964_pci_device; +extern const device_t s3_mirocrystal_20sd_864_vlb_device; extern const device_t s3_phoenix_vision864_pci_device; extern const device_t s3_phoenix_vision864_vlb_device; extern const device_t s3_phoenix_vision868_pci_device; @@ -357,8 +358,9 @@ extern const device_t s3_diamond_stealth64_pci_device; extern const device_t s3_diamond_stealth64_vlb_device; extern const device_t s3_diamond_stealth64_964_pci_device; extern const device_t s3_diamond_stealth64_964_vlb_device; -extern const device_t s3_mirovideo_40sv_968_pci_device; -extern const device_t s3_mirovideo_40sv_968_vlb_device; +extern const device_t s3_mirovideo_40sv_ergo_968_pci_device; +extern const device_t s3_phoenix_vision968_pci_device; +extern const device_t s3_phoenix_vision968_vlb_device; extern const device_t s3_spea_mercury_p64v_pci_device; extern const device_t s3_elsa_winner2000_pro_x_964_pci_device; extern const device_t s3_elsa_winner2000_pro_x_pci_device; diff --git a/src/video/vid_s3.c b/src/video/vid_s3.c index 5aa4922f2..8c204b43e 100644 --- a/src/video/vid_s3.c +++ b/src/video/vid_s3.c @@ -46,6 +46,7 @@ #define ROM_MIROCRYSTAL10SD_805 "roms/video/s3/MIROcrystal10SD_VLB.VBI" #define ROM_MIROCRYSTAL20SV_964_VLB "roms/video/s3/S3_964VL_BT485_27C256_miroCRYSTAL_20sv_ver1.2.bin" #define ROM_MIROCRYSTAL20SV_964_PCI "roms/video/s3/mirocrystal.VBI" +#define ROM_MIROCRYSTAL20SD_864_VLB "roms/video/s3/Miro20SD.BIN" #define ROM_PHOENIX_86C80X "roms/video/s3/805.vbi" #define ROM_PARADISE_BAHAMAS64 "roms/video/s3/bahamas64.bin" #define ROM_PHOENIX_VISION864 "roms/video/s3/86c864p.bin" @@ -61,8 +62,9 @@ #define ROM_ELSAWIN2KPROX_964 "roms/video/s3/elsaw20004m.BIN" #define ROM_ELSAWIN2KPROX "roms/video/s3/elsaw20008m.BIN" #define ROM_PHOENIX_VISION868 "roms/video/s3/1-DSV3868.BIN" -#define ROM_MIROVIDEO40SV_968 "roms/video/s3/S3_968PCI_TVP3026_miroVideo40SV_PCI_1.04.BIN" +#define ROM_MIROVIDEO40SV_ERGO_968_PCI "roms/video/s3/S3_968PCI_TVP3026_miroVideo40SV_PCI_1.04.BIN" #define ROM_SPEA_MERCURY_P64V "roms/video/s3/S3_968PCI_TVP3026_SPEAMecuryP64V_ver1.01.BIN" +#define ROM_PHOENIX_VISION968 "roms/video/s3/1-DSV3968P.BIN" enum { @@ -89,11 +91,13 @@ enum S3_ELSAWIN2KPROX_964, S3_ELSAWIN2KPROX, S3_PHOENIX_VISION868, - S3_MIROVIDEO40SV_968, + S3_MIROVIDEO40SV_ERGO_968, S3_MIROCRYSTAL10SD_805, S3_SPEA_MIRAGE_P64, S3_SPEA_MERCURY_P64V, - S3_MIROCRYSTAL20SV_964 + S3_MIROCRYSTAL20SV_964, + S3_MIROCRYSTAL20SD_864, + S3_PHOENIX_VISION968 }; @@ -253,6 +257,12 @@ typedef struct s3_t int ssv_len1, ssv_len2; uint8_t ssv_dir1, ssv_dir2; uint8_t ssv_draw1, ssv_draw2; + + /*S3 928 and 80x cards only*/ + int setup_fifo_slot, setup_fifo_slot2; + int draw_fifo_slot, draw_fifo_slot2; + int port_slot1, port_slot2; + int port_slot3, port_slot4; } accel; struct { @@ -471,14 +481,16 @@ s3_cpu_dest(s3_t *s3) static int s3_enable_fifo(s3_t *s3) { + svga_t *svga = &s3->svga; + if ((s3->chip == S3_TRIO32) || (s3->chip == S3_TRIO64) || (s3->chip == S3_TRIO64V) || (s3->chip == S3_TRIO64V2) || (s3->chip == S3_VISION864) || (s3->chip == S3_VISION964) || (s3->chip == S3_VISION968) || (s3->chip == S3_VISION868)) return 1; /* FIFO always enabled on these chips. */ - //return !!((svga->crtc[0x40] & 0x08) || (s3->accel.advfunc_cntl & 0x40)); - return 0; /*Disable FIFO on pre-964 cards due to glitches going around*/ + return !!((svga->crtc[0x40] & 0x08) || (s3->accel.advfunc_cntl & 0x40)); + //return 0; /*Disable FIFO on pre-964 cards due to glitches going around*/ } static void @@ -487,6 +499,12 @@ s3_accel_out_pixtrans_w(s3_t *s3, uint16_t val) svga_t *svga = &s3->svga; if (s3->accel.cmd & 0x100) { + s3->accel.port_slot1++; + s3->accel.port_slot2++; + if (s3->accel.port_slot1 || s3->accel.port_slot2) + s3->accel.draw_fifo_slot++; + if (s3->accel.draw_fifo_slot > 8) + s3->accel.draw_fifo_slot = 1; switch (s3->accel.cmd & 0x600) { case 0x000: if (((s3->accel.multifunc[0xa] & 0xc0) == 0x80) || (s3->accel.cmd & 2)) { @@ -546,6 +564,10 @@ s3_accel_out_pixtrans_w(s3_t *s3, uint16_t val) } break; } + + if ((s3_enable_fifo(s3) && s3->chip >= S3_VISION964) || (s3_enable_fifo(s3) == 0)) { + s3->accel.draw_fifo_slot = 0; + } } } @@ -553,6 +575,12 @@ static void s3_accel_out_pixtrans_l(s3_t *s3, uint32_t val) { if (s3->accel.cmd & 0x100) { + s3->accel.port_slot1++; + s3->accel.port_slot2++; + if (s3->accel.port_slot1 || s3->accel.port_slot2) + s3->accel.draw_fifo_slot++; + if (s3->accel.draw_fifo_slot > 8) + s3->accel.draw_fifo_slot = 1; switch (s3->accel.cmd & 0x600) { case 0x000: if (((s3->accel.multifunc[0xa] & 0xc0) == 0x80) || (s3->accel.cmd & 2)) { @@ -612,6 +640,10 @@ s3_accel_out_pixtrans_l(s3_t *s3, uint32_t val) } break; } + + if ((s3_enable_fifo(s3) && s3->chip >= S3_VISION964) || (s3_enable_fifo(s3) == 0)) { + s3->accel.draw_fifo_slot = 0; + } } } @@ -622,6 +654,12 @@ s3_accel_out_fifo(s3_t *s3, uint16_t port, uint8_t val) switch (port) { case 0x8148: case 0x82e8: + s3->accel.port_slot1++; + s3->accel.port_slot2++; + if (s3->accel.port_slot1 || s3->accel.port_slot2) + s3->accel.draw_fifo_slot++; + if (s3->accel.draw_fifo_slot > 8) + s3->accel.draw_fifo_slot = 1; s3->accel.cur_y_bitres = (s3->accel.cur_y_bitres & 0xff00) | val; s3->accel.cur_y = (s3->accel.cur_y & 0xf00) | val; s3->accel.poly_cy = s3->accel.cur_y; @@ -642,6 +680,12 @@ s3_accel_out_fifo(s3_t *s3, uint16_t port, uint8_t val) break; case 0x8548: case 0x86e8: + s3->accel.port_slot1++; + s3->accel.port_slot2++; + if (s3->accel.port_slot1 || s3->accel.port_slot2) + s3->accel.draw_fifo_slot++; + if (s3->accel.draw_fifo_slot > 8) + s3->accel.draw_fifo_slot = 1; s3->accel.cur_x_bitres = (s3->accel.cur_x_bitres & 0xff00) | val; s3->accel.cur_x = (s3->accel.cur_x & 0xf00) | val; s3->accel.poly_cx = s3->accel.cur_x << 20; @@ -664,6 +708,12 @@ s3_accel_out_fifo(s3_t *s3, uint16_t port, uint8_t val) break; case 0x8948: case 0x8ae8: + s3->accel.port_slot1++; + s3->accel.port_slot2++; + if (s3->accel.port_slot1 || s3->accel.port_slot2) + s3->accel.draw_fifo_slot++; + if (s3->accel.draw_fifo_slot > 8) + s3->accel.draw_fifo_slot = 1; s3->accel.desty_axstp = (s3->accel.desty_axstp & 0x3f00) | val; s3->accel.point_1_updated = 1; break; @@ -685,6 +735,12 @@ s3_accel_out_fifo(s3_t *s3, uint16_t port, uint8_t val) break; case 0x8d48: case 0x8ee8: + s3->accel.port_slot1++; + s3->accel.port_slot2++; + if (s3->accel.port_slot1 || s3->accel.port_slot2) + s3->accel.draw_fifo_slot++; + if (s3->accel.draw_fifo_slot > 8) + s3->accel.draw_fifo_slot = 1; s3->accel.destx_distp = (s3->accel.destx_distp & 0x3f00) | val; s3->accel.point_1_updated = 1; break; @@ -704,6 +760,12 @@ s3_accel_out_fifo(s3_t *s3, uint16_t port, uint8_t val) break; case 0x9148: case 0x92e8: + s3->accel.port_slot1++; + s3->accel.port_slot2++; + if (s3->accel.port_slot1 || s3->accel.port_slot2) + s3->accel.draw_fifo_slot++; + if (s3->accel.draw_fifo_slot > 8) + s3->accel.draw_fifo_slot = 1; s3->accel.err_term = (s3->accel.err_term & 0x3f00) | val; break; case 0x9149: case 0x92e9: @@ -721,6 +783,12 @@ s3_accel_out_fifo(s3_t *s3, uint16_t port, uint8_t val) break; case 0x9548: case 0x96e8: + s3->accel.port_slot1++; + s3->accel.port_slot2++; + if (s3->accel.port_slot1 || s3->accel.port_slot2) + s3->accel.draw_fifo_slot++; + if (s3->accel.draw_fifo_slot > 8) + s3->accel.draw_fifo_slot = 1; s3->accel.maj_axis_pcnt = (s3->accel.maj_axis_pcnt & 0xf00) | val; break; case 0x9459: case 0x96e9: @@ -738,6 +806,12 @@ s3_accel_out_fifo(s3_t *s3, uint16_t port, uint8_t val) break; case 0x9948: case 0x9ae8: + s3->accel.port_slot1++; + s3->accel.port_slot2++; + if (s3->accel.port_slot1 || s3->accel.port_slot2) + s3->accel.draw_fifo_slot++; + if (s3->accel.draw_fifo_slot > 8) + s3->accel.draw_fifo_slot = 1; s3->accel.cmd = (s3->accel.cmd & 0xff00) | val; s3->data_available = 0; s3->accel.b2e8_pix = 0; @@ -767,6 +841,12 @@ s3_accel_out_fifo(s3_t *s3, uint16_t port, uint8_t val) break; case 0xa148: case 0xa2e8: + s3->accel.port_slot3++; + s3->accel.port_slot4++; + if (s3->accel.port_slot3 || s3->accel.port_slot4) + s3->accel.setup_fifo_slot++; + if (s3->accel.setup_fifo_slot > 8) + s3->accel.setup_fifo_slot = 1; if (s3->bpp == 3 && s3->accel.multifunc[0xe] & 0x10 && !(s3->accel.multifunc[0xe] & 0x200)) s3->accel.bkgd_color = (s3->accel.bkgd_color & ~0x00ff0000) | (val << 16); else @@ -803,6 +883,12 @@ s3_accel_out_fifo(s3_t *s3, uint16_t port, uint8_t val) break; case 0xa548: case 0xa6e8: + s3->accel.port_slot3++; + s3->accel.port_slot4++; + if (s3->accel.port_slot3 || s3->accel.port_slot4) + s3->accel.setup_fifo_slot++; + if (s3->accel.setup_fifo_slot > 8) + s3->accel.setup_fifo_slot = 1; if (s3->bpp == 3 && s3->accel.multifunc[0xe] & 0x10 && !(s3->accel.multifunc[0xe] & 0x200)) s3->accel.frgd_color = (s3->accel.frgd_color & ~0x00ff0000) | (val << 16); else @@ -839,6 +925,12 @@ s3_accel_out_fifo(s3_t *s3, uint16_t port, uint8_t val) break; case 0xa948: case 0xaae8: + s3->accel.port_slot3++; + s3->accel.port_slot4++; + if (s3->accel.port_slot3 || s3->accel.port_slot4) + s3->accel.setup_fifo_slot++; + if (s3->accel.setup_fifo_slot > 8) + s3->accel.setup_fifo_slot = 1; if (s3->bpp == 3 && s3->accel.multifunc[0xe] & 0x10 && !(s3->accel.multifunc[0xe] & 0x200)) s3->accel.wrt_mask = (s3->accel.wrt_mask & ~0x00ff0000) | (val << 16); else @@ -875,6 +967,12 @@ s3_accel_out_fifo(s3_t *s3, uint16_t port, uint8_t val) break; case 0xad48: case 0xaee8: + s3->accel.port_slot3++; + s3->accel.port_slot4++; + if (s3->accel.port_slot3 || s3->accel.port_slot4) + s3->accel.setup_fifo_slot++; + if (s3->accel.setup_fifo_slot > 8) + s3->accel.setup_fifo_slot = 1; if (s3->bpp == 3 && s3->accel.multifunc[0xe] & 0x10 && !(s3->accel.multifunc[0xe] & 0x200)) s3->accel.rd_mask = (s3->accel.rd_mask & ~0x00ff0000) | (val << 16); else @@ -911,6 +1009,12 @@ s3_accel_out_fifo(s3_t *s3, uint16_t port, uint8_t val) break; case 0xb148: case 0xb2e8: + s3->accel.port_slot1++; + s3->accel.port_slot2++; + if (s3->accel.port_slot1 || s3->accel.port_slot2) + s3->accel.draw_fifo_slot++; + if (s3->accel.draw_fifo_slot > 8) + s3->accel.draw_fifo_slot = 1; if (s3->bpp == 3 && s3->accel.multifunc[0xe] & 0x10 && !(s3->accel.multifunc[0xe] & 0x200)) s3->accel.color_cmp = (s3->accel.color_cmp & ~0x00ff0000) | (val << 16); else @@ -947,10 +1051,22 @@ s3_accel_out_fifo(s3_t *s3, uint16_t port, uint8_t val) break; case 0xb548: case 0xb6e8: + s3->accel.port_slot3++; + s3->accel.port_slot4++; + if (s3->accel.port_slot3 || s3->accel.port_slot4) + s3->accel.setup_fifo_slot++; + if (s3->accel.setup_fifo_slot > 8) + s3->accel.setup_fifo_slot = 1; s3->accel.bkgd_mix = val; break; case 0xb948: case 0xbae8: + s3->accel.port_slot3++; + s3->accel.port_slot4++; + if (s3->accel.port_slot3 || s3->accel.port_slot4) + s3->accel.setup_fifo_slot++; + if (s3->accel.setup_fifo_slot > 8) + s3->accel.setup_fifo_slot = 1; s3->accel.frgd_mix = val; break; @@ -960,6 +1076,24 @@ s3_accel_out_fifo(s3_t *s3, uint16_t port, uint8_t val) case 0xbd49: case 0xbee9: s3->accel.multifunc_cntl = (s3->accel.multifunc_cntl & 0xff) | (val << 8); s3->accel.multifunc[s3->accel.multifunc_cntl >> 12] = s3->accel.multifunc_cntl & 0xfff; + switch (s3->accel.multifunc_cntl >> 12) { + case 0: + s3->accel.port_slot1++; + s3->accel.port_slot2++; + if (s3->accel.port_slot1 || s3->accel.port_slot2) + s3->accel.draw_fifo_slot++; + if (s3->accel.draw_fifo_slot > 8) + s3->accel.draw_fifo_slot = 1; + break; + case 0xa: + s3->accel.port_slot3++; + s3->accel.port_slot4++; + if (s3->accel.port_slot3 || s3->accel.port_slot4) + s3->accel.setup_fifo_slot++; + if (s3->accel.setup_fifo_slot > 8) + s3->accel.setup_fifo_slot = 1; + break; + } break; case 0xd148: case 0xd2e8: @@ -1057,6 +1191,12 @@ s3_accel_out_fifo(s3_t *s3, uint16_t port, uint8_t val) break; s3->accel.pix_trans[0] = val; if (s3->accel.cmd & 0x100) { + s3->accel.port_slot1++; + s3->accel.port_slot2++; + if (s3->accel.port_slot1 || s3->accel.port_slot2) + s3->accel.draw_fifo_slot++; + if (s3->accel.draw_fifo_slot > 8) + s3->accel.draw_fifo_slot = 1; if (!(s3->accel.cmd & 0x600)) { if (((s3->accel.multifunc[0xa] & 0xc0) == 0x80) || (s3->accel.cmd & 2)) { if (((s3->accel.frgd_mix & 0x60) != 0x40) || ((s3->accel.bkgd_mix & 0x60) != 0x40)) @@ -1193,6 +1333,13 @@ s3_accel_out_fifo(s3_t *s3, uint16_t port, uint8_t val) } break; } + + if ((s3_enable_fifo(s3) && s3->chip >= S3_VISION964) || (s3_enable_fifo(s3) == 0)) { + if (s3->accel.port_slot1 || s3->accel.port_slot2) { + s3->accel.draw_fifo_slot = 0; + } else if (s3->accel.port_slot3 || s3->accel.port_slot4) + s3->accel.setup_fifo_slot = 0; + } } static void @@ -1373,6 +1520,13 @@ s3_accel_write_fifo(s3_t *s3, uint32_t addr, uint8_t val) s3_accel_out_fifo(s3, addr & 0xffff, val); } else { if (s3->accel.cmd & 0x100) { + s3->accel.port_slot1++; + s3->accel.port_slot2++; + if (s3->accel.port_slot1 || s3->accel.port_slot2) + s3->accel.draw_fifo_slot++; + if (s3->accel.draw_fifo_slot > 8) + s3->accel.draw_fifo_slot = 1; + if ((s3->accel.cmd & 0x600) == 0x200) { if (((s3->accel.multifunc[0xa] & 0xc0) == 0x80) || (s3->accel.cmd & 2)) { if (((s3->accel.frgd_mix & 0x60) != 0x40) || ((s3->accel.bkgd_mix & 0x60) != 0x40)) @@ -1390,6 +1544,9 @@ s3_accel_write_fifo(s3_t *s3, uint32_t addr, uint8_t val) } else s3_accel_start(1, 1, 0xffffffff, val | (val << 8) | (val << 16) | (val << 24), s3); } + if ((s3_enable_fifo(s3) && s3->chip >= S3_VISION964) || (s3_enable_fifo(s3) == 0)) { + s3->accel.draw_fifo_slot = 0; + } } } } @@ -2175,8 +2332,9 @@ s3_io_set_alt(s3_t *s3) if (!s3->translate) return; - if ((s3->chip == S3_VISION968 || s3->chip == S3_VISION868) && (svga->seqregs[9] & 0x80)) + if ((s3->chip == S3_VISION968 || s3->chip == S3_VISION868) && (svga->seqregs[9] & 0x80)) { return; + } io_sethandler(0x4148, 0x0002, s3_accel_in, NULL, NULL, s3_accel_out, NULL, NULL, s3); io_sethandler(0x4548, 0x0002, s3_accel_in, NULL, NULL, s3_accel_out, NULL, NULL, s3); @@ -2233,8 +2391,9 @@ s3_io_set(s3_t *s3) io_sethandler(0x03c0, 0x0020, s3_in, NULL, NULL, s3_out, NULL, NULL, s3); - if ((s3->chip == S3_VISION968 || s3->chip == S3_VISION868) && (svga->seqregs[9] & 0x80)) + if ((s3->chip == S3_VISION968 || s3->chip == S3_VISION868) && (svga->seqregs[9] & 0x80)) { return; + } io_sethandler(0x42e8, 0x0002, s3_accel_in, NULL, NULL, s3_accel_out, NULL, NULL, s3); io_sethandler(0x46e8, 0x0002, s3_accel_in, NULL, NULL, s3_accel_out, NULL, NULL, s3); @@ -2354,9 +2513,10 @@ s3_out(uint16_t addr, uint8_t val, void *p) else rs3 = 0; bt48x_ramdac_out(addr, rs2, rs3, val, svga->ramdac, svga); - } else if ((s3->chip == S3_VISION964 && s3->card_type == S3_ELSAWIN2KPROX_964) || (s3->chip == S3_VISION968 && s3->card_type == S3_ELSAWIN2KPROX)) + } else if ((s3->chip == S3_VISION964 && s3->card_type == S3_ELSAWIN2KPROX_964) || (s3->chip == S3_VISION968 && (s3->card_type == S3_ELSAWIN2KPROX || + s3->card_type == S3_PHOENIX_VISION968))) ibm_rgb528_ramdac_out(addr, rs2, val, svga->ramdac, svga); - else if ((s3->chip == S3_VISION968 && (s3->card_type == S3_MIROVIDEO40SV_968 || s3->card_type == S3_SPEA_MERCURY_P64V))) { + else if ((s3->chip == S3_VISION968 && (s3->card_type == S3_SPEA_MERCURY_P64V || s3->card_type == S3_MIROVIDEO40SV_ERGO_968))) { rs3 = !!(svga->crtc[0x55] & 0x02); tvp3026_ramdac_out(addr, rs2, rs3, val, svga->ramdac, svga); } else if (((s3->chip == S3_86C801) || (s3->chip == S3_86C805)) && (s3->card_type != S3_MIROCRYSTAL10SD_805)) @@ -2383,7 +2543,7 @@ s3_out(uint16_t addr, uint8_t val, void *p) return; if ((svga->crtcreg == 0x36) && (svga->crtc[0x39] != 0xa5)) return; - if (s3->chip == S3_TRIO64V2 && svga->crtcreg >= 0x80) + if ((s3->chip == S3_TRIO64V2) && svga->crtcreg >= 0x80) return; old = svga->crtc[svga->crtcreg]; svga->crtc[svga->crtcreg] = val; @@ -2418,6 +2578,19 @@ s3_out(uint16_t addr, uint8_t val, void *p) } s3->bpp = (svga->crtc[0x50] >> 4) & 3; break; + + case 0x5c: + if ((val & 0xa0) == 0x80) + i2c_gpio_set(s3->i2c, !!(val & 0x40), !!(val & 0x10)); + if (s3->card_type == S3_PHOENIX_VISION868 || s3->card_type == S3_PHOENIX_VISION968) { + if ((val & 0x20) && (!(svga->crtc[0x55] & 0x01) && !(svga->crtc[0x43] & 2))) + svga->dac_addr |= 0x20; + } else if (s3->card_type == S3_MIROVIDEO40SV_ERGO_968) { + if ((val & 0x80) && (!(svga->crtc[0x55] & 0x01) && !(svga->crtc[0x43] & 2))) + svga->dac_addr |= 0x02; + } + break; + case 0x69: if (s3->chip >= S3_VISION964) s3->ma_ext = val & 0x1f; @@ -2444,6 +2617,7 @@ s3_out(uint16_t addr, uint8_t val, void *p) else s3->ma_ext = (s3->ma_ext & ~0xc) | ((val & 3) << 2); break; + case 0x6a: if (s3->chip >= S3_VISION964) { s3->bank = val; @@ -2530,11 +2704,6 @@ s3_out(uint16_t addr, uint8_t val, void *p) } break; - case 0x5c: - if ((val & 0xa0) == 0x80) - i2c_gpio_set(s3->i2c, !!(val & 0x40), !!(val & 0x10)); - break; - case 0x42: if ((s3->chip == S3_VISION964) || (s3->chip == S3_VISION968) || (s3->chip == S3_86C928)) { if (((svga->miscout >> 2) & 3) == 3) @@ -2612,8 +2781,14 @@ s3_in(uint16_t addr, void *p) break; case 0x3c5: - if (svga->seqaddr >= 0x10 && svga->seqaddr < 0x20) - return svga->seqregs[svga->seqaddr]; + if (svga->seqaddr >= 0x10 && svga->seqaddr < 0x20) { + temp = svga->seqregs[svga->seqaddr]; + /* This is needed for the Intel Advanced/ATX's built-in S3 Trio64V+ BIOS to not + get stuck in an infinite loop. */ + if ((s3->card_type == S3_PHOENIX_TRIO64VPLUS_ONBOARD) && (svga->seqaddr == 0x17)) + svga->seqregs[svga->seqaddr] ^= 0x01; + return temp; + } break; case 0x3c6: case 0x3c7: case 0x3c8: case 0x3c9: @@ -2623,9 +2798,10 @@ s3_in(uint16_t addr, void *p) else if ((s3->chip == S3_VISION964 && s3->card_type != S3_ELSAWIN2KPROX_964) || (s3->chip == S3_86C928)) { rs3 = !!(svga->crtc[0x55] & 0x02); return bt48x_ramdac_in(addr, rs2, rs3, svga->ramdac, svga); - } else if ((s3->chip == S3_VISION964 && s3->card_type == S3_ELSAWIN2KPROX_964) || (s3->chip == S3_VISION968 && s3->card_type == S3_ELSAWIN2KPROX)) + } else if ((s3->chip == S3_VISION964 && s3->card_type == S3_ELSAWIN2KPROX_964) || (s3->chip == S3_VISION968 && (s3->card_type == S3_ELSAWIN2KPROX || + s3->card_type == S3_PHOENIX_VISION968))) return ibm_rgb528_ramdac_in(addr, rs2, svga->ramdac, svga); - else if ((s3->chip == S3_VISION968 && (s3->card_type == S3_MIROVIDEO40SV_968 || s3->card_type == S3_SPEA_MERCURY_P64V))) { + else if ((s3->chip == S3_VISION968 && (s3->card_type == S3_SPEA_MERCURY_P64V || s3->card_type == S3_MIROVIDEO40SV_ERGO_968))) { rs3 = !!(svga->crtc[0x55] & 0x02); return tvp3026_ramdac_in(addr, rs2, rs3, svga->ramdac, svga); } else if (((s3->chip == S3_86C801) || (s3->chip == S3_86C805)) && (s3->card_type != S3_MIROCRYSTAL10SD_805)) @@ -2648,7 +2824,10 @@ s3_in(uint16_t addr, void *p) case 0x31: return (svga->crtc[0x31] & 0xcf) | ((s3->ma_ext & 3) << 4); case 0x35: return (svga->crtc[0x35] & 0xf0) | (s3->bank & 0xf); case 0x45: s3->hwc_col_stack_pos = 0; break; - case 0x51: return (svga->crtc[0x51] & 0xf0) | ((s3->bank >> 2) & 0xc) | ((s3->ma_ext >> 2) & 3); + case 0x51: + if (s3->chip == S3_86C801 || s3->chip == S3_86C805) + return (svga->crtc[0x51] & 0xfa) | ((s3->bank >> 2) & 0x4) | ((s3->ma_ext >> 2) & 1); + return (svga->crtc[0x51] & 0xf0) | ((s3->bank >> 2) & 0xc) | ((s3->ma_ext >> 2) & 3); case 0x5c: /* General Output Port Register */ temp = svga->crtc[svga->crtcreg] & 0xa0; if (((svga->miscout >> 2) & 3) == 3) @@ -2667,7 +2846,7 @@ s3_in(uint16_t addr, void *p) /* Phoenix S3 video BIOS'es seem to expect CRTC registers 6B and 6C to be mirrors of 59 and 5A. */ case 0x6b: - if (s3->chip != S3_TRIO64V2 && s3->card_type != S3_MIROVIDEO40SV_968) { + if (s3->chip != S3_TRIO64V2) { if (svga->crtc[0x53] & 0x08) { return (s3->chip == S3_TRIO64V) ? (svga->crtc[0x59] & 0xfc) : (svga->crtc[0x59] & 0xfe); } else { @@ -2677,10 +2856,10 @@ s3_in(uint16_t addr, void *p) return svga->crtc[0x6b]; break; case 0x6c: - if (s3->chip != S3_TRIO64V2 && s3->card_type != S3_MIROVIDEO40SV_968) { - if (svga->crtc[0x53] & 0x08) + if (s3->chip != S3_TRIO64V2) { + if (svga->crtc[0x53] & 0x08) { return 0x00; - else + } else return (svga->crtc[0x5a] & 0x80); } else return svga->crtc[0x6c]; @@ -2721,7 +2900,7 @@ static void s3_recalctimings(svga_t *svga) else bt48x_recalctimings(svga->ramdac, svga); } else if (s3->chip == S3_VISION968) { - if (s3->card_type == S3_MIROVIDEO40SV_968 || s3->card_type == S3_SPEA_MERCURY_P64V) + if (s3->card_type == S3_SPEA_MERCURY_P64V || s3->card_type == S3_MIROVIDEO40SV_ERGO_968) tvp3026_recalctimings(svga->ramdac, svga); else ibm_rgb528_recalctimings(svga->ramdac, svga); @@ -2741,10 +2920,7 @@ static void s3_recalctimings(svga_t *svga) svga->lowres = !((svga->gdcreg[5] & 0x40) && (svga->crtc[0x3a] & 0x10)); - if (((svga->gdcreg[5] & 0x40) && (svga->crtc[0x3a] & 0x10)) || (svga->crtc[0x3a] & 0x10)) { - pclog("CRTC14 bit 6 byte mode = %02x, CRTC17 bit 6 byte mode = %02x, CRTC17 bit 5 word mode ma15 = %02x, CRTC31 bit 3 dword mode = %02x\n", - svga->crtc[0x14] & 0x40, svga->crtc[0x17] & 0x40, svga->crtc[0x17] & 0x20, svga->crtc[0x31] & 0x08); - + if (((svga->gdcreg[5] & 0x40) && (svga->crtc[0x3a] & 0x10)) || (svga->crtc[0x3a] & 0x10)) { if (svga->crtc[0x31] & 0x08) /*This would typically force dword mode, but we are encountering accel bugs with it, so force byte mode instead*/ svga->force_byte_mode = 1; else @@ -2766,11 +2942,13 @@ static void s3_recalctimings(svga_t *svga) svga->hdisp *= 2; } - if (s3->card_type == S3_MIROVIDEO40SV_968) { + if (s3->card_type == S3_MIROVIDEO40SV_ERGO_968 || s3->card_type == S3_MIROCRYSTAL20SD_864 || + s3->card_type == S3_PHOENIX_VISION968 || s3->card_type == S3_SPEA_MERCURY_P64V) { if (svga->hdisp != 1408) svga->hdisp = s3->width; } if (s3->card_type == S3_MIROCRYSTAL10SD_805) { + pclog("S3 CRTC51 = %02x, CRTC5D = %02x, CRTC5E = %02x, CRTC35 = %02x\n", svga->crtc[0x51], svga->crtc[0x5d], svga->crtc[0x5e], svga->crtc[0x35]); if (svga->rowoffset == 256 && ((svga->crtc[0x51] & 0x30) == 0x00 && !(svga->crtc[0x43] & 0x04))) svga->rowoffset >>= 1; } @@ -2792,6 +2970,16 @@ static void s3_recalctimings(svga_t *svga) if (s3->width == 1280 || s3->width == 1600) svga->hdisp *= 2; } + if (s3->card_type == S3_MIROVIDEO40SV_ERGO_968 || s3->card_type == S3_PHOENIX_VISION968 || + s3->card_type == S3_SPEA_MERCURY_P64V) { + if (svga->hdisp == (1408*2)) + svga->hdisp /= 2; + else + svga->hdisp = s3->width; + } + + if (s3->card_type == S3_SPEA_MIRAGE_86C801 || s3->card_type == S3_SPEA_MIRAGE_86C805) + svga->hdisp = s3->width; break; case 16: svga->render = svga_render_16bpp_highres; @@ -2811,7 +2999,8 @@ static void s3_recalctimings(svga_t *svga) if (s3->width == 1280 || s3->width == 1600) svga->hdisp *= 2; } - if (s3->card_type == S3_MIROVIDEO40SV_968) { + if (s3->card_type == S3_MIROVIDEO40SV_ERGO_968 || s3->card_type == S3_PHOENIX_VISION968 || + s3->card_type == S3_SPEA_MERCURY_P64V) { if (svga->hdisp == (1408*2)) svga->hdisp /= 2; else @@ -2829,7 +3018,8 @@ static void s3_recalctimings(svga_t *svga) else svga->hdisp = (svga->hdisp * 2) / 3; } else { - if (s3->card_type == S3_MIROVIDEO40SV_968) + if (s3->card_type == S3_MIROVIDEO40SV_ERGO_968 || s3->card_type == S3_PHOENIX_VISION968 || + s3->card_type == S3_SPEA_MERCURY_P64V) svga->hdisp = s3->width; } break; @@ -2844,7 +3034,9 @@ static void s3_recalctimings(svga_t *svga) } if (s3->width == 1280 || s3->width == 1600 || (s3->card_type == S3_SPEA_MERCURY_P64V)) svga->hdisp *= 2; - if (s3->card_type == S3_MIROVIDEO40SV_968 || s3->card_type == S3_MIROCRYSTAL20SV_964) + if (s3->card_type == S3_MIROVIDEO40SV_ERGO_968 || s3->card_type == S3_MIROCRYSTAL20SV_964 || + s3->card_type == S3_MIROCRYSTAL20SD_864 || s3->card_type == S3_PHOENIX_VISION968 || + s3->card_type == S3_SPEA_MERCURY_P64V) svga->hdisp = s3->width; break; } @@ -3067,7 +3259,7 @@ s3_updatemapping(s3_t *s3) mem_mapping_enable(&s3->mmio_mapping); } else mem_mapping_disable(&s3->mmio_mapping); - + /* New MMIO. */ if (svga->crtc[0x53] & 0x08) mem_mapping_set_addr(&s3->new_mmio_mapping, s3->linear_base + 0x1000000, 0x20000); @@ -3104,7 +3296,10 @@ s3_accel_out(uint16_t port, uint8_t val, void *p) if (port >= 0x8000) { if (s3_enable_fifo(s3)) { - s3_queue(s3, port, val, FIFO_OUT_BYTE); + if (s3->chip <= S3_86C805) + s3_accel_out_fifo(s3, port, val); + else + s3_queue(s3, port, val, FIFO_OUT_BYTE); } else { s3_accel_out_fifo(s3, port, val); } @@ -3150,9 +3345,12 @@ s3_accel_out_w(uint16_t port, uint16_t val, void *p) if (!s3->enable_8514) return; - if (s3_enable_fifo(s3)) - s3_queue(s3, port, val, FIFO_OUT_WORD); - else + if (s3_enable_fifo(s3)) { + if (s3->chip <= S3_86C805) + s3_accel_out_fifo_w(s3, port, val); + else + s3_queue(s3, port, val, FIFO_OUT_WORD); + } else s3_accel_out_fifo_w(s3, port, val); } @@ -3164,9 +3362,12 @@ s3_accel_out_l(uint16_t port, uint32_t val, void *p) if (!s3->enable_8514) return; - if (s3_enable_fifo(s3)) - s3_queue(s3, port, val, FIFO_OUT_DWORD); - else + if (s3_enable_fifo(s3)) { + if (s3->chip <= S3_86C805) + s3_accel_out_fifo_l(s3, port, val); + else + s3_queue(s3, port, val, FIFO_OUT_DWORD); + } else s3_accel_out_fifo_l(s3, port, val); } @@ -3188,6 +3389,7 @@ s3_accel_in(uint16_t port, void *p) case 0x8148: case 0x82e8: s3_wait_fifo_idle(s3); + return s3->accel.cur_y & 0xff; case 0x8149: case 0x82e9: s3_wait_fifo_idle(s3); @@ -3249,29 +3451,122 @@ s3_accel_in(uint16_t port, void *p) case 0x8118: case 0x9948: case 0x9ae8: temp = 0; /* FIFO empty */ - if (!s3->blitter_busy) + if (!s3->blitter_busy && s3->chip >= S3_VISION964) wake_fifo_thread(s3); if (FIFO_FULL && (s3->chip >= S3_VISION964)) temp = 0xff; /*FIFO full*/ - return temp; /*FIFO empty*/ + else if (s3->chip <= S3_86C805) { + if (s3_enable_fifo(s3)) { + if (s3->accel.port_slot3) { + if (s3->accel.setup_fifo_slot) { + switch (s3->accel.setup_fifo_slot) { + case 1: + temp = 1; + break; + case 2: + temp = 3; + break; + case 3: + temp = 7; + break; + case 4: + temp = 0x0f; + break; + case 5: + temp = 0x1f; + break; + case 6: + temp = 0x3f; + break; + case 7: + temp = 0x7f; + break; + case 8: + temp = 0xff; + break; + } + } + + s3->accel.setup_fifo_slot2 = s3->accel.setup_fifo_slot; + s3->accel.setup_fifo_slot = 0; + s3->accel.port_slot3 = 0; + } else if (s3->accel.port_slot1) { + if (s3->accel.draw_fifo_slot) { + switch (s3->accel.draw_fifo_slot) { + case 1: + temp = 1; + break; + case 2: + temp = 3; + break; + case 3: + temp = 7; + break; + case 4: + temp = 0x0f; + break; + case 5: + temp = 0x1f; + break; + case 6: + temp = 0x3f; + break; + case 7: + temp = 0x7f; + break; + case 8: + temp = 0xff; + break; + } + } + + s3->accel.draw_fifo_slot2 = s3->accel.draw_fifo_slot; + s3->accel.draw_fifo_slot = 0; + s3->accel.port_slot1 = 0; + } + } + } + return temp; case 0x8119: case 0x9949: case 0x9ae9: - if (!s3->blitter_busy) + if (!s3->blitter_busy && s3->chip >= S3_VISION964) wake_fifo_thread(s3); temp = 0; - if ((s3->chip >= S3_86C928) && s3_enable_fifo(s3)) { - if (!FIFO_EMPTY || s3->force_busy) { - temp |= 0x02; /*Hardware busy*/ + if (s3_enable_fifo(s3)) { + if (s3->chip >= S3_VISION964) { + if (!FIFO_EMPTY || s3->force_busy) { + temp |= 0x02; /*Hardware busy*/ + } else { + temp |= 0x04; /*FIFO empty*/ + } + s3->force_busy = 0; + if (FIFO_FULL) + temp |= 0xf8; /*FIFO full*/ } else { - temp |= 0x04; /*FIFO empty*/ + if (s3->force_busy) { + temp |= 0x02; /*Hardware busy*/ + } else { + if (s3->accel.port_slot2) { + s3->accel.port_slot2 = 0; + if (!s3->accel.draw_fifo_slot2) + temp |= 0x04; /*FIFO empty*/ + if (s3->accel.draw_fifo_slot2) + s3->accel.draw_fifo_slot2 = 0; + } else if (s3->accel.port_slot4) { + s3->accel.port_slot4 = 0; + if (!s3->accel.setup_fifo_slot2) + temp |= 0x04; /*FIFO empty*/ + if (s3->accel.setup_fifo_slot2) + s3->accel.setup_fifo_slot2 = 0; + } + } + + s3->force_busy = 0; + if (s3->data_available) { + temp |= 0x01; /*Read Data available*/ + s3->data_available = 0; + } } - s3->force_busy = 0; - if (s3->data_available && (s3->chip <= S3_86C805)) { - temp |= 0x01; /*Read Data available*/ - s3->data_available = 0; - } - if (FIFO_FULL && s3->chip >= S3_VISION964) - temp |= 0xf8; /*FIFO full*/ } else { if (s3->force_busy) { temp |= 0x02; /*Hardware busy*/ @@ -3508,6 +3803,12 @@ s3_accel_in(uint16_t port, void *p) break; READ_PIXTRANS_BYTE_IO(0) if (s3->accel.cmd & 0x100) { + s3->accel.port_slot1++; + s3->accel.port_slot2++; + if (s3->accel.port_slot1 || s3->accel.port_slot2) + s3->accel.draw_fifo_slot++; + if (s3->accel.draw_fifo_slot > 8) + s3->accel.draw_fifo_slot = 1; switch (s3->accel.cmd & 0x600) { case 0x000: if (((s3->accel.multifunc[0xa] & 0xc0) == 0x80) || (s3->accel.cmd & 2)) { @@ -3602,6 +3903,10 @@ s3_accel_in(uint16_t port, void *p) return temp; } + if (s3_enable_fifo(s3) == 0) { + s3->accel.draw_fifo_slot = 0; + } + return 0xff; } @@ -3619,6 +3924,13 @@ s3_accel_in_w(uint16_t port, void *p) if (s3_cpu_dest(s3)) { READ_PIXTRANS_WORD + s3->accel.port_slot1++; + s3->accel.port_slot2++; + if (s3->accel.port_slot1 || s3->accel.port_slot2) + s3->accel.draw_fifo_slot++; + if (s3->accel.draw_fifo_slot > 8) + s3->accel.draw_fifo_slot = 1; + switch (s3->accel.cmd & 0x600) { case 0x000: if (((s3->accel.multifunc[0xa] & 0xc0) == 0x80) || (s3->accel.cmd & 2)) { @@ -3639,6 +3951,10 @@ s3_accel_in_w(uint16_t port, void *p) s3_accel_start(2, 1, 0xffffffff, temp | (temp << 16), s3); break; } + + if (s3_enable_fifo(s3) == 0) { + s3->accel.draw_fifo_slot = 0; + } } return temp; } @@ -3657,6 +3973,13 @@ s3_accel_in_l(uint16_t port, void *p) if (s3_cpu_dest(s3)) { READ_PIXTRANS_LONG + s3->accel.port_slot1++; + s3->accel.port_slot2++; + if (s3->accel.port_slot1 || s3->accel.port_slot2) + s3->accel.draw_fifo_slot++; + if (s3->accel.draw_fifo_slot > 8) + s3->accel.draw_fifo_slot = 1; + switch (s3->accel.cmd & 0x600) { case 0x000: if (((s3->accel.multifunc[0xa] & 0xc0) == 0x80) || (s3->accel.cmd & 2)) { @@ -3687,6 +4010,10 @@ s3_accel_in_l(uint16_t port, void *p) } break; } + + if (s3_enable_fifo(s3) == 0) { + s3->accel.draw_fifo_slot = 0; + } } return temp; @@ -3702,11 +4029,15 @@ s3_accel_write(uint32_t addr, uint8_t val, void *p) if (!s3->enable_8514) return; - if (s3_enable_fifo(s3)) { - if (svga->crtc[0x53] & 0x08) - s3_queue(s3, addr & 0x1ffff, val, FIFO_WRITE_BYTE); - else - s3_queue(s3, addr & 0xffff, val, FIFO_WRITE_BYTE); + if (s3_enable_fifo(s3)) { + if (s3->chip <= S3_86C805) { + s3_accel_write_fifo(s3, addr & 0xffff, val); + } else { + if (svga->crtc[0x53] & 0x08) + s3_queue(s3, addr & 0x1ffff, val, FIFO_WRITE_BYTE); + else + s3_queue(s3, addr & 0xffff, val, FIFO_WRITE_BYTE); + } } else s3_accel_write_fifo(s3, addr & 0xffff, val); } @@ -3721,10 +4052,14 @@ s3_accel_write_w(uint32_t addr, uint16_t val, void *p) return; if (s3_enable_fifo(s3)) { - if (svga->crtc[0x53] & 0x08) - s3_queue(s3, addr & 0x1ffff, val, FIFO_WRITE_WORD); - else - s3_queue(s3, addr & 0xffff, val, FIFO_WRITE_WORD); + if (s3->chip <= S3_86C805) { + s3_accel_write_fifo_w(s3, addr & 0xffff, val); + } else { + if (svga->crtc[0x53] & 0x08) + s3_queue(s3, addr & 0x1ffff, val, FIFO_WRITE_WORD); + else + s3_queue(s3, addr & 0xffff, val, FIFO_WRITE_WORD); + } } else s3_accel_write_fifo_w(s3, addr & 0xffff, val); } @@ -3739,10 +4074,14 @@ s3_accel_write_l(uint32_t addr, uint32_t val, void *p) return; if (s3_enable_fifo(s3)) { - if (svga->crtc[0x53] & 0x08) - s3_queue(s3, addr & 0x1ffff, val, FIFO_WRITE_DWORD); - else - s3_queue(s3, addr & 0xffff, val, FIFO_WRITE_DWORD); + if (s3->chip <= S3_86C805) { + s3_accel_write_fifo_l(s3, addr & 0xffff, val); + } else { + if (svga->crtc[0x53] & 0x08) + s3_queue(s3, addr & 0x1ffff, val, FIFO_WRITE_DWORD); + else + s3_queue(s3, addr & 0xffff, val, FIFO_WRITE_DWORD); + } } else s3_accel_write_fifo_l(s3, addr & 0xffff, val); } @@ -3789,6 +4128,13 @@ s3_accel_read(uint32_t addr, void *p) } else if (s3_cpu_dest(s3)) { READ_PIXTRANS_BYTE_MM + s3->accel.port_slot1++; + s3->accel.port_slot2++; + if (s3->accel.port_slot1 || s3->accel.port_slot2) + s3->accel.draw_fifo_slot++; + if (s3->accel.draw_fifo_slot > 8) + s3->accel.draw_fifo_slot = 1; + switch (s3->accel.cmd & 0x600) { case 0x000: if (((s3->accel.multifunc[0xa] & 0xc0) == 0x80) || (s3->accel.cmd & 2)) { @@ -3809,6 +4155,10 @@ s3_accel_read(uint32_t addr, void *p) s3_accel_start(2, 1, 0xffffffff, temp | (temp << 8) | (temp << 16) | (temp << 24), s3); break; } + + if (s3_enable_fifo(s3) == 0) { + s3->accel.draw_fifo_slot = 0; + } } } @@ -3840,6 +4190,13 @@ s3_accel_read_w(uint32_t addr, void *p) } else if (s3_cpu_dest(s3)) { READ_PIXTRANS_WORD + s3->accel.port_slot1++; + s3->accel.port_slot2++; + if (s3->accel.port_slot1 || s3->accel.port_slot2) + s3->accel.draw_fifo_slot++; + if (s3->accel.draw_fifo_slot > 8) + s3->accel.draw_fifo_slot = 1; + switch (s3->accel.cmd & 0x600) { case 0x000: if (((s3->accel.multifunc[0xa] & 0xc0) == 0x80) || (s3->accel.cmd & 2)) { @@ -3860,6 +4217,10 @@ s3_accel_read_w(uint32_t addr, void *p) s3_accel_start(2, 1, 0xffffffff, temp | (temp << 16), s3); break; } + + if (s3_enable_fifo(s3) == 0) { + s3->accel.draw_fifo_slot = 0; + } } } @@ -3998,6 +4359,13 @@ s3_accel_read_l(uint32_t addr, void *p) } else if (s3_cpu_dest(s3)) { READ_PIXTRANS_LONG + s3->accel.port_slot1++; + s3->accel.port_slot2++; + if (s3->accel.port_slot1 || s3->accel.port_slot2) + s3->accel.draw_fifo_slot++; + if (s3->accel.draw_fifo_slot > 8) + s3->accel.draw_fifo_slot = 1; + switch (s3->accel.cmd & 0x600) { case 0x000: if (((s3->accel.multifunc[0xa] & 0xc0) == 0x80) || (s3->accel.cmd & 2)) { @@ -4028,6 +4396,10 @@ s3_accel_read_l(uint32_t addr, void *p) } break; } + + if (s3_enable_fifo(s3) == 0) { + s3->accel.draw_fifo_slot = 0; + } } } @@ -4851,6 +5223,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ /*Bit 4 of the Command register is the draw yes bit, which enables writing to memory/reading from memory when enabled. When this bit is disabled, no writing to memory/reading from memory is allowed. (This bit is almost meaningless on the NOP command)*/ + switch (cmd) { case 0: /*NOP (Short Stroke Vectors)*/ @@ -5176,7 +5549,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ s3->accel.cy |= ~0xfff; } } - + s3->accel.dest = dstbase + s3->accel.cy * s3->width; if (s3_cpu_src(s3)) { @@ -5410,7 +5783,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ } } } - + s3->accel.src = srcbase + s3->accel.cy * s3->width; s3->accel.dest = dstbase + s3->accel.dy * s3->width; } @@ -5422,6 +5795,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ frgd_mix = (s3->accel.frgd_mix >> 5) & 3; bkgd_mix = (s3->accel.bkgd_mix >> 5) & 3; + if (!cpu_input && frgd_mix == 3 && !vram_mask && !compare_mode && (s3->accel.cmd & 0xa0) == 0xa0 && (s3->accel.frgd_mix & 0xf) == 7 && (s3->accel.bkgd_mix & 0xf) == 7) @@ -5449,7 +5823,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ s3->accel.cx -= (s3->accel.maj_axis_pcnt & 0xfff) + 1; s3->accel.dx -= (s3->accel.maj_axis_pcnt & 0xfff) + 1; s3->accel.sx = s3->accel.maj_axis_pcnt & 0xfff; - + s3->accel.cy++; s3->accel.dy++; @@ -5505,6 +5879,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ mix_dat <<= 1; mix_dat |= 1; + if (s3->bpp == 0) cpu_dat >>= 8; else cpu_dat >>= 16; @@ -5530,7 +5905,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ { s3->accel.cx += (s3->accel.maj_axis_pcnt & 0xfff) + 1; s3->accel.dx += (s3->accel.maj_axis_pcnt & 0xfff) + 1; - } + } s3->accel.sx = s3->accel.maj_axis_pcnt & 0xfff; @@ -5550,11 +5925,13 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ s3->accel.sy--; - if (cpu_input) + if (cpu_input) { return; + } - if (s3->accel.sy < 0) + if (s3->accel.sy < 0) { return; + } } } } @@ -5575,7 +5952,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ if (s3->accel.cur_x_bit12) s3->accel.cx |= ~0xfff; s3->accel.cy = s3->accel.cur_y & 0xfff; if (s3->accel.cur_y_bit12) s3->accel.cy |= ~0xfff; - + /*Align source with destination*/ s3->accel.pattern = (s3->accel.cy * s3->width) + s3->accel.cx; s3->accel.dest = dstbase + s3->accel.dy * s3->width; @@ -5675,9 +6052,12 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ s3->accel.sy--; - if (cpu_input/* && (s3->accel.multifunc[0xa] & 0xc0) == 0x80*/) return; - if (s3->accel.sy < 0) + if (cpu_input) { return; + } + if (s3->accel.sy < 0) { + return; + } } } break; @@ -6097,7 +6477,7 @@ s3_pci_write(int func, int addr, uint8_t val, void *p) { s3_t *s3 = (s3_t *)p; svga_t *svga = &s3->svga; - + switch (addr) { case 0x00: case 0x01: case 0x02: case 0x03: @@ -6176,7 +6556,7 @@ static int vram_sizes[] = 0, 0, /*4 MB*/ 0, - 0, + 0, /*6 MB*/ 0, 3 /*8 MB*/ }; @@ -6239,6 +6619,11 @@ static void *s3_init(const device_t *info) else video_inform(VIDEO_FLAG_TYPE_SPECIAL, &timing_s3_86c801); break; + case S3_MIROCRYSTAL20SD_864: + bios_fn = ROM_MIROCRYSTAL20SD_864_VLB; + chip = S3_VISION864; + video_inform(VIDEO_FLAG_TYPE_SPECIAL, &timing_s3_vision864_vlb); + break; case S3_PARADISE_BAHAMAS64: bios_fn = ROM_PARADISE_BAHAMAS64; chip = S3_VISION864; @@ -6275,14 +6660,19 @@ static void *s3_init(const device_t *info) chip = S3_VISION964; if (info->flags & DEVICE_PCI) { bios_fn = ROM_MIROCRYSTAL20SV_964_PCI; - video_inform(VIDEO_FLAG_TYPE_SPECIAL, &timing_s3_vision864_pci); + video_inform(VIDEO_FLAG_TYPE_SPECIAL, &timing_s3_vision964_pci); } else { bios_fn = ROM_MIROCRYSTAL20SV_964_VLB; - video_inform(VIDEO_FLAG_TYPE_SPECIAL, &timing_s3_vision864_vlb); + video_inform(VIDEO_FLAG_TYPE_SPECIAL, &timing_s3_vision964_vlb); } break; - case S3_MIROVIDEO40SV_968: - bios_fn = ROM_MIROVIDEO40SV_968; + case S3_MIROVIDEO40SV_ERGO_968: + bios_fn = ROM_MIROVIDEO40SV_ERGO_968_PCI; + chip = S3_VISION968; + video_inform(VIDEO_FLAG_TYPE_SPECIAL, &timing_s3_vision968_pci); + break; + case S3_PHOENIX_VISION968: + bios_fn = ROM_PHOENIX_VISION968; chip = S3_VISION968; if (info->flags & DEVICE_PCI) video_inform(VIDEO_FLAG_TYPE_SPECIAL, &timing_s3_vision968_pci); @@ -6385,7 +6775,7 @@ static void *s3_init(const device_t *info) memset(s3, 0, sizeof(s3_t)); - if (info->local == S3_MIROCRYSTAL10SD_805 || info->local == S3_SPEA_MIRAGE_86C801 || + if (info->local == S3_SPEA_MIRAGE_86C801 || info->local == S3_SPEA_MIRAGE_86C805) vram = 1; else @@ -6455,9 +6845,10 @@ static void *s3_init(const device_t *info) if (chip == S3_VISION964 && info->local != S3_ELSAWIN2KPROX_964) svga->dac_hwcursor_draw = bt48x_hwcursor_draw; - else if ((chip == S3_VISION964 && info->local == S3_ELSAWIN2KPROX_964) || (chip == S3_VISION968 && info->local == S3_ELSAWIN2KPROX)) + else if ((chip == S3_VISION964 && info->local == S3_ELSAWIN2KPROX_964) || (chip == S3_VISION968 && (info->local == S3_ELSAWIN2KPROX || + info->local == S3_PHOENIX_VISION968))) svga->dac_hwcursor_draw = ibm_rgb528_hwcursor_draw; - else if (chip == S3_VISION968 && (info->local == S3_MIROVIDEO40SV_968 || info->local == S3_SPEA_MERCURY_P64V)) + else if (chip == S3_VISION968 && (info->local == S3_SPEA_MERCURY_P64V || info->local == S3_MIROVIDEO40SV_ERGO_968)) svga->dac_hwcursor_draw = tvp3026_hwcursor_draw; if (chip >= S3_VISION964) { @@ -6568,7 +6959,7 @@ static void *s3_init(const device_t *info) case S3_SPEA_MIRAGE_86C801: case S3_SPEA_MIRAGE_86C805: - svga->decode_mask = (2 << 20) - 1; + svga->decode_mask = (1 << 20) - 1; stepping = 0xa0; /*86C801/86C805*/ s3->id = stepping; s3->id_ext = stepping; @@ -6612,6 +7003,7 @@ static void *s3_init(const device_t *info) case S3_PARADISE_BAHAMAS64: case S3_PHOENIX_VISION864: + case S3_MIROCRYSTAL20SD_864: svga->decode_mask = (8 << 20) - 1; if (info->local == S3_PARADISE_BAHAMAS64) stepping = 0xc0; /*Vision864*/ @@ -6644,11 +7036,11 @@ static void *s3_init(const device_t *info) svga->clock_gen = device_add(&icd2061_device); svga->getclock = icd2061_getclock; break; - case S3_ELSAWIN2KPROX: - case S3_MIROVIDEO40SV_968: case S3_SPEA_MERCURY_P64V: + case S3_MIROVIDEO40SV_ERGO_968: + case S3_PHOENIX_VISION968: svga->decode_mask = (8 << 20) - 1; s3->id = 0xe1; /*Vision968*/ s3->id_ext = s3->id_ext_pci = 0xf0; @@ -6664,8 +7056,8 @@ static void *s3_init(const device_t *info) svga->crtc[0x59] = 0x00; svga->crtc[0x5a] = 0x0a; } - - if (info->local == S3_ELSAWIN2KPROX) + + if (info->local == S3_ELSAWIN2KPROX || info->local == S3_PHOENIX_VISION968) svga->ramdac = device_add(&ibm_rgb528_ramdac_device); else svga->ramdac = device_add(&tvp3026_ramdac_device); @@ -6675,7 +7067,7 @@ static void *s3_init(const device_t *info) break; case S3_PHOENIX_VISION868: - svga->decode_mask = (8 << 20) - 1; + svga->decode_mask = (4 << 20) - 1; s3->id = 0xe1; /*Vision868*/ s3->id_ext = 0x90; s3->id_ext_pci = 0x80; @@ -6843,9 +7235,19 @@ static int s3_diamond_stealth64_964_available(void) return rom_present(ROM_DIAMOND_STEALTH64_964); } -static int s3_mirovideo_40sv_968_available(void) +static int s3_mirovideo_40sv_ergo_968_pci_available(void) { - return rom_present(ROM_MIROVIDEO40SV_968); + return rom_present(ROM_MIROVIDEO40SV_ERGO_968_PCI); +} + +static int s3_phoenix_vision968_available(void) +{ + return rom_present(ROM_PHOENIX_VISION968); +} + +static int s3_mirocrystal_20sd_864_vlb_available(void) +{ + return rom_present(ROM_MIROCRYSTAL20SD_864_VLB); } static int s3_spea_mercury_p64v_pci_available(void) @@ -7126,7 +7528,7 @@ const device_t s3_spea_mirage_86c805_vlb_device = const device_t s3_mirocrystal_10sd_805_vlb_device = { - "S3 86c805 VLB (MiroCrystal 10SD)", + "S3 86c805 VLB (MiroCRYSTAL 10SD)", DEVICE_VLB, S3_MIROCRYSTAL10SD_805, s3_init, @@ -7135,7 +7537,7 @@ const device_t s3_mirocrystal_10sd_805_vlb_device = { s3_mirocrystal_10sd_805_available }, s3_speed_changed, s3_force_redraw, - NULL + s3_9fx_config }; const device_t s3_phoenix_86c801_isa_device = @@ -7194,6 +7596,20 @@ const device_t s3_metheus_86c928_vlb_device = s3_standard_config }; +const device_t s3_mirocrystal_20sd_864_vlb_device = +{ + "S3 Vision864 VLB (MiroCRYSTAL 20SD)", + DEVICE_VLB, + S3_MIROCRYSTAL20SD_864, + s3_init, + s3_close, + NULL, + { s3_mirocrystal_20sd_864_vlb_available }, + s3_speed_changed, + s3_force_redraw, + s3_9fx_config +}; + const device_t s3_bahamas64_vlb_device = { "S3 Vision864 VLB (Paradise Bahamas 64)", @@ -7279,29 +7695,43 @@ const device_t s3_diamond_stealth64_964_pci_device = s3_standard_config }; -const device_t s3_mirovideo_40sv_968_vlb_device = +const device_t s3_phoenix_vision968_pci_device = { - "S3 Vision968 VLB (MiroVIDEO 40SV)", - DEVICE_VLB, - S3_MIROVIDEO40SV_968, + "S3 Vision968 PCI (Phoenix)", + DEVICE_PCI, + S3_PHOENIX_VISION968, s3_init, s3_close, NULL, - { s3_mirovideo_40sv_968_available }, + { s3_phoenix_vision968_available }, s3_speed_changed, s3_force_redraw, s3_standard_config }; -const device_t s3_mirovideo_40sv_968_pci_device = +const device_t s3_phoenix_vision968_vlb_device = { - "S3 Vision968 PCI (MiroVIDEO 40SV)", - DEVICE_PCI, - S3_MIROVIDEO40SV_968, + "S3 Vision968 VLB (Phoenix)", + DEVICE_VLB, + S3_PHOENIX_VISION968, s3_init, s3_close, NULL, - { s3_mirovideo_40sv_968_available }, + { s3_phoenix_vision968_available }, + s3_speed_changed, + s3_force_redraw, + s3_standard_config +}; + +const device_t s3_mirovideo_40sv_ergo_968_pci_device = +{ + "S3 Vision968 PCI (MiroVIDEO 40SV Ergo)", + DEVICE_PCI, + S3_MIROVIDEO40SV_ERGO_968, + s3_init, + s3_close, + NULL, + { s3_mirovideo_40sv_ergo_968_pci_available }, s3_speed_changed, s3_force_redraw, s3_standard_config diff --git a/src/video/vid_table.c b/src/video/vid_table.c index a26727e25..a34e77b48 100644 --- a/src/video/vid_table.c +++ b/src/video/vid_table.c @@ -145,7 +145,8 @@ video_cards[] = { { "n9_9fx_pci", &s3_9fx_pci_device }, { "px_trio64_pci", &s3_phoenix_trio64_pci_device }, { "elsawin2kprox_pci", &s3_elsa_winner2000_pro_x_pci_device }, - { "mirovideo40sv_pci", &s3_mirovideo_40sv_968_pci_device }, + { "mirovideo40sv_pci", &s3_mirovideo_40sv_ergo_968_pci_device }, + { "px_vision968_pci", &s3_phoenix_vision968_pci_device }, { "spea_mercury64p_pci", &s3_spea_mercury_p64v_pci_device }, { "px_vision868_pci", &s3_phoenix_vision868_pci_device }, { "px_trio64vplus_pci", &s3_phoenix_trio64vplus_pci_device }, @@ -189,6 +190,7 @@ video_cards[] = { { "px_s3_v7_805_vlb", &s3_spea_mirage_86c805_vlb_device }, { "stealth64v_vlb", &s3_diamond_stealth64_964_vlb_device }, { "mirocrystal20sv_vlb", &s3_mirocrystal_20sv_964_vlb_device }, + { "mirocrystal20sd_vlb", &s3_mirocrystal_20sd_864_vlb_device }, { "bahamas64_vlb", &s3_bahamas64_vlb_device }, { "px_vision864_vlb", &s3_phoenix_vision864_vlb_device }, { "stealthse_vlb", &s3_diamond_stealth_se_vlb_device }, @@ -197,6 +199,7 @@ video_cards[] = { { "n9_9fx_vlb", &s3_9fx_vlb_device }, { "px_trio64_vlb", &s3_phoenix_trio64_vlb_device }, { "spea_miragep64_vlb", &s3_spea_mirage_p64_vlb_device }, + { "px_vision968_vlb", &s3_phoenix_vision968_vlb_device }, { "px_vision868_vlb", &s3_phoenix_vision868_vlb_device }, { "ht216_32", &ht216_32_standalone_device }, { "virge325_vlb", &s3_virge_325_vlb_device }, From 13dc05cfd2a7d593c9610ab029cec6cd7cac70c3 Mon Sep 17 00:00:00 2001 From: OBattler Date: Mon, 13 Sep 2021 21:02:15 +0200 Subject: [PATCH 6/9] Removed the useless double-buffering in video/video.c, improves performance and reduces RAM usage. --- src/include/86box/video.h | 2 +- src/video/video.c | 14 ++++---------- src/vnc.c | 2 +- src/win/win_opengl.c | 10 ++++++++-- src/win/win_sdl.c | 14 +++++++------- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/include/86box/video.h b/src/include/86box/video.h index be7591dc7..479312d1a 100644 --- a/src/include/86box/video.h +++ b/src/include/86box/video.h @@ -84,7 +84,7 @@ typedef rgb_t PALETTE[256]; extern int changeframecount; extern volatile int screenshots; -extern bitmap_t *buffer32, *render_buffer; +extern bitmap_t *buffer32; extern PALETTE cgapal, cgapal_mono[6]; extern uint32_t pal_lookup[256]; diff --git a/src/video/video.c b/src/video/video.c index 008228a00..66323f079 100644 --- a/src/video/video.c +++ b/src/video/video.c @@ -74,7 +74,6 @@ volatile int screenshots = 0; bitmap_t *buffer32 = NULL; -bitmap_t *render_buffer = NULL; uint8_t fontdat[2048][8]; /* IBM CGA font */ uint8_t fontdatm[2048][16]; /* IBM MDA font */ uint8_t fontdatw[512][32]; /* Wyse700 font */ @@ -364,7 +363,7 @@ video_take_screenshot(const char *fn, int startx, int starty, int y1, int y2, in for (y = 0; y < h; ++y) { b_rgb[y] = (png_byte *) malloc(png_get_rowbytes(png_ptr, info_ptr)); for (x = 0; x < w; ++x) { - temp = render_buffer->dat[(y * w) + x]; + temp = buffer32->line[starty + y][startx + x]; b_rgb[y][(x) * 3 + 0] = (temp >> 16) & 0xff; b_rgb[y][(x) * 3 + 1] = (temp >> 8) & 0xff; @@ -436,19 +435,16 @@ void blit_thread(void *param) thread_reset_event(blit_data.wake_blit_thread); MTR_BEGIN("video", "blit_thread"); - if (blit_data.y2 > 0) { + if ((video_grayscale || invert_display) && blit_data.y2 > 0) { for (yy = blit_data.y1; yy < blit_data.y2; yy++) { if (((blit_data.y + yy) >= 0) && ((blit_data.y + yy) < buffer32->h)) { - if (video_grayscale || invert_display) - video_transform_copy(&(render_buffer->dat)[yy * blit_data.w], &(buffer32->line[blit_data.y + yy][blit_data.x]), blit_data.w); - else - memcpy(&(render_buffer->dat)[yy * blit_data.w], &(buffer32->line[blit_data.y + yy][blit_data.x]), blit_data.w << 2); + video_transform_copy(&(buffer32->line[blit_data.y + yy][blit_data.x]), &(buffer32->line[blit_data.y + yy][blit_data.x]), blit_data.w); } } } if (screenshots) { - if (render_buffer != NULL) + if (buffer32 != NULL) video_screenshot(blit_data.x, blit_data.y, blit_data.y1, blit_data.y2, blit_data.w, blit_data.h); screenshots--; video_log("screenshot taken, %i left\n", screenshots); @@ -833,7 +829,6 @@ video_init(void) /* Account for overscan. */ buffer32 = create_bitmap(2048 + 64, 2048 + 64); - render_buffer = create_bitmap(2048 + 64, 2048 + 64); for (c = 0; c < 64; c++) { cgapal[c + 64].r = (((c & 4) ? 2 : 0) | ((c & 0x10) ? 1 : 0)) * 21; @@ -902,7 +897,6 @@ video_close(void) free(video_8togs); free(video_6to8); - destroy_bitmap(render_buffer); destroy_bitmap(buffer32); if (fontdatksc5601) { diff --git a/src/vnc.c b/src/vnc.c index 09c00831f..5f687a9f3 100644 --- a/src/vnc.c +++ b/src/vnc.c @@ -176,7 +176,7 @@ vnc_blit(int x, int y, int y1, int y2, int w, int h) p = (uint32_t *)&(((uint32_t *)rfb->frameBuffer)[yy*VNC_MAX_X]); if ((y+yy) >= 0 && (y+yy) < VNC_MAX_Y) - memcpy(p, &(render_buffer->dat[yy * w]), w*4); + memcpy(p, &(buffer32->line[yy]), w*4); } video_blit_complete(); diff --git a/src/win/win_opengl.c b/src/win/win_opengl.c index 9d44fc47e..1d8239af8 100644 --- a/src/win/win_opengl.c +++ b/src/win/win_opengl.c @@ -810,14 +810,20 @@ static void opengl_main(void* param) static void opengl_blit(int x, int y, int y1, int y2, int w, int h) { - if (y1 == y2 || h <= 0 || render_buffer == NULL || thread == NULL || + int yy; + + if (y1 == y2 || h <= 0 || buffer32 == NULL || thread == NULL || atomic_flag_test_and_set(&blit_info[write_pos].in_use)) { video_blit_complete(); return; } - memcpy(blit_info[write_pos].buffer, &(render_buffer->dat)[y1 * w], w * (y2 - y1) * sizeof(uint32_t)); + for (yy = y1; yy < y2; yy++) { + if ((y + yy) >= 0 && (y + yy) < buffer32->h) + memcpy(blit_info[write_pos].buffer + (yy * w * 4), + &(((uint32_t *) buffer32->line[y + yy])[x]), w * 4); + } video_blit_complete(); diff --git a/src/win/win_sdl.c b/src/win/win_sdl.c index 8a748fb2b..c5978501f 100644 --- a/src/win/win_sdl.c +++ b/src/win/win_sdl.c @@ -234,24 +234,24 @@ sdl_blit(int x, int y, int y1, int y2, int w, int h) SDL_Rect r_src; int ret; - if (!sdl_enabled || (y1 == y2) || (h <= 0) || (render_buffer == NULL) || (sdl_render == NULL) || (sdl_tex == NULL)) { + if (!sdl_enabled || (y1 == y2) || (h <= 0) || (buffer32 == NULL) || (sdl_render == NULL) || (sdl_tex == NULL)) { video_blit_complete(); return; } SDL_LockMutex(sdl_mutex); - r_src.x = 0; - r_src.y = y1; + r_src.x = x; + r_src.y = y; r_src.w = w; - r_src.h = y2 - y1; - SDL_UpdateTexture(sdl_tex, &r_src, &(render_buffer->dat)[y1 * w], w * 4); + r_src.h = h; + SDL_UpdateTexture(sdl_tex, &r_src, &(buffer32->line[y][x]), (2048 + 64) * 4); video_blit_complete(); SDL_RenderClear(sdl_render); - r_src.x = 0; - r_src.y = 0; + r_src.x = x; + r_src.y = y; r_src.w = w; r_src.h = h; From 7473a1c4b9b9e1e579ac209c6a57930e5225a981 Mon Sep 17 00:00:00 2001 From: OBattler Date: Mon, 13 Sep 2021 21:28:44 +0200 Subject: [PATCH 7/9] Fixed the OpenGL 3.3 renderer. --- src/win/win_opengl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/win/win_opengl.c b/src/win/win_opengl.c index 1d8239af8..dec6436d0 100644 --- a/src/win/win_opengl.c +++ b/src/win/win_opengl.c @@ -819,7 +819,7 @@ static void opengl_blit(int x, int y, int y1, int y2, int w, int h) return; } - for (yy = y1; yy < y2; yy++) { + for (yy = 0; yy < h; yy++) { if ((y + yy) >= 0 && (y + yy) < buffer32->h) memcpy(blit_info[write_pos].buffer + (yy * w * 4), &(((uint32_t *) buffer32->line[y + yy])[x]), w * 4); @@ -827,8 +827,8 @@ static void opengl_blit(int x, int y, int y1, int y2, int w, int h) video_blit_complete(); - blit_info[write_pos].y1 = y1; - blit_info[write_pos].y2 = y2; + blit_info[write_pos].y1 = 0; + blit_info[write_pos].y2 = h - 1; blit_info[write_pos].w = w; blit_info[write_pos].h = h; From 96faa28eeb757327d1f28445adcf7dbd6f1a565f Mon Sep 17 00:00:00 2001 From: OBattler Date: Mon, 13 Sep 2021 23:19:10 +0200 Subject: [PATCH 8/9] Removed the useless y1 and y2 parameters from the renderers' blit functions (and other places). --- src/include/86box/vid_svga.h | 2 +- src/include/86box/video.h | 6 ++-- src/machine/m_amstrad.c | 8 ++--- src/machine/m_at_compaq.c | 2 +- src/machine/m_at_t3100e_vid.c | 2 +- src/machine/m_pcjr.c | 8 ++--- src/machine/m_tandy.c | 8 ++--- src/machine/m_xt_t1000_vid.c | 2 +- src/unix/unix.c | 10 +++--- src/unix/unix_sdl.c | 22 ++++++------ src/video/vid_cga.c | 8 ++--- src/video/vid_colorplus.c | 4 +-- src/video/vid_compaq_cga.c | 8 ++--- src/video/vid_ega.c | 17 ++++------ src/video/vid_f82c425.c | 2 +- src/video/vid_genius.c | 2 +- src/video/vid_hercules.c | 4 +-- src/video/vid_herculesplus.c | 2 +- src/video/vid_incolor.c | 2 +- src/video/vid_mda.c | 2 +- src/video/vid_nga.c | 8 ++--- src/video/vid_ogc.c | 8 ++--- src/video/vid_pgc.c | 4 +-- src/video/vid_sigma.c | 2 +- src/video/vid_svga.c | 17 ++++------ src/video/vid_voodoo_display.c | 2 +- src/video/vid_wy700.c | 2 +- src/video/video.c | 62 ++++++++++++++++------------------ src/vnc.c | 9 +++-- src/win/win_opengl.c | 8 ++--- src/win/win_sdl.c | 6 ++-- 31 files changed, 119 insertions(+), 130 deletions(-) diff --git a/src/include/86box/vid_svga.h b/src/include/86box/vid_svga.h index 93d4aeffc..91559aa72 100644 --- a/src/include/86box/vid_svga.h +++ b/src/include/86box/vid_svga.h @@ -202,7 +202,7 @@ void svga_close(svga_t *svga); uint32_t svga_mask_addr(uint32_t addr, svga_t *svga); uint32_t svga_mask_changedaddr(uint32_t addr, svga_t *svga); -void svga_doblit(int y1, int y2, int wx, int wy, svga_t *svga); +void svga_doblit(int wx, int wy, svga_t *svga); enum { diff --git a/src/include/86box/video.h b/src/include/86box/video.h index 479312d1a..83c57e444 100644 --- a/src/include/86box/video.h +++ b/src/include/86box/video.h @@ -150,10 +150,10 @@ extern void video_inform(int type, const video_timings_t *ptr); extern int video_get_type(void); -extern void video_setblit(void(*blit)(int,int,int,int,int,int)); +extern void video_setblit(void(*blit)(int,int,int,int)); extern void video_blend(int x, int y); -extern void video_blit_memtoscreen_8(int x, int y, int y1, int y2, int w, int h); -extern void video_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h); +extern void video_blit_memtoscreen_8(int x, int y, int w, int h); +extern void video_blit_memtoscreen(int x, int y, int w, int h); extern void video_blit_complete(void); extern void video_wait_for_blit(void); extern void video_wait_for_buffer(void); diff --git a/src/machine/m_amstrad.c b/src/machine/m_amstrad.c index 24fc1be51..10e4df12e 100644 --- a/src/machine/m_amstrad.c +++ b/src/machine/m_amstrad.c @@ -577,10 +577,10 @@ vid_poll_1512(void *priv) } if (enable_overscan) { - video_blit_memtoscreen_8(0, (vid->firstline - 4) << 1, 0, ((vid->lastline - vid->firstline) + 8) << 1, + video_blit_memtoscreen_8(0, (vid->firstline - 4) << 1, xsize, ((vid->lastline - vid->firstline) + 8) << 1); } else { - video_blit_memtoscreen_8(8, vid->firstline << 1, 0, (vid->lastline - vid->firstline) << 1, + video_blit_memtoscreen_8(8, vid->firstline << 1, xsize, (vid->lastline - vid->firstline) << 1); } } @@ -1403,7 +1403,7 @@ lcdm_poll(amsvid_t *vid) if (video_force_resize_get()) video_force_resize_set(0); } - video_blit_memtoscreen(0, mda->firstline, 0, ysize, xsize, ysize); + video_blit_memtoscreen(0, mda->firstline, xsize, ysize); frames++; video_res_x = mda->crtc[1]; video_res_y = mda->crtc[6]; @@ -1571,7 +1571,7 @@ lcdc_poll(amsvid_t *vid) video_force_resize_set(0); } - video_blit_memtoscreen(0, cga->firstline << 1, 0, (cga->lastline - cga->firstline) << 1, + video_blit_memtoscreen(0, cga->firstline << 1, xsize, (cga->lastline - cga->firstline) << 1); } diff --git a/src/machine/m_at_compaq.c b/src/machine/m_at_compaq.c index e0aef82ef..4772c3ccc 100644 --- a/src/machine/m_at_compaq.c +++ b/src/machine/m_at_compaq.c @@ -514,7 +514,7 @@ compaq_plasma_poll(void *p) if (video_force_resize_get()) video_force_resize_set(0); } - video_blit_memtoscreen(0, 0, 0, ysize, xsize, ysize); + video_blit_memtoscreen(0, 0, xsize, ysize); frames++; /* Fixed 640x400 resolution */ diff --git a/src/machine/m_at_t3100e_vid.c b/src/machine/m_at_t3100e_vid.c index cf012a27b..b52c8ef03 100644 --- a/src/machine/m_at_t3100e_vid.c +++ b/src/machine/m_at_t3100e_vid.c @@ -590,7 +590,7 @@ void t3100e_poll(void *p) if (video_force_resize_get()) video_force_resize_set(0); } - video_blit_memtoscreen(0, 0, 0, ysize, xsize, ysize); + video_blit_memtoscreen(0, 0, xsize, ysize); frames++; /* Fixed 640x400 resolution */ diff --git a/src/machine/m_pcjr.c b/src/machine/m_pcjr.c index c51dbf03a..c54c7f0c7 100644 --- a/src/machine/m_pcjr.c +++ b/src/machine/m_pcjr.c @@ -566,17 +566,17 @@ vid_poll(void *p) if (enable_overscan) { if (pcjr->composite) - video_blit_memtoscreen(0, (pcjr->firstline - 4) << 1, 0, ((pcjr->lastline - pcjr->firstline) + 8) << 1, + video_blit_memtoscreen(0, (pcjr->firstline - 4) << 1, xsize, ((pcjr->lastline - pcjr->firstline) + 8) << 1); else - video_blit_memtoscreen_8(0, (pcjr->firstline - 4) << 1, 0, ((pcjr->lastline - pcjr->firstline) + 8) << 1, + video_blit_memtoscreen_8(0, (pcjr->firstline - 4) << 1, xsize, ((pcjr->lastline - pcjr->firstline) + 8) << 1); } else { if (pcjr->composite) - video_blit_memtoscreen(8, pcjr->firstline << 1, 0, (pcjr->lastline - pcjr->firstline) << 1, + video_blit_memtoscreen(8, pcjr->firstline << 1, xsize, (pcjr->lastline - pcjr->firstline) << 1); else - video_blit_memtoscreen_8(8, pcjr->firstline << 1, 0, (pcjr->lastline - pcjr->firstline) << 1, + video_blit_memtoscreen_8(8, pcjr->firstline << 1, xsize, (pcjr->lastline - pcjr->firstline) << 1); } } diff --git a/src/machine/m_tandy.c b/src/machine/m_tandy.c index 75aa7cbeb..8de9883b7 100644 --- a/src/machine/m_tandy.c +++ b/src/machine/m_tandy.c @@ -1032,17 +1032,17 @@ vid_poll(void *priv) if (enable_overscan) { if (!dev->is_sl2 && vid->composite) - video_blit_memtoscreen(0, (vid->firstline - 4) << 1, 0, ((vid->lastline - vid->firstline) + 8) << 1, + video_blit_memtoscreen(0, (vid->firstline - 4) << 1, xsize, ((vid->lastline - vid->firstline) + 8) << 1); else - video_blit_memtoscreen_8(0, (vid->firstline - 4) << 1, 0, ((vid->lastline - vid->firstline) + 8) << 1, + video_blit_memtoscreen_8(0, (vid->firstline - 4) << 1, xsize, ((vid->lastline - vid->firstline) + 8) << 1); } else { if (!dev->is_sl2 && vid->composite) - video_blit_memtoscreen(8, vid->firstline << 1, 0, (vid->lastline - vid->firstline) << 1, + video_blit_memtoscreen(8, vid->firstline << 1, xsize, (vid->lastline - vid->firstline) << 1); else - video_blit_memtoscreen_8(8, vid->firstline << 1, 0, (vid->lastline - vid->firstline) << 1, + video_blit_memtoscreen_8(8, vid->firstline << 1, xsize, (vid->lastline - vid->firstline) << 1); } } diff --git a/src/machine/m_xt_t1000_vid.c b/src/machine/m_xt_t1000_vid.c index c3930d29e..8e1c7029c 100644 --- a/src/machine/m_xt_t1000_vid.c +++ b/src/machine/m_xt_t1000_vid.c @@ -556,7 +556,7 @@ static void t1000_poll(void *p) if (video_force_resize_get()) video_force_resize_set(0); } - video_blit_memtoscreen(0, 0, 0, ysize, xsize, ysize); + video_blit_memtoscreen(0, 0, xsize, ysize); frames++; /* Fixed 640x200 resolution */ diff --git a/src/unix/unix.c b/src/unix/unix.c index 93d3ede73..ca2866cb4 100644 --- a/src/unix/unix.c +++ b/src/unix/unix.c @@ -161,10 +161,10 @@ static const uint16_t sdl_to_xt[0x200] = typedef struct sdl_blit_params { - int x, y, y1, y2, w, h; + int x, y, w, h; } sdl_blit_params; -sdl_blit_params params = { 0, 0, 0, 0, 0, 0 }; +sdl_blit_params params = { 0, 0, 0, 0 }; int blitreq = 0; void* dynld_module(const char *name, dllimp_t *table) @@ -607,7 +607,7 @@ void ui_sb_bugui(char *str) } -extern void sdl_blit(int x, int y, int y1, int y2, int w, int h); +extern void sdl_blit(int x, int y, int w, int h); typedef struct mouseinputdata { @@ -1122,8 +1122,8 @@ int main(int argc, char** argv) } if (blitreq) { - extern void sdl_blit(int x, int y, int y1, int y2, int w, int h); - sdl_blit(params.x, params.y, params.y1, params.y2, params.w, params.h); + extern void sdl_blit(int x, int y, int w, int h); + sdl_blit(params.x, params.y, params.w, params.h); } if (title_set) { diff --git a/src/unix/unix_sdl.c b/src/unix/unix_sdl.c index ff31e5786..ae5b43a9b 100644 --- a/src/unix/unix_sdl.c +++ b/src/unix/unix_sdl.c @@ -23,7 +23,7 @@ typedef struct sdl_blit_params { - int x, y, y1, y2, w, h; + int x, y, w, h; } sdl_blit_params; extern sdl_blit_params params; extern int blitreq; @@ -121,26 +121,24 @@ sdl_stretch(int *w, int *h, int *x, int *y) void -sdl_blit_shim(int x, int y, int y1, int y2, int w, int h) +sdl_blit_shim(int x, int y, int w, int h) { params.x = x; params.y = y; params.w = w; params.h = h; - params.y1 = y1; - params.y2 = y2; blitreq = 1; } void ui_window_title_real(); void -sdl_blit(int x, int y, int y1, int y2, int w, int h) +sdl_blit(int x, int y, int w, int h) { SDL_Rect r_src; int ret; - if (!sdl_enabled || (y1 == y2) || (h <= 0) || (render_buffer == NULL) || (sdl_render == NULL) || (sdl_tex == NULL)) { + if (!sdl_enabled || (h <= 0) || (render_buffer == NULL) || (sdl_render == NULL) || (sdl_tex == NULL)) { video_blit_complete(); return; } @@ -153,17 +151,17 @@ sdl_blit(int x, int y, int y1, int y2, int w, int h) else sdl_resize(resize_w, resize_h); resize_pending = 0; } - r_src.x = 0; - r_src.y = y1; + r_src.x = x; + r_src.y = y; r_src.w = w; - r_src.h = y2 - y1; - SDL_UpdateTexture(sdl_tex, &r_src, &(render_buffer->dat)[y1 * w], w * 4); + r_src.h = h; + SDL_UpdateTexture(sdl_tex, &r_src, &(buffer32->line[y][x]), (2048 + 64) * 4); video_blit_complete(); SDL_RenderClear(sdl_render); - r_src.x = 0; - r_src.y = 0; + r_src.x = x; + r_src.y = y; r_src.w = w; r_src.h = h; diff --git a/src/video/vid_cga.c b/src/video/vid_cga.c index dda14f48e..ef3f2c4ef 100644 --- a/src/video/vid_cga.c +++ b/src/video/vid_cga.c @@ -463,17 +463,17 @@ cga_poll(void *p) if (enable_overscan) { if (cga->composite) - video_blit_memtoscreen(0, (cga->firstline - 4) << 1, 0, ((cga->lastline - cga->firstline) + 8) << 1, + video_blit_memtoscreen(0, (cga->firstline - 4) << 1, xsize, ((cga->lastline - cga->firstline) + 8) << 1); else - video_blit_memtoscreen_8(0, (cga->firstline - 4) << 1, 0, ((cga->lastline - cga->firstline) + 8) << 1, + video_blit_memtoscreen_8(0, (cga->firstline - 4) << 1, xsize, ((cga->lastline - cga->firstline) + 8) << 1); } else { if (cga->composite) - video_blit_memtoscreen(8, cga->firstline << 1, 0, (cga->lastline - cga->firstline) << 1, + video_blit_memtoscreen(8, cga->firstline << 1, xsize, (cga->lastline - cga->firstline) << 1); else - video_blit_memtoscreen_8(8, cga->firstline << 1, 0, (cga->lastline - cga->firstline) << 1, + video_blit_memtoscreen_8(8, cga->firstline << 1, xsize, (cga->lastline - cga->firstline) << 1); } } diff --git a/src/video/vid_colorplus.c b/src/video/vid_colorplus.c index ed5cd6f00..3343aaf0e 100644 --- a/src/video/vid_colorplus.c +++ b/src/video/vid_colorplus.c @@ -326,9 +326,9 @@ void colorplus_poll(void *p) } if (colorplus->cga.composite) - video_blit_memtoscreen(0, colorplus->cga.firstline - 4, 0, (colorplus->cga.lastline - colorplus->cga.firstline) + 8, xsize, (colorplus->cga.lastline - colorplus->cga.firstline) + 8); + video_blit_memtoscreen(0, colorplus->cga.firstline - 4, xsize, (colorplus->cga.lastline - colorplus->cga.firstline) + 8); else - video_blit_memtoscreen_8(0, colorplus->cga.firstline - 4, 0, (colorplus->cga.lastline - colorplus->cga.firstline) + 8, xsize, (colorplus->cga.lastline - colorplus->cga.firstline) + 8); + video_blit_memtoscreen_8(0, colorplus->cga.firstline - 4, xsize, (colorplus->cga.lastline - colorplus->cga.firstline) + 8); frames++; video_res_x = xsize - 16; diff --git a/src/video/vid_compaq_cga.c b/src/video/vid_compaq_cga.c index 0a82bdee1..d971a6af4 100644 --- a/src/video/vid_compaq_cga.c +++ b/src/video/vid_compaq_cga.c @@ -340,14 +340,14 @@ compaq_cga_poll(void *p) if (enable_overscan) { if (self->cga.composite) - video_blit_memtoscreen(0, self->cga.firstline - 8, 0, (self->cga.lastline - self->cga.firstline) + 16, xsize, (self->cga.lastline - self->cga.firstline) + 16); + video_blit_memtoscreen(0, self->cga.firstline - 8, xsize, (self->cga.lastline - self->cga.firstline) + 16); else - video_blit_memtoscreen_8(0, self->cga.firstline - 8, 0, (self->cga.lastline - self->cga.firstline) + 16, xsize, (self->cga.lastline - self->cga.firstline) + 16); + video_blit_memtoscreen_8(0, self->cga.firstline - 8, xsize, (self->cga.lastline - self->cga.firstline) + 16); } else { if (self->cga.composite) - video_blit_memtoscreen(8, self->cga.firstline, 0, self->cga.lastline - self->cga.firstline, xsize, self->cga.lastline - self->cga.firstline); + video_blit_memtoscreen(8, self->cga.firstline, xsize, self->cga.lastline - self->cga.firstline); else - video_blit_memtoscreen_8(8, self->cga.firstline, 0, self->cga.lastline - self->cga.firstline, xsize, self->cga.lastline - self->cga.firstline); + video_blit_memtoscreen_8(8, self->cga.firstline, xsize, self->cga.lastline - self->cga.firstline); } } diff --git a/src/video/vid_ega.c b/src/video/vid_ega.c index 570a676d3..c8f2a43c1 100644 --- a/src/video/vid_ega.c +++ b/src/video/vid_ega.c @@ -35,7 +35,7 @@ #include <86box/vid_ega.h> -void ega_doblit(int y1, int y2, int wx, int wy, ega_t *ega); +void ega_doblit(int wx, int wy, ega_t *ega); #define BIOS_IBM_PATH "roms/video/ega/ibm_6277356_ega_card_u44_27128.bin" @@ -597,10 +597,10 @@ ega_poll(void *p) if (ega->vres) { wy = (ega->lastline - ega->firstline) << 1; - ega_doblit(ega->firstline_draw << 1, (ega->lastline_draw + 1) << 1, wx, wy, ega); + ega_doblit(wx, wy, ega); } else { wy = ega->lastline - ega->firstline; - ega_doblit(ega->firstline_draw, ega->lastline_draw + 1, wx, wy, ega); + ega_doblit(wx, wy, ega); } frames++; @@ -658,7 +658,7 @@ ega_poll(void *p) void -ega_doblit(int y1, int y2, int wx, int wy, ega_t *ega) +ega_doblit(int wx, int wy, ega_t *ega) { int y_add = (enable_overscan) ? overscan_y : 0; int x_add = (enable_overscan) ? overscan_x : 0; @@ -676,12 +676,7 @@ ega_doblit(int y1, int y2, int wx, int wy, ega_t *ega) } if ((wx <= 0) || (wy <= 0)) { - video_blit_memtoscreen(x_start, y_start, 0, 0, 0, 0); - return; - } - - if (y1 > y2) { - video_blit_memtoscreen(x_start, y_start, 0, 0, xsize + x_add, ysize + y_add); + video_blit_memtoscreen(x_start, y_start, 0, 0); return; } @@ -734,7 +729,7 @@ ega_doblit(int y1, int y2, int wx, int wy, ega_t *ega) } } - video_blit_memtoscreen(x_start, y_start, y1, y2 + y_add, xsize + x_add, ysize + y_add); + video_blit_memtoscreen(x_start, y_start, xsize + x_add, ysize + y_add); if (ega->vres) ega->y_add >>= 1; diff --git a/src/video/vid_f82c425.c b/src/video/vid_f82c425.c index ab8b12299..a9d2f14ba 100644 --- a/src/video/vid_f82c425.c +++ b/src/video/vid_f82c425.c @@ -584,7 +584,7 @@ static void f82c425_poll(void *p) if (video_force_resize_get()) video_force_resize_set(0); } - video_blit_memtoscreen(0, 0, 0, ysize, xsize, ysize); + video_blit_memtoscreen(0, 0, xsize, ysize); frames++; /* Fixed 640x200 resolution */ diff --git a/src/video/vid_genius.c b/src/video/vid_genius.c index c054230b1..57854a051 100644 --- a/src/video/vid_genius.c +++ b/src/video/vid_genius.c @@ -689,7 +689,7 @@ genius_poll(void *p) video_force_resize_set(0); } - video_blit_memtoscreen_8(0, 0, 0, ysize, xsize, ysize); + video_blit_memtoscreen_8(0, 0, xsize, ysize); frames++; /* Fixed 728x1008 resolution */ diff --git a/src/video/vid_hercules.c b/src/video/vid_hercules.c index 4e1d4e8b9..6c9660bb8 100644 --- a/src/video/vid_hercules.c +++ b/src/video/vid_hercules.c @@ -517,9 +517,9 @@ hercules_poll(void *priv) } if (enable_overscan) - video_blit_memtoscreen_8(0, dev->firstline, 0, ysize + 28, xsize + 16, ysize + 28); + video_blit_memtoscreen_8(0, dev->firstline, xsize + 16, ysize + 28); else - video_blit_memtoscreen_8(8, dev->firstline + 14, 0, ysize + 14, xsize, ysize); + video_blit_memtoscreen_8(8, dev->firstline + 14, xsize, ysize); frames++; // if ((dev->ctrl & 2) && (dev->ctrl2 & 1)) { if (dev->ctrl & 0x02) { diff --git a/src/video/vid_herculesplus.c b/src/video/vid_herculesplus.c index df5b01da0..607780a68 100644 --- a/src/video/vid_herculesplus.c +++ b/src/video/vid_herculesplus.c @@ -581,7 +581,7 @@ herculesplus_poll(void *priv) if (video_force_resize_get()) video_force_resize_set(0); } - video_blit_memtoscreen_8(0, dev->firstline, 0, dev->lastline - dev->firstline, xsize, dev->lastline - dev->firstline); + video_blit_memtoscreen_8(0, dev->firstline, xsize, dev->lastline - dev->firstline); frames++; if ((dev->ctrl & HERCULESPLUS_CTRL_GRAPH) && (dev->ctrl2 & HERCULESPLUS_CTRL2_GRAPH)) { video_res_x = dev->crtc[1] * 16; diff --git a/src/video/vid_incolor.c b/src/video/vid_incolor.c index 8b644077e..64d93a5c0 100644 --- a/src/video/vid_incolor.c +++ b/src/video/vid_incolor.c @@ -998,7 +998,7 @@ incolor_poll(void *priv) if (video_force_resize_get()) video_force_resize_set(0); } - video_blit_memtoscreen(0, dev->firstline, 0, dev->lastline - dev->firstline, xsize, dev->lastline - dev->firstline); + video_blit_memtoscreen(0, dev->firstline, xsize, dev->lastline - dev->firstline); frames++; if ((dev->ctrl & INCOLOR_CTRL_GRAPH) && (dev->ctrl2 & INCOLOR_CTRL2_GRAPH)) { video_res_x = dev->crtc[1] * 16; diff --git a/src/video/vid_mda.c b/src/video/vid_mda.c index c05744b01..f2550f134 100644 --- a/src/video/vid_mda.c +++ b/src/video/vid_mda.c @@ -230,7 +230,7 @@ void mda_poll(void *p) if (video_force_resize_get()) video_force_resize_set(0); } - video_blit_memtoscreen_8(0, mda->firstline, 0, ysize, xsize, ysize); + video_blit_memtoscreen_8(0, mda->firstline, xsize, ysize); frames++; video_res_x = mda->crtc[1]; video_res_y = mda->crtc[6]; diff --git a/src/video/vid_nga.c b/src/video/vid_nga.c index 66c09d744..1c34db342 100644 --- a/src/video/vid_nga.c +++ b/src/video/vid_nga.c @@ -474,17 +474,17 @@ nga_poll(void *priv) /* nga specific */ if (enable_overscan) { if (nga->cga.composite) - video_blit_memtoscreen(0, (nga->cga.firstline - 8), 0, (nga->cga.lastline - nga->cga.firstline) + 16, + video_blit_memtoscreen(0, (nga->cga.firstline - 8), xsize, (nga->cga.lastline - nga->cga.firstline) + 16); else - video_blit_memtoscreen_8(0, (nga->cga.firstline - 8), 0, (nga->cga.lastline - nga->cga.firstline) + 16, + video_blit_memtoscreen_8(0, (nga->cga.firstline - 8), xsize, (nga->cga.lastline - nga->cga.firstline) + 16); } else { if (nga->cga.composite) - video_blit_memtoscreen(8, nga->cga.firstline, 0, (nga->cga.lastline - nga->cga.firstline), + video_blit_memtoscreen(8, nga->cga.firstline, xsize, (nga->cga.lastline - nga->cga.firstline)); else - video_blit_memtoscreen_8(8, nga->cga.firstline, 0, (nga->cga.lastline - nga->cga.firstline), + video_blit_memtoscreen_8(8, nga->cga.firstline, xsize, (nga->cga.lastline - nga->cga.firstline)); } } diff --git a/src/video/vid_ogc.c b/src/video/vid_ogc.c index cdc433bdf..c562c6f11 100644 --- a/src/video/vid_ogc.c +++ b/src/video/vid_ogc.c @@ -489,17 +489,17 @@ ogc_poll(void *priv) /* ogc specific */ if (enable_overscan) { if (ogc->cga.composite) - video_blit_memtoscreen(0, (ogc->cga.firstline - 8), 0, (ogc->cga.lastline - ogc->cga.firstline) + 16, + video_blit_memtoscreen(0, (ogc->cga.firstline - 8), xsize, (ogc->cga.lastline - ogc->cga.firstline) + 16); else - video_blit_memtoscreen_8(0, (ogc->cga.firstline - 8), 0, (ogc->cga.lastline - ogc->cga.firstline) + 16, + video_blit_memtoscreen_8(0, (ogc->cga.firstline - 8), xsize, (ogc->cga.lastline - ogc->cga.firstline) + 16); } else { if (ogc->cga.composite) - video_blit_memtoscreen(8, ogc->cga.firstline, 0, (ogc->cga.lastline - ogc->cga.firstline), + video_blit_memtoscreen(8, ogc->cga.firstline, xsize, (ogc->cga.lastline - ogc->cga.firstline)); else - video_blit_memtoscreen_8(8, ogc->cga.firstline, 0, (ogc->cga.lastline - ogc->cga.firstline), + video_blit_memtoscreen_8(8, ogc->cga.firstline, xsize, (ogc->cga.lastline - ogc->cga.firstline)); } } diff --git a/src/video/vid_pgc.c b/src/video/vid_pgc.c index 213d85f6a..34e5c2d99 100644 --- a/src/video/vid_pgc.c +++ b/src/video/vid_pgc.c @@ -2493,7 +2493,7 @@ pgc_cga_poll(pgc_t *dev) if (video_force_resize_get()) video_force_resize_set(0); } - video_blit_memtoscreen_8(0, 0, 0, ysize, xsize, ysize); + video_blit_memtoscreen_8(0, 0, xsize, ysize); frames++; /* We have a fixed 640x400 screen for CGA modes. */ @@ -2578,7 +2578,7 @@ pgc_poll(void *priv) if (video_force_resize_get()) video_force_resize_set(0); } - video_blit_memtoscreen(0, 0, 0, ysize, xsize, ysize); + video_blit_memtoscreen(0, 0, xsize, ysize); frames++; video_res_x = dev->screenw; diff --git a/src/video/vid_sigma.c b/src/video/vid_sigma.c index 88365b427..008232bc4 100644 --- a/src/video/vid_sigma.c +++ b/src/video/vid_sigma.c @@ -758,7 +758,7 @@ sigma_poll(void *p) video_force_resize_set(0); } - video_blit_memtoscreen_8(0, sigma->firstline - 4, 0, (sigma->lastline - sigma->firstline) + 8, xsize, (sigma->lastline - sigma->firstline) + 8); + video_blit_memtoscreen_8(0, sigma->firstline - 4, xsize, (sigma->lastline - sigma->firstline) + 8); frames++; video_res_x = xsize - 16; diff --git a/src/video/vid_svga.c b/src/video/vid_svga.c index 07f6f3823..9615c10a0 100644 --- a/src/video/vid_svga.c +++ b/src/video/vid_svga.c @@ -41,7 +41,7 @@ #include <86box/vid_svga_render.h> -void svga_doblit(int y1, int y2, int wx, int wy, svga_t *svga); +void svga_doblit(int wx, int wy, svga_t *svga); extern int cyc_total; extern uint8_t edatlookup[4][4]; @@ -823,10 +823,10 @@ svga_poll(void *p) if (!svga->override) { if (svga->vertical_linedbl) { wy = (svga->lastline - svga->firstline) << 1; - svga_doblit(svga->firstline_draw << 1, (svga->lastline_draw + 1) << 1, wx, wy, svga); + svga_doblit(wx, wy, svga); } else { wy = svga->lastline - svga->firstline; - svga_doblit(svga->firstline_draw, svga->lastline_draw + 1, wx, wy, svga); + svga_doblit(wx, wy, svga); } } @@ -1342,7 +1342,7 @@ svga_read_linear(uint32_t addr, void *p) void -svga_doblit(int y1, int y2, int wx, int wy, svga_t *svga) +svga_doblit(int wx, int wy, svga_t *svga) { int y_add, x_add, y_start, x_start, bottom; uint32_t *p; @@ -1362,12 +1362,7 @@ svga_doblit(int y1, int y2, int wx, int wy, svga_t *svga) } if ((wx <= 0) || (wy <= 0)) { - video_blit_memtoscreen(x_start, y_start, 0, 0, 0, 0); - return; - } - - if (y1 > y2) { - video_blit_memtoscreen(x_start, y_start, 0, 0, xsize + x_add, ysize + y_add); + video_blit_memtoscreen(x_start, y_start, 0, 0); return; } @@ -1423,7 +1418,7 @@ svga_doblit(int y1, int y2, int wx, int wy, svga_t *svga) } } - video_blit_memtoscreen(x_start, y_start, y1, y2 + y_add, xsize + x_add, ysize + y_add); + video_blit_memtoscreen(x_start, y_start, xsize + x_add, ysize + y_add); if (svga->vertical_linedbl) svga->vertical_linedbl >>= 1; diff --git a/src/video/vid_voodoo_display.c b/src/video/vid_voodoo_display.c index bfee8554c..a52249bee 100644 --- a/src/video/vid_voodoo_display.c +++ b/src/video/vid_voodoo_display.c @@ -655,7 +655,7 @@ skip_draw: thread_release_mutex(voodoo->force_blit_mutex); if (voodoo->dirty_line_high > voodoo->dirty_line_low || force_blit) - svga_doblit(0, voodoo->v_disp, voodoo->h_disp, voodoo->v_disp-1, voodoo->svga); + svga_doblit(voodoo->h_disp, voodoo->v_disp-1, voodoo->svga); if (voodoo->clutData_dirty) { voodoo->clutData_dirty = 0; diff --git a/src/video/vid_wy700.c b/src/video/vid_wy700.c index 0affbd58e..57faf5fdc 100644 --- a/src/video/vid_wy700.c +++ b/src/video/vid_wy700.c @@ -870,7 +870,7 @@ void wy700_poll(void *p) if (video_force_resize_get()) video_force_resize_set(0); } - video_blit_memtoscreen_8(0, 0, 0, ysize, xsize, ysize); + video_blit_memtoscreen_8(0, 0, xsize, ysize); frames++; /* Fixed 1280x800 resolution */ diff --git a/src/video/video.c b/src/video/video.c index 66323f079..a98f125cb 100644 --- a/src/video/video.c +++ b/src/video/video.c @@ -244,7 +244,7 @@ const uint32_t shade[5][256] = static struct { - int x, y, y1, y2, w, h; + int x, y, w, h; int busy; int buffer_in_use; @@ -255,7 +255,7 @@ static struct { } blit_data; -static void (*blit_func)(int x, int y, int y1, int y2, int w, int h); +static void (*blit_func)(int x, int y, int w, int h); #ifdef ENABLE_VIDEO_LOG @@ -279,7 +279,7 @@ video_log(const char *fmt, ...) void -video_setblit(void(*blit)(int,int,int,int,int,int)) +video_setblit(void(*blit)(int,int,int,int)) { blit_func = blit; } @@ -317,7 +317,7 @@ static png_infop info_ptr; static void -video_take_screenshot(const char *fn, int startx, int starty, int y1, int y2, int w, int h) +video_take_screenshot(const char *fn) { int i, x, y; png_bytep *b_rgb = NULL; @@ -349,25 +349,26 @@ video_take_screenshot(const char *fn, int startx, int starty, int y1, int y2, in png_init_io(png_ptr, fp); - png_set_IHDR(png_ptr, info_ptr, w, h, + png_set_IHDR(png_ptr, info_ptr, blit_data.w, blit_data.h, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - b_rgb = (png_bytep *) malloc(sizeof(png_bytep) * h); + b_rgb = (png_bytep *) malloc(sizeof(png_bytep) * blit_data.h); if (b_rgb == NULL) { video_log("[video_take_screenshot] Unable to Allocate RGB Bitmap Memory"); fclose(fp); return; } - for (y = 0; y < h; ++y) { + for (y = 0; y < blit_data.h; ++y) { b_rgb[y] = (png_byte *) malloc(png_get_rowbytes(png_ptr, info_ptr)); - for (x = 0; x < w; ++x) { - temp = buffer32->line[starty + y][startx + x]; - - b_rgb[y][(x) * 3 + 0] = (temp >> 16) & 0xff; - b_rgb[y][(x) * 3 + 1] = (temp >> 8) & 0xff; - b_rgb[y][(x) * 3 + 2] = temp & 0xff; + for (x = 0; x < blit_data.w; ++x) { + if (buffer32 == NULL) + memset(&(b_rgb[y][x * 3]), 0x00, 3); + else { + temp = buffer32->line[blit_data.y + y][blit_data.x + x]; + memcpy(&(b_rgb[y][x * 3]), &temp, 3); + } } } @@ -378,7 +379,7 @@ video_take_screenshot(const char *fn, int startx, int starty, int y1, int y2, in png_write_end(png_ptr, NULL); /* cleanup heap allocation */ - for (i = 0; i < h; i++) + for (i = 0; i < blit_data.h; i++) if (b_rgb[i]) free(b_rgb[i]); if (b_rgb) free(b_rgb); @@ -388,7 +389,7 @@ video_take_screenshot(const char *fn, int startx, int starty, int y1, int y2, in static void -video_screenshot(int x, int y, int y1, int y2, int w, int h) +video_screenshot(void) { char path[1024], fn[128]; @@ -407,7 +408,7 @@ video_screenshot(int x, int y, int y1, int y2, int w, int h) video_log("taking screenshot to: %s\n", path); - video_take_screenshot((const char *) path, x, y, y1, y2, w, h); + video_take_screenshot((const char *) path); png_destroy_write_struct(&png_ptr, &info_ptr); } @@ -417,10 +418,12 @@ video_transform_copy(uint32_t *dst, uint32_t *src, int len) { int i; - for (i = 0; i < len; i++) { - *dst = video_color_transform(*src); - dst++; - src++; + if ((dst != NULL) && (src != NULL)) { + for (i = 0; i < len; i++) { + *dst = video_color_transform(*src); + dst++; + src++; + } } } @@ -435,8 +438,8 @@ void blit_thread(void *param) thread_reset_event(blit_data.wake_blit_thread); MTR_BEGIN("video", "blit_thread"); - if ((video_grayscale || invert_display) && blit_data.y2 > 0) { - for (yy = blit_data.y1; yy < blit_data.y2; yy++) { + if ((video_grayscale || invert_display) && (blit_data.h > 0)) { + for (yy = 0; yy < blit_data.h; yy++) { if (((blit_data.y + yy) >= 0) && ((blit_data.y + yy) < buffer32->h)) { video_transform_copy(&(buffer32->line[blit_data.y + yy][blit_data.x]), &(buffer32->line[blit_data.y + yy][blit_data.x]), blit_data.w); } @@ -444,16 +447,13 @@ void blit_thread(void *param) } if (screenshots) { - if (buffer32 != NULL) - video_screenshot(blit_data.x, blit_data.y, blit_data.y1, blit_data.y2, blit_data.w, blit_data.h); + video_screenshot(); screenshots--; video_log("screenshot taken, %i left\n", screenshots); } if (blit_func) - blit_func(blit_data.x, blit_data.y, - blit_data.y1, blit_data.y2, - blit_data.w, blit_data.h); + blit_func(blit_data.x, blit_data.y, blit_data.w, blit_data.h); blit_data.busy = 0; @@ -464,7 +464,7 @@ void blit_thread(void *param) void -video_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h) +video_blit_memtoscreen(int x, int y, int w, int h) { MTR_BEGIN("video", "video_blit_memtoscreen"); @@ -477,8 +477,6 @@ video_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h) blit_data.buffer_in_use = 1; blit_data.x = x; blit_data.y = y; - blit_data.y1 = y1; - blit_data.y2 = y2; blit_data.w = w; blit_data.h = h; @@ -542,7 +540,7 @@ video_blend(int x, int y) void -video_blit_memtoscreen_8(int x, int y, int y1, int y2, int w, int h) +video_blit_memtoscreen_8(int x, int y, int w, int h) { int yy, xx; @@ -559,7 +557,7 @@ video_blit_memtoscreen_8(int x, int y, int y1, int y2, int w, int h) } } - video_blit_memtoscreen(x, y, y1, y2, w, h); + video_blit_memtoscreen(x, y, w, h); } diff --git a/src/vnc.c b/src/vnc.c index 5f687a9f3..f2f4655b0 100644 --- a/src/vnc.c +++ b/src/vnc.c @@ -167,16 +167,19 @@ vnc_display(rfbClientPtr cl) static void -vnc_blit(int x, int y, int y1, int y2, int w, int h) +vnc_blit(int x, int y, int w, int h) { uint32_t *p; int yy; - for (yy=y1; yyframeBuffer)[yy*VNC_MAX_X]); if ((y+yy) >= 0 && (y+yy) < VNC_MAX_Y) - memcpy(p, &(buffer32->line[yy]), w*4); + memcpy(p, &(buffer32->line[yy]), w*sizeof(uint32_t)); } video_blit_complete(); diff --git a/src/win/win_opengl.c b/src/win/win_opengl.c index dec6436d0..7e92e40b8 100644 --- a/src/win/win_opengl.c +++ b/src/win/win_opengl.c @@ -808,11 +808,11 @@ static void opengl_main(void* param) CoUninitialize(); } -static void opengl_blit(int x, int y, int y1, int y2, int w, int h) +static void opengl_blit(int x, int y, int w, int h) { int yy; - if (y1 == y2 || h <= 0 || buffer32 == NULL || thread == NULL || + if ((h <= 0) || (buffer32 == NULL) || (thread == NULL) || atomic_flag_test_and_set(&blit_info[write_pos].in_use)) { video_blit_complete(); @@ -821,8 +821,8 @@ static void opengl_blit(int x, int y, int y1, int y2, int w, int h) for (yy = 0; yy < h; yy++) { if ((y + yy) >= 0 && (y + yy) < buffer32->h) - memcpy(blit_info[write_pos].buffer + (yy * w * 4), - &(((uint32_t *) buffer32->line[y + yy])[x]), w * 4); + memcpy(blit_info[write_pos].buffer + (yy * w * sizeof(uint32_t)), + &(((uint32_t *) buffer32->line[y + yy])[x]), w * sizeof(uint32_t)); } video_blit_complete(); diff --git a/src/win/win_sdl.c b/src/win/win_sdl.c index c5978501f..303fb5f69 100644 --- a/src/win/win_sdl.c +++ b/src/win/win_sdl.c @@ -229,12 +229,12 @@ sdl_stretch(int *w, int *h, int *x, int *y) static void -sdl_blit(int x, int y, int y1, int y2, int w, int h) +sdl_blit(int x, int y, int w, int h) { SDL_Rect r_src; int ret; - if (!sdl_enabled || (y1 == y2) || (h <= 0) || (buffer32 == NULL) || (sdl_render == NULL) || (sdl_tex == NULL)) { + if (!sdl_enabled || (h <= 0) || (buffer32 == NULL) || (sdl_render == NULL) || (sdl_tex == NULL)) { video_blit_complete(); return; } @@ -245,7 +245,7 @@ sdl_blit(int x, int y, int y1, int y2, int w, int h) r_src.y = y; r_src.w = w; r_src.h = h; - SDL_UpdateTexture(sdl_tex, &r_src, &(buffer32->line[y][x]), (2048 + 64) * 4); + SDL_UpdateTexture(sdl_tex, &r_src, &(buffer32->line[y][x]), (2048 + 64) * sizeof(uint32_t)); video_blit_complete(); SDL_RenderClear(sdl_render); From f27fec174021aad03a1ae9ff061530bf885c46e6 Mon Sep 17 00:00:00 2001 From: OBattler Date: Mon, 13 Sep 2021 23:28:00 +0200 Subject: [PATCH 9/9] Removed EGA/(S)VGA render wake-up on zero-sized blit and fixed the last compile-breaking mistake in the Unix SDL code. --- src/unix/unix_sdl.c | 2 +- src/video/vid_ega.c | 4 +--- src/video/vid_svga.c | 4 +--- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/unix/unix_sdl.c b/src/unix/unix_sdl.c index ae5b43a9b..ee1220409 100644 --- a/src/unix/unix_sdl.c +++ b/src/unix/unix_sdl.c @@ -138,7 +138,7 @@ sdl_blit(int x, int y, int w, int h) SDL_Rect r_src; int ret; - if (!sdl_enabled || (h <= 0) || (render_buffer == NULL) || (sdl_render == NULL) || (sdl_tex == NULL)) { + if (!sdl_enabled || (h <= 0) || (buffer32 == NULL) || (sdl_render == NULL) || (sdl_tex == NULL)) { video_blit_complete(); return; } diff --git a/src/video/vid_ega.c b/src/video/vid_ega.c index c8f2a43c1..61cf87ee0 100644 --- a/src/video/vid_ega.c +++ b/src/video/vid_ega.c @@ -675,10 +675,8 @@ ega_doblit(int wx, int wy, ega_t *ega) bottom <<= 1; } - if ((wx <= 0) || (wy <= 0)) { - video_blit_memtoscreen(x_start, y_start, 0, 0); + if ((wx <= 0) || (wy <= 0)) return; - } if (ega->vres) ega->y_add <<= 1; diff --git a/src/video/vid_svga.c b/src/video/vid_svga.c index 9615c10a0..b38353701 100644 --- a/src/video/vid_svga.c +++ b/src/video/vid_svga.c @@ -1361,10 +1361,8 @@ svga_doblit(int wx, int wy, svga_t *svga) bottom <<= 1; } - if ((wx <= 0) || (wy <= 0)) { - video_blit_memtoscreen(x_start, y_start, 0, 0); + if ((wx <= 0) || (wy <= 0)) return; - } if (svga->vertical_linedbl) svga->y_add <<= 1;