coleco, add some games and emulate mapper chip

This commit is contained in:
dinkc64 2024-02-17 12:24:22 -05:00
parent fdd87ff061
commit 0c8bfc12cf

View File

@ -19,6 +19,7 @@ static UINT8 *DrvCartROM;
static UINT8 *DrvZ80RAM;
static UINT8 *DrvSGM24kRAM;
static UINT8 *DrvSGM8kRAM;
static UINT8 *DrvEEPROM;
static INT32 joy_mode;
static INT32 joy_status[2];
@ -39,10 +40,12 @@ static UINT8 spinner[2] = { 0, 0 };
static UINT32 MegaCart; // MegaCart size
static UINT32 MegaCartBank; // current Bank
static UINT32 MegaCartBanks; // total banks
static INT32 OCMBanks[4];
static INT32 use_EEPROM = 0;
static INT32 use_SGM = 0;
static INT32 use_SAC = 0; // 1 = SuperAction, 2 = ROLLER
static INT32 use_OCM = 0;
static INT32 SGM_map_24k;
static INT32 SGM_map_8k;
@ -271,10 +274,19 @@ static struct BurnDIPInfo ROLLERDIPList[]=
STDDIPINFO(ROLLER)
void update_map()
{
if (!use_SGM) return;
if (use_OCM) {
ZetMapMemory(DrvCartROM + OCMBanks[3] * 0x2000, 0x8000, 0x9fff, MAP_ROM);
ZetMapMemory(DrvCartROM + OCMBanks[0] * 0x2000, 0xa000, 0xbfff, MAP_ROM);
ZetMapMemory(DrvCartROM + OCMBanks[1] * 0x2000, 0xc000, 0xdfff, MAP_ROM);
// ZetMapMemory(DrvCartROM + OCMBanks[2] * 0x2000, 0xe000, 0xffff, MAP_ROM);
}
if (SGM_map_24k) {
ZetMapMemory(DrvSGM24kRAM, 0x2000, 0x7fff, MAP_RAM);
} else {
@ -321,7 +333,7 @@ static UINT8 controller_read(INT32 port)
static void __fastcall coleco_write_port(UINT16 port, UINT8 data)
{
if (use_SGM) {
if (use_SGM) {
switch (port & 0xff) // SGM
{
case 0x50:
@ -332,7 +344,7 @@ static void __fastcall coleco_write_port(UINT16 port, UINT8 data)
AY8910Write(0, 1, data);
return;
case 0x53:
case 0x53:
SGM_map_24k = data & 1;
update_map();
return;
@ -475,9 +487,28 @@ static INT32 DrvDoReset()
scanline = 0;
lets_nmi = -1;
if (use_OCM) {
// Penguin Adventure expects this to be mapped-in by default
SGM_map_24k = 1;
ZetOpen(0);
update_map();
ZetClose();
}
return 0;
}
static UINT8 O_EEPROM_OK = 0xff;
static INT32 O_EEPROM_CmdPos = 0;
static INT32 O_EEPROM_State = 0;
enum {
EEP_NONE = 0 << 1,
EEP_INIT = 1 << 1,
EEP_STATUS = 2 << 1,
EEP_WRITE = 3 << 1
};
static void __fastcall main_write(UINT16 address, UINT8 data)
{
// maybe we should support bankswitching on writes too?
@ -489,14 +520,74 @@ static void __fastcall main_write(UINT16 address, UINT8 data)
case 0xffa0:
case 0xffb0:
MegaCartBank = (address >> 4) & 3;
return;
return;
}
}
if (use_OCM) {
if (address >= 0xe000 && address <= 0xfffb) {
if (data == 0xaa && O_EEPROM_CmdPos == 0) {
O_EEPROM_CmdPos++;
}
else if (data == 0x55 && O_EEPROM_CmdPos == 1) {
O_EEPROM_CmdPos++;
}
else if (O_EEPROM_CmdPos == 2) {
switch (data) {
case 0x80: {
O_EEPROM_State = EEP_INIT;
break;
}
case 0x30: {
if (O_EEPROM_State == EEP_INIT) {
O_EEPROM_State = EEP_STATUS;
}
break;
}
case 0xa0: {
O_EEPROM_State = EEP_WRITE;
break;
}
default: {
bprintf(0, _T("--> EEP Unknown command-byte! %x @ %x\n"), data, address);
break;
}
}
O_EEPROM_CmdPos = 0;
}
else if (O_EEPROM_State == EEP_WRITE) {
DrvEEPROM[address & 0x3ff] = data;
O_EEPROM_State = EEP_NONE;
}
}
switch (address) {
case 0xfffc:
case 0xfffd:
case 0xfffe:
case 0xffff:
OCMBanks[address & 0x03] = data & 0xf;
update_map();
return;
}
}
bprintf(0, _T("mw %x %x\n"), address, data);
}
static UINT8 __fastcall main_read(UINT16 address)
{
if (use_OCM && address >= 0xe000 && address <= 0xffff) {
if (address == 0xe000 && O_EEPROM_State == EEP_STATUS) {
return O_EEPROM_OK;
}
if (OCMBanks[2] == 0xf && (address & 0x1fff) < 0x3ff) {
return DrvEEPROM[address & 0x3ff];
} else {
return DrvCartROM[(OCMBanks[2] * 0x2000) + (address - 0xe000)];
}
}
if (address >= 0xffc0/* && address <= 0xffff*/) {
MegaCartBank = (0xffff - address) & (MegaCartBanks - 1);
@ -509,7 +600,6 @@ static UINT8 __fastcall main_read(UINT16 address)
return DrvCartROM[(MegaCartBank * 0x4000) + (address - 0xc000)];
//bprintf(0, _T("mr %X,"), address);
return 0;
}
@ -520,6 +610,8 @@ static INT32 MemIndex()
DrvZ80BIOS = Next; Next += 0x004000;
DrvCartROM = Next; Next += 0x100000;
DrvEEPROM = Next; Next += 0x000400; // 1k for OCM
AllRam = Next;
DrvZ80RAM = Next; Next += 0x000400;
@ -576,7 +668,17 @@ static INT32 DrvInit()
ZetMapMemory(DrvCartROM, 0x8000, 0xbfff, MAP_ROM);
ZetSetReadHandler(main_read);
ZetSetWriteHandler(main_write);
}
} else if (use_OCM) {
MegaCart = 0;
bprintf(0, _T("ColecoVision OCM mapper w/EEPROM.\n"));
ZetSetReadHandler(main_read);
ZetSetWriteHandler(main_write);
OCMBanks[0] = 3;
OCMBanks[1] = 2;
OCMBanks[2] = 1;
OCMBanks[3] = 0;
update_map();
}
else if (MegaCart) {
// MegaCart
MegaCartBanks = MegaCart / 0x4000;
@ -584,7 +686,7 @@ static INT32 DrvInit()
bprintf(0, _T("ColecoVision MegaCart: mapping cartrom[%X] to 0x8000 - 0xbfff.\n"), lastbank);
ZetMapMemory(DrvCartROM + lastbank, 0x8000, 0xbfff, MAP_ROM);
ZetSetReadHandler(main_read);
//ZetSetWriteHandler(main_write);
update_map();
} else {
// Regular CV Cart
ZetMapMemory(DrvCartROM, 0x8000, 0xffff, MAP_ROM);
@ -608,6 +710,10 @@ static INT32 DrvInit()
BurnTrackballInit(2);
BurnTrackballSetVelocityCurve(1);
if (use_OCM) {
memset(DrvEEPROM, 0xff, 0x10);
}
DrvDoReset();
return 0;
@ -644,6 +750,14 @@ static INT32 DrvInitEEPROM() // w/EEPROM (boxxle)
return DrvInit();
}
static INT32 DrvInitOCM()
{
use_OCM = 1;
use_SGM = 1;
return DrvInit();
}
static INT32 DrvExit()
{
TMS9928AExit();
@ -658,6 +772,7 @@ static INT32 DrvExit()
use_SGM = 0;
use_EEPROM = 0;
use_SAC = 0;
use_OCM = 0;
return 0;
}
@ -732,7 +847,7 @@ static INT32 DrvFrame()
}
INT32 nInterleave = 262;
INT32 nCyclesTotal[1] = { 3579545 / 60 };
INT32 nCyclesTotal[1] = { (INT32)(3579545 / 59.92) };
INT32 nCyclesDone[1] = { 0 };
ZetNewFrame();
@ -793,6 +908,10 @@ static INT32 DrvScan(INT32 nAction, INT32 *pnMin)
AY8910Scan(nAction, pnMin);
}
if (use_OCM) {
SCAN_VAR(OCMBanks);
}
if (use_SAC) {
BurnTrackballScan();
SCAN_VAR(spinner);
@ -808,6 +927,10 @@ static INT32 DrvScan(INT32 nAction, INT32 *pnMin)
SCAN_VAR(SGM_map_8k);
}
if (nAction & ACB_NVRAM && use_OCM) {
ScanVar(DrvEEPROM, 0x400, "NV RAM");
}
if (nAction & ACB_WRITE) {
if (use_SGM) {
ZetOpen(0);
@ -7078,6 +7201,25 @@ struct BurnDriver BurnDrvcv_gpworld = {
272, 228, 4, 3
};
// Gradius (SGM) (HB)
static struct BurnRomInfo cv_GradiusRomDesc[] = {
{ "Gradius SGM (2016)(Opcode Games).rom", 131072, 0x30d337e4, BRF_ESS | BRF_PRG },
};
STDROMPICKEXT(cv_Gradius, cv_Gradius, cv_coleco)
STD_ROM_FN(cv_Gradius)
struct BurnDriver BurnDrvcv_Gradius = {
"cv_gradius", NULL, "cv_coleco", NULL, "1986-2016",
"Gradius (SGM) (HB)\0", NULL, "Opcode Games - Konami", "ColecoVision",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_HOMEBREW, 2, HARDWARE_COLECO, GBF_HORSHOOT, 0,
CVGetZipName, cv_GradiusRomInfo, cv_GradiusRomName, NULL, NULL, NULL, NULL, ColecoInputInfo, ColecoDIPInfo,
DrvInitOCM, DrvExit, DrvFrame, TMS9928ADraw, DrvScan, NULL, TMS9928A_PALETTE_SIZE,
272, 228, 4, 3
};
// Gulkave (HB)
static struct BurnRomInfo cv_gulkaveRomDesc[] = {
@ -8161,6 +8303,25 @@ struct BurnDriver BurnDrvcv_mrchin = {
272, 228, 4, 3
};
// Mr. Do! Run Run (SGM) (HB)
static struct BurnRomInfo cv_mrdorunrunRomDesc[] = {
{ "Mr. Do! Run Run SGM (2022)(CollectorVision).rom", 131072, 0x13d53b3c, BRF_PRG | BRF_ESS },
};
STDROMPICKEXT(cv_mrdorunrun, cv_mrdorunrun, cv_coleco)
STD_ROM_FN(cv_mrdorunrun)
struct BurnDriver BurnDrvcv_mrdorunrun = {
"cv_mrdorunrun", NULL, "cv_coleco", NULL, "1987-2022",
"Mr. Do! Run Run (SGM) (HB)\0", "SGM - Published by CollectorVision Games", "Universal", "ColecoVision",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_HOMEBREW, 2, HARDWARE_COLECO, GBF_ACTION, 0,
CVGetZipName, cv_mrdorunrunRomInfo, cv_mrdorunrunRomName, NULL, NULL, NULL, NULL, ColecoInputInfo, ColecoDIPInfo,
DrvInitSGM, DrvExit, DrvFrame, TMS9928ADraw, DrvScan, NULL, TMS9928A_PALETTE_SIZE,
272, 228, 4, 3
};
// Ms. Space Fury (HB)
static struct BurnRomInfo cv_msspacefuryRomDesc[] = {
@ -8446,6 +8607,25 @@ struct BurnDriver BurnDrvcv_pegged = {
272, 228, 4, 3
};
// Penguin Adventure (SGM) (HB)
static struct BurnRomInfo cv_PenguinadvRomDesc[] = {
{ "Penguin Adventure SGM (2016)(Opcode Games).rom", 131072, 0x6831ad48, BRF_ESS | BRF_PRG },
};
STDROMPICKEXT(cv_Penguinadv, cv_Penguinadv, cv_coleco)
STD_ROM_FN(cv_Penguinadv)
struct BurnDriver BurnDrvcv_Penguinadv = {
"cv_penguinadv", NULL, "cv_coleco", NULL, "1986-2016",
"Penguin Adventure (SGM) (HB)\0", NULL, "Opcode Games - Konami", "ColecoVision",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_HOMEBREW, 1, HARDWARE_COLECO, GBF_ACTION, 0,
CVGetZipName, cv_PenguinadvRomInfo, cv_PenguinadvRomName, NULL, NULL, NULL, NULL, ColecoInputInfo, ColecoDIPInfo,
DrvInitOCM, DrvExit, DrvFrame, TMS9928ADraw, DrvScan, NULL, TMS9928A_PALETTE_SIZE,
272, 228, 4, 3
};
// Penguin Land (HB)
static struct BurnRomInfo cv_penguinlandRomDesc[] = {