// queued FIFO transfers, ...x = index, ...l = queue length\r
   // each entry has 2 values: [n]>>3 = #writes, [n]&7 = flags (FQ_*)\r
   unsigned int fifo_queue[8], fifo_qx, fifo_ql;\r
-  unsigned int fifo_total;    // total# of pending FIFO entries (w/o BGDMA)\r
+  int fifo_total;             // total# of pending FIFO entries (w/o BGDMA)\r
 \r
   unsigned short fifo_slot;   // last executed slot in current scanline\r
   unsigned short fifo_maxslot;// #slots in scanline\r
   if (l > cnt)\r
     l = cnt;\r
   if (!(vf->fifo_queue[vf->fifo_qx] & FQ_BGDMA))\r
-    vf->fifo_total -= ((cnt & b) + l) >> b;\r
+    if ((vf->fifo_total -= ((cnt & b) + l) >> b) < 0) vf->fifo_total = 0;\r
   cnt -= l;\r
 \r
   // if entry has been processed...\r