1 // license:BSD-3-Clause 2 // copyright-holders:Victor Trucco,Steve Ellenoff,Phil Stroffolino,Tatsuyuki Satoh,Tomasz Slanina,Nicola Salmoria,Vas Crabb 3 4 #include "machine/gen_latch.h" 5 #include "sound/msm5205.h" 6 #include "cpu/m6809/m6809.h" 7 #include "cpu/mcs48/mcs48.h" 8 #include "cpu/z80/z80.h" 9 #include "emupal.h" 10 #include "tilemap.h" 11 12 13 class gladiatr_state_base : public driver_device 14 { 15 public: 16 void videoram_w(offs_t offset, u8 data); 17 void colorram_w(offs_t offset, u8 data); 18 void textram_w(offs_t offset, u8 data); 19 void paletteram_w(offs_t offset, u8 data); 20 DECLARE_WRITE_LINE_MEMBER(spritebuffer_w); 21 void adpcm_command_w(u8 data); 22 u8 adpcm_command_r(); 23 DECLARE_WRITE_LINE_MEMBER(flipscreen_w); 24 DECLARE_WRITE_LINE_MEMBER(ym_irq); 25 26 void cpu2_map(address_map &map); 27 protected: gladiatr_state_base(const machine_config & mconfig,device_type type,const char * tag)28 gladiatr_state_base(const machine_config &mconfig, device_type type, const char *tag) 29 : driver_device(mconfig, type, tag) 30 , m_maincpu(*this, "maincpu") 31 , m_subcpu(*this, "sub") 32 , m_audiocpu(*this, "audiocpu") 33 , m_cctl(*this, "cctl") 34 , m_ccpu(*this, "ccpu") 35 , m_ucpu(*this, "ucpu") 36 , m_csnd(*this, "csnd") 37 , m_gfxdecode(*this, "gfxdecode") 38 , m_palette(*this, "palette") 39 , m_msm(*this, "msm") 40 , m_soundlatch(*this, "soundlatch") 41 , m_videoram(*this, "videoram") 42 , m_colorram(*this, "colorram") 43 , m_textram(*this, "textram") 44 , m_paletteram(*this, "paletteram") 45 , m_spriteram(*this, "spriteram") 46 , m_video_attributes(0) 47 , m_fg_scrolly(0) 48 , m_fg_tile_bank(0) 49 , m_bg_tile_bank(0) 50 , m_sprite_bank(0) 51 , m_sprite_buffer(0) 52 , m_fg_tilemap(nullptr) 53 , m_bg_tilemap(nullptr) 54 { 55 } 56 57 TILE_GET_INFO_MEMBER(bg_get_tile_info); 58 TILE_GET_INFO_MEMBER(fg_get_tile_info); 59 60 void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); 61 62 required_device<z80_device> m_maincpu; 63 required_device<z80_device> m_subcpu; 64 required_device<mc6809_device> m_audiocpu; 65 optional_device<upi41_cpu_device> m_cctl; 66 optional_device<upi41_cpu_device> m_ccpu; 67 optional_device<upi41_cpu_device> m_ucpu; 68 optional_device<upi41_cpu_device> m_csnd; 69 required_device<gfxdecode_device> m_gfxdecode; 70 required_device<palette_device> m_palette; 71 required_device<msm5205_device> m_msm; 72 required_device<generic_latch_8_device> m_soundlatch; 73 74 required_shared_ptr<u8> m_videoram; 75 required_shared_ptr<u8> m_colorram; 76 required_shared_ptr<u8> m_textram; 77 required_shared_ptr<u8> m_paletteram; 78 required_shared_ptr<u8> m_spriteram; 79 80 int m_video_attributes; 81 int m_fg_scrolly; 82 int m_fg_tile_bank; 83 int m_bg_tile_bank; 84 int m_sprite_bank; 85 int m_sprite_buffer; 86 87 tilemap_t *m_fg_tilemap; 88 tilemap_t *m_bg_tilemap; 89 }; 90 91 class gladiatr_state : public gladiatr_state_base 92 { 93 public: gladiatr_state(const machine_config & mconfig,device_type type,const char * tag)94 gladiatr_state(const machine_config &mconfig, device_type type, const char *tag) 95 : gladiatr_state_base(mconfig, type, tag) 96 , m_dsw1(*this, "DSW1") 97 , m_dsw2(*this, "DSW2") 98 , m_in0(*this, "IN0") 99 , m_in1(*this, "IN1") 100 , m_in2(*this, "IN2") 101 , m_coins(*this, "COINS") 102 , m_tclk_val(false) 103 , m_cctl_p1(0xff) 104 , m_cctl_p2(0xff) 105 , m_ucpu_p1(0xff) 106 , m_csnd_p1(0xff) 107 , m_fg_scrollx(0) 108 , m_bg_scrollx(0) 109 , m_bg_scrolly(0) 110 { 111 } 112 113 DECLARE_INPUT_CHANGED_MEMBER(p1_s1); 114 DECLARE_INPUT_CHANGED_MEMBER(p1_s2); 115 DECLARE_INPUT_CHANGED_MEMBER(p2_s1); 116 DECLARE_INPUT_CHANGED_MEMBER(p2_s2); 117 118 void gladiatr(machine_config &config); 119 void greatgur(machine_config &config); 120 121 void init_gladiatr(); 122 123 private: 124 DECLARE_WRITE_LINE_MEMBER(spritebank_w); 125 void gladiatr_video_registers_w(offs_t offset, u8 data); 126 127 void gladiatr_irq_patch_w(u8 data); 128 void gladiator_int_control_w(u8 data); 129 void gladiator_adpcm_w(u8 data); 130 131 DECLARE_WRITE_LINE_MEMBER(tclk_w); 132 u8 cctl_p1_r(); 133 u8 cctl_p2_r(); 134 void ccpu_p2_w(u8 data); 135 DECLARE_READ_LINE_MEMBER(tclk_r); 136 DECLARE_READ_LINE_MEMBER(ucpu_t1_r); 137 u8 ucpu_p1_r(); 138 void ucpu_p1_w(u8 data); 139 u8 ucpu_p2_r(); 140 DECLARE_READ_LINE_MEMBER(csnd_t1_r); 141 u8 csnd_p1_r(); 142 void csnd_p1_w(u8 data); 143 u8 csnd_p2_r(); 144 145 DECLARE_MACHINE_RESET(gladiator); 146 DECLARE_VIDEO_START(gladiatr); 147 148 uint32_t screen_update_gladiatr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 149 static void swap_block(u8 *src1, u8 *src2, int len); 150 151 void gladiatr_cpu1_io(address_map &map); 152 void gladiatr_cpu1_map(address_map &map); 153 void gladiatr_cpu2_io(address_map &map); 154 void gladiatr_cpu3_map(address_map &map); 155 156 required_ioport m_dsw1, m_dsw2; 157 required_ioport m_in0, m_in1, m_in2; 158 required_ioport m_coins; 159 160 bool m_tclk_val; 161 u8 m_cctl_p1, m_cctl_p2; 162 u8 m_ucpu_p1, m_csnd_p1; 163 164 int m_fg_scrollx; 165 int m_bg_scrollx; 166 int m_bg_scrolly; 167 }; 168 169 class ppking_state : public gladiatr_state_base 170 { 171 public: ppking_state(const machine_config & mconfig,device_type type,const char * tag)172 ppking_state(const machine_config &mconfig, device_type type, const char *tag) 173 : gladiatr_state_base(mconfig, type, tag) 174 , m_nvram(*this, "nvram") 175 , m_soundlatch2(*this, "soundlatch2") 176 { 177 } 178 179 u8 ppking_f1_r(); 180 void ppking_qx0_w(offs_t offset, u8 data); 181 void ppking_qx1_w(offs_t offset, u8 data); 182 void ppking_qx3_w(u8 data); 183 u8 ppking_qx3_r(offs_t offset); 184 u8 ppking_qx0_r(offs_t offset); 185 u8 ppking_qx1_r(offs_t offset); 186 u8 ppking_qxcomu_r(offs_t offset); 187 void ppking_qxcomu_w(u8 data); 188 void ppking_video_registers_w(offs_t offset, u8 data); 189 void ppking_adpcm_w(u8 data); 190 void cpu2_irq_ack_w(u8 data); 191 192 void init_ppking(); 193 194 DECLARE_MACHINE_RESET(ppking); 195 DECLARE_VIDEO_START(ppking); 196 197 uint32_t screen_update_ppking(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 198 199 void ppking(machine_config &config); 200 void ppking_cpu1_io(address_map &map); 201 void ppking_cpu1_map(address_map &map); 202 void ppking_cpu2_io(address_map &map); 203 void ppking_cpu3_map(address_map &map); 204 private: 205 required_shared_ptr<u8> m_nvram; 206 required_device<generic_latch_8_device> m_soundlatch2; 207 208 struct 209 { 210 u8 rxd; 211 u8 txd; 212 u8 rst; 213 u8 state; 214 u8 packet_type; 215 } m_mcu[2]; 216 217 bool mcu_parity_check(); 218 void mcu_input_check(); 219 }; 220