1 // license:BSD-3-Clause 2 // copyright-holders:Chris Moore, Nicola Salmoria 3 #ifndef MAME_INCLUDES_BUBLBOBL_H 4 #define MAME_INCLUDES_BUBLBOBL_H 5 6 #pragma once 7 8 #include "cpu/m6805/m68705.h" 9 #include "cpu/mcs48/mcs48.h" 10 #include "machine/input_merger.h" 11 #include "machine/gen_latch.h" 12 #include "sound/2203intf.h" 13 #include "sound/3526intf.h" 14 #include "emupal.h" 15 #include "screen.h" 16 17 #include "machine/taito68705interface.h" 18 19 20 class bublbobl_state : public driver_device 21 { 22 public: 23 enum 24 { 25 TIMER_M68705_IRQ_ACK 26 }; 27 bublbobl_state(const machine_config & mconfig,device_type type,const char * tag)28 bublbobl_state(const machine_config &mconfig, device_type type, const char *tag) 29 : driver_device(mconfig, type, tag) 30 , m_videoram(*this, "videoram") 31 , m_objectram(*this, "objectram") 32 , m_mcu_sharedram(*this, "mcu_sharedram") 33 , m_maincpu(*this, "maincpu") 34 , m_mcu(*this, "mcu") 35 , m_audiocpu(*this, "audiocpu") 36 , m_subcpu(*this, "subcpu") 37 , m_screen(*this, "screen") 38 , m_gfxdecode(*this, "gfxdecode") 39 , m_palette(*this, "palette") 40 , m_ym2203(*this, "ym2203") 41 , m_ym3526(*this, "ym3526") 42 , m_soundirq(*this, "soundirq") 43 , m_soundnmi(*this, "soundnmi") 44 , m_main_to_sound(*this, "main_to_sound") 45 , m_sound_to_main(*this, "sound_to_main") 46 { } 47 48 /* memory pointers */ 49 required_shared_ptr<uint8_t> m_videoram; 50 required_shared_ptr<uint8_t> m_objectram; 51 optional_shared_ptr<uint8_t> m_mcu_sharedram; 52 53 /* video-related */ 54 bool m_video_enable; 55 56 /* sound-related */ 57 int m_sreset_old; 58 59 /* mcu-related */ 60 61 /* Bubble Bobble MCU */ 62 uint8_t m_ddr1; 63 uint8_t m_ddr2; 64 uint8_t m_ddr3; 65 uint8_t m_ddr4; 66 uint8_t m_port1_in; 67 uint8_t m_port2_in; 68 uint8_t m_port3_in; 69 uint8_t m_port4_in; 70 uint8_t m_port1_out; 71 uint8_t m_port2_out; 72 uint8_t m_port3_out; 73 uint8_t m_port4_out; 74 /* Bobble Bobble */ 75 int m_ic43_a; 76 int m_ic43_b; 77 78 /* devices */ 79 required_device<cpu_device> m_maincpu; 80 optional_device<cpu_device> m_mcu; 81 required_device<cpu_device> m_audiocpu; 82 required_device<cpu_device> m_subcpu; 83 required_device<screen_device> m_screen; 84 required_device<gfxdecode_device> m_gfxdecode; 85 required_device<palette_device> m_palette; 86 optional_device<ym2203_device> m_ym2203; 87 optional_device<ym3526_device> m_ym3526; 88 optional_device<input_merger_device> m_soundirq; 89 required_device<input_merger_device> m_soundnmi; 90 required_device<generic_latch_8_device> m_main_to_sound; 91 required_device<generic_latch_8_device> m_sound_to_main; 92 93 94 void common_sreset(int state); 95 void bublbobl_bankswitch_w(uint8_t data); 96 void tokio_bankswitch_w(uint8_t data); 97 void tokio_videoctrl_w(uint8_t data); 98 void bublbobl_nmitrigger_w(uint8_t data); 99 uint8_t tokiob_mcu_r(); 100 void bublbobl_soundcpu_reset_w(uint8_t data); 101 uint8_t common_sound_semaphores_r(); 102 uint8_t bublbobl_mcu_ddr1_r(); 103 void bublbobl_mcu_ddr1_w(uint8_t data); 104 uint8_t bublbobl_mcu_ddr2_r(); 105 void bublbobl_mcu_ddr2_w(uint8_t data); 106 uint8_t bublbobl_mcu_ddr3_r(); 107 void bublbobl_mcu_ddr3_w(uint8_t data); 108 uint8_t bublbobl_mcu_ddr4_r(); 109 void bublbobl_mcu_ddr4_w(uint8_t data); 110 uint8_t bublbobl_mcu_port1_r(); 111 void bublbobl_mcu_port1_w(uint8_t data); 112 uint8_t bublbobl_mcu_port2_r(); 113 void bublbobl_mcu_port2_w(uint8_t data); 114 uint8_t bublbobl_mcu_port3_r(); 115 void bublbobl_mcu_port3_w(uint8_t data); 116 uint8_t bublbobl_mcu_port4_r(); 117 void bublbobl_mcu_port4_w(uint8_t data); 118 uint8_t boblbobl_ic43_a_r(offs_t offset); 119 void boblbobl_ic43_a_w(offs_t offset, uint8_t data); 120 void boblbobl_ic43_b_w(offs_t offset, uint8_t data); 121 uint8_t boblbobl_ic43_b_r(offs_t offset); 122 123 void init_dland(); 124 void init_common(); 125 DECLARE_MACHINE_START(tokio); 126 DECLARE_MACHINE_RESET(tokio); 127 DECLARE_MACHINE_START(bublbobl); 128 DECLARE_MACHINE_RESET(bublbobl); 129 DECLARE_MACHINE_START(boblbobl); 130 DECLARE_MACHINE_RESET(boblbobl); 131 DECLARE_MACHINE_START(common); 132 DECLARE_MACHINE_RESET(common); 133 uint32_t screen_update_bublbobl(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 134 void configure_banks(); 135 136 void tokio(machine_config &config); 137 void boblbobl(machine_config &config); 138 void bublbobl(machine_config &config); 139 void bublbobl_nomcu(machine_config &config); 140 void bublboblp(machine_config &config); 141 void tokiob(machine_config &config); 142 void bootleg_map(address_map &map); 143 void bublbobl_maincpu_map(address_map &map); 144 void common_maincpu_map(address_map &map); 145 void mcu_map(address_map &map); 146 void sound_map(address_map &map); 147 void subcpu_map(address_map &map); 148 void tokio_map(address_map &map); 149 void tokio_map_bootleg(address_map &map); 150 void tokio_map_mcu(address_map &map); 151 void tokio_sound_map(address_map &map); 152 void tokio_subcpu_map(address_map &map); 153 protected: 154 virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; 155 }; 156 157 158 class bub68705_state : public bublbobl_state 159 { 160 public: bub68705_state(const machine_config & mconfig,device_type type,const char * tag)161 bub68705_state(const machine_config &mconfig, device_type type, const char *tag) 162 : bublbobl_state(mconfig, type, tag) 163 , m_mcu(*this, "mcu") 164 , m_mux_ports(*this, { "DSW0", "DSW1", "IN1", "IN2" }) 165 , m_port_a_out(0xff) 166 , m_port_b_out(0xff) 167 , m_address(0) 168 , m_latch(0) 169 { 170 } 171 172 void port_a_w(uint8_t data); 173 void port_b_w(offs_t offset, uint8_t data, uint8_t mem_mask = ~0); 174 175 INTERRUPT_GEN_MEMBER(bublbobl_m68705_interrupt); 176 177 DECLARE_MACHINE_START(bub68705); 178 DECLARE_MACHINE_RESET(bub68705); 179 180 void bub68705(machine_config &config); 181 protected: 182 required_device<m68705p_device> m_mcu; 183 required_ioport_array<4> m_mux_ports; 184 185 uint8_t m_port_a_out; 186 uint8_t m_port_b_out; 187 uint16_t m_address; 188 uint8_t m_latch; 189 }; 190 191 192 class bub8749_state : public bublbobl_state 193 { 194 public: bub8749_state(const machine_config & mconfig,device_type type,const char * tag)195 bub8749_state(const machine_config &mconfig, device_type type, const char *tag) 196 : bublbobl_state(mconfig, type, tag) 197 , m_mcu(*this, "mcu") 198 { 199 } 200 201 void bub8749(machine_config &config); 202 203 protected: 204 required_device<i8749_device> m_mcu; 205 }; 206 207 #endif // MAME_INCLUDES_BUBLBOBL_H 208