mirror of
https://github.com/libretro/FBNeo.git
synced 2024-11-23 17:09:43 +00:00
megadrive: hook up serial eeprom code from picodrive. add Megaman - Wily Wars USA version as parent, hook up a couple other games to the serial eeprom
This commit is contained in:
parent
b9e36c8be1
commit
3bec0340ae
@ -147,7 +147,7 @@ depobj = burn.o burn_bitmap.o burn_gun.o burn_led.o burn_shift.o burn_memory.o
|
||||
\
|
||||
toa_bcu2.o toa_extratext.o toa_gp9001.o toa_palette.o toaplan1.o toaplan.o \
|
||||
\
|
||||
megadrive.o stm95.o \
|
||||
megadrive.o stm95.o mdeeprom.o \
|
||||
\
|
||||
pce.o \
|
||||
\
|
||||
|
@ -623,9 +623,9 @@ void IpsApplyPatches(UINT8* base, char* rom_name);
|
||||
#define HARDWARE_SEGA_MEGADRIVE_PCB_POKEMON (40)
|
||||
#define HARDWARE_SEGA_MEGADRIVE_PCB_POKEMON2 (41)
|
||||
#define HARDWARE_SEGA_MEGADRIVE_PCB_MULAN (42)
|
||||
#define HARDWARE_SEGA_MEGADRIVE_TEAMPLAYER (43)
|
||||
#define HARDWARE_SEGA_MEGADRIVE_TEAMPLAYER_PORT2 (44)
|
||||
#define HARDWARE_SEGA_MEGADRIVE_FOURWAYPLAY (45)
|
||||
#define HARDWARE_SEGA_MEGADRIVE_TEAMPLAYER (0x40)
|
||||
#define HARDWARE_SEGA_MEGADRIVE_TEAMPLAYER_PORT2 (0x80)
|
||||
#define HARDWARE_SEGA_MEGADRIVE_FOURWAYPLAY (0xc0)
|
||||
|
||||
#define HARDWARE_SEGA_MEGADRIVE_SRAM_00400 (0x0100)
|
||||
#define HARDWARE_SEGA_MEGADRIVE_SRAM_00800 (0x0200)
|
||||
|
@ -2,7 +2,6 @@
|
||||
#include "megadrive.h"
|
||||
|
||||
// Notes:
|
||||
// blockb - requires serial eeprom to boot, currently unemulated -dink
|
||||
// sampras might need different addresses for j-cart (0x3ffffe?)
|
||||
|
||||
// Driver generated by database on http://www.barryharris.me.uk
|
||||
@ -5402,7 +5401,7 @@ struct BurnDriver BurnDrvmd_blockb = {
|
||||
"md_blockb", NULL, NULL, NULL, "1995",
|
||||
"Blockbuster World Video Game Championship II (USA)\0", NULL, "Acclaim Entertainment", "Sega Megadrive",
|
||||
NULL, NULL, NULL, NULL,
|
||||
BDF_16BIT_ONLY, 2, HARDWARE_SEGA_MEGADRIVE | HARDWARE_SEGA_MEGADRIVE_PCB_SEGA_SRAM, GBF_MISC, 0,
|
||||
BDF_GAME_WORKING | BDF_16BIT_ONLY, 2, HARDWARE_SEGA_MEGADRIVE | HARDWARE_SEGA_MEGADRIVE_PCB_NBA_JAM_TE, GBF_MISC, 0,
|
||||
MegadriveGetZipName, md_blockbRomInfo, md_blockbRomName, NULL, NULL, NULL, NULL, MegadriveInputInfo, MegadriveDIPInfo,
|
||||
MegadriveInit, MegadriveExit, MegadriveFrame, MegadriveDraw, MegadriveScan,
|
||||
&bMegadriveRecalcPalette, 0x100, 320, 224, 4, 3
|
||||
@ -18624,9 +18623,9 @@ struct BurnDriver BurnDrvmd_megaga10 = {
|
||||
&bMegadriveRecalcPalette, 0x100, 320, 224, 4, 3
|
||||
};
|
||||
|
||||
// Mega Man - The Wily Wars (Euro)
|
||||
// Mega Man - The Wily Wars (USA)
|
||||
static struct BurnRomInfo md_megamanRomDesc[] = {
|
||||
{ "mega man - the wily wars (euro).bin", 0x200000, 0xdcf6e8b2, BRF_PRG | SEGA_MD_ROM_LOAD16_WORD_SWAP | SEGA_MD_ROM_OFFS_000000 },
|
||||
{ "mega man - the wily wars (usa).bin", 0x200000, 0x0cd405db, BRF_PRG | SEGA_MD_ROM_LOAD16_WORD_SWAP | SEGA_MD_ROM_OFFS_000000 },
|
||||
};
|
||||
|
||||
STD_ROM_PICK(md_megaman)
|
||||
@ -18634,10 +18633,28 @@ STD_ROM_FN(md_megaman)
|
||||
|
||||
struct BurnDriver BurnDrvmd_megaman = {
|
||||
"md_megaman", NULL, NULL, NULL, "1994",
|
||||
"Mega Man - The Wily Wars (USA)\0", NULL, "Capcom", "Sega Megadrive",
|
||||
NULL, NULL, NULL, NULL,
|
||||
BDF_GAME_WORKING | BDF_16BIT_ONLY, 2, HARDWARE_SEGA_MEGADRIVE | HARDWARE_SEGA_MEGADRIVE_PCB_SEGA_EEPROM, GBF_RUNGUN, 0,
|
||||
MegadriveGetZipName, md_megamanRomInfo, md_megamanRomName, NULL, NULL, NULL, NULL, MegadriveInputInfo, MegadriveDIPInfo,
|
||||
MegadriveInit, MegadriveExit, MegadriveFrame, MegadriveDraw, MegadriveScan,
|
||||
&bMegadriveRecalcPalette, 0x100, 320, 224, 4, 3
|
||||
};
|
||||
|
||||
// Mega Man - The Wily Wars (Euro)
|
||||
static struct BurnRomInfo md_megamaneuRomDesc[] = {
|
||||
{ "mega man - the wily wars (euro).bin", 0x200000, 0xdcf6e8b2, BRF_PRG | SEGA_MD_ROM_LOAD16_WORD_SWAP | SEGA_MD_ROM_OFFS_000000 },
|
||||
};
|
||||
|
||||
STD_ROM_PICK(md_megamaneu)
|
||||
STD_ROM_FN(md_megamaneu)
|
||||
|
||||
struct BurnDriver BurnDrvmd_megamaneu = {
|
||||
"md_megamaneu", "md_megaman", NULL, NULL, "1994",
|
||||
"Mega Man - The Wily Wars (Euro)\0", NULL, "Capcom", "Sega Megadrive",
|
||||
NULL, NULL, NULL, NULL,
|
||||
BDF_GAME_WORKING | BDF_16BIT_ONLY, 2, HARDWARE_SEGA_MEGADRIVE | HARDWARE_SEGA_MEGADRIVE_PCB_SEGA_SRAM, GBF_RUNGUN, 0,
|
||||
MegadriveGetZipName, md_megamanRomInfo, md_megamanRomName, NULL, NULL, NULL, NULL, MegadriveInputInfo, MegadriveDIPInfo,
|
||||
BDF_GAME_WORKING | BDF_16BIT_ONLY | BDF_CLONE, 2, HARDWARE_SEGA_MEGADRIVE | HARDWARE_SEGA_MEGADRIVE_PCB_SEGA_EEPROM, GBF_RUNGUN, 0,
|
||||
MegadriveGetZipName, md_megamaneuRomInfo, md_megamaneuRomName, NULL, NULL, NULL, NULL, MegadriveInputInfo, MegadriveDIPInfo,
|
||||
MegadriveInit, MegadriveExit, MegadriveFrame, MegadriveDraw, MegadriveScan,
|
||||
&bMegadriveRecalcPalette, 0x100, 320, 224, 4, 3
|
||||
};
|
||||
@ -18661,7 +18678,6 @@ struct BurnDriver BurnDrvmd_rockman = {
|
||||
};
|
||||
|
||||
// Rockman Mega World (Jpn, Alt)
|
||||
// Note: Impossible to win game due to broken sram in this version.
|
||||
static struct BurnRomInfo md_rockman1RomDesc[] = {
|
||||
{ "rockman mega world (jpn) (alt).bin", 0x200000, 0x85c956ef, BRF_PRG | SEGA_MD_ROM_LOAD16_WORD_SWAP | SEGA_MD_ROM_OFFS_000000 },
|
||||
};
|
||||
@ -18671,9 +18687,9 @@ STD_ROM_FN(md_rockman1)
|
||||
|
||||
struct BurnDriver BurnDrvmd_rockman1 = {
|
||||
"md_rockman1", "md_megaman", NULL, NULL, "1994",
|
||||
"Rockman Mega World (Jpn, Alt)\0", "Play md_rockman or md_megaman instead!", "Capcom", "Sega Megadrive",
|
||||
"Rockman Mega World (Jpn, Alt)\0", NULL, "Capcom", "Sega Megadrive",
|
||||
NULL, NULL, NULL, NULL,
|
||||
BDF_GAME_NOT_WORKING | BDF_16BIT_ONLY | BDF_CLONE, 2, HARDWARE_SEGA_MEGADRIVE, GBF_RUNGUN, 0,
|
||||
BDF_GAME_WORKING | BDF_16BIT_ONLY | BDF_CLONE | HARDWARE_SEGA_MEGADRIVE_PCB_SEGA_EEPROM, 2, HARDWARE_SEGA_MEGADRIVE, GBF_RUNGUN, 0,
|
||||
MegadriveGetZipName, md_rockman1RomInfo, md_rockman1RomName, NULL, NULL, NULL, NULL, MegadriveInputInfo, MegadriveDIPInfo,
|
||||
MegadriveInit, MegadriveExit, MegadriveFrame, MegadriveDraw, MegadriveScan,
|
||||
&bMegadriveRecalcPalette, 0x100, 320, 224, 4, 3
|
||||
|
254
src/burn/drv/megadrive/mdeeprom.cpp
Normal file
254
src/burn/drv/megadrive/mdeeprom.cpp
Normal file
@ -0,0 +1,254 @@
|
||||
/*
|
||||
* rarely used EEPROM code
|
||||
* (C) notaz, 2007-2009
|
||||
*
|
||||
* This work is licensed under the terms of MAME license.
|
||||
* See COPYING file in the top-level directory.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "burnint.h"
|
||||
#include "m68000_intf.h"
|
||||
|
||||
|
||||
struct i2c_eep {
|
||||
UINT8 eeprom_type; // eeprom type: 0: 7bit (24C01), 2: 2 addr words (X24C02+), 3: 3 addr words
|
||||
UINT8 eeprom_bit_cl; // bit number for cl
|
||||
UINT8 eeprom_bit_in; // bit number for in
|
||||
UINT8 eeprom_bit_out; // bit number for out
|
||||
|
||||
UINT32 last_write;
|
||||
UINT16 eeprom_addr; // EEPROM address register
|
||||
UINT8 eeprom_cycle; // EEPROM cycle number
|
||||
UINT8 eeprom_slave; // EEPROM slave word for X24C02 and better SRAMs
|
||||
UINT8 eeprom_status;
|
||||
UINT8 eeprom_wb[2]; // EEPROM latch/write buffer
|
||||
UINT8 changed;
|
||||
UINT8 *data; // pointer to EEPROM block
|
||||
};
|
||||
|
||||
static i2c_eep eeprom;
|
||||
|
||||
void EEPROM_init(UINT8 type, UINT8 cl, UINT8 i, UINT8 o, UINT8 *data)
|
||||
{
|
||||
memset(&eeprom, 0, sizeof(eeprom));
|
||||
|
||||
eeprom.eeprom_type = type; // 0: 7bit (24C01), 2: 2 addr words (X24C02+), 3: 3 addr words
|
||||
eeprom.eeprom_bit_cl = cl;
|
||||
eeprom.eeprom_bit_in = i;
|
||||
eeprom.eeprom_bit_out= o;
|
||||
eeprom.data = data;
|
||||
eeprom.last_write = 0xffff0000;
|
||||
}
|
||||
|
||||
void EEPROM_init(UINT8 *data)
|
||||
{
|
||||
EEPROM_init(0, 1, 0, 0, data);
|
||||
}
|
||||
|
||||
void EEPROM_scan()
|
||||
{
|
||||
SCAN_VAR(eeprom.last_write);
|
||||
SCAN_VAR(eeprom.eeprom_addr);
|
||||
SCAN_VAR(eeprom.eeprom_cycle);
|
||||
SCAN_VAR(eeprom.eeprom_slave);
|
||||
SCAN_VAR(eeprom.eeprom_status);
|
||||
SCAN_VAR(eeprom.eeprom_wb);
|
||||
SCAN_VAR(eeprom.changed);
|
||||
// data block is scanned in megadrive.cpp..
|
||||
}
|
||||
|
||||
// eeprom_status: LA.. s.la (L=pending SCL, A=pending SDA,
|
||||
// s=started, l=old SCL, a=old SDA)
|
||||
static void EEPROM_write_do(UINT32 d) // ???? ??la (l=SCL, a=SDA)
|
||||
{
|
||||
UINT32 sreg = eeprom.eeprom_status, saddr = eeprom.eeprom_addr;
|
||||
UINT32 scyc = eeprom.eeprom_cycle, ssa = eeprom.eeprom_slave;
|
||||
|
||||
//elprintf(EL_EEPROM, "eeprom: scl/sda: %i/%i -> %i/%i, newtime=%i", (sreg&2)>>1, sreg&1, (d&2)>>1, d&1, SekTotalCycles() - eeprom.last_write);
|
||||
saddr &= 0x1fff;
|
||||
|
||||
if(sreg & d & 2) {
|
||||
// SCL was and is still high..
|
||||
if((sreg & 1) && !(d&1)) {
|
||||
// ..and SDA went low, means it's a start command, so clear internal addr reg and clock counter
|
||||
//elprintf(EL_EEPROM, "eeprom: -start-");
|
||||
//saddr = 0;
|
||||
scyc = 0;
|
||||
sreg |= 8;
|
||||
} else if(!(sreg & 1) && (d&1)) {
|
||||
// SDA went high == stop command
|
||||
//elprintf(EL_EEPROM, "eeprom: -stop-");
|
||||
sreg &= ~8;
|
||||
}
|
||||
}
|
||||
else if((sreg & 8) && !(sreg & 2) && (d&2))
|
||||
{
|
||||
// we are started and SCL went high - next cycle
|
||||
scyc++; // pre-increment
|
||||
if(eeprom.eeprom_type) {
|
||||
// X24C02+
|
||||
if((ssa&1) && scyc == 18) {
|
||||
scyc = 9;
|
||||
saddr++; // next address in read mode
|
||||
/*if(eeprom.eeprom_type==2) saddr&=0xff; else*/ saddr&=0x1fff; // mask
|
||||
}
|
||||
else if(eeprom.eeprom_type == 2 && scyc == 27) scyc = 18;
|
||||
else if(scyc == 36) scyc = 27;
|
||||
} else {
|
||||
// X24C01
|
||||
if(scyc == 18) {
|
||||
scyc = 9; // wrap
|
||||
if(saddr&1) { saddr+=2; saddr&=0xff; } // next addr in read mode
|
||||
}
|
||||
}
|
||||
//elprintf(EL_EEPROM, "eeprom: scyc: %i", scyc);
|
||||
}
|
||||
else if((sreg & 8) && (sreg & 2) && !(d&2))
|
||||
{
|
||||
// we are started and SCL went low (falling edge)
|
||||
if(eeprom.eeprom_type) {
|
||||
// X24C02+
|
||||
if(scyc == 9 || scyc == 18 || scyc == 27); // ACK cycles
|
||||
else if( (eeprom.eeprom_type == 3 && scyc > 27) || (eeprom.eeprom_type == 2 && scyc > 18) ) {
|
||||
if(!(ssa&1)) {
|
||||
// data write
|
||||
UINT8 *pm=eeprom.data+saddr;
|
||||
*pm <<= 1; *pm |= d&1;
|
||||
if(scyc == 26 || scyc == 35) {
|
||||
saddr=(saddr&~0xf)|((saddr+1)&0xf); // only 4 (?) lowest bits are incremented
|
||||
//elprintf(EL_EEPROM, "eeprom: write done, addr inc to: %x, last byte=%02x", saddr, *pm);
|
||||
}
|
||||
eeprom.changed = 1;
|
||||
}
|
||||
} else if(scyc > 9) {
|
||||
if(!(ssa&1)) {
|
||||
// we latch another addr bit
|
||||
saddr<<=1;
|
||||
if(eeprom.eeprom_type == 2) saddr&=0xff; else saddr&=0x1fff; // mask
|
||||
saddr|=d&1;
|
||||
if(scyc==17||scyc==26) {
|
||||
//elprintf(EL_EEPROM, "eeprom: addr reg done: %x", saddr);
|
||||
if(scyc==17&&eeprom.eeprom_type==2) { saddr&=0xff; saddr|=(ssa<<7)&0x700; } // add device bits too
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// slave address
|
||||
ssa<<=1; ssa|=d&1;
|
||||
//if(scyc==8) elprintf(EL_EEPROM, "eeprom: slave done: %x", ssa);
|
||||
}
|
||||
} else {
|
||||
// X24C01
|
||||
if(scyc == 9); // ACK cycle, do nothing
|
||||
else if(scyc > 9) {
|
||||
if(!(saddr&1)) {
|
||||
// data write
|
||||
UINT8 *pm=eeprom.data+(saddr>>1);
|
||||
*pm <<= 1; *pm |= d&1;
|
||||
if(scyc == 17) {
|
||||
saddr=(saddr&0xf9)|((saddr+2)&6); // only 2 lowest bits are incremented
|
||||
//elprintf(EL_EEPROM, "eeprom: write done, addr inc to: %x, last byte=%02x", saddr>>1, *pm);
|
||||
}
|
||||
eeprom.changed = 1;
|
||||
}
|
||||
} else {
|
||||
// we latch another addr bit
|
||||
saddr<<=1; saddr|=d&1; saddr&=0xff;
|
||||
//if(scyc==8) elprintf(EL_EEPROM, "eeprom: addr done: %x", saddr>>1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sreg &= ~3; sreg |= d&3; // remember SCL and SDA
|
||||
eeprom.eeprom_status = (UINT8) sreg;
|
||||
eeprom.eeprom_cycle = (UINT8) scyc;
|
||||
eeprom.eeprom_slave = (UINT8) ssa;
|
||||
eeprom.eeprom_addr = (UINT16)saddr;
|
||||
}
|
||||
|
||||
static void EEPROM_upd_pending(UINT32 d)
|
||||
{
|
||||
UINT32 d1, sreg = eeprom.eeprom_status;
|
||||
|
||||
sreg &= ~0xc0;
|
||||
|
||||
// SCL
|
||||
d1 = (d >> eeprom.eeprom_bit_cl) & 1;
|
||||
sreg |= d1 << 7;
|
||||
|
||||
// SDA in
|
||||
d1 = (d >> eeprom.eeprom_bit_in) & 1;
|
||||
sreg |= d1 << 6;
|
||||
|
||||
eeprom.eeprom_status = (UINT8) sreg;
|
||||
}
|
||||
|
||||
void EEPROM_write16(UINT32 d)
|
||||
{
|
||||
// this diff must be at most 16 for NBA Jam to work
|
||||
if (SekTotalCycles() - eeprom.last_write < 16) {
|
||||
// just update pending state
|
||||
//elprintf(EL_EEPROM, "eeprom: skip because cycles=%i", SekTotalCycles() - eeprom.last_write);
|
||||
EEPROM_upd_pending(d);
|
||||
} else {
|
||||
int srs = eeprom.eeprom_status;
|
||||
EEPROM_write_do(srs >> 6); // execute pending
|
||||
EEPROM_upd_pending(d);
|
||||
if ((srs ^ eeprom.eeprom_status) & 0xc0) // update time only if SDA/SCL changed
|
||||
eeprom.last_write = SekTotalCycles();
|
||||
}
|
||||
}
|
||||
|
||||
void EEPROM_write8(UINT32 a, UINT8 d)
|
||||
{
|
||||
UINT8 *wb = eeprom.eeprom_wb;
|
||||
wb[a & 1] = d;
|
||||
EEPROM_write16((wb[0] << 8) | wb[1]);
|
||||
}
|
||||
|
||||
UINT32 EEPROM_read()
|
||||
{
|
||||
UINT32 shift, d;
|
||||
UINT32 sreg, saddr, scyc, ssa, interval;
|
||||
|
||||
// flush last pending write
|
||||
EEPROM_write_do(eeprom.eeprom_status>>6);
|
||||
|
||||
sreg = eeprom.eeprom_status; saddr = eeprom.eeprom_addr&0x1fff; scyc = eeprom.eeprom_cycle; ssa = eeprom.eeprom_slave;
|
||||
interval = SekTotalCycles() - eeprom.last_write;
|
||||
d = (sreg>>6)&1; // use SDA as "open bus"
|
||||
|
||||
// NBA Jam is nasty enough to read <before> raising the SCL and starting the new cycle.
|
||||
// this is probably valid because data changes occur while SCL is low and data can be read
|
||||
// before it's actual cycle begins.
|
||||
if (!(sreg&0x80) && interval >= 24) {
|
||||
//elprintf(EL_EEPROM, "eeprom: early read, cycles=%i", interval);
|
||||
scyc++;
|
||||
}
|
||||
|
||||
if (!(sreg & 8)); // not started, use open bus
|
||||
else if (scyc == 9 || scyc == 18 || scyc == 27) {
|
||||
//elprintf(EL_EEPROM, "eeprom: r ack");
|
||||
d = 0;
|
||||
} else if (scyc > 9 && scyc < 18) {
|
||||
// started and first command word received
|
||||
shift = 17-scyc;
|
||||
if (eeprom.eeprom_type) {
|
||||
// X24C02+
|
||||
if (ssa&1) {
|
||||
//elprintf(EL_EEPROM, "eeprom: read: addr %02x, cycle %i, reg %02x", saddr, scyc, sreg);
|
||||
//if (shift==0) elprintf(EL_EEPROM, "eeprom: read done, byte %02x", eeprom.data[saddr]);
|
||||
d = (eeprom.data[saddr]>>shift)&1;
|
||||
}
|
||||
} else {
|
||||
// X24C01
|
||||
if (saddr&1) {
|
||||
//elprintf(EL_EEPROM, "eeprom: read: addr %02x, cycle %i, reg %02x", saddr>>1, scyc, sreg);
|
||||
//if (shift==0) elprintf(EL_EEPROM, "eeprom: read done, byte %02x", eeprom.data[saddr>>1]);
|
||||
d = (eeprom.data[saddr>>1]>>shift)&1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (d << eeprom.eeprom_bit_out);
|
||||
}
|
6
src/burn/drv/megadrive/mdeeprom.h
Normal file
6
src/burn/drv/megadrive/mdeeprom.h
Normal file
@ -0,0 +1,6 @@
|
||||
void EEPROM_init(UINT8 *data);
|
||||
void EEPROM_init(UINT8 type, UINT8 cl, UINT8 i, UINT8 o, UINT8 *data);
|
||||
void EEPROM_write16(UINT32 d);
|
||||
void EEPROM_write8(UINT32 a, UINT8 d);
|
||||
UINT32 EEPROM_read();
|
||||
void EEPROM_scan();
|
@ -31,6 +31,7 @@
|
||||
#include "megadrive.h"
|
||||
#include "bitswap.h"
|
||||
#include "m68000_debug.h"
|
||||
#include "mdeeprom.h" // i2c eeprom for MD
|
||||
|
||||
//#define CYCDBUG
|
||||
|
||||
@ -437,7 +438,7 @@ static UINT16 __fastcall MegadriveReadWord(UINT32 sekAddress)
|
||||
bprintf(PRINT_NORMAL, _T("Attempt to read word value of location %x\n"), sekAddress);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return 0xffff;
|
||||
}
|
||||
|
||||
static UINT8 __fastcall MegadriveReadByte(UINT32 sekAddress)
|
||||
@ -470,7 +471,7 @@ static UINT8 __fastcall MegadriveReadByte(UINT32 sekAddress)
|
||||
bprintf(PRINT_NORMAL, _T("Attempt to read byte value of location %x\n"), sekAddress);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return 0xff;
|
||||
}
|
||||
|
||||
static void __fastcall MegadriveZ80ProgWrite(UINT16 a, UINT8 d); // forward
|
||||
@ -549,7 +550,7 @@ static void __fastcall MegadriveWriteByte(UINT32 sekAddress, UINT8 byteValue)
|
||||
|
||||
default: {
|
||||
if (!bNoDebug)
|
||||
bprintf(PRINT_NORMAL, _T("Attempt to write byte value %x to location %x\n"), byteValue, sekAddress);
|
||||
bprintf(PRINT_NORMAL, _T("Attempt to write byte value %x to location %x (PC: %X, PPC: %x)\n"), byteValue, sekAddress, SekGetPC(-1), SekGetPPC(-1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1506,6 +1507,10 @@ static INT32 MegadriveResetDo()
|
||||
}
|
||||
RamMisc->SRamReadOnly = 0;
|
||||
}
|
||||
|
||||
RamMisc->I2CClk = 0;
|
||||
RamMisc->I2CMem = 0;
|
||||
|
||||
memset(JoyPad, 0, sizeof(struct MegadriveJoyPad));
|
||||
teamplayer_reset();
|
||||
|
||||
@ -2821,7 +2826,7 @@ static void SetupCustomCartridgeMappers()
|
||||
SekClose();
|
||||
}
|
||||
|
||||
switch ((BurnDrvGetHardwareCode() & 0xff)) {
|
||||
switch ((BurnDrvGetHardwareCode() & 0xc0)) {
|
||||
case HARDWARE_SEGA_MEGADRIVE_FOURWAYPLAY:
|
||||
FourWayPlayMode = 1;
|
||||
break;
|
||||
@ -2950,64 +2955,86 @@ static void __fastcall Megadrive6658ARegWriteWord(UINT32 sekAddress, UINT16 word
|
||||
|
||||
static UINT8 __fastcall WboyVEEPROMReadByte(UINT32 sekAddress)
|
||||
{
|
||||
if (sekAddress & 1) return ~RamMisc->I2CMem & 1;
|
||||
if (sekAddress == 0x200001) return EEPROM_read();
|
||||
|
||||
bprintf(PRINT_NORMAL, _T("WboyVEEPROM Read Byte %x\n"), sekAddress);
|
||||
if (sekAddress < 0x300000) {
|
||||
return RomMain[sekAddress^1];
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0xff;
|
||||
}
|
||||
|
||||
static UINT16 __fastcall WboyVEEPROMReadWord(UINT32 sekAddress)
|
||||
{
|
||||
bprintf(PRINT_NORMAL, _T("WboyVEEPROM Read Word %x\n"), sekAddress);
|
||||
if (sekAddress == 0x200001) return EEPROM_read();
|
||||
|
||||
return 0;
|
||||
if (sekAddress < 0x300000) {
|
||||
UINT16 *Rom = (UINT16*)RomMain;
|
||||
return Rom[sekAddress >> 1];
|
||||
}
|
||||
|
||||
return 0xffff;
|
||||
}
|
||||
|
||||
static void __fastcall WboyVEEPROMWriteByte(UINT32 sekAddress, UINT8 byteValue)
|
||||
{
|
||||
if (sekAddress & 1) {
|
||||
RamMisc->I2CClk = (byteValue & 0x0002) >> 1;
|
||||
RamMisc->I2CMem = (byteValue & 0x0001);
|
||||
if (sekAddress == 0x200001) {
|
||||
EEPROM_write8(sekAddress, byteValue);
|
||||
return;
|
||||
}
|
||||
|
||||
bprintf(PRINT_NORMAL, _T("WboyVEEPROM write byte value %02x to location %08x\n"), byteValue, sekAddress);
|
||||
}
|
||||
|
||||
static void __fastcall WboyVEEPROMWriteWord(UINT32 sekAddress, UINT16 wordValue)
|
||||
{
|
||||
bprintf(PRINT_NORMAL, _T("WboyVEEPROM write word value %04x to location %08x\n"), wordValue, sekAddress);
|
||||
if (sekAddress == 0x200001)
|
||||
EEPROM_write16(wordValue);
|
||||
}
|
||||
|
||||
static UINT8 __fastcall NbajamEEPROMReadByte(UINT32 sekAddress)
|
||||
{
|
||||
bprintf(PRINT_NORMAL, _T("Nbajam Read Byte %x\n"), sekAddress);
|
||||
if (sekAddress == 0x200001) return EEPROM_read();
|
||||
|
||||
return 0;
|
||||
if (sekAddress < 0x300000) {
|
||||
return RomMain[sekAddress^1];
|
||||
}
|
||||
|
||||
return 0xff;
|
||||
}
|
||||
|
||||
static UINT16 __fastcall NbajamEEPROMReadWord(UINT32 /*sekAddress*/)
|
||||
static UINT16 __fastcall NbajamEEPROMReadWord(UINT32 sekAddress)
|
||||
{
|
||||
return RamMisc->I2CMem & 1;
|
||||
if (sekAddress == 0x200001) return EEPROM_read();
|
||||
|
||||
if (sekAddress < 0x300000) {
|
||||
UINT16 *Rom = (UINT16*)RomMain;
|
||||
return Rom[sekAddress >> 1];
|
||||
}
|
||||
|
||||
return 0xffff;
|
||||
}
|
||||
|
||||
static void __fastcall NbajamEEPROMWriteByte(UINT32 sekAddress, UINT8 byteValue)
|
||||
{
|
||||
bprintf(PRINT_NORMAL, _T("Nbajam write byte value %02x to location %08x\n"), byteValue, sekAddress);
|
||||
if (sekAddress == 0x200001) {
|
||||
EEPROM_write8(sekAddress, byteValue);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void __fastcall NbajamEEPROMWriteWord(UINT32 /*sekAddress*/, UINT16 wordValue)
|
||||
static void __fastcall NbajamEEPROMWriteWord(UINT32 sekAddress, UINT16 wordValue)
|
||||
{
|
||||
RamMisc->I2CClk = (wordValue & 0x0002) >> 1;
|
||||
RamMisc->I2CMem = (wordValue & 0x0001);
|
||||
if (sekAddress == 0x200001)
|
||||
EEPROM_write16(wordValue);
|
||||
}
|
||||
|
||||
static UINT8 __fastcall NbajamteEEPROMReadByte(UINT32 sekAddress)
|
||||
{ // this is enough to get the game booting and working, but with no real serial eeprom handling
|
||||
{
|
||||
if (sekAddress >= 0x200000 && sekAddress <= 0x200001) {
|
||||
if (sekAddress & 1) return RamMisc->I2CMem & 1;
|
||||
return 0;
|
||||
UINT16 d = EEPROM_read();
|
||||
if (!(sekAddress & 1))
|
||||
d >>= 8;
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
if (sekAddress < 0x300000) {
|
||||
@ -3019,6 +3046,10 @@ static UINT8 __fastcall NbajamteEEPROMReadByte(UINT32 sekAddress)
|
||||
|
||||
static UINT16 __fastcall NbajamteEEPROMReadWord(UINT32 sekAddress)
|
||||
{
|
||||
if (sekAddress >= 0x200000 && sekAddress <= 0x200001) {
|
||||
return EEPROM_read();
|
||||
}
|
||||
|
||||
if (sekAddress < 0x300000) {
|
||||
UINT16 *Rom = (UINT16*)RomMain;
|
||||
return Rom[sekAddress >> 1];
|
||||
@ -3029,17 +3060,15 @@ static UINT16 __fastcall NbajamteEEPROMReadWord(UINT32 sekAddress)
|
||||
|
||||
static void __fastcall NbajamteEEPROMWriteByte(UINT32 sekAddress, UINT8 byteValue)
|
||||
{
|
||||
if (sekAddress == 0x200001) {
|
||||
// RamMisc->I2CClk = (wordValue & 0x0002) >> 1;
|
||||
RamMisc->I2CMem = (byteValue & 0x0001);
|
||||
return;
|
||||
if (sekAddress >= 0x200000 && sekAddress <= 0x200001) {
|
||||
EEPROM_write8(sekAddress, byteValue);
|
||||
}
|
||||
}
|
||||
|
||||
static void __fastcall NbajamteEEPROMWriteWord(UINT32 sekAddress, UINT16 wordValue)
|
||||
{
|
||||
if (sekAddress == 0x200001) {
|
||||
RamMisc->I2CMem = (wordValue & 0x0001);
|
||||
if (sekAddress >= 0x200000 && sekAddress <= 0x200001) {
|
||||
EEPROM_write16(wordValue);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -3190,6 +3219,8 @@ static void MegadriveSetupSRAM()
|
||||
|
||||
if ((BurnDrvGetHardwareCode() & 0xff) == HARDWARE_SEGA_MEGADRIVE_PCB_SEGA_EEPROM) {
|
||||
RamMisc->SRamHasSerialEEPROM = 1;
|
||||
bprintf(PRINT_IMPORTANT, _T("Serial EEPROM, generic Sega style.\n"));
|
||||
EEPROM_init(SRam);
|
||||
SekOpen(0);
|
||||
SekMapHandler(5, 0x200000, 0x200001, MAP_READ | MAP_WRITE);
|
||||
SekSetReadByteHandler(5, WboyVEEPROMReadByte);
|
||||
@ -3199,8 +3230,10 @@ static void MegadriveSetupSRAM()
|
||||
SekClose();
|
||||
}
|
||||
|
||||
if ((BurnDrvGetHardwareCode() & 0xff) == HARDWARE_SEGA_MEGADRIVE_PCB_NBA_JAM) {
|
||||
if ((BurnDrvGetHardwareCode() & 0xff) & HARDWARE_SEGA_MEGADRIVE_PCB_NBA_JAM) {
|
||||
RamMisc->SRamHasSerialEEPROM = 1;
|
||||
bprintf(PRINT_IMPORTANT, _T("Serial EEPROM, NBAJam.\n"));
|
||||
EEPROM_init(2, 1, 0, 1, SRam);
|
||||
SekOpen(0);
|
||||
SekMapHandler(5, 0x200000, 0x200001, MAP_READ | MAP_WRITE);
|
||||
SekSetReadByteHandler(5, NbajamEEPROMReadByte);
|
||||
@ -3212,6 +3245,8 @@ static void MegadriveSetupSRAM()
|
||||
|
||||
if (((BurnDrvGetHardwareCode() & 0xff) == HARDWARE_SEGA_MEGADRIVE_PCB_NBA_JAM_TE) || ((BurnDrvGetHardwareCode() & 0xff) == HARDWARE_SEGA_MEGADRIVE_PCB_NFL_QB_96) || ((BurnDrvGetHardwareCode() & 0xff) == HARDWARE_SEGA_MEGADRIVE_PCB_C_SLAM)) {
|
||||
RamMisc->SRamHasSerialEEPROM = 1;
|
||||
bprintf(PRINT_IMPORTANT, _T("Serial EEPROM, NBAJamTE.\n"));
|
||||
EEPROM_init(2, 8, 0, 0, SRam);
|
||||
SekOpen(0);
|
||||
SekMapHandler(5, 0x200000, 0x200001, MAP_READ | MAP_WRITE);
|
||||
SekSetReadByteHandler(5, NbajamteEEPROMReadByte);
|
||||
@ -3304,35 +3339,6 @@ static void MegadriveSetupSRAM()
|
||||
}
|
||||
}
|
||||
|
||||
static void sram_patch_megaman()
|
||||
{
|
||||
UINT16 *rom = (UINT16*)RomMain;
|
||||
// code to allow use of sram in megaman, which is i2c eeprom(not impl. yet)
|
||||
rom[0x0018e/2] = 0x125a; rom[0x001b2/2] = 0xf820;
|
||||
rom[0x001ba/2] = 0x3fff; rom[0x0036a/2] = 0x4e71;
|
||||
rom[0x003a4/2] = 0x4e71; rom[0x6db4e/2] = 0x4e71;
|
||||
rom[0x6db50/2] = 0x4e71; rom[0x6db5c/2] = 0x40ce;
|
||||
rom[0x6db76/2] = 0x0050; rom[0x6db8c/2] = 0x40ce;
|
||||
rom[0x6dba8/2] = 0x003e; rom[0x6dbb8/2] = 0x4e71;
|
||||
rom[0x6dbba/2] = 0x4e71; rom[0x6dbbc/2] = 0x60fa;
|
||||
rom[0x6dbbe/2] = 0x4e71; rom[0x6dbc0/2] = 0x4e71;
|
||||
rom[0x6dbc2/2] = 0x4e71; rom[0x6dbc4/2] = 0x4e71;
|
||||
rom[0x6dbc6/2] = 0x4a41; rom[0x6dbc8/2] = 0x6606;
|
||||
rom[0x6dbca/2] = 0x45f9; rom[0x6dbce/2] = 0x0101;
|
||||
rom[0x6dbd0/2] = 0x1412; rom[0x6dbd2/2] = 0xe14a;
|
||||
rom[0x6dbd4/2] = 0x142a; rom[0x6dbd6/2] = 0x0002;
|
||||
rom[0x6dbd8/2] = 0x45ea; rom[0x6dbda/2] = 0x0004;
|
||||
rom[0x6dbdc/2] = 0x4e75; rom[0x6dbde/2] = 0x4e71;
|
||||
rom[0x6dbe0/2] = 0x4e71; rom[0x6dbe2/2] = 0x4e71;
|
||||
rom[0x6dbe4/2] = 0x4e71; rom[0x6dbe6/2] = 0x4a41;
|
||||
rom[0x6dbe8/2] = 0x6606; rom[0x6dbea/2] = 0x45f9;
|
||||
rom[0x6dbec/2] = 0x0020; rom[0x6dbee/2] = 0x0101;
|
||||
rom[0x6dbf0/2] = 0x1542; rom[0x6dbf2/2] = 0x0002;
|
||||
rom[0x6dbf4/2] = 0xe04a; rom[0x6dbf6/2] = 0x1482;
|
||||
rom[0x6dbf8/2] = 0x45ea; rom[0x6dbfa/2] = 0x0004;
|
||||
rom[0x6dbfc/2] = 0x4e75; rom[0x6dbfe/2] = 0x4e71;
|
||||
}
|
||||
|
||||
static INT32 __fastcall MegadriveTAScallback(void)
|
||||
{
|
||||
return 0; // disable
|
||||
@ -3350,11 +3356,6 @@ INT32 MegadriveInit()
|
||||
MegadriveLoadRoms(0);
|
||||
if (MegadriveLoadRoms(1)) return 1;
|
||||
|
||||
if (strstr(BurnDrvGetTextA(DRV_NAME), "megaman")) {
|
||||
bprintf(0, _T("Megaman SRAM fix activated!\n"));
|
||||
sram_patch_megaman(); // after rom-load (must!)
|
||||
}
|
||||
|
||||
{
|
||||
SekInit(0, 0x68000); // Allocate 68000
|
||||
SekOpen(0);
|
||||
@ -4854,6 +4855,7 @@ INT32 MegadriveScan(INT32 nAction, INT32 *pnMin)
|
||||
ZetScan(nAction);
|
||||
BurnMD2612Scan(nAction, pnMin);
|
||||
SN76496Scan(nAction, pnMin);
|
||||
EEPROM_scan();
|
||||
|
||||
SCAN_VAR(Scanline);
|
||||
SCAN_VAR(Z80HasBus);
|
||||
@ -4873,7 +4875,7 @@ INT32 MegadriveScan(INT32 nAction, INT32 *pnMin)
|
||||
BurnRandomScan(nAction);
|
||||
}
|
||||
|
||||
if (nAction & ACB_NVRAM && RamMisc->SRamDetected) {
|
||||
if ((nAction & ACB_NVRAM && RamMisc->SRamDetected) || RamMisc->SRamHasSerialEEPROM) {
|
||||
struct BurnArea ba;
|
||||
memset(&ba, 0, sizeof(ba));
|
||||
ba.Data = SRam;
|
||||
|
Loading…
Reference in New Issue
Block a user