diff options
author | 2016-03-12 12:31:13 +0100 | |
---|---|---|
committer | 2016-03-12 12:31:13 +0100 | |
commit | a026a582f1a0ea8c1ede3acaddacef506ef3f3b0 (patch) | |
tree | e31573822f2359677de519f9f3b600d98e8764cd /src/devices/machine | |
parent | 477d2abd43984f076b7e45f5527591fa8fd0d241 (diff) | |
parent | dcab55bf53b94713a6f72e9633f5101c8dd6c08c (diff) |
Merge pull request #15 from mamedev/master
Sync to base master
Diffstat (limited to 'src/devices/machine')
31 files changed, 1263 insertions, 200 deletions
diff --git a/src/devices/machine/68307tmu.cpp b/src/devices/machine/68307tmu.cpp index 6f5c33687cd..e3c8e595f7c 100644 --- a/src/devices/machine/68307tmu.cpp +++ b/src/devices/machine/68307tmu.cpp @@ -99,7 +99,7 @@ WRITE16_MEMBER( m68307cpu_device::m68307_internal_timer_w ) } } -static TIMER_CALLBACK( m68307_timer0_callback ) +TIMER_CALLBACK_MEMBER(m68307_timer::timer0_callback ) { m68307cpu_device* m68k = (m68307cpu_device *)ptr; m68307_single_timer* tptr = &m68k->m68307TIMER->singletimer[0]; @@ -110,7 +110,7 @@ static TIMER_CALLBACK( m68307_timer0_callback ) tptr->mametimer->adjust(m68k->cycles_to_attotime(20000)); } -static TIMER_CALLBACK( m68307_timer1_callback ) +TIMER_CALLBACK_MEMBER(m68307_timer::timer1_callback ) { m68307cpu_device* m68k = (m68307cpu_device *)ptr; m68307_single_timer* tptr = &m68k->m68307TIMER->singletimer[1]; @@ -122,7 +122,7 @@ static TIMER_CALLBACK( m68307_timer1_callback ) } -static TIMER_CALLBACK( m68307_wd_timer_callback ) +TIMER_CALLBACK_MEMBER(m68307_timer::wd_timer_callback ) { printf("wd timer\n"); } @@ -134,15 +134,12 @@ void m68307_timer::init(m68307cpu_device *device) m68307_single_timer* tptr; tptr = &singletimer[0]; - tptr->mametimer = device->machine().scheduler().timer_alloc(FUNC(m68307_timer0_callback), parent); + tptr->mametimer = device->machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(m68307_timer::timer0_callback),this), parent); tptr = &singletimer[1]; - tptr->mametimer = device->machine().scheduler().timer_alloc(FUNC(m68307_timer1_callback), parent); - - - wd_mametimer = device->machine().scheduler().timer_alloc(FUNC(m68307_wd_timer_callback), parent); - + tptr->mametimer = device->machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(m68307_timer::timer1_callback),this), parent); + wd_mametimer = device->machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(m68307_timer::wd_timer_callback),this), parent); } UINT16 m68307_timer::read_tcn(UINT16 mem_mask, int which) diff --git a/src/devices/machine/68307tmu.h b/src/devices/machine/68307tmu.h index 2c62858b66d..660bdaeeb41 100644 --- a/src/devices/machine/68307tmu.h +++ b/src/devices/machine/68307tmu.h @@ -38,4 +38,8 @@ class m68307_timer void init(m68307cpu_device *device); void reset(void); + + TIMER_CALLBACK_MEMBER(timer0_callback); + TIMER_CALLBACK_MEMBER(timer1_callback); + TIMER_CALLBACK_MEMBER(wd_timer_callback); }; diff --git a/src/devices/machine/74123.cpp b/src/devices/machine/74123.cpp index d5eddbe91a3..0263ad0eb4b 100644 --- a/src/devices/machine/74123.cpp +++ b/src/devices/machine/74123.cpp @@ -116,7 +116,7 @@ int ttl74123_device::timer_running() /*------------------------------------------------- - TIMER_CALLBACK( output_callback ) + TIMER_CALLBACK_MEMBER( output_callback ) -------------------------------------------------*/ TIMER_CALLBACK_MEMBER( ttl74123_device::output_callback ) @@ -140,7 +140,7 @@ void ttl74123_device::set_output() /*------------------------------------------------- - TIMER_CALLBACK( clear_callback ) + TIMER_CALLBACK_MEMBER( clear_callback ) -------------------------------------------------*/ TIMER_CALLBACK_MEMBER( ttl74123_device::clear_callback ) diff --git a/src/devices/machine/8042kbdc.cpp b/src/devices/machine/8042kbdc.cpp index a1d36a41b43..509a5952890 100644 --- a/src/devices/machine/8042kbdc.cpp +++ b/src/devices/machine/8042kbdc.cpp @@ -224,10 +224,10 @@ void kbdc8042_device::device_start() { // resolve callbacks m_system_reset_cb.resolve_safe(); - m_gate_a20_cb.resolve(); - m_input_buffer_full_cb.resolve(); + m_gate_a20_cb.resolve_safe(); + m_input_buffer_full_cb.resolve_safe(); m_output_buffer_empty_cb.resolve_safe(); - m_speaker_cb.resolve(); + m_speaker_cb.resolve_safe(); m_operation_write_state = 0; /* first write to 0x60 might occur before anything can set this */ memset(&m_keyboard, 0x00, sizeof(m_keyboard)); memset(&m_mouse, 0x00, sizeof(m_mouse)); @@ -287,7 +287,8 @@ void kbdc8042_device::at_8042_receive(UINT8 data) m_input_buffer_full_cb(1); /* Lets 8952's timers do their job before clear the interrupt line, */ /* else Keyboard interrupt never happens. */ - machine().scheduler().timer_set(attotime::from_usec(2), timer_expired_delegate(FUNC(kbdc8042_device::kbdc8042_clr_int),this)); + /* Why was this done? It dies when an extended scan code is received */ + //machine().scheduler().timer_set(attotime::from_usec(2), timer_expired_delegate(FUNC(kbdc8042_device::kbdc8042_clr_int),this)); } } @@ -347,6 +348,7 @@ READ8_MEMBER(kbdc8042_device::data_r) switch (offset) { case 0: data = m_data; + m_input_buffer_full_cb(0); if ((m_status_read_mode != 3) || (data != 0xfa)) { if (m_keybtype != KBDC8042_AT386 || (data != 0x55)) diff --git a/src/devices/machine/bcreader.cpp b/src/devices/machine/bcreader.cpp index 5a5df7fb452..4d05a779835 100644 --- a/src/devices/machine/bcreader.cpp +++ b/src/devices/machine/bcreader.cpp @@ -208,7 +208,6 @@ void barcode_reader_device::decode(int len) sum += (i & 1) ? (m_byte_data[i] * 1) : (m_byte_data[i] * 3); } - if (m_pixel_data) { sum = (10 - (sum % 10)) % 10; if (sum != m_byte_data[len - 1]) diff --git a/src/devices/machine/f3853.cpp b/src/devices/machine/f3853.cpp index a37e1b7e59b..49deb99f073 100644 --- a/src/devices/machine/f3853.cpp +++ b/src/devices/machine/f3853.cpp @@ -77,7 +77,7 @@ void f3853_device::device_start() m_interrupt_req_cb.bind_relative_to(*owner()); - m_timer = machine().scheduler().timer_alloc(FUNC(f3853_timer_callback), (void *)this ); + m_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(f3853_device::timer_callback),this)); save_item(NAME(m_high) ); save_item(NAME(m_low) ); @@ -128,13 +128,7 @@ void f3853_device::timer_start(UINT8 value) m_timer->adjust(period); } - -TIMER_CALLBACK( f3853_device::f3853_timer_callback ) -{ - reinterpret_cast<f3853_device*>(ptr)->timer(); -} - -void f3853_device::timer() +TIMER_CALLBACK_MEMBER(f3853_device::timer_callback) { if(m_timer_enable) { diff --git a/src/devices/machine/f3853.h b/src/devices/machine/f3853.h index 82e9610c174..b080b982fc2 100644 --- a/src/devices/machine/f3853.h +++ b/src/devices/machine/f3853.h @@ -72,20 +72,17 @@ public: void set_external_interrupt_in_line(int level); void set_priority_in_line(int level); + TIMER_CALLBACK_MEMBER(timer_callback); protected: // device-level overrides virtual void device_start() override; virtual void device_reset() override; virtual void device_post_load() override { } virtual void device_clock_changed() override { } - - static TIMER_CALLBACK( f3853_timer_callback ); - private: void set_interrupt_request_line(); void timer_start(UINT8 value); - void timer(); f3853_interrupt_req_delegate m_interrupt_req_cb; UINT8 m_high; diff --git a/src/devices/machine/genpc.cpp b/src/devices/machine/genpc.cpp new file mode 100644 index 00000000000..a363c0d75aa --- /dev/null +++ b/src/devices/machine/genpc.cpp @@ -0,0 +1,921 @@ +// license:BSD-3-Clause +// copyright-holders:Wilbert Pol, Miodrag Milanovic +/*************************************************************************** + + machine/genpc.c + + +***************************************************************************/ + +#include "emu.h" +#include "machine/genpc.h" +#include "machine/i8255.h" +#include "machine/pic8259.h" +#include "machine/pit8253.h" +#include "sound/speaker.h" +#include "machine/ram.h" +#include "imagedev/cassette.h" + +#define VERBOSE_PIO 0 /* PIO (keyboard controller) */ + +#define PIO_LOG(N,M,A) \ + do { \ + if(VERBOSE_PIO>=N) \ + { \ + if( M ) \ + logerror("%11.6f: %-24s",machine().time().as_double(),(char*)M ); \ + logerror A; \ + } \ + } while (0) + + +/************************************************************************* + * + * PC DMA stuff + * + *************************************************************************/ + +WRITE8_MEMBER( ibm5160_mb_device::pc_page_w) +{ + switch(offset % 4) + { + case 1: + m_dma_offset[2] = data; + break; + case 2: + m_dma_offset[3] = data; + break; + case 3: + m_dma_offset[0] = m_dma_offset[1] = data; + break; + } +} + + +WRITE_LINE_MEMBER( ibm5160_mb_device::pc_dma_hrq_changed ) +{ + m_maincpu->set_input_line(INPUT_LINE_HALT, state ? ASSERT_LINE : CLEAR_LINE); + + /* Assert HLDA */ + m_dma8237->hack_w(state); +} + + +READ8_MEMBER( ibm5160_mb_device::pc_dma_read_byte ) +{ + if(m_dma_channel == -1) + return 0xff; + address_space &spaceio = m_maincpu->space(AS_PROGRAM); + offs_t page_offset = (((offs_t) m_dma_offset[m_dma_channel]) << 16) & 0x0F0000; + return spaceio.read_byte( page_offset + offset); +} + + +WRITE8_MEMBER( ibm5160_mb_device::pc_dma_write_byte ) +{ + if(m_dma_channel == -1) + return; + address_space &spaceio = m_maincpu->space(AS_PROGRAM); + offs_t page_offset = (((offs_t) m_dma_offset[m_dma_channel]) << 16) & 0x0F0000; + + spaceio.write_byte( page_offset + offset, data); +} + + +READ8_MEMBER( ibm5160_mb_device::pc_dma8237_1_dack_r ) +{ + return m_isabus->dack_r(1); +} + +READ8_MEMBER( ibm5160_mb_device::pc_dma8237_2_dack_r ) +{ + return m_isabus->dack_r(2); +} + + +READ8_MEMBER( ibm5160_mb_device::pc_dma8237_3_dack_r ) +{ + return m_isabus->dack_r(3); +} + + +WRITE8_MEMBER( ibm5160_mb_device::pc_dma8237_1_dack_w ) +{ + m_isabus->dack_w(1,data); +} + +WRITE8_MEMBER( ibm5160_mb_device::pc_dma8237_2_dack_w ) +{ + m_isabus->dack_w(2,data); +} + + +WRITE8_MEMBER( ibm5160_mb_device::pc_dma8237_3_dack_w ) +{ + m_isabus->dack_w(3,data); +} + + +WRITE8_MEMBER( ibm5160_mb_device::pc_dma8237_0_dack_w ) +{ + m_u73_q2 = 0; + m_dma8237->dreq0_w( m_u73_q2 ); +} + + +WRITE_LINE_MEMBER( ibm5160_mb_device::pc_dma8237_out_eop ) +{ + m_cur_eop = state == ASSERT_LINE; + if(m_dma_channel != -1 && m_cur_eop) + m_isabus->eop_w(m_dma_channel, m_cur_eop ? ASSERT_LINE : CLEAR_LINE ); +} + +void ibm5160_mb_device::pc_select_dma_channel(int channel, bool state) +{ + if(!state) { + m_dma_channel = channel; + if(m_cur_eop) + m_isabus->eop_w(channel, ASSERT_LINE ); + + } else if(m_dma_channel == channel) { + m_dma_channel = -1; + if(m_cur_eop) + m_isabus->eop_w(channel, CLEAR_LINE ); + } +} + +WRITE_LINE_MEMBER( ibm5160_mb_device::pc_dack0_w ) { pc_select_dma_channel(0, state); } +WRITE_LINE_MEMBER( ibm5160_mb_device::pc_dack1_w ) { pc_select_dma_channel(1, state); } +WRITE_LINE_MEMBER( ibm5160_mb_device::pc_dack2_w ) { pc_select_dma_channel(2, state); } +WRITE_LINE_MEMBER( ibm5160_mb_device::pc_dack3_w ) { pc_select_dma_channel(3, state); } + +/************************************************************* + * + * pic8259 configuration + * + *************************************************************/ + +WRITE_LINE_MEMBER(ibm5160_mb_device::pc_speaker_set_spkrdata) +{ + m_pc_spkrdata = state ? 1 : 0; + m_speaker->level_w(m_pc_spkrdata & m_pit_out2); +} + + +/************************************************************* + * + * pit8253 configuration + * + *************************************************************/ + +WRITE_LINE_MEMBER( ibm5160_mb_device::pc_pit8253_out1_changed ) +{ + /* Trigger DMA channel #0 */ + if ( m_out1 == 0 && state == 1 && m_u73_q2 == 0 ) + { + m_u73_q2 = 1; + m_dma8237->dreq0_w( m_u73_q2 ); + } + m_out1 = state; +} + + +WRITE_LINE_MEMBER( ibm5160_mb_device::pc_pit8253_out2_changed ) +{ + m_pit_out2 = state ? 1 : 0; + m_speaker->level_w(m_pc_spkrdata & m_pit_out2); +} + + +/********************************************************** + * + * PPI8255 interface + * + * + * PORT A (input) + * + * Directly attached to shift register which stores data + * received from the keyboard. + * + * PORT B (output) + * 0 - PB0 - TIM2GATESPK - Enable/disable counting on timer 2 of the 8253 + * 1 - PB1 - SPKRDATA - Speaker data + * 2 - PB2 - - Enable receiving data from the keyboard when keyboard is not locked. + * 3 - PB3 - - Dipsswitch set selector + * 4 - PB4 - ENBRAMPCK - Enable ram parity check + * 5 - PB5 - ENABLEI/OCK - Enable expansion I/O check + * 6 - PB6 - - Connected to keyboard clock signal + * 0 = ignore keyboard signals + * 1 = accept keyboard signals + * 7 - PB7 - - Clear/disable shift register and IRQ1 line + * 0 = normal operation + * 1 = clear and disable shift register and clear IRQ1 flip flop + * + * PORT C + * 0 - PC0 - - Dipswitch 0/4 SW1 + * 1 - PC1 - - Dipswitch 1/5 SW1 + * 2 - PC2 - - Dipswitch 2/6 SW1 + * 3 - PC3 - - Dipswitch 3/7 SW1 + * 4 - PC4 - SPK - Speaker/cassette data + * 5 - PC5 - I/OCHCK - Expansion I/O check result + * 6 - PC6 - T/C2OUT - Output of 8253 timer 2 + * 7 - PC7 - PCK - Parity check result + * + * IBM5150 SW1: + * 0 - OFF - One or more floppy drives + * ON - Diskless operation + * 1 - OFF - 8087 present + * ON - No 8087 present + * 2+3 - Used to determine on board memory configuration + * OFF OFF - 64KB + * ON OFF - 48KB + * OFF ON - 32KB + * ON ON - 16KB + * 4+5 - Used to select display + * OFF OFF - Monochrome + * ON OFF - CGA, 80 column + * OFF ON - CGA, 40 column + * ON ON - EGA/VGA display + * 6+7 - Used to select number of disk drives + * OFF OFF - four disk drives + * ON OFF - three disk drives + * OFF ON - two disk drives + * ON ON - one disk drive + * + **********************************************************/ +WRITE_LINE_MEMBER( ibm5150_mb_device::keyboard_clock_w ) +{ + if (!m_ppi_keyboard_clear && !state && !m_ppi_shift_enable) + { + m_ppi_shift_enable = m_ppi_shift_register & 0x01; + + m_ppi_shift_register >>= 1; + m_ppi_shift_register |= m_ppi_data_signal << 7; + + m_pic8259->ir1_w(m_ppi_shift_enable); + m_pc_kbdc->data_write_from_mb(!m_ppi_shift_enable); + } +} + +WRITE_LINE_MEMBER( ec1841_mb_device::keyboard_clock_w ) +{ + if (!m_ppi_keyboard_clear && !state && !m_ppi_shift_enable) + { + m_ppi_shift_enable = m_ppi_shift_register & 0x01; + + m_ppi_shift_register >>= 1; + m_ppi_shift_register |= m_ppi_data_signal << 7; + + m_pic8259->ir1_w(m_ppi_shift_enable); + m_pc_kbdc->data_write_from_mb(!m_ppi_shift_enable); + } +} + +WRITE_LINE_MEMBER( ibm5160_mb_device::keyboard_clock_w ) +{ + if (!m_ppi_keyboard_clear && !state && !m_ppi_shift_enable) + { + m_ppi_shift_enable = m_ppi_shift_register & 0x01; + + m_ppi_shift_register >>= 1; + m_ppi_shift_register |= m_ppi_data_signal << 7; + + m_pic8259->ir1_w(m_ppi_shift_enable); + m_pc_kbdc->data_write_from_mb(!BIT(m_ppi_portb, 2) && !m_ppi_shift_enable); + } +} + + +WRITE_LINE_MEMBER( ibm5160_mb_device::keyboard_data_w ) +{ + m_ppi_data_signal = state; +} + +READ8_MEMBER (ibm5160_mb_device::pc_ppi_porta_r) +{ + int data = 0xFF; + /* KB port A */ + if (m_ppi_keyboard_clear) + { + /* 0 0 - no floppy drives + * 1 Not used + * 2-3 The number of memory banks on the system board + * 4-5 Display mode + * 11 = monochrome + * 10 - color 80x25 + * 01 - color 40x25 + * 6-7 The number of floppy disk drives + */ + data = ioport("DSW0")->read(); + } + else + { + data = m_ppi_shift_register; + } + PIO_LOG(1,"PIO_A_r",("$%02x\n", data)); + return data; +} + + +READ8_MEMBER ( ibm5160_mb_device::pc_ppi_portc_r ) +{ + int data=0xff; + + data&=~0x80; // no parity error + data&=~0x40; // no error on expansion board + /* KB port C: equipment flags */ + if (m_ppi_portc_switch_high) + { + /* read hi nibble of S2 */ + data = (data & 0xf0) | ((ioport("DSW0")->read() >> 4) & 0x0f); + PIO_LOG(1,"PIO_C_r (hi)",("$%02x\n", data)); + } + else + { + /* read lo nibble of S2 */ + data = (data & 0xf0) | (ioport("DSW0")->read() & 0x0f); + PIO_LOG(1,"PIO_C_r (lo)",("$%02x\n", data)); + } + + if ( m_ppi_portb & 0x01 ) + { + data = ( data & ~0x10 ) | ( m_pit_out2 ? 0x10 : 0x00 ); + } + data = ( data & ~0x20 ) | ( m_pit_out2 ? 0x20 : 0x00 ); + + return data; +} + + +WRITE8_MEMBER( ibm5160_mb_device::pc_ppi_portb_w ) +{ + /* PPI controller port B*/ + m_ppi_portb = data; + m_ppi_portc_switch_high = data & 0x08; + m_ppi_keyboard_clear = data & 0x80; + m_ppi_keyb_clock = data & 0x40; + m_pit8253->write_gate2(BIT(data, 0)); + pc_speaker_set_spkrdata( data & 0x02 ); + + /* If PB7 is set clear the shift register and reset the IRQ line */ + if ( m_ppi_keyboard_clear ) + { + m_ppi_shift_register = 0; + m_ppi_shift_enable = 0; + m_pic8259->ir1_w(m_ppi_shift_enable); + } + + m_pc_kbdc->data_write_from_mb(!BIT(m_ppi_portb, 2) && !m_ppi_shift_enable); + m_ppi_clock_signal = ( m_ppi_keyb_clock ) ? 1 : 0; + m_pc_kbdc->clock_write_from_mb(m_ppi_clock_signal); +} + + +/********************************************************** + * + * NMI handling + * + **********************************************************/ + +WRITE8_MEMBER( ibm5160_mb_device::nmi_enable_w ) +{ + m_nmi_enabled = BIT(data,7); + m_isabus->set_nmi_state(m_nmi_enabled); +} +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +const device_type IBM5160_MOTHERBOARD = &device_creator<ibm5160_mb_device>; + +//************************************************************************** +// DEVICE CONFIGURATION +//************************************************************************** + +static MACHINE_CONFIG_FRAGMENT( ibm5160_mb_config ) + MCFG_DEVICE_ADD("pit8253", PIT8253, 0) + MCFG_PIT8253_CLK0(XTAL_14_31818MHz/12) /* heartbeat IRQ */ + MCFG_PIT8253_OUT0_HANDLER(DEVWRITELINE("pic8259", pic8259_device, ir0_w)) + MCFG_PIT8253_CLK1(XTAL_14_31818MHz/12) /* dram refresh */ + MCFG_PIT8253_OUT1_HANDLER(WRITELINE(ibm5160_mb_device, pc_pit8253_out1_changed)) + MCFG_PIT8253_CLK2(XTAL_14_31818MHz/12) /* pio port c pin 4, and speaker polling enough */ + MCFG_PIT8253_OUT2_HANDLER(WRITELINE(ibm5160_mb_device, pc_pit8253_out2_changed)) + + MCFG_DEVICE_ADD( "dma8237", AM9517A, XTAL_14_31818MHz/3 ) + MCFG_I8237_OUT_HREQ_CB(WRITELINE(ibm5160_mb_device, pc_dma_hrq_changed)) + MCFG_I8237_OUT_EOP_CB(WRITELINE(ibm5160_mb_device, pc_dma8237_out_eop)) + MCFG_I8237_IN_MEMR_CB(READ8(ibm5160_mb_device, pc_dma_read_byte)) + MCFG_I8237_OUT_MEMW_CB(WRITE8(ibm5160_mb_device, pc_dma_write_byte)) + MCFG_I8237_IN_IOR_1_CB(READ8(ibm5160_mb_device, pc_dma8237_1_dack_r)) + MCFG_I8237_IN_IOR_2_CB(READ8(ibm5160_mb_device, pc_dma8237_2_dack_r)) + MCFG_I8237_IN_IOR_3_CB(READ8(ibm5160_mb_device, pc_dma8237_3_dack_r)) + MCFG_I8237_OUT_IOW_0_CB(WRITE8(ibm5160_mb_device, pc_dma8237_0_dack_w)) + MCFG_I8237_OUT_IOW_1_CB(WRITE8(ibm5160_mb_device, pc_dma8237_1_dack_w)) + MCFG_I8237_OUT_IOW_2_CB(WRITE8(ibm5160_mb_device, pc_dma8237_2_dack_w)) + MCFG_I8237_OUT_IOW_3_CB(WRITE8(ibm5160_mb_device, pc_dma8237_3_dack_w)) + MCFG_I8237_OUT_DACK_0_CB(WRITELINE(ibm5160_mb_device, pc_dack0_w)) + MCFG_I8237_OUT_DACK_1_CB(WRITELINE(ibm5160_mb_device, pc_dack1_w)) + MCFG_I8237_OUT_DACK_2_CB(WRITELINE(ibm5160_mb_device, pc_dack2_w)) + MCFG_I8237_OUT_DACK_3_CB(WRITELINE(ibm5160_mb_device, pc_dack3_w)) + + MCFG_PIC8259_ADD( "pic8259", INPUTLINE(":maincpu", 0), VCC, NULL ) + + MCFG_DEVICE_ADD("ppi8255", I8255A, 0) + MCFG_I8255_IN_PORTA_CB(READ8(ibm5160_mb_device, pc_ppi_porta_r)) + MCFG_I8255_OUT_PORTB_CB(WRITE8(ibm5160_mb_device, pc_ppi_portb_w)) + MCFG_I8255_IN_PORTC_CB(READ8(ibm5160_mb_device, pc_ppi_portc_r)) + + MCFG_DEVICE_ADD("isa", ISA8, 0) + MCFG_ISA8_CPU(":maincpu") + MCFG_ISA_OUT_IRQ2_CB(DEVWRITELINE("pic8259", pic8259_device, ir2_w)) + MCFG_ISA_OUT_IRQ3_CB(DEVWRITELINE("pic8259", pic8259_device, ir3_w)) + MCFG_ISA_OUT_IRQ4_CB(DEVWRITELINE("pic8259", pic8259_device, ir4_w)) + MCFG_ISA_OUT_IRQ5_CB(DEVWRITELINE("pic8259", pic8259_device, ir5_w)) + MCFG_ISA_OUT_IRQ6_CB(DEVWRITELINE("pic8259", pic8259_device, ir6_w)) + MCFG_ISA_OUT_IRQ7_CB(DEVWRITELINE("pic8259", pic8259_device, ir7_w)) + MCFG_ISA_OUT_DRQ1_CB(DEVWRITELINE("dma8237", am9517a_device, dreq1_w)) + MCFG_ISA_OUT_DRQ2_CB(DEVWRITELINE("dma8237", am9517a_device, dreq2_w)) + MCFG_ISA_OUT_DRQ3_CB(DEVWRITELINE("dma8237", am9517a_device, dreq3_w)) + + MCFG_DEVICE_ADD("pc_kbdc", PC_KBDC, 0) + MCFG_PC_KBDC_OUT_CLOCK_CB(WRITELINE(ibm5160_mb_device, keyboard_clock_w)) + MCFG_PC_KBDC_OUT_DATA_CB(WRITELINE(ibm5160_mb_device, keyboard_data_w)) + + /* sound hardware */ + MCFG_SPEAKER_STANDARD_MONO("mono") + MCFG_SOUND_ADD("speaker", SPEAKER_SOUND, 0) + MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) +MACHINE_CONFIG_END + + +//------------------------------------------------- +// machine_config_additions - device-specific +// machine configurations +//------------------------------------------------- + +machine_config_constructor ibm5160_mb_device::device_mconfig_additions() const +{ + return MACHINE_CONFIG_NAME( ibm5160_mb_config ); +} + + +static INPUT_PORTS_START( ibm5160_mb ) + PORT_START("DSW0") /* IN1 */ + PORT_DIPNAME( 0xc0, 0x40, "Number of floppy drives") + PORT_DIPSETTING( 0x00, "1" ) + PORT_DIPSETTING( 0x40, "2" ) + PORT_DIPSETTING( 0x80, "3" ) + PORT_DIPSETTING( 0xc0, "4" ) + PORT_DIPNAME( 0x30, 0x30, "Graphics adapter") + PORT_DIPSETTING( 0x00, "EGA/VGA" ) + PORT_DIPSETTING( 0x10, "Color 40x25" ) + PORT_DIPSETTING( 0x20, "Color 80x25" ) + PORT_DIPSETTING( 0x30, "Monochrome" ) + PORT_DIPNAME( 0x0c, 0x0c, "RAM banks") + PORT_DIPSETTING( 0x00, "1 - 16/ 64/256K" ) + PORT_DIPSETTING( 0x04, "2 - 32/128/512K" ) + PORT_DIPSETTING( 0x08, "3 - 48/192/576K" ) + PORT_DIPSETTING( 0x0c, "4 - 64/256/640K" ) + PORT_DIPNAME( 0x02, 0x00, "8087 installed") + PORT_DIPSETTING( 0x00, DEF_STR(No) ) + PORT_DIPSETTING( 0x02, DEF_STR(Yes) ) + PORT_DIPNAME( 0x01, 0x01, "Boot from floppy") + PORT_DIPSETTING( 0x01, DEF_STR(Yes) ) + PORT_DIPSETTING( 0x00, DEF_STR(No) ) +INPUT_PORTS_END +//------------------------------------------------- +// input_ports - device-specific input ports +//------------------------------------------------- + +ioport_constructor ibm5160_mb_device::device_input_ports() const +{ + return INPUT_PORTS_NAME( ibm5160_mb ); +} + + +void ibm5160_mb_device::static_set_cputag(device_t &device, const char *tag) +{ + ibm5160_mb_device &board = downcast<ibm5160_mb_device &>(device); + board.m_cputag = tag; +} + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// ibm5160_mb_device - constructor +//------------------------------------------------- + +ibm5160_mb_device::ibm5160_mb_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, IBM5160_MOTHERBOARD, "IBM5160_MOTHERBOARD", tag, owner, clock, "ibm5160_mb", __FILE__), + m_maincpu(*owner, "maincpu"), + m_pic8259(*this, "pic8259"), + m_dma8237(*this, "dma8237"), + m_pit8253(*this, "pit8253"), + m_ppi8255(*this, "ppi8255"), + m_speaker(*this, "speaker"), + m_isabus(*this, "isa"), + m_pc_kbdc(*this, "pc_kbdc"), + m_ram(*this, ":" RAM_TAG) +{ +} + +DEVICE_ADDRESS_MAP_START( map, 8, ibm5160_mb_device ) + AM_RANGE(0x0000, 0x000f) AM_DEVREADWRITE("dma8237", am9517a_device, read, write) + AM_RANGE(0x0020, 0x002f) AM_DEVREADWRITE("pic8259", pic8259_device, read, write) + AM_RANGE(0x0040, 0x004f) AM_DEVREADWRITE("pit8253", pit8253_device, read, write) + AM_RANGE(0x0060, 0x006f) AM_DEVREADWRITE("ppi8255", i8255_device, read, write) + AM_RANGE(0x0080, 0x008f) AM_WRITE(pc_page_w) + AM_RANGE(0x00a0, 0x00a1) AM_WRITE(nmi_enable_w) +ADDRESS_MAP_END + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void ibm5160_mb_device::device_start() +{ + if(!m_ram->started()) + throw device_missing_dependencies(); + m_maincpu->space(AS_PROGRAM).install_ram(0, m_ram->size() - 1, m_ram->pointer()); +} + + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void ibm5160_mb_device::device_reset() +{ + m_u73_q2 = 0; + m_out1 = 2; // initial state of pit output is undefined + m_pc_spkrdata = 0; + m_pit_out2 = 1; + m_dma_channel = -1; + m_cur_eop = false; + memset(m_dma_offset,0,sizeof(m_dma_offset)); + m_ppi_portc_switch_high = 0; + m_ppi_speaker = 0; + m_ppi_keyboard_clear = 0; + m_ppi_keyb_clock = 0; + m_ppi_portb = 0; + m_ppi_clock_signal = 0; + m_ppi_data_signal = 0; + m_ppi_shift_register = 0; + m_ppi_shift_enable = 0; + m_nmi_enabled = 0; + m_speaker->level_w(0); +} + + +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +const device_type IBM5150_MOTHERBOARD = &device_creator<ibm5150_mb_device>; + +//************************************************************************** +// DEVICE CONFIGURATION +//************************************************************************** +static MACHINE_CONFIG_FRAGMENT( ibm5150_mb_config ) + MCFG_FRAGMENT_ADD(ibm5160_mb_config) + + MCFG_DEVICE_MODIFY("pc_kbdc") + MCFG_PC_KBDC_OUT_CLOCK_CB(WRITELINE(ibm5150_mb_device, keyboard_clock_w)) + + MCFG_DEVICE_MODIFY("ppi8255") + MCFG_I8255_OUT_PORTB_CB(WRITE8(ibm5150_mb_device, pc_ppi_portb_w)) + MCFG_I8255_IN_PORTC_CB(READ8(ibm5150_mb_device, pc_ppi_portc_r)) + + MCFG_CASSETTE_ADD( "cassette" ) + MCFG_CASSETTE_DEFAULT_STATE(CASSETTE_PLAY | CASSETTE_MOTOR_DISABLED | CASSETTE_SPEAKER_ENABLED) +MACHINE_CONFIG_END + + +//------------------------------------------------- +// machine_config_additions - device-specific +// machine configurations +//------------------------------------------------- + +machine_config_constructor ibm5150_mb_device::device_mconfig_additions() const +{ + return MACHINE_CONFIG_NAME( ibm5150_mb_config ); +} + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// ibm5150_mb_device - constructor +//------------------------------------------------- + +ibm5150_mb_device::ibm5150_mb_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : ibm5160_mb_device(mconfig, tag, owner, clock), + m_cassette(*this, "cassette") +{ +} + +READ8_MEMBER (ibm5150_mb_device::pc_ppi_porta_r) +{ + int data = 0xFF; + /* KB port A */ + if (m_ppi_keyboard_clear) + { + /* 0 0 - no floppy drives + * 1 Not used + * 2-3 The number of memory banks on the system board + * 4-5 Display mode + * 11 = monochrome + * 10 - color 80x25 + * 01 - color 40x25 + * 6-7 The number of floppy disk drives + */ + data = ioport("DSW0")->read() & 0xF3; + switch ( m_ram->size() ) + { + case 16 * 1024: + data |= 0x00; + break; + case 32 * 1024: /* Need to verify if this is correct */ + data |= 0x04; + break; + case 48 * 1024: /* Need to verify if this is correct */ + data |= 0x08; + break; + default: + data |= 0x0C; + break; + } + } + else + { + data = m_ppi_shift_register; + } + PIO_LOG(1,"PIO_A_r",("$%02x\n", data)); + return data; +} + + +READ8_MEMBER ( ibm5150_mb_device::pc_ppi_portc_r ) +{ + int data=0xff; + + data&=~0x80; // no parity error + data&=~0x40; // no error on expansion board + /* KB port C: equipment flags */ + if (m_ppi_portc_switch_high) + { + /* read hi nibble of SW2 */ + data = data & 0xf0; + + switch ( m_ram->size() - 64 * 1024 ) + { + case 64 * 1024: data |= 0x00; break; + case 128 * 1024: data |= 0x02; break; + case 192 * 1024: data |= 0x04; break; + case 256 * 1024: data |= 0x06; break; + case 320 * 1024: data |= 0x08; break; + case 384 * 1024: data |= 0x0A; break; + case 448 * 1024: data |= 0x0C; break; + case 512 * 1024: data |= 0x0E; break; + case 576 * 1024: data |= 0x01; break; + case 640 * 1024: data |= 0x03; break; + case 704 * 1024: data |= 0x05; break; + case 768 * 1024: data |= 0x07; break; + case 832 * 1024: data |= 0x09; break; + case 896 * 1024: data |= 0x0B; break; + case 960 * 1024: data |= 0x0D; break; + } + if ( m_ram->size() > 960 * 1024 ) + data |= 0x0D; + + PIO_LOG(1,"PIO_C_r (hi)",("$%02x\n", data)); + } + else + { + /* read lo nibble of S2 */ + data = (data & 0xf0) | (ioport("DSW0")->read() & 0x0f); + PIO_LOG(1,"PIO_C_r (lo)",("$%02x\n", data)); + } + + if ( ! ( m_ppi_portb & 0x08 ) ) + { + double tap_val = m_cassette->input(); + + if ( tap_val < 0 ) + { + data &= ~0x10; + } + else + { + data |= 0x10; + } + } + else + { + if ( m_ppi_portb & 0x01 ) + { + data = ( data & ~0x10 ) | ( m_pit_out2 ? 0x10 : 0x00 ); + } + } + data = ( data & ~0x20 ) | ( m_pit_out2 ? 0x20 : 0x00 ); + + return data; +} + + +WRITE8_MEMBER( ibm5150_mb_device::pc_ppi_portb_w ) +{ + /* KB controller port B */ + m_ppi_portb = data; + m_ppi_portc_switch_high = data & 0x08; + m_ppi_keyboard_clear = data & 0x80; + m_ppi_keyb_clock = data & 0x40; + m_pit8253->write_gate2(BIT(data, 0)); + pc_speaker_set_spkrdata( data & 0x02 ); + + m_cassette->change_state(( data & 0x08 ) ? CASSETTE_MOTOR_DISABLED : CASSETTE_MOTOR_ENABLED,CASSETTE_MASK_MOTOR); + + /* If PB7 is set clear the shift register and reset the IRQ line */ + if ( m_ppi_keyboard_clear ) + { + m_ppi_shift_register = 0; + m_ppi_shift_enable = 0; + m_pic8259->ir1_w(m_ppi_shift_enable); + } + + m_pc_kbdc->data_write_from_mb(!m_ppi_shift_enable); + m_ppi_clock_signal = ( m_ppi_keyb_clock ) ? 1 : 0; + m_pc_kbdc->clock_write_from_mb(m_ppi_clock_signal); +} + +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +const device_type EC1841_MOTHERBOARD = &device_creator<ec1841_mb_device>; + +static MACHINE_CONFIG_FRAGMENT( ec1841_mb_config ) + MCFG_FRAGMENT_ADD(ibm5160_mb_config) + + MCFG_DEVICE_MODIFY("ppi8255") + MCFG_I8255_OUT_PORTB_CB(WRITE8(ec1841_mb_device, pc_ppi_portb_w)) + MCFG_I8255_IN_PORTC_CB(READ8(ec1841_mb_device, pc_ppi_portc_r)) + + MCFG_DEVICE_MODIFY("pc_kbdc") + MCFG_PC_KBDC_OUT_CLOCK_CB(WRITELINE(ec1841_mb_device, keyboard_clock_w)) +MACHINE_CONFIG_END + + +//------------------------------------------------- +// machine_config_additions - device-specific +// machine configurations +//------------------------------------------------- + +machine_config_constructor ec1841_mb_device::device_mconfig_additions() const +{ + return MACHINE_CONFIG_NAME( ec1841_mb_config ); +} + +static INPUT_PORTS_START( ec1841_mb ) + PORT_START("DSW0") /* SA1 */ + PORT_DIPNAME( 0xc0, 0x40, "Number of floppy drives") + PORT_DIPSETTING( 0x00, "1" ) + PORT_DIPSETTING( 0x40, "2" ) + PORT_DIPSETTING( 0x80, "3" ) + PORT_DIPSETTING( 0xc0, "4" ) + PORT_DIPNAME( 0x30, 0x20, "Graphics adapter") + PORT_DIPSETTING( 0x00, "Reserved" ) + PORT_DIPSETTING( 0x10, "Color 40x25" ) + PORT_DIPSETTING( 0x20, "Color 80x25" ) + PORT_DIPSETTING( 0x30, "Monochrome" ) + PORT_BIT( 0x08, 0x08, IPT_UNUSED ) + /* BIOS does not support booting from QD floppies */ + PORT_DIPNAME( 0x04, 0x04, "Floppy type") + PORT_DIPSETTING( 0x00, "80 tracks" ) + PORT_DIPSETTING( 0x04, "40 tracks" ) + PORT_DIPNAME( 0x02, 0x00, "8087 installed") + PORT_DIPSETTING( 0x00, DEF_STR(No) ) + PORT_DIPSETTING( 0x02, DEF_STR(Yes) ) + PORT_DIPNAME( 0x01, 0x01, "Boot from floppy") + PORT_DIPSETTING( 0x01, DEF_STR(Yes) ) + PORT_DIPSETTING( 0x00, DEF_STR(No) ) + + PORT_START("SA2") + PORT_DIPNAME( 0x04, 0x04, "Speech synthesizer") + PORT_DIPSETTING( 0x00, "Installed" ) + PORT_DIPSETTING( 0x04, "Not installed" ) +INPUT_PORTS_END + +//------------------------------------------------- +// input_ports - device-specific input ports +//------------------------------------------------- + +ioport_constructor ec1841_mb_device::device_input_ports() const +{ + return INPUT_PORTS_NAME( ec1841_mb ); +} + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// ec1841_mb_device - constructor +//------------------------------------------------- + +ec1841_mb_device::ec1841_mb_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : ibm5160_mb_device(mconfig, tag, owner, clock) +{ +} + +void ec1841_mb_device::device_start() +{ +} + +// kbd interface is 5150-like but PB2 controls access to second bank of DIP switches (SA2). +WRITE8_MEMBER( ec1841_mb_device::pc_ppi_portb_w ) +{ + /* KB controller port B */ + m_ppi_portb = data; + m_ppi_portc_switch_high = data & 0x04; + m_ppi_keyboard_clear = data & 0x80; + m_ppi_keyb_clock = data & 0x40; + m_pit8253->write_gate2(BIT(data, 0)); + pc_speaker_set_spkrdata( data & 0x02 ); + + /* If PB7 is set clear the shift register and reset the IRQ line */ + if ( m_ppi_keyboard_clear ) + { + m_ppi_shift_register = 0; + m_ppi_shift_enable = 0; + m_pic8259->ir1_w(m_ppi_shift_enable); + } + + m_pc_kbdc->data_write_from_mb(!m_ppi_shift_enable); + m_ppi_clock_signal = ( m_ppi_keyb_clock ) ? 1 : 0; + m_pc_kbdc->clock_write_from_mb(m_ppi_clock_signal); +} + +READ8_MEMBER ( ec1841_mb_device::pc_ppi_portc_r ) +{ + int data=0xff; + + data&=~0x80; // no parity error + data&=~0x40; // no error on expansion board + + if (m_ppi_portc_switch_high) + { + data = (data & 0xf0) | (ioport("SA2")->read() & 0x0f); + } + + data = ( data & ~0x20 ) | ( m_pit_out2 ? 0x20 : 0x00 ); + + return data; +} + +pc_noppi_mb_device::pc_noppi_mb_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : ibm5160_mb_device(mconfig, tag, owner, clock) +{ +} + +//************************************************************************** +// DEVICE CONFIGURATION +//************************************************************************** + +static MACHINE_CONFIG_FRAGMENT( pc_noppi_mb_config ) + MCFG_FRAGMENT_ADD(ibm5160_mb_config) + + MCFG_DEVICE_REMOVE("pc_kbdc") + MCFG_DEVICE_REMOVE("ppi8255") +MACHINE_CONFIG_END + +static INPUT_PORTS_START( pc_noppi_mb ) +INPUT_PORTS_END + +//------------------------------------------------- +// machine_config_additions - device-specific +// machine configurations +//------------------------------------------------- + +machine_config_constructor pc_noppi_mb_device::device_mconfig_additions() const +{ + return MACHINE_CONFIG_NAME( pc_noppi_mb_config ); +} + +ioport_constructor pc_noppi_mb_device::device_input_ports() const +{ + return INPUT_PORTS_NAME( pc_noppi_mb ); +} + +DEVICE_ADDRESS_MAP_START( map, 8, pc_noppi_mb_device ) + AM_RANGE(0x0000, 0x000f) AM_DEVREADWRITE("dma8237", am9517a_device, read, write) + AM_RANGE(0x0020, 0x002f) AM_DEVREADWRITE("pic8259", pic8259_device, read, write) + AM_RANGE(0x0040, 0x004f) AM_DEVREADWRITE("pit8253", pit8253_device, read, write) + AM_RANGE(0x0080, 0x008f) AM_WRITE(pc_page_w) + AM_RANGE(0x00a0, 0x00a1) AM_WRITE(nmi_enable_w) +ADDRESS_MAP_END + +const device_type PCNOPPI_MOTHERBOARD = &device_creator<pc_noppi_mb_device>; diff --git a/src/devices/machine/genpc.h b/src/devices/machine/genpc.h new file mode 100644 index 00000000000..e766ea367da --- /dev/null +++ b/src/devices/machine/genpc.h @@ -0,0 +1,195 @@ +// license:BSD-3-Clause +// copyright-holders:Wilbert Pol, Miodrag Milanovic +/***************************************************************************** + * + * includes/pc.h + * + ****************************************************************************/ + +#ifndef GENPC_H_ +#define GENPC_H_ + +#include "machine/ins8250.h" +#include "machine/i8255.h" +#include "machine/am9517a.h" +#include "bus/isa/isa.h" +#include "bus/isa/isa_cards.h" +#include "bus/pc_kbd/pc_kbdc.h" +#include "machine/pic8259.h" +#include "machine/pit8253.h" +#include "sound/speaker.h" +#include "imagedev/cassette.h" +#include "machine/ram.h" + +#define MCFG_IBM5160_MOTHERBOARD_ADD(_tag, _cputag) \ + MCFG_DEVICE_ADD(_tag, IBM5160_MOTHERBOARD, 0) \ + ibm5160_mb_device::static_set_cputag(*device, _cputag); +// ======================> ibm5160_mb_device +class ibm5160_mb_device : public device_t +{ +public: + // construction/destruction + ibm5160_mb_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + // inline configuration + static void static_set_cputag(device_t &device, const char *tag); + + // optional information overrides + virtual machine_config_constructor device_mconfig_additions() const override; + virtual ioport_constructor device_input_ports() const override; + + DECLARE_ADDRESS_MAP(map, 8); +protected: + // device-level overrides + virtual void device_start() override; + virtual void device_reset() override; +public: + required_device<cpu_device> m_maincpu; + required_device<pic8259_device> m_pic8259; + required_device<am9517a_device> m_dma8237; + required_device<pit8253_device> m_pit8253; + optional_device<i8255_device> m_ppi8255; + required_device<speaker_sound_device> m_speaker; + required_device<isa8_device> m_isabus; + optional_device<pc_kbdc_device> m_pc_kbdc; + required_device<ram_device> m_ram; + + /* U73 is an LS74 - dual flip flop */ + /* Q2 is set by OUT1 from the 8253 and goes to DRQ1 on the 8237 */ + UINT8 m_u73_q2; + UINT8 m_out1; + int m_dma_channel; + UINT8 m_dma_offset[4]; + UINT8 m_pc_spkrdata; + UINT8 m_pit_out2; + bool m_cur_eop; + + UINT8 m_nmi_enabled; + + int m_ppi_portc_switch_high; + int m_ppi_speaker; + int m_ppi_keyboard_clear; + UINT8 m_ppi_keyb_clock; + UINT8 m_ppi_portb; + UINT8 m_ppi_clock_signal; + UINT8 m_ppi_data_signal; + UINT8 m_ppi_shift_register; + UINT8 m_ppi_shift_enable; + + // interface to the keyboard + DECLARE_WRITE_LINE_MEMBER( keyboard_clock_w ); + DECLARE_WRITE_LINE_MEMBER( keyboard_data_w ); + + DECLARE_READ8_MEMBER ( pc_ppi_porta_r ); + DECLARE_READ8_MEMBER ( pc_ppi_portc_r ); + DECLARE_WRITE8_MEMBER( pc_ppi_portb_w ); + + DECLARE_WRITE_LINE_MEMBER( pc_pit8253_out1_changed ); + DECLARE_WRITE_LINE_MEMBER( pc_pit8253_out2_changed ); + + DECLARE_WRITE_LINE_MEMBER( pc_dma_hrq_changed ); + DECLARE_WRITE_LINE_MEMBER( pc_dma8237_out_eop ); + DECLARE_READ8_MEMBER( pc_dma_read_byte ); + DECLARE_WRITE8_MEMBER( pc_dma_write_byte ); + DECLARE_READ8_MEMBER( pc_dma8237_1_dack_r ); + DECLARE_READ8_MEMBER( pc_dma8237_2_dack_r ); + DECLARE_READ8_MEMBER( pc_dma8237_3_dack_r ); + DECLARE_WRITE8_MEMBER( pc_dma8237_1_dack_w ); + DECLARE_WRITE8_MEMBER( pc_dma8237_2_dack_w ); + DECLARE_WRITE8_MEMBER( pc_dma8237_3_dack_w ); + DECLARE_WRITE8_MEMBER( pc_dma8237_0_dack_w ); + DECLARE_WRITE_LINE_MEMBER( pc_dack0_w ); + DECLARE_WRITE_LINE_MEMBER( pc_dack1_w ); + DECLARE_WRITE_LINE_MEMBER( pc_dack2_w ); + DECLARE_WRITE_LINE_MEMBER( pc_dack3_w ); + + DECLARE_WRITE_LINE_MEMBER( pc_speaker_set_spkrdata ); + + DECLARE_WRITE8_MEMBER(pc_page_w); + DECLARE_WRITE8_MEMBER(nmi_enable_w); + + const char *m_cputag; + +private: + void pc_select_dma_channel(int channel, bool state); +}; + + +// device type definition +extern const device_type IBM5160_MOTHERBOARD; + + +#define MCFG_IBM5150_MOTHERBOARD_ADD(_tag, _cputag) \ + MCFG_DEVICE_ADD(_tag, IBM5150_MOTHERBOARD, 0) \ + ibm5150_mb_device::static_set_cputag(*device, _cputag); + +// ======================> ibm5150_mb_device +class ibm5150_mb_device : public ibm5160_mb_device +{ +public: + // construction/destruction + ibm5150_mb_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // optional information overrides + virtual machine_config_constructor device_mconfig_additions() const override; + + DECLARE_WRITE_LINE_MEMBER( keyboard_clock_w ); + +protected: + // device-level overrides + + required_device<cassette_image_device> m_cassette; +public: + DECLARE_READ8_MEMBER ( pc_ppi_porta_r ); + DECLARE_READ8_MEMBER ( pc_ppi_portc_r ); + DECLARE_WRITE8_MEMBER( pc_ppi_portb_w ); +}; + + +// device type definition +extern const device_type IBM5150_MOTHERBOARD; + + +#define MCFG_EC1841_MOTHERBOARD_ADD(_tag, _cputag) \ + MCFG_DEVICE_ADD(_tag, EC1841_MOTHERBOARD, 0) \ + ec1841_mb_device::static_set_cputag(*device, _cputag); + +class ec1841_mb_device : public ibm5160_mb_device +{ +public: + // construction/destruction + ec1841_mb_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // optional information overrides + virtual machine_config_constructor device_mconfig_additions() const override; + virtual ioport_constructor device_input_ports() const override; + virtual void device_start() override; + +public: + DECLARE_READ8_MEMBER ( pc_ppi_portc_r ); + DECLARE_WRITE8_MEMBER( pc_ppi_portb_w ); + + DECLARE_WRITE_LINE_MEMBER( keyboard_clock_w ); +}; + +extern const device_type EC1841_MOTHERBOARD; + +#define MCFG_PCNOPPI_MOTHERBOARD_ADD(_tag, _cputag) \ + MCFG_DEVICE_ADD(_tag, PCNOPPI_MOTHERBOARD, 0) \ + pc_noppi_mb_device::static_set_cputag(*device, _cputag); + +class pc_noppi_mb_device : public ibm5160_mb_device +{ +public: + // construction/destruction + pc_noppi_mb_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + UINT8 pit_out2() { return m_pit_out2; } // helper for near-clones with multifunction ics instead of 8255s + + DECLARE_ADDRESS_MAP(map, 8); + + virtual machine_config_constructor device_mconfig_additions() const override; + virtual ioport_constructor device_input_ports() const override; +}; + +extern const device_type PCNOPPI_MOTHERBOARD; + +#endif /* GENPC_H_ */ diff --git a/src/devices/machine/k056230.cpp b/src/devices/machine/k056230.cpp index 8d750b66a8a..f641b799147 100644 --- a/src/devices/machine/k056230.cpp +++ b/src/devices/machine/k056230.cpp @@ -54,12 +54,7 @@ READ8_MEMBER(k056230_device::read) return 0; } -TIMER_CALLBACK( k056230_device::network_irq_clear_callback ) -{ - reinterpret_cast<k056230_device*>(ptr)->network_irq_clear(); -} - -void k056230_device::network_irq_clear() +TIMER_CALLBACK_MEMBER(k056230_device::network_irq_clear) { if (m_cpu) m_cpu->set_input_line(INPUT_LINE_IRQ2, CLEAR_LINE); @@ -84,7 +79,7 @@ WRITE8_MEMBER(k056230_device::write) if (m_cpu) m_cpu->set_input_line(INPUT_LINE_IRQ2, ASSERT_LINE); - machine().scheduler().timer_set(attotime::from_usec(10), FUNC(network_irq_clear_callback), 0, (void*)this); + machine().scheduler().timer_set(attotime::from_usec(10), timer_expired_delegate(FUNC(k056230_device::network_irq_clear), this)); } } // else diff --git a/src/devices/machine/k056230.h b/src/devices/machine/k056230.h index 5695261f4c2..4fa8d165fd1 100644 --- a/src/devices/machine/k056230.h +++ b/src/devices/machine/k056230.h @@ -47,7 +47,7 @@ public: DECLARE_READ8_MEMBER(read); DECLARE_WRITE8_MEMBER(write); - static TIMER_CALLBACK( network_irq_clear_callback ); + TIMER_CALLBACK_MEMBER(network_irq_clear); protected: // device-level overrides @@ -58,7 +58,6 @@ protected: private: - void network_irq_clear(); int m_is_thunderh; required_device<cpu_device> m_cpu; diff --git a/src/devices/machine/nvram.cpp b/src/devices/machine/nvram.cpp index d1e99ceb98b..88d1191187a 100644 --- a/src/devices/machine/nvram.cpp +++ b/src/devices/machine/nvram.cpp @@ -165,5 +165,5 @@ void nvram_device::determine_final_base() // if we are region-backed for the default, find it now and make sure it's the right size if (m_region != nullptr && m_region->bytes() != m_length) - throw emu_fatalerror("NVRAM device '%s' has a default region, but it should be 0x%" SIZETFMT "X bytes", tag(), m_length); + throw emu_fatalerror("%s",string_format("NVRAM device '%s' has a default region, but it should be 0x%I64uX bytes", tag(), m_length).c_str()); } diff --git a/src/devices/machine/ram.cpp b/src/devices/machine/ram.cpp index c190ea64f16..66e8b31cf4f 100644 --- a/src/devices/machine/ram.cpp +++ b/src/devices/machine/ram.cpp @@ -1,4 +1,4 @@ -// license: BSD-3-Clause +// license:BSD-3-Clause // copyright-holders: Dirk Best /************************************************************************* diff --git a/src/devices/machine/ram.h b/src/devices/machine/ram.h index 5140309f825..8fbe85cd865 100644 --- a/src/devices/machine/ram.h +++ b/src/devices/machine/ram.h @@ -1,4 +1,4 @@ -// license: BSD-3-Clause +// license:BSD-3-Clause // copyright-holders: Dirk Best /************************************************************************* diff --git a/src/devices/machine/rtc65271.cpp b/src/devices/machine/rtc65271.cpp index 074b8d87f48..0c02e4fb176 100644 --- a/src/devices/machine/rtc65271.cpp +++ b/src/devices/machine/rtc65271.cpp @@ -464,30 +464,10 @@ void rtc65271_device::field_interrupts() /* - Timer handlers -*/ -TIMER_CALLBACK( rtc65271_device::rtc_SQW_callback ) -{ - rtc65271_device *rtc = reinterpret_cast<rtc65271_device *>(ptr); - rtc->rtc_SQW_cb(); -} - -TIMER_CALLBACK( rtc65271_device::rtc_begin_update_callback ) -{ - rtc65271_device *rtc = reinterpret_cast<rtc65271_device *>(ptr); - rtc->rtc_begin_update_cb(); -} - -TIMER_CALLBACK( rtc65271_device::rtc_end_update_callback ) -{ - rtc65271_device *rtc = reinterpret_cast<rtc65271_device *>(ptr); - rtc->rtc_end_update_cb(); -} -/* Update SQW output state each half-period and assert periodic interrupt each period. */ -void rtc65271_device::rtc_SQW_cb() +TIMER_CALLBACK_MEMBER(rtc65271_device::rtc_SQW_cb) { attotime half_period; @@ -506,14 +486,14 @@ void rtc65271_device::rtc_SQW_cb() /* Begin update cycle (called every second) */ -void rtc65271_device::rtc_begin_update_cb() +TIMER_CALLBACK_MEMBER(rtc65271_device::rtc_begin_update_cb) { if (((m_regs[reg_A] & reg_A_DV) == 0x20) && ! (m_regs[reg_B] & reg_B_SET)) { m_regs[reg_A] |= reg_A_UIP; /* schedule end of update cycle */ - machine().scheduler().timer_set(UPDATE_CYCLE_TIME, FUNC(rtc_end_update_callback), 0, (void *)this); + machine().scheduler().timer_set(UPDATE_CYCLE_TIME, timer_expired_delegate(FUNC(rtc65271_device::rtc_end_update_cb), this)); } } @@ -521,7 +501,7 @@ void rtc65271_device::rtc_begin_update_cb() End update cycle (called UPDATE_CYCLE_TIME = 1948us after start of update cycle) */ -void rtc65271_device::rtc_end_update_cb() +TIMER_CALLBACK_MEMBER(rtc65271_device::rtc_end_update_cb) { static const int days_in_month_table[12] = { @@ -684,9 +664,9 @@ rtc65271_device::rtc65271_device(const machine_config &mconfig, const char *tag, //------------------------------------------------- void rtc65271_device::device_start() { - m_update_timer = machine().scheduler().timer_alloc(FUNC(rtc_begin_update_callback), (void *)this); + m_update_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(rtc65271_device::rtc_begin_update_cb), this)); m_update_timer->adjust(attotime::from_seconds(1), 0, attotime::from_seconds(1)); - m_SQW_timer = machine().scheduler().timer_alloc(FUNC(rtc_SQW_callback), (void *)this); + m_SQW_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(rtc65271_device::rtc_SQW_cb), this)); m_interrupt_cb.resolve(); save_item(NAME(m_regs)); diff --git a/src/devices/machine/rtc65271.h b/src/devices/machine/rtc65271.h index c5d554e75fd..903f5fe9a28 100644 --- a/src/devices/machine/rtc65271.h +++ b/src/devices/machine/rtc65271.h @@ -43,13 +43,9 @@ private: void write(int xramsel, offs_t offset, UINT8 data); void field_interrupts(); - static TIMER_CALLBACK( rtc_SQW_callback ); - static TIMER_CALLBACK( rtc_begin_update_callback ); - static TIMER_CALLBACK( rtc_end_update_callback ); - - void rtc_SQW_cb(); - void rtc_begin_update_cb(); - void rtc_end_update_cb(); + TIMER_CALLBACK_MEMBER(rtc_SQW_cb); + TIMER_CALLBACK_MEMBER(rtc_begin_update_cb); + TIMER_CALLBACK_MEMBER(rtc_end_update_cb); /* 64 8-bit registers (10 clock registers, 4 control/status registers, and 50 bytes of user RAM) */ UINT8 m_regs[64]; diff --git a/src/devices/machine/rtc9701.cpp b/src/devices/machine/rtc9701.cpp index 7c92ddc53e7..fc72c76c900 100644 --- a/src/devices/machine/rtc9701.cpp +++ b/src/devices/machine/rtc9701.cpp @@ -41,7 +41,7 @@ rtc9701_device::rtc9701_device(const machine_config &mconfig, const char *tag, d { } -void rtc9701_device::timer_callback() +TIMER_CALLBACK_MEMBER(rtc9701_device::timer_callback) { static const UINT8 dpm[12] = { 0x31, 0x28, 0x31, 0x30, 0x31, 0x30, 0x31, 0x31, 0x30, 0x31, 0x30, 0x31 }; int dpm_count; @@ -72,11 +72,6 @@ void rtc9701_device::timer_callback() if((m_rtc.year & 0xf0) >= 0xa0) { m_rtc.year = 0; } //2000-2099 possible timeframe } -TIMER_CALLBACK( rtc9701_device::rtc_inc_callback ) -{ - reinterpret_cast<rtc9701_device *>(ptr)->timer_callback(); -} - //------------------------------------------------- // device_validity_check - perform validity checks // on this device @@ -93,7 +88,7 @@ void rtc9701_device::device_validity_check(validity_checker &valid) const void rtc9701_device::device_start() { /* let's call the timer callback every second */ - machine().scheduler().timer_pulse(attotime::from_hz(clock() / XTAL_32_768kHz), FUNC(rtc_inc_callback), 0, (void *)this); + machine().scheduler().timer_pulse(attotime::from_hz(clock() / XTAL_32_768kHz), timer_expired_delegate(FUNC(rtc9701_device::timer_callback), this)); system_time systime; machine().base_datetime(systime); diff --git a/src/devices/machine/rtc9701.h b/src/devices/machine/rtc9701.h index 14407f157ec..c294cb5d9f1 100644 --- a/src/devices/machine/rtc9701.h +++ b/src/devices/machine/rtc9701.h @@ -59,7 +59,7 @@ public: DECLARE_READ_LINE_MEMBER( read_bit ); DECLARE_WRITE_LINE_MEMBER( set_cs_line ); DECLARE_WRITE_LINE_MEMBER( set_clock_line ); - void timer_callback(); + TIMER_CALLBACK_MEMBER(timer_callback); protected: // device-level overrides @@ -74,8 +74,6 @@ protected: inline UINT8 rtc_read(UINT8 offset); inline void rtc_write(UINT8 offset,UINT8 data); - static TIMER_CALLBACK( rtc_inc_callback ); - int m_latch; int m_reset_line; int m_clock_line; diff --git a/src/devices/machine/s3520cf.cpp b/src/devices/machine/s3520cf.cpp index d37a6b2a542..e504e5b9022 100644 --- a/src/devices/machine/s3520cf.cpp +++ b/src/devices/machine/s3520cf.cpp @@ -40,7 +40,7 @@ s3520cf_device::s3520cf_device(const machine_config &mconfig, const char *tag, d { } -void s3520cf_device::timer_callback() +TIMER_CALLBACK_MEMBER(s3520cf_device::timer_callback) { static const UINT8 dpm[12] = { 0x31, 0x28, 0x31, 0x30, 0x31, 0x30, 0x31, 0x31, 0x30, 0x31, 0x30, 0x31 }; int dpm_count; @@ -71,10 +71,6 @@ void s3520cf_device::timer_callback() if((m_rtc.year & 0xf0) >= 0xa0) { m_rtc.year = 0; } //1901-2000 possible timeframe } -TIMER_CALLBACK( s3520cf_device::rtc_inc_callback ) -{ - reinterpret_cast<s3520cf_device *>(ptr)->timer_callback(); -} //------------------------------------------------- // device_validity_check - perform validity checks @@ -93,7 +89,7 @@ void s3520cf_device::device_validity_check(validity_checker &valid) const void s3520cf_device::device_start() { /* let's call the timer callback every second for now */ - machine().scheduler().timer_pulse(attotime::from_hz(clock() / XTAL_32_768kHz), FUNC(rtc_inc_callback), 0, (void *)this); + machine().scheduler().timer_pulse(attotime::from_hz(clock() / XTAL_32_768kHz), timer_expired_delegate(FUNC(s3520cf_device::timer_callback), this)); system_time systime; machine().base_datetime(systime); diff --git a/src/devices/machine/s3520cf.h b/src/devices/machine/s3520cf.h index c277c69142a..b2b3fa452a6 100644 --- a/src/devices/machine/s3520cf.h +++ b/src/devices/machine/s3520cf.h @@ -50,7 +50,7 @@ public: DECLARE_WRITE_LINE_MEMBER( set_cs_line ); DECLARE_WRITE_LINE_MEMBER( set_clock_line ); DECLARE_WRITE_LINE_MEMBER( write_bit ); - void timer_callback(); + TIMER_CALLBACK_MEMBER(timer_callback); protected: // device-level overrides @@ -60,8 +60,6 @@ protected: inline UINT8 rtc_read(UINT8 offset); inline void rtc_write(UINT8 offset,UINT8 data); - static TIMER_CALLBACK( rtc_inc_callback ); - int m_dir; int m_latch; int m_reset_line; diff --git a/src/devices/machine/s3c24xx.inc b/src/devices/machine/s3c24xx.inc index e2c4800f077..ca7bc05a90d 100644 --- a/src/devices/machine/s3c24xx.inc +++ b/src/devices/machine/s3c24xx.inc @@ -1,3 +1,5 @@ +// license:BSD-3-Clause +// copyright-holders:Tim Schuerewegen /******************************************************************************* Samsung S3C2400 / S3C2410 / S3C2440 diff --git a/src/devices/machine/serflash.cpp b/src/devices/machine/serflash.cpp index ebdd1dd53a9..f5a002ae929 100644 --- a/src/devices/machine/serflash.cpp +++ b/src/devices/machine/serflash.cpp @@ -77,7 +77,7 @@ void serflash_device::nvram_read(emu_file &file) int size = m_length / FLASH_PAGE_SIZE; - if (file) + if (file.is_open()) { UINT32 page; file.read(&page, 4); diff --git a/src/devices/machine/terminal.cpp b/src/devices/machine/terminal.cpp index 6b1b26b8c85..86388182f15 100644 --- a/src/devices/machine/terminal.cpp +++ b/src/devices/machine/terminal.cpp @@ -319,14 +319,14 @@ WRITE8_MEMBER( generic_terminal_device::kbd_put ) ***************************************************************************/ static MACHINE_CONFIG_FRAGMENT( generic_terminal ) - MCFG_SCREEN_ADD(TERMINAL_SCREEN_TAG, RASTER) + MCFG_SCREEN_ADD_MONOCHROME(TERMINAL_SCREEN_TAG, RASTER, rgb_t::green) MCFG_SCREEN_REFRESH_RATE(50) MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ MCFG_SCREEN_SIZE(TERMINAL_WIDTH*8, TERMINAL_HEIGHT*10) MCFG_SCREEN_VISIBLE_AREA(0, TERMINAL_WIDTH*8-1, 0, TERMINAL_HEIGHT*10-1) MCFG_SCREEN_UPDATE_DEVICE(DEVICE_SELF, generic_terminal_device, update) - MCFG_PALETTE_ADD_MONOCHROME_GREEN("palette") + MCFG_PALETTE_ADD_MONOCHROME("palette") MCFG_DEVICE_ADD(KEYBOARD_TAG, GENERIC_KEYBOARD, 0) MCFG_GENERIC_KEYBOARD_CB(WRITE8(generic_terminal_device, kbd_put)) diff --git a/src/devices/machine/v3021.cpp b/src/devices/machine/v3021.cpp index ab0057d9951..d7caf681c70 100644 --- a/src/devices/machine/v3021.cpp +++ b/src/devices/machine/v3021.cpp @@ -38,7 +38,7 @@ v3021_device::v3021_device(const machine_config &mconfig, const char *tag, devic { } -void v3021_device::timer_callback() +TIMER_CALLBACK_MEMBER(v3021_device::timer_callback) { static const UINT8 dpm[12] = { 0x31, 0x28, 0x31, 0x30, 0x31, 0x30, 0x31, 0x31, 0x30, 0x31, 0x30, 0x31 }; int dpm_count; @@ -69,11 +69,6 @@ void v3021_device::timer_callback() if((m_rtc.year & 0xf0) >= 0xa0) { m_rtc.year = 0; } //2000-2099 possible timeframe } -TIMER_CALLBACK( v3021_device::rtc_inc_callback ) -{ - reinterpret_cast<v3021_device *>(ptr)->timer_callback(); -} - //------------------------------------------------- // device_validity_check - perform validity checks // on this device @@ -90,7 +85,7 @@ void v3021_device::device_validity_check(validity_checker &valid) const void v3021_device::device_start() { /* let's call the timer callback every second */ - machine().scheduler().timer_pulse(attotime::from_hz(clock() / XTAL_32_768kHz), FUNC(rtc_inc_callback), 0, (void *)this); + machine().scheduler().timer_pulse(attotime::from_hz(clock() / XTAL_32_768kHz), timer_expired_delegate(FUNC(v3021_device::timer_callback),this)); system_time systime; machine().base_datetime(systime); diff --git a/src/devices/machine/v3021.h b/src/devices/machine/v3021.h index 7e4844216c4..ed13501e949 100644 --- a/src/devices/machine/v3021.h +++ b/src/devices/machine/v3021.h @@ -45,7 +45,7 @@ public: // I/O operations DECLARE_WRITE8_MEMBER( write ); DECLARE_READ8_MEMBER( read ); - void timer_callback(); + TIMER_CALLBACK_MEMBER(timer_callback); protected: // device-level overrides @@ -53,8 +53,6 @@ protected: virtual void device_start() override; virtual void device_reset() override; - static TIMER_CALLBACK( rtc_inc_callback ); - UINT8 m_cal_mask,m_cal_com,m_cal_cnt,m_cal_val; rtc_regs_t m_rtc; diff --git a/src/devices/machine/wd_fdc.cpp b/src/devices/machine/wd_fdc.cpp index 15744f5f7bc..84fcbf5ceb8 100644 --- a/src/devices/machine/wd_fdc.cpp +++ b/src/devices/machine/wd_fdc.cpp @@ -90,7 +90,7 @@ void wd_fdc_t::device_start() enmf_cb.resolve(); if (!has_enmf && !enmf_cb.isnull()) - logerror("%s: Warning, this chip doesn't have an ENMF line.\n", tag()); + logerror("Warning, this chip doesn't have an ENMF line.\n"); t_gen = timer_alloc(TM_GEN); t_cmd = timer_alloc(TM_CMD); @@ -154,9 +154,9 @@ void wd_fdc_t::soft_reset() intrq_cond = 0; live_abort(); - // restore - last_dir = 1; - seek_start(RESTORE); + // trigger a restore after everything else is reset too, in particular the floppy device itself + sub_state = INITIAL_RESTORE; + t_gen->adjust(attotime::zero); } void wd_fdc_t::set_floppy(floppy_image_device *_floppy) @@ -190,13 +190,13 @@ void wd_fdc_t::set_floppy(floppy_image_device *_floppy) void wd_fdc_t::dden_w(bool _dden) { if(disable_mfm) { - logerror("%s: Error, this chip does not have a dden line\n", tag()); + logerror("Error, this chip does not have a dden line\n"); return; } if(dden != _dden) { dden = _dden; - if (TRACE_LINES) logerror("%s: select %s\n", tag(), dden ? "fm" : "mfm"); + if (TRACE_LINES) logerror("select %s\n", dden ? "fm" : "mfm"); } } @@ -215,7 +215,7 @@ std::string wd_fdc_t::ttsn() void wd_fdc_t::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { - if (TRACE_EVENT) logerror("%s: Event fired for timer %s\n", tag(), (id==TM_GEN)? "TM_GEN" : (id==TM_CMD)? "TM_CMD" : (id==TM_TRACK)? "TM_TRACK" : "TM_SECTOR"); + if (TRACE_EVENT) logerror("Event fired for timer %s\n", (id==TM_GEN)? "TM_GEN" : (id==TM_CMD)? "TM_CMD" : (id==TM_TRACK)? "TM_TRACK" : "TM_SECTOR"); live_sync(); switch(id) { @@ -243,7 +243,7 @@ void wd_fdc_t::command_end() void wd_fdc_t::seek_start(int state) { - if (TRACE_COMMAND) logerror("%s: seek %d (track=%d)\n", tag(), data, track); + if (TRACE_COMMAND) logerror("seek %d (track=%d)\n", data, track); main_state = state; status &= ~(S_CRC|S_RNF|S_SPIN); if(head_control) { @@ -263,7 +263,7 @@ void wd_fdc_t::seek_continue() for(;;) { switch(sub_state) { case SPINUP: - if (TRACE_STATE) logerror("%s: SPINUP\n", tag()); + if (TRACE_STATE) logerror("SPINUP\n"); if(!(status & S_MON)) { spinup(); return; @@ -274,11 +274,11 @@ void wd_fdc_t::seek_continue() break; case SPINUP_WAIT: - if (TRACE_STATE) logerror("%s: SPINUP_WAIT\n", tag()); + if (TRACE_STATE) logerror("SPINUP_WAIT\n"); return; case SPINUP_DONE: - if (TRACE_STATE) logerror("%s: SPINUP_DONE\n", tag()); + if (TRACE_STATE) logerror("SPINUP_DONE\n"); if(main_state == RESTORE && floppy && !floppy->trk00_r()) { sub_state = SEEK_WAIT_STEP_TIME; delay_cycles(t_gen, step_times[command & 3]); @@ -296,7 +296,7 @@ void wd_fdc_t::seek_continue() break; case SEEK_MOVE: - if (TRACE_STATE) logerror("%s: SEEK_MOVE\n", tag()); + if (TRACE_STATE) logerror("SEEK_MOVE\n"); if(floppy) { floppy->dir_w(last_dir); floppy->stp_w(0); @@ -312,11 +312,11 @@ void wd_fdc_t::seek_continue() return; case SEEK_WAIT_STEP_TIME: - if (TRACE_STATE) logerror("%s: SEEK_WAIT_STEP_TIME\n", tag()); + if (TRACE_STATE) logerror("SEEK_WAIT_STEP_TIME\n"); return; case SEEK_WAIT_STEP_TIME_DONE: { - if (TRACE_STATE) logerror("%s: SEEK_WAIT_STEP_TIME_DONE\n", tag()); + if (TRACE_STATE) logerror("SEEK_WAIT_STEP_TIME_DONE\n"); bool done = false; switch(main_state) { case RESTORE: @@ -349,16 +349,16 @@ void wd_fdc_t::seek_continue() } case SEEK_WAIT_STABILIZATION_TIME: - if (TRACE_STATE) logerror("%s: SEEK_WAIT_STABILIZATION_TIME\n", tag()); + if (TRACE_STATE) logerror("SEEK_WAIT_STABILIZATION_TIME\n"); return; case SEEK_WAIT_STABILIZATION_TIME_DONE: - if (TRACE_STATE) logerror("%s: SEEK_WAIT_STABILIZATION_TIME_DONE\n", tag()); + if (TRACE_STATE) logerror("SEEK_WAIT_STABILIZATION_TIME_DONE\n"); sub_state = SEEK_DONE; break; case SEEK_DONE: - if (TRACE_STATE) logerror("%s: SEEK_DONE\n", tag()); + if (TRACE_STATE) logerror("SEEK_DONE\n"); status |= S_HLD; hld = true; if (!hld_cb.isnull()) @@ -378,7 +378,7 @@ void wd_fdc_t::seek_continue() return; case SCAN_ID: - if (TRACE_STATE) logerror("%s: SCAN_ID\n", tag()); + if (TRACE_STATE) logerror("SCAN_ID\n"); if(cur_live.idbuf[0] != track) { live_start(SEARCH_ADDRESS_MARK_HEADER); return; @@ -392,13 +392,13 @@ void wd_fdc_t::seek_continue() return; case SCAN_ID_FAILED: - if (TRACE_STATE) logerror("%s: SCAN_ID_FAILED\n", tag()); + if (TRACE_STATE) logerror("SCAN_ID_FAILED\n"); status |= S_RNF; command_end(); return; default: - logerror("%s: seek unknown sub-state %d\n", ttsn().c_str(), sub_state); + logerror("seek unknown sub-state %d\n", ttsn().c_str(), sub_state); return; } } @@ -407,7 +407,7 @@ void wd_fdc_t::seek_continue() bool wd_fdc_t::sector_matches() const { if(TRACE_MATCH) - logerror("%s: matching read T=%02x H=%02x S=%02x L=%02x - searched T=%02x S=%02x\n", tag(), + logerror("matching read T=%02x H=%02x S=%02x L=%02x - searched T=%02x S=%02x\n", cur_live.idbuf[0], cur_live.idbuf[1], cur_live.idbuf[2], cur_live.idbuf[3], track, sector); @@ -428,7 +428,7 @@ bool wd_fdc_t::is_ready() void wd_fdc_t::read_sector_start() { - if (TRACE_COMMAND) logerror("%s: read sector%s (c=%02x) t=%d, s=%d\n", tag(), command & 0x10 ? " multiple" : "", command, track, sector); + if (TRACE_COMMAND) logerror("read sector%s (c=%02x) t=%d, s=%d\n", command & 0x10 ? " multiple" : "", command, track, sector); if(!is_ready()) { command_end(); return; @@ -449,7 +449,7 @@ void wd_fdc_t::read_sector_continue() for(;;) { switch(sub_state) { case SPINUP: - if (TRACE_STATE) logerror("%s: SPINUP\n", tag()); + if (TRACE_STATE) logerror("SPINUP\n"); if(!(status & S_MON)) { spinup(); return; @@ -458,11 +458,11 @@ void wd_fdc_t::read_sector_continue() break; case SPINUP_WAIT: - if (TRACE_STATE) logerror("%s: SPINUP_WAIT\n", tag()); + if (TRACE_STATE) logerror("SPINUP_WAIT\n"); return; case SPINUP_DONE: - if (TRACE_STATE) logerror("%s: SPINUP_DONE\n", tag()); + if (TRACE_STATE) logerror("SPINUP_DONE\n"); if(command & 4) { sub_state = SETTLE_WAIT; delay_cycles(t_gen, settle_time()); @@ -473,18 +473,18 @@ void wd_fdc_t::read_sector_continue() } case SETTLE_WAIT: - if (TRACE_STATE) logerror("%s: SETTLE_WAIT\n", tag()); + if (TRACE_STATE) logerror("SETTLE_WAIT\n"); return; case SETTLE_DONE: - if (TRACE_STATE) logerror("%s: SETTLE_DONE\n", tag()); + if (TRACE_STATE) logerror("SETTLE_DONE\n"); sub_state = SCAN_ID; counter = 0; live_start(SEARCH_ADDRESS_MARK_HEADER); return; case SCAN_ID: - if (TRACE_STATE) logerror("%s: SCAN_ID\n", tag()); + if (TRACE_STATE) logerror("SCAN_ID\n"); if(!sector_matches()) { live_start(SEARCH_ADDRESS_MARK_HEADER); return; @@ -500,13 +500,13 @@ void wd_fdc_t::read_sector_continue() return; case SCAN_ID_FAILED: - if (TRACE_STATE) logerror("%s: SCAN_ID_FAILED\n", tag()); + if (TRACE_STATE) logerror("SCAN_ID_FAILED\n"); status |= S_RNF; command_end(); return; case SECTOR_READ: - if (TRACE_STATE) logerror("%s: SECTOR_READ\n", tag()); + if (TRACE_STATE) logerror("SECTOR_READ\n"); if(cur_live.crc) status |= S_CRC; @@ -520,7 +520,7 @@ void wd_fdc_t::read_sector_continue() break; default: - logerror("%s: read sector unknown sub-state %d\n", ttsn().c_str(), sub_state); + logerror("read sector unknown sub-state %d\n", ttsn().c_str(), sub_state); return; } } @@ -528,7 +528,7 @@ void wd_fdc_t::read_sector_continue() void wd_fdc_t::read_track_start() { - if (TRACE_COMMAND) logerror("%s: read track (c=%02x) t=%d\n", tag(), command, track); + if (TRACE_COMMAND) logerror("read track (c=%02x) t=%d\n", command, track); if(!is_ready()) { command_end(); @@ -550,7 +550,7 @@ void wd_fdc_t::read_track_continue() for(;;) { switch(sub_state) { case SPINUP: - if (TRACE_STATE) logerror("%s: SPINUP\n", tag()); + if (TRACE_STATE) logerror("SPINUP\n"); if(!(status & S_MON)) { spinup(); return; @@ -559,11 +559,11 @@ void wd_fdc_t::read_track_continue() break; case SPINUP_WAIT: - if (TRACE_STATE) logerror("%s: SPINUP_WAIT\n", tag()); + if (TRACE_STATE) logerror("SPINUP_WAIT\n"); return; case SPINUP_DONE: - if (TRACE_STATE) logerror("%s: SPINUP_DONE\n", tag()); + if (TRACE_STATE) logerror("SPINUP_DONE\n"); if(command & 4) { sub_state = SETTLE_WAIT; delay_cycles(t_gen, settle_time()); @@ -575,31 +575,31 @@ void wd_fdc_t::read_track_continue() } case SETTLE_WAIT: - if (TRACE_STATE) logerror("%s: SETTLE_WAIT\n", tag()); + if (TRACE_STATE) logerror("SETTLE_WAIT\n"); return; case SETTLE_DONE: - if (TRACE_STATE) logerror("%s: SETTLE_DONE\n", tag()); + if (TRACE_STATE) logerror("SETTLE_DONE\n"); sub_state = WAIT_INDEX; return; case WAIT_INDEX: - if (TRACE_STATE) logerror("%s: WAIT_INDEX\n", tag()); + if (TRACE_STATE) logerror("WAIT_INDEX\n"); return; case WAIT_INDEX_DONE: - if (TRACE_STATE) logerror("%s: WAIT_INDEX_DONE\n", tag()); + if (TRACE_STATE) logerror("WAIT_INDEX_DONE\n"); sub_state = TRACK_DONE; live_start(READ_TRACK_DATA); return; case TRACK_DONE: - if (TRACE_STATE) logerror("%s: TRACK_DONE\n", tag()); + if (TRACE_STATE) logerror("TRACK_DONE\n"); command_end(); return; default: - logerror("%s: read track unknown sub-state %d\n", ttsn().c_str(), sub_state); + logerror("read track unknown sub-state %d\n", ttsn().c_str(), sub_state); return; } } @@ -607,7 +607,7 @@ void wd_fdc_t::read_track_continue() void wd_fdc_t::read_id_start() { - if (TRACE_COMMAND) logerror("%s: read id (c=%02x)\n", tag(), command); + if (TRACE_COMMAND) logerror("read id (c=%02x)\n", command); if(!is_ready()) { command_end(); return; @@ -628,7 +628,7 @@ void wd_fdc_t::read_id_continue() for(;;) { switch(sub_state) { case SPINUP: - if (TRACE_STATE) logerror("%s: SPINUP\n", tag()); + if (TRACE_STATE) logerror("SPINUP\n"); if(!(status & S_MON)) { spinup(); return; @@ -637,11 +637,11 @@ void wd_fdc_t::read_id_continue() break; case SPINUP_WAIT: - if (TRACE_STATE) logerror("%s: SPINUP_WAIT\n", tag()); + if (TRACE_STATE) logerror("SPINUP_WAIT\n"); return; case SPINUP_DONE: - if (TRACE_STATE) logerror("%s: SPINUP_DONE\n", tag()); + if (TRACE_STATE) logerror("SPINUP_DONE\n"); if(command & 4) { sub_state = SETTLE_WAIT; delay_cycles(t_gen, settle_time()); @@ -652,29 +652,29 @@ void wd_fdc_t::read_id_continue() } case SETTLE_WAIT: - if (TRACE_STATE) logerror("%s: SETTLE_WAIT\n", tag()); + if (TRACE_STATE) logerror("SETTLE_WAIT\n"); return; case SETTLE_DONE: - if (TRACE_STATE) logerror("%s: SETTLE_DONE\n", tag()); + if (TRACE_STATE) logerror("SETTLE_DONE\n"); sub_state = SCAN_ID; counter = 0; live_start(SEARCH_ADDRESS_MARK_HEADER); return; case SCAN_ID: - if (TRACE_STATE) logerror("%s: SCAN_ID\n", tag()); + if (TRACE_STATE) logerror("SCAN_ID\n"); command_end(); return; case SCAN_ID_FAILED: - if (TRACE_STATE) logerror("%s: SCAN_ID_FAILED\n", tag()); + if (TRACE_STATE) logerror("SCAN_ID_FAILED\n"); status |= S_RNF; command_end(); return; default: - logerror("%s: read id unknown sub-state %d\n", ttsn().c_str(), sub_state); + logerror("read id unknown sub-state %d\n", ttsn().c_str(), sub_state); return; } } @@ -682,7 +682,7 @@ void wd_fdc_t::read_id_continue() void wd_fdc_t::write_track_start() { - if (TRACE_COMMAND) logerror("%s: write track (c=%02x) t=%d\n", tag(), command, track); + if (TRACE_COMMAND) logerror("write track (c=%02x) t=%d\n", command, track); if(!is_ready()) { command_end(); @@ -709,7 +709,7 @@ void wd_fdc_t::write_track_continue() for(;;) { switch(sub_state) { case SPINUP: - if (TRACE_STATE) logerror("%s: SPINUP\n", tag()); + if (TRACE_STATE) logerror("SPINUP\n"); if(!(status & S_MON)) { spinup(); return; @@ -718,11 +718,11 @@ void wd_fdc_t::write_track_continue() break; case SPINUP_WAIT: - if (TRACE_STATE) logerror("%s: SPINUP_WAIT\n", tag()); + if (TRACE_STATE) logerror("SPINUP_WAIT\n"); return; case SPINUP_DONE: - if (TRACE_STATE) logerror("%s: SPINUP_DONE\n", tag()); + if (TRACE_STATE) logerror("SPINUP_DONE\n"); if(command & 4) { sub_state = SETTLE_WAIT; delay_cycles(t_gen, settle_time()); @@ -733,22 +733,22 @@ void wd_fdc_t::write_track_continue() } case SETTLE_WAIT: - if (TRACE_STATE) logerror("%s: SETTLE_WAIT\n", tag()); + if (TRACE_STATE) logerror("SETTLE_WAIT\n"); return; case SETTLE_DONE: - if (TRACE_STATE) logerror("%s: SETTLE_DONE\n", tag()); + if (TRACE_STATE) logerror("SETTLE_DONE\n"); set_drq(); sub_state = DATA_LOAD_WAIT; delay_cycles(t_gen, 192); return; case DATA_LOAD_WAIT: - if (TRACE_STATE) logerror("%s: DATA_LOAD_WAIT\n", tag()); + if (TRACE_STATE) logerror("DATA_LOAD_WAIT\n"); return; case DATA_LOAD_WAIT_DONE: - if (TRACE_STATE) logerror("%s: DATA_LOAD_WAIT_DONE\n", tag()); + if (TRACE_STATE) logerror("DATA_LOAD_WAIT_DONE\n"); if(drq) { status |= S_LOST; drop_drq(); @@ -759,18 +759,18 @@ void wd_fdc_t::write_track_continue() break; case WAIT_INDEX: - if (TRACE_STATE) logerror("%s: WAIT_INDEX\n", tag()); + if (TRACE_STATE) logerror("WAIT_INDEX\n"); return; case WAIT_INDEX_DONE: - if (TRACE_STATE) logerror("%s: WAIT_INDEX_DONE\n", tag()); + if (TRACE_STATE) logerror("WAIT_INDEX_DONE\n"); sub_state = TRACK_DONE; live_start(WRITE_TRACK_DATA); pll_start_writing(machine().time()); return; case TRACK_DONE: - if (TRACE_STATE) logerror("%s: TRACK_DONE\n", tag()); + if (TRACE_STATE) logerror("TRACK_DONE\n"); if(format_last_byte_count) { char buf[32]; if(format_last_byte_count > 1) @@ -779,12 +779,12 @@ void wd_fdc_t::write_track_continue() sprintf(buf, "%02x", format_last_byte); format_description_string += buf; } - if (TRACE_DESC) logerror("%s: track description %s\n", tag(), format_description_string.c_str()); + if (TRACE_DESC) logerror("track description %s\n", format_description_string.c_str()); command_end(); return; default: - logerror("%s: write track unknown sub-state %d\n", ttsn().c_str(), sub_state); + logerror("write track unknown sub-state %d\n", ttsn().c_str(), sub_state); return; } } @@ -793,7 +793,7 @@ void wd_fdc_t::write_track_continue() void wd_fdc_t::write_sector_start() { - if (TRACE_COMMAND) logerror("%s: write sector%s (c=%02x) t=%d, s=%d\n", tag(), command & 0x10 ? " multiple" : "", command, track, sector); + if (TRACE_COMMAND) logerror("write sector%s (c=%02x) t=%d, s=%d\n", command & 0x10 ? " multiple" : "", command, track, sector); if(!is_ready()) { command_end(); @@ -815,7 +815,7 @@ void wd_fdc_t::write_sector_continue() for(;;) { switch(sub_state) { case SPINUP: - if (TRACE_STATE) logerror("%s: SPINUP\n", tag()); + if (TRACE_STATE) logerror("SPINUP\n"); if(!(status & S_MON)) { spinup(); return; @@ -824,11 +824,11 @@ void wd_fdc_t::write_sector_continue() break; case SPINUP_WAIT: - if (TRACE_STATE) logerror("%s: SPINUP_WAIT\n", tag()); + if (TRACE_STATE) logerror("SPINUP_WAIT\n"); return; case SPINUP_DONE: - if (TRACE_STATE) logerror("%s: SPINUP_DONE\n", tag()); + if (TRACE_STATE) logerror("SPINUP_DONE\n"); if(command & 4) { sub_state = SETTLE_WAIT; delay_cycles(t_gen, settle_time()); @@ -839,18 +839,18 @@ void wd_fdc_t::write_sector_continue() } case SETTLE_WAIT: - if (TRACE_STATE) logerror("%s: SETTLE_WAIT\n", tag()); + if (TRACE_STATE) logerror("SETTLE_WAIT\n"); return; case SETTLE_DONE: - if (TRACE_STATE) logerror("%s: SETTLE_DONE\n", tag()); + if (TRACE_STATE) logerror("SETTLE_DONE\n"); sub_state = SCAN_ID; counter = 0; live_start(SEARCH_ADDRESS_MARK_HEADER); return; case SCAN_ID: - if (TRACE_STATE) logerror("%s: SCAN_ID\n", tag()); + if (TRACE_STATE) logerror("SCAN_ID\n"); if(!sector_matches()) { live_start(SEARCH_ADDRESS_MARK_HEADER); return; @@ -866,13 +866,13 @@ void wd_fdc_t::write_sector_continue() return; case SCAN_ID_FAILED: - if (TRACE_STATE) logerror("%s: SCAN_ID_FAILED\n", tag()); + if (TRACE_STATE) logerror("SCAN_ID_FAILED\n"); status |= S_RNF; command_end(); return; case SECTOR_WRITE: - if (TRACE_STATE) logerror("%s: SECTOR_WRITE\n", tag()); + if (TRACE_STATE) logerror("SECTOR_WRITE\n"); if(command & 0x10) { sector++; sub_state = SPINUP_DONE; @@ -883,7 +883,7 @@ void wd_fdc_t::write_sector_continue() break; default: - logerror("%s: write sector unknown sub-state %d\n", ttsn().c_str(), sub_state); + logerror("write sector unknown sub-state %d\n", ttsn().c_str(), sub_state); return; } } @@ -891,7 +891,7 @@ void wd_fdc_t::write_sector_continue() void wd_fdc_t::interrupt_start() { - if (TRACE_COMMAND) logerror("%s: Forced interrupt (c=%02x)\n", tag(), command); + if (TRACE_COMMAND) logerror("Forced interrupt (c=%02x)\n", command); if(status & S_BUSY) { main_state = sub_state = cur_live.state = IDLE; @@ -990,6 +990,11 @@ void wd_fdc_t::do_generic() sub_state = DATA_LOAD_WAIT_DONE; break; + case INITIAL_RESTORE: + last_dir = 1; + seek_start(RESTORE); + break; + default: if(cur_live.tm.is_never()) logerror("%s: do_generic on unknown sub-state %d\n", ttsn().c_str(), sub_state); @@ -1055,7 +1060,7 @@ void wd_fdc_t::do_cmd_w() void wd_fdc_t::cmd_w(UINT8 val) { - if (TRACE_COMP) logerror("%s: Initiating command %02x\n", tag(), val); + if (TRACE_COMP) logerror("Initiating command %02x\n", val); if (inverted_bus) val ^= 0xff; if(intrq && !(intrq_cond & I_IMM)) { @@ -1492,7 +1497,7 @@ bool wd_fdc_t::write_one_bit(const attotime &limit) void wd_fdc_t::live_write_raw(UINT16 raw) { - if (TRACE_WRITE) logerror("%s: write raw %04x, CRC=%04x\n", tag(), raw, cur_live.crc); + if (TRACE_WRITE) logerror("write raw %04x, CRC=%04x\n", raw, cur_live.crc); cur_live.shift_reg = raw; cur_live.data_bit_context = raw & 1; } @@ -1511,7 +1516,7 @@ void wd_fdc_t::live_write_mfm(UINT8 mfm) } cur_live.shift_reg = raw; cur_live.data_bit_context = context; - if (TRACE_WRITE) logerror("%s: live_write_mfm byte=%02x, raw=%04x, CRC=%04x\n", tag(), mfm, raw, cur_live.crc); + if (TRACE_WRITE) logerror("live_write_mfm byte=%02x, raw=%04x, CRC=%04x\n", mfm, raw, cur_live.crc); } @@ -1524,7 +1529,7 @@ void wd_fdc_t::live_write_fm(UINT8 fm) cur_live.data_reg = fm; cur_live.shift_reg = raw; cur_live.data_bit_context = fm & 1; - if (TRACE_WRITE) logerror("%s: live_write_fm byte=%02x, raw=%04x, CRC=%04x\n", tag(), fm, raw, cur_live.crc); + if (TRACE_WRITE) logerror("live_write_fm byte=%02x, raw=%04x, CRC=%04x\n", fm, raw, cur_live.crc); } void wd_fdc_t::live_run(attotime limit) diff --git a/src/devices/machine/wd_fdc.h b/src/devices/machine/wd_fdc.h index 4abc761e74b..8aab3309264 100644 --- a/src/devices/machine/wd_fdc.h +++ b/src/devices/machine/wd_fdc.h @@ -275,7 +275,7 @@ private: WRITE_TRACK, WRITE_SECTOR, - // Sub states + // Sub states, plus the reset-time restore request SPINUP, SPINUP_WAIT, @@ -304,6 +304,8 @@ private: SECTOR_WRITE, TRACK_DONE, + INITIAL_RESTORE, + // Live states SEARCH_ADDRESS_MARK_HEADER, diff --git a/src/devices/machine/z80ctc.cpp b/src/devices/machine/z80ctc.cpp index 276254d96f1..a6cb090e30b 100644 --- a/src/devices/machine/z80ctc.cpp +++ b/src/devices/machine/z80ctc.cpp @@ -303,7 +303,7 @@ void z80ctc_device::ctc_channel::start(z80ctc_device *device, int index) // initialize state m_device = device; m_index = index; - m_timer = m_device->machine().scheduler().timer_alloc(FUNC(static_timer_callback), this); + m_timer = m_device->machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(z80ctc_device::ctc_channel::timer_callback), this)); // register for save states m_device->save_item(NAME(m_mode), m_index); @@ -478,7 +478,7 @@ void z80ctc_device::ctc_channel::trigger(UINT8 data) { // if we hit zero, do the same thing as for a timer interrupt if (--m_down == 0) - timer_callback(); + timer_callback(nullptr,0); } } } @@ -490,7 +490,7 @@ void z80ctc_device::ctc_channel::trigger(UINT8 data) // side-effects //------------------------------------------------- -void z80ctc_device::ctc_channel::timer_callback() +TIMER_CALLBACK_MEMBER(z80ctc_device::ctc_channel::timer_callback) { // down counter has reached zero - see if we should interrupt if ((m_mode & INTERRUPT) == INTERRUPT_ON) diff --git a/src/devices/machine/z80ctc.h b/src/devices/machine/z80ctc.h index 2c3002e1166..a144ff013d4 100644 --- a/src/devices/machine/z80ctc.h +++ b/src/devices/machine/z80ctc.h @@ -103,7 +103,7 @@ private: attotime period() const; void trigger(UINT8 data); - void timer_callback(); + TIMER_CALLBACK_MEMBER(timer_callback); z80ctc_device * m_device; // pointer back to our device int m_index; // our channel index @@ -113,9 +113,6 @@ private: UINT8 m_extclk; // current signal from the external clock emu_timer * m_timer; // array of active timers UINT8 m_int_state; // interrupt status (for daisy chain) - - private: - static TIMER_CALLBACK( static_timer_callback ) { reinterpret_cast<z80ctc_device::ctc_channel *>(ptr)->timer_callback(); } }; // internal state diff --git a/src/devices/machine/z80dma.cpp b/src/devices/machine/z80dma.cpp index c1f3162bebd..bf5c4585234 100644 --- a/src/devices/machine/z80dma.cpp +++ b/src/devices/machine/z80dma.cpp @@ -176,7 +176,7 @@ void z80dma_device::device_start() m_out_iorq_cb.resolve_safe(); // allocate timer - m_timer = machine().scheduler().timer_alloc(FUNC(static_timerproc), (void *)this); + m_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(z80dma_device::timerproc), this)); // register for state saving save_item(NAME(m_regs)); @@ -488,7 +488,7 @@ int z80dma_device::do_write() // timerproc //------------------------------------------------- -void z80dma_device::timerproc() +TIMER_CALLBACK_MEMBER(z80dma_device::timerproc) { int done; @@ -837,10 +837,10 @@ void z80dma_device::write(UINT8 data) // rdy_write_callback - deferred RDY signal write //------------------------------------------------- -void z80dma_device::rdy_write_callback(int state) +TIMER_CALLBACK_MEMBER(z80dma_device::rdy_write_callback) { // normalize state - m_rdy = state; + m_rdy = param; m_status = (m_status & 0xFD) | (!is_ready() << 1); update_status(); @@ -859,7 +859,7 @@ void z80dma_device::rdy_write_callback(int state) WRITE_LINE_MEMBER(z80dma_device::rdy_w) { if (LOG) logerror("Z80DMA '%s' RDY: %d Active High: %d\n", tag(), state, READY_ACTIVE_HIGH); - machine().scheduler().synchronize(FUNC(static_rdy_write_callback), state, (void *)this); + machine().scheduler().synchronize(timer_expired_delegate(FUNC(z80dma_device::rdy_write_callback),this), state); } diff --git a/src/devices/machine/z80dma.h b/src/devices/machine/z80dma.h index fc1c3c1175c..0b1916c5d5f 100644 --- a/src/devices/machine/z80dma.h +++ b/src/devices/machine/z80dma.h @@ -111,13 +111,11 @@ private: void do_transfer_write(); void do_search(); - static TIMER_CALLBACK( static_timerproc ) { reinterpret_cast<z80dma_device *>(ptr)->timerproc(); } - void timerproc(); + TIMER_CALLBACK_MEMBER(timerproc); void update_status(); - static TIMER_CALLBACK( static_rdy_write_callback ) { reinterpret_cast<z80dma_device *>(ptr)->rdy_write_callback(param); } - void rdy_write_callback(int state); + TIMER_CALLBACK_MEMBER(rdy_write_callback); // internal state devcb_write_line m_out_busreq_cb; |