From f624c52cef438f7e839c7de6ab5bdf474eb3a6e2 Mon Sep 17 00:00:00 2001 From: fulivi Date: Mon, 30 Mar 2015 17:58:51 +0200 Subject: [PATCH 1/7] imds2: improved keyboard mapping --- src/mess/drivers/imds2.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/mess/drivers/imds2.c b/src/mess/drivers/imds2.c index 89de9892f3b..d225849497e 100644 --- a/src/mess/drivers/imds2.c +++ b/src/mess/drivers/imds2.c @@ -543,13 +543,13 @@ static INPUT_PORTS_START(imds2) // See [1], pg 57 for keyboard layout PORT_START("KEY0") PORT_BIT(0x01 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_TAB) PORT_CHAR('\t') // OK - PORT_BIT(0x02 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('@') PORT_CHAR('`') + PORT_BIT(0x02 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_COLON) PORT_CHAR('@') PORT_CHAR('`') // OK PORT_BIT(0x04 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<') // OK PORT_BIT(0x08 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13) // OK - PORT_BIT(0x10 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') - PORT_BIT(0x20 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR(':') PORT_CHAR('*') // ' - PORT_BIT(0x40 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>') // . - PORT_BIT(0x80 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?') + PORT_BIT(0x10 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') // OK + PORT_BIT(0x20 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR(':') PORT_CHAR('*') // OK + PORT_BIT(0x40 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>') // OK + PORT_BIT(0x80 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?') // OK PORT_START("KEY1") PORT_BIT(0x01 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_Z) PORT_CHAR('z') PORT_CHAR('Z') // OK @@ -563,13 +563,13 @@ static INPUT_PORTS_START(imds2) PORT_START("KEY2") PORT_BIT(0x01 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_0) PORT_CHAR('0') PORT_CHAR('~') // OK - PORT_BIT(0x02 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[') PORT_CHAR('{') + PORT_BIT(0x02 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[') PORT_CHAR('{') // OK PORT_BIT(0x04 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_O) PORT_CHAR('o') PORT_CHAR('O') // OK PORT_BIT(0x08 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_L) PORT_CHAR('l') PORT_CHAR('L') // OK PORT_BIT(0x10 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR(')') // OK PORT_BIT(0x20 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('=') // OK PORT_BIT(0x40 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_P) PORT_CHAR('p') PORT_CHAR('P') // OK - PORT_BIT(0x80 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR('+') + PORT_BIT(0x80 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR(';') PORT_CHAR('+') // OK PORT_START("KEY3") PORT_BIT(0x01 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_S) PORT_CHAR('s') PORT_CHAR('S') // OK @@ -604,17 +604,17 @@ static INPUT_PORTS_START(imds2) PORT_START("KEY6") PORT_BIT(0x01 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8) // BS PORT_BIT(0x02 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_HOME) PORT_CHAR(UCHAR_MAMEKEY(HOME)) // OK - PORT_BIT(0x04 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\') PORT_CHAR('|') // OK + PORT_BIT(0x04 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('\\') PORT_CHAR('|') // OK PORT_BIT(0x08 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT)) // OK PORT_BIT(0x10 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_LCONTROL) PORT_CHAR(UCHAR_SHIFT_2) // OK PORT_BIT(0x20 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT)) // OK - PORT_BIT(0x40 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(']') PORT_CHAR('}') + PORT_BIT(0x40 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(']') PORT_CHAR('}') // OK PORT_BIT(0x80 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP)) // OK PORT_START("KEY7") PORT_BIT(0x01 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC)) // OK PORT_BIT(0x02 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN)) // OK - PORT_BIT(0x04 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('_') PORT_CHAR('^') + PORT_BIT(0x04 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('_') PORT_CHAR('^') // OK PORT_BIT(0x08 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_LSHIFT) PORT_CHAR(UCHAR_SHIFT_1) // OK PORT_BIT(0x10 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_LALT) PORT_CHAR(UCHAR_MAMEKEY(LALT)) // OK PORT_BIT(0x20 , IP_ACTIVE_LOW , IPT_KEYBOARD) PORT_CODE(KEYCODE_CAPSLOCK) PORT_TOGGLE PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK)) From d0ad3fd6374e9b6c5986b27e2cb42d0f7a0f0510 Mon Sep 17 00:00:00 2001 From: fulivi Date: Mon, 30 Mar 2015 18:01:15 +0200 Subject: [PATCH 2/7] pic8259: fixed a polling mode bug --- src/emu/machine/pic8259.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/emu/machine/pic8259.c b/src/emu/machine/pic8259.c index 6d404d654c5..d86b25dd30c 100644 --- a/src/emu/machine/pic8259.c +++ b/src/emu/machine/pic8259.c @@ -152,11 +152,6 @@ READ8_MEMBER( pic8259_device::read ) if ( m_ocw3 & 0x04 ) { /* Polling mode */ - if ( m_isr & ~m_imr ) - { - acknowledge(); - } - if ( m_irr & ~m_imr ) { /* check the various IRQs */ @@ -168,6 +163,7 @@ READ8_MEMBER( pic8259_device::read ) break; } } + acknowledge(); } } else From fede14aa974c70537c81824a50ce6d10ebef75fc Mon Sep 17 00:00:00 2001 From: fulivi Date: Wed, 1 Apr 2015 16:09:45 +0200 Subject: [PATCH 3/7] i8275: improved visual attribute decoding and cursor appearance --- src/emu/video/i8275.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/emu/video/i8275.c b/src/emu/video/i8275.c index 53218f2cc4b..cf7b5d022ea 100644 --- a/src/emu/video/i8275.c +++ b/src/emu/video/i8275.c @@ -309,13 +309,14 @@ void i8275_device::device_timer(emu_timer &timer, device_timer_id id, int param, m_vsp = (m_stored_attr & FAC_B) ? 1 : 0; m_gpa = (m_stored_attr & FAC_GG) >> 2; m_rvv = (m_stored_attr & FAC_R) ? 1 : 0; - m_lten = (m_stored_attr & FAC_U) ? 1 : 0; + m_lten = ((m_stored_attr & FAC_U) != 0) && (lc == UNDERLINE) ? 1 : 0; for (int sx = 0; sx < CHARACTERS_PER_ROW; sx++) { int m_lineattr = 0; int lten = 0; int vsp = 0; + int rvv = 0; UINT8 data = m_buffer[!m_buffer_dma][sx]; @@ -328,7 +329,7 @@ void i8275_device::device_timer(emu_timer &timer, device_timer_id id, int param, m_vsp = (data & FAC_B) ? 1 : 0; m_gpa = (data & FAC_GG) >> 2; m_rvv = (data & FAC_R) ? 1 : 0; - m_lten = (data & FAC_U) ? 1 : 0; + m_lten = ((data & FAC_U) != 0) && (lc == UNDERLINE) ? 1 : 0; if ((SCANLINES_PER_ROW - lc)==1) m_stored_attr = data; @@ -412,7 +413,7 @@ void i8275_device::device_timer(emu_timer &timer, device_timer_id id, int param, } else { - lten = vis; + rvv = vis; } } @@ -429,7 +430,7 @@ void i8275_device::device_timer(emu_timer &timer, device_timer_id id, int param, (data & 0x7f), // char code to be displayed m_lineattr, // line attribute code lten | m_lten, // light enable signal - m_rvv, // reverse video signal + rvv ^ m_rvv, // reverse video signal vsp, // video suppression m_gpa, // general purpose attribute code m_hlgt // highlight From 4945071946213c6d62aeaaa6fe0e7d7391141778 Mon Sep 17 00:00:00 2001 From: fulivi Date: Wed, 1 Apr 2015 16:10:30 +0200 Subject: [PATCH 4/7] Implemented disk writing for IMD format --- src/lib/formats/imd_dsk.c | 94 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 90 insertions(+), 4 deletions(-) diff --git a/src/lib/formats/imd_dsk.c b/src/lib/formats/imd_dsk.c index 78f073fef1d..c6ad412eaa3 100644 --- a/src/lib/formats/imd_dsk.c +++ b/src/lib/formats/imd_dsk.c @@ -135,6 +135,91 @@ static floperr_t imd_read_indexed_sector(floppy_image_legacy *floppy, int head, return internal_imd_read_sector(floppy, head, track, sector, TRUE, buffer, buflen); } +static floperr_t imd_expand_file(floppy_image_legacy *floppy , UINT64 offset , size_t amount) +{ + if (amount == 0) { + return FLOPPY_ERROR_SUCCESS; + } + + UINT64 file_size = floppy_image_size(floppy); + + if (offset > file_size) { + return FLOPPY_ERROR_INTERNAL; + } + + UINT64 size_after_off = file_size - offset; + + if (size_after_off == 0) { + return FLOPPY_ERROR_SUCCESS; + } + + UINT8 *buffer = global_alloc_array(UINT8 , size_after_off); + + // Read the part of file after offset + floppy_image_read(floppy , buffer , offset , size_after_off); + + // Add zeroes + floppy_image_write_filler(floppy , 0 , offset , amount); + + // Write back the part of file after offset + floppy_image_write(floppy, buffer, offset + amount, size_after_off); + + global_free_array(buffer); + + // Update track offsets + struct imddsk_tag *tag = get_tag(floppy); + for (int track = 0; track < tag->tracks; track++) { + for (int head = 0; head < tag->heads; head++) { + UINT64 *track_off = &(tag->track_offsets[ (track << 1) + head ]); + if (*track_off >= offset) { + *track_off += amount; + } + } + } + + return FLOPPY_ERROR_SUCCESS; +} + +static floperr_t imd_write_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector_index, const void *buffer, size_t buflen, int ddam) +{ + UINT64 offset; + floperr_t err; + UINT8 header[1]; + + // take sector offset + err = get_offset(floppy, head, track, sector_index, TRUE, &offset); + if (err) + return err; + + floppy_image_read(floppy, header, offset, 1); + + switch (header[ 0 ]) { + case 0: + return FLOPPY_ERROR_SEEKERROR; + + default: + // Expand image file (from 1 byte to a whole sector) + err = imd_expand_file(floppy , offset , buflen - 1); + if (err) { + return err; + } + // Fall through! + + case 1: + case 3: + case 5: + case 7: + // Turn every kind of sector into type 1 (normal data) + header[ 0 ] = 1; + floppy_image_write(floppy, header, offset, 1); + // Write sector + floppy_image_write(floppy, buffer, offset + 1, buflen); + break; + } + + return FLOPPY_ERROR_SUCCESS; +} + static floperr_t imd_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length) { floperr_t err; @@ -266,6 +351,7 @@ FLOPPY_CONSTRUCT( imd_dsk_construct ) callbacks = floppy_callbacks(floppy); callbacks->read_sector = imd_read_sector; callbacks->read_indexed_sector = imd_read_indexed_sector; + callbacks->write_indexed_sector = imd_write_indexed_sector; callbacks->get_sector_length = imd_get_sector_length; callbacks->get_heads_per_disk = imd_get_heads_per_disk; callbacks->get_tracks_per_disk = imd_get_tracks_per_disk; @@ -380,10 +466,10 @@ bool imd_format::load(io_generic *io, UINT32 form_factor, floppy_image *image) for(int i=0; i 8) { From 5f5b432cc6ac16ce066f8cd4960162ff1db1b560 Mon Sep 17 00:00:00 2001 From: fulivi Date: Thu, 9 Apr 2015 12:22:11 +0200 Subject: [PATCH 5/7] imds2: PIO added, seems OK --- src/mess/drivers/imds2.c | 54 ++++++++++++++++++++++++++++++++++++--- src/mess/includes/imds2.h | 12 +++++++++ 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/src/mess/drivers/imds2.c b/src/mess/drivers/imds2.c index d225849497e..a711a519a72 100644 --- a/src/mess/drivers/imds2.c +++ b/src/mess/drivers/imds2.c @@ -63,7 +63,6 @@ // ICs that are not emulated yet are marked with "*" // // TODO: -// - Improve keyboard mapping // - Emulate PIO. No known dumps of its ROM are available, though. // - Emulate line printer output on PIO // - Emulate serial channels on IPC @@ -101,6 +100,9 @@ // FDC oscillator of IOC board: 8 MHz #define IOC_XTAL_Y1 XTAL_8MHz +// PIO oscillator: 6 MHz +#define IOC_XTAL_Y3 XTAL_6MHz + // Frequency of beeper #define IOC_BEEP_FREQ 3300 @@ -112,12 +114,13 @@ static ADDRESS_MAP_START(ipc_io_map , AS_IO , 8 , imds2_state) ADDRESS_MAP_UNMAP_LOW AM_RANGE(0xc0 , 0xc0) AM_READWRITE(imds2_ipc_dbbout_r , imds2_ipc_dbbin_data_w) AM_RANGE(0xc1 , 0xc1) AM_READWRITE(imds2_ipc_status_r , imds2_ipc_dbbin_cmd_w) + AM_RANGE(0xf8 , 0xf9) AM_DEVREADWRITE("iocpio" , i8041_device , upi41_master_r , upi41_master_w) AM_RANGE(0xfa , 0xfb) AM_READWRITE(imds2_ipclocpic_r , imds2_ipclocpic_w) AM_RANGE(0xfc , 0xfd) AM_READWRITE(imds2_ipcsyspic_r , imds2_ipcsyspic_w) AM_RANGE(0xff , 0xff) AM_WRITE(imds2_ipc_control_w) ADDRESS_MAP_END - static ADDRESS_MAP_START(ioc_mem_map , AS_PROGRAM , 8 , imds2_state) +static ADDRESS_MAP_START(ioc_mem_map , AS_PROGRAM , 8 , imds2_state) ADDRESS_MAP_UNMAP_HIGH AM_RANGE(0x0000 , 0x1fff) AM_ROM AM_RANGE(0x4000 , 0x5fff) AM_RAM @@ -143,6 +146,11 @@ static ADDRESS_MAP_START(ioc_io_map , AS_IO , 8 , imds2_state) AM_RANGE(0xf0 , 0xf8) AM_DEVREADWRITE("iocdma" , i8257_device , read , write) ADDRESS_MAP_END +static ADDRESS_MAP_START(pio_io_map , AS_IO , 8 , imds2_state) + AM_RANGE(MCS48_PORT_P1 , MCS48_PORT_P1) AM_READWRITE(imds2_pio_port_p1_r , imds2_pio_port_p1_w) + AM_RANGE(MCS48_PORT_P2 , MCS48_PORT_P2) AM_READWRITE(imds2_pio_port_p2_r , imds2_pio_port_p2_w) +ADDRESS_MAP_END + static ADDRESS_MAP_START(kb_io_map , AS_IO , 8 , imds2_state) AM_RANGE(MCS48_PORT_P1 , MCS48_PORT_P1) AM_WRITE(imds2_kb_port_p1_w) AM_RANGE(MCS48_PORT_P2 , MCS48_PORT_P2) AM_READ(imds2_kb_port_p2_r) @@ -161,6 +169,7 @@ imds2_state::imds2_state(const machine_config &mconfig, device_type type, const m_iocbeep(*this , "iocbeep"), m_ioctimer(*this , "ioctimer"), m_iocfdc(*this , "iocfdc"), + m_iocpio(*this , "iocpio"), m_kbcpu(*this , "kbcpu"), m_palette(*this , "palette"), m_gfxdecode(*this, "gfxdecode"), @@ -370,7 +379,7 @@ WRITE8_MEMBER(imds2_state::imds2_ioc_reset_f1_w) READ8_MEMBER(imds2_state::imds2_ioc_status_r) { - return (~m_ipc_ioc_status & 0x0f) | 0xf0; + return ~m_ipc_ioc_status; } READ8_MEMBER(imds2_state::imds2_ioc_dbbin_r) @@ -428,6 +437,31 @@ WRITE8_MEMBER(imds2_state::imds2_ioc_mem_w) return prog_space.write_byte(offset , data); } +READ8_MEMBER(imds2_state::imds2_pio_port_p1_r) +{ + // TODO + return 0; +} + +WRITE8_MEMBER(imds2_state::imds2_pio_port_p1_w) +{ + m_pio_port1 = data; + imds2_update_printer(); +} + +READ8_MEMBER(imds2_state::imds2_pio_port_p2_r) +{ + return m_pio_port2; +} + +WRITE8_MEMBER(imds2_state::imds2_pio_port_p2_w) +{ + m_pio_port2 = data; + imds2_update_printer(); + // Send INTR to IPC + m_ipclocpic->ir5_w(BIT(data , 7)); +} + I8275_DRAW_CHARACTER_MEMBER(imds2_state::crtc_display_pixels) { unsigned i; @@ -538,6 +572,11 @@ void imds2_state::imds2_update_beeper(void) m_iocbeep->set_state(m_beeper_timer == 0 && BIT(m_miscout , 0) == 0); } +void imds2_state::imds2_update_printer(void) +{ + // TODO +} + static INPUT_PORTS_START(imds2) // See [1], pg 56 for key matrix layout // See [1], pg 57 for keyboard layout @@ -727,6 +766,10 @@ static MACHINE_CONFIG_START(imds2 , imds2_state) MCFG_LEGACY_FLOPPY_DRIVE_ADD(FLOPPY_0, imds2_floppy_interface) + MCFG_CPU_ADD("iocpio" , I8041 , IOC_XTAL_Y3) + MCFG_CPU_IO_MAP(pio_io_map) + MCFG_QUANTUM_TIME(attotime::from_hz(100)) + MCFG_CPU_ADD("kbcpu", I8741, XTAL_3_579545MHz) /* 3.579545 MHz */ MCFG_CPU_IO_MAP(kb_io_map) MCFG_QUANTUM_TIME(attotime::from_hz(100)) @@ -743,6 +786,11 @@ ROM_START(imds2) ROM_LOAD("ioc_a51.bin" , 0x0800 , 0x0800 , CRC(6aa2f86c) SHA1(d3a5314d86e3366545b4c97b29e323dfab383d5f)) ROM_LOAD("ioc_a52.bin" , 0x1000 , 0x0800 , CRC(b88a38d5) SHA1(934716a1daec852f4d1f846510f42408df0c9584)) ROM_LOAD("ioc_a53.bin" , 0x1800 , 0x0800 , CRC(c8df4bb9) SHA1(2dfb921e94ae7033a7182457b2f00657674d1b77)) + + // ROM definition of PIO controller (8041A) + ROM_REGION(0x400 , "iocpio" , 0) + ROM_LOAD("pio_a72.bin" , 0 , 0x400 , CRC(c1eabf25)) + // ROM definition of keyboard controller (8741) ROM_REGION(0x400 , "kbcpu" , 0) ROM_LOAD("kbd511.bin" , 0 , 0x400 , CRC(ba7c4303) SHA1(19899af732d0ae1247bfc79979b1ee5f339ee5cf)) diff --git a/src/mess/includes/imds2.h b/src/mess/includes/imds2.h index 5fb1b513ecf..144445c2e6b 100644 --- a/src/mess/includes/imds2.h +++ b/src/mess/includes/imds2.h @@ -53,6 +53,10 @@ class imds2_state : public driver_device DECLARE_READ8_MEMBER(imds2_ioc_mem_r); DECLARE_WRITE8_MEMBER(imds2_ioc_mem_w); + DECLARE_READ8_MEMBER(imds2_pio_port_p1_r); + DECLARE_WRITE8_MEMBER(imds2_pio_port_p1_w); + DECLARE_READ8_MEMBER(imds2_pio_port_p2_r); + DECLARE_WRITE8_MEMBER(imds2_pio_port_p2_w); I8275_DRAW_CHARACTER_MEMBER(crtc_display_pixels); @@ -71,6 +75,7 @@ class imds2_state : public driver_device required_device m_iocbeep; required_device m_ioctimer; required_device m_iocfdc; + required_device m_iocpio; required_device m_kbcpu; required_device m_palette; required_device m_gfxdecode; @@ -90,6 +95,7 @@ class imds2_state : public driver_device bool imds2_in_ipc_rom(offs_t offset) const; void imds2_update_beeper(void); + void imds2_update_printer(void); // IPC control port UINT8 m_ipc_control; @@ -117,6 +123,12 @@ class imds2_state : public driver_device // IPC/IOC status UINT8 m_ipc_ioc_status; + + // PIO port 1 + UINT8 m_pio_port1; + + // PIO port 2 + UINT8 m_pio_port2; }; #endif /* _IMDS2_H_ */ From a7402d0c963c47a142dea4691139b68d0253bedf Mon Sep 17 00:00:00 2001 From: fulivi Date: Fri, 10 Apr 2015 18:27:44 +0200 Subject: [PATCH 6/7] imds2: printer output completed, seems OK --- src/mess/drivers/imds2.c | 101 +++++++++++++++++++++++++++++--------- src/mess/includes/imds2.h | 20 +++++--- 2 files changed, 91 insertions(+), 30 deletions(-) diff --git a/src/mess/drivers/imds2.c b/src/mess/drivers/imds2.c index a711a519a72..746d900dfc1 100644 --- a/src/mess/drivers/imds2.c +++ b/src/mess/drivers/imds2.c @@ -35,7 +35,7 @@ // // This board acts as a controller for all I/O of the system. // It is structured as if it were 2 boards in one: -// One part (around 8080) controls Keyboard, CRT & floppy, the other part (around PIO 8741) controls all parallel I/Os +// One part (around 8080) controls Keyboard, CRT & floppy, the other part (around PIO 8041A) controls all parallel I/Os // (Line printer, Paper tape puncher, Paper tape reader, I/O to PROM programmer). // Both parts are interfaced to IPC through a bidirectional 8-bit bus. // IOC is composed of these parts: @@ -51,7 +51,7 @@ // A20 8275 CRT controller // A19 2708 Character generator ROM // LS1 3.3 kHz beeper -//*A72 8741-4 CPU @ 6 MHz (PIO: parallel I/O) +// A72 8041A CPU @ 6 MHz (PIO: parallel I/O) // // ********** // Keyboard controller @@ -63,8 +63,6 @@ // ICs that are not emulated yet are marked with "*" // // TODO: -// - Emulate PIO. No known dumps of its ROM are available, though. -// - Emulate line printer output on PIO // - Emulate serial channels on IPC // - Emulate PIT on IPC // - Adjust speed of processors. Wait states are not accounted for yet. @@ -86,8 +84,6 @@ // should be mounted and the system reset. After a few seconds the ISIS-II // prompt should appear. A command that could be tried is "DIR" that lists // the content of floppy disk. -// Please note that the message "FAILURE -- PIO NOT RESPONDING" is normal -// as the support for PIO isn't implemented yet #include "includes/imds2.h" @@ -114,7 +110,7 @@ static ADDRESS_MAP_START(ipc_io_map , AS_IO , 8 , imds2_state) ADDRESS_MAP_UNMAP_LOW AM_RANGE(0xc0 , 0xc0) AM_READWRITE(imds2_ipc_dbbout_r , imds2_ipc_dbbin_data_w) AM_RANGE(0xc1 , 0xc1) AM_READWRITE(imds2_ipc_status_r , imds2_ipc_dbbin_cmd_w) - AM_RANGE(0xf8 , 0xf9) AM_DEVREADWRITE("iocpio" , i8041_device , upi41_master_r , upi41_master_w) + AM_RANGE(0xf8 , 0xf9) AM_DEVREADWRITE("iocpio" , i8041_device , upi41_master_r , upi41_master_w) AM_RANGE(0xfa , 0xfb) AM_READWRITE(imds2_ipclocpic_r , imds2_ipclocpic_w) AM_RANGE(0xfc , 0xfd) AM_READWRITE(imds2_ipcsyspic_r , imds2_ipcsyspic_w) AM_RANGE(0xff , 0xff) AM_WRITE(imds2_ipc_control_w) @@ -169,11 +165,12 @@ imds2_state::imds2_state(const machine_config &mconfig, device_type type, const m_iocbeep(*this , "iocbeep"), m_ioctimer(*this , "ioctimer"), m_iocfdc(*this , "iocfdc"), - m_iocpio(*this , "iocpio"), + m_iocpio(*this , "iocpio"), m_kbcpu(*this , "kbcpu"), m_palette(*this , "palette"), m_gfxdecode(*this, "gfxdecode"), m_floppy0(*this , FLOPPY_0), + m_centronics(*this , "centronics"), m_io_key0(*this , "KEY0"), m_io_key1(*this , "KEY1"), m_io_key2(*this , "KEY2"), @@ -182,7 +179,8 @@ imds2_state::imds2_state(const machine_config &mconfig, device_type type, const m_io_key5(*this , "KEY5"), m_io_key6(*this , "KEY6"), m_io_key7(*this , "KEY7"), - m_ioc_options(*this , "IOC_OPTS") + m_ioc_options(*this , "IOC_OPTS"), + m_device_status_byte(0xff) { } @@ -439,29 +437,62 @@ WRITE8_MEMBER(imds2_state::imds2_ioc_mem_w) READ8_MEMBER(imds2_state::imds2_pio_port_p1_r) { - // TODO - return 0; + // If STATUS ENABLE/ == 0 return inverted device status byte, else return 0xff + // STATUS ENABLE/ == 0 when P23-P20 == 12 & P24 == 0 & P25 = 1 & P26 = 1 + if ((m_pio_port2 & 0x7f) == 0x6c) { + return ~m_device_status_byte; + } else { + return 0xff; +} } WRITE8_MEMBER(imds2_state::imds2_pio_port_p1_w) { - m_pio_port1 = data; - imds2_update_printer(); + m_pio_port1 = data; + imds2_update_printer(); } READ8_MEMBER(imds2_state::imds2_pio_port_p2_r) { - return m_pio_port2; + return m_pio_port2; } WRITE8_MEMBER(imds2_state::imds2_pio_port_p2_w) { - m_pio_port2 = data; - imds2_update_printer(); + m_pio_port2 = data; + imds2_update_printer(); // Send INTR to IPC m_ipclocpic->ir5_w(BIT(data , 7)); } +WRITE_LINE_MEMBER(imds2_state::imds2_pio_lpt_ack_w) +{ + if (state) { + m_device_status_byte |= 0x20; + } else { + m_device_status_byte &= ~0x20; + } +} + +WRITE_LINE_MEMBER(imds2_state::imds2_pio_lpt_busy_w) +{ + // Busy is active high in centronics_device whereas it's active low in MDS + if (!state) { + m_device_status_byte |= 0x10; + } else { + m_device_status_byte &= ~0x10; + } +} + +WRITE_LINE_MEMBER(imds2_state::imds2_pio_lpt_select_w) +{ + if (state) { + m_device_status_byte |= 0x40; + } else { + m_device_status_byte &= ~0x40; + } +} + I8275_DRAW_CHARACTER_MEMBER(imds2_state::crtc_display_pixels) { unsigned i; @@ -574,7 +605,24 @@ void imds2_state::imds2_update_beeper(void) void imds2_state::imds2_update_printer(void) { - // TODO + // Data to printer is ~P1 when STATUS ENABLE/==1, else 0xff (assuming pull-ups on printer) + UINT8 printer_data; + if ((m_pio_port2 & 0x7f) == 0x6c) { + printer_data = 0xff; + } else { + printer_data = ~m_pio_port1; + } + m_centronics->write_data0(BIT(printer_data , 0)); + m_centronics->write_data1(BIT(printer_data , 1)); + m_centronics->write_data2(BIT(printer_data , 2)); + m_centronics->write_data3(BIT(printer_data , 3)); + m_centronics->write_data4(BIT(printer_data , 4)); + m_centronics->write_data5(BIT(printer_data , 5)); + m_centronics->write_data6(BIT(printer_data , 6)); + m_centronics->write_data7(BIT(printer_data , 7)); + + // LPT DATA STROBE/ == 0 when P23-P20 == 9 & P24 == 0 + m_centronics->write_strobe((m_pio_port2 & 0x1f) != 0x09); } static INPUT_PORTS_START(imds2) @@ -766,13 +814,18 @@ static MACHINE_CONFIG_START(imds2 , imds2_state) MCFG_LEGACY_FLOPPY_DRIVE_ADD(FLOPPY_0, imds2_floppy_interface) - MCFG_CPU_ADD("iocpio" , I8041 , IOC_XTAL_Y3) - MCFG_CPU_IO_MAP(pio_io_map) + MCFG_CPU_ADD("iocpio" , I8041 , IOC_XTAL_Y3) + MCFG_CPU_IO_MAP(pio_io_map) MCFG_QUANTUM_TIME(attotime::from_hz(100)) - + MCFG_CPU_ADD("kbcpu", I8741, XTAL_3_579545MHz) /* 3.579545 MHz */ MCFG_CPU_IO_MAP(kb_io_map) MCFG_QUANTUM_TIME(attotime::from_hz(100)) + + MCFG_CENTRONICS_ADD("centronics", centronics_devices, "printer") + MCFG_CENTRONICS_ACK_HANDLER(WRITELINE(imds2_state , imds2_pio_lpt_ack_w)) + MCFG_CENTRONICS_BUSY_HANDLER(WRITELINE(imds2_state , imds2_pio_lpt_busy_w)) + MCFG_CENTRONICS_PERROR_HANDLER(WRITELINE(imds2_state , imds2_pio_lpt_select_w)) MACHINE_CONFIG_END ROM_START(imds2) @@ -787,10 +840,10 @@ ROM_START(imds2) ROM_LOAD("ioc_a52.bin" , 0x1000 , 0x0800 , CRC(b88a38d5) SHA1(934716a1daec852f4d1f846510f42408df0c9584)) ROM_LOAD("ioc_a53.bin" , 0x1800 , 0x0800 , CRC(c8df4bb9) SHA1(2dfb921e94ae7033a7182457b2f00657674d1b77)) - // ROM definition of PIO controller (8041A) - ROM_REGION(0x400 , "iocpio" , 0) - ROM_LOAD("pio_a72.bin" , 0 , 0x400 , CRC(c1eabf25)) - + // ROM definition of PIO controller (8041A) + ROM_REGION(0x400 , "iocpio" , 0) + ROM_LOAD("pio_a72.bin" , 0 , 0x400 , BAD_DUMP CRC(9a446534)) + // ROM definition of keyboard controller (8741) ROM_REGION(0x400 , "kbcpu" , 0) ROM_LOAD("kbd511.bin" , 0 , 0x400 , CRC(ba7c4303) SHA1(19899af732d0ae1247bfc79979b1ee5f339ee5cf)) diff --git a/src/mess/includes/imds2.h b/src/mess/includes/imds2.h index 144445c2e6b..a7c05a46a8a 100644 --- a/src/mess/includes/imds2.h +++ b/src/mess/includes/imds2.h @@ -15,6 +15,7 @@ #include "machine/pic8259.h" #include "machine/i8271.h" #include "imagedev/flopdrv.h" +#include "bus/centronics/ctronics.h" class imds2_state : public driver_device { @@ -57,6 +58,9 @@ class imds2_state : public driver_device DECLARE_WRITE8_MEMBER(imds2_pio_port_p1_w); DECLARE_READ8_MEMBER(imds2_pio_port_p2_r); DECLARE_WRITE8_MEMBER(imds2_pio_port_p2_w); + DECLARE_WRITE_LINE_MEMBER(imds2_pio_lpt_ack_w); + DECLARE_WRITE_LINE_MEMBER(imds2_pio_lpt_busy_w); + DECLARE_WRITE_LINE_MEMBER(imds2_pio_lpt_select_w); I8275_DRAW_CHARACTER_MEMBER(crtc_display_pixels); @@ -75,11 +79,12 @@ class imds2_state : public driver_device required_device m_iocbeep; required_device m_ioctimer; required_device m_iocfdc; - required_device m_iocpio; + required_device m_iocpio; required_device m_kbcpu; required_device m_palette; required_device m_gfxdecode; required_device m_floppy0; + required_device m_centronics; required_ioport m_io_key0; required_ioport m_io_key1; required_ioport m_io_key2; @@ -95,7 +100,7 @@ class imds2_state : public driver_device bool imds2_in_ipc_rom(offs_t offset) const; void imds2_update_beeper(void); - void imds2_update_printer(void); + void imds2_update_printer(void); // IPC control port UINT8 m_ipc_control; @@ -124,11 +129,14 @@ class imds2_state : public driver_device // IPC/IOC status UINT8 m_ipc_ioc_status; - // PIO port 1 - UINT8 m_pio_port1; + // PIO port 1 + UINT8 m_pio_port1; - // PIO port 2 - UINT8 m_pio_port2; + // PIO port 2 + UINT8 m_pio_port2; + + // PIO device status byte + UINT8 m_device_status_byte; }; #endif /* _IMDS2_H_ */ From 52a51f6912a1089311365dc1148fe0498a44fe2f Mon Sep 17 00:00:00 2001 From: fulivi Date: Mon, 13 Apr 2015 12:06:25 +0200 Subject: [PATCH 7/7] imds2: changed checksum for PIO fw v1.1 --- src/mess/drivers/imds2.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/mess/drivers/imds2.c b/src/mess/drivers/imds2.c index 746d900dfc1..0eb65373a96 100644 --- a/src/mess/drivers/imds2.c +++ b/src/mess/drivers/imds2.c @@ -62,7 +62,13 @@ // // ICs that are not emulated yet are marked with "*" // +// NOTE: +// Firmware running on PIO is NOT original because a dump is not available at the moment. +// Emulator runs a version of PIO firmware that was specifically developped by me to implement +// line printer output. +// // TODO: +// - Find a dump of the original PIO firmware // - Emulate serial channels on IPC // - Emulate PIT on IPC // - Adjust speed of processors. Wait states are not accounted for yet. @@ -841,8 +847,10 @@ ROM_START(imds2) ROM_LOAD("ioc_a53.bin" , 0x1800 , 0x0800 , CRC(c8df4bb9) SHA1(2dfb921e94ae7033a7182457b2f00657674d1b77)) // ROM definition of PIO controller (8041A) + // For the time being a specially developped PIO firmware is used until a dump of the original PIO is + // available. ROM_REGION(0x400 , "iocpio" , 0) - ROM_LOAD("pio_a72.bin" , 0 , 0x400 , BAD_DUMP CRC(9a446534)) + ROM_LOAD("pio_a72.bin" , 0 , 0x400 , BAD_DUMP CRC(8c8e740b)) // ROM definition of keyboard controller (8741) ROM_REGION(0x400 , "kbcpu" , 0)