Skip to content

Commit

Permalink
Merge pull request 86Box#3981 from Cacodemon345/mga-g100
Browse files Browse the repository at this point in the history
Make Matrox Productiva G100 usable as secondary display
  • Loading branch information
OBattler authored Jan 2, 2024
2 parents 4fa19c6 + 64c930f commit 72ff425
Show file tree
Hide file tree
Showing 2 changed files with 215 additions and 204 deletions.
43 changes: 27 additions & 16 deletions src/video/vid_mga.c
Original file line number Diff line number Diff line change
Expand Up @@ -2797,11 +2797,14 @@ static uint8_t
mystique_readb_linear(uint32_t addr, void *priv)
{
const svga_t *svga = (svga_t *) priv;
mystique_t *mystique = (mystique_t *) svga->priv;

if (!svga->fast)
return svga_read_linear(addr, priv);
if (mystique->type < MGA_1064SG) {
if (!svga->fast)
return svga_read_linear(addr, priv);
}

cycles -= video_timing_read_b;
cycles -= svga->monitor->mon_video_timing_read_b;

addr &= svga->decode_mask;
if (addr >= svga->vram_max)
Expand All @@ -2815,7 +2818,7 @@ mystique_readw_linear(uint32_t addr, void *priv)
{
svga_t *svga = (svga_t *) priv;

cycles -= video_timing_read_w;
cycles -= svga->monitor->mon_video_timing_read_w;

addr &= svga->decode_mask;
if (addr >= svga->vram_max)
Expand All @@ -2829,7 +2832,7 @@ mystique_readl_linear(uint32_t addr, void *priv)
{
svga_t *svga = (svga_t *) priv;

cycles -= video_timing_read_l;
cycles -= svga->monitor->mon_video_timing_read_l;

addr &= svga->decode_mask;
if (addr >= svga->vram_max)
Expand All @@ -2842,13 +2845,16 @@ static void
mystique_writeb_linear(uint32_t addr, uint8_t val, void *priv)
{
svga_t *svga = (svga_t *) priv;
mystique_t *mystique = (mystique_t *) svga->priv;

if (!svga->fast) {
svga_write_linear(addr, val, priv);
return;
if (mystique->type < MGA_1064SG) {
if (!svga->fast) {
svga_write_linear(addr, val, priv);
return;
}
}

cycles -= video_timing_write_b;
cycles -= svga->monitor->mon_video_timing_write_b;

addr &= svga->decode_mask;
if (addr >= svga->vram_max)
Expand All @@ -2863,7 +2869,7 @@ mystique_writew_linear(uint32_t addr, uint16_t val, void *priv)
{
svga_t *svga = (svga_t *) priv;

cycles -= video_timing_write_w;
cycles -= svga->monitor->mon_video_timing_write_w;

addr &= svga->decode_mask;
if (addr >= svga->vram_max)
Expand All @@ -2878,7 +2884,7 @@ mystique_writel_linear(uint32_t addr, uint32_t val, void *priv)
{
svga_t *svga = (svga_t *) priv;

cycles -= video_timing_write_l;
cycles -= svga->monitor->mon_video_timing_write_l;

addr &= svga->decode_mask;
if (addr >= svga->vram_max)
Expand Down Expand Up @@ -6193,9 +6199,11 @@ mystique_pci_write(UNUSED(int func), int addr, uint8_t val, void *priv)
if (!(mystique->pci_regs[0x43] & 0x40))
return;
mystique->pci_regs[addr] = val;
if (addr == 0x30)
mystique->pci_regs[addr] &= 1;
if (mystique->pci_regs[0x30] & 0x01) {
uint32_t addr = (mystique->pci_regs[0x32] << 16) | (mystique->pci_regs[0x33] << 24);
mem_mapping_set_addr(&mystique->bios_rom.mapping, addr, 0x8000);
mem_mapping_set_addr(&mystique->bios_rom.mapping, addr, (mystique->type == MGA_G100) ? 0x10000 : 0x8000);
} else
mem_mapping_disable(&mystique->bios_rom.mapping);
return;
Expand All @@ -6219,11 +6227,11 @@ mystique_pci_write(UNUSED(int func), int addr, uint8_t val, void *priv)
if (val & 0x40) {
if (mystique->pci_regs[0x30] & 0x01) {
uint32_t addr = (mystique->pci_regs[0x32] << 16) | (mystique->pci_regs[0x33] << 24);
mem_mapping_set_addr(&mystique->bios_rom.mapping, addr, 0x8000);
mem_mapping_set_addr(&mystique->bios_rom.mapping, addr, (mystique->type == MGA_G100) ? 0x10000 : 0x8000);
} else
mem_mapping_disable(&mystique->bios_rom.mapping);
} else
mem_mapping_set_addr(&mystique->bios_rom.mapping, 0x000c0000, 0x8000);
mem_mapping_set_addr(&mystique->bios_rom.mapping, 0x000c0000, (mystique->type == MGA_G100) ? 0x10000 : 0x8000);
}
break;

Expand Down Expand Up @@ -6322,7 +6330,10 @@ mystique_init(const device_t *info)
else
romfn = ROM_MYSTIQUE_220;

rom_init(&mystique->bios_rom, romfn, 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL);
if (mystique->type == MGA_G100)
rom_init(&mystique->bios_rom, romfn, 0xc0000, 0x10000, 0xffff, 0, MEM_MAPPING_EXTERNAL);
else
rom_init(&mystique->bios_rom, romfn, 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL);
mem_mapping_disable(&mystique->bios_rom.mapping);

mystique->vram_size = device_get_config_int("memory");
Expand Down Expand Up @@ -6382,7 +6393,7 @@ mystique_init(const device_t *info)
if (romfn == NULL)
pci_add_card(PCI_ADD_VIDEO, mystique_pci_read, mystique_pci_write, mystique, &mystique->pci_slot);
else
pci_add_card(PCI_ADD_NORMAL, mystique_pci_read, mystique_pci_write, mystique, &mystique->pci_slot);
pci_add_card((info->flags & DEVICE_AGP) ? PCI_ADD_AGP : PCI_ADD_NORMAL, mystique_pci_read, mystique_pci_write, mystique, &mystique->pci_slot);
mystique->pci_regs[0x06] = 0x80;
mystique->pci_regs[0x07] = 0 << 1;
mystique->pci_regs[0x2c] = mystique->bios_rom.rom[0x7ff8];
Expand Down
Loading

0 comments on commit 72ff425

Please sign in to comment.