Browse Source

Merge upstream beanch 'devilution/master'

pull/287/head
Xadhoom 7 years ago
parent
commit
6856fb74e2
  1. 8
      3rdParty/Storm/Source/storm.h
  2. 16
      DiabloUI/diabloui.h
  3. 43
      Source/appfat.cpp
  4. 4
      Source/appfat.h
  5. 51
      Source/automap.cpp
  6. 4
      Source/capture.cpp
  7. 4
      Source/codec.cpp
  8. 104
      Source/control.cpp
  9. 8
      Source/control.h
  10. 11
      Source/cursor.cpp
  11. 4
      Source/dead.cpp
  12. 8
      Source/debug.cpp
  13. 6
      Source/diablo.cpp
  14. 82
      Source/diablo.h
  15. 8
      Source/doom.cpp
  16. 50
      Source/drlg_l1.cpp
  17. 382
      Source/drlg_l2.cpp
  18. 2
      Source/drlg_l2.h
  19. 8
      Source/drlg_l3.cpp
  20. 423
      Source/drlg_l4.cpp
  21. 15
      Source/dthread.cpp
  22. 97
      Source/dx.cpp
  23. 5
      Source/effects.cpp
  24. 5
      Source/encrypt.cpp
  25. 60
      Source/engine.cpp
  26. 1
      Source/engine.h
  27. 4
      Source/error.cpp
  28. 4
      Source/fault.cpp
  29. 4
      Source/gamemenu.cpp
  30. 16
      Source/gendung.cpp
  31. 26
      Source/gmenu.cpp
  32. 4
      Source/help.cpp
  33. 8
      Source/init.cpp
  34. 11
      Source/interfac.cpp
  35. 11
      Source/inv.cpp
  36. 67
      Source/items.cpp
  37. 10
      Source/lighting.cpp
  38. 2
      Source/list.h
  39. 4
      Source/loadsave.cpp
  40. 5
      Source/logging.cpp
  41. 6
      Source/mainmenu.cpp
  42. 21
      Source/minitext.cpp
  43. 4
      Source/missiles.cpp
  44. 10
      Source/monster.cpp
  45. 5
      Source/movie.cpp
  46. 32
      Source/mpqapi.cpp
  47. 2
      Source/mpqapi.h
  48. 14
      Source/msg.cpp
  49. 4
      Source/msgcmd.cpp
  50. 179
      Source/multi.cpp
  51. 8
      Source/multi.h
  52. 5
      Source/nthread.cpp
  53. 2432
      Source/objects.cpp
  54. 34
      Source/objects.h
  55. 5
      Source/pack.cpp
  56. 6
      Source/palette.cpp
  57. 4
      Source/path.cpp
  58. 8
      Source/pfile.cpp
  59. 43
      Source/player.cpp
  60. 4
      Source/plrmsg.cpp
  61. 4
      Source/portal.cpp
  62. 4
      Source/quests.cpp
  63. 7
      Source/render.cpp
  64. 4
      Source/restrict.cpp
  65. 23
      Source/scrollrt.cpp
  66. 4
      Source/setmaps.cpp
  67. 4
      Source/sha.cpp
  68. 5
      Source/sound.cpp
  69. 4
      Source/spells.cpp
  70. 424
      Source/stores.cpp
  71. 2
      Source/stores.h
  72. 4
      Source/sync.cpp
  73. 4
      Source/textdat.cpp
  74. 119
      Source/themes.cpp
  75. 17
      Source/tmsg.cpp
  76. 1
      Source/tmsg.h
  77. 14
      Source/town.cpp
  78. 13
      Source/towners.cpp
  79. 5
      Source/track.cpp
  80. 113
      Source/trigs.cpp
  81. 9
      Source/wave.cpp
  82. 3
      SourceS/devilution.h
  83. 2
      SourceS/miniwin/misc.h
  84. 4
      SourceX/dx.cpp
  85. 7
      SourceX/miniwin/misc.cpp
  86. 14
      defs.h
  87. 2
      enums.h
  88. 90
      types.h

8
3rdParty/Storm/Source/storm.h vendored

@ -11,7 +11,8 @@
#else
#include "miniwin.h"
#include "miniwin/pushdecl.inc"
namespace dvl {
#endif
@ -1348,4 +1349,9 @@ BOOL __stdcall SFileEnableDirectAccess(BOOL enable);
}
#endif
#ifdef DEVILUTION_STUB
}
#include "miniwin/popdecl.inc"
#endif
#endif

16
DiabloUI/diabloui.h

@ -2,10 +2,15 @@
#ifndef __DIABLOUI_H__
#define __DIABLOUI_H__
#if defined(__GNUC__) || defined(__cplusplus)
extern "C" {
#ifdef DEVILUTION_STUB
#include "miniwin/pushdecl.inc"
namespace dvl {
#endif
//#if defined(__GNUC__) || defined(__cplusplus)
//extern "C" {
//#endif
struct FontStruct {
unsigned char fontbin[258];
HANDLE fonttrans[256];
@ -55,8 +60,13 @@ void __stdcall UiCreateGameCriteria(_uiheroinfo *pInfo, char *str);
BOOL __stdcall UiGetDefaultStats(int pclass, _uidefaultstats *pStats);
BOOL __stdcall UiBetaDisclaimer(int a1);
#if defined(__GNUC__) || defined(__cplusplus)
//#if defined(__GNUC__) || defined(__cplusplus)
//}
//#endif
#ifdef DEVILUTION_STUB
}
#include "miniwin/popdecl.inc"
#endif
#endif /* __DIABLOUI_H__ */

43
Source/appfat.cpp

@ -1,6 +1,5 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
#include "../3rdParty/Storm/Source/storm.h"
DEVILUTION_BEGIN_NAMESPACE
@ -16,6 +15,41 @@ int cleanup_thread_id;
// }
//}
void TriggerBreak()
{
#ifdef _DEBUG
LPTOP_LEVEL_EXCEPTION_FILTER pFilter;
pFilter = SetUnhandledExceptionFilter(BreakFilter);
#ifdef USE_ASM
__asm {
int 3
}
#else
__debugbreak();
#endif
SetUnhandledExceptionFilter(pFilter);
#endif
}
#ifdef _DEBUG
LONG __stdcall BreakFilter(PEXCEPTION_POINTERS pExc)
{
if(pExc->ExceptionRecord == NULL) {
return 0;
}
if(pExc->ExceptionRecord->ExceptionCode != EXCEPTION_BREAKPOINT) {
return 0;
}
if(((BYTE *)pExc->ContextRecord->Eip)[0] == 0xCC) { // int 3
pExc->ContextRecord->Eip++;
}
return -1;
}
#endif
char *GetErrorStr(DWORD error_code)
{
DWORD upper_code;
@ -424,6 +458,9 @@ void __cdecl app_fatal(const char *pszFmt, ...)
va_start(va, pszFmt);
FreeDlg();
#ifdef _DEBUG
TriggerBreak();
#endif
if (pszFmt)
MsgBox(pszFmt, va);

4
Source/appfat.h

@ -6,6 +6,10 @@ extern char sz_error_buf[256];
extern int terminating; // weak
extern int cleanup_thread_id; // weak
void TriggerBreak();
#ifdef _DEBUG
LONG __stdcall BreakFilter(PEXCEPTION_POINTERS pExc);
#endif
char *GetErrorStr(DWORD error_code);
void TraceErrorDD(HRESULT hError, char *pszBuffer, DWORD dwMaxChars);
void TraceErrorDS(HRESULT hError, char *pszBuffer, DWORD dwMaxChars);

51
Source/automap.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE
@ -510,28 +508,41 @@ void DrawAutomapPlr()
WORD GetAutomapType(int x, int y, BOOL view)
{
if (view) {
if (x == -1 && y >= 0 && y < DMAXY && automapview[0][y])
return ~GetAutomapType(0, y, FALSE) & (MAPFLAG_SQUARE << 8);
if (y == -1) {
if (x < 0)
return 0;
if (x < DMAXX && automapview[x][0])
return ~GetAutomapType(x, 0, FALSE) & (MAPFLAG_SQUARE << 8);
WORD rv;
if (view && x == -1 && y >= 0 && y < DMAXY && automapview[0][y]) {
if (GetAutomapType(0, y, FALSE) & (MAPFLAG_SQUARE << 8)) {
return 0;
} else {
return MAPFLAG_SQUARE << 8;
}
}
if (x >= 0 && x < DMAXX && y >= 0 && y < DMAXY) {
if (automapview[x][y] || !view) {
WORD type = automaptype[(BYTE)dungeon[x][y]];
if (type == 7 && GetAutomapType(x - 1, y, FALSE) & (MAPFLAG_HORZARCH << 8)
&& GetAutomapType(x, y - 1, FALSE) & (MAPFLAG_VERTARCH << 8)) {
type = 1;
}
return type;
if (view && y == -1 && x >= 0 && x < DMAXY && automapview[x][0]) {
if (GetAutomapType(x, 0, FALSE) & (MAPFLAG_SQUARE << 8)) {
return 0;
} else {
return MAPFLAG_SQUARE << 8;
}
}
return 0;
if (x < 0 || x >= DMAXX) {
return 0;
}
if (y < 0 || y >= DMAXX) {
return 0;
}
if (!automapview[x][y] && view) {
return 0;
}
rv = automaptype[(BYTE)dungeon[x][y]];
if (rv == 7
&& GetAutomapType(x - 1, y, FALSE) & (MAPFLAG_HORZARCH << 8)
&& GetAutomapType(x, y - 1, FALSE) & (MAPFLAG_VERTARCH << 8)) {
rv = 1;
}
return rv;
}
void DrawAutomapGame()

4
Source/capture.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE

4
Source/codec.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE

104
Source/control.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE
@ -10,8 +8,8 @@ void *pDurIcons;
void *pChrButtons;
BOOL drawhpflag; // idb
BOOL dropGoldFlag;
int panbtn[8];
BOOL chrbtn[4];
WORD panbtn[8];
WORD chrbtn[4];
void *pMultiBtns;
void *pPanelButtons;
void *pChrPanel;
@ -22,14 +20,14 @@ BOOL drawmanaflag; // idb
BOOL chrbtnactive;
char sgszTalkMsg[MAX_SEND_STR_LEN];
BYTE *pPanelText;
int frame_4B8800; // idb
int nGoldFrame;
BYTE *pLifeBuff;
BYTE *pBtmBuff;
void *pTalkBtns;
int pstrjust[4];
int pnumlines; // idb
BOOL pinfoflag;
int talkbtndown[3];
WORD talkbtndown[3];
int pSpell; // weak
BYTE *pManaBuff;
char infoclr; // weak
@ -181,7 +179,7 @@ void DrawSpellCel(int xp, int yp, BYTE *Trans, int nCel, int w)
dst = &gpBuffer[xp + PitchTbl[yp]];
tbl = SplTransTbl;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov ebx, Trans
mov eax, nCel
@ -632,7 +630,7 @@ void CPrintString(int nOffset, int nCel, char col)
{
/// ASSERT: assert(gpBuffer);
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov ebx, pPanelText
mov eax, nCel
@ -944,7 +942,7 @@ void DrawPanelBox(int x, int y, int w, int h, int sx, int sy)
nSrcOff = x + 640 * y;
nDstOff = sx + 768 * sy;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov esi, pBtmBuff
add esi, nSrcOff
@ -1020,7 +1018,7 @@ void SetFlaskHeight(BYTE *pCelBuff, int min, int max, int c, int r)
nDstOff = c + 768 * r;
w = max - min;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov esi, pCelBuff
add esi, nSrcOff
@ -1047,7 +1045,7 @@ void SetFlaskHeight(BYTE *pCelBuff, int min, int max, int c, int r)
void DrawFlask(BYTE *pCelBuff, int w, int nSrcOff, BYTE *pBuff, int nDstOff, int h)
{
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov esi, pCelBuff
add esi, nSrcOff
@ -1181,64 +1179,58 @@ void UpdateManaFlask()
void InitControlPan()
{
size_t v0; // esi
void *v1; // ecx
void *v2; // ecx
void *v3; // ecx
unsigned char *v5; // eax
v0 = 144 * 640;
if (gbMaxPlayers != 1)
v0 = 288 * 640;
pBtmBuff = DiabloAllocPtr(v0);
memset(pBtmBuff, 0, v0);
pManaBuff = DiabloAllocPtr(0x1E40);
memset(pManaBuff, 0, 0x1E40);
pLifeBuff = DiabloAllocPtr(0x1E40);
memset(pLifeBuff, 0, 0x1E40);
int i;
if (gbMaxPlayers == 1) {
pBtmBuff = DiabloAllocPtr(144 * 640);
memset(pBtmBuff, 0, 144 * 640);
} else {
pBtmBuff = DiabloAllocPtr(288 * 640);
memset(pBtmBuff, 0, 288 * 640);
}
pManaBuff = DiabloAllocPtr(88 * 88);
memset(pManaBuff, 0, 88 * 88);
pLifeBuff = DiabloAllocPtr(88 * 88);
memset(pLifeBuff, 0, 88 * 88);
pPanelText = LoadFileInMem("CtrlPan\\SmalText.CEL", 0);
pChrPanel = LoadFileInMem("Data\\Char.CEL", 0);
pSpellCels = LoadFileInMem("CtrlPan\\SpelIcon.CEL", 0);
SetSpellTrans(RSPLTYPE_SKILL);
pStatusPanel = LoadFileInMem("CtrlPan\\Panel8.CEL", 0);
CelDecodeRect((BYTE *)pBtmBuff, 0, 143, 640, (BYTE *)pStatusPanel, 1, 640);
v1 = pStatusPanel;
pStatusPanel = 0;
mem_free_dbg(v1);
MemFreeDbg(pStatusPanel);
pStatusPanel = LoadFileInMem("CtrlPan\\P8Bulbs.CEL", 0);
CelDecodeRect((BYTE *)pLifeBuff, 0, 87, 88, (BYTE *)pStatusPanel, 1, 88);
CelDecodeRect((BYTE *)pManaBuff, 0, 87, 88, (BYTE *)pStatusPanel, 2, 88);
v2 = pStatusPanel;
pStatusPanel = 0;
mem_free_dbg(v2);
MemFreeDbg(pStatusPanel);
talkflag = 0;
if (gbMaxPlayers != 1) {
pTalkPanel = LoadFileInMem("CtrlPan\\TalkPanl.CEL", 0);
CelDecodeRect((BYTE *)pBtmBuff, 0, 287, 640, (BYTE *)pTalkPanel, 1, 640);
v3 = pTalkPanel;
pTalkPanel = 0;
mem_free_dbg(v3);
MemFreeDbg(pTalkPanel);
pMultiBtns = LoadFileInMem("CtrlPan\\P8But2.CEL", 0);
pTalkBtns = LoadFileInMem("CtrlPan\\TalkButt.CEL", 0);
sgbPlrTalkTbl = 0;
*(_DWORD *)byte_4B894C = 0x1010101;
talkbtndown[0] = 0;
talkbtndown[1] = 0;
sgszTalkMsg[0] = 0;
talkbtndown[2] = 0;
for (i = 0; i < sizeof(byte_4B894C); i++)
byte_4B894C[i] = 1;
for (i = 0; i < sizeof(talkbtndown); i++)
talkbtndown[i] = 0;
}
panelflag = 0;
lvlbtndown = 0;
pPanelButtons = LoadFileInMem("CtrlPan\\Panel8bu.CEL", 0);
memset(panbtn, 0, sizeof(panbtn));
for (i = 0; i < sizeof(panbtn); i++)
panbtn[i] = 0;
panbtndown = 0;
numpanbtns = 2 * (gbMaxPlayers != 1) + 6;
if (gbMaxPlayers == 1)
numpanbtns = 6;
else
numpanbtns = 8;
pChrButtons = LoadFileInMem("Data\\CharBut.CEL", 0);
chrbtn[0] = 0;
chrbtn[1] = 0;
chrbtn[2] = 0;
for (i = 0; i < sizeof(chrbtn); i++)
chrbtn[i] = 0;
chrbtnactive = FALSE;
chrbtn[3] = 0;
pDurIcons = LoadFileInMem("Items\\DurIcons.CEL", 0);
strcpy(infostr, "");
ClearPanel();
@ -1259,23 +1251,13 @@ void InitControlPan()
SpellPages[0][0] = SPL_RECHARGE;
}
pQLogCel = LoadFileInMem("Data\\Quest.CEL", 0);
v5 = LoadFileInMem("CtrlPan\\Golddrop.cel", 0);
frame_4B8800 = 1;
pGBoxBuff = LoadFileInMem("CtrlPan\\Golddrop.cel", 0);
dropGoldFlag = FALSE;
dropGoldValue = 0;
initialDropGoldValue = 0;
initialDropGoldIndex = 0;
pGBoxBuff = v5;
nGoldFrame = 1;
}
// 4B851C: using guessed type int lvlbtndown;
// 4B8840: using guessed type int sgbPlrTalkTbl;
// 4B8950: using guessed type int sbooktab;
// 4B8960: using guessed type int talkflag;
// 4B8968: using guessed type int sbookflag;
// 4B8A7C: using guessed type int numpanbtns;
// 4B8B84: using guessed type int panelflag;
// 4B8C98: using guessed type int spselflag;
// 679660: using guessed type char gbMaxPlayers;
void ClearCtrlPan()
{
@ -2314,7 +2296,7 @@ void RedBack()
/// ASSERT: assert(gpBuffer);
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
if (leveltype != DTYPE_HELL) {
__asm {
mov edi, gpBuffer
@ -2585,8 +2567,8 @@ void DrawGoldSplit(int amount)
}
screen_xa = screen_x + 452;
}
CelDecodeOnly(screen_xa, 300, (BYTE *)pCelBuff, frame_4B8800, 12);
frame_4B8800 = (frame_4B8800 & 7) + 1;
CelDecodeOnly(screen_xa, 300, (BYTE *)pCelBuff, nGoldFrame, 12);
nGoldFrame = (nGoldFrame & 7) + 1;
}
void control_drop_gold(char vkey)

8
Source/control.h

@ -6,8 +6,8 @@ extern void *pDurIcons;
extern void *pChrButtons;
extern BOOL drawhpflag; // idb
extern BOOL dropGoldFlag;
extern int panbtn[8];
extern BOOL chrbtn[4];
extern WORD panbtn[8];
extern WORD chrbtn[4];
extern void *pMultiBtns;
extern void *pPanelButtons;
extern void *pChrPanel;
@ -16,14 +16,14 @@ extern int dropGoldValue; // idb
extern BOOL drawmanaflag; // idb
extern BOOL chrbtnactive;
extern BYTE *pPanelText;
extern int frame_4B8800; // idb
extern int nGoldFrame;
extern BYTE *pLifeBuff;
extern BYTE *pBtmBuff;
extern void *pTalkBtns;
extern int pstrjust[4];
extern int pnumlines; // idb
extern BOOL pinfoflag;
extern int talkbtndown[3];
extern WORD talkbtndown[3];
extern int pSpell; // weak
extern BYTE *pManaBuff;
extern char infoclr; // weak

11
Source/cursor.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE
@ -79,12 +77,7 @@ void InitCursor()
void FreeCursor()
{
void *p;
p = pCursCels;
pCursCels = NULL;
mem_free_dbg(p);
MemFreeDbg(pCursCels);
ClearCursor();
}

4
Source/dead.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE

8
Source/debug.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE
@ -17,9 +15,7 @@ void LoadDebugGFX()
void FreeDebugGFX()
{
void *temp = pSquareCel;
pSquareCel = NULL;
mem_free_dbg(temp);
MemFreeDbg(pSquareCel);
}
void CheckDungeonClear()

6
Source/diablo.cpp

@ -1,6 +1,6 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
#include "../3rdParty/Storm/Source/storm.h"
#include "../DiabloUI/diabloui.h"
DEVILUTION_BEGIN_NAMESPACE

82
Source/diablo.h

@ -2,6 +2,82 @@
#ifndef __DIABLO_H__
#define __DIABLO_H__
#include "../types.h"
//#ifdef __cplusplus
//extern "C" {
//#endif
#include "appfat.h"
#include "automap.h"
#include "capture.h"
#include "codec.h"
#include "control.h"
#include "cursor.h"
#include "dead.h"
#include "debug.h"
#include "doom.h"
#include "drlg_l1.h"
#include "drlg_l2.h"
#include "drlg_l3.h"
#include "drlg_l4.h"
#include "dthread.h"
#include "dx.h"
#include "effects.h"
#include "encrypt.h"
#include "engine.h"
#include "error.h"
#include "fault.h"
#include "gamemenu.h"
#include "gendung.h"
#include "gmenu.h"
#include "help.h"
#include "init.h"
#include "interfac.h"
#include "inv.h"
#include "items.h"
#include "lighting.h"
#include "loadsave.h"
#include "logging.h"
#include "mainmenu.h"
#include "minitext.h"
#include "missiles.h"
#include "monster.h"
#include "movie.h"
#include "mpqapi.h"
#include "msg.h"
#include "msgcmd.h"
#include "multi.h"
#include "nthread.h"
#include "objects.h"
#include "pack.h"
#include "palette.h"
#include "path.h"
#include "pfile.h"
#include "player.h"
#include "plrmsg.h"
#include "portal.h"
#include "quests.h"
#include "restrict.h"
#include "scrollrt.h"
#include "setmaps.h"
#include "sha.h"
#include "sound.h"
#include "spells.h"
#include "stores.h"
#include "sync.h"
#include "textdat.h" // check file name
#include "themes.h"
#include "tmsg.h"
#include "town.h"
#include "towners.h"
#include "track.h"
#include "trigs.h"
#include "wave.h"
#include "render.h" // linked last, likely .s/.asm
//#ifdef __cplusplus
//}
//#endif
extern HWND ghMainWnd;
extern int glMid1Seed[NUMLEVELS];
extern int glMid2Seed[NUMLEVELS];
@ -97,4 +173,10 @@ extern BOOL FriendlyMode;
extern char *spszMsgTbl[4]; // weak
extern char *spszMsgKeyTbl[4]; // weak
#ifdef DEVILUTION_STUB
#include "miniwin/popdecl.inc"
#endif
DEVILUTION_END_NAMESPACE
#endif /* __DIABLO_H__ */

8
Source/doom.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE
@ -46,9 +44,7 @@ void doom_alloc_cel()
void doom_cleanup()
{
void *ptr = pDoomCel;
pDoomCel = NULL;
mem_free_dbg(ptr);
MemFreeDbg(pDoomCel);
}
void doom_load_graphics()

50
Source/drlg_l1.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE
@ -212,7 +210,7 @@ void DRLG_L1Pass3()
lv = 22 - 1;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov esi, pMegaTiles
mov eax, lv
@ -255,7 +253,7 @@ void DRLG_L1Pass3()
for (i = 0; i < DMAXX; i++) {
lv = (unsigned char)dungeon[i][j] - 1;
/// ASSERT: assert(lv >= 0);
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov esi, pMegaTiles
mov eax, lv
@ -429,11 +427,7 @@ void DRLG_LoadL1SP()
void DRLG_FreeL1SP()
{
void *ptr;
ptr = pSetPiece;
pSetPiece = NULL;
mem_free_dbg(ptr);
MemFreeDbg(pSetPiece);
}
void DRLG_L5(int entry)
@ -1033,29 +1027,19 @@ int L5GetArea()
void L5makeDungeon()
{
signed int v0; // edi
signed int v1; // esi
char *v2; // edx
char v3; // cl
int v4; // eax
int v5; // eax
v0 = 0;
do {
v1 = 0;
v2 = (char *)dungeon + v0;
do {
v3 = *v2;
v2 += 40;
v4 = 160 * v1++;
v5 = v4 + 2 * v0;
L5dungeon[0][v5] = v3;
L5dungeon[0][v5 + 1] = v3;
L5dungeon[1][v5] = v3;
L5dungeon[1][v5 + 1] = v3;
} while (v1 < 40);
++v0;
} while (v0 < 40);
int i, j;
int i_2, j_2;
for (j = 0; j < 40; j++) {
for (i = 0; i < 40; i++) {
j_2 = j << 1;
i_2 = i << 1;
L5dungeon[i_2][j_2] = dungeon[i][j];
L5dungeon[i_2][j_2 + 1] = dungeon[i][j];
L5dungeon[i_2 + 1][j_2] = dungeon[i][j];
L5dungeon[i_2 + 1][j_2 + 1] = dungeon[i][j];
}
}
}
void L5makeDmt()

382
Source/drlg_l2.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE
@ -238,22 +236,14 @@ int Patterns[100][10] = {
void InitDungeon()
{
signed int v0; // edx
signed int v1; // eax
signed int v2; // ecx
int i, j;
v0 = 0;
do {
v1 = v0;
v2 = 40;
do {
dflags[0][v1] = 0;
predungeon[0][v1] = 32;
v1 += 40;
--v2;
} while (v2);
++v0;
} while (v0 < 40);
for(j = 0; j < DMAXY; j++) {
for(i = 0; i < DMAXX; i++) {
predungeon[i][j] = 32;
dflags[i][j] = 0;
}
}
}
void L2LockoutFix()
@ -460,7 +450,7 @@ void DRLG_L2Pass3()
lv = 12 - 1;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov esi, pMegaTiles
mov eax, lv
@ -502,7 +492,7 @@ void DRLG_L2Pass3()
xx = 16;
for (i = 0; i < DMAXX; i++) {
lv = (unsigned char)dungeon[i][j] - 1;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov esi, pMegaTiles
mov eax, lv
@ -633,32 +623,24 @@ void CreateL2Dungeon(unsigned int rseed, int entry)
void DRLG_LoadL2SP()
{
char *v1; // ecx
setloadflag_2 = 0;
if (QuestStatus(QTYPE_BLIND)) {
v1 = "Levels\\L2Data\\Blind2.DUN";
} else {
if (QuestStatus(QTYPE_BLOOD)) {
v1 = "Levels\\L2Data\\Blood1.DUN";
} else {
if (!QuestStatus(QTYPE_BONE))
return;
v1 = "Levels\\L2Data\\Bonestr2.DUN";
}
if(QuestStatus(QTYPE_BLIND)) {
pSetPiece_2 = (char *)LoadFileInMem("Levels\\L2Data\\Blind2.DUN", 0);
setloadflag_2 = 1;
} else if(QuestStatus(QTYPE_BLOOD)) {
pSetPiece_2 = (char *)LoadFileInMem("Levels\\L2Data\\Blood1.DUN", 0);
setloadflag_2 = 1;
} else if(QuestStatus(QTYPE_BONE)) {
pSetPiece_2 = (char *)LoadFileInMem("Levels\\L2Data\\Bonestr2.DUN", 0);
setloadflag_2 = 1;
}
pSetPiece_2 = (char *)LoadFileInMem(v1, 0);
setloadflag_2 = 1;
}
// 5B50D8: using guessed type int setloadflag_2;
void DRLG_FreeL2SP()
{
char *ptr;
ptr = pSetPiece_2;
pSetPiece_2 = NULL;
mem_free_dbg(ptr);
MemFreeDbg(pSetPiece_2);
}
void DRLG_L2(int entry)
@ -1118,104 +1100,101 @@ void L2TileFix()
BOOL CreateDungeon()
{
int v0; // esi
int v1; // edx
int v2; // ecx
signed int v3; // esi
char *v4; // eax
signed int v5; // ebx
_BYTE *v6; // ecx
BOOL v7; // zf
BOOL v8; // eax
int v9; // edi
int v10; // esi
signed int v12; // [esp-4h] [ebp-20h]
int nX1; // [esp+8h] [ebp-14h]
int nY1; // [esp+Ch] [ebp-10h]
int nX2; // [esp+10h] [ebp-Ch]
int nY2; // [esp+14h] [ebp-8h]
int nHd; // [esp+18h] [ebp-4h]
int i, j, nHx1, nHy1, nHx2, nHy2, nHd, ForceH, ForceW;
BOOL ForceHW;
ForceW = 0;
ForceH = 0;
ForceHW = FALSE;
switch(currlevel) {
case 5:
if(quests[QTYPE_BLOOD]._qactive) {
ForceHW = TRUE;
ForceH = 20;
ForceW = 14;
}
break;
case 6:
if(quests[QTYPE_BONE]._qactive) {
ForceHW = TRUE;
ForceW = 10;
ForceH = 10;
}
break;
case 7:
if(quests[QTYPE_BLIND]._qactive) {
ForceHW = TRUE;
ForceW = 15;
ForceH = 15;
}
break;
case 8:
break;
}
v0 = 0;
v1 = 0;
v2 = 0;
if (currlevel == 5) {
if (!quests[QTYPE_BLOOD]._qactive)
goto LABEL_12;
v1 = 20;
v0 = 14;
} else {
if (currlevel == 6) {
if (!quests[QTYPE_BONE]._qactive)
goto LABEL_12;
v12 = 10;
} else {
if (currlevel != 7 || !quests[QTYPE_BLIND]._qactive)
goto LABEL_12;
v12 = 15;
CreateRoom(2, 2, 39, 39, 0, 0, ForceHW, ForceH, ForceW);
while(pHallList != NULL) {
GetHall(&nHx1, &nHy1, &nHx2, &nHy2, &nHd);
ConnectHall(nHx1, nHy1, nHx2, nHy2, nHd);
}
for(j = 0; j <= DMAXY; j++) { /// BUGFIX: change '<=' to '<'
for(i = 0; i <= DMAXX; i++) { /// BUGFIX: change '<=' to '<'
if(predungeon[i][j] == 67) {
predungeon[i][j] = 35;
}
if(predungeon[i][j] == 66) {
predungeon[i][j] = 35;
}
if(predungeon[i][j] == 69) {
predungeon[i][j] = 35;
}
if(predungeon[i][j] == 65) {
predungeon[i][j] = 35;
}
if(predungeon[i][j] == 44) {
predungeon[i][j] = 46;
if(predungeon[i - 1][j - 1] == 32) {
predungeon[i - 1][j - 1] = 35;
}
if(predungeon[i - 1][j] == 32) {
predungeon[i - 1][j] = 35;
}
if(predungeon[i - 1][1 + j] == 32) {
predungeon[i - 1][1 + j] = 35;
}
if(predungeon[i + 1][j - 1] == 32) {
predungeon[i + 1][j - 1] = 35;
}
if(predungeon[i + 1][j] == 32) {
predungeon[i + 1][j] = 35;
}
if(predungeon[i + 1][1 + j] == 32) {
predungeon[i + 1][1 + j] = 35;
}
if(predungeon[i][j - 1] == 32) {
predungeon[i][j - 1] = 35;
}
if(predungeon[i][j + 1] == 32) {
predungeon[i][j + 1] = 35;
}
}
}
v0 = v12;
v1 = v12;
}
v2 = 1;
LABEL_12:
CreateRoom(2, 2, 39, 39, 0, 0, v2, v1, v0);
while (pHallList) {
GetHall(&nX1, &nY1, &nX2, &nY2, &nHd);
ConnectHall(nX1, nY1, nX2, nY2, nHd);
if(!DL2_FillVoids()) {
return FALSE;
}
v3 = 0;
do {
v4 = (char *)&predungeon[-1][v3];
v5 = 41;
do {
v6 = (unsigned char *)v4 + 40;
if (v4[40] == 67)
*v6 = 35;
if (*v6 == 66)
*v6 = 35;
if (*v6 == 69)
*v6 = 35;
if (*v6 == 65)
*v6 = 35;
if (*v6 == 44) {
v7 = *(v4 - 1) == 32;
*v6 = 46;
if (v7)
*(v4 - 1) = 35;
if (*v4 == 32)
*v4 = 35;
if (v4[1] == 32)
v4[1] = 35;
if (v4[79] == 32)
v4[79] = 35;
if (v4[80] == 32)
v4[80] = 35;
if (v4[81] == 32)
v4[81] = 35;
if (v4[39] == 32)
v4[39] = 35;
if (v4[41] == 32)
v4[41] = 35;
}
--v5;
v4 += 40;
} while (v5);
++v3;
} while (v3 <= 40);
v8 = DL2_FillVoids();
if (v8) {
v9 = 0;
do {
v10 = 0;
do
DoPatternCheck(v10++, v9);
while (v10 < 40);
++v9;
} while (v9 < 40);
v8 = 1;
for(j = 0; j < DMAXY; j++) {
for(i = 0; i < DMAXX; i++) {
DoPatternCheck(i, j);
}
}
return v8;
return TRUE;
}
void CreateRoom(int nX1, int nY1, int nX2, int nY2, int nRDest, int nHDir, int ForceHW, int nH, int nW)
@ -1418,111 +1397,74 @@ void CreateRoom(int nX1, int nY1, int nX2, int nY2, int nRDest, int nHDir, int F
// 5276CC: using guessed type int nSx2;
// 5276D4: using guessed type int nSy2;
void DefineRoom(int nX1, int nY1, int nX2, int nY2, int ForceHW)
void DefineRoom(int nX1, int nY1, int nX2, int nY2, BOOL ForceHW)
{
int v5; // esi
int v6; // edi
int v7; // eax
int i; // eax
BOOLEAN v9; // zf
int v10; // ecx
char *v11; // eax
char *v12; // ebx
int v13; // eax
int v14; // [esp+10h] [ebp-4h]
int v15; // [esp+10h] [ebp-4h]
int nY2a; // [esp+20h] [ebp+Ch]
char *ForceHWa; // [esp+24h] [ebp+10h]
v5 = nX1;
v6 = nX2;
predungeon[v5][nY1] = 67;
predungeon[v5][nY2] = 69;
predungeon[v6][nY1] = 66;
predungeon[v6][nY2] = 65;
v7 = nRoomCnt + 1;
nRoomCnt = v7;
v7 *= 20;
*(int *)((char *)&RoomList[0].nRoomx1 + v7) = nX1;
*(int *)((char *)&RoomList[0].nRoomx2 + v7) = nX2;
*(int *)((char *)&RoomList[0].nRoomy1 + v7) = nY1;
*(int *)((char *)&RoomList[0].nRoomy2 + v7) = nY2;
if (ForceHW == 1) {
for (i = nX1; i < nX2; ++i) {
if (i < nY2) {
ForceHWa = &dflags[i][nY1];
v14 = nY2 - i;
i = nY2;
do {
*ForceHWa |= DFLAG_EXPLORED;
v9 = v14-- == 1;
ForceHWa += 40;
} while (!v9);
int i, j;
predungeon[nX1][nY1] = 67;
predungeon[nX1][nY2] = 69;
predungeon[nX2][nY1] = 66;
predungeon[nX2][nY2] = 65;
nRoomCnt++;
RoomList[nRoomCnt].nRoomx1 = nX1;
RoomList[nRoomCnt].nRoomx2 = nX2;
RoomList[nRoomCnt].nRoomy1 = nY1;
RoomList[nRoomCnt].nRoomy2 = nY2;
if(ForceHW == TRUE) {
for(i = nX1; i < nX2; i++) {
while(i < nY2) {
dflags[i][nY1] |= 0x80;
i++;
}
}
}
v10 = nX1 + 1;
if (v10 <= nX2 - 1) {
v15 = nX2 - v10;
v11 = (char *)&predungeon[v10][nY2];
do {
v11[nY1 - nY2] = 35;
*v11 = 35;
v11 += 40;
--v15;
} while (v15);
for(i = nX1 + 1; i <= nX2 - 1; i++) {
predungeon[i][nY1] = 35;
predungeon[i][nY2] = 35;
}
nY2a = nY2 - 1;
while (++nY1 <= nY2a) {
predungeon[v5][nY1] = 35;
predungeon[v6][nY1] = 35;
if (v10 < nX2) {
v12 = (char *)&predungeon[v10][nY1];
v13 = nX2 - v10;
do {
*v12 = 46;
v12 += 40;
--v13;
} while (v13);
nY2--;
for(j = nY1 + 1; j <= nY2; j++) {
predungeon[nX1][j] = 35;
predungeon[nX2][j] = 35;
for(i = nX1 + 1; i < nX2; i++) {
predungeon[i][j] = 46;
}
}
}
void AddHall(int nX1, int nY1, int nX2, int nY2, int nHd)
{
int v5; // edi
int v6; // esi
HALLNODE *v7; // eax
HALLNODE *i; // ecx
v5 = nX1;
v6 = nY1;
if (pHallList) {
v7 = (HALLNODE *)DiabloAllocPtr(24);
v7->pNext = 0;
v7->nHallx2 = nX2;
v7->nHally2 = nY2;
v7->nHallx1 = v5;
v7->nHally1 = v6;
v7->nHalldir = nHd;
for (i = pHallList; i->pNext; i = i->pNext)
;
i->pNext = v7;
} else {
pHallList = (HALLNODE *)DiabloAllocPtr(24);
pHallList->nHallx1 = v5;
pHallList->nHally1 = v6;
HALLNODE *p1, *p2;
if(pHallList == NULL) {
pHallList = (HALLNODE *)DiabloAllocPtr(sizeof(*pHallList));
pHallList->nHallx1 = nX1;
pHallList->nHally1 = nY1;
pHallList->nHallx2 = nX2;
pHallList->nHally2 = nY2;
pHallList->nHalldir = nHd;
pHallList->pNext = 0;
pHallList->pNext = NULL;
} else {
p1 = (HALLNODE *)DiabloAllocPtr(sizeof(*pHallList));
p1->nHallx1 = nX1;
p1->nHally1 = nY1;
p1->nHallx2 = nX2;
p1->nHally2 = nY2;
p1->nHalldir = nHd;
p1->pNext = NULL;
p2 = pHallList;
while(p2->pNext != NULL) {
p2 = p2->pNext;
}
p2->pNext = p1;
}
}
void GetHall(int *nX1, int *nY1, int *nX2, int *nY2, int *nHd)
{
HALLNODE *p1;
HALLNODE *p2;
p1 = pHallList->pNext;
*nX1 = pHallList->nHallx1;
@ -1530,11 +1472,7 @@ void GetHall(int *nX1, int *nY1, int *nX2, int *nY2, int *nHd)
*nX2 = pHallList->nHallx2;
*nY2 = pHallList->nHally2;
*nHd = pHallList->nHalldir;
p2 = pHallList;
pHallList = NULL;
mem_free_dbg(p2);
MemFreeDbg(pHallList);
pHallList = p1;
}

2
Source/drlg_l2.h

@ -29,7 +29,7 @@ void DRLG_L2SetRoom(int rx1, int ry1);
void L2TileFix();
BOOL CreateDungeon();
void CreateRoom(int nX1, int nY1, int nX2, int nY2, int nRDest, int nHDir, int ForceHW, int nH, int nW);
void DefineRoom(int nX1, int nY1, int nX2, int nY2, int ForceHW);
void DefineRoom(int nX1, int nY1, int nX2, int nY2, BOOL ForceHW);
void AddHall(int nX1, int nY1, int nX2, int nY2, int nHd);
void GetHall(int *nX1, int *nY1, int *nX2, int *nY2, int *nHd);
void ConnectHall(int nX1, int nY1, int nX2, int nY2, int nHd);

8
Source/drlg_l3.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE
@ -1821,7 +1819,7 @@ void DRLG_L3Pass3()
lv = 8 - 1;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov esi, pMegaTiles
mov eax, lv
@ -1863,7 +1861,7 @@ void DRLG_L3Pass3()
xx = 16;
for (i = 0; i < DMAXX; i++) {
lv = (unsigned char)dungeon[i][j] - 1;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
if (lv >= 0) {
__asm {
mov esi, pMegaTiles

423
Source/drlg_l4.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE
@ -308,11 +306,7 @@ void DRLG_LoadL4SP()
void DRLG_FreeL4SP()
{
char *ptr;
ptr = pSetPiece_2;
pSetPiece_2 = NULL;
mem_free_dbg(ptr);
MemFreeDbg(pSetPiece_2);
}
void DRLG_L4SetSPRoom(int rx1, int ry1)
@ -541,195 +535,154 @@ void CreateL4Dungeon(unsigned int rseed, int entry)
void DRLG_L4(int entry)
{
signed int v1; // ebp
//int v2; // eax
int v3; // edx
char *v4; // edi
char v5; // bp
unsigned int v6; // ecx
char *v7; // edi
int v8; // ecx
//int v9; // eax
int v10; // eax
unsigned char *v11; // ecx
unsigned char *v12; // ecx
//int v13; // eax
signed int v14; // eax
signed int v15; // ecx
int v16; // ebx
int v17; // edi
char *v18; // ebp
signed int v19; // ecx
signed int v20; // eax
signed int v21; // esi
int v22; // [esp-8h] [ebp-20h]
int v23; // [esp+10h] [ebp-8h]
int v24; // [esp+14h] [ebp-4h]
v1 = 0;
v23 = entry;
int i, j, spi, spj;
BOOL doneflag;
do {
DRLG_InitTrans();
do {
InitL4Dungeon();
L4firstRoom();
L4FixRim();
} while (GetArea() < 173);
} while(GetArea() < 173);
uShape();
L4makeDungeon();
L4makeDmt();
L4tileFix();
if (currlevel == 16)
if(currlevel == 16) {
L4SaveQuads();
//_LOBYTE(v2) = QuestStatus(QTYPE_WARLRD);
if ((QuestStatus(QTYPE_WARLRD) || currlevel == quests[QTYPE_VB]._qlevel && gbMaxPlayers != 1) && SP4x1 < SP4x2) {
v3 = SP4x1;
v24 = SP4x2 - SP4x1;
do {
if (SP4y1 < SP4y2) {
v4 = &dflags[v3][SP4y1];
v5 = SP4y2 - SP4y1;
v6 = (unsigned int)(SP4y2 - SP4y1) >> 2;
memset(v4, 1u, 4 * v6);
v7 = &v4[4 * v6];
v8 = v5 & 3;
v1 = 0;
memset(v7, 1, v8);
}
if(QuestStatus(QTYPE_WARLRD) || currlevel == quests[QTYPE_VB]._qlevel && gbMaxPlayers != 1) {
for(spi = SP4x1; spi < SP4x2; spi++) {
for(spj = SP4y1; spj < SP4y2; spj++) {
dflags[spi][spj] = 1;
}
++v3;
--v24;
} while (v24);
}
}
L4AddWall();
DRLG_L4FloodTVal();
DRLG_L4TransFix();
if (setloadflag_2)
if(setloadflag_2) {
DRLG_L4SetSPRoom(SP4x1, SP4y1);
if (currlevel == 16)
DRLG_LoadDiabQuads(1);
//_LOBYTE(v9) = QuestStatus(QTYPE_WARLRD);
if (!QuestStatus(QTYPE_WARLRD)) {
if (currlevel == 15) {
if (!v23) {
v10 = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 1, 0);
if (v10) {
if (gbMaxPlayers != 1 || (v11 = (unsigned char *)L4PENTA, quests[QTYPE_MOD]._qactive == 2))
v11 = (unsigned char *)L4PENTA2;
v10 = DRLG_L4PlaceMiniSet(v11, 1, 1, -1, -1, 0, 1);
}
goto LABEL_35;
}
if(currlevel == 16) {
DRLG_LoadDiabQuads(TRUE);
}
if(QuestStatus(QTYPE_WARLRD)) {
if(entry == 0) {
doneflag = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 1, 0);
if(doneflag && currlevel == 13) {
doneflag = DRLG_L4PlaceMiniSet(L4TWARP, 1, 1, -1, -1, 0, 6);
}
v10 = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 0, 0);
if (v10) {
if (gbMaxPlayers != 1 || (v12 = (unsigned char *)L4PENTA, quests[QTYPE_MOD]._qactive == 2))
v12 = (unsigned char *)L4PENTA2;
v10 = DRLG_L4PlaceMiniSet(v12, 1, 1, -1, -1, 1, 1);
ViewX++;
} else if(entry == 1) {
doneflag = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 0, 0);
if(doneflag && currlevel == 13) {
doneflag = DRLG_L4PlaceMiniSet(L4TWARP, 1, 1, -1, -1, 0, 6);
}
ViewX = 2 * setpc_x + 22;
ViewY = 2 * setpc_y + 22;
} else {
if (!v23) {
v10 = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 1, 0);
if (v10) {
if (currlevel != 16)
v10 = DRLG_L4PlaceMiniSet(L4DSTAIRS, 1, 1, -1, -1, 0, 1);
goto LABEL_31;
}
LABEL_35:
++ViewX;
continue;
doneflag = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 0, 0);
if(doneflag && currlevel == 13) {
doneflag = DRLG_L4PlaceMiniSet(L4TWARP, 1, 1, -1, -1, 1, 6);
}
v10 = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 0, 0);
if (v23 != 1) {
if (v10) {
if (currlevel != 16)
v10 = DRLG_L4PlaceMiniSet(L4DSTAIRS, 1, 1, -1, -1, 0, 1);
LABEL_46:
if (v10) {
if (currlevel == 13) {
v22 = 1;
LABEL_34:
v10 = DRLG_L4PlaceMiniSet(L4TWARP, 1, 1, -1, -1, v22, 6);
goto LABEL_35;
}
}
ViewX++;
}
} else if(currlevel != 15) {
if(entry == 0) {
doneflag = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 1, 0);
if(doneflag && currlevel != 16) {
doneflag = DRLG_L4PlaceMiniSet(L4DSTAIRS, 1, 1, -1, -1, 0, 1);
}
if(doneflag && currlevel == 13) {
doneflag = DRLG_L4PlaceMiniSet(L4TWARP, 1, 1, -1, -1, 0, 6);
}
ViewX++;
} else if(entry == 1) {
doneflag = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 0, 0);
if(doneflag && currlevel != 16) {
doneflag = DRLG_L4PlaceMiniSet(L4DSTAIRS, 1, 1, -1, -1, 1, 1);
}
if(doneflag && currlevel == 13) {
doneflag = DRLG_L4PlaceMiniSet(L4TWARP, 1, 1, -1, -1, 0, 6);
}
ViewY++;
} else {
doneflag = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 0, 0);
if(doneflag && currlevel != 16) {
doneflag = DRLG_L4PlaceMiniSet(L4DSTAIRS, 1, 1, -1, -1, 0, 1);
}
if(doneflag && currlevel == 13) {
doneflag = DRLG_L4PlaceMiniSet(L4TWARP, 1, 1, -1, -1, 1, 6);
}
ViewX++;
}
} else {
if(entry == 0) {
doneflag = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 1, 0);
if(doneflag) {
if(gbMaxPlayers == 1 && quests[QTYPE_MOD]._qactive != 2) {
doneflag = DRLG_L4PlaceMiniSet(L4PENTA, 1, 1, -1, -1, 0, 1);
} else {
doneflag = DRLG_L4PlaceMiniSet(L4PENTA2, 1, 1, -1, -1, 0, 1);
}
goto LABEL_35;
}
if (v10) {
if (currlevel != 16)
v10 = DRLG_L4PlaceMiniSet(L4DSTAIRS, 1, 1, -1, -1, 1, 1);
if (v10 && currlevel == 13)
v10 = DRLG_L4PlaceMiniSet(L4TWARP, 1, 1, -1, -1, 0, 6);
ViewX++;
} else {
doneflag = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 0, 0);
if(doneflag) {
if(gbMaxPlayers == 1 && quests[QTYPE_MOD]._qactive != 2) {
doneflag = DRLG_L4PlaceMiniSet(L4PENTA, 1, 1, -1, -1, 1, 1);
} else {
doneflag = DRLG_L4PlaceMiniSet(L4PENTA2, 1, 1, -1, -1, 1, 1);
}
}
ViewY++;
}
++ViewY;
continue;
}
if (!v23) {
v10 = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 1, 0);
LABEL_31:
if (!v10 || currlevel != 13)
goto LABEL_35;
v22 = 0;
goto LABEL_34;
}
v10 = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 0, 0);
if (v23 != 1)
goto LABEL_46;
if (v10 && currlevel == 13)
v10 = DRLG_L4PlaceMiniSet(L4TWARP, 1, 1, -1, -1, 0, 6);
ViewX = 2 * setpc_x + 22;
ViewY = 2 * setpc_y + 22;
} while (!v10);
} while(!doneflag);
DRLG_L4GeneralFix();
if (currlevel != 16)
if(currlevel != 16) {
DRLG_PlaceThemeRooms(7, 10, 6, 8, 1);
}
DRLG_L4Shadows();
DRLG_L4Corners();
DRLG_L4Subs();
DRLG_Init_Globals();
//_LOBYTE(v13) = QuestStatus(QTYPE_WARLRD);
if (QuestStatus(QTYPE_WARLRD)) {
do {
v14 = v1;
v15 = 40;
do {
pdungeon[0][v14] = dungeon[0][v14];
v14 += 40;
--v15;
} while (v15);
++v1;
} while (v1 < 40);
if(QuestStatus(QTYPE_WARLRD)) {
for(j = 0; j < DMAXY; j++) {
for(i = 0; i < DMAXX; i++) {
pdungeon[i][j] = dungeon[i][j];
}
}
}
DRLG_CheckQuests(SP4x1, SP4y1);
if (currlevel == 15) {
v16 = -1;
do {
v17 = -1;
v18 = (char *)&dungeon[0][v16 + 1];
do {
if (*v18 == 98)
Make_SetPC(v17, v16, 5, 5);
if (*v18 == 107)
Make_SetPC(v17, v16, 5, 5);
v18 += 40;
++v17;
} while (v17 + 1 < 40);
++v16;
} while (v16 < 39);
}
if (currlevel == 16) {
v19 = 0;
do {
v20 = v19;
v21 = 40;
do {
pdungeon[0][v20] = dungeon[0][v20];
v20 += 40;
--v21;
} while (v21);
++v19;
} while (v19 < 40);
DRLG_LoadDiabQuads(0);
if(currlevel == 15) {
for(j = 0; j < DMAXY; j++) {
for(i = 0; i < DMAXX; i++) {
if(dungeon[i][j] == 98) {
Make_SetPC(i - 1, j - 1, 5, 5);
}
if(dungeon[i][j] == 107) {
Make_SetPC(i - 1, j - 1, 5, 5);
}
}
}
}
if(currlevel == 16) {
for(j = 0; j < DMAXY; j++) {
for(i = 0; i < DMAXX; i++) {
pdungeon[i][j] = dungeon[i][j];
}
}
DRLG_LoadDiabQuads(FALSE);
}
}
// 528A40: using guessed type int SP4x2;
@ -1484,104 +1437,48 @@ void DRLG_L4Subs()
void L4makeDungeon()
{
signed int v0; // ebx
signed int v1; // esi
char *v2; // edx
char v3; // cl
int v4; // eax
int v5; // eax
int v6; // ebx
char *v7; // esi
signed int v8; // edx
char v9; // cl
int v10; // eax
int v11; // eax
signed int v12; // ebx
signed int v13; // esi
char *v14; // edx
char v15; // cl
int v16; // eax
int v17; // eax
int v18; // ebx
char *v19; // esi
signed int v20; // edx
char v21; // cl
int v22; // eax
int v23; // eax
signed int v24; // [esp+Ch] [ebp-8h]
char *v25; // [esp+10h] [ebp-4h]
char *v26; // [esp+10h] [ebp-4h]
v0 = 0;
do {
v1 = 0;
v2 = (char *)dung + v0;
do {
v3 = *v2;
v2 += 20;
v4 = 160 * v1++;
v5 = v4 + 2 * v0;
L4dungeon[0][v5] = v3;
L4dungeon[0][v5 + 1] = v3;
L4dungeon[1][v5] = v3;
L4dungeon[1][v5 + 1] = v3;
} while (v1 < 20);
++v0;
} while (v0 < 20);
v6 = 0;
v25 = (char *)&dung[0][19];
v24 = 20;
do {
v7 = v25;
v8 = 0;
do {
v9 = *v7;
v7 += 20;
v10 = 160 * v8++;
v11 = v10 + 2 * v6;
L4dungeon[0][v11 + 40] = v9;
L4dungeon[0][v11 + 41] = v9;
L4dungeon[1][v11 + 40] = v9;
L4dungeon[1][v11 + 41] = v9;
} while (v8 < 20);
++v6;
--v25;
--v24;
} while (v24);
v12 = 0;
do {
v13 = 0;
v14 = (char *)&dung[19][v12];
do {
v15 = *v14;
v14 -= 20;
v16 = 160 * v13++;
v17 = v16 + 2 * v12;
L4dungeon[40][v17] = v15;
L4dungeon[40][v17 + 1] = v15;
L4dungeon[41][v17] = v15;
L4dungeon[41][v17 + 1] = v15;
} while (v13 < 20);
++v12;
} while (v12 < 20);
v18 = 0;
v26 = (char *)&dung[19][19];
do {
v19 = v26;
v20 = 0;
do {
v21 = *v19;
v19 -= 20;
v22 = 160 * v20++;
v23 = v22 + 2 * v18;
L4dungeon[40][v23 + 40] = v21;
L4dungeon[40][v23 + 41] = v21;
L4dungeon[41][v23 + 40] = v21;
L4dungeon[41][v23 + 41] = v21;
} while (v20 < 20);
++v18;
--v26;
} while ((signed int)v26 > (signed int)&dung[18][19]);
int i, j, k, l;
for(j = 0; j < 20; j++) {
for(i = 0; i < 20; i++) {
k = i << 1;
l = j << 1;
L4dungeon[k][l] = dung[i][j];
L4dungeon[k][l + 1] = dung[i][j];
L4dungeon[k + 1][l] = dung[i][j];
L4dungeon[k + 1][l + 1] = dung[i][j];
}
}
for(j = 0; j < 20; j++) {
for(i = 0; i < 20; i++) {
k = i << 1;
l = j << 1;
L4dungeon[k][l + 40] = dung[i][19 - j];
L4dungeon[k][l + 41] = dung[i][19 - j];
L4dungeon[k + 1][l + 40] = dung[i][19 - j];
L4dungeon[k + 1][l + 41] = dung[i][19 - j];
}
}
for(j = 0; j < 20; j++) {
for(i = 0; i < 20; i++) {
k = i << 1;
l = j << 1;
L4dungeon[k + 40][l] = dung[19 - i][j];
L4dungeon[k + 40][l + 1] = dung[19 - i][j];
L4dungeon[k + 41][l] = dung[19 - i][j];
L4dungeon[k + 41][l + 1] = dung[19 - i][j];
}
}
for(j = 0; j < 20; j++) {
for(i = 0; i < 20; i++) {
k = i << 1;
l = j << 1;
L4dungeon[k + 40][l + 40] = dung[19 - i][19 - j];
L4dungeon[k + 40][l + 41] = dung[19 - i][19 - j];
L4dungeon[k + 41][l + 40] = dung[19 - i][19 - j];
L4dungeon[k + 41][l + 41] = dung[19 - i][19 - j];
}
}
}
void uShape()
@ -2070,7 +1967,7 @@ void DRLG_L4Pass3()
lv = 30 - 1;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov esi, pMegaTiles
mov eax, lv
@ -2112,7 +2009,7 @@ void DRLG_L4Pass3()
xx = 16;
for (i = 0; i < DMAXX; i++) {
lv = (unsigned char)dungeon[i][j] - 1;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
if (lv >= 0) {
__asm {
mov esi, pMegaTiles

15
Source/dthread.cpp

@ -1,6 +1,5 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
#include "../3rdParty/Storm/Source/storm.h"
DEVILUTION_BEGIN_NAMESPACE
@ -130,7 +129,7 @@ unsigned int __stdcall dthread_handler(void *unused)
void dthread_cleanup()
{
char *error_buf;
TMegaPkt *tmp1, *tmp2;
TMegaPkt *tmp;
if (sghWorkToDoEvent == NULL) {
return;
@ -150,11 +149,9 @@ void dthread_cleanup()
sghWorkToDoEvent = NULL;
while (sgpInfoHead) {
tmp1 = sgpInfoHead->pNext;
tmp2 = sgpInfoHead;
sgpInfoHead = NULL;
mem_free_dbg(tmp2);
sgpInfoHead = tmp1;
tmp = sgpInfoHead->pNext;
MemFreeDbg(sgpInfoHead);
sgpInfoHead = tmp;
}
}

97
Source/dx.cpp

@ -1,6 +1,5 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
#include "../3rdParty/Storm/Source/storm.h"
DEVILUTION_BEGIN_NAMESPACE
@ -23,26 +22,26 @@ HMODULE ghDiabMod; // idb
void dx_init(HWND hWnd)
{
HWND v1; // esi
GUID *v2; // ecx
int v3; // eax
int v4; // eax
//int v5; // ecx
int v6; // edi
int v7; // eax
int v8; // eax
HWND hWnda; // [esp+1Ch] [ebp-4h]
v1 = hWnd;
hWnda = hWnd;
HRESULT hDDVal;
int winw, winh;
BOOL bSuccess;
GUID *lpGUID;
/// ASSERT: assert(! gpBuffer);
/// ASSERT: assert(! sgdwLockCount);
/// ASSERT: assert(! sgpBackBuf);
SetFocus(hWnd);
ShowWindow(v1, SW_SHOWNORMAL);
v2 = NULL;
if (gbEmulate)
v2 = (GUID *)DDCREATE_EMULATIONONLY;
v3 = dx_DirectDrawCreate(v2, &lpDDInterface, NULL);
if (v3)
ErrDlg(IDD_DIALOG1, v3, "C:\\Src\\Diablo\\Source\\dx.cpp", 149);
ShowWindow(hWnd, SW_SHOWNORMAL);
lpGUID = (GUID *)DDCREATE_EMULATIONONLY;
if(!gbEmulate) {
lpGUID = NULL;
}
hDDVal = dx_DirectDrawCreate(lpGUID, &lpDDInterface, NULL);
if(hDDVal != DD_OK) {
ErrDlg(IDD_DIALOG1, hDDVal, "C:\\Src\\Diablo\\Source\\dx.cpp", 149);
}
#ifdef COLORFIX
#ifdef __DDRAWI_INCLUDED__
@ -52,37 +51,57 @@ void dx_init(HWND hWnd)
#endif
#endif
fullscreen = 1;
#ifndef _DEBUG
fullscreen = TRUE;
#endif
if(!fullscreen) {
#ifdef __cplusplus
v4 = lpDDInterface->SetCooperativeLevel(v1, DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT | DDSCL_FULLSCREEN);
hDDVal = lpDDInterface->SetCooperativeLevel(hWnd, DDSCL_NORMAL | DDSCL_ALLOWREBOOT);
#else
v4 = lpDDInterface->lpVtbl->SetCooperativeLevel(lpDDInterface, v1, DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT | DDSCL_FULLSCREEN);
hDDVal = lpDDInterface->lpVtbl->SetCooperativeLevel(lpDDInterface, hWnd, DDSCL_NORMAL | DDSCL_ALLOWREBOOT);
#endif
if (v4 == DDERR_EXCLUSIVEMODEALREADYSET) {
MI_Dummy(0); // v5
} else if (v4) {
ErrDlg(IDD_DIALOG1, v4, "C:\\Src\\Diablo\\Source\\dx.cpp", 170);
}
if(hDDVal == DDERR_EXCLUSIVEMODEALREADYSET) {
TriggerBreak();
} else if(hDDVal != DD_OK) {
ErrDlg(IDD_DIALOG1, hDDVal, "C:\\Diablo\\Direct\\dx.cpp", 155);
}
SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
} else {
#ifdef __cplusplus
if (lpDDInterface->SetDisplayMode(SCREEN_WIDTH, SCREEN_HEIGHT, 8)) {
hDDVal = lpDDInterface->SetCooperativeLevel(hWnd, DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT | DDSCL_FULLSCREEN);
#else
if (lpDDInterface->lpVtbl->SetDisplayMode(lpDDInterface, SCREEN_WIDTH, SCREEN_HEIGHT, 8)) {
hDDVal = lpDDInterface->lpVtbl->SetCooperativeLevel(lpDDInterface, hWnd, DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT | DDSCL_FULLSCREEN);
#endif
v6 = GetSystemMetrics(SM_CXSCREEN);
v7 = GetSystemMetrics(SM_CYSCREEN);
if(hDDVal == DDERR_EXCLUSIVEMODEALREADYSET) {
TriggerBreak();
} else if(hDDVal != DD_OK) {
ErrDlg(IDD_DIALOG1, hDDVal, "C:\\Src\\Diablo\\Source\\dx.cpp", 170);
}
#ifdef __cplusplus
v8 = lpDDInterface->SetDisplayMode(v6, v7, 8);
hDDVal = lpDDInterface->SetDisplayMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP);
#else
v8 = lpDDInterface->lpVtbl->SetDisplayMode(lpDDInterface, v6, v7, 8);
hDDVal = lpDDInterface->lpVtbl->SetDisplayMode(lpDDInterface, SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP);
#endif
if (v8)
ErrDlg(IDD_DIALOG1, v8, "C:\\Src\\Diablo\\Source\\dx.cpp", 183);
if(hDDVal != DD_OK) {
winw = GetSystemMetrics(SM_CXSCREEN);
winh = GetSystemMetrics(SM_CYSCREEN);
#ifdef __cplusplus
hDDVal = lpDDInterface->SetDisplayMode(winw, winh, SCREEN_BPP);
#else
hDDVal = lpDDInterface->lpVtbl->SetDisplayMode(lpDDInterface, winw, winh, SCREEN_BPP);
#endif
if(hDDVal != DD_OK) {
ErrDlg(IDD_DIALOG1, hDDVal, "C:\\Src\\Diablo\\Source\\dx.cpp", 183);
}
}
}
dx_create_primary_surface();
palette_init();
GdiSetBatchLimit(1);
dx_create_back_buffer();
SDrawManualInitialize(hWnda, lpDDInterface, lpDDSPrimary, 0, 0, lpDDSBackBuf, lpDDPalette, 0);
bSuccess = SDrawManualInitialize(hWnd, lpDDInterface, lpDDSPrimary, NULL, NULL, lpDDSBackBuf, lpDDPalette, NULL);
/// ASSERT: assert(bSuccess);
}
// 52A549: using guessed type char gbEmulate;

5
Source/effects.cpp

@ -1,6 +1,5 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
#include "../3rdParty/Storm/Source/storm.h"
DEVILUTION_BEGIN_NAMESPACE

5
Source/encrypt.cpp

@ -1,6 +1,5 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
#include "../3rdParty/PKWare/pkware.h"
DEVILUTION_BEGIN_NAMESPACE

60
Source/engine.cpp

@ -1,10 +1,9 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
#include "../3rdParty/Storm/Source/storm.h"
DEVILUTION_BEGIN_NAMESPACE
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
#pragma warning(disable : 4731) // frame pointer register 'ebp' modified by inline assembly code
#endif
@ -33,7 +32,7 @@ void CelDrawDatOnly(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth)
if (!pRLEBytes)
return;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov esi, pRLEBytes
mov edi, pDecodeTo
@ -251,7 +250,7 @@ void CelDecDatLightOnly(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWi
if (!pRLEBytes)
return;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov eax, light_table_index
shl eax, 8
@ -406,7 +405,7 @@ void CelDecDatLightTrans(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nW
if (!pRLEBytes)
return;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov eax, light_table_index
shl eax, 8
@ -742,7 +741,7 @@ void CelDrawHdrLightRed(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, in
tbl = &pLightTbl[idx];
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov esi, src
mov edi, dst
@ -827,7 +826,7 @@ void Cel2DecDatOnly(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth)
if (!gpBuffer)
return;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov esi, pRLEBytes
mov edi, pDecodeTo
@ -1019,7 +1018,7 @@ void Cel2DecDatLightOnly(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nW
if (!gpBuffer)
return;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov eax, light_table_index
shl eax, 8
@ -1190,7 +1189,7 @@ void Cel2DecDatLightTrans(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int n
if (!gpBuffer)
return;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov eax, light_table_index
shl eax, 8
@ -1506,7 +1505,7 @@ void Cel2DrawHdrLightRed(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, i
tbl = &pLightTbl[idx];
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
w = 768 + nWidth;
__asm {
@ -1599,7 +1598,7 @@ void CelDecodeRect(BYTE *pBuff, int CelSkip, int hgt, int wdt, BYTE *pCelBuff, i
if (!pBuff)
return;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov ebx, pCelBuff
mov eax, nCel
@ -1720,7 +1719,7 @@ void CelDecodeClr(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth
if (!gpBuffer)
return;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov ebx, pCelBuff
mov eax, nCel
@ -1861,7 +1860,7 @@ void CelDrawHdrClrHL(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWi
if (!gpBuffer)
return;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov ebx, pCelBuff
mov eax, nCel
@ -2040,7 +2039,7 @@ void ENG_set_pixel(int sx, int sy, BYTE col)
dst = &gpBuffer[sx + PitchTbl[sy]];
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov edi, dst
cmp edi, gpBufEnd
@ -2072,7 +2071,7 @@ void engine_draw_pixel(int sx, int sy)
dst = &gpBuffer[sx + PitchTbl[sy]];
}
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov edi, dst
cmp edi, gpBufEnd
@ -2395,6 +2394,21 @@ int random(BYTE idx, int v)
return (GetRndSeed() >> 16) % v;
}
void engine_debug_trap(BOOL show_cursor)
{
/*
TMemBlock *pCurr;
sgMemCrit.Enter();
while(sgpMemBlock != NULL) {
pCurr = sgpMemBlock->pNext;
SMemFree(sgpMemBlock, "C:\\Diablo\\Direct\\ENGINE.CPP", 1970);
sgpMemBlock = pCurr;
}
sgMemCrit.Leave();
*/
}
unsigned char *DiabloAllocPtr(int dwBytes)
{
BYTE *buf;
@ -2552,7 +2566,7 @@ void Cl2DecodeFrm1(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int Cel
void Cl2DecDatFrm1(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth)
{
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
push ebx
push esi
@ -2736,7 +2750,7 @@ void Cl2DecodeFrm2(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWidt
void Cl2DecDatFrm2(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, char col)
{
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
push ebx
push esi
@ -2948,7 +2962,7 @@ void Cl2DecodeFrm3(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int Cel
void Cl2DecDatLightTbl1(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, BYTE *pTable)
{
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
push ebx
push esi
@ -3185,7 +3199,7 @@ void Cl2DecodeFrm4(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int Cel
void Cl2DecDatFrm4(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth)
{
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
push ebx
push esi
@ -3386,7 +3400,7 @@ void Cl2DecodeClrHL(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWid
void Cl2DecDatClrHL(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, char col)
{
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
push ebx
push esi
@ -3610,7 +3624,7 @@ void Cl2DecodeFrm5(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int Cel
void Cl2DecDatLightTbl2(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, BYTE *pTable)
{
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
push ebx
push esi

1
Source/engine.h

@ -40,6 +40,7 @@ int GetDirection(int x1, int y1, int x2, int y2);
void SetRndSeed(int s);
int GetRndSeed();
int random(BYTE idx, int v);
void engine_debug_trap(BOOL show_cursor);
unsigned char *DiabloAllocPtr(int dwBytes);
void mem_free_dbg(void *p);
BYTE *LoadFileInMem(char *pszName, int *pdwFileLen);

4
Source/error.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE

4
Source/fault.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE

4
Source/gamemenu.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE

16
Source/gendung.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE
@ -132,7 +130,7 @@ void MakeSpeedCels()
BOOL blood_flag;
WORD *pMap;
DWORD *pFrameTable;
#if (_MSC_VER < 800) || (_MSC_VER > 1200)
#ifndef USE_ASM
int k, l;
BYTE width, pix;
BYTE *src, *dst, *tbl;
@ -165,7 +163,7 @@ void MakeSpeedCels()
nlevel_frames = pFrameTable[0] & 0xFFFF;
for (i = 1; i < nlevel_frames; i++) {
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov ebx, pDungeonCels
mov eax, i
@ -190,7 +188,7 @@ void MakeSpeedCels()
blood_flag = TRUE;
if (level_frame_count[i]) {
if (level_frame_types[i] != 0x1000) {
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
j = level_frame_sizes[i];
__asm {
mov ebx, pDungeonCels
@ -223,7 +221,7 @@ void MakeSpeedCels()
}
#endif
} else {
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov ebx, pDungeonCels
mov eax, i
@ -324,7 +322,7 @@ void MakeSpeedCels()
lfs_adder = level_frame_sizes[i];
for (j = 1; j < blk_cnt; j++) {
SpeedFrameTbl[i][j] = frameidx;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov ebx, pDungeonCels
mov eax, currtile
@ -360,7 +358,7 @@ void MakeSpeedCels()
} else {
for (j = 1; j < blk_cnt; j++) {
SpeedFrameTbl[i][j] = frameidx;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov ebx, pDungeonCels
mov eax, currtile

26
Source/gmenu.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE
@ -74,23 +72,11 @@ void gmenu_print_text(int x, int y, char *pszStr)
void FreeGMenu()
{
void *ptr;
ptr = sgpLogo;
sgpLogo = NULL;
mem_free_dbg(ptr);
ptr = BigTGold_cel;
BigTGold_cel = NULL;
mem_free_dbg(ptr);
ptr = PentSpin_cel;
PentSpin_cel = NULL;
mem_free_dbg(ptr);
ptr = option_cel;
option_cel = NULL;
mem_free_dbg(ptr);
ptr = optbar_cel;
optbar_cel = NULL;
mem_free_dbg(ptr);
MemFreeDbg(sgpLogo);
MemFreeDbg(BigTGold_cel);
MemFreeDbg(PentSpin_cel);
MemFreeDbg(option_cel);
MemFreeDbg(optbar_cel);
}
void gmenu_init_menu()

4
Source/help.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE

8
Source/init.cpp

@ -1,6 +1,6 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
#include "../3rdParty/Storm/Source/storm.h"
#include "../DiabloUI/diabloui.h"
DEVILUTION_BEGIN_NAMESPACE
@ -45,7 +45,7 @@ void init_cleanup(BOOL show_cursor)
sound_cleanup();
NetClose();
dx_cleanup();
MI_Dummy(show_cursor);
engine_debug_trap(show_cursor);
StormDestroy();
if (show_cursor)

11
Source/interfac.cpp

@ -1,6 +1,5 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
#include "../3rdParty/Storm/Source/storm.h"
DEVILUTION_BEGIN_NAMESPACE
@ -246,11 +245,7 @@ void ShowProgress(unsigned int uMsg)
void FreeInterface()
{
void *ptr;
ptr = sgpBackCel;
sgpBackCel = NULL;
mem_free_dbg(ptr);
MemFreeDbg(sgpBackCel);
}
void InitCutscene(unsigned int uMsg)

11
Source/inv.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE
@ -94,10 +92,7 @@ int AP2x2Tbl[10] = { 8, 28, 6, 26, 4, 24, 2, 22, 0, 20 }; // weak
void FreeInvGFX()
{
void *invCels = pInvCels;
pInvCels = NULL;
mem_free_dbg(invCels);
MemFreeDbg(pInvCels);
}
void InitInv()
@ -122,7 +117,7 @@ void InvDrawSlotBack(int X, int Y, int W, int H)
dst = &gpBuffer[X + PitchTbl[Y]];
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov edi, dst
xor edx, edx

67
Source/items.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE
@ -1371,7 +1369,7 @@ void CreatePlrItems(int p)
GetPlrHandSeed(&plr[p].InvBody[INVLOC_HAND_RIGHT]);
#ifdef _DEBUG
if(!debug_mode_key_w) {
if (!debug_mode_key_w) {
#endif
SetPlrHandItem(&plr[p].HoldItem, IDI_WARRCLUB);
GetPlrHandSeed(&plr[p].HoldItem);
@ -1412,7 +1410,7 @@ void CreatePlrItems(int p)
GetPlrHandSeed(&plr[p].HoldItem);
#ifdef _DEBUG
if(!debug_mode_key_w) {
if (!debug_mode_key_w) {
#endif
plr[p].HoldItem._ivalue = 100;
plr[p].HoldItem._iCurs = ICURS_GOLD_SMALL;
@ -1424,7 +1422,7 @@ void CreatePlrItems(int p)
plr[p].HoldItem._ivalue = 5000;
plr[p].HoldItem._iCurs = ICURS_GOLD_LARGE;
plr[p]._pGold = plr[p].HoldItem._ivalue * 40;
for(i = 0; i < 40; i++) {
for (i = 0; i < 40; i++) {
GetPlrHandSeed(&plr[p].HoldItem);
plr[p].InvList[plr[p]._pNumInv++] = plr[p].HoldItem;
plr[p].InvGrid[i] = plr[p]._pNumInv;
@ -1569,24 +1567,20 @@ void GetSuperItemLoc(int x, int y, int *xx, int *yy)
void CalcItemValue(int i)
{
int v1; // ecx
int v2; // esi
BOOLEAN v3; // sf
int v4; // esi
v1 = i;
v2 = item[v1]._iVMult1 + item[v1]._iVMult2;
v3 = v2 < 0;
if (v2 > 0) {
v2 *= item[v1]._ivalue;
v3 = v2 < 0;
}
if (v3)
v2 = item[v1]._ivalue / v2;
v4 = item[v1]._iVAdd1 + item[v1]._iVAdd2 + v2;
if (v4 <= 0)
v4 = 1;
item[v1]._iIvalue = v4;
int v;
v = item[i]._iVMult1 + item[i]._iVMult2;
if (v > 0) {
v *= item[i]._ivalue;
}
if (v < 0) {
v = item[i]._ivalue / v;
}
v = item[i]._iVAdd1 + item[i]._iVAdd2 + v;
if (v <= 0) {
v = 1;
}
item[i]._iIvalue = v;
}
void GetBookSpell(int i, int lvl)
@ -3128,13 +3122,10 @@ void ProcessItems()
void FreeItemGFX()
{
int i; // esi
void *v1; // ecx
int i;
for (i = 0; i < 35; i++) {
v1 = (void *)itemanims[i];
itemanims[i] = 0;
mem_free_dbg(v1);
MemFreeDbg(itemanims[i]);
}
}
@ -3651,7 +3642,7 @@ void DrawULine(int y)
{
/// ASSERT: assert(gpBuffer);
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
int yy;
yy = PitchTbl[SStringY[y] + 198] + 26 + 64;
@ -4737,11 +4728,11 @@ BOOL GetItemRecord(int nSeed, WORD wCI, int nIndex)
dwTicks = GetTickCount();
for(i = 0; i < gnNumGetRecords; i++) {
if(dwTicks - itemrecord[i].dwTimestamp > 6000) {
for (i = 0; i < gnNumGetRecords; i++) {
if (dwTicks - itemrecord[i].dwTimestamp > 6000) {
NextItemRecord(i);
i--;
} else if(nSeed == itemrecord[i].nSeed && wCI == itemrecord[i].wCI && nIndex == itemrecord[i].nIndex) {
} else if (nSeed == itemrecord[i].nSeed && wCI == itemrecord[i].wCI && nIndex == itemrecord[i].nIndex) {
return FALSE;
}
}
@ -4753,7 +4744,7 @@ void NextItemRecord(int i)
{
gnNumGetRecords--;
if(gnNumGetRecords == 0) {
if (gnNumGetRecords == 0) {
return;
}
@ -4769,7 +4760,7 @@ void SetItemRecord(int nSeed, WORD wCI, int nIndex)
dwTicks = GetTickCount();
if(gnNumGetRecords == MAXITEMS) {
if (gnNumGetRecords == MAXITEMS) {
return;
}
@ -4787,11 +4778,11 @@ void PutItemRecord(int nSeed, WORD wCI, int nIndex)
dwTicks = GetTickCount();
for(i = 0; i < gnNumGetRecords; i++) {
if(dwTicks - itemrecord[i].dwTimestamp > 6000) {
for (i = 0; i < gnNumGetRecords; i++) {
if (dwTicks - itemrecord[i].dwTimestamp > 6000) {
NextItemRecord(i);
i--;
} else if(nSeed == itemrecord[i].nSeed && wCI == itemrecord[i].wCI && nIndex == itemrecord[i].nIndex) {
} else if (nSeed == itemrecord[i].nSeed && wCI == itemrecord[i].wCI && nIndex == itemrecord[i].nIndex) {
NextItemRecord(i);
break;
}

10
Source/lighting.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE
@ -755,11 +753,7 @@ void DoVision(int nXPos, int nYPos, int nRadius, BOOL doautomap, BOOL visible)
void FreeLightTable()
{
BYTE *ptr;
ptr = pLightTbl;
pLightTbl = NULL;
mem_free_dbg(ptr);
MemFreeDbg(pLightTbl);
}
void InitLightTable()

2
Source/list.h

@ -6,6 +6,8 @@
#include <stddef.h> // for offsetof
#include <typeinfo> // for typeid
#include "../3rdParty/Storm/Source/storm.h"
DEVILUTION_BEGIN_NAMESPACE
#ifdef _MSC_VER
#pragma warning (disable : 4291) // no matching operator delete found

4
Source/loadsave.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE

5
Source/logging.cpp

@ -1,6 +1,5 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
#include "../3rdParty/Storm/Source/storm.h"
DEVILUTION_BEGIN_NAMESPACE

6
Source/mainmenu.cpp

@ -1,6 +1,6 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
#include "../3rdParty/Storm/Source/storm.h"
#include "../DiabloUI/diabloui.h"
DEVILUTION_BEGIN_NAMESPACE

21
Source/minitext.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE
@ -43,24 +41,15 @@ int qscroll_spd_tbl[9] = { 2, 4, 6, 8, 0, -1, -2, -3, -4 };
void FreeQuestText()
{
void *ptr;
ptr = pMedTextCels;
pMedTextCels = NULL;
mem_free_dbg(ptr);
ptr = pTextBoxCels;
pTextBoxCels = NULL;
mem_free_dbg(ptr);
MemFreeDbg(pMedTextCels);
MemFreeDbg(pTextBoxCels);
}
void InitQuestText()
{
unsigned char *v0; // eax
pMedTextCels = LoadFileInMem("Data\\MedTextS.CEL", 0);
v0 = LoadFileInMem("Data\\TextBox.CEL", 0);
pTextBoxCels = LoadFileInMem("Data\\TextBox.CEL", 0);
qtextflag = FALSE;
pTextBoxCels = v0;
}
// 646D00: using guessed type char qtextflag;
@ -104,7 +93,7 @@ void PrintQTextChr(int sx, int sy, BYTE *pCelBuff, int nCel)
pStart = &gpBuffer[PitchTbl[209]];
pEnd = &gpBuffer[PitchTbl[469]];
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov ebx, pCelBuff
mov eax, nCel

4
Source/missiles.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE

10
Source/monster.cpp

@ -1,6 +1,5 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
#include "../3rdParty/Storm/Source/storm.h"
DEVILUTION_BEGIN_NAMESPACE
@ -5864,15 +5863,12 @@ void FreeMonsters()
{
int mtype;
int i, j;
void *ptr;
for (i = 0; i < nummtypes; i++) {
mtype = Monsters[i].mtype;
for (j = 0; j < 6; j++) {
if (animletter[j] != 's' || monsterdata[mtype].has_special) {
ptr = Monsters[i].Anims[j].CMem;
Monsters[i].Anims[j].CMem = NULL;
mem_free_dbg(ptr);
MemFreeDbg(Monsters[i].Anims[j].CMem);
}
}
}

5
Source/movie.cpp

@ -1,6 +1,5 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
#include "../3rdParty/Storm/Source/storm.h"
DEVILUTION_BEGIN_NAMESPACE

32
Source/mpqapi.cpp

@ -1,6 +1,5 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
#include "../3rdParty/Storm/Source/storm.h"
DEVILUTION_BEGIN_NAMESPACE
@ -100,8 +99,22 @@ void mpqapi_xor_buf(char *pbData)
} while (v3);
}
void mpqapi_update_multi_creation_time(DWORD dwChar)
void mpqapi_store_default_time(DWORD dwChar)
{
/*
DWORD idx;
char dst[160];
if(gbMaxPlayers == 1) {
return;
}
/// ASSERT: assert(dwChar < MAX_CHARACTERS);
idx = 16 * dwChar;
mpqapi_reg_load_modification_time(dst, sizeof(dst));
*(_DWORD *)&dst[idx + 4] = 0x78341348; // dwHighDateTime
mpqapi_reg_store_modification_time(dst, sizeof(dst));
*/
}
BOOLEAN mpqapi_reg_store_modification_time(char *pbData, DWORD dwLen)
@ -578,16 +591,9 @@ BOOLEAN mpqapi_parse_archive_header(_FILEHEADER *pHdr, int *pdwNextFileStart) //
void mpqapi_close_archive(const char *pszArchive, BOOL bFree, int dwChar) // CloseMPQ
{
_BLOCKENTRY *blockEntry;
_HASHENTRY *hashEntry;
if (bFree) {
blockEntry = sgpBlockTbl;
sgpBlockTbl = NULL;
mem_free_dbg(blockEntry);
hashEntry = sgpHashTbl;
sgpHashTbl = NULL;
mem_free_dbg(hashEntry);
MemFreeDbg(sgpBlockTbl);
MemFreeDbg(sgpHashTbl);
}
if (sghArchive != INVALID_HANDLE_VALUE) {
CloseHandle(sghArchive);

2
Source/mpqapi.h

@ -10,7 +10,7 @@ BOOL mpqapi_set_hidden(const char *pszArchive, BOOL hidden);
void mpqapi_store_creation_time(const char *pszArchive, int dwChar);
BOOL mpqapi_reg_load_modification_time(char *dst, int size);
void mpqapi_xor_buf(char *pbData);
void mpqapi_update_multi_creation_time(DWORD dwChar);
void mpqapi_store_default_time(DWORD dwChar);
BOOLEAN mpqapi_reg_store_modification_time(char *pbData, DWORD dwLen);
_BLOCKENTRY *j_mpqapi_remove_hash_entry(char *pszName);
void mpqapi_remove_hash_entry(const char *pszName);

14
Source/msg.cpp

@ -1,6 +1,6 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
#include "../3rdParty/Storm/Source/storm.h"
#include "../DiabloUI/diabloui.h"
DEVILUTION_BEGIN_NAMESPACE
@ -108,13 +108,9 @@ BOOL msg_wait_resync()
void msg_free_packets()
{
TMegaPkt *tmp;
while (sgpMegaPkt) {
sgpCurrPkt = sgpMegaPkt->pNext;
tmp = sgpMegaPkt;
sgpMegaPkt = NULL;
mem_free_dbg(tmp);
MemFreeDbg(sgpMegaPkt);
sgpMegaPkt = sgpCurrPkt;
}
}
@ -2236,7 +2232,7 @@ int On_SEND_PLRINFO(TCmdPlrInfoHdr *pCmd, int pnum)
if (gbBufferMsgs == 1)
msg_send_packet(pnum, pCmd, pCmd->wBytes + sizeof(*pCmd));
else
multi_player_joins(pnum, pCmd, pCmd->bCmd == CMD_ACK_PLRINFO);
recv_plrinfo(pnum, pCmd, pCmd->bCmd == CMD_ACK_PLRINFO);
return pCmd->wBytes + sizeof(*pCmd);
}

4
Source/msgcmd.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
#include "list.h"
DEVILUTION_BEGIN_NAMESPACE

179
Source/multi.cpp

@ -1,13 +1,16 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
#include "../3rdParty/Storm/Source/storm.h"
#include "../DiabloUI/diabloui.h"
DEVILUTION_BEGIN_NAMESPACE
BOOLEAN gbSomebodyWonGameKludge; // weak
#ifdef _DEBUG
DWORD gdwHistTicks;
#endif
TBuffer sgHiPriBuf;
char szPlayerDescript[128];
short sgwPackPlrOffsetTbl[MAX_PLRS];
WORD sgwPackPlrOffsetTbl[MAX_PLRS];
PkPlayerStruct netplr[MAX_PLRS];
BOOLEAN sgbPlayerTurnBitTbl[MAX_PLRS];
char sgbPlayerLeftGameTbl[MAX_PLRS];
@ -35,6 +38,40 @@ const int event_types[3] = {
EVENT_TYPE_PLAYER_MESSAGE
};
#ifdef _DEBUG
void __cdecl dumphist(const char *pszFmt, ...)
{
static FILE *sgpHistFile = NULL;
DWORD dwTicks;
va_list va;
va_start(va, pszFmt);
if(sgpHistFile == NULL) {
sgpHistFile = fopen("c:\\dumphist.txt", "wb");
if(sgpHistFile == NULL) {
return;
}
}
dwTicks = GetTickCount();
fprintf(sgpHistFile, "%4u.%02u ", (dwTicks - gdwHistTicks) / 1000, (dwTicks - gdwHistTicks) % 1000 / 10);
vfprintf(sgpHistFile, pszFmt, va);
fprintf(
sgpHistFile,
"\r\n (%d,%d)(%d,%d)(%d,%d)(%d,%d)\r\n",
plr[0].plractive,
player_state[0],
plr[1].plractive,
player_state[1],
plr[2].plractive,
player_state[2],
plr[3].plractive,
player_state[3]);
fflush(sgpHistFile);
}
#endif
void multi_msg_add(BYTE *a1, unsigned char a2)
{
if (a1) {
@ -724,6 +761,10 @@ BOOL NetInit(BOOL bSinglePlayer, BOOL *pfExitProgram)
if (!multi_init_multi(&ProgramData, &plrdata, &UiData, pfExitProgram))
return FALSE;
}
#ifdef _DEBUG
gdwHistTicks = GetTickCount();
dumphist("(%d) new game started", myplr);
#endif
sgbNetInited = TRUE;
sgbTimeout = FALSE;
delta_init();
@ -734,7 +775,7 @@ BOOL NetInit(BOOL bSinglePlayer, BOOL *pfExitProgram)
sync_init();
nthread_start(sgbPlayerTurnBitTbl[myplr]);
dthread_start();
dummy_nop_used_in_NetInit();
tmsg_start();
sgdwGameLoops = 0;
sgbSentThisCycle = 0;
gbDeltaSender = myplr;
@ -769,10 +810,6 @@ BOOL NetInit(BOOL bSinglePlayer, BOOL *pfExitProgram)
// 6796E4: using guessed type char gbDeltaSender;
// 6796E8: using guessed type int sgbNetInited;
void dummy_nop_used_in_NetInit()
{
}
void buffer_init(TBuffer *pBuf)
{
pBuf->dwNextWriteOffset = 0;
@ -928,68 +965,72 @@ BOOL multi_upgrade(int *pfExitProgram)
return result;
}
void multi_player_joins(int pnum, TCmdPlrInfoHdr *cmd, int a3)
{
int v3; // ebx
TCmdPlrInfoHdr *v4; // edi
short *v5; // esi
int v6; // esi
BOOLEAN v7; // zf
char *v8; // eax
int v9; // ST08_4
unsigned char *v10; // edx
int v11; // eax
int v12; // ecx
int v13; // eax
v3 = pnum;
v4 = cmd;
if (myplr != pnum) {
v5 = &sgwPackPlrOffsetTbl[pnum];
if (*v5 == cmd->wOffset || (*v5 = 0, !cmd->wOffset)) {
if (!a3 && !*v5) {
multi_send_pinfo(pnum, CMD_ACK_PLRINFO);
}
memcpy((char *)&netplr[v3] + (unsigned short)v4->wOffset, &v4[1], (unsigned short)v4->wBytes);
*v5 += v4->wBytes;
if (*v5 == 1266) {
*v5 = 0;
multi_player_left_msg(v3, 0);
v6 = v3;
plr[v3]._pGFXLoad = 0;
UnPackPlayer(&netplr[v3], v3, 1);
if (a3) {
++gbActivePlayers;
v7 = sgbPlayerTurnBitTbl[v3] == 0;
plr[v6].plractive = 1;
v8 = "Player '%s' (level %d) just joined the game";
if (v7)
v8 = "Player '%s' (level %d) is already in the game";
EventPlrMsg(v8, plr[v6]._pName, plr[v6]._pLevel);
LoadPlrGFX(v3, PFILE_STAND);
SyncInitPlr(v3);
if (plr[v6].plrlevel == currlevel) {
if (plr[v6]._pHitPoints >> 6 <= 0) {
plr[v6]._pgfxnum = 0;
LoadPlrGFX(v3, PFILE_DEATH);
v9 = plr[v6]._pDWidth;
v10 = plr[v6]._pDAnim[0];
plr[v6]._pmode = 8;
NewPlrAnim(v3, v10, plr[v6]._pDFrames, 1, v9);
v11 = plr[v6]._pAnimLen;
v12 = v11 - 1;
plr[v6]._pVar8 = 2 * v11;
v13 = plr[v6].WorldX;
plr[v6]._pAnimFrame = v12;
dFlags[v13][plr[v6].WorldY] |= DFLAG_DEAD_PLAYER;
} else {
StartStand(v3, 0);
}
}
}
}
void recv_plrinfo(int pnum, TCmdPlrInfoHdr *p, BOOL recv)
{
char *szEvent;
if(myplr == pnum) {
return;
}
/// ASSERT: assert((DWORD)pnum < MAX_PLRS);
if(sgwPackPlrOffsetTbl[pnum] != p->wOffset) {
sgwPackPlrOffsetTbl[pnum] = 0;
if(p->wOffset != 0) {
return;
}
}
if(!recv && sgwPackPlrOffsetTbl[pnum] == 0) {
multi_send_pinfo(pnum, CMD_ACK_PLRINFO);
}
memcpy((char *)&netplr[pnum] + p->wOffset, &p[1], p->wBytes); /* todo: cast? */
sgwPackPlrOffsetTbl[pnum] += p->wBytes;
if(sgwPackPlrOffsetTbl[pnum] != sizeof(*netplr)) {
return;
}
sgwPackPlrOffsetTbl[pnum] = 0;
multi_player_left_msg(pnum, 0);
plr[pnum]._pGFXLoad = 0;
UnPackPlayer(&netplr[pnum], pnum, 1);
if(!recv) {
#ifdef _DEBUG
dumphist("(%d) received all %d plrinfo", myplr, pnum);
#endif
return;
}
plr[pnum].plractive = 1;
gbActivePlayers++;
if(sgbPlayerTurnBitTbl[pnum] != 0) {
szEvent = "Player '%s' (level %d) just joined the game";
} else {
szEvent = "Player '%s' (level %d) is already in the game";
}
EventPlrMsg(szEvent, plr[pnum]._pName, plr[pnum]._pLevel);
LoadPlrGFX(pnum, PFILE_STAND);
SyncInitPlr(pnum);
if(plr[pnum].plrlevel == currlevel) {
if(plr[pnum]._pHitPoints >> 6 > 0) {
StartStand(pnum, 0);
} else {
plr[pnum]._pgfxnum = 0;
LoadPlrGFX(pnum, PFILE_DEATH);
plr[pnum]._pmode = PM_DEATH;
NewPlrAnim(pnum, plr[pnum]._pDAnim[0], plr[pnum]._pDFrames, 1, plr[pnum]._pDWidth);
plr[pnum]._pAnimFrame = plr[pnum]._pAnimLen - 1;
plr[pnum]._pVar8 = 2 * plr[pnum]._pAnimLen;
dFlags[plr[pnum].WorldX][plr[pnum].WorldY] |= DFLAG_DEAD_PLAYER;
}
}
#ifdef _DEBUG
dumphist("(%d) making %d active -- recv_plrinfo", myplr, pnum);
#endif
}
DEVILUTION_END_NAMESPACE

8
Source/multi.h

@ -4,7 +4,7 @@
extern BOOLEAN gbSomebodyWonGameKludge; // weak
extern char szPlayerDescript[128];
extern short sgwPackPlrOffsetTbl[MAX_PLRS];
extern WORD sgwPackPlrOffsetTbl[MAX_PLRS];
extern PkPlayerStruct netplr[MAX_PLRS];
extern BOOL gbShouldValidatePackage;
extern BYTE gbActivePlayers;
@ -15,6 +15,9 @@ extern char szPlayerName[128];
extern BYTE gbDeltaSender; // weak
extern int player_state[MAX_PLRS];
#ifdef _DEBUG
void __cdecl dumphist(const char *pszFmt, ...);
#endif
void multi_msg_add(BYTE *a1, unsigned char a2);
void NetSendLoPri(BYTE *pbMsg, BYTE bLen);
void multi_copy_packet(TBuffer *a1, void *packet, BYTE size);
@ -43,7 +46,6 @@ void NetClose();
char multi_event_handler(int a1);
void __stdcall multi_handle_events(_SNETEVENT *pEvt);
BOOL NetInit(BOOL bSinglePlayer, BOOL *pfExitProgram);
void dummy_nop_used_in_NetInit();
void buffer_init(TBuffer *pBuf);
void multi_send_pinfo(int pnum, char cmd);
int InitNewSeed(int newseed);
@ -51,7 +53,7 @@ void SetupLocalCoords();
BOOL multi_init_single(_SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info);
BOOL multi_init_multi(_SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info, int *pfExitProgram);
BOOL multi_upgrade(int *pfExitProgram);
void multi_player_joins(int pnum, TCmdPlrInfoHdr *cmd, int a3);
void recv_plrinfo(int pnum, TCmdPlrInfoHdr *p, BOOL recv);
/* rdata */

5
Source/nthread.cpp

@ -1,6 +1,5 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
#include "../3rdParty/Storm/Source/storm.h"
DEVILUTION_BEGIN_NAMESPACE

2432
Source/objects.cpp

File diff suppressed because it is too large Load Diff

34
Source/objects.h

@ -54,17 +54,23 @@ void AddL3Door(int i, int x, int y, int ot);
void AddSarc(int i);
void AddFlameTrap(int i);
void AddFlameLvr(int i);
void AddTrap(int i);
void AddTrap(int i, int t);
void AddObjLight(int i, int r);
void AddBarrel(int i);
void AddBarrel(int i, int t);
void AddShrine(int i);
void AddBookcase(int i);
void AddPurifyingFountain(int i);
void AddArmorStand(int i);
void AddGoatShrine(int i);
void AddCauldron(int i);
void AddMurkyFountain(int i);
void AddTearFountain(int i);
void AddDecap(int i);
void AddVilebook(int i);
void AddMagicCircle(int i);
void AddBrnCross(int i);
void AddBookstand(int i);
void AddBloodFtn(int i);
void AddPedistal(int i);
void AddStoryBook(int i);
void AddWeaponRack(int i);
@ -90,12 +96,12 @@ void ObjL1Special(int x1, int y1, int x2, int y2);
void ObjL2Special(int x1, int y1, int x2, int y2);
void DoorSet(int oi, int dx, int dy);
void RedoPlayerVision();
void OperateL1RDoor(int pnum, int oi, unsigned char sendflag);
void OperateL1LDoor(int pnum, int oi, unsigned char sendflag);
void OperateL2RDoor(int pnum, int oi, unsigned char sendflag);
void OperateL2LDoor(int pnum, int oi, unsigned char sendflag);
void OperateL3RDoor(int pnum, int oi, unsigned char sendflag);
void OperateL3LDoor(int pnum, int oi, unsigned char sendflag);
void OperateL1RDoor(int pnum, int oi, BOOL sendflag);
void OperateL1LDoor(int pnum, int oi, BOOL sendflag);
void OperateL2RDoor(int pnum, int oi, BOOL sendflag);
void OperateL2LDoor(int pnum, int oi, BOOL sendflag);
void OperateL3RDoor(int pnum, int oi, BOOL sendflag);
void OperateL3LDoor(int pnum, int oi, BOOL sendflag);
void MonstCheckDoors(int m);
void ObjChangeMap(int x1, int y1, int x2, int y2);
void ObjChangeMapResync(int x1, int y1, int x2, int y2);
@ -104,12 +110,12 @@ void OperateLever(int pnum, int i);
void OperateBook(int pnum, int i);
void OperateBookLever(int pnum, int i);
void OperateSChambBk(int pnum, int i);
void OperateChest(int pnum, int i, unsigned char sendmsg);
void OperateChest(int pnum, int i, BOOL sendmsg);
void OperateMushPatch(int pnum, int i);
void OperateInnSignChest(int pnum, int i);
void OperateSlainHero(int pnum, int i, unsigned char sendmsg);
void OperateSlainHero(int pnum, int i, BOOL sendmsg);
void OperateTrapLvr(int i);
void OperateSarc(int pnum, int i, unsigned char sendmsg);
void OperateSarc(int pnum, int i, BOOL sendmsg);
void OperateL2Door(int pnum, int i, unsigned char sendflag);
void OperateL3Door(int pnum, int i, unsigned char sendflag);
void OperatePedistal(int pnum, int i);
@ -118,12 +124,12 @@ int ItemMiscIdIdx(int imiscid);
void OperateShrine(int pnum, int i, int sType);
void OperateSkelBook(int pnum, int i, BOOL sendmsg);
void OperateBookCase(int pnum, int i, BOOL sendmsg);
void OperateDecap(int pnum, int i, unsigned char sendmsg);
void OperateDecap(int pnum, int i, BOOL sendmsg);
void OperateArmorStand(int pnum, int i, BOOL sendmsg);
int FindValidShrine(int i);
void OperateGoatShrine(int pnum, int i, int sType);
void OperateCauldron(int pnum, int i, int sType);
BOOLEAN OperateFountains(int pnum, int i);
BOOL OperateFountains(int pnum, int i);
void OperateWeaponRack(int pnum, int i, BOOL sendmsg);
void OperateStoryBook(int pnum, int i);
void OperateLazStand(int pnum, int i);
@ -133,7 +139,7 @@ void SyncOpL2Door(int pnum, int cmd, int i);
void SyncOpL3Door(int pnum, int cmd, int i);
void SyncOpObject(int pnum, int cmd, int i);
void BreakCrux(int i);
void BreakBarrel(int pnum, int i, int dam, unsigned char forcebreak, int sendmsg);
void BreakBarrel(int pnum, int i, int dam, BOOL forcebreak, int sendmsg);
void BreakObject(int pnum, int oi);
void SyncBreakObj(int pnum, int oi);
void SyncL1Doors(int i);

5
Source/pack.cpp

@ -1,6 +1,5 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
#include "../3rdParty/Storm/Source/storm.h"
DEVILUTION_BEGIN_NAMESPACE

6
Source/palette.cpp

@ -1,5 +1,5 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
#include "../3rdParty/Storm/Source/storm.h"
DEVILUTION_BEGIN_NAMESPACE
@ -39,8 +39,10 @@ void palette_init()
#else
error_code = lpDDSPrimary->lpVtbl->SetPalette(lpDDSPrimary, lpDDPalette);
#endif
#ifndef RGBMODE
if (error_code)
ErrDlg(IDD_DIALOG8, error_code, "C:\\Src\\Diablo\\Source\\PALETTE.CPP", 146);
#endif
}
void LoadGamma()

4
Source/path.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE

8
Source/pfile.cpp

@ -1,6 +1,6 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
#include "../3rdParty/Storm/Source/storm.h"
#include "../DiabloUI/diabloui.h"
DEVILUTION_BEGIN_NAMESPACE
@ -106,7 +106,7 @@ BOOL pfile_open_archive(BOOL a1, unsigned int save_num)
return TRUE;
if (a1 && gbMaxPlayers > 1)
mpqapi_update_multi_creation_time(save_num);
mpqapi_store_default_time(save_num);
return FALSE;
}

43
Source/player.cpp

@ -1,6 +1,5 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
#include "../3rdParty/Storm/Source/storm.h"
DEVILUTION_BEGIN_NAMESPACE
@ -355,39 +354,19 @@ DWORD GetPlrGFXSize(char *szCel)
void FreePlayerGFX(int pnum)
{
void *ptr;
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal("FreePlayerGFX: illegal player %d", pnum);
}
ptr = plr[pnum]._pNData;
plr[pnum]._pNData = NULL;
mem_free_dbg(ptr);
ptr = plr[pnum]._pWData;
plr[pnum]._pWData = NULL;
mem_free_dbg(ptr);
ptr = plr[pnum]._pAData;
plr[pnum]._pAData = NULL;
mem_free_dbg(ptr);
ptr = plr[pnum]._pHData;
plr[pnum]._pHData = NULL;
mem_free_dbg(ptr);
ptr = plr[pnum]._pLData;
plr[pnum]._pLData = NULL;
mem_free_dbg(ptr);
ptr = plr[pnum]._pFData;
plr[pnum]._pFData = NULL;
mem_free_dbg(ptr);
ptr = plr[pnum]._pTData;
plr[pnum]._pTData = NULL;
mem_free_dbg(ptr);
ptr = plr[pnum]._pDData;
plr[pnum]._pDData = NULL;
mem_free_dbg(ptr);
ptr = plr[pnum]._pBData;
plr[pnum]._pBData = NULL;
mem_free_dbg(ptr);
MemFreeDbg(plr[pnum]._pNData);
MemFreeDbg(plr[pnum]._pWData);
MemFreeDbg(plr[pnum]._pAData);
MemFreeDbg(plr[pnum]._pHData);
MemFreeDbg(plr[pnum]._pLData);
MemFreeDbg(plr[pnum]._pFData);
MemFreeDbg(plr[pnum]._pTData);
MemFreeDbg(plr[pnum]._pDData);
MemFreeDbg(plr[pnum]._pBData);
plr[pnum]._pGFXLoad = 0;
}

4
Source/plrmsg.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE

4
Source/portal.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE

4
Source/quests.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE

7
Source/render.cpp

@ -1,8 +1,7 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE
#include "_asm.cpp"
int WorldBoolFlag = 0;
@ -115,7 +114,7 @@ int WorldTbl17_2[17] = { 0, 32, 60, 88, 112, 136, 156, 176, 192, 208, 220, 232,
|/
*/
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
#include "_render.cpp"
#else
void drawTopArchesUpperScreen(BYTE *pBuff)

4
Source/restrict.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE

23
Source/scrollrt.cpp

@ -1,6 +1,5 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
#include "../3rdParty/Storm/Source/storm.h"
DEVILUTION_BEGIN_NAMESPACE
@ -2130,7 +2129,7 @@ void DrawZoom(int x, int y)
/// ASSERT: assert(gpBuffer);
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov esi, gpBuffer
mov edx, nDstOff
@ -2195,7 +2194,7 @@ void ClearScreenBuffer()
/// ASSERT: assert(gpBuffer);
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov edi, gpBuffer
add edi, SCREENXY(0, 0)
@ -2636,16 +2635,16 @@ void DoBlitScreen(DWORD dwX, DWORD dwY, DWORD dwWdt, DWORD dwHgt)
}
} else {
nSrcOff = SCREENXY(dwX, dwY);
nDstOff = dwX + dwY * DDS_desc.lPitch;
nDstOff = dwX * (SCREEN_BPP / 8) + dwY * DDS_desc.lPitch;
nSrcWdt = BUFFER_WIDTH - dwWdt;
nDstWdt = DDS_desc.lPitch - dwWdt;
nDstWdt = DDS_desc.lPitch - dwWdt * (SCREEN_BPP / 8);
dwWdt >>= 2;
lock_buf(6);
/// ASSERT: assert(gpBuffer);
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#if defined(USE_ASM) && !defined(RGBMODE)
__asm {
mov esi, gpBuffer
mov edi, DDS_desc.lpSurface
@ -2671,7 +2670,15 @@ void DoBlitScreen(DWORD dwX, DWORD dwY, DWORD dwWdt, DWORD dwHgt)
for (hgt = 0; hgt < dwHgt; hgt++, src += nSrcWdt, dst += nDstWdt) {
for (wdt = 0; wdt < 4 * dwWdt; wdt++) {
#ifndef RGBMODE
*dst++ = *src++;
#else
PALETTEENTRY pal = system_palette[*src++];
dst[0] = pal.peBlue;
dst[1] = pal.peGreen;
dst[2] = pal.peRed;
dst += 4;
#endif
}
}
#endif

4
Source/setmaps.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE

4
Source/sha.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE

5
Source/sound.cpp

@ -1,6 +1,5 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
#include "../3rdParty/Storm/Source/storm.h"
DEVILUTION_BEGIN_NAMESPACE

4
Source/spells.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE

424
Source/stores.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE
@ -20,7 +18,7 @@ int InStoreFlag; // idb
ItemStruct storehold[48];
int gossipstart; // weak
ItemStruct witchitem[20];
int stextscrl;
BOOL stextscrl;
int numpremium; // idb
ItemStruct healitem[20];
ItemStruct golditem;
@ -78,7 +76,7 @@ char *talkname[9] = {
void InitStores()
{
int i; // eax
int i;
pSTextBoxCels = LoadFileInMem("Data\\TextBox2.CEL", 0);
pCelBuff = LoadFileInMem("Data\\PentSpn2.CEL", 0);
@ -87,7 +85,7 @@ void InitStores()
stextflag = STORE_NONE;
InStoreFlag = 1;
stextsize = 0;
stextscrl = 0;
stextscrl = FALSE;
numpremium = 0;
premiumlevel = 1;
@ -97,16 +95,10 @@ void InitStores()
boyitem._itype = -1;
boylevel = 0;
}
// 69FB38: using guessed type int talker;
// 6A09E0: using guessed type char stextsize;
// 6A6BB8: using guessed type int stextscrl;
// 6A8A3C: using guessed type int boylevel;
// 6AA705: using guessed type char stextflag;
void SetupTownStores()
{
int i; // eax
int l; // esi
int i, l;
SetRndSeed(glSeedTbl[currlevel] * GetTickCount());
if (gbMaxPlayers == 1) {
@ -130,21 +122,12 @@ void SetupTownStores()
SpawnBoy(plr[myplr]._pLevel);
SpawnPremium(plr[myplr]._pLevel);
}
// 679660: using guessed type char gbMaxPlayers;
void FreeStoreMem()
{
void *p;
p = pSTextBoxCels;
pSTextBoxCels = NULL;
mem_free_dbg(p);
p = pCelBuff;
pCelBuff = NULL;
mem_free_dbg(p);
p = pSTextSlidCels;
pSTextSlidCels = NULL;
mem_free_dbg(p);
MemFreeDbg(pSTextBoxCels);
MemFreeDbg(pCelBuff);
MemFreeDbg(pSTextSlidCels);
}
void DrawSTextBack()
@ -275,7 +258,7 @@ void DrawSLine(int y)
/// ASSERT: assert(gpBuffer);
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov esi, gpBuffer
mov edi, esi
@ -307,46 +290,32 @@ void DrawSLine(int y)
void DrawSArrows(int y1, int y2)
{
int *v2; // ebp
int v3; // ebx
int v4; // edi
int v5; // esi
int v6; // eax
int v7; // eax
v2 = &SStringY[y2];
v3 = y1;
v4 = SStringY[y1] + 204;
v5 = *v2 + 204;
if (stextscrlubtn == -1)
CelDecodeOnly(665, v4, (BYTE *)pSTextSlidCels, 10, 12);
int yd1, yd2, yd3;
yd1 = SStringY[y1] + 204;
yd2 = SStringY[y2] + 204;
if (stextscrlubtn != -1)
CelDecodeOnly(665, yd1, (BYTE *)pSTextSlidCels, 12, 12);
else
CelDecodeOnly(665, v4, (BYTE *)pSTextSlidCels, 12, 12);
if (stextscrldbtn == -1)
CelDecodeOnly(665, v5, (BYTE *)pSTextSlidCels, 9, 12);
CelDecodeOnly(665, yd1, (BYTE *)pSTextSlidCels, 10, 12);
if (stextscrldbtn != -1)
CelDecodeOnly(665, yd2, (BYTE *)pSTextSlidCels, 11, 12);
else
CelDecodeOnly(665, v5, (BYTE *)pSTextSlidCels, 11, 12);
while (1) {
v4 += 12;
if (v4 >= v5)
break;
CelDecodeOnly(665, v4, (BYTE *)pSTextSlidCels, 14, 12);
CelDecodeOnly(665, yd2, (BYTE *)pSTextSlidCels, 9, 12);
yd1 += 12;
for (yd3 = yd1; yd3 < yd2; yd3 += 12) {
CelDecodeOnly(665, yd3, (BYTE *)pSTextSlidCels, 14, 12);
}
v6 = stextsel;
if (stextsel == 22)
v6 = stextlhold;
if (storenumh <= 1)
v7 = 0;
yd3 = stextlhold;
else
yd3 = stextsel;
if (storenumh > 1)
yd3 = 1000 * (stextsval + ((yd3 - stextup) >> 2)) / (storenumh - 1) * (SStringY[y2] - SStringY[y1] - 24) / 1000;
else
v7 = (*v2 - SStringY[v3] - 24) * (1000 * (stextsval + ((v6 - stextup) >> 2)) / (storenumh - 1)) / 1000;
CelDecodeOnly(665, SStringY[v3 + 1] + v7 + 204, (BYTE *)pSTextSlidCels, 13, 12);
yd3 = 0;
CelDecodeOnly(665, SStringY[y1 + 1] + 204 + yd3, (BYTE *)pSTextSlidCels, 13, 12);
}
// 69F108: using guessed type int stextup;
// 69F10C: using guessed type int storenumh;
// 69F110: using guessed type int stextlhold;
// 6A8A28: using guessed type int stextsel;
// 6A8A2C: using guessed type char stextscrldbtn;
// 6AA704: using guessed type char stextscrlubtn;
void DrawSTextHelp()
{
@ -477,7 +446,7 @@ void StoreAutoPlace()
void S_StartSmith()
{
stextsize = 0;
stextscrl = 0;
stextscrl = FALSE;
AddSText(0, 1, 1u, "Welcome to the", COL_GOLD, 0);
AddSText(0, 3, 1u, "Blacksmith's shop", COL_GOLD, 0);
AddSText(0, 7, 1u, "Would you like to:", COL_GOLD, 0);
@ -492,7 +461,6 @@ void S_StartSmith()
}
// 69F10C: using guessed type int storenumh;
// 6A09E0: using guessed type char stextsize;
// 6A6BB8: using guessed type int stextscrl;
void S_ScrollSBuy(int idx)
{
@ -535,78 +503,62 @@ void S_ScrollSBuy(int idx)
void PrintStoreItem(ItemStruct *x, int l, char iclr)
{
ItemStruct *v3; // esi
char v5; // cl
char v6; // cl
int v7; // eax
char v8; // al
unsigned char v9; // al
char v10; // al
int v11; // edi
char sstr[128]; // [esp+Ch] [ebp-84h]
int y; // [esp+8Ch] [ebp-4h]
sstr[0] = 0;
v3 = x;
y = l;
char sstr[128];
sstr[0] = '\0';
if (x->_iIdentified) {
if (x->_iMagical != ITEM_QUALITY_UNIQUE) {
v5 = x->_iPrePower;
if (v5 != -1) {
PrintItemPower(v5, v3);
if (x->_iPrePower != -1) {
PrintItemPower(x->_iPrePower, x);
strcat(sstr, tempstr);
}
}
v6 = v3->_iSufPower;
if (v6 != -1) {
PrintItemPower(v6, v3);
if (x->_iSufPower != -1) {
PrintItemPower(x->_iSufPower, x);
if (sstr[0])
strcat(sstr, ", ");
strcat(sstr, tempstr);
}
}
if (v3->_iMiscId == IMISC_STAFF && v3->_iMaxCharges) {
sprintf(tempstr, "Charges: %i/%i", v3->_iCharges, v3->_iMaxCharges);
if (x->_iMiscId == IMISC_STAFF && x->_iMaxCharges) {
sprintf(tempstr, "Charges: %i/%i", x->_iCharges, x->_iMaxCharges);
if (sstr[0])
strcat(sstr, ", ");
strcat(sstr, tempstr);
}
if (sstr[0])
AddSText(40, y++, 0, sstr, iclr, 0);
sstr[0] = 0;
if (v3->_iClass == ICLASS_WEAPON)
sprintf(sstr, "Damage: %i-%i ", v3->_iMinDam, v3->_iMaxDam);
if (v3->_iClass == ICLASS_ARMOR)
sprintf(sstr, "Armor: %i ", v3->_iAC);
v7 = v3->_iMaxDur;
if (v7 != 255 && v7) {
sprintf(tempstr, "Dur: %i/%i, ", v3->_iDurability, v3->_iMaxDur);
if (sstr[0]) {
AddSText(40, l, 0, sstr, iclr, 0);
l++;
}
sstr[0] = '\0';
if (x->_iClass == ICLASS_WEAPON)
sprintf(sstr, "Damage: %i-%i ", x->_iMinDam, x->_iMaxDam);
if (x->_iClass == ICLASS_ARMOR)
sprintf(sstr, "Armor: %i ", x->_iAC);
if (x->_iMaxDur != 255 && x->_iMaxDur) {
sprintf(tempstr, "Dur: %i/%i, ", x->_iDurability, x->_iMaxDur);
strcat(sstr, tempstr);
} else {
strcat(sstr, "Indestructible, ");
}
if (!v3->_itype)
sstr[0] = 0;
if (v3->_iMinStr + (unsigned char)v3->_iMinMag + v3->_iMinDex) {
if (!x->_itype)
sstr[0] = '\0';
if (!(x->_iMinStr + x->_iMinMag + x->_iMinDex)) {
strcat(sstr, "No required attributes");
} else {
strcpy(tempstr, "Required:");
v8 = v3->_iMinStr;
if (v8)
sprintf(tempstr, "%s %i Str", tempstr, v8);
v9 = v3->_iMinMag;
if (v9)
sprintf(tempstr, "%s %i Mag", tempstr, v9);
v10 = v3->_iMinDex;
if (v10)
sprintf(tempstr, "%s %i Dex", tempstr, v10);
if (x->_iMinStr)
sprintf(tempstr, "%s %i Str", tempstr, x->_iMinStr);
if (x->_iMinMag)
sprintf(tempstr, "%s %i Mag", tempstr, x->_iMinMag);
if (x->_iMinDex)
sprintf(tempstr, "%s %i Dex", tempstr, x->_iMinDex);
strcat(sstr, tempstr);
} else {
strcat(sstr, "No required attributes");
}
v11 = y;
AddSText(40, y, 0, sstr, iclr, 0);
if (v3->_iMagical == ITEM_QUALITY_UNIQUE) {
if (v3->_iIdentified)
AddSText(40, v11 + 1, 0, "Unique Item", iclr, 0);
AddSText(40, l, 0, sstr, iclr, 0);
if (x->_iMagical == ITEM_QUALITY_UNIQUE) {
if (x->_iIdentified)
AddSText(40, l + 1, 0, "Unique Item", iclr, 0);
}
}
@ -615,7 +567,7 @@ void S_StartSBuy()
int i;
stextsize = 1;
stextscrl = 1;
stextscrl = TRUE;
stextsval = 0;
sprintf(tempstr, "I have these items for sale : Your gold : %i", plr[myplr]._pGold);
AddSText(0, 1, 1, tempstr, COL_GOLD, 0);
@ -634,7 +586,6 @@ void S_StartSBuy()
// 69F10C: using guessed type int storenumh;
// 6A09E0: using guessed type char stextsize;
// 6A09E4: using guessed type int stextsmax;
// 6A6BB8: using guessed type int stextscrl;
void S_ScrollSPBuy(int idx)
{
@ -704,7 +655,7 @@ BOOL S_StartSPBuy()
}
stextsize = 1;
stextscrl = 1;
stextscrl = TRUE;
stextsval = 0;
sprintf(tempstr, "I have these premium items for sale : Your gold : %i", plr[myplr]._pGold);
@ -726,7 +677,6 @@ BOOL S_StartSPBuy()
// 69FB38: using guessed type int talker;
// 6A09E0: using guessed type char stextsize;
// 6A09E4: using guessed type int stextsmax;
// 6A6BB8: using guessed type int stextscrl;
// 6A8A28: using guessed type int stextsel;
BOOL SmithSellOk(int i)
@ -814,7 +764,7 @@ void S_StartSSell()
}
if (!sellok) {
stextscrl = 0;
stextscrl = FALSE;
sprintf(tempstr, "You have nothing I want. Your gold : %i", plr[myplr]._pGold);
AddSText(0, 1, 1, tempstr, COL_GOLD, 0);
AddSLine(3);
@ -822,7 +772,7 @@ void S_StartSSell()
AddSText(0, 22, 1, "Back", COL_WHITE, 1);
OffsetSTextY(22, 6);
} else {
stextscrl = 1;
stextscrl = TRUE;
stextsval = 0;
stextsmax = plr[myplr]._pNumInv;
sprintf(tempstr, "Which item is for sale? Your gold : %i", plr[myplr]._pGold);
@ -837,7 +787,6 @@ void S_StartSSell()
// 69F10C: using guessed type int storenumh;
// 6A09E0: using guessed type char stextsize;
// 6A09E4: using guessed type int stextsmax;
// 6A6BB8: using guessed type int stextscrl;
BOOL SmithRepairOk(int i)
{
@ -857,96 +806,58 @@ BOOL SmithRepairOk(int i)
void S_StartSRepair()
{
int v0; // ebp
int *v1; // eax
int v2; // esi
int v3; // eax
int v4; // eax
int v5; // eax
int v6; // eax
int v7; // edi
//int v8; // eax
int v9; // esi
int v10; // eax
int v11; // [esp-4h] [ebp-1Ch]
signed int v12; // [esp+10h] [ebp-8h]
int v13; // [esp+14h] [ebp-4h]
v0 = 0;
BOOL repairok;
int i;
stextsize = 1;
v12 = 0;
repairok = FALSE;
storenumh = 0;
v1 = &storehold[0]._itype;
do {
*v1 = -1;
v1 += 92;
} while ((signed int)v1 < (signed int)&storehold[48]._itype);
v2 = myplr;
v3 = myplr;
if (plr[myplr].InvBody[INVLOC_HEAD]._itype != -1 && plr[v3].InvBody[INVLOC_HEAD]._iDurability != plr[v3].InvBody[INVLOC_HEAD]._iMaxDur) {
v12 = 1;
AddStoreHoldRepair(plr[v3].InvBody, -1);
v2 = myplr;
}
v4 = v2;
if (plr[v2].InvBody[INVLOC_CHEST]._itype != -1 && plr[v4].InvBody[INVLOC_CHEST]._iDurability != plr[v4].InvBody[INVLOC_CHEST]._iMaxDur) {
v12 = 1;
AddStoreHoldRepair(&plr[v4].InvBody[INVLOC_CHEST], -2);
v2 = myplr;
}
v5 = v2;
if (plr[v2].InvBody[INVLOC_HAND_LEFT]._itype != -1 && plr[v5].InvBody[INVLOC_HAND_LEFT]._iDurability != plr[v5].InvBody[INVLOC_HAND_LEFT]._iMaxDur) {
v12 = 1;
AddStoreHoldRepair(&plr[v5].InvBody[INVLOC_HAND_LEFT], -3);
v2 = myplr;
}
v6 = v2;
if (plr[v2].InvBody[INVLOC_HAND_RIGHT]._itype != -1 && plr[v6].InvBody[INVLOC_HAND_RIGHT]._iDurability != plr[v6].InvBody[INVLOC_HAND_RIGHT]._iMaxDur) {
v12 = 1;
AddStoreHoldRepair(&plr[v6].InvBody[INVLOC_HAND_RIGHT], -4);
v2 = myplr;
}
v7 = 21720 * v2;
if (plr[v2]._pNumInv > 0) {
v13 = 0;
do {
//_LOBYTE(v8) = SmithRepairOk(v0);
if (SmithRepairOk(v0)) {
v12 = 1;
AddStoreHoldRepair((ItemStruct *)((char *)&plr[0].InvList[v13] + v7), v0);
v2 = myplr;
}
++v13;
v7 = 21720 * v2;
++v0;
} while (v0 < plr[v2]._pNumInv);
}
v9 = v2;
v11 = plr[v9]._pGold;
if (v12) {
stextsval = 0;
v10 = plr[v9]._pNumInv;
stextscrl = 1;
stextsmax = v10;
sprintf(tempstr, "Repair which item? Your gold : %i", v11);
AddSText(0, 1, 1u, tempstr, COL_GOLD, 0);
AddSLine(3);
AddSLine(21);
S_ScrollSSell(stextsval);
} else {
stextscrl = 0;
sprintf(tempstr, "You have nothing to repair. Your gold : %i", v11);
AddSText(0, 1, 1u, tempstr, COL_GOLD, 0);
for (i = 0; i < 40; i++)
storehold[i]._itype = ITYPE_NONE;
if (plr[myplr].InvBody[INVLOC_HEAD]._itype != ITYPE_NONE && plr[myplr].InvBody[INVLOC_HEAD]._iDurability != plr[myplr].InvBody[INVLOC_HEAD]._iMaxDur) {
repairok = TRUE;
AddStoreHoldRepair(plr[myplr].InvBody, -1);
}
if (plr[myplr].InvBody[INVLOC_CHEST]._itype != ITYPE_NONE && plr[myplr].InvBody[INVLOC_CHEST]._iDurability != plr[myplr].InvBody[INVLOC_CHEST]._iMaxDur) {
repairok = TRUE;
AddStoreHoldRepair(&plr[myplr].InvBody[INVLOC_CHEST], -2);
}
if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_NONE && plr[myplr].InvBody[INVLOC_HAND_LEFT]._iDurability != plr[myplr].InvBody[INVLOC_HAND_LEFT]._iMaxDur) {
repairok = TRUE;
AddStoreHoldRepair(&plr[myplr].InvBody[INVLOC_HAND_LEFT], -3);
}
if (plr[myplr].InvBody[INVLOC_HAND_RIGHT]._itype != ITYPE_NONE && plr[myplr].InvBody[INVLOC_HAND_RIGHT]._iDurability != plr[myplr].InvBody[INVLOC_HAND_RIGHT]._iMaxDur) {
repairok = TRUE;
AddStoreHoldRepair(&plr[myplr].InvBody[INVLOC_HAND_RIGHT], -4);
}
for (i = 0; i < plr[myplr]._pNumInv; i++) {
if (SmithRepairOk(i)) {
repairok = TRUE;
AddStoreHoldRepair(&plr[myplr].InvList[i], i);
}
}
if (!repairok) {
stextscrl = FALSE;
sprintf(tempstr, "You have nothing to repair. Your gold : %i", plr[myplr]._pGold);
AddSText(0, 1, 1, tempstr, 3, 0);
AddSLine(3);
AddSLine(21);
AddSText(0, 22, 1, "Back", 0, 1);
OffsetSTextY(22, 6);
return;
}
AddSText(0, 22, 1u, "Back", COL_WHITE, 1);
stextscrl = TRUE;
stextsval = 0;
stextsmax = plr[myplr]._pNumInv;
sprintf(tempstr, "Repair which item? Your gold : %i", plr[myplr]._pGold);
AddSText(0, 1, 1, tempstr, 3, 0);
AddSLine(3);
AddSLine(21);
S_ScrollSSell(stextsval);
AddSText(0, 22, 1, "Back", 0, 1);
OffsetSTextY(22, 6);
}
// 69F10C: using guessed type int storenumh;
// 6A09E0: using guessed type char stextsize;
// 6A09E4: using guessed type int stextsmax;
// 6A6BB8: using guessed type int stextscrl;
void AddStoreHoldRepair(ItemStruct *itm, int i)
{
@ -975,7 +886,7 @@ void AddStoreHoldRepair(ItemStruct *itm, int i)
void S_StartWitch()
{
stextsize = 0;
stextscrl = 0;
stextscrl = FALSE;
AddSText(0, 2, 1u, "Witch's shack", COL_GOLD, 0);
AddSText(0, 9, 1u, "Would you like to:", COL_GOLD, 0);
AddSText(0, 12, 1u, "Talk to Adria", COL_BLUE, 1);
@ -988,7 +899,6 @@ void S_StartWitch()
}
// 69F10C: using guessed type int storenumh;
// 6A09E0: using guessed type char stextsize;
// 6A6BB8: using guessed type int stextscrl;
void S_ScrollWBuy(int idx)
{
@ -1036,7 +946,7 @@ void S_StartWBuy()
v0 = plr[myplr]._pGold;
stextsize = 1;
stextscrl = 1;
stextscrl = TRUE;
stextsval = 0;
stextsmax = 20;
sprintf(tempstr, "I have these items for sale : Your gold : %i", v0);
@ -1063,7 +973,6 @@ void S_StartWBuy()
// 69F10C: using guessed type int storenumh;
// 6A09E0: using guessed type char stextsize;
// 6A09E4: using guessed type int stextsmax;
// 6A6BB8: using guessed type int stextscrl;
BOOL WitchSellOk(int i)
{
@ -1133,7 +1042,7 @@ void S_StartWSell()
}
if (!sellok) {
stextscrl = 0;
stextscrl = FALSE;
sprintf(tempstr, "You have nothing I want. Your gold : %i", plr[myplr]._pGold);
AddSText(0, 1, 1, tempstr, COL_GOLD, 0);
AddSLine(3);
@ -1141,7 +1050,7 @@ void S_StartWSell()
AddSText(0, 22, 1, "Back", COL_WHITE, 1);
OffsetSTextY(22, 6);
} else {
stextscrl = 1;
stextscrl = TRUE;
stextsval = 0;
stextsmax = plr[myplr]._pNumInv;
sprintf(tempstr, "Which item is for sale? Your gold : %i", plr[myplr]._pGold);
@ -1156,7 +1065,6 @@ void S_StartWSell()
// 69F10C: using guessed type int storenumh;
// 6A09E0: using guessed type char stextsize;
// 6A09E4: using guessed type int stextsmax;
// 6A6BB8: using guessed type int stextscrl;
BOOL WitchRechargeOk(int i)
{
@ -1209,7 +1117,7 @@ void S_StartWRecharge()
}
if (!rechargeok) {
stextscrl = 0;
stextscrl = FALSE;
sprintf(tempstr, "You have nothing to recharge. Your gold : %i", plr[myplr]._pGold);
AddSText(0, 1, 1, tempstr, COL_GOLD, 0);
AddSLine(3);
@ -1217,7 +1125,7 @@ void S_StartWRecharge()
AddSText(0, 22, 1, "Back", COL_WHITE, 1);
OffsetSTextY(22, 6);
} else {
stextscrl = 1;
stextscrl = TRUE;
stextsval = 0;
stextsmax = plr[myplr]._pNumInv;
sprintf(tempstr, "Recharge which item? Your gold : %i", plr[myplr]._pGold);
@ -1233,30 +1141,28 @@ void S_StartWRecharge()
void S_StartNoMoney()
{
StartStore((unsigned char)stextshold);
stextscrl = 0;
stextscrl = FALSE;
stextsize = 1;
ClearSText(5, 23);
AddSText(0, 14, 1u, "You do not have enough gold", COL_WHITE, 1);
}
// 6A09E0: using guessed type char stextsize;
// 6A6BB8: using guessed type int stextscrl;
void S_StartNoRoom()
{
StartStore((unsigned char)stextshold);
stextscrl = 0;
stextscrl = FALSE;
ClearSText(5, 23);
AddSText(0, 14, 1u, "You do not have enough room in inventory", COL_WHITE, 1);
}
// 6A6BB8: using guessed type int stextscrl;
void S_StartConfirm()
{
BOOL idprint; // esi
char iclr; // [esp+Ch] [ebp-4h]
BOOL idprint;
char iclr;
StartStore(stextshold);
stextscrl = 0;
stextscrl = FALSE;
ClearSText(5, 23);
iclr = COL_WHITE;
@ -1287,52 +1193,39 @@ void S_StartConfirm()
AddSTextVal(8, plr[myplr].HoldItem._iIvalue);
PrintStoreItem(&plr[myplr].HoldItem, 9, iclr);
if (stextshold > STORE_WRECHARGE) {
if (stextshold == STORE_BBOY) {
strcpy(tempstr, "Do we have a deal?");
goto LABEL_37;
}
if (stextshold != STORE_HBUY) {
if (stextshold == STORE_SIDENTIFY) {
strcpy(tempstr, "Are you sure you want to identify this item?");
goto LABEL_37;
}
if (stextshold != STORE_SPBUY)
goto LABEL_37;
}
LABEL_34:
strcpy(tempstr, "Are you sure you want to buy this item?");
goto LABEL_37;
}
switch (stextshold) {
case STORE_BBOY:
strcpy(tempstr, "Do we have a deal?");
break;
case STORE_SIDENTIFY:
strcpy(tempstr, "Are you sure you want to identify this item?");
break;
case STORE_HBUY:
case STORE_SPBUY:
case STORE_WBUY:
case STORE_SBUY:
strcpy(tempstr, "Are you sure you want to buy this item?");
break;
case STORE_WRECHARGE:
strcpy(tempstr, "Are you sure you want to recharge this item?");
break;
case STORE_SBUY:
goto LABEL_34;
case STORE_SSELL:
LABEL_27:
case STORE_WSELL:
strcpy(tempstr, "Are you sure you want to sell this item?");
break;
case STORE_SREPAIR:
strcpy(tempstr, "Are you sure you want to repair this item?");
break;
case STORE_WBUY:
goto LABEL_34;
case STORE_WSELL:
goto LABEL_27;
}
LABEL_37:
AddSText(0, 15, 1u, tempstr, COL_WHITE, 0);
AddSText(0, 18, 1u, "Yes", COL_WHITE, 1);
AddSText(0, 20, 1u, "No", COL_WHITE, 1);
}
// 6A6BB8: using guessed type int stextscrl;
void S_StartBoy()
{
stextsize = 0;
stextscrl = 0;
stextscrl = FALSE;
AddSText(0, 2, 1u, "Wirt the Peg-legged boy", COL_GOLD, 0);
AddSLine(5);
if (boyitem._itype != -1) {
@ -1348,14 +1241,13 @@ void S_StartBoy()
}
}
// 6A09E0: using guessed type char stextsize;
// 6A6BB8: using guessed type int stextscrl;
void S_StartBBoy()
{
int iclr; // esi
stextsize = 1;
stextscrl = 0;
stextscrl = FALSE;
sprintf(tempstr, "I have this item for sale : Your gold : %i", plr[myplr]._pGold);
AddSText(0, 1, 1u, tempstr, COL_GOLD, 0);
AddSLine(3);
@ -1377,12 +1269,11 @@ void S_StartBBoy()
OffsetSTextY(22, 6);
}
// 6A09E0: using guessed type char stextsize;
// 6A6BB8: using guessed type int stextscrl;
void S_StartHealer()
{
stextsize = 0;
stextscrl = 0;
stextscrl = FALSE;
AddSText(0, 1, 1u, "Welcome to the", COL_GOLD, 0);
AddSText(0, 3, 1u, "Healer's home", COL_GOLD, 0);
AddSText(0, 9, 1u, "Would you like to:", COL_GOLD, 0);
@ -1395,7 +1286,6 @@ void S_StartHealer()
}
// 69F10C: using guessed type int storenumh;
// 6A09E0: using guessed type char stextsize;
// 6A6BB8: using guessed type int stextscrl;
void S_ScrollHBuy(int idx)
{
@ -1432,7 +1322,7 @@ void S_StartHBuy()
v0 = plr[myplr]._pGold;
stextsize = 1;
stextscrl = 1;
stextscrl = TRUE;
stextsval = 0;
sprintf(tempstr, "I have these items for sale : Your gold : %i", v0);
AddSText(0, 1, 1u, tempstr, COL_GOLD, 0);
@ -1458,12 +1348,11 @@ void S_StartHBuy()
// 69F10C: using guessed type int storenumh;
// 6A09E0: using guessed type char stextsize;
// 6A09E4: using guessed type int stextsmax;
// 6A6BB8: using guessed type int stextscrl;
void S_StartStory()
{
stextsize = 0;
stextscrl = 0;
stextscrl = FALSE;
AddSText(0, 2, 1u, "The Town Elder", COL_GOLD, 0);
AddSText(0, 9, 1u, "Would you like to:", COL_GOLD, 0);
AddSText(0, 12, 1u, "Talk to Cain", COL_BLUE, 1);
@ -1472,7 +1361,6 @@ void S_StartStory()
AddSLine(5);
}
// 6A09E0: using guessed type char stextsize;
// 6A6BB8: using guessed type int stextscrl;
BOOL IdItemOk(ItemStruct *i)
{
@ -1545,7 +1433,7 @@ void S_StartSIdentify()
}
if (!idok) {
stextscrl = 0;
stextscrl = FALSE;
sprintf(tempstr, "You have nothing to identify. Your gold : %i", plr[myplr]._pGold);
AddSText(0, 1, 1, tempstr, COL_GOLD, 0);
AddSLine(3);
@ -1553,7 +1441,7 @@ void S_StartSIdentify()
AddSText(0, 22, 1, "Back", COL_WHITE, 1);
OffsetSTextY(22, 6);
} else {
stextscrl = 1;
stextscrl = TRUE;
stextsval = 0;
stextsmax = plr[myplr]._pNumInv;
sprintf(tempstr, "Identify which item? Your gold : %i", plr[myplr]._pGold);
@ -1568,14 +1456,13 @@ void S_StartSIdentify()
// 69F10C: using guessed type int storenumh;
// 6A09E0: using guessed type char stextsize;
// 6A09E4: using guessed type int stextsmax;
// 6A6BB8: using guessed type int stextscrl;
void S_StartIdShow()
{
char iclr; // [esp+4h] [ebp-4h]
StartStore(stextshold);
stextscrl = 0;
stextscrl = FALSE;
ClearSText(5, 23);
iclr = COL_WHITE;
@ -1589,7 +1476,6 @@ void S_StartIdShow()
PrintStoreItem(&plr[myplr].HoldItem, 12, iclr);
AddSText(0, 18, 1u, "Done", COL_WHITE, 1);
}
// 6A6BB8: using guessed type int stextscrl;
void S_StartTalk()
{
@ -1605,7 +1491,7 @@ void S_StartTalk()
int y; // [esp+14h] [ebp-4h]
stextsize = 0;
stextscrl = 0;
stextscrl = FALSE;
sprintf(tempstr, "Talk to %s", talkname[talker]);
AddSText(0, 2, 1u, tempstr, COL_GOLD, 0);
AddSLine(5);
@ -1645,12 +1531,11 @@ void S_StartTalk()
}
// 69FB38: using guessed type int talker;
// 6A09E0: using guessed type char stextsize;
// 6A6BB8: using guessed type int stextscrl;
void S_StartTavern()
{
stextsize = 0;
stextscrl = 0;
stextscrl = FALSE;
AddSText(0, 1, 1u, "Welcome to the", COL_GOLD, 0);
AddSText(0, 3, 1u, "Rising Sun", COL_GOLD, 0);
AddSText(0, 9, 1u, "Would you like to:", COL_GOLD, 0);
@ -1661,12 +1546,11 @@ void S_StartTavern()
}
// 69F10C: using guessed type int storenumh;
// 6A09E0: using guessed type char stextsize;
// 6A6BB8: using guessed type int stextscrl;
void S_StartBarMaid()
{
stextsize = 0;
stextscrl = 0;
stextscrl = FALSE;
AddSText(0, 2, 1u, "Gillian", COL_GOLD, 0);
AddSText(0, 9, 1u, "Would you like to:", COL_GOLD, 0);
AddSText(0, 12, 1u, "Talk to Gillian", COL_BLUE, 1);
@ -1676,12 +1560,11 @@ void S_StartBarMaid()
}
// 69F10C: using guessed type int storenumh;
// 6A09E0: using guessed type char stextsize;
// 6A6BB8: using guessed type int stextscrl;
void S_StartDrunk()
{
stextsize = 0;
stextscrl = 0;
stextscrl = FALSE;
AddSText(0, 2, 1u, "Farnham the Drunk", COL_GOLD, 0);
AddSText(0, 9, 1u, "Would you like to:", COL_GOLD, 0);
AddSText(0, 12, 1u, "Talk to Farnham", COL_BLUE, 1);
@ -1691,7 +1574,6 @@ void S_StartDrunk()
}
// 69F10C: using guessed type int storenumh;
// 6A09E0: using guessed type char stextsize;
// 6A6BB8: using guessed type int stextscrl;
void StartStore(char s)
{
@ -1851,7 +1733,6 @@ LABEL_19:
InStoreFlag = (InStoreFlag & 7) + 1;
}
// 6A09E0: using guessed type char stextsize;
// 6A6BB8: using guessed type int stextscrl;
// 6AA705: using guessed type char stextflag;
void STextESC()
@ -1980,7 +1861,6 @@ void STextUp()
}
}
// 69F108: using guessed type int stextup;
// 6A6BB8: using guessed type int stextscrl;
// 6A8A28: using guessed type int stextsel;
void STextDown()
@ -2026,7 +1906,6 @@ void STextDown()
}
}
// 6A09E4: using guessed type int stextsmax;
// 6A6BB8: using guessed type int stextscrl;
// 6A8A28: using guessed type int stextsel;
// 6AA700: using guessed type int stextdown;
@ -2046,7 +1925,6 @@ void STextPrior()
}
}
// 69F108: using guessed type int stextup;
// 6A6BB8: using guessed type int stextscrl;
// 6A8A28: using guessed type int stextsel;
void STextNext()
@ -2064,7 +1942,6 @@ void STextNext()
}
}
// 6A09E4: using guessed type int stextsmax;
// 6A6BB8: using guessed type int stextscrl;
// 6A8A28: using guessed type int stextsel;
// 6AA700: using guessed type int stextdown;
@ -3276,7 +3153,6 @@ void CheckStoreBtn()
}
// 646D00: using guessed type char qtextflag;
// 6A09E0: using guessed type char stextsize;
// 6A6BB8: using guessed type int stextscrl;
// 6A8A28: using guessed type int stextsel;
// 6A8A2C: using guessed type char stextscrldbtn;
// 6AA704: using guessed type char stextscrlubtn;

2
Source/stores.h

@ -18,7 +18,7 @@ extern int InStoreFlag; // idb
extern ItemStruct storehold[48];
extern int gossipstart; // weak
extern ItemStruct witchitem[20];
extern int stextscrl;
extern BOOL stextscrl;
extern int numpremium; // idb
extern ItemStruct healitem[20];
extern ItemStruct golditem;

4
Source/sync.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE

4
Source/textdat.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE

119
Source/themes.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE
@ -216,74 +214,55 @@ BOOL TFit_Obj3(int t)
BOOL CheckThemeReqs(int t)
{
BOOLEAN rv; // al
int v2; // ecx
int v3; // ecx
int v4; // ecx
int v5; // ecx
BOOLEAN v6; // zf
int v7; // ecx
int v8; // ecx
int v9; // ecx
rv = 1;
if (t <= 10) {
if (t != 10) {
v2 = t - 1;
if (v2) {
v3 = v2 - 2;
if (v3) {
v4 = v3 - 2;
if (v4) {
v5 = v4 - 2;
if (v5) {
if (v5 != 2) {
return rv;
}
v6 = pFountainFlag == 0;
} else {
v6 = bFountainFlag == 0;
}
LABEL_21:
if (!v6) {
return rv;
}
return 0;
}
}
}
if (leveltype != 3) {
v6 = leveltype == DTYPE_HELL;
goto LABEL_21;
}
return 0;
BOOL rv;
rv = TRUE;
switch (t) {
case THEME_SHRINE:
case THEME_SKELROOM:
case THEME_LIBRARY:
if (leveltype == DTYPE_CAVES || leveltype == DTYPE_HELL) {
rv = FALSE;
}
LABEL_16:
v6 = leveltype == DTYPE_CATHEDRAL;
goto LABEL_21;
}
v7 = t - 12;
if (v7) {
v8 = v7 - 1;
if (!v8) {
v6 = mFountainFlag == 0;
goto LABEL_21;
break;
case THEME_BLOODFOUNTAIN:
if (!bFountainFlag) {
rv = FALSE;
}
break;
case THEME_PURIFYINGFOUNTAIN:
if (!pFountainFlag) {
rv = FALSE;
}
v9 = v8 - 1;
if (!v9) {
v6 = tFountainFlag == 0;
goto LABEL_21;
break;
case THEME_ARMORSTAND:
if (leveltype == DTYPE_CATHEDRAL) {
rv = FALSE;
}
break;
case THEME_CAULDRON:
if (leveltype != DTYPE_HELL || !cauldronFlag) {
rv = FALSE;
}
if (v9 != 2) {
return rv;
break;
case THEME_MURKYFOUNTAIN:
if (!mFountainFlag) {
rv = FALSE;
}
goto LABEL_16;
}
if (leveltype == DTYPE_HELL) {
v6 = cauldronFlag == 0;
goto LABEL_21;
break;
case THEME_TEARFOUNTAIN:
if (!tFountainFlag) {
rv = FALSE;
}
break;
case THEME_WEAPONRACK:
if (leveltype == DTYPE_CATHEDRAL) {
rv = FALSE;
}
break;
}
return 0;
return rv;
}
// 6AAA58: using guessed type int mFountainFlag;
// 6AAA5C: using guessed type int cauldronFlag;
@ -453,19 +432,19 @@ void InitThemes()
}
if (leveltype == 2 || leveltype == 3 || leveltype == 4) {
for (i = 0; i < themeCount; i++)
themes[i].ttype = -1;
themes[i].ttype = THEME_NONE;
if (QuestStatus(QTYPE_ZHAR)) {
for (j = 0; j < themeCount; j++) {
themes[j].ttval = themeLoc[j].ttval;
if (SpecialThemeFit(j, 5)) {
themes[j].ttype = 5;
if (SpecialThemeFit(j, THEME_LIBRARY)) {
themes[j].ttype = THEME_LIBRARY;
zharlib = j;
break;
}
}
}
for (i = 0; i < themeCount; i++) {
if (themes[i].ttype == -1) {
if (themes[i].ttype == THEME_NONE) {
themes[i].ttval = themeLoc[i].ttval;
for (j = ThemeGood[random(0, 4)];; j = random(0, 17)) {
if (SpecialThemeFit(i, j)) {

17
Source/tmsg.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE
@ -40,13 +38,18 @@ void tmsg_add(BYTE *pbMsg, BYTE bLen)
*tail = msg;
}
void tmsg_start()
{
/// ASSERT: assert(! sgpTimedMsgHead);
}
void *tmsg_cleanup()
{
TMsg *next;
while (sgpTimedMsgHead) {
TMsg *next = sgpTimedMsgHead->hdr.pNext;
TMsg *head = sgpTimedMsgHead;
sgpTimedMsgHead = NULL;
mem_free_dbg(head);
next = sgpTimedMsgHead->hdr.pNext;
MemFreeDbg(sgpTimedMsgHead);
sgpTimedMsgHead = next;
}
return sgpTimedMsgHead;

1
Source/tmsg.h

@ -4,6 +4,7 @@
int tmsg_get(BYTE *pbMsg, DWORD dwMaxLen);
void tmsg_add(BYTE *pbMsg, BYTE bLen);
void tmsg_start();
void *tmsg_cleanup();
#endif /* __TMSG_H__ */

14
Source/town.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE
@ -8,7 +6,7 @@ void town_clear_upper_buf(BYTE *pBuff)
{
/// ASSERT: assert(gpBuffer);
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov edi, pBuff
mov edx, 30
@ -71,7 +69,7 @@ void town_clear_low_buf(BYTE *pBuff)
{
/// ASSERT: assert(gpBuffer);
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov edi, pBuff
mov edx, 30
@ -946,7 +944,7 @@ void T_DrawZoom(int x, int y)
/// ASSERT: assert(gpBuffer);
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov esi, gpBuffer
mov edx, nDstOff
@ -1111,7 +1109,7 @@ void T_FillSector(unsigned char *P3Tiles, unsigned char *pSector, int xi, int yi
for (j = 0; j < h; j++) {
xx = xi;
for (i = 0; i < w; i++) {
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov esi, pSector
mov eax, ii
@ -1177,7 +1175,7 @@ void T_FillTile(unsigned char *P3Tiles, int xx, int yy, int t)
{
long v1, v2, v3, v4;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#ifdef USE_ASM
__asm {
mov eax, t
dec eax

13
Source/towners.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE
@ -395,22 +393,17 @@ void InitTowners()
void FreeTownerGFX()
{
void *tmp;
int i;
for (i = 0; i < 16; i++) {
if (towner[i]._tNData == pCowCels) {
towner[i]._tNData = NULL;
} else if (towner[i]._tNData) {
tmp = towner[i]._tNData;
towner[i]._tNData = NULL;
mem_free_dbg(tmp);
MemFreeDbg(towner[i]._tNData);
}
}
tmp = pCowCels;
pCowCels = NULL;
mem_free_dbg(tmp);
MemFreeDbg(pCowCels);
}
void TownCtrlMsg(int i)

5
Source/track.cpp

@ -1,6 +1,5 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
#include "../3rdParty/Storm/Source/storm.h"
DEVILUTION_BEGIN_NAMESPACE

113
Source/trigs.cpp

@ -1,6 +1,4 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
DEVILUTION_BEGIN_NAMESPACE
@ -251,88 +249,45 @@ void InitL3Triggers()
void InitL4Triggers()
{
signed int v0; // edi
int *v1; // esi
int *v2; // edx
TriggerStruct *v3; // ecx
int *v4; // eax
int v5; // edx
int(*v6)[112]; // edi
signed int v7; // ecx
int *v8; // eax
int(*v9)[112]; // [esp+Ch] [ebp-Ch]
int(*v10)[112]; // [esp+Ch] [ebp-Ch]
int v11; // [esp+10h] [ebp-8h]
int(*v12)[112]; // [esp+14h] [ebp-4h]
int i, j;
trigflag_4 = 0;
v11 = 0;
v9 = dPiece;
do {
v0 = 0;
v12 = v9;
v1 = &trigs[trigflag_4]._tmsg;
v2 = &trigs[trigflag_4]._ty;
v3 = &trigs[trigflag_4];
v4 = &trigs[trigflag_4]._tlvl;
do {
if ((*v12)[0] == 83) {
++trigflag_4;
v3->_tx = v0;
*v2 = v11;
*v1 = WM_DIABPREVLVL;
v4 += 4;
++v3;
v2 += 4;
v1 += 4;
for (j = 0; j < MAXDUNY; j++) {
for (i = 0; i < MAXDUNX; i++) {
if (dPiece[i][j] == 83) {
trigs[trigflag_4]._tx = i;
trigs[trigflag_4]._ty = j;
trigs[trigflag_4]._tmsg = WM_DIABPREVLVL;
trigflag_4++;
}
if ((*v12)[0] == 422) {
v3->_tx = v0;
*v2 = v11;
*v1 = WM_DIABTWARPUP;
*v4 = 0;
++trigflag_4;
v4 += 4;
++v3;
v2 += 4;
v1 += 4;
if (dPiece[i][j] == 422) {
trigs[trigflag_4]._tx = i;
trigs[trigflag_4]._ty = j;
trigs[trigflag_4]._tmsg = WM_DIABTWARPUP;
trigs[trigflag_4]._tlvl = 0;
trigflag_4++;
}
if ((*v12)[0] == 120) {
++trigflag_4;
v3->_tx = v0;
*v2 = v11;
*v1 = WM_DIABNEXTLVL;
v4 += 4;
++v3;
v2 += 4;
v1 += 4;
if (dPiece[i][j] == 120) {
trigs[trigflag_4]._tx = i;
trigs[trigflag_4]._ty = j;
trigs[trigflag_4]._tmsg = WM_DIABNEXTLVL;
trigflag_4++;
}
++v12;
++v0;
} while (v0 < 112);
v9 = (int(*)[112])((char *)v9 + 4);
++v11;
} while ((signed int)v9 < (signed int)dPiece[1]);
v5 = 0;
v10 = dPiece;
do {
v6 = v10;
v7 = 0;
v8 = &trigs[trigflag_4]._ty;
do {
if ((*v6)[0] == 370 && quests[QTYPE_VB]._qactive == 3) {
++trigflag_4;
*(v8 - 1) = v7;
*v8 = v5;
v8[1] = WM_DIABNEXTLVL;
v8 += 4;
}
}
for (j = 0; j < MAXDUNY; j++) {
for (i = 0; i < MAXDUNX; i++) {
if (dPiece[i][j] == 370 && quests[QTYPE_VB]._qactive == 3) {
trigs[trigflag_4]._tx = i;
trigs[trigflag_4]._ty = j;
trigs[trigflag_4]._tmsg = WM_DIABNEXTLVL;
trigflag_4++;
}
++v7;
++v6;
} while (v7 < 112);
v10 = (int(*)[112])((char *)v10 + 4);
++v5;
} while ((signed int)v10 < (signed int)dPiece[1]);
}
}
trigflag_3 = 0;
}

9
Source/wave.cpp

@ -1,6 +1,5 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "diablo.h"
#include "../3rdParty/Storm/Source/storm.h"
DEVILUTION_BEGIN_NAMESPACE
@ -105,9 +104,7 @@ void *AllocateMemFile(HANDLE hsFile, MEMFILE *pMemFile, DWORD dwPos)
void FreeMemFile(MEMFILE *pMemFile)
{
void *mem = pMemFile->buf;
pMemFile->buf = NULL;
mem_free_dbg(mem);
MemFreeDbg(pMemFile->buf);
}
BOOL ReadWaveFile(MEMFILE *pMemFile, WAVEFORMATEX *pwfx, CKINFO *chunk)

3
SourceS/devilution.h

@ -1 +1,2 @@
#include "../types.h"
#include "diablo.h"
#include "../3rdParty/Storm/Source/storm.h"

2
SourceS/miniwin/misc.h

@ -544,6 +544,8 @@ WINBOOL WINAPI DeleteFileA(LPCSTR lpFileName);
WINBOOL WINAPI CopyFileA(LPCSTR lpExistingFileName, LPCSTR lpNewFileName, WINBOOL bFailIfExists);
HFILE WINAPI OpenFile(LPCSTR lpFileName, LPOFSTRUCT lpReOpenBuff, UINT uStyle);
void __debugbreak();
typedef struct _CONTEXT {
//

4
SourceX/dx.cpp

@ -1,7 +1,7 @@
#include "devilution.h"
#include "DiabloUI/diabloui.h"
#include "miniwin/ddraw.h"
#include "../types.h"
namespace dvl {
BYTE *sgpBackBuf;

7
SourceX/miniwin/misc.cpp

@ -1,9 +1,9 @@
#include <SDL.h>
#include "devilution.h"
#include "DiabloUI/diabloui.h"
#include "stubs.h"
#include "miniwin/ddraw.h"
#include "DiabloUI/diabloui.h"
#include <string>
#ifdef _MSC_VER
#define strcasecmp _stricmp
@ -757,4 +757,9 @@ LONG SetWindowLongA(HWND hWnd, int nIndex, LONG dwNewLong)
return 0;
}
void __debugbreak()
{
DUMMY();
}
}

14
defs.h

@ -87,8 +87,18 @@
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480
#define BUFFER_WIDTH 768
#define BUFFER_HEIGHT 656
// If defined, use 32-bit colors instead of 8-bit [Default -> Undefined]
//#define RGBMODE
#ifndef RGBMODE
#define SCREEN_BPP 8
#else
#define SCREEN_BPP 32
#endif
#define BUFFER_WIDTH (64 + SCREEN_WIDTH + 64)
#define BUFFER_HEIGHT (160 + SCREEN_HEIGHT + 16)
#define TILE_SIZE 32
#define SCREENXY(x, y) ((x) + 64 + (((y) + 160) * 768))

2
enums.h

@ -1915,7 +1915,7 @@ typedef enum theme_id {
THEME_TEARFOUNTAIN = 0xE,
THEME_BRNCROSS = 0xF,
THEME_WEAPONRACK = 0x10,
THEME_NONE = 0xFF,
THEME_NONE = -1,
} theme_id;
typedef enum event_type {

90
types.h

@ -59,9 +59,9 @@ DEVILUTION_BEGIN_NAMESPACE
#include "enums.h"
#include "structs.h"
#include "DiabloUI/diabloui.h"
#include "3rdParty/Storm/Source/storm.h"
#include "3rdParty/PKWare/pkware.h"
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
#define USE_ASM
#endif
// If defined, use copy protection [Default -> Defined]
//#define COPYPROT
@ -78,88 +78,4 @@ DEVILUTION_BEGIN_NAMESPACE
// 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
// header files
//#ifdef __cplusplus
//extern "C" {
//#endif
#include "Source/appfat.h"
#include "Source/automap.h"
#include "Source/capture.h"
#include "Source/codec.h"
#include "Source/control.h"
#include "Source/cursor.h"
#include "Source/dead.h"
#include "Source/debug.h"
#include "Source/diablo.h"
#include "Source/doom.h"
#include "Source/drlg_l1.h"
#include "Source/drlg_l2.h"
#include "Source/drlg_l3.h"
#include "Source/drlg_l4.h"
#include "Source/dthread.h"
#include "Source/dx.h"
#include "Source/effects.h"
#include "Source/encrypt.h"
#include "Source/engine.h"
#include "Source/error.h"
#include "Source/fault.h"
#include "Source/gamemenu.h"
#include "Source/gendung.h"
#include "Source/gmenu.h"
#include "Source/help.h"
#include "Source/init.h"
#include "Source/interfac.h"
#include "Source/inv.h"
#include "Source/items.h"
#include "Source/lighting.h"
#include "Source/loadsave.h"
#include "Source/logging.h"
#include "Source/mainmenu.h"
#include "Source/minitext.h"
#include "Source/missiles.h"
#include "Source/monster.h"
#include "Source/movie.h"
#include "Source/mpqapi.h"
#include "Source/msg.h"
#include "Source/msgcmd.h"
#include "Source/multi.h"
#include "Source/nthread.h"
#include "Source/objects.h"
#include "Source/pack.h"
#include "Source/palette.h"
#include "Source/path.h"
#include "Source/pfile.h"
#include "Source/player.h"
#include "Source/plrmsg.h"
#include "Source/portal.h"
#include "Source/quests.h"
#include "Source/restrict.h"
#include "Source/scrollrt.h"
#include "Source/setmaps.h"
#include "Source/sha.h"
#include "Source/sound.h"
#include "Source/spells.h"
#include "Source/stores.h"
#include "Source/sync.h"
#include "Source/textdat.h" // check file name
#include "Source/themes.h"
#include "Source/tmsg.h"
#include "Source/town.h"
#include "Source/towners.h"
#include "Source/track.h"
#include "Source/trigs.h"
#include "Source/wave.h"
#include "Source/render.h" // linked last, likely .s/.asm
//#ifdef __cplusplus
//}
//#endif
#include "miniwin/popdecl.inc"
DEVILUTION_END_NAMESPACE
#endif

Loading…
Cancel
Save