src/mess/machine/kaypro.c
| r3670 | r3671 | |
| 152 | 152 | ******************************************************/ |
| 153 | 153 | INTERRUPT_GEN( kaypro_interrupt ) |
| 154 | 154 | { |
| 155 | const address_space *space = cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 155 | 156 | int mod, row, col, chg, new; |
| 156 | 157 | static int lastrow = 0, mask = 0x00, key = 0x00, repeat = 0, repeater = 0; |
| 157 | 158 | |
| r3670 | r3671 | |
| 167 | 168 | } |
| 168 | 169 | |
| 169 | 170 | row = 9; |
| 170 | | new = input_port_read(machine, "ROW9"); |
| 171 | new = input_port_read(device->machine, "ROW9"); |
| 171 | 172 | chg = keyrows[row] ^ new; |
| 172 | 173 | |
| 173 | | if (!chg) { new = input_port_read(machine, "ROW8"); chg = keyrows[--row] ^ new; } |
| 174 | | if (!chg) { new = input_port_read(machine, "ROW7"); chg = keyrows[--row] ^ new; } |
| 175 | | if (!chg) { new = input_port_read(machine, "ROW6"); chg = keyrows[--row] ^ new; } |
| 176 | | if (!chg) { new = input_port_read(machine, "ROW5"); chg = keyrows[--row] ^ new; } |
| 177 | | if (!chg) { new = input_port_read(machine, "ROW4"); chg = keyrows[--row] ^ new; } |
| 178 | | if (!chg) { new = input_port_read(machine, "ROW3"); chg = keyrows[--row] ^ new; } |
| 179 | | if (!chg) { new = input_port_read(machine, "ROW2"); chg = keyrows[--row] ^ new; } |
| 180 | | if (!chg) { new = input_port_read(machine, "ROW1"); chg = keyrows[--row] ^ new; } |
| 181 | | if (!chg) { new = input_port_read(machine, "ROW0"); chg = keyrows[--row] ^ new; } |
| 174 | if (!chg) { new = input_port_read(device->machine, "ROW8"); chg = keyrows[--row] ^ new; } |
| 175 | if (!chg) { new = input_port_read(device->machine, "ROW7"); chg = keyrows[--row] ^ new; } |
| 176 | if (!chg) { new = input_port_read(device->machine, "ROW6"); chg = keyrows[--row] ^ new; } |
| 177 | if (!chg) { new = input_port_read(device->machine, "ROW5"); chg = keyrows[--row] ^ new; } |
| 178 | if (!chg) { new = input_port_read(device->machine, "ROW4"); chg = keyrows[--row] ^ new; } |
| 179 | if (!chg) { new = input_port_read(device->machine, "ROW3"); chg = keyrows[--row] ^ new; } |
| 180 | if (!chg) { new = input_port_read(device->machine, "ROW2"); chg = keyrows[--row] ^ new; } |
| 181 | if (!chg) { new = input_port_read(device->machine, "ROW1"); chg = keyrows[--row] ^ new; } |
| 182 | if (!chg) { new = input_port_read(device->machine, "ROW0"); chg = keyrows[--row] ^ new; } |
| 182 | 183 | if (!chg) --row; |
| 183 | 184 | |
| 184 | 185 | if (row >= 0) |
| r3670 | r3671 | |
| 222 | 223 | if( key ) /* normal key */ |
| 223 | 224 | { |
| 224 | 225 | repeater = 30; |
| 225 | | kaypro_conin_w(machine, 0, key); |
| 226 | kaypro_conin_w(space, 0, key); |
| 226 | 227 | } |
| 227 | 228 | else |
| 228 | 229 | if( (row == 0) && (chg == 0x04) ) /* Ctrl-@ (NUL) */ |
| 229 | | kaypro_conin_w(machine, 0, 0); |
| 230 | kaypro_conin_w(space, 0, 0); |
| 230 | 231 | keyrows[row] |= new; |
| 231 | 232 | } |
| 232 | 233 | else |
| r3670 | r3671 | |
| 237 | 238 | } |
| 238 | 239 | else if ( key && (keyrows[lastrow] & mask) && repeat == 0 ) |
| 239 | 240 | { |
| 240 | | kaypro_conin_w(machine, 0, key); |
| 241 | kaypro_conin_w(space, 0, key); |
| 241 | 242 | } |
| 242 | 243 | } |
| 243 | 244 | |
src/mess/machine/cpm_bios.c
| r3670 | r3671 | |
| 77 | 77 | * initialize bios functions at addresses BIOS_00 .. BIOS_11 |
| 78 | 78 | * and the central bios execute function at BIOS_EXEC |
| 79 | 79 | *****************************************************************************/ |
| 80 | | static void cpm_jumptable(void) |
| 80 | static void cpm_jumptable(running_machine *machine) |
| 81 | 81 | { |
| 82 | | UINT8 * RAM = memory_get_write_ptr(0, ADDRESS_SPACE_PROGRAM, 0x0000); |
| 82 | const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 83 | UINT8 * RAM = memory_get_write_ptr(space, 0x0000); |
| 83 | 84 | int i; |
| 84 | 85 | int jmp_addr, fun_addr; |
| 85 | 86 | |
| r3670 | r3671 | |
| 132 | 133 | *****************************************************************************/ |
| 133 | 134 | int cpm_init( running_machine *machine, int n, const char *const ids[]) |
| 134 | 135 | { |
| 135 | | UINT8 * RAM = memory_get_write_ptr(0, ADDRESS_SPACE_PROGRAM, 0x0000); |
| 136 | const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 137 | UINT8 * RAM = memory_get_write_ptr(space, 0x0000); |
| 136 | 138 | const dsk_fmt *f; |
| 137 | 139 | int i, d; |
| 138 | 140 | |
| r3670 | r3671 | |
| 258 | 260 | /* create a file to receive list output (ie. PIP LST:=FILE.EXT) */ |
| 259 | 261 | mame_fopen(SEARCHPATH_IMAGE, "cpm.lst", OPEN_FLAG_WRITE, &lp); |
| 260 | 262 | |
| 261 | | cpm_jumptable(); |
| 263 | cpm_jumptable(machine); |
| 262 | 264 | |
| 263 | 265 | add_exit_callback(machine, cpm_exit); |
| 264 | 266 | return 0; |
| r3670 | r3671 | |
| 293 | 295 | * cpm_conout_chr |
| 294 | 296 | * send a character to the console |
| 295 | 297 | *****************************************************************************/ |
| 296 | | static void cpm_conout_chr(int data) |
| 298 | static void cpm_conout_chr(running_machine *machine, int data) |
| 297 | 299 | { |
| 298 | | io_write_byte(BIOS_CONOUT, data); |
| 300 | const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_IO); |
| 301 | memory_write_byte(space, BIOS_CONOUT, data); |
| 299 | 302 | } |
| 300 | 303 | |
| 301 | 304 | /***************************************************************************** |
| 302 | 305 | * cpm_conout_str |
| 303 | 306 | * send a zero terminated string to the console |
| 304 | 307 | *****************************************************************************/ |
| 305 | | static void cpm_conout_str(const char *src) |
| 308 | static void cpm_conout_str(running_machine *machine, const char *src) |
| 306 | 309 | { |
| 307 | 310 | while (*src) |
| 308 | | cpm_conout_chr(*src++); |
| 311 | cpm_conout_chr(machine, *src++); |
| 309 | 312 | } |
| 310 | 313 | |
| 311 | 314 | /***************************************************************************** |
| r3670 | r3671 | |
| 500 | 503 | dma = d; |
| 501 | 504 | } |
| 502 | 505 | |
| 503 | | static void dump_sector(void) |
| 506 | static void dump_sector(running_machine *machine) |
| 504 | 507 | { |
| 505 | | UINT8 *DMA = ((UINT8 *) memory_get_write_ptr(0, ADDRESS_SPACE_PROGRAM, 0x0000)) + dma; |
| 508 | const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 509 | UINT8 *DMA = ((UINT8 *) memory_get_write_ptr(space, 0x0000)) + dma; |
| 506 | 510 | |
| 507 | 511 | { |
| 508 | 512 | int i; |
| r3670 | r3671 | |
| 522 | 526 | } |
| 523 | 527 | } |
| 524 | 528 | |
| 525 | | int cpm_disk_read_sector(void) |
| 529 | int cpm_disk_read_sector(running_machine *machine) |
| 526 | 530 | { |
| 531 | const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 527 | 532 | int result = -1; |
| 528 | 533 | |
| 529 | 534 | /* TODO: remove this */ |
| 530 | | unsigned char *RAM = memory_get_write_ptr(0, ADDRESS_SPACE_PROGRAM, 0x0000); |
| 535 | unsigned char *RAM = memory_get_write_ptr(space, 0x0000); |
| 531 | 536 | |
| 532 | 537 | if (curdisk >= 0 && |
| 533 | 538 | curdisk < num_disks && |
| r3670 | r3671 | |
| 548 | 553 | { |
| 549 | 554 | logerror("BDOS Err on %c: Select\n", curdisk + 'A'); |
| 550 | 555 | } |
| 551 | | dump_sector(); |
| 556 | dump_sector(machine); |
| 552 | 557 | return result; |
| 553 | 558 | } |
| 554 | 559 | |
| 555 | | int cpm_disk_write_sector(void) |
| 560 | int cpm_disk_write_sector(running_machine *machine) |
| 556 | 561 | { |
| 562 | const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 557 | 563 | int result = -1; |
| 558 | 564 | |
| 559 | 565 | /* TODO: remove this */ |
| 560 | | unsigned char *RAM = memory_get_write_ptr(0, ADDRESS_SPACE_PROGRAM, 0x0000); |
| 566 | unsigned char *RAM = memory_get_write_ptr(space, 0x0000); |
| 561 | 567 | |
| 562 | 568 | if (curdisk >= 0 && |
| 563 | 569 | curdisk < num_disks && |
| r3670 | r3671 | |
| 588 | 594 | { |
| 589 | 595 | const dsk_fmt *f; |
| 590 | 596 | char buff[256]; |
| 591 | | UINT8 * RAM = memory_get_write_ptr(0, ADDRESS_SPACE_PROGRAM, 0x0000); |
| 597 | const address_space *program_space = cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 598 | UINT8 * RAM = memory_get_write_ptr(program_space, 0x0000); |
| 592 | 599 | UINT16 tmp, af, bc, de, hl; |
| 593 | 600 | int i; |
| 594 | 601 | |
| 595 | 602 | /* Get the values of the basic Z80 registers */ |
| 596 | | af = activecpu_get_reg( Z80_AF ); |
| 597 | | bc = activecpu_get_reg( Z80_BC ); |
| 598 | | de = activecpu_get_reg( Z80_DE ); |
| 599 | | hl = activecpu_get_reg( Z80_HL ); |
| 603 | af = cpu_get_reg( space->machine->cpu[0], Z80_AF ); |
| 604 | bc = cpu_get_reg( space->machine->cpu[0], Z80_BC ); |
| 605 | de = cpu_get_reg( space->machine->cpu[0], Z80_DE ); |
| 606 | hl = cpu_get_reg( space->machine->cpu[0], Z80_HL ); |
| 600 | 607 | |
| 601 | 608 | switch( data ) |
| 602 | 609 | { |
| r3670 | r3671 | |
| 604 | 611 | if (VERBOSE) |
| 605 | 612 | logerror("BIOS 00 cold boot\n"); |
| 606 | 613 | |
| 607 | | cpm_conout_str("MESS CP/M 2.2 Emulator\r\n\n"); |
| 614 | cpm_conout_str(space->machine, "MESS CP/M 2.2 Emulator\r\n\n"); |
| 608 | 615 | for (i = 0; i < NDSK; i++) |
| 609 | 616 | { |
| 610 | 617 | if (fmt[i] != -1) |
| r3670 | r3671 | |
| 619 | 626 | (f->density == DEN_FM_LO || f->density == DEN_FM_HI) ? "SD" : "DD", |
| 620 | 627 | f->spt, f->seclen, |
| 621 | 628 | f->dpb.dsm + 1, (RECL << f->dpb.bsh) / 1024); |
| 622 | | cpm_conout_str(buff); |
| 629 | cpm_conout_str(space->machine, buff); |
| 623 | 630 | } |
| 624 | 631 | } |
| 625 | 632 | /* change vector at 0000 to warm start */ |
| r3670 | r3671 | |
| 639 | 646 | |
| 640 | 647 | /* copy the CP/M 2.2 image to Z80 memory space */ |
| 641 | 648 | for (i = 0; i < 0x1600; i++) |
| 642 | | RAM[CCP + i] = memory_region(machine, "cpu1")[i]; |
| 649 | RAM[CCP + i] = memory_region(space->machine, "cpu1")[i]; |
| 643 | 650 | |
| 644 | 651 | /* build the bios jump table */ |
| 645 | | cpm_jumptable(); |
| 652 | cpm_jumptable(space->machine); |
| 646 | 653 | bc = curdisk; |
| 647 | | cpu_set_reg(machine->activecpu, Z80_BC, bc ); |
| 648 | | cpu_set_reg(machine->activecpu, Z80_SP, 0x0080 ); |
| 649 | | cpu_set_reg(machine->activecpu, Z80_PC, CCP + 3 ); |
| 654 | cpu_set_reg(space->machine->cpu[0], Z80_BC, bc ); |
| 655 | cpu_set_reg(space->machine->cpu[0], Z80_SP, 0x0080 ); |
| 656 | cpu_set_reg(space->machine->cpu[0], Z80_PC, CCP + 3 ); |
| 650 | 657 | break; |
| 651 | 658 | |
| 652 | 659 | case 0x02: /* CSTAT */ |
| 653 | | tmp = io_read_byte(BIOS_CONST) & 0xff; |
| 660 | tmp = memory_read_byte(cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_IO), BIOS_CONST) & 0xff; |
| 654 | 661 | af = (af & 0xff) | (tmp << 8); |
| 655 | 662 | |
| 656 | 663 | if (VERBOSE_CONIO) |
| r3670 | r3671 | |
| 658 | 665 | break; |
| 659 | 666 | |
| 660 | 667 | case 0x03: /* CONIN */ |
| 661 | | if ( io_read_byte(BIOS_CONST) == 0 ) |
| 668 | if ( memory_read_byte(cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_IO), BIOS_CONST) == 0 ) |
| 662 | 669 | { |
| 663 | | cpu_set_reg(machine->activecpu, Z80_PC, activecpu_get_reg(Z80_PC) - 2 ); |
| 670 | cpu_set_reg(space->machine->cpu[0], Z80_PC, cpu_get_reg(space->machine->cpu[0], Z80_PC) - 2 ); |
| 664 | 671 | break; |
| 665 | 672 | } |
| 666 | | tmp = io_read_byte(BIOS_CONIN) & 0xff; |
| 673 | tmp = memory_read_byte(cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_IO), BIOS_CONIN) & 0xff; |
| 667 | 674 | af = (af & 0xff) | (tmp << 8); |
| 668 | 675 | if (VERBOSE_CONIO) |
| 669 | 676 | logerror("BIOS 03 console input A:%02X\n", tmp); |
| r3670 | r3671 | |
| 673 | 680 | tmp = bc & 0xff; |
| 674 | 681 | if (VERBOSE_CONIO) |
| 675 | 682 | logerror("BIOS 04 console output C:%02X\n", tmp); |
| 676 | | cpm_conout_chr( tmp ); |
| 683 | cpm_conout_chr( space->machine, tmp ); |
| 677 | 684 | break; |
| 678 | 685 | |
| 679 | 686 | case 0x05: /* LSTOUT */ |
| r3670 | r3671 | |
| 751 | 758 | |
| 752 | 759 | |
| 753 | 760 | case 0x0d: /* RDSEC */ |
| 754 | | tmp = cpm_disk_read_sector(); |
| 761 | tmp = cpm_disk_read_sector(space->machine); |
| 755 | 762 | af = (af & 0xff) | (tmp << 8); |
| 756 | 763 | |
| 757 | 764 | if (VERBOSE_BIOS) |
| r3670 | r3671 | |
| 760 | 767 | |
| 761 | 768 | |
| 762 | 769 | case 0x0e: /* WRSEC */ |
| 763 | | tmp = cpm_disk_write_sector(); |
| 770 | tmp = cpm_disk_write_sector(space->machine); |
| 764 | 771 | af = (af & 0xff) | (tmp << 8); |
| 765 | 772 | |
| 766 | 773 | if (VERBOSE_BIOS) |
| r3670 | r3671 | |
| 805 | 812 | |
| 806 | 813 | |
| 807 | 814 | case 0x11: /* TRAP */ |
| 808 | | cpm_conout_str(buff); |
| 815 | cpm_conout_str(space->machine, buff); |
| 809 | 816 | break; |
| 810 | 817 | } |
| 811 | 818 | |
| 812 | 819 | /* Write back the possibly modified Z80 basic registers */ |
| 813 | | cpu_set_reg(machine->activecpu, Z80_AF, af ); |
| 814 | | cpu_set_reg(machine->activecpu, Z80_BC, bc ); |
| 815 | | cpu_set_reg(machine->activecpu, Z80_DE, de ); |
| 816 | | cpu_set_reg(machine->activecpu, Z80_HL, hl ); |
| 820 | cpu_set_reg(space->machine->cpu[0], Z80_AF, af ); |
| 821 | cpu_set_reg(space->machine->cpu[0], Z80_BC, bc ); |
| 822 | cpu_set_reg(space->machine->cpu[0], Z80_DE, de ); |
| 823 | cpu_set_reg(space->machine->cpu[0], Z80_HL, hl ); |
| 817 | 824 | } |
| 818 | 825 | |