1 // license:BSD-3-Clause 2 // copyright-holders:Mirko Buffoni, Nicola Salmoria, Tomasz Slanina 3 #ifndef MAME_INCLUDES_SUPERQIX_H 4 #define MAME_INCLUDES_SUPERQIX_H 5 6 #pragma once 7 8 #include "cpu/mcs51/mcs51.h" 9 #include "cpu/m6805/m68705.h" 10 #include "sound/ay8910.h" 11 #include "sound/samples.h" 12 #include "emupal.h" 13 #include "tilemap.h" 14 15 class superqix_state_base : public driver_device 16 { 17 public: superqix_state_base(const machine_config & mconfig,device_type type,const char * tag)18 superqix_state_base(const machine_config &mconfig, device_type type, const char *tag) 19 : driver_device(mconfig, type, tag) 20 , m_maincpu(*this,"maincpu") 21 , m_mcu(*this, "mcu") 22 , m_spriteram(*this, "spriteram") 23 , m_videoram(*this, "videoram") 24 , m_bitmapram(*this, "bitmapram") 25 , m_bitmapram2(*this, "bitmapram2") 26 , m_gfxdecode(*this, "gfxdecode") 27 , m_palette(*this, "palette") 28 , m_ay1(*this, "ay1") 29 { } 30 31 void init_perestro(); 32 void init_sqix(); 33 void init_sqixr0(); 34 void init_pbillian(); 35 void init_hotsmash(); 36 37 TILE_GET_INFO_MEMBER(sqix_get_bg_tile_info); 38 39 protected: 40 required_device<cpu_device> m_maincpu; 41 optional_device<cpu_device> m_mcu; 42 required_shared_ptr<uint8_t> m_spriteram; 43 required_shared_ptr<uint8_t> m_videoram; 44 optional_shared_ptr<uint8_t> m_bitmapram; 45 optional_shared_ptr<uint8_t> m_bitmapram2; 46 required_device<gfxdecode_device> m_gfxdecode; 47 required_device<palette_device> m_palette; 48 required_device<ay8910_device> m_ay1; 49 50 // commmon 68705/8751/HLE 51 uint8_t m_from_mcu; // byte latch for 68705/8751->z80 comms 52 uint8_t m_from_z80; // byte latch for z80->68705/8751 comms 53 bool m_z80_has_written; // z80 has written to latch flag 54 bool m_mcu_has_written; // 68705/8751 has written to latch flag 55 56 //general machine stuff 57 bool m_invert_coin_lockout; 58 bool m_invert_p2_spinner; 59 int m_gfxbank; 60 bool m_show_bitmap; 61 bool m_nmi_mask; 62 63 std::unique_ptr<bitmap_ind16> m_fg_bitmap[2]; 64 tilemap_t *m_bg_tilemap; 65 66 uint8_t nmi_ack_r(); 67 void superqix_videoram_w(offs_t offset, uint8_t data); 68 void superqix_bitmapram_w(offs_t offset, uint8_t data); 69 void superqix_bitmapram2_w(offs_t offset, uint8_t data); 70 void superqix_0410_w(uint8_t data); 71 72 DECLARE_VIDEO_START(superqix); 73 static rgb_t BBGGRRII(uint32_t raw); 74 uint32_t screen_update_superqix(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 75 void superqix_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect); 76 77 void main_map(address_map &map); 78 79 virtual void machine_init_common(); 80 }; 81 82 83 class superqix_state : public superqix_state_base 84 { 85 public: superqix_state(const machine_config & mconfig,device_type type,const char * tag)86 superqix_state(const machine_config &mconfig, device_type type, const char *tag) 87 : superqix_state_base(mconfig, type, tag) 88 , m_ay2(*this, "ay2") 89 { 90 } 91 92 void sqix(machine_config &config); 93 void sqix_8031(machine_config &config); 94 void sqix_nomcu(machine_config &config); 95 96 DECLARE_READ_LINE_MEMBER(fromz80_semaphore_input_r); 97 DECLARE_READ_LINE_MEMBER(frommcu_semaphore_input_r); 98 99 protected: 100 virtual void machine_start() override; 101 virtual void video_start() override; 102 103 private: 104 required_device<ay8910_device> m_ay2; 105 106 // 8031 and/or 8751 MCU related 107 uint8_t m_bl_port1; 108 uint8_t m_bl_fake_port2; 109 uint8_t m_port2_raw; 110 uint8_t m_bl_port3_out; 111 112 uint8_t z80_semaphore_assert_r(); 113 void bootleg_mcu_port1_w(uint8_t data); 114 void mcu_port2_w(uint8_t data); 115 void mcu_port3_w(u8 data); 116 uint8_t mcu_port3_r(); 117 uint8_t bootleg_mcu_port3_r(); 118 void bootleg_mcu_port3_w(uint8_t data); 119 void z80_ay1_sync_address_w(uint8_t data); 120 uint8_t z80_ay2_iob_r(); 121 void z80_ay2_iob_w(uint8_t data); 122 void bootleg_flipscreen_w(uint8_t data); 123 uint8_t bootleg_in0_r(); 124 INTERRUPT_GEN_MEMBER(sqix_timer_irq); 125 DECLARE_MACHINE_RESET(superqix); 126 127 void sqix_port_map(address_map &map); 128 void sqix_8031_map(address_map &map); 129 130 virtual void machine_init_common() override; 131 132 TIMER_CALLBACK_MEMBER(z80_semaphore_assert_cb); 133 TIMER_CALLBACK_MEMBER(mcu_port2_w_cb); 134 TIMER_CALLBACK_MEMBER(mcu_port3_w_cb); 135 TIMER_CALLBACK_MEMBER(z80_ay1_sync_address_w_cb); 136 TIMER_CALLBACK_MEMBER(z80_ay2_iob_w_cb); 137 TIMER_CALLBACK_MEMBER(bootleg_mcu_port1_w_cb); 138 }; 139 140 141 class hotsmash_state : public superqix_state_base 142 { 143 public: hotsmash_state(const machine_config & mconfig,device_type type,const char * tag)144 hotsmash_state(const machine_config &mconfig, device_type type, const char *tag) 145 : superqix_state_base(mconfig, type, tag) 146 , m_dsw(*this, "DSW%u", 1) 147 , m_dials(*this, "DIAL%u", 1) 148 , m_plungers(*this, "PLUNGER%u", 1) 149 , m_launchbtns(*this, "LAUNCH%u", 1) 150 , m_samples(*this, "samples") 151 , m_samples_region(*this, "samples") 152 , m_samplebuf() 153 , m_portb_out(0xff) 154 , m_portc_out(0xff) 155 , m_dial_oldpos{ 0, 0 } 156 , m_dial_sign{ 0, 0 } 157 { 158 } 159 160 void pbillian(machine_config &config); 161 void pbillianb(machine_config &config); 162 163 DECLARE_CUSTOM_INPUT_MEMBER(pbillian_semaphore_input_r); 164 165 protected: 166 virtual void machine_start() override; 167 virtual void video_start() override; 168 169 private: 170 u8 hotsmash_68705_porta_r(); 171 void hotsmash_68705_portb_w(u8 data); 172 void hotsmash_68705_portc_w(u8 data); 173 void hotsmash_z80_mcu_w(u8 data); 174 u8 hotsmash_z80_mcu_r(); 175 176 void pbillian_sample_trigger_w(u8 data); 177 void pbillian_0410_w(u8 data); 178 179 DECLARE_WRITE_LINE_MEMBER(vblank_irq); 180 181 SAMPLES_START_CB_MEMBER(pbillian_sh_start); 182 183 TILE_GET_INFO_MEMBER(pb_get_bg_tile_info); 184 185 u32 screen_update_pbillian(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 186 187 void pbillian_port_map(address_map &map); 188 void pbillianb_port_map(address_map &map); 189 190 virtual void machine_init_common() override; 191 192 int read_inputs(int player); 193 194 void pbillian_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); 195 196 required_ioport_array<2> m_dsw; 197 optional_ioport_array<2> m_dials; 198 optional_ioport_array<2> m_plungers; 199 optional_ioport_array<2> m_launchbtns; 200 optional_device<samples_device> m_samples; 201 optional_region_ptr<u8> m_samples_region; 202 203 std::unique_ptr<s16[]> m_samplebuf; 204 205 // 68705 related 206 u8 m_porta_in; 207 u8 m_portb_out; 208 u8 m_portc_out; 209 210 // spinner quadrature stuff 211 int m_dial_oldpos[2]; 212 int m_dial_sign[2]; 213 }; 214 215 #endif // MAME_INCLUDES_SUPERQIX_H 216