1 // license:BSD-3-Clause
2 // copyright-holders:Phil Stroffolino, Carlos A. Lozano, Rob Rosenbrock
3 #ifndef MAME_INCLUDES_RENEGADE_H
4 #define MAME_INCLUDES_RENEGADE_H
5 
6 #pragma once
7 
8 #include "machine/taito68705interface.h"
9 
10 #include "machine/gen_latch.h"
11 #include "machine/timer.h"
12 #include "sound/msm5205.h"
13 #include "tilemap.h"
14 #include "screen.h"
15 
16 class renegade_state : public driver_device
17 {
18 public:
renegade_state(const machine_config & mconfig,device_type type,const char * tag)19 	renegade_state(const machine_config &mconfig, device_type type, const char *tag)
20 		: driver_device(mconfig, type, tag)
21 		, m_maincpu(*this,"maincpu")
22 		, m_audiocpu(*this, "audiocpu")
23 		, m_mcu(*this, "mcu")
24 		, m_msm(*this, "msm")
25 		, m_screen(*this, "screen")
26 		, m_gfxdecode(*this, "gfxdecode")
27 		, m_soundlatch(*this, "soundlatch")
28 		, m_fg_videoram(*this, "fg_videoram")
29 		, m_bg_videoram(*this, "bg_videoram")
30 		, m_spriteram(*this, "spriteram")
31 		, m_rombank(*this, "rombank")
32 		, m_adpcmrom(*this, "adpcm")
33 	{
34 	}
35 
36 	void renegade(machine_config &config);
37 	void kuniokunb(machine_config &config);
38 
39 	DECLARE_CUSTOM_INPUT_MEMBER(mcu_status_r);
40 	DECLARE_INPUT_CHANGED_MEMBER(coin_inserted);
41 
42 protected:
43 	virtual void machine_start() override;
44 	virtual void machine_reset() override;
45 	virtual void video_start() override;
46 
47 private:
48 	required_device<cpu_device> m_maincpu;
49 	required_device<cpu_device> m_audiocpu;
50 	optional_device<taito68705_mcu_device> m_mcu;
51 	required_device<msm5205_device> m_msm;
52 	required_device<screen_device> m_screen;
53 	required_device<gfxdecode_device> m_gfxdecode;
54 	required_device<generic_latch_8_device> m_soundlatch;
55 
56 	required_shared_ptr<uint8_t> m_fg_videoram;
57 	required_shared_ptr<uint8_t> m_bg_videoram;
58 	required_shared_ptr<uint8_t> m_spriteram;
59 
60 	required_memory_bank m_rombank;
61 
62 	required_region_ptr<uint8_t> m_adpcmrom;
63 
64 	uint32_t m_adpcm_pos;
65 	uint32_t m_adpcm_end;
66 	bool m_adpcm_playing;
67 
68 	int32_t m_scrollx;
69 	tilemap_t *m_bg_tilemap;
70 	tilemap_t *m_fg_tilemap;
71 
72 	uint8_t mcu_reset_r();
73 	void bankswitch_w(uint8_t data);
74 	void irq_ack_w(uint8_t data);
75 	void nmi_ack_w(uint8_t data);
76 	void fg_videoram_w(offs_t offset, uint8_t data);
77 	void bg_videoram_w(offs_t offset, uint8_t data);
78 	void flipscreen_w(uint8_t data);
79 	void scroll_lsb_w(uint8_t data);
80 	void scroll_msb_w(uint8_t data);
81 	void adpcm_start_w(uint8_t data);
82 	void adpcm_addr_w(uint8_t data);
83 	void adpcm_stop_w(uint8_t data);
84 	DECLARE_WRITE_LINE_MEMBER(adpcm_int);
85 
86 	TILE_GET_INFO_MEMBER(get_bg_tilemap_info);
87 	TILE_GET_INFO_MEMBER(get_fg_tilemap_info);
88 
89 	TIMER_DEVICE_CALLBACK_MEMBER(interrupt);
90 
91 	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
92 	void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
93 
94 	void renegade_map(address_map &map);
95 	void renegade_nomcu_map(address_map &map);
96 	void renegade_sound_map(address_map &map);
97 };
98 
99 #endif // MAME_INCLUDES_RENEGADE_H
100