mirror of
https://github.com/holub/mame
synced 2025-04-24 17:30:55 +03:00
Written a preliminary S-3520CF RTC chip device, used by Nintendo Super System [Angelo Salese]
This commit is contained in:
parent
7b1a2ebc9e
commit
359adc3269
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -1177,6 +1177,8 @@ src/emu/machine/rtc65271.c svneol=native#text/plain
|
||||
src/emu/machine/rtc65271.h svneol=native#text/plain
|
||||
src/emu/machine/rtc9701.c svneol=native#text/plain
|
||||
src/emu/machine/rtc9701.h svneol=native#text/plain
|
||||
src/emu/machine/s3520cf.c svneol=native#text/plain
|
||||
src/emu/machine/s3520cf.h svneol=native#text/plain
|
||||
src/emu/machine/s3c2400.c svneol=native#text/plain
|
||||
src/emu/machine/s3c2400.h svneol=native#text/plain
|
||||
src/emu/machine/s3c2410.c svneol=native#text/plain
|
||||
|
@ -242,6 +242,7 @@ EMUMACHINEOBJS = \
|
||||
$(EMUMACHINE)/s3c2400.o \
|
||||
$(EMUMACHINE)/s3c2410.o \
|
||||
$(EMUMACHINE)/s3c2440.o \
|
||||
$(EMUMACHINE)/s3520cf.o \
|
||||
$(EMUMACHINE)/scsi.o \
|
||||
$(EMUMACHINE)/scsicd.o \
|
||||
$(EMUMACHINE)/scsidev.o \
|
||||
|
191
src/emu/machine/s3520cf.c
Normal file
191
src/emu/machine/s3520cf.c
Normal file
@ -0,0 +1,191 @@
|
||||
/***************************************************************************
|
||||
|
||||
Seiko/Epson S-3520CF
|
||||
|
||||
preliminary device by Angelo Salese
|
||||
|
||||
TODO:
|
||||
- kludge on address?
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#include "emu.h"
|
||||
#include "machine/s3520cf.h"
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// GLOBAL VARIABLES
|
||||
//**************************************************************************
|
||||
|
||||
// device type definition
|
||||
const device_type S3520CF = &device_creator<s3520cf_device>;
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// LIVE DEVICE
|
||||
//**************************************************************************
|
||||
|
||||
//-------------------------------------------------
|
||||
// s3520cf_device - constructor
|
||||
//-------------------------------------------------
|
||||
|
||||
s3520cf_device::s3520cf_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: device_t(mconfig, S3520CF, "s3520cf", tag, owner, clock)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_validity_check - perform validity checks
|
||||
// on this device
|
||||
//-------------------------------------------------
|
||||
|
||||
void s3520cf_device::device_validity_check(validity_checker &valid) const
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_start - device-specific startup
|
||||
//-------------------------------------------------
|
||||
|
||||
void s3520cf_device::device_start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_reset - device-specific reset
|
||||
//-------------------------------------------------
|
||||
|
||||
void s3520cf_device::device_reset()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// rtc_read - used to route RTC reading registers
|
||||
//-------------------------------------------------
|
||||
|
||||
inline UINT8 s3520cf_device::rtc_read(UINT8 offset)
|
||||
{
|
||||
UINT8 res;
|
||||
|
||||
res = 0;
|
||||
|
||||
switch(offset)
|
||||
{
|
||||
// case 0: // 1 sec
|
||||
// case 1: // 10 sec
|
||||
// case 2: // 1 min
|
||||
// case 3: // 10 min
|
||||
// case 6: // week
|
||||
// case 7: // 1 day
|
||||
case 4: // 1 hour
|
||||
res = 1;
|
||||
break;
|
||||
case 5: // 10 hour
|
||||
res = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
inline void s3520cf_device::rtc_write(UINT8 offset,UINT8 data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// READ/WRITE HANDLERS
|
||||
//**************************************************************************
|
||||
|
||||
READ_LINE_MEMBER( s3520cf_device::read_bit )
|
||||
{
|
||||
return m_read_latch;
|
||||
}
|
||||
|
||||
WRITE_LINE_MEMBER( s3520cf_device::set_dir_line )
|
||||
{
|
||||
//printf("%d DIR LINE\n",state);
|
||||
|
||||
m_dir = state;
|
||||
}
|
||||
|
||||
WRITE_LINE_MEMBER( s3520cf_device::set_cs_line )
|
||||
{
|
||||
m_reset_line = state;
|
||||
|
||||
//printf("%d CS LINE\n",state);
|
||||
|
||||
if(m_reset_line != CLEAR_LINE)
|
||||
{
|
||||
//printf("Reset asserted\n");
|
||||
m_current_cmd = 0;
|
||||
m_cmd_stream_pos = 0;
|
||||
m_rtc_state = RTC_SET_ADDRESS;
|
||||
//m_latch = 0;
|
||||
}
|
||||
}
|
||||
|
||||
WRITE_LINE_MEMBER( s3520cf_device::write_bit )
|
||||
{
|
||||
m_latch = state;
|
||||
// printf("%d LATCH LINE\n",state);
|
||||
}
|
||||
|
||||
WRITE_LINE_MEMBER( s3520cf_device::set_clock_line )
|
||||
{
|
||||
if(state == 1 && m_reset_line == CLEAR_LINE)
|
||||
{
|
||||
//printf("%d %d\n",m_latch, m_dir);
|
||||
|
||||
switch(m_rtc_state)
|
||||
{
|
||||
case RTC_SET_ADDRESS:
|
||||
m_current_cmd = (m_current_cmd >> 1) | ((m_latch<<3)&8);
|
||||
m_cmd_stream_pos++;
|
||||
|
||||
if(m_cmd_stream_pos == 4)
|
||||
{
|
||||
m_rtc_addr = (m_current_cmd + 1) & 0xf; /* TODO: +1??? */
|
||||
m_rtc_state = RTC_SET_DATA;
|
||||
m_cmd_stream_pos = 0;
|
||||
m_current_cmd = 0;
|
||||
}
|
||||
break;
|
||||
case RTC_SET_DATA:
|
||||
if(m_dir == 1) // READ
|
||||
{
|
||||
//if(m_cmd_stream_pos == 0)
|
||||
{
|
||||
//printf("%02x %d\n",m_rtc_addr,m_cmd_stream_pos);
|
||||
}
|
||||
m_read_latch = (rtc_read(m_rtc_addr) >> (m_cmd_stream_pos)) & 1;
|
||||
}
|
||||
|
||||
m_current_cmd = (m_current_cmd >> 1) | ((m_latch<<3)&8);
|
||||
m_cmd_stream_pos++;
|
||||
if(m_cmd_stream_pos == 4)
|
||||
{
|
||||
if(m_dir == 0) // WRITE
|
||||
{
|
||||
printf("%02x %02x\n",m_rtc_addr,m_current_cmd);
|
||||
rtc_write(m_rtc_addr,m_current_cmd);
|
||||
}
|
||||
|
||||
m_rtc_addr = m_current_cmd;
|
||||
m_rtc_state = RTC_SET_ADDRESS;
|
||||
m_cmd_stream_pos = 0;
|
||||
m_current_cmd = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
80
src/emu/machine/s3520cf.h
Normal file
80
src/emu/machine/s3520cf.h
Normal file
@ -0,0 +1,80 @@
|
||||
/***************************************************************************
|
||||
|
||||
Template for skeleton device
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __S3520CFDEV_H__
|
||||
#define __S3520CFDEV_H__
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// INTERFACE CONFIGURATION MACROS
|
||||
//**************************************************************************
|
||||
|
||||
#define MCFG_S3520CF_ADD(_tag) \
|
||||
MCFG_DEVICE_ADD(_tag, S3520CF, XTAL_32_768kHz) \
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// TYPE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
||||
typedef enum
|
||||
{
|
||||
RTC_SET_ADDRESS = 0,
|
||||
RTC_SET_DATA
|
||||
} s3520cf_state_t;
|
||||
|
||||
|
||||
// ======================> s3520cf_device
|
||||
|
||||
class s3520cf_device : public device_t
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
s3520cf_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
|
||||
// I/O operations
|
||||
READ_LINE_MEMBER( read_bit );
|
||||
WRITE_LINE_MEMBER( set_dir_line );
|
||||
WRITE_LINE_MEMBER( set_cs_line );
|
||||
WRITE_LINE_MEMBER( set_clock_line );
|
||||
WRITE_LINE_MEMBER( write_bit );
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_validity_check(validity_checker &valid) const;
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
inline UINT8 rtc_read(UINT8 offset);
|
||||
inline void rtc_write(UINT8 offset,UINT8 data);
|
||||
|
||||
int m_dir;
|
||||
int m_latch;
|
||||
int m_reset_line;
|
||||
int m_read_latch;
|
||||
UINT8 m_current_cmd;
|
||||
UINT8 m_cmd_stream_pos;
|
||||
UINT8 m_rtc_addr;
|
||||
|
||||
s3520cf_state_t m_rtc_state;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// device type definition
|
||||
extern const device_type S3520CF;
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// GLOBAL VARIABLES
|
||||
//**************************************************************************
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -2,6 +2,8 @@
|
||||
|
||||
Mitsubishi M50458 OSD chip
|
||||
|
||||
preliminary device by Angelo Salese
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#include "emu.h"
|
||||
@ -19,6 +21,7 @@ const device_type M50458 = &device_creator<m50458_device>;
|
||||
static ADDRESS_MAP_START( m50458_vram, AS_0, 16, m50458_device )
|
||||
AM_RANGE(0x0000, 0x023f) AM_RAM // vram
|
||||
AM_RANGE(0x0240, 0x0241) AM_WRITE(vreg_120_w)
|
||||
AM_RANGE(0x024c, 0x024d) AM_WRITE(vreg_126_w)
|
||||
AM_RANGE(0x024e, 0x024f) AM_WRITE(vreg_127_w)
|
||||
ADDRESS_MAP_END
|
||||
|
||||
@ -30,8 +33,15 @@ ROM_END
|
||||
|
||||
WRITE16_MEMBER( m50458_device::vreg_120_w)
|
||||
{
|
||||
// ...
|
||||
}
|
||||
|
||||
WRITE16_MEMBER( m50458_device::vreg_126_w)
|
||||
{
|
||||
// ...
|
||||
}
|
||||
|
||||
|
||||
WRITE16_MEMBER( m50458_device::vreg_127_w)
|
||||
{
|
||||
if(data & 0x20) // RAMERS, display RAM is erased
|
||||
|
@ -29,11 +29,6 @@ typedef enum
|
||||
OSD_SET_DATA
|
||||
} m50458_state_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT8 r,g,b;
|
||||
} m50458_bg_t;
|
||||
|
||||
// ======================> m50458_device
|
||||
|
||||
class m50458_device : public device_t,
|
||||
@ -48,6 +43,7 @@ public:
|
||||
WRITE_LINE_MEMBER( set_cs_line );
|
||||
WRITE_LINE_MEMBER( set_clock_line );
|
||||
DECLARE_WRITE16_MEMBER(vreg_120_w);
|
||||
DECLARE_WRITE16_MEMBER(vreg_126_w);
|
||||
DECLARE_WRITE16_MEMBER(vreg_127_w);
|
||||
|
||||
UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
|
||||
@ -66,9 +62,9 @@ protected:
|
||||
UINT16 m_current_cmd;
|
||||
int m_cmd_stream_pos;
|
||||
UINT16 m_osd_addr;
|
||||
UINT8 m_bg_pen;
|
||||
|
||||
m50458_state_t m_osd_state;
|
||||
m50458_bg_t m_m50458_bg;
|
||||
|
||||
private:
|
||||
inline UINT16 read_word(offs_t address);
|
||||
|
@ -296,6 +296,7 @@ Contra III CONTRA_III_1 TC574000 CONTRA_III_0 TC574000 GAME1_NSSU
|
||||
#include "emu.h"
|
||||
#include "cpu/z80/z80.h"
|
||||
#include "machine/eeprom.h"
|
||||
#include "machine/s3520cf.h"
|
||||
#include "video/m50458.h"
|
||||
#include "includes/snes.h"
|
||||
#include "rendlay.h"
|
||||
@ -306,10 +307,12 @@ class nss_state : public snes_state
|
||||
public:
|
||||
nss_state(const machine_config &mconfig, device_type type, const char *tag)
|
||||
: snes_state(mconfig, type, tag),
|
||||
m_m50458(*this,"m50458")
|
||||
m_m50458(*this,"m50458"),
|
||||
m_s3520cf(*this, "s3520cf")
|
||||
{ }
|
||||
|
||||
required_device<m50458_device> m_m50458;
|
||||
required_device<s3520cf_device> m_s3520cf;
|
||||
UINT8 m_wram_wp_flag;
|
||||
UINT8 *m_wram;
|
||||
UINT8 m_nmi_enable;
|
||||
@ -540,7 +543,7 @@ WRITE8_MEMBER(nss_state::rtc_osd_w)
|
||||
---- --x- RTC Direction (0=Low=Write, 1=High=Read)
|
||||
---- ---x RTC /CS (0=Low/Select, 1=High/No)
|
||||
*/
|
||||
/* TODO */
|
||||
// printf("%02x\n",data & 0xf);
|
||||
ioport("RTC_OSD")->write(data, 0xff);
|
||||
}
|
||||
|
||||
@ -550,6 +553,7 @@ static ADDRESS_MAP_START( bios_io_map, AS_IO, 8, nss_state )
|
||||
AM_RANGE(0x00, 0x00) AM_READ(port_00_r) AM_WRITE(port_00_w)
|
||||
AM_RANGE(0x01, 0x01) AM_READ_PORT("FP")
|
||||
AM_RANGE(0x02, 0x02) AM_READ_PORT("SYSTEM") AM_WRITE(rtc_osd_w)
|
||||
AM_RANGE(0x03, 0x03) AM_READ_PORT("RTC")
|
||||
|
||||
AM_RANGE(0x72, 0x72) AM_WRITE(rtc_osd_w)
|
||||
AM_RANGE(0x80, 0x80) AM_WRITE(port_00_w)
|
||||
@ -608,9 +612,17 @@ static INPUT_PORTS_START( snes )
|
||||
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE_MEMBER("eeprom", eeprom_device, set_cs_line)
|
||||
|
||||
PORT_START("RTC_OSD")
|
||||
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE_MEMBER("m50458", m50458_device, set_clock_line)
|
||||
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE_MEMBER("m50458", m50458_device, set_clock_line)
|
||||
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE_MEMBER("m50458", m50458_device, write_bit)
|
||||
PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE_MEMBER("m50458", m50458_device, set_cs_line)
|
||||
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE_MEMBER("s3520cf", s3520cf_device, set_clock_line)
|
||||
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE_MEMBER("s3520cf", s3520cf_device, write_bit)
|
||||
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE_MEMBER("s3520cf", s3520cf_device, set_dir_line)
|
||||
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE_MEMBER("s3520cf", s3520cf_device, set_cs_line)
|
||||
|
||||
PORT_START("RTC")
|
||||
PORT_BIT( 0xfe, IP_ACTIVE_HIGH, IPT_UNKNOWN )
|
||||
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE_MEMBER("s3520cf", s3520cf_device, read_bit)
|
||||
|
||||
PORT_START("SERIAL1_DATA1_L")
|
||||
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P1 Button A") PORT_PLAYER(1)
|
||||
@ -771,6 +783,9 @@ static MACHINE_CONFIG_DERIVED( nss, snes )
|
||||
MCFG_CPU_IO_MAP(bios_io_map)
|
||||
MCFG_CPU_VBLANK_INT("screen", nss_vblank_irq)
|
||||
|
||||
MCFG_M50458_ADD("m50458",4000000) /* TODO: clock */
|
||||
MCFG_S3520CF_ADD("s3520cf") /* RTC */
|
||||
|
||||
/* TODO: the screen should actually superimpose, but for the time being let's just separate outputs for now */
|
||||
MCFG_DEFAULT_LAYOUT(layout_dualhsxs)
|
||||
|
||||
@ -783,8 +798,6 @@ static MACHINE_CONFIG_DERIVED( nss, snes )
|
||||
|
||||
MCFG_EEPROM_ADD("eeprom", nss_eeprom_intf)
|
||||
|
||||
MCFG_M50458_ADD("m50458",4000000) /* TODO: clock */
|
||||
|
||||
MCFG_MACHINE_START( nss )
|
||||
MACHINE_CONFIG_END
|
||||
|
||||
|
@ -14,7 +14,7 @@ Template for skeleton device
|
||||
//**************************************************************************
|
||||
|
||||
// device type definition
|
||||
const device_type xxx = &device_creator<xxx_device>;
|
||||
const device_type XXX = &device_creator<xxx_device>;
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
@ -26,7 +26,7 @@ const device_type xxx = &device_creator<xxx_device>;
|
||||
//-------------------------------------------------
|
||||
|
||||
xxx_device::xxx_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: device_t(mconfig, xxx, "xxx", tag, owner, clock)
|
||||
: device_t(mconfig, XXX, "xxx", tag, owner, clock)
|
||||
{
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user