More accurate MSM5832 WR emulation; add pinout for RTC58323 (nw)

This commit is contained in:
AJR 2016-11-13 22:18:12 -05:00
parent 24e98ca456
commit a6d4d84e50
7 changed files with 63 additions and 53 deletions

View File

@ -267,6 +267,8 @@ void apricot_keyboard_hle_device::received_byte(uint8_t byte)
{
m_rtc->address_w(m_rtc_index--);
m_rtc->data_w(machine().dummy_space(), 0, byte);
m_rtc->write_w(1);
m_rtc->write_w(0);
}
}
else
@ -303,7 +305,6 @@ void apricot_keyboard_hle_device::received_byte(uint8_t byte)
// make rtc chip ready
m_rtc->cs_w(1);
m_rtc->write_w(1);
break;

View File

@ -92,6 +92,7 @@ msm5832_device::msm5832_device(const machine_config &mconfig, const char *tag, d
device_rtc_interface(mconfig, *this),
m_hold(0),
m_address(0),
m_data(0),
m_read(0),
m_write(0),
m_cs(0)
@ -115,6 +116,7 @@ void msm5832_device::device_start()
save_item(NAME(m_reg));
save_item(NAME(m_hold));
save_item(NAME(m_address));
save_item(NAME(m_data));
save_item(NAME(m_read));
save_item(NAME(m_write));
save_item(NAME(m_cs));
@ -163,28 +165,9 @@ void msm5832_device::rtc_clock_updated(int year, int month, int day, int day_of_
READ8_MEMBER( msm5832_device::data_r )
{
uint8_t data = 0;
if (LOG) logerror("MSM5832 Register Read %01x: %01x\n", m_address, m_data & 0x0f);
if (m_cs && m_read)
{
if (m_address == REGISTER_REF)
{
// TODO reference output
}
else if (m_address <= REGISTER_Y10)
{
data = m_reg[m_address];
}
else
{
// Otrona Attache CP/M BIOS checks unused registers to detect it
data = 0x0f;
}
}
if (LOG) logerror("MSM5832 Register Read %01x: %01x\n", m_address, data & 0x0f);
return data & 0x0f;
return m_data & 0x0f;
}
@ -196,20 +179,7 @@ WRITE8_MEMBER( msm5832_device::data_w )
{
if (LOG) logerror("MSM5832 Register Write %01x: %01x\n", m_address, data & 0x0f);
if (m_cs && m_write)
{
if (m_address == REGISTER_REF)
{
// TODO reference output
}
else if (m_address <= REGISTER_Y10)
{
m_reg[m_address] = data & 0x0f;
set_time(false, read_counter(REGISTER_Y1), read_counter(REGISTER_MO1), read_counter(REGISTER_D1), m_reg[REGISTER_W],
read_counter(REGISTER_H1), read_counter(REGISTER_MI1), read_counter(REGISTER_S1));
}
}
m_data = data & 0x0f;
}
@ -222,6 +192,23 @@ void msm5832_device::address_w(uint8_t data)
if (LOG) logerror("MSM5832 Address: %01x\n", data & 0x0f);
m_address = data & 0x0f;
if (m_cs && m_read)
{
if (m_address == REGISTER_REF)
{
// TODO reference output
}
else if (m_address <= REGISTER_Y10)
{
m_data = m_reg[m_address];
}
else
{
// Otrona Attache CP/M BIOS checks unused registers to detect it
m_data = 0x0f;
}
}
}
@ -280,8 +267,26 @@ WRITE_LINE_MEMBER( msm5832_device::read_w )
WRITE_LINE_MEMBER( msm5832_device::write_w )
{
if (m_write == state)
return;
if (LOG) logerror("MSM5832 WR: %u\n", state);
if (m_cs && state)
{
if (m_address == REGISTER_REF)
{
// TODO reference output
}
else if (m_address <= REGISTER_Y10)
{
m_reg[m_address] = m_data & 0x0f;
set_time(false, read_counter(REGISTER_Y1), read_counter(REGISTER_MO1), read_counter(REGISTER_D1), m_reg[REGISTER_W],
read_counter(REGISTER_H1), read_counter(REGISTER_MI1), read_counter(REGISTER_S1));
}
}
m_write = state;
}

View File

@ -80,7 +80,9 @@ private:
uint8_t m_reg[13]; // registers
int m_hold; // counter hold
int m_address; // address
uint8_t m_address; // address
uint8_t m_data; // latched data
int m_read;
int m_write;

View File

@ -15,6 +15,20 @@
D3 7 | | 10 _BUSY
GND 8 |_____________| 9 ADDRESS WRITE
_____ _____
NC 1 |* \_/ | 24 Vdd
NC 2 | | 23 Vdd
NC 3 | | 22 Vdd
NC 4 | | 21 Vdd
CS2 5 | | 20 Vdd
WRITE 6 | | 19 Vdd
READ 7 | RTC58323 | 18 Vdd
D0 8 | | 17 CS1
D1 9 | | 16 TEST
D2 10 | | 15 STOP
D3 11 | | 14 _BUSY
GND 12 |_____________| 13 ADDRESS WRITE
**********************************************************************/
#pragma once

View File

@ -122,7 +122,6 @@ public:
DECLARE_READ8_MEMBER(lpt_status_r);
DECLARE_WRITE8_MEMBER(lpt_data_w);
DECLARE_WRITE8_MEMBER(rtc_control_w);
DECLARE_WRITE8_MEMBER(rtc_data_w);
MC6845_ON_UPDATE_ADDR_CHANGED(crtc_addr);
MC6845_UPDATE_ROW(update_row);
@ -134,7 +133,6 @@ public:
required_device<screen_device> m_screen;
uint8_t m_mc6845_address;
uint16_t m_video_update_address;
uint8_t m_rtc_data;
};
@ -172,7 +170,6 @@ void amusco_state::video_start()
void amusco_state::machine_start()
{
m_rtc_data = 0;
}
@ -305,16 +302,6 @@ WRITE8_MEMBER(amusco_state::rtc_control_w)
m_rtc->hold_w(BIT(data, 6));
m_rtc->write_w(BIT(data, 5));
m_rtc->read_w(BIT(data, 4));
// TO DO: MSM5832 WR emulation is inaccurate
if (BIT(data, 5))
m_rtc->data_w(space, 0, m_rtc_data);
}
WRITE8_MEMBER(amusco_state::rtc_data_w)
{
// TO DO: MSM5832 should be able to latch this value itself
m_rtc_data = data;
}
static ADDRESS_MAP_START( amusco_io_map, AS_IO, 8, amusco_state )
@ -454,7 +441,7 @@ static MACHINE_CONFIG_START( amusco, amusco_state )
MCFG_DEVICE_ADD("rtc_interface", I8155, 0)
MCFG_I8155_OUT_PORTA_CB(WRITE8(amusco_state, rtc_control_w))
MCFG_I8155_IN_PORTC_CB(DEVREAD8("rtc", msm5832_device, data_r))
MCFG_I8155_OUT_PORTC_CB(WRITE8(amusco_state, rtc_data_w))
MCFG_I8155_OUT_PORTC_CB(DEVWRITE8("rtc", msm5832_device, data_w))
/* video hardware */
MCFG_SCREEN_ADD("screen", RASTER)

View File

@ -491,10 +491,10 @@ void attache_state::operation_strobe(address_space& space, uint8_t data)
break;
case PIO_SEL_5832_WRITE:
m_rtc->cs_w(1);
m_rtc->write_w(1);
m_rtc->read_w(0);
m_rtc->address_w((data & 0xf0) >> 4);
m_rtc->data_w(space,0,data & 0x0f);
m_rtc->write_w(1);
logerror("RTC: write %01x to %01x\n",data & 0x0f,(data & 0xf0) >> 4);
break;
case PIO_SEL_5832_READ:

View File

@ -2419,7 +2419,6 @@ WRITE8_MEMBER( cmi_state::q133_1_portb_w )
m_msm5832->hold_w(BIT(data, 0));
m_msm5832->read_w(BIT(data, 1));
m_msm5832->write_w(BIT(data, 2));
m_msm5832->cs_w(1);
}
/*
@ -2720,6 +2719,8 @@ void cmi_state::machine_start()
/* Allocate 256B scratch RAM per CPU */
m_scratch_ram[0] = std::make_unique<uint8_t[]>(0x100);
m_scratch_ram[1] = std::make_unique<uint8_t[]>(0x100);
m_msm5832->cs_w(1);
}
INTERRUPT_GEN_MEMBER( cmi_state::cmi_iix_vblank )