From 05db1e373ef73fa8a0f4da32554f61b21bb3f837 Mon Sep 17 00:00:00 2001 From: "Benjamin C. Wiley Sittler" Date: Mon, 27 Feb 2023 00:52:51 -0500 Subject: [PATCH] Add mapper `#32` MAPPER_GG_FFF8_FFF9_FFFA_FFFE_FFFF for "Super GG 68 in 1" multicart Mapper #27 is skipped because I expect #90 may land first. Mapper #28 is skipped because I expect #91 may land first. Mapper #29 is skipped because I expect #93 may land first. Mapper #30 is skipped because I expect #94 may land first. Mapper #31 is skipped because I expect #95 may land first. There is still some glitchiness in the save-state mechanism that needs to be resolved, but all games other than Choplifter at least start. --- meka/compat.txt | 3 +- meka/meka.nam | 1 + meka/srcs/machine.cpp | 23 ++++++++++++++++ meka/srcs/mappers.cpp | 64 +++++++++++++++++++++++++++++++++++++++++++ meka/srcs/mappers.h | 2 ++ meka/srcs/saves.cpp | 52 +++++++++++++++++++++++++++++++++-- 6 files changed, 141 insertions(+), 4 deletions(-) diff --git a/meka/compat.txt b/meka/compat.txt index 1a98aee9..98fc075c 100644 --- a/meka/compat.txt +++ b/meka/compat.txt @@ -1407,6 +1407,7 @@ Super Battletank Ok Super Columns Ok Super Columns (JP) Ok + Super GG 68 in 1 *Ok Super Golf (JP) Ok Super Kick Off [SMS-GG] Ok Superman - The Man of Steel Ok @@ -1497,7 +1498,7 @@ Zoop (US) Ok Zoop [Proto] (US) Ok ----------------------------------------------------------------------------- - 517 games tested - 506 are "Ok" - Compatibility rate: 97.63% + 518 games tested - 507 are "Ok" - Compatibility rate: 97.88% ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- diff --git a/meka/meka.nam b/meka/meka.nam index 56e07012..f8e90726 100644 --- a/meka/meka.nam +++ b/meka/meka.nam @@ -1289,6 +1289,7 @@ GG b421c057 96BD12C62621B8D6 Striker/COUNTRY=EU/PRODUCT_NO=2551-50 GG 73d6745a 18CC99C9849C9901 Super Battletank/COUNTRY=US/PRODUCT_NO=1239 GG 8ba43af3 DAA4C785B7042952 Super Columns/COUNTRY=US,EU/PRODUCT_NO=2449,2449-50 GG 2a100717 E7260408CEC8EE63 Super Columns/COUNTRY=JP/PRODUCT_NO=G-3226 +GG 99ee7296 8F378BEF3668D84A Super GG 68 in 1/EMU_MAPPER=32 GG 528cbbce FAE75543A7740E5E Super Golf/COUNTRY=JP/PRODUCT_NO=T-26017,T-26027 GG 73df5a15 43574420E8CF212A Superman - The Man of Steel/COUNTRY=EU/PRODUCT_NO=T-70068,70068-00 GG aa3f2172 0A5C6040EBCF152B Superman - The Man of Steel [Proto]/FLAGS=PROTO/COMMENT=Prototype version of the game. diff --git a/meka/srcs/machine.cpp b/meka/srcs/machine.cpp index 76391b00..516b9ec6 100644 --- a/meka/srcs/machine.cpp +++ b/meka/srcs/machine.cpp @@ -22,6 +22,7 @@ #include "tvtype.h" #include "sound/fmunit.h" #include "sound/psg.h" +#include "app_game.h" //----------------------------------------------------------------------------- // Data @@ -193,6 +194,9 @@ void Machine_Set_Handler_MemRW(void) case MAPPER_SMS_Korean_MD_FFFA: WrZ80 = WrZ80_NoHook = Write_Mapper_SMS_Korean_MD_FFFA; break; + case MAPPER_GG_FFF8_FFF9_FFFA_FFFE_FFFF: + WrZ80 = WrZ80_NoHook = Write_Mapper_GG_FFF8_FFF9_FFFA_FFFE_FFFF; + break; } } @@ -467,6 +471,25 @@ void Machine_Set_Mapping (void) g_machine.mapper_regs[2] = 1; break; + case MAPPER_GG_FFF8_FFF9_FFFA_FFFE_FFFF: + Map_8k_ROM(0, 0x00 & tsms.Pages_Mask_8k); + Map_8k_ROM(1, 0x01 & tsms.Pages_Mask_8k); + Map_8k_ROM(2, 0x02 & tsms.Pages_Mask_8k); + Map_8k_ROM(3, 0x03 & tsms.Pages_Mask_8k); + Map_8k_ROM(4, 0x00 & tsms.Pages_Mask_8k); + Map_8k_ROM(5, 0x01 & tsms.Pages_Mask_8k); + Map_8k_RAM(6, 0); + Map_8k_RAM(7, 0); + g_machine.mapper_regs_count = 6; + for (int i = 0; i != MAPPER_REGS_MAX; i++) + g_machine.mapper_regs[i] = 0; + g_machine.mapper_regs[2] = 1; + drv_set(DRV_GG); + gamebox_resize_all(); + VDP_UpdateLineLimits(); + Video_GameMode_UpdateBounds(); + break; + case MAPPER_SC3000_Survivors_Multicart: g_machine.mapper_regs_count = 1; for (int i = 0; i != MAPPER_REGS_MAX; i++) diff --git a/meka/srcs/mappers.cpp b/meka/srcs/mappers.cpp index 1fc1b3ad..01e6c3ea 100644 --- a/meka/srcs/mappers.cpp +++ b/meka/srcs/mappers.cpp @@ -14,6 +14,9 @@ #include "shared.h" #include "mappers.h" #include "eeprom.h" +#include "vdp.h" +#include "video.h" +#include "app_game.h" //----------------------------------------------------------------------------- // Data @@ -928,6 +931,67 @@ WRITE_FUNC(Write_Mapper_SMS_Korean_MD_FFFA) Write_Error(Addr, Value); } +// Mapper #32 +// Super GG 68 in 1 +WRITE_FUNC(Write_Mapper_GG_FFF8_FFF9_FFFA_FFFE_FFFF) +{ + if ((Addr == 0xFFF8) || (Addr == 0xFFF9) || (Addr == 0xFFFA) || (Addr == 0xFFFE) || (Addr == 0xFFFF)) // Configurable segment ----------------------------------------------- + { + if (Addr == 0xFFF8) { + g_machine.mapper_regs[5] = Value; + } else if (Addr == 0xFFF9) { + g_machine.mapper_regs[4] = Value; + } else if (Addr == 0xFFFA) { + g_machine.mapper_regs[3] = Value; + if ((Value == 0x01) && (g_machine.mapper_regs[4] == 0x00) && (g_machine.mapper_regs[5] == 0x00)) { + g_machine.mapper_regs[0] = 0x40; + } + } else if (Addr == 0xFFFE) { + g_machine.mapper_regs[2] = Value; + if ((Value == 0x01) && (g_machine.mapper_regs[0] == 0x40)) { + bool second_megabyte_active = (g_machine.mapper_regs[4] & 0x12) || (g_machine.mapper_regs[3] & 0x04); + bool sega_mapper_active = (g_machine.mapper_regs[4] & 0x1E) || (g_machine.mapper_regs[3] & 0x04); + g_machine.mapper_regs[0] = (g_machine.mapper_regs[5] & 0x1F) | (second_megabyte_active ? 0x20 : 0x00) | (sega_mapper_active ? 0x80 : 0x00); + } + } else if (Addr == 0xFFFF) { + g_machine.mapper_regs[1] = Value; + } + if (1) { + bool sega_mapper_active = g_machine.mapper_regs[0] & 0x80; + bool second_megabyte_active = g_machine.mapper_regs[0] & 0x20; + unsigned int sega_mapper_mask = sega_mapper_active ? (second_megabyte_active ? 0x1F : 0x0F) : 0x01; + unsigned int page_0000_8k = (g_machine.mapper_regs[0] & 0x3F) * 4; + unsigned int page_4000_8k = page_0000_8k + ((g_machine.mapper_regs[2] & sega_mapper_mask) * 2); + unsigned int page_8000_8k = page_0000_8k + ((g_machine.mapper_regs[1] & sega_mapper_mask) * 2); + Map_8k_ROM(0, page_0000_8k & tsms.Pages_Mask_8k); + Map_8k_ROM(1, (page_0000_8k | 0x01) & tsms.Pages_Mask_8k); + Map_8k_ROM(2, page_4000_8k & tsms.Pages_Mask_8k); + Map_8k_ROM(3, (page_4000_8k | 0x01) & tsms.Pages_Mask_8k); + Map_8k_ROM(4, page_8000_8k & tsms.Pages_Mask_8k); + Map_8k_ROM(5, (page_8000_8k | 0x01) & tsms.Pages_Mask_8k); + } + bool sms_gg_mode_active = (g_machine.mapper_regs[4] & 0x80) || (g_machine.mapper_regs[3] & 0x01); + if (sms_gg_mode_active) { + drv_set(DRV_SMS); + } else { + drv_set(DRV_GG); + } + gamebox_resize_all(); + VDP_UpdateLineLimits(); + Video_GameMode_UpdateBounds(); + //return; + } + + switch (Addr >> 13) + { + // RAM [0xC000] = [0xE000] ------------------------------------------------ + case 6: Mem_Pages[6][Addr] = Value; return; + case 7: Mem_Pages[7][Addr] = Value; return; + } + + Write_Error(Addr, Value); +} + // Based on MSX ASCII 8KB mapper? http://bifi.msxnet.org/msxnet/tech/megaroms.html#ascii8 // - This mapper requires 4 registers to save bank switching state. // However, all other mappers so far used only 3 registers, stored as 3 bytes. diff --git a/meka/srcs/mappers.h b/meka/srcs/mappers.h index 57d66a32..ef0fb7a9 100644 --- a/meka/srcs/mappers.h +++ b/meka/srcs/mappers.h @@ -49,6 +49,7 @@ #define MAPPER_SMS_Korean_MD_FFF0 (24) // Registers at 0xFFF0 and 0xFFFF (Mega Mode Super Game 30 [SMS-MD]) #define MAPPER_SMS_Korean_MD_FFF5 (25) // Registers at 0xFFF5 and 0xFFFF (Jaemiissneun Game Mo-eumjip 42/65 Hap [SMS-MD], Pigu Wang Hap ~ Jaemiiss-neun Game Mo-eumjip [SMS-MD]) #define MAPPER_SMS_Korean_MD_FFFA (26) // Registers at 0xFFFA and 0xFFFF (Game Jiphap 30 Hap [SMS-MD]) +#define MAPPER_GG_FFF8_FFF9_FFFA_FFFE_FFFF (32) // Registers at 0xFFF8, 0xFFF9, 0xFFFA, 0xFFFE, and 0xFFFF (Super GG 68 in 1) #define READ_FUNC(_NAME) u8 _NAME(register u16 Addr) #define WRITE_FUNC(_NAME) void _NAME(register u16 Addr, register u8 Value) @@ -94,6 +95,7 @@ WRITE_FUNC (Write_Mapper_SMS_Korean_0000_xor_FF); WRITE_FUNC (Write_Mapper_SMS_Korean_MD_FFF0); WRITE_FUNC (Write_Mapper_SMS_Korean_MD_FFF5); WRITE_FUNC (Write_Mapper_SMS_Korean_MD_FFFA); +WRITE_FUNC (Write_Mapper_GG_FFF8_FFF9_FFFA_FFFE_FFFF); //----------------------------------------------------------------------------- void Out_SC3000_SurvivorsMulticarts_DataWrite(u8 v); diff --git a/meka/srcs/saves.cpp b/meka/srcs/saves.cpp index 74b6b060..ba841b4d 100644 --- a/meka/srcs/saves.cpp +++ b/meka/srcs/saves.cpp @@ -26,6 +26,7 @@ void Load_Game_Fixup(void) { int i; u8 b; + bool sms_gg_mode_in_mapper = false; // CPU #ifdef MARAT_Z80 @@ -141,13 +142,56 @@ void Load_Game_Fixup(void) WrZ80_NoHook(0xFFFF, g_machine.mapper_regs[1]); WrZ80_NoHook(0xFFFE, g_machine.mapper_regs[2]); break; + case MAPPER_GG_FFF8_FFF9_FFFA_FFFE_FFFF: + if (1) { + bool sega_mapper_active = g_machine.mapper_regs[0] & 0x80; + bool mapper_latch_open = g_machine.mapper_regs[0] & 0x40; + bool second_megabyte_active = g_machine.mapper_regs[0] & 0x20; + unsigned int base_page_32k = g_machine.mapper_regs[0] & 0x1F; + unsigned int reg_FFF8 = g_machine.mapper_regs[5]; + unsigned int reg_FFF9 = g_machine.mapper_regs[4]; + unsigned int reg_FFFA = g_machine.mapper_regs[3]; + unsigned int reg_FFFE = g_machine.mapper_regs[2]; + unsigned int reg_FFFF = g_machine.mapper_regs[1]; + WrZ80_NoHook(0xFFF9, 0x00); + WrZ80_NoHook(0xFFF8, 0x00); + WrZ80_NoHook(0xFFFA, 0x01); + WrZ80_NoHook(0xFFF8, base_page_32k); + WrZ80_NoHook(0xFFF9, (reg_FFF9 & 0x80) | ((sega_mapper_active && second_megabyte_active) ? 0x12 : 0x00) | ((sega_mapper_active && !second_megabyte_active) ? 0x0C : 0x00)); + WrZ80_NoHook(0xFFFA, (reg_FFFA & 0x01) | ((sega_mapper_active && second_megabyte_active) ? 0x04 : 0x00)); + WrZ80_NoHook(0xFFFE, 0x01); + if (g_machine.mapper_regs[1] != reg_FFFF) { + WrZ80_NoHook(0xFFFF, reg_FFFF); + } + if (g_machine.mapper_regs[2] != reg_FFFE) { + WrZ80_NoHook(0xFFFE, reg_FFFE); + } + if (mapper_latch_open) { + WrZ80_NoHook(0xFFF9, 0x00); + WrZ80_NoHook(0xFFF8, 0x00); + WrZ80_NoHook(0xFFFA, 0x01); + } + if (g_machine.mapper_regs[4] != reg_FFF9) { + WrZ80_NoHook(0xFFF9, reg_FFF9); + } + if (g_machine.mapper_regs[5] != reg_FFF8) { + WrZ80_NoHook(0xFFF8, reg_FFF8); + } + if (g_machine.mapper_regs[3] != reg_FFFA) { + WrZ80_NoHook(0xFFFA, reg_FFFA); + } + sms_gg_mode_in_mapper = true; + } + break; } } // VDP/Graphic related - tsms.VDP_Video_Change |= VDP_VIDEO_CHANGE_ALL; - VDP_UpdateLineLimits(); - // FALSE!!! // tsms.VDP_Line = 224; + if (!sms_gg_mode_in_mapper) { + tsms.VDP_Video_Change |= VDP_VIDEO_CHANGE_ALL; + VDP_UpdateLineLimits(); + // FALSE!!! // tsms.VDP_Line = 224; + } // Rewrite all VDP registers (we can do that since it has zero side-effect) for (i = 0; i < 16; i ++) @@ -335,6 +379,7 @@ int Save_Game_MSV(FILE *f) case MAPPER_SMS_Korean_MD_FFF0: case MAPPER_SMS_Korean_MD_FFF5: case MAPPER_SMS_Korean_MD_FFFA: + case MAPPER_GG_FFF8_FFF9_FFFA_FFFE_FFFF: default: fwrite (RAM, 0x2000, 1, f); // Do not use g_driver->ram because of g_driver video mode change break; @@ -513,6 +558,7 @@ int Load_Game_MSV(FILE *f) case MAPPER_SMS_Korean_MD_FFF0: case MAPPER_SMS_Korean_MD_FFF5: case MAPPER_SMS_Korean_MD_FFFA: + case MAPPER_GG_FFF8_FFF9_FFFA_FFFE_FFFF: default: fread (RAM, 0x2000, 1, f); // Do not use g_driver->ram because of g_driver video mode change break;