Fixed Linked List DMA end marker. (#183)
authorgameblabla <gameblabla@users.noreply.github.com>
Mon, 16 Aug 2021 21:03:52 +0000 (21:03 +0000)
committerGitHub <noreply@github.com>
Mon, 16 Aug 2021 21:03:52 +0000 (00:03 +0300)
Taken from PCSX Redux project.
https://github.com/grumpycoders/pcsx-redux/pull/396/commits/a6401da3a4e7b4860b0f7a7f679cf9a93e739caa

libpcsxcore/psxdma.c
plugins/dfxvideo/gpu.c
plugins/gpu-gles/gpuPlugin.c

index 03ee563..cb84fbc 100644 (file)
@@ -122,7 +122,8 @@ static u32 gpuDmaChainSize(u32 addr) {
                // next 32-bit pointer
                addr = psxMu32( addr & ~0x3 ) & 0xffffff;
                size += 1;
-       } while (addr != 0xffffff);
+       } while (!(addr & 0x800000)); // contrary to some documentation, the end-of-linked-list marker is not actually 0xFF'FFFF
+                                  // any pointer with bit 23 set will do.
 
        return size;
 }
index 3d20dfa..649cb42 100644 (file)
@@ -1060,8 +1060,8 @@ long CALLBACK GPUdmaChain(uint32_t * baseAddrL, uint32_t addr)
    if(count>0) GPUwriteDataMem(&baseAddrL[dmaMem>>2],count);
 
    addr = GETLE32(&baseAddrL[addr>>2])&0xffffff;
-  }
- while (addr != 0xffffff);
+   } while (!(addr & 0x800000)); // contrary to some documentation, the end-of-linked-list marker is not actually 0xFF'FFFF
+                                  // any pointer with bit 23 set will do.
 
  GPUIsIdle;
 
index 60570ac..6d3ca14 100644 (file)
@@ -2205,9 +2205,8 @@ do
   if(count>0) GPUwriteDataMem(&baseAddrL[dmaMem>>2],count);\r
   \r
   addr = baseAddrL[addr>>2]&0xffffff;\r
- }\r
-while (addr != 0xffffff);\r
-\r
+  } while (!(addr & 0x800000)); // contrary to some documentation, the end-of-linked-list marker is not actually 0xFF'FFFF\r
+                                  // any pointer with bit 23 set will do.\r
 GPUIsIdle;\r
 \r
 return 0;\r