summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/z80/t6a84.h
blob: 1f81b934a9946453949cb041e876b752a01daa62 (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
// license:BSD-3-Clause
// copyright-holders:QUFB
/***************************************************************************

    Toshiba T6A84, TLCS-Z80 ASSP Family

    Unknown specs. Disassembled code suggests that this processor uses
    separate code and data address spaces. Mapped pages on each space are
    configured by writing to I/O ports. Values 0 to 7 map the corresponding
    0x10000 sized page from ROM offset 0 to 0x7ffff, while value 8 seems to
    map full contents of RAM.

    Pinout: https://patents.google.com/patent/CN2280961Y/en

***************************************************************************/

#ifndef MAME_CPU_Z80_T6A84_H
#define MAME_CPU_Z80_T6A84_H

#pragma once

#include "z80.h"


/***************************************************************************
    TYPE DEFINITIONS
***************************************************************************/

class t6a84_device : public z80_device
{
public:
	enum address_spaces : uint8_t
	{
		AS_STACK = AS_OPCODES + 1
	};

	t6a84_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	uint32_t code_address(uint16_t address);
	uint32_t data_address(uint16_t address);
	uint32_t stack_address(uint16_t address);

	auto branch_cb() { return m_branch_cb.bind(); }
	auto irqfetch_cb() { return m_irqfetch_cb.bind(); }
	auto reti_cb() { return m_reti_cb.bind(); }

protected:
	t6a84_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, address_map_constructor io_map);

	// device-level overrides
	virtual void device_start() override;
	virtual void device_reset() override;

	// device_execute_interface implementation
	virtual void execute_run() override;

	// z80 overrides
	virtual uint8_t stack_read(uint16_t addr) override;
	virtual void stack_write(uint16_t addr, uint8_t value) override;

	uint8_t code_page_r();
	uint8_t data_page_r();
	uint8_t stack_page_r();
	uint8_t vector_page_r();
	void code_page_w(uint8_t page);
	void data_page_w(uint8_t page);
	void stack_page_w(uint8_t page);
	void vector_page_w(uint8_t page);

	void internal_io_map(address_map &map) const;
	virtual space_config_vector memory_space_config() const override;
	virtual bool memory_translate(int spacenum, int intention, offs_t &address, address_space *&target_space) override;

	const address_space_config m_program_space_config;
	const address_space_config m_data_space_config;
	const address_space_config m_stack_space_config;
	const address_space_config m_io_space_config;

	memory_access<16, 0, 0, ENDIANNESS_LITTLE>::specific m_stack;

	devcb_write_line m_branch_cb;
	devcb_write_line m_irqfetch_cb;
	devcb_write_line m_reti_cb;

private:
	uint8_t m_code_page;
	uint8_t m_delay_code_page;
	bool m_is_delay_code_page_set;
	uint8_t m_prev_code_page;
	uint8_t m_data_page;
	uint8_t m_stack_page;
	uint8_t m_vector_page;
};


// device type definition
DECLARE_DEVICE_TYPE(T6A84, t6a84_device)


#endif // MAME_CPU_Z80_T6A84_H