summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/ldv1000.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/machine/ldv1000.cpp')
-rw-r--r--src/devices/machine/ldv1000.cpp205
1 files changed, 97 insertions, 108 deletions
diff --git a/src/devices/machine/ldv1000.cpp b/src/devices/machine/ldv1000.cpp
index 4f7a0196e40..4ee45b098d0 100644
--- a/src/devices/machine/ldv1000.cpp
+++ b/src/devices/machine/ldv1000.cpp
@@ -18,9 +18,10 @@
#include "emu.h"
#include "ldv1000.h"
+
+#include "cpu/z80/z80.h"
#include "machine/i8255.h"
#include "machine/z80ctc.h"
-#include "cpu/z80/z80.h"
#include "machine/z80daisy.h"
@@ -29,11 +30,13 @@
// DEBUGGING
//**************************************************************************
-#define LOG_PORT_IO 0
-#define LOG_STATUS_CHANGES 0
-#define LOG_FRAMES_SEEN 0
-#define LOG_COMMANDS 0
+#define LOG_PORT_IO (1U << 1)
+#define LOG_STATUS_CHANGES (1U << 2)
+#define LOG_FRAMES_SEEN (1U << 3)
+#define LOG_COMMANDS (1U << 4)
+#define VERBOSE (0)
+#include "logmacro.h"
//**************************************************************************
@@ -102,7 +105,7 @@ ROM_END
//-------------------------------------------------
pioneer_ldv1000_device::pioneer_ldv1000_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
- : laserdisc_device(mconfig, PIONEER_LDV1000, tag, owner, clock),
+ : parallel_laserdisc_device(mconfig, PIONEER_LDV1000, tag, owner, clock),
m_z80_cpu(*this, "ldv1000"),
m_z80_ctc(*this, "ldvctc"),
m_multitimer(nullptr),
@@ -131,17 +134,7 @@ pioneer_ldv1000_device::pioneer_ldv1000_device(const machine_config &mconfig, co
void pioneer_ldv1000_device::data_w(uint8_t data)
{
m_command = data;
- if (LOG_COMMANDS)
- logerror("-> COMMAND = %02X (%s)\n", data, (m_portc1 & 0x10) ? "valid" : "invalid");
-}
-
-
-//-------------------------------------------------
-// enter_w - set the state of the ENTER strobe
-//-------------------------------------------------
-
-void pioneer_ldv1000_device::enter_w(uint8_t data)
-{
+ LOGMASKED(LOG_COMMANDS, "-> COMMAND = %02X (%s)\n", data, (m_portc1 & 0x10) ? "valid" : "invalid");
}
@@ -155,9 +148,9 @@ void pioneer_ldv1000_device::device_start()
laserdisc_device::device_start();
// allocate timers
- m_multitimer = timer_alloc(TID_MULTIJUMP);
-
- m_command_strobe_cb.resolve_safe();
+ m_multitimer = timer_alloc(FUNC(pioneer_ldv1000_device::multijump_tick), this);
+ m_vsync_off_timer = timer_alloc(FUNC(pioneer_ldv1000_device::vsync_off), this);
+ m_process_vbi_timer = timer_alloc(FUNC(pioneer_ldv1000_device::process_vbi_data), this);
}
@@ -187,73 +180,72 @@ void pioneer_ldv1000_device::device_reset()
//-------------------------------------------------
-// device_timer - handle timers set by this
-// device
+// vsync_off - clear the VSYNC flag
//-------------------------------------------------
-void pioneer_ldv1000_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+TIMER_CALLBACK_MEMBER(pioneer_ldv1000_device::vsync_off)
{
- switch (id)
- {
- case TID_MULTIJUMP:
- {
- // bit 5 of port B on PPI 1 selects the direction of slider movement
- int direction = (m_portb1 & 0x20) ? 1 : -1;
- advance_slider(direction);
-
- // update down counter and reschedule
- if (--m_counter != 0)
- timer.adjust(MULTIJUMP_TRACK_TIME);
- break;
- }
+ m_vsync = false;
+}
+
- case TID_VSYNC_OFF:
- m_vsync = false;
- break;
+//-------------------------------------------------
+// multijump_tick - move the slider across
+// multiple tracks
+//-------------------------------------------------
- case TID_VBI_DATA_FETCH:
+TIMER_CALLBACK_MEMBER(pioneer_ldv1000_device::multijump_tick)
+{
+ // bit 5 of port B on PPI 1 selects the direction of slider movement
+ int direction = (m_portb1 & 0x20) ? 1 : -1;
+ advance_slider(direction);
+
+ // update down counter and reschedule
+ if (--m_counter != 0)
+ m_multitimer->adjust(MULTIJUMP_TRACK_TIME);
+}
+
+
+//-------------------------------------------------
+// process_vbi_data - process VBI data which was
+// fetched by the parent device
+//-------------------------------------------------
+
+TIMER_CALLBACK_MEMBER(pioneer_ldv1000_device::process_vbi_data)
+{
+ // appears to return data in reverse order
+ uint32_t lines[3];
+ lines[0] = get_field_code(LASERDISC_CODE_LINE1718, false);
+ lines[1] = get_field_code(LASERDISC_CODE_LINE17, false);
+ lines[2] = get_field_code(LASERDISC_CODE_LINE16, false);
+
+ // fill in the details
+ memset(m_vbi, 0, sizeof(m_vbi));
+ if (focus_on() && laser_on())
+ {
+ // loop over lines
+ for (int line = 0; line < 3; line++)
{
- // appears to return data in reverse order
- uint32_t lines[3];
- lines[0] = get_field_code(LASERDISC_CODE_LINE1718, false);
- lines[1] = get_field_code(LASERDISC_CODE_LINE17, false);
- lines[2] = get_field_code(LASERDISC_CODE_LINE16, false);
-
- // fill in the details
- memset(m_vbi, 0, sizeof(m_vbi));
- if (focus_on() && laser_on())
+ uint8_t *dest = &m_vbi[line * 7];
+ uint32_t data = lines[line];
+
+ // the logic only processes leadin/leadout/frame number codes
+ if (data == VBI_CODE_LEADIN || data == VBI_CODE_LEADOUT || (data & VBI_MASK_CAV_PICTURE) == VBI_CODE_CAV_PICTURE)
{
- // loop over lines
- for (int line = 0; line < 3; line++)
- {
- uint8_t *dest = &m_vbi[line * 7];
- uint32_t data = lines[line];
-
- // the logic only processes leadin/leadout/frame number codes
- if (data == VBI_CODE_LEADIN || data == VBI_CODE_LEADOUT || (data & VBI_MASK_CAV_PICTURE) == VBI_CODE_CAV_PICTURE)
- {
- *dest++ = 0x09 | (((data & VBI_MASK_CAV_PICTURE) == VBI_CODE_CAV_PICTURE) ? 0x02 : 0x00);
- *dest++ = 0x08;
- *dest++ = (data >> 16) & 0x0f;
- *dest++ = (data >> 12) & 0x0f;
- *dest++ = (data >> 8) & 0x0f;
- *dest++ = (data >> 4) & 0x0f;
- *dest++ = (data >> 0) & 0x0f;
- }
- }
+ *dest++ = 0x09 | (((data & VBI_MASK_CAV_PICTURE) == VBI_CODE_CAV_PICTURE) ? 0x02 : 0x00);
+ *dest++ = 0x08;
+ *dest++ = (data >> 16) & 0x0f;
+ *dest++ = (data >> 12) & 0x0f;
+ *dest++ = (data >> 8) & 0x0f;
+ *dest++ = (data >> 4) & 0x0f;
+ *dest++ = (data >> 0) & 0x0f;
}
-
- // signal that data is ready and reset the readback index
- m_vbiready = true;
- m_vbiindex = 0;
- break;
}
-
- // pass everything else onto the parent
- default:
- laserdisc_device::device_timer(timer, id, param, ptr);
- break;
}
+
+ // signal that data is ready and reset the readback index
+ m_vbiready = true;
+ m_vbiindex = 0;
}
@@ -309,13 +301,13 @@ void pioneer_ldv1000_device::player_vsync(const vbi_metadata &vbi, int fieldnum,
// signal VSYNC and set a timer to turn it off
m_vsync = true;
- timer_set(screen().scan_period() * 4, TID_VSYNC_OFF);
+ m_vsync_off_timer->adjust(screen().scan_period() * 4);
// also set a timer to fetch the VBI data when it is ready
- timer_set(screen().time_until_pos(19*2), TID_VBI_DATA_FETCH);
+ m_process_vbi_timer->adjust(screen().time_until_pos(19*2));
// boost interleave for the first 1ms to improve communications
- machine().scheduler().boost_interleave(attotime::zero, attotime::from_msec(1));
+ machine().scheduler().perfect_quantum(attotime::from_msec(1));
}
@@ -326,11 +318,9 @@ void pioneer_ldv1000_device::player_vsync(const vbi_metadata &vbi, int fieldnum,
int32_t pioneer_ldv1000_device::player_update(const vbi_metadata &vbi, int fieldnum, const attotime &curtime)
{
- if (LOG_FRAMES_SEEN)
- {
- int frame = frame_from_metadata(vbi);
- if (frame != FRAME_NOT_PRESENT) logerror("== %d\n", frame);
- }
+ int frame = frame_from_metadata(vbi);
+ if (frame != FRAME_NOT_PRESENT)
+ LOGMASKED(LOG_FRAMES_SEEN, "== %d\n", frame);
return fieldnum;
}
@@ -340,7 +330,7 @@ int32_t pioneer_ldv1000_device::player_update(const vbi_metadata &vbi, int field
// an interrupt in the daisy chain
//-------------------------------------------------
-WRITE_LINE_MEMBER( pioneer_ldv1000_device::ctc_interrupt )
+void pioneer_ldv1000_device::ctc_interrupt(int state)
{
m_z80_cpu->set_input_line(0, state ? ASSERT_LINE : CLEAR_LINE);
}
@@ -351,7 +341,7 @@ WRITE_LINE_MEMBER( pioneer_ldv1000_device::ctc_interrupt )
// the decoder/display chips
//-------------------------------------------------
-WRITE8_MEMBER( pioneer_ldv1000_device::z80_decoder_display_port_w )
+void pioneer_ldv1000_device::z80_decoder_display_port_w(offs_t offset, uint8_t data)
{
/*
TX/RX = /A0 (A0=0 -> TX, A0=1 -> RX)
@@ -382,7 +372,7 @@ WRITE8_MEMBER( pioneer_ldv1000_device::z80_decoder_display_port_w )
// decoder/display chips
//-------------------------------------------------
-READ8_MEMBER( pioneer_ldv1000_device::z80_decoder_display_port_r )
+uint8_t pioneer_ldv1000_device::z80_decoder_display_port_r(offs_t offset)
{
// reads from offset 3 constitute actual reads from the display and decoder chips
uint8_t result = 0;
@@ -392,7 +382,7 @@ READ8_MEMBER( pioneer_ldv1000_device::z80_decoder_display_port_r )
if (m_portselect == 4)
{
m_vbiready = false;
- result = m_vbi[m_vbiindex++ % ARRAY_LENGTH(m_vbi)];
+ result = m_vbi[m_vbiindex++ % std::size(m_vbi)];
}
}
return result;
@@ -404,7 +394,7 @@ READ8_MEMBER( pioneer_ldv1000_device::z80_decoder_display_port_r )
// the controlling system
//-------------------------------------------------
-READ8_MEMBER( pioneer_ldv1000_device::z80_controller_r )
+uint8_t pioneer_ldv1000_device::z80_controller_r()
{
// note that this is a cheesy implementation; the real thing relies on exquisite timing
uint8_t result = m_command ^ 0xff;
@@ -417,10 +407,10 @@ READ8_MEMBER( pioneer_ldv1000_device::z80_controller_r )
// z80_controller_w - handle status latch writes
//-------------------------------------------------
-WRITE8_MEMBER( pioneer_ldv1000_device::z80_controller_w )
+void pioneer_ldv1000_device::z80_controller_w(uint8_t data)
{
- if (LOG_STATUS_CHANGES && data != m_status)
- logerror("%s:CONTROLLER.W=%02X\n", machine().describe_context(), data);
+ if (data != m_status)
+ LOGMASKED(LOG_STATUS_CHANGES, "%s:CONTROLLER.W=%02X\n", machine().describe_context(), data);
m_status = data;
}
@@ -430,11 +420,10 @@ WRITE8_MEMBER( pioneer_ldv1000_device::z80_controller_w )
// PPI #0
//-------------------------------------------------
-WRITE8_MEMBER( pioneer_ldv1000_device::ppi0_porta_w )
+void pioneer_ldv1000_device::ppi0_porta_w(uint8_t data)
{
m_counter_start = data;
- if (LOG_PORT_IO)
- logerror("%s:PORTA.0=%02X\n", machine().describe_context(), data);
+ LOGMASKED(LOG_PORT_IO, "%s:PORTA.0=%02X\n", machine().describe_context(), data);
}
@@ -443,7 +432,7 @@ WRITE8_MEMBER( pioneer_ldv1000_device::ppi0_porta_w )
// PPI #0
//-------------------------------------------------
-READ8_MEMBER( pioneer_ldv1000_device::ppi0_portb_r )
+uint8_t pioneer_ldv1000_device::ppi0_portb_r()
{
return m_counter;
}
@@ -454,7 +443,7 @@ READ8_MEMBER( pioneer_ldv1000_device::ppi0_portb_r )
// PPI #0
//-------------------------------------------------
-READ8_MEMBER( pioneer_ldv1000_device::ppi0_portc_r )
+uint8_t pioneer_ldv1000_device::ppi0_portc_r()
{
/*
$10 = /VSYNC
@@ -477,7 +466,7 @@ READ8_MEMBER( pioneer_ldv1000_device::ppi0_portc_r )
// PPI #0
//-------------------------------------------------
-WRITE8_MEMBER( pioneer_ldv1000_device::ppi0_portc_w )
+void pioneer_ldv1000_device::ppi0_portc_w(uint8_t data)
{
/*
$01 = preload on up/down counters
@@ -489,9 +478,9 @@ WRITE8_MEMBER( pioneer_ldv1000_device::ppi0_portc_w )
// set the new value
uint8_t prev = m_portc0;
m_portc0 = data;
- if (LOG_PORT_IO && ((data ^ prev) & 0x0f) != 0)
+ if ((data ^ prev) & 0x0f)
{
- logerror("%s:PORTC.0=%02X%s%s%s\n", machine().describe_context(), data,
+ LOGMASKED(LOG_PORT_IO, "%s:PORTC.0=%02X%s%s%s\n", machine().describe_context(), data,
(data & 0x01) ? " PRELOAD" : "",
!(data & 0x02) ? " /MULTIJUMP" : "",
(data & 0x04) ? " SCANMODE" : "");
@@ -512,7 +501,7 @@ WRITE8_MEMBER( pioneer_ldv1000_device::ppi0_portc_w )
// PPI #1
//-------------------------------------------------
-READ8_MEMBER( pioneer_ldv1000_device::ppi1_porta_r )
+uint8_t pioneer_ldv1000_device::ppi1_porta_r()
{
/*
$01 = /FOCS LOCK
@@ -562,7 +551,7 @@ READ8_MEMBER( pioneer_ldv1000_device::ppi1_porta_r )
// PPI #1
//-------------------------------------------------
-WRITE8_MEMBER( pioneer_ldv1000_device::ppi1_portb_w )
+void pioneer_ldv1000_device::ppi1_portb_w(uint8_t data)
{
/*
$01 = /FOCS ON
@@ -578,9 +567,9 @@ WRITE8_MEMBER( pioneer_ldv1000_device::ppi1_portb_w )
// set the new value
uint8_t prev = m_portb1;
m_portb1 = data;
- if (LOG_PORT_IO && ((data ^ prev) & 0xff) != 0)
+ if ((data ^ prev) & 0xff)
{
- logerror("%s:PORTB.1=%02X: %s%s%s%s%s%s\n", machine().describe_context(), data,
+ LOGMASKED(LOG_PORT_IO, "%s:PORTB.1=%02X: %s%s%s%s%s%s\n", machine().describe_context(), data,
!(data & 0x01) ? " FOCSON" : "",
!(data & 0x02) ? " SPDLRUN" : "",
!(data & 0x04) ? " JUMPTRIG" : "",
@@ -615,7 +604,7 @@ WRITE8_MEMBER( pioneer_ldv1000_device::ppi1_portb_w )
// PPI #1
//-------------------------------------------------
-WRITE8_MEMBER( pioneer_ldv1000_device::ppi1_portc_w )
+void pioneer_ldv1000_device::ppi1_portc_w(uint8_t data)
{
/*
$01 = AUD 1
@@ -631,9 +620,9 @@ WRITE8_MEMBER( pioneer_ldv1000_device::ppi1_portc_w )
// set the new value
uint8_t prev = m_portc1;
m_portc1 = data;
- if (LOG_PORT_IO && ((data ^ prev) & 0xcf) != 0)
+ if ((data ^ prev) & 0xcf)
{
- logerror("%s:PORTC.1=%02X%s%s%s%s%s%s%s%s\n", machine().describe_context(), data,
+ LOGMASKED(LOG_PORT_IO, "%s:PORTC.1=%02X%s%s%s%s%s%s%s%s\n", machine().describe_context(), data,
(data & 0x01) ? " AUD1" : "",
(data & 0x02) ? " AUD2" : "",
(data & 0x04) ? " AUDEN" : "",