1 // license:BSD-3-Clause
2 // copyright-holders:Luca Elia
3 /*************************************************************************
4 
5     American Speedway
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_AMSPDWY_H
9 #define MAME_INCLUDES_AMSPDWY_H
10 
11 #pragma once
12 
13 #include "machine/gen_latch.h"
14 #include "sound/ym2151.h"
15 #include "emupal.h"
16 #include "screen.h"
17 #include "tilemap.h"
18 
19 class amspdwy_state : public driver_device
20 {
21 public:
amspdwy_state(const machine_config & mconfig,device_type type,const char * tag)22 	amspdwy_state(const machine_config &mconfig, device_type type, const char *tag) :
23 		driver_device(mconfig, type, tag),
24 		m_videoram(*this, "videoram"),
25 		m_spriteram(*this, "spriteram"),
26 		m_colorram(*this, "colorram"),
27 		m_maincpu(*this, "maincpu"),
28 		m_audiocpu(*this, "audiocpu"),
29 		m_ym2151(*this, "ymsnd"),
30 		m_gfxdecode(*this, "gfxdecode"),
31 		m_screen(*this, "screen"),
32 		m_palette(*this, "palette"),
33 		m_soundlatch(*this, "soundlatch")
34 	{ }
35 
36 	void amspdwy(machine_config &config);
37 
38 protected:
39 	virtual void machine_start() override;
40 	virtual void machine_reset() override;
41 	virtual void video_start() override;
42 
43 private:
44 	/* memory pointers */
45 	required_shared_ptr<uint8_t> m_videoram;
46 	required_shared_ptr<uint8_t> m_spriteram;
47 	required_shared_ptr<uint8_t> m_colorram;
48 
49 	/* devices */
50 	required_device<cpu_device> m_maincpu;
51 	required_device<cpu_device> m_audiocpu;
52 	required_device<ym2151_device> m_ym2151;
53 	required_device<gfxdecode_device> m_gfxdecode;
54 	required_device<screen_device> m_screen;
55 	required_device<palette_device> m_palette;
56 	required_device<generic_latch_8_device> m_soundlatch;
57 
58 	/* video-related */
59 	tilemap_t *m_bg_tilemap;
60 	int m_flipscreen;
61 
62 	/* misc */
63 	uint8_t m_wheel_old[2];
64 	uint8_t m_wheel_return[2];
65 
66 	uint8_t amspdwy_wheel_0_r();
67 	uint8_t amspdwy_wheel_1_r();
68 	void amspdwy_flipscreen_w(uint8_t data);
69 	void amspdwy_videoram_w(offs_t offset, uint8_t data);
70 	void amspdwy_colorram_w(offs_t offset, uint8_t data);
71 	uint8_t amspdwy_sound_r();
72 	TILE_GET_INFO_MEMBER(get_tile_info);
73 	TILEMAP_MAPPER_MEMBER(tilemap_scan_cols_back);
74 
75 	uint32_t screen_update_amspdwy(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
76 	void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
77 	uint8_t amspdwy_wheel_r(int index);
78 
79 	void amspdwy_map(address_map &map);
80 	void amspdwy_portmap(address_map &map);
81 	void amspdwy_sound_map(address_map &map);
82 };
83 
84 #endif // MAME_INCLUDES_AMSPDWY_H
85