Some changes in preparation for the not yet committable PAS16 changes.
This commit is contained in:
@@ -422,4 +422,31 @@ low_fir_sb16(int c, int i, double NewSample)
|
||||
return out;
|
||||
}
|
||||
|
||||
extern double low_fir_pas16_coef[4][SB16_NCoef];
|
||||
|
||||
static inline double
|
||||
low_fir_pas16(int c, int i, double NewSample)
|
||||
{
|
||||
static double x[4][2][SB16_NCoef + 1]; // input samples
|
||||
static int pos[4] = { 0, 0, 0, 0 };
|
||||
double out = 0.0;
|
||||
int n;
|
||||
|
||||
/* Calculate the new output */
|
||||
x[c][i][pos[c]] = NewSample;
|
||||
|
||||
for (n = 0; n < ((SB16_NCoef + 1) - pos[c]) && n < SB16_NCoef; n++)
|
||||
out += low_fir_pas16_coef[c][n] * x[c][i][n + pos[c]];
|
||||
for (; n < SB16_NCoef; n++)
|
||||
out += low_fir_pas16_coef[c][n] * x[c][i][(n + pos[c]) - (SB16_NCoef + 1)];
|
||||
|
||||
if (i == 1) {
|
||||
pos[c]++;
|
||||
if (pos[c] > SB16_NCoef)
|
||||
pos[c] = 0;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
#endif /*EMU_FILTERS_H*/
|
||||
|
@@ -113,6 +113,7 @@ extern double AGPCLK;
|
||||
|
||||
extern uint64_t PITCONST;
|
||||
extern uint64_t PAS16CONST;
|
||||
extern uint64_t PAS16CONST2;
|
||||
extern uint64_t ISACONST;
|
||||
extern uint64_t CGACONST;
|
||||
extern uint64_t MDACONST;
|
||||
@@ -123,13 +124,19 @@ extern uint64_t RTCCONST;
|
||||
|
||||
extern int refresh_at_enable;
|
||||
|
||||
extern void pit_change_pas16_const(double prescale);
|
||||
extern void pit_device_reset(pit_t *dev);
|
||||
|
||||
extern void pit_change_pas16_consts(double prescale);
|
||||
|
||||
extern void pit_set_pit_const(void *data, uint64_t pit_const);
|
||||
|
||||
extern void ctr_clock(void *data, int counter_id);
|
||||
|
||||
/* Sets a counter's CLOCK input. */
|
||||
extern void pit_ctr_set_clock(ctr_t *ctr, int clock, void *priv);
|
||||
|
||||
extern void pit_ctr_set_gate(void *data, int counter_id, int gate);
|
||||
|
||||
extern void pit_ctr_set_out_func(void *data, int counter_id, void (*func)(int new_out, int old_out, void *priv));
|
||||
|
||||
extern void pit_ctr_set_using_timer(void *data, int counter_id, int using_timer);
|
||||
|
@@ -71,10 +71,22 @@ typedef struct pitf_t {
|
||||
ctrf_t counters[3];
|
||||
|
||||
uint8_t ctrl;
|
||||
|
||||
void *dev_priv;
|
||||
} pitf_t;
|
||||
|
||||
extern void pitf_set_pit_const(void *data, uint64_t pit_const);
|
||||
|
||||
extern void pitf_handler(int set, uint16_t base, int size, void *priv);
|
||||
|
||||
extern void pitf_ctr_set_out_func(void *data, int counter_id, void (*func)(int new_out, int old_out, void *priv));
|
||||
|
||||
extern void pitf_ctr_set_using_timer(void *data, int counter_id, int using_timer);
|
||||
|
||||
extern void pitf_ctr_set_gate(void *data, int counter_id, int gate);
|
||||
|
||||
extern void pitf_ctr_clock(void *data, int counter_id);
|
||||
|
||||
extern uint8_t pitf_read_reg(void *priv, uint8_t reg);
|
||||
|
||||
extern const pit_intf_t pit_fast_intf;
|
||||
|
@@ -124,6 +124,7 @@ extern const device_t cms_device;
|
||||
extern const device_t gus_device;
|
||||
|
||||
/* Pro Audio Spectrum 16 */
|
||||
extern const device_t pasplus_device;
|
||||
extern const device_t pas16_device;
|
||||
|
||||
/* IBM PS/1 Audio Card */
|
||||
|
53
src/pit.c
53
src/pit.c
@@ -48,6 +48,7 @@ pit_intf_t pit_devs[2];
|
||||
double cpuclock;
|
||||
double PITCONSTD;
|
||||
double PAS16CONSTD;
|
||||
double PAS16CONST2D;
|
||||
double SYSCLK;
|
||||
double isa_timing;
|
||||
double bus_timing;
|
||||
@@ -58,6 +59,7 @@ double AGPCLK;
|
||||
|
||||
uint64_t PITCONST;
|
||||
uint64_t PAS16CONST;
|
||||
uint64_t PAS16CONST2;
|
||||
uint64_t ISACONST;
|
||||
uint64_t CGACONST;
|
||||
uint64_t MDACONST;
|
||||
@@ -309,7 +311,7 @@ ctr_tick(ctr_t *ctr, void *priv)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
ctr_clock(void *data, int counter_id)
|
||||
{
|
||||
pit_t *pit = (pit_t *) data;
|
||||
@@ -535,8 +537,9 @@ pit_write(uint16_t addr, uint8_t val, void *priv)
|
||||
int t = (addr & 3);
|
||||
ctr_t *ctr;
|
||||
|
||||
if ((dev->flags & (PIT_8254 | PIT_EXT_IO)))
|
||||
if ((dev->flags & (PIT_8254 | PIT_EXT_IO))) {
|
||||
pit_log("[%04X:%08X] pit_write(%04X, %02X, %08X)\n", CS, cpu_state.pc, addr, val, priv);
|
||||
}
|
||||
|
||||
switch (addr & 3) {
|
||||
case 3: /* control */
|
||||
@@ -552,8 +555,9 @@ pit_write(uint16_t addr, uint8_t val, void *priv)
|
||||
ctr_latch_count(&dev->counters[1]);
|
||||
if (val & 8)
|
||||
ctr_latch_count(&dev->counters[2]);
|
||||
if ((dev->flags & (PIT_8254 | PIT_EXT_IO)))
|
||||
if ((dev->flags & (PIT_8254 | PIT_EXT_IO))) {
|
||||
pit_log("PIT %i: Initiated readback command\n", t);
|
||||
}
|
||||
}
|
||||
if (!(val & 0x10)) {
|
||||
if (val & 2)
|
||||
@@ -570,9 +574,10 @@ pit_write(uint16_t addr, uint8_t val, void *priv)
|
||||
|
||||
if (!(dev->ctrl & 0x30)) {
|
||||
ctr_latch_count(ctr);
|
||||
if ((dev->flags & (PIT_8254 | PIT_EXT_IO)))
|
||||
if ((dev->flags & (PIT_8254 | PIT_EXT_IO))) {
|
||||
pit_log("PIT %i: Initiated latched read, %i bytes latched\n",
|
||||
t, ctr->latched);
|
||||
}
|
||||
} else {
|
||||
ctr->ctrl = val;
|
||||
ctr->rm = ctr->wm = (ctr->ctrl >> 4) & 3;
|
||||
@@ -584,13 +589,15 @@ pit_write(uint16_t addr, uint8_t val, void *priv)
|
||||
ctr_set_out(ctr, !!ctr->m, dev);
|
||||
ctr->state = 0;
|
||||
if (ctr->latched) {
|
||||
if ((dev->flags & (PIT_8254 | PIT_EXT_IO)))
|
||||
if ((dev->flags & (PIT_8254 | PIT_EXT_IO))) {
|
||||
pit_log("PIT %i: Reload while counter is latched\n", t);
|
||||
}
|
||||
ctr->rl--;
|
||||
}
|
||||
|
||||
if ((dev->flags & (PIT_8254 | PIT_EXT_IO)))
|
||||
if ((dev->flags & (PIT_8254 | PIT_EXT_IO))) {
|
||||
pit_log("PIT %i: M = %i, RM/WM = %i, State = %i, Out = %i\n", t, ctr->m, ctr->rm, ctr->state, ctr->out);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -608,8 +615,9 @@ pit_write(uint16_t addr, uint8_t val, void *priv)
|
||||
ctr->l = val;
|
||||
ctr->lback = ctr->l;
|
||||
ctr->lback2 = ctr->l;
|
||||
if ((dev->flags & (PIT_8254 | PIT_EXT_IO)))
|
||||
if ((dev->flags & (PIT_8254 | PIT_EXT_IO))) {
|
||||
pit_log("PIT %i (1): Written byte %02X, latch now %04X\n", t, val, ctr->l);
|
||||
}
|
||||
if (ctr->m == 0)
|
||||
ctr_set_out(ctr, 0, dev);
|
||||
ctr_load(ctr);
|
||||
@@ -618,8 +626,9 @@ pit_write(uint16_t addr, uint8_t val, void *priv)
|
||||
ctr->l = (val << 8);
|
||||
ctr->lback = ctr->l;
|
||||
ctr->lback2 = ctr->l;
|
||||
if ((dev->flags & (PIT_8254 | PIT_EXT_IO)))
|
||||
if ((dev->flags & (PIT_8254 | PIT_EXT_IO))) {
|
||||
pit_log("PIT %i (2): Written byte %02X, latch now %04X\n", t, val, ctr->l);
|
||||
}
|
||||
if (ctr->m == 0)
|
||||
ctr_set_out(ctr, 0, dev);
|
||||
ctr_load(ctr);
|
||||
@@ -630,15 +639,17 @@ pit_write(uint16_t addr, uint8_t val, void *priv)
|
||||
ctr->l = (ctr->l & 0x00ff) | (val << 8);
|
||||
ctr->lback = ctr->l;
|
||||
ctr->lback2 = ctr->l;
|
||||
if ((dev->flags & (PIT_8254 | PIT_EXT_IO)))
|
||||
if ((dev->flags & (PIT_8254 | PIT_EXT_IO))) {
|
||||
pit_log("PIT %i (0x83): Written high byte %02X, latch now %04X\n", t, val, ctr->l);
|
||||
}
|
||||
ctr_load(ctr);
|
||||
} else {
|
||||
ctr->l = (ctr->l & 0xff00) | val;
|
||||
ctr->lback = ctr->l;
|
||||
ctr->lback2 = ctr->l;
|
||||
if ((dev->flags & (PIT_8254 | PIT_EXT_IO)))
|
||||
if ((dev->flags & (PIT_8254 | PIT_EXT_IO))) {
|
||||
pit_log("PIT %i (3): Written low byte %02X, latch now %04X\n", t, val, ctr->l);
|
||||
}
|
||||
if (ctr->m == 0) {
|
||||
ctr->state = 0;
|
||||
ctr_set_out(ctr, 0, dev);
|
||||
@@ -774,8 +785,9 @@ pit_read(uint16_t addr, void *priv)
|
||||
break;
|
||||
}
|
||||
|
||||
if ((dev->flags & (PIT_8254 | PIT_EXT_IO)))
|
||||
if ((dev->flags & (PIT_8254 | PIT_EXT_IO))) {
|
||||
pit_log("[%04X:%08X] pit_read(%04X, %08X) = %02X\n", CS, cpu_state.pc, addr, priv, ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -855,6 +867,15 @@ ctr_reset(ctr_t *ctr)
|
||||
ctr->l_det = 0;
|
||||
}
|
||||
|
||||
void
|
||||
pit_device_reset(pit_t *dev)
|
||||
{
|
||||
dev->clock = 0;
|
||||
|
||||
for (uint8_t i = 0; i < 3; i++)
|
||||
ctr_reset(&dev->counters[i]);
|
||||
}
|
||||
|
||||
void
|
||||
pit_reset(pit_t *dev)
|
||||
{
|
||||
@@ -1094,9 +1115,10 @@ pit_ps2_init(int type)
|
||||
}
|
||||
|
||||
void
|
||||
pit_change_pas16_const(double prescale)
|
||||
pit_change_pas16_consts(double prescale)
|
||||
{
|
||||
PAS16CONST = (uint64_t) ((PITCONSTD / prescale) * (double) (1ULL << 32));
|
||||
PAS16CONST = (uint64_t) ((PAS16CONSTD / prescale) * (double) (1ULL << 32));
|
||||
PAS16CONST2 = (uint64_t) ((PAS16CONST2D / prescale) * (double) (1ULL << 32));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1195,7 +1217,10 @@ pit_set_clock(uint32_t clock)
|
||||
TIMER_USEC = (uint64_t) ((cpuclock / 1000000.0) * (double) (1ULL << 32));
|
||||
|
||||
PAS16CONSTD = (cpuclock / 441000.0);
|
||||
PAS16CONST = (uint64_t) (PITCONSTD * (double) (1ULL << 32));
|
||||
PAS16CONST = (uint64_t) (PAS16CONSTD * (double) (1ULL << 32));
|
||||
|
||||
PAS16CONST2D = (cpuclock / 1008000.0);
|
||||
PAS16CONST2 = (uint64_t) (PAS16CONST2D * (double) (1ULL << 32));
|
||||
|
||||
isa_timing = (cpuclock / (double) cpu_isa_speed);
|
||||
if (cpu_64bitbus)
|
||||
|
@@ -99,7 +99,7 @@ pitf_ctr_get_count(void *data, int counter_id)
|
||||
return (uint16_t) ctr->l;
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
pitf_ctr_set_out_func(void *data, int counter_id, void (*func)(int new_out, int old_out, void *priv))
|
||||
{
|
||||
if (data == NULL)
|
||||
@@ -111,7 +111,7 @@ pitf_ctr_set_out_func(void *data, int counter_id, void (*func)(int new_out, int
|
||||
ctr->out_func = func;
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
pitf_ctr_set_using_timer(void *data, int counter_id, int using_timer)
|
||||
{
|
||||
if (tsc > 0)
|
||||
@@ -284,7 +284,7 @@ pitf_set_gate_no_timer(ctrf_t *ctr, int gate, void *priv)
|
||||
pitf_dump_and_disable_timer(ctr);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
pitf_ctr_set_gate(void *data, int counter_id, int gate)
|
||||
{
|
||||
pitf_t *pit = (pitf_t *) data;
|
||||
@@ -619,7 +619,7 @@ pitf_timer_over(void *priv)
|
||||
pitf_over(ctr, pit);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
pitf_ctr_clock(void *data, int counter_id)
|
||||
{
|
||||
pitf_t *pit = (pitf_t *) data;
|
||||
@@ -692,6 +692,12 @@ pitf_close(void *priv)
|
||||
free(dev);
|
||||
}
|
||||
|
||||
void
|
||||
pitf_handler(int set, uint16_t base, int size, void *priv)
|
||||
{
|
||||
io_handler(set, base, size, pitf_read, NULL, NULL, pitf_write, NULL, NULL, priv);
|
||||
}
|
||||
|
||||
static void *
|
||||
pitf_init(const device_t *info)
|
||||
{
|
||||
|
Reference in New Issue
Block a user