1 // license:BSD-3-Clause 2 // copyright-holders:Tomasz Slanina 3 /* 4 5 Witch / Pinball Champ '95 / Keirin Ou 6 7 */ 8 9 #ifndef MAME_INCLUDES_WITCH_H 10 #define MAME_INCLUDES_WITCH_H 11 12 #pragma once 13 14 #include "cpu/z80/z80.h" 15 #include "machine/i8255.h" 16 #include "machine/nvram.h" 17 #include "machine/ticket.h" 18 #include "sound/ay8910.h" 19 #include "sound/2203intf.h" 20 #include "sound/es8712.h" 21 #include "emupal.h" 22 #include "screen.h" 23 #include "speaker.h" 24 #include "tilemap.h" 25 26 #define MAIN_CLOCK XTAL(12'000'000) 27 #define CPU_CLOCK MAIN_CLOCK / 4 28 #define YM2203_CLOCK MAIN_CLOCK / 4 29 #define AY8910_CLOCK MAIN_CLOCK / 8 30 #define MSM5202_CLOCK 384_kHz_XTAL 31 32 #define HOPPER_PULSE 50 // time between hopper pulses in milliseconds (not right for attendant pay) 33 #define UNBANKED_SIZE 0x800 34 35 36 class witch_state : public driver_device 37 { 38 public: witch_state(const machine_config & mconfig,device_type type,const char * tag)39 witch_state(const machine_config &mconfig, device_type type, const char *tag) 40 : driver_device(mconfig, type, tag) 41 , m_maincpu(*this, "maincpu") 42 , m_subcpu(*this, "sub") 43 , m_ppi(*this, "ppi%u", 1U) 44 , m_gfxdecode(*this, "gfxdecode") 45 , m_gfx0_vram(*this, "gfx0_vram") 46 , m_gfx0_cram(*this, "gfx0_cram") 47 , m_gfx1_vram(*this, "gfx1_vram") 48 , m_gfx1_cram(*this, "gfx1_cram") 49 , m_sprite_ram(*this, "sprite_ram") 50 , m_palette(*this, "palette") 51 , m_hopper(*this, "hopper") 52 , m_mainbank(*this, "mainbank") 53 { } 54 55 void witch(machine_config &config); 56 57 void init_witch(); 58 59 void gfx0_vram_w(offs_t offset, uint8_t data); 60 void gfx0_cram_w(offs_t offset, uint8_t data); 61 void gfx1_vram_w(offs_t offset, uint8_t data); 62 void gfx1_cram_w(offs_t offset, uint8_t data); 63 uint8_t gfx1_vram_r(offs_t offset); 64 uint8_t gfx1_cram_r(offs_t offset); 65 uint8_t read_a000(); 66 void write_a002(uint8_t data); 67 void write_a006(uint8_t data); 68 void main_write_a008(uint8_t data); 69 void sub_write_a008(uint8_t data); 70 uint8_t prot_read_700x(offs_t offset); 71 void xscroll_w(uint8_t data); 72 void yscroll_w(uint8_t data); 73 74 protected: 75 void common_map(address_map &map); 76 77 tilemap_t *m_gfx0_tilemap; 78 tilemap_t *m_gfx1_tilemap; 79 80 required_device<cpu_device> m_maincpu; 81 required_device<cpu_device> m_subcpu; 82 required_device_array<i8255_device, 2> m_ppi; 83 required_device<gfxdecode_device> m_gfxdecode; 84 85 required_shared_ptr<uint8_t> m_gfx0_vram; 86 required_shared_ptr<uint8_t> m_gfx0_cram; 87 required_shared_ptr<uint8_t> m_gfx1_vram; 88 required_shared_ptr<uint8_t> m_gfx1_cram; 89 required_shared_ptr<uint8_t> m_sprite_ram; 90 required_device<palette_device> m_palette; 91 92 required_device<ticket_dispenser_device> m_hopper; 93 94 optional_memory_bank m_mainbank; 95 96 int m_scrollx; 97 int m_scrolly; 98 uint8_t m_reg_a002; 99 uint8_t m_motor_active; 100 101 TILE_GET_INFO_MEMBER(get_gfx0_tile_info); 102 TILE_GET_INFO_MEMBER(get_gfx1_tile_info); 103 virtual void video_start() override; 104 uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 105 void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); 106 virtual void machine_reset() override; 107 108 void witch_common_map(address_map &map); 109 void witch_main_map(address_map &map); 110 void witch_sub_map(address_map &map); 111 112 void video_common_init(); 113 bool has_spr_rom_bank; 114 uint8_t m_spr_bank; 115 }; 116 117 class keirinou_state : public witch_state 118 { 119 public: keirinou_state(const machine_config & mconfig,device_type type,const char * tag)120 keirinou_state(const machine_config &mconfig, device_type type, const char *tag) 121 : witch_state(mconfig, type, tag), 122 m_paletteram(*this, "paletteram") 123 { } 124 125 void keirinou(machine_config &config); 126 127 private: 128 void keirinou_common_map(address_map &map); 129 void keirinou_main_map(address_map &map); 130 void keirinou_sub_map(address_map &map); 131 132 void write_keirinou_a002(uint8_t data); 133 void palette_w(offs_t offset, uint8_t data); 134 TILE_GET_INFO_MEMBER(get_keirinou_gfx1_tile_info); 135 136 virtual void video_start() override; 137 138 uint8_t m_bg_bank; 139 required_shared_ptr<uint8_t> m_paletteram; 140 }; 141 142 143 #endif 144