1 // license:BSD-3-Clause 2 // copyright-holders:Bryan McPhail 3 #ifndef MAME_INCLUDES_TAITO_F3_H 4 #define MAME_INCLUDES_TAITO_F3_H 5 6 #pragma once 7 8 #include "audio/taito_en.h" 9 #include "machine/eepromser.h" 10 #include "machine/watchdog.h" 11 #include "sound/okim6295.h" 12 #include "emupal.h" 13 #include "screen.h" 14 #include "tilemap.h" 15 16 struct F3config; 17 18 /* This it the best way to allow game specific kludges until the system is fully understood */ 19 enum { 20 /* Early F3 class games, these are not cartridge games and system features may be different */ 21 RINGRAGE=0, /* D21 */ 22 ARABIANM, /* D29 */ 23 RIDINGF, /* D34 */ 24 GSEEKER, /* D40 */ 25 TRSTAR, /* D53 */ 26 GUNLOCK, /* D66 */ 27 TWINQIX, 28 UNDRFIRE, /* D67 - Heavily modified F3 hardware (different memory map) */ 29 SCFINALS, 30 LIGHTBR, /* D69 */ 31 32 /* D77 - F3 motherboard proms, all following games are 'F3 package system' */ 33 /* D78 I CUP */ 34 KAISERKN, /* D84 */ 35 DARIUSG, /* D87 */ 36 BUBSYMPH, /* D90 */ 37 SPCINVDX, /* D93 */ 38 HTHERO95, /* D94 */ 39 QTHEATER, /* D95 */ 40 EACTION2, /* E02 */ 41 SPCINV95, /* E06 */ 42 QUIZHUHU, /* E08 */ 43 PBOBBLE2, /* E10 */ 44 GEKIRIDO, /* E11 */ 45 KTIGER2, /* E15 */ 46 BUBBLEM, /* E21 */ 47 CLEOPATR, /* E28 */ 48 PBOBBLE3, /* E29 */ 49 ARKRETRN, /* E36 */ 50 KIRAMEKI, /* E44 */ 51 PUCHICAR, /* E46 */ 52 PBOBBLE4, /* E49 */ 53 POPNPOP, /* E51 */ 54 LANDMAKR, /* E61 */ 55 RECALH, /* prototype */ 56 COMMANDW, /* prototype */ 57 TMDRILL 58 }; 59 60 class taito_f3_state : public driver_device 61 { 62 public: taito_f3_state(const machine_config & mconfig,device_type type,const char * tag)63 taito_f3_state(const machine_config &mconfig, device_type type, const char *tag) 64 : driver_device(mconfig, type, tag), 65 m_maincpu(*this, "maincpu"), 66 m_watchdog(*this, "watchdog"), 67 m_gfxdecode(*this, "gfxdecode"), 68 m_screen(*this, "screen"), 69 m_palette(*this, "palette"), 70 m_eeprom(*this, "eeprom"), 71 m_textram(*this, "textram", 0), 72 m_spriteram(*this, "spriteram", 0), 73 m_charram(*this, "charram", 0), 74 m_line_ram(*this, "line_ram", 0), 75 m_pf_ram(*this, "pf_ram", 0), 76 m_pivot_ram(*this, "pivot_ram", 0), 77 m_input(*this, "IN.%u", 0), 78 m_dial(*this, "DIAL.%u", 0), 79 m_eepromin(*this, "EEPROMIN"), 80 m_eepromout(*this, "EEPROMOUT"), 81 m_taito_en(*this, "taito_en"), 82 m_oki(*this, "oki"), 83 m_paletteram32(*this, "paletteram"), 84 m_okibank(*this, "okibank") 85 { } 86 87 void f3_eeprom(machine_config &config); 88 void f3(machine_config &config); 89 void f3_224a(machine_config &config); 90 void bubsympb(machine_config &config); 91 void f3_224b(machine_config &config); 92 void f3_224c(machine_config &config); 93 void f3_224b_eeprom(machine_config &config); 94 95 void init_commandw(); 96 void init_pbobble2(); 97 void init_puchicar(); 98 void init_intcup94(); 99 void init_landmakr(); 100 void init_twinqix(); 101 void init_elvactr(); 102 void init_arabianm(); 103 void init_bubsympb(); 104 void init_ktiger2(); 105 void init_lightbr(); 106 void init_gekirido(); 107 void init_arkretrn(); 108 void init_kirameki(); 109 void init_qtheater(); 110 void init_popnpop(); 111 void init_spcinvdj(); 112 void init_pbobbl2p(); 113 void init_landmkrp(); 114 void init_bubblem(); 115 void init_ridingf(); 116 void init_gseeker(); 117 void init_bubsymph(); 118 void init_hthero95(); 119 void init_gunlock(); 120 void init_pbobble4(); 121 void init_dariusg(); 122 void init_recalh(); 123 void init_kaiserkn(); 124 void init_spcinv95(); 125 void init_trstaroj(); 126 void init_ringrage(); 127 void init_cupfinal(); 128 void init_quizhuhu(); 129 void init_pbobble3(); 130 void init_cleopatr(); 131 void init_scfinals(); 132 void init_pbobbl2x(); 133 134 template <int Num> DECLARE_CUSTOM_INPUT_MEMBER(f3_analog_r); 135 template <int Num> DECLARE_CUSTOM_INPUT_MEMBER(f3_coin_r); 136 DECLARE_CUSTOM_INPUT_MEMBER(eeprom_read); 137 138 protected: 139 enum 140 { 141 TIMER_F3_INTERRUPT3 142 }; 143 144 virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; 145 virtual void device_post_load(void) override; 146 147 virtual void machine_start() override; 148 virtual void machine_reset() override; 149 virtual void video_start() override; 150 151 required_device<cpu_device> m_maincpu; 152 optional_device<watchdog_timer_device> m_watchdog; 153 required_device<gfxdecode_device> m_gfxdecode; 154 required_device<screen_device> m_screen; 155 required_device<palette_device> m_palette; 156 optional_device<eeprom_serial_base_device> m_eeprom; 157 158 required_shared_ptr<u16> m_textram; 159 required_shared_ptr<u16> m_spriteram; 160 required_shared_ptr<u16> m_charram; 161 required_shared_ptr<u16> m_line_ram; 162 required_shared_ptr<u16> m_pf_ram; 163 required_shared_ptr<u16> m_pivot_ram; 164 165 optional_ioport_array<6> m_input; 166 optional_ioport_array<2> m_dial; 167 optional_ioport m_eepromin; 168 optional_ioport m_eepromout; 169 170 emu_timer *m_interrupt3_timer; 171 u32 m_coin_word[2]; 172 173 struct tempsprite 174 { 175 int code, color; 176 int flipx, flipy; 177 int x, y; 178 int zoomx, zoomy; 179 int pri; 180 }; 181 182 struct f3_playfield_line_inf 183 { 184 int alpha_mode[256]; 185 int pri[256]; 186 187 /* use for draw_scanlines */ 188 u16 *src[256], *src_s[256], *src_e[256]; 189 u8 *tsrc[256], *tsrc_s[256]; 190 int x_count[256]; 191 u32 x_zoom[256]; 192 u32 clip0[256]; 193 u32 clip1[256]; 194 }; 195 196 struct f3_spritealpha_line_inf 197 { 198 u16 alpha_level[256]; 199 u16 spri[256]; 200 u16 sprite_alpha[256]; 201 u32 sprite_clip0[256]; 202 u32 sprite_clip1[256]; 203 s16 clip0_l[256]; 204 s16 clip0_r[256]; 205 s16 clip1_l[256]; 206 s16 clip1_r[256]; 207 }; 208 209 int m_game; 210 tilemap_t *m_tilemap[8]; 211 tilemap_t *m_pixel_layer; 212 tilemap_t *m_vram_layer; 213 std::unique_ptr<u16[]> m_spriteram16_buffered; 214 u16 m_control_0[8]; 215 u16 m_control_1[8]; 216 int m_flipscreen; 217 u8 m_sprite_extra_planes; 218 u8 m_sprite_pen_mask; 219 u16 *m_pf_data[8]; 220 int m_sprite_lag; 221 u8 m_sprite_pri_usage; 222 bitmap_ind8 m_pri_alp_bitmap; 223 int m_alpha_level_2as; 224 int m_alpha_level_2ad; 225 int m_alpha_level_3as; 226 int m_alpha_level_3ad; 227 int m_alpha_level_2bs; 228 int m_alpha_level_2bd; 229 int m_alpha_level_3bs; 230 int m_alpha_level_3bd; 231 int m_alpha_level_last; 232 int m_width_mask; 233 int m_twidth_mask; 234 int m_twidth_mask_bit; 235 std::unique_ptr<u8[]> m_tile_opaque_sp; 236 std::unique_ptr<u8[]> m_tile_opaque_pf[8]; 237 u8 m_add_sat[256][256]; 238 int m_alpha_s_1_1; 239 int m_alpha_s_1_2; 240 int m_alpha_s_1_4; 241 int m_alpha_s_1_5; 242 int m_alpha_s_1_6; 243 int m_alpha_s_1_8; 244 int m_alpha_s_1_9; 245 int m_alpha_s_1_a; 246 int m_alpha_s_2a_0; 247 int m_alpha_s_2a_4; 248 int m_alpha_s_2a_8; 249 int m_alpha_s_2b_0; 250 int m_alpha_s_2b_4; 251 int m_alpha_s_2b_8; 252 int m_alpha_s_3a_0; 253 int m_alpha_s_3a_1; 254 int m_alpha_s_3a_2; 255 int m_alpha_s_3b_0; 256 int m_alpha_s_3b_1; 257 int m_alpha_s_3b_2; 258 u32 m_dval; 259 u8 m_pval; 260 u8 m_tval; 261 u8 m_pdest_2a; 262 u8 m_pdest_2b; 263 int m_tr_2a; 264 int m_tr_2b; 265 u8 m_pdest_3a; 266 u8 m_pdest_3b; 267 int m_tr_3a; 268 int m_tr_3b; 269 u16 *m_src[5]; 270 u16 *m_src_s[5]; 271 u16 *m_src_e[5]; 272 u16 m_clip_al[5]; 273 u16 m_clip_ar[5]; 274 u16 m_clip_bl[5]; 275 u16 m_clip_br[5]; 276 u8 *m_tsrc[5]; 277 u8 *m_tsrc_s[5]; 278 u32 m_x_count[5]; 279 u32 m_x_zoom[5]; 280 std::unique_ptr<tempsprite[]> m_spritelist; 281 const tempsprite *m_sprite_end; 282 std::unique_ptr<f3_playfield_line_inf[]> m_pf_line_inf; 283 std::unique_ptr<f3_spritealpha_line_inf[]> m_sa_line_inf; 284 const F3config *m_game_config; 285 int (taito_f3_state::*m_dpix_n[8][16])(u32 s_pix); 286 int (taito_f3_state::**m_dpix_lp[5])(u32 s_pix); 287 int (taito_f3_state::**m_dpix_sp[9])(u32 s_pix); 288 289 u16 pf_ram_r(offs_t offset); 290 void pf_ram_w(offs_t offset, u16 data, u16 mem_mask = ~0); 291 void control_0_w(offs_t offset, u16 data, u16 mem_mask = ~0); 292 void control_1_w(offs_t offset, u16 data, u16 mem_mask = ~0); 293 u16 spriteram_r(offs_t offset); 294 void spriteram_w(offs_t offset, u16 data, u16 mem_mask = ~0); 295 u16 textram_r(offs_t offset); 296 void textram_w(offs_t offset, u16 data, u16 mem_mask = ~0); 297 u16 charram_r(offs_t offset); 298 void charram_w(offs_t offset, u16 data, u16 mem_mask = ~0); 299 u16 pivot_r(offs_t offset); 300 void pivot_w(offs_t offset, u16 data, u16 mem_mask = ~0); 301 u16 lineram_r(offs_t offset); 302 void lineram_w(offs_t offset, u16 data, u16 mem_mask = ~0); 303 304 template<unsigned Layer> TILE_GET_INFO_MEMBER(get_tile_info); 305 TILE_GET_INFO_MEMBER(get_tile_info_text); 306 TILE_GET_INFO_MEMBER(get_tile_info_pixel); 307 u32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); 308 DECLARE_WRITE_LINE_MEMBER(screen_vblank); 309 310 void bubsympb_map(address_map &map); 311 void f3_map(address_map &map); 312 313 void tile_decode(); 314 315 inline void f3_drawgfx(bitmap_rgb32 &dest_bmp, const rectangle &clip, gfx_element *gfx, int code, int color, int flipx, int flipy, int sx, int sy, u8 pri_dst); 316 inline void f3_drawgfxzoom(bitmap_rgb32 &dest_bmp, const rectangle &clip, gfx_element *gfx, int code, int color, int flipx, int flipy, int sx, int sy, int scalex, int scaley, u8 pri_dst); 317 void draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect); 318 void get_sprite_info(const u16 *spriteram16_ptr); 319 void print_debug_info(bitmap_rgb32 &bitmap); 320 inline void alpha_set_level(); 321 inline void alpha_blend32_s(int alphas, u32 s); 322 inline void alpha_blend32_d(int alphas, u32 s); 323 inline void alpha_blend_1_1(u32 s); 324 inline void alpha_blend_1_2(u32 s); 325 inline void alpha_blend_1_4(u32 s); 326 inline void alpha_blend_1_5(u32 s); 327 inline void alpha_blend_1_6(u32 s); 328 inline void alpha_blend_1_8(u32 s); 329 inline void alpha_blend_1_9(u32 s); 330 inline void alpha_blend_1_a(u32 s); 331 inline void alpha_blend_2a_0(u32 s); 332 inline void alpha_blend_2a_4(u32 s); 333 inline void alpha_blend_2a_8(u32 s); 334 inline void alpha_blend_2b_0(u32 s); 335 inline void alpha_blend_2b_4(u32 s); 336 inline void alpha_blend_2b_8(u32 s); 337 inline void alpha_blend_3a_0(u32 s); 338 inline void alpha_blend_3a_1(u32 s); 339 inline void alpha_blend_3a_2(u32 s); 340 inline void alpha_blend_3b_0(u32 s); 341 inline void alpha_blend_3b_1(u32 s); 342 inline void alpha_blend_3b_2(u32 s); 343 int dpix_1_noalpha(u32 s_pix); 344 int dpix_ret1(u32 s_pix); 345 int dpix_ret0(u32 s_pix); 346 int dpix_1_1(u32 s_pix); 347 int dpix_1_2(u32 s_pix); 348 int dpix_1_4(u32 s_pix); 349 int dpix_1_5(u32 s_pix); 350 int dpix_1_6(u32 s_pix); 351 int dpix_1_8(u32 s_pix); 352 int dpix_1_9(u32 s_pix); 353 int dpix_1_a(u32 s_pix); 354 int dpix_2a_0(u32 s_pix); 355 int dpix_2a_4(u32 s_pix); 356 int dpix_2a_8(u32 s_pix); 357 int dpix_3a_0(u32 s_pix); 358 int dpix_3a_1(u32 s_pix); 359 int dpix_3a_2(u32 s_pix); 360 int dpix_2b_0(u32 s_pix); 361 int dpix_2b_4(u32 s_pix); 362 int dpix_2b_8(u32 s_pix); 363 int dpix_3b_0(u32 s_pix); 364 int dpix_3b_1(u32 s_pix); 365 int dpix_3b_2(u32 s_pix); 366 int dpix_2_0(u32 s_pix); 367 int dpix_2_4(u32 s_pix); 368 int dpix_2_8(u32 s_pix); 369 int dpix_3_0(u32 s_pix); 370 int dpix_3_1(u32 s_pix); 371 int dpix_3_2(u32 s_pix); 372 inline void dpix_1_sprite(u32 s_pix); 373 inline void dpix_bg(u32 bgcolor); 374 void init_alpha_blend_func(); 375 inline void draw_scanlines(bitmap_rgb32 &bitmap, int xsize, s16 *draw_line_num, const f3_playfield_line_inf **line_t, const int *sprite, u32 orient, int skip_layer_num); 376 void visible_tile_check(f3_playfield_line_inf *line_t, int line, u32 x_index_fx, u32 y_index, u16 *pf_data_n); 377 void calculate_clip(int y, u16 pri, u32* clip0, u32* clip1, int *line_enable); 378 void get_spritealphaclip_info(); 379 void get_line_ram_info(tilemap_t *tmap, int sx, int sy, int pos, u16 *pf_data_n); 380 void get_vram_info(tilemap_t *vram_tilemap, tilemap_t *pixel_tilemap, int sx, int sy); 381 void scanline_draw(bitmap_rgb32 &bitmap, const rectangle &cliprect); 382 383 private: 384 optional_device<taito_en_device> m_taito_en; 385 optional_device<okim6295_device> m_oki; 386 387 optional_shared_ptr<u32> m_paletteram32; 388 optional_memory_bank m_okibank; 389 390 void bubsympb_oki_w(u8 data); 391 u32 f3_control_r(offs_t offset); 392 void f3_control_w(offs_t offset, u32 data, u32 mem_mask = ~0); 393 void f3_unk_w(offs_t offset, u16 data); 394 void sound_reset_0_w(u32 data); 395 void sound_reset_1_w(u32 data); 396 void sound_bankswitch_w(offs_t offset, u32 data, u32 mem_mask = ~0); 397 void palette_24bit_w(offs_t offset, u32 data, u32 mem_mask = ~0); 398 399 INTERRUPT_GEN_MEMBER(interrupt2); 400 401 void bubsympb_oki_map(address_map &map); 402 }; 403 404 #endif // MAME_INCLUDES_TAITO_F3_H 405