tx0.c: reduce tagmap lookups (nw)

This commit is contained in:
Wilbert Pol 2015-08-01 14:06:50 +02:00
parent b0ab01e8bc
commit 435c80ef16
3 changed files with 17 additions and 12 deletions

View File

@ -125,7 +125,7 @@ static INPUT_PORTS_START( tx0 )
PORT_BIT( 0000002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Toggle Switch Register Switch 16") PORT_CODE(KEYCODE_COMMA) PORT_BIT( 0000002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Toggle Switch Register Switch 16") PORT_CODE(KEYCODE_COMMA)
PORT_BIT( 0000001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Toggle Switch Register Switch 17") PORT_CODE(KEYCODE_STOP) PORT_BIT( 0000001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Toggle Switch Register Switch 17") PORT_CODE(KEYCODE_STOP)
PORT_START("TWR0") /* 3: typewriter codes 00-17 */ PORT_START("TWR.0") /* 3: typewriter codes 00-17 */
PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("E") PORT_CODE(KEYCODE_E) PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("E") PORT_CODE(KEYCODE_E)
PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("8") PORT_CODE(KEYCODE_8) PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("8") PORT_CODE(KEYCODE_8)
PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("| _") PORT_CODE(KEYCODE_SLASH) PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("| _") PORT_CODE(KEYCODE_SLASH)
@ -140,7 +140,7 @@ static INPUT_PORTS_START( tx0 )
PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("U") PORT_CODE(KEYCODE_U) PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("U") PORT_CODE(KEYCODE_U)
PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("2") PORT_CODE(KEYCODE_2) PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("2") PORT_CODE(KEYCODE_2)
PORT_START("TWR1") /* 4: typewriter codes 20-37 */ PORT_START("TWR.1") /* 4: typewriter codes 20-37 */
PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME(". )") PORT_CODE(KEYCODE_STOP) PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME(". )") PORT_CODE(KEYCODE_STOP)
PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("D") PORT_CODE(KEYCODE_D) PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("D") PORT_CODE(KEYCODE_D)
PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("5") PORT_CODE(KEYCODE_5) PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("5") PORT_CODE(KEYCODE_5)
@ -156,7 +156,7 @@ static INPUT_PORTS_START( tx0 )
PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("- +") PORT_CODE(KEYCODE_MINUS) PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("- +") PORT_CODE(KEYCODE_MINUS)
PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("K") PORT_CODE(KEYCODE_K) PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("K") PORT_CODE(KEYCODE_K)
PORT_START("TWR2") /* 5: typewriter codes 40-57 */ PORT_START("TWR.2") /* 5: typewriter codes 40-57 */
PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("T") PORT_CODE(KEYCODE_T) PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("T") PORT_CODE(KEYCODE_T)
PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Z") PORT_CODE(KEYCODE_Z) PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Z") PORT_CODE(KEYCODE_Z)
PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Backspace") PORT_CODE(KEYCODE_BACKSPACE) PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Backspace") PORT_CODE(KEYCODE_BACKSPACE)
@ -169,7 +169,7 @@ static INPUT_PORTS_START( tx0 )
PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("P") PORT_CODE(KEYCODE_P) PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("P") PORT_CODE(KEYCODE_P)
PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Q") PORT_CODE(KEYCODE_Q) PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Q") PORT_CODE(KEYCODE_Q)
PORT_START("TWR3") /* 6: typewriter codes 60-77 */ PORT_START("TWR.3") /* 6: typewriter codes 60-77 */
PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("O") PORT_CODE(KEYCODE_O) PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("O") PORT_CODE(KEYCODE_O)
PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("B") PORT_CODE(KEYCODE_B) PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("B") PORT_CODE(KEYCODE_B)
PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("G") PORT_CODE(KEYCODE_G) PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("G") PORT_CODE(KEYCODE_G)
@ -1408,11 +1408,10 @@ void tx0_state::tx0_keyboard()
int typewriter_transitions; int typewriter_transitions;
int charcode, lr; int charcode, lr;
static const char *const twrnames[] = { "TWR0", "TWR1", "TWR2", "TWR3" };
for (i=0; i<4; i++) for (i=0; i<4; i++)
{ {
typewriter_keys[i] = ioport(twrnames[i])->read(); typewriter_keys[i] = m_twr[i]->read();
} }
for (i=0; i<4; i++) for (i=0; i<4; i++)
@ -1428,7 +1427,7 @@ void tx0_state::tx0_keyboard()
previous LR */ previous LR */
lr = (1 << 17) | ((charcode & 040) << 10) | ((charcode & 020) << 8) | ((charcode & 010) << 6) | ((charcode & 004) << 4) | ((charcode & 002) << 2) | ((charcode & 001) << 1); lr = (1 << 17) | ((charcode & 040) << 10) | ((charcode & 020) << 8) | ((charcode & 010) << 6) | ((charcode & 004) << 4) | ((charcode & 002) << 2) | ((charcode & 001) << 1);
/* write modified LR */ /* write modified LR */
machine().device("maincpu")->state().set_state_int(TX0_LR, lr); m_maincpu->set_state_int(TX0_LR, lr);
tx0_typewriter_drawchar(charcode); /* we want to echo input */ tx0_typewriter_drawchar(charcode); /* we want to echo input */
break; break;
} }
@ -1451,7 +1450,7 @@ INTERRUPT_GEN_MEMBER(tx0_state::tx0_interrupt)
/* read new state of control keys */ /* read new state of control keys */
control_keys = ioport("CSW")->read(); control_keys = m_csw->read();
if (control_keys & tx0_control) if (control_keys & tx0_control)
{ {

View File

@ -136,7 +136,11 @@ public:
: driver_device(mconfig, type, tag), : driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"), m_maincpu(*this, "maincpu"),
m_gfxdecode(*this, "gfxdecode"), m_gfxdecode(*this, "gfxdecode"),
m_palette(*this, "palette") { } m_palette(*this, "palette"),
m_crt(*this, "crt"),
m_csw(*this, "CSW"),
m_twr(*this, "TWR")
{ }
tx0_tape_reader_t m_tape_reader; tx0_tape_reader_t m_tape_reader;
tape_puncher_t m_tape_puncher; tape_puncher_t m_tape_puncher;
@ -152,7 +156,6 @@ public:
bitmap_ind16 m_typewriter_bitmap; bitmap_ind16 m_typewriter_bitmap;
int m_pos; int m_pos;
int m_case_shift; int m_case_shift;
crt_device *m_crt;
DECLARE_DRIVER_INIT(tx0); DECLARE_DRIVER_INIT(tx0);
virtual void machine_start(); virtual void machine_start();
virtual void machine_reset(); virtual void machine_reset();
@ -198,8 +201,13 @@ public:
DECLARE_WRITE_LINE_MEMBER(tx0_sel); DECLARE_WRITE_LINE_MEMBER(tx0_sel);
DECLARE_WRITE_LINE_MEMBER(tx0_io_reset_callback); DECLARE_WRITE_LINE_MEMBER(tx0_io_reset_callback);
void magtape_callback(); void magtape_callback();
private:
required_device<gfxdecode_device> m_gfxdecode; required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette; required_device<palette_device> m_palette;
required_device<crt_device> m_crt;
required_ioport m_csw;
required_ioport_array<4> m_twr;
}; };
/* defines for each bit and mask in input port "CSW" */ /* defines for each bit and mask in input port "CSW" */

View File

@ -36,8 +36,6 @@ void tx0_state::video_start()
const rectangle typewriter_bitmap_bounds(0, typewriter_window_width-1, 0, typewriter_window_height-1); const rectangle typewriter_bitmap_bounds(0, typewriter_window_width-1, 0, typewriter_window_height-1);
m_typewriter_bitmap.fill(pen_typewriter_bg, typewriter_bitmap_bounds); m_typewriter_bitmap.fill(pen_typewriter_bg, typewriter_bitmap_bounds);
m_crt = machine().device<crt_device>("crt");
} }