trunk/src/mess/machine/victor9k_fdc.c
| r242159 | r242160 | |
| 11 | 11 | |
| 12 | 12 | /* |
| 13 | 13 | |
| 14 | value error description |
| 15 | |
| 16 | 01 no sync pulse detected |
| 17 | 02 no header track |
| 18 | 03 checksum error in header |
| 19 | 04 not right track |
| 20 | 05 not right sector |
| 21 | 06 not a data block |
| 22 | 07 data checksum error |
| 23 | 08 sync too long |
| 24 | 99 not a system disc |
| 25 | |
| 26 | */ |
| 27 | |
| 28 | /* |
| 29 | |
| 14 | 30 | TODO: |
| 15 | 31 | |
| 16 | | - disk error 2 (cannot find block header?) |
| 32 | - communication error with SCP after loading boot sector |
| 17 | 33 | - 8048 spindle speed control |
| 18 | 34 | - read PLL |
| 19 | 35 | - write logic |
| r242159 | r242160 | |
| 37 | 53 | #define M6522_5_TAG "1k" |
| 38 | 54 | #define M6522_6_TAG "1h" |
| 39 | 55 | |
| 56 | #define GCR_DECODE(_e, _i) \ |
| 57 | ((BIT(_e, 6) << 7) | (BIT(_i, 7) << 6) | (_e & 0x33) | (BIT(_e, 2) << 3) | (_i & 0x04)) |
| 40 | 58 | |
| 41 | 59 | |
| 42 | 60 | //************************************************************************** |
| r242159 | r242160 | |
| 209 | 227 | m_via4_irq(CLEAR_LINE), |
| 210 | 228 | m_via5_irq(CLEAR_LINE), |
| 211 | 229 | m_via6_irq(CLEAR_LINE), |
| 212 | | m_syn(0), |
| 213 | | m_lbrdy(1), |
| 214 | 230 | m_period(attotime::from_nsec(2130)) |
| 215 | 231 | { |
| 216 | 232 | cur_live.tm = attotime::never; |
| r242159 | r242160 | |
| 259 | 275 | save_item(NAME(m_via4_irq)); |
| 260 | 276 | save_item(NAME(m_via5_irq)); |
| 261 | 277 | save_item(NAME(m_via6_irq)); |
| 262 | | save_item(NAME(m_syn)); |
| 263 | | save_item(NAME(m_lbrdy)); |
| 264 | 278 | } |
| 265 | 279 | |
| 266 | 280 | |
| r242159 | r242160 | |
| 630 | 644 | |
| 631 | 645 | */ |
| 632 | 646 | |
| 633 | | UINT8 e = checkpoint_live.e; |
| 634 | | UINT8 i = checkpoint_live.i; |
| 635 | | |
| 636 | | return BIT(e, 6) << 7 | BIT(i, 7) << 6 | BIT(e, 5) << 5 | BIT(e, 4) << 4 | BIT(e, 2) << 3 | BIT(i, 1) << 2 | (e & 0x03); |
| 647 | return GCR_DECODE(checkpoint_live.e, checkpoint_live.i); |
| 637 | 648 | } |
| 638 | 649 | |
| 639 | 650 | WRITE8_MEMBER( victor_9000_fdc_t::via5_pb_w ) |
| r242159 | r242160 | |
| 886 | 897 | { |
| 887 | 898 | live_sync(); |
| 888 | 899 | cur_live.lbrdy = 1; |
| 889 | | if (LOG_VIA) logerror("%s %s LBRDY 1\n", machine().time().as_string(), machine().describe_context()); |
| 890 | | m_lbrdy_cb(1); |
| 891 | | checkpoint(); |
| 892 | | live_run(); |
| 900 | cur_live.lbrdy_changed = true; |
| 901 | if (LOG_VIA) logerror("%s %s LBRDY 1 : %02x\n", machine().time().as_string(), machine().describe_context(), m_via5->read(space, offset)); |
| 902 | live_delay(RUNNING_SYNCPOINT); |
| 893 | 903 | } |
| 894 | 904 | |
| 895 | 905 | return m_via5->read(space, offset); |
| r242159 | r242160 | |
| 901 | 911 | { |
| 902 | 912 | live_sync(); |
| 903 | 913 | cur_live.lbrdy = 1; |
| 914 | cur_live.lbrdy_changed = true; |
| 904 | 915 | if (LOG_VIA) logerror("%s %s LBRDY 1\n", machine().time().as_string(), machine().describe_context()); |
| 905 | | m_lbrdy_cb(1); |
| 906 | | checkpoint(); |
| 907 | | live_run(); |
| 916 | live_delay(RUNNING_SYNCPOINT); |
| 908 | 917 | } |
| 909 | 918 | |
| 910 | 919 | m_via5->write(space, offset, data); |
| r242159 | r242160 | |
| 1045 | 1054 | |
| 1046 | 1055 | cur_live.brdy = 1; |
| 1047 | 1056 | cur_live.lbrdy = 1; |
| 1057 | cur_live.lbrdy_changed = true; |
| 1048 | 1058 | cur_live.sync = 1; |
| 1049 | 1059 | cur_live.syn = 1; |
| 1060 | cur_live.syn_changed = true; |
| 1050 | 1061 | cur_live.gcr_err = 1; |
| 1051 | 1062 | } |
| 1052 | 1063 | |
| r242159 | r242160 | |
| 1088 | 1099 | // sync counter |
| 1089 | 1100 | if (sync) { |
| 1090 | 1101 | cur_live.sync_bit_counter = 0; |
| 1091 | | cur_live.sync_byte_counter = 10; |
| 1102 | cur_live.sync_byte_counter = 9; |
| 1092 | 1103 | } else if (!cur_live.sync) { |
| 1093 | 1104 | cur_live.sync_bit_counter++; |
| 1094 | 1105 | if (cur_live.sync_bit_counter == 10) { |
| r242159 | r242160 | |
| 1103 | 1114 | // syn |
| 1104 | 1115 | int syn = !(cur_live.sync_byte_counter == 15); |
| 1105 | 1116 | |
| 1106 | | if (LOG) logerror("%s bit %u sync %u bc %u sbc %u sBC %u syn %u\n",cur_live.tm.as_string(),bit,sync,cur_live.bit_counter,cur_live.sync_bit_counter,cur_live.sync_byte_counter,syn); |
| 1107 | | |
| 1108 | 1117 | // GCR decoder |
| 1109 | 1118 | if (cur_live.drw) { |
| 1110 | 1119 | cur_live.i = cur_live.drw << 10 | cur_live.shift_reg; |
| r242159 | r242160 | |
| 1114 | 1123 | |
| 1115 | 1124 | cur_live.e = m_gcr_rom->base()[cur_live.i]; |
| 1116 | 1125 | |
| 1126 | if (LOG) logerror("%s bit %u sync %u bc %u sbc %u sBC %u syn %u i %03x e %02x\n",cur_live.tm.as_string(),bit,sync,cur_live.bit_counter,cur_live.sync_bit_counter,cur_live.sync_byte_counter,syn,cur_live.i,cur_live.e); |
| 1127 | |
| 1117 | 1128 | // byte ready |
| 1118 | 1129 | int brdy = !(cur_live.bit_counter == 9); |
| 1119 | 1130 | |
| r242159 | r242160 | |
| 1122 | 1133 | |
| 1123 | 1134 | if (brdy != cur_live.brdy) { |
| 1124 | 1135 | if (LOG) logerror("%s BRDY %u\n", cur_live.tm.as_string(),brdy); |
| 1125 | | if (LOG && !brdy) |
| 1136 | if (!brdy) |
| 1126 | 1137 | { |
| 1127 | | UINT8 e = cur_live.e; |
| 1128 | | UINT8 i = cur_live.i; |
| 1129 | | |
| 1130 | | UINT8 data = BIT(e, 6) << 7 | BIT(i, 7) << 6 | BIT(e, 5) << 5 | BIT(e, 4) << 4 | BIT(e, 2) << 3 | BIT(i, 1) << 2 | (e & 0x03); |
| 1131 | | logerror("%s BRDY %02x\n",cur_live.tm.as_string(),data); |
| 1138 | cur_live.lbrdy = 0; |
| 1139 | cur_live.lbrdy_changed = true; |
| 1140 | if (LOG_VIA) logerror("%s LBRDY 0 : %02x\n", cur_live.tm.as_string(), GCR_DECODE(cur_live.e, cur_live.i)); |
| 1132 | 1141 | } |
| 1133 | 1142 | cur_live.brdy = brdy; |
| 1134 | | if (!brdy) cur_live.lbrdy = 0; |
| 1135 | 1143 | syncpoint = true; |
| 1136 | 1144 | } |
| 1137 | 1145 | |
| r242159 | r242160 | |
| 1144 | 1152 | if (syn != cur_live.syn) { |
| 1145 | 1153 | if (LOG) logerror("%s SYN %u\n", cur_live.tm.as_string(),syn); |
| 1146 | 1154 | cur_live.syn = syn; |
| 1155 | cur_live.syn_changed = true; |
| 1147 | 1156 | syncpoint = true; |
| 1148 | 1157 | } |
| 1149 | 1158 | |
| r242159 | r242160 | |
| 1166 | 1175 | } |
| 1167 | 1176 | |
| 1168 | 1177 | case RUNNING_SYNCPOINT: { |
| 1169 | | m_lbrdy_cb(cur_live.lbrdy); |
| 1170 | | m_syn_cb(cur_live.syn); |
| 1178 | if (cur_live.lbrdy_changed) { |
| 1179 | m_lbrdy_cb(cur_live.lbrdy); |
| 1180 | cur_live.lbrdy_changed = false; |
| 1181 | } |
| 1171 | 1182 | |
| 1183 | if (cur_live.syn_changed) { |
| 1184 | m_syn_cb(cur_live.syn); |
| 1185 | cur_live.syn_changed = false; |
| 1186 | } |
| 1187 | |
| 1188 | m_via5->write_ca1(cur_live.brdy); |
| 1189 | |
| 1172 | 1190 | cur_live.state = RUNNING; |
| 1173 | 1191 | checkpoint(); |
| 1174 | 1192 | break; |