diff options
Diffstat (limited to 'src/mame/old/neogeo_slot.cpp')
-rw-r--r-- | src/mame/old/neogeo_slot.cpp | 206 |
1 files changed, 206 insertions, 0 deletions
diff --git a/src/mame/old/neogeo_slot.cpp b/src/mame/old/neogeo_slot.cpp new file mode 100644 index 00000000000..5844025bb68 --- /dev/null +++ b/src/mame/old/neogeo_slot.cpp @@ -0,0 +1,206 @@ +// license:BSD-3-Clause +// copyright-holders:S. Smith,David Haywood +/*********************************************************************************************************** + + ***********************************************************************************************************/ + + +#include "emu.h" +#include "neogeo_slot.h" + +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +const device_type NEOGEO_CART_SLOT = device_creator<neogeo_cart_slot_device>; + + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// neogeo_cart_slot_device - constructor +//------------------------------------------------- +neogeo_cart_slot_device::neogeo_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint16_t clock) : + device_t(mconfig, NEOGEO_CART_SLOT, "NeoGeo Cartridge Slot", tag, owner, clock, "neogeo_cart_slot", __FILE__), + device_image_interface(mconfig, *this), + device_slot_interface(mconfig, *this), + m_cart(nullptr) +{ +} + + +//------------------------------------------------- +// neogeo_cart_slot_device - destructor +//------------------------------------------------- + +neogeo_cart_slot_device::~neogeo_cart_slot_device() +{ +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void neogeo_cart_slot_device::device_start() +{ + m_cart = dynamic_cast<device_neogeo_cart_interface *>(get_card_device()); +} + +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- + + + +/*------------------------------------------------- + call load + -------------------------------------------------*/ + + +image_init_result neogeo_cart_slot_device::call_load() +{ + if (m_cart) + { + uint16_t *ROM; + uint8_t* ROM8; + uint32_t len; + + if (software_entry() != nullptr) + { + // create memory regions + len = get_software_region_length("maincpu"); + m_cart->rom_alloc(len); ROM = m_cart->get_rom_base(); + memcpy(ROM, get_software_region("maincpu"), len); + + len = get_software_region_length("fixed"); + m_cart->fixed_alloc(len); ROM8 = m_cart->get_fixed_base(); + memcpy(ROM8, get_software_region("fixed"), len); + + if (get_software_region("audiocpu") != nullptr) + { + len = get_software_region_length("audiocpu"); + m_cart->audio_alloc(len + 0x10000); ROM8 = m_cart->get_audio_base(); + memcpy(ROM8, get_software_region("audiocpu"), len); + memcpy(ROM8 + 0x10000, get_software_region("audiocpu"), len); // avoid reloading in XML, should just improve banking instead tho? + } + + len = get_software_region_length("ymsnd"); + m_cart->ym_alloc(len); ROM8 = m_cart->get_ym_base(); + memcpy(ROM8, get_software_region("ymsnd"), len); + + if (get_software_region("ymsnd.deltat") != nullptr) + { + len = get_software_region_length("ymsnd.deltat"); + m_cart->ymdelta_alloc(len); ROM8 = m_cart->get_ymdelta_base(); + memcpy(ROM8, get_software_region("ymsnd.deltat"), len); + } + else + { + // ensure there is no delta-t region + } + + + len = get_software_region_length("sprites"); + m_cart->sprites_alloc(len); ROM8 = m_cart->get_sprites_base(); + memcpy(ROM8, get_software_region("sprites"), len); + + if (get_software_region("audiocrypt") != nullptr) // encrypted Z80 code + { + len = get_software_region_length("audiocrypt"); + m_cart->audiocrypt_alloc(len); ROM8 = m_cart->get_audiocrypt_base(); + memcpy(ROM8, get_software_region("audiocrypt"), len); + // allocate the audiocpu region to decrypt data into + m_cart->audio_alloc(len + 0x10000); + } + + m_cart->decrypt_all( + (uint8_t*)m_cart->get_rom_base(), m_cart->get_rom_size(), + m_cart->get_sprites_base(), m_cart->get_sprites_size(), + m_cart->get_fixed_base(), m_cart->get_fixed_size(), + m_cart->get_ym_base(), m_cart->get_ym_size(), + m_cart->get_ymdelta_base(), m_cart->get_ymdelta_size(), + m_cart->get_audio_base(), m_cart->get_audio_size(), + m_cart->get_audiocrypt_base(), m_cart->get_audiocrypt_size()); + + + // create optimized sprite cache + m_cart->m_sprite_gfx_address_mask = neogeohelper_optimize_sprite_data(m_cart->get_sprites_optimized_arr(), m_cart->get_sprites_base(), m_cart->get_sprites_size()); + + + return image_init_result::PASS; + } + } + + return image_init_result::PASS; +} + +void neogeo_cart_slot_device::setup_memory_banks(running_machine &machine) +{ + uint16_t* base16 = get_rom_base(); + uint32_t size = get_rom_size(); + machine.memory().region_free(":maincpu"); + machine.memory().region_alloc(":maincpu",size,2, ENDIANNESS_BIG); + memcpy(memregion(":maincpu")->base(),(uint8_t*)base16,size); + + uint8_t* base = get_audio_base(); + size = get_audio_size(); + machine.memory().region_free(":audiocpu"); + machine.memory().region_alloc(":audiocpu",size,1, ENDIANNESS_LITTLE); + memcpy(memregion(":audiocpu")->base(),base,size); + + + base = get_ym_base(); + size = get_ym_size(); + + machine.memory().region_free(":ymsnd"); + machine.memory().region_alloc(":ymsnd",size,1, ENDIANNESS_LITTLE); + memcpy(memregion(":ymsnd")->base(),base,size); + + + base = get_ymdelta_base(); + size = get_ymdelta_size(); + machine.memory().region_free(":ymsnd.deltat"); + + if(base) + { + machine.memory().region_alloc(":ymsnd.deltat",size,1, ENDIANNESS_LITTLE); + memcpy(memregion(":ymsnd.deltat")->base(),base,size); + } + + +} + +/*------------------------------------------------- + call_unload + -------------------------------------------------*/ + +void neogeo_cart_slot_device::call_unload() +{ +} + + +/*------------------------------------------------- + get default card software + -------------------------------------------------*/ + +std::string neogeo_cart_slot_device::get_default_card_software() +{ + return software_get_default_slot("rom"); +} + +/*------------------------------------------------- + read + -------------------------------------------------*/ + +READ16_MEMBER(neogeo_cart_slot_device::read_rom) +{ + if (m_cart) + return m_cart->read_rom(space, offset, mem_mask); + else + return 0xffff; +} |