diff options
author | 2020-09-16 22:29:50 -0400 | |
---|---|---|
committer | 2020-09-16 22:29:50 -0400 | |
commit | fd2b3cedabd6e88a0e2e6012633d193dcdedfbd1 (patch) | |
tree | 138000be2939de8b14e21540a6f8a920146aa4f3 | |
parent | 7270ef632c9a713937314bdd2ee31270a8923894 (diff) |
Mac updates [R. Belmont]
- Moved macadb out of mac_state into a device
- Moved SE and Classic to mac128 where they fit in much better
- Removed a bunch of cruft from mac_state
- Slowed Egret and Cuda down to the correct clocks
-rw-r--r-- | src/devices/sound/asc.cpp | 5 | ||||
-rw-r--r-- | src/mame/drivers/mac.cpp | 300 | ||||
-rw-r--r-- | src/mame/drivers/mac128.cpp | 254 | ||||
-rw-r--r-- | src/mame/includes/mac.h | 94 | ||||
-rw-r--r-- | src/mame/machine/cuda.cpp | 2 | ||||
-rw-r--r-- | src/mame/machine/egret.cpp | 15 | ||||
-rw-r--r-- | src/mame/machine/egret.h | 4 | ||||
-rw-r--r-- | src/mame/machine/mac.cpp | 503 | ||||
-rw-r--r-- | src/mame/machine/macadb.cpp | 490 | ||||
-rw-r--r-- | src/mame/machine/macadb.h | 110 |
10 files changed, 759 insertions, 1018 deletions
diff --git a/src/devices/sound/asc.cpp b/src/devices/sound/asc.cpp index 79c13c90836..e03494040ab 100644 --- a/src/devices/sound/asc.cpp +++ b/src/devices/sound/asc.cpp @@ -137,6 +137,11 @@ void asc_device::sound_stream_update(sound_stream &stream, std::vector<read_stre if (m_fifo_cap_a < 0x1ff) { m_regs[R_FIFOSTAT-0x800] |= 1; // fifo A less than half full + + if (m_fifo_cap_a == 0) // fifo A fully empty + { + m_regs[R_FIFOSTAT-0x800] |= 2; // fifo A empty + } } } break; diff --git a/src/mame/drivers/mac.cpp b/src/mame/drivers/mac.cpp index f97b71647d0..2db4d331526 100644 --- a/src/mame/drivers/mac.cpp +++ b/src/mame/drivers/mac.cpp @@ -88,9 +88,6 @@ #include "bus/nubus/pds30_30hr.h" #include "bus/nubus/pds30_mc30.h" -// 68000 PDS cards -#include "bus/macpds/pds_tpdfpd.h" - #include "machine/macadb.h" #include "softlist.h" #include "speaker.h" @@ -582,35 +579,6 @@ void mac_state::mac_5396_w(offs_t offset, uint8_t data) ADDRESS MAPS ***************************************************************************/ -void mac_state::mac512ke_map(address_map &map) -{ - map(0x800000, 0x9fffff).r(FUNC(mac_state::mac_scc_r)); - map(0xa00000, 0xbfffff).w(FUNC(mac_state::mac_scc_w)); - map(0xc00000, 0xdfffff).rw(FUNC(mac_state::mac_iwm_r), FUNC(mac_state::mac_iwm_w)); - map(0xe80000, 0xefffff).rw(FUNC(mac_state::mac_via_r), FUNC(mac_state::mac_via_w)); - map(0xfffff0, 0xffffff).rw(FUNC(mac_state::mac_autovector_r), FUNC(mac_state::mac_autovector_w)); -} - -void mac_state::macplus_map(address_map &map) -{ - map(0x580000, 0x5fffff).rw(FUNC(mac_state::macplus_scsi_r), FUNC(mac_state::macplus_scsi_w)); - map(0x800000, 0x9fffff).r(FUNC(mac_state::mac_scc_r)); - map(0xa00000, 0xbfffff).w(FUNC(mac_state::mac_scc_w)); - map(0xc00000, 0xdfffff).rw(FUNC(mac_state::mac_iwm_r), FUNC(mac_state::mac_iwm_w)); - map(0xe80000, 0xefffff).rw(FUNC(mac_state::mac_via_r), FUNC(mac_state::mac_via_w)); - map(0xfffff0, 0xffffff).rw(FUNC(mac_state::mac_autovector_r), FUNC(mac_state::mac_autovector_w)); -} - -void mac_state::macse_map(address_map &map) -{ - map(0x580000, 0x5fffff).rw(FUNC(mac_state::macplus_scsi_r), FUNC(mac_state::macplus_scsi_w)); - map(0x900000, 0x9fffff).r(FUNC(mac_state::mac_scc_r)); - map(0xb00000, 0xbfffff).w(FUNC(mac_state::mac_scc_w)); - map(0xd00000, 0xdfffff).rw(FUNC(mac_state::mac_iwm_r), FUNC(mac_state::mac_iwm_w)); - map(0xe80000, 0xefffff).rw(FUNC(mac_state::mac_via_r), FUNC(mac_state::mac_via_w)); - map(0xfffff0, 0xffffff).rw(FUNC(mac_state::mac_autovector_r), FUNC(mac_state::mac_autovector_w)); -} - void mac_state::macprtb_map(address_map &map) { map(0x900000, 0x93ffff).rom().region("bootrom", 0).mirror(0x0c0000); @@ -902,11 +870,6 @@ static void mac_pds030_cards(device_slot_interface &device) device.option_add("mc30", PDS030_XCEEDMC30); // Micron/XCEED Technology MacroColor 30 } -static void mac_sepds_cards(device_slot_interface &device) -{ - device.option_add("radiusfpd", PDS_SEDISPLAY); // Radius Full Page Display card for SE -} - static void mac_lcpds_cards(device_slot_interface &device) { } @@ -980,9 +943,11 @@ void mac_state::add_egret(machine_config &config, int type) { EGRET(config, m_egret, type); m_egret->reset_callback().set(FUNC(mac_state::cuda_reset_w)); - m_egret->linechange_callback().set(FUNC(mac_state::adb_linechange_w)); + m_egret->linechange_callback().set(m_macadb, FUNC(macadb_device::adb_linechange_w)); m_egret->via_clock_callback().set(m_via1, FUNC(via6522_device::write_cb1)); m_egret->via_data_callback().set(m_via1, FUNC(via6522_device::write_cb2)); + m_macadb->set_mcu_mode(true); + m_macadb->adb_data_callback().set(m_egret, FUNC(egret_device::set_adb_line)); config.set_perfect_quantum(m_maincpu); } @@ -990,9 +955,12 @@ void mac_state::add_cuda(machine_config &config, int type) { CUDA(config, m_cuda, type); m_cuda->reset_callback().set(FUNC(mac_state::cuda_reset_w)); - m_cuda->linechange_callback().set(FUNC(mac_state::adb_linechange_w)); + m_cuda->linechange_callback().set(m_macadb, FUNC(macadb_device::adb_linechange_w)); m_cuda->via_clock_callback().set(m_via1, FUNC(via6522_device::write_cb1)); m_cuda->via_data_callback().set(m_via1, FUNC(via6522_device::write_cb2)); + m_macadb->set_mcu_mode(true); + m_macadb->adb_data_callback().set(m_cuda, FUNC(cuda_device::set_adb_line)); + config.set_perfect_quantum(m_maincpu); } void mac_state::add_asc(machine_config &config, asc_device::asc_type type) @@ -1034,61 +1002,6 @@ void mac_state::add_pb1xx_vias(machine_config &config) m_via2->irq_handler().set(FUNC(mac_state::mac_via2_irq)); } -void mac_state::mac512ke_base(machine_config &config) -{ - M68000(config, m_maincpu, C7M); /* 7.8336 MHz */ - m_maincpu->set_addrmap(AS_PROGRAM, &mac_state::mac512ke_map); - m_maincpu->set_dasm_override(FUNC(mac_state::mac_dasm_override)); - config.set_maximum_quantum(attotime::from_hz(60)); - - SCREEN(config, m_screen, SCREEN_TYPE_RASTER); - m_screen->set_raw(C7M*2, MAC_H_TOTAL, 0, MAC_H_VIS, MAC_V_TOTAL, 0, MAC_V_VIS); - m_screen->set_screen_update(FUNC(mac_state::screen_update_mac)); - m_screen->set_palette(m_palette); - - PALETTE(config, m_palette, palette_device::MONOCHROME_INVERTED); - - MCFG_VIDEO_START_OVERRIDE(mac_state,mac) - - SPEAKER(config, "speaker").front_center(); - DAC_8BIT_PWM(config, m_dac, 0); - m_dac->add_route(ALL_OUTPUTS, "speaker", 0.25); // 2 x ls161 - voltage_regulator_device &vreg(VOLTAGE_REGULATOR(config, "vref", 0)); - vreg.add_route(0, "dac", 1.0, DAC_VREF_POS_INPUT); - vreg.add_route(0, "dac", -1.0, DAC_VREF_NEG_INPUT); - - add_base_devices(config, true, false); - - VIA6522(config, m_via1, 1000000); - m_via1->readpa_handler().set(FUNC(mac_state::mac_via_in_a)); - 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->irq_handler().set(FUNC(mac_state::mac_via_irq)); - - RAM(config, m_ram); - m_ram->set_default_size("512K"); -} - -void mac_state::mac512ke(machine_config &config) -{ - mac512ke_base(config); -} - -void mac_state::add_macplus_additions(machine_config &config) -{ - m_maincpu->set_addrmap(AS_PROGRAM, &mac_state::macplus_map); - - add_scsi(config); - - /* internal ram */ - m_ram->set_default_size("4M"); - m_ram->set_extra_options("1M,2M,2560K,4M"); - - // software list - SOFTWARE_LIST(config, "flop35_list").set_original("mac_flop"); -} - void mac_state::add_nubus(machine_config &config, bool bank1, bool bank2) { nubus_device &nubus(NUBUS(config, "nubus", 0)); @@ -1126,43 +1039,6 @@ template <typename T> void mac_state::add_nubus_pds(machine_config &config, cons NUBUS_SLOT(config, slot_tag, "pds", std::forward<T>(opts), nullptr); } -void mac_state::macplus(machine_config &config) -{ - mac512ke_base(config); - add_macplus_additions(config); -} - -void mac_state::macse(machine_config &config) -{ - mac512ke_base(config); - add_macplus_additions(config); - m_maincpu->set_addrmap(AS_PROGRAM, &mac_state::macse_map); - - m_via1->writepb_handler().set(FUNC(mac_state::mac_via_out_b_bbadb)); - m_via1->cb2_handler().set(FUNC(mac_state::mac_adb_via_out_cb2)); - - /* internal ram */ - m_ram->set_default_size("4M"); - m_ram->set_extra_options("2M,2560K,4M"); - - MACPDS(config, "sepds", "maincpu"); - MACPDS_SLOT(config, "pds", "sepds", mac_sepds_cards, nullptr); -} - -void mac_state::macclasc(machine_config &config) -{ - mac512ke_base(config); - add_macplus_additions(config); - m_maincpu->set_addrmap(AS_PROGRAM, &mac_state::macse_map); - - m_via1->writepb_handler().set(FUNC(mac_state::mac_via_out_b_bbadb)); - m_via1->cb2_handler().set(FUNC(mac_state::mac_adb_via_out_cb2)); - - /* internal ram */ - m_ram->set_default_size("4M"); - m_ram->set_extra_options("2M,2560K,4M"); -} - void mac_state::macprtb(machine_config &config) { /* basic machine hardware */ @@ -1184,6 +1060,10 @@ void mac_state::macprtb(machine_config &config) add_scsi(config); add_asc(config, asc_device::asc_type::ASC); + MACADB(config, m_macadb, C15M); + m_macadb->set_pmu_mode(true); + m_macadb->set_pmu_is_via1(true); + VIA6522(config, m_via1, 783360); m_via1->readpa_handler().set(FUNC(mac_state::mac_via_in_a_pmu)); m_via1->readpb_handler().set(FUNC(mac_state::mac_via_in_b_pmu)); @@ -1216,6 +1096,11 @@ void mac_state::macii(machine_config &config, bool cpu, asc_device::asc_type asc add_via1_adb(config, true); add_via2(config); + MACADB(config, m_macadb, C15M); + m_macadb->via_clock_callback().set(m_via1, FUNC(via6522_device::write_cb1)); + m_macadb->via_data_callback().set(m_via1, FUNC(via6522_device::write_cb2)); + m_macadb->adb_irq_callback().set(FUNC(mac_state::adb_irq_w)); + RAM(config, m_ram); m_ram->set_default_size("2M"); m_ram->set_extra_options("8M,32M,64M,96M,128M"); @@ -1290,7 +1175,9 @@ void mac_state::maclc(machine_config &config, bool cpu, bool egret, asc_device:: add_nubus_pds(config, "lcpds", mac_lcpds_cards); if (egret) + { add_egret(config, EGRET_341S0850); + } } void mac_state::maclc2(machine_config &config, bool egret) @@ -1337,7 +1224,9 @@ void mac_state::maclc3(machine_config &config, bool egret) m_ram->set_extra_options("8M,16M,32M,48M,64M,80M"); if (egret) + { add_egret(config, EGRET_341S0851); + } } void mac_state::maclc520(machine_config &config) @@ -1420,6 +1309,11 @@ void mac_state::macse30(machine_config &config) add_via1_adb(config, false); add_via2(config); + MACADB(config, m_macadb, C15M); + m_macadb->via_clock_callback().set(m_via1, FUNC(via6522_device::write_cb1)); + m_macadb->via_data_callback().set(m_via1, FUNC(via6522_device::write_cb2)); + m_macadb->adb_irq_callback().set(FUNC(mac_state::adb_irq_w)); + RAM(config, m_ram); m_ram->set_default_size("2M"); m_ram->set_extra_options("8M,16M,32M,48M,64M,96M,128M"); @@ -1445,6 +1339,9 @@ void mac_state::macpb140(machine_config &config) add_base_devices(config, false, true); add_pb1xx_vias(config); + MACADB(config, m_macadb, C15M); + m_macadb->set_pmu_mode(true); + RAM(config, m_ram); m_ram->set_default_size("2M"); m_ram->set_extra_options("4M,6M,8M"); @@ -1490,6 +1387,9 @@ void mac_state::macpb160(machine_config &config) add_base_devices(config, false, true); add_pb1xx_vias(config); + MACADB(config, m_macadb, C15M); + m_macadb->set_pmu_mode(true); + RAM(config, m_ram); m_ram->set_default_size("4M"); m_ram->set_extra_options("8M,12M,16M"); @@ -1633,6 +1533,7 @@ void mac_state::pwrmac(machine_config &config) m_ram->set_default_size("8M"); m_ram->set_extra_options("16M,32M,64M,128M"); + MACADB(config, m_macadb, C15M); add_cuda(config, CUDA_341S0060); } @@ -1685,127 +1586,9 @@ void mac_state::macqd700(machine_config &config) } static INPUT_PORTS_START( macadb ) - PORT_START("MOUSE0") /* Mouse - button */ - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("Mouse Button") PORT_CODE(MOUSECODE_BUTTON1) - - PORT_START("MOUSE1") /* Mouse - X AXIS */ - PORT_BIT( 0xff, 0x00, IPT_MOUSE_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) - - PORT_START("MOUSE2") /* Mouse - Y AXIS */ - PORT_BIT( 0xff, 0x00, IPT_MOUSE_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) - - /* This handles the standard (not Extended) Apple ADB keyboard, which is similar to the IIgs's */ - /* main keyboard */ - - PORT_START("KEY0") - PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_A) PORT_CHAR('a') PORT_CHAR('A') - PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_S) PORT_CHAR('s') PORT_CHAR('S') - PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_D) PORT_CHAR('d') PORT_CHAR('D') - PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F) PORT_CHAR('f') PORT_CHAR('F') - PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_H) PORT_CHAR('h') PORT_CHAR('H') - PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_G) PORT_CHAR('g') PORT_CHAR('G') - PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_Z) PORT_CHAR('z') PORT_CHAR('Z') - PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_X) PORT_CHAR('x') PORT_CHAR('X') - PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_C) PORT_CHAR('c') PORT_CHAR('C') - PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_V) PORT_CHAR('v') PORT_CHAR('V') - PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_UNUSED) /* extra key on ISO : */ - PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_B) PORT_CHAR('b') PORT_CHAR('B') - PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_Q) PORT_CHAR('q') PORT_CHAR('Q') - PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_W) PORT_CHAR('w') PORT_CHAR('W') - PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_E) PORT_CHAR('e') PORT_CHAR('E') - PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_R) PORT_CHAR('r') PORT_CHAR('R') - - PORT_START("KEY1") - PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_Y) PORT_CHAR('y') PORT_CHAR('Y') - PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_T) PORT_CHAR('t') PORT_CHAR('T') - PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!') - PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('@') - PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#') - PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$') - PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('^') - PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%') - PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('=') PORT_CHAR('+') - PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR('(') - PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('&') - PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('_') - PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('*') - PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_0) PORT_CHAR('0') PORT_CHAR(')') - PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(']') PORT_CHAR('}') - PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_O) PORT_CHAR('o') PORT_CHAR('O') - - PORT_START("KEY2") - PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_U) PORT_CHAR('u') PORT_CHAR('U') - PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[') PORT_CHAR('{') - PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_I) PORT_CHAR('i') PORT_CHAR('I') - PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_P) PORT_CHAR('p') PORT_CHAR('P') - PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Return") PORT_CODE(KEYCODE_ENTER) PORT_CHAR('\r') - PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_L) PORT_CHAR('l') PORT_CHAR('L') - PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_J) PORT_CHAR('j') PORT_CHAR('J') - PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR('\'') PORT_CHAR('"') - PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_K) PORT_CHAR('k') PORT_CHAR('K') - PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR(':') - PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\') PORT_CHAR('|') - PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<') - PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?') - PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_N) PORT_CHAR('n') PORT_CHAR('N') - PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_M) PORT_CHAR('m') PORT_CHAR('M') - PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>') - - PORT_START("KEY3") - PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_TAB) PORT_CHAR('\t') - PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') - PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('`') PORT_CHAR('~') - PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8) - PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_UNUSED) /* keyboard Enter : */ - PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Esc") PORT_CODE(KEYCODE_ESC) PORT_CHAR(27) - PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Control") PORT_CODE(KEYCODE_LCONTROL) - PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Command / Open Apple") PORT_CODE(KEYCODE_RALT) - PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Shift") PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1) - PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Caps Lock") PORT_CODE(KEYCODE_CAPSLOCK) PORT_TOGGLE - PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Option / Solid Apple") PORT_CODE(KEYCODE_LALT) - PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Left Arrow") PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT)) - PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Right Arrow") PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT)) - PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Down Arrow") PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN)) - PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Up Arrow") PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP)) - PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_UNUSED) /* ??? */ - - /* keypad */ - PORT_START("KEY4") - PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_UNUSED) // 0x40 - PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_DEL_PAD) PORT_CHAR(UCHAR_MAMEKEY(DEL_PAD)) // 0x41 - PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_UNUSED) // 0x42 - PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_ASTERISK) PORT_CHAR(UCHAR_MAMEKEY(ASTERISK)) // 0x43 - PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_UNUSED) // 0x44 - PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_PLUS_PAD) PORT_CHAR(UCHAR_MAMEKEY(PLUS_PAD)) // 0x45 - PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_UNUSED) // 0x46 - PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Keypad Clear") PORT_CODE(/*KEYCODE_NUMLOCK*/KEYCODE_DEL) PORT_CHAR(UCHAR_MAMEKEY(NUMLOCK)) // 0x47 - PORT_BIT(0x0700, IP_ACTIVE_HIGH, IPT_UNUSED) // 0x48, 49, 4a - PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_SLASH_PAD) PORT_CHAR(UCHAR_MAMEKEY(SLASH_PAD)) // 0x4b - PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_ENTER_PAD) PORT_CHAR(UCHAR_MAMEKEY(ENTER_PAD)) // 0x4c - PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_UNUSED) // 0x4d - PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS_PAD) PORT_CHAR(UCHAR_MAMEKEY(MINUS_PAD)) // 0x4e - PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_UNUSED) // 0x4f - - PORT_START("KEY5") - PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_UNUSED) // 0x50 - PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(/*CODE_OTHER*/KEYCODE_NUMLOCK) PORT_CHAR(UCHAR_MAMEKEY(EQUALS_PAD)) // 0x51 - PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_0_PAD) PORT_CHAR(UCHAR_MAMEKEY(0_PAD)) // 0x52 - PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_1_PAD) PORT_CHAR(UCHAR_MAMEKEY(1_PAD)) // 0x53 - PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_2_PAD) PORT_CHAR(UCHAR_MAMEKEY(2_PAD)) // 0x54 - PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_3_PAD) PORT_CHAR(UCHAR_MAMEKEY(3_PAD)) // 0x55 - PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_4_PAD) PORT_CHAR(UCHAR_MAMEKEY(4_PAD)) // 0x56 - PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_5_PAD) PORT_CHAR(UCHAR_MAMEKEY(5_PAD)) // 0x57 - PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_6_PAD) PORT_CHAR(UCHAR_MAMEKEY(6_PAD)) // 0x58 - PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_7_PAD) PORT_CHAR(UCHAR_MAMEKEY(7_PAD)) // 0x59 - PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_UNUSED) // 0x5a - PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_8_PAD) PORT_CHAR(UCHAR_MAMEKEY(8_PAD)) // 0x5b - PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_9_PAD) PORT_CHAR(UCHAR_MAMEKEY(9_PAD)) // 0x5c - PORT_BIT(0xE000, IP_ACTIVE_HIGH, IPT_UNUSED) INPUT_PORTS_END INPUT_PORTS_START( maciici ) - PORT_INCLUDE(macadb) - PORT_START("MONTYPE") PORT_CONFNAME(0x0f, 0x06, "Connected monitor") PORT_CONFSETTING( 0x01, "15\" Portrait Display (640x870)") @@ -1821,22 +1604,6 @@ INPUT_PORTS_END ***************************************************************************/ -ROM_START( macse ) - ROM_REGION16_BE(0x40000, "bootrom", 0) - ROM_LOAD16_WORD( "macse.rom", 0x00000, 0x40000, CRC(0f7ff80c) SHA1(58532b7d0d49659fd5228ac334a1b094f0241968)) -ROM_END - -ROM_START( macsefd ) - ROM_REGION16_BE(0x40000, "bootrom", 0) - ROM_LOAD( "be06e171.rom", 0x000000, 0x040000, CRC(f530cb10) SHA1(d3670a90273d12e53d86d1228c068cb660b8c9d1) ) -ROM_END - -ROM_START( macclasc ) - ROM_REGION16_BE(0x80000, "bootrom", 0) // a49f9914, second half of chip dump is the 6.0.3 XO rom disk - // this dump is big endian - ROM_LOAD( "341-0813__=c=1983-90_apple__japan__910d_d.27c4096_be.ue1", 0x000000, 0x080000, CRC(510d7d38) SHA1(ccd10904ddc0fb6a1d216b2e9effd5ec6cf5a83d) ) -ROM_END - ROM_START( maclc ) ROM_REGION32_BE(0x100000, "bootrom", 0) ROM_LOAD("350eacf0.rom", 0x000000, 0x080000, CRC(71681726) SHA1(6bef5853ae736f3f06c2b4e79772f65910c3b7d4)) @@ -2035,8 +1802,6 @@ ROM_START( maclc520 ) ROM_END /* YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME */ -COMP( 1987, macse, 0, 0, macse, macadb, mac_state, init_macse, "Apple Computer", "Macintosh SE", MACHINE_NOT_WORKING ) -COMP( 1987, macsefd, 0, 0, macse, macadb, mac_state, init_macse, "Apple Computer", "Macintosh SE (FDHD)", MACHINE_NOT_WORKING ) COMP( 1987, macii, 0, 0, macii, macadb, mac_state, init_macii, "Apple Computer", "Macintosh II", MACHINE_NOT_WORKING ) COMP( 1987, maciihmu, macii, 0, maciihmu, macadb, mac_state, init_macii, "Apple Computer", "Macintosh II (w/o 68851 MMU)", MACHINE_NOT_WORKING ) COMP( 1988, mac2fdhd, 0, 0, macii, macadb, mac_state, init_maciifdhd, "Apple Computer", "Macintosh II (FDHD)", MACHINE_NOT_WORKING ) @@ -2046,7 +1811,6 @@ COMP( 1989, macse30, mac2fdhd, 0, macse30, macadb, mac_state, init_macs COMP( 1989, maciicx, mac2fdhd, 0, maciicx, macadb, mac_state, init_maciicx, "Apple Computer", "Macintosh IIcx", MACHINE_NOT_WORKING ) COMP( 1989, maciici, 0, 0, maciici, maciici, mac_state, init_maciici, "Apple Computer", "Macintosh IIci", MACHINE_NOT_WORKING ) COMP( 1990, maciifx, 0, 0, maciifx, macadb, mac_state, init_maciifx, "Apple Computer", "Macintosh IIfx", MACHINE_NOT_WORKING ) -COMP( 1990, macclasc, 0, 0, macclasc, macadb, mac_state, init_macclassic, "Apple Computer", "Macintosh Classic", MACHINE_NOT_WORKING ) COMP( 1990, maclc, 0, 0, maclc, maciici, mac_state, init_maclc, "Apple Computer", "Macintosh LC", MACHINE_IMPERFECT_SOUND ) COMP( 1990, maciisi, 0, 0, maciisi, maciici, mac_state, init_maciisi, "Apple Computer", "Macintosh IIsi", MACHINE_NOT_WORKING ) COMP( 1991, macpb100, 0, 0, macprtb, macadb, mac_state, init_macprtb, "Apple Computer", "Macintosh PowerBook 100", MACHINE_NOT_WORKING ) diff --git a/src/mame/drivers/mac128.cpp b/src/mame/drivers/mac128.cpp index a7b31810805..de3e93a68d8 100644 --- a/src/mame/drivers/mac128.cpp +++ b/src/mame/drivers/mac128.cpp @@ -5,7 +5,9 @@ drivers/mac128.cpp Original-style Macintosh family emulation - The cutoff here is Macs with 128k-style video and audio and no ADB + The cutoff here is Macs with 128k-style video and audio. + We also include the SE and Classic, which are basically cost-reduced Mac Pluses with ADB + instead of the original keyboard/mouse hardware. Nate Woods, Raphael Nabet, R. Belmont @@ -99,8 +101,10 @@ c0 8 data bits, Rx disabled #include "machine/swim.h" #include "machine/timer.h" #include "machine/z80scc.h" +#include "machine/macadb.h" #include "sound/dac.h" #include "sound/volt_reg.h" +#include "bus/macpds/pds_tpdfpd.h" #include "formats/ap_dsk35.h" @@ -122,9 +126,11 @@ c0 8 data bits, Rx disabled /* tells which model is being emulated (set by macxxx_init) */ enum mac128model_t { - MODEL_MAC_128K512K, // 68000 machines + MODEL_MAC_128K512K, MODEL_MAC_512KE, - MODEL_MAC_PLUS + MODEL_MAC_PLUS, + MODEL_MAC_SE, + MODEL_MAC_CLASSIC }; // video parameters @@ -150,6 +156,7 @@ public: driver_device(mconfig, type, tag), m_maincpu(*this, "maincpu"), m_via(*this, "via6522_0"), + m_macadb(*this, "macadb"), m_ram(*this, RAM_TAG), m_ncr5380(*this, "ncr5380"), m_iwm(*this, "fdc"), @@ -167,43 +174,30 @@ public: void mac512ke(machine_config &config); void mac128k(machine_config &config); void macplus(machine_config &config); + void macse(machine_config &config); + void macclasc(machine_config &config); void init_mac128k512k(); void init_mac512ke(); void init_macplus(); + void init_macse(); + void init_macclassic(); private: required_device<m68000_device> m_maincpu; required_device<via6522_device> m_via; + optional_device<macadb_device> m_macadb; required_device<ram_device> m_ram; optional_device<ncr5380_device> m_ncr5380; required_device<applefdc_base_device> m_iwm; - required_device<mac_keyboard_port_device> m_mackbd; + optional_device<mac_keyboard_port_device> m_mackbd; optional_device<rtc3430042_device> m_rtc; - required_ioport m_mouse0, m_mouse1, m_mouse2; + optional_ioport m_mouse0, m_mouse1, m_mouse2; virtual void machine_start() override; virtual void machine_reset() override; - mac128model_t m_model; - - uint32_t m_overlay; - - int m_irq_count, m_ca1_data, m_ca2_data; - - int m_mouse_bit_x; - int m_mouse_bit_y; - int last_mx, last_my; - int count_x, count_y; - int m_last_was_x; - int m_screen_buffer; - emu_timer *m_scan_timer; - emu_timer *m_hblank_timer; - - // interrupts - int m_scc_interrupt, m_via_interrupt, m_scsi_interrupt, m_last_taken_interrupt; - void scc_mouse_irq( int x, int y ); void set_via_interrupt(int value); void field_interrupts(); @@ -212,6 +206,7 @@ private: uint16_t ram_r(offs_t offset); void ram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + void ram_w_se(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); uint16_t ram_600000_r(offs_t offset); void ram_600000_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~ 0); uint16_t mac_via_r(offs_t offset); @@ -225,26 +220,52 @@ private: DECLARE_WRITE_LINE_MEMBER(mac_scsi_irq); DECLARE_WRITE_LINE_MEMBER(set_scc_interrupt); + WRITE_LINE_MEMBER(adb_irq_w) { m_adb_irq_pending = state; } + TIMER_CALLBACK_MEMBER(mac_scanline); TIMER_CALLBACK_MEMBER(mac_hblank); uint32_t screen_update_mac(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); uint8_t mac_via_in_a(); uint8_t mac_via_in_b(); + uint8_t mac_via_in_b_se(); void mac_via_out_a(uint8_t data); void mac_via_out_b(uint8_t data); + void mac_via_out_a_se(uint8_t data); + void mac_via_out_b_se(uint8_t data); DECLARE_WRITE_LINE_MEMBER(mac_via_irq); void mac_driver_init(mac128model_t model); void update_volume(); void mac512ke_map(address_map &map); void macplus_map(address_map &map); -private: + void macse_map(address_map &map); + + mac128model_t m_model; + + uint32_t m_overlay; + + int m_irq_count, m_ca1_data, m_ca2_data; + int m_mouse_bit_x; + int m_mouse_bit_y; + int last_mx, last_my; + int count_x, count_y; + int m_last_was_x; + int m_screen_buffer; + emu_timer *m_scan_timer; + emu_timer *m_hblank_timer; + + // interrupts + int m_scc_interrupt, m_via_interrupt, m_scsi_interrupt, m_last_taken_interrupt; + // wait states for accessing the VIA int m_via_cycles; bool m_snd_enable; bool m_main_buffer; int m_snd_vol; + int m_adb_irq_pending; + int m_drive_select; + int m_scsiirq_enable; u16 *m_ram_ptr, *m_rom_ptr; u32 m_ram_mask, m_ram_size; @@ -262,6 +283,29 @@ void mac128_state::machine_start() m_scan_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mac128_state::mac_scanline), this)); m_hblank_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mac128_state::mac_hblank), this)); + + save_item(NAME(m_overlay)); + save_item(NAME(m_irq_count)); + save_item(NAME(m_ca1_data)); + save_item(NAME(m_ca2_data)); + save_item(NAME(m_mouse_bit_x)); + save_item(NAME(m_mouse_bit_y)); + save_item(NAME(last_mx)); + save_item(NAME(last_my)); + save_item(NAME(count_x)); + save_item(NAME(count_y)); + save_item(NAME(m_last_was_x)); + save_item(NAME(m_screen_buffer)); + save_item(NAME(m_scc_interrupt)); + save_item(NAME(m_via_interrupt)); + save_item(NAME(m_scsi_interrupt)); + save_item(NAME(m_last_taken_interrupt)); + save_item(NAME(m_snd_enable)); + save_item(NAME(m_main_buffer)); + save_item(NAME(m_snd_vol)); + save_item(NAME(m_adb_irq_pending)); + save_item(NAME(m_drive_select)); + save_item(NAME(m_scsiirq_enable)); } void mac128_state::machine_reset() @@ -278,6 +322,9 @@ void mac128_state::machine_reset() m_irq_count = 0; m_ca1_data = 0; m_ca2_data = 0; + m_adb_irq_pending = 0; + m_drive_select = 0; + m_scsiirq_enable = 0; const int next_vpos = m_screen->vpos() + 1; m_scan_timer->adjust(m_screen->time_until_pos(next_vpos), next_vpos); @@ -303,6 +350,12 @@ void mac128_state::ram_w(offs_t offset, uint16_t data, uint16_t mem_mask) } } +void mac128_state::ram_w_se(offs_t offset, uint16_t data, uint16_t mem_mask) +{ + m_overlay = 0; + COMBINE_DATA(&m_ram_ptr[offset & m_ram_mask]); +} + uint16_t mac128_state::ram_600000_r(offs_t offset) { return m_ram_ptr[offset & m_ram_mask]; @@ -326,7 +379,7 @@ void mac128_state::field_interrupts() take_interrupt = 1; } -// printf("field_interrupts: take %d\n", take_interrupt); +// printf("field_interrupts: take %d\n", take_interrupt); if (m_last_taken_interrupt > -1) { @@ -351,7 +404,7 @@ WRITE_LINE_MEMBER(mac128_state::set_scc_interrupt) void mac128_state::set_via_interrupt(int value) { m_via_interrupt = value; - this->field_interrupts(); + field_interrupts(); } void mac128_state::vblank_irq() @@ -359,6 +412,11 @@ void mac128_state::vblank_irq() m_ca1_data ^= 1; m_via->write_ca1(m_ca1_data); + if (m_macadb) + { + m_macadb->adb_vblank(); + } + if (++m_irq_count == 60) { m_irq_count = 0; @@ -403,7 +461,7 @@ TIMER_CALLBACK_MEMBER(mac128_state::mac_scanline) m_hblank_timer->adjust(m_screen->time_until_pos(scanline, MAC_H_VIS)); } - if (!(scanline % 10)) + if ((!(scanline % 10)) && (m_model < MODEL_MAC_SE)) { mouse_callback(); } @@ -683,7 +741,7 @@ uint16_t mac128_state::mac_autovector_r(offs_t offset) uint8_t mac128_state::mac_via_in_a() { - return 0x80; + return 0x81; } uint8_t mac128_state::mac_via_in_b() @@ -699,6 +757,22 @@ uint8_t mac128_state::mac_via_in_b() val |= m_rtc->data_r(); +// printf("%s VIA1 IN_B = %02x\n", machine().describe_context().c_str(), val); + + return val; +} + +uint8_t mac128_state::mac_via_in_b_se() +{ + int val = m_macadb->get_adb_state()<<4; + + if (!m_adb_irq_pending) + { + val |= 0x08; + } + + val |= m_rtc->data_r(); + // printf("%s VIA1 IN_B = %02x\n", machine().describe_context().c_str(), val); return val; @@ -716,16 +790,32 @@ void mac128_state::mac_via_out_a(uint8_t data) m_snd_vol = data & 0x07; update_volume(); - /* Early Mac models had VIA A4 control overlaying. In the Mac SE (and - * possibly later models), overlay was set on reset, but cleared on the - * first access to the ROM. */ - + /* Early Mac models had VIA A4 control overlaying. In the Mac SE and + * later models, overlay was set on reset, but cleared on the first + * access to the ROM's normal address space. */ if (((data & 0x10) >> 4) != m_overlay) { m_overlay = (data & 0x10) >> 4; } } +void mac128_state::mac_via_out_a_se(uint8_t data) +{ +// printf("%s VIA OUT A: %02x (PC %x)\n", machine().describe_context().c_str(), data); + + //set_scc_waitrequest((data & 0x80) >> 7); + m_screen_buffer = (data & 0x40) >> 6; + sony_set_sel_line(m_iwm, (data & 0x20) >> 5); + + m_snd_vol = data & 0x07; + update_volume(); + + if (m_model == MODEL_MAC_SE) // on SE only this selects which floppy drive (0 = upper, 1 = lower) + { + m_drive_select = ((data & 0x10) >> 4); + } +} + void mac128_state::mac_via_out_b(uint8_t data) { // printf("%s VIA1 OUT B: %02x\n", machine().describe_context().c_str(), data); @@ -737,6 +827,22 @@ void mac128_state::mac_via_out_b(uint8_t data) m_rtc->clk_w((data >> 1) & 0x01); } +void mac128_state::mac_via_out_b_se(uint8_t data) +{ +// printf("%s VIA OUT B: %02x\n", machine().describe_context().c_str(), data); + + m_snd_enable = ((data & 0x80) == 0) ? true : false; + update_volume(); + + m_scsiirq_enable = (data & 0x40) ? 0 : 1; + + m_macadb->mac_adb_newaction((data & 0x30) >> 4); + + m_rtc->ce_w((data & 0x04)>>2); + m_rtc->data_w(data & 0x01); + m_rtc->clk_w((data >> 1) & 0x01); +} + /* ************************************************************************* * Mouse * *************************************************************************/ @@ -823,14 +929,6 @@ void mac128_state::mac_driver_init(mac128model_t model) { m_scsi_interrupt = 0; m_model = model; -#if 0 - /* set up RAM mirror at 0x600000-0x6fffff (0x7fffff ???) */ - mac_install_memory(0x600000, 0x6fffff, m_ram->size(), m_ram->pointer(), FALSE, "bank2"); - - /* set up ROM at 0x400000-0x4fffff (-0x5fffff for mac 128k/512k/512ke) */ - mac_install_memory(0x400000, (model >= MODEL_MAC_PLUS) ? 0x4fffff : 0x5fffff, - memregion("bootrom")->bytes(), memregion("bootrom")->base(), TRUE, "bank3"); -#endif memset(m_ram->pointer(), 0, m_ram->size()); } @@ -874,6 +972,8 @@ void mac128_state::init_##label() \ MAC_DRIVER_INIT(mac128k512k, MODEL_MAC_128K512K) MAC_DRIVER_INIT(mac512ke, MODEL_MAC_512KE) MAC_DRIVER_INIT(macplus, MODEL_MAC_PLUS) +MAC_DRIVER_INIT(macse, MODEL_MAC_SE) +MAC_DRIVER_INIT(macclassic, MODEL_MAC_CLASSIC) /*************************************************************************** ADDRESS MAPS @@ -903,6 +1003,18 @@ void mac128_state::macplus_map(address_map &map) map(0xfffff0, 0xffffff).rw(FUNC(mac128_state::mac_autovector_r), FUNC(mac128_state::mac_autovector_w)); } +void mac128_state::macse_map(address_map &map) +{ + map(0x000000, 0x3fffff).rw(FUNC(mac128_state::ram_r), FUNC(mac128_state::ram_w_se)); + map(0x400000, 0x4fffff).rom().region("bootrom", 0); + map(0x580000, 0x5fffff).rw(FUNC(mac128_state::macplus_scsi_r), FUNC(mac128_state::macplus_scsi_w)); + map(0x900000, 0x9fffff).r(m_scc, FUNC(z80scc_device::dc_ab_r)).umask16(0xff00); + map(0xb00000, 0xbfffff).w(m_scc, FUNC(z80scc_device::dc_ab_w)).umask16(0x00ff); + map(0xd00000, 0xdfffff).rw(FUNC(mac128_state::mac_iwm_r), FUNC(mac128_state::mac_iwm_w)); + map(0xe80000, 0xefffff).rw(FUNC(mac128_state::mac_via_r), FUNC(mac128_state::mac_via_w)); + map(0xfffff0, 0xffffff).rw(FUNC(mac128_state::mac_autovector_r), FUNC(mac128_state::mac_autovector_w)); +} + /*************************************************************************** DEVICE CONFIG ***************************************************************************/ @@ -994,7 +1106,6 @@ void mac128_state::mac128k(machine_config &config) m_ram->set_default_size("128K"); } - void mac128_state::macplus(machine_config &config) { mac512ke(config); @@ -1015,6 +1126,45 @@ void mac128_state::macplus(machine_config &config) m_ram->set_extra_options("1M,2M,2560K,4M"); } +static void mac_sepds_cards(device_slot_interface &device) +{ + device.option_add("radiusfpd", PDS_SEDISPLAY); // Radius Full Page Display card for SE +} + +void mac128_state::macse(machine_config &config) +{ + macplus(config); + m_maincpu->set_addrmap(AS_PROGRAM, &mac128_state::macse_map); + + config.device_remove("kbd"); + config.device_remove("pds"); + + MACADB(config, m_macadb, C7M); + m_macadb->via_clock_callback().set(m_via, FUNC(via6522_device::write_cb1)); + m_macadb->via_data_callback().set(m_via, FUNC(via6522_device::write_cb2)); + m_macadb->adb_irq_callback().set(FUNC(mac128_state::adb_irq_w)); + + m_via->readpb_handler().set(FUNC(mac128_state::mac_via_in_b_se)); + m_via->writepa_handler().set(FUNC(mac128_state::mac_via_out_a_se)); + m_via->writepb_handler().set(FUNC(mac128_state::mac_via_out_b_se)); + m_via->cb2_handler().set(m_macadb, FUNC(macadb_device::adb_data_w)); + + /* internal ram */ + m_ram->set_default_size("4M"); + m_ram->set_extra_options("2M,2560K,4M"); + + MACPDS(config, "sepds", "maincpu"); + MACPDS_SLOT(config, "pds", "sepds", mac_sepds_cards, nullptr); +} + +void mac128_state::macclasc(machine_config &config) +{ + macse(config); + + config.device_remove("pds"); + config.device_remove("sepds"); +} + static INPUT_PORTS_START( macplus ) PORT_START("MOUSE0") /* Mouse - button */ PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("Mouse Button") PORT_CODE(MOUSECODE_BUTTON1) @@ -1026,6 +1176,9 @@ static INPUT_PORTS_START( macplus ) PORT_BIT( 0xff, 0x00, IPT_MOUSE_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) INPUT_PORTS_END +static INPUT_PORTS_START( macadb ) +INPUT_PORTS_END + /*************************************************************************** Machine driver(s) @@ -1192,6 +1345,22 @@ ROM_START( macplus ) // same notes as above apply here as well ROMX_LOAD( "rominator-20150225-hi.bin", 0x000000, 0x080000, CRC(a28ba8ec) SHA1(9ddcf500727955c60db0ff24b5ca2458f53fd89a), ROM_SKIP(1) | ROM_BIOS(4) ) ROM_END +ROM_START( macse ) + ROM_REGION16_BE(0x100000, "bootrom", 0) + ROM_LOAD16_WORD( "macse.rom", 0x00000, 0x40000, CRC(0f7ff80c) SHA1(58532b7d0d49659fd5228ac334a1b094f0241968)) +ROM_END + +ROM_START( macsefd ) + ROM_REGION16_BE(0x100000, "bootrom", 0) + ROM_LOAD( "be06e171.rom", 0x000000, 0x040000, CRC(f530cb10) SHA1(d3670a90273d12e53d86d1228c068cb660b8c9d1) ) +ROM_END + +ROM_START( macclasc ) + ROM_REGION16_BE(0x100000, "bootrom", 0) // a49f9914, second half of chip dump is the 6.0.3 XO rom disk + // this dump is big endian + ROM_LOAD( "341-0813__=c=1983-90_apple__japan__910d_d.27c4096_be.ue1", 0x000000, 0x080000, CRC(510d7d38) SHA1(ccd10904ddc0fb6a1d216b2e9effd5ec6cf5a83d) ) +ROM_END + /* YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME */ //COMP( 1983, mactw, 0, 0, mac128k, macplus, mac128_state, init_mac128k512k, "Apple Computer", "Macintosh (4.3T Prototype)", MACHINE_NOT_WORKING ) COMP( 1984, mac128k, 0, 0, mac128k, macplus, mac128_state, init_mac128k512k, "Apple Computer", "Macintosh 128k", MACHINE_NOT_WORKING ) @@ -1200,3 +1369,6 @@ COMP( 1986, mac512ke, macplus, 0, mac512ke, macplus, mac128_state, init_mac COMP( 1985, unitron, macplus, 0, mac512ke, macplus, mac128_state, init_mac512ke, "bootleg (Unitron)", "Mac 512", MACHINE_NOT_WORKING ) COMP( 1986, macplus, 0, 0, macplus, macplus, mac128_state, init_macplus, "Apple Computer", "Macintosh Plus", MACHINE_NOT_WORKING ) COMP( 1985, utrn1024, macplus, 0, macplus, macplus, mac128_state, init_macplus, "bootleg (Unitron)", "Unitron 1024", MACHINE_NOT_WORKING ) +COMP( 1987, macse, 0, 0, macse, macadb, mac128_state, init_macse, "Apple Computer", "Macintosh SE", MACHINE_NOT_WORKING ) +COMP( 1987, macsefd, 0, 0, macse, macadb, mac128_state, init_macse, "Apple Computer", "Macintosh SE (FDHD)", MACHINE_NOT_WORKING ) +COMP( 1990, macclasc, 0, 0, macclasc, macadb, mac128_state, init_macclassic, "Apple Computer", "Macintosh Classic", MACHINE_NOT_WORKING ) diff --git a/src/mame/includes/mac.h b/src/mame/includes/mac.h index bbca13d3c52..5164532102a 100644 --- a/src/mame/includes/mac.h +++ b/src/mame/includes/mac.h @@ -18,6 +18,7 @@ #include "machine/timer.h" #include "machine/egret.h" #include "machine/cuda.h" +#include "machine/macadb.h" #include "bus/nubus/nubus.h" #include "bus/macpds/macpds.h" #include "machine/applefdc.h" @@ -36,14 +37,9 @@ #define MAC_539X_2_TAG "539x_2" // 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)) #define ADB_IS_EGRET (m_model >= MODEL_MAC_LC && m_model <= MODEL_MAC_CLASSIC_II) || ((m_model >= MODEL_MAC_IISI) && (m_model <= MODEL_MAC_IIVI)) -#define ADB_IS_EGRET_NONCLASS (mac->m_model >= MODEL_MAC_LC && mac->m_model <= MODEL_MAC_CLASSIC_II) || ((mac->m_model >= MODEL_MAC_IISI) && (mac->m_model <= MODEL_MAC_IIVI)) #define ADB_IS_CUDA ((m_model >= MODEL_MAC_COLOR_CLASSIC && m_model <= MODEL_MAC_LC_580) || ((m_model >= MODEL_MAC_QUADRA_660AV) && (m_model <= MODEL_MAC_QUADRA_630)) || (m_model >= MODEL_MAC_POWERMAC_6100)) -#define ADB_IS_CUDA_NONCLASS ((mac->m_model >= MODEL_MAC_COLOR_CLASSIC && mac->m_model <= MODEL_MAC_LC_580) || ((mac->m_model >= MODEL_MAC_QUADRA_660AV) && (mac->m_model <= MODEL_MAC_QUADRA_630)) || (mac->m_model >= MODEL_MAC_POWERMAC_6100)) -#define ADB_IS_PM_VIA1_CLASS (m_model >= MODEL_MAC_PORTABLE && m_model <= MODEL_MAC_PB100) -#define ADB_IS_PM_VIA2_CLASS (m_model >= MODEL_MAC_PB140 && m_model <= MODEL_MAC_PBDUO_270c) #define ADB_IS_PM_CLASS ((m_model >= MODEL_MAC_PORTABLE && m_model <= MODEL_MAC_PB100) || (m_model >= MODEL_MAC_PB140 && m_model <= MODEL_MAC_PBDUO_270c)) // video parameters for classic Macs @@ -70,6 +66,7 @@ public: m_awacs(*this, "awacs"), m_egret(*this, EGRET_TAG), m_cuda(*this, CUDA_TAG), + m_macadb(*this, "macadb"), m_ram(*this, RAM_TAG), m_scc(*this, "scc"), m_539x_1(*this, MAC_539X_1_TAG), @@ -77,20 +74,13 @@ public: m_ncr5380(*this, "ncr5380"), m_fdc(*this, "fdc"), m_rtc(*this, "rtc"), - m_mouse0(*this, "MOUSE0"), - m_mouse1(*this, "MOUSE1"), - m_mouse2(*this, "MOUSE2"), - m_keys(*this, "KEY%u", 0), m_montype(*this, "MONTYPE"), - m_snd_enable(false), m_main_buffer(true), - m_snd_vol(7), m_vram(*this,"vram"), m_vram16(*this,"vram16"), m_via2_ca1_hack(0), m_screen(*this, "screen"), - m_palette(*this, "palette"), - m_dac(*this, "dac") + m_palette(*this, "palette") { m_rom_size = 0; m_rom_ptr = nullptr; @@ -99,7 +89,6 @@ public: 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); - void add_macplus_additions(machine_config &config); void add_nubus(machine_config &config, bool bank1 = true, bool bank2 = true); template <typename T> void add_nubus_pds(machine_config &config, const char *slot_tag, T &&opts); void add_via1_adb(machine_config &config, bool macii); @@ -109,15 +98,10 @@ public: void add_egret(machine_config &config, int type); void add_cuda(machine_config &config, int type); - void mac512ke_base(machine_config &config); - void mac512ke(machine_config &config); - void macplus(machine_config &config); void maclc(machine_config &config, bool cpu = true, bool egret = true, asc_device::asc_type asc_type = asc_device::asc_type::V8); void macpb170(machine_config &config); - void macclasc(machine_config &config); void maciisi(machine_config &config); void maclc2(machine_config &config, bool egret = true); - void macse(machine_config &config); void maclc3(machine_config &config, bool egret = true); void macpd210(machine_config &config); void maciici(machine_config &config); @@ -244,7 +228,6 @@ public: }; model_t m_model; - int m_drive_select; private: required_device<cpu_device> m_maincpu; @@ -254,6 +237,7 @@ private: optional_device<awacs_device> m_awacs; optional_device<egret_device> m_egret; optional_device<cuda_device> m_cuda; + optional_device<macadb_device> m_macadb; required_device<ram_device> m_ram; required_device<scc8530_legacy_device> m_scc; optional_device<ncr539x_device> m_539x_1; @@ -262,8 +246,8 @@ private: required_device<applefdc_base_device> m_fdc; optional_device<rtc3430042_device> m_rtc; - required_ioport m_mouse0, m_mouse1, m_mouse2; - optional_ioport_array<7> m_keys; + //required_ioport m_mouse0, m_mouse1, m_mouse2; + //optional_ioport_array<7> m_keys; optional_ioport m_montype; virtual void machine_start() override; @@ -279,7 +263,6 @@ private: uint32_t m_overlay; - int m_scsiirq_enable; uint32_t m_via2_vbl; uint32_t m_se30_vbl_enable; @@ -289,45 +272,19 @@ private: TIMER_CALLBACK_MEMBER(overlay_timeout_func); uint32_t rom_switch_r(offs_t offset); - bool m_snd_enable; bool m_main_buffer; - int m_snd_vol; - - /* 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; - int last_mx, last_my; - int count_x, count_y; - int m_last_was_x; + int m_adb_irq_pending; int m_screen_buffer; - int irq_count, ca1_data, ca2_data; - // Mac ADB state - int32_t m_adb_irq_pending, m_adb_waiting_cmd, m_adb_datasize, m_adb_buffer[257]; - int32_t m_adb_state, m_adb_command, m_adb_send, m_adb_timer_ticks, m_adb_extclock, m_adb_direction; - int32_t m_adb_listenreg, m_adb_listenaddr, m_adb_last_talk, m_adb_srq_switch; - int32_t m_adb_stream_ptr; - int32_t m_adb_linestate; - bool m_adb_srqflag; -#define kADBKeyBufSize 32 - uint8_t m_adb_keybuf[kADBKeyBufSize]; - uint8_t m_adb_keybuf_start; - uint8_t m_adb_keybuf_end; - - // Portable/PB100 Power Manager IC comms (chapter 4, "Guide to the Macintosh Family Hardware", second edition) - uint8_t m_pm_data_send, m_pm_data_recv, m_pm_ack, m_pm_req, m_pm_cmd[32], m_pm_out[32], m_pm_dptr, m_pm_sptr, m_pm_slen, m_pm_state; - uint8_t m_pmu_int_status, m_pmu_last_adb_command, m_pmu_poll; - emu_timer *m_pmu_send_timer; - // 60.15 Hz timer for RBV/V8/Sonora/Eagle/VASP/etc. emu_timer *m_6015_timer; // ADB refresh timer, independent of anything else going on emu_timer *m_adbupdate_timer; + WRITE_LINE_MEMBER(adb_irq_w) { m_adb_irq_pending = state; } + // RBV and friends (V8, etc) uint8_t m_rbv_regs[256], m_rbv_ier, m_rbv_ifr, m_rbv_type, m_rbv_montype, m_rbv_vbltime; uint32_t m_rbv_colors[3], m_rbv_count, m_rbv_clutoffs, m_rbv_immed10wr; @@ -357,12 +314,7 @@ private: void set_via2_interrupt(int value); void field_interrupts(); void vblank_irq(); - void adb_talk(); - void mouse_callback(); void rbv_recalc_irqs(); - void pmu_exec(); - void mac_adb_newaction(int state); - void set_adb_line(int linestate); void update_volume(); uint16_t mac_via_r(offs_t offset); @@ -435,12 +387,10 @@ private: DECLARE_WRITE_LINE_MEMBER(drq_539x_1_w); DECLARE_WRITE_LINE_MEMBER(cuda_reset_w); - DECLARE_WRITE_LINE_MEMBER(adb_linechange_w); DECLARE_WRITE_LINE_MEMBER(mac_scsi_irq); DECLARE_WRITE_LINE_MEMBER(mac_asc_irq); - void mac512ke_map(address_map &map); void macii_map(address_map &map); void maciici_map(address_map &map); @@ -458,29 +408,11 @@ private: void pwrmac_map(address_map &map); void quadra700_map(address_map &map); - int has_adb(); - void adb_reset(); - void adb_vblank(); - int adb_pollkbd(int update); - int adb_pollmouse(); - void adb_accummouse( uint8_t *MouseX, uint8_t *MouseY ); - void pmu_one_byte_reply(uint8_t result); - void pmu_three_byte_reply(uint8_t result1, uint8_t result2, uint8_t result3); + inline bool has_adb() { return m_model >= MODEL_MAC_SE; } // wait states for accessing the VIA int m_via_cycles; - // ADB mouse state - int m_adb_mouseaddr; - int m_adb_lastmousex, m_adb_lastmousey, m_adb_lastbutton, m_adb_mouse_initialized; - - // ADB keyboard state - int m_adb_keybaddr; - int m_adb_keybinitialized, m_adb_currentkeys[2], m_adb_modifiers; - - // PRAM for ADB MCU HLEs (mostly unused now) - uint8_t m_adb_pram[256]; - uint8_t m_oss_regs[0x400]; // AMIC for x100 PowerMacs @@ -492,13 +424,13 @@ private: int m_via2_ca1_hack; optional_device<screen_device> m_screen; optional_device<palette_device> m_palette; - optional_device<dac_8bit_pwm_device> m_dac; uint32_t m_rom_size; uint32_t *m_rom_ptr; emu_timer *m_scanline_timer; - emu_timer *m_adb_timer; + + uint8_t m_pm_req, m_pm_state, m_pm_dptr, m_pm_cmd; void macgsc_palette(palette_device &palette) const; @@ -529,8 +461,6 @@ private: TIMER_CALLBACK_MEMBER(mac_scanline_tick); TIMER_CALLBACK_MEMBER(dafb_vbl_tick); 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_adb_via_out_cb2); uint8_t mac_via_in_a(); uint8_t mac_via_in_b(); diff --git a/src/mame/machine/cuda.cpp b/src/mame/machine/cuda.cpp index ce4c32ad487..9be2fbd3dbc 100644 --- a/src/mame/machine/cuda.cpp +++ b/src/mame/machine/cuda.cpp @@ -87,7 +87,7 @@ void cuda_device::cuda_map(address_map &map) void cuda_device::device_add_mconfig(machine_config &config) { - M68HC05EG(config, m_maincpu, XTAL(32'768)*192); // 32.768 kHz input clock, can be PLL'ed to x128 = 4.1 MHz under s/w control + M68HC05EG(config, m_maincpu, XTAL(32'768)*128); // Intended to run 4.1 MHz, the ADB timings in uS are twice as long as spec at 2.1 m_maincpu->set_addrmap(AS_PROGRAM, &cuda_device::cuda_map); } diff --git a/src/mame/machine/egret.cpp b/src/mame/machine/egret.cpp index 281047548ee..dacd0a3ec4e 100644 --- a/src/mame/machine/egret.cpp +++ b/src/mame/machine/egret.cpp @@ -86,7 +86,7 @@ void egret_device::egret_map(address_map &map) void egret_device::device_add_mconfig(machine_config &config) { - M68HC05EG(config, m_maincpu, XTAL(32'768)*192); // 32.768 kHz input clock, can be PLL'ed to x128 = 4.1 MHz under s/w control + M68HC05EG(config, m_maincpu, XTAL(32'768)*128); // Intended to run 4.1 MHz, the ADB timings in uS are twice as long as spec at 2.1 m_maincpu->set_addrmap(AS_PROGRAM, &egret_device::egret_map); } @@ -111,19 +111,20 @@ void egret_device::send_port(uint8_t offset, uint8_t data) if ((data & 0x80) != last_adb) { -/* if (data & 0x80) + m_adb_dtime = (int)(machine().time().as_ticks(1000000) - last_adb_time); + /* + if (data & 0x80) { - printf("EG ADB: 1->0 time %lld\n", machine().time().as_ticks(1000000) - last_adb_time); + printf("EG ADB: 1->0 time %d\n", m_adb_dtime); } else { - printf("EG ADB: 0->1 time %lld\n", machine().time().as_ticks(1000000) - last_adb_time); - }*/ - + printf("EG ADB: 0->1 time %d\n", m_adb_dtime); + } + */ // allow the linechange handler to override us adb_in = (data & 0x80) ? true : false; - m_adb_dtime = (int)(machine().time().as_ticks(1000000) - last_adb_time); write_linechange(((data & 0x80) >> 7) ^ 1); last_adb = data & 0x80; diff --git a/src/mame/machine/egret.h b/src/mame/machine/egret.h index 831c0808a93..b1597dca367 100644 --- a/src/mame/machine/egret.h +++ b/src/mame/machine/egret.h @@ -67,7 +67,6 @@ public: void set_via_data(uint8_t dat) { via_data = dat; } uint8_t get_via_clock() { return via_clock; } void set_adb_line(int linestate) { adb_in = (linestate == ASSERT_LINE) ? true : false; } - int get_adb_dtime() { return m_adb_dtime; } int rom_offset; @@ -76,7 +75,8 @@ public: auto via_clock_callback() { return write_via_clock.bind(); } auto via_data_callback() { return write_via_data.bind(); } - devcb_write_line write_reset, write_linechange, write_via_clock, write_via_data; + devcb_write_line write_reset, write_linechange; + devcb_write_line write_via_clock, write_via_data; void egret_map(address_map &map); protected: diff --git a/src/mame/machine/mac.cpp b/src/mame/machine/mac.cpp index b6810f12e8f..e5b8727e1e0 100644 --- a/src/mame/machine/mac.cpp +++ b/src/mame/machine/mac.cpp @@ -118,32 +118,10 @@ #define LOG_MEMORY 0 #endif -// returns non-zero if this Mac has ADB -int mac_state::has_adb() -{ - return m_model >= MODEL_MAC_SE; -} - // handle disk enable lines void mac_fdc_set_enable_lines(device_t *device, int enable_mask) { - mac_state *mac = device->machine().driver_data<mac_state>(); - - if (mac->m_model != mac_state::MODEL_MAC_SE) - { - sony_set_enable_lines(device, enable_mask); - } - else - { - if (enable_mask) - { - sony_set_enable_lines(device, mac->m_drive_select ? 1 : 2); - } - else - { - sony_set_enable_lines(device, enable_mask); - } - } + sony_set_enable_lines(device, enable_mask); } void mac_state::mac_install_memory(offs_t memory_begin, offs_t memory_end, @@ -508,87 +486,6 @@ uint32_t mac_state::rom_switch_r(offs_t offset) return m_rom_ptr[offset & ((m_rom_size - 1)>>2)]; } - -/* ************************************************************************* - * Mouse - * *************************************************************************/ - -void mac_state::mouse_callback() -{ - int new_mx, new_my; - int x_needs_update = 0, y_needs_update = 0; - - new_mx = m_mouse1->read(); - new_my = m_mouse2->read(); - - /* see if it moved in the x coord */ - if (new_mx != last_mx) - { - int diff = new_mx - last_mx; - - /* check for wrap */ - if (diff > 0x80) - diff = 0x100-diff; - if (diff < -0x80) - diff = -0x100-diff; - - count_x += diff; - - last_mx = new_mx; - } - /* see if it moved in the y coord */ - if (new_my != last_my) - { - int diff = new_my - last_my; - - /* check for wrap */ - if (diff > 0x80) - diff = 0x100-diff; - if (diff < -0x80) - diff = -0x100-diff; - - count_y += diff; - - last_my = new_my; - } - - /* update any remaining count and then return */ - if (count_x) - { - if (count_x < 0) - { - count_x++; - m_mouse_bit_x = 0; - x_needs_update = 2; - } - else - { - count_x--; - m_mouse_bit_x = 1; - x_needs_update = 1; - } - } - else if (count_y) - { - if (count_y < 0) - { - count_y++; - m_mouse_bit_y = 1; - y_needs_update = 1; - } - else - { - count_y--; - m_mouse_bit_y = 0; - y_needs_update = 2; - } - } - - if (x_needs_update || y_needs_update) - /* assert Port B External Interrupt on the SCC */ - scc_mouse_irq(x_needs_update, y_needs_update ); -} - /* ************************************************************************* * SCSI * *************************************************************************/ @@ -757,108 +654,6 @@ WRITE_LINE_MEMBER(mac_state::drq_539x_1_w) * * Serial Communications Controller * *************************************************************************/ - -void mac_state::scc_mouse_irq(int x, int y) -{ - static int lasty = 0; - static int lastx = 0; - - if (x && y) - { - if (m_last_was_x) { - m_scc->set_status(0x0a); - if(x == 2) { - if(lastx) { - m_scc->set_reg_a(0, 0x04); - m_mouse_bit_x = 0; - } else { - m_scc->set_reg_a(0, 0x0C); - m_mouse_bit_x = 1; - } - } else { - if(lastx) { - m_scc->set_reg_a(0, 0x04); - m_mouse_bit_x = 1; - } else { - m_scc->set_reg_a(0, 0x0C); - m_mouse_bit_x = 0; - } - } - lastx = !lastx; - } else { - m_scc->set_status(0x02); - if(y == 2) { - if(lasty) { - m_scc->set_reg_b(0, 0x04); - m_mouse_bit_y = 0; - } else { - m_scc->set_reg_b(0, 0x0C); - m_mouse_bit_y = 1; - } - } else { - if(lasty) { - m_scc->set_reg_b(0, 0x04); - m_mouse_bit_y = 1; - } else { - m_scc->set_reg_b(0, 0x0C); - m_mouse_bit_y = 0; - } - } - lasty = !lasty; - } - - m_last_was_x ^= 1; - } - else - { - if (x) { - m_scc->set_status(0x0a); - if(x == 2) { - if(lastx) { - m_scc->set_reg_a(0, 0x04); - m_mouse_bit_x = 0; - } else { - m_scc->set_reg_a(0, 0x0C); - m_mouse_bit_x = 1; - } - } else { - if(lastx) { - m_scc->set_reg_a(0, 0x04); - m_mouse_bit_x = 1; - } else { - m_scc->set_reg_a(0, 0x0C); - m_mouse_bit_x = 0; - } - } - lastx = !lastx; - } else { - m_scc->set_status(0x02); - if(y == 2) { - if(lasty) { - m_scc->set_reg_b(0, 0x04); - m_mouse_bit_y = 0; - } else { - m_scc->set_reg_b(0, 0x0C); - m_mouse_bit_y = 1; - } - } else { - if(lasty) { - m_scc->set_reg_b(0, 0x04); - m_mouse_bit_y = 1; - } else { - m_scc->set_reg_b(0, 0x0C); - m_mouse_bit_y = 0; - } - } - lasty = !lasty; - } - } - - this->set_scc_interrupt(1); -} - - - uint16_t mac_state::mac_scc_r(offs_t offset) { uint16_t result; @@ -867,8 +662,6 @@ uint16_t mac_state::mac_scc_r(offs_t offset) return (result << 8) | result; } - - void mac_state::mac_scc_w(offs_t offset, uint16_t data) { m_scc->reg_w(offset, data); @@ -914,7 +707,7 @@ void mac_state::mac_iwm_w(offs_t offset, uint16_t data, uint16_t mem_mask) WRITE_LINE_MEMBER(mac_state::mac_adb_via_out_cb2) { - //printf("VIA OUT CB2 = %x (ticks %d)\n", state, m_adb_timer_ticks); + //printf("VIA OUT CB2 = %x\n", state); if (ADB_IS_EGRET) { m_egret->set_via_data(state & 1); @@ -925,17 +718,9 @@ WRITE_LINE_MEMBER(mac_state::mac_adb_via_out_cb2) } else { - if (m_adb_timer_ticks > 0) + if (m_macadb) { - m_adb_command <<= 1; - if (state) - { - m_adb_command |= 1; - } - else - { - m_adb_command &= ~1; - } + m_macadb->adb_data_w(state); } } } @@ -1039,7 +824,7 @@ uint8_t mac_state::mac_via_in_a_pmu() #if LOG_ADB // printf("Read PM data %x\n", m_pm_data_recv); #endif - return m_pm_data_recv; + return m_macadb->get_pm_data_recv(); } uint8_t mac_state::mac_via_in_b() @@ -1051,7 +836,7 @@ uint8_t mac_state::mac_via_in_b() if (ADB_IS_BITBANG_CLASS) { - val |= m_adb_state<<4; + val |= m_macadb->get_adb_state()<<4; if (!m_adb_irq_pending) { @@ -1068,17 +853,6 @@ uint8_t mac_state::mac_via_in_b() { val |= m_cuda->get_treq()<<3; } - else - { - if (m_mouse_bit_y) /* Mouse Y2 */ - val |= 0x20; - if (m_mouse_bit_x) /* Mouse X2 */ - val |= 0x10; - if ((m_mouse0->read() & 0x01) == 0) - val |= 0x08; - - val |= m_rtc->data_r(); - } // printf("%s VIA1 IN_B = %02x\n", machine().describe_context().c_str(), val); @@ -1091,7 +865,7 @@ uint8_t mac_state::mac_via_in_b_ii() if (ADB_IS_BITBANG_CLASS) { - val |= m_adb_state<<4; + val |= m_macadb->get_adb_state()<<4; if (!m_adb_irq_pending) { @@ -1133,7 +907,7 @@ uint8_t mac_state::mac_via_in_b_pmu() { int val = 0; // printf("Read VIA B: PM_ACK %x\n", m_pm_ack); - val = 0x80 | 0x04 | m_pm_ack; // SCC wait/request (bit 2 must be set at 900c1a or startup tests always fail) + val = 0x80 | 0x04 | m_macadb->get_pm_ack(); // SCC wait/request (bit 2 must be set at 900c1a or startup tests always fail) // printf("%s VIA1 IN_B = %02x\n", machine().describe_context().c_str(), val); @@ -1147,29 +921,6 @@ void mac_state::mac_via_out_a(uint8_t data) set_scc_waitrequest((data & 0x80) >> 7); m_screen_buffer = (data & 0x40) >> 6; sony_set_sel_line(m_fdc.target(), (data & 0x20) >> 5); - if (m_model == MODEL_MAC_SE) // on SE this selects which floppy drive (0 = upper, 1 = lower) - { - m_drive_select = ((data & 0x10) >> 4); - } - - if (m_model < MODEL_MAC_SE) // SE no longer has dual buffers - { - m_main_buffer = ((data & 0x08) == 0x08) ? true : false; - } - - if (m_model < MODEL_MAC_II) - { - m_snd_vol = data & 0x07; - update_volume(); - } - - /* Early Mac models had VIA A4 control overlaying. In the Mac SE (and - * possibly later models), overlay was set on reset, but cleared on the - * first access to the ROM. */ - if (m_model < MODEL_MAC_SE) - { - set_memory_overlay((data & 0x10) >> 4); - } } void mac_state::mac_via_out_a_pmu(uint8_t data) @@ -1179,61 +930,21 @@ void mac_state::mac_via_out_a_pmu(uint8_t data) #if LOG_ADB // printf("%02x to PM\n", data); #endif - m_pm_data_send = data; + m_macadb->set_pm_data_send(data); } void mac_state::mac_via_out_b(uint8_t data) { // printf("%s VIA1 OUT B: %02x\n", machine().describe_context().c_str(), data); - - if (AUDIO_IS_CLASSIC) - { - m_snd_enable = (data & 0x80) == 0; - update_volume(); - } - m_rtc->ce_w((data & 0x04)>>2); m_rtc->data_w(data & 0x01); m_rtc->clk_w((data >> 1) & 0x01); } -void mac_state::update_volume(void) -{ - if (AUDIO_IS_CLASSIC) - { - if (!m_snd_enable) - { - // ls161 clear input - m_dac->set_output_gain(ALL_OUTPUTS, 0); - } - else - { - // sound -> r13 (470k) - // sound -> r12 (470k) -> 4016 (pa0 != 0) - // sound -> r17 (150k) -> 4016 (pa1 != 0) - // sound -> r16 (68k) -> 4016 (pa2 != 0) - m_dac->set_output_gain(ALL_OUTPUTS, 8.0 / (m_snd_vol + 1)); - } - } -} - void mac_state::mac_via_out_b_bbadb(uint8_t data) { // printf("%s VIA1 OUT B: %02x\n", machine().describe_context().c_str(), data); - if (AUDIO_IS_CLASSIC) - { - m_snd_enable = (data & 0x80) == 0; - update_volume(); - } - - // SE and Classic have SCSI enable/disable here - if ((m_model == MODEL_MAC_SE) || (m_model == MODEL_MAC_CLASSIC)) - { - m_scsiirq_enable = (data & 0x40) ? 0 : 1; -// printf("VIAB & 0x40 = %02x, IRQ enable %d\n", data & 0x40, m_scsiirq_enable); - } - if (m_model == MODEL_MAC_SE30) { // 0x40 = 0 means enable vblank on SE/30 @@ -1246,7 +957,7 @@ void mac_state::mac_via_out_b_bbadb(uint8_t data) } } - mac_adb_newaction((data & 0x30) >> 4); + m_macadb->mac_adb_newaction((data & 0x30) >> 4); m_rtc->ce_w((data & 0x04)>>2); m_rtc->data_w(data & 0x01); @@ -1285,62 +996,7 @@ void mac_state::mac_via_out_b_pmu(uint8_t data) // printf("%s VIA1 OUT B: %02x\n", machine().describe_context().c_str(), data); sony_set_sel_line(m_fdc.target(), (data & 0x20) >> 5); - m_drive_select = ((data & 0x10) >> 4); - - if ((data & 1) && !(m_pm_req & 1)) - { - #if LOG_ADB - printf("PM: 68k dropping /REQ\n"); - #endif - - if (m_pm_state == 0) // do this in receive state only - { - m_pm_data_recv = 0xff; - m_pm_ack |= 2; - - // check if length byte matches - if ((m_pm_dptr >= 2) && (m_pm_cmd[1] == (m_pm_dptr-2))) - { - pmu_exec(); - #if LOG_ADB - printf("PMU exec: command %02x length %d\n", m_pm_cmd[0], m_pm_cmd[1]); - #endif - } - } - } - else if (!(data & 1) && (m_pm_req & 1)) - { - if (m_pm_state == 0) - { - #if LOG_ADB - printf("PM: 68k asserting /REQ, clocking in byte [%d] = %02x\n", m_pm_dptr, m_pm_data_send); - #endif - m_pm_ack &= ~2; // clear, we're waiting for more bytes - m_pm_cmd[m_pm_dptr++] = m_pm_data_send; - } - else // receiving, so this is different - { - m_pm_data_recv = m_pm_out[m_pm_sptr++]; - m_pm_slen--; - m_pm_ack |= 2; // raise ACK to indicate available byte - #if LOG_ADB - printf("PM: 68k asserted /REQ, sending byte %02x\n", m_pm_data_recv); - #endif - - // another byte to send? - if (m_pm_slen) - { - m_pmu_send_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(100))); - } - else - { - m_pm_state = 0; // back to receive state - m_pmu_send_timer->adjust(attotime::never); - } - } - } - - m_pm_req = data & 1; + m_macadb->pmu_req_w(data & 1); } WRITE_LINE_MEMBER(mac_state::mac_via_irq) @@ -1438,7 +1094,7 @@ uint8_t mac_state::mac_via2_in_a() uint8_t mac_state::mac_via2_in_a_pmu() { - return m_pm_data_recv; + return m_macadb->get_pm_data_recv(); } uint8_t mac_state::mac_via2_in_b() @@ -1462,7 +1118,7 @@ uint8_t mac_state::mac_via2_in_b_pmu() { // logerror("%s VIA2 IN B\n", machine().describe_context()); - if (m_pm_ack == 2) + if (m_macadb->get_pm_ack() == 2) { return 0xcf; } @@ -1480,7 +1136,7 @@ void mac_state::mac_via2_out_a(uint8_t data) void mac_state::mac_via2_out_a_pmu(uint8_t data) { // logerror("%s VIA2 OUT A: %02x\n", machine().describe_context(), data); - m_pm_data_send = data; + m_macadb->set_pm_data_send(data); } void mac_state::mac_via2_out_b(uint8_t data) @@ -1500,61 +1156,7 @@ void mac_state::mac_via2_out_b(uint8_t data) void mac_state::mac_via2_out_b_pmu(uint8_t data) { // logerror("%s VIA2 OUT B PMU: %02x\n", machine().describe_context(), data); - - if ((data & 4) && !(m_pm_req & 4)) - { - #if LOG_ADB - printf("PM: 68k dropping /REQ\n"); - #endif - - if (m_pm_state == 0) // do this in receive state only - { - m_pm_data_recv = 0xff; - m_pm_ack |= 2; - - // check if length byte matches - if ((m_pm_dptr >= 2) && (m_pm_cmd[1] == (m_pm_dptr-2))) - { - pmu_exec(); - #if LOG_ADB - printf("PMU exec: command %02x length %d\n", m_pm_cmd[0], m_pm_cmd[1]); - #endif - } - } - } - else if (!(data & 4) && (m_pm_req & 4)) - { - if (m_pm_state == 0) - { - #if LOG_ADB - printf("PM: 68k asserting /REQ, clocking in byte [%d] = %02x\n", m_pm_dptr, m_pm_data_send); - #endif - m_pm_ack &= ~2; // clear, we're waiting for more bytes - m_pm_cmd[m_pm_dptr++] = m_pm_data_send; - } - else // receiving, so this is different - { - m_pm_data_recv = m_pm_out[m_pm_sptr++]; - m_pm_slen--; - m_pm_ack |= 2; // raise ACK to indicate available byte - #if LOG_ADB - printf("PM: 68k asserted /REQ, sending byte %02x\n", m_pm_data_recv); - #endif - - // another byte to send? - if (m_pm_slen) - { - m_pmu_send_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(100))); - } - else - { - m_pm_state = 0; // back to receive state - m_pmu_send_timer->adjust(attotime::never); - } - } - } - - m_pm_req = data & 4; + m_macadb->pmu_req_w((data>>2) & 1); } // This signal is generated internally on RBV, V8, Sonora, VASP, Eagle, etc. @@ -1570,20 +1172,6 @@ TIMER_CALLBACK_MEMBER(mac_state::mac_6015_tick) void mac_state::machine_start() { - if (has_adb()) - { - this->m_adb_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mac_state::mac_adb_tick),this)); - this->m_adb_timer->adjust(attotime::never); - - // also allocate PMU timer - if (ADB_IS_PM_CLASS) - { - m_pmu_send_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mac_state::mac_pmu_tick),this)); - this->m_adb_timer->adjust(attotime::never); - m_pmu_int_status = 0; - } - } - if (m_screen) { this->m_scanline_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mac_state::mac_scanline_tick),this)); @@ -1632,7 +1220,7 @@ void mac_state::machine_reset() break; case 7833600*2: // "16 MHz" Macs - m_via_cycles = -30; + m_via_cycles = -32; break; case 20000000: // 20 MHz Macs @@ -1644,7 +1232,7 @@ void mac_state::machine_reset() break; case 7833600*4: // 32 MHz Macs (these are C7M * 4 like IIvx) - m_via_cycles = -60; + m_via_cycles = -62; break; case 33000000: // 33 MHz Macs ('040s) @@ -1667,10 +1255,10 @@ void mac_state::machine_reset() fatalerror("mac: unknown clock\n"); } - // clear PMU response timer - if (ADB_IS_PM_CLASS) + // Egret currently needs more dramatic VIA slowdowns. Need to determine what's realistic. + if (ADB_IS_EGRET) { - this->m_adb_timer->adjust(attotime::never); + m_via_cycles *= 35; } // default to 32-bit mode on LC @@ -1719,27 +1307,11 @@ void mac_state::machine_reset() m_via2->write_cb1(1); } - if (has_adb()) - { - this->adb_reset(); - } - - if ((m_model == MODEL_MAC_SE) || (m_model == MODEL_MAC_CLASSIC)) - { - // classic will fail RAM test and try to boot appletalk if RAM is not all zero - memset(m_ram->pointer(), 0, m_ram->size()); - } - m_scsi_interrupt = 0; - m_drive_select = 0; - m_scsiirq_enable = 0; m_via2_vbl = 0; m_se30_vbl_enable = 0; m_nubus_irq_state = 0xff; - 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; m_last_taken_interrupt = 0; } @@ -1878,13 +1450,6 @@ void mac_state::mac_driver_init(model_t model) m_overlay_timeout = (emu_timer *)nullptr; } - /* setup keyboard */ - /* clear key matrix for macadb */ - for (int i=0; i<7; i++) - { - m_key_matrix[i] = 0; - } - /* save state stuff */ machine().save().register_postload(save_prepost_delegate(FUNC(mac_state::mac_state_load), this)); } @@ -1976,9 +1541,9 @@ void mac_state::nubus_slot_interrupt(uint8_t slot, uint32_t state) void mac_state::vblank_irq() { /* handle ADB keyboard/mouse */ - if (has_adb()) + if (has_adb() && m_macadb) { - this->adb_vblank(); + m_macadb->adb_vblank(); } /* signal VBlank on CA1 input on the VIA */ @@ -2036,28 +1601,6 @@ TIMER_CALLBACK_MEMBER(mac_state::mac_scanline_tick) if (scanline == MAC_V_VIS) vblank_irq(); - /* check for mouse changes at 10 irqs per frame */ - if (m_model <= MODEL_MAC_PLUS) - { - if (!(scanline % 10)) - mouse_callback(); - } - - if (m_dac) - { - uint16_t *snd_buf_ptr; - if (m_main_buffer) - { - snd_buf_ptr = (uint16_t *)(m_ram->pointer() + m_ram->size() - MAC_MAIN_SND_BUF_OFFSET); - } - else - { - snd_buf_ptr = (uint16_t *)(m_ram->pointer() + m_ram->size() - MAC_ALT_SND_BUF_OFFSET); - } - - m_dac->write(snd_buf_ptr[scanline] >> 8); - } - int next_scanline = (scanline+1) % MAC_V_TOTAL; m_scanline_timer->adjust(m_screen->time_until_pos(next_scanline), next_scanline); } @@ -2221,7 +1764,7 @@ const char *lookup_trap(uint16_t opcode) { 0xA07F, "_InternalWait" }, { 0xA080, "_GetVideoDefault" }, { 0xA081, "_SetVideoDefault" }, - { 0xA082, "_DTInstall" }, + { 0xA082, "_`nstall" }, { 0xA083, "_SetOSDefault" }, { 0xA084, "_GetOSDefault" }, { 0xA085, "_PMgrOp" }, diff --git a/src/mame/machine/macadb.cpp b/src/mame/machine/macadb.cpp index c77be4a2889..4d0ffb2ae27 100644 --- a/src/mame/machine/macadb.cpp +++ b/src/mame/machine/macadb.cpp @@ -2,12 +2,12 @@ // copyright-holders:R. Belmont /*************************************************************************** - macadb.c - handles various aspects of ADB on the Mac. + macadb.cpp - handles various aspects of ADB on the Mac. ***************************************************************************/ #include "emu.h" -#include "includes/mac.h" +#include "macadb.h" #define LOG_ADB 0 #define LOG_ADB_MCU_CMD 0 @@ -24,6 +24,13 @@ #define ADB_CMD_RESET (0) #define ADB_CMD_FLUSH (1) +// use 1 MHz base to get microseconds +static constexpr int adb_timebase = 1000000; + +static constexpr int adb_short = 85; +static constexpr int adb_long = 157; +static constexpr int adb_srq = ((85+157)*3); + // ADB line states enum { @@ -67,6 +74,226 @@ enum LST_SENDSTOPa }; +// device type definition +DEFINE_DEVICE_TYPE(MACADB, macadb_device, "macadb", "Mac ADB HLE") + +static INPUT_PORTS_START( macadb ) + PORT_START("MOUSE0") /* Mouse - button */ + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("Mouse Button") PORT_CODE(MOUSECODE_BUTTON1) + + PORT_START("MOUSE1") /* Mouse - X AXIS */ + PORT_BIT( 0xff, 0x00, IPT_MOUSE_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) + + PORT_START("MOUSE2") /* Mouse - Y AXIS */ + PORT_BIT( 0xff, 0x00, IPT_MOUSE_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) + + /* This handles the standard (not Extended) Apple ADB keyboard, which is similar to the IIgs keyboard */ + PORT_START("KEY0") + PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_A) PORT_CHAR('a') PORT_CHAR('A') + PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_S) PORT_CHAR('s') PORT_CHAR('S') + PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_D) PORT_CHAR('d') PORT_CHAR('D') + PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F) PORT_CHAR('f') PORT_CHAR('F') + PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_H) PORT_CHAR('h') PORT_CHAR('H') + PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_G) PORT_CHAR('g') PORT_CHAR('G') + PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_Z) PORT_CHAR('z') PORT_CHAR('Z') + PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_X) PORT_CHAR('x') PORT_CHAR('X') + PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_C) PORT_CHAR('c') PORT_CHAR('C') + PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_V) PORT_CHAR('v') PORT_CHAR('V') + PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_UNUSED) /* extra key on ISO : */ + PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_B) PORT_CHAR('b') PORT_CHAR('B') + PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_Q) PORT_CHAR('q') PORT_CHAR('Q') + PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_W) PORT_CHAR('w') PORT_CHAR('W') + PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_E) PORT_CHAR('e') PORT_CHAR('E') + PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_R) PORT_CHAR('r') PORT_CHAR('R') + + PORT_START("KEY1") + PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_Y) PORT_CHAR('y') PORT_CHAR('Y') + PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_T) PORT_CHAR('t') PORT_CHAR('T') + PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!') + PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('@') + PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#') + PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$') + PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('^') + PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%') + PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('=') PORT_CHAR('+') + PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR('(') + PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('&') + PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('_') + PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('*') + PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_0) PORT_CHAR('0') PORT_CHAR(')') + PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(']') PORT_CHAR('}') + PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_O) PORT_CHAR('o') PORT_CHAR('O') + + PORT_START("KEY2") + PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_U) PORT_CHAR('u') PORT_CHAR('U') + PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[') PORT_CHAR('{') + PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_I) PORT_CHAR('i') PORT_CHAR('I') + PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_P) PORT_CHAR('p') PORT_CHAR('P') + PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Return") PORT_CODE(KEYCODE_ENTER) PORT_CHAR('\r') + PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_L) PORT_CHAR('l') PORT_CHAR('L') + PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_J) PORT_CHAR('j') PORT_CHAR('J') + PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR('\'') PORT_CHAR('"') + PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_K) PORT_CHAR('k') PORT_CHAR('K') + PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR(':') + PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\') PORT_CHAR('|') + PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<') + PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?') + PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_N) PORT_CHAR('n') PORT_CHAR('N') + PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_M) PORT_CHAR('m') PORT_CHAR('M') + PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>') + + PORT_START("KEY3") + PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_TAB) PORT_CHAR('\t') + PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') + PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('`') PORT_CHAR('~') + PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8) + PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_UNUSED) /* keyboard Enter : */ + PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Esc") PORT_CODE(KEYCODE_ESC) PORT_CHAR(27) + PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Control") PORT_CODE(KEYCODE_LCONTROL) + PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Command / Open Apple") PORT_CODE(KEYCODE_RALT) + PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Shift") PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1) + PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Caps Lock") PORT_CODE(KEYCODE_CAPSLOCK) PORT_TOGGLE + PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Option / Solid Apple") PORT_CODE(KEYCODE_LALT) + PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Left Arrow") PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT)) + PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Right Arrow") PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT)) + PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Down Arrow") PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN)) + PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Up Arrow") PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP)) + PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_UNUSED) /* ??? */ + + /* keypad */ + PORT_START("KEY4") + PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_UNUSED) // 0x40 + PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_DEL_PAD) PORT_CHAR(UCHAR_MAMEKEY(DEL_PAD)) // 0x41 + PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_UNUSED) // 0x42 + PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_ASTERISK) PORT_CHAR(UCHAR_MAMEKEY(ASTERISK)) // 0x43 + PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_UNUSED) // 0x44 + PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_PLUS_PAD) PORT_CHAR(UCHAR_MAMEKEY(PLUS_PAD)) // 0x45 + PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_UNUSED) // 0x46 + PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Keypad Clear") PORT_CODE(/*KEYCODE_NUMLOCK*/KEYCODE_DEL) PORT_CHAR(UCHAR_MAMEKEY(NUMLOCK)) // 0x47 + PORT_BIT(0x0700, IP_ACTIVE_HIGH, IPT_UNUSED) // 0x48, 49, 4a + PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_SLASH_PAD) PORT_CHAR(UCHAR_MAMEKEY(SLASH_PAD)) // 0x4b + PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_ENTER_PAD) PORT_CHAR(UCHAR_MAMEKEY(ENTER_PAD)) // 0x4c + PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_UNUSED) // 0x4d + PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS_PAD) PORT_CHAR(UCHAR_MAMEKEY(MINUS_PAD)) // 0x4e + PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_UNUSED) // 0x4f + + PORT_START("KEY5") + PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_UNUSED) // 0x50 + PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(/*CODE_OTHER*/KEYCODE_NUMLOCK) PORT_CHAR(UCHAR_MAMEKEY(EQUALS_PAD)) // 0x51 + PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_0_PAD) PORT_CHAR(UCHAR_MAMEKEY(0_PAD)) // 0x52 + PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_1_PAD) PORT_CHAR(UCHAR_MAMEKEY(1_PAD)) // 0x53 + PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_2_PAD) PORT_CHAR(UCHAR_MAMEKEY(2_PAD)) // 0x54 + PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_3_PAD) PORT_CHAR(UCHAR_MAMEKEY(3_PAD)) // 0x55 + PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_4_PAD) PORT_CHAR(UCHAR_MAMEKEY(4_PAD)) // 0x56 + PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_5_PAD) PORT_CHAR(UCHAR_MAMEKEY(5_PAD)) // 0x57 + PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_6_PAD) PORT_CHAR(UCHAR_MAMEKEY(6_PAD)) // 0x58 + PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_7_PAD) PORT_CHAR(UCHAR_MAMEKEY(7_PAD)) // 0x59 + PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_UNUSED) // 0x5a + PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_8_PAD) PORT_CHAR(UCHAR_MAMEKEY(8_PAD)) // 0x5b + PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_9_PAD) PORT_CHAR(UCHAR_MAMEKEY(9_PAD)) // 0x5c + PORT_BIT(0xE000, IP_ACTIVE_HIGH, IPT_UNUSED) +INPUT_PORTS_END + +macadb_device::macadb_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, MACADB, tag, owner, clock), + m_mouse0(*this, "MOUSE0"), + m_mouse1(*this, "MOUSE1"), + m_mouse2(*this, "MOUSE2"), + m_keys(*this, "KEY%u", 0), + write_via_clock(*this), + write_via_data(*this), + write_adb_data(*this), + write_adb_irq(*this), + m_bIsMCUMode(false), + m_bIsPMU(false), + m_bIsPMUVIA1(false) +{ +} + +ioport_constructor macadb_device::device_input_ports() const +{ + return INPUT_PORTS_NAME(macadb); +} + +void macadb_device::device_start() +{ + write_via_clock.resolve_safe(); + write_via_data.resolve_safe(); + write_adb_data.resolve_safe(); + write_adb_irq.resolve_safe(); + + this->m_adb_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(macadb_device::mac_adb_tick),this)); + this->m_adb_timer->adjust(attotime::never); + + // also allocate PMU timer + if (m_bIsPMU) + { + m_pmu_send_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(macadb_device::mac_pmu_tick),this)); + this->m_adb_timer->adjust(attotime::never); + m_pmu_int_status = 0; + } + + save_item(NAME(m_last_adb_time)); + save_item(NAME(m_key_matrix)); + save_item(NAME(m_adb_waiting_cmd)); + save_item(NAME(m_adb_datasize)); + save_item(NAME(m_adb_buffer)); + save_item(NAME(m_adb_command)); + save_item(NAME(m_adb_send)); + save_item(NAME(m_adb_timer_ticks)); + save_item(NAME(m_adb_extclock)); + save_item(NAME(m_adb_direction)); + save_item(NAME(m_adb_listenreg)); + save_item(NAME(m_adb_listenaddr)); + save_item(NAME(m_adb_last_talk)); + save_item(NAME(m_adb_srq_switch)); + save_item(NAME(m_adb_stream_ptr)); + save_item(NAME(m_adb_linestate)); + save_item(NAME(m_adb_srqflag)); + save_item(NAME(m_adb_keybuf)); + save_item(NAME(m_adb_keybuf_start)); + save_item(NAME(m_adb_keybuf_end)); + save_item(NAME(m_adb_mouseaddr)); + save_item(NAME(m_adb_lastmousex)); + save_item(NAME(m_adb_lastmousey)); + save_item(NAME(m_adb_lastbutton)); + save_item(NAME(m_adb_mouse_initialized)); + save_item(NAME(m_adb_keybaddr)); + save_item(NAME(m_adb_keybinitialized)); + save_item(NAME(m_adb_currentkeys)); + save_item(NAME(m_adb_modifiers)); + save_item(NAME(m_adb_pram)); + save_item(NAME(m_pm_ack)); + save_item(NAME(m_pm_cmd)); + save_item(NAME(m_pm_out)); + save_item(NAME(m_pm_dptr)); + save_item(NAME(m_pm_sptr)); + save_item(NAME(m_pm_slen)); + save_item(NAME(m_pm_state)); + save_item(NAME(m_pm_data_recv)); + save_item(NAME(m_pmu_int_status)); + save_item(NAME(m_pmu_last_adb_command)); + save_item(NAME(m_pmu_poll)); + save_item(NAME(m_pm_req)); + save_item(NAME(m_pm_data_send)); +} + +WRITE_LINE_MEMBER(macadb_device::adb_data_w) +{ + if (m_adb_timer_ticks > 0) + { + m_adb_command <<= 1; + if (state) + { + m_adb_command |= 1; + } + else + { + m_adb_command &= ~1; + } + } +} + /* ************************************************************************* * High-level ADB primitives used by all lower-level implementations * *************************************************************************/ @@ -75,7 +302,7 @@ enum static char const *const adb_statenames[4] = { "NEW", "EVEN", "ODD", "IDLE" }; #endif -int mac_state::adb_pollkbd(int update) +int macadb_device::adb_pollkbd(int update) { int i, j, keybuf, report, codes[2], result; @@ -211,7 +438,7 @@ int mac_state::adb_pollkbd(int update) return result; } -int mac_state::adb_pollmouse() +int macadb_device::adb_pollmouse() { int NewX, NewY, NewButton; @@ -232,7 +459,7 @@ int mac_state::adb_pollmouse() return 0; } -void mac_state::adb_accummouse( uint8_t *MouseX, uint8_t *MouseY ) +void macadb_device::adb_accummouse( uint8_t *MouseX, uint8_t *MouseY ) { int MouseCountX = 0, MouseCountY = 0; int NewX, NewY; @@ -276,7 +503,7 @@ void mac_state::adb_accummouse( uint8_t *MouseX, uint8_t *MouseY ) *MouseY = (uint8_t)MouseCountY; } -void mac_state::adb_talk() +void macadb_device::adb_talk() { int addr, reg; @@ -326,11 +553,8 @@ void mac_state::adb_talk() m_adb_command = 0; m_adb_listenreg = reg; m_adb_listenaddr = addr; - if ((ADB_IS_EGRET) || (ADB_IS_CUDA)) - { - m_adb_stream_ptr = 0; - memset(m_adb_buffer, 0, sizeof(m_adb_buffer)); - } + m_adb_stream_ptr = 0; + memset(m_adb_buffer, 0, sizeof(m_adb_buffer)); } else { @@ -532,9 +756,9 @@ void mac_state::adb_talk() } } -TIMER_CALLBACK_MEMBER(mac_state::mac_adb_tick) +TIMER_CALLBACK_MEMBER(macadb_device::mac_adb_tick) { - if ((ADB_IS_EGRET) || (ADB_IS_CUDA)) + if (m_bIsMCUMode) { switch (m_adb_linestate) { @@ -545,19 +769,19 @@ TIMER_CALLBACK_MEMBER(mac_state::mac_adb_tick) case LST_TSTOPSTART: set_adb_line(ASSERT_LINE); - m_adb_timer->adjust(attotime::from_ticks(57, 1000000)); + m_adb_timer->adjust(attotime::from_ticks(adb_short, adb_timebase)); m_adb_linestate++; break; case LST_TSTOPSTARTa: set_adb_line(CLEAR_LINE); - m_adb_timer->adjust(attotime::from_ticks(57, 1000000)); + m_adb_timer->adjust(attotime::from_ticks(adb_short, adb_timebase)); m_adb_linestate++; break; case LST_STARTBIT: set_adb_line(ASSERT_LINE); - m_adb_timer->adjust(attotime::from_ticks(105, 1000000)); + m_adb_timer->adjust(attotime::from_ticks(adb_long, adb_timebase)); m_adb_linestate++; break; @@ -572,13 +796,13 @@ TIMER_CALLBACK_MEMBER(mac_state::mac_adb_tick) set_adb_line(CLEAR_LINE); if (m_adb_buffer[m_adb_stream_ptr] & 0x80) { -// printf("1 "); - m_adb_timer->adjust(attotime::from_ticks(57, 1000000)); + //printf("1 "); + m_adb_timer->adjust(attotime::from_ticks(adb_short, adb_timebase)); } else { -// printf("0 "); - m_adb_timer->adjust(attotime::from_ticks(105, 1000000)); + //printf("0 "); + m_adb_timer->adjust(attotime::from_ticks(adb_long, adb_timebase)); } m_adb_linestate++; break; @@ -593,11 +817,11 @@ TIMER_CALLBACK_MEMBER(mac_state::mac_adb_tick) set_adb_line(ASSERT_LINE); if (m_adb_buffer[m_adb_stream_ptr] & 0x80) { - m_adb_timer->adjust(attotime::from_ticks(105, 1000000)); + m_adb_timer->adjust(attotime::from_ticks(adb_long, adb_timebase)); } else { - m_adb_timer->adjust(attotime::from_ticks(57, 1000000)); + m_adb_timer->adjust(attotime::from_ticks(adb_short, adb_timebase)); } m_adb_buffer[m_adb_stream_ptr] <<= 1; m_adb_linestate++; @@ -608,12 +832,12 @@ TIMER_CALLBACK_MEMBER(mac_state::mac_adb_tick) if (m_adb_buffer[m_adb_stream_ptr] & 0x80) { // printf(" "); - m_adb_timer->adjust(attotime::from_ticks(105, 1000000)); + m_adb_timer->adjust(attotime::from_ticks(adb_long, adb_timebase)); } else { // printf(" "); - m_adb_timer->adjust(attotime::from_ticks(57, 1000000)); + m_adb_timer->adjust(attotime::from_ticks(adb_short, adb_timebase)); } m_adb_stream_ptr++; @@ -629,7 +853,7 @@ TIMER_CALLBACK_MEMBER(mac_state::mac_adb_tick) case LST_SENDSTOP: set_adb_line(CLEAR_LINE); - m_adb_timer->adjust(attotime::from_ticks((57*2), 1000000)); + m_adb_timer->adjust(attotime::from_ticks((adb_short*2), adb_timebase)); m_adb_linestate++; break; @@ -645,7 +869,7 @@ TIMER_CALLBACK_MEMBER(mac_state::mac_adb_tick) // for input to Mac, the VIA reads on the *other* clock edge, so update this here if (!m_adb_direction) { - m_via1->write_cb2((m_adb_send & 0x80)>>7); + write_via_data((m_adb_send & 0x80)>>7); m_adb_send <<= 1; } @@ -653,13 +877,13 @@ TIMER_CALLBACK_MEMBER(mac_state::mac_adb_tick) //printf("ADB transition (%d)\n", m_adb_timer_ticks); if (m_adb_direction) { - m_via1->write_cb1(m_adb_extclock ^ 1); - m_via1->write_cb1(m_adb_extclock); + write_via_clock(m_adb_extclock ^ 1); + write_via_clock(m_adb_extclock); } else { - m_via1->write_cb1(m_adb_extclock); - m_via1->write_cb1(m_adb_extclock ^ 1); + write_via_clock(m_adb_extclock); + write_via_clock(m_adb_extclock ^ 1); } m_adb_timer_ticks--; @@ -667,7 +891,7 @@ TIMER_CALLBACK_MEMBER(mac_state::mac_adb_tick) { m_adb_timer->adjust(attotime::never); - if ((m_adb_direction) && (ADB_IS_BITBANG_CLASS)) + if ((m_adb_direction) && (!m_bIsMCUMode)) { adb_talk(); if((m_adb_last_talk == 2) && m_adb_datasize) { @@ -676,10 +900,10 @@ TIMER_CALLBACK_MEMBER(mac_state::mac_adb_tick) } } - if (!(m_adb_direction) && (ADB_IS_BITBANG_CLASS)) + if (!(m_adb_direction) && !(m_bIsMCUMode)) { - // m_via1->write_cb1(m_adb_extclock); - m_via1->write_cb1(m_adb_extclock ^ 1); + // write_via_clock(m_adb_extclock); + write_via_clock(m_adb_extclock ^ 1); } } else @@ -689,7 +913,7 @@ TIMER_CALLBACK_MEMBER(mac_state::mac_adb_tick) } } -void mac_state::mac_adb_newaction(int state) +void macadb_device::mac_adb_newaction(int state) { if (state != m_adb_state) { @@ -706,7 +930,7 @@ void mac_state::mac_adb_newaction(int state) m_adb_command = m_adb_send = 0; m_adb_direction = 1; // Mac is shifting us a command m_adb_waiting_cmd = 1; // we're going to get a command - m_adb_irq_pending = 0; + write_adb_irq(CLEAR_LINE); m_adb_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(100))); break; @@ -736,20 +960,20 @@ void mac_state::mac_adb_newaction(int state) else { m_adb_send = 0; - m_adb_irq_pending = 1; + write_adb_irq(ASSERT_LINE); } m_adb_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(100))); break; case ADB_STATE_IDLE: - m_adb_irq_pending = 0; + write_adb_irq(CLEAR_LINE); break; } } } -TIMER_CALLBACK_MEMBER(mac_state::mac_pmu_tick) +TIMER_CALLBACK_MEMBER(macadb_device::mac_pmu_tick) { // state 10 means this is in response to an ADB command if (m_pm_state == 10) @@ -761,9 +985,9 @@ TIMER_CALLBACK_MEMBER(mac_state::mac_pmu_tick) // tick CB1, which should cause a PMU interrupt on PMU machines m_adb_extclock ^= 1; - m_via1->write_cb1(m_adb_extclock); + write_via_clock(m_adb_extclock); m_adb_extclock ^= 1; - m_via1->write_cb1(m_adb_extclock); + write_via_clock(m_adb_extclock); } else { @@ -774,7 +998,7 @@ TIMER_CALLBACK_MEMBER(mac_state::mac_pmu_tick) } } -void mac_state::pmu_one_byte_reply(uint8_t result) +void macadb_device::pmu_one_byte_reply(uint8_t result) { m_pm_out[0] = m_pm_out[1] = 1; // length m_pm_out[2] = result; @@ -782,7 +1006,7 @@ void mac_state::pmu_one_byte_reply(uint8_t result) m_pmu_send_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(200))); } -void mac_state::pmu_three_byte_reply(uint8_t result1, uint8_t result2, uint8_t result3) +void macadb_device::pmu_three_byte_reply(uint8_t result1, uint8_t result2, uint8_t result3) { m_pm_out[0] = m_pm_out[1] = 3; // length m_pm_out[2] = result1; @@ -792,13 +1016,71 @@ void mac_state::pmu_three_byte_reply(uint8_t result1, uint8_t result2, uint8_t r m_pmu_send_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(200))); } -void mac_state::pmu_exec() +WRITE_LINE_MEMBER(macadb_device::pmu_req_w) +{ + if ((state) && !(m_pm_req & 1)) + { + #if LOG_ADB + printf("PM: 68k dropping /REQ\n"); + #endif + + if (m_pm_state == 0) // do this in receive state only + { + m_pm_data_recv = 0xff; + m_pm_ack |= 2; + + // check if length byte matches + if ((m_pm_dptr >= 2) && (m_pm_cmd[1] == (m_pm_dptr-2))) + { + pmu_exec(); + #if LOG_ADB + printf("PMU exec: command %02x length %d\n", m_pm_cmd[0], m_pm_cmd[1]); + #endif + } + } + } + else if (!(state) && (m_pm_req & 1)) + { + if (m_pm_state == 0) + { + #if LOG_ADB + printf("PM: 68k asserting /REQ, clocking in byte [%d] = %02x\n", m_pm_dptr, m_pm_data_send); + #endif + m_pm_ack &= ~2; // clear, we're waiting for more bytes + m_pm_cmd[m_pm_dptr++] = m_pm_data_send; + } + else // receiving, so this is different + { + m_pm_data_recv = m_pm_out[m_pm_sptr++]; + m_pm_slen--; + m_pm_ack |= 2; // raise ACK to indicate available byte + #if LOG_ADB + printf("PM: 68k asserted /REQ, sending byte %02x\n", m_pm_data_recv); + #endif + + // another byte to send? + if (m_pm_slen) + { + m_pmu_send_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(100))); + } + else + { + m_pm_state = 0; // back to receive state + m_pmu_send_timer->adjust(attotime::never); + } + } + } + + m_pm_req = state ? 1 : 0; +} + +void macadb_device::pmu_exec() { m_pm_sptr = 0; // clear send pointer m_pm_slen = 0; // and send length m_pm_dptr = 0; // and receive pointer -// printf("PMU: Command %02x\n", mac->m_pm_cmd[0]); + printf("PMU: Command %02x\n", m_pm_cmd[0]); switch (m_pm_cmd[0]) { case 0x10: // subsystem power and clock ctrl @@ -815,33 +1097,6 @@ void mac_state::pmu_exec() m_pm_cmd[5]); #endif - #if 0 - m_pm_state = 10; - m_pmu_send_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(200))); - if (ADB_IS_PM_VIA1_CLASS) - { - m_pmu_int_status = 0x1; - } - else if (ADB_IS_PM_VIA2_CLASS) - { - m_pmu_int_status = 0x10; - } - else - { - fatalerror("mac: unknown ADB PMU type\n"); - } - m_pmu_last_adb_command = m_pm_cmd[2]; - m_adb_command = m_pm_cmd[2]; - m_adb_waiting_cmd = 1; - adb_talk(); - - if ((m_pm_cmd[2] & 0xf) == 0xb) // LISTEN register 3 (remap) - { - m_adb_waiting_cmd = 0; - m_adb_command = mac->m_pm_cmd[5]; - adb_talk(); - } - #else if (((m_pm_cmd[2] == 0xfc) || (m_pm_cmd[2] == 0x2c)) && (m_pm_cmd[3] == 4)) { // printf("PMU: request to poll ADB, returning nothing\n"); @@ -852,25 +1107,21 @@ void mac_state::pmu_exec() { m_pm_state = 10; m_pmu_send_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(200))); - if (ADB_IS_PM_VIA1_CLASS) + if (m_bIsPMUVIA1) { m_pmu_int_status = 0x1; } - else if (ADB_IS_PM_VIA2_CLASS) - { - m_pmu_int_status = 0x10; - } else { - fatalerror("mac: unknown ADB PMU type\n"); + m_pmu_int_status = 0x10; } + m_pmu_last_adb_command = m_pm_cmd[2]; } m_adb_command = m_pm_cmd[2]; m_adb_waiting_cmd = 1; adb_talk(); - #endif break; case 0x21: // turn ADB auto-poll off (does this need a reply?) @@ -1013,7 +1264,7 @@ void mac_state::pmu_exec() break; case 0x78: // read interrupt flag - if (ADB_IS_PM_VIA2_CLASS) // PB 140/170 use a "leaner" PMU protocol where you get the data for a PMU interrupt here + if (!m_bIsPMUVIA1) // PB 140/170 use a "leaner" PMU protocol where you get the data for a PMU interrupt here { #if 0 if ((m_pmu_int_status&0xf0) == 0x10) @@ -1050,7 +1301,7 @@ void mac_state::pmu_exec() } else { - pmu_one_byte_reply(mac, m_pmu_int_status); + pmu_one_byte_reply(m_pmu_int_status); } #else if ((m_pmu_int_status&0xf0) == 0x10) @@ -1123,15 +1374,15 @@ void mac_state::pmu_exec() } } -void mac_state::adb_vblank() +void macadb_device::adb_vblank() { - if ((m_adb_state == ADB_STATE_IDLE) || ((ADB_IS_PM_CLASS) && (m_pmu_poll))) + if ((m_adb_state == ADB_STATE_IDLE) || ((m_bIsPMU) && (m_pmu_poll))) { if (this->adb_pollmouse()) { // if the mouse was the last TALK, we can just send the new data // otherwise we need to pull SRQ - if ((m_adb_last_talk == m_adb_mouseaddr) && !(ADB_IS_PM_CLASS)) + if ((m_adb_last_talk == m_adb_mouseaddr) && !(m_bIsPMU)) { // repeat last TALK to get updated data m_adb_waiting_cmd = 1; @@ -1140,26 +1391,9 @@ void mac_state::adb_vblank() m_adb_timer_ticks = 8; this->m_adb_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(100))); } - #if 0 - else if (ADB_IS_PM_CLASS) - { - m_adb_waiting_cmd = 1; - this->adb_talk(); - m_pm_state = 10; - m_pmu_send_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(200))); - if (ADB_IS_PM_VIA1_CLASS) - { - m_pmu_int_status = 0x1; - } - else if (ADB_IS_PM_VIA2_CLASS) - { - m_pmu_int_status = 0x10; - } - } - #endif else { - m_adb_irq_pending = 1; + write_adb_irq(ASSERT_LINE); m_adb_command = m_adb_send = 0; m_adb_timer_ticks = 1; // one tick should be sufficient to make it see the IRQ this->m_adb_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(100))); @@ -1168,7 +1402,7 @@ void mac_state::adb_vblank() } else if (this->adb_pollkbd(0)) { - if ((m_adb_last_talk == m_adb_keybaddr) && !(ADB_IS_PM_CLASS)) + if ((m_adb_last_talk == m_adb_keybaddr) && !(m_bIsPMU)) { // repeat last TALK to get updated data m_adb_waiting_cmd = 1; @@ -1178,7 +1412,7 @@ void mac_state::adb_vblank() this->m_adb_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(100))); } #if 0 - else if (ADB_IS_PM_CLASS) + else if (m_bIsPMU) { m_adb_waiting_cmd = 1; this->adb_talk(); @@ -1189,7 +1423,7 @@ void mac_state::adb_vblank() #endif else { - m_adb_irq_pending = 1; + write_adb_irq(ASSERT_LINE); m_adb_command = m_adb_send = 0; m_adb_timer_ticks = 1; // one tick should be sufficient to make it see the IRQ this->m_adb_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(100))); @@ -1199,12 +1433,14 @@ void mac_state::adb_vblank() } } -void mac_state::adb_reset() +void macadb_device::device_reset() { int i; + m_pm_data_send = m_pm_data_recv = m_pm_ack = m_pm_req = m_pm_dptr = 0; + m_pm_state = 0; m_adb_srq_switch = 0; - m_adb_irq_pending = 0; // no interrupt + write_adb_irq(CLEAR_LINE); // no interrupt m_adb_timer_ticks = 0; m_adb_command = 0; m_adb_extclock = 0; @@ -1213,10 +1449,7 @@ void mac_state::adb_reset() m_adb_state = 0; m_adb_srqflag = false; m_pmu_poll = 0; - if (ADB_IS_BITBANG_CLASS) - { - m_adb_state = ADB_STATE_NOTINIT; - } + m_adb_state = ADB_STATE_NOTINIT; m_adb_direction = 0; m_adb_datasize = 0; m_adb_last_talk = -1; @@ -1239,12 +1472,13 @@ void mac_state::adb_reset() } m_adb_keybuf_start = 0; m_adb_keybuf_end = 0; + + m_last_adb_time = 0; } -WRITE_LINE_MEMBER(mac_state::adb_linechange_w) +WRITE_LINE_MEMBER(macadb_device::adb_linechange_w) { - int dtime = 0; -/* static char const *const states[] = + /* static char const *const states[] = { "idle", "attention", @@ -1262,16 +1496,10 @@ WRITE_LINE_MEMBER(mac_state::adb_linechange_w) "srqnodata" };*/ - if (ADB_IS_EGRET) - { - dtime = m_egret->get_adb_dtime(); - } - else if (ADB_IS_CUDA) - { - dtime = m_cuda->get_adb_dtime(); - } + int dtime = (int)(machine().time().as_ticks(adb_timebase) - m_last_adb_time); + m_last_adb_time = machine().time().as_ticks(adb_timebase); -/* if (m_adb_linestate <= 12) + /*if (m_adb_linestate <= 12) { printf("linechange: %d -> %d, time %d (state %d = %s)\n", state^1, state, dtime, m_adb_linestate, states[m_adb_linestate]); } @@ -1386,7 +1614,7 @@ WRITE_LINE_MEMBER(mac_state::adb_linechange_w) printf("%02x ", m_adb_buffer[i]); }*/ m_adb_linestate = LST_TSTOPSTART; // T1t - m_adb_timer->adjust(attotime::from_ticks(324/4, 1000000)); + m_adb_timer->adjust(attotime::from_ticks(324/4, adb_timebase)); m_adb_stream_ptr = 0; } else if (m_adb_direction) // if direction is set, we LISTENed to a valid device @@ -1398,7 +1626,7 @@ WRITE_LINE_MEMBER(mac_state::adb_linechange_w) if (m_adb_srqflag) { m_adb_linestate = LST_SRQNODATA; - m_adb_timer->adjust(attotime::from_ticks(486, 1000000)); // SRQ time + m_adb_timer->adjust(attotime::from_ticks(adb_srq, adb_timebase)); // SRQ time } else { @@ -1426,15 +1654,3 @@ WRITE_LINE_MEMBER(mac_state::adb_linechange_w) break; } } - -void mac_state::set_adb_line(int linestate) -{ - if (ADB_IS_EGRET) - { - m_egret->set_adb_line(linestate); - } - else if (ADB_IS_CUDA) - { - m_cuda->set_adb_line(linestate); - } -} diff --git a/src/mame/machine/macadb.h b/src/mame/machine/macadb.h index 6a8d16a718e..6b2fff18880 100644 --- a/src/mame/machine/macadb.h +++ b/src/mame/machine/macadb.h @@ -1,2 +1,112 @@ // license:BSD-3-Clause // copyright-holders:R. Belmont +#ifndef MAME_MACHINE_MACADB_H +#define MAME_MACHINE_MACADB_H + +#pragma once + +#include "emu.h" + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> macadb_device + +class macadb_device : public device_t +{ +public: + // construction/destruction + macadb_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + + void set_mcu_mode(bool bMCUMode) { m_bIsMCUMode = bMCUMode; } + void set_pmu_mode(bool bPMUMode) { m_bIsPMU = bPMUMode; } + void set_pmu_is_via1(bool bPMUVIA1) { m_bIsPMUVIA1 = bPMUVIA1; } + + auto via_clock_callback() { return write_via_clock.bind(); } + auto via_data_callback() { return write_via_data.bind(); } + auto adb_data_callback() { return write_adb_data.bind(); } + auto adb_irq_callback() { return write_adb_irq.bind(); } + + required_ioport m_mouse0, m_mouse1, m_mouse2; + required_ioport_array<6> m_keys; + devcb_write_line write_via_clock, write_via_data, write_adb_data, write_adb_irq; + + DECLARE_WRITE_LINE_MEMBER(adb_data_w); + DECLARE_WRITE_LINE_MEMBER(adb_linechange_w); + + void adb_vblank(); + void mac_adb_newaction(int state); + int32_t get_adb_state(void) { return m_adb_state; } + + void pmu_exec(); + int get_pm_data_recv(void) { return m_pm_data_recv; } + int get_pm_ack(void) { return m_pm_ack; } + void set_pm_data_send(int data) { m_pm_data_send = data; } + DECLARE_WRITE_LINE_MEMBER(pmu_req_w); + +protected: + // device-level overrides + virtual ioport_constructor device_input_ports() const override; + virtual void device_start() override; + virtual void device_reset() override; + +private: + bool m_bIsMCUMode; + bool m_bIsPMU; + bool m_bIsPMUVIA1; + + uint64_t m_last_adb_time; + + emu_timer *m_adb_timer; + + /* keyboard matrix to detect transition */ + int m_key_matrix[7]; + + // ADB HLE state + int32_t m_adb_state, m_adb_waiting_cmd, m_adb_datasize, m_adb_buffer[257]; + int32_t m_adb_command, m_adb_send, m_adb_timer_ticks, m_adb_extclock, m_adb_direction; + int32_t m_adb_listenreg, m_adb_listenaddr, m_adb_last_talk, m_adb_srq_switch; + int32_t m_adb_stream_ptr; + int32_t m_adb_linestate; + bool m_adb_srqflag; + + #define kADBKeyBufSize 32 + uint8_t m_adb_keybuf[kADBKeyBufSize]; + uint8_t m_adb_keybuf_start; + uint8_t m_adb_keybuf_end; + + // Portable/PB100 Power Manager IC comms (chapter 4, "Guide to the Macintosh Family Hardware", second edition) + uint8_t m_pm_ack, m_pm_cmd[32], m_pm_out[32], m_pm_dptr, m_pm_sptr, m_pm_slen, m_pm_state, m_pm_data_recv; + uint8_t m_pmu_int_status, m_pmu_last_adb_command, m_pmu_poll, m_pm_req, m_pm_data_send; + emu_timer *m_pmu_send_timer; + + // ADB mouse state + int m_adb_mouseaddr; + int m_adb_lastmousex, m_adb_lastmousey, m_adb_lastbutton, m_adb_mouse_initialized; + + // ADB keyboard state + int m_adb_keybaddr; + int m_adb_keybinitialized, m_adb_currentkeys[2], m_adb_modifiers; + + // PRAM for ADB MCU HLEs (mostly unused now) + uint8_t m_adb_pram[256]; + + int adb_pollkbd(int update); + int adb_pollmouse(); + void adb_accummouse( uint8_t *MouseX, uint8_t *MouseY ); + void adb_talk(); + + void pmu_one_byte_reply(uint8_t result); + void pmu_three_byte_reply(uint8_t result1, uint8_t result2, uint8_t result3); + + inline void set_adb_line(int linestate) { write_adb_data(linestate); } + + TIMER_CALLBACK_MEMBER(mac_adb_tick); // macadb.c + TIMER_CALLBACK_MEMBER(mac_pmu_tick); // macadb.c +}; + +// device type definition +DECLARE_DEVICE_TYPE(MACADB, macadb_device) + +#endif // MAME_MACHINE_MACADB_H |