diff options
author | arbee <rb6502@users.noreply.github.com> | 2021-02-24 20:46:24 -0500 |
---|---|---|
committer | arbee <rb6502@users.noreply.github.com> | 2021-02-24 20:46:24 -0500 |
commit | 2ea2a582f39390bb4b2210c0ccc4455b57000749 (patch) | |
tree | adbc5f529bf025991f902198c52154f9cbe30c3e | |
parent | c186e7eb3aaa637390ea6f6bae75a99eecda8db2 (diff) |
mac updates: [R. Belmont]
- Adjust macadb timings to work with real timings from the microcontrollers
- Eliminate via_cycles timing hack
- Preliminary working ADB on Portable and PowerBook 100
-rw-r--r-- | src/mame/drivers/macprtb.cpp | 7 | ||||
-rw-r--r-- | src/mame/drivers/macpwrbk030.cpp | 6 | ||||
-rw-r--r-- | src/mame/includes/mac.h | 5 | ||||
-rw-r--r-- | src/mame/machine/mac.cpp | 57 | ||||
-rw-r--r-- | src/mame/machine/macadb.cpp | 24 | ||||
-rw-r--r-- | src/mame/machine/macadb.h | 1 |
6 files changed, 28 insertions, 72 deletions
diff --git a/src/mame/drivers/macprtb.cpp b/src/mame/drivers/macprtb.cpp index 8950f7aa8c1..ed539694429 100644 --- a/src/mame/drivers/macprtb.cpp +++ b/src/mame/drivers/macprtb.cpp @@ -239,8 +239,9 @@ private: int m_adb_line; void set_adb_line(int state) { m_adb_line = state; } u8 pmu_adb_r() { return (m_adb_line<<1); } - void pmu_adb_w(u8 data) { m_macadb->adb_linechange_w(data & 1); } + void pmu_adb_w(u8 data) { m_macadb->adb_linechange_w((data & 1) ^ 1); } u8 pmu_in_r() { return 0x20; } // bit 5 is 0 if the Target Disk Mode should be enabled on the PB100 + u8 ad_in_r() { return 0xff; } }; void macportable_state::field_interrupts() @@ -389,6 +390,7 @@ TIMER_CALLBACK_MEMBER(macportable_state::mac_6015_tick) m_via1->write_ca1(m_ca1_data); m_pmu->set_input_line(m50753_device::M50753_INT1_LINE, ASSERT_LINE); + m_macadb->adb_vblank(); if (++m_irq_count == 60) { @@ -441,6 +443,7 @@ void macportable_state::macprtb_map(address_map &map) map(0xfb0000, 0xfbffff).rw(m_asc, FUNC(asc_device::read), FUNC(asc_device::write)); map(0xfc0000, 0xfcffff).r(FUNC(macportable_state::mac_config_r)); map(0xfd0000, 0xfdffff).rw(FUNC(macportable_state::mac_scc_r), FUNC(macportable_state::mac_scc_2_w)); + map(0xfe0000, 0xfe0001).noprw(); map(0xfffff0, 0xffffff).rw(FUNC(macportable_state::mac_autovector_r), FUNC(macportable_state::mac_autovector_w)); } @@ -517,6 +520,8 @@ void macportable_state::macprtb(machine_config &config) m_pmu->read_p<4>().set(FUNC(macportable_state::pmu_adb_r)); m_pmu->write_p<4>().set(FUNC(macportable_state::pmu_adb_w)); m_pmu->read_in_p().set(FUNC(macportable_state::pmu_in_r)); + m_pmu->ad_in<0>().set(FUNC(macportable_state::ad_in_r)); + m_pmu->ad_in<1>().set(FUNC(macportable_state::ad_in_r)); M50740(config, "kybd", 3.93216_MHz_XTAL).set_disable(); diff --git a/src/mame/drivers/macpwrbk030.cpp b/src/mame/drivers/macpwrbk030.cpp index 5c92ef275fa..f18ad6d5ce3 100644 --- a/src/mame/drivers/macpwrbk030.cpp +++ b/src/mame/drivers/macpwrbk030.cpp @@ -267,8 +267,9 @@ private: int m_adb_line; void set_adb_line(int state) { m_adb_line = state; } u8 pmu_adb_r() { return (m_adb_line<<1); } - void pmu_adb_w(u8 data) { m_macadb->adb_linechange_w(data & 1); } - u8 pmu_in_r() { return 0x20; } // bit 5 is 0 if the Target Disk Mode should be enabled on the PB100 + void pmu_adb_w(u8 data) { m_macadb->adb_linechange_w((data & 1) ^ 1); } + + u8 pmu_in_r() { return 0x20; } // bit 5 is 0 if the Target Disk Mode should be enabled }; // 4-level grayscale @@ -520,6 +521,7 @@ TIMER_CALLBACK_MEMBER(macpb030_state::mac_6015_tick) m_via1->write_ca1(m_ca1_data); m_pmu->set_input_line(m50753_device::M50753_INT1_LINE, ASSERT_LINE); + m_macadb->adb_vblank(); if (++m_irq_count == 60) { diff --git a/src/mame/includes/mac.h b/src/mame/includes/mac.h index 9e1fcb28f54..336a4543f52 100644 --- a/src/mame/includes/mac.h +++ b/src/mame/includes/mac.h @@ -33,7 +33,7 @@ #include "emupal.h" #include "screen.h" -#define NEW_SWIM 0 +#define NEW_SWIM 1 #define MAC_SCREEN_NAME "screen" #define MAC_539X_1_TAG "539x_1" @@ -378,9 +378,6 @@ private: inline bool has_adb() { return m_model >= MODEL_MAC_SE; } - // wait states for accessing the VIA - int m_via_cycles; - uint8_t m_oss_regs[0x400]; // AMIC for x100 PowerMacs diff --git a/src/mame/machine/mac.cpp b/src/mame/machine/mac.cpp index 9a3f1ebb14e..cfa8d4207ea 100644 --- a/src/mame/machine/mac.cpp +++ b/src/mame/machine/mac.cpp @@ -1128,63 +1128,6 @@ void mac_state::machine_reset() m_6015_timer->adjust(attotime::from_hz(60.15), 0, attotime::from_hz(60.15)); } - // we use the CPU clock divided by the VIA clock (783360 Hz) rounded up as - // an approximation for the right number of wait states. this yields good - // results - it's towards the end of the worst-case delay on h/w. - switch (m_maincpu->clock()) - { - case 7833600: // C7M on classic Macs - m_via_cycles = -10; - break; - - case 7833600*2: // "16 MHz" Macs - m_via_cycles = -32; - break; - - case 20000000: // 20 MHz Macs - m_via_cycles = -40; - break; - - case 25000000: // 25 MHz Macs - m_via_cycles = -50; - break; - - case 7833600*4: // 32 MHz Macs (these are C7M * 4 like IIvx) - m_via_cycles = -62; - break; - - case 33000000: // 33 MHz Macs ('040s) - m_via_cycles = -64; - break; - - case 40000000: // 40 MHz Macs - m_via_cycles = -80; - break; - - case 60000000: // 60 MHz PowerMac - m_via_cycles = -120; - break; - - case 66000000: // 66 MHz PowerMac - m_via_cycles = -128; - break; - - default: - fatalerror("mac: unknown clock\n"); - } - - // Egret currently needs a larger VIA slowdown - if (ADB_IS_EGRET) - { - m_via_cycles *= 2; - } - - // And a little more for Cuda. - if (ADB_IS_CUDA) - { - m_via_cycles *= 3; - } - // default to 32-bit mode on LC if (m_model == MODEL_MAC_LC) { diff --git a/src/mame/machine/macadb.cpp b/src/mame/machine/macadb.cpp index 0d61c247bda..f2d7fe357a9 100644 --- a/src/mame/machine/macadb.cpp +++ b/src/mame/machine/macadb.cpp @@ -26,12 +26,12 @@ static constexpr int32_t ADB_STATE_NOTINIT = 4; static constexpr int ADB_CMD_RESET = 0; static constexpr int ADB_CMD_FLUSH = 1; -// use 1 MHz base to get microseconds -static constexpr int adb_timebase = 1000000; +// use 1 MHz base to get microseconds (hack: *2 to get old wrong HC05 numbers to all realign to reality) +static constexpr int adb_timebase = 2000000; static constexpr int adb_short = 85; static constexpr int adb_long = 157; -static constexpr int adb_srq = ((85+157)*3); +static constexpr int adb_srq = ((85+157)*4); // ADB line states enum @@ -229,6 +229,7 @@ void macadb_device::device_start() m_adb_listenreg = 0; m_adb_listenaddr = 0; m_adb_stream_ptr = 0; + m_adb_linein = 0; std::fill(std::begin(m_adb_keybuf), std::end(m_adb_keybuf), 0); std::fill(std::begin(m_adb_pram), std::end(m_adb_pram), 0); @@ -262,6 +263,7 @@ void macadb_device::device_start() save_item(NAME(m_adb_currentkeys)); save_item(NAME(m_adb_modifiers)); save_item(NAME(m_adb_pram)); + save_item(NAME(m_adb_linein)); } WRITE_LINE_MEMBER(macadb_device::adb_data_w) @@ -1024,7 +1026,7 @@ void macadb_device::device_reset() WRITE_LINE_MEMBER(macadb_device::adb_linechange_w) { - /* static char const *const states[] = +/* static char const *const states[] = { "idle", "attention", @@ -1042,10 +1044,16 @@ WRITE_LINE_MEMBER(macadb_device::adb_linechange_w) "srqnodata" };*/ + if (state == m_adb_linein) + { + return; + } + m_adb_linein = state; + 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]); } @@ -1076,11 +1084,11 @@ WRITE_LINE_MEMBER(macadb_device::adb_linechange_w) case LST_IDLE: if ((state) && (dtime >= 4500)) // reset { - LOGMASKED(LOG_LINESTATE, "ADB RESET\n"); + //printf("ADB RESET\n"); } else if ((state) && (dtime >= 1200)) // attention { - LOGMASKED(LOG_LINESTATE, "ADB ATTENTION\n"); + //printf("ADB ATTENTION\n"); m_adb_waiting_cmd = 1; m_adb_direction = 0; m_adb_linestate++; @@ -1090,7 +1098,7 @@ WRITE_LINE_MEMBER(macadb_device::adb_linechange_w) case LST_ATTENTION: if ((!state) && (dtime >= 90)) // Tsync { - LOGMASKED(LOG_LINESTATE, "ADB Tsync\n"); + //printf("ADB Tsync\n"); m_adb_command = 0; m_adb_linestate++; } diff --git a/src/mame/machine/macadb.h b/src/mame/machine/macadb.h index 8e284fb80c6..79f8ab63736 100644 --- a/src/mame/machine/macadb.h +++ b/src/mame/machine/macadb.h @@ -60,6 +60,7 @@ private: int32_t m_adb_stream_ptr; int32_t m_adb_linestate; bool m_adb_srqflag; + int m_adb_linein; #define kADBKeyBufSize 32 uint8_t m_adb_keybuf[kADBKeyBufSize]; |