trunk/src/mess/machine/upd765.c
| r18829 | r18830 | |
| 148 | 148 | for(int i=0; i<4; i++) { |
| 149 | 149 | flopi[i].main_state = IDLE; |
| 150 | 150 | flopi[i].sub_state = IDLE; |
| 151 | | flopi[i].irq_seek = false; |
| 152 | 151 | flopi[i].live = false; |
| 153 | 152 | flopi[i].ready = !ready_polled; |
| 154 | | flopi[i].irq_polled = false; |
| 153 | flopi[i].irq = floppy_info::IRQ_NONE; |
| 155 | 154 | } |
| 156 | 155 | data_irq = false; |
| 156 | polled_irq = false; |
| 157 | 157 | internal_drq = false; |
| 158 | 158 | fifo_pos = 0; |
| 159 | 159 | command_pos = 0; |
| r18829 | r18830 | |
| 1097 | 1097 | main_phase = PHASE_RESULT; |
| 1098 | 1098 | |
| 1099 | 1099 | int fid; |
| 1100 | | for(fid=0; fid<4 && !flopi[fid].irq_seek; fid++); |
| 1101 | | if(fid == 4) |
| 1102 | | for(fid=0; fid<4 && !flopi[fid].irq_polled; fid++); |
| 1100 | for(fid=0; fid<4 && flopi[fid].irq == floppy_info::IRQ_NONE; fid++); |
| 1103 | 1101 | if(fid == 4) { |
| 1104 | 1102 | st0 = ST0_UNK; |
| 1105 | 1103 | result[0] = st0; |
| r18829 | r18830 | |
| 1109 | 1107 | break; |
| 1110 | 1108 | } |
| 1111 | 1109 | floppy_info &fi = flopi[fid]; |
| 1112 | | if(fi.irq_seek) |
| 1113 | | fi.irq_seek = false; |
| 1114 | | |
| 1115 | | else if(fi.irq_polled) { |
| 1110 | if(fi.irq == floppy_info::IRQ_POLLED) { |
| 1116 | 1111 | // Documentation is somewhat contradictory w.r.t polling |
| 1117 | 1112 | // and irq. PC bios, especially 5150, requires that only |
| 1118 | 1113 | // one irq happens. That's also wait the ns82077a doc |
| 1119 | 1114 | // says it does. OTOH, a number of docs says you need to |
| 1120 | 1115 | // call SIS 4 times, once per drive... |
| 1121 | 1116 | // |
| 1122 | | // Let's take the option that allows PC to boot. |
| 1117 | // There's also the interaction with the seek irq. The |
| 1118 | // somewhat borderline tf20 code seems to think that |
| 1119 | // essentially ignoring the polling irq should work. |
| 1120 | // |
| 1121 | // So at that point the best bet seems to drop the |
| 1122 | // "polled" irq as soon as a SIS happens, and override any |
| 1123 | // polled-in-waiting information when a seek irq happens |
| 1124 | // for a given floppy. |
| 1123 | 1125 | |
| 1124 | | for(int i=0; i<4; i++) |
| 1125 | | flopi[i].irq_polled = false; |
| 1126 | | |
| 1127 | 1126 | st0 = ST0_ABRT | fid; |
| 1128 | | } else { |
| 1129 | | abort(); |
| 1130 | 1127 | } |
| 1128 | fi.irq = floppy_info::IRQ_NONE; |
| 1129 | |
| 1130 | polled_irq = false; |
| 1131 | |
| 1131 | 1132 | result[0] = st0; |
| 1132 | 1133 | result[1] = fi.pcn; |
| 1133 | 1134 | logerror("%s: command sense interrupt status (fid=%d %02x %02x)\n", tag(), fid, result[0], result[1]); |
| r18829 | r18830 | |
| 1165 | 1166 | if(data_completion) |
| 1166 | 1167 | data_irq = true; |
| 1167 | 1168 | else |
| 1168 | | fi.irq_seek = true; |
| 1169 | fi.irq = floppy_info::IRQ_SEEK; |
| 1169 | 1170 | check_irq(); |
| 1170 | 1171 | } |
| 1171 | 1172 | |
| r18829 | r18830 | |
| 1785 | 1786 | void upd765_family_device::check_irq() |
| 1786 | 1787 | { |
| 1787 | 1788 | bool old_irq = cur_irq; |
| 1788 | | cur_irq = data_irq || internal_drq; |
| 1789 | cur_irq = data_irq || polled_irq || internal_drq; |
| 1789 | 1790 | for(int i=0; i<4; i++) |
| 1790 | | cur_irq = cur_irq || flopi[i].irq_seek || flopi[i].irq_polled; |
| 1791 | cur_irq = cur_irq || flopi[i].irq == floppy_info::IRQ_SEEK; |
| 1791 | 1792 | cur_irq = cur_irq && (dor & 4) && (dor & 8); |
| 1792 | 1793 | if(cur_irq != old_irq && !intrq_cb.isnull()) { |
| 1793 | 1794 | logerror("%s: irq = %d\n", tag(), cur_irq); |
| r18829 | r18830 | |
| 1851 | 1852 | if(ready != flopi[fid].ready) { |
| 1852 | 1853 | logerror("%s: polled %d : %d -> %d\n", tag(), fid, flopi[fid].ready, ready); |
| 1853 | 1854 | flopi[fid].ready = ready; |
| 1854 | | flopi[fid].irq_polled = true; |
| 1855 | | changed = true; |
| 1855 | if(flopi[fid].irq == floppy_info::IRQ_NONE) { |
| 1856 | flopi[fid].irq = floppy_info::IRQ_POLLED; |
| 1857 | polled_irq = true; |
| 1858 | changed = true; |
| 1859 | } |
| 1856 | 1860 | } |
| 1857 | 1861 | } |
| 1858 | 1862 | if(changed) |
trunk/src/mess/machine/upd765.h
| r18829 | r18830 | |
| 249 | 249 | }; |
| 250 | 250 | |
| 251 | 251 | struct floppy_info { |
| 252 | enum { IRQ_NONE, IRQ_SEEK, IRQ_POLLED }; |
| 252 | 253 | emu_timer *tm; |
| 253 | 254 | floppy_image_device *dev; |
| 254 | 255 | int id; |
| 255 | 256 | int main_state, sub_state; |
| 256 | 257 | int dir, counter; |
| 257 | 258 | UINT8 pcn; |
| 258 | | bool irq_seek, live, index, ready, irq_polled; |
| 259 | int irq; |
| 260 | bool live, index, ready; |
| 259 | 261 | }; |
| 260 | 262 | |
| 261 | 263 | struct live_info { |
| r18829 | r18830 | |
| 284 | 286 | |
| 285 | 287 | live_info cur_live, checkpoint_live; |
| 286 | 288 | line_cb intrq_cb, drq_cb; |
| 287 | | bool cur_irq, data_irq, drq, internal_drq, tc, tc_done, locked; |
| 289 | bool cur_irq, polled_irq, data_irq, drq, internal_drq, tc, tc_done, locked; |
| 288 | 290 | floppy_info flopi[4]; |
| 289 | 291 | |
| 290 | 292 | int fifo_pos, fifo_expected, command_pos, result_pos; |