summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/machine/decocpu6.cpp
blob: 64729a28cf080f1750ff23c0181946ef05065fb7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// license:BSD-3-Clause
// copyright-holders:David Haywood
/* apparently Deco CPU-6 used by ProGolf
 just seems to be a bitswap on the opcodes like 222, but not the same one
 not a complex scheme like CPU-7?
*/


#include "emu.h"
#include "decocpu6.h"

DEFINE_DEVICE_TYPE(DECO_CPU6, deco_cpu6_device, "decocpu6", "DECO CPU-6")


deco_cpu6_device::deco_cpu6_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
	m6502_device(mconfig, DECO_CPU6, tag, owner, clock)
{
}

void deco_cpu6_device::device_start()
{
	mintf = std::make_unique<mi_decrypt>();
	init();
}

void deco_cpu6_device::device_reset()
{
	m6502_device::device_reset();
}

uint8_t deco_cpu6_device::mi_decrypt::read_sync(uint16_t adr)
{
	if (adr&1)
		return bitswap<8>(cache->read_byte(adr),6,4,7,5,3,2,1,0);
	else
		return cache->read_byte(adr);
}

std::unique_ptr<util::disasm_interface> deco_cpu6_device::create_disassembler()
{
	return std::make_unique<disassembler>();
}

u32 deco_cpu6_device::disassembler::interface_flags() const
{
	return SPLIT_DECRYPTION;
}

u8 deco_cpu6_device::disassembler::decrypt8(u8 value, offs_t pc, bool opcode) const
{
	return opcode && (pc & 1) ? bitswap<8>(value,6,4,7,5,3,2,1,0) : value;
}