[Core/MS] improved Z80 address decoding on Japanese Master System I/O chip (315-5297)

[Core/GG] modified VDP register 10 state on reset (fixes Terminator 2: Judgment Day)
[Core/SG] added support for SG-1000 II clone hardware (2KB RAM + integrated VDP/PSG chip 315-5066)
This commit is contained in:
EkeEke 2014-03-02 16:07:08 +01:00
parent e9fc71ec4f
commit 10e5a924df
16 changed files with 173 additions and 129 deletions

View File

@ -2,7 +2,7 @@
* Genesis Plus
* SG-1000, Master System & Game Gear cartridge hardware support
*
* Copyright (C) 2007-2013 Eke-Eke (Genesis Plus GX)
* Copyright (C) 2007-2014 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:
@ -42,9 +42,9 @@
#define MAPPER_NONE (0x00)
#define MAPPER_TEREBI (0x01)
#define MAPPER_RAM_8K_EXT1 (0x02)
#define MAPPER_RAM_8K_EXT2 (0x03)
#define MAPPER_OMV (0x04)
#define MAPPER_RAM_2K (0x02)
#define MAPPER_RAM_8K_EXT1 (0x03)
#define MAPPER_RAM_8K_EXT2 (0x04)
#define MAPPER_SEGA (0x10)
#define MAPPER_SEGA_X (0x11)
#define MAPPER_93C46 (0x12)
@ -56,8 +56,6 @@
#define MAPPER_MSX (0x21)
#define MAPPER_MSX_NEMESIS (0x22)
#define GAME_DATABASE_CNT (214)
typedef struct
{
uint32 crc;
@ -76,7 +74,7 @@ typedef struct
uint8 pages;
} romhw_t;
static const rominfo_t game_list[GAME_DATABASE_CNT] =
static const rominfo_t game_list[] =
{
/* program requiring Mega Drive VDP (Mode 5) */
{0x47FA618D, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_PBC, REGION_USA}, /* Charles MacDonald's Mode 5 Demo Program */
@ -91,8 +89,6 @@ static const rominfo_t game_list[GAME_DATABASE_CNT] =
{0x23BAC434, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA_X, SYSTEM_GG, REGION_USA}, /* Shining Force Gaiden - Final Conflict (JP) [T-Eng] */
/* games using various Korean mappers */
{0x17AB6883, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_NONE, SYSTEM_SMS, REGION_JAPAN_NTSC}, /* FA Tetris (KR) */
{0x61E8806F, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_NONE, SYSTEM_SMS, REGION_JAPAN_NTSC}, /* Flash Point (KR) */
{0x445525E2, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_MSX, SYSTEM_SMS, REGION_JAPAN_NTSC}, /* Penguin Adventure (KR) */
{0x83F0EEDE, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_MSX, SYSTEM_SMS, REGION_JAPAN_NTSC}, /* Street Master (KR) */
{0xA05258F5, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_MSX, SYSTEM_SMS, REGION_JAPAN_NTSC}, /* Won-Si-In (KR) */
@ -106,7 +102,6 @@ static const rominfo_t game_list[GAME_DATABASE_CNT] =
{0x89B79E77, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_KOREA, SYSTEM_SMS, REGION_JAPAN_NTSC}, /* Dodgeball King (KR) */
{0x18FB98A3, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_KOREA, SYSTEM_SMS, REGION_JAPAN_NTSC}, /* Jang Pung 3 (KR) */
{0x97D03541, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_KOREA, SYSTEM_SMS, REGION_JAPAN_NTSC}, /* Sangokushi 3 (KR) */
{0x67C2F0FF, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_KOREA, SYSTEM_SMS, REGION_JAPAN_NTSC}, /* Super Boy 2 (KR) */
{0x192949D5, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_KOREA_8K, SYSTEM_SMS, REGION_JAPAN_NTSC}, /* Janggun-ui Adeul (KR) */
{0x9FA727A0, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_KOREA_16K, SYSTEM_GGMS, REGION_USA}, /* Street Hero [Proto 0] [SMS-GG] (US) */
{0xFB481971, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_KOREA_16K, SYSTEM_GGMS, REGION_USA}, /* Street Hero [Proto 1] [SMS-GG] (US) */
@ -116,18 +111,18 @@ static const rominfo_t game_list[GAME_DATABASE_CNT] =
{0x8813514B, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_SMS2, REGION_EUROPE}, /* Excellent Dizzy Collection, The [Proto] */
{0xB9664AE1, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_SMS2, REGION_EUROPE}, /* Fantastic Dizzy */
{0xA577CE46, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_SMS2, REGION_EUROPE}, /* Micro Machines */
{0xEA5C3A6F, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_SMS2, REGION_USA}, /* Dinobasher - Starring Bignose the Caveman [Proto] */
{0xAA140C9C, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GGMS, REGION_USA}, /* Excellent Dizzy Collection, The [SMS-GG] */
{0xC888222B, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GGMS, REGION_USA}, /* Fantastic Dizzy [SMS-GG] */
{0x76C5BDFB, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GGMS, REGION_USA}, /* Jang Pung 2 [SMS-GG] */
{0x6CAA625B, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GG, REGION_USA}, /* Cosmic Spacehead [GG]*/
{0x152F0DCC, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GG, REGION_USA}, /* Drop Zone" */
{0x5E53C7F7, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GG, REGION_USA}, /* Ernie Els Golf */
{0xD9A7F170, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GG, REGION_USA}, /* Man Overboard! */
{0xF7C524F6, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GG, REGION_USA}, /* Micro Machines [GG] */
{0xDBE8895C, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GG, REGION_USA}, /* Micro Machines 2 - Turbo Tournament */
{0xC1756BEE, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GG, REGION_USA}, /* Pete Sampras Tennis */
{0x72981057, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GG, REGION_USA}, /* CJ Elephant Fugitive */
{0xEA5C3A6F, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_SMS2, REGION_USA}, /* Dinobasher - Starring Bignose the Caveman [Proto] */
{0xAA140C9C, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GGMS, REGION_USA}, /* Excellent Dizzy Collection, The [SMS-GG] */
{0xC888222B, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GGMS, REGION_USA}, /* Fantastic Dizzy [SMS-GG] */
{0x76C5BDFB, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GGMS, REGION_USA}, /* Jang Pung 2 [SMS-GG] */
{0x6CAA625B, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GG, REGION_USA}, /* Cosmic Spacehead [GG]*/
{0x152F0DCC, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GG, REGION_USA}, /* Drop Zone */
{0x5E53C7F7, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GG, REGION_USA}, /* Ernie Els Golf */
{0xD9A7F170, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GG, REGION_USA}, /* Man Overboard! */
{0xF7C524F6, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GG, REGION_USA}, /* Micro Machines [GG] */
{0xDBE8895C, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GG, REGION_USA}, /* Micro Machines 2 - Turbo Tournament */
{0xC1756BEE, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GG, REGION_USA}, /* Pete Sampras Tennis */
{0x72981057, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GG, REGION_USA}, /* CJ Elephant Fugitive */
/* games using serial EEPROM */
{0x36EBCD6D, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_93C46, SYSTEM_GG, REGION_USA}, /* Majors Pro Baseball */
@ -138,34 +133,39 @@ static const rominfo_t game_list[GAME_DATABASE_CNT] =
/* games using Terebi Oekaki graphic board */
{0xDD4A661B, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_TEREBI, SYSTEM_SG, REGION_JAPAN_NTSC}, /* Terebi Oekaki */
/* games requiring 8K RAM extension adapter */
{0xCE5648C3, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_RAM_8K_EXT1, SYSTEM_SG, REGION_JAPAN_NTSC}, /* Bomberman Special [DahJee] (TW) */
{0x223397A1, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_RAM_8K_EXT1, SYSTEM_SG, REGION_JAPAN_NTSC}, /* King's Valley (TW) */
{0x281D2888, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_RAM_8K_EXT1, SYSTEM_SG, REGION_JAPAN_NTSC}, /* Knightmare (TW) */
{0x306D5F78, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_RAM_8K_EXT1, SYSTEM_SG, REGION_JAPAN_NTSC}, /* Rally-X [DahJee] (TW) */
{0x29E047CC, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_RAM_8K_EXT1, SYSTEM_SG, REGION_JAPAN_NTSC}, /* Road Fighter (TW) */
{0x5CBD1163, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_RAM_8K_EXT1, SYSTEM_SG, REGION_JAPAN_NTSC}, /* Tank Battalion (TW) */
{0x2E7166D5, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_RAM_8K_EXT1, SYSTEM_SG, REGION_JAPAN_NTSC}, /* The Legend of Kage (TW) */
{0xC550B4F0, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_RAM_8K_EXT1, SYSTEM_SG, REGION_JAPAN_NTSC}, /* TwinBee (TW) */
{0xFC87463C, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_RAM_8K_EXT1, SYSTEM_SG, REGION_JAPAN_NTSC}, /* Yie Ar Kung-Fu II (TW) */
{0x69FC1494, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_RAM_8K_EXT2, SYSTEM_SG, REGION_JAPAN_NTSC}, /* Bomberman Special (TW) */
{0xFFC4EE3F, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_RAM_8K_EXT2, SYSTEM_SG, REGION_JAPAN_NTSC}, /* Magical Kid Wiz (TW) */
{0x2E366CCF, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_RAM_8K_EXT2, SYSTEM_SG, REGION_JAPAN_NTSC}, /* The Castle (TW) */
{0xAAAC12CF, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_RAM_8K_EXT2, SYSTEM_SG, REGION_JAPAN_NTSC}, /* Rally-X (TW) */
{0xD2EDD329, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_RAM_8K_EXT2, SYSTEM_SG, REGION_JAPAN_NTSC}, /* Road Fighter (TW) */
/* games using 2KB external RAM (volatile) */
{0x092F29D6, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_RAM_2K, SYSTEM_SG, REGION_JAPAN_NTSC}, /* The Castle (J) */
{0xAF4F14BC, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_RAM_2K, SYSTEM_SG, REGION_JAPAN_NTSC}, /* Othello (J) */
{0x1D1A0CA3, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_RAM_2K, SYSTEM_SGII, REGION_JAPAN_NTSC}, /* Othello (TW) */
/* games requiring 2K internal RAM (Othello Multivision hardware) */
{0x7F7F009D, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_OMV, SYSTEM_SG, REGION_JAPAN_NTSC}, /* Circus Charlie (KR) */
{0x77DB4704, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_OMV, SYSTEM_SG, REGION_JAPAN_NTSC}, /* Q*Bert */
{0xC5A67B95, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_OMV, SYSTEM_SG, REGION_JAPAN_NTSC}, /* Othello Multivision BIOS */
/* games requiring SG-1000 II 8K RAM extension adapter */
{0xCE5648C3, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_RAM_8K_EXT1, SYSTEM_SGII, REGION_JAPAN_NTSC}, /* Bomberman Special [DahJee] (TW) */
{0x223397A1, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_RAM_8K_EXT1, SYSTEM_SGII, REGION_JAPAN_NTSC}, /* King's Valley (TW) */
{0x281D2888, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_RAM_8K_EXT1, SYSTEM_SGII, REGION_JAPAN_NTSC}, /* Knightmare (TW) */
{0x306D5F78, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_RAM_8K_EXT1, SYSTEM_SGII, REGION_JAPAN_NTSC}, /* Rally-X [DahJee] (TW) */
{0x29E047CC, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_RAM_8K_EXT1, SYSTEM_SGII, REGION_JAPAN_NTSC}, /* Road Fighter (TW) */
{0x5CBD1163, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_RAM_8K_EXT1, SYSTEM_SGII, REGION_JAPAN_NTSC}, /* Tank Battalion (TW) */
{0x2E7166D5, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_RAM_8K_EXT1, SYSTEM_SGII, REGION_JAPAN_NTSC}, /* The Legend of Kage (TW) */
{0xC550B4F0, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_RAM_8K_EXT1, SYSTEM_SGII, REGION_JAPAN_NTSC}, /* TwinBee (TW) */
{0xFC87463C, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_RAM_8K_EXT1, SYSTEM_SGII, REGION_JAPAN_NTSC}, /* Yie Ar Kung-Fu II (TW) */
{0x69FC1494, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_RAM_8K_EXT2, SYSTEM_SGII, REGION_JAPAN_NTSC}, /* Bomberman Special (TW) */
{0xFFC4EE3F, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_RAM_8K_EXT2, SYSTEM_SGII, REGION_JAPAN_NTSC}, /* Magical Kid Wiz (TW) */
{0x2E366CCF, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_RAM_8K_EXT2, SYSTEM_SGII, REGION_JAPAN_NTSC}, /* The Castle (TW) */
{0xAAAC12CF, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_RAM_8K_EXT2, SYSTEM_SGII, REGION_JAPAN_NTSC}, /* Rally-X (TW) */
{0xD2EDD329, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_RAM_8K_EXT2, SYSTEM_SGII, REGION_JAPAN_NTSC}, /* Road Fighter (TW) */
/* games requiring 2K internal RAM (SG-1000 II clone hardware) */
{0x7F7F009D, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_NONE, SYSTEM_SGII, REGION_JAPAN_NTSC}, /* Circus Charlie (KR) */
{0x77DB4704, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_NONE, SYSTEM_SGII, REGION_JAPAN_NTSC}, /* Q*Bert */
{0xC5A67B95, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_NONE, SYSTEM_SGII, REGION_JAPAN_NTSC}, /* Othello Multivision BIOS */
/* games requiring Japanese region setting */
{0x71DEBA5A, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_GG, REGION_JAPAN_NTSC}, /* Pop Breaker */
{0xC9DD4E5F, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS, REGION_JAPAN_NTSC}, /* Woody Pop (Super Arkanoid) */
/* games requiring Mark-III hardware (no Memory Control port) */
{0xBD1CC7DF, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_MARKIII, REGION_JAPAN_NTSC}, /* Super Tetris (KR) */
{0x6D309AC5, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_MARKIII, REGION_JAPAN_NTSC}, /* Power Boggle Boggle (KR) */
/* games requiring Japanese Master System I/O chip (315-5297) */
{0xBD1CC7DF, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS, REGION_JAPAN_NTSC}, /* Super Tetris (KR) */
{0x6D309AC5, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS, REGION_JAPAN_NTSC}, /* Power Boggle Boggle (KR) */
/* games requiring random RAM pattern initialization */
{0x08BF3DE3, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_NONE, SYSTEM_MARKIII, REGION_JAPAN_NTSC}, /* Alibaba and 40 Thieves (KR) */
@ -368,7 +368,7 @@ static unsigned char read_mapper_default(unsigned int address);
void sms_cart_init(void)
{
int i;
int i = sizeof(game_list) / sizeof(rominfo_t) - 1;
/* game CRC */
uint32 crc = crc32(0, cart.rom, cart.romsize);
@ -401,7 +401,7 @@ void sms_cart_init(void)
}
/* auto-detect game settings */
for (i=0; i<GAME_DATABASE_CNT; i++)
do
{
if (crc == game_list[i].crc)
{
@ -427,9 +427,10 @@ void sms_cart_init(void)
}
/* game found, leave loop */
i = GAME_DATABASE_CNT;
break;
}
}
while (i--);
/* ROM paging */
if (cart_rom.mapper < MAPPER_SEGA)
@ -672,7 +673,7 @@ void sms_cart_switch(uint8 mode)
int sms_cart_region_detect(void)
{
int i;
int i = sizeof(game_list) / sizeof(rominfo_t) - 1;
/* compute CRC */
uint32 crc = crc32(0, cart.rom, cart.romsize);
@ -684,13 +685,14 @@ int sms_cart_region_detect(void)
}
/* game database */
for (i=0; i<GAME_DATABASE_CNT; i++)
do
{
if (crc == game_list[i].crc)
{
return game_list[i].region;
}
}
while(i--);
/* Mark-III hardware */
if (system_hw == SYSTEM_MARKIII)
@ -721,44 +723,40 @@ static void mapper_reset(void)
{
int i;
/* reset internal RAM mapping */
if (system_hw == SYSTEM_SG)
/* reset $C000-$FFFF mapping */
if (cart_rom.mapper == MAPPER_RAM_8K_EXT2)
{
/* 8k RAM extension adapter (type B) */
if (cart_rom.mapper == MAPPER_RAM_8K_EXT2)
for (i = 0x30; i < 0x40; i++)
{
/* $C000-$FFFF mapped to 8k external RAM (mirrored) */
for (i = 0x30; i < 0x40; i++)
{
z80_readmap[i] = z80_writemap[i] = &work_ram[(i & 0x07) << 10];
}
z80_readmap[i] = z80_writemap[i] = &work_ram[(i & 0x07) << 10];
}
/* Othello Multivision hardware */
else if (cart_rom.mapper == MAPPER_OMV)
}
else if (system_hw == SYSTEM_SGII)
{
/* SG-1000 II clone hardware with 2KB internal RAM */
for (i = 0x30; i < 0x40; i++)
{
/* $C000-$FFFF mapped to 2k internal RAM (mirrored) */
for (i = 0x30; i < 0x40; i++)
{
z80_readmap[i] = z80_writemap[i] = &work_ram[(i & 0x01) << 10];
}
z80_readmap[i] = z80_writemap[i] = &work_ram[(i & 0x01) << 10];
}
/* default SG-1000 hardware */
else
}
else if (system_hw == SYSTEM_SG)
{
/* default SG-1000 hardware has only 1KB internal RAM */
for (i = 0x30; i < 0x40; i++)
{
/* $C000-$FFFF mapped to 1k internal RAM (mirrored) */
for (i = 0x30; i < 0x40; i++)
{
z80_readmap[i] = z80_writemap[i] = &work_ram[0];
}
z80_readmap[i] = z80_writemap[i] = &work_ram[0];
}
}
else
{
/* Master System / Game Gear hardware: $C000-$FFFF mapped to 8k internal RAM (mirrored) */
/* Mark III / Master System / Game Gear hardware */
for (i = 0x30; i < 0x40; i++)
{
/* $C000-$FFFF mapped to 8k internal RAM (mirrored) */
z80_readmap[i] = z80_writemap[i] = &work_ram[(i & 0x07) << 10];
}
}
@ -779,37 +777,34 @@ static void mapper_reset(void)
return;
}
/* by default, $0000-$BFFF is mapped to ROM (first 48k) */
/* reset $0000-$BFFF mapping */
for (i = 0x00; i < 0x30; i++)
{
/* by default, $0000-$BFFF is mapped to cartridge ROM (first 48k) */
z80_readmap[i] = &slot.rom[i << 10];
z80_writemap[i] = cart.rom + 0x510000; /* unused area */
}
/* reset cartridge hardware mapping */
if (slot.mapper < MAPPER_SEGA)
if (slot.mapper == MAPPER_RAM_8K_EXT1)
{
/* cartridge extra RAM enabled by default with 32K ROM (The Castle) */
if (slot.pages <= 0x20)
{
/* $8000-$BFFF mapped to 8k external RAM (mirrored) */
for (i = 0x20; i < 0x30; i++)
{
z80_readmap[i] = z80_writemap[i] = &work_ram[0x2000 + ((i & 0x07) << 10)];
}
}
/* 8k RAM extension adapter (type A) */
if (slot.mapper == MAPPER_RAM_8K_EXT1)
for (i = 0x08; i < 0x10; i++)
{
/* $2000-$3FFF mapped to 8k external RAM */
for (i = 0x08; i < 0x10; i++)
{
z80_readmap[i] = z80_writemap[i] = &work_ram[0x2000 + ((i & 0x07) << 10)];
}
z80_readmap[i] = z80_writemap[i] = &work_ram[0x2000 + ((i & 0x07) << 10)];
}
}
else
else if (slot.mapper == MAPPER_RAM_2K)
{
/* 2k on-board RAM (The Castle, Othello) */
for (i = 0x20; i < 0x30; i++)
{
/* $8000-$BFFF mapped to 2k external RAM (mirrored) */
z80_readmap[i] = z80_writemap[i] = &work_ram[0x2000 + ((i & 0x07) << 10)];
}
}
else if (slot.mapper >= MAPPER_SEGA)
{
/* reset ROM paging hardware */
if (slot.mapper & MAPPER_KOREA_8K)
@ -844,6 +839,7 @@ static void mapper_reset(void)
switch (slot.mapper)
{
case MAPPER_NONE:
case MAPPER_RAM_2K:
case MAPPER_RAM_8K_EXT1:
case MAPPER_RAM_8K_EXT2:
z80_readmem = read_mapper_default;

View File

@ -2,7 +2,7 @@
* Genesis Plus
* SG-1000, Master System & Game Gear cartridge hardware support
*
* Copyright (C) 2007-2013 Eke-Eke (Genesis Plus GX)
* Copyright (C) 2007-2014 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:

View File

@ -5,7 +5,7 @@
* Support for SG-1000, Mark-III, Master System, Game Gear, Mega Drive & Mega CD hardware
*
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code)
* Copyright (C) 2007-2013 Eke-Eke (Genesis Plus GX)
* Copyright (C) 2007-2014 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:
@ -196,7 +196,7 @@ void gen_init(void)
break;
}
/* Master SYstem hardware */
/* Master System hardware */
case SYSTEM_SMS:
case SYSTEM_SMS2:
{
@ -215,6 +215,7 @@ void gen_init(void)
/* SG-1000 hardware */
case SYSTEM_SG:
case SYSTEM_SGII:
{
z80_writeport = z80_sg_port_w;
z80_readport = z80_sg_port_r;

View File

@ -5,7 +5,7 @@
* Support for SG-1000, Mark-III, Master System, Game Gear, Mega Drive & Mega CD hardware
*
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code)
* Copyright (C) 2007-2013 Eke-Eke (Genesis Plus GX)
* Copyright (C) 2007-2014 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:

View File

@ -5,7 +5,7 @@
* Support for SG-1000, Mark-III, Master System, Game Gear & Mega Drive ports access
*
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code)
* Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX)
* Copyright (C) 2007-2014 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:
@ -430,6 +430,13 @@ void z80_ms_port_w(unsigned int port, unsigned char data)
case 0x00:
case 0x01:
{
/* full address range is decoded by 315-5297 I/O chip (fixes Super Tetris / Power Boggle Boggle) */
if ((region_code == REGION_JAPAN_NTSC) && ((port & 0xFE) != 0x3E))
{
z80_unused_port_w(port & 0xFF, data);
return;
}
io_z80_write(port & 1, data, Z80.cycles + SMS_CYCLE_OFFSET);
return;
}

View File

@ -5,7 +5,7 @@
* Support for SG-1000, Mark-III, Master System, Game Gear & Mega Drive ports access
*
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code)
* Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX)
* Copyright (C) 2007-2014 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:

View File

@ -2,7 +2,7 @@
* Genesis Plus
* Savestate support
*
* Copyright (C) 2007-2012 Eke-Eke (Genesis Plus GX)
* Copyright (C) 2007-2014 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:
@ -121,7 +121,7 @@ int state_load(unsigned char *state)
}
else
{
SN76489_Init(snd.blips[0][0], snd.blips[0][1], (system_hw < SYSTEM_MARKIII) ? SN_DISCRETE : SN_INTEGRATED);
SN76489_Init(snd.blips[0][0], snd.blips[0][1], (system_hw == SYSTEM_SG) ? SN_DISCRETE : SN_INTEGRATED);
SN76489_Config(0, config.psg_preamp, config.psgBoostNoise, io_reg[6]);
}

View File

@ -2,7 +2,7 @@
* Genesis Plus
* Savestate support
*
* Copyright (C) 2007-2012 Eke-Eke (Genesis Plus GX)
* Copyright (C) 2007-2014 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:

View File

@ -5,7 +5,7 @@
* Support for "Genesis", "Genesis + CD" & "Master System" modes
*
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code)
* Copyright (C) 2007-2013 Eke-Eke (Genesis Plus GX)
* Copyright (C) 2007-2014 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:
@ -111,7 +111,7 @@ int audio_init(int samplerate, double framerate)
blip_set_rates(snd.blips[0][1], mclk, samplerate);
/* Initialize PSG core */
SN76489_Init(snd.blips[0][0], snd.blips[0][1], (system_hw < SYSTEM_MARKIII) ? SN_DISCRETE : SN_INTEGRATED);
SN76489_Init(snd.blips[0][0], snd.blips[0][1], (system_hw == SYSTEM_SG) ? SN_DISCRETE : SN_INTEGRATED);
/* Mega CD sound hardware */
if (system_hw == SYSTEM_MCD)

View File

@ -5,7 +5,7 @@
* Support for "Genesis", "Genesis + CD" & "Master System" modes
*
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code)
* Copyright (C) 2007-2013 Eke-Eke (Genesis Plus GX)
* Copyright (C) 2007-2014 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:
@ -46,7 +46,8 @@
/* Supported hardware models */
#define SYSTEM_SG 0x10
#define SYSTEM_MARKIII 0x11
#define SYSTEM_SGII 0x11
#define SYSTEM_MARKIII 0x12
#define SYSTEM_SMS 0x20
#define SYSTEM_SMS2 0x21
#define SYSTEM_GG 0x40

View File

@ -2,10 +2,10 @@
* Genesis Plus
* Video Display Processor (68k & Z80 CPU interface)
*
* Support for SG-1000, Master System (315-5124 & 315-5246), Game Gear & Mega Drive VDP
* Support for SG-1000 (TMS99xx & 315-5066), Master System (315-5124 & 315-5246), Game Gear & Mega Drive VDP
*
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code)
* Copyright (C) 2007-2013 Eke-Eke (Genesis Plus GX)
* Copyright (C) 2007-2014 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:
@ -322,8 +322,9 @@ void vdp_reset(void)
switch (system_hw)
{
case SYSTEM_SG:
case SYSTEM_SGII:
{
/* SG-1000 VDP (TMS99xx) */
/* SG-1000 (TMS99xx) or SG-1000 II (315-5066) VDP */
vdp_z80_data_w = vdp_z80_data_w_sg;
vdp_z80_data_r = vdp_z80_data_r_m4;
break;
@ -358,19 +359,23 @@ void vdp_reset(void)
}
/* SG-1000 specific */
if (system_hw == SYSTEM_SG)
if (system_hw & SYSTEM_SG)
{
/* 16k address decoding by default (Magical Kid Wiz) */
vdp_reg_w(1, 0x80, 0);
/* no H-INT on TMS99xx */
vdp_reg_w(10, 0xFF, 0);
}
/* Game Gear specific */
else if (system_hw & SYSTEM_GG)
{
/* H-INT disabled on startup (fixes Terminator 2: Judgement Day) */
vdp_reg_w(10, 0xFF, 0);
}
/* Master System specific */
else if ((system_hw & SYSTEM_SMS) && (!(config.bios & 1) || !(system_bios & SYSTEM_SMS)))
{
/* force registers initialization (only if Master System BIOS is disabled or not loaded) */
/* force registers initialization (normally done by BOOT ROM on all Master System models) */
vdp_reg_w(0 , 0x36, 0);
vdp_reg_w(1 , 0x80, 0);
vdp_reg_w(2 , 0xFF, 0);
@ -389,7 +394,7 @@ void vdp_reset(void)
/* Mega Drive specific */
else if (((system_hw == SYSTEM_MD) || (system_hw == SYSTEM_MCD)) && (config.bios & 1) && !(system_bios & SYSTEM_MD))
{
/* force registers initialization (only if TMSS model is emulated and BOOT ROM is not loaded) */
/* force registers initialization (normally done by BOOT ROM, only on Mega Drive model with TMSS) */
vdp_reg_w(0 , 0x04, 0);
vdp_reg_w(1 , 0x04, 0);
vdp_reg_w(10, 0xFF, 0);
@ -445,7 +450,7 @@ int vdp_context_load(uint8 *state, uint8 version)
/* restore VDP registers */
if (system_hw < SYSTEM_MD)
{
if (system_hw > SYSTEM_SG)
if (system_hw >= SYSTEM_MARKIII)
{
for (i=0;i<0x10;i++)
{
@ -1632,6 +1637,37 @@ static void vdp_reg_w(unsigned int r, unsigned int d, unsigned int cycles)
r = d ^ reg[1];
reg[1] = d;
/* 4K/16K address decoding */
if (r & 0x80)
{
/* original TMS99xx hardware only (fixes Magical Kid Wiz) */
if (system_hw == SYSTEM_SG)
{
int i;
/* make temporary copy of 16KB VRAM */
memcpy(vram + 0x4000, vram, 0x4000);
/* re-arrange 16KB VRAM address decoding */
if (d & 0x80)
{
/* 4K->16K address decoding */
for (i=0; i<0x4000; i+=2)
{
*(uint16 *)(vram + ((i & 0x203F) | ((i << 6) & 0x1000) | ((i >> 1) & 0xFC0))) = *(uint16 *)(vram + 0x4000 + i);
}
}
else
{
/* 16K->4K address decoding */
for (i=0; i<0x4000; i+=2)
{
*(uint16 *)(vram + ((i & 0x203F) | ((i >> 6) & 0x40) | ((i << 1) & 0x1F80))) = *(uint16 *)(vram + 0x4000 + i);
}
}
}
}
/* Display status (modified during active display) */
if ((r & 0x40) && (v_counter < bitmap.viewport.h))
{
@ -2762,7 +2798,7 @@ static unsigned int vdp_z80_data_r_m4(void)
/* Process next read */
fifo[0] = vram[addr & 0x3FFF];
/* Increment address register (TODO: check how address is incremented in Mode 4) */
/* Increment address register (TODO: check how address is incremented with Mega Drive VDP in Mode 4) */
addr += (reg[15] + 1);
/* Return data */
@ -2978,12 +3014,6 @@ static void vdp_z80_data_w_sg(unsigned int data)
/* Clear pending flag */
pending = 0;
/* 4K address decoding (cf. tms9918a.txt) */
if (!(reg[1] & 0x80))
{
index = (index & 0x203F) | ((index >> 6) & 0x40) | ((index << 1) & 0x1F80);
}
/* VRAM write */
vram[index] = data;

View File

@ -2,10 +2,10 @@
* Genesis Plus
* Video Display Processor (68k & Z80 CPU interface)
*
* Support for SG-1000, Master System (315-5124 & 315-5246), Game Gear & Mega Drive VDP
* Support for SG-1000 (TMS99xx & 315-5066), Master System (315-5124 & 315-5246), Game Gear & Mega Drive VDP
*
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code)
* Copyright (C) 2007-2013 Eke-Eke (Genesis Plus GX)
* Copyright (C) 2007-2014 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:

View File

@ -1,11 +1,11 @@
/***************************************************************************************
* Genesis Plus
* Video Display Processor (Modes 0, 1, 2, 3, 4 & 5 rendering)
* Video Display Processor (video output rendering)
*
* Support for SG-1000, Master System (315-5124 & 315-5246), Game Gear & Mega Drive VDP
* Support for all TMS99xx modes, Mode 4 & Mode 5 rendering
*
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code)
* Copyright (C) 2007-2013 Eke-Eke (Genesis Plus GX)
* Copyright (C) 2007-2014 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:
@ -1023,6 +1023,7 @@ void color_update_m4(int index, unsigned int data)
}
case SYSTEM_SG:
case SYSTEM_SGII:
{
/* Fixed TMS99xx palette */
if (index & 0x0F)
@ -4103,7 +4104,7 @@ void render_line(int line)
/* Left-most column blanking */
if (reg[0] & 0x20)
{
if (system_hw > SYSTEM_SG)
if (system_hw > SYSTEM_SGII)
{
memset(&linebuf[0][0x20], 0x40, 8);
}

View File

@ -1,8 +1,8 @@
/***************************************************************************************
* Genesis Plus
* Video Display Processor (Modes 0, 1, 2, 3, 4 & 5 rendering)
* Video Display Processor (video output rendering)
*
* Support for SG-1000, Master System (315-5124 & 315-5246), Game Gear & Mega Drive VDP
* Support for all TMS99xx modes, Mode 4 & Mode 5 rendering
*
* Copyright (C) 1998-2007 Charles Mac Donald (original code)
* Copyright (C) 2007-2013 Eke-Eke (Genesis Plus GX)

View File

@ -3,7 +3,7 @@
*
* Genesis Plus GX menu
*
* Copyright Eke-Eke (2009-2013)
* Copyright Eke-Eke (2009-2014)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:
@ -1081,6 +1081,8 @@ static void systemmenu ()
sprintf (items[0].text, "Console Type: AUTO");
else if (config.system == SYSTEM_SG)
sprintf (items[0].text, "Console Type: SG-1000");
else if (config.system == SYSTEM_SGII)
sprintf (items[0].text, "Console Type: SG-1000 II");
else if (config.system == SYSTEM_MARKIII)
sprintf (items[0].text, "Console Type: MARK-III");
else if (config.system == SYSTEM_SMS)
@ -1166,6 +1168,12 @@ static void systemmenu ()
if (system_hw) system_hw = SYSTEM_SG;
}
else if (config.system == SYSTEM_SG)
{
config.system = SYSTEM_SGII;
sprintf (items[0].text, "Console Type: SG-1000 II");
if (system_hw) system_hw = SYSTEM_SGII;
}
else if (config.system == SYSTEM_SGII)
{
config.system = SYSTEM_MARKIII;
sprintf (items[0].text, "Console Type: MARK-III");

View File

@ -3,7 +3,7 @@
*
* Genesis Plus GX menus
*
* Copyright Eke-Eke (2009-2013)
* Copyright Eke-Eke (2009-2014)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met: