From 5b80d7785547b2dfd101311e51121525832d1f8f Mon Sep 17 00:00:00 2001 From: Fabio Priuli Date: Sat, 23 Feb 2013 14:28:39 +0000 Subject: [PATCH] (MESS) gameboy.c: fixed cart type for MBC1 collection games, promoting Bomberman Collection, Genjin Collection, Momotarou Collection, Mortal Kombat I & II and Super Chinese Land 1.2.3 to working state [Fabio Priuli] gbcolor.c: added support for Sintax mapper, promoting a dozen of pirate games to working state [taizou, Fabio Priuli] --- hash/gameboy.xml | 30 +-- hash/gbcolor.xml | 453 ++++++------------------------------- src/mess/drivers/gb.c | 80 +++---- src/mess/machine/gb_mbc.c | 177 ++++++++++++++- src/mess/machine/gb_mbc.h | 34 ++- src/mess/machine/gb_slot.c | 29 ++- src/mess/machine/gb_slot.h | 3 +- 7 files changed, 336 insertions(+), 470 deletions(-) diff --git a/hash/gameboy.xml b/hash/gameboy.xml index c32e79f71bf..f523e22b3ad 100644 --- a/hash/gameboy.xml +++ b/hash/gameboy.xml @@ -2150,7 +2150,7 @@ - + Bomberman Collection (Jpn) 1996 @@ -2159,7 +2159,7 @@ - + @@ -6502,7 +6502,7 @@ - + Genjin Collection (Jpn) 1996 @@ -6511,7 +6511,7 @@ - + @@ -10859,7 +10859,7 @@ - + Mani 4 in 1 (Chi, DMG-603 CHN) 19?? Mani @@ -10872,20 +10872,6 @@ - - - Mani 4 in 1 (Chi, DMG-603 CHN, Hacked) - 19?? - Mani - - - - - - - - - Marble Madness (Euro, USA) 1991 @@ -11969,7 +11955,7 @@ - + @@ -12339,7 +12325,7 @@ Acclaim Entertainment - + @@ -19543,7 +19529,7 @@ - + diff --git a/hash/gbcolor.xml b/hash/gbcolor.xml index 5027b886a8d..555dae31d88 100644 --- a/hash/gbcolor.xml +++ b/hash/gbcolor.xml @@ -2241,7 +2241,7 @@ Undumped Pirates: Hudson Soft - + @@ -22731,6 +22731,7 @@ Undumped Pirates: Sachen + @@ -22745,16 +22746,19 @@ Undumped Pirates: --> - + Lei Nu Ji Shen (Tw) 2000 GOWIN + + + @@ -22875,7 +22879,7 @@ Undumped Pirates: - + Ice Age II (Chi) 20?? Sintax @@ -22969,13 +22973,14 @@ Undumped Pirates: - + + Pocket Monster Ruby (Chi) 200? Sintax - + @@ -22985,29 +22990,14 @@ Undumped Pirates: - - Pocket Monster Ruby (Chi, Hacked) - 200? - Sintax - - - - - - - - - - - - - + + Pocket Monster Saphire (Chi) 200? Sintax - + @@ -23017,30 +23007,15 @@ Undumped Pirates: - - Pocket Monster Saphire (Chi, Hacked) - 200? - Sintax - - - - - - - - - - - - - + + Kou Dai Guai Shou - Lan Bao Shi (Chi) 200? Sintax - + @@ -23050,29 +23025,14 @@ Undumped Pirates: - - Kou Dai Guai Shou - Lan Bao Shi (Chi, Hacked) - 200? - Sintax - - - - - - - - - - - - - + + Shu Ma Bao Long - Shui Jing Ban II (Chi) 200? Sintax - + @@ -23082,29 +23042,14 @@ Undumped Pirates: - - Shu Ma Bao Long - Shui Jing Ban II (Chi, Hacked) - 200? - Sintax - - - - - - - - - - - - - + + The Firmament Baby (Chi) 200? Sintax - + @@ -23114,29 +23059,14 @@ Undumped Pirates: - - The Firmament Baby (Chi, Hacked) - 200? - Sintax - - - - - - - - - - - - - + + Tai Kong Bao Bei (Chi) 200? Sintax - + @@ -23146,29 +23076,14 @@ Undumped Pirates: - - Tai Kong Bao Bei (Chi, Hacked) - 200? - Sintax - - - - - - - - - - - - - + + Xiao Taichi - Shen Hua Li Xian (Chi) 200? Sintax - + @@ -23178,29 +23093,14 @@ Undumped Pirates: - - Xiao Taichi - Shen Hua Li Xian (Chi, Hacked) - 200? - Sintax - - - - - - - - - - - - - + + 2003 Crash Bandicoot II Advance - The Huge Adventure (Chi) 200? Sintax - + @@ -23210,29 +23110,14 @@ Undumped Pirates: - - 2003 Crash Bandicoot II Advance - The Huge Adventure (Chi, Hacked) - 200? - Sintax - - - - - - - - - - - - - + + Bynasty Warriors Advance 5 (Chi) 200? Sintax - + @@ -23242,29 +23127,14 @@ Undumped Pirates: - - Bynasty Warriors Advance 5 (Chi, Hacked) - 200? - Sintax - - - - - - - - - - - - - + + Chao Ji Ji Qi Ren Da Zhan X (Chi) 200? Sintax - + @@ -23274,29 +23144,14 @@ Undumped Pirates: - - Chao Ji Ji Qi Ren Da Zhan X (Chi, Hacked) - 200? - Sintax - - - - - - - - - - - - - + + Chao Ji Ji Qi Ren Da Zhan X (Chi, Alt) 200? Sintax - + @@ -23306,29 +23161,14 @@ Undumped Pirates: - - Chao Ji Ji Qi Ren Da Zhan X (Chi, Alt, Hacked) - 200? - Sintax - - - - - - - - - - - - - + + Jing Ling Wang III (Chi) 200? Sintax - + @@ -23338,29 +23178,14 @@ Undumped Pirates: - - Jing Ling Wang III (Chi, Hacked) - 200? - Sintax - - - - - - - - - - - - - + + Quan Ba Tian Xia (Chi) 200? Sintax - + @@ -23370,29 +23195,14 @@ Undumped Pirates: - - Quan Ba Tian Xia (Chi, Hacked) - 200? - Sintax - - - - - - - - - - - - - + + Zhi Huan Wang - Shou Bu Qu (Chi) 200? Sintax - + @@ -23402,29 +23212,14 @@ Undumped Pirates: - - Zhi Huan Wang - Shou Bu Qu (Chi, Hacked) - 200? - Sintax - - - - - - - - - - - - - + + Xing Qiu Da Zhan II - Ke Long Ren Zhan Yi (Chi) 200? Sintax - + @@ -23434,29 +23229,14 @@ Undumped Pirates: - - Xing Qiu Da Zhan II - Ke Long Ren Zhan Yi (Chi, Hacked) - 200? - Sintax - - - - - - - - - - - - - + + Ha Li Xiao Zi Di Er Bu - Mi Shi De Mi (Chi) 200? Sintax - + @@ -23466,29 +23246,14 @@ Undumped Pirates: - - Ha Li Xiao Zi Di Er Bu - Mi Shi De Mi (Chi, Hacked) - 200? - Sintax - - - - - - - - - - - - - + + Hai Zhan Qi Bing (Chi) 200? Jump Technology ~ Sintax - + @@ -23498,29 +23263,14 @@ Undumped Pirates: - - Hai Zhan Qi Bing (Chi, Hacked) - 200? - Jump Technology ~ Sintax - - - - - - - - - - - - - + + Zhen San Guo Wu Shuang 2 - Shin Sangokumusou 2 (Chi) 200? Sintax - + @@ -23530,29 +23280,14 @@ Undumped Pirates: - - Zhen San Guo Wu Shuang 2 - Shin Sangokumusou 2 (Chi, Hacked) - 200? - Sintax - - - - - - - - - - - - - + + Zhi Zhu Xia III (Chi) 200? Sintax - + @@ -23562,22 +23297,6 @@ Undumped Pirates: - - Zhi Zhu Xia III (Chi, Hacked) - 200? - Sintax - - - - - - - - - - - - Xin Feng Shen Bang (Chi, Ripped from 12 in 1 multicart) 2001 @@ -23594,12 +23313,14 @@ Undumped Pirates: - + + 2003 Digitmon Sapphire (Chi) 20?? <unknown> + @@ -23608,26 +23329,13 @@ Undumped Pirates: - - 2003 Digitmon Sapphire (Chi, Hacked) - 20?? - <unknown> - - - - - - - - - - Shu Ma Bao Long 3 - Shui Jing Ban (Chi) 20?? <unknown> + @@ -23643,6 +23351,7 @@ Undumped Pirates: + @@ -24380,12 +24089,13 @@ Undumped Pirates: - + + Donkey Kong 5 - The Journey of Over Time and Space (Chi) 200? Sintax - + @@ -24395,21 +24105,6 @@ Undumped Pirates: - - Donkey Kong 5 - The Journey of Over Time and Space (Chi, Hacked) - 200? - Sintax - - - - - - - - - - - Super Mario 3 Special (Chi, Bad? Protected?) 200? @@ -24423,7 +24118,7 @@ Undumped Pirates: - + Digimon 2 (Chi) 20?? Yong Yong @@ -24468,7 +24163,7 @@ Undumped Pirates: - + Digimon 02 4 (Chi) 20?? Yong Yong diff --git a/src/mess/drivers/gb.c b/src/mess/drivers/gb.c index 5c34ebbf8e9..d4e5c0b560d 100644 --- a/src/mess/drivers/gb.c +++ b/src/mess/drivers/gb.c @@ -456,26 +456,6 @@ space. This mapper uses 32KB sized banks. static const UINT16 mgb_cpu_regs[6] = { 0xFFB0, 0x0013, 0x00D8, 0x014D, 0xFFFE, 0x0100 }; /* Game Boy Pocket / Super Game Boy 2 */ static const UINT16 megaduck_cpu_regs[6] = { 0x0000, 0x0000, 0x0000, 0x0000, 0xFFFE, 0x0000 }; /* Megaduck */ -static ADDRESS_MAP_START(gb_map, AS_PROGRAM, 8, gb_state ) - ADDRESS_MAP_UNMAP_HIGH - AM_RANGE(0x0000, 0x00ff) AM_ROMBANK("bank5") /* BIOS or ROM */ - AM_RANGE(0x0100, 0x01ff) AM_ROMBANK("bank10") /* ROM bank */ - AM_RANGE(0x0200, 0x08ff) AM_ROMBANK("bank6") - AM_RANGE(0x0900, 0x3fff) AM_ROMBANK("bank11") - AM_RANGE(0x4000, 0x5fff) AM_ROMBANK("bank1") /* 8KB/16KB switched ROM bank */ - AM_RANGE(0x6000, 0x7fff) AM_ROMBANK("bank4") /* 8KB/16KB switched ROM bank */ - AM_RANGE(0x8000, 0x9fff) AM_READWRITE(gb_vram_r, gb_vram_w ) /* 8k VRAM */ - AM_RANGE(0xa000, 0xbfff) AM_RAMBANK("bank2") /* 8k switched RAM bank (cartridge) */ - AM_RANGE(0xc000, 0xfdff) AM_RAM /* 8k low RAM, echo RAM */ - AM_RANGE(0xfe00, 0xfeff) AM_READWRITE(gb_oam_r, gb_oam_w ) /* OAM RAM */ - AM_RANGE(0xff00, 0xff0f) AM_READWRITE(gb_io_r, gb_io_w ) /* I/O */ - AM_RANGE(0xff10, 0xff26) AM_DEVREADWRITE_LEGACY("custom", gb_sound_r, gb_sound_w ) /* sound registers */ - AM_RANGE(0xff27, 0xff2f) AM_NOP /* unused */ - AM_RANGE(0xff30, 0xff3f) AM_DEVREADWRITE_LEGACY("custom", gb_wave_r, gb_wave_w ) /* Wave ram */ - AM_RANGE(0xff40, 0xff7f) AM_READWRITE(gb_video_r, gb_io2_w) /* Video controller & BIOS flip-flop */ - AM_RANGE(0xff80, 0xfffe) AM_RAM /* High RAM */ - AM_RANGE(0xffff, 0xffff) AM_READWRITE(gb_ie_r, gb_ie_w ) /* Interrupt enable register */ -ADDRESS_MAP_END READ8_MEMBER(gb_state::gb_cart_r) { @@ -647,10 +627,36 @@ static INPUT_PORTS_START( gameboy ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SELECT) PORT_NAME("Select") INPUT_PORTS_END -static MACHINE_CONFIG_START( gb_common, gb_state ) +static SLOT_INTERFACE_START(gb_cart) + SLOT_INTERFACE_INTERNAL("rom", GB_STD_ROM) + SLOT_INTERFACE_INTERNAL("rom_mbc1", GB_ROM_MBC1) + SLOT_INTERFACE_INTERNAL("rom_mbc1col", GB_ROM_MBC1_COL) + SLOT_INTERFACE_INTERNAL("rom_mbc2", GB_ROM_MBC2) + SLOT_INTERFACE_INTERNAL("rom_mbc3", GB_ROM_MBC3) + SLOT_INTERFACE_INTERNAL("rom_huc1", GB_ROM_MBC3) + SLOT_INTERFACE_INTERNAL("rom_huc3", GB_ROM_MBC3) + SLOT_INTERFACE_INTERNAL("rom_mbc5", GB_ROM_MBC5) + SLOT_INTERFACE_INTERNAL("rom_mbc6", GB_ROM_MBC6) + SLOT_INTERFACE_INTERNAL("rom_mbc7", GB_ROM_MBC7) + SLOT_INTERFACE_INTERNAL("rom_tama5", GB_ROM_TAMA5) + SLOT_INTERFACE_INTERNAL("rom_mmm01", GB_ROM_MMM01) + SLOT_INTERFACE_INTERNAL("rom_wisdom", GB_ROM_WISDOM) + SLOT_INTERFACE_INTERNAL("rom_yong", GB_ROM_YONG) + SLOT_INTERFACE_INTERNAL("rom_lasama", GB_ROM_LASAMA) + SLOT_INTERFACE_INTERNAL("rom_atvrac", GB_ROM_ATVRAC) + SLOT_INTERFACE_INTERNAL("rom_camera", GB_STD_ROM) + SLOT_INTERFACE_INTERNAL("rom_sintax", GB_ROM_SINTAX) +SLOT_INTERFACE_END + +static SLOT_INTERFACE_START(megaduck_cart) + SLOT_INTERFACE_INTERNAL("rom", MEGADUCK_ROM) +SLOT_INTERFACE_END + + +static MACHINE_CONFIG_START( gameboy, gb_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", LR35902, 4194304) /* 4.194304 MHz */ - MCFG_CPU_PROGRAM_MAP(gb_map) + MCFG_CPU_PROGRAM_MAP(gameboy_map) MCFG_LR35902_TIMER_CB( WRITE8( gb_state, gb_timer_callback ) ) MCFG_LR35902_HALT_BUG MCFG_CPU_VBLANK_INT_DRIVER("screen", gb_state, gb_scanline_interrupt) /* 1 dummy int each frame */ @@ -678,36 +684,8 @@ static MACHINE_CONFIG_START( gb_common, gb_state ) MCFG_SOUND_ADD("custom", GAMEBOY, 0) MCFG_SOUND_ROUTE(0, "lspeaker", 0.50) MCFG_SOUND_ROUTE(1, "rspeaker", 0.50) -MACHINE_CONFIG_END - -static SLOT_INTERFACE_START(gb_cart) - SLOT_INTERFACE_INTERNAL("rom", GB_STD_ROM) - SLOT_INTERFACE_INTERNAL("rom_mbc1", GB_ROM_MBC1) - SLOT_INTERFACE_INTERNAL("rom_mbc1k", GB_ROM_MBC1K) - SLOT_INTERFACE_INTERNAL("rom_mbc2", GB_ROM_MBC2) - SLOT_INTERFACE_INTERNAL("rom_mbc3", GB_ROM_MBC3) - SLOT_INTERFACE_INTERNAL("rom_huc1", GB_ROM_MBC3) - SLOT_INTERFACE_INTERNAL("rom_huc3", GB_ROM_MBC3) - SLOT_INTERFACE_INTERNAL("rom_mbc5", GB_ROM_MBC5) - SLOT_INTERFACE_INTERNAL("rom_mbc6", GB_ROM_MBC6) - SLOT_INTERFACE_INTERNAL("rom_mbc7", GB_ROM_MBC7) - SLOT_INTERFACE_INTERNAL("rom_tama5", GB_ROM_TAMA5) - SLOT_INTERFACE_INTERNAL("rom_mmm01", GB_ROM_MMM01) - SLOT_INTERFACE_INTERNAL("rom_wisdom", GB_ROM_WISDOM) - SLOT_INTERFACE_INTERNAL("rom_yong", GB_ROM_YONG) - SLOT_INTERFACE_INTERNAL("rom_lasama", GB_ROM_LASAMA) - SLOT_INTERFACE_INTERNAL("rom_atvrac", GB_ROM_ATVRAC) - SLOT_INTERFACE_INTERNAL("rom_camera", GB_STD_ROM) -SLOT_INTERFACE_END - -static SLOT_INTERFACE_START(megaduck_cart) - SLOT_INTERFACE_INTERNAL("rom", MEGADUCK_ROM) -SLOT_INTERFACE_END - -static MACHINE_CONFIG_DERIVED( gameboy, gb_common ) - MCFG_CPU_REPLACE("maincpu", LR35902, 4194304) /* 4.194304 MHz */ - MCFG_CPU_PROGRAM_MAP(gameboy_map) + /* cartslot */ MCFG_GB_CARTRIDGE_ADD("gbslot", gb_cart, NULL, NULL) MCFG_SOFTWARE_LIST_ADD("cart_list","gameboy") diff --git a/src/mess/machine/gb_mbc.c b/src/mess/machine/gb_mbc.c index c643e118699..b7049e5c409 100644 --- a/src/mess/machine/gb_mbc.c +++ b/src/mess/machine/gb_mbc.c @@ -17,13 +17,14 @@ //------------------------------------------------- const device_type GB_ROM_MBC1 = &device_creator; -const device_type GB_ROM_MBC1K = &device_creator; +const device_type GB_ROM_MBC1_COL = &device_creator; const device_type GB_ROM_MBC2 = &device_creator; const device_type GB_ROM_MBC3 = &device_creator; const device_type GB_ROM_MBC5 = &device_creator; const device_type GB_ROM_MBC6 = &device_creator; const device_type GB_ROM_MBC7 = &device_creator; const device_type GB_ROM_MMM01 = &device_creator; +const device_type GB_ROM_SINTAX = &device_creator; gb_rom_mbc_device::gb_rom_mbc_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock) @@ -37,8 +38,8 @@ gb_rom_mbc1_device::gb_rom_mbc1_device(const machine_config &mconfig, const char { } -gb_rom_mbc1k_device::gb_rom_mbc1k_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : gb_rom_mbc_device(mconfig, GB_ROM_MBC1K, "GB MBC1 Korean Carts", tag, owner, clock) +gb_rom_mbc1col_device::gb_rom_mbc1col_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : gb_rom_mbc_device(mconfig, GB_ROM_MBC1_COL, "GB MBC1 Collection Carts", tag, owner, clock) { } @@ -72,6 +73,11 @@ gb_rom_mmm01_device::gb_rom_mmm01_device(const machine_config &mconfig, const ch { } +gb_rom_sintax_device::gb_rom_sintax_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : gb_rom_mbc_device(mconfig, GB_ROM_SINTAX, "GB MBC5 Sintax Carts", tag, owner, clock) +{ +} + void gb_rom_mbc_device::device_start() { @@ -107,7 +113,7 @@ void gb_rom_mbc1_device::device_start() save_item(NAME(m_mode)); } -void gb_rom_mbc1k_device::device_start() +void gb_rom_mbc1col_device::device_start() { has_timer = FALSE; has_rumble = FALSE; @@ -238,6 +244,37 @@ void gb_rom_mmm01_device::device_start() save_item(NAME(m_reg)); } +void gb_rom_sintax_device::device_start() +{ + has_timer = FALSE; + has_rumble = FALSE; + + m_latch_bank = 0; + m_latch_bank2 = 1; + m_ram_bank = 0; + m_ram_enable = 0; + m_mode = 0; + + m_sintax_mode = 0; + m_currentxor = 0; + m_xor2 = 0; + m_xor3 = 0; + m_xor4 = 0; + m_xor5 = 0; + + save_item(NAME(m_latch_bank)); + save_item(NAME(m_latch_bank2)); + save_item(NAME(m_ram_bank)); + save_item(NAME(m_ram_enable)); + save_item(NAME(m_mode)); + save_item(NAME(m_sintax_mode)); + save_item(NAME(m_currentxor)); + save_item(NAME(m_xor2)); + save_item(NAME(m_xor3)); + save_item(NAME(m_xor4)); + save_item(NAME(m_xor5)); +} + /*------------------------------------------------- mapper specific handlers @@ -321,7 +358,7 @@ WRITE8_MEMBER(gb_rom_mbc1_device::write_ram) // MBC1 Korean variant (used by Bomberman Selection) -READ8_MEMBER(gb_rom_mbc1k_device::read_rom) +READ8_MEMBER(gb_rom_mbc1col_device::read_rom) { if (offset < 0x4000) return m_rom[rom_bank_map[m_latch_bank] * 0x4000 + (offset & 0x3fff)]; @@ -329,7 +366,7 @@ READ8_MEMBER(gb_rom_mbc1k_device::read_rom) return m_rom[rom_bank_map[m_latch_bank2] * 0x4000 + (offset & 0x3fff)]; } -WRITE8_MEMBER(gb_rom_mbc1k_device::write_bank) +WRITE8_MEMBER(gb_rom_mbc1col_device::write_bank) { if (offset < 0x2000) m_ram_enable = ((data & 0x0f) == 0x0a) ? 1 : 0; @@ -355,7 +392,7 @@ WRITE8_MEMBER(gb_rom_mbc1k_device::write_bank) } // RAM access is the same as usual MBC1 -READ8_MEMBER(gb_rom_mbc1k_device::read_ram) +READ8_MEMBER(gb_rom_mbc1col_device::read_ram) { if (m_ram && m_ram_enable) { @@ -366,7 +403,7 @@ READ8_MEMBER(gb_rom_mbc1k_device::read_ram) return 0xff; } -WRITE8_MEMBER(gb_rom_mbc1k_device::write_ram) +WRITE8_MEMBER(gb_rom_mbc1col_device::write_ram) { if (m_ram && m_ram_enable) { @@ -678,7 +715,7 @@ WRITE8_MEMBER(gb_rom_mmm01_device::write_bank) logerror("0x%04X: write 0x%02X to 0x%04X\n", space.device().safe_pc(), data, offset); else { - logerror( "0x%04X: write 0x%02X to 0x%04X\n", space.device().safe_pc(), data, offset); + logerror("0x%04X: write 0x%02X to 0x%04X\n", space.device().safe_pc(), data, offset); /* Not sure if this is correct, Taito Variety Pack sets these values */ /* Momotarou Collection 2 writes 01 and 21 here */ switch (data) @@ -689,3 +726,125 @@ WRITE8_MEMBER(gb_rom_mmm01_device::write_bank) } } } + +// MBC5 variant used by Sintax games + +void gb_rom_sintax_device::set_xor_for_bank(UINT8 bank) +{ + switch (bank & 0x0f) + { + case 0x00: case 0x04: case 0x08: case 0x0c: + m_currentxor = m_xor2; + break; + case 0x01: case 0x05: case 0x09: case 0x0d: + m_currentxor = m_xor3; + break; + case 0x02: case 0x06: case 0x0a: case 0x0e: + m_currentxor = m_xor4; + break; + case 0x03: case 0x07: case 0x0b: case 0x0f: + m_currentxor = m_xor5; + break; + } +} + +READ8_MEMBER(gb_rom_sintax_device::read_rom) +{ + if (offset < 0x4000) + return m_rom[rom_bank_map[m_latch_bank] * 0x4000 + (offset & 0x3fff)]; + else + return m_rom[rom_bank_map[m_latch_bank2] * 0x4000 + (offset & 0x3fff)] ^ m_currentxor; +} + +WRITE8_MEMBER(gb_rom_sintax_device::write_bank) +{ + if (offset < 0x2000) + m_ram_enable = ((data & 0x0f) == 0x0a) ? 1 : 0; + else if (offset < 0x3000) + { + set_xor_for_bank(data); + + switch (m_sintax_mode & 0x0f) + { + case 0x0d: + data = BITSWAP8(data, 1,0,7,6,5,4,3,2); + break; + case 0x09: + //data = BITSWAP8(data, 3,2,5,4,0,1,6,7); // Monkey..no + data = BITSWAP8(data, 4,5,2,3,0,1,6,7); + break; + case 0x00: // 0x10=lion 0x00 hmmmmm // 1 and 0 unconfirmed + data = BITSWAP8(data, 7,0,5,6,3,4,1,2); + break; + case 0x01: + data = BITSWAP8(data, 0,1,6,7,4,5,2,3); + break; + case 0x05: + data = BITSWAP8(data, 7,6,1,0,3,2,5,4); // Not 100% on this one + break; + case 0x07: + data = BITSWAP8(data, 2,0,3,1,5,4,7,6); // 5 and 7 unconfirmed + break; + case 0x0b: + data = BITSWAP8(data, 2,3,0,1,6,7,4,5); // 5 and 6 unconfirmed + break; + } + m_latch_bank2 = (m_latch_bank2 & 0x100) | data; + } + else if (offset < 0x4000) + { + m_latch_bank2 = (m_latch_bank2 & 0xff) | ((data & 0x01) << 8); + } + else if (offset < 0x5000) + { + data &= 0x0f; + if (has_rumble) + data &= 0x7; + m_ram_bank = data; + } + else if (offset < 0x6000) + { + if (!m_sintax_mode) + { + m_sintax_mode = data; + write_bank(space, 0x2000, 1); //force a fake bank switch + } + printf("sintax mode %x\n", m_sintax_mode & 0xf); + } + else if (offset >= 0x7000) + { + switch ((offset & 0x00f0) >> 4) + { + case 2: + m_xor2 = data; + break; + case 3: + m_xor3 = data; + break; + case 4: + m_xor4 = data; + break; + case 5: + m_xor5 = data; + break; + } + + if (m_currentxor == 0) + set_xor_for_bank(4); + } + +} + +READ8_MEMBER(gb_rom_sintax_device::read_ram) +{ + if (m_ram && m_ram_enable) + return m_ram[ram_bank_map[m_ram_bank] * 0x2000 + (offset & 0x1fff)]; + else + return 0xff; +} + +WRITE8_MEMBER(gb_rom_sintax_device::write_ram) +{ + if (m_ram && m_ram_enable) + m_ram[ram_bank_map[m_ram_bank] * 0x2000 + (offset & 0x1fff)] = data; +} diff --git a/src/mess/machine/gb_mbc.h b/src/mess/machine/gb_mbc.h index c29c558495f..d66e7a5b42a 100644 --- a/src/mess/machine/gb_mbc.h +++ b/src/mess/machine/gb_mbc.h @@ -44,17 +44,17 @@ public: virtual DECLARE_WRITE8_MEMBER(write_ram); }; -// ======================> gb_rom_mbc1k_device +// ======================> gb_rom_mbc1col_device -class gb_rom_mbc1k_device : public gb_rom_mbc_device +class gb_rom_mbc1col_device : public gb_rom_mbc_device { public: // construction/destruction - gb_rom_mbc1k_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + gb_rom_mbc1col_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); // device-level overrides virtual void device_start(); - virtual void device_config_complete() { m_shortname = "gb_rom_mbc1k"; } + virtual void device_config_complete() { m_shortname = "gb_rom_mbc1col"; } virtual DECLARE_READ8_MEMBER(read_rom); virtual DECLARE_WRITE8_MEMBER(write_bank); @@ -172,10 +172,33 @@ public: UINT8 m_bank_mask, m_bank, m_reg; }; +// ======================> gb_rom_sintax_device +class gb_rom_sintax_device : public gb_rom_mbc_device +{ +public: + // construction/destruction + gb_rom_sintax_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // device-level overrides + virtual void device_start(); + virtual void device_config_complete() { m_shortname = "gb_rom_sintax"; } + void set_xor_for_bank(UINT8 bank); + + // reading and writing + virtual DECLARE_READ8_MEMBER(read_rom); + virtual DECLARE_WRITE8_MEMBER(write_bank); + virtual DECLARE_READ8_MEMBER(read_ram); + virtual DECLARE_WRITE8_MEMBER(write_ram); + UINT8 m_bank_mask, m_bank, m_reg; + + UINT8 m_currentxor, m_xor2, m_xor3, m_xor4, m_xor5, m_sintax_mode; +}; + + // device type definition extern const device_type GB_ROM_MBC1; -extern const device_type GB_ROM_MBC1K; +extern const device_type GB_ROM_MBC1_COL; extern const device_type GB_ROM_MBC2; extern const device_type GB_ROM_MBC3; extern const device_type GB_ROM_MBC4; @@ -183,5 +206,6 @@ extern const device_type GB_ROM_MBC5; extern const device_type GB_ROM_MBC6; extern const device_type GB_ROM_MBC7; extern const device_type GB_ROM_MMM01; +extern const device_type GB_ROM_SINTAX; #endif diff --git a/src/mess/machine/gb_slot.c b/src/mess/machine/gb_slot.c index 67a6a5afde4..fa85465f691 100644 --- a/src/mess/machine/gb_slot.c +++ b/src/mess/machine/gb_slot.c @@ -200,7 +200,7 @@ struct gb_slot static const gb_slot slot_list[] = { { GB_MBC_MBC1, "rom_mbc1" }, - { GB_MBC_MBC1_KOR, "rom_mbc1k" }, + { GB_MBC_MBC1_COL, "rom_mbc1col" }, { GB_MBC_MBC2, "rom_mbc2" }, { GB_MBC_MBC3, "rom_mbc3" }, { GB_MBC_MBC5, "rom_mbc5" }, @@ -214,6 +214,7 @@ static const gb_slot slot_list[] = { GB_MBC_YONGYONG, "rom_yong" }, { GB_MBC_LASAMA, "rom_lasama" }, { GB_MBC_ATVRACIN, "rom_atvrac" }, + { GB_MBC_SINTAX, "rom_sintax" }, { GB_MBC_CAMERA, "rom_camera" } }; @@ -520,11 +521,33 @@ int base_gb_cart_slot_device::get_cart_type(UINT8 *ROM, UINT32 len) } } - /* Check if we're dealing with a Korean variant of the MBC1 mapper */ + // Check for some unlicensed games + if (type == GB_MBC_MBC5) + { + int count = 0; + for (int i = 0x0184; i < 0x0184 + 0x30; i++) + { + count += ROM[i]; + } + if (count == 4876) + { +// printf("Niutoude!\n"); +// type = GB_MBC_NIUTOUDE; + } + if (count == 4138 || count == 4125) + { + // Zhi Huan Wang uses 4138 + // most sintax use 4125 + printf("Sintax %d!\n", count); + type = GB_MBC_SINTAX; + } + } + + /* Check if we're dealing with the multigame variant of the MBC1 mapper */ if (type == GB_MBC_MBC1) { if (ROM[0x13f] == 0x42 && ROM[0x140] == 0x32 && ROM[0x141] == 0x43 && ROM[0x142] == 0x4B) - type = GB_MBC_MBC1_KOR; + type = GB_MBC_MBC1_COL; } return type; diff --git a/src/mess/machine/gb_slot.h b/src/mess/machine/gb_slot.h index 154e8c03d5f..612c2f5453a 100644 --- a/src/mess/machine/gb_slot.h +++ b/src/mess/machine/gb_slot.h @@ -22,11 +22,12 @@ enum GB_MBC_MBC6, /* ?? ROM, 32KB SRAM */ GB_MBC_MBC7, /* ?? ROM, ?? RAM */ GB_MBC_WISDOM, /* ?? ROM, ?? RAM - Wisdom tree controller */ - GB_MBC_MBC1_KOR, /* 1MB ROM, ?? RAM - Korean MBC1 variant */ + GB_MBC_MBC1_COL, /* 1MB ROM, ?? RAM - MBC1 variant for multigame carts */ GB_MBC_YONGYONG, /* ?? ROM, ?? RAM - Appears in Sonic 3D Blast 5 pirate */ GB_MBC_LASAMA, /* ?? ROM, ?? RAM - Appears in La Sa Ma */ GB_MBC_ATVRACIN, GB_MBC_CAMERA, + GB_MBC_SINTAX, GB_MBC_MEGADUCK, /* MEGADUCK style banking */ GB_MBC_UNKNOWN /* Unknown mapper */ };