mac.cpp: Removed 128k/512k/512ke/Plus keyboard code - those machines were moved to mac128.cpp ages ago.

This commit is contained in:
Vas Crabb 2020-07-01 03:27:28 +10:00
parent 0da8be556f
commit 9c0de481ca
4 changed files with 2 additions and 390 deletions

View File

@ -84,7 +84,7 @@
+------+-----------------+
| P22 | / Clr . |
| P23 | - , * |
| T1 | Ent + |
| T1 | Ent + |
+------+-----------------+
Known part numbers:

View File

@ -47,6 +47,7 @@
#include "emu.h"
#include "includes/mac.h"
#include "cpu/m68000/m68000.h"
#include "cpu/powerpc/ppc.h"
#include "cpu/m6805/m6805.h"
@ -929,17 +930,6 @@ void mac_state::add_base_devices(machine_config &config, bool rtc, bool super_wo
m_scc->intrq_callback().set(FUNC(mac_state::set_scc_interrupt));
}
void mac_state::add_mackbd(machine_config &config)
{
#ifdef MAC_USE_EMULATED_KBD
MACKBD(config, m_mackbd, 0);
m_mackbd->dataout_handler().set(m_via, FUNC(via6522_device::write_cb2));
m_mackbd->clkout_handler().set(FUNC(mac_state::mac_kbd_clk_in));
#else
MACKBD(config, m_mackbd, 0);
#endif
}
void mac_state::add_scsi(machine_config &config, bool cdrom)
{
scsi_port_device &scsibus(SCSI_PORT(config, "scsi"));
@ -1067,7 +1057,6 @@ void mac_state::mac512ke_base(machine_config &config)
m_via1->readpb_handler().set(FUNC(mac_state::mac_via_in_b));
m_via1->writepa_handler().set(FUNC(mac_state::mac_via_out_a));
m_via1->writepb_handler().set(FUNC(mac_state::mac_via_out_b));
m_via1->cb2_handler().set(FUNC(mac_state::mac_via_out_cb2));
m_via1->irq_handler().set(FUNC(mac_state::mac_via_irq));
RAM(config, m_ram);
@ -1077,7 +1066,6 @@ void mac_state::mac512ke_base(machine_config &config)
void mac_state::mac512ke(machine_config &config)
{
mac512ke_base(config);
add_mackbd(config);
}
void mac_state::add_macplus_additions(machine_config &config)
@ -1135,7 +1123,6 @@ void mac_state::macplus(machine_config &config)
{
mac512ke_base(config);
add_macplus_additions(config);
add_mackbd(config);
}
void mac_state::macse(machine_config &config)
@ -1195,7 +1182,6 @@ void mac_state::macprtb(machine_config &config)
m_via1->readpb_handler().set(FUNC(mac_state::mac_via_in_b_pmu));
m_via1->writepa_handler().set(FUNC(mac_state::mac_via_out_a_pmu));
m_via1->writepb_handler().set(FUNC(mac_state::mac_via_out_b_pmu));
m_via1->cb2_handler().set(FUNC(mac_state::mac_via_out_cb2));
m_via1->irq_handler().set(FUNC(mac_state::mac_via_irq));
RAM(config, m_ram);

View File

@ -23,7 +23,6 @@
#include "machine/applefdc.h"
#include "machine/ncr539x.h"
#include "machine/ncr5380.h"
#include "machine/mackbd.h"
#include "machine/macrtc.h"
#include "sound/asc.h"
#include "sound/awacs.h"
@ -35,10 +34,6 @@
#define MAC_SCREEN_NAME "screen"
#define MAC_539X_1_TAG "539x_1"
#define MAC_539X_2_TAG "539x_2"
#define MACKBD_TAG "mackbd"
// uncomment to run i8021 keyboard in original 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))
@ -81,7 +76,6 @@ public:
m_539x_2(*this, MAC_539X_2_TAG),
m_ncr5380(*this, "ncr5380"),
m_fdc(*this, "fdc"),
m_mackbd(*this, MACKBD_TAG),
m_rtc(*this, "rtc"),
m_mouse0(*this, "MOUSE0"),
m_mouse1(*this, "MOUSE1"),
@ -100,7 +94,6 @@ public:
{
}
void add_mackbd(machine_config &config);
void add_scsi(machine_config &config, bool cdrom = false);
void add_base_devices(machine_config &config, bool rtc = true, bool super_woz = false);
void add_asc(machine_config &config, asc_device::asc_type type = asc_device::asc_type::ASC);
@ -265,7 +258,6 @@ private:
optional_device<ncr539x_device> m_539x_2;
optional_device<ncr5380_device> m_ncr5380;
required_device<applefdc_base_device> m_fdc;
optional_device<mackbd_device> m_mackbd;
optional_device<rtc3430042_device> m_rtc;
required_ioport m_mouse0, m_mouse1, m_mouse2;
@ -309,24 +301,6 @@ private:
bool m_main_buffer;
int m_snd_vol;
#ifndef MAC_USE_EMULATED_KBD
/* used to store the reply to most keyboard commands */
int m_keyboard_reply;
/* Keyboard communication in progress? */
int m_kbd_comm;
int m_kbd_receive;
/* timer which is used to time out inquiry */
emu_timer *m_inquiry_timeout;
int m_kbd_shift_reg;
int m_kbd_shift_count;
/* 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];
@ -555,10 +529,6 @@ private:
uint32_t screen_update_macsonora(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
uint32_t screen_update_macpbwd(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
DECLARE_WRITE_LINE_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_adbrefresh_tick);
TIMER_CALLBACK_MEMBER(mac_scanline_tick);
@ -566,7 +536,6 @@ private:
TIMER_CALLBACK_MEMBER(dafb_cursor_tick);
TIMER_CALLBACK_MEMBER(mac_adb_tick); // macadb.c
TIMER_CALLBACK_MEMBER(mac_pmu_tick); // macadb.c
DECLARE_WRITE_LINE_MEMBER(mac_via_out_cb2);
DECLARE_WRITE_LINE_MEMBER(mac_adb_via_out_cb2);
uint8_t mac_via_in_a();
uint8_t mac_via_in_b();
@ -595,10 +564,6 @@ private:
DECLARE_WRITE_LINE_MEMBER(mac_via2_irq);
void dafb_recalc_ints();
void set_scc_waitrequest(int waitrequest);
int scan_keyboard();
void keyboard_init();
void kbd_shift_out(int data);
void keyboard_receive(int val);
void mac_driver_init(model_t model);
void mac_install_memory(offs_t memory_begin, offs_t memory_end, offs_t memory_size, void *memory_data, int is_rom, const char *bank);
offs_t mac_dasm_override(std::ostream &stream, offs_t pc, const util::disasm_interface::data_buffer &opcodes, const util::disasm_interface::data_buffer &params);

View File

@ -506,315 +506,6 @@ uint32_t mac_state::rom_switch_r(offs_t offset)
}
/*
R Nabet 000531 : added keyboard code
*/
/* *************************************************************************
* non-ADB keyboard support
*
* The keyboard uses a i8021 (?) microcontroller.
* It uses a bidirectional synchonous serial line, connected to the VIA (SR feature)
*
* Our emulation is more a hack than anything else - the keyboard controller is
* not emulated, instead we interpret keyboard commands directly. I made
* many guesses, which may be wrong
*
* todo :
* * find the correct model number for the Mac Plus keyboard ?
* * emulate original Macintosh keyboards (2 layouts : US and international)
*
* references :
* * IM III-29 through III-32 and III-39 through III-42
* * IM IV-250
* *************************************************************************/
/*
scan_keyboard()
scan the keyboard, and returns key transition code (or nullptr ($7B) if none)
*/
#ifndef MAC_USE_EMULATED_KBD
int mac_state::scan_keyboard()
{
int i, j;
int keybuf = 0;
int keycode;
if (m_keycode_buf_index)
{
return m_keycode_buf[--m_keycode_buf_index];
}
for (i=0; i<7; i++)
{
keybuf = m_keys[i]->read();
if (keybuf != m_key_matrix[i])
{
/* if state has changed, find first bit which has changed */
if (LOG_KEYBOARD)
logerror("keyboard state changed, %d %X\n", i, keybuf);
for (j=0; j<16; j++)
{
if (((keybuf ^ m_key_matrix[i]) >> j) & 1)
{
/* update m_key_matrix */
m_key_matrix[i] = (m_key_matrix[i] & ~ (1 << j)) | (keybuf & (1 << j));
if (i < 4)
{
/* create key code */
keycode = (i << 5) | (j << 1) | 0x01;
if (! (keybuf & (1 << j)))
{
/* key up */
keycode |= 0x80;
}
return keycode;
}
else if (i < 6)
{
/* create key code */
keycode = ((i & 3) << 5) | (j << 1) | 0x01;
if ((keycode == 0x05) || (keycode == 0x0d) || (keycode == 0x11) || (keycode == 0x1b))
{
/* these keys cause shift to be pressed (for compatibility with mac 128/512) */
if (keybuf & (1 << j))
{
/* key down */
if (! (m_key_matrix[3] & 0x0100))
{
/* shift key is really up */
m_keycode_buf[0] = keycode;
m_keycode_buf[1] = 0x79;
m_keycode_buf_index = 2;
return 0x71; /* "presses" shift down */
}
}
else
{ /* key up */
if (! (m_key_matrix[3] & 0x0100))
{
/* shift key is really up */
m_keycode_buf[0] = keycode | 0x80;
m_keycode_buf[1] = 0x79;
m_keycode_buf_index = 2;
return 0xF1; /* "releases" shift */
}
}
}
if (! (keybuf & (1 << j)))
{
/* key up */
keycode |= 0x80;
}
m_keycode_buf[0] = keycode;
m_keycode_buf_index = 1;
return 0x79;
}
else /* i == 6 */
{
/* create key code */
keycode = (j << 1) | 0x01;
if (! (keybuf & (1 << j)))
{
/* key up */
keycode |= 0x80;
}
m_keycode_buf[0] = keycode;
m_keycode_buf_index = 1;
return 0x79;
}
}
}
}
}
return 0x7B; /* return nullptr */
}
/*
power-up init
*/
void mac_state::keyboard_init()
{
int i;
/* init flag */
m_kbd_comm = false;
m_kbd_receive = false;
m_kbd_shift_reg=0;
m_kbd_shift_count=0;
/* clear key matrix */
for (i=0; i<7; i++)
{
m_key_matrix[i] = 0;
}
/* purge transmission buffer */
m_keycode_buf_index = 0;
}
#endif
/******************* Keyboard <-> VIA communication ***********************/
#ifdef MAC_USE_EMULATED_KBD
WRITE_LINE_MEMBER(mac_state::mac_kbd_clk_in)
{
printf("CLK: %d\n", state^1);
m_via1->write_cb1(state ? 0 : 1);
}
WRITE_LINE_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;
if (m_kbd_comm == true)
{
for (i=0; i<8; i++)
{
/* Put data on CB2 if we are sending*/
if (m_kbd_receive == false)
m_via1->write_cb2(m_kbd_shift_reg&0x80?1:0);
m_kbd_shift_reg <<= 1;
m_via1->write_cb1(0);
m_via1->write_cb1(1);
}
if (m_kbd_receive == true)
{
m_kbd_receive = false;
/* Process the command received from mac */
keyboard_receive(m_kbd_shift_reg & 0xff);
}
else
{
/* Communication is over */
m_kbd_comm = false;
}
}
}
void mac_state::kbd_shift_out(int data)
{
if (m_kbd_comm == true)
{
m_kbd_shift_reg = data;
machine().scheduler().timer_set(attotime::from_msec(1), timer_expired_delegate(FUNC(mac_state::kbd_clock),this));
}
}
WRITE_LINE_MEMBER(mac_state::mac_via_out_cb2)
{
if (m_kbd_comm == false && state == 0)
{
/* Mac pulls CB2 down to initiate communication */
m_kbd_comm = true;
m_kbd_receive = true;
machine().scheduler().timer_set(attotime::from_usec(100), timer_expired_delegate(FUNC(mac_state::kbd_clock),this));
}
if (m_kbd_comm == true && m_kbd_receive == true)
{
/* Shift in what mac is sending */
m_kbd_shift_reg = (m_kbd_shift_reg & ~1) | state;
}
}
/*
called when inquiry times out (1/4s)
*/
TIMER_CALLBACK_MEMBER(mac_state::inquiry_timeout_func)
{
if (LOG_KEYBOARD)
logerror("keyboard enquiry timeout\n");
kbd_shift_out(0x7B); /* always send nullptr */
}
/*
called when a command is received from the mac
*/
void mac_state::keyboard_receive(int val)
{
switch (val)
{
case 0x10:
/* inquiry - returns key transition code, or nullptr ($7B) if time out (1/4s) */
if (LOG_KEYBOARD)
logerror("keyboard command : inquiry\n");
m_inquiry_timeout->adjust(
attotime(0, DOUBLE_TO_ATTOSECONDS(0.25)), 0);
break;
case 0x14:
/* instant - returns key transition code, or nullptr ($7B) */
if (LOG_KEYBOARD)
logerror("keyboard command : instant\n");
kbd_shift_out(scan_keyboard());
break;
case 0x16:
/* model number - resets keyboard, return model number */
if (LOG_KEYBOARD)
logerror("keyboard command : model number\n");
{ /* reset */
int i;
/* clear key matrix */
for (i=0; i<7; i++)
{
m_key_matrix[i] = 0;
}
/* purge transmission buffer */
m_keycode_buf_index = 0;
}
/* format : 1 if another device (-> keypad ?) connected | next device (-> keypad ?) number 1-8
| keyboard model number 1-8 | 1 */
/* keyboards :
3 : mac 512k, US and international layout ? Mac plus ???
other values : Apple II keyboards ?
*/
/* keypads :
??? : standard keypad (always available on Mac Plus) ???
*/
kbd_shift_out(0x17); /* probably wrong */
break;
case 0x36:
/* test - resets keyboard, return ACK ($7D) or NAK ($77) */
if (LOG_KEYBOARD)
logerror("keyboard command : test\n");
kbd_shift_out(0x7D); /* ACK */
break;
default:
if (LOG_KEYBOARD)
logerror("unknown keyboard command 0x%X\n", val);
kbd_shift_out(0);
break;
}
}
#endif
/* *************************************************************************
* Mouse
* *************************************************************************/
@ -2040,13 +1731,6 @@ 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;
@ -2186,16 +1870,11 @@ 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));
@ -2293,24 +1972,6 @@ void mac_state::vblank_irq()
this->adb_vblank();
}
#ifndef MAC_USE_EMULATED_KBD
/* handle keyboard */
if (m_kbd_comm == true && m_kbd_receive == false)
{
int keycode = scan_keyboard();
if (keycode != 0x7B)
{
/* if key pressed, send the code */
logerror("keyboard enquiry successful, keycode %X\n", keycode);
m_inquiry_timeout->reset();
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))
{