summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/includes/hp9845.h
blob: 60f09aa5e7d59872613d80d6411725a1b60c07a1 (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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// license:BSD-3-Clause
// copyright-holders:F. Ulivi
// *******************************
// Driver for HP 9845B/C/T systems
// *******************************
#ifndef _HP9845_H_
#define _HP9845_H_

#include "cpu/hphybrid/hphybrid.h"
#include "machine/hp_taco.h"
#include "sound/beep.h"
#include "bus/hp9845_io/hp9845_io.h"
#include "screen.h"
#include "machine/ram.h"
#include "machine/timer.h"

class hp9845_base_state : public driver_device
{
public:
	hp9845_base_state(const machine_config &mconfig, device_type type, const char *tag);

	virtual void machine_start() override;
	virtual void machine_reset() override;
	virtual void device_reset() override;

	TIMER_DEVICE_CALLBACK_MEMBER(gv_timer);

	virtual DECLARE_READ16_MEMBER(graphic_r) = 0;
	virtual DECLARE_WRITE16_MEMBER(graphic_w) = 0;
	attotime time_to_gv_mem_availability(void) const;

	IRQ_CALLBACK_MEMBER(irq_callback);
	void update_irq(void);
	DECLARE_WRITE8_MEMBER(irq_w);
	void irq_w(uint8_t sc , int state);
	void update_flg_sts(void);
	DECLARE_WRITE8_MEMBER(sts_w);
	void sts_w(uint8_t sc , int state);
	DECLARE_WRITE8_MEMBER(flg_w);
	void flg_w(uint8_t sc , int state);

	TIMER_DEVICE_CALLBACK_MEMBER(kb_scan);
	DECLARE_READ16_MEMBER(kb_scancode_r);
	DECLARE_READ16_MEMBER(kb_status_r);
	DECLARE_WRITE16_MEMBER(kb_irq_clear_w);
	TIMER_DEVICE_CALLBACK_MEMBER(beeper_off);

	DECLARE_WRITE8_MEMBER(pa_w);

	DECLARE_WRITE_LINE_MEMBER(prt_irl_w);
	DECLARE_WRITE_LINE_MEMBER(prt_flg_w);
	DECLARE_WRITE_LINE_MEMBER(prt_sts_w);
	DECLARE_WRITE_LINE_MEMBER(t14_irq_w);
	DECLARE_WRITE_LINE_MEMBER(t14_flg_w);
	DECLARE_WRITE_LINE_MEMBER(t14_sts_w);
	DECLARE_WRITE_LINE_MEMBER(t15_irq_w);
	DECLARE_WRITE_LINE_MEMBER(t15_flg_w);
	DECLARE_WRITE_LINE_MEMBER(t15_sts_w);

	DECLARE_INPUT_CHANGED_MEMBER(togglekey_changed);
protected:
	required_device<hp_5061_3001_cpu_device> m_lpu;
	required_device<hp_5061_3001_cpu_device> m_ppu;
	required_device<screen_device> m_screen;
	required_device<palette_device> m_palette;
	required_device<timer_device> m_gv_timer;
	required_ioport m_io_key0;
	required_ioport m_io_key1;
	required_ioport m_io_key2;
	required_ioport m_io_key3;
	required_ioport m_io_shiftlock;
	required_device<hp_taco_device> m_t14;
	required_device<hp_taco_device> m_t15;
	required_device<beep_device> m_beeper;
	required_device<timer_device> m_beep_timer;
	required_device<hp9845_io_slot_device> m_io_slot0;
	required_device<hp9845_io_slot_device> m_io_slot1;
	required_device<hp9845_io_slot_device> m_io_slot2;
	required_device<hp9845_io_slot_device> m_io_slot3;
	required_device<ram_device> m_ram;

	void setup_ram_block(unsigned block , unsigned offset);

	virtual void advance_gv_fsm(bool ds , bool trigger) = 0;
	void kb_scan_ioport(ioport_value pressed , ioport_port *port , unsigned idx_base , int& max_seq_len , unsigned& max_seq_idx);
	void update_kb_prt_irq();

	// Character generator
	required_region_ptr<uint8_t> m_chargen;

	// Text mode video I/F
	typedef struct {
		uint8_t chars[ 80 ];
		uint8_t attrs[ 80 ];
		bool full;
	} video_buffer_t;

	bitmap_rgb32 m_bitmap;
	offs_t m_video_mar;
	uint16_t m_video_word;
	bool m_video_load_mar;
	bool m_video_first_mar;
	bool m_video_byte_idx;
	bool m_video_buff_idx;
	bool m_video_blanked;
	video_buffer_t m_video_buff[ 2 ];

	// Graphic video
	typedef enum {
		GV_STAT_RESET,
		GV_STAT_WAIT_DS_0 = GV_STAT_RESET,
		GV_STAT_WAIT_TRIG_0,
		GV_STAT_WAIT_MEM_0,
		GV_STAT_WAIT_DS_1,
		GV_STAT_WAIT_DS_2,
		GV_STAT_WAIT_TRIG_1,
		GV_STAT_WAIT_MEM_1,
		GV_STAT_WAIT_MEM_2
	} gv_fsm_state_t;

	bool m_graphic_sel;
	gv_fsm_state_t m_gv_fsm_state;
	bool m_gv_int_en;
	bool m_gv_dma_en;
	uint8_t m_gv_cmd; // U65 (GC)
	uint16_t m_gv_data_w;     // U29, U45, U28 & U44 (GC)
	uint16_t m_gv_data_r;     // U59 & U60 (GC)
	uint16_t m_gv_io_counter; // U1, U2, U14 & U15 (GC)
	uint16_t m_gv_cursor_x;   // U31 & U23 (GS)
	uint16_t m_gv_cursor_y;   // U15 & U8 (GS)
	bool m_gv_cursor_gc;    // U8 (GS)
	bool m_gv_cursor_fs;    // U8 (GS)

	// Interrupt handling
	uint8_t m_irl_pending;
	uint8_t m_irh_pending;

	// FLG/STS handling
	uint8_t m_pa;
	uint16_t m_flg_status;
	uint16_t m_sts_status;

	// State of keyboard
	ioport_value m_kb_state[ 4 ];
	uint8_t m_kb_scancode;
	uint16_t m_kb_status;

	// Printer
	bool m_prt_irl;
};

#endif /* _HP9845_H_ */