From eb6223426dcc0f7de76e322c0cbeab9f89d01586 Mon Sep 17 00:00:00 2001 From: mooglyguy Date: Thu, 17 Jan 2019 18:54:51 +0100 Subject: -vsmile: Added proper slot device emulation for the cartridge slot. Gets vsmile techart fully working. [Ryan Holtz] -vsmileb: Found enough port bits to show the VTech logo and V.Smile Baby intro. No game boots yet. [Ryan Holtz] -spg2xx: Added separate logging for external interrupts and address mapping. [Ryan Holtz] --- hash/vsmile_cart.xml | 115 +++++++++++++++- scripts/src/bus.lua | 14 ++ scripts/target/mame/arcade.lua | 1 + scripts/target/mame/mess.lua | 1 + src/devices/bus/vsmile/rom.cpp | 75 ++++++++++ src/devices/bus/vsmile/rom.h | 54 ++++++++ src/devices/bus/vsmile/vsmile_slot.cpp | 245 +++++++++++++++++++++++++++++++++ src/devices/bus/vsmile/vsmile_slot.h | 119 ++++++++++++++++ src/devices/machine/spg2xx.cpp | 22 +-- src/mame/drivers/vsmile.cpp | 95 +++++-------- 10 files changed, 665 insertions(+), 76 deletions(-) create mode 100644 src/devices/bus/vsmile/rom.cpp create mode 100644 src/devices/bus/vsmile/rom.h create mode 100644 src/devices/bus/vsmile/vsmile_slot.cpp create mode 100644 src/devices/bus/vsmile/vsmile_slot.h diff --git a/hash/vsmile_cart.xml b/hash/vsmile_cart.xml index c79f01ad82a..06da389ca49 100644 --- a/hash/vsmile_cart.xml +++ b/hash/vsmile_cart.xml @@ -111,7 +111,7 @@ Game cartridges +========+===================+============================================================================+ | | 80-090260(US) | Disney Fairies: Tinker Bell | | | (DK) | Disney Fairies: Tingeling | -| | 80-090274(SE) | Disney Fairies: Tingeling | +| XX | 80-090274(SE) | Disney Fairies: Tingeling | | | 80-090275(NO) | Disney Fairies: Tingeling | | | (FI) | Disney Fairies: Helinä-keiju | +========+===================+============================================================================+ @@ -170,7 +170,7 @@ Game cartridges | | 80-092086(PT) | Mickey - A Aventura Mágica de Mickey (EAN is 3417768920964 cart 92096) | | | 80-092087(SP) | Mickey - La Aventura Mágica de Mickey | | | (DK) | Mickey | -| | 80-092094(SE) | Musse Pigg - Musses magiska äventyr | +| XX | 80-092094(SE) | Musse Pigg - Musses magiska äventyr | | | (NO) | Mickey | | | (FI) | Mickey | +========+===================+============================================================================+ @@ -521,6 +521,7 @@ Game cartridges VTech + @@ -537,6 +538,7 @@ Game cartridges VTech + @@ -553,6 +555,7 @@ Game cartridges VTech + @@ -569,6 +572,7 @@ Game cartridges VTech + @@ -585,6 +589,7 @@ Game cartridges VTech + @@ -601,6 +606,7 @@ Game cartridges VTech + @@ -617,6 +623,7 @@ Game cartridges VTech + @@ -633,6 +640,7 @@ Game cartridges VTech + @@ -649,6 +657,7 @@ Game cartridges VTech + @@ -665,6 +674,7 @@ Game cartridges VTech + @@ -680,6 +690,7 @@ Game cartridges 2005 VTech / Giochi Preziosi + @@ -692,6 +703,7 @@ Game cartridges VTech + @@ -709,6 +721,7 @@ Game cartridges VTech + @@ -725,6 +738,7 @@ Game cartridges VTech + @@ -741,6 +755,7 @@ Game cartridges VTech + @@ -757,6 +772,7 @@ Game cartridges VTech + @@ -774,6 +790,7 @@ Game cartridges VTech + @@ -790,6 +807,7 @@ Game cartridges VTech + @@ -806,6 +824,7 @@ Game cartridges VTech + @@ -822,6 +841,7 @@ Game cartridges VTech + @@ -839,6 +859,7 @@ Game cartridges + @@ -855,6 +876,7 @@ Game cartridges VTech + @@ -871,6 +893,7 @@ Game cartridges VTech + @@ -883,6 +906,7 @@ Game cartridges VTech / Giochi Preziosi + @@ -895,6 +919,7 @@ Game cartridges VTech + @@ -911,6 +936,7 @@ Game cartridges VTech + @@ -927,6 +953,7 @@ Game cartridges VTech + @@ -943,6 +970,7 @@ Game cartridges VTech + @@ -959,6 +987,7 @@ Game cartridges VTech + @@ -975,6 +1004,7 @@ Game cartridges VTech + @@ -988,6 +1018,7 @@ Game cartridges VTech + @@ -1004,6 +1035,7 @@ Game cartridges VTech + @@ -1020,6 +1052,7 @@ Game cartridges VTech + @@ -1036,6 +1069,7 @@ Game cartridges VTech + @@ -1052,6 +1086,7 @@ Game cartridges VTech + @@ -1068,6 +1103,7 @@ Game cartridges VTech + @@ -1084,6 +1120,7 @@ Game cartridges VTech + @@ -1100,6 +1137,7 @@ Game cartridges VTech + @@ -1116,6 +1154,7 @@ Game cartridges VTech + @@ -1132,6 +1171,7 @@ Game cartridges VTech + @@ -1148,6 +1188,7 @@ Game cartridges VTech + @@ -1164,6 +1205,7 @@ Game cartridges VTech + @@ -1180,6 +1222,7 @@ Game cartridges VTech + @@ -1196,6 +1239,7 @@ Game cartridges VTech + @@ -1212,6 +1256,7 @@ Game cartridges VTech + @@ -1228,6 +1273,7 @@ Game cartridges VTech + @@ -1244,6 +1290,7 @@ Game cartridges VTech / Giochi Preziosi + @@ -1256,6 +1303,7 @@ Game cartridges VTech + @@ -1268,6 +1316,7 @@ Game cartridges VTech + @@ -1284,6 +1333,7 @@ Game cartridges VTech + @@ -1300,6 +1350,7 @@ Game cartridges VTech + @@ -1316,6 +1367,7 @@ Game cartridges VTech + @@ -1332,6 +1384,7 @@ Game cartridges VTech + @@ -1348,6 +1401,7 @@ Game cartridges VTech + @@ -1364,6 +1418,7 @@ Game cartridges VTech + @@ -1380,6 +1435,7 @@ Game cartridges VTech + @@ -1396,6 +1452,7 @@ Game cartridges VTech + @@ -1412,6 +1469,7 @@ Game cartridges VTech + @@ -1428,6 +1486,7 @@ Game cartridges VTech + @@ -1444,6 +1503,7 @@ Game cartridges VTech + @@ -1460,6 +1520,7 @@ Game cartridges VTech + @@ -1476,6 +1537,7 @@ Game cartridges VTech + @@ -1492,6 +1554,7 @@ Game cartridges VTech + @@ -1504,6 +1567,7 @@ Game cartridges VTech + @@ -1520,6 +1584,7 @@ Game cartridges VTech + @@ -1535,6 +1600,7 @@ Game cartridges 2007 VTech + @@ -1547,6 +1613,7 @@ Game cartridges VTech + @@ -1563,6 +1630,7 @@ Game cartridges VTech + @@ -1579,6 +1647,7 @@ Game cartridges VTech + @@ -1595,6 +1664,7 @@ Game cartridges VTech + @@ -1611,6 +1681,7 @@ Game cartridges VTech + @@ -1626,6 +1697,7 @@ Game cartridges 200? VTech / Giochi Preziosi + @@ -1638,6 +1710,7 @@ Game cartridges VTech + @@ -1654,6 +1727,7 @@ Game cartridges VTech + @@ -1670,6 +1744,7 @@ Game cartridges VTech + @@ -1686,6 +1761,7 @@ Game cartridges VTech + @@ -1702,6 +1778,7 @@ Game cartridges VTech + @@ -1718,6 +1795,7 @@ Game cartridges VTech + @@ -1734,6 +1812,7 @@ Game cartridges VTech + @@ -1750,6 +1829,7 @@ Game cartridges VTech + @@ -1766,6 +1846,7 @@ Game cartridges VTech + @@ -1782,6 +1863,7 @@ Game cartridges VTech + @@ -1798,6 +1880,7 @@ Game cartridges VTech + @@ -1814,6 +1897,7 @@ Game cartridges VTech + @@ -1830,6 +1914,7 @@ Game cartridges VTech + @@ -1846,6 +1931,7 @@ Game cartridges VTech + @@ -1862,6 +1948,7 @@ Game cartridges VTech + @@ -1878,6 +1965,7 @@ Game cartridges VTech + @@ -1894,6 +1982,7 @@ Game cartridges VTech + @@ -1910,6 +1999,7 @@ Game cartridges VTech + @@ -1926,6 +2016,7 @@ Game cartridges VTech + @@ -1942,6 +2033,7 @@ Game cartridges VTech + @@ -1954,6 +2046,7 @@ Game cartridges VTech + @@ -1970,6 +2063,7 @@ Game cartridges VTech + @@ -1986,6 +2080,7 @@ Game cartridges VTech + @@ -2002,6 +2097,7 @@ Game cartridges VTech + @@ -2018,6 +2114,7 @@ Game cartridges VTech + @@ -2034,6 +2131,7 @@ Game cartridges VTech + @@ -2050,6 +2148,7 @@ Game cartridges VTech + @@ -2066,6 +2165,7 @@ Game cartridges VTech + @@ -2082,6 +2182,7 @@ Game cartridges VTech + @@ -2098,6 +2199,7 @@ Game cartridges VTech + @@ -2115,6 +2217,7 @@ Game cartridges VTech + @@ -2131,6 +2234,7 @@ Game cartridges VTech + @@ -2150,6 +2254,7 @@ Game cartridges VTech + @@ -2169,6 +2274,7 @@ Game cartridges VTech + @@ -2181,6 +2287,7 @@ Game cartridges VTech + @@ -2197,6 +2304,7 @@ Game cartridges VTech + @@ -2213,6 +2321,7 @@ Game cartridges VTech + @@ -2225,6 +2334,7 @@ Game cartridges VTech + @@ -2241,6 +2351,7 @@ Game cartridges VTech + diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua index 5350a2d510a..bb729f34c3c 100644 --- a/scripts/src/bus.lua +++ b/scripts/src/bus.lua @@ -3268,6 +3268,20 @@ if (BUSES["UTS_KBD"]~=null) then } end +--------------------------------------------------- +-- +--@src/devices/bus/vsmile/vsmile_slot.h,BUSES["VSMILE"] = true +--------------------------------------------------- + +if (BUSES["VSMILE"]~=null) then + files { + MAME_DIR .. "src/devices/bus/vsmile/vsmile_slot.cpp", + MAME_DIR .. "src/devices/bus/vsmile/vsmile_slot.h", + MAME_DIR .. "src/devices/bus/vsmile/rom.cpp", + MAME_DIR .. "src/devices/bus/vsmile/rom.h", + } +end + --------------------------------------------------- -- --@src/devices/bus/vtech/memexp/memexp.h,BUSES["VTECH_MEMEXP"] = true diff --git a/scripts/target/mame/arcade.lua b/scripts/target/mame/arcade.lua index 597cd9a5755..68086de2aa5 100644 --- a/scripts/target/mame/arcade.lua +++ b/scripts/target/mame/arcade.lua @@ -742,6 +742,7 @@ BUSES["VECTREX"] = true --BUSES["VIDBRAIN"] = true --BUSES["VIP"] = true --BUSES["VME"] = true +--BUSES["VSMILE"] = true --BUSES["VTECH_IOEXP"] = true --BUSES["VTECH_MEMEXP"] = true --BUSES["WANGPC"] = true diff --git a/scripts/target/mame/mess.lua b/scripts/target/mame/mess.lua index 89e17e9853b..484ffa695ef 100644 --- a/scripts/target/mame/mess.lua +++ b/scripts/target/mame/mess.lua @@ -823,6 +823,7 @@ BUSES["VIC20"] = true BUSES["VIDBRAIN"] = true BUSES["VIP"] = true BUSES["VME"] = true +BUSES["VSMILE"] = true BUSES["VTECH_IOEXP"] = true BUSES["VTECH_MEMEXP"] = true BUSES["WANGPC"] = true diff --git a/src/devices/bus/vsmile/rom.cpp b/src/devices/bus/vsmile/rom.cpp new file mode 100644 index 00000000000..627b93f56c1 --- /dev/null +++ b/src/devices/bus/vsmile/rom.cpp @@ -0,0 +1,75 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz +/*********************************************************************************************************** + + V.Smile cart emulation + + We support standard carts and one with on-board RAM + + ***********************************************************************************************************/ + + +#include "emu.h" +#include "rom.h" + + +//------------------------------------------------- +// vsmile_rom_device - constructor +//------------------------------------------------- + +DEFINE_DEVICE_TYPE(VSMILE_ROM_STD, vsmile_rom_device, "vsmile_rom", "V.Smile Cart") +DEFINE_DEVICE_TYPE(VSMILE_ROM_RAM, vsmile_rom_ram_device, "vsmile_rom_ram", "V.Smile Cart + RAM") + + +vsmile_rom_device::vsmile_rom_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, type, tag, owner, clock) + , device_vsmile_cart_interface(mconfig, *this) +{ +} + +vsmile_rom_device::vsmile_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : vsmile_rom_device(mconfig, VSMILE_ROM_STD, tag, owner, clock) +{ +} + +vsmile_rom_ram_device::vsmile_rom_ram_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) + : vsmile_rom_device(mconfig, type, tag, owner, clock) +{ +} + +vsmile_rom_ram_device::vsmile_rom_ram_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : vsmile_rom_ram_device(mconfig, VSMILE_ROM_RAM, tag, owner, clock) +{ +} + + +//------------------------------------------------- +// mapper specific start/reset +//------------------------------------------------- + +void vsmile_rom_device::device_start() +{ +} + +void vsmile_rom_device::device_reset() +{ +} + + +/*------------------------------------------------- + Carts with RAM + -------------------------------------------------*/ + +READ16_MEMBER(vsmile_rom_ram_device::bank2_r) +{ + if (!m_ram.empty() && offset < m_ram.size()) + return m_ram[offset]; + else // this cannot actually happen... + return 0; +} + +WRITE16_MEMBER(vsmile_rom_ram_device::bank2_w) +{ + if (!m_ram.empty() && offset < m_ram.size()) + COMBINE_DATA(&m_ram[offset]); +} diff --git a/src/devices/bus/vsmile/rom.h b/src/devices/bus/vsmile/rom.h new file mode 100644 index 00000000000..18208b6c4c7 --- /dev/null +++ b/src/devices/bus/vsmile/rom.h @@ -0,0 +1,54 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz +#ifndef MAME_BUS_VSMILE_ROM_H +#define MAME_BUS_VSMILE_ROM_H + +#pragma once + +#include "vsmile_slot.h" + +// ======================> vsmile_rom_device + +class vsmile_rom_device : public device_t, public device_vsmile_cart_interface +{ +public: + // construction/destruction + vsmile_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + + // reading and writing + virtual DECLARE_READ16_MEMBER(bank0_r) override { return m_rom[0x000000 + offset]; } + virtual DECLARE_READ16_MEMBER(bank1_r) override { return m_rom[0x100000 + offset]; } + virtual DECLARE_READ16_MEMBER(bank2_r) override { return m_rom[0x200000 + offset]; } + virtual DECLARE_READ16_MEMBER(bank3_r) override { return m_rom[0x300000 + offset]; } + +protected: + vsmile_rom_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); + + // device-level overrides + virtual void device_start() override; + virtual void device_reset() override; +}; + + +// ======================> vsmile_rom_ram_device + +class vsmile_rom_ram_device : public vsmile_rom_device +{ +public: + // construction/destruction + vsmile_rom_ram_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + + virtual DECLARE_READ16_MEMBER(bank2_r) override; + virtual DECLARE_WRITE16_MEMBER(bank2_w) override; + +protected: + vsmile_rom_ram_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); +}; + + +// device type definition +DECLARE_DEVICE_TYPE(VSMILE_ROM_STD, vsmile_rom_device) +DECLARE_DEVICE_TYPE(VSMILE_ROM_RAM, vsmile_rom_ram_device) + + +#endif // MAME_BUS_VSMILE_ROM_H diff --git a/src/devices/bus/vsmile/vsmile_slot.cpp b/src/devices/bus/vsmile/vsmile_slot.cpp new file mode 100644 index 00000000000..7e33578f00e --- /dev/null +++ b/src/devices/bus/vsmile/vsmile_slot.cpp @@ -0,0 +1,245 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz +/*********************************************************************************************************** + + V.Smile cart emulation + (through slot devices) + + ***********************************************************************************************************/ + + +#include "emu.h" +#include "vsmile_slot.h" + +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +DEFINE_DEVICE_TYPE(VSMILE_CART_SLOT, vsmile_cart_slot_device, "vsmile_cart_slot", "V.Smile Cartridge Slot") + +//************************************************************************** +// V.Smile cartridge interface +//************************************************************************** + +//------------------------------------------------- +// device_vsmile_cart_interface - constructor +//------------------------------------------------- + +device_vsmile_cart_interface::device_vsmile_cart_interface(const machine_config &mconfig, device_t &device) + : device_slot_card_interface(mconfig, device) + , m_rom(nullptr) + , m_rom_size(0) +{ +} + + +//------------------------------------------------- +// ~device_vsmile_cart_interface - destructor +//------------------------------------------------- + +device_vsmile_cart_interface::~device_vsmile_cart_interface() +{ +} + +//------------------------------------------------- +// rom_alloc - alloc the space for the cart +//------------------------------------------------- + +void device_vsmile_cart_interface::rom_alloc(uint32_t size, const char *tag) +{ + if (m_rom == nullptr) + { + // We always alloc 8MB of ROM region + m_rom = (uint16_t *)device().machine().memory().region_alloc(std::string(tag).append(VSMILE_SLOT_ROM_REGION_TAG).c_str(), 0x800000, 2, ENDIANNESS_BIG)->base(); + m_rom_size = size; + } +} + + +//------------------------------------------------- +// ram_alloc - alloc the space for the ram +//------------------------------------------------- + +void device_vsmile_cart_interface::ram_alloc(uint32_t size) +{ + m_ram.resize(size / sizeof(uint16_t)); +} + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// vsmile_cart_slot_device - constructor +//------------------------------------------------- +vsmile_cart_slot_device::vsmile_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, VSMILE_CART_SLOT, tag, owner, clock), + device_image_interface(mconfig, *this), + device_slot_interface(mconfig, *this), + m_type(VSMILE_STD), + m_cart(nullptr) +{ +} + + +//------------------------------------------------- +// vsmile_cart_slot_device - destructor +//------------------------------------------------- + +vsmile_cart_slot_device::~vsmile_cart_slot_device() +{ +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void vsmile_cart_slot_device::device_start() +{ + m_cart = dynamic_cast(get_card_device()); +} + + +//------------------------------------------------- +// V.Smile PCB +//------------------------------------------------- + +struct vsmile_slot +{ + int pcb_id; + const char *slot_option; +}; + +// Here, we take the feature attribute from .xml (i.e. the PCB name) and we assign a unique ID to it +static const vsmile_slot slot_list[] = +{ + { VSMILE_STD, "vsmile_rom" }, + { VSMILE_SRAM, "vsmile_ram" }, +}; + +static int vsmile_get_pcb_id(const char *slot) +{ + for (auto & elem : slot_list) + { + if (!core_stricmp(elem.slot_option, slot)) + return elem.pcb_id; + } + + return 0; +} + +/*------------------------------------------------- + call load + -------------------------------------------------*/ + +image_init_result vsmile_cart_slot_device::call_load() +{ + if (m_cart) + { + uint32_t size = loaded_through_softlist() ? get_software_region_length("rom") : length(); + if (size > 0x800000) + { + seterror(IMAGE_ERROR_UNSPECIFIED, "Attempted loading a cart larger than 8MB"); + return image_init_result::FAIL; + } + + m_cart->rom_alloc(size, tag()); + uint8_t *rom = (uint8_t *)m_cart->get_rom_base(); + + if (!loaded_through_softlist()) + { + fread(rom, size); + m_type = VSMILE_STD; + } + else + { + const char *pcb_name = get_feature("slot"); + + memcpy(rom, get_software_region("rom"), size); + + if (pcb_name) + m_type = vsmile_get_pcb_id(pcb_name); + + osd_printf_info("V.Smile: Detected (XML) %s\n", pcb_name ? pcb_name : "NONE"); + } + + if (m_type == VSMILE_SRAM) + { + m_cart->ram_alloc(0x200000); + } + + return image_init_result::PASS; + } + + return image_init_result::PASS; +} + + +/*------------------------------------------------- + call_unload + -------------------------------------------------*/ + +void vsmile_cart_slot_device::call_unload() +{ +} + + +/*------------------------------------------------- + get default card software + -------------------------------------------------*/ + +std::string vsmile_cart_slot_device::get_default_card_software(get_default_card_software_hook &hook) const +{ + return software_get_default_slot("vsmile_rom"); +} + + +/*------------------------------------------------- + read + -------------------------------------------------*/ + +READ16_MEMBER(vsmile_cart_slot_device::bank0_r) +{ + return m_cart->bank0_r(space, offset, mem_mask); +} + +READ16_MEMBER(vsmile_cart_slot_device::bank1_r) +{ + return m_cart->bank1_r(space, offset, mem_mask); +} + +READ16_MEMBER(vsmile_cart_slot_device::bank2_r) +{ + return m_cart->bank2_r(space, offset, mem_mask); +} + +READ16_MEMBER(vsmile_cart_slot_device::bank3_r) +{ + return m_cart->bank3_r(space, offset, mem_mask); +} + + +/*------------------------------------------------- + write + -------------------------------------------------*/ + +WRITE16_MEMBER(vsmile_cart_slot_device::bank0_w) +{ + m_cart->bank0_w(space, offset, data, mem_mask); +} + +WRITE16_MEMBER(vsmile_cart_slot_device::bank1_w) +{ + m_cart->bank1_w(space, offset, data, mem_mask); +} + +WRITE16_MEMBER(vsmile_cart_slot_device::bank2_w) +{ + m_cart->bank2_w(space, offset, data, mem_mask); +} + +WRITE16_MEMBER(vsmile_cart_slot_device::bank3_w) +{ + m_cart->bank3_w(space, offset, data, mem_mask); +} diff --git a/src/devices/bus/vsmile/vsmile_slot.h b/src/devices/bus/vsmile/vsmile_slot.h new file mode 100644 index 00000000000..559d0185f93 --- /dev/null +++ b/src/devices/bus/vsmile/vsmile_slot.h @@ -0,0 +1,119 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz +#ifndef MAME_BUS_VSMILE_VSMILE_SLOT_H +#define MAME_BUS_VSMILE_VSMILE_SLOT_H + +#pragma once + +#include "softlist_dev.h" + + +/*************************************************************************** + TYPE DEFINITIONS + ***************************************************************************/ + +#define VSMILE_SLOT_ROM_REGION_TAG ":cart:rom" + +enum +{ + VSMILE_STD = 0, + VSMILE_SRAM +}; + +// ======================> device_vsmile_cart_interface + +class device_vsmile_cart_interface : public device_slot_card_interface +{ +public: + // construction/destruction + virtual ~device_vsmile_cart_interface(); + + // reading and writing + virtual DECLARE_READ16_MEMBER(bank0_r) { return 0; } + virtual DECLARE_READ16_MEMBER(bank1_r) { return 0; } + virtual DECLARE_READ16_MEMBER(bank2_r) { return 0; } + virtual DECLARE_READ16_MEMBER(bank3_r) { return 0; } + virtual DECLARE_WRITE16_MEMBER(bank0_w) { printf("0 %08x = %04x\n", offset, data); } + virtual DECLARE_WRITE16_MEMBER(bank1_w) { printf("1 %08x = %04x\n", offset, data); } + virtual DECLARE_WRITE16_MEMBER(bank2_w) { printf("2 %08x = %04x\n", offset, data); } + virtual DECLARE_WRITE16_MEMBER(bank3_w) { printf("3 %08x = %04x\n", offset, data); } + + void rom_alloc(uint32_t size, const char *tag); + void ram_alloc(uint32_t size); + uint16_t* get_rom_base() { return m_rom; } + uint16_t* get_ram_base() { return &m_ram[0]; } + uint32_t get_rom_size() { return m_rom_size; } + uint32_t get_ram_size() { return m_ram.size() * sizeof(uint16_t); } + void set_rom_size(uint32_t val) { m_rom_size = val; } + +protected: + device_vsmile_cart_interface(const machine_config &mconfig, device_t &device); + + // internal state + uint16_t *m_rom; // this points to the cart rom region + uint32_t m_rom_size; // this is the actual game size, not the rom region size! + std::vector m_ram; +}; + + +// ======================> vsmile_cart_slot_device + +class vsmile_cart_slot_device : public device_t, + public device_image_interface, + public device_slot_interface +{ +public: + // construction/destruction + template + vsmile_cart_slot_device(machine_config const &mconfig, char const *tag, device_t *owner, T &&opts, char const *dflt) + : vsmile_cart_slot_device(mconfig, tag, owner, (uint32_t)0) + { + option_reset(); + opts(*this); + set_default_option(dflt); + set_fixed(false); + } + vsmile_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + virtual ~vsmile_cart_slot_device(); + + // device-level overrides + virtual void device_start() override; + + // image-level overrides + virtual image_init_result call_load() override; + virtual void call_unload() override; + virtual const software_list_loader &get_software_list_loader() const override { return rom_software_list_loader::instance(); } + + uint32_t get_rom_size() { if (m_cart) return m_cart->get_rom_size(); return 0; } + + virtual iodevice_t image_type() const override { return IO_CARTSLOT; } + virtual bool is_readable() const override { return 1; } + virtual bool is_writeable() const override { return 0; } + virtual bool is_creatable() const override { return 0; } + virtual bool must_be_loaded() const override { return 1; } + virtual bool is_reset_on_load() const override { return 1; } + virtual const char *image_interface() const override { return "vsmile_cart"; } + virtual const char *file_extensions() const override { return "u1,u3,bin"; } + + // slot interface overrides + virtual std::string get_default_card_software(get_default_card_software_hook &hook) const override; + + // reading and writing + virtual DECLARE_READ16_MEMBER(bank0_r); + virtual DECLARE_READ16_MEMBER(bank1_r); + virtual DECLARE_READ16_MEMBER(bank2_r); + virtual DECLARE_READ16_MEMBER(bank3_r); + virtual DECLARE_WRITE16_MEMBER(bank0_w); + virtual DECLARE_WRITE16_MEMBER(bank1_w); + virtual DECLARE_WRITE16_MEMBER(bank2_w); + virtual DECLARE_WRITE16_MEMBER(bank3_w); + +protected: + int m_type; + device_vsmile_cart_interface* m_cart; +}; + +// device type definition +DECLARE_DEVICE_TYPE(VSMILE_CART_SLOT, vsmile_cart_slot_device) + +#endif // MAME_BUS_VSMILE_VSMILE_SLOT_H diff --git a/src/devices/machine/spg2xx.cpp b/src/devices/machine/spg2xx.cpp index 12f58b838f0..8115be0da32 100644 --- a/src/devices/machine/spg2xx.cpp +++ b/src/devices/machine/spg2xx.cpp @@ -43,6 +43,8 @@ DEFINE_DEVICE_TYPE(SPG28X, spg28x_device, "spg28x", "SPG280-series System-on-a-C #define LOG_UNKNOWN_PPU (1U << 24) #define LOG_FIQ (1U << 25) #define LOG_SIO (1U << 26) +#define LOG_EXT_MEM (1U << 27) +#define LOG_EXTINT (1U << 28) #define LOG_IO (LOG_IO_READS | LOG_IO_WRITES | LOG_IRQS | LOG_GPIO | LOG_UART | LOG_I2C | LOG_DMA | LOG_TIMERS | LOG_UNKNOWN_IO) #define LOG_CHANNELS (LOG_CHANNEL_READS | LOG_CHANNEL_WRITES) #define LOG_SPU (LOG_SPU_READS | LOG_SPU_WRITES | LOG_UNKNOWN_SPU | LOG_CHANNEL_READS | LOG_CHANNEL_WRITES \ @@ -1087,10 +1089,10 @@ READ16_MEMBER(spg2xx_device::io_r) if (m_uart_rx_available) { m_io_regs[0x31] &= ~0x0081; - logerror("UART Rx data is available, clearing bits\n"); + LOGMASKED(LOG_UART, "UART Rx data is available, clearing bits\n"); if (m_uart_rx_fifo_count) { - logerror("Remaining count %d, value %02x\n", m_uart_rx_fifo_count, m_uart_rx_fifo[m_uart_rx_fifo_start]); + LOGMASKED(LOG_UART, "Remaining count %d, value %02x\n", m_uart_rx_fifo_count, m_uart_rx_fifo[m_uart_rx_fifo_start]); m_io_regs[0x36] = m_uart_rx_fifo[m_uart_rx_fifo_start]; val = m_io_regs[0x36]; m_uart_rx_fifo_start = (m_uart_rx_fifo_start + 1) % ARRAY_LENGTH(m_uart_rx_fifo); @@ -1102,7 +1104,7 @@ READ16_MEMBER(spg2xx_device::io_r) } else { - logerror("Remaining count %d, setting up timer\n", m_uart_rx_fifo_count); + LOGMASKED(LOG_UART, "Remaining count %d, setting up timer\n", m_uart_rx_fifo_count); //uart_receive_tick(); if (m_uart_rx_timer->remaining() == attotime::never) m_uart_rx_timer->adjust(attotime::from_ticks(BIT(m_io_regs[0x30], 5) ? 11 : 10, m_uart_baud_rate)); @@ -1585,10 +1587,10 @@ WRITE16_MEMBER(spg2xx_device::io_w) "256KW, 3c0000-3fffff\n", "512KW, 380000-3fffff\n" }; - LOGMASKED(LOG_IO_WRITES, "io_w: Ext. Memory Control (not yet implemented) = %04x:\n", data); - LOGMASKED(LOG_IO_WRITES, " WaitStates:%d, BusArbPrio:%s\n", (data >> 1) & 3, s_bus_arb[(data >> 3) & 7]); - LOGMASKED(LOG_IO_WRITES, " ROMAddrDecode:%s\n", s_addr_decode[(data >> 6) & 3]); - LOGMASKED(LOG_IO_WRITES, " RAMAddrDecode:%s\n", s_ram_decode[(data >> 8) & 15]); + LOGMASKED(LOG_EXT_MEM, "io_w: Ext. Memory Control (not yet implemented) = %04x:\n", data); + LOGMASKED(LOG_EXT_MEM, " WaitStates:%d, BusArbPrio:%s\n", (data >> 1) & 3, s_bus_arb[(data >> 3) & 7]); + LOGMASKED(LOG_EXT_MEM, " ROMAddrDecode:%s\n", s_addr_decode[(data >> 6) & 3]); + LOGMASKED(LOG_EXT_MEM, " RAMAddrDecode:%s\n", s_ram_decode[(data >> 8) & 15]); m_chip_sel((data >> 6) & 3); m_io_regs[offset] = data; break; @@ -1976,12 +1978,12 @@ void spg2xx_device::uart_receive_tick() void spg2xx_device::extint_w(int channel, bool state) { - logerror("Setting extint channel %d to %s\n", channel, state ? "true" : "false"); + LOGMASKED(LOG_EXTINT, "Setting extint channel %d to %s\n", channel, state ? "true" : "false"); bool old = m_extint[channel]; m_extint[channel] = state; if (old != state) { - logerror("extint state changed, so %sing interrupt\n", state ? "rais" : "lower"); + LOGMASKED(LOG_EXTINT, "extint state changed, so %sing interrupt\n", state ? "rais" : "lower"); const uint16_t mask = (channel == 0) ? 0x0200 : 0x1000; const uint16_t old_irq = IO_IRQ_STATUS; if (state) @@ -1991,7 +1993,7 @@ void spg2xx_device::extint_w(int channel, bool state) if (old_irq != IO_IRQ_STATUS) { - logerror("extint IRQ changed, so checking interrupts\n"); + LOGMASKED(LOG_EXTINT, "extint IRQ changed, so checking interrupts\n"); check_irqs(mask); } } diff --git a/src/mame/drivers/vsmile.cpp b/src/mame/drivers/vsmile.cpp index 20c95b2df6b..fb6b3bbdcd5 100644 --- a/src/mame/drivers/vsmile.cpp +++ b/src/mame/drivers/vsmile.cpp @@ -19,8 +19,8 @@ #include "emu.h" -#include "bus/generic/slot.h" -#include "bus/generic/carts.h" +#include "bus/vsmile/vsmile_slot.h" +#include "bus/vsmile/rom.h" #include "cpu/unsp/unsp.h" @@ -42,28 +42,19 @@ public: , m_cart(*this, "cartslot") , m_bankdev(*this, "bank") , m_system_region(*this, "maincpu") - , m_cart_region(nullptr) - , m_cart_addr_mask(0) { } void vsmile_base(machine_config &config); protected: - virtual void machine_start() override; - void mem_map(address_map &map); - DECLARE_DEVICE_IMAGE_LOAD_MEMBER(cart); - required_device m_spg; required_device m_maincpu; required_device m_screen; - required_device m_cart; + required_device m_cart; required_device m_bankdev; required_memory_region m_system_region; - memory_region *m_cart_region; - - uint32_t m_cart_addr_mask; }; class vsmile_state : public vsmile_base_state @@ -106,9 +97,6 @@ private: void uart_tx_fifo_push(uint8_t data); void handle_uart_tx(); - DECLARE_READ16_MEMBER(bank0_r); - DECLARE_READ16_MEMBER(bank1_r); - DECLARE_READ16_MEMBER(bank2_r); DECLARE_READ16_MEMBER(bank3_r); enum @@ -181,29 +169,9 @@ private: * ************************************/ -void vsmile_base_state::machine_start() -{ - if (m_cart && m_cart->exists()) - { - std::string region_tag; - m_cart_region = memregion(region_tag.assign(m_cart->tag()).append(GENERIC_ROM_REGION_TAG).c_str()); - m_cart_addr_mask = (m_cart_region->bytes() >> 1) - 1; - } -} - -DEVICE_IMAGE_LOAD_MEMBER(vsmile_base_state, cart) -{ - uint32_t size = m_cart->common_get_size("rom"); - - m_cart->rom_alloc(size, GENERIC_ROM16_WIDTH, ENDIANNESS_LITTLE); - m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - - return image_init_result::PASS; -} - void vsmile_base_state::mem_map(address_map &map) { - map(0x000000, 0x3fffff).r(m_bankdev, FUNC(address_map_bank_device::read16)); + map(0x000000, 0x3fffff).rw(m_bankdev, FUNC(address_map_bank_device::read16), FUNC(address_map_bank_device::write16)); map(0x000000, 0x003fff).m(m_spg, FUNC(spg2xx_device::map)); } @@ -315,21 +283,6 @@ void vsmile_state::device_timer(emu_timer &timer, device_timer_id id, int param, } } -READ16_MEMBER(vsmile_state::bank0_r) -{ - return ((uint16_t*)m_cart_region->base())[offset & m_cart_addr_mask]; -} - -READ16_MEMBER(vsmile_state::bank1_r) -{ - return ((uint16_t*)m_cart_region->base())[(offset + 0x100000) & m_cart_addr_mask]; -} - -READ16_MEMBER(vsmile_state::bank2_r) -{ - return ((uint16_t*)m_cart_region->base())[(offset + 0x200000) & m_cart_addr_mask]; -} - READ16_MEMBER(vsmile_state::bank3_r) { return ((uint16_t*)m_system_region->base())[offset]; @@ -438,14 +391,14 @@ void vsmile_state::banked_map(address_map &map) map(0x0a00000, 0x0afffff).rom().region("maincpu", 0); map(0x0b00000, 0x0bfffff).rom().region("maincpu", 0); - map(0x1000000, 0x13fffff).r(FUNC(vsmile_state::bank0_r)); + map(0x1000000, 0x13fffff).rw(m_cart, FUNC(vsmile_cart_slot_device::bank0_r), FUNC(vsmile_cart_slot_device::bank0_w)); - map(0x1400000, 0x15fffff).r(FUNC(vsmile_state::bank0_r)); - map(0x1600000, 0x17fffff).r(FUNC(vsmile_state::bank2_r)); + map(0x1400000, 0x15fffff).rw(m_cart, FUNC(vsmile_cart_slot_device::bank0_r), FUNC(vsmile_cart_slot_device::bank0_w)); + map(0x1600000, 0x17fffff).rw(m_cart, FUNC(vsmile_cart_slot_device::bank2_r), FUNC(vsmile_cart_slot_device::bank2_w)); - map(0x1800000, 0x18fffff).r(FUNC(vsmile_state::bank0_r)); - map(0x1900000, 0x19fffff).r(FUNC(vsmile_state::bank1_r)); - map(0x1a00000, 0x1afffff).r(FUNC(vsmile_state::bank2_r)); + map(0x1800000, 0x18fffff).rw(m_cart, FUNC(vsmile_cart_slot_device::bank0_r), FUNC(vsmile_cart_slot_device::bank0_w)); + map(0x1900000, 0x19fffff).rw(m_cart, FUNC(vsmile_cart_slot_device::bank1_r), FUNC(vsmile_cart_slot_device::bank1_w)); + map(0x1a00000, 0x1afffff).r(m_cart, FUNC(vsmile_cart_slot_device::bank2_r)); map(0x1b00000, 0x1bfffff).r(FUNC(vsmile_state::bank3_r)); } @@ -464,14 +417,14 @@ void vsmileb_state::machine_start() READ16_MEMBER(vsmileb_state::porta_r) { - uint16_t data = 1; + uint16_t data = 0x0380; logerror("%s: GPIO Port A Read: %04x\n", machine().describe_context(), data); return data; } READ16_MEMBER(vsmileb_state::portb_r) { - uint16_t data = 0; + uint16_t data = 0x0080; logerror("%s: GPIO Port B Read: %04x\n", machine().describe_context(), data); return data; } @@ -501,13 +454,23 @@ WRITE16_MEMBER(vsmileb_state::portc_w) WRITE8_MEMBER(vsmileb_state::chip_sel_w) { logerror("%s: Chip Select Write: %d\n", machine().describe_context(), data); + m_bankdev->set_bank(data); } void vsmileb_state::banked_map(address_map &map) { map(0x0000000, 0x03fffff).rom().region("maincpu", 0); - map(0x0400000, 0x07fffff).rom().region("maincpu", 0); - map(0x0800000, 0x0bfffff).rom().region("maincpu", 0); + //map(0x0400000, 0x07fffff).rom().region("maincpu", 0); + //map(0x0800000, 0x0bfffff).rom().region("maincpu", 0); + //map(0x0000000, 0x03fffff).rom().region("maincpu", 0); + //map(0x0100000, 0x01fffff).rom().region("maincpu", 0); + //map(0x0200000, 0x02fffff).rom().region("maincpu", 0); + //map(0x0300000, 0x03fffff).rom().region("maincpu", 0); + + map(0x0400000, 0x05fffff).rom().region("maincpu", 0); + //map(0x0600000, 0x07fffff).nopr(); + //map(0x0200000, 0x02fffff).rom().region("maincpu", 0); + //map(0x0300000, 0x03fffff).rom().region("maincpu", 0); } /************************************ @@ -556,6 +519,12 @@ INPUT_PORTS_END static INPUT_PORTS_START( vsmileb ) INPUT_PORTS_END +static void vsmile_cart(device_slot_interface &device) +{ + device.option_add_internal("vsmile_rom", VSMILE_ROM_STD); + device.option_add_internal("vsmile_ram", VSMILE_ROM_RAM); +} + void vsmile_base_state::vsmile_base(machine_config &config) { UNSP(config, m_maincpu, XTAL(27'000'000)); @@ -582,9 +551,7 @@ void vsmile_base_state::vsmile_base(machine_config &config) m_bankdev->set_shift(-1); m_bankdev->set_stride(0x400000); - GENERIC_CARTSLOT(config, m_cart, generic_plain_slot, "vsmile_cart"); - m_cart->set_width(GENERIC_ROM16_WIDTH); - m_cart->set_device_load(device_image_load_delegate(&vsmile_base_state::device_image_load_cart, this)); + VSMILE_CART_SLOT(config, m_cart, vsmile_cart, nullptr); } void vsmile_state::vsmile(machine_config &config) -- cgit v1.2.3