mirror of
https://github.com/holub/mame
synced 2025-05-23 14:19:01 +03:00
(MESS): Checkpoint original Mac keyboard LLE, make it possible to select by #ifdef (nw)
This appears to have regressed when the MCS48 CPU core was recently modernized, although I haven't been able to determine exactly why yet.
This commit is contained in:
parent
dbb4595fcc
commit
7b2256d6af
@ -960,6 +960,7 @@ static MACHINE_CONFIG_START( mac512ke, mac_state )
|
||||
MCFG_VIA6522_ADD("via6522_0", 1000000, mac_via6522_intf)
|
||||
|
||||
MCFG_MACKBD_ADD()
|
||||
MCFG_MACKBD_CLKOUT_HANDLER(WRITELINE(mac_state, mac_kbd_clk_in))
|
||||
|
||||
/* internal ram */
|
||||
MCFG_RAM_ADD(RAM_TAG)
|
||||
|
@ -28,6 +28,9 @@
|
||||
#define MAC_539X_1_TAG "scsi:539x_1"
|
||||
#define MAC_539X_2_TAG "scsi:539x_2"
|
||||
|
||||
// uncomment to run i8021 keyboard in orignal Mac/512(e)/Plus
|
||||
//#define MAC_USE_EMULATED_KBD (1)
|
||||
|
||||
// model helpers
|
||||
#define ADB_IS_BITBANG ((mac->m_model == MODEL_MAC_SE || mac->m_model == MODEL_MAC_CLASSIC) || (mac->m_model >= MODEL_MAC_II && mac->m_model <= MODEL_MAC_IICI) || (mac->m_model == MODEL_MAC_SE30) || (mac->m_model == MODEL_MAC_QUADRA_700))
|
||||
#define ADB_IS_BITBANG_CLASS ((m_model == MODEL_MAC_SE || m_model == MODEL_MAC_CLASSIC) || (m_model >= MODEL_MAC_II && m_model <= MODEL_MAC_IICI) || (m_model == MODEL_MAC_SE30) || (m_model == MODEL_MAC_QUADRA_700))
|
||||
@ -251,6 +254,7 @@ public:
|
||||
UINT32 m_se30_vbl_enable;
|
||||
UINT8 m_nubus_irq_state;
|
||||
|
||||
#ifndef MAC_USE_EMULATED_KBD
|
||||
/* used to store the reply to most keyboard commands */
|
||||
int m_keyboard_reply;
|
||||
|
||||
@ -263,12 +267,13 @@ public:
|
||||
int m_kbd_shift_reg;
|
||||
int m_kbd_shift_count;
|
||||
|
||||
/* keyboard matrix to detect transition */
|
||||
int m_key_matrix[7];
|
||||
|
||||
/* keycode buffer (used for keypad/arrow key transition) */
|
||||
int m_keycode_buf[2];
|
||||
int m_keycode_buf_index;
|
||||
#endif
|
||||
|
||||
/* keyboard matrix to detect transition - macadb needs to stop relying on this */
|
||||
int m_key_matrix[7];
|
||||
|
||||
int m_mouse_bit_x;
|
||||
int m_mouse_bit_y;
|
||||
@ -499,8 +504,10 @@ public:
|
||||
UINT32 screen_update_macsonora(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
|
||||
UINT32 screen_update_macpbwd(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
|
||||
INTERRUPT_GEN_MEMBER(mac_rbv_vbl);
|
||||
#ifndef MAC_USE_EMULATED_KBD
|
||||
TIMER_CALLBACK_MEMBER(kbd_clock);
|
||||
TIMER_CALLBACK_MEMBER(inquiry_timeout_func);
|
||||
#endif
|
||||
TIMER_CALLBACK_MEMBER(mac_6015_tick);
|
||||
TIMER_CALLBACK_MEMBER(mac_scanline_tick);
|
||||
TIMER_CALLBACK_MEMBER(dafb_vbl_tick);
|
||||
|
@ -88,20 +88,11 @@
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include "emu.h"
|
||||
#include "machine/6522via.h"
|
||||
#include "machine/8530scc.h"
|
||||
#include "cpu/m68000/m68000.h"
|
||||
#include "includes/mac.h"
|
||||
#include "machine/applefdc.h"
|
||||
#include "machine/sonydriv.h"
|
||||
#include "machine/ncr5380.h"
|
||||
#include "sound/asc.h"
|
||||
#include "includes/mac.h"
|
||||
#include "debug/debugcpu.h"
|
||||
#include "machine/ram.h"
|
||||
#include "debugger.h"
|
||||
|
||||
#define AUDIO_IS_CLASSIC (m_model <= MODEL_MAC_CLASSIC)
|
||||
@ -134,7 +125,12 @@ const via6522_interface mac_via6522_intf =
|
||||
{
|
||||
DEVCB_DRIVER_MEMBER(mac_state,mac_via_in_a), DEVCB_DRIVER_MEMBER(mac_state,mac_via_in_b),
|
||||
DEVCB_NULL, DEVCB_NULL,
|
||||
|
||||
#ifdef MAC_USE_EMULATED_KBD
|
||||
DEVCB_NULL, DEVCB_DRIVER_MEMBER(mac_state,mac_via_in_cb2),
|
||||
#else
|
||||
DEVCB_NULL, DEVCB_NULL,
|
||||
#endif
|
||||
DEVCB_DRIVER_MEMBER(mac_state,mac_via_out_a), DEVCB_DRIVER_MEMBER(mac_state,mac_via_out_b),
|
||||
DEVCB_NULL, DEVCB_NULL,
|
||||
DEVCB_NULL, DEVCB_DRIVER_MEMBER(mac_state,mac_via_out_cb2),
|
||||
@ -545,7 +541,7 @@ void mac_state::set_memory_overlay(int overlay)
|
||||
|
||||
scan the keyboard, and returns key transition code (or NULL ($7B) if none)
|
||||
*/
|
||||
|
||||
#ifndef MAC_USE_EMULATED_KBD
|
||||
int mac_state::scan_keyboard()
|
||||
{
|
||||
int i, j;
|
||||
@ -671,9 +667,31 @@ void mac_state::keyboard_init()
|
||||
/* purge transmission buffer */
|
||||
m_keycode_buf_index = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/******************* Keyboard <-> VIA communication ***********************/
|
||||
|
||||
WRITE_LINE_MEMBER(mac_state::mac_kbd_clk_in)
|
||||
{
|
||||
printf("CLK: %d\n", state^1);
|
||||
m_via1->write_cb1(state ? 0 : 1);
|
||||
}
|
||||
|
||||
#ifdef MAC_USE_EMULATED_KBD
|
||||
READ8_MEMBER(mac_state::mac_via_in_cb2)
|
||||
{
|
||||
printf("Read %d from keyboard (PC=%x)\n", (m_mackbd->data_r() == ASSERT_LINE) ? 1 : 0, m_maincpu->pc());
|
||||
return (m_mackbd->data_r() == ASSERT_LINE) ? 1 : 0;
|
||||
}
|
||||
|
||||
WRITE8_MEMBER(mac_state::mac_via_out_cb2)
|
||||
{
|
||||
printf("Sending %d to kbd (PC=%x)\n", data, m_maincpu->pc());
|
||||
m_mackbd->data_w((data & 1) ? ASSERT_LINE : CLEAR_LINE);
|
||||
}
|
||||
|
||||
#else // keyboard HLE
|
||||
|
||||
TIMER_CALLBACK_MEMBER(mac_state::kbd_clock)
|
||||
{
|
||||
int i;
|
||||
@ -813,6 +831,7 @@ void mac_state::keyboard_receive(int val)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* *************************************************************************
|
||||
* Mouse
|
||||
@ -1891,11 +1910,13 @@ void mac_state::machine_reset()
|
||||
m_via2_vbl = 0;
|
||||
m_se30_vbl_enable = 0;
|
||||
m_nubus_irq_state = 0xff;
|
||||
#ifndef MAC_USE_EMULATED_KBD
|
||||
m_keyboard_reply = 0;
|
||||
m_kbd_comm = 0;
|
||||
m_kbd_receive = 0;
|
||||
m_kbd_shift_reg = 0;
|
||||
m_kbd_shift_count = 0;
|
||||
#endif
|
||||
m_mouse_bit_x = m_mouse_bit_y = 0;
|
||||
m_pm_data_send = m_pm_data_recv = m_pm_ack = m_pm_req = m_pm_dptr = 0;
|
||||
m_pm_state = 0;
|
||||
@ -2053,9 +2074,16 @@ void mac_state::mac_driver_init(model_t model)
|
||||
}
|
||||
|
||||
/* setup keyboard */
|
||||
#ifndef MAC_USE_EMULATED_KBD
|
||||
keyboard_init();
|
||||
|
||||
m_inquiry_timeout = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mac_state::inquiry_timeout_func),this));
|
||||
#else
|
||||
/* clear key matrix for macadb */
|
||||
for (int i=0; i<7; i++)
|
||||
{
|
||||
m_key_matrix[i] = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* save state stuff */
|
||||
machine().save().register_postload(save_prepost_delegate(FUNC(mac_state::mac_state_load), this));
|
||||
@ -2153,6 +2181,7 @@ void mac_state::vblank_irq()
|
||||
this->adb_vblank();
|
||||
}
|
||||
|
||||
#ifndef MAC_USE_EMULATED_KBD
|
||||
/* handle keyboard */
|
||||
if (m_kbd_comm == TRUE)
|
||||
{
|
||||
@ -2168,6 +2197,7 @@ void mac_state::vblank_irq()
|
||||
kbd_shift_out(keycode);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* signal VBlank on CA1 input on the VIA */
|
||||
if ((m_model < MODEL_MAC_II) || (m_model == MODEL_MAC_PB140) || (m_model == MODEL_MAC_PB160) || (m_model == MODEL_MAC_QUADRA_700))
|
||||
|
@ -19,28 +19,28 @@
|
||||
|
||||
x------- Clock to Mac
|
||||
-x------ Caps Lock
|
||||
--x----- Row 5 (tied to Vcc for keypad)
|
||||
---x---- Row 4
|
||||
----x--- Row 3
|
||||
-----x-- Row 2
|
||||
------x- Row 1
|
||||
-------x Row 0
|
||||
--x----- Row 5 readback (tied to Vcc for keypad)
|
||||
---x---- Row 4 readback
|
||||
----x--- Row 3 readback
|
||||
-----x-- Row 2 readback
|
||||
------x- Row 1 readback
|
||||
-------x Row 0 readback
|
||||
|
||||
Port 1:
|
||||
|
||||
x------- Column 8
|
||||
-x------ Column 7
|
||||
--x----- Column 6
|
||||
---x---- Column 5
|
||||
----x--- Column 4
|
||||
-----x-- Column 3
|
||||
------x- Column 2
|
||||
-------x Column 1
|
||||
x------- Column 8 strobe
|
||||
-x------ Column 7 strobe
|
||||
--x----- Column 6 strobe
|
||||
---x---- Column 5 strobe
|
||||
----x--- Column 4 strobe
|
||||
-----x-- Column 3 strobe
|
||||
------x- Column 2 strobe
|
||||
-------x Column 1 strobe
|
||||
|
||||
Port 2:
|
||||
x--- Command/Apple
|
||||
-x-- Shift
|
||||
--x- Column 0
|
||||
--x- Column 0 strobe
|
||||
---x Data to Mac
|
||||
|
||||
The T1 line is "Option".
|
||||
@ -57,7 +57,7 @@
|
||||
// MACROS / CONSTANTS
|
||||
//**************************************************************************
|
||||
|
||||
#define MACKBD_CPU_TAG "mackbd"
|
||||
#define MACKBD_CPU_TAG "mackbd"
|
||||
|
||||
//**************************************************************************
|
||||
// DEVICE DEFINITIONS
|
||||
@ -83,7 +83,7 @@ ADDRESS_MAP_END
|
||||
|
||||
static ADDRESS_MAP_START( mackbd_io_map, AS_IO, 8, mackbd_device )
|
||||
AM_RANGE(MCS48_PORT_BUS, MCS48_PORT_BUS) AM_READ(p0_r)
|
||||
AM_RANGE(0x2f, 0x2f) AM_WRITE(p0_w)
|
||||
AM_RANGE(0x2f, 0x36) AM_WRITE(p0_w)
|
||||
AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_READWRITE(p1_r, p1_w)
|
||||
AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_READWRITE(p2_r, p2_w)
|
||||
AM_RANGE(MCS48_PORT_T1, MCS48_PORT_T1) AM_READ(t1_r)
|
||||
@ -94,11 +94,90 @@ ADDRESS_MAP_END
|
||||
//-------------------------------------------------
|
||||
|
||||
static MACHINE_CONFIG_FRAGMENT( mackbd )
|
||||
MCFG_CPU_ADD(MACKBD_CPU_TAG, I8021, 100000) // "100,000 operations per second"?
|
||||
MCFG_CPU_ADD(MACKBD_CPU_TAG, I8021, 3000000) // "the approximate clock rate of the MPU is 3 MHz"
|
||||
MCFG_CPU_PROGRAM_MAP(mackbd_map)
|
||||
MCFG_CPU_IO_MAP(mackbd_io_map)
|
||||
MACHINE_CONFIG_END
|
||||
|
||||
static INPUT_PORTS_START( mackbd )
|
||||
PORT_START("COL0")
|
||||
PORT_BIT(0x0001, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_G) PORT_CHAR('g') PORT_CHAR('G')
|
||||
PORT_BIT(0x0002, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_H) PORT_CHAR('h') PORT_CHAR('H')
|
||||
PORT_BIT(0x0004, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F) PORT_CHAR('f') PORT_CHAR('F')
|
||||
PORT_BIT(0x0008, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_D) PORT_CHAR('d') PORT_CHAR('D')
|
||||
PORT_BIT(0x0010, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_S) PORT_CHAR('s') PORT_CHAR('S')
|
||||
PORT_BIT(0x0020, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_A) PORT_CHAR('a') PORT_CHAR('A')
|
||||
|
||||
PORT_START("COL1")
|
||||
PORT_BIT(0x0001, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_B) PORT_CHAR('b') PORT_CHAR('B')
|
||||
PORT_BIT(0x0002, IP_ACTIVE_LOW, IPT_UNKNOWN)
|
||||
PORT_BIT(0x0004, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_V) PORT_CHAR('v') PORT_CHAR('V')
|
||||
PORT_BIT(0x0008, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_C) PORT_CHAR('c') PORT_CHAR('C')
|
||||
PORT_BIT(0x0010, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_X) PORT_CHAR('x') PORT_CHAR('X')
|
||||
PORT_BIT(0x0020, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Z) PORT_CHAR('z') PORT_CHAR('Z')
|
||||
|
||||
PORT_START("COL2")
|
||||
PORT_BIT(0x0001, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_T) PORT_CHAR('t') PORT_CHAR('T')
|
||||
PORT_BIT(0x0002, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Y) PORT_CHAR('y') PORT_CHAR('Y')
|
||||
PORT_BIT(0x0004, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_R) PORT_CHAR('r') PORT_CHAR('R')
|
||||
PORT_BIT(0x0008, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_E) PORT_CHAR('e') PORT_CHAR('E')
|
||||
PORT_BIT(0x0010, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_W) PORT_CHAR('w') PORT_CHAR('W')
|
||||
PORT_BIT(0x0020, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Q) PORT_CHAR('q') PORT_CHAR('Q')
|
||||
|
||||
PORT_START("COL3")
|
||||
PORT_BIT(0x0001, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%')
|
||||
PORT_BIT(0x0002, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('^')
|
||||
PORT_BIT(0x0004, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$')
|
||||
PORT_BIT(0x0008, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#')
|
||||
PORT_BIT(0x0010, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('@')
|
||||
PORT_BIT(0x0020, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!')
|
||||
|
||||
PORT_START("COL4")
|
||||
PORT_BIT(0x0001, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_0) PORT_CHAR('0') PORT_CHAR(')')
|
||||
PORT_BIT(0x0002, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('*')
|
||||
PORT_BIT(0x0004, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('_')
|
||||
PORT_BIT(0x0008, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('&')
|
||||
PORT_BIT(0x0010, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR('(')
|
||||
PORT_BIT(0x0020, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('=') PORT_CHAR('+')
|
||||
|
||||
PORT_START("COL5")
|
||||
PORT_BIT(0x0001, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_P) PORT_CHAR('p') PORT_CHAR('P')
|
||||
PORT_BIT(0x0002, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_I) PORT_CHAR('i') PORT_CHAR('I')
|
||||
PORT_BIT(0x0004, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[') PORT_CHAR('{')
|
||||
PORT_BIT(0x0008, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_U) PORT_CHAR('u') PORT_CHAR('U')
|
||||
PORT_BIT(0x0010, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_O) PORT_CHAR('o') PORT_CHAR('O')
|
||||
PORT_BIT(0x0020, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(']') PORT_CHAR('}')
|
||||
|
||||
PORT_START("COL6")
|
||||
PORT_BIT(0x0001, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR(':')
|
||||
PORT_BIT(0x0002, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_K) PORT_CHAR('k') PORT_CHAR('K')
|
||||
PORT_BIT(0x0004, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR('\'') PORT_CHAR('"')
|
||||
PORT_BIT(0x0008, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_J) PORT_CHAR('j') PORT_CHAR('J')
|
||||
PORT_BIT(0x0010, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_L) PORT_CHAR('l') PORT_CHAR('L')
|
||||
PORT_BIT(0x0020, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_ENTER) PORT_CHAR('\r') PORT_NAME("Return")
|
||||
|
||||
PORT_START("COL7")
|
||||
PORT_BIT(0x0001, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>')
|
||||
PORT_BIT(0x0002, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_M) PORT_CHAR('m') PORT_CHAR('M')
|
||||
PORT_BIT(0x0004, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_N) PORT_CHAR('n') PORT_CHAR('N')
|
||||
PORT_BIT(0x0008, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?')
|
||||
PORT_BIT(0x0010, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<')
|
||||
PORT_BIT(0x0020, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\') PORT_CHAR('|')
|
||||
|
||||
PORT_START("COL8")
|
||||
PORT_BIT(0x0001, IP_ACTIVE_LOW, IPT_UNKNOWN)
|
||||
PORT_BIT(0x0002, IP_ACTIVE_LOW, IPT_UNKNOWN)
|
||||
PORT_BIT(0x0004, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8)
|
||||
PORT_BIT(0x0008, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('`') PORT_CHAR('~')
|
||||
PORT_BIT(0x0010, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ')
|
||||
PORT_BIT(0x0020, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_TAB) PORT_CHAR('\t')
|
||||
|
||||
PORT_START("MODS")
|
||||
PORT_BIT(0x0001, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Caps Lock") PORT_CODE(KEYCODE_CAPSLOCK) PORT_TOGGLE
|
||||
PORT_BIT(0x0002, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Option") PORT_CODE(KEYCODE_LALT) PORT_CHAR(UCHAR_SHIFT_2)
|
||||
PORT_BIT(0x0004, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Shift") PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1)
|
||||
PORT_BIT(0x0008, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Command") PORT_CODE(KEYCODE_LCONTROL)
|
||||
INPUT_PORTS_END
|
||||
|
||||
//-------------------------------------------------
|
||||
// machine_config_additions - device-specific
|
||||
@ -115,6 +194,11 @@ const rom_entry *mackbd_device::device_rom_region() const
|
||||
return ROM_NAME( mackbd );
|
||||
}
|
||||
|
||||
ioport_constructor mackbd_device::device_input_ports() const
|
||||
{
|
||||
return INPUT_PORTS_NAME( mackbd );
|
||||
}
|
||||
|
||||
//**************************************************************************
|
||||
// LIVE DEVICE
|
||||
//**************************************************************************
|
||||
@ -124,8 +208,9 @@ const rom_entry *mackbd_device::device_rom_region() const
|
||||
//-------------------------------------------------
|
||||
|
||||
mackbd_device::mackbd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: device_t(mconfig, MACKBD, "Macintosh keyboard", tag, owner, clock, "mackbd", __FILE__),
|
||||
m_maincpu(*this, MACKBD_CPU_TAG)
|
||||
: device_t(mconfig, MACKBD, "Macintosh keyboard", tag, owner, clock, "mackbd", __FILE__),
|
||||
m_maincpu(*this, MACKBD_CPU_TAG),
|
||||
m_clkout_handler(*this)
|
||||
{
|
||||
}
|
||||
|
||||
@ -135,7 +220,7 @@ mackbd_device::mackbd_device(const machine_config &mconfig, const char *tag, dev
|
||||
|
||||
void mackbd_device::device_start()
|
||||
{
|
||||
// m_out_reset_func.resolve(m_out_reset_cb, *this);
|
||||
m_clkout_handler.resolve_safe();
|
||||
}
|
||||
|
||||
|
||||
@ -145,36 +230,103 @@ void mackbd_device::device_start()
|
||||
|
||||
void mackbd_device::device_reset()
|
||||
{
|
||||
p0 = p1 = p2 = 0;
|
||||
p0 = 0x3f;
|
||||
data_from_mac = data_to_mac = 0;
|
||||
}
|
||||
|
||||
void mackbd_device::scan_kbd_col(int col)
|
||||
{
|
||||
char tempcol[8];
|
||||
UINT16 keydata;
|
||||
|
||||
// read the selected col
|
||||
sprintf(tempcol, "COL%d", col);
|
||||
keydata = ioport(tempcol)->read();
|
||||
|
||||
p0 &= ~0x3f;
|
||||
p0 |= (keydata & 0x3f);
|
||||
|
||||
// set modifier bits in p2
|
||||
p2 = ioport("MODS")->read() & 0xc;
|
||||
}
|
||||
|
||||
READ8_MEMBER(mackbd_device::p0_r)
|
||||
{
|
||||
return 0x20; // 0x20 indicates we're a keyboard rather than the keypad
|
||||
UINT8 ret = p0;
|
||||
|
||||
// capslock
|
||||
if (ioport("MODS")->read() & 0x1)
|
||||
{
|
||||
ret |= 0x40;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
WRITE8_MEMBER(mackbd_device::p0_w)
|
||||
{
|
||||
if (!(data & 2))
|
||||
{
|
||||
scan_kbd_col(0);
|
||||
}
|
||||
|
||||
if (data & 0x80)
|
||||
{
|
||||
m_clkout_handler(ASSERT_LINE);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_clkout_handler(CLEAR_LINE);
|
||||
// machine().scheduler().boost_interleave(attotime::zero, attotime::from_usec(10));
|
||||
}
|
||||
}
|
||||
|
||||
READ8_MEMBER(mackbd_device::p1_r)
|
||||
{
|
||||
return 0;
|
||||
return p1;
|
||||
}
|
||||
|
||||
WRITE8_MEMBER(mackbd_device::p1_w)
|
||||
{
|
||||
data ^= 0xff;
|
||||
if (data & 0x01) scan_kbd_col(1);
|
||||
if (data & 0x02) scan_kbd_col(2);
|
||||
if (data & 0x04) scan_kbd_col(3);
|
||||
if (data & 0x08) scan_kbd_col(4);
|
||||
if (data & 0x10) scan_kbd_col(5);
|
||||
if (data & 0x20) scan_kbd_col(6);
|
||||
if (data & 0x40) scan_kbd_col(7);
|
||||
if (data & 0x80) scan_kbd_col(8);
|
||||
}
|
||||
|
||||
READ8_MEMBER(mackbd_device::p2_r)
|
||||
{
|
||||
return 0;
|
||||
return p2 | data_from_mac;
|
||||
}
|
||||
|
||||
WRITE8_MEMBER(mackbd_device::p2_w)
|
||||
{
|
||||
// prevent key scan accesses to the port from messing with the data line (how does this work on h/w?)
|
||||
if (m_maincpu->pc() != 0x19e && m_maincpu->pc() != 0x1a3)
|
||||
{
|
||||
data_to_mac = data_from_mac = (data & 1);
|
||||
// printf("data to/from mac = %d (PC=%x)\n", data_to_mac, m_maincpu->pc());
|
||||
}
|
||||
}
|
||||
|
||||
READ8_MEMBER(mackbd_device::t1_r)
|
||||
{
|
||||
return 0;
|
||||
return (ioport("MODS")->read() & 0x2) ? 0xff : 0x00;
|
||||
}
|
||||
|
||||
READ_LINE_MEMBER(mackbd_device::data_r)
|
||||
{
|
||||
return data_to_mac ? ASSERT_LINE : CLEAR_LINE;
|
||||
}
|
||||
|
||||
WRITE_LINE_MEMBER(mackbd_device::data_w)
|
||||
{
|
||||
data_from_mac = (state == ASSERT_LINE) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
@ -11,20 +11,23 @@
|
||||
// MACROS / CONSTANTS
|
||||
//**************************************************************************
|
||||
|
||||
#define MACKBD_TAG "mackbd"
|
||||
#define MACKBD_TAG "mackbd"
|
||||
|
||||
//**************************************************************************
|
||||
// INTERFACE CONFIGURATION MACROS
|
||||
//**************************************************************************
|
||||
|
||||
#define MCFG_MACKBD_ADD() \
|
||||
MCFG_DEVICE_ADD(MACKBD_TAG, MACKBD, 0)
|
||||
MCFG_DEVICE_ADD(MACKBD_TAG, MACKBD, 0)
|
||||
|
||||
#define MCFG_MACKBD_REPLACE() \
|
||||
MCFG_DEVICE_REPLACE(MACKBD_TAG, MACKBD, 0)
|
||||
MCFG_DEVICE_REPLACE(MACKBD_TAG, MACKBD, 0)
|
||||
|
||||
#define MCFG_MACKBD_REMOVE() \
|
||||
MCFG_DEVICE_REMOVE(MACKBD_TAG)
|
||||
MCFG_DEVICE_REMOVE(MACKBD_TAG)
|
||||
|
||||
#define MCFG_MACKBD_CLKOUT_HANDLER(_devcb) \
|
||||
devcb = &mackbd_device::set_clkout_handler(*device, DEVCB2_##_devcb);
|
||||
|
||||
//**************************************************************************
|
||||
// TYPE DEFINITIONS
|
||||
@ -35,8 +38,11 @@
|
||||
class mackbd_device : public device_t
|
||||
{
|
||||
public:
|
||||
// static config helper
|
||||
template<class _Object> static devcb2_base &set_clkout_handler(device_t &device, _Object object) { return downcast<mackbd_device &>(device).m_clkout_handler.set_callback(object); }
|
||||
|
||||
// construction/destruction
|
||||
mackbd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
mackbd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
|
||||
DECLARE_READ8_MEMBER(p0_r);
|
||||
DECLARE_WRITE8_MEMBER(p0_w);
|
||||
@ -46,18 +52,25 @@ public:
|
||||
DECLARE_WRITE8_MEMBER(p2_w);
|
||||
DECLARE_READ8_MEMBER(t1_r);
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
virtual machine_config_constructor device_mconfig_additions() const;
|
||||
virtual const rom_entry *device_rom_region() const;
|
||||
DECLARE_READ_LINE_MEMBER(data_r);
|
||||
DECLARE_WRITE_LINE_MEMBER(data_w);
|
||||
|
||||
required_device<cpu_device> m_maincpu;
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
virtual machine_config_constructor device_mconfig_additions() const;
|
||||
virtual const rom_entry *device_rom_region() const;
|
||||
virtual ioport_constructor device_input_ports() const;
|
||||
|
||||
required_device<cpu_device> m_maincpu;
|
||||
|
||||
private:
|
||||
UINT8 p0, p1, p2, data_from_mac, data_to_mac;
|
||||
|
||||
// devcb_resolved_write_line m_out_reset_func;
|
||||
devcb2_write_line m_clkout_handler;
|
||||
|
||||
void scan_kbd_col(int col);
|
||||
};
|
||||
|
||||
// device type definition
|
||||
|
Loading…
Reference in New Issue
Block a user