1 // license:BSD-3-Clause
2 // copyright-holders:Aaron Giles
3 /*************************************************************************
4 
5     Atari Bad Lands hardware
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_BADLANDS_H
9 #define MAME_INCLUDES_BADLANDS_H
10 
11 #pragma once
12 
13 #include "cpu/z80/z80.h"
14 #include "cpu/m68000/m68000.h"
15 #include "cpu/m6502/m6502.h"
16 #include "machine/eeprompar.h"
17 #include "machine/gen_latch.h"
18 #include "machine/watchdog.h"
19 #include "machine/timer.h"
20 #include "sound/ym2151.h"
21 #include "video/atarimo.h"
22 
23 #include "speaker.h"
24 #include "tilemap.h"
25 
26 /*----------- defined in machine/badlands.cpp -----------*/
27 
28 //extern const gfx_layout badlands_molayout;
29 
30 INPUT_PORTS_EXTERN(badlands);
31 
32 
33 class badlands_state : public driver_device
34 {
35 public:
badlands_state(const machine_config & mconfig,device_type type,const char * tag)36 	badlands_state(const machine_config &mconfig, device_type type, const char *tag)
37 		: driver_device(mconfig, type, tag)
38 		, m_maincpu(*this, "maincpu")
39 		, m_audiocpu(*this, "audiocpu")
40 		, m_soundlatch(*this, "soundlatch")
41 		, m_mainlatch(*this, "mainlatch")
42 		, m_ymsnd(*this, "ymsnd")
43 		, m_screen(*this, "screen")
44 		, m_gfxdecode(*this, "gfxdecode")
45 		, m_playfield_tilemap(*this, "playfield")
46 		, m_mob(*this, "mob")
47 	{ }
48 
49 	required_device<cpu_device> m_maincpu;
50 	optional_device<cpu_device> m_audiocpu;
51 	optional_device<generic_latch_8_device> m_soundlatch;
52 	optional_device<generic_latch_8_device> m_mainlatch;
53 	optional_device<ym2151_device> m_ymsnd;
54 
55 	required_device<screen_device> m_screen;
56 	required_device<gfxdecode_device> m_gfxdecode;
57 	required_device<tilemap_device> m_playfield_tilemap;
58 	optional_device<atari_motion_objects_device> m_mob;
59 
60 	uint16_t sound_busy_r();
61 	void sound_reset_w(uint16_t data);
62 	uint16_t pedal_0_r();
63 	uint16_t pedal_1_r();
64 
65 	uint8_t audio_io_r();
66 	void audio_io_w(uint8_t data);
67 	uint8_t audio_irqack_r();
68 	void audio_irqack_w(uint8_t data);
69 
70 	void init_badlands();
71 	TILE_GET_INFO_MEMBER(get_playfield_tile_info);
72 	DECLARE_MACHINE_START(badlands);
73 	DECLARE_MACHINE_RESET(badlands);
74 	DECLARE_VIDEO_START(badlands);
75 	uint32_t screen_update_badlands(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
76 	INTERRUPT_GEN_MEMBER(vblank_int);
77 	void video_int_ack_w(uint16_t data);
78 	TIMER_DEVICE_CALLBACK_MEMBER(sound_scanline);
79 	void badlands_pf_bank_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
80 
81 	static const atari_motion_objects_config s_mob_config;
82 	void badlands(machine_config &config);
83 	void audio_map(address_map &map);
84 	void main_map(address_map &map);
85 
86 private:
87 	uint8_t           m_pedal_value[2];
88 	uint8_t           m_playfield_tile_bank;
89 };
90 
91 class badlandsbl_state : public badlands_state
92 {
93 public:
badlandsbl_state(const machine_config & mconfig,device_type type,const char * tag)94 	badlandsbl_state(const machine_config &mconfig, device_type type, const char *tag)
95 		: badlands_state(mconfig, type, tag),
96 		  m_b_sharedram(*this, "b_sharedram"),
97 		  m_spriteram(*this, "spriteram")
98 	{}
99 
100 	uint8_t bootleg_shared_r(offs_t offset);
101 	void bootleg_shared_w(offs_t offset, uint8_t data);
102 	void bootleg_main_irq_w(uint8_t data);
103 	uint16_t badlandsb_unk_r();
104 	uint8_t sound_response_r();
105 	TIMER_DEVICE_CALLBACK_MEMBER(bootleg_sound_scanline);
106 
107 	void badlandsb(machine_config &config);
108 	void bootleg_map(address_map &map);
109 	void bootleg_audio_map(address_map &map);
110 	uint32_t screen_update_badlandsbl(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
111 
112 protected:
113 	virtual void machine_reset() override;
114 
115 private:
116 	required_shared_ptr<uint8_t> m_b_sharedram;
117 	required_shared_ptr<uint16_t> m_spriteram;
118 
119 	uint8_t m_sound_response;
120 };
121 
122 
123 #endif // MAME_INCLUDES_BADLANDS_H
124 
125 
126