From 11d7afd5780a5a7eb3fee560decc14934354bf63 Mon Sep 17 00:00:00 2001 From: TC1995 Date: Thu, 30 May 2024 00:13:29 +0200 Subject: [PATCH] Video changes part 3 (minor though) 1. Added an on-board S3 ViRGE DX (375) video card to the Intel AP440FX socket 8-based machine alongside its on-board CS4236B audio. 2. Sanity check for on-board S3 ViRGE devices. --- src/include/86box/video.h | 1 + src/machine/m_at_socket8.c | 7 +++++ src/machine/machine_table.c | 14 +++++----- src/video/vid_s3_virge.c | 51 +++++++++++++++++++++++++++---------- 4 files changed, 52 insertions(+), 21 deletions(-) diff --git a/src/include/86box/video.h b/src/include/86box/video.h index e1a1a7502..83930122b 100644 --- a/src/include/86box/video.h +++ b/src/include/86box/video.h @@ -528,6 +528,7 @@ extern const device_t s3_diamond_stealth_2000_pci_device; extern const device_t s3_diamond_stealth_3000_pci_device; extern const device_t s3_stb_velocity_3d_pci_device; extern const device_t s3_virge_375_pci_device; +extern const device_t s3_virge_375_onboard_pci_device; extern const device_t s3_diamond_stealth_2000pro_pci_device; extern const device_t s3_virge_385_pci_device; extern const device_t s3_virge_357_pci_device; diff --git a/src/machine/m_at_socket8.c b/src/machine/m_at_socket8.c index e8262a6f4..8c2688c1a 100644 --- a/src/machine/m_at_socket8.c +++ b/src/machine/m_at_socket8.c @@ -33,6 +33,7 @@ #include <86box/timer.h> #include <86box/nvr.h> #include <86box/sio.h> +#include <86box/sound.h> #include <86box/hwm.h> #include <86box/spd.h> #include <86box/video.h> @@ -322,6 +323,12 @@ machine_at_ap440fx_init(const machine_t *model) device_add(&pc87307_device); device_add(&intel_flash_bxt_ami_device); + if (sound_card_current[0] == SOUND_INTERNAL) + device_add(&cs4236b_device); + + if (gfxcard[0] == VID_INTERNAL) + device_add(&s3_virge_375_onboard_pci_device); + return ret; } diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index 4b91f1668..9d38686bd 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -5182,7 +5182,7 @@ const machine_t machines[] = { .snd_device = NULL, .net_device = NULL }, - /* The board has a "ASII KB-100" which I was not able to find any information about, + /* The board has a "ASII KB-100" which I was not able to find any information about, but the BIOS sends commands C9 without a parameter and D5, both of which are Phoenix MultiKey commands. */ { @@ -10606,7 +10606,7 @@ const machine_t machines[] = { .snd_device = NULL, .net_device = NULL }, - /* [TEST] The board doesn't seem to have a KBC at all, which probably means it's an on-chip one on the PC87306 SIO. + /* [TEST] The board doesn't seem to have a KBC at all, which probably means it's an on-chip one on the PC87306 SIO. A list on a Danish site shows the BIOS as having a -0 string, indicating non-AMI KBC firmware. */ { .name = "[i430HX] Supermicro P55T2S", @@ -12658,7 +12658,7 @@ const machine_t machines[] = { .snd_device = NULL, .net_device = NULL }, - + /* ALi ALADDiN IV+ */ /* Has the ALi M1543 southbridge with on-chip KBC. */ { @@ -13051,7 +13051,7 @@ const machine_t machines[] = { .max_multi = 5.5 }, .bus_flags = MACHINE_PS2_A97 | MACHINE_BUS_USB, - .flags = MACHINE_IDE_DUAL | MACHINE_SOUND | MACHINE_APM | MACHINE_ACPI | MACHINE_GAMEPORT | MACHINE_USB, + .flags = MACHINE_IDE_DUAL | MACHINE_SOUND | MACHINE_APM | MACHINE_ACPI | MACHINE_GAMEPORT | MACHINE_USB, .ram = { .min = 8192, .max = 786432, @@ -13462,7 +13462,7 @@ const machine_t machines[] = { .max_multi = 3.5 }, .bus_flags = MACHINE_PS2_PCI | MACHINE_BUS_USB, - .flags = MACHINE_IDE_DUAL | MACHINE_APM | MACHINE_USB, /* Machine has internal video: S3 ViRGE/DX and sound: Crystal CS4236B */ + .flags = MACHINE_IDE_DUAL | MACHINE_APM | MACHINE_SOUND | MACHINE_VIDEO | MACHINE_USB, /* Machine has internal video: S3 ViRGE/DX and sound: Crystal CS4236B */ .ram = { .min = 8192, .max = 131072, @@ -13476,8 +13476,8 @@ const machine_t machines[] = { .device = NULL, .fdc_device = NULL, .sio_device = NULL, - .vid_device = NULL, - .snd_device = NULL, + .vid_device = &s3_virge_375_onboard_pci_device, + .snd_device = &cs4236b_device, .net_device = NULL }, /* According to tests from real hardware: This has AMI MegaKey KBC firmware on the diff --git a/src/video/vid_s3_virge.c b/src/video/vid_s3_virge.c index 4d64dffbd..26560c498 100644 --- a/src/video/vid_s3_virge.c +++ b/src/video/vid_s3_virge.c @@ -295,6 +295,8 @@ typedef struct virge_t { void *i2c, *ddc; int waiting; + + int has_bios; } virge_t; static video_timings_t timing_diamond_stealth3d_2000_pci = { .type = VIDEO_PCI, .write_b = 2, .write_w = 2, .write_l = 3, .read_b = 28, .read_w = 28, .read_l = 45 }; @@ -1070,14 +1072,13 @@ s3_virge_updatemapping(virge_t *virge) virge->linear_base &= ~(virge->linear_size - 1); s3_virge_log("Linear framebuffer at %08X size %08X, mask = %08x, CRTC58 sel = %02x\n", virge->linear_base, virge->linear_size, virge->vram_mask, svga->crtc[0x58] & 7); if (virge->linear_base == 0xa0000) { - mem_mapping_set_addr(&svga->mapping, 0xa0000, 0x10000); + mem_mapping_set_addr(&svga->mapping, 0xa0000, 0x10000, 0); mem_mapping_disable(&virge->linear_mapping); } else { - if (virge->chip == S3_VIRGEVX || virge->chip == S3_TRIO3D2X) { + if (virge->chip == S3_VIRGEVX || virge->chip == S3_TRIO3D2X) virge->linear_base &= 0xfe000000; - } else { + else virge->linear_base &= 0xfc000000; - } mem_mapping_set_addr(&virge->linear_mapping, virge->linear_base, virge->linear_size); } @@ -4069,16 +4070,16 @@ s3_virge_pci_read(UNUSED(int func), int addr, void *priv) break; case 0x30: - ret = virge->pci_regs[0x30] & 0x01; + ret = virge->has_bios ? (virge->pci_regs[0x30] & 0x01) : 0x00; break; /*BIOS ROM address*/ case 0x31: ret = 0x00; break; case 0x32: - ret = virge->pci_regs[0x32]; + ret = virge->has_bios ? virge->pci_regs[0x32] : 0x00; break; case 0x33: - ret = virge->pci_regs[0x33]; + ret = virge->has_bios ? virge->pci_regs[0x33] : 0x00; break; case 0x34: @@ -4202,6 +4203,8 @@ s3_virge_pci_write(UNUSED(int func), int addr, uint8_t val, void *priv) case 0x30: case 0x32: case 0x33: + if (!virge->has_bios) + return; virge->pci_regs[addr] = val; if (virge->pci_regs[0x30] & 0x01) { uint32_t biosaddr = (virge->pci_regs[0x32] << 16) | (virge->pci_regs[0x33] << 24); @@ -4337,7 +4340,8 @@ s3_virge_reset(void *priv) virge->svga.crtc[0x37] = 1 | (7 << 5); virge->svga.crtc[0x53] = 8; - mem_mapping_disable(&virge->bios_rom.mapping); + if (virge->has_bios) + mem_mapping_disable(&virge->bios_rom.mapping); s3_virge_updatemapping(virge); @@ -4360,6 +4364,8 @@ s3_virge_init(const device_t *info) else virge->memory_size = device_get_config_int("memory"); + virge->has_bios = !!(info->local & 0x100); + switch (info->local) { case S3_VIRGE_325: bios_fn = ROM_VIRGE_325; @@ -4374,7 +4380,7 @@ s3_virge_init(const device_t *info) bios_fn = ROM_STB_VELOCITY_3D; break; case S3_VIRGE_DX: - bios_fn = ROM_VIRGE_DX; + bios_fn = virge->has_bios ? ROM_VIRGE_DX : NULL; break; case S3_DIAMOND_STEALTH3D_2000PRO: bios_fn = ROM_DIAMOND_STEALTH3D_2000PRO; @@ -4408,11 +4414,12 @@ s3_virge_init(const device_t *info) rom_init(&virge->bios_rom, bios_fn, 0xc0000, 0x10000, 0xffff, 0, MEM_MAPPING_EXTERNAL); else rom_init(&virge->bios_rom, bios_fn, 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); + + mem_mapping_disable(&virge->bios_rom.mapping); } - mem_mapping_disable(&virge->bios_rom.mapping); - - mem_mapping_add(&virge->linear_mapping, 0, 0, svga_read_linear, + mem_mapping_add(&virge->linear_mapping, 0, 0, + svga_read_linear, svga_readw_linear, svga_readl_linear, svga_write_linear, @@ -4421,7 +4428,8 @@ s3_virge_init(const device_t *info) NULL, MEM_MAPPING_EXTERNAL, &virge->svga); - mem_mapping_add(&virge->mmio_mapping, 0, 0, s3_virge_mmio_read, + mem_mapping_add(&virge->mmio_mapping, 0, 0, + s3_virge_mmio_read, s3_virge_mmio_read_w, s3_virge_mmio_read_l, s3_virge_mmio_write, @@ -4430,7 +4438,8 @@ s3_virge_init(const device_t *info) NULL, MEM_MAPPING_EXTERNAL, virge); - mem_mapping_add(&virge->new_mmio_mapping, 0, 0, s3_virge_mmio_read, + mem_mapping_add(&virge->new_mmio_mapping, 0, 0, + s3_virge_mmio_read, s3_virge_mmio_read_w, s3_virge_mmio_read_l, s3_virge_mmio_write, @@ -4896,6 +4905,20 @@ const device_t s3_virge_375_pci_device = { .config = s3_virge_config }; +const device_t s3_virge_375_onboard_pci_device = { + .name = "S3 ViRGE/DX (375) On-Board PCI", + .internal_name = "virge375_onboard_pci", + .flags = DEVICE_PCI, + .local = S3_VIRGE_DX | 0x100, + .init = s3_virge_init, + .close = s3_virge_close, + .reset = s3_virge_reset, + { .available = NULL }, + .speed_changed = s3_virge_speed_changed, + .force_redraw = s3_virge_force_redraw, + .config = s3_virge_config +}; + const device_t s3_diamond_stealth_2000pro_pci_device = { .name = "S3 ViRGE/DX (Diamond Stealth 3D 2000 Pro) PCI", .internal_name = "stealth3d_2000pro_pci",