gpgx: port other changes from the old branch

This commit is contained in:
nattthebear 2017-06-22 17:44:23 -04:00
parent e231cd5084
commit 21c70d1d65
5 changed files with 2497 additions and 2441 deletions

Binary file not shown.

View File

@ -550,7 +550,7 @@ GPGX_EX int gpgx_init(const char *feromextension, ECL_ENTRY int (*feload_archive
config.overscan = 0;
config.gg_extra = 0;
config.ntsc = 0;
config.render = 0;
config.render = 1;
// set overall input system type
// usual is MD GAMEPAD or NONE

View File

@ -940,21 +940,57 @@ static void mapper_sf001_w(uint32 address, uint32 data)
*/
static void mapper_sf002_w(uint32 address, uint32 data)
{
int i;
if (data & 0x80)
/* 8 x 512k banks */
address = (address << 2) & 0x38;
/* bank 0 remains unchanged */
if (address)
{
/* $000000-$1BFFFF mapped to $200000-$3BFFFF */
for (i=0x20; i<0x3C; i++)
uint32 i;
uint8 *src = cart.rom + (data << 19);
for (i = 0; i<8; i++)
{
m68k.memory_map[i].base = cart.rom + ((i & 0x1F) << 16);
m68k.memory_map[address++].base = src + (i << 16);
}
}
else // emulate turning on SRAM
{
if (data & 1)
{
if (sram.on)
{
/* Backup RAM mapped to $200000-$20ffff (normally mirrored up to $3fffff but this breaks Sonic Megamix and no game need it) */
cart.hw.bankshift = m68k.memory_map[0x20].base;
m68k.memory_map[0x20].base = sram.sram;
m68k.memory_map[0x20].read8 = sram_read_byte;
m68k.memory_map[0x20].read16 = sram_read_word;
zbank_memory_map[0x20].read = sram_read_byte;
/* Backup RAM write protection */
if (data & 2)
{
m68k.memory_map[0x20].write8 = m68k_unused_8_w;
m68k.memory_map[0x20].write16 = m68k_unused_16_w;
zbank_memory_map[0x20].write = zbank_unused_w;
}
else
{
m68k.memory_map[0x20].write8 = sram_write_byte;
m68k.memory_map[0x20].write16 = sram_write_word;
zbank_memory_map[0x20].write = sram_write_byte;
}
}
}
else
{
/* $200000-$3BFFFF mapped to $200000-$3BFFFF */
for (i=0x20; i<0x3C; i++)
{
m68k.memory_map[i].base = cart.rom + (i << 16);
// automatically turn off writing to SRAM if SRAM is not visible
m68k.memory_map[0x20].write8 = m68k_unused_8_w;
m68k.memory_map[0x20].write16 = m68k_unused_16_w;
zbank_memory_map[0x20].write = zbank_unused_w;
// put the ROM data back in the memory map
m68k.memory_map[0x20].base = cart.hw.bankshift;
}
}
}

View File

@ -175,7 +175,20 @@ void sram_init()
sram.end = 0x203fff;
}
}
else if (strstr(rominfo.product, "T-50166") != NULL)
{
/* Might and Magic Gates to Another World */
sram.on = 1;
sram.start = 0x200001;
sram.end = 0x203fff;
}
else if (strstr(rominfo.international, "MIGHT & MAGIC III") != NULL)
{
/* Might and Magic III - Isles of Terra (USA) (Proto) */
sram.on = 1;
sram.start = 0x200001;
sram.end = 0x203fff;
}
/* auto-detect games which need disabled backup RAM */
else if (strstr(rominfo.product,"T-113016") != NULL)
{

View File

@ -14,6 +14,7 @@
#endif /* M68K_EMULATE_ADDRESS_ERROR */
#include "m68k.h"
#include "mem68k.h"
#include "../cinterface/callbacks.h"
void CDLog68k(uint addr, uint flags);
@ -1106,16 +1107,22 @@ INLINE void m68ki_push_16(uint value)
{
REG_SP = MASK_OUT_ABOVE_32(REG_SP - 2);
/*m68ki_write_16(REG_SP, value);*/
if (m68ki_cpu.memory_map[(REG_SP >> 16) & 0xff].write16 != m68k_unused_16_w)
{
*(uint16 *)(m68ki_cpu.memory_map[(REG_SP >> 16) & 0xff].base + (REG_SP & 0xffff)) = value;
}
}
INLINE void m68ki_push_32(uint value)
{
REG_SP = MASK_OUT_ABOVE_32(REG_SP - 4);
/*m68ki_write_32(REG_SP, value);*/
if (m68ki_cpu.memory_map[(REG_SP >> 16) & 0xff].write16 != m68k_unused_16_w)
{
*(uint16 *)(m68ki_cpu.memory_map[(REG_SP >> 16) & 0xff].base + (REG_SP & 0xffff)) = value >> 16;
*(uint16 *)(m68ki_cpu.memory_map[((REG_SP + 2) >> 16) & 0xff].base + ((REG_SP + 2) & 0xffff)) = value & 0xffff;
}
}
INLINE uint m68ki_pull_16(void)
{