summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Ryan Holtz <therealmogminer@gmail.com>2018-04-30 16:59:07 +0200
committer Ryan Holtz <therealmogminer@gmail.com>2018-04-30 17:44:58 +0200
commit06e9fc04e1d2f481411f735289abb089d12d5645 (patch)
tree36fcc6393b8fee6bd1600bc0bd8be828c50cab66
parent9f2e687dbe498bb5f4a4c36d5e440c26374b1176 (diff)
-adc0808: Improved timings a bit more, nw
-rw-r--r--src/devices/machine/adc0808.cpp47
-rw-r--r--src/devices/machine/adc0808.h1
-rw-r--r--src/mame/machine/starwars.cpp2
3 files changed, 34 insertions, 16 deletions
diff --git a/src/devices/machine/adc0808.cpp b/src/devices/machine/adc0808.cpp
index b2bb8876703..7c2eadb845a 100644
--- a/src/devices/machine/adc0808.cpp
+++ b/src/devices/machine/adc0808.cpp
@@ -107,29 +107,47 @@ void adc0808_device::device_timer(emu_timer &timer, device_timer_id id, int para
{
case STATE_IDLE:
m_cycle_timer->adjust(attotime::never);
- m_eoc = 1;
+ return;
+
+ // ready; beginning to run conversion cycle
+ case STATE_CONVERSION_READY:
+ m_state = STATE_CONVERSION_RUNNING;
+
+ m_sar = m_in_cb[m_address](0);
+ m_eoc = 0;
m_eoc_cb(m_eoc);
- m_eoc_ff_cb(1);
+
+ // the conversion takes 8 iterations/cycles
+ m_cycle_timer->adjust(attotime::from_ticks(8, clock()));
return;
- // start of conversion cycle
+ // start; mark ourselves as ready for conversion 1 cycle later
case STATE_CONVERSION_START:
- m_state = STATE_CONVERSION_RUNNING;
- // the conversion takes 8 steps every 8 cycles
- m_cycle_timer->adjust(attotime::from_hz(clock()) * 63);
+ m_state = STATE_CONVERSION_READY;
+ m_cycle_timer->adjust(attotime::from_hz(clock()));
return;
// end of conversion cycle
case STATE_CONVERSION_RUNNING:
- m_sar = m_in_cb[m_address](0);
+ {
m_state = STATE_IDLE;
+ const uint8_t start_sar = m_sar;
+ m_sar = m_in_cb[m_address](0);
+
+ m_eoc = 1;
+ m_eoc_cb(m_eoc);
+ m_eoc_ff_cb(1);
if (VERBOSE)
logerror("Conversion finished, result %02x\n", m_sar);
+ if (m_sar != start_sar)
+ logerror("Conversion finished, should fail - starting value %02x, ending value %02x", start_sar, m_sar);
+
// eoc is delayed by one cycle
- m_cycle_timer->adjust(attotime::from_hz(clock()));
+ m_cycle_timer->adjust(attotime::never);
break;
+ }
}
}
@@ -159,16 +177,17 @@ WRITE8_MEMBER( adc0808_device::address_w )
WRITE_LINE_MEMBER( adc0808_device::start_w )
{
- if (m_start == 1 && state == 0)
+ if (m_start == state)
+ return;
+
+ if (state && !m_start)
{
m_state = STATE_CONVERSION_START;
- m_cycle_timer->adjust(attotime::zero);
+ m_cycle_timer->adjust(attotime::from_hz(clock()));
}
- else if (m_start == 0 && state == 1)
+ else if (!state && m_start)
{
- m_sar = 0;
- m_eoc = 0;
- m_eoc_cb(m_eoc);
+ m_cycle_timer->adjust(attotime::from_hz(clock()));
}
m_start = state;
diff --git a/src/devices/machine/adc0808.h b/src/devices/machine/adc0808.h
index 5b9c97dc69f..ace9fcf4682 100644
--- a/src/devices/machine/adc0808.h
+++ b/src/devices/machine/adc0808.h
@@ -119,6 +119,7 @@ private:
{
STATE_IDLE,
STATE_CONVERSION_START,
+ STATE_CONVERSION_READY,
STATE_CONVERSION_RUNNING
};
state m_state;
diff --git a/src/mame/machine/starwars.cpp b/src/mame/machine/starwars.cpp
index 5ed7b81fa11..546c636e36e 100644
--- a/src/mame/machine/starwars.cpp
+++ b/src/mame/machine/starwars.cpp
@@ -151,8 +151,6 @@ void starwars_state::run_mproc()
int IP15_8, IP7, IP6_0; /* Instruction PROM values */
int mptime;
- logerror("Running Matrix Processor...\n");
-
mptime = 0;
m_math_run = 1;