1 // license:BSD-3-Clause 2 // copyright-holders:Bryan McPhail, Angelo Salese 3 #ifndef MAME_INCLUDES_TATSUMI_H 4 #define MAME_INCLUDES_TATSUMI_H 5 6 #pragma once 7 8 #include "sound/okim6295.h" 9 #include "sound/ym2151.h" 10 #include "cpu/m68000/m68000.h" 11 #include "machine/cxd1095.h" 12 #include "machine/gen_latch.h" 13 #include "emupal.h" 14 #include "tilemap.h" 15 16 class tatsumi_state : public driver_device 17 { 18 public: tatsumi_state(const machine_config & mconfig,device_type type,const char * tag)19 tatsumi_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_subcpu(*this, "sub") 24 , m_ym2151(*this, "ymsnd") 25 , m_oki(*this, "oki") 26 , m_gfxdecode(*this, "gfxdecode") 27 , m_palette(*this, "palette") 28 , m_videoram(*this, "videoram") 29 , m_sharedram(*this, "sharedram") 30 , m_sprite_control_ram(*this, "obj_ctrl_ram") 31 , m_spriteram(*this, "spriteram") 32 , m_mainregion(*this, "master_rom") 33 , m_subregion(*this, "slave_rom") 34 { } 35 36 void hd6445_crt_w(offs_t offset, uint8_t data); 37 INTERRUPT_GEN_MEMBER(v30_interrupt); 38 TILE_GET_INFO_MEMBER(get_text_tile_info); 39 40 protected: 41 required_device<cpu_device> m_maincpu; 42 required_device<cpu_device> m_audiocpu; 43 required_device<m68000_base_device> m_subcpu; 44 optional_device<ym2151_device> m_ym2151; 45 required_device<okim6295_device> m_oki; 46 required_device<gfxdecode_device> m_gfxdecode; 47 required_device<palette_device> m_palette; 48 49 optional_shared_ptr<uint16_t> m_videoram; 50 optional_shared_ptr<uint16_t> m_sharedram; 51 required_shared_ptr<uint16_t> m_sprite_control_ram; 52 required_shared_ptr<uint16_t> m_spriteram; 53 required_memory_region m_mainregion; 54 required_memory_region m_subregion; 55 56 uint8_t *m_rom_sprite_lookup[2]; 57 uint8_t *m_rom_clut[2]; 58 uint16_t m_control_word; 59 uint8_t m_last_control; 60 tilemap_t *m_tx_layer; 61 bitmap_rgb32 m_temp_bitmap; 62 std::unique_ptr<uint8_t[]> m_shadow_pen_array; 63 void text_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 64 uint16_t tatsumi_v30_68000_r(offs_t offset); 65 void tatsumi_v30_68000_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 66 uint16_t tatsumi_sprite_control_r(offs_t offset); 67 void tatsumi_sprite_control_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 68 69 uint8_t tatsumi_hack_ym2151_r(); 70 71 void tatsumi_reset(); 72 template<class BitmapClass> void draw_sprites(BitmapClass &bitmap, const rectangle &cliprect, int write_priority_only, int rambank); 73 template<class BitmapClass> inline void roundupt_drawgfxzoomrotate( BitmapClass &dest_bmp, const rectangle &clip, 74 gfx_element *gfx, uint32_t code,uint32_t color,int flipx,int flipy,uint32_t ssx,uint32_t ssy, 75 int scalex, int scaley, int rotate, int write_priority_only ); 76 void update_cluts(int fake_palette_offset, int object_base, int length); 77 78 uint8_t m_hd6445_reg[64]; 79 void apply_shadow_bitmap(bitmap_rgb32 &bitmap, const rectangle &cliprect, bitmap_ind8 &shadow_bitmap, uint8_t xor_output); 80 81 uint8_t m_hd6445_address; 82 }; 83 84 class apache3_state : public tatsumi_state 85 { 86 public: apache3_state(const machine_config & mconfig,device_type type,const char * tag)87 apache3_state(const machine_config &mconfig, device_type type, const char *tag) 88 : tatsumi_state(mconfig, type, tag) 89 , m_subcpu2(*this, "sub2") 90 , m_apache3_g_ram(*this, "apache3_g_ram") 91 , m_apache3_z80_ram(*this, "apache3_z80_ram") 92 , m_apache3_prom(*this, "proms") 93 , m_vr1(*this, "VR1") 94 { 95 } 96 97 void apache3(machine_config &config); 98 99 void init_apache3(); 100 101 private: 102 uint16_t apache3_bank_r(); 103 void apache3_bank_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 104 void apache3_z80_ctrl_w(uint16_t data); 105 uint16_t apache3_v30_v20_r(offs_t offset); 106 void apache3_v30_v20_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 107 uint16_t apache3_z80_r(offs_t offset); 108 void apache3_z80_w(offs_t offset, uint16_t data); 109 uint8_t apache3_vr1_r(); 110 void apache3_rotate_w(uint16_t data); 111 void apache3_road_z_w(uint16_t data); 112 void apache3_road_x_w(offs_t offset, uint8_t data); 113 114 DECLARE_MACHINE_RESET(apache3); 115 DECLARE_VIDEO_START(apache3); 116 uint32_t screen_update_apache3(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); 117 DECLARE_WRITE_LINE_MEMBER(apache3_68000_reset); 118 119 void apache3_68000_map(address_map &map); 120 void apache3_v20_map(address_map &map); 121 void apache3_v30_map(address_map &map); 122 void apache3_z80_map(address_map &map); 123 124 void draw_sky(bitmap_rgb32 &bitmap, const rectangle &cliprect, int palette_base, int start_offset); 125 void draw_ground(bitmap_rgb32 &dst, const rectangle &cliprect); 126 127 required_device<cpu_device> m_subcpu2; 128 129 required_shared_ptr<uint16_t> m_apache3_g_ram; 130 required_shared_ptr<uint8_t> m_apache3_z80_ram; 131 required_region_ptr<uint8_t> m_apache3_prom; 132 133 required_ioport m_vr1; 134 135 uint16_t m_apache3_rotate_ctrl[12]; 136 int m_apache3_rot_idx; 137 std::unique_ptr<uint8_t[]> m_apache3_road_x_ram; 138 uint8_t m_apache3_road_z; 139 }; 140 141 class roundup5_state : public tatsumi_state 142 { 143 public: roundup5_state(const machine_config & mconfig,device_type type,const char * tag)144 roundup5_state(const machine_config &mconfig, device_type type, const char *tag) 145 : tatsumi_state(mconfig, type, tag) 146 , m_vregs(*this, "vregs") 147 , m_bg_scrollx(*this, "bg_scrollx") 148 , m_bg_scrolly(*this, "bg_scrolly") 149 , m_road_ctrl_ram(*this, "road_ctrl_ram") 150 , m_road_pixel_ram(*this, "road_pixel_ram") 151 , m_road_color_ram(*this, "road_color_ram") 152 , m_road_yclip(*this, "road_yclip") 153 , m_road_vregs(*this, "road_vregs") 154 { 155 } 156 157 void roundup5(machine_config &config); 158 159 void init_roundup5(); 160 161 private: 162 uint16_t roundup_v30_z80_r(offs_t offset); 163 void roundup_v30_z80_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 164 void roundup5_control_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 165 void road_vregs_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 166 uint8_t gfxdata_r(offs_t offset); 167 void gfxdata_w(offs_t offset, uint8_t data); 168 void output_w(uint8_t data); 169 170 DECLARE_VIDEO_START(roundup5); 171 uint32_t screen_update_roundup5(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); 172 173 void roundup5_68000_map(address_map &map); 174 void roundup5_v30_map(address_map &map); 175 void roundup5_z80_map(address_map &map); 176 177 // virtual void machine_reset() override; 178 179 void draw_road(bitmap_rgb32 &bitmap, const rectangle &cliprect); 180 void draw_landscape(bitmap_rgb32 &bitmap, const rectangle &cliprect, uint8_t type); 181 182 required_shared_ptr<uint16_t> m_vregs; 183 required_shared_ptr<uint16_t> m_bg_scrollx; 184 required_shared_ptr<uint16_t> m_bg_scrolly; 185 required_shared_ptr<uint16_t> m_road_ctrl_ram; 186 required_shared_ptr<uint16_t> m_road_pixel_ram; 187 required_shared_ptr<uint16_t> m_road_color_ram; 188 required_shared_ptr<uint16_t> m_road_yclip; 189 required_shared_ptr<uint16_t> m_road_vregs; 190 191 std::unique_ptr<uint8_t[]> m_tx_gfxram; 192 std::unique_ptr<uint8_t[]> m_bg_gfxram; 193 }; 194 195 class cyclwarr_state : public tatsumi_state 196 { 197 public: cyclwarr_state(const machine_config & mconfig,device_type type,const char * tag)198 cyclwarr_state(const machine_config &mconfig, device_type type, const char *tag) 199 : tatsumi_state(mconfig, type, tag) 200 , m_soundlatch(*this, "soundlatch") 201 , m_master_ram(*this, "master_ram") 202 , m_slave_ram(*this, "slave_ram") 203 , m_cyclwarr_videoram(*this, "cw_videoram%u", 0U) 204 , m_cyclwarr_tileclut(*this, "cw_tileclut") 205 { 206 } 207 208 void cyclwarr(machine_config &config); 209 void bigfight(machine_config &config); 210 211 void init_cyclwarr(); 212 213 protected: 214 virtual void machine_reset() override; 215 216 private: 217 uint16_t cyclwarr_sprite_r(offs_t offset); 218 void cyclwarr_sprite_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 219 void video_config_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 220 void bigfight_a40000_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 221 void mixing_control_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 222 void cyclwarr_control_w(uint8_t data); 223 void cyclwarr_sound_w(uint8_t data); 224 void output_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 225 uint8_t oki_status_xor_r(); 226 227 template<int Bank> uint16_t cyclwarr_videoram_r(offs_t offset); 228 template<int Bank> void cyclwarr_videoram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 229 230 template<int Bank> TILE_GET_INFO_MEMBER(get_tile_info_bigfight); 231 template<int Bank> TILE_GET_INFO_MEMBER(get_tile_info_cyclwarr_road); 232 DECLARE_VIDEO_START(cyclwarr); 233 DECLARE_VIDEO_START(bigfight); 234 uint32_t screen_update_cyclwarr(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); 235 236 void common_map(address_map &map); 237 void master_map(address_map &map); 238 void slave_map(address_map &map); 239 void sound_map(address_map &map); 240 241 required_device<generic_latch_8_device> m_soundlatch; 242 243 required_shared_ptr<uint16_t> m_master_ram; 244 required_shared_ptr<uint16_t> m_slave_ram; 245 required_shared_ptr_array<uint16_t, 2> m_cyclwarr_videoram; 246 required_region_ptr<uint8_t> m_cyclwarr_tileclut; 247 248 std::vector<uint8_t> m_mask; 249 tilemap_t *m_layer[4]; 250 251 uint16_t m_video_config[4]; 252 uint16_t m_mixing_control; 253 uint16_t m_bigfight_a40000[2]; 254 uint16_t m_bigfight_bank; 255 uint16_t m_bigfight_last_bank; 256 uint16_t m_road_color_bank, m_prev_road_bank; 257 uint16_t m_layer_page_size[4]; 258 bool m_layer1_can_be_road; 259 260 void tile_expand(); 261 void draw_bg(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, tilemap_t *src, const uint16_t* scrollx, const uint16_t* scrolly, const uint16_t layer_page_size, bool is_road, int hi_priority); 262 void draw_bg_layers(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int hi_priority); 263 void apply_highlight_bitmap(bitmap_rgb32 &bitmap, const rectangle &cliprect, bitmap_ind8 &highlight_bitmap); 264 }; 265 266 #endif // MAME_INCLUDES_TATSUMI_H 267