From 10e5a924df072b0062d3d2f945c12b357a041108 Mon Sep 17 00:00:00 2001 From: EkeEke Date: Sun, 2 Mar 2014 16:07:08 +0100 Subject: [PATCH] [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) --- core/cart_hw/sms_cart.c | 174 ++++++++++++++++++++-------------------- core/cart_hw/sms_cart.h | 2 +- core/genesis.c | 5 +- core/genesis.h | 2 +- core/memz80.c | 9 ++- core/memz80.h | 2 +- core/state.c | 4 +- core/state.h | 2 +- core/system.c | 4 +- core/system.h | 5 +- core/vdp_ctrl.c | 64 +++++++++++---- core/vdp_ctrl.h | 4 +- core/vdp_render.c | 9 ++- core/vdp_render.h | 4 +- gx/gui/menu.c | 10 ++- gx/gui/menu.h | 2 +- 16 files changed, 173 insertions(+), 129 deletions(-) diff --git a/core/cart_hw/sms_cart.c b/core/cart_hw/sms_cart.c index 3f1a24d..e244bd5 100644 --- a/core/cart_hw/sms_cart.c +++ b/core/cart_hw/sms_cart.c @@ -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= 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; diff --git a/core/cart_hw/sms_cart.h b/core/cart_hw/sms_cart.h index bf20336..d7e6583 100644 --- a/core/cart_hw/sms_cart.h +++ b/core/cart_hw/sms_cart.h @@ -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: diff --git a/core/genesis.c b/core/genesis.c index f15f2f7..c61073b 100644 --- a/core/genesis.c +++ b/core/genesis.c @@ -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; diff --git a/core/genesis.h b/core/genesis.h index a7b10a7..b4d885a 100644 --- a/core/genesis.h +++ b/core/genesis.h @@ -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: diff --git a/core/memz80.c b/core/memz80.c index 3a5d9b2..0165114 100644 --- a/core/memz80.c +++ b/core/memz80.c @@ -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; } diff --git a/core/memz80.h b/core/memz80.h index 27207f3..c570c21 100644 --- a/core/memz80.h +++ b/core/memz80.h @@ -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: diff --git a/core/state.c b/core/state.c index 50b99c2..8547949 100644 --- a/core/state.c +++ b/core/state.c @@ -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]); } diff --git a/core/state.h b/core/state.h index 678d632..6b480c0 100644 --- a/core/state.h +++ b/core/state.h @@ -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: diff --git a/core/system.c b/core/system.c index d80a255..bb74455 100644 --- a/core/system.c +++ b/core/system.c @@ -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) diff --git a/core/system.h b/core/system.h index b679421..3d1226a 100644 --- a/core/system.h +++ b/core/system.h @@ -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 diff --git a/core/vdp_ctrl.c b/core/vdp_ctrl.c index 4a80ae3..7d1f1dc 100644 --- a/core/vdp_ctrl.c +++ b/core/vdp_ctrl.c @@ -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; diff --git a/core/vdp_ctrl.h b/core/vdp_ctrl.h index 8a8ee8d..3519cf3 100644 --- a/core/vdp_ctrl.h +++ b/core/vdp_ctrl.h @@ -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: diff --git a/core/vdp_render.c b/core/vdp_render.c index 3677232..04b4288 100644 --- a/core/vdp_render.c +++ b/core/vdp_render.c @@ -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); } diff --git a/core/vdp_render.h b/core/vdp_render.h index 9ce924c..5a3a75c 100644 --- a/core/vdp_render.h +++ b/core/vdp_render.h @@ -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) diff --git a/gx/gui/menu.c b/gx/gui/menu.c index 1ca3651..b2380df 100644 --- a/gx/gui/menu.c +++ b/gx/gui/menu.c @@ -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"); diff --git a/gx/gui/menu.h b/gx/gui/menu.h index e10c225..b8608bd 100644 --- a/gx/gui/menu.h +++ b/gx/gui/menu.h @@ -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: