1 // license:BSD-3-Clause 2 // copyright-holders:Luca Elia 3 #ifndef MAME_INCLUDES_SETA_H 4 #define MAME_INCLUDES_SETA_H 5 6 #pragma once 7 8 /*************************************************************************** 9 10 -= Seta Hardware =- 11 12 ***************************************************************************/ 13 14 #include "machine/74157.h" 15 #include "machine/adc083x.h" 16 #include "machine/gen_latch.h" 17 #include "machine/ticket.h" 18 #include "machine/timer.h" 19 #include "machine/tmp68301.h" 20 #include "machine/upd4701.h" 21 #include "machine/upd4992.h" 22 #include "sound/x1_010.h" 23 #include "video/seta001.h" 24 #include "emupal.h" 25 #include "tilemap.h" 26 27 28 class seta_state : public driver_device 29 { 30 public: 31 struct uPD71054_state 32 { 33 emu_timer *timer[3]; // Timer 34 u16 max[3]; // Max counter 35 u16 write_select; // Max counter write select 36 u8 reg[4]; // 37 }; 38 39 struct game_offset 40 { 41 /* 2 values, for normal and flipped */ 42 const char *gamename; 43 int sprite_offs[2]; 44 int tilemap_offs[2]; 45 }; 46 seta_state(const machine_config & mconfig,device_type type,const char * tag)47 seta_state(const machine_config &mconfig, device_type type, const char *tag) : 48 driver_device(mconfig, type, tag), 49 m_maincpu(*this,"maincpu"), 50 m_audiocpu(*this, "audiocpu"), 51 m_subcpu(*this,"sub"), 52 m_seta001(*this, "spritegen"), 53 m_x1(*this, "x1snd"), 54 m_soundlatch(*this, "soundlatch%u", 1U), 55 m_dsw(*this, "DSW"), 56 m_rot(*this, "ROT%u", 1), 57 m_p1(*this, "P1"), 58 m_p2(*this, "P2"), 59 m_coins(*this, "COINS"), 60 m_extra_port(*this, "EXTRA"), 61 m_sharedram(*this,"sharedram"), 62 m_vram(*this,"vram_%u", 0U), 63 m_vctrl(*this,"vctrl_%u", 0U), 64 m_paletteram(*this,"paletteram%u", 1U), 65 m_subbank(*this,"subbank"), 66 m_x1_bank(*this,"x1_bank"), 67 m_leds(*this, "led%u", 0U), 68 m_gfxdecode(*this, "gfxdecode"), 69 m_palette(*this, "palette") 70 { } 71 72 void keroppij(machine_config &config); 73 void madshark(machine_config &config); 74 void jjsquawb(machine_config &config); 75 void oisipuzl(machine_config &config); 76 void zingzipbl(machine_config &config); 77 void eightfrc(machine_config &config); 78 void gundhara(machine_config &config); 79 void triplfun(machine_config &config); 80 void calibr50(machine_config &config); 81 void blandiap(machine_config &config); 82 void wits(machine_config &config); 83 void msgundam(machine_config &config); 84 void msgundamb(machine_config &config); 85 void extdwnhl(machine_config &config); 86 void pairlove(machine_config &config); 87 void zingzip(machine_config &config); 88 void wiggie(machine_config &config); 89 void umanclub(machine_config &config); 90 void tndrcade(machine_config &config); 91 void daioh(machine_config &config); 92 void atehate(machine_config &config); 93 void thunderlbl(machine_config &config); 94 void blockcarb(machine_config &config); 95 void wrofaero(machine_config &config); 96 void downtown(machine_config &config); 97 void blockcar(machine_config &config); 98 void crazyfgt(machine_config &config); 99 void keroppi(machine_config &config); 100 void drgnunit(machine_config &config); 101 void orbs(machine_config &config); 102 void daiohp(machine_config &config); 103 void magspeed(machine_config &config); 104 void krzybowl(machine_config &config); 105 void qzkklgy2(machine_config &config); 106 void kamenrid(machine_config &config); 107 void superbar(machine_config &config); 108 void jjsquawk(machine_config &config); 109 void twineagl(machine_config &config); 110 void blandia(machine_config &config); 111 void thunderl(machine_config &config); 112 void metafox(machine_config &config); 113 void utoukond(machine_config &config); 114 void rezon(machine_config &config); 115 116 void init_bank6502(); 117 void init_downtown(); 118 void init_rezon(); 119 void init_twineagl(); 120 void init_crazyfgt(); 121 void init_metafox(); 122 void init_arbalest(); 123 void init_wiggie(); 124 void init_bankx1(); 125 void init_eightfrc(); 126 void init_pairlove(); 127 128 void palette_init_RRRRRGGGGGBBBBB_proms(palette_device &palette) const; 129 130 SETA001_SPRITE_GFXBANK_CB_MEMBER(setac_gfxbank_callback); 131 132 u32 screen_update_seta_layers(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 133 134 protected: 135 required_device<cpu_device> m_maincpu; 136 optional_device<cpu_device> m_audiocpu; 137 optional_device<cpu_device> m_subcpu; 138 required_device<seta001_device> m_seta001; 139 optional_device<x1_010_device> m_x1; 140 optional_device_array<generic_latch_8_device, 2> m_soundlatch; 141 142 optional_ioport m_dsw; 143 optional_ioport_array<2> m_rot; 144 optional_ioport m_p1; 145 optional_ioport m_p2; 146 optional_ioport m_coins; 147 optional_ioport m_extra_port; 148 149 optional_shared_ptr<u8> m_sharedram; 150 optional_shared_ptr_array<u16, 2> m_vram; 151 optional_shared_ptr_array<u16, 2> m_vctrl; 152 optional_shared_ptr_array<u16, 2> m_paletteram; 153 154 optional_memory_bank m_subbank; 155 optional_memory_bank m_x1_bank; 156 157 output_finder<48> m_leds; 158 159 required_device<gfxdecode_device> m_gfxdecode; 160 required_device<palette_device> m_palette; 161 162 u8 m_vregs; 163 164 int m_tiles_offset; 165 tilemap_t *m_tilemap[2]; // Max 2 Layers 166 int m_rambank[2]; // 2 Tilemap banks for each layers 167 int m_tilemaps_flip; 168 int m_samples_bank; 169 int m_color_mode_shift; 170 int m_current_tilemap_mode[2]; 171 172 uPD71054_state m_uPD71054; 173 const game_offset *m_global_offsets; 174 175 int m_sub_ctrl_data; 176 177 int m_keroppi_prize_hop; 178 int m_keroppi_protection_count; 179 emu_timer *m_keroppi_prize_hop_timer; 180 181 u8 m_twineagl_xram[8]; 182 int m_twineagl_tilebank[4]; 183 184 u16 m_magspeed_lights[3]; 185 186 std::unique_ptr<u16[]> m_pairslove_protram; 187 std::unique_ptr<u16[]> m_pairslove_protram_old; 188 std::unique_ptr<u16[]> m_downtown_protection; 189 190 u16 metafox_protection_r(offs_t offset); 191 void seta_coin_counter_w(u8 data); 192 void seta_coin_lockout_w(u8 data); 193 void seta_vregs_w(u8 data); 194 template<int Layer> void vram_w(offs_t offset, u16 data, u16 mem_mask = ~0); 195 void twineagl_tilebank_w(offs_t offset, u8 data); 196 void timer_regs_w(offs_t offset, u16 data); 197 u8 sharedram_68000_r(offs_t offset); 198 void sharedram_68000_w(offs_t offset, u8 data); 199 void sub_ctrl_w(offs_t offset, u8 data); 200 u16 seta_dsw_r(offs_t offset); 201 202 u16 zingzipbl_unknown_r(); 203 u16 keroppi_protection_r(); 204 u16 keroppi_protection_init_r(); 205 u16 keroppi_coin_r(); 206 void keroppi_prize_w(u16 data); 207 u16 thunderl_protection_r(); 208 void thunderl_protection_w(u16 data); 209 void utoukond_sound_control_w(u8 data); 210 u16 pairlove_prot_r(offs_t offset); 211 void pairlove_prot_w(offs_t offset, u16 data); 212 void sub_bankswitch_w(u8 data); 213 void sub_bankswitch_lockout_w(u8 data); 214 u8 ff_r(); 215 u8 downtown_ip_r(offs_t offset); 216 void calibr50_sub_bankswitch_w(u8 data); 217 void calibr50_soundlatch2_w(u8 data); 218 void twineagl_ctrl_w(u8 data); 219 u16 twineagl_debug_r(); 220 u16 twineagl_200100_r(offs_t offset); 221 void twineagl_200100_w(offs_t offset, u16 data, u16 mem_mask = ~0); 222 u16 downtown_protection_r(offs_t offset); 223 void downtown_protection_w(offs_t offset, u16 data, u16 mem_mask = ~0); 224 u16 arbalest_debug_r(); 225 void magspeed_lights_w(offs_t offset, u16 data, u16 mem_mask = ~0); 226 u8 dsw1_r(); 227 u8 dsw2_r(); 228 u16 extra_r(); 229 230 TILE_GET_INFO_MEMBER(twineagl_get_tile_info); 231 template<int Layer> TILE_GET_INFO_MEMBER(get_tile_info); 232 DECLARE_VIDEO_START(seta_no_layers); 233 DECLARE_VIDEO_START(kyustrkr_no_layers); 234 DECLARE_VIDEO_START(twineagl_1_layer); 235 DECLARE_VIDEO_START(seta_1_layer); 236 DECLARE_MACHINE_RESET(calibr50); 237 238 DECLARE_VIDEO_START(seta_2_layers); 239 void blandia_palette(palette_device &palette) const; 240 void zingzip_palette(palette_device &palette) const; 241 DECLARE_MACHINE_START(wrofaero); 242 void gundhara_palette(palette_device &palette) const; 243 void jjsquawk_palette(palette_device &palette) const; 244 DECLARE_MACHINE_START(keroppi); 245 DECLARE_MACHINE_START(magspeed); 246 DECLARE_VIDEO_START(oisipuzl_2_layers); 247 u32 screen_update_seta_no_layers(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 248 u32 screen_update_seta(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 249 250 DECLARE_WRITE_LINE_MEMBER(screen_vblank_seta_buffer_sprites); 251 u16 ipl0_ack_r(); 252 void ipl0_ack_w(u16 data); 253 u16 ipl1_ack_r(); 254 void ipl1_ack_w(u16 data); 255 u16 ipl2_ack_r(); 256 void ipl2_ack_w(u16 data); 257 void uPD71054_update_timer(device_t *cpu, int no); 258 INTERRUPT_GEN_MEMBER(wrofaero_interrupt); 259 TIMER_CALLBACK_MEMBER(uPD71054_timer_callback); 260 TIMER_CALLBACK_MEMBER(keroppi_prize_hop_callback); 261 TIMER_DEVICE_CALLBACK_MEMBER(seta_interrupt_1_and_2); 262 TIMER_DEVICE_CALLBACK_MEMBER(seta_interrupt_2_and_4); 263 TIMER_DEVICE_CALLBACK_MEMBER(seta_sub_interrupt); 264 TIMER_DEVICE_CALLBACK_MEMBER(tndrcade_sub_interrupt); 265 TIMER_DEVICE_CALLBACK_MEMBER(calibr50_interrupt); 266 TIMER_DEVICE_CALLBACK_MEMBER(crazyfgt_interrupt); 267 268 void set_pens(); 269 void draw_tilemap_palette_effect(bitmap_ind16 &bitmap, const rectangle &cliprect, tilemap_t *tilemap, int scrollx, int scrolly, int gfxnum, int flipscreen); 270 void seta_layers_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int sprite_bank_size); 271 void uPD71054_timer_init(); 272 DECLARE_WRITE_LINE_MEMBER(pit_out0); 273 DECLARE_WRITE_LINE_MEMBER(utoukond_ym3438_interrupt); 274 275 void atehate_map(address_map &map); 276 void blandia_map(address_map &map); 277 void blandia_x1_map(address_map &map); 278 void blandiap_map(address_map &map); 279 void blockcar_map(address_map &map); 280 void blockcarb_map(address_map &map); 281 void blockcarb_sound_map(address_map &map); 282 void blockcarb_sound_portmap(address_map &map); 283 void calibr50_map(address_map &map); 284 void calibr50_sub_map(address_map &map); 285 void crazyfgt_map(address_map &map); 286 void daioh_map(address_map &map); 287 void daiohp_map(address_map &map); 288 void downtown_map(address_map &map); 289 void downtown_sub_map(address_map &map); 290 void drgnunit_map(address_map &map); 291 void extdwnhl_map(address_map &map); 292 void jjsquawb_map(address_map &map); 293 void kamenrid_map(address_map &map); 294 void keroppi_map(address_map &map); 295 void krzybowl_map(address_map &map); 296 void madshark_map(address_map &map); 297 void magspeed_map(address_map &map); 298 void metafox_sub_map(address_map &map); 299 void msgundam_map(address_map &map); 300 void msgundamb_map(address_map &map); 301 void oisipuzl_map(address_map &map); 302 void orbs_map(address_map &map); 303 void pairlove_map(address_map &map); 304 void thunderl_map(address_map &map); 305 void thunderlbl_map(address_map &map); 306 void thunderlbl_sound_map(address_map &map); 307 void thunderlbl_sound_portmap(address_map &map); 308 void tndrcade_map(address_map &map); 309 void tndrcade_sub_map(address_map &map); 310 void triplfun_map(address_map &map); 311 void twineagl_sub_map(address_map &map); 312 void umanclub_map(address_map &map); 313 void utoukond_map(address_map &map); 314 void utoukond_sound_io_map(address_map &map); 315 void utoukond_sound_map(address_map &map); 316 void wiggie_map(address_map &map); 317 void wiggie_sound_map(address_map &map); 318 void wrofaero_map(address_map &map); 319 void zingzipbl_map(address_map &map); 320 }; 321 322 class usclssic_state : public seta_state 323 { 324 public: usclssic_state(const machine_config & mconfig,device_type type,const char * tag)325 usclssic_state(const machine_config &mconfig, device_type type, const char *tag) : 326 seta_state(mconfig, type, tag), 327 m_upd4701(*this, "upd4701"), 328 m_buttonmux(*this, "buttonmux"), 329 m_track_x(*this, "TRACK%u_X", 1U), 330 m_track_y(*this, "TRACK%u_Y", 1U) 331 { } 332 333 void usclssic(machine_config &config); 334 335 DECLARE_CUSTOM_INPUT_MEMBER(trackball_x_r); 336 DECLARE_CUSTOM_INPUT_MEMBER(trackball_y_r); 337 338 protected: 339 virtual void machine_start() override; 340 341 private: 342 u16 dsw_r(offs_t offset); 343 void lockout_w(u8 data); 344 345 void usclssic_palette(palette_device &palette) const; 346 347 u32 screen_update_usclssic(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 348 349 void usclssic_set_pens(); 350 351 void usclssic_map(address_map &map); 352 353 required_device<upd4701_device> m_upd4701; 354 required_device<hc157_device> m_buttonmux; 355 required_ioport_array<2> m_track_x; 356 required_ioport_array<2> m_track_y; 357 358 u8 m_port_select; 359 }; 360 361 class kiwame_state : public seta_state 362 { 363 public: kiwame_state(const machine_config & mconfig,device_type type,const char * tag)364 kiwame_state(const machine_config &mconfig, device_type type, const char *tag) : 365 seta_state(mconfig, type, tag), 366 m_maincpu(*this, "maincpu"), 367 m_key(*this, "KEY%u", 0U) 368 { } 369 370 void kiwame(machine_config &config); 371 372 private: 373 void row_select_w(u16 data); 374 u16 input_r(offs_t offset); 375 DECLARE_WRITE_LINE_MEMBER(kiwame_vblank); 376 377 void kiwame_map(address_map &map); 378 379 required_device<tmp68301_device> m_maincpu; 380 required_ioport_array<10> m_key; 381 382 u16 m_kiwame_row_select; 383 }; 384 385 class zombraid_state : public seta_state 386 { 387 public: zombraid_state(const machine_config & mconfig,device_type type,const char * tag)388 zombraid_state(const machine_config &mconfig, device_type type, const char *tag) : 389 seta_state(mconfig, type, tag), 390 m_adc(*this, "adc"), 391 m_gun_inputs(*this, {"GUNX1", "GUNY1", "GUNX2", "GUNY2"}), 392 m_gun_recoil(*this, "Player%u_Gun_Recoil", 1U) 393 { } 394 395 void zombraid(machine_config &config); 396 void init_zombraid(); 397 398 protected: 399 DECLARE_MACHINE_START(zombraid); 400 401 private: 402 double adc_cb(u8 input); 403 u16 gun_r(); 404 void gun_w(u16 data); 405 406 void zombraid_map(address_map &map); 407 void zombraid_x1_map(address_map &map); 408 409 required_device<adc083x_device> m_adc; 410 required_ioport_array<4> m_gun_inputs; 411 output_finder<2> m_gun_recoil; 412 }; 413 414 class setaroul_state : public seta_state 415 { 416 public: setaroul_state(const machine_config & mconfig,device_type type,const char * tag)417 setaroul_state(const machine_config &mconfig, device_type type, const char *tag) : 418 seta_state(mconfig, type, tag), 419 m_rtc(*this, "rtc"), 420 m_hopper(*this, "hopper"), 421 m_bet(*this, "BET.%02X", 0), 422 m_mux(0), 423 m_pay(0), 424 m_led(0), 425 m_coin_start_cycles(0) 426 { } 427 428 void setaroul(machine_config &config); 429 430 DECLARE_INPUT_CHANGED_MEMBER(coin_drop_start); 431 DECLARE_CUSTOM_INPUT_MEMBER(coin_sensors_r); 432 DECLARE_CUSTOM_INPUT_MEMBER(hopper_sensors_r); 433 434 DECLARE_WRITE_LINE_MEMBER(screen_vblank); 435 436 private: 437 void rtc_w(u16 data); 438 u16 rtc_r(offs_t offset); 439 440 u16 inputs_r(); 441 void mux_w(u16 data); 442 443 void pay_w(u8 data); 444 void led_w(u8 data); 445 446 u16 spritecode_r(offs_t offset); 447 void spritecode_w(offs_t offset, u16 data); 448 449 void spriteylow_w(offs_t offset, u16 data); 450 451 void spritectrl_w(offs_t offset, u16 data); 452 453 DECLARE_MACHINE_START(setaroul); 454 DECLARE_MACHINE_RESET(setaroul); 455 456 DECLARE_VIDEO_START(setaroul_1_layer); 457 void setaroul_palette(palette_device &palette) const; 458 u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 459 460 TIMER_DEVICE_CALLBACK_MEMBER(interrupt); 461 462 void setaroul_map(address_map &map); 463 464 required_device<upd4992_device> m_rtc; // ! Actually D4911C ! 465 required_device<ticket_dispenser_device> m_hopper; 466 required_ioport_array<26> m_bet; 467 468 u8 m_mux; 469 470 u8 m_pay; 471 u8 m_led; 472 473 uint64_t m_coin_start_cycles; 474 475 void show_outputs(); 476 }; 477 478 class jockeyc_state : public seta_state 479 { 480 public: jockeyc_state(const machine_config & mconfig,device_type type,const char * tag)481 jockeyc_state(const machine_config &mconfig, device_type type, const char *tag) : 482 seta_state(mconfig, type, tag), 483 m_rtc(*this, "rtc"), 484 m_hopper1(*this, "hopper1"), m_hopper2(*this, "hopper2"), 485 m_inttoote_700000(*this, "inttoote_700000"), 486 m_key1(*this, "KEY1.%u", 0), m_key2(*this, "KEY2.%u", 0), 487 m_dsw1(*this, "DSW1"), 488 m_dsw2_3(*this, "DSW2_3"), 489 m_cabinet(*this, "CABINET"), 490 m_p1x(*this, "P1X"), 491 m_p1y(*this, "P1Y"), 492 m_out_cancel(*this, "cancel%u", 1U), 493 m_out_payout(*this, "payout%u", 1U), 494 m_out_start(*this, "start%u", 1U), 495 m_out_help(*this, "help"), 496 m_out_itstart(*this, "start"), 497 m_mux(0), 498 m_out(0) 499 { } 500 501 void inttoote(machine_config &config); 502 void jockeyc(machine_config &config); 503 504 void init_inttoote(); 505 506 private: 507 void rtc_w(u16 data); 508 u16 rtc_r(offs_t offset); 509 510 u16 dsw_r(offs_t offset); 511 u16 comm_r(); 512 513 u16 mux_r(); 514 void jockeyc_mux_w(offs_t offset, u16 data, u16 mem_mask = ~0); 515 void jockeyc_out_w(offs_t offset, u16 data, u16 mem_mask = ~0); 516 517 u16 trackball_r(offs_t offset); 518 519 DECLARE_MACHINE_START(jockeyc); 520 DECLARE_MACHINE_START(inttoote); 521 DECLARE_VIDEO_START(jockeyc_1_layer); 522 523 TIMER_DEVICE_CALLBACK_MEMBER(interrupt); 524 525 void inttoote_mux_w(offs_t offset, u16 data, u16 mem_mask = ~0); 526 void inttoote_out_w(offs_t offset, u16 data, u16 mem_mask = ~0); 527 u16 inttoote_700000_r(offs_t offset); 528 529 void inttoote_map(address_map &map); 530 void jockeyc_map(address_map &map); 531 532 required_device<upd4992_device> m_rtc; // ! Actually D4911C ! 533 required_device<ticket_dispenser_device> m_hopper1, m_hopper2; // the 2nd hopper is optional 534 535 optional_shared_ptr<u16> m_inttoote_700000; 536 required_ioport_array<5> m_key1, m_key2; 537 required_ioport m_dsw1, m_dsw2_3; 538 optional_ioport m_cabinet; 539 optional_ioport m_p1x; 540 optional_ioport m_p1y; 541 542 output_finder<2> m_out_cancel; 543 output_finder<2> m_out_payout; 544 output_finder<2> m_out_start; 545 output_finder<> m_out_help; 546 output_finder<> m_out_itstart; 547 548 u16 m_mux; 549 u16 m_out; 550 551 void update_hoppers(); 552 void show_outputs(); 553 }; 554 555 #endif // MAME_INCLUDES_SETA_H 556