1 // license:BSD-3-Clause 2 // copyright-holders:Aaron Giles 3 /************************************************************************* 4 5 Cinemat/Leland driver 6 7 *************************************************************************/ 8 #ifndef MAME_INCLUDES_LELAND_H 9 #define MAME_INCLUDES_LELAND_H 10 11 #pragma once 12 13 #include "machine/eepromser.h" 14 #include "sound/dac.h" 15 #include "sound/ay8910.h" 16 #include "emupal.h" 17 #include "screen.h" 18 #include "tilemap.h" 19 20 #define LELAND_BATTERY_RAM_SIZE 0x4000 21 #define ATAXX_EXTRA_TRAM_SIZE 0x800 22 23 24 struct vram_state_data 25 { 26 u16 m_addr; 27 u8 m_latch[2]; 28 }; 29 30 class leland_80186_sound_device; 31 32 class leland_state : public driver_device 33 { 34 public: leland_state(const machine_config & mconfig,device_type type,const char * tag)35 leland_state(const machine_config &mconfig, device_type type, const char *tag) 36 : driver_device(mconfig, type, tag) 37 , m_master(*this, "master") 38 , m_slave(*this, "slave") 39 , m_mainram(*this, "mainram") 40 , m_master_bankslot(*this, "masterbank_%u", 0U) 41 , m_master_base(*this, "master") 42 , m_slave_bankslot(*this, "slavebank") 43 , m_slave_base(*this, "slave") 44 , m_eeprom(*this, "eeprom") 45 , m_battery_ram(*this, "battery") 46 , m_palette(*this, "palette") 47 , m_screen(*this, "screen") 48 , m_gfxdecode(*this, "gfxdecode") 49 , m_io_in(*this, "IN%u", 0U) 50 , m_io_an(*this, "AN%u", 0U) 51 , m_dac(*this, "dac%u", 0U) 52 , m_ay8910(*this, "ay8910") 53 , m_ay8912(*this, "ay8912") 54 , m_bg_gfxrom(*this, "bg_gfx") 55 , m_bg_prom(*this, "bg_prom") 56 { } 57 58 void leland(machine_config &config); 59 void leland_video(machine_config &config); 60 61 void init_dblplay(); 62 void init_dangerz(); 63 void init_mayhem(); 64 void init_alleymas(); 65 void init_strkzone(); 66 void init_wseries(); 67 void init_powrplay(); 68 void init_basebal2(); 69 void init_upyoural(); 70 void init_cerberus(); 71 72 void cerberus_bankswitch(); 73 void mayhem_bankswitch(); 74 void dangerz_bankswitch(); 75 void basebal2_bankswitch(); 76 void redline_bankswitch(); 77 78 void offroad_bankswitch(); 79 void viper_bankswitch(); 80 81 u8 raster_r(); 82 void slave_video_addr_w(offs_t offset, u8 data); 83 void slave_large_banksw_w(u8 data); 84 void master_video_addr_w(offs_t offset, u8 data); 85 86 TIMER_CALLBACK_MEMBER(ataxx_interrupt_callback); 87 88 protected: 89 required_device<cpu_device> m_master; 90 required_device<cpu_device> m_slave; 91 required_shared_ptr<u8> m_mainram; 92 required_memory_bank_array<2> m_master_bankslot; 93 required_region_ptr<u8> m_master_base; 94 required_memory_bank m_slave_bankslot; 95 required_region_ptr<u8> m_slave_base; 96 required_device<eeprom_serial_93cxx_device> m_eeprom; 97 required_shared_ptr<u8> m_battery_ram; 98 required_device<palette_device> m_palette; 99 required_device<screen_device> m_screen; 100 required_device<gfxdecode_device> m_gfxdecode; 101 102 optional_ioport_array<4> m_io_in; 103 optional_ioport_array<6> m_io_an; 104 105 emu_timer *m_master_int_timer; 106 u8 m_battery_ram_enable; 107 108 void rotate_memory(const char *cpuname); 109 110 int dial_compute_value(int new_val, int indx); 111 u8 m_dial_last_input[4]; 112 u8 m_dial_last_result[4]; 113 u8 m_analog_result; 114 115 int m_dangerz_x; 116 int m_dangerz_y; 117 118 void init_master_ports(u8 mvram_base, u8 io_base); 119 void (leland_state::*m_update_master_bank)(); 120 121 int vram_port_r(offs_t offset, int num); 122 void vram_port_w(offs_t offset, u8 data, int num); 123 124 u8 m_wcol_enable; 125 126 u8 master_analog_key_r(offs_t offset); 127 void master_analog_key_w(offs_t offset, u8 data); 128 u8 dangerz_input_y_r(); 129 u8 dangerz_input_x_r(); 130 u8 dangerz_input_upper_r(); 131 void scroll_w(offs_t offset, u8 data); 132 void leland_master_alt_bankswitch_w(u8 data); 133 134 tilemap_t *m_tilemap; 135 u16 m_xscroll; 136 u16 m_yscroll; 137 std::unique_ptr<u8[]> m_video_ram; 138 struct vram_state_data m_vram_state[2]; 139 140 void slave_map_program(address_map &map); 141 142 TIMER_CALLBACK_MEMBER(leland_delayed_mvram_w); 143 144 private: 145 optional_device_array<dac_byte_interface, 2> m_dac; 146 optional_device<ay8910_device> m_ay8910; 147 optional_device<ay8912_device> m_ay8912; 148 149 required_region_ptr<u8> m_bg_gfxrom; 150 optional_region_ptr<u8> m_bg_prom; 151 152 u8 m_dac_control; 153 u8 *m_alleymas_kludge_mem; 154 u8 m_gfx_control; 155 u8 m_keycard_shift; 156 u8 m_keycard_bit; 157 u8 m_keycard_state; 158 u8 m_keycard_clock; 159 u8 m_keycard_command[3]; 160 u8 m_top_board_bank; 161 u8 m_sound_port_bank; 162 u8 m_alternate_bank; 163 u8 m_gfxbank; 164 u16 m_last_scanline; 165 emu_timer *m_scanline_timer; 166 167 u8 cerberus_dial_1_r(); 168 u8 cerberus_dial_2_r(); 169 void alleymas_joystick_kludge(u8 data); 170 void leland_battery_ram_w(offs_t offset, u8 data); 171 u8 leland_master_input_r(offs_t offset); 172 void leland_master_output_w(offs_t offset, u8 data); 173 void gated_paletteram_w(offs_t offset, u8 data); 174 u8 gated_paletteram_r(offs_t offset); 175 void slave_small_banksw_w(u8 data); 176 void ataxx_slave_banksw_w(u8 data); 177 void leland_mvram_port_w(offs_t offset, u8 data); 178 u8 leland_mvram_port_r(offs_t offset); 179 void leland_svram_port_w(offs_t offset, u8 data); 180 u8 leland_svram_port_r(offs_t offset); 181 u8 sound_port_r(); 182 void sound_port_w(u8 data); 183 void gfx_port_w(u8 data); 184 185 virtual void machine_start() override; 186 virtual void machine_reset() override; 187 virtual void video_start() override; 188 189 TILEMAP_MAPPER_MEMBER(leland_scan); 190 TILE_GET_INFO_MEMBER(leland_get_tile_info); 191 u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 192 INTERRUPT_GEN_MEMBER(leland_master_interrupt); 193 TIMER_CALLBACK_MEMBER(leland_interrupt_callback); 194 TIMER_CALLBACK_MEMBER(scanline_callback); 195 196 void video_addr_w(offs_t offset, u8 data, int num); 197 198 void update_dangerz_xy(); 199 200 void leland_init_eeprom(u8 default_val, const u16 *data, u8 serial_offset, u8 serial_type); 201 void ataxx_init_eeprom(const u16 *data); 202 int keycard_r(); 203 void keycard_w(int data); 204 void master_map_io(address_map &map); 205 void master_map_program(address_map &map); 206 void slave_map_io(address_map &map); 207 void slave_small_map_program(address_map &map); 208 }; 209 210 211 class redline_state : public leland_state 212 { 213 public: redline_state(const machine_config & mconfig,device_type type,const char * tag)214 redline_state(const machine_config &mconfig, device_type type, const char *tag) 215 : leland_state(mconfig, type, tag) 216 , m_sound(*this, "custom") 217 { 218 } 219 220 void init_redlin2p(); 221 void init_quarterb(); 222 void init_viper(); 223 void init_teamqb(); 224 void init_aafb(); 225 void init_aafbb(); 226 void init_aafbd2p(); 227 void init_offroad(); 228 void init_offroadt(); 229 void init_pigout(); 230 231 void redline(machine_config &config); 232 void quarterb(machine_config &config); 233 void lelandi(machine_config &config); 234 235 private: 236 u8 redline_pedal_1_r(); 237 u8 redline_pedal_2_r(); 238 u8 redline_wheel_1_r(); 239 u8 redline_wheel_2_r(); 240 u8 offroad_wheel_1_r(); 241 u8 offroad_wheel_2_r(); 242 u8 offroad_wheel_3_r(); 243 void redline_master_alt_bankswitch_w(u8 data); 244 245 void master_redline_map_io(address_map &map); 246 void slave_large_map_program(address_map &map); 247 248 required_device<leland_80186_sound_device> m_sound; 249 }; 250 251 252 class ataxx_state : public leland_state 253 { 254 public: ataxx_state(const machine_config & mconfig,device_type type,const char * tag)255 ataxx_state(const machine_config &mconfig, device_type type, const char *tag) 256 : leland_state(mconfig, type, tag) 257 , m_sound(*this, "custom") 258 , m_xrom_base(*this, "xrom") 259 { 260 } 261 262 void init_ataxx(); 263 void init_ataxxj(); 264 void init_wsf(); 265 void init_indyheat(); 266 void init_brutforc(); 267 void init_asylum(); 268 269 void ataxx(machine_config &config); 270 void wsf(machine_config &config); 271 272 private: 273 u8 ataxx_trackball_r(offs_t offset); 274 u8 indyheat_analog_r(offs_t offset); 275 void indyheat_analog_w(offs_t offset, u8 data); 276 277 void ataxx_battery_ram_w(offs_t offset, u8 data); 278 u8 ataxx_master_input_r(offs_t offset); 279 void ataxx_master_output_w(offs_t offset, u8 data); 280 void paletteram_and_misc_w(offs_t offset, u8 data); 281 u8 paletteram_and_misc_r(offs_t offset); 282 void ataxx_mvram_port_w(offs_t offset, u8 data); 283 void ataxx_svram_port_w(offs_t offset, u8 data); 284 u8 ataxx_mvram_port_r(offs_t offset); 285 u8 ataxx_svram_port_r(offs_t offset); 286 u8 eeprom_r(); 287 void eeprom_w(u8 data); 288 289 TILEMAP_MAPPER_MEMBER(ataxx_scan); 290 TILE_GET_INFO_MEMBER(ataxx_get_tile_info); 291 292 void ataxx_bankswitch(); 293 294 virtual void machine_start() override; 295 virtual void machine_reset() override; 296 virtual void video_start() override; 297 298 void ataxx_video(machine_config &config); 299 300 void master_map_program_2(address_map &map); 301 void master_map_io_2(address_map &map); 302 void slave_map_io_2(address_map &map); 303 304 required_device<leland_80186_sound_device> m_sound; 305 306 required_region_ptr<u8> m_xrom_base; 307 308 std::unique_ptr<u8[]> m_ataxx_qram; 309 u8 m_master_bank; 310 u32 m_xrom1_addr; 311 u32 m_xrom2_addr; 312 std::unique_ptr<u8[]> m_extra_tram; 313 }; 314 315 316 #define SERIAL_TYPE_NONE 0 317 #define SERIAL_TYPE_ADD 1 318 #define SERIAL_TYPE_ADD_XOR 2 319 #define SERIAL_TYPE_ENCRYPT 3 320 #define SERIAL_TYPE_ENCRYPT_XOR 4 321 322 #endif // MAME_INCLUDES_LELAND_H 323