1 // license:BSD-3-Clause
2 // copyright-holders:Pierpaolo Prazzoli, Bryan McPhail
3 #ifndef MAME_INCLUDES_TRYOUT_H
4 #define MAME_INCLUDES_TRYOUT_H
5 
6 #pragma once
7 
8 #include "machine/gen_latch.h"
9 #include "emupal.h"
10 #include "tilemap.h"
11 
12 class tryout_state : public driver_device
13 {
14 public:
tryout_state(const machine_config & mconfig,device_type type,const char * tag)15 	tryout_state(const machine_config &mconfig, device_type type, const char *tag) :
16 		driver_device(mconfig, type, tag),
17 		m_maincpu(*this, "maincpu"),
18 		m_audiocpu(*this, "audiocpu"),
19 		m_gfxdecode(*this, "gfxdecode"),
20 		m_palette(*this, "palette"),
21 		m_soundlatch(*this, "soundlatch"),
22 		m_videoram(*this, "videoram"),
23 		m_spriteram(*this, "spriteram"),
24 		m_spriteram2(*this, "spriteram2"),
25 		m_gfx_control(*this, "gfx_control")
26 	{ }
27 
28 	void tryout(machine_config &config);
29 
30 	DECLARE_INPUT_CHANGED_MEMBER(coin_inserted);
31 
32 private:
33 	required_device<cpu_device> m_maincpu;
34 	required_device<cpu_device> m_audiocpu;
35 	required_device<gfxdecode_device> m_gfxdecode;
36 	required_device<palette_device> m_palette;
37 	required_device<generic_latch_8_device> m_soundlatch;
38 
39 	required_shared_ptr<uint8_t> m_videoram;
40 	required_shared_ptr<uint8_t> m_spriteram;
41 	required_shared_ptr<uint8_t> m_spriteram2;
42 	required_shared_ptr<uint8_t> m_gfx_control;
43 
44 	tilemap_t *m_fg_tilemap;
45 	tilemap_t *m_bg_tilemap;
46 	uint8_t m_vram_bank;
47 	std::unique_ptr<uint8_t[]> m_vram;
48 	std::unique_ptr<uint8_t[]> m_vram_gfx;
49 
50 	void nmi_ack_w(uint8_t data);
51 	void sound_w(uint8_t data);
52 	void sound_irq_ack_w(uint8_t data);
53 	void bankswitch_w(uint8_t data);
54 	uint8_t vram_r(offs_t offset);
55 	void videoram_w(offs_t offset, uint8_t data);
56 	void vram_w(offs_t offset, uint8_t data);
57 	void vram_bankswitch_w(uint8_t data);
58 	void flipscreen_w(uint8_t data);
59 
60 	TILE_GET_INFO_MEMBER(get_fg_tile_info);
61 	TILE_GET_INFO_MEMBER(get_bg_tile_info);
62 	TILEMAP_MAPPER_MEMBER(get_fg_memory_offset);
63 	TILEMAP_MAPPER_MEMBER(get_bg_memory_offset);
64 
65 	virtual void machine_start() override;
66 	virtual void video_start() override;
67 	void tryout_palette(palette_device &palette) const;
68 
69 	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
70 	void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
71 
72 	void main_cpu(address_map &map);
73 	void sound_cpu(address_map &map);
74 };
75 
76 #endif // MAME_INCLUDES_TRYOUT_H
77