diff options
Diffstat (limited to 'src/mess/machine/c64.c')
-rw-r--r-- | src/mess/machine/c64.c | 136 |
1 files changed, 26 insertions, 110 deletions
diff --git a/src/mess/machine/c64.c b/src/mess/machine/c64.c index f6f61639cb6..27a15b4a183 100644 --- a/src/mess/machine/c64.c +++ b/src/mess/machine/c64.c @@ -78,23 +78,23 @@ static void c64_nmi( running_machine &machine ) * see machine/cbm.c */ -static READ8_DEVICE_HANDLER( c64_cia0_port_a_r ) +READ8_MEMBER(legacy_c64_state::c64_cia0_port_a_r) { - UINT8 cia0portb = mos6526_pb_r(space.machine().device("cia_0"), space, 0); + UINT8 cia0portb = mos6526_pb_r(machine().device("cia_0"), space, 0); - return cbm_common_cia0_port_a_r(device, cia0portb); + return cbm_common_cia0_port_a_r(machine().device("cia_0"), cia0portb); } -static READ8_DEVICE_HANDLER( c64_cia0_port_b_r ) +READ8_MEMBER(legacy_c64_state::c64_cia0_port_b_r) { - UINT8 cia0porta = mos6526_pa_r(space.machine().device("cia_0"), space, 0); + UINT8 cia0porta = mos6526_pa_r(machine().device("cia_0"), space, 0); - return cbm_common_cia0_port_b_r(device, cia0porta); + return cbm_common_cia0_port_b_r(machine().device("cia_0"), cia0porta); } -static WRITE8_DEVICE_HANDLER( c64_cia0_port_b_w ) +WRITE8_MEMBER(legacy_c64_state::c64_cia0_port_b_w) { - device_t *vic2 = space.machine().device("vic2"); + device_t *vic2 = machine().device("vic2"); vic2_lightpen_write(vic2, data & 0x10); } @@ -133,10 +133,10 @@ const mos6526_interface c64_ntsc_cia0 = DEVCB_NULL, /* pc_func */ DEVCB_NULL, DEVCB_NULL, - DEVCB_HANDLER(c64_cia0_port_a_r), + DEVCB_DRIVER_MEMBER(legacy_c64_state,c64_cia0_port_a_r), DEVCB_NULL, - DEVCB_HANDLER(c64_cia0_port_b_r), - DEVCB_HANDLER(c64_cia0_port_b_w) + DEVCB_DRIVER_MEMBER(legacy_c64_state,c64_cia0_port_b_r), + DEVCB_DRIVER_MEMBER(legacy_c64_state,c64_cia0_port_b_w) }; const mos6526_interface c64_pal_cia0 = @@ -145,10 +145,10 @@ const mos6526_interface c64_pal_cia0 = DEVCB_NULL, /* pc_func */ DEVCB_NULL, DEVCB_NULL, - DEVCB_HANDLER(c64_cia0_port_a_r), + DEVCB_DRIVER_MEMBER(legacy_c64_state,c64_cia0_port_a_r), DEVCB_NULL, - DEVCB_HANDLER(c64_cia0_port_b_r), - DEVCB_HANDLER(c64_cia0_port_b_w) + DEVCB_DRIVER_MEMBER(legacy_c64_state,c64_cia0_port_b_r), + DEVCB_DRIVER_MEMBER(legacy_c64_state,c64_cia0_port_b_w) }; @@ -175,30 +175,27 @@ const mos6526_interface c64_pal_cia0 = * flag restore key or rs232 received data input * irq to nmi connected ? */ -static READ8_DEVICE_HANDLER( c64_cia1_port_a_r ) +READ8_MEMBER(legacy_c64_state::c64_cia1_port_a_r) { - legacy_c64_state *state = space.machine().driver_data<legacy_c64_state>(); - UINT8 value = 0xff; - if (!state->m_iec->clk_r()) + if (!m_iec->clk_r()) value &= ~0x40; - if (!state->m_iec->data_r()) + if (!m_iec->data_r()) value &= ~0x80; return value; } -static WRITE8_DEVICE_HANDLER( c64_cia1_port_a_w ) +WRITE8_MEMBER(legacy_c64_state::c64_cia1_port_a_w) { - legacy_c64_state *state = space.machine().driver_data<legacy_c64_state>(); static const int helper[4] = {0xc000, 0x8000, 0x4000, 0x0000}; - state->m_iec->clk_w(!(data & 0x10)); - state->m_iec->data_w(!(data & 0x20)); - state->m_iec->atn_w(!(data & 0x08)); - state->m_vicaddr = state->m_memory + helper[data & 0x03]; + m_iec->clk_w(!(data & 0x10)); + m_iec->data_w(!(data & 0x20)); + m_iec->atn_w(!(data & 0x08)); + m_vicaddr = m_memory + helper[data & 0x03]; } static void c64_cia1_interrupt( device_t *device, int level ) @@ -212,8 +209,8 @@ const mos6526_interface c64_ntsc_cia1 = DEVCB_NULL, /* pc_func */ DEVCB_NULL, DEVCB_NULL, - DEVCB_HANDLER(c64_cia1_port_a_r), - DEVCB_HANDLER(c64_cia1_port_a_w), + DEVCB_DRIVER_MEMBER(legacy_c64_state,c64_cia1_port_a_r), + DEVCB_DRIVER_MEMBER(legacy_c64_state,c64_cia1_port_a_w), DEVCB_NULL, DEVCB_NULL }; @@ -224,8 +221,8 @@ const mos6526_interface c64_pal_cia1 = DEVCB_NULL, /* pc_func */ DEVCB_NULL, DEVCB_NULL, - DEVCB_HANDLER(c64_cia1_port_a_r), - DEVCB_HANDLER(c64_cia1_port_a_w), + DEVCB_DRIVER_MEMBER(legacy_c64_state,c64_cia1_port_a_r), + DEVCB_DRIVER_MEMBER(legacy_c64_state,c64_cia1_port_a_w), DEVCB_NULL, DEVCB_NULL }; @@ -530,87 +527,6 @@ static void c64_bankswitch( running_machine &machine, int reset ) state->m_old_data = data; } -/** - ddr bit 1 port line is output - port bit 1 port line is high - - p0 output loram - p1 output hiram - p2 output charen - p3 output cassette data - p4 input cassette switch - p5 output cassette motor - p6,7 not available on M6510 - */ - -WRITE8_DEVICE_HANDLER(c64_m6510_port_write) -{ - legacy_c64_state *state = space.machine().driver_data<legacy_c64_state>(); - - UINT8 direction = offset; // HACK ALERT! - - /* if line is marked as input then keep current value */ - data = (state->m_port_data & ~direction) | (data & direction); - - /* resistors make P0,P1,P2 go high when respective line is changed to input */ - if (!(direction & 0x04)) - data |= 0x04; - - if (!(direction & 0x02)) - data |= 0x02; - - if (!(direction & 0x01)) - data |= 0x01; - - state->m_port_data = data; - - if (state->m_tape_on) - { - if (direction & 0x08) - { - space.machine().device<cassette_image_device>(CASSETTE_TAG)->output((data & 0x08) ? -(0x5a9e >> 1) : +(0x5a9e >> 1)); - } - - if (direction & 0x20) - { - if(!(data & 0x20)) - { - space.machine().device<cassette_image_device>(CASSETTE_TAG)->change_state(CASSETTE_MOTOR_ENABLED, CASSETTE_MASK_MOTOR); - state->m_datasette_timer->adjust(attotime::zero, 0, attotime::from_hz(44100)); - } - else - { - space.machine().device<cassette_image_device>(CASSETTE_TAG)->change_state(CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR); - state->m_datasette_timer->reset(); - } - } - } - - if (!state->m_ultimax) - c64_bankswitch(space.machine(), 0); - - state->m_memory[0x000] = device->memory().space(AS_PROGRAM).read_byte(0); - state->m_memory[0x001] = device->memory().space(AS_PROGRAM).read_byte(1); - -} - -READ8_DEVICE_HANDLER(c64_m6510_port_read) -{ - legacy_c64_state *state = space.machine().driver_data<legacy_c64_state>(); - UINT8 data = state->m_port_data; - - if (state->m_tape_on) - { - if ((space.machine().device<cassette_image_device>(CASSETTE_TAG)->get_state() & CASSETTE_MASK_UISTATE) != CASSETTE_STOPPED) - data &= ~0x10; - else - data |= 0x10; - } - - return data; -} - - int c64_paddle_read( device_t *device, address_space &space, int which ) { running_machine &machine = device->machine(); |