mirror of
https://github.com/holub/mame
synced 2025-05-19 03:59:35 +03:00
8257dma and z80dma devices now require device callback handlers instead of machine handlers.
Updated affected drivers accordingly.
This commit is contained in:
parent
25379f0b5a
commit
54da9f29bd
@ -15,6 +15,7 @@
|
|||||||
#include "debugger.h"
|
#include "debugger.h"
|
||||||
#include "s2650.h"
|
#include "s2650.h"
|
||||||
#include "s2650cpu.h"
|
#include "s2650cpu.h"
|
||||||
|
#include "deprecat.h"
|
||||||
|
|
||||||
/* define this to have some interrupt information logged */
|
/* define this to have some interrupt information logged */
|
||||||
#define VERBOSE 0
|
#define VERBOSE 0
|
||||||
@ -40,6 +41,7 @@ typedef struct {
|
|||||||
UINT16 ras[8]; /* 8 return address stack entries */
|
UINT16 ras[8]; /* 8 return address stack entries */
|
||||||
UINT8 irq_state;
|
UINT8 irq_state;
|
||||||
int (*irq_callback)(int irqline);
|
int (*irq_callback)(int irqline);
|
||||||
|
read16_machine_func addr_rewrite;
|
||||||
} s2650_Regs;
|
} s2650_Regs;
|
||||||
|
|
||||||
static s2650_Regs S;
|
static s2650_Regs S;
|
||||||
@ -170,7 +172,7 @@ static void s2650_set_sense(int state);
|
|||||||
***************************************************************/
|
***************************************************************/
|
||||||
INLINE UINT8 ROP(void)
|
INLINE UINT8 ROP(void)
|
||||||
{
|
{
|
||||||
UINT8 result = cpu_readop(S.page + S.iar);
|
UINT8 result = cpu_readop(S.addr_rewrite(Machine, S.page + S.iar, 0));
|
||||||
S.iar = (S.iar + 1) & PMSK;
|
S.iar = (S.iar + 1) & PMSK;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -181,7 +183,7 @@ INLINE UINT8 ROP(void)
|
|||||||
***************************************************************/
|
***************************************************************/
|
||||||
INLINE UINT8 ARG(void)
|
INLINE UINT8 ARG(void)
|
||||||
{
|
{
|
||||||
UINT8 result = cpu_readop_arg(S.page + S.iar);
|
UINT8 result = cpu_readop_arg(S.addr_rewrite(Machine, S.page + S.iar, 0));
|
||||||
S.iar = (S.iar + 1) & PMSK;
|
S.iar = (S.iar + 1) & PMSK;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -190,7 +192,8 @@ INLINE UINT8 ARG(void)
|
|||||||
* RDMEM
|
* RDMEM
|
||||||
* read memory byte from addr
|
* read memory byte from addr
|
||||||
***************************************************************/
|
***************************************************************/
|
||||||
#define RDMEM(addr) program_read_byte_8le(addr)
|
#define RDMEM(addr) program_read_byte_8le(S.addr_rewrite(Machine, addr, 0))
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************
|
/***************************************************************
|
||||||
* handy table to build PC relative offsets
|
* handy table to build PC relative offsets
|
||||||
@ -507,7 +510,7 @@ static const int S2650_relative[0x100] =
|
|||||||
* Store source register to memory addr (CC unchanged)
|
* Store source register to memory addr (CC unchanged)
|
||||||
***************************************************************/
|
***************************************************************/
|
||||||
#define M_STR(address,source) \
|
#define M_STR(address,source) \
|
||||||
program_write_byte_8le(address, source)
|
program_write_byte_8le(S.addr_rewrite(Machine, address, 0), source)
|
||||||
|
|
||||||
/***************************************************************
|
/***************************************************************
|
||||||
* M_AND
|
* M_AND
|
||||||
@ -765,9 +768,15 @@ static void ABS_EA(void) _ABS_EA()
|
|||||||
static void BRA_EA(void) _BRA_EA()
|
static void BRA_EA(void) _BRA_EA()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static READ16_HANDLER( default_rewrite )
|
||||||
|
{
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
static void s2650_init(int index, int clock, const void *config, int (*irqcallback)(int))
|
static void s2650_init(int index, int clock, const void *config, int (*irqcallback)(int))
|
||||||
{
|
{
|
||||||
S.irq_callback = irqcallback;
|
S.irq_callback = irqcallback;
|
||||||
|
S.addr_rewrite = (config ? config : &default_rewrite );
|
||||||
|
|
||||||
state_save_register_item("s2650", index, S.ppc);
|
state_save_register_item("s2650", index, S.ppc);
|
||||||
state_save_register_item("s2650", index, S.page);
|
state_save_register_item("s2650", index, S.page);
|
||||||
@ -786,8 +795,10 @@ static void s2650_init(int index, int clock, const void *config, int (*irqcallba
|
|||||||
static void s2650_reset(void)
|
static void s2650_reset(void)
|
||||||
{
|
{
|
||||||
int (*save_irqcallback)(int) = S.irq_callback;
|
int (*save_irqcallback)(int) = S.irq_callback;
|
||||||
|
read16_machine_func save_addr_rewrite = S.addr_rewrite;
|
||||||
memset(&S, 0, sizeof(S));
|
memset(&S, 0, sizeof(S));
|
||||||
S.irq_callback = save_irqcallback;
|
S.irq_callback = save_irqcallback;
|
||||||
|
S.addr_rewrite = save_addr_rewrite;
|
||||||
S.psl = COM | WC;
|
S.psl = COM | WC;
|
||||||
S.psu = 0;
|
S.psu = 0;
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ struct _dma8257_t
|
|||||||
|
|
||||||
static TIMER_CALLBACK( dma8257_timerproc );
|
static TIMER_CALLBACK( dma8257_timerproc );
|
||||||
static TIMER_CALLBACK( dma8257_msbflip_timerproc );
|
static TIMER_CALLBACK( dma8257_msbflip_timerproc );
|
||||||
static void dma8257_update_status(running_machine *machine, dma8257_t *dma8257);
|
static void dma8257_update_status(const device_config *device);
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
@ -76,8 +76,9 @@ INLINE dma8257_t *get_safe_token(const device_config *device) {
|
|||||||
return ( dma8257_t * ) device->token;
|
return ( dma8257_t * ) device->token;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dma8257_do_operation(running_machine *machine, dma8257_t *dma8257, int channel)
|
static int dma8257_do_operation(const device_config *device, int channel)
|
||||||
{
|
{
|
||||||
|
dma8257_t *dma8257 = get_safe_token(device);
|
||||||
int done;
|
int done;
|
||||||
UINT8 data;
|
UINT8 data;
|
||||||
UINT8 mode;
|
UINT8 mode;
|
||||||
@ -87,18 +88,18 @@ static int dma8257_do_operation(running_machine *machine, dma8257_t *dma8257, in
|
|||||||
{
|
{
|
||||||
dma8257->status |= (0x01 << channel);
|
dma8257->status |= (0x01 << channel);
|
||||||
if (dma8257->intf->out_tc[channel])
|
if (dma8257->intf->out_tc[channel])
|
||||||
dma8257->intf->out_tc[channel](machine, 0, ASSERT_LINE);
|
dma8257->intf->out_tc[channel](device, 0, ASSERT_LINE);
|
||||||
}
|
}
|
||||||
switch(mode) {
|
switch(mode) {
|
||||||
case 1:
|
case 1:
|
||||||
if (dma8257->intf->memory_read!=NULL) {
|
if (dma8257->intf->memory_read!=NULL) {
|
||||||
data = dma8257->intf->memory_read(machine, dma8257->address[channel]);
|
data = dma8257->intf->memory_read(device, dma8257->address[channel]);
|
||||||
} else {
|
} else {
|
||||||
data = 0;
|
data = 0;
|
||||||
logerror("8257: No memory read function defined.\n");
|
logerror("8257: No memory read function defined.\n");
|
||||||
}
|
}
|
||||||
if (dma8257->intf->channel_write[channel]!=NULL) {
|
if (dma8257->intf->channel_write[channel]!=NULL) {
|
||||||
dma8257->intf->channel_write[channel](machine, 0, data);
|
dma8257->intf->channel_write[channel](device, 0, data);
|
||||||
} else {
|
} else {
|
||||||
logerror("8257: No channel write function for channel %d defined.\n",channel);
|
logerror("8257: No channel write function for channel %d defined.\n",channel);
|
||||||
}
|
}
|
||||||
@ -110,14 +111,14 @@ static int dma8257_do_operation(running_machine *machine, dma8257_t *dma8257, in
|
|||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
if (dma8257->intf->channel_read[channel]!=NULL) {
|
if (dma8257->intf->channel_read[channel]!=NULL) {
|
||||||
data = dma8257->intf->channel_read[channel](machine, 0);
|
data = dma8257->intf->channel_read[channel](device, 0);
|
||||||
} else {
|
} else {
|
||||||
data = 0;
|
data = 0;
|
||||||
logerror("8257: No channel read function for channel %d defined.\n",channel);
|
logerror("8257: No channel read function for channel %d defined.\n",channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dma8257->intf->memory_write!=NULL) {
|
if (dma8257->intf->memory_write!=NULL) {
|
||||||
dma8257->intf->memory_write(machine, dma8257->address[channel], data);
|
dma8257->intf->memory_write(device, dma8257->address[channel], data);
|
||||||
} else {
|
} else {
|
||||||
logerror("8257: No memory write function defined.\n");
|
logerror("8257: No memory write function defined.\n");
|
||||||
}
|
}
|
||||||
@ -143,7 +144,7 @@ static int dma8257_do_operation(running_machine *machine, dma8257_t *dma8257, in
|
|||||||
dma8257->registers[5] = dma8257->registers[7];
|
dma8257->registers[5] = dma8257->registers[7];
|
||||||
}
|
}
|
||||||
if (dma8257->intf->out_tc[channel])
|
if (dma8257->intf->out_tc[channel])
|
||||||
dma8257->intf->out_tc[channel](machine, 0, CLEAR_LINE);
|
dma8257->intf->out_tc[channel](device, 0, CLEAR_LINE);
|
||||||
}
|
}
|
||||||
return done;
|
return done;
|
||||||
}
|
}
|
||||||
@ -152,7 +153,8 @@ static int dma8257_do_operation(running_machine *machine, dma8257_t *dma8257, in
|
|||||||
|
|
||||||
static TIMER_CALLBACK( dma8257_timerproc )
|
static TIMER_CALLBACK( dma8257_timerproc )
|
||||||
{
|
{
|
||||||
dma8257_t *dma8257 = ptr;
|
const device_config *device = ptr;
|
||||||
|
dma8257_t *dma8257 = get_safe_token(device);
|
||||||
int i, channel = 0, rr;
|
int i, channel = 0, rr;
|
||||||
int done;
|
int done;
|
||||||
|
|
||||||
@ -164,14 +166,14 @@ static TIMER_CALLBACK( dma8257_timerproc )
|
|||||||
if (dma8257->mode & dma8257->drq & (1 << channel))
|
if (dma8257->mode & dma8257->drq & (1 << channel))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
done = dma8257_do_operation(machine, dma8257, channel);
|
done = dma8257_do_operation(device, channel);
|
||||||
|
|
||||||
dma8257->rr = (channel + 1) & 0x03;
|
dma8257->rr = (channel + 1) & 0x03;
|
||||||
|
|
||||||
if (done)
|
if (done)
|
||||||
{
|
{
|
||||||
dma8257->drq &= ~(0x01 << channel);
|
dma8257->drq &= ~(0x01 << channel);
|
||||||
dma8257_update_status(machine, dma8257);
|
dma8257_update_status(device);
|
||||||
if (!(DMA_MODE_AUTOLOAD(dma8257->mode) && channel==2)) {
|
if (!(DMA_MODE_AUTOLOAD(dma8257->mode) && channel==2)) {
|
||||||
if (DMA_MODE_TCSTOP(dma8257->mode)) {
|
if (DMA_MODE_TCSTOP(dma8257->mode)) {
|
||||||
dma8257->mode &= ~(0x01 << channel);
|
dma8257->mode &= ~(0x01 << channel);
|
||||||
@ -184,14 +186,16 @@ static TIMER_CALLBACK( dma8257_timerproc )
|
|||||||
|
|
||||||
static TIMER_CALLBACK( dma8257_msbflip_timerproc )
|
static TIMER_CALLBACK( dma8257_msbflip_timerproc )
|
||||||
{
|
{
|
||||||
dma8257_t *dma8257 = ptr;
|
const device_config *device = ptr;
|
||||||
|
dma8257_t *dma8257 = get_safe_token(device);
|
||||||
dma8257->msb ^= 1;
|
dma8257->msb ^= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void dma8257_update_status(running_machine *machine, dma8257_t *dma8257)
|
static void dma8257_update_status(const device_config *device)
|
||||||
{
|
{
|
||||||
|
dma8257_t *dma8257 = get_safe_token(device);
|
||||||
UINT16 pending_transfer;
|
UINT16 pending_transfer;
|
||||||
attotime next;
|
attotime next;
|
||||||
|
|
||||||
@ -216,7 +220,7 @@ static void dma8257_update_status(running_machine *machine, dma8257_t *dma8257)
|
|||||||
/* set the halt line */
|
/* set the halt line */
|
||||||
if (dma8257->intf && dma8257->intf->cpunum >= 0)
|
if (dma8257->intf && dma8257->intf->cpunum >= 0)
|
||||||
{
|
{
|
||||||
cpunum_set_input_line(machine, dma8257->intf->cpunum, INPUT_LINE_HALT,
|
cpunum_set_input_line(device->machine, dma8257->intf->cpunum, INPUT_LINE_HALT,
|
||||||
pending_transfer ? ASSERT_LINE : CLEAR_LINE);
|
pending_transfer ? ASSERT_LINE : CLEAR_LINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,9 +324,10 @@ WRITE8_DEVICE_HANDLER( dma8257_w )
|
|||||||
|
|
||||||
static TIMER_CALLBACK( dma8257_drq_write_callback )
|
static TIMER_CALLBACK( dma8257_drq_write_callback )
|
||||||
{
|
{
|
||||||
|
const device_config *device = ptr;
|
||||||
|
dma8257_t *dma8257 = get_safe_token(device);
|
||||||
int channel = param >> 1;
|
int channel = param >> 1;
|
||||||
int state = param & 0x01;
|
int state = param & 0x01;
|
||||||
dma8257_t *dma8257 = ptr;
|
|
||||||
|
|
||||||
/* normalize state */
|
/* normalize state */
|
||||||
if (state)
|
if (state)
|
||||||
@ -337,17 +342,16 @@ static TIMER_CALLBACK( dma8257_drq_write_callback )
|
|||||||
else
|
else
|
||||||
dma8257->drq &= ~(0x01 << channel);
|
dma8257->drq &= ~(0x01 << channel);
|
||||||
|
|
||||||
dma8257_update_status(machine, dma8257);
|
dma8257_update_status(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
WRITE8_DEVICE_HANDLER( dma8257_drq_w )
|
WRITE8_DEVICE_HANDLER( dma8257_drq_w )
|
||||||
{
|
{
|
||||||
dma8257_t *dma8257 = get_safe_token(device);
|
|
||||||
int param = (offset << 1) | (data ? 1 : 0);
|
int param = (offset << 1) | (data ? 1 : 0);
|
||||||
|
|
||||||
timer_call_after_resynch(dma8257, param, dma8257_drq_write_callback);
|
timer_call_after_resynch((void *) device, param, dma8257_drq_write_callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -369,8 +373,8 @@ static DEVICE_START( dma8257 )
|
|||||||
dma8257->intf = device->static_config;
|
dma8257->intf = device->static_config;
|
||||||
|
|
||||||
dma8257->status = 0x0f;
|
dma8257->status = 0x0f;
|
||||||
dma8257->timer = timer_alloc(dma8257_timerproc, dma8257);
|
dma8257->timer = timer_alloc(dma8257_timerproc, (void *) device);
|
||||||
dma8257->msbflip_timer = timer_alloc(dma8257_msbflip_timerproc, dma8257);
|
dma8257->msbflip_timer = timer_alloc(dma8257_msbflip_timerproc, (void *) device);
|
||||||
|
|
||||||
state_save_combine_module_and_tag(unique_tag, "dma8257", device->tag);
|
state_save_combine_module_and_tag(unique_tag, "dma8257", device->tag);
|
||||||
|
|
||||||
@ -394,7 +398,7 @@ static DEVICE_RESET( dma8257 )
|
|||||||
|
|
||||||
dma8257->status &= 0xf0;
|
dma8257->status &= 0xf0;
|
||||||
dma8257->mode = 0;
|
dma8257->mode = 0;
|
||||||
dma8257_update_status(device->machine, dma8257 );
|
dma8257_update_status(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,15 +28,15 @@ struct _dma8257_interface
|
|||||||
int clockhz;
|
int clockhz;
|
||||||
|
|
||||||
/* accessors to main memory */
|
/* accessors to main memory */
|
||||||
read8_machine_func memory_read;
|
read8_device_func memory_read;
|
||||||
write8_machine_func memory_write;
|
write8_device_func memory_write;
|
||||||
|
|
||||||
/* channel accesors */
|
/* channel accesors */
|
||||||
read8_machine_func channel_read[DMA8257_NUM_CHANNELS];
|
read8_device_func channel_read[DMA8257_NUM_CHANNELS];
|
||||||
write8_machine_func channel_write[DMA8257_NUM_CHANNELS];
|
write8_device_func channel_write[DMA8257_NUM_CHANNELS];
|
||||||
|
|
||||||
/* function to call when DMA completes */
|
/* function to call when DMA completes */
|
||||||
write8_machine_func out_tc[DMA8257_NUM_CHANNELS];
|
write8_device_func out_tc[DMA8257_NUM_CHANNELS];
|
||||||
};
|
};
|
||||||
|
|
||||||
/* device interface */
|
/* device interface */
|
||||||
|
@ -88,7 +88,6 @@
|
|||||||
typedef struct _z80dma_t z80dma_t;
|
typedef struct _z80dma_t z80dma_t;
|
||||||
struct _z80dma_t
|
struct _z80dma_t
|
||||||
{
|
{
|
||||||
running_machine *machine;
|
|
||||||
const z80dma_interface *intf;
|
const z80dma_interface *intf;
|
||||||
emu_timer *timer;
|
emu_timer *timer;
|
||||||
|
|
||||||
@ -111,7 +110,7 @@ struct _z80dma_t
|
|||||||
};
|
};
|
||||||
|
|
||||||
static TIMER_CALLBACK( z80dma_timerproc );
|
static TIMER_CALLBACK( z80dma_timerproc );
|
||||||
static void z80dma_update_status(running_machine *machine, z80dma_t *z80dma);
|
static void z80dma_update_status(const device_config *device);
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
@ -122,8 +121,9 @@ INLINE z80dma_t *get_safe_token(const device_config *device) {
|
|||||||
return ( z80dma_t * ) device->token;
|
return ( z80dma_t * ) device->token;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void z80dma_do_read(z80dma_t *cntx)
|
static void z80dma_do_read(const device_config *device)
|
||||||
{
|
{
|
||||||
|
z80dma_t *cntx = get_safe_token(device);
|
||||||
UINT8 mode;
|
UINT8 mode;
|
||||||
|
|
||||||
mode = TRANSFER_MODE(cntx);
|
mode = TRANSFER_MODE(cntx);
|
||||||
@ -132,17 +132,17 @@ static void z80dma_do_read(z80dma_t *cntx)
|
|||||||
if (PORTA_IS_SOURCE(cntx))
|
if (PORTA_IS_SOURCE(cntx))
|
||||||
{
|
{
|
||||||
if (PORTA_MEMORY(cntx))
|
if (PORTA_MEMORY(cntx))
|
||||||
cntx->latch = cntx->intf->memory_read(cntx->machine, cntx->addressA);
|
cntx->latch = cntx->intf->memory_read(device, cntx->addressA);
|
||||||
else
|
else
|
||||||
cntx->latch = cntx->intf->portA_read(cntx->machine, cntx->addressA);
|
cntx->latch = cntx->intf->portA_read(device, cntx->addressA);
|
||||||
cntx->addressA += PORTA_STEP(cntx);
|
cntx->addressA += PORTA_STEP(cntx);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (PORTB_MEMORY(cntx))
|
if (PORTB_MEMORY(cntx))
|
||||||
cntx->latch = cntx->intf->memory_read(cntx->machine, cntx->addressB);
|
cntx->latch = cntx->intf->memory_read(device, cntx->addressB);
|
||||||
else
|
else
|
||||||
cntx->latch = cntx->intf->portB_read(cntx->machine, cntx->addressB);
|
cntx->latch = cntx->intf->portB_read(device, cntx->addressB);
|
||||||
cntx->addressB += PORTB_STEP(cntx);
|
cntx->addressB += PORTB_STEP(cntx);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -153,8 +153,9 @@ static void z80dma_do_read(z80dma_t *cntx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int z80dma_do_write(z80dma_t *cntx)
|
static int z80dma_do_write(const device_config *device)
|
||||||
{
|
{
|
||||||
|
z80dma_t *cntx = get_safe_token(device);
|
||||||
int done;
|
int done;
|
||||||
UINT8 mode;
|
UINT8 mode;
|
||||||
|
|
||||||
@ -168,17 +169,17 @@ static int z80dma_do_write(z80dma_t *cntx)
|
|||||||
if (PORTA_IS_SOURCE(cntx))
|
if (PORTA_IS_SOURCE(cntx))
|
||||||
{
|
{
|
||||||
if (PORTB_MEMORY(cntx))
|
if (PORTB_MEMORY(cntx))
|
||||||
cntx->intf->memory_write(cntx->machine, cntx->addressB, cntx->latch);
|
cntx->intf->memory_write(device, cntx->addressB, cntx->latch);
|
||||||
else
|
else
|
||||||
cntx->intf->portB_write(cntx->machine, cntx->addressB, cntx->latch);
|
cntx->intf->portB_write(device, cntx->addressB, cntx->latch);
|
||||||
cntx->addressB += PORTB_STEP(cntx);
|
cntx->addressB += PORTB_STEP(cntx);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (PORTA_MEMORY(cntx))
|
if (PORTA_MEMORY(cntx))
|
||||||
cntx->intf->memory_write(cntx->machine, cntx->addressA, cntx->latch);
|
cntx->intf->memory_write(device, cntx->addressA, cntx->latch);
|
||||||
else
|
else
|
||||||
cntx->intf->portB_write(cntx->machine, cntx->addressA, cntx->latch);
|
cntx->intf->portB_write(device, cntx->addressA, cntx->latch);
|
||||||
cntx->addressA += PORTA_STEP(cntx);
|
cntx->addressA += PORTA_STEP(cntx);
|
||||||
}
|
}
|
||||||
cntx->count--;
|
cntx->count--;
|
||||||
@ -198,7 +199,8 @@ static int z80dma_do_write(z80dma_t *cntx)
|
|||||||
|
|
||||||
static TIMER_CALLBACK( z80dma_timerproc )
|
static TIMER_CALLBACK( z80dma_timerproc )
|
||||||
{
|
{
|
||||||
z80dma_t *cntx = ptr;
|
const device_config *device = ptr;
|
||||||
|
z80dma_t *cntx = get_safe_token(device);
|
||||||
int done;
|
int done;
|
||||||
|
|
||||||
if (--cntx->cur_cycle)
|
if (--cntx->cur_cycle)
|
||||||
@ -207,26 +209,27 @@ static TIMER_CALLBACK( z80dma_timerproc )
|
|||||||
}
|
}
|
||||||
if (cntx->is_read)
|
if (cntx->is_read)
|
||||||
{
|
{
|
||||||
z80dma_do_read(cntx);
|
z80dma_do_read(device);
|
||||||
done = 0;
|
done = 0;
|
||||||
cntx->is_read = 0;
|
cntx->is_read = 0;
|
||||||
cntx->cur_cycle = (PORTA_IS_SOURCE(cntx) ? PORTA_CYCLE_LEN(cntx) : PORTB_CYCLE_LEN(cntx));
|
cntx->cur_cycle = (PORTA_IS_SOURCE(cntx) ? PORTA_CYCLE_LEN(cntx) : PORTB_CYCLE_LEN(cntx));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
done = z80dma_do_write(cntx);
|
done = z80dma_do_write(device);
|
||||||
cntx->is_read = 1;
|
cntx->is_read = 1;
|
||||||
cntx->cur_cycle = (PORTB_IS_SOURCE(cntx) ? PORTA_CYCLE_LEN(cntx) : PORTB_CYCLE_LEN(cntx));
|
cntx->cur_cycle = (PORTB_IS_SOURCE(cntx) ? PORTA_CYCLE_LEN(cntx) : PORTB_CYCLE_LEN(cntx));
|
||||||
}
|
}
|
||||||
if (done)
|
if (done)
|
||||||
{
|
{
|
||||||
cntx->dma_enabled = 0; //FIXME: Correct?
|
cntx->dma_enabled = 0; //FIXME: Correct?
|
||||||
z80dma_update_status(machine, cntx);
|
z80dma_update_status(device);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void z80dma_update_status(running_machine *machine, z80dma_t *z80dma)
|
static void z80dma_update_status(const device_config *device)
|
||||||
{
|
{
|
||||||
|
z80dma_t *z80dma = get_safe_token(device);
|
||||||
UINT16 pending_transfer;
|
UINT16 pending_transfer;
|
||||||
attotime next;
|
attotime next;
|
||||||
|
|
||||||
@ -254,7 +257,7 @@ static void z80dma_update_status(running_machine *machine, z80dma_t *z80dma)
|
|||||||
if (z80dma->intf && z80dma->intf->cpunum >= 0)
|
if (z80dma->intf && z80dma->intf->cpunum >= 0)
|
||||||
{
|
{
|
||||||
//FIXME: Synchronization is done by BUSREQ!
|
//FIXME: Synchronization is done by BUSREQ!
|
||||||
cpunum_set_input_line(machine, z80dma->intf->cpunum, INPUT_LINE_HALT,
|
cpunum_set_input_line(device->machine, z80dma->intf->cpunum, INPUT_LINE_HALT,
|
||||||
pending_transfer ? ASSERT_LINE : CLEAR_LINE);
|
pending_transfer ? ASSERT_LINE : CLEAR_LINE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -385,14 +388,15 @@ WRITE8_DEVICE_HANDLER( z80dma_w )
|
|||||||
|
|
||||||
static TIMER_CALLBACK( z80dma_rdy_write_callback )
|
static TIMER_CALLBACK( z80dma_rdy_write_callback )
|
||||||
{
|
{
|
||||||
|
const device_config *device = ptr;
|
||||||
int state = param & 0x01;
|
int state = param & 0x01;
|
||||||
z80dma_t *cntx = ptr;
|
z80dma_t *cntx = get_safe_token(device);
|
||||||
|
|
||||||
/* normalize state */
|
/* normalize state */
|
||||||
cntx->rdy = 1 ^ state ^ READY_ACTIVE_HIGH(cntx);
|
cntx->rdy = 1 ^ state ^ READY_ACTIVE_HIGH(cntx);
|
||||||
cntx->status = (cntx->status & 0xFD) | (cntx->rdy<<1);
|
cntx->status = (cntx->status & 0xFD) | (cntx->rdy<<1);
|
||||||
|
|
||||||
z80dma_update_status(machine, cntx);
|
z80dma_update_status(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -405,7 +409,7 @@ WRITE8_DEVICE_HANDLER( z80dma_rdy_w)
|
|||||||
|
|
||||||
param = (data ? 1 : 0);
|
param = (data ? 1 : 0);
|
||||||
LOG(("RDY: %d Active High: %d\n", data, READY_ACTIVE_HIGH(z80dma)));
|
LOG(("RDY: %d Active High: %d\n", data, READY_ACTIVE_HIGH(z80dma)));
|
||||||
timer_call_after_resynch(z80dma, param, z80dma_rdy_write_callback);
|
timer_call_after_resynch((void *) device, param, z80dma_rdy_write_callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
@ -422,11 +426,9 @@ static DEVICE_START( z80dma )
|
|||||||
assert(device->tag != NULL);
|
assert(device->tag != NULL);
|
||||||
assert(strlen(device->tag) < 20);
|
assert(strlen(device->tag) < 20);
|
||||||
|
|
||||||
//z80dma->device_type = device_type;
|
|
||||||
z80dma->machine = device->machine;
|
|
||||||
z80dma->intf = device->static_config;
|
z80dma->intf = device->static_config;
|
||||||
|
|
||||||
z80dma->timer = timer_alloc(z80dma_timerproc, z80dma);
|
z80dma->timer = timer_alloc(z80dma_timerproc, (void *) device);
|
||||||
|
|
||||||
state_save_combine_module_and_tag(unique_tag, "z80dma", device->tag);
|
state_save_combine_module_and_tag(unique_tag, "z80dma", device->tag);
|
||||||
|
|
||||||
@ -456,7 +458,7 @@ static DEVICE_RESET( z80dma )
|
|||||||
z80dma->rdy = 0;
|
z80dma->rdy = 0;
|
||||||
z80dma->num_follow = 0;
|
z80dma->num_follow = 0;
|
||||||
z80dma->dma_enabled = 0;
|
z80dma->dma_enabled = 0;
|
||||||
z80dma_update_status(device->machine, z80dma);
|
z80dma_update_status(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,14 +19,14 @@ struct _z80dma_interface
|
|||||||
int clockhz;
|
int clockhz;
|
||||||
|
|
||||||
/* accessors to main memory */
|
/* accessors to main memory */
|
||||||
read8_machine_func memory_read;
|
read8_device_func memory_read;
|
||||||
write8_machine_func memory_write;
|
write8_device_func memory_write;
|
||||||
|
|
||||||
/* port accesors */
|
/* port accesors */
|
||||||
read8_machine_func portA_read;
|
read8_device_func portA_read;
|
||||||
write8_machine_func portA_write;
|
write8_device_func portA_write;
|
||||||
read8_machine_func portB_read;
|
read8_device_func portB_read;
|
||||||
write8_machine_func portB_write;
|
write8_device_func portB_write;
|
||||||
|
|
||||||
/* interrupt callback - not implemented */
|
/* interrupt callback - not implemented */
|
||||||
/* void (*irqcb)(int state); */
|
/* void (*irqcb)(int state); */
|
||||||
|
@ -320,12 +320,12 @@ Donkey Kong Junior Notes
|
|||||||
*
|
*
|
||||||
*************************************/
|
*************************************/
|
||||||
|
|
||||||
static READ8_HANDLER( hb_dma_read_byte );
|
static READ8_DEVICE_HANDLER( hb_dma_read_byte );
|
||||||
static WRITE8_HANDLER( hb_dma_write_byte );
|
static WRITE8_DEVICE_HANDLER( hb_dma_write_byte );
|
||||||
static READ8_HANDLER( dk_dma_read_byte );
|
static READ8_DEVICE_HANDLER( dk_dma_read_byte );
|
||||||
static WRITE8_HANDLER( dk_dma_write_byte );
|
static WRITE8_DEVICE_HANDLER( dk_dma_write_byte );
|
||||||
static READ8_HANDLER( p8257_ctl_r );
|
static READ8_DEVICE_HANDLER( p8257_ctl_r );
|
||||||
static WRITE8_HANDLER( p8257_ctl_w );
|
static WRITE8_DEVICE_HANDLER( p8257_ctl_w );
|
||||||
|
|
||||||
/*************************************
|
/*************************************
|
||||||
*
|
*
|
||||||
@ -477,7 +477,7 @@ static MACHINE_RESET( drakton )
|
|||||||
*
|
*
|
||||||
*************************************/
|
*************************************/
|
||||||
|
|
||||||
static READ8_HANDLER( dk_dma_read_byte )
|
static READ8_DEVICE_HANDLER( dk_dma_read_byte )
|
||||||
{
|
{
|
||||||
UINT8 result;
|
UINT8 result;
|
||||||
|
|
||||||
@ -488,16 +488,16 @@ static READ8_HANDLER( dk_dma_read_byte )
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static WRITE8_HANDLER( dk_dma_write_byte )
|
static WRITE8_DEVICE_HANDLER( dk_dma_write_byte )
|
||||||
{
|
{
|
||||||
cpuintrf_push_context(0);
|
cpuintrf_push_context(0);
|
||||||
program_write_byte(offset, data);
|
program_write_byte(offset, data);
|
||||||
cpuintrf_pop_context();
|
cpuintrf_pop_context();
|
||||||
}
|
}
|
||||||
|
|
||||||
static READ8_HANDLER( hb_dma_read_byte )
|
static READ8_DEVICE_HANDLER( hb_dma_read_byte )
|
||||||
{
|
{
|
||||||
dkong_state *state = machine->driver_data;
|
dkong_state *state = device->machine->driver_data;
|
||||||
int bucket = state->rev_map[(offset>>10) & 0x1ff];
|
int bucket = state->rev_map[(offset>>10) & 0x1ff];
|
||||||
int addr;
|
int addr;
|
||||||
UINT8 data;
|
UINT8 data;
|
||||||
@ -514,9 +514,9 @@ static READ8_HANDLER( hb_dma_read_byte )
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static WRITE8_HANDLER( hb_dma_write_byte )
|
static WRITE8_DEVICE_HANDLER( hb_dma_write_byte )
|
||||||
{
|
{
|
||||||
dkong_state *state = machine->driver_data;
|
dkong_state *state = device->machine->driver_data;
|
||||||
int bucket = state->rev_map[(offset>>10) & 0x1ff];
|
int bucket = state->rev_map[(offset>>10) & 0x1ff];
|
||||||
int addr;
|
int addr;
|
||||||
|
|
||||||
@ -530,15 +530,15 @@ static WRITE8_HANDLER( hb_dma_write_byte )
|
|||||||
cpuintrf_pop_context();
|
cpuintrf_pop_context();
|
||||||
}
|
}
|
||||||
|
|
||||||
static READ8_HANDLER( p8257_ctl_r )
|
static READ8_DEVICE_HANDLER( p8257_ctl_r )
|
||||||
{
|
{
|
||||||
dkong_state *state = machine->driver_data;
|
dkong_state *state = device->machine->driver_data;
|
||||||
return state->dma_latch;
|
return state->dma_latch;
|
||||||
}
|
}
|
||||||
|
|
||||||
static WRITE8_HANDLER( p8257_ctl_w )
|
static WRITE8_DEVICE_HANDLER( p8257_ctl_w )
|
||||||
{
|
{
|
||||||
dkong_state *state = machine->driver_data;
|
dkong_state *state = device->machine->driver_data;
|
||||||
state->dma_latch = data;
|
state->dma_latch = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,8 +94,8 @@ write:
|
|||||||
|
|
||||||
#include "mario.h"
|
#include "mario.h"
|
||||||
|
|
||||||
static READ8_HANDLER(mario_dma_read_byte);
|
static READ8_DEVICE_HANDLER(mario_dma_read_byte);
|
||||||
static WRITE8_HANDLER(mario_dma_write_byte);
|
static WRITE8_DEVICE_HANDLER(mario_dma_write_byte);
|
||||||
|
|
||||||
/*************************************
|
/*************************************
|
||||||
*
|
*
|
||||||
@ -125,7 +125,7 @@ static const z80dma_interface mario_dma =
|
|||||||
*
|
*
|
||||||
*************************************/
|
*************************************/
|
||||||
|
|
||||||
static READ8_HANDLER(mario_dma_read_byte)
|
static READ8_DEVICE_HANDLER(mario_dma_read_byte)
|
||||||
{
|
{
|
||||||
UINT8 result;
|
UINT8 result;
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ static READ8_HANDLER(mario_dma_read_byte)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static WRITE8_HANDLER(mario_dma_write_byte)
|
static WRITE8_DEVICE_HANDLER(mario_dma_write_byte)
|
||||||
{
|
{
|
||||||
cpuintrf_push_context(0);
|
cpuintrf_push_context(0);
|
||||||
program_write_byte(offset, data);
|
program_write_byte(offset, data);
|
||||||
|
Loading…
Reference in New Issue
Block a user