diff --git a/src/video/vid_oti067.c b/src/video/vid_oak_oti.c similarity index 72% rename from src/video/vid_oti067.c rename to src/video/vid_oak_oti.c index 420571b4f..32a0a78a3 100644 --- a/src/video/vid_oti067.c +++ b/src/video/vid_oak_oti.c @@ -6,9 +6,9 @@ * * This file is part of the 86Box distribution. * - * Oak OTI067/077 emulation. + * Oak OTI037C/67/077 emulation. * - * Version: @(#)vid_oti067.c 1.0.4 2018/02/03 + * Version: @(#)vid_oak_oti.c 1.0.5 2018/02/24 * * Authors: Sarah Walker, * Miran Grca, @@ -27,10 +27,10 @@ #include "../rom.h" #include "../device.h" #include "video.h" -#include "vid_oti067.h" +#include "vid_oak_oti.h" #include "vid_svga.h" - +#define BIOS_37C_PATH L"roms/video/oti/oti037c/bios.bin" #define BIOS_67_PATH L"roms/video/oti/bios.bin" #define BIOS_77_PATH L"roms/video/oti/oti077.vbi" @@ -45,6 +45,8 @@ typedef struct { uint8_t pos; + uint8_t enable_register; + uint32_t vram_size; uint32_t vram_mask; @@ -58,24 +60,32 @@ oti_out(uint16_t addr, uint8_t val, void *p) oti_t *oti = (oti_t *)p; svga_t *svga = &oti->svga; uint8_t old; + uint8_t idx; + if (!(oti->enable_register & 1) && addr != 0x3C3) + return; + if ((((addr&0xFFF0) == 0x3D0 || (addr&0xFFF0) == 0x3B0) && addr < 0x3de) && !(svga->miscout & 1)) addr ^= 0x60; switch (addr) { + case 0x3C3: + oti->enable_register = val & 1; + return; + case 0x3D4: - svga->crtcreg = val & 31; + svga->crtcreg = val; return; case 0x3D5: - if ((svga->crtcreg < 7) && (svga->crtc[0x11] & 0x80)) + if (((svga->crtcreg & 31) < 7) && (svga->crtc[0x11] & 0x80)) return; - if ((svga->crtcreg == 7) && (svga->crtc[0x11] & 0x80)) + if (((svga->crtcreg & 31) == 7) && (svga->crtc[0x11] & 0x80)) val = (svga->crtc[7] & ~0x10) | (val & 0x10); - old = svga->crtc[svga->crtcreg]; - svga->crtc[svga->crtcreg] = val; + old = svga->crtc[svga->crtcreg & 31]; + svga->crtc[svga->crtcreg & 31] = val; if (old != val) { - if (svga->crtcreg < 0xE || svga->crtcreg > 0x10) { + if ((svga->crtcreg & 31) < 0xE || (svga->crtcreg & 31) > 0x10) { svga->fullchange = changeframecount; svga_recalctimings(svga); } @@ -83,20 +93,31 @@ oti_out(uint16_t addr, uint8_t val, void *p) break; case 0x3DE: - oti->index = val & 0x1f; + oti->index = val; return; case 0x3DF: - oti->regs[oti->index] = val; - switch (oti->index) { + idx = oti->index & 0x1f; + oti->regs[idx] = val; + switch (idx) { case 0xD: - svga->vram_display_mask = (val & 0xc) ? oti->vram_mask : 0x3ffff; - if ((val & 0x80) && oti->vram_size == 256) - mem_mapping_disable(&svga->mapping); + if (oti->chip_id) + { + svga->vram_display_mask = (val & 0xc) ? oti->vram_mask : 0x3ffff; + if ((val & 0x80) && oti->vram_size == 256) + mem_mapping_disable(&svga->mapping); + else + mem_mapping_enable(&svga->mapping); + if (!(val & 0x80)) + svga->vram_display_mask = 0x3ffff; + } else - mem_mapping_enable(&svga->mapping); - if (!(val & 0x80)) - svga->vram_display_mask = 0x3ffff; + { + if (val & 0x80) + mem_mapping_disable(&svga->mapping); + else + mem_mapping_enable(&svga->mapping); + } break; case 0x11: @@ -118,16 +139,23 @@ oti_in(uint16_t addr, void *p) svga_t *svga = &oti->svga; uint8_t temp; + if (!(oti->enable_register & 1) && addr != 0x3C3) + return 0xff; + if ((((addr&0xFFF0) == 0x3D0 || (addr&0xFFF0) == 0x3B0) && addr < 0x3de) && !(svga->miscout & 1)) addr ^= 0x60; switch (addr) { + case 0x3C3: + temp = oti->enable_register; + break; + case 0x3D4: temp = svga->crtcreg; break; case 0x3D5: - temp = svga->crtc[svga->crtcreg]; + temp = svga->crtc[svga->crtcreg & 31]; break; case 0x3DE: @@ -135,10 +163,10 @@ oti_in(uint16_t addr, void *p) break; case 0x3DF: - if (oti->index==0x10) + if ((oti->index & 0x1f)==0x10) temp = 0x18; else - temp = oti->regs[oti->index]; + temp = oti->regs[oti->index & 0x1f]; break; default: @@ -200,6 +228,10 @@ oti_init(device_t *info) oti->chip_id = info->local; switch(oti->chip_id) { + case 0: + romfn = BIOS_37C_PATH; + break; + case 2: romfn = BIOS_67_PATH; break; @@ -220,9 +252,12 @@ oti_init(device_t *info) io_sethandler(0x03c0, 32, oti_in, NULL, NULL, oti_out, NULL, NULL, oti); - io_sethandler(0x46e8, 1, oti_pos_in,NULL,NULL, oti_pos_out,NULL,NULL, oti); - oti->svga.miscout = 1; + io_sethandler(0x46e8, 1, oti_pos_in,NULL,NULL, oti_pos_out,NULL,NULL, oti); + + oti->svga.miscout = 1; + oti->regs[0] = 0x08; /* fixme: bios wants to read this at index 0? this index is undocumented */ + return(oti); } @@ -264,6 +299,11 @@ oti_add_status_info(char *s, int max_len, void *p) svga_add_status_info(s, max_len, &oti->svga); } +static int +oti037c_available(void) +{ + return(rom_present(BIOS_37C_PATH)); +} static int oti067_available(void) @@ -325,6 +365,18 @@ static device_config_t oti077_config[] = } }; +device_t oti037c_device = +{ + "Oak OTI-037C", + DEVICE_ISA, + 0, + oti_init, oti_close, NULL, + oti037c_available, + oti_speed_changed, + oti_force_redraw, + oti_add_status_info, + oti067_config +}; device_t oti067_device = { diff --git a/src/video/vid_oti067.h b/src/video/vid_oak_oti.h similarity index 84% rename from src/video/vid_oti067.h rename to src/video/vid_oak_oti.h index b9ac2dfcb..4652e4436 100644 --- a/src/video/vid_oti067.h +++ b/src/video/vid_oak_oti.h @@ -1,7 +1,7 @@ /* Copyright holders: Sarah Walker, Tenshi see COPYING for more details */ -extern device_t oti037_device; +extern device_t oti037c_device; extern device_t oti067_device; extern device_t oti067_acer386_device; extern device_t oti077_device; diff --git a/src/video/vid_svga.c b/src/video/vid_svga.c index eab769419..0498137f6 100644 --- a/src/video/vid_svga.c +++ b/src/video/vid_svga.c @@ -298,11 +298,45 @@ uint8_t svga_in(uint16_t addr, void *p) return svga->gdcreg[svga->gdcaddr & 0xf]; case 0x3DA: svga->attrff = 0; + svga->attrff = 0; + + /* old diagnostic code if (svga->cgastat & 0x01) svga->cgastat &= ~0x30; else svga->cgastat ^= 0x30; return svga->cgastat; + */ + svga->cgastat &= ~0x30; + /* copy color diagnostic info from the overscan color register */ + switch (svga->attrregs[0x12] & 0x30) + { + case 0x00: /* P0 and P2 */ + if (svga->attrregs[0x11] & 0x01) + svga->cgastat |= 0x10; + if (svga->attrregs[0x11] & 0x04) + svga->cgastat |= 0x20; + break; + case 0x10: /* P4 and P5 */ + if (svga->attrregs[0x11] & 0x10) + svga->cgastat |= 0x10; + if (svga->attrregs[0x11] & 0x20) + svga->cgastat |= 0x20; + break; + case 0x20: /* P1 and P3 */ + if (svga->attrregs[0x11] & 0x02) + svga->cgastat |= 0x10; + if (svga->attrregs[0x11] & 0x08) + svga->cgastat |= 0x20; + break; + case 0x30: /* P6 and P7 */ + if (svga->attrregs[0x11] & 0x40) + svga->cgastat |= 0x10; + if (svga->attrregs[0x11] & 0x80) + svga->cgastat |= 0x20; + break; + } + return svga->cgastat; } return 0xFF; } @@ -508,7 +542,7 @@ void svga_poll(void *p) } if (svga->hwcursor_on || svga->overlay_on) - svga->changedvram[svga->ma >> 12] = svga->changedvram[(svga->ma >> 12) + 1] = svga->interlace ? 3 : 2;; + svga->changedvram[svga->ma >> 12] = svga->changedvram[(svga->ma >> 12) + 1] = svga->interlace ? 3 : 2; if (!svga->override) svga->render(svga); diff --git a/src/video/vid_table.c b/src/video/vid_table.c index d9d6caa5d..03097d185 100644 --- a/src/video/vid_table.c +++ b/src/video/vid_table.c @@ -51,7 +51,7 @@ # include "vid_nv_riva128.h" # endif #endif -#include "vid_oti067.h" +#include "vid_oak_oti.h" #include "vid_paradise.h" #include "vid_s3.h" #include "vid_s3_virge.h" @@ -104,6 +104,7 @@ video_cards[] = { { "[ISA] Hercules InColor", "incolor", &incolor_device, GFX_INCOLOR, {VIDEO_ISA, 8, 16, 32, 8, 16, 32}}, { "[ISA] MDA", "mda", &mda_device, GFX_MDA, {VIDEO_ISA, 8, 16, 32, 8, 16, 32}}, { "[ISA] MDSI Genius", "genius", &genius_device, GFX_GENIUS, {VIDEO_ISA, 8, 16, 32, 8, 16, 32}}, + {"[ISA] OAK OTI-037C", "oti037c", &oti037c_device, GFX_OTI037C, {VIDEO_ISA, 6, 8, 16, 6, 8, 16}}, {"[ISA] OAK OTI-067", "oti067", &oti067_device, GFX_OTI067, {VIDEO_ISA, 6, 8, 16, 6, 8, 16}}, {"[ISA] OAK OTI-077", "oti077", &oti077_device, GFX_OTI077, {VIDEO_ISA, 6, 8, 16, 6, 8, 16}}, {"[ISA] Paradise PVGA1A", "pvga1a", ¶dise_pvga1a_device, GFX_PVGA1A, {VIDEO_ISA, 8, 16, 32, 8, 16, 32}}, diff --git a/src/win/Makefile.mingw b/src/win/Makefile.mingw index a65308478..c34c422d4 100644 --- a/src/win/Makefile.mingw +++ b/src/win/Makefile.mingw @@ -498,7 +498,7 @@ VIDOBJ := video.o \ vid_cl54xx.o \ vid_et4000.o vid_sc1502x_ramdac.o \ vid_et4000w32.o vid_stg_ramdac.o \ - vid_oti067.o \ + vid_oak_oti.o \ vid_paradise.o \ vid_ti_cf62011.o \ vid_tvga.o \