src/mess/machine/ap2_slot.c
| r7840 | r7841 | |
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | /*------------------------------------------------- |
| 135 | apple2_c800_slot_r - slot read function |
| 136 | -------------------------------------------------*/ |
| 134 | 137 | |
| 138 | READ8_DEVICE_HANDLER(apple2_c800_slot_r) |
| 139 | { |
| 140 | UINT8 result = 0x00; |
| 141 | const apple2_slot_config *config = get_config(device); |
| 142 | apple2_slot_token *token = get_token(device); |
| 135 | 143 | |
| 144 | /* do we actually have a device, and can we read? */ |
| 145 | if ((token->slot_device != NULL) && (config->rhc800 != NULL)) |
| 146 | { |
| 147 | result = (*config->rhc800)(token->slot_device, offset); |
| 148 | } |
| 149 | |
| 150 | return result; |
| 151 | } |
| 152 | |
| 136 | 153 | /*------------------------------------------------- |
| 154 | apple2_c800_slot_w - slot write function |
| 155 | -------------------------------------------------*/ |
| 156 | |
| 157 | WRITE8_DEVICE_HANDLER(apple2_c800_slot_w) |
| 158 | { |
| 159 | const apple2_slot_config *config = get_config(device); |
| 160 | apple2_slot_token *token = get_token(device); |
| 161 | |
| 162 | /* do we actually have a device, and can we read? */ |
| 163 | if ((token->slot_device != NULL) && (config->whc800 != NULL)) |
| 164 | { |
| 165 | (*config->whc800)(token->slot_device, offset, data); |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | /*------------------------------------------------- |
| 170 | apple2_slot_ROM_w - slot write function |
| 171 | -------------------------------------------------*/ |
| 172 | |
| 173 | WRITE8_DEVICE_HANDLER(apple2_slot_ROM_w) |
| 174 | { |
| 175 | const apple2_slot_config *config = get_config(device); |
| 176 | apple2_slot_token *token = get_token(device); |
| 177 | |
| 178 | /* do we actually have a device, and can we read? */ |
| 179 | if ((token->slot_device != NULL) && (config->whcnxx != NULL)) |
| 180 | { |
| 181 | (*config->whcnxx)(token->slot_device, offset, data); |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | /*------------------------------------------------- |
| 137 | 186 | DEVICE_GET_INFO(apple2_slot) - device get info |
| 138 | 187 | function |
| 139 | 188 | -------------------------------------------------*/ |
src/mess/machine/ap2_slot.h
| r7840 | r7841 | |
| 30 | 30 | const char *tag; |
| 31 | 31 | read8_device_func rh; |
| 32 | 32 | write8_device_func wh; |
| 33 | read8_device_func rhc800; |
| 34 | write8_device_func whc800; |
| 35 | write8_device_func whcnxx; |
| 33 | 36 | }; |
| 34 | 37 | |
| 35 | 38 | |
| r7840 | r7841 | |
| 38 | 41 | DEVICE CONFIGURATION MACROS |
| 39 | 42 | ***************************************************************************/ |
| 40 | 43 | |
| 41 | | #define MDRV_APPLE2_SLOT_ADD(_slot_number, _slot_device_tag, _rh, _wh) \ |
| 44 | #define MDRV_APPLE2_SLOT_ADD(_slot_number, _slot_device_tag, _rh, _wh, _rhc800, _whc800, _whcnxx) \ |
| 42 | 45 | MDRV_DEVICE_ADD("slot_" #_slot_number, APPLE2_SLOT, 0) \ |
| 43 | 46 | MDRV_DEVICE_CONFIG_DATAPTR(apple2_slot_config, tag, _slot_device_tag) \ |
| 44 | 47 | MDRV_DEVICE_CONFIG_DATAPTR(apple2_slot_config, rh, _rh) \ |
| 45 | 48 | MDRV_DEVICE_CONFIG_DATAPTR(apple2_slot_config, wh, _wh) \ |
| 49 | MDRV_DEVICE_CONFIG_DATAPTR(apple2_slot_config, rhc800, _rhc800) \ |
| 50 | MDRV_DEVICE_CONFIG_DATAPTR(apple2_slot_config, whc800, _whc800) \ |
| 51 | MDRV_DEVICE_CONFIG_DATAPTR(apple2_slot_config, whcnxx, _whcnxx) \ |
| 46 | 52 | |
| 47 | 53 | |
| 48 | 54 | |
| r7840 | r7841 | |
| 59 | 65 | /* slot write function */ |
| 60 | 66 | WRITE8_DEVICE_HANDLER(apple2_slot_w); |
| 61 | 67 | |
| 68 | /* slot ROM write function */ |
| 69 | WRITE8_DEVICE_HANDLER(apple2_slot_ROM_w); |
| 70 | |
| 71 | /* slot extended ROM read function */ |
| 72 | READ8_DEVICE_HANDLER(apple2_c800_slot_r); |
| 73 | |
| 74 | /* slot extended ROM write function */ |
| 75 | WRITE8_DEVICE_HANDLER(apple2_c800_slot_w); |
| 76 | |
| 62 | 77 | /* slot device lookup */ |
| 63 | 78 | running_device *apple2_slot(running_machine *machine, int slotnum); |
| 64 | 79 | |
src/mess/machine/apple2.c
| r7840 | r7841 | |
| 44 | 44 | static UINT32 a2_mask; |
| 45 | 45 | static UINT32 a2_set; |
| 46 | 46 | |
| 47 | static INT32 a2_cnxx_slot; |
| 47 | 48 | |
| 48 | 49 | /* local */ |
| 49 | 50 | static int a2_speaker_state; |
| r7840 | r7841 | |
| 73 | 74 | static WRITE8_HANDLER ( apple2_c05x_w ); |
| 74 | 75 | static WRITE8_HANDLER ( apple2_c07x_w ); |
| 75 | 76 | |
| 77 | static READ8_HANDLER ( apple2_c1xx_r ); |
| 78 | static WRITE8_HANDLER ( apple2_c1xx_w ); |
| 79 | static READ8_HANDLER ( apple2_c4xx_r ); |
| 80 | static WRITE8_HANDLER ( apple2_c4xx_w ); |
| 76 | 81 | |
| 82 | static READ8_HANDLER ( apple2_c800_r ); |
| 83 | static WRITE8_HANDLER ( apple2_c800_w ); |
| 84 | static READ8_HANDLER ( apple2_ce00_r ); |
| 85 | static WRITE8_HANDLER ( apple2_ce00_w ); |
| 77 | 86 | |
| 78 | 87 | /* ----------------------------------------------------------------------- |
| 79 | 88 | * New Apple II memory manager |
| r7840 | r7841 | |
| 173 | 182 | } |
| 174 | 183 | else if ((meminfo.read_mem & 0xC0000000) == APPLE2_MEM_SLOT) |
| 175 | 184 | { |
| 176 | | /* slot RAM */ |
| 177 | | if (slot_ram) |
| 178 | | rbase = &slot_ram[meminfo.read_mem & APPLE2_MEM_MASK]; |
| 179 | | else |
| 180 | | rh = read_floatingbus; |
| 185 | // slots 1-2 |
| 186 | if ((meminfo.write_mem & APPLE2_MEM_MASK) == 0) |
| 187 | { |
| 188 | rh = apple2_c1xx_r; |
| 189 | } |
| 190 | else if ((meminfo.write_mem & APPLE2_MEM_MASK) == 0x300) |
| 191 | { // slots 4-7 |
| 192 | rh = apple2_c4xx_r; |
| 193 | } |
| 181 | 194 | } |
| 182 | 195 | else if ((meminfo.read_mem & 0xC0000000) == APPLE2_MEM_ROM) |
| 183 | 196 | { |
| r7840 | r7841 | |
| 251 | 264 | } |
| 252 | 265 | else if ((meminfo.write_mem & 0xC0000000) == APPLE2_MEM_SLOT) |
| 253 | 266 | { |
| 254 | | /* slot RAM */ |
| 255 | | if (slot_ram) |
| 256 | | wbase = &slot_ram[meminfo.write_mem & APPLE2_MEM_MASK]; |
| 257 | | else |
| 258 | | wh_nop = 1; |
| 267 | /* slot RAM/ROM */ |
| 268 | |
| 269 | // slots 1-2 |
| 270 | if ((meminfo.write_mem & APPLE2_MEM_MASK) == 0) |
| 271 | { |
| 272 | wh = apple2_c1xx_w; |
| 273 | } |
| 274 | else if ((meminfo.write_mem & APPLE2_MEM_MASK) == 0x300) |
| 275 | { // slots 4-7 |
| 276 | wh = apple2_c4xx_w; |
| 277 | } |
| 259 | 278 | } |
| 260 | 279 | else if ((meminfo.write_mem & 0xC0000000) == APPLE2_MEM_ROM) |
| 261 | 280 | { |
| r7840 | r7841 | |
| 340 | 359 | |
| 341 | 360 | if (offset < 0x80) |
| 342 | 361 | { |
| 362 | if (a2_cnxx_slot != -1) |
| 363 | { |
| 364 | a2_cnxx_slot = -1; |
| 365 | apple2_update_memory(space->machine); |
| 366 | } |
| 367 | |
| 343 | 368 | /* normal handler */ |
| 344 | 369 | if (handlers[offset / 0x10]) |
| 345 | 370 | result = handlers[offset / 0x10](space, offset % 0x10); |
| r7840 | r7841 | |
| 384 | 409 | |
| 385 | 410 | if (offset < 0x80) |
| 386 | 411 | { |
| 412 | if (a2_cnxx_slot != -1) |
| 413 | { |
| 414 | a2_cnxx_slot = -1; |
| 415 | apple2_update_memory(space->machine); |
| 416 | } |
| 417 | |
| 387 | 418 | /* normal handler */ |
| 388 | 419 | if (handlers[offset / 0x10]) |
| 389 | 420 | handlers[offset / 0x10](space, offset % 0x10, data); |
| r7840 | r7841 | |
| 402 | 433 | } |
| 403 | 434 | } |
| 404 | 435 | |
| 436 | static READ8_HANDLER( apple2_c1xx_r ) |
| 437 | { |
| 438 | int slotnum; |
| 439 | UINT8 *rom, *slot_ram; |
| 440 | UINT32 rom_length, slot_length; |
| 405 | 441 | |
| 442 | // find slot_ram if any |
| 443 | rom = memory_region(space->machine, "maincpu"); |
| 444 | rom_length = memory_region_length(space->machine, "maincpu") & ~0xFFF; |
| 445 | slot_length = memory_region_length(space->machine, "maincpu") - rom_length; |
| 446 | slot_ram = (slot_length > 0) ? &rom[rom_length] : NULL; |
| 406 | 447 | |
| 448 | if (slot_ram) |
| 449 | { |
| 450 | slotnum = ((offset>>8) & 0xf) + 1; |
| 451 | if (a2_cnxx_slot != slotnum) |
| 452 | { |
| 453 | a2_cnxx_slot = slotnum; |
| 454 | apple2_update_memory(space->machine); |
| 455 | } |
| 456 | |
| 457 | return slot_ram[offset]; |
| 458 | } |
| 459 | // else fall through to floating bus |
| 460 | |
| 461 | return apple2_getfloatingbusvalue(space->machine); |
| 462 | } |
| 463 | |
| 464 | static WRITE8_HANDLER ( apple2_c1xx_w ) |
| 465 | { |
| 466 | int slotnum; |
| 467 | running_device *slotdevice; |
| 468 | UINT8 *rom, *slot_ram; |
| 469 | UINT32 rom_length, slot_length; |
| 470 | |
| 471 | // find slot_ram if any |
| 472 | rom = memory_region(space->machine, "maincpu"); |
| 473 | rom_length = memory_region_length(space->machine, "maincpu") & ~0xFFF; |
| 474 | slot_length = memory_region_length(space->machine, "maincpu") - rom_length; |
| 475 | slot_ram = (slot_length > 0) ? &rom[rom_length] : NULL; |
| 476 | |
| 477 | slotnum = ((offset>>8) & 0xf) + 1; |
| 478 | |
| 479 | slotdevice = apple2_slot(space->machine, slotnum); |
| 480 | |
| 481 | if (slotdevice != NULL) |
| 482 | { |
| 483 | apple2_slot_ROM_w(slotdevice, offset&0xff, data); |
| 484 | } |
| 485 | else |
| 486 | { |
| 487 | if (slot_ram) |
| 488 | slot_ram[offset] = data; |
| 489 | } |
| 490 | } |
| 491 | |
| 492 | static READ8_HANDLER( apple2_c4xx_r ) |
| 493 | { |
| 494 | int slotnum; |
| 495 | UINT8 *rom, *slot_ram; |
| 496 | UINT32 rom_length, slot_length; |
| 497 | |
| 498 | // find slot_ram if any |
| 499 | rom = memory_region(space->machine, "maincpu"); |
| 500 | rom_length = memory_region_length(space->machine, "maincpu") & ~0xFFF; |
| 501 | slot_length = memory_region_length(space->machine, "maincpu") - rom_length; |
| 502 | slot_ram = (slot_length > 0) ? &rom[rom_length] : NULL; |
| 503 | |
| 504 | if (slot_ram) |
| 505 | { |
| 506 | slotnum = ((offset>>8) & 0xf) + 4; |
| 507 | if (a2_cnxx_slot != slotnum) |
| 508 | { |
| 509 | a2_cnxx_slot = slotnum; |
| 510 | apple2_update_memory(space->machine); |
| 511 | } |
| 512 | |
| 513 | return slot_ram[offset+0x300]; |
| 514 | } |
| 515 | // else fall through to floating bus |
| 516 | |
| 517 | return apple2_getfloatingbusvalue(space->machine); |
| 518 | } |
| 519 | |
| 520 | static WRITE8_HANDLER ( apple2_c4xx_w ) |
| 521 | { |
| 522 | int slotnum; |
| 523 | running_device *slotdevice; |
| 524 | UINT8 *rom, *slot_ram; |
| 525 | UINT32 rom_length, slot_length; |
| 526 | |
| 527 | // find slot_ram if any |
| 528 | rom = memory_region(space->machine, "maincpu"); |
| 529 | rom_length = memory_region_length(space->machine, "maincpu") & ~0xFFF; |
| 530 | slot_length = memory_region_length(space->machine, "maincpu") - rom_length; |
| 531 | slot_ram = (slot_length > 0) ? &rom[rom_length] : NULL; |
| 532 | |
| 533 | slotnum = ((offset>>8) & 0xf) + 4; |
| 534 | |
| 535 | slotdevice = apple2_slot(space->machine, slotnum); |
| 536 | |
| 537 | if (slotdevice != NULL) |
| 538 | { |
| 539 | apple2_slot_ROM_w(slotdevice, offset&0xff, data); |
| 540 | } |
| 541 | else |
| 542 | { |
| 543 | if (slot_ram) |
| 544 | slot_ram[offset] = data; |
| 545 | } |
| 546 | } |
| 547 | |
| 548 | static READ8_HANDLER(apple2_cfff_r) |
| 549 | { |
| 550 | // debugger guard |
| 551 | if(!space->debugger_access) |
| 552 | { |
| 553 | a2_cnxx_slot = -1; |
| 554 | apple2_update_memory(space->machine); |
| 555 | } |
| 556 | |
| 557 | return apple2_getfloatingbusvalue(space->machine); |
| 558 | } |
| 559 | |
| 560 | static WRITE8_HANDLER(apple2_cfff_w) |
| 561 | { |
| 562 | a2_cnxx_slot = -1; |
| 563 | apple2_update_memory(space->machine); |
| 564 | } |
| 565 | |
| 566 | static READ8_HANDLER ( apple2_c800_r ) |
| 567 | { |
| 568 | running_device *slotdevice; |
| 569 | |
| 570 | slotdevice = apple2_slot(space->machine, a2_cnxx_slot); |
| 571 | |
| 572 | if (slotdevice != NULL) |
| 573 | { |
| 574 | return apple2_c800_slot_r(slotdevice, offset&0xfff); |
| 575 | } |
| 576 | |
| 577 | return apple2_getfloatingbusvalue(space->machine); |
| 578 | } |
| 579 | |
| 580 | static WRITE8_HANDLER ( apple2_c800_w ) |
| 581 | { |
| 582 | running_device *slotdevice; |
| 583 | |
| 584 | slotdevice = apple2_slot(space->machine, a2_cnxx_slot); |
| 585 | |
| 586 | if (slotdevice != NULL) |
| 587 | { |
| 588 | apple2_c800_slot_w(slotdevice, offset&0xfff, data); |
| 589 | } |
| 590 | } |
| 591 | |
| 592 | static READ8_HANDLER ( apple2_ce00_r ) |
| 593 | { |
| 594 | running_device *slotdevice; |
| 595 | |
| 596 | slotdevice = apple2_slot(space->machine, a2_cnxx_slot); |
| 597 | |
| 598 | if (slotdevice != NULL) |
| 599 | { |
| 600 | return apple2_c800_slot_r(slotdevice, (offset&0xfff) + 0x600); |
| 601 | } |
| 602 | |
| 603 | return apple2_getfloatingbusvalue(space->machine); |
| 604 | } |
| 605 | |
| 606 | static WRITE8_HANDLER ( apple2_ce00_w ) |
| 607 | { |
| 608 | running_device *slotdevice; |
| 609 | |
| 610 | slotdevice = apple2_slot(space->machine, a2_cnxx_slot); |
| 611 | |
| 612 | if (slotdevice != NULL) |
| 613 | { |
| 614 | apple2_c800_slot_w(slotdevice, (offset&0xfff)+0x600, data); |
| 615 | } |
| 616 | } |
| 617 | |
| 407 | 618 | static void apple2_mem_0000(running_machine *machine, offs_t begin, offs_t end, apple2_meminfo *meminfo) |
| 408 | 619 | { |
| 409 | 620 | meminfo->read_mem = (apple2_flags & VAR_ALTZP) ? 0x010000 : 0x000000; |
| r7840 | r7841 | |
| 466 | 677 | meminfo->write_handler = apple2_c0xx_w; |
| 467 | 678 | } |
| 468 | 679 | |
| 680 | static void apple2_mem_CFFF(running_machine *machine, offs_t begin, offs_t end, apple2_meminfo *meminfo) |
| 681 | { |
| 682 | meminfo->read_handler = apple2_cfff_r; |
| 683 | meminfo->write_handler = apple2_cfff_w; |
| 684 | } |
| 685 | |
| 469 | 686 | static void apple2_mem_Cx00(running_machine *machine, offs_t begin, offs_t end, apple2_meminfo *meminfo) |
| 470 | 687 | { |
| 471 | 688 | if (apple2_flags & VAR_INTCXROM) |
| r7840 | r7841 | |
| 496 | 713 | |
| 497 | 714 | static void apple2_mem_C800(running_machine *machine, offs_t begin, offs_t end, apple2_meminfo *meminfo) |
| 498 | 715 | { |
| 499 | | meminfo->read_mem = (begin & 0x0FFF) | (apple2_flags & VAR_ROMSWITCH ? 0x4000 : 0x0000) | APPLE2_MEM_ROM; |
| 500 | | meminfo->write_mem = APPLE2_MEM_FLOATING; |
| 716 | if (a2_cnxx_slot == -1) |
| 717 | { |
| 718 | meminfo->read_mem = (begin & 0x0FFF) | (apple2_flags & VAR_ROMSWITCH ? 0x4000 : 0x0000) | APPLE2_MEM_ROM; |
| 719 | meminfo->write_mem = APPLE2_MEM_FLOATING; |
| 720 | } |
| 721 | else |
| 722 | { |
| 723 | meminfo->read_handler = apple2_c800_r; |
| 724 | meminfo->write_handler = apple2_c800_w; |
| 725 | } |
| 501 | 726 | } |
| 502 | 727 | |
| 503 | 728 | static void apple2_mem_CE00(running_machine *machine, offs_t begin, offs_t end, apple2_meminfo *meminfo) |
| r7840 | r7841 | |
| 509 | 734 | } |
| 510 | 735 | else |
| 511 | 736 | { |
| 512 | | meminfo->read_mem = (begin & 0x0FFF) | (apple2_flags & VAR_ROMSWITCH ? 0x4000 : 0x0000) | APPLE2_MEM_ROM; |
| 513 | | meminfo->write_mem = APPLE2_MEM_FLOATING; |
| 737 | if (a2_cnxx_slot == -1) |
| 738 | { |
| 739 | meminfo->read_mem = (begin & 0x0FFF) | (apple2_flags & VAR_ROMSWITCH ? 0x4000 : 0x0000) | APPLE2_MEM_ROM; |
| 740 | meminfo->write_mem = APPLE2_MEM_FLOATING; |
| 741 | } |
| 742 | else |
| 743 | { |
| 744 | meminfo->read_handler = apple2_ce00_r; |
| 745 | meminfo->write_handler = apple2_ce00_w; |
| 746 | } |
| 514 | 747 | } |
| 515 | 748 | } |
| 516 | 749 | |
| r7840 | r7841 | |
| 579 | 812 | { 0xC300, 0xC3FF, apple2_mem_C300, A2MEM_MONO }, |
| 580 | 813 | { 0xC400, 0xC7FF, apple2_mem_Cx00, A2MEM_MONO }, |
| 581 | 814 | { 0xC800, 0xCDFF, apple2_mem_C800, A2MEM_MONO }, |
| 582 | | { 0xCE00, 0xCFFF, apple2_mem_CE00, A2MEM_MONO }, |
| 815 | { 0xCE00, 0xCFFE, apple2_mem_CE00, A2MEM_MONO }, |
| 816 | { 0xCFFF, 0xCFFF, apple2_mem_CFFF, A2MEM_IO }, |
| 583 | 817 | { 0xD000, 0xDFFF, apple2_mem_D000, A2MEM_DUAL }, |
| 584 | 818 | { 0xE000, 0xFFFF, apple2_mem_E000, A2MEM_DUAL }, |
| 585 | 819 | { 0 } |