From c0085bdb95e7e60293d003c5a2df46738ddc9a20 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Fri, 12 Apr 2019 22:08:30 +0200 Subject: [PATCH 01/11] Clean up GoldAutoPlace --- Source/inv.cpp | 157 ++++++++++++++++++------------------------------- Source/inv.h | 2 +- 2 files changed, 58 insertions(+), 101 deletions(-) diff --git a/Source/inv.cpp b/Source/inv.cpp index 653a6b13d..5318068e1 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -650,112 +650,69 @@ LABEL_24: return v6; } -int GoldAutoPlace(int pnum) +BOOL GoldAutoPlace(int pnum) { - int v1; // ebp - int v2; // edi - int v3; // ecx - int *v4; // esi - int v5; // eax - int v6; // edi - int *v7; // esi - int v8; // eax - signed int v9; // ebx - char *v10; // edx - int v11; // eax - int v12; // ecx - int pnuma; // [esp+10h] [ebp-4h] - - pnuma = pnum; - v1 = pnum; - v2 = 0; - v3 = 0; - if (plr[v1]._pNumInv <= 0) { - LABEL_14: - v6 = 0; - if (plr[v1]._pNumInv <= 0) { - LABEL_28: - v9 = 39; - do { - if (v3) - break; - v10 = &plr[0].InvGrid[10 * (v9 / 10) + v1 * 21720 + v9 % 10]; - if (!*v10) { - v11 = v1 * 21720 + 368 * plr[v1]._pNumInv; - qmemcpy((char *)plr[0].InvList + v11, &plr[v1].HoldItem, 0x170u); - ++plr[v1]._pNumInv; - *v10 = plr[v1]._pNumInv; - v12 = plr[v1].HoldItem._ivalue; - if (v12 < 2500) { - if (v12 > 1000) - *(int *)((char *)&plr[0].InvList[0]._iCurs + v11) = 5; - else - *(int *)((char *)&plr[0].InvList[0]._iCurs + v11) = 4; - } else { - *(int *)((char *)&plr[0].InvList[0]._iCurs + v11) = 6; - } - plr[v1]._pGold = CalculateGold(pnuma); - v3 = 1; - } - --v9; - } while (v9 >= 0); - } else { - v7 = &plr[v1].InvList[0]._ivalue; - while (!v3) { - if (*(v7 - 47) == 11 && *v7 < 5000) { - v8 = plr[v1].HoldItem._ivalue + *v7; - if (v8 <= 5000) { - *v7 = v8; - if (v8 < 2500) { - if (v8 > 1000) - *(v7 - 1) = 5; - else - *(v7 - 1) = 4; - } else { - *(v7 - 1) = 6; - } - plr[v1]._pGold = CalculateGold(pnuma); - v3 = 1; - } - } - ++v6; - v7 += 92; - if (v6 >= plr[v1]._pNumInv) { - if (v3) - return v3; - goto LABEL_28; - } + BOOL done; + int i, ii; + int xx, yy; + + done = FALSE; + for (i = 0; i < plr[pnum]._pNumInv && !done; i++) { + if (plr[pnum].InvList[i]._itype == ITYPE_GOLD) { + if (plr[pnum].HoldItem._ivalue + plr[pnum].InvList[i]._ivalue <= 5000) { + plr[pnum].InvList[i]._ivalue = plr[pnum].HoldItem._ivalue + plr[pnum].InvList[i]._ivalue; + if (plr[pnum].InvList[i]._ivalue >= 2500) + plr[pnum].InvList[i]._iCurs = ICURS_GOLD_LARGE; + else if (plr[pnum].InvList[i]._ivalue <= 1000) + plr[pnum].InvList[i]._iCurs = ICURS_GOLD_SMALL; + else + plr[pnum].InvList[i]._iCurs = ICURS_GOLD_MEDIUM; + plr[pnum]._pGold = CalculateGold(pnum); + done = TRUE; } } - } else { - v4 = &plr[v1].InvList[0]._ivalue; - while (!v3) { - if (*(v4 - 47) == 11) { - v5 = *v4 + plr[v1].HoldItem._ivalue; - if (v5 <= 5000) { - *v4 = v5; - if (v5 < 2500) { - if (v5 > 1000) - *(v4 - 1) = 5; - else - *(v4 - 1) = 4; - } else { - *(v4 - 1) = 6; - } - plr[v1]._pGold = CalculateGold(pnuma); - v3 = 1; - } - } - ++v2; - v4 += 92; - if (v2 >= plr[v1]._pNumInv) { - if (v3) - return v3; - goto LABEL_14; + } + if (done) + return done; + + for (i = 0; i < plr[pnum]._pNumInv && !done; i++) { + if (plr[pnum].InvList[i]._itype == ITYPE_GOLD && plr[pnum].InvList[i]._ivalue < 5000) { + if (plr[pnum].HoldItem._ivalue + plr[pnum].InvList[i]._ivalue <= 5000) { + plr[pnum].InvList[i]._ivalue = plr[pnum].HoldItem._ivalue + plr[pnum].InvList[i]._ivalue; + if (plr[pnum].InvList[i]._ivalue >= 2500) + plr[pnum].InvList[i]._iCurs = ICURS_GOLD_LARGE; + else if (plr[pnum].InvList[i]._ivalue <= 1000) + plr[pnum].InvList[i]._iCurs = ICURS_GOLD_SMALL; + else + plr[pnum].InvList[i]._iCurs = ICURS_GOLD_MEDIUM; + plr[pnum]._pGold = CalculateGold(pnum); + done = TRUE; } } } - return v3; + if (done) + return done; + + for (i = 39; i >= 0 && !done; i--) { + yy = 10 * (i / 10); + xx = i % 10; + if (!plr[pnum].InvGrid[xx + yy]) { + ii = plr[pnum]._pNumInv; + plr[pnum].InvList[ii] = plr[pnum].HoldItem; + plr[pnum]._pNumInv = plr[pnum]._pNumInv + 1; + plr[pnum].InvGrid[xx + yy] = plr[pnum]._pNumInv; + if (plr[pnum].HoldItem._ivalue >= 2500) + plr[pnum].InvList[ii]._iCurs = ICURS_GOLD_LARGE; + else if (plr[pnum].HoldItem._ivalue <= 1000) + plr[pnum].InvList[ii]._iCurs = ICURS_GOLD_SMALL; + else + plr[pnum].InvList[ii]._iCurs = ICURS_GOLD_MEDIUM; + plr[pnum]._pGold = CalculateGold(pnum); + done = TRUE; + } + } + + return done; } int WeaponAutoPlace(int pnum) diff --git a/Source/inv.h b/Source/inv.h index c8f52f200..10e2ecd31 100644 --- a/Source/inv.h +++ b/Source/inv.h @@ -12,7 +12,7 @@ void DrawInv(); void DrawInvBelt(); int AutoPlace(int pnum, int ii, int sx, int sy, int saveflag); int SpecialAutoPlace(int pnum, int ii, int sx, int sy, int saveflag); -int GoldAutoPlace(int pnum); +BOOL GoldAutoPlace(int pnum); int WeaponAutoPlace(int pnum); int SwapItem(ItemStruct *a, ItemStruct *b); void CheckInvPaste(int pnum, int mx, int my); From e5a2fc921947cc03146a619347fd1d75f852de57 Mon Sep 17 00:00:00 2001 From: JustAnotherGuid <46401660+JustAnotherGuid@users.noreply.github.com> Date: Sat, 13 Apr 2019 01:38:18 +0200 Subject: [PATCH 02/11] CheckTriggers [bin exact] (#925) --- Source/trigs.cpp | 155 ++++++++++++++++++++--------------------------- 1 file changed, 65 insertions(+), 90 deletions(-) diff --git a/Source/trigs.cpp b/Source/trigs.cpp index 280639e03..edde820f2 100644 --- a/Source/trigs.cpp +++ b/Source/trigs.cpp @@ -823,108 +823,83 @@ void CheckTrigForce() void CheckTriggers() { - int *v0; // edi - int v1; // esi - int v2; // ecx - int v3; // eax - int v4; // edx - signed int v5; // edx - int v6; // eax - int v9; // [esp-4h] [ebp-20h] - int x; // [esp+Ch] [ebp-10h] - int y; // [esp+10h] [ebp-Ch] - int v12; // [esp+14h] [ebp-8h] - int error_id; // [esp+1Bh] [ebp-1h] + int x, y, i; + BOOL abort; + char abortflag; if (plr[myplr]._pmode) return; - v12 = 0; - if (trigflag[4] <= 0) - return; - v0 = &trigs[0]._tmsg; - while (1) { - v1 = myplr; - v2 = plr[myplr].WorldX; - if (v2 != *(v0 - 2)) - goto LABEL_34; - v3 = plr[v1].WorldY; - if (v3 != *(v0 - 1)) - goto LABEL_34; - v4 = *v0; - if (*v0 == WM_DIABNEXTLVL) { + + for (i = 0; i < trigflag[4]; i++) { + if (plr[myplr].WorldX != trigs[i]._tx || plr[myplr].WorldY != trigs[i]._ty) { + continue; + } + + switch (trigs[i]._tmsg) { + case WM_DIABNEXTLVL: if (pcurs >= CURSOR_FIRSTITEM && DropItemBeforeTrig()) return; - v6 = currlevel + 1; - goto LABEL_32; - } - if (*v0 == WM_DIABPREVLVL) { + StartNewLvl(myplr, trigs[i]._tmsg, currlevel + 1); + break; + case WM_DIABPREVLVL: if (pcurs >= CURSOR_FIRSTITEM && DropItemBeforeTrig()) return; - v6 = currlevel - 1; - LABEL_32: - v9 = v6; - goto LABEL_33; - } - if (*v0 != WM_DIABRTNLVL) + StartNewLvl(myplr, trigs[i]._tmsg, currlevel - 1); break; - StartNewLvl(myplr, v4, ReturnLvl); - LABEL_34: - ++v12; - v0 += 4; - if (v12 >= trigflag[4]) - return; - } - if (*v0 != WM_DIABTOWNWARP) { - if (*v0 == WM_DIABTWARPUP) { + case WM_DIABRTNLVL: + StartNewLvl(myplr, trigs[i]._tmsg, ReturnLvl); + break; + case WM_DIABTOWNWARP: + if (gbMaxPlayers != 1) { + abort = FALSE; + + if (trigs[i]._tlvl == 5 && plr[myplr]._pLevel < 8) { + abort = TRUE; + x = plr[myplr].WorldX; + y = plr[myplr].WorldY + 1; + abortflag = EMSG_REQUIRES_LVL_8; + } + + if (trigs[i]._tlvl == 9 && plr[myplr]._pLevel < 13) { + abort = TRUE; + x = plr[myplr].WorldX + 1; + y = plr[myplr].WorldY; + abortflag = EMSG_REQUIRES_LVL_13; + } + + if (trigs[i]._tlvl == 13 && plr[myplr]._pLevel < 17) { + abort = TRUE; + x = plr[myplr].WorldX; + y = plr[myplr].WorldY + 1; + abortflag = EMSG_REQUIRES_LVL_17; + } + + if (abort) { + if (plr[myplr]._pClass == PC_WARRIOR) { + PlaySFX(PS_WARR43); + } else if (plr[myplr]._pClass == PC_ROGUE) { + PlaySFX(PS_ROGUE43); + } else if (plr[myplr]._pClass == PC_SORCERER) { + PlaySFX(PS_MAGE43); + } + + InitDiabloMsg(abortflag); + NetSendCmdLoc(TRUE, CMD_WALKXY, x, y); + return; + } + } + + StartNewLvl(myplr, trigs[i]._tmsg, trigs[i]._tlvl); + break; + case WM_DIABTWARPUP: TWarpFrom = currlevel; - StartNewLvl(myplr, v4, 0); - } else { + StartNewLvl(myplr, trigs[i]._tmsg, 0); + break; + default: app_fatal("Unknown trigger msg"); + break; } - goto LABEL_34; - } - if (gbMaxPlayers == 1) - goto LABEL_46; - v5 = 0; - if (v0[1] == 5 && plr[v1]._pLevel < 8) { - v5 = 1; - x = plr[myplr].WorldX; - _LOBYTE(y) = v3 + 1; - _LOBYTE(error_id) = EMSG_REQUIRES_LVL_8; - } - if (v0[1] == 9 && plr[v1]._pLevel < 13) { - v5 = 1; - _LOBYTE(x) = v2 + 1; - y = plr[v1].WorldY; - _LOBYTE(error_id) = EMSG_REQUIRES_LVL_13; - } - if (v0[1] == 13 && plr[v1]._pLevel < 17) { - x = plr[myplr].WorldX; - v5 = 1; - _LOBYTE(y) = v3 + 1; - _LOBYTE(error_id) = EMSG_REQUIRES_LVL_17; - } - if (!v5) { - LABEL_46: - v9 = v0[1]; - LABEL_33: - StartNewLvl(myplr, *v0, v9); - goto LABEL_34; - } - switch (plr[myplr]._pClass) { - case PC_WARRIOR: - PlaySFX(PS_WARR43); - break; - case PC_ROGUE: - PlaySFX(PS_ROGUE43); - break; - case PC_SORCERER: - PlaySFX(PS_MAGE43); - break; } - _LOBYTE(v2) = error_id; - InitDiabloMsg(v2); - NetSendCmdLoc(TRUE, CMD_WALKXY, x, y); } // 679660: using guessed type char gbMaxPlayers; // 6ABB30: using guessed type int TWarpFrom; From 925135ed46d28e6bf8879dab7934c5ae8da0251d Mon Sep 17 00:00:00 2001 From: qndel Date: Sat, 13 Apr 2019 01:10:02 +0200 Subject: [PATCH 03/11] DoAutoMap bin exact --- Source/control.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/control.cpp b/Source/control.cpp index cf40916b8..811a6e33c 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -1459,10 +1459,10 @@ void control_check_btn_press() void DoAutoMap() { if (currlevel || gbMaxPlayers != 1) { - if (automapflag) - automapflag = 0; - else + if (!automapflag) StartAutomap(); + else + automapflag = 0; } else { InitDiabloMsg(EMSG_NO_AUTOMAP_IN_TOWN); } From 8d155bde000e16613999d7a83b2cdff57a61f4ef Mon Sep 17 00:00:00 2001 From: qndel Date: Sat, 13 Apr 2019 01:07:31 +0200 Subject: [PATCH 04/11] DoPanBtn bin exact --- Source/control.cpp | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/Source/control.cpp b/Source/control.cpp index 811a6e33c..3e8559fca 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -1392,40 +1392,22 @@ void DoSpeedBook() void DoPanBtn() { - int v0; // edx - int v1; // ebx - int v2; // edi - int v3; // esi - int(*v4)[5]; // eax - int v5; // ecx + int i; - v0 = MouseX; - v1 = MouseY; - v2 = numpanbtns; - v3 = 0; - if (numpanbtns > 0) { - v4 = PanBtnPos; - do { - if (v0 >= (*v4)[0] && v0 <= (*v4)[0] + (*v4)[2]) { - v5 = (*v4)[1]; - if (v1 >= v5 && v1 <= v5 + (*v4)[3]) { - panbtn[v3] = 1; - drawbtnflag = 1; - panbtndown = 1; - } + for (i = 0; i < numpanbtns; i++) { + if (MouseX >= PanBtnPos[i][0] && MouseX <= PanBtnPos[i][0] + PanBtnPos[i][2]) { + if (MouseY >= PanBtnPos[i][1] && MouseY <= PanBtnPos[i][1] + PanBtnPos[i][3]) { + panbtn[i] = 1; + drawbtnflag = 1; + panbtndown = 1; } - ++v3; - ++v4; - } while (v3 < v2); + } } - if (!spselflag && v0 >= 565 && v0 < 621 && v1 >= 416 && v1 < 472) { + if (!spselflag && MouseX >= 565 && MouseX < 621 && MouseY >= 416 && MouseY < 472) { DoSpeedBook(); gamemenu_off(); } } -// 4B8A7C: using guessed type int numpanbtns; -// 4B8C90: using guessed type int panbtndown; -// 4B8C98: using guessed type int spselflag; void control_set_button_down(int btn_id) { From da48bf0c1433a2320e7905fd69afda2ecf231625 Mon Sep 17 00:00:00 2001 From: qndel Date: Sat, 13 Apr 2019 00:38:42 +0200 Subject: [PATCH 05/11] DrawCtrlPan bin exact --- Source/control.cpp | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/Source/control.cpp b/Source/control.cpp index 3e8559fca..af0ee23bb 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -1308,33 +1308,22 @@ void ClearCtrlPan() void DrawCtrlPan() { - signed int v0; // edi - int *v1; // esi - int v2; // ecx - int v3; // eax + int i; - v0 = 0; - v1 = (int *)PanBtnPos; - do { - v2 = *v1; - if (panbtn[v0]) - CelDecodeOnly(v2 + 64, v1[1] + 178, (BYTE *)pPanelButtons, v0 + 1, 71); + for (i = 0; i < 6; i++) { + if (!panbtn[i]) + DrawPanelBox(PanBtnPos[i][0], PanBtnPos[i][1] - 336, 71, 20, PanBtnPos[i][0] + 64, PanBtnPos[i][1] + 160); else - DrawPanelBox(v2, v1[1] - 336, 71, 20, v2 + 64, v1[1] + 160); - ++v0; - v1 += 5; - } while (v0 < 6); + CelDecodeOnly(PanBtnPos[i][0] + 64, PanBtnPos[i][1] + 178, (BYTE *)pPanelButtons, i + 1, 71); + } if (numpanbtns == 8) { CelDecodeOnly(151, 634, (BYTE *)pMultiBtns, panbtn[6] + 1, 33); if (FriendlyMode) - v3 = panbtn[7] + 3; + CelDecodeOnly(591, 634, (BYTE *)pMultiBtns, panbtn[7] + 3, 33); else - v3 = panbtn[7] + 5; - CelDecodeOnly(591, 634, (BYTE *)pMultiBtns, v3, 33); + CelDecodeOnly(591, 634, (BYTE *)pMultiBtns, panbtn[7] + 5, 33); } } -// 484368: using guessed type int FriendlyMode; -// 4B8A7C: using guessed type int numpanbtns; void DoSpeedBook() { From 9a3b746d0ed303a2716d001c0795ccf24e08fd8d Mon Sep 17 00:00:00 2001 From: qndel Date: Sat, 13 Apr 2019 01:46:01 +0200 Subject: [PATCH 06/11] DrawSpell bin exact (#929) --- Source/control.cpp | 48 +++++++++++++++++++--------------------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/Source/control.cpp b/Source/control.cpp index af0ee23bb..26dcc81df 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -358,35 +358,27 @@ void SetSpellTrans(char t) void DrawSpell() { - int v0; // ebp - char v1; // cl - char v2; // bl - int v3; // edi - int v4; // esi - char v6; // [esp+Fh] [ebp-5h] - - v0 = myplr; - v1 = plr[myplr]._pRSpell; - v2 = plr[myplr]._pRSplType; - v3 = v1; - v6 = plr[myplr]._pRSpell; - v4 = plr[myplr]._pISplLvlAdd + plr[myplr]._pSplLvl[v1]; - if (v2 == RSPLTYPE_SPELL && v1 != -1) { - if (!CheckSpell(myplr, v1, RSPLTYPE_SPELL, TRUE)) - v2 = RSPLTYPE_INVALID; - v0 = myplr; - if (v4 <= 0) - v2 = RSPLTYPE_INVALID; - } - if (!currlevel && v2 != RSPLTYPE_INVALID && !spelldata[v3].sTownSpell) - v2 = RSPLTYPE_INVALID; - if (plr[v0]._pRSpell < 0) - v2 = RSPLTYPE_INVALID; - SetSpellTrans(v2); - if (v6 == -1) - DrawSpellCel(629, 631, (BYTE *)pSpellCels, 27, 56); + char spl, st; + int tlvl; + + spl = plr[myplr]._pRSpell; + st = plr[myplr]._pRSplType; + tlvl = plr[myplr]._pISplLvlAdd + plr[myplr]._pSplLvl[spl]; + if (st == RSPLTYPE_SPELL && spl != RSPLTYPE_INVALID) { + if (!CheckSpell(myplr, spl, RSPLTYPE_SPELL, TRUE)) + st = RSPLTYPE_INVALID; + if (tlvl <= 0) + st = RSPLTYPE_INVALID; + } + if (!currlevel && st != RSPLTYPE_INVALID && !spelldata[spl].sTownSpell) + st = RSPLTYPE_INVALID; + if (plr[myplr]._pRSpell < 0) + st = RSPLTYPE_INVALID; + SetSpellTrans(st); + if (spl != RSPLTYPE_INVALID) + DrawSpellCel(629, 631, (BYTE *)pSpellCels, (char)SpellITbl[spl], 56); else - DrawSpellCel(629, 631, (BYTE *)pSpellCels, (char)SpellITbl[v3], 56); + DrawSpellCel(629, 631, (BYTE *)pSpellCels, 27, 56); } void DrawSpellList() From ad8e41258a4755ef201b75511611b72e49c97831 Mon Sep 17 00:00:00 2001 From: qndel Date: Sat, 13 Apr 2019 02:11:01 +0200 Subject: [PATCH 07/11] SetSpeedSpell bin exact (#928) --- Source/control.cpp | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/Source/control.cpp b/Source/control.cpp index 26dcc81df..da53b7015 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -587,28 +587,17 @@ void SetSpell() void SetSpeedSpell(int slot) { - int v1; // esi - signed int v3; // ebp - int v5; // ebx - int *v6; // edi + int i; - v1 = pSpell; - if (pSpell != -1) { - v3 = 0; - v5 = pSplType; - v6 = plr[myplr]._pSplHotKey; - do { - if (*v6 == v1 && plr[myplr]._pSplTHotKey[v3] == v5) - *v6 = -1; - ++v3; - ++v6; - } while (v3 < 4); - plr[myplr]._pSplHotKey[slot] = v1; - plr[myplr]._pSplTHotKey[slot] = v5; + if (pSpell != SPL_INVALID) { + for (i = 0; i < 4; ++i) { + if (plr[myplr]._pSplHotKey[i] == pSpell && plr[myplr]._pSplTHotKey[i] == pSplType) + plr[myplr]._pSplHotKey[i] = SPL_INVALID; + } + plr[myplr]._pSplHotKey[slot] = pSpell; + plr[myplr]._pSplTHotKey[slot] = pSplType; } } -// 4B8834: using guessed type int pSpell; -// 4B8954: using guessed type int pSplType; void ToggleSpell(int slot) { From b228d6e00a0167f8fc078c4c89d2bb79a9e2ebff Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Fri, 12 Apr 2019 22:42:39 -0500 Subject: [PATCH 08/11] Palette fix for newer Windows --- Source/diablo.cpp | 2 +- Source/dx.cpp | 9 +++++++++ types.h | 8 +++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 0c8a7b86a..0d4e7e248 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -171,7 +171,7 @@ void run_game_loop(unsigned int uMsg) gbGameLoopStartup = 0; DrawAndBlit(); } -#ifdef SLEEP +#ifdef SLEEPFIX Sleep(1); #endif } diff --git a/Source/dx.cpp b/Source/dx.cpp index 79841dd05..efcb888e6 100644 --- a/Source/dx.cpp +++ b/Source/dx.cpp @@ -67,6 +67,15 @@ void dx_init(HWND hWnd) v3 = dx_DirectDrawCreate(v2, &lpDDInterface, NULL); if (v3) ErrDlg(IDD_DIALOG1, v3, "C:\\Src\\Diablo\\Source\\dx.cpp", 149); + +#ifdef COLORFIX +#ifdef __DDRAWI_INCLUDED__ + ((LPDDRAWI_DIRECTDRAW_INT)lpDDInterface)->lpLcl->dwAppHackFlags |= 0x800; +#else + ((DWORD **)lpDDInterface)[1][18] |= 0x800; +#endif +#endif + fullscreen = 1; #ifdef __cplusplus v4 = lpDDInterface->SetCooperativeLevel(v1, DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT | DDSCL_FULLSCREEN); diff --git a/types.h b/types.h index c427ce332..ef715d13d 100644 --- a/types.h +++ b/types.h @@ -48,13 +48,19 @@ // If defined, use copy protection [Default -> Defined] //#define COPYPROT + // If defined, don't reload for debuggers [Default -> Undefined] // Note that with patch 1.03 the command line was hosed, this is required to pass arguments to the game #ifdef _DEBUG #define DEBUGGER #endif + // If defined, don't fry the CPU [Default -> Undefined] -#define SLEEP +#define SLEEPFIX + +// If defined, fix palette glitch in Windows Vista+ [Default -> Undefined] +//#define COLORFIX + // If defined, use standard memcpy() in place of qmemcpy() [Default -> Undefined] // Will be replaced with [rep movsd] if optimization is used #define FAST_MEMCPY From cc40bbfbe3bcd711b535272558a07f1ef82f57fa Mon Sep 17 00:00:00 2001 From: Robin Eklind Date: Sat, 13 Apr 2019 19:18:35 +0900 Subject: [PATCH 09/11] Cleanup DRLG_RectTrans, already bin exact --- Source/gendung.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/Source/gendung.cpp b/Source/gendung.cpp index 7844a09e9..84a6361dc 100644 --- a/Source/gendung.cpp +++ b/Source/gendung.cpp @@ -595,22 +595,14 @@ void DRLG_MRectTrans(int x1, int y1, int x2, int y2) void DRLG_RectTrans(int x1, int y1, int x2, int y2) { - int i; // esi - char *v5; // edx - int j; // eax - - for (i = y1; i <= y2; ++i) { - if (x1 <= x2) { - v5 = &dTransVal[x1][i]; - j = x2 - x1 + 1; - do { - *v5 = TransVal; - v5 += 112; - --j; - } while (j); + int i, j; + + for (j = y1; j <= y2; j++) { + for (i = x1; i <= x2; i++) { + dTransVal[i][j] = TransVal; } } - ++TransVal; + TransVal++; } // 5A5590: using guessed type char TransVal; From 1991c06220a222dad6bf1665464825db3ed811d7 Mon Sep 17 00:00:00 2001 From: Robin Eklind Date: Sat, 13 Apr 2019 20:05:26 +0900 Subject: [PATCH 10/11] DrawWarLord bin exact --- Source/quests.cpp | 69 +++++++++++++++++------------------------------ 1 file changed, 24 insertions(+), 45 deletions(-) diff --git a/Source/quests.cpp b/Source/quests.cpp index 1bfcd1e46..acf6be8ec 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -418,54 +418,33 @@ void DrawSkelKing(int q, int x, int y) void DrawWarLord(int x, int y) { - int v2; // esi - int v3; // edi - unsigned char *v4; // eax - int v5; // ebx - int v6; // edx - int v7; // edx - char *v8; // eax - int v9; // ecx - char *v10; // esi - char v11; // bl - unsigned char *ptr; // [esp+Ch] [ebp-Ch] - int v13; // [esp+10h] [ebp-8h] - int v14; // [esp+14h] [ebp-4h] + int rw, rh; + int i, j; + unsigned char *sp; + unsigned char *setp; + int v; - v2 = y; - v3 = x; - v4 = LoadFileInMem("Levels\\L4Data\\Warlord2.DUN", 0); - v5 = *v4; - ptr = v4; - v4 += 2; - v14 = v2; - v6 = *v4; - setpc_h = v6; - v7 = v2 + v6; - v8 = (char *)(v4 + 2); - setpc_w = v5; - setpc_x = v3; - setpc_y = v2; - if (v2 < v7) { - v13 = v3 + v5; - do { - if (v3 < v13) { - v9 = v13 - v3; - v10 = (char *)&dungeon[v3][v14]; - do { - v11 = *v8; - if (!*v8) - v11 = 6; - *v10 = v11; - v8 += 2; - v10 += 40; - --v9; - } while (v9); + setp = LoadFileInMem("Levels\\L4Data\\Warlord2.DUN", NULL); + rw = *setp; + sp = setp + 2; + rh = *sp; + sp += 2; + setpc_w = rw; + setpc_h = rh; + setpc_x = x; + setpc_y = y; + for (j = y; j < y+rh; j++) { + for (i = x; i < x+rw; i++) { + if (*sp != 0) { + v = *sp; + } else { + v = 6; } - ++v14; - } while (v14 < v7); + dungeon[i][j] = v; + sp += 2; + } } - mem_free_dbg(ptr); + mem_free_dbg(setp); } // 5CF330: using guessed type int setpc_h; // 5CF334: using guessed type int setpc_w; From 9b8263b4febbad23cccb45d24267d066e2b219e4 Mon Sep 17 00:00:00 2001 From: Robin Eklind Date: Sat, 13 Apr 2019 20:21:54 +0900 Subject: [PATCH 11/11] DrawSChamber bin exact --- Source/quests.cpp | 75 ++++++++++++++++++----------------------------- 1 file changed, 28 insertions(+), 47 deletions(-) diff --git a/Source/quests.cpp b/Source/quests.cpp index acf6be8ec..81c0981fc 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -451,57 +451,38 @@ void DrawWarLord(int x, int y) void DrawSChamber(int q, int x, int y) { - int v3; // esi - unsigned char *v4; // eax - int v5; // edi - int v6; // ebx - int v7; // eax - char *v8; // ecx - int v9; // eax - char *v10; // edx - char v11; // bl - int v12; // edx - unsigned char *ptr; // [esp+Ch] [ebp-10h] - int v14; // [esp+10h] [ebp-Ch] - int v15; // [esp+14h] [ebp-8h] - int v16; // [esp+18h] [ebp-4h] + int i, j; + int rw, rh; + int xx, yy; + unsigned char *sp; + unsigned char *setp; + int v; - v3 = x; - v14 = q; - v4 = LoadFileInMem("Levels\\L2Data\\Bonestr1.DUN", 0); - v5 = y; - ptr = v4; - v6 = y; - v7 = *v4; - setpc_h = ptr[2]; - v8 = (char *)(ptr + 4); - setpc_w = v7; - setpc_x = v3; + setp = LoadFileInMem("Levels\\L2Data\\Bonestr1.DUN", NULL); + rw = *setp; + sp = setp + 2; + rh = *sp; + sp += 2; + setpc_w = rw; + setpc_h = rh; + setpc_x = x; setpc_y = y; - v15 = y + setpc_h; - if (y < y + setpc_h) { - v16 = v3 + v7; - do { - if (v3 < v16) { - v9 = v16 - v3; - v10 = (char *)&dungeon[v3][v6]; - do { - v11 = *v8; - if (!*v8) - v11 = 3; - *v10 = v11; - v8 += 2; - v10 += 40; - --v9; - } while (v9); + for (j = y; j < y+rh; j++) { + for (i = x; i < x+rw; i++) { + if (*sp != 0) { + v = *sp; + } else { + v = 3; } - v6 = y++ + 1; - } while (y < v15); + dungeon[i][j] = v; + sp += 2; + } } - v12 = v14; - quests[v12]._qtx = 2 * v3 + 22; - quests[v12]._qty = 2 * v5 + 23; - mem_free_dbg(ptr); + xx = 2 * x + 22; + yy = 2 * y + 23; + quests[q]._qtx = xx; + quests[q]._qty = yy; + mem_free_dbg(setp); } // 5CF330: using guessed type int setpc_h; // 5CF334: using guessed type int setpc_w;