I've added a 3x3 low detail mode (4x2 was easy), it works but crashes on exit and i don't know why. I've traced the algorithm and it's right. The only way to prevent the crash is to stop the inner loop with x < rowsize-6 but then the rightmost part of the screen wouldn't be filled and would display junk. I've kept detailxshift and detailyshift at 1 since otherwise would be a mess but i think it doesn't matter. The problem is in ~DSimpleCanvas but the debug info is not useful. If someone wants to help i would appreciate it, i know Randi is the only one who knows well that part of the code.
- Code: Select all • Expand view
void R_DetailDouble ()
{
...
case 5: // x- and y-triple
{
int rowsize = viewwidth;
int realpitch = RenderTarget->GetPitch();
int pitch = realpitch << 1;
int y,x;
BYTE *linefrom, *lineto;
BYTE c;
int offset = viewwidth > 320 ? CPU.DataL1LineSize : 0;
linefrom = dc_destorg;
for (y = 0; y < viewheight; ++y, linefrom += pitch)
{
if (y > 0)
{
lineto = linefrom - viewwidth*3 - offset;
}
else
{
lineto = linefrom - viewwidth;
}
for (x = 0; x < rowsize-3; x=x+3)
{
c = linefrom[x];
lineto[x*2] = c;
lineto[x*2+1] = c;
lineto[x*2+2] = c;
c = linefrom[x+1];
lineto[x*2+3] = c;
lineto[x*2+4] = c;
lineto[x*2+5] = c;
}
x = rowsize-1;
if (viewwidth >= 200)
{
c = linefrom[x-2];
lineto[x*2-2] = c;
lineto[x*2-1] = c;
}
c = linefrom[x-1];
lineto[x*2] = c;
lineto[x*2+1] = c;
if (y > 0)
{
memcpy (lineto+realpitch, lineto, rowsize*2);
memcpy (lineto+realpitch*2, lineto, rowsize*2);
}
else
{
memcpy (lineto+realpitch, lineto, rowsize*2);
}
}
}
break;
}
Edit: rowsize is for instance 160 and screen width is 320. I've added the missing part but it crashes the same.
Edit2: it's fixed.