|
3 | 3 | #include "emu.h"
|
4 | 4 | #include "konami.h"
|
5 | 5 |
|
| 6 | +#include "machine/intelfsh.h" |
| 7 | + |
6 | 8 | #include "sound/k051649.h"
|
7 | 9 | #include "sound/vlm5030.h"
|
8 | 10 | #include "sound/dac.h"
|
@@ -199,6 +201,142 @@ void msx_cart_konami_scc_device::bank_w(u8 data)
|
199 | 201 |
|
200 | 202 |
|
201 | 203 |
|
| 204 | +class msx_cart_sunrise_scc_device : public device_t, public msx_cart_interface |
| 205 | +{ |
| 206 | +public: |
| 207 | + msx_cart_sunrise_scc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) |
| 208 | + : device_t(mconfig, MSX_CART_SUNRISE_SCC, tag, owner, clock) |
| 209 | + , msx_cart_interface(mconfig, *this) |
| 210 | + , m_k051649(*this, "k051649") |
| 211 | + , m_flash(*this, "flash") |
| 212 | + , m_scc_view(*this, "scc_view") |
| 213 | + { } |
| 214 | + |
| 215 | + virtual std::error_condition initialize_cartridge(std::string &message) override; |
| 216 | + |
| 217 | +protected: |
| 218 | + // device_t implementation |
| 219 | + virtual void device_start() override { save_item(NAME(m_selected_bank)); } |
| 220 | + virtual void device_reset() override; |
| 221 | + |
| 222 | + virtual const tiny_rom_entry *device_rom_region() const override; |
| 223 | + virtual void device_add_mconfig(machine_config &config) override; |
| 224 | + |
| 225 | +private: |
| 226 | + template <int Bank> u8 flash_r(offs_t offset); |
| 227 | + template <int Bank> void flash_w(offs_t offset, u8 data); |
| 228 | + template <int Bank> void bank_w(offs_t offset, u8 data); |
| 229 | + |
| 230 | + required_device<k051649_device> m_k051649; |
| 231 | + required_device<intelfsh8_device> m_flash; |
| 232 | + memory_view m_scc_view; |
| 233 | + |
| 234 | + u8 m_selected_bank[4]; |
| 235 | +}; |
| 236 | + |
| 237 | +ROM_START(msx_cart_sunrise_scc) |
| 238 | + ROM_REGION(0x80000, "flash", ROMREGION_ERASEFF) |
| 239 | +ROM_END |
| 240 | + |
| 241 | +const tiny_rom_entry *msx_cart_sunrise_scc_device::device_rom_region() const |
| 242 | +{ |
| 243 | + return ROM_NAME(msx_cart_sunrise_scc); |
| 244 | +} |
| 245 | + |
| 246 | +void msx_cart_sunrise_scc_device::device_add_mconfig(machine_config &config) |
| 247 | +{ |
| 248 | + K051649(config, m_k051649, DERIVED_CLOCK(1, 1)); |
| 249 | + if (parent_slot()) |
| 250 | + m_k051649->add_route(ALL_OUTPUTS, soundin(), 0.4); |
| 251 | + |
| 252 | + AMD_29F040(config, m_flash); |
| 253 | +} |
| 254 | + |
| 255 | +void msx_cart_sunrise_scc_device::device_reset() |
| 256 | +{ |
| 257 | + m_scc_view.select(0); |
| 258 | + for (int i = 0; i < 4; i++) |
| 259 | + m_selected_bank[i] = i; |
| 260 | +} |
| 261 | + |
| 262 | +std::error_condition msx_cart_sunrise_scc_device::initialize_cartridge(std::string &message) |
| 263 | +{ |
| 264 | + if (!cart_rom_region()) |
| 265 | + { |
| 266 | + message = "msx_cart_sunrise_scc_device: Required region 'rom' was not found."; |
| 267 | + return image_error::INTERNAL; |
| 268 | + } |
| 269 | + |
| 270 | + const u32 size = cart_rom_region()->bytes(); |
| 271 | + if (size != 0x80000) |
| 272 | + { |
| 273 | + message = "msx_cart_sunrise_scc_device: Region 'rom' has unsupported size."; |
| 274 | + return image_error::INVALIDLENGTH; |
| 275 | + } |
| 276 | + |
| 277 | + u8 *flash = memregion("flash")->base(); |
| 278 | + memcpy(flash, cart_rom_region()->base(), size); |
| 279 | + |
| 280 | + page(0)->install_read_handler(0x0000, 0x1fff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::flash_r<2>))); |
| 281 | + page(0)->install_write_handler(0x0000, 0x1fff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::flash_w<2>))); |
| 282 | + page(0)->install_read_handler(0x2000, 0x3fff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::flash_r<3>))); |
| 283 | + page(0)->install_write_handler(0x2000, 0x3fff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::flash_w<3>))); |
| 284 | + page(1)->install_read_handler(0x4000, 0x5fff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::flash_r<0>))); |
| 285 | + page(1)->install_write_handler(0x4000, 0x5fff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::bank_w<0>))); |
| 286 | + page(1)->install_read_handler(0x6000, 0x7fff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::flash_r<1>))); |
| 287 | + page(1)->install_write_handler(0x6000, 0x7fff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::bank_w<1>))); |
| 288 | + page(2)->install_view(0x8000, 0x9fff, m_scc_view); |
| 289 | + m_scc_view[0].install_read_handler(0x8000, 0x9fff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::flash_r<2>))); |
| 290 | + m_scc_view[0].install_write_handler(0x8000, 0x97ff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::bank_w<2>))); |
| 291 | + m_scc_view[1].install_read_handler(0x8000, 0x97ff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::flash_r<2>))); |
| 292 | + m_scc_view[1].install_write_handler(0x8000, 0x97ff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::bank_w<2>))); |
| 293 | + m_scc_view[1].install_read_handler(0x9800, 0x987f, 0, 0x0700, 0, emu::rw_delegate(m_k051649, FUNC(k051649_device::k051649_waveform_r))); |
| 294 | + m_scc_view[1].install_write_handler(0x9800, 0x987f, 0, 0x0700, 0, emu::rw_delegate(m_k051649, FUNC(k051649_device::k051649_waveform_w))); |
| 295 | + m_scc_view[1].install_write_handler(0x9880, 0x9889, 0, 0x0710, 0, emu::rw_delegate(m_k051649, FUNC(k051649_device::k051649_frequency_w))); |
| 296 | + m_scc_view[1].install_write_handler(0x988a, 0x988e, 0, 0x0710, 0, emu::rw_delegate(m_k051649, FUNC(k051649_device::k051649_volume_w))); |
| 297 | + m_scc_view[1].install_write_handler(0x988f, 0x988f, 0, 0x0710, 0, emu::rw_delegate(m_k051649, FUNC(k051649_device::k051649_keyonoff_w))); |
| 298 | + m_scc_view[1].install_read_handler(0x98e0, 0x98e0, 0, 0x071f, 0, emu::rw_delegate(m_k051649, FUNC(k051649_device::k051649_test_r))); |
| 299 | + m_scc_view[1].install_write_handler(0x98e0, 0x98e0, 0, 0x071f, 0, emu::rw_delegate(m_k051649, FUNC(k051649_device::k051649_test_w))); |
| 300 | + page(2)->install_read_handler(0xa000, 0xbfff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::flash_r<3>))); |
| 301 | + page(2)->install_write_handler(0xa000, 0xbfff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::bank_w<3>))); |
| 302 | + page(3)->install_read_handler(0xc000, 0xdfff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::flash_r<0>))); |
| 303 | + page(3)->install_write_handler(0xc000, 0xdfff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::flash_w<0>))); |
| 304 | + page(3)->install_read_handler(0xe000, 0xffff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::flash_r<1>))); |
| 305 | + page(3)->install_write_handler(0xe000, 0xffff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::flash_w<1>))); |
| 306 | + |
| 307 | + return std::error_condition(); |
| 308 | +} |
| 309 | + |
| 310 | +template <int Bank> |
| 311 | +u8 msx_cart_sunrise_scc_device::flash_r(offs_t offset) |
| 312 | +{ |
| 313 | + return m_flash->read(m_selected_bank[Bank] * 0x2000 + offset); |
| 314 | +} |
| 315 | + |
| 316 | +template <int Bank> |
| 317 | +void msx_cart_sunrise_scc_device::flash_w(offs_t offset, u8 data) |
| 318 | +{ |
| 319 | + m_flash->write(m_selected_bank[Bank] * 0x2000 + offset, data); |
| 320 | +} |
| 321 | + |
| 322 | +template <int Bank> |
| 323 | +void msx_cart_sunrise_scc_device::bank_w(offs_t offset, u8 data) |
| 324 | +{ |
| 325 | + if ((offset & 0x1800) == 0x1000) |
| 326 | + { |
| 327 | + m_selected_bank[Bank] = data & 0x3f; |
| 328 | + if (Bank == 2) |
| 329 | + m_scc_view.select(((data & 0x3f) == 0x3f) ? 1 : 0); |
| 330 | + } |
| 331 | + else |
| 332 | + m_flash->write(m_selected_bank[Bank] * 0x2000 + offset, data); |
| 333 | +} |
| 334 | + |
| 335 | + |
| 336 | + |
| 337 | + |
| 338 | + |
| 339 | + |
202 | 340 | class msx_cart_gamemaster2_device : public device_t, public msx_cart_interface
|
203 | 341 | {
|
204 | 342 | public:
|
@@ -817,6 +955,7 @@ void msx_cart_ec701_device::bank_w(u8 data)
|
817 | 955 |
|
818 | 956 | DEFINE_DEVICE_TYPE_PRIVATE(MSX_CART_KONAMI, msx_cart_interface, msx_cart_konami_device, "msx_cart_konami", "MSX Cartridge - KONAMI")
|
819 | 957 | DEFINE_DEVICE_TYPE_PRIVATE(MSX_CART_KONAMI_SCC, msx_cart_interface, msx_cart_konami_scc_device, "msx_cart_konami_scc", "MSX Cartridge - KONAMI+SCC")
|
| 958 | +DEFINE_DEVICE_TYPE_PRIVATE(MSX_CART_SUNRISE_SCC, msx_cart_interface, msx_cart_sunrise_scc_device, "msx_cart_sunrise_scc", "MSX Cartridge - Sunrise+SCC") |
820 | 959 | DEFINE_DEVICE_TYPE_PRIVATE(MSX_CART_GAMEMASTER2, msx_cart_interface, msx_cart_gamemaster2_device, "msx_cart_gamemaster2", "MSX Cartridge - GAMEMASTER2")
|
821 | 960 | DEFINE_DEVICE_TYPE_PRIVATE(MSX_CART_SYNTHESIZER, msx_cart_interface, msx_cart_synthesizer_device, "msx_cart_synthesizer", "MSX Cartridge - Synthesizer")
|
822 | 961 | DEFINE_DEVICE_TYPE_PRIVATE(MSX_CART_SOUND_SNATCHER, msx_cart_interface, msx_cart_konami_sound_snatcher_device, "msx_cart_sound_snatcher", "MSX Cartridge - Sound Snatcher")
|
|
0 commit comments