@@ -345,7 +345,7 @@ uint16_t sega_32x_device::m68k_a15106_r()
345
345
346
346
retval = m_a15106_reg;
347
347
348
- if (m_fifo_block_a_full && m_fifo_block_b_full ) retval |= 0x8080 ;
348
+ if (m_fifo[ 0 ]. full () && m_fifo[ 1 ]. full () ) retval |= 0x8080 ;
349
349
350
350
return retval;
351
351
}
@@ -373,12 +373,10 @@ void sega_32x_device::m68k_a15106_w(address_space &space, offs_t offset, uint16_
373
373
374
374
if ((m_a15106_reg & 4 ) == 0 ) // clears the FIFO state
375
375
{
376
- m_current_fifo_block = m_fifo_block_a;
377
- m_current_fifo_readblock = m_fifo_block_b;
378
- m_current_fifo_write_pos = 0 ;
379
- m_current_fifo_read_pos = 0 ;
380
- m_fifo_block_a_full = 0 ;
381
- m_fifo_block_b_full = 0 ;
376
+ m_fifo[0 ].clear ();
377
+ m_fifo[1 ].clear ();
378
+ m_fifo_write_block = 0 ;
379
+ m_fifo_read_block = 0 ;
382
380
}
383
381
384
382
// logerror("m68k_a15106_w %04x\n", data);
@@ -423,45 +421,18 @@ uint16_t sega_32x_device::dreq_common_r(address_space &space, offs_t offset)
423
421
return 0xffff ;
424
422
}
425
423
426
- uint16_t retdat = m_current_fifo_readblock[m_current_fifo_read_pos];
427
-
428
- m_current_fifo_read_pos++;
429
-
430
- // logerror("reading FIFO!\n");
431
-
432
- if (m_current_fifo_readblock == m_fifo_block_a && !m_fifo_block_a_full)
433
- logerror (" Fifo block a isn't filled!\n " );
434
-
435
- if (m_current_fifo_readblock == m_fifo_block_b && !m_fifo_block_b_full)
436
- logerror (" %s Fifo block b isn't filled!\n " , machine ().describe_context ());
437
-
438
-
439
- if (m_current_fifo_read_pos==4 )
424
+ if (m_fifo[m_fifo_read_block].empty ())
440
425
{
441
- if (m_current_fifo_readblock == m_fifo_block_a)
442
- {
443
- m_fifo_block_a_full = 0 ;
444
-
445
- if (m_fifo_block_b_full)
446
- {
447
- m_current_fifo_readblock = m_fifo_block_b;
448
- m_current_fifo_block = m_fifo_block_a;
449
- }
450
-
451
- m_current_fifo_read_pos = 0 ;
452
- }
453
- else if (m_current_fifo_readblock == m_fifo_block_b)
454
- {
455
- m_fifo_block_b_full = 0 ;
426
+ logerror (" Attempt to read FIFO while empty %c!\n " , m_fifo_read_block ? ' B' : ' A' );
427
+ return 0xffff ;
428
+ }
456
429
457
- if (m_fifo_block_a_full)
458
- {
459
- m_current_fifo_readblock = m_fifo_block_a;
460
- m_current_fifo_block = m_fifo_block_b;
461
- }
430
+ uint16_t retdat = m_fifo[m_fifo_read_block].dequeue ();
462
431
463
- m_current_fifo_read_pos = 0 ;
464
- }
432
+ if (m_fifo[m_fifo_read_block].empty ())
433
+ {
434
+ m_fifo_read_block ^= 1 ;
435
+ // m_main_cpu->resume(1);
465
436
}
466
437
467
438
return retdat;
@@ -527,15 +498,11 @@ void sega_32x_device::dreq_common_w(address_space &space, offs_t offset, uint16_
527
498
return ;
528
499
}
529
500
530
- if (m_current_fifo_block==m_fifo_block_a && m_fifo_block_a_full)
531
- {
532
- logerror (" attempt to write to Full Fifo block a!\n " );
533
- return ;
534
- }
535
-
536
- if (m_current_fifo_block==m_fifo_block_b && m_fifo_block_b_full)
501
+ if (m_fifo[m_fifo_write_block].full ())
537
502
{
538
- logerror (" attempt to write to Full Fifo block b!\n " );
503
+ logerror (" Attempt to write with FIFO full block %c!\n " , m_fifo_write_block ? ' B' : ' A' );
504
+ m_main_cpu->defer_access ();
505
+ // m_main_cpu->suspend_until_trigger(1, true);
539
506
return ;
540
507
}
541
508
@@ -553,43 +520,23 @@ void sega_32x_device::dreq_common_w(address_space &space, offs_t offset, uint16_
553
520
return ;
554
521
}
555
522
556
- m_current_fifo_block[m_current_fifo_write_pos] = data;
557
- m_current_fifo_write_pos++;
523
+ m_fifo[m_fifo_write_block].enqueue (data);
558
524
m_dreq_size --;
559
525
560
- if (m_current_fifo_write_pos== 4 )
526
+ if (m_fifo[m_fifo_write_block]. full () )
561
527
{
562
- if (m_current_fifo_block==m_fifo_block_a)
563
- {
564
- m_fifo_block_a_full = 1 ;
565
- if (!m_fifo_block_b_full)
566
- {
567
- m_current_fifo_block = m_fifo_block_b;
568
- m_current_fifo_readblock = m_fifo_block_a;
569
- // incase we have a stalled DMA in progress, let the SH2 know there is data available
570
- m_master_cpu->sh2_notify_dma_data_available ();
571
- m_slave_cpu->sh2_notify_dma_data_available ();
572
-
573
- }
574
- m_current_fifo_write_pos = 0 ;
575
- }
576
- else
577
- {
578
- m_fifo_block_b_full = 1 ;
579
-
580
- if (!m_fifo_block_a_full)
581
- {
582
- m_current_fifo_block = m_fifo_block_a;
583
- m_current_fifo_readblock = m_fifo_block_b;
584
- // incase we have a stalled DMA in progress, let the SH2 know there is data available
585
- m_master_cpu->sh2_notify_dma_data_available ();
586
- m_slave_cpu->sh2_notify_dma_data_available ();
587
- }
588
-
589
- m_current_fifo_write_pos = 0 ;
590
- }
528
+ m_fifo_write_block ^= 1 ;
529
+ m_master_cpu->sh2_notify_dma_data_available ();
530
+ m_slave_cpu->sh2_notify_dma_data_available ();
591
531
}
592
532
533
+ // if (m_fifo[0].full() && m_fifo[1].full())
534
+ // {
535
+ // //m_fifo_read_block ^= 1;
536
+ // //m_master_cpu->sh2_notify_dma_data_available();
537
+ // //m_slave_cpu->sh2_notify_dma_data_available();
538
+ // }
539
+
593
540
break ;
594
541
}
595
542
}
@@ -1560,10 +1507,10 @@ SH2_DMA_FIFO_DATA_AVAILABLE_CB(sega_32x_device::_32x_fifo_available_callback)
1560
1507
{
1561
1508
if (src==0x4012 )
1562
1509
{
1563
- if (m_current_fifo_readblock==m_fifo_block_a && m_fifo_block_a_full )
1510
+ if (!m_fifo[ 0 ]. empty () && m_fifo_read_block == 0 )
1564
1511
return 1 ;
1565
1512
1566
- if (m_current_fifo_readblock==m_fifo_block_b && m_fifo_block_b_full )
1513
+ if (!m_fifo[ 1 ]. empty () && m_fifo_read_block == 1 )
1567
1514
return 1 ;
1568
1515
1569
1516
return 0 ;
@@ -1724,6 +1671,7 @@ void sega_32x_device::device_add_mconfig(machine_config &config)
1724
1671
// (update: actually fixed by using synchronize in comms space)
1725
1672
// sharrierju: "press start button" will flicker at /512 onward
1726
1673
// chaotixju: hangs after sega logo at /256
1674
+ // twcmd: expects /64 after FIFO rewrite
1727
1675
1728
1676
// some games appear to dislike 'perfect' levels of interleave, probably due to
1729
1677
// non-emulated cache, ram waitstates and other issues?
@@ -1807,12 +1755,10 @@ void sega_32x_device::device_reset()
1807
1755
m_32x_displaymode = 0 ;
1808
1756
m_32x_240mode = 0 ;
1809
1757
1810
- m_current_fifo_block = m_fifo_block_a;
1811
- m_current_fifo_readblock = m_fifo_block_b;
1812
- m_current_fifo_write_pos = 0 ;
1813
- m_current_fifo_read_pos = 0 ;
1814
- m_fifo_block_a_full = 0 ;
1815
- m_fifo_block_b_full = 0 ;
1758
+ m_fifo[0 ].clear ();
1759
+ m_fifo[1 ].clear ();
1760
+ m_fifo_write_block = 0 ;
1761
+ m_fifo_read_block = 0 ;
1816
1762
1817
1763
m_32x_hcount_compare_val = -1 ;
1818
1764
m_32x_hcount_reg = 0 ;
0 commit comments