1 // license:BSD-3-Clause 2 // copyright-holders:Luca Elia,Olivier Galibert,Paul Priest 3 /************************************************************************* 4 5 Psikyo Games 6 7 *************************************************************************/ 8 #ifndef MAME_INCLUDES_PSIKYO_H 9 #define MAME_INCLUDES_PSIKYO_H 10 11 #pragma once 12 13 #include "machine/gen_latch.h" 14 #include "video/bufsprite.h" 15 #include "sound/okim6295.h" 16 #include "emupal.h" 17 #include "screen.h" 18 #include "tilemap.h" 19 20 #include <algorithm> 21 22 class psikyo_state : public driver_device 23 { 24 public: psikyo_state(const machine_config & mconfig,device_type type,const char * tag)25 psikyo_state(const machine_config &mconfig, device_type type, const char *tag) 26 : driver_device(mconfig, type, tag) 27 , m_vram(*this, "vram_%u", 0U, (u8)32) 28 , m_vregs(*this, "vregs") 29 , m_bootleg_spritebuffer(*this, "boot_spritebuf") 30 , m_spritelut(*this, "spritelut") 31 , m_audiobank(*this, "audiobank") 32 , m_okibank(*this, "okibank") 33 , m_in_dsw(*this, "DSW") 34 , m_in_p1_p2(*this, "P1_P2") 35 , m_in_coin(*this, "COIN") 36 , m_maincpu(*this, "maincpu") 37 , m_audiocpu(*this, "audiocpu") 38 , m_oki(*this, "oki") 39 , m_soundlatch(*this, "soundlatch") 40 , m_gfxdecode(*this, "gfxdecode") 41 , m_screen(*this, "screen") 42 , m_palette(*this, "palette") 43 , m_spriteram(*this, "spriteram") 44 { 45 std::fill(std::begin(m_old_linescroll), std::end(m_old_linescroll), ~u32(0)); 46 std::fill(std::begin(m_old_tmapsize), std::end(m_old_tmapsize), ~u32(0)); 47 std::fill(std::begin(m_tmapsize), std::end(m_tmapsize), ~u32(0)); 48 } 49 50 void sngkace(machine_config &config); 51 void s1945n(machine_config &config); 52 void gunbird(machine_config &config); 53 void s1945(machine_config &config); 54 void s1945bl(machine_config &config); 55 56 void init_s1945a(); 57 void init_s1945j(); 58 void init_sngkace(); 59 void init_s1945(); 60 void init_s1945bl(); 61 void init_tengai(); 62 void init_gunbird(); 63 64 DECLARE_READ_LINE_MEMBER(z80_nmi_r); 65 DECLARE_READ_LINE_MEMBER(mcu_status_r); 66 67 private: 68 /* memory pointers */ 69 required_shared_ptr_array<u16, 2> m_vram; 70 required_shared_ptr<u32> m_vregs; 71 optional_shared_ptr<u32> m_bootleg_spritebuffer; 72 73 required_region_ptr<u16> m_spritelut; 74 optional_memory_bank m_audiobank; 75 optional_memory_bank m_okibank; 76 optional_ioport m_in_dsw; 77 optional_ioport m_in_p1_p2; 78 optional_ioport m_in_coin; 79 80 /* video-related */ 81 struct sprite_t 82 { 83 u8 gfx; 84 u32 code,color; 85 bool flipx,flipy; 86 s32 x,y; 87 u32 zoomx,zoomy; 88 u32 primask; 89 }; 90 91 tilemap_t *m_tilemap[2]; 92 u8 m_tilemap_bank[2]; 93 bool m_ka302c_banking; 94 u32 m_old_linescroll[2]; 95 u32 m_old_tmapsize[2]; 96 u32 m_tmapsize[2]; 97 std::unique_ptr<sprite_t[]> m_spritelist; 98 struct sprite_t *m_sprite_ptr_pre; 99 u16 m_sprite_ctrl; 100 101 /* game-specific */ 102 // 1945 MCU 103 int m_mcu_status; 104 u8 m_s1945_mcu_direction; 105 u8 m_s1945_mcu_latch1; 106 u8 m_s1945_mcu_latch2; 107 u8 m_s1945_mcu_inlatch; 108 u8 m_s1945_mcu_index; 109 u8 m_s1945_mcu_latching; 110 u8 m_s1945_mcu_mode; 111 u8 m_s1945_mcu_control; 112 u8 m_s1945_mcu_bctrl; 113 const u8 *m_s1945_mcu_table; 114 115 u32 sngkace_input_r(offs_t offset); 116 u32 gunbird_input_r(offs_t offset); 117 void s1945_mcu_data_w(uint8_t data); 118 void s1945_mcu_control_w(uint8_t data); 119 void s1945_mcu_direction_w(uint8_t data); 120 void s1945_mcu_bctrl_w(uint8_t data); 121 void s1945_mcu_command_w(uint8_t data); 122 u32 s1945_mcu_data_r(); 123 uint8_t s1945_mcu_control_r(); 124 u32 s1945_input_r(offs_t offset); 125 void s1945bl_okibank_w(u8 data); 126 template<int Shift> void sound_bankswitch_w(u8 data); 127 template<int Layer> u16 vram_r(offs_t offset); 128 template<int Layer> void vram_w(offs_t offset, u16 data, u16 mem_mask); 129 130 template<int Layer> TILE_GET_INFO_MEMBER(get_tile_info); 131 template<int Layer> TILEMAP_MAPPER_MEMBER(tile_scan); 132 virtual void machine_start() override; 133 virtual void machine_reset() override; 134 DECLARE_VIDEO_START(sngkace); 135 DECLARE_VIDEO_START(psikyo); 136 u32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); 137 u32 screen_update_bootleg(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); 138 DECLARE_WRITE_LINE_MEMBER(screen_vblank); 139 DECLARE_WRITE_LINE_MEMBER(screen_vblank_bootleg); 140 void switch_bgbanks(u8 tmap, u8 bank); 141 void draw_sprites(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); 142 void get_sprites(); 143 void get_sprites_bootleg(); 144 void s1945_mcu_init(); 145 146 /* devices */ 147 required_device<cpu_device> m_maincpu; 148 optional_device<cpu_device> m_audiocpu; 149 optional_device<okim6295_device> m_oki; 150 optional_device<generic_latch_8_device> m_soundlatch; 151 required_device<gfxdecode_device> m_gfxdecode; 152 required_device<screen_device> m_screen; 153 required_device<palette_device> m_palette; 154 required_device<buffered_spriteram32_device> m_spriteram; 155 156 void gunbird_map(address_map &map); 157 void gunbird_sound_io_map(address_map &map); 158 void gunbird_sound_map(address_map &map); 159 void psikyo_bootleg_map(address_map &map); 160 void psikyo_map(address_map &map); 161 void s1945_map(address_map &map); 162 void s1945_sound_io_map(address_map &map); 163 void s1945bl_oki_map(address_map &map); 164 void s1945n_map(address_map &map); 165 void sngkace_map(address_map &map); 166 void sngkace_sound_io_map(address_map &map); 167 void sngkace_sound_map(address_map &map); 168 }; 169 170 #endif // MAME_INCLUDES_PSIKYO_H 171