summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/rw5000/b6100.cpp
blob: e0f66fca15e1022d3afb98f104f0b9426c6f5c60 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// license:BSD-3-Clause
// copyright-holders:hap
/*

  Rockwell B6100 MCU (based on B5500+B6000)

*/

#include "emu.h"
#include "b6100.h"

#include "rw5000d.h"


DEFINE_DEVICE_TYPE(B6100, b6100_cpu_device, "b6100", "Rockwell B6100")


// constructor
b6100_cpu_device::b6100_cpu_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, int prgwidth, address_map_constructor program, int datawidth, address_map_constructor data) :
	b6000_cpu_device(mconfig, type, tag, owner, clock, prgwidth, program, datawidth, data)
{ }

b6100_cpu_device::b6100_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) :
	b6100_cpu_device(mconfig, B6100, tag, owner, clock, 10, address_map_constructor(FUNC(b6100_cpu_device::program_896x8), this), 6, address_map_constructor(FUNC(b6100_cpu_device::data_48x4), this))
{ }


// internal memory maps
void b6100_cpu_device::program_896x8(address_map &map)
{
	map(0x000, 0x2ff).rom();
	map(0x380, 0x3ff).rom();
}

void b6100_cpu_device::data_48x4(address_map &map)
{
	map(0x00, 0x0b).ram();
	map(0x10, 0x1b).ram();
	map(0x20, 0x2b).ram();
	map(0x30, 0x3b).ram();
}


// disasm
std::unique_ptr<util::disasm_interface> b6100_cpu_device::create_disassembler()
{
	return std::make_unique<b6100_disassembler>();
}


// digit segment decoder
u16 b6100_cpu_device::decode_digit(u8 data)
{
	static u16 lut_segs[0x10] =
	{
		// 0-9 same as B6000
		0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f,

		// EFG, BCG, none, SEG8, SEG9, SEG10
		0x70, 0x46, 0x00, 0x80, 0x100, 0x200
	};
	return lut_segs[data & 0xf];
}


//-------------------------------------------------
//  execute
//-------------------------------------------------

void b6100_cpu_device::execute_one()
{
	switch (m_op)
	{
		case 0x1c: case 0x1d: case 0x1e: case 0x1f: op_lb(11); break;
		case 0x38: case 0x39: case 0x3a: case 0x3b: op_tl(); break;

		case 0x0c: op_sc(); break;
		case 0x0d: op_rsc(); break;

		// rest is same as B6000
		default: b6000_cpu_device::execute_one(); break;
	}

	// instead of with TKBS, carry flag directly outputs to SPK
	if (m_c != m_prev_c)
		m_write_spk(m_c);
}

bool b6100_cpu_device::op_is_tl(u8 op)
{
	return ((op & 0xf8) == 0x30) || ((op & 0xfc) == 0x38);
}

bool b6100_cpu_device::op_is_lb(u8 op)
{
	return ((op & 0xfc) == 0x1c) || ((op & 0xf0) == 0x20) || ((op & 0xfc) == 0x3c);
}


//-------------------------------------------------
//  changed opcodes (no need for separate file)
//-------------------------------------------------

void b6100_cpu_device::op_read()
{
	// READ: add KB to A, skip next on no overflow
	m_a += (m_read_kb() & 0xf);
	m_skip = !BIT(m_a, 4);
	m_a &= 0xf;
}