1 // license:BSD-3-Clause 2 // copyright-holders:Bryan McPhail 3 #ifndef MAME_INCLUDES_DEC8_H 4 #define MAME_INCLUDES_DEC8_H 5 6 #pragma once 7 8 #include "cpu/mcs51/mcs51.h" 9 #include "machine/gen_latch.h" 10 #include "machine/input_merger.h" 11 #include "sound/msm5205.h" 12 #include "video/bufsprite.h" 13 #include "video/decbac06.h" 14 #include "video/deckarn.h" 15 #include "video/decmxc06.h" 16 #include "video/decrmc3.h" 17 #include "screen.h" 18 #include "tilemap.h" 19 20 class dec8_state : public driver_device 21 { 22 public: 23 enum 24 { 25 TIMER_DEC8_I8751, 26 TIMER_DEC8_M6502 27 }; 28 dec8_state(const machine_config & mconfig,device_type type,const char * tag)29 dec8_state(const machine_config &mconfig, device_type type, const char *tag) : 30 driver_device(mconfig, type, tag), 31 m_maincpu(*this, "maincpu"), 32 m_subcpu(*this, "sub"), 33 m_audiocpu(*this, "audiocpu"), 34 m_mcu(*this, "mcu"), 35 m_nmigate(*this, "nmigate"), 36 m_spriteram(*this, "spriteram") , 37 m_msm(*this, "msm"), 38 m_tilegen(*this, "tilegen%u", 1), 39 m_spritegen_krn(*this, "spritegen_krn"), 40 m_spritegen_mxc(*this, "spritegen_mxc"), 41 m_gfxdecode(*this, "gfxdecode"), 42 m_screen(*this, "screen"), 43 m_palette(*this, "palette"), 44 m_soundlatch(*this, "soundlatch"), 45 m_videoram(*this, "videoram"), 46 m_bg_data(*this, "bg_data"), 47 m_mainbank(*this, "mainbank"), 48 m_soundbank(*this, "soundbank"), 49 m_coin_port(*this, "I8751") 50 { } 51 52 void shackled(machine_config &config); 53 void meikyuh(machine_config &config); 54 void lastmisn(machine_config &config); 55 void csilver(machine_config &config); 56 void cobracom(machine_config &config); 57 void garyoret(machine_config &config); 58 void srdarwin(machine_config &config); 59 void ghostb(machine_config &config); 60 void oscar(machine_config &config); 61 void gondo(machine_config &config); 62 63 void init_dec8(); 64 void init_csilver(); 65 66 private: 67 /* devices */ 68 required_device<cpu_device> m_maincpu; 69 optional_device<cpu_device> m_subcpu; 70 required_device<cpu_device> m_audiocpu; 71 optional_device<i8751_device> m_mcu; 72 optional_device<input_merger_device> m_nmigate; 73 required_device<buffered_spriteram8_device> m_spriteram; 74 optional_device<msm5205_device> m_msm; 75 optional_device_array<deco_bac06_device, 2> m_tilegen; 76 optional_device<deco_karnovsprites_device> m_spritegen_krn; 77 optional_device<deco_mxc06_device> m_spritegen_mxc; 78 required_device<gfxdecode_device> m_gfxdecode; 79 required_device<screen_device> m_screen; 80 required_device<deco_rmc3_device> m_palette; 81 required_device<generic_latch_8_device> m_soundlatch; 82 83 /* memory pointers */ 84 required_shared_ptr<uint8_t> m_videoram; 85 optional_shared_ptr<uint8_t> m_bg_data; 86 87 /* memory regions */ 88 required_memory_bank m_mainbank; 89 optional_memory_bank m_soundbank; 90 91 uint8_t * m_pf1_data; 92 uint8_t * m_row; 93 std::unique_ptr<uint16_t[]> m_buffered_spriteram16; // for the mxc06 sprite chip emulation (oscar, cobra) 94 95 /* video-related */ 96 tilemap_t *m_bg_tilemap; 97 tilemap_t *m_pf1_tilemap; 98 tilemap_t *m_fix_tilemap; 99 //int m_scroll1[4]; 100 int m_scroll2[4]; 101 int m_bg_control[0x20]; 102 int m_pf1_control[0x20]; 103 int m_game_uses_priority; 104 105 /* misc */ 106 bool m_secclr; 107 bool m_nmi_enable; 108 uint8_t m_i8751_p2; 109 int m_i8751_port0; 110 int m_i8751_port1; 111 int m_i8751_return; 112 int m_i8751_value; 113 int m_coinage_id; 114 int m_coin1; 115 int m_coin2; 116 int m_need1; 117 int m_need2; 118 int m_cred1; 119 int m_cred2; 120 int m_credits; 121 int m_latch; 122 bool m_coin_state; 123 int m_snd; 124 int m_msm5205next; 125 int m_toggle; 126 127 emu_timer *m_i8751_timer; 128 emu_timer *m_m6502_timer; 129 130 void dec8_mxc06_karn_buffer_spriteram_w(uint8_t data); 131 uint8_t i8751_h_r(); 132 uint8_t i8751_l_r(); 133 void i8751_reset_w(uint8_t data); 134 uint8_t gondo_player_1_r(offs_t offset); 135 uint8_t gondo_player_2_r(offs_t offset); 136 void dec8_i8751_w(offs_t offset, uint8_t data); 137 void dec8_bank_w(uint8_t data); 138 void ghostb_bank_w(uint8_t data); 139 void csilver_control_w(uint8_t data); 140 void dec8_sound_w(uint8_t data); 141 void csilver_adpcm_data_w(uint8_t data); 142 void csilver_sound_bank_w(uint8_t data); 143 void main_irq_on_w(uint8_t data); 144 void main_irq_off_w(uint8_t data); 145 void main_firq_off_w(uint8_t data); 146 void sub_irq_on_w(uint8_t data); 147 void sub_irq_off_w(uint8_t data); 148 void sub_firq_off_w(uint8_t data); 149 void flip_screen_w(uint8_t data); 150 uint8_t i8751_port0_r(); 151 void i8751_port0_w(uint8_t data); 152 uint8_t i8751_port1_r(); 153 void i8751_port1_w(uint8_t data); 154 void gondo_mcu_to_main_w(uint8_t data); 155 void shackled_mcu_to_main_w(uint8_t data); 156 void srdarwin_mcu_to_main_w(uint8_t data); 157 void csilver_mcu_to_main_w(uint8_t data); 158 void dec8_bg_data_w(offs_t offset, uint8_t data); 159 uint8_t dec8_bg_data_r(offs_t offset); 160 void dec8_videoram_w(offs_t offset, uint8_t data); 161 void srdarwin_videoram_w(offs_t offset, uint8_t data); 162 void dec8_scroll2_w(offs_t offset, uint8_t data); 163 void srdarwin_control_w(offs_t offset, uint8_t data); 164 void lastmisn_control_w(uint8_t data); 165 void shackled_control_w(uint8_t data); 166 void lastmisn_scrollx_w(uint8_t data); 167 void lastmisn_scrolly_w(uint8_t data); 168 void gondo_scroll_w(offs_t offset, uint8_t data); 169 uint8_t csilver_adpcm_reset_r(); 170 TILE_GET_INFO_MEMBER(get_cobracom_fix_tile_info); 171 TILE_GET_INFO_MEMBER(get_ghostb_fix_tile_info); 172 TILE_GET_INFO_MEMBER(get_oscar_fix_tile_info); 173 TILEMAP_MAPPER_MEMBER(lastmisn_scan_rows); 174 TILE_GET_INFO_MEMBER(get_lastmisn_tile_info); 175 TILE_GET_INFO_MEMBER(get_lastmisn_fix_tile_info); 176 TILE_GET_INFO_MEMBER(get_srdarwin_fix_tile_info); 177 TILE_GET_INFO_MEMBER(get_srdarwin_tile_info); 178 TILE_GET_INFO_MEMBER(get_gondo_fix_tile_info); 179 TILE_GET_INFO_MEMBER(get_gondo_tile_info); 180 virtual void machine_start() override; 181 virtual void machine_reset() override; 182 DECLARE_VIDEO_START(lastmisn); 183 DECLARE_VIDEO_START(shackled); 184 DECLARE_VIDEO_START(gondo); 185 DECLARE_VIDEO_START(garyoret); 186 DECLARE_VIDEO_START(ghostb); 187 DECLARE_VIDEO_START(oscar); 188 DECLARE_VIDEO_START(srdarwin); 189 DECLARE_VIDEO_START(cobracom); 190 void allocate_buffered_spriteram16(); 191 uint32_t screen_update_lastmisn(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 192 uint32_t screen_update_shackled(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 193 uint32_t screen_update_gondo(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 194 uint32_t screen_update_garyoret(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 195 uint32_t screen_update_ghostb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 196 uint32_t screen_update_oscar(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 197 uint32_t screen_update_srdarwin(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 198 uint32_t screen_update_cobracom(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 199 DECLARE_WRITE_LINE_MEMBER(screen_vblank_dec8); 200 DECLARE_WRITE_LINE_MEMBER(oscar_coin_irq); 201 void oscar_coin_clear_w(uint8_t data); 202 DECLARE_WRITE_LINE_MEMBER(shackled_coin_irq); 203 void srdarwin_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, bitmap_ind8 &primap); 204 void gondo_colpri_cb(u32 &colour, u32 &pri_mask); 205 void cobracom_colpri_cb(u32 &colour, u32 &pri_mask); 206 void oscar_tile_cb(tile_data &tileinfo, u32 &tile, u32 &colour, u32 &flags); 207 DECLARE_WRITE_LINE_MEMBER(csilver_adpcm_int); 208 209 void set_screen_raw_params_data_east(machine_config &config); 210 211 void cobra_map(address_map &map); 212 void csilver_map(address_map &map); 213 void csilver_s_map(address_map &map); 214 void csilver_sub_map(address_map &map); 215 void dec8_s_map(address_map &map); 216 void garyoret_map(address_map &map); 217 void gondo_map(address_map &map); 218 void lastmisn_map(address_map &map); 219 void lastmisn_sub_map(address_map &map); 220 void meikyuh_map(address_map &map); 221 void oscar_map(address_map &map); 222 void oscar_s_map(address_map &map); 223 void oscar_sub_map(address_map &map); 224 void shackled_map(address_map &map); 225 void shackled_sub_map(address_map &map); 226 void srdarwin_map(address_map &map); 227 void ym3526_s_map(address_map &map); 228 protected: 229 virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; 230 231 private: 232 /* ports */ 233 optional_ioport m_coin_port; 234 }; 235 236 #endif // MAME_INCLUDES_DEC8_H 237