MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / IOPReadFIFO

Function IOPReadFIFO

pcsx2/DEV9/DEV9.cpp:284–316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

282 dev9.fifo_bytes_read += write;
283}
284void IOPReadFIFO()
285{
286 pxAssert((dev9.dma_iop_ptr != nullptr) && (dev9.xfr_ctrl & SPD_XFR_DMAEN));
287 pxAssert((dev9.xfr_ctrl & SPD_XFR_WRITE) == 0);
288
289 const int unread = (dev9.fifo_bytes_write - dev9.fifo_bytes_read);
290 const int base = dev9.fifo_bytes_read % (SPD_DBUF_AVAIL_MAX * 512);
291
292 const int remain = dev9.dma_iop_size - dev9.dma_iop_transfered;
293 const int read = std::min(remain, unread);
294
295 pxAssert(unread <= SPD_DBUF_AVAIL_MAX * 512);
296
297 if (read == 0)
298 return;
299
300 if (base + read > SPD_DBUF_AVAIL_MAX * 512)
301 {
302 const int was = SPD_DBUF_AVAIL_MAX * 512 - base;
303
304 std::memcpy(dev9.dma_iop_ptr + dev9.dma_iop_transfered, dev9.fifo + base, was);
305 std::memcpy(dev9.dma_iop_ptr + dev9.dma_iop_transfered + was, dev9.fifo, read - was);
306 }
307 else
308 {
309 std::memcpy(dev9.dma_iop_ptr + dev9.dma_iop_transfered, dev9.fifo + base, read);
310 }
311
312 dev9.dma_iop_transfered += read;
313 dev9.fifo_bytes_read += read;
314 if (dev9.fifo_bytes_read > dev9.fifo_bytes_write)
315 Console.Error("DEV9: UNDERFLOW BY IOP");
316}
317void IOPWriteFIFO()
318{
319 pxAssert((dev9.dma_iop_ptr != nullptr) && (dev9.xfr_ctrl & SPD_XFR_DMAEN));

Callers 1

DEV9runFIFOFunction · 0.85

Calls 2

minFunction · 0.50
ErrorMethod · 0.45

Tested by

no test coverage detected