mirror of
https://github.com/holub/mame
synced 2025-07-04 17:38:08 +03:00
m37710: Internalize timing for A-D converter
This commit is contained in:
parent
75e748a296
commit
f7f5bedbbe
@ -418,7 +418,7 @@ void m37710_cpu_device::m37710_recalc_timer(int timer)
|
||||
switch (m_timer_mode[timer] & 0x3)
|
||||
{
|
||||
case 0: // timer mode
|
||||
time = attotime::from_hz(unscaled_clock()) * tscales[m_timer_mode[timer]>>6];
|
||||
time = clocks_to_attotime(tscales[m_timer_mode[timer]>>6]);
|
||||
time *= (tval + 1);
|
||||
|
||||
LOGMASKED(LOG_TIMER, "Timer %d in timer mode, %f Hz\n", timer, 1.0 / time.as_double());
|
||||
@ -445,7 +445,7 @@ void m37710_cpu_device::m37710_recalc_timer(int timer)
|
||||
switch (m_timer_mode[timer] & 0x3)
|
||||
{
|
||||
case 0: // timer mode
|
||||
time = attotime::from_hz(unscaled_clock()) * tscales[m_timer_mode[timer]>>6];
|
||||
time = clocks_to_attotime(tscales[m_timer_mode[timer]>>6]);
|
||||
time *= (tval + 1);
|
||||
|
||||
LOGMASKED(LOG_TIMER, "Timer %d in timer mode, %f Hz\n", timer, 1.0 / time.as_double());
|
||||
@ -535,9 +535,43 @@ void m37710_cpu_device::ad_control_w(uint8_t data)
|
||||
{
|
||||
LOGMASKED(LOG_AD, "ad_control_w %x: A/D control reg = %x\n", data, m_ad_control);
|
||||
|
||||
if (BIT(data, 6) && !BIT(m_ad_control, 6))
|
||||
{
|
||||
// A-D conversion clock may be selected as f2/4 or f2/2
|
||||
m_ad_timer->adjust(clocks_to_attotime(57 * 2 * (BIT(data, 7) ? 2 : 4)));
|
||||
if (BIT(data, 4))
|
||||
data &= 0xf8;
|
||||
}
|
||||
else if (!BIT(data, 6))
|
||||
m_ad_timer->adjust(attotime::never);
|
||||
|
||||
m_ad_control = data;
|
||||
}
|
||||
|
||||
TIMER_CALLBACK_MEMBER(m37710_cpu_device::ad_timer_cb)
|
||||
{
|
||||
int line = m_ad_control & 0x07;
|
||||
|
||||
m_ad_result[line] = m_analog_cb[line]();
|
||||
|
||||
if (BIT(m_ad_control, 4))
|
||||
m_ad_control = (m_ad_control & 0xf8) | ((line + 1) & 0x07);
|
||||
|
||||
// repeat or sweep conversion
|
||||
if (BIT(m_ad_control, 3) || (BIT(m_ad_control, 4) && line != (m_ad_sweep & 0x03) * 2 + 1))
|
||||
{
|
||||
LOGMASKED(LOG_AD, "AN%d input converted = %x (repeat/sweep)\n", line, m_ad_result[line]);
|
||||
m_ad_timer->adjust(clocks_to_attotime(57 * 2 * (BIT(m_ad_control, 7) ? 2 : 4)));
|
||||
}
|
||||
else
|
||||
{
|
||||
// interrupt occurs only when conversion stops
|
||||
LOGMASKED(LOG_AD, "AN%d input converted = %x (finished)\n", line, m_ad_result[line]);
|
||||
m37710_set_irq_line(M37710_LINE_ADC, ASSERT_LINE);
|
||||
m_ad_control &= 0xbf;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t m37710_cpu_device::ad_sweep_r()
|
||||
{
|
||||
return m_ad_sweep;
|
||||
@ -552,7 +586,7 @@ void m37710_cpu_device::ad_sweep_w(uint8_t data)
|
||||
|
||||
uint16_t m37710_cpu_device::ad_result_r(offs_t offset)
|
||||
{
|
||||
uint16_t result = m_analog_cb[offset]();
|
||||
uint16_t result = m_ad_result[offset];
|
||||
|
||||
LOGMASKED(LOG_AD, "ad_result_r from %02x: A/D %d = %x (PC=%x)\n", (int)(offset * 2) + 0x20, offset, result, REG_PB<<16 | REG_PC);
|
||||
|
||||
@ -847,10 +881,6 @@ uint8_t m37710_cpu_device::int_control_r(offs_t offset)
|
||||
|
||||
uint8_t result = m_int_control[level];
|
||||
|
||||
// A-D IRQ not properly hooked up yet
|
||||
if (level == M37710_LINE_ADC)
|
||||
result |= 8;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1007,6 +1037,7 @@ void m37710_cpu_device::device_reset()
|
||||
// A-D
|
||||
m_ad_control &= 7;
|
||||
m_ad_sweep = (m_ad_sweep & ~0xdc) | 3;
|
||||
m_ad_timer->reset();
|
||||
|
||||
// UARTs
|
||||
for (i = 0; i < 2; i++)
|
||||
@ -1208,6 +1239,7 @@ void m37710_cpu_device::device_start()
|
||||
std::fill(std::begin(m_port_dir), std::end(m_port_dir), 0);
|
||||
m_ad_control = 0;
|
||||
m_ad_sweep = 0;
|
||||
std::fill(std::begin(m_ad_result), std::end(m_ad_result), 0);
|
||||
std::fill(std::begin(m_uart_mode), std::end(m_uart_mode), 0);
|
||||
std::fill(std::begin(m_uart_baud), std::end(m_uart_baud), 0);
|
||||
std::fill(std::begin(m_uart_ctrl_reg0), std::end(m_uart_ctrl_reg0), 0);
|
||||
@ -1243,6 +1275,8 @@ void m37710_cpu_device::device_start()
|
||||
m_timer_out[i] = 0;
|
||||
}
|
||||
|
||||
m_ad_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(m37710_cpu_device::ad_timer_cb), this));
|
||||
|
||||
save_item(NAME(m_a));
|
||||
save_item(NAME(m_b));
|
||||
save_item(NAME(m_ba));
|
||||
@ -1279,6 +1313,7 @@ void m37710_cpu_device::device_start()
|
||||
save_item(NAME(m_port_dir));
|
||||
save_item(NAME(m_ad_control));
|
||||
save_item(NAME(m_ad_sweep));
|
||||
save_item(NAME(m_ad_result));
|
||||
save_item(NAME(m_uart_mode));
|
||||
save_item(NAME(m_uart_baud));
|
||||
save_item(NAME(m_uart_ctrl_reg0));
|
||||
|
@ -135,6 +135,7 @@ protected:
|
||||
void pulse_output_w(offs_t offset, uint8_t data);
|
||||
uint8_t ad_control_r();
|
||||
void ad_control_w(uint8_t data);
|
||||
TIMER_CALLBACK_MEMBER(ad_timer_cb);
|
||||
uint8_t ad_sweep_r();
|
||||
void ad_sweep_w(uint8_t data);
|
||||
uint16_t ad_result_r(offs_t offset);
|
||||
@ -267,6 +268,8 @@ private:
|
||||
// A/D
|
||||
uint8_t m_ad_control;
|
||||
uint8_t m_ad_sweep;
|
||||
uint16_t m_ad_result[8];
|
||||
emu_timer *m_ad_timer;
|
||||
|
||||
// UARTs
|
||||
uint8_t m_uart_mode[2];
|
||||
|
@ -477,11 +477,6 @@ TIMER_DEVICE_CALLBACK_MEMBER(namcofl_state::mcu_irq2_cb)
|
||||
m_mcu->set_input_line(M37710_LINE_IRQ2, HOLD_LINE);
|
||||
}
|
||||
|
||||
TIMER_DEVICE_CALLBACK_MEMBER(namcofl_state::mcu_adc_cb)
|
||||
{
|
||||
m_mcu->set_input_line(M37710_LINE_ADC, HOLD_LINE);
|
||||
}
|
||||
|
||||
|
||||
MACHINE_START_MEMBER(namcofl_state,namcofl)
|
||||
{
|
||||
@ -532,7 +527,6 @@ void namcofl_state::namcofl(machine_config &config)
|
||||
/* TODO: irq generation for these */
|
||||
TIMER(config, "mcu_irq0").configure_periodic(FUNC(namcofl_state::mcu_irq0_cb), attotime::from_hz(60));
|
||||
TIMER(config, "mcu_irq2").configure_periodic(FUNC(namcofl_state::mcu_irq2_cb), attotime::from_hz(60));
|
||||
TIMER(config, "mcu_adc").configure_periodic(FUNC(namcofl_state::mcu_adc_cb), attotime::from_hz(60));
|
||||
|
||||
MCFG_MACHINE_START_OVERRIDE(namcofl_state,namcofl)
|
||||
MCFG_MACHINE_RESET_OVERRIDE(namcofl_state,namcofl)
|
||||
|
@ -927,10 +927,6 @@ void namcona1_state::scanline_interrupt(int scanline)
|
||||
{
|
||||
const u16 enabled = m_mEnableInterrupts ? ~m_vreg[0x1a / 2] : 0;
|
||||
|
||||
// adc (timing guessed, when does this trigger?)
|
||||
if (scanline == 0)
|
||||
m_mcu->set_input_line(M37710_LINE_ADC, HOLD_LINE);
|
||||
|
||||
// vblank
|
||||
if (scanline == 224)
|
||||
{
|
||||
|
@ -337,11 +337,6 @@ TIMER_DEVICE_CALLBACK_MEMBER(namconb1_state::mcu_irq2_cb)
|
||||
m_mcu->set_input_line(M37710_LINE_IRQ2, HOLD_LINE);
|
||||
}
|
||||
|
||||
TIMER_DEVICE_CALLBACK_MEMBER(namconb1_state::mcu_adc_cb)
|
||||
{
|
||||
m_mcu->set_input_line(M37710_LINE_ADC, HOLD_LINE);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
WRITE8_MEMBER(namconb1_state::namconb1_cpureg_w)
|
||||
@ -984,7 +979,6 @@ void namconb1_state::namconb1(machine_config &config)
|
||||
// has to be 60 hz or music will go crazy in nebulray, vshoot, gslugrs*
|
||||
TIMER(config, "mcu_irq0").configure_periodic(FUNC(namconb1_state::mcu_irq0_cb), attotime::from_hz(60));
|
||||
TIMER(config, "mcu_irq2").configure_periodic(FUNC(namconb1_state::mcu_irq2_cb), attotime::from_hz(60));
|
||||
TIMER(config, "mcu_adc").configure_periodic(FUNC(namconb1_state::mcu_adc_cb), attotime::from_hz(60));
|
||||
|
||||
SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
|
||||
m_screen->set_raw(MASTER_CLOCK/8, 384, 0, 288, 264, 0, 224);
|
||||
|
@ -356,7 +356,6 @@ private:
|
||||
DECLARE_WRITE16_MEMBER(c76_speedup_w);
|
||||
TIMER_DEVICE_CALLBACK_MEMBER(mcu_irq0_cb);
|
||||
TIMER_DEVICE_CALLBACK_MEMBER(mcu_irq2_cb);
|
||||
TIMER_DEVICE_CALLBACK_MEMBER(mcu_adc_cb);
|
||||
|
||||
void c76_map(address_map &map);
|
||||
void namcos11_map(address_map &map);
|
||||
@ -594,11 +593,6 @@ TIMER_DEVICE_CALLBACK_MEMBER(namcos11_state::mcu_irq2_cb)
|
||||
m_mcu->set_input_line(M37710_LINE_IRQ2, HOLD_LINE);
|
||||
}
|
||||
|
||||
TIMER_DEVICE_CALLBACK_MEMBER(namcos11_state::mcu_adc_cb)
|
||||
{
|
||||
m_mcu->set_input_line(M37710_LINE_ADC, HOLD_LINE);
|
||||
}
|
||||
|
||||
void namcos11_state::coh110(machine_config &config)
|
||||
{
|
||||
CXD8530CQ(config, m_maincpu, XTAL(67'737'600));
|
||||
@ -620,7 +614,6 @@ void namcos11_state::coh110(machine_config &config)
|
||||
/* TODO: irq generation for these */
|
||||
TIMER(config, "mcu_irq0").configure_periodic(FUNC(namcos11_state::mcu_irq0_cb), attotime::from_hz(60));
|
||||
TIMER(config, "mcu_irq2").configure_periodic(FUNC(namcos11_state::mcu_irq2_cb), attotime::from_hz(60));
|
||||
TIMER(config, "mcu_adc").configure_periodic(FUNC(namcos11_state::mcu_adc_cb), attotime::from_hz(60));
|
||||
|
||||
CXD8561Q(config, "gpu", XTAL(53'693'175), 0x200000, subdevice<psxcpu_device>("maincpu")).set_screen("screen");
|
||||
|
||||
|
@ -2736,8 +2736,6 @@ TIMER_DEVICE_CALLBACK_MEMBER(namcos22s_state::mcu_irq)
|
||||
/* TODO: real sources of these */
|
||||
if (scanline == 480)
|
||||
m_mcu->set_input_line(M37710_LINE_IRQ0, HOLD_LINE);
|
||||
else if (scanline == 0)
|
||||
m_mcu->set_input_line(M37710_LINE_ADC, HOLD_LINE);
|
||||
else if (scanline == 240)
|
||||
m_mcu->set_input_line(M37710_LINE_IRQ2, HOLD_LINE);
|
||||
}
|
||||
|
@ -91,7 +91,6 @@ private:
|
||||
TIMER_CALLBACK_MEMBER(raster_interrupt_callback);
|
||||
TIMER_DEVICE_CALLBACK_MEMBER(mcu_irq0_cb);
|
||||
TIMER_DEVICE_CALLBACK_MEMBER(mcu_irq2_cb);
|
||||
TIMER_DEVICE_CALLBACK_MEMBER(mcu_adc_cb);
|
||||
void common_init();
|
||||
int FLobjcode2tile(int code);
|
||||
void TilemapCB(uint16_t code, int *tile, int *mask);
|
||||
|
@ -142,7 +142,6 @@ private:
|
||||
TIMER_DEVICE_CALLBACK_MEMBER(scantimer);
|
||||
TIMER_DEVICE_CALLBACK_MEMBER(mcu_irq0_cb);
|
||||
TIMER_DEVICE_CALLBACK_MEMBER(mcu_irq2_cb);
|
||||
TIMER_DEVICE_CALLBACK_MEMBER(mcu_adc_cb);
|
||||
|
||||
int NB1objcode2tile(int code);
|
||||
int NB2objcode2tile_machbrkr(int code);
|
||||
|
Loading…
Reference in New Issue
Block a user