[Core/MD] improved SVP memory handlers accuracy (fixes Virtua Racing debug mode)

This commit is contained in:
EkeEke 2016-07-09 19:46:22 +02:00
parent 36da8a2453
commit 1dac828fb5
10 changed files with 81 additions and 45 deletions

View File

@ -43,6 +43,7 @@ Genesis Plus GX 1.7.5 (xx/xx/xxxx) (Eke-Eke)
* added support for Everdrive extended SSF mapper
* improved console region auto-detection for a few PAL-only games (The Smurfs Travel the World & Williams Arcade's Greatest Hits)
* improved I2C EEPROM boards emulation accuracy
* improved SVP memory handlers accuracy (fixes Virtua Racing debug mode)
* fixed Game Genie / Pro Action Replay lock-on support when Mega CD hardware is enabled
* fixed SRAM support in Triple Play 96 & Triple Play - Gold Edition
* fixed automatic CD loading with .md ROM files

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 MiB

After

Width:  |  Height:  |  Size: 3.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 MiB

After

Width:  |  Height:  |  Size: 3.3 MiB

View File

@ -394,17 +394,6 @@ void md_cart_init(void)
if (strstr(rominfo.international,"Virtua Racing"))
{
svp_init();
m68k.memory_map[0x30].base = svp->dram;
m68k.memory_map[0x30].read16 = NULL;
m68k.memory_map[0x30].write16 = svp_write_dram;
m68k.memory_map[0x31].base = svp->dram + 0x10000;
m68k.memory_map[0x31].read16 = NULL;
m68k.memory_map[0x31].write16 = svp_write_dram;
m68k.memory_map[0x39].read16 = svp_read_cell_1;
m68k.memory_map[0x3a].read16 = svp_read_cell_2;
}
/**********************************************

View File

@ -76,9 +76,9 @@ typedef struct
/* Cartridge type */
typedef struct
{
uint8 *base; /* ROM base (saved for OS/Cartridge ROM swap) */
uint32 romsize; /* ROM size */
uint32 mask; /* ROM mask */
uint8 *base; /* ROM base (saved for OS/Cartridge ROM swap) */
uint32 romsize; /* ROM size */
uint32 mask; /* ROM mask */
uint8 special; /* custom external hardware (Lock-On, J-Cart, 3-D glasses, Terebi Oekaki,...) */
cart_hw_t hw; /* cartridge internal hardware */
uint8 rom[MAXROMSIZE]; /* ROM area */

View File

@ -12,12 +12,69 @@
#include "shared.h"
svp_t *svp = NULL;
svp_t *svp;
static void svp_write_dram(uint32 address, uint32 data)
{
*(uint16 *)(svp->dram + (address & 0x1fffe)) = data;
if (data)
{
if (address == 0x30fe06) svp->ssp1601.emu_status &= ~SSP_WAIT_30FE06;
else if (address == 0x30fe08) svp->ssp1601.emu_status &= ~SSP_WAIT_30FE08;
}
}
static uint32 svp_read_cell_1(uint32 address)
{
address = (address & 0xe002) | ((address & 0x7c) << 6) | ((address & 0x1f80) >> 5);
return *(uint16 *)(svp->dram + address);
}
static uint32 svp_read_cell_2(uint32 address)
{
address = (address & 0xf002) | ((address & 0x3c) << 6) | ((address & 0xfc0) >> 4);
return *(uint16 *)(svp->dram + address);
}
static uint32 svp_read_cell_byte(uint32 address)
{
uint16 data = m68k.memory_map[address >> 16].read16(address);
if (address & 0x01)
{
return (data & 0xff);
}
return (data >> 8);
}
void svp_init(void)
{
svp = (void *) ((char *)cart.rom + 0x200000);
memset(svp, 0, sizeof(*svp));
m68k.memory_map[0x30].base = svp->dram;
m68k.memory_map[0x30].read8 = NULL;
m68k.memory_map[0x30].read16 = NULL;
m68k.memory_map[0x30].write8 = NULL;
m68k.memory_map[0x30].write16 = svp_write_dram;
zbank_memory_map[0x30].read = NULL;
zbank_memory_map[0x30].write = NULL;
m68k.memory_map[0x31].base = svp->dram + 0x10000;
m68k.memory_map[0x31].read8 = NULL;
m68k.memory_map[0x31].read16 = NULL;
m68k.memory_map[0x31].write8 = NULL;
m68k.memory_map[0x31].write16 = NULL;
zbank_memory_map[0x31].read = NULL;
zbank_memory_map[0x31].write = NULL;
m68k.memory_map[0x39].read8 = svp_read_cell_byte;
m68k.memory_map[0x39].read16 = svp_read_cell_1;
zbank_memory_map[0x39].read = svp_read_cell_byte;
m68k.memory_map[0x3a].read8 = svp_read_cell_byte;
m68k.memory_map[0x3a].read16 = svp_read_cell_2;
zbank_memory_map[0x3a].read = svp_read_cell_byte;
}
void svp_reset(void)
@ -26,24 +83,3 @@ void svp_reset(void)
ssp1601_reset(&svp->ssp1601);
}
void svp_write_dram(uint32 address, uint32 data)
{
*(uint16 *)(svp->dram + (address & 0x1fffe)) = data;
if ((address == 0x30fe06) && data) svp->ssp1601.emu_status &= ~SSP_WAIT_30FE06;
if ((address == 0x30fe08) && data) svp->ssp1601.emu_status &= ~SSP_WAIT_30FE08;
}
uint32 svp_read_cell_1(uint32 address)
{
address >>= 1;
address = (address & 0x7001) | ((address & 0x3e) << 6) | ((address & 0xfc0) >> 5);
return *(uint16 *)(svp->dram + (address & 0x1fffe));
}
uint32 svp_read_cell_2(uint32 address)
{
address >>= 1;
address = (address & 0x7801) | ((address & 0x1e) << 6) | ((address & 0x7e0) >> 4);
return *(uint16 *)(svp->dram + (address & 0x1fffe));
}

View File

@ -26,8 +26,5 @@ extern svp_t *svp;
extern void svp_init(void);
extern void svp_reset(void);
extern void svp_write_dram(uint32 address, uint32 data);
extern uint32 svp_read_cell_1(uint32 address);
extern uint32 svp_read_cell_2(uint32 address);
#endif

View File

@ -2,8 +2,8 @@
* Genesis Plus
* Main 68k bus handlers
*
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code)
* Copyright (C) 2007-2015 Eke-Eke (Genesis Plus GX)
* Copyright (C) 1998-2003 Charles Mac Donald (original code)
* Copyright (C) 2007-2016 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:
@ -420,6 +420,19 @@ unsigned int ctrl_io_read_byte(unsigned int address)
case 0x44: /* RADICA */
case 0x50: /* SVP */
{
if ((address & 0xFC) == 0x00)
{
unsigned int data = svp->ssp1601.gr[SSP_XST].byte.h;
return (address & 1) ? (data & 0xFF) : (data >> 8);
}
if ((address & 0xFE) == 0x04)
{
unsigned int data = svp->ssp1601.gr[SSP_PM0].byte.h;
svp->ssp1601.gr[SSP_PM0].byte.h &= ~1;
return (address & 1) ? (data & 0xFF) : (data >> 8);
}
return m68k_read_bus_8(address);
}
@ -536,12 +549,12 @@ unsigned int ctrl_io_read_word(unsigned int address)
case 0x50: /* SVP */
{
if ((address & 0xFD) == 0)
if ((address & 0xFC) == 0x00)
{
return svp->ssp1601.gr[SSP_XST].byte.h;
}
if ((address & 0xFF) == 4)
if ((address & 0xFE) == 0x04)
{
unsigned int data = svp->ssp1601.gr[SSP_PM0].byte.h;
svp->ssp1601.gr[SSP_PM0].byte.h &= ~1;

View File

@ -2,8 +2,8 @@
* Genesis Plus
* Main 68k bus handlers
*
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code)
* Copyright (C) 2007-2015 Eke-Eke (Genesis Plus GX)
* Copyright (C) 1998-2003 Charles Mac Donald (original code)
* Copyright (C) 2007-2016 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met: