diff options
author | 2014-03-18 11:46:44 +0000 | |
---|---|---|
committer | 2014-03-18 11:46:44 +0000 | |
commit | f65e037141714318cfd32ecf988a7993f6cd9b3f (patch) | |
tree | 4c9a58e4b763733d3e2e80a409da026626978cc7 /src/mess/machine/kb3600.c | |
parent | 15b2c80c62e9eddad3a6322fdef9c22039ce1eaa (diff) |
(MESS) Moved common machine and video chips to emu. (nw)
Diffstat (limited to 'src/mess/machine/kb3600.c')
-rw-r--r-- | src/mess/machine/kb3600.c | 221 |
1 files changed, 0 insertions, 221 deletions
diff --git a/src/mess/machine/kb3600.c b/src/mess/machine/kb3600.c deleted file mode 100644 index de24bd3f822..00000000000 --- a/src/mess/machine/kb3600.c +++ /dev/null @@ -1,221 +0,0 @@ -/********************************************************************** - - General Instruments AY-5-3600 Keyboard Encoder emulation - - Copyright MESS Team. - Visit http://mamedev.org for licensing and usage restrictions. - -*********************************************************************/ - -/* - - TODO: - - - scan timer clock frequency - - more accurate emulation of real chip - -*/ - -#include "kb3600.h" - - - -//************************************************************************** -// MACROS / CONSTANTS -//************************************************************************** - -#define LOG 0 - - - -//************************************************************************** -// GLOBAL VARIABLES -//************************************************************************** - -// devices -const device_type AY3600 = &device_creator<ay3600_device>; - -//************************************************************************** -// LIVE DEVICE -//************************************************************************** - -//------------------------------------------------- -// ay3600_device - constructor -//------------------------------------------------- - -ay3600_device::ay3600_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, AY3600, "AY-5-3600", tag, owner, clock, "ay3600", __FILE__), - m_read_x0(*this), - m_read_x1(*this), - m_read_x2(*this), - m_read_x3(*this), - m_read_x4(*this), - m_read_x5(*this), - m_read_x6(*this), - m_read_x7(*this), - m_read_x8(*this), - m_read_shift(*this), - m_read_control(*this), - m_write_data_ready(*this), - m_write_ako(*this) -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void ay3600_device::device_start() -{ - // resolve callbacks - m_read_x0.resolve_safe(0); - m_read_x1.resolve_safe(0); - m_read_x2.resolve_safe(0); - m_read_x3.resolve_safe(0); - m_read_x4.resolve_safe(0); - m_read_x5.resolve_safe(0); - m_read_x6.resolve_safe(0); - m_read_x7.resolve_safe(0); - m_read_x8.resolve_safe(0); - m_read_shift.resolve_safe(0); - m_read_control.resolve_safe(0); - m_write_data_ready.resolve_safe(); - m_write_ako.resolve_safe(); - - // allocate timers - m_scan_timer = timer_alloc(); - m_scan_timer->adjust(attotime::from_hz(60), 0, attotime::from_hz(60)); - - // state saving - save_item(NAME(m_b)); - save_item(NAME(m_ako)); - save_item(NAME(m_keys_down)); -} - - -//------------------------------------------------- -// device_start - device-specific reset -//------------------------------------------------- - -void ay3600_device::device_reset() -{ - m_ako = 0; - for (int i = 0; i < MAX_KEYS_DOWN; i++) - { - m_keys_down[i] = -1; - } -} - -//------------------------------------------------- -// device_timer - handler timer events -//------------------------------------------------- - -void ay3600_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) -{ - int ako = 0; - - for (int x = 0; x < 9; x++) - { - UINT16 data = 0; - - switch(x) - { - case 0: data = m_read_x0(); break; - case 1: data = m_read_x1(); break; - case 2: data = m_read_x2(); break; - case 3: data = m_read_x3(); break; - case 4: data = m_read_x4(); break; - case 5: data = m_read_x5(); break; - case 6: data = m_read_x6(); break; - case 7: data = m_read_x7(); break; - case 8: data = m_read_x8(); break; - } - - for (int y = 0; y < 10; y++) - { - int b = (x * 10) + y; - - if (b > 63) - { - b -= 64; - b = 0x100 | b; - } - - b |= (m_read_shift() << 6); - b |= (m_read_control() << 7); - - if (BIT(data, y)) - { - bool found = false; - - // is this key already down? - for (int k = 0; k < MAX_KEYS_DOWN; k++) - { - if (b == m_keys_down[k]) - { - found = true; - break; - } - } - - if (!found) - { - ako = 1; - - if (m_b != b) - { - m_b = b; - - m_write_data_ready(1); - return; - } - - // add to the keys down list - for (int k = 0; k < MAX_KEYS_DOWN; k++) - { - if (m_keys_down[k] == -1) - { - m_keys_down[k] = b; - break; - } - } - } - } - else // key released, unmark it from the keys_down table - { - for (int k = 0; k < MAX_KEYS_DOWN; k++) - { - if (b == m_keys_down[k]) - { - m_keys_down[k] = -1; - } - } - } - } - } - - if (!ako) - { - m_b = -1; - } - - if (ako != m_ako) - { - m_write_ako(ako); - m_ako = ako; - } -} - - -//------------------------------------------------- -// b_r - -//------------------------------------------------- - -UINT16 ay3600_device::b_r() -{ - UINT16 data = m_b; - - m_write_data_ready(0); - - return data; -} |