1 // license:BSD-3-Clause
2 // copyright-holders:Zsolt Vasvari
3 #ifndef MAME_INCLUDES_SAURO_H
4 #define MAME_INCLUDES_SAURO_H
5 
6 #pragma once
7 
8 #include "machine/74259.h"
9 #include "machine/gen_latch.h"
10 #include "sound/sp0256.h"
11 #include "emupal.h"
12 #include "tilemap.h"
13 
14 class sauro_state : public driver_device
15 {
16 public:
sauro_state(const machine_config & mconfig,device_type type,const char * tag)17 	sauro_state(const machine_config &mconfig, device_type type, const char *tag) :
18 		driver_device(mconfig, type, tag),
19 		m_maincpu(*this, "maincpu"),
20 		m_gfxdecode(*this, "gfxdecode"),
21 		m_palette(*this, "palette"),
22 		m_sp0256(*this, "speech"),
23 		m_mainlatch(*this, "mainlatch"),
24 		m_soundlatch(*this, "soundlatch"),
25 		m_spriteram(*this, "spriteram"),
26 		m_videoram(*this, "videoram"),
27 		m_colorram(*this, "colorram"),
28 		m_videoram2(*this, "videoram2"),
29 		m_colorram2(*this, "colorram2")
30 	{ }
31 
32 	void trckydoc(machine_config &config);
33 	void tecfri(machine_config &config);
34 	void sauro(machine_config &config);
35 	void saurob(machine_config &config);
36 
37 	void init_tecfri();
38 
39 private:
40 	required_device<cpu_device> m_maincpu;
41 	required_device<gfxdecode_device> m_gfxdecode;
42 	required_device<palette_device> m_palette;
43 	optional_device<sp0256_device> m_sp0256;
44 	optional_device<ls259_device> m_mainlatch;
45 	optional_device<generic_latch_8_device> m_soundlatch; // sauro only
46 
47 	required_shared_ptr<uint8_t> m_spriteram;
48 	required_shared_ptr<uint8_t> m_videoram;
49 	required_shared_ptr<uint8_t> m_colorram;
50 	optional_shared_ptr<uint8_t> m_videoram2;
51 	optional_shared_ptr<uint8_t> m_colorram2;
52 
53 	tilemap_t *m_bg_tilemap;
54 	tilemap_t *m_fg_tilemap;
55 	uint8_t m_palette_bank;
56 
57 	bool m_irq_enable;
58 
59 	virtual void machine_start() override;
60 
61 	// common
62 	DECLARE_WRITE_LINE_MEMBER(vblank_irq);
63 	DECLARE_WRITE_LINE_MEMBER(irq_reset_w);
64 	DECLARE_WRITE_LINE_MEMBER(coin1_w);
65 	DECLARE_WRITE_LINE_MEMBER(coin2_w);
66 	DECLARE_WRITE_LINE_MEMBER(flip_screen_w);
67 	void videoram_w(offs_t offset, uint8_t data);
68 	void colorram_w(offs_t offset, uint8_t data);
69 	void scroll_bg_w(uint8_t data);
70 
71 	// sauro specific
72 	void sauro_sound_command_w(uint8_t data);
73 	uint8_t sauro_sound_command_r();
74 	DECLARE_WRITE_LINE_MEMBER(sauro_palette_bank0_w);
75 	DECLARE_WRITE_LINE_MEMBER(sauro_palette_bank1_w);
76 	void sauro_scroll_fg_w(uint8_t data);
77 	void sauro_videoram2_w(offs_t offset, uint8_t data);
78 	void sauro_colorram2_w(offs_t offset, uint8_t data);
79 	void adpcm_w(uint8_t data);
80 
81 	TILE_GET_INFO_MEMBER(get_tile_info_bg);
82 	TILE_GET_INFO_MEMBER(get_tile_info_fg);
83 
84 	DECLARE_VIDEO_START(trckydoc);
85 	DECLARE_VIDEO_START(sauro);
86 
87 	uint32_t screen_update_trckydoc(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
88 	uint32_t screen_update_sauro(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
89 	void sauro_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
90 	void trckydoc_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
91 
92 	void sauro_io_map(address_map &map);
93 	void sauro_map(address_map &map);
94 	void sauro_sound_map(address_map &map);
95 	void saurob_sound_map(address_map &map);
96 	void trckydoc_map(address_map &map);
97 };
98 
99 #endif // MAME_INCLUDES_SAURO_H
100