Add LPT device emulation framework.

Move long-broken DAC and Sound Source emulation to new framework.
Add stereo DAC emulation.
This commit is contained in:
SarahW 2017-09-01 11:34:20 +01:00
commit d3232adef5
25 changed files with 785 additions and 334 deletions

View file

@ -1,8 +1,65 @@
#include "ibm.h"
#include "dac.h"
#include "io.h"
#include "lpt.h"
#include "lpt_dac.h"
#include "lpt_dss.h"
char lpt1_device_name[16];
static struct
{
char name[64];
char internal_name[16];
lpt_device_t *device;
} lpt_devices[] =
{
{"None", "none", NULL},
{"Disney Sound Source", "dss", &dss_device},
{"LPT DAC / Covox Speech Thing", "lpt_dac", &lpt_dac_device},
{"Stereo LPT DAC", "lpt_dac_stereo", &lpt_dac_stereo_device},
{"", "", NULL}
};
char *lpt_device_get_name(int id)
{
if (strlen(lpt_devices[id].name) == 0)
return NULL;
return lpt_devices[id].name;
}
char *lpt_device_get_internal_name(int id)
{
if (strlen(lpt_devices[id].internal_name) == 0)
return NULL;
return lpt_devices[id].internal_name;
}
static lpt_device_t *lpt1_device;
static void *lpt1_device_p;
void lpt1_device_init()
{
int c = 0;
while (strcmp(lpt_devices[c].internal_name, lpt1_device_name) && strlen(lpt_devices[c].internal_name) != 0)
c++;
if (strlen(lpt_devices[c].internal_name) == 0)
lpt1_device = NULL;
else
{
lpt1_device = lpt_devices[c].device;
if (lpt1_device)
lpt1_device_p = lpt1_device->init();
}
}
void lpt1_device_close()
{
if (lpt1_device)
lpt1_device->close(lpt1_device_p);
lpt1_device = NULL;
}
static uint8_t lpt1_dat, lpt2_dat;
static uint8_t lpt1_ctrl, lpt2_ctrl;
@ -12,11 +69,13 @@ void lpt1_write(uint16_t port, uint8_t val, void *priv)
switch (port & 3)
{
case 0:
writedac(0,val);
if (lpt1_device)
lpt1_device->write_data(val, lpt1_device_p);
lpt1_dat = val;
break;
case 2:
writedacctrl(0,val);
if (lpt1_device)
lpt1_device->write_ctrl(val, lpt1_device_p);
lpt1_ctrl = val;
break;
}
@ -28,7 +87,9 @@ uint8_t lpt1_read(uint16_t port, void *priv)
case 0:
return lpt1_dat;
case 1:
return readdacfifo();
if (lpt1_device)
return lpt1_device->read_status(lpt1_device_p);
return 0;
case 2:
return lpt1_ctrl;
}
@ -40,11 +101,9 @@ void lpt2_write(uint16_t port, uint8_t val, void *priv)
switch (port & 3)
{
case 0:
writedac(0,val);
lpt2_dat = val;
break;
case 2:
writedacctrl(0,val);
lpt2_ctrl = val;
break;
}
@ -56,7 +115,7 @@ uint8_t lpt2_read(uint16_t port, void *priv)
case 0:
return lpt2_dat;
case 1:
return readdacfifo();
return 0;
case 2:
return lpt2_ctrl;
}