1 // license:BSD-3-Clause
2 // copyright-holders:Eugene Sandulenko
3 #ifndef MAME_INCLUDES_TIAMC1_H
4 #define MAME_INCLUDES_TIAMC1_H
5 
6 #pragma once
7 
8 #include "machine/pit8253.h"
9 #include "sound/spkrdev.h"
10 #include "emupal.h"
11 #include "tilemap.h"
12 
13 class tiamc1_state : public driver_device
14 {
15 public:
tiamc1_state(const machine_config & mconfig,device_type type,const char * tag)16 	tiamc1_state(const machine_config &mconfig, device_type type, const char *tag)
17 		: driver_device(mconfig, type, tag)
18 		, m_maincpu(*this, "maincpu")
19 		, m_gfxdecode(*this, "gfxdecode")
20 		, m_palette(*this, "palette")
21 		, m_speaker(*this, "speaker")
22 	{ }
23 
24 	void kot(machine_config &config);
25 	void tiamc1(machine_config &config);
26 
27 protected:
28 	virtual void machine_reset() override;
29 	virtual void video_start() override;
30 
31 private:
32 	std::unique_ptr<uint8_t[]> m_videoram;
33 	uint8_t *m_tileram;
34 	uint8_t *m_charram;
35 	uint8_t *m_spriteram_x;
36 	uint8_t *m_spriteram_y;
37 	uint8_t *m_spriteram_a;
38 	uint8_t *m_spriteram_n;
39 	uint8_t *m_paletteram;
40 	uint8_t m_layers_ctrl;
41 	uint8_t m_bg_vshift;
42 	uint8_t m_bg_hshift;
43 	uint8_t m_bg_bplctrl;
44 	tilemap_t *m_bg_tilemap1;
45 	tilemap_t *m_bg_tilemap2;
46 	std::unique_ptr<rgb_t[]> m_palette_ptr;
47 	void tiamc1_control_w(uint8_t data);
48 	void tiamc1_videoram_w(offs_t offset, uint8_t data);
49 	void tiamc1_bankswitch_w(uint8_t data);
50 	void tiamc1_sprite_x_w(offs_t offset, uint8_t data);
51 	void tiamc1_sprite_y_w(offs_t offset, uint8_t data);
52 	void tiamc1_sprite_a_w(offs_t offset, uint8_t data);
53 	void tiamc1_sprite_n_w(offs_t offset, uint8_t data);
54 	void tiamc1_bg_vshift_w(uint8_t data);
55 	void tiamc1_bg_hshift_w(uint8_t data);
56 	void tiamc1_bg_bplctrl_w(uint8_t data);
57 	void tiamc1_palette_w(offs_t offset, uint8_t data);
58 	void kot_bankswitch_w(uint8_t data);
59 	void kot_videoram_w(offs_t offset, uint8_t data);
60 	DECLARE_WRITE_LINE_MEMBER(pit8253_2_w);
61 
62 	TILE_GET_INFO_MEMBER(get_bg1_tile_info);
63 	TILE_GET_INFO_MEMBER(get_bg2_tile_info);
64 	DECLARE_VIDEO_START(kot);
65 	void tiamc1_palette(palette_device &palette);
66 	uint32_t screen_update_tiamc1(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
67 	uint32_t screen_update_kot(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
68 	void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
69 	required_device<cpu_device> m_maincpu;
70 	required_device<gfxdecode_device> m_gfxdecode;
71 	required_device<palette_device> m_palette;
72 
73 	void kotrybolov_io_map(address_map &map);
74 	void kotrybolov_map(address_map &map);
75 	void tiamc1_io_map(address_map &map);
76 	void tiamc1_map(address_map &map);
77 
78 	optional_device<speaker_sound_device> m_speaker;
79 	void update_bg_palette();
80 };
81 
82 #endif // MAME_INCLUDES_TIAMC1_H
83