1 // license:BSD-3-Clause
2 // copyright-holders:Nicola Salmoria
3 /*************************************************************************
4 
5     Tail to Nose / Super Formula
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_TAIL2NOS_H
9 #define MAME_INCLUDES_TAIL2NOS_H
10 
11 #pragma once
12 
13 #include "machine/6850acia.h"
14 #include "machine/gen_latch.h"
15 #include "video/k051316.h"
16 #include "emupal.h"
17 #include "tilemap.h"
18 
19 class tail2nos_state : public driver_device
20 {
21 public:
tail2nos_state(const machine_config & mconfig,device_type type,const char * tag)22 	tail2nos_state(const machine_config &mconfig, device_type type, const char *tag) :
23 		driver_device(mconfig, type, tag),
24 		m_txvideoram(*this, "txvideoram"),
25 		m_spriteram(*this, "spriteram"),
26 		m_zoomram(*this, "k051316"),
27 		m_maincpu(*this, "maincpu"),
28 		m_audiocpu(*this, "audiocpu"),
29 		m_k051316(*this, "k051316"),
30 		m_gfxdecode(*this, "gfxdecode"),
31 		m_palette(*this, "palette"),
32 		m_soundlatch(*this, "soundlatch"),
33 		m_acia(*this, "acia"),
34 		m_analog(*this, "AN%u", 0U)
35 	{ }
36 
37 	void tail2nos(machine_config &config);
38 
39 	template <int N> DECLARE_CUSTOM_INPUT_MEMBER(analog_in_r);
40 
41 protected:
42 	virtual void machine_start() override;
43 	virtual void machine_reset() override;
44 	virtual void video_start() override;
45 
46 private:
47 	/* memory pointers */
48 	required_shared_ptr<uint16_t> m_txvideoram;
49 	required_shared_ptr<uint16_t> m_spriteram;
50 	required_shared_ptr<uint16_t> m_zoomram;
51 
52 	/* video-related */
53 	tilemap_t   *m_tx_tilemap;
54 	int         m_txbank;
55 	int         m_txpalette;
56 	bool        m_video_enable;
57 	bool        m_flip_screen;
58 
59 	/* devices */
60 	required_device<cpu_device> m_maincpu;
61 	required_device<cpu_device> m_audiocpu;
62 	required_device<k051316_device> m_k051316;
63 	required_device<gfxdecode_device> m_gfxdecode;
64 	required_device<palette_device> m_palette;
65 	required_device<generic_latch_8_device> m_soundlatch;
66 	required_device<acia6850_device> m_acia;
67 	required_ioport_array<2> m_analog;
68 
69 	void tail2nos_txvideoram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
70 	void tail2nos_zoomdata_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
71 	void tail2nos_gfxbank_w(uint8_t data);
72 	void sound_bankswitch_w(uint8_t data);
73 	uint8_t sound_semaphore_r();
74 	TILE_GET_INFO_MEMBER(get_tile_info);
75 	uint32_t screen_update_tail2nos(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
76 	void tail2nos_postload();
77 	void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
78 	K051316_CB_MEMBER(zoom_callback);
79 	void main_map(address_map &map);
80 	void sound_map(address_map &map);
81 	void sound_port_map(address_map &map);
82 };
83 
84 #endif // MAME_INCLUDES_TAIL2NOS_H
85