(MESS) msx.c: Added support for mapper used by Holy Quran. [hap, Wilbert Pol]

This commit is contained in:
Wilbert Pol 2014-06-04 17:57:35 +00:00
parent 961ce4b810
commit db5294cec3
6 changed files with 162 additions and 5 deletions

2
.gitattributes vendored
View File

@ -1001,6 +1001,8 @@ src/emu/bus/msx_cart/fmpac.c svneol=native#text/plain
src/emu/bus/msx_cart/fmpac.h svneol=native#text/plain
src/emu/bus/msx_cart/hfox.c svneol=native#text/plain
src/emu/bus/msx_cart/hfox.h svneol=native#text/plain
src/emu/bus/msx_cart/holy_quran.c svneol=native#text/plain
src/emu/bus/msx_cart/holy_quran.h svneol=native#text/plain
src/emu/bus/msx_cart/konami.c svneol=native#text/plain
src/emu/bus/msx_cart/konami.h svneol=native#text/plain
src/emu/bus/msx_cart/korean.c svneol=native#text/plain

View File

@ -15242,18 +15242,17 @@ legacy FM implementations cannot find it.
</part>
</software>
<!-- FIXME: proper HOLYQURAN mapper needs to be implemented! -->
<software name="quran" supported="no">
<software name="quran">
<description>The Holy Quran</description>
<year>1987</year>
<publisher>Al Alamiah</publisher>
<info name="serial" value="R052" />
<info name="usage" value="Requires an Arabic MSX" />
<part name="cart" interface="msx_cart">
<feature name="slot" value="ascii16" />
<feature name="mapper" value="M60002-0125SP-16" /> <!-- WRONG MAPPER (but in this way no crash of the emulator) -->
<feature name="slot" value="holy_quran" />
<dataarea name="rom" size="1048576">
<rom name="holyquran.rom" size="1048576" crc="83f28ad3" sha1="0dbc7defd96b71c1fe2d63cbc725f5e58aea2db0" offset="0x0000" />
<!-- there are 2 ROMs on the cartridge -->
<rom name="holyquran.rom" size="1048576" crc="3b003e5c" sha1="7d439080b43d94385fd4c426d4f6fee884bc2926" status="baddump" offset="0x0000" />
</dataarea>
</part>
</software>

View File

@ -412,6 +412,7 @@ BUSOBJS += $(BUSOBJ)/msx_cart/cartridge.o
BUSOBJS += $(BUSOBJ)/msx_cart/crossblaim.o
BUSOBJS += $(BUSOBJ)/msx_cart/fmpac.o
BUSOBJS += $(BUSOBJ)/msx_cart/hfox.o
BUSOBJS += $(BUSOBJ)/msx_cart/holy_quran.o
BUSOBJS += $(BUSOBJ)/msx_cart/konami.o
BUSOBJS += $(BUSOBJ)/msx_cart/korean.o
BUSOBJS += $(BUSOBJ)/msx_cart/majutsushi.o

View File

@ -5,6 +5,7 @@
#include "crossblaim.h"
#include "fmpac.h"
#include "hfox.h"
#include "holy_quran.h"
#include "konami.h"
#include "korean.h"
#include "majutsushi.h"
@ -45,6 +46,7 @@ SLOT_INTERFACE_START(msx_cart)
SLOT_INTERFACE_INTERNAL("super_swangi", MSX_CART_SUPER_SWANGI)
SLOT_INTERFACE_INTERNAL("hfox", MSX_CART_HFOX)
SLOT_INTERFACE_INTERNAL("keyboard_master", MSX_CART_KEYBOARD_MASTER)
SLOT_INTERFACE_INTERNAL("holy_quran", MSX_CART_HOLY_QURAN)
SLOT_INTERFACE_END

View File

@ -0,0 +1,118 @@
#include "emu.h"
#include "holy_quran.h"
const device_type MSX_CART_HOLY_QURAN = &device_creator<msx_cart_holy_quran>;
msx_cart_holy_quran::msx_cart_holy_quran(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, MSX_CART_HOLY_QURAN, "MSX Cartridge - Holy Quran", tag, owner, clock, "msx_cart_holy_quran", __FILE__)
, msx_cart_interface(mconfig, *this)
, m_decrypt(false)
{
for (int i = 0; i < 4; i++)
{
m_selected_bank[i] = 0;
m_bank_base[i] = NULL;
}
/* protection uses a simple rotation on databus, some lines inverted:
D0 D4 D4 D5
D1 ~ D3 D5 ~ D2
D2 ~ D6 D6 D7
D3 ~ D0 D7 D1 */
for (int i=0; i < 0x100; i++)
{
m_lookup_prot[i] = (((i << 4) & 0x50) | ((i >> 3) & 5) | ((i << 1) & 0xa0) | ((i << 2) & 8) | ((i >> 6) & 2)) ^ 0x4d;
}
}
void msx_cart_holy_quran::device_start()
{
save_item(NAME(m_selected_bank));
save_item(NAME(m_decrypt));
machine().save().register_postload(save_prepost_delegate(FUNC(msx_cart_holy_quran::restore_banks), this));
}
void msx_cart_holy_quran::restore_banks()
{
m_bank_base[0] = get_rom_base() + (m_selected_bank[0] & 0x7f) * 0x2000;
m_bank_base[1] = get_rom_base() + (m_selected_bank[1] & 0x7f) * 0x2000;
m_bank_base[2] = get_rom_base() + (m_selected_bank[2] & 0x7f) * 0x2000;
m_bank_base[3] = get_rom_base() + (m_selected_bank[3] & 0x7f) * 0x2000;
}
void msx_cart_holy_quran::device_reset()
{
for (int i = 0; i < 4; i++)
{
m_selected_bank[i] = 0;
}
}
void msx_cart_holy_quran::initialize_cartridge()
{
if (get_rom_size() != 0x100000)
{
fatalerror("holy_quran: Invalid ROM size\n");
}
restore_banks();
}
READ8_MEMBER(msx_cart_holy_quran::read_cart)
{
if (offset >= 0x4000 && offset < 0xc000)
{
UINT8 data = m_bank_base[(offset - 0x4000) >> 13][offset & 0x1fff];
if (m_decrypt)
{
return m_lookup_prot[data];
}
// The decryption should actually start working after the first M1 cycle executing something
// from the cartridge.
if (offset == ((m_rom[3] << 8) | m_rom[2]) && !space.debugger_access())
{
m_decrypt = true;
}
return data;
}
return 0xff;
}
WRITE8_MEMBER(msx_cart_holy_quran::write_cart)
{
switch (offset)
{
case 0x5000:
m_selected_bank[0] = data;
restore_banks();
break;
case 0x5400:
m_selected_bank[1] = data;
restore_banks();
break;
case 0x5800:
m_selected_bank[2] = data;
restore_banks();
break;
case 0x5c00:
m_selected_bank[3] = data;
restore_banks();
break;
default:
logerror("msx_cart_holy_quran: unhandled write %02x to %04x\n", data, offset);
break;
}
}

View File

@ -0,0 +1,35 @@
#ifndef __MSX_CART_HOLY_QURAN_H
#define __MSX_CART_HOLY_QURAN_H
#include "bus/msx_cart/cartridge.h"
extern const device_type MSX_CART_HOLY_QURAN;
class msx_cart_holy_quran : public device_t
, public msx_cart_interface
{
public:
msx_cart_holy_quran(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
// device-level overrides
virtual void device_start();
virtual void device_reset();
virtual void initialize_cartridge();
virtual DECLARE_READ8_MEMBER(read_cart);
virtual DECLARE_WRITE8_MEMBER(write_cart);
void restore_banks();
private:
UINT8 m_lookup_prot[256];
UINT8 m_selected_bank[4];
UINT8 *m_bank_base[4];
bool m_decrypt;
};
#endif