diff --git a/src/include/86box/vid_8514a.h b/src/include/86box/vid_8514a.h index 4c534c47b..6e8528325 100644 --- a/src/include/86box/vid_8514a.h +++ b/src/include/86box/vid_8514a.h @@ -67,8 +67,6 @@ typedef union { typedef struct ibm8514_t { rom_t bios_rom; - rom_t bios_rom2; - mem_mapping_t bios_mapping; uint8_t *rom1; uint8_t *rom2; hwcursor8514_t hwcursor; @@ -107,6 +105,8 @@ typedef struct ibm8514_t { uint64_t dispofftime; struct { + uint16_t scratch0; + uint16_t scratch1; uint16_t subsys_cntl; uint16_t setup_md; uint16_t advfunc_cntl; diff --git a/src/include/86box/vid_svga.h b/src/include/86box/vid_svga.h index 02c2e0f17..ffe4f5808 100644 --- a/src/include/86box/vid_svga.h +++ b/src/include/86box/vid_svga.h @@ -348,6 +348,8 @@ extern void ati8514_out(uint16_t addr, uint8_t val, void *priv); extern uint8_t ati8514_in(uint16_t addr, void *priv); extern void ati8514_recalctimings(svga_t *svga); extern uint8_t ati8514_mca_read(int port, void *priv); +extern uint8_t ati8514_rom_readb(uint32_t addr, void *priv); +extern uint16_t ati8514_rom_readw(uint32_t addr, void *priv); extern void ati8514_mca_write(int port, uint8_t val, void *priv); extern void ati8514_pos_write(uint16_t port, uint8_t val, void *priv); extern void ati8514_init(svga_t *svga, void *ext8514, void *dev8514); diff --git a/src/video/vid_8514a.c b/src/video/vid_8514a.c index 1c9a482af..32a402ec5 100644 --- a/src/video/vid_8514a.c +++ b/src/video/vid_8514a.c @@ -47,7 +47,7 @@ # undef CLAMP #endif -#define BIOS_MACH8_ROM_PATH "roms/video/mach8/11301113140_4k.BIN" +#define BIOS_MACH8_ROM_PATH "roms/video/mach8/11301113140_ROM.BIN" static void ibm8514_accel_outb(uint16_t port, uint8_t val, void *priv); static void ibm8514_accel_outw(uint16_t port, uint16_t val, void *priv); @@ -3930,7 +3930,7 @@ ibm8514_mca_reset(void *priv) ibm8514_log("MCA reset.\n"); dev->on = 0; - if (dev->extensions) + if (dev->extensions == ATI) ati8514_mca_write(0x102, 0, svga); else ibm8514_mca_write(0x102, 0, svga); @@ -3950,6 +3950,8 @@ ibm8514_vblank_start(void *priv) static void * ibm8514_init(const device_t *info) { + FILE *fp; + uint8_t *rom_load = NULL; uint32_t bios_addr = 0; uint16_t bios_rom_eeprom = 0x0000; @@ -3979,33 +3981,46 @@ ibm8514_init(const device_t *info) dev->extensions = device_get_config_int("extensions"); bios_addr = device_get_config_hex20("bios_addr"); if (dev->type & DEVICE_MCA) - bios_addr = 0xc6000; + bios_addr = 0xc6800; switch (dev->extensions) { case ATI: if (rom_present(BIOS_MACH8_ROM_PATH)) { mach_t * mach = (mach_t *) calloc(1, sizeof(mach_t)); svga->ext8514 = mach; + fp = rom_fopen(BIOS_MACH8_ROM_PATH, "rb"); + if (bios_addr & 0x800) + (void) fseek(fp, 0x000, SEEK_SET); + else + (void) fseek(fp, 0x800, SEEK_SET); - rom_init(&dev->bios_rom, - BIOS_MACH8_ROM_PATH, - bios_addr, 0x1000, 0xfff, - 0, MEM_MAPPING_EXTERNAL); + rom_load = malloc(0x2000); + (void) !fread(rom_load, 0x2000, 1, fp); + (void) fclose(fp); + memset(&dev->bios_rom, 0x00, sizeof(rom_t)); + dev->bios_rom.rom = rom_load; + dev->bios_rom.mask = 0x1fff; + mem_mapping_add(&dev->bios_rom.mapping, bios_addr, 0x2000, + ati8514_rom_readb, ati8514_rom_readw, NULL, + NULL, NULL, NULL, + dev->bios_rom.rom, MEM_MAPPING_EXTERNAL | MEM_MAPPING_ROM_WS, dev); ati8514_init(svga, svga->ext8514, svga->dev8514); - mach->accel.scratch0 = ((bios_addr >> 7) - 0x1000) >> 4; - bios_rom_eeprom = mach->accel.scratch0; if (dev->type & DEVICE_MCA) { + dev->accel.scratch0 = (((bios_addr >> 7) - 0x1000) >> 4); + dev->accel.scratch0 |= ((dev->accel.scratch0 + 0x01) << 8); + bios_rom_eeprom = dev->accel.scratch0; dev->pos_regs[0] = 0x88; dev->pos_regs[1] = 0x80; - mach->eeprom.data[0] = 0x0000; - mach->eeprom.data[1] = bios_rom_eeprom | ((bios_rom_eeprom | 0x01) << 8); - ibm8514_log("EEPROM Data1=%04x.\n", mach->eeprom.data[1]); + mach->eeprom.data[1] = bios_rom_eeprom; mca_add(ati8514_mca_read, ati8514_mca_write, ibm8514_mca_feedb, ibm8514_mca_reset, svga); ati_eeprom_load_mach8(&mach->eeprom, "ati8514_mca.nvr", 1); mem_mapping_disable(&dev->bios_rom.mapping); - } else + } else { + dev->accel.scratch0 = ((bios_addr >> 7) - 0x1000) >> 4; + dev->accel.scratch0 |= ((dev->accel.scratch0 + 0x01) << 8); ati_eeprom_load_mach8(&mach->eeprom, "ati8514.nvr", 0); + } break; } @@ -4099,21 +4114,32 @@ static const device_config_t isa_ext8514_config[] = { .description = "BIOS address", .type = CONFIG_HEX20, .default_string = NULL, - .default_int = 0xc8000, + .default_int = 0xc8800, .file_filter = NULL, .spinner = { 0 }, .selection = { { .description = "C800h", .value = 0xc8000 }, + { .description = "C880h", .value = 0xc8800 }, { .description = "CA00h", .value = 0xca000 }, + { .description = "CA80h", .value = 0xca800 }, { .description = "CC00h", .value = 0xcc000 }, + { .description = "CC80h", .value = 0xcc800 }, { .description = "CE00h", .value = 0xce000 }, + { .description = "CE80h", .value = 0xce800 }, { .description = "D000h", .value = 0xd0000 }, + { .description = "D080h", .value = 0xd0800 }, { .description = "D200h", .value = 0xd2000 }, + { .description = "D280h", .value = 0xd2800 }, { .description = "D400h", .value = 0xd4000 }, + { .description = "D480h", .value = 0xd4800 }, { .description = "D600h", .value = 0xd6000 }, + { .description = "D680h", .value = 0xd6800 }, { .description = "D800h", .value = 0xd8000 }, + { .description = "D880h", .value = 0xd8800 }, { .description = "DA00h", .value = 0xda000 }, + { .description = "DA80h", .value = 0xda800 }, { .description = "DC00h", .value = 0xdc000 }, + { .description = "DC80h", .value = 0xdc800 }, { .description = "DE00h", .value = 0xde000 }, { .description = "" } }, diff --git a/src/video/vid_ati_mach8.c b/src/video/vid_ati_mach8.c index c4a2b8814..e0d66f5cc 100644 --- a/src/video/vid_ati_mach8.c +++ b/src/video/vid_ati_mach8.c @@ -2825,7 +2825,7 @@ mach_set_resolution(mach_t *mach, svga_t *svga) dev->v_syncstart = mach->eeprom.data[8] + 1; mach->accel.clock_sel_mode = ((mach->eeprom.data[4] >> 8) & 0xff) << 2; } else { - pclog("Mach: EEPROM 1024x768: %04x.\n", mach->eeprom.data[9]); + mach_log("Mach: EEPROM 1024x768: %04x.\n", mach->eeprom.data[9]); switch (mach->eeprom.data[9] & 0xff) { case 0x00: /*1024x768 76Hz Non-interlaced*/ dev->h_total = 0xa3; @@ -2885,7 +2885,7 @@ mach_set_resolution(mach_t *mach, svga_t *svga) dev->v_syncstart = mach->eeprom.data[8] + 1; mach->accel.clock_sel_mode = ((mach->eeprom.data[4] >> 8) & 0xff) << 2; } else { - pclog("Mach Reset: EEPROM 1024x768: %04x.\n", mach->eeprom.data[9]); + mach_log("Mach Reset: EEPROM 1024x768: %04x.\n", mach->eeprom.data[9]); switch (mach->eeprom.data[9] & 0xff) { case 0x00: /*1024x768 76Hz Non-interlaced*/ dev->h_total = 0xa3; @@ -4066,9 +4066,9 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u case 0x52ef: mach_log("ATI 8514/A: (0x%04x) ScratchPad0 val=%04x.\n", port, val); if (len == 2) - mach->accel.scratch0 = val; + dev->accel.scratch0 = val; else { - WRITE8(port, mach->accel.scratch0, val); + WRITE8(port, dev->accel.scratch0, val); } break; @@ -4076,9 +4076,9 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u case 0x56ef: mach_log("ATI 8514/A: (0x%04x) ScratchPad1 val=%04x.\n", port, val); if (len == 2) - mach->accel.scratch1 = val; + dev->accel.scratch1 = val; else { - WRITE8(port, mach->accel.scratch1, val); + WRITE8(port, dev->accel.scratch1, val); } break; @@ -4119,6 +4119,7 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u else { WRITE8(port, mach->accel.max_waitstates, val); } + mach_log("ATI 8514/A: (0x%04x) val=0x%02x, len=%d.\n", port, val, len); break; case 0x6eee: @@ -4208,8 +4209,10 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u svga_recalctimings(svga); mach32_updatemapping(mach, svga); - } else - ati_eeprom_write(&mach->eeprom, !!(mach->accel.ext_ge_config & 0x04), !!(mach->accel.ext_ge_config & 0x02), !!(mach->accel.ext_ge_config & 0x01)); + } else { + if (mach->accel.ext_ge_config & 0x80) + ati_eeprom_write(&mach->eeprom, !!(mach->accel.ext_ge_config & 0x04), !!(mach->accel.ext_ge_config & 0x02), !!(mach->accel.ext_ge_config & 0x01)); + } break; case 0x7eee: @@ -5161,27 +5164,16 @@ mach_accel_in_call(uint16_t port, mach_t *mach, svga_t *svga, ibm8514_t *dev) case 0x52ee: case 0x52ef: - READ8(port, mach->accel.scratch0); - if (mach->mca_bus) { - if (svga->ext8514 != NULL) { - temp = (((dev->bios_rom.mapping.base >> 7) - 0x1000) >> 4); - if (port & 1) - temp |= 0x01; - } else { - if (mach->accel.scratch0 == 0x1234) - temp = 0x0000; - } - } else { - mach_log("ScratchPad0=%x.\n", mach->accel.scratch0); - if (mach->accel.scratch0 == 0x1234) - temp = 0x0000; - } + READ8(port, dev->accel.scratch0); + mach_log("ScratchPad0=%x.\n", dev->accel.scratch0); + if (dev->accel.scratch0 == 0x1234) + temp = 0x0000; break; case 0x56ee: case 0x56ef: - READ8(port, mach->accel.scratch1); - mach_log("ScratchPad1=%x.\n", mach->accel.scratch1); + READ8(port, dev->accel.scratch1); + mach_log("ScratchPad1=%x.\n", dev->accel.scratch1); break; case 0x5eee: @@ -7327,6 +7319,38 @@ mach_reset(void *priv) } } +uint8_t +ati8514_rom_readb(uint32_t addr, void *priv) +{ + const ibm8514_t *dev = (ibm8514_t *) priv; + const rom_t *rom = &dev->bios_rom; + uint8_t ret; + + mach_log("ROM1RB=%05x, ", addr); + + addr &= 0x1fff; + ret = rom->rom[addr]; + + mach_log("ReadBAddr1=%03x, ret=%02x.\n", addr, ret); + return (ret); +} + +uint16_t +ati8514_rom_readw(uint32_t addr, void *priv) +{ + const ibm8514_t *dev = (ibm8514_t *) priv; + const rom_t *rom = &dev->bios_rom; + uint16_t ret; + + mach_log("ROM1RW=%05x, ", addr); + + addr &= 0x1fff; + ret = (*(uint16_t *) &(rom->rom[addr])); + + mach_log("ReadWAddr1=%03x, ret=%04x.\n", addr, ret); + return (ret); +} + static void * mach8_init(const device_t *info) {