diff --git a/hash/vsmile_cart.xml b/hash/vsmile_cart.xml index 0929e37fc61..7e607636156 100644 --- a/hash/vsmile_cart.xml +++ b/hash/vsmile_cart.xml @@ -515,7 +515,7 @@ Game cartridges - + Disneys Aladdin - Aladdins Welt der Wunder (Ger) 2005? VTech @@ -532,7 +532,7 @@ Game cartridges - + Entdecke die Welt von Rotkäppchen (Ger) 200? VTech @@ -549,7 +549,7 @@ Game cartridges - + Alphabet Park Adventure (USA) 200? VTech @@ -566,7 +566,7 @@ Game cartridges - + Abenteuer im ABC Park (Ger) 200? VTech @@ -583,7 +583,7 @@ Game cartridges - + ABC Land Aventure (Fra) 200? VTech @@ -600,7 +600,7 @@ Game cartridges - + Disneys Arielle die Meerjungfrau - Arielles aufregendes Abenteuer (Ger, Rev. 3?) 2004? VTech @@ -617,7 +617,7 @@ Game cartridges - + Disneys Arielle Die Meerjungfrau - Arielles aufregendes Abenteuer (Ger) 2004? VTech @@ -634,7 +634,7 @@ Game cartridges - + Disney La Petite Sirene - Ariel devient une princesse (Fra) 2004? VTech @@ -651,7 +651,7 @@ Game cartridges - + Disney Den Lille Havfrue - Ariels majestætiske rejse! (Den) 200? VTech @@ -668,7 +668,7 @@ Game cartridges - + Disneys Den Lilla Sjöjungfrun - Ariels majestätiska resa! (Swe) 200? VTech @@ -685,7 +685,7 @@ Game cartridges - + Disney La sirenetta - Ariel e la crociera magica (Ita) 2005 VTech / Giochi Preziosi @@ -697,7 +697,7 @@ Game cartridges - + Barney - Erlebnis-Reise (Ger) 2005? VTech @@ -715,7 +715,7 @@ Game cartridges - + Bob the Builder - Bob's Busy Day (USA) 2005? VTech @@ -732,7 +732,7 @@ Game cartridges - + Bob der Baumeister - Bobs spannender Arbeitstag (Ger) 2005? VTech @@ -749,7 +749,7 @@ Game cartridges - + Byggemand Bob - Bobs travle dag (Den) 2006? VTech @@ -766,7 +766,7 @@ Game cartridges - + Byggare Bob - Bobs stressiga dag (Swe) 2006? VTech @@ -784,7 +784,7 @@ Game cartridges - + Disney/Pixar Cars - Rev It Up in Radiator Springs (USA) 2006? VTech @@ -801,7 +801,7 @@ Game cartridges - + Disney/Pixar Cars - Vollgas in Radiator Springs (Ger) 2006? VTech @@ -818,7 +818,7 @@ Game cartridges - + Disney/Pixar Cars - Quatre Roues (Fra) 2006? VTech @@ -835,7 +835,7 @@ Game cartridges - + Disney/Pixar Biler - Ræs i Kølerkildekøbing (Den) 2007? VTech @@ -852,7 +852,7 @@ Game cartridges - + Disney/Pixar Bilar - Kör ikapp i Kylarköping (Swe) 2007? VTech @@ -870,7 +870,7 @@ Game cartridges - + Disney Princess Cinderella - Cinderella's Magic Wishes (USA) 2005? VTech @@ -887,7 +887,7 @@ Game cartridges - + Disney Princess Cinderella - Cinderella's Magic Wishes (USA, Alt) 200? VTech @@ -900,7 +900,7 @@ Game cartridges - + Disney Cenerentola - I desideri magici di Cenerentola (Ita) 2006 VTech / Giochi Preziosi @@ -913,7 +913,7 @@ Game cartridges - + Disney Princesses Cendrillon - Le rêve enchanté de Cendrillon (Fra) 2005? VTech @@ -930,7 +930,7 @@ Game cartridges - + Disney Princess Cinderella - Askepots magiske ønsker (Den) 2006? VTech @@ -947,7 +947,7 @@ Game cartridges - + Disney Princess Cinderella - Lernen im Märchenland (Ger, Rev. 1) 2007? VTech @@ -964,7 +964,7 @@ Game cartridges - + Disney Princess Cinderella - Lernen im Märchenland (Ger) 2005? VTech @@ -981,7 +981,7 @@ Game cartridges - + Disney Princess Cinderella - Askungens magiska önskningar (Swe) 2006? VTech @@ -998,7 +998,7 @@ Game cartridges - + Disney's Mickey Mouse - Mickey's Magical Adventure (USA) 200? VTech @@ -1012,7 +1012,7 @@ Game cartridges - + Nick Jr Dora the Explorer - Dora's Fix-it Adventure (USA) 2005? VTech @@ -1029,7 +1029,7 @@ Game cartridges - + Dora L'Exploratrice - Les aventures de Dora Apprentie Mécano (Fra) 2005? VTech @@ -1046,7 +1046,7 @@ Game cartridges - + Nick Jr Dora - Doras Reparatur-Abenteuer (Ger, Rev. 1) 2007? VTech @@ -1063,7 +1063,7 @@ Game cartridges - + Elmos großes Abenteuer (Ger) 2005? VTech @@ -1080,7 +1080,7 @@ Game cartridges - + Le Monde d'ELMO - Les Grandes Decouvertes D'Elmo (Fra) 2005? VTech @@ -1097,7 +1097,7 @@ Game cartridges - + V.Smile Fußball Schule (Ger) 200? VTech @@ -1114,7 +1114,7 @@ Game cartridges - + Disney/Pixar Finding Nemo - Nemo's Ocean Discoveries (USA) 2005? VTech @@ -1131,7 +1131,7 @@ Game cartridges - + Disney/Pixar Finding Nemo - De Wonderwereld Van Nemo (NL) 2005? VTech @@ -1148,7 +1148,7 @@ Game cartridges - + Freds Zahlen Rallye (Ger) 200? VTech @@ -1165,7 +1165,7 @@ Game cartridges - + Apprenti' pilote (Fra) 200? VTech @@ -1182,7 +1182,7 @@ Game cartridges - + Kleine Einsteins (Ger, Rev. 3?) 2009? VTech @@ -1199,7 +1199,7 @@ Game cartridges - + Disney's The Lion King - Simba's Big Adventure (USA) 200? VTech @@ -1216,7 +1216,7 @@ Game cartridges - + Der Koenig der Loewen - Simbas großes Abenteuer (Ger, Rev. 2?) 2004 VTech @@ -1233,7 +1233,7 @@ Game cartridges - + Roi Lion - Simba Decouvre la Jungle (Fra) 200? VTech @@ -1250,7 +1250,7 @@ Game cartridges - + Disney Løvernes Konge - Simbas store eventyr (Den) 200? VTech @@ -1267,7 +1267,7 @@ Game cartridges - + Disney Lejonkungen - Simbas stora äventyr (Swe) 200? VTech @@ -1284,7 +1284,7 @@ Game cartridges - + Disney Il re leone - La grande avventura di Simba (Ita) 2005 VTech / Giochi Preziosi @@ -1297,7 +1297,7 @@ Game cartridges - + Kung Fu Panda - Path of the Panda (UK) 2008 VTech @@ -1310,7 +1310,7 @@ Game cartridges - + Kung Fu Panda - Der Weg des Panda (Ger) 2008 VTech @@ -1327,7 +1327,7 @@ Game cartridges - + Meister Manny's Werkzeugkiste (Ger) 2009? VTech @@ -1361,7 +1361,7 @@ Game cartridges - + Disneys Micky - Mickys magisches Abenteuer (Ger) 2004? VTech @@ -1378,7 +1378,7 @@ Game cartridges - + Disneys Musse Pigg - Musses magiska äventyr (Swe) 200? VTech @@ -1395,7 +1395,7 @@ Game cartridges - + Micky Maus Wunderhaus (Ger, Rev. 3?) 200? VTech @@ -1412,7 +1412,7 @@ Game cartridges - + Mickey Mouse Clubhouse (NL) 200? VTech @@ -1429,7 +1429,7 @@ Game cartridges - + Mickey Mouse Clubhouse (Swe) 200? VTech @@ -1446,7 +1446,7 @@ Game cartridges - + DreamWorks Monsters vs Aliens (Ger) 2009? VTech @@ -1463,7 +1463,7 @@ Game cartridges - + Mein erster Hund (Ger) 200? VTech @@ -1480,7 +1480,7 @@ Game cartridges - + Min hundvalp (Swe) 2009? VTech @@ -1497,7 +1497,7 @@ Game cartridges - + Noddy - Detektiv für einen Tag (Ger, Rev. 3?) 200? VTech @@ -1514,7 +1514,7 @@ Game cartridges - + Oui-Oui - Detective d'un Jour (Fra) 200? VTech @@ -1531,7 +1531,7 @@ Game cartridges - + Disney/Pixar Oben (Ger) 2009? VTech @@ -1548,7 +1548,7 @@ Game cartridges - + Disney/Pixar Up (UK) 2009 VTech @@ -1561,7 +1561,7 @@ Game cartridges - + Cranium Partyland Park - A Carnival of Play-and-Learn Fun (USA) 2007? VTech @@ -1578,7 +1578,7 @@ Game cartridges - + Disney/Pixar Ratatouille - Remys neue Rezepte (Ger) 2007? VTech @@ -1595,7 +1595,7 @@ Game cartridges - + Disney/Pixar Ratatouille - Le nuove ricette di Remy (Ita) 2007 VTech @@ -1607,7 +1607,7 @@ Game cartridges - + Scooby-Doo! - Funland Frenzy (USA) 200? VTech @@ -1624,7 +1624,7 @@ Game cartridges - + Scooby-Doo - Panique à Funland (Fra) 200? VTech @@ -1641,7 +1641,7 @@ Game cartridges - + Scooby-Doo! - Im Lernpark (Ger) 200? VTech @@ -1658,7 +1658,7 @@ Game cartridges - + Scooby-Doo! - Sjov i forlystelsesparken (Den) 200? VTech @@ -1675,7 +1675,7 @@ Game cartridges - + Scooby-Doo! - Tivoli-tokerier (Swe) 200? VTech @@ -1692,7 +1692,7 @@ Game cartridges - + Scooby-Doo! - Avventura a Funland (Ita) 200? VTech / Giochi Preziosi @@ -1704,7 +1704,7 @@ Game cartridges - + Ernies & Berts Fantastisches Abenteuer (Ger) 2006? VTech @@ -1721,7 +1721,7 @@ Game cartridges - + DreamWorks Shrek the Third - Arthur's School Day Adventure (USA) 2007? VTech @@ -1738,7 +1738,7 @@ Game cartridges - + Shrek der Dritte - Ein Spannender Schultag (Ger) 2007 VTech @@ -1755,7 +1755,7 @@ Game cartridges - + Shrek De Derde - Arthurs Schooldag Avontuur (NL) 2007? VTech @@ -1772,7 +1772,7 @@ Game cartridges - + DreamWorks Shrek - Die Geschichte des Drachen (Ger) 2006? VTech @@ -1789,7 +1789,7 @@ Game cartridges - + DreamWorks Shrek - Le rhume de Dragonne (Fra) 2006? VTech @@ -1806,7 +1806,7 @@ Game cartridges - + Spider-Man & ses amis - Missions secrètes (Fra) 2005? VTech @@ -1823,7 +1823,7 @@ Game cartridges - + Spider-Man & Freunde - Wettkampf im Space-Labor (Ger) 2006? VTech @@ -1840,7 +1840,7 @@ Game cartridges - + Nickelodeon Spongebob Squarepants - A Day in the Life of a Sponge (USA) 2005? VTech @@ -1857,7 +1857,7 @@ Game cartridges - + Nickelodeon Spongebob Schwammkopf - Der Tag des Schwamms (Ger, Rev. 1) 2005? VTech @@ -1874,7 +1874,7 @@ Game cartridges - + Nickelodeon Spongebob Schwammkopf - Der Tag des Schwamms (Ger) 2005? VTech @@ -1891,7 +1891,7 @@ Game cartridges - + Superman - Der Superheld (Ger) 200? VTech @@ -1908,7 +1908,7 @@ Game cartridges - + Superman - De Grootste Held (NL) 200? VTech @@ -1925,7 +1925,7 @@ Game cartridges - + Superman - À la rescousse ! (Fra) 200? VTech @@ -1942,7 +1942,7 @@ Game cartridges - + Thomas & seine Freunde - Freunde Halten Zusammen (Ger, Rev. 1) 2007? VTech @@ -1959,7 +1959,7 @@ Game cartridges - + Thomas & seine Freunde - Freunde Halten Zusammen (Ger) 2007? VTech @@ -1976,7 +1976,7 @@ Game cartridges - + Thomas er ses Amis - Les locomotives s'entraident (Fra) 2007? VTech @@ -1993,7 +1993,7 @@ Game cartridges - + Thomas & Friends - Tågen hjälps åt (Swe) 2007? VTech @@ -2010,7 +2010,7 @@ Game cartridges - + Tingeling (Swe) 2010? VTech @@ -2027,7 +2027,7 @@ Game cartridges - + Disney/Pixar Toy Story 2 - Operation: Rescue Woody! (USA) 2005 VTech @@ -2040,7 +2040,7 @@ Game cartridges - + Disney/Pixar Toy Story 2 - Woodys Spannende Rettung (Ger) 2006? VTech @@ -2057,7 +2057,7 @@ Game cartridges - + Disney/Pixar Toy Story 2 - Operation: Rädda Woody! (Swe) 2005? VTech @@ -2074,7 +2074,7 @@ Game cartridges - + Disney/Pixar Wall-E (Ger) 2008? VTech @@ -2091,7 +2091,7 @@ Game cartridges - + Disney/Pixar Wall-E (Swe) 2008? VTech @@ -2108,7 +2108,7 @@ Game cartridges - + Disneys Winnie Puuh - Die Honigjagd (Ger) 2004? VTech @@ -2125,7 +2125,7 @@ Game cartridges - + My Friends Tigger & Pooh - Die Honigjagd (Ger) 2008? VTech @@ -2142,7 +2142,7 @@ Game cartridges - + Disney Winnie l'Ourson - La Chasse au miel de Winnie (Fra) 2004? VTech @@ -2159,7 +2159,7 @@ Game cartridges - + Disney Winnie l'Ourson - La Chasse au miel de Winnie (Fra, Rev. 2) 2004? VTech @@ -2176,7 +2176,7 @@ Game cartridges - + Disney Peter Plys - Honningjagten (Den) 200? VTech @@ -2193,7 +2193,7 @@ Game cartridges - + Disney Nalle Puh - Honungsjakten (Swe) 200? VTech @@ -2211,7 +2211,7 @@ Game cartridges - + V.Smile - Lern- und Tanzmatte (Ger) 200? VTech @@ -2248,7 +2248,7 @@ Game cartridges - + V.Smile Tecknarstudio (Swe) 200? VTech @@ -2268,7 +2268,7 @@ Game cartridges - + Zayzoo - My Alien Classmate (USA) 200? VTech @@ -2281,7 +2281,7 @@ Game cartridges - + Zayzoo: An Earth Adventure (USA) 200? VTech @@ -2298,7 +2298,7 @@ Game cartridges - + Zayzoos Lernall (Ger) 200? VTech @@ -2315,7 +2315,7 @@ Game cartridges - + Zayzoo: An Earth Adventure (UK) 200? VTech @@ -2328,7 +2328,7 @@ Game cartridges - + Zézou - Notre Ami Venu d'Ailleurs (Fra) 200? VTech diff --git a/hash/vsmilem_cart.xml b/hash/vsmilem_cart.xml index 86100a979cc..0caa6ee780f 100644 --- a/hash/vsmilem_cart.xml +++ b/hash/vsmilem_cart.xml @@ -237,7 +237,7 @@ Smartbooks currently have no dumps available, hence they are temporarily listed - + Action Manía (Sp) 201? VTech @@ -252,7 +252,7 @@ Smartbooks currently have no dumps available, hence they are temporarily listed - + Disney Princess Cinderella - Lernen im Märchenland (Ger) 2010? VTech @@ -267,7 +267,7 @@ Smartbooks currently have no dumps available, hence they are temporarily listed - + Disney Princess Cinderella - Lernen im Märchenland (Ger, Rev. 2?) 2010? VTech @@ -279,7 +279,7 @@ Smartbooks currently have no dumps available, hence they are temporarily listed - + DreamWorks Kung Fu Panda - Der Weg des Panda (Ger) 2008? VTech @@ -294,7 +294,7 @@ Smartbooks currently have no dumps available, hence they are temporarily listed - + Dora - Doras Reparatur-Abenteuer (Ger) 2009? VTech @@ -309,7 +309,7 @@ Smartbooks currently have no dumps available, hence they are temporarily listed - + Dora - Doras Reparatur-Abenteuer (Ger, Rev. 2) 2009? VTech @@ -324,7 +324,7 @@ Smartbooks currently have no dumps available, hence they are temporarily listed - + Kleine Einsteins (Ger) 200? VTech @@ -336,7 +336,7 @@ Smartbooks currently have no dumps available, hence they are temporarily listed - + Kleine Einsteins (Ger, Rev. 2?) 200? VTech @@ -348,7 +348,7 @@ Smartbooks currently have no dumps available, hence they are temporarily listed - + Thomas - Freunde halten zusammen (Ger) 2007? VTech @@ -360,7 +360,7 @@ Smartbooks currently have no dumps available, hence they are temporarily listed - + Spider-Man & Freunde - Geheime Missionen (Ger) 2010 VTech @@ -375,7 +375,7 @@ Smartbooks currently have no dumps available, hence they are temporarily listed - + TinkerBell (Ger) 2009? VTech @@ -390,7 +390,7 @@ Smartbooks currently have no dumps available, hence they are temporarily listed - + Winnie Puuh - Die Honigjagd (Ger) 2009? VTech @@ -405,7 +405,7 @@ Smartbooks currently have no dumps available, hence they are temporarily listed - + Wintersport (Ger) 2009? VTech diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua index 5350a2d510a..82280e51d1c 100644 --- a/scripts/src/bus.lua +++ b/scripts/src/bus.lua @@ -3268,6 +3268,25 @@ if (BUSES["UTS_KBD"]~=null) then } end +--------------------------------------------------- +-- +--@src/devices/bus/vsmile/vsmile_ctrl.h,BUSES["VSMILE"] = true +--@src/devices/bus/vsmile/vsmile_slot.h,BUSES["VSMILE"] = true +--------------------------------------------------- + +if (BUSES["VSMILE"]~=null) then + files { + MAME_DIR .. "src/devices/bus/vsmile/vsmile_ctrl.cpp", + MAME_DIR .. "src/devices/bus/vsmile/vsmile_ctrl.h", + MAME_DIR .. "src/devices/bus/vsmile/vsmile_slot.cpp", + MAME_DIR .. "src/devices/bus/vsmile/vsmile_slot.h", + MAME_DIR .. "src/devices/bus/vsmile/joystick.cpp", + MAME_DIR .. "src/devices/bus/vsmile/joystick.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 2f38dd70e58..6d3eaba6d54 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/joystick.cpp b/src/devices/bus/vsmile/joystick.cpp new file mode 100644 index 00000000000..b3be2f25ce3 --- /dev/null +++ b/src/devices/bus/vsmile/joystick.cpp @@ -0,0 +1,46 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz + +#include "emu.h" +#include "joystick.h" + + +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +DEFINE_DEVICE_TYPE(VSMILE_JOYSTICK, vsmile_joystick_device, "vsmile_joystick", "V.Smile Joystick Controller") + + +//************************************************************************** +// V.Smile joystick controller +//************************************************************************** + +vsmile_joystick_device::vsmile_joystick_device( + machine_config const &mconfig, + char const *tag, + device_t *owner, + uint32_t clock) + : device_t(mconfig, VSMILE_JOYSTICK, tag, owner, clock) + , device_vsmile_ctrl_interface(mconfig, *this) +{ +} + +vsmile_joystick_device::~vsmile_joystick_device() +{ +} + +void vsmile_joystick_device::device_start() +{ + // TODO: initialise and register save state +} + +void vsmile_joystick_device::cts_w(int state) +{ + // TODO: CTS input changed +} + +void vsmile_joystick_device::data_w(uint8_t data) +{ + // TODO: data arrived +} diff --git a/src/devices/bus/vsmile/joystick.h b/src/devices/bus/vsmile/joystick.h new file mode 100644 index 00000000000..4fde270925f --- /dev/null +++ b/src/devices/bus/vsmile/joystick.h @@ -0,0 +1,39 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz +#ifndef MAME_BUS_VSMILE_JOYSTICK_H +#define MAME_BUS_VSMILE_JOYSTICK_H + +#pragma once + +#include "vsmile_ctrl.h" + +/*************************************************************************** + TYPE DEFINITIONS + ***************************************************************************/ + +// ======================> vsmile_joystick_device + +class vsmile_joystick_device : public device_t, public device_vsmile_ctrl_interface +{ +public: + // construction/destruction + vsmile_joystick_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock = 0U); + virtual ~vsmile_joystick_device(); + +protected: + // device_t implementation + virtual void device_start() override; + + // device_vsmile_ctrl_interface implementation + virtual void cts_w(int state) override; + virtual void data_w(uint8_t data) override; +}; + + +/*************************************************************************** + DEVICE TYPES + ***************************************************************************/ + +DECLARE_DEVICE_TYPE(VSMILE_JOYSTICK, vsmile_joystick_device) + +#endif // MAME_BUS_VSMILE_JOYSTICK_H diff --git a/src/devices/bus/vsmile/rom.cpp b/src/devices/bus/vsmile/rom.cpp new file mode 100644 index 00000000000..49740bc7f37 --- /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 NVRAM + + ***********************************************************************************************************/ + + +#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_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) + : 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_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_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) +{ +} + + +//------------------------------------------------- +// mapper specific start/reset +//------------------------------------------------- + +void vsmile_rom_device::device_start() +{ +} + +void vsmile_rom_device::device_reset() +{ +} + + +/*------------------------------------------------- + Cart with NVRAM + -------------------------------------------------*/ + +READ16_MEMBER(vsmile_rom_nvram_device::bank2_r) +{ + if (!m_nvram.empty() && offset < m_nvram.size()) + return m_nvram[offset]; + else // this cannot actually happen... + return 0; +} + +WRITE16_MEMBER(vsmile_rom_nvram_device::bank2_w) +{ + if (!m_nvram.empty() && offset < m_nvram.size()) + COMBINE_DATA(&m_nvram[offset]); +} diff --git a/src/devices/bus/vsmile/rom.h b/src/devices/bus/vsmile/rom.h new file mode 100644 index 00000000000..5d93cb64109 --- /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_nvram_device + +class vsmile_rom_nvram_device : public vsmile_rom_device +{ +public: + // construction/destruction + 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_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_NVRAM, vsmile_rom_nvram_device) + + +#endif // MAME_BUS_VSMILE_ROM_H diff --git a/src/devices/bus/vsmile/vsmile_ctrl.cpp b/src/devices/bus/vsmile/vsmile_ctrl.cpp new file mode 100644 index 00000000000..c30f47384d9 --- /dev/null +++ b/src/devices/bus/vsmile/vsmile_ctrl.cpp @@ -0,0 +1,111 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz + +#include "emu.h" +#include "vsmile_ctrl.h" + + +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +DEFINE_DEVICE_TYPE(VSMILE_CTRL_PORT, vsmile_ctrl_port_device, "vsmile_ctrl_port", "V.Smile Controller Port") + + +//************************************************************************** +// V.Smile controller interface +//************************************************************************** + +device_vsmile_ctrl_interface::device_vsmile_ctrl_interface(const machine_config &mconfig, device_t &device) + : device_slot_card_interface(mconfig, device) + , m_port(dynamic_cast(device.owner())) +{ +} + +device_vsmile_ctrl_interface::~device_vsmile_ctrl_interface() +{ +} + +void device_vsmile_ctrl_interface::interface_validity_check(validity_checker &valid) const +{ + device_slot_card_interface::interface_validity_check(valid); + + if (device().owner() && !m_port) + { + osd_printf_error( + "Owner device %s (%s) is not a vsmile_ctrl_port_device\n", + device().owner()->tag(), + device().owner()->name()); + } +} + +void device_vsmile_ctrl_interface::interface_pre_start() +{ + device_slot_card_interface::interface_pre_start(); + + if (m_port && !m_port->started()) + throw device_missing_dependencies(); +} + + +//************************************************************************** +// V.Smile controller port +//************************************************************************** + +vsmile_ctrl_port_device::vsmile_ctrl_port_device( + machine_config const &mconfig, + char const *tag, + device_t *owner, + uint32_t clock) + : device_t(mconfig, VSMILE_CTRL_PORT, tag, owner, clock) + , device_slot_interface(mconfig, *this) + , m_rts_cb(*this) + , m_data_cb(*this) +{ +} + +vsmile_ctrl_port_device::~vsmile_ctrl_port_device() +{ +} + +void vsmile_ctrl_port_device::device_validity_check(validity_checker &valid) const +{ + device_t *const card(get_card_device()); + if (card && !dynamic_cast(card)) + { + osd_printf_error( + "Card device %s (%s) does not implement device_vsmile_ctrl_interface\n", + card->tag(), + card->name()); + } +} + +void vsmile_ctrl_port_device::device_resolve_objects() +{ + device_vsmile_ctrl_interface *const card(dynamic_cast(get_card_device())); + if (card) + m_device = card; + + m_rts_cb.resolve_safe(); + m_data_cb.resolve_safe(); +} + +void vsmile_ctrl_port_device::device_start() +{ + device_t *const card(get_card_device()); + if (card && !m_device) + { + throw emu_fatalerror( + "vsmile_ctrl_port_device: card device %s (%s) does not implement device_vsmile_ctrl_interface\n", + card->tag(), + card->name()); + } +} + + +#include "joystick.h" + +void vsmile_controllers(device_slot_interface &device) +{ + device.option_add("joy", VSMILE_JOYSTICK); +} diff --git a/src/devices/bus/vsmile/vsmile_ctrl.h b/src/devices/bus/vsmile/vsmile_ctrl.h new file mode 100644 index 00000000000..9a1fdf13125 --- /dev/null +++ b/src/devices/bus/vsmile/vsmile_ctrl.h @@ -0,0 +1,111 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz +#ifndef MAME_BUS_VSMILE_VSMILE_CTRL_H +#define MAME_BUS_VSMILE_VSMILE_CTRL_H + +#pragma once + + +/*************************************************************************** + FORWARD DECLARATIONS + ***************************************************************************/ + +class vsmile_ctrl_port_device; + + +/*************************************************************************** + TYPE DEFINITIONS + ***************************************************************************/ + +// ======================> device_vsmile_ctrl_interface + +class device_vsmile_ctrl_interface : public device_slot_card_interface +{ +public: + virtual ~device_vsmile_ctrl_interface(); + +protected: + device_vsmile_ctrl_interface(machine_config const &mconfig, device_t &device); + + // device_interface implementation + virtual void interface_validity_check(validity_checker &valid) const override ATTR_COLD; + virtual void interface_pre_start() override; + + // otuput signals + void rts_out(int state); + void data_out(uint8_t data); + +private: + // input signal handlers for implementataions to override + virtual void cts_w(int state) = 0; + virtual void data_w(uint8_t data) = 0; + + vsmile_ctrl_port_device *const m_port; + + friend class vsmile_ctrl_port_device; +}; + + +// ======================> vsmile_ctrl_port_device + +class vsmile_ctrl_port_device : public device_t, public device_slot_interface +{ +public: + // configuration + auto rts_cb() { return m_rts_cb.bind(); } + auto data_cb() { return m_data_cb.bind(); } + + // construction/destruction + template + vsmile_ctrl_port_device(machine_config const &mconfig, char const *tag, device_t *owner, T &&opts, char const *dflt) + : vsmile_ctrl_port_device(mconfig, tag, owner, 0U) + { + option_reset(); + opts(*this); + set_default_option(dflt); + set_fixed(false); + } + vsmile_ctrl_port_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock = 0U); + virtual ~vsmile_ctrl_port_device(); + + // input signals + void cts_w(int state) { if (m_device) m_device->cts_w(state); } + void data_w(uint8_t data) { if (m_device) m_device->data_w(data); } + +protected: + // device_t implementation + virtual void device_validity_check(validity_checker &valid) const override ATTR_COLD; + virtual void device_resolve_objects() override; + virtual void device_start() override; + +private: + device_vsmile_ctrl_interface *m_device; + devcb_write_line m_rts_cb; + devcb_write8 m_data_cb; + + friend class device_vsmile_ctrl_interface; +}; + + +/*************************************************************************** + INLINE FUNCTIONS + ***************************************************************************/ + +inline void device_vsmile_ctrl_interface::rts_out(int state) { m_port->m_rts_cb(state); } +inline void device_vsmile_ctrl_interface::data_out(uint8_t data) { m_port->m_data_cb(data); } + + +/*************************************************************************** + FUNCTIONS + ***************************************************************************/ + +void vsmile_controllers(device_slot_interface &device); + + +/*************************************************************************** + DEVICE TYPES + ***************************************************************************/ + +DECLARE_DEVICE_TYPE(VSMILE_CTRL_PORT, vsmile_ctrl_port_device) + +#endif // MAME_BUS_VSMILE_VSMILE_CTRL_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..9489c1f38dd --- /dev/null +++ b/src/devices/bus/vsmile/vsmile_slot.cpp @@ -0,0 +1,257 @@ +// 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; + } +} + + +//------------------------------------------------- +// nvram_alloc - alloc the space for the nvram +//------------------------------------------------- + +void device_vsmile_cart_interface::nvram_alloc(uint32_t size) +{ + m_nvram.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_NVRAM, "vsmile_nvram" }, +}; + +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_NVRAM) + { + 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; + } + + return image_init_result::PASS; +} + + +/*------------------------------------------------- + call_unload + -------------------------------------------------*/ + +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()); + } +} + + +/*------------------------------------------------- + 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..0eceee33a25 --- /dev/null +++ b/src/devices/bus/vsmile/vsmile_slot.h @@ -0,0 +1,122 @@ +// 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_NVRAM +}; + +// ======================> 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 nvram_alloc(uint32_t size); + uint16_t* get_rom_base() { return m_rom; } + uint16_t* get_nvram_base() { return &m_nvram[0]; } + uint32_t get_rom_size() { return m_rom_size; } + 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 m_nvram; +}; + + +// ======================> 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(); } + + 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; } + 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 28c34103492..5a5d8bdda34 100644 --- a/src/devices/machine/spg2xx.cpp +++ b/src/devices/machine/spg2xx.cpp @@ -1385,7 +1385,7 @@ WRITE16_MEMBER(spg2xx_device::io_w) { 128, 256, 512, 1024 }, { 105000, 210000, 420000, 840000 } }; - LOGMASKED(LOG_IO_WRITES, "io_w: Timebase Control = %04x (Source:%s, TMB2:%s, TMB1:%s)\n", data, + LOGMASKED(LOG_TIMERS, "io_w: Timebase Control = %04x (Source:%s, TMB2:%s, TMB1:%s)\n", data, BIT(data, 4) ? "27MHz" : "32768Hz", s_tmb2_sel[BIT(data, 4)][(data >> 2) & 3], s_tmb1_sel[BIT(data, 4)][data & 3]); const uint16_t old = m_io_regs[offset]; m_io_regs[offset] = data; @@ -1408,11 +1408,11 @@ WRITE16_MEMBER(spg2xx_device::io_w) } case 0x11: // Timebase Clear - LOGMASKED(LOG_IO_WRITES, "io_w: Timebase Clear = %04x\n", data); + LOGMASKED(LOG_TIMERS, "io_w: Timebase Clear = %04x\n", data); break; case 0x12: // Timer A Data - LOGMASKED(LOG_IO_WRITES, "io_w: Timer A Data = %04x\n", data); + LOGMASKED(LOG_TIMERS, "io_w: Timer A Data = %04x\n", data); m_io_regs[offset] = data; m_timer_a_preload = data; break; @@ -1421,7 +1421,7 @@ WRITE16_MEMBER(spg2xx_device::io_w) { static const char* const s_source_a[8] = { "0", "0", "32768Hz", "8192Hz", "4096Hz", "1", "0", "ExtClk1" }; static const char* const s_source_b[8] = { "2048Hz", "1024Hz", "256Hz", "TMB1", "4Hz", "2Hz", "1", "ExtClk2" }; - LOGMASKED(LOG_IO_WRITES, "io_w: Timer A Control = %04x (Source A:%s, Source B:%s)\n", data, + LOGMASKED(LOG_TIMERS, "io_w: Timer A Control = %04x (Source A:%s, Source B:%s)\n", data, s_source_a[data & 7], s_source_b[(data >> 3) & 7]); m_io_regs[offset] = data; switch (data & 7) @@ -1480,7 +1480,7 @@ WRITE16_MEMBER(spg2xx_device::io_w) case 0x15: // Timer A IRQ Clear { - LOGMASKED(LOG_IO_WRITES, "io_w: Timer A IRQ Clear\n"); + LOGMASKED(LOG_TIMERS, "io_w: Timer A IRQ Clear\n"); const uint16_t old = IO_IRQ_STATUS; IO_IRQ_STATUS &= ~0x0800; if (IO_IRQ_STATUS != old) @@ -1489,7 +1489,7 @@ WRITE16_MEMBER(spg2xx_device::io_w) } case 0x16: // Timer B Data - LOGMASKED(LOG_IO_WRITES, "io_w: Timer B Data = %04x\n", data); + LOGMASKED(LOG_TIMERS, "io_w: Timer B Data = %04x\n", data); m_io_regs[offset] = data; m_timer_b_preload = data; break; @@ -1497,7 +1497,7 @@ WRITE16_MEMBER(spg2xx_device::io_w) case 0x17: // Timer B Control { static const char* const s_source_c[8] = { "0", "0", "32768Hz", "8192Hz", "4096Hz", "1", "0", "ExtClk1" }; - LOGMASKED(LOG_IO_WRITES, "io_w: Timer B Control = %04x (Source C:%s)\n", data, s_source_c[data & 7]); + LOGMASKED(LOG_TIMERS, "io_w: Timer B Control = %04x (Source C:%s)\n", data, s_source_c[data & 7]); m_io_regs[offset] = data; if (m_io_regs[0x18] == 1) { @@ -1508,7 +1508,7 @@ WRITE16_MEMBER(spg2xx_device::io_w) case 0x18: // Timer B Enable { - LOGMASKED(LOG_IO_WRITES, "io_w: Timer B Enable = %04x\n", data); + LOGMASKED(LOG_TIMERS, "io_w: Timer B Enable = %04x\n", data); m_io_regs[offset] = data & 1; if (data & 1) { @@ -1523,7 +1523,7 @@ WRITE16_MEMBER(spg2xx_device::io_w) case 0x19: // Timer B IRQ Clear { - LOGMASKED(LOG_IO_WRITES, "io_w: Timer B IRQ Clear\n"); + LOGMASKED(LOG_TIMERS, "io_w: Timer B IRQ Clear\n"); const uint16_t old = IO_IRQ_STATUS; IO_IRQ_STATUS &= ~0x0400; if (IO_IRQ_STATUS != old) @@ -1860,16 +1860,20 @@ void spg2xx_device::device_timer(emu_timer &timer, device_timer_id id, int param case TIMER_TMB1: { LOGMASKED(LOG_TIMERS, "TMB1 elapsed, setting IRQ Status bit 0 (old:%04x, new:%04x, enable:%04x)\n", IO_IRQ_STATUS, IO_IRQ_STATUS | 1, IO_IRQ_ENABLE); + const uint16_t old = IO_IRQ_STATUS; IO_IRQ_STATUS |= 1; - check_irqs(0x0001); + if (old ^ (IO_IRQ_STATUS & IO_IRQ_ENABLE)) + check_irqs(0x0001); break; } case TIMER_TMB2: { LOGMASKED(LOG_TIMERS, "TMB2 elapsed, setting IRQ Status bit 1 (old:%04x, new:%04x, enable:%04x)\n", IO_IRQ_STATUS, IO_IRQ_STATUS | 2, IO_IRQ_ENABLE); + const uint16_t old = IO_IRQ_STATUS; IO_IRQ_STATUS |= 2; - check_irqs(0x0002); + if (old ^ (IO_IRQ_STATUS & IO_IRQ_ENABLE)) + check_irqs(0x0002); break; } @@ -1916,6 +1920,7 @@ void spg2xx_device::device_timer(emu_timer &timer, device_timer_id id, int param void spg2xx_device::system_timer_tick() { + const uint16_t old = IO_IRQ_STATUS; uint16_t check_mask = 0x0040; IO_IRQ_STATUS |= 0x0040; @@ -1943,7 +1948,8 @@ void spg2xx_device::system_timer_tick() } } - check_irqs(check_mask); + if (old ^ (IO_IRQ_STATUS & IO_IRQ_ENABLE)) + check_irqs(check_mask); } void spg2xx_device::uart_transmit_tick() @@ -2011,7 +2017,7 @@ void spg2xx_device::check_irqs(const uint16_t changed) if (changed & 0x0c00) // Timer A, Timer B IRQ { - LOGMASKED(LOG_IRQS, "%ssserting IRQ2 (%04x)\n", (IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x0c00) ? "A" : "Dea", (IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x0c00)); + LOGMASKED(LOG_TIMERS, "%ssserting IRQ2 (%04x)\n", (IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x0c00) ? "A" : "Dea", (IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x0c00)); m_cpu->set_state_unsynced(UNSP_IRQ2_LINE, (IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x0c00) ? ASSERT_LINE : CLEAR_LINE); } @@ -2043,7 +2049,7 @@ void spg2xx_device::check_irqs(const uint16_t changed) if (changed & 0x0070) // 1024Hz, 2048Hz, 4096Hz IRQ { - LOGMASKED(LOG_IRQS, "%ssserting IRQ6 (%04x)\n", (IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x0070) ? "A" : "Dea", (IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x0070)); + LOGMASKED(LOG_TIMERS, "%ssserting IRQ6 (%04x)\n", (IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x0070) ? "A" : "Dea", (IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x0070)); m_cpu->set_state_unsynced(UNSP_IRQ6_LINE, (IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x0070) ? ASSERT_LINE : CLEAR_LINE); } diff --git a/src/mame/drivers/vsmile.cpp b/src/mame/drivers/vsmile.cpp index 98620231f2c..524f58bdac1 100644 --- a/src/mame/drivers/vsmile.cpp +++ b/src/mame/drivers/vsmile.cpp @@ -1,8 +1,9 @@ // license:BSD-3-Clause -// copyright-holders:David Haywood +// copyright-holders:Ryan Holtz /****************************************************************************** - V-Tech V.Smile skeleton driver + V-Tech V.Smile console emulation + V-Tech V.Smile Baby console emulation Similar Systems: @@ -18,26 +19,34 @@ #include "emu.h" +#include "bus/generic/slot.h" +#include "bus/generic/carts.h" +#include "bus/vsmile/vsmile_ctrl.h" +#include "bus/vsmile/vsmile_slot.h" +#include "bus/vsmile/rom.h" + #include "cpu/unsp/unsp.h" +#include "machine/bankdev.h" #include "machine/spg2xx.h" #include "screen.h" #include "softlist.h" #include "speaker.h" -class vsmile_state : public driver_device +class vsmile_base_state : public driver_device { public: - vsmile_state(const machine_config &mconfig, device_type type, const char *tag) + vsmile_base_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag) , m_spg(*this, "spg") , m_maincpu(*this, "maincpu") , m_screen(*this, "screen") + , m_bankdev(*this, "bank") + , m_system_region(*this, "maincpu") { } - void vsmile(machine_config &config); - void vsmileb(machine_config &config); + void vsmile_base(machine_config &config); protected: void mem_map(address_map &map); @@ -45,21 +54,520 @@ protected: required_device m_spg; required_device m_maincpu; required_device m_screen; + required_device m_bankdev; + required_memory_region m_system_region; }; -void vsmile_state::mem_map(address_map &map) +class vsmile_state : public vsmile_base_state { - map(0x000000, 0x3fffff).rom().region("maincpu", 0); +public: + vsmile_state(const machine_config &mconfig, device_type type, const char *tag) + : vsmile_base_state(mconfig, type, tag) + , m_cart(*this, "cartslot") + , m_ctrl(*this, "ctrl%u", 1U) + , m_io_joy(*this, "JOY") + , m_io_colors(*this, "COLORS") + , m_io_buttons(*this, "BUTTONS") + , m_dsw_region(*this, "REGION") + , m_uart_tx_timer(nullptr) + , m_pad_timer(nullptr) + { } + + void vsmile(machine_config &config); + void vsmilep(machine_config &config); + + DECLARE_INPUT_CHANGED_MEMBER(pad_joy_changed); + DECLARE_INPUT_CHANGED_MEMBER(pad_color_changed); + DECLARE_INPUT_CHANGED_MEMBER(pad_button_changed); + +private: + virtual void machine_start() override; + virtual void machine_reset() override; + virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; + + static const device_timer_id TIMER_UART_TX = 0; + static const device_timer_id TIMER_PAD = 1; + + void banked_map(address_map &map); + + DECLARE_READ16_MEMBER(portb_r); + DECLARE_READ16_MEMBER(portc_r); + DECLARE_WRITE16_MEMBER(portc_w); + + DECLARE_WRITE8_MEMBER(chip_sel_w); + + DECLARE_WRITE8_MEMBER(uart_rx); + void uart_tx_fifo_push(uint8_t data); + void handle_uart_tx(); + + DECLARE_READ16_MEMBER(bank3_r); + + enum + { + VSMILE_PORTB_CS1 = 0x01, + VSMILE_PORTB_CS2 = 0x02, + VSMILE_PORTB_CART = 0x04, + VSMILE_PORTB_RESET = 0x08, + VSMILE_PORTB_FRONT24 = 0x10, + VSMILE_PORTB_OFF = 0x20, + VSMILE_PORTB_OFF_SW = 0x40, + VSMILE_PORTB_ON_SW = 0x80, + + VSMILE_PORTC_VER = 0x0f, + VSMILE_PORTC_LOGO = 0x10, + VSMILE_PORTC_TEST = 0x20, + VSMILE_PORTC_AMP = 0x40, + VSMILE_PORTC_SYSRESET = 0x80, + + XMIT_STATE_IDLE = 0, + XMIT_STATE_RTS = 1, + XMIT_STATE_CTS = 2 + }; + + required_device m_cart; + required_device_array m_ctrl; + required_ioport m_io_joy; + required_ioport m_io_colors; + required_ioport m_io_buttons; + required_ioport m_dsw_region; + + bool m_ctrl_cts[2]; + bool m_ctrl_rts[2]; + uint8_t m_ctrl_probe_history[2]; + uint8_t m_ctrl_probe_count; + uint8_t m_uart_tx_fifo[32]; // arbitrary size + uint8_t m_uart_tx_fifo_start; + uint8_t m_uart_tx_fifo_end; + uint8_t m_uart_tx_fifo_count; + emu_timer *m_uart_tx_timer; + int m_uart_tx_state; + + emu_timer *m_pad_timer; +}; + +class vsmileb_state : public vsmile_base_state +{ +public: + vsmileb_state(const machine_config &mconfig, device_type type, const char *tag) + : vsmile_base_state(mconfig, type, tag) + , m_cart(*this, "cartslot") + , m_io_logo(*this, "LOGO") + , m_cart_region(nullptr) + , m_cart_addr_mask(0) + { } + + void vsmileb(machine_config &config); + +private: + virtual void machine_start() override; + + void banked_map(address_map &map); + + DECLARE_DEVICE_IMAGE_LOAD_MEMBER(cart); + + DECLARE_READ16_MEMBER(porta_r); + DECLARE_READ16_MEMBER(portb_r); + DECLARE_READ16_MEMBER(portc_r); + DECLARE_WRITE16_MEMBER(porta_w); + DECLARE_WRITE16_MEMBER(portb_w); + DECLARE_WRITE16_MEMBER(portc_w); + DECLARE_WRITE8_MEMBER(chip_sel_w); + + required_device m_cart; + required_ioport m_io_logo; + + memory_region *m_cart_region; + uint32_t m_cart_addr_mask; +}; + +/************************************ + * + * Common + * + ************************************/ + +void vsmile_base_state::mem_map(address_map &map) +{ + 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)); } +/************************************ + * + * V.Smile + * + ************************************/ + +void vsmile_state::machine_start() +{ + vsmile_base_state::machine_start(); + + m_bankdev->set_bank(m_cart && m_cart->exists() ? 4 : 0); + + m_pad_timer = timer_alloc(TIMER_PAD); + m_pad_timer->adjust(attotime::never); + + m_uart_tx_timer = timer_alloc(TIMER_UART_TX); + m_uart_tx_timer->adjust(attotime::never); + + save_item(NAME(m_ctrl_cts)); + save_item(NAME(m_ctrl_rts)); + save_item(NAME(m_ctrl_probe_history)); + save_item(NAME(m_ctrl_probe_count)); + save_item(NAME(m_uart_tx_fifo)); + save_item(NAME(m_uart_tx_fifo_start)); + save_item(NAME(m_uart_tx_fifo_end)); + save_item(NAME(m_uart_tx_fifo_count)); +} + +void vsmile_state::machine_reset() +{ + m_pad_timer->adjust(attotime::from_hz(1), 0, attotime::from_hz(1)); + m_uart_tx_timer->adjust(attotime::from_hz(9600/10), 0, attotime::from_hz(9600/10)); + + memset(m_ctrl_cts, 0, sizeof(bool) * 2); + memset(m_ctrl_rts, 0, sizeof(bool) * 2); + memset(m_ctrl_probe_history, 0, 2); + m_ctrl_probe_count = 0; + memset(m_uart_tx_fifo, 0, 32); + m_uart_tx_fifo_start = 0; + m_uart_tx_fifo_end = 0; + m_uart_tx_fifo_count = 0; + m_uart_tx_state = XMIT_STATE_IDLE; +} + +void vsmile_state::uart_tx_fifo_push(uint8_t data) +{ + if (m_uart_tx_fifo_count == ARRAY_LENGTH(m_uart_tx_fifo)) + { + logerror("Warning: Trying to push more than %d bytes onto the controller Tx FIFO, data will be lost\n", ARRAY_LENGTH(m_uart_tx_fifo)); + } + + m_uart_tx_fifo[m_uart_tx_fifo_end] = data; + m_uart_tx_fifo_count++; + m_uart_tx_fifo_end = (m_uart_tx_fifo_end + 1) % ARRAY_LENGTH(m_uart_tx_fifo); +} + +void vsmile_state::handle_uart_tx() +{ + if (m_uart_tx_fifo_count == 0) + return; + + if (m_uart_tx_state == XMIT_STATE_IDLE) + { + m_uart_tx_state = XMIT_STATE_RTS; + m_ctrl_rts[0] = true; + m_spg->extint_w(0, true); + return; + } + + m_spg->uart_rx(m_uart_tx_fifo[m_uart_tx_fifo_start]); + m_uart_tx_fifo_start = (m_uart_tx_fifo_start + 1) % ARRAY_LENGTH(m_uart_tx_fifo); + m_uart_tx_fifo_count--; + if (m_uart_tx_fifo_count == 0) + { + m_uart_tx_state = XMIT_STATE_IDLE; + m_ctrl_rts[0] = false; + m_spg->extint_w(0, false); + //m_uart_tx_timer->adjust(attotime::never); + } +} + +WRITE8_MEMBER(vsmile_state::uart_rx) +{ + if ((data >> 4) == 7 || (data >> 4) == 11) + { + m_ctrl_probe_history[0] = m_ctrl_probe_history[1]; + m_ctrl_probe_history[1] = data; + const uint8_t response = ((m_ctrl_probe_history[0] + m_ctrl_probe_history[1] + 0x0f) & 0x0f) ^ 0x05; + uart_tx_fifo_push(0xb0 | response); + } +} + +void vsmile_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +{ + switch (id) + { + case TIMER_UART_TX: + handle_uart_tx(); + break; + case TIMER_PAD: + uart_tx_fifo_push(0x55); + break; + default: + logerror("Unknown timer ID: %d\n", id); + break; + } +} + +READ16_MEMBER(vsmile_state::bank3_r) +{ + return ((uint16_t*)m_system_region->base())[offset]; +} + +READ16_MEMBER(vsmile_state::portb_r) +{ + return VSMILE_PORTB_OFF_SW | VSMILE_PORTB_ON_SW | VSMILE_PORTB_RESET; +} + +READ16_MEMBER(vsmile_state::portc_r) +{ + uint16_t data = m_dsw_region->read(); + data |= m_ctrl_rts[0] ? 0 : 0x0400; + data |= m_ctrl_rts[1] ? 0 : 0x1000; + data |= 0x2000; + //data = machine().rand() & 0xffff; + return data; +} + +WRITE16_MEMBER(vsmile_state::portc_w) +{ + if (BIT(mem_mask, 8)) + { + m_ctrl_cts[0] = BIT(data, 8); + if (m_uart_tx_state == XMIT_STATE_RTS) + m_uart_tx_state = XMIT_STATE_CTS; + } + if (BIT(mem_mask, 9)) + { + m_ctrl_cts[1] = BIT(data, 9); + } +} + +INPUT_CHANGED_MEMBER(vsmile_state::pad_joy_changed) +{ + const uint8_t value = m_io_joy->read(); + + if (BIT(value, 2)) + uart_tx_fifo_push(0xcf); + else if (BIT(value, 3)) + uart_tx_fifo_push(0xc7); + else + uart_tx_fifo_push(0xc0); + + if (BIT(value, 0)) + uart_tx_fifo_push(0x87); + else if (BIT(value, 1)) + uart_tx_fifo_push(0x8f); + else + uart_tx_fifo_push(0x80); +} + +INPUT_CHANGED_MEMBER(vsmile_state::pad_color_changed) +{ + uart_tx_fifo_push(0x90 | m_io_colors->read()); +} + +INPUT_CHANGED_MEMBER(vsmile_state::pad_button_changed) +{ + const uint8_t value = m_io_buttons->read(); + const size_t bit = reinterpret_cast(param); + if (BIT(value, bit)) + { + uart_tx_fifo_push(0xa1 + (uint8_t)bit); + } + else + { + uart_tx_fifo_push(0xa0); + } +} + +WRITE8_MEMBER(vsmile_state::chip_sel_w) +{ + const uint16_t cart_offset = m_cart && m_cart->exists() ? 4 : 0; + switch (data) + { + case 0: + m_bankdev->set_bank(cart_offset); + break; + case 1: + m_bankdev->set_bank(1 + cart_offset); + break; + case 2: + case 3: + m_bankdev->set_bank(2 + cart_offset); + break; + } + m_maincpu->invalidate_cache(); +} + +void vsmile_state::banked_map(address_map &map) +{ + map(0x0000000, 0x00fffff).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, 0x04fffff).rom().region("maincpu", 0); + map(0x0500000, 0x05fffff).rom().region("maincpu", 0); + map(0x0600000, 0x06fffff).rom().region("maincpu", 0); + map(0x0700000, 0x07fffff).rom().region("maincpu", 0); + + map(0x0800000, 0x08fffff).rom().region("maincpu", 0); + map(0x0900000, 0x09fffff).rom().region("maincpu", 0); + map(0x0a00000, 0x0afffff).rom().region("maincpu", 0); + map(0x0b00000, 0x0bfffff).rom().region("maincpu", 0); + + map(0x1000000, 0x13fffff).rw(m_cart, FUNC(vsmile_cart_slot_device::bank0_r), FUNC(vsmile_cart_slot_device::bank0_w)); + + 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).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).rw(m_cart, FUNC(vsmile_cart_slot_device::bank2_r), FUNC(vsmile_cart_slot_device::bank2_w)); + map(0x1b00000, 0x1bfffff).r(FUNC(vsmile_state::bank3_r)); +} + +/************************************ + * + * V.Smile Baby + * + ************************************/ + +void vsmileb_state::machine_start() +{ + 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; + } + + m_bankdev->set_bank(0); +} + +DEVICE_IMAGE_LOAD_MEMBER(vsmileb_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; +} + +READ16_MEMBER(vsmileb_state::porta_r) +{ + uint16_t data = 0x0300 | (m_io_logo->read() ? 0x0080 : 0x0000); + logerror("%s: GPIO Port A Read: %04x\n", machine().describe_context(), data); + return data; +} + +READ16_MEMBER(vsmileb_state::portb_r) +{ + uint16_t data = 0x0080; + logerror("%s: GPIO Port B Read: %04x\n", machine().describe_context(), data); + return data; +} + +READ16_MEMBER(vsmileb_state::portc_r) +{ + uint16_t data = 0; + logerror("%s: GPIO Port C Read: %04x\n", machine().describe_context(), data); + return data; +} + +WRITE16_MEMBER(vsmileb_state::porta_w) +{ + logerror("%s: GPIO Port A Write: %04x & %04x = %04x\n", machine().describe_context(), data, mem_mask, data & mem_mask); +} + +WRITE16_MEMBER(vsmileb_state::portb_w) +{ + logerror("%s: GPIO Port B Write: %04x & %04x = %04x\n", machine().describe_context(), data, mem_mask, data & mem_mask); +} + +WRITE16_MEMBER(vsmileb_state::portc_w) +{ + logerror("%s: GPIO Port C Write: %04x & %04x = %04x\n", machine().describe_context(), data, mem_mask, data & mem_mask); +} + +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(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); +} + +/************************************ + * + * Inputs + * + ************************************/ + static INPUT_PORTS_START( vsmile ) + PORT_START("JOY") + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_state, pad_joy_changed, 0) PORT_NAME("Joypad Up") + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_state, pad_joy_changed, 0) PORT_NAME("Joypad Down") + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_state, pad_joy_changed, 0) PORT_NAME("Joypad Left") + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_state, pad_joy_changed, 0) PORT_NAME("Joypad Right") + PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED ) + + PORT_START("COLORS") + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_state, pad_color_changed, 0) PORT_NAME("Green") + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_state, pad_color_changed, 0) PORT_NAME("Blue") + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_state, pad_color_changed, 0) PORT_NAME("Yellow") + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_state, pad_color_changed, 0) PORT_NAME("Red") + PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED ) + + PORT_START("BUTTONS") + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_state, pad_button_changed, 0) PORT_NAME("OK") + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_state, pad_button_changed, 1) PORT_NAME("Quit") + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON7 ) PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_state, pad_button_changed, 2) PORT_NAME("Help") + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON8 ) PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_state, pad_button_changed, 3) PORT_NAME("ABC") + PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED ) + + PORT_START("REGION") + PORT_DIPNAME( 0x0f, 0x04, "BIOS Region" ) + PORT_DIPSETTING( 0x04, "UK/US" ) + PORT_DIPSETTING( 0x07, "China" ) + PORT_DIPSETTING( 0x08, "Mexico" ) + PORT_DIPSETTING( 0x0a, "Italy" ) + PORT_DIPSETTING( 0x0b, "Germany" ) + PORT_DIPSETTING( 0x0c, "Spain" ) + PORT_DIPSETTING( 0x0d, "France" ) + PORT_DIPNAME( 0x10, 0x10, "VTech Intro" ) + PORT_DIPSETTING( 0x00, "Off" ) + PORT_DIPSETTING( 0x10, "On" ) + PORT_BIT( 0xe0, 0x00, IPT_UNUSED ) INPUT_PORTS_END -void vsmile_state::vsmile(machine_config &config) +static INPUT_PORTS_START( vsmileb ) + PORT_START("LOGO") + PORT_DIPNAME( 0x10, 0x10, "VTech Intro" ) + PORT_DIPSETTING( 0x00, "Off" ) + PORT_DIPSETTING( 0x10, "On" ) + PORT_BIT( 0xe0, 0x00, IPT_UNUSED ) +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_nvram", VSMILE_ROM_NVRAM); +} + +void vsmile_base_state::vsmile_base(machine_config &config) { UNSP(config, m_maincpu, XTAL(27'000'000)); - m_maincpu->set_addrmap(AS_PROGRAM, &vsmile_state::mem_map); + m_maincpu->set_addrmap(AS_PROGRAM, &vsmile_base_state::mem_map); m_maincpu->set_force_no_drc(true); SCREEN(config, m_screen, SCREEN_TYPE_RASTER); @@ -75,6 +583,65 @@ void vsmile_state::vsmile(machine_config &config) SPG24X(config, m_spg, XTAL(27'000'000), m_maincpu, m_screen); m_spg->add_route(ALL_OUTPUTS, "lspeaker", 0.5); m_spg->add_route(ALL_OUTPUTS, "rspeaker", 0.5); + + ADDRESS_MAP_BANK(config, m_bankdev); + m_bankdev->set_endianness(ENDIANNESS_LITTLE); + m_bankdev->set_data_width(16); + m_bankdev->set_shift(-1); + m_bankdev->set_stride(0x400000); +} + +void vsmile_state::vsmile(machine_config &config) +{ + vsmile_base(config); + + m_spg->portb_in().set(FUNC(vsmile_state::portb_r)); + m_spg->portc_in().set(FUNC(vsmile_state::portc_r)); + m_spg->portc_out().set(FUNC(vsmile_state::portc_w)); + m_spg->chip_select().set(FUNC(vsmile_state::chip_sel_w)); + m_spg->uart_tx().set(FUNC(vsmile_state::uart_rx)); + + m_bankdev->set_addrmap(AS_PROGRAM, &vsmile_state::banked_map); + + VSMILE_CART_SLOT(config, m_cart, vsmile_cart, nullptr); + + VSMILE_CTRL_PORT(config, m_ctrl[0], vsmile_controllers, "joy"); + m_ctrl[0]->rts_cb().set([this] (int state) { logerror("controller 1 RTS: %d\n", state); }); + m_ctrl[0]->data_cb().set([this] (int data) { logerror("controller 1 data: %02X\n", data); }); + + VSMILE_CTRL_PORT(config, m_ctrl[1], vsmile_controllers, nullptr); + m_ctrl[1]->rts_cb().set([this] (int state) { logerror("controller 2 RTS: %d\n", state); }); + m_ctrl[1]->data_cb().set([this] (int data) { logerror("controller 2 data: %02X\n", data); }); + + SOFTWARE_LIST(config, "cart_list").set_original("vsmile_cart"); + SOFTWARE_LIST(config, "cart_list2").set_original("vsmilem_cart"); +} + +void vsmile_state::vsmilep(machine_config &config) +{ + vsmile(config); + m_spg->set_pal(true); +} + +void vsmileb_state::vsmileb(machine_config &config) +{ + vsmile_base(config); + + m_spg->porta_in().set(FUNC(vsmileb_state::porta_r)); + m_spg->portb_in().set(FUNC(vsmileb_state::portb_r)); + m_spg->portc_in().set(FUNC(vsmileb_state::portc_r)); + m_spg->porta_out().set(FUNC(vsmileb_state::porta_w)); + m_spg->portb_out().set(FUNC(vsmileb_state::portb_w)); + m_spg->portc_out().set(FUNC(vsmileb_state::portc_w)); + m_spg->chip_select().set(FUNC(vsmileb_state::chip_sel_w)); + + m_bankdev->set_addrmap(AS_PROGRAM, &vsmileb_state::banked_map); + + 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(&vsmileb_state::device_image_load_cart, this)); + + SOFTWARE_LIST(config, "cart_list").set_original("vsmileb_cart"); } ROM_START( vsmile ) @@ -97,8 +664,8 @@ ROM_START( vsmileb ) ROM_LOAD( "vbabybios.bin", 0x000000, 0x800000, CRC(ddc7f845) SHA1(2c17d0f54200070176d03d44a40c7923636e596a) ) ROM_END -// year, name, parent, compat, machine, input, class, init, company, fullname, flags -CONS( 2005, vsmile, 0, 0, vsmile, vsmile, vsmile_state, empty_init, "VTech", "V.Smile (US)", MACHINE_IS_SKELETON ) -CONS( 2005, vsmileg, vsmile, 0, vsmile, vsmile, vsmile_state, empty_init, "VTech", "V.Smile (Germany)", MACHINE_IS_SKELETON ) -CONS( 2005, vsmilef, vsmile, 0, vsmile, vsmile, vsmile_state, empty_init, "VTech", "V.Smile (France)", MACHINE_IS_SKELETON ) -CONS( 2005, vsmileb, 0, 0, vsmile, vsmile, vsmile_state, empty_init, "VTech", "V.Smile Baby (US)", MACHINE_IS_SKELETON ) +// year, name, parent, compat, machine, input, class, init, company, fullname, flags +CONS( 2005, vsmile, 0, 0, vsmile, vsmile, vsmile_state, empty_init, "VTech", "V.Smile (US)", MACHINE_NOT_WORKING | MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS ) +CONS( 2005, vsmileg, vsmile, 0, vsmilep, vsmile, vsmile_state, empty_init, "VTech", "V.Smile (Germany)", MACHINE_NOT_WORKING | MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS ) +CONS( 2005, vsmilef, vsmile, 0, vsmilep, vsmile, vsmile_state, empty_init, "VTech", "V.Smile (France)", MACHINE_NOT_WORKING | MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS ) +CONS( 2005, vsmileb, 0, 0, vsmileb, vsmileb, vsmileb_state, empty_init, "VTech", "V.Smile Baby (US)", MACHINE_NOT_WORKING | MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS )