trunk/src/mess/machine/adamexp.c
| r0 | r18912 | |
| 1 | /********************************************************************** |
| 2 | |
| 3 | Coleco Adam Expansion Port emulation |
| 4 | |
| 5 | Copyright MESS Team. |
| 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | |
| 8 | **********************************************************************/ |
| 9 | |
| 10 | #include "machine/adamexp.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 ADAM_EXPANSION_SLOT = &device_creator<adam_expansion_slot_device>; |
| 27 | |
| 28 | |
| 29 | |
| 30 | //************************************************************************** |
| 31 | // DEVICE C64_EXPANSION CARD INTERFACE |
| 32 | //************************************************************************** |
| 33 | |
| 34 | //------------------------------------------------- |
| 35 | // device_adam_expansion_slot_card_interface - constructor |
| 36 | //------------------------------------------------- |
| 37 | |
| 38 | device_adam_expansion_slot_card_interface::device_adam_expansion_slot_card_interface(const machine_config &mconfig, device_t &device) |
| 39 | : device_slot_card_interface(mconfig, device), |
| 40 | m_rom(NULL), |
| 41 | m_ram(NULL), |
| 42 | m_rom_mask(0), |
| 43 | m_ram_mask(0) |
| 44 | { |
| 45 | m_slot = dynamic_cast<adam_expansion_slot_device *>(device.owner()); |
| 46 | } |
| 47 | |
| 48 | |
| 49 | //------------------------------------------------- |
| 50 | // ~device_adam_expansion_slot_card_interface - destructor |
| 51 | //------------------------------------------------- |
| 52 | |
| 53 | device_adam_expansion_slot_card_interface::~device_adam_expansion_slot_card_interface() |
| 54 | { |
| 55 | } |
| 56 | |
| 57 | |
| 58 | //------------------------------------------------- |
| 59 | // adam_rom_pointer - get expansion ROM pointer |
| 60 | //------------------------------------------------- |
| 61 | |
| 62 | UINT8* device_adam_expansion_slot_card_interface::adam_rom_pointer(running_machine &machine, size_t size) |
| 63 | { |
| 64 | if (m_rom == NULL) |
| 65 | { |
| 66 | m_rom = auto_alloc_array(machine, UINT8, size); |
| 67 | |
| 68 | m_rom_mask = size - 1; |
| 69 | } |
| 70 | |
| 71 | return m_rom; |
| 72 | } |
| 73 | |
| 74 | |
| 75 | //------------------------------------------------- |
| 76 | // adam_ram_pointer - get expansion ROM pointer |
| 77 | //------------------------------------------------- |
| 78 | |
| 79 | UINT8* device_adam_expansion_slot_card_interface::adam_ram_pointer(running_machine &machine, size_t size) |
| 80 | { |
| 81 | if (m_ram == NULL) |
| 82 | { |
| 83 | m_ram = auto_alloc_array(machine, UINT8, size); |
| 84 | |
| 85 | m_ram_mask = size - 1; |
| 86 | } |
| 87 | |
| 88 | return m_ram; |
| 89 | } |
| 90 | |
| 91 | |
| 92 | |
| 93 | //************************************************************************** |
| 94 | // LIVE DEVICE |
| 95 | //************************************************************************** |
| 96 | |
| 97 | //------------------------------------------------- |
| 98 | // adam_expansion_slot_device - constructor |
| 99 | //------------------------------------------------- |
| 100 | |
| 101 | adam_expansion_slot_device::adam_expansion_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 102 | device_t(mconfig, ADAM_EXPANSION_SLOT, "ADAM expansion slot", tag, owner, clock), |
| 103 | device_slot_interface(mconfig, *this), |
| 104 | device_image_interface(mconfig, *this) |
| 105 | { |
| 106 | } |
| 107 | |
| 108 | |
| 109 | //------------------------------------------------- |
| 110 | // adam_expansion_slot_device - destructor |
| 111 | //------------------------------------------------- |
| 112 | |
| 113 | adam_expansion_slot_device::~adam_expansion_slot_device() |
| 114 | { |
| 115 | } |
| 116 | |
| 117 | |
| 118 | //------------------------------------------------- |
| 119 | // device_config_complete - perform any |
| 120 | // operations now that the configuration is |
| 121 | // complete |
| 122 | //------------------------------------------------- |
| 123 | |
| 124 | void adam_expansion_slot_device::device_config_complete() |
| 125 | { |
| 126 | // inherit a copy of the static data |
| 127 | const adam_expansion_slot_interface *intf = reinterpret_cast<const adam_expansion_slot_interface *>(static_config()); |
| 128 | if (intf != NULL) |
| 129 | { |
| 130 | *static_cast<adam_expansion_slot_interface *>(this) = *intf; |
| 131 | } |
| 132 | |
| 133 | // or initialize to defaults if none provided |
| 134 | else |
| 135 | { |
| 136 | memset(&m_out_int_cb, 0, sizeof(m_out_int_cb)); |
| 137 | } |
| 138 | |
| 139 | // set brief and instance name |
| 140 | update_names(); |
| 141 | } |
| 142 | |
| 143 | |
| 144 | //------------------------------------------------- |
| 145 | // device_start - device-specific startup |
| 146 | //------------------------------------------------- |
| 147 | |
| 148 | void adam_expansion_slot_device::device_start() |
| 149 | { |
| 150 | m_cart = dynamic_cast<device_adam_expansion_slot_card_interface *>(get_card_device()); |
| 151 | |
| 152 | // resolve callbacks |
| 153 | m_out_int_func.resolve(m_out_int_cb, *this); |
| 154 | } |
| 155 | |
| 156 | |
| 157 | //------------------------------------------------- |
| 158 | // device_reset - device-specific reset |
| 159 | //------------------------------------------------- |
| 160 | |
| 161 | void adam_expansion_slot_device::device_reset() |
| 162 | { |
| 163 | } |
| 164 | |
| 165 | |
| 166 | //------------------------------------------------- |
| 167 | // call_load - |
| 168 | //------------------------------------------------- |
| 169 | |
| 170 | bool adam_expansion_slot_device::call_load() |
| 171 | { |
| 172 | if (m_cart) |
| 173 | { |
| 174 | size_t size = 0; |
| 175 | |
| 176 | if (software_entry() == NULL) |
| 177 | { |
| 178 | size = length(); |
| 179 | |
| 180 | fread(m_cart->adam_rom_pointer(machine(), size), size); |
| 181 | } |
| 182 | else |
| 183 | { |
| 184 | size = get_software_region_length("rom"); |
| 185 | if (size) memcpy(m_cart->adam_rom_pointer(machine(), size), get_software_region("rom"), size); |
| 186 | |
| 187 | size = get_software_region_length("ram"); |
| 188 | if (size) memcpy(m_cart->adam_ram_pointer(machine(), size), get_software_region("ram"), size); |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | return IMAGE_INIT_PASS; |
| 193 | } |
| 194 | |
| 195 | |
| 196 | //------------------------------------------------- |
| 197 | // call_softlist_load - |
| 198 | //------------------------------------------------- |
| 199 | |
| 200 | bool adam_expansion_slot_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry) |
| 201 | { |
| 202 | load_software_part_region(this, swlist, swname, start_entry); |
| 203 | |
| 204 | return true; |
| 205 | } |
| 206 | |
| 207 | |
| 208 | //------------------------------------------------- |
| 209 | // get_default_card_software - |
| 210 | //------------------------------------------------- |
| 211 | |
| 212 | const char * adam_expansion_slot_device::get_default_card_software(const machine_config &config, emu_options &options) |
| 213 | { |
| 214 | return software_get_default_slot(config, options, this, "standard"); |
| 215 | } |
| 216 | |
| 217 | |
| 218 | //------------------------------------------------- |
| 219 | // bd_r - buffered data read |
| 220 | //------------------------------------------------- |
| 221 | |
| 222 | UINT8 adam_expansion_slot_device::bd_r(address_space &space, offs_t offset, UINT8 data, int bmreq, int biorq, int aux_rom_cs, int cas1, int cas2) |
| 223 | { |
| 224 | if (m_cart != NULL) |
| 225 | { |
| 226 | data = m_cart->adam_bd_r(space, offset, data, bmreq, biorq, aux_rom_cs, cas1, cas2); |
| 227 | } |
| 228 | |
| 229 | return data; |
| 230 | } |
| 231 | |
| 232 | |
| 233 | //------------------------------------------------- |
| 234 | // cd_w - cartridge data write |
| 235 | //------------------------------------------------- |
| 236 | |
| 237 | void adam_expansion_slot_device::bd_w(address_space &space, offs_t offset, UINT8 data, int bmreq, int biorq, int aux_rom_cs, int cas1, int cas2) |
| 238 | { |
| 239 | if (m_cart != NULL) |
| 240 | { |
| 241 | m_cart->adam_bd_w(space, offset, data, bmreq, biorq, aux_rom_cs, cas1, cas2); |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | WRITE_LINE_MEMBER( adam_expansion_slot_device::int_w ) { m_out_int_func(state); } |
| 246 | |
| 247 | |
| 248 | //------------------------------------------------- |
| 249 | // SLOT_INTERFACE( adam_slot1_devices ) |
| 250 | //------------------------------------------------- |
| 251 | |
| 252 | SLOT_INTERFACE_START( adam_slot1_devices ) |
| 253 | SLOT_INTERFACE("adamlink", ADAMLINK) |
| 254 | SLOT_INTERFACE_END |
| 255 | |
| 256 | |
| 257 | //------------------------------------------------- |
| 258 | // SLOT_INTERFACE( adam_slot2_devices ) |
| 259 | //------------------------------------------------- |
| 260 | |
| 261 | SLOT_INTERFACE_START( adam_slot2_devices ) |
| 262 | SLOT_INTERFACE_END |
| 263 | |
| 264 | |
| 265 | //------------------------------------------------- |
| 266 | // SLOT_INTERFACE( adam_slot3_devices ) |
| 267 | //------------------------------------------------- |
| 268 | |
| 269 | SLOT_INTERFACE_START( adam_slot3_devices ) |
| 270 | SLOT_INTERFACE("ram", ADAM_RAM) |
| 271 | SLOT_INTERFACE_END |
trunk/src/mess/machine/adamexp.h
| r0 | r18912 | |
| 1 | /********************************************************************** |
| 2 | |
| 3 | Coleco Adam Expansion Port emulation |
| 4 | |
| 5 | Copyright MESS Team. |
| 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | |
| 8 | **********************************************************************/ |
| 9 | |
| 10 | #pragma once |
| 11 | |
| 12 | #ifndef __ADAM_EXPANSION_SLOT__ |
| 13 | #define __ADAM_EXPANSION_SLOT__ |
| 14 | |
| 15 | #include "emu.h" |
| 16 | |
| 17 | |
| 18 | |
| 19 | //************************************************************************** |
| 20 | // CONSTANTS |
| 21 | //************************************************************************** |
| 22 | |
| 23 | #define ADAM_LEFT_EXPANSION_SLOT_TAG "slot1" |
| 24 | #define ADAM_CENTER_EXPANSION_SLOT_TAG "slot2" |
| 25 | #define ADAM_RIGHT_EXPANSION_SLOT_TAG "slot3" |
| 26 | |
| 27 | |
| 28 | |
| 29 | //************************************************************************** |
| 30 | // INTERFACE CONFIGURATION MACROS |
| 31 | //************************************************************************** |
| 32 | |
| 33 | #define ADAM_EXPANSION_SLOT_INTERFACE(_name) \ |
| 34 | const adam_expansion_slot_interface (_name) = |
| 35 | |
| 36 | |
| 37 | #define MCFG_ADAM_EXPANSION_SLOT_ADD(_tag, _clock, _config, _slot_intf, _def_slot, _def_inp) \ |
| 38 | MCFG_DEVICE_ADD(_tag, ADAM_EXPANSION_SLOT, _clock) \ |
| 39 | MCFG_DEVICE_CONFIG(_config) \ |
| 40 | MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, _def_inp, false) |
| 41 | |
| 42 | |
| 43 | |
| 44 | //************************************************************************** |
| 45 | // TYPE DEFINITIONS |
| 46 | //************************************************************************** |
| 47 | |
| 48 | // ======================> adam_expansion_slot_interface |
| 49 | |
| 50 | struct adam_expansion_slot_interface |
| 51 | { |
| 52 | devcb_write_line m_out_int_cb; |
| 53 | }; |
| 54 | |
| 55 | |
| 56 | // ======================> adam_expansion_slot_device |
| 57 | |
| 58 | class device_adam_expansion_slot_card_interface; |
| 59 | |
| 60 | class adam_expansion_slot_device : public device_t, |
| 61 | public adam_expansion_slot_interface, |
| 62 | public device_slot_interface, |
| 63 | public device_image_interface |
| 64 | { |
| 65 | public: |
| 66 | // construction/destruction |
| 67 | adam_expansion_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 68 | virtual ~adam_expansion_slot_device(); |
| 69 | |
| 70 | // computer interface |
| 71 | UINT8 bd_r(address_space &space, offs_t offset, UINT8 data, int bmreq, int biorq, int aux_rom_cs, int cas1, int cas2); |
| 72 | void bd_w(address_space &space, offs_t offset, UINT8 data, int bmreq, int biorq, int aux_rom_cs, int cas1, int cas2); |
| 73 | |
| 74 | // cartridge interface |
| 75 | DECLARE_WRITE_LINE_MEMBER( int_w ); |
| 76 | |
| 77 | protected: |
| 78 | // device-level overrides |
| 79 | virtual void device_config_complete(); |
| 80 | virtual void device_start(); |
| 81 | virtual void device_reset(); |
| 82 | |
| 83 | // image-level overrides |
| 84 | virtual bool call_load(); |
| 85 | virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry); |
| 86 | |
| 87 | virtual iodevice_t image_type() const { return IO_CARTSLOT; } |
| 88 | |
| 89 | virtual bool is_readable() const { return 1; } |
| 90 | virtual bool is_writeable() const { return 0; } |
| 91 | virtual bool is_creatable() const { return 0; } |
| 92 | virtual bool must_be_loaded() const { return 0; } |
| 93 | virtual bool is_reset_on_load() const { return 1; } |
| 94 | virtual const char *image_interface() const { return "adam_rom"; } |
| 95 | virtual const char *file_extensions() const { return "bin,rom"; } |
| 96 | virtual const option_guide *create_option_guide() const { return NULL; } |
| 97 | |
| 98 | // slot interface overrides |
| 99 | virtual const char * get_default_card_software(const machine_config &config, emu_options &options); |
| 100 | |
| 101 | devcb_resolved_write_line m_out_int_func; |
| 102 | |
| 103 | device_adam_expansion_slot_card_interface *m_cart; |
| 104 | }; |
| 105 | |
| 106 | |
| 107 | // ======================> device_adam_expansion_slot_card_interface |
| 108 | |
| 109 | class device_adam_expansion_slot_card_interface : public device_slot_card_interface |
| 110 | { |
| 111 | friend class adam_expansion_slot_device; |
| 112 | |
| 113 | public: |
| 114 | // construction/destruction |
| 115 | device_adam_expansion_slot_card_interface(const machine_config &mconfig, device_t &device); |
| 116 | virtual ~device_adam_expansion_slot_card_interface(); |
| 117 | |
| 118 | protected: |
| 119 | // initialization |
| 120 | virtual UINT8* adam_rom_pointer(running_machine &machine, size_t size); |
| 121 | virtual UINT8* adam_ram_pointer(running_machine &machine, size_t size); |
| 122 | |
| 123 | // runtime |
| 124 | virtual UINT8 adam_bd_r(address_space &space, offs_t offset, UINT8 data, int bmreq, int biorq, int aux_rom_cs, int cas1, int cas2) { return data; } |
| 125 | virtual void adam_bd_w(address_space &space, offs_t offset, UINT8 data, int bmreq, int biorq, int aux_rom_cs, int cas1, int cas2) { } |
| 126 | |
| 127 | adam_expansion_slot_device *m_slot; |
| 128 | |
| 129 | UINT8 *m_rom; |
| 130 | UINT8 *m_ram; |
| 131 | |
| 132 | size_t m_rom_mask; |
| 133 | size_t m_ram_mask; |
| 134 | }; |
| 135 | |
| 136 | |
| 137 | // device type definition |
| 138 | extern const device_type ADAM_EXPANSION_SLOT; |
| 139 | |
| 140 | |
| 141 | // slot devices |
| 142 | #include "machine/adamlink.h" |
| 143 | #include "machine/adam_ram.h" |
| 144 | |
| 145 | SLOT_INTERFACE_EXTERN( adam_slot1_devices ); |
| 146 | SLOT_INTERFACE_EXTERN( adam_slot2_devices ); |
| 147 | SLOT_INTERFACE_EXTERN( adam_slot3_devices ); |
| 148 | |
| 149 | |
| 150 | |
| 151 | #endif |
trunk/src/mess/drivers/adam.c
| r18911 | r18912 | |
| 287 | 287 | |
| 288 | 288 | TODO: |
| 289 | 289 | |
| 290 | - fix MC6801 serial I/O |
| 291 | - sort out WP ROM select |
| 290 | 292 | - floppy |
| 291 | | - slot interface |
| 292 | 293 | - printer |
| 293 | 294 | - SPI |
| 294 | 295 | - sound (PSG RDY -> Z80 WAIT) |
| r18911 | r18912 | |
| 341 | 342 | //************************************************************************** |
| 342 | 343 | |
| 343 | 344 | //------------------------------------------------- |
| 344 | | // bankswitch - |
| 345 | // mreq_r - memory request read |
| 345 | 346 | //------------------------------------------------- |
| 346 | 347 | |
| 347 | | void adam_state::bankswitch() |
| 348 | READ8_MEMBER( adam_state::mreq_r ) |
| 348 | 349 | { |
| 349 | | address_space &program = m_maincpu->space(AS_PROGRAM); |
| 350 | | UINT8 *ram = m_ram->pointer(); |
| 350 | int bmreq = 0, biorq = 1, boot_rom_cs = 1, aux_decode_1 = 1, aux_rom_cs = 1, cas1 = 1, cas2 = 1; |
| 351 | 351 | |
| 352 | | switch (m_mioc & 0x03) |
| 352 | UINT8 data = 0; |
| 353 | |
| 354 | if (offset < 0x8000) |
| 353 | 355 | { |
| 354 | | case LO_SMARTWRITER: |
| 355 | | if (BIT(m_an, 1)) |
| 356 | switch (m_mioc & 0x03) |
| 356 | 357 | { |
| 357 | | program.unmap_readwrite(0x0000, 0x5fff); |
| 358 | | program.install_rom(0x6000, 0x7fff, memregion("wp")->base() + 0x8000); |
| 358 | case LO_SMARTWRITER: |
| 359 | boot_rom_cs = 0; |
| 360 | |
| 361 | if (BIT(m_an, 1)) |
| 362 | { |
| 363 | if (offset >= 0x6000) |
| 364 | { |
| 365 | data = m_wp_rom[0x8000 + (offset & 0x1fff)]; |
| 366 | } |
| 367 | } |
| 368 | else |
| 369 | { |
| 370 | data = m_wp_rom[offset]; |
| 371 | } |
| 372 | break; |
| 373 | |
| 374 | case LO_INTERNAL_RAM: |
| 375 | cas1 = 0; |
| 376 | break; |
| 377 | |
| 378 | case LO_RAM_EXPANSION: |
| 379 | cas2 = 0; |
| 380 | break; |
| 381 | |
| 382 | case LO_OS7_ROM_INTERNAL_RAM: |
| 383 | if (offset < 0x2000) |
| 384 | { |
| 385 | aux_decode_1 = 0; |
| 386 | } |
| 387 | else |
| 388 | { |
| 389 | cas1 = 0; |
| 390 | } |
| 391 | break; |
| 359 | 392 | } |
| 360 | | else |
| 393 | } |
| 394 | else |
| 395 | { |
| 396 | switch ((m_mioc >> 2) & 0x03) |
| 361 | 397 | { |
| 362 | | program.install_rom(0x0000, 0x7fff, memregion("wp")->base()); |
| 398 | case HI_INTERNAL_RAM: |
| 399 | cas1 = 0; |
| 400 | break; |
| 401 | |
| 402 | case HI_ROM_EXPANSION: |
| 403 | aux_rom_cs = 0; |
| 404 | break; |
| 405 | |
| 406 | case HI_RAM_EXPANSION: |
| 407 | if (m_game) |
| 408 | { |
| 409 | aux_decode_1 = 0; |
| 410 | } |
| 411 | else |
| 412 | { |
| 413 | cas2 = 0; |
| 414 | } |
| 415 | break; |
| 416 | |
| 417 | case HI_CARTRIDGE_ROM: |
| 418 | aux_decode_1 = 0; |
| 419 | break; |
| 363 | 420 | } |
| 421 | } |
| 422 | |
| 423 | if (!cas1) |
| 424 | { |
| 425 | data = m_ram->pointer()[offset]; |
| 426 | } |
| 427 | |
| 428 | if (!boot_rom_cs) |
| 429 | { |
| 430 | // TODO |
| 431 | } |
| 432 | |
| 433 | if (!aux_decode_1) |
| 434 | { |
| 435 | switch (offset >> 13) |
| 436 | { |
| 437 | case 0: // U2 |
| 438 | data = m_os7_rom[offset]; |
| 439 | break; |
| 440 | |
| 441 | case 1: break; |
| 442 | case 2: break; |
| 443 | |
| 444 | case 4: // CS1 |
| 445 | case 5: // CS2 |
| 446 | case 6: // CS3 |
| 447 | case 7: // CS4 |
| 448 | data = m_cart_rom[offset & 0x7fff]; |
| 449 | break; |
| 450 | } |
| 451 | } |
| 452 | |
| 453 | data = m_slot1->bd_r(space, offset & 0xff, data, 1, biorq, 1, 1, 1); |
| 454 | data = m_slot2->bd_r(space, offset, data, bmreq, biorq, aux_rom_cs, 1, cas2); |
| 455 | data = m_slot3->bd_r(space, offset, data, 1, 1, 1, cas1, cas2); |
| 456 | |
| 457 | return data; |
| 458 | } |
| 459 | |
| 460 | |
| 461 | //------------------------------------------------- |
| 462 | // mreq_w - memory request write |
| 463 | //------------------------------------------------- |
| 464 | |
| 465 | WRITE8_MEMBER( adam_state::mreq_w ) |
| 466 | { |
| 467 | int bmreq = 0, biorq = 1, aux_rom_cs = 1, cas1 = 1, cas2 = 1; |
| 468 | |
| 469 | if (offset < 0x8000) |
| 470 | { |
| 471 | switch (m_mioc & 0x03) |
| 472 | { |
| 473 | case LO_INTERNAL_RAM: |
| 474 | cas1 = 0; |
| 475 | break; |
| 476 | |
| 477 | case LO_RAM_EXPANSION: |
| 478 | cas2 = 0; |
| 479 | break; |
| 480 | |
| 481 | case LO_OS7_ROM_INTERNAL_RAM: |
| 482 | if (offset >= 0x2000) |
| 483 | { |
| 484 | cas1 = 0; |
| 485 | } |
| 486 | break; |
| 487 | } |
| 488 | } |
| 489 | else |
| 490 | { |
| 491 | switch ((m_mioc >> 2) & 0x03) |
| 492 | { |
| 493 | case HI_INTERNAL_RAM: |
| 494 | cas1 = 0; |
| 495 | break; |
| 496 | |
| 497 | case HI_RAM_EXPANSION: |
| 498 | if (!m_game) |
| 499 | { |
| 500 | cas2 = 0; |
| 501 | } |
| 502 | break; |
| 503 | } |
| 504 | } |
| 505 | |
| 506 | if (!cas1) |
| 507 | { |
| 508 | m_ram->pointer()[offset] = data; |
| 509 | } |
| 510 | |
| 511 | m_slot1->bd_w(space, offset & 0xff, data, 1, biorq, 1, 1, 1); |
| 512 | m_slot2->bd_w(space, offset, data, bmreq, biorq, aux_rom_cs, 1, cas2); |
| 513 | m_slot3->bd_w(space, offset, data, 1, 1, 1, cas1, cas2); |
| 514 | } |
| 515 | |
| 516 | |
| 517 | //------------------------------------------------- |
| 518 | // iorq_r - I/O request read |
| 519 | //------------------------------------------------- |
| 520 | |
| 521 | READ8_MEMBER( adam_state::iorq_r ) |
| 522 | { |
| 523 | int bmreq = 1, biorq = 0, aux_rom_cs = 1, cas1 = 1, cas2 = 1; |
| 524 | |
| 525 | UINT8 data = 0; |
| 526 | |
| 527 | switch ((offset >> 5) & 0x07) |
| 528 | { |
| 529 | case 1: |
| 530 | data = adamnet_r(space, 0); |
| 364 | 531 | break; |
| 365 | 532 | |
| 366 | | case LO_INTERNAL_RAM: |
| 367 | | program.install_ram(0x0000, 0x7fff, ram); |
| 533 | case 3: |
| 534 | data = mioc_r(space, 0); |
| 368 | 535 | break; |
| 369 | 536 | |
| 370 | | case LO_RAM_EXPANSION: |
| 371 | | if (m_ram->size() > 64 * 1024) |
| 372 | | program.install_ram(0x0000, 0x7fff, ram + 0x10000); |
| 537 | case 5: |
| 538 | if (BIT(offset, 0)) |
| 539 | { |
| 540 | data = m_vdc->register_read(space, 0); |
| 541 | } |
| 373 | 542 | else |
| 374 | | program.unmap_readwrite(0x0000, 0x7fff); |
| 543 | { |
| 544 | data = m_vdc->vram_read(space, 0); |
| 545 | } |
| 375 | 546 | break; |
| 376 | 547 | |
| 377 | | case LO_OS7_ROM_INTERNAL_RAM: |
| 378 | | program.install_rom(0x0000, 0x1fff, memregion("os7")->base()); |
| 379 | | program.install_ram(0x2000, 0x7fff, ram + 0x2000); |
| 548 | case 7: |
| 549 | if (BIT(offset, 1)) |
| 550 | { |
| 551 | data = input2_r(space, 0); |
| 552 | } |
| 553 | else |
| 554 | { |
| 555 | data = input1_r(space, 0); |
| 556 | } |
| 380 | 557 | break; |
| 381 | 558 | } |
| 382 | 559 | |
| 383 | | switch ((m_mioc >> 2) & 0x03) |
| 560 | data = m_slot1->bd_r(space, offset & 0xff, data, 1, biorq, 1, 1, 1); |
| 561 | data = m_slot2->bd_r(space, offset, data, bmreq, biorq, aux_rom_cs, 1, cas2); |
| 562 | data = m_slot3->bd_r(space, offset, data, 1, 1, 1, cas1, cas2); |
| 563 | |
| 564 | return data; |
| 565 | } |
| 566 | |
| 567 | |
| 568 | //------------------------------------------------- |
| 569 | // iorq_w - I/O request write |
| 570 | //------------------------------------------------- |
| 571 | |
| 572 | WRITE8_MEMBER( adam_state::iorq_w ) |
| 573 | { |
| 574 | int bmreq = 1, biorq = 0, aux_rom_cs = 1, cas1 = 1, cas2 = 1; |
| 575 | |
| 576 | switch ((offset >> 5) & 0x07) |
| 384 | 577 | { |
| 385 | | case HI_INTERNAL_RAM: |
| 386 | | program.install_ram(0x8000, 0xffff, ram + 0x8000); |
| 578 | case 1: |
| 579 | adamnet_w(space, 0, data); |
| 387 | 580 | break; |
| 388 | 581 | |
| 389 | | case HI_ROM_EXPANSION: |
| 390 | | program.install_rom(0x8000, 0xffff, memregion("xrom")->base()); |
| 582 | case 3: |
| 583 | mioc_w(space, 0, data); |
| 391 | 584 | break; |
| 392 | 585 | |
| 393 | | case HI_RAM_EXPANSION: |
| 394 | | if (m_game) |
| 586 | case 4: |
| 587 | paddle_w(space, 0, data); |
| 588 | break; |
| 589 | |
| 590 | case 5: |
| 591 | if (BIT(offset, 0)) |
| 395 | 592 | { |
| 396 | | program.install_rom(0x8000, 0xffff, memregion("cart")->base()); |
| 593 | m_vdc->register_write(space, 0, data); |
| 397 | 594 | } |
| 398 | 595 | else |
| 399 | 596 | { |
| 400 | | if (m_ram->size() > 64 * 1024) |
| 401 | | program.install_ram(0x8000, 0xffff, ram + 0x18000); |
| 402 | | else |
| 403 | | program.unmap_readwrite(0x8000, 0xffff); |
| 597 | m_vdc->vram_write(space, 0, data); |
| 404 | 598 | } |
| 405 | 599 | break; |
| 406 | 600 | |
| 407 | | case HI_CARTRIDGE_ROM: |
| 408 | | program.install_rom(0x8000, 0xffff, memregion("cart")->base()); |
| 601 | case 6: |
| 602 | joystick_w(space, 0, data); |
| 409 | 603 | break; |
| 604 | |
| 605 | case 7: |
| 606 | m_psg->write(space, 0, data); |
| 607 | break; |
| 410 | 608 | } |
| 609 | |
| 610 | m_slot1->bd_w(space, offset & 0xff, data, 1, biorq, 1, 1, 1); |
| 611 | m_slot2->bd_w(space, offset, data, bmreq, biorq, aux_rom_cs, 1, cas2); |
| 612 | m_slot3->bd_w(space, offset, data, 1, 1, 1, cas1, cas2); |
| 411 | 613 | } |
| 412 | 614 | |
| 413 | 615 | |
| r18911 | r18912 | |
| 443 | 645 | */ |
| 444 | 646 | |
| 445 | 647 | m_mioc = data; |
| 446 | | |
| 447 | | bankswitch(); |
| 448 | 648 | } |
| 449 | 649 | |
| 450 | 650 | |
| r18911 | r18912 | |
| 492 | 692 | } |
| 493 | 693 | |
| 494 | 694 | m_an = data; |
| 495 | | |
| 496 | | bankswitch(); |
| 497 | 695 | } |
| 498 | 696 | |
| 499 | 697 | |
| r18911 | r18912 | |
| 720 | 918 | //------------------------------------------------- |
| 721 | 919 | |
| 722 | 920 | static ADDRESS_MAP_START( adam_mem, AS_PROGRAM, 8, adam_state ) |
| 921 | AM_RANGE(0x0000, 0xffff) AM_READWRITE(mreq_r, mreq_w) |
| 723 | 922 | ADDRESS_MAP_END |
| 724 | 923 | |
| 725 | 924 | |
| r18911 | r18912 | |
| 728 | 927 | //------------------------------------------------- |
| 729 | 928 | |
| 730 | 929 | static ADDRESS_MAP_START( adam_io, AS_IO, 8, adam_state ) |
| 731 | | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 732 | | AM_RANGE(0x20, 0x20) AM_MIRROR(0x1f) AM_READWRITE(adamnet_r, adamnet_w) |
| 733 | | AM_RANGE(0x60, 0x60) AM_MIRROR(0x1f) AM_READWRITE(mioc_r, mioc_w) |
| 734 | | AM_RANGE(0x80, 0x80) AM_MIRROR(0x1f) AM_WRITE(paddle_w) |
| 735 | | AM_RANGE(0xa0, 0xa0) AM_MIRROR(0x1e) AM_DEVREADWRITE(TMS9928A_TAG, tms9928a_device, vram_read, vram_write) |
| 736 | | AM_RANGE(0xa1, 0xa1) AM_MIRROR(0x1e) AM_DEVREADWRITE(TMS9928A_TAG, tms9928a_device, register_read, register_write) |
| 737 | | AM_RANGE(0xc0, 0xc0) AM_MIRROR(0x1f) AM_WRITE(joystick_w) |
| 738 | | AM_RANGE(0xe0, 0xe0) AM_MIRROR(0x1f) AM_DEVWRITE(SN76489A_TAG, sn76489a_device, write) |
| 739 | | AM_RANGE(0xe0, 0xe0) AM_MIRROR(0x1d) AM_READ(input1_r) |
| 740 | | AM_RANGE(0xe2, 0xe2) AM_MIRROR(0x1d) AM_READ(input2_r) |
| 930 | AM_RANGE(0x0000, 0xffff) AM_READWRITE(iorq_r, iorq_w) |
| 741 | 931 | ADDRESS_MAP_END |
| 742 | 932 | |
| 743 | 933 | |
| r18911 | r18912 | |
| 833 | 1023 | }; |
| 834 | 1024 | |
| 835 | 1025 | |
| 1026 | //------------------------------------------------- |
| 1027 | // ADAM_EXPANSION_SLOT_INTERFACE( slot1_intf ) |
| 1028 | //------------------------------------------------- |
| 836 | 1029 | |
| 1030 | static ADAM_EXPANSION_SLOT_INTERFACE( slot1_intf ) |
| 1031 | { |
| 1032 | DEVCB_CPU_INPUT_LINE(Z80_TAG, INPUT_LINE_IRQ0) |
| 1033 | }; |
| 1034 | |
| 1035 | |
| 1036 | //------------------------------------------------- |
| 1037 | // ADAM_EXPANSION_SLOT_INTERFACE( slot2_intf ) |
| 1038 | //------------------------------------------------- |
| 1039 | |
| 1040 | static ADAM_EXPANSION_SLOT_INTERFACE( slot2_intf ) |
| 1041 | { |
| 1042 | DEVCB_CPU_INPUT_LINE(Z80_TAG, INPUT_LINE_IRQ0) |
| 1043 | }; |
| 1044 | |
| 1045 | |
| 1046 | //------------------------------------------------- |
| 1047 | // ADAM_EXPANSION_SLOT_INTERFACE( slot3_intf ) |
| 1048 | //------------------------------------------------- |
| 1049 | |
| 1050 | static ADAM_EXPANSION_SLOT_INTERFACE( slot3_intf ) |
| 1051 | { |
| 1052 | DEVCB_NULL // slot 3 has no INT line |
| 1053 | }; |
| 1054 | |
| 1055 | |
| 1056 | |
| 837 | 1057 | //************************************************************************** |
| 838 | 1058 | // MACHINE INITIALIZATION |
| 839 | 1059 | //************************************************************************** |
| r18911 | r18912 | |
| 844 | 1064 | |
| 845 | 1065 | void adam_state::machine_start() |
| 846 | 1066 | { |
| 1067 | // find memory regions |
| 1068 | m_wp_rom = memregion("wp")->base(); |
| 1069 | m_os7_rom = memregion("os7")->base(); |
| 1070 | m_cart_rom = memregion("cart")->base(); |
| 1071 | |
| 847 | 1072 | // state saving |
| 848 | 1073 | save_item(NAME(m_mioc)); |
| 849 | 1074 | save_item(NAME(m_game)); |
| r18911 | r18912 | |
| 883 | 1108 | |
| 884 | 1109 | m_an = 0; |
| 885 | 1110 | |
| 886 | | bankswitch(); |
| 887 | | |
| 888 | 1111 | m_maincpu->reset(); |
| 889 | 1112 | m_netcpu->reset(); |
| 890 | 1113 | } |
| r18911 | r18912 | |
| 923 | 1146 | MCFG_SOUND_CONFIG(psg_intf) |
| 924 | 1147 | |
| 925 | 1148 | // devices |
| 926 | | MCFG_ADAMNET_BUS_ADD() |
| 927 | | MCFG_ADAMNET_SLOT_ADD("an1", adamnet_devices, "kb", NULL) |
| 928 | | MCFG_ADAMNET_SLOT_ADD("an2", adamnet_devices, "prn", NULL) |
| 929 | | MCFG_ADAMNET_SLOT_ADD("an3", adamnet_devices, "ddp", NULL) |
| 930 | | MCFG_ADAMNET_SLOT_ADD("an4", adamnet_devices, "fdc", NULL) |
| 931 | | MCFG_ADAMNET_SLOT_ADD("an5", adamnet_devices, NULL, NULL) |
| 932 | | MCFG_ADAMNET_SLOT_ADD("an6", adamnet_devices, NULL, NULL) |
| 933 | | MCFG_ADAMNET_SLOT_ADD("an7", adamnet_devices, NULL, NULL) |
| 934 | | MCFG_ADAMNET_SLOT_ADD("an8", adamnet_devices, NULL, NULL) |
| 935 | | MCFG_ADAMNET_SLOT_ADD("an9", adamnet_devices, NULL, NULL) |
| 936 | | MCFG_ADAMNET_SLOT_ADD("an10", adamnet_devices, NULL, NULL) |
| 937 | | MCFG_ADAMNET_SLOT_ADD("an11", adamnet_devices, NULL, NULL) |
| 938 | | MCFG_ADAMNET_SLOT_ADD("an12", adamnet_devices, NULL, NULL) |
| 939 | | MCFG_ADAMNET_SLOT_ADD("an13", adamnet_devices, NULL, NULL) |
| 940 | | MCFG_ADAMNET_SLOT_ADD("an14", adamnet_devices, NULL, NULL) |
| 941 | | MCFG_ADAMNET_SLOT_ADD("an15", adamnet_devices, NULL, NULL) |
| 942 | | |
| 943 | 1149 | MCFG_TIMER_DRIVER_ADD_PERIODIC("paddles", adam_state, paddle_tick, attotime::from_msec(20)) |
| 944 | 1150 | |
| 945 | | // cartridge |
| 1151 | MCFG_ADAMNET_BUS_ADD() |
| 1152 | MCFG_ADAMNET_SLOT_ADD("net1", adamnet_devices, "kb", NULL) |
| 1153 | MCFG_ADAMNET_SLOT_ADD("net2", adamnet_devices, "prn", NULL) |
| 1154 | MCFG_ADAMNET_SLOT_ADD("net3", adamnet_devices, "ddp", NULL) |
| 1155 | MCFG_ADAMNET_SLOT_ADD("net4", adamnet_devices, "fdc", NULL) |
| 1156 | MCFG_ADAMNET_SLOT_ADD("net5", adamnet_devices, NULL, NULL) |
| 1157 | MCFG_ADAMNET_SLOT_ADD("net6", adamnet_devices, NULL, NULL) |
| 1158 | MCFG_ADAMNET_SLOT_ADD("net7", adamnet_devices, NULL, NULL) |
| 1159 | MCFG_ADAMNET_SLOT_ADD("net8", adamnet_devices, NULL, NULL) |
| 1160 | MCFG_ADAMNET_SLOT_ADD("net9", adamnet_devices, NULL, NULL) |
| 1161 | MCFG_ADAMNET_SLOT_ADD("net10", adamnet_devices, NULL, NULL) |
| 1162 | MCFG_ADAMNET_SLOT_ADD("net11", adamnet_devices, NULL, NULL) |
| 1163 | MCFG_ADAMNET_SLOT_ADD("net12", adamnet_devices, NULL, NULL) |
| 1164 | MCFG_ADAMNET_SLOT_ADD("net13", adamnet_devices, NULL, NULL) |
| 1165 | MCFG_ADAMNET_SLOT_ADD("net14", adamnet_devices, NULL, NULL) |
| 1166 | MCFG_ADAMNET_SLOT_ADD("net15", adamnet_devices, NULL, NULL) |
| 1167 | |
| 946 | 1168 | MCFG_CARTSLOT_ADD("cart") |
| 947 | 1169 | MCFG_CARTSLOT_EXTENSION_LIST("rom,col,bin") |
| 948 | 1170 | MCFG_CARTSLOT_NOT_MANDATORY |
| 949 | 1171 | MCFG_CARTSLOT_INTERFACE("coleco_cart") |
| 950 | 1172 | |
| 951 | | // ROM expansion |
| 952 | | MCFG_CARTSLOT_ADD("xrom") |
| 953 | | MCFG_CARTSLOT_EXTENSION_LIST("rom,bin") |
| 954 | | MCFG_CARTSLOT_NOT_MANDATORY |
| 955 | | MCFG_CARTSLOT_INTERFACE("adam_xrom") |
| 956 | | |
| 1173 | MCFG_ADAM_EXPANSION_SLOT_ADD(ADAM_LEFT_EXPANSION_SLOT_TAG, XTAL_7_15909MHz/2, slot1_intf, adam_slot1_devices, "adamlink", NULL) |
| 1174 | MCFG_ADAM_EXPANSION_SLOT_ADD(ADAM_CENTER_EXPANSION_SLOT_TAG, XTAL_7_15909MHz/2, slot2_intf, adam_slot2_devices, NULL, NULL) |
| 1175 | MCFG_ADAM_EXPANSION_SLOT_ADD(ADAM_RIGHT_EXPANSION_SLOT_TAG, XTAL_7_15909MHz/2, slot3_intf, adam_slot3_devices, "ram", NULL) |
| 1176 | |
| 957 | 1177 | // internal ram |
| 958 | 1178 | MCFG_RAM_ADD(RAM_TAG) |
| 959 | 1179 | MCFG_RAM_DEFAULT_SIZE("64K") |
| 960 | | MCFG_RAM_EXTRA_OPTIONS("128K") |
| 961 | 1180 | |
| 962 | 1181 | // software lists |
| 963 | 1182 | MCFG_SOFTWARE_LIST_ADD("colec_cart_list", "coleco") |
| r18911 | r18912 | |
| 992 | 1211 | ROM_REGION( 0x800, M6801_TAG, 0 ) |
| 993 | 1212 | ROM_LOAD( "master rev a 174b.u6", 0x000, 0x800, CRC(035a7a3d) SHA1(0426e6eaf18c2be9fe08066570c214ab5951ee14) ) |
| 994 | 1213 | |
| 995 | | ROM_REGION( 0x8000, "xrom", ROMREGION_ERASE00 ) |
| 996 | | ROM_CART_LOAD( "xrom", 0x0000, 0x8000, ROM_NOMIRROR | ROM_OPTIONAL ) |
| 997 | | |
| 998 | 1214 | ROM_REGION( 0x8000, "cart", 0 ) |
| 999 | 1215 | ROM_CART_LOAD( "cart", 0x0000, 0x8000, ROM_NOMIRROR | ROM_OPTIONAL ) |
| 1000 | 1216 | ROM_END |