src/mess/machine/plus4exp.c
| r0 | r15528 | |
| 1 | /**********************************************************************
|
| 2 | |
| 3 | Commodore Plus/4 Expansion Port emulation
|
| 4 | |
| 5 | Copyright MESS Team.
|
| 6 | Visit http://mamedev.org for licensing and usage restrictions.
|
| 7 | |
| 8 | **********************************************************************/
|
| 9 | |
| 10 | #include "machine/plus4exp.h"
|
| 11 | |
| 12 | |
| 13 | |
| 14 | //**************************************************************************
|
| 15 | // MACROS/CONSTANTS
|
| 16 | //**************************************************************************
|
| 17 | |
| 18 | #define LOG 0
|
| 19 | |
| 20 | |
| 21 | |
| 22 | //**************************************************************************
|
| 23 | // DEVICE DEFINITIONS
|
| 24 | //**************************************************************************
|
| 25 | |
| 26 | const device_type PLUS4_EXPANSION_SLOT = &device_creator<plus4_expansion_slot_device>;
|
| 27 | |
| 28 | |
| 29 | |
| 30 | //**************************************************************************
|
| 31 | // DEVICE PLUS4_EXPANSION CARD INTERFACE
|
| 32 | //**************************************************************************
|
| 33 | |
| 34 | //-------------------------------------------------
|
| 35 | // device_plus4_expansion_card_interface - constructor
|
| 36 | //-------------------------------------------------
|
| 37 | |
| 38 | device_plus4_expansion_card_interface::device_plus4_expansion_card_interface(const machine_config &mconfig, device_t &device)
|
| 39 | : device_slot_card_interface(mconfig, device),
|
| 40 | m_c1l(NULL),
|
| 41 | m_c1h(NULL),
|
| 42 | m_c2l(NULL),
|
| 43 | m_c2h(NULL),
|
| 44 | m_ram(NULL),
|
| 45 | m_nvram(NULL),
|
| 46 | m_nvram_size(0),
|
| 47 | m_c1l_mask(0),
|
| 48 | m_c1h_mask(0),
|
| 49 | m_c2l_mask(0),
|
| 50 | m_c2h_mask(0),
|
| 51 | m_ram_mask(0)
|
| 52 | {
|
| 53 | m_slot = dynamic_cast<plus4_expansion_slot_device *>(device.owner());
|
| 54 | }
|
| 55 | |
| 56 | |
| 57 | //-------------------------------------------------
|
| 58 | // ~device_plus4_expansion_card_interface - destructor
|
| 59 | //-------------------------------------------------
|
| 60 | |
| 61 | device_plus4_expansion_card_interface::~device_plus4_expansion_card_interface()
|
| 62 | {
|
| 63 | }
|
| 64 | |
| 65 | |
| 66 | //-------------------------------------------------
|
| 67 | // plus4_c1l_pointer - get low ROM 1 pointer
|
| 68 | //-------------------------------------------------
|
| 69 | |
| 70 | UINT8* device_plus4_expansion_card_interface::plus4_c1l_pointer(running_machine &machine, size_t size)
|
| 71 | {
|
| 72 | if (m_c1l == NULL)
|
| 73 | {
|
| 74 | m_c1l = auto_alloc_array(machine, UINT8, size);
|
| 75 | |
| 76 | m_c1l_mask = size - 1;
|
| 77 | }
|
| 78 | |
| 79 | return m_c1l;
|
| 80 | }
|
| 81 | |
| 82 | |
| 83 | //-------------------------------------------------
|
| 84 | // plus4_c1h_pointer - get low ROM 1 pointer
|
| 85 | //-------------------------------------------------
|
| 86 | |
| 87 | UINT8* device_plus4_expansion_card_interface::plus4_c1h_pointer(running_machine &machine, size_t size)
|
| 88 | {
|
| 89 | if (m_c1h == NULL)
|
| 90 | {
|
| 91 | m_c1h = auto_alloc_array(machine, UINT8, size);
|
| 92 | |
| 93 | m_c1h_mask = size - 1;
|
| 94 | }
|
| 95 | |
| 96 | return m_c1h;
|
| 97 | }
|
| 98 | |
| 99 | |
| 100 | //-------------------------------------------------
|
| 101 | // plus4_c2l_pointer - get low ROM 1 pointer
|
| 102 | //-------------------------------------------------
|
| 103 | |
| 104 | UINT8* device_plus4_expansion_card_interface::plus4_c2l_pointer(running_machine &machine, size_t size)
|
| 105 | {
|
| 106 | if (m_c2l == NULL)
|
| 107 | {
|
| 108 | m_c2l = auto_alloc_array(machine, UINT8, size);
|
| 109 | |
| 110 | m_c2l_mask = size - 1;
|
| 111 | }
|
| 112 | |
| 113 | return m_c2l;
|
| 114 | }
|
| 115 | |
| 116 | |
| 117 | //-------------------------------------------------
|
| 118 | // plus4_c2h_pointer - get low ROM 1 pointer
|
| 119 | //-------------------------------------------------
|
| 120 | |
| 121 | UINT8* device_plus4_expansion_card_interface::plus4_c2h_pointer(running_machine &machine, size_t size)
|
| 122 | {
|
| 123 | if (m_c2h == NULL)
|
| 124 | {
|
| 125 | m_c2h = auto_alloc_array(machine, UINT8, size);
|
| 126 | |
| 127 | m_c2h_mask = size - 1;
|
| 128 | }
|
| 129 | |
| 130 | return m_c2h;
|
| 131 | }
|
| 132 | |
| 133 | |
| 134 | //-------------------------------------------------
|
| 135 | // plus4_ram_pointer - get RAM pointer
|
| 136 | //-------------------------------------------------
|
| 137 | |
| 138 | UINT8* device_plus4_expansion_card_interface::plus4_ram_pointer(running_machine &machine, size_t size)
|
| 139 | {
|
| 140 | if (m_ram == NULL)
|
| 141 | {
|
| 142 | m_ram = auto_alloc_array(machine, UINT8, size);
|
| 143 | |
| 144 | m_ram_mask = size - 1;
|
| 145 | }
|
| 146 | |
| 147 | return m_ram;
|
| 148 | }
|
| 149 | |
| 150 | |
| 151 | //-------------------------------------------------
|
| 152 | // plus4_ram_pointer - get NVRAM pointer
|
| 153 | //-------------------------------------------------
|
| 154 | |
| 155 | UINT8* device_plus4_expansion_card_interface::plus4_nvram_pointer(running_machine &machine, size_t size)
|
| 156 | {
|
| 157 | if (m_nvram == NULL)
|
| 158 | {
|
| 159 | m_nvram = auto_alloc_array(machine, UINT8, size);
|
| 160 | |
| 161 | m_nvram_mask = size - 1;
|
| 162 | m_nvram_size = size;
|
| 163 | }
|
| 164 | |
| 165 | return m_nvram;
|
| 166 | }
|
| 167 | |
| 168 | |
| 169 | |
| 170 | //**************************************************************************
|
| 171 | // LIVE DEVICE
|
| 172 | //**************************************************************************
|
| 173 | |
| 174 | //-------------------------------------------------
|
| 175 | // plus4_expansion_slot_device - constructor
|
| 176 | //-------------------------------------------------
|
| 177 | |
| 178 | plus4_expansion_slot_device::plus4_expansion_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
|
| 179 | device_t(mconfig, PLUS4_EXPANSION_SLOT, "Plus/4 expansion port", tag, owner, clock),
|
| 180 | device_slot_interface(mconfig, *this),
|
| 181 | device_image_interface(mconfig, *this)
|
| 182 | {
|
| 183 | }
|
| 184 | |
| 185 | |
| 186 | //-------------------------------------------------
|
| 187 | // plus4_expansion_slot_device - destructor
|
| 188 | //-------------------------------------------------
|
| 189 | |
| 190 | plus4_expansion_slot_device::~plus4_expansion_slot_device()
|
| 191 | {
|
| 192 | }
|
| 193 | |
| 194 | |
| 195 | //-------------------------------------------------
|
| 196 | // device_config_complete - perform any
|
| 197 | // operations now that the configuration is
|
| 198 | // complete
|
| 199 | //-------------------------------------------------
|
| 200 | |
| 201 | void plus4_expansion_slot_device::device_config_complete()
|
| 202 | {
|
| 203 | // inherit a copy of the static data
|
| 204 | const plus4_expansion_slot_interface *intf = reinterpret_cast<const plus4_expansion_slot_interface *>(static_config());
|
| 205 | if (intf != NULL)
|
| 206 | {
|
| 207 | *static_cast<plus4_expansion_slot_interface *>(this) = *intf;
|
| 208 | }
|
| 209 | |
| 210 | // or initialize to defaults if none provided
|
| 211 | else
|
| 212 | {
|
| 213 | memset(&m_in_dma_cd_cb, 0, sizeof(m_in_dma_cd_cb));
|
| 214 | memset(&m_out_dma_cd_cb, 0, sizeof(m_out_dma_cd_cb));
|
| 215 | memset(&m_out_irq_cb, 0, sizeof(m_out_irq_cb));
|
| 216 | memset(&m_out_dma_cb, 0, sizeof(m_out_dma_cb));
|
| 217 | memset(&m_out_reset_cb, 0, sizeof(m_out_reset_cb));
|
| 218 | }
|
| 219 | |
| 220 | // set brief and instance name
|
| 221 | update_names();
|
| 222 | }
|
| 223 | |
| 224 | |
| 225 | //-------------------------------------------------
|
| 226 | // device_start - device-specific startup
|
| 227 | //-------------------------------------------------
|
| 228 | |
| 229 | void plus4_expansion_slot_device::device_start()
|
| 230 | {
|
| 231 | m_cart = dynamic_cast<device_plus4_expansion_card_interface *>(get_card_device());
|
| 232 | |
| 233 | // resolve callbacks
|
| 234 | m_in_dma_cd_func.resolve(m_in_dma_cd_cb, *this);
|
| 235 | m_out_dma_cd_func.resolve(m_out_dma_cd_cb, *this);
|
| 236 | m_out_irq_func.resolve(m_out_irq_cb, *this);
|
| 237 | m_out_dma_func.resolve(m_out_dma_cb, *this);
|
| 238 | m_out_reset_func.resolve(m_out_reset_cb, *this);
|
| 239 | }
|
| 240 | |
| 241 | |
| 242 | //-------------------------------------------------
|
| 243 | // call_load -
|
| 244 | //-------------------------------------------------
|
| 245 | |
| 246 | bool plus4_expansion_slot_device::call_load()
|
| 247 | {
|
| 248 | if (m_cart)
|
| 249 | {
|
| 250 | size_t size = 0;
|
| 251 | |
| 252 | if (software_entry() == NULL)
|
| 253 | {
|
| 254 | // TODO
|
| 255 | }
|
| 256 | else
|
| 257 | {
|
| 258 | size = get_software_region_length("c1l");
|
| 259 | if (size) memcpy(m_cart->plus4_c1l_pointer(machine(), size), get_software_region("c1l"), size);
|
| 260 | |
| 261 | size = get_software_region_length("c1h");
|
| 262 | if (size) memcpy(m_cart->plus4_c1h_pointer(machine(), size), get_software_region("c1h"), size);
|
| 263 | |
| 264 | size = get_software_region_length("c2l");
|
| 265 | if (size) memcpy(m_cart->plus4_c2l_pointer(machine(), size), get_software_region("c2l"), size);
|
| 266 | |
| 267 | size = get_software_region_length("c2h");
|
| 268 | if (size) memcpy(m_cart->plus4_c2h_pointer(machine(), size), get_software_region("c2h"), size);
|
| 269 | |
| 270 | size = get_software_region_length("ram");
|
| 271 | if (size) memset(m_cart->plus4_ram_pointer(machine(), size), 0, size);
|
| 272 | |
| 273 | size = get_software_region_length("nvram");
|
| 274 | if (size) memset(m_cart->plus4_nvram_pointer(machine(), size), 0, size);
|
| 275 | }
|
| 276 | }
|
| 277 | |
| 278 | return IMAGE_INIT_PASS;
|
| 279 | }
|
| 280 | |
| 281 | |
| 282 | //-------------------------------------------------
|
| 283 | // call_softlist_load -
|
| 284 | //-------------------------------------------------
|
| 285 | |
| 286 | bool plus4_expansion_slot_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry)
|
| 287 | {
|
| 288 | load_software_part_region(this, swlist, swname, start_entry);
|
| 289 | |
| 290 | return true;
|
| 291 | }
|
| 292 | |
| 293 | |
| 294 | //-------------------------------------------------
|
| 295 | // get_default_card_software -
|
| 296 | //-------------------------------------------------
|
| 297 | |
| 298 | const char * plus4_expansion_slot_device::get_default_card_software(const machine_config &config, emu_options &options)
|
| 299 | {
|
| 300 | return software_get_default_slot(config, options, this, "standard");
|
| 301 | }
|
| 302 | |
| 303 | |
| 304 | //-------------------------------------------------
|
| 305 | // cd_r - cartridge data read
|
| 306 | //-------------------------------------------------
|
| 307 | |
| 308 | UINT8 plus4_expansion_slot_device::cd_r(address_space &space, offs_t offset, int ba, int cs0, int c1l, int c2l, int cs1, int c1h, int c2h)
|
| 309 | {
|
| 310 | UINT8 data = 0;
|
| 311 | |
| 312 | if (m_cart != NULL)
|
| 313 | {
|
| 314 | data = m_cart->plus4_cd_r(space, offset, ba, cs0, c1l, c1h, cs1, c2l, c2h);
|
| 315 | }
|
| 316 | |
| 317 | return data;
|
| 318 | }
|
| 319 | |
| 320 | |
| 321 | //-------------------------------------------------
|
| 322 | // cd_w - cartridge data write
|
| 323 | //-------------------------------------------------
|
| 324 | |
| 325 | void plus4_expansion_slot_device::cd_w(address_space &space, offs_t offset, UINT8 data, int ba, int cs0, int c1l, int c2l, int cs1, int c1h, int c2h)
|
| 326 | {
|
| 327 | if (m_cart != NULL)
|
| 328 | {
|
| 329 | m_cart->plus4_cd_w(space, offset, data, ba, cs0, c1l, c1h, cs1, c2l, c2h);
|
| 330 | }
|
| 331 | }
|
| 332 | |
| 333 | |
| 334 | //-------------------------------------------------
|
| 335 | // screen_update -
|
| 336 | //-------------------------------------------------
|
| 337 | |
| 338 | UINT32 plus4_expansion_slot_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
|
| 339 | {
|
| 340 | bool value = false;
|
| 341 | |
| 342 | if (m_cart != NULL)
|
| 343 | {
|
| 344 | value = m_cart->plus4_screen_update(screen, bitmap, cliprect);
|
| 345 | }
|
| 346 | |
| 347 | return value;
|
| 348 | }
|
| 349 | |
| 350 | |
| 351 | //-------------------------------------------------
|
| 352 | // dma_cd_r - DMA read
|
| 353 | //-------------------------------------------------
|
| 354 | |
| 355 | UINT8 plus4_expansion_slot_device::dma_cd_r(offs_t offset)
|
| 356 | {
|
| 357 | return m_in_dma_cd_func(offset);
|
| 358 | }
|
| 359 | |
| 360 | |
| 361 | //-------------------------------------------------
|
| 362 | // dma_cd_w - DMA write
|
| 363 | //-------------------------------------------------
|
| 364 | |
| 365 | void plus4_expansion_slot_device::dma_cd_w(offs_t offset, UINT8 data)
|
| 366 | {
|
| 367 | m_out_dma_cd_func(offset, data);
|
| 368 | }
|
| 369 | |
| 370 | |
| 371 | WRITE_LINE_MEMBER( plus4_expansion_slot_device::irq_w ) { m_out_irq_func(state); }
|
| 372 | WRITE_LINE_MEMBER( plus4_expansion_slot_device::dma_w ) { m_out_dma_func(state); }
|
| 373 | WRITE_LINE_MEMBER( plus4_expansion_slot_device::reset_w ) { m_out_reset_func(state); }
|
| 374 | |
| 375 | |
| 376 | //-------------------------------------------------
|
| 377 | // phi2 - system clock frequency
|
| 378 | //-------------------------------------------------
|
| 379 | |
| 380 | int plus4_expansion_slot_device::phi2()
|
| 381 | {
|
| 382 | return clock();
|
| 383 | }
|
src/mess/machine/plus4exp.h
| r0 | r15528 | |
| 1 | /**********************************************************************
|
| 2 | |
| 3 | Commodore Plus/4 Expansion Port emulation
|
| 4 | |
| 5 | Copyright MESS Team.
|
| 6 | Visit http://mamedev.org for licensing and usage restrictions.
|
| 7 | |
| 8 | **********************************************************************
|
| 9 | |
| 10 | GND 1 A GND
|
| 11 | +5V 2 B C1 LOW
|
| 12 | +5V 3 C _BRESET
|
| 13 | _IRQ 4 D _RAS
|
| 14 | R/_W 5 E phi0
|
| 15 | C1 HIGH 6 F A15
|
| 16 | C2 LOW 7 H A14
|
| 17 | C2 HIGH 8 J A13
|
| 18 | _CS1 9 K A12
|
| 19 | _CS0 10 L A11
|
| 20 | _CAS 11 M A10
|
| 21 | MUX 12 N A9
|
| 22 | BA 13 P A8
|
| 23 | D7 14 R A7
|
| 24 | D6 15 S A6
|
| 25 | D5 16 T A5
|
| 26 | D4 17 U A4
|
| 27 | D3 18 V A3
|
| 28 | D2 19 W A2
|
| 29 | D1 20 X A1
|
| 30 | D0 21 Y A0
|
| 31 | AEC 22 Z N.C. (RAMEN)
|
| 32 | EXT AUDIO 23 AA N.C.
|
| 33 | phi2 24 BB N.C.
|
| 34 | GND 25 CC GND
|
| 35 | |
| 36 | **********************************************************************/
|
| 37 | |
| 38 | #pragma once
|
| 39 | |
| 40 | #ifndef __PLUS4_EXPANSION_SLOT__
|
| 41 | #define __PLUS4_EXPANSION_SLOT__
|
| 42 | |
| 43 | #include "emu.h"
|
| 44 | |
| 45 | |
| 46 | |
| 47 | //**************************************************************************
|
| 48 | // CONSTANTS
|
| 49 | //**************************************************************************
|
| 50 | |
| 51 | #define PLUS4_EXPANSION_SLOT_TAG "exp"
|
| 52 | |
| 53 | |
| 54 | |
| 55 | //**************************************************************************
|
| 56 | // INTERFACE CONFIGURATION MACROS
|
| 57 | //**************************************************************************
|
| 58 | |
| 59 | #define PLUS4_EXPANSION_INTERFACE(_name) \
|
| 60 | const plus4_expansion_slot_interface (_name) =
|
| 61 | |
| 62 | |
| 63 | #define MCFG_PLUS4_EXPANSION_SLOT_ADD(_tag, _clock, _config, _slot_intf, _def_slot, _def_inp) \
|
| 64 | MCFG_DEVICE_ADD(_tag, PLUS4_EXPANSION_SLOT, _clock) \
|
| 65 | MCFG_DEVICE_CONFIG(_config) \
|
| 66 | MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, _def_inp, false)
|
| 67 | |
| 68 | |
| 69 | |
| 70 | //**************************************************************************
|
| 71 | // TYPE DEFINITIONS
|
| 72 | //**************************************************************************
|
| 73 | |
| 74 | // ======================> plus4_expansion_slot_interface
|
| 75 | |
| 76 | struct plus4_expansion_slot_interface
|
| 77 | {
|
| 78 | devcb_read8 m_in_dma_cd_cb;
|
| 79 | devcb_write8 m_out_dma_cd_cb;
|
| 80 | devcb_write_line m_out_irq_cb;
|
| 81 | devcb_write_line m_out_dma_cb;
|
| 82 | devcb_write_line m_out_reset_cb;
|
| 83 | };
|
| 84 | |
| 85 | |
| 86 | // ======================> plus4_expansion_slot_device
|
| 87 | |
| 88 | class device_plus4_expansion_card_interface;
|
| 89 | |
| 90 | class plus4_expansion_slot_device : public device_t,
|
| 91 | public plus4_expansion_slot_interface,
|
| 92 | public device_slot_interface,
|
| 93 | public device_image_interface
|
| 94 | {
|
| 95 | public:
|
| 96 | // construction/destruction
|
| 97 | plus4_expansion_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
| 98 | virtual ~plus4_expansion_slot_device();
|
| 99 | |
| 100 | // computer interface
|
| 101 | UINT8 cd_r(address_space &space, offs_t offset, int ba, int cs0, int c1l, int c2l, int cs1, int c1h, int c2h);
|
| 102 | void cd_w(address_space &space, offs_t offset, UINT8 data, int ba, int cs0, int c1l, int c2l, int cs1, int c1h, int c2h);
|
| 103 | UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
|
| 104 | |
| 105 | // cartridge interface
|
| 106 | UINT8 dma_cd_r(offs_t offset);
|
| 107 | void dma_cd_w(offs_t offset, UINT8 data);
|
| 108 | DECLARE_WRITE_LINE_MEMBER( irq_w );
|
| 109 | DECLARE_WRITE_LINE_MEMBER( dma_w );
|
| 110 | DECLARE_WRITE_LINE_MEMBER( reset_w );
|
| 111 | int phi2();
|
| 112 | int dotclock();
|
| 113 | |
| 114 | |
| 115 | protected:
|
| 116 | // device-level overrides
|
| 117 | virtual void device_config_complete();
|
| 118 | virtual void device_start();
|
| 119 | |
| 120 | // image-level overrides
|
| 121 | virtual bool call_load();
|
| 122 | virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry);
|
| 123 | |
| 124 | virtual iodevice_t image_type() const { return IO_CARTSLOT; }
|
| 125 | |
| 126 | virtual bool is_readable() const { return 1; }
|
| 127 | virtual bool is_writeable() const { return 0; }
|
| 128 | virtual bool is_creatable() const { return 0; }
|
| 129 | virtual bool must_be_loaded() const { return 0; }
|
| 130 | virtual bool is_reset_on_load() const { return 1; }
|
| 131 | virtual const char *image_interface() const { return "plus4_cart"; }
|
| 132 | virtual const char *file_extensions() const { return "rom,bin"; }
|
| 133 | virtual const option_guide *create_option_guide() const { return NULL; }
|
| 134 | |
| 135 | // slot interface overrides
|
| 136 | virtual const char * get_default_card_software(const machine_config &config, emu_options &options);
|
| 137 | |
| 138 | devcb_resolved_read8 m_in_dma_cd_func;
|
| 139 | devcb_resolved_write8 m_out_dma_cd_func;
|
| 140 | devcb_resolved_write_line m_out_irq_func;
|
| 141 | devcb_resolved_write_line m_out_dma_func;
|
| 142 | devcb_resolved_write_line m_out_reset_func;
|
| 143 | |
| 144 | device_plus4_expansion_card_interface *m_cart;
|
| 145 | };
|
| 146 | |
| 147 | |
| 148 | // ======================> device_plus4_expansion_card_interface
|
| 149 | |
| 150 | class device_plus4_expansion_card_interface : public device_slot_card_interface
|
| 151 | {
|
| 152 | friend class plus4_expansion_slot_device;
|
| 153 | |
| 154 | public:
|
| 155 | // construction/destruction
|
| 156 | device_plus4_expansion_card_interface(const machine_config &mconfig, device_t &device);
|
| 157 | virtual ~device_plus4_expansion_card_interface();
|
| 158 | |
| 159 | // initialization
|
| 160 | virtual UINT8* plus4_c1l_pointer(running_machine &machine, size_t size);
|
| 161 | virtual UINT8* plus4_c1h_pointer(running_machine &machine, size_t size);
|
| 162 | virtual UINT8* plus4_c2l_pointer(running_machine &machine, size_t size);
|
| 163 | virtual UINT8* plus4_c2h_pointer(running_machine &machine, size_t size);
|
| 164 | virtual UINT8* plus4_ram_pointer(running_machine &machine, size_t size);
|
| 165 | virtual UINT8* plus4_nvram_pointer(running_machine &machine, size_t size);
|
| 166 | |
| 167 | // memory access
|
| 168 | virtual UINT8 plus4_cd_r(address_space &space, offs_t offset, int ba, int cs0, int c1l, int c2l, int cs1, int c1h, int c2h) { return 0; };
|
| 169 | virtual void plus4_cd_w(address_space &space, offs_t offset, UINT8 data, int ba, int cs0, int c1l, int c2l, int cs1, int c1h, int c2h) { };
|
| 170 | virtual void plus4_reset_w() { };
|
| 171 | virtual UINT32 plus4_screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { return 0; }
|
| 172 | |
| 173 | protected:
|
| 174 | plus4_expansion_slot_device *m_slot;
|
| 175 |
|
| 176 | UINT8 *m_c1l;
|
| 177 | UINT8 *m_c1h;
|
| 178 | UINT8 *m_c2l;
|
| 179 | UINT8 *m_c2h;
|
| 180 | UINT8 *m_ram;
|
| 181 | UINT8 *m_nvram;
|
| 182 | |
| 183 | size_t m_nvram_size;
|
| 184 | |
| 185 | size_t m_c1l_mask;
|
| 186 | size_t m_c1h_mask;
|
| 187 | size_t m_c2l_mask;
|
| 188 | size_t m_c2h_mask;
|
| 189 | size_t m_ram_mask;
|
| 190 | size_t m_nvram_mask;
|
| 191 | };
|
| 192 | |
| 193 | |
| 194 | // device type definition
|
| 195 | extern const device_type PLUS4_EXPANSION_SLOT;
|
| 196 | |
| 197 | |
| 198 | |
| 199 | #endif
|
src/mess/machine/plus4user.c
| r0 | r15528 | |
| 1 | /**********************************************************************
|
| 2 | |
| 3 | Commodore Plus/4 User Port emulation
|
| 4 | |
| 5 | Copyright MESS Team.
|
| 6 | Visit http://mamedev.org for licensing and usage restrictions.
|
| 7 | |
| 8 | **********************************************************************/
|
| 9 | |
| 10 | #include "machine/plus4user.h"
|
| 11 | |
| 12 | |
| 13 | |
| 14 | //**************************************************************************
|
| 15 | // GLOBAL VARIABLES
|
| 16 | //**************************************************************************
|
| 17 | |
| 18 | const device_type PLUS4_USER_PORT = &device_creator<plus4_user_port_device>;
|
| 19 | |
| 20 | |
| 21 | |
| 22 | //**************************************************************************
|
| 23 | // CARD INTERFACE
|
| 24 | //**************************************************************************
|
| 25 | |
| 26 | //-------------------------------------------------
|
| 27 | // device_plus4_user_port_interface - constructor
|
| 28 | //-------------------------------------------------
|
| 29 | |
| 30 | device_plus4_user_port_interface::device_plus4_user_port_interface(const machine_config &mconfig, device_t &device)
|
| 31 | : device_slot_card_interface(mconfig,device)
|
| 32 | {
|
| 33 | m_slot = dynamic_cast<plus4_user_port_device *>(device.owner());
|
| 34 | }
|
| 35 | |
| 36 | |
| 37 | //-------------------------------------------------
|
| 38 | // ~device_plus4_user_port_interface - destructor
|
| 39 | //-------------------------------------------------
|
| 40 | |
| 41 | device_plus4_user_port_interface::~device_plus4_user_port_interface()
|
| 42 | {
|
| 43 | }
|
| 44 | |
| 45 | |
| 46 | |
| 47 | //**************************************************************************
|
| 48 | // LIVE DEVICE
|
| 49 | //**************************************************************************
|
| 50 | |
| 51 | //-------------------------------------------------
|
| 52 | // plus4_user_port_device - constructor
|
| 53 | //-------------------------------------------------
|
| 54 | |
| 55 | plus4_user_port_device::plus4_user_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
|
| 56 | device_t(mconfig, PLUS4_USER_PORT, "Plus/4 user port", tag, owner, clock),
|
| 57 | device_slot_interface(mconfig, *this)
|
| 58 | {
|
| 59 | }
|
| 60 | |
| 61 | |
| 62 | //-------------------------------------------------
|
| 63 | // plus4_user_port_device - destructor
|
| 64 | //-------------------------------------------------
|
| 65 | |
| 66 | plus4_user_port_device::~plus4_user_port_device()
|
| 67 | {
|
| 68 | }
|
| 69 | |
| 70 | |
| 71 | //-------------------------------------------------
|
| 72 | // device_config_complete - perform any
|
| 73 | // operations now that the configuration is
|
| 74 | // complete
|
| 75 | //-------------------------------------------------
|
| 76 | |
| 77 | void plus4_user_port_device::device_config_complete()
|
| 78 | {
|
| 79 | // inherit a copy of the static data
|
| 80 | const plus4_user_port_interface *intf = reinterpret_cast<const plus4_user_port_interface *>(static_config());
|
| 81 | if (intf != NULL)
|
| 82 | {
|
| 83 | *static_cast<plus4_user_port_interface *>(this) = *intf;
|
| 84 | }
|
| 85 | |
| 86 | // or initialize to defaults if none provided
|
| 87 | else
|
| 88 | {
|
| 89 | memset(&m_out_reset_cb, 0, sizeof(m_out_reset_cb));
|
| 90 | }
|
| 91 | }
|
| 92 | |
| 93 | |
| 94 | //-------------------------------------------------
|
| 95 | // device_start - device-specific startup
|
| 96 | //-------------------------------------------------
|
| 97 | |
| 98 | void plus4_user_port_device::device_start()
|
| 99 | {
|
| 100 | m_cart = dynamic_cast<device_plus4_user_port_interface *>(get_card_device());
|
| 101 | |
| 102 | // resolve callbacks
|
| 103 | m_out_reset_func.resolve(m_out_reset_cb, *this);
|
| 104 | }
|
| 105 | |
| 106 | |
| 107 | //-------------------------------------------------
|
| 108 | // device_reset - device-specific reset
|
| 109 | //-------------------------------------------------
|
| 110 | |
| 111 | void plus4_user_port_device::device_reset()
|
| 112 | {
|
| 113 | }
|
| 114 | |
| 115 | |
| 116 | READ8_MEMBER( plus4_user_port_device::p_r ) { UINT8 data = 0xff; if (m_cart != NULL) data = m_cart->plus4_p_r(space, offset); return data; }
|
| 117 | WRITE8_MEMBER( plus4_user_port_device::p_w ) { if (m_cart != NULL) m_cart->plus4_p_w(space, offset, data); }
|
| 118 | |
| 119 | READ_LINE_MEMBER( plus4_user_port_device::rxd_r ) { int state = 1; if (m_cart != NULL) state = m_cart->plus4_rxd_r(); return state; }
|
| 120 | READ_LINE_MEMBER( plus4_user_port_device::dcd_r ) { int state = 1; if (m_cart != NULL) state = m_cart->plus4_dcd_r(); return state; }
|
| 121 | READ_LINE_MEMBER( plus4_user_port_device::dsr_r ) { int state = 1; if (m_cart != NULL) state = m_cart->plus4_dsr_r(); return state; }
|
| 122 | |
| 123 | WRITE_LINE_MEMBER( plus4_user_port_device::txd_w ) { if (m_cart != NULL) m_cart->plus4_txd_w(state); }
|
| 124 | WRITE_LINE_MEMBER( plus4_user_port_device::dtr_w ) { if (m_cart != NULL) m_cart->plus4_dtr_w(state); }
|
| 125 | WRITE_LINE_MEMBER( plus4_user_port_device::rts_w ) { if (m_cart != NULL) m_cart->plus4_rts_w(state); }
|
| 126 | WRITE_LINE_MEMBER( plus4_user_port_device::rxc_w ) { if (m_cart != NULL) m_cart->plus4_rxc_w(state); }
|
| 127 | |
| 128 | WRITE_LINE_MEMBER( plus4_user_port_device::reset_w ) { m_out_reset_func(state); }
|
src/mess/machine/plus4user.h
| r0 | r15528 | |
| 1 | /**********************************************************************
|
| 2 | |
| 3 | Commodore Plus/4 User Port emulation
|
| 4 | |
| 5 | Copyright MESS Team.
|
| 6 | Visit http://mamedev.org for licensing and usage restrictions.
|
| 7 | |
| 8 | **********************************************************************
|
| 9 | |
| 10 | GND 1 A GND
|
| 11 | +5V 2 B P0
|
| 12 | _BRESET 3 C RxD
|
| 13 | P2 4 D RTS
|
| 14 | P3 5 E DTR
|
| 15 | P4 6 F P7
|
| 16 | P5 7 H DCD
|
| 17 | P0 8 J P6
|
| 18 | ATN 9 K P1
|
| 19 | +9VAC 10 L DSR
|
| 20 | +9VAC 11 M TxD
|
| 21 | GND 12 N GND
|
| 22 | |
| 23 | **********************************************************************/
|
| 24 | |
| 25 | #pragma once
|
| 26 | |
| 27 | #ifndef __PLUS4_USER_PORT__
|
| 28 | #define __PLUS4_USER_PORT__
|
| 29 | |
| 30 | #include "emu.h"
|
| 31 | |
| 32 | |
| 33 | |
| 34 | //**************************************************************************
|
| 35 | // CONSTANTS
|
| 36 | //**************************************************************************
|
| 37 | |
| 38 | #define PLUS4_USER_PORT_TAG "user"
|
| 39 | |
| 40 | |
| 41 | |
| 42 | //**************************************************************************
|
| 43 | // INTERFACE CONFIGURATION MACROS
|
| 44 | //**************************************************************************
|
| 45 | |
| 46 | #define PLUS4_USER_PORT_INTERFACE(_name) \
|
| 47 | const plus4_user_port_interface (_name) =
|
| 48 | |
| 49 | |
| 50 | #define MCFG_PLUS4_USER_PORT_ADD(_tag, _config, _slot_intf, _def_slot, _def_inp) \
|
| 51 | MCFG_DEVICE_ADD(_tag, PLUS4_USER_PORT, 0) \
|
| 52 | MCFG_DEVICE_CONFIG(_config) \
|
| 53 | MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, _def_inp, false)
|
| 54 | |
| 55 | |
| 56 | |
| 57 | //**************************************************************************
|
| 58 | // TYPE DEFINITIONS
|
| 59 | //**************************************************************************
|
| 60 | |
| 61 | // ======================> plus4_user_port_interface
|
| 62 | |
| 63 | struct plus4_user_port_interface
|
| 64 | {
|
| 65 | devcb_write_line m_out_reset_cb;
|
| 66 | };
|
| 67 | |
| 68 | |
| 69 | // ======================> plus4_user_port_device
|
| 70 | |
| 71 | class device_plus4_user_port_interface;
|
| 72 | |
| 73 | class plus4_user_port_device : public device_t,
|
| 74 | public plus4_user_port_interface,
|
| 75 | public device_slot_interface
|
| 76 | {
|
| 77 | public:
|
| 78 | // construction/destruction
|
| 79 | plus4_user_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
| 80 | virtual ~plus4_user_port_device();
|
| 81 | |
| 82 | // computer interface
|
| 83 | DECLARE_READ8_MEMBER( p_r );
|
| 84 | DECLARE_WRITE8_MEMBER( p_w );
|
| 85 | DECLARE_READ_LINE_MEMBER( rxd_r );
|
| 86 | DECLARE_READ_LINE_MEMBER( dcd_r );
|
| 87 | DECLARE_READ_LINE_MEMBER( dsr_r );
|
| 88 | DECLARE_WRITE_LINE_MEMBER( txd_w );
|
| 89 | DECLARE_WRITE_LINE_MEMBER( dtr_w );
|
| 90 | DECLARE_WRITE_LINE_MEMBER( rts_w );
|
| 91 | DECLARE_WRITE_LINE_MEMBER( rxc_w );
|
| 92 | |
| 93 | // cartridge interface
|
| 94 | DECLARE_WRITE_LINE_MEMBER( reset_w );
|
| 95 | |
| 96 | protected:
|
| 97 | // device-level overrides
|
| 98 | virtual void device_start();
|
| 99 | virtual void device_reset();
|
| 100 | virtual void device_config_complete();
|
| 101 | |
| 102 | devcb_resolved_write_line m_out_reset_func;
|
| 103 | |
| 104 | device_plus4_user_port_interface *m_cart;
|
| 105 | };
|
| 106 | |
| 107 | |
| 108 | // ======================> device_plus4_user_port_interface
|
| 109 | |
| 110 | // class representing interface-specific live plus4_expansion card
|
| 111 | class device_plus4_user_port_interface : public device_slot_card_interface
|
| 112 | {
|
| 113 | public:
|
| 114 | // construction/destruction
|
| 115 | device_plus4_user_port_interface(const machine_config &mconfig, device_t &device);
|
| 116 | virtual ~device_plus4_user_port_interface();
|
| 117 | |
| 118 | virtual UINT8 plus4_p_r(address_space &space, offs_t offset) { return 0xff; };
|
| 119 | virtual void plus4_p_w(address_space &space, offs_t offset, UINT8 data) { };
|
| 120 | |
| 121 | virtual int plus4_rxd_r() { return 1; };
|
| 122 | virtual int plus4_dcd_r() { return 0; };
|
| 123 | virtual int plus4_dsr_r() { return 0; };
|
| 124 | virtual void plus4_txd_w(int level) { };
|
| 125 | virtual void plus4_dtr_w(int level) { };
|
| 126 | virtual void plus4_rts_w(int level) { };
|
| 127 | virtual void plus4_rxc_w(int level) { };
|
| 128 | |
| 129 | // reset
|
| 130 | virtual void plus4_reset_w(int level) { };
|
| 131 | |
| 132 | protected:
|
| 133 | plus4_user_port_device *m_slot;
|
| 134 | };
|
| 135 | |
| 136 | |
| 137 | // device type definition
|
| 138 | extern const device_type PLUS4_USER_PORT;
|
| 139 | |
| 140 | |
| 141 | |
| 142 | #endif
|