1 // license:BSD-3-Clause 2 // copyright-holders:Nicola Salmoria 3 /************************************************************************* 4 5 Irem M72 hardware 6 7 *************************************************************************/ 8 #ifndef MAME_INCLUDES_M72_H 9 #define MAME_INCLUDES_M72_H 10 11 #pragma once 12 13 #include "audio/m72.h" 14 #include "cpu/mcs51/mcs51.h" 15 #include "machine/mb8421.h" 16 #include "machine/pic8259.h" 17 #include "machine/upd4701.h" 18 #include "video/bufsprite.h" 19 #include "sound/dac.h" 20 #include "emupal.h" 21 #include "screen.h" 22 #include "tilemap.h" 23 24 #define M81_B_B_JUMPER_J3_S \ 25 PORT_START("JumperJ3") \ 26 PORT_CONFNAME( 0x0001, 0x0000, "M81-B-B Jumper J3" ) \ 27 PORT_CONFSETTING( 0x0000, "S" ) \ 28 /* PORT_CONFSETTING( 0x0001, "W" ) */ 29 30 #define M81_B_B_JUMPER_J3_W \ 31 PORT_START("JumperJ3") \ 32 PORT_CONFNAME( 0x0001, 0x0001, "M81-B-B Jumper J3" ) \ 33 /* PORT_CONFSETTING( 0x0000, "S" ) */ \ 34 PORT_CONFSETTING( 0x0001, "W" ) 35 36 class m72_state : public driver_device 37 { 38 public: m72_state(const machine_config & mconfig,device_type type,const char * tag)39 m72_state(const machine_config &mconfig, device_type type, const char *tag) : 40 driver_device(mconfig, type, tag), 41 m_maincpu(*this, "maincpu"), 42 m_soundcpu(*this, "soundcpu"), 43 m_mcu(*this, "mcu"), 44 m_dpram(*this, "dpram"), 45 m_dac(*this, "dac"), 46 m_audio(*this, "m72"), 47 m_gfxdecode(*this, "gfxdecode"), 48 m_screen(*this, "screen"), 49 m_palette(*this, "palette"), 50 m_spriteram(*this, "spriteram"), 51 m_videoram(*this, "videoram%u", 1U), 52 m_m82_rowscrollram(*this, "majtitle_rowscr"), 53 m_spriteram2(*this, "spriteram2"), 54 m_soundram(*this, "soundram"), 55 m_paletteram(*this, "paletteram%u", 1U), 56 m_upd71059c(*this, "upd71059c"), 57 m_upd4701(*this, {"upd4701l", "upd4701h"}), 58 m_samples_region(*this, "samples"), 59 m_io_dsw(*this, "DSW"), 60 m_fg_source(0), 61 m_bg_source(0), 62 m_m81_b_b_j3(*this, "JumperJ3"), 63 m_m82_rowscroll(0), 64 m_m82_tmcontrol(0) 65 { } 66 67 void m72_base(machine_config &config); 68 void m72_audio_chips(machine_config &config); 69 void m72_xmultipl(machine_config &config); 70 void m72_dbreed(machine_config &config); 71 void m72_dbreedw(machine_config &config); 72 void cosmccop(machine_config &config); 73 void poundfor(machine_config &config); 74 void m72(machine_config &config); 75 void m81_hharry(machine_config &config); 76 void m81_xmultipl(machine_config &config); 77 void kengo(machine_config &config); 78 void m81_dbreed(machine_config &config); 79 void m72_8751(machine_config &config); 80 void m72_airduel(machine_config &config); 81 void hharryu(machine_config &config); 82 void rtype2(machine_config &config); 83 void m82(machine_config &config); 84 void rtype(machine_config &config); 85 void imgfightb(machine_config &config); 86 void lohtb(machine_config &config); 87 void imgfight(machine_config &config); 88 void mrheli(machine_config &config); 89 void nspiritj(machine_config &config); 90 91 void init_dkgenm72(); 92 void init_bchopper(); 93 void init_gallop(); 94 void init_m72_8751(); 95 void init_dbreedm72(); 96 void init_airduelm72(); 97 void init_nspirit(); 98 99 private: 100 required_device<cpu_device> m_maincpu; 101 required_device<cpu_device> m_soundcpu; 102 optional_device<cpu_device> m_mcu; 103 optional_device<mb8421_mb8431_16_device> m_dpram; 104 optional_device<dac_byte_interface> m_dac; 105 optional_device<m72_audio_device> m_audio; 106 required_device<gfxdecode_device> m_gfxdecode; 107 required_device<screen_device> m_screen; 108 required_device<palette_device> m_palette; 109 required_device<buffered_spriteram16_device> m_spriteram; 110 111 required_shared_ptr_array<u16, 2> m_videoram; 112 optional_shared_ptr<u16> m_m82_rowscrollram; 113 optional_shared_ptr<u16> m_spriteram2; 114 optional_shared_ptr<u8> m_soundram; 115 required_shared_ptr_array<u16, 2> m_paletteram; 116 117 optional_device<pic8259_device> m_upd71059c; 118 optional_device_array<upd4701_device, 2> m_upd4701; 119 120 optional_region_ptr<u8> m_samples_region; 121 122 optional_ioport m_io_dsw; 123 124 std::unique_ptr<u16[]> m_protection_ram; 125 emu_timer *m_scanline_timer; 126 const u8 *m_protection_code; 127 const u8 *m_protection_crc; 128 u32 m_raster_irq_position; 129 tilemap_t *m_fg_tilemap; 130 tilemap_t *m_bg_tilemap; 131 tilemap_t *m_bg_tilemap_large; 132 s32 m_scrollx[2]; 133 s32 m_scrolly[2]; 134 s32 m_video_off; 135 136 int m_fg_source; 137 int m_bg_source; 138 optional_ioport m_m81_b_b_j3; 139 140 // majtitle specific 141 int m_m82_rowscroll; 142 u16 m_m82_tmcontrol; 143 144 // m72_i8751 specific 145 u8 m_mcu_sample_latch; 146 u32 m_mcu_sample_addr; 147 148 // common 149 template<unsigned N> u16 palette_r(offs_t offset); 150 template<unsigned N> void palette_w(offs_t offset, u16 data, u16 mem_mask); 151 void videoram1_w(offs_t offset, u16 data, u16 mem_mask); 152 void videoram2_w(offs_t offset, u16 data, u16 mem_mask); 153 void irq_line_w(u16 data); 154 template<unsigned N> void scrollx_w(offs_t offset, u16 data, u16 mem_mask); 155 template<unsigned N> void scrolly_w(offs_t offset, u16 data, u16 mem_mask); 156 void dmaon_w(u8 data); 157 void port02_w(u8 data); 158 u8 soundram_r(offs_t offset); 159 void soundram_w(offs_t offset, u8 data); 160 161 // m72_i8751 specific 162 void main_mcu_w(offs_t offset, u16 data, u16 mem_mask); 163 void mcu_data_w(offs_t offset, u8 data); 164 u8 mcu_data_r(offs_t offset); 165 u8 mcu_sample_r(); 166 void mcu_low_w(u8 data); 167 void mcu_high_w(u8 data); 168 169 u16 protection_r(offs_t offset, u16 mem_mask = ~0); 170 void protection_w(offs_t offset, u16 data, u16 mem_mask = ~0); 171 172 // game specific 173 void bchopper_sample_trigger_w(offs_t offset, u16 data, u16 mem_mask = ~0); 174 void nspirit_sample_trigger_w(offs_t offset, u16 data, u16 mem_mask = ~0); 175 void loht_sample_trigger_w(offs_t offset, u16 data, u16 mem_mask = ~0); 176 void dbreedm72_sample_trigger_w(offs_t offset, u16 data, u16 mem_mask = ~0); 177 void airduelm72_sample_trigger_w(offs_t offset, u16 data, u16 mem_mask = ~0); 178 void dkgenm72_sample_trigger_w(offs_t offset, u16 data, u16 mem_mask = ~0); 179 void gallop_sample_trigger_w(offs_t offset, u16 data, u16 mem_mask = ~0); 180 void rtype2_port02_w(u8 data); 181 void poundfor_port02_w(u8 data); 182 void m82_gfx_ctrl_w(offs_t offset, u16 data, u16 mem_mask); 183 void m82_tm_ctrl_w(offs_t offset, u16 data, u16 mem_mask); 184 185 TILE_GET_INFO_MEMBER(get_bg_tile_info); 186 TILE_GET_INFO_MEMBER(get_fg_tile_info); 187 188 template<unsigned N> TILE_GET_INFO_MEMBER(rtype2_get_tile_info); 189 190 TILEMAP_MAPPER_MEMBER(m82_scan_rows); 191 192 void machine_start() override; 193 void machine_reset() override; 194 DECLARE_VIDEO_START(m72); 195 DECLARE_VIDEO_START(imgfight); 196 DECLARE_VIDEO_START(mrheli); 197 DECLARE_VIDEO_START(nspiritj); 198 DECLARE_VIDEO_START(xmultipl); 199 DECLARE_VIDEO_START(hharry); 200 DECLARE_VIDEO_START(rtype2); 201 DECLARE_VIDEO_START(m82); 202 DECLARE_VIDEO_START(hharryu); 203 DECLARE_VIDEO_START(poundfor); 204 DECLARE_MACHINE_START(kengo); 205 DECLARE_MACHINE_RESET(kengo); 206 207 INTERRUPT_GEN_MEMBER(fake_nmi); 208 TIMER_CALLBACK_MEMBER(synch_callback); 209 TIMER_CALLBACK_MEMBER(scanline_interrupt); 210 TIMER_CALLBACK_MEMBER(kengo_scanline_interrupt); 211 TIMER_CALLBACK_MEMBER(delayed_ram16_w); 212 TIMER_CALLBACK_MEMBER(delayed_ram8_w); 213 214 u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 215 u32 screen_update_m81(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 216 u32 screen_update_m82(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 217 inline void m72_m81_get_tile_info(tile_data &tileinfo,int tile_index,const u16 *vram,int gfxnum); 218 void register_savestate(); 219 inline void changecolor(offs_t color, u8 r, u8 g, u8 b); 220 void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect); 221 void majtitle_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect); 222 void copy_le(u16 *dest, const u8 *src, u8 bytes); 223 void install_protection_handler(const u8 *code,const u8 *crc); 224 225 void dbreed_map(address_map &map); 226 void dbreedm72_map(address_map &map); 227 void dbreedwm72_map(address_map &map); 228 void hharry_map(address_map &map); 229 void hharryu_map(address_map &map); 230 void kengo_map(address_map &map); 231 void lohtb_map(address_map &map); 232 void lohtb_portmap(address_map &map); 233 void m72_cpu1_common_map(address_map &map); 234 void m72_map(address_map &map); 235 void m72_protected_map(address_map &map); 236 void m72_portmap(address_map &map); 237 void m72_protected_portmap(address_map &map); 238 void m72_airduel_portmap(address_map &map); 239 void m81_cpu1_common_map(address_map &map); 240 void m81_portmap(address_map &map); 241 void m82_map(address_map &map); 242 void m82_portmap(address_map &map); 243 void m84_cpu1_common_map(address_map &map); 244 void m84_portmap(address_map &map); 245 void m84_v33_portmap(address_map &map); 246 void i80c31_mem_map(address_map &map); 247 void mcu_io_map(address_map &map); 248 void poundfor_portmap(address_map &map); 249 void poundfor_sound_portmap(address_map &map); 250 void rtype2_map(address_map &map); 251 void rtype2_sound_portmap(address_map &map); 252 void rtype_map(address_map &map); 253 void rtype_sound_portmap(address_map &map); 254 void sound_portmap(address_map &map); 255 void sound_protected_portmap(address_map &map); 256 void sound_ram_map(address_map &map); 257 void sound_rom_map(address_map &map); 258 void xmultipl_map(address_map &map); 259 void xmultiplm72_map(address_map &map); 260 }; 261 262 #endif // MAME_INCLUDES_M72_H 263