1 // license:BSD-3-Clause
2 // copyright-holders:Mike Balfour
3 /***************************************************************************
4 
5     Irem M27 hardware
6 
7     If you have any questions about how this driver works, don't hesitate to
8     ask.  - Mike Balfour (mab22@po.cwru.edu)
9 
10     To Do:
11     - Device-ify video and audio hardware to turn optional_devices into
12       required_devices.
13 
14 ****************************************************************************/
15 
16 #ifndef MAME_INCLUDES_REDALERT_H
17 #define MAME_INCLUDES_REDALERT_H
18 
19 #pragma once
20 
21 #include "cpu/i8085/i8085.h"
22 #include "machine/6821pia.h"
23 #include "machine/gen_latch.h"
24 #include "sound/ay8910.h"
25 #include "sound/hc55516.h"
26 #include "screen.h"
27 
28 class redalert_state : public driver_device
29 {
30 public:
redalert_state(const machine_config & mconfig,device_type type,const char * tag)31 	redalert_state(const machine_config &mconfig, device_type type, const char *tag) :
32 		driver_device(mconfig, type, tag),
33 		m_bitmap_videoram(*this, "bitmap_videoram"),
34 		m_charmap_videoram(*this, "charram"),
35 		m_video_control(*this, "video_control"),
36 		m_bitmap_color(*this, "bitmap_color"),
37 		m_maincpu(*this, "maincpu"),
38 		m_audiocpu(*this, "audiocpu"),
39 		m_voicecpu(*this, "voice"),
40 		m_ay8910(*this, "aysnd"),
41 		m_ay(*this, "ay%u", 1U),
42 		m_cvsd(*this, "cvsd"),
43 		m_sndpia(*this, "sndpia"),
44 		m_screen(*this, "screen"),
45 		m_soundlatch(*this, "soundlatch"),
46 		m_soundlatch2(*this, "soundlatch2")
47 	{
48 	}
49 
50 	void redalert_video_common(machine_config &config);
51 	void redalert_video(machine_config &config);
52 	void ww3_video(machine_config &config);
53 	void panther_video(machine_config &config);
54 	void demoneye_video(machine_config &config);
55 	void redalert_audio_m37b(machine_config &config);
56 	void redalert_audio_voice(machine_config &config);
57 	void redalert_audio(machine_config &config);
58 	void ww3_audio(machine_config &config);
59 	void panther_audio(machine_config &config);
60 	void demoneye_audio(machine_config &config);
61 	void demoneye(machine_config &config);
62 	void ww3(machine_config &config);
63 	void panther(machine_config &config);
64 	void redalert(machine_config &config);
65 
66 	DECLARE_INPUT_CHANGED_MEMBER(coin_inserted);
67 	DECLARE_CUSTOM_INPUT_MEMBER(sound_status_r);
68 
69 private:
70 	required_shared_ptr<uint8_t> m_bitmap_videoram;
71 	required_shared_ptr<uint8_t> m_charmap_videoram;
72 	required_shared_ptr<uint8_t> m_video_control;
73 	required_shared_ptr<uint8_t> m_bitmap_color;
74 
75 	required_device<cpu_device> m_maincpu;
76 	required_device<cpu_device> m_audiocpu;
77 	optional_device<i8085a_cpu_device> m_voicecpu;
78 	optional_device<ay8910_device> m_ay8910;
79 	optional_device_array<ay8910_device, 2> m_ay;
80 	optional_device<hc55516_device> m_cvsd;
81 	optional_device<pia6821_device> m_sndpia;
82 	required_device<screen_device> m_screen;
83 	required_device<generic_latch_8_device> m_soundlatch;
84 	optional_device<generic_latch_8_device> m_soundlatch2;
85 
86 	std::unique_ptr<uint8_t[]> m_bitmap_colorram;
87 	uint8_t m_control_xor;
88 	uint8_t redalert_interrupt_clear_r();
89 	void redalert_interrupt_clear_w(uint8_t data);
90 	uint8_t panther_interrupt_clear_r();
91 	void redalert_bitmap_videoram_w(offs_t offset, uint8_t data);
92 	void redalert_audio_command_w(uint8_t data);
93 	uint8_t redalert_ay8910_latch_1_r();
94 	void redalert_ay8910_latch_2_w(uint8_t data);
95 	void redalert_voice_command_w(uint8_t data);
96 	void demoneye_audio_command_w(uint8_t data);
97 	DECLARE_VIDEO_START(redalert);
98 	DECLARE_VIDEO_START(ww3);
99 	DECLARE_VIDEO_START(demoneye);
100 	uint32_t screen_update_redalert(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
101 	uint32_t screen_update_demoneye(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
102 	uint32_t screen_update_panther(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
103 	INTERRUPT_GEN_MEMBER(redalert_vblank_interrupt);
104 	TIMER_CALLBACK_MEMBER(audio_irq_on);
105 	TIMER_CALLBACK_MEMBER(audio_irq_off);
106 	void redalert_analog_w(uint8_t data);
107 	void redalert_AY8910_w(uint8_t data);
108 	DECLARE_WRITE_LINE_MEMBER(sod_callback);
109 	DECLARE_READ_LINE_MEMBER(sid_callback);
110 	void demoneye_ay8910_latch_1_w(uint8_t data);
111 	uint8_t demoneye_ay8910_latch_2_r();
112 	void demoneye_ay8910_data_w(uint8_t data);
113 	void get_redalert_pens(pen_t *pens);
114 	void get_panther_pens(pen_t *pens);
115 	void get_demoneye_pens(pen_t *pens);
116 	void demoneye_bitmap_layer_w(offs_t offset, uint8_t data);
117 	void demoneye_bitmap_ypos_w(u8 data);
118 
119 	virtual void sound_start() override;
120 
121 	void redalert_main_map(address_map &map);
122 	void ww3_main_map(address_map &map);
123 	void panther_main_map(address_map &map);
124 	void demoneye_main_map(address_map &map);
125 
126 	void redalert_audio_map(address_map &map);
127 	void panther_audio_map(address_map &map);
128 	void demoneye_audio_map(address_map &map);
129 
130 	void redalert_voice_map(address_map &map);
131 
132 	emu_timer *m_audio_irq_on_timer;
133 	emu_timer *m_audio_irq_off_timer;
134 
135 	uint8_t m_ay8910_latch_1;
136 	uint8_t m_ay8910_latch_2;
137 	u8 m_demoneye_bitmap_reg[4];
138 	u8 m_demoneye_bitmap_yoffs;
139 	u8 m_sound_hs;
140 };
141 
142 #endif // MAME_INCLUDES_REDALERT_H
143