1 // license:BSD-3-Clause
2 // copyright-holders:Stefan Jokisch
3 /*************************************************************************
4 
5     Atari tank8 hardware
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_TANK8_H
9 #define MAME_INCLUDES_TANK8_H
10 
11 #pragma once
12 
13 #include "sound/discrete.h"
14 #include "emupal.h"
15 #include "screen.h"
16 #include "tilemap.h"
17 
18 /* Discrete Sound Input Nodes */
19 #define TANK8_CRASH_EN          NODE_01
20 #define TANK8_BUGLE_EN          NODE_02
21 #define TANK8_MOTOR1_EN         NODE_03
22 #define TANK8_MOTOR2_EN         NODE_04
23 #define TANK8_MOTOR3_EN         NODE_05
24 #define TANK8_MOTOR4_EN         NODE_06
25 #define TANK8_MOTOR5_EN         NODE_07
26 #define TANK8_MOTOR6_EN         NODE_08
27 #define TANK8_MOTOR7_EN         NODE_09
28 #define TANK8_MOTOR8_EN         NODE_10
29 #define TANK8_EXPLOSION_EN      NODE_11
30 #define TANK8_ATTRACT_EN        NODE_12
31 #define TANK8_BUGLE_DATA1       NODE_13
32 #define TANK8_BUGLE_DATA2       NODE_14
33 
34 
35 class tank8_state : public driver_device
36 {
37 public:
tank8_state(const machine_config & mconfig,device_type type,const char * tag)38 	tank8_state(const machine_config &mconfig, device_type type, const char *tag) :
39 		driver_device(mconfig, type, tag),
40 		m_maincpu(*this, "maincpu"),
41 		m_discrete(*this, "discrete"),
42 		m_gfxdecode(*this, "gfxdecode"),
43 		m_screen(*this, "screen"),
44 		m_palette(*this, "palette"),
45 		m_video_ram(*this, "video_ram"),
46 		m_pos_h_ram(*this, "pos_h_ram"),
47 		m_pos_v_ram(*this, "pos_v_ram"),
48 		m_pos_d_ram(*this, "pos_d_ram"),
49 		m_team(*this, "team")
50 	{ }
51 
52 	void tank8(machine_config &config);
53 
54 	void init_decode();
55 
56 private:
57 	enum
58 	{
59 		TIMER_COLLISION
60 	};
61 
62 	uint8_t collision_r();
63 	void lockout_w(offs_t offset, uint8_t data);
64 	void int_reset_w(uint8_t data);
65 	void video_ram_w(offs_t offset, uint8_t data);
66 	void crash_w(uint8_t data);
67 	void explosion_w(uint8_t data);
68 	void bugle_w(uint8_t data);
69 	void bug_w(uint8_t data);
70 	void attract_w(uint8_t data);
71 	void motor_w(offs_t offset, uint8_t data);
72 
73 	TILE_GET_INFO_MEMBER(get_tile_info);
74 
75 	virtual void machine_reset() override;
76 	virtual void video_start() override;
77 	void tank8_palette(palette_device &palette) const;
78 
79 	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
80 	DECLARE_WRITE_LINE_MEMBER(screen_vblank);
81 	void set_pens();
82 	inline int get_x_pos(int n);
83 	inline int get_y_pos(int n);
84 	void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
85 	void draw_bullets(bitmap_ind16 &bitmap, const rectangle &cliprect);
86 	void set_collision(int index);
87 
88 	virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
89 	void tank8_cpu_map(address_map &map);
90 
91 	required_device<cpu_device> m_maincpu;
92 	required_device<discrete_device> m_discrete;
93 	required_device<gfxdecode_device> m_gfxdecode;
94 	required_device<screen_device> m_screen;
95 	required_device<palette_device> m_palette;
96 
97 	required_shared_ptr<uint8_t> m_video_ram;
98 	required_shared_ptr<uint8_t> m_pos_h_ram;
99 	required_shared_ptr<uint8_t> m_pos_v_ram;
100 	required_shared_ptr<uint8_t> m_pos_d_ram;
101 	required_shared_ptr<uint8_t> m_team;
102 
103 	int m_collision_index;
104 	tilemap_t *m_tilemap;
105 	bitmap_ind16 m_helper1;
106 	bitmap_ind16 m_helper2;
107 	bitmap_ind16 m_helper3;
108 	emu_timer *m_collision_timer;
109 };
110 
111 /*----------- defined in audio/tank8.c -----------*/
112 
113 DISCRETE_SOUND_EXTERN( tank8_discrete );
114 
115 #endif // MAME_INCLUDES_TANK8_H
116