Merge pull request #1788 from ajrhacker/ls157

Create new 74LS157 device and hook it up to MSM5205 on Rastan
This commit is contained in:
R. Belmont 2016-12-02 16:13:12 -05:00 committed by GitHub
commit 84f9def81f
9 changed files with 344 additions and 14 deletions

View File

@ -355,6 +355,18 @@ if (MACHINES["TTL74153"]~=null) then
}
end
---------------------------------------------------
--
--@src/devices/machine/74157.h,MACHINES["TTL74157"] = true
---------------------------------------------------
if (MACHINES["TTL74157"]~=null) then
files {
MAME_DIR .. "src/devices/machine/74157.cpp",
MAME_DIR .. "src/devices/machine/74157.h",
}
end
---------------------------------------------------
--
--@src/devices/machine/74161.h,MACHINES["TTL74161"] = true

View File

@ -360,6 +360,7 @@ MACHINES["TTL74123"] = true
MACHINES["TTL74145"] = true
MACHINES["TTL74148"] = true
MACHINES["TTL74153"] = true
MACHINES["TTL74157"] = true
--MACHINES["TTL74161"] = true
--MACHINES["TTL74175"] = true
MACHINES["TTL74181"] = true

View File

@ -536,6 +536,7 @@ MACHINES["TTL74123"] = true
MACHINES["TTL74145"] = true
MACHINES["TTL74148"] = true
MACHINES["TTL74153"] = true
--MACHINES["TTL74157"] = true
MACHINES["TTL74161"] = true
MACHINES["TTL74175"] = true
MACHINES["TTL74181"] = true

View File

@ -0,0 +1,202 @@
// license:BSD-3-Clause
// copyright-holders:AJR
/***************************************************************************
74LS157 Quad 2-Line to 1-Line Data Selectors/Multiplexers (TTL)
Often used to help feed 8-bit ROM data into a MSM5205, and for many
other purposes.
74LS158 has inverted outputs; 74LS157 is non-inverting.
***************************************************************************/
#include "emu.h"
#include "74157.h"
//**************************************************************************
// 74LS157 DEVICE
//**************************************************************************
const device_type LS157 = &device_creator<ls157_device>;
//-------------------------------------------------
// ls157_device - constructor
//-------------------------------------------------
ls157_device::ls157_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, LS157, "74LS157 Data Selectors/Multiplexers", tag, owner, clock, "74ls157", __FILE__)
, m_out_cb(*this)
{
m_a = 0;
m_b = 0;
m_select = false;
m_strobe = false;
}
//-------------------------------------------------
// device_start - perform device-specific
// startup
//-------------------------------------------------
void ls157_device::device_start()
{
// resolve callbacks
m_out_cb.resolve_safe();
// register items for save state
save_item(NAME(m_a));
save_item(NAME(m_b));
save_item(NAME(m_select));
save_item(NAME(m_strobe));
}
//**************************************************************************
// DATA INPUTS
//**************************************************************************
//-------------------------------------------------
// a_w -- write nibble to A1-A4
//-------------------------------------------------
WRITE8_MEMBER(ls157_device::a_w)
{
a_w(data);
}
void ls157_device::a_w(u8 data)
{
m_a = data & 0xf;
update_output();
}
//-------------------------------------------------
// b_w -- write nibble to B1-B4
//-------------------------------------------------
WRITE8_MEMBER(ls157_device::b_w)
{
b_w(data);
}
void ls157_device::b_w(u8 data)
{
m_b = data & 0xf;
update_output();
}
//-------------------------------------------------
// ab_w -- write high nibble to A1-A4 and write
// low nibble to B1-B4
//-------------------------------------------------
WRITE8_MEMBER(ls157_device::ab_w)
{
ab_w(data);
}
void ls157_device::ab_w(u8 data)
{
m_a = data >> 4;
m_b = data & 0xf;
update_output();
}
//-------------------------------------------------
// ba_w -- write high nibble to B1-B4 and write
// low nibble to A1-A4
//-------------------------------------------------
WRITE8_MEMBER(ls157_device::ba_w)
{
ba_w(data);
}
void ls157_device::ba_w(u8 data)
{
m_b = data >> 4;
m_a = data & 0xf;
update_output();
}
//-------------------------------------------------
// interleave_w -- write even-numbered bits to
// A1-A4 and write odd-numbered bits to B1-B4
//-------------------------------------------------
WRITE8_MEMBER(ls157_device::interleave_w)
{
interleave_w(data);
}
void ls157_device::interleave_w(u8 data)
{
m_b = ((data >> 4) & 8)
| ((data >> 3) & 4)
| ((data >> 2) & 2)
| ((data >> 1) & 1);
m_a = ((data >> 3) & 8)
| ((data >> 2) & 4)
| ((data >> 1) & 2)
| ((data >> 0) & 1);
update_output();
}
//**************************************************************************
// CONTROL LINE INPUTS
//**************************************************************************
//-------------------------------------------------
// select_w -- set select input
//-------------------------------------------------
WRITE_LINE_MEMBER(ls157_device::select_w)
{
if (m_select != bool(state))
{
m_select = bool(state);
update_output();
}
}
//-------------------------------------------------
// strobe_w -- set strobe input (active low)
//-------------------------------------------------
WRITE_LINE_MEMBER(ls157_device::strobe_w)
{
if (m_strobe != bool(state))
{
m_strobe = bool(state);
// Clear output when strobe goes high
if (m_strobe)
m_out_cb(0);
else
m_out_cb(m_select ? m_b : m_a);
}
}
//-------------------------------------------------
// update_output -- update output lines Y1-Y4
// unless strobe is high
//-------------------------------------------------
void ls157_device::update_output()
{
// S high, strobe low: Y1-Y4 = B1-B4
// S low, strobe low: Y1-Y4 = A1-A4
if (!m_strobe)
m_out_cb(m_select ? m_b : m_a);
}

View File

@ -0,0 +1,95 @@
// license:BSD-3-Clause
// copyright-holders:AJR
/***************************************************************************
74LS157 Quad 2-Line to 1-Line Data Selectors/Multiplexers (TTL)
****************************************************************************
____ ____
SELECT 1 |* \_/ | 16 Vcc
A1 IN 2 | | 15 STROBE
B1 IN 3 | | 14 A4 IN
Y1 OUT 4 | | 13 B4 IN
A2 IN 5 | 74LS157 | 12 Y4 OUT
B2 IN 6 | | 11 A3 IN
Y2 OUT 7 | | 10 B3 IN
GND 8 |___________| 9 Y3 OUT
***************************************************************************/
#pragma once
#ifndef DEVICES_MACHINE_74157_H
#define DEVICES_MACHINE_74157_H
#include "emu.h"
//**************************************************************************
// DEVICE CONFIGURATION MACROS
//**************************************************************************
#define MCFG_74LS157_OUT_CB(_devcb) \
devcb = &ls157_device::set_out_callback(*device, DEVCB_##_devcb);
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
// ======================> ls157_device
class ls157_device : public device_t
{
public:
// construction/destruction
ls157_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
// static configuration
template<class _Object> static devcb_base &set_out_callback(device_t &device, _Object object) { return downcast<ls157_device &>(device).m_out_cb.set_callback(object); }
// data writes
DECLARE_WRITE8_MEMBER(a_w);
void a_w(u8 data);
DECLARE_WRITE8_MEMBER(b_w);
void b_w(u8 data);
DECLARE_WRITE8_MEMBER(ab_w);
void ab_w(u8 data);
DECLARE_WRITE8_MEMBER(ba_w);
void ba_w(u8 data);
DECLARE_WRITE8_MEMBER(interleave_w);
void interleave_w(u8 data);
// line writes
DECLARE_WRITE_LINE_MEMBER(select_w);
DECLARE_WRITE_LINE_MEMBER(strobe_w);
protected:
// device-level overrides
virtual void device_start() override;
private:
// internal helpers
void update_output();
// callbacks
devcb_write8 m_out_cb;
// internal state
u8 m_a;
u8 m_b;
bool m_select;
bool m_strobe;
};
//**************************************************************************
// GLOBAL VARIABLES
//**************************************************************************
// device type definition
extern const device_type LS157;
#endif

View File

@ -252,6 +252,11 @@ void msm5205_device::data_w(int data)
m_data = (data & 0x07) << 1; /* unknown */
}
WRITE8_MEMBER(msm5205_device::data_w)
{
data_w(data);
}
/*
* Handle a change of the selector
*/

View File

@ -52,12 +52,16 @@ public:
// reset signal should keep for 2cycle of VCLK
void reset_w(int reset);
// adpcmata is latched after vclk_interrupt callback
void data_w(int data);
DECLARE_WRITE8_MEMBER(data_w);
// VCLK slave mode option
// if VCLK and reset or data is changed at the same time,
// call vclk_w after data_w and reset_w.
void vclk_w(int vclk);
// option , selected pin selector
void playmode_w(int select);

View File

@ -171,16 +171,16 @@ WRITE8_MEMBER(rastan_state::rastan_bankswitch_w)
WRITE_LINE_MEMBER(rastan_state::rastan_msm5205_vck)
{
if (m_adpcm_data != -1)
if (!state)
return;
m_adpcm_ff = !m_adpcm_ff;
m_adpcm_sel->select_w(m_adpcm_ff);
if (m_adpcm_ff)
{
m_msm->data_w(m_adpcm_data & 0x0f);
m_adpcm_data = -1;
}
else
{
m_adpcm_data = memregion("adpcm")->base()[m_adpcm_pos];
m_adpcm_sel->ba_w(m_adpcm_data[m_adpcm_pos]);
m_adpcm_pos = (m_adpcm_pos + 1) & 0xffff;
m_msm->data_w(m_adpcm_data >> 4);
}
}
@ -192,6 +192,7 @@ WRITE8_MEMBER(rastan_state::rastan_msm5205_address_w)
WRITE8_MEMBER(rastan_state::rastan_msm5205_start_w)
{
m_msm->reset_w(0);
m_adpcm_ff = false;
}
WRITE8_MEMBER(rastan_state::rastan_msm5205_stop_w)
@ -344,7 +345,7 @@ void rastan_state::machine_start()
save_item(NAME(m_sprites_flipscreen));
save_item(NAME(m_adpcm_pos));
save_item(NAME(m_adpcm_data));
save_item(NAME(m_adpcm_ff));
}
void rastan_state::machine_reset()
@ -352,7 +353,7 @@ void rastan_state::machine_reset()
m_sprite_ctrl = 0;
m_sprites_flipscreen = 0;
m_adpcm_pos = 0;
m_adpcm_data = -1;
m_adpcm_ff = false;
}
@ -405,6 +406,9 @@ static MACHINE_CONFIG_START( rastan, rastan_state )
MCFG_MSM5205_PRESCALER_SELECTOR(MSM5205_S48_4B) /* 8 kHz */
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.60)
MCFG_DEVICE_ADD("adpcm_sel", LS157, 0)
MCFG_74LS157_OUT_CB(DEVWRITE8("msm", msm5205_device, data_w))
MCFG_DEVICE_ADD("tc0140syt", TC0140SYT, 0)
MCFG_TC0140SYT_MASTER_CPU("maincpu")
MCFG_TC0140SYT_SLAVE_CPU("audiocpu")

View File

@ -5,6 +5,8 @@
Rastan
*************************************************************************/
#include "machine/74157.h"
#include "sound/msm5205.h"
#include "video/pc080sn.h"
#include "video/pc090oj.h"
@ -17,21 +19,25 @@ public:
m_maincpu(*this, "maincpu"),
m_audiocpu(*this, "audiocpu"),
m_msm(*this, "msm"),
m_adpcm_sel(*this, "adpcm_sel"),
m_adpcm_data(*this, "adpcm"),
m_pc080sn(*this, "pc080sn"),
m_pc090oj(*this, "pc090oj") { }
/* video-related */
uint16_t m_sprite_ctrl;
uint16_t m_sprites_flipscreen;
u16 m_sprite_ctrl;
u16 m_sprites_flipscreen;
/* misc */
int m_adpcm_pos;
int m_adpcm_data;
u16 m_adpcm_pos;
bool m_adpcm_ff;
/* devices */
required_device<cpu_device> m_maincpu;
required_device<cpu_device> m_audiocpu;
required_device<msm5205_device> m_msm;
required_device<ls157_device> m_adpcm_sel;
required_region_ptr<u8> m_adpcm_data;
required_device<pc080sn_device> m_pc080sn;
required_device<pc090oj_device> m_pc090oj;
DECLARE_WRITE8_MEMBER(rastan_msm5205_address_w);