diff --git a/HISTORY.txt b/HISTORY.txt index d6392f0..d688c9a 100644 --- a/HISTORY.txt +++ b/HISTORY.txt @@ -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 diff --git a/builds/genesis_plus_gx_libretro.dll b/builds/genesis_plus_gx_libretro.dll index 5a2ee12..7b36337 100644 Binary files a/builds/genesis_plus_gx_libretro.dll and b/builds/genesis_plus_gx_libretro.dll differ diff --git a/builds/genplus_cube.dol b/builds/genplus_cube.dol index 2841d34..464fe29 100644 Binary files a/builds/genplus_cube.dol and b/builds/genplus_cube.dol differ diff --git a/builds/genplus_wii.dol b/builds/genplus_wii.dol index 49f5d06..c680350 100644 Binary files a/builds/genplus_wii.dol and b/builds/genplus_wii.dol differ diff --git a/core/cart_hw/sms_cart.c b/core/cart_hw/sms_cart.c index 3d4f932..6b3dd43 100644 --- a/core/cart_hw/sms_cart.c +++ b/core/cart_hw/sms_cart.c @@ -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) */ diff --git a/core/genesis.c b/core/genesis.c index 11a06d4..a76881f 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-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; diff --git a/core/genesis.h b/core/genesis.h index 7e1162a..04e0052 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-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: diff --git a/core/system.h b/core/system.h index d7ca95f..a9c0945 100644 --- a/core/system.h +++ b/core/system.h @@ -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,17 +45,18 @@ #include "blip_buf.h" /* Supported hardware models */ -#define SYSTEM_SG 0x10 -#define SYSTEM_SGII 0x11 -#define SYSTEM_MARKIII 0x12 -#define SYSTEM_SMS 0x20 -#define SYSTEM_SMS2 0x21 -#define SYSTEM_GG 0x40 -#define SYSTEM_GGMS 0x41 -#define SYSTEM_MD 0x80 -#define SYSTEM_PBC 0x81 -#define SYSTEM_PICO 0x82 -#define SYSTEM_MCD 0x84 +#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 +#define SYSTEM_GGMS 0x41 +#define SYSTEM_MD 0x80 +#define SYSTEM_PBC 0x81 +#define SYSTEM_PICO 0x82 +#define SYSTEM_MCD 0x84 /* NTSC & PAL Master Clock frequencies */ #define MCLOCK_NTSC 53693175 diff --git a/core/vdp_ctrl.c b/core/vdp_ctrl.c index a91757e..be7957c 100644 --- a/core/vdp_ctrl.c +++ b/core/vdp_ctrl.c @@ -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; diff --git a/core/vdp_render.c b/core/vdp_render.c index 070ac18..7aee11e 100644 --- a/core/vdp_render.c +++ b/core/vdp_render.c @@ -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); } diff --git a/gcw0/config.c b/gcw0/config.c index c92e6ba..c5a10d1 100644 --- a/gcw0/config.c +++ b/gcw0/config.c @@ -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) */ diff --git a/gcw0/main.c b/gcw0/main.c index 06ebe10..3ffe435 100644 --- a/gcw0/main.c +++ b/gcw0/main.c @@ -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; diff --git a/gcw0/utils.c b/gcw0/utils.c index 67ac55a..a350aef 100644 --- a/gcw0/utils.c +++ b/gcw0/utils.c @@ -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"; diff --git a/gx/docs/README.doc b/gx/docs/README.doc index 3c7df87..7242fd4 100644 Binary files a/gx/docs/README.doc and b/gx/docs/README.doc differ diff --git a/gx/docs/README.pdf b/gx/docs/README.pdf index 4379dfb..e0105e9 100644 Binary files a/gx/docs/README.pdf and b/gx/docs/README.pdf differ diff --git a/gx/gui/menu.c b/gx/gui/menu.c index 8118735..0271a27 100644 --- a/gx/gui/menu.c +++ b/gx/gui/menu.c @@ -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"); diff --git a/libretro/libretro.c b/libretro/libretro.c index 653ebb9..6c62e4f 100644 --- a/libretro/libretro.c +++ b/libretro/libretro.c @@ -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; diff --git a/libretro/libretro_core_options.h b/libretro/libretro_core_options.h index 882fef0..c843955 100644 --- a/libretro/libretro_core_options.h +++ b/libretro/libretro_core_options.h @@ -102,14 +102,15 @@ struct retro_core_option_v2_definition option_defs_us[] = { NULL, "system", { - { "auto", "Auto" }, - { "sg-1000", "SG-1000" }, - { "sg-1000 II", "SG-1000 II" }, - { "mark-III", "Mark III" }, - { "master system", "Master System" }, - { "master system II", "Master System II" }, - { "game gear", "Game Gear" }, - { "mega drive / genesis", "Mega Drive/Genesis" }, + { "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" }, + { "game gear", "Game Gear" }, + { "mega drive / genesis", "Mega Drive/Genesis" }, { NULL, NULL }, }, "auto" diff --git a/psp2/config.c b/psp2/config.c index f80c2c3..f1b74d3 100644 --- a/psp2/config.c +++ b/psp2/config.c @@ -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) */ diff --git a/sdl/config.c b/sdl/config.c index 5e2cf72..223d720 100644 --- a/sdl/config.c +++ b/sdl/config.c @@ -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) */