1 // license:BSD-3-Clause 2 // copyright-holders:Ryan Holtz 3 /****************************************************************************** 4 5 V-Tech V.Smile console emulation 6 V-Tech V.Smile Baby console emulation 7 8 Similar Systems: 9 10 V.Smile Pocket 11 V.Smile Cyber Pocket 12 V.Smile PC Pal 13 V-Motion Active Learning System 14 V.Flash 15 V.Baby 16 Leapfrog Leapster 17 18 *******************************************************************************/ 19 20 #ifndef MAME_INCLUDES_VSMILE_H 21 #define MAME_INCLUDES_VSMILE_H 22 23 #include "bus/vsmile/vsmile_ctrl.h" 24 #include "bus/vsmile/vsmile_slot.h" 25 #include "bus/vsmile/rom.h" 26 27 #include "cpu/unsp/unsp.h" 28 29 #include "machine/bankdev.h" 30 #include "machine/spg2xx.h" 31 32 #include "screen.h" 33 34 class vsmile_base_state : public driver_device 35 { 36 public: vsmile_base_state(const machine_config & mconfig,device_type type,const char * tag)37 vsmile_base_state(const machine_config &mconfig, device_type type, const char *tag) 38 : driver_device(mconfig, type, tag) 39 , m_maincpu(*this, "maincpu") 40 , m_screen(*this, "screen") 41 , m_bankdev(*this, "bank") 42 , m_cart(*this, "cartslot") 43 , m_system_region(*this, "sysrom") 44 { } 45 46 void vsmile_base(machine_config &config); 47 48 protected: 49 virtual void machine_start() override; 50 51 void mem_map(address_map &map); 52 53 void chip_sel_w(uint8_t data); 54 55 uint16_t bank3_r(offs_t offset); 56 57 required_device<spg2xx_device> m_maincpu; 58 required_device<screen_device> m_screen; 59 required_device<address_map_bank_device> m_bankdev; 60 required_device<vsmile_cart_slot_device> m_cart; 61 required_memory_region m_system_region; 62 }; 63 64 class vsmile_state : public vsmile_base_state 65 { 66 public: vsmile_state(const machine_config & mconfig,device_type type,const char * tag)67 vsmile_state(const machine_config &mconfig, device_type type, const char *tag) 68 : vsmile_base_state(mconfig, type, tag) 69 , m_ctrl(*this, "ctrl%u", 1U) 70 , m_dsw_region(*this, "REGION") 71 , m_redled(*this, "redled%u", 1U) 72 , m_yellowled(*this, "yellowled%u", 1U) 73 , m_blueled(*this, "blueled%u", 1U) 74 , m_greenled(*this, "greenled%u", 1U) 75 { } 76 77 void vsmile(machine_config &config); 78 void vsmilep(machine_config &config); 79 80 private: 81 virtual void machine_start() override; 82 virtual void machine_reset() override; 83 84 void banked_map(address_map &map); 85 86 void ctrl_tx_w(uint8_t data); 87 template <int Which> DECLARE_WRITE_LINE_MEMBER(ctrl_rts_w); 88 89 uint16_t portb_r(); 90 void portb_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 91 uint16_t portc_r(); 92 void portc_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 93 94 void uart_rx(uint8_t data); 95 96 enum 97 { 98 VSMILE_PORTB_CS1 = 0x01, 99 VSMILE_PORTB_CS2 = 0x02, 100 VSMILE_PORTB_CART = 0x04, 101 VSMILE_PORTB_RESET = 0x08, 102 VSMILE_PORTB_FRONT24 = 0x10, 103 VSMILE_PORTB_OFF = 0x20, 104 VSMILE_PORTB_OFF_SW = 0x40, 105 VSMILE_PORTB_ON_SW = 0x80, 106 107 VSMILE_PORTC_VER = 0x0f, 108 VSMILE_PORTC_LOGO = 0x10, 109 VSMILE_PORTC_TEST = 0x20, 110 VSMILE_PORTC_AMP = 0x40, 111 VSMILE_PORTC_SYSRESET = 0x80, 112 }; 113 114 required_device_array<vsmile_ctrl_port_device, 2> m_ctrl; 115 required_ioport m_dsw_region; 116 117 output_finder<2> m_redled; 118 output_finder<2> m_yellowled; 119 output_finder<2> m_blueled; 120 output_finder<2> m_greenled; 121 122 bool m_ctrl_rts[2]; 123 bool m_ctrl_select[2]; 124 }; 125 126 class vsmilem_state : public vsmile_state 127 { 128 public: vsmilem_state(const machine_config & mconfig,device_type type,const char * tag)129 vsmilem_state(const machine_config &mconfig, device_type type, const char *tag) 130 : vsmile_state(mconfig, type, tag) 131 { } 132 133 void vsmilem(machine_config &config); 134 135 protected: 136 void porta_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 137 uint16_t porta_r(offs_t offset, uint16_t mem_mask = ~0); 138 }; 139 140 class vsmileb_state : public vsmile_base_state 141 { 142 public: vsmileb_state(const machine_config & mconfig,device_type type,const char * tag)143 vsmileb_state(const machine_config &mconfig, device_type type, const char *tag) 144 : vsmile_base_state(mconfig, type, tag) 145 , m_io_logo(*this, "LOGO") 146 { } 147 148 void vsmileb(machine_config &config); 149 void vsmilebp(machine_config &config); 150 151 enum : uint16_t 152 { 153 BUTTON_YELLOW = 0x01fe, 154 BUTTON_BLUE = 0x03ee, 155 BUTTON_ORANGE = 0x03de, 156 BUTTON_GREEN = 0x03be, 157 BUTTON_RED = 0x02fe, 158 BUTTON_CLOUD = 0x03f6, 159 BUTTON_BALL = 0x03fa, 160 BUTTON_EXIT = 0x03fc 161 }; 162 163 DECLARE_INPUT_CHANGED_MEMBER(pad_button_changed); 164 165 // make slide switches usable on a keyboard 166 template <uint16_t V> DECLARE_INPUT_CHANGED_MEMBER(sw_mode); 167 168 private: 169 virtual void machine_start() override; 170 virtual void machine_reset() override; 171 172 void banked_map(address_map &map); 173 174 uint16_t porta_r(); 175 uint16_t portb_r(); 176 177 required_ioport m_io_logo; 178 179 uint16_t m_mode; 180 }; 181 182 #endif // MAME_INCLUDES_VSMILE_H 183