From c17377e8a90354d19f9b18adb6acdf04c75faa59 Mon Sep 17 00:00:00 2001 From: Andrew Gardner Date: Sun, 21 Dec 2008 08:21:34 +0000 Subject: [PATCH] Fixed update_handler for the dsp56k and polygonet. [Andrew Gardner] (The driver more or less works again. And holy moly is this thing fast with my crazy interleave values!) --- src/emu/cpu/dsp56k/dsp56k.c | 23 +++++++++++++++++++++++ src/mame/drivers/plygonet.c | 24 +++++++++++++++++------- 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/src/emu/cpu/dsp56k/dsp56k.c b/src/emu/cpu/dsp56k/dsp56k.c index e3e9557cc8c..83c4771cd49 100644 --- a/src/emu/cpu/dsp56k/dsp56k.c +++ b/src/emu/cpu/dsp56k/dsp56k.c @@ -39,12 +39,15 @@ ***************************************************************************/ static CPU_RESET( dsp56k ); + /*************************************************************************** ONBOARD MEMORY ALLOCATION ***************************************************************************/ +// TODO: Put these in the cpustate!!! static UINT16 *dsp56k_peripheral_ram; static UINT16 *dsp56k_program_ram; + /*************************************************************************** COMPONENT FUNCTIONALITY ***************************************************************************/ @@ -63,6 +66,22 @@ static UINT16 *dsp56k_program_ram; // 4-8 Memory handlers for on-chip peripheral memory. #include "dsp56mem.c" + +/*************************************************************************** + Direct Update Handler +***************************************************************************/ +static DIRECT_UPDATE_HANDLER( dsp56k_direct_handler ) +{ + if (address >= (0x0000<<1) && address <= (0x07ff<<1)) + { + direct->raw = direct->decrypted = (void*)(dsp56k_program_ram - (0x0000<<1)); + return ~0; + } + + return address; +} + + /*************************************************************************** MEMORY ACCESSORS ***************************************************************************/ @@ -172,6 +191,10 @@ static CPU_INIT( dsp56k ) cpustate->device = device; cpustate->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM); cpustate->data = memory_find_address_space(device, ADDRESS_SPACE_DATA); + + /* Setup the direct memory handler for this CPU */ + /* NOTE: Be sure to grab this guy and call him if you ever install another direct_update_hander in a driver! */ + memory_set_direct_update_handler(cpustate->program, dsp56k_direct_handler); } static void agu_reset(dsp56k_core* cpustate) diff --git a/src/mame/drivers/plygonet.c b/src/mame/drivers/plygonet.c index e279cdb797c..593a9798178 100644 --- a/src/mame/drivers/plygonet.c +++ b/src/mame/drivers/plygonet.c @@ -105,6 +105,8 @@ static const UINT16 dsp56k_bank02_size = 0x4000; static UINT16* dsp56k_bank02_r static const UINT16 dsp56k_shared_ram_16_size = 0x2000; static UINT16* dsp56k_shared_ram_16; static const UINT16 dsp56k_bank04_size = 0x1fc0; static UINT16* dsp56k_bank04_ram; +static direct_update_func dsp56k_update_handler = NULL; + static const eeprom_interface eeprom_intf = { 7, /* address bits */ @@ -230,7 +232,7 @@ static READ32_HANDLER( dsp_host_interface_r ) if (mem_mask == 0x0000ff00) { hi_addr++; } /* Low byte */ if (mem_mask == 0xff000000) {} /* High byte */ - value = dsp56k_host_interface_read((device_config*)space->cpu, hi_addr); + value = dsp56k_host_interface_read((device_config*)cputag_get_cpu(space->machine, "dsp"), hi_addr); if (mem_mask == 0x0000ff00) { value <<= 8; } if (mem_mask == 0xff000000) { value <<= 24; } @@ -300,7 +302,7 @@ static WRITE32_HANDLER( dsp_host_interface_w ) if (mem_mask == 0xff000000) { hi_data = (data & 0xff000000) >> 24; } logerror("write (host-side) %08x %08x %08x (HI %04x)\n", offset, mem_mask, data, hi_addr); - dsp56k_host_interface_write((device_config*)space->cpu, hi_addr, hi_data); + dsp56k_host_interface_write((device_config*)cputag_get_cpu(space->machine, "dsp"), hi_addr, hi_data); } @@ -321,14 +323,22 @@ static READ16_HANDLER( dsp56k_bootload_r ) static DIRECT_UPDATE_HANDLER( plygonet_dsp56k_direct_handler ) { - if (address >= 0x7000 && address <= 0x7fff) + /* Call the dsp's update handler first */ + if (dsp56k_update_handler != NULL) { - direct->raw = direct->decrypted = (void*)(dsp56k_p_mirror - 0x7000); + if ((*dsp56k_update_handler)(space, address, direct) == ~0) + return ~0; + } + + /* If the requested region wasn't in there, see if it needs to be caught driver-side */ + if (address >= (0x7000<<1) && address <= (0x7fff<<1)) + { + direct->raw = direct->decrypted = (UINT8*)(dsp56k_p_mirror) - (0x7000<<1); return ~0; } - else if (address >= 0x8000 && address <= 0x87ff) + else if (address >= (0x8000<<1) && address <= (0x87ff<<1)) { - direct->raw = direct->decrypted = (void*)(dsp56k_p_8000 - 0x8000); + direct->raw = direct->decrypted = (UINT8*)(dsp56k_p_8000) - (0x8000<<1); return ~0; } @@ -715,7 +725,7 @@ static DRIVER_INIT(polygonet) memset(dsp56k_bank04_ram, 0, 2 * 8 * dsp56k_bank04_size * sizeof(UINT16)); /* The dsp56k occasionally executes out of mapped memory */ - memory_set_direct_update_handler(cpu_get_address_space(machine->cpu[1], ADDRESS_SPACE_PROGRAM), plygonet_dsp56k_direct_handler); + dsp56k_update_handler = memory_set_direct_update_handler(cpu_get_address_space(machine->cpu[1], ADDRESS_SPACE_PROGRAM), plygonet_dsp56k_direct_handler); } ROM_START( plygonet )