Skip to content

Commit f4bf8c9

Browse files
committed
fixing lower edge of threaded drawing
1 parent 55ff133 commit f4bf8c9

File tree

7 files changed

+57
-10
lines changed

7 files changed

+57
-10
lines changed

Infernity.zip

373 Bytes
Binary file not shown.

Source/control.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2766,6 +2766,7 @@ void clearShit(int pnum) {
27662766
}
27672767

27682768
bool SwitchInvTab(int newTab) {
2769+
if (talkflag) { return false; }
27692770
//if (pcurs < CURSOR_FIRSTITEM) {
27702771
if (newTab != plr[myplr].currentInventoryIndex) {
27712772
bool fromstash = plr[myplr].currentInventoryIndex >= 4;

Source/diablo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1606,7 +1606,7 @@ void __cdecl diablo_pause_game()
16061606

16071607
void SwitchWeapons() {
16081608

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

Source/scrollrt.cpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3335,8 +3335,13 @@ void __fastcall DoBlitScreen(int dwX, int dwY, int dwWdt, int dwHgt)
33353335
{
33363336
lock_buf_priv();
33373337
if (rgb_enabled && currentGameState != 1) {
3338+
3339+
//for (int y = 0; y < dwHgt; ++y) {
3340+
// 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);
3341+
//}
3342+
33383343
threadedStuff* t = new threadedStuff("diablo", 200, GetConfigBoolVariable("logDrawingDataToFile"),gData);
3339-
std::vector<std::future<void> > results(t->dd->num_threads);
3344+
std::vector<std::future<void> > results(t->dd->num_threads+1);
33403345
for (int j = 0; j < t->dd->num_threads; ++j) {
33413346
results[j] = t->dd->pp.push([j,t](int) {
33423347
int mul = ScreenHeight / t->dd->num_threads;
@@ -3346,14 +3351,27 @@ void __fastcall DoBlitScreen(int dwX, int dwY, int dwWdt, int dwHgt)
33463351
}
33473352
});
33483353
}
3349-
for (int j = 0; j < t->dd->num_threads; ++j) { results[j].get(); }
3354+
results[t->dd->num_threads] = t->dd->pp.push([t](int) {
3355+
int rest = ScreenHeight % t->dd->num_threads;
3356+
for (int i = ScreenHeight - rest; i < ScreenHeight; ++i) {
3357+
int tid = i;
3358+
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);
3359+
}
3360+
});
3361+
3362+
3363+
3364+
for (int j = 0; j <= t->dd->num_threads; ++j) { results[j].get(); }
33503365

33513366
bool ac = gData.autoConfigDone;
33523367
delete t;
33533368
if (!ac && gData.autoConfigDone) {
3354-
NetSendCmdString(1 << myplr, "Autoconfig finished!");
3369+
std::stringstream ss;
3370+
ss << "Autoconfig finished - threads: " << gData.num_threads;
3371+
NetSendCmdString(1 << myplr, (char*)ss.str().c_str());
33553372
}
33563373

3374+
33573375

33583376
//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);
33593377
//memcpy((unsigned char*)DDS_desc.lpSurface + j*DDS_desc.lPitch*4, (unsigned char*)&rgbBuffer->row[dwX + j].pixels[dwY], dwWdt*4);

diablo-ddrawwrapper-master/Project/ddrawwrapper/DirectDrawSurfaceWrapper.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,15 +1091,17 @@ HRESULT __stdcall IDirectDrawSurfaceWrapper::Unlock(LPVOID lpRect)
10911091
else {
10921092
threadedStuff* t;
10931093
if (gameState == 12) {
1094+
10941095
/*
10951096
for (int i = 0; i < ((surfaceWidth * surfaceHeight)); i++) {
10961097
unsigned int ii = i << 2;
10971098
rgbVideoMem[i] = RGB(rawVideoMem[ii + 3], rawVideoMem[ii + 2], rawVideoMem[ii + 1]);
1098-
}*/
1099+
}
1100+
*/
10991101

11001102

11011103
t = new threadedStuff("ddraw.dll - unlock", 200, false, gData2);
1102-
std::vector<std::future<void> > results(t->dd->num_threads);
1104+
std::vector<std::future<void> > results(t->dd->num_threads+1);
11031105
int wid = surfaceWidth;
11041106
int hei = surfaceHeight;
11051107
UINT32* vidmem = rgbVideoMem;
@@ -1114,8 +1116,21 @@ HRESULT __stdcall IDirectDrawSurfaceWrapper::Unlock(LPVOID lpRect)
11141116
}
11151117
});
11161118
}
1117-
for (int j = 0; j < t->dd->num_threads; ++j) { results[j].get(); }
1119+
1120+
1121+
results[t->dd->num_threads] = t->dd->pp.push([wid, hei, t, vidmem, rawmem](int) {
1122+
int rest = ((wid * hei)) % t->dd->num_threads;
1123+
for (int i = ((wid * hei)) - rest; i < ((wid * hei)); ++i) {
1124+
unsigned int ii = i << 2;
1125+
vidmem[i] = RGB(rawmem[ii + 3], rawmem[ii + 2], rawmem[ii + 1]);
1126+
}
1127+
});
1128+
1129+
1130+
1131+
for (int j = 0; j <= t->dd->num_threads; ++j) { results[j].get(); }
11181132
delete t;
1133+
11191134
}
11201135
else {
11211136
for (int i = 0; i < ((surfaceWidth * surfaceHeight)); i++) {

diablo-ddrawwrapper-master/Project/ddrawwrapper/DirectDrawWrapper.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,8 +1314,10 @@ HRESULT IDirectDrawWrapper::Present()
13141314

13151315
//for (DWORD y = 0; y < displayModeHeight; y++){
13161316
// memcpy((BYTE *)d3dlrect.pBits + (y * d3dlrect.Pitch), &lpAttachedSurface->rgbVideoMem[y * displayModeWidth], displayModeWidth * sizeof(UINT32));}
1317+
1318+
13171319
threadedStuff *t = new threadedStuff("ddraw.dll - present", 200, false, gData);
1318-
std::vector<std::future<void> > results(t->dd->num_threads);
1320+
std::vector<std::future<void> > results(t->dd->num_threads+1);
13191321
int wid = displayModeWidth;
13201322
int hei = displayModeHeight;
13211323
int pitch = d3dlrect.Pitch;
@@ -1330,8 +1332,19 @@ HRESULT IDirectDrawWrapper::Present()
13301332
}
13311333
});
13321334
}
1333-
for (int j = 0; j < t->dd->num_threads; ++j) { results[j].get(); }
1335+
1336+
results[t->dd->num_threads] = t->dd->pp.push([t , wid, hei, pitch, bits, vidmem](int) {
1337+
int rest = hei % t->dd->num_threads;
1338+
for (int i = hei - rest; i < hei; ++i) {
1339+
int tid = i;
1340+
memcpy((BYTE *)bits + (tid * pitch), &vidmem[tid * wid], wid * sizeof(UINT32));
1341+
}
1342+
});
1343+
1344+
1345+
for (int j = 0; j <= t->dd->num_threads; ++j) { results[j].get(); }
13341346
delete t;
1347+
13351348

13361349
/*
13371350
std::vector<std::future<void> > results(t->dd->num_threads);

diablo-ddrawwrapper-master/Project/ddrawwrapper/DirectDrawWrapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ struct threadedStuff {
7070
d.autoConfigDone = false;
7171
d.initThread = true;
7272
d.pp.init();
73-
d.pp.resize(d.maxThreads);
73+
d.pp.resize(d.maxThreads+1);
7474
}
7575
}
7676
~threadedStuff() {

0 commit comments

Comments
 (0)