diff options
Diffstat (limited to 'src/mame/drivers/ti99_4p.cpp')
-rw-r--r-- | src/mame/drivers/ti99_4p.cpp | 189 |
1 files changed, 111 insertions, 78 deletions
diff --git a/src/mame/drivers/ti99_4p.cpp b/src/mame/drivers/ti99_4p.cpp index 3b0be43a5b4..215916f68e6 100644 --- a/src/mame/drivers/ti99_4p.cpp +++ b/src/mame/drivers/ti99_4p.cpp @@ -132,12 +132,12 @@ #define LOG_WARN (1U<<1) // Warnings #define LOG_ILLWRITE (1U<<2) #define LOG_READY (1U<<3) -#define LOG_INT (1U<<4) +#define LOG_INTERRUPTS (1U<<4) #define LOG_ADDRESS (1U<<5) #define LOG_MEM (1U<<6) #define LOG_MUX (1U<<7) -#define VERBOSE ( LOG_WARN ) +#define VERBOSE ( LOG_GENERAL | LOG_WARN ) #include "logmacro.h" @@ -177,7 +177,7 @@ private: // CRU (Communication Register Unit) handling uint8_t cruread(offs_t offset); void cruwrite(offs_t offset, uint8_t data); - uint8_t read_by_9901(offs_t offset); + uint8_t psi_input(offs_t offset); DECLARE_WRITE_LINE_MEMBER(keyC0); DECLARE_WRITE_LINE_MEMBER(keyC1); DECLARE_WRITE_LINE_MEMBER(keyC2); @@ -195,6 +195,10 @@ private: void datamux_clock_in(int clock); + // Latch for 9901 INT1 and INT2 lines + int m_int1; + int m_int2; + // Devices required_device<tms9900_device> m_cpu; required_device<tms9901_device> m_tms9901; @@ -217,7 +221,7 @@ private: uint16_t *m_rom; // First joystick. 6 for TI-99/4A - int m_firstjoy; + static constexpr int FIRSTJOY=6; int m_keyboard_column; int m_check_alphalock; @@ -274,10 +278,6 @@ private: // Mapper registers uint8_t m_mapper[16]; - // Latch for 9901 INT2, INT1 lines - int m_9901_int; - void set_9901_int(int line, line_state state); - int m_ready_prev; // for debugging purposes only }; @@ -377,7 +377,7 @@ static INPUT_PORTS_START(ti99_4p) PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('-') PORT_START("ALPHA") /* one more port for Alpha line */ - PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Alpha Lock") PORT_CODE(KEYCODE_CAPSLOCK) PORT_TOGGLE + PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Alpha Lock") PORT_CODE(KEYCODE_CAPSLOCK) PORT_TOGGLE INPUT_PORTS_END @@ -725,61 +725,103 @@ uint8_t ti99_4p_state::cruread(offs_t offset) Keyboard/tape control ****************************************************************************/ -uint8_t ti99_4p_state::read_by_9901(offs_t offset) +uint8_t ti99_4p_state::psi_input(offs_t offset) { - int answer=0; - - switch (offset & 0x03) + switch (offset) { - case tms9901_device::CB_INT7: - // Read pins INT3*-INT7* of TI99's 9901. - // bit 1: INT1 status - // bit 2: INT2 status - // bit 3-7: keyboard status bits 0 to 4 - // - // |K|K|K|K|K|I2|I1|C| - // - if (m_keyboard_column >= m_firstjoy) // joy 1 and 2 - { - answer = m_joyport->read_port(); - } + case tms9901_device::INT1: + return (m_int1==CLEAR_LINE)? 1 : 0; + case tms9901_device::INT2: + return (m_int2==CLEAR_LINE)? 1 : 0; + case tms9901_device::INT3: + case tms9901_device::INT4: + case tms9901_device::INT5: + case tms9901_device::INT6: + // Keyboard ACTIVE_LOW (s.o.) + // Joysticks ACTIVE_LOW (handset.cpp) + if (m_keyboard_column >= 6) + return BIT(m_joyport->read_port(), offset-tms9901_device::INT3); + else + return BIT(m_keyboard[m_keyboard_column]->read(), offset-tms9901_device::INT3); + + case tms9901_device::INT7_P15: + if (m_keyboard_column >= 6) // Joysticks + return BIT(m_joyport->read_port(), offset-tms9901_device::INT3); else { - answer = m_keyboard[m_keyboard_column]->read(); - } - if (m_check_alphalock) - { - answer &= ~(m_alpha->read()); + if (m_check_alphalock) + { + return BIT(m_alpha->read(), offset-tms9901_device::INT3); + } + else + return BIT(m_keyboard[m_keyboard_column]->read(), offset-tms9901_device::INT3); } - answer = (answer << 3) | m_9901_int; - break; - - case tms9901_device::INT8_INT15: - // Read pins int8_t*-INT15* of TI99's 9901. - // bit 0-2: keyboard status bits 5 to 7 - // bit 3: tape input mirror - // bit 5-7: weird, not emulated - // |1|1|1|1|0|K|K|K| - if (m_keyboard_column >= m_firstjoy) answer = 0x07; - else answer = ((m_keyboard[m_keyboard_column]->read())>>5) & 0x07; - answer |= 0xf0; - break; - - case tms9901_device::P0_P7: - break; - - case tms9901_device::P8_P15: - // Read pins P8-P15 of TI99's 9901. - // bit 26: high - // bit 27: tape input - answer = 4; - if (m_cassette->input() > 0) answer |= 8; - break; + case tms9901_device::INT8_P14: + case tms9901_device::INT9_P13: + case tms9901_device::INT10_P12: + if (m_keyboard_column >= FIRSTJOY) // no joystick lines after /INT7 + return 1; + else + return BIT(m_keyboard[m_keyboard_column]->read(), offset-tms9901_device::INT3); + case tms9901_device::INT11_P11: + // CS2 is write-only + return (m_cassette->input() > 0); + default: + return 1; } - return answer; } +/* switch (offset & 0x03) + { + case tms9901_device::CB_INT7: + // Read pins INT3*-INT7* of TI99's 9901. + // bit 1: INT1 status + // bit 2: INT2 status + // bit 3-7: keyboard status bits 0 to 4 + // + // |K|K|K|K|K|I2|I1|C| + // + if (m_keyboard_column >= FIRSTJOY) // joy 1 and 2 + { + answer = m_joyport->read_port(); + } + else + { + answer = m_keyboard[m_keyboard_column]->read(); + } + if (m_check_alphalock) + { + answer &= ~(m_alpha->read()); + } + answer = (answer << 3) | m_9901_int; + break; + + case tms9901_device::INT8_INT15: + // Read pins int8_t*-INT15* of TI99's 9901. + // bit 0-2: keyboard status bits 5 to 7 + // bit 3: tape input mirror + // bit 5-7: weird, not emulated + + // |1|1|1|1|0|K|K|K| + if (m_keyboard_column >= FIRSTJOY) answer = 0x07; + else answer = ((m_keyboard[m_keyboard_column]->read())>>5) & 0x07; + answer |= 0xf0; + break; + + case tms9901_device::P0_P7: + break; + + case tms9901_device::P8_P15: + // Read pins P8-P15 of TI99's 9901. + // bit 26: high + // bit 27: tape input + answer = 4; + if (m_cassette->input() > 0) answer |= 8; + break; + } + */ + /* WRITE key column select (P2-P4) */ @@ -788,9 +830,9 @@ void ti99_4p_state::set_keyboard_column(int number, int data) if (data!=0) m_keyboard_column |= 1 << number; else m_keyboard_column &= ~(1 << number); - if (m_keyboard_column >= m_firstjoy) + if (m_keyboard_column >= FIRSTJOY) { - m_joyport->write_port(m_keyboard_column - m_firstjoy + 1); + m_joyport->write_port(m_keyboard_column - FIRSTJOY + 1); } } @@ -874,23 +916,16 @@ WRITE_LINE_MEMBER( ti99_4p_state::ready_line ) ready_join(); } -void ti99_4p_state::set_9901_int( int line, line_state state) -{ - m_tms9901->set_single_int(line, state); - // We latch the value for the read operation. Mind the negative logic. - if (state==CLEAR_LINE) m_9901_int |= (1<<line); - else m_9901_int &= ~(1<<line); -} - WRITE_LINE_MEMBER( ti99_4p_state::extint ) { - LOGMASKED(LOG_INT, "EXTINT level = %02x\n", state); - set_9901_int(1, (line_state)state); + LOGMASKED(LOG_INTERRUPTS, "EXTINT level = %02x\n", state); + m_int1 = (line_state)state; + m_tms9901->set_int_line(1, state); } WRITE_LINE_MEMBER( ti99_4p_state::notconnected ) { - LOGMASKED(LOG_INT, "Setting a not connected line ... ignored\n"); + LOGMASKED(LOG_INTERRUPTS, "Setting a not connected line ... ignored\n"); } /* @@ -931,14 +966,13 @@ void ti99_4p_state::driver_start() m_peribox->senila(CLEAR_LINE); m_peribox->senilb(CLEAR_LINE); - m_firstjoy = 6; - m_sysready = ASSERT_LINE; m_muxready = true; m_rom = (uint16_t*)(memregion("maincpu")->base()); - save_item(NAME(m_firstjoy)); + save_item(NAME(m_int1)); + save_item(NAME(m_int2)); save_item(NAME(m_keyboard_column)); save_item(NAME(m_check_alphalock)); save_item(NAME(m_internal_dsr)); @@ -960,7 +994,6 @@ void ti99_4p_state::driver_start() save_item(NAME(m_highbyte)); save_item(NAME(m_latch)); save_pointer(NAME(m_mapper),16); - save_item(NAME(m_9901_int)); } /* @@ -968,7 +1001,9 @@ void ti99_4p_state::driver_start() */ WRITE_LINE_MEMBER(ti99_4p_state::video_interrupt_in) { - set_9901_int(2, (line_state)state); + LOGMASKED(LOG_INTERRUPTS, "VDP INT2 from EVPC on tms9901, level=%d\n", state); + m_int2 = (line_state)state; + m_tms9901->set_int_line(2, state); } /* @@ -976,11 +1011,9 @@ WRITE_LINE_MEMBER(ti99_4p_state::video_interrupt_in) */ void ti99_4p_state::driver_reset() { - set_9901_int(12, CLEAR_LINE); - m_cpu->set_ready(ASSERT_LINE); m_cpu->set_hold(CLEAR_LINE); - m_9901_int = 0x03; // INT2* and INT1* set to 1, i.e. inactive + m_int1 = m_int2 = CLEAR_LINE; } /* @@ -1000,7 +1033,7 @@ void ti99_4p_state::ti99_4p_60hz(machine_config& config) // tms9901 TMS9901(config, m_tms9901, 0); - m_tms9901->read_cb().set(FUNC(ti99_4p_state::read_by_9901)); + m_tms9901->read_cb().set(FUNC(ti99_4p_state::psi_input)); m_tms9901->p_out_cb(2).set(FUNC(ti99_4p_state::keyC0)); m_tms9901->p_out_cb(3).set(FUNC(ti99_4p_state::keyC1)); m_tms9901->p_out_cb(4).set(FUNC(ti99_4p_state::keyC2)); @@ -1008,7 +1041,7 @@ void ti99_4p_state::ti99_4p_60hz(machine_config& config) m_tms9901->p_out_cb(6).set(FUNC(ti99_4p_state::cs_motor)); m_tms9901->p_out_cb(8).set(FUNC(ti99_4p_state::audio_gate)); m_tms9901->p_out_cb(9).set(FUNC(ti99_4p_state::cassette_output)); - m_tms9901->intlevel_cb().set(FUNC(ti99_4p_state::tms9901_interrupt)); + m_tms9901->intreq_cb().set(FUNC(ti99_4p_state::tms9901_interrupt)); // Peripheral expansion box (SGCPU composition) TI99_PERIBOX_SG(config, m_peribox, 0); |