Skip to content
Permalink
Browse files

fixing lower edge of threaded drawing

  • Loading branch information...
qndel committed Sep 17, 2018
1 parent 55ff133 commit f4bf8c9ac8f89bcd2633aba575e477b24c4959b9
BIN +373 Bytes (100%) Infernity.zip
Binary file not shown.
@@ -2766,6 +2766,7 @@ void clearShit(int pnum) {
}

bool SwitchInvTab(int newTab) {
if (talkflag) { return false; }
//if (pcurs < CURSOR_FIRSTITEM) {
if (newTab != plr[myplr].currentInventoryIndex) {
bool fromstash = plr[myplr].currentInventoryIndex >= 4;
@@ -1606,7 +1606,7 @@ void __cdecl diablo_pause_game()

void SwitchWeapons() {

if (plr[myplr]._pmode != 1 && plr[myplr]._pmode != 2 && plr[myplr]._pmode != 3 && plr[myplr]._pmode != 8) {
if (plr[myplr]._pmode != 1 && plr[myplr]._pmode != 2 && plr[myplr]._pmode != 3 && plr[myplr]._pmode != 8 && !talkflag) {
ItemStruct wtf = plr[myplr].InvBody[4];
ItemStruct wtf2 = plr[myplr].InvBody[5];

@@ -3335,8 +3335,13 @@ void __fastcall DoBlitScreen(int dwX, int dwY, int dwWdt, int dwHgt)
{
lock_buf_priv();
if (rgb_enabled && currentGameState != 1) {

//for (int y = 0; y < dwHgt; ++y) {
// memcpyRGB((unsigned char*)DDS_desc.lpSurface + (dwX + (dwY + y)*DDS_desc.lPitch) * 4, (unsigned char*)&gpBuffer->row[dwX + y].pixels[dwY], (unsigned char*)rgbBuffer->row[dwX + y].pixels[dwY].argb, dwWdt);
//}

threadedStuff* t = new threadedStuff("diablo", 200, GetConfigBoolVariable("logDrawingDataToFile"),gData);
std::vector<std::future<void> > results(t->dd->num_threads);
std::vector<std::future<void> > results(t->dd->num_threads+1);
for (int j = 0; j < t->dd->num_threads; ++j) {
results[j] = t->dd->pp.push([j,t](int) {
int mul = ScreenHeight / t->dd->num_threads;
@@ -3346,14 +3351,27 @@ void __fastcall DoBlitScreen(int dwX, int dwY, int dwWdt, int dwHgt)
}
});
}
for (int j = 0; j < t->dd->num_threads; ++j) { results[j].get(); }
results[t->dd->num_threads] = t->dd->pp.push([t](int) {
int rest = ScreenHeight % t->dd->num_threads;
for (int i = ScreenHeight - rest; i < ScreenHeight; ++i) {
int tid = i;
memcpyRGB((unsigned char*)DDS_desc.lpSurface + tid * DDS_desc.lPitch * 4, (unsigned char*)&gpBuffer->row[tid].pixels[0], (unsigned char*)rgbBuffer->row[tid].pixels[0].argb, GLOBAL_WIDTH);
}
});



for (int j = 0; j <= t->dd->num_threads; ++j) { results[j].get(); }

bool ac = gData.autoConfigDone;
delete t;
if (!ac && gData.autoConfigDone) {
NetSendCmdString(1 << myplr, "Autoconfig finished!");
std::stringstream ss;
ss << "Autoconfig finished - threads: " << gData.num_threads;
NetSendCmdString(1 << myplr, (char*)ss.str().c_str());
}



//memcpyRGB((unsigned char*)DDS_desc.lpSurface + (dwX + (dwY + j)*DDS_desc.lPitch) * 4, (unsigned char*)&gpBuffer->row[dwX + j].pixels[dwY], (unsigned char*)rgbBuffer->row[dwX + j].pixels[dwY].argb, dwWdt);
//memcpy((unsigned char*)DDS_desc.lpSurface + j*DDS_desc.lPitch*4, (unsigned char*)&rgbBuffer->row[dwX + j].pixels[dwY], dwWdt*4);
@@ -1091,15 +1091,17 @@ HRESULT __stdcall IDirectDrawSurfaceWrapper::Unlock(LPVOID lpRect)
else {
threadedStuff* t;
if (gameState == 12) {

/*
for (int i = 0; i < ((surfaceWidth * surfaceHeight)); i++) {
unsigned int ii = i << 2;
rgbVideoMem[i] = RGB(rawVideoMem[ii + 3], rawVideoMem[ii + 2], rawVideoMem[ii + 1]);
}*/
}
*/


t = new threadedStuff("ddraw.dll - unlock", 200, false, gData2);
std::vector<std::future<void> > results(t->dd->num_threads);
std::vector<std::future<void> > results(t->dd->num_threads+1);
int wid = surfaceWidth;
int hei = surfaceHeight;
UINT32* vidmem = rgbVideoMem;
@@ -1114,8 +1116,21 @@ HRESULT __stdcall IDirectDrawSurfaceWrapper::Unlock(LPVOID lpRect)
}
});
}
for (int j = 0; j < t->dd->num_threads; ++j) { results[j].get(); }


results[t->dd->num_threads] = t->dd->pp.push([wid, hei, t, vidmem, rawmem](int) {
int rest = ((wid * hei)) % t->dd->num_threads;
for (int i = ((wid * hei)) - rest; i < ((wid * hei)); ++i) {
unsigned int ii = i << 2;
vidmem[i] = RGB(rawmem[ii + 3], rawmem[ii + 2], rawmem[ii + 1]);
}
});



for (int j = 0; j <= t->dd->num_threads; ++j) { results[j].get(); }
delete t;

}
else {
for (int i = 0; i < ((surfaceWidth * surfaceHeight)); i++) {
@@ -1314,8 +1314,10 @@ HRESULT IDirectDrawWrapper::Present()

//for (DWORD y = 0; y < displayModeHeight; y++){
// memcpy((BYTE *)d3dlrect.pBits + (y * d3dlrect.Pitch), &lpAttachedSurface->rgbVideoMem[y * displayModeWidth], displayModeWidth * sizeof(UINT32));}


threadedStuff *t = new threadedStuff("ddraw.dll - present", 200, false, gData);
std::vector<std::future<void> > results(t->dd->num_threads);
std::vector<std::future<void> > results(t->dd->num_threads+1);
int wid = displayModeWidth;
int hei = displayModeHeight;
int pitch = d3dlrect.Pitch;
@@ -1330,8 +1332,19 @@ HRESULT IDirectDrawWrapper::Present()
}
});
}
for (int j = 0; j < t->dd->num_threads; ++j) { results[j].get(); }

results[t->dd->num_threads] = t->dd->pp.push([t , wid, hei, pitch, bits, vidmem](int) {
int rest = hei % t->dd->num_threads;
for (int i = hei - rest; i < hei; ++i) {
int tid = i;
memcpy((BYTE *)bits + (tid * pitch), &vidmem[tid * wid], wid * sizeof(UINT32));
}
});


for (int j = 0; j <= t->dd->num_threads; ++j) { results[j].get(); }
delete t;


/*
std::vector<std::future<void> > results(t->dd->num_threads);
@@ -70,7 +70,7 @@ struct threadedStuff {
d.autoConfigDone = false;
d.initThread = true;
d.pp.init();
d.pp.resize(d.maxThreads);
d.pp.resize(d.maxThreads+1);
}
}
~threadedStuff() {

0 comments on commit f4bf8c9

Please sign in to comment.
You can’t perform that action at this time.