First post, by peterferrie
I looked today at how emm386.exe does DMA transfers, to see why it's not affected by wraparounds. What happens is that it has an internal 64kb buffer, and copies to/from there prior to performing the transfer. The internal buffer is required for DMA transfer because the underlying physical pages might not be contiguous in the requester's buffer. The copy is also done using flat mode so there's no wraparound in the requester's buffer, either.
That leads to a question regarding this code:
for ( ; size ; size--, offset++) {
if (offset>(dma_wrapping<<dma16)) {
LOG_MSG(...
}
offset &= dma_wrap;
Why not check for overflow before the copy starts?
Checking after every byte incurs quite a lot of overhead. Moving the check outside of the 'for' loop would also allow switching to an internal buffer to complete the transfer, and thus avoiding the wraparound completely. The &dma_wrap could then be removed, too.
That would improve the compatibility for several games.