1 // license:BSD-3-Clause
2 // copyright-holders:Ernesto Corvi
3 #ifndef MAME_INCLUDES_TRUCOCL_H
4 #define MAME_INCLUDES_TRUCOCL_H
5 
6 #pragma once
7 
8 #include "sound/dac.h"
9 #include "emupal.h"
10 #include "tilemap.h"
11 
12 class trucocl_state : public driver_device
13 {
14 public:
trucocl_state(const machine_config & mconfig,device_type type,const char * tag)15 	trucocl_state(const machine_config &mconfig, device_type type, const char *tag)
16 		: driver_device(mconfig, type, tag),
17 		m_videoram(*this, "videoram"),
18 		m_colorram(*this, "colorram"),
19 		m_maincpu(*this, "maincpu"),
20 		m_dac(*this, "dac"),
21 		m_gfxdecode(*this, "gfxdecode") { }
22 
23 	void trucocl(machine_config &config);
24 
25 	void init_trucocl();
26 
27 protected:
28 	enum
29 	{
30 		TIMER_DAC_IRQ
31 	};
32 
33 	virtual void machine_reset() override;
34 	virtual void video_start() override;
35 
36 	virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
37 
38 private:
39 	int m_cur_dac_address;
40 	int m_cur_dac_address_index;
41 	required_shared_ptr<uint8_t> m_videoram;
42 	required_shared_ptr<uint8_t> m_colorram;
43 	tilemap_t *m_bg_tilemap;
44 
45 	uint8_t m_irq_mask;
46 	emu_timer *m_dac_irq_timer;
47 
48 	void irq_enable_w(uint8_t data);
49 	void trucocl_videoram_w(offs_t offset, uint8_t data);
50 	void trucocl_colorram_w(offs_t offset, uint8_t data);
51 	void audio_dac_w(uint8_t data);
52 	TILE_GET_INFO_MEMBER(get_bg_tile_info);
53 	void trucocl_palette(palette_device &palette) const;
54 	uint32_t screen_update_trucocl(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
55 	INTERRUPT_GEN_MEMBER(trucocl_interrupt);
56 	required_device<cpu_device> m_maincpu;
57 	required_device<dac_byte_interface> m_dac;
58 	required_device<gfxdecode_device> m_gfxdecode;
59 
60 	void main_map(address_map &map);
61 	void main_io(address_map &map);
62 };
63 
64 #endif // MAME_INCLUDES_TRUCOCL_H
65