mirror of
https://github.com/holub/mame
synced 2025-05-25 15:25:33 +03:00
1. Added the ability to invoke CPU input lines with devcb callbacks
2. Changed sp0256 to use devcb callbacks 3. Updated sauro driver as per #2
This commit is contained in:
parent
e4aeab1a20
commit
219639f3d7
@ -98,6 +98,13 @@ static WRITE_LINE_DEVICE_HANDLER( trampoline_write8_to_write_line )
|
||||
(*resolved->real.writedevice)(resolved->realtarget, 0, state);
|
||||
}
|
||||
|
||||
static WRITE_LINE_DEVICE_HANDLER( trampoline_writecpu_to_write_line )
|
||||
{
|
||||
const devcb_resolved_write_line *resolved = (const devcb_resolved_write_line *)device;
|
||||
const device_config *cpu = resolved->realtarget;
|
||||
cpu_set_input_line(cpu, resolved->real.writeline, state ? ASSERT_LINE : CLEAR_LINE);
|
||||
}
|
||||
|
||||
void devcb_resolve_write_line(devcb_resolved_write_line *resolved, const devcb_write_line *config, const device_config *device)
|
||||
{
|
||||
/* reset the resolved structure */
|
||||
@ -119,6 +126,20 @@ void devcb_resolve_write_line(devcb_resolved_write_line *resolved, const devcb_w
|
||||
resolved->real.writespace = config->writespace;
|
||||
}
|
||||
|
||||
/* cpu line handlers */
|
||||
else if (config->type >= DEVCB_TYPE_CPU_LINE(0) && config->type < DEVCB_TYPE_CPU_LINE(MAX_INPUT_LINES))
|
||||
{
|
||||
FPTR line = (FPTR)config->type - (FPTR)DEVCB_TYPE_CPU_LINE(0);
|
||||
const device_config *cpu = cputag_get_cpu(device->machine, config->tag);
|
||||
|
||||
if (cpu == NULL)
|
||||
fatalerror("devcb_resolve_write_line: unable to find CPU '%s' (requested by %s '%s')", config->tag, device_get_name(device), device->tag);
|
||||
resolved->target = resolved;
|
||||
resolved->write = trampoline_writecpu_to_write_line;
|
||||
resolved->realtarget = cpu;
|
||||
resolved->real.writeline = (int) line;
|
||||
}
|
||||
|
||||
/* device handlers */
|
||||
else if (config->type != NULL && (config->writeline != NULL || config->writedevice != NULL))
|
||||
{
|
||||
|
@ -24,6 +24,7 @@
|
||||
The adapted callback types supported are:
|
||||
|
||||
input port (port)
|
||||
cpu input line (cpu input line)
|
||||
read_line_device_func: (device)
|
||||
write_line_device_func: (device, data)
|
||||
read8_device_func: (device, offset)
|
||||
@ -49,6 +50,7 @@
|
||||
#define DEVCB_TYPE_SELF ((device_type)1)
|
||||
#define DEVCB_TYPE_INPUT ((device_type)2)
|
||||
#define DEVCB_TYPE_MEMORY(space) ((device_type)(4 + (space)))
|
||||
#define DEVCB_TYPE_CPU_LINE(line) ((device_type)(4 + ADDRESS_SPACES + (line)))
|
||||
|
||||
|
||||
|
||||
@ -72,6 +74,9 @@
|
||||
/* read handlers for an I/O port by tag */
|
||||
#define DEVCB_INPUT_PORT(tag) { DEVCB_TYPE_INPUT, (tag), NULL, NULL, NULL }
|
||||
|
||||
/* write handlers for a CPU input line */
|
||||
#define DEVCB_CPU_INPUT_LINE(tag,line) { DEVCB_TYPE_CPU_LINE(line), (tag), NULL, NULL, NULL }
|
||||
|
||||
|
||||
/* macros for defining read_line/write_line functions */
|
||||
#define READ_LINE_DEVICE_HANDLER(name) int name(ATTR_UNUSED const device_config *device)
|
||||
@ -134,6 +139,7 @@ struct _devcb_resolved_write_line
|
||||
{
|
||||
write8_device_func writedevice;
|
||||
write8_space_func writespace;
|
||||
int writeline;
|
||||
} real; /* real write function for stubs */
|
||||
};
|
||||
|
||||
|
@ -58,7 +58,7 @@
|
||||
if( sp->sby_line != line_state ) \
|
||||
{ \
|
||||
sp->sby_line = line_state; \
|
||||
if( sp->sby ) sp->sby(sp->device, sp->sby_line); \
|
||||
devcb_call_write_line(&sp->sby, sp->sby_line); \
|
||||
} \
|
||||
}
|
||||
|
||||
@ -79,8 +79,8 @@ struct sp0256
|
||||
{
|
||||
const device_config *device;
|
||||
sound_stream *stream; /* MAME core sound stream */
|
||||
void (*drq)(const device_config *device, int state); /* Data request callback */
|
||||
void (*sby)(const device_config *device, int state); /* Standby callback */
|
||||
devcb_resolved_write_line drq; /* Data request callback */
|
||||
devcb_resolved_write_line sby; /* Standby callback */
|
||||
int sby_line; /* Standby line state */
|
||||
INT16 *cur_buf; /* Current sound buffer. */
|
||||
int cur_len; /* Fullness of current sound buffer. */
|
||||
@ -767,7 +767,7 @@ static void sp0256_micro(struct sp0256 *sp)
|
||||
sp->ald = 0;
|
||||
for (i = 0; i < 16; i++)
|
||||
sp->filt.r[i] = 0;
|
||||
if( sp->drq) sp->drq(sp->device, ASSERT_LINE);
|
||||
devcb_call_write_line(&sp->drq, 1);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
@ -781,7 +781,7 @@ static void sp0256_micro(struct sp0256 *sp)
|
||||
for (i = 0; i < 16; i++)
|
||||
sp->filt.r[i] = 0;
|
||||
|
||||
SET_SBY(ASSERT_LINE)
|
||||
SET_SBY(1)
|
||||
|
||||
return;
|
||||
}
|
||||
@ -1175,10 +1175,10 @@ static SND_START( sp0256 )
|
||||
struct sp0256 *sp = device->token;
|
||||
|
||||
sp->device = device;
|
||||
sp->drq = intf->lrq_callback;
|
||||
sp->sby = intf->sby_callback;
|
||||
if( sp->drq ) sp->drq(device, ASSERT_LINE);
|
||||
if( sp->sby ) sp->sby(device, sp->sby_line = ASSERT_LINE);
|
||||
devcb_resolve_write_line(&sp->drq, &intf->lrq_callback, device);
|
||||
devcb_resolve_write_line(&sp->sby, &intf->sby_callback, device);
|
||||
devcb_call_write_line(&sp->drq, 1);
|
||||
devcb_call_write_line(&sp->sby, 1);
|
||||
|
||||
sp->stream = stream_create(device, 0, 1, clock / CLOCK_DIVIDER, sp, sp0256_update);
|
||||
|
||||
@ -1234,8 +1234,8 @@ static void sp0256_reset(struct sp0256 *sp)
|
||||
sp->mode = 0;
|
||||
sp->page = 0x1000 << 3;
|
||||
sp->silent = 1;
|
||||
if( sp->drq ) sp->drq(sp->device, ASSERT_LINE);
|
||||
SET_SBY(ASSERT_LINE)
|
||||
devcb_call_write_line(&sp->drq, 1);
|
||||
SET_SBY(1)
|
||||
}
|
||||
|
||||
static SND_RESET( sp0256 )
|
||||
@ -1263,8 +1263,8 @@ WRITE8_HANDLER( sp0256_ALD_w )
|
||||
/* ---------------------------------------------------------------- */
|
||||
sp->lrq = 0;
|
||||
sp->ald = (0xFF & data) << 4;
|
||||
if( sp->drq ) sp->drq(sp->device, CLEAR_LINE);
|
||||
SET_SBY(CLEAR_LINE)
|
||||
devcb_call_write_line(&sp->drq, 0);
|
||||
SET_SBY(0)
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef __SP0256_H__
|
||||
#define __SP0256_H__
|
||||
|
||||
#include "devcb.h"
|
||||
|
||||
/*
|
||||
GI SP0256 Narrator Speech Processor
|
||||
|
||||
@ -24,9 +26,10 @@
|
||||
*/
|
||||
|
||||
typedef struct _sp0256_interface sp0256_interface;
|
||||
struct _sp0256_interface {
|
||||
void (*lrq_callback)(const device_config *device, int state);
|
||||
void (*sby_callback)(const device_config *device, int state);
|
||||
struct _sp0256_interface
|
||||
{
|
||||
devcb_write_line lrq_callback;
|
||||
devcb_write_line sby_callback;
|
||||
};
|
||||
|
||||
void sp0256_bitrevbuff(UINT8 *buffer, unsigned int start, unsigned int length);
|
||||
|
@ -135,12 +135,6 @@ static WRITE8_HANDLER( adpcm_w )
|
||||
sp0256_ALD_w(space, 0, data);
|
||||
}
|
||||
|
||||
static void lrq_callback(const device_config *device, int state)
|
||||
{
|
||||
//cpu_set_input_line(device->machine->cpu[1], INPUT_LINE_NMI, PULSE_LINE);
|
||||
cpu_set_input_line(device->machine->cpu[1], INPUT_LINE_NMI, state);
|
||||
}
|
||||
|
||||
static ADDRESS_MAP_START( sauro_readmem, ADDRESS_SPACE_PROGRAM, 8 )
|
||||
AM_RANGE(0x0000, 0xdfff) AM_READ(SMH_ROM)
|
||||
AM_RANGE(0xe000, 0xebff) AM_READ(SMH_RAM)
|
||||
@ -336,8 +330,8 @@ static const gfx_layout sauro_spritelayout =
|
||||
|
||||
static const sp0256_interface sauro_sp256 =
|
||||
{
|
||||
lrq_callback,
|
||||
0
|
||||
DEVCB_CPU_INPUT_LINE("audio", INPUT_LINE_NMI),
|
||||
DEVCB_NULL
|
||||
};
|
||||
|
||||
static GFXDECODE_START( sauro )
|
||||
|
Loading…
Reference in New Issue
Block a user