Browse Source

Merge branch 'master'

pull/35/head
Xadhoom 7 years ago
parent
commit
83d902c4a4
  1. 1
      CMakeLists.txt
  2. 305
      Source/control.cpp
  3. 4
      Source/control.h
  4. 2
      Source/doom.cpp
  5. 3524
      Source/engine.cpp
  6. 58
      Source/engine.h
  7. 16
      Source/error.cpp
  8. 88
      Source/gendung.cpp
  9. 12
      Source/gmenu.cpp
  10. 2
      Source/interfac.cpp
  11. 20
      Source/inv.cpp
  12. 2
      Source/items.cpp
  13. 2
      Source/minitext.cpp
  14. 997
      Source/missiles.cpp
  15. 2
      Source/missiles.h
  16. 31
      Source/mpqapi.cpp
  17. 2
      Source/mpqapi.h
  18. 6
      Source/quests.cpp
  19. 976
      Source/scrollrt.cpp
  20. 20
      Source/scrollrt.h
  21. 19
      Source/sound.cpp
  22. 18
      Source/stores.cpp
  23. 42
      Source/town.cpp
  24. 87
      SourceS/miniwin/com/dsound.inc
  25. 2
      SourceS/miniwin/misc.h
  26. 26
      SourceX/dx.cpp
  27. 121
      SourceX/miniwin_dsound.cpp
  28. 20
      SourceX/pch.h
  29. 221
      SourceX/sound.cpp

1
CMakeLists.txt

@ -159,6 +159,7 @@ add_executable(devilutionx
SourceX/miniwin/misc_msg.cpp
SourceX/miniwin/rand.cpp
SourceX/miniwin/thread.cpp
SourceX/miniwin_dsound.cpp
SourceX/sound.cpp
SourceX/storm.cpp
SourceX/storm_net.cpp

305
Source/control.cpp

@ -53,7 +53,7 @@ int numpanbtns; // weak
void *pStatusPanel;
char panelstr[256];
int panelflag; // weak
unsigned char splTrans[256];
unsigned char SplTransTbl[256];
int initialDropGoldValue; // idb
void *pSpellCels;
int panbtndown; // weak
@ -185,79 +185,129 @@ int SpellPages[6][7] = {
{ -1, -1, -1, -1, -1, -1, -1 }
};
void __fastcall DrawSpellCel(int xp, int yp, char *Trans, int nCel, int w)
{
char *v5; // ebx
char *v6; // esi
char *v7; // edi
int v9; // edx
unsigned int v10; // eax
unsigned int v11; // ecx
char v14; // cf
unsigned int v15; // ecx
INT_PTR v18; // [esp+Ch] [ebp-Ch]
int _EAX;
unsigned char *_EBX;
v5 = &Trans[4 * nCel];
v6 = &Trans[*(_DWORD *)v5];
v7 = (char *)gpBuffer + screen_y_times_768[yp] + xp;
v18 = (INT_PTR)&v6[*((_DWORD *)v5 + 1) - *(_DWORD *)v5];
_EBX = splTrans;
do {
v9 = w;
do {
while (1) {
v10 = (unsigned char)*v6++;
if ((v10 & 0x80u) == 0)
break;
_LOBYTE(v10) = -(char)v10;
v7 += v10;
v9 -= v10;
if (!v9)
goto LABEL_12;
}
v9 -= v10;
v11 = v10 >> 1;
if (v10 & 1) {
_EAX = *v6++;
ASM_XLAT(_EAX, _EBX);
*v7++ = _EAX;
if (!v11)
continue;
}
v14 = v11 & 1;
v15 = v11 >> 1;
if (!v14)
goto LABEL_15;
_EAX = *(_WORD *)v6;
v6 += 2;
ASM_XLAT(_EAX, _EBX);
_EAX = __ROR2__(_EAX, 8);
ASM_XLAT(_EAX, _EBX);
*(_WORD *)v7 = __ROR2__(_EAX, 8);
v7 += 2;
if (v15) {
LABEL_15:
do {
_EAX = *(_DWORD *)v6;
v6 += 4;
ASM_XLAT(_EAX, _EBX);
_EAX = _rotr(_EAX, 8);
ASM_XLAT(_EAX, _EBX);
_EAX = _rotr(_EAX, 8);
ASM_XLAT(_EAX, _EBX);
_EAX = _rotr(_EAX, 8);
ASM_XLAT(_EAX, _EBX);
*(_DWORD *)v7 = _rotr(_EAX, 8);
v7 += 4;
--v15;
} while (v15);
void __fastcall DrawSpellCel(int xp, int yp, BYTE *Trans, int nCel, int w)
{
BYTE *tmp, *dst, *tbl, *end;
/// ASSERT: assert(gpBuffer);
tmp = (BYTE *)gpBuffer; /* remove when fixed */
dst = &tmp[screen_y_times_768[yp] + xp];
tbl = SplTransTbl;
#if (_MSC_VER >= 800) && (_MSC_VER <= 1200)
__asm {
mov ebx, Trans
mov eax, nCel
shl eax, 2
add ebx, eax
mov eax, [ebx+4]
sub eax, [ebx]
mov end, eax
mov esi, Trans
add esi, [ebx]
mov edi, dst
mov eax, end
add eax, esi
mov end, eax
mov ebx, tbl
label1:
mov edx, w
label2:
xor eax, eax
lodsb
or al, al
js label6
sub edx, eax
mov ecx, eax
shr ecx, 1
jnb label3
lodsb
xlat
stosb
jecxz label5
label3:
shr ecx, 1
jnb label4
lodsw
xlat
ror ax, 8
xlat
ror ax, 8
stosw
jecxz label5
label4:
lodsd
xlat
ror eax, 8
xlat
ror eax, 8
xlat
ror eax, 8
xlat
ror eax, 8
stosd
loop label4
label5:
or edx, edx
jz label7
jmp label2
label6:
neg al
add edi, eax
sub edx, eax
jnz label2
label7:
sub edi, 768
sub edi, w
cmp esi, end
jnz label1
}
#else
int i;
BYTE width;
BYTE *src;
DWORD *pFrameTable;
pFrameTable = (DWORD *)&Trans[4 * nCel];
src = &Trans[pFrameTable[0]];
end = &src[pFrameTable[1] - pFrameTable[0]];
for(; src != end; dst -= 768 + w) {
for(i = w; i;) {
width = *src++;
if(!(width & 0x80)) {
i -= width;
// asm_cel_light_edge(width, tbl, dst, src);
if(width & 1) {
dst[0] = tbl[src[0]];
src++;
dst++;
}
width >>= 1;
if(width & 1) {
dst[0] = tbl[src[0]];
dst[1] = tbl[src[1]];
src += 2;
dst += 2;
}
width >>= 1;
for(; width; width--) {
dst[0] = tbl[src[0]];
dst[1] = tbl[src[1]];
dst[2] = tbl[src[2]];
dst[3] = tbl[src[3]];
src += 4;
dst += 4;
}
} else {
width = -(char)width;
dst += width;
i -= width;
}
} while (v9);
LABEL_12:
v7 = &v7[-w - 768];
} while (v6 != (char *)v18);
}
}
#endif
}
void __fastcall SetSpellTrans(char t)
@ -266,53 +316,54 @@ void __fastcall SetSpellTrans(char t)
if (t == RSPLTYPE_SKILL) {
for (i = 0; i < 128; i++)
splTrans[i] = i;
SplTransTbl[i] = i;
}
for (i = 128; i < 256; i++)
splTrans[i] = i;
splTrans[255] = 0;
SplTransTbl[i] = i;
SplTransTbl[255] = 0;
switch (t) {
case RSPLTYPE_SPELL:
splTrans[PAL8_YELLOW] = PAL16_BLUE + 1;
splTrans[PAL8_YELLOW + 1] = PAL16_BLUE + 3;
splTrans[PAL8_YELLOW + 2] = PAL16_BLUE + 5;
SplTransTbl[PAL8_YELLOW] = PAL16_BLUE + 1;
SplTransTbl[PAL8_YELLOW + 1] = PAL16_BLUE + 3;
SplTransTbl[PAL8_YELLOW + 2] = PAL16_BLUE + 5;
for (i = PAL16_BLUE; i < PAL16_BLUE + 16; i++) {
splTrans[PAL16_BEIGE - PAL16_BLUE + i] = i;
splTrans[PAL16_YELLOW - PAL16_BLUE + i] = i;
splTrans[PAL16_ORANGE - PAL16_BLUE + i] = i;
SplTransTbl[PAL16_BEIGE - PAL16_BLUE + i] = i;
SplTransTbl[PAL16_YELLOW - PAL16_BLUE + i] = i;
SplTransTbl[PAL16_ORANGE - PAL16_BLUE + i] = i;
}
return;
break;
case RSPLTYPE_SCROLL:
splTrans[PAL8_YELLOW] = PAL16_BEIGE + 1;
splTrans[PAL8_YELLOW + 1] = PAL16_BEIGE + 3;
splTrans[PAL8_YELLOW + 2] = PAL16_BEIGE + 5;
SplTransTbl[PAL8_YELLOW] = PAL16_BEIGE + 1;
SplTransTbl[PAL8_YELLOW + 1] = PAL16_BEIGE + 3;
SplTransTbl[PAL8_YELLOW + 2] = PAL16_BEIGE + 5;
for (i = PAL16_BEIGE; i < PAL16_BEIGE + 16; i++) {
splTrans[PAL16_YELLOW - PAL16_BEIGE + i] = i;
splTrans[PAL16_ORANGE - PAL16_BEIGE + i] = i;
SplTransTbl[PAL16_YELLOW - PAL16_BEIGE + i] = i;
SplTransTbl[PAL16_ORANGE - PAL16_BEIGE + i] = i;
}
return;
break;
case RSPLTYPE_CHARGES:
splTrans[PAL8_YELLOW] = PAL16_ORANGE + 1;
splTrans[PAL8_YELLOW + 1] = PAL16_ORANGE + 3;
splTrans[PAL8_YELLOW + 2] = PAL16_ORANGE + 5;
SplTransTbl[PAL8_YELLOW] = PAL16_ORANGE + 1;
SplTransTbl[PAL8_YELLOW + 1] = PAL16_ORANGE + 3;
SplTransTbl[PAL8_YELLOW + 2] = PAL16_ORANGE + 5;
for (i = PAL16_ORANGE; i < PAL16_ORANGE + 16; i++) {
splTrans[PAL16_BEIGE - PAL16_ORANGE + i] = i;
splTrans[PAL16_YELLOW - PAL16_ORANGE + i] = i;
SplTransTbl[PAL16_BEIGE - PAL16_ORANGE + i] = i;
SplTransTbl[PAL16_YELLOW - PAL16_ORANGE + i] = i;
}
return;
break;
case RSPLTYPE_INVALID:
splTrans[PAL8_YELLOW] = PAL16_GRAY + 1;
splTrans[PAL8_YELLOW + 1] = PAL16_GRAY + 3;
splTrans[PAL8_YELLOW + 2] = PAL16_GRAY + 5;
SplTransTbl[PAL8_YELLOW] = PAL16_GRAY + 1;
SplTransTbl[PAL8_YELLOW + 1] = PAL16_GRAY + 3;
SplTransTbl[PAL8_YELLOW + 2] = PAL16_GRAY + 5;
for (i = PAL16_GRAY; i < PAL16_GRAY + 15; i++) {
splTrans[PAL16_BEIGE - PAL16_GRAY + i] = i;
splTrans[PAL16_YELLOW - PAL16_GRAY + i] = i;
splTrans[PAL16_ORANGE - PAL16_GRAY + i] = i;
SplTransTbl[PAL16_BEIGE - PAL16_GRAY + i] = i;
SplTransTbl[PAL16_YELLOW - PAL16_GRAY + i] = i;
SplTransTbl[PAL16_ORANGE - PAL16_GRAY + i] = i;
}
splTrans[PAL16_BEIGE + 15] = 0;
splTrans[PAL16_YELLOW + 15] = 0;
splTrans[PAL16_ORANGE + 15] = 0;
SplTransTbl[PAL16_BEIGE + 15] = 0;
SplTransTbl[PAL16_YELLOW + 15] = 0;
SplTransTbl[PAL16_ORANGE + 15] = 0;
break;
}
}
@ -344,9 +395,9 @@ void __cdecl DrawSpell()
v2 = RSPLTYPE_INVALID;
SetSpellTrans(v2);
if (v6 == -1)
DrawSpellCel(629, 631, (char *)pSpellCels, 27, 56);
DrawSpellCel(629, 631, (BYTE *)pSpellCels, 27, 56);
else
DrawSpellCel(629, 631, (char *)pSpellCels, (char)SpellITbl[v3], 56);
DrawSpellCel(629, 631, (BYTE *)pSpellCels, (char)SpellITbl[v3], 56);
}
void __cdecl DrawSpellList()
@ -432,11 +483,11 @@ void __cdecl DrawSpellList()
}
if (!currlevel && !*v20)
SetSpellTrans(RSPLTYPE_INVALID);
DrawSpellCel(v17, xp, (char *)pSpellCels, (char)SpellITbl[v4], 56);
DrawSpellCel(v17, xp, (BYTE *)pSpellCels, (char)SpellITbl[v4], 56);
if (MouseX >= v17 - 64 && MouseX < v17 - 64 + 56 && MouseY >= v22 && MouseY < v22 + 56) {
pSpell = v4;
pSplType = v1;
DrawSpellCel(v17, xp, (char *)pSpellCels, yp, 56);
DrawSpellCel(v17, xp, (BYTE *)pSpellCels, yp, 56);
if (v1) {
switch (v1) {
case RSPLTYPE_SPELL:
@ -502,7 +553,7 @@ void __cdecl DrawSpellList()
v16 = 0;
do {
if (plr[v0]._pSplHotKey[v16] == pSpell && plr[v0]._pSplTHotKey[v16] == pSplType) {
DrawSpellCel(v17, xp, (char *)pSpellCels, v16 + 48, 56);
DrawSpellCel(v17, xp, (BYTE *)pSpellCels, v16 + 48, 56);
sprintf(tempstr, "Spell Hot Key #F%i", v16 + 5);
AddPanelString(tempstr, 1);
v0 = myplr;
@ -1069,19 +1120,19 @@ void __cdecl DrawCtrlPan()
do {
v2 = *v1;
if (panbtn[v0])
CelDecodeOnly(v2 + 64, v1[1] + 178, pPanelButtons, v0 + 1, 71);
CelDecodeOnly(v2 + 64, v1[1] + 178, (BYTE *)pPanelButtons, v0 + 1, 71);
else
DrawPanelBox(v2, v1[1] - 336, 71, 20, v2 + 64, v1[1] + 160);
++v0;
v1 += 5;
} while (v0 < 6);
if (numpanbtns == 8) {
CelDecodeOnly(151, 634, pMultiBtns, panbtn[6] + 1, 33);
CelDecodeOnly(151, 634, (BYTE *)pMultiBtns, panbtn[6] + 1, 33);
if (FriendlyMode)
v3 = panbtn[7] + 3;
else
v3 = panbtn[7] + 5;
CelDecodeOnly(591, 634, pMultiBtns, v3, 33);
CelDecodeOnly(591, 634, (BYTE *)pMultiBtns, v3, 33);
}
}
// 484368: using guessed type int FriendlyMode;
@ -1725,7 +1776,7 @@ void __cdecl DrawChr()
int v30; // [esp+54h] [ebp-8h]
char a5[4]; // [esp+58h] [ebp-4h]
CelDecodeOnly(64, 511, pChrPanel, 1, 320);
CelDecodeOnly(64, 511, (BYTE *)pChrPanel, 1, 320);
ADD_PlrStringXY(20, 32, 151, plr[myplr]._pName, 0);
if (plr[myplr]._pClass == PC_WARRIOR) {
ADD_PlrStringXY(168, 32, 299, "Warrior", 0);
@ -1888,13 +1939,13 @@ void __cdecl DrawChr()
ADD_PlrStringXY(95, 266, 126, a4, 2);
v22 = plr[myplr]._pClass;
if (plr[myplr]._pBaseStr < MaxStats[v22][ATTRIB_STR])
CelDecodeOnly(201, 319, pChrButtons, chrbtn[0] + 2, 41);
CelDecodeOnly(201, 319, (BYTE *)pChrButtons, chrbtn[0] + 2, 41);
if (plr[myplr]._pBaseMag < MaxStats[v22][ATTRIB_MAG])
CelDecodeOnly(201, 347, pChrButtons, chrbtn[1] + 4, 41);
CelDecodeOnly(201, 347, (BYTE *)pChrButtons, chrbtn[1] + 4, 41);
if (plr[myplr]._pBaseDex < MaxStats[v22][ATTRIB_DEX])
CelDecodeOnly(201, 376, pChrButtons, chrbtn[2] + 6, 41);
CelDecodeOnly(201, 376, (BYTE *)pChrButtons, chrbtn[2] + 6, 41);
if (plr[myplr]._pBaseVit < MaxStats[v22][ATTRIB_VIT])
CelDecodeOnly(201, 404, pChrButtons, chrbtn[3] + 8, 41);
CelDecodeOnly(201, 404, (BYTE *)pChrButtons, chrbtn[3] + 8, 41);
}
v23 = plr[myplr]._pMaxHP;
a5[0] = v23 > plr[myplr]._pMaxHPBase;
@ -2030,7 +2081,7 @@ void __cdecl DrawLevelUpIcon()
if (!stextflag) {
v0 = (lvlbtndown != 0) + 2;
ADD_PlrStringXY(0, 303, 120, "Level Up", 0);
CelDecodeOnly(104, 495, pChrButtons, v0, 41);
CelDecodeOnly(104, 495, (BYTE *)pChrButtons, v0, 41);
}
}
// 4B851C: using guessed type int lvlbtndown;
@ -2198,7 +2249,7 @@ int __fastcall DrawDurIcon4Item(ItemStruct *pItem, int x, int c)
LABEL_18:
if (v5 > 2)
v7 += 8;
CelDecodeOnly(v4, 495, pDurIcons, v7, 32);
CelDecodeOnly(v4, 495, (BYTE *)pDurIcons, v7, 32);
return v4 - 40;
}
@ -2290,8 +2341,8 @@ void __cdecl DrawSpellBook()
int v11; // [esp+18h] [ebp-10h]
int v12; // [esp+1Ch] [ebp-Ch]
CelDecodeOnly(384, 511, pSpellBkCel, 1, 320);
CelDecodeOnly(76 * sbooktab + 391, 508, pSBkBtnCel, sbooktab + 1, 76);
CelDecodeOnly(384, 511, (BYTE *)pSpellBkCel, 1, 320);
CelDecodeOnly(76 * sbooktab + 391, 508, (BYTE *)pSBkBtnCel, sbooktab + 1, 76);
v9 = 1;
v8 = 214;
v0 = plr[myplr]._pISpells | plr[myplr]._pMemSpells | plr[myplr]._pAblSpells;
@ -2301,10 +2352,10 @@ void __cdecl DrawSpellBook()
if (v2 != -1 && (v1 & v0)) {
v7 = GetSBookTrans(v2, TRUE);
SetSpellTrans(v7);
DrawSpellCel(395, v8 + 1, (char *)pSBkIconCels, (char)SpellITbl[v2], MAX_SPELLS);
DrawSpellCel(395, v8 + 1, (BYTE *)pSBkIconCels, (char)SpellITbl[v2], MAX_SPELLS);
if (v2 == plr[myplr]._pRSpell && v7 == _LOBYTE(plr[myplr]._pRSplType)) {
SetSpellTrans(RSPLTYPE_SKILL);
DrawSpellCel(395, v8 + 1, (char *)pSBkIconCels, 43, MAX_SPELLS);
DrawSpellCel(395, v8 + 1, (BYTE *)pSBkIconCels, 43, MAX_SPELLS);
}
PrintSBookStr(10, v8 - 22, 0, spelldata[v2].sNameText, 0);
v3 = GetSBookTrans(v2, FALSE);
@ -2433,7 +2484,7 @@ void __fastcall DrawGoldSplit(int amount)
screen_x = 0;
v1 = amount;
CelDecodeOnly(415, 338, pGBoxBuff, 1, 261);
CelDecodeOnly(415, 338, (BYTE *)pGBoxBuff, 1, 261);
sprintf(tempstr, "You have %u gold", initialDropGoldValue);
ADD_PlrStringXY(366, 87, 600, tempstr, 3);
v2 = get_pieces_str(initialDropGoldValue);
@ -2452,7 +2503,7 @@ void __fastcall DrawGoldSplit(int amount)
}
screen_xa = screen_x + 452;
}
CelDecodeOnly(screen_xa, 300, pCelBuff, frame_4B8800, 12);
CelDecodeOnly(screen_xa, 300, (BYTE *)pCelBuff, frame_4B8800, 12);
frame_4B8800 = (frame_4B8800 & 7) + 1;
}
@ -2600,7 +2651,7 @@ void __cdecl DrawTalkPan()
} while (v4 < 39);
*v3 = 0;
LABEL_10:
CelDecDatOnly((char *)gpBuffer + a4, (char *)pCelBuff, frame, 12);
CelDecDatOnly((BYTE *)gpBuffer + a4, (BYTE *)pCelBuff, frame, 12);
v5 = 0;
a1 = plr[0]._pName;
v10 = 0;
@ -2628,7 +2679,7 @@ void __cdecl DrawTalkPan()
if (talkbtndown[v5])
v7 = (v5 != 0) + 5;
}
CelDecodeOnly(236, 18 * v5 + 596, pTalkBtns, v7, 61);
CelDecodeOnly(236, 18 * v5 + 596, (BYTE *)pTalkBtns, v7, 61);
goto LABEL_18;
}
}

4
Source/control.h

@ -46,14 +46,14 @@ extern int numpanbtns; // weak
extern void *pStatusPanel;
extern char panelstr[256];
extern int panelflag; // weak
extern unsigned char spell_trans[256];
extern unsigned char SplTransTbl[256];
extern int initialDropGoldValue; // idb
extern void *pSpellCels;
extern int panbtndown; // weak
extern void *pTalkPanel; // idb
extern int spselflag; // weak
void __fastcall DrawSpellCel(int xp, int yp, char *Trans, int nCel, int w);
void __fastcall DrawSpellCel(int xp, int yp, BYTE *Trans, int nCel, int w);
void __fastcall SetSpellTrans(char t);
void __cdecl DrawSpell();
void __cdecl DrawSpellList();

2
Source/doom.cpp

@ -97,7 +97,7 @@ void __cdecl doom_draw()
}
}
CelDecodeOnly(64, 511, pDoomCel, 1, 640);
CelDecodeOnly(64, 511, (BYTE *)pDoomCel, 1, 640);
}
DEVILUTION_END_NAMESPACE

3524
Source/engine.cpp

File diff suppressed because it is too large Load Diff

58
Source/engine.h

@ -11,24 +11,22 @@ extern int orgseed; // weak
extern int SeedCount; // weak
extern int dword_52B99C; // bool valid - if x/y are in bounds
void __fastcall CelDrawDatOnly(char *pDecodeTo, char *pRLEBytes, int dwRLESize, int dwRLEWdt);
void __fastcall CelDecodeOnly(int screen_x, int screen_y, void *pCelBuff, int frame, int frame_width);
void __fastcall CelDecDatOnly(char *pBuff, char *pCelBuff, int frame, int frame_width);
void __fastcall CelDrawHdrOnly(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int always_0, int direction);
void __fastcall CelDecodeHdrOnly(char *pBuff, char *pCelBuff, int frame, int frame_width, int always_0, int direction);
void __fastcall CelDecDatLightOnly(char *pDecodeTo, char *pRLEBytes, int frame_content_size, int frame_width);
void __fastcall CelDecDatLightEntry(unsigned char n, char *LightIndex, char **pDecodeTo, char **pRLEBytes); /* __usercall a1@<cl> a2@<ebx> a3@<edi> a4@<esi> */
void __fastcall CelDecDatLightTrans(char *pDecodeTo, char *pRLEBytes, int frame_content_size, int frame_width);
void __fastcall CelDecodeLightOnly(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width);
void __fastcall CelDrawDatOnly(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth);
void __fastcall CelDecodeOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth);
void __fastcall CelDecDatOnly(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth);
void __fastcall CelDrawHdrOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir);
void __fastcall CelDecodeHdrOnly(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir);
void __fastcall CelDecDatLightOnly(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth);
void __fastcall CelDecDatLightTrans(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth);
void __fastcall CelDecodeLightOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth);
void __fastcall CelDecodeHdrLightOnly(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int always_0, int direction);
void __fastcall CelDecodeHdrLightTrans(char *pBuff, char *pCelBuff, int frame, int frame_width, int always_0, int direction);
void __fastcall CelDrawHdrLightRed(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int always_0, int direction, char always_1);
void __fastcall Cel2DecDatOnly(char *pDecodeTo, char *pRLEBytes, int frame_content_size, int frame_width);
void __fastcall Cel2DrawHdrOnly(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int a6, int direction);
void __fastcall Cel2DecodeHdrOnly(char *pBuff, char *pCelBuff, int frame, int frame_width, int a5, int direction);
void __fastcall Cel2DecDatLightOnly(char *pDecodeTo, char *pRLEBytes, int frame_content_size, int frame_width);
void __fastcall Cel2DecDatLightEntry(unsigned char n, char *LightIndex, char **pDecodeTo, char **pRLEBytes); /* __usercall a1@<cl> a2@<ebx> a3@<edi> a4@<esi> */
void __fastcall Cel2DecDatLightTrans(char *pDecodeTo, char *pRLEBytes, int frame_content_size, int frame_width);
void __fastcall Cel2DecDatOnly(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth);
void __fastcall Cel2DrawHdrOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir);
void __fastcall Cel2DecodeHdrOnly(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir);
void __fastcall Cel2DecDatLightOnly(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth);
void __fastcall Cel2DecDatLightTrans(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth);
void __fastcall Cel2DecodeHdrLight(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int a6, int direction);
void __fastcall Cel2DecodeLightTrans(char *dst_buf, char *pCelBuff, int frame, int frame_width, int a5, int direction);
void __fastcall Cel2DrawHdrLightRed(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int always_0, int direction, char always_1);
@ -49,21 +47,21 @@ unsigned char *__fastcall DiabloAllocPtr(int dwBytes);
void __fastcall mem_free_dbg(void *p);
BYTE *__fastcall LoadFileInMem(char *pszName, int *pdwFileLen);
void __fastcall LoadFileWithMem(char *pszName, void *buf);
void __fastcall Cl2ApplyTrans(unsigned char *p, unsigned char *ttbl, int last_frame);
void __fastcall Cl2DecodeFrm1(int x, int y, char *pCelBuff, int nCel, int width, INT_PTR dir1, INT_PTR dir2);
void __fastcall Cl2DecDatFrm1(char *buffer, char *frame_content, int a3, int width);
void __fastcall Cl2DecodeFrm2(char colour, int screen_x, int screen_y, char *pCelBuff, int nCel, int frame_width, int a7, int a8);
void __fastcall Cl2DecDatFrm2(char *buffer, char *a2, int a3, int a4, char a5);
void __fastcall Cl2DecodeFrm3(int screen_x, int screen_y, char *pCelBuff, int nCel, int frame_width, int a6, int a7, char a8);
void __fastcall Cl2DecDatLightTbl1(char *a1, char *a2, int a3, int a4, char *unused_lindex);
void __fastcall Cl2DecodeLightTbl(int screen_x, int screen_y, char *pCelBuff, int nCel, int frame_width, int a6, int a7);
void __fastcall Cl2DecodeFrm4(int screen_x, int screen_y, char *pCelBuff, int nCel, int frame_width, int a6, int a7);
void __fastcall Cl2DecDatFrm4(char *buffer, char *a2, int a3, int frame_width);
void __fastcall Cl2DecodeClrHL(char colour, int screen_x, int screen_y, char *pCelBuff, int nCel, int frame_width, int a7, int a8);
void __fastcall Cl2DecDatClrHL(char *dst_buf, char *frame_content, int a3, int frame_width, char colour);
void __fastcall Cl2DecodeFrm5(int screen_x, int screen_y, char *pCelBuff, int nCel, int frame_width, int a6, int a7, char a8);
void __fastcall Cl2DecDatLightTbl2(char *dst_buf, char *a2, int a3, int frame_width, char *a5);
void __fastcall Cl2DecodeFrm6(int screen_x, int screen_y, char *pCelBuff, int nCel, int frame_width, int a6, int a7);
void __fastcall Cl2ApplyTrans(BYTE *p, BYTE *ttbl, int nCel);
void __fastcall Cl2DecodeFrm1(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir);
void __fastcall Cl2DecDatFrm1(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth);
void __fastcall Cl2DecodeFrm2(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir);
void __fastcall Cl2DecDatFrm2(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, char col);
void __fastcall Cl2DecodeFrm3(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir, char light);
void __fastcall Cl2DecDatLightTbl1(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, BYTE *pTable);
void __fastcall Cl2DecodeLightTbl(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir);
void __fastcall Cl2DecodeFrm4(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir);
void __fastcall Cl2DecDatFrm4(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth);
void __fastcall Cl2DecodeClrHL(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir);
void __fastcall Cl2DecDatClrHL(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, char col);
void __fastcall Cl2DecodeFrm5(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir, char light);
void __fastcall Cl2DecDatLightTbl2(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, BYTE *pTable);
void __fastcall Cl2DecodeFrm6(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir);
void __fastcall PlayInGameMovie(char *pszMovie);
/* rdata */

16
Source/error.cpp

@ -100,23 +100,23 @@ void __cdecl DrawDiabloMsg()
signed int v17; // [esp+Ch] [ebp-8h]
signed int screen_x; // [esp+10h] [ebp-4h]
CelDecodeOnly(165, 318, pSTextSlidCels, 1, 12);
CelDecodeOnly(591, 318, pSTextSlidCels, 4, 12);
CelDecodeOnly(165, 366, pSTextSlidCels, 2, 12);
CelDecodeOnly(591, 366, pSTextSlidCels, 3, 12);
CelDecodeOnly(165, 318, (BYTE *)pSTextSlidCels, 1, 12);
CelDecodeOnly(591, 318, (BYTE *)pSTextSlidCels, 4, 12);
CelDecodeOnly(165, 366, (BYTE *)pSTextSlidCels, 2, 12);
CelDecodeOnly(591, 366, (BYTE *)pSTextSlidCels, 3, 12);
screen_x = 173;
v16 = 35;
do {
CelDecodeOnly(screen_x, 318, pSTextSlidCels, 5, 12);
CelDecodeOnly(screen_x, 366, pSTextSlidCels, 7, 12);
CelDecodeOnly(screen_x, 318, (BYTE *)pSTextSlidCels, 5, 12);
CelDecodeOnly(screen_x, 366, (BYTE *)pSTextSlidCels, 7, 12);
screen_x += 12;
--v16;
} while (v16);
v0 = 330;
v1 = 3;
do {
CelDecodeOnly(165, v0, pSTextSlidCels, 6, 12);
CelDecodeOnly(591, v0, pSTextSlidCels, 8, 12);
CelDecodeOnly(165, v0, (BYTE *)pSTextSlidCels, 6, 12);
CelDecodeOnly(591, v0, (BYTE *)pSTextSlidCels, 8, 12);
v0 += 12;
--v1;
} while (v1);

88
Source/gendung.cpp

@ -73,61 +73,55 @@ short dpiece_defs_map_2[16][MAXDUNX][MAXDUNY];
void __cdecl FillSolidBlockTbls()
{
unsigned char *v0; // eax
char *v1; // ecx
unsigned char *v2; // esi
int v3; // edx
unsigned char v4; // bl
int size; // [esp+8h] [ebp-4h]
unsigned char bv;
unsigned int dwTiles;
unsigned char *pSBFile, *pTmp;
int i;
memset(nBlockTable, 0, sizeof(nBlockTable));
memset(nSolidTable, 0, sizeof(nSolidTable));
memset(nTransTable, 0, sizeof(nTransTable));
memset(nMissileTable, 0, sizeof(nMissileTable));
memset(nTrapTable, 0, sizeof(nTrapTable));
if (leveltype != DTYPE_TOWN) {
switch (leveltype) {
case DTYPE_CATHEDRAL:
v1 = "Levels\\L1Data\\L1.SOL";
break;
case DTYPE_CATACOMBS:
v1 = "Levels\\L2Data\\L2.SOL";
break;
case DTYPE_CAVES:
v1 = "Levels\\L3Data\\L3.SOL";
break;
case DTYPE_HELL:
v1 = "Levels\\L4Data\\L4.SOL";
break;
default:
TermMsg("FillSolidBlockTbls");
// v0 = (unsigned char *)size; /* check error */
goto LABEL_13;
}
} else {
v1 = "Levels\\TownData\\Town.SOL";
switch(leveltype) {
case DTYPE_TOWN:
pSBFile = LoadFileInMem("Levels\\TownData\\Town.SOL", (int *)&dwTiles);
break;
case DTYPE_CATHEDRAL:
pSBFile = LoadFileInMem("Levels\\L1Data\\L1.SOL", (int *)&dwTiles);
break;
case DTYPE_CATACOMBS:
pSBFile = LoadFileInMem("Levels\\L2Data\\L2.SOL", (int *)&dwTiles);
break;
case DTYPE_CAVES:
pSBFile = LoadFileInMem("Levels\\L3Data\\L3.SOL", (int *)&dwTiles);
break;
case DTYPE_HELL:
pSBFile = LoadFileInMem("Levels\\L4Data\\L4.SOL", (int *)&dwTiles);
break;
default:
TermMsg("FillSolidBlockTbls");
}
v0 = LoadFileInMem(v1, &size);
LABEL_13:
v2 = v0;
if ((unsigned int)size >= 1) {
v3 = 0;
do {
v4 = *v2++;
if (v4 & 1)
nSolidTable[v3 + 1] = 1;
if (v4 & 2)
nBlockTable[v3 + 1] = 1;
if (v4 & 4)
nMissileTable[v3 + 1] = 1;
if (v4 & 8)
nTransTable[v3 + 1] = 1;
if ((v4 & 0x80u) != 0)
nTrapTable[v3 + 1] = TRUE;
block_lvid[v3++ + 1] = (v4 >> 4) & 7;
} while (v3 + 1 <= (unsigned int)size);
pTmp = pSBFile;
for(i = 1; i <= dwTiles; i++) {
bv = *pTmp++;
if(bv & 1)
nSolidTable[i] = 1;
if(bv & 2)
nBlockTable[i] = 1;
if(bv & 4)
nMissileTable[i] = 1;
if(bv & 8)
nTransTable[i] = 1;
if(bv & 0x80)
nTrapTable[i] = 1;
block_lvid[i] = (bv & 0x70) >> 4; /* beta: (bv >> 4) & 7 */
}
mem_free_dbg(v0);
mem_free_dbg(pSBFile);
}
void __cdecl gendung_418D91()

12
Source/gmenu.cpp

@ -67,7 +67,7 @@ void __fastcall gmenu_print_text(int x, int y, char *pszStr)
++v3;
v7 = lfontframe[fontidx[i]];
if (v7)
CelDecodeLightOnly(v5, v4, (char *)BigTGold_cel, v7, 46);
CelDecodeLightOnly(v5, v4, (BYTE *)BigTGold_cel, v7, 46);
v5 += lfontkern[v7] + 2;
}
}
@ -196,7 +196,7 @@ void __cdecl gmenu_draw()
if (dword_634480) {
if (dword_63447C)
dword_63447C();
CelDecodeOnly(236, 262, sgpLogo, 1, 296);
CelDecodeOnly(236, 262, (BYTE *)sgpLogo, 1, 296);
v0 = 320;
for (i = dword_634480; i->fnMenu; v0 += 45) {
gmenu_draw_menu_item(i, v0);
@ -236,7 +236,7 @@ void __fastcall gmenu_draw_menu_item(TMenuItem *pItem, int a2)
v14 = v4;
if (v3->dwFlags & 0x40000000) {
v6 = (v4 >> 1) + 80;
CelDecodeOnly(v6, v2 - 10, optbar_cel, 1, 287);
CelDecodeOnly(v6, v2 - 10, (BYTE *)optbar_cel, 1, 287);
v7 = (v3->dwFlags >> 12) & 0xFFF;
if (v7 < 2)
v7 = 2;
@ -244,7 +244,7 @@ void __fastcall gmenu_draw_menu_item(TMenuItem *pItem, int a2)
v9 = (v5 >> 1) + 82;
v10 = v8;
gmenu_clear_buffer(v9, v2 - 12, v8 + 13, 28);
CelDecodeOnly(v6 + v10 + 2, v2 - 12, option_cel, 1, 27);
CelDecodeOnly(v6 + v10 + 2, v2 - 12, (BYTE *)option_cel, 1, 27);
v5 = v14;
}
v11 = 384 - (v5 >> 1);
@ -254,8 +254,8 @@ void __fastcall gmenu_draw_menu_item(TMenuItem *pItem, int a2)
gmenu_print_text(384 - (v5 >> 1), v2, v3->pszStr);
if (v3 == sgpCurrItem) {
v13 = v2 + 1;
CelDecodeOnly(v11 - 54, v13, PentSpin_cel, (unsigned char)byte_634478, 48);
CelDecodeOnly(v11 + v5 + 4, v13, PentSpin_cel, (unsigned char)byte_634478, 48);
CelDecodeOnly(v11 - 54, v13, (BYTE *)PentSpin_cel, (unsigned char)byte_634478, 48);
CelDecodeOnly(v11 + v5 + 4, v13, (BYTE *)PentSpin_cel, (unsigned char)byte_634478, 48);
}
}
// 634478: using guessed type char byte_634478;

2
Source/interfac.cpp

@ -39,7 +39,7 @@ void __cdecl DrawCutscene()
unsigned int v0; // esi
j_lock_buf_priv(1);
CelDecodeOnly(64, 639, sgpBackCel, 1, 640);
CelDecodeOnly(64, 639, (BYTE *)sgpBackCel, 1, 640);
v0 = 0;
if (sgdwProgress) {
do

20
Source/inv.cpp

@ -152,7 +152,7 @@ void __cdecl DrawInv()
BOOL invtest[40];
int frame, frame_width, colour, screen_x, screen_y, i, j, ii;
CelDecodeOnly(384, 511, pInvCels, 1, 320);
CelDecodeOnly(384, 511, (BYTE *)pInvCels, 1, 320);
if (plr[myplr].InvBody[INVLOC_HEAD]._itype != ITYPE_NONE) {
InvDrawSlotBack(517, 219, 2 * INV_SLOT_SIZE_PX, 2 * INV_SLOT_SIZE_PX);
@ -172,7 +172,7 @@ void __cdecl DrawInv()
}
if (plr[myplr].InvBody[INVLOC_HEAD]._iStatFlag) {
CelDrawHdrOnly(517, 219, (char *)pCursCels, frame, frame_width, 0, 8);
CelDrawHdrOnly(517, 219, (BYTE *)pCursCels, frame, frame_width, 0, 8);
} else {
CelDrawHdrLightRed(517, 219, (char *)pCursCels, frame, frame_width, 0, 8, 1);
}
@ -196,7 +196,7 @@ void __cdecl DrawInv()
}
if (plr[myplr].InvBody[INVLOC_RING_LEFT]._iStatFlag) {
CelDrawHdrOnly(432, 365, (char *)pCursCels, frame, frame_width, 0, 8);
CelDrawHdrOnly(432, 365, (BYTE *)pCursCels, frame, frame_width, 0, 8);
} else {
CelDrawHdrLightRed(432, 365, (char *)pCursCels, frame, frame_width, 0, 8, 1);
}
@ -220,7 +220,7 @@ void __cdecl DrawInv()
}
if (plr[myplr].InvBody[INVLOC_RING_RIGHT]._iStatFlag) {
CelDrawHdrOnly(633, 365, (char *)pCursCels, frame, frame_width, 0, 8);
CelDrawHdrOnly(633, 365, (BYTE *)pCursCels, frame, frame_width, 0, 8);
} else {
CelDrawHdrLightRed(633, 365, (char *)pCursCels, frame, frame_width, 0, 8, 1);
}
@ -244,7 +244,7 @@ void __cdecl DrawInv()
}
if (plr[myplr].InvBody[INVLOC_AMULET]._iStatFlag) {
CelDrawHdrOnly(589, 220, (char *)pCursCels, frame, frame_width, 0, 8);
CelDrawHdrOnly(589, 220, (BYTE *)pCursCels, frame, frame_width, 0, 8);
} else {
CelDrawHdrLightRed(589, 220, (char *)pCursCels, frame, frame_width, 0, 8, 1);
}
@ -271,7 +271,7 @@ void __cdecl DrawInv()
}
if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._iStatFlag) {
CelDrawHdrOnly(screen_x, screen_y, (char *)pCursCels, frame, frame_width, 0, 8);
CelDrawHdrOnly(screen_x, screen_y, (BYTE *)pCursCels, frame, frame_width, 0, 8);
} else {
CelDrawHdrLightRed(screen_x, screen_y, (char *)pCursCels, frame, frame_width, 0, 8, 1);
}
@ -311,7 +311,7 @@ void __cdecl DrawInv()
}
if (plr[myplr].InvBody[INVLOC_HAND_RIGHT]._iStatFlag) {
CelDrawHdrOnly(screen_x, screen_y, (char *)pCursCels, frame, frame_width, 0, 8);
CelDrawHdrOnly(screen_x, screen_y, (BYTE *)pCursCels, frame, frame_width, 0, 8);
} else {
CelDrawHdrLightRed(screen_x, screen_y, (char *)pCursCels, frame, frame_width, 0, 8, 1);
}
@ -335,7 +335,7 @@ void __cdecl DrawInv()
}
if (plr[myplr].InvBody[INVLOC_CHEST]._iStatFlag) {
CelDrawHdrOnly(517, 320, (char *)pCursCels, frame, frame_width, 0, 8);
CelDrawHdrOnly(517, 320, (BYTE *)pCursCels, frame, frame_width, 0, 8);
} else {
CelDrawHdrLightRed(517, 320, (char *)pCursCels, frame, frame_width, 0, 8, 1);
}
@ -379,7 +379,7 @@ void __cdecl DrawInv()
CelDrawHdrOnly(
InvRect[j + SLOTXY_INV_FIRST].X + 64,
InvRect[j + SLOTXY_INV_FIRST].Y + 159,
(char *)pCursCels, frame, frame_width, 0, 8);
(BYTE *)pCursCels, frame, frame_width, 0, 8);
} else {
CelDrawHdrLightRed(
InvRect[j + SLOTXY_INV_FIRST].X + 64,
@ -424,7 +424,7 @@ void __cdecl DrawInvBelt()
}
if (plr[myplr].SpdList[i]._iStatFlag)
CelDrawHdrOnly(InvRect[i + 65].X + 64, InvRect[i + 65].Y + 159, (char *)pCursCels, frame, frame_width, 0, 8);
CelDrawHdrOnly(InvRect[i + 65].X + 64, InvRect[i + 65].Y + 159, (BYTE *)pCursCels, frame, frame_width, 0, 8);
else
CelDrawHdrLightRed(InvRect[i + 65].X + 64, InvRect[i + 65].Y + 159, (char *)pCursCels, frame, frame_width, 0, 8, 1);

2
Source/items.cpp

@ -3698,7 +3698,7 @@ void __fastcall PrintItemPower(char plidx, ItemStruct *x)
void __cdecl DrawUBack()
{
CelDecodeOnly(88, 487, pSTextBoxCels, 1, 271);
CelDecodeOnly(88, 487, (BYTE *)pSTextBoxCels, 1, 271);
#define TRANS_RECT_X 27
#define TRANS_RECT_Y 28

2
Source/minitext.cpp

@ -87,7 +87,7 @@ void __fastcall InitQTextMsg(int m)
void __cdecl DrawQTextBack()
{
CelDecodeOnly(88, 487, pTextBoxCels, 1, 591);
CelDecodeOnly(88, 487, (BYTE *)pTextBoxCels, 1, 591);
#define TRANS_RECT_X 27
#define TRANS_RECT_Y 28

997
Source/missiles.cpp

File diff suppressed because it is too large Load Diff

2
Source/missiles.h

@ -50,7 +50,7 @@ void __fastcall AddLightctrl(int mi, int sx, int sy, int dx, int dy, int midir,
void __fastcall AddLightning(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddMisexp(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddWeapexp(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
BOOLEAN __fastcall CheckIfTrig(int x, int y);
BOOL __fastcall CheckIfTrig(int x, int y);
void __fastcall AddTown(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddFlash(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddFlash2(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);

31
Source/mpqapi.cpp

@ -103,27 +103,24 @@ void __fastcall mpqapi_update_multi_creation_time(DWORD dwChar)
{
}
BOOLEAN __fastcall mpqapi_reg_store_modification_time(char *pbData, int dwLen)
BOOLEAN __fastcall mpqapi_reg_store_modification_time(char *pbData, DWORD dwLen)
{
int v2; // ebx
char *v3; // ebp
char *v4; // edi
unsigned int v5; // esi
char *v6; // ecx
char *pbCurrentData;
DWORD i;
char *pbDataToXor;
v2 = dwLen;
v3 = pbData;
v4 = pbData;
if ((unsigned int)dwLen >= 8) {
v5 = (unsigned int)dwLen >> 3;
pbCurrentData = pbData;
if (dwLen >= 8) {
i = dwLen >> 3;
do {
v6 = v4;
v4 += 8;
mpqapi_xor_buf(v6);
--v5;
} while (v5);
pbDataToXor = pbCurrentData;
pbCurrentData += 8;
mpqapi_xor_buf(pbDataToXor);
--i;
} while (i);
}
return SRegSaveData("Diablo", "Video Player ", 0, (unsigned char *)v3, v2);
return SRegSaveData("Diablo", "Video Player ", 0, (unsigned char *)pbData, dwLen);
}
void __fastcall mpqapi_remove_hash_entry(const char *pszName)

2
Source/mpqapi.h

@ -11,7 +11,7 @@ void __fastcall mpqapi_store_creation_time(const char *pszArchive, int dwChar);
BOOLEAN __fastcall mpqapi_reg_load_modification_time(char *dst, int size);
void __fastcall mpqapi_xor_buf(char *pbData);
void __fastcall mpqapi_update_multi_creation_time(DWORD dwChar);
BOOLEAN __fastcall mpqapi_reg_store_modification_time(char *pbData, int dwLen);
BOOLEAN __fastcall mpqapi_reg_store_modification_time(char *pbData, DWORD dwLen);
_BLOCKENTRY *__fastcall j_mpqapi_remove_hash_entry(char *pszName);
void __fastcall mpqapi_remove_hash_entry(const char *pszName);
void __fastcall mpqapi_free_block(int block_offset, int block_size);

6
Source/quests.cpp

@ -942,7 +942,7 @@ void __fastcall PrintQLString(int x, int y, unsigned char cjustflag, char *str,
v12 = v8 + v6 + 76;
if (!cjustflag)
v12 = v6 + 76;
CelDecodeOnly(v12, v5 + 205, pCelBuff, ALLQUESTS, 12);
CelDecodeOnly(v12, v5 + 205, (BYTE *)pCelBuff, ALLQUESTS, 12);
}
v13 = 0;
v19 = 0;
@ -965,7 +965,7 @@ void __fastcall PrintQLString(int x, int y, unsigned char cjustflag, char *str,
v16 = v8 + v6 + 100;
else
v16 = 340 - v6;
CelDecodeOnly(v16, v5 + 205, pCelBuff, ALLQUESTS, 12);
CelDecodeOnly(v16, v5 + 205, (BYTE *)pCelBuff, ALLQUESTS, 12);
}
}
// 69BE90: using guessed type int qline;
@ -976,7 +976,7 @@ void __cdecl DrawQuestLog()
int i; // esi
PrintQLString(0, 2, 1u, "Quest Log", 3);
CelDecodeOnly(64, 511, pQLogCel, 1, 320);
CelDecodeOnly(64, 511, (BYTE *)pQLogCel, 1, 320);
v0 = qtopline;
for (i = 0; i < numqlines; ++i) {
PrintQLString(0, v0, 1u, questlist[qlist[i]]._qlstr, 0);

976
Source/scrollrt.cpp

File diff suppressed because it is too large Load Diff

20
Source/scrollrt.h

@ -10,29 +10,29 @@ extern char arch_draw_type; // weak
extern DDSURFACEDESC DDS_desc;
extern int cel_transparency_active; // weak
extern int level_piece_id; // weak
extern int(__fastcall *DrawPlrProc)(int player_num, int x, int y, int screen_x, int screen_y, void *cl2_buf, int frame, int frame_width, int a9, int a10);
extern void (__fastcall *DrawPlrProc)(int, int, int, int, int, BYTE *, int, int, int, int);
extern int draw_monster_num; // weak
void __cdecl ClearCursor();
void __fastcall DrawMissile(int x, int y, int sx, int sy, int a5, int a6, BOOL del_flag);
void __fastcall DrawClippedMissile(int x, int y, int sx, int sy, int a5, int a6, BOOL a7);
void __fastcall DrawDeadPlayer(int x, int y, int sx, int sy, int a5, int a6, BOOLEAN clipped);
void __fastcall DrawPlayer(int pnum, int x, int y, int px, int py, unsigned char *animdata, int animframe, int animwidth, int a9, int a10);
void __fastcall DrawClippedPlayer(int pnum, int x, int y, int px, int py, unsigned char *animdata, int animframe, int animwidth, int a9, int a10);
void __fastcall DrawMissile(int x, int y, int sx, int sy, int a5, int a6, BOOL pre);
void __fastcall DrawClippedMissile(int x, int y, int sx, int sy, int a5, int a6, BOOL pre);
void __fastcall DrawDeadPlayer(int x, int y, int sx, int sy, int a5, int a6, BOOL clipped);
void __fastcall DrawPlayer(int pnum, int x, int y, int px, int py, BYTE *pCelBuff, int nCel, int nWidth, int a9, int a10);
void __fastcall DrawClippedPlayer(int pnum, int x, int y, int px, int py, BYTE *pCelBuff, int nCel, int nWidth, int a9, int a10);
void __fastcall DrawView(int StartX, int StartY);
void __fastcall DrawGame(int x, int y);
void __fastcall scrollrt_draw_lower(int x, int y, int sx, int sy, int a5, int some_flag);
void __fastcall scrollrt_draw_clipped_dungeon(char *a1, int sx, int sy, int a4, int a5, int a6);
void __fastcall DrawClippedMonster(int x, int y, int a3, int a4, int mon_id, int a6, int a7);
void __fastcall DrawClippedObject(int x, int y, int a3, int a4, int pre_flag, int a6, int dir);
void __fastcall DrawClippedMonster(int x, int y, int mx, int my, int m, int a6, int a7);
void __fastcall DrawClippedObject(int x, int y, int ox, int oy, BOOL pre, int a6, int dir);
void __fastcall scrollrt_draw_clipped_e_flag(char *buffer, int x, int y, int a4, int a5);
void __fastcall scrollrt_draw_lower_2(int x, int y, int sx, int sy, int a5, int a6, int some_flag);
void __fastcall scrollrt_draw_clipped_dungeon_2(char *buffer, int x, int y, int a4, int a5, int sx, int sy, int me_flag);
void __fastcall scrollrt_draw_clipped_e_flag_2(char *buffer, int x, int y, int a4, signed int a5, int sx, int sy);
void __fastcall scrollrt_draw_upper(int x, int y, int sx, int sy, int a5, int a6, int some_flag);
void __fastcall scrollrt_draw_dungeon(char *buffer, int x, int y, int a4, int a5, int sx, int sy, int me_flag);
void __fastcall DrawMonster(int x, int y, int a3, int a4, int mon_id, int a6, int a7);
void __fastcall DrawObject(int x, int y, int a3, int a4, int pre_flag, int a6, int dir);
void __fastcall DrawMonster(int x, int y, int mx, int my, int m, int a6, int a7);
void __fastcall DrawObject(int x, int y, int ox, int oy, BOOL pre, int a6, int dir);
void __fastcall scrollrt_draw_e_flag(char *buffer, int x, int y, int a4, int a5, int sx, int sy);
void __fastcall DrawZoom(int x, int y);
void __cdecl ClearScreenBuffer();

19
Source/sound.cpp

@ -36,20 +36,20 @@ char unk_volume[4][2] = {
void __fastcall snd_update(BOOL bStopAll)
{
DWORD error_code, i;
DWORD dwStatus, i;
for (i = 0; i < 8; i++) {
if (!DSBs[i])
continue;
#ifdef __cplusplus
if (!bStopAll && !DSBs[i]->GetStatus(&error_code) && error_code == DSBSTATUS_PLAYING)
if (!bStopAll && DSBs[i]->GetStatus(&dwStatus) == DS_OK && dwStatus == DSBSTATUS_PLAYING)
continue;
DSBs[i]->Stop();
DSBs[i]->Release();
#else
if (!bStopAll && !DSBs[i]->lpVtbl->GetStatus(DSBs[i], &error_code) && error_code == DSBSTATUS_PLAYING)
if (!bStopAll && DSBs[i]->lpVtbl->GetStatus(DSBs[i], &dwStatus) == DS_OK && dwStatus == DSBSTATUS_PLAYING)
continue;
DSBs[i]->lpVtbl->Stop(DSBs[i]);
@ -72,7 +72,7 @@ void __fastcall snd_stop_snd(TSnd *pSnd)
BOOL __fastcall snd_playing(TSnd *pSnd)
{
DWORD error_code; // TODO should probably be HRESULT
DWORD dwStatus;
if (!pSnd)
return FALSE;
@ -81,12 +81,13 @@ BOOL __fastcall snd_playing(TSnd *pSnd)
return FALSE;
#ifdef __cplusplus
if (pSnd->DSB->GetStatus(&error_code))
if (pSnd->DSB->GetStatus(&dwStatus) != DS_OK)
#else
if (pSnd->DSB->lpVtbl->GetStatus(pSnd->DSB, &error_code))
if (pSnd->DSB->lpVtbl->GetStatus(pSnd->DSB, &dwStatus) != DS_OK)
#endif
return FALSE;
return error_code == DSBSTATUS_PLAYING;
return dwStatus == DSBSTATUS_PLAYING;
}
void __fastcall snd_play_snd(TSnd *pSnd, int lVolume, int lPan)
@ -183,9 +184,9 @@ BOOL __fastcall sound_file_reload(TSnd *sound_file, LPDIRECTSOUNDBUFFER DSB)
BOOL rv;
#ifdef __cplusplus
if (DSB->Restore())
if (DSB->Restore() != DS_OK)
#else
if (DSB->lpVtbl->Restore(DSB))
if (DSB->lpVtbl->Restore(DSB) != DS_OK)
#endif
return FALSE;

18
Source/stores.cpp

@ -149,7 +149,7 @@ void __cdecl FreeStoreMem()
void __cdecl DrawSTextBack()
{
CelDecodeOnly(408, 487, pSTextBoxCels, 1, 271);
CelDecodeOnly(408, 487, (BYTE *)pSTextBoxCels, 1, 271);
#define TRANS_RECT_X 347
#define TRANS_RECT_Y 28
@ -216,7 +216,7 @@ void __fastcall PrintSString(int x, int y, unsigned char cjustflag, char *str, i
v14 = v27 + v30 + v8 - 20;
else
v14 = v27 + v8 - 20;
CelDecodeOnly(v14, v6 + 205, pCelBuff, InStoreFlag, 12);
CelDecodeOnly(v14, v6 + 205, (BYTE *)pCelBuff, InStoreFlag, 12);
}
v29 = 0;
if (v28 > 0) {
@ -250,7 +250,7 @@ void __fastcall PrintSString(int x, int y, unsigned char cjustflag, char *str, i
v22 = v27 + v30 + v8 + 4;
else
v22 = 660 - v8;
CelDecodeOnly(v22, v6 + 205, pCelBuff, InStoreFlag, 12);
CelDecodeOnly(v22, v6 + 205, (BYTE *)pCelBuff, InStoreFlag, 12);
}
}
// 6A09E0: using guessed type char stextsize;
@ -311,18 +311,18 @@ void __fastcall DrawSArrows(int y1, int y2)
v4 = SStringY[y1] + 204;
v5 = *v2 + 204;
if (stextscrlubtn == -1)
CelDecodeOnly(665, v4, pSTextSlidCels, 10, 12);
CelDecodeOnly(665, v4, (BYTE *)pSTextSlidCels, 10, 12);
else
CelDecodeOnly(665, v4, pSTextSlidCels, 12, 12);
CelDecodeOnly(665, v4, (BYTE *)pSTextSlidCels, 12, 12);
if (stextscrldbtn == -1)
CelDecodeOnly(665, v5, pSTextSlidCels, 9, 12);
CelDecodeOnly(665, v5, (BYTE *)pSTextSlidCels, 9, 12);
else
CelDecodeOnly(665, v5, pSTextSlidCels, 11, 12);
CelDecodeOnly(665, v5, (BYTE *)pSTextSlidCels, 11, 12);
while (1) {
v4 += 12;
if (v4 >= v5)
break;
CelDecodeOnly(665, v4, pSTextSlidCels, 14, 12);
CelDecodeOnly(665, v4, (BYTE *)pSTextSlidCels, 14, 12);
}
v6 = stextsel;
if (stextsel == 22)
@ -331,7 +331,7 @@ void __fastcall DrawSArrows(int y1, int y2)
v7 = 0;
else
v7 = (*v2 - SStringY[v3] - 24) * (1000 * (stextsval + ((v6 - stextup) >> 2)) / (storenumh - 1)) / 1000;
CelDecodeOnly(665, SStringY[v3 + 1] + v7 + 204, pSTextSlidCels, 13, 12);
CelDecodeOnly(665, SStringY[v3 + 1] + v7 + 204, (BYTE *)pSTextSlidCels, 13, 12);
}
// 69F108: using guessed type int stextup;
// 69F10C: using guessed type int storenumh;

42
Source/town.cpp

@ -153,7 +153,7 @@ void __fastcall town_draw_clipped_town(BYTE *buffer, int x, int y, int sx, int s
item[v10]._iAnimWidth,
0,
8);
Cel2DrawHdrOnly(v11, sy, (char *)item[v10]._iAnimData, item[v10]._iAnimFrame, item[v10]._iAnimWidth, 0, 8);
Cel2DrawHdrOnly(v11, sy, item[v10]._iAnimData, item[v10]._iAnimFrame, item[v10]._iAnimWidth, 0, 8);
}
if (dFlags[0][v7] & DFLAG_MONSTER) {
v12 = -1 - dMonster[x][y - 1]; // -1 - *(&dword_52D204 + v7); /* check */
@ -168,7 +168,7 @@ void __fastcall town_draw_clipped_town(BYTE *buffer, int x, int y, int sx, int s
towner[v12]._tAnimWidth,
0,
8);
Cel2DrawHdrOnly(v13, sy, (char *)towner[v12]._tAnimData, towner[v12]._tAnimFrame, towner[v12]._tAnimWidth, 0, 8);
Cel2DrawHdrOnly(v13, sy, towner[v12]._tAnimData, towner[v12]._tAnimFrame, towner[v12]._tAnimWidth, 0, 8);
}
v14 = dMonster[0][v7];
if (v14 > 0) {
@ -185,7 +185,7 @@ void __fastcall town_draw_clipped_town(BYTE *buffer, int x, int y, int sx, int s
towner[v16]._tAnimWidth,
0,
8);
Cel2DrawHdrOnly(v17, sy, (char *)towner[v16]._tAnimData, towner[v16]._tAnimFrame, towner[v16]._tAnimWidth, 0, 8);
Cel2DrawHdrOnly(v17, sy, towner[v16]._tAnimData, towner[v16]._tAnimFrame, towner[v16]._tAnimWidth, 0, 8);
}
if (dFlags[0][v7] & DFLAG_PLAYER) {
v18 = -1 - dPlayer[x][y - 1]; // -1 - *((_BYTE *)&themeLoc[49].height + v7 + 3);
@ -193,8 +193,8 @@ void __fastcall town_draw_clipped_town(BYTE *buffer, int x, int y, int sx, int s
v20 = sy + plr[v19]._pyoff;
v21 = sx + plr[v19]._pxoff - plr[v19]._pAnimWidth2;
if (v18 == pcursplr)
Cl2DecodeClrHL(165, v21, v20, (char *)plr[v19]._pAnimData, plr[v19]._pAnimFrame, plr[v19]._pAnimWidth, 0, 8);
Cl2DecodeFrm4(v21, v20, (char *)plr[v19]._pAnimData, plr[v19]._pAnimFrame, plr[v19]._pAnimWidth, 0, 8);
Cl2DecodeClrHL(165, v21, v20, plr[v19]._pAnimData, plr[v19]._pAnimFrame, plr[v19]._pAnimWidth, 0, 8);
Cl2DecodeFrm4(v21, v20, plr[v19]._pAnimData, plr[v19]._pAnimFrame, plr[v19]._pAnimWidth, 0, 8);
if (some_flag && plr[v19]._peflag)
town_draw_clipped_e_flag((BYTE *)v27 - 64, xa - 1, y + 1, sx - 64, sy);
v7 = v29;
@ -208,8 +208,8 @@ void __fastcall town_draw_clipped_town(BYTE *buffer, int x, int y, int sx, int s
v25 = sy + plr[v24]._pyoff;
v26 = sx + plr[v24]._pxoff - plr[v24]._pAnimWidth2;
if (v23 == pcursplr)
Cl2DecodeClrHL(165, v26, v25, (char *)plr[v24]._pAnimData, plr[v24]._pAnimFrame, plr[v24]._pAnimWidth, 0, 8);
Cl2DecodeFrm4(v26, v25, (char *)plr[v24]._pAnimData, plr[v24]._pAnimFrame, plr[v24]._pAnimWidth, 0, 8);
Cl2DecodeClrHL(165, v26, v25, plr[v24]._pAnimData, plr[v24]._pAnimFrame, plr[v24]._pAnimWidth, 0, 8);
Cl2DecodeFrm4(v26, v25, plr[v24]._pAnimData, plr[v24]._pAnimFrame, plr[v24]._pAnimWidth, 0, 8);
if (some_flag && plr[v24]._peflag)
town_draw_clipped_e_flag((BYTE *)v27 - 64, xa - 1, y + 1, sx - 64, sy);
v7 = v29;
@ -413,7 +413,7 @@ void __fastcall town_draw_clipped_town_2(int x, int y, int a3, int a4, int a5, i
item[v12]._iAnimWidth,
a5,
8);
Cel2DrawHdrOnly(v13, sy, (char *)item[v12]._iAnimData, item[v12]._iAnimFrame, item[v12]._iAnimWidth, a5, 8);
Cel2DrawHdrOnly(v13, sy, item[v12]._iAnimData, item[v12]._iAnimFrame, item[v12]._iAnimWidth, a5, 8);
}
if (dFlags[0][v9] & DFLAG_MONSTER) {
v14 = -1 - dMonster[x][y - 1]; // -1 - *(&dword_52D204 + v9); /* check */
@ -428,7 +428,7 @@ void __fastcall town_draw_clipped_town_2(int x, int y, int a3, int a4, int a5, i
towner[v14]._tAnimWidth,
a5,
8);
Cel2DrawHdrOnly(v15, sy, (char *)towner[v14]._tAnimData, towner[v14]._tAnimFrame, towner[v14]._tAnimWidth, a5, 8);
Cel2DrawHdrOnly(v15, sy, towner[v14]._tAnimData, towner[v14]._tAnimFrame, towner[v14]._tAnimWidth, a5, 8);
}
v16 = dMonster[0][v9];
if (v16 > 0) {
@ -445,7 +445,7 @@ void __fastcall town_draw_clipped_town_2(int x, int y, int a3, int a4, int a5, i
towner[v18]._tAnimWidth,
a5,
8);
Cel2DrawHdrOnly(v19, sy, (char *)towner[v18]._tAnimData, towner[v18]._tAnimFrame, towner[v18]._tAnimWidth, a5, 8);
Cel2DrawHdrOnly(v19, sy, towner[v18]._tAnimData, towner[v18]._tAnimFrame, towner[v18]._tAnimWidth, a5, 8);
}
if (dFlags[0][v9] & DFLAG_PLAYER) {
v20 = -1 - dPlayer[x][y - 1]; // -1 - *((_BYTE *)&themeLoc[49].height + v9 + 3);
@ -453,8 +453,8 @@ void __fastcall town_draw_clipped_town_2(int x, int y, int a3, int a4, int a5, i
v22 = sy + plr[v21]._pyoff;
v23 = sx + plr[v21]._pxoff - plr[v21]._pAnimWidth2;
if (v20 == pcursplr)
Cl2DecodeClrHL(165, v23, v22, (char *)plr[v21]._pAnimData, plr[v21]._pAnimFrame, plr[v21]._pAnimWidth, a5, 8);
Cl2DecodeFrm4(v23, v22, (char *)plr[v21]._pAnimData, plr[v21]._pAnimFrame, plr[v21]._pAnimWidth, a5, 8);
Cl2DecodeClrHL(165, v23, v22, plr[v21]._pAnimData, plr[v21]._pAnimFrame, plr[v21]._pAnimWidth, a5, 8);
Cl2DecodeFrm4(v23, v22, plr[v21]._pAnimData, plr[v21]._pAnimFrame, plr[v21]._pAnimWidth, a5, 8);
if (some_flag && plr[v21]._peflag)
town_draw_clipped_e_flag_2((BYTE *)(v29 - 64), xa - 1, a3 + 1, a4, a5, sx - 64, sy);
v9 = v31;
@ -468,8 +468,8 @@ void __fastcall town_draw_clipped_town_2(int x, int y, int a3, int a4, int a5, i
v27 = sy + plr[v26]._pyoff;
v28 = sx + plr[v26]._pxoff - plr[v26]._pAnimWidth2;
if (v25 == pcursplr)
Cl2DecodeClrHL(165, v28, v27, (char *)plr[v26]._pAnimData, plr[v26]._pAnimFrame, plr[v26]._pAnimWidth, a5, 8);
Cl2DecodeFrm4(v28, v27, (char *)plr[v26]._pAnimData, plr[v26]._pAnimFrame, plr[v26]._pAnimWidth, a5, 8);
Cl2DecodeClrHL(165, v28, v27, plr[v26]._pAnimData, plr[v26]._pAnimFrame, plr[v26]._pAnimWidth, a5, 8);
Cl2DecodeFrm4(v28, v27, plr[v26]._pAnimData, plr[v26]._pAnimFrame, plr[v26]._pAnimWidth, a5, 8);
if (some_flag && plr[v26]._peflag)
town_draw_clipped_e_flag_2((BYTE *)(v29 - 64), xa - 1, a3 + 1, a4, a5, sx - 64, sy);
v9 = v31;
@ -656,29 +656,29 @@ void __fastcall town_draw_town_all(BYTE *buffer, int x, int y, int a4, int dir,
xx = sx - item[ii]._iAnimWidth2;
if (ii == pcursitem)
CelDecodeClr(ICOL_BLUE, xx, sy, (char *)item[ii]._iAnimData, item[ii]._iAnimFrame, item[ii]._iAnimWidth, 0, dir);
CelDrawHdrOnly(xx, sy, (char *)item[ii]._iAnimData, item[ii]._iAnimFrame, item[ii]._iAnimWidth, 0, dir);
CelDrawHdrOnly(xx, sy, item[ii]._iAnimData, item[ii]._iAnimFrame, item[ii]._iAnimWidth, 0, dir);
}
if (dFlags[x][y] & DFLAG_MONSTER) {
mi = -1 - dMonster[x][y - 1];
xx = sx - towner[mi]._tAnimWidth2;
if (mi == pcursmonst)
CelDecodeClr(PAL16_BEIGE + 6, xx, sy, (char *)towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, 0, dir);
CelDrawHdrOnly(xx, sy, (char *)towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, 0, dir);
CelDrawHdrOnly(xx, sy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, 0, dir);
}
if (dMonster[x][y] > 0) {
mi = dMonster[x][y] - 1;
xx = sx - towner[mi]._tAnimWidth2;
if (mi == pcursmonst)
CelDecodeClr(PAL16_BEIGE + 6, xx, sy, (char *)towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, 0, dir);
CelDrawHdrOnly(xx, sy, (char *)towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, 0, dir);
CelDrawHdrOnly(xx, sy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, 0, dir);
}
if (dFlags[x][y] & DFLAG_PLAYER) {
pnum = -1 - dPlayer[x][y - 1];
yy = sy + plr[pnum]._pyoff;
xx = sx + plr[pnum]._pxoff - plr[pnum]._pAnimWidth2;
if (pnum == pcursplr)
Cl2DecodeFrm2(PAL16_BEIGE + 5, xx, yy, (char *)plr[pnum]._pAnimData, plr[pnum]._pAnimFrame, plr[pnum]._pAnimWidth, 0, dir);
Cl2DecodeFrm1(xx, yy, (char *)plr[pnum]._pAnimData, plr[pnum]._pAnimFrame, plr[pnum]._pAnimWidth, 0, dir);
Cl2DecodeFrm2(PAL16_BEIGE + 5, xx, yy, plr[pnum]._pAnimData, plr[pnum]._pAnimFrame, plr[pnum]._pAnimWidth, 0, dir);
Cl2DecodeFrm1(xx, yy, plr[pnum]._pAnimData, plr[pnum]._pAnimFrame, plr[pnum]._pAnimWidth, 0, dir);
if (some_flag && plr[pnum]._peflag)
town_draw_e_flag(buffer - 64, x - 1, y + 1, a4, dir, sx - 64, sy);
}
@ -689,8 +689,8 @@ void __fastcall town_draw_town_all(BYTE *buffer, int x, int y, int a4, int dir,
yy = sy + plr[pnum]._pyoff;
xx = sx + plr[pnum]._pxoff - plr[pnum]._pAnimWidth2;
if (pnum == pcursplr)
Cl2DecodeFrm2(PAL16_BEIGE + 5, xx, yy, (char *)plr[pnum]._pAnimData, plr[pnum]._pAnimFrame, plr[pnum]._pAnimWidth, 0, dir);
Cl2DecodeFrm1(xx, yy, (char *)plr[pnum]._pAnimData, plr[pnum]._pAnimFrame, plr[pnum]._pAnimWidth, 0, dir);
Cl2DecodeFrm2(PAL16_BEIGE + 5, xx, yy, plr[pnum]._pAnimData, plr[pnum]._pAnimFrame, plr[pnum]._pAnimWidth, 0, dir);
Cl2DecodeFrm1(xx, yy, plr[pnum]._pAnimData, plr[pnum]._pAnimFrame, plr[pnum]._pAnimWidth, 0, dir);
if (some_flag && plr[pnum]._peflag)
town_draw_e_flag(buffer - 64, x - 1, y + 1, a4, dir, sx - 64, sy);
}

87
SourceS/miniwin/com/dsound.inc

@ -1,5 +1,3 @@
typedef void *LPDSBCAPS, *LPCDSBUFFERDESC;
struct IDirectSound;
typedef IDirectSound *LPDIRECTSOUND;
@ -11,31 +9,38 @@ typedef struct _DSBUFFERDESC {
LPWAVEFORMATEX lpwfxFormat;
} DSBUFFERDESC, *LPDSBUFFERDESC;
typedef DSBUFFERDESC *LPDSBCAPS, *LPCDSBUFFERDESC;
DECLARE_INTERFACE_(IDirectSoundBuffer, IUnknown)
{
// clang-format off
STDMETHOD(GetCaps)(THIS_ LPDSBCAPS pDSBufferCaps);
STDMETHOD(GetCurrentPosition)(THIS_ LPDWORD pdwCurrentPlayCursor, LPDWORD pdwCurrentWriteCursor);
STDMETHOD(GetFormat)(THIS_ LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten);
STDMETHOD(GetVolume)(THIS_ LPLONG plVolume);
STDMETHOD(GetPan)(THIS_ LPLONG plPan);
STDMETHOD(GetFrequency)(THIS_ LPDWORD pdwFrequency);
STDMETHOD(GetStatus)(THIS_ LPDWORD pdwStatus);
STDMETHOD(Initialize)(THIS_ LPDIRECTSOUND pDirectSound, LPCDSBUFFERDESC pcDSBufferDesc);
STDMETHOD(GetStatus)(THIS_ LPDWORD pdwStatus) PURE;
STDMETHOD(Lock)(THIS_ DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1,
LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags);
STDMETHOD(Play)(THIS_ DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags);
STDMETHOD(SetCurrentPosition)(THIS_ DWORD dwNewPosition);
STDMETHOD(SetFormat)(THIS_ LPCWAVEFORMATEX pcfxFormat);
STDMETHOD(SetVolume)(THIS_ LONG lVolume);
STDMETHOD(SetPan)(THIS_ LONG lPan);
STDMETHOD(SetFrequency)(THIS_ DWORD dwFrequency);
STDMETHOD(Stop)(THIS);
STDMETHOD(Unlock)(THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2);
STDMETHOD(Restore)(THIS);
LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags) PURE;
STDMETHOD(Play)(THIS_ DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags) PURE;
STDMETHOD(SetFormat)(THIS_ LPCWAVEFORMATEX pcfxFormat) PURE;
STDMETHOD(SetVolume)(THIS_ LONG lVolume) PURE;
STDMETHOD(SetPan)(THIS_ LONG lPan) PURE;
STDMETHOD(Stop)(THIS) PURE;
STDMETHOD(Unlock)(THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2) PURE;
STDMETHOD(Restore)(THIS) PURE;
// clang-format on
};
<<<<<<< HEAD:SourceS/miniwin/com/dsound.inc
=======
#define DSBCAPS_PRIMARYBUFFER 0x00000001
#define DSBCAPS_STATIC 0x00000002
#define DSBCAPS_CTRLPAN 0x00000040
#define DSBCAPS_CTRLVOLUME 0x00000080
#define DSSCL_EXCLUSIVE 0x00000003
#define WAVE_FORMAT_PCM 1
#define ERROR_SUCCESS 0L
>>>>>>> master:SourceS/miniwin_dsound.h
typedef IDirectSoundBuffer *LPDIRECTSOUNDBUFFER;
typedef void *LPUNKNOWN, *LPCGUID;
@ -69,20 +74,46 @@ typedef struct _DSCAPS {
DECLARE_INTERFACE_(IDirectSound, IUnknown)
{
// clang-format off
STDMETHOD(CreateSoundBuffer)(THIS_ LPCDSBUFFERDESC pcDSBufferDesc, LPDIRECTSOUNDBUFFER *ppDSBuffer, LPUNKNOWN pUnkOuter);
STDMETHOD(GetCaps)(THIS_ LPDSCAPS pDSCaps);
STDMETHOD(DuplicateSoundBuffer)(THIS_ LPDIRECTSOUNDBUFFER pDSBufferOriginal, LPDIRECTSOUNDBUFFER *ppDSBufferDuplicate);
STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwLevel);
STDMETHOD(Compact)(THIS);
STDMETHOD(GetSpeakerConfig)(THIS_ LPDWORD pdwSpeakerConfig);
STDMETHOD(SetSpeakerConfig)(THIS_ DWORD dwSpeakerConfig);
STDMETHOD(Initialize)(THIS_ LPCGUID pcGuidDevice);
STDMETHOD(CreateSoundBuffer)(THIS_ LPCDSBUFFERDESC pcDSBufferDesc, LPDIRECTSOUNDBUFFER *ppDSBuffer, LPUNKNOWN pUnkOuter) PURE;
STDMETHOD(GetCaps)(THIS_ LPDSCAPS pDSCaps) PURE;
STDMETHOD(DuplicateSoundBuffer)(THIS_ LPDIRECTSOUNDBUFFER pDSBufferOriginal, LPDIRECTSOUNDBUFFER *ppDSBufferDuplicate) PURE;
STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwLevel) PURE;
// clang-format on
};
<<<<<<< HEAD:SourceS/miniwin/com/dsound.inc
const auto DVL_DSBCAPS_PRIMARYBUFFER = 0x00000001;
const auto DVL_DSBCAPS_STATIC = 0x00000002;
const auto DVL_DSBCAPS_CTRLPAN = 0x00000040;
const auto DVL_DSBCAPS_CTRLVOLUME = 0x00000080;
const auto DVL_WAVE_FORMAT_PCM = 1;
const auto DVL_DS_OK = 0;
=======
#define _FACDS 0x878
#define MAKE_DSHRESULT(code) MAKE_HRESULT(1, _FACDS, code)
#define DSBSTATUS_PLAYING 0x00000001
#define E_NOINTERFACE 0x80004002
#define DSERR_PRIOLEVELNEEDED MAKE_DSHRESULT(70)
#define DSERR_BADFORMAT MAKE_DSHRESULT(100)
#define DSERR_NODRIVER MAKE_DSHRESULT(120)
#define DSERR_ALREADYINITIALIZED MAKE_DSHRESULT(130)
#define DSERR_BUFFERLOST MAKE_DSHRESULT(150)
#define DS_OK 0
#define DSERR_INVALIDCALL MAKE_DSHRESULT(50)
#define DSERR_NOAGGREGATION 0x80040110
#define DSERR_OUTOFMEMORY 0x8007000E
#define DSERR_INVALIDPARAM 0x80070057
#define DSERR_ALLOCATED MAKE_DSHRESULT(10)
#define DSERR_CONTROLUNAVAIL MAKE_DSHRESULT(30)
class DirectSound : public IDirectSound {
public:
METHOD ULONG Release();
METHOD HRESULT CreateSoundBuffer(LPCDSBUFFERDESC pcDSBufferDesc, LPDIRECTSOUNDBUFFER *ppDSBuffer, LPUNKNOWN pUnkOute);
METHOD HRESULT GetCaps(LPDSCAPS pDSCaps);
METHOD HRESULT DuplicateSoundBuffer(LPDIRECTSOUNDBUFFER pDSBufferOriginal, LPDIRECTSOUNDBUFFER *ppDSBufferDuplicate);
METHOD HRESULT SetCooperativeLevel(HWND hwnd, DWORD dwLevel);
};
>>>>>>> master:SourceS/miniwin_dsound.h

2
SourceS/miniwin/misc.h

@ -81,6 +81,7 @@ typedef LONG HRESULT;
typedef LRESULT(CALLBACK *WNDPROC)(HWND, UINT, WPARAM, LPARAM);
#pragma pack(push, 1)
typedef struct waveformat_tag {
WORD wFormatTag;
WORD nChannels;
@ -103,6 +104,7 @@ typedef struct tWAVEFORMATEX {
WORD wBitsPerSample;
WORD cbSize;
} WAVEFORMATEX, *LPWAVEFORMATEX, *LPCWAVEFORMATEX;
#pragma pack(pop)
typedef struct _FILETIME {
DWORD dwLowDateTime;

26
SourceX/dx.cpp

@ -35,17 +35,7 @@ bool surface_dirty;
// DirectDraw COM interface stub implementations
//
#define METHOD virtual
class StubSurface : public IDirectDrawSurface {
METHOD HRESULT QueryInterface(DVL_REFIID refiid, LPVOID *lpvoid)
{
UNIMPLEMENTED();
};
METHOD ULONG AddRef()
{
UNIMPLEMENTED();
};
METHOD ULONG Release()
{
UNIMPLEMENTED();
@ -217,14 +207,6 @@ class StubSurface : public IDirectDrawSurface {
};
class StubPalette : public IDirectDrawPalette {
METHOD HRESULT QueryInterface(DVL_REFIID refiid, LPVOID *lpvoid)
{
UNIMPLEMENTED();
};
METHOD ULONG AddRef()
{
UNIMPLEMENTED();
};
METHOD ULONG Release()
{
UNIMPLEMENTED();
@ -249,14 +231,6 @@ class StubPalette : public IDirectDrawPalette {
};
class StubDraw : public IDirectDraw {
METHOD HRESULT QueryInterface(DVL_REFIID refiid, LPVOID *lpvoid)
{
UNIMPLEMENTED();
};
METHOD ULONG AddRef()
{
UNIMPLEMENTED();
};
METHOD ULONG Release()
{
UNIMPLEMENTED();

121
SourceX/miniwin_dsound.cpp

@ -0,0 +1,121 @@
#include "pch.h"
ULONG __stdcall DirectSound::Release()
{
Mix_CloseAudio();
return 0;
};
HRESULT __stdcall DirectSound::CreateSoundBuffer(LPCDSBUFFERDESC pcDSBufferDesc, LPDIRECTSOUNDBUFFER *ppDSBuffer, LPUNKNOWN pUnkOute)
{
if (pcDSBufferDesc->dwFlags != DSBCAPS_PRIMARYBUFFER) { // Creating primery buffer isn't needed and breaks Music
*ppDSBuffer = new DirectSoundBuffer();
}
return DS_OK;
};
HRESULT __stdcall DirectSound::GetCaps(LPDSCAPS pDSCaps)
{
return DS_OK;
};
/**
* @brief SDL handels this for us when using Mix_PlayChannel(-1);
*/
HRESULT __stdcall DirectSound::DuplicateSoundBuffer(LPDIRECTSOUNDBUFFER pDSBufferOriginal, LPDIRECTSOUNDBUFFER *ppDSBufferDuplicate)
{
UNIMPLEMENTED();
return DS_OK;
};
HRESULT __stdcall DirectSound::SetCooperativeLevel(HWND hwnd, DWORD dwLevel)
{
return DS_OK;
};
///// DirectSoundBuffer /////
ULONG __stdcall DirectSoundBuffer::Release()
{
Mix_FreeChunk(chunk);
return 0;
};
/**
* @brief Only used for handeling duplicates
*/
HRESULT __stdcall DirectSoundBuffer::GetStatus(LPDWORD pdwStatus)
{
return DSERR_INVALIDPARAM;
};
HRESULT __stdcall DirectSoundBuffer::Lock(DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1,
LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags)
{
*pdwAudioBytes1 = dwBytes;
*ppvAudioPtr1 = malloc(dwBytes);
return DS_OK;
};
HRESULT __stdcall DirectSoundBuffer::Play(DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags)
{
int channel = Mix_PlayChannel(-1, chunk, 0);
if (channel == -1) {
SDL_Log("To few channels, skipping sound\n");
return DS_OK;
}
Mix_Volume(channel, volume);
int panned = 255 - 255 * abs(pan) / 10000;
Mix_SetPanning(channel, pan <= 0 ? 255 : panned, pan >= 0 ? 255 : panned);
return DS_OK;
};
HRESULT __stdcall DirectSoundBuffer::SetFormat(LPCWAVEFORMATEX pcfxFormat)
{
return DS_OK;
};
HRESULT __stdcall DirectSoundBuffer::SetVolume(LONG lVolume)
{
volume = MIX_MAX_VOLUME - MIX_MAX_VOLUME * lVolume / VOLUME_MIN;
return DS_OK;
};
HRESULT __stdcall DirectSoundBuffer::SetPan(LONG lPan)
{
pan = lPan;
return DS_OK;
};
HRESULT __stdcall DirectSoundBuffer::Stop()
{
for (int i = 1; i < Mix_AllocateChannels(-1); i++) {
if (Mix_GetChunk(i) != chunk) {
continue;
}
Mix_HaltChannel(i);
}
return DS_OK;
};
HRESULT __stdcall DirectSoundBuffer::Unlock(LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2)
{
SDL_RWops *rw = SDL_RWFromConstMem(pvAudioPtr1, dwAudioBytes1);
chunk = Mix_LoadWAV_RW(rw, 1);
free(pvAudioPtr1);
return DS_OK;
};
HRESULT __stdcall DirectSoundBuffer::Restore()
{
return DS_OK;
};

20
SourceX/pch.h

@ -19,3 +19,23 @@
#include "devilution.h"
#include "DiabloUI/diabloui.h"
struct DirectSoundBuffer : public IDirectSoundBuffer {
public:
METHOD ULONG Release();
BOOL GetStatus(LPDWORD pdwStatus);
HRESULT Lock(DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1,
LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags);
HRESULT Play(DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags);
HRESULT SetFormat(LPCWAVEFORMATEX pcfxFormat);
HRESULT SetVolume(LONG lVolume);
HRESULT SetPan(LONG lPan);
HRESULT Stop();
HRESULT Unlock(LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2);
HRESULT Restore();
private:
int volume = 0;
int pan = 0;
Mix_Chunk *chunk;
};

221
SourceX/sound.cpp

@ -39,17 +39,36 @@ void snd_update(BOOL bStopAll)
{
DWORD error_code, i;
if (!bStopAll)
return;
for (i = 0; i < 8; i++) {
if (!DSBs[i])
continue;
#ifdef __cplusplus
if (!bStopAll && !DSBs[i]->GetStatus(&error_code) && error_code == DSBSTATUS_PLAYING)
continue;
DSBs[i]->Stop();
DSBs[i]->Release();
#else
if (!bStopAll && !DSBs[i]->lpVtbl->GetStatus(DSBs[i], &error_code) && error_code == DSBSTATUS_PLAYING)
continue;
DSBs[i]->lpVtbl->Stop(DSBs[i]);
DSBs[i]->lpVtbl->Release(DSBs[i]);
#endif
Mix_HaltChannel(-1);
DSBs[i] = NULL;
}
}
void snd_stop_snd(TSnd *pSnd)
{
DUMMY_ONCE();
if (pSnd && pSnd->DSB)
Mix_HaltChannel(-1);
#ifdef __cplusplus
pSnd->DSB->Stop();
#else
pSnd->DSB->lpVtbl->Stop(pSnd->DSB);
#endif
}
BOOL snd_playing(TSnd *pSnd)
@ -62,9 +81,14 @@ BOOL snd_playing(TSnd *pSnd)
if (pSnd->DSB == NULL)
return false;
DUMMY_ONCE();
#ifdef __cplusplus
if (pSnd->DSB->GetStatus(&error_code))
#else
if (pSnd->DSB->lpVtbl->GetStatus(pSnd->DSB, &error_code))
#endif
return FALSE;
return false;
return error_code == DVL_DSBSTATUS_PLAYING;
}
void snd_play_snd(TSnd *pSnd, int lVolume, int lPan)
@ -88,24 +112,41 @@ void snd_play_snd(TSnd *pSnd, int lVolume, int lPan)
return;
}
if (snd_playing(pSnd)) {
DSB = sound_dup_channel(pSnd->DSB);
if (DSB == NULL) {
return;
}
}
lVolume += sglSoundVolume;
if (lVolume < VOLUME_MIN) {
lVolume = VOLUME_MIN;
} else if (lVolume > VOLUME_MAX) {
lVolume = VOLUME_MAX;
}
#ifdef __cplusplus
DSB->SetVolume(lVolume);
DSB->SetPan(lPan);
Mix_VolumeChunk((Mix_Chunk *)(pSnd->DSB), MIX_MAX_VOLUME - MIX_MAX_VOLUME * lVolume / VOLUME_MIN);
int channel = Mix_PlayChannel(-1, (Mix_Chunk *)(pSnd->DSB), 0);
if (channel != -1) {
int panned = 255 * abs(lPan) / 10000;
Mix_SetPanning(channel, lPan <= 0 ? 255 : panned, lPan >= 0 ? 255 : panned);
}
error_code = DSB->Play(0, 0, 0);
#else
DSB->lpVtbl->SetVolume(DSB, lVolume);
DSB->lpVtbl->SetPan(DSB, lPan);
error_code = DSB->lpVtbl->Play(DSB, 0, 0, 0);
#endif
if (channel == -1) {
SDL_Log("Mix_PlayChannel: %s\n", SDL_GetError());
if (error_code != DSERR_BUFFERLOST) {
if (error_code != DS_OK) {
DSErrMsg(error_code, 261, "C:\\Src\\Diablo\\Source\\SOUND.CPP");
}
} else if (sound_file_reload(pSnd, DSB)) {
UNIMPLEMENTED();
#ifdef __cplusplus
DSB->Play(0, 0, 0);
#else
DSB->lpVtbl->Play(DSB, 0, 0, 0);
#endif
}
pSnd->start_tc = tc;
@ -120,7 +161,17 @@ LPDIRECTSOUNDBUFFER sound_dup_channel(LPDIRECTSOUNDBUFFER DSB)
}
for (i = 0; i < 8; i++) {
UNIMPLEMENTED();
if (!DSBs[i]) {
#ifdef __cplusplus
if (sglpDS->DuplicateSoundBuffer(DSB, &DSBs[i]) != DS_OK) {
#else
if (sglpDS->lpVtbl->DuplicateSoundBuffer(sglpDS, DSB, &DSBs[i]) != DS_OK) {
#endif
return NULL;
}
return DSBs[i];
}
}
return NULL;
@ -133,13 +184,32 @@ BOOL sound_file_reload(TSnd *sound_file, LPDIRECTSOUNDBUFFER DSB)
DWORD size1, size2;
BOOL rv;
DUMMY_ONCE();
#ifdef __cplusplus
if (DSB->Restore())
#else
if (DSB->lpVtbl->Restore(DSB))
#endif
return FALSE;
rv = false;
WOpenFile(sound_file->sound_path, &file, false);
WSetFilePointer(file, sound_file->chunk.dwOffset, NULL, 0);
#ifdef __cplusplus
if (DSB->Lock(0, sound_file->chunk.dwSize, &buf1, &size1, &buf2, &size2, 0) == DS_OK) {
WReadFile(file, buf1, size1);
if (DSB->Unlock(buf1, size1, buf2, size2) == DS_OK)
rv = TRUE;
}
#else
if (DSB->lpVtbl->Lock(DSB, 0, sound_file->chunk.dwSize, &buf1, &size1, &buf2, &size2, 0) == DS_OK) {
WReadFile(file, buf1, size1);
if (DSB->lpVtbl->Unlock(DSB, buf1, size1, buf2, size2) == DS_OK)
rv = TRUE;
}
#endif
WCloseFile(file);
return rv;
@ -154,7 +224,7 @@ TSnd *sound_file_load(char *path)
DWORD size1, size2;
HRESULT error_code;
if (!gbSndInited)
if (!sglpDS)
return NULL;
WOpenFile(path, &file, false);
@ -163,20 +233,30 @@ TSnd *sound_file_load(char *path)
pSnd->sound_path = path;
pSnd->start_tc = GetTickCount() - 81;
//This opens the file and reads it, makes Mix_chunk pointer to it.
//Once this is done the pointer is stored TSnd Struct
size1 = (int)SFileGetFileSize((HANDLE)file, 0);
wave_file = DiabloAllocPtr(size1);
SFileReadFile(file, (void *)wave_file, size1, (LPDWORD)&size2, 0);
SDL_RWops *rw = SDL_RWFromConstMem((void *)wave_file, size1);
Mix_Chunk *SoundFX = Mix_LoadWAV_RW(rw, 1);
pSnd->DSB = (LPDIRECTSOUNDBUFFER)SoundFX;
if (!pSnd->DSB)
wave_file = LoadWaveFile(file, &pSnd->fmt, &pSnd->chunk);
if (!wave_file)
TermMsg("Invalid sound format on file %s", pSnd->sound_path);
sound_CreateSoundBuffer(pSnd);
#ifdef __cplusplus
error_code = pSnd->DSB->Lock(0, pSnd->chunk.dwSize, &buf1, &size1, &buf2, &size2, 0);
#else
error_code = pSnd->DSB->lpVtbl->Lock(pSnd->DSB, 0, pSnd->chunk.dwSize, &buf1, &size1, &buf2, &size2, 0);
#endif
if (error_code != DS_OK)
DSErrMsg(error_code, 318, "C:\\Src\\Diablo\\Source\\SOUND.CPP");
memcpy(buf1, wave_file + pSnd->chunk.dwOffset, size1);
#ifdef __cplusplus
error_code = pSnd->DSB->Unlock(buf1, size1, buf2, size2);
#else
error_code = pSnd->DSB->lpVtbl->Unlock(pSnd->DSB, buf1, size1, buf2, size2);
#endif
if (error_code != DS_OK)
DSErrMsg(error_code, 325, "C:\\Src\\Diablo\\Source\\SOUND.CPP");
mem_free_dbg((void *)wave_file);
WCloseFile(file);
@ -195,14 +275,30 @@ void sound_CreateSoundBuffer(TSnd *sound_file)
DSB.lpwfxFormat = &sound_file->fmt;
DSB.dwSize = sizeof(DSBUFFERDESC);
DSB.dwFlags = DVL_DSBCAPS_CTRLVOLUME | DVL_DSBCAPS_CTRLPAN | DVL_DSBCAPS_STATIC;
sound_file->chunk.dwSize += sound_file->chunk.dwOffset;
sound_file->chunk.dwOffset = 0;
#ifdef __cplusplus
error_code = sglpDS->CreateSoundBuffer(&DSB, &sound_file->DSB, NULL);
#else
error_code = sglpDS->lpVtbl->CreateSoundBuffer(sglpDS, &DSB, &sound_file->DSB, NULL);
#endif
if (error_code != ERROR_SUCCESS)
DSErrMsg(error_code, 282, "C:\\Src\\Diablo\\Source\\SOUND.CPP");
}
void sound_file_cleanup(TSnd *sound_file)
{
if (sound_file) {
if (sound_file->DSB) {
DUMMY_ONCE();
Mix_FreeChunk((Mix_Chunk *)sound_file->DSB);
#ifdef __cplusplus
sound_file->DSB->Stop();
sound_file->DSB->Release();
#else
sound_file->DSB->lpVtbl->Stop(sound_file->DSB);
sound_file->DSB->lpVtbl->Release(sound_file->DSB);
#endif
sound_file->DSB = NULL;
}
@ -212,23 +308,26 @@ void sound_file_cleanup(TSnd *sound_file)
void snd_init(HWND hWnd)
{
DUMMY();
sound_load_volume("Sound Volume", &sglSoundVolume);
gbSoundOn = sglSoundVolume > VOLUME_MIN;
sound_load_volume("Music Volume", &sglMusicVolume);
gbMusicOn = sglMusicVolume > VOLUME_MIN;
if (Mix_OpenAudio(44100, AUDIO_S16LSB, 2, 1024) != 0) {
if (sound_DirectSoundCreate(NULL, &sglpDS, NULL) != DS_OK)
sglpDS = NULL;
#ifdef __cplusplus
if (sglpDS && sglpDS->SetCooperativeLevel(hWnd, DSSCL_EXCLUSIVE) == DS_OK)
#else
if (sglpDS && sglpDS->lpVtbl->SetCooperativeLevel(sglpDS, hWnd, DSSCL_EXCLUSIVE) == DS_OK)
#endif
sound_create_primary_buffer(NULL);
}
SVidInitialize(sglpDS);
SFileDdaInitialize(sglpDS);
gbSndInited = true;
gbSndInited = sglpDS != NULL;
}
void sound_load_volume(char *value_name, int *value)
@ -249,7 +348,6 @@ void sound_load_volume(char *value_name, int *value)
void sound_create_primary_buffer(HANDLE music_track)
{
DUMMY();
HRESULT error_code;
DSBUFFERDESC dsbuf;
WAVEFORMATEX format;
@ -303,8 +401,8 @@ void sound_create_primary_buffer(HANDLE music_track)
HRESULT sound_DirectSoundCreate(LPGUID lpGuid, LPDIRECTSOUND *ppDS, LPUNKNOWN pUnkOuter)
{
UNIMPLEMENTED();
HRESULT(* DirectSoundCreate)
DUMMY();
HRESULT(*DirectSoundCreate)
(LPGUID lpGuid, LPDIRECTSOUND * ppDS, LPUNKNOWN pUnkOuter);
if (hDsound_dll == NULL) {
@ -312,11 +410,13 @@ HRESULT sound_DirectSoundCreate(LPGUID lpGuid, LPDIRECTSOUND *ppDS, LPUNKNOWN pU
}
}
DirectSoundCreate = NULL;
if (DirectSoundCreate == NULL) {
ErrDlg(IDD_DIALOG5, GetLastError(), "C:\\Src\\Diablo\\Source\\SOUND.CPP", 427);
}
return DirectSoundCreate(lpGuid, ppDS, pUnkOuter);
*ppDS = new DirectSound();
int result = Mix_OpenAudio(22050, AUDIO_S16LSB, 2, 1024);
Mix_AllocateChannels(25);
Mix_ReserveChannels(1); // reserve one channel for naration (SFileDda*)
return result;
}
void sound_cleanup()
@ -325,8 +425,12 @@ void sound_cleanup()
SVidDestroy();
SFileDdaDestroy();
if (gbSndInited) {
DUMMY();
if (sglpDS) {
#ifdef __cplusplus
sglpDS->Release();
#else
sglpDS->lpVtbl->Release(sglpDS);
#endif
sglpDS = NULL;
}
@ -358,7 +462,7 @@ void music_start(int nTrack)
/// ASSERT: assert((DWORD) nTrack < NUM_MUSIC);
music_stop();
if (gbSndInited && gbMusicOn) {
if (sglpDS && gbMusicOn) {
#ifdef _DEBUG
SFileEnableDirectAccess(false);
#endif
@ -416,31 +520,4 @@ int sound_get_or_set_sound_volume(int volume)
return sglSoundVolume;
}
/*
SDL_AudioSpec wanted;
static Uint32 audio_len;
static Uint8 *audio_pos;
void fill_audio(void *udata, Uint8 *stream, int len)
{
//DUMMY();
//wanted.freq = 44100; //seems not to be used at this time
//wanted.format = AUDIO_S16LSB; //seems not to be used at this time
//wanted.channels = 2; // 1 = mono, 2 = stereo, seems not to be used at this time
//wanted.samples = 1024; // Good low-latency value for callback, seems not to be used at this time
//wanted.callback = fill_audio; //seems not to be used at this time
//wanted.userdata = NULL; //seems not to be used at this time
// Only play if we have data left
if (audio_len == 0)
return;
// Mix as much data as possible
len = (len > audio_len ? audio_len : len);
SDL_MixAudio(stream, audio_pos, len, SDL_MIX_MAXVOLUME);
audio_pos += len;
audio_len -= len;
}
*/
}
} // namespace dvl

Loading…
Cancel
Save