mirror of
https://github.com/holub/mame
synced 2025-07-04 17:38:08 +03:00
Some more cases to directly access the state interface instead of using the old
cpu_* macros. Also changed the ADSP21xx callbacks to take a cpu_device.
This commit is contained in:
parent
af9e6f531f
commit
553ec7f427
@ -91,7 +91,7 @@ INLINE void update_mstat(adsp2100_state *adsp)
|
||||
}
|
||||
if ((adsp->mstat ^ adsp->mstat_prev) & MSTAT_TIMER)
|
||||
if (adsp->timer_fired != NULL)
|
||||
(*adsp->timer_fired)(adsp->device, (adsp->mstat & MSTAT_TIMER) != 0);
|
||||
(*adsp->timer_fired)(*adsp->device, (adsp->mstat & MSTAT_TIMER) != 0);
|
||||
if (adsp->mstat & MSTAT_STICKYV)
|
||||
adsp->astat_clear = ~(CFLAG | NFLAG | ZFLAG);
|
||||
else
|
||||
@ -421,8 +421,8 @@ static void wr_ifc(adsp2100_state *adsp, INT32 val)
|
||||
}
|
||||
check_irqs(adsp);
|
||||
}
|
||||
static void wr_tx0(adsp2100_state *adsp, INT32 val) { if (adsp->sport_tx_callback) (*adsp->sport_tx_callback)(adsp->device, 0, val); }
|
||||
static void wr_tx1(adsp2100_state *adsp, INT32 val) { if (adsp->sport_tx_callback) (*adsp->sport_tx_callback)(adsp->device, 1, val); }
|
||||
static void wr_tx0(adsp2100_state *adsp, INT32 val) { if (adsp->sport_tx_callback) (*adsp->sport_tx_callback)(*adsp->device, 0, val); }
|
||||
static void wr_tx1(adsp2100_state *adsp, INT32 val) { if (adsp->sport_tx_callback) (*adsp->sport_tx_callback)(*adsp->device, 1, val); }
|
||||
static void wr_owrctr(adsp2100_state *adsp, INT32 val) { adsp->cntr = val & 0x3fff; }
|
||||
static void wr_topstack(adsp2100_state *adsp, INT32 val) { pc_stack_push_val(adsp, val & 0x3fff); }
|
||||
|
||||
@ -503,8 +503,8 @@ static INT32 rd_icntl(adsp2100_state *adsp) { return adsp->icntl; }
|
||||
static INT32 rd_cntr(adsp2100_state *adsp) { return adsp->cntr; }
|
||||
static INT32 rd_sb(adsp2100_state *adsp) { return adsp->core.sb.s; }
|
||||
static INT32 rd_px(adsp2100_state *adsp) { return adsp->px; }
|
||||
static INT32 rd_rx0(adsp2100_state *adsp) { if (adsp->sport_rx_callback) return (*adsp->sport_rx_callback)(adsp->device, 0); else return 0; }
|
||||
static INT32 rd_rx1(adsp2100_state *adsp) { if (adsp->sport_rx_callback) return (*adsp->sport_rx_callback)(adsp->device, 1); else return 0; }
|
||||
static INT32 rd_rx0(adsp2100_state *adsp) { if (adsp->sport_rx_callback) return (*adsp->sport_rx_callback)(*adsp->device, 0); else return 0; }
|
||||
static INT32 rd_rx1(adsp2100_state *adsp) { if (adsp->sport_rx_callback) return (*adsp->sport_rx_callback)(*adsp->device, 1); else return 0; }
|
||||
static INT32 rd_stacktop(adsp2100_state *adsp) { return pc_stack_pop_val(adsp); }
|
||||
|
||||
#define READ_REG(adsp,grp,reg) ((*rd_reg[grp][reg])(adsp))
|
||||
|
@ -17,12 +17,11 @@
|
||||
***************************************************************************/
|
||||
|
||||
/* transmit and receive data callbacks types */
|
||||
typedef INT32 (*adsp21xx_rx_func)(running_device *device, int port);
|
||||
typedef void (*adsp21xx_tx_func)(running_device *device, int port, INT32 data);
|
||||
typedef void (*adsp21xx_timer_func)(running_device *device, int enable);
|
||||
typedef INT32 (*adsp21xx_rx_func)(cpu_device &device, int port);
|
||||
typedef void (*adsp21xx_tx_func)(cpu_device &device, int port, INT32 data);
|
||||
typedef void (*adsp21xx_timer_func)(cpu_device &device, int enable);
|
||||
|
||||
typedef struct _adsp21xx_config adsp21xx_config;
|
||||
struct _adsp21xx_config
|
||||
struct adsp21xx_config
|
||||
{
|
||||
adsp21xx_rx_func rx; /* callback for serial receive */
|
||||
adsp21xx_tx_func tx; /* callback for serial transmit */
|
||||
|
@ -2980,5 +2980,5 @@ static UINT64 get_cpu_reg(void *globalref, void *ref)
|
||||
static void set_cpu_reg(void *globalref, void *ref, UINT64 value)
|
||||
{
|
||||
cpu_device *device = (cpu_device *)globalref;
|
||||
cpu_set_reg(device, (FPTR)ref, value);
|
||||
device->state_set_value((FPTR)ref, value);
|
||||
}
|
||||
|
@ -165,9 +165,9 @@ public:
|
||||
|
||||
// state getters
|
||||
UINT64 state_value(int index);
|
||||
UINT64 pc() { return state_value(STATE_GENPC); }
|
||||
UINT64 pcbase() { return state_value(STATE_GENPCBASE); }
|
||||
UINT64 sp() { return state_value(STATE_GENSP); }
|
||||
offs_t pc() { return state_value(STATE_GENPC); }
|
||||
offs_t pcbase() { return state_value(STATE_GENPCBASE); }
|
||||
offs_t sp() { return state_value(STATE_GENSP); }
|
||||
UINT64 flags() { return state_value(STATE_GENFLAGS); }
|
||||
astring &state_string(int index, astring &dest);
|
||||
int state_string_max_length(int index);
|
||||
|
@ -474,7 +474,7 @@ static void update_control_lines(running_machine *machine)
|
||||
val &= ~0x88;
|
||||
if (cpu_to_cage_ready) val |= 0x08;
|
||||
if (cage_to_cpu_ready) val |= 0x80;
|
||||
cpu_set_reg(cage_cpu, TMS32031_IOF, val);
|
||||
cage_cpu->state_set_value(TMS32031_IOF, val);
|
||||
}
|
||||
|
||||
|
||||
|
@ -409,12 +409,12 @@ static WRITE16_HANDLER( output_latch_w );
|
||||
static READ16_HANDLER( output_control_r );
|
||||
static WRITE16_HANDLER( output_control_w );
|
||||
|
||||
static void timer_enable_callback(running_device *device, int enable);
|
||||
static void timer_enable_callback(cpu_device &device, int enable);
|
||||
static TIMER_DEVICE_CALLBACK( internal_timer_callback );
|
||||
static TIMER_DEVICE_CALLBACK( dcs_irq );
|
||||
static TIMER_DEVICE_CALLBACK( sport0_irq );
|
||||
static void recompute_sample_rate(running_machine *machine);
|
||||
static void sound_tx_callback(running_device *device, int port, INT32 data);
|
||||
static void sound_tx_callback(cpu_device &device, int port, INT32 data);
|
||||
|
||||
static READ16_HANDLER( dcs_polling_r );
|
||||
static WRITE16_HANDLER( dcs_polling_w );
|
||||
@ -1794,14 +1794,14 @@ static void reset_timer(running_machine *machine)
|
||||
}
|
||||
|
||||
|
||||
static void timer_enable_callback(running_device *device, int enable)
|
||||
static void timer_enable_callback(cpu_device &device, int enable)
|
||||
{
|
||||
dcs.timer_enable = enable;
|
||||
dcs.timer_ignore = 0;
|
||||
if (enable)
|
||||
{
|
||||
// mame_printf_debug("Timer enabled @ %d cycles/int, or %f Hz\n", dcs.timer_scale * (dcs.timer_period + 1), 1.0 / dcs.cpu->cycles_to_attotime(dcs.timer_scale * (dcs.timer_period + 1)));
|
||||
reset_timer(device->machine);
|
||||
reset_timer(device.machine);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1971,7 +1971,7 @@ static TIMER_DEVICE_CALLBACK( dcs_irq )
|
||||
}
|
||||
|
||||
/* store it */
|
||||
cpu_set_reg(dcs.cpu, ADSP2100_I0 + dcs.ireg, reg);
|
||||
dcs.cpu->state_set_value(ADSP2100_I0 + dcs.ireg, reg);
|
||||
}
|
||||
|
||||
|
||||
@ -2010,7 +2010,7 @@ static void recompute_sample_rate(running_machine *machine)
|
||||
}
|
||||
|
||||
|
||||
static void sound_tx_callback(running_device *device, int port, INT32 data)
|
||||
static void sound_tx_callback(cpu_device &device, int port, INT32 data)
|
||||
{
|
||||
/* check if it's for SPORT1 */
|
||||
if (port != 1)
|
||||
@ -2033,21 +2033,21 @@ static void sound_tx_callback(running_device *device, int port, INT32 data)
|
||||
|
||||
/* now get the register contents in a more legible format */
|
||||
/* we depend on register indexes to be continuous (wich is the case in our core) */
|
||||
source = cpu_get_reg(device, ADSP2100_I0 + dcs.ireg);
|
||||
dcs.incs = cpu_get_reg(device, ADSP2100_M0 + mreg);
|
||||
dcs.size = cpu_get_reg(device, ADSP2100_L0 + lreg);
|
||||
source = device.state_value(ADSP2100_I0 + dcs.ireg);
|
||||
dcs.incs = device.state_value(ADSP2100_M0 + mreg);
|
||||
dcs.size = device.state_value(ADSP2100_L0 + lreg);
|
||||
|
||||
/* get the base value, since we need to keep it around for wrapping */
|
||||
source -= dcs.incs;
|
||||
|
||||
/* make it go back one so we dont lose the first sample */
|
||||
cpu_set_reg(device, ADSP2100_I0 + dcs.ireg, source);
|
||||
device.state_set_value(ADSP2100_I0 + dcs.ireg, source);
|
||||
|
||||
/* save it as it is now */
|
||||
dcs.ireg_base = source;
|
||||
|
||||
/* recompute the sample rate and timer */
|
||||
recompute_sample_rate(device->machine);
|
||||
recompute_sample_rate(device.machine);
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
@ -1781,9 +1781,10 @@ static READ16_HANDLER( main_to_sound_comm_r )
|
||||
|
||||
static TIMER_CALLBACK( delayed_response_r )
|
||||
{
|
||||
cpu_device *master = machine->device<cpu_device>("master");
|
||||
int checkpc = param;
|
||||
int pc = cpu_get_reg(devtag_get_device(machine, "master"), Z80_PC);
|
||||
int oldaf = cpu_get_reg(devtag_get_device(machine, "master"), Z80_AF);
|
||||
int pc = master->pc();
|
||||
int oldaf = master->state_value(Z80_AF);
|
||||
|
||||
/* This is pretty cheesy, but necessary. Since the CPUs run in round-robin order,
|
||||
synchronizing on the write to this register from the slave side does nothing.
|
||||
@ -1796,7 +1797,7 @@ static TIMER_CALLBACK( delayed_response_r )
|
||||
if (LOG_COMM) logerror("(Updated sound response latch to %02X)\n", sound_response);
|
||||
|
||||
oldaf = (oldaf & 0x00ff) | (sound_response << 8);
|
||||
cpu_set_reg(devtag_get_device(machine, "master"), Z80_AF, oldaf);
|
||||
master->state_set_value(Z80_AF, oldaf);
|
||||
}
|
||||
else
|
||||
logerror("ERROR: delayed_response_r - current PC = %04X, checkPC = %04X\n", pc, checkpc);
|
||||
|
@ -171,7 +171,7 @@ static UINT8 adsp_ireg;
|
||||
static offs_t adsp_ireg_base, adsp_incs, adsp_size;
|
||||
static dmadac_sound_device *dmadac[SOUND_CHANNELS];
|
||||
|
||||
static void adsp_tx_callback(running_device *device, int port, INT32 data);
|
||||
static void adsp_tx_callback(cpu_device &device, int port, INT32 data);
|
||||
|
||||
|
||||
/*************************************
|
||||
@ -571,8 +571,10 @@ static WRITE16_HANDLER( adsp_rombank_w )
|
||||
|
||||
static TIMER_DEVICE_CALLBACK( adsp_autobuffer_irq )
|
||||
{
|
||||
cpu_device *adsp = timer.machine->device<cpu_device>("adsp");
|
||||
|
||||
/* get the index register */
|
||||
int reg = cpu_get_reg(devtag_get_device(timer.machine, "adsp"), ADSP2100_I0 + adsp_ireg);
|
||||
int reg = adsp->state_value(ADSP2100_I0 + adsp_ireg);
|
||||
|
||||
/* copy the current data into the buffer */
|
||||
// logerror("ADSP buffer: I%d=%04X incs=%04X size=%04X\n", adsp_ireg, reg, adsp_incs, adsp_size);
|
||||
@ -589,15 +591,15 @@ static TIMER_DEVICE_CALLBACK( adsp_autobuffer_irq )
|
||||
reg = adsp_ireg_base;
|
||||
|
||||
/* generate the (internal, thats why the pulse) irq */
|
||||
generic_pulse_irq_line(devtag_get_device(timer.machine, "adsp"), ADSP2105_IRQ1);
|
||||
generic_pulse_irq_line(adsp, ADSP2105_IRQ1);
|
||||
}
|
||||
|
||||
/* store it */
|
||||
cpu_set_reg(devtag_get_device(timer.machine, "adsp"), ADSP2100_I0 + adsp_ireg, reg);
|
||||
adsp->state_set_value(ADSP2100_I0 + adsp_ireg, reg);
|
||||
}
|
||||
|
||||
|
||||
static void adsp_tx_callback(running_device *device, int port, INT32 data)
|
||||
static void adsp_tx_callback(cpu_device &device, int port, INT32 data)
|
||||
{
|
||||
/* check if it's for SPORT1 */
|
||||
if (port != 1)
|
||||
@ -621,15 +623,15 @@ static void adsp_tx_callback(running_device *device, int port, INT32 data)
|
||||
|
||||
/* now get the register contents in a more legible format */
|
||||
/* we depend on register indexes to be continuous (wich is the case in our core) */
|
||||
source = cpu_get_reg(device, ADSP2100_I0 + adsp_ireg);
|
||||
adsp_incs = cpu_get_reg(device, ADSP2100_M0 + mreg);
|
||||
adsp_size = cpu_get_reg(device, ADSP2100_L0 + lreg);
|
||||
source = device.state_value(ADSP2100_I0 + adsp_ireg);
|
||||
adsp_incs = device.state_value(ADSP2100_M0 + mreg);
|
||||
adsp_size = device.state_value(ADSP2100_L0 + lreg);
|
||||
|
||||
/* get the base value, since we need to keep it around for wrapping */
|
||||
source -= adsp_incs;
|
||||
|
||||
/* make it go back one so we dont lose the first sample */
|
||||
cpu_set_reg(device, ADSP2100_I0 + adsp_ireg, source);
|
||||
device.state_set_value(ADSP2100_I0 + adsp_ireg, source);
|
||||
|
||||
/* save it as it is now */
|
||||
adsp_ireg_base = source;
|
||||
@ -637,7 +639,7 @@ static void adsp_tx_callback(running_device *device, int port, INT32 data)
|
||||
/* calculate how long until we generate an interrupt */
|
||||
|
||||
/* period per each bit sent */
|
||||
sample_period = attotime_mul(ATTOTIME_IN_HZ(cpu_get_clock(device)), 2 * (adsp_control_regs[S1_SCLKDIV_REG] + 1));
|
||||
sample_period = attotime_mul(ATTOTIME_IN_HZ(device.clock()), 2 * (adsp_control_regs[S1_SCLKDIV_REG] + 1));
|
||||
|
||||
/* now put it down to samples, so we know what the channel frequency has to be */
|
||||
sample_period = attotime_mul(sample_period, 16 * SOUND_CHANNELS);
|
||||
|
@ -1150,17 +1150,17 @@ READ16_HANDLER( hd68k_ds3_gdata_r )
|
||||
logerror("%06X:hd68k_ds3_gdata_r(%04X)\n", cpu_get_previouspc(space->cpu), state->ds3_gdata);
|
||||
|
||||
/* attempt to optimize the transfer if conditions are right */
|
||||
if (space->cpu == devtag_get_device(space->machine, "maincpu") && pc == state->ds3_transfer_pc &&
|
||||
if (space->cpu == state->maincpu && pc == state->ds3_transfer_pc &&
|
||||
!(!state->ds3_g68flag && state->ds3_g68irqs) && !(state->ds3_gflag && state->ds3_gfirqs))
|
||||
{
|
||||
UINT32 destaddr = cpu_get_reg(space->cpu, M68K_A1);
|
||||
UINT16 count68k = cpu_get_reg(space->cpu, M68K_D1);
|
||||
UINT16 mstat = cpu_get_reg(state->adsp, ADSP2100_MSTAT);
|
||||
UINT16 i6 = cpu_get_reg(state->adsp, (mstat & 1) ? ADSP2100_MR0 : ADSP2100_MR0_SEC);
|
||||
UINT16 l6 = cpu_get_reg(state->adsp, ADSP2100_L6) - 1;
|
||||
UINT16 m7 = cpu_get_reg(state->adsp, ADSP2100_M7);
|
||||
UINT32 destaddr = state->maincpu->state_value(M68K_A1);
|
||||
UINT16 count68k = state->maincpu->state_value(M68K_D1);
|
||||
UINT16 mstat = state->adsp->state_value(ADSP2100_MSTAT);
|
||||
UINT16 i6 = state->adsp->state_value((mstat & 1) ? ADSP2100_MR0 : ADSP2100_MR0_SEC);
|
||||
UINT16 l6 = state->adsp->state_value(ADSP2100_L6) - 1;
|
||||
UINT16 m7 = state->adsp->state_value(ADSP2100_M7);
|
||||
|
||||
logerror("%06X:optimizing 68k transfer, %d words\n", cpu_get_previouspc(space->cpu), count68k);
|
||||
logerror("%06X:optimizing 68k transfer, %d words\n", state->maincpu->pcbase(), count68k);
|
||||
|
||||
while (count68k > 0 && state->adsp_data_memory[0x16e6] > 0)
|
||||
{
|
||||
@ -1172,8 +1172,8 @@ READ16_HANDLER( hd68k_ds3_gdata_r )
|
||||
}
|
||||
count68k--;
|
||||
}
|
||||
cpu_set_reg(space->cpu, M68K_D1, count68k);
|
||||
cpu_set_reg(state->adsp, (mstat & 1) ? ADSP2100_MR0 : ADSP2100_MR0_SEC, i6);
|
||||
state->maincpu->state_set_value(M68K_D1, count68k);
|
||||
state->adsp->state_set_value((mstat & 1) ? ADSP2100_MR0 : ADSP2100_MR0_SEC, i6);
|
||||
state->adsp_speedup_count[1]++;
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ void cinemat_vector_callback(running_device *device, INT16 sx, INT16 sy, INT16 e
|
||||
WRITE8_HANDLER(cinemat_vector_control_w)
|
||||
{
|
||||
int r, g, b, i;
|
||||
running_device *cpu = devtag_get_device(space->machine, "maincpu");
|
||||
cpu_device *cpu = space->machine->device<cpu_device>("maincpu");
|
||||
|
||||
switch (color_mode)
|
||||
{
|
||||
@ -98,7 +98,7 @@ WRITE8_HANDLER(cinemat_vector_control_w)
|
||||
/* X register as the intensity */
|
||||
if (data != last_control && data)
|
||||
{
|
||||
int xval = cpu_get_reg(cpu, CCPU_X) & 0x0f;
|
||||
int xval = cpu->state_value(CCPU_X) & 0x0f;
|
||||
i = (xval + 1) * 255 / 16;
|
||||
vector_color = MAKE_RGB(i,i,i);
|
||||
}
|
||||
@ -109,7 +109,7 @@ WRITE8_HANDLER(cinemat_vector_control_w)
|
||||
/* X register as the intensity */
|
||||
if (data != last_control && data)
|
||||
{
|
||||
int xval = cpu_get_reg(cpu, CCPU_X);
|
||||
int xval = cpu->state_value(CCPU_X);
|
||||
xval = (~xval >> 2) & 0x3f;
|
||||
i = (xval + 1) * 255 / 64;
|
||||
vector_color = MAKE_RGB(i,i,i);
|
||||
@ -121,7 +121,7 @@ WRITE8_HANDLER(cinemat_vector_control_w)
|
||||
/* as 4-4-4 BGR values */
|
||||
if (data != last_control && data)
|
||||
{
|
||||
int xval = cpu_get_reg(cpu, CCPU_X);
|
||||
int xval = cpu->state_value(CCPU_X);
|
||||
r = (~xval >> 0) & 0x0f;
|
||||
r = r * 255 / 15;
|
||||
g = (~xval >> 4) & 0x0f;
|
||||
@ -142,15 +142,15 @@ WRITE8_HANDLER(cinemat_vector_control_w)
|
||||
/* on an IV instruction if data == 0 here */
|
||||
if (data != last_control && !data)
|
||||
{
|
||||
lastx = cpu_get_reg(cpu, CCPU_X);
|
||||
lasty = cpu_get_reg(cpu, CCPU_Y);
|
||||
lastx = cpu->state_value(CCPU_X);
|
||||
lasty = cpu->state_value(CCPU_Y);
|
||||
}
|
||||
|
||||
/* on the rising edge of the data value, latch the Y register */
|
||||
/* as 2-3-3 BGR values */
|
||||
if (data != last_control && data)
|
||||
{
|
||||
int yval = cpu_get_reg(cpu, CCPU_Y);
|
||||
int yval = cpu->state_value(CCPU_Y);
|
||||
r = (~yval >> 0) & 0x07;
|
||||
r = r * 255 / 7;
|
||||
g = (~yval >> 3) & 0x07;
|
||||
@ -160,8 +160,8 @@ WRITE8_HANDLER(cinemat_vector_control_w)
|
||||
vector_color = MAKE_RGB(r,g,b);
|
||||
|
||||
/* restore the original X,Y values */
|
||||
cpu_set_reg(cpu, CCPU_X, lastx);
|
||||
cpu_set_reg(cpu, CCPU_Y, lasty);
|
||||
cpu->state_set_value(CCPU_X, lastx);
|
||||
cpu->state_set_value(CCPU_Y, lasty);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user