/************************************************* * memory mapped I/O read * bit function * 7 not assigned * 6 column 6 * 5 column 5 * 4 column 4 * 3 column 3 * 2 column 2 * 1 column 1 * 0 column 0 ************************************************/ static int mra_bank(int bank, int offs) { static int level_old = 0, cassette_bit = 0; int level, data = 0xff; /* Laser 500/700 only: keyboard rows A through D */ if( (offs & 0x00ff) == 0x00ff ) { static int row_a,row_b,row_c,row_d; if( (offs & 0x0300) == 0x0000 ) /* keyboard row A */ { if( readinputport( 8) != row_a ) { row_a = readinputport(8); data &= row_a; } } if( (offs & 0x0300) == 0x0100 ) /* keyboard row B */ { if( readinputport( 9) != row_b ) { row_b = readinputport( 9); data &= row_b; } } if( (offs & 0x0300) == 0x0200 ) /* keyboard row C */ { if( readinputport(10) != row_c ) { row_c = readinputport(10); data &= row_c; } } if( (offs & 0x0300) == 0x0300 ) /* keyboard row D */ { if( readinputport(11) != row_d ) { row_d = readinputport(11); data &= row_d; } } } else { /* All Lasers keyboard rows 0 through 7 */ if( !(offs & 0x01) ) data &= readinputport( 0); if( !(offs & 0x02) ) data &= readinputport( 1); if( !(offs & 0x04) ) data &= readinputport( 2); if( !(offs & 0x08) ) data &= readinputport( 3); if( !(offs & 0x10) ) data &= readinputport( 4); if( !(offs & 0x20) ) data &= readinputport( 5); if( !(offs & 0x40) ) data &= readinputport( 6); if( !(offs & 0x80) ) data &= readinputport( 7); } /* what's bit 7 good for? tape input maybe? */ level = cassette_input(vtech2_cassette_image()) * 65536.0; if( level < level_old - 511 ) cassette_bit = 0x00; if( level > level_old + 511 ) cassette_bit = 0x80; level_old = level; data &= ~cassette_bit; // logerror("bank #%d keyboard_r [$%04X] $%02X\n", bank, offs, data); return data; }
/************************************************* * memory mapped I/O read * bit function * 7 not assigned * 6 column 6 * 5 column 5 * 4 column 4 * 3 column 3 * 2 column 2 * 1 column 1 * 0 column 0 ************************************************/ static int mra_bank(running_machine &machine, int bank, int offs) { vtech2_state *state = machine.driver_data<vtech2_state>(); int level, data = 0xff; /* Laser 500/700 only: keyboard rows A through D */ if( (offs & 0x00ff) == 0x00ff ) { if( (offs & 0x0300) == 0x0000 ) /* keyboard row A */ { if( input_port_read(machine, "ROWA") != state->m_row_a ) { state->m_row_a = input_port_read(machine, "ROWA"); data &= state->m_row_a; } } if( (offs & 0x0300) == 0x0100 ) /* keyboard row B */ { if( input_port_read(machine, "ROWB") != state->m_row_b ) { state->m_row_b = input_port_read(machine, "ROWB"); data &= state->m_row_b; } } if( (offs & 0x0300) == 0x0200 ) /* keyboard row C */ { if( input_port_read(machine, "ROWC") != state->m_row_c ) { state->m_row_c = input_port_read(machine, "ROWC"); data &= state->m_row_c; } } if( (offs & 0x0300) == 0x0300 ) /* keyboard row D */ { if( input_port_read(machine, "ROWD") != state->m_row_d ) { state->m_row_d = input_port_read(machine, "ROWD"); data &= state->m_row_d; } } } else { /* All Lasers keyboard rows 0 through 7 */ if( !(offs & 0x01) ) data &= input_port_read(machine, "ROW0"); if( !(offs & 0x02) ) data &= input_port_read(machine, "ROW1"); if( !(offs & 0x04) ) data &= input_port_read(machine, "ROW2"); if( !(offs & 0x08) ) data &= input_port_read(machine, "ROW3"); if( !(offs & 0x10) ) data &= input_port_read(machine, "ROW4"); if( !(offs & 0x20) ) data &= input_port_read(machine, "ROW5"); if( !(offs & 0x40) ) data &= input_port_read(machine, "ROW6"); if( !(offs & 0x80) ) data &= input_port_read(machine, "ROW7"); } /* what's bit 7 good for? tape input maybe? */ level = (vtech2_cassette_image(machine))->input() * 65536.0; if( level < state->m_level_old - 511 ) state->m_cassette_bit = 0x00; if( level > state->m_level_old + 511 ) state->m_cassette_bit = 0x80; state->m_level_old = level; data &= ~state->m_cassette_bit; // logerror("bank #%d keyboard_r [$%04X] $%02X\n", bank, offs, data); return data; }