Skip to content

Commit

Permalink
Mapper: added mapper 27 for '2 Hap in 1 - David-2 ~ Moai-ui bomul (oc…
Browse files Browse the repository at this point in the history
  • Loading branch information
bsittler authored and ocornut committed Mar 20, 2023
1 parent 3cb1c30 commit ec6d139
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 1 deletion.
3 changes: 2 additions & 1 deletion meka/compat.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
SMS-MD: This version is an MD cartridge using the SMS compatibility mode
-----------------------------------------------------------------------------
128 Hap (KR) - *Ok
2 Hap in 1 - David-2 ~ Moai-ui bomul - *Ok
20 em 1 (BR) - Ok
3D Gunner [Proto] LP,3D Ok
4 PAK All Action (AU) - Ok
Expand Down Expand Up @@ -671,7 +672,7 @@
Zillion II: The Tri Formation [Proto] FM Ok
Zool - Ok
-----------------------------------------------------------------------------
650 games tested - 646 are "Ok"
651 games tested - 647 are "Ok"
-----------------------------------------------------------------------------

-----------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions meka/meka.nam
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
; 24 : sms korean xx-in-1, register at 0xFFF0, 0xFFFE, 0xFFFE (used in MD multicart with SMS games)
; 25 : sms korean xx-in-1, register at 0xFFF5, 0xFFFE, 0xFFFE (used in MD multicart with SMS games)
; 26 : sms korean xx-in-1, register at 0xFFFA, 0xFFFE, 0xFFFE (used in MD multicart with SMS games)
; 27 : sms korean xx-in-1, register at 0x2000
;-----------------------------------------------------------------------------

;-----------------------------------------------------------------------------
Expand Down Expand Up @@ -88,6 +89,7 @@
;-----------------------------------------------------------------------------

SMS ba5ec0e3 0707EB856DC38BC7 128 Hap (KR)/COUNTRY=KR/EMU_MAPPER=19
SMS 1b3e032e 8479DA42A3D4F67A 2 Hap in 1 - David-2 ~ Moai-ui bomul/COUNTRY=KR/EMU_MAPPER=27
SMS f0f35c22 02079D9D9AF6B27B 20 em 1/COUNTRY=BR
SMS 56dcb2d4 9FA930C396F93600 3D Gunner [Proto]/EMU_MAPPER=0/EMU_INPUTS=LIGHTPHASER/EMU_3D/EMU_LP_FUNC=2/COMMENT=Prototype version of the unreleased game.
SMS a67f2a5c 4EB5F14E8488C9E9 4 PAK All Action/COUNTRY=AU/EMU_MAPPER=14
Expand Down
18 changes: 18 additions & 0 deletions meka/srcs/machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,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_SMS_Korean_MSX_32KB_2000:
WrZ80 = WrZ80_NoHook = Write_Mapper_SMS_Korean_MSX_32KB_2000;
break;
}
}

Expand Down Expand Up @@ -467,6 +470,21 @@ void Machine_Set_Mapping (void)
g_machine.mapper_regs[2] = 1;
break;

case MAPPER_SMS_Korean_MSX_32KB_2000:
Map_8k_ROM(0, 0 & tsms.Pages_Mask_8k);
Map_8k_ROM(1, 1 & tsms.Pages_Mask_8k);
Map_8k_ROM(2, 2 & tsms.Pages_Mask_8k);
Map_8k_ROM(3, 3 & tsms.Pages_Mask_8k);
Map_8k_ROM(4, 4 & tsms.Pages_Mask_8k);
Map_8k_ROM(5, 5 & tsms.Pages_Mask_8k);
Map_8k_RAM(6, 0);
Map_8k_RAM(7, 0);
g_machine.mapper_regs_count = 1;
for (int i = 0; i != MAPPER_REGS_MAX; i++)
g_machine.mapper_regs[i] = 0;
g_machine.mapper_regs[0] = 0;
break;

case MAPPER_SC3000_Survivors_Multicart:
g_machine.mapper_regs_count = 1;
for (int i = 0; i != MAPPER_REGS_MAX; i++)
Expand Down
24 changes: 24 additions & 0 deletions meka/srcs/mappers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,30 @@ WRITE_FUNC(Write_Mapper_SMS_Korean_MD_FFFA)
Write_Error(Addr, Value);
}

// Mapper #27
// 2 Hap in 1 - David-2 ~ Moai-ui bomul
WRITE_FUNC (Write_Mapper_SMS_Korean_MSX_32KB_2000)
{
if (Addr == 0x2000) // Configurable segment -----------------------------------------------
{
g_machine.mapper_regs[0] = Value;
Map_8k_ROM(2, (Value * 4 + 2) & tsms.Pages_Mask_8k);
Map_8k_ROM(3, (Value * 4 + 3) & tsms.Pages_Mask_8k);
Map_8k_ROM(4, (Value * 4 + 4) & tsms.Pages_Mask_8k);
Map_8k_ROM(5, (Value * 4 + 5) & tsms.Pages_Mask_8k);
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.
Expand Down
2 changes: 2 additions & 0 deletions meka/srcs/mappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_SMS_Korean_MSX_32KB_2000 (27) // Register at 0x2000 (2 Hap in 1 - David-2 ~ Moai-ui bomul)

#define READ_FUNC(_NAME) u8 _NAME(register u16 Addr)
#define WRITE_FUNC(_NAME) void _NAME(register u16 Addr, register u8 Value)
Expand Down Expand Up @@ -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_SMS_Korean_MSX_32KB_2000);
//-----------------------------------------------------------------------------
void Out_SC3000_SurvivorsMulticarts_DataWrite(u8 v);

Expand Down
5 changes: 5 additions & 0 deletions meka/srcs/saves.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ void Load_Game_Fixup(void)
WrZ80_NoHook(0xFFFF, g_machine.mapper_regs[1]);
WrZ80_NoHook(0xFFFE, g_machine.mapper_regs[2]);
break;
case MAPPER_SMS_Korean_MSX_32KB_2000:
WrZ80_NoHook(0x2000, g_machine.mapper_regs[0]);
break;
}
}

Expand Down Expand Up @@ -335,6 +338,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_SMS_Korean_MSX_32KB_2000:
default:
fwrite (RAM, 0x2000, 1, f); // Do not use g_driver->ram because of g_driver video mode change
break;
Expand Down Expand Up @@ -513,6 +517,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_SMS_Korean_MSX_32KB_2000:
default:
fread (RAM, 0x2000, 1, f); // Do not use g_driver->ram because of g_driver video mode change
break;
Expand Down

0 comments on commit ec6d139

Please sign in to comment.