mirror of
https://github.com/holub/mame
synced 2025-04-21 16:01:56 +03:00
Modernized 74153.c. This still needs updating to devcb/devcb2. (nw)
This commit is contained in:
parent
bd24a25a56
commit
b624317fc6
@ -35,153 +35,32 @@
|
||||
|
||||
#include "emu.h"
|
||||
#include "machine/74153.h"
|
||||
#include "devlegcy.h"
|
||||
|
||||
|
||||
struct ttl74153_state
|
||||
{
|
||||
/* callback */
|
||||
void (*output_cb)(device_t *device);
|
||||
|
||||
/* inputs */
|
||||
int a; /* pin 14 */
|
||||
int b; /* pin 2 */
|
||||
int input_lines[2][4]; /* pins 3-6,10-13 */
|
||||
int enable[2]; /* pins 1,15 */
|
||||
|
||||
/* output */
|
||||
int output[2]; /* pins 7,9 */
|
||||
|
||||
/* internals */
|
||||
int last_output[2];
|
||||
};
|
||||
|
||||
INLINE ttl74153_state *get_safe_token(device_t *device)
|
||||
{
|
||||
assert(device != NULL);
|
||||
assert(device->type() == TTL74153);
|
||||
|
||||
return (ttl74153_state *)downcast<ttl74153_device *>(device)->token();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ttl74153_update(device_t *device)
|
||||
{
|
||||
ttl74153_state *state = get_safe_token(device);
|
||||
int sel;
|
||||
int section;
|
||||
|
||||
|
||||
sel = (state->b << 1) | state->a;
|
||||
|
||||
|
||||
/* process both sections */
|
||||
for (section = 0; section < 2; section++)
|
||||
{
|
||||
if (state->enable[section])
|
||||
state->output[section] = 0; // row 1 in truth table
|
||||
else
|
||||
state->output[section] = state->input_lines[section][sel];
|
||||
}
|
||||
|
||||
|
||||
/* call callback if either of the outputs changed */
|
||||
if ( state->output_cb &&
|
||||
((state->output[0] != state->last_output[0]) ||
|
||||
(state->output[1] != state->last_output[1])))
|
||||
{
|
||||
state->last_output[0] = state->output[0];
|
||||
state->last_output[1] = state->output[1];
|
||||
|
||||
state->output_cb(device);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ttl74153_a_w(device_t *device, int data)
|
||||
{
|
||||
ttl74153_state *state = get_safe_token(device);
|
||||
state->a = data ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
void ttl74153_b_w(device_t *device, int data)
|
||||
{
|
||||
ttl74153_state *state = get_safe_token(device);
|
||||
state->b = data ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
void ttl74153_input_line_w(device_t *device, int section, int input_line, int data)
|
||||
{
|
||||
ttl74153_state *state = get_safe_token(device);
|
||||
state->input_lines[section][input_line] = data ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
void ttl74153_enable_w(device_t *device, int section, int data)
|
||||
{
|
||||
ttl74153_state *state = get_safe_token(device);
|
||||
state->enable[section] = data ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
int ttl74153_output_r(device_t *device, int section)
|
||||
{
|
||||
ttl74153_state *state = get_safe_token(device);
|
||||
return state->output[section];
|
||||
}
|
||||
|
||||
|
||||
static DEVICE_START( ttl74153 )
|
||||
{
|
||||
ttl74153_config *config = (ttl74153_config *)device->static_config();
|
||||
ttl74153_state *state = get_safe_token(device);
|
||||
state->output_cb = config->output_cb;
|
||||
|
||||
device->save_item(NAME(state->enable));
|
||||
device->save_item(NAME(state->last_output));
|
||||
device->save_item(NAME(state->input_lines[0][0]));
|
||||
device->save_item(NAME(state->input_lines[0][1]));
|
||||
device->save_item(NAME(state->input_lines[0][2]));
|
||||
device->save_item(NAME(state->input_lines[0][3]));
|
||||
device->save_item(NAME(state->input_lines[1][0]));
|
||||
device->save_item(NAME(state->input_lines[1][1]));
|
||||
device->save_item(NAME(state->input_lines[1][2]));
|
||||
device->save_item(NAME(state->input_lines[1][3]));
|
||||
device->save_item(NAME(state->a));
|
||||
device->save_item(NAME(state->b));
|
||||
}
|
||||
|
||||
|
||||
static DEVICE_RESET( ttl74153 )
|
||||
{
|
||||
ttl74153_state *state = get_safe_token(device);
|
||||
|
||||
state->a = 1;
|
||||
state->b = 1;
|
||||
state->enable[0] = 1;
|
||||
state->enable[1] = 1;
|
||||
state->input_lines[0][0] = 1;
|
||||
state->input_lines[0][1] = 1;
|
||||
state->input_lines[0][2] = 1;
|
||||
state->input_lines[0][3] = 1;
|
||||
state->input_lines[1][0] = 1;
|
||||
state->input_lines[1][1] = 1;
|
||||
state->input_lines[1][2] = 1;
|
||||
state->input_lines[1][3] = 1;
|
||||
|
||||
state->last_output[0] = -1;
|
||||
state->last_output[1] = -1;
|
||||
}
|
||||
|
||||
const device_type TTL74153 = &device_creator<ttl74153_device>;
|
||||
|
||||
ttl74153_device::ttl74153_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: device_t(mconfig, TTL74153, "74153", tag, owner, clock, "74153", __FILE__)
|
||||
: device_t(mconfig, TTL74153, "74153", tag, owner, clock, "74153", __FILE__),
|
||||
m_a(0),
|
||||
m_b(0)
|
||||
{
|
||||
m_token = global_alloc_clear(ttl74153_state);
|
||||
m_input_lines[0][0] = 0;
|
||||
m_input_lines[0][1] = 0;
|
||||
m_input_lines[0][2] = 0;
|
||||
m_input_lines[0][3] = 0;
|
||||
m_input_lines[1][0] = 0;
|
||||
m_input_lines[1][1] = 0;
|
||||
m_input_lines[1][2] = 0;
|
||||
m_input_lines[1][3] = 0;
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
m_enable[i] = 0;
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
m_output[i] = 0;
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
m_last_output[i] = 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
@ -192,6 +71,15 @@ ttl74153_device::ttl74153_device(const machine_config &mconfig, const char *tag,
|
||||
|
||||
void ttl74153_device::device_config_complete()
|
||||
{
|
||||
// inherit a copy of the static data
|
||||
const ttl74153_config *intf = reinterpret_cast<const ttl74153_config *>(static_config());
|
||||
if (intf != NULL)
|
||||
*static_cast<ttl74153_config *>(this) = *intf;
|
||||
|
||||
// or initialize to defaults if none provided
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
@ -200,7 +88,18 @@ void ttl74153_device::device_config_complete()
|
||||
|
||||
void ttl74153_device::device_start()
|
||||
{
|
||||
DEVICE_START_NAME( ttl74153 )(this);
|
||||
save_item(NAME(m_enable));
|
||||
save_item(NAME(m_last_output));
|
||||
save_item(NAME(m_input_lines[0][0]));
|
||||
save_item(NAME(m_input_lines[0][1]));
|
||||
save_item(NAME(m_input_lines[0][2]));
|
||||
save_item(NAME(m_input_lines[0][3]));
|
||||
save_item(NAME(m_input_lines[1][0]));
|
||||
save_item(NAME(m_input_lines[1][1]));
|
||||
save_item(NAME(m_input_lines[1][2]));
|
||||
save_item(NAME(m_input_lines[1][3]));
|
||||
save_item(NAME(m_a));
|
||||
save_item(NAME(m_b));
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
@ -209,5 +108,81 @@ void ttl74153_device::device_start()
|
||||
|
||||
void ttl74153_device::device_reset()
|
||||
{
|
||||
DEVICE_RESET_NAME( ttl74153 )(this);
|
||||
m_a = 1;
|
||||
m_b = 1;
|
||||
m_enable[0] = 1;
|
||||
m_enable[1] = 1;
|
||||
m_input_lines[0][0] = 1;
|
||||
m_input_lines[0][1] = 1;
|
||||
m_input_lines[0][2] = 1;
|
||||
m_input_lines[0][3] = 1;
|
||||
m_input_lines[1][0] = 1;
|
||||
m_input_lines[1][1] = 1;
|
||||
m_input_lines[1][2] = 1;
|
||||
m_input_lines[1][3] = 1;
|
||||
|
||||
m_last_output[0] = -1;
|
||||
m_last_output[1] = -1;
|
||||
}
|
||||
|
||||
|
||||
void ttl74153_device::update()
|
||||
{
|
||||
int sel;
|
||||
int section;
|
||||
|
||||
|
||||
sel = (m_b << 1) | m_a;
|
||||
|
||||
|
||||
/* process both sections */
|
||||
for (section = 0; section < 2; section++)
|
||||
{
|
||||
if (m_enable[section])
|
||||
m_output[section] = 0; // row 1 in truth table
|
||||
else
|
||||
m_output[section] = m_input_lines[section][sel];
|
||||
}
|
||||
|
||||
|
||||
/* call callback if either of the outputs changed */
|
||||
if ( m_output_cb &&
|
||||
((m_output[0] != m_last_output[0]) ||
|
||||
(m_output[1] != m_last_output[1])))
|
||||
{
|
||||
m_last_output[0] = m_output[0];
|
||||
m_last_output[1] = m_output[1];
|
||||
|
||||
m_output_cb(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ttl74153_device::a_w(int data)
|
||||
{
|
||||
m_a = data ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
void ttl74153_device::b_w(int data)
|
||||
{
|
||||
m_b = data ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
void ttl74153_device::input_line_w(int section, int input_line, int data)
|
||||
{
|
||||
m_input_lines[section][input_line] = data ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
void ttl74153_device::enable_w(int section, int data)
|
||||
{
|
||||
m_enable[section] = data ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
int ttl74153_device::output_r(int section)
|
||||
{
|
||||
return m_output[section];
|
||||
}
|
||||
|
@ -40,44 +40,52 @@
|
||||
|
||||
struct ttl74153_config
|
||||
{
|
||||
void (*output_cb)(device_t *device);
|
||||
void (*m_output_cb)(device_t *device);
|
||||
};
|
||||
|
||||
|
||||
#define MCFG_74153_ADD(_tag, _config) \
|
||||
MCFG_DEVICE_ADD(_tag, TTL74153, 0) \
|
||||
MCFG_DEVICE_CONFIG(_config)
|
||||
|
||||
|
||||
|
||||
/* must call TTL74153_update() after setting the inputs */
|
||||
void ttl74153_update(device_t *device);
|
||||
|
||||
void ttl74153_a_w(device_t *device, int data);
|
||||
void ttl74153_b_w(device_t *device, int data);
|
||||
void ttl74153_input_line_w(device_t *device, int section, int input_line, int data);
|
||||
void ttl74153_enable_w(device_t *device, int section, int data);
|
||||
int ttl74153_output_r(device_t *device, int section);
|
||||
|
||||
class ttl74153_device : public device_t
|
||||
class ttl74153_device : public device_t,
|
||||
public ttl74153_config
|
||||
{
|
||||
public:
|
||||
ttl74153_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
~ttl74153_device() { global_free(m_token); }
|
||||
~ttl74153_device() {}
|
||||
|
||||
// access to legacy token
|
||||
void *token() const { assert(m_token != NULL); return m_token; }
|
||||
/* must call update() after setting the inputs */
|
||||
void update();
|
||||
|
||||
void a_w(int data);
|
||||
void b_w(int data);
|
||||
void input_line_w(int section, int input_line, int data);
|
||||
void enable_w(int section, int data);
|
||||
int output_r(int section);
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_config_complete();
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
|
||||
private:
|
||||
// internal state
|
||||
void *m_token;
|
||||
|
||||
/* inputs */
|
||||
int m_a; /* pin 14 */
|
||||
int m_b; /* pin 2 */
|
||||
int m_input_lines[2][4]; /* pins 3-6,10-13 */
|
||||
int m_enable[2]; /* pins 1,15 */
|
||||
|
||||
/* output */
|
||||
int m_output[2]; /* pins 7,9 */
|
||||
|
||||
/* internals */
|
||||
int m_last_output[2];
|
||||
};
|
||||
|
||||
extern const device_type TTL74153;
|
||||
|
||||
#define MCFG_74153_ADD(_tag, _config) \
|
||||
MCFG_DEVICE_ADD(_tag, TTL74153, 0) \
|
||||
MCFG_DEVICE_CONFIG(_config)
|
||||
|
||||
#endif
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "machine/6821pia.h"
|
||||
#include "machine/7474.h"
|
||||
#include "machine/74148.h"
|
||||
#include "machine/74153.h"
|
||||
|
||||
class carpolo_state : public driver_device
|
||||
{
|
||||
@ -18,7 +19,21 @@ public:
|
||||
m_alpharam(*this, "alpharam"),
|
||||
m_spriteram(*this, "spriteram"),
|
||||
m_maincpu(*this, "maincpu"),
|
||||
m_ttl74148_3s (*this, "74148_3s") { }
|
||||
m_ttl74148_3s(*this, "74148_3s"),
|
||||
m_ttl74153_1k(*this, "74153_1k"),
|
||||
m_ttl7474_2s_1(*this, "7474_2s_1"),
|
||||
m_ttl7474_2s_2(*this, "7474_2s_2"),
|
||||
m_ttl7474_2u_1(*this, "7474_2u_1"),
|
||||
m_ttl7474_2u_2(*this, "7474_2u_2"),
|
||||
m_ttl7474_1f_1(*this, "7474_1f_1"),
|
||||
m_ttl7474_1f_2(*this, "7474_1f_2"),
|
||||
m_ttl7474_1d_1(*this, "7474_1d_1"),
|
||||
m_ttl7474_1d_2(*this, "7474_1d_2"),
|
||||
m_ttl7474_1c_1(*this, "7474_1c_1"),
|
||||
m_ttl7474_1c_2(*this, "7474_1c_2"),
|
||||
m_ttl7474_1a_1(*this, "7474_1a_1"),
|
||||
m_ttl7474_1a_2(*this, "7474_1a_2")
|
||||
{}
|
||||
|
||||
required_shared_ptr<UINT8> m_alpharam;
|
||||
required_shared_ptr<UINT8> m_spriteram;
|
||||
@ -33,19 +48,19 @@ public:
|
||||
UINT8 m_last_wheel_value[4];
|
||||
required_device<cpu_device> m_maincpu;
|
||||
required_device<ttl74148_device> m_ttl74148_3s;
|
||||
device_t *m_ttl74153_1k;
|
||||
ttl7474_device *m_ttl7474_2s_1;
|
||||
ttl7474_device *m_ttl7474_2s_2;
|
||||
ttl7474_device *m_ttl7474_2u_1;
|
||||
ttl7474_device *m_ttl7474_2u_2;
|
||||
ttl7474_device *m_ttl7474_1f_1;
|
||||
ttl7474_device *m_ttl7474_1f_2;
|
||||
ttl7474_device *m_ttl7474_1d_1;
|
||||
ttl7474_device *m_ttl7474_1d_2;
|
||||
ttl7474_device *m_ttl7474_1c_1;
|
||||
ttl7474_device *m_ttl7474_1c_2;
|
||||
ttl7474_device *m_ttl7474_1a_1;
|
||||
ttl7474_device *m_ttl7474_1a_2;
|
||||
required_device<ttl74153_device> m_ttl74153_1k;
|
||||
required_device<ttl7474_device> m_ttl7474_2s_1;
|
||||
required_device<ttl7474_device> m_ttl7474_2s_2;
|
||||
required_device<ttl7474_device> m_ttl7474_2u_1;
|
||||
required_device<ttl7474_device> m_ttl7474_2u_2;
|
||||
required_device<ttl7474_device> m_ttl7474_1f_1;
|
||||
required_device<ttl7474_device> m_ttl7474_1f_2;
|
||||
required_device<ttl7474_device> m_ttl7474_1d_1;
|
||||
required_device<ttl7474_device> m_ttl7474_1d_2;
|
||||
required_device<ttl7474_device> m_ttl7474_1c_1;
|
||||
required_device<ttl7474_device> m_ttl7474_1c_2;
|
||||
required_device<ttl7474_device> m_ttl7474_1a_1;
|
||||
required_device<ttl7474_device> m_ttl7474_1a_2;
|
||||
bitmap_ind16 *m_sprite_sprite_collision_bitmap1;
|
||||
bitmap_ind16 *m_sprite_sprite_collision_bitmap2;
|
||||
bitmap_ind16 *m_sprite_goal_collision_bitmap1;
|
||||
|
@ -9,8 +9,6 @@
|
||||
#include "emu.h"
|
||||
#include "cpu/m6502/m6502.h"
|
||||
#include "machine/6821pia.h"
|
||||
#include "machine/7474.h"
|
||||
#include "machine/74153.h"
|
||||
#include "includes/carpolo.h"
|
||||
|
||||
|
||||
@ -260,24 +258,24 @@ INTERRUPT_GEN_MEMBER(carpolo_state::carpolo_timer_interrupt)
|
||||
how much, resulting in only two different possible levels */
|
||||
if (port_value & 0x01)
|
||||
{
|
||||
ttl74153_input_line_w(m_ttl74153_1k, 0, player, 1);
|
||||
ttl74153_input_line_w(m_ttl74153_1k, 1, player, 0);
|
||||
m_ttl74153_1k->input_line_w(0, player, 1);
|
||||
m_ttl74153_1k->input_line_w(1, player, 0);
|
||||
}
|
||||
else if (port_value & 0x02)
|
||||
{
|
||||
ttl74153_input_line_w(m_ttl74153_1k, 0, player, 1);
|
||||
ttl74153_input_line_w(m_ttl74153_1k, 1, player, 1);
|
||||
m_ttl74153_1k->input_line_w(0, player, 1);
|
||||
m_ttl74153_1k->input_line_w(1, player, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ttl74153_input_line_w(m_ttl74153_1k, 0, player, 0);
|
||||
m_ttl74153_1k->input_line_w(0, player, 0);
|
||||
/* the other line is irrelevant */
|
||||
}
|
||||
|
||||
port_value >>= 2;
|
||||
}
|
||||
|
||||
ttl74153_update(m_ttl74153_1k);
|
||||
m_ttl74153_1k->update();
|
||||
}
|
||||
|
||||
// FIXME: Remove trampolines
|
||||
@ -375,10 +373,10 @@ WRITE8_MEMBER(carpolo_state::pia_0_port_b_w)
|
||||
bit 6 - Select pedal 0
|
||||
bit 7 - Select pdeal 1 */
|
||||
|
||||
ttl74153_a_w(m_ttl74153_1k, data & 0x40);
|
||||
ttl74153_b_w(m_ttl74153_1k, data & 0x80);
|
||||
m_ttl74153_1k->a_w(data & 0x40);
|
||||
m_ttl74153_1k->b_w(data & 0x80);
|
||||
|
||||
ttl74153_update(m_ttl74153_1k);
|
||||
m_ttl74153_1k->update();
|
||||
}
|
||||
|
||||
READ8_MEMBER(carpolo_state::pia_0_port_b_r)
|
||||
@ -386,8 +384,8 @@ READ8_MEMBER(carpolo_state::pia_0_port_b_r)
|
||||
/* bit 4 - Pedal bit 0
|
||||
bit 5 - Pedal bit 1 */
|
||||
|
||||
return (ttl74153_output_r(m_ttl74153_1k, 0) << 5) |
|
||||
(ttl74153_output_r(m_ttl74153_1k, 1) << 4);
|
||||
return (m_ttl74153_1k->output_r(0) << 5) |
|
||||
(m_ttl74153_1k->output_r(1) << 4);
|
||||
}
|
||||
|
||||
|
||||
@ -467,22 +465,6 @@ const pia6821_interface carpolo_pia1_intf =
|
||||
|
||||
void carpolo_state::machine_start()
|
||||
{
|
||||
/* find flip-flops */
|
||||
m_ttl7474_2s_1 = machine().device<ttl7474_device>("7474_2s_1");
|
||||
m_ttl7474_2s_2 = machine().device<ttl7474_device>("7474_2s_2");
|
||||
m_ttl7474_2u_1 = machine().device<ttl7474_device>("7474_2u_1");
|
||||
m_ttl7474_2u_2 = machine().device<ttl7474_device>("7474_2u_2");
|
||||
m_ttl7474_1f_1 = machine().device<ttl7474_device>("7474_1f_1");
|
||||
m_ttl7474_1f_2 = machine().device<ttl7474_device>("7474_1f_2");
|
||||
m_ttl7474_1d_1 = machine().device<ttl7474_device>("7474_1d_1");
|
||||
m_ttl7474_1d_2 = machine().device<ttl7474_device>("7474_1d_2");
|
||||
m_ttl7474_1c_1 = machine().device<ttl7474_device>("7474_1c_1");
|
||||
m_ttl7474_1c_2 = machine().device<ttl7474_device>("7474_1c_2");
|
||||
m_ttl7474_1a_1 = machine().device<ttl7474_device>("7474_1a_1");
|
||||
m_ttl7474_1a_2 = machine().device<ttl7474_device>("7474_1a_2");
|
||||
|
||||
m_ttl74153_1k = machine().device("74153_1k");
|
||||
|
||||
save_item(NAME(m_ball_screen_collision_cause));
|
||||
save_item(NAME(m_car_ball_collision_x));
|
||||
save_item(NAME(m_car_ball_collision_y));
|
||||
@ -540,6 +522,6 @@ void carpolo_state::machine_reset()
|
||||
|
||||
|
||||
/* set up the pedal handling chips */
|
||||
ttl74153_enable_w(m_ttl74153_1k, 0, 0);
|
||||
ttl74153_enable_w(m_ttl74153_1k, 1, 0);
|
||||
m_ttl74153_1k->enable_w(0, 0);
|
||||
m_ttl74153_1k->enable_w(1, 0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user