mirror of
https://github.com/mamedev/mame.git
synced 2024-11-16 07:48:32 +01:00
Added CDP1863 sound device for MESS.
This commit is contained in:
parent
7d526a162a
commit
32e04ee9ef
5 changed files with 314 additions and 0 deletions
2
.gitattributes
vendored
2
.gitattributes
vendored
|
@ -793,6 +793,8 @@ src/emu/sound/c6280.c svneol=native#text/plain
|
|||
src/emu/sound/c6280.h svneol=native#text/plain
|
||||
src/emu/sound/cdda.c svneol=native#text/plain
|
||||
src/emu/sound/cdda.h svneol=native#text/plain
|
||||
src/emu/sound/cdp1863.c svneol=native#text/plain
|
||||
src/emu/sound/cdp1863.h svneol=native#text/plain
|
||||
src/emu/sound/cdp1869.c svneol=native#text/plain
|
||||
src/emu/sound/cdp1869.h svneol=native#text/plain
|
||||
src/emu/sound/cem3394.c svneol=native#text/plain
|
||||
|
|
231
src/emu/sound/cdp1863.c
Normal file
231
src/emu/sound/cdp1863.c
Normal file
|
@ -0,0 +1,231 @@
|
|||
/**********************************************************************
|
||||
|
||||
RCA CDP1863 CMOS 8-Bit Programmable Frequency Generator emulation
|
||||
|
||||
Copyright MESS Team.
|
||||
Visit http://mamedev.org for licensing and usage restrictions.
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
/*
|
||||
|
||||
TODO:
|
||||
|
||||
- what happens if you connect both clocks?
|
||||
|
||||
*/
|
||||
|
||||
#include "driver.h"
|
||||
#include "sndintrf.h"
|
||||
#include "streams.h"
|
||||
#include "cpu/cdp1802/cdp1802.h"
|
||||
#include "cdp1863.h"
|
||||
|
||||
/***************************************************************************
|
||||
PARAMETERS
|
||||
***************************************************************************/
|
||||
|
||||
#define CDP1863_DEFAULT_LATCH 0x35
|
||||
|
||||
/***************************************************************************
|
||||
TYPE DEFINITIONS
|
||||
***************************************************************************/
|
||||
|
||||
typedef struct _cdp1863_t cdp1863_t;
|
||||
struct _cdp1863_t
|
||||
{
|
||||
int clock1; /* clock 1 */
|
||||
int clock2; /* clock 2 */
|
||||
|
||||
sound_stream *stream; /* sound output */
|
||||
|
||||
/* sound state */
|
||||
int oe; /* output enable */
|
||||
int latch; /* sound latch */
|
||||
INT16 signal; /* current signal */
|
||||
int incr; /* initial wave state */
|
||||
};
|
||||
|
||||
/***************************************************************************
|
||||
INLINE FUNCTIONS
|
||||
***************************************************************************/
|
||||
|
||||
INLINE cdp1863_t *get_safe_token(const device_config *device)
|
||||
{
|
||||
assert(device != NULL);
|
||||
assert(device->token != NULL);
|
||||
return (cdp1863_t *)device->token;
|
||||
}
|
||||
|
||||
INLINE cdp1863_config *get_safe_config(const device_config *device)
|
||||
{
|
||||
assert(device != NULL);
|
||||
return (cdp1863_config *)device->inline_config;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
IMPLEMENTATION
|
||||
***************************************************************************/
|
||||
|
||||
/*-------------------------------------------------
|
||||
cdp1863_str_w - tone latch write
|
||||
-------------------------------------------------*/
|
||||
|
||||
WRITE8_DEVICE_HANDLER( cdp1863_str_w )
|
||||
{
|
||||
cdp1863_t *cdp1863 = get_safe_token(device);
|
||||
|
||||
cdp1863->latch = data;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
cdp1863_oe_w - output enable write
|
||||
------------------------------------------------*/
|
||||
|
||||
WRITE_LINE_DEVICE_HANDLER( cdp1863_oe_w )
|
||||
{
|
||||
cdp1863_t *cdp1863 = get_safe_token(device);
|
||||
|
||||
cdp1863->oe = state;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
cdp1863_set_clk1 - set clock 1 frequency
|
||||
------------------------------------------------*/
|
||||
|
||||
void cdp1863_set_clk1(const device_config *device, int frequency)
|
||||
{
|
||||
cdp1863_t *cdp1863 = get_safe_token(device);
|
||||
|
||||
cdp1863->clock1 = frequency;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
cdp1863_set_clk2 - set clock 2 frequency
|
||||
------------------------------------------------*/
|
||||
|
||||
void cdp1863_set_clk2(const device_config *device, int frequency)
|
||||
{
|
||||
cdp1863_t *cdp1863 = get_safe_token(device);
|
||||
|
||||
cdp1863->clock2 = frequency;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
STREAM_UPDATE( cdp1863_stream_update )
|
||||
-------------------------------------------------*/
|
||||
|
||||
static STREAM_UPDATE( cdp1863_stream_update )
|
||||
{
|
||||
cdp1863_t *cdp1863 = get_safe_token(device);
|
||||
|
||||
INT16 signal = cdp1863->signal;
|
||||
stream_sample_t *buffer = outputs[0];
|
||||
|
||||
memset( buffer, 0, samples * sizeof(*buffer) );
|
||||
|
||||
if (cdp1863->oe)
|
||||
{
|
||||
double frequency;
|
||||
int rate = device->machine->sample_rate / 2;
|
||||
|
||||
/* get progress through wave */
|
||||
int incr = cdp1863->incr;
|
||||
|
||||
if (cdp1863->clock1 > 0)
|
||||
{
|
||||
/* CLK1 is pre-divided by 4 */
|
||||
frequency = cdp1863->clock1 / 4 / (cdp1863->latch + 1) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* CLK2 is pre-divided by 8 */
|
||||
frequency = cdp1863->clock2 / 8 / (cdp1863->latch + 1) / 2;
|
||||
}
|
||||
|
||||
if (signal < 0)
|
||||
{
|
||||
signal = -0x7fff;
|
||||
}
|
||||
else
|
||||
{
|
||||
signal = 0x7fff;
|
||||
}
|
||||
|
||||
while( samples-- > 0 )
|
||||
{
|
||||
*buffer++ = signal;
|
||||
incr -= frequency;
|
||||
while( incr < 0 )
|
||||
{
|
||||
incr += rate;
|
||||
signal = -signal;
|
||||
}
|
||||
}
|
||||
|
||||
/* store progress through wave */
|
||||
cdp1863->incr = incr;
|
||||
cdp1863->signal = signal;
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
DEVICE_START( cdp1863 )
|
||||
-------------------------------------------------*/
|
||||
|
||||
static DEVICE_START( cdp1863 )
|
||||
{
|
||||
cdp1863_t *cdp1863 = get_safe_token(device);
|
||||
const cdp1863_config *config = get_safe_config(device);
|
||||
|
||||
/* set initial values */
|
||||
cdp1863->stream = stream_create(device, 0, 1, device->machine->sample_rate, cdp1863, cdp1863_stream_update);
|
||||
cdp1863->clock1 = device->clock;
|
||||
cdp1863->clock2 = config->clock2;
|
||||
cdp1863->oe = 1;
|
||||
|
||||
/* register for state saving */
|
||||
state_save_register_device_item(device, 0, cdp1863->clock1);
|
||||
state_save_register_device_item(device, 0, cdp1863->clock2);
|
||||
state_save_register_device_item(device, 0, cdp1863->oe);
|
||||
state_save_register_device_item(device, 0, cdp1863->latch);
|
||||
state_save_register_device_item(device, 0, cdp1863->signal);
|
||||
state_save_register_device_item(device, 0, cdp1863->incr);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
DEVICE_RESET( cdp1863 )
|
||||
-------------------------------------------------*/
|
||||
|
||||
static DEVICE_RESET( cdp1863 )
|
||||
{
|
||||
cdp1863_t *cdp1863 = get_safe_token(device);
|
||||
|
||||
cdp1863->latch = CDP1863_DEFAULT_LATCH;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
DEVICE_GET_INFO( cdp1863 )
|
||||
-------------------------------------------------*/
|
||||
|
||||
DEVICE_GET_INFO( cdp1863 )
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
/* --- the following bits of info are returned as 64-bit signed integers --- */
|
||||
case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(cdp1863_t); break;
|
||||
case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(cdp1863_config); break;
|
||||
|
||||
/* --- the following bits of info are returned as pointers to data or functions --- */
|
||||
case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(cdp1863); break;
|
||||
case DEVINFO_FCT_STOP: /* Nothing */ break;
|
||||
case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(cdp1863); break;
|
||||
|
||||
/* --- the following bits of info are returned as NULL-terminated strings --- */
|
||||
case DEVINFO_STR_NAME: strcpy(info->s, "RCA CDP1863"); break;
|
||||
case DEVINFO_STR_FAMILY: strcpy(info->s, "RCA CDP1800"); break;
|
||||
case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break;
|
||||
case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
|
||||
case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright MESS Team"); break;
|
||||
}
|
||||
}
|
68
src/emu/sound/cdp1863.h
Normal file
68
src/emu/sound/cdp1863.h
Normal file
|
@ -0,0 +1,68 @@
|
|||
/**********************************************************************
|
||||
|
||||
RCA CDP1863 CMOS 8-Bit Programmable Frequency Generator emulation
|
||||
|
||||
Copyright MESS Team.
|
||||
Visit http://mamedev.org for licensing and usage restrictions.
|
||||
|
||||
**********************************************************************
|
||||
_____ _____
|
||||
_RESET 1 |* \_/ | 16 Vdd
|
||||
CLK 2 2 | | 15 OE
|
||||
CLK 1 3 | | 14 OUT
|
||||
STR 4 | CDP1863 | 13 DO7
|
||||
DI0 5 | | 12 DI6
|
||||
DI1 6 | | 11 DI5
|
||||
DI2 7 | | 10 DI4
|
||||
Vss 8 |_____________| 9 DI3
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef __CDP1863__
|
||||
#define __CDP1863__
|
||||
|
||||
/***************************************************************************
|
||||
MACROS / CONSTANTS
|
||||
***************************************************************************/
|
||||
|
||||
#define CDP1863 DEVICE_GET_INFO_NAME(cdp1863)
|
||||
#define SOUND_CDP1863 CDP1863
|
||||
|
||||
#define MDRV_CDP1863_ADD(_tag, _clock1, _clock2) \
|
||||
MDRV_DEVICE_ADD(_tag, SOUND, _clock1) \
|
||||
MDRV_DEVICE_CONFIG_DATAPTR(cdp1863_config, type, SOUND_CDP1863) \
|
||||
MDRV_DEVICE_CONFIG_DATA32(cdp1863_config, clock2, _clock2)
|
||||
|
||||
#define CDP1863_INTERFACE(name) \
|
||||
const cdp1863_interface (name) =
|
||||
|
||||
/***************************************************************************
|
||||
TYPE DEFINITIONS
|
||||
***************************************************************************/
|
||||
|
||||
typedef struct _cdp1863_config cdp1863_config;
|
||||
struct _cdp1863_config
|
||||
{
|
||||
const sound_config *type;
|
||||
|
||||
int clock2; /* the clock 2 (pin 2) of the chip */
|
||||
};
|
||||
|
||||
/***************************************************************************
|
||||
PROTOTYPES
|
||||
***************************************************************************/
|
||||
|
||||
/* device interface */
|
||||
DEVICE_GET_INFO( cdp1863 );
|
||||
|
||||
/* load tone latch */
|
||||
WRITE8_DEVICE_HANDLER( cdp1863_str_w );
|
||||
|
||||
/* output enable */
|
||||
WRITE_LINE_DEVICE_HANDLER( cdp1863_oe_w );
|
||||
|
||||
/* clock setters */
|
||||
void cdp1863_set_clk1(const device_config *device, int frequency) ATTR_NONNULL(1);
|
||||
void cdp1863_set_clk2(const device_config *device, int frequency) ATTR_NONNULL(1);
|
||||
|
||||
#endif
|
|
@ -193,6 +193,18 @@ endif
|
|||
|
||||
|
||||
|
||||
#-------------------------------------------------
|
||||
# RCA CDP1863
|
||||
#-------------------------------------------------
|
||||
|
||||
SOUNDDEFS += -DHAS_CDP1863=$(if $(filter CDP1863,$(SOUNDS)),1,0)
|
||||
|
||||
ifneq ($(filter CDP1863,$(SOUNDS)),)
|
||||
SOUNDOBJS += $(SOUNDOBJ)/cdp1863.o
|
||||
endif
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------
|
||||
# RCA CDP1869
|
||||
#-------------------------------------------------
|
||||
|
|
|
@ -213,6 +213,7 @@ SOUNDS += WAVE
|
|||
#SOUNDS += SID8580
|
||||
SOUNDS += SP0256
|
||||
SOUNDS += DIGITALKER
|
||||
SOUNDS += CDP1863
|
||||
|
||||
|
||||
#-------------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue