1 // license:BSD-3-Clause 2 // copyright-holders:Ville Linde, hap, Nicola Salmoria 3 /****************************************************************************** 4 5 Seibu SPI hardware 6 7 ******************************************************************************/ 8 9 #include "machine/eepromser.h" 10 #include "machine/7200fifo.h" 11 #include "machine/intelfsh.h" 12 #include "sound/okim6295.h" 13 #include "emupal.h" 14 #include "tilemap.h" 15 16 class seibuspi_state : public driver_device 17 { 18 public: seibuspi_state(const machine_config & mconfig,device_type type,const char * tag)19 seibuspi_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_mainram(*this, "mainram") 24 , m_z80_rom(*this, "audiocpu") 25 , m_eeprom(*this, "eeprom") 26 , m_soundfifo(*this, "soundfifo%u", 1) 27 , m_oki(*this, "oki%u", 1) 28 , m_gfxdecode(*this, "gfxdecode") 29 , m_palette(*this, "palette") 30 , m_key(*this, "KEY.%u", 0) 31 , m_special(*this, "SPECIAL") 32 , m_z80_bank(*this, "z80_bank") 33 , m_soundflash1(*this, "soundflash1") 34 , m_soundflash2(*this, "soundflash2") 35 , m_soundflash1_region(*this, "soundflash1") 36 { } 37 38 void sys386f(machine_config &config); 39 void sxx2f(machine_config &config); 40 void rdft2(machine_config &config); 41 void ejanhs(machine_config &config); 42 void sys386i(machine_config &config); 43 void sxx2g(machine_config &config); 44 void spi(machine_config &config); 45 void sxx2e(machine_config &config); 46 47 void init_sei252(); 48 void init_batlball(); 49 void init_senkyu(); 50 void init_viprp1(); 51 void init_viprp1o(); 52 void init_rdft(); 53 void init_rfjet(); 54 void init_senkyua(); 55 void init_rdft2(); 56 void init_ejanhs(); 57 void init_sys386f(); 58 59 template <int N> DECLARE_CUSTOM_INPUT_MEMBER(ejanhs_encode); 60 61 IRQ_CALLBACK_MEMBER(spi_irq_callback); 62 INTERRUPT_GEN_MEMBER(spi_interrupt); 63 64 u32 screen_update_sys386f(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); 65 66 protected: 67 required_device<cpu_device> m_maincpu; 68 optional_device<cpu_device> m_audiocpu; 69 required_shared_ptr<u32> m_mainram; 70 optional_memory_region m_z80_rom; 71 optional_device<eeprom_serial_93cxx_device> m_eeprom; 72 optional_device_array<fifo7200_device, 2> m_soundfifo; 73 optional_device_array<okim6295_device, 2> m_oki; 74 required_device<gfxdecode_device> m_gfxdecode; 75 required_device<palette_device> m_palette; 76 77 optional_ioport_array<5> m_key; 78 optional_ioport m_special; 79 80 optional_memory_bank m_z80_bank; 81 82 optional_device<intel_e28f008sa_device> m_soundflash1, m_soundflash2; 83 84 optional_region_ptr<u8> m_soundflash1_region; 85 86 int m_z80_prg_transfer_pos; 87 int m_z80_lastbank; 88 u8 m_sb_coin_latch; 89 u8 m_ejsakura_input_port; 90 tilemap_t *m_text_layer; 91 tilemap_t *m_back_layer; 92 tilemap_t *m_midl_layer; 93 tilemap_t *m_fore_layer; 94 u32 m_video_dma_length; 95 u32 m_video_dma_address; 96 u16 m_layer_enable; 97 u16 m_layer_bank; 98 u8 m_rf2_layer_bank; 99 u16 m_scrollram[6]; 100 bool m_rowscroll_enable; 101 int m_midl_layer_offset; 102 int m_fore_layer_offset; 103 int m_text_layer_offset; 104 int m_fore_layer_d13; 105 int m_back_layer_d14; 106 int m_midl_layer_d14; 107 int m_fore_layer_d14; 108 std::unique_ptr<u32[]> m_tilemap_ram; 109 std::unique_ptr<u32[]> m_palette_ram; 110 std::unique_ptr<u32[]> m_sprite_ram; 111 u32 m_tilemap_ram_size; 112 u32 m_palette_ram_size; 113 u32 m_sprite_ram_size; 114 u32 m_bg_fore_layer_position; 115 u8 m_alpha_table[0x2000]; 116 int m_sprite_bpp; 117 118 void tile_decrypt_key_w(u16 data); 119 void spi_layer_bank_w(offs_t offset, u16 data, u16 mem_mask = ~0); 120 void spi_layer_enable_w(offs_t offset, u16 data, u16 mem_mask = ~0); 121 void rf2_layer_bank_w(u8 data); 122 void scroll_w(offs_t offset, u16 data, u16 mem_mask = ~0); 123 void tilemap_dma_start_w(u32 data); 124 void palette_dma_start_w(u32 data); 125 void sprite_dma_start_w(u16 data); 126 void video_dma_length_w(offs_t offset, u32 data, u32 mem_mask = ~0); 127 void video_dma_address_w(offs_t offset, u32 data, u32 mem_mask = ~0); 128 u8 spi_status_r(); 129 u8 spi_ds2404_unknown_r(); 130 u8 sb_coin_r(); 131 void spi_coin_w(u8 data); 132 u8 sound_fifo_status_r(); 133 void z80_prg_transfer_w(u8 data); 134 void z80_enable_w(u8 data); 135 u8 z80_soundfifo_status_r(); 136 void z80_bank_w(u8 data); 137 u32 ejsakura_keyboard_r(); 138 void ejsakura_input_select_w(u32 data); 139 void eeprom_w(u8 data); 140 void spi_layerbanks_eeprom_w(u8 data); 141 void oki_bank_w(u8 data); 142 143 u32 senkyu_speedup_r(); 144 u32 senkyua_speedup_r(); 145 u32 batlball_speedup_r(); 146 u32 rdft_speedup_r(); 147 u32 viprp1_speedup_r(); 148 u32 viprp1o_speedup_r(); 149 u32 rf2_speedup_r(); 150 u32 rfjet_speedup_r(); 151 152 DECLARE_WRITE_LINE_MEMBER(ymf_irqhandler); 153 154 void set_layer_offsets(); 155 void drawgfx_blend(bitmap_rgb32 &bitmap, const rectangle &cliprect, gfx_element *gfx, u32 code, u32 color, bool flipx, bool flipy, int sx, int sy, bitmap_ind8 &primap, u8 primask); 156 void draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, bitmap_ind8 &primap, int priority); 157 void combine_tilemap(bitmap_rgb32 &bitmap, const rectangle &cliprect, tilemap_t *tile, int sx, int sy, int opaque, s16 *rowscroll); 158 159 virtual void machine_start() override; 160 virtual void video_start() override; 161 DECLARE_MACHINE_RESET(spi); 162 DECLARE_MACHINE_RESET(sxx2e); 163 DECLARE_VIDEO_START(ejanhs); 164 DECLARE_VIDEO_START(sys386f); 165 TILE_GET_INFO_MEMBER(get_text_tile_info); 166 TILE_GET_INFO_MEMBER(get_back_tile_info); 167 TILE_GET_INFO_MEMBER(get_midl_tile_info); 168 TILE_GET_INFO_MEMBER(get_fore_tile_info); 169 u32 screen_update_spi(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); 170 171 void register_video_state(); 172 void init_spi_common(); 173 174 void text_decrypt(u8 *rom); 175 void bg_decrypt(u8 *rom, int size); 176 177 void rdft2_text_decrypt(u8 *rom); 178 void rdft2_bg_decrypt(u8 *rom, int size); 179 180 void rfjet_text_decrypt(u8 *rom); 181 void rfjet_bg_decrypt(u8 *rom, int size); 182 183 void base_map(address_map &map); 184 void rdft2_map(address_map &map); 185 void rise_map(address_map &map); 186 void sei252_map(address_map &map); 187 void spi_map(address_map &map); 188 void spi_soundmap(address_map &map); 189 void spi_ymf271_map(address_map &map); 190 void sxx2e_map(address_map &map); 191 void sxx2e_soundmap(address_map &map); 192 void sxx2f_map(address_map &map); 193 void sys386f_map(address_map &map); 194 void sys386i_map(address_map &map); 195 }; 196