1 // license:BSD-3-Clause 2 // copyright-holders:Ryan Holtz, David Haywood 3 #ifndef MAME_INCLUDES_SPG2XX_H 4 #define MAME_INCLUDES_SPG2XX_H 5 6 #pragma once 7 8 #include "cpu/unsp/unsp.h" 9 #include "machine/i2cmem.h" 10 #include "machine/spg2xx.h" 11 12 13 #include "screen.h" 14 #include "softlist.h" 15 #include "speaker.h" 16 #include "machine/eepromser.h" 17 #include "machine/i2cmem.h" 18 19 20 class spg2xx_game_state : public driver_device 21 { 22 public: spg2xx_game_state(const machine_config & mconfig,device_type type,const char * tag)23 spg2xx_game_state(const machine_config &mconfig, device_type type, const char *tag) : 24 driver_device(mconfig, type, tag), 25 m_maincpu(*this, "maincpu"), 26 m_screen(*this, "screen"), 27 m_bank(*this, "cartbank"), 28 m_io_p1(*this, "P1"), 29 m_io_p2(*this, "P2"), 30 m_io_p3(*this, "P3"), 31 m_io_guny(*this, "GUNY"), 32 m_io_gunx(*this, "GUNX"), 33 m_i2cmem(*this, "i2cmem") 34 { } 35 36 void spg2xx_base(machine_config &config); 37 void spg2xx(machine_config &config); 38 void spg2xx_pal(machine_config &config); 39 40 void rad_skat(machine_config &config); 41 void rad_skatp(machine_config &config); 42 void rad_sktv(machine_config &config); 43 void rad_crik(machine_config &config); 44 void non_spg_base(machine_config &config); 45 void comil(machine_config &config); 46 void tvsprt10(machine_config &config); 47 void guitarfv(machine_config &config); 48 void tmntmutm(machine_config &config); 49 50 51 void init_crc(); 52 void init_tvsprt10(); 53 54 protected: 55 virtual void machine_start() override; 56 virtual void machine_reset() override; 57 58 void decrypt_ac_ff(uint16_t* ROM, int size); 59 60 void switch_bank(uint32_t bank); 61 62 void i2c_w(offs_t offset, uint8_t data); 63 uint8_t i2c_r(offs_t offset); 64 65 virtual void porta_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 66 virtual void portb_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 67 virtual void portc_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 68 69 uint16_t base_porta_r(offs_t offset, uint16_t mem_mask = ~0); 70 uint16_t base_portb_r(offs_t offset, uint16_t mem_mask = ~0); 71 uint16_t base_portc_r(offs_t offset, uint16_t mem_mask = ~0); 72 uint16_t base_guny_r(); 73 uint16_t base_gunx_r(); 74 75 required_device<spg2xx_device> m_maincpu; 76 required_device<screen_device> m_screen; 77 optional_memory_bank m_bank; 78 79 80 virtual void mem_map_4m(address_map &map); 81 virtual void mem_map_2m(address_map &map); 82 virtual void mem_map_1m(address_map &map); 83 84 uint32_t m_current_bank; 85 86 required_ioport m_io_p1; 87 optional_ioport m_io_p2; 88 optional_ioport m_io_p3; 89 optional_ioport m_io_guny; 90 optional_ioport m_io_gunx; 91 optional_device<i2cmem_device> m_i2cmem; 92 }; 93 94 95 class spg2xx_game_pballpup_state : public spg2xx_game_state 96 { 97 public: spg2xx_game_pballpup_state(const machine_config & mconfig,device_type type,const char * tag)98 spg2xx_game_pballpup_state(const machine_config &mconfig, device_type type, const char *tag) : 99 spg2xx_game_state(mconfig, type, tag), 100 m_eeprom(*this, "eeprom") 101 { } 102 103 void pballpup(machine_config &config); 104 105 private: 106 uint16_t porta_r(); 107 virtual void porta_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0) override; 108 109 required_device<eeprom_serial_93cxx_device> m_eeprom; 110 }; 111 112 class spg2xx_game_comil_state : public spg2xx_game_state 113 { 114 public: spg2xx_game_comil_state(const machine_config & mconfig,device_type type,const char * tag)115 spg2xx_game_comil_state(const machine_config &mconfig, device_type type, const char *tag) : 116 spg2xx_game_state(mconfig, type, tag), 117 m_porta_data(0), 118 m_extra_in(*this, "EXTRA%u", 0U) 119 { } 120 121 void comil(machine_config &config); 122 123 private: 124 uint16_t porta_r(offs_t offset, uint16_t mem_mask = ~0); 125 void porta_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0) override; 126 uint16_t portb_r(offs_t offset, uint16_t mem_mask = ~0); 127 uint16_t m_porta_data; 128 required_ioport_array<8> m_extra_in; 129 }; 130 131 class spg2xx_game_swclone_state : public spg2xx_game_state 132 { 133 public: spg2xx_game_swclone_state(const machine_config & mconfig,device_type type,const char * tag)134 spg2xx_game_swclone_state(const machine_config &mconfig, device_type type, const char *tag) : 135 spg2xx_game_state(mconfig, type, tag), 136 m_porta_data(0), 137 m_i2cmem(*this, "i2cmem") 138 { } 139 140 void swclone(machine_config &config); 141 void init_swclone(); 142 143 private: 144 uint16_t porta_r(); 145 void porta_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0) override; 146 uint16_t m_porta_data; 147 148 required_device<i2cmem_device> m_i2cmem; 149 }; 150 151 class spg2xx_game_tmntmutm_state : public spg2xx_game_state 152 { 153 public: spg2xx_game_tmntmutm_state(const machine_config & mconfig,device_type type,const char * tag)154 spg2xx_game_tmntmutm_state(const machine_config &mconfig, device_type type, const char *tag) : 155 spg2xx_game_state(mconfig, type, tag), 156 m_i2cmem(*this, "i2cmem") 157 { } 158 159 void tmntmutm(machine_config &config); 160 161 private: 162 uint16_t guny_r(); 163 uint16_t gunx_r(); 164 165 required_device<i2cmem_device> m_i2cmem; 166 }; 167 168 class spg2xx_game_albkickb_state : public spg2xx_game_state 169 { 170 public: spg2xx_game_albkickb_state(const machine_config & mconfig,device_type type,const char * tag)171 spg2xx_game_albkickb_state(const machine_config &mconfig, device_type type, const char *tag) : 172 spg2xx_game_state(mconfig, type, tag) 173 { } 174 175 void ablkickb(machine_config &config); 176 177 void init_ablkickb(); 178 179 private: 180 uint16_t portb_r(offs_t offset, uint16_t mem_mask = ~0); 181 }; 182 183 class spg2xx_game_dreamlss_state : public spg2xx_game_state 184 { 185 public: spg2xx_game_dreamlss_state(const machine_config & mconfig,device_type type,const char * tag)186 spg2xx_game_dreamlss_state(const machine_config &mconfig, device_type type, const char *tag) : 187 spg2xx_game_state(mconfig, type, tag), 188 m_porta_data(0), 189 m_portb_data(0), 190 m_i2cmem(*this, "i2cmem") 191 { } 192 193 void dreamlss(machine_config &config); 194 195 private: 196 uint16_t m_porta_data; 197 uint16_t m_portb_data; 198 199 uint16_t porta_r(); 200 uint16_t portb_r(); 201 virtual void portb_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0) override; 202 virtual void porta_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0) override; 203 204 required_device<i2cmem_device> m_i2cmem; 205 }; 206 207 class spg2xx_game_gssytts_state : public spg2xx_game_state 208 { 209 public: spg2xx_game_gssytts_state(const machine_config & mconfig,device_type type,const char * tag)210 spg2xx_game_gssytts_state(const machine_config &mconfig, device_type type, const char *tag) : 211 spg2xx_game_state(mconfig, type, tag), 212 m_upperbank(*this, "upperbank") 213 { } 214 215 void gssytts(machine_config &config); 216 217 protected: 218 virtual void machine_start() override; 219 virtual void machine_reset() override; 220 221 virtual void portc_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0) override; 222 223 required_memory_bank m_upperbank; 224 225 private: 226 227 void mem_map_upperbank(address_map& map); 228 }; 229 230 class spg2xx_game_senwfit_state : public spg2xx_game_gssytts_state 231 { 232 public: spg2xx_game_senwfit_state(const machine_config & mconfig,device_type type,const char * tag)233 spg2xx_game_senwfit_state(const machine_config &mconfig, device_type type, const char *tag) : 234 spg2xx_game_gssytts_state(mconfig, type, tag) 235 { } 236 237 void init_senwfit(); 238 protected: 239 240 virtual void portc_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0) override; 241 242 private: 243 }; 244 245 246 class spg2xx_game_senspeed_state : public spg2xx_game_state 247 { 248 public: spg2xx_game_senspeed_state(const machine_config & mconfig,device_type type,const char * tag)249 spg2xx_game_senspeed_state(const machine_config &mconfig, device_type type, const char *tag) : 250 spg2xx_game_state(mconfig, type, tag), 251 m_i2cmem(*this, "i2cmem") 252 { } 253 254 void senspeed(machine_config &config); 255 256 private: 257 uint16_t portb_r(); 258 void portb_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0) override; 259 required_device<i2cmem_device> m_i2cmem; 260 }; 261 262 class spg2xx_game_fordrace_state : public spg2xx_game_state 263 { 264 public: spg2xx_game_fordrace_state(const machine_config & mconfig,device_type type,const char * tag)265 spg2xx_game_fordrace_state(const machine_config &mconfig, device_type type, const char *tag) : 266 spg2xx_game_state(mconfig, type, tag) 267 { } 268 269 void fordrace(machine_config &config); 270 271 DECLARE_CUSTOM_INPUT_MEMBER(wheel_r); 272 DECLARE_CUSTOM_INPUT_MEMBER(wheel2_r); 273 274 private: 275 }; 276 277 278 279 class spg2xx_game_wfcentro_state : public spg2xx_game_state 280 { 281 public: spg2xx_game_wfcentro_state(const machine_config & mconfig,device_type type,const char * tag)282 spg2xx_game_wfcentro_state(const machine_config &mconfig, device_type type, const char *tag) : 283 spg2xx_game_state(mconfig, type, tag) 284 { } 285 286 void wfcentro(machine_config &config); 287 288 protected: 289 // virtual void machine_start() override; 290 // virtual void machine_reset() override; 291 292 // virtual void portc_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0) override; 293 294 private: 295 296 void mem_map_wfcentro(address_map& map); 297 }; 298 299 class spg2xx_game_ordentv_state : public spg2xx_game_state 300 { 301 public: spg2xx_game_ordentv_state(const machine_config & mconfig,device_type type,const char * tag)302 spg2xx_game_ordentv_state(const machine_config &mconfig, device_type type, const char *tag) : 303 spg2xx_game_state(mconfig, type, tag) 304 { } 305 306 void ordentv(machine_config &config); 307 308 void init_ordentv(); 309 310 protected: 311 312 uint16_t ordentv_portc_r(offs_t offset, uint16_t mem_mask = ~0); 313 private: 314 }; 315 316 class spg2xx_game_hotwheels_state : public spg2xx_game_state 317 { 318 public: spg2xx_game_hotwheels_state(const machine_config & mconfig,device_type type,const char * tag)319 spg2xx_game_hotwheels_state(const machine_config &mconfig, device_type type, const char *tag) : 320 spg2xx_game_state(mconfig, type, tag), 321 m_porta_dat_hot(0xffff), 322 m_io_p1_extra(*this, "P1EXTRA") 323 { } 324 325 void hotwheels(machine_config &config); 326 327 protected: 328 329 uint16_t hotwheels_porta_r(offs_t offset, uint16_t mem_mask = ~0); 330 virtual void porta_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0) override; 331 332 private: 333 334 uint16_t m_porta_dat_hot; 335 required_ioport m_io_p1_extra; 336 }; 337 338 339 340 #endif // MAME_INCLUDES_SPG2XX_H 341