chaknpop: replace MCU simulation with dump [Team Japump!!!,Chack'n,Hau]

This commit is contained in:
Vas Crabb 2017-06-21 09:41:24 +10:00
parent a47ef3ce71
commit 8a3b1a26fb
3 changed files with 26 additions and 171 deletions

View File

@ -4,8 +4,8 @@
Chack'n Pop driver by BUT
Note: The 68705 MCU isn't dumped, because it's protected, however we simulate
it using data extracted with a trojan. See machine/chaknpop.c
Modified by Hau, Chack'n
Chack'n Pop
Taito 1983
@ -110,13 +110,10 @@ Notes:
*/
#include "emu.h"
#include "includes/chaknpop.h"
#include "cpu/z80/z80.h"
#include "cpu/m6805/m6805.h"
#include "sound/ay8910.h"
#include "screen.h"
#include "speaker.h"
#include "includes/chaknpop.h"
/***************************************************************************
@ -148,10 +145,10 @@ WRITE8_MEMBER(chaknpop_state::coinlock_w)
static ADDRESS_MAP_START( chaknpop_map, AS_PROGRAM, 8, chaknpop_state )
AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0x87ff) AM_RAM AM_SHARE("mcu_ram")
AM_RANGE(0x8800, 0x8800) AM_READWRITE(mcu_port_a_r, mcu_port_a_w)
AM_RANGE(0x8801, 0x8801) AM_READWRITE(mcu_port_b_r, mcu_port_b_w)
AM_RANGE(0x8802, 0x8802) AM_READWRITE(mcu_port_c_r, mcu_port_c_w)
AM_RANGE(0x8000, 0x87ff) AM_RAM
AM_RANGE(0x8800, 0x8800) AM_DEVREADWRITE("bmcu", taito68705_mcu_device, data_r, data_w)
AM_RANGE(0x8801, 0x8801) AM_READ(mcu_status_r)
AM_RANGE(0x8802, 0x8802) AM_NOP // watchdog?
AM_RANGE(0x8804, 0x8805) AM_DEVREADWRITE("ay1", ay8910_device, data_r, address_data_w)
AM_RANGE(0x8806, 0x8807) AM_DEVREADWRITE("ay2", ay8910_device, data_r, address_data_w)
AM_RANGE(0x8808, 0x8808) AM_READ_PORT("DSWC")
@ -337,10 +334,6 @@ void chaknpop_state::machine_start()
save_item(NAME(m_gfxmode));
save_item(NAME(m_flip_x));
save_item(NAME(m_flip_y));
save_item(NAME(m_mcu_seed));
save_item(NAME(m_mcu_result));
save_item(NAME(m_mcu_select));
}
void chaknpop_state::machine_reset()
@ -348,19 +341,18 @@ void chaknpop_state::machine_reset()
m_gfxmode = 0;
m_flip_x = 0;
m_flip_y = 0;
m_mcu_seed = MCU_INITIAL_SEED;
m_mcu_result = 0;
m_mcu_select = 0;
}
static MACHINE_CONFIG_START( chaknpop )
static MACHINE_CONFIG_START( chaknpop, chaknpop_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80, XTAL_18MHz / 6) /* Verified on PCB */
MCFG_CPU_PROGRAM_MAP(chaknpop_map)
MCFG_CPU_VBLANK_INT_DRIVER("screen", chaknpop_state, irq0_line_hold)
MCFG_DEVICE_ADD("bmcu", TAITO68705_MCU, XTAL_18MHz / 6) /* Verified on PCB */
MCFG_QUANTUM_TIME(attotime::from_hz(6000)) /* 100 CPU slices per frame - an high value to ensure proper */
/* synchronization of the CPUs */
/* video hardware */
MCFG_SCREEN_ADD("screen", RASTER)
@ -404,8 +396,8 @@ ROM_START( chaknpop )
ROM_LOAD( "ao4_04.ic25", 0x06000, 0x2000, CRC(5209c7d4) SHA1(dcba785a697df55d84d65735de38365869a1da9d) )
ROM_LOAD( "ao4_05.ic3", 0x0a000, 0x2000, CRC(8720e024) SHA1(99e445c117d1501a245f9eb8d014abc4712b4963) )
ROM_REGION( 0x0800, "mcu", 0 ) /* 2k for the Motorola MC68705P5 Micro-controller */
ROM_LOAD( "ao4_06.ic23", 0x0000, 0x0800, NO_DUMP )
ROM_REGION( 0x0800, "bmcu:mcu", 0 ) /* 2k for the Motorola MC68705P5 Micro-controller */
ROM_LOAD( "ao4_06.ic23", 0x0000, 0x0800, CRC(9c78c24c) SHA1(f74c7f3ee106e5c45c907e590ec09614a2bc6751) )
ROM_REGION( 0x4000, "gfx1", 0 ) /* Sprite */
ROM_LOAD( "ao4_08.ic14", 0x0000, 0x2000, CRC(5575a021) SHA1(c2fad53fe6a12c19cec69d27c13fce6aea2502f2) )
@ -421,5 +413,5 @@ ROM_START( chaknpop )
ROM_END
/* ( YEAR NAME PARENT MACHINE INPUT STATE INIT MONITOR COMPANY FULLNAME FLAGS ) */
GAME( 1983, chaknpop, 0, chaknpop, chaknpop, chaknpop_state, 0, ROT0, "Taito Corporation", "Chack'n Pop", MACHINE_SUPPORTS_SAVE )
/* ( YEAR NAME PARENT MACHINE INPUT INIT MONITOR COMPANY FULLNAME ) */
GAME( 1983, chaknpop, 0, chaknpop, chaknpop, driver_device, 0, ROT0, "Taito Corporation", "Chack'n Pop", MACHINE_SUPPORTS_SAVE )

View File

@ -1,9 +1,7 @@
// license:BSD-3-Clause
// copyright-holders:BUT
#define MCU_INITIAL_SEED 0x81
#include "machine/taito68705interface.h"
class chaknpop_state : public driver_device
{
@ -11,30 +9,24 @@ public:
chaknpop_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_bmcu(*this, "bmcu"),
m_gfxdecode(*this, "gfxdecode"),
m_palette(*this, "palette"),
m_mcu_ram(*this, "mcu_ram"),
m_tx_ram(*this, "tx_ram"),
m_attr_ram(*this, "attr_ram"),
m_spr_ram(*this, "spr_ram") { }
/* devices */
required_device<cpu_device> m_maincpu;
optional_device<taito68705_mcu_device> m_bmcu;
required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette;
/* memory pointers */
required_shared_ptr<uint8_t> m_mcu_ram;
required_shared_ptr<uint8_t> m_tx_ram;
required_shared_ptr<uint8_t> m_attr_ram;
required_shared_ptr<uint8_t> m_spr_ram;
/* mcu-related */
uint8_t m_mcu_seed;
uint8_t m_mcu_select;
uint8_t m_mcu_result;
/* video-related */
tilemap_t *m_tx_tilemap;
uint8_t *m_vram1;
@ -46,18 +38,13 @@ public:
uint8_t m_flip_y;
DECLARE_WRITE8_MEMBER(coinlock_w);
DECLARE_READ8_MEMBER(mcu_port_a_r);
DECLARE_READ8_MEMBER(mcu_port_b_r);
DECLARE_READ8_MEMBER(mcu_port_c_r);
DECLARE_WRITE8_MEMBER(mcu_port_a_w);
DECLARE_WRITE8_MEMBER(mcu_port_b_w);
DECLARE_WRITE8_MEMBER(mcu_port_c_w);
DECLARE_READ8_MEMBER(gfxmode_r);
DECLARE_WRITE8_MEMBER(gfxmode_w);
DECLARE_WRITE8_MEMBER(txram_w);
DECLARE_WRITE8_MEMBER(attrram_w);
DECLARE_WRITE8_MEMBER(unknown_port_1_w);
DECLARE_WRITE8_MEMBER(unknown_port_2_w);
DECLARE_READ8_MEMBER(mcu_status_r);
TILE_GET_INFO_MEMBER(get_tx_tile_info);
virtual void machine_start() override;

View File

@ -6,139 +6,15 @@
*/
#include "emu.h"
#include "cpu/z80/z80.h"
#include "includes/chaknpop.h"
/* mcu data that is extracted from the real board! */
/* updated on 2st Jun 2003 */
static const uint8_t mcu_data[256] = {
0x3a, 0xe6, 0x80, 0xc6, 0x0e, 0xdd, 0x77, 0xfd,
0x7e, 0xfe, 0x10, 0x38, 0x10, 0xdd, 0x7e, 0x03,
0xc6, 0x08, 0xdd, 0x77, 0x03, 0xdd, 0x7e, 0xff,
0xc6, 0x08, 0xdd, 0x77, 0xff, 0x34, 0x23, 0xc9,
0x06, 0x10, 0xdd, 0xe5, 0xe1, 0x23, 0x23, 0x23,
0x4e, 0x23, 0x5e, 0x23, 0x56, 0x23, 0x23, 0x7b,
0xb2, 0x28, 0x02, 0x79, 0x12, 0x10, 0xf1, 0xc9,
0xe6, 0x03, 0x87, 0x87, 0x6f, 0x26, 0x00, 0x29,
0x29, 0x29, 0xe5, 0x29, 0x29, 0x29, 0xc1, 0x09,
0x01, 0xc3, 0x81, 0x09, 0xe5, 0xdd, 0xe1, 0xc9,
0x10, 0x00, 0x08, 0x10, 0x20, 0x64, 0x50, 0x00,
0x08, 0x50, 0xb0, 0x01, 0x34, 0xa0, 0x13, 0x34,
0xb0, 0x05, 0x34, 0xc0, 0x04, 0x34, 0xd0, 0x02,
0x34, 0xf0, 0x02, 0x34, 0x00, 0x60, 0x00, 0x00,
0x3f, 0x00, 0x0c, 0x1f, 0xa0, 0x3f, 0x1e, 0xa2,
0x01, 0x1e, 0xa1, 0x0a, 0x1e, 0xa2, 0x07, 0x1e,
0x92, 0x05, 0x1e, 0x02, 0x04, 0x1e, 0x12, 0x09,
0x3f, 0x22, 0x06, 0x3f, 0x21, 0x03, 0x3f, 0x20,
0x02, 0x00, 0x00, 0x3f, 0x00, 0x04, 0x02, 0xa0,
0x40, 0x12, 0xa1, 0x06, 0x12, 0xa2, 0x02, 0x12,
0xa1, 0x0a, 0x12, 0xa2, 0x07, 0x10, 0x92, 0x05,
0x10, 0x02, 0x04, 0x12, 0x12, 0x09, 0x12, 0x22,
0x06, 0x12, 0x21, 0x03, 0x12, 0x20, 0x02, 0x26,
0x00, 0x14, 0x12, 0x00, 0x00, 0x00, 0x3f, 0x00,
0x04, 0x1a, 0xa0, 0x40, 0x3f, 0x00, 0x00, 0x00,
0x3e, 0x3a, 0x87, 0x83, 0x3c, 0x32, 0x87, 0x83,
0x0f, 0x0f, 0xe6, 0x07, 0xfe, 0x02, 0x20, 0x01,
0xaf, 0x11, 0x40, 0x98, 0x1d, 0x12, 0x1d, 0x20,
0xfb, 0x2a, 0x89, 0x83, 0x2b, 0x22, 0x89, 0x83,
0xc9, 0x3a, 0x5b, 0x81, 0xa7, 0xc0, 0x21, 0x80,
0x81, 0x11, 0x04, 0x00, 0x06, 0x09, 0x34, 0x19,
0x10, 0xfc, 0x3e, 0x01, 0x32, 0x5b, 0x81, 0xc9
};
void chaknpop_state::mcu_update_seed( uint8_t data )
READ8_MEMBER(chaknpop_state::mcu_status_r)
{
if (!(data & 0x80))
{
m_mcu_seed += 0x83;
m_mcu_seed = (m_mcu_seed & 0x80) | (m_mcu_seed >> 1);
}
m_mcu_seed += 0x19;
//logerror("New seed: 0x%02x\n", m_mcu_seed);
// bit 0 = when 1, MCU is ready to receive data from main CPU
// bit 1 = when 1, MCU has sent data to the main CPU
return
((CLEAR_LINE == m_bmcu->host_semaphore_r()) ? 0x01 : 0x00) |
((CLEAR_LINE != m_bmcu->mcu_semaphore_r()) ? 0x02 : 0x00);
}
/***************************************************************************
Memory handlers
***************************************************************************/
READ8_MEMBER(chaknpop_state::mcu_port_a_r)
{
//logerror("%04x: MCU port_a read\n", space.device().safe_pc());
return m_mcu_result;
}
READ8_MEMBER(chaknpop_state::mcu_port_b_r)
{
//logerror("%04x: MCU port_b read\n", space.device().safe_pc());
return 0xff;
}
READ8_MEMBER(chaknpop_state::mcu_port_c_r)
{
//logerror("%04x: MCU port_c read\n", space.device().safe_pc());
return 0x00;
}
WRITE8_MEMBER(chaknpop_state::mcu_port_a_w)
{
uint8_t mcu_command;
mcu_command = data + m_mcu_seed;
m_mcu_result = 0;
if (mcu_command < 0x08)
{
mcu_update_seed(data);
m_mcu_result = mcu_data[m_mcu_select * 8 + mcu_command];
m_mcu_result -= m_mcu_seed;
mcu_update_seed(m_mcu_result);
logerror("%04x: MCU command 0x%02x, result 0x%02x\n", space.device().safe_pc(), mcu_command, m_mcu_result);
}
else if (mcu_command >= 0x28 && mcu_command <= 0x2a)
{
mcu_update_seed(data);
m_mcu_result = m_mcu_ram[0x380 + mcu_command];
m_mcu_result -= m_mcu_seed;
mcu_update_seed(m_mcu_result);
logerror("%04x: MCU command 0x%02x, result 0x%02x\n", space.device().safe_pc(), mcu_command, m_mcu_result);
}
else if (mcu_command < 0x80)
{
mcu_update_seed(data);
if (mcu_command >= 0x40 && mcu_command < 0x60)
{
m_mcu_select = mcu_command - 0x40;
logerror("%04x: MCU select 0x%02x\n", space.device().safe_pc(), m_mcu_select);
}
}
else if (mcu_command == 0x9c|| mcu_command == 0xde)
{
mcu_update_seed(data);
logerror("%04x: MCU command 0x%02x\n", space.device().safe_pc(), mcu_command);
}
}
WRITE8_MEMBER(chaknpop_state::mcu_port_b_w)
{
//logerror("%04x: MCU port_b write 0x%02x\n", space.device().safe_pc(), data);
}
WRITE8_MEMBER(chaknpop_state::mcu_port_c_w)
{
//logerror("%04x: MCU port_c write 0x%02x\n", space.device().safe_pc(), data);
}