1 // license:BSD-3-Clause
2 // copyright-holders:Sandro Ronco
3 /***************************************************************************
4 
5         VTech Laser PC4
6 
7 ****************************************************************************/
8 #ifndef MAME_INCLUDES_PC4_H
9 #define MAME_INCLUDES_PC4_H
10 
11 #pragma once
12 
13 
14 #include "sound/beep.h"
15 #include "emupal.h"
16 
17 class pc4_state : public driver_device
18 {
19 public:
pc4_state(const machine_config & mconfig,device_type type,const char * tag)20 	pc4_state(const machine_config &mconfig, device_type type, const char *tag) :
21 		driver_device(mconfig, type, tag),
22 		m_maincpu(*this, "maincpu"),
23 		m_beep(*this, "beeper"),
24 		m_region_charset(*this, "charset"),
25 		m_rombank(*this, "rombank")
26 	{ }
27 
28 	void pc4(machine_config &config);
29 
30 protected:
31 	static const device_timer_id BUSY_TIMER = 0;
32 	static const device_timer_id BLINKING_TIMER = 1;
33 
34 	virtual void machine_start() override;
35 
36 	virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
37 
38 private:
39 	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
40 
41 	void beep_w(uint8_t data);
42 	void bank_w(uint8_t data);
43 	uint8_t kb_r(offs_t offset);
44 
45 	//LCD controller
46 	void update_ac();
47 	void set_busy_flag(uint16_t usec);
48 
49 	void lcd_control_w(uint8_t data);
50 	uint8_t lcd_control_r();
51 	void lcd_data_w(uint8_t data);
52 	uint8_t lcd_data_r();
53 	void lcd_offset_w(uint8_t data);
54 
55 	void pc4_palette(palette_device &palette) const;
56 
57 	void pc4_io(address_map &map);
58 	void pc4_mem(address_map &map);
59 
60 	emu_timer *m_blink_timer;
61 	emu_timer *m_busy_timer;
62 
63 	uint8_t m_busy_flag;
64 	uint8_t m_ddram[0xa0];
65 	uint8_t m_cgram[0x40];
66 	int16_t m_ac;
67 	uint8_t m_ac_mode;
68 	uint8_t m_data_bus_flag;
69 	int16_t m_cursor_pos;
70 	uint8_t m_display_on;
71 	uint8_t m_cursor_on;
72 	uint8_t m_blink_on;
73 	uint8_t m_shift_on;
74 	int8_t m_disp_shift;
75 	int8_t m_direction;
76 	uint8_t m_blink;
77 
78 	required_device<cpu_device> m_maincpu;
79 	required_device<beep_device> m_beep;
80 
81 	required_memory_region m_region_charset;
82 	required_memory_bank m_rombank;
83 	ioport_port *io_port[8];
84 };
85 
86 #endif // MAME_INCLUDES_PC4_H
87