Merge pull request #6130 from 86Box/tc1995

Major video changes and fixes of the day (September 7th, 2025)
This commit is contained in:
Miran Grča
2025-09-07 01:04:10 +02:00
committed by GitHub
6 changed files with 757 additions and 192 deletions

View File

@@ -449,6 +449,7 @@ extern void ibm_rgb528_ramdac_set_ref_clock(void *priv, svga_t *svga, float r
extern void icd2061_write(void *priv, int val);
extern float icd2061_getclock(int clock, void *priv);
extern void icd2061_set_ref_clock(void *priv, svga_t *svga, float ref_clock);
/* The code is the same, the #define's are so that the correct name can be used. */
# define ics9161_write icd2061_write
@@ -465,6 +466,8 @@ extern uint8_t sc1148x_ramdac_in(uint16_t addr, int rs2, void *priv, svga_t *svg
extern void sc1502x_ramdac_out(uint16_t addr, uint8_t val, void *priv, svga_t *svga);
extern uint8_t sc1502x_ramdac_in(uint16_t addr, void *priv, svga_t *svga);
extern void sc1502x_rs2_ramdac_out(uint16_t addr, int rs2, uint8_t val, void *priv, svga_t *svga);
extern uint8_t sc1502x_rs2_ramdac_in(uint16_t addr, int rs2, void *priv, svga_t *svga);
extern void sdac_ramdac_out(uint16_t addr, int rs2, uint8_t val, void *priv, svga_t *svga);
extern uint8_t sdac_ramdac_in(uint16_t addr, int rs2, void *priv, svga_t *svga);
@@ -516,6 +519,7 @@ extern const device_t sc11487_ramdac_device;
extern const device_t sc11486_ramdac_device;
extern const device_t sc11484_nors2_ramdac_device;
extern const device_t sc1502x_ramdac_device;
extern const device_t sc1502x_rs2_ramdac_device;
extern const device_t sdac_ramdac_device;
extern const device_t stg_ramdac_device;
extern const device_t tkd8001_ramdac_device;

View File

@@ -412,7 +412,7 @@ extern const device_t cga_pravetz_device;
/* Compaq CGA */
extern const device_t compaq_cga_device;
extern const device_t compaq_cga_2_device;
extern const device_t compaq_plasma_device;
extern const device_t compaq_plasma_device;
/* Olivetti OGC */
extern const device_t ogc_device;
@@ -513,8 +513,11 @@ extern const device_t realtek_rtg3106_device;
extern const device_t s3_orchid_86c911_isa_device;
extern const device_t s3_diamond_stealth_vram_isa_device;
extern const device_t s3_ami_86c924_isa_device;
extern const device_t s3_elsa_winner1000_86c928_vlb_device;
extern const device_t s3_elsa_winner2000_86c928_isa_device;
extern const device_t s3_metheus_86c928_isa_device;
extern const device_t s3_metheus_86c928_vlb_device;
extern const device_t s3_elsa_winner1000_86c928_pci_device;
extern const device_t s3_spea_mercury_lite_86c928_pci_device;
extern const device_t s3_spea_mirage_86c801_isa_device;
extern const device_t s3_winner1000_805_isa_device;
@@ -635,9 +638,9 @@ extern const device_t wy700_device;
extern const device_t v6355d_device;
/* Tandy */
extern const device_t tandy_1000_video_device;
extern const device_t tandy_1000hx_video_device;
extern const device_t tandy_1000sl_video_device;
extern const device_t tandy_1000_video_device;
extern const device_t tandy_1000hx_video_device;
extern const device_t tandy_1000sl_video_device;
#endif

View File

@@ -29,10 +29,15 @@
#define HAVE_STDARG_H
#include <86box/86box.h>
#include <86box/device.h>
#include <86box/mem.h>
#include <86box/timer.h>
#include <86box/video.h>
#include <86box/vid_svga.h>
#include <86box/plat_unused.h>
typedef struct icd2061_t {
float freq[3];
float freq[3];
float ref_clock;
int count;
int bit_count;
@@ -121,7 +126,7 @@ icd2061_write(void *priv, int val)
q = qa + 2; /* Q (ICD2061) / M (ICS9161) */
ps = (icd2061->ctrl & (1 << a)) ? 4 : 2; /* Prescale */
icd2061->freq[a] = ((float) (p_ * ps) / (float) (q * m)) * 14318184.0f;
icd2061->freq[a] = ((float) (p_ * ps) / (float) (q * m)) * icd2061->ref_clock;
icd2061_log("P = %02X, M = %01X, Q = %02X, freq[%i] = %f\n", p_, m, q, a, icd2061->freq[a]);
} else if (a == 6) {
@@ -149,12 +154,24 @@ icd2061_getclock(int clock, void *priv)
return icd2061->freq[clock];
}
void
icd2061_set_ref_clock(void *priv, svga_t *svga, float ref_clock)
{
icd2061_t *icd2061 = (icd2061_t *) priv;
if (icd2061)
icd2061->ref_clock = ref_clock;
svga_recalctimings(svga);
}
static void *
icd2061_init(UNUSED(const device_t *info))
{
icd2061_t *icd2061 = (icd2061_t *) malloc(sizeof(icd2061_t));
memset(icd2061, 0, sizeof(icd2061_t));
icd2061->ref_clock = 14318184.0f;
icd2061->freq[0] = 25175000.0;
icd2061->freq[1] = 28322000.0;
icd2061->freq[2] = 28322000.0;

View File

@@ -33,65 +33,32 @@
typedef struct sc1502x_ramdac_t {
int state;
int use_rs2;
uint8_t ctrl;
uint8_t idx;
uint8_t regs[256];
uint32_t pixel_mask;
uint8_t enable_ext;
} sc1502x_ramdac_t;
static void
sc1502x_ramdac_bpp(uint8_t val, sc1502x_ramdac_t *ramdac, svga_t *svga)
sc1502x_ramdac_bpp(sc1502x_ramdac_t *ramdac, svga_t *svga)
{
int oldbpp = 0;
if (val == 0xff)
return;
ramdac->ctrl = val;
oldbpp = svga->bpp;
switch ((val & 1) | ((val & 0xc0) >> 5)) {
case 0:
svga->bpp = 8;
break;
case 2:
case 3:
switch (val & 0x20) {
case 0x00:
svga->bpp = 32;
break;
case 0x20:
svga->bpp = 24;
break;
default:
break;
}
break;
case 4:
case 5:
svga->bpp = 15;
break;
case 6:
int oldbpp = svga->bpp;
if (ramdac->ctrl & 0x80) {
if (ramdac->ctrl & 0x40) {
svga->bpp = 16;
break;
case 7:
if (val & 4) {
switch (val & 0x20) {
case 0x00:
svga->bpp = 32;
break;
case 0x20:
svga->bpp = 24;
break;
default:
break;
}
} else
svga->bpp = 16;
break;
default:
break;
} else
svga->bpp = 15;
} else {
if (ramdac->ctrl & 0x40) {
if (ramdac->regs[0x10] & 0x01)
svga->bpp = 32;
else if (ramdac->ctrl & 0x20)
svga->bpp = 24;
else
svga->bpp = 32;
} else
svga->bpp = 8;
}
if (oldbpp != svga->bpp)
svga_recalctimings(svga);
@@ -104,29 +71,30 @@ sc1502x_ramdac_out(uint16_t addr, uint8_t val, void *priv, svga_t *svga)
switch (addr) {
case 0x3C6:
if (ramdac->state == 0)
ramdac->enable_ext = (val == 0x10);
if (ramdac->state == 4) {
if ((ramdac->state == 4) || (ramdac->ctrl & 0x10)) {
ramdac->state = 0;
sc1502x_ramdac_bpp(val, ramdac, svga);
ramdac->ctrl = val;
if (val != 0xff)
sc1502x_ramdac_bpp(ramdac, svga);
return;
}
ramdac->state = 0;
svga_out(addr, val, svga);
break;
case 0x3C7:
if (ramdac->enable_ext) {
if (ramdac->ctrl & 0x10)
ramdac->idx = val;
return;
}
else
svga_out(addr, val, svga);
ramdac->state = 0;
break;
case 0x3C8:
if (ramdac->enable_ext) {
if (ramdac->ctrl & 0x10) {
switch (ramdac->idx) {
case 8:
ramdac->regs[ramdac->idx] = val;
svga_set_ramdac_type(svga, (ramdac->regs[ramdac->idx] & 1) ? RAMDAC_8BIT : RAMDAC_6BIT);
ramdac->regs[8] = val;
svga->ramdac_type = (val & 0x01) ? RAMDAC_8BIT : RAMDAC_6BIT;
break;
case 0x0d:
ramdac->pixel_mask = val & svga->dac_mask;
@@ -137,24 +105,96 @@ sc1502x_ramdac_out(uint16_t addr, uint8_t val, void *priv, svga_t *svga)
case 0x0f:
ramdac->pixel_mask |= ((val & svga->dac_mask) << 16);
break;
case 0x10:
ramdac->regs[0x10] = val;
sc1502x_ramdac_bpp(ramdac, svga);
break;
default:
ramdac->regs[ramdac->idx] = val;
break;
}
return;
}
} else
svga_out(addr, val, svga);
ramdac->state = 0;
break;
case 0x3C9:
if (ramdac->enable_ext)
return;
ramdac->state = 0;
svga_out(addr, val, svga);
break;
default:
break;
}
svga_out(addr, val, svga);
}
void
sc1502x_rs2_ramdac_out(uint16_t addr, int rs2, uint8_t val, void *priv, svga_t *svga)
{
sc1502x_ramdac_t *ramdac = (sc1502x_ramdac_t *) priv;
uint8_t rs = (addr & 0x03);
rs |= ((!!rs2) << 2);
switch (rs) {
case 0x00:
if (ramdac->ctrl & 0x10) {
switch (ramdac->idx) {
case 8:
ramdac->regs[8] = val;
svga->ramdac_type = (val & 0x01) ? RAMDAC_8BIT : RAMDAC_6BIT;
break;
case 0x0d:
ramdac->pixel_mask = val & svga->dac_mask;
break;
case 0x0e:
ramdac->pixel_mask |= ((val & svga->dac_mask) << 8);
break;
case 0x0f:
ramdac->pixel_mask |= ((val & svga->dac_mask) << 16);
break;
case 0x10:
ramdac->regs[0x10] = val;
sc1502x_ramdac_bpp(ramdac, svga);
break;
default:
ramdac->regs[ramdac->idx] = val;
break;
}
} else
svga_out(addr, val, svga);
break;
case 0x01:
svga_out(addr, val, svga);
break;
case 0x02:
if (ramdac->ctrl & 0x10) {
ramdac->ctrl = val;
if (val != 0xff)
sc1502x_ramdac_bpp(ramdac, svga);
} else
svga_out(addr, val, svga);
break;
case 0x03:
if (ramdac->ctrl & 0x10)
ramdac->idx = val;
else
svga_out(addr, val, svga);
break;
case 0x04:
case 0x05:
case 0x07:
svga_out(addr, val, svga);
break;
case 0x06:
ramdac->ctrl = val;
if (val != 0xff)
sc1502x_ramdac_bpp(ramdac, svga);
break;
default:
svga_out(addr, val, svga);
break;
}
}
uint8_t
@@ -166,8 +206,7 @@ sc1502x_ramdac_in(uint16_t addr, void *priv, svga_t *svga)
switch (addr) {
case 0x3C6:
if (ramdac->state == 4) {
ramdac->state = 0;
temp = ramdac->ctrl;
temp = ramdac->ctrl;
break;
}
ramdac->state++;
@@ -176,7 +215,7 @@ sc1502x_ramdac_in(uint16_t addr, void *priv, svga_t *svga)
ramdac->state = 0;
break;
case 0x3C8:
if (ramdac->enable_ext) {
if (ramdac->ctrl & 0x10) {
switch (ramdac->idx) {
case 9:
temp = 0x53;
@@ -203,14 +242,72 @@ sc1502x_ramdac_in(uint16_t addr, void *priv, svga_t *svga)
temp = ramdac->regs[ramdac->idx];
break;
}
} else
ramdac->state = 0;
}
ramdac->state = 0;
break;
case 0x3C9:
if (ramdac->enable_ext)
if (ramdac->ctrl & 0x10)
temp = ramdac->idx;
else
ramdac->state = 0;
ramdac->state = 0;
break;
default:
break;
}
return temp;
}
uint8_t
sc1502x_rs2_ramdac_in(uint16_t addr, int rs2, void *priv, svga_t *svga)
{
sc1502x_ramdac_t *ramdac = (sc1502x_ramdac_t *) priv;
uint8_t rs = (addr & 0x03);
uint8_t temp = svga_in(addr, svga);
rs |= ((!!rs2) << 2);
switch (rs) {
case 0x00:
if (ramdac->ctrl & 0x10) {
switch (ramdac->idx) {
case 9:
temp = 0x53;
break;
case 0x0a:
temp = 0x3a;
break;
case 0x0b:
temp = 0xb1;
break;
case 0x0c:
temp = 0x41;
break;
case 0x0d:
temp = ramdac->pixel_mask & 0xff;
break;
case 0x0e:
temp = ramdac->pixel_mask >> 8;
break;
case 0x0f:
temp = ramdac->pixel_mask >> 16;
break;
default:
temp = ramdac->regs[ramdac->idx];
break;
}
}
break;
case 0x01:
if (ramdac->ctrl & 0x10)
temp = ramdac->idx;
break;
case 0x02:
if (ramdac->ctrl & 0x10)
temp = ramdac->ctrl;
break;
case 0x06:
temp = ramdac->ctrl;
break;
default:
@@ -221,7 +318,7 @@ sc1502x_ramdac_in(uint16_t addr, void *priv, svga_t *svga)
}
static void *
sc1502x_ramdac_init(UNUSED(const device_t *info))
sc1502x_ramdac_init(const device_t *info)
{
sc1502x_ramdac_t *ramdac = (sc1502x_ramdac_t *) malloc(sizeof(sc1502x_ramdac_t));
memset(ramdac, 0, sizeof(sc1502x_ramdac_t));
@@ -254,3 +351,17 @@ const device_t sc1502x_ramdac_device = {
.force_redraw = NULL,
.config = NULL
};
const device_t sc1502x_rs2_ramdac_device = {
.name = "Sierra SC1502x RAMDAC with RS2",
.internal_name = "sc1502x_rs2_ramdac",
.flags = 0,
.local = 1,
.init = sc1502x_ramdac_init,
.close = sc1502x_ramdac_close,
.reset = NULL,
.available = NULL,
.speed_changed = NULL,
.force_redraw = NULL,
.config = NULL
};

File diff suppressed because it is too large Load Diff

View File

@@ -91,7 +91,6 @@ video_cards[] = {
{ .device = &nga_device, .flags = VIDEO_FLAG_TYPE_NONE },
{ .device = &nec_sv9000_device, .flags = VIDEO_FLAG_TYPE_NONE },
{ .device = &ogc_device, .flags = VIDEO_FLAG_TYPE_NONE },
{ .device = &jvga_device, .flags = VIDEO_FLAG_TYPE_NONE },
{ .device = &oti037c_device, .flags = VIDEO_FLAG_TYPE_NONE },
{ .device = &oti067_device, .flags = VIDEO_FLAG_TYPE_NONE },
{ .device = &oti077_device, .flags = VIDEO_FLAG_TYPE_NONE },
@@ -127,10 +126,12 @@ video_cards[] = {
{ .device = &gd5434_isa_device, .flags = VIDEO_FLAG_TYPE_NONE },
{ .device = &gd5434_diamond_speedstar_64_a3_isa_device, .flags = VIDEO_FLAG_TYPE_NONE },
{ .device = &inmos_isa_device, .flags = VIDEO_FLAG_TYPE_XGA },
{ .device = &jvga_device, .flags = VIDEO_FLAG_TYPE_NONE },
{ .device = &radius_svga_multiview_isa_device, .flags = VIDEO_FLAG_TYPE_NONE },
{ .device = &s3_diamond_stealth_vram_isa_device, .flags = VIDEO_FLAG_TYPE_NONE },
{ .device = &s3_orchid_86c911_isa_device, .flags = VIDEO_FLAG_TYPE_NONE },
{ .device = &s3_ami_86c924_isa_device, .flags = VIDEO_FLAG_TYPE_NONE },
{ .device = &s3_elsa_winner2000_86c928_isa_device, .flags = VIDEO_FLAG_TYPE_NONE },
{ .device = &s3_metheus_86c928_isa_device, .flags = VIDEO_FLAG_TYPE_NONE },
{ .device = &s3_phoenix_86c801_isa_device, .flags = VIDEO_FLAG_TYPE_NONE },
{ .device = &s3_spea_mirage_86c801_isa_device, .flags = VIDEO_FLAG_TYPE_NONE },
@@ -160,6 +161,7 @@ video_cards[] = {
{ .device = &gd5430_diamond_speedstar_pro_se_a8_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE },
{ .device = &gd5430_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE },
{ .device = &gd5434_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE },
{ .device = &s3_elsa_winner1000_86c928_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE },
{ .device = &s3_metheus_86c928_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE },
{ .device = &s3_mirocrystal_8s_805_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE },
{ .device = &s3_mirocrystal_10sd_805_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE },
@@ -199,6 +201,7 @@ video_cards[] = {
{ .device = &et4000w32p_cardex_pci_device, .flags = VIDEO_FLAG_TYPE_NONE },
{ .device = &et4000w32p_noncardex_pci_device, .flags = VIDEO_FLAG_TYPE_NONE },
{ .device = &et4000w32p_pci_device, .flags = VIDEO_FLAG_TYPE_NONE },
{ .device = &s3_elsa_winner1000_86c928_pci_device, .flags = VIDEO_FLAG_TYPE_NONE },
{ .device = &s3_spea_mercury_lite_86c928_pci_device, .flags = VIDEO_FLAG_TYPE_NONE },
{ .device = &s3_diamond_stealth64_964_pci_device, .flags = VIDEO_FLAG_TYPE_NONE },
{ .device = &s3_elsa_winner2000_pro_x_964_pci_device, .flags = VIDEO_FLAG_TYPE_NONE },