1 // license:BSD-3-Clause
2 // copyright-holders:Manuel Abadia, Peter Ferrie
3 #ifndef MAME_INCLUDES_THOOP2_H
4 #define MAME_INCLUDES_THOOP2_H
5 
6 #pragma once
7 
8 #include "machine/74259.h"
9 #include "emupal.h"
10 #include "tilemap.h"
11 
12 class thoop2_state : public driver_device
13 {
14 public:
thoop2_state(const machine_config & mconfig,device_type type,const char * tag)15 	thoop2_state(const machine_config &mconfig, device_type type, const char *tag) :
16 		driver_device(mconfig, type, tag),
17 		m_pant{ nullptr, nullptr },
18 		m_maincpu(*this, "maincpu"),
19 		m_outlatch(*this, "outlatch"),
20 		m_gfxdecode(*this, "gfxdecode"),
21 		m_palette(*this, "palette"),
22 		m_okibank(*this, "okibank"),
23 		m_videoram(*this, "videoram"),
24 		m_vregs(*this, "vregs"),
25 		m_spriteram(*this, "spriteram"),
26 		m_shareram(*this, "shareram")
27 	{ }
28 
29 	void thoop2(machine_config &config);
30 
31 private:
32 	void oki_bankswitch_w(uint8_t data);
33 	DECLARE_WRITE_LINE_MEMBER(coin1_lockout_w);
34 	DECLARE_WRITE_LINE_MEMBER(coin2_lockout_w);
35 	DECLARE_WRITE_LINE_MEMBER(coin1_counter_w);
36 	DECLARE_WRITE_LINE_MEMBER(coin2_counter_w);
37 
38 	void vram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
39 	void shareram_w(offs_t offset, uint8_t data);
40 	uint8_t shareram_r(offs_t offset);
41 
42 	template<int Layer> TILE_GET_INFO_MEMBER(get_tile_info);
43 	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
44 
45 	void mcu_hostmem_map(address_map &map);
46 	void oki_map(address_map &map);
47 	void thoop2_map(address_map &map);
48 
49 	virtual void machine_start() override;
50 	virtual void video_start() override;
51 
52 	void sort_sprites();
53 	void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int pri);
54 
55 	int m_sprite_count[5];
56 	std::unique_ptr<int[]> m_sprite_table[5];
57 	tilemap_t *m_pant[2];
58 
59 	required_device<cpu_device> m_maincpu;
60 	required_device<ls259_device> m_outlatch;
61 	required_device<gfxdecode_device> m_gfxdecode;
62 	required_device<palette_device> m_palette;
63 	required_memory_bank m_okibank;
64 
65 	required_shared_ptr<uint16_t> m_videoram;
66 	required_shared_ptr<uint16_t> m_vregs;
67 	required_shared_ptr<uint16_t> m_spriteram;
68 	required_shared_ptr<uint16_t> m_shareram;
69 };
70 
71 #endif // MAME_INCLUDES_THOOP2_H
72