summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/fga002.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/machine/fga002.cpp')
-rw-r--r--src/devices/machine/fga002.cpp111
1 files changed, 48 insertions, 63 deletions
diff --git a/src/devices/machine/fga002.cpp b/src/devices/machine/fga002.cpp
index 59a40777aa9..f9683b4f152 100644
--- a/src/devices/machine/fga002.cpp
+++ b/src/devices/machine/fga002.cpp
@@ -34,13 +34,12 @@
#include "emu.h"
#include "fga002.h"
-//#define LOG_GENERAL (1U << 0)
-#define LOG_SETUP (1U << 1)
-#define LOG_READ (1U << 2)
-#define LOG_INT (1U << 3)
-#define LOG_VEC (1U << 4)
-#define LOG_LVL (1U << 5)
-#define LOG_IACK (1U << 6)
+#define LOG_SETUP (1U << 1)
+#define LOG_READ (1U << 2)
+#define LOG_INT (1U << 3)
+#define LOG_VEC (1U << 4)
+#define LOG_LVL (1U << 5)
+#define LOG_IACK (1U << 6)
//#define VERBOSE (LOG_GENERAL | LOG_SETUP)
//#define LOG_OUTPUT_FUNC printf
@@ -77,10 +76,10 @@ DEFINE_DEVICE_TYPE(FGA002, fga002_device, "fga002", "Force FGA-002")
fga002_device::fga002_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, type, tag, owner, clock)
, m_out_int_cb(*this)
- , m_liack4_cb(*this)
- , m_liack5_cb(*this)
- , m_liack6_cb(*this)
- , m_liack7_cb(*this)
+ , m_liack4_cb(*this, 0)
+ , m_liack5_cb(*this, 0)
+ , m_liack6_cb(*this, 0)
+ , m_liack7_cb(*this, 0)
, m_irq_level(uint8_t(0))
{
for (auto & elem : m_int_state)
@@ -96,15 +95,8 @@ void fga002_device::device_start()
{
LOG("%s\n", FUNCNAME);
- // resolve callbacks
- m_out_int_cb.resolve_safe();
- m_liack4_cb.resolve_safe(0);
- m_liack5_cb.resolve_safe(0);
- m_liack6_cb.resolve_safe(0);
- m_liack7_cb.resolve_safe(0);
-
// Timers
- fga_timer = timer_alloc(TIMER_ID_FGA);
+ fga_timer = timer_alloc(FUNC(fga002_device::timer_tick), this);
save_pointer (NAME (m_fga002), sizeof(m_fga002));
@@ -143,31 +135,24 @@ void fga002_device::device_reset()
}
//-------------------------------------------------
-// device_timer - handler timer events
+// timer_tick - decrement timer 0
//-------------------------------------------------
-void fga002_device::device_timer (emu_timer &timer, device_timer_id id, int32_t param, void *ptr)
+
+TIMER_CALLBACK_MEMBER(fga002_device::timer_tick)
{
- switch(id)
+ if (m_tim0count-- == 0) // Zero detect
{
- case TIMER_ID_FGA:
- if (m_tim0count-- == 0) // Zero detect
+ if ((m_fga002[FGA_TIM0CTL] & REG_TIM0CTL_ZERO_STOP) == 0)
{
- if ((m_fga002[FGA_TIM0CTL] & REG_TIM0CTL_ZERO_STOP) == 0)
- {
- fga_timer->adjust(attotime::never, TIMER_ID_FGA, attotime::never);
- }
+ fga_timer->adjust(attotime::never);
+ }
+ else
+ {
+ if ((m_fga002[FGA_TIM0CTL] & REG_TIM0CTL_AUTOPRELOAD) == 0)
+ m_tim0count &= 0xff;
else
- {
- if ((m_fga002[FGA_TIM0CTL] & REG_TIM0CTL_AUTOPRELOAD) == 0)
- m_tim0count &= 0xff;
- else
- m_tim0count = m_fga002[FGA_TIM0PRELOAD];
- }
+ m_tim0count = m_fga002[FGA_TIM0PRELOAD];
}
- break;
- default:
- LOG("Unhandled Timer ID %d\n", id);
- break;
}
}
@@ -408,27 +393,27 @@ void fga002_device::do_fga002reg_tim0ctl_w(uint8_t data)
if ((data & REG_TIM0CTL_START_STOP) != (m_fga002[FGA_TIM0CTL] & REG_TIM0CTL_START_STOP))
{
if ((data & REG_TIM0CTL_START_STOP) == 0)
- fga_timer->adjust(attotime::never, TIMER_ID_FGA, attotime::never);
+ fga_timer->adjust(attotime::never);
else
{
switch (data & REG_TIM0CTL_CLK_MSK)
{
- case REG_TIM0CTL_CLK_1_MIC: fga_timer->adjust(attotime::from_usec(1), TIMER_ID_FGA, attotime::from_usec(1)); break;
- case REG_TIM0CTL_CLK_2_MIC: fga_timer->adjust(attotime::from_usec(2), TIMER_ID_FGA, attotime::from_usec(2)); break;
- case REG_TIM0CTL_CLK_4_MIC: fga_timer->adjust(attotime::from_usec(4), TIMER_ID_FGA, attotime::from_usec(4)); break;
- case REG_TIM0CTL_CLK_8_MIC: fga_timer->adjust(attotime::from_usec(8), TIMER_ID_FGA, attotime::from_usec(8)); break;
- case REG_TIM0CTL_CLK_16_MIC: fga_timer->adjust(attotime::from_usec(16), TIMER_ID_FGA, attotime::from_usec(16)); break;
- case REG_TIM0CTL_CLK_32_MIC: fga_timer->adjust(attotime::from_usec(32), TIMER_ID_FGA, attotime::from_usec(32)); break;
- case REG_TIM0CTL_CLK_64_MIC: fga_timer->adjust(attotime::from_usec(64), TIMER_ID_FGA, attotime::from_usec(64)); break;
- case REG_TIM0CTL_CLK_128_MIC: fga_timer->adjust(attotime::from_usec(128), TIMER_ID_FGA, attotime::from_usec(128)); break;
- case REG_TIM0CTL_CLK_256_MIC: fga_timer->adjust(attotime::from_usec(256), TIMER_ID_FGA, attotime::from_usec(256)); break;
- case REG_TIM0CTL_CLK_512_MIC: fga_timer->adjust(attotime::from_usec(512), TIMER_ID_FGA, attotime::from_usec(512)); break;
- case REG_TIM0CTL_CLK_2_MIL: fga_timer->adjust(attotime::from_msec(2), TIMER_ID_FGA, attotime::from_msec(2)); break;
- case REG_TIM0CTL_CLK_8_MIL: fga_timer->adjust(attotime::from_msec(8), TIMER_ID_FGA, attotime::from_msec(8)); break;
- case REG_TIM0CTL_CLK_32_MIL: fga_timer->adjust(attotime::from_msec(32), TIMER_ID_FGA, attotime::from_msec(32)); break;
- case REG_TIM0CTL_CLK_125_MIL: fga_timer->adjust(attotime::from_msec(125), TIMER_ID_FGA, attotime::from_msec(125)); break;
- case REG_TIM0CTL_CLK_500_MIL: fga_timer->adjust(attotime::from_msec(500), TIMER_ID_FGA, attotime::from_msec(500)); break;
- case REG_TIM0CTL_CLK_2_SEC: fga_timer->adjust(attotime::from_seconds(2), TIMER_ID_FGA, attotime::from_seconds(2)); break;
+ case REG_TIM0CTL_CLK_1_MIC: fga_timer->adjust(attotime::from_usec(1), 0, attotime::from_usec(1)); break;
+ case REG_TIM0CTL_CLK_2_MIC: fga_timer->adjust(attotime::from_usec(2), 0, attotime::from_usec(2)); break;
+ case REG_TIM0CTL_CLK_4_MIC: fga_timer->adjust(attotime::from_usec(4), 0, attotime::from_usec(4)); break;
+ case REG_TIM0CTL_CLK_8_MIC: fga_timer->adjust(attotime::from_usec(8), 0, attotime::from_usec(8)); break;
+ case REG_TIM0CTL_CLK_16_MIC: fga_timer->adjust(attotime::from_usec(16), 0, attotime::from_usec(16)); break;
+ case REG_TIM0CTL_CLK_32_MIC: fga_timer->adjust(attotime::from_usec(32), 0, attotime::from_usec(32)); break;
+ case REG_TIM0CTL_CLK_64_MIC: fga_timer->adjust(attotime::from_usec(64), 0, attotime::from_usec(64)); break;
+ case REG_TIM0CTL_CLK_128_MIC: fga_timer->adjust(attotime::from_usec(128), 0, attotime::from_usec(128)); break;
+ case REG_TIM0CTL_CLK_256_MIC: fga_timer->adjust(attotime::from_usec(256), 0, attotime::from_usec(256)); break;
+ case REG_TIM0CTL_CLK_512_MIC: fga_timer->adjust(attotime::from_usec(512), 0, attotime::from_usec(512)); break;
+ case REG_TIM0CTL_CLK_2_MIL: fga_timer->adjust(attotime::from_msec(2), 0, attotime::from_msec(2)); break;
+ case REG_TIM0CTL_CLK_8_MIL: fga_timer->adjust(attotime::from_msec(8), 0, attotime::from_msec(8)); break;
+ case REG_TIM0CTL_CLK_32_MIL: fga_timer->adjust(attotime::from_msec(32), 0, attotime::from_msec(32)); break;
+ case REG_TIM0CTL_CLK_125_MIL: fga_timer->adjust(attotime::from_msec(125), 0, attotime::from_msec(125)); break;
+ case REG_TIM0CTL_CLK_500_MIL: fga_timer->adjust(attotime::from_msec(500), 0, attotime::from_msec(500)); break;
+ case REG_TIM0CTL_CLK_2_SEC: fga_timer->adjust(attotime::from_seconds(2), 0, attotime::from_seconds(2)); break;
default: logerror("REG_TIM0CTL programmer error, please report\n"); break; // Should never happen
}
}
@@ -599,14 +584,14 @@ void fga002_device::lirq_w(int status, int vector, int control, int state)
}
}
-WRITE_LINE_MEMBER (fga002_device::lirq0_w) { LOGINT("%s\n", FUNCNAME); lirq_w( FGA_ISLOCAL0, INT_LOCAL0, FGA_ICRLOCAL0, state ); }
-WRITE_LINE_MEMBER (fga002_device::lirq1_w) { LOGINT("%s\n", FUNCNAME); lirq_w( FGA_ISLOCAL1, INT_LOCAL1, FGA_ICRLOCAL1, state ); }
-WRITE_LINE_MEMBER (fga002_device::lirq2_w) { LOGINT("%s\n", FUNCNAME); lirq_w( FGA_ISLOCAL2, INT_LOCAL2, FGA_ICRLOCAL2, state ); }
-WRITE_LINE_MEMBER (fga002_device::lirq3_w) { LOGINT("%s\n", FUNCNAME); lirq_w( FGA_ISLOCAL3, INT_LOCAL3, FGA_ICRLOCAL3, state ); }
-WRITE_LINE_MEMBER (fga002_device::lirq4_w) { LOGINT("%s\n", FUNCNAME); lirq_w( FGA_ISLOCAL4, INT_LOCAL4, FGA_ICRLOCAL4, state ); }
-WRITE_LINE_MEMBER (fga002_device::lirq5_w) { LOGINT("%s\n", FUNCNAME); lirq_w( FGA_ISLOCAL5, INT_LOCAL5, FGA_ICRLOCAL5, state ); }
-WRITE_LINE_MEMBER (fga002_device::lirq6_w) { LOGINT("%s\n", FUNCNAME); lirq_w( FGA_ISLOCAL6, INT_LOCAL6, FGA_ICRLOCAL6, state ); }
-WRITE_LINE_MEMBER (fga002_device::lirq7_w) { LOGINT("%s\n", FUNCNAME); lirq_w( FGA_ISLOCAL7, INT_LOCAL7, FGA_ICRLOCAL7, state ); }
+void fga002_device::lirq0_w(int state) { LOGINT("%s\n", FUNCNAME); lirq_w( FGA_ISLOCAL0, INT_LOCAL0, FGA_ICRLOCAL0, state ); }
+void fga002_device::lirq1_w(int state) { LOGINT("%s\n", FUNCNAME); lirq_w( FGA_ISLOCAL1, INT_LOCAL1, FGA_ICRLOCAL1, state ); }
+void fga002_device::lirq2_w(int state) { LOGINT("%s\n", FUNCNAME); lirq_w( FGA_ISLOCAL2, INT_LOCAL2, FGA_ICRLOCAL2, state ); }
+void fga002_device::lirq3_w(int state) { LOGINT("%s\n", FUNCNAME); lirq_w( FGA_ISLOCAL3, INT_LOCAL3, FGA_ICRLOCAL3, state ); }
+void fga002_device::lirq4_w(int state) { LOGINT("%s\n", FUNCNAME); lirq_w( FGA_ISLOCAL4, INT_LOCAL4, FGA_ICRLOCAL4, state ); }
+void fga002_device::lirq5_w(int state) { LOGINT("%s\n", FUNCNAME); lirq_w( FGA_ISLOCAL5, INT_LOCAL5, FGA_ICRLOCAL5, state ); }
+void fga002_device::lirq6_w(int state) { LOGINT("%s\n", FUNCNAME); lirq_w( FGA_ISLOCAL6, INT_LOCAL6, FGA_ICRLOCAL6, state ); }
+void fga002_device::lirq7_w(int state) { LOGINT("%s\n", FUNCNAME); lirq_w( FGA_ISLOCAL7, INT_LOCAL7, FGA_ICRLOCAL7, state ); }
void fga002_device::write(offs_t offset, uint8_t data){
LOG("%s[%04x] <- %02x - ", FUNCNAME, offset, data);