1 // license:BSD-3-Clause
2 // copyright-holders:Curt Coder
3 #pragma once
4 
5 #ifndef MAME_INCLUDES_TMC600_H
6 #define MAME_INCLUDES_TMC600_H
7 
8 #include "cpu/cosmac/cosmac.h"
9 #include "imagedev/cassette.h"
10 #include "imagedev/snapquik.h"
11 #include "bus/centronics/ctronics.h"
12 #include "bus/tmc600/euro.h"
13 #include "machine/cdp1852.h"
14 #include "machine/ram.h"
15 #include "machine/timer.h"
16 #include "sound/cdp1869.h"
17 #include "speaker.h"
18 
19 #define SCREEN_TAG          "screen"
20 #define CDP1802_TAG         "cdp1802"
21 #define CDP1869_TAG         "cdp1869"
22 #define CDP1852_KB_TAG      "cdp1852_kb"
23 #define CDP1852_BUS_TAG     "cdp1852_bus"
24 #define CDP1852_TMC700_TAG  "cdp1852_printer"
25 #define CENTRONICS_TAG      "centronics"
26 
27 #define TMC600_PAGE_RAM_SIZE    0x400
28 #define TMC600_PAGE_RAM_MASK    0x3ff
29 
30 class tmc600_state : public driver_device
31 {
32 public:
tmc600_state(const machine_config & mconfig,device_type type,const char * tag)33 	tmc600_state(const machine_config &mconfig, device_type type, const char *tag) :
34 		driver_device(mconfig, type, tag),
35 		m_maincpu(*this, CDP1802_TAG),
36 		m_vis(*this, CDP1869_TAG),
37 		m_bwio(*this, CDP1852_KB_TAG),
38 		m_cassette(*this, "cassette"),
39 		m_centronics(*this, "centronics"),
40 		m_bus(*this, "bus"),
41 		m_ram(*this, RAM_TAG),
42 		m_char_rom(*this, "chargen"),
43 		m_page_ram(*this, "page_ram"),
44 		m_color_ram(*this, "color_ram"),
45 		m_run(*this, "RUN"),
46 		m_key_row(*this, "Y%u", 0)
47 	{ }
48 
49 	void tmc600(machine_config &config);
50 	void tmc600_video(machine_config &config);
51 
52 private:
53 	required_device<cosmac_device> m_maincpu;
54 	required_device<cdp1869_device> m_vis;
55 	required_device<cdp1852_device> m_bwio;
56 	required_device<cassette_image_device> m_cassette;
57 	required_device<centronics_device> m_centronics;
58 	required_device<tmc600_eurobus_slot_device> m_bus;
59 	required_device<ram_device> m_ram;
60 	required_region_ptr<uint8_t> m_char_rom;
61 	required_shared_ptr<uint8_t> m_page_ram;
62 	optional_shared_ptr<uint8_t> m_color_ram;
63 	required_ioport m_run;
64 	required_ioport_array<8> m_key_row;
65 
66 	virtual void video_start() override;
67 
68 	uint8_t  rtc_r();
69 	void printer_w(uint8_t data);
70 	void vismac_register_w(uint8_t data);
71 	void vismac_data_w(uint8_t data);
72 	void page_ram_w(offs_t offset, uint8_t data);
73 	DECLARE_READ_LINE_MEMBER( clear_r );
74 	DECLARE_READ_LINE_MEMBER( ef2_r );
75 	DECLARE_READ_LINE_MEMBER( ef3_r );
76 	DECLARE_WRITE_LINE_MEMBER( q_w );
77 	void sc_w(uint8_t data);
78 	void out3_w(uint8_t data);
79 	DECLARE_WRITE_LINE_MEMBER( prd_w );
80 
81 	uint8_t get_color(uint16_t pma);
82 
83 	// video state
84 	int m_vismac_reg_latch;     // video register latch
85 	int m_vismac_color_latch;   // color latch
86 	bool m_blink;                // cursor blink
87 	int m_frame;
88 	bool m_rtc_int;
89 	u8 m_out3;
90 
91 	TIMER_DEVICE_CALLBACK_MEMBER(blink_tick);
92 	CDP1869_CHAR_RAM_READ_MEMBER(tmc600_char_ram_r);
93 	CDP1869_PCB_READ_MEMBER(tmc600_pcb_r);
94 
95 	void cdp1869_page_ram(address_map &map);
96 	void tmc600_io_map(address_map &map);
97 	void tmc600_map(address_map &map);
98 };
99 
100 #endif
101