src/mess/video/i82720.c
| r1470 | r1471 | |
| 29 | 29 | #define GDC_FIFO_DIR_WRITE 0 |
| 30 | 30 | #define GDC_FIFO_DIR_READ 1 |
| 31 | 31 | |
| 32 | | #define GDC_LOG_CMDS |
| 33 | | #ifdef GDC_LOG_CMDS |
| 34 | | #define GDC_LOG_CMD_1(x) (logerror(x)) |
| 35 | | #define GDC_LOG_CMD_2(x,y) (logerror(x,y)) |
| 36 | | #define GDC_LOG_CMD_3(x,y,z) (logerror(x,y,z)) |
| 37 | | #define GDC_LOG_CMD_4(x,y,z,a) (logerror(x,y,z,a)) |
| 38 | | #else |
| 39 | | #define GDC_LOG_CMD_1(x) |
| 40 | | #define GDC_LOG_CMD_2(x,y) |
| 41 | | #define GDC_LOG_CMD_3(x,y,z) |
| 42 | | #define GDC_LOG_CMD_4(x,y,z,a) |
| 43 | | #endif |
| 32 | #define VERBOSE 1 |
| 33 | #define LOG(x) do { if (VERBOSE) logerror x; } while (0) |
| 44 | 34 | |
| 45 | 35 | /* FIFO */ |
| 46 | 36 | typedef struct |
| r1470 | r1471 | |
| 218 | 208 | /* We cannot go higher than 15 */ |
| 219 | 209 | gdcp->fifo.write_pos = (gdcp->fifo.write_pos + 1) & 0x0f; |
| 220 | 210 | } else { |
| 221 | | GDC_LOG_CMD_2("gdc_fifo_enqueue: The fifo is full at PC = %04X\n", |
| 222 | | activecpu_get_pc()); |
| 211 | LOG(("gdc_fifo_enqueue: The fifo is full at PC = %04X\n", |
| 212 | activecpu_get_pc())); |
| 223 | 213 | } |
| 224 | 214 | } |
| 225 | 215 | |
| r1470 | r1471 | |
| 417 | 407 | gdc_write(address, gdc_read(address) | (data & mask)); |
| 418 | 408 | break; |
| 419 | 409 | } |
| 420 | | /* GDC_LOG_CMD_3("gdc_write_data: address = %04x, base = %04x\n", |
| 421 | | address, base_addr); */ |
| 410 | /* LOG(("gdc_write_data: address = %04x, base = %04x\n", |
| 411 | address, base_addr)); */ |
| 422 | 412 | } |
| 423 | 413 | |
| 424 | 414 | static void gdc_update_ead_and_mask(void) |
| r1470 | r1471 | |
| 483 | 473 | INLINE |
| 484 | 474 | void gdc_dump_disp_regs(void) |
| 485 | 475 | { |
| 486 | | GDC_LOG_CMD_2("gdc: display mode = %d\n", |
| 487 | | gdc.registers.display.display_mode); |
| 488 | | GDC_LOG_CMD_2("gdc: words_per_line = %d\n", |
| 489 | | gdc.registers.display.words_per_line); |
| 490 | | GDC_LOG_CMD_2("gdc: horiz_sync_width = %d\n", |
| 491 | | gdc.registers.display.horiz_sync_width); |
| 492 | | GDC_LOG_CMD_2("gdc: lines_per_field = %d\n", |
| 493 | | gdc.registers.display.lines_per_field); |
| 476 | LOG(("gdc: display mode = %d\n", |
| 477 | gdc.registers.display.display_mode)); |
| 478 | LOG(("gdc: words_per_line = %d\n", |
| 479 | gdc.registers.display.words_per_line)); |
| 480 | LOG(("gdc: horiz_sync_width = %d\n", |
| 481 | gdc.registers.display.horiz_sync_width)); |
| 482 | LOG(("gdc: lines_per_field = %d\n", |
| 483 | gdc.registers.display.lines_per_field)); |
| 494 | 484 | } |
| 495 | 485 | |
| 496 | 486 | INLINE const char* |
| r1470 | r1471 | |
| 538 | 528 | reg += (gdc.registers.command.sync[0] & 0x02) ? 0x01 : 0; |
| 539 | 529 | gdc.registers.display.display_mode = reg; |
| 540 | 530 | |
| 541 | | GDC_LOG_CMD_2("gdc_cmd_sync: mode byte = %02X\n", |
| 542 | | gdc.registers.command.sync[0]); |
| 543 | | GDC_LOG_CMD_2("gdc_cmd_sync: mode is %s\n", gdc_disp_mode_to_str(reg)); |
| 531 | LOG(("gdc_cmd_sync: mode byte = %02X\n", |
| 532 | gdc.registers.command.sync[0])); |
| 533 | LOG(("gdc_cmd_sync: mode is %s\n", gdc_disp_mode_to_str(reg))); |
| 544 | 534 | |
| 545 | 535 | |
| 546 | 536 | if ( i == 1 ) |
| r1470 | r1471 | |
| 552 | 542 | gdc.registers.display.words_per_line = reg + 2; |
| 553 | 543 | gdc.registers.display.display_width = reg + 2; |
| 554 | 544 | |
| 555 | | GDC_LOG_CMD_2("gdc_cmd_sync: words_per_line set to %d\n", |
| 556 | | gdc.registers.display.words_per_line); |
| 557 | | GDC_LOG_CMD_2("gdc_cmd_sync: display_width set to %d\n", |
| 558 | | gdc.registers.display.display_width); |
| 545 | LOG(("gdc_cmd_sync: words_per_line set to %d\n", |
| 546 | gdc.registers.display.words_per_line)); |
| 547 | LOG(("gdc_cmd_sync: display_width set to %d\n", |
| 548 | gdc.registers.display.display_width)); |
| 559 | 549 | |
| 560 | 550 | if ( i == 2 ) |
| 561 | 551 | return; |
| r1470 | r1471 | |
| 621 | 611 | UINT8* param_in_fifo = gdc_fifo_dequeue_param(&gdc); |
| 622 | 612 | if ( param_in_fifo ) { |
| 623 | 613 | gdc.registers.display.words_per_line = *param_in_fifo; |
| 624 | | GDC_LOG_CMD_2("gdc_cmd_pitch: words_per_line set to %d\n", |
| 625 | | gdc.registers.display.words_per_line); |
| 614 | LOG(("gdc_cmd_pitch: words_per_line set to %d\n", |
| 615 | gdc.registers.display.words_per_line)); |
| 626 | 616 | } |
| 627 | 617 | } |
| 628 | 618 | |
| r1470 | r1471 | |
| 689 | 679 | param <<= 1; |
| 690 | 680 | } |
| 691 | 681 | tmp_str[8] = 0; |
| 692 | | GDC_LOG_CMD_2("gdc_cmd_pram: %s\n", tmp_str); |
| 682 | LOG(("gdc_cmd_pram: %s\n", tmp_str)); |
| 693 | 683 | } |
| 694 | 684 | if ( gdc_get_base_addr(&gdc) != base_addr_before ) { |
| 695 | | GDC_LOG_CMD_3("gdc_cmd_pram: base_addr changed from %08X to %08X\n", |
| 696 | | base_addr_before, gdc_get_base_addr(&gdc)); |
| 685 | LOG(("gdc_cmd_pram: base_addr changed from %08X to %08X\n", |
| 686 | base_addr_before, gdc_get_base_addr(&gdc))); |
| 697 | 687 | } |
| 698 | 688 | } |
| 699 | 689 | |
| r1470 | r1471 | |
| 712 | 702 | dispregs->disp_cursor = (*param_p & 0x80) != 0; |
| 713 | 703 | /* Number of lines per character row - 1 */ |
| 714 | 704 | dispregs->lines_per_ch_row = (*param_p & 0x1f) + 1; |
| 715 | | GDC_LOG_CMD_2("gdc_cmd_cchar: Display cursor = %d\n", |
| 716 | | dispregs->disp_cursor); |
| 717 | | GDC_LOG_CMD_2("gdc_cmd_cchar: Lines per character row = %d\n", |
| 718 | | dispregs->lines_per_ch_row); |
| 705 | LOG(("gdc_cmd_cchar: Display cursor = %d\n", |
| 706 | dispregs->disp_cursor)); |
| 707 | LOG(("gdc_cmd_cchar: Lines per character row = %d\n", |
| 708 | dispregs->lines_per_ch_row)); |
| 719 | 709 | /* Next parameter */ |
| 720 | 710 | if ( ( param_p = gdc_fifo_dequeue_param(&gdc)) == NULL ) return; |
| 721 | 711 | /* Lower bits of blink rate (there are 5) */ |
| r1470 | r1471 | |
| 724 | 714 | dispregs->cursor_blinking = (*param_p & 0x20) == 0; |
| 725 | 715 | /* Cursor top lite number in the row */ |
| 726 | 716 | dispregs->cursor_top_line = *param_p & 0x1f; |
| 727 | | GDC_LOG_CMD_2("gdc_cmd_cchar: Cursor blinking = %d\n", |
| 728 | | dispregs->cursor_blinking); |
| 729 | | GDC_LOG_CMD_2("gdc_cmd_cchar: Cursor top line = %d\n", |
| 730 | | dispregs->cursor_top_line); |
| 717 | LOG(("gdc_cmd_cchar: Cursor blinking = %d\n", |
| 718 | dispregs->cursor_blinking)); |
| 719 | LOG(("gdc_cmd_cchar: Cursor top line = %d\n", |
| 720 | dispregs->cursor_top_line)); |
| 731 | 721 | /* Next parameter */ |
| 732 | 722 | if ( ( param_p = gdc_fifo_dequeue_param(&gdc)) == NULL ) return; |
| 733 | 723 | dispregs->cursor_blink_rate = (*param_p & 0x07) | temp_reg; |
| 734 | 724 | dispregs->cursor_bottom_line = (*param_p & 0xf8) >> 3; |
| 735 | | GDC_LOG_CMD_2("gdc_cmd_cchar: Cursor blink rate = %d\n", |
| 736 | | dispregs->cursor_blink_rate); |
| 737 | | GDC_LOG_CMD_2("gdc_cmd_cchar: Cursor bottom line = %d\n", |
| 738 | | dispregs->cursor_bottom_line); |
| 725 | LOG(("gdc_cmd_cchar: Cursor blink rate = %d\n", |
| 726 | dispregs->cursor_blink_rate)); |
| 727 | LOG(("gdc_cmd_cchar: Cursor bottom line = %d\n", |
| 728 | dispregs->cursor_bottom_line)); |
| 739 | 729 | |
| 740 | 730 | |
| 741 | 731 | } |
| r1470 | r1471 | |
| 763 | 753 | /* What will be done next time? */ |
| 764 | 754 | dispregs->figs_operation = (*param_p & 0xf1) >> 3; |
| 765 | 755 | dispregs->figs_direction = *param_p & 0x03; |
| 766 | | GDC_LOG_CMD_2("gdc_cmd_figs: Operation = %x\n", dispregs->figs_operation); |
| 767 | | GDC_LOG_CMD_2("gdc_cmd_figs: Direction = %x\n", dispregs->figs_direction); |
| 756 | LOG(("gdc_cmd_figs: Operation = %x\n", dispregs->figs_operation)); |
| 757 | LOG(("gdc_cmd_figs: Direction = %x\n", dispregs->figs_direction)); |
| 768 | 758 | for ( i = 0; i < 5; ++i ) { |
| 769 | 759 | UINT8 quit = 0; |
| 770 | 760 | if ( ( param_p = gdc_fifo_dequeue_param(&gdc)) == NULL ) return; |
| r1470 | r1471 | |
| 791 | 781 | dispregs->figs_dm_param = temp_reg; |
| 792 | 782 | break; |
| 793 | 783 | } |
| 794 | | GDC_LOG_CMD_3("gdc_cmd_figs: dc[%d] = %x\n", i, temp_reg); |
| 784 | LOG(("gdc_cmd_figs: dc[%d] = %x\n", i, temp_reg)); |
| 795 | 785 | if ( quit ) { |
| 796 | 786 | return; |
| 797 | 787 | } |
| r1470 | r1471 | |
| 813 | 803 | if ( ( param_p = gdc_fifo_dequeue_param(&gdc)) == NULL ) return; |
| 814 | 804 | temp_reg |= (*param_p) << 8; |
| 815 | 805 | dispregs->mask = temp_reg; |
| 816 | | GDC_LOG_CMD_2("gdc_cmd_mask: mask = %04X\n", dispregs->mask); |
| 806 | LOG(("gdc_cmd_mask: mask = %04X\n", dispregs->mask)); |
| 817 | 807 | } |
| 818 | 808 | |
| 819 | 809 | /*-------------------------------------------------------------------------*/ |
| r1470 | r1471 | |
| 844 | 834 | { |
| 845 | 835 | TYP_GDC_REGS_DISPLAY* dispregs = &gdc.registers.display; |
| 846 | 836 | gdc_cmd_inner_curs(); |
| 847 | | GDC_LOG_CMD_2("gdc_cmd_curs: ead = %08X, ", dispregs->ead); |
| 848 | | GDC_LOG_CMD_2("mask = %04X\n", dispregs->mask); |
| 837 | LOG(("gdc_cmd_curs: ead = %08X, ", dispregs->ead)); |
| 838 | LOG(("mask = %04X\n", dispregs->mask)); |
| 849 | 839 | } |
| 850 | 840 | |
| 851 | 841 | /*-------------------------------------------------------------------------*/ |
| r1470 | r1471 | |
| 902 | 892 | return; |
| 903 | 893 | } |
| 904 | 894 | |
| 905 | | GDC_LOG_CMD_4("gdc_cmd_wdat: data = %04X, dc = %02X, mod = %x", |
| 906 | | temp_reg, dispregs->figs_dc_param, dispregs->cur_mod); |
| 907 | | GDC_LOG_CMD_3(" mask = %04X, transfer = %02X\n", dispregs->mask, |
| 908 | | command & 0x18 ); |
| 895 | LOG(("gdc_cmd_wdat: data = %04X, dc = %02X, mod = %x", |
| 896 | temp_reg, dispregs->figs_dc_param, dispregs->cur_mod)); |
| 897 | LOG((" mask = %04X, transfer = %02X\n", dispregs->mask, |
| 898 | command & 0x18 )); |
| 909 | 899 | |
| 910 | 900 | /* if ( gdc.registers.display.display_mode == 1 ) { */ |
| 911 | 901 | /* if ( temp_reg & 0x01 || temp_reg & 0x0100 ) { */ |
| r1470 | r1471 | |
| 978 | 968 | /* Calculate word address */ |
| 979 | 969 | dispregs->ead = saved_ead - |
| 980 | 970 | (dispregs->zoom_gchr*row+zy) * dispregs->words_per_line; |
| 981 | | GDC_LOG_CMD_2("gdc_cmd_gchrd: pram : %1x\n", gdc.pram[15-row]); |
| 971 | LOG(("gdc_cmd_gchrd: pram : %1x\n", gdc.pram[15-row])); |
| 982 | 972 | /* Reset pixel mask (x) */ |
| 983 | 973 | dispregs->mask = saved_mask; |
| 984 | 974 | for ( bitnbr = 0; bitnbr < 8; ++bitnbr ) { |
| r1470 | r1471 | |
| 994 | 984 | if ( dispregs->mask & 0x8000 ) { |
| 995 | 985 | dispregs->ead++; |
| 996 | 986 | } |
| 997 | | /* GDC_LOG_CMD_2("gdc_cmd_gchrd: mask before = %02X\n", dispregs->mask); */ |
| 987 | /* LOG(("gdc_cmd_gchrd: mask before = %02X\n", dispregs->mask)); */ |
| 998 | 988 | dispregs->mask = rotleft16(dispregs->mask); |
| 999 | | /* GDC_LOG_CMD_2("gdc_cmd_gchrd: mask now = %02X\n", dispregs->mask); */ |
| 1000 | | /* GDC_LOG_CMD_2("gdc_cmd_gchrd: ead now = %04X\n", dispregs->ead); */ |
| 989 | /* LOG(("gdc_cmd_gchrd: mask now = %02X\n", dispregs->mask)); */ |
| 990 | /* LOG(("gdc_cmd_gchrd: ead now = %04X\n", dispregs->ead)); */ |
| 1001 | 991 | } |
| 1002 | 992 | } |
| 1003 | 993 | } |
| r1470 | r1471 | |
| 1024 | 1014 | |
| 1025 | 1015 | case CMD_RESET: |
| 1026 | 1016 | /* Resets the GDC to its idle mode */ |
| 1027 | | GDC_LOG_CMD_1("gdc_command: RESET\n"); |
| 1017 | LOG(("gdc_command: RESET\n")); |
| 1028 | 1018 | gdc_cmd_sync(); |
| 1029 | 1019 | gdc_fifo_reset(&gdc); |
| 1030 | 1020 | break; |
| 1031 | 1021 | case CMD_SYNC_OFF: |
| 1032 | 1022 | /* Specifies the video format and disables the display */ |
| 1033 | | GDC_LOG_CMD_1("gdc_command: SYNC_OFF\n"); |
| 1023 | LOG(("gdc_command: SYNC_OFF\n")); |
| 1034 | 1024 | gdc_cmd_sync(); |
| 1035 | 1025 | break; |
| 1036 | 1026 | case CMD_SYNC_ON: |
| 1037 | 1027 | /* Specifies the video format and enables the display */ |
| 1038 | | GDC_LOG_CMD_1("gdc_command: SYNC_ON\n"); |
| 1028 | LOG(("gdc_command: SYNC_ON\n")); |
| 1039 | 1029 | gdc_cmd_sync(); |
| 1040 | 1030 | break; |
| 1041 | 1031 | |
| 1042 | 1032 | case CMD_VSYNC_SLAVE: /* Selects slave video synchronization mode */ |
| 1043 | | GDC_LOG_CMD_1("gdc_command: VSYNC_SLAVE\n"); |
| 1033 | LOG(("gdc_command: VSYNC_SLAVE\n")); |
| 1044 | 1034 | break; |
| 1045 | 1035 | |
| 1046 | 1036 | case CMD_VSYNC_MASTER: /* Selects master video synchronization mode */ |
| 1047 | | GDC_LOG_CMD_1("gdc_command: VSYNC_MASTER\n"); |
| 1037 | LOG(("gdc_command: VSYNC_MASTER\n")); |
| 1048 | 1038 | break; |
| 1049 | 1039 | |
| 1050 | 1040 | case CMD_CCHAR: /* Specifies the cursor and character row heights */ |
| 1051 | | GDC_LOG_CMD_1("gdc_command: CCHAR\n"); |
| 1041 | LOG(("gdc_command: CCHAR\n")); |
| 1052 | 1042 | gdc_cmd_cchar(); |
| 1053 | 1043 | break; |
| 1054 | 1044 | |
| 1055 | 1045 | /* Display control commands */ |
| 1056 | 1046 | case CMD_START: /* Ends idle mode and unblanks the display */ |
| 1057 | | GDC_LOG_CMD_1("gdc_command: START\n"); |
| 1047 | LOG(("gdc_command: START\n")); |
| 1058 | 1048 | gdc_cmd_start(); |
| 1059 | 1049 | break; |
| 1060 | 1050 | |
| 1061 | 1051 | case CMD_BCTRL_OFF: /* Controls the blanking and unblanking of the display */ |
| 1062 | | GDC_LOG_CMD_1("gdc_command: BCTRL_OFF\n"); |
| 1052 | LOG(("gdc_command: BCTRL_OFF\n")); |
| 1063 | 1053 | break; |
| 1064 | 1054 | |
| 1065 | 1055 | case CMD_BCTRL_ON: /* Controls the blanking and unblanking of the display */ |
| 1066 | | GDC_LOG_CMD_1("gdc_command: BCTRL_ON\n"); |
| 1056 | LOG(("gdc_command: BCTRL_ON\n")); |
| 1067 | 1057 | break; |
| 1068 | 1058 | |
| 1069 | 1059 | /* Specifies zoom factors for the display and graphics characters writing */ |
| 1070 | 1060 | case CMD_ZOOM: |
| 1071 | | GDC_LOG_CMD_1("gdc_command: ZOOM\n"); |
| 1061 | LOG(("gdc_command: ZOOM\n")); |
| 1072 | 1062 | gdc_cmd_zoom(); |
| 1073 | 1063 | break; |
| 1074 | 1064 | |
| 1075 | 1065 | |
| 1076 | 1066 | case CMD_CURS: |
| 1077 | 1067 | /* Sets the position of the cursor in display memory */ |
| 1078 | | GDC_LOG_CMD_1("gdc_command: CURS\n"); |
| 1068 | LOG(("gdc_command: CURS\n")); |
| 1079 | 1069 | gdc_cmd_curs(); |
| 1080 | 1070 | break; |
| 1081 | 1071 | |
| 1082 | 1072 | case CMD_PITCH: |
| 1083 | 1073 | /* Specifies the width of the X dimension of the display memory */ |
| 1084 | | GDC_LOG_CMD_1("gdc_command: PITCH\n"); |
| 1074 | LOG(("gdc_command: PITCH\n")); |
| 1085 | 1075 | gdc_cmd_pitch(); |
| 1086 | 1076 | break; |
| 1087 | 1077 | |
| 1088 | 1078 | /* Drawing control commands */ |
| 1089 | 1079 | |
| 1090 | 1080 | case CMD_MASK: /* Sets the MASK register contents */ |
| 1091 | | GDC_LOG_CMD_1("gdc_command: MASK\n"); |
| 1081 | LOG(("gdc_command: MASK\n")); |
| 1092 | 1082 | gdc_cmd_mask(); |
| 1093 | 1083 | break; |
| 1094 | 1084 | |
| 1095 | 1085 | case CMD_FIGS: /* Specifies the parameters for the drawing processor */ |
| 1096 | | GDC_LOG_CMD_1("gdc_command: FIGS\n"); |
| 1086 | LOG(("gdc_command: FIGS\n")); |
| 1097 | 1087 | gdc_cmd_figs(); |
| 1098 | 1088 | break; |
| 1099 | 1089 | |
| 1100 | 1090 | case CMD_FIGD: /* Draws the figure as specified above */ |
| 1101 | | GDC_LOG_CMD_1("gdc_command: FIGD\n"); |
| 1091 | LOG(("gdc_command: FIGD\n")); |
| 1102 | 1092 | break; |
| 1103 | 1093 | |
| 1104 | 1094 | case CMD_GCHRD: /* Draws the graphics character into display */ |
| 1105 | | GDC_LOG_CMD_1("gdc_command: GCHRD\n"); |
| 1095 | LOG(("gdc_command: GCHRD\n")); |
| 1106 | 1096 | gdc_cmd_gchrd(); |
| 1107 | 1097 | break; |
| 1108 | 1098 | |
| 1109 | 1099 | /* Memory data read commands */ |
| 1110 | 1100 | |
| 1111 | 1101 | case CMD_CURD: /* Reads the cursor position */ |
| 1112 | | GDC_LOG_CMD_1("gdc_command: CURD\n"); |
| 1102 | LOG(("gdc_command: CURD\n")); |
| 1113 | 1103 | break; |
| 1114 | 1104 | |
| 1115 | 1105 | case CMD_LPRD: /* Reads the light pen address */ |
| 1116 | | GDC_LOG_CMD_1("gdc_command: LPRD\n"); |
| 1106 | LOG(("gdc_command: LPRD\n")); |
| 1117 | 1107 | gdc_cmd_lprd(); |
| 1118 | 1108 | break; |
| 1119 | 1109 | |
| r1470 | r1471 | |
| 1122 | 1112 | /* Display control commands */ |
| 1123 | 1113 | if ((command & CMD_PRAM_BITMASK) == CMD_PRAM_BITMASK) |
| 1124 | 1114 | { |
| 1125 | | GDC_LOG_CMD_2("gdc_command: PRAM write at offset %01X\n", |
| 1126 | | command & ~((UINT8)CMD_PRAM_BITMASK)); |
| 1115 | LOG(("gdc_command: PRAM write at offset %01X\n", |
| 1116 | command & ~((UINT8)CMD_PRAM_BITMASK))); |
| 1127 | 1117 | gdc_cmd_pram(command & ~((UINT8)CMD_PRAM_BITMASK)); |
| 1128 | 1118 | break; |
| 1129 | 1119 | } |
| r1470 | r1471 | |
| 1135 | 1125 | |
| 1136 | 1126 | case CMD_WDAT_BITMASK: |
| 1137 | 1127 | /* Writes data words or bytes into display memory */ |
| 1138 | | GDC_LOG_CMD_1("gdc_command: WDAT\n"); |
| 1128 | LOG(("gdc_command: WDAT\n")); |
| 1139 | 1129 | gdc_cmd_wdat(command); |
| 1140 | 1130 | break; |
| 1141 | 1131 | |
| 1142 | 1132 | /* Memory data read commands */ |
| 1143 | 1133 | |
| 1144 | 1134 | case CMD_RDAT_BITMASK: /* Reads data words or bytes from display */ |
| 1145 | | GDC_LOG_CMD_1("gdc_command: RDAT\n"); |
| 1135 | LOG(("gdc_command: RDAT\n")); |
| 1146 | 1136 | gdc_cmd_rdat(command); |
| 1147 | 1137 | break; |
| 1148 | 1138 | |
| 1149 | 1139 | /* Data control commands */ |
| 1150 | 1140 | |
| 1151 | 1141 | case CMD_DMAR_BITMASK: /* Requests a DMA read transfer */ |
| 1152 | | GDC_LOG_CMD_1("gdc_command: DMAR\n"); |
| 1142 | LOG(("gdc_command: DMAR\n")); |
| 1153 | 1143 | break; |
| 1154 | 1144 | |
| 1155 | 1145 | case CMD_DMAW_BITMASK: /* Requests a DMA write transfer */ |
| 1156 | | GDC_LOG_CMD_1("gdc_command: DMAW\n"); |
| 1146 | LOG(("gdc_command: DMAW\n")); |
| 1157 | 1147 | break; |
| 1158 | 1148 | |
| 1159 | 1149 | default: |
| r1470 | r1471 | |
| 1167 | 1157 | /* Empty the fifo. It could be that we haven't read |
| 1168 | 1158 | everything correctly */ |
| 1169 | 1159 | if ( (!gdc_fifo_reading(&gdc)) && (! gdc_fifo_empty(&gdc)) ) { |
| 1170 | | GDC_LOG_CMD_1("GDC Fifo not empty after processing command!\n"); |
| 1160 | LOG(("GDC Fifo not empty after processing command!\n")); |
| 1171 | 1161 | while ( gdc_fifo_dequeue_param(&gdc) ) { |
| 1172 | 1162 | /**/ |
| 1173 | 1163 | } |
| r1470 | r1471 | |
| 1223 | 1213 | case CMD_DMAW_BITMASK: |
| 1224 | 1214 | return 0; |
| 1225 | 1215 | default: |
| 1226 | | GDC_LOG_CMD_2("gdc_nbr_expected_params: cannot find command %X\n", |
| 1227 | | command); |
| 1216 | LOG(("gdc_nbr_expected_params: cannot find command %X\n", |
| 1217 | command)); |
| 1228 | 1218 | return 16; |
| 1229 | 1219 | } |
| 1230 | 1220 | } |
| r1470 | r1471 | |
| 1253 | 1243 | if ( last_command >= 0 ) { |
| 1254 | 1244 | gdc_fifo_add_from_outside(&gdc, data, 0); |
| 1255 | 1245 | if ( gdc_fifo_get_nbr_params(&gdc) == nbr_expected_params ) { |
| 1256 | | GDC_LOG_CMD_1("GDC: Number of parameters reached\n"); |
| 1246 | LOG(("GDC: Number of parameters reached\n")); |
| 1257 | 1247 | gdc_command_processor(last_command); |
| 1258 | 1248 | last_command = -1; |
| 1259 | 1249 | } |
| 1260 | 1250 | } else { |
| 1261 | | GDC_LOG_CMD_1("GDC Got parameter without command\n"); |
| 1251 | LOG(("GDC Got parameter without command\n")); |
| 1262 | 1252 | } |
| 1263 | 1253 | |
| 1264 | 1254 | break; |
| r1470 | r1471 | |
| 1275 | 1265 | |
| 1276 | 1266 | /* Check if it is a command without parameters, if so process it now */ |
| 1277 | 1267 | if ( gdc_nbr_expected_params(data) == 0 ) { |
| 1278 | | GDC_LOG_CMD_1("GDC: Command takes zero parameters\n"); |
| 1268 | LOG(("GDC: Command takes zero parameters\n")); |
| 1279 | 1269 | gdc_command_processor(data); |
| 1280 | 1270 | last_command = -1; |
| 1281 | 1271 | } else { |
| r1470 | r1471 | |
| 1306 | 1296 | switch(offset & 0x07) { |
| 1307 | 1297 | case 0x00: /* Status register */ |
| 1308 | 1298 | |
| 1309 | | GDC_LOG_CMD_3("%04X: GDC Port %04X (Status) Read", |
| 1310 | | activecpu_get_pc(), offset); |
| 1299 | LOG(("%04X: GDC Port %04X (Status) Read", |
| 1300 | activecpu_get_pc(), offset)); |
| 1311 | 1301 | /* Optimize this later, i.e. when we know what to return */ |
| 1312 | 1302 | data = ( gdc_fifo_reading(&gdc) && !gdc_fifo_empty(&gdc)) | |
| 1313 | 1303 | (gdc_fifo_full(&gdc) << 1) | |
| r1470 | r1471 | |
| 1320 | 1310 | |
| 1321 | 1311 | case 0x01: /* FIFO Read */ |
| 1322 | 1312 | |
| 1323 | | GDC_LOG_CMD_3("%04X: GDC Port %04X (Fifo) Read", |
| 1313 | LOG(("%04X: GDC Port %04X (Fifo) Read", |
| 1324 | 1314 | activecpu_get_pc(), |
| 1325 | | offset); |
| 1315 | offset)); |
| 1326 | 1316 | if ( gdc_fifo_reading(&gdc)) { |
| 1327 | 1317 | UINT8* data_p = gdc_fifo_dequeue(&gdc); |
| 1328 | 1318 | if ( data_p ) { |
| r1470 | r1471 | |
| 1337 | 1327 | break; |
| 1338 | 1328 | |
| 1339 | 1329 | default: |
| 1340 | | GDC_LOG_CMD_3("%04X: GDC UNKNOWN Port Read %04X", |
| 1341 | | activecpu_get_pc(), offset); |
| 1330 | LOG(("%04X: GDC UNKNOWN Port Read %04X", |
| 1331 | activecpu_get_pc(), offset)); |
| 1342 | 1332 | data = 0x44; |
| 1343 | 1333 | if ( activecpu_get_pc() == 0xF952D ) { |
| 1344 | 1334 | data = 0x04; |
| r1470 | r1471 | |
| 1350 | 1340 | data = 0x00; |
| 1351 | 1341 | break; |
| 1352 | 1342 | } |
| 1353 | | GDC_LOG_CMD_2(" returns %1X\n", data); |
| 1343 | LOG((" returns %1X\n", data)); |
| 1354 | 1344 | return(data); |
| 1355 | 1345 | } |
| 1356 | 1346 | |
src/mess/machine/dgn_beta.c
| r1470 | r1471 | |
| 59 | 59 | #include <assert.h> |
| 60 | 60 | |
| 61 | 61 | #include "driver.h" |
| 62 | #include "debug/debugcon.h" |
| 62 | 63 | #include "cpu/m6809/m6809.h" |
| 63 | 64 | #include "machine/6821pia.h" |
| 64 | 65 | #include "includes/coco.h" |
| r1470 | r1471 | |
| 70 | 71 | |
| 71 | 72 | static UINT8 *system_rom; |
| 72 | 73 | |
| 73 | | /* Only log errors if debugging ! */ |
| 74 | | #ifdef MAME_DEBUG |
| 74 | #define VERBOSE 0 |
| 75 | 75 | |
| 76 | | //#define LOG_BANK_UPDATE 1 |
| 77 | | //#define LOG_DEFAULT_TASK 1 |
| 78 | | //#define LOG_PAGE_WRITE 1 |
| 79 | | //#define LOG_HALT 1 |
| 80 | | //#define LOG_TASK 1 |
| 81 | | //#define LOG_KEYBOARD 1 |
| 82 | | //#define LOG_VIDEO 1 |
| 83 | | #define LOG_DISK 0 |
| 84 | | //#define LOG_INTS 1 |
| 85 | | #endif |
| 86 | 76 | |
| 77 | #define LOG_BANK_UPDATE(x) do { if (VERBOSE) logerror x; } while (0) |
| 78 | #define LOG_DEFAULT_TASK(x) do { if (VERBOSE) logerror x; } while (0) |
| 79 | #define LOG_PAGE_WRITE(x) do { if (VERBOSE) logerror x; } while (0) |
| 80 | #define LOG_HALT(x) do { if (VERBOSE) logerror x; } while (0) |
| 81 | #define LOG_TASK(x) do { if (VERBOSE) logerror x; } while (0) |
| 82 | #define LOG_KEYBOARD(x) do { if (VERBOSE) logerror x; } while (0) |
| 83 | #define LOG_VIDEO(x) do { if (VERBOSE) logerror x; } while (0) |
| 84 | #define LOG_DISK(x) do { if (VERBOSE) logerror x; } while (0) |
| 85 | #define LOG_INTS(x) do { if (VERBOSE) logerror x; } while (0) |
| 86 | |
| 87 | |
| 88 | |
| 87 | 89 | #ifdef MAME_DEBUG |
| 88 | 90 | #include "debug/debugcpu.h" |
| 89 | 91 | #include "debug/debugcon.h" |
| r1470 | r1471 | |
| 240 | 242 | int bank_start; |
| 241 | 243 | int bank_end; |
| 242 | 244 | int MapPage; |
| 243 | | #ifdef LOG_BANK_UPDATE |
| 244 | | // logerror("\n\nUpdating banks %d to %d at PC=$%X\n",first,last,activecpu_get_pc()); |
| 245 | | #endif |
| 245 | |
| 246 | LOG_BANK_UPDATE(("\n\nUpdating banks %d to %d at PC=$%X\n",first,last,activecpu_get_pc())); |
| 246 | 247 | for(Page=first;Page<=last;Page++) |
| 247 | 248 | { |
| 248 | 249 | bank_start = bank_info[Page].start; |
| r1470 | r1471 | |
| 293 | 294 | memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, bank_start, bank_end,0,0,writebank); |
| 294 | 295 | memory_install_write8_handler(1, ADDRESS_SPACE_PROGRAM, bank_start, bank_end,0,0,writebank); |
| 295 | 296 | |
| 296 | | #ifdef LOG_BANK_UPDATE |
| 297 | | logerror("UpdateBanks:MapPage=$%02X readbank=$%X\n",MapPage,(int)readbank); |
| 298 | | logerror("PageRegsSet Task=%X Page=%x\n",TaskReg,Page); |
| 299 | | logerror("memory_set_bankptr(%X)\n",Page+1); |
| 300 | | logerror("memory_install_write8_handler CPU=0\n"); |
| 301 | | logerror("memory_install_write8_handler CPU=1\n"); |
| 302 | | #endif |
| 297 | LOG_BANK_UPDATE(("UpdateBanks:MapPage=$%02X readbank=$%X\n",MapPage,(int)readbank)); |
| 298 | LOG_BANK_UPDATE(("PageRegsSet Task=%X Page=%x\n",TaskReg,Page)); |
| 299 | LOG_BANK_UPDATE(("memory_set_bankptr(%X)\n",Page+1)); |
| 300 | LOG_BANK_UPDATE(("memory_install_write8_handler CPU=0\n")); |
| 301 | LOG_BANK_UPDATE(("memory_install_write8_handler CPU=1\n")); |
| 303 | 302 | } |
| 304 | 303 | } |
| 305 | 304 | |
| r1470 | r1471 | |
| 308 | 307 | { |
| 309 | 308 | int Idx; |
| 310 | 309 | |
| 311 | | #ifdef LOG_DEFAULT_TASK |
| 312 | | logerror("SetDefaultTask()\n"); |
| 313 | | debug_console_printf("Set Default task\n"); |
| 314 | | #endif |
| 310 | LOG_DEFAULT_TASK(("SetDefaultTask()\n")); |
| 311 | if (VERBOSE) debug_console_printf("Set Default task\n"); |
| 315 | 312 | |
| 316 | 313 | TaskReg=NoPagingTask; |
| 317 | 314 | |
| r1470 | r1471 | |
| 355 | 352 | { |
| 356 | 353 | PageRegs[PIATaskReg][offset].value=data; |
| 357 | 354 | |
| 358 | | #ifdef LOG_PAGE_WRITE |
| 359 | | logerror("PageRegWrite : task=$%X offset=$%X value=$%X\n",PIATaskReg,offset,data); |
| 360 | | #endif |
| 355 | LOG_PAGE_WRITE(("PageRegWrite : task=$%X offset=$%X value=$%X\n",PIATaskReg,offset,data)); |
| 361 | 356 | |
| 362 | 357 | if (EnableMapRegs) |
| 363 | 358 | { |
| r1470 | r1471 | |
| 550 | 545 | int Idx; |
| 551 | 546 | int Selected; |
| 552 | 547 | |
| 553 | | #ifdef LOG_KEYBOARD |
| 554 | | logerror("PB Read\n"); |
| 555 | | #endif |
| 548 | LOG_KEYBOARD(("PB Read\n")); |
| 556 | 549 | |
| 557 | 550 | KAny_next=0; |
| 558 | 551 | |
| r1470 | r1471 | |
| 594 | 587 | |
| 595 | 588 | RetVal = (KInDat_next<<5) | (KAny_next<<2); |
| 596 | 589 | |
| 597 | | #ifdef LOG_KEYBOARD |
| 598 | | logerror("FC22=$%02X KAny=%d\n",RetVal,KAny_next); |
| 599 | | #endif |
| 590 | LOG_KEYBOARD(("FC22=$%02X KAny=%d\n",RetVal,KAny_next)); |
| 600 | 591 | |
| 601 | 592 | return RetVal; |
| 602 | 593 | } |
| r1470 | r1471 | |
| 606 | 597 | int InClkState; |
| 607 | 598 | int OutClkState; |
| 608 | 599 | |
| 609 | | #ifdef LOG_KEYBOARD |
| 610 | | logerror("PB Write\n"); |
| 611 | | #endif |
| 600 | LOG_KEYBOARD(("PB Write\n")); |
| 612 | 601 | |
| 613 | 602 | InClkState = data & KInClk; |
| 614 | 603 | OutClkState = data & KOutClk; |
| 615 | 604 | |
| 616 | | #ifdef LOG_KEYBOARD |
| 617 | | logerror("InClkState=$%02X OldInClkState=$%02X Keyrow=$%02X ",InClkState,(d_pia0_pb_last & KInClk),Keyrow); |
| 618 | | #endif |
| 605 | LOG_KEYBOARD(("InClkState=$%02X OldInClkState=$%02X Keyrow=$%02X ",InClkState,(d_pia0_pb_last & KInClk),Keyrow)); |
| 619 | 606 | |
| 620 | 607 | /* Input clock bit has changed state */ |
| 621 | 608 | if ((InClkState) != (d_pia0_pb_last & KInClk)) |
| r1470 | r1471 | |
| 625 | 612 | { |
| 626 | 613 | KInDat_next=(~Keyrow & 0x40)>>6; |
| 627 | 614 | Keyrow = ((Keyrow<<1) | 0x01) & 0x7F ; |
| 628 | | #ifdef LOG_KEYBOARD |
| 629 | | logerror("Keyrow=$%02X KInDat_next=%X\n",Keyrow,KInDat_next); |
| 630 | | #endif |
| 615 | LOG_KEYBOARD(("Keyrow=$%02X KInDat_next=%X\n",Keyrow,KInDat_next)); |
| 631 | 616 | } |
| 632 | 617 | } |
| 633 | 618 | |
| r1470 | r1471 | |
| 637 | 622 | static WRITE8_HANDLER(d_pia0_cb2_w) |
| 638 | 623 | { |
| 639 | 624 | int RowNo; |
| 640 | | #ifdef LOG_KEYBOARD |
| 641 | | logerror("\nCB2 Write\n"); |
| 642 | | #endif |
| 625 | LOG_KEYBOARD(("\nCB2 Write\n")); |
| 626 | |
| 643 | 627 | /* load keyrow on rising edge of CB2 */ |
| 644 | 628 | if((data==1) && (d_pia0_cb2_last==0)) |
| 645 | 629 | { |
| r1470 | r1471 | |
| 650 | 634 | /* In the beta the shift registers are a cmos 4015, and a cmos 4013 in series */ |
| 651 | 635 | RowShifter = (RowShifter<<1) | ((d_pia0_pb_last & KOutDat)>>4); |
| 652 | 636 | RowShifter &= 0x3FF; |
| 653 | | #ifdef LOG_KEYBOARD |
| 654 | | logerror("Rowshifter=$%02X Keyrow=$%02X\n",RowShifter,Keyrow); |
| 655 | | debug_console_printf("rowshifter clocked, value=%3X, RowNo=%d, Keyrow=%2X\n",RowShifter,RowNo,Keyrow); |
| 656 | | #endif |
| 637 | LOG_KEYBOARD(("Rowshifter=$%02X Keyrow=$%02X\n",RowShifter,Keyrow)); |
| 638 | if (VERBOSE) debug_console_printf("rowshifter clocked, value=%3X, RowNo=%d, Keyrow=%2X\n",RowShifter,RowNo,Keyrow); |
| 657 | 639 | } |
| 658 | 640 | |
| 659 | 641 | d_pia0_cb2_last=data; |
| r1470 | r1471 | |
| 698 | 680 | else |
| 699 | 681 | HALT_DMA=CLEAR_LINE; |
| 700 | 682 | |
| 701 | | #ifdef LOG_HALT |
| 702 | | logerror("DMA_CPU HALT=%d\n",HALT_DMA); |
| 703 | | #endif |
| 683 | LOG_HALT(("DMA_CPU HALT=%d\n",HALT_DMA)); |
| 704 | 684 | cpunum_set_input_line(1, INPUT_LINE_HALT, HALT_DMA); |
| 705 | 685 | |
| 706 | 686 | /* CPU un-halted let it run ! */ |
| r1470 | r1471 | |
| 717 | 697 | if (data & DDenCtrl) |
| 718 | 698 | { |
| 719 | 699 | wd17xx_set_density(DEN_FM_LO); |
| 720 | | #ifdef MAME_DEBUG |
| 721 | | if (LOG_DISK) |
| 722 | | logerror("Set density low %d\n",(data & DDenCtrl)); |
| 723 | | #endif |
| 700 | LOG_DISK(("Set density low %d\n",(data & DDenCtrl))); |
| 724 | 701 | } |
| 725 | 702 | else |
| 726 | 703 | { |
| 727 | 704 | wd17xx_set_density(DEN_MFM_LO); |
| 728 | | #ifdef MAME_DEBUG |
| 729 | | if (LOG_DISK) |
| 730 | | logerror("Set density high %d\n",(data & DDenCtrl)); |
| 731 | | #endif |
| 705 | LOG_DISK(("Set density high %d\n",(data & DDenCtrl))); |
| 732 | 706 | } |
| 733 | 707 | } |
| 734 | 708 | |
| r1470 | r1471 | |
| 749 | 723 | HALT_CPU=CLEAR_LINE; |
| 750 | 724 | else |
| 751 | 725 | HALT_CPU=ASSERT_LINE; |
| 752 | | #ifdef LOG_HALT |
| 753 | | logerror("MAIN_CPU HALT=%d\n",HALT_CPU); |
| 754 | | #endif |
| 726 | LOG_HALT(("MAIN_CPU HALT=%d\n",HALT_CPU)); |
| 755 | 727 | cpunum_set_input_line(0, INPUT_LINE_HALT, HALT_CPU); |
| 756 | 728 | |
| 757 | 729 | d_pia1_pb_last=data & 0x02; |
| r1470 | r1471 | |
| 792 | 764 | int OldEnableMap; |
| 793 | 765 | int NMI; |
| 794 | 766 | |
| 795 | | #ifdef LOG_TASK |
| 796 | | logerror("FCC0 write : $%02X\n",data); |
| 797 | | #endif |
| 767 | LOG_TASK(("FCC0 write : $%02X\n",data)); |
| 798 | 768 | |
| 799 | 769 | /* Bit 7 of $FFC0, seems to control NMI on second CPU */ |
| 800 | 770 | NMI=(data & 0x80); |
| r1470 | r1471 | |
| 802 | 772 | /* only take action if NMI changed */ |
| 803 | 773 | if(NMI!=DMA_NMI_LAST) |
| 804 | 774 | { |
| 805 | | #ifdef LOG_INTS |
| 806 | | logerror("cpu1 NMI : %d\n",NMI); |
| 807 | | // debug_console_printf("cpu1 NMI : %d\n",NMI); |
| 808 | | #endif |
| 775 | LOG_INTS(("cpu1 NMI : %d\n",NMI)); |
| 809 | 776 | if(!NMI) |
| 810 | 777 | { |
| 811 | 778 | cpunum_set_input_line(1,INPUT_LINE_NMI,ASSERT_LINE); |
| r1470 | r1471 | |
| 831 | 798 | OldTask=PIATaskReg; |
| 832 | 799 | PIATaskReg=data & 0x0F; |
| 833 | 800 | |
| 834 | | #ifdef LOG_TASK |
| 835 | | logerror("OldTask=$%02X EnableMapRegs=%d OldEnableMap=%d\n",OldTask,EnableMapRegs,OldEnableMap); |
| 836 | | #endif |
| 801 | LOG_TASK(("OldTask=$%02X EnableMapRegs=%d OldEnableMap=%d\n",OldTask,EnableMapRegs,OldEnableMap)); |
| 837 | 802 | |
| 838 | 803 | // Maping was enabled or disabled, select apropreate task reg |
| 839 | 804 | // and map it in |
| r1470 | r1471 | |
| 858 | 823 | UpdateBanks(0,IOPage+1); |
| 859 | 824 | } |
| 860 | 825 | } |
| 861 | | #ifdef LOG_TASK |
| 862 | | logerror("TaskReg=$%02X PIATaskReg=$%02X\n",TaskReg,PIATaskReg); |
| 863 | | #endif |
| 826 | LOG_TASK(("TaskReg=$%02X PIATaskReg=$%02X\n",TaskReg,PIATaskReg)); |
| 864 | 827 | } |
| 865 | 828 | |
| 866 | 829 | static READ8_HANDLER(d_pia2_pb_r) |
| r1470 | r1471 | |
| 903 | 866 | IRQ = CLEAR_LINE; |
| 904 | 867 | |
| 905 | 868 | cpunum_set_input_line(0, M6809_IRQ_LINE, IRQ); |
| 906 | | #ifdef LOG_INTS |
| 907 | | logerror("cpu0 IRQ : %d\n",IRQ); |
| 908 | | #endif |
| 869 | LOG_INTS(("cpu0 IRQ : %d\n",IRQ)); |
| 909 | 870 | } |
| 910 | 871 | |
| 911 | 872 | static void cpu0_recalc_firq(int state) |
| r1470 | r1471 | |
| 920 | 881 | |
| 921 | 882 | cpunum_set_input_line(0, M6809_FIRQ_LINE, FIRQ); |
| 922 | 883 | |
| 923 | | #ifdef LOG_INTS |
| 924 | | logerror("cpu0 FIRQ : %d\n",FIRQ); |
| 925 | | #endif |
| 884 | LOG_INTS(("cpu0 FIRQ : %d\n",FIRQ)); |
| 926 | 885 | } |
| 927 | 886 | |
| 928 | 887 | /* CPU 1 */ |
| r1470 | r1471 | |
| 930 | 889 | static void cpu1_recalc_firq(int state) |
| 931 | 890 | { |
| 932 | 891 | cpunum_set_input_line(1, M6809_FIRQ_LINE, state); |
| 933 | | #ifdef LOG_INTS |
| 934 | | logerror("cpu1 FIRQ : %d\n",state); |
| 935 | | #endif |
| 892 | LOG_INTS(("cpu1 FIRQ : %d\n",state)); |
| 936 | 893 | } |
| 937 | 894 | |
| 938 | 895 | /********************************************************************************************/ |
| r1470 | r1471 | |
| 962 | 919 | break; |
| 963 | 920 | } |
| 964 | 921 | |
| 965 | | #ifdef MAME_DEBUG |
| 966 | | if (LOG_DISK) |
| 967 | | logerror("dgnbeta_fdc_callback(%d)\n",event); |
| 968 | | #endif |
| 922 | LOG_DISK(("dgnbeta_fdc_callback(%d)\n",event)); |
| 969 | 923 | } |
| 970 | 924 | |
| 971 | 925 | READ8_HANDLER(dgnbeta_wd2797_r) |
| r1470 | r1471 | |
| 976 | 930 | { |
| 977 | 931 | case 0: |
| 978 | 932 | result = wd17xx_status_r(0); |
| 979 | | #ifdef MAME_DEBUG |
| 980 | | if (LOG_DISK) |
| 981 | | logerror("Disk status=%2.2X\n",result); |
| 982 | | #endif |
| 933 | LOG_DISK(("Disk status=%2.2X\n",result)); |
| 983 | 934 | break; |
| 984 | 935 | case 1: |
| 985 | 936 | result = wd17xx_track_r(0); |
| r1470 | r1471 | |
| 1029 | 980 | int Idx; |
| 1030 | 981 | int Row; |
| 1031 | 982 | |
| 1032 | | #ifdef LOG_KEYBOARD |
| 1033 | | logerror("Scanning Host keyboard\n"); |
| 1034 | | #endif |
| 983 | LOG_KEYBOARD(("Scanning Host keyboard\n")); |
| 1035 | 984 | |
| 1036 | 985 | for(Idx=0;Idx<NoKeyrows;Idx++) |
| 1037 | 986 | { |
| r1470 | r1471 | |
| 1050 | 999 | default : Row=0x7F; break; |
| 1051 | 1000 | } |
| 1052 | 1001 | Keyboard[Idx]=Row; |
| 1053 | | #ifdef LOG_KEYBOARD |
| 1054 | | logerror("Keyboard[%d]=$%02X\n",Idx,Row); |
| 1002 | LOG_KEYBOARD(("Keyboard[%d]=$%02X\n",Idx,Row)); |
| 1055 | 1003 | if (Row!=0x7F) |
| 1056 | 1004 | { |
| 1057 | | logerror("Found Pressed Key\n"); |
| 1005 | LOG_KEYBOARD(("Found Pressed Key\n")); |
| 1058 | 1006 | } |
| 1059 | | #endif |
| 1060 | 1007 | } |
| 1061 | 1008 | #endif |
| 1062 | 1009 | } |
| r1470 | r1471 | |
| 1073 | 1020 | { |
| 1074 | 1021 | pia_2_cb2_w(0,CLEAR_LINE); |
| 1075 | 1022 | } |
| 1076 | | #ifdef LOG_VIDEO |
| 1077 | | logerror("Vblank\n"); |
| 1078 | | #endif |
| 1023 | LOG_VIDEO(("Vblank\n")); |
| 1079 | 1024 | ScanInKeyboard(); |
| 1080 | 1025 | } |
| 1081 | 1026 | |
src/mess/machine/at45dbxx.c
| r1470 | r1471 | |
| 13 | 13 | #include "at45dbxx.h" |
| 14 | 14 | |
| 15 | 15 | #define LOG_LEVEL 1 |
| 16 | | #define _logerror(level,...) if (LOG_LEVEL > level) logerror(__VA_ARGS__) |
| 16 | #define _logerror(level,x) if (LOG_LEVEL > level) logerror x |
| 17 | 17 | |
| 18 | 18 | #define FLASH_CMD_52 0x52 |
| 19 | 19 | #define FLASH_CMD_57 0x57 |
| r1470 | r1471 | |
| 64 | 64 | |
| 65 | 65 | void at45dbxx_init( int type) |
| 66 | 66 | { |
| 67 | | _logerror( 0, "at45dbxx_init (%d)\n", type); |
| 67 | _logerror( 0, ("at45dbxx_init (%d)\n", type)); |
| 68 | 68 | memset( &flash, 0, sizeof( flash)); |
| 69 | 69 | switch (type) |
| 70 | 70 | { |
| r1470 | r1471 | |
| 81 | 81 | |
| 82 | 82 | void at45dbxx_exit( void) |
| 83 | 83 | { |
| 84 | | _logerror( 0, "at45dbxx_exit\n"); |
| 84 | _logerror( 0, ("at45dbxx_exit\n")); |
| 85 | 85 | free( flash.buffer2); |
| 86 | 86 | free( flash.buffer1); |
| 87 | 87 | free( flash.data); |
| r1470 | r1471 | |
| 89 | 89 | |
| 90 | 90 | void at45dbxx_reset( void) |
| 91 | 91 | { |
| 92 | | _logerror( 1, "at45dbxx_reset\n"); |
| 92 | _logerror( 1, ("at45dbxx_reset\n")); |
| 93 | 93 | // mode |
| 94 | 94 | flash.mode = FLASH_MODE_SI; |
| 95 | 95 | // command |
| r1470 | r1471 | |
| 137 | 137 | if ((flash.mode != FLASH_MODE_SO) || (!flash.io.data)) return 0; |
| 138 | 138 | // read byte |
| 139 | 139 | data = flash.io.data[flash.io.pos++]; |
| 140 | | _logerror( 2, "at45dbxx_read_byte (%02X) (%03d/%03d)\n", data, flash.io.pos, flash.io.size); |
| 140 | _logerror( 2, ("at45dbxx_read_byte (%02X) (%03d/%03d)\n", data, flash.io.pos, flash.io.size)); |
| 141 | 141 | if (flash.io.pos == flash.io.size) flash.io.pos = 0; |
| 142 | 142 | return data; |
| 143 | 143 | } |
| r1470 | r1471 | |
| 179 | 179 | if (flash.cmd.size < 8) |
| 180 | 180 | { |
| 181 | 181 | UINT8 opcode; |
| 182 | | _logerror( 2, "at45dbxx_write_byte (%02X)\n", data); |
| 182 | _logerror( 2, ("at45dbxx_write_byte (%02X)\n", data)); |
| 183 | 183 | // add to command buffer |
| 184 | 184 | flash.cmd.data[flash.cmd.size++] = data; |
| 185 | 185 | // check opcode |
| r1470 | r1471 | |
| 192 | 192 | // 8 bits command |
| 193 | 193 | if (flash.cmd.size == 1) |
| 194 | 194 | { |
| 195 | | _logerror( 1, "at45dbxx opcode %02X - status register read\n", opcode); |
| 195 | _logerror( 1, ("at45dbxx opcode %02X - status register read\n", opcode)); |
| 196 | 196 | flash.status = (flash.status & 0xC7) | flash.devid; // 80 = busy / 40 = compare fail |
| 197 | 197 | flash_set_io( &flash.status, 1, 0); |
| 198 | 198 | flash.mode = FLASH_MODE_SO; |
| r1470 | r1471 | |
| 209 | 209 | UINT32 page; |
| 210 | 210 | UINT8 comp; |
| 211 | 211 | page = flash_get_page_addr(); |
| 212 | | _logerror( 1, "at45dbxx opcode %02X - main memory page to buffer 1 compare [%04X]\n", opcode, page); |
| 212 | _logerror( 1, ("at45dbxx opcode %02X - main memory page to buffer 1 compare [%04X]\n", opcode, page)); |
| 213 | 213 | comp = memcmp( flash.data + page * flash.page_size, flash.buffer1, flash.page_size) == 0 ? 0 : 1; |
| 214 | 214 | if (comp) flash.status |= 0x40; else flash.status &= ~0x40; |
| 215 | | _logerror( 1, "at45dbxx page compare %s\n", comp ? "failure" : "success"); |
| 215 | _logerror( 1, ("at45dbxx page compare %s\n", comp ? "failure" : "success")); |
| 216 | 216 | flash.mode = FLASH_MODE_SI; |
| 217 | 217 | flash.cmd.size = 8; |
| 218 | 218 | } |
| r1470 | r1471 | |
| 227 | 227 | UINT32 page, byte; |
| 228 | 228 | page = flash_get_page_addr(); |
| 229 | 229 | byte = flash_get_byte_addr(); |
| 230 | | _logerror( 1, "at45dbxx opcode %02X - main memory page read [%04X/%04X]\n", opcode, page, byte); |
| 230 | _logerror( 1, ("at45dbxx opcode %02X - main memory page read [%04X/%04X]\n", opcode, page, byte)); |
| 231 | 231 | flash_set_io( flash.data + page * flash.page_size, flash.page_size, byte); |
| 232 | 232 | flash.mode = FLASH_MODE_SO; |
| 233 | 233 | flash.cmd.size = 8; |
| r1470 | r1471 | |
| 243 | 243 | UINT32 page, byte; |
| 244 | 244 | page = flash_get_page_addr(); |
| 245 | 245 | byte = flash_get_byte_addr(); |
| 246 | | _logerror( 1, "at45dbxx opcode %02X - main memory page program through buffer 1 [%04X/%04X]\n",opcode, page, byte); |
| 246 | _logerror( 1, ("at45dbxx opcode %02X - main memory page program through buffer 1 [%04X/%04X]\n",opcode, page, byte)); |
| 247 | 247 | flash_set_io( flash.buffer1, flash.page_size, byte); |
| 248 | 248 | memset( flash.buffer1, 0xFF, flash.page_size); |
| 249 | 249 | flash.mode = FLASH_MODE_SI; |
| r1470 | r1471 | |
| 254 | 254 | // other |
| 255 | 255 | default : |
| 256 | 256 | { |
| 257 | | _logerror( 1, "at45dbxx opcode %02X - unknown\n", opcode); |
| 257 | _logerror( 1, ("at45dbxx opcode %02X - unknown\n", opcode)); |
| 258 | 258 | flash.cmd.data[0] = 0; |
| 259 | 259 | flash.cmd.size = 0; |
| 260 | 260 | } |
| r1470 | r1471 | |
| 263 | 263 | } |
| 264 | 264 | else |
| 265 | 265 | { |
| 266 | | _logerror( 2, "at45dbxx_write_byte (%02X) (%03d/%03d)\n", data, flash.io.pos + 1, flash.io.size); |
| 266 | _logerror( 2, ("at45dbxx_write_byte (%02X) (%03d/%03d)\n", data, flash.io.pos + 1, flash.io.size)); |
| 267 | 267 | // store byte |
| 268 | 268 | flash.io.data[flash.io.pos] = data; |
| 269 | 269 | flash.io.pos++; |
| r1470 | r1471 | |
| 296 | 296 | UINT32 page, byte; |
| 297 | 297 | page = flash_get_page_addr(); |
| 298 | 298 | byte = flash_get_byte_addr(); |
| 299 | | _logerror( 1, "at45dbxx - program data stored in buffer 1 into selected page in main memory [%04X/%04X]\n", page, byte); |
| 299 | _logerror( 1, ("at45dbxx - program data stored in buffer 1 into selected page in main memory [%04X/%04X]\n", page, byte)); |
| 300 | 300 | memcpy( flash.data + page * flash.page_size, flash.buffer1, flash.page_size); |
| 301 | 301 | } |
| 302 | 302 | // reset |
| r1470 | r1471 | |
| 338 | 338 | |
| 339 | 339 | void at45dbxx_load( mame_file *file) |
| 340 | 340 | { |
| 341 | | _logerror( 0, "at45dbxx_load (%p)\n", file); |
| 341 | _logerror( 0, ("at45dbxx_load (%p)\n", file)); |
| 342 | 342 | mame_fread( file, flash.data, flash.size); |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | void at45dbxx_save( mame_file *file) |
| 346 | 346 | { |
| 347 | | _logerror( 0, "at45dbxx_save (%p)\n", file); |
| 347 | _logerror( 0, ("at45dbxx_save (%p)\n", file)); |
| 348 | 348 | mame_fwrite( file, flash.data, flash.size); |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | /* |
| 352 | 352 | NVRAM_HANDLER( at45dbxx ) |
| 353 | 353 | { |
| 354 | | _logerror( 0, "nvram_handler_at45dbxx (%p/%d)\n", file, read_or_write); |
| 354 | _logerror( 0, ("nvram_handler_at45dbxx (%p/%d)\n", file, read_or_write)); |
| 355 | 355 | if (read_or_write) |
| 356 | 356 | { |
| 357 | 357 | at45dbxx_save( file); |
src/mess/machine/i8271.c
| r1470 | r1471 | |
| 35 | 35 | |
| 36 | 36 | static char temp_buffer[16384]; |
| 37 | 37 | |
| 38 | | // uncomment to give verbose debug information |
| 39 | | //#define VERBOSE |
| 40 | | |
| 41 | 38 | static I8271 i8271; |
| 42 | 39 | |
| 43 | | #ifdef VERBOSE |
| 44 | | #define FDC_LOG(x) logerror("I8271: %s\n",x) |
| 45 | | #define FDC_LOG_COMMAND(x) logerror("I8271: COMMAND %s\n",x) |
| 46 | | #else |
| 47 | | #define FDC_LOG(x) |
| 48 | | #define FDC_LOG_COMMAND(x) |
| 49 | | #endif |
| 40 | #define VERBOSE 0 |
| 50 | 41 | |
| 42 | #define LOG(x) do { if (VERBOSE) logerror x; } while (0) |
| 43 | #define FDC_LOG(x) do { if (VERBOSE) logerror("I8271: %s\n",x); } while (0) |
| 44 | #define FDC_LOG_COMMAND(x) do { if (VERBOSE) logerror("I8271: COMMAND %s\n",x); } while (0) |
| 45 | |
| 51 | 46 | static mess_image *current_image(void) |
| 52 | 47 | { |
| 53 | 48 | return image_from_devtype_and_index(IO_FLOPPY, i8271.drive); |
| r1470 | r1471 | |
| 510 | 505 | i8271_timed_data_request(); |
| 511 | 506 | return; |
| 512 | 507 | } |
| 513 | | #ifdef VERBOSE |
| 514 | | logerror("error getting sector data\n"); |
| 515 | | #endif |
| 508 | LOG(("error getting sector data\n")); |
| 516 | 509 | |
| 517 | 510 | i8271_timed_command_complete(); |
| 518 | 511 | } |
| r1470 | r1471 | |
| 545 | 538 | i8271_timed_data_request(); |
| 546 | 539 | return; |
| 547 | 540 | } |
| 548 | | #ifdef VERBOSE |
| 549 | | logerror("error getting sector data\n"); |
| 550 | | #endif |
| 541 | LOG(("error getting sector data\n")); |
| 551 | 542 | |
| 552 | 543 | i8271_timed_command_complete(); |
| 553 | 544 | } |
| r1470 | r1471 | |
| 625 | 616 | { |
| 626 | 617 | case 0x0d: |
| 627 | 618 | { |
| 628 | | #ifdef VERBOSE |
| 629 | | logerror("Initialization\n"); |
| 630 | | #endif |
| 619 | LOG(("Initialization\n")); |
| 631 | 620 | i8271.StepRate = i8271.CommandParameters[1]; |
| 632 | 621 | i8271.HeadSettlingTime = i8271.CommandParameters[2]; |
| 633 | 622 | i8271.IndexCountBeforeHeadUnload = (i8271.CommandParameters[3]>>4) & 0x0f; |
| r1470 | r1471 | |
| 637 | 626 | |
| 638 | 627 | case 0x010: |
| 639 | 628 | { |
| 640 | | #ifdef VERBOSE |
| 641 | | logerror("Load bad Tracks Surface 0\n"); |
| 642 | | #endif |
| 629 | LOG(("Load bad Tracks Surface 0\n")); |
| 643 | 630 | i8271_load_bad_tracks(0); |
| 644 | 631 | |
| 645 | 632 | } |
| r1470 | r1471 | |
| 647 | 634 | |
| 648 | 635 | case 0x018: |
| 649 | 636 | { |
| 650 | | #ifdef VERBOSE |
| 651 | | logerror("Load bad Tracks Surface 1\n"); |
| 652 | | #endif |
| 637 | LOG(("Load bad Tracks Surface 1\n")); |
| 653 | 638 | i8271_load_bad_tracks(1); |
| 654 | 639 | |
| 655 | 640 | } |
| r1470 | r1471 | |
| 782 | 767 | /* TODO: Check bits 6-7 and 5-2 are valid */ |
| 783 | 768 | i8271.Mode = i8271.CommandParameters[1]; |
| 784 | 769 | |
| 785 | | #ifdef VERBOSE |
| 786 | 770 | if (i8271.Mode & 0x01) |
| 787 | 771 | { |
| 788 | | logerror("Mode: Non-DMA\n"); |
| 772 | LOG(("Mode: Non-DMA\n")); |
| 789 | 773 | } |
| 790 | 774 | else |
| 791 | 775 | { |
| 792 | | logerror("Mode: DMA\n"); |
| 776 | LOG(("Mode: DMA\n")); |
| 793 | 777 | } |
| 794 | 778 | |
| 795 | 779 | if (i8271.Mode & 0x02) |
| 796 | 780 | { |
| 797 | | logerror("Single actuator\n"); |
| 781 | LOG(("Single actuator\n")); |
| 798 | 782 | } |
| 799 | 783 | else |
| 800 | 784 | { |
| 801 | | logerror("Double actuator\n"); |
| 785 | LOG(("Double actuator\n")); |
| 802 | 786 | } |
| 803 | | #endif |
| 804 | 787 | } |
| 805 | 788 | break; |
| 806 | 789 | |
| 807 | 790 | case I8271_SPECIAL_REGISTER_SURFACE_0_CURRENT_TRACK: |
| 808 | 791 | { |
| 809 | | #ifdef VERBOSE |
| 810 | | logerror("Surface 0 Current Track\n"); |
| 811 | | #endif |
| 792 | LOG(("Surface 0 Current Track\n")); |
| 812 | 793 | i8271_write_current_track(0, i8271.CommandParameters[1]); |
| 813 | 794 | } |
| 814 | 795 | break; |
| 815 | 796 | |
| 816 | 797 | case I8271_SPECIAL_REGISTER_SURFACE_1_CURRENT_TRACK: |
| 817 | 798 | { |
| 818 | | #ifdef VERBOSE |
| 819 | | logerror("Surface 1 Current Track\n"); |
| 820 | | #endif |
| 799 | LOG(("Surface 1 Current Track\n")); |
| 821 | 800 | i8271_write_current_track(1, i8271.CommandParameters[1]); |
| 822 | 801 | } |
| 823 | 802 | break; |
| 824 | 803 | |
| 825 | 804 | case I8271_SPECIAL_REGISTER_SURFACE_0_BAD_TRACK_1: |
| 826 | 805 | { |
| 827 | | #ifdef VERBOSE |
| 828 | | logerror("Surface 0 Bad Track 1\n"); |
| 829 | | #endif |
| 806 | LOG(("Surface 0 Bad Track 1\n")); |
| 830 | 807 | i8271_write_bad_track(0, 1, i8271.CommandParameters[1]); |
| 831 | 808 | } |
| 832 | 809 | break; |
| 833 | 810 | |
| 834 | 811 | case I8271_SPECIAL_REGISTER_SURFACE_0_BAD_TRACK_2: |
| 835 | 812 | { |
| 836 | | #ifdef VERBOSE |
| 837 | | logerror("Surface 0 Bad Track 2\n"); |
| 838 | | #endif |
| 839 | | i8271_write_bad_track(0, 2,i8271.CommandParameters[1]); |
| 813 | LOG(("Surface 0 Bad Track 2\n")); |
| 814 | i8271_write_bad_track(0, 2,i8271.CommandParameters[1]); |
| 840 | 815 | } |
| 841 | 816 | break; |
| 842 | 817 | |
| 843 | 818 | case I8271_SPECIAL_REGISTER_SURFACE_1_BAD_TRACK_1: |
| 844 | 819 | { |
| 845 | | #ifdef VERBOSE |
| 846 | | logerror("Surface 1 Bad Track 1\n"); |
| 847 | | #endif |
| 820 | LOG(("Surface 1 Bad Track 1\n")); |
| 848 | 821 | |
| 849 | 822 | |
| 850 | 823 | i8271_write_bad_track(1, 1, i8271.CommandParameters[1]); |
| r1470 | r1471 | |
| 853 | 826 | |
| 854 | 827 | case I8271_SPECIAL_REGISTER_SURFACE_1_BAD_TRACK_2: |
| 855 | 828 | { |
| 856 | | #ifdef VERBOSE |
| 857 | | logerror("Surface 1 Bad Track 2\n"); |
| 858 | | #endif |
| 829 | LOG(("Surface 1 Bad Track 2\n")); |
| 859 | 830 | |
| 860 | 831 | i8271_write_bad_track(1, 2, i8271.CommandParameters[1]); |
| 861 | 832 | } |
| r1470 | r1471 | |
| 869 | 840 | FDC_LOG_COMMAND("Write Drive Control Output port\n"); |
| 870 | 841 | |
| 871 | 842 | |
| 872 | | #ifdef VERBOSE |
| 873 | 843 | if (i8271.CommandParameters[1] & 0x01) |
| 874 | 844 | { |
| 875 | | logerror("Write Enable\n"); |
| 845 | LOG(("Write Enable\n")); |
| 876 | 846 | } |
| 877 | 847 | if (i8271.CommandParameters[1] & 0x02) |
| 878 | 848 | { |
| 879 | | logerror("Seek/Step\n"); |
| 849 | LOG(("Seek/Step\n")); |
| 880 | 850 | } |
| 881 | 851 | if (i8271.CommandParameters[1] & 0x04) |
| 882 | 852 | { |
| 883 | | logerror("Direction\n"); |
| 853 | LOG(("Direction\n")); |
| 884 | 854 | } |
| 885 | 855 | if (i8271.CommandParameters[1] & 0x08) |
| 886 | 856 | { |
| 887 | | logerror("Load Head\n"); |
| 857 | LOG(("Load Head\n")); |
| 888 | 858 | } |
| 889 | 859 | if (i8271.CommandParameters[1] & 0x010) |
| 890 | 860 | { |
| 891 | | logerror("Low head current\n"); |
| 861 | LOG(("Low head current\n")); |
| 892 | 862 | } |
| 893 | 863 | if (i8271.CommandParameters[1] & 0x020) |
| 894 | 864 | { |
| 895 | | logerror("Write Fault Reset\n"); |
| 865 | LOG(("Write Fault Reset\n")); |
| 896 | 866 | } |
| 897 | 867 | |
| 898 | | logerror("Select %02x\n", (i8271.CommandParameters[1] & 0x0c0)>>6); |
| 899 | | #endif |
| 868 | LOG(("Select %02x\n", (i8271.CommandParameters[1] & 0x0c0)>>6)); |
| 869 | |
| 900 | 870 | /* get drive */ |
| 901 | 871 | i8271_get_drive(); |
| 902 | 872 | |
| r1470 | r1471 | |
| 1019 | 989 | |
| 1020 | 990 | FDC_LOG_COMMAND("READ DATA MULTI RECORD"); |
| 1021 | 991 | |
| 1022 | | #ifdef VERBOSE |
| 1023 | | logerror("Sector Count: %02x\n", i8271.Counter); |
| 1024 | | logerror("Track: %02x\n",i8271.CommandParameters[0]); |
| 1025 | | logerror("Sector: %02x\n", i8271.CommandParameters[1]); |
| 1026 | | logerror("Sector Length: %02x bytes\n", 1<<(i8271.ID_N+7)); |
| 1027 | | #endif |
| 992 | LOG(("Sector Count: %02x\n", i8271.Counter)); |
| 993 | LOG(("Track: %02x\n",i8271.CommandParameters[0])); |
| 994 | LOG(("Sector: %02x\n", i8271.CommandParameters[1])); |
| 995 | LOG(("Sector Length: %02x bytes\n", 1<<(i8271.ID_N+7))); |
| 1028 | 996 | |
| 1029 | 997 | i8271_get_drive(); |
| 1030 | 998 | |
| r1470 | r1471 | |
| 1054 | 1022 | i8271.Counter = 1; |
| 1055 | 1023 | i8271.ID_R = i8271.CommandParameters[1]; |
| 1056 | 1024 | |
| 1057 | | #ifdef VERBOSE |
| 1058 | | logerror("Sector Count: %02x\n", i8271.Counter); |
| 1059 | | logerror("Track: %02x\n",i8271.CommandParameters[0]); |
| 1060 | | logerror("Sector: %02x\n", i8271.CommandParameters[1]); |
| 1061 | | logerror("Sector Length: %02x bytes\n", 1<<(i8271.ID_N+7)); |
| 1062 | | #endif |
| 1025 | LOG(("Sector Count: %02x\n", i8271.Counter)); |
| 1026 | LOG(("Track: %02x\n",i8271.CommandParameters[0])); |
| 1027 | LOG(("Sector: %02x\n", i8271.CommandParameters[1])); |
| 1028 | LOG(("Sector Length: %02x bytes\n", 1<<(i8271.ID_N+7))); |
| 1029 | |
| 1063 | 1030 | i8271_get_drive(); |
| 1064 | 1031 | |
| 1065 | 1032 | if (!floppy_drive_get_flag_state(img, FLOPPY_DRIVE_READY)) |
| r1470 | r1471 | |
| 1092 | 1059 | |
| 1093 | 1060 | FDC_LOG_COMMAND("READ DATA MULTI RECORD"); |
| 1094 | 1061 | |
| 1095 | | #ifdef VERBOSE |
| 1096 | | logerror("Sector Count: %02x\n", i8271.Counter); |
| 1097 | | logerror("Track: %02x\n",i8271.CommandParameters[0]); |
| 1098 | | logerror("Sector: %02x\n", i8271.CommandParameters[1]); |
| 1099 | | logerror("Sector Length: %02x bytes\n", 1<<(i8271.ID_N+7)); |
| 1100 | | #endif |
| 1062 | LOG(("Sector Count: %02x\n", i8271.Counter)); |
| 1063 | LOG(("Track: %02x\n",i8271.CommandParameters[0])); |
| 1064 | LOG(("Sector: %02x\n", i8271.CommandParameters[1])); |
| 1065 | LOG(("Sector Length: %02x bytes\n", 1<<(i8271.ID_N+7))); |
| 1101 | 1066 | |
| 1102 | 1067 | i8271_get_drive(); |
| 1103 | 1068 | |
| r1470 | r1471 | |
| 1140 | 1105 | i8271.ID_R = i8271.CommandParameters[1]; |
| 1141 | 1106 | |
| 1142 | 1107 | |
| 1143 | | #ifdef VERBOSE |
| 1144 | | logerror("Sector Count: %02x\n", i8271.Counter); |
| 1145 | | logerror("Track: %02x\n",i8271.CommandParameters[0]); |
| 1146 | | logerror("Sector: %02x\n", i8271.CommandParameters[1]); |
| 1147 | | logerror("Sector Length: %02x bytes\n", 1<<(i8271.ID_N+7)); |
| 1148 | | #endif |
| 1108 | LOG(("Sector Count: %02x\n", i8271.Counter)); |
| 1109 | LOG(("Track: %02x\n",i8271.CommandParameters[0])); |
| 1110 | LOG(("Sector: %02x\n", i8271.CommandParameters[1])); |
| 1111 | LOG(("Sector Length: %02x bytes\n", 1<<(i8271.ID_N+7))); |
| 1149 | 1112 | i8271_get_drive(); |
| 1150 | 1113 | |
| 1151 | 1114 | i8271.drive_control_output &=~1; |
| r1470 | r1471 | |
| 1185 | 1148 | { |
| 1186 | 1149 | FDC_LOG_COMMAND("READ ID"); |
| 1187 | 1150 | |
| 1188 | | #ifdef VERBOSE |
| 1189 | | logerror("Track: %02x\n",i8271.CommandParameters[0]); |
| 1190 | | logerror("ID Field Count: %02x\n", i8271.CommandParameters[2]); |
| 1191 | | #endif |
| 1151 | LOG(("Track: %02x\n",i8271.CommandParameters[0])); |
| 1152 | LOG(("ID Field Count: %02x\n", i8271.CommandParameters[2])); |
| 1192 | 1153 | |
| 1193 | 1154 | i8271_get_drive(); |
| 1194 | 1155 | |
| r1470 | r1471 | |
| 1212 | 1173 | break; |
| 1213 | 1174 | |
| 1214 | 1175 | default: |
| 1215 | | #ifdef VERBOSE |
| 1216 | | logerror("ERROR Unrecognised Command\n"); |
| 1217 | | #endif |
| 1176 | LOG(("ERROR Unrecognised Command\n")); |
| 1218 | 1177 | break; |
| 1219 | 1178 | } |
| 1220 | 1179 | } |
| r1470 | r1471 | |
| 1227 | 1186 | { |
| 1228 | 1187 | case 0: |
| 1229 | 1188 | { |
| 1230 | | #ifdef VERBOSE |
| 1231 | | logerror("I8271 W Command Register: %02x\n", data); |
| 1232 | | #endif |
| 1189 | LOG(("I8271 W Command Register: %02x\n", data)); |
| 1233 | 1190 | |
| 1234 | 1191 | i8271.CommandRegister = data; |
| 1235 | 1192 | i8271.Command = i8271.CommandRegister & 0x03f; |
| r1470 | r1471 | |
| 1334 | 1291 | |
| 1335 | 1292 | case 1: |
| 1336 | 1293 | { |
| 1337 | | #ifdef VERBOSE |
| 1338 | | logerror("I8271 W Parameter Register: %02x\n",data); |
| 1339 | | #endif |
| 1294 | LOG(("I8271 W Parameter Register: %02x\n",data)); |
| 1340 | 1295 | i8271.ParameterRegister = data; |
| 1341 | 1296 | |
| 1342 | 1297 | if (i8271.ParameterCount!=0) |
| r1470 | r1471 | |
| 1351 | 1306 | |
| 1352 | 1307 | case 2: |
| 1353 | 1308 | { |
| 1354 | | #ifdef VERBOSE |
| 1355 | | logerror("I8271 W Reset Register: %02x\n", data); |
| 1356 | | #endif |
| 1309 | LOG(("I8271 W Reset Register: %02x\n", data)); |
| 1357 | 1310 | if (((data ^ i8271.ResetRegister) & 0x01)!=0) |
| 1358 | 1311 | { |
| 1359 | 1312 | if ((data & 0x01)==0) |
| r1470 | r1471 | |
| 1381 | 1334 | { |
| 1382 | 1335 | /* bit 1,0 are zero other bits contain status data */ |
| 1383 | 1336 | i8271.StatusRegister &= ~0x03; |
| 1384 | | #ifdef VERBOSE |
| 1385 | | logerror("I8271 R Status Register: %02x\n",i8271.StatusRegister); |
| 1386 | | #endif |
| 1337 | LOG(("I8271 R Status Register: %02x\n",i8271.StatusRegister)); |
| 1387 | 1338 | return i8271.StatusRegister; |
| 1388 | 1339 | } |
| 1389 | 1340 | |
| r1470 | r1471 | |
| 1396 | 1347 | i8271_set_irq_state(0); |
| 1397 | 1348 | |
| 1398 | 1349 | i8271.StatusRegister &= ~I8271_STATUS_RESULT_FULL; |
| 1399 | | #ifdef VERBOSE |
| 1400 | | logerror("I8271 R Result Register %02x\n",i8271.ResultRegister); |
| 1401 | | #endif |
| 1350 | LOG(("I8271 R Result Register %02x\n",i8271.ResultRegister)); |
| 1402 | 1351 | return i8271.ResultRegister; |
| 1403 | 1352 | } |
| 1404 | 1353 | |
src/mess/machine/amigacd.c
| r1470 | r1471 | |
| 19 | 19 | |
| 20 | 20 | #define VERBOSE_DMAC 0 |
| 21 | 21 | |
| 22 | | #if VERBOSE_DMAC |
| 23 | | #define LOG logerror |
| 24 | | #else |
| 25 | | INLINE void dummy_log( const char *a, ... ) {} |
| 26 | | #define LOG dummy_log |
| 27 | | #endif |
| 22 | #define LOG(x) do { if (VERBOSE_DMAC) logerror x; } while (0) |
| 28 | 23 | |
| 29 | 24 | /* constants */ |
| 30 | 25 | #define CD_SECTOR_TIME (1000/((300*1024)/2048)) /* 2X CDROM sector time in msec (300KBps) */ |
| r1470 | r1471 | |
| 133 | 128 | case 0x20: |
| 134 | 129 | { |
| 135 | 130 | UINT8 v = dmac_data.istr; |
| 136 | | LOG( "DMAC: PC=%08x - ISTR Read(%04x)\n", activecpu_get_pc(), dmac_data.istr ); |
| 131 | LOG(( "DMAC: PC=%08x - ISTR Read(%04x)\n", activecpu_get_pc(), dmac_data.istr )); |
| 137 | 132 | |
| 138 | 133 | dmac_data.istr &= ~0x0f; |
| 139 | 134 | return v; |
| r1470 | r1471 | |
| 142 | 137 | |
| 143 | 138 | case 0x21: |
| 144 | 139 | { |
| 145 | | LOG( "DMAC: PC=%08x - CNTR Read(%04x)\n", activecpu_get_pc(), dmac_data.cntr ); |
| 140 | LOG(( "DMAC: PC=%08x - CNTR Read(%04x)\n", activecpu_get_pc(), dmac_data.cntr )); |
| 146 | 141 | return dmac_data.cntr; |
| 147 | 142 | } |
| 148 | 143 | break; |
| 149 | 144 | |
| 150 | 145 | case 0x40: /* wtc hi */ |
| 151 | 146 | { |
| 152 | | LOG( "DMAC: PC=%08x - WTC HI Read\n", activecpu_get_pc() ); |
| 147 | LOG(( "DMAC: PC=%08x - WTC HI Read\n", activecpu_get_pc() )); |
| 153 | 148 | return (dmac_data.wtc >> 16); |
| 154 | 149 | } |
| 155 | 150 | break; |
| 156 | 151 | |
| 157 | 152 | case 0x41: /* wtc lo */ |
| 158 | 153 | { |
| 159 | | LOG( "DMAC: PC=%08x - WTC LO Read\n", activecpu_get_pc() ); |
| 154 | LOG(( "DMAC: PC=%08x - WTC LO Read\n", activecpu_get_pc() )); |
| 160 | 155 | return dmac_data.wtc; |
| 161 | 156 | } |
| 162 | 157 | break; |
| 163 | 158 | |
| 164 | 159 | case 0x42: /* acr hi */ |
| 165 | 160 | { |
| 166 | | LOG( "DMAC: PC=%08x - ACR HI Read\n", activecpu_get_pc() ); |
| 161 | LOG(( "DMAC: PC=%08x - ACR HI Read\n", activecpu_get_pc() )); |
| 167 | 162 | return (dmac_data.acr >> 16); |
| 168 | 163 | } |
| 169 | 164 | break; |
| 170 | 165 | |
| 171 | 166 | case 0x43: /* acr lo */ |
| 172 | 167 | { |
| 173 | | LOG( "DMAC: PC=%08x - ACR LO Read\n", activecpu_get_pc() ); |
| 168 | LOG(( "DMAC: PC=%08x - ACR LO Read\n", activecpu_get_pc() )); |
| 174 | 169 | return dmac_data.acr; |
| 175 | 170 | } |
| 176 | 171 | break; |
| r1470 | r1471 | |
| 178 | 173 | case 0x48: /* wd33c93 SCSI expansion */ |
| 179 | 174 | case 0x49: |
| 180 | 175 | { |
| 181 | | LOG( "DMAC: PC=%08x - WD33C93 Read(%d)\n", activecpu_get_pc(), offset & 1 ); |
| 176 | LOG(( "DMAC: PC=%08x - WD33C93 Read(%d)\n", activecpu_get_pc(), offset & 1 )); |
| 182 | 177 | return 0x00; /* Not available without SCSI expansion */ |
| 183 | 178 | } |
| 184 | 179 | break; |
| 185 | 180 | |
| 186 | 181 | case 0x50: |
| 187 | 182 | { |
| 188 | | LOG( "DMAC: PC=%08x - CDROM RESP Read\n", activecpu_get_pc() ); |
| 183 | LOG(( "DMAC: PC=%08x - CDROM RESP Read\n", activecpu_get_pc() )); |
| 189 | 184 | return matsucd_response_r(); |
| 190 | 185 | } |
| 191 | 186 | break; |
| r1470 | r1471 | |
| 194 | 189 | case 0x52: |
| 195 | 190 | case 0x53: |
| 196 | 191 | { |
| 197 | | LOG( "DMAC: PC=%08x - XT IO Read(%d)\n", activecpu_get_pc(), (offset & 3)-1 ); |
| 192 | LOG(( "DMAC: PC=%08x - XT IO Read(%d)\n", activecpu_get_pc(), (offset & 3)-1 )); |
| 198 | 193 | return 0xff; |
| 199 | 194 | } |
| 200 | 195 | break; |
| r1470 | r1471 | |
| 216 | 211 | case 0x66: |
| 217 | 212 | case 0x67: |
| 218 | 213 | { |
| 219 | | LOG( "DMAC: PC=%08x - TPI6525 Read(%d)\n", activecpu_get_pc(), (offset - 0x58) ); |
| 214 | LOG(( "DMAC: PC=%08x - TPI6525 Read(%d)\n", activecpu_get_pc(), (offset - 0x58) )); |
| 220 | 215 | return tpi6525_0_port_r(offset - 0x58); |
| 221 | 216 | } |
| 222 | 217 | break; |
| 223 | 218 | |
| 224 | 219 | case 0x70: /* DMA start strobe */ |
| 225 | 220 | { |
| 226 | | LOG( "DMAC: PC=%08x - DMA Start Strobe\n", activecpu_get_pc() ); |
| 221 | LOG(( "DMAC: PC=%08x - DMA Start Strobe\n", activecpu_get_pc() )); |
| 227 | 222 | timer_adjust( dmac_data.dma_timer, ATTOTIME_IN_MSEC( CD_SECTOR_TIME ), 0, attotime_zero ); |
| 228 | 223 | } |
| 229 | 224 | break; |
| 230 | 225 | |
| 231 | 226 | case 0x71: /* DMA stop strobe */ |
| 232 | 227 | { |
| 233 | | LOG( "DMAC: PC=%08x - DMA Stop Strobe\n", activecpu_get_pc() ); |
| 228 | LOG(( "DMAC: PC=%08x - DMA Stop Strobe\n", activecpu_get_pc() )); |
| 234 | 229 | timer_reset( dmac_data.dma_timer, attotime_never ); |
| 235 | 230 | } |
| 236 | 231 | break; |
| 237 | 232 | |
| 238 | 233 | case 0x72: /* Clear IRQ strobe */ |
| 239 | 234 | { |
| 240 | | LOG( "DMAC: PC=%08x - IRQ Clear Strobe\n", activecpu_get_pc() ); |
| 235 | LOG(( "DMAC: PC=%08x - IRQ Clear Strobe\n", activecpu_get_pc() )); |
| 241 | 236 | dmac_data.istr &= ~ISTR_INT_P; |
| 242 | 237 | } |
| 243 | 238 | break; |
| 244 | 239 | |
| 245 | 240 | case 0x74: /* Flush strobe */ |
| 246 | 241 | { |
| 247 | | LOG( "DMAC: PC=%08x - Flush Strobe\n", activecpu_get_pc() ); |
| 242 | LOG(( "DMAC: PC=%08x - Flush Strobe\n", activecpu_get_pc() )); |
| 248 | 243 | dmac_data.istr |= ISTR_FE_FLG; |
| 249 | 244 | } |
| 250 | 245 | break; |
| r1470 | r1471 | |
| 265 | 260 | { |
| 266 | 261 | case 0x21: /* control write */ |
| 267 | 262 | { |
| 268 | | LOG( "DMAC: PC=%08x - CNTR Write(%04x)\n", activecpu_get_pc(), data ); |
| 263 | LOG(( "DMAC: PC=%08x - CNTR Write(%04x)\n", activecpu_get_pc(), data )); |
| 269 | 264 | dmac_data.cntr = data; |
| 270 | 265 | check_interrupts(); |
| 271 | 266 | } |
| r1470 | r1471 | |
| 273 | 268 | |
| 274 | 269 | case 0x40: /* wtc hi */ |
| 275 | 270 | { |
| 276 | | LOG( "DMAC: PC=%08x - WTC HI Write - data = %04x\n", activecpu_get_pc(), data ); |
| 271 | LOG(( "DMAC: PC=%08x - WTC HI Write - data = %04x\n", activecpu_get_pc(), data )); |
| 277 | 272 | dmac_data.wtc &= 0x0000ffff; |
| 278 | 273 | dmac_data.wtc |= ((UINT32)data) << 16; |
| 279 | 274 | } |
| r1470 | r1471 | |
| 281 | 276 | |
| 282 | 277 | case 0x41: /* wtc lo */ |
| 283 | 278 | { |
| 284 | | LOG( "DMAC: PC=%08x - WTC LO Write - data = %04x\n", activecpu_get_pc(), data ); |
| 279 | LOG(( "DMAC: PC=%08x - WTC LO Write - data = %04x\n", activecpu_get_pc(), data )); |
| 285 | 280 | dmac_data.wtc &= 0xffff0000; |
| 286 | 281 | dmac_data.wtc |= data; |
| 287 | 282 | } |
| r1470 | r1471 | |
| 289 | 284 | |
| 290 | 285 | case 0x42: /* acr hi */ |
| 291 | 286 | { |
| 292 | | LOG( "DMAC: PC=%08x - ACR HI Write - data = %04x\n", activecpu_get_pc(), data ); |
| 287 | LOG(( "DMAC: PC=%08x - ACR HI Write - data = %04x\n", activecpu_get_pc(), data )); |
| 293 | 288 | dmac_data.acr &= 0x0000ffff; |
| 294 | 289 | dmac_data.acr |= ((UINT32)data) << 16; |
| 295 | 290 | } |
| r1470 | r1471 | |
| 297 | 292 | |
| 298 | 293 | case 0x43: /* acr lo */ |
| 299 | 294 | { |
| 300 | | LOG( "DMAC: PC=%08x - ACR LO Write - data = %04x\n", activecpu_get_pc(), data ); |
| 295 | LOG(( "DMAC: PC=%08x - ACR LO Write - data = %04x\n", activecpu_get_pc(), data )); |
| 301 | 296 | dmac_data.acr &= 0xffff0000; |
| 302 | 297 | dmac_data.acr |= data; |
| 303 | 298 | } |
| r1470 | r1471 | |
| 305 | 300 | |
| 306 | 301 | case 0x47: /* dawr */ |
| 307 | 302 | { |
| 308 | | LOG( "DMAC: PC=%08x - DAWR Write - data = %04x\n", activecpu_get_pc(), data ); |
| 303 | LOG(( "DMAC: PC=%08x - DAWR Write - data = %04x\n", activecpu_get_pc(), data )); |
| 309 | 304 | dmac_data.dawr = data; |
| 310 | 305 | } |
| 311 | 306 | break; |
| r1470 | r1471 | |
| 313 | 308 | case 0x48: /* wd33c93 SCSI expansion */ |
| 314 | 309 | case 0x49: |
| 315 | 310 | { |
| 316 | | LOG( "DMAC: PC=%08x - WD33C93 Write(%d) - data = %04x\n", activecpu_get_pc(), offset & 1, data ); |
| 311 | LOG(( "DMAC: PC=%08x - WD33C93 Write(%d) - data = %04x\n", activecpu_get_pc(), offset & 1, data )); |
| 317 | 312 | /* Not available without SCSI expansion */ |
| 318 | 313 | } |
| 319 | 314 | break; |
| 320 | 315 | |
| 321 | 316 | case 0x50: |
| 322 | 317 | { |
| 323 | | LOG( "DMAC: PC=%08x - CDROM CMD Write - data = %04x\n", activecpu_get_pc(), data ); |
| 318 | LOG(( "DMAC: PC=%08x - CDROM CMD Write - data = %04x\n", activecpu_get_pc(), data )); |
| 324 | 319 | matsucd_command_w( data ); |
| 325 | 320 | } |
| 326 | 321 | break; |
| r1470 | r1471 | |
| 342 | 337 | case 0x66: |
| 343 | 338 | case 0x67: |
| 344 | 339 | { |
| 345 | | LOG( "DMAC: PC=%08x - TPI6525 Write(%d) - data = %04x\n", activecpu_get_pc(), (offset - 0x58), data ); |
| 340 | LOG(( "DMAC: PC=%08x - TPI6525 Write(%d) - data = %04x\n", activecpu_get_pc(), (offset - 0x58), data )); |
| 346 | 341 | tpi6525_0_port_w(offset - 0x58, data); |
| 347 | 342 | } |
| 348 | 343 | break; |
| 349 | 344 | |
| 350 | 345 | case 0x70: /* DMA start strobe */ |
| 351 | 346 | { |
| 352 | | LOG( "DMAC: PC=%08x - DMA Start Strobe\n", activecpu_get_pc() ); |
| 347 | LOG(( "DMAC: PC=%08x - DMA Start Strobe\n", activecpu_get_pc() )); |
| 353 | 348 | timer_adjust( dmac_data.dma_timer, ATTOTIME_IN_MSEC( CD_SECTOR_TIME ), 0, attotime_zero ); |
| 354 | 349 | } |
| 355 | 350 | break; |
| 356 | 351 | |
| 357 | 352 | case 0x71: /* DMA stop strobe */ |
| 358 | 353 | { |
| 359 | | LOG( "DMAC: PC=%08x - DMA Stop Strobe\n", activecpu_get_pc() ); |
| 354 | LOG(( "DMAC: PC=%08x - DMA Stop Strobe\n", activecpu_get_pc() )); |
| 360 | 355 | timer_reset( dmac_data.dma_timer, attotime_never ); |
| 361 | 356 | } |
| 362 | 357 | break; |
| 363 | 358 | |
| 364 | 359 | case 0x72: /* Clear IRQ strobe */ |
| 365 | 360 | { |
| 366 | | LOG( "DMAC: PC=%08x - IRQ Clear Strobe\n", activecpu_get_pc() ); |
| 361 | LOG(( "DMAC: PC=%08x - IRQ Clear Strobe\n", activecpu_get_pc() )); |
| 367 | 362 | dmac_data.istr &= ~ISTR_INT_P; |
| 368 | 363 | } |
| 369 | 364 | break; |
| 370 | 365 | |
| 371 | 366 | case 0x74: /* Flush Strobe */ |
| 372 | 367 | { |
| 373 | | LOG( "DMAC: PC=%08x - Flush Strobe\n", activecpu_get_pc() ); |
| 368 | LOG(( "DMAC: PC=%08x - Flush Strobe\n", activecpu_get_pc() )); |
| 374 | 369 | dmac_data.istr |= ISTR_FE_FLG; |
| 375 | 370 | } |
| 376 | 371 | break; |
| r1470 | r1471 | |
| 465 | 460 | |
| 466 | 461 | static void tp6525_irq( int level ) |
| 467 | 462 | { |
| 468 | | LOG( "TPI6525 Interrupt: level = %d\n", level); |
| 463 | LOG(( "TPI6525 Interrupt: level = %d\n", level )); |
| 469 | 464 | |
| 470 | 465 | if ( level ) |
| 471 | 466 | { |
src/mess/machine/nes_mmc.c
| r1470 | r1471 | |
| 27 | 27 | #include "nes_mmc.h" |
| 28 | 28 | #include "sound/nes_apu.h" |
| 29 | 29 | |
| 30 | | #define LOG_MMC 1 |
| 31 | | #define LOG_FDS 1 |
| 30 | #define VERBOSE 1 |
| 32 | 31 | |
| 32 | #define LOG_MMC(x) do { if (VERBOSE) logerror x; } while (0) |
| 33 | #define LOG_FDS(x) do { if (VERBOSE) logerror x; } while (0) |
| 34 | |
| 33 | 35 | /* Global variables */ |
| 34 | 36 | static int prg_mask; |
| 35 | 37 | |
| r1470 | r1471 | |
| 352 | 354 | MMC1_Size_16k = 1; |
| 353 | 355 | MMC1_Switch_Low = 1; |
| 354 | 356 | /* TODO: should we switch banks at this time also? */ |
| 355 | | #ifdef LOG_MMC |
| 356 | | logerror("=== MMC1 regs reset to default\n"); |
| 357 | | #endif |
| 357 | LOG_MMC(("=== MMC1 regs reset to default\n")); |
| 358 | 358 | return; |
| 359 | 359 | } |
| 360 | 360 | |
| r1470 | r1471 | |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | MMC1_SizeVrom_4k = (MMC1_reg & 0x10); |
| 387 | | #ifdef LOG_MMC |
| 388 | | logerror(" MMC1 reg #1 val:%02x\n", MMC1_reg); |
| 389 | | logerror("\t\tBank Size: "); |
| 387 | LOG_MMC((" MMC1 reg #1 val:%02x\n", MMC1_reg)); |
| 388 | LOG_MMC(("\t\tBank Size: ")); |
| 390 | 389 | if (MMC1_Size_16k) |
| 391 | | logerror("16k\n"); |
| 392 | | else logerror("32k\n"); |
| 390 | LOG_MMC(("16k\n")); |
| 391 | else LOG_MMC(("32k\n")); |
| 393 | 392 | |
| 394 | | logerror("\t\tBank Select: "); |
| 393 | LOG_MMC(("\t\tBank Select: ")); |
| 395 | 394 | if (MMC1_Switch_Low) |
| 396 | | logerror("$8000\n"); |
| 397 | | else logerror("$C000\n"); |
| 395 | LOG_MMC(("$8000\n")); |
| 396 | else LOG_MMC(("$C000\n")); |
| 398 | 397 | |
| 399 | | logerror("\t\tVROM Bankswitch Size Select: "); |
| 398 | LOG_MMC(("\t\tVROM Bankswitch Size Select: ")); |
| 400 | 399 | if (MMC1_SizeVrom_4k) |
| 401 | | logerror("4k\n"); |
| 402 | | else logerror("8k\n"); |
| 400 | LOG_MMC(("4k\n")); |
| 401 | else LOG_MMC(("8k\n")); |
| 403 | 402 | |
| 404 | | logerror ("\t\tMirroring: %d\n", MMC1_reg & 0x03); |
| 405 | | #endif |
| 403 | LOG_MMC(("\t\tMirroring: %d\n", MMC1_reg & 0x03)); |
| 406 | 404 | break; |
| 407 | 405 | |
| 408 | 406 | case 1: |
| r1470 | r1471 | |
| 418 | 416 | memory_set_bankptr (2, &nes.rom[MMC1_extended_base + MMC1_bank2]); |
| 419 | 417 | memory_set_bankptr (3, &nes.rom[MMC1_extended_base + MMC1_bank3]); |
| 420 | 418 | memory_set_bankptr (4, &nes.rom[MMC1_extended_base + MMC1_bank4]); |
| 421 | | #ifdef LOG_MMC |
| 422 | | logerror("MMC1_extended 1024k bank (no reg) select: %02x\n", MMC1_extended_bank); |
| 423 | | #endif |
| 419 | LOG_MMC(("MMC1_extended 1024k bank (no reg) select: %02x\n", MMC1_extended_bank)); |
| 424 | 420 | } |
| 425 | 421 | else |
| 426 | 422 | { |
| r1470 | r1471 | |
| 432 | 428 | memory_set_bankptr (2, &nes.rom[MMC1_extended_base + MMC1_bank2]); |
| 433 | 429 | memory_set_bankptr (3, &nes.rom[MMC1_extended_base + MMC1_bank3]); |
| 434 | 430 | memory_set_bankptr (4, &nes.rom[MMC1_extended_base + MMC1_bank4]); |
| 435 | | #ifdef LOG_MMC |
| 436 | | logerror("MMC1_extended 1024k bank (reg 1) select: %02x\n", MMC1_extended_bank); |
| 437 | | #endif |
| 431 | LOG_MMC(("MMC1_extended 1024k bank (reg 1) select: %02x\n", MMC1_extended_bank)); |
| 438 | 432 | MMC1_extended_swap = 0; |
| 439 | 433 | } |
| 440 | 434 | else MMC1_extended_swap = 1; |
| r1470 | r1471 | |
| 448 | 442 | memory_set_bankptr (2, &nes.rom[MMC1_extended_base + MMC1_bank2]); |
| 449 | 443 | memory_set_bankptr (3, &nes.rom[MMC1_extended_base + MMC1_bank3]); |
| 450 | 444 | memory_set_bankptr (4, &nes.rom[MMC1_extended_base + MMC1_bank4]); |
| 451 | | #ifdef LOG_MMC |
| 452 | | logerror("MMC1_extended 512k bank select: %02x\n", MMC1_extended_bank & 0x01); |
| 453 | | #endif |
| 445 | LOG_MMC(("MMC1_extended 512k bank select: %02x\n", MMC1_extended_bank & 0x01)); |
| 454 | 446 | } |
| 455 | 447 | else if (nes.chr_chunks > 0) |
| 456 | 448 | { |
| r1470 | r1471 | |
| 460 | 452 | { |
| 461 | 453 | int bank = MMC1_reg & ((nes.chr_chunks << 1) - 1); |
| 462 | 454 | ppu2c0x_set_videorom_bank(0, 0, 8, bank, 256); |
| 463 | | #ifdef LOG_MMC |
| 464 | | logerror("MMC1 8k VROM switch: %02x\n", MMC1_reg); |
| 465 | | #endif |
| 455 | LOG_MMC(("MMC1 8k VROM switch: %02x\n", MMC1_reg)); |
| 466 | 456 | } |
| 467 | 457 | else |
| 468 | 458 | { |
| 469 | 459 | int bank = MMC1_reg & ((nes.chr_chunks << 1) - 1); |
| 470 | 460 | ppu2c0x_set_videorom_bank(0, 0, 4, bank, 256); |
| 471 | | #ifdef LOG_MMC |
| 472 | | logerror("MMC1 4k VROM switch (low): %02x\n", MMC1_reg); |
| 473 | | #endif |
| 461 | LOG_MMC(("MMC1 4k VROM switch (low): %02x\n", MMC1_reg)); |
| 474 | 462 | } |
| 475 | 463 | } |
| 476 | 464 | break; |
| r1470 | r1471 | |
| 487 | 475 | memory_set_bankptr (2, &nes.rom[MMC1_extended_base + MMC1_bank2]); |
| 488 | 476 | memory_set_bankptr (3, &nes.rom[MMC1_extended_base + MMC1_bank3]); |
| 489 | 477 | memory_set_bankptr (4, &nes.rom[MMC1_extended_base + MMC1_bank4]); |
| 490 | | #ifdef LOG_MMC |
| 491 | | logerror("MMC1_extended 1024k bank (reg 2) select: %02x\n", MMC1_extended_bank); |
| 492 | | #endif |
| 478 | LOG_MMC(("MMC1_extended 1024k bank (reg 2) select: %02x\n", MMC1_extended_bank)); |
| 493 | 479 | MMC1_extended_swap = 0; |
| 494 | 480 | } |
| 495 | 481 | else |
| r1470 | r1471 | |
| 499 | 485 | { |
| 500 | 486 | int bank = MMC1_reg & ((nes.chr_chunks << 1) - 1); |
| 501 | 487 | ppu2c0x_set_videorom_bank(0, 4, 4, bank, 256); |
| 502 | | #ifdef LOG_MMC |
| 503 | | logerror("MMC1 4k VROM switch (high): %02x\n", MMC1_reg); |
| 504 | | #endif |
| 488 | LOG_MMC(("MMC1 4k VROM switch (high): %02x\n", MMC1_reg)); |
| 505 | 489 | } |
| 506 | 490 | break; |
| 507 | 491 | case 3: |
| r1470 | r1471 | |
| 522 | 506 | memory_set_bankptr (3, &nes.rom[MMC1_extended_base + MMC1_bank3]); |
| 523 | 507 | memory_set_bankptr (4, &nes.rom[MMC1_extended_base + MMC1_bank4]); |
| 524 | 508 | } |
| 525 | | #ifdef LOG_MMC |
| 526 | | logerror("MMC1 32k bank select: %02x\n", MMC1_reg); |
| 527 | | #endif |
| 509 | LOG_MMC(("MMC1 32k bank select: %02x\n", MMC1_reg)); |
| 528 | 510 | } |
| 529 | 511 | else |
| 530 | 512 | /* Switching one 16k bank */ |
| r1470 | r1471 | |
| 545 | 527 | memory_set_bankptr (3, &nes.rom[MMC1_extended_base + MMC1_bank3]); |
| 546 | 528 | memory_set_bankptr (4, &nes.rom[MMC1_extended_base + MMC1_bank4]); |
| 547 | 529 | } |
| 548 | | #ifdef LOG_MMC |
| 549 | | logerror("MMC1 16k-low bank select: %02x\n", MMC1_reg); |
| 550 | | #endif |
| 530 | LOG_MMC(("MMC1 16k-low bank select: %02x\n", MMC1_reg)); |
| 551 | 531 | } |
| 552 | 532 | else |
| 553 | 533 | { |
| r1470 | r1471 | |
| 566 | 546 | memory_set_bankptr (3, &nes.rom[MMC1_extended_base + MMC1_bank3]); |
| 567 | 547 | memory_set_bankptr (4, &nes.rom[MMC1_extended_base + MMC1_bank4]); |
| 568 | 548 | } |
| 569 | | #ifdef LOG_MMC |
| 570 | | logerror("MMC1 16k-high bank select: %02x\n", MMC1_reg); |
| 571 | | #endif |
| 549 | LOG_MMC(("MMC1 16k-high bank select: %02x\n", MMC1_reg)); |
| 572 | 550 | } |
| 573 | 551 | } |
| 574 | 552 | |
| 575 | | #ifdef LOG_MMC |
| 576 | | logerror("-- page1: %06x\n", MMC1_bank1); |
| 577 | | logerror("-- page2: %06x\n", MMC1_bank2); |
| 578 | | logerror("-- page3: %06x\n", MMC1_bank3); |
| 579 | | logerror("-- page4: %06x\n", MMC1_bank4); |
| 580 | | #endif |
| 553 | LOG_MMC(("-- page1: %06x\n", MMC1_bank1)); |
| 554 | LOG_MMC(("-- page2: %06x\n", MMC1_bank2)); |
| 555 | LOG_MMC(("-- page3: %06x\n", MMC1_bank3)); |
| 556 | LOG_MMC(("-- page4: %06x\n", MMC1_bank4)); |
| 581 | 557 | break; |
| 582 | 558 | } |
| 583 | 559 | MMC1_reg_count = 0; |
| r1470 | r1471 | |
| 663 | 639 | /* Reset the banks */ |
| 664 | 640 | mapper4_set_prg (); |
| 665 | 641 | mapper4_set_chr (); |
| 666 | | #ifdef LOG_MMC |
| 667 | | logerror(" MMC3 reset banks\n"); |
| 668 | | #endif |
| 642 | LOG_MMC((" MMC3 reset banks\n")); |
| 669 | 643 | } |
| 670 | 644 | last_bank = data & 0xc0; |
| 671 | 645 | break; |
| r1470 | r1471 | |
| 679 | 653 | data &= 0xfe; |
| 680 | 654 | MMC3_chr[cmd] = data * 64; |
| 681 | 655 | mapper4_set_chr (); |
| 682 | | #ifdef LOG_MMC |
| 683 | | logerror(" MMC3 set vram %d: %d\n", cmd, data); |
| 684 | | #endif |
| 656 | LOG_MMC((" MMC3 set vram %d: %d\n", cmd, data)); |
| 685 | 657 | break; |
| 686 | 658 | |
| 687 | 659 | case 2: case 3: case 4: case 5: |
| 688 | 660 | MMC3_chr[cmd] = data * 64; |
| 689 | 661 | mapper4_set_chr (); |
| 690 | | #ifdef LOG_MMC |
| 691 | | logerror(" MMC3 set vram %d: %d\n", cmd, data); |
| 692 | | #endif |
| 662 | LOG_MMC((" MMC3 set vram %d: %d\n", cmd, data)); |
| 693 | 663 | break; |
| 694 | 664 | |
| 695 | 665 | case 6: |
| r1470 | r1471 | |
| 718 | 688 | |
| 719 | 689 | case 0x2001: /* $a001 - extra RAM enable/disable */ |
| 720 | 690 | nes.mid_ram_enable = data; |
| 721 | | #ifdef LOG_MMC |
| 722 | | logerror(" MMC3 mid_ram enable: %02x\n", 0); |
| 723 | | #endif |
| 691 | LOG_MMC((" MMC3 mid_ram enable: %02x\n", 0)); |
| 724 | 692 | break; |
| 725 | 693 | |
| 726 | 694 | case 0x4000: /* $c000 - IRQ scanline counter */ |
| 727 | 695 | IRQ_count_latch = data; |
| 728 | | #ifdef LOG_MMC |
| 729 | | // logerror(" MMC3 set irq count latch: %02x (scanline %d)\n", data, ppu2c0x_get_current_scanline(0)); |
| 730 | | #endif |
| 696 | // LOG_MMC((" MMC3 set irq count latch: %02x (scanline %d)\n", data, ppu2c0x_get_current_scanline(0))); |
| 731 | 697 | break; |
| 732 | 698 | |
| 733 | 699 | case 0x4001: /* $c001 - IRQ scanline latch */ |
| 734 | 700 | IRQ_reload = 1; |
| 735 | | #ifdef LOG_MMC |
| 736 | | // logerror(" MMC3 set irq reload (scanline %d)\n", ppu2c0x_get_current_scanline(0)); |
| 737 | | #endif |
| 701 | // LOG_MMC((" MMC3 set irq reload (scanline %d)\n", ppu2c0x_get_current_scanline(0))); |
| 738 | 702 | break; |
| 739 | 703 | |
| 740 | 704 | case 0x6000: /* $e000 - Disable IRQs */ |
| 741 | 705 | IRQ_enable = 0; |
| 742 | | #ifdef LOG_MMC |
| 743 | | logerror(" MMC3 disable irqs\n"); |
| 744 | | #endif |
| 706 | LOG_MMC((" MMC3 disable irqs\n")); |
| 745 | 707 | break; |
| 746 | 708 | |
| 747 | 709 | case 0x6001: /* $e001 - Enable IRQs */ |
| 748 | 710 | IRQ_enable = 1; |
| 749 | | #ifdef LOG_MMC |
| 750 | | logerror(" MMC3 enable irqs\n"); |
| 751 | | #endif |
| 711 | LOG_MMC((" MMC3 enable irqs\n")); |
| 752 | 712 | break; |
| 753 | 713 | |
| 754 | 714 | default: |
| r1470 | r1471 | |
| 808 | 768 | break; |
| 809 | 769 | } |
| 810 | 770 | case 0x2000: /* $a000 */ |
| 811 | | #ifdef LOG_MMC |
| 812 | | logerror(" mapper 118 mirroring: %02x\n", data); |
| 813 | | #endif |
| 771 | LOG_MMC((" mapper 118 mirroring: %02x\n", data)); |
| 814 | 772 | switch (data & 0x02) |
| 815 | 773 | { |
| 816 | 774 | case 0x00: ppu2c0x_set_mirroring(0, PPU_MIRROR_LOW); break; |
| r1470 | r1471 | |
| 820 | 778 | |
| 821 | 779 | case 0x2001: /* $a001 - extra RAM enable/disable */ |
| 822 | 780 | nes.mid_ram_enable = data; |
| 823 | | #ifdef LOG_MMC |
| 824 | | logerror(" MMC3 mid_ram enable: %02x\n", data); |
| 825 | | #endif |
| 781 | LOG_MMC((" MMC3 mid_ram enable: %02x\n", data)); |
| 826 | 782 | break; |
| 827 | 783 | |
| 828 | 784 | case 0x4000: /* $c000 - IRQ scanline counter */ |
| 829 | 785 | IRQ_count = data; |
| 830 | | #ifdef LOG_MMC |
| 831 | | logerror(" MMC3 set irq count: %02x\n", data); |
| 832 | | #endif |
| 786 | LOG_MMC((" MMC3 set irq count: %02x\n", data)); |
| 833 | 787 | break; |
| 834 | 788 | |
| 835 | 789 | case 0x4001: /* $c001 - IRQ scanline latch */ |
| 836 | 790 | IRQ_count_latch = data; |
| 837 | | #ifdef LOG_MMC |
| 838 | | logerror(" MMC3 set irq count latch: %02x\n", data); |
| 839 | | #endif |
| 791 | LOG_MMC((" MMC3 set irq count latch: %02x\n", data)); |
| 840 | 792 | break; |
| 841 | 793 | |
| 842 | 794 | case 0x6000: /* $e000 - Disable IRQs */ |
| 843 | 795 | IRQ_enable = 0; |
| 844 | 796 | IRQ_count = IRQ_count_latch; /* TODO: verify this */ |
| 845 | | #ifdef LOG_MMC |
| 846 | | logerror(" MMC3 disable irqs: %02x\n", data); |
| 847 | | #endif |
| 797 | LOG_MMC((" MMC3 disable irqs: %02x\n", data)); |
| 848 | 798 | break; |
| 849 | 799 | |
| 850 | 800 | case 0x6001: /* $e001 - Enable IRQs */ |
| 851 | 801 | IRQ_enable = 1; |
| 852 | | #ifdef LOG_MMC |
| 853 | | logerror(" MMC3 enable irqs: %02x\n", data); |
| 854 | | #endif |
| 802 | LOG_MMC((" MMC3 enable irqs: %02x\n", data)); |
| 855 | 803 | break; |
| 856 | 804 | |
| 857 | 805 | default: |
| r1470 | r1471 | |
| 1396 | 1344 | |
| 1397 | 1345 | static WRITE8_HANDLER( mapper8_w ) |
| 1398 | 1346 | { |
| 1399 | | #ifdef LOG_MMC |
| 1400 | | logerror("* Mapper 8 switch, vrom: %02x, rom: %02x\n", data & 0x07, (data >> 3)); |
| 1401 | | #endif |
| 1347 | LOG_MMC(("* Mapper 8 switch, vrom: %02x, rom: %02x\n", data & 0x07, (data >> 3))); |
| 1402 | 1348 | /* Switch 8k VROM bank */ |
| 1403 | 1349 | chr8 (data & 0x07); |
| 1404 | 1350 | |
| r1470 | r1471 | |
| 1556 | 1502 | |
| 1557 | 1503 | static WRITE8_HANDLER( mapper11_w ) |
| 1558 | 1504 | { |
| 1559 | | #ifdef LOG_MMC |
| 1560 | | logerror("* Mapper 11 switch, data: %02x\n", data); |
| 1561 | | #endif |
| 1505 | LOG_MMC(("* Mapper 11 switch, data: %02x\n", data)); |
| 1506 | |
| 1562 | 1507 | /* Switch 8k VROM bank */ |
| 1563 | 1508 | chr8 (data >> 4); |
| 1564 | 1509 | |
| r1470 | r1471 | |
| 1567 | 1512 | } |
| 1568 | 1513 | static WRITE8_HANDLER( mapper13_w ) |
| 1569 | 1514 | { |
| 1570 | | #ifdef LOG_MMC |
| 1571 | | logerror("* Mapper 13 switch, data: %02x\n", data ); |
| 1572 | | #endif |
| 1515 | LOG_MMC(("* Mapper 13 switch, data: %02x\n", data )); |
| 1516 | |
| 1573 | 1517 | //this is a place-holder call. |
| 1574 | 1518 | //mapper doesn't work because CHR-RAM is not mapped. |
| 1575 | 1519 | chr4_4 (data); |
| r1470 | r1471 | |
| 2120 | 2064 | break; |
| 2121 | 2065 | } |
| 2122 | 2066 | |
| 2123 | | #ifdef LOG_FDS |
| 2124 | | logerror ("fds_r, address: %04x, data: %02x\n", offset + 0x4030, ret); |
| 2125 | | #endif |
| 2067 | LOG_FDS(("fds_r, address: %04x, data: %02x\n", offset + 0x4030, ret)); |
| 2126 | 2068 | |
| 2127 | 2069 | return ret; |
| 2128 | 2070 | } |
| r1470 | r1471 | |
| 2166 | 2108 | break; |
| 2167 | 2109 | } |
| 2168 | 2110 | |
| 2169 | | #ifdef LOG_FDS |
| 2170 | | logerror ("fds_w, address: %04x, data: %02x\n", offset + 0x4020, data); |
| 2171 | | #endif |
| 2172 | | |
| 2111 | LOG_FDS(("fds_w, address: %04x, data: %02x\n", offset + 0x4020, data)); |
| 2173 | 2112 | } |
| 2174 | 2113 | |
| 2175 | 2114 | static void konami_irq ( int num, int scanline, int vblank, int blanked ) |
| r1470 | r1471 | |
| 2873 | 2812 | |
| 2874 | 2813 | static WRITE8_HANDLER( mapper41_m_w ) |
| 2875 | 2814 | { |
| 2876 | | #ifdef LOG_MMC |
| 2877 | | logerror("mapper41_m_w, offset: %04x, data: %02x\n", offset, data); |
| 2878 | | #endif |
| 2815 | LOG_MMC(("mapper41_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 2816 | |
| 2879 | 2817 | if (offset & 0x20) |
| 2880 | 2818 | ppu2c0x_set_mirroring(0, PPU_MIRROR_HORZ); |
| 2881 | 2819 | else |
| r1470 | r1471 | |
| 2889 | 2827 | |
| 2890 | 2828 | static WRITE8_HANDLER( mapper41_w ) |
| 2891 | 2829 | { |
| 2892 | | #ifdef LOG_MMC |
| 2893 | | logerror("mapper41_w, offset: %04x, data: %02x\n", offset, data); |
| 2894 | | #endif |
| 2830 | LOG_MMC(("mapper41_w, offset: %04x, data: %02x\n", offset, data)); |
| 2895 | 2831 | |
| 2896 | 2832 | if (mapper41_reg2) |
| 2897 | 2833 | { |
| r1470 | r1471 | |
| 3087 | 3023 | /* Switch 8k bank at $8000 */ |
| 3088 | 3024 | data &= prg_mask; |
| 3089 | 3025 | memory_set_bankptr (1, &nes.rom[0x2000 * (data) + 0x10000]); |
| 3090 | | #ifdef LOG_MMC |
| 3091 | | logerror(" Mapper 65 switch ($8000) value: %02x\n", data); |
| 3092 | | #endif |
| 3026 | LOG_MMC((" Mapper 65 switch ($8000) value: %02x\n", data)); |
| 3093 | 3027 | break; |
| 3094 | 3028 | case 0x1001: |
| 3095 | 3029 | if (data & 0x80) |
| r1470 | r1471 | |
| 3108 | 3042 | /* Switch 8k bank at $a000 */ |
| 3109 | 3043 | data &= prg_mask; |
| 3110 | 3044 | memory_set_bankptr (2, &nes.rom[0x2000 * (data) + 0x10000]); |
| 3111 | | #ifdef LOG_MMC |
| 3112 | | logerror(" Mapper 65 switch ($a000) value: %02x\n", data); |
| 3113 | | #endif |
| 3045 | LOG_MMC((" Mapper 65 switch ($a000) value: %02x\n", data)); |
| 3114 | 3046 | break; |
| 3115 | 3047 | |
| 3116 | 3048 | case 0x3000: |
| r1470 | r1471 | |
| 3129 | 3061 | /* Switch 8k bank at $c000 */ |
| 3130 | 3062 | data &= prg_mask; |
| 3131 | 3063 | memory_set_bankptr (3, &nes.rom[0x2000 * (data) + 0x10000]); |
| 3132 | | #ifdef LOG_MMC |
| 3133 | | logerror(" Mapper 65 switch ($c000) value: %02x\n", data); |
| 3134 | | #endif |
| 3064 | LOG_MMC((" Mapper 65 switch ($c000) value: %02x\n", data)); |
| 3135 | 3065 | break; |
| 3136 | 3066 | |
| 3137 | 3067 | default: |
| r1470 | r1471 | |
| 3142 | 3072 | |
| 3143 | 3073 | static WRITE8_HANDLER( mapper66_w ) |
| 3144 | 3074 | { |
| 3145 | | #ifdef LOG_MMC |
| 3146 | | logerror("* Mapper 66 switch, offset %04x, data: %02x\n", offset, data); |
| 3147 | | #endif |
| 3075 | LOG_MMC(("* Mapper 66 switch, offset %04x, data: %02x\n", offset, data)); |
| 3148 | 3076 | |
| 3149 | 3077 | prg32 ((data & 0x30) >> 4); |
| 3150 | 3078 | chr8 (data & 0x03); |
| r1470 | r1471 | |
| 3844 | 3772 | |
| 3845 | 3773 | static WRITE8_HANDLER( mapper93_m_w ) |
| 3846 | 3774 | { |
| 3847 | | #ifdef LOG_MMC |
| 3848 | | logerror("mapper93_m_w %04x:%02x\n", offset, data); |
| 3849 | | #endif |
| 3775 | LOG_MMC(("mapper93_m_w %04x:%02x\n", offset, data)); |
| 3850 | 3776 | |
| 3851 | 3777 | prg16_89ab (data); |
| 3852 | 3778 | } |
| 3853 | 3779 | |
| 3854 | 3780 | static WRITE8_HANDLER( mapper93_w ) |
| 3855 | 3781 | { |
| 3856 | | #ifdef LOG_MMC |
| 3857 | | logerror("mapper93_w %04x:%02x\n", offset, data); |
| 3858 | | #endif |
| 3782 | LOG_MMC(("mapper93_w %04x:%02x\n", offset, data)); |
| 3783 | |
| 3859 | 3784 | /* The high nibble appears to be the same prg bank as */ |
| 3860 | 3785 | /* was written to the mid-area mapper */ |
| 3861 | 3786 | } |
| 3862 | 3787 | |
| 3863 | 3788 | static WRITE8_HANDLER( mapper94_w ) |
| 3864 | 3789 | { |
| 3865 | | #ifdef LOG_MMC |
| 3866 | | logerror("mapper94_w %04x:%02x\n", offset, data); |
| 3867 | | #endif |
| 3790 | LOG_MMC(("mapper94_w %04x:%02x\n", offset, data)); |
| 3868 | 3791 | |
| 3869 | 3792 | prg16_89ab (data >> 2); |
| 3870 | 3793 | } |
| 3871 | 3794 | |
| 3872 | 3795 | static WRITE8_HANDLER( mapper95_w ) |
| 3873 | 3796 | { |
| 3874 | | #ifdef LOG_MMC |
| 3875 | | logerror("mapper95_w %04x:%02x\n", offset, data); |
| 3876 | | #endif |
| 3797 | LOG_MMC(("mapper95_w %04x:%02x\n", offset, data)); |
| 3877 | 3798 | |
| 3878 | 3799 | switch (offset) |
| 3879 | 3800 | { |
| r1470 | r1471 | |
| 3905 | 3826 | } |
| 3906 | 3827 | static WRITE8_HANDLER( mapper101_m_w ) |
| 3907 | 3828 | { |
| 3908 | | #ifdef LOG_MMC |
| 3909 | | logerror("mapper101_m_w %04x:%02x\n", offset, data); |
| 3910 | | #endif |
| 3829 | LOG_MMC(("mapper101_m_w %04x:%02x\n", offset, data)); |
| 3911 | 3830 | |
| 3912 | 3831 | chr8 (data); |
| 3913 | 3832 | } |
| 3914 | 3833 | |
| 3915 | 3834 | static WRITE8_HANDLER( mapper101_w ) |
| 3916 | 3835 | { |
| 3917 | | #ifdef LOG_MMC |
| 3918 | | logerror("mapper101_w %04x:%02x\n", offset, data); |
| 3919 | | #endif |
| 3836 | LOG_MMC(("mapper101_w %04x:%02x\n", offset, data)); |
| 3920 | 3837 | |
| 3921 | 3838 | /* ??? */ |
| 3922 | 3839 | } |
| 3923 | 3840 | static WRITE8_HANDLER( mapper113_l_w ) |
| 3924 | 3841 | { |
| 3925 | | #ifdef LOG_MMC |
| 3926 | | logerror("mapper113_w %04x:%02x\n", offset, data); |
| 3927 | | #endif |
| 3842 | LOG_MMC(("mapper113_w %04x:%02x\n", offset, data)); |
| 3843 | |
| 3928 | 3844 | //I think this is the right value |
| 3929 | 3845 | if(offset>0xFF) |
| 3930 | 3846 | return; |
| r1470 | r1471 | |
| 3933 | 3849 | } |
| 3934 | 3850 | static WRITE8_HANDLER( mapper133_l_w ) |
| 3935 | 3851 | { |
| 3936 | | #ifdef LOG_MMC |
| 3937 | | logerror("mapper133_w %04x:%02x\n", offset, data); |
| 3938 | | #endif |
| 3852 | LOG_MMC(("mapper133_w %04x:%02x\n", offset, data)); |
| 3853 | |
| 3939 | 3854 | //I think this is the right value |
| 3940 | 3855 | if(offset!=0x20) |
| 3941 | 3856 | return; |
| r1470 | r1471 | |
| 3951 | 3866 | |
| 3952 | 3867 | static WRITE8_HANDLER( mapper144_w ) |
| 3953 | 3868 | { |
| 3954 | | #ifdef LOG_MMC |
| 3955 | | logerror("* Mapper 144 switch, data: %02x\n", data); |
| 3956 | | #endif |
| 3869 | LOG_MMC(("* Mapper 144 switch, data: %02x\n", data)); |
| 3957 | 3870 | |
| 3958 | 3871 | //just like mapper 11, except bit 0 taken from ROM |
| 3959 | 3872 | //and 0x8000 ignored? |
| r1470 | r1471 | |
| 3971 | 3884 | } |
| 3972 | 3885 | static WRITE8_HANDLER( mapper180_w ) |
| 3973 | 3886 | { |
| 3974 | | #ifdef LOG_MMC |
| 3975 | | logerror("* Mapper 180 switch, data: %02x\n", data); |
| 3976 | | #endif |
| 3887 | LOG_MMC(("* Mapper 180 switch, data: %02x\n", data)); |
| 3977 | 3888 | |
| 3978 | 3889 | prg16_cdef(data&7); |
| 3979 | 3890 | } |
| 3980 | 3891 | static WRITE8_HANDLER( mapper184_m_w ) |
| 3981 | 3892 | { |
| 3982 | | #ifdef LOG_MMC |
| 3983 | | logerror("* Mapper 184 switch, data: %02x\n", data); |
| 3984 | | #endif |
| 3893 | LOG_MMC(("* Mapper 184 switch, data: %02x\n", data)); |
| 3985 | 3894 | |
| 3986 | 3895 | if(0==offset) |
| 3987 | 3896 | { |
| r1470 | r1471 | |
| 3996 | 3905 | int size_16; |
| 3997 | 3906 | int bank; |
| 3998 | 3907 | |
| 3999 | | #ifdef LOG_MMC |
| 4000 | | logerror ("mapper225_w, offset: %04x, data: %02x\n", offset, data); |
| 4001 | | #endif |
| 3908 | LOG_MMC(("mapper225_w, offset: %04x, data: %02x\n", offset, data)); |
| 4002 | 3909 | |
| 4003 | 3910 | chr8 (offset & 0x3f); |
| 4004 | 3911 | hi_bank = offset & 0x40; |
| r1470 | r1471 | |
| 4029 | 3936 | int bank; |
| 4030 | 3937 | static int reg0, reg1; |
| 4031 | 3938 | |
| 4032 | | #ifdef LOG_MMC |
| 4033 | | logerror ("mapper226_w, offset: %04x, data: %02x\n", offset, data); |
| 4034 | | #endif |
| 3939 | LOG_MMC(("mapper226_w, offset: %04x, data: %02x\n", offset, data)); |
| 4035 | 3940 | |
| 4036 | 3941 | if (offset & 0x01) |
| 4037 | 3942 | { |
| r1470 | r1471 | |
| 4070 | 3975 | int size_32; |
| 4071 | 3976 | int bank; |
| 4072 | 3977 | |
| 4073 | | #ifdef LOG_MMC |
| 4074 | | logerror ("mapper227_w, offset: %04x, data: %02x\n", offset, data); |
| 4075 | | #endif |
| 3978 | LOG_MMC(("mapper227_w, offset: %04x, data: %02x\n", offset, data)); |
| 4076 | 3979 | |
| 4077 | 3980 | hi_bank = offset & 0x04; |
| 4078 | 3981 | size_32 = offset & 0x01; |
| r1470 | r1471 | |
| 4110 | 4013 | int bank; |
| 4111 | 4014 | int chr; |
| 4112 | 4015 | |
| 4113 | | #ifdef LOG_MMC |
| 4114 | | logerror ("mapper228_w, offset: %04x, data: %02x\n", offset, data); |
| 4115 | | #endif |
| 4016 | LOG_MMC(("mapper228_w, offset: %04x, data: %02x\n", offset, data)); |
| 4116 | 4017 | |
| 4117 | 4018 | /* Determine low 4 bits of program bank */ |
| 4118 | 4019 | bank = (offset & 0x780) >> 7; |
| r1470 | r1471 | |
| 4160 | 4061 | |
| 4161 | 4062 | static WRITE8_HANDLER( mapper229_w ) |
| 4162 | 4063 | { |
| 4163 | | #ifdef LOG_MMC |
| 4164 | | logerror ("mapper229_w, offset: %04x, data: %02x\n", offset, data); |
| 4165 | | #endif |
| 4064 | LOG_MMC(("mapper229_w, offset: %04x, data: %02x\n", offset, data)); |
| 4166 | 4065 | |
| 4167 | 4066 | if (offset & 0x20) |
| 4168 | 4067 | ppu2c0x_set_mirroring(0, PPU_MIRROR_HORZ); |
| r1470 | r1471 | |
| 4186 | 4085 | { |
| 4187 | 4086 | int bank; |
| 4188 | 4087 | |
| 4189 | | #ifdef LOG_MMC |
| 4190 | | logerror("mapper231_w, offset: %04x, data: %02x\n", offset, data); |
| 4191 | | #endif |
| 4088 | LOG_MMC(("mapper231_w, offset: %04x, data: %02x\n", offset, data)); |
| 4192 | 4089 | |
| 4193 | 4090 | bank = (data & 0x03) | ((data & 0x80) >> 5); |
| 4194 | 4091 | prg32 (bank); |
src/mess/machine/thomson.c
| r1470 | r1471 | |
| 37 | 37 | |
| 38 | 38 | #define PRINT(x) mame_printf_info x |
| 39 | 39 | |
| 40 | | #if VERBOSE |
| 41 | | #define LOG(x) logerror x |
| 42 | | #else |
| 43 | | #define LOG(x) |
| 44 | | #endif |
| 40 | #define LOG(x) do { if (VERBOSE) logerror x; } while (0) |
| 41 | #define LOG_IRQ(x) do { if (VERBOSE_IRQ) logerror x; } while (0) |
| 42 | #define LOG_KBD(x) do { if (VERBOSE_KBD) logerror x; } while (0) |
| 43 | #define LOG_BANK(x) do { if (VERBOSE_BANK) logerror x; } while (0) |
| 44 | #define LOG_VIDEO(x) do { if (VERBOSE_VIDEO) logerror x; } while (0) |
| 45 | #define LOG_IO(x) do { if (VERBOSE_IO) logerror x; } while (0) |
| 46 | #define LOG_MIDI(x) do { if (VERBOSE_MIDI) logerror x; } while (0) |
| 45 | 47 | |
| 46 | | |
| 47 | 48 | /*************************** utilities ********************************/ |
| 48 | 49 | |
| 49 | 50 | |
| r1470 | r1471 | |
| 61 | 62 | |
| 62 | 63 | static void thom_set_irq ( int line, int state ) |
| 63 | 64 | { |
| 64 | | |
| 65 | | #if VERBOSE_IRQ |
| 66 | 65 | int old = thom_irq; |
| 67 | | #endif |
| 68 | 66 | |
| 69 | 67 | if ( state ) |
| 70 | 68 | thom_irq |= 1 << line; |
| 71 | 69 | else |
| 72 | 70 | thom_irq &= ~(1 << line); |
| 73 | 71 | |
| 74 | | #if VERBOSE_IRQ |
| 75 | 72 | if ( !old && thom_irq ) |
| 76 | | logerror( "%f thom_set_irq: irq line up %i\n", attotime_to_double(timer_get_time()), line ); |
| 73 | LOG_IRQ(( "%f thom_set_irq: irq line up %i\n", attotime_to_double(timer_get_time()), line )); |
| 77 | 74 | if ( old && !thom_irq ) |
| 78 | | logerror( "%f thom_set_irq: irq line down %i\n", attotime_to_double(timer_get_time()), line ); |
| 79 | | #endif |
| 75 | LOG_IRQ(( "%f thom_set_irq: irq line down %i\n", attotime_to_double(timer_get_time()), line )); |
| 80 | 76 | |
| 81 | 77 | cpunum_set_input_line( 0, M6809_IRQ_LINE, thom_irq ? ASSERT_LINE : CLEAR_LINE ); |
| 82 | 78 | } |
| r1470 | r1471 | |
| 85 | 81 | |
| 86 | 82 | static void thom_set_firq ( int line, int state ) |
| 87 | 83 | { |
| 88 | | |
| 89 | | #if VERBOSE_IRQ |
| 90 | 84 | int old = thom_irq; |
| 91 | | #endif |
| 92 | 85 | |
| 93 | 86 | if ( state ) |
| 94 | 87 | thom_firq |= 1 << line; |
| 95 | 88 | else |
| 96 | 89 | thom_firq &= ~(1 << line); |
| 97 | 90 | |
| 98 | | #if VERBOSE_IRQ |
| 99 | 91 | if ( !old && thom_firq ) |
| 100 | | logerror( "%f thom_set_firq: firq line up %i\n", attotime_to_double(timer_get_time()), line ); |
| 92 | LOG_IRQ(( "%f thom_set_firq: firq line up %i\n", attotime_to_double(timer_get_time()), line )); |
| 101 | 93 | if ( old && !thom_firq ) |
| 102 | | logerror( "%f thom_set_firq: firq line down %i\n", attotime_to_double(timer_get_time()), line ); |
| 103 | | #endif |
| 94 | LOG_IRQ(( "%f thom_set_firq: firq line down %i\n", attotime_to_double(timer_get_time()), line )); |
| 104 | 95 | |
| 105 | 96 | cpunum_set_input_line( 0, M6809_FIRQ_LINE, thom_firq ? ASSERT_LINE : CLEAR_LINE ); |
| 106 | 97 | } |
| r1470 | r1471 | |
| 328 | 319 | memory_install_read8_handler( 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x0003, 0, 0, to7_cartridge_r ); |
| 329 | 320 | } |
| 330 | 321 | |
| 331 | | #if VERBOSE_BANK |
| 332 | 322 | if ( bank != old_bank ) |
| 333 | | logerror( "to7_update_cart_bank: CART is cartridge bank %i\n", bank ); |
| 334 | | #endif |
| 323 | LOG_BANK(( "to7_update_cart_bank: CART is cartridge bank %i\n", bank )); |
| 335 | 324 | |
| 336 | 325 | memory_set_bank( THOM_CART_BANK, bank ); |
| 337 | 326 | old_bank = bank; |
| r1470 | r1471 | |
| 426 | 415 | if ( ! to7_lightpen ) |
| 427 | 416 | return; |
| 428 | 417 | |
| 429 | | #if VERBOSE_VIDEO |
| 430 | | logerror( "%f to7_lightpen_cb: step=%i\n", attotime_to_double(timer_get_time()), step ); |
| 431 | | #endif |
| 432 | | |
| 418 | LOG_VIDEO(( "%f to7_lightpen_cb: step=%i\n", attotime_to_double(timer_get_time()), step )); |
| 433 | 419 | pia_set_input_cb1( THOM_PIA_SYS, 1 ); |
| 434 | 420 | pia_set_input_cb1( THOM_PIA_SYS, 0 ); |
| 435 | 421 | to7_lightpen_step = step; |
| r1470 | r1471 | |
| 445 | 431 | { |
| 446 | 432 | /* INIT signal wired to system PIA 6821 */ |
| 447 | 433 | |
| 448 | | #if VERBOSE_VIDEO |
| 449 | | logerror( "%f to7_set_init: init=%i\n", attotime_to_double(timer_get_time()), init ); |
| 450 | | #endif |
| 451 | | |
| 434 | LOG_VIDEO(( "%f to7_set_init: init=%i\n", attotime_to_double(timer_get_time()), init )); |
| 452 | 435 | pia_set_input_ca1( THOM_PIA_SYS, init ); |
| 453 | 436 | } |
| 454 | 437 | |
| r1470 | r1471 | |
| 570 | 553 | int tx = data & 1; |
| 571 | 554 | int dtr = ( data & 2 ) ? 1 : 0; |
| 572 | 555 | |
| 573 | | #if VERBOSE_IO |
| 574 | | logerror( "$%04x %f to7_io_porta_out: tx=%i, dtr=%i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), tx, dtr ); |
| 575 | | #endif |
| 576 | | |
| 556 | LOG_IO(( "$%04x %f to7_io_porta_out: tx=%i, dtr=%i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), tx, dtr )); |
| 577 | 557 | if ( dtr ) |
| 578 | 558 | to7_io_line.State |= SERIAL_STATE_DTR; |
| 579 | 559 | else |
| r1470 | r1471 | |
| 596 | 576 | else |
| 597 | 577 | cts = ( centronics_read_handshake( 0 ) & CENTRONICS_NOT_BUSY ) ? 1 : 0; |
| 598 | 578 | |
| 599 | | #if VERBOSE_IO |
| 600 | | logerror( "$%04x %f to7_io_porta_in: mode=%i cts=%i, dsr=%i, rd=%i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), to7_io_mode(), cts, dsr, rd ); |
| 601 | | #endif |
| 579 | LOG_IO(( "$%04x %f to7_io_porta_in: mode=%i cts=%i, dsr=%i, rd=%i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), to7_io_mode(), cts, dsr, rd )); |
| 602 | 580 | |
| 603 | 581 | return (dsr ? 0x20 : 0) | (cts ? 0x40 : 0) | (rd ? 0x80: 0); |
| 604 | 582 | } |
| r1470 | r1471 | |
| 609 | 587 | { |
| 610 | 588 | /* set 8-bit data */ |
| 611 | 589 | |
| 612 | | #if VERBOSE_IO |
| 613 | | logerror( "$%04x %f to7_io_portb_out: CENTRONICS set data=$%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data ); |
| 614 | | #endif |
| 590 | LOG_IO(( "$%04x %f to7_io_portb_out: CENTRONICS set data=$%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data )); |
| 615 | 591 | |
| 616 | 592 | centronics_write_data( 0, data ); |
| 617 | 593 | } |
| r1470 | r1471 | |
| 620 | 596 | |
| 621 | 597 | static WRITE8_HANDLER ( to7_io_cb2_out ) |
| 622 | 598 | { |
| 623 | | /* send STROBE to printer */ |
| 599 | /* send STROBE to printer */ |
| 624 | 600 | |
| 625 | | #if VERBOSE_IO |
| 626 | | logerror( "$%04x %f to7_io_cb2_out: CENTRONICS set strobe=%i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data ); |
| 627 | | #endif |
| 601 | LOG_IO(( "$%04x %f to7_io_cb2_out: CENTRONICS set strobe=%i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data )); |
| 628 | 602 | |
| 629 | 603 | centronics_write_handshake( 0, data ? CENTRONICS_STROBE : 0, CENTRONICS_STROBE ); |
| 630 | 604 | } |
| r1470 | r1471 | |
| 636 | 610 | /* our peer's state has changed */ |
| 637 | 611 | to7_io_line.input_state = state; |
| 638 | 612 | |
| 639 | | #if VERBOSE_IO |
| 640 | | logerror( "%f to7_io_in_callback: cts=%i dsr=%i rd=%i\n", attotime_to_double(timer_get_time()), (state & SERIAL_STATE_CTS) ? 1 : 0, (state & SERIAL_STATE_DSR) ? 1 : 0, (int)get_in_data_bit( state ) ); |
| 641 | | #endif |
| 642 | | |
| 613 | LOG_IO(( "%f to7_io_in_callback: cts=%i dsr=%i rd=%i\n", attotime_to_double(timer_get_time()), (state & SERIAL_STATE_CTS) ? 1 : 0, (state & SERIAL_STATE_DSR) ? 1 : 0, (int)get_in_data_bit( state ) )); |
| 643 | 614 | } |
| 644 | 615 | |
| 645 | 616 | |
| r1470 | r1471 | |
| 741 | 712 | |
| 742 | 713 | static void to7_modem_cb( int state ) |
| 743 | 714 | { |
| 744 | | #if VERBOSE_IO |
| 745 | | logerror ( "to7_modem_cb: called %i\n", state ); |
| 746 | | #endif |
| 715 | LOG(( "to7_modem_cb: called %i\n", state )); |
| 747 | 716 | } |
| 748 | 717 | |
| 749 | 718 | |
| r1470 | r1471 | |
| 1114 | 1083 | /* bit 5: overrun */ |
| 1115 | 1084 | /* bit 6: parity error (ignored) */ |
| 1116 | 1085 | /* bit 7: interrupt */ |
| 1117 | | #if VERBOSE_MIDI |
| 1118 | | logerror( "$%04x %f to7_midi_r: status $%02X (rdrf=%i, tdre=%i, ovrn=%i, irq=%i)\n", |
| 1086 | LOG_MIDI(( "$%04x %f to7_midi_r: status $%02X (rdrf=%i, tdre=%i, ovrn=%i, irq=%i)\n", |
| 1119 | 1087 | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), to7_midi_status, |
| 1120 | 1088 | (to7_midi_status & ACIA_6850_RDRF) ? 1 : 0, |
| 1121 | 1089 | (to7_midi_status & ACIA_6850_TDRE) ? 1 : 0, |
| 1122 | 1090 | (to7_midi_status & ACIA_6850_OVRN) ? 1 : 0, |
| 1123 | | (to7_midi_status & ACIA_6850_irq) ? 1 : 0 ); |
| 1124 | | #endif |
| 1091 | (to7_midi_status & ACIA_6850_irq) ? 1 : 0 )); |
| 1125 | 1092 | return to7_midi_status; |
| 1126 | 1093 | |
| 1127 | 1094 | |
| r1470 | r1471 | |
| 1134 | 1101 | else |
| 1135 | 1102 | to7_midi_status &= ~ACIA_6850_OVRN; |
| 1136 | 1103 | to7_midi_overrun = 0; |
| 1137 | | #if VERBOSE_MIDI |
| 1138 | | logerror( "$%04x %f to7_midi_r: read data $%02X\n", |
| 1139 | | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data ); |
| 1140 | | #endif |
| 1104 | LOG_MIDI(( "$%04x %f to7_midi_r: read data $%02X\n", |
| 1105 | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data )); |
| 1141 | 1106 | to7_midi_update_irq(); |
| 1142 | 1107 | return data; |
| 1143 | 1108 | } |
| r1470 | r1471 | |
| 1164 | 1129 | if ( (data & 3) == 3 ) |
| 1165 | 1130 | { |
| 1166 | 1131 | /* reset */ |
| 1167 | | #if VERBOSE_MIDI |
| 1168 | | logerror( "$%04x %f to7_midi_w: reset (data=$%02X)\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data ); |
| 1169 | | #endif |
| 1132 | LOG_MIDI(( "$%04x %f to7_midi_w: reset (data=$%02X)\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data )); |
| 1170 | 1133 | to7_midi_overrun = 0; |
| 1171 | 1134 | to7_midi_status = 2; |
| 1172 | 1135 | to7_midi_intr = 0; |
| r1470 | r1471 | |
| 1178 | 1141 | /* bits 5-6: interrupt on transmit */ |
| 1179 | 1142 | /* bit 7: interrupt on receive */ |
| 1180 | 1143 | to7_midi_intr = data >> 5; |
| 1181 | | #if VERBOSE_MIDI |
| 1182 | 1144 | { |
| 1183 | 1145 | static const int bits[8] = { 7,7,7,7,8,8,8,8 }; |
| 1184 | 1146 | static const int stop[8] = { 2,2,1,1,2,1,1,1 }; |
| 1185 | 1147 | static const char parity[8] = { 'e','o','e','o','-','-','e','o' }; |
| 1186 | | logerror( "$%04x %f to7_midi_w: set control to $%02X (bits=%i, stop=%i, parity=%c, intr in=%i out=%i)\n", |
| 1148 | LOG_MIDI(( "$%04x %f to7_midi_w: set control to $%02X (bits=%i, stop=%i, parity=%c, intr in=%i out=%i)\n", |
| 1187 | 1149 | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), |
| 1188 | 1150 | data, |
| 1189 | 1151 | bits[ (data >> 2) & 7 ], |
| 1190 | 1152 | stop[ (data >> 2) & 7 ], |
| 1191 | 1153 | parity[ (data >> 2) & 7 ], |
| 1192 | 1154 | to7_midi_intr >> 2, |
| 1193 | | (to7_midi_intr & 3) ? 1 : 0); |
| 1155 | (to7_midi_intr & 3) ? 1 : 0)); |
| 1194 | 1156 | } |
| 1195 | | #endif |
| 1196 | 1157 | } |
| 1197 | 1158 | to7_midi_update_irq(); |
| 1198 | 1159 | break; |
| 1199 | 1160 | |
| 1200 | 1161 | |
| 1201 | 1162 | case 1: /* output data */ |
| 1202 | | #if VERBOSE_MIDI |
| 1203 | | logerror( "$%04x %f to7_midi_w: write data $%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data ); |
| 1204 | | #endif |
| 1163 | LOG_MIDI(( "$%04x %f to7_midi_w: write data $%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data )); |
| 1205 | 1164 | if ( data == 0x55 ) |
| 1206 | 1165 | /* cable-detect: shortcut */ |
| 1207 | 1166 | chardev_fake_in( to7_midi_chardev, 0x55 ); |
| r1470 | r1471 | |
| 1430 | 1389 | return; |
| 1431 | 1390 | } |
| 1432 | 1391 | |
| 1433 | | #if VERBOSE_BANK |
| 1434 | 1392 | if ( bank != old_bank ) |
| 1435 | | logerror( "to770_update_ram_bank: RAM bank change %i\n", bank ); |
| 1436 | | #endif |
| 1393 | LOG_BANK(( "to770_update_ram_bank: RAM bank change %i\n", bank )); |
| 1437 | 1394 | |
| 1438 | 1395 | memory_set_bank( THOM_RAM_BANK, bank ); |
| 1439 | 1396 | memory_install_write8_handler( 0, ADDRESS_SPACE_PROGRAM, 0xa000, 0xdfff, 0, 0, |
| r1470 | r1471 | |
| 1806 | 1763 | /* 64 KB ROM from "JANE" cartridge */ |
| 1807 | 1764 | memory_install_write8_handler( 0, ADDRESS_SPACE_PROGRAM, 0xb000, 0xefff, 0, 0, MWA8_NOP ); |
| 1808 | 1765 | bank = mo5_reg_cart & 3; |
| 1809 | | #if VERBOSE_BANK |
| 1810 | 1766 | if ( bank != old_bank ) |
| 1811 | | logerror( "mo5_update_cart_bank: CART is cartridge bank %i (A7CB style)\n", bank ); |
| 1812 | | #endif |
| 1767 | LOG_BANK(( "mo5_update_cart_bank: CART is cartridge bank %i (A7CB style)\n", bank )); |
| 1813 | 1768 | } |
| 1814 | 1769 | else if ( rom_is_ram ) |
| 1815 | 1770 | { |
| r1470 | r1471 | |
| 1818 | 1773 | bank = 4 + ( mo5_reg_cart & 3 ); |
| 1819 | 1774 | memory_install_write8_handler( 0, ADDRESS_SPACE_PROGRAM, 0xb000, 0xefff, 0, 0, write_enable ? |
| 1820 | 1775 | (write8_handler)(STATIC_BANK1 + THOM_CART_BANK - 1) : MWA8_NOP ); |
| 1821 | | #if VERBOSE_BANK |
| 1822 | 1776 | if ( bank != old_bank ) |
| 1823 | | logerror( "mo5_update_cart_bank: CART is nanonetwork RAM bank %i (write-enable=%i)\n", mo5_reg_cart & 3, write_enable ? 1 : 0 ); |
| 1824 | | #endif |
| 1777 | LOG_BANK(( "mo5_update_cart_bank: CART is nanonetwork RAM bank %i (write-enable=%i)\n", mo5_reg_cart & 3, write_enable ? 1 : 0 )); |
| 1825 | 1778 | } |
| 1826 | 1779 | else |
| 1827 | 1780 | { |
| r1470 | r1471 | |
| 1832 | 1785 | bank = thom_cart_bank % thom_cart_nb_banks; |
| 1833 | 1786 | memory_install_read8_handler( 0, ADDRESS_SPACE_PROGRAM, 0xbffc, 0xbfff, 0, 0, mo5_cartridge_r ); |
| 1834 | 1787 | } |
| 1835 | | #if VERBOSE_BANK |
| 1836 | 1788 | if ( bank != old_bank ) |
| 1837 | | logerror( "mo5_update_cart_bank: CART is internal / cartridge bank %i\n", thom_cart_bank ); |
| 1838 | | #endif |
| 1789 | LOG_BANK(( "mo5_update_cart_bank: CART is internal / cartridge bank %i\n", thom_cart_bank )); |
| 1839 | 1790 | } |
| 1840 | 1791 | memory_set_bank( THOM_CART_BANK, bank ); |
| 1841 | 1792 | old_bank = bank; |
| r1470 | r1471 | |
| 2102 | 2053 | |
| 2103 | 2054 | WRITE8_HANDLER ( to9_vreg_w ) |
| 2104 | 2055 | { |
| 2105 | | #if VERBOSE_VIDEO |
| 2106 | | logerror( "$%04x %f to9_vreg_w: off=%i ($%04X) data=$%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), offset, 0xe7da + offset, data ); |
| 2107 | | #endif |
| 2056 | LOG_VIDEO(( "$%04x %f to9_vreg_w: off=%i ($%04X) data=$%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), offset, 0xe7da + offset, data )); |
| 2108 | 2057 | |
| 2109 | 2058 | switch ( offset ) |
| 2110 | 2059 | { |
| r1470 | r1471 | |
| 2171 | 2120 | case 0: |
| 2172 | 2121 | /* BASIC (64 KB) */ |
| 2173 | 2122 | bank = 4 + to9_soft_bank; |
| 2174 | | #if VERBOSE_BANK |
| 2175 | 2123 | if ( bank != old_bank ) |
| 2176 | | logerror( "to9_update_cart_bank: CART is BASIC bank %i\n", to9_soft_bank ); |
| 2177 | | #endif |
| 2124 | LOG_BANK(( "to9_update_cart_bank: CART is BASIC bank %i\n", to9_soft_bank )); |
| 2178 | 2125 | break; |
| 2179 | 2126 | case 1: |
| 2180 | 2127 | /* software 1 (32 KB) */ |
| 2181 | 2128 | bank = 8 + (to9_soft_bank & 1); |
| 2182 | | #if VERBOSE_BANK |
| 2183 | 2129 | if ( bank != old_bank ) |
| 2184 | | logerror( "to9_update_cart_bank: CART is software 1 bank %i\n", to9_soft_bank ); |
| 2185 | | #endif |
| 2130 | LOG_BANK(( "to9_update_cart_bank: CART is software 1 bank %i\n", to9_soft_bank )); |
| 2186 | 2131 | break; |
| 2187 | 2132 | case 2: |
| 2188 | 2133 | /* software 2 (32 KB) */ |
| 2189 | 2134 | bank = 10 + (to9_soft_bank & 1); |
| 2190 | | #if VERBOSE_BANK |
| 2191 | 2135 | if ( bank != old_bank ) |
| 2192 | | logerror( "to9_update_cart_bank: CART is software 2 bank %i\n", to9_soft_bank ); |
| 2193 | | #endif |
| 2136 | LOG_BANK(( "to9_update_cart_bank: CART is software 2 bank %i\n", to9_soft_bank )); |
| 2194 | 2137 | break; |
| 2195 | 2138 | case 3: |
| 2196 | 2139 | /* external cartridge */ |
| r1470 | r1471 | |
| 2199 | 2142 | bank = thom_cart_bank % thom_cart_nb_banks; |
| 2200 | 2143 | memory_install_read8_handler( 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x0003, 0, 0, to7_cartridge_r ); |
| 2201 | 2144 | } |
| 2202 | | #if VERBOSE_BANK |
| 2203 | 2145 | if ( bank != old_bank ) |
| 2204 | | logerror( "to9_update_cart_bank: CART is cartridge bank %i\n", thom_cart_bank ); |
| 2205 | | #endif |
| 2146 | LOG_BANK(( "to9_update_cart_bank: CART is cartridge bank %i\n", thom_cart_bank )); |
| 2206 | 2147 | break; |
| 2207 | 2148 | } |
| 2208 | 2149 | |
| r1470 | r1471 | |
| 2270 | 2211 | return; |
| 2271 | 2212 | } |
| 2272 | 2213 | |
| 2273 | | #if VERBOSE_BANK |
| 2274 | 2214 | if ( old_bank != bank ) |
| 2275 | | logerror( "to9_update_ram_bank: bank %i selected (pia=$%02X disk=%i)\n", bank, portb & 0xf8, disk ); |
| 2276 | | #endif |
| 2215 | LOG_BANK(( "to9_update_ram_bank: bank %i selected (pia=$%02X disk=%i)\n", bank, portb & 0xf8, disk )); |
| 2277 | 2216 | |
| 2278 | 2217 | memory_set_bank( THOM_RAM_BANK, bank ); |
| 2279 | 2218 | memory_install_write8_handler( 0, ADDRESS_SPACE_PROGRAM, 0xa000, 0xdfff, 0, 0, |
| r1470 | r1471 | |
| 2384 | 2323 | /* bit 5: overrun */ |
| 2385 | 2324 | /* bit 6: parity error */ |
| 2386 | 2325 | /* bit 7: interrupt */ |
| 2387 | | #if VERBOSE_KBD |
| 2388 | | logerror( "$%04x %f to9_kbd_r: status $%02X (rdrf=%i, tdre=%i, ovrn=%i, pe=%i, irq=%i)\n", |
| 2326 | |
| 2327 | LOG_KBD(( "$%04x %f to9_kbd_r: status $%02X (rdrf=%i, tdre=%i, ovrn=%i, pe=%i, irq=%i)\n", |
| 2389 | 2328 | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), to9_kbd_status, |
| 2390 | 2329 | (to9_kbd_status & ACIA_6850_RDRF) ? 1 : 0, |
| 2391 | 2330 | (to9_kbd_status & ACIA_6850_TDRE) ? 1 : 0, |
| 2392 | 2331 | (to9_kbd_status & ACIA_6850_OVRN) ? 1 : 0, |
| 2393 | 2332 | (to9_kbd_status & ACIA_6850_PE) ? 1 : 0, |
| 2394 | | (to9_kbd_status & ACIA_6850_irq) ? 1 : 0 ); |
| 2395 | | #endif |
| 2333 | (to9_kbd_status & ACIA_6850_irq) ? 1 : 0 )); |
| 2396 | 2334 | return to9_kbd_status; |
| 2397 | 2335 | |
| 2398 | 2336 | case 1: /* get input data */ |
| r1470 | r1471 | |
| 2402 | 2340 | else |
| 2403 | 2341 | to9_kbd_status &= ~(ACIA_6850_OVRN | ACIA_6850_RDRF); |
| 2404 | 2342 | to9_kbd_overrun = 0; |
| 2405 | | #if VERBOSE_KBD |
| 2406 | | logerror( "$%04x %f to9_kbd_r: read data $%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), to9_kbd_in ); |
| 2407 | | #endif |
| 2343 | LOG_KBD(( "$%04x %f to9_kbd_r: read data $%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), to9_kbd_in )); |
| 2408 | 2344 | to9_kbd_update_irq(); |
| 2409 | 2345 | return to9_kbd_in; |
| 2410 | 2346 | |
| r1470 | r1471 | |
| 2431 | 2367 | to9_kbd_overrun = 0; |
| 2432 | 2368 | to9_kbd_status = ACIA_6850_TDRE; |
| 2433 | 2369 | to9_kbd_intr = 0; |
| 2434 | | #if VERBOSE_KBD |
| 2435 | | logerror( "$%04x %f to9_kbd_w: reset (data=$%02X)\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data ); |
| 2436 | | #endif |
| 2370 | LOG_KBD(( "$%04x %f to9_kbd_w: reset (data=$%02X)\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data )); |
| 2437 | 2371 | } |
| 2438 | 2372 | else |
| 2439 | 2373 | { |
| r1470 | r1471 | |
| 2445 | 2379 | /* bits 5-6: interrupt on transmit */ |
| 2446 | 2380 | /* bit 7: interrupt on receive */ |
| 2447 | 2381 | to9_kbd_intr = data >> 5; |
| 2448 | | #if VERBOSE_KBD |
| 2449 | | logerror( "$%04x %f to9_kbd_w: set control to $%02X (parity=%i, intr in=%i out=%i)\n", |
| 2382 | |
| 2383 | LOG_KBD(( "$%04x %f to9_kbd_w: set control to $%02X (parity=%i, intr in=%i out=%i)\n", |
| 2450 | 2384 | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), |
| 2451 | 2385 | data, to9_kbd_parity, to9_kbd_intr >> 2, |
| 2452 | | (to9_kbd_intr & 3) ? 1 : 0 ); |
| 2453 | | #endif |
| 2386 | (to9_kbd_intr & 3) ? 1 : 0 )); |
| 2454 | 2387 | } |
| 2455 | 2388 | to9_kbd_update_irq(); |
| 2456 | 2389 | break; |
| r1470 | r1471 | |
| 2507 | 2440 | { |
| 2508 | 2441 | /* overrun will be set when the current valid byte is read */ |
| 2509 | 2442 | to9_kbd_overrun = 1; |
| 2510 | | #if VERBOSE_KBD |
| 2511 | | logerror( "%f to9_kbd_send: overrun => drop data=$%02X, parity=%i\n", attotime_to_double(timer_get_time()), data, parity ); |
| 2512 | | #endif |
| 2443 | LOG_KBD(( "%f to9_kbd_send: overrun => drop data=$%02X, parity=%i\n", attotime_to_double(timer_get_time()), data, parity )); |
| 2513 | 2444 | } |
| 2514 | 2445 | else |
| 2515 | 2446 | { |
| r1470 | r1471 | |
| 2520 | 2451 | to9_kbd_status &= ~ACIA_6850_PE; /* parity OK */ |
| 2521 | 2452 | else |
| 2522 | 2453 | to9_kbd_status |= ACIA_6850_PE; /* parity error */ |
| 2523 | | #if VERBOSE_KBD |
| 2524 | | logerror( "%f to9_kbd_send: data=$%02X, parity=%i, status=$%02X\n", attotime_to_double(timer_get_time()), data, parity, to9_kbd_status ); |
| 2525 | | #endif |
| 2454 | LOG_KBD(( "%f to9_kbd_send: data=$%02X, parity=%i, status=$%02X\n", attotime_to_double(timer_get_time()), data, parity, to9_kbd_status )); |
| 2526 | 2455 | } |
| 2527 | 2456 | to9_kbd_update_irq(); |
| 2528 | 2457 | } |
| r1470 | r1471 | |
| 2639 | 2568 | to9_kbd_key_count++; |
| 2640 | 2569 | if ( to9_kbd_key_count < TO9_KBD_REPEAT_DELAY || (to9_kbd_key_count - TO9_KBD_REPEAT_DELAY) % TO9_KBD_REPEAT_PERIOD ) |
| 2641 | 2570 | return 0; |
| 2642 | | #if VERBOSE_KBD |
| 2643 | | logerror( "to9_kbd_get_key: repeat key $%02X '%c'\n", asc, asc ); |
| 2644 | | #endif |
| 2571 | LOG_KBD(( "to9_kbd_get_key: repeat key $%02X '%c'\n", asc, asc )); |
| 2645 | 2572 | return asc; |
| 2646 | 2573 | } |
| 2647 | 2574 | else { |
| 2648 | 2575 | to9_kbd_last_key = key; |
| 2649 | 2576 | to9_kbd_key_count = 0; |
| 2650 | | #if VERBOSE_KBD |
| 2651 | | logerror( "to9_kbd_get_key: key down $%02X '%c'\n", asc, asc ); |
| 2652 | | #endif |
| 2577 | LOG_KBD(( "to9_kbd_get_key: key down $%02X '%c'\n", asc, asc )); |
| 2653 | 2578 | return asc; |
| 2654 | 2579 | } |
| 2655 | 2580 | } |
| r1470 | r1471 | |
| 2768 | 2693 | centronics_write_data( 0, data ); |
| 2769 | 2694 | centronics_write_handshake( 0, (b & 2) ? CENTRONICS_STROBE : 0, CENTRONICS_STROBE ); |
| 2770 | 2695 | |
| 2771 | | #if VERBOSE_IO |
| 2772 | | logerror( "$%04x %f to9_update_centronics: data=$%02X strobe=%i\n", |
| 2696 | LOG_IO(( "$%04x %f to9_update_centronics: data=$%02X strobe=%i\n", |
| 2773 | 2697 | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data, |
| 2774 | | (b & 2) ? 1 : 0 ); |
| 2775 | | #endif |
| 2698 | (b & 2) ? 1 : 0 )); |
| 2776 | 2699 | } |
| 2777 | 2700 | |
| 2778 | 2701 | |
| r1470 | r1471 | |
| 2781 | 2704 | { |
| 2782 | 2705 | UINT8 ktest = to9_kbd_ktest(); |
| 2783 | 2706 | |
| 2784 | | #if VERBOSE_KBD |
| 2785 | | logerror( "to9_sys_porta_in: ktest=%i\n", ktest ); |
| 2786 | | #endif |
| 2707 | LOG_KBD(( "to9_sys_porta_in: ktest=%i\n", ktest )); |
| 2787 | 2708 | |
| 2788 | 2709 | return ktest; |
| 2789 | 2710 | } |
| r1470 | r1471 | |
| 2802 | 2723 | to9_update_centronics(); /* bits 0-1: printer */ |
| 2803 | 2724 | to9_update_ram_bank(); |
| 2804 | 2725 | |
| 2805 | | #if VERBOSE |
| 2806 | 2726 | if ( data & 4 ) /* bit 2: video overlay (TODO) */ |
| 2807 | | logerror( "to9_sys_portb_out: video overlay not handled\n" ); |
| 2808 | | #endif |
| 2727 | LOG(( "to9_sys_portb_out: video overlay not handled\n" )); |
| 2809 | 2728 | } |
| 2810 | 2729 | |
| 2811 | 2730 | |
| r1470 | r1471 | |
| 3085 | 3004 | { |
| 3086 | 3005 | attotime d; |
| 3087 | 3006 | |
| 3088 | | #if VERBOSE_KBD |
| 3089 | | logerror( "%f to8_kbd_timer_cb: step=%i ack=%i data=$%03X\n", attotime_to_double(timer_get_time()), to8_kbd_step, to8_kbd_ack, to8_kbd_data ); |
| 3090 | | #endif |
| 3007 | LOG_KBD(( "%f to8_kbd_timer_cb: step=%i ack=%i data=$%03X\n", attotime_to_double(timer_get_time()), to8_kbd_step, to8_kbd_ack, to8_kbd_data )); |
| 3091 | 3008 | |
| 3092 | 3009 | if( ! to8_kbd_step ) |
| 3093 | 3010 | { |
| r1470 | r1471 | |
| 3105 | 3022 | else |
| 3106 | 3023 | { |
| 3107 | 3024 | /* got key! */ |
| 3108 | | #if VERBOSE_KBD |
| 3109 | | logerror( "to8_kbd_timer_cb: got key $%03X\n", k ); |
| 3110 | | #endif |
| 3025 | LOG_KBD(( "to8_kbd_timer_cb: got key $%03X\n", k )); |
| 3111 | 3026 | to8_kbd_data = k; |
| 3112 | 3027 | to8_kbd_step = 1; |
| 3113 | 3028 | d = ATTOTIME_IN_USEC( 100 ); |
| r1470 | r1471 | |
| 3174 | 3089 | if ( data ) |
| 3175 | 3090 | { |
| 3176 | 3091 | double len = attotime_to_double(timer_timeelapsed( to8_kbd_signal )) * 1000. - 2.; |
| 3177 | | #if VERBOSE_KBD |
| 3178 | | logerror( "%f to8_kbd_set_ack: CPU end ack, len=%f\n", attotime_to_double(timer_get_time()), len ); |
| 3179 | | #endif |
| 3092 | LOG_KBD(( "%f to8_kbd_set_ack: CPU end ack, len=%f\n", attotime_to_double(timer_get_time()), len )); |
| 3180 | 3093 | if ( to8_kbd_data == 0xfff ) |
| 3181 | 3094 | { |
| 3182 | 3095 | /* end signal from CPU */ |
| r1470 | r1471 | |
| 3232 | 3145 | timer_adjust( to8_kbd_timer, ATTOTIME_IN_USEC( 400 ), 0, attotime_never ); |
| 3233 | 3146 | timer_adjust( to8_kbd_signal, attotime_never, 0, attotime_never ); |
| 3234 | 3147 | } |
| 3235 | | #if VERBOSE_KBD |
| 3236 | | logerror( "%f to8_kbd_set_ack: CPU ack, data=$%03X\n", attotime_to_double(timer_get_time()), to8_kbd_data ); |
| 3237 | | #endif |
| 3148 | LOG_KBD(( "%f to8_kbd_set_ack: CPU ack, data=$%03X\n", attotime_to_double(timer_get_time()), to8_kbd_data )); |
| 3238 | 3149 | } |
| 3239 | 3150 | } |
| 3240 | 3151 | |
| r1470 | r1471 | |
| 3285 | 3196 | { |
| 3286 | 3197 | static int old_bank = -1; |
| 3287 | 3198 | int bank = (to8_reg_sys1 & 0x80) ? to7_floppy_bank : (to8_bios_bank + TO7_NB_FLOP_BANK); |
| 3288 | | #if VERBOSE_BANK |
| 3199 | |
| 3289 | 3200 | if ( bank != old_bank ) |
| 3290 | | logerror( "to8_update_floppy_bank: floppy ROM is %s bank %i\n", |
| 3201 | LOG_BANK(( "to8_update_floppy_bank: floppy ROM is %s bank %i\n", |
| 3291 | 3202 | (to8_reg_sys1 & 0x80) ? "external" : "internal", |
| 3292 | | bank % TO7_NB_FLOP_BANK ); |
| 3293 | | #endif |
| 3203 | bank % TO7_NB_FLOP_BANK )); |
| 3294 | 3204 | memory_set_bank( THOM_FLOP_BANK, bank ); |
| 3295 | 3205 | old_bank = bank; |
| 3296 | 3206 | } |
| r1470 | r1471 | |
| 3304 | 3214 | if ( to8_reg_sys1 & 0x10 ) |
| 3305 | 3215 | { |
| 3306 | 3216 | bank = to8_reg_ram & 31; |
| 3307 | | #if VERBOSE_BANK |
| 3308 | 3217 | if ( bank != to8_data_vpage ) |
| 3309 | | logerror( "to8_update_ram_bank: select bank %i (new style)\n", bank ); |
| 3310 | | #endif |
| 3218 | LOG_BANK(( "to8_update_ram_bank: select bank %i (new style)\n", bank )); |
| 3311 | 3219 | } |
| 3312 | 3220 | else |
| 3313 | 3221 | { |
| r1470 | r1471 | |
| 3327 | 3235 | logerror( "to8_update_ram_bank: unknown RAM bank=$%02X\n", portb & 0xf8 ); |
| 3328 | 3236 | return; |
| 3329 | 3237 | } |
| 3330 | | #if VERBOSE_BANK |
| 3331 | 3238 | if ( bank != to8_data_vpage ) |
| 3332 | | logerror( "to8_update_ram_bank: select bank %i (old style)\n", bank ); |
| 3333 | | #endif |
| 3239 | LOG_BANK(( "to8_update_ram_bank: select bank %i (old style)\n", bank )); |
| 3334 | 3240 | } |
| 3335 | 3241 | |
| 3336 | 3242 | /* due to adressing distortion, the 16 KB banked memory space is |
| r1470 | r1471 | |
| 3375 | 3281 | (to8_cart_vpage <= 4) ? to8_vcart_w : |
| 3376 | 3282 | (write8_handler)(STATIC_BANK1 + THOM_CART_BANK - 1) : |
| 3377 | 3283 | MWA8_NOP ); |
| 3378 | | #if VERBOSE_BANK |
| 3379 | 3284 | if ( bank != old_bank ) |
| 3380 | | logerror( "to8_update_cart_bank: CART is RAM bank %i (write-enable=%i)\n", to8_cart_vpage, (to8_reg_cart & 0x40) ? 1 : 0 ); |
| 3381 | | #endif |
| 3285 | LOG_BANK(( "to8_update_cart_bank: CART is RAM bank %i (write-enable=%i)\n", to8_cart_vpage, (to8_reg_cart & 0x40) ? 1 : 0 )); |
| 3382 | 3286 | } |
| 3383 | 3287 | else |
| 3384 | 3288 | { |
| r1470 | r1471 | |
| 3387 | 3291 | { |
| 3388 | 3292 | /* internal software ROM space */ |
| 3389 | 3293 | bank = 4 + to8_soft_bank; |
| 3390 | | #if VERBOSE_BANK |
| 3391 | 3294 | if ( bank != old_bank ) |
| 3392 | | logerror( "to8_update_cart_bank: CART is internal bank %i\n", |
| 3393 | | to8_soft_bank ); |
| 3394 | | #endif |
| 3295 | LOG_BANK(( "to8_update_cart_bank: CART is internal bank %i\n", |
| 3296 | to8_soft_bank )); |
| 3395 | 3297 | } |
| 3396 | 3298 | else |
| 3397 | 3299 | { |
| r1470 | r1471 | |
| 3403 | 3305 | |
| 3404 | 3306 | } |
| 3405 | 3307 | |
| 3406 | | #if VERBOSE_BANK |
| 3407 | 3308 | if ( bank != old_bank ) |
| 3408 | | logerror( "to8_update_cart_bank: CART is external cartridge bank %i\n", thom_cart_bank ); |
| 3409 | | #endif |
| 3309 | LOG_BANK(( "to8_update_cart_bank: CART is external cartridge bank %i\n", thom_cart_bank )); |
| 3410 | 3310 | } |
| 3411 | 3311 | } |
| 3412 | 3312 | memory_set_bank( THOM_CART_BANK, bank ); |
| r1470 | r1471 | |
| 3548 | 3448 | res = 0; |
| 3549 | 3449 | } |
| 3550 | 3450 | |
| 3551 | | #if VERBOSE_VIDEO |
| 3552 | | logerror( "$%04x %f to8_gatearray_r: off=%i ($%04X) res=$%02X lightpen=%i\n", |
| 3451 | LOG_VIDEO(( "$%04x %f to8_gatearray_r: off=%i ($%04X) res=$%02X lightpen=%i\n", |
| 3553 | 3452 | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), |
| 3554 | | offset, 0xe7e4 + offset, res, to7_lightpen ); |
| 3555 | | #endif |
| 3453 | offset, 0xe7e4 + offset, res, to7_lightpen )); |
| 3556 | 3454 | |
| 3557 | 3455 | return res; |
| 3558 | 3456 | } |
| r1470 | r1471 | |
| 3561 | 3459 | |
| 3562 | 3460 | WRITE8_HANDLER ( to8_gatearray_w ) |
| 3563 | 3461 | { |
| 3564 | | #if VERBOSE_VIDEO |
| 3565 | | logerror( "$%04x %f to8_gatearray_w: off=%i ($%04X) data=$%02X\n", |
| 3462 | LOG_VIDEO(( "$%04x %f to8_gatearray_w: off=%i ($%04X) data=$%02X\n", |
| 3566 | 3463 | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), |
| 3567 | | offset, 0xe7e4 + offset, data ); |
| 3568 | | #endif |
| 3464 | offset, 0xe7e4 + offset, data )); |
| 3569 | 3465 | |
| 3570 | 3466 | switch ( offset ) |
| 3571 | 3467 | { |
| r1470 | r1471 | |
| 3644 | 3540 | |
| 3645 | 3541 | WRITE8_HANDLER ( to8_vreg_w ) |
| 3646 | 3542 | { |
| 3647 | | #if VERBOSE_VIDEO |
| 3648 | | logerror( "$%04x %f to8_vreg_w: off=%i ($%04X) data=$%02X\n", |
| 3543 | LOG_VIDEO(( "$%04x %f to8_vreg_w: off=%i ($%04X) data=$%02X\n", |
| 3649 | 3544 | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), |
| 3650 | | offset, 0xe7da + offset, data ); |
| 3651 | | #endif |
| 3545 | offset, 0xe7da + offset, data )); |
| 3652 | 3546 | |
| 3653 | 3547 | switch ( offset ) |
| 3654 | 3548 | { |
| r1470 | r1471 | |
| 3703 | 3597 | { |
| 3704 | 3598 | int ktest = to8_kbd_ktest (); |
| 3705 | 3599 | |
| 3706 | | #if VERBOSE_KBD |
| 3707 | | logerror( "$%04x %f: to8_sys_porta_in ktest=%i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), ktest ); |
| 3708 | | #endif |
| 3600 | LOG_KBD(( "$%04x %f: to8_sys_porta_in ktest=%i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), ktest )); |
| 3709 | 3601 | |
| 3710 | 3602 | return ktest; |
| 3711 | 3603 | } |
| r1470 | r1471 | |
| 3716 | 3608 | { |
| 3717 | 3609 | to9_update_centronics(); /* bits 0-1: printer */ |
| 3718 | 3610 | to8_update_ram_bank(); |
| 3719 | | #if VERBOSE |
| 3611 | |
| 3720 | 3612 | if ( data & 4 ) /* bit 2: video overlay (TODO) */ |
| 3721 | | logerror( "to8_sys_portb_out: video overlay not handled\n" ); |
| 3722 | | #endif |
| 3613 | LOG(( "to8_sys_portb_out: video overlay not handled\n" )); |
| 3723 | 3614 | } |
| 3724 | 3615 | |
| 3725 | 3616 | |
| r1470 | r1471 | |
| 4084 | 3975 | if ( to8_reg_sys1 & 0x10 ) |
| 4085 | 3976 | { |
| 4086 | 3977 | bank = to8_reg_ram & 7; /* 128 KB RAM only = 8 pages */ |
| 4087 | | #if VERBOSE_BANK |
| 4088 | 3978 | if ( bank != to8_data_vpage ) |
| 4089 | | logerror( "mo6_update_ram_bank: select bank %i (new style)\n", bank ); |
| 4090 | | #endif |
| 3979 | LOG_BANK(( "mo6_update_ram_bank: select bank %i (new style)\n", bank )); |
| 4091 | 3980 | } |
| 4092 | 3981 | to8_data_vpage = bank; |
| 4093 | 3982 | memory_set_bank( TO8_DATA_LO, to8_data_vpage ); |
| r1470 | r1471 | |
| 4115 | 4004 | memory_install_write8_handler( 0, ADDRESS_SPACE_PROGRAM, 0xb000, 0xefff, 0, 0, |
| 4116 | 4005 | (to8_reg_cart & 0x40) ? (to8_cart_vpage <= 4) ? to8_vcart_w : |
| 4117 | 4006 | (write8_handler)(STATIC_BANK1 + THOM_CART_BANK - 1) : MWA8_NOP ); |
| 4118 | | #if VERBOSE_BANK |
| 4119 | 4007 | if ( bank != old_bank ) |
| 4120 | | logerror( "mo6_update_cart_bank: CART is RAM bank %i (write-enable=%i)\n", to8_cart_vpage, (to8_reg_cart & 0x40) ? 1 : 0 ); |
| 4121 | | #endif |
| 4008 | LOG_BANK(( "mo6_update_cart_bank: CART is RAM bank %i (write-enable=%i)\n", to8_cart_vpage, (to8_reg_cart & 0x40) ? 1 : 0 )); |
| 4122 | 4009 | } |
| 4123 | 4010 | else if ( thom_cart_nb_banks == 4 ) |
| 4124 | 4011 | { |
| 4125 | 4012 | /* "JANE"-style cartridge bank switching */ |
| 4126 | 4013 | memory_install_write8_handler( 0, ADDRESS_SPACE_PROGRAM, 0xb000, 0xefff, 0, 0, MWA8_NOP ); |
| 4127 | 4014 | bank = mo5_reg_cart & 3; |
| 4128 | | #if VERBOSE_BANK |
| 4129 | 4015 | if ( bank != old_bank ) |
| 4130 | | logerror( "mo6_update_cart_bank: CART is external cartridge bank %i (A7CB style)\n", bank ); |
| 4131 | | #endif |
| 4016 | LOG_BANK(( "mo6_update_cart_bank: CART is external cartridge bank %i (A7CB style)\n", bank )); |
| 4132 | 4017 | } |
| 4133 | 4018 | else |
| 4134 | 4019 | { |
| r1470 | r1471 | |
| 4138 | 4023 | bank = 8 + to8_cart_vpage; |
| 4139 | 4024 | memory_install_write8_handler( 0, ADDRESS_SPACE_PROGRAM, 0xb000, 0xefff, 0, 0, write_enable ? |
| 4140 | 4025 | (write8_handler)(STATIC_BANK1 + THOM_CART_BANK - 1) : MWA8_NOP ); |
| 4141 | | #if VERBOSE_BANK |
| 4142 | 4026 | if ( bank != old_bank ) |
| 4143 | | logerror( "mo6_update_cart_bank: CART is RAM bank %i (write-enable=%i) (MO5 compat.)\n", to8_cart_vpage, write_enable ? 1 : 0 ); |
| 4144 | | #endif |
| 4027 | LOG_BANK(( "mo6_update_cart_bank: CART is RAM bank %i (write-enable=%i) (MO5 compat.)\n", to8_cart_vpage, write_enable ? 1 : 0 )); |
| 4145 | 4028 | } |
| 4146 | 4029 | } |
| 4147 | 4030 | else |
| r1470 | r1471 | |
| 4155 | 4038 | bank = b + 6; /* BASIC 128 */ |
| 4156 | 4039 | else |
| 4157 | 4040 | bank = b + 4; /* BASIC 1 */ |
| 4158 | | #if VERBOSE_BANK |
| 4159 | 4041 | if ( bank != old_bank ) |
| 4160 | | logerror( "mo6_update_cart_bank: CART is internal ROM bank %i\n", b ); |
| 4161 | | #endif |
| 4042 | LOG_BANK(( "mo6_update_cart_bank: CART is internal ROM bank %i\n", b )); |
| 4162 | 4043 | } |
| 4163 | 4044 | else |
| 4164 | 4045 | { |
| r1470 | r1471 | |
| 4169 | 4050 | bank = thom_cart_bank % thom_cart_nb_banks; |
| 4170 | 4051 | memory_install_read8_handler( 0, ADDRESS_SPACE_PROGRAM, 0xbffc, 0xbfff, 0, 0, mo6_cartridge_r ); |
| 4171 | 4052 | } |
| 4172 | | #if VERBOSE_BANK |
| 4173 | 4053 | if ( bank != old_bank ) |
| 4174 | | logerror( "mo6_update_cart_bank: CART is external cartridge bank %i\n", bank ); |
| 4175 | | #endif |
| 4054 | LOG_BANK(( "mo6_update_cart_bank: CART is external cartridge bank %i\n", bank )); |
| 4176 | 4055 | } |
| 4177 | 4056 | } |
| 4178 | 4057 | |
| r1470 | r1471 | |
| 4428 | 4307 | res = 0; |
| 4429 | 4308 | } |
| 4430 | 4309 | |
| 4431 | | #if VERBOSE_VIDEO |
| 4432 | | logerror( "$%04x %f mo6_gatearray_r: off=%i ($%04X) res=$%02X lightpen=%i\n", |
| 4310 | LOG_VIDEO(( "$%04x %f mo6_gatearray_r: off=%i ($%04X) res=$%02X lightpen=%i\n", |
| 4433 | 4311 | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), |
| 4434 | | offset, 0xa7e4 + offset, res, to7_lightpen ); |
| 4435 | | #endif |
| 4312 | offset, 0xa7e4 + offset, res, to7_lightpen )); |
| 4436 | 4313 | |
| 4437 | 4314 | return res; |
| 4438 | 4315 | } |
| r1470 | r1471 | |
| 4441 | 4318 | |
| 4442 | 4319 | WRITE8_HANDLER ( mo6_gatearray_w ) |
| 4443 | 4320 | { |
| 4444 | | #if VERBOSE_VIDEO |
| 4445 | | logerror( "$%04x %f mo6_gatearray_w: off=%i ($%04X) data=$%02X\n", |
| 4321 | LOG_VIDEO(( "$%04x %f mo6_gatearray_w: off=%i ($%04X) data=$%02X\n", |
| 4446 | 4322 | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), |
| 4447 | | offset, 0xa7e4 + offset, data ); |
| 4448 | | #endif |
| 4323 | offset, 0xa7e4 + offset, data )); |
| 4449 | 4324 | |
| 4450 | 4325 | switch ( offset ) |
| 4451 | 4326 | { |
| r1470 | r1471 | |
| 4510 | 4385 | |
| 4511 | 4386 | WRITE8_HANDLER ( mo6_vreg_w ) |
| 4512 | 4387 | { |
| 4513 | | #if VERBOSE_VIDEO |
| 4514 | | logerror( "$%04x %f mo6_vreg_w: off=%i ($%04X) data=$%02X\n", |
| 4388 | LOG_VIDEO(( "$%04x %f mo6_vreg_w: off=%i ($%04X) data=$%02X\n", |
| 4515 | 4389 | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), |
| 4516 | | offset, 0xa7da + offset, data ); |
| 4517 | | #endif |
| 4390 | offset, 0xa7da + offset, data )); |
| 4518 | 4391 | |
| 4519 | 4392 | switch ( offset ) |
| 4520 | 4393 | { |
src/mess/machine/cybiko.c
| r1470 | r1471 | |
| 55 | 55 | #endif |
| 56 | 56 | |
| 57 | 57 | #define LOG_LEVEL 1 |
| 58 | | #define _logerror(level,...) if (LOG_LEVEL > level) logerror(__VA_ARGS__) |
| 58 | #define _logerror(level,x) if (LOG_LEVEL > level) logerror x |
| 59 | 59 | |
| 60 | 60 | ///////////////////////// |
| 61 | 61 | // FUNCTION PROTOTYPES // |
| r1470 | r1471 | |
| 87 | 87 | |
| 88 | 88 | DRIVER_INIT( cybikov1 ) |
| 89 | 89 | { |
| 90 | | _logerror( 0, "init_cybikov1\n"); |
| 90 | _logerror( 0, ("init_cybikov1\n")); |
| 91 | 91 | init_ram_handler( 0x200000, mess_ram_size, 0x200000); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | DRIVER_INIT( cybikov2 ) |
| 95 | 95 | { |
| 96 | | _logerror( 0, "init_cybikov2\n"); |
| 96 | _logerror( 0, ("init_cybikov2\n")); |
| 97 | 97 | init_ram_handler( 0x200000, mess_ram_size, 0x200000); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | DRIVER_INIT( cybikoxt ) |
| 101 | 101 | { |
| 102 | | _logerror( 0, "init_cybikoxt\n"); |
| 102 | _logerror( 0, ("init_cybikoxt\n")); |
| 103 | 103 | init_ram_handler( 0x400000, mess_ram_size, 0x200000); |
| 104 | 104 | } |
| 105 | 105 | |
| r1470 | r1471 | |
| 110 | 110 | /* |
| 111 | 111 | NVRAM_HANDLER( cybikov1 ) |
| 112 | 112 | { |
| 113 | | _logerror( 0, "nvram_handler_cybikov1 (%p/%d)\n", file, read_or_write); |
| 113 | _logerror( 0, ("nvram_handler_cybikov1 (%p/%d)\n", file, read_or_write)); |
| 114 | 114 | nvram_handler_at45dbxx( machine, file, read_or_write); |
| 115 | 115 | nvram_handler_pcf8593( machine, file, read_or_write); |
| 116 | 116 | } |
| r1470 | r1471 | |
| 119 | 119 | /* |
| 120 | 120 | NVRAM_HANDLER( cybikov2 ) |
| 121 | 121 | { |
| 122 | | _logerror( 0, "nvram_handler_cybikov2 (%p/%d)\n", file, read_or_write); |
| 122 | _logerror( 0, ("nvram_handler_cybikov2 (%p/%d)\n", file, read_or_write)); |
| 123 | 123 | nvram_handler_at45dbxx( machine, file, read_or_write); |
| 124 | 124 | nvram_handler_sst39vfx( machine, file, read_or_write); |
| 125 | 125 | nvram_handler_pcf8593( machine, file, read_or_write); |
| r1470 | r1471 | |
| 129 | 129 | /* |
| 130 | 130 | NVRAM_HANDLER( cybikoxt ) |
| 131 | 131 | { |
| 132 | | _logerror( 0, "nvram_handler_cybikoxt (%p/%d)\n", file, read_or_write); |
| 132 | _logerror( 0, ("nvram_handler_cybikoxt (%p/%d)\n", file, read_or_write)); |
| 133 | 133 | nvram_handler_sst39vfx( machine, file, read_or_write); |
| 134 | 134 | nvram_handler_pcf8593( machine, file, read_or_write); |
| 135 | 135 | } |
| r1470 | r1471 | |
| 184 | 184 | |
| 185 | 185 | MACHINE_START( cybikov1 ) |
| 186 | 186 | { |
| 187 | | _logerror( 0, "machine_start_cybikov1\n"); |
| 187 | _logerror( 0, ("machine_start_cybikov1\n")); |
| 188 | 188 | // real-time clock |
| 189 | 189 | pcf8593_init(); |
| 190 | 190 | nvram_system_load( machine, "rtc", pcf8593_load, 0); |
| r1470 | r1471 | |
| 199 | 199 | |
| 200 | 200 | MACHINE_START( cybikov2 ) |
| 201 | 201 | { |
| 202 | | _logerror( 0, "machine_start_cybikov2\n"); |
| 202 | _logerror( 0, ("machine_start_cybikov2\n")); |
| 203 | 203 | // real-time clock |
| 204 | 204 | pcf8593_init(); |
| 205 | 205 | nvram_system_load( machine, "rtc", pcf8593_load, 0); |
| r1470 | r1471 | |
| 218 | 218 | |
| 219 | 219 | MACHINE_START( cybikoxt ) |
| 220 | 220 | { |
| 221 | | _logerror( 0, "machine_start_cybikoxt\n"); |
| 221 | _logerror( 0, ("machine_start_cybikoxt\n")); |
| 222 | 222 | // real-time clock |
| 223 | 223 | pcf8593_init(); |
| 224 | 224 | nvram_system_load( machine, "rtc", pcf8593_load, 0); |
| r1470 | r1471 | |
| 238 | 238 | |
| 239 | 239 | MACHINE_RESET( cybikov1 ) |
| 240 | 240 | { |
| 241 | | _logerror( 0, "machine_reset_cybikov1\n"); |
| 241 | _logerror( 0, ("machine_reset_cybikov1\n")); |
| 242 | 242 | pcf8593_reset(); |
| 243 | 243 | at45dbxx_reset(); |
| 244 | 244 | cybiko_rs232_reset(); |
| r1470 | r1471 | |
| 246 | 246 | |
| 247 | 247 | MACHINE_RESET( cybikov2 ) |
| 248 | 248 | { |
| 249 | | _logerror( 0, "machine_reset_cybikov2\n"); |
| 249 | _logerror( 0, ("machine_reset_cybikov2\n")); |
| 250 | 250 | pcf8593_reset(); |
| 251 | 251 | at45dbxx_reset(); |
| 252 | 252 | sst39vfx_reset(); |
| r1470 | r1471 | |
| 255 | 255 | |
| 256 | 256 | MACHINE_RESET( cybikoxt ) |
| 257 | 257 | { |
| 258 | | _logerror( 0, "machine_reset_cybikoxt\n"); |
| 258 | _logerror( 0, ("machine_reset_cybikoxt\n")); |
| 259 | 259 | pcf8593_reset(); |
| 260 | 260 | sst39vfx_reset(); |
| 261 | 261 | cybiko_rs232_reset(); |
| r1470 | r1471 | |
| 267 | 267 | |
| 268 | 268 | MACHINE_STOP( cybikov1 ) |
| 269 | 269 | { |
| 270 | | _logerror( 0, "machine_stop_cybikov1\n"); |
| 270 | _logerror( 0, ("machine_stop_cybikov1\n")); |
| 271 | 271 | // real-time clock |
| 272 | 272 | nvram_system_save( machine, "rtc", pcf8593_save); |
| 273 | 273 | pcf8593_exit(); |
| r1470 | r1471 | |
| 280 | 280 | |
| 281 | 281 | MACHINE_STOP( cybikov2 ) |
| 282 | 282 | { |
| 283 | | _logerror( 0, "machine_stop_cybikov2\n"); |
| 283 | _logerror( 0, ("machine_stop_cybikov2\n")); |
| 284 | 284 | // real-time clock |
| 285 | 285 | nvram_system_save( machine, "rtc", pcf8593_save); |
| 286 | 286 | pcf8593_exit(); |
| r1470 | r1471 | |
| 296 | 296 | |
| 297 | 297 | MACHINE_STOP( cybikoxt ) |
| 298 | 298 | { |
| 299 | | _logerror( 0, "machine_stop_cybikoxt\n"); |
| 299 | _logerror( 0, ("machine_stop_cybikoxt\n")); |
| 300 | 300 | // real-time clock |
| 301 | 301 | nvram_system_save( machine, "rtc", pcf8593_save); |
| 302 | 302 | pcf8593_exit(); |
| r1470 | r1471 | |
| 328 | 328 | |
| 329 | 329 | static void cybiko_rs232_init( void) |
| 330 | 330 | { |
| 331 | | _logerror( 0, "cybiko_rs232_init\n"); |
| 331 | _logerror( 0, ("cybiko_rs232_init\n")); |
| 332 | 332 | memset( &rs232, 0, sizeof( rs232)); |
| 333 | 333 | // timer_pulse( TIME_IN_HZ( 10), NULL, 0, rs232_timer_callback); |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | static void cybiko_rs232_exit( void) |
| 337 | 337 | { |
| 338 | | _logerror( 0, "cybiko_rs232_exit\n"); |
| 338 | _logerror( 0, ("cybiko_rs232_exit\n")); |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | static void cybiko_rs232_reset( void) |
| 342 | 342 | { |
| 343 | | _logerror( 0, "cybiko_rs232_reset\n"); |
| 343 | _logerror( 0, ("cybiko_rs232_reset\n")); |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | static void cybiko_rs232_write_byte( UINT8 data) |
| r1470 | r1471 | |
| 352 | 352 | |
| 353 | 353 | static void cybiko_rs232_pin_sck( int data) |
| 354 | 354 | { |
| 355 | | _logerror( 3, "cybiko_rs232_pin_sck (%d)\n", data); |
| 355 | _logerror( 3, ("cybiko_rs232_pin_sck (%d)\n", data)); |
| 356 | 356 | // clock high-to-low |
| 357 | 357 | if ((rs232.pin.sck == 1) && (data == 0)) |
| 358 | 358 | { |
| r1470 | r1471 | |
| 380 | 380 | |
| 381 | 381 | static void cybiko_rs232_pin_txd( int data) |
| 382 | 382 | { |
| 383 | | _logerror( 3, "cybiko_rs232_pin_txd (%d)\n", data); |
| 383 | _logerror( 3, ("cybiko_rs232_pin_txd (%d)\n", data)); |
| 384 | 384 | rs232.pin.txd = data; |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | static int cybiko_rs232_pin_rxd( void) |
| 388 | 388 | { |
| 389 | | _logerror( 3, "cybiko_rs232_pin_rxd\n"); |
| 389 | _logerror( 3, ("cybiko_rs232_pin_rxd\n")); |
| 390 | 390 | return rs232.pin.rxd; |
| 391 | 391 | } |
| 392 | 392 | |
| r1470 | r1471 | |
| 417 | 417 | { |
| 418 | 418 | UINT8 data = 0xFF; |
| 419 | 419 | int i; |
| 420 | | _logerror( 2, "cybiko_key_r_byte (%08X)\n", offset); |
| 420 | _logerror( 2, ("cybiko_key_r_byte (%08X)\n", offset)); |
| 421 | 421 | // A11 |
| 422 | 422 | if (!(offset & (1 << 11))) data &= 0xFE; |
| 423 | 423 | // A1 .. A9 |
| r1470 | r1471 | |
| 431 | 431 | READ16_HANDLER( cybiko_key_r ) |
| 432 | 432 | { |
| 433 | 433 | UINT16 data = 0; |
| 434 | | _logerror( 2, "cybiko_key_r (%08X/%04X)\n", offset, mem_mask); |
| 434 | _logerror( 2, ("cybiko_key_r (%08X/%04X)\n", offset, mem_mask)); |
| 435 | 435 | if ACCESSING_MSB16 data = data | (cybiko_key_r_byte( offset * 2 + 0) << 8); |
| 436 | 436 | if ACCESSING_LSB16 data = data | (cybiko_key_r_byte( offset * 2 + 1) << 0); |
| 437 | | _logerror( 2, "%04X\n", data); |
| 437 | _logerror( 2, ("%04X\n", data)); |
| 438 | 438 | return data; |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | READ8_HANDLER( cybiko_io_reg_r ) |
| 442 | 442 | { |
| 443 | 443 | UINT8 data = 0; |
| 444 | | _logerror( 2, "cybiko_io_reg_r (%08X)\n", offset); |
| 444 | _logerror( 2, ("cybiko_io_reg_r (%08X)\n", offset)); |
| 445 | 445 | switch (offset) |
| 446 | 446 | { |
| 447 | 447 | // keyboard |
| r1470 | r1471 | |
| 474 | 474 | |
| 475 | 475 | WRITE8_HANDLER( cybiko_io_reg_w ) |
| 476 | 476 | { |
| 477 | | _logerror( 2, "cybiko_io_reg_w (%08X/%02X)\n", offset, data); |
| 477 | _logerror( 2, ("cybiko_io_reg_w (%08X/%02X)\n", offset, data)); |
| 478 | 478 | switch (offset) |
| 479 | 479 | { |
| 480 | 480 | // speaker |
| r1470 | r1471 | |
| 502 | 502 | |
| 503 | 503 | READ8_HANDLER( cybikov1_io_reg_r ) |
| 504 | 504 | { |
| 505 | | _logerror( 2, "cybikov1_io_reg_r (%08X)\n", offset); |
| 505 | _logerror( 2, ("cybikov1_io_reg_r (%08X)\n", offset)); |
| 506 | 506 | return cybiko_io_reg_r( offset); |
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | READ8_HANDLER( cybikov2_io_reg_r ) |
| 510 | 510 | { |
| 511 | | _logerror( 2, "cybikov2_io_reg_r (%08X)\n", offset); |
| 511 | _logerror( 2, ("cybikov2_io_reg_r (%08X)\n", offset)); |
| 512 | 512 | return cybiko_io_reg_r( offset); |
| 513 | 513 | } |
| 514 | 514 | |
| 515 | 515 | READ8_HANDLER( cybikoxt_io_reg_r ) |
| 516 | 516 | { |
| 517 | 517 | UINT8 data = 0; |
| 518 | | _logerror( 2, "cybikoxt_io_reg_r (%08X)\n", offset); |
| 518 | _logerror( 2, ("cybikoxt_io_reg_r (%08X)\n", offset)); |
| 519 | 519 | switch (offset) |
| 520 | 520 | { |
| 521 | 521 | // rs232 |
| r1470 | r1471 | |
| 528 | 528 | |
| 529 | 529 | WRITE8_HANDLER( cybikov1_io_reg_w ) |
| 530 | 530 | { |
| 531 | | _logerror( 2, "cybikov1_io_reg_w (%08X/%02X)\n", offset, data); |
| 531 | _logerror( 2, ("cybikov1_io_reg_w (%08X/%02X)\n", offset, data)); |
| 532 | 532 | cybiko_io_reg_w( offset, data); |
| 533 | 533 | } |
| 534 | 534 | |
| 535 | 535 | WRITE8_HANDLER( cybikov2_io_reg_w ) |
| 536 | 536 | { |
| 537 | | _logerror( 2, "cybikov2_io_reg_w (%08X/%02X)\n", offset, data); |
| 537 | _logerror( 2, ("cybikov2_io_reg_w (%08X/%02X)\n", offset, data)); |
| 538 | 538 | cybiko_io_reg_w( offset, data); |
| 539 | 539 | } |
| 540 | 540 | |
| 541 | 541 | WRITE8_HANDLER( cybikoxt_io_reg_w ) |
| 542 | 542 | { |
| 543 | | _logerror( 2, "cybikoxt_io_reg_w (%08X/%02X)\n", offset, data); |
| 543 | _logerror( 2, ("cybikoxt_io_reg_w (%08X/%02X)\n", offset, data)); |
| 544 | 544 | switch (offset) |
| 545 | 545 | { |
| 546 | 546 | // rs232 |
src/mess/machine/kc.c
| r1470 | r1471 | |
| 9 | 9 | #include "sound/speaker.h" |
| 10 | 10 | #include "image.h" |
| 11 | 11 | |
| 12 | | #define KC_DEBUG |
| 12 | #define KC_DEBUG 1 |
| 13 | #define LOG(x) do { if (KC_DEBUG) logerror x; } while (0) |
| 13 | 14 | |
| 14 | 15 | static int kc85_pio_data[2]; |
| 15 | 16 | |
| r1470 | r1471 | |
| 322 | 323 | { |
| 323 | 324 | int port_upper; |
| 324 | 325 | int module_index; |
| 325 | | #ifdef KC_DEBUG |
| 326 | | logerror("kc85 module r: %04x\n",offset); |
| 327 | | #endif |
| 328 | 326 | |
| 327 | LOG(("kc85 module r: %04x\n",offset)); |
| 328 | |
| 329 | 329 | port_upper = (offset>>8) & 0x0ff; |
| 330 | 330 | |
| 331 | 331 | /* module is accessed at every 4th address. 0x00,0x04,0x08,0x0c etc */ |
| r1470 | r1471 | |
| 480 | 480 | /* The basic transmit proceedure is working, keys are received */ |
| 481 | 481 | /* Todo: Key-repeat, and allowing the same key to be pressed twice! */ |
| 482 | 482 | |
| 483 | | //#define KC_KEYBOARD_DEBUG |
| 483 | #define KC_KEYBOARD_DEBUG 0 |
| 484 | #define LOG_KBD(x) do { if (KC_KEYBOARD_DEBUG) logerror x; } while (0) |
| 484 | 485 | |
| 485 | 486 | /* |
| 486 | 487 | |
| r1470 | r1471 | |
| 856 | 857 | /* get current pulse state */ |
| 857 | 858 | pulse_state = (keyboard_data.transmit_buffer[pulse_byte_count]>>pulse_bit_count) & 0x01; |
| 858 | 859 | |
| 859 | | #ifdef KC_KEYBOARD_DEBUG |
| 860 | | logerror("kc keyboard sending pulse: %02x\n",pulse_state); |
| 861 | | #endif |
| 860 | LOG_KBD(("kc keyboard sending pulse: %02x\n",pulse_state)); |
| 862 | 861 | |
| 863 | 862 | /* set pulse */ |
| 864 | 863 | z80pio_bstb_w(0,pulse_state & kc_brdy); |
| r1470 | r1471 | |
| 1069 | 1068 | |
| 1070 | 1069 | /* generate fake code */ |
| 1071 | 1070 | code = (i<<3) | b; |
| 1072 | | #ifdef KC_KEYBOARD_DEBUG |
| 1073 | | logerror("code: %02x\n",code); |
| 1074 | | #endif |
| 1071 | LOG_KBD(("code: %02x\n",code)); |
| 1075 | 1072 | kc_keyboard_queue_scancode(code); |
| 1076 | 1073 | } |
| 1077 | 1074 | } |
| r1470 | r1471 | |
| 1155 | 1152 | } |
| 1156 | 1153 | else |
| 1157 | 1154 | { |
| 1158 | | #ifdef KC_DEBUG |
| 1159 | | logerror("RAM8 write enabled\n"); |
| 1160 | | #endif |
| 1155 | LOG(("RAM8 write enabled\n")); |
| 1156 | |
| 1161 | 1157 | /* ram8 is enabled and write enabled */ |
| 1162 | 1158 | memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0x8000, 0xa7ff, 0, 0, MWA8_BANK9); |
| 1163 | 1159 | memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0xa800, 0xbfff, 0, 0, MWA8_BANK10); |
| r1470 | r1471 | |
| 1167 | 1163 | } |
| 1168 | 1164 | else |
| 1169 | 1165 | { |
| 1170 | | #ifdef KC_DEBUG |
| 1171 | | logerror("no memory at ram8\n"); |
| 1172 | | #endif |
| 1166 | LOG(("no memory at ram8\n")); |
| 1167 | |
| 1173 | 1168 | memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0x8000, 0xa7ff, 0, 0, MRA8_NOP); |
| 1174 | 1169 | memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0xa800, 0xbfff, 0, 0, MRA8_NOP); |
| 1175 | 1170 | memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0x8000, 0xa7ff, 0, 0, MWA8_NOP); |
| r1470 | r1471 | |
| 1202 | 1197 | /* access ram? */ |
| 1203 | 1198 | if (kc85_pio_data[0] & (1<<1)) |
| 1204 | 1199 | { |
| 1205 | | #ifdef KC_DEBUG |
| 1206 | | logerror("ram0 enabled\n"); |
| 1207 | | #endif |
| 1200 | LOG(("ram0 enabled\n")); |
| 1208 | 1201 | |
| 1209 | 1202 | /* yes; set address of bank */ |
| 1210 | 1203 | memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x3fff, 0, 0, MRA8_BANK1); |
| r1470 | r1471 | |
| 1214 | 1207 | if ((kc85_pio_data[0] & (1<<3))==0) |
| 1215 | 1208 | { |
| 1216 | 1209 | /* yes */ |
| 1217 | | #ifdef KC_DEBUG |
| 1218 | | logerror("ram0 write protected\n"); |
| 1219 | | #endif |
| 1210 | LOG(("ram0 write protected\n")); |
| 1220 | 1211 | |
| 1221 | 1212 | /* ram is enabled and write protected */ |
| 1222 | 1213 | memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x3fff, 0, 0, MWA8_ROM); |
| 1223 | 1214 | } |
| 1224 | 1215 | else |
| 1225 | 1216 | { |
| 1226 | | #ifdef KC_DEBUG |
| 1227 | | logerror("ram0 write enabled\n"); |
| 1228 | | #endif |
| 1217 | LOG(("ram0 write enabled\n")); |
| 1229 | 1218 | |
| 1230 | 1219 | /* ram is enabled and write enabled; and set address of bank */ |
| 1231 | 1220 | memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x3fff, 0, 0, MWA8_BANK7); |
| r1470 | r1471 | |
| 1234 | 1223 | } |
| 1235 | 1224 | else |
| 1236 | 1225 | { |
| 1237 | | #ifdef KC_DEBUG |
| 1238 | | logerror("no memory at ram0!\n"); |
| 1239 | | #endif |
| 1226 | LOG(("no memory at ram0!\n")); |
| 1240 | 1227 | |
| 1241 | 1228 | // memory_set_bankptr(1,memory_region(REGION_CPU1) + 0x013000); |
| 1242 | 1229 | /* ram is disabled */ |
| r1470 | r1471 | |
| 1267 | 1254 | if ((kc85_86_data & (1<<1))==0) |
| 1268 | 1255 | { |
| 1269 | 1256 | /* yes */ |
| 1270 | | #ifdef KC_DEBUG |
| 1271 | | logerror("ram4 write protected\n"); |
| 1272 | | #endif |
| 1257 | LOG(("ram4 write protected\n")); |
| 1273 | 1258 | |
| 1274 | 1259 | /* ram is enabled and write protected */ |
| 1275 | 1260 | wh = MWA8_NOP; |
| 1276 | 1261 | } |
| 1277 | 1262 | else |
| 1278 | 1263 | { |
| 1279 | | #ifdef KC_DEBUG |
| 1280 | | logerror("ram4 write enabled\n"); |
| 1281 | | #endif |
| 1264 | LOG(("ram4 write enabled\n")); |
| 1265 | |
| 1282 | 1266 | /* ram is enabled and write enabled */ |
| 1283 | 1267 | wh = MWA8_BANK8; |
| 1284 | 1268 | /* set address of bank */ |
| r1470 | r1471 | |
| 1287 | 1271 | } |
| 1288 | 1272 | else |
| 1289 | 1273 | { |
| 1290 | | #ifdef KC_DEBUG |
| 1291 | | logerror("no memory at ram4!\n"); |
| 1292 | | #endif |
| 1274 | LOG(("no memory at ram4!\n")); |
| 1275 | |
| 1293 | 1276 | /* ram is disabled */ |
| 1294 | 1277 | rh = MRA8_NOP; |
| 1295 | 1278 | wh = MWA8_NOP; |
| r1470 | r1471 | |
| 1307 | 1290 | if (kc85_86_data & (1<<7)) |
| 1308 | 1291 | { |
| 1309 | 1292 | /* CAOS rom takes priority */ |
| 1310 | | #ifdef KC_DEBUG |
| 1311 | | logerror("CAOS rom 0x0c000\n"); |
| 1312 | | #endif |
| 1293 | LOG(("CAOS rom 0x0c000\n")); |
| 1294 | |
| 1313 | 1295 | memory_set_bankptr(5,memory_region(REGION_CPU1) + 0x012000); |
| 1314 | 1296 | rh = MRA8_BANK5; |
| 1315 | 1297 | } |
| 1316 | 1298 | else if (kc85_pio_data[0] & (1<<7)) |
| 1317 | 1299 | { |
| 1318 | | #ifdef KC_DEBUG |
| 1319 | 1300 | /* BASIC takes next priority */ |
| 1320 | | logerror("BASIC rom 0x0c000\n"); |
| 1321 | | #endif |
| 1301 | LOG(("BASIC rom 0x0c000\n")); |
| 1322 | 1302 | |
| 1323 | 1303 | memory_set_bankptr(5, memory_region(REGION_CPU1) + 0x010000); |
| 1324 | 1304 | rh = MRA8_BANK5; |
| r1470 | r1471 | |
| 1327 | 1307 | { |
| 1328 | 1308 | if (kc85_module_rom) |
| 1329 | 1309 | { |
| 1330 | | logerror("module rom at 0xc000\n"); |
| 1310 | LOG(("module rom at 0xc000\n")); |
| 1331 | 1311 | |
| 1332 | 1312 | memory_set_bankptr(5, kc85_module_rom); |
| 1333 | 1313 | rh = MRA8_BANK5; |
| r1470 | r1471 | |
| 1335 | 1315 | else |
| 1336 | 1316 | { |
| 1337 | 1317 | |
| 1338 | | #ifdef KC_DEBUG |
| 1339 | | logerror("No roms 0x0c000\n"); |
| 1340 | | #endif |
| 1318 | LOG(("No roms 0x0c000\n")); |
| 1319 | |
| 1341 | 1320 | rh = MRA8_NOP; |
| 1342 | 1321 | } |
| 1343 | 1322 | } |
| r1470 | r1471 | |
| 1352 | 1331 | if (kc85_pio_data[0] & (1<<0)) |
| 1353 | 1332 | { |
| 1354 | 1333 | /* enable CAOS rom in memory range 0x0e000-0x0ffff */ |
| 1355 | | #ifdef KC_DEBUG |
| 1356 | | logerror("CAOS rom 0x0e000\n"); |
| 1357 | | #endif |
| 1334 | LOG(("CAOS rom 0x0e000\n")); |
| 1358 | 1335 | /* read will access the rom */ |
| 1359 | 1336 | memory_set_bankptr(6,memory_region(REGION_CPU1) + 0x013000); |
| 1360 | 1337 | rh = MRA8_BANK6; |
| 1361 | 1338 | } |
| 1362 | 1339 | else |
| 1363 | 1340 | { |
| 1364 | | #ifdef KC_DEBUG |
| 1365 | | logerror("no rom 0x0e000\n"); |
| 1366 | | #endif |
| 1341 | LOG(("no rom 0x0e000\n")); |
| 1342 | |
| 1367 | 1343 | rh = MRA8_NOP; |
| 1368 | 1344 | } |
| 1369 | 1345 | memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0xe000, 0xffff, 0, 0, rh); |
| r1470 | r1471 | |
| 1430 | 1406 | |
| 1431 | 1407 | WRITE8_HANDLER ( kc85_4_86_w ) |
| 1432 | 1408 | { |
| 1433 | | #ifdef KC_DEBUG |
| 1434 | | logerror("0x086 W: %02x\n",data); |
| 1435 | | #endif |
| 1409 | LOG(("0x086 W: %02x\n",data)); |
| 1436 | 1410 | |
| 1437 | 1411 | kc85_86_data = data; |
| 1438 | 1412 | |
| r1470 | r1471 | |
| 1448 | 1422 | |
| 1449 | 1423 | WRITE8_HANDLER ( kc85_4_84_w ) |
| 1450 | 1424 | { |
| 1451 | | #ifdef KC_DEBUG |
| 1452 | | logerror("0x084 W: %02x\n",data); |
| 1453 | | #endif |
| 1425 | LOG(("0x084 W: %02x\n",data)); |
| 1426 | |
| 1454 | 1427 | kc85_84_data = data; |
| 1455 | 1428 | |
| 1456 | 1429 | kc85_4_video_ram_select_bank(data & 0x01); |
| r1470 | r1471 | |
| 1471 | 1444 | |
| 1472 | 1445 | if (kc85_pio_data[0] & (1<<7)) |
| 1473 | 1446 | { |
| 1474 | | #ifdef KC_DEBUG |
| 1475 | 1447 | /* BASIC takes next priority */ |
| 1476 | | logerror("BASIC rom 0x0c000\n"); |
| 1477 | | #endif |
| 1448 | LOG(("BASIC rom 0x0c000\n")); |
| 1449 | |
| 1478 | 1450 | memory_set_bankptr(4, memory_region(REGION_CPU1) + 0x010000); |
| 1479 | 1451 | rh = MRA8_BANK4; |
| 1480 | 1452 | } |
| 1481 | 1453 | else |
| 1482 | 1454 | { |
| 1483 | | #ifdef KC_DEBUG |
| 1484 | | logerror("No roms 0x0c000\n"); |
| 1485 | | #endif |
| 1455 | LOG(("No roms 0x0c000\n")); |
| 1456 | |
| 1486 | 1457 | rh = MRA8_NOP; |
| 1487 | 1458 | } |
| 1488 | 1459 | memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0xc000, 0xdfff, 0, 0, rh); |
| r1470 | r1471 | |
| 1495 | 1466 | |
| 1496 | 1467 | if (kc85_pio_data[0] & (1<<0)) |
| 1497 | 1468 | { |
| 1498 | | #ifdef KC_DEBUG |
| 1499 | 1469 | /* enable CAOS rom in memory range 0x0e000-0x0ffff */ |
| 1500 | | logerror("CAOS rom 0x0e000\n"); |
| 1501 | | #endif |
| 1470 | LOG(("CAOS rom 0x0e000\n")); |
| 1471 | |
| 1502 | 1472 | memory_set_bankptr(5,memory_region(REGION_CPU1) + 0x012000); |
| 1503 | 1473 | rh = MRA8_BANK5; |
| 1504 | 1474 | } |
| 1505 | 1475 | else |
| 1506 | 1476 | { |
| 1507 | | #ifdef KC_DEBUG |
| 1508 | | logerror("no rom 0x0e000\n"); |
| 1509 | | #endif |
| 1477 | LOG(("no rom 0x0e000\n")); |
| 1478 | |
| 1510 | 1479 | rh = MRA8_NOP; |
| 1511 | 1480 | } |
| 1512 | 1481 | memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0xe000, 0xffff, 0, 0, rh); |
| r1470 | r1471 | |
| 1523 | 1492 | /* access ram? */ |
| 1524 | 1493 | if (kc85_pio_data[0] & (1<<1)) |
| 1525 | 1494 | { |
| 1526 | | #ifdef KC_DEBUG |
| 1527 | | logerror("ram0 enabled\n"); |
| 1528 | | #endif |
| 1495 | LOG(("ram0 enabled\n")); |
| 1496 | |
| 1529 | 1497 | /* yes */ |
| 1530 | 1498 | rh = MRA8_BANK1; |
| 1531 | 1499 | /* set address of bank */ |
| r1470 | r1471 | |
| 1535 | 1503 | if ((kc85_pio_data[0] & (1<<3))==0) |
| 1536 | 1504 | { |
| 1537 | 1505 | /* yes */ |
| 1538 | | #ifdef KC_DEBUG |
| 1539 | | logerror("ram0 write protected\n"); |
| 1540 | | #endif |
| 1506 | LOG(("ram0 write protected\n")); |
| 1541 | 1507 | |
| 1542 | 1508 | /* ram is enabled and write protected */ |
| 1543 | 1509 | wh = MWA8_NOP; |
| 1544 | 1510 | } |
| 1545 | 1511 | else |
| 1546 | 1512 | { |
| 1547 | | #ifdef KC_DEBUG |
| 1548 | | logerror("ram0 write enabled\n"); |
| 1549 | | #endif |
| 1513 | LOG(("ram0 write enabled\n")); |
| 1550 | 1514 | |
| 1551 | 1515 | /* ram is enabled and write enabled */ |
| 1552 | 1516 | wh = MWA8_BANK6; |
| r1470 | r1471 | |
| 1556 | 1520 | } |
| 1557 | 1521 | else |
| 1558 | 1522 | { |
| 1559 | | #ifdef KC_DEBUG |
| 1560 | | logerror("no memory at ram0!\n"); |
| 1561 | | #endif |
| 1523 | LOG(("no memory at ram0!\n")); |
| 1562 | 1524 | |
| 1563 | 1525 | /* ram is disabled */ |
| 1564 | 1526 | rh = MRA8_NOP; |
| r1470 | r1471 | |
| 1580 | 1542 | if (kc85_pio_data[0] & (1<<2)) |
| 1581 | 1543 | { |
| 1582 | 1544 | /* IRM enabled */ |
| 1583 | | #ifdef KC_DEBUG |
| 1584 | | logerror("IRM enabled\n"); |
| 1585 | | #endif |
| 1545 | LOG(("IRM enabled\n")); |
| 1586 | 1546 | ram_page = mess_ram+0x08000; |
| 1587 | 1547 | |
| 1588 | 1548 | memory_set_bankptr(3, ram_page); |
| r1470 | r1471 | |
| 1594 | 1554 | else if (kc85_pio_data[1] & (1<<5)) |
| 1595 | 1555 | { |
| 1596 | 1556 | /* RAM8 ACCESS */ |
| 1597 | | #ifdef KC_DEBUG |
| 1598 | | logerror("RAM8 enabled\n"); |
| 1599 | | #endif |
| 1557 | LOG(("RAM8 enabled\n")); |
| 1600 | 1558 | ram_page = mess_ram + 0x04000; |
| 1601 | 1559 | |
| 1602 | 1560 | memory_set_bankptr(3, ram_page); |
| r1470 | r1471 | |
| 1605 | 1563 | /* write protect RAM8 ? */ |
| 1606 | 1564 | if ((kc85_pio_data[1] & (1<<6))==0) |
| 1607 | 1565 | { |
| 1608 | | #ifdef KC_DEBUG |
| 1609 | | logerror("RAM8 write protected\n"); |
| 1610 | | #endif |
| 1566 | LOG(("RAM8 write protected\n")); |
| 1611 | 1567 | /* ram8 is enabled and write protected */ |
| 1612 | 1568 | wh = MWA8_NOP; |
| 1613 | 1569 | } |
| 1614 | 1570 | else |
| 1615 | 1571 | { |
| 1616 | | #ifdef KC_DEBUG |
| 1617 | | logerror("RAM8 write enabled\n"); |
| 1618 | | #endif |
| 1572 | LOG(("RAM8 write enabled\n")); |
| 1619 | 1573 | /* ram8 is enabled and write enabled */ |
| 1620 | 1574 | wh = MWA8_BANK8; |
| 1621 | 1575 | memory_set_bankptr(8,ram_page); |
| r1470 | r1471 | |
| 1623 | 1577 | } |
| 1624 | 1578 | else |
| 1625 | 1579 | { |
| 1626 | | #ifdef KC_DEBUG |
| 1627 | | logerror("no memory at ram8!\n"); |
| 1628 | | #endif |
| 1580 | LOG(("no memory at ram8!\n")); |
| 1629 | 1581 | rh = MRA8_NOP; |
| 1630 | 1582 | wh = MWA8_NOP; |
| 1631 | 1583 | } |
| r1470 | r1471 | |
| 1755 | 1707 | unsigned char data; |
| 1756 | 1708 | |
| 1757 | 1709 | data = z80ctc_0_r(offset); |
| 1758 | | //#ifdef KC_KEYBOARD_DEBUG |
| 1759 | | //logerror("ctc data r:%02x\n",data); |
| 1760 | | //#endif |
| 1710 | //LOG_KBD(("ctc data r:%02x\n",data)); |
| 1761 | 1711 | return data; |
| 1762 | 1712 | } |
| 1763 | 1713 | |
| r1470 | r1471 | |
| 1784 | 1734 | static void kc85_pio_ardy_callback(int state) |
| 1785 | 1735 | { |
| 1786 | 1736 | kc_ardy = state & 0x01; |
| 1787 | | #ifdef KC_DEBUG |
| 1737 | |
| 1788 | 1738 | if (state) |
| 1789 | 1739 | { |
| 1790 | | logerror("PIO A Ready\n"); |
| 1740 | LOG(("PIO A Ready\n")); |
| 1791 | 1741 | } |
| 1792 | | #endif |
| 1793 | | |
| 1794 | 1742 | } |
| 1795 | 1743 | |
| 1796 | 1744 | /* callback for brdy output from PIO */ |
| r1470 | r1471 | |
| 1798 | 1746 | static void kc85_pio_brdy_callback(int state) |
| 1799 | 1747 | { |
| 1800 | 1748 | kc_brdy = state & 0x01; |
| 1801 | | #ifdef KC_DEBUG |
| 1749 | |
| 1802 | 1750 | if (state) |
| 1803 | 1751 | { |
| 1804 | | logerror("PIO B Ready\n"); |
| 1752 | LOG(("PIO B Ready\n")); |
| 1805 | 1753 | } |
| 1806 | | #endif |
| 1807 | 1754 | } |
| 1808 | 1755 | |
| 1809 | 1756 | static const z80pio_interface kc85_pio_intf = |
src/mess/machine/corvushd.c
| r1470 | r1471 | |
| 67 | 67 | #include "devices/harddriv.h" |
| 68 | 68 | #include "includes/corvushd.h" |
| 69 | 69 | #include "timer.h" |
| 70 | #include <ctype.h> |
| 70 | 71 | |
| 71 | 72 | #define VERBOSE 0 |
| 72 | 73 | #define VERBOSE_RESPONSES 0 |
| r1470 | r1471 | |
| 81 | 82 | #define INTERBYTE_DELAY 5 // Inter-byte delay in microseconds communicating between controller and host |
| 82 | 83 | #define INTERSECTOR_DELAY 25000 // 25ms delay between sectors (4800 RPM = 80 Rev/Second. Maximum 2 sectors transferred / Rev) |
| 83 | 84 | |
| 85 | #define LOG(x) do { if (VERBOSE) logerror x; } while (0) |
| 86 | #define LOG_BUFFER(p,s) do { if (VERBOSE) dump_buffer(p,s); } while (0) |
| 84 | 87 | // |
| 85 | 88 | // Structures |
| 86 | 89 | // |
| r1470 | r1471 | |
| 378 | 381 | |
| 379 | 382 | |
| 380 | 383 | |
| 381 | | #if VERBOSE |
| 382 | 384 | // |
| 383 | 385 | // Dump_Buffer |
| 384 | 386 | // |
| r1470 | r1471 | |
| 391 | 393 | // Returns: |
| 392 | 394 | // nada |
| 393 | 395 | // |
| 394 | | void dump_buffer(UINT8 *buffer, UINT16 length) { |
| 396 | static void dump_buffer(UINT8 *buffer, UINT16 length) { |
| 395 | 397 | |
| 396 | | #include <ctype.h> |
| 397 | | |
| 398 | 398 | UINT16 offset; |
| 399 | 399 | char ascii_dump[16]; |
| 400 | | int cpos; |
| 401 | 400 | |
| 402 | 401 | logerror("dump_buffer: Dump of %d bytes:\n", length); |
| 403 | 402 | logerror("Base 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f ASCII\n"); |
| r1470 | r1471 | |
| 417 | 416 | logerror("%.*s", (16 - (offset % 16)) * 3, " "); |
| 418 | 417 | logerror("%.*s\n", offset % 16 ? offset % 16 : 16, ascii_dump); |
| 419 | 418 | } |
| 420 | | #endif |
| 421 | 419 | |
| 422 | 420 | |
| 423 | 421 | |
| r1470 | r1471 | |
| 442 | 440 | |
| 443 | 441 | c->awaiting_modifier = FALSE; // This is the case by definition |
| 444 | 442 | |
| 445 | | #if VERBOSE |
| 446 | | logerror("parse_hdc_command: Called with data: 0x%2.2x, Prep mode is: %d\n", data, c->prep_mode); |
| 447 | | #endif |
| 443 | LOG(("parse_hdc_command: Called with data: 0x%2.2x, Prep mode is: %d\n", data, c->prep_mode)); |
| 448 | 444 | |
| 449 | 445 | if(!c->prep_mode) { |
| 450 | 446 | switch(data) { |
| r1470 | r1471 | |
| 470 | 466 | case PREP_MODE_SELECT: |
| 471 | 467 | c->recv_bytes = corvus_cmd[data][0].recv_bytes; |
| 472 | 468 | c->xmit_bytes = corvus_cmd[data][0].xmit_bytes; |
| 473 | | #if VERBOSE |
| 474 | | logerror("parse_hdc_command: Single byte command recoginized: 0x%2.2x, to recv: %d, to xmit: %d\n", data, |
| 475 | | c->recv_bytes, c->xmit_bytes); |
| 476 | | #endif |
| 469 | LOG(("parse_hdc_command: Single byte command recoginized: 0x%2.2x, to recv: %d, to xmit: %d\n", data, |
| 470 | c->recv_bytes, c->xmit_bytes)); |
| 477 | 471 | break; |
| 478 | 472 | // |
| 479 | 473 | // Double-byte commands |
| r1470 | r1471 | |
| 495 | 489 | // case DELACTIVENUM_OMNI_CODE: |
| 496 | 490 | // case FINDACTIVE_CODE: |
| 497 | 491 | c->awaiting_modifier = TRUE; |
| 498 | | #if VERBOSE |
| 499 | | logerror("parse_hdc_command: Double byte command recoginized: 0x%2.2x\n", data); |
| 500 | | #endif |
| 492 | LOG(("parse_hdc_command: Double byte command recoginized: 0x%2.2x\n", data)); |
| 501 | 493 | break; |
| 502 | 494 | |
| 503 | 495 | default: // This is an INVALID command |
| 504 | 496 | c->recv_bytes = 1; |
| 505 | 497 | c->xmit_bytes = 1; |
| 506 | | #if VERBOSE |
| 507 | | logerror("parse_hdc_command: Invalid command detected: 0x%2.2x\n", data); |
| 508 | | #endif |
| 498 | LOG(("parse_hdc_command: Invalid command detected: 0x%2.2x\n", data)); |
| 509 | 499 | return TRUE; |
| 510 | 500 | } |
| 511 | 501 | } else { |
| r1470 | r1471 | |
| 522 | 512 | case PREP_WRITE_FIRMWARE: |
| 523 | 513 | c->recv_bytes = corvus_prep_cmd[data].recv_bytes; |
| 524 | 514 | c->xmit_bytes = corvus_prep_cmd[data].xmit_bytes; |
| 525 | | #if VERBOSE |
| 526 | | logerror("parse_hdc_command: Prep command recognized: 0x%2.2x, to recv: %d, to xmit: %d\n", data, |
| 527 | | c->recv_bytes, c->xmit_bytes); |
| 528 | | #endif |
| 515 | LOG(("parse_hdc_command: Prep command recognized: 0x%2.2x, to recv: %d, to xmit: %d\n", data, |
| 516 | c->recv_bytes, c->xmit_bytes)); |
| 529 | 517 | break; |
| 530 | 518 | |
| 531 | 519 | default: // This is an INVALID prep command |
| 532 | 520 | c->recv_bytes = 1; |
| 533 | 521 | c->xmit_bytes = 1; |
| 534 | | #if VERBOSE |
| 535 | | logerror("parse_hdc_command: Invalid Prep command detected: 0x%2.2x\n", data); |
| 536 | | #endif |
| 522 | LOG(("parse_hdc_command: Invalid Prep command detected: 0x%2.2x\n", data)); |
| 537 | 523 | return TRUE; |
| 538 | 524 | } |
| 539 | 525 | } // if(!prep_mode) |
| r1470 | r1471 | |
| 566 | 552 | UINT8 tbuffer[512]; // Buffer to hold an entire sector |
| 567 | 553 | UINT16 cylinder; // Cylinder this sector resides on |
| 568 | 554 | |
| 569 | | #if VERBOSE |
| 570 | | logerror("corvus_write_sector: Write Drive: %d, physical sector: 0x%5.5x\n", drv, sector); |
| 571 | | #endif |
| 555 | LOG(("corvus_write_sector: Write Drive: %d, physical sector: 0x%5.5x\n", drv, sector)); |
| 572 | 556 | |
| 573 | 557 | if(drv >= device_count(IO_HARDDISK)) { |
| 574 | 558 | logerror("corvus_write_sector: Attempt to write to non-existant drive: %d\n", drv); |
| r1470 | r1471 | |
| 604 | 588 | |
| 605 | 589 | c->last_cylinder = cylinder; |
| 606 | 590 | |
| 607 | | #if VERBOSE |
| 608 | | logerror("corvus_write_sector: Full sector dump on a write of %d bytes follows:\n", len); |
| 609 | | dump_buffer(len == 512 ? buffer : tbuffer, 512); |
| 610 | | #endif |
| 591 | LOG(("corvus_write_sector: Full sector dump on a write of %d bytes follows:\n", len)); |
| 592 | LOG_BUFFER(len == 512 ? buffer : tbuffer, 512); |
| 611 | 593 | |
| 612 | 594 | return STAT_SUCCESS; |
| 613 | 595 | } |
| r1470 | r1471 | |
| 646 | 628 | drv = (dadr->address_msn_and_drive & 0x0f) - 1; |
| 647 | 629 | sector = (dadr->address_msn_and_drive & 0xf0 << 12) | (dadr->address_mid << 8) | dadr->address_lsb; |
| 648 | 630 | |
| 649 | | #if VERBOSE |
| 650 | | logerror("corvus_write_logical_sector: Writing based on DADR: 0x%6.6x, logical sector: 0x%5.5x, drive: %d\n", |
| 651 | | dadr->address_msn_and_drive << 16 | dadr->address_lsb << 8 | dadr->address_mid, sector, drv); |
| 652 | | #endif |
| 631 | LOG(("corvus_write_logical_sector: Writing based on DADR: 0x%6.6x, logical sector: 0x%5.5x, drive: %d\n", |
| 632 | dadr->address_msn_and_drive << 16 | dadr->address_lsb << 8 | dadr->address_mid, sector, drv)); |
| 653 | 633 | |
| 654 | 634 | // |
| 655 | 635 | // Shift the logical sector address forward by the number of firmware cylinders (2) + the number of spare tracks (7) |
| r1470 | r1471 | |
| 688 | 668 | UINT8 tbuffer[512]; // Buffer to store full sector results in |
| 689 | 669 | UINT16 cylinder; |
| 690 | 670 | |
| 691 | | #if VERBOSE |
| 692 | | logerror("corvus_read_sector: Read Drive: %d, physical sector: 0x%5.5x\n", drv, sector); |
| 693 | | #endif |
| 671 | LOG(("corvus_read_sector: Read Drive: %d, physical sector: 0x%5.5x\n", drv, sector)); |
| 694 | 672 | |
| 695 | 673 | if(drv >= device_count(IO_HARDDISK)) { |
| 696 | 674 | logerror("corvus_read_sector: Attempt to read from non-existant drive: %d\n", drv); |
| r1470 | r1471 | |
| 715 | 693 | |
| 716 | 694 | c->last_cylinder = cylinder; |
| 717 | 695 | |
| 718 | | #if VERBOSE |
| 719 | | logerror("corvus_read_sector: Data read follows:\n"); |
| 720 | | dump_buffer(tbuffer, len); |
| 721 | | #endif |
| 696 | LOG(("corvus_read_sector: Data read follows:\n")); |
| 697 | LOG_BUFFER(tbuffer, len); |
| 722 | 698 | |
| 723 | 699 | return STAT_SUCCESS; |
| 724 | 700 | } |
| r1470 | r1471 | |
| 757 | 733 | drv = (dadr->address_msn_and_drive & 0x0f) - 1; |
| 758 | 734 | sector = (dadr->address_msn_and_drive & 0xf0 << 12) | (dadr->address_mid << 8) | dadr->address_lsb; |
| 759 | 735 | |
| 760 | | #if VERBOSE |
| 761 | | logerror("corvus_read_logical_sector: Reading based on DADR: 0x%6.6x, logical sector: 0x%5.5x, drive: %d\n", |
| 762 | | dadr->address_msn_and_drive << 16 | dadr->address_lsb << 8 | dadr->address_mid, sector, drv); |
| 763 | | #endif |
| 736 | LOG(("corvus_read_logical_sector: Reading based on DADR: 0x%6.6x, logical sector: 0x%5.5x, drive: %d\n", |
| 737 | dadr->address_msn_and_drive << 16 | dadr->address_lsb << 8 | dadr->address_mid, sector, drv)); |
| 764 | 738 | |
| 765 | 739 | // |
| 766 | 740 | // Shift the logical sector address forward by the number of firmware cylinders (2) + the number of spare tracks (7) |
| r1470 | r1471 | |
| 1056 | 1030 | c->buffer.drive_param_response.physical_capacity.midb = (raw_capacity & 0x00ff00) >> 8; |
| 1057 | 1031 | c->buffer.drive_param_response.physical_capacity.lsb = (raw_capacity & 0x0000ff); |
| 1058 | 1032 | |
| 1059 | | #if VERBOSE |
| 1060 | | logerror("corvus_get_drive_parameters: Drive Parameter packet follows:\n"); |
| 1061 | | dump_buffer(c->buffer.raw_data, 110); |
| 1062 | | #endif |
| 1033 | LOG(("corvus_get_drive_parameters: Drive Parameter packet follows:\n")); |
| 1034 | LOG_BUFFER(c->buffer.raw_data, 110); |
| 1063 | 1035 | |
| 1064 | 1036 | return STAT_SUCCESS; |
| 1065 | 1037 | } |
| r1470 | r1471 | |
| 1081 | 1053 | |
| 1082 | 1054 | corvus_hdc_t *c = &corvus_hdc; // Pick up global controller structure |
| 1083 | 1055 | |
| 1084 | | #if VERBOSE |
| 1085 | | logerror("corvus_read_boot_block: Reading boot block: %d\n", block); |
| 1086 | | #endif |
| 1056 | LOG(("corvus_read_boot_block: Reading boot block: %d\n", block)); |
| 1087 | 1057 | |
| 1088 | 1058 | return corvus_read_sector(0, 25 + block, c->buffer.read_512_response.data, 512); |
| 1089 | 1059 | |
| r1470 | r1471 | |
| 1112 | 1082 | |
| 1113 | 1083 | relative_sector = head * c->sectors_per_track + sector; |
| 1114 | 1084 | |
| 1115 | | #if VERBOSE |
| 1116 | | logerror("corvus_read_firmware_block: Reading firmware head: 0x%2.2x, sector: 0x%2.2x, relative_sector: 0x%2.2x\n", |
| 1117 | | head, sector, relative_sector); |
| 1118 | | #endif |
| 1085 | LOG(("corvus_read_firmware_block: Reading firmware head: 0x%2.2x, sector: 0x%2.2x, relative_sector: 0x%2.2x\n", |
| 1086 | head, sector, relative_sector)); |
| 1119 | 1087 | |
| 1120 | 1088 | status = corvus_read_sector(0, relative_sector, c->buffer.read_512_response.data, 512); // TODO: Which drive should Prep Mode talk to ??? |
| 1121 | 1089 | return status; |
| r1470 | r1471 | |
| 1145 | 1113 | |
| 1146 | 1114 | relative_sector = head * c->sectors_per_track + sector; |
| 1147 | 1115 | |
| 1148 | | #if VERBOSE |
| 1149 | | logerror("corvus_write_firmware_block: Writing firmware head: 0x%2.2x, sector: 0x%2.2x, relative_sector: 0x%2.2x\n", |
| 1150 | | head, sector, relative_sector); |
| 1151 | | #endif |
| 1116 | LOG(("corvus_write_firmware_block: Writing firmware head: 0x%2.2x, sector: 0x%2.2x, relative_sector: 0x%2.2x\n", |
| 1117 | head, sector, relative_sector)); |
| 1152 | 1118 | |
| 1153 | 1119 | status = corvus_write_sector(0, relative_sector, buffer, 512); // TODO: Which drive should Prep Mode talk to ??? |
| 1154 | 1120 | return status; |
| r1470 | r1471 | |
| 1187 | 1153 | len = 512; |
| 1188 | 1154 | } |
| 1189 | 1155 | |
| 1190 | | #if VERBOSE |
| 1191 | | logerror("corvus_format_drive: Formatting drive with 0x%5.5x sectors, pattern buffer (passed length: %d)follows\n", max_sector, len); |
| 1192 | | dump_buffer(pattern, 512); |
| 1193 | | #endif |
| 1156 | LOG(("corvus_format_drive: Formatting drive with 0x%5.5x sectors, pattern buffer (passed length: %d)follows\n", max_sector, len)); |
| 1157 | LOG_BUFFER(pattern, 512); |
| 1194 | 1158 | |
| 1195 | 1159 | for(sector = 0; sector <= max_sector; sector++) { |
| 1196 | 1160 | status = corvus_write_sector(0, sector, pattern, 512); |
| r1470 | r1471 | |
| 1245 | 1209 | |
| 1246 | 1210 | corvus_hdc_t *c = &corvus_hdc; |
| 1247 | 1211 | |
| 1248 | | #if VERBOSE && VERBOSE_RESPONSES |
| 1249 | | logerror("corvus_hdc_data_w: Complete packet received. Dump follows:\n"); |
| 1250 | | dump_buffer(c->buffer.raw_data, c->offset); |
| 1251 | | #endif |
| 1212 | if (VERBOSE_RESPONSES) |
| 1213 | { |
| 1214 | LOG(("corvus_hdc_data_w: Complete packet received. Dump follows:\n")); |
| 1215 | LOG_BUFFER(c->buffer.raw_data, c->offset); |
| 1216 | } |
| 1252 | 1217 | |
| 1253 | 1218 | if(!invalid_command_flag) { |
| 1254 | 1219 | if(!c->prep_mode) { |
| r1470 | r1471 | |
| 1359 | 1324 | logerror("corvus_hdc_data_w: Unimplemented Prep command, returning FATAL FAULT status!\n"); |
| 1360 | 1325 | } |
| 1361 | 1326 | } |
| 1362 | | #if VERBOSE && VERBOSE_RESPONSES |
| 1363 | | logerror("corvus_hdc_data_w: Command execution complete, status: 0x%2.2x. Response dump follows:\n", |
| 1364 | | c->buffer.single_byte_response.status); |
| 1365 | | dump_buffer(c->buffer.raw_data, c->xmit_bytes); |
| 1366 | | #endif |
| 1327 | if (VERBOSE_RESPONSES) |
| 1328 | { |
| 1329 | LOG(("corvus_hdc_data_w: Command execution complete, status: 0x%2.2x. Response dump follows:\n", |
| 1330 | c->buffer.single_byte_response.status)); |
| 1331 | LOG_BUFFER(c->buffer.raw_data, c->xmit_bytes); |
| 1332 | } |
| 1367 | 1333 | |
| 1368 | 1334 | } // if(!invalid_command_flag) |
| 1369 | 1335 | |
| r1470 | r1471 | |
| 1384 | 1350 | // |
| 1385 | 1351 | c->offset = 0; // Point to beginning of buffer for response |
| 1386 | 1352 | |
| 1387 | | #if VERBOSE |
| 1388 | | logerror("corvus_hdc_data_w: Setting one-time mame timer of %d microseconds to simulate disk function\n", c->delay); |
| 1389 | | #endif |
| 1353 | LOG(("corvus_hdc_data_w: Setting one-time mame timer of %d microseconds to simulate disk function\n", c->delay)); |
| 1390 | 1354 | |
| 1391 | 1355 | // |
| 1392 | 1356 | // Set up timers for command completion and timeout from host |
| r1470 | r1471 | |
| 1420 | 1384 | c->status |= CONTROLLER_DIRECTION; // Set to Controller-to-Host, Ready mode |
| 1421 | 1385 | c->status &= ~(CONTROLLER_BUSY); |
| 1422 | 1386 | |
| 1423 | | #if VERBOSE |
| 1424 | | logerror("corvus_hdc_callback: Callback executed with function CALLBACK_CTH_MODE\n"); |
| 1425 | | #endif |
| 1387 | LOG(("corvus_hdc_callback: Callback executed with function CALLBACK_CTH_MODE\n")); |
| 1426 | 1388 | |
| 1427 | 1389 | break; |
| 1428 | 1390 | case CALLBACK_HTC_MODE: |
| 1429 | 1391 | c->status &= ~(CONTROLLER_DIRECTION | |
| 1430 | 1392 | CONTROLLER_BUSY); // Set to Host-to-Controller, Ready mode |
| 1431 | 1393 | |
| 1432 | | #if VERBOSE |
| 1433 | | logerror("corvus_hdc_callback: Callback executed with function CALLBACK_HTC_MODE\n"); |
| 1434 | | #endif |
| 1394 | LOG(("corvus_hdc_callback: Callback executed with function CALLBACK_HTC_MODE\n")); |
| 1435 | 1395 | |
| 1436 | 1396 | break; |
| 1437 | 1397 | case CALLBACK_SAME_MODE: |
| r1470 | r1471 | |
| 1447 | 1407 | c->xmit_bytes = 1; |
| 1448 | 1408 | logerror("corvus_hdc_callback: Exceeded four-second timeout for data from host, resetting communications\n"); |
| 1449 | 1409 | } else { // if(c->recv_bytes == 0) This was a variable-size command |
| 1450 | | #if VERBOSE |
| 1451 | | logerror("corvus_hdc_callback: Executing variable-length command via four-second timeout\n"); |
| 1452 | | #endif |
| 1410 | LOG(("corvus_hdc_callback: Executing variable-length command via four-second timeout\n")); |
| 1453 | 1411 | corvus_process_command_packet(0); // Process the command |
| 1454 | 1412 | } |
| 1455 | 1413 | break; |
| r1470 | r1471 | |
| 1500 | 1458 | timer_adjust(c->timeout_timer, ATTOTIME_IN_SEC(4), CALLBACK_TIMEOUT, attotime_zero); |
| 1501 | 1459 | timer_enable(c->timeout_timer, 0); // Start this timer out disabled |
| 1502 | 1460 | |
| 1503 | | #if VERBOSE |
| 1504 | | logerror("corvus_hdc_init: Attached to drive image: H:%d, C:%d, S:%d\n", info->heads, info->cylinders, info->sectors); |
| 1505 | | #endif |
| 1461 | LOG(("corvus_hdc_init: Attached to drive image: H:%d, C:%d, S:%d\n", info->heads, info->cylinders, info->sectors)); |
| 1506 | 1462 | |
| 1507 | 1463 | // |
| 1508 | 1464 | // Define all of the packet sizes for the commands |
| r1470 | r1471 | |
| 1602 | 1558 | corvus_prep_cmd[PREP_WRITE_FIRMWARE].recv_bytes = 514; |
| 1603 | 1559 | corvus_prep_cmd[PREP_WRITE_FIRMWARE].xmit_bytes = 1; |
| 1604 | 1560 | |
| 1605 | | #if VERBOSE |
| 1606 | | logerror("corvus_hdc_init: Drive structures initialized\n"); |
| 1607 | | #endif |
| 1561 | LOG(("corvus_hdc_init: Drive structures initialized\n")); |
| 1608 | 1562 | |
| 1609 | 1563 | return TRUE; |
| 1610 | 1564 | } |
| r1470 | r1471 | |
| 1662 | 1616 | result = c->buffer.raw_data[c->offset++]; |
| 1663 | 1617 | |
| 1664 | 1618 | if(c->offset == c->xmit_bytes) { |
| 1665 | | #if VERBOSE |
| 1666 | | logerror("corvus_hdc_data_r: Finished transmitting %d bytes of data. Returning to idle mode.\n", c->xmit_bytes); |
| 1667 | | #endif |
| 1619 | LOG(("corvus_hdc_data_r: Finished transmitting %d bytes of data. Returning to idle mode.\n", c->xmit_bytes)); |
| 1668 | 1620 | |
| 1669 | 1621 | c->offset = 0; // We've reached the end of valid data |
| 1670 | 1622 | c->xmit_bytes = 0; // We don't have anything more to say |
| r1470 | r1471 | |
| 1720 | 1672 | // We're supposed to be paying attention. Make a decision about the data received |
| 1721 | 1673 | // |
| 1722 | 1674 | if(c->offset == 0) { // First byte of a packet |
| 1723 | | #if VERBOSE |
| 1724 | | logerror("corvus_hdc_data_w: Received a byte with c->offset == 0. Processing as command: 0x%2.2x\n", data); |
| 1725 | | #endif |
| 1675 | LOG(("corvus_hdc_data_w: Received a byte with c->offset == 0. Processing as command: 0x%2.2x\n", data)); |
| 1726 | 1676 | invalid_command_flag = parse_hdc_command(data); |
| 1727 | 1677 | timer_reset(c->timeout_timer, (ATTOTIME_IN_SEC(4))); |
| 1728 | 1678 | timer_enable(c->timeout_timer, 1); // Start our four-second timer |
| 1729 | 1679 | } else if(c->offset == 1 && c->awaiting_modifier) { // Second byte of a packet |
| 1730 | | #if VERBOSE |
| 1731 | | logerror("corvus_hdc_data_w: Received a byte while awaiting modifier with c->offset == 0. Processing as modifier: 0x%2.2x\n", data); |
| 1732 | | #endif |
| 1680 | LOG(("corvus_hdc_data_w: Received a byte while awaiting modifier with c->offset == 0. Processing as modifier: 0x%2.2x\n", data)); |
| 1733 | 1681 | c->awaiting_modifier = FALSE; |
| 1734 | 1682 | c->recv_bytes = corvus_cmd[c->buffer.command.code][data].recv_bytes; |
| 1735 | 1683 | c->xmit_bytes = corvus_cmd[c->buffer.command.code][data].xmit_bytes; |
src/mess/drivers/nc.c
| r1470 | r1471 | |
| 104 | 104 | #include "devices/cartslot.h" |
| 105 | 105 | #include "sound/beep.h" |
| 106 | 106 | |
| 107 | | /* uncomment for verbose debugging information */ |
| 108 | | /* #define VERBOSE */ |
| 109 | 107 | |
| 110 | | #define NC200_DEBUG |
| 108 | #define VERBOSE 0 |
| 109 | #define LOG(x) do { if (VERBOSE) logerror x; } while (0) |
| 111 | 110 | |
| 111 | #define NC200_DEBUG 1 |
| 112 | #define LOG_DEBUG(x) do { if (NC200_DEBUG) logerror x; } while (0) |
| 113 | |
| 114 | |
| 112 | 115 | #include "includes/centroni.h" |
| 113 | 116 | #include "devices/printer.h" |
| 114 | 117 | |
| r1470 | r1471 | |
| 313 | 316 | |
| 314 | 317 | static TIMER_CALLBACK(nc_keyboard_timer_callback) |
| 315 | 318 | { |
| 316 | | #ifdef VERBOSE |
| 317 | | logerror("keyboard int\n"); |
| 318 | | #endif |
| 319 | LOG(("keyboard int\n")); |
| 319 | 320 | |
| 320 | 321 | /* set int */ |
| 321 | 322 | nc_irq_status |= (1<<3); |
| r1470 | r1471 | |
| 361 | 362 | memory_set_bankptr(bank+1, addr); |
| 362 | 363 | |
| 363 | 364 | write_handler = MWA8_NOP; |
| 364 | | #ifdef VERBOSE |
| 365 | | logerror("BANK %d: ROM %d\n",bank,mem_bank); |
| 366 | | #endif |
| 365 | LOG(("BANK %d: ROM %d\n",bank,mem_bank)); |
| 367 | 366 | } |
| 368 | 367 | break; |
| 369 | 368 | |
| r1470 | r1471 | |
| 380 | 379 | memory_set_bankptr(bank+5, addr); |
| 381 | 380 | |
| 382 | 381 | write_handler = nc_bankhandler_w[bank]; |
| 383 | | #ifdef VERBOSE |
| 384 | | logerror("BANK %d: RAM\n",bank); |
| 385 | | #endif |
| 382 | LOG(("BANK %d: RAM\n",bank)); |
| 386 | 383 | } |
| 387 | 384 | break; |
| 388 | 385 | |
| r1470 | r1471 | |
| 413 | 410 | write_handler = MWA8_NOP; |
| 414 | 411 | } |
| 415 | 412 | |
| 416 | | #ifdef VERBOSE |
| 417 | | logerror("BANK %d: CARD-RAM\n",bank); |
| 418 | | #endif |
| 413 | LOG(("BANK %d: CARD-RAM\n",bank)); |
| 419 | 414 | } |
| 420 | 415 | else |
| 421 | 416 | { |
| r1470 | r1471 | |
| 457 | 452 | if (!file) |
| 458 | 453 | return; |
| 459 | 454 | |
| 460 | | #ifdef VERBOSE |
| 461 | | logerror("restoring nc memory\n"); |
| 462 | | #endif |
| 455 | LOG(("restoring nc memory\n")); |
| 463 | 456 | /* get size of memory data stored */ |
| 464 | 457 | mame_fread(file, &stored_size, sizeof(unsigned long)); |
| 465 | 458 | |
| r1470 | r1471 | |
| 480 | 473 | if (!file) |
| 481 | 474 | return; |
| 482 | 475 | |
| 483 | | #ifdef VERBOSE |
| 484 | | logerror("storing nc memory\n"); |
| 485 | | #endif |
| 476 | LOG(("storing nc memory\n")); |
| 486 | 477 | /* write size of memory data */ |
| 487 | 478 | mame_fwrite(file, &mess_ram_size, sizeof(unsigned long)); |
| 488 | 479 | |
| r1470 | r1471 | |
| 539 | 530 | { |
| 540 | 531 | case NC_TYPE_1xx: |
| 541 | 532 | { |
| 542 | | #ifdef VERBOSE |
| 543 | | logerror("nmi triggered\n"); |
| 544 | | #endif |
| 533 | LOG(("nmi triggered\n")); |
| 545 | 534 | cpunum_set_input_line(0, INPUT_LINE_NMI, PULSE_LINE); |
| 546 | 535 | } |
| 547 | 536 | break; |
| r1470 | r1471 | |
| 628 | 617 | |
| 629 | 618 | static WRITE8_HANDLER(nc_memory_management_w) |
| 630 | 619 | { |
| 631 | | #ifdef VERBOSE |
| 632 | | logerror("Memory management W: %02x %02x\n",offset,data); |
| 633 | | #endif |
| 620 | LOG(("Memory management W: %02x %02x\n",offset,data)); |
| 634 | 621 | nc_memory_config[offset] = data; |
| 635 | 622 | |
| 636 | 623 | nc_refresh_memory_config(); |
| r1470 | r1471 | |
| 638 | 625 | |
| 639 | 626 | static WRITE8_HANDLER(nc_irq_mask_w) |
| 640 | 627 | { |
| 641 | | #ifdef VERBOSE |
| 642 | | logerror("irq mask w: %02x\n", data); |
| 643 | | #endif |
| 644 | | #ifdef NC200_DEBUG |
| 645 | | logerror("irq mask nc200 w: %02x\n",data & ((1<<4) | (1<<5) | (1<<6) | (1<<7))); |
| 646 | | #endif |
| 628 | LOG(("irq mask w: %02x\n", data)); |
| 629 | LOG_DEBUG(("irq mask nc200 w: %02x\n",data & ((1<<4) | (1<<5) | (1<<6) | (1<<7)))); |
| 647 | 630 | |
| 648 | 631 | /* writing mask clears ints that are to be masked? */ |
| 649 | 632 | nc_irq_mask = data; |
| r1470 | r1471 | |
| 653 | 636 | |
| 654 | 637 | static WRITE8_HANDLER(nc_irq_status_w) |
| 655 | 638 | { |
| 656 | | #ifdef VERBOSE |
| 657 | | logerror("irq status w: %02x\n", data); |
| 658 | | #endif |
| 639 | LOG(("irq status w: %02x\n", data)); |
| 659 | 640 | data = data^0x0ff; |
| 660 | 641 | |
| 661 | 642 | if (nc_type == NC_TYPE_200) |
| r1470 | r1471 | |
| 734 | 715 | |
| 735 | 716 | static WRITE8_HANDLER(nc_sound_w) |
| 736 | 717 | { |
| 737 | | #ifdef VERBOSE |
| 738 | | logerror("sound w: %04x %02x\n", offset, data); |
| 739 | | #endif |
| 718 | LOG(("sound w: %04x %02x\n", offset, data)); |
| 719 | |
| 740 | 720 | switch (offset) |
| 741 | 721 | { |
| 742 | 722 | case 0x0: |
| r1470 | r1471 | |
| 827 | 807 | /* same for nc100 and nc200 */ |
| 828 | 808 | static WRITE8_HANDLER(nc_printer_data_w) |
| 829 | 809 | { |
| 830 | | #ifdef VERBOSE |
| 831 | | logerror("printer write %02x\n",data); |
| 832 | | #endif |
| 810 | LOG(("printer write %02x\n",data)); |
| 833 | 811 | centronics_write_data(0,data); |
| 834 | 812 | } |
| 835 | 813 | |
| r1470 | r1471 | |
| 862 | 840 | /* bit 3-0: not used */ |
| 863 | 841 | nc_display_memory_start = (data & 0x0f0)<<(12-4); |
| 864 | 842 | |
| 865 | | #ifdef VERBOSE |
| 866 | | logerror("disp memory w: %04x\n", (int) nc_display_memory_start); |
| 867 | | #endif |
| 868 | | |
| 843 | LOG(("disp memory w: %04x\n", (int) nc_display_memory_start)); |
| 869 | 844 | } |
| 870 | 845 | |
| 871 | 846 | |
| r1470 | r1471 | |
| 913 | 888 | { |
| 914 | 889 | if (state) |
| 915 | 890 | { |
| 916 | | // #ifdef VERBOSE |
| 917 | 891 | logerror("tx ready\n"); |
| 918 | | // #endif |
| 919 | 892 | nc_irq_latch |= (1<<1); |
| 920 | 893 | } |
| 921 | 894 | } |
| r1470 | r1471 | |
| 931 | 904 | { |
| 932 | 905 | if (state) |
| 933 | 906 | { |
| 934 | | //#ifdef VERBOSE |
| 935 | 907 | logerror("rx ready\n"); |
| 936 | | //#endif |
| 937 | 908 | nc_irq_latch |= (1<<0); |
| 938 | 909 | } |
| 939 | 910 | } |
| r1470 | r1471 | |
| 1028 | 999 | /* bits 7-1: not used */ |
| 1029 | 1000 | /* bit 0: 1 = no effect, 0 = power off */ |
| 1030 | 1001 | nc_poweroff_control = data; |
| 1031 | | #ifdef VERBOSE |
| 1032 | | logerror("nc poweroff control: %02x\n",data); |
| 1033 | | #endif |
| 1002 | LOG(("nc poweroff control: %02x\n",data)); |
| 1034 | 1003 | } |
| 1035 | 1004 | |
| 1036 | 1005 | |
| r1470 | r1471 | |
| 1084 | 1053 | |
| 1085 | 1054 | static WRITE8_HANDLER(nc100_memory_card_wait_state_w) |
| 1086 | 1055 | { |
| 1087 | | #ifdef VERBOSE |
| 1088 | | logerror("nc100 memory card wait state: %02x\n",data); |
| 1089 | | #endif |
| 1056 | LOG(("nc100 memory card wait state: %02x\n",data)); |
| 1090 | 1057 | } |
| 1091 | 1058 | |
| 1092 | 1059 | |
| r1470 | r1471 | |
| 1255 | 1222 | /* bit 4-0: not used */ |
| 1256 | 1223 | nc_display_memory_start = (data & 0x0e0)<<(12-4); |
| 1257 | 1224 | |
| 1258 | | #ifdef VERBOSE |
| 1259 | | logerror("disp memory w: %04x\n", (int) nc_display_memory_start); |
| 1260 | | #endif |
| 1225 | LOG(("disp memory w: %04x\n", (int) nc_display_memory_start)); |
| 1261 | 1226 | } |
| 1262 | 1227 | #endif |
| 1263 | 1228 | |
| r1470 | r1471 | |
| 1365 | 1330 | #ifdef UNUSED_FUNCTION |
| 1366 | 1331 | static void nc200_floppy_drive_index_callback(int drive_id) |
| 1367 | 1332 | { |
| 1368 | | #ifdef NC200_DEBUG |
| 1369 | | logerror("nc200 index pulse\n"); |
| 1370 | | #endif |
| 1333 | LOG_DEBUG(("nc200 index pulse\n")); |
| 1371 | 1334 | // nc_irq_status |= (1<<4); |
| 1372 | 1335 | |
| 1373 | 1336 | // nc_update_interrupts(); |
| r1470 | r1471 | |
| 1519 | 1482 | } |
| 1520 | 1483 | |
| 1521 | 1484 | /* bit 5 is used in disk interface */ |
| 1522 | | #ifdef NC200_DEBUG |
| 1523 | | logerror("bit 5: PC: %04x %02x\n",activecpu_get_pc(), data & (1<<5)); |
| 1524 | | #endif |
| 1485 | LOG_DEBUG(("bit 5: PC: %04x %02x\n",activecpu_get_pc(), data & (1<<5))); |
| 1525 | 1486 | } |
| 1526 | 1487 | |
| 1527 | 1488 | |
| r1470 | r1471 | |
| 1539 | 1500 | |
| 1540 | 1501 | static WRITE8_HANDLER(nc200_memory_card_wait_state_w) |
| 1541 | 1502 | { |
| 1542 | | #ifdef NC200_DEBUG |
| 1543 | | logerror("nc200 memory card wait state: PC: %04x %02x\n",activecpu_get_pc(),data); |
| 1544 | | #endif |
| 1503 | LOG_DEBUG(("nc200 memory card wait state: PC: %04x %02x\n",activecpu_get_pc(),data)); |
| 1545 | 1504 | floppy_drive_set_motor_state(0,1); |
| 1546 | 1505 | floppy_drive_set_ready_state(0,1,1); |
| 1547 | 1506 | |
| r1470 | r1471 | |
| 1553 | 1512 | /* bit 0 seems to be the same as nc100 */ |
| 1554 | 1513 | static WRITE8_HANDLER(nc200_poweroff_control_w) |
| 1555 | 1514 | { |
| 1556 | | #ifdef NC200_DEBUG |
| 1557 | | logerror("nc200 power off: PC: %04x %02x\n", activecpu_get_pc(),data); |
| 1558 | | #endif |
| 1515 | LOG_DEBUG(("nc200 power off: PC: %04x %02x\n", activecpu_get_pc(),data)); |
| 1559 | 1516 | |
| 1560 | 1517 | nc200_video_set_backlight(((data^(1<<2))>>2) & 0x01); |
| 1561 | 1518 | } |