1 // license:BSD-3-Clause 2 // copyright-holders:Luca Elia 3 #ifndef MAME_INCLUDES_CISCHEAT_H 4 #define MAME_INCLUDES_CISCHEAT_H 5 6 #pragma once 7 8 // TODO: better inheritance, eventually split individual driver files 9 10 #include "sound/okim6295.h" 11 #include "machine/gen_latch.h" 12 #include "machine/ticket.h" 13 #include "machine/timer.h" 14 #include "machine/watchdog.h" 15 #include "video/ms1_tmap.h" 16 #include "emupal.h" 17 #include "screen.h" 18 19 class cischeat_state : public driver_device 20 { 21 public: cischeat_state(const machine_config & mconfig,device_type type,const char * tag)22 cischeat_state(const machine_config &mconfig, device_type type, const char *tag) 23 : driver_device(mconfig, type, tag) 24 , m_tmap(*this, "scroll%u", 0) 25 , m_ram(*this, "ram") 26 , m_roadram(*this, "roadram.%u", 0) 27 , m_f1gpstr2_ioready(*this, "ioready") 28 , m_maincpu(*this, "maincpu") 29 , m_cpu1(*this, "cpu1") 30 , m_cpu2(*this, "cpu2") 31 , m_cpu3(*this, "cpu3") 32 , m_cpu5(*this, "cpu5") 33 , m_soundcpu(*this, "soundcpu") 34 , m_screen(*this, "screen") 35 , m_watchdog(*this, "watchdog") 36 , m_oki1(*this, "oki1") 37 , m_oki2(*this, "oki2") 38 , m_gfxdecode(*this, "gfxdecode") 39 , m_palette(*this, "palette") 40 , m_soundlatch(*this, "soundlatch") 41 , m_soundlatch2(*this, "soundlatch2") 42 , m_leds(*this, "led%u", 0U) 43 {} 44 45 void scudhamm_motor_command_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 46 void scudhamm_leds_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 47 void scudhamm_enable_w(uint16_t data); 48 void scudhamm_oki_bank_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 49 void bigrun_soundbank_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 50 uint16_t scudhamm_motor_status_r(); 51 uint16_t scudhamm_motor_pos_r(); 52 uint8_t scudhamm_analog_r(); 53 uint16_t bigrun_ip_select_r(); 54 void leds_out_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 55 void unknown_out_w(uint16_t data); 56 void motor_out_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 57 void wheel_out_w(uint16_t data); 58 void ip_select_w(uint16_t data); 59 void ip_select_plus1_w(uint16_t data); 60 void bigrun_comms_w(uint16_t data); 61 void active_layers_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 62 uint16_t cischeat_ip_select_r(); 63 void cischeat_soundlatch_w(uint16_t data); 64 void cischeat_comms_w(uint16_t data); 65 uint16_t f1gpstar_wheel_r(); 66 uint16_t f1gpstr2_ioready_r(); 67 uint16_t wildplt_xy_r(); 68 uint16_t wildplt_mux_r(); 69 void wildplt_mux_w(uint16_t data); 70 void f1gpstar_motor_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 71 void f1gpstar_soundint_w(uint16_t data); 72 void f1gpstar_comms_w(uint16_t data); 73 void f1gpstr2_io_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 74 void cischeat_soundbank_1_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 75 void cischeat_soundbank_2_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 76 DECLARE_WRITE_LINE_MEMBER(sound_irq); 77 void init_cischeat(); 78 void init_bigrun(); 79 void init_f1gpstar(); 80 uint32_t screen_update_bigrun(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 81 uint32_t screen_update_scudhamm(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 82 uint32_t screen_update_cischeat(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 83 uint32_t screen_update_f1gpstar(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 84 TIMER_DEVICE_CALLBACK_MEMBER(bigrun_scanline); 85 TIMER_DEVICE_CALLBACK_MEMBER(scudhamm_scanline); 86 void prepare_shadows(); 87 void cischeat_draw_road(bitmap_ind16 &bitmap, const rectangle &cliprect, int road_num, int priority1, int priority2, int transparency); 88 void f1gpstar_draw_road(bitmap_ind16 &bitmap, const rectangle &cliprect, int road_num, int priority1, int priority2, int transparency); 89 void cischeat_draw_sprites(bitmap_ind16 &bitmap , const rectangle &cliprect, int priority1, int priority2); 90 void bigrun_draw_sprites(bitmap_ind16 &bitmap , const rectangle &cliprect, int priority1, int priority2); 91 void cischeat_untangle_sprites(const char *region); 92 93 void scudhamm(machine_config &config); 94 void cischeat(machine_config &config); 95 void f1gpstr2(machine_config &config); 96 void f1gpstar(machine_config &config); 97 void bigrun(machine_config &config); 98 void bigrun_map(address_map &map); 99 void bigrun_map2(address_map &map); 100 void bigrun_map3(address_map &map); 101 void bigrun_sound_map(address_map &map); 102 void cischeat_map(address_map &map); 103 void cischeat_map2(address_map &map); 104 void cischeat_map3(address_map &map); 105 void cischeat_sound_map(address_map &map); 106 void f1gpstar_map(address_map &map); 107 void f1gpstar_map2(address_map &map); 108 void f1gpstar_map3(address_map &map); 109 void f1gpstar_sound_map(address_map &map); 110 void f1gpstr2_io_map(address_map &map); 111 void f1gpstr2_map(address_map &map); 112 void f1gpstr2_sound_map(address_map &map); 113 void scudhamm_map(address_map &map); 114 115 protected: machine_start()116 virtual void machine_start() override { m_leds.resolve(); } 117 virtual void video_start() override; 118 119 optional_device_array<megasys1_tilemap_device, 3> m_tmap; 120 required_shared_ptr<uint16_t> m_ram; 121 optional_shared_ptr_array<uint16_t,2> m_roadram; 122 optional_shared_ptr<uint16_t> m_f1gpstr2_ioready; 123 124 uint16_t *m_objectram; 125 uint16_t m_active_layers; 126 127 int m_prev; 128 uint16_t m_scudhamm_motor_command; 129 int m_ip_select; 130 uint16_t m_wildplt_output; 131 uint8_t m_drawmode_table[16]; 132 int m_debugsprites; 133 int m_show_unknown; 134 uint16_t *m_spriteram; 135 136 uint8_t m_motor_value; 137 uint8_t m_io_value; 138 139 // TODO: make these to have a more meaningful name 140 optional_device<cpu_device> m_maincpu; 141 optional_device<cpu_device> m_cpu1; 142 optional_device<cpu_device> m_cpu2; 143 optional_device<cpu_device> m_cpu3; 144 optional_device<cpu_device> m_cpu5; 145 optional_device<cpu_device> m_soundcpu; 146 required_device<screen_device> m_screen; 147 optional_device<watchdog_timer_device> m_watchdog; 148 required_device<okim6295_device> m_oki1; 149 required_device<okim6295_device> m_oki2; 150 required_device<gfxdecode_device> m_gfxdecode; 151 required_device<palette_device> m_palette; 152 optional_device<generic_latch_16_device> m_soundlatch; 153 optional_device<generic_latch_16_device> m_soundlatch2; 154 155 output_finder<5> m_leds; 156 }; 157 158 class armchamp2_state : public cischeat_state 159 { 160 public: armchamp2_state(const machine_config & mconfig,device_type type,const char * tag)161 armchamp2_state(const machine_config &mconfig, device_type type, const char *tag) 162 : cischeat_state(mconfig, type, tag) 163 { 164 m_arm_motor_command = 0; 165 m_armold = 0; 166 } 167 168 uint16_t motor_status_r(); 169 void motor_command_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 170 uint8_t analog_r(); 171 void output_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 172 173 void armchmp2(machine_config &config); 174 void armchmp2_map(address_map &map); 175 TIMER_DEVICE_CALLBACK_MEMBER(armchamp2_scanline); 176 DECLARE_CUSTOM_INPUT_MEMBER(left_sensor_r); 177 DECLARE_CUSTOM_INPUT_MEMBER(right_sensor_r); 178 DECLARE_CUSTOM_INPUT_MEMBER(center_sensor_r); 179 180 private: 181 u16 m_arm_motor_command; 182 int m_armold; 183 }; 184 185 class wildplt_state : public cischeat_state 186 { 187 public: wildplt_state(const machine_config & mconfig,device_type type,const char * tag)188 wildplt_state(const machine_config &mconfig, device_type type, const char *tag) 189 : cischeat_state(mconfig, type, tag) 190 {} 191 192 uint16_t *m_buffer_spriteram; 193 std::unique_ptr<uint16_t[]> m_allocated_spriteram; 194 void wildplt_map(address_map &map); 195 void wildplt(machine_config &config); 196 void sprite_dma_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 197 198 protected: 199 virtual void video_start() override; 200 201 private: 202 uint16_t m_sprite_dma_reg; 203 }; 204 205 class captflag_state : public cischeat_state 206 { 207 public: captflag_state(const machine_config & mconfig,device_type type,const char * tag)208 captflag_state(const machine_config &mconfig, device_type type, const char *tag) 209 : cischeat_state(mconfig, type, tag) 210 , m_hopper(*this, "hopper") 211 , m_motor_left(*this, "motor_left") 212 , m_motor_right(*this, "motor_right") 213 , m_oki1_bank(*this, "oki1_bank") 214 , m_oki2_bank(*this, "oki2_bank") 215 { 216 for (int side = 0; side < 2; ++side) 217 m_motor_command[side] = m_motor_pos[side] = 0; 218 m_captflag_leds = 0; 219 } 220 221 void captflag(machine_config &config); 222 template <int N> DECLARE_READ_LINE_MEMBER(motor_busy_r); 223 template <int N> DECLARE_CUSTOM_INPUT_MEMBER(motor_pos_r); 224 void init_captflag(); 225 226 private: 227 void motor_command_right_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 228 void motor_command_left_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 229 void motor_move(int side, uint16_t data); 230 void oki_bank_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 231 232 void leds_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 233 234 TIMER_DEVICE_CALLBACK_MEMBER(captflag_scanline); 235 236 void captflag_map(address_map &map); 237 void oki1_map(address_map &map); 238 void oki2_map(address_map &map); 239 240 required_device<ticket_dispenser_device> m_hopper; 241 242 required_device<timer_device> m_motor_left; 243 required_device<timer_device> m_motor_right; 244 245 required_memory_bank m_oki1_bank; 246 required_memory_bank m_oki2_bank; 247 248 uint16_t m_captflag_leds; 249 uint16_t m_motor_command[2]; 250 uint16_t m_motor_pos[2]; 251 }; 252 253 #endif 254