Move components of video cards (external ramdacs and clock generators that could be paired with many cards) to their own folders. Reorganise video cmakelists

This commit is contained in:
starfrost013
2025-06-17 01:07:26 +01:00
parent 07b418d470
commit c826294a96
18 changed files with 80 additions and 30 deletions

View File

@@ -0,0 +1,110 @@
/*
* 86Box A hypervisor and IBM PC system emulator that specializes in
* running old operating systems and software designed for IBM
* PC systems and compatibles from 1981 through fairly recent
* system designs based on the PCI bus.
*
* This file is part of the 86Box distribution.
*
* AV9194 clock generator emulation.
*
* Used by the S3 86c801 (V7-Mirage) card.
*
*
*
* Authors: Miran Grca, <mgrca8@gmail.com>
*
* Copyright 2016-2018 Miran Grca.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.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>
float
av9194_getclock(int clock, UNUSED(void *priv))
{
float ret = 0.0;
switch (clock & 0x0f) {
case 0:
ret = 25175000.0;
break;
case 1:
ret = 28322000.0;
break;
case 2:
ret = 40000000.0;
break;
case 4:
ret = 50000000.0;
break;
case 5:
ret = 77000000.0;
break;
case 6:
ret = 36000000.0;
break;
case 7:
ret = 44900000.0;
break;
case 8:
ret = 130000000.0;
break;
case 9:
ret = 120000000.0;
break;
case 0xa:
ret = 80000000.0;
break;
case 0xb:
ret = 31500000.0;
break;
case 0xc:
ret = 110000000.0;
break;
case 0xd:
ret = 65000000.0;
break;
case 0xe:
ret = 75000000.0;
break;
case 0xf:
ret = 94500000.0;
break;
default:
break;
}
return ret;
}
static void *
av9194_init(UNUSED(const device_t *info))
{
/* Return something non-NULL. */
return (void *) &av9194_device;
}
const device_t av9194_device = {
.name = "AV9194 Clock Generator",
.internal_name = "av9194",
.flags = 0,
.local = 0,
.init = av9194_init,
.close = NULL,
.reset = NULL,
.available = NULL,
.speed_changed = NULL,
.force_redraw = NULL,
.config = NULL
};

View File

@@ -0,0 +1,200 @@
/*
* 86Box A hypervisor and IBM PC system emulator that specializes in
* running old operating systems and software designed for IBM
* PC systems and compatibles from 1981 through fairly recent
* system designs based on the PCI bus.
*
* This file is part of the 86Box distribution.
*
* ICD2061 clock generator emulation.
* Also emulates the ICS9161 which is the same as the ICD2016,
* but without the need for tuning (which is irrelevant in
* emulation anyway).
*
* Used by ET4000w32/p (Diamond Stealth 32) and the S3
* Vision964 family.
*
*
*
* Authors: Miran Grca, <mgrca8@gmail.com>
*
* Copyright 2016-2018 Miran Grca.
*/
#include <stdarg.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#define HAVE_STDARG_H
#include <86box/86box.h>
#include <86box/device.h>
#include <86box/plat_unused.h>
typedef struct icd2061_t {
float freq[3];
int count;
int bit_count;
int unlocked;
int state;
uint32_t data;
uint32_t ctrl;
} icd2061_t;
#ifdef ENABLE_ICD2061_LOG
int icd2061_do_log = ENABLE_ICD2061_LOG;
static void
icd2061_log(const char *fmt, ...)
{
va_list ap;
if (icd2061_do_log) {
va_start(ap, fmt);
pclog_ex(fmt, ap);
va_end(ap);
}
}
#else
# define icd2061_log(fmt, ...)
#endif
void
icd2061_write(void *priv, int val)
{
icd2061_t *icd2061 = (icd2061_t *) priv;
int nd;
int oc;
int nc;
int a;
int qa;
int q;
int pa;
int p_;
int m;
int ps;
nd = (val & 2) >> 1; /* Old data. */
oc = icd2061->state & 1; /* Old clock. */
nc = val & 1; /* New clock. */
icd2061->state = val;
if (nc && !oc) { /* Low-to-high transition of CLK. */
if (!icd2061->unlocked) {
if (nd) { /* DATA high. */
icd2061->count++;
icd2061_log("Low-to-high transition of CLK with DATA high, %i total\n", icd2061->count);
} else { /* DATA low. */
if (icd2061->count >= 5) {
icd2061->unlocked = 1;
icd2061->bit_count = icd2061->data = 0;
#ifdef ENABLE_ICD2061_LOG
icd2061_log("ICD2061 unlocked\n");
#endif
} else {
icd2061->count = 0;
#ifdef ENABLE_ICD2061_LOG
icd2061_log("ICD2061 locked\n");
#endif
}
}
} else if (nc) {
icd2061->data |= (nd << icd2061->bit_count);
icd2061->bit_count++;
if (icd2061->bit_count == 26) {
icd2061_log("26 bits received, data = %08X\n", icd2061->data);
a = ((icd2061->data >> 22) & 0x07); /* A */
icd2061_log("A = %01X\n", a);
if (a < 3) {
pa = ((icd2061->data >> 11) & 0x7f); /* P' (ICD2061) / N' (ICS9161) */
m = ((icd2061->data >> 8) & 0x07); /* M (ICD2061) / R (ICS9161) */
qa = ((icd2061->data >> 1) & 0x7f); /* Q' (ICD2061) / M' (ICS9161) */
p_ = pa + 3; /* P (ICD2061) / N (ICS9161) */
m = 1 << m;
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_log("P = %02X, M = %01X, Q = %02X, freq[%i] = %f\n", p_, m, q, a, icd2061->freq[a]);
} else if (a == 6) {
icd2061->ctrl = ((icd2061->data >> 13) & 0xff);
icd2061_log("ctrl = %02X\n", icd2061->ctrl);
}
icd2061->count = icd2061->bit_count = icd2061->data = 0;
icd2061->unlocked = 0;
#ifdef ENABLE_ICD2061_LOG
icd2061_log("ICD2061 locked\n");
#endif
}
}
}
}
float
icd2061_getclock(int clock, void *priv)
{
const icd2061_t *icd2061 = (icd2061_t *) priv;
if (clock > 2)
clock = 2;
return icd2061->freq[clock];
}
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->freq[0] = 25175000.0;
icd2061->freq[1] = 28322000.0;
icd2061->freq[2] = 28322000.0;
return icd2061;
}
static void
icd2061_close(void *priv)
{
icd2061_t *icd2061 = (icd2061_t *) priv;
if (icd2061)
free(icd2061);
}
const device_t icd2061_device = {
.name = "ICD2061 Clock Generator",
.internal_name = "icd2061",
.flags = 0,
.local = 0,
.init = icd2061_init,
.close = icd2061_close,
.reset = NULL,
.available = NULL,
.speed_changed = NULL,
.force_redraw = NULL,
.config = NULL
};
const device_t ics9161_device = {
.name = "ICS9161 Clock Generator",
.internal_name = "ics9161",
.flags = 0,
.local = 0,
.init = icd2061_init,
.close = icd2061_close,
.reset = NULL,
.available = NULL,
.speed_changed = NULL,
.force_redraw = NULL,
.config = NULL
};

View File

@@ -0,0 +1,217 @@
/*
* 86Box A hypervisor and IBM PC system emulator that specializes in
* running old operating systems and software designed for IBM
* PC systems and compatibles from 1981 through fairly recent
* system designs based on the PCI bus.
*
* This file is part of the 86Box distribution.
*
* ICS2494 clock generator emulation.
*
* Used by the AMI S3 924.
*
*
*
* Authors: Miran Grca, <mgrca8@gmail.com>
*
* Copyright 2020 Miran Grca.
*/
#include <stdarg.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#define HAVE_STDARG_H
#include <86box/86box.h>
#include <86box/device.h>
typedef struct ics2494_t {
float freq[16];
} ics2494_t;
#ifdef ENABLE_ICS2494_LOG
int ics2494_do_log = ENABLE_ICS2494_LOG;
static void
ics2494_log(const char *fmt, ...)
{
va_list ap;
if (ics2494_do_log) {
va_start(ap, fmt);
pclog_ex(fmt, ap);
va_end(ap);
}
}
#else
# define ics2494_log(fmt, ...)
#endif
float
ics2494_getclock(int clock, void *priv)
{
const ics2494_t *ics2494 = (ics2494_t *) priv;
if (clock > 15)
clock = 15;
ics2494_log("Clock=%d, freq=%f.\n", clock, ics2494->freq[clock]);
return ics2494->freq[clock];
}
static void *
ics2494_init(const device_t *info)
{
ics2494_t *ics2494 = (ics2494_t *) malloc(sizeof(ics2494_t));
memset(ics2494, 0, sizeof(ics2494_t));
switch (info->local) {
case 10:
/* ATI 18810 for ATI 28800 */
ics2494->freq[0x0] = 42954000.0;
ics2494->freq[0x1] = 48771000.0;
ics2494->freq[0x2] = 0.0;
ics2494->freq[0x3] = 36000000.0;
ics2494->freq[0x4] = 50350000.0;
ics2494->freq[0x5] = 56640000.0;
ics2494->freq[0x6] = 0.0;
ics2494->freq[0x7] = 44900000.0;
ics2494->freq[0x8] = 30240000.0;
ics2494->freq[0x9] = 32000000.0;
ics2494->freq[0xa] = 37500000.0;
ics2494->freq[0xb] = 39000000.0;
ics2494->freq[0xc] = 40000000.0;
ics2494->freq[0xd] = 56644000.0;
ics2494->freq[0xe] = 75000000.0;
ics2494->freq[0xf] = 65000000.0;
break;
case 110:
/* ATI 18811-0 for ATI Mach32 */
ics2494->freq[0x0] = 42954000.0;
ics2494->freq[0x1] = 48771000.0;
ics2494->freq[0x2] = 92400000.0;
ics2494->freq[0x3] = 36000000.0;
ics2494->freq[0x4] = 50350000.0;
ics2494->freq[0x5] = 56640000.0;
ics2494->freq[0x6] = 0.0;
ics2494->freq[0x7] = 44900000.0;
ics2494->freq[0x8] = 30240000.0;
ics2494->freq[0x9] = 32000000.0;
ics2494->freq[0xa] = 110000000.0;
ics2494->freq[0xb] = 80000000.0;
ics2494->freq[0xc] = 39910000.0;
ics2494->freq[0xd] = 44900000.0;
ics2494->freq[0xe] = 75000000.0;
ics2494->freq[0xf] = 65000000.0;
break;
case 111:
/* ATI 18811-1 for ATI Mach32 MCA */
ics2494->freq[0x0] = 100000000.0;
ics2494->freq[0x1] = 126000000.0;
ics2494->freq[0x2] = 92400000.0;
ics2494->freq[0x3] = 36000000.0;
ics2494->freq[0x4] = 50350000.0;
ics2494->freq[0x5] = 56640000.0;
ics2494->freq[0x6] = 0.0;
ics2494->freq[0x7] = 44900000.0;
ics2494->freq[0x8] = 135000000.0;
ics2494->freq[0x9] = 32000000.0;
ics2494->freq[0xa] = 110000000.0;
ics2494->freq[0xb] = 80000000.0;
ics2494->freq[0xc] = 39910000.0;
ics2494->freq[0xd] = 44900000.0;
ics2494->freq[0xe] = 75000000.0;
ics2494->freq[0xf] = 65000000.0;
break;
case 305:
/* ICS2494A(N)-205 for S3 86C924 */
ics2494->freq[0x0] = 25175000.0;
ics2494->freq[0x1] = 28322000.0;
ics2494->freq[0x2] = 40000000.0;
ics2494->freq[0x3] = 0.0;
ics2494->freq[0x4] = 50000000.0;
ics2494->freq[0x5] = 77000000.0;
ics2494->freq[0x6] = 36000000.0;
ics2494->freq[0x7] = 44889000.0;
ics2494->freq[0x8] = 130000000.0;
ics2494->freq[0x9] = 120000000.0;
ics2494->freq[0xa] = 80000000.0;
ics2494->freq[0xb] = 31500000.0;
ics2494->freq[0xc] = 110000000.0;
ics2494->freq[0xd] = 65000000.0;
ics2494->freq[0xe] = 75000000.0;
ics2494->freq[0xf] = 94500000.0;
break;
default:
break;
}
return ics2494;
}
static void
ics2494_close(void *priv)
{
ics2494_t *ics2494 = (ics2494_t *) priv;
if (ics2494)
free(ics2494);
}
const device_t ics2494an_305_device = {
.name = "ICS2494AN-305 Clock Generator",
.internal_name = "ics2494an_305",
.flags = 0,
.local = 305,
.init = ics2494_init,
.close = ics2494_close,
.reset = NULL,
.available = NULL,
.speed_changed = NULL,
.force_redraw = NULL,
.config = NULL
};
const device_t ati18810_device = {
.name = "ATI 18810 Clock Generator",
.internal_name = "ati18810",
.flags = 0,
.local = 10,
.init = ics2494_init,
.close = ics2494_close,
.reset = NULL,
.available = NULL,
.speed_changed = NULL,
.force_redraw = NULL,
.config = NULL
};
const device_t ati18811_0_device = {
.name = "ATI 18811-0 Clock Generator",
.internal_name = "ati18811_0",
.flags = 0,
.local = 110,
.init = ics2494_init,
.close = ics2494_close,
.reset = NULL,
.available = NULL,
.speed_changed = NULL,
.force_redraw = NULL,
.config = NULL
};
const device_t ati18811_1_device = {
.name = "ATI 18811-1 Clock Generator",
.internal_name = "ati18811_1",
.flags = 0,
.local = 111,
.init = ics2494_init,
.close = ics2494_close,
.reset = NULL,
.available = NULL,
.speed_changed = NULL,
.force_redraw = NULL,
.config = NULL
};

View File

@@ -0,0 +1,136 @@
/*
* 86Box A hypervisor and IBM PC system emulator that specializes in
* running old operating systems and software designed for IBM
* PC systems and compatibles from 1981 through fairly recent
* system designs based on the PCI bus.
*
* This file is part of the 86Box distribution.
*
* ICS2595 clock chip emulation. Used by ATI Mach64.
*
*
*
* Authors: Sarah Walker, <https://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
*
* Copyright 2008-2018 Sarah Walker.
* Copyright 2016-2018 Miran Grca.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include <86box/86box.h>
#include <86box/device.h>
#include <86box/plat_unused.h>
typedef struct ics2595_t {
int oldfs3;
int oldfs2;
int dat;
int pos;
int state;
double clocks[16];
double output_clock;
} ics2595_t;
enum {
ICS2595_IDLE = 0,
ICS2595_WRITE,
ICS2595_READ
};
static int ics2595_div[4] = { 8, 4, 2, 1 };
void
ics2595_write(void *priv, int strobe, int dat)
{
ics2595_t *ics2595 = (ics2595_t *) priv;
int d;
int n;
int l;
if (strobe) {
if ((dat & 8) && !ics2595->oldfs3) { /*Data clock*/
switch (ics2595->state) {
case ICS2595_IDLE:
ics2595->state = (dat & 4) ? ICS2595_WRITE : ICS2595_IDLE;
ics2595->pos = 0;
break;
case ICS2595_WRITE:
ics2595->dat = (ics2595->dat >> 1);
if (dat & 4)
ics2595->dat |= (1 << 19);
ics2595->pos++;
if (ics2595->pos == 20) {
l = (ics2595->dat >> 2) & 0xf;
n = ((ics2595->dat >> 7) & 255) + 257;
d = ics2595_div[(ics2595->dat >> 16) & 3];
ics2595->clocks[l] = (14318181.8 * ((double) n / 46.0)) / (double) d;
ics2595->state = ICS2595_IDLE;
}
break;
default:
break;
}
}
ics2595->oldfs2 = dat & 4;
ics2595->oldfs3 = dat & 8;
}
ics2595->output_clock = ics2595->clocks[dat];
}
static void *
ics2595_init(UNUSED(const device_t *info))
{
ics2595_t *ics2595 = (ics2595_t *) malloc(sizeof(ics2595_t));
memset(ics2595, 0, sizeof(ics2595_t));
return ics2595;
}
static void
ics2595_close(void *priv)
{
ics2595_t *ics2595 = (ics2595_t *) priv;
if (ics2595)
free(ics2595);
}
double
ics2595_getclock(void *priv)
{
const ics2595_t *ics2595 = (ics2595_t *) priv;
return ics2595->output_clock;
}
void
ics2595_setclock(void *priv, double clock)
{
ics2595_t *ics2595 = (ics2595_t *) priv;
ics2595->output_clock = clock;
}
const device_t ics2595_device = {
.name = "ICS2595 clock chip",
.internal_name = "ics2595",
.flags = 0,
.local = 0,
.init = ics2595_init,
.close = ics2595_close,
.reset = NULL,
.available = NULL,
.speed_changed = NULL,
.force_redraw = NULL,
.config = NULL
};