summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/machine/decocpu7.cpp
blob: 61b959d061bf5b3a3cfff3600b91b77e452c3f99 (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
// license:BSD-3-Clause
// copyright-holders:David Haywood

#include "decocpu7.h"

deco_cpu7_device::deco_cpu7_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
	m6502_device(mconfig, DECO_CPU7, "DECO CPU-7", tag, owner, clock, "decocpu7", __FILE__)
{
}

void deco_cpu7_device::device_start()
{
	mintf = new mi_decrypt;
	init();
}

void deco_cpu7_device::device_reset()
{
	m6502_device::device_reset();
	static_cast<mi_decrypt *>(mintf)->had_written = false;
}

uint8_t deco_cpu7_device::mi_decrypt::read_sync(uint16_t adr)
{
	uint8_t res = direct->read_byte(adr);
	if(had_written) {
		had_written = false;
		if((adr & 0x0104) == 0x0104)
			res = BITSWAP8(res, 6,5,3,4,2,7,1,0);
	}
	return res;
}

void deco_cpu7_device::mi_decrypt::write(uint16_t adr, uint8_t val)
{
	program->write_byte(adr, val);
	had_written = true;
}