From 0f6f7ba8420510cf7b65ae4ea9bfb9dd859cb6e4 Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Fri, 1 Jan 2010 00:18:16 +0000 Subject: [PATCH] Converted RSP callbacks into device callbacks. Removed a ton of tag-based queries in favor of using the device passed. --- src/emu/cpu/rsp/rsp.h | 8 ++-- src/emu/cpu/rsp/rspdrc.c | 8 ++-- src/mame/drivers/aleck64.c | 4 +- src/mame/includes/n64.h | 8 ++-- src/mame/machine/n64.c | 94 ++++++++++++++++++++------------------ 5 files changed, 63 insertions(+), 59 deletions(-) diff --git a/src/emu/cpu/rsp/rsp.h b/src/emu/cpu/rsp/rsp.h index a9a71d32141..8065c1c43f1 100644 --- a/src/emu/cpu/rsp/rsp.h +++ b/src/emu/cpu/rsp/rsp.h @@ -74,10 +74,10 @@ typedef void (*rsp_set_status_func)(const device_config *device, UINT32 status); typedef struct _rsp_config rsp_config; struct _rsp_config { - read32_space_func dp_reg_r; - write32_space_func dp_reg_w; - read32_space_func sp_reg_r; - write32_space_func sp_reg_w; + read32_device_func dp_reg_r; + write32_device_func dp_reg_w; + read32_device_func sp_reg_r; + write32_device_func sp_reg_w; rsp_set_status_func sp_set_status; }; diff --git a/src/emu/cpu/rsp/rspdrc.c b/src/emu/cpu/rsp/rspdrc.c index 00be607e142..8186fb2512f 100644 --- a/src/emu/cpu/rsp/rspdrc.c +++ b/src/emu/cpu/rsp/rspdrc.c @@ -579,14 +579,14 @@ static void cfunc_get_cop0_reg(void *param) { if(dest) { - rsp->r[dest] = (rsp->config->sp_reg_r)(rsp->program, reg, 0x00000000); + rsp->r[dest] = (rsp->config->sp_reg_r)(rsp->device, reg, 0x00000000); } } else if (reg >= 8 && reg < 16) { if(dest) { - rsp->r[dest] = (rsp->config->dp_reg_r)(rsp->program, reg - 8, 0x00000000); + rsp->r[dest] = (rsp->config->dp_reg_r)(rsp->device, reg - 8, 0x00000000); } } else @@ -603,11 +603,11 @@ static void cfunc_set_cop0_reg(void *param) if (reg >= 0 && reg < 8) { - (rsp->config->sp_reg_w)(rsp->program, reg, data, 0x00000000); + (rsp->config->sp_reg_w)(rsp->device, reg, data, 0x00000000); } else if (reg >= 8 && reg < 16) { - (rsp->config->dp_reg_w)(rsp->program, reg - 8, data, 0x00000000); + (rsp->config->dp_reg_w)(rsp->device, reg - 8, data, 0x00000000); } else { diff --git a/src/mame/drivers/aleck64.c b/src/mame/drivers/aleck64.c index 1dae8fd7401..8a26cc934ca 100644 --- a/src/mame/drivers/aleck64.c +++ b/src/mame/drivers/aleck64.c @@ -186,8 +186,8 @@ static ADDRESS_MAP_START( n64_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x00000000, 0x007fffff) AM_RAM AM_BASE(&rdram) // RDRAM AM_RANGE(0x04000000, 0x04000fff) AM_RAM AM_SHARE("dmem") // RSP DMEM AM_RANGE(0x04001000, 0x04001fff) AM_RAM AM_SHARE("imem") // RSP IMEM - AM_RANGE(0x04040000, 0x040fffff) AM_READWRITE(n64_sp_reg_r, n64_sp_reg_w) // RSP - AM_RANGE(0x04100000, 0x041fffff) AM_READWRITE(n64_dp_reg_r, n64_dp_reg_w) // RDP + AM_RANGE(0x04040000, 0x040fffff) AM_DEVREADWRITE("rsp", n64_sp_reg_r, n64_sp_reg_w) // RSP + AM_RANGE(0x04100000, 0x041fffff) AM_DEVREADWRITE("rsp", n64_dp_reg_r, n64_dp_reg_w) // RDP AM_RANGE(0x04300000, 0x043fffff) AM_READWRITE(n64_mi_reg_r, n64_mi_reg_w) // MIPS Interface AM_RANGE(0x04400000, 0x044fffff) AM_READWRITE(n64_vi_reg_r, n64_vi_reg_w) // Video Interface AM_RANGE(0x04500000, 0x045fffff) AM_READWRITE(n64_ai_reg_r, n64_ai_reg_w) // Audio Interface diff --git a/src/mame/includes/n64.h b/src/mame/includes/n64.h index 5c9d18c2d4f..629eb68dbcd 100644 --- a/src/mame/includes/n64.h +++ b/src/mame/includes/n64.h @@ -79,10 +79,10 @@ extern READ32_HANDLER( n64_rdram_reg_r ); extern WRITE32_HANDLER( n64_rdram_reg_w ); extern READ32_HANDLER( n64_mi_reg_r ); extern WRITE32_HANDLER( n64_mi_reg_w ); -extern READ32_HANDLER( n64_sp_reg_r ); -extern WRITE32_HANDLER( n64_sp_reg_w ); -extern READ32_HANDLER( n64_dp_reg_r ); -extern WRITE32_HANDLER( n64_dp_reg_w ); +extern READ32_DEVICE_HANDLER( n64_sp_reg_r ); +extern WRITE32_DEVICE_HANDLER( n64_sp_reg_w ); +extern READ32_DEVICE_HANDLER( n64_dp_reg_r ); +extern WRITE32_DEVICE_HANDLER( n64_dp_reg_w ); extern READ32_HANDLER( n64_vi_reg_r ); extern WRITE32_HANDLER( n64_vi_reg_w ); extern READ32_HANDLER( n64_ai_reg_r ); diff --git a/src/mame/machine/n64.c b/src/mame/machine/n64.c index ce06d32c592..f60fc3f6b0f 100644 --- a/src/mame/machine/n64.c +++ b/src/mame/machine/n64.c @@ -442,7 +442,7 @@ static void sp_set_status(const device_config *device, UINT32 status) } } -READ32_HANDLER( n64_sp_reg_r ) +READ32_DEVICE_HANDLER( n64_sp_reg_r ) { switch (offset) { @@ -456,7 +456,7 @@ READ32_HANDLER( n64_sp_reg_r ) return (sp_dma_skip << 20) | (sp_dma_count << 12) | sp_dma_length; case 0x10/4: // SP_STATUS_REG - return cpu_get_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR); + return cpu_get_reg(device, RSP_SR); case 0x14/4: // SP_DMA_FULL_REG return 0; @@ -490,17 +490,17 @@ READ32_HANDLER( n64_sp_reg_r ) return ++dp_clock; case 0x40000/4: // PC - return cpu_get_reg(cputag_get_cpu(space->machine, "rsp"), RSP_PC) & 0x00000fff; + return cpu_get_reg(device, RSP_PC) & 0x00000fff; default: - logerror("sp_reg_r: %08X, %08X at %08X\n", offset, mem_mask, cpu_get_pc(space->cpu)); + logerror("sp_reg_r: %08X, %08X at %08X\n", offset, mem_mask, cpu_get_pc(device)); break; } return 0; } -WRITE32_HANDLER( n64_sp_reg_w ) +WRITE32_DEVICE_HANDLER( n64_sp_reg_w ) { if ((offset & 0x10000) == 0) { @@ -530,16 +530,19 @@ WRITE32_HANDLER( n64_sp_reg_w ) case 0x10/4: // RSP_STATUS_REG { + UINT32 oldstatus = cpu_get_reg(device, RSP_SR); + UINT32 newstatus = oldstatus; + // printf( "RSP_STATUS_REG Write; %08x\n", data ); if (data & 0x00000001) // clear halt { //if (first_rsp) //{ - // cpu_spinuntil_trigger(space->cpu, 6789); + // cpu_spinuntil_trigger(device, 6789); // printf( "Clearing RSP_STATUS_HALT\n" ); - cputag_set_input_line(space->machine, "rsp", INPUT_LINE_HALT, CLEAR_LINE); - cpu_set_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR, cpu_get_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR) & ~RSP_STATUS_HALT ); + cpu_set_input_line(device, INPUT_LINE_HALT, CLEAR_LINE); + newstatus &= ~RSP_STATUS_HALT; // RSP_STATUS &= ~RSP_STATUS_HALT; //} //else @@ -550,130 +553,131 @@ WRITE32_HANDLER( n64_sp_reg_w ) if (data & 0x00000002) // set halt { // printf( "Setting RSP_STATUS_HALT\n" ); - cputag_set_input_line(space->machine, "rsp", INPUT_LINE_HALT, ASSERT_LINE); - cpu_set_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR, cpu_get_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR) | RSP_STATUS_HALT ); + cpu_set_input_line(device, INPUT_LINE_HALT, ASSERT_LINE); + newstatus |= RSP_STATUS_HALT; // RSP_STATUS |= RSP_STATUS_HALT; } if (data & 0x00000004) { //printf( "Clearing RSP_STATUS_BROKE\n" ); - cpu_set_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR, cpu_get_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR) & ~RSP_STATUS_BROKE ); + newstatus &= ~RSP_STATUS_BROKE; // RSP_STATUS &= ~RSP_STATUS_BROKE; // clear broke } if (data & 0x00000008) // clear interrupt { - clear_rcp_interrupt(space->machine, SP_INTERRUPT); + clear_rcp_interrupt(device->machine, SP_INTERRUPT); } if (data & 0x00000010) // set interrupt { - signal_rcp_interrupt(space->machine, SP_INTERRUPT); + signal_rcp_interrupt(device->machine, SP_INTERRUPT); } if (data & 0x00000020) { // printf( "Clearing RSP_STATUS_SSTEP\n" ); - cpu_set_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR, cpu_get_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR) & ~RSP_STATUS_SSTEP ); + newstatus &= ~RSP_STATUS_SSTEP; // RSP_STATUS &= ~RSP_STATUS_SSTEP; // clear single step } if (data & 0x00000040) { //printf( "Setting RSP_STATUS_SSTEP\n" ); - cpu_set_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR, cpu_get_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR) | RSP_STATUS_SSTEP ); - if( !( cpu_get_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR) & ( RSP_STATUS_BROKE | RSP_STATUS_HALT ) ) ) + newstatus |= RSP_STATUS_SSTEP; + if( !( oldstatus & ( RSP_STATUS_BROKE | RSP_STATUS_HALT ) ) ) { - cpu_set_reg(cputag_get_cpu(space->machine, "rsp"), RSP_STEPCNT, 1 ); + cpu_set_reg(device, RSP_STEPCNT, 1 ); } // RSP_STATUS |= RSP_STATUS_SSTEP; // set single step } if (data & 0x00000080) { - cpu_set_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR, cpu_get_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR) & ~RSP_STATUS_INTR_BREAK ); + newstatus &= ~RSP_STATUS_INTR_BREAK; // RSP_STATUS &= ~RSP_STATUS_INTR_BREAK; // clear interrupt on break } if (data & 0x00000100) { - cpu_set_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR, cpu_get_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR) | RSP_STATUS_INTR_BREAK ); + newstatus |= RSP_STATUS_INTR_BREAK; // RSP_STATUS |= RSP_STATUS_INTR_BREAK; // set interrupt on break } if (data & 0x00000200) { - cpu_set_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR, cpu_get_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR) & ~RSP_STATUS_SIGNAL0 ); + newstatus &= ~RSP_STATUS_SIGNAL0; // RSP_STATUS &= ~RSP_STATUS_SIGNAL0; // clear signal 0 } if (data & 0x00000400) { - cpu_set_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR, cpu_get_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR) | RSP_STATUS_SIGNAL0 ); + newstatus |= RSP_STATUS_SIGNAL0; // RSP_STATUS |= RSP_STATUS_SIGNAL0; // set signal 0 } if (data & 0x00000800) { - cpu_set_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR, cpu_get_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR) & ~RSP_STATUS_SIGNAL1 ); + newstatus &= ~RSP_STATUS_SIGNAL1; // RSP_STATUS &= ~RSP_STATUS_SIGNAL1; // clear signal 1 } if (data & 0x00001000) { - cpu_set_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR, cpu_get_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR) | RSP_STATUS_SIGNAL1 ); + newstatus |= RSP_STATUS_SIGNAL1; // RSP_STATUS |= RSP_STATUS_SIGNAL1; // set signal 1 } if (data & 0x00002000) { - cpu_set_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR, cpu_get_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR) & ~RSP_STATUS_SIGNAL2 ); + newstatus &= ~RSP_STATUS_SIGNAL2 ; // RSP_STATUS &= ~RSP_STATUS_SIGNAL2; // clear signal 2 } if (data & 0x00004000) { - cpu_set_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR, cpu_get_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR) | RSP_STATUS_SIGNAL2 ); + newstatus |= RSP_STATUS_SIGNAL2; // RSP_STATUS |= RSP_STATUS_SIGNAL2; // set signal 2 } if (data & 0x00008000) { - cpu_set_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR, cpu_get_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR) & ~RSP_STATUS_SIGNAL3 ); + newstatus &= ~RSP_STATUS_SIGNAL3; // RSP_STATUS &= ~RSP_STATUS_SIGNAL3; // clear signal 3 } if (data & 0x00010000) { - cpu_set_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR, cpu_get_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR) | RSP_STATUS_SIGNAL3 ); + newstatus |= RSP_STATUS_SIGNAL3; // RSP_STATUS |= RSP_STATUS_SIGNAL3; // set signal 3 } if (data & 0x00020000) { - cpu_set_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR, cpu_get_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR) & ~RSP_STATUS_SIGNAL4 ); + newstatus &= ~RSP_STATUS_SIGNAL4; // RSP_STATUS &= ~RSP_STATUS_SIGNAL4; // clear signal 4 } if (data & 0x00040000) { - cpu_set_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR, cpu_get_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR) | RSP_STATUS_SIGNAL4 ); + newstatus |= RSP_STATUS_SIGNAL4; // RSP_STATUS |= RSP_STATUS_SIGNAL4; // set signal 4 } if (data & 0x00080000) { - cpu_set_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR, cpu_get_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR) & ~RSP_STATUS_SIGNAL5 ); + newstatus &= ~RSP_STATUS_SIGNAL5; // RSP_STATUS &= ~RSP_STATUS_SIGNAL5; // clear signal 5 } if (data & 0x00100000) { - cpu_set_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR, cpu_get_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR) | RSP_STATUS_SIGNAL5 ); + newstatus |= RSP_STATUS_SIGNAL5; // RSP_STATUS |= RSP_STATUS_SIGNAL5; // set signal 5 } if (data & 0x00200000) { - cpu_set_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR, cpu_get_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR) & ~RSP_STATUS_SIGNAL6 ); + newstatus &= ~RSP_STATUS_SIGNAL6; // RSP_STATUS &= ~RSP_STATUS_SIGNAL6; // clear signal 6 } if (data & 0x00400000) { - cpu_set_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR, cpu_get_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR) | RSP_STATUS_SIGNAL6 ); + newstatus |= RSP_STATUS_SIGNAL6; // RSP_STATUS |= RSP_STATUS_SIGNAL6; // set signal 6 } if (data & 0x00800000) { - cpu_set_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR, cpu_get_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR) & ~RSP_STATUS_SIGNAL7 ); + newstatus &= ~RSP_STATUS_SIGNAL7; // RSP_STATUS &= ~RSP_STATUS_SIGNAL7; // clear signal 7 } if (data & 0x01000000) { - cpu_set_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR, cpu_get_reg(cputag_get_cpu(space->machine, "rsp"), RSP_SR) | RSP_STATUS_SIGNAL7 ); + newstatus |= RSP_STATUS_SIGNAL7; // RSP_STATUS |= RSP_STATUS_SIGNAL7; // set signal 7 } + cpu_set_reg(device, RSP_SR, newstatus); break; } @@ -686,7 +690,7 @@ WRITE32_HANDLER( n64_sp_reg_w ) break; default: - logerror("sp_reg_w: %08X, %08X, %08X at %08X\n", data, offset, mem_mask, cpu_get_pc(space->cpu)); + logerror("sp_reg_w: %08X, %08X, %08X at %08X\n", data, offset, mem_mask, cpu_get_pc(device)); break; } } @@ -696,18 +700,18 @@ WRITE32_HANDLER( n64_sp_reg_w ) { case 0x00/4: // SP_PC_REG //printf( "Setting PC to: %08x\n", 0x04001000 | (data & 0xfff ) ); - if( cpu_get_reg(cputag_get_cpu(space->machine, "rsp"), RSP_NEXTPC) != 0xffffffff ) + if( cpu_get_reg(device, RSP_NEXTPC) != 0xffffffff ) { - cpu_set_reg(cputag_get_cpu(space->machine, "rsp"), RSP_NEXTPC, 0x1000 | (data & 0xfff)); + cpu_set_reg(device, RSP_NEXTPC, 0x1000 | (data & 0xfff)); } else { - cpu_set_reg(cputag_get_cpu(space->machine, "rsp"), RSP_PC, 0x1000 | (data & 0xfff)); + cpu_set_reg(device, RSP_PC, 0x1000 | (data & 0xfff)); } break; default: - logerror("sp_reg_w: %08X, %08X, %08X at %08X\n", data, offset, mem_mask, cpu_get_pc(space->cpu)); + logerror("sp_reg_w: %08X, %08X, %08X at %08X\n", data, offset, mem_mask, cpu_get_pc(device)); break; } } @@ -725,7 +729,7 @@ void dp_full_sync(running_machine *machine) signal_rcp_interrupt(machine, DP_INTERRUPT); } -READ32_HANDLER( n64_dp_reg_r ) +READ32_DEVICE_HANDLER( n64_dp_reg_r ) { switch (offset) { @@ -742,14 +746,14 @@ READ32_HANDLER( n64_dp_reg_r ) return dp_status; default: - logerror("dp_reg_r: %08X, %08X at %08X\n", offset, mem_mask, cpu_get_pc(space->cpu)); + logerror("dp_reg_r: %08X, %08X at %08X\n", offset, mem_mask, cpu_get_pc(device)); break; } return 0; } -WRITE32_HANDLER( n64_dp_reg_w ) +WRITE32_DEVICE_HANDLER( n64_dp_reg_w ) { switch (offset) { @@ -760,7 +764,7 @@ WRITE32_HANDLER( n64_dp_reg_w ) case 0x04/4: // DP_END_REG dp_end = data; - rdp_process_list(space->machine); + rdp_process_list(device->machine); break; case 0x0c/4: // DP_STATUS_REG @@ -773,7 +777,7 @@ WRITE32_HANDLER( n64_dp_reg_w ) break; default: - logerror("dp_reg_w: %08X, %08X, %08X at %08X\n", data, offset, mem_mask, cpu_get_pc(space->cpu)); + logerror("dp_reg_w: %08X, %08X, %08X at %08X\n", data, offset, mem_mask, cpu_get_pc(device)); break; } }