Imported COM8116 DBRG from MESS. (no whatsnew)

This commit is contained in:
Curt Coder 2011-04-10 18:37:27 +00:00
parent 7ac5373f3c
commit 009a270864
4 changed files with 285 additions and 0 deletions

2
.gitattributes vendored
View File

@ -762,6 +762,8 @@ src/emu/machine/cdp1852.c svneol=native#text/plain
src/emu/machine/cdp1852.h svneol=native#text/plain
src/emu/machine/cdp1871.c svneol=native#text/plain
src/emu/machine/cdp1871.h svneol=native#text/plain
src/emu/machine/com8116.c svneol=native#text/plain
src/emu/machine/com8116.h svneol=native#text/plain
src/emu/machine/cr589.c svneol=native#text/plain
src/emu/machine/cr589.h svneol=native#text/plain
src/emu/machine/devhelpr.h svneol=native#text/plain

View File

@ -158,6 +158,7 @@ EMUMACHINEOBJS = \
$(EMUMACHINE)/at28c16.o \
$(EMUMACHINE)/cdp1852.o \
$(EMUMACHINE)/cdp1871.o \
$(EMUMACHINE)/com8116.o \
$(EMUMACHINE)/cr589.o \
$(EMUMACHINE)/ds1302.o \
$(EMUMACHINE)/ds2401.o \

150
src/emu/machine/com8116.c Normal file
View File

@ -0,0 +1,150 @@
/**********************************************************************
COM8116 Dual Baud Rate Generator (Programmable Divider) emulation
Copyright MESS Team.
Visit http://mamedev.org for licensing and usage restrictions.
**********************************************************************/
#include "emu.h"
#include "com8116.h"
#include "machine/devhelpr.h"
//**************************************************************************
// MACROS / CONSTANTS
//**************************************************************************
#define LOG 0
//**************************************************************************
// GLOBAL VARIABLES
//**************************************************************************
// devices
const device_type COM8116 = com8116_device_config::static_alloc_device_config;
//**************************************************************************
// DEVICE CONFIGURATION
//**************************************************************************
GENERIC_DEVICE_CONFIG_SETUP(com8116, "COM8116")
//-------------------------------------------------
// device_config_complete - perform any
// operations now that the configuration is
// complete
//-------------------------------------------------
void com8116_device_config::device_config_complete()
{
// inherit a copy of the static data
const com8116_interface *intf = reinterpret_cast<const com8116_interface *>(static_config());
if (intf != NULL)
*static_cast<com8116_interface *>(this) = *intf;
// or initialize to defaults if none provided
else
{
memset(&m_out_fx4_func, 0, sizeof(m_out_fx4_func));
memset(&m_out_fr_func, 0, sizeof(m_out_fr_func));
memset(&m_out_ft_func, 0, sizeof(m_out_ft_func));
}
}
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// com8116_device - constructor
//-------------------------------------------------
com8116_device::com8116_device(running_machine &_machine, const com8116_device_config &config)
: device_t(_machine, config),
m_config(config)
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void com8116_device::device_start()
{
// resolve callbacks
devcb_resolve_write_line(&m_out_fx4_func, &m_config.m_out_fx4_func, this);
devcb_resolve_write_line(&m_out_fr_func, &m_config.m_out_fr_func, this);
devcb_resolve_write_line(&m_out_ft_func, &m_config.m_out_ft_func, this);
// allocate timers
m_fx4_timer = timer_alloc(TIMER_FX4);
m_fx4_timer->adjust(attotime::zero, 0, attotime::from_hz(clock() / 4));
m_fr_timer = timer_alloc(TIMER_FR);
m_ft_timer = timer_alloc(TIMER_FT);
// register for state saving
save_item(NAME(m_fr));
save_item(NAME(m_ft));
}
//-------------------------------------------------
// device_timer - handler timer events
//-------------------------------------------------
void com8116_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
switch (id)
{
case TIMER_FX4:
devcb_call_write_line(&m_out_fx4_func, 1);
break;
case TIMER_FR:
devcb_call_write_line(&m_out_fr_func, 1);
break;
case TIMER_FT:
devcb_call_write_line(&m_out_ft_func, 1);
break;
}
}
//-------------------------------------------------
// str_w -
//-------------------------------------------------
WRITE8_MEMBER( com8116_device::str_w )
{
if (LOG) logerror("COM8116 '%s' Receiver Divider %01x\n", tag(), data & 0x0f);
m_fr = data & 0x0f;
m_fr_timer->adjust(attotime::zero, 0, attotime::from_hz(clock() / m_config.m_fr_divisors[m_fr] / 2));
}
//-------------------------------------------------
// stt_w -
//-------------------------------------------------
WRITE8_MEMBER( com8116_device::stt_w )
{
if (LOG) logerror("COM8116 '%s' Transmitter Divider %01x\n", tag(), data & 0x0f);
m_ft = data & 0x0f;
m_ft_timer->adjust(attotime::zero, 0, attotime::from_hz(clock() / m_config.m_ft_divisors[m_ft] / 2));
}

132
src/emu/machine/com8116.h Normal file
View File

@ -0,0 +1,132 @@
/**********************************************************************
COM8116 Dual Baud Rate Generator (Programmable Divider) emulation
Copyright MESS Team.
Visit http://mamedev.org for licensing and usage restrictions.
**********************************************************************
_____ _____
XTAL/EXT1 1 |* \_/ | 18 XTAL/EXT2
+5V 2 | | 17 fT
fR 3 | | 16 Ta
Ra 4 | COM8116 | 15 Tb
Rb 5 | COM8116T | 14 Tc
Rc 6 | COM8136 | 13 Td
Rd 7 | COM8136T | 12 STT
STR 8 | | 11 GND
NC 9 |_____________| 10 fX/4
**********************************************************************/
#pragma once
#ifndef __COM8116__
#define __COM8116__
#include "emu.h"
///*************************************************************************
// INTERFACE CONFIGURATION MACROS
///*************************************************************************
#define MCFG_COM8116_ADD(_tag, _clock, _config) \
MCFG_DEVICE_ADD(_tag, COM8116, _clock) \
MCFG_DEVICE_CONFIG(_config)
#define COM8116_INTERFACE(name) \
const com8116_interface (name) =
///*************************************************************************
// TYPE DEFINITIONS
///*************************************************************************
// ======================> com8116_interface
struct com8116_interface
{
devcb_write_line m_out_fx4_func;
devcb_write_line m_out_fr_func;
devcb_write_line m_out_ft_func;
// receiver divisor ROM (19-bit)
UINT32 m_fr_divisors[16];
// transmitter divisor ROM (19-bit)
UINT32 m_ft_divisors[16];
};
// ======================> com8116_device_config
class com8116_device_config : public device_config,
public com8116_interface
{
friend class com8116_device;
// construction/destruction
com8116_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
public:
// allocators
static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
virtual device_t *alloc_device(running_machine &machine) const;
protected:
// device_config overrides
virtual void device_config_complete();
};
// ======================> com8116_device
class com8116_device : public device_t
{
friend class com8116_device_config;
// construction/destruction
com8116_device(running_machine &_machine, const com8116_device_config &_config);
public:
DECLARE_WRITE8_MEMBER( str_w );
DECLARE_WRITE8_MEMBER( stt_w );
protected:
// device-level overrides
virtual void device_start();
virtual void device_timer(emu_timer &timer, device_timer_id id, int m_param, void *ptr);
private:
static const device_timer_id TIMER_FX4 = 0;
static const device_timer_id TIMER_FR = 1;
static const device_timer_id TIMER_FT = 2;
devcb_resolved_write_line m_out_fx4_func;
devcb_resolved_write_line m_out_fr_func;
devcb_resolved_write_line m_out_ft_func;
int m_fr; // receiver frequency
int m_ft; // transmitter frequency
// timers
emu_timer *m_fx4_timer;
emu_timer *m_fr_timer;
emu_timer *m_ft_timer;
const com8116_device_config &m_config;
};
// device type definition
extern const device_type COM8116;
#endif