From c2c576dad44d3cec80641334838c3daf8c60a172 Mon Sep 17 00:00:00 2001 From: Ryan Holtz Date: Fri, 13 Apr 2018 21:04:28 +0200 Subject: Added skeleton SAA1403 device, nw --- scripts/src/machine.lua | 12 +++ scripts/src/video.lua | 4 +- scripts/target/mame/mess.lua | 3 + src/devices/machine/saa1043.cpp | 78 +++++++++++++++++ src/devices/machine/saa1043.h | 184 ++++++++++++++++++++++++++++++++++++++++ src/mame/drivers/vp415.cpp | 48 ++++++++++- 6 files changed, 326 insertions(+), 3 deletions(-) create mode 100644 src/devices/machine/saa1043.cpp create mode 100644 src/devices/machine/saa1043.h diff --git a/scripts/src/machine.lua b/scripts/src/machine.lua index 8d7fd3d2739..f08a592ffae 100644 --- a/scripts/src/machine.lua +++ b/scripts/src/machine.lua @@ -2457,6 +2457,18 @@ if (MACHINES["S3C44B0"]~=null) then } end +--------------------------------------------------- +-- +--@src/devices/machine/saa1043.h,MACHINES["SAA1043"] = true +--------------------------------------------------- + +if (MACHINES["SAA1043"]~=null) then + files { + MAME_DIR .. "src/devices/machine/saa1043.cpp", + MAME_DIR .. "src/devices/machine/saa1043.h", + } +end + --------------------------------------------------- -- --@src/devices/machine/scnxx562.h,MACHINES["DUSCC"] = true diff --git a/scripts/src/video.lua b/scripts/src/video.lua index 9baca568f33..b3ca841fde0 100644 --- a/scripts/src/video.lua +++ b/scripts/src/video.lua @@ -510,10 +510,10 @@ end --------------------------------------------------- -- ---@src/devices/video/mb88303.h,MACHINES["MB88303"] = true +--@src/devices/video/mb88303.h,VIDEOS["MB88303"] = true --------------------------------------------------- -if (MACHINES["MB88303"]~=null) then +if (VIDEOS["MB88303"]~=null) then files { MAME_DIR .. "src/devices/video/mb88303.cpp", MAME_DIR .. "src/devices/video/mb88303.h", diff --git a/scripts/target/mame/mess.lua b/scripts/target/mame/mess.lua index 7bcff927ace..ebf6ee13acd 100644 --- a/scripts/target/mame/mess.lua +++ b/scripts/target/mame/mess.lua @@ -356,6 +356,7 @@ VIDEOS["GBA_LCD"] = true VIDEOS["MGA2064W"] = true VIDEOS["PPU2C0X"] = true VIDEOS["DP8510"] = true +VIDEOS["MB88303"] = true -------------------------------------------------- -- specify available machine cores @@ -542,6 +543,7 @@ MACHINES["RTC9701"] = true MACHINES["S3520CF"] = true MACHINES["S3C24XX"] = true MACHINES["S3C44B0"] = true +MACHINES["SAA1043"] = true MACHINES["SATURN"] = true --MACHINES["SCSI"] = true MACHINES["SCUDSP"] = true @@ -3701,6 +3703,7 @@ files { MAME_DIR .. "src/mame/drivers/vii.cpp", MAME_DIR .. "src/mame/drivers/vp60.cpp", MAME_DIR .. "src/mame/drivers/vp122.cpp", + MAME_DIR .. "src/mame/drivers/vp415.cpp", MAME_DIR .. "src/mame/drivers/vsmilepro.cpp", MAME_DIR .. "src/mame/drivers/wicat.cpp", MAME_DIR .. "src/mame/drivers/wyse.cpp", diff --git a/src/devices/machine/saa1043.cpp b/src/devices/machine/saa1043.cpp new file mode 100644 index 00000000000..a45b14e0764 --- /dev/null +++ b/src/devices/machine/saa1043.cpp @@ -0,0 +1,78 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz +/*********************************************************************** + + Philips SAA1043 Universal Sync Generator + + TOOD: + - Everything. + +***********************************************************************/ + +#include "emu.h" +#include "saa1043.h" + +DEFINE_DEVICE_TYPE(SAA1043, saa1043_device, "saa1043", "Philips SAA1043") + +/*static*/ const uint32_t saa1043_device::s_line_counts[4] = { 624, 624, 524, 524 }; + +saa1043_device::saa1043_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, SAA1043, tag, owner, clock) + , m_outputs({ *this, *this, *this, *this, *this, *this, + *this, *this, *this, *this, *this, *this, + *this, *this, *this, *this, *this, *this }) +{ + memset(m_outputs_hooked, 0, sizeof(bool) * OUT_COUNT); +} + +void saa1043_device::device_start() +{ + m_h = attotime::from_ticks(320, clock()); + m_line_count = s_line_counts[m_type]; + + // resolve callbacks + for (uint32_t i = 0; i < OUT_COUNT; i++) + { + m_outputs[i].resolve_safe(); + if (m_outputs_hooked[i]) + { + m_timers[i] = timer_alloc(i); + switch(i) + { + case V2: + m_timers[V2]->adjust(m_h * 6, 1); + break; + default: + // Not yet implemented + break; + } + } + } +} + +void saa1043_device::device_reset() +{ + // Clear any existing clock states + for (uint32_t i = 0; i < OUT_COUNT; i++) + { + m_outputs[i](CLEAR_LINE); + } +} + +void saa1043_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +{ + switch (id) + { + case V2: + m_outputs[id](1 - param); + if (param) + m_timers[V2]->adjust(m_h * (m_line_count - 9), 0); + else + m_timers[V2]->adjust(m_h * 9, 1); + break; + + default: + // Not yet implemented + break; + } +} diff --git a/src/devices/machine/saa1043.h b/src/devices/machine/saa1043.h new file mode 100644 index 00000000000..0d8b6507634 --- /dev/null +++ b/src/devices/machine/saa1043.h @@ -0,0 +1,184 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz +/*********************************************************************** + + Philips SAA1043 Universal Sync Generator emulation + + TODO: + - Everything. + +************************************************************************ + _____ _____ + BC 1 |* \_/ | 28 Vdd + FH2 2 | | 27 ID + SI 3 | | 26 CS + FH3 4 | | 25 CB + X 5 | | 24 H2 + Y 6 | | 23 H1 + FD 7 | SAA1043 | 22 DL + FH80 8 | | 21 CLP + VCR 9 | | 20 V2 + OSCO 10 | | 19 V1 + OSCI 11 | | 18 RR + PH 12 | | 17 WMP + NS 13 | | 16 RI + Vss 14 |_____________| 15 ECS + +************************************************************************/ + +#ifndef MAME_MACHINE_SAA1043_H +#define MAME_MACHINE_SAA1043_H + +#pragma once + + + +//************************************************************************** +// INTERFACE CONFIGURATION MACROS +//************************************************************************** + +// NB: This is effectively an aggregate of the X and Y inputs. +#define MCFG_SAA1043_TYPE(_type) \ + &downcast(*device).set_type(_type); + +#define MCFG_SAA1043_BC_CALLBACK(_write) \ + devcb = &downcast(*device).set_bc_callback(DEVCB_##_write); + +#define MCFG_SAA1043_FH2_CALLBACK(_write) \ + devcb = &downcast(*device).set_fh2_callback(DEVCB_##_write); + +#define MCFG_SAA1043_FH3_CALLBACK(_write) \ + devcb = &downcast(*device).set_fh3_callback(DEVCB_##_write); + +#define MCFG_SAA1043_FH80_CALLBACK(_write) \ + devcb = &downcast(*device).set_fh80_callback(DEVCB_##_write); + +#define MCFG_SAA1043_PH_CALLBACK(_write) \ + devcb = &downcast(*device).set_ph_callback(DEVCB_##_write); + +#define MCFG_SAA1043_NS_CALLBACK(_write) \ + devcb = &downcast(*device).set_ns_callback(DEVCB_##_write); + +#define MCFG_SAA1043_RI_CALLBACK(_write) \ + devcb = &downcast(*device).set_ri_callback(DEVCB_##_write); + +#define MCFG_SAA1043_WMP_CALLBACK(_write) \ + devcb = &downcast(*device).set_wmp_callback(DEVCB_##_write); + +#define MCFG_SAA1043_RR_CALLBACK(_write) \ + devcb = &downcast(*device).set_rr_callback(DEVCB_##_write); + +#define MCFG_SAA1043_V1_CALLBACK(_write) \ + devcb = &downcast(*device).set_v1_callback(DEVCB_##_write); + +#define MCFG_SAA1043_V2_CALLBACK(_write) \ + devcb = &downcast(*device).set_v2_callback(DEVCB_##_write); + +#define MCFG_SAA1043_CLP_CALLBACK(_write) \ + devcb = &downcast(*device).set_clp_callback(DEVCB_##_write); + +#define MCFG_SAA1043_DL_CALLBACK(_write) \ + devcb = &downcast(*device).set_dl_callback(DEVCB_##_write); + +#define MCFG_SAA1043_H1_CALLBACK(_write) \ + devcb = &downcast(*device).set_h1_callback(DEVCB_##_write); + +#define MCFG_SAA1043_H2_CALLBACK(_write) \ + devcb = &downcast(*device).set_h2_callback(DEVCB_##_write); + +#define MCFG_SAA1043_CB_CALLBACK(_write) \ + devcb = &downcast(*device).set_cb_callback(DEVCB_##_write); + +#define MCFG_SAA1043_CS_CALLBACK(_write) \ + devcb = &downcast(*device).set_cs_callback(DEVCB_##_write); + +#define MCFG_SAA1043_ID_CALLBACK(_write) \ + devcb = &downcast(*device).set_id_callback(DEVCB_##_write); + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> saa1043_device + +class saa1043_device : public device_t +{ +public: + // construction/destruction + saa1043_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + + enum outputs : uint32_t + { + BC, + FH2, + FH3, + FH80, + PH, + NS, + RI, + WMP, + RR, + V1, + V2, + CLP, + DL, + H1, + H2, + CB, + CS, + ID, + + OUT_COUNT + }; + + enum signal_type : uint32_t + { + PAL, + SECAM, + NTSC, + PAL_M, + }; + + void set_type(signal_type type) { m_type = type; } + + template devcb_base &set_bc_callback(Object &&cb) { m_outputs_hooked[BC] = true; return m_outputs[BC].set_callback(std::forward(cb)); } + template devcb_base &set_fh2_callback(Object &&cb) { m_outputs_hooked[FH2] = true; return m_outputs[FH2].set_callback(std::forward(cb)); } + template devcb_base &set_fh3_callback(Object &&cb) { m_outputs_hooked[FH3] = true; return m_outputs[FH3].set_callback(std::forward(cb)); } + template devcb_base &set_fh80_callback(Object &&cb) { m_outputs_hooked[FH80] = true; return m_outputs[FH80].set_callback(std::forward(cb)); } + template devcb_base &set_ph_callback(Object &&cb) { m_outputs_hooked[PH] = true; return m_outputs[PH].set_callback(std::forward(cb)); } + template devcb_base &set_ns_callback(Object &&cb) { m_outputs_hooked[NS] = true; return m_outputs[NS].set_callback(std::forward(cb)); } + template devcb_base &set_ri_callback(Object &&cb) { m_outputs_hooked[RI] = true; return m_outputs[RI].set_callback(std::forward(cb)); } + template devcb_base &set_wmp_callback(Object &&cb) { m_outputs_hooked[WMP] = true; return m_outputs[WMP].set_callback(std::forward(cb)); } + template devcb_base &set_rr_callback(Object &&cb) { m_outputs_hooked[RR] = true; return m_outputs[RR].set_callback(std::forward(cb)); } + template devcb_base &set_v1_callback(Object &&cb) { m_outputs_hooked[V1] = true; return m_outputs[V1].set_callback(std::forward(cb)); } + template devcb_base &set_v2_callback(Object &&cb) { m_outputs_hooked[V2] = true; return m_outputs[V2].set_callback(std::forward(cb)); } + template devcb_base &set_clp_callback(Object &&cb) { m_outputs_hooked[CLP] = true; return m_outputs[CLP].set_callback(std::forward(cb)); } + template devcb_base &set_dl_callback(Object &&cb) { m_outputs_hooked[DL] = true; return m_outputs[DL].set_callback(std::forward(cb)); } + template devcb_base &set_h1_callback(Object &&cb) { m_outputs_hooked[H1] = true; return m_outputs[H1].set_callback(std::forward(cb)); } + template devcb_base &set_h2_callback(Object &&cb) { m_outputs_hooked[H2] = true; return m_outputs[H2].set_callback(std::forward(cb)); } + template devcb_base &set_cb_callback(Object &&cb) { m_outputs_hooked[CB] = true; return m_outputs[CB].set_callback(std::forward(cb)); } + template devcb_base &set_cs_callback(Object &&cb) { m_outputs_hooked[CS] = true; return m_outputs[CS].set_callback(std::forward(cb)); } + template devcb_base &set_id_callback(Object &&cb) { m_outputs_hooked[ID] = true; return m_outputs[ID].set_callback(std::forward(cb)); } + +protected: + // device-level overrides + virtual void device_start() override; + virtual void device_reset() override; + virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; + +private: + devcb_write_line m_outputs[OUT_COUNT]; + bool m_outputs_hooked[OUT_COUNT]; + emu_timer *m_timers[OUT_COUNT]; + signal_type m_type; + + attotime m_h; + uint32_t m_line_count; + + static const uint32_t s_line_counts[4]; +}; + +// device type definition +DECLARE_DEVICE_TYPE(SAA1043, saa1043_device) + +#endif // MAME_MACHINE_SAA1043_H diff --git a/src/mame/drivers/vp415.cpp b/src/mame/drivers/vp415.cpp index 71b797618f7..608740146f6 100644 --- a/src/mame/drivers/vp415.cpp +++ b/src/mame/drivers/vp415.cpp @@ -52,6 +52,7 @@ #include "machine/i8155.h" #include "machine/i8255.h" +#include "machine/saa1043.h" #include "video/mb88303.h" class vp415_state : public driver_device @@ -89,6 +90,8 @@ public: DECLARE_READ8_MEMBER(drive_i8255_pc_r); DECLARE_WRITE8_MEMBER(drive_cpu_port1_w); + DECLARE_WRITE_LINE_MEMBER(refv_w); + static const char* Z80CPU_TAG; static const char* Z80RAM_TAG; static const char* CTRLCPU_TAG; @@ -102,6 +105,7 @@ public: static const char* I8155_TAG; static const char* I8255_TAG; static const char* CHARGEN_TAG; + static const char* SYNCGEN_TAG; protected: enum @@ -184,6 +188,27 @@ protected: CTRL_PARITY_BIT = 2, }; + enum + { + I8255PB_COMM1 = 0x01, + I8255PB_COMM2 = 0x02, + I8255PB_COMM3 = 0x04, + I8255PB_COMM4 = 0x08, + I8255PB_RLS_N = 0x10, + I8255PB_SL_PWR = 0x20, + I8255PB_RAD_FS_N = 0x40, + I8255PB_STR1 = 0x80, + + I8255PB_COMM1_BIT = 0, + I8255PB_COMM2_BIT = 1, + I8255PB_COMM3_BIT = 2, + I8255PB_COMM4_BIT = 3, + I8255PB_RLS_N_BIT = 4, + I8255PB_SL_PWR_BIT = 5, + I8255PB_RAD_FS_N_BIT = 6, + I8255PB_STR1_BIT = 7, + }; + virtual void video_start() override; void z80_program_map(address_map &map); @@ -214,6 +239,8 @@ protected: uint8_t m_aux_status_reg; uint8_t m_diag_status_reg; uint8_t m_intn_lines[2]; + + uint8_t m_refv; }; /*static*/ const char* vp415_state::Z80CPU_TAG = "z80cpu"; @@ -229,6 +256,7 @@ protected: /*static*/ const char* vp415_state::I8155_TAG = "i8155"; /*static*/ const char* vp415_state::I8255_TAG = "i8255"; /*static*/ const char* vp415_state::CHARGEN_TAG = "mb88303"; +/*static*/ const char* vp415_state::SYNCGEN_TAG = "saa1043"; void vp415_state::machine_reset() { @@ -248,6 +276,12 @@ void vp415_state::machine_start() { } +WRITE_LINE_MEMBER(vp415_state::refv_w) +{ + m_refv = state; + m_drivecpu->set_input_line(MCS51_INT0_LINE, m_refv ? ASSERT_LINE : CLEAR_LINE); +} + // CPU Datagrabber Module (W) WRITE8_MEMBER(vp415_state::ncr5385_w) @@ -475,7 +509,16 @@ WRITE8_MEMBER(vp415_state::drive_i8255_pa_w) WRITE8_MEMBER(vp415_state::drive_i8255_pb_w) { - logerror("%s: drive_i8255_pb_w: %02x\n", machine().describe_context(), data); + logerror("%s: drive_i8255_pb_w: COMM-1:%d, COMM-2:%d, COMM-3:%d, COMM-4:%d, /RLS:%d, SL-PWR:%d, /RAD-FS:%d, STR1:%d\n" + , machine().describe_context() + , BIT(data, I8255PB_COMM1_BIT) + , BIT(data, I8255PB_COMM2_BIT) + , BIT(data, I8255PB_COMM3_BIT) + , BIT(data, I8255PB_COMM4_BIT) + , BIT(data, I8255PB_RLS_N_BIT) + , BIT(data, I8255PB_SL_PWR_BIT) + , BIT(data, I8255PB_RAD_FS_N_BIT) + , BIT(data, I8255PB_STR1_BIT)); } READ8_MEMBER(vp415_state::drive_i8255_pc_r) @@ -561,6 +604,9 @@ MACHINE_CONFIG_START(vp415_state::vp415) MCFG_DEVICE_ADD(CHARGEN_TAG, MB88303, 0) + MCFG_DEVICE_ADD(SYNCGEN_TAG, SAA1043, XTAL(5'000'000)) + MCFG_SAA1043_V2_CALLBACK(WRITELINE(vp415_state, refv_w)) + MCFG_SCREEN_ADD("screen", RASTER) MCFG_SCREEN_REFRESH_RATE(50) MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */) -- cgit v1.2.3