| 691 | } |
| 692 | |
| 693 | void gifMFIFOInterrupt() |
| 694 | { |
| 695 | //DevCon.Warning("gifMFIFOInterrupt"); |
| 696 | gif.mfifocycles = 0; |
| 697 | |
| 698 | if (dmacRegs.ctrl.MFD != MFD_GIF) |
| 699 | { // GIF not in MFIFO anymore, come out. |
| 700 | DevCon.WriteLn("GIF Leaving MFIFO - Report if any errors"); |
| 701 | gifInterrupt(); |
| 702 | CPU_SET_DMASTALL(DMAC_MFIFO_GIF, true); |
| 703 | return; |
| 704 | } |
| 705 | |
| 706 | gifCheckPathStatus(false); |
| 707 | |
| 708 | if (gifUnit.gifPath[GIF_PATH_3].state == GIF_PATH_IDLE) |
| 709 | { |
| 710 | if (vif1Regs.stat.VGW) |
| 711 | { |
| 712 | // Check if VIF is in a cycle or is currently "idle" waiting for GIF to come back. |
| 713 | if (!(cpuRegs.interrupt & (1 << DMAC_VIF1))) |
| 714 | CPU_INT(DMAC_VIF1, 1); |
| 715 | |
| 716 | // Make sure it loops if the GIF packet is empty to prepare for the next packet |
| 717 | // or end if it was the end of a packet. |
| 718 | // This must trigger after VIF retriggers as VIf might instantly mask Path3 |
| 719 | if (!gifUnit.Path3Masked() || gifch.qwc == 0) |
| 720 | { |
| 721 | GifDMAInt(16); |
| 722 | } |
| 723 | CPU_SET_DMASTALL(DMAC_MFIFO_GIF, gifUnit.Path3Masked() || !gifUnit.CanDoPath3()); |
| 724 | return; |
| 725 | } |
| 726 | } |
| 727 | |
| 728 | if (gifUnit.gsSIGNAL.queued) |
| 729 | { |
| 730 | GifDMAInt(128); |
| 731 | CPU_SET_DMASTALL(DMAC_MFIFO_GIF, true); |
| 732 | return; |
| 733 | } |
| 734 | |
| 735 | // If there's something in the FIFO and we can do PATH3, empty the FIFO. |
| 736 | if (gif_fifo.fifoSize > 0) |
| 737 | { |
| 738 | const int readSize = gif_fifo.read_fifo(); |
| 739 | |
| 740 | if (readSize) |
| 741 | GifDMAInt(readSize * BIAS); |
| 742 | |
| 743 | // The following is quite timing sensitive so we need to pause/resume the DMA in these certain scenarios |
| 744 | // If the DMA is masked/blocked and the fifo is full, no need to run the DMA |
| 745 | // If we just read from the fifo, we want to loop and not read more DMA |
| 746 | // If there is no DMA data waiting and the DMA is active, let the DMA progress until there is |
| 747 | if ((!CheckPaths() && gif_fifo.fifoSize == 16) || readSize) |
| 748 | { |
| 749 | CPU_SET_DMASTALL(DMAC_MFIFO_GIF, gifUnit.Path3Masked() || !gifUnit.CanDoPath3()); |
| 750 | return; |
no test coverage detected