1 // license:LGPL-2.1+ 2 // copyright-holders:Olivier Galibert, Angelo Salese, David Haywood, Tomasz Slanina 3 #ifndef MAME_INCLUDES_RAIDEN2_H 4 #define MAME_INCLUDES_RAIDEN2_H 5 6 #pragma once 7 8 #include "audio/seibu.h" 9 #include "machine/seibucop.h" 10 #include "video/bufsprite.h" 11 #include "video/seibu_crtc.h" 12 #include "emupal.h" 13 #include "screen.h" 14 #include "tilemap.h" 15 16 #include <algorithm> 17 18 class raiden2_state : public driver_device 19 { 20 public: raiden2_state(const machine_config & mconfig,device_type type,const char * tag)21 raiden2_state(const machine_config &mconfig, device_type type, const char *tag) 22 : driver_device(mconfig, type, tag) 23 , m_spriteram(*this, "spriteram") 24 , m_maincpu(*this, "maincpu") 25 , m_seibu_sound(*this, "seibu_sound") 26 , m_gfxdecode(*this, "gfxdecode") 27 , m_palette(*this, "palette") 28 , m_screen(*this, "screen") 29 , m_mainbank(*this, "mainbank%u", 1U) 30 , m_raiden2cop(*this, "raiden2cop") 31 32 , m_sprite_prot_x(0) 33 , m_sprite_prot_y(0) 34 , m_dst1(0) 35 , m_cop_spr_maxx(0) 36 , m_cop_spr_off(0) 37 38 , m_bg_bank(0) 39 , m_fg_bank(0) 40 , m_mid_bank(0) 41 , m_tx_bank(0) 42 , m_tilemap_enable(0) 43 44 , m_prg_bank(0) 45 , m_cop_bank(0) 46 { 47 std::fill(std::begin(m_sprite_prot_src_addr), std::end(m_sprite_prot_src_addr), 0); 48 std::fill(std::begin(m_scrollvals), std::end(m_scrollvals), 0); 49 } 50 51 void raidendx(machine_config &config); 52 void xsedae(machine_config &config); 53 void zeroteam(machine_config &config); 54 void raiden2(machine_config &config); 55 56 void init_raidendx(); 57 void init_xsedae(); 58 void init_zeroteam(); 59 void init_raiden2(); 60 61 protected: 62 std::unique_ptr<u16[]> m_back_data; 63 std::unique_ptr<u16[]> m_fore_data; 64 std::unique_ptr<u16[]> m_mid_data; 65 std::unique_ptr<u16[]> m_text_data; // private buffers, allocated in init 66 std::unique_ptr<u16[]> m_palette_data; 67 required_device<buffered_spriteram16_device> m_spriteram; 68 required_device<cpu_device> m_maincpu; 69 optional_device<seibu_sound_device> m_seibu_sound; 70 required_device<gfxdecode_device> m_gfxdecode; 71 required_device<palette_device> m_palette; 72 required_device<screen_device> m_screen; 73 optional_memory_bank_array<2> m_mainbank; 74 optional_device<raiden2cop_device> m_raiden2cop; 75 76 void sprite_prot_x_w(u16 data); 77 void sprite_prot_y_w(u16 data); 78 void sprite_prot_src_seg_w(u16 data); 79 void sprite_prot_src_w(address_space &space, u16 data); 80 u16 sprite_prot_src_seg_r(); 81 u16 sprite_prot_dst1_r(); 82 u16 sprite_prot_maxx_r(); 83 u16 sprite_prot_off_r(); 84 void sprite_prot_dst1_w(u16 data); 85 void sprite_prot_maxx_w(u16 data); 86 void sprite_prot_off_w(u16 data); 87 88 u16 m_sprite_prot_x,m_sprite_prot_y,m_dst1,m_cop_spr_maxx,m_cop_spr_off; 89 u16 m_sprite_prot_src_addr[2]; 90 91 INTERRUPT_GEN_MEMBER(interrupt); 92 void common_save_state(); 93 virtual void video_start() override; 94 95 void tilemap_enable_w(offs_t offset, u16 data, u16 mem_mask = ~0); 96 void tile_scroll_w(offs_t offset, u16 data, u16 mem_mask = ~0); 97 void background_w(offs_t offset, u16 data, u16 mem_mask = ~0); 98 void foreground_w(offs_t offset, u16 data, u16 mem_mask = ~0); 99 void midground_w(offs_t offset, u16 data, u16 mem_mask = ~0); 100 void text_w(offs_t offset, u16 data, u16 mem_mask = ~0); 101 void m_videoram_private_w(offs_t offset, uint16_t data); 102 103 void bank_reset(int bgbank, int fgbank, int midbank, int txbank); 104 105 static u16 const raiden_blended_colors[]; 106 static u16 const xsedae_blended_colors[]; 107 static u16 const zeroteam_blended_colors[]; 108 109 bool m_blend_active[0x800]; // cfg 110 111 tilemap_t *m_background_layer,*m_midground_layer,*m_foreground_layer,*m_text_layer; 112 113 int m_bg_bank, m_fg_bank, m_mid_bank, m_tx_bank; 114 u16 m_tilemap_enable; 115 116 u16 m_scrollvals[6]; 117 118 void draw_sprites(const rectangle &cliprect); 119 120 const int *m_cur_spri; // cfg 121 122 DECLARE_GFXDECODE_MEMBER(gfx_raiden2); 123 TILE_GET_INFO_MEMBER(get_back_tile_info); 124 TILE_GET_INFO_MEMBER(get_mid_tile_info); 125 TILE_GET_INFO_MEMBER(get_fore_tile_info); 126 TILE_GET_INFO_MEMBER(get_text_tile_info); 127 u32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); 128 129 void blend_layer(bitmap_rgb32 &bitmap, const rectangle &cliprect, bitmap_ind16 &source, int layer); 130 void tilemap_draw_and_blend(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, tilemap_t *tilemap); 131 132 void init_blending(const u16 *table); 133 134 bitmap_ind16 m_tile_bitmap, m_sprite_bitmap; 135 136 void zeroteam_sound_map(address_map &map); 137 138 private: 139 void raiden2_bank_w(u8 data); 140 void tile_bank_01_w(u8 data); 141 u16 cop_tile_bank_2_r(); 142 void cop_tile_bank_2_w(offs_t offset, u16 data, u16 mem_mask = ~0); 143 void raidendx_cop_bank_2_w(offs_t offset, u16 data, u16 mem_mask = ~0); 144 145 uint8_t m_prg_bank; 146 u16 m_cop_bank; 147 148 void sprcpt_val_1_w(offs_t offset, u16 data, u16 mem_mask = ~0); 149 void sprcpt_val_2_w(offs_t offset, u16 data, u16 mem_mask = ~0); 150 void sprcpt_data_1_w(offs_t offset, u16 data, u16 mem_mask = ~0); 151 void sprcpt_data_2_w(offs_t offset, u16 data, u16 mem_mask = ~0); 152 void sprcpt_data_3_w(offs_t offset, u16 data, u16 mem_mask = ~0); 153 void sprcpt_data_4_w(offs_t offset, u16 data, u16 mem_mask = ~0); 154 void sprcpt_adr_w(offs_t offset, u16 data, u16 mem_mask = ~0); 155 void sprcpt_flags_1_w(offs_t offset, u16 data, u16 mem_mask = ~0); 156 void sprcpt_flags_2_w(offs_t offset, u16 data, u16 mem_mask = ~0); 157 158 u32 m_sprcpt_adr, m_sprcpt_idx; 159 160 u32 m_sprcpt_val[2], m_sprcpt_flags1; 161 u16 m_sprcpt_flags2; 162 u32 m_sprcpt_data_1[0x100], m_sprcpt_data_2[0x40], m_sprcpt_data_3[6], m_sprcpt_data_4[4]; 163 164 virtual void machine_start() override; 165 DECLARE_MACHINE_RESET(raiden2); 166 DECLARE_MACHINE_RESET(zeroteam); 167 DECLARE_MACHINE_RESET(xsedae); 168 DECLARE_MACHINE_RESET(raidendx); 169 170 void combine32(u32 *val, offs_t offset, u16 data, u16 mem_mask); 171 void sprcpt_init(); 172 void raiden2_cop_mem(address_map &map); 173 void raiden2_mem(address_map &map); 174 void raiden2_sound_map(address_map &map); 175 void raidendx_mem(address_map &map); 176 void xsedae_mem(address_map &map); 177 void zeroteam_mem(address_map &map); 178 }; 179 180 #endif // MAME_INCLUDES_RAIDEN2_H 181