Maketrax : simulate protection [iq_132, Robbbert]

This commit is contained in:
Robbbert 2018-01-10 03:13:03 +11:00
parent f80b76c391
commit b66737f7be
2 changed files with 82 additions and 49 deletions

View File

@ -395,7 +395,12 @@ MACHINE_RESET_MEMBER(pacman_state,superabc)
superabc_bank_w(m_maincpu->space(AS_PROGRAM), 0, 0); superabc_bank_w(m_maincpu->space(AS_PROGRAM), 0, 0);
} }
MACHINE_RESET_MEMBER(pacman_state,maketrax)
{
m_maketrax_counter = 0;
m_maketrax_offset = 0;
m_maketrax_disable_protection = 0;
}
/************************************* /*************************************
* *
@ -575,13 +580,44 @@ READ8_MEMBER(pacman_state::alibaba_mystery_2_r)
* *
*************************************/ *************************************/
WRITE8_MEMBER(pacman_state::maketrax_protection_w)
{
if (data == 0) // disable protection / reset?
{
m_maketrax_counter = 0;
m_maketrax_offset = 0;
m_maketrax_disable_protection = 1;
return;
}
if (data == 1)
{
m_maketrax_disable_protection = 0;
m_maketrax_counter++;
if (m_maketrax_counter == 0x3c)
{
m_maketrax_counter = 0;
m_maketrax_offset++;
if (m_maketrax_offset == 0x1e)
m_maketrax_offset = 0;
}
}
}
READ8_MEMBER(pacman_state::maketrax_special_port2_r) READ8_MEMBER(pacman_state::maketrax_special_port2_r)
{ {
int data = ioport("DSW1")->read(); const uint8_t protdata[0x1e] = { // table at $ebd (odd entries)
int pc = m_maincpu->pcbase(); 0x00, 0xc0, 0x00, 0x40, 0xc0, 0x40, 0x00, 0xc0, 0x00, 0x40, 0x00, 0xc0, 0x00, 0x40, 0xc0, 0x40,
0x00, 0xc0, 0x00, 0x40, 0x00, 0xc0, 0x00, 0x40, 0xc0, 0x40, 0x00, 0xc0, 0x00, 0x40
if ((pc == 0x1973) || (pc == 0x2389)) return data | 0x40; };
if (m_maketrax_disable_protection == 0)
return protdata[m_maketrax_offset];
uint8_t data = ioport("DSW1")->read() & 0x3f;
switch (offset) switch (offset)
{ {
case 0x01: case 0x01:
@ -598,11 +634,13 @@ READ8_MEMBER(pacman_state::maketrax_special_port2_r)
READ8_MEMBER(pacman_state::maketrax_special_port3_r) READ8_MEMBER(pacman_state::maketrax_special_port3_r)
{ {
int pc = m_maincpu->pcbase(); const uint8_t protdata[0x1e] = { // table at $ebd (even entries)
0x1f, 0x3f, 0x2f, 0x2f, 0x0f, 0x0f, 0x0f, 0x3f, 0x0f, 0x0f, 0x1c, 0x3c, 0x2c, 0x2c, 0x0c, 0x0c,
if (pc == 0x040e) return 0x20; 0x0c, 0x3c, 0x0c, 0x0c, 0x11, 0x31, 0x21, 0x21, 0x01, 0x01, 0x01, 0x31, 0x01, 0x01
};
if ((pc == 0x115e) || (pc == 0x3ae2)) return 0x00;
if (m_maketrax_disable_protection == 0)
return protdata[m_maketrax_offset];
switch (offset) switch (offset)
{ {
@ -3512,7 +3550,11 @@ static MACHINE_CONFIG_START( pacman )
MACHINE_CONFIG_END MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( maketrax, pacman ) static MACHINE_CONFIG_DERIVED( maketrax, pacman )
MCFG_CPU_MODIFY("maincpu") MCFG_MACHINE_RESET_OVERRIDE(pacman_state,maketrax)
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( korosuke, pacman )
MCFG_CPU_MODIFY("maincpu")
MCFG_CPU_DECRYPTED_OPCODES_MAP(patched_opcodes_map) MCFG_CPU_DECRYPTED_OPCODES_MAP(patched_opcodes_map)
MCFG_DEVICE_MODIFY("mainlatch") // 8K on original boards MCFG_DEVICE_MODIFY("mainlatch") // 8K on original boards
@ -6813,33 +6855,12 @@ ROM_END
* *
*************************************/ *************************************/
void pacman_state::maketrax_rom_decode()
{
uint8_t *rom = memregion("maincpu")->base();
/* patch protection using a copy of the opcodes so ROM checksum */
/* tests will not fail */
memcpy(m_patched_opcodes,rom,0x4000);
m_patched_opcodes[0x0415] = 0xc9;
m_patched_opcodes[0x1978] = 0x18;
m_patched_opcodes[0x238e] = 0xc9;
m_patched_opcodes[0x3ae5] = 0xe6;
m_patched_opcodes[0x3ae7] = 0x00;
m_patched_opcodes[0x3ae8] = 0xc9;
m_patched_opcodes[0x3aed] = 0x86;
m_patched_opcodes[0x3aee] = 0xc0;
m_patched_opcodes[0x3aef] = 0xb0;
}
DRIVER_INIT_MEMBER(pacman_state,maketrax) DRIVER_INIT_MEMBER(pacman_state,maketrax)
{ {
/* set up protection handlers */ /* set up protection handlers */
m_maincpu->space(AS_PROGRAM).install_write_handler(0x5004, 0x5004, write8_delegate(FUNC(pacman_state::maketrax_protection_w),this));
m_maincpu->space(AS_PROGRAM).install_read_handler(0x5080, 0x50bf, read8_delegate(FUNC(pacman_state::maketrax_special_port2_r),this)); m_maincpu->space(AS_PROGRAM).install_read_handler(0x5080, 0x50bf, read8_delegate(FUNC(pacman_state::maketrax_special_port2_r),this));
m_maincpu->space(AS_PROGRAM).install_read_handler(0x50c0, 0x50ff, read8_delegate(FUNC(pacman_state::maketrax_special_port3_r),this)); m_maincpu->space(AS_PROGRAM).install_read_handler(0x50c0, 0x50ff, read8_delegate(FUNC(pacman_state::maketrax_special_port3_r),this));
maketrax_rom_decode();
} }
void pacman_state::korosuke_rom_decode() void pacman_state::korosuke_rom_decode()
@ -7323,7 +7344,7 @@ GAME( 1981, crush4, crush, pacman, maketrax, pacman_state, eyes, ROT
GAME( 1981, crush5, crush, crush4, crush4, pacman_state, 0, ROT90, "Alpha Denshi Co. / Kural TWT", "Crush Roller (set 5)", MACHINE_SUPPORTS_SAVE ) GAME( 1981, crush5, crush, crush4, crush4, pacman_state, 0, ROT90, "Alpha Denshi Co. / Kural TWT", "Crush Roller (set 5)", MACHINE_SUPPORTS_SAVE )
GAME( 1981, maketrax, crush, maketrax, maketrax, pacman_state, maketrax, ROT270, "Alpha Denshi Co. / Kural (Williams license)", "Make Trax (US set 1)", MACHINE_SUPPORTS_SAVE ) GAME( 1981, maketrax, crush, maketrax, maketrax, pacman_state, maketrax, ROT270, "Alpha Denshi Co. / Kural (Williams license)", "Make Trax (US set 1)", MACHINE_SUPPORTS_SAVE )
GAME( 1981, maketrxb, crush, maketrax, maketrax, pacman_state, maketrax, ROT270, "Alpha Denshi Co. / Kural (Williams license)", "Make Trax (US set 2)", MACHINE_SUPPORTS_SAVE ) GAME( 1981, maketrxb, crush, maketrax, maketrax, pacman_state, maketrax, ROT270, "Alpha Denshi Co. / Kural (Williams license)", "Make Trax (US set 2)", MACHINE_SUPPORTS_SAVE )
GAME( 1981, korosuke, crush, maketrax, korosuke, pacman_state, korosuke, ROT90, "Alpha Denshi Co. / Kural Electric, Ltd.", "Korosuke Roller (Japan)", MACHINE_SUPPORTS_SAVE ) // ADK considers it a sequel? GAME( 1981, korosuke, crush, korosuke, korosuke, pacman_state, korosuke, ROT90, "Alpha Denshi Co. / Kural Electric, Ltd.", "Korosuke Roller (Japan)", MACHINE_SUPPORTS_SAVE ) // ADK considers it a sequel?
GAME( 1981, crushrlf, crush, pacman, maketrax, pacman_state, 0, ROT90, "bootleg", "Crush Roller (Famare SA PCB)", MACHINE_SUPPORTS_SAVE ) GAME( 1981, crushrlf, crush, pacman, maketrax, pacman_state, 0, ROT90, "bootleg", "Crush Roller (Famare SA PCB)", MACHINE_SUPPORTS_SAVE )
GAME( 1981, crushbl, crush, pacman, maketrax, pacman_state, 0, ROT90, "bootleg", "Crush Roller (bootleg set 1)", MACHINE_SUPPORTS_SAVE ) GAME( 1981, crushbl, crush, pacman, maketrax, pacman_state, 0, ROT90, "bootleg", "Crush Roller (bootleg set 1)", MACHINE_SUPPORTS_SAVE )
GAME( 1981, crushbl2, crush, maketrax, mbrush, pacman_state, maketrax, ROT90, "bootleg", "Crush Roller (bootleg set 2)", MACHINE_SUPPORTS_SAVE ) GAME( 1981, crushbl2, crush, maketrax, mbrush, pacman_state, maketrax, ROT90, "bootleg", "Crush Roller (bootleg set 2)", MACHINE_SUPPORTS_SAVE )

View File

@ -13,23 +13,25 @@ class pacman_state : public driver_device
{ {
public: public:
pacman_state(const machine_config &mconfig, device_type type, const char *tag) pacman_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag), : driver_device(mconfig, type, tag)
m_maincpu(*this, "maincpu"), , m_maincpu(*this, "maincpu")
m_namco_sound(*this, "namco"), , m_namco_sound(*this, "namco")
m_watchdog(*this, "watchdog"), , m_watchdog(*this, "watchdog")
m_spriteram(*this, "spriteram"), , m_spriteram(*this, "spriteram")
m_spriteram2(*this, "spriteram2"), , m_spriteram2(*this, "spriteram2")
m_s2650_spriteram(*this, "s2650_spriteram"), , m_s2650_spriteram(*this, "s2650_spriteram")
m_videoram(*this, "videoram"), , m_videoram(*this, "videoram")
m_colorram(*this, "colorram"), , m_colorram(*this, "colorram")
m_s2650games_tileram(*this, "s2650_tileram"), , m_s2650games_tileram(*this, "s2650_tileram")
m_rocktrv2_prot_data(*this, "rocktrv2_prot"), , m_rocktrv2_prot_data(*this, "rocktrv2_prot")
m_gfxdecode(*this, "gfxdecode"), , m_gfxdecode(*this, "gfxdecode")
m_palette(*this, "palette"), , m_palette(*this, "palette")
m_patched_opcodes(*this, "patched_opcodes") , m_patched_opcodes(*this, "patched_opcodes")
{ } { }
required_device<cpu_device> m_maincpu; required_device<cpu_device> m_maincpu;
private:
optional_device<namco_device> m_namco_sound; optional_device<namco_device> m_namco_sound;
required_device<watchdog_timer_device> m_watchdog; required_device<watchdog_timer_device> m_watchdog;
optional_shared_ptr<uint8_t> m_spriteram; optional_shared_ptr<uint8_t> m_spriteram;
@ -57,6 +59,11 @@ public:
uint8_t m_bgpriority; uint8_t m_bgpriority;
int m_xoffsethack; int m_xoffsethack;
uint8_t m_inv_spr; uint8_t m_inv_spr;
uint8_t m_maketrax_counter;
uint8_t m_maketrax_offset;
int m_maketrax_disable_protection;
public:
uint8_t m_irq_mask; uint8_t m_irq_mask;
DECLARE_WRITE8_MEMBER(pacman_interrupt_vector_w); DECLARE_WRITE8_MEMBER(pacman_interrupt_vector_w);
@ -69,6 +76,7 @@ public:
DECLARE_WRITE8_MEMBER(alibaba_sound_w); DECLARE_WRITE8_MEMBER(alibaba_sound_w);
DECLARE_READ8_MEMBER(alibaba_mystery_1_r); DECLARE_READ8_MEMBER(alibaba_mystery_1_r);
DECLARE_READ8_MEMBER(alibaba_mystery_2_r); DECLARE_READ8_MEMBER(alibaba_mystery_2_r);
DECLARE_WRITE8_MEMBER(maketrax_protection_w);
DECLARE_READ8_MEMBER(maketrax_special_port2_r); DECLARE_READ8_MEMBER(maketrax_special_port2_r);
DECLARE_READ8_MEMBER(maketrax_special_port3_r); DECLARE_READ8_MEMBER(maketrax_special_port3_r);
DECLARE_READ8_MEMBER(korosuke_special_port2_r); DECLARE_READ8_MEMBER(korosuke_special_port2_r);
@ -145,6 +153,7 @@ public:
DECLARE_VIDEO_START(s2650games); DECLARE_VIDEO_START(s2650games);
DECLARE_MACHINE_RESET(mschamp); DECLARE_MACHINE_RESET(mschamp);
DECLARE_MACHINE_RESET(superabc); DECLARE_MACHINE_RESET(superabc);
DECLARE_MACHINE_RESET(maketrax);
DECLARE_VIDEO_START(pengo); DECLARE_VIDEO_START(pengo);
DECLARE_VIDEO_START(jrpacman); DECLARE_VIDEO_START(jrpacman);
uint32_t screen_update_pacman(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); uint32_t screen_update_pacman(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
@ -152,13 +161,15 @@ public:
INTERRUPT_GEN_MEMBER(vblank_irq); INTERRUPT_GEN_MEMBER(vblank_irq);
INTERRUPT_GEN_MEMBER(vblank_nmi); INTERRUPT_GEN_MEMBER(vblank_nmi);
INTERRUPT_GEN_MEMBER(s2650_interrupt); INTERRUPT_GEN_MEMBER(s2650_interrupt);
private:
void init_save_state(); void init_save_state();
void jrpacman_mark_tile_dirty( int offset ); void jrpacman_mark_tile_dirty( int offset );
void maketrax_rom_decode();
void korosuke_rom_decode(); void korosuke_rom_decode();
void eyes_decode(uint8_t *data); void eyes_decode(uint8_t *data);
void mspacman_install_patches(uint8_t *ROM); void mspacman_install_patches(uint8_t *ROM);
public:
// epos.c // epos.c
DECLARE_READ8_MEMBER(epos_decryption_w); DECLARE_READ8_MEMBER(epos_decryption_w);
DECLARE_MACHINE_START(theglobp); DECLARE_MACHINE_START(theglobp);
@ -168,6 +179,7 @@ public:
DECLARE_MACHINE_START(acitya); DECLARE_MACHINE_START(acitya);
DECLARE_MACHINE_RESET(acitya); DECLARE_MACHINE_RESET(acitya);
private:
// pacplus.c // pacplus.c
uint8_t pacplus_decrypt(int addr, uint8_t e); uint8_t pacplus_decrypt(int addr, uint8_t e);
void pacplus_decode(); void pacplus_decode();