mirror of
https://github.com/holub/mame
synced 2025-10-04 16:34:53 +03:00
-vsmile_slot: Added NVRAM support which should work, but doesn't. nw
This commit is contained in:
parent
7bd2bb2765
commit
879470fc1b
@ -2234,7 +2234,7 @@ Game cartridges
|
||||
<publisher>VTech</publisher>
|
||||
<info name="serial" value="80-067004(GER)" />
|
||||
<part name="cart" interface="vsmile_cart">
|
||||
<feature name="slot" value="vsmile_ram" />
|
||||
<feature name="slot" value="vsmile_nvram" />
|
||||
<feature name="pcb" value="67000C" />
|
||||
<feature name="pcb_model" value="67000C-5" />
|
||||
<feature name="cart_type" value="yellow" />
|
||||
@ -2243,7 +2243,7 @@ Game cartridges
|
||||
<dataarea name="rom" size="4194304">
|
||||
<rom name="GER-509.u3" size="4194304" crc="ae5f4fe2" sha1="1c5428da7464182e6ee0585d1ebc211f91667238" offset="0" />
|
||||
</dataarea>
|
||||
<dataarea name="vram" size="131072">
|
||||
<dataarea name="nvram" size="131072">
|
||||
</dataarea>
|
||||
</part>
|
||||
</software>
|
||||
@ -2254,7 +2254,7 @@ Game cartridges
|
||||
<publisher>VTech</publisher>
|
||||
<info name="serial" value="80-067021(SE)" />
|
||||
<part name="cart" interface="vsmile_cart">
|
||||
<feature name="slot" value="vsmile_ram" />
|
||||
<feature name="slot" value="vsmile_nvram" />
|
||||
<feature name="pcb" value="67000C" />
|
||||
<feature name="pcb_model" value="67000C-2" />
|
||||
<feature name="cart_type" value="yellow" />
|
||||
@ -2263,7 +2263,7 @@ Game cartridges
|
||||
<dataarea name="rom" size="4194304">
|
||||
<rom name="52-67021.u3" size="4194304" crc="27449e15" sha1="5c13865dffb04c98c69f3422c965d76a9aa36c33" offset="0" />
|
||||
</dataarea>
|
||||
<dataarea name="vram" size="131072">
|
||||
<dataarea name="nvram" size="131072">
|
||||
</dataarea>
|
||||
</part>
|
||||
</software>
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
V.Smile cart emulation
|
||||
|
||||
We support standard carts and one with on-board RAM
|
||||
We support standard carts and one with on-board NVRAM
|
||||
|
||||
***********************************************************************************************************/
|
||||
|
||||
@ -17,8 +17,8 @@
|
||||
// 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")
|
||||
DEFINE_DEVICE_TYPE(VSMILE_ROM_STD, vsmile_rom_device, "vsmile_rom", "V.Smile Cart")
|
||||
DEFINE_DEVICE_TYPE(VSMILE_ROM_NVRAM, vsmile_rom_nvram_device, "vsmile_rom_nvram", "V.Smile Cart + NVRAM")
|
||||
|
||||
|
||||
vsmile_rom_device::vsmile_rom_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
|
||||
@ -32,13 +32,13 @@ vsmile_rom_device::vsmile_rom_device(const machine_config &mconfig, const char *
|
||||
{
|
||||
}
|
||||
|
||||
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_nvram_device::vsmile_rom_nvram_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)
|
||||
vsmile_rom_nvram_device::vsmile_rom_nvram_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
|
||||
: vsmile_rom_nvram_device(mconfig, VSMILE_ROM_NVRAM, tag, owner, clock)
|
||||
{
|
||||
}
|
||||
|
||||
@ -57,19 +57,19 @@ void vsmile_rom_device::device_reset()
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
Carts with RAM
|
||||
Cart with NVRAM
|
||||
-------------------------------------------------*/
|
||||
|
||||
READ16_MEMBER(vsmile_rom_ram_device::bank2_r)
|
||||
READ16_MEMBER(vsmile_rom_nvram_device::bank2_r)
|
||||
{
|
||||
if (!m_ram.empty() && offset < m_ram.size())
|
||||
return m_ram[offset];
|
||||
if (!m_nvram.empty() && offset < m_nvram.size())
|
||||
return m_nvram[offset];
|
||||
else // this cannot actually happen...
|
||||
return 0;
|
||||
}
|
||||
|
||||
WRITE16_MEMBER(vsmile_rom_ram_device::bank2_w)
|
||||
WRITE16_MEMBER(vsmile_rom_nvram_device::bank2_w)
|
||||
{
|
||||
if (!m_ram.empty() && offset < m_ram.size())
|
||||
COMBINE_DATA(&m_ram[offset]);
|
||||
if (!m_nvram.empty() && offset < m_nvram.size())
|
||||
COMBINE_DATA(&m_nvram[offset]);
|
||||
}
|
||||
|
@ -30,25 +30,25 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
// ======================> vsmile_rom_ram_device
|
||||
// ======================> vsmile_rom_nvram_device
|
||||
|
||||
class vsmile_rom_ram_device : public vsmile_rom_device
|
||||
class vsmile_rom_nvram_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);
|
||||
vsmile_rom_nvram_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);
|
||||
vsmile_rom_nvram_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)
|
||||
DECLARE_DEVICE_TYPE(VSMILE_ROM_NVRAM, vsmile_rom_nvram_device)
|
||||
|
||||
|
||||
#endif // MAME_BUS_VSMILE_ROM_H
|
||||
|
@ -57,12 +57,12 @@ void device_vsmile_cart_interface::rom_alloc(uint32_t size, const char *tag)
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// ram_alloc - alloc the space for the ram
|
||||
// nvram_alloc - alloc the space for the nvram
|
||||
//-------------------------------------------------
|
||||
|
||||
void device_vsmile_cart_interface::ram_alloc(uint32_t size)
|
||||
void device_vsmile_cart_interface::nvram_alloc(uint32_t size)
|
||||
{
|
||||
m_ram.resize(size / sizeof(uint16_t));
|
||||
m_nvram.resize(size / sizeof(uint16_t));
|
||||
}
|
||||
|
||||
|
||||
@ -115,7 +115,7 @@ struct vsmile_slot
|
||||
static const vsmile_slot slot_list[] =
|
||||
{
|
||||
{ VSMILE_STD, "vsmile_rom" },
|
||||
{ VSMILE_SRAM, "vsmile_ram" },
|
||||
{ VSMILE_NVRAM, "vsmile_nvram" },
|
||||
};
|
||||
|
||||
static int vsmile_get_pcb_id(const char *slot)
|
||||
@ -164,9 +164,15 @@ image_init_result vsmile_cart_slot_device::call_load()
|
||||
osd_printf_info("V.Smile: Detected (XML) %s\n", pcb_name ? pcb_name : "NONE");
|
||||
}
|
||||
|
||||
if (m_type == VSMILE_SRAM)
|
||||
if (m_type == VSMILE_NVRAM)
|
||||
{
|
||||
m_cart->ram_alloc(0x200000);
|
||||
m_cart->nvram_alloc(0x200000);
|
||||
}
|
||||
|
||||
if (m_cart->get_nvram_size())
|
||||
{
|
||||
printf("nvram_size 1\n");
|
||||
battery_load(m_cart->get_nvram_base(), m_cart->get_nvram_size(), 0x00);
|
||||
}
|
||||
|
||||
return image_init_result::PASS;
|
||||
@ -182,6 +188,12 @@ image_init_result vsmile_cart_slot_device::call_load()
|
||||
|
||||
void vsmile_cart_slot_device::call_unload()
|
||||
{
|
||||
if (m_cart)
|
||||
printf("nvram_size: %d\n", m_cart->get_nvram_size());
|
||||
if (m_cart && m_cart->get_nvram_size())
|
||||
{
|
||||
battery_save(m_cart->get_nvram_base(), m_cart->get_nvram_size());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
enum
|
||||
{
|
||||
VSMILE_STD = 0,
|
||||
VSMILE_SRAM
|
||||
VSMILE_NVRAM
|
||||
};
|
||||
|
||||
// ======================> device_vsmile_cart_interface
|
||||
@ -39,20 +39,22 @@ public:
|
||||
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);
|
||||
void nvram_alloc(uint32_t size);
|
||||
uint16_t* get_rom_base() { return m_rom; }
|
||||
uint16_t* get_ram_base() { return &m_ram[0]; }
|
||||
uint16_t* get_nvram_base() { return &m_nvram[0]; }
|
||||
uint32_t get_rom_size() { return m_rom_size; }
|
||||
uint32_t get_ram_size() { return m_ram.size() * sizeof(uint16_t); }
|
||||
uint32_t get_nvram_size() { return m_nvram.size() * sizeof(uint16_t); }
|
||||
void set_rom_size(uint32_t val) { m_rom_size = val; }
|
||||
|
||||
void save_nvram() { device().save_item(NAME(m_nvram)); }
|
||||
|
||||
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<uint16_t> m_ram;
|
||||
std::vector<uint16_t> m_nvram;
|
||||
};
|
||||
|
||||
|
||||
@ -84,6 +86,7 @@ public:
|
||||
virtual void call_unload() override;
|
||||
virtual const software_list_loader &get_software_list_loader() const override { return rom_software_list_loader::instance(); }
|
||||
|
||||
void save_nvram() { if (m_cart && m_cart->get_nvram_size()) m_cart->save_nvram(); }
|
||||
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; }
|
||||
|
@ -557,8 +557,8 @@ 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);
|
||||
device.option_add_internal("vsmile_rom", VSMILE_ROM_STD);
|
||||
device.option_add_internal("vsmile_nvram", VSMILE_ROM_NVRAM);
|
||||
}
|
||||
|
||||
void vsmile_base_state::vsmile_base(machine_config &config)
|
||||
|
Loading…
Reference in New Issue
Block a user