[Core/SG] added SG-1000 II hardware with 8KB RAM extension adapter in selectable hardware models (fixes #437)

This commit is contained in:
ekeeke 2022-10-29 13:51:34 +02:00
parent ec466a7c9e
commit 6ec9ac2729
20 changed files with 63 additions and 51 deletions

View File

@ -96,6 +96,7 @@ Genesis Plus GX 1.7.5 (xx/xx/xxxx) (Eke-Eke)
---------------
* added support for new SMS Power Korean dumps (Star Soldier & Pippols)
* added support for SG-1000 II clone hardware (2KB RAM + integrated VDP/PSG chip 315-5066)
* added support for SG-1000 II hardware with 8KB RAM extension adapter
* fixed SG-1000 internal RAM size (1KB instead of 2KB)
* fixed savestates for games using external RAM
* restored SG-1000 Pause button support

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 MiB

After

Width:  |  Height:  |  Size: 3.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 MiB

After

Width:  |  Height:  |  Size: 4.0 MiB

View File

@ -45,7 +45,6 @@
#define MAPPER_RAM_2K (0x02)
#define MAPPER_RAM_8K (0x03)
#define MAPPER_RAM_8K_EXT1 (0x04)
#define MAPPER_RAM_8K_EXT2 (0x05)
#define MAPPER_SEGA (0x10)
#define MAPPER_SEGA_X (0x11)
#define MAPPER_93C46 (0x12)
@ -160,7 +159,7 @@ static const rominfo_t game_list[] =
/* games using 8KB external RAM (volatile) */
{0x092F29D6, 0, 0, 0, MAPPER_RAM_8K, SYSTEM_SG, REGION_JAPAN_NTSC}, /* The Castle (J) */
/* games requiring SG-1000 II 8K RAM extension adapters */
/* games requiring SG-1000 II 8K RAM extension adapter (type A) */
{0xCE5648C3, 0, 0, 0, MAPPER_RAM_8K_EXT1, SYSTEM_SGII, REGION_JAPAN_NTSC}, /* Bomberman Special [DahJee] (TW) */
{0x223397A1, 0, 0, 0, MAPPER_RAM_8K_EXT1, SYSTEM_SGII, REGION_JAPAN_NTSC}, /* King's Valley (TW) */
{0x281D2888, 0, 0, 0, MAPPER_RAM_8K_EXT1, SYSTEM_SGII, REGION_JAPAN_NTSC}, /* Knightmare (TW) */
@ -172,11 +171,13 @@ static const rominfo_t game_list[] =
{0xFC87463C, 0, 0, 0, MAPPER_RAM_8K_EXT1, SYSTEM_SGII, REGION_JAPAN_NTSC}, /* Yie Ar Kung-Fu II (TW) */
{0xDF7CBFA5, 0, 0, 0, MAPPER_RAM_8K_EXT1, SYSTEM_SGII, REGION_JAPAN_NTSC}, /* Pippols (TW) */
{0xE0816BB7, 0, 0, 0, MAPPER_RAM_8K_EXT1, SYSTEM_SGII, REGION_JAPAN_NTSC}, /* Star Soldier (TW) */
{0x69FC1494, 0, 0, 0, MAPPER_RAM_8K_EXT2, SYSTEM_SGII, REGION_JAPAN_NTSC}, /* Bomberman Special (TW) */
{0xFFC4EE3F, 0, 0, 0, MAPPER_RAM_8K_EXT2, SYSTEM_SGII, REGION_JAPAN_NTSC}, /* Magical Kid Wiz (TW) */
{0x2E366CCF, 0, 0, 0, MAPPER_RAM_8K_EXT2, SYSTEM_SGII, REGION_JAPAN_NTSC}, /* The Castle (TW) */
{0xAAAC12CF, 0, 0, 0, MAPPER_RAM_8K_EXT2, SYSTEM_SGII, REGION_JAPAN_NTSC}, /* Rally-X (TW) */
{0xD2EDD329, 0, 0, 0, MAPPER_RAM_8K_EXT2, SYSTEM_SGII, REGION_JAPAN_NTSC}, /* Road Fighter (TW) */
/* games requiring SG-1000 II 8K RAM extension adapter (type B) */
{0x69FC1494, 0, 0, 0, MAPPER_NONE, SYSTEM_SGII_RAM_EXT, REGION_JAPAN_NTSC}, /* Bomberman Special (TW) */
{0xFFC4EE3F, 0, 0, 0, MAPPER_NONE, SYSTEM_SGII_RAM_EXT, REGION_JAPAN_NTSC}, /* Magical Kid Wiz (TW) */
{0x2E366CCF, 0, 0, 0, MAPPER_NONE, SYSTEM_SGII_RAM_EXT, REGION_JAPAN_NTSC}, /* The Castle (TW) */
{0xAAAC12CF, 0, 0, 0, MAPPER_NONE, SYSTEM_SGII_RAM_EXT, REGION_JAPAN_NTSC}, /* Rally-X (TW) */
{0xD2EDD329, 0, 0, 0, MAPPER_NONE, SYSTEM_SGII_RAM_EXT, REGION_JAPAN_NTSC}, /* Road Fighter (TW) */
/* games requiring 2KB internal RAM (SG-1000 II clone hardware) */
{0x7F7F009D, 0, 0, 0, MAPPER_NONE, SYSTEM_SGII, REGION_JAPAN_NTSC}, /* Circus Charlie (KR) */
@ -883,13 +884,13 @@ static void mapper_reset(void)
int i;
/* reset $C000-$FFFF mapping */
if (cart_rom.mapper == MAPPER_RAM_8K_EXT2)
if (system_hw == SYSTEM_SG)
{
/* 8KB RAM extension adapter (type B) */
/* original SG-1000 hardware has only 1KB internal RAM */
for (i = 0x30; i < 0x40; i++)
{
/* $C000-$FFFF mapped to 8KB external RAM (mirrored) */
z80_readmap[i] = z80_writemap[i] = &work_ram[(i & 0x07) << 10];
/* $C000-$FFFF mapped to 1KB internal RAM (mirrored) */
z80_readmap[i] = z80_writemap[i] = &work_ram[0];
}
}
else if (system_hw == SYSTEM_SGII)
@ -901,18 +902,9 @@ static void mapper_reset(void)
z80_readmap[i] = z80_writemap[i] = &work_ram[(i & 0x01) << 10];
}
}
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 1KB internal RAM (mirrored) */
z80_readmap[i] = z80_writemap[i] = &work_ram[0];
}
}
else
{
/* Mark III / Master System / Game Gear hardware */
/* Mark III / Master System / Game Gear hardware or SG-1000 II hardware with 8KB RAM extension adapter (type B) */
for (i = 0x30; i < 0x40; i++)
{
/* $C000-$FFFF mapped to 8KB internal RAM (mirrored) */

View File

@ -5,7 +5,7 @@
* Support for SG-1000, Mark-III, Master System, Game Gear, Mega Drive & Mega CD hardware
*
* Copyright (C) 1998-2003 Charles Mac Donald (original code)
* Copyright (C) 2007-2021 Eke-Eke (Genesis Plus GX)
* Copyright (C) 2007-2022 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:
@ -221,6 +221,7 @@ void gen_init(void)
/* SG-1000 hardware */
case SYSTEM_SG:
case SYSTEM_SGII:
case SYSTEM_SGII_RAM_EXT:
{
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-2003 Charles Mac Donald (original code)
* Copyright (C) 2007-2021 Eke-Eke (Genesis Plus GX)
* Copyright (C) 2007-2022 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 16-bit & 8-bit hardware modes
*
* Copyright (C) 1998-2003 Charles Mac Donald (original code)
* Copyright (C) 2007-2021 Eke-Eke (Genesis Plus GX)
* Copyright (C) 2007-2022 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:
@ -45,9 +45,10 @@
#include "blip_buf.h"
/* Supported hardware models */
#define SYSTEM_SG 0x10
#define SYSTEM_SGII 0x11
#define SYSTEM_MARKIII 0x12
#define SYSTEM_SG 0x01
#define SYSTEM_SGII 0x02
#define SYSTEM_SGII_RAM_EXT 0x03
#define SYSTEM_MARKIII 0x10
#define SYSTEM_SMS 0x20
#define SYSTEM_SMS2 0x21
#define SYSTEM_GG 0x40

View File

@ -362,6 +362,7 @@ void vdp_reset(void)
{
case SYSTEM_SG:
case SYSTEM_SGII:
case SYSTEM_SGII_RAM_EXT:
{
/* SG-1000 (TMS99xx) or SG-1000 II (315-5066) VDP */
vdp_z80_data_w = vdp_z80_data_w_sg;

View File

@ -1036,6 +1036,7 @@ void color_update_m4(int index, unsigned int data)
case SYSTEM_SG:
case SYSTEM_SGII:
case SYSTEM_SGII_RAM_EXT:
{
/* Fixed TMS99xx palette */
if (index & 0x0F)
@ -4748,7 +4749,7 @@ void render_line(int line)
/* Left-most column blanking */
if (reg[0] & 0x20)
{
if (system_hw > SYSTEM_SGII)
if (system_hw >= SYSTEM_MARKIII)
{
memset(&linebuf[0][0x20], 0x40, 8);
}

View File

@ -57,7 +57,7 @@ void set_config_defaults(void)
config.mono = 0;
/* system options */
config.system = 0; /* = AUTO (or SYSTEM_SG, SYSTEM_MARKIII, SYSTEM_SMS, SYSTEM_SMS2, SYSTEM_GG, SYSTEM_MD) */
config.system = 0; /* = AUTO (or SYSTEM_SG, SYSTEM_SGII, SYSTEM_SGII_RAM_EXT, SYSTEM_MARKIII, SYSTEM_SMS, SYSTEM_SMS2, SYSTEM_GG, SYSTEM_MD) */
config.region_detect = 0; /* = AUTO (1 = USA, 2 = EUROPE, 3 = JAPAN/NTSC, 4 = JAPAN/PAL) */
config.vdp_mode = 0; /* = AUTO (1 = NTSC, 2 = PAL) */
config.master_clock = 0; /* = AUTO (1 = NTSC, 2 = PAL) */

View File

@ -960,7 +960,7 @@ static int gcw0menu(void)
SDL_FreeSurface(tempbgSurface);
SDL_FreeSurface(bgSurface);
}
else if ( (system_hw == SYSTEM_SG) || (system_hw == SYSTEM_SGII) ) //SG-1000 I&II
else if ( (system_hw == SYSTEM_SG)|| (system_hw == SYSTEM_SGII) || (system_hw == SYSTEM_SGII_RAM_EXT) ) //SG-1000 I&II
{
SDL_Surface *tempbgSurface;
SDL_Surface *bgSurface;

View File

@ -119,9 +119,9 @@ char* get_save_directory(void) {
char pathname[MAXPATHLEN];
if(system_hw <= SYSTEM_MARKIII){
if(system_hw < SYSTEM_MARKIII){
system_dir = "/saves/sg";
} else if (system_hw > SYSTEM_MARKIII && system_hw <= SYSTEM_SMS2) {
} else if (system_hw >= SYSTEM_MARKIII && system_hw <= SYSTEM_SMS2) {
system_dir = "/saves/ms";
} else if (system_hw > SYSTEM_SMS2 && system_hw <= SYSTEM_GGMS) {
system_dir = "/saves/gg";

Binary file not shown.

Binary file not shown.

View File

@ -1300,6 +1300,8 @@ static void systemmenu ()
sprintf (items[0].text, "System: SG-1000");
else if (config.system == SYSTEM_SGII)
sprintf (items[0].text, "System: SG-1000 II");
else if (config.system == SYSTEM_SGII_RAM_EXT)
sprintf (items[0].text, "System: SG-1000 + RAM EXT.");
else if (config.system == SYSTEM_MARKIII)
sprintf (items[0].text, "System: MARK-III");
else if (config.system == SYSTEM_SMS)
@ -1416,6 +1418,12 @@ static void systemmenu ()
if (system_hw) system_hw = SYSTEM_SGII;
}
else if (config.system == SYSTEM_SGII)
{
config.system = SYSTEM_SGII_RAM_EXT;
sprintf (items[0].text, "System: SG-1000 + RAM EXT.");
if (system_hw) system_hw = SYSTEM_SGII_RAM_EXT;
}
else if (config.system == SYSTEM_SGII_RAM_EXT)
{
config.system = SYSTEM_MARKIII;
sprintf (items[0].text, "System: MARK-III");

View File

@ -1292,6 +1292,8 @@ static void check_variables(bool first_run)
config.system = SYSTEM_SG;
else if (var.value && !strcmp(var.value, "sg-1000 II"))
config.system = SYSTEM_SGII;
else if (var.value && !strcmp(var.value, "sg-1000 II + ram ext."))
config.system = SYSTEM_SGII_RAM_EXT;
else if (var.value && !strcmp(var.value, "mark-III"))
config.system = SYSTEM_MARKIII;
else if (var.value && !strcmp(var.value, "master system"))
@ -3423,7 +3425,11 @@ size_t retro_get_memory_size(unsigned id)
}
}
case RETRO_MEMORY_SYSTEM_RAM:
if (system_hw == SYSTEM_SMS || system_hw == SYSTEM_SMS2 || system_hw == SYSTEM_GG || system_hw == SYSTEM_GGMS)
if (system_hw == SYSTEM_SG)
return 0x00400;
else if (system_hw == SYSTEM_SGII)
return 0x00800;
else if (system_hw == SYSTEM_SGII_RAM_EXT || system_hw == SYSTEM_SMS || system_hw == SYSTEM_SMS2 || system_hw == SYSTEM_GG || system_hw == SYSTEM_GGMS || system_hw == SYSTEM_PBC)
return 0x02000;
else
return 0x10000;

View File

@ -105,6 +105,7 @@ struct retro_core_option_v2_definition option_defs_us[] = {
{ "auto", "Auto" },
{ "sg-1000", "SG-1000" },
{ "sg-1000 II", "SG-1000 II" },
{ "sg-1000 II + ram ext.","SG-1000 II + RAM Ext."},
{ "mark-III", "Mark III" },
{ "master system", "Master System" },
{ "master system II", "Master System II" },

View File

@ -26,7 +26,7 @@ void set_config_defaults(void)
config.mono = 0;
/* system options */
config.system = 0; /* = AUTO (or SYSTEM_SG, SYSTEM_MARKIII, SYSTEM_SMS, SYSTEM_SMS2, SYSTEM_GG, SYSTEM_MD) */
config.system = 0; /* = AUTO (or SYSTEM_SG, SYSTEM_SGII, SYSTEM_SGII_RAM_EXT, SYSTEM_MARKIII, SYSTEM_SMS, SYSTEM_SMS2, SYSTEM_GG, SYSTEM_MD) */
config.region_detect = 0; /* = AUTO (1 = USA, 2 = EUROPE, 3 = JAPAN/NTSC, 4 = JAPAN/PAL) */
config.vdp_mode = 0; /* = AUTO (1 = NTSC, 2 = PAL) */
config.master_clock = 0; /* = AUTO (1 = NTSC, 2 = PAL) */

View File

@ -29,7 +29,7 @@ void set_config_defaults(void)
config.mono = 0;
/* system options */
config.system = 0; /* = AUTO (or SYSTEM_SG, SYSTEM_MARKIII, SYSTEM_SMS, SYSTEM_SMS2, SYSTEM_GG, SYSTEM_MD) */
config.system = 0; /* = AUTO (or SYSTEM_SG, SYSTEM_SGII, SYSTEM_SGII_RAM_EXT, SYSTEM_MARKIII, SYSTEM_SMS, SYSTEM_SMS2, SYSTEM_GG, SYSTEM_MD) */
config.region_detect = 0; /* = AUTO (1 = USA, 2 = EUROPE, 3 = JAPAN/NTSC, 4 = JAPAN/PAL) */
config.vdp_mode = 0; /* = AUTO (1 = NTSC, 2 = PAL) */
config.master_clock = 0; /* = AUTO (1 = NTSC, 2 = PAL) */