Browse Source

Merge branch 'master' of github.com:diasurgical/devilution

pull/72/head
Anders Jenbo 7 years ago
parent
commit
32c9acbc04
  1. 25
      README.md
  2. 331
      Source/control.cpp
  3. 10
      Source/control.h
  4. 151
      Source/drlg_l2.cpp
  5. 172
      Source/drlg_l3.cpp
  6. 174
      Source/drlg_l4.cpp
  7. 749
      Source/gendung.cpp
  8. 20
      Source/gendung.h
  9. 81
      Source/inv.cpp
  10. 485
      Source/missiles.cpp
  11. 26
      Source/stores.cpp
  12. 36
      Source/trigs.cpp
  13. 3
      types.h

25
README.md

@ -77,7 +77,7 @@ make -j$(nproc)
## Building for the native platform
*Note: Since 64-bit builds are currently not in a playable state, it is advised to build in a 32-bit environment. Another possibility is a 32-bit build on a 64-bit system (see above).*
<details><summary>Linux</summary>
### Installing dependencies on Debian and Ubuntu
```
sudo apt-get install cmake g++ libsdl2-dev libsdl2-mixer-dev libsdl2-ttf-dev libsodium-dev
@ -122,24 +122,31 @@ All games are encrypted and password protected.
[Guidelines](docs/CONTRIBUTING.md)
# Modding
Here are some screenshots to demonstrate the relative ease of improving the game:
Below are a few examples of some simple improvements made to the game. It is planned in the future to create tools for designing dungeons and graphics.
![Screenshot 1: Monster lifebar+items](https://github.com/diasurgical/scalpel/blob/master/screens/mod1.png)
![Screenshot 2: New trade screen](https://github.com/diasurgical/scalpel/blob/master/screens/mod2.png)
# F.A.Q.
<details><summary>Click to reveal</summary>
> Wow, does this mean I can download and play Diablo for free now?
No, you'll need access to the data from the original game. To get a legitimate copy of the game assets, please refer to the [GoG release of Diablo 1](https://www.gog.com/game/diablo).
> Ok, so I'm playing DevilutionX now and all the sudden it crashed. NOW WHAT??
No, you'll need access to the data from the original game. If you don't have an original CD then you can [buy Diablo from GoG.com](https://www.gog.com/game/diablo).
> Cool, so I fired your mod up, but there's no 1080p or new features?
Open an issue and provide as much information as possible (OS version, etc.) including any crash logs.
> I thought I'd fix the crash myself, but after looking at the code its a disaster. Do you speak v2-34-v8?
We're working on it.
> After looking at the code some of it is a disaster
That is the result of decompiled code. Whenever a program is compiled, much of the source is optimized and stripped away, so it's nearly impossible to decompile it back. Have patience. Everything will be cleaned up eventually. :)
> What about Hellfire?
Hellfire was a bit of a flop on the developer's part. Support may come in the future once the base game is finished.
</details>
# Credits
- Reverse engineered by GalaXyHaXz in 2018
- [sanctuary](https://github.com/sanctuary) - extensively documenting Diablo's game engine
- [BWAPI Team](https://github.com/bwapi) - providing library API to work with Storm
- [Ladislav Zezula](https://github.com/ladislav-zezula) - reversing PKWARE library, further documenting Storm
@ -148,11 +155,13 @@ That is the result of decompiled code. Whenever a program is compiled, much of t
- Blizzard North - wait, this was a typo!
- Depression - reason to waste four months of my life doing this ;)
And a special thanks to all the support and people who work on Devilution to make it possible! <3
# Legal
This software is being released to the Public Domain. No assets of Diablo are being provided. You must own a copy of Diablo and have access to the assets beforehand in order to use this software.
Devilution is released to the Public Domain. The documentation and function provided by Devilution may only be utilized with assets provided by ownership of Diablo.
Battle.net(R) - Copyright (C) 1996 Blizzard Entertainment, Inc. All rights reserved. Battle.net and Blizzard Entertainment are trademarks or registered trademarks of Blizzard Entertainment, Inc. in the U.S. and/or other countries.
Diablo(R) - Copyright (C) 1996 Blizzard Entertainment, Inc. All rights reserved. Diablo and Blizzard Entertainment are trademarks or registered trademarks of Blizzard Entertainment, Inc. in the U.S. and/or other countries.
This software is in no way associated with or endorsed by Blizzard Entertainment(R).
Devilution and any of its' maintainers are in no way associated with or endorsed by Blizzard Entertainment(R).

331
Source/control.cpp

@ -23,15 +23,15 @@ BOOL chrbtnactive;
char sgszTalkMsg[80];
BYTE *pPanelText;
int frame_4B8800; // idb
char *pLifeBuff;
void *pBtmBuff;
BYTE *pLifeBuff;
BYTE *pBtmBuff;
void *pTalkBtns;
int pstrjust[4];
int pnumlines; // idb
BOOL pinfoflag;
int talkbtndown[3];
int pSpell; // weak
char *pManaBuff;
BYTE *pManaBuff;
int infoclr; // weak
int sgbPlrTalkTbl; // weak // should be char [4]
void *pGBoxBuff;
@ -961,76 +961,155 @@ void __cdecl ClearPanel()
void __fastcall DrawPanelBox(int x, int y, int w, int h, int sx, int sy)
{
char *v6; // esi
char *v7; // edi
int v8; // edx
unsigned int v9; // ecx
char v10; // cf
unsigned int v11; // ecx
int nSrcOff, nDstOff;
v6 = (char *)pBtmBuff + 640 * y + x;
v7 = (char *)&gpBuffer[768 * sy + sx];
v8 = h;
do {
v9 = w >> 1;
if (!(w & 1) || (*v7 = *v6, ++v6, ++v7, v9)) {
v10 = v9 & 1;
v11 = w >> 2;
if (!v10 || (*(_WORD *)v7 = *(_WORD *)v6, v6 += 2, v7 += 2, v11)) {
qmemcpy(v7, v6, 4 * v11);
v6 += 4 * v11;
v7 += 4 * v11;
}
/// ASSERT: assert(gpBuffer);
nSrcOff = x + 640 * y;
nDstOff = sx + 768 * sy;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
__asm {
mov esi, pBtmBuff
add esi, nSrcOff
mov edi, gpBuffer
add edi, nDstOff
xor ebx, ebx
mov bx, word ptr w
xor edx, edx
mov dx, word ptr h
label1:
mov ecx, ebx
shr ecx, 1
jnb label2
movsb
jecxz label4
label2:
shr ecx, 1
jnb label3
movsw
jecxz label4
label3:
rep movsd
label4:
add esi, 640
sub esi, ebx
add edi, 768
sub edi, ebx
dec edx
jnz label1
}
#else
int wdt, hgt;
BYTE *src, *dst;
src = &pBtmBuff[nSrcOff];
dst = &gpBuffer[nDstOff];
for(hgt = h; hgt; hgt--, src += 640 - w, dst += 768 - w) {
wdt = w;
if(wdt & 1) {
dst[0] = src[0];
src++;
dst++;
}
wdt >>= 1;
if(wdt & 1) {
dst[0] = src[0];
dst[1] = src[1];
src += 2;
dst += 2;
}
v6 = &v6[-w + 640];
v7 = &v7[-w + 768];
--v8;
} while (v8);
wdt >>= 1;
while(wdt) {
dst[0] = src[0];
dst[1] = src[1];
dst[2] = src[2];
dst[3] = src[3];
src += 4;
dst += 4;
wdt--;
}
}
#endif
}
void __fastcall SetFlaskHeight(char *buf, int min, int max, int c, int r)
void __fastcall SetFlaskHeight(BYTE *pCelBuff, int min, int max, int c, int r)
{
char *v5; // esi
char *v6; // edi
int v7; // edx
int nSrcOff, nDstOff, w;
v5 = &buf[88 * min];
v6 = (char *)&gpBuffer[768 * r + c];
v7 = max - min;
do {
qmemcpy(v6, v5, 0x58u);
v5 += 88;
v6 += 768;
--v7;
} while (v7);
}
void __fastcall DrawFlask(void *a1, int a2, int a3, void *a4, int a5, int a6)
{
char *v6; // esi
_BYTE *v7; // edi
int v8; // edx
signed int v9; // ecx
char v10; // al
int v11; // [esp+Ch] [ebp-4h]
v11 = a2;
v6 = (char *)a1 + a3;
v7 = (unsigned char *)a4 + a5;
v8 = a6;
do {
v9 = 59;
do {
v10 = *v6++;
if (v10)
*v7 = v10;
++v7;
--v9;
} while (v9);
v6 = &v6[v11 - 59];
v7 += 709;
--v8;
} while (v8);
/// ASSERT: assert(gpBuffer);
nSrcOff = 88 * min;
nDstOff = c + 768 * r;
w = max - min;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
__asm {
mov esi, pCelBuff
add esi, nSrcOff
mov edi, gpBuffer
add edi, nDstOff
mov edx, w
label1:
mov ecx, 88 / 4
rep movsd
add edi, 768 - 88
dec edx
jnz label1
}
#else
BYTE *src, *dst;
src = &pCelBuff[nSrcOff];
dst = &gpBuffer[nDstOff];
for(; w; w--, src += 88, dst += 768)
memcpy(dst, src, 88);
#endif
}
void __fastcall DrawFlask(BYTE *pCelBuff, int w, int nSrcOff, BYTE *pBuff, int nDstOff, int h)
{
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
__asm {
mov esi, pCelBuff
add esi, nSrcOff
mov edi, pBuff
add edi, nDstOff
mov edx, h
label1:
mov ecx, 59
label2:
lodsb
or al, al
jz label3
mov [edi], al
label3:
inc edi
loop label2
add esi, w
sub esi, 59
add edi, 768 - 59
dec edx
jnz label1
}
#else
int wdt, hgt;
BYTE *src, *dst;
src = &pCelBuff[nSrcOff];
dst = &pBuff[nDstOff];
for(hgt = h; hgt; hgt--, src += w - 59, dst += 768 - 59) {
for(wdt = 59; wdt; wdt--) {
if(*src)
*dst = *src;
src++;
dst++;
}
}
#endif
}
void __cdecl DrawLifeFlask()
@ -1137,9 +1216,9 @@ void __cdecl InitControlPan()
v0 = 288 * 640;
pBtmBuff = DiabloAllocPtr(v0);
memset(pBtmBuff, 0, v0);
pManaBuff = (char *)DiabloAllocPtr(0x1E40);
pManaBuff = DiabloAllocPtr(0x1E40);
memset(pManaBuff, 0, 0x1E40);
pLifeBuff = (char *)DiabloAllocPtr(0x1E40);
pLifeBuff = DiabloAllocPtr(0x1E40);
memset(pLifeBuff, 0, 0x1E40);
pPanelText = LoadFileInMem("CtrlPan\\SmalText.CEL", 0);
pChrPanel = LoadFileInMem("Data\\Char.CEL", 0);
@ -2363,52 +2442,78 @@ LABEL_18:
void __cdecl RedBack()
{
int v0; // eax
char *v1; // edi
signed int v3; // edx
signed int v4; // ecx
char *v7; // edi
signed int v9; // edx
signed int v10; // ecx
int v12; // [esp+8h] [ebp-4h]
int _EAX;
char *_EBX;
v0 = -(light4flag != 0);
_LOWORD(v0) = v0 & 0xF400;
v12 = v0 + 768 * 6;
if (leveltype == DTYPE_HELL) {
v7 = (char *)&gpBuffer[SCREENXY(0, 0)];
_EBX = &pLightTbl[v12];
v9 = 352;
do {
v10 = 640;
do {
_EAX = *v7;
if ((unsigned char)*v7 >= 32)
ASM_XLAT(_EAX, _EBX);
*v7++ = _EAX;
--v10;
} while (v10);
v7 += 128;
--v9;
} while (v9);
int idx;
idx = light4flag ? 1536 : 4608;
/// ASSERT: assert(gpBuffer);
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
if(leveltype != DTYPE_HELL) {
__asm {
mov edi, gpBuffer
add edi, SCREENXY(0, 0)
mov ebx, pLightTbl
add ebx, idx
mov edx, 352
lx_label1:
mov ecx, 640
lx_label2:
mov al, [edi]
xlat
stosb
loop lx_label2
add edi, 768 - 640
dec edx
jnz lx_label1
}
} else {
v1 = (char *)&gpBuffer[SCREENXY(0, 0)];
_EBX = &pLightTbl[v12];
v3 = 352;
do {
v4 = 640;
do {
_EAX = *v1;
ASM_XLAT(_EAX, _EBX);
*v1++ = _EAX;
--v4;
} while (v4);
v1 += 128;
--v3;
} while (v3);
__asm {
mov edi, gpBuffer
add edi, SCREENXY(0, 0)
mov ebx, pLightTbl
add ebx, idx
mov edx, 352
l4_label1:
mov ecx, 640
l4_label2:
mov al, [edi]
cmp al, 32
jb l4_label3
xlat
l4_label3:
stosb
loop l4_label2
add edi, 768 - 640
dec edx
jnz l4_label1
}
}
#else
int w, h;
BYTE *dst, *tbl;
if(leveltype != DTYPE_HELL) {
dst = &gpBuffer[SCREENXY(0, 0)];
tbl = (BYTE *)&pLightTbl[idx];
for(h = 352; h; h--, dst += 768 - 640) {
for(w = 640; w; w--) {
*dst = tbl[*dst];
dst++;
}
}
} else {
dst = &gpBuffer[SCREENXY(0, 0)];
tbl = (BYTE *)&pLightTbl[idx];
for(h = 352; h; h--, dst += 768 - 640) {
for(w = 640; w; w--) {
if(*dst >= 32)
*dst = tbl[*dst];
dst++;
}
}
}
#endif
}
// 525728: using guessed type int light4flag;

10
Source/control.h

@ -17,15 +17,15 @@ extern BOOL drawmanaflag; // idb
extern BOOL chrbtnactive;
extern BYTE *pPanelText;
extern int frame_4B8800; // idb
extern char *pLifeBuff;
extern void *pBtmBuff;
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 int pSpell; // weak
extern char *pManaBuff;
extern BYTE *pManaBuff;
extern int infoclr; // weak
extern void *pGBoxBuff;
extern void *pSBkBtnCel;
@ -65,8 +65,8 @@ void __fastcall AddPanelString(char *str, BOOL just);
void __cdecl ClearPanel();
void __fastcall DrawPanelBox(int x, int y, int w, int h, int sx, int sy);
void __cdecl InitPanelStr();
void __fastcall SetFlaskHeight(char *buf, int min, int max, int c, int r);
void __fastcall DrawFlask(void *a1, int a2, int a3, void *a4, int a5, int a6);
void __fastcall SetFlaskHeight(BYTE *pCelBuff, int min, int max, int c, int r);
void __fastcall DrawFlask(BYTE *pCelBuff, int w, int nSrcOff, BYTE *pBuff, int nDstOff, int h);
void __cdecl DrawLifeFlask();
void __cdecl UpdateLifeFlask();
void __cdecl DrawManaFlask();

151
Source/drlg_l2.cpp

@ -523,77 +523,86 @@ void __fastcall LoadL2Dungeon(char *sFileName, int vx, int vy)
void __cdecl DRLG_L2Pass3()
{
int v0; // eax
int *v1; // edx
int *v2; // eax
signed int v3; // ecx
signed int v4; // ebx
int *v5; // ecx
unsigned char *v6; // edx
unsigned short *v7; // esi
unsigned short v8; // ax
int v9; // eax
int v10; // ST24_4
int v11; // ST20_4
int v12; // ST1C_4
signed int v13; // [esp+Ch] [ebp-1Ch]
int *v14; // [esp+10h] [ebp-18h]
int v15; // [esp+14h] [ebp-14h]
int v16; // [esp+18h] [ebp-10h]
int v17; // [esp+1Ch] [ebp-Ch]
int v18; // [esp+20h] [ebp-8h]
v0 = *((unsigned short *)pMegaTiles + 44) + 1;
v18 = *((unsigned short *)pMegaTiles + 44) + 1;
_LOWORD(v0) = *((_WORD *)pMegaTiles + 45);
v17 = ++v0;
_LOWORD(v0) = *((_WORD *)pMegaTiles + 46);
v16 = ++v0;
_LOWORD(v0) = *((_WORD *)pMegaTiles + 47);
v15 = v0 + 1;
v1 = dPiece[1];
do {
v2 = v1;
v3 = 56;
do {
*(v2 - 112) = v18;
*v2 = v17;
*(v2 - 111) = v16;
v2[1] = v15;
v2 += 224;
--v3;
} while (v3);
v1 += 2;
} while ((INT_PTR)v1 < (INT_PTR)dPiece[2]);
v4 = 0;
v14 = &dPiece[17][16];
do {
v5 = v14;
v6 = (unsigned char *)dungeon + v4;
v13 = 40;
do {
v7 = (unsigned short *)((char *)pMegaTiles + 8 * (*v6 - 1));
v8 = *v7;
++v7;
v9 = v8 + 1;
v10 = v9;
_LOWORD(v9) = *v7;
++v7;
v11 = ++v9;
_LOWORD(v9) = *v7;
v12 = ++v9;
_LOWORD(v9) = v7[1];
v6 += 40;
*(v5 - 112) = v10;
*v5 = v11;
*(v5 - 111) = v12;
v5[1] = v9 + 1;
v5 += 224;
--v13;
} while (v13);
v14 += 2;
++v4;
} while (v4 < 40);
int i, j, xx, yy;
long v1, v2, v3, v4, lv;
lv = 12-1;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
__asm {
mov esi, pMegaTiles
mov eax, lv
shl eax, 3
add esi, eax
xor eax, eax
lodsw
inc eax
mov v1, eax
lodsw
inc eax
mov v2, eax
lodsw
inc eax
mov v3, eax
lodsw
inc eax
mov v4, eax
}
#else
v1 = *((WORD *)&pMegaTiles[lv*8])+1;
v2 = *((WORD *)&pMegaTiles[lv*8]+1)+1;
v3 = *((WORD *)&pMegaTiles[lv*8]+2)+1;
v4 = *((WORD *)&pMegaTiles[lv*8]+3)+1;
#endif
for(j = 0; j < MAXDUNY; j += 2) {
for(i = 0; i < MAXDUNX; i += 2) {
dPiece[i][j] = v1;
dPiece[i+1][j] = v2;
dPiece[i][j+1] = v3;
dPiece[i+1][j+1] = v4;
}
}
yy = 16;
for(j = 0; j < DMAXY; j++) {
xx = 16;
for(i = 0; i < DMAXX; i++) {
lv = (unsigned char)dungeon[i][j]-1;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
__asm {
mov esi, pMegaTiles
mov eax, lv
shl eax, 3
add esi, eax
xor eax, eax
lodsw
inc eax
mov v1, eax
lodsw
inc eax
mov v2, eax
lodsw
inc eax
mov v3, eax
lodsw
inc eax
mov v4, eax
}
#else
v1 = *((WORD *)&pMegaTiles[lv*8])+1;
v2 = *((WORD *)&pMegaTiles[lv*8]+1)+1;
v3 = *((WORD *)&pMegaTiles[lv*8]+2)+1;
v4 = *((WORD *)&pMegaTiles[lv*8]+3)+1;
#endif
dPiece[xx][yy] = v1;
dPiece[xx+1][yy] = v2;
dPiece[xx][yy+1] = v3;
dPiece[xx+1][yy+1] = v4;
xx += 2;
}
yy += 2;
}
}
void __fastcall LoadPreL2Dungeon(char *sFileName, int vx, int vy)

172
Source/drlg_l3.cpp

@ -2336,88 +2336,100 @@ BOOLEAN __fastcall WoodHorizR(int x, int j)
void __cdecl DRLG_L3Pass3()
{
int v0; // eax
int *v1; // esi
int *v2; // eax
signed int v3; // ecx
signed int v4; // ebx
int *v5; // ecx
unsigned char *v6; // edi
unsigned short *v7; // esi
unsigned short v8; // ax
int v9; // eax
signed int v10; // [esp+Ch] [ebp-1Ch]
int *v11; // [esp+10h] [ebp-18h]
int v12; // [esp+14h] [ebp-14h]
int v13; // [esp+18h] [ebp-10h]
int v14; // [esp+18h] [ebp-10h]
int v15; // [esp+1Ch] [ebp-Ch]
int v16; // [esp+1Ch] [ebp-Ch]
int v17; // [esp+20h] [ebp-8h]
int v18; // [esp+20h] [ebp-8h]
int v19; // [esp+24h] [ebp-4h]
int v20; // [esp+24h] [ebp-4h]
v0 = *((unsigned short *)pMegaTiles + 28) + 1;
v19 = *((unsigned short *)pMegaTiles + 28) + 1;
_LOWORD(v0) = *((_WORD *)pMegaTiles + 29);
v17 = ++v0;
_LOWORD(v0) = *((_WORD *)pMegaTiles + 30);
v15 = ++v0;
_LOWORD(v0) = *((_WORD *)pMegaTiles + 31);
v13 = v0 + 1;
v1 = dPiece[1];
do {
v2 = v1;
v3 = 56;
do {
*(v2 - 112) = v19;
*v2 = v17;
*(v2 - 111) = v15;
v2[1] = v13;
v2 += 224;
--v3;
} while (v3);
v1 += 2;
} while ((signed int)v1 < (signed int)dPiece[2]);
v4 = 0;
v11 = &dPiece[17][16];
do {
v5 = v11;
v6 = (unsigned char *)dungeon + v4;
v10 = 40;
do {
v12 = *v6 - 1;
if (v12 < 0) {
v20 = 0;
v18 = 0;
v16 = 0;
v14 = 0;
int i, j, xx, yy;
long v1, v2, v3, v4, lv;
lv = 8-1;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
__asm {
mov esi, pMegaTiles
mov eax, lv
shl eax, 3
add esi, eax
xor eax, eax
lodsw
inc eax
mov v1, eax
lodsw
inc eax
mov v2, eax
lodsw
inc eax
mov v3, eax
lodsw
inc eax
mov v4, eax
}
#else
v1 = *((WORD *)&pMegaTiles[lv*8])+1;
v2 = *((WORD *)&pMegaTiles[lv*8]+1)+1;
v3 = *((WORD *)&pMegaTiles[lv*8]+2)+1;
v4 = *((WORD *)&pMegaTiles[lv*8]+3)+1;
#endif
for(j = 0; j < MAXDUNY; j += 2) {
for(i = 0; i < MAXDUNX; i += 2) {
dPiece[i][j] = v1;
dPiece[i+1][j] = v2;
dPiece[i][j+1] = v3;
dPiece[i+1][j+1] = v4;
}
}
yy = 16;
for(j = 0; j < DMAXY; j++) {
xx = 16;
for(i = 0; i < DMAXX; i++) {
lv = (unsigned char)dungeon[i][j]-1;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
if(lv >= 0) {
__asm {
mov esi, pMegaTiles
mov eax, lv
shl eax, 3
add esi, eax
xor eax, eax
lodsw
inc eax
mov v1, eax
lodsw
inc eax
mov v2, eax
lodsw
inc eax
mov v3, eax
lodsw
inc eax
mov v4, eax
}
} else {
v7 = (unsigned short *)((char *)pMegaTiles + 8 * v12);
v8 = *v7;
++v7;
v9 = v8 + 1;
v20 = v9;
_LOWORD(v9) = *v7;
++v7;
v18 = ++v9;
_LOWORD(v9) = *v7;
v16 = ++v9;
_LOWORD(v9) = v7[1];
v14 = v9 + 1;
v1 = 0;
v2 = 0;
v3 = 0;
v4 = 0;
}
v6 += 40;
*(v5 - 112) = v20;
*v5 = v18;
*(v5 - 111) = v16;
v5[1] = v14;
v5 += 224;
--v10;
} while (v10);
v11 += 2;
++v4;
} while (v4 < 40);
#else
if(lv >= 0) {
v1 = *((WORD *)&pMegaTiles[lv*8])+1;
v2 = *((WORD *)&pMegaTiles[lv*8]+1)+1;
v3 = *((WORD *)&pMegaTiles[lv*8]+2)+1;
v4 = *((WORD *)&pMegaTiles[lv*8]+3)+1;
} else {
v1 = 0;
v2 = 0;
v3 = 0;
v4 = 0;
}
#endif
dPiece[xx][yy] = v1;
dPiece[xx+1][yy] = v2;
dPiece[xx][yy+1] = v3;
dPiece[xx+1][yy+1] = v4;
xx += 2;
}
yy += 2;
}
}
void __fastcall LoadL3Dungeon(char *sFileName, int vx, int vy)

174
Source/drlg_l4.cpp

@ -2858,88 +2858,100 @@ void __cdecl DRLG_L4Corners()
void __cdecl DRLG_L4Pass3()
{
int v0; // eax
int *v1; // esi
int *v2; // eax
signed int v3; // ecx
signed int v4; // ebx
int *v5; // ecx
unsigned char *v6; // edi
unsigned short *v7; // esi
unsigned short v8; // ax
int v9; // eax
signed int v10; // [esp+Ch] [ebp-1Ch]
int *v11; // [esp+10h] [ebp-18h]
int v12; // [esp+14h] [ebp-14h]
int v13; // [esp+18h] [ebp-10h]
int v14; // [esp+18h] [ebp-10h]
int v15; // [esp+1Ch] [ebp-Ch]
int v16; // [esp+1Ch] [ebp-Ch]
int v17; // [esp+20h] [ebp-8h]
int v18; // [esp+20h] [ebp-8h]
int v19; // [esp+24h] [ebp-4h]
int v20; // [esp+24h] [ebp-4h]
v0 = *((unsigned short *)pMegaTiles + 116) + 1;
v19 = *((unsigned short *)pMegaTiles + 116) + 1;
_LOWORD(v0) = *((_WORD *)pMegaTiles + 117);
v17 = ++v0;
_LOWORD(v0) = *((_WORD *)pMegaTiles + 118);
v15 = ++v0;
_LOWORD(v0) = *((_WORD *)pMegaTiles + 119);
v13 = v0 + 1;
v1 = dPiece[1];
do {
v2 = v1;
v3 = 56;
do {
*(v2 - 112) = v19;
*v2 = v17;
*(v2 - 111) = v15;
v2[1] = v13;
v2 += 224;
--v3;
} while (v3);
v1 += 2;
} while ((signed int)v1 < (signed int)dPiece[2]);
v4 = 0;
v11 = &dPiece[17][16];
do {
v5 = v11;
v6 = (unsigned char *)dungeon + v4;
v10 = 40;
do {
v12 = *v6 - 1;
if (v12 < 0) {
v20 = 0;
v18 = 0;
v16 = 0;
v14 = 0;
int i, j, xx, yy;
long v1, v2, v3, v4, lv;
lv = 30-1;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
__asm {
mov esi, pMegaTiles
mov eax, lv
shl eax, 3
add esi, eax
xor eax, eax
lodsw
inc eax
mov v1, eax
lodsw
inc eax
mov v2, eax
lodsw
inc eax
mov v3, eax
lodsw
inc eax
mov v4, eax
}
#else
v1 = *((WORD *)&pMegaTiles[lv*8])+1;
v2 = *((WORD *)&pMegaTiles[lv*8]+1)+1;
v3 = *((WORD *)&pMegaTiles[lv*8]+2)+1;
v4 = *((WORD *)&pMegaTiles[lv*8]+3)+1;
#endif
for(j = 0; j < MAXDUNY; j += 2) {
for(i = 0; i < MAXDUNX; i += 2) {
dPiece[i][j] = v1;
dPiece[i+1][j] = v2;
dPiece[i][j+1] = v3;
dPiece[i+1][j+1] = v4;
}
}
yy = 16;
for(j = 0; j < DMAXY; j++) {
xx = 16;
for(i = 0; i < DMAXX; i++) {
lv = (unsigned char)dungeon[i][j]-1;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
if(lv >= 0) {
__asm {
mov esi, pMegaTiles
mov eax, lv
shl eax, 3
add esi, eax
xor eax, eax
lodsw
inc eax
mov v1, eax
lodsw
inc eax
mov v2, eax
lodsw
inc eax
mov v3, eax
lodsw
inc eax
mov v4, eax
}
} else {
v7 = (unsigned short *)((char *)pMegaTiles + 8 * v12);
v8 = *v7;
++v7;
v9 = v8 + 1;
v20 = v9;
_LOWORD(v9) = *v7;
++v7;
v18 = ++v9;
_LOWORD(v9) = *v7;
v16 = ++v9;
_LOWORD(v9) = v7[1];
v14 = v9 + 1;
}
v6 += 40;
*(v5 - 112) = v20;
*v5 = v18;
*(v5 - 111) = v16;
v5[1] = v14;
v5 += 224;
--v10;
} while (v10);
v11 += 2;
++v4;
} while (v4 < 40);
v1 = 0;
v2 = 0;
v3 = 0;
v4 = 0;
}
#else
if(lv >= 0) {
v1 = *((WORD *)&pMegaTiles[lv*8])+1;
v2 = *((WORD *)&pMegaTiles[lv*8]+1)+1;
v3 = *((WORD *)&pMegaTiles[lv*8]+2)+1;
v4 = *((WORD *)&pMegaTiles[lv*8]+3)+1;
} else {
v1 = 0;
v2 = 0;
v3 = 0;
v4 = 0;
}
#endif
dPiece[xx][yy] = v1;
dPiece[xx+1][yy] = v2;
dPiece[xx][yy+1] = v3;
dPiece[xx+1][yy+1] = v4;
xx += 2;
}
yy += 2;
}
}
DEVILUTION_END_NAMESPACE

749
Source/gendung.cpp

@ -4,14 +4,14 @@
DEVILUTION_BEGIN_NAMESPACE
short level_frame_types[2048];
WORD level_frame_types[MAXTILES];
int themeCount;
char nTransTable[2049];
//int dword_52D204;
int dMonster[MAXDUNX][MAXDUNY];
char dungeon[40][40];
char dObject[MAXDUNX][MAXDUNY];
void *pSpeedCels;
BYTE *pSpeedCels;
int nlevel_frames; // weak
char pdungeon[40][40];
char dDead[MAXDUNX][MAXDUNY];
@ -23,9 +23,9 @@ char dflags[40][40];
int dPiece[MAXDUNX][MAXDUNY];
char dTransVal[MAXDUNX][MAXDUNY];
int setloadflag_2; // weak
int tile_defs[2048];
int tile_defs[MAXTILES];
BYTE *pMegaTiles;
void *pLevelPieces;
BYTE *pLevelPieces;
int gnDifficulty; // idb
char block_lvid[2049];
//char byte_5B78EB;
@ -35,10 +35,10 @@ BYTE leveltype;
unsigned char currlevel; // idb
char TransList[256];
BOOLEAN nSolidTable[2049];
int level_frame_count[2048];
int level_frame_count[MAXTILES];
ScrollStruct ScrollInfo;
void *pDungeonCels;
int speed_cel_frame_num_from_light_index_frame_num[16][128];
BYTE *pDungeonCels;
int speed_cel_frame_num_from_light_index_frame_num[128][16];
THEME_LOC themeLoc[MAXTHEMES];
char dPlayer[MAXDUNX][MAXDUNY];
int dword_5C2FF8; // weak
@ -51,7 +51,7 @@ void *level_special_cel;
char dFlags[MAXDUNX][MAXDUNY];
char dItem[MAXDUNX][MAXDUNY];
BYTE setlvlnum;
int level_frame_sizes[2048];
int level_frame_sizes[MAXTILES];
char nMissileTable[2049];
char *pSetPiece_2;
char setlvltype; // weak
@ -69,7 +69,7 @@ int setpc_y; // idb
char dMissile[MAXDUNX][MAXDUNY];
int dminx; // weak
int dminy; // weak
short dpiece_defs_map_2[16][MAXDUNX][MAXDUNY];
WORD dpiece_defs_map_2[MAXDUNX][MAXDUNY][16];
void __cdecl FillSolidBlockTbls()
{
@ -126,348 +126,362 @@ void __cdecl FillSolidBlockTbls()
void __cdecl gendung_418D91()
{
signed int v0; // edx
short(*v1)[MAXDUNX][MAXDUNY]; // edi
short(*v2)[MAXDUNX][MAXDUNY]; // esi
signed int v3; // ebx
int i; // edx
short v5; // ax
int v6; // ecx
signed int v7; // edx
int v8; // eax
int v9; // edi
char *v10; // esi
int j; // ecx
unsigned char v12; // al
unsigned char *v13; // esi
int v14; // ecx
signed int v15; // edx
int v16; // eax
int v17; // ecx
unsigned char v18; // al
signed int v19; // ecx
int v20; // edi
int v21; // edx
int v22; // edi
int v23; // eax
int v24; // eax
BOOLEAN v25; // zf
int v26; // edx
char *v27; // esi
char *v28; // edi
int k; // ecx
char *v33; // esi
char *v34; // edi
int v36; // ecx
signed int v37; // edx
int v38; // eax
int v39; // ecx
short(*v42)[MAXDUNX][MAXDUNY]; // esi
short v43; // ax
unsigned short v44; // dx
short v45; // ax
int v46; // [esp-4h] [ebp-38h]
int v47; // [esp-4h] [ebp-38h]
int v48; // [esp+Ch] [ebp-28h]
int(*v49)[128]; // [esp+10h] [ebp-24h]
int(*v50)[112]; // [esp+10h] [ebp-24h]
int v51; // [esp+14h] [ebp-20h]
short(*v52)[MAXDUNX][MAXDUNY]; // [esp+14h] [ebp-20h]
signed int v53; // [esp+18h] [ebp-1Ch]
int v54; // [esp+18h] [ebp-1Ch]
short(*v55)[MAXDUNX][MAXDUNY]; // [esp+18h] [ebp-1Ch]
int v56; // [esp+1Ch] [ebp-18h]
int(*v57)[112]; // [esp+1Ch] [ebp-18h]
signed int v58; // [esp+20h] [ebp-14h]
int v59; // [esp+20h] [ebp-14h]
int v60; // [esp+24h] [ebp-10h]
signed int v61; // [esp+24h] [ebp-10h]
int v62; // [esp+28h] [ebp-Ch]
int v63; // [esp+2Ch] [ebp-8h]
signed int v64; // [esp+30h] [ebp-4h]
signed int v65; // [esp+30h] [ebp-4h]
int _EAX;
char *_EBX;
int i, j, x, y;
int total_frames, blocks, total_size, frameidx, lfs_adder, blk_cnt, currtile, nDataSize;
WORD m;
BOOL blood_flag;
WORD *pMap;
DWORD *pFrameTable;
#if (_MSC_VER < 800) || (_MSC_VER > 1200)
int k, l;
BYTE width, pix;
BYTE *src, *dst, *tbl;
#endif
v0 = 0;
memset(level_frame_types, 0, sizeof(level_frame_types));
memset(level_frame_count, 0, sizeof(level_frame_count));
do {
tile_defs[v0] = v0;
++v0;
} while (v0 < 2048);
v1 = dpiece_defs_map_2;
v48 = 2 * (leveltype == DTYPE_HELL) + 10;
do {
v2 = v1;
v3 = 112;
do {
for (i = 0; i < v48; ++i) {
v5 = (*v2)[0][i];
if ((*v2)[0][i]) {
v6 = v5 & 0xFFF;
++level_frame_count[v6];
level_frame_types[v6] = v5 & 0x7000;
for(i = 0; i < MAXTILES; i++) {
tile_defs[i] = i;
level_frame_count[i] = 0;
level_frame_types[i] = 0;
}
if(leveltype != DTYPE_HELL)
blocks = 10;
else
blocks = 12;
for(y = 0; y < MAXDUNY; y++) {
for(x = 0; x < MAXDUNX; x++) {
for(i = 0; i < blocks; i++) {
pMap = dpiece_defs_map_2[x][y];
if(pMap[i]) {
level_frame_count[pMap[i] & 0xFFF]++;
level_frame_types[pMap[i] & 0xFFF] = pMap[i] & 0x7000;
}
}
v2 = (short(*)[MAXDUNX][MAXDUNY])((char *)v2 + 3584);
--v3;
} while (v3);
v1 = (short(*)[MAXDUNX][MAXDUNY])((char *)v1 + 32);
} while ((signed int)v1 < (signed int)dpiece_defs_map_2[0][16]); /* check */
v7 = 1;
nlevel_frames = *(_DWORD *)pDungeonCels & 0xFFFF;
v8 = nlevel_frames;
if (nlevel_frames > 1) {
do {
level_frame_sizes[v7] = (*((_DWORD *)pDungeonCels + v7 + 1) - *((_DWORD *)pDungeonCels + v7)) & 0xFFFF;
v8 = nlevel_frames;
++v7;
} while (v7 < nlevel_frames);
}
}
v9 = 0;
pFrameTable = (DWORD *)pDungeonCels;
nlevel_frames = pFrameTable[0] & 0xFFFF;
for(i = 1; i < nlevel_frames; i++) {
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
__asm {
mov ebx, pDungeonCels
mov eax, i
shl eax, 2
add ebx, eax
mov eax, [ebx+4]
sub eax, [ebx]
mov nDataSize, eax
}
#else
nDataSize = pFrameTable[i + 1] - pFrameTable[i];
#endif
level_frame_sizes[i] = nDataSize & 0xFFFF;
}
level_frame_sizes[0] = 0;
if (leveltype == DTYPE_HELL && v8 > 0) {
do {
if (!v9)
if(leveltype == DTYPE_HELL) {
for(i = 0; i < nlevel_frames; i++) {
if(!i)
level_frame_count[0] = 0;
v53 = 1;
if (level_frame_count[v9]) {
if (level_frame_types[v9] == 4096) {
v13 = (unsigned char *)pDungeonCels + *((_DWORD *)pDungeonCels + v9);
v14 = 32;
do {
v46 = v14;
v15 = 32;
do {
while (1) {
v16 = *v13++;
if ((v16 & 0x80u) == 0)
break;
_LOBYTE(v16) = -(char)v16;
v15 -= v16;
if (!v15)
goto LABEL_36;
}
v15 -= v16;
v17 = v16;
do {
v18 = *v13++;
if (v18 && v18 < 0x20u)
v53 = 0;
--v17;
} while (v17);
} while (v15);
LABEL_36:
v14 = v46 - 1;
} while (v46 != 1);
blood_flag = TRUE;
if(level_frame_count[i]) {
if(level_frame_types[i] != 0x1000) {
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
j = level_frame_sizes[i];
__asm {
mov ebx, pDungeonCels
mov eax, i
shl eax, 2
add ebx, eax
mov esi, pDungeonCels
add esi, [ebx]
xor ebx, ebx
mov ecx, j
jecxz l1_label3
l1_label1:
lodsb
cmp al, 0
jz l1_label2
cmp al, 32
jnb l1_label2
mov blood_flag, ebx
l1_label2:
loop l1_label1
l1_label3:
nop
}
#else
src = &pDungeonCels[pFrameTable[i]];
for(j = level_frame_sizes[i]; j; j--) {
pix = *src++;
if(pix && pix < 32)
blood_flag = FALSE;
}
#endif
} else {
v10 = (char *)pDungeonCels + *((_DWORD *)pDungeonCels + v9);
for (j = level_frame_sizes[v9]; j; --j) {
v12 = *v10++;
if (v12 && v12 < 0x20u)
v53 = 0;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
__asm {
mov ebx, pDungeonCels
mov eax, i
shl eax, 2
add ebx, eax
mov esi, pDungeonCels
add esi, [ebx]
xor ebx, ebx
mov ecx, 32
l2_label1:
push ecx
mov edx, 32
l2_label2:
xor eax, eax
lodsb
or al, al
js l2_label5
sub edx, eax
mov ecx, eax
l2_label3:
lodsb
cmp al, 0
jz l2_label4
cmp al, 32
jnb l2_label4
mov blood_flag, ebx
l2_label4:
loop l2_label3
or edx, edx
jz l2_label6
jmp l2_label2
l2_label5:
neg al
sub edx, eax
jnz l2_label2
l2_label6:
pop ecx
loop l2_label1
}
#else
src = &pDungeonCels[pFrameTable[i]];
for(k = 32; k; k--) {
for(l = 32; l;) {
width = *src++;
if(!(width & 0x80)) {
l -= width;
while(width) {
pix = *src++;
if(pix && pix < 32)
blood_flag = FALSE;
width--;
}
} else {
width = -(char)width;
l -= width;
}
}
}
#endif
}
if (!v53)
level_frame_count[v9] = 0;
if(!blood_flag)
level_frame_count[i] = 0;
}
++v9;
} while (v9 < nlevel_frames);
}
}
gendung_4191BF(2047);
v19 = 0;
v20 = 0;
if (light4flag) {
do {
v21 = level_frame_sizes[v20++];
v19 += 2 * v21;
} while (v19 < 0x100000);
gendung_4191BF(MAXTILES - 1);
total_size = 0;
total_frames = 0;
if(light4flag) {
while(total_size < 0x100000) {
total_size += level_frame_sizes[total_frames] << 1;
total_frames++;
}
} else {
do
v19 += 14 * level_frame_sizes[v20++];
while (v19 < 0x100000);
}
v22 = v20 - 1;
v58 = v22;
if (v22 > 128) {
v58 = 128;
v22 = 128;
while(total_size < 0x100000) {
total_size += (level_frame_sizes[total_frames] << 4) - (level_frame_sizes[total_frames] << 1);
total_frames++;
}
}
v23 = -(light4flag != 0);
v63 = 0;
_LOBYTE(v23) = v23 & 0xF4;
v54 = 0;
v60 = v23 + 15;
if (v22 > 0) {
v56 = 0;
v49 = speed_cel_frame_num_from_light_index_frame_num;
do {
v24 = v54;
v25 = level_frame_types[v54] == 4096;
v62 = tile_defs[v54];
(*v49)[0] = v62;
if (v25) {
v65 = 1;
if (v60 > 1) {
do {
speed_cel_frame_num_from_light_index_frame_num[0][v65 + v56] = v63;
v33 = (char *)pDungeonCels + *((_DWORD *)pDungeonCels + v62);
v34 = (char *)pSpeedCels + v63;
_EBX = &pLightTbl[256 * v65];
v36 = 32;
do {
v47 = v36;
v37 = 32;
do {
while (1) {
v38 = (unsigned char)*v33++;
*v34++ = v38;
if ((v38 & 0x80u) == 0)
break;
_LOBYTE(v38) = -(char)v38;
v37 -= v38;
if (!v37)
goto LABEL_63;
}
v37 -= v38;
v39 = v38;
do {
_EAX = *v33++;
ASM_XLAT(_EAX, _EBX);
*v34++ = _EAX;
--v39;
} while (v39);
} while (v37);
LABEL_63:
v36 = v47 - 1;
} while (v47 != 1);
v63 += level_frame_sizes[v54];
++v65;
} while (v65 < v60);
goto LABEL_65;
total_frames--;
if(total_frames > 128)
total_frames = 128;
frameidx = 0; /* move into loop ? */
if(light4flag)
blk_cnt = 3;
else
blk_cnt = 15;
for(i = 0; i < total_frames; i++) {
currtile = tile_defs[i];
speed_cel_frame_num_from_light_index_frame_num[i][0] = currtile;
if(level_frame_types[i] != 0x1000) {
lfs_adder = level_frame_sizes[i];
for(j = 1; j < blk_cnt; j++) {
speed_cel_frame_num_from_light_index_frame_num[i][j] = frameidx;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
__asm {
mov ebx, pDungeonCels
mov eax, currtile
shl eax, 2
add ebx, eax
mov esi, pDungeonCels
add esi, [ebx]
mov edi, pSpeedCels
add edi, frameidx
mov ebx, j
shl ebx, 8
add ebx, pLightTbl
mov ecx, lfs_adder
jecxz l3_label2
l3_label1:
lodsb
xlat
stosb
loop l3_label1
l3_label2:
nop
}
} else {
v26 = level_frame_sizes[v24];
v51 = level_frame_sizes[v24];
v64 = 1;
if (v60 > 1) {
do {
speed_cel_frame_num_from_light_index_frame_num[0][v64 + v56] = v63;
v27 = (char *)pDungeonCels + *((_DWORD *)pDungeonCels + v62);
v28 = (char *)pSpeedCels + v63;
_EBX = &pLightTbl[256 * v64];
for (k = v51; k; --k) {
_EAX = *v27++;
ASM_XLAT(_EAX, _EBX);
*v28++ = _EAX;
#else
src = &pDungeonCels[pFrameTable[currtile]];
dst = &pSpeedCels[frameidx];
tbl = (BYTE *)&pLightTbl[256 * j];
for(k = lfs_adder; k; k--) {
*dst++ = tbl[*src++];
}
#endif
frameidx += lfs_adder;
}
} else {
for(j = 1; j < blk_cnt; j++) {
speed_cel_frame_num_from_light_index_frame_num[i][j] = frameidx;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
__asm {
mov ebx, pDungeonCels
mov eax, currtile
shl eax, 2
add ebx, eax
mov esi, pDungeonCels
add esi, [ebx]
mov edi, pSpeedCels
add edi, frameidx
mov ebx, j
shl ebx, 8
add ebx, pLightTbl
mov ecx, 32
l4_label1:
push ecx
mov edx, 32
l4_label2:
xor eax, eax
lodsb
stosb
or al, al
js l4_label4
sub edx, eax
mov ecx, eax
l4_label3:
lodsb
xlat
stosb
loop l4_label3
or edx, edx
jz l4_label5
jmp l4_label2
l4_label4:
neg al
sub edx, eax
jnz l4_label2
l4_label5:
pop ecx
loop l4_label1
}
#else
src = &pDungeonCels[pFrameTable[currtile]];
dst = &pSpeedCels[frameidx];
tbl = (BYTE *)&pLightTbl[256 * j];
for(k = 32; k; k--) {
for(l = 32; l;) {
width = *src++;
*dst++ = width;
if(!(width & 0x80)) {
l -= width;
while(width) {
*dst++ = tbl[*src++];
width--;
}
} else {
width = -(char)width;
l -= width;
}
v63 += v26;
++v64;
} while (v64 < v60);
LABEL_65:
v22 = v58;
goto LABEL_66;
}
}
#endif
frameidx += level_frame_sizes[i];
}
LABEL_66:
++v54;
v49 = (int(*)[128])((char *)v49 + 64);
v56 += 16;
} while (v54 < v22);
}
}
v57 = dPiece;
v55 = dpiece_defs_map_2;
do {
v61 = 112;
v52 = v55;
v50 = v57;
do {
if ((*v50)[0] && v48 > 0) {
v42 = v52;
v59 = v48;
do {
v43 = *(_WORD *)v42;
if (*(_WORD *)v42) {
v44 = 0;
if (v22 > 0) {
do {
if ((v43 & 0xFFF) == tile_defs[v44]) {
v45 = v44 + level_frame_types[v44];
v44 = v22;
v43 = v45 + -32768;
}
++v44;
} while (v44 < v22);
*(_WORD *)v42 = v43;
for(y = 0; y < MAXDUNY; y++) {
for(x = 0; x < MAXDUNX; x++) {
if(dPiece[x][y]) {
pMap = dpiece_defs_map_2[x][y];
for(i = 0; i < blocks; i++) {
if(pMap[i]) {
for(m = 0; m < total_frames; m++) {
if((pMap[i] & 0xFFF) == tile_defs[m]) {
pMap[i] = m + level_frame_types[m] + 0x8000;
m = total_frames;
}
}
}
v42 = (short(*)[MAXDUNX][MAXDUNY])((char *)v42 + 2);
--v59;
} while (v59);
}
}
++v50;
v52 = (short(*)[MAXDUNX][MAXDUNY])((char *)v52 + 3584);
--v61;
} while (v61);
v55 = (short(*)[MAXDUNX][MAXDUNY])((char *)v55 + 32);
v57 = (int(*)[112])((char *)v57 + 4);
} while ((signed int)v55 < (signed int)dpiece_defs_map_2[0][16]); /* check */
}
}
}
// 525728: using guessed type int light4flag;
// 53CD4C: using guessed type int nlevel_frames;
void __fastcall gendung_4191BF(int frames)
{
int v1; // edi
signed int v2; // eax
int i; // esi
v1 = frames;
v2 = 0;
while (v1 > 0 && !v2) {
v2 = 1;
for (i = 0; i < v1; ++i) {
if (level_frame_count[i] < level_frame_count[i + 1]) {
int i;
BOOL doneflag;
doneflag = FALSE;
while(frames > 0 && !doneflag) {
doneflag = TRUE;
for(i = 0; i < frames; i++) {
if(level_frame_count[i] < level_frame_count[i + 1]) {
gendung_4191FB(i, i + 1);
v2 = 0;
doneflag = FALSE;
}
}
--v1;
frames--;
}
}
void __fastcall gendung_4191FB(int a1, int a2)
void __fastcall gendung_4191FB(int f1, int f2)
{
int v2; // esi
int *v3; // edi
short *v4; // edx
int v5; // ST10_4
int *v6; // edi
int *v7; // eax
int v8; // ST10_4
short *v9; // ecx
int v10; // edx
int swap;
v2 = a2;
v3 = &level_frame_count[a1];
v4 = &level_frame_types[a2];
v2 *= 4;
v5 = *v3;
*v3 = *(int *)((char *)level_frame_count + v2);
v6 = &tile_defs[a1];
*(int *)((char *)level_frame_count + v2) = v5;
v7 = &level_frame_sizes[a1];
v8 = *v6;
*v6 = *(int *)((char *)tile_defs + v2);
*(int *)((char *)tile_defs + v2) = v8;
v9 = &level_frame_types[a1];
_LOWORD(v6) = *v9;
*v9 = *v4;
*v4 = (signed short)v6;
v10 = *v7;
*v7 = *(int *)((char *)level_frame_sizes + v2);
*(int *)((char *)level_frame_sizes + v2) = v10;
swap = level_frame_count[f1];
level_frame_count[f1] = level_frame_count[f2];
level_frame_count[f2] = swap;
swap = tile_defs[f1];
tile_defs[f1] = tile_defs[f2];
tile_defs[f2] = swap;
swap = level_frame_types[f1];
level_frame_types[f1] = level_frame_types[f2];
level_frame_types[f2] = swap;
swap = level_frame_sizes[f1];
level_frame_sizes[f1] = level_frame_sizes[f2];
level_frame_sizes[f2] = swap;
}
int __fastcall gendung_get_dpiece_num_from_coord(int x, int y)
@ -475,87 +489,60 @@ int __fastcall gendung_get_dpiece_num_from_coord(int x, int y)
if (x < MAXDUNY - y)
return (y + y * y + x * (x + 2 * y + 3)) / 2;
x = MAXDUNY - x - 1;
x = MAXDUNX - x - 1;
y = MAXDUNY - y - 1;
return MAXDUNX * MAXDUNY - (y + y * y + x * (x + 2 * y + 3)) / 2 - 1;
return MAXDUNX * MAXDUNY - ((y + y * y + x * (x + 2 * y + 3)) / 2) - 1;
}
void __cdecl gendung_4192C2()
{
short(*v0)[MAXDUNX][MAXDUNY]; // ebx
int v1; // ebp
short(*v2)[MAXDUNX][MAXDUNY]; // esi
char *v3; // edi
int x; // [esp+10h] [ebp-4h]
x = 0;
v0 = dpiece_defs_map_2;
do {
v1 = 0;
do {
v2 = v0;
v3 = (char *)dpiece_defs_map_1 + 32 * gendung_get_dpiece_num_from_coord(x, v1++);
v0 = (short(*)[MAXDUNX][MAXDUNY])((char *)v0 + 32);
qmemcpy(v3, v2, 0x20u);
} while (v1 < 112);
++x;
} while ((signed int)v0 < (signed int)&dpiece_defs_map_2[16][0][0]);
int i, x, y;
for(x = 0; x < MAXDUNX; x++) {
for(y = 0; y < MAXDUNY; y++) {
for(i = 0; i < 16; i++) {
dpiece_defs_map_1[gendung_get_dpiece_num_from_coord(x, y)][i] = dpiece_defs_map_2[x][y][i];
}
}
}
}
void __cdecl SetDungeonMicros()
{
signed int v0; // esi
short(*v1)[MAXDUNX][MAXDUNY]; // edx
int(*v2)[112]; // ebp
int v3; // eax
char *v4; // eax
signed int i; // ecx
_WORD *v6; // edi
int j; // ecx
short(*v8)[MAXDUNX][MAXDUNY]; // [esp+8h] [ebp-Ch]
int(*v9)[112]; // [esp+Ch] [ebp-8h]
signed int v10; // [esp+10h] [ebp-4h]
int i, x, y, lv, blocks;
WORD *pMap, *pPiece;
if (leveltype == DTYPE_HELL) {
dword_5A5594 = 12;
v0 = 16;
} else {
if(leveltype != DTYPE_HELL) {
dword_5A5594 = 10;
v0 = 10;
blocks = 10;
} else {
dword_5A5594 = 12;
blocks = 16;
}
v9 = dPiece;
v8 = dpiece_defs_map_2;
do {
v1 = v8;
v2 = v9;
v10 = 112;
do {
if ((*v2)[0]) {
v3 = (*v2)[0] - 1;
if (leveltype == DTYPE_HELL)
v4 = (char *)pLevelPieces + 32 * v3;
for(y = 0; y < MAXDUNY; y++) {
for(x = 0; x < MAXDUNX; x++) {
lv = dPiece[x][y];
pMap = dpiece_defs_map_2[x][y];
if(lv) {
lv--;
if(leveltype != DTYPE_HELL)
pPiece = (WORD *)&pLevelPieces[20 * lv];
else
v4 = (char *)pLevelPieces + 20 * v3;
for (i = 0; i < v0; ++i)
(*v1)[0][i] = *(_WORD *)&v4[2 * (v0 + (i & 1) - (i & 0xE)) - 4];
} else if (v0 > 0) {
memset(v1, 0, 4 * ((unsigned int)v0 >> 1));
v6 = (_WORD *)((char *)v1 + 4 * ((unsigned int)v0 >> 1));
for (j = v0 & 1; j; --j) {
*v6 = 0;
++v6;
}
pPiece = (WORD *)&pLevelPieces[32 * lv];
for(i = 0; i < blocks; i++)
pMap[i] = pPiece[(i & 1) + blocks - 2 - (i & 0xE)];
} else {
for(i = 0; i < blocks; i++)
pMap[i] = 0;
}
++v2;
v1 = (short(*)[MAXDUNX][MAXDUNY])((char *)v1 + 3584);
--v10;
} while (v10);
v8 = (short(*)[MAXDUNX][MAXDUNY])((char *)v8 + 32);
v9 = (int(*)[112])((char *)v9 + 4);
} while ((signed int)v8 < (signed int)dpiece_defs_map_2[0][16]); /* check */
}
}
gendung_418D91();
gendung_4192C2();
if (zoomflag) {
if(zoomflag) {
scr_pix_width = 640;
scr_pix_height = 352;
dword_5C2FF8 = 10;

20
Source/gendung.h

@ -2,14 +2,14 @@
#ifndef __GENDUNG_H__
#define __GENDUNG_H__
extern short level_frame_types[2048];
extern WORD level_frame_types[MAXTILES];
extern int themeCount;
extern char nTransTable[2049];
//int dword_52D204;
extern int dMonster[MAXDUNX][MAXDUNY];
extern char dungeon[40][40];
extern char dObject[MAXDUNX][MAXDUNY];
extern void *pSpeedCels;
extern BYTE *pSpeedCels;
extern int nlevel_frames; // weak
extern char pdungeon[40][40];
extern char dDead[MAXDUNX][MAXDUNY];
@ -21,9 +21,9 @@ extern char dflags[40][40];
extern int dPiece[MAXDUNX][MAXDUNY];
extern char dTransVal[MAXDUNX][MAXDUNY];
extern int setloadflag_2; // weak
extern int tile_defs[2048];
extern int tile_defs[MAXTILES];
extern BYTE *pMegaTiles;
extern void *pLevelPieces;
extern BYTE *pLevelPieces;
extern int gnDifficulty; // idb
extern char block_lvid[2049];
//char byte_5B78EB;
@ -33,10 +33,10 @@ extern BYTE leveltype;
extern unsigned char currlevel; // idb
extern char TransList[256];
extern BOOLEAN nSolidTable[2049];
extern int level_frame_count[2048];
extern int level_frame_count[MAXTILES];
extern ScrollStruct ScrollInfo;
extern void *pDungeonCels;
extern int speed_cel_frame_num_from_light_index_frame_num[16][128];
extern BYTE *pDungeonCels;
extern int speed_cel_frame_num_from_light_index_frame_num[128][16];
extern THEME_LOC themeLoc[MAXTHEMES];
extern char dPlayer[MAXDUNX][MAXDUNY];
extern int dword_5C2FF8; // weak
@ -49,7 +49,7 @@ extern void *level_special_cel;
extern char dFlags[MAXDUNX][MAXDUNY];
extern char dItem[MAXDUNX][MAXDUNY];
extern BYTE setlvlnum;
extern int level_frame_sizes[2048];
extern int level_frame_sizes[MAXTILES];
extern char nMissileTable[2049];
extern char *pSetPiece_2;
extern char setlvltype; // weak
@ -67,12 +67,12 @@ extern int setpc_y; // idb
extern char dMissile[MAXDUNX][MAXDUNY];
extern int dminx; // weak
extern int dminy; // weak
extern short dpiece_defs_map_2[16][MAXDUNX][MAXDUNY];
extern WORD dpiece_defs_map_2[MAXDUNX][MAXDUNY][16];
void __cdecl FillSolidBlockTbls();
void __cdecl gendung_418D91();
void __fastcall gendung_4191BF(int frames);
void __fastcall gendung_4191FB(int a1, int a2);
void __fastcall gendung_4191FB(int f1, int f2);
int __fastcall gendung_get_dpiece_num_from_coord(int x, int y);
void __cdecl gendung_4192C2();
void __cdecl SetDungeonMicros();

81
Source/inv.cpp

@ -116,35 +116,60 @@ void __cdecl InitInv()
void __fastcall InvDrawSlotBack(int X, int Y, int W, int H)
{
unsigned char *v4; // edi
int v5; // edx
int v6; // ecx
unsigned char v7; // al
unsigned char v8; // al
v4 = (unsigned char *)gpBuffer + screen_y_times_768[Y] + X;
v5 = (unsigned short)H;
do {
v6 = (unsigned short)W;
do {
v7 = *v4;
if (*v4 < 0xB0u)
goto LABEL_9;
if (v7 > 0xBFu) {
if (v7 < 0xF0u)
goto LABEL_9;
v8 = v7 - 80;
} else {
v8 = v7 - 16;
BYTE *dst;
/// ASSERT: assert(gpBuffer);
dst = &gpBuffer[X + screen_y_times_768[Y]];
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
__asm {
mov edi, dst
xor edx, edx
xor ebx, ebx
mov dx, word ptr H
mov bx, word ptr W
label1:
mov ecx, ebx
label2:
mov al, [edi]
cmp al, PAL16_BLUE
jb label5
cmp al, PAL16_BLUE + 15
ja label3
sub al, PAL16_BLUE - PAL16_BEIGE
jmp label4
label3:
cmp al, PAL16_GRAY
jb label5
sub al, PAL16_GRAY - PAL16_BEIGE
label4:
mov [edi], al
label5:
inc edi
loop label2
sub edi, 768
sub edi, ebx
dec edx
jnz label1
}
#else
int wdt, hgt;
BYTE pix;
for(hgt = H; hgt; hgt--, dst -= 768 + W) {
for(wdt = W; wdt; wdt--) {
pix = *dst;
if(pix >= PAL16_BLUE) {
if(pix <= PAL16_BLUE + 15)
pix -= PAL16_BLUE - PAL16_BEIGE;
else if(pix >= PAL16_GRAY)
pix -= PAL16_GRAY - PAL16_BEIGE;
}
*v4 = v8;
LABEL_9:
++v4;
--v6;
} while (v6);
v4 = &v4[-(unsigned short)W - 768];
--v5;
} while (v5);
*dst++ = pix;
}
}
#endif
}
void __cdecl DrawInv()

485
Source/missiles.cpp

@ -2292,62 +2292,38 @@ void __fastcall AddGuardian(int mi, int sx, int sy, int dx, int dy, int midir, i
void __fastcall AddChain(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam)
{
int v9; // ecx
v9 = mi;
missile[v9]._miVar1 = dx;
missile[v9]._miVar2 = dy;
missile[v9]._mirange = 1;
missile[mi]._miVar1 = dx;
missile[mi]._miVar2 = dy;
missile[mi]._mirange = 1;
UseMana(id, 14);
}
void __fastcall miss_null_11(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam)
{
int v9; // esi
int v10; // eax
v9 = mi;
SetMissDir(mi, dx);
v10 = v9;
missile[v10]._midam = 0;
missile[v10]._miLightFlag = TRUE;
missile[v10]._mirange = 250;
missile[mi]._midam = 0;
missile[mi]._miLightFlag = TRUE;
missile[mi]._mirange = 250;
}
void __fastcall miss_null_12(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam)
{
signed int v9; // edx
int v10; // esi
int v11; // eax
v9 = dx;
v10 = mi;
if (dx > 3)
v9 = 2;
SetMissDir(mi, v9);
v11 = v10;
missile[v11]._midam = 0;
missile[v11]._miLightFlag = TRUE;
missile[v11]._mirange = 250;
dx = 2;
SetMissDir(mi, dx);
missile[mi]._midam = 0;
missile[mi]._miLightFlag = TRUE;
missile[mi]._mirange = 250;
}
void __fastcall miss_null_13(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam)
{
signed int v9; // edx
int v10; // esi
int v11; // eax
int v12; // ecx
v9 = dx;
v10 = mi;
if (dx > 3)
v9 = 2;
SetMissDir(mi, v9);
v11 = v10;
v12 = missile[v10]._miAnimLen;
missile[v11]._midam = 0;
missile[v11]._miLightFlag = TRUE;
missile[v11]._mirange = v12;
dx = 2;
SetMissDir(mi, dx);
missile[mi]._midam = 0;
missile[mi]._miLightFlag = TRUE;
missile[mi]._mirange = missile[mi]._miAnimLen;
}
void __fastcall AddRhino(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam)
@ -2454,35 +2430,26 @@ void __fastcall AddAcid(int mi, int sx, int sy, int dx, int dy, int midir, int m
void __fastcall miss_null_1D(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam)
{
int v9; // ecx
int v10; // eax
v9 = mi;
missile[v9]._midam = dam;
missile[v9]._mirange = 50;
v10 = 50 - missile[v9]._miAnimLen;
missile[v9]._mixvel = 0;
missile[v9]._miyvel = 0;
missile[v9]._miVar1 = v10;
missile[v9]._miVar2 = 0;
missile[mi]._midam = dam;
missile[mi]._mirange = 50;
missile[mi]._mixvel = 0;
missile[mi]._miyvel = 0;
missile[mi]._miVar1 = 50 - missile[mi]._miAnimLen;
missile[mi]._miVar2 = 0;
}
void __fastcall AddAcidpud(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam)
{
int v9; // esi
int v10; // edi
int v11; // eax
int monst;
v9 = mi;
v10 = missile[mi]._misource;
missile[v9]._mixvel = 0;
missile[v9]._miyvel = 0;
missile[v9]._mixoff = 0;
missile[v9]._miyoff = 0;
missile[v9]._miLightFlag = TRUE;
v11 = random(50, 15);
missile[v9]._miPreFlag = TRUE;
missile[v9]._mirange = v11 + 40 * ((unsigned char)monster[v10]._mint + 1);
monst = missile[mi]._misource;
missile[mi]._mixvel = 0;
missile[mi]._miyvel = 0;
missile[mi]._mixoff = 0;
missile[mi]._miyoff = 0;
missile[mi]._miLightFlag = TRUE;
missile[mi]._mirange = random(50, 15) + 40 * (monster[monst]._mint + 1);
missile[mi]._miPreFlag = TRUE;
}
void __fastcall AddStone(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam)
@ -2644,47 +2611,33 @@ void __fastcall AddBoom(int mi, int sx, int sy, int dx, int dy, int midir, int m
void __fastcall AddHeal(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam)
{
int v9; // esi
signed int v10; // ebx
int v12; // edi
int i; // ebx
int v15; // ecx
int *v16; // eax
int *v17; // eax
int v18; // esi
int v19; // [esp+Ch] [ebp-8h]
int v20; // [esp+10h] [ebp-4h]
v19 = mi;
v9 = id;
v10 = 0;
v12 = (random(57, 10) + 1) << 6;
if (plr[id]._pLevel > 0) {
do {
v12 += (random(57, 4) + 1) << 6;
++v10;
} while (v10 < plr[v9]._pLevel);
}
v20 = 0;
for (i = v19; v20 < missile[i]._mispllvl; ++v20) {
v12 += (random(57, 6) + 1) << 6;
}
if (plr[v9]._pClass == PC_WARRIOR)
v12 *= 2;
if (plr[v9]._pClass == PC_ROGUE)
v12 += v12 >> 1;
v15 = plr[v9]._pMaxHP;
v16 = &plr[v9]._pHitPoints;
*v16 += v12;
if (plr[v9]._pHitPoints > v15)
*v16 = v15;
v17 = &plr[v9]._pHPBase;
v18 = plr[v9]._pMaxHPBase;
*v17 += v12;
if (*v17 > v18)
*v17 = v18;
int i;
int HealAmount;
HealAmount = (random(57, 10) + 1) << 6;
for (i = 0; i < plr[id]._pLevel; i++) {
HealAmount += (random(57, 4) + 1) << 6;
}
for (i = 0; i < missile[mi]._mispllvl; i++) {
HealAmount += (random(57, 6) + 1) << 6;
}
if (plr[id]._pClass == PC_WARRIOR)
HealAmount += HealAmount;
if (plr[id]._pClass == PC_ROGUE)
HealAmount += HealAmount >> 1;
plr[id]._pHitPoints += HealAmount;
if (plr[id]._pHitPoints > plr[id]._pMaxHP)
plr[id]._pHitPoints = plr[id]._pMaxHP;
plr[id]._pHPBase += HealAmount;
if (plr[id]._pHPBase > plr[id]._pMaxHPBase)
plr[id]._pHPBase = plr[id]._pMaxHPBase;
UseMana(id, 2);
missile[i]._miDelFlag = TRUE;
missile[mi]._miDelFlag = TRUE;
drawhpflag = TRUE;
}
@ -3071,18 +3024,13 @@ void __fastcall AddBoneSpirit(int mi, int sx, int sy, int dx, int dy, int midir,
void __fastcall AddRportal(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam)
{
int v9; // eax
int v10; // edx
v9 = mi;
missile[v9]._miVar2 = 0;
missile[v9]._mix = sx;
missile[v9]._misx = sx;
missile[v9]._mirange = 100;
v10 = 100 - missile[mi]._miAnimLen;
missile[v9]._miy = sy;
missile[v9]._misy = sy;
missile[v9]._miVar1 = v10;
missile[mi]._mix = sx;
missile[mi]._miy = sy;
missile[mi]._misx = sx;
missile[mi]._misy = sy;
missile[mi]._miVar1 = 100 - missile[mi]._miAnimLen;
missile[mi]._miVar2 = 0;
missile[mi]._mirange = 100;
PutMissile(mi);
}
@ -3168,41 +3116,21 @@ int __fastcall AddMissile(int sx, int sy, int dx, int dy, int midir, int mitype,
int __fastcall Sentfire(int i, int sx, int sy)
{
int v3; // esi
int v4; // ebx
int v5; // edi
//int v6; // eax
int v7; // eax
int v8; // eax
int v9; // edi
int midir; // ST30_4
int v11; // ecx
int v12; // eax
//int v13; // edx
int mi; // [esp+Ch] [ebp-8h]
mi = i;
v3 = i;
v4 = sx;
v5 = 0;
//_LOBYTE(v6) = LineClear(missile[i]._mix, missile[i]._miy, sx, sy);
int ex, dir;
ex = 0;
if (LineClear(missile[i]._mix, missile[i]._miy, sx, sy)) {
v7 = dMonster[v4][sy];
if (v7 > 0 && monster[v7 - 1]._mhitpoints >> 6 > 0 && v7 - 1 > 3) /* fix monstactive */
{
v8 = GetDirection(missile[v3]._mix, missile[v3]._miy, v4, sy);
v9 = missile[v3]._misource;
midir = v8;
v11 = missile[v3]._misource;
missile[v3]._miVar3 = missileavail[0];
v12 = GetSpellLevel(v11, 1);
AddMissile(missile[v3]._mix, missile[v3]._miy, v4, sy, midir, MIS_FIREBOLT, 0, v9, missile[v3]._midam, v12); /* check mtype v13 */
v5 = -1;
SetMissDir(mi, 2);
missile[v3]._miVar2 = 3;
if (dMonster[sx][sy] > 0 && monster[dMonster[sx][sy] - 1]._mhitpoints >> 6 > 0 && dMonster[sx][sy] - 1 > 3) {
dir = GetDirection(missile[i]._mix, missile[i]._miy, sx, sy);
missile[i]._miVar3 = missileavail[0];
AddMissile(missile[i]._mix, missile[i]._miy, sx, sy, dir, MIS_FIREBOLT, 0, missile[i]._misource, missile[i]._midam, GetSpellLevel(missile[i]._misource, 1));
ex = -1;
SetMissDir(i, 2);
missile[i]._miVar2 = 3;
}
}
return v5;
return ex;
}
void __fastcall MI_Dummy(int i)
@ -3247,130 +3175,84 @@ void __fastcall MI_SetManashield(int i)
void __fastcall MI_LArrow(int i)
{
int v1; // esi
char v2; // al
int v3; // ebx
int v4; // eax
int v6; // edi
int v7; // ecx
int v8; // eax
int v9; // ecx
int v10; // edx
int v11; // ST0C_4
unsigned char *v12; // eax
unsigned char v13; // bl
int v14; // eax
int v15; // edx
int v16; // ecx
int v17; // ST10_4
int v18; // ecx
int v19; // edi
int v20; // eax
int v21; // eax
int v22; // ecx
int v23; // ST0C_4
int v24; // edi
int v25; // eax
int v26; // eax
int v27; // ecx
int v28; // ST10_4
int v29; // ecx
unsigned char v32; // [esp+Ch] [ebp-8h]
int ia; // [esp+10h] [ebp-4h]
int p, mind, maxd, rst;
v1 = i;
ia = i;
v2 = missile[i]._miAnimType;
--missile[v1]._mirange;
v3 = missile[i]._misource;
if (v2 == MFILE_MINILTNG || v2 == MFILE_MAGBLOS) {
ChangeLight(missile[v1]._mlid, missile[v1]._mix, missile[v1]._miy, missile[v1]._miAnimFrame + 5);
v18 = missiledata[missile[v1]._mitype].mResist;
v32 = missiledata[missile[v1]._mitype].mResist;
if (missile[v1]._mitype == MIS_LARROW) {
if (v3 == -1) {
v21 = random(68, 10);
v22 = currlevel;
v19 = v21 + currlevel + 1;
v20 = random(68, 10) + 2 * currlevel + 1;
missile[i]._mirange--;
p = missile[i]._misource;
if (missile[i]._miAnimType == MFILE_MINILTNG || missile[i]._miAnimType == MFILE_MAGBLOS) {
ChangeLight(missile[i]._mlid, missile[i]._mix, missile[i]._miy, missile[i]._miAnimFrame + 5);
rst = missiledata[missile[i]._mitype].mResist;
if (missile[i]._mitype == MIS_LARROW) {
if (p != -1) {
mind = plr[p]._pILMinDam;
maxd = plr[p]._pILMaxDam;
} else {
v19 = plr[v3]._pILMinDam;
v20 = plr[v3]._pILMaxDam;
mind = random(68, 10) + 1 + currlevel;
maxd = random(68, 10) + 1 + currlevel * 2;
}
v23 = missile[v1]._miy;
missiledata[MIS_LARROW].mResist = MISR_LIGHTNING;
CheckMissileCol(ia, v19, v20, 0, missile[v1]._mix, v23, 1);
CheckMissileCol(i, mind, maxd, 0, missile[i]._mix, missile[i]._miy, 1);
}
if (missile[v1]._mitype == MIS_FARROW) {
if (v3 == -1) {
v26 = random(68, 10);
v27 = currlevel;
v24 = v26 + currlevel + 1;
v25 = random(68, 10) + 2 * currlevel + 1;
if (missile[i]._mitype == MIS_FARROW) {
if (p != -1) {
mind = plr[p]._pIFMinDam;
maxd = plr[p]._pIFMaxDam;
} else {
v24 = plr[v3]._pIFMinDam;
v25 = plr[v3]._pIFMaxDam;
mind = random(68, 10) + 1 + currlevel;
maxd = random(68, 10) + 1 + currlevel * 2;
}
v28 = missile[v1]._miy;
missiledata[MIS_FARROW].mResist = MISR_FIRE;
CheckMissileCol(ia, v24, v25, 0, missile[v1]._mix, v28, 1);
CheckMissileCol(i, mind, maxd, 0, missile[i]._mix, missile[i]._miy, 1);
}
missiledata[missile[v1]._mitype].mResist = v32;
missiledata[missile[i]._mitype].mResist = rst;
} else {
v4 = missile[v1]._mixvel;
++missile[v1]._midist;
missile[v1]._mitxoff += v4;
missile[v1]._mityoff += missile[v1]._miyvel;
missile[i]._midist++;
missile[i]._mitxoff += missile[i]._mixvel;
missile[i]._mityoff += missile[i]._miyvel;
GetMissilePos(i);
if (v3 == -1) {
v8 = random(68, 10);
v9 = currlevel;
v6 = v8 + currlevel + 1;
v7 = random(68, 10) + 2 * currlevel + 1;
} else if (missile[v1]._micaster) {
v6 = (unsigned char)monster[v3].mMinDamage;
v7 = (unsigned char)monster[v3].mMaxDamage;
if (p != -1) {
if (!missile[i]._micaster) {
mind = plr[p]._pIMinDam;
maxd = plr[p]._pIMaxDam;
} else {
mind = monster[p].mMinDamage;
maxd = monster[p].mMaxDamage;
}
} else {
v6 = plr[v3]._pIMinDam;
v7 = plr[v3]._pIMaxDam;
mind = random(68, 10) + 1 + currlevel;
maxd = random(68, 10) + 1 + currlevel * 2;
}
v10 = missile[v1]._mix;
if (v10 != missile[v1]._misx || missile[v1]._miy != missile[v1]._misy) {
v11 = missile[v1]._miy;
v12 = &missiledata[missile[v1]._mitype].mResist;
v13 = *v12;
*v12 = 0;
CheckMissileCol(ia, v6, v7, 0, v10, v11, 0);
missiledata[missile[v1]._mitype].mResist = v13;
if (missile[i]._mix != missile[i]._misx || missile[i]._miy != missile[i]._misy) {
rst = missiledata[missile[i]._mitype].mResist;
missiledata[missile[i]._mitype].mResist = 0;
CheckMissileCol(i, mind, maxd, 0, missile[i]._mix, missile[i]._miy, 0);
missiledata[missile[i]._mitype].mResist = rst;
}
if (missile[v1]._mirange) {
v15 = missile[v1]._mix;
if (v15 != missile[v1]._miVar1 || missile[v1]._miy != missile[v1]._miVar2) {
v16 = missile[v1]._mlid;
missile[v1]._miVar1 = v15;
v17 = missile[v1]._miy;
missile[v1]._miVar2 = v17;
ChangeLight(v16, v15, v17, 5);
}
} else {
missile[v1]._mitxoff -= missile[v1]._mixvel;
v14 = missile[v1]._miyvel;
missile[v1]._mimfnum = 0;
missile[v1]._mityoff -= v14;
GetMissilePos(ia);
if (missile[v1]._mitype == MIS_LARROW)
SetMissAnim(ia, MFILE_MINILTNG);
if (!missile[i]._mirange) {
missile[i]._mimfnum = 0;
missile[i]._mitxoff -= missile[i]._mixvel;
missile[i]._mityoff -= missile[i]._miyvel;
GetMissilePos(i);
if (missile[i]._mitype == MIS_LARROW)
SetMissAnim(i, MFILE_MINILTNG);
else
SetMissAnim(ia, MFILE_MAGBLOS);
missile[v1]._mirange = missile[v1]._miAnimLen - 1;
SetMissAnim(i, MFILE_MAGBLOS);
missile[i]._mirange = missile[i]._miAnimLen - 1;
} else {
if (missile[i]._mix != missile[i]._miVar1 || missile[i]._miy != missile[i]._miVar2) {
missile[i]._miVar1 = missile[i]._mix;
missile[i]._miVar2 = missile[i]._miy;
ChangeLight(missile[i]._mlid, missile[i]._mix, missile[i]._miy, 5);
}
}
}
if (!missile[v1]._mirange) {
v29 = missile[v1]._mlid;
missile[v1]._miDelFlag = TRUE;
AddUnLight(v29);
if (!missile[i]._mirange) {
missile[i]._miDelFlag = TRUE;
AddUnLight(missile[i]._mlid);
}
PutMissile(ia);
PutMissile(i);
}
void __fastcall MI_Arrow(int i)
@ -4407,69 +4289,48 @@ void __fastcall MI_Boom(int i)
void __fastcall MI_Rhino(int i)
{
int v1; // ebx
int v2; // esi
int v3; // edi
int v4; // edi
int v5; // eax
int v6; // eax
int v7; // ebx
BOOLEAN v8; // zf
int x; // [esp+Ch] [ebp-1Ch]
int v10; // [esp+10h] [ebp-18h]
int y; // [esp+14h] [ebp-14h]
int a2; // [esp+18h] [ebp-10h]
int a3; // [esp+1Ch] [ebp-Ch]
int arglist; // [esp+20h] [ebp-8h]
int a1; // [esp+24h] [ebp-4h]
int mix, miy, mix2, miy2, omx, omy, monst;
v1 = i;
v2 = i;
arglist = i;
v3 = missile[i]._misource;
a1 = v3;
v4 = v3;
if (monster[v4]._mmode != MM_CHARGE)
goto LABEL_12;
monst = missile[i]._misource;
if (monster[monst]._mmode != MM_CHARGE) {
missile[i]._miDelFlag = TRUE;
return;
}
GetMissilePos(i);
v5 = missile[v2]._mix;
x = v5;
v10 = missile[v2]._miy;
dMonster[v5][v10] = 0;
v6 = missile[v2]._mixvel;
if (monster[v4]._mAi == AI_SNAKE) {
missile[v2]._mitxoff += 2 * v6;
missile[v2]._mityoff += 2 * missile[v2]._miyvel;
GetMissilePos(v1);
a2 = missile[v2]._mix;
a3 = missile[v2]._miy;
missile[v2]._mitxoff -= missile[v2]._mixvel;
missile[v2]._mityoff -= missile[v2]._miyvel;
mix = missile[i]._mix;
miy = missile[i]._miy;
dMonster[mix][miy] = 0;
if (monster[monst]._mAi == AI_SNAKE) {
missile[i]._mitxoff += 2 * missile[i]._mixvel;
missile[i]._mityoff += 2 * missile[i]._miyvel;
GetMissilePos(i);
mix2 = missile[i]._mix;
miy2 = missile[i]._miy;
missile[i]._mitxoff -= missile[i]._mixvel;
missile[i]._mityoff -= missile[i]._miyvel;
} else {
missile[v2]._mitxoff += v6;
missile[v2]._mityoff += missile[v2]._miyvel;
missile[i]._mitxoff += missile[i]._mixvel;
missile[i]._mityoff += missile[i]._miyvel;
}
GetMissilePos(v1);
v7 = missile[v2]._mix;
y = missile[v2]._miy;
if (!PosOkMonst(a1, missile[v2]._mix, missile[v2]._miy) || monster[v4]._mAi == AI_SNAKE && !PosOkMonst(a1, a2, a3)) {
MissToMonst(arglist, x, v10);
LABEL_12:
missile[v2]._miDelFlag = TRUE;
GetMissilePos(i);
omx = missile[i]._mix;
omy = missile[i]._miy;
if (!PosOkMonst(monst, missile[i]._mix, missile[i]._miy) || (monster[monst]._mAi == AI_SNAKE && !PosOkMonst(monst, mix2, miy2))) {
MissToMonst(i, mix, miy);
missile[i]._miDelFlag = TRUE;
return;
}
v8 = monster[v4]._uniqtype == 0;
monster[v4]._mfutx = v7;
monster[v4]._moldx = v7;
dMonster[v7][y] = -1 - a1;
monster[v4]._mx = v7;
monster[v4]._mfuty = y;
monster[v4]._moldy = y;
monster[v4]._my = y;
if (!v8)
ChangeLightXY(missile[v2]._mlid, v7, y);
MoveMissilePos(arglist);
PutMissile(arglist);
monster[monst]._mfutx = omx;
monster[monst]._moldx = omx;
dMonster[omx][omy] = -1 - monst;
monster[monst]._mx = omx;
monster[monst]._mfuty = omy;
monster[monst]._moldy = omy;
monster[monst]._my = omy;
if (monster[monst]._uniqtype != 0)
ChangeLightXY(missile[i]._mlid, omx, omy);
MoveMissilePos(i);
PutMissile(i);
}
void __fastcall mi_null_32(int i)
@ -4850,7 +4711,7 @@ void __fastcall MI_Flamec(int i)
void __fastcall MI_Cbolt(int i)
{
int sx, sy, dy, md;
int md;
int bpath[16] = { -1, 0, 1, -1, 0, 1, -1, -1, 0, 0, 1, 1, 0, 1, -1, 0 };
missile[i]._mirange--;

26
Source/stores.cpp

@ -703,33 +703,23 @@ void __fastcall PrintStoreItem(ItemStruct *x, int l, char iclr)
void __cdecl S_StartSBuy()
{
int v0; // ST10_4
int v1; // eax
int *v2; // ecx
int i;
v0 = plr[myplr]._pGold;
stextsize = 1;
stextscrl = 1;
stextsval = 0;
sprintf(tempstr, "I have these items for sale : Your gold : %i", v0);
AddSText(0, 1, 1u, tempstr, COL_GOLD, 0);
sprintf(tempstr, "I have these items for sale : Your gold : %i", plr[myplr]._pGold);
AddSText(0, 1, 1, tempstr, COL_GOLD, 0);
AddSLine(3);
AddSLine(21);
S_ScrollSBuy(stextsval);
AddSText(0, 22, 1u, "Back", COL_WHITE, 0);
AddSText(0, 22, 1, "Back", COL_WHITE, 0);
OffsetSTextY(22, 6);
v1 = 0;
storenumh = 0;
if (smithitem[0]._itype != -1) {
v2 = &smithitem[0]._itype;
do {
v2 += 92;
++v1;
} while (*v2 != -1);
storenumh = v1;
}
stextsmax = v1 - 4;
if (v1 - 4 < 0)
for (i = 0; smithitem[i]._itype != -1; i++)
storenumh++;
stextsmax = storenumh - 4;
if (stextsmax < 0)
stextsmax = 0;
}
// 69F10C: using guessed type int storenumh;

36
Source/trigs.cpp

@ -964,33 +964,17 @@ LABEL_17:
void __cdecl Freeupstairs()
{
int *v0; // ecx
int v1; // ebx
char *v2; // eax
signed int v3; // edi
char *v4; // edx
signed int v5; // esi
int i, yy, xx, tx, ty;
if (trigflag[4] > 0) {
v0 = &trigs[0]._ty;
v1 = trigflag[4];
do {
v2 = &dFlags[*(v0 - 1) - 2][*v0 - 2]; /* v2 = &nBlockTable[112 * *(v0 - 1) + 1830 + *v0]; check */
v3 = 5;
do {
v4 = v2;
v5 = 5;
do {
*v4 |= DFLAG_POPULATED;
v4 += 112;
--v5;
} while (v5);
++v2;
--v3;
} while (v3);
v0 += 4;
--v1;
} while (v1);
for (i = 0; i < trigflag[4]; i++) {
tx = trigs[i]._tx;
ty = trigs[i]._ty;
for (yy = 0; yy < MAXTRIGGERS; yy++) {
for (xx = 0; xx < MAXTRIGGERS; xx++) {
dFlags[tx - 2 + xx][ty - 2 + yy] |= DFLAG_POPULATED;
}
}
}
}

3
types.h

@ -75,9 +75,6 @@ DEVILUTION_BEGIN_NAMESPACE
// Will be replaced with [rep movsd] if optimization is used
#define FAST_MEMCPY
/* temp macro for asm XLAT */
#define ASM_XLAT(eax, ebx) eax = (eax & 0xFFFFFF00) + LOBYTE(ebx[LOBYTE(eax)])
// header files
//#ifdef __cplusplus
//extern "C" {

Loading…
Cancel
Save