Previous 15994 Revisions Next

r13179 Sunday 6th November, 2011 at 18:46:22 UTC by Olivier Galibert
amigafdc: Fixes, fixes and more fixes [O. Galibert]
[src/emu/machine]amigafdc.c

src/emu/machine/amigafdc.c
r13178r13179
8282void amiga_fdc::live_delay(int state)
8383{
8484   cur_live.next_state = state;
85   t_gen->adjust(cur_live.tm - machine().time());
85   if(cur_live.tm != machine().time())
86      t_gen->adjust(cur_live.tm - machine().time());
8687}
8788
8889void amiga_fdc::live_sync()
r13178r13179
9192      if(cur_live.tm > machine().time()) {
9293         rollback();
9394         live_run(machine().time());
94      } else {
95         if(cur_live.next_state != -1)
95      }
96      if(cur_live.tm == machine().time()) {
97         if(cur_live.next_state != -1) {
9698            cur_live.state = cur_live.next_state;
99            cur_live.next_state = -1;
100         }
97101         if(cur_live.state == IDLE)
98102            cur_live.tm = attotime::never;
99103      }
100      cur_live.next_state = -1;
101104      checkpoint();
102105   }
103106}
r13178r13179
120123         int bit = cur_live.pll.get_next_bit(cur_live.tm, floppy, limit);
121124         if(bit < 0)
122125            return;
126
123127         cur_live.shift_reg = (cur_live.shift_reg << 1) | bit;
124128         cur_live.bit_counter++;
125129
126         if((adkcon & 0x0200) && !(cur_live.shift_reg & 0x80))
130         if((adkcon & 0x0200) && !(cur_live.shift_reg & 0x80)) {
127131            cur_live.bit_counter--;
128132
133            // Avoid any risk of livelock
134            live_delay(RUNNING_SYNCPOINT);
135            return;
136         }
137
138         if(cur_live.bit_counter > 8)
139            abort();
140
129141         if(cur_live.bit_counter == 8) {
130142            live_delay(RUNNING_SYNCPOINT);
131143            return;
r13178r13179
147159      case RUNNING_SYNCPOINT: {
148160         if(cur_live.shift_reg == dsksync) {
149161            if(adkcon & 0x0400) {
150               if(dma_state == DMA_WAIT_START)
162               if(dma_state == DMA_WAIT_START) {
151163                  dma_state = DMA_RUNNING_BYTE_0;
152
153               cur_live.bit_counter = 0;
164                  cur_live.bit_counter = 0;
165               } else if(cur_live.bit_counter != 8)
166                  cur_live.bit_counter = 0;
154167            }
155168            dskbyt |= 0x0400;
156169            address_space *space = machine().device("maincpu")->memory().space(AS_PROGRAM);
r13178r13179
218231{
219232   live_sync();
220233   adkcon = data;
234   live_run();
221235}
222236
223237void amiga_fdc::dsklen_w(UINT16 data)
r13178r13179
234248         dskbyt |= 0x4000;
235249   } else
236250      pre_dsklen = data;
251   live_run();
237252}
238253
239254void amiga_fdc::dskpth_w(UINT16 data)
240255{
241256   live_sync();
242257   dskpt = (dskpt & 0xffff) | (data << 16);
258   live_run();
243259}
244260
245261void amiga_fdc::dskptl_w(UINT16 data)
246262{
247263   live_sync();
248264   dskpt = (dskpt & 0xffff0000) | data;
265   live_run();
249266}
250267
251268UINT16 amiga_fdc::dskpth_r()
r13178r13179
262279{
263280   live_sync();
264281   dsksync = data;
282   live_run();
265283}
266284
267285void amiga_fdc::dmacon_set(UINT16 data)
r13178r13179
272290   dskbyt = dskbyt & 0xbfff;
273291   if(dma_state != DMA_IDLE)
274292      dskbyt |= 0x4000;
293   live_run();
275294}
276295
277296UINT16 amiga_fdc::dskbytr_r()
r13178r13179
306325
307326WRITE8_MEMBER( amiga_fdc::ciaaprb_w )
308327{
328   floppy_image_device *old_floppy = floppy;
329
309330   live_sync();
310331
311332   if(!(data & 0x08))
r13178r13179
319340   else
320341      floppy = 0;
321342
343   if(old_floppy != floppy) {
344      if(old_floppy)
345         old_floppy->setup_index_pulse_cb(floppy_image_device::index_pulse_cb());
346      if(floppy)
347         floppy->setup_index_pulse_cb(floppy_image_device::index_pulse_cb(FUNC(amiga_fdc::index_callback), this));
348   }
349
322350   if(floppy) {
323351      floppy->ss_w(!((data >> 2) & 1));
324352      floppy->dir_w((data >> 1) & 1);
r13178r13179
333361      live_abort();
334362
335363   setup_leds();
364   live_run();
336365}
337366
338367UINT8 amiga_fdc::ciaapra_r()

Previous 15994 Revisions Next


© 1998-2018 The MESS Team