original game source as is

This commit is contained in:
HarpyWar 2020-04-05 21:28:01 +03:00
commit 0c9dda2f03
2083 changed files with 326042 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
HELLFIRE.MPQ
*.COD
*.obj
*.MAP
*.PDB

785
src/APPFAT.CPP Normal file
View File

@ -0,0 +1,785 @@
//***********************************************************************
// Assertion System
//
// Copyright (c) 1996 by Blizzard Entertainment.
// All rights reserved.
//***********************************************************************
#include "diablo.h"
#pragma hdrstop
#include <tchar.h>
#include "storm.h"
#include "resource.h"
//***********************************************************************
// Externals
//***********************************************************************
void cleanup(BOOL bNormalExit);
//***********************************************************************
//***********************************************************************
/*
void DebugDump2(const char * pszFmt,va_list args) {
static FILE * f = NULL;
if (! f) f = fopen("c:\\hellfr__.dbg","wt");
if (! f) return;
vfprintf(f,pszFmt,args);
fflush(f);
}
void __cdecl DebugDump(const char * pszFmt, ...) {
va_list args;
va_start(args,pszFmt);
DebugDump2(pszFmt,args);
va_end(args);
}
*/
//***********************************************************************
// WARNING: the code below ONLY works on x86 compatible systems
//***********************************************************************
#ifdef _X86_
#ifndef NDEBUG
static LONG WINAPI BreakExceptionHdlr(struct _EXCEPTION_POINTERS *pep) {
// if we got a breakpoint exception, we expected it -- keep running
PEXCEPTION_RECORD per = pep->ExceptionRecord;
if (per && per->ExceptionCode == EXCEPTION_BREAKPOINT) {
// in windows 95, the int3 instruction will already be
// skipped by the time we get here. In windows NT, the
// Eip will still point to the int3 instruction. Therefore
// look at the offending byte, and if it is int3 (0xcc) then
// skip over the instruction
BYTE * pInst = (BYTE *) pep->ContextRecord->Eip;
if (*pInst == 0xcc) pep->ContextRecord->Eip += 1;
// continue execution
return EXCEPTION_CONTINUE_EXECUTION;
}
return EXCEPTION_CONTINUE_SEARCH;
}
#endif
#endif
//***********************************************************************
//***********************************************************************
void myDebugBreak() {
#ifndef NDEBUG
// -- Save current exception handler and set it
// to a handler which expects a break to occur.
// -- If we are in the debugger, the debugger will
// override our exception handler, and we will
// drop into the debugger.
// -- If there is no debugger present, our exception
// handler will skip over the break instruction
// and allow normal execution of the program
LPTOP_LEVEL_EXCEPTION_FILTER lpLastHdlr;
lpLastHdlr = SetUnhandledExceptionFilter(BreakExceptionHdlr);
// drop into the debugger
__asm int 3
// restore exception handler
SetUnhandledExceptionFilter(lpLastHdlr);
#endif
}
//***********************************************************************
//***********************************************************************
static void get_ddraw_error(HRESULT ddrval,TCHAR * pszBuf,DWORD dwMaxChars) {
const TCHAR * pszErr;
// @@ eventually we should get these from our resource file
// so that they can be properly translated and so
// they don't have to stay loaded all the time
switch (ddrval) {
case DD_OK:
pszErr = "DD_OK";
break;
case DDERR_ALREADYINITIALIZED:
pszErr = "DDERR_ALREADYINITIALIZED";
break;
case DDERR_BLTFASTCANTCLIP:
pszErr = "DDERR_BLTFASTCANTCLIP";
break;
case DDERR_CANNOTATTACHSURFACE:
pszErr = "DDERR_CANNOTATTACHSURFACE";
break;
case DDERR_CANNOTDETACHSURFACE:
pszErr = "DDERR_CANNOTDETACHSURFACE";
break;
case DDERR_CANTCREATEDC:
pszErr = "DDERR_CANTCREATEDC";
break;
case DDERR_CANTDUPLICATE:
pszErr = "DDERR_CANTDUPLICATE";
break;
case DDERR_CLIPPERISUSINGHWND:
pszErr = "DDERR_CLIPPERISUSINGHWND";
break;
case DDERR_COLORKEYNOTSET:
pszErr = "DDERR_COLORKEYNOTSET";
break;
case DDERR_CURRENTLYNOTAVAIL:
pszErr = "DDERR_CURRENTLYNOTAVAIL";
break;
case DDERR_DIRECTDRAWALREADYCREATED:
pszErr = "DDERR_DIRECTDRAWALREADYCREATED";
break;
case DDERR_EXCEPTION:
pszErr = "DDERR_EXCEPTION";
break;
case DDERR_EXCLUSIVEMODEALREADYSET:
pszErr = "DDERR_EXCLUSIVEMODEALREADYSET";
break;
case DDERR_GENERIC:
pszErr = "DDERR_GENERIC";
break;
case DDERR_HEIGHTALIGN:
pszErr = "DDERR_HEIGHTALIGN";
break;
case DDERR_HWNDALREADYSET:
pszErr = "DDERR_HWNDALREADYSET";
break;
case DDERR_HWNDSUBCLASSED:
pszErr = "DDERR_HWNDSUBCLASSED";
break;
case DDERR_IMPLICITLYCREATED:
pszErr = "DDERR_IMPLICITLYCREATED";
break;
case DDERR_INCOMPATIBLEPRIMARY:
pszErr = "DDERR_INCOMPATIBLEPRIMARY";
break;
case DDERR_INVALIDCAPS:
pszErr = "DDERR_INVALIDCAPS";
break;
case DDERR_INVALIDCLIPLIST:
pszErr = "DDERR_INVALIDCLIPLIST";
break;
case DDERR_INVALIDDIRECTDRAWGUID:
pszErr = "DDERR_INVALIDDIRECTDRAWGUID";
break;
case DDERR_INVALIDMODE:
pszErr = "DDERR_INVALIDMODE";
break;
case DDERR_INVALIDOBJECT:
pszErr = "DDERR_INVALIDOBJECT";
break;
case DDERR_INVALIDPARAMS:
pszErr = "DDERR_INVALIDPARAMS";
break;
case DDERR_INVALIDPIXELFORMAT:
pszErr = "DDERR_INVALIDPIXELFORMAT";
break;
case DDERR_INVALIDPOSITION:
pszErr = "DDERR_INVALIDPOSITION";
break;
case DDERR_INVALIDRECT:
pszErr = "DDERR_INVALIDRECT";
break;
case DDERR_LOCKEDSURFACES:
pszErr = "DDERR_LOCKEDSURFACES";
break;
case DDERR_NO3D:
pszErr = "DDERR_NO3D";
break;
case DDERR_NOALPHAHW:
pszErr = "DDERR_NOALPHAHW";
break;
case DDERR_NOBLTHW:
pszErr = "DDERR_NOBLTHW";
break;
case DDERR_NOCLIPLIST:
pszErr = "DDERR_NOCLIPLIST";
break;
case DDERR_NOCLIPPERATTACHED:
pszErr = "DDERR_NOCLIPPERATTACHED";
break;
case DDERR_NOCOLORCONVHW:
pszErr = "DDERR_NOCOLORCONVHW";
break;
case DDERR_NOCOLORKEY:
pszErr = "DDERR_NOCOLORKEY";
break;
case DDERR_NOCOLORKEYHW:
pszErr = "DDERR_NOCOLORKEYHW";
break;
case DDERR_NOCOOPERATIVELEVELSET:
pszErr = "DDERR_NOCOOPERATIVELEVELSET";
break;
case DDERR_NODC:
pszErr = "DDERR_NODC";
break;
case DDERR_NODDROPSHW:
pszErr = "DDERR_NODDROPSHW";
break;
case DDERR_NODIRECTDRAWHW:
pszErr = "DDERR_NODIRECTDRAWHW";
break;
case DDERR_NOEMULATION:
pszErr = "DDERR_NOEMULATION";
break;
case DDERR_NOEXCLUSIVEMODE:
pszErr = "DDERR_NOEXCLUSIVEMODE";
break;
case DDERR_NOFLIPHW:
pszErr = "DDERR_NOFLIPHW";
break;
case DDERR_NOGDI:
pszErr = "DDERR_NOGDI";
break;
case DDERR_NOHWND:
pszErr = "DDERR_NOHWND";
break;
case DDERR_NOMIRRORHW:
pszErr = "DDERR_NOMIRRORHW";
break;
case DDERR_NOOVERLAYDEST:
pszErr = "DDERR_NOOVERLAYDEST";
break;
case DDERR_NOOVERLAYHW:
pszErr = "DDERR_NOOVERLAYHW";
break;
case DDERR_NOPALETTEATTACHED:
pszErr = "DDERR_NOPALETTEATTACHED";
break;
case DDERR_NOPALETTEHW:
pszErr = "DDERR_NOPALETTEHW";
break;
case DDERR_NORASTEROPHW:
pszErr = "DDERR_NORASTEROPHW";
break;
case DDERR_NOROTATIONHW:
pszErr = "DDERR_NOROTATIONHW";
break;
case DDERR_NOSTRETCHHW:
pszErr = "DDERR_NOSTRETCHHW";
break;
case DDERR_NOT4BITCOLOR:
pszErr = "DDERR_NOT4BITCOLOR";
break;
case DDERR_NOT4BITCOLORINDEX:
pszErr = "DDERR_NOT4BITCOLORINDEX";
break;
case DDERR_NOT8BITCOLOR:
pszErr = "DDERR_NOT8BITCOLOR";
break;
case DDERR_NOTAOVERLAYSURFACE:
pszErr = "DDERR_NOTAOVERLAYSURFACE";
break;
case DDERR_NOTEXTUREHW:
pszErr = "DDERR_NOTEXTUREHW";
break;
case DDERR_NOTFLIPPABLE:
pszErr = "DDERR_NOTFLIPPABLE";
break;
case DDERR_NOTFOUND:
pszErr = "DDERR_NOTFOUND";
break;
case DDERR_NOTLOCKED:
pszErr = "DDERR_NOTLOCKED";
break;
case DDERR_NOTPALETTIZED:
pszErr = "DDERR_NOTPALETTIZED";
break;
case DDERR_NOVSYNCHW:
pszErr = "DDERR_NOVSYNCHW";
break;
case DDERR_NOZBUFFERHW:
pszErr = "DDERR_NOZBUFFERHW";
break;
case DDERR_NOZOVERLAYHW:
pszErr = "DDERR_NOZOVERLAYHW";
break;
case DDERR_OUTOFCAPS:
pszErr = "DDERR_OUTOFCAPS";
break;
case DDERR_OUTOFMEMORY:
pszErr = "DDERR_OUTOFMEMORY";
break;
case DDERR_OUTOFVIDEOMEMORY:
pszErr = "DDERR_OUTOFVIDEOMEMORY";
break;
case DDERR_OVERLAYCANTCLIP:
pszErr = "DDERR_OVERLAYCANTCLIP";
break;
case DDERR_OVERLAYCOLORKEYONLYONEACTIVE:
pszErr = "DDERR_OVERLAYCOLORKEYONLYONEACTIVE";
break;
case DDERR_OVERLAYNOTVISIBLE:
pszErr = "DDERR_OVERLAYNOTVISIBLE";
break;
case DDERR_PALETTEBUSY:
pszErr = "DDERR_PALETTEBUSY";
break;
case DDERR_PRIMARYSURFACEALREADYEXISTS:
pszErr = "DDERR_PRIMARYSURFACEALREADYEXISTS";
break;
case DDERR_REGIONTOOSMALL:
pszErr = "DDERR_REGIONTOOSMALL";
break;
case DDERR_SURFACEALREADYATTACHED:
pszErr = "DDERR_SURFACEALREADYATTACHED";
break;
case DDERR_SURFACEALREADYDEPENDENT:
pszErr = "DDERR_SURFACEALREADYDEPENDENT";
break;
case DDERR_SURFACEBUSY:
pszErr = "DDERR_SURFACEBUSY";
break;
case DDERR_SURFACEISOBSCURED:
pszErr = "DDERR_SURFACEISOBSCURED";
break;
case DDERR_SURFACELOST:
pszErr = "DDERR_SURFACELOST";
break;
case DDERR_SURFACENOTATTACHED:
pszErr = "DDERR_SURFACENOTATTACHED";
break;
case DDERR_TOOBIGHEIGHT:
pszErr = "DDERR_TOOBIGHEIGHT";
break;
case DDERR_TOOBIGSIZE:
pszErr = "DDERR_TOOBIGSIZE";
break;
case DDERR_TOOBIGWIDTH:
pszErr = "DDERR_TOOBIGWIDTH";
break;
case DDERR_UNSUPPORTED:
pszErr = "DDERR_UNSUPPORTED";
break;
case DDERR_UNSUPPORTEDFORMAT:
pszErr = "DDERR_UNSUPPORTEDFORMAT";
break;
case DDERR_UNSUPPORTEDMASK:
pszErr = "DDERR_UNSUPPORTEDMASK";
break;
case DDERR_VERTICALBLANKINPROGRESS:
pszErr = "DDERR_VERTICALBLANKINPROGRESS";
break;
case DDERR_WASSTILLDRAWING:
pszErr = "DDERR_WASSTILLDRAWING";
break;
case DDERR_WRONGMODE:
pszErr = "DDERR_WRONGMODE";
break;
case DDERR_XALIGN:
pszErr = "DDERR_XALIGN";
break;
case DDERR_CANTLOCKSURFACE:
pszErr = "DDERR_CANTLOCKSURFACE";
break;
case DDERR_CANTPAGELOCK:
pszErr = "DDERR_CANTPAGELOCK";
break;
case DDERR_CANTPAGEUNLOCK:
pszErr = "DDERR_CANTPAGEUNLOCK";
break;
case DDERR_DCALREADYCREATED:
pszErr = "DDERR_DCALREADYCREATED";
break;
case DDERR_INVALIDSURFACETYPE:
pszErr = "DDERR_INVALIDSURFACETYPE";
break;
case DDERR_NOMIPMAPHW:
pszErr = "DDERR_NOMIPMAPHW";
break;
case DDERR_NOTPAGELOCKED:
pszErr = "DDERR_NOTPAGELOCKED";
break;
default:
const TCHAR szUnknown[] = "DDERR unknown 0x%x";
app_assert(dwMaxChars >= sizeof(szUnknown) + 10);
sprintf(pszBuf,szUnknown,ddrval);
return;
}
_tcsncpy(pszBuf,pszErr,dwMaxChars);
}
//***********************************************************************
//***********************************************************************
static void get_dsound_error(HRESULT dsrval,TCHAR * pszBuf,DWORD dwMaxChars) {
const TCHAR * pszErr;
// @@ eventually we should get these from our resource file
// so that they can be properly translated and so
// they don't have to stay loaded all the time
switch(dsrval) {
case DS_OK:
pszErr = "DS_OK";
break;
case DSERR_ALLOCATED:
pszErr = "DSERR_ALLOCATED";
break;
case DSERR_ALREADYINITIALIZED:
pszErr = "DSERR_ALREADYINITIALIZED";
break;
case DSERR_BADFORMAT:
pszErr = "DSERR_BADFORMAT";
break;
case DSERR_BUFFERLOST:
pszErr = "DSERR_BUFFERLOST";
break;
case DSERR_CONTROLUNAVAIL:
pszErr = "DSERR_CONTROLUNAVAIL";
break;
case DSERR_INVALIDCALL:
pszErr = "DSERR_INVALIDCALL";
break;
case DSERR_INVALIDPARAM:
pszErr = "DSERR_INVALIDPARAM";
break;
case DSERR_NOAGGREGATION:
pszErr = "DSERR_NOAGGREGATION";
break;
case DSERR_NODRIVER:
pszErr = "DSERR_NODRIVER";
break;
case DSERR_OUTOFMEMORY:
pszErr = "DSERR_OUTOFMEMORY";
break;
case DSERR_PRIOLEVELNEEDED:
pszErr = "DSERR_PRIOLEVELNEEDED";
break;
case E_NOINTERFACE:
pszErr = "E_NOINTERFACE";
break;
default:
const TCHAR szUnknown[] = "DSERR unknown 0x%x";
app_assert(dwMaxChars >= sizeof(szUnknown) + 10);
sprintf(pszBuf,szUnknown,dsrval);
return;
}
_tcsncpy(pszBuf,pszErr,dwMaxChars);
}
//***********************************************************************
//***********************************************************************
// pjw.patch3.start -- changes due to STORM error handling
const TCHAR * strGetError(DWORD dwErr) {
static TCHAR szBuf[256];
if (HRESULT_FACILITY(dwErr) == _FACDS) {
get_dsound_error(dwErr,szBuf,sizeof(szBuf) / sizeof(szBuf[0]));
}
else if (HRESULT_FACILITY(dwErr) == _FACDD) {
get_ddraw_error(dwErr,szBuf,sizeof(szBuf) / sizeof(szBuf[0]));
}
else if (SErrGetErrorStr(dwErr,szBuf,sizeof(szBuf) / sizeof(szBuf[0]))) {
// got storm message
}
else if (!FormatMessage(
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
dwErr,
MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),
szBuf,
sizeof(szBuf) / sizeof(szBuf[0]),
NULL
)) {
wsprintf(szBuf,"unknown error 0x%08x",dwErr);
}
// remove trailing newline crap
int nLen = strlen(szBuf);
char * pszTemp = szBuf + nLen - 1;
while (nLen-- > 0) {
pszTemp--;
if (*pszTemp == '\r' || *pszTemp == '\n')
*pszTemp = 0;
else
break;
}
return szBuf;
}
// pjw.patch3.end
//***********************************************************************
//***********************************************************************
const TCHAR * strGetLastError() {
return strGetError(GetLastError());
}
//***********************************************************************
//***********************************************************************
static void app_debug_msg(const char * pszFmt,va_list args) {
char szBuf[256];
wvsprintf(szBuf,pszFmt,args);
#ifdef _DEBUG
OutputDebugString(szBuf);
OutputDebugString(TEXT("\n"));
#endif
// turn off "topmost" flag so that we don't stick above debugger
if (ghMainWnd) SetWindowPos(ghMainWnd, HWND_NOTOPMOST, 0, 0, 0, 0,
SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
// can't use storm -- it might be dead
MessageBox(ghMainWnd,szBuf,"ERROR",MB_ICONERROR | MB_OK | MB_TASKMODAL);
}
//***********************************************************************
//***********************************************************************
static void pre_fatal_cleanup() {
// if we fatal from a subsidiary thread, it may kill
// off things which are needed by other threads, so
// if we are already fataling, give the other thread
// some time to die
static BOOL sbInFatal = 0;
static unsigned snThreadID = 0;
if (sbInFatal && snThreadID != GetCurrentThreadId())
Sleep(20000);
sbInFatal = 1;
snThreadID = GetCurrentThreadId();
// kill off direct draw so that dialogs will be visible
void free_directx();
free_directx();
// for multiplayer games, make sure our fatal
// handler doesn't cause other players to timeout
extern BYTE gbMaxPlayers;
if (gbMaxPlayers > 1) {
if (SNetLeaveGame(SNET_EXIT_AUTO_SHUTDOWN))
Sleep(2000);
}
// kill off network play
SNetDestroy();
// make sure cursor is visible for any dialog box we display
ShowCursor(TRUE);
}
//***********************************************************************
//***********************************************************************
void __cdecl app_fatal(const char * pszFmt,...) {
pre_fatal_cleanup();
// break into debugger
myDebugBreak();
if (pszFmt) {
va_list args;
va_start(args,pszFmt);
app_debug_msg(pszFmt,args);
va_end(args);
}
cleanup(FALSE);
exit(1);
ExitProcess(1); // just in case
}
//***********************************************************************
//***********************************************************************
void __cdecl app_warning(const char * pszFmt,...) {
app_assert(pszFmt);
char szBuf[256];
va_list args;
va_start(args,pszFmt);
wvsprintf(szBuf,pszFmt,args);
va_end(args);
SDrawMessageBox(
szBuf,
"Hellfire",
MB_ICONEXCLAMATION | MB_OK | MB_TASKMODAL
);
}
//***********************************************************************
//***********************************************************************
#if EXTENDED_ASSERT
void assert_fail(int nLineNo, const char * pszFile, const char * pszFail) {
app_fatal("assertion failed (%d:%s)\n%s",nLineNo,pszFile,pszFail);
}
#else
void assert_fail(int nLineNo, const char * pszFile) {
app_fatal("assertion failed (%d:%s)",nLineNo,pszFile);
}
#endif
//***********************************************************************
//***********************************************************************
void ddraw_assert_fail(HRESULT ddrval, int nLineNo, const char * pszFile) {
if (ddrval == DD_OK) return;
app_fatal(
"Direct draw error (%s:%d)\n%s",
pszFile,
nLineNo,
strGetError(ddrval)
);
}
//***********************************************************************
//***********************************************************************
void dsound_assert_fail(HRESULT dsrval, int nLineNo, const char * pszFile) {
if (dsrval == DS_OK) return;
app_fatal(
"Direct sound error (%s:%d)\n%s",
pszFile,
nLineNo,
strGetError(dsrval)
);
}
//******************************************************************
//******************************************************************
void center_window(HWND hWnd) {
RECT r;
GetWindowRect(hWnd,&r);
int cxWnd = r.right - r.left;
int cyWnd = r.bottom - r.top;
// get display limits
HDC hdc = GetDC(hWnd);
int cxScreen = GetDeviceCaps(hdc,HORZRES);
int cyScreen = GetDeviceCaps(hdc,VERTRES);
ReleaseDC(hWnd,hdc);
// Calculate new X position, then adjust for screen
int xNew = (cxScreen - cxWnd) / 2;
if (! SetWindowPos(
hWnd,
NULL,
(cxScreen - cxWnd) / 2,
(cyScreen - cyWnd) / 2,
0,
0,
SWP_NOSIZE | SWP_NOZORDER
)) app_fatal("center_window: %s",strGetLastError());
}
//******************************************************************
//******************************************************************
static void ErrorDlgInit(HWND hWnd,LPARAM lParam) {
center_window(hWnd);
if (lParam) SetDlgItemText(hWnd,IDC_ERROR_TAG,(LPCTSTR) lParam);
}
//******************************************************************
//******************************************************************
static BOOL CALLBACK ErrorDlgProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) {
switch (uMsg) {
case WM_INITDIALOG:
ErrorDlgInit(hWnd,lParam);
break;
case WM_COMMAND:
if (IDOK == GET_WM_COMMAND_ID(wParam,lParam))
EndDialog(hWnd,TRUE);
else if (IDCANCEL == GET_WM_COMMAND_ID(wParam,lParam))
EndDialog(hWnd,FALSE);
break;
default:
return FALSE;
}
return TRUE;
}
//******************************************************************
//******************************************************************
void ErrorDlg(int nDlgId,DWORD dwErr,const char * pszFile,int nLine) {
pre_fatal_cleanup();
char szBuf[512];
const char * pszTemp = strrchr(pszFile,'\\');
if (pszTemp) pszFile = pszTemp + 1;
wsprintf(szBuf,"%s\nat: %s line %d",strGetError(dwErr),pszFile,nLine);
#ifdef _DEBUG
OutputDebugString(szBuf);
OutputDebugString(TEXT("\n"));
#endif
if (-1 == DialogBoxParam(
ghInst,
MAKEINTRESOURCE(nDlgId),
ghMainWnd,
ErrorDlgProc,
(LPARAM) szBuf
)) app_fatal("ErrDlg: %d",nDlgId);
app_fatal(NULL);
}
//******************************************************************
//******************************************************************
void FileErrorDlg(const char * pszName) {
pre_fatal_cleanup();
if (! pszName) pszName = "";
if (-1 == DialogBoxParam(
ghInst,
MAKEINTRESOURCE(IDD_FILE_ERR),
ghMainWnd,
ErrorDlgProc,
(LPARAM) pszName
)) app_fatal("FileErrDlg");
app_fatal(NULL);
}
//******************************************************************
//******************************************************************
void DiskFreeErrorDlg(const char * pszDir) {
pre_fatal_cleanup();
if (-1 == DialogBoxParam(
ghInst,
MAKEINTRESOURCE(IDD_DISKFREE_ERR),
ghMainWnd,
ErrorDlgProc,
(LPARAM) pszDir
)) app_fatal("DiskFreeDlg");
app_fatal(NULL);
}
//******************************************************************
//******************************************************************
// pjw.patch1.start.1/13/97
BOOL InsertCDDlg(void) {
ShowCursor(TRUE);
int nResult;
if (-1 == (nResult = DialogBoxParam(
ghInst,
MAKEINTRESOURCE(IDD_CDROM_ERR),
ghMainWnd,
ErrorDlgProc,
(LPARAM) ""
))) app_fatal("InsertCDDlg");
ShowCursor(FALSE);
return nResult == IDOK;
}
// pjw.patch1.end.1/13/97

839
src/AUTOMAP.CPP Normal file
View File

@ -0,0 +1,839 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Automap file
**
** (C)1995 Condor, Inc. All rights reserved.
**
**-----------------------------------------------------------------------**
** $Header: /Diablo/AUTOMAP.CPP 1 1/22/97 2:06p Dgartner $
**-----------------------------------------------------------------------**
**
** File Routines
**-----------------------------------------------------------------------*/
#include "diablo.h"
#pragma hdrstop
#include "automap.h"
#include "engine.h"
#include "gendung.h"
#include "scrollrt.h"
#include "items.h"
#include "player.h"
#include "control.h"
#include "inv.h"
#include "quests.h"
#include "multi.h"
#include "setmaps.h"
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
#define AUTOMAPMAX 200
#define AUTOMAPMIN 50
#define AUTOMAPADD 5
#define AUTOMAPST ((AUTOMAPMAX-AUTOMAPMIN)/AUTOMAPADD)+1
#define MAXMEGA MAXTILES/4
#define AMDC 144
#define AMLC 200
#define AMPC 153 //129
#define AMS_DOORL 0x01
#define AMS_DOORR 0x02
#define AMS_ARCHL 0x04
#define AMS_ARCHR 0x08
#define AMS_GRATEL 0x10
#define AMS_GRATER 0x20
#define AMS_DIRT 0x40
#define AMS_STAIRS 0x80
#define AMS_NONEL 0x15
#define AMS_NONER 0x2a
#define AMS_DIRT8 0x4000 // AMS_DIRT << 8
#define AMS_DIRTLR 0x4007 // Lower right dirt piece
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
BOOL automapflag;
int automapscale;
int automaps1, automaps2, automaps3, automaps4, automaps5;
int automapx, automapy;
int amxadd, amyadd;
char automapstbl[AUTOMAPST];
WORD automaptype[MAXMEGA];
BYTE automapview[AUTOMAPX][AUTOMAPY];
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
void InitAutomapOnce()
{
automapflag = FALSE;
automapscale = AUTOMAPMIN;
automaps1 = (automapscale << 6) / 100;
automaps2 = automaps1 >> 1;
automaps3 = automaps2 >> 1;
automaps4 = automaps3 >> 1;
automaps5 = automaps4 >> 1;
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
void InitAutomap()
{
int i, j, a, v;
DWORD dwTiles;
byte *pAFile, *pTmp;
a = AUTOMAPMIN;
for (i = 0; i < AUTOMAPST; i++) {
v = (a << 6) / 100;
automapstbl[i] = ((320 / v) << 1) + 1;
if ((320 % v) != 0) automapstbl[i]++;
if ((320 % v) >= ((a << 5) / 100)) automapstbl[i]++;
a += AUTOMAPADD;
}
ZeroMemory(automaptype,sizeof(automaptype));
switch (leveltype) {
case 1:
if (currlevel < CRYPTSTART)
{
pAFile = LoadFileInMemSig("Levels\\L1Data\\L1.AMP",&dwTiles,'AMAP');
dwTiles /= 2;
}
else
{
pAFile = LoadFileInMemSig("NLevels\\L5Data\\L5.AMP",&dwTiles,'AMAP');
dwTiles /= 2;
}
break;
case 2:
pAFile = LoadFileInMemSig("Levels\\L2Data\\L2.AMP",&dwTiles,'AMAP');
dwTiles /= 2;
break;
case 3:
if (currlevel < HIVESTART)
{
pAFile = LoadFileInMemSig("Levels\\L3Data\\L3.AMP",&dwTiles,'AMAP');
dwTiles /= 2;
}
else
{
pAFile = LoadFileInMemSig("NLevels\\L6Data\\L6.AMP",&dwTiles,'AMAP');
dwTiles /= 2;
}
break;
case 4:
pAFile = LoadFileInMemSig("Levels\\L4Data\\L4.AMP",&dwTiles,'AMAP');
dwTiles /= 2;
break;
default:
// get out!
return;
}
pTmp = pAFile;
for (DWORD d = 1; d <= dwTiles; d++) {
byte b1 = *pTmp++;
byte b2 = *pTmp++;
automaptype[d] = b1 + (b2 << 8);
}
DiabloFreePtr(pAFile);
// Clear automap vision
ZeroMemory(automapview,sizeof(automapview));
// Get rid of any residue prevision calls
for (j = 0; j < DMAXY; j++) {
for (i = 0; i < DMAXX; i++)
dFlags[i][j] &= BFMASK_AUTOMAP;
}
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
void StartAutomap()
{
amxadd = 0;
amyadd = 0;
automapflag = TRUE;
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
void AutomapUp()
{
amxadd--;
amyadd--;
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
void AutomapDown()
{
amxadd++;
amyadd++;
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
void AutomapLeft()
{
amxadd--;
amyadd++;
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
void AutomapRight()
{
amxadd++;
amyadd--;
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
void AutomapZoomIn()
{
if (automapscale < AUTOMAPMAX) {
automapscale += AUTOMAPADD;
automaps1 = (automapscale << 6) / 100;
automaps2 = automaps1 >> 1;
automaps3 = automaps2 >> 1;
automaps4 = automaps3 >> 1;
automaps5 = automaps4 >> 1;
}
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
void AutomapZoomOut()
{
if (automapscale > AUTOMAPMIN) {
automapscale -= AUTOMAPADD;
automaps1 = (automapscale << 6) / 100;
automaps2 = automaps1 >> 1;
automaps3 = automaps2 >> 1;
automaps4 = automaps3 >> 1;
automaps5 = automaps4 >> 1;
}
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
static void DrawAMSquare(int x, int y)
{
int sx1, sy1, sx2, sy2;
sx1 = x - automaps2;
sy1 = y - automaps3;
sx2 = sx1 + automaps1;
sy2 = sy1 + automaps2;
DrawLine(x, sy1, sx1, y, 131);
DrawLine(x, sy1, sx2, y, 131);
DrawLine(x, sy2, sx1, y, 131);
DrawLine(x, sy2, sx2, y, 131);
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
static void DrawAMQuarterSquare(int x, int y, int color)
{
int sx1, sy1, sx2, sy2;
sx1 = x - (automaps2 / 2);
sy1 = y - (automaps3 / 2);
sx2 = sx1 + (automaps1 / 2);
sy2 = sy1 + (automaps2 / 2);
DrawLine(x, sy1, sx1, y, color);
DrawLine(x, sy1, sx2, y, color);
DrawLine(x, sy2, sx1, y, color);
DrawLine(x, sy2, sx2, y, color);
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
static void DrawAMShape(int x, int y, WORD shape)
{
int x1, y1, x2, y2;
BYTE f;
BOOL lwf, rwf, llwf, lrwf;
//DrawAMSquare(x, y);
f = (shape >> 8) & 0xff;
if (f & AMS_DIRT) {
DrawPoint(x, y, AMLC);
DrawPoint(x - automaps4, y - automaps5, AMLC);
DrawPoint(x - automaps4, y + automaps5, AMLC);
DrawPoint(x + automaps4, y - automaps5, AMLC);
DrawPoint(x + automaps4, y + automaps5, AMLC);
DrawPoint(x - automaps3, y, AMLC);
DrawPoint(x + automaps3, y, AMLC);
DrawPoint(x, y - automaps4, AMLC);
DrawPoint(x, y + automaps4, AMLC);
DrawPoint(x - automaps2 + automaps4, y + automaps5, AMLC);
DrawPoint(x + automaps2 - automaps4, y + automaps5, AMLC);
DrawPoint(x - automaps3, y + automaps4, AMLC);
DrawPoint(x + automaps3, y + automaps4, AMLC);
DrawPoint(x - automaps4, y + automaps3 - automaps5, AMLC);
DrawPoint(x + automaps4, y + automaps3 - automaps5, AMLC);
DrawPoint(x, y + automaps3, AMLC);
}
if (f & AMS_STAIRS) {
DrawLine(x-automaps4, y-automaps4-automaps5, x+automaps3+automaps4, y+automaps5, AMDC);
DrawLine(x-automaps3, y-automaps4, x+automaps3, y+automaps4, AMDC);
DrawLine(x-automaps3-automaps4, y-automaps5, x+automaps4, y+automaps4+automaps5, AMDC);
DrawLine(x-automaps2, y, x, y+automaps3, AMDC);
}
lwf = FALSE;
rwf = FALSE;
llwf = FALSE;
lrwf = FALSE;
switch(shape & 0xf) {
case 1:
x1 = x - automaps3; // Column
y1 = y - automaps3;
x2 = x1 + automaps2;
y2 = y - automaps4;
DrawLine(x, y1, x1, y2, AMLC);
DrawLine(x, y1, x2, y2, AMLC);
DrawLine(x, y, x1, y2, AMLC);
DrawLine(x, y, x2, y2, AMLC);
break;
case 2:
case 5:
lwf = TRUE;
break;
case 3:
case 6:
rwf = TRUE;
break;
case 4:
lwf = TRUE;
rwf = TRUE;
break;
case 8:
lwf = TRUE;
llwf = TRUE;
break;
case 9:
rwf = TRUE;
lrwf = TRUE;
break;
case 10:
llwf = TRUE;
break;
case 11:
lrwf = TRUE;
break;
case 12:
llwf = TRUE;
lrwf = TRUE;
break;
}
if (lwf) {
if (f & AMS_DOORL) {
x1 = x - automaps2;
x2 = x - automaps3;
y1 = y - automaps3;
y2 = y - automaps4;
DrawLine(x, y1, x-automaps4, y1+automaps5, AMLC);
DrawLine(x1, y, x1+automaps4, y-automaps5, AMLC);
DrawLine(x2, y1, x1, y2, AMDC);
DrawLine(x2, y1, x, y2, AMDC);
DrawLine(x2, y, x1, y2, AMDC);
DrawLine(x2, y, x, y2, AMDC);
}
if (f & AMS_GRATEL) {
DrawLine(x-automaps3, y-automaps4, x-automaps2, y, AMLC);
f |= AMS_ARCHL; // Force arch square
}
if (f & AMS_ARCHL) {
x1 = x - automaps3;
y1 = y - automaps3;
x2 = x1 + automaps2;
y2 = y - automaps4;
DrawLine(x, y1, x1, y2, AMLC);
DrawLine(x, y1, x2, y2, AMLC);
DrawLine(x, y, x1, y2, AMLC);
DrawLine(x, y, x2, y2, AMLC);
}
if ((f & AMS_NONEL) == 0) DrawLine(x, y-automaps3, x-automaps2, y, AMLC); // Left wall
}
if (rwf) {
if (f & AMS_DOORR) {
x1 = x + automaps3;
x2 = x + automaps2;
y1 = y - automaps3;
y2 = y - automaps4;
DrawLine(x, y1, x+automaps4, y1+automaps5, AMLC);
DrawLine(x2, y, x2-automaps4, y-automaps5, AMLC);
DrawLine(x1, y1, x, y2, AMDC);
DrawLine(x1, y1, x2, y2, AMDC);
DrawLine(x1, y, x, y2, AMDC);
DrawLine(x1, y, x2, y2, AMDC);
}
if (f & AMS_GRATER) {
DrawLine(x+automaps3, y-automaps4, x+automaps2, y, AMLC);
f |= AMS_ARCHR; // Force arch square
}
if (f & AMS_ARCHR) {
x1 = x - automaps3;
y1 = y - automaps3;
x2 = x1 + automaps2;
y2 = y - automaps4;
DrawLine(x, y1, x1, y2, AMLC);
DrawLine(x, y1, x2, y2, AMLC);
DrawLine(x, y, x1, y2, AMLC);
DrawLine(x, y, x2, y2, AMLC);
}
if ((f & AMS_NONER) == 0) DrawLine(x, y-automaps3, x+automaps2, y, AMLC); // Right wall
}
if (llwf) {
if (f & AMS_DOORL) {
x1 = x - automaps2;
x2 = x - automaps3;
y1 = y + automaps3;
y2 = y + automaps4;
DrawLine(x, y1, x-automaps4, y1-automaps5, AMLC);
DrawLine(x1, y, x1+automaps4, y+automaps5, AMLC);
DrawLine(x2, y1, x1, y2, AMDC);
DrawLine(x2, y1, x, y2, AMDC);
DrawLine(x2, y, x1, y2, AMDC);
DrawLine(x2, y, x, y2, AMDC);
} else
DrawLine(x, y+automaps3, x-automaps2, y, AMLC); // Lower Left wall
}
if (lrwf) {
if (f & AMS_DOORR) {
x1 = x + automaps3;
x2 = x + automaps2;
y1 = y + automaps3;
y2 = y + automaps4;
DrawLine(x, y1, x+automaps4, y1-automaps5, AMLC);
DrawLine(x2, y, x2-automaps4, y+automaps5, AMLC);
DrawLine(x1, y1, x, y2, AMDC);
DrawLine(x1, y1, x2, y2, AMDC);
DrawLine(x1, y, x, y2, AMDC);
DrawLine(x1, y, x2, y2, AMDC);
} else
DrawLine(x, y+automaps3, x+automaps2, y, AMLC); // Lower Right wall
}
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
static void DrawAllObjects()
{
int px, py;
if (plr[myplr]._pmode == PM_WALK3) {
px = plr[myplr]._pfutx;
py = plr[myplr]._pfuty;
if (plr[myplr]._pdir == DIR_L) px++;
else py++;
} else {
px = plr[myplr]._px;
py = plr[myplr]._py;
}
int beginx = px - 8;
if (beginx < 0)
beginx = 0;
else if (beginx > MAXDUNX)
beginx = MAXDUNX;
int beginy = py - 8;
if (beginy < 0)
beginy = 0;
else if (beginy > MAXDUNY)
beginy = MAXDUNY;
int endx = px + 8;
if (endx < 0)
endx = 0;
else if (endx > MAXDUNX)
endx = MAXDUNX;
int endy = py + 8;
if (endy < 0)
endy = 0;
else if (endy > MAXDUNY)
endy = MAXDUNY;
for (int ix=beginx; ix < endx; ++ix)
{
for (int iy = beginy; iy < endy; ++iy)
{
if (dItem[ix][iy] != 0)
{
int dx = ix - ViewX - (amxadd << 1);
int dy = iy - ViewY - (amyadd << 1);
int x = 384 + (dx * automaps3) - (dy * automaps3);
int y = 336 + (dx * automaps4) + (dy * automaps4);
x += ((ScrollInfo._sxoff * automapscale) / 100) >> 1;
y += ((ScrollInfo._syoff * automapscale) / 100) >> 1;
if (invflag || sbookflag) x -= 160;
if (chrflag || questlog) x += 160;
y -= automaps4;
DrawAMQuarterSquare(x,y, 129);
}
}
}
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
static void DrawAutomapPlr()
{
int px, py;
int dx, dy;
int x, y;
if (plr[myplr]._pmode == PM_WALK3) {
px = plr[myplr]._pfutx;
py = plr[myplr]._pfuty;
if (plr[myplr]._pdir == DIR_L) px++;
else py++;
} else {
px = plr[myplr]._px;
py = plr[myplr]._py;
}
dx = px - ViewX - (amxadd << 1);
dy = py - ViewY - (amyadd << 1);
x = 384 + (dx * automaps3) - (dy * automaps3);
y = 336 + (dx * automaps4) + (dy * automaps4);
x += ((plr[myplr]._pxoff * automapscale) / 100) >> 1;
y += ((plr[myplr]._pyoff * automapscale) / 100) >> 1;
x += ((ScrollInfo._sxoff * automapscale) / 100) >> 1;
y += ((ScrollInfo._syoff * automapscale) / 100) >> 1;
if (invflag || sbookflag) x -= 160;
if (chrflag || questlog) x += 160;
y -= automaps4;
switch (plr[myplr]._pdir) {
case DIR_U:
DrawLine(x, y, x, y-automaps3, AMPC);
DrawLine(x, y-automaps3, x-automaps5, y-automaps4, AMPC);
DrawLine(x, y-automaps3, x+automaps5, y-automaps4, AMPC);
break;
case DIR_UR:
DrawLine(x, y, x+automaps3, y-automaps4, AMPC);
DrawLine(x+automaps3, y-automaps4, x+automaps4, y-automaps4, AMPC);
DrawLine(x+automaps3, y-automaps4, x+automaps4+automaps5, y, AMPC);
break;
case DIR_R:
DrawLine(x, y, x+automaps3, y, AMPC);
DrawLine(x+automaps3, y, x+automaps4, y-automaps5, AMPC);
DrawLine(x+automaps3, y, x+automaps4, y+automaps5, AMPC);
break;
case DIR_DR:
DrawLine(x, y, x+automaps3, y+automaps4, AMPC);
DrawLine(x+automaps3, y+automaps4, x+automaps4+automaps5, y, AMPC);
DrawLine(x+automaps3, y+automaps4, x+automaps4, y+automaps4, AMPC);
break;
case DIR_D:
DrawLine(x, y, x, y+automaps3, AMPC);
DrawLine(x, y+automaps3, x+automaps5, y+automaps4, AMPC);
DrawLine(x, y+automaps3, x-automaps5, y+automaps4, AMPC);
break;
case DIR_DL:
DrawLine(x, y, x-automaps3, y+automaps4, AMPC);
DrawLine(x-automaps3, y+automaps4, x-automaps4-automaps5, y, AMPC);
DrawLine(x-automaps3, y+automaps4, x-automaps4, y+automaps4, AMPC);
break;
case DIR_L:
DrawLine(x, y, x-automaps3, y, AMPC);
DrawLine(x-automaps3, y, x-automaps4, y-automaps5, AMPC);
DrawLine(x-automaps3, y, x-automaps4, y+automaps5, AMPC);
break;
case DIR_UL:
DrawLine(x, y, x-automaps3, y-automaps4, AMPC);
DrawLine(x-automaps3, y-automaps4, x-automaps4, y-automaps4, AMPC);
DrawLine(x-automaps3, y-automaps4, x-automaps4-automaps5, y, AMPC);
break;
}
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
static WORD GetAutomapType(int x, int y, BOOL view)
{
WORD rv, t;
if ((view) && (x == -1) && (y >= 0) && (y < AUTOMAPY) && (automapview[0][y])) {
if (GetAutomapType(0, y, FALSE) & AMS_DIRT8) return(0);
else return(0x4000);
}
if ((view) && (y == -1) && (x >= 0) && (x < AUTOMAPX) && (automapview[x][0])) {
if (GetAutomapType(x, 0, FALSE) & AMS_DIRT8) return(0);
else return(0x4000);
}
if ((x < 0) || (x >= AUTOMAPX)) return(0);
if ((y < 0) || (y >= AUTOMAPY)) return(0);
if ((!automapview[x][y]) && (view)) return(0);
rv = automaptype[dungeon[x][y]];
if (rv == 7) {
t = GetAutomapType(x-1,y,FALSE) >> 8;
if (t & AMS_ARCHR) {
t = GetAutomapType(x,y-1,FALSE) >> 8;
if (t & AMS_ARCHL) rv = 1;
}
}
return(rv);
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
/*
void DrawAutomapTest()
{
int i, j, x, y;
y = 336;
x = 384 - (automaps1 * 2);
for (i = 1; i < 5; i++) {
DrawAMShape(x, y, 0x0300 + i);
x += automaps1;
}
}
*/
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
static void draw_game_info() {
#define LINE_HGT 15
char szBuf[256];
int y = 20;
if (gbMaxPlayers > 1) {
strcat(strcpy(szBuf,"game: "),gszGameName);
PrintStringXY(8,y,szBuf,ICOLOR_GOLD);
y += LINE_HGT;
if (gszGamePass[0]) {
strcat(strcpy(szBuf,"password: "),gszGamePass);
PrintStringXY(8,y,szBuf,ICOLOR_GOLD);
y += LINE_HGT;
}
}
if (setlevel) {
PrintStringXY(8,y,SetLevelName[setlvlnum],ICOLOR_GOLD);
}
else if (currlevel) {
if (currlevel >= HIVESTART && currlevel <= HIVEEND)
sprintf(szBuf, "Level: Nest %i", currlevel - HIVESTART + 1);
else if (currlevel >= CRYPTSTART && currlevel <= CRYPTEND)
sprintf(szBuf, "Level: Crypt %i", currlevel - CRYPTSTART + 1);
else
sprintf(szBuf,"Level: %i", currlevel);
PrintStringXY(8,y,szBuf,ICOLOR_GOLD);
}
#undef LINE_HGT
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
void DrawAutomap()
{
int i, j;
int x, y;
int xs, ys;
int mx, my;
int ams;
WORD s;
if (leveltype == 0) {
draw_game_info();
return;
}
app_assert(gpBuffer);
glClipY = (long) gpBuffer + 393216; // (352 + 160) * 768
automapx = (ViewX - DIRTEDGED2) >> 1;
while ((automapx + amxadd) < 0) amxadd++;
while ((automapx + amxadd) >= AUTOMAPX) amxadd--;
automapx += amxadd;
automapy = (ViewY - DIRTEDGED2) >> 1;
while ((automapy + amyadd) < 0) amyadd++;
while ((automapy + amyadd) >= AUTOMAPY) amyadd--;
automapy += amyadd;
ams = automapstbl[(automapscale - AUTOMAPMIN) / AUTOMAPADD];
if ((ScrollInfo._sxoff + ScrollInfo._syoff) != 0) ams++;
mx = automapx - ams;
my = automapy - 1;
if (ams & 1) {
xs = 384 - (automaps1 * ((ams-1) >> 1));
ys = 336 - (automaps2 * ((ams+1) >> 1));
} else {
xs = 384 - (automaps1 * (ams >> 1)) + automaps2;
ys = 336 - (automaps2 * (ams >> 1)) - automaps3;
}
if (ViewX & 1) {
xs -= automaps3;
ys -= automaps4;
}
if (ViewY & 1) {
xs += automaps3;
ys -= automaps4;
}
xs += ((ScrollInfo._sxoff * automapscale) / 100) >> 1;
ys += ((ScrollInfo._syoff * automapscale) / 100) >> 1;
if (invflag || sbookflag) xs -= 160;
if (chrflag || questlog) xs += 160;
for (j = 0; j <= (ams+1); j++) {
x = xs;
y = ys;
for (i = 0; i < ams; i++) {
s = GetAutomapType(mx+i,my-i,TRUE);
if (s != 0) DrawAMShape(x, y, s);
//else DrawAMSquare(x, y);
x += automaps1;
}
my++;
x = xs - automaps2;
y = ys + automaps3;
for (i = 0; i <= ams; i++) {
s = GetAutomapType(mx+i,my-i,TRUE);
if (s != 0) DrawAMShape(x, y, s);
//else DrawAMSquare(x, y);
x += automaps1;
}
mx++;
ys = ys + automaps2;
}
DrawAutomapPlr();
if (HighLightAllItems)
{
DrawAllObjects();
}
draw_game_info();
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
void SetAutomapView(int x, int y)
{
int xx, yy;
WORD s, d;
xx = (x - DIRTEDGED2) >> 1;
yy = (y - DIRTEDGED2) >> 1;
if ((xx < 0) || (xx >= AUTOMAPX)) return;
if ((yy < 0) || (yy >= AUTOMAPY)) return;
automapview[xx][yy] = TRUE;
s = GetAutomapType(xx, yy, FALSE);
d = s & AMS_DIRT8;
s = s & 0xf;
switch (s) {
case 2:
if (d) {
if (GetAutomapType(xx, yy+1, FALSE) == AMS_DIRTLR) automapview[xx][yy+1] = TRUE;
} else {
if (GetAutomapType(xx-1, yy, FALSE) & AMS_DIRT8) automapview[xx-1][yy] = TRUE;
}
break;
case 3:
if (d) {
if (GetAutomapType(xx+1, yy, FALSE) == AMS_DIRTLR) automapview[xx+1][yy] = TRUE;
} else {
if (GetAutomapType(xx, yy-1, FALSE) & AMS_DIRT8) automapview[xx][yy-1] = TRUE;
}
break;
case 4:
if (d) {
if (GetAutomapType(xx, yy+1, FALSE) == AMS_DIRTLR) automapview[xx][yy+1] = TRUE;
if (GetAutomapType(xx+1, yy, FALSE) == AMS_DIRTLR) automapview[xx+1][yy] = TRUE;
} else {
if (GetAutomapType(xx-1, yy, FALSE) & AMS_DIRT8) automapview[xx-1][yy] = TRUE;
if (GetAutomapType(xx, yy-1, FALSE) & AMS_DIRT8) automapview[xx][yy-1] = TRUE;
if (GetAutomapType(xx-1, yy-1, FALSE) & AMS_DIRT8) automapview[xx-1][yy-1] = TRUE;
}
break;
case 5:
if (d) {
if (GetAutomapType(xx, yy-1, FALSE) & AMS_DIRT8) automapview[xx][yy-1] = TRUE;
if (GetAutomapType(xx, yy+1, FALSE) == AMS_DIRTLR) automapview[xx][yy+1] = TRUE;
} else {
if (GetAutomapType(xx-1, yy, FALSE) & AMS_DIRT8) automapview[xx-1][yy] = TRUE;
}
break;
case 6:
if (d) {
if (GetAutomapType(xx-1, yy, FALSE) & AMS_DIRT8) automapview[xx-1][yy] = TRUE;
if (GetAutomapType(xx+1, yy, FALSE) == AMS_DIRTLR) automapview[xx+1][yy] = TRUE;
} else {
if (GetAutomapType(xx, yy-1, FALSE) & AMS_DIRT8) automapview[xx][yy-1] = TRUE;
}
break;
}
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
void SyncAutomap()
{
automaps1 = (automapscale << 6) / 100;
automaps2 = automaps1 >> 1;
automaps3 = automaps2 >> 1;
automaps4 = automaps3 >> 1;
automaps5 = automaps4 >> 1;
amxadd = 0;
amyadd = 0;
}

41
src/AUTOMAP.H Normal file
View File

@ -0,0 +1,41 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Constants and Variables
**
** (C)1995 Condor, Inc. All rights reserved.
**-----------------------------------------------------------------------**
** $Header: /Diablo/AUTOMAP.H 1 1/22/97 2:06p Dgartner $
**-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------**
** Defines
**-----------------------------------------------------------------------*/
#define AUTOMAPX 40
#define AUTOMAPY 40
/*-----------------------------------------------------------------------**
** Externs
**-----------------------------------------------------------------------*/
extern BOOL automapflag;
extern BYTE automapview[AUTOMAPX][AUTOMAPY];
extern int automapscale;
/*-----------------------------------------------------------------------**
** Prototypes
**-----------------------------------------------------------------------*/
void InitAutomapOnce();
void InitAutomap();
void DrawAutomap();
void SetAutomapView(int, int);
void SyncAutomap();
void StartAutomap();
void AutomapUp();
void AutomapDown();
void AutomapLeft();
void AutomapRight();
void AutomapZoomIn();
void AutomapZoomOut();

BIN
src/AUTOPLAY.ICO Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

15
src/BUGS.TXT Normal file
View File

@ -0,0 +1,15 @@
*) in MonsterStruct the field mArmorClass should be a short instead of a char.
Currently it overflows in HELL mode.
*) Peril and Devastation can be on Bows but do nothing. Peril should be
removed from bows, Devastation damage should be added to the arrows.
*) Items of Jester have a 0 to 600% damage, not 0-> to 500% either
change the text or the calculation.
*) If you drop a weapon then pick it up (For a Barbarian anyway) half your
life pts come back. (Inventory bug)
*) Doppelganger can clone a golem. (Should be prevented)
*) Rage go to town, and back and you are in a permant rage.

263
src/CAPTURE.CPP Normal file
View File

@ -0,0 +1,263 @@
//***************************************************************************
// capture.c
// created 4.14.95
// written by Patrick Wyatt
//***************************************************************************
#include "diablo.h"
#pragma hdrstop
#include <io.h>
#include <ctype.h>
#include "engine.h"
//***************************************************************************
// externs
//***************************************************************************
void DrawAndBlit();
//***************************************************************************
// constants
//***************************************************************************
#define PCX_HEADER 10
#define PCX_VERSION 5
#define PCX_ENCODE 1
#define PCX_MAX_REP 63
#define PCX_X_PAL 12
#define PCX_COLORS 16
#define X_PCX_COLORS 256
//***************************************************************************
// types
//***************************************************************************
#pragma pack(push,1)
typedef struct PCXHeader {
BYTE nHeader; // 10 for valid PCX files
BYTE nVersion; // 5 for version 3.0 with palette
BYTE nEncode; // file encoding mode
BYTE nBits; // 8 for 256 color mode
WORD x1;
WORD y1;
WORD x2;
WORD y2;
WORD nScrWid;
WORD nScrHgt;
} PCXHeader;
typedef struct PCXInfo {
BYTE nMode; // always 0
BYTE nPlanes; // number of bit planes
WORD nLine; // bytes per line
BYTE unused[60]; // fill out to 128 bytes
} PCXInfo;
typedef struct TPCX_RGB {
BYTE r;
BYTE g;
BYTE b;
} TPCX_RGB;
typedef struct TPCX_XPal {
BYTE nPal;
TPCX_RGB rgb[X_PCX_COLORS];
} TPCX_XPal;
typedef struct TPCX {
PCXHeader Header;
TPCX_RGB Pal16[PCX_COLORS];
PCXInfo Info;
} TPCX;
#pragma pack(pop)
//***************************************************************************
//***************************************************************************
static BOOL pcx_write_header(HANDLE hFile,WORD wWdt,WORD wHgt) {
TPCX pcx;
ZeroMemory(&pcx,sizeof(pcx));
// initialize header
pcx.Header.nHeader = PCX_HEADER;
pcx.Header.nVersion = PCX_VERSION;
pcx.Header.nEncode = PCX_ENCODE;
pcx.Header.nBits = 8;
//pcx.Header.x1 = 0;
//pcx.Header.y1 = 0;
pcx.Header.x2 = wWdt - 1;
pcx.Header.y2 = wHgt - 1;
pcx.Header.nScrWid = wWdt;
pcx.Header.nScrHgt = wHgt;
//pcx.Info.nMode = 0;
pcx.Info.nPlanes = 1;
pcx.Info.nLine = wWdt;
DWORD dwBytes;
return WriteFile(hFile,&pcx,sizeof(pcx),&dwBytes,NULL)
&& (dwBytes == sizeof(pcx));
}
//***************************************************************************
//***************************************************************************
static BOOL pcx_write_pal(HANDLE hFile,const PALETTEENTRY pal[256]) {
// setup extended palette header
TPCX_XPal xpal;
xpal.nPal = PCX_X_PAL;
// copy palette colors
for (int i = 0; i < X_PCX_COLORS; i++) {
xpal.rgb[i].r = pal[i].peRed;
xpal.rgb[i].g = pal[i].peGreen;
xpal.rgb[i].b = pal[i].peBlue;
}
// write it
DWORD dwBytes;
return WriteFile(hFile,&xpal,sizeof(xpal),&dwBytes,NULL)
&& (dwBytes == sizeof(xpal));
}
//***************************************************************************
//***************************************************************************
static BYTE * pcx_compress_line(const BYTE * pSrc,BYTE * pDst,int nWdt) {
BYTE c;
int nCount;
do {
// get next character
c = *pSrc++;
nCount = 1;
nWdt--;
// see how long the sequence is
while ((c == *pSrc) && (nCount < PCX_MAX_REP) && nWdt) {
nCount++;
nWdt--;
pSrc++;
}
// write repeat count (if needed)
if ((nCount > 1) || (c > 0xbf)) {
nCount |= 0xc0;
*pDst++ = (BYTE) nCount;
}
*pDst++ = c;
} while (nWdt);
return pDst;
}
//***************************************************************************
//***************************************************************************
static BOOL pcx_write_image(HANDLE hFile,WORD wDstWdt,WORD wDstHgt,WORD wSrcWdt,const BYTE * pSrc) {
BYTE * pDstEnd;
BYTE * pDstBase;
DWORD dwWrite;
DWORD dwBytes;
// allocate line buffer -- line cannot be more than 2x larger
pDstBase = (BYTE *) DiabloAllocPtrSig(2 * wDstWdt,'CAPt');
while (wDstHgt--) {
pDstEnd = pcx_compress_line(pSrc,pDstBase,wDstWdt);
pSrc += wSrcWdt;
dwWrite = pDstEnd - pDstBase;
if (! WriteFile(hFile,pDstBase,dwWrite,&dwBytes,NULL)) return FALSE;
if (dwBytes != dwWrite) return FALSE;
}
DiabloFreePtr(pDstBase);
return TRUE;
}
//***************************************************************************
//***************************************************************************
#define MAX_CAPTURE 100
#define DIG_OFF 6
static const char szCAPTURE[] = "screen??.PCX";
static const char szCAPTUREfmt[] = "screen%02d.PCX";
static HANDLE open_capture_file(char szFileName[MAX_PATH]) {
int nValue;
BYTE bUsedTbl[MAX_CAPTURE];
ZeroMemory(bUsedTbl,sizeof(bUsedTbl));
struct _finddata_t ffblk;
long lHandle = _findfirst(szCAPTURE,&ffblk);
if (lHandle != -1) {
do {
if (! isdigit(ffblk.name[DIG_OFF+0]))
continue;
if (! isdigit(ffblk.name[DIG_OFF+1]))
continue;
nValue = (ffblk.name[DIG_OFF + 0] - '0') * 10;
nValue += ffblk.name[DIG_OFF + 1] - '0';
bUsedTbl[nValue] = 1;
} while (! _findnext(lHandle,&ffblk));
}
for (nValue = 0; nValue < MAX_CAPTURE; nValue++) {
if (bUsedTbl[nValue]) continue;
sprintf(szFileName,szCAPTUREfmt,nValue);
return CreateFile(szFileName,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
}
return INVALID_HANDLE_VALUE;
}
//***************************************************************************
//***************************************************************************
static void red_palette(const PALETTEENTRY src[256]) {
PALETTEENTRY dst[256];
for (int i = 0; i < 256; i++) {
dst[i].peRed = src[i].peRed;
dst[i].peGreen = 0;
dst[i].peBlue = 0;
dst[i].peFlags = 0;
}
lpDDPal->SetEntries(0,0,256,dst);
}
//***************************************************************************
//***************************************************************************
void screen_capture(void) {
HANDLE hFile;
char szFileName[MAX_PATH];
PALETTEENTRY pal[256];
if (INVALID_HANDLE_VALUE == (hFile = open_capture_file(szFileName)))
return;
// get the current palette, then flash the screen red
DrawAndBlit();
lpDDPal->GetEntries(0,0,256,pal);
red_palette(pal);
lock_buf(2);
app_assert(gpBuffer);
BOOL bOK = pcx_write_header(hFile,TOTALX,TOTALY);
if (bOK) bOK = pcx_write_image(hFile,TOTALX,TOTALY,BUFFERX,gpBuffer + 122944);
if (bOK) bOK = pcx_write_pal(hFile,pal);
unlock_buf(2);
CloseHandle(hFile);
if (! bOK)
DeleteFile(szFileName);
// restore palette
Sleep(300);
lpDDPal->SetEntries(0,0,256,pal);
}

317
src/CODEC.CPP Normal file
View File

@ -0,0 +1,317 @@
//******************************************************************
// codec.cpp
//******************************************************************
#include "diablo.h"
#pragma hdrstop
#include "engine.h"
//******************************************************************
// externs
//******************************************************************
void DesDestroy ();
void DesEncrypt (int, const void *, void *);
void DesInitialize (int, BOOL, const void *);
void IdeaDestroy ();
void IdeaEncrypt (int, const void *, void *);
void IdeaInitialize (int, BOOL, const void *);
void ShaDestroy ();
void ShaGetLastHash (int, void *);
void ShaHash (int, const void *, void *);
void ShaInitialize (int);
//******************************************************************
// set encryption methods
//******************************************************************
#define IDEA 0
#define DES 0
//******************************************************************
// private
//******************************************************************
#define BLOCKSIZE 64
#define VERSION 0
typedef struct _appendrec {
DWORD checkvalue;
BYTE version;
BYTE lastblocksize;
WORD reserved;
} appendrec, *appendptr;
typedef struct _keyrec {
WORD ideakey[3][8];
BYTE deskey[3][8];
BYTE shainitvect[64];
} keyrec, *keyptr;
//******************************************************************
//******************************************************************
static void DestroyKeys () {
#if DES
DesDestroy();
#endif
#if IDEA
IdeaDestroy();
#endif
ShaDestroy();
}
//******************************************************************
//******************************************************************
static void InitializeKeys (BOOL encrypt, const char *password) {
keyrec keyset;
// generate a key
srand(SAVE_GAME_KEY);
BYTE * pb = (BYTE *) &keyset;
for (int i = sizeof(keyset); i--; )
*pb++ = (BYTE) rand();
// HASH THE PASSWORD AND MIX IT WITH THE KEY
{
BYTE originalpassword[64];
BYTE hashedpassword[20];
{
int passchar = 0;
for (int loop = 0; loop < 64; ++loop) {
if (!*(password+passchar))
passchar = 0;
originalpassword[loop] = *(password+passchar++);
}
}
ShaInitialize(0);
ShaHash(0,originalpassword,hashedpassword);
ShaDestroy();
{
LPBYTE keysptr = (LPBYTE)&keyset;
for (int loop = 0; loop < sizeof(keyset); ++loop)
*(keysptr+loop) ^= hashedpassword[loop % 20];
}
ZeroMemory(originalpassword, sizeof originalpassword);
ZeroMemory(hashedpassword, sizeof hashedpassword);
}
// INITIALIZE THE ENCRYPTION ALGORITHMS
for (int loop = 0; loop < 3; ++loop) {
#if DES
DesInitialize(loop,encrypt,keyset.deskey[loop]);
#endif
#if IDEA
IdeaInitialize(loop,encrypt,keyset.ideakey[loop]);
#endif
ShaInitialize(loop);
ShaHash(loop,keyset.shainitvect,NULL);
}
// WIPE OUT THE LOCAL COPY OF THE KEYS
ZeroMemory(&keyset,sizeof(keyrec));
}
//******************************************************************
//******************************************************************
DWORD DecodeFile(BYTE * pbSrcDst,DWORD dwDstBytes,const char * pszPassword) {
app_assert(pbSrcDst);
app_assert(pszPassword);
// initialize encryption keys
InitializeKeys(0,pszPassword);
// make sure the length is correct
if (dwDstBytes <= sizeof(appendrec)) return 0;
dwDstBytes -= sizeof(appendrec);
if (dwDstBytes & (BLOCKSIZE-1)) return 0;
DWORD dwBytesLeft = dwDstBytes;
// DECRYPT THE FILE BLOCK BY BLOCK
BYTE buffer[2][BLOCKSIZE];
while (dwBytesLeft) {
// get the next chunk
CopyMemory(&buffer[0][0],pbSrcDst,BLOCKSIZE);
// DECRYPT THE BLOCK
{
BYTE hash[20];
ShaGetLastHash(0,hash);
int loop;
#if IDEA
for (loop = 0; loop < BLOCKSIZE; loop += 8) {
IdeaEncrypt(2,&buffer[0][loop],&buffer[1][loop]);
IdeaEncrypt(1,&buffer[1][loop],&buffer[0][loop]);
IdeaEncrypt(0,&buffer[0][loop],&buffer[1][loop]);
}
for (loop = 0; loop < BLOCKSIZE; loop++)
buffer[0][loop] = buffer[1][loop]-hash[(BLOCKSIZE-(loop+1)) % 20];
#endif
#if DES
for (loop = 0; loop < BLOCKSIZE; loop += 8) {
DesEncrypt(2,&buffer[0][loop],&buffer[1][loop]);
DesEncrypt(1,&buffer[1][loop],&buffer[0][loop]);
DesEncrypt(0,&buffer[0][loop],&buffer[1][loop]);
}
for (loop = 0; loop < BLOCKSIZE; loop++)
buffer[0][loop] = hash[loop % 20] ^ buffer[1][loop];
#endif
#if ! DES && ! IDEA
for (loop = 0; loop < BLOCKSIZE; loop++)
buffer[0][loop] = hash[loop % 20] ^ buffer[0][loop];
#endif
ShaHash(0,buffer[0],NULL);
ZeroMemory(hash,sizeof(hash));
}
// WRITE THE BLOCK
CopyMemory(pbSrcDst,&buffer[0][0],BLOCKSIZE);
// next block
pbSrcDst += BLOCKSIZE;
dwBytesLeft -= BLOCKSIZE;
}
// hide buffer contents
ZeroMemory(buffer,sizeof(buffer));
// CHECK THE FILE TERMINATION RECORD
const appendrec * append = (const appendrec *) pbSrcDst;
// CHECK THE ENCRYPTION VERSION
if (append->version > VERSION)
goto error;
// CONFIRM THAT THE KEY AND PASSWORD WERE VALID
{
BYTE hash[20];
ShaGetLastHash(0,hash);
if (append->checkvalue != * (LPDWORD) &hash[0]) {
ZeroMemory(hash,20);
goto error;
}
}
// SET THE EXACT OUTPUT SIZE
dwDstBytes -= BLOCKSIZE - append->lastblocksize;
DestroyKeys();
return dwDstBytes;
error:
DestroyKeys();
return 0;
}
//******************************************************************
// CalcEncodeDstBytes()
// -- calculate the number of bytes required to hold the encoded
// file information including the append record
//******************************************************************
DWORD CalcEncodeDstBytes(DWORD dwSrcBytes) {
app_assert(dwSrcBytes);
if (dwSrcBytes & (BLOCKSIZE-1))
dwSrcBytes += BLOCKSIZE - (dwSrcBytes & (BLOCKSIZE-1));
dwSrcBytes += sizeof(appendrec);
return dwSrcBytes;
}
//******************************************************************
//******************************************************************
void EncodeFile(BYTE * pbSrcDst,DWORD dwSrcBytes,DWORD dwDstBytes,const char * pszPassword) {
app_assert(pbSrcDst);
app_assert(pszPassword);
// make sure the user allocated enough bytes for the destination
if (dwDstBytes != CalcEncodeDstBytes(dwSrcBytes))
app_fatal("Invalid encode parameters");
// initialize encryption keys
InitializeKeys(1,pszPassword);
// ENCRYPT THE FILE BLOCK BY BLOCK
DWORD lastblocksize = 0;
BYTE buffer[2][BLOCKSIZE];
while (dwSrcBytes) {
// get the next src data chunk
DWORD blocksize = min(dwSrcBytes,BLOCKSIZE);
CopyMemory(&buffer[0][0],pbSrcDst,blocksize);
// blank out any unused portion of the buffer
if (blocksize < BLOCKSIZE)
ZeroMemory(&buffer[0][blocksize],BLOCKSIZE - blocksize);
// ENCRYPT THE BLOCK
{
BYTE hash[20];
ShaGetLastHash(0,hash);
ShaHash(0,buffer[0],NULL);
int loop;
#if ! DES && ! IDEA
for (loop = 0; loop < BLOCKSIZE; loop++)
buffer[0][loop] = hash[loop % 20] ^ buffer[0][loop];
#endif
#if DES
for (loop = 0; loop < BLOCKSIZE; loop++)
buffer[1][loop] = hash[loop % 20] ^ buffer[0][loop];
for (loop = 0; loop < BLOCKSIZE; loop += 8) {
DesEncrypt(0,&buffer[1][loop],&buffer[0][loop]);
DesEncrypt(1,&buffer[0][loop],&buffer[1][loop]);
DesEncrypt(2,&buffer[1][loop],&buffer[0][loop]);
}
#endif
#if IDEA
for (loop = 0; loop < BLOCKSIZE; loop++)
buffer[1][loop] = buffer[0][loop]+hash[(BLOCKSIZE-(loop+1)) % 20];
for (loop = 0; loop < BLOCKSIZE; loop += 8) {
IdeaEncrypt(0,&buffer[1][loop],&buffer[0][loop]);
IdeaEncrypt(1,&buffer[0][loop],&buffer[1][loop]);
IdeaEncrypt(2,&buffer[1][loop],&buffer[0][loop]);
}
#endif
// hide hash info
ZeroMemory(hash,sizeof(hash));
}
// write encrypted chunk to destination
CopyMemory(pbSrcDst,&buffer[0][0],BLOCKSIZE);
// next block
pbSrcDst += BLOCKSIZE;
dwSrcBytes -= blocksize;
lastblocksize = blocksize;
}
// hide buffer
ZeroMemory(buffer,sizeof(buffer));
// APPEND THE TERMINATION RECORD
BYTE hash[20];
appendrec * append = (appendrec *) pbSrcDst;
ShaGetLastHash(0,hash);
append->checkvalue = * (LPDWORD) &hash[0];
append->version = VERSION;
append->lastblocksize = (BYTE) lastblocksize;
append->reserved = 0;
DestroyKeys();
}

2949
src/CONTROL.CPP Normal file

File diff suppressed because it is too large Load Diff

149
src/CONTROL.H Normal file
View File

@ -0,0 +1,149 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Constants and Variables
**
** (C)1995 Condor, Inc. All rights reserved.
**-----------------------------------------------------------------------**
** $Header: /Diablo/CONTROL.H 1 1/22/97 2:06p Dgartner $
**-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------**
** Defines
**-----------------------------------------------------------------------*/
#define SB1X1 121
#define SB1X2 176
#define SB2X1 196
#define SB2X2 251
#define SBY1 408
#define SBY2 463
#define SBSY1 SBY1-55
#define SBSY2 SBY2-55
#define TEXT_LEFT 0
#define TEXT_CENTER 1
#define TEXT_RIGHT 2
#define ICOLOR_WHITE 0
#define ICOLOR_BLUE 1
#define ICOLOR_RED 2
#define ICOLOR_GOLD 3
/*-----------------------------------------------------------------------**
** Structures
**-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------**
** Externs
**-----------------------------------------------------------------------*/
extern BYTE *pBtmBuff; // Offscreen control panel buffer
extern BYTE *pStatusPanel;
extern BYTE *pGBoxBuff; // Drop gold control panel buffer
extern BOOL dropGoldFlag;
extern const BYTE fonttrans[];
extern const BYTE fontkern[];
extern BOOL pinfoflag;
extern char infostr[256];
extern char infoclr;
extern char tempstr[256];
extern BOOL drawhpflag;
extern BOOL drawmanaflag;
extern BOOL chrflag;
extern BOOL drawbtnflag, panbtndown;
extern BOOL panelflag;
extern BOOL spselflag;
extern BOOL chrbtndown;
extern BOOL lvlbtndown;
extern BOOL sbookflag;
extern BOOL talkflag;
extern int dropGoldValue;
extern int initialDropGoldValue;
extern int initialDropGoldIndex;
/*-----------------------------------------------------------------------**
** Prototypes
**-----------------------------------------------------------------------*/
void InitControlPan();
void CopyCtrlPan(int, int, int, int, int, int);
void DrawCtrlPan();
void FreeControlPan();
void AddPanelString(const char *, int);
void ClearPanel();
void DrawHealthTop();
void DrawHealthBar();
void DrawManaTop();
void DrawManaBar();
void CalcInitBallPer();
BOOL InfoFit(const char *);
void DrawInfoBox();
void DrawSpellIcon();
void DrawSpellList();
void SetSpell();
void SetupSpellSel();
void SetSpellHK(int);
void GetSpellHK(int);
void DrawChr();
void CheckLvlBtn();
void ReleaseLvlBtn();
void DrawLevelUpIcon();
void CheckPanelBtns();
void ReleasePanelBtn();
void DrawButtons();
void CheckPanelInfo();
void CheckDeadButtons();
void CheckChrBtns();
void ReleaseChrBtn();
void DrawDurIcon();
void DrawPanelFont (long, long, char);
void RedBack();
void DrawPause();
void DrawSpellBook();
void CheckSBook();
//BOOL CheckSBookCast();
void TalkStart();
void TalkEnd();
BOOL Talk_wm_char(WPARAM wKey);
BOOL Talk_wm_keydown(WPARAM wKey);
void DrawTalkBox();
void PrintStringXY(int x, int y,const char * pszStr, char col);
void DrawGoldBox(int gold);
void DropGoldType(char c);
void DropGold(int pnum, int cii);
void SetDropGoldCursor(int pnum);

746
src/CURSOR.CPP Normal file
View File

@ -0,0 +1,746 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Cursor file
**
** (C)1995 Condor, Inc. All rights reserved.
**
**-----------------------------------------------------------------------**
** $Header: /Diablo/CURSOR.CPP 4 2/12/97 10:48a Dbrevik2 $
**-----------------------------------------------------------------------**
**
** File Routines
**-----------------------------------------------------------------------*/
#include "diablo.h"
#pragma hdrstop
#include "sound.h"
#include "engine.h"
#include "gendung.h"
#include "control.h"
#include "items.h"
#include "player.h"
#include "monster.h"
#include "objects.h"
#include "cursor.h"
#include "debug.h"
#include "scrollrt.h"
#include "inv.h"
#include "trigs.h"
#include "lighting.h"
#include "missiles.h"
#include "town.h"
#include "towners.h"
#include "quests.h"
#include "doom.h"
/*-----------------------------------------------------------------------**
** externs
**-----------------------------------------------------------------------*/
BOOL IsTracking();
void savecrsr_reset();
/*-----------------------------------------------------------------------**
** Global variables
**-----------------------------------------------------------------------*/
int curs;
int cursW, cursH;
int icursW, icursH;
int icursW28, icursH28;
int cursmx, cursmy;
int cursmonst;
char cursobj;
char cursitem;
char cursinvitem;
char cursplr;
BYTE *pCursCels;
BYTE *pCursCels2;
static int oldcursmonst;
const int CursorWidth [ITEM_LAST_ID+12] = {
// Null, Glove Pointer, Identify, Repair, Recharge, Disarm, Oil, Telekenesis, Resurrect, Target, Heal Other, Watch
0, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 23,
// Inv 1x1
28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
// Inv 1x2
28, 28, 28, 28, 28, 28,
// Inv 1x3
28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28,
// Inv 2x2
56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56,
// Inv 2x3
56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56,
// New 1x1
28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
// New 2x2
56, 56,
// New 1x3
28, 28, 28,
// New 2x3
56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56,
};
const int CursorHeight[ITEM_LAST_ID+12] = {
// Null, Glove Pointer, Identify, Repair, Recharge, Disarm, Oil, Telekenesis, Resurrect, Target, Heal Other, Watch
0, 29, 32, 32, 32, 32, 32, 32, 32, 32, 32, 35,
// Inv 1x1
28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
// Inv 1x2
56, 56, 56, 56, 56, 56,
// Inv 1x3
84, 84, 84, 84, 84, 84, 84, 84, 84, 84,
84, 84, 84, 84, 84, 84, 84, 84, 84,
// Inv 2x2
56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56,
// Inv 2x3
84, 84, 84, 84, 84, 84, 84, 84, 84, 84,
84, 84, 84, 84, 84, 84, 84, 84, 84, 84,
84, 84, 84, 84, 84, 84, 84, 84, 84, 84,
84, 84, 84, 84, 84, 84, 84, 84, 84, 84,
84, 84, 84, 84, 84, 84, 84, 84, 84, 84,
84, 84, 84, 84, 84, 84, 84, 84, 84, 84,
84, 84, 84, 84, 84, 84, 84, 84,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
56, 56,
84, 84, 84,
84, 84, 84, 84, 84, 84, 84, 84, 84, 84,
84, 84, 84, 84, 84, 84, 84, 84, 84, 84,
84, 84, 84, 84,
};
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
void InitCursor() {
app_assert(! pCursCels);
pCursCels = LoadFileInMemSig("Data\\Inv\\Objcurs.CEL",NULL,'CRSR');
pCursCels2 = LoadFileInMemSig("Data\\Inv\\Objcurs2.CEL",NULL,'CRSR');
savecrsr_reset();
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
void FreeCursor() {
DiabloFreePtr(pCursCels);
DiabloFreePtr(pCursCels2);
savecrsr_reset();
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
void SetICursor(int i) {
icursW = CursorWidth[i];
icursH = CursorHeight[i];
icursW28 = icursW / 28;
icursH28 = icursH / 28;
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
void SetCursor(int i) {
curs = i;
cursW = CursorWidth[curs];
cursH = CursorHeight[curs];
SetICursor(i);
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
void NewCursor(int i) {
SetCursor(i);
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
void InitLevelCursor() {
SetCursor(GLOVE_CURS);
cursmx = ViewX;
cursmy = ViewY;
oldcursmonst = -1;
cursmonst = -1;
cursobj = -1;
cursitem = -1;
cursplr = -1;
savecrsr_reset();
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
void CheckTown() {
for (int i = 0; i < nummissiles; i++) {
int mx = missileactive[i];
if (missile[mx]._mitype == MIT_TOWN) {
if (((cursmx == missile[mx]._mix - 1) && (cursmy == missile[mx]._miy)) ||
((cursmx == missile[mx]._mix) && (cursmy == missile[mx]._miy - 1)) ||
((cursmx == missile[mx]._mix - 1) && (cursmy == missile[mx]._miy - 1)) ||
((cursmx == missile[mx]._mix - 2) && (cursmy == missile[mx]._miy - 1)) ||
((cursmx == missile[mx]._mix - 2) && (cursmy == missile[mx]._miy - 2)) ||
((cursmx == missile[mx]._mix - 1) && (cursmy == missile[mx]._miy - 2)) ||
((cursmx == missile[mx]._mix) && (cursmy == missile[mx]._miy))) {
trigflag = TRUE;
ClearPanel();
strcpy(infostr, "Town Portal");
sprintf(tempstr, "from %s", plr[missile[mx]._misource]._pName);
AddPanelString(tempstr, TEXT_CENTER);
cursmx = missile[mx]._mix;
cursmy = missile[mx]._miy;
}
}
}
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
void CheckRportal() {
for (int i = 0; i < nummissiles; i++) {
int mx = missileactive[i];
if (missile[mx]._mitype == MIT_RPORTAL) {
if (((cursmx == missile[mx]._mix - 1) && (cursmy == missile[mx]._miy)) ||
((cursmx == missile[mx]._mix) && (cursmy == missile[mx]._miy - 1)) ||
((cursmx == missile[mx]._mix - 1) && (cursmy == missile[mx]._miy - 1)) ||
((cursmx == missile[mx]._mix - 2) && (cursmy == missile[mx]._miy - 1)) ||
((cursmx == missile[mx]._mix - 2) && (cursmy == missile[mx]._miy - 2)) ||
((cursmx == missile[mx]._mix - 1) && (cursmy == missile[mx]._miy - 2)) ||
((cursmx == missile[mx]._mix) && (cursmy == missile[mx]._miy))) {
trigflag = TRUE;
ClearPanel();
strcpy(infostr, "Portal to");
if (!(setlevel)) strcpy(tempstr, "The Unholy Altar");
else strcpy(tempstr, "level 15");
AddPanelString(tempstr, TEXT_CENTER);
cursmx = missile[mx]._mix;
cursmy = missile[mx]._miy;
}
}
}
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
void CheckCursMove() {
int mx,my;
int offsetx,offsety,gridx,gridy;
char co,ci,cp;
int cm;
BOOL minusy, plusx;
BOOL lefthalf;
int newMouseX;
int newMouseY;
int pvar6tmp, pvar7tmp;
long xo, yo;
newMouseX = MouseX;
newMouseY = MouseY;
// Convert screen point to map position
if (chrflag || questlog) {
if (newMouseX >= TOTALX/4) newMouseX -= TOTALX/4;
else newMouseX = 0;
}
else if (invflag || sbookflag) {
if (newMouseX <= TOTALX/2) newMouseX += TOTALX/4;
else newMouseX = 0;
}
// if the mouse outside the gamemap area, but
// the mouse is in tracking mode, then pretend
// that the mouse is actually in the gamemap
if (newMouseY > 351 && IsTracking())
newMouseY = 351;
if (!svgamode)
{
newMouseX >>= 1;
newMouseY >>= 1;
}
// Offset mouse position by the scroll offset, to align it with tile grid
newMouseX -= ScrollInfo._sxoff;
newMouseY -= ScrollInfo._syoff;
// THIS IS A HACK
// Here, we predict the next scroll increment, so the mouse position is
// where it would be during the next frame.
// This is a fix -- without this, the following sometimes happens:
// The user holds down the mouse button, and the walk path alternates
// between two different directions, because the cursor is sampled just before
// player reaches his next square.
xo = plr[myplr]._pVar6 >> 8;
yo = plr[myplr]._pVar7 >> 8;
pvar6tmp = plr[myplr]._pVar6 + plr[myplr]._pxvel;
pvar7tmp = plr[myplr]._pVar7 + plr[myplr]._pyvel;
xo -= (pvar6tmp >> 8);
yo -= (pvar7tmp >> 8);
if ((myplr == myplr) && (ScrollInfo._sdir != SCRL_NONE)) {
newMouseX -= xo;
newMouseY -= yo;
}
if (newMouseX < 0)
newMouseX = 0;
if (newMouseX >= TOTALX)
newMouseX = TOTALX;
if (newMouseY < 0)
newMouseY = 0;
if (newMouseY >= TOTALY)
newMouseY = TOTALY;
// Calculate position in square grid
gridx = newMouseX >> 6;
gridy = newMouseY >> 5;
// Calculate offset in that square
offsetx = newMouseX & 63;
offsety = newMouseY & 31;
// Convert from square grid to diamond grid
mx = gridx + gridy + ViewX - (svgamode ? 10:5);
my = gridy - gridx + ViewY;
if (minusy = (offsety < (offsetx >> 1))) {
my--;
}
if (plusx = (offsety >= (32 - (offsetx >> 1)))) {
mx++;
}
if (mx < 0) mx = 0;
if (mx >= DMAXX) mx = DMAXX - 1;
if (my < 0) my = 0;
if (my >= DMAXY) my = DMAXY - 1;
lefthalf = (minusy && plusx) || ((minusy || plusx) && offsetx < 32);
oldcursmonst = cursmonst;
cursmonst = -1;
cursobj = -1;
cursitem = -1;
if (cursinvitem != -1)
drawsbarflag = TRUE;
cursinvitem = -1;
cursplr = -1;
uitemflag = FALSE;
panelflag = FALSE;
trigflag = FALSE;
if (plr[myplr]._pInvincible) return; // Dead?
// Skip if I have an item
if ((curs >= ICSTART) || (spselflag)) {
cursmx = mx;
cursmy = my;
return;
}
if (MouseY > 352) {
CheckPanelInfo();
return;
}
if (drawmapofdoom) return;
if ((invflag) && (MouseX > 320)) {
cursinvitem = CheckInvHLight();
return;
}
if (sbookflag && (MouseX > 320))
return;
if ((chrflag || questlog) && (MouseX < 320)) return;
if (leveltype != 0) {
if (oldcursmonst != -1) {
if (!lefthalf && (dMonster[mx+2][my+1] != 0) && (dFlags[mx+2][my+1] & BFLAG_VISIBLE)) {
if (dMonster[mx+2][my+1] > 0) cm = dMonster[mx+2][my+1] - 1;
else cm = -(dMonster[mx+2][my+1] + 1);
if (cm == oldcursmonst) {
if (((monster[cm]._mhitpoints >> HP_SHIFT) > 0) && (monster[cm].MData->mSelFlag & MSEL_TOP)) {
cursmx = mx + 1;
cursmy = my + 2;
cursmonst = cm;
}
}
}
if (lefthalf && (dMonster[mx+1][my+2] != 0) && (dFlags[mx+1][my+2] & BFLAG_VISIBLE)) {
if (dMonster[mx+1][my+2] > 0) cm = dMonster[mx+1][my+2] - 1;
else cm = -(dMonster[mx+1][my+2] + 1);
if (cm == oldcursmonst) {
if (((monster[cm]._mhitpoints >> HP_SHIFT) > 0) && (monster[cm].MData->mSelFlag & MSEL_TOP)) {
cursmx = mx + 1;
cursmy = my + 2;
cursmonst = cm;
}
}
}
if ((dMonster[mx+2][my+2] != 0) && (dFlags[mx+2][my+2] & BFLAG_VISIBLE)) {
if (dMonster[mx+2][my+2] > 0) cm = dMonster[mx+2][my+2] - 1;
else cm = -(dMonster[mx+2][my+2] + 1);
if (cm == oldcursmonst) {
if (((monster[cm]._mhitpoints >> HP_SHIFT) > 0) && (monster[cm].MData->mSelFlag & MSEL_TOP)) {
cursmx = mx + 2;
cursmy = my + 2;
cursmonst = cm;
}
}
}
if (!lefthalf && (dMonster[mx+1][my] != 0) && (dFlags[mx+1][my] & BFLAG_VISIBLE)) {
if (dMonster[mx+1][my] > 0) cm = dMonster[mx+1][my] - 1;
else cm = -(dMonster[mx+1][my] + 1);
if (cm == oldcursmonst) {
if (((monster[cm]._mhitpoints >> HP_SHIFT) > 0) && (monster[cm].MData->mSelFlag & MSEL_MID)) {
cursmx = mx + 1;
cursmy = my;
cursmonst = cm;
}
}
}
if (lefthalf && (dMonster[mx][my+1] != 0) && (dFlags[mx][my+1] & BFLAG_VISIBLE)) {
if (dMonster[mx][my+1] > 0) cm = dMonster[mx][my+1] - 1;
else cm = -(dMonster[mx][my+1] + 1);
if (cm == oldcursmonst) {
if (((monster[cm]._mhitpoints >> HP_SHIFT) > 0) && (monster[cm].MData->mSelFlag & MSEL_MID)) {
cursmx = mx;
cursmy = my + 1;
cursmonst = cm;
}
}
}
if ((dMonster[mx][my] != 0) && (dFlags[mx][my] & BFLAG_VISIBLE)) {
if (dMonster[mx][my] > 0) cm = dMonster[mx][my] - 1;
else cm = -(dMonster[mx][my] + 1);
if (cm == oldcursmonst) {
if (((monster[cm]._mhitpoints >> HP_SHIFT) > 0) && (monster[cm].MData->mSelFlag & MSEL_FLR)) {
cursmx = mx;
cursmy = my;
cursmonst = cm;
}
}
}
if ((dMonster[mx+1][my+1] != 0) && (dFlags[mx+1][my+1] & BFLAG_VISIBLE)) {
if (dMonster[mx+1][my+1] > 0) cm = dMonster[mx+1][my+1] - 1;
else cm = -(dMonster[mx+1][my+1] + 1);
if (cm == oldcursmonst) {
if (((monster[cm]._mhitpoints >> HP_SHIFT) > 0) && (monster[cm].MData->mSelFlag & MSEL_MID)) {
cursmx = mx + 1;
cursmy = my + 1;
cursmonst = cm;
}
}
}
if (cursmonst != -1) {
if (monster[cursmonst]._mFlags & MFLAG_INVISIBLE) {
cursmonst = -1;
cursmx = mx;
cursmy = my;
}
}
if ((cursmonst != -1)
&& ((monster[cursmonst]._mFlags & MFLAG_MKILLER) != 0)
&& ((monster[cursmonst]._mFlags & MFLAG_BERSERK) == 0)
) cursmonst = -1;
if (cursmonst != -1) return;
}
if (!lefthalf && (dMonster[mx+2][my+1] != 0) && (dFlags[mx+2][my+1] & BFLAG_VISIBLE)) {
if (dMonster[mx+2][my+1] > 0) cm = dMonster[mx+2][my+1] - 1;
else cm = -(dMonster[mx+2][my+1] + 1);
if (((monster[cm]._mhitpoints >> HP_SHIFT) > 0) && (monster[cm].MData->mSelFlag & MSEL_TOP)) {
cursmx = mx + 2;
cursmy = my + 1;
cursmonst = cm;
}
}
if (lefthalf && (dMonster[mx+1][my+2] != 0) && (dFlags[mx+1][my+2] & BFLAG_VISIBLE)) {
if (dMonster[mx+1][my+2] > 0) cm = dMonster[mx+1][my+2] - 1;
else cm = -(dMonster[mx+1][my+2] + 1);
if (((monster[cm]._mhitpoints >> HP_SHIFT) > 0) && (monster[cm].MData->mSelFlag & MSEL_TOP)) {
cursmx = mx + 1;
cursmy = my + 2;
cursmonst = cm;
}
}
if ((dMonster[mx+2][my+2] != 0) && (dFlags[mx+2][my+2] & BFLAG_VISIBLE)) {
if (dMonster[mx+2][my+2] > 0) cm = dMonster[mx+2][my+2] - 1;
else cm = -(dMonster[mx+2][my+2] + 1);
if (((monster[cm]._mhitpoints >> HP_SHIFT) > 0) && (monster[cm].MData->mSelFlag & MSEL_TOP)) {
cursmx = mx + 2;
cursmy = my + 2;
cursmonst = cm;
}
}
if (!lefthalf && (dMonster[mx+1][my] != 0) && (dFlags[mx+1][my] & BFLAG_VISIBLE)) {
if (dMonster[mx+1][my] > 0) cm = dMonster[mx+1][my] - 1;
else cm = -(dMonster[mx+1][my] + 1);
if (((monster[cm]._mhitpoints >> HP_SHIFT) > 0) && (monster[cm].MData->mSelFlag & MSEL_MID)) {
cursmx = mx + 1;
cursmy = my;
cursmonst = cm;
}
}
if (lefthalf && (dMonster[mx][my+1] != 0) && (dFlags[mx][my+1] & BFLAG_VISIBLE)) {
if (dMonster[mx][my+1] > 0) cm = dMonster[mx][my+1] - 1;
else cm = -(dMonster[mx][my+1] + 1);
if (((monster[cm]._mhitpoints >> HP_SHIFT) > 0) && (monster[cm].MData->mSelFlag & MSEL_MID)) {
cursmx = mx;
cursmy = my + 1;
cursmonst = cm;
}
}
if ((dMonster[mx][my] != 0) && (dFlags[mx][my] & BFLAG_VISIBLE)) {
if (dMonster[mx][my] > 0) cm = dMonster[mx][my] - 1;
else cm = -(dMonster[mx][my] + 1);
if (((monster[cm]._mhitpoints >> HP_SHIFT) > 0) && (monster[cm].MData->mSelFlag & MSEL_FLR)) {
cursmx = mx;
cursmy = my;
cursmonst = cm;
}
}
if ((dMonster[mx+1][my+1] != 0) && (dFlags[mx+1][my+1] & BFLAG_VISIBLE)) {
if (dMonster[mx+1][my+1] > 0) cm = dMonster[mx+1][my+1] - 1;
else cm = -(dMonster[mx+1][my+1] + 1);
if (((monster[cm]._mhitpoints >> HP_SHIFT) > 0) && (monster[cm].MData->mSelFlag & MSEL_MID)) {
cursmx = mx + 1;
cursmy = my + 1;
cursmonst = cm;
}
}
if (cursmonst != -1) {
if (monster[cursmonst]._mFlags & MFLAG_INVISIBLE) {
cursmonst = -1;
cursmx = mx;
cursmy = my;
}
}
if ((cursmonst != -1)
&& ((monster[cursmonst]._mFlags & MFLAG_MKILLER) != 0)
&& ((monster[cursmonst]._mFlags & MFLAG_BERSERK) == 0)
) cursmonst = -1;
} else {
if (!lefthalf && (dMonster[mx+1][my] > 0)) {
cursmonst = dMonster[mx+1][my] - 1;
cursmx = mx + 1;
cursmy = my;
}
if (lefthalf && (dMonster[mx][my+1] > 0)) {
cursmonst = dMonster[mx][my+1] - 1;
cursmx = mx;
cursmy = my + 1;
}
if (dMonster[mx][my] > 0) {
cursmonst = dMonster[mx][my] - 1;
cursmx = mx;
cursmy = my;
}
if (dMonster[mx+1][my+1] > 0) {
cursmonst = dMonster[mx+1][my+1] - 1;
cursmx = mx + 1;
cursmy = my + 1;
}
if (!towner[cursmonst]._tSelFlag) cursmonst = -1;
}
if (cursmonst == -1) {
if (!lefthalf && (dPlayer[mx+1][my] != 0)) {
if (dPlayer[mx+1][my] > 0) cp = dPlayer[mx+1][my] - 1;
else cp = -(dPlayer[mx+1][my] + 1);
if ((cp != myplr) && (plr[cp]._pHitPoints != 0)) {
cursmx = mx + 1;
cursmy = my;
cursplr = cp;
}
}
if (lefthalf && (dPlayer[mx][my+1] != 0)) {
if (dPlayer[mx][my+1] > 0) cp = dPlayer[mx][my+1] - 1;
else cp = -(dPlayer[mx][my+1] + 1);
if ((cp != myplr) && (plr[cp]._pHitPoints != 0)) {
cursmx = mx;
cursmy = my + 1;
cursplr = cp;
}
}
if (dPlayer[mx][my] != 0) {
if (dPlayer[mx][my] > 0) cp = dPlayer[mx][my] - 1;
else cp = -(dPlayer[mx][my] + 1);
if (cp != myplr) {
cursmx = mx;
cursmy = my;
cursplr = cp;
}
}
if (dFlags[mx][my] & BFLAG_DEADPLR) {
for (int i = 0; i < MAX_PLRS; i++) {
if ((plr[i]._px == mx) && (plr[i]._py == my) && (i != myplr)) {
cursmx = mx;
cursmy = my;
cursplr = i;
}
}
}
if (curs == RESURRECT_CURS) {
for (int j = -1; j < 2; j++) {
for (int k = -1; k < 2; k++) {
if (dFlags[mx+j][my+k] & BFLAG_DEADPLR) {
for (int i = 0; i < MAX_PLRS; i++) {
if ((plr[i]._px == mx+j) && (plr[i]._py == my+k) && (i != myplr)) {
cursmx = mx+j;
cursmy = my+k;
cursplr = i;
}
}
}
}
}
}
if (dPlayer[mx+1][my+1] != 0) {
if (dPlayer[mx+1][my+1] > 0) cp = dPlayer[mx+1][my+1] - 1;
else cp = -(dPlayer[mx+1][my+1] + 1);
if ((cp != myplr) && (plr[cp]._pHitPoints != 0)) {
cursmx = mx + 1;
cursmy = my + 1;
cursplr = cp;
}
}
}
if ((cursmonst == -1) && (cursplr == -1)) {
if (!lefthalf && (dObject[mx+1][my] != 0)) {
if (dObject[mx+1][my] > 0) co = dObject[mx+1][my] - 1;
else co = -(dObject[mx+1][my] + 1);
if (object[co]._oSelFlag >= OSEL_TOP) {
cursmx = mx + 1;
cursmy = my;
cursobj = co;
}
}
if (lefthalf && (dObject[mx][my+1] != 0)) {
if (dObject[mx][my+1] > 0) co = dObject[mx][my+1] - 1;
else co = -(dObject[mx][my+1] + 1);
if (object[co]._oSelFlag >= OSEL_TOP) {
cursmx = mx;
cursmy = my + 1;
cursobj = co;
}
}
if (dObject[mx][my] != 0) {
if (dObject[mx][my] > 0) co = dObject[mx][my] - 1;
else co = -(dObject[mx][my] + 1);
if ((object[co]._oSelFlag == OSEL_FLR) || (object[co]._oSelFlag == OSEL_ALL)) {
cursmx = mx;
cursmy = my;
cursobj = co;
}
}
if (dObject[mx+1][my+1] != 0) {
if (dObject[mx+1][my+1] > 0) co = dObject[mx+1][my+1] - 1;
else co = -(dObject[mx+1][my+1] + 1);
if (object[co]._oSelFlag >= OSEL_TOP) {
cursmx = mx + 1;
cursmy = my + 1;
cursobj = co;
}
}
}
if ((cursplr == -1) && (cursobj == -1) && (cursmonst == -1)) {
if (!lefthalf && (dItem[mx+1][my] > 0)) {
ci = dItem[mx+1][my] - 1;
if (item[ci]._iSelFlag >= ISEL_TOP) {
cursmx = mx + 1;
cursmy = my;
cursitem = ci;
}
}
if (lefthalf && (dItem[mx][my+1] > 0)) {
ci = dItem[mx][my+1] - 1;
if (item[ci]._iSelFlag >= ISEL_TOP) {
cursmx = mx;
cursmy = my + 1;
cursitem = ci;
}
}
if (dItem[mx][my] > 0) {
ci = dItem[mx][my] - 1;
if ((item[ci]._iSelFlag == ISEL_FLR) || (item[ci]._iSelFlag == ISEL_ALL)) {
cursmx = mx;
cursmy = my;
cursitem = ci;
}
}
if (dItem[mx+1][my+1] > 0) {
ci = dItem[mx+1][my+1] - 1;
if (item[ci]._iSelFlag >= ISEL_TOP) {
cursmx = mx + 1;
cursmy = my + 1;
cursitem = ci;
}
}
if (cursitem == -1) {
cursmx = mx;
cursmy = my;
CheckTrigForce();
CheckTown();
CheckRportal();
}
}
if (curs == IDENTIFY_CURS) {
cursobj = -1;
cursmonst = -1;
cursitem = -1;
cursmx = mx;
cursmy = my;
}
if ((cursmonst != -1)
&& ((monster[cursmonst]._mFlags & MFLAG_MKILLER) != 0)
&& ((monster[cursmonst]._mFlags & MFLAG_BERSERK) == 0)
) cursmonst = -1;
}

68
src/CURSOR.H Normal file
View File

@ -0,0 +1,68 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Constants and Variables
**
** (C)1995 Condor, Inc. All rights reserved.
**-----------------------------------------------------------------------**
** $Header: /Diablo/CURSOR.H 1 1/22/97 2:06p Dgartner $
**-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------**
** Defines
**-----------------------------------------------------------------------*/
#define NO_CURSOR 0
#define VIEW_CURSOR 1
#define GLOVE_CURS 1
#define IDENTIFY_CURS 2
#define REPAIR_CURS 3
#define RECHARGE_CURS 4
#define DISARM_CURS 5
#define OIL_CURS 6
#define TELE_CURS 7
#define RESURRECT_CURS 8
#define TARGET_CURS 9
#define HEALOTHER_CURS 10
#define WATCH_CURS 11
#define ICSTART 12 // Cursor where items start at
#define ICLAST 179 // last of the original cursors
#define MSEL_NONE 0 // No selection (not used)
#define MSEL_FLR 1 // Floor / single square
#define MSEL_MID 2 // Square above monster base
#define MSEL_REG 3 // Normal floor + 1 square above
#define MSEL_TOP 4 // Square 2 above monster base
#define MSEL_FLY 6 // Square 1 and 2 above base (gargolye, bat)
#define MSEL_BIG 7 // Large monsters floor, 1, and 2 squares
/*-----------------------------------------------------------------------**
** Externs
**-----------------------------------------------------------------------*/
extern int curs;
extern int cursW, cursH;
extern int icursW, icursH;
extern int icursW28, icursH28;
extern int cursmx, cursmy;
extern int cursmonst;
extern char cursobj;
extern char cursitem;
extern char cursinvitem;
extern char cursplr;
extern BYTE *pCursCels;
extern BYTE *pCursCels2;
extern const int CursorWidth[];
extern const int CursorHeight[];
/*-----------------------------------------------------------------------**
** Prototypes
**-----------------------------------------------------------------------*/
void InitCursor();
void InitLevelCursor();
void CheckCursMove();
void SetICursor(int i);
void SetCursor(int i);
void NewCursor(int i);

957
src/D3DTYPES.H Normal file
View File

@ -0,0 +1,957 @@
/*==========================================================================;
*
* Copyright (C) 1995-1996 Microsoft Corporation. All Rights Reserved.
*
* File: d3dtypes.h
* Content: Direct3D types include file
*
***************************************************************************/
#ifndef _D3DTYPES_H_
#define _D3DTYPES_H_
// pjw commented out -- win32 out to be defined!
// #ifndef WIN32
//#include "subwtype.h"
//#else
#include <windows.h>
//#endif
#include "ddraw.h"
#pragma pack(4)
#if defined(__cplusplus)
extern "C"
{
#endif
/* D3DVALUE is the fundamental Direct3D fractional data type */
#define D3DVALP(val, prec) ((float)(val))
#define D3DVAL(val) ((float)(val))
typedef float D3DVALUE, *LPD3DVALUE;
#define D3DDivide(a, b) (float)((double) (a) / (double) (b))
#define D3DMultiply(a, b) ((a) * (b))
typedef LONG D3DFIXED;
#ifndef RGB_MAKE
/*
* Format of CI colors is
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | alpha | color index | fraction |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
#define CI_GETALPHA(ci) ((ci) >> 24)
#define CI_GETINDEX(ci) (((ci) >> 8) & 0xffff)
#define CI_GETFRACTION(ci) ((ci) & 0xff)
#define CI_ROUNDINDEX(ci) CI_GETINDEX((ci) + 0x80)
#define CI_MASKALPHA(ci) ((ci) & 0xffffff)
#define CI_MAKE(a, i, f) (((a) << 24) | ((i) << 8) | (f))
/*
* Format of RGBA colors is
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | alpha | red | green | blue |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
#define RGBA_GETALPHA(rgb) ((rgb) >> 24)
#define RGBA_GETRED(rgb) (((rgb) >> 16) & 0xff)
#define RGBA_GETGREEN(rgb) (((rgb) >> 8) & 0xff)
#define RGBA_GETBLUE(rgb) ((rgb) & 0xff)
#define RGBA_MAKE(r, g, b, a) ((D3DCOLOR) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)))
/* D3DRGB and D3DRGBA may be used as initialisers for D3DCOLORs
* The float values must be in the range 0..1
*/
#define D3DRGB(r, g, b) \
(0xff000000L | ( ((long)((r) * 255)) << 16) | (((long)((g) * 255)) << 8) | (long)((b) * 255))
#define D3DRGBA(r, g, b, a) \
( (((long)((a) * 255)) << 24) | (((long)((r) * 255)) << 16) \
| (((long)((g) * 255)) << 8) | (long)((b) * 255) \
)
/*
* Format of RGB colors is
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | ignored | red | green | blue |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
#define RGB_GETRED(rgb) (((rgb) >> 16) & 0xff)
#define RGB_GETGREEN(rgb) (((rgb) >> 8) & 0xff)
#define RGB_GETBLUE(rgb) ((rgb) & 0xff)
#define RGBA_SETALPHA(rgba, x) (((x) << 24) | ((rgba) & 0x00ffffff))
#define RGB_MAKE(r, g, b) ((D3DCOLOR) (((r) << 16) | ((g) << 8) | (b)))
#define RGBA_TORGB(rgba) ((D3DCOLOR) ((rgba) & 0xffffff))
#define RGB_TORGBA(rgb) ((D3DCOLOR) ((rgb) | 0xff000000))
#endif
/*
* Flags for Enumerate functions
*/
/*
* Stop the enumeration
*/
#define D3DENUMRET_CANCEL DDENUMRET_CANCEL
/*
* Continue the enumeration
*/
#define D3DENUMRET_OK DDENUMRET_OK
typedef HRESULT (WINAPI* LPD3DVALIDATECALLBACK)(LPVOID lpUserArg, DWORD dwOffset);
typedef HRESULT (WINAPI* LPD3DENUMTEXTUREFORMATSCALLBACK)(LPDDSURFACEDESC lpDdsd, LPVOID lpContext);
typedef DWORD D3DCOLOR, D3DCOLOR, *LPD3DCOLOR;
typedef DWORD D3DMATERIALHANDLE, *LPD3DMATERIALHANDLE;
typedef DWORD D3DTEXTUREHANDLE, *LPD3DTEXTUREHANDLE;
typedef DWORD D3DMATRIXHANDLE, *LPD3DMATRIXHANDLE;
typedef struct _D3DCOLORVALUE {
union {
D3DVALUE r;
D3DVALUE dvR;
};
union {
D3DVALUE g;
D3DVALUE dvG;
};
union {
D3DVALUE b;
D3DVALUE dvB;
};
union {
D3DVALUE a;
D3DVALUE dvA;
};
} D3DCOLORVALUE;
typedef struct _D3DRECT {
union {
LONG x1;
LONG lX1;
};
union {
LONG y1;
LONG lY1;
};
union {
LONG x2;
LONG lX2;
};
union {
LONG y2;
LONG lY2;
};
} D3DRECT, *LPD3DRECT;
typedef struct _D3DVECTOR {
union {
D3DVALUE x;
D3DVALUE dvX;
};
union {
D3DVALUE y;
D3DVALUE dvY;
};
union {
D3DVALUE z;
D3DVALUE dvZ;
};
} D3DVECTOR, *LPD3DVECTOR;
/*
* Vertex data types supported in an ExecuteBuffer.
*/
/*
* Homogeneous vertices
*/
typedef struct _D3DHVERTEX {
DWORD dwFlags; /* Homogeneous clipping flags */
union {
D3DVALUE hx;
D3DVALUE dvHX;
};
union {
D3DVALUE hy;
D3DVALUE dvHY;
};
union {
D3DVALUE hz;
D3DVALUE dvHZ;
};
} D3DHVERTEX, *LPD3DHVERTEX;
/*
* Transformed/lit vertices
*/
typedef struct _D3DTLVERTEX {
union {
D3DVALUE sx; /* Screen coordinates */
D3DVALUE dvSX;
};
union {
D3DVALUE sy;
D3DVALUE dvSY;
};
union {
D3DVALUE sz;
D3DVALUE dvSZ;
};
union {
D3DVALUE rhw; /* Reciprocal of homogeneous w */
D3DVALUE dvRHW;
};
union {
D3DCOLOR color; /* Vertex color */
D3DCOLOR dcColor;
};
union {
D3DCOLOR specular; /* Specular component of vertex */
D3DCOLOR dcSpecular;
};
union {
D3DVALUE tu; /* Texture coordinates */
D3DVALUE dvTU;
};
union {
D3DVALUE tv;
D3DVALUE dvTV;
};
} D3DTLVERTEX, *LPD3DTLVERTEX;
/*
* Untransformed/lit vertices
*/
typedef struct _D3DLVERTEX {
union {
D3DVALUE x; /* Homogeneous coordinates */
D3DVALUE dvX;
};
union {
D3DVALUE y;
D3DVALUE dvY;
};
union {
D3DVALUE z;
D3DVALUE dvZ;
};
DWORD dwReserved;
union {
D3DCOLOR color; /* Vertex color */
D3DCOLOR dcColor;
};
union {
D3DCOLOR specular; /* Specular component of vertex */
D3DCOLOR dcSpecular;
};
union {
D3DVALUE tu; /* Texture coordinates */
D3DVALUE dvTU;
};
union {
D3DVALUE tv;
D3DVALUE dvTV;
};
} D3DLVERTEX, *LPD3DLVERTEX;
/*
* Untransformed/unlit vertices
*/
typedef struct _D3DVERTEX {
union {
D3DVALUE x; /* Homogeneous coordinates */
D3DVALUE dvX;
};
union {
D3DVALUE y;
D3DVALUE dvY;
};
union {
D3DVALUE z;
D3DVALUE dvZ;
};
union {
D3DVALUE nx; /* Normal */
D3DVALUE dvNX;
};
union {
D3DVALUE ny;
D3DVALUE dvNY;
};
union {
D3DVALUE nz;
D3DVALUE dvNZ;
};
union {
D3DVALUE tu; /* Texture coordinates */
D3DVALUE dvTU;
};
union {
D3DVALUE tv;
D3DVALUE dvTV;
};
} D3DVERTEX, *LPD3DVERTEX;
/*
* Matrix, viewport, and tranformation structures and definitions.
*/
typedef struct _D3DMATRIX {
D3DVALUE _11, _12, _13, _14;
D3DVALUE _21, _22, _23, _24;
D3DVALUE _31, _32, _33, _34;
D3DVALUE _41, _42, _43, _44;
} D3DMATRIX, *LPD3DMATRIX;
typedef struct _D3DVIEWPORT {
DWORD dwSize;
DWORD dwX;
DWORD dwY; /* Top left */
DWORD dwWidth;
DWORD dwHeight; /* Dimensions */
D3DVALUE dvScaleX; /* Scale homogeneous to screen */
D3DVALUE dvScaleY; /* Scale homogeneous to screen */
D3DVALUE dvMaxX; /* Min/max homogeneous x coord */
D3DVALUE dvMaxY; /* Min/max homogeneous y coord */
D3DVALUE dvMinZ;
D3DVALUE dvMaxZ; /* Min/max homogeneous z coord */
} D3DVIEWPORT, *LPD3DVIEWPORT;
/*
* Values for clip fields.
*/
#define D3DCLIP_LEFT 0x00000001L
#define D3DCLIP_RIGHT 0x00000002L
#define D3DCLIP_TOP 0x00000004L
#define D3DCLIP_BOTTOM 0x00000008L
#define D3DCLIP_FRONT 0x00000010L
#define D3DCLIP_BACK 0x00000020L
#define D3DCLIP_GEN0 0x00000040L
#define D3DCLIP_GEN1 0x00000080L
#define D3DCLIP_GEN2 0x00000100L
#define D3DCLIP_GEN3 0x00000200L
#define D3DCLIP_GEN4 0x00000400L
#define D3DCLIP_GEN5 0x00000800L
/*
* Values for d3d status.
*/
#define D3DSTATUS_CLIPUNIONLEFT D3DCLIP_LEFT
#define D3DSTATUS_CLIPUNIONRIGHT D3DCLIP_RIGHT
#define D3DSTATUS_CLIPUNIONTOP D3DCLIP_TOP
#define D3DSTATUS_CLIPUNIONBOTTOM D3DCLIP_BOTTOM
#define D3DSTATUS_CLIPUNIONFRONT D3DCLIP_FRONT
#define D3DSTATUS_CLIPUNIONBACK D3DCLIP_BACK
#define D3DSTATUS_CLIPUNIONGEN0 D3DCLIP_GEN0
#define D3DSTATUS_CLIPUNIONGEN1 D3DCLIP_GEN1
#define D3DSTATUS_CLIPUNIONGEN2 D3DCLIP_GEN2
#define D3DSTATUS_CLIPUNIONGEN3 D3DCLIP_GEN3
#define D3DSTATUS_CLIPUNIONGEN4 D3DCLIP_GEN4
#define D3DSTATUS_CLIPUNIONGEN5 D3DCLIP_GEN5
#define D3DSTATUS_CLIPINTERSECTIONLEFT 0x00001000L
#define D3DSTATUS_CLIPINTERSECTIONRIGHT 0x00002000L
#define D3DSTATUS_CLIPINTERSECTIONTOP 0x00004000L
#define D3DSTATUS_CLIPINTERSECTIONBOTTOM 0x00008000L
#define D3DSTATUS_CLIPINTERSECTIONFRONT 0x00010000L
#define D3DSTATUS_CLIPINTERSECTIONBACK 0x00020000L
#define D3DSTATUS_CLIPINTERSECTIONGEN0 0x00040000L
#define D3DSTATUS_CLIPINTERSECTIONGEN1 0x00080000L
#define D3DSTATUS_CLIPINTERSECTIONGEN2 0x00100000L
#define D3DSTATUS_CLIPINTERSECTIONGEN3 0x00200000L
#define D3DSTATUS_CLIPINTERSECTIONGEN4 0x00400000L
#define D3DSTATUS_CLIPINTERSECTIONGEN5 0x00800000L
#define D3DSTATUS_ZNOTVISIBLE 0x01000000L
#define D3DSTATUS_CLIPUNIONALL ( \
D3DSTATUS_CLIPUNIONLEFT | \
D3DSTATUS_CLIPUNIONRIGHT | \
D3DSTATUS_CLIPUNIONTOP | \
D3DSTATUS_CLIPUNIONBOTTOM | \
D3DSTATUS_CLIPUNIONFRONT | \
D3DSTATUS_CLIPUNIONBACK | \
D3DSTATUS_CLIPUNIONGEN0 | \
D3DSTATUS_CLIPUNIONGEN1 | \
D3DSTATUS_CLIPUNIONGEN2 | \
D3DSTATUS_CLIPUNIONGEN3 | \
D3DSTATUS_CLIPUNIONGEN4 | \
D3DSTATUS_CLIPUNIONGEN5 \
)
#define D3DSTATUS_CLIPINTERSECTIONALL ( \
D3DSTATUS_CLIPINTERSECTIONLEFT | \
D3DSTATUS_CLIPINTERSECTIONRIGHT | \
D3DSTATUS_CLIPINTERSECTIONTOP | \
D3DSTATUS_CLIPINTERSECTIONBOTTOM | \
D3DSTATUS_CLIPINTERSECTIONFRONT | \
D3DSTATUS_CLIPINTERSECTIONBACK | \
D3DSTATUS_CLIPINTERSECTIONGEN0 | \
D3DSTATUS_CLIPINTERSECTIONGEN1 | \
D3DSTATUS_CLIPINTERSECTIONGEN2 | \
D3DSTATUS_CLIPINTERSECTIONGEN3 | \
D3DSTATUS_CLIPINTERSECTIONGEN4 | \
D3DSTATUS_CLIPINTERSECTIONGEN5 \
)
#define D3DSTATUS_DEFAULT ( \
D3DSTATUS_CLIPINTERSECTIONALL | \
D3DSTATUS_ZNOTVISIBLE)
/*
* Options for direct transform calls
*/
#define D3DTRANSFORM_CLIPPED 0x00000001l
#define D3DTRANSFORM_UNCLIPPED 0x00000002l
typedef struct _D3DTRANSFORMDATA {
DWORD dwSize;
LPVOID lpIn; /* Input vertices */
DWORD dwInSize; /* Stride of input vertices */
LPVOID lpOut; /* Output vertices */
DWORD dwOutSize; /* Stride of output vertices */
LPD3DHVERTEX lpHOut; /* Output homogeneous vertices */
DWORD dwClip; /* Clipping hint */
DWORD dwClipIntersection;
DWORD dwClipUnion; /* Union of all clip flags */
D3DRECT drExtent; /* Extent of transformed vertices */
} D3DTRANSFORMDATA, *LPD3DTRANSFORMDATA;
/*
* Structure defining position and direction properties for lighting.
*/
typedef struct _D3DLIGHTINGELEMENT {
D3DVECTOR dvPosition; /* Lightable point in model space */
D3DVECTOR dvNormal; /* Normalised unit vector */
} D3DLIGHTINGELEMENT, *LPD3DLIGHTINGELEMENT;
/*
* Structure defining material properties for lighting.
*/
typedef struct _D3DMATERIAL {
DWORD dwSize;
union {
D3DCOLORVALUE diffuse; /* Diffuse color RGBA */
D3DCOLORVALUE dcvDiffuse;
};
union {
D3DCOLORVALUE ambient; /* Ambient color RGB */
D3DCOLORVALUE dcvAmbient;
};
union {
D3DCOLORVALUE specular; /* Specular 'shininess' */
D3DCOLORVALUE dcvSpecular;
};
union {
D3DCOLORVALUE emissive; /* Emissive color RGB */
D3DCOLORVALUE dcvEmissive;
};
union {
D3DVALUE power; /* Sharpness if specular highlight */
D3DVALUE dvPower;
};
D3DTEXTUREHANDLE hTexture; /* Handle to texture map */
DWORD dwRampSize;
} D3DMATERIAL, *LPD3DMATERIAL;
typedef enum _D3DLIGHTTYPE {
D3DLIGHT_POINT = 1,
D3DLIGHT_SPOT = 2,
D3DLIGHT_DIRECTIONAL = 3,
D3DLIGHT_PARALLELPOINT = 4,
D3DLIGHT_GLSPOT = 5,
} D3DLIGHTTYPE;
/*
* Structure defining a light source and its properties.
*/
typedef struct _D3DLIGHT {
DWORD dwSize;
D3DLIGHTTYPE dltType; /* Type of light source */
D3DCOLORVALUE dcvColor; /* Color of light */
D3DVECTOR dvPosition; /* Position in world space */
D3DVECTOR dvDirection; /* Direction in world space */
D3DVALUE dvRange; /* Cutoff range */
D3DVALUE dvFalloff; /* Falloff */
D3DVALUE dvAttenuation0; /* Constant attenuation */
D3DVALUE dvAttenuation1; /* Linear attenuation */
D3DVALUE dvAttenuation2; /* Quadratic attenuation */
D3DVALUE dvTheta; /* Inner angle of spotlight cone */
D3DVALUE dvPhi; /* Outer angle of spotlight cone */
} D3DLIGHT, *LPD3DLIGHT;
typedef struct _D3DLIGHTDATA {
DWORD dwSize;
LPD3DLIGHTINGELEMENT lpIn; /* Input positions and normals */
DWORD dwInSize; /* Stride of input elements */
LPD3DTLVERTEX lpOut; /* Output colors */
DWORD dwOutSize; /* Stride of output colors */
} D3DLIGHTDATA, *LPD3DLIGHTDATA;
typedef enum _D3DCOLORMODEL {
D3DCOLOR_MONO = 1,
D3DCOLOR_RGB = 2,
} D3DCOLORMODEL;
/*
* Options for clearing
*/
#define D3DCLEAR_TARGET 0x00000001l /* Clear target surface */
#define D3DCLEAR_ZBUFFER 0x00000002l /* Clear target z buffer */
/*
* Execute buffers are allocated via Direct3D. These buffers may then
* be filled by the application with instructions to execute along with
* vertex data.
*/
/*
* Supported op codes for execute instructions.
*/
typedef enum _D3DOPCODE {
D3DOP_POINT = 1,
D3DOP_LINE = 2,
D3DOP_TRIANGLE = 3,
D3DOP_MATRIXLOAD = 4,
D3DOP_MATRIXMULTIPLY = 5,
D3DOP_STATETRANSFORM = 6,
D3DOP_STATELIGHT = 7,
D3DOP_STATERENDER = 8,
D3DOP_PROCESSVERTICES = 9,
D3DOP_TEXTURELOAD = 10,
D3DOP_EXIT = 11,
D3DOP_BRANCHFORWARD = 12,
D3DOP_SPAN = 13,
D3DOP_SETSTATUS = 14,
} D3DOPCODE;
typedef struct _D3DINSTRUCTION {
BYTE bOpcode; /* Instruction opcode */
BYTE bSize; /* Size of each instruction data unit */
WORD wCount; /* Count of instruction data units to follow */
} D3DINSTRUCTION, *LPD3DINSTRUCTION;
/*
* Structure for texture loads
*/
typedef struct _D3DTEXTURELOAD {
D3DTEXTUREHANDLE hDestTexture;
D3DTEXTUREHANDLE hSrcTexture;
} D3DTEXTURELOAD, *LPD3DTEXTURELOAD;
/*
* Structure for picking
*/
typedef struct _D3DPICKRECORD {
BYTE bOpcode;
BYTE bPad;
DWORD dwOffset;
D3DVALUE dvZ;
} D3DPICKRECORD, *LPD3DPICKRECORD;
/*
* The following defines the rendering states which can be set in the
* execute buffer.
*/
typedef enum _D3DSHADEMODE {
D3DSHADE_FLAT = 1,
D3DSHADE_GOURAUD = 2,
D3DSHADE_PHONG = 3,
} D3DSHADEMODE;
typedef enum _D3DFILLMODE {
D3DFILL_POINT = 1,
D3DFILL_WIREFRAME = 2,
D3DFILL_SOLID = 3,
} D3DFILLMODE;
typedef struct _D3DLINEPATTERN {
WORD wRepeatFactor;
WORD wLinePattern;
} D3DLINEPATTERN;
typedef enum _D3DTEXTUREFILTER {
D3DFILTER_NEAREST = 1,
D3DFILTER_LINEAR = 2,
D3DFILTER_MIPNEAREST = 3,
D3DFILTER_MIPLINEAR = 4,
D3DFILTER_LINEARMIPNEAREST = 5,
D3DFILTER_LINEARMIPLINEAR = 6,
} D3DTEXTUREFILTER;
typedef enum _D3DBLEND {
D3DBLEND_ZERO = 1,
D3DBLEND_ONE = 2,
D3DBLEND_SRCCOLOR = 3,
D3DBLEND_INVSRCCOLOR = 4,
D3DBLEND_SRCALPHA = 5,
D3DBLEND_INVSRCALPHA = 6,
D3DBLEND_DESTALPHA = 7,
D3DBLEND_INVDESTALPHA = 8,
D3DBLEND_DESTCOLOR = 9,
D3DBLEND_INVDESTCOLOR = 10,
D3DBLEND_SRCALPHASAT = 11,
D3DBLEND_BOTHSRCALPHA = 12,
D3DBLEND_BOTHINVSRCALPHA = 13,
} D3DBLEND;
typedef enum _D3DTEXTUREBLEND {
D3DTBLEND_DECAL = 1,
D3DTBLEND_MODULATE = 2,
D3DTBLEND_DECALALPHA = 3,
D3DTBLEND_MODULATEALPHA = 4,
D3DTBLEND_DECALMASK = 5,
D3DTBLEND_MODULATEMASK = 6,
D3DTBLEND_COPY = 7,
} D3DTEXTUREBLEND;
typedef enum _D3DTEXTUREADDRESS {
D3DTADDRESS_WRAP = 1,
D3DTADDRESS_MIRROR = 2,
D3DTADDRESS_CLAMP = 3,
} D3DTEXTUREADDRESS;
typedef enum _D3DCULL {
D3DCULL_NONE = 1,
D3DCULL_CW = 2,
D3DCULL_CCW = 3,
} D3DCULL;
typedef enum _D3DCMPFUNC {
D3DCMP_NEVER = 1,
D3DCMP_LESS = 2,
D3DCMP_EQUAL = 3,
D3DCMP_LESSEQUAL = 4,
D3DCMP_GREATER = 5,
D3DCMP_NOTEQUAL = 6,
D3DCMP_GREATEREQUAL = 7,
D3DCMP_ALWAYS = 8,
} D3DCMPFUNC;
typedef enum _D3DFOGMODE {
D3DFOG_NONE = 0,
D3DFOG_EXP = 1,
D3DFOG_EXP2 = 2,
D3DFOG_LINEAR = 3
} D3DFOGMODE;
/*
* Amount to add to a state to generate the override for that state.
*/
#define D3DSTATE_OVERRIDE_BIAS 256
/*
* A state which sets the override flag for the specified state type.
*/
#define D3DSTATE_OVERRIDE(type) ((DWORD) (type) + D3DSTATE_OVERRIDE_BIAS)
typedef enum _D3DTRANSFORMSTATETYPE {
D3DTRANSFORMSTATE_WORLD = 1,
D3DTRANSFORMSTATE_VIEW = 2,
D3DTRANSFORMSTATE_PROJECTION = 3,
} D3DTRANSFORMSTATETYPE;
typedef enum _D3DLIGHTSTATETYPE {
D3DLIGHTSTATE_MATERIAL = 1,
D3DLIGHTSTATE_AMBIENT = 2,
D3DLIGHTSTATE_COLORMODEL = 3,
D3DLIGHTSTATE_FOGMODE = 4,
D3DLIGHTSTATE_FOGSTART = 5,
D3DLIGHTSTATE_FOGEND = 6,
D3DLIGHTSTATE_FOGDENSITY = 7,
} D3DLIGHTSTATETYPE;
typedef enum _D3DRENDERSTATETYPE {
D3DRENDERSTATE_TEXTUREHANDLE = 1, /* Texture handle */
D3DRENDERSTATE_ANTIALIAS = 2, /* Antialiasing prim edges */
D3DRENDERSTATE_TEXTUREADDRESS = 3, /* D3DTEXTUREADDRESS */
D3DRENDERSTATE_TEXTUREPERSPECTIVE = 4, /* TRUE for perspective correction */
D3DRENDERSTATE_WRAPU = 5, /* TRUE for wrapping in u */
D3DRENDERSTATE_WRAPV = 6, /* TRUE for wrapping in v */
D3DRENDERSTATE_ZENABLE = 7, /* TRUE to enable z test */
D3DRENDERSTATE_FILLMODE = 8, /* D3DFILL_MODE */
D3DRENDERSTATE_SHADEMODE = 9, /* D3DSHADEMODE */
D3DRENDERSTATE_LINEPATTERN = 10, /* D3DLINEPATTERN */
D3DRENDERSTATE_MONOENABLE = 11, /* TRUE to enable mono rasterization */
D3DRENDERSTATE_ROP2 = 12, /* ROP2 */
D3DRENDERSTATE_PLANEMASK = 13, /* DWORD physical plane mask */
D3DRENDERSTATE_ZWRITEENABLE = 14, /* TRUE to enable z writes */
D3DRENDERSTATE_ALPHATESTENABLE = 15, /* TRUE to enable alpha tests */
D3DRENDERSTATE_LASTPIXEL = 16, /* TRUE for last-pixel on lines */
D3DRENDERSTATE_TEXTUREMAG = 17, /* D3DTEXTUREFILTER */
D3DRENDERSTATE_TEXTUREMIN = 18, /* D3DTEXTUREFILTER */
D3DRENDERSTATE_SRCBLEND = 19, /* D3DBLEND */
D3DRENDERSTATE_DESTBLEND = 20, /* D3DBLEND */
D3DRENDERSTATE_TEXTUREMAPBLEND = 21, /* D3DTEXTUREBLEND */
D3DRENDERSTATE_CULLMODE = 22, /* D3DCULL */
D3DRENDERSTATE_ZFUNC = 23, /* D3DCMPFUNC */
D3DRENDERSTATE_ALPHAREF = 24, /* D3DFIXED */
D3DRENDERSTATE_ALPHAFUNC = 25, /* D3DCMPFUNC */
D3DRENDERSTATE_DITHERENABLE = 26, /* TRUE to enable dithering */
D3DRENDERSTATE_BLENDENABLE = 27, /* TRUE to enable alpha blending */
D3DRENDERSTATE_FOGENABLE = 28, /* TRUE to enable fog */
D3DRENDERSTATE_SPECULARENABLE = 29, /* TRUE to enable specular */
D3DRENDERSTATE_ZVISIBLE = 30, /* TRUE to enable z checking */
D3DRENDERSTATE_SUBPIXEL = 31, /* TRUE to enable subpixel correction */
D3DRENDERSTATE_SUBPIXELX = 32, /* TRUE to enable correction in X only */
D3DRENDERSTATE_STIPPLEDALPHA = 33, /* TRUE to enable stippled alpha */
D3DRENDERSTATE_FOGCOLOR = 34, /* D3DCOLOR */
D3DRENDERSTATE_FOGTABLEMODE = 35, /* D3DFOGMODE */
D3DRENDERSTATE_FOGTABLESTART = 36, /* Fog table start */
D3DRENDERSTATE_FOGTABLEEND = 37, /* Fog table end */
D3DRENDERSTATE_FOGTABLEDENSITY = 38, /* Fog table density */
D3DRENDERSTATE_STIPPLEENABLE = 39, /* TRUE to enable stippling */
D3DRENDERSTATE_STIPPLEPATTERN00 = 64, /* Stipple pattern 01... */
D3DRENDERSTATE_STIPPLEPATTERN01 = 65,
D3DRENDERSTATE_STIPPLEPATTERN02 = 66,
D3DRENDERSTATE_STIPPLEPATTERN03 = 67,
D3DRENDERSTATE_STIPPLEPATTERN04 = 68,
D3DRENDERSTATE_STIPPLEPATTERN05 = 69,
D3DRENDERSTATE_STIPPLEPATTERN06 = 70,
D3DRENDERSTATE_STIPPLEPATTERN07 = 71,
D3DRENDERSTATE_STIPPLEPATTERN08 = 72,
D3DRENDERSTATE_STIPPLEPATTERN09 = 73,
D3DRENDERSTATE_STIPPLEPATTERN10 = 74,
D3DRENDERSTATE_STIPPLEPATTERN11 = 75,
D3DRENDERSTATE_STIPPLEPATTERN12 = 76,
D3DRENDERSTATE_STIPPLEPATTERN13 = 77,
D3DRENDERSTATE_STIPPLEPATTERN14 = 78,
D3DRENDERSTATE_STIPPLEPATTERN15 = 79,
D3DRENDERSTATE_STIPPLEPATTERN16 = 80,
D3DRENDERSTATE_STIPPLEPATTERN17 = 81,
D3DRENDERSTATE_STIPPLEPATTERN18 = 82,
D3DRENDERSTATE_STIPPLEPATTERN19 = 83,
D3DRENDERSTATE_STIPPLEPATTERN20 = 84,
D3DRENDERSTATE_STIPPLEPATTERN21 = 85,
D3DRENDERSTATE_STIPPLEPATTERN22 = 86,
D3DRENDERSTATE_STIPPLEPATTERN23 = 87,
D3DRENDERSTATE_STIPPLEPATTERN24 = 88,
D3DRENDERSTATE_STIPPLEPATTERN25 = 89,
D3DRENDERSTATE_STIPPLEPATTERN26 = 90,
D3DRENDERSTATE_STIPPLEPATTERN27 = 91,
D3DRENDERSTATE_STIPPLEPATTERN28 = 92,
D3DRENDERSTATE_STIPPLEPATTERN29 = 93,
D3DRENDERSTATE_STIPPLEPATTERN30 = 94,
D3DRENDERSTATE_STIPPLEPATTERN31 = 95,
} D3DRENDERSTATETYPE;
#define D3DRENDERSTATE_STIPPLEPATTERN(y) (D3DRENDERSTATE_STIPPLEPATTERN00 + (y))
typedef struct _D3DSTATE {
union {
D3DTRANSFORMSTATETYPE dtstTransformStateType;
D3DLIGHTSTATETYPE dlstLightStateType;
D3DRENDERSTATETYPE drstRenderStateType;
};
union {
DWORD dwArg[1];
D3DVALUE dvArg[1];
};
} D3DSTATE, *LPD3DSTATE;
/*
* Operation used to load matrices
* hDstMat = hSrcMat
*/
typedef struct _D3DMATRIXLOAD {
D3DMATRIXHANDLE hDestMatrix; /* Destination matrix */
D3DMATRIXHANDLE hSrcMatrix; /* Source matrix */
} D3DMATRIXLOAD, *LPD3DMATRIXLOAD;
/*
* Operation used to multiply matrices
* hDstMat = hSrcMat1 * hSrcMat2
*/
typedef struct _D3DMATRIXMULTIPLY {
D3DMATRIXHANDLE hDestMatrix; /* Destination matrix */
D3DMATRIXHANDLE hSrcMatrix1; /* First source matrix */
D3DMATRIXHANDLE hSrcMatrix2; /* Second source matrix */
} D3DMATRIXMULTIPLY, *LPD3DMATRIXMULTIPLY;
/*
* Operation used to transform and light vertices.
*/
typedef struct _D3DPROCESSVERTICES {
DWORD dwFlags; /* Do we transform or light or just copy? */
WORD wStart; /* Index to first vertex in source */
WORD wDest; /* Index to first vertex in local buffer */
DWORD dwCount; /* Number of vertices to be processed */
DWORD dwReserved; /* Must be zero */
} D3DPROCESSVERTICES, *LPD3DPROCESSVERTICES;
#define D3DPROCESSVERTICES_TRANSFORMLIGHT 0x00000000L
#define D3DPROCESSVERTICES_TRANSFORM 0x00000001L
#define D3DPROCESSVERTICES_COPY 0x00000002L
#define D3DPROCESSVERTICES_OPMASK 0x00000007L
#define D3DPROCESSVERTICES_UPDATEEXTENTS 0x00000008L
#define D3DPROCESSVERTICES_NOCOLOR 0x00000010L
/*
* Triangle flags
*/
/*
* Tri strip and fan flags.
* START loads all three vertices
* EVEN and ODD load just v3 with even or odd culling
* START_FLAT contains a count from 0 to 29 that allows the
* whole strip or fan to be culled in one hit.
* e.g. for a quad len = 1
*/
#define D3DTRIFLAG_START 0x00000000L
#define D3DTRIFLAG_STARTFLAT(len) (len) /* 0 < len < 30 */
#define D3DTRIFLAG_ODD 0x0000001eL
#define D3DTRIFLAG_EVEN 0x0000001fL
/*
* Triangle edge flags
* enable edges for wireframe or antialiasing
*/
#define D3DTRIFLAG_EDGEENABLE1 0x00000100L /* v0-v1 edge */
#define D3DTRIFLAG_EDGEENABLE2 0x00000200L /* v1-v2 edge */
#define D3DTRIFLAG_EDGEENABLE3 0x00000400L /* v2-v0 edge */
#define D3DTRIFLAG_EDGEENABLETRIANGLE \
(D3DTRIFLAG_EDGEENABLE1 | D3DTRIFLAG_EDGEENABLE2 | D3DTRIFLAG_EDGEENABLE3)
/*
* Primitive structures and related defines. Vertex offsets are to types
* D3DVERTEX, D3DLVERTEX, or D3DTLVERTEX.
*/
/*
* Triangle list primitive structure
*/
typedef struct _D3DTRIANGLE {
union {
WORD v1; /* Vertex indices */
WORD wV1;
};
union {
WORD v2;
WORD wV2;
};
union {
WORD v3;
WORD wV3;
};
WORD wFlags; /* Edge (and other) flags */
} D3DTRIANGLE, *LPD3DTRIANGLE;
/*
* Line strip structure.
* The instruction count - 1 defines the number of line segments.
*/
typedef struct _D3DLINE {
union {
WORD v1; /* Vertex indices */
WORD wV1;
};
union {
WORD v2;
WORD wV2;
};
} D3DLINE, *LPD3DLINE;
/*
* Span structure
* Spans join a list of points with the same y value.
* If the y value changes, a new span is started.
*/
typedef struct _D3DSPAN {
WORD wCount; /* Number of spans */
WORD wFirst; /* Index to first vertex */
} D3DSPAN, *LPD3DSPAN;
/*
* Point structure
*/
typedef struct _D3DPOINT {
WORD wCount; /* number of points */
WORD wFirst; /* index to first vertex */
} D3DPOINT, *LPD3DPOINT;
/*
* Forward branch structure.
* Mask is logically anded with the driver status mask
* if the result equals 'value', the branch is taken.
*/
typedef struct _D3DBRANCH {
DWORD dwMask; /* Bitmask against D3D status */
DWORD dwValue;
BOOL bNegate; /* TRUE to negate comparison */
DWORD dwOffset; /* How far to branch forward (0 for exit)*/
} D3DBRANCH, *LPD3DBRANCH;
/*
* Status used for set status instruction.
* The D3D status is initialised on device creation
* and is modified by all execute calls.
*/
typedef struct _D3DSTATUS {
DWORD dwFlags; /* Do we set extents or status */
DWORD dwStatus; /* D3D status */
D3DRECT drExtent;
} D3DSTATUS, *LPD3DSTATUS;
#define D3DSETSTATUS_STATUS 0x00000001L
#define D3DSETSTATUS_EXTENTS 0x00000002L
#define D3DSETSTATUS_ALL (D3DSETSTATUS_STATUS | D3DSETSTATUS_EXTENTS)
/*
* Statistics structure
*/
typedef struct _D3DSTATS {
DWORD dwSize;
DWORD dwTrianglesDrawn;
DWORD dwLinesDrawn;
DWORD dwPointsDrawn;
DWORD dwSpansDrawn;
DWORD dwVerticesProcessed;
} D3DSTATS, *LPD3DSTATS;
/*
* Execute options.
* When calling using D3DEXECUTE_UNCLIPPED all the primitives
* inside the buffer must be contained within the viewport.
*/
#define D3DEXECUTE_CLIPPED 0x00000001l
#define D3DEXECUTE_UNCLIPPED 0x00000002l
typedef struct _D3DEXECUTEDATA {
DWORD dwSize;
DWORD dwVertexOffset;
DWORD dwVertexCount;
DWORD dwInstructionOffset;
DWORD dwInstructionLength;
DWORD dwHVertexOffset;
D3DSTATUS dsStatus; /* Status after execute */
} D3DEXECUTEDATA, *LPD3DEXECUTEDATA;
/*
* Palette flags.
* This are or'ed with the peFlags in the PALETTEENTRYs passed to DirectDraw.
*/
#define D3DPAL_FREE 0x00 /* Renderer may use this entry freely */
#define D3DPAL_READONLY 0x40 /* Renderer may not set this entry */
#define D3DPAL_RESERVED 0x80 /* Renderer may not use this entry */
#if defined(__cplusplus)
};
#endif
#pragma pack()
#endif /* _D3DTYPES_H_ */

BIN
src/D523BD.ZIP Normal file

Binary file not shown.

BIN
src/D523BF.ZIP Normal file

Binary file not shown.

3102
src/DDRAW.H Normal file

File diff suppressed because it is too large Load Diff

BIN
src/DDRAW.LIB Normal file

Binary file not shown.

123
src/DEAD.CPP Normal file
View File

@ -0,0 +1,123 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Dead file
**
** (C)1995 Condor, Inc. All rights reserved.
**
**-----------------------------------------------------------------------**
** $Header: /Diablo/DEAD.CPP 1 1/22/97 2:06p Dgartner $
**-----------------------------------------------------------------------**
**
** File Routines
**-----------------------------------------------------------------------*/
#include "diablo.h"
#pragma hdrstop
#include "sound.h"
#include "dead.h"
#include "monster.h"
#include "monstint.h"
#include "missiles.h"
#include "misdat.h"
#include "gendung.h"
#include "lighting.h"
/*-----------------------------------------------------------------------*
** Global Variables
**-----------------------------------------------------------------------*/
DeadStruct dead[MAXDEAD];
int spurtndx;
int stonendx;
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
void InitDead ()
{
int nd,i,j,mi;
int mtypes[MONSTERTYPES];
for (i = 0; i < MONSTERTYPES; i++) mtypes[i] = 0;
nd = 0;
for (i = 0; i < nummtypes; i++) {
if (mtypes[Monsters[i].mtype] == 0) {
for (j = 0; j < 8; j++) dead[nd]._deadData[j] = Monsters[i].Anims[MA_DEATH].Cels[j];
dead[nd]._deadFrame = Monsters[i].Anims[MA_DEATH].Frames;
dead[nd]._deadWidth = Monsters[i].mAnimWidth;
dead[nd]._deadWidth2 = Monsters[i].mAnimWidth2;
dead[nd]._deadtrans = 0;
Monsters[i].mdeadval = nd + 1;
mtypes[Monsters[i].mtype] = nd + 1;
nd++;
}
}
// set blood burst dead frames
for (j = 0; j < 8; j++) dead[nd]._deadData[j] = misfiledata[MF_SPURT].mAnimData[0];
dead[nd]._deadFrame = 8;
dead[nd]._deadWidth = 128;
dead[nd]._deadWidth2 = (128 - 64) >> 1;
dead[nd]._deadtrans = 0;
spurtndx = nd + 1;
nd++;
// set stone dead frames
for (j = 0; j < 8; j++) dead[nd]._deadData[j] = misfiledata[MF_STONE].mAnimData[0];
dead[nd]._deadFrame = 12;
dead[nd]._deadWidth = 128;
dead[nd]._deadWidth2 = (128 - 64) >> 1;
dead[nd]._deadtrans = 0;
stonendx = nd + 1;
nd++;
// set unique monster dead frames
for (i = 0; i < nummonsters; i++) {
mi = monstactive[i];
if (monster[mi]._uniqtype != 0) {
for (j = 0; j < 8; j++) dead[nd]._deadData[j] = monster[mi].MType->Anims[MA_DEATH].Cels[j];
dead[nd]._deadFrame = monster[mi].MType->Anims[MA_DEATH].Frames;
dead[nd]._deadWidth = monster[mi].MType->mAnimWidth;
dead[nd]._deadWidth2 = monster[mi].MType->mAnimWidth2;
dead[nd]._deadtrans = LIGHT_U + monster[mi]._uniqtrans;
monster[mi]._udeadval = nd + 1;
nd++;
}
}
app_assert(nd <= MAXDEAD);
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
void AddDead(int dx, int dy, char dv, int ddir)
{
char tdv;
tdv = (dv & 0x1f) + ((ddir & 0x7) << 5);
dDead[dx][dy] = tdv;
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
void SyncUniqDead()
{
int i,mi;
int x,y;
// See function InitDead() to understand what this is all about
for (i = 0; i < nummonsters; i++) {
mi = monstactive[i];
if (monster[mi]._uniqtype != 0) {
// Search dDead array for this dead type, and place a light source there
for(x=0; x < DMAXX; x++)
for(y=0; y < DMAXY; y++)
if((dDead[x][y] & 0x1f) == monster[mi]._udeadval)
ChangeLightXY(monster[mi].mlid, x, y);
}
}
}

43
src/DEAD.H Normal file
View File

@ -0,0 +1,43 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Constants and Variables
**
** (C)1995 Condor, Inc. All rights reserved.
**-----------------------------------------------------------------------**
** $Header: /Diablo/DEAD.H 1 1/22/97 2:06p Dgartner $
**-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------**
** Defines
**-----------------------------------------------------------------------*/
#define MAXDEAD 31 // Always will be 31!
/*-----------------------------------------------------------------------**
** Structures
**-----------------------------------------------------------------------*/
typedef struct {
BYTE *_deadData[8]; // Data pointer to anim tables
int _deadFrame; // current dead frame
long _deadWidth; // width of dead
long _deadWidth2; // (width - 64) / 2 of dead for drawing
char _deadtrans; // translations for unique monsters
} DeadStruct;
/*-----------------------------------------------------------------------**
** Externs
**-----------------------------------------------------------------------*/
extern DeadStruct dead[MAXDEAD];
extern int spurtndx;
extern int stonendx;
/*-----------------------------------------------------------------------**
** Prototypes
**-----------------------------------------------------------------------*/
void InitDead();
void AddDead(int, int, char, int);
void SyncUniqDead();

350
src/DEBUG.CPP Normal file
View File

@ -0,0 +1,350 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Debugging file
**
** (C)1995 Condor, Inc. All rights reserved.
**
**-----------------------------------------------------------------------**
** $Header: /Diablo/DEBUG.CPP 1 1/22/97 2:06p Dgartner $
**-----------------------------------------------------------------------*/
#include "diablo.h"
#pragma hdrstop
#include "debug.h"
#include "engine.h"
#include "error.h"
#include "items.h"
#include "gendung.h"
#include "player.h"
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
BYTE *pSquareCel;
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
void InitDebugGFX() {
app_assert(! pSquareCel);
if (visiondebug)
pSquareCel = LoadFileInMemSig("Data\\Square.CEL",NULL,'DBGS');
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
void FreeDebugGFX() {
DiabloFreePtr(pSquareCel);
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
#define DEBUGSEEDS 4096
int debugseeds[DEBUGSEEDS];
//int seedcnt, seedidx[17];
int seedcnt, seedidx[NUMLEVELS+1]; // JKE to add crypt
BOOL seedflag = FALSE;
void InitDebugSeeds()
{
for (int i = 0; i < DEBUGSEEDS; i++) debugseeds[i] = -1;
seedcnt = 0;
for (i = 0; i < 17; i++) seedidx[i] = 0;
}
void StartDebugSeeds()
{
if (currlevel == 0) return;
seedcnt = seedidx[currlevel];
seedflag = TRUE;
}
void EndDebugSeeds()
{
if (currlevel == 0) return;
seedidx[currlevel+1] = seedcnt;
seedflag = FALSE;
}
void SaveDebugSeed(int s)
{
if (!seedflag) return;
if (seedcnt == DEBUGSEEDS) return;
if (currlevel == 0) return;
if (debugseeds[seedcnt] == -1) {
debugseeds[seedcnt] = s;
} else {
if (debugseeds[seedcnt] != s) app_fatal("Seeds desynced");
}
seedcnt++;
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
#if 0
char davehold1[5][MAXDUNX][MAXDUNY];
char davehold2[5][MAXDUNX][MAXDUNY];
BOOL daveinited[5] = { FALSE, FALSE, FALSE, FALSE, FALSE };
#define LEVELCHECK 1
void DaveCheck()
{
int xp, yp;
//if (currlevel != LEVELCHECK) return;
if (currlevel == 0) return;
if (currlevel >= 5) return;
for (yp = 0; yp < MAXDUNY; yp++) {
for (xp = 0; xp < MAXDUNX; xp++) {
if (dMonster[xp][yp] != 0) app_fatal("Monsters not cleared");
if (dPlayer[xp][yp] != 0) app_fatal("Players not cleared");
if (daveinited[currlevel]) {
if (davehold1[currlevel][xp][yp] != (dFlags[xp][yp] & BFLAG_MONSTACTIVE))
app_fatal("MonstActive not same");
if (davehold2[currlevel][xp][yp] != (dFlags[xp][yp] & BFLAG_SETPC))
app_fatal("Set Piece not same");
} else {
davehold1[currlevel][xp][yp] = dFlags[xp][yp] & BFLAG_MONSTACTIVE;
davehold2[currlevel][xp][yp] = dFlags[xp][yp] & BFLAG_SETPC;
}
}
}
daveinited[currlevel] = TRUE;
}
#endif
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
#if 1
#include "msg.h"
int blipplr = 0;
void BlipDebug(BOOL next)
{
if (next) blipplr = (blipplr + 1) & 0x3;
int i = blipplr;
char tempstr[128];
sprintf(tempstr, "Plr %i : Active = %i", i, plr[i].plractive);
NetSendString((1 << myplr), tempstr);
if (plr[i].plractive) {
sprintf(tempstr, " Plr %i is %s", i, plr[i]._pName);
NetSendString((1 << myplr), tempstr);
sprintf(tempstr, " Lvl = %i : Change = %i", plr[i].plrlevel, plr[i]._pLvlChanging);
NetSendString((1 << myplr), tempstr);
sprintf(tempstr, " x = %i, y = %i : tx = %i, ty = %i : fx = %i, fy = %i",
plr[i]._px, plr[i]._py, plr[i]._ptargx, plr[i]._ptargy, plr[i]._pfutx, plr[i]._pfuty);
NetSendString((1 << myplr), tempstr);
sprintf(tempstr, " mode = %i : daction = %i : walk[0] = %i", plr[i]._pmode, plr[i].destAction, plr[i].walkpath[0]);
NetSendString((1 << myplr), tempstr);
sprintf(tempstr, " inv = %i : hp = %i", plr[i]._pInvincible, plr[i]._pHitPoints);
NetSendString((1 << myplr), tempstr);
}
}
#endif
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
#if 1
#include "quests.h"
int currqdebug = 0;
void PrintQuestDebug()
{
char tempstr[128];
sprintf(tempstr, "Quest %i : Active = %i, Var1 = %i", currqdebug, quests[currqdebug]._qactive, quests[currqdebug]._qvar1);
NetSendString((1 << myplr),tempstr);
currqdebug++;
if (currqdebug == MAXQUESTS) currqdebug = 0;
}
#endif
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
#if 1
#include "monstint.h"
#include "themes.h"
#include "drlg_l4.h"
extern byte dung[L4DUNX][L4DUNY];
extern byte L4dungeon[L4DX][L4DY];
char mphold1[NUMLEVELS+1][MAXDUNX][MAXDUNY];
char mphold2[NUMLEVELS+1][MAXDUNX][MAXDUNY];
void DaveCheck2()
{
int xp, yp;
for (yp = 0; yp < MAXDUNY; yp++) {
for (xp = 0; xp < MAXDUNX; xp++) {
if (dMonster[xp][yp] != 0) app_fatal("Monsters not cleared");
if (dPlayer[xp][yp] != 0) app_fatal("Players not cleared");
mphold1[currlevel][xp][yp] = dFlags[xp][yp] & BFLAG_MONSTACTIVE;
mphold2[currlevel][xp][yp] = dFlags[xp][yp] & BFLAG_SETPC;
}
}
}
/*-----------------------------------------------------------------------*/
void PrintDaveCheck2()
{
int i, j, xp, yp, sum1, sum2, sum3;
long fv;
char tempstr[128];
sum1 = 0;
sum2 = 0;
for (yp = 0; yp < MAXDUNY; yp++) {
for (xp = 0; xp < MAXDUNX; xp++) {
sum1 += mphold1[currlevel][xp][yp];
sum2 += mphold2[currlevel][xp][yp];
}
}
sprintf(tempstr, "Level %i : Monst Active Sum = %i : dFlag sum = %i", currlevel, sum1, sum2);
NetSendString((1 << myplr),tempstr);
sum1 = 0;
sum2 = 0;
for (i = 1; i <= MAXTILES; i++) {
if (nSolidTable[i]) {
sum1 += i;
sum2++;
}
}
// Calc a volume of monsters
fv = 0;
for (i = DIRTEDGED2; i < (DMAXY - (DIRTEDGED2)); i++) {
for (j = DIRTEDGED2; j < (DMAXX - (DIRTEDGED2)); j++) {
if (!SolidLoc(i,j)) fv++;
}
}
sum3 = 0;
for (j = 0; j < MDMAXY; j++) {
for (i = 0; i < MDMAXX; i++) sum3 += dungeon[i][j];
}
sprintf(tempstr, "Solid Sum = %i:%i : Monst Vol = %i : Dungeon Sum = %i", sum1, sum2, fv, sum3);
NetSendString((1 << myplr),tempstr);
sum1 = 0;
for (j = 0; j < MAXDUNY; j++) {
for (i = 0; i < MAXDUNX; i++) {
sum1 += dTransVal[i][j];
}
}
sum2 = 0;
for (j = 0; j < DMAXY; j++) {
for (i = 0; i < DMAXX; i++) {
sum2 += dPiece[i][j];
}
}
sprintf(tempstr, "Num themes = %i/%i : Trans Sum = %i : dPiece Sum = %i", numthemes, themeCount, sum1, sum2);
NetSendString((1 << myplr),tempstr);
if (leveltype == 4) {
sum1 = 0;
for (j = 0; j < L4DUNY; j++) {
for (i = 0; i < L4DUNX; i++) sum1 += dung[i][j];
}
sum2 = 0;
for (j = 0; j < L4DY; j++) {
for (i = 0; i < L4DX; i++) sum2 += L4dungeon[i][j];
}
sprintf(tempstr, "dung sum = %i : L4Dungeon sum = %i", sum1, sum2);
}
}
/*-----------------------------------------------------------------------*/
int dungdebugy = 0;
void DaveDungDebug()
{
int sum, i;
char tempstr[128];
sum = 0;
for (i = 0; i < MDMAXX; i++) sum += dungeon[i][dungdebugy];
sprintf(tempstr, "dungeon Y=%i sum = %i", dungdebugy, sum);
NetSendString((1 << myplr), tempstr);
dungdebugy++;
if (dungdebugy == MDMAXY) dungdebugy = 0;
}
#endif
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
#if 1
#include "sound.h"
#include "monster.h"
#include "monstdat.h"
#include "cursor.h"
int debugmonst = 0;
void PrintDaveMonst(int m)
{
char tempstr[128];
int inlist, i;
sprintf(tempstr, "Monster %i = %s", m, monster[m].mName);
NetSendString((1 << myplr), tempstr);
sprintf(tempstr, "X = %i, Y = %i", monster[m]._mx, monster[m]._my);
NetSendString((1 << myplr), tempstr);
sprintf(tempstr, "Enemy = %i, HP = %i", monster[m]._menemy, monster[m]._mhitpoints);
NetSendString((1 << myplr), tempstr);
sprintf(tempstr, "Mode = %i, Var1 = %i", monster[m]._mmode, monster[m]._mVar1);
NetSendString((1 << myplr), tempstr);
inlist = 0;
for (i = 0; i < nummonsters; i++) {
if (monstactive[i] == m) inlist = 1;
}
sprintf(tempstr, "Active List = %i, Squelch = %i", inlist, monster[m]._msquelch);
NetSendString((1 << myplr), tempstr);
}
void DaveDebugMonst()
{
int cm;
if (cursmonst == -1) {
if (dMonster[cursmx][cursmy] == 0) cm = debugmonst;
else {
if (dMonster[cursmx][cursmy] > 0) cm = dMonster[cursmx][cursmy] - 1;
else cm = -(dMonster[cursmx][cursmy] + 1);
}
} else cm = cursmonst;
PrintDaveMonst(cm);
}
void DaveDebugMonst2()
{
char tempstr[128];
debugmonst++;
if (debugmonst == MAXMONSTERS) debugmonst = 0;
sprintf(tempstr, "Current debug monster = %i", debugmonst);
NetSendString((1 << myplr), tempstr);
}
#endif

19
src/DEBUG.H Normal file
View File

@ -0,0 +1,19 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Constants and Variables
**
** (C)1995 Condor, Inc. All rights reserved.
**-----------------------------------------------------------------------**
** $Header: /Diablo/DEBUG.H 1 1/22/97 2:06p Dgartner $
**-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------**
** Externs
**-----------------------------------------------------------------------*/
extern BYTE *pSquareCel;
void InitDebugSeeds();
void StartDebugSeeds();
void EndDebugSeeds();
void SaveDebugSeed(int s);

BIN
src/DIABLO.APS Normal file

Binary file not shown.

5342
src/DIABLO.BAK Normal file

File diff suppressed because it is too large Load Diff

3107
src/DIABLO.CPP Normal file

File diff suppressed because it is too large Load Diff

763
src/DIABLO.DSP Normal file
View File

@ -0,0 +1,763 @@
# Microsoft Developer Studio Project File - Name="Diablo" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=Diablo - Win32 Release
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "Diablo.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "Diablo.mak" CFG="Diablo - Win32 Release"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "Diablo - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "Diablo - Win32 Debug" (based on "Win32 (x86) Application")
!MESSAGE "Diablo - Win32 FinalFinal" (based on "Win32 (x86) Application")
!MESSAGE "Diablo - Win32 Shareware FinalFinal" (based on\
"Win32 (x86) Application")
!MESSAGE "Diablo - Win32 Shareware Release" (based on\
"Win32 (x86) Application")
!MESSAGE
# Begin Project
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "Diablo - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir ".\WinRel"
# PROP BASE Intermediate_Dir ".\WinRel"
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir ".\WinRel"
# PROP Intermediate_Dir ".\WinRel"
# PROP Ignore_Export_Lib 0
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FR /YX /c
# ADD CPP /nologo /G5 /Gr /MT /W3 /Zi /O1 /D "WIN32" /D "_WINDOWS" /D "_DEBUG" /D PROGRAM_VERSION=RETAIL /FAcs /Fr /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
# ADD LINK32 libcmt.lib winmm.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib version.lib /nologo /subsystem:windows /map /machine:I386 /nodefaultlib /out:".\WinRel/hellfire.exe"
# SUBTRACT LINK32 /incremental:yes /debug
!ELSEIF "$(CFG)" == "Diablo - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir ".\WinDebug"
# PROP BASE Intermediate_Dir ".\WinDebug"
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir ".\WinDebug"
# PROP Intermediate_Dir ".\WinDebug"
# PROP Ignore_Export_Lib 0
# ADD BASE CPP /nologo /W3 /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /c
# ADD CPP /nologo /G5 /Gr /MTd /W3 /Gm /GR /GX /Zi /Od /D "WIN32" /D "_WINDOWS" /D "_DEBUG" /D PROGRAM_VERSION=RETAIL /D "DEBUG_MEM" /D "_MULTITEST" /FAcs /Fr /YX /FD /c
# SUBTRACT CPP /Gy
# ADD BASE MTL /nologo /D "_DEBUG" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386
# ADD LINK32 libcmt.lib winmm.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib version.lib /nologo /subsystem:windows /profile /map /debug /machine:I386 /nodefaultlib /out:".\WinDebug/Hellfire.exe"
# SUBTRACT LINK32 /force
!ELSEIF "$(CFG)" == "Diablo - Win32 FinalFinal"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir ".\Diablo__"
# PROP BASE Intermediate_Dir ".\Diablo__"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir ".\WinFinal"
# PROP Intermediate_Dir ".\WinFinal"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /G5 /Gr /MT /W3 /Zi /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
# SUBTRACT BASE CPP /Fr
# ADD CPP /nologo /G5 /Gr /MT /W3 /Zi /O1 /D "WIN32" /D "_WINDOWS" /D "NDEBUG" /D PROGRAM_VERSION=RETAIL /D "_MULTITEST" /FAcs /YX /FD /c
# SUBTRACT CPP /Fr
# ADD BASE MTL /nologo /D "NDEBUG" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 winspool.lib libcmt.lib winmm.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib version.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib
# ADD LINK32 libcmt.lib winmm.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib version.lib /nologo /subsystem:windows /map /machine:I386 /nodefaultlib /out:".\WinFinal/Hellfire.exe"
# SUBTRACT LINK32 /incremental:yes
!ELSEIF "$(CFG)" == "Diablo - Win32 Shareware FinalFinal"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir ".\Diablo__"
# PROP BASE Intermediate_Dir ".\Diablo__"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir ".\SFinal"
# PROP Intermediate_Dir ".\SFinal"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /G5 /Gr /MT /W3 /Zi /O1 /D "WIN32" /D "_WINDOWS" /D "NDEBUG" /YX /c
# SUBTRACT BASE CPP /Fr
# ADD CPP /nologo /G5 /Gr /MT /W3 /Zi /O1 /D "WIN32" /D "_WINDOWS" /D "NDEBUG" /D PROGRAM_VERSION=SHAREWARE /FAcs /YX /FD /c
# SUBTRACT CPP /Fr
# ADD BASE MTL /nologo /D "NDEBUG" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 libcmt.lib winmm.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib version.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib
# ADD LINK32 libcmt.lib winmm.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib version.lib /nologo /subsystem:windows /map /machine:I386 /nodefaultlib
# SUBTRACT LINK32 /incremental:yes
!ELSEIF "$(CFG)" == "Diablo - Win32 Shareware Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir ".\Diablo_0"
# PROP BASE Intermediate_Dir ".\Diablo_0"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir ".\SRel"
# PROP Intermediate_Dir ".\SRel"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /G5 /Gr /MT /W3 /Zi /O1 /D "WIN32" /D "_WINDOWS" /D "_DEBUG" /YX /c
# SUBTRACT BASE CPP /Fr
# ADD CPP /nologo /G5 /Gr /MT /W3 /Zi /O1 /D "WIN32" /D "_WINDOWS" /D "_DEBUG" /D PROGRAM_VERSION=SHAREWARE /FAcs /YX /FD /c
# SUBTRACT CPP /Fr
# ADD BASE MTL /nologo /D "NDEBUG" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 libcmt.lib winmm.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib version.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib
# ADD LINK32 libcmt.lib winmm.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib version.lib /nologo /subsystem:windows /map /debug /machine:I386 /nodefaultlib
# SUBTRACT LINK32 /incremental:yes
!ENDIF
# Begin Target
# Name "Diablo - Win32 Release"
# Name "Diablo - Win32 Debug"
# Name "Diablo - Win32 FinalFinal"
# Name "Diablo - Win32 Shareware FinalFinal"
# Name "Diablo - Win32 Shareware Release"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
# Begin Source File
SOURCE=.\appfat.cpp
# End Source File
# Begin Source File
SOURCE=.\automap.cpp
# End Source File
# Begin Source File
SOURCE=.\capture.cpp
# End Source File
# Begin Source File
SOURCE=.\CODEC.CPP
# End Source File
# Begin Source File
SOURCE=.\CONTROL.CPP
# End Source File
# Begin Source File
SOURCE=.\CURSOR.CPP
# End Source File
# Begin Source File
SOURCE=.\ddraw.lib
# End Source File
# Begin Source File
SOURCE=.\DEAD.CPP
# End Source File
# Begin Source File
SOURCE=.\DEBUG.CPP
# End Source File
# Begin Source File
SOURCE=.\DIABLO.CPP
# End Source File
# Begin Source File
SOURCE=.\diablo.rc
!IF "$(CFG)" == "Diablo - Win32 Release"
!ELSEIF "$(CFG)" == "Diablo - Win32 Debug"
!ELSEIF "$(CFG)" == "Diablo - Win32 FinalFinal"
!ELSEIF "$(CFG)" == "Diablo - Win32 Shareware FinalFinal"
!ELSEIF "$(CFG)" == "Diablo - Win32 Shareware Release"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\doom.cpp
# End Source File
# Begin Source File
SOURCE=.\DRLG_L1.CPP
# End Source File
# Begin Source File
SOURCE=.\DRLG_L2.CPP
# End Source File
# Begin Source File
SOURCE=.\DRLG_L3.CPP
# End Source File
# Begin Source File
SOURCE=.\drlg_l4.cpp
# End Source File
# Begin Source File
SOURCE=.\dsound.lib
# End Source File
# Begin Source File
SOURCE=.\dthread.cpp
# End Source File
# Begin Source File
SOURCE=.\dx.cpp
# End Source File
# Begin Source File
SOURCE=.\effects.cpp
# End Source File
# Begin Source File
SOURCE=.\encrypt.cpp
# End Source File
# Begin Source File
SOURCE=.\ENGINE.CPP
# End Source File
# Begin Source File
SOURCE=.\error.cpp
# End Source File
# Begin Source File
SOURCE=.\except.cpp
# End Source File
# Begin Source File
SOURCE=.\GameMenu.cpp
# End Source File
# Begin Source File
SOURCE=.\GENDUNG.CPP
# End Source File
# Begin Source File
SOURCE=.\gmenu.cpp
# End Source File
# Begin Source File
SOURCE=.\WinDebug\hellfrui.lib
# End Source File
# Begin Source File
SOURCE=.\help.cpp
# End Source File
# Begin Source File
SOURCE=.\implode.lib
# End Source File
# Begin Source File
SOURCE=.\init.cpp
# End Source File
# Begin Source File
SOURCE=.\Interfac.cpp
# End Source File
# Begin Source File
SOURCE=.\inv.cpp
# End Source File
# Begin Source File
SOURCE=.\itemdat.cpp
# End Source File
# Begin Source File
SOURCE=.\ITEMS.CPP
# End Source File
# Begin Source File
SOURCE=.\LIGHTING.CPP
# End Source File
# Begin Source File
SOURCE=.\loadsave.cpp
# End Source File
# Begin Source File
SOURCE=.\mainmenu.cpp
# End Source File
# Begin Source File
SOURCE=.\minitext.cpp
# End Source File
# Begin Source File
SOURCE=.\misdat.cpp
# End Source File
# Begin Source File
SOURCE=.\misdat.h
# End Source File
# Begin Source File
SOURCE=.\MISSILES.CPP
# End Source File
# Begin Source File
SOURCE=.\Mono.cpp
# End Source File
# Begin Source File
SOURCE=.\MONSTDAT.CPP
# End Source File
# Begin Source File
SOURCE=.\MONSTER.CPP
# End Source File
# Begin Source File
SOURCE=.\movie.cpp
# End Source File
# Begin Source File
SOURCE=.\mpqapi.cpp
# End Source File
# Begin Source File
SOURCE=.\msg.cpp
# End Source File
# Begin Source File
SOURCE=.\multi.cpp
# End Source File
# Begin Source File
SOURCE=.\nthread.cpp
# End Source File
# Begin Source File
SOURCE=.\objdat.cpp
# End Source File
# Begin Source File
SOURCE=.\OBJECTS.CPP
# End Source File
# Begin Source File
SOURCE=.\packplr.cpp
# End Source File
# Begin Source File
SOURCE=.\PALETTE.CPP
# End Source File
# Begin Source File
SOURCE=.\path.cpp
# End Source File
# Begin Source File
SOURCE=.\pfile.cpp
# End Source File
# Begin Source File
SOURCE=.\PLAYER.CPP
# End Source File
# Begin Source File
SOURCE=.\plrmsg.cpp
# End Source File
# Begin Source File
SOURCE=.\portal.cpp
# End Source File
# Begin Source File
SOURCE=.\Quests.cpp
# End Source File
# Begin Source File
SOURCE=.\SCROLLRT.CPP
# End Source File
# Begin Source File
SOURCE=.\SetMaps.cpp
# End Source File
# Begin Source File
SOURCE=.\SHA.CPP
# End Source File
# Begin Source File
SOURCE=.\SOUND.CPP
# End Source File
# Begin Source File
SOURCE=.\Spelldat.cpp
# End Source File
# Begin Source File
SOURCE=.\SPELLS.CPP
# End Source File
# Begin Source File
SOURCE=.\stores.cpp
# End Source File
# Begin Source File
SOURCE=.\WinDebug\storm.lib
# End Source File
# Begin Source File
SOURCE=.\sync.cpp
# End Source File
# Begin Source File
SOURCE=.\Textdat.cpp
# End Source File
# Begin Source File
SOURCE=.\themes.cpp
# End Source File
# Begin Source File
SOURCE=.\tmsg.cpp
# End Source File
# Begin Source File
SOURCE=.\TOWN.CPP
# End Source File
# Begin Source File
SOURCE=.\towners.cpp
# End Source File
# Begin Source File
SOURCE=.\track.cpp
# End Source File
# Begin Source File
SOURCE=.\TRIGS.CPP
# End Source File
# Begin Source File
SOURCE=.\wave.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
# Begin Source File
SOURCE=.\automap.h
# End Source File
# Begin Source File
SOURCE=.\Control.h
# End Source File
# Begin Source File
SOURCE=.\Cursor.h
# End Source File
# Begin Source File
SOURCE=.\d3dtypes.h
# End Source File
# Begin Source File
SOURCE=.\Ddraw.h
# End Source File
# Begin Source File
SOURCE=.\Dead.h
# End Source File
# Begin Source File
SOURCE=.\Debug.h
# End Source File
# Begin Source File
SOURCE=.\Diablo.h
# End Source File
# Begin Source File
SOURCE=.\Diabloui.h
# End Source File
# Begin Source File
SOURCE=.\doom.h
# End Source File
# Begin Source File
SOURCE=.\Drlg_l1.h
# End Source File
# Begin Source File
SOURCE=.\Drlg_l2.h
# End Source File
# Begin Source File
SOURCE=.\Drlg_l3.h
# End Source File
# Begin Source File
SOURCE=.\Drlg_l4.h
# End Source File
# Begin Source File
SOURCE=.\Dsound.h
# End Source File
# Begin Source File
SOURCE=.\Effects.h
# End Source File
# Begin Source File
SOURCE=.\Engine.h
# End Source File
# Begin Source File
SOURCE=.\error.h
# End Source File
# Begin Source File
SOURCE=.\Gamemenu.h
# End Source File
# Begin Source File
SOURCE=.\Gendung.h
# End Source File
# Begin Source File
SOURCE=.\help.h
# End Source File
# Begin Source File
SOURCE=.\implode.h
# End Source File
# Begin Source File
SOURCE=.\Interfac.h
# End Source File
# Begin Source File
SOURCE=.\Inv.h
# End Source File
# Begin Source File
SOURCE=.\itemdat.h
# End Source File
# Begin Source File
SOURCE=.\Items.h
# End Source File
# Begin Source File
SOURCE=.\Lighting.h
# End Source File
# Begin Source File
SOURCE=.\mainmenu.h
# End Source File
# Begin Source File
SOURCE=.\MiniText.h
# End Source File
# Begin Source File
SOURCE=.\Missiles.h
# End Source File
# Begin Source File
SOURCE=.\Mono.h
# End Source File
# Begin Source File
SOURCE=.\Monstdat.h
# End Source File
# Begin Source File
SOURCE=.\Monster.h
# End Source File
# Begin Source File
SOURCE=.\monstint.h
# End Source File
# Begin Source File
SOURCE=.\mpqapi.h
# End Source File
# Begin Source File
SOURCE=.\msg.h
# End Source File
# Begin Source File
SOURCE=.\Multi.h
# End Source File
# Begin Source File
SOURCE=.\objdat.h
# End Source File
# Begin Source File
SOURCE=.\Objects.h
# End Source File
# Begin Source File
SOURCE=.\packplr.h
# End Source File
# Begin Source File
SOURCE=.\Palette.h
# End Source File
# Begin Source File
SOURCE=.\path.h
# End Source File
# Begin Source File
SOURCE=.\Player.h
# End Source File
# Begin Source File
SOURCE=.\portal.h
# End Source File
# Begin Source File
SOURCE=.\Quests.h
# End Source File
# Begin Source File
SOURCE=.\regconst.h
# End Source File
# Begin Source File
SOURCE=.\Sclass.h
# End Source File
# Begin Source File
SOURCE=.\scrlasm.h
# End Source File
# Begin Source File
SOURCE=.\Scrollrt.h
# End Source File
# Begin Source File
SOURCE=.\Setmaps.h
# End Source File
# Begin Source File
SOURCE=.\Sound.h
# End Source File
# Begin Source File
SOURCE=.\spelldat.h
# End Source File
# Begin Source File
SOURCE=.\Spells.h
# End Source File
# Begin Source File
SOURCE=.\stores.h
# End Source File
# Begin Source File
SOURCE=.\Storm.h
# End Source File
# Begin Source File
SOURCE=.\textdat.h
# End Source File
# Begin Source File
SOURCE=.\themes.h
# End Source File
# Begin Source File
SOURCE=.\Town.h
# End Source File
# Begin Source File
SOURCE=.\towners.h
# End Source File
# Begin Source File
SOURCE=.\Trigs.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\icon1.ico
# End Source File
# End Group
# Begin Source File
SOURCE=.\WinRel\Scroll.obj
# End Source File
# End Target
# End Project

41
src/DIABLO.DSW Normal file
View File

@ -0,0 +1,41 @@
Microsoft Developer Studio Workspace File, Format Version 5.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "Diablo"=.\Diablo.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "ui"=.\UISRC\UI\ui.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

316
src/DIABLO.H Normal file
View File

@ -0,0 +1,316 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Constants and Variables
**
** (C)1995 Condor, Inc. All rights reserved.
**-----------------------------------------------------------------------**
** $Header: /Diablo/DIABLO.H 4 2/10/97 6:22p Dbrevik2 $
**-----------------------------------------------------------------------*/
//******************************************************************
// SOFTWARE VERSIONING
//******************************************************************
// version constants
#define SHAREWARE 1
#define BETA 2
#define RETAIL 3
#define IS_VERSION(x) (PROGRAM_VERSION == x)
// make sure valid PROGRAM_VERSION is defined
#ifndef PROGRAM_VERSION
#error PROGRAM_VERSION should be defined in Build.Settings.C/C++.Preprocessor
#elif IS_VERSION(SHAREWARE)
//#pragma message("*building shareware")
#elif IS_VERSION(BETA)
//#pragma message("*building beta")
#elif IS_VERSION(RETAIL)
//#pragma message("*building retail")
#else
#error PROGRAM_VERSION is invalid
#endif
// collin's new RLE draw code -- must have
// reprocessed .CL2 files for this to work
#define RLE_DRAW 1 // 1 in final
// cheats compile flag 0 == off, 1 == on
#define CHEATS 1 // 0 in final
#ifdef NDEBUG
#undef CHEATS
#define CHEATS 0
#endif
// misc 0 == testing, 1 == normal
#define RELEASE 1 // 1 in final
#ifdef NDEBUG
#undef RELEASE
#define RELEASE 1
#endif
// 1 = allow debugging, 0 = release
#define ALLOW_WINDOWED_MODE 1 // 0 in final
#ifdef NDEBUG
#undef ALLOW_WINDOWED_MODE
#define ALLOW_WINDOWED_MODE 0
#endif
// 1 = show network debugging info
#define TRACEOUT 1 // 0 in final
#ifdef NDEBUG
#undef TRACEOUT
#define TRACEOUT 0
#endif
// 1 = show current trace function, 0 = release
#define ALLOW_TRACE_FCN 0 // 0 in final
#ifdef NDEBUG
#undef ALLOW_TRACE_FCN
#define ALLOW_TRACE_FCN 0
#endif
#if ALLOW_TRACE_FCN
void trace_fcn(const char * pszFcn);
#define TRACE_FCN(x) trace_fcn(x)
#else
#define TRACE_FCN(x) NULL
#endif
// save file "version"
// so we don't have version number conflicts:
// - EVEN number if RETAIL/SHAREWARE version
// - ODD number if BETA version
#define SAVE_GAME_KEY 0x7058
#if IS_VERSION(RETAIL) && ((SAVE_GAME_KEY & 1) != 0)
#error -- SAVE_GAME_KEY must be EVEN for RETAIL version
#endif
#if IS_VERSION(BETA) && ((SAVE_GAME_KEY & 1) == 0)
#error -- SAVE_GAME_KEY must be ODD for BETA version
#endif
// EVEN version ID = retail version
// ODD version ID = beta version
#define VERSIONID 34
#if IS_VERSION(RETAIL) && ((VERSIONID & 1) != 0)
#error -- VERSIONID must be EVEN for RETAIL version
#endif
#if IS_VERSION(BETA) && ((VERSIONID & 1) == 0)
#error -- VERSIONID must be ODD for BETA version
#endif
#ifndef PROGRAM_VERSION
#error PROGRAM_VERSION not defined
#elif IS_VERSION(RETAIL)
//#define PROGRAMID 'DRTL'
#define PROGRAMID 'HRTL'
#elif IS_VERSION(SHAREWARE)
#define PROGRAMID 'DSHR'
#elif IS_VERSION(BETA)
#define PROGRAMID 'DIAB'
#else
#error -- VERSION NOT DEFINED
#endif
/*-----------------------------------------------------------------------**
** Defines
**-----------------------------------------------------------------------*/
#define MAX_PLRS 4
// frame rate
#define GAME_FRAMES_PER_SECOND 20
// Our messages
#define WM_DIABNEXTLVL WM_USER+2
#define WM_DIABPREVLVL WM_USER+3
#define WM_DIABRTNLVL WM_USER+4
#define WM_DIABSETLVL WM_USER+5
#define WM_DIABWARPLVL WM_USER+6
#define WM_DIABTOWNWARP WM_USER+7
#define WM_DIABTWARPUP WM_USER+8
#define WM_DIABRETOWN WM_USER+9
#define WM_DIABNEWGAME WM_USER+10
#define WM_DIABLOADGAME WM_USER+11
// Screen size
#define TOTALX 640
#define TOTALY 480
// Size of control panel
#define CTRLPANY 128
// Size of game play area
#define GAMEY 352
// Offscreen buffer size
#define BUFFERX 768
#define BUFFERY 656
#define BUFFERSIZE BUFFERX*BUFFERY
#define BTMBUFFX 640
#define BTMBUFFY 144
#define BTMBUFFSIZE BTMBUFFX*BTMBUFFY
#define BTMBUFFMULTISIZE BTMBUFFX*BTMBUFFY*2
// Used in processing players, monsters, objects etc.
#define RUN_DONE 0
#define RUN_AGAIN 1
#define MAX_LEVELS 24
#define DIABLO_LEVEL 16
#define SLAIN_HERO_LEVEL 9
#define STORY_BOOK1_LEVEL 4
#define STORY_BOOK2_LEVEL 8
#define STORY_BOOK3_LEVEL 12
// JKE STORY BOOKS FOR HELLFIRE
#define SKULKEN_BOOK1_LEVEL 21
#define SKULKEN_BOOK2_LEVEL 22
#define SKULKEN_BOOK3_LEVEL 23
/*-----------------------------------------------------------------------**
** Included files
**-----------------------------------------------------------------------*/
#define STRICT
#include <windows.h>
#include <windowsx.h>
#include <mmsystem.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "ddraw.h"
#include "dsound.h"
#include <time.h>
#include <direct.h>
#include <errno.h>
/*-----------------------------------------------------------------------**
** Externs
**-----------------------------------------------------------------------*/
extern HWND ghMainWnd;
extern HINSTANCE ghInst;
extern const char gszAppName[];
// DO NOT USE gbFontTransTbl directly -- use the macro
// to prevent sign extension problems with characters!!!
extern const BYTE gbFontTransTbl[];
#define char2print(c) gbFontTransTbl[(BYTE) (c)];
// video vars
extern LPDIRECTDRAW lpDD;
extern LPDIRECTDRAWSURFACE lpDDSPrimary;
extern LPDIRECTDRAWPALETTE lpDDPal;
extern BOOL fullscreen;
extern BOOL bActive;
// these variables are only valid if lock_buf() has been called
extern BYTE * gpBuffer;
extern "C" long glClipY;
void lock_buf(BYTE bFcn);
void unlock_buf(BYTE bFcn);
// program vars
extern BOOL svgamode;
extern int MouseX, MouseY;
extern int force_redraw;
// Temp vars (delete all uses before final compile)
extern long gv1;
extern long gv2;
extern long gv3;
extern long gv4;
extern long gv5;
// General flags
extern BOOL PauseMode;
extern BOOL gbProcessPlayers;
extern BOOL FriendlyMode;
#if CHEATS
extern BOOL davedebug;
extern BOOL cheatflag;
extern BOOL simplecheat;
#endif
extern BOOL visiondebug;
extern BOOL light4flag;
extern BOOL leveldebug;
extern BOOL monstdebug;
extern int debugmonsttypes;
extern int DebugMonsters[10];
/*----------------------------------------------------------*/
// HELLFIRE FLAGS
/*----------------------------------------------------------*/
extern bool gbTheo;
extern bool gbCowsuit;
extern bool gbOurNest;
extern bool gbAllowBard;
extern bool gbAllowBarbarian;
extern bool gbAllowMultiPlayer;
/*-----------------------------------------------------------------------**
** Prototypes
**-----------------------------------------------------------------------*/
LRESULT CALLBACK DiabloDefProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
void LoadGameLevel(BOOL, int);
void FreeGameMem();
void SetupSaveBasePath();
#if TRACEOUT
void __cdecl TraceOut(const char * pszFmt, ...);
#endif
/*-----------------------------------------------------------------------**
** Assertion System
**-----------------------------------------------------------------------*/
#define EXTENDED_ASSERT 1 // 0 in final
#ifdef NDEBUG
#undef EXTENDED_ASSERT
#define EXTENDED_ASSERT 0
#endif
const TCHAR * strGetLastError();
const TCHAR * strGetError(DWORD dwErr);
void __cdecl app_fatal(const char * pszFmt,...);
void __cdecl app_warning(const char * pszFmt,...);
void app_assert(int);
#if EXTENDED_ASSERT && !defined(NDEBUG)
void assert_fail(int nLineNo, const char * pszFile, const char * pszFail);
#define app_assert(x) ((x) ? NULL : assert_fail(__LINE__,__FILE__,#x))
#elif !defined(NDEBUG)
void assert_fail(int nLineNo, const char * pszFile);
#define app_assert(x) ((x) ? NULL : assert_fail(__LINE__,__FILE__))
#else
#define app_assert(x) (x) // in case of side effects
#endif
void ddraw_assert(int);
void ddraw_assert_fail(HRESULT ddrval, int nLineNo, const char * pszFile);
#define ddraw_assert(x) (((x) == DD_OK) ? NULL : ddraw_assert_fail((x),__LINE__,__FILE__))
void dsound_assert(int);
void dsound_assert_fail(HRESULT dsrval, int nLineNo, const char * pszFile);
#define dsound_assert(x) (((x) == DS_OK) ? NULL : dsound_assert_fail((x),__LINE__,__FILE__))
// jcm.patch1.start.1/14/97
#ifdef NDEBUG
#define GRACEFUL_EXIT
#endif
// jcm.patch1.end.1/14/97

9974
src/DIABLO.MAK Normal file

File diff suppressed because it is too large Load Diff

BIN
src/DIABLO.MDP Normal file

Binary file not shown.

BIN
src/DIABLO.NCB Normal file

Binary file not shown.

BIN
src/DIABLO.OPT Normal file

Binary file not shown.

0
src/DIABLO.PLG Normal file
View File

325
src/DIABLO.RC Normal file
View File

@ -0,0 +1,325 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON1 ICON DISCARDABLE "icon1.ico"
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION 97,5,23,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "Synergistic Software\0"
VALUE "FileDescription", "Hellfire\0"
VALUE "FileVersion", "1, 0, 1, 0\0"
VALUE "InternalName", "Hellfire\0"
VALUE "LegalCopyright", "Copyright © 1997\0"
VALUE "OriginalFilename", "hellfire.exe\0"
VALUE "ProductName", "Synergistic Software Hellfire\0"
VALUE "ProductVersion", "98, 1, 13, 1\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#endif // !_MAC
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_DDRAW_ERR DIALOG DISCARDABLE 0, 0, 250, 241
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Direct Draw Error"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,193,220,50,14
LTEXT "Hellfire was unable to properly initialize your video card using DirectX. Please try the following solutions to correct the problem:",
IDC_STATIC,7,7,236,18
LTEXT "Use the Diablo setup program ""SETUP.EXE"" provided on the Diablo CD-ROM to install DirectX 3.0.",
IDC_STATIC,19,26,210,18
LTEXT "Install the most recent DirectX video drivers provided by the manufacturer of your video card. A list of video card manufactuers can be found at: http://www.sierracom",
IDC_STATIC,19,48,210,27
LTEXT "The error encountered while trying to initialize the video card was:",
IDC_STATIC,7,175,236,9
LTEXT "unknown error",IDC_ERROR_TAG,19,186,210,27
LTEXT "If you continue to have problems, we have also included Microsoft DirectX 2.0 drivers on the Diablo CD-ROM. This older version of DirectX may work in cases where DirectX 3.0 does not.",
IDC_STATIC,7,79,236,27
LTEXT "USA telephone: 1-800-426-9400\nInternational telephone: 206-882-8080\nhttp://www.microsoft.com",
IDC_STATIC,19,137,210,27
LTEXT "If you continue to have problems with DirectX, please contact Microsoft's Technical Support at:",
IDC_STATIC,7,116,236,18
END
IDD_MEM_ERR DIALOG DISCARDABLE 0, 0, 250, 213
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Out of Memory Error"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,193,192,50,14
LTEXT "Hellfire has exhausted all the memory on your system. This problem can likely be corrected by changing the virtual memory settings for Windows. Ensure that your system has at least 10 megabytes of free disk space, then check your virtual memory settings:",
IDC_STATIC,7,7,236,36
LTEXT "Select ""Settings - Control Panel"" from the ""Start"" menu\nRun the ""System"" control panel applet\nSelect the ""Performance"" tab, and press ""Virtual Memory""\nUse the ""Let Windows manage my virtual memory..."" option",
IDC_STATIC,23,54,197,36
LTEXT "The error encountered was:",IDC_STATIC,7,146,236,11
LTEXT "unknown location",IDC_ERROR_TAG,20,157,210,27
LTEXT "For Windows 95:",IDC_STATIC,7,45,236,9
LTEXT "Select ""Settings - Control Panel"" from the ""Start"" menu\nRun the ""System"" control panel applet\nSelect the ""Performance"" tab\nPress ""Change"" in ""Virtual Memory"" settings\nEnsure that the virtual memory file is at least 32 megabytes",
IDC_STATIC,17,98,197,45
LTEXT "For Windows NT:",IDC_STATIC,7,89,236,9
END
IDD_FILE_ERR DIALOG DISCARDABLE 0, 0, 265, 114
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Data File Error"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,208,93,50,14
LTEXT "Hellfire was unable to open a required file. Please ensure that the Diablo disc is in the CDROM drive. If this problem persists, try uninstalling and reinstalling Hellfire using the program ""SETUP.EXE"" on the Hellfire CD-ROM.",
-1,7,7,251,36
LTEXT "The problem occurred while trying to load a file",-1,7,
48,232,9
LTEXT "unknown file",IDC_ERROR_TAG,20,59,210,27
END
IDD_DDRAW_DLL_ERR DIALOG DISCARDABLE 0, 0, 250, 161
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Direct Draw Error"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,193,140,50,14
LTEXT "Hellfire was unable to find the file ""ddraw.dll"", which is a component of Microsoft DirectX. Please run the program ""SETUP.EXE"" on the Diablo CD-ROM and install Microsoft DirectX.",
-1,7,7,236,27
LTEXT "The error encountered while trying to initialize DirectX was:",
-1,7,95,236,9
LTEXT "unknown error",IDC_ERROR_TAG,19,106,210,29
LTEXT "USA telephone: 1-800-426-9400\nInternational telephone: 206-882-8080\nhttp://www.microsoft.com",
-1,19,60,210,27
LTEXT "If you continue to have problems with DirectX, please contact Microsoft's Technical Support at:",
-1,7,39,236,18
END
IDD_DSOUND_DLL_ERR DIALOG DISCARDABLE 0, 0, 250, 161
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Direct Sound Error"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,193,140,50,14
LTEXT "Hellfire was unable to find the file ""dsound.dll"", which is a component of Microsoft DirectX. Please run the program ""SETUP.EXE"" on the Diablo CD-ROM and install Microsoft DirectX.",
-1,7,7,236,27
LTEXT "The error encountered while trying to initialize DirectX was:",
-1,7,95,236,9
LTEXT "unknown error",IDC_ERROR_TAG,19,106,210,27
LTEXT "USA telephone: 1-800-426-9400\nInternational telephone: 206-882-8080\nhttp://www.microsoft.com",
-1,19,60,210,27
LTEXT "If you continue to have problems with DirectX, please contact Microsoft's Technical Support at:",
-1,7,39,236,18
END
IDD_DISKFREE_ERR DIALOG DISCARDABLE 0, 0, 250, 100
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Out of Disk Space"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,193,79,50,14
LTEXT "Hellfire requires at least 10 megabytes of free disk space to run properly. The disk:",
-1,7,7,236,18
LTEXT "",-1,7,43,232,9
LTEXT "unknown drive",IDC_ERROR_TAG,7,33,210,9
LTEXT "has less than 10 megabytes of free space left. Please free some space on your drive and run Hellfire again.",
-1,7,52,236,18
END
IDD_DDRAW_PAL_ERR DIALOG DISCARDABLE 0, 0, 250, 161
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Direct Draw Error"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,193,140,50,14
LTEXT "Hellfire was unable to switch video modes. This is a common problem for computers with more than one video card. To correct this problem, please set your video resolution to 640 x 480 and try running Hellfire again.",
IDC_STATIC,7,7,236,27
LTEXT "The error encountered while trying to switch video modes was:",
IDC_STATIC,7,95,236,9
LTEXT "unknown error",IDC_ERROR_TAG,19,106,210,27
LTEXT "Select ""Settings - Control Panel"" from the ""Start"" menu\nRun the ""Display"" control panel applet\nSelect the ""Settings"" tab\nSet the ""Desktop Area"" to ""640 x 480 pixels""",
IDC_STATIC,23,50,197,36
LTEXT "For Windows 95 and Windows NT",IDC_STATIC,7,41,236,9
END
IDD_CDROM_ERR DIALOG DISCARDABLE 0, 0, 250, 92
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Data File Error"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,136,71,50,14
LTEXT "Hellfire cannot read a required data file. Your Diablo CD may not be in the CDROM drive. Please ensure that the Diablo disc is in the CDROM drive and press OK. To leave the program, press Exit.",
-1,7,7,236,27
LTEXT "unknown file",IDC_ERROR_TAG,20,37,210,27
PUSHBUTTON "Exit",IDCANCEL,193,71,50,14
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_DDRAW_ERR, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 243
TOPMARGIN, 7
BOTTOMMARGIN, 234
END
IDD_MEM_ERR, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 243
TOPMARGIN, 7
BOTTOMMARGIN, 206
END
IDD_FILE_ERR, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 258
TOPMARGIN, 7
BOTTOMMARGIN, 107
END
IDD_DDRAW_DLL_ERR, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 243
TOPMARGIN, 7
BOTTOMMARGIN, 154
END
IDD_DSOUND_DLL_ERR, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 243
TOPMARGIN, 7
BOTTOMMARGIN, 154
END
IDD_DISKFREE_ERR, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 243
TOPMARGIN, 7
BOTTOMMARGIN, 93
END
IDD_DDRAW_PAL_ERR, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 243
TOPMARGIN, 7
BOTTOMMARGIN, 154
END
IDD_CDROM_ERR, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 243
TOPMARGIN, 7
BOTTOMMARGIN, 85
END
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

3097
src/DIABLO.SAV Normal file

File diff suppressed because it is too large Load Diff

265
src/DIABLOUI.H Normal file
View File

@ -0,0 +1,265 @@
//***************************************************************************
// DiabloUI.h
// created 9.13.96
//***************************************************************************
//***************************************************************************
extern "C" void APIENTRY UiInitialize(void);
extern "C" void APIENTRY UiSetSpawned(BOOL bSpawned);
extern "C" void APIENTRY UiDestroy();
extern "C" void APIENTRY UiAppActivate(BOOL activating);
//***************************************************************************
extern "C" BOOL CALLBACK UiCreateGameCallback (SNETCREATEDATAPTR createdata,
SNETPROGRAMDATAPTR programdata,
SNETPLAYERDATAPTR playerdata,
SNETUIDATAPTR interfacedata,
SNETVERSIONDATAPTR versiondata,
DWORD *playerid);
extern "C" BOOL CALLBACK UiArtCallback (DWORD providerid,
DWORD artid,
LPPALETTEENTRY pe,
LPBYTE buffer,
DWORD buffersize,
int *width,
int *height,
int *bitdepth);
extern "C" BOOL CALLBACK UiSoundCallback(DWORD providerid, DWORD soundid, DWORD flags);
extern "C" BOOL CALLBACK UiDrawDescCallback (DWORD providerid,
DWORD itemtype,
LPCSTR itemname,
LPCSTR itemdescription,
DWORD itemflags,
DWORD drawflags,
DWORD time,
LPDRAWITEMSTRUCT lpdis);
extern "C" BOOL CALLBACK UiMessageBoxCallback(HWND hWnd,
LPCTSTR lpText,
LPCTSTR lpCaption,
UINT uType);
extern "C" BOOL CALLBACK UiAuthCallback(DWORD dwItemType, LPCSTR szName, LPCSTR szDesc, DWORD dwUserFlags, LPCSTR szItem, LPSTR szErrorBuf, DWORD dwErrorBufSize);
extern "C" BOOL CALLBACK UiGetDataCallback(DWORD providerid, DWORD dataid, LPVOID buffer, DWORD buffersize, DWORD *bytesused);
extern "C" BOOL CALLBACK UiCategoryCallback(
BOOL userinitiated,
SNETPROGRAMDATAPTR programdata,
SNETPLAYERDATAPTR playerdata,
SNETUIDATAPTR interfacedata,
SNETVERSIONDATAPTR versiondata,
DWORD * categorybits,
DWORD * categorymask);
//***************************************************************************
enum _ui_classes {
UI_WARRIOR = 0,
UI_ROGUE,
UI_SORCERER,
UI_MONK,
UI_BARD,
UI_BARBARIAN,
UI_NUM_CLASSES
};
//***************************************************************************
extern "C" BOOL APIENTRY UiTitleDialog (UINT timeoutseconds);
extern "C" BOOL APIENTRY UiBetaDisclaimer (UINT timeoutseconds);
extern "C" BOOL APIENTRY UiCreditsDialog (UINT pixelspersec);
extern "C" BOOL APIENTRY UiSupportDialog (UINT pixelspersec);
//***************************************************************************
enum _copyprot_results {
COPYPROT_OK = 1,
COPYPROT_CANCEL
};
extern "C" BOOL APIENTRY UiCopyProtError (DWORD *result);
//***************************************************************************
#define DEFAULT_ATTRACT_TIMEOUT 30
typedef void (CALLBACK *PLAYSND)(LPCSTR);
enum _mainmenu_selections {
MAINMENU_SINGLE_PLAYER = 1,
MAINMENU_MULTIPLAYER,
MAINMENU_REPLAY_INTRO,
MAINMENU_SUPPORT,
MAINMENU_SHOW_CREDITS,
MAINMENU_EXIT_DIABLO,
MAINMENU_ATTRACT_MODE
};
extern "C" BOOL APIENTRY UiMainMenuDialog(LPCTSTR registration,
DWORD * selection,
bool allowMultiPlayer,
PLAYSND sndfcn = NULL,
UINT attracttimeoutseconds = DEFAULT_ATTRACT_TIMEOUT);
//***************************************************************************
#define MAX_GAME_LEN 32
#define MAX_PASSWORD_LEN 32
enum _difficulty {
DIFF_NORMAL,
DIFF_NIGHTMARE,
DIFF_HELL,
NUM_DIFFICULTIES
};
typedef struct _gamedata TGAMEDATA;
struct _gamedata {
DWORD dwSeed;
BYTE bDiff; // Use enum's from _difficulty settings
};
//***************************************************************************
//***************************************************************************
// all the functions and structures for selecting/creating/deleting heros
//***************************************************************************
//***************************************************************************
#define MAX_NAME_LEN 16 // including terminting char
#define MAX_CLASS_LEN 16 // including terminting char
typedef struct _uiheroinfo TUIHEROINFO;
typedef TUIHEROINFO *TPUIHEROINFO;
typedef struct _uidefaultstats {
WORD strength;
WORD magic;
WORD dexterity;
WORD vitality;
} TUIDEFSTATS, *TPUIDEFSTATS;
struct _uiheroinfo {
TPUIHEROINFO next;
char name[MAX_NAME_LEN]; // eg "Frasier"
WORD level;
BYTE heroclass; // UI_WARRIOR, etc.
BYTE herorank; // # of times hero has killed Diablo (range = 0..NUM_DIFFICULTIES)
WORD strength;
WORD magic;
WORD dexterity;
WORD vitality;
DWORD gold;
BOOL hassaved;
BOOL spawned;
};
//***************************************************************************
#define UI_DESC_MAXLENGTH 128
// The following routines output a null terminated string to the provided preallocated
// pointers. The maximum length of the string is defined by the above constant.
extern "C" BOOL APIENTRY UiCreatePlayerDescription(TPUIHEROINFO pHeroInfo, DWORD dwProgramId, LPSTR pPlayerDesc);
// Call this routine to generate a query string used by Battle.net to sort games in the
// JoinGame list. Returns the number of bytes written out to szQuery.
extern "C" int APIENTRY UiCreateGameCriteria(TPUIHEROINFO pHeroInfo, LPSTR pszQuery);
//***************************************************************************
typedef BOOL (CALLBACK *ENUMHEROPROC)(TPUIHEROINFO);
typedef BOOL (CALLBACK *ENUMHEROS)(ENUMHEROPROC);
typedef BOOL (CALLBACK *CREATEHERO)(TPUIHEROINFO);
typedef BOOL (CALLBACK *DELETEHERO)(TPUIHEROINFO);
typedef BOOL (CALLBACK *GETDEFHERO)(int, TPUIDEFSTATS);
enum _selhero_selections {
SELHERO_NEW_DUNGEON = 1,
SELHERO_CONTINUE,
SELHERO_CONNECT,
SELHERO_PREVIOUS
};
extern "C" BOOL APIENTRY UiSelHeroSingDialog(
ENUMHEROS enumfcn,
CREATEHERO createfcn,
DELETEHERO deletefcn,
GETDEFHERO getstatsfcn,
DWORD *selection,
LPSTR heroname,
int *difficulty,
bool allowBard,
bool allowBarbarian
);
extern "C" BOOL APIENTRY UiSelHeroMultDialog(
ENUMHEROS enumfcn,
CREATEHERO createfcn,
DELETEHERO deletefcn,
GETDEFHERO getstatsfcn,
DWORD *selection,
LPSTR heroname,
bool allowBard,
bool allowBarbarian
);
// if the default starting statistics for a character class change
// then Diablo.exe will have to provide this function
extern "C" BOOL CALLBACK UiGetDefaultStats(int heroclass, TPUIDEFSTATS defaultstats);
//***************************************************************************
extern "C" BOOL APIENTRY UiLogonDialog(HWND parent,
DWORD *selection,
LPSTR logonname,
UINT maxnamelen,
LPSTR logonpassword,
UINT maxpasswordlen);
//***************************************************************************
typedef int (CALLBACK *PROGRESSFCN)(void);
extern "C" BOOL APIENTRY UiProgressDialog(HWND parent,
LPCSTR progresstext,
BOOL abortable,
PROGRESSFCN progressfcn,
DWORD callspersec);
//***************************************************************************
extern "C" void APIENTRY UiOnPaint (LPPARAMS params);
extern "C" BOOL APIENTRY UiSetBackgroundBitmap (HWND window,
LPPALETTEENTRY palette,
LPBYTE bitmapbits,
int width,
int height);
//***************************************************************************
//***************************************************************************
extern "C" BOOL APIENTRY UiSelectProvider (SNETCAPSPTR mincaps,
SNETPROGRAMDATAPTR programdata,
SNETPLAYERDATAPTR playerdata,
SNETUIDATAPTR interfacedata,
SNETVERSIONDATAPTR versiondata,
DWORD *providerid);
extern "C" BOOL APIENTRY UiSelectGame (DWORD flags,
SNETPROGRAMDATAPTR programdata,
SNETPLAYERDATAPTR playerdata,
SNETUIDATAPTR interfacedata,
SNETVERSIONDATAPTR versiondata,
DWORD *playerid);
//***************************************************************************
//***************************************************************************
#define DEVNAME_LEN SNETSPI_MAXSTRINGLENGTH
#define DEVDESC_LEN SNETSPI_MAXSTRINGLENGTH
#define MAX_DIAL_LEN 32
enum _dialmodes {
MODE_ANSWER = (IDCANCEL + 1),
MODE_DIALOLD,
MODE_DIALNEW
};
typedef struct _modeminfo TMODEM;
typedef TMODEM *TPMODEM;
struct _modeminfo {
TPMODEM next;
DWORD deviceid;
TCHAR devicename[DEVNAME_LEN];
TCHAR devicedesc[DEVDESC_LEN];
};

BIN
src/DIABLOUI.LIB Normal file

Binary file not shown.

BIN
src/DIABLOUI.LSV Normal file

Binary file not shown.

BIN
src/DIABLO~1.BCE Normal file

Binary file not shown.

162
src/DOOM.CPP Normal file
View File

@ -0,0 +1,162 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Map of Doom file
**
** (C)1995 Condor, Inc. All rights reserved.
**
**-----------------------------------------------------------------------**
** $Header: /Diablo/DOOM.CPP 1 1/22/97 2:06p Dgartner $
**-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
#include "diablo.h"
#pragma hdrstop
#include "doom.h"
#include "engine.h"
#include "control.h"
#include "gendung.h"
/*-----------------------------------------------------------------------*
** Global Variables
**-----------------------------------------------------------------------*/
#define DOOM_NUMFRAMES 30
#define DOOM_ENDFRAME 31
#define DOOM_TICK 1200 // Every 20*60 (1 min) frames is next doom map cycle
#define DOOM_TOTAL (DOOM_NUMFRAMES*DOOM_TICK)+1
#define DOOM_ANIMSPD 5
bool drawmapofdoom = false;
static BYTE *pDoomCel = 0;
int doomtime = 0;
static int currdoom = 0;
static int animdoomdelay = 0;
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
void InitMapOfDoomTime()
{
if (doomtime > 0) return;
doomtime = 0;
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
void DoMapOfDoomTime()
{
if (doomtime < DOOM_TOTAL) {
doomtime++;
if (doomtime == DOOM_TOTAL) {
#if !IS_VERSION(SHAREWARE)
PlayInGameMovie("gendata\\doom.smk");
#endif
doomtime++;
}
}
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
int CheckMapOfDoomTime()
{
if (doomtime == DOOM_TOTAL) return(DOOM_ENDFRAME);
return(doomtime / DOOM_TICK);
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
void FreeDoomMem()
{
if (pDoomCel != NULL)
{
DiabloFreePtr(pDoomCel);
pDoomCel = NULL;
}
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
static bool GetDoomMem()
{
FreeDoomMem();
pDoomCel = DiabloAllocPtrSig((227 + 1) * 1024,'DOOM');
return (pDoomCel != 0);
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
static bool LoadDoomFrame()
{
bool result = false;
// if (currlevel < HIVESTART)
// {
// if (currdoom == DOOM_ENDFRAME) {
// strcpy(tempstr, "Items\\Map\\MapZDoom.CEL");
// }
// else if (currdoom < 10) {
// sprintf (tempstr, "Items\\Map\\MapZ000%i.CEL", currdoom);
// }
// else sprintf (tempstr, "Items\\Map\\MapZ00%i.CEL", currdoom);
// LoadFileWithMem(tempstr, pDoomCel);
// }
// else
{
strcpy(tempstr, "Items\\Map\\MapZtown.CEL");
if (LoadFileWithMem(tempstr, pDoomCel)) {
result = true;
}
}
return result;
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
void InitMapOfDoomView()
{
if (GetDoomMem()) {
if (CheckMapOfDoomTime() == DOOM_ENDFRAME) currdoom = DOOM_ENDFRAME;
else currdoom = 0;
if (LoadDoomFrame())
drawmapofdoom = true;
else
EndMapOfDoomView();
}
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
void EndMapOfDoomView()
{
//if (!drawmapofdoom) return;
drawmapofdoom = false;
FreeDoomMem();
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
void DrawMapOfDoom()
{
if (!drawmapofdoom) return;
// if (currdoom != DOOM_ENDFRAME) {
// animdoomdelay++;
// if (animdoomdelay >= DOOM_ANIMSPD) {
// animdoomdelay = 0;
// currdoom++;
// if (currdoom > CheckMapOfDoomTime()) currdoom = 0;
// LoadDoomFrame();
// }
// }
DrawCel(64, 511, pDoomCel, 1, 640);
}

26
src/DOOM.H Normal file
View File

@ -0,0 +1,26 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Constants and Variables
**
** (C)1995 Condor, Inc. All rights reserved.
**-----------------------------------------------------------------------**
** $Header: /Diablo/DOOM.H 1 1/22/97 2:06p Dgartner $
**-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------**
** externs
**-----------------------------------------------------------------------*/
extern bool drawmapofdoom;
extern int doomtime;
/*-----------------------------------------------------------------------**
** Prototypes
**-----------------------------------------------------------------------*/
void InitMapOfDoomTime();
void DoMapOfDoomTime();
void InitMapOfDoomView();
void EndMapOfDoomView();
void DrawMapOfDoom();

3564
src/DRLG_L1.CPP Normal file

File diff suppressed because it is too large Load Diff

135
src/DRLG_L1.H Normal file
View File

@ -0,0 +1,135 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Constants and Variables
**
** (C)1995 Condor, Inc. All rights reserved.
**-----------------------------------------------------------------------**
** $Header: /Diablo/DRLG_L1.H 1 1/22/97 2:06p Dgartner $
**-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------**
** Defines
**-----------------------------------------------------------------------*/
#define MAXCHRS 17
#define D_NULL 0 // Unused/empty space
#define D_VWALL 1 // Vertical wall
#define D_HWALL 2 // Horizontal wall
#define D_LRC 3 // Lower right corner
#define D_ULC 4 // Upper left corner
#define D_AULC 5 // Archway upper left corner
#define D_URC 6 // Upper right corner
#define D_LLC 7 // Lower left corner
#define D_AURC 8 // Archway upper right corner
#define D_ALLC 9 // Archway lower left corner
#define D_TULC1 10 // Transition piece #1 upper left corner
#define D_AVW 11 // Archway veritcal wall
#define D_AHW 12 // Archway horizontal wall
#define D_FLOOR 13 // Floor
#define D_TULC2 14 // Transition piece #2 upper left corner
#define D_COL 15 // Column
#define D_BCAP 16 // Bottom cap
#define D_RCAP 17 // Right cap
#define D_DV 18 // Dirt with vertical edge
#define D_DH 19 // Dirt with horizontal edge
#define D_DLRC 20 // Dirt lower right corner
#define D_DULC 21 // Dirt upper left corner
#define D_DIRT 22 // Normal Dirt piece
#define D_DURC 23 // Dirt upper right corner
#define D_DLLC 24 // Dirt lower left corener
#define D_DRV 25 // Door on a vertical wall
#define D_DRH 26 // Door on a horizontal wall
#define D_DDULC 28 // Double door upper left corner
#define D_DRURC 30 // Door on upper right corner
#define D_DRLLC 31 // Door on lower left corner
#define D_DRVT1 40 // Vertical door on transition 1
#define D_DRVULC 41 // Vertical door on upper left corner
#define D_DRHT2 42 // Horizontal door on transition 2
#define D_DRHULC 43 // Horizontal door on upper left corner
#define AREAMIN 4
#define AREAMAX 12
#define NODOOR 0x00 // No door flag
#define HDOOR 0x01 // Horizontal door
#define VDOOR 0x02 // Vertical door
#define DDOOR 0x03 // Double door (both dirs)
//#define SETP_BIT 0x80 // Non changeable set piece bit (defined in gendung.h)
#define SETP_MASK 0x7f
#define SETP_TEMP 0x40 // Temp non changeable set piece bit
#define SETP_TMASK 0xbf
#define NUMDPATS 9
#define NUMSPATS 37
#define _S1 139
#define _S2 140
#define _S3 141
#define _S4 142
#define _S5 143
#define _S6 144
#define _S7 145
#define _S8 146
#define _S9 147
#define _S10 148
#define _S11 149
#define _S12 150
#define _S13 151
#define _S14 152
#define _S15 153
#define _S16 154
#define _S17 155
#define _S18 156
#define _S19 157
#define NUMBLOCKS 206
#define NUMSETPIECES 4
#define NA_KRUL_LEVEL 24 // change to 24 for real game JKE
#define CORNERSTONE_LEVEL 21
/*-----------------------------------------------------------------------**
** Structures
**-----------------------------------------------------------------------*/
typedef struct {
int qpat;
int d1;
int d2;
int d3;
int d4;
} DPatsStruct;
//JKE
typedef struct
{
int x,y; //location of lower center door mini tile
BOOL Open; // is the place open?
BOOL Books; // were the books used to open?
int LeverX, LeverY;
BOOL Lever_Thrown;
int MIndex;
} Na_Krul_Struct;
extern Na_Krul_Struct Na_Krul;
/*-----------------------------------------------------------------------**
** Prototypes
**-----------------------------------------------------------------------*/
//void CreateL1Dungeon(unsigned int, int);
void LoadL1Dungeon(char [], int, int);
void LoadPreL1Dungeon(char [], int, int);
//void InitL1DirtQuads();
//void DRLG_L1FloodTVal();
byte L5TileType(int t);
void CreateL5Dungeon(unsigned int, int);

3050
src/DRLG_L2.CPP Normal file

File diff suppressed because it is too large Load Diff

109
src/DRLG_L2.H Normal file
View File

@ -0,0 +1,109 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Constants and Variables
**
** (C)1995 Condor, Inc. All rights reserved.
**-----------------------------------------------------------------------**
** $Header: /Diablo/DRLG_L2.H 1 1/22/97 2:06p Dgartner $
**-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------**
** Defines
**-----------------------------------------------------------------------*/
#define DIR_NONE 0
#define DIR_NORTH 1
#define DIR_EAST 2
#define DIR_SOUTH 3
#define DIR_WEST 4
#define AREA_MIN 2
#define MAX_DOORS 7
#define MAX_ROOMS 80
#define ROOM_MAX 10
#define ROOM_MIN 6
#define VWALL_PIECE 1
#define HWALL_PIECE 2
#define FLOOR_PIECE 3
#define VDOOR_PIECE 4
#define HDOOR_PIECE 5
#define LRWALL_PIECE 6
#define URWALL_PIECE 7
#define ULWALL_PIECE 8
#define LLWALL_PIECE 9
#define DVWALL_PIECE 10
#define DHWALL_PIECE 11
#define DFLOOR_PIECE 12
#define DULWALL_PIECE 13
#define DURWALL_PIECE 14
#define DLLWALL_PIECE 15
#define DLRWALL_PIECE 16
#define THEME_PIECE 252
#define NO_CHAR ' '
#define WALL_CHAR '#'
#define FLOOR_CHAR '.'
#define HALL_CHAR ','
#define DOOR_CHAR 'D'
#define LRWALL_CHAR 'A'
#define URWALL_CHAR 'B'
#define ULWALL_CHAR 'C'
#define LLWALL_CHAR 'E'
#define L2_NUMBLOCKS 161
#define L2_NUMSPATS 2
#define NOTOK 255
#define OK 254
#define CNO 0
#define CWALL 1
#define CFLOOR 2
#define CDOOR 3
#define CEMPTY 4
#define CDoF 5
#define CDoW 6
#define CEoF 7
#define CDoWoF 8
#define SNUM1 2
#define SNUM2 2
#define SETP_BIT 0x80 // Non changeable set piece bit
/*-----------------------------------------------------------------------**
** Structures
**-----------------------------------------------------------------------*/
typedef struct NODE {
int nHallx1;
int nHally1;
int nHallx2;
int nHally2;
int nHalldir;
struct NODE * pNext;
} HALLNODE;
typedef struct {
int nRoomx1;
int nRoomy1;
int nRoomx2;
int nRoomy2;
int nRoomDest;
} ROOMNODE;
/*-----------------------------------------------------------------------**
** Prototypes
**-----------------------------------------------------------------------*/
void CreateL2Dungeon(unsigned int, int);
void LoadL2Dungeon(char [], int, int);
void LoadPreL2Dungeon(char [], int, int);

2842
src/DRLG_L3.CPP Normal file

File diff suppressed because it is too large Load Diff

68
src/DRLG_L3.H Normal file
View File

@ -0,0 +1,68 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Constants and Variables
**
** (C)1995 Condor, Inc. All rights reserved.
**-----------------------------------------------------------------------**
** $Header: /Diablo/DRLG_L3.H 1 1/22/97 2:06p Dgartner $
**-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------**
** Defines
**-----------------------------------------------------------------------*/
#define BLK_U 0
#define BLK_R 1
#define BLK_D 2
#define BLK_L 3
#define L3_DIRT 8
//#define MINFAREA 1536
#define MINFAREA 600
#define FR_FALSE 0
#define FR_TRUE 1
#define UR_ISLE 14
#define LL_ISLE 13
#define LR_ISLE 12
#define UL_WALL 11
#define TOP_WALL 10
#define LEFT_WALL 9
#define FILL 8
#define FLOOR 7
#define LR_WALL 6
#define UL_ISLE 5
#define RIGHT_WALL 4
#define UR_WALL 3
#define BOTTOM_WALL 2
#define LL_WALL 1
#define D3_NULL 0
#define L3_NUMBLOCKS 124
#define NORTH 0
#define SOUTH 1
#define EAST 2
#define WEST 3
#define WOOD_HORIZWALL 134
#define WOOD_VERTWALL 137
#define WOOD_LRCORNER 138
#define WOOD_HORIZGATE 146
#define WOOD_VERTGATE 147
#define WOOD_ULCORNER 150
#define WOOD_URCORNER 151
#define WOOD_LLCORNER 152
/*-----------------------------------------------------------------------**
** Prototypes
**-----------------------------------------------------------------------*/
void CreateL3Dungeon(unsigned int, int);
void LoadPreL3Dungeon(char [], int, int);
void LoadL3Dungeon(char [], int, int);
int DRLG_L3Spawn(int, int, int *);
BOOL SkipThemeRoom( int x, int y );

1668
src/DRLG_L4.CPP Normal file

File diff suppressed because it is too large Load Diff

86
src/DRLG_L4.H Normal file
View File

@ -0,0 +1,86 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Constants and Variables
**
** (C)1995 Condor, Inc. All rights reserved.
**
**-----------------------------------------------------------------------**
** $Header: /Diablo/DRLG_L4.H 1 1/22/97 2:06p Dgartner $
**-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------**
** Defines
**-----------------------------------------------------------------------*/
#define L4DIR_HORIZ 0
#define L4DIR_VERT 1
#define L4ROOM_MIN 2
#define L4ROOM_MAX 6
#define L4DUNX 20
#define L4DUNY 20
#define L4MIN_AREA ((L4DUNX*L4DUNY)/3) + ((L4DUNX*L4DUNY)/10)
#define L4DX 80
#define L4DY 80
#define L4_DIRT 12
#define NUMBBLOCKS 140
// PIC == PIECE
#define VWALL_PIC 1
#define HWALL_PIC 2
#define LRWALL_PIC 12
#define FLOOR_PIC 6
#define URWALL_PIC 16
#define ULWALL_PIC 9
#define LLWALL_PIC 15
#define DVWALL_PIC 18
#define DHWALL_PIC 19
#define DFLOOR_PIC 20
#define DULWALL_PIC 21
#define DURWALL_PIC 25
#define DURWALL2_PIC 28
#define DURWALL3_PIC 23
#define DLLWALL_PIC 27
#define DLLWALL2_PIC 26
#define DLLWALL3_PIC 22
#define DLRWALL_PIC 24
#define DIRT_PIC 30
//Arches
#define YARCHWALL_PIC 53
#define XARCHWALL_PIC 57
#define NUMSPATS 37
#define _1S 47
#define _2S 48
#define _3S 49
#define _4S 50
#define _5S 51
#define _6S 54
#define _7S 55
#define _8S 58
#define _9S 59
#define _10S 60
/*-----------------------------------------------------------------------**
** externs
**-----------------------------------------------------------------------*/
extern int diabquad1x, diabquad2x, diabquad3x, diabquad4x;
extern int diabquad1y, diabquad2y, diabquad3y, diabquad4y;
/*-----------------------------------------------------------------------**
** Prototypes
**-----------------------------------------------------------------------*/
void CreateL4Dungeon(unsigned int, int);
//int DRLG_L4Spawn(int, int, int *);

605
src/DSOUND.H Normal file
View File

@ -0,0 +1,605 @@
/*==========================================================================;
*
* Copyright (C) 1995,1996 Microsoft Corporation. All Rights Reserved.
*
* File: dsound.h
* Content: DirectSound include file
*
***************************************************************************/
#ifndef __DSOUND_INCLUDED__
#define __DSOUND_INCLUDED__
#include "d3dtypes.h"
#ifdef _WIN32
#define COM_NO_WINDOWS_H
#include <objbase.h>
#endif
#define _FACDS 0x878
#define MAKE_DSHRESULT( code ) MAKE_HRESULT( 1, _FACDS, code )
#ifdef __cplusplus
extern "C" {
#endif
// Direct Sound Component GUID {47D4D946-62E8-11cf-93BC-444553540000}
DEFINE_GUID(CLSID_DirectSound,
0x47d4d946, 0x62e8, 0x11cf, 0x93, 0xbc, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0);
// DirectSound 279afa83-4981-11ce-a521-0020af0be560
DEFINE_GUID(IID_IDirectSound,0x279AFA83,0x4981,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60);
// DirectSoundBuffer 279afa85-4981-11ce-a521-0020af0be560
DEFINE_GUID(IID_IDirectSoundBuffer,0x279AFA85,0x4981,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60);
//DirectSound3DListener 279afa84-4981-11ce-a521-0020af0be560
DEFINE_GUID(IID_IDirectSound3DListener,0x279AFA84,0x4981,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60);
//DirectSound3DBuffer 279afa86-4981-11ce-a521-0020af0be560
DEFINE_GUID(IID_IDirectSound3DBuffer,0x279AFA86,0x4981,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60);
//==========================================================================;
//
// Structures...
//
//==========================================================================;
#ifdef __cplusplus
/* 'struct' not 'class' per the way DECLARE_INTERFACE_ is defined */
struct IDirectSound;
struct IDirectSoundBuffer;
struct IDirectSound3DListener;
struct IDirectSound3DBuffer;
#endif
typedef struct IDirectSound *LPDIRECTSOUND;
typedef struct IDirectSoundBuffer *LPDIRECTSOUNDBUFFER;
typedef struct IDirectSoundBuffer **LPLPDIRECTSOUNDBUFFER;
typedef struct IDirectSound3DListener *LPDIRECTSOUND3DLISTENER;
typedef struct IDirectSound3DBuffer *LPDIRECTSOUND3DBUFFER;
typedef struct _DSCAPS
{
DWORD dwSize;
DWORD dwFlags;
DWORD dwMinSecondarySampleRate;
DWORD dwMaxSecondarySampleRate;
DWORD dwPrimaryBuffers;
DWORD dwMaxHwMixingAllBuffers;
DWORD dwMaxHwMixingStaticBuffers;
DWORD dwMaxHwMixingStreamingBuffers;
DWORD dwFreeHwMixingAllBuffers;
DWORD dwFreeHwMixingStaticBuffers;
DWORD dwFreeHwMixingStreamingBuffers;
DWORD dwMaxHw3DAllBuffers;
DWORD dwMaxHw3DStaticBuffers;
DWORD dwMaxHw3DStreamingBuffers;
DWORD dwFreeHw3DAllBuffers;
DWORD dwFreeHw3DStaticBuffers;
DWORD dwFreeHw3DStreamingBuffers;
DWORD dwTotalHwMemBytes;
DWORD dwFreeHwMemBytes;
DWORD dwMaxContigFreeHwMemBytes;
DWORD dwUnlockTransferRateHwBuffers;
DWORD dwPlayCpuOverheadSwBuffers;
DWORD dwReserved1;
DWORD dwReserved2;
} DSCAPS, *LPDSCAPS;
typedef struct _DSBCAPS
{
DWORD dwSize;
DWORD dwFlags;
DWORD dwBufferBytes;
DWORD dwUnlockTransferRate;
DWORD dwPlayCpuOverhead;
} DSBCAPS, *LPDSBCAPS;
typedef struct _DSBUFFERDESC
{
DWORD dwSize;
DWORD dwFlags;
DWORD dwBufferBytes;
DWORD dwReserved;
LPWAVEFORMATEX lpwfxFormat;
} DSBUFFERDESC, *LPDSBUFFERDESC;
typedef struct _DS3DBUFFER
{
DWORD dwSize;
D3DVECTOR vPosition;
D3DVECTOR vVelocity;
DWORD dwInsideConeAngle;
DWORD dwOutsideConeAngle;
D3DVECTOR vConeOrientation;
LONG lConeOutsideVolume;
D3DVALUE flMinDistance;
D3DVALUE flMaxDistance;
DWORD dwMode;
} DS3DBUFFER, *LPDS3DBUFFER;
typedef struct _DS3DLISTENER
{
DWORD dwSize;
D3DVECTOR vPosition;
D3DVECTOR vVelocity;
D3DVECTOR vOrientFront;
D3DVECTOR vOrientTop;
D3DVALUE flDistanceFactor;
D3DVALUE flRolloffFactor;
D3DVALUE flDopplerFactor;
} DS3DLISTENER, *LPDS3DLISTENER;
typedef LPVOID* LPLPVOID;
typedef BOOL (FAR PASCAL * LPDSENUMCALLBACKW)(const GUID FAR *, LPWSTR, LPWSTR, LPVOID);
typedef BOOL (FAR PASCAL * LPDSENUMCALLBACKA)(const GUID FAR *, LPSTR, LPSTR, LPVOID);
extern HRESULT WINAPI DirectSoundCreate(const GUID * lpGUID, LPDIRECTSOUND * ppDS, IUnknown FAR *pUnkOuter );
extern HRESULT WINAPI DirectSoundEnumerateW(LPDSENUMCALLBACKW lpCallback, LPVOID lpContext );
extern HRESULT WINAPI DirectSoundEnumerateA(LPDSENUMCALLBACKA lpCallback, LPVOID lpContext );
#ifdef UNICODE
#define LPDSENUMCALLBACK LPDSENUMCALLBACKW
#define DirectSoundEnumerate DirectSoundEnumerateW
#else
#define LPDSENUMCALLBACK LPDSENUMCALLBACKA
#define DirectSoundEnumerate DirectSoundEnumerateA
#endif
//
// IDirectSound
//
#undef INTERFACE
#define INTERFACE IDirectSound
#ifdef _WIN32
DECLARE_INTERFACE_( IDirectSound, IUnknown )
{
/*** IUnknown methods ***/
STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
STDMETHOD_(ULONG,AddRef) (THIS) PURE;
STDMETHOD_(ULONG,Release) (THIS) PURE;
/*** IDirectSound methods ***/
STDMETHOD( CreateSoundBuffer)(THIS_ LPDSBUFFERDESC, LPLPDIRECTSOUNDBUFFER, IUnknown FAR *) PURE;
STDMETHOD( GetCaps)(THIS_ LPDSCAPS ) PURE;
STDMETHOD( DuplicateSoundBuffer)(THIS_ LPDIRECTSOUNDBUFFER, LPLPDIRECTSOUNDBUFFER ) PURE;
STDMETHOD( SetCooperativeLevel)(THIS_ HWND, DWORD ) PURE;
STDMETHOD( Compact)(THIS ) PURE;
STDMETHOD( GetSpeakerConfig)(THIS_ LPDWORD ) PURE;
STDMETHOD( SetSpeakerConfig)(THIS_ DWORD ) PURE;
STDMETHOD( Initialize)(THIS_ const GUID * ) PURE;
};
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirectSound_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDirectSound_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDirectSound_Release(p) (p)->lpVtbl->Release(p)
#define IDirectSound_CreateSoundBuffer(p,a,b,c) (p)->lpVtbl->CreateSoundBuffer(p,a,b,c)
#define IDirectSound_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a)
#define IDirectSound_DuplicateSoundBuffer(p,a,b) (p)->lpVtbl->DuplicateSoundBuffer(p,a,b)
#define IDirectSound_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b)
#define IDirectSound_Compact(p) (p)->lpVtbl->Compact(p)
#define IDirectSound_GetSpeakerConfig(p,a) (p)->lpVtbl->GetSpeakerConfig(p,a)
#define IDirectSound_SetSpeakerConfig(p,b) (p)->lpVtbl->SetSpeakerConfig(p,b)
#define IDirectSound_Initialize(p,a) (p)->lpVtbl->Initialize(p,a)
#else
#define IDirectSound_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
#define IDirectSound_AddRef(p) (p)->AddRef()
#define IDirectSound_Release(p) (p)->Release()
#define IDirectSound_CreateSoundBuffer(p,a,b,c) (p)->CreateSoundBuffer(a,b,c)
#define IDirectSound_GetCaps(p,a) (p)->GetCaps(a)
#define IDirectSound_DuplicateSoundBuffer(p,a,b) (p)->DuplicateSoundBuffer(a,b)
#define IDirectSound_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b)
#define IDirectSound_Compact(p) (p)->Compact()
#define IDirectSound_GetSpeakerConfig(p,a) (p)->GetSpeakerConfig(a)
#define IDirectSound_SetSpeakerConfig(p,b) (p)->SetSpeakerConfig(b)
#define IDirectSound_Initialize(p,a) (p)->Initialize(a)
#endif
#endif
//
// IDirectSoundBuffer
//
#undef INTERFACE
#define INTERFACE IDirectSoundBuffer
#ifdef _WIN32
DECLARE_INTERFACE_( IDirectSoundBuffer, IUnknown )
{
/*** IUnknown methods ***/
STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
STDMETHOD_(ULONG,AddRef) (THIS) PURE;
STDMETHOD_(ULONG,Release) (THIS) PURE;
/*** IDirectSoundBuffer methods ***/
STDMETHOD( GetCaps)(THIS_ LPDSBCAPS ) PURE;
STDMETHOD(GetCurrentPosition)(THIS_ LPDWORD,LPDWORD ) PURE;
STDMETHOD( GetFormat)(THIS_ LPWAVEFORMATEX, DWORD, LPDWORD ) PURE;
STDMETHOD( GetVolume)(THIS_ LPLONG ) PURE;
STDMETHOD( GetPan)(THIS_ LPLONG ) PURE;
STDMETHOD( GetFrequency)(THIS_ LPDWORD ) PURE;
STDMETHOD( GetStatus)(THIS_ LPDWORD ) PURE;
STDMETHOD( Initialize)(THIS_ LPDIRECTSOUND, LPDSBUFFERDESC ) PURE;
STDMETHOD( Lock)(THIS_ DWORD,DWORD,LPVOID,LPDWORD,LPVOID,LPDWORD,DWORD ) PURE;
STDMETHOD( Play)(THIS_ DWORD,DWORD,DWORD ) PURE;
STDMETHOD(SetCurrentPosition)(THIS_ DWORD ) PURE;
STDMETHOD( SetFormat)(THIS_ LPWAVEFORMATEX ) PURE;
STDMETHOD( SetVolume)(THIS_ LONG ) PURE;
STDMETHOD( SetPan)(THIS_ LONG ) PURE;
STDMETHOD( SetFrequency)(THIS_ DWORD ) PURE;
STDMETHOD( Stop)(THIS ) PURE;
STDMETHOD( Unlock)(THIS_ LPVOID,DWORD,LPVOID,DWORD ) PURE;
STDMETHOD( Restore)(THIS ) PURE;
};
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirectSoundBuffer_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDirectSoundBuffer_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDirectSoundBuffer_Release(p) (p)->lpVtbl->Release(p)
#define IDirectSoundBuffer_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a)
#define IDirectSoundBuffer_GetCurrentPosition(p,a,b) (p)->lpVtbl->GetCurrentPosition(p,a,b)
#define IDirectSoundBuffer_GetFormat(p,a,b,c) (p)->lpVtbl->GetFormat(p,a,b,c)
#define IDirectSoundBuffer_GetVolume(p,a) (p)->lpVtbl->GetVolume(p,a)
#define IDirectSoundBuffer_GetPan(p,a) (p)->lpVtbl->GetPan(p,a)
#define IDirectSoundBuffer_GetFrequency(p,a) (p)->lpVtbl->GetFrequency(p,a)
#define IDirectSoundBuffer_GetStatus(p,a) (p)->lpVtbl->GetStatus(p,a)
#define IDirectSoundBuffer_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b)
#define IDirectSoundBuffer_Lock(p,a,b,c,d,e,f,g) (p)->lpVtbl->Lock(p,a,b,c,d,e,f,g)
#define IDirectSoundBuffer_Play(p,a,b,c) (p)->lpVtbl->Play(p,a,b,c)
#define IDirectSoundBuffer_SetCurrentPosition(p,a) (p)->lpVtbl->SetCurrentPosition(p,a)
#define IDirectSoundBuffer_SetFormat(p,a) (p)->lpVtbl->SetFormat(p,a)
#define IDirectSoundBuffer_SetVolume(p,a) (p)->lpVtbl->SetVolume(p,a)
#define IDirectSoundBuffer_SetPan(p,a) (p)->lpVtbl->SetPan(p,a)
#define IDirectSoundBuffer_SetFrequency(p,a) (p)->lpVtbl->SetFrequency(p,a)
#define IDirectSoundBuffer_Stop(p) (p)->lpVtbl->Stop(p)
#define IDirectSoundBuffer_Unlock(p,a,b,c,d) (p)->lpVtbl->Unlock(p,a,b,c,d)
#define IDirectSoundBuffer_Restore(p) (p)->lpVtbl->Restore(p)
#else
#define IDirectSoundBuffer_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
#define IDirectSoundBuffer_AddRef(p) (p)->AddRef()
#define IDirectSoundBuffer_Release(p) (p)->Release()
#define IDirectSoundBuffer_GetCaps(p,a) (p)->GetCaps(a)
#define IDirectSoundBuffer_GetCurrentPosition(p,a,b) (p)->GetCurrentPosition(a,b)
#define IDirectSoundBuffer_GetFormat(p,a,b,c) (p)->GetFormat(a,b,c)
#define IDirectSoundBuffer_GetVolume(p,a) (p)->GetVolume(a)
#define IDirectSoundBuffer_GetPan(p,a) (p)->GetPan(a)
#define IDirectSoundBuffer_GetFrequency(p,a) (p)->GetFrequency(a)
#define IDirectSoundBuffer_GetStatus(p,a) (p)->GetStatus(a)
#define IDirectSoundBuffer_Initialize(p,a,b) (p)->Initialize(a,b)
#define IDirectSoundBuffer_Lock(p,a,b,c,d,e,f,g) (p)->Lock(a,b,c,d,e,f,g)
#define IDirectSoundBuffer_Play(p,a,b,c) (p)->Play(a,b,c)
#define IDirectSoundBuffer_SetCurrentPosition(p,a) (p)->SetCurrentPosition(a)
#define IDirectSoundBuffer_SetFormat(p,a) (p)->SetFormat(a)
#define IDirectSoundBuffer_SetVolume(p,a) (p)->SetVolume(a)
#define IDirectSoundBuffer_SetPan(p,a) (p)->SetPan(a)
#define IDirectSoundBuffer_SetFrequency(p,a) (p)->SetFrequency(a)
#define IDirectSoundBuffer_Stop(p) (p)->Stop()
#define IDirectSoundBuffer_Unlock(p,a,b,c,d) (p)->Unlock(a,b,c,d)
#define IDirectSoundBuffer_Restore(p) (p)->Restore()
#endif
#endif
//
// IDirectSound3DListener
//
#undef INTERFACE
#define INTERFACE IDirectSound3DListener
#ifdef _WIN32
DECLARE_INTERFACE_(IDirectSound3DListener, IUnknown)
{
/*** IUnknown methods ***/
STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
STDMETHOD_(ULONG,AddRef) (THIS) PURE;
STDMETHOD_(ULONG,Release) (THIS) PURE;
/*** IDirectSound3D methods ***/
STDMETHOD(GetAllParameters)(THIS_ LPDS3DLISTENER) PURE;
STDMETHOD(GetDistanceFactor)(THIS_ LPD3DVALUE) PURE;
STDMETHOD(GetDopplerFactor)(THIS_ LPD3DVALUE) PURE;
STDMETHOD(GetOrientation)(THIS_ LPD3DVECTOR, LPD3DVECTOR) PURE;
STDMETHOD(GetPosition)(THIS_ LPD3DVECTOR) PURE;
STDMETHOD(GetRolloffFactor)(THIS_ LPD3DVALUE ) PURE;
STDMETHOD(GetVelocity)(THIS_ LPD3DVECTOR) PURE;
STDMETHOD(SetAllParameters)(THIS_ LPDS3DLISTENER, DWORD) PURE;
STDMETHOD(SetDistanceFactor)(THIS_ D3DVALUE, DWORD) PURE;
STDMETHOD(SetDopplerFactor)(THIS_ D3DVALUE, DWORD) PURE;
STDMETHOD(SetOrientation)(THIS_ D3DVALUE, D3DVALUE, D3DVALUE, D3DVALUE, D3DVALUE, D3DVALUE, DWORD) PURE;
STDMETHOD(SetPosition)(THIS_ D3DVALUE, D3DVALUE, D3DVALUE, DWORD) PURE;
STDMETHOD(SetRolloffFactor)(THIS_ D3DVALUE, DWORD) PURE;
STDMETHOD(SetVelocity)(THIS_ D3DVALUE, D3DVALUE, D3DVALUE, DWORD) PURE;
STDMETHOD(CommitDeferredSettings)(THIS) PURE;
};
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirectSound3DListener_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDirectSound3DListener_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDirectSound3DListener_Release(p) (p)->lpVtbl->Release(p)
#define IDirectSound3DListener_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a)
#define IDirectSound3DListener_GetDistanceFactor(p,a) (p)->lpVtbl->GetDistanceFactor(p,a)
#define IDirectSound3DListener_GetDopplerFactor(p,a) (p)->lpVtbl->GetDopplerFactor(p,a)
#define IDirectSound3DListener_GetOrientation(p,a,b) (p)->lpVtbl->GetOrientation(p,a,b)
#define IDirectSound3DListener_GetPosition(p,a) (p)->lpVtbl->GetPosition(p,a)
#define IDirectSound3DListener_GetRolloffFactor(p,a) (p)->lpVtbl->GetRolloffFactor(p,a)
#define IDirectSound3DListener_GetVelocity(p,a) (p)->lpVtbl->GetVelocity(p,a)
#define IDirectSound3DListener_SetAllParameters(p,a,b) (p)->lpVtbl->SetAllParameters(p,a,b)
#define IDirectSound3DListener_SetDistanceFactor(p,a,b) (p)->lpVtbl->SetDistanceFactor(p,a,b)
#define IDirectSound3DListener_SetDopplerFactor(p,a,b) (p)->lpVtbl->SetDopplerFactor(p,a,b)
#define IDirectSound3DListener_SetOrientation(p,a,b,c,d,e,f,g) (p)->lpVtbl->SetOrientation(p,a,b,c,d,e,f,g)
#define IDirectSound3DListener_SetPosition(p,a,b,c,d) (p)->lpVtbl->SetPosition(p,a,b,c,d)
#define IDirectSound3DListener_SetRolloffFactor(p,a,b) (p)->lpVtbl->SetRolloffFactor(p,a,b)
#define IDirectSound3DListener_SetVelocity(p,a,b,c,d) (p)->lpVtbl->SetVelocity(p,a,b,c,d)
#define IDirectSound3DListener_CommitDeferredSettings(p) (p)->lpVtbl->CommitDeferredSettings(p)
#else
#define IDirectSound3DListener_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
#define IDirectSound3DListener_AddRef(p) (p)->AddRef()
#define IDirectSound3DListener_Release(p) (p)->Release()
#define IDirectSound3DListener_GetAllParameters(p,a) (p)->GetAllParameters(a)
#define IDirectSound3DListener_GetDistanceFactor(p,a) (p)->GetDistanceFactor(a)
#define IDirectSound3DListener_GetDopplerFactor(p,a) (p)->GetDopplerFactor(a)
#define IDirectSound3DListener_GetOrientation(p,a,b) (p)->GetOrientation(a,b)
#define IDirectSound3DListener_GetPosition(p,a) (p)->GetPosition(a)
#define IDirectSound3DListener_GetRolloffFactor(p,a) (p)->GetRolloffFactor(a)
#define IDirectSound3DListener_GetVelocity(p,a) (p)->GetVelocity(a)
#define IDirectSound3DListener_SetAllParameters(p,a,b) (p)->SetAllParameters(a,b)
#define IDirectSound3DListener_SetDistanceFactor(p,a,b) (p)->SetDistanceFactor(a,b)
#define IDirectSound3DListener_SetDopplerFactor(p,a,b) (p)->SetDopplerFactor(a,b)
#define IDirectSound3DListener_SetOrientation(p,a,b,c,d,e,f,g) (p)->SetOrientation(a,b,c,d,e,f,g)
#define IDirectSound3DListener_SetPosition(p,a,b,c,d) (p)->SetPosition(a,b,c,d)
#define IDirectSound3DListener_SetRolloffFactor(p,a,b) (p)->SetRolloffFactor(a,b)
#define IDirectSound3DListener_SetVelocity(p,a,b,c,d) (p)->SetVelocity(a,b,c,d)
#define IDirectSound3DListener_CommitDeferredSettings(p) (p)->CommitDeferredSettings()
#endif
#endif
//
// IDirectSound3DBuffer
//
#undef INTERFACE
#define INTERFACE IDirectSound3DBuffer
#ifdef _WIN32
DECLARE_INTERFACE_(IDirectSound3DBuffer, IUnknown)
{
/*** IUnknown methods ***/
STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
STDMETHOD_(ULONG,AddRef) (THIS) PURE;
STDMETHOD_(ULONG,Release) (THIS) PURE;
/*** IDirectSoundBuffer3D methods ***/
STDMETHOD(GetAllParameters)(THIS_ LPDS3DBUFFER) PURE;
STDMETHOD(GetConeAngles)(THIS_ LPDWORD, LPDWORD) PURE;
STDMETHOD(GetConeOrientation)(THIS_ LPD3DVECTOR) PURE;
STDMETHOD(GetConeOutsideVolume)(THIS_ LPLONG) PURE;
STDMETHOD(GetMaxDistance)(THIS_ LPD3DVALUE) PURE;
STDMETHOD(GetMinDistance)(THIS_ LPD3DVALUE) PURE;
STDMETHOD(GetMode)(THIS_ LPDWORD) PURE;
STDMETHOD(GetPosition)(THIS_ LPD3DVECTOR) PURE;
STDMETHOD(GetVelocity)(THIS_ LPD3DVECTOR) PURE;
STDMETHOD(SetAllParameters)(THIS_ LPDS3DBUFFER, DWORD) PURE;
STDMETHOD(SetConeAngles)(THIS_ DWORD, DWORD, DWORD) PURE;
STDMETHOD(SetConeOrientation)(THIS_ D3DVALUE, D3DVALUE, D3DVALUE, DWORD) PURE;
STDMETHOD(SetConeOutsideVolume)(THIS_ LONG, DWORD) PURE;
STDMETHOD(SetMaxDistance)(THIS_ D3DVALUE, DWORD) PURE;
STDMETHOD(SetMinDistance)(THIS_ D3DVALUE, DWORD) PURE;
STDMETHOD(SetMode)(THIS_ DWORD, DWORD) PURE;
STDMETHOD(SetPosition)(THIS_ D3DVALUE, D3DVALUE, D3DVALUE, DWORD) PURE;
STDMETHOD(SetVelocity)(THIS_ D3DVALUE, D3DVALUE, D3DVALUE, DWORD) PURE;
};
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirectSound3DBuffer_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDirectSound3DBuffer_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDirectSound3DBuffer_Release(p) (p)->lpVtbl->Release(p)
#define IDirectSound3DBuffer_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a)
#define IDirectSound3DBuffer_GetConeAngles(p,a,b) (p)->lpVtbl->GetConeAngles(p,a,b)
#define IDirectSound3DBuffer_GetConeOrientation(p,a) (p)->lpVtbl->GetConeOrientation(p,a)
#define IDirectSound3DBuffer_GetConeOutsideVolume(p,a) (p)->lpVtbl->GetConeOutsideVolume(p,a)
#define IDirectSound3DBuffer_GetPosition(p,a) (p)->lpVtbl->GetPosition(p,a)
#define IDirectSound3DBuffer_GetMinDistance(p,a) (p)->lpVtbl->GetMinDistance(p,a)
#define IDirectSound3DBuffer_GetMaxDistance(p,a) (p)->lpVtbl->GetMaxDistance(p,a)
#define IDirectSound3DBuffer_GetMode(p,a) (p)->lpVtbl->GetMode(p,a)
#define IDirectSound3DBuffer_GetVelocity(p,a) (p)->lpVtbl->GetVelocity(p,a)
#define IDirectSound3DBuffer_SetAllParameters(p,a,b) (p)->lpVtbl->SetAllParameters(p,a,b)
#define IDirectSound3DBuffer_SetConeAngles(p,a,b,c) (p)->lpVtbl->SetConeAngles(p,a,b,c)
#define IDirectSound3DBuffer_SetConeOrientation(p,a,b,c,d) (p)->lpVtbl->SetConeOrientation(p,a,b,c,d)
#define IDirectSound3DBuffer_SetConeOutsideVolume(p,a,b)(p)->lpVtbl->SetConeOutsideVolume(p,a,b)
#define IDirectSound3DBuffer_SetPosition(p,a,b,c,d) (p)->lpVtbl->SetPosition(p,a,b,c,d)
#define IDirectSound3DBuffer_SetMinDistance(p,a,b) (p)->lpVtbl->SetMinDistance(p,a,b)
#define IDirectSound3DBuffer_SetMaxDistance(p,a,b) (p)->lpVtbl->SetMaxDistance(p,a,b)
#define IDirectSound3DBuffer_SetMode(p,a,b) (p)->lpVtbl->SetMode(p,a,b)
#define IDirectSound3DBuffer_SetVelocity(p,a,b,c,d) (p)->lpVtbl->SetVelocity(p,a,b,c,d)
#else
#define IDirectSound3DBuffer_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
#define IDirectSound3DBuffer_AddRef(p) (p)->AddRef()
#define IDirectSound3DBuffer_Release(p) (p)->Release()
#define IDirectSound3DBuffer_GetAllParameters(p,a) (p)->GetAllParameters(a)
#define IDirectSound3DBuffer_GetConeAngles(p,a,b) (p)->GetConeAngles(a,b)
#define IDirectSound3DBuffer_GetConeOrientation(p,a) (p)->GetConeOrientation(a)
#define IDirectSound3DBuffer_GetConeOutsideVolume(p,a) (p)->GetConeOutsideVolume(a)
#define IDirectSound3DBuffer_GetPosition(p,a) (p)->GetPosition(a)
#define IDirectSound3DBuffer_GetMinDistance(p,a) (p)->GetMinDistance(a)
#define IDirectSound3DBuffer_GetMaxDistance(p,a) (p)->GetMaxDistance(a)
#define IDirectSound3DBuffer_GetMode(p,a) (p)->GetMode(a)
#define IDirectSound3DBuffer_GetVelocity(p,a) (p)->GetVelocity(a)
#define IDirectSound3DBuffer_SetAllParameters(p,a,b) (p)->SetAllParameters(a,b)
#define IDirectSound3DBuffer_SetConeAngles(p,a,b,c) (p)->SetConeAngles(a,b,c)
#define IDirectSound3DBuffer_SetConeOrientation(p,a,b,c,d) (p)->SetConeOrientation(a,b,c,d)
#define IDirectSound3DBuffer_SetConeOutsideVolume(p,a,b)(p)->SetConeOutsideVolume(a,b)
#define IDirectSound3DBuffer_SetPosition(p,a,b,c,d) (p)->SetPosition(a,b,c,d)
#define IDirectSound3DBuffer_SetMinDistance(p,a,b) (p)->SetMinDistance(a,b)
#define IDirectSound3DBuffer_SetMaxDistance(p,a,b) (p)->SetMaxDistance(a,b)
#define IDirectSound3DBuffer_SetMode(p,a,b) (p)->SetMode(a,b)
#define IDirectSound3DBuffer_SetVelocity(p,a,b,c,d) (p)->SetVelocity(a,b,c,d)
#endif
#endif
/*
* Return Codes
*/
#define DS_OK 0
/*
* The call failed because resources (such as a priority level)
* were already being used by another caller.
*/
#define DSERR_ALLOCATED MAKE_DSHRESULT( 10 )
/*
* The control (vol,pan,etc.) requested by the caller is not available.
*/
#define DSERR_CONTROLUNAVAIL MAKE_DSHRESULT( 30 )
/*
* An invalid parameter was passed to the returning function
*/
#define DSERR_INVALIDPARAM E_INVALIDARG
/*
* This call is not valid for the current state of this object
*/
#define DSERR_INVALIDCALL MAKE_DSHRESULT( 50 )
/*
* An undetermined error occured inside the DSound subsystem
*/
#define DSERR_GENERIC E_FAIL
/*
* The caller does not have the priority level required for the function to
* succeed.
*/
#define DSERR_PRIOLEVELNEEDED MAKE_DSHRESULT( 70 )
/*
* The DSound subsystem couldn't allocate sufficient memory to complete the
* caller's request.
*/
#define DSERR_OUTOFMEMORY E_OUTOFMEMORY
/*
* The specified WAVE format is not supported
*/
#define DSERR_BADFORMAT MAKE_DSHRESULT( 100 )
/*
* The function called is not supported at this time
*/
#define DSERR_UNSUPPORTED E_NOTIMPL
/*
* No sound driver is available for use
*/
#define DSERR_NODRIVER MAKE_DSHRESULT( 120 )
/*
* This object is already initialized
*/
#define DSERR_ALREADYINITIALIZED MAKE_DSHRESULT( 130 )
/*
* This object does not support aggregation
*/
#define DSERR_NOAGGREGATION CLASS_E_NOAGGREGATION
/*
* The buffer memory has been lost, and must be Restored.
*/
#define DSERR_BUFFERLOST MAKE_DSHRESULT( 150 )
/*
* Another app has a higher priority level, preventing this call from
* succeeding.
*/
#define DSERR_OTHERAPPHASPRIO MAKE_DSHRESULT( 160 )
/*
* The Initialize() member on the Direct Sound Object has not been
* called or called successfully before calls to other members.
*/
#define DSERR_UNINITIALIZED MAKE_DSHRESULT( 170 )
//==========================================================================;
//
// Flags...
//
//==========================================================================;
#define DSCAPS_PRIMARYMONO 0x00000001
#define DSCAPS_PRIMARYSTEREO 0x00000002
#define DSCAPS_PRIMARY8BIT 0x00000004
#define DSCAPS_PRIMARY16BIT 0x00000008
#define DSCAPS_CONTINUOUSRATE 0x00000010
#define DSCAPS_EMULDRIVER 0x00000020
#define DSCAPS_CERTIFIED 0x00000040
#define DSCAPS_SECONDARYMONO 0x00000100
#define DSCAPS_SECONDARYSTEREO 0x00000200
#define DSCAPS_SECONDARY8BIT 0x00000400
#define DSCAPS_SECONDARY16BIT 0x00000800
#define DSBPLAY_LOOPING 0x00000001
#define DSBSTATUS_PLAYING 0x00000001
#define DSBSTATUS_BUFFERLOST 0x00000002
#define DSBSTATUS_LOOPING 0x00000004
#define DSBLOCK_FROMWRITECURSOR 0x00000001
#define DSSCL_NORMAL 1
#define DSSCL_PRIORITY 2
#define DSSCL_EXCLUSIVE 3
#define DSSCL_WRITEPRIMARY 4
// flags for IDirectSound3DBuffer::SetMode
#define DS3DMODE_NORMAL 0 // default must be 0
#define DS3DMODE_HEADRELATIVE 1
#define DS3DMODE_DISABLE 2
// flags for dwApply parameter of some 3D functions
#define DS3D_IMMEDIATE 0
#define DS3D_DEFERRED 1
// default values for 3d factors
#define DS3D_DEFAULTDISTANCEFACTOR 1.0f
#define DS3D_DEFAULTROLLOFFFACTOR 1.0f
#define DS3D_DEFAULTDOPPLERFACTOR 1.0f
#define DSBCAPS_PRIMARYBUFFER 0x00000001
#define DSBCAPS_STATIC 0x00000002
#define DSBCAPS_LOCHARDWARE 0x00000004
#define DSBCAPS_LOCSOFTWARE 0x00000008
#define DSBCAPS_CTRL3D 0x00000010
#define DSBCAPS_CTRLFREQUENCY 0x00000020
#define DSBCAPS_CTRLPAN 0x00000040
#define DSBCAPS_CTRLVOLUME 0x00000080
#define DSBCAPS_CTRLDEFAULT 0x000000E0 // Pan + volume + frequency.
#define DSBCAPS_CTRLALL 0x000000F0 // All control capabilities
#define DSBCAPS_STICKYFOCUS 0x00004000
#define DSBCAPS_GLOBALFOCUS 0x00008000
#define DSBCAPS_GETCURRENTPOSITION2 0x00010000 // More accurate play cursor under emulation
#define DSSPEAKER_HEADPHONE 1
#define DSSPEAKER_MONO 2
#define DSSPEAKER_QUAD 3
#define DSSPEAKER_STEREO 4
#define DSSPEAKER_SURROUND 5
#ifdef __cplusplus
};
#endif
#endif /* __DSOUND_INCLUDED__ */

BIN
src/DSOUND.LIB Normal file

Binary file not shown.

214
src/DTHREAD.CPP Normal file
View File

@ -0,0 +1,214 @@
//******************************************************************
// dthread.cpp
//******************************************************************
#include "diablo.h"
#pragma hdrstop
#include <process.h>
#include "msg.h"
#include "multi.h"
#include "gendung.h"
#include "sound.h"
#include "storm.h"
#include "items.h"
#include "player.h"
#include "engine.h"
//******************************************************************
// extern
//******************************************************************
extern DWORD gdwDeltaBytesSec;
void SendPlayerInfoChunk(int pnum,BYTE bCmd,const BYTE * pbSrc,DWORD dwLen);
//******************************************************************
// private
//******************************************************************
typedef struct TInfo {
struct TInfo * pNext;
int pnum;
BYTE bCmd;
DWORD dwLen;
BYTE bData[1];
} TInfo;
// linked list and critical section to protect it
static TInfo * sgpInfoHead;
static CCritSect sgInfoCrit;
// thread and synchronization objects
static BYTE sgbRunThread = FALSE;
static HANDLE sghThread = INVALID_HANDLE_VALUE;
static HANDLE sghWorkToDoEvent = NULL;
static unsigned sgThreadID;
//******************************************************************
//******************************************************************
static unsigned __stdcall dthread_proc(void *) {
TInfo * pInfo;
while (sgbRunThread) {
// sleep until there is work to do
if (! sgpInfoHead && WAIT_FAILED == WaitForSingleObject(sghWorkToDoEvent,INFINITE))
app_fatal(TEXT("dthread4:\n%s"),strGetLastError());
// pull one item off the list
sgInfoCrit.Enter();
pInfo = sgpInfoHead;
if (sgpInfoHead) sgpInfoHead = sgpInfoHead->pNext;
else ResetEvent(sghWorkToDoEvent);
sgInfoCrit.Leave();
if (! pInfo) continue;
// send the item if it still has a valid destination
if (pInfo->pnum != MAX_PLRS) {
SendPlayerInfoChunk(
pInfo->pnum,
pInfo->bCmd,
&pInfo->bData[0],
pInfo->dwLen
);
}
// (bytes * 1000 ms/sec) / (bytes/sec) = ms sleep time
app_assert(gdwDeltaBytesSec);
DWORD dwSleepTime = pInfo->dwLen * 1000 / gdwDeltaBytesSec;
dwSleepTime = min(dwSleepTime,1);
// free item
DiabloFreePtr(pInfo);
// wait for output queue to empty before sending again
if (dwSleepTime) Sleep(dwSleepTime);
// pjw.patch2.start
#if CHEATS
static DWORD sdwSkips = 0;
sdwSkips++;
HDC hDC;
HRESULT ddr = lpDDSPrimary->GetDC(&hDC);
if (ddr == DD_OK) {
char szBuf[16];
wsprintf(szBuf,"d:%u",sdwSkips);
TextOut(hDC,5,460,szBuf,strlen(szBuf));
lpDDSPrimary->ReleaseDC(hDC);
}
#endif
// pjw.patch2.end
}
return 0;
}
//******************************************************************
//******************************************************************
void dthread_remove_player(int pnum) {
sgInfoCrit.Enter();
for (TInfo * pInfo = sgpInfoHead; pInfo; pInfo = pInfo->pNext)
if (pInfo->pnum == pnum) pInfo->pnum = MAX_PLRS;
sgInfoCrit.Leave();
}
//******************************************************************
//******************************************************************
void dthread_SendPlayerInfoChunk(int pnum,BYTE bCmd,const BYTE * pbSrc,DWORD dwLen) {
// pjw.patch2.start
// app_assert((DWORD) pnum < MAX_PLRS);
if (gbMaxPlayers == 1) return;
// pjw.patch2.end
app_assert(pnum != myplr);
app_assert(pbSrc);
app_assert(dwLen);
// create a block of memory for the player info
TInfo * pInfo = (TInfo *) DiabloAllocPtrSig(sizeof(TInfo) + dwLen,'DLTA');
pInfo->pNext = NULL;
pInfo->pnum = pnum;
pInfo->bCmd = bCmd;
pInfo->dwLen = dwLen;
CopyMemory(pInfo->bData,pbSrc,dwLen);
// link to tail of list
sgInfoCrit.Enter();
TInfo ** ppInfo = &sgpInfoHead;
while (*ppInfo) ppInfo = &(*ppInfo)->pNext;
*ppInfo = pInfo;
// wake up thread if necessary -- inside crit section
SetEvent(sghWorkToDoEvent);
sgInfoCrit.Leave();
}
//******************************************************************
//******************************************************************
void dthread_init() {
// we don't have to send delta info in single
// player mode, so don't bother initializing thread
app_assert(sghThread == INVALID_HANDLE_VALUE);
if (gbMaxPlayers == 1) return;
// make sure linked list is properly initialized
app_assert(! sgpInfoHead);
// create synchronization object for thread
app_assert(! sghWorkToDoEvent);
if (NULL == (sghWorkToDoEvent = CreateEvent(
NULL, // security info
TRUE, // manual reset
FALSE, // initial state
NULL // name
))) app_fatal("dthread:1\n%s",strGetLastError());
// create worker thread
sgbRunThread = TRUE;
app_assert(sghThread == INVALID_HANDLE_VALUE);
if (INVALID_HANDLE_VALUE == (sghThread = (HANDLE) _beginthreadex(
NULL, // no security info
0, // stack size
dthread_proc, // start address
NULL, // argument list
0, // initial state
&sgThreadID // sgThreadID
))) app_fatal(TEXT("dthread2:\n%s"),strGetLastError());
}
//******************************************************************
//******************************************************************
void dthread_free() {
// if the event was never initialized, the thread cannot be running
if (! sghWorkToDoEvent) return;
// kill off the loader thread
sgbRunThread = FALSE;
SetEvent(sghWorkToDoEvent);
// wait til the thread is done
if (sghThread != INVALID_HANDLE_VALUE) {
if (sgThreadID != GetCurrentThreadId()) {
if (WAIT_FAILED == WaitForSingleObject(sghThread,INFINITE))
app_fatal("dthread3:\n(%s)",strGetLastError());
CloseHandle(sghThread);
sghThread = INVALID_HANDLE_VALUE;
}
}
// clean up event
CloseHandle(sghWorkToDoEvent);
sghWorkToDoEvent = NULL;
// clean up linked list
while (sgpInfoHead) {
TInfo * pNext = sgpInfoHead->pNext;
DiabloFreePtr(sgpInfoHead);
sgpInfoHead = pNext;
}
}

371
src/DX.CPP Normal file
View File

@ -0,0 +1,371 @@
//******************************************************************
// dx.cpp
//******************************************************************
#include "diablo.h"
#pragma hdrstop
#include "storm.h"
#include "palette.h"
#include "engine.h"
#include "resource.h"
#include "gendung.h"
//******************************************************************
// extern
//******************************************************************
void myDebugBreak();
void ErrorDlg(int nDlgId,DWORD dwErr,const char * pszFile,int nLine);
//******************************************************************
// public
//******************************************************************
BYTE * gpBuffer;
LPDIRECTDRAW lpDD; // DirectDraw object
LPDIRECTDRAWSURFACE lpDDSPrimary; // DirectDraw primary surface
LPDIRECTDRAWSURFACE lpDDSBackBuf; // optional back buffer
LPDIRECTDRAWPALETTE lpDDPal; // DirectDraw palette
BYTE gbForceBackBuf = FALSE;
BYTE gbUseDDEmulation = FALSE;
//******************************************************************
// private
//******************************************************************
static DWORD sgdwLockCount;
static CCritSect sgDrawCrit;
static BYTE * sgpBackBuf;
static HINSTANCE sghDDlib = NULL;
#ifndef NDEBUG
static DWORD sgdwLockTbl[256];
#endif
//******************************************************************
//******************************************************************
static void init_backbuf() {
app_assert(! gpBuffer);
app_assert(! sgdwLockCount);
app_assert(! sgpBackBuf);
// can we lock the primary surface?
DDSCAPS caps;
DDSURFACEDESC ddsd;
app_assert(lpDDSPrimary);
HRESULT ddrval = lpDDSPrimary->GetCaps(&caps);
ddraw_assert(ddrval);
app_assert(caps.dwCaps & DDSCAPS_PRIMARYSURFACE);
// is this a lockable surface?
extern BYTE gbForceBackBuf;
if (! gbForceBackBuf) {
ddsd.dwSize = sizeof(ddsd);
ddrval = lpDDSPrimary->Lock(NULL,&ddsd,DDLOCK_WAIT|DDLOCK_WRITEONLY,NULL);
if (ddrval == DD_OK) {
ddrval = lpDDSPrimary->Unlock(NULL);
// pjw.patch1.start.1/13/97
// commented out -- in NT it is possible to
// lose a video surface while it is locked
// ddraw_assert(ddrval);
// pjw.patch1.end.1/13/97
// surface is lockable, just create an offscreen memory buffer
sgpBackBuf = DiabloAllocPtrSig(BUFFERSIZE,'OFFS');
return;
}
// non-lockable surface?
if (ddrval != DDERR_CANTLOCKSURFACE)
ErrorDlg(IDD_DDRAW_ERR,ddrval,__FILE__,__LINE__);
}
// create a secondary surface and lock it permanently
ZeroMemory(&ddsd,sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH|DDSD_PITCH|DDSD_PIXELFORMAT;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
ddsd.dwHeight = BUFFERY;
ddsd.dwWidth = BUFFERX;
ddsd.lPitch = BUFFERX;
ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
ddrval = lpDDSPrimary->GetPixelFormat(&ddsd.ddpfPixelFormat);
if (ddrval != DD_OK) ErrorDlg(IDD_DDRAW_ERR,ddrval,__FILE__,__LINE__);
ddrval = lpDD->CreateSurface(&ddsd,&lpDDSBackBuf,NULL);
if (ddrval != DD_OK) ErrorDlg(IDD_DDRAW_ERR,ddrval,__FILE__,__LINE__);
}
//******************************************************************
//******************************************************************
static void init_primary() {
DDSURFACEDESC ddsd;
ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
HRESULT ddrval = lpDD->CreateSurface(&ddsd, &lpDDSPrimary, NULL);
if (ddrval != DD_OK) ErrorDlg(IDD_DDRAW_ERR,ddrval,__FILE__,__LINE__);
}
//******************************************************************
//******************************************************************
static HRESULT InDirectDrawCreate(
GUID * lpGUID,
LPDIRECTDRAW * lplpDD,
IUnknown * pUnkOuter
) {
// load direct draw library
if (! sghDDlib) sghDDlib = LoadLibrary(TEXT("ddraw.dll"));
if (! sghDDlib) ErrorDlg(IDD_DDRAW_DLL_ERR,GetLastError(),__FILE__,__LINE__);
// bind to DirectDrawCreate
typedef HRESULT (WINAPI * DDCREATETYPE)(GUID *,LPDIRECTDRAW *,IUnknown *);
DDCREATETYPE ddcreatefunc = (DDCREATETYPE) GetProcAddress(sghDDlib,TEXT("DirectDrawCreate"));
if (! ddcreatefunc) ErrorDlg(IDD_DDRAW_DLL_ERR,GetLastError(),__FILE__,__LINE__);
// call DirectDrawCreate
return ddcreatefunc(lpGUID,lplpDD,pUnkOuter);
}
//******************************************************************
//******************************************************************
void init_directx(HWND hWnd) {
HRESULT ddrval;
app_assert(! gpBuffer);
app_assert(! sgdwLockCount);
app_assert(! sgpBackBuf);
SetFocus(hWnd);
ShowWindow(hWnd,SW_SHOWNORMAL);
extern BYTE gbUseDDEmulation;
GUID * lpGUID = NULL;
if (gbUseDDEmulation) lpGUID = (GUID *) DDCREATE_EMULATIONONLY;
ddrval = InDirectDrawCreate(lpGUID,&lpDD,NULL);
if (ddrval != DD_OK) ErrorDlg(IDD_DDRAW_ERR,ddrval,__FILE__,__LINE__);
#if !ALLOW_WINDOWED_MODE
fullscreen = TRUE;
#endif
#if ALLOW_WINDOWED_MODE
if (!fullscreen) {
ddrval = lpDD->SetCooperativeLevel(hWnd,DDSCL_NORMAL | DDSCL_ALLOWREBOOT);
if (ddrval == DDERR_EXCLUSIVEMODEALREADYSET) myDebugBreak();
else if (ddrval != DD_OK) ErrorDlg(IDD_DDRAW_ERR,ddrval,__FILE__,__LINE__);
// turn off "topmost" flag so that we don't stick above debugger
SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0,
SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
}
else {
#endif
// Get exclusive mode
ddrval = lpDD->SetCooperativeLevel(hWnd,DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_ALLOWREBOOT);
if (ddrval == DDERR_EXCLUSIVEMODEALREADYSET) myDebugBreak();
else if (ddrval != DD_OK) ErrorDlg(IDD_DDRAW_ERR,ddrval,__FILE__,__LINE__);
// Set the video mode to 640x480x8
ddrval = lpDD->SetDisplayMode( 640, 480, 8);
// pjw.patch1.start.1/13/97
// some notebook computers can't switch resolutions -- but
// we should be able to switch the color depth to 256 ???
if (ddrval != DD_OK) {
int nWdt = GetSystemMetrics(SM_CXSCREEN);
int nHgt = GetSystemMetrics(SM_CYSCREEN);
ddrval = lpDD->SetDisplayMode(nWdt, nHgt, 8);
}
// pjw.patch1.end.1/13/97
if (ddrval != DD_OK) ErrorDlg(IDD_DDRAW_ERR,ddrval,__FILE__,__LINE__);
#if ALLOW_WINDOWED_MODE
}
#endif
init_primary();
CreatePalette();
// Do not allow gdi batching
GdiSetBatchLimit(1);
// Get the full offscreen buffer including edges
init_backbuf();
// inform STORM library of our DirectDraw objects
BOOL bSuccess = SDrawManualInitialize(
hWnd, // window
lpDD, // direct draw
lpDDSPrimary, // primary
NULL, // secondary
NULL, // system
lpDDSBackBuf, // temporary
lpDDPal, // palette
NULL // gdi palette
);
app_assert(bSuccess);
}
//******************************************************************
//******************************************************************
static void lock_buf_priv() {
// don't allow any other threads access to the draw
// buffer while we have it locked
sgDrawCrit.Enter();
if (sgpBackBuf) {
gpBuffer = sgpBackBuf;
}
else if (! lpDDSBackBuf) {
// if the back buffer was destroyed by another thread
// it is because it is fataling...give it a chance to
// shut down the system before performing our own fatal
Sleep(20000);
app_fatal("lock_buf_priv");
}
else if (! sgdwLockCount) {
DDSURFACEDESC ddsd;
ddsd.dwSize = sizeof(ddsd);
HRESULT ddrval = lpDDSBackBuf->Lock(NULL,&ddsd,DDLOCK_WAIT,NULL);
ddraw_assert(ddrval);
gpBuffer = (BYTE *) ddsd.lpSurface;
app_assert(gpBuffer);
glClipY += (long) gpBuffer;
}
// increment lock count
sgdwLockCount++;
}
//******************************************************************
//******************************************************************
void lock_buf(BYTE bFcn) {
// for debugging -- make sure no lock count over/underflow
#ifndef NDEBUG
sgdwLockTbl[bFcn]++;
#endif
lock_buf_priv();
}
//******************************************************************
//******************************************************************
static void unlock_buf_priv() {
if (! sgdwLockCount) app_fatal("draw main unlock error");
if (! gpBuffer) app_fatal("draw consistency error");
if (! sgpBackBuf) app_assert(lpDDSBackBuf);
// decrement lock count
sgdwLockCount--;
if (! sgdwLockCount) {
glClipY -= (long) gpBuffer;
gpBuffer = NULL;
if (! sgpBackBuf) {
HRESULT ddrval = lpDDSBackBuf->Unlock(NULL);
ddraw_assert(ddrval);
}
}
sgDrawCrit.Leave();
}
//******************************************************************
//******************************************************************
void unlock_buf(BYTE bFcn) {
// for debugging -- make sure no lock count over/underflow
#ifndef NDEBUG
if (! sgdwLockTbl[bFcn]) app_fatal("Draw lock underflow: 0x%x",bFcn);
sgdwLockTbl[bFcn]--;
#endif
unlock_buf_priv();
}
//******************************************************************
// THIS FUNCTION MAY BE CALLED FROM ANY THREAD IN THE PROGRAM
// ALL OTHER PUBLIC FUNCTIONS IN THIS MODULE MAY ONLY BE CALLED
// FROM THE MAIN APPLICATION THREAD!
//******************************************************************
void free_directx() {
if (ghMainWnd) ShowWindow(ghMainWnd,SW_HIDE);
// tell SDraw that we're about to kill off direct draw
// so it doesn't try to re-use freed objects
SDrawDestroy();
sgDrawCrit.Enter();
if (sgpBackBuf) {
app_assert(! lpDDSBackBuf);
DiabloFreePtr(sgpBackBuf);
}
else if (lpDDSBackBuf) {
lpDDSBackBuf->Release();
lpDDSBackBuf = NULL;
}
sgdwLockCount = 0;
gpBuffer = NULL;
sgDrawCrit.Leave();
if (lpDDSPrimary) {
lpDDSPrimary->Release();
lpDDSPrimary = NULL;
}
if (lpDDPal) {
lpDDPal->Release();
lpDDPal = NULL;
}
if (lpDD) {
lpDD->Release();
lpDD = NULL;
}
// cannot free library now, still may be in use
// by directX window procedure...
/*
if (sghDDlib) {
FreeLibrary(sghDDlib);
sghDDlib = NULL;
}
*/
}
//******************************************************************
//******************************************************************
void ddraw_switch_modes() {
sgDrawCrit.Enter();
app_assert(ghMainWnd);
void savecrsr_reset();
savecrsr_reset();
// remove any locks this thread has on buffer
DWORD dwSaveCount = sgdwLockCount;
while (sgdwLockCount) unlock_buf_priv();
free_directx();
force_redraw = FULLDRAW;
init_directx(ghMainWnd);
// restore locks
while (dwSaveCount--) lock_buf_priv();
sgDrawCrit.Leave();
}
//******************************************************************
//******************************************************************
void ddraw_reinit() {
ddraw_switch_modes();
}

595
src/EFFECTS.CPP Normal file
View File

@ -0,0 +1,595 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Sound sgpSFX
**
** (C)1995 Condor, Inc. All rights reserved.
**
**-----------------------------------------------------------------------**
** $Header: /Diablo/EFFECTS.CPP 1 1/22/97 2:06p Dgartner $
**-----------------------------------------------------------------------**/
#include "diablo.h"
#pragma hdrstop
#include "storm.h"
#include "sound.h"
#include "monster.h"
#include "monstdat.h"
#include "gendung.h"
#include "items.h"
#include "player.h"
#include "engine.h"
#include "effects.h"
#include "multi.h"
//******************************************************************
// debugging
//******************************************************************
#define DEBUG_STREAM 1 // 0 in final
#ifdef NDEBUG
#undef DEBUG_STREAM
#define DEBUG_STREAM 0
#endif
//******************************************************************
// extern
//******************************************************************
void snd_update(BOOL bStopAll);
//******************************************************************
// public
//******************************************************************
int sfxdelay, sfxdnum;
//******************************************************************
// private
//******************************************************************
// sound constants
#define sfx_STREAM 0x01 // streaming sound effect
#define sfx_ALLOWMULTIPLE 0x02 // only valid for non-streamed sounds
#define sfx_MENU 0x04 // menu sound
#define sfx_MONK 0x08 // only needed for the monk
#define sfx_ROGUE 0x10 // only needed for the rogue
#define sfx_WARRIOR 0x20 // only needed for the warrior
#define sfx_SORCEROR 0x40 // only needed for the sorceror
#define sfx_BARD 0x10 // reuse the rogue
#define sfx_BARBARIAN 0x20 // reuse the warrior
#define sfx_DEBUG_STREAM 0x80 // for debugging when streaming is off
#define sfx_CHAR_MASK (sfx_MONK|sfx_ROGUE|sfx_WARRIOR|sfx_SORCEROR)
// sound structure
#pragma pack(push,1)
typedef struct TSFX {
BYTE bFlags;
char * pszName;
TSnd * pSnd;
} TSFX;
#pragma pack(pop)
// build sound data table
#define EFFECTS_DATA
#include "effects.h"
#undef EFFECTS_DATA
#define NUM_SFX (sizeof(sgSFX) / sizeof(sgSFX[0]))
static HSFILE sghStream = NULL;
static TSFX * sgpStreamSFX = NULL;
//******************************************************************
//******************************************************************
BOOL effect_is_playing(int nSFX) {
app_assert(nSFX < NUM_SFX);
TSFX * pSFX = &sgSFX[nSFX];
// if a sound buffer is allocated, then just return play status
if (pSFX->pSnd) return snd_playing(pSFX->pSnd);
// if this is a streamed sound, is it the current stream?
if (pSFX->bFlags & sfx_STREAM)
return (pSFX == sgpStreamSFX);
return FALSE;
}
//******************************************************************
//******************************************************************
#if DEBUG_STREAM
static void debug_stream_update(BOOL bStop) {
// if sound isn't initialized, we don't have to do any work
if (! gbSndInited) return;
TSFX * pSFX = sgSFX;
for (DWORD d = NUM_SFX; d--; pSFX++) {
if (! (pSFX->bFlags & sfx_DEBUG_STREAM)) continue;
if (! pSFX->pSnd) continue;
if (!bStop && snd_playing(pSFX->pSnd)) continue;
pSFX->bFlags &= ~sfx_DEBUG_STREAM;
snd_free_snd(pSFX->pSnd);
pSFX->pSnd = NULL;
}
}
#endif
//******************************************************************
//******************************************************************
void stream_stop() {
if (sghStream) {
SFileDdaEnd(sghStream);
SFileCloseFile(sghStream);
sghStream = NULL;
sgpStreamSFX = NULL;
}
#if DEBUG_STREAM
debug_stream_update(TRUE);
#endif
}
//******************************************************************
//******************************************************************
#if DEBUG_STREAM
static void debug_stream(TSFX * pSFX,LONG lVolume,LONG lPan) {
// OK, the streaming stuff failed, just load
// it into memory and play it, then free it
if (pSFX->pSnd) return;
if (NULL == (pSFX->pSnd = snd_load_snd(pSFX->pszName)))
return;
pSFX->bFlags |= sfx_DEBUG_STREAM;
snd_play_snd(pSFX->pSnd,lVolume,lPan);
}
#endif
//******************************************************************
//******************************************************************
static void stream_play(TSFX * pSFX,LONG lVolume,LONG lPan) {
app_assert(pSFX);
app_assert(pSFX->bFlags & sfx_STREAM);
stream_stop();
// adjust volume by global volume amount
lVolume += sound_volume(VOLUME_READ);
if (lVolume < VOLUME_MIN) return;
else if (lVolume > VOLUME_MAX) lVolume = VOLUME_MAX;
// open stream file
#ifndef NDEBUG
SFileEnableDirectAccess(0);
#endif
BOOL bResult = SFileOpenFile(pSFX->pszName,&sghStream);
#ifndef NDEBUG
SFileEnableDirectAccess(1);
#endif
if (! bResult) {
sghStream = NULL;
#if DEBUG_STREAM
debug_stream(pSFX,lVolume,lPan);
#endif
return;
}
// play it
if (! SFileDdaBeginEx(sghStream,DDA_BUF_SIZE,0,0,lVolume,lPan,0)) {
stream_stop();
#if DEBUG_STREAM
debug_stream(pSFX,lVolume,lPan);
#endif
return;
}
sgpStreamSFX = pSFX;
}
//******************************************************************
//******************************************************************
static void stream_update() {
// is there a stream playing?
if (! sghStream) return;
// get current stream position
DWORD nPosition,nMaxPosition;
if (! SFileDdaGetPos(sghStream,&nPosition,&nMaxPosition))
return;
// if it hasn't finished playing, let it run
if (nPosition < nMaxPosition)
return;
stream_stop();
}
//******************************************************************
//******************************************************************
static void sfx_stop() {
TSFX * pSFX = sgSFX;
for (DWORD d = NUM_SFX; d--; pSFX++) {
if (! pSFX->pSnd) continue;
snd_stop_snd(pSFX->pSnd);
}
}
//******************************************************************
//******************************************************************
void InitMonsterSND(int monst) {
// if sound isn't initialized, we don't have to do any work
if (! gbSndInited) return;
static const char sndletter[MAX_MS + 1] = "ahds";
int mtype = Monsters[monst].mtype;
for (int snd = 0; snd < MAX_MS; snd++) {
// if this is the "special" sound, and monster doesn't have
// a special sound then we don't need to load the sound
if (sndletter[snd] == 's' && !monsterdata[mtype].snd_special)
continue;
for (int i = 0; i < 2; i++) {
// derive path for sound effect
char szTemp[MAX_PATH];
sprintf(szTemp,monsterdata[mtype].sndfile,sndletter[snd],i+1);
char * pszBuf = (char *) DiabloAllocPtrSig(strlen(szTemp) + 1,'SNDN');
strcpy(pszBuf,szTemp);
// load sound effect
// leave ptr active
TSnd * pSnd = snd_load_snd(pszBuf);
Monsters[monst].Snds[snd].effect[i] = pSnd;
// if the sound was never allocated, free the file name buffer
if (! pSnd) DiabloFreePtr(pszBuf);
}
}
}
//******************************************************************
//******************************************************************
void FreeMonsterSnd() {
for (int monst = 0;monst < nummtypes; monst++) {
int mtype = Monsters[monst].mtype;
for (int snd = 0; snd < MAX_MS; snd++) {
for (int i = 0; i < 2; i++) {
TSnd * pSnd = Monsters[monst].Snds[snd].effect[i];
if (! pSnd) continue;
Monsters[monst].Snds[snd].effect[i] = NULL;
// save ptr to sound effect name
char * pszBuf = (char *) pSnd->pszName;
pSnd->pszName = NULL;
// free sound
snd_free_snd(pSnd);
// free sound name
DiabloFreePtr(pszBuf);
}
}
}
}
//******************************************************************
//******************************************************************
static BOOL calc_snd_position(int x,int y,LONG * plVolume,LONG * plPan) {
// calc position relative to player
x -= plr[myplr]._px;
y -= plr[myplr]._py;
// calc pan
*plPan = (x - y) * 256;
if (abs(*plPan) > 6400) return FALSE;
// calc volume
*plVolume = max(abs(x),abs(y)) * 64;
if (*plVolume >= 6400) return FALSE;
*plVolume = - *plVolume;
return TRUE;
}
//******************************************************************
//******************************************************************
static void PlaySFX_priv(TSFX * pSFX,BOOL loc,int x, int y) {
// Don't play sfx if in just onto level
if ((plr[myplr].pLvlLoad) && (gbMaxPlayers != 1)) return;
// if sound isn't initialized, we don't have to do any work
if (! gbSndInited) return;
if (! gbSoundOn) return;
// this is the lowest level location to intercept game sound
// effects. If we are in some buffering mode (either because
// we're receiving or parsing information prior to starting a
// level) then we don't want to play any sound effects because
// the player is not in a position to interact with anything yet.
if (gbBufferMsgs != BUFFER_OFF) return;
// check for sound buffer duplication
if (pSFX->bFlags & sfx_STREAM) {
// streams sounds are always allowed to play
// as they will shut off any previous stream
}
else if (pSFX->bFlags & sfx_ALLOWMULTIPLE) {
// we allow this sound to use multiple buffers
}
else if (pSFX->pSnd && snd_playing(pSFX->pSnd)) {
// this sound is already playing -- skip
return;
}
// calculate volume and panning, and clip sound if necessary
LONG lPan = 0;
LONG lVolume = 0;
if (loc && !calc_snd_position(x,y,&lVolume,&lPan))
return;
if (pSFX->bFlags & sfx_STREAM) {
stream_play(pSFX,lVolume,lPan);
}
else {
if (! pSFX->pSnd) pSFX->pSnd = snd_load_snd(pSFX->pszName);
if (pSFX->pSnd) snd_play_snd(pSFX->pSnd,lVolume,lPan);
}
}
//******************************************************************
// Plays a monster sound effect
// i = monster# to player for
// mode = which sfx to play (attack, hit, death, etc)
//******************************************************************
void PlayEffect(int i, int mode) {
// Don't play sfx if in just onto level
if (plr[myplr].pLvlLoad) return;
// choose which of the two rnd sfx to play
// always perform random() function even if
// sound is off so that random generators stay synced
int nr = random(164, 2);
// return *after* the random call so that all systems are synced
if (! gbSndInited) return;
if (! gbSoundOn) return;
// this is the lowest level location to intercept game sound
// effects. If we are in some buffering mode (either because
// we're receiving or parsing information prior to starting a
// level) then we don't want to play any sound effects because
// the player is not in a position to interact with anything yet.
if (gbBufferMsgs != BUFFER_OFF) return;
// monster type index (0 - nummtypes)
int mi = monster[i]._mMTidx;
// validate sound effect
TSnd * pSnd = Monsters[mi].Snds[mode].effect[nr];
if (! pSnd) {
#ifndef NDEBUG // don't fatal out in release version
app_fatal("Monster sound problem\n:%s playing %i", Monsters[mi].MData->mName, mode);
#endif
return;
}
// don't allow duplication multiple monster effects
if (snd_playing(pSnd)) return;
// calculate volume and panning, and clip sound if necessary
LONG lPan;
LONG lVolume;
if (!calc_snd_position(monster[i]._mx,monster[i]._my,&lVolume,&lPan))
return;
snd_play_snd(pSnd,lVolume,lPan);
}
//******************************************************************
// Determine random sfx to play
//******************************************************************
static int RndSFX(int psfx) {
int nRand;
if (psfx == PS_WARR69) nRand = 2;
else if (psfx == PS_WARR14) nRand = 3;
else if (psfx == PS_WARR15) nRand = 3;
else if (psfx == PS_WARR16) nRand = 3;
#if !IS_VERSION(SHAREWARE)
else if (psfx == PS_MAGE69) nRand = 2;
else if (psfx == PS_ROGUE69) nRand = 2;
else if (psfx == PS_MONK69) nRand = 2;
else if (psfx == PS_BARD69) nRand = 2;
#endif
else if (psfx == PS_SWING) nRand = 2;
else if (psfx == LS_ACID) nRand = 2;
else if (psfx == IS_FMAG) nRand = 2;
else if (psfx == IS_MAGIC) nRand = 2;
else if (psfx == IS_BHIT) nRand = 2;
// else if (psfx == PS_WALK1) nRand = 4;
#if !IS_VERSION(SHAREWARE)
else if (psfx == PS_WARR2) nRand = 3;
#endif
else return psfx;
return psfx + random(165,nRand);
}
//******************************************************************
// If player has hit something, play the hit sfx from the player
// (sword hitting metal, bone, etc)
//******************************************************************
void PlaySFX(int psfx) {
psfx = RndSFX(psfx);
app_assert(psfx < NUM_SFX);
PlaySFX_priv(&sgSFX[psfx],FALSE,0,0);
}
//******************************************************************
// Like PlaySFX, but with a dungeon location
//******************************************************************
void PlaySfxLoc(int psfx, int x, int y) {
psfx = RndSFX(psfx);
app_assert(psfx < NUM_SFX);
// don't let walk sounds get clipped!
if (psfx >= PS_WALK1 && psfx <= PS_WALK4) {
TSnd * pSnd = sgSFX[psfx].pSnd;
if (pSnd) pSnd->dwLastPlayTime = 0;
}
PlaySFX_priv(&sgSFX[psfx],TRUE,x,y);
}
//******************************************************************
//******************************************************************
void sound_stop() {
snd_update(TRUE);
stream_stop();
sfx_stop();
// stop all monster sounds
int mi, mode, nr;
for (mi = 0; mi < nummtypes; mi++) {
for (mode = 0; mode < MAX_MS; mode++) {
for (nr = 0; nr < 2; nr++) {
TSnd * pSnd = Monsters[mi].Snds[mode].effect[nr];
snd_stop_snd(pSnd);
}
}
}
}
//******************************************************************
//******************************************************************
void sound_update() {
// if sound isn't initialized, we don't have to do any work
if (! gbSndInited) return;
snd_update(FALSE);
stream_update();
#if DEBUG_STREAM
debug_stream_update(FALSE);
#endif
}
//******************************************************************
//******************************************************************
void sound_exit() {
sound_stop();
for (DWORD d = 0; d < NUM_SFX; d++) {
if (! sgSFX[d].pSnd) continue;
#if DEBUG_STREAM
sgSFX[d].bFlags &= ~sfx_DEBUG_STREAM;
#endif
snd_free_snd(sgSFX[d].pSnd);
sgSFX[d].pSnd = NULL;
}
}
//******************************************************************
//******************************************************************
static void priv_sound_init(BYTE bLoadMask) {
// if sound manager isn't initialized, we don't have to do any work
if (! gbSndInited) return;
// save character load flags
BYTE bCharMask = bLoadMask & sfx_CHAR_MASK;
// load mask excludes character mask
bLoadMask ^= bCharMask;
// load sounds
for (DWORD d = 0; d < NUM_SFX; d++) {
// is it already loaded?
if (sgSFX[d].pSnd) continue;
// don't load streamed sounds
if (sgSFX[d].bFlags & sfx_STREAM) continue;
// if load mask is non-zero, only load sound effect if
// it has a flag which is set in the load mask
if (bLoadMask && !(sgSFX[d].bFlags & bLoadMask)) continue;
// is this a character sound that we don't need?
if (sgSFX[d].bFlags & sfx_CHAR_MASK) {
if (! (sgSFX[d].bFlags & bCharMask))
continue;
}
// load it
sgSFX[d].pSnd = snd_load_snd(sgSFX[d].pszName);
}
}
//******************************************************************
//******************************************************************
void sound_init() {
BYTE bLoadMask = 0;
if (gbMaxPlayers > 1)
bLoadMask = sfx_CHAR_MASK;
else if (plr[myplr]._pClass == CLASS_WARRIOR)
bLoadMask = sfx_WARRIOR;
else if (plr[myplr]._pClass == CLASS_ROGUE)
bLoadMask = sfx_ROGUE;
else if (plr[myplr]._pClass == CLASS_SORCEROR)
bLoadMask = sfx_SORCEROR;
else if (plr[myplr]._pClass == CLASS_MONK)
bLoadMask = sfx_MONK;
else if (plr[myplr]._pClass == CLASS_BARD)
bLoadMask = sfx_BARD;
else if (plr[myplr]._pClass == CLASS_BARBARIAN)
bLoadMask = sfx_BARBARIAN;
else
app_fatal("effects:1");
priv_sound_init(bLoadMask);
}
//******************************************************************
//******************************************************************
void menusnd_init() {
priv_sound_init(sfx_MENU);
}
//******************************************************************
//******************************************************************
void CALLBACK menusnd_play(LPCSTR pszName) {
// sound initialized?
if (! gbSndInited) return;
if (! gbSoundOn) return;
for (DWORD d = 0; d < NUM_SFX; d++) {
if (_stricmp(sgSFX[d].pszName,pszName)) continue;
if (! sgSFX[d].pSnd) continue;
if (snd_playing(sgSFX[d].pSnd)) break;
snd_play_snd(sgSFX[d].pSnd,0,0);
break;
}
}

1440
src/EFFECTS.H Normal file

File diff suppressed because it is too large Load Diff

165
src/ENCRYPT.CPP Normal file
View File

@ -0,0 +1,165 @@
//******************************************************************
// ENCRYPT.CPP
// File pack utility
// By Michael O'Brien (6/1/96) && Patrick Wyatt (6/24/96)
//******************************************************************
#include "diablo.h"
#pragma hdrstop
#include "engine.h"
#include "mpqapi.h"
#include "implode.h"
//******************************************************************
// private
//******************************************************************
typedef struct _COMPRESSIONINFO {
LPVOID sourcebuffer;
DWORD sourceoffset;
LPVOID destbuffer;
DWORD destoffset;
DWORD bytes;
} COMPRESSIONINFO, *COMPRESSIONPTR;
static DWORD hashsource[5][256];
//******************************************************************
//******************************************************************
void Decrypt(LPDWORD data, DWORD bytes, DWORD key) {
DWORD adjust = 0xEEEEEEEE;
DWORD iter = bytes >> 2;
while (iter--) {
adjust += hashsource[HASH_ENCRYPTDATA][key & 0xFF];
adjust += (*data++ ^= adjust+key)+(adjust << 5)+3;
key = (key >> 11) | ((key << 21) ^ 0xFFE00000)+0x11111111;
}
}
//******************************************************************
//******************************************************************
void Encrypt(LPDWORD data, DWORD bytes, DWORD key) {
DWORD adjust = 0xEEEEEEEE;
DWORD iter = bytes >> 2;
while (iter--) {
DWORD origdata = *data;
adjust += hashsource[HASH_ENCRYPTDATA][key & 0xFF];
*data++ = origdata ^ (adjust+key);
adjust += origdata + (adjust << 5)+3;
key = (key >> 11) | ((key << 21) ^ 0xFFE00000)+0x11111111;
}
}
//******************************************************************
//******************************************************************
DWORD Hash(const char *filename, int hashtype) {
DWORD result = 0x7FED7FED;
DWORD adjust = 0xEEEEEEEE;
while (filename && *filename) {
char origchar = toupper(*filename++);
result = (result+adjust) ^ hashsource[hashtype][origchar];
adjust += origchar+result+(adjust << 5)+3;
}
return result;
}
//******************************************************************
//******************************************************************
void InitializeHashSource() {
DWORD seed = 0x100001;
for (int loop1 = 0; loop1 < 256; ++loop1) {
for (int loop2 = 0; loop2 < 5; ++loop2) {
seed = (seed*0x7D+3) % 0x2AAAAB;
DWORD rand1 = seed & 0xFFFF;
seed = (seed*0x7D+3) % 0x2AAAAB;
DWORD rand2 = seed & 0xFFFF;
hashsource[loop2][loop1] = (rand1 << 16) | rand2;
}
}
}
//******************************************************************
//******************************************************************
static UINT __cdecl CompBufferRead(LPSTR buffer, UINT *size, LPVOID param) {
COMPRESSIONPTR infoptr = (COMPRESSIONPTR) param;
UINT bytes = min(*size,infoptr->bytes-infoptr->sourceoffset);
CopyMemory(buffer,(LPSTR)infoptr->sourcebuffer+infoptr->sourceoffset,bytes);
infoptr->sourceoffset += bytes;
return bytes;
}
//******************************************************************
//******************************************************************
static void __cdecl CompBufferWrite(LPSTR buffer, UINT *size, LPVOID param) {
COMPRESSIONPTR infoptr = (COMPRESSIONPTR)param;
CopyMemory((LPSTR)infoptr->destbuffer+infoptr->destoffset,buffer,*size);
infoptr->destoffset += *size;
}
//******************************************************************
//******************************************************************
DWORD Compress(LPBYTE data, DWORD bytes) {
// ALLOCATE COMPRESSION BUFFERS
LPVOID implodebuffer = DiabloAllocPtrSig(CMP_BUFFER_SIZE,'CMPt');
LPVOID destbuffer = DiabloAllocPtrSig(max(SECTORSIZE*2,bytes*2),'CMPt');
// CREATE AN INFORMATION RECORD
COMPRESSIONINFO info;
info.sourcebuffer = data;
info.sourceoffset = 0;
info.destbuffer = destbuffer;
info.destoffset = 0;
info.bytes = bytes;
// PERFORM THE COMPRESSION
UINT comptype = CMP_BINARY;
UINT dictsize = max(512,min(4096,SECTORSIZE));
implode(CompBufferRead,CompBufferWrite,(LPSTR)implodebuffer,&info,&comptype,&dictsize);
// IF THE DATA WAS NOT COMPRESSABLE, RETURN THE SOURCE DATA
// OTHERWISE, RETURN THE COMPRESSED DATA
if (info.destoffset < bytes) {
CopyMemory(data,destbuffer,info.destoffset);
bytes = info.destoffset;
}
DiabloFreePtr(implodebuffer);
DiabloFreePtr(destbuffer);
return bytes;
}
//******************************************************************
//******************************************************************
void Expand(LPBYTE data, DWORD bytes, DWORD dwMaxBytes) {
// ALLOCATE COMPRESSION BUFFERS
LPVOID implodebuffer = DiabloAllocPtrSig(CMP_BUFFER_SIZE,'CMPt');
LPVOID destbuffer = DiabloAllocPtrSig(dwMaxBytes,'CMPt');
// CREATE AN INFORMATION RECORD
COMPRESSIONINFO info;
info.sourcebuffer = data;
info.sourceoffset = 0;
info.destbuffer = destbuffer;
info.destoffset = 0;
info.bytes = bytes;
// PERFORM THE DECOMPRESSION
explode(CompBufferRead,CompBufferWrite,(LPSTR)implodebuffer,&info);
app_assert(info.destoffset <= dwMaxBytes);
// copy back into the original buffer
CopyMemory(data,destbuffer,info.destoffset);
DiabloFreePtr(implodebuffer);
DiabloFreePtr(destbuffer);
}

3500
src/ENGINE.CPP Normal file

File diff suppressed because it is too large Load Diff

142
src/ENGINE.H Normal file
View File

@ -0,0 +1,142 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Constants and Variables
**
** (C)1995 Condor, Inc. All rights reserved.
**-----------------------------------------------------------------------**
** $Header: /Diablo/ENGINE.H 1 1/22/97 2:06p Dgartner $
**-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------**
** Prototypes
**-----------------------------------------------------------------------*/
void DrawCel (long, long, BYTE *, long, long);
void DrawCelP (BYTE *, BYTE *, long, long);
void DrawSlabCel (long, long, BYTE *, long, long, long, long);
void DrawSlabCelP (BYTE *, BYTE *, long, long, long, long);
void DrawCelL (long, long, BYTE *, long, long);
void DrawCelPL (BYTE *, BYTE *, long, long);
void DrawSlabCelL (long, long, BYTE *, long, long, long, long);
void DrawSlabCelPL (BYTE *, BYTE *, long, long, long, long);
void TDrawSlabCelPL (BYTE *, BYTE *, long, long, long, long);
void CDrawSlabCel (long, long, BYTE *, long, long, long, long);
void CDrawSlabCelP (BYTE *, BYTE *, long, long, long, long);
void CDrawSlabCelL (long, long, BYTE *, long, long, long, long);
void CDrawSlabCelPL (BYTE *, BYTE *, long, long, long, long);
void TCDrawSlabCelPL (BYTE *, BYTE *, long, long, long, long);
void DrawSlabCelI(long, long, BYTE *, long, long, long, long, char);
void CDrawSlabCelI(long, long, BYTE *, long, long, long, long, char);
void OutlineSlabCel(byte, long, long, BYTE *, long, long, long, long);
void COutlineSlabCel(byte, long, long, BYTE *, long, long, long, long);
void DrawBuffCel(BYTE *, long, long, long, BYTE *, long, long);
void DecodeFullCel (BYTE *, BYTE *, long, long);
void DecodeFullCelL (BYTE *, BYTE *, long, long);
void CDecodeFullCel (BYTE *, BYTE *, long, long);
void CDecodeFullCelL (BYTE *, BYTE *, long, long);
void TranslateCels(byte *, byte *, int);
int GetDirection(int, int, int, int);
long GetRndSeed();
void SetRndSeed(long);
long random(byte, long);
void DrawLine(int, int, int, int, byte);
void DrawPoint(int, int, byte);
void PlayInGameMovie(const char * pszMovie);
//******************************************************************
// memory management
//******************************************************************
#define DEBUG_MEM 1 // 0 in final
#ifdef NDEBUG
#undef DEBUG_MEM
#define DEBUG_MEM 0
#endif
// public memory management functions
BYTE * DiabloAllocPtr(DWORD dwBytes);
BYTE * DiabloAllocPtrSig(DWORD dwBytes,DWORD dwSig);
// NOTE: DiabloFreePtr behavior
//
// p MUST be an l-value
//
// if p is NULL:
// no memory is freed
// if p is NOT NULL:
// p is set to NULL before call to free, and then memory is freed
// GUARANTEES p == NULL immediately after DiabloFreePtr is called!
void DiabloFreePtr(void * p);
BYTE * LoadFileInMem(const char * pszName, DWORD * pdwFileLen);
BYTE * LoadFileInMemSig(const char * pszName, DWORD * pdwFileLen,DWORD dwSig);
DWORD LoadFileWithMem(const char * pszName, BYTE * pbMem);
void mem_cleanup(BOOL bNormalExit);
#if DEBUG_MEM
// internal functions
void mem_use_sig(DWORD dwSig,DWORD dwBytes);
void mem_unuse_sig(DWORD dwSig,DWORD dwBytes);
BYTE * mem_malloc_dbg(DWORD dwBytes,DWORD dwSig,DWORD dwLine,const TCHAR * pszFile);
void mem_free_dbg(void * p,DWORD dwLine,const TCHAR * pszFile);
BYTE * load_file_dbg(const char * pszName,DWORD * pdwFileLen,DWORD dwSig,DWORD dwLine,const TCHAR * pszFile);
// definitions of public functions
#define DiabloAllocPtr(dwBytes) mem_malloc_dbg(dwBytes,'NONE',__LINE__,__FILE__)
#define DiabloAllocPtrSig(dwBytes,dwSig) mem_malloc_dbg(dwBytes,dwSig,__LINE__,__FILE__)
#define LoadFileInMem(pszName,pdwFileLen) load_file_dbg(pszName,pdwFileLen,'NONE',__LINE__,__FILE__)
#define LoadFileInMemSig(pszName,pdwFileLen,dwSig) load_file_dbg(pszName,pdwFileLen,dwSig,__LINE__,__FILE__)
// free function -- set pointer to NULL before real call to free
#define DiabloFreePtr(p) { \
void * p__p = (void *) (p); \
(p) = NULL; \
mem_free_dbg(p__p,__LINE__,__FILE__); \
}
#else
// internal functions
void mem_free_dbg(void * p);
// definitions of public functions
#define DiabloAllocPtrSig(dwBytes,dwSig) DiabloAllocPtr(dwBytes)
#define LoadFileInMemSig(pszName,pdwFileLen,dwSig) LoadFileInMem(pszName,pdwFileLen)
// free function -- set pointer to NULL before real call to free
#define DiabloFreePtr(p) { \
void * p__p = (void *) (p); \
(p) = NULL; \
mem_free_dbg(p__p); \
}
#endif
//******************************************************************
// file manager
//******************************************************************
#ifdef _STORM_H_
void patSFileCloseFile(HSFILE handle);
DWORD patSFileGetFileSize(HSFILE handle,LPDWORD filesizehigh = NULL);
BOOL patSFileOpenFile(LPCTSTR filename,HSFILE *handle,BOOL bCanFail = FALSE);
void patSFileReadFile(HSFILE handle,LPVOID buffer,DWORD bytestoread);
DWORD patSFileSetFilePointer(HSFILE handle,LONG distancetomove,PLONG distancetomovehigh,DWORD movemethod);
#endif

206
src/ERROR.CPP Normal file
View File

@ -0,0 +1,206 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Control panel file
**
** (C)1995 Condor, Inc. All rights reserved.
**
**-----------------------------------------------------------------------**
** $Header: /Diablo/ERROR.CPP 1 1/22/97 2:06p Dgartner $
**-----------------------------------------------------------------------**
**
** File Routines
**-----------------------------------------------------------------------*/
#include "diablo.h"
#pragma hdrstop
#include "error.h"
#include "engine.h"
#include "control.h"
#include "items.h"
#include "stores.h"
#include "scrollrt.h"
/*-----------------------------------------------------------------------**
** Message strings
**-----------------------------------------------------------------------*/
char *MsgStrings[] = {
"",
"No automap available in town",
"No multiplayer functions in demo",
"Direct Sound Creation Failed",
"Not available in shareware version",
"Not enough space to save",
"No Pause in town",
"Copying to a hard disk is recommended",
"Multiplayer sync problem",
"No pause in multiplayer",
"Loading...",
"Saving...",
//Shrine messages
"Some are weakened as one grows strong", //12 Mysterious
"New strength is forged through destruction", //13 Hidden
"Those who defend seldom attack", //14 Gloomy
"The sword of justice is swift and sharp", //15 Weird
"While the spirit is vigilant the body thrives", //16 Magical
"The powers of mana refocused renews", //17 Stone
"Time cannot diminish the power of steel", //18 Religious
"Magic is not always what it seems to be", //19 Enchanted
"What once was opened now is closed", //20 Thaumaturgic
"Intensity comes at the cost of wisdom", //21 Fascinating
"Arcane power brings destruction", //22 Cryptic
"That which cannot be held cannot be harmed", //23 Supernatural
"Crimson and Azure become as the sun", //24 Eldritch
"Knowledge and wisdom at the cost of self", //25 Eerie
"Drink and be refreshed", //26 Divine
"Wherever you go, there you are", //27 Holy
"Energy comes at the cost of wisdom", //28 Sacred
"Riches abound when least expected", //29 Spiritual
"Where avarice fails, patience gains reward", //30 Spooky
"Blessed by a benevolent companion!", //31 Spooky Multi
"The hands of men may be guided by fate", //32 Abandoned
"Strength is bolstered by heavenly faith", //33 Creepy
"The essence of life flows from within", //34 Quiet
"The way is made clear when viewed from above", //35 Secluded
"Salvation comes at the cost of wisdom", //36 Ornate
"Mysteries are revealed in the light of reason", //37 Glimmering
"Those who are last may yet be first", //38 Tainted
"Generosity brings its own rewards", //39 Tainted Multi
//Shortcut messages
"You must be at least level 8 to use this.", //40
"You must be at least level 13 to use this.", //41
"You must be at least level 17 to use this.", //42
"Arcane knowledge gained!", //43
// New Shrines
"That which does not kill you...", //44 Oily
"Knowledge is power.", //45 Glowing
"Give and you shall receive.", //46 Mendicants.
"Some experience is gained by touch.", //47 Edisons
"There's no place like home.", //48 Town
"Spirtual energy is restored.", //49 Energy
"You feel more agile.", //50 Time Morning
"You feel stronger.", //51 Time Afternoon.
"You feel wiser.", //52 Time Evening.
"You feel refreshed.", //53 Time Night.
"That which can break will.", //54 Murphy's
};
/*-----------------------------------------------------------------------**
** Local defines
**-----------------------------------------------------------------------*/
#define MSGCNT 70
char msgflag;
char msgdelay;
char msgtable[80];
char msgcnt = 0;
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
void InitDiabloMsg(char e)
{
int i;
for (i = 0; i < msgcnt; i++) {
if (msgtable[i] == e) return;
}
msgtable[msgcnt] = e;
if (msgcnt < 80) msgcnt++;
msgflag = msgtable[0];
msgdelay = MSGCNT;
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
void ClrDiabloMsg()
{
for (int i = 0; i < 80; i++) msgtable[i] = MSG_NONE;
msgflag = MSG_NONE;
msgcnt = 0;
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
void DrawDiabloMsg()
{
int i, x, y;
long boffset;
int sl,tw;
// Draw error box
DrawCel(165, 318, pSTextSlidCels, 1, 12);
DrawCel(591, 318, pSTextSlidCels, 4, 12);
DrawCel(165, 366, pSTextSlidCels, 2, 12);
DrawCel(591, 366, pSTextSlidCels, 3, 12);
x = 173;
for (i = 0; i < 35; i++) {
DrawCel(x, 318, pSTextSlidCels, 5, 12);
DrawCel(x, 366, pSTextSlidCels, 7, 12);
x += 12;
}
y = 330;
for (i = 0; i < 3; i++) {
DrawCel(165, y, pSTextSlidCels, 6, 12);
DrawCel(591, y, pSTextSlidCels, 8, 12);
y += 12;
}
app_assert(gpBuffer);
__asm {
mov edi,dword ptr [gpBuffer]
add edi,278952
xor eax,eax
mov edx,27
_YLp: mov ecx,216 // (width+6)/2
_XLp1: stosb
inc edi
loop _XLp1
sub edi,1200 // ((width+6)/2) + 768
mov ecx,216 // (width+6)/2
_XLp2: inc edi
stosb
loop _XLp2
sub edi,1200 // ((width+6)/2) + 768
dec edx
jnz _YLp
}
strcpy(tempstr, MsgStrings[msgflag]);
boffset = nBuffWTbl[342] + 165;
sl = strlen(tempstr);
tw = 0;
for (i = 0; i < sl; i++) {
BYTE c = char2print(tempstr[i]);
c = fonttrans[c];
tw += fontkern[c]+1;
}
if (tw < 442) boffset += (442 - tw) >> 1;
for (i = 0; i < sl; i++) {
BYTE c = char2print(tempstr[i]);
c = fonttrans[c];
if (c) DrawPanelFont(boffset, c, ICOLOR_GOLD);
boffset += fontkern[c]+1;
}
if (msgdelay > 0) msgdelay--;
if (msgdelay == 0) {
msgcnt--;
msgdelay = MSGCNT;
if (msgcnt == 0) msgflag = MSG_NONE;
else msgflag = msgtable[msgcnt];
}
}

93
src/ERROR.H Normal file
View File

@ -0,0 +1,93 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Constants and Variables
**
** (C)1995 Condor, Inc. All rights reserved.
**-----------------------------------------------------------------------**
** $Header: /Diablo/ERROR.H 1 1/22/97 2:06p Dgartner $
**-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------**
** Defines
**-----------------------------------------------------------------------*/
#define MSG_NONE 0
#define MSG_AMAPTWN 1
#define MSG_MULTIBTN 2
#define MSG_SOUND 3
#define MSG_SHAREWARE 4
#define MSG_SAVESIZE 5
#define MSG_NOPAUSE 6
#define MSG_HDRIVE 7
#define MSG_SYNC 8 // Multi sync
#define MSG_MULTIPAUSE 9 // No multiplayer pause
#define MSG_LOADGAME 10
#define MSG_SAVEGAME 11
#define SHRINE_1 12 // Mysterious
#define SHRINE_2 13 // Hidden
#define SHRINE_3 14 // Gloomy
#define SHRINE_4 15 // Weird
#define SHRINE_5 16 // Magical
#define SHRINE_6 17 // Stone
#define SHRINE_7 18 // Religious
#define SHRINE_8 19 // Enchanted
#define SHRINE_9 20 // Thaumaturgic
#define SHRINE_10 21 // Fascinating
#define SHRINE_11 22 // Cryptic
#define SHRINE_12 23 // Supernatural
#define SHRINE_13 24 // Eldritch
#define SHRINE_14 25 // Eerie
#define SHRINE_15 26 // Divine
#define SHRINE_16 27 // Holy
#define SHRINE_17 28 // Sacred
#define SHRINE_18 29 // Spiritual
#define SHRINE_19 30 // Spooky
#define SHRINE_19B 31 // Spooky for multiplayer
#define SHRINE_20 32 // Abandoned
#define SHRINE_21 33 // Creepy
#define SHRINE_22 34 // Quiet
#define SHRINE_23 35 // Secluded
#define SHRINE_24 36 // Ornate
#define SHRINE_25 37 // Glimmering
#define SHRINE_26 38 // Tainted
#define SHRINE_26B 39 // Tainted for mulitplayer
#define SHRINE_27 44 // Oily
#define SHRINE_28 45 // Glowing
#define SHRINE_29 46 // Mendicants
#define SHRINE_30 47 // Edisons
#define SHRINE_31 48 // Town
#define SHRINE_32 49 // Energy
#define SHRINE_33A 50 // Time Morning
#define SHRINE_33B 51 // Time Afternoon
#define SHRINE_33C 52 // Time Evening
#define SHRINE_33D 53 // Time Night
#define SHRINE_34 54 // Murphy's
#define MSG_TRIG1 40 // Shortcut to catacombs
#define MSG_TRIG2 41 // Shortcut to caves
#define MSG_TRIG3 42 // Shortcut to hell
#define MSG_INBONE 43 // Book with spell in Bone Chamber
/*-----------------------------------------------------------------------**
** Structures
**-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------**
** Externs
**-----------------------------------------------------------------------*/
extern char msgflag;
extern char msgdelay;
/*-----------------------------------------------------------------------**
** Prototypes
**-----------------------------------------------------------------------*/
void InitDiabloMsg(char);
void ClrDiabloMsg();
void DrawDiabloMsg();

286
src/EXCEPT.CPP Normal file
View File

@ -0,0 +1,286 @@
//******************************************************************
// except.cpp
//******************************************************************
#include "diablo.h"
#pragma hdrstop
#include <tchar.h>
//******************************************************************
// private
//******************************************************************
class CExcept {
public:
CExcept();
~CExcept();
private:
// entry point where control comes on an unhandled exception
static LONG WINAPI ExceptionFilter(PEXCEPTION_POINTERS pExceptionInfo);
// variables used by the class
static TCHAR m_szLogFileName[MAX_PATH];
static LPTOP_LEVEL_EXCEPTION_FILTER m_previousFilter;
};
TCHAR CExcept::m_szLogFileName[MAX_PATH];
LPTOP_LEVEL_EXCEPTION_FILTER CExcept::m_previousFilter;
static CExcept g_CExcept;
//******************************************************************
//******************************************************************
static void __cdecl tprintf(HANDLE hFile,LPCTSTR pszFmt,...) {
va_list argptr;
DWORD cbWritten;
TCHAR szBuf[1024];
va_start(argptr,pszFmt);
int nChars = wvsprintf(szBuf,pszFmt,argptr);
WriteFile(hFile,szBuf,nChars * sizeof(TCHAR),&cbWritten,0);
va_end(argptr);
}
//******************************************************************
// Given a linear address,locates the module,section,and offset containing
// that address.
//
// Note: the szModule paramater buffer is an output buffer of length specified
// by the len parameter (in characters!)
//******************************************************************
static BOOL GetLogicalAddress(
PVOID addr,
PTSTR szModule,
DWORD len,
DWORD *pdwSection,
DWORD *pdwOffset
) {
MEMORY_BASIC_INFORMATION mbi;
if (!VirtualQuery(addr,&mbi,sizeof(mbi)))
return FALSE;
DWORD hMod = (DWORD)mbi.AllocationBase;
if (!GetModuleFileName((HMODULE)hMod,szModule,len))
return FALSE;
// Point to the DOS header in memory
PIMAGE_DOS_HEADER pDosHdr = (PIMAGE_DOS_HEADER)hMod;
// From the DOS header,find the NT (PE) header
PIMAGE_NT_HEADERS pNtHdr = (PIMAGE_NT_HEADERS)(hMod + pDosHdr->e_lfanew);
PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pNtHdr);
DWORD rva = (DWORD)addr - hMod; // RVA is offset from module load address
// Iterate through the section table,looking for the one that encompasses
// the linear address.
for (
unsigned i = 0;
i < pNtHdr->FileHeader.NumberOfSections;
i++,pSection++
) {
DWORD sectionStart = pSection->VirtualAddress;
DWORD sectionEnd = sectionStart
+ max(pSection->SizeOfRawData,pSection->Misc.VirtualSize);
// Is the address in this section???
if ((rva >= sectionStart) && (rva <= sectionEnd)) {
// Yes,address is in the section. Calculate section and offset
*pdwSection = i+1;
*pdwOffset = rva - sectionStart;
return TRUE;
}
}
return FALSE; // Should never get here!
}
//******************************************************************
//******************************************************************
static void IntelStackWalk(HANDLE hFile,PCONTEXT pContext) {
tprintf(hFile,_T("\r\nCall stack:\r\n"));
tprintf(hFile,_T("Address Frame Logical addr Module\r\n"));
DWORD pc = pContext->Eip;
PDWORD pFrame,pPrevFrame;
pFrame = (PDWORD)pContext->Ebp;
while (1) {
TCHAR szModule[MAX_PATH] = _T("");
DWORD section = 0,offset = 0;
GetLogicalAddress((PVOID)pc,szModule,sizeof(szModule),&section,&offset);
tprintf(hFile,_T("%08X %08X %04X:%08X %s\r\n"),
pc,pFrame,section,offset,szModule);
// precede to next higher frame on stack
pc = pFrame[1];
pPrevFrame = pFrame;
pFrame = (PDWORD)pFrame[0];
// Frame pointer must be aligned on a DWORD boundary
if ((DWORD)pFrame & 3) break;
if (pFrame <= pPrevFrame) break;
// Can two DWORDs be read from the supposed frame address?
if (IsBadWritePtr(pFrame,sizeof(PVOID)*2)) break;
}
}
//******************************************************************
//******************************************************************
static LPTSTR GetExceptionString(DWORD dwCode) {
#define EXCEPTION(x) case EXCEPTION_##x: return _T(#x);
switch (dwCode) {
EXCEPTION(ACCESS_VIOLATION)
EXCEPTION(DATATYPE_MISALIGNMENT)
EXCEPTION(BREAKPOINT)
EXCEPTION(SINGLE_STEP)
EXCEPTION(ARRAY_BOUNDS_EXCEEDED)
EXCEPTION(FLT_DENORMAL_OPERAND)
EXCEPTION(FLT_DIVIDE_BY_ZERO)
EXCEPTION(FLT_INEXACT_RESULT)
EXCEPTION(FLT_INVALID_OPERATION)
EXCEPTION(FLT_OVERFLOW)
EXCEPTION(FLT_STACK_CHECK)
EXCEPTION(FLT_UNDERFLOW)
EXCEPTION(INT_DIVIDE_BY_ZERO)
EXCEPTION(INT_OVERFLOW)
EXCEPTION(PRIV_INSTRUCTION)
EXCEPTION(IN_PAGE_ERROR)
EXCEPTION(ILLEGAL_INSTRUCTION)
EXCEPTION(NONCONTINUABLE_EXCEPTION)
EXCEPTION(STACK_OVERFLOW)
EXCEPTION(INVALID_DISPOSITION)
EXCEPTION(GUARD_PAGE)
EXCEPTION(INVALID_HANDLE)
}
#undef EXCEPTION
// If not one of the "known" exceptions, try to
// get the string from NTDLL.DLL's message table.
static TCHAR szBuf[512] = { 0 };
FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_HMODULE,
GetModuleHandle(_T("NTDLL.DLL")),
dwCode,0,szBuf,sizeof(szBuf),0);
return szBuf;
}
//******************************************************************
//******************************************************************
static void GenerateExceptionReport(HANDLE hFile,PEXCEPTION_POINTERS pExceptionInfo) {
PEXCEPTION_RECORD pExceptionRecord = pExceptionInfo->ExceptionRecord;
// First print information about the type of fault
tprintf(hFile,_T("Exception code: %08X %s\r\n"),
pExceptionRecord->ExceptionCode,
GetExceptionString(pExceptionRecord->ExceptionCode));
// Now print information about where the fault occured
TCHAR szFaultingModule[MAX_PATH];
DWORD section,offset;
GetLogicalAddress(pExceptionRecord->ExceptionAddress,
szFaultingModule,
sizeof(szFaultingModule),
&section,&offset);
tprintf(hFile,_T("Fault address: %08X %02X:%08X %s\r\n"),
pExceptionRecord->ExceptionAddress,
section,offset,szFaultingModule);
PCONTEXT pCtx = pExceptionInfo->ContextRecord;
// Show the registers
#ifdef _M_IX86 // Intel Only!
tprintf(hFile,_T("\r\nRegisters:\r\n"));
tprintf(hFile,_T("EAX:%08X\r\nEBX:%08X\r\nECX:%08X\r\nEDX:%08X\r\nESI:%08X\r\nEDI:%08X\r\n"),
pCtx->Eax,pCtx->Ebx,pCtx->Ecx,pCtx->Edx,pCtx->Esi,pCtx->Edi);
tprintf(hFile,_T("CS:EIP:%04X:%08X\r\n"),pCtx->SegCs,pCtx->Eip);
tprintf(hFile,_T("SS:ESP:%04X:%08X EBP:%08X\r\n"),
pCtx->SegSs,pCtx->Esp,pCtx->Ebp);
tprintf(hFile,_T("DS:%04X ES:%04X FS:%04X GS:%04X\r\n"),
pCtx->SegDs,pCtx->SegEs,pCtx->SegFs,pCtx->SegGs);
tprintf(hFile,_T("Flags:%08X\r\n"),pCtx->EFlags);
// Walk the stack using x86 specific code
IntelStackWalk(hFile,pCtx);
#endif
tprintf(hFile,_T("\r\n"));
}
//******************************************************************
//******************************************************************
LONG WINAPI CExcept::ExceptionFilter(PEXCEPTION_POINTERS pExceptionInfo) {
// try opening the error report file in the program directory
// if we can't open the file, it may be because the app
// is running from a CDROM drive -- try opening a file
// with the same name in c:
HANDLE hFile;
for (int i = 0; i < 2; i++) {
hFile = CreateFile(
m_szLogFileName,
GENERIC_WRITE,
0,
0,
OPEN_ALWAYS,
FILE_FLAG_WRITE_THROUGH,
0
);
if (hFile != INVALID_HANDLE_VALUE) break;
// extract the file name
LPTSTR lpFName = _tcsrchr(m_szLogFileName,_T('\\'));
if (! lpFName) break;
// create full path to file in C:
TCHAR szTemp[MAX_PATH] = _T("c:\\");
_tcscat(szTemp,lpFName);
_tcscpy(m_szLogFileName,szTemp);
}
if (hFile != INVALID_HANDLE_VALUE) {
SetFilePointer(hFile,0,0,FILE_END);
GenerateExceptionReport(hFile,pExceptionInfo);
CloseHandle(hFile);
}
if (m_previousFilter) return m_previousFilter(pExceptionInfo);
return EXCEPTION_CONTINUE_SEARCH;
}
//******************************************************************
//******************************************************************
CExcept::CExcept() {
// Install the unhandled exception filter function
m_previousFilter = SetUnhandledExceptionFilter(ExceptionFilter);
// Figure out what the report file will be named,and store it away
GetModuleFileName(0,m_szLogFileName,MAX_PATH);
// replace .EXE with .ERR
PTSTR pszDot = _tcsrchr(m_szLogFileName,_T('.'));
if (pszDot) {
pszDot++;
if (_tcslen(pszDot) >= 3)
_tcscpy(pszDot,_T("ERR"));
}
// delete any old exception reports
DeleteFile(m_szLogFileName);
}
//******************************************************************
//******************************************************************
CExcept::~CExcept() {
SetUnhandledExceptionFilter(m_previousFilter);
}

25
src/FIXES.TXT Normal file
View File

@ -0,0 +1,25 @@
*) Fixed the bug where picking up gold when your inventory is full
duplicates the gold in your hand and fills your gold slot.
*) Fixed the Berserk spell to prevent crashes.
*) Fixed entering the new levels.
*) Fixed to dropping and picking back up oiled items.
*) Fixed generating spell books by Adria.
*) Fixed placing of weapons for all player classes.
*) Fixed generating rings of fire behind a wall.
Donald:
*) Fixed Gosip.
*) Fix to item changing between games.
12/29/97
*)Fix to gold cursor when full of gold in inventory.

13
src/FUTURES.TXT Normal file
View File

@ -0,0 +1,13 @@
Bad Priest:
Low max strength:
Medium armor cuts spell level in half.
Full armor sets spell level to 1.
Daggers and small swords are best.
Large weapons don't do full damage. (Priest is too weak)
Benefit: mana cost is really low. Heal other in Multiplayer mode

485
src/GAMEMENU.CPP Normal file
View File

@ -0,0 +1,485 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Game Menu file
**
** (C)1995 Condor, Inc. All rights reserved.
**
**-----------------------------------------------------------------------**
** $Header: /Diablo/GAMEMENU.CPP 1 1/22/97 2:06p Dgartner $
**-----------------------------------------------------------------------*/
#include "diablo.h"
#pragma hdrstop
#include "gendung.h"
#include "sound.h"
#include "gamemenu.h"
#include "scrollrt.h"
#include "multi.h"
#include "cursor.h"
#include "items.h"
#include "player.h"
#include "error.h"
#include "palette.h"
#include "effects.h"
#include "msg.h"
#include "storm.h"
//******************************************************************
// extern
//******************************************************************
extern BOOL gbRunGame;
extern BOOL gbRunGameResult;
extern BOOL deathflag;
void sound_stop();
void GM_SaveGame();
void GM_LoadGame(BOOL firstflag);
LRESULT CALLBACK DisableInputWndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
void interface_msg_pump();
WNDPROC my_SetWindowProc(WNDPROC wndProc);
/*extern*/ DWORD gbWalkOn = TRUE;
extern char gszProgKey[];
void CornerstoneSave();
//******************************************************************
// private
//******************************************************************
// menu functions
static void fnNew(BOOL bActivate);
static void fnLoad(BOOL bActivate);
static void fnOptions(BOOL bActivate);
static void fnSave(BOOL bActivate);
static void fnQuit(BOOL bActivate);
static void fnRestart(BOOL bActivate);
static void fnMusic(BOOL bActivate);
static void fnSound(BOOL bActivate);
static void fnWalk(BOOL bActivate);
static void fnGamma(BOOL bActivate);
static void fnOptionPrevious(BOOL bActivate);
static void fnReturnToGame(BOOL bActivate);
static void fnSaveAndQuit(BOOL bActivate);
// menus
#define OPTION_SINGLE_SAVE 0
#define OPTION_SINGLE_LOAD 3
static TMenuItem sgSingleMenu[] = {
{ mf_ENABLED, "Save Game", fnSave },
{ mf_ENABLED, "Options", fnOptions },
{ mf_ENABLED, "New Game", fnNew },
{ mf_ENABLED, "Load Game", fnLoad },
{ mf_ENABLED, "Quit Hellfire", fnQuit },
{ mf_ENABLED, NULL, NULL }
};
#define OPTION_MULTI_RESTART 2
static TMenuItem sgMultiMenu[] = {
{ mf_ENABLED, "Options", fnOptions },
{ mf_ENABLED, "New Game", fnNew },
{ mf_ENABLED, "Restart In Town", fnRestart },
{ mf_ENABLED, "Quit Hellfire", fnQuit },
{ mf_ENABLED, NULL, NULL }
};
#define OPTION_MUSIC 0
#define OPTION_SOUND 1
#define OPTION_GAMMA 2
#define OPTION_WALK 3
static TMenuItem sgOptionsMenu[] = {
{ mf_ENABLED | mf_SLIDER, NULL, fnMusic },
{ mf_ENABLED | mf_SLIDER, NULL, fnSound },
{ mf_ENABLED | mf_SLIDER, "Gamma", fnGamma },
{ mf_ENABLED | mf_SLIDER, NULL, fnWalk },
{ mf_ENABLED, "Previous Menu", fnOptionPrevious },
{ mf_ENABLED, NULL, NULL }
};
// strings for options menu
#define SM_ON 0
#define SM_DISABLED 1
static const char * sgszMusic[] = {
"Music",
"Music Disabled",
};
static const char * sgszSound[] = {
"Sound",
"Sound Disabled",
};
static const char * sgszWalk[] = {
"Jog",
"Walk",
};
const char * sgszWalkId = "Fast Walk";
//******************************************************************
//******************************************************************
static void gm_single_update(TMenuItem * pMenuItems) {
app_assert(pMenuItems == sgSingleMenu);
gmenu_set_enable(&sgSingleMenu[OPTION_SINGLE_LOAD],gbValidSaveFile);
gmenu_set_enable(
&sgSingleMenu[OPTION_SINGLE_SAVE],
plr[myplr]._pmode != PM_DEATH && !deathflag
);
}
//******************************************************************
//******************************************************************
static void gm_multi_update(TMenuItem * pMenuItems) {
app_assert(pMenuItems == sgMultiMenu);
gmenu_set_enable(&sgMultiMenu[OPTION_MULTI_RESTART],deathflag);
}
//******************************************************************
//******************************************************************
void gamemenu_on() {
if (gbMaxPlayers == 1)
gmenu_set_menu(sgSingleMenu,gm_single_update);
else
gmenu_set_menu(sgMultiMenu,gm_multi_update);
// remove all junky windows under the menu
extern BOOL clear_windows();
clear_windows();
}
//******************************************************************
//******************************************************************
void gamemenu_off() {
gmenu_set_menu(NULL,NULL);
}
//******************************************************************
//******************************************************************
void gamemenu_toggle() {
if (gmenu_is_on())
gamemenu_off();
else
gamemenu_on();
}
//******************************************************************
//******************************************************************
static void fnOptionPrevious(BOOL bActivate) {
app_assert(bActivate);
gamemenu_on();
}
//******************************************************************
//******************************************************************
static void fnNew(BOOL bActivate) {
app_assert(bActivate);
for (int i = 0; i < MAX_PLRS; i++) {
plr[i]._pmode = PM_QUIT;
plr[i]._pInvincible = TRUE;
}
deathflag = FALSE;
force_redraw = FULLDRAW;
FullBlit(TRUE);
CornerStone.Initted = FALSE;
// stop running game loop
gbRunGame = FALSE;
gamemenu_off();
}
//******************************************************************
//******************************************************************
static void fnQuit(BOOL bActivate) {
app_assert(bActivate);
fnNew(bActivate);
gbRunGameResult = FALSE;
}
//******************************************************************
//******************************************************************
static void fnLoad(BOOL bActivate) {
app_assert(bActivate);
app_assert(gbMaxPlayers == 1);
app_assert(gbValidSaveFile);
// set window proc to function which will ignore input
app_assert(ghMainWnd);
WNDPROC saveProc = my_SetWindowProc(DisableInputWndProc);
gamemenu_off();
SetCursor(NO_CURSOR);
InitDiabloMsg(MSG_LOADGAME);
force_redraw = FULLDRAW;
DrawAndBlit();
GM_LoadGame(FALSE);
ClrDiabloMsg();
CornerStone.Initted = FALSE;
PaletteFadeOut(FADE_FAST);
deathflag = FALSE;
force_redraw = FULLDRAW;
DrawAndBlit();
PaletteFadeIn(FADE_FAST);
SetCursor(GLOVE_CURS);
// flush out all the messages and restore old wndproc
interface_msg_pump();
saveProc = my_SetWindowProc(saveProc);
app_assert(saveProc == DisableInputWndProc);
}
//******************************************************************
//******************************************************************
static void fnSave(BOOL bActivate) {
app_assert(bActivate);
app_assert(gbMaxPlayers == 1);
if (curs != GLOVE_CURS) {
// @@@ how bout an error msg
return;
}
if (plr[myplr]._pmode == PM_DEATH || deathflag) {
gamemenu_off();
return;
}
// set window proc to function which will ignore input
app_assert(ghMainWnd);
WNDPROC saveProc = my_SetWindowProc(DisableInputWndProc);
SetCursor(NO_CURSOR);
gamemenu_off();
InitDiabloMsg(MSG_SAVEGAME);
force_redraw = FULLDRAW;
DrawAndBlit();
GM_SaveGame();
ClrDiabloMsg();
force_redraw = FULLDRAW;
SetCursor(GLOVE_CURS);
// update the Cornerstone of the World
if (CornerStone.Initted)
CornerstoneSave();
// flush out all the messages and restore old wndproc
interface_msg_pump();
saveProc = my_SetWindowProc(saveProc);
app_assert(saveProc == DisableInputWndProc);
}
//******************************************************************
//******************************************************************
static void fnRestart(BOOL bActivate) {
app_assert(bActivate);
NetSendCmd(TRUE, CMD_RETOWN);
}
//******************************************************************
//******************************************************************
static void set_volume_item(const char ** ppStrs,TMenuItem * pItem,LONG lVolume) {
if (gbSndInited) {
pItem->dwFlags |= mf_ENABLED | mf_SLIDER;
pItem->pszStr = ppStrs[SM_ON];
gmenu_set_slider_ticks(pItem,VOLUME_TICKS);
gmenu_set_slider(pItem,VOLUME_MIN,VOLUME_MAX,lVolume);
}
else {
pItem->dwFlags &= ~(mf_ENABLED | mf_SLIDER);
pItem->pszStr = ppStrs[SM_DISABLED];
}
}
//******************************************************************
//******************************************************************
static LONG get_volume_item(const TMenuItem * pItem) {
return gmenu_get_slider(pItem,VOLUME_MIN,VOLUME_MAX);
}
//******************************************************************
//******************************************************************
static void set_music_item() {
set_volume_item(sgszMusic,&sgOptionsMenu[OPTION_MUSIC],music_volume(VOLUME_READ));
}
//******************************************************************
//******************************************************************
static void set_sound_item() {
set_volume_item(sgszSound,&sgOptionsMenu[OPTION_SOUND],sound_volume(VOLUME_READ));
}
//******************************************************************
//******************************************************************
static void set_walk_item() {
gmenu_set_slider_ticks(&sgOptionsMenu[OPTION_WALK],2);
gmenu_set_slider(
&sgOptionsMenu[OPTION_WALK], 0, 1, gbWalkOn);
sgOptionsMenu[OPTION_WALK].pszStr =
sgszWalk[(gbWalkOn)?SM_ON:SM_DISABLED];
}
//******************************************************************
//******************************************************************
static void set_gamma_item() {
gmenu_set_slider_ticks(&sgOptionsMenu[OPTION_GAMMA],lGAMMA_TICKS);
gmenu_set_slider(
&sgOptionsMenu[OPTION_GAMMA],
lGAMMA_MIN,
lGAMMA_MAX,
GammaLevel(lGAMMA_READ)
);
}
//******************************************************************
//******************************************************************
static LONG get_gamma_item() {
return gmenu_get_slider(
&sgOptionsMenu[OPTION_GAMMA],
lGAMMA_MIN,
lGAMMA_MAX
);
}
//******************************************************************
//******************************************************************
static void fnOptions(BOOL bActivate) {
app_assert(bActivate);
set_music_item();
set_sound_item();
set_walk_item();
set_gamma_item();
gmenu_set_menu(sgOptionsMenu,NULL);
}
//******************************************************************
//******************************************************************
static void fnMusic(BOOL bActivate) {
if (bActivate) {
if (gbMusicOn) {
gbMusicOn = FALSE;
music_stop();
music_volume(VOLUME_MIN);
}
else {
gbMusicOn = TRUE;
music_volume(VOLUME_MAX);
if (currlevel >= HIVESTART) // fix this later JKE
{
music_start((currlevel > HIVEEND)? 5 : 6);
}
else
music_start(leveltype);
}
}
else {
LONG lVolume = get_volume_item(&sgOptionsMenu[OPTION_MUSIC]);
music_volume(lVolume);
if (lVolume == VOLUME_MIN) {
if (gbMusicOn) {
gbMusicOn = FALSE;
music_stop();
}
}
else {
if (! gbMusicOn) {
gbMusicOn = TRUE;
if (currlevel >= HIVESTART) // fix this later JKE
{
music_start((currlevel > HIVEEND)? 5 : 6);
}
else
music_start(leveltype);
}
}
}
set_music_item();
}
//******************************************************************
//******************************************************************
static void fnSound(BOOL bActivate) {
if (bActivate) {
if (gbSoundOn) {
gbSoundOn = FALSE;
sound_stop();
sound_volume(VOLUME_MIN);
}
else {
gbSoundOn = TRUE;
sound_volume(VOLUME_MAX);
}
}
else {
LONG lVolume = get_volume_item(&sgOptionsMenu[OPTION_SOUND]);
sound_volume(lVolume);
if (lVolume == VOLUME_MIN) {
if (gbSoundOn) {
gbSoundOn = FALSE;
sound_stop();
}
}
else {
if (! gbSoundOn) {
gbSoundOn = TRUE;
}
}
}
PlaySFX(IS_TITLEMOV);
set_sound_item();
}
static void fnWalk(BOOL bActivate) {
if (gbMaxPlayers != 1) // single-player only
return;
if (gbWalkOn) {
gbWalkOn = FALSE;
}
else {
gbWalkOn = TRUE;
}
SRegSaveValue(gszProgKey,sgszWalkId,0,gbWalkOn);
PlaySFX(IS_TITLEMOV);
set_walk_item();
}
//******************************************************************
//******************************************************************
static void fnGamma(BOOL bActivate) {
LONG lGamma;
if (bActivate) {
lGamma = GammaLevel(lGAMMA_READ);
if (lGamma == lGAMMA_MIN)
lGamma = lGAMMA_MAX;
else
lGamma = lGAMMA_MIN;
}
else {
lGamma = get_gamma_item();
}
GammaLevel(lGamma);
set_gamma_item();
}

56
src/GAMEMENU.H Normal file
View File

@ -0,0 +1,56 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Constants and Variables
**
** (C)1995 Condor, Inc. All rights reserved.
**-----------------------------------------------------------------------**
** $Header: /Diablo/GAMEMENU.H 1 1/22/97 2:06p Dgartner $
**-----------------------------------------------------------------------*/
//******************************************************************
//******************************************************************
#define mf_ENABLED 0x80000000
#define mf_SLIDER 0x40000000
typedef void (* TMenuFcn)(BOOL bActivate);
typedef struct TMenuItem {
DWORD dwFlags;
const char * pszStr;
TMenuFcn fnMenu;
} TMenuItem;
typedef void (* TMenuUpdateFcn)(TMenuItem * pMenuItems);
//******************************************************************
// menu functions
//******************************************************************
void gmenu_init();
void gmenu_free();
void gmenu_draw();
BOOL gmenu_is_on();
BOOL gmenu_click(BOOL bMouseDown);
BOOL gmenu_mousemove();
BOOL gmenu_key(WPARAM wKey);
void gmenu_set_menu(TMenuItem * pMenuItems,TMenuUpdateFcn fnUpdate);
void gmenu_set_enable(TMenuItem * pMenuItem,BOOL bEnable);
void gmenu_set_slider(TMenuItem * pItem,LONG lMin,LONG lMax,LONG lVal);
LONG gmenu_get_slider(const TMenuItem * pItem,LONG lMin,LONG lMax);
void gmenu_set_slider_ticks(TMenuItem * pMenuItem,DWORD dwTicks);
//******************************************************************
// gamemenu functions
//******************************************************************
void gamemenu_toggle();
void gamemenu_on();
void gamemenu_off();
//******************************************************************
// other prototypes
//******************************************************************
void GM_LoadGame(BOOL);
void SaveLevel();
void LoadLevel();

1209
src/GENDUNG.CPP Normal file

File diff suppressed because it is too large Load Diff

234
src/GENDUNG.H Normal file
View File

@ -0,0 +1,234 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Constants and Variables
**
** (C)1995 Condor, Inc. All rights reserved.
**-----------------------------------------------------------------------**
** $Header: /Diablo/GENDUNG.H 1 1/22/97 2:06p Dgartner $
**-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------**
** Defines
**-----------------------------------------------------------------------*/
#define LVLLENGTH 4
#define TLVL_START 0
#define LVL1_START 1
#define LVL2_START LVL1_START+LVLLENGTH
#define LVL3_START LVL2_START+LVLLENGTH
#define LVL4_START LVL3_START+LVLLENGTH
//HellFire JKE 7/29
#define LVL5_START LVL4_START+LVLLENGTH
#define CRYPTSTART 21
#define CRYPTEND 24
#define HIVESTART 17
#define HIVEEND 20
//#define NUMLEVELS ((4*LVLLENGTH)+1)
#define NUMLEVELS ((6*LVLLENGTH)+1) //HellFire JKE 7/29
#define NUMSLEVELS 10
#define DIRTEDGE 32
#define DIRTEDGED2 (DIRTEDGE/2)
#define DMAXX (80+DIRTEDGE)
#define DMAXY (80+DIRTEDGE)
#define MAXDUNX DMAXX
#define MAXDUNY DMAXY
#define MDMAXX ((DMAXX-DIRTEDGE)/2) // Mega tile dungeon max (max div 2)
#define MDMAXY ((DMAXY-DIRTEDGE)/2)
#define MAXTILES 2048
#define MAXMREND 128
#define NUMSPEEDCELS 64
#define SPEEDSIZE NUMSPEEDCELS*16384
#define MAXMICRO 2048
#define MAXDIRT 32
#define NODRAW 0
#define VIEWDRAW 1
#define FULLDRAW 0xff
#define SCRL_NONE 0
#define SCRL_U 1
#define SCRL_UR 2
#define SCRL_R 3
#define SCRL_DR 4
#define SCRL_D 5
#define SCRL_DL 6
#define SCRL_L 7
#define SCRL_UL 8
// bFlags bits
#define BFLAG_AUTOMAP 0x80
#define BFLAG_VISIBLE 0x40
#define BFLAG_PLRLR 0x20
#define BFLAG_MONSTLR 0x10
#define BFLAG_SETPC 0x08
#define BFLAG_DEADPLR 0x04
// Set Piece bit used in all drlg's
#define SETP_BIT 0x80 // Non changeable set piece bit
#define BFLAG_MONSTACTIVE 0x02
#define BFLAG_MISSILE 0x01
#define BFMASK_AUTOMAP 0x7f
#define BFMASK_VISIBLE 0xbf
#define BFMASK_PLRLR 0xdf
#define BFMASK_MONSTLR 0xef
#define BFMASK_SETPC 0xf7
//#define BFMASK_UNUSED 0xfb
//#define BFMASK_UNUSED 0xfd
#define BFMASK_MISSILE 0xfe
#define WTYPE_NONE 0
#define WTYPE_LEFT 1
#define WTYPE_RIGHT 2
#define WTYPE_ULC 3
#define WTYPE_LRC 4
#define D_NORMAL 0
#define D_NIGHTMARE 1
#define D_HELL 2
/*-----------------------------------------------------------------------**
** Macros
**-----------------------------------------------------------------------*/
#define MegaToMini(M) ((M << 1) + DIRTEDGED2)
#define MiniToMega(m) ((m - DIRTEDGED2) >> 1)
/*-----------------------------------------------------------------------**
** Structures
**-----------------------------------------------------------------------*/
typedef struct {
byte strig;
byte s1;
byte s2;
byte s3;
byte nv1;
byte nv2;
byte nv3;
} ShadowStruct;
typedef struct {
int _sxoff; // Smooth scroll x,y offsets
int _syoff;
int _sdx; // Delta between plr and view x,y
int _sdy;
int _sdir; // Direction
} ScrollStruct;
typedef struct THEME_LOC {
int x; //Upper left coord
int y; //Upper left coord
int ttval; //Transparency value
int width; //Room width
int height; //Room height
} THEME_LOC;
/*-----------------------------------------------------------------------**
** Externs
**-----------------------------------------------------------------------*/
extern byte dungeon[MDMAXX][MDMAXY];
extern byte pdungeon[MDMAXX][MDMAXY];
extern byte dflags[MDMAXX][MDMAXY];
extern int setpc_x, setpc_y, setpc_w, setpc_h;
extern byte *pSetPiece;
extern BOOL setloadflag;
extern "C" {
extern BYTE *pDungeonCels;
extern BYTE *pSpeedCels;
extern long microoffset[MAXMREND][16];
extern byte nWTypeTable[MAXTILES+1];
}
extern BYTE *pSpecialCels;
extern BYTE *pMegaTiles;
extern BYTE *pMiniTiles;
extern BYTE nBlockTable[MAXTILES+1];
extern BYTE nSolidTable[MAXTILES+1];
extern BYTE nTransTable[MAXTILES+1];
extern BYTE nMissileTable[MAXTILES+1];
extern BYTE nTrapTable[MAXTILES+1];
extern int dminx, dminy, dmaxx, dmaxy;
extern int gnDifficulty;
extern BYTE currlevel;
extern BYTE leveltype;
extern BYTE setlevel;
extern BYTE setlvlnum;
extern BYTE setlvltype;
extern int ViewX, ViewY;
extern int ViewDX, ViewDY;
extern int ViewBX, ViewBY;
extern ScrollStruct ScrollInfo;
extern int LvlViewX, LvlViewY;
extern int btmbx, btmby;
extern int btmdx, btmdy;
extern int MicroTileLen;
extern char TransVal;
extern BYTE TransList[256];
extern int dPiece[MAXDUNX][MAXDUNY]; // Tile #
typedef struct { WORD mt[16]; } MICROS;
extern MICROS dMT[MAXDUNX][MAXDUNY]; // Micro Tiles
extern MICROS dMT2[MAXDUNX*MAXDUNY];
extern char dTransVal[MAXDUNX][MAXDUNY]; // Transparent active value
extern char dLight[MAXDUNX][MAXDUNY]; // Current light value
extern char dSaveLight[MAXDUNX][MAXDUNY]; // Static light value
extern char dFlags[MAXDUNX][MAXDUNY]; // Flags for Solid collision, etc.
extern char dPlayer[MAXDUNX][MAXDUNY]; // Player
extern int dMonster[MAXDUNX][MAXDUNY]; // Monster
extern char dDead[MAXDUNX][MAXDUNY]; // Dead plr/monster
extern char dObject[MAXDUNX][MAXDUNY]; // Objects
extern char dItem[MAXDUNX][MAXDUNY]; // Items
extern char dMissile[MAXDUNX][MAXDUNY]; // Missiles (0 = none, # = missile, -1 = two or more)
extern char dSpecial[MAXDUNX][MAXDUNY]; // Second layer of tiling
extern int themeCount;
extern THEME_LOC themeLoc[50];
/*-----------------------------------------------------------------------**
** Prototypes
**-----------------------------------------------------------------------*/
int CalcRot(int x, int y);
void SetDungeonMicros();
void FillSolidBlockTbls ();
void DRLG_InitTrans();
void DRLG_MRectTrans(int, int, int, int);
void DRLG_MCopyTrans(int, int, int, int, BOOL, BOOL, BOOL, BOOL);
void DRLG_RectTrans(int, int, int, int);
void DRLG_CopyTrans(int, int, int, int);
void DRLG_ListTrans(int, byte *);
void DRLG_AreaTrans(int, byte *);
void DRLG_InitSetPC();
void DRLG_SetPC();
void Make_SetPC(int x, int y, int w, int h);
void DrawDungMiniMap(unsigned char floor);
BOOL DRLG_WillThemeRoomFit(int, int, int, int, int, int *, int *);
void DRLG_CreateThemeRoom(int);
void DRLG_PlaceThemeRooms(int, int, int, int, BOOL);
void DRLG_HoldThemeRooms();
BOOL SkipThemeRoom(int, int);

527
src/GMENU.CPP Normal file
View File

@ -0,0 +1,527 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Game Menu file
**
** (C)1995 Condor, Inc. All rights reserved.
**
**-----------------------------------------------------------------------**
** $Header: /Diablo/GMENU.CPP 1 1/22/97 2:06p Dgartner $
**-----------------------------------------------------------------------**
**
** File Routines
**-----------------------------------------------------------------------*/
#include "diablo.h"
#pragma hdrstop
#include "sound.h"
#include "gendung.h"
#include "gamemenu.h"
#include "scrollrt.h"
#include "engine.h"
#include "effects.h"
//******************************************************************
// extern
//******************************************************************
void RedBack();
//******************************************************************
// kerning
//******************************************************************
#define KERNSPACE 2
static const BYTE mfonttrans[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0-15
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16-31
0, 37, 49, 38, 0, 39, 40, 47, 42, 43, 41, 45, 52, 44, 53, 55, // 32-47
36, 27, 28, 29, 30, 31, 32, 33, 34, 35, 51, 50, 0, 46, 0, 54, // 48-63
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, // 64-79
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 42, 0, 43, 0, 0, // 80-95
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, // 96-111
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 20, 0, 21, 0, 0 // 112-127
};
static const BYTE mfontkern[56] = { 18, // Space/Invalid
33, 21, 26, 28, 19, 19, 26, 25, 11, 12, 25, 19, 34, 28, 32, 20, // a-p
32, 28, 20, 28, 36, 35, 46, 33, 33, 24, // q-z
11, 23, 22, 22, 21, 22, 21, 21, 21, 32, // 1-0
10, 20, 36, 31, 17, 13, 12, 13, 18, 16, 11, 20, 21, 11, 10, 12, 11, 21, 23 // misc
};
//******************************************************************
// private data
//******************************************************************
static BYTE sgbGameSpin;
static BYTE sgbTitleAnimate;
static BYTE * sgpLogo;
static BYTE * sgpSpinCels;
static BYTE * sgpMenuCels;
static BYTE * sgpSliderCels;
static BYTE * sgpBarCels;
static TMenuItem * sgpMenu;
static TMenuUpdateFcn sgfnMenuUpdateFcn;
static TMenuItem * sgpCurrItem;
static DWORD sgdwMenuItems;
static long sglSpinnerTime;
static long sglTitleTime;
static BYTE sgbTracking;
#define MENU_STARTY 320
#define MENU_CLICKY (MENU_STARTY - 203)
#define MENU_LINEHGT 45
#define SLIDER_WDT 256
#define SLIDER_ITEM_WDT 27
#define SLIDER_TOTAL_WDT 490
#define ENABLE_LVAL 0
#define DISABLE_LVAL 15
#define MIN_SLIDER_TICKS 2
#define SLIDER_TICK_SHIFT 12
#define MAX_SLIDER_TICKS 0xfff
#define mf_SLIDER_VAL_MASK 0x00000fff
#define mf_SLIDER_TICK_MASK 0x00fff000
#define SPINNER_TIME 25 // milliseconds
#define TITLE_TIME 25 // milliseconds
//******************************************************************
//******************************************************************
static void DrawBigFontXY(int x, int y,const char * pszStr) {
app_assert(pszStr);
while (*pszStr) {
BYTE c = char2print(*pszStr++);
c = mfonttrans[c];
if (c != 0) DrawCelL(x, y, sgpMenuCels, c, 46);
x += mfontkern[c] + KERNSPACE;
}
}
//******************************************************************
//******************************************************************
void DrawPause() {
if (currlevel != 0) RedBack();
if (! sgpMenu) {
nLVal = 0; // set light level
DrawBigFontXY(316, 336, "Pause");
}
}
//******************************************************************
//******************************************************************
void gmenu_free() {
DiabloFreePtr(sgpLogo);
DiabloFreePtr(sgpMenuCels);
DiabloFreePtr(sgpSpinCels);
DiabloFreePtr(sgpSliderCels);
DiabloFreePtr(sgpBarCels);
}
//******************************************************************
//******************************************************************
void gmenu_init() {
sgbGameSpin = 1;
sgbTitleAnimate = 1;
sgpMenu = NULL;
sgpCurrItem = NULL;
sgfnMenuUpdateFcn = NULL;
sgdwMenuItems = 0;
sgbTracking = FALSE;
app_assert(! sgpLogo);
//sgpLogo = LoadFileInMemSig("Data\\Diabsmal.CEL",NULL,'MENU');
sgpLogo = LoadFileInMemSig("Data\\hf_logo3.CEL",NULL,'MENU');
sgpMenuCels = LoadFileInMemSig("Data\\BigTGold.CEL",NULL,'MENU');
sgpSpinCels = LoadFileInMemSig("Data\\PentSpin.CEL",NULL,'MENU');
sgpSliderCels = LoadFileInMemSig("Data\\option.CEL",NULL,'MENU');
sgpBarCels = LoadFileInMemSig("Data\\optbar.CEL",NULL,'MENU');
}
//******************************************************************
//******************************************************************
BOOL gmenu_is_on() {
return sgpMenu != NULL;
}
//******************************************************************
//******************************************************************
static void gmenu_change(BOOL bNext) {
if (! sgpCurrItem) return;
sgbTracking = FALSE;
for (DWORD d = sgdwMenuItems; d--; ) {
if (bNext) {
// next item
sgpCurrItem++;
// wrap at end of list
if (! sgpCurrItem->fnMenu)
sgpCurrItem = sgpMenu;
}
else {
// wrap at beginning of list
if (sgpCurrItem == sgpMenu)
sgpCurrItem = sgpMenu + sgdwMenuItems;
// prev item
sgpCurrItem--;
}
if (sgpCurrItem->dwFlags & mf_ENABLED) {
if (d) PlaySFX(IS_TITLEMOV);
break;
}
}
}
//******************************************************************
//******************************************************************
void gmenu_set_menu(TMenuItem * pMenuItems,TMenuUpdateFcn fnUpdate) {
PauseMode = 0;
sgpMenu = pMenuItems;
sgbTracking = FALSE;
sgfnMenuUpdateFcn = fnUpdate;
if (sgfnMenuUpdateFcn) sgfnMenuUpdateFcn(sgpMenu);
// calculate number of items in menu
sgdwMenuItems = 0;
if (sgpMenu) {
for (TMenuItem * pItem = sgpMenu; pItem->fnMenu; pItem++)
sgdwMenuItems++;
}
// move to the first active item in the menu
sgpCurrItem = sgpMenu + sgdwMenuItems - 1;
gmenu_change(TRUE);
}
//******************************************************************
//******************************************************************
static void DrawBar(DWORD x,DWORD y,DWORD wdt,DWORD hgt) {
app_assert(gpBuffer);
BYTE * pbDst = gpBuffer + nBuffWTbl[y] + x;
while (hgt--) {
FillMemory(pbDst,wdt,0xcd);
pbDst -= 768;
}
}
//******************************************************************
//******************************************************************
static DWORD gmenu_calc_item_width(const TMenuItem * pItem) {
// hardcode the size of sliders so they all justify uniformly
// so that the slider bars line up vertically
if (pItem->dwFlags & mf_SLIDER)
return SLIDER_TOTAL_WDT;
DWORD wdt = 0;
const char * pszStr = pItem->pszStr;
while (*pszStr) {
BYTE c = char2print(*pszStr++);
c = mfonttrans[c];
wdt += mfontkern[c] + KERNSPACE;
}
wdt -= KERNSPACE;
return wdt;
}
//******************************************************************
//******************************************************************
static void gmenu_draw_item(const TMenuItem * pItem,int yPos) {
DWORD wdt = gmenu_calc_item_width(pItem);
if (pItem->dwFlags & mf_SLIDER) {
int xPos = 640/2 + wdt/2 + 43 - SLIDER_WDT - SLIDER_ITEM_WDT;
DrawCel(xPos + 0,yPos - 10,sgpBarCels, 1, 287);
DWORD dwLen = pItem->dwFlags & mf_SLIDER_VAL_MASK;
// scale 0..ticks to 0..SLIDER_WDT
DWORD dwTicks = pItem->dwFlags & mf_SLIDER_TICK_MASK;
dwTicks >>= SLIDER_TICK_SHIFT;
if (dwTicks < MIN_SLIDER_TICKS) dwTicks = MIN_SLIDER_TICKS;
dwLen *= SLIDER_WDT;
dwLen /= dwTicks;
DrawBar(xPos + 2,yPos - 12,dwLen + SLIDER_ITEM_WDT/2,28);
xPos += dwLen;
DrawCel(xPos + 2,yPos - 12,sgpSliderCels, 1, 27);
}
// draw string with lighting
int xPos = 640/2 - wdt/2 + 64;
nLVal = (pItem->dwFlags & mf_ENABLED) ? ENABLE_LVAL : DISABLE_LVAL;
DrawBigFontXY(xPos, yPos, pItem->pszStr);
if (pItem == sgpCurrItem) {
DrawCel(xPos - 54, yPos + 1, sgpSpinCels, sgbGameSpin, 48);
DrawCel(xPos + wdt + 4, yPos + 1, sgpSpinCels, sgbGameSpin, 48);
}
}
//******************************************************************
//******************************************************************
void gmenu_draw() {
if (! sgpMenu) return;
if (sgfnMenuUpdateFcn) sgfnMenuUpdateFcn(sgpMenu);
const TMenuItem * pItem;
long lCurrTime = (long) GetTickCount();
//DrawCel(236, 262, sgpLogo, 1, 296);
if (lCurrTime - sglTitleTime > TITLE_TIME){
++sgbTitleAnimate;
if (sgbTitleAnimate > 16) sgbTitleAnimate = 1;
sglTitleTime = lCurrTime;
}
DrawCel(169, 262, sgpLogo, sgbTitleAnimate, 430);
// draw items
DWORD yPos = MENU_STARTY;
for (pItem = sgpMenu; pItem->fnMenu; pItem++) {
gmenu_draw_item(pItem,yPos);
yPos += MENU_LINEHGT;
}
// adjust spinner
if (lCurrTime - sglSpinnerTime > SPINNER_TIME) {
sgbGameSpin++;
if (sgbGameSpin == 9) sgbGameSpin = 1;
sglSpinnerTime = lCurrTime;
}
}
//******************************************************************
//******************************************************************
static void gmenu_slider(BOOL bNext) {
if (! (sgpCurrItem->dwFlags & mf_SLIDER)) return;
LONG lVal = sgpCurrItem->dwFlags & mf_SLIDER_VAL_MASK;
LONG lTicks = sgpCurrItem->dwFlags & mf_SLIDER_TICK_MASK;
lTicks >>= SLIDER_TICK_SHIFT;
if (bNext) {
if (lVal == lTicks) return;
lVal++;
}
else {
if (! lVal) return;
lVal--;
}
sgpCurrItem->dwFlags &= ~mf_SLIDER_VAL_MASK;
sgpCurrItem->dwFlags |= lVal;
sgpCurrItem->fnMenu(FALSE);
}
//******************************************************************
//******************************************************************
BOOL gmenu_key(WPARAM wKey) {
if (! sgpMenu) return FALSE;
app_assert(sgpCurrItem);
switch (wKey) {
case VK_SPACE:
// allow spacebar
return FALSE;
case VK_LEFT:
gmenu_slider(FALSE);
break;
case VK_RIGHT:
gmenu_slider(TRUE);
break;
case VK_UP:
gmenu_change(FALSE);
break;
case VK_DOWN:
gmenu_change(TRUE);
break;
case VK_RETURN:
app_assert(sgpCurrItem);
if (sgpCurrItem->dwFlags & mf_ENABLED) {
PlaySFX(IS_TITLEMOV);
sgpCurrItem->fnMenu(TRUE);
}
break;
case VK_ESCAPE:
PlaySFX(IS_TITLEMOV);
gmenu_set_menu(NULL,NULL);
break;
}
return TRUE;
}
//******************************************************************
//******************************************************************
static BYTE gmenu_mouse_in_slider(LONG * plOffset) {
app_assert(plOffset);
*plOffset = 640/2 + SLIDER_TOTAL_WDT/2 - SLIDER_WDT - SLIDER_ITEM_WDT;
if (MouseX < *plOffset) {
*plOffset = 0;
return FALSE;
}
else if (MouseX > *plOffset + SLIDER_WDT) {
*plOffset = SLIDER_WDT;
return FALSE;
}
*plOffset = MouseX - *plOffset;
return TRUE;
}
//******************************************************************
//******************************************************************
BOOL gmenu_mousemove() {
if (! sgbTracking) return FALSE;
app_assert(sgpCurrItem);
// get position = 0..SLIDER_WDT
LONG lOffset;
gmenu_mouse_in_slider(&lOffset);
// scale to 0..ticks
LONG lTicks = sgpCurrItem->dwFlags & mf_SLIDER_TICK_MASK;
lTicks >>= SLIDER_TICK_SHIFT;
lOffset *= lTicks;
lOffset /= SLIDER_WDT;
// set item value
sgpCurrItem->dwFlags &= ~mf_SLIDER_VAL_MASK;
sgpCurrItem->dwFlags |= lOffset;
sgpCurrItem->fnMenu(FALSE);
return TRUE;
}
//******************************************************************
//******************************************************************
BOOL gmenu_click(BOOL bMouseDown) {
// handle mouseup
if (! bMouseDown) {
if (! sgbTracking) return FALSE;
sgbTracking = FALSE;
return TRUE;
}
if (! sgpMenu) return FALSE;
if (MouseY >= 352) return FALSE;
int nItem = MouseY - MENU_CLICKY;
if (nItem < 0) return TRUE;
nItem /= MENU_LINEHGT;
if ((DWORD) nItem >= sgdwMenuItems) return TRUE;
// only click menu item if it is enabled
TMenuItem * pItem = sgpMenu + nItem;
if (! (pItem->dwFlags & mf_ENABLED)) return TRUE;
DWORD wdt = gmenu_calc_item_width(pItem);
if ((DWORD) MouseX < 640/2-wdt/2) return TRUE;
if ((DWORD) MouseX > 640/2+wdt/2) return TRUE;
// set current item
sgpCurrItem = pItem;
PlaySFX(IS_TITLEMOV);
if (pItem->dwFlags & mf_SLIDER) {
LONG lTemp;
sgbTracking = gmenu_mouse_in_slider(&lTemp);
gmenu_mousemove();
}
else {
sgpCurrItem->fnMenu(TRUE);
}
return TRUE;
}
//******************************************************************
//******************************************************************
void gmenu_set_enable(TMenuItem * pMenuItem,BOOL bEnable) {
app_assert(pMenuItem);
if (bEnable)
pMenuItem->dwFlags |= mf_ENABLED;
else
pMenuItem->dwFlags &= ~mf_ENABLED;
}
//******************************************************************
//******************************************************************
void gmenu_set_slider(TMenuItem * pItem,LONG lMin,LONG lMax,LONG lVal) {
app_assert(pItem);
LONG lTicks = pItem->dwFlags & mf_SLIDER_TICK_MASK;
lTicks >>= SLIDER_TICK_SHIFT;
if (lTicks < MIN_SLIDER_TICKS) lTicks = MIN_SLIDER_TICKS;
// make lVal zero-based
lVal -= lMin;
// scale to slider
lVal *= lTicks;
lVal += (lMax - lMin - 1) / 2;
lVal /= lMax - lMin;
// store into menu item
pItem->dwFlags &= ~mf_SLIDER_VAL_MASK;
pItem->dwFlags |= lVal;
}
//******************************************************************
//******************************************************************
LONG gmenu_get_slider(const TMenuItem * pItem,LONG lMin,LONG lMax) {
app_assert(pItem);
// get value from menu item
LONG lVal = pItem->dwFlags & mf_SLIDER_VAL_MASK;
LONG lTicks = pItem->dwFlags & mf_SLIDER_TICK_MASK;
lTicks >>= SLIDER_TICK_SHIFT;
if (lTicks < MIN_SLIDER_TICKS) lTicks = MIN_SLIDER_TICKS;
// restore scale
lVal *= lMax - lMin;
lVal += (lTicks - 1) / 2;
lVal /= lTicks;
// re-base
lVal += lMin;
return lVal;
}
//******************************************************************
//******************************************************************
void gmenu_set_slider_ticks(TMenuItem * pItem,DWORD dwTicks) {
app_assert(pItem);
app_assert(dwTicks >= MIN_SLIDER_TICKS && dwTicks <= MAX_SLIDER_TICKS);
pItem->dwFlags &= ~mf_SLIDER_TICK_MASK;
pItem->dwFlags |= mf_SLIDER_TICK_MASK & (dwTicks << SLIDER_TICK_SHIFT);
}

BIN
src/HELLFRUI.LIB Normal file

Binary file not shown.

1106
src/HELP.CPP Normal file

File diff suppressed because it is too large Load Diff

54
src/HELP.H Normal file
View File

@ -0,0 +1,54 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Constants and Variables
**
** (C)1995 Condor, Inc. All rights reserved.
**-----------------------------------------------------------------------**
** $Header: /Diablo/HELP.H 1 1/22/97 2:06p Dgartner $
**-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------**
** Defines
**-----------------------------------------------------------------------*/
#define MAXHELPSTRS 8
#define MAXHELPLINES 4
/*-----------------------------------------------------------------------**
** Structures
**-----------------------------------------------------------------------*/
typedef struct {
int hsx;
int hsy;
char hstr[128];
byte hclr;
} HelpStrStruct;
typedef struct {
int hlx1;
int hly1;
int hlx2;
int hly2;
byte hlclr;
} HelpLineStruct;
/*-----------------------------------------------------------------------**
** Externs
**-----------------------------------------------------------------------*/
extern BOOL helpflag;
/*-----------------------------------------------------------------------**
** Prototypes
**-----------------------------------------------------------------------*/
void InitHelpSys();
void DrawHelp();
void StartHelp();
void HelpScrollUp();
void HelpScrollDown();

BIN
src/ICON1.ICO Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

44
src/IMPLODE.H Normal file
View File

@ -0,0 +1,44 @@
/***************************************************************
PKWARE Data Compression Library (R) for Win32
Copyright 1991,1992,1994,1995 PKWARE Inc. All Rights Reserved.
PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off.
***************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
unsigned int __cdecl implode(
unsigned int (__cdecl *read_buf)(char *buf, unsigned int *size, void *param),
void (__cdecl *write_buf)(char *buf, unsigned int *size, void *param),
char *work_buf,
void *param,
unsigned int *type,
unsigned int *dsize);
unsigned int __cdecl explode(
unsigned int (__cdecl *read_buf)(char *buf, unsigned int *size, void *param),
void (__cdecl *write_buf)(char *buf, unsigned int *size, void *param),
char *work_buf,
void *param);
unsigned long __cdecl crc32(char *buffer, unsigned int *size, unsigned long *old_crc);
#ifdef __cplusplus
} // End of 'extern "C"' declaration
#endif
#define CMP_BUFFER_SIZE 36312
#define EXP_BUFFER_SIZE 12596
#define CMP_BINARY 0
#define CMP_ASCII 1
#define CMP_NO_ERROR 0
#define CMP_INVALID_DICTSIZE 1
#define CMP_INVALID_MODE 2
#define CMP_BAD_DATA 3
#define CMP_ABORT 4

BIN
src/IMPLODE.LIB Normal file

Binary file not shown.

804
src/INIT.CPP Normal file
View File

@ -0,0 +1,804 @@
//******************************************************************
// init.cpp
//******************************************************************
#include "diablo.h"
#pragma hdrstop
#include <shlobj.h>
#include "storm.h"
#include "palette.h"
#include "engine.h"
#include "gendung.h"
#include "lighting.h"
#include "multi.h"
#include "sound.h"
#include "effects.h"
#include "diabloui.h"
#include "resource.h"
//******************************************************************
// debugging
//******************************************************************
// minor version number -- as in 1.xx
// jmm.patch3
#define MINOR_VERSION "04"
// jmm.endpatch3
// change to "01" when done with patch
#define HF_MINOR_VERSION "01"
#define DIRECT_FILE_ACCESS 1 // 0 in final
#ifdef NDEBUG
#undef DIRECT_FILE_ACCESS
#define DIRECT_FILE_ACCESS 0
#endif
//******************************************************************
// extern
//******************************************************************
void init_directx(HWND hWnd);
void free_directx();
void ddraw_switch_modes();
void BlackPalette();
void ReleasePlayerFile();
void FileErrorDlg(const char * pszName);
//******************************************************************
// public
//******************************************************************
BOOL bActive; // is application active?
const char gszAppName[] = "HELLFIRE";
const char gszDiabloName[] = "DIABLO";
HSARCHIVE ghsMainArchive;
HSARCHIVE ghsHFBardArchive = NULL;
HSARCHIVE ghsHFBarbarianArchive = NULL;
// Version string --- NOTE: DO NOT CHANGE THIS VERSION
// NUMBER IN THE PROGRAM, CHANGE IT IN THE RESOURCE FILE!
char gszVersionNumber[MAX_PATH] = "internal version unknown";
char gszPrintVersion[MAX_PATH] = "Hellfire v1." HF_MINOR_VERSION ; // " (from Diablo v1." MINOR_VERSION ")";
SNETVERSIONDATA gVersion;
static char sgszProgramName[MAX_PATH];
static char sgszMainArchiveName[MAX_PATH];
static char sgszPatchArchiveName[MAX_PATH];
static char sgszHFArchiveName[MAX_PATH];
static char sgszHFMonkArchiveName[MAX_PATH];
static char sgszHFBardArchiveName[MAX_PATH];
static char sgszHFBarbarianArchiveName[MAX_PATH];
static char sgszHFMusicArchiveName[MAX_PATH];
static char sgszHFVoiceArchiveName[MAX_PATH];
static char sgszHFOpt1ArchiveName[MAX_PATH];
static char sgszHFOpt2ArchiveName[MAX_PATH];
//******************************************************************
// private
//******************************************************************
static WNDPROC sgWndProc;
static LRESULT CALLBACK WndProc(HWND ,UINT ,WPARAM ,LPARAM );
static HSARCHIVE sghsPatchArchive;
static HSARCHIVE sghsHFArchive;
static HSARCHIVE sghsHFMonkArchive;
static HSARCHIVE sghsHFMusicArchive;
static HSARCHIVE sghsHFVoiceArchive;
static HSARCHIVE sghsHFOpt1Archive;
static HSARCHIVE sghsHFOpt2Archive;
static BOOL killedmom = 0;
#define MOMLINKNAME "Microsoft Office Shortcut Bar.lnk"
//******************************************************************
//******************************************************************
static void SearchDirectory(LPCSTR directory) {
char searchspec[MAX_PATH];
strcpy(searchspec,directory);
if ((!searchspec[0]) ||(searchspec[strlen(searchspec)-1] != '\\'))
strcat(searchspec,"\\*");
else
strcat(searchspec,"*");
WIN32_FIND_DATA finddata;
HANDLE findhandle = FindFirstFile(searchspec,&finddata);
if (findhandle != INVALID_HANDLE_VALUE) {
do
if (finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
if (strcmp(finddata.cFileName,".") && strcmp(finddata.cFileName,"..")) {
char buffer[MAX_PATH] = "";
if ((!directory[0]) ||(directory[strlen(directory)-1] != '\\'))
sprintf(buffer,"%s\\%s\\",directory,finddata.cFileName);
else
sprintf(buffer,"%s%s\\",directory,finddata.cFileName);
SearchDirectory(buffer);
}
}
else {
if (!_stricmp(finddata.cFileName,MOMLINKNAME))
ShellExecute(GetDesktopWindow(),"open",finddata.cFileName,"",directory,SW_SHOWNORMAL);
}
while (FindNextFile(findhandle,&finddata));
FindClose(findhandle);
}
}
//******************************************************************
//******************************************************************
static HWND find_mom_window() {
HWND hWnd = GetForegroundWindow();
while (hWnd) {
char classname[256];
GetClassName(hWnd,classname,255);
if (! _stricmp(classname,"MOM Parent")) break;
hWnd = GetNextWindow(hWnd,GW_HWNDNEXT);
}
return hWnd;
}
//******************************************************************
//******************************************************************
static void KillMom() {
HWND hWnd;
if (NULL != (hWnd = find_mom_window())) {
PostMessage(hWnd,WM_CLOSE,0,0);
killedmom = 1;
}
}
//******************************************************************
//******************************************************************
static void WaitMomDead() {
HWND hWnd;
DWORD dwCurrTime = GetTickCount();
while (NULL != (hWnd = find_mom_window())) {
Sleep(250);
if (GetTickCount() - dwCurrTime > 4000)
break;
}
}
//******************************************************************
//******************************************************************
static void ResurrectMom() {
if (!killedmom)
return;
killedmom = 0;
char buffer[256] = "";
LPITEMIDLIST idlist = NULL;
if (SHGetSpecialFolderLocation(GetDesktopWindow(),CSIDL_STARTMENU,&idlist) == NOERROR) {
SHGetPathFromIDList(idlist,buffer);
SearchDirectory(buffer);
}
}
//******************************************************************
//******************************************************************
static void disable_screen_saver(BYTE bDisable) {
// direct draw doesn't like the screen saver to be enabled, it
// will quit with a fatal error if the screen saver kicks in.
// Disable the screen saver while the program is running
HKEY hKey;
BYTE bNewState;
DWORD dwSuccess;
TCHAR szBuf[16];
static BYTE sbState = FALSE;
static const TCHAR scszKey[] = TEXT("ScreenSaveActive");
// open master key
dwSuccess = RegOpenKeyEx(HKEY_CURRENT_USER,TEXT("Control Panel\\Desktop"),0,KEY_READ | KEY_WRITE,&hKey);
if (dwSuccess != ERROR_SUCCESS) return;
if (bDisable) {
// get current screen saver state
DWORD dwType;
DWORD dwSize = sizeof(szBuf);
dwSuccess = RegQueryValueEx(hKey,scszKey,NULL,&dwType,(LPBYTE) szBuf,&dwSize);
if (dwSuccess == ERROR_SUCCESS) sbState = szBuf[0] != TEXT('0');
bNewState = 0;
}
else {
// restore old screen saver state
bNewState = sbState;
}
// set the new state
szBuf[0] = bNewState ? TEXT('1') : TEXT('0');
szBuf[1] = 0;
RegSetValueEx(hKey,scszKey,NULL,REG_SZ,(LPBYTE) szBuf,2 * sizeof(szBuf[0]));
RegCloseKey(hKey);
}
//******************************************************************
//******************************************************************
/*
static void key_press(int key)
{
// Simulate a key press
keybd_event( key,
0x45,
KEYEVENTF_EXTENDEDKEY | 0,
0 );
// Simulate a key release
keybd_event( VK_CAPITAL,
0x45,
KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,
0);
}
*/
//******************************************************************
//******************************************************************
/*
static void init_caps_lock(BOOL init)
{
BYTE keyState[256];
static BOOL capslocked;
GetKeyboardState((LPBYTE)&keyState);
if(init)
{
capslocked = keyState[VK_CAPITAL] & 1;
// Set caps lock off initially
// NOTE: FriendlyMode is opposite polarity to caps_lock, i.e., it is originally ON
if(capslocked)
key_press(VK_CAPITAL);
}
else { // restore caps lock to originial state
if( (capslocked && !(keyState[VK_CAPITAL] & 1)) ||
(!capslocked && (keyState[VK_CAPITAL] & 1)) )
key_press(VK_CAPITAL);
}
}
*/
//******************************************************************
//******************************************************************
void cleanup(BOOL bNormalExit) {
ReleasePlayerFile();
disable_screen_saver(FALSE);
// init_caps_lock(FALSE);
ResurrectMom();
if (ghsMainArchive) {
SFileCloseArchive(ghsMainArchive);
ghsMainArchive = NULL;
}
if (sghsPatchArchive) {
SFileCloseArchive(sghsPatchArchive);
sghsPatchArchive = NULL;
}
if (sghsHFArchive) {
SFileCloseArchive(sghsHFArchive);
sghsHFArchive = NULL;
}
if (sghsHFMonkArchive) {
SFileCloseArchive(sghsHFMonkArchive);
sghsHFMonkArchive = NULL;
}
if (ghsHFBardArchive) {
SFileCloseArchive(ghsHFBardArchive);
ghsHFBardArchive = NULL;
}
if (ghsHFBarbarianArchive) {
SFileCloseArchive(ghsHFBarbarianArchive);
ghsHFBarbarianArchive = NULL;
}
if (sghsHFMusicArchive) {
SFileCloseArchive(sghsHFMusicArchive);
sghsHFMusicArchive = NULL;
}
if (sghsHFVoiceArchive) {
SFileCloseArchive(sghsHFVoiceArchive);
sghsHFVoiceArchive = NULL;
}
if (sghsHFOpt1Archive) {
SFileCloseArchive(sghsHFOpt1Archive);
sghsHFOpt1Archive = NULL;
}
if (sghsHFOpt2Archive) {
SFileCloseArchive(sghsHFOpt2Archive);
sghsHFOpt2Archive = NULL;
}
UiDestroy();
sound_exit();
snd_exit();
NetClose();
free_directx();
mem_cleanup(bNormalExit);
StormDestroy();
if (bNormalExit) ShowCursor(TRUE);
}
//******************************************************************
//******************************************************************
static void remove_trailing_bslash(char * pszPath) {
char * pszTemp = strrchr(pszPath,'\\');
if (pszTemp && !pszTemp[1])
*pszTemp = 0;
}
//******************************************************************
//******************************************************************
static BOOL FindCDArchive(
char szName[MAX_PATH], // saved full path
const char * pszArchName, // default archive name
DWORD dwPriority, // priority
HSARCHIVE * phsArchive // archive name
) {
// get a list of drives, and figure out which ones are CDROM
char szDriveList[MAX_PATH];
DWORD dwLen = GetLogicalDriveStrings(MAX_PATH,szDriveList);
if (! dwLen) return FALSE;
if (dwLen > MAX_PATH) return FALSE;
// skip over leading bslash in archive name
while (*pszArchName == '\\') pszArchName++;
const char * pszDriveList = szDriveList;
while (*pszDriveList) {
// save current drive
const char * pszCurrDrive = pszDriveList;
// skip over drive string and trailing NULL
while (*pszDriveList++) NULL;
// is this a CDROM drive?
if (DRIVE_CDROM != GetDriveType(pszCurrDrive))
continue;
strcpy(szName,pszCurrDrive);
strcat(szName,pszArchName);
if (SFileOpenArchive(szName,dwPriority,TRUE,phsArchive))
return TRUE;
}
return FALSE;
}
//******************************************************************
//******************************************************************
static HSARCHIVE open_1_archive(
char szName[MAX_PATH], // saved full path
const char * pszArchName, // default archive name
const char * pszArchPathRegKey, // registry key for directory
DWORD dwPriority, // priority
BOOL bCDOnly // TRUE => CD ROM only
) {
HSARCHIVE hArchive;
// get current directory
char szCurrDir[MAX_PATH];
if (! GetCurrentDirectory(MAX_PATH,szCurrDir))
app_fatal("Can't get program path");
remove_trailing_bslash(szCurrDir);
if (! SFileSetBasePath(szCurrDir))
app_fatal("SFileSetBasePath");
// get program directory
char szProgDir[MAX_PATH];
if (! GetModuleFileName(ghInst,szProgDir,MAX_PATH))
app_fatal("Can't get program name");
char * pszExeName = strrchr(szProgDir,'\\');
if (pszExeName) *pszExeName = 0;
remove_trailing_bslash(szProgDir);
// try the current directory
strcpy(szName,szCurrDir);
strcat(szName,pszArchName);
if (SFileOpenArchive(
szName,
dwPriority,
#if DIRECT_FILE_ACCESS
FALSE,
#else
bCDOnly,
#endif
&hArchive
)) return hArchive;
// try the program directory
if (strcmp(szProgDir,szCurrDir)) {
strcpy(szName,szProgDir);
strcat(szName,pszArchName);
if (SFileOpenArchive(
szName,
dwPriority,
#if DIRECT_FILE_ACCESS
FALSE,
#else
bCDOnly,
#endif
&hArchive
)) return hArchive;
}
// get CD directory
char szDataDir[MAX_PATH];
szDataDir[0] = 0;
if (pszArchPathRegKey && SRegLoadString(TEXT("Archives"),pszArchPathRegKey,0,szDataDir,MAX_PATH)) {
// try the data directory
remove_trailing_bslash(szDataDir);
strcpy(szName,szDataDir);
strcat(szName,pszArchName);
if (SFileOpenArchive(
szName,
dwPriority,
#if DIRECT_FILE_ACCESS
FALSE,
#else
bCDOnly,
#endif
&hArchive
)) return hArchive;
}
// if this file is to be found on a CDROM, search *all* CDROMs
// don't pass szName, because in case of failure by FindCDArchive,
// it already contains the name of the desired archive, which
// STORM wants
if (bCDOnly && FindCDArchive(szDataDir,pszArchName,dwPriority,&hArchive)) {
strcpy(szName,szDataDir);
return hArchive;
}
// we couldn't open the file, but leave the szName variable
// filled in with the program directory + archive name
return NULL;
}
//******************************************************************
//******************************************************************
static void get_program_version_info() {
// get name of .EXE file
if (! GetModuleFileName(ghInst,sgszProgramName,MAX_PATH))
return;
// get sizeof version structure to allocate
DWORD dwUnused;
DWORD dwVerLen = GetFileVersionInfoSize(sgszProgramName,&dwUnused);
if (! dwVerLen) return;
// get version info
LPVOID lpData = DiabloAllocPtrSig(dwVerLen,'VERS');
if (! GetFileVersionInfo(sgszProgramName,0,dwVerLen,lpData))
goto cleanup;
UINT uBytes;
VS_FIXEDFILEINFO * pInfo;
if (! VerQueryValue(lpData,TEXT("\\"),(LPVOID *) &pInfo,&uBytes))
goto cleanup;
app_assert(uBytes >= sizeof(VS_FIXEDFILEINFO));
sprintf(
gszVersionNumber,
"version %d.%d.%d.%d",
pInfo->dwProductVersionMS >> 16,
pInfo->dwProductVersionMS & 0x0ffff,
pInfo->dwProductVersionLS >> 16,
pInfo->dwProductVersionLS & 0x0ffff
);
cleanup:
DiabloFreePtr(lpData);
}
//******************************************************************
//******************************************************************
static void open_archives() {
// setup version info
ZeroMemory(&gVersion,sizeof(gVersion));
gVersion.size = sizeof(gVersion);
gVersion.versionstring = gszVersionNumber;
gVersion.executablefile = sgszProgramName;
gVersion.originalarchivefile = sgszMainArchiveName;
gVersion.patcharchivefile = sgszPatchArchiveName;
// fill in program name and version string
get_program_version_info();
while (1) {
// open main archive
ghsMainArchive = open_1_archive(
sgszMainArchiveName, // saved full path
#if IS_VERSION(SHAREWARE)
TEXT("\\spawn.mpq"), // default archive name
TEXT("DiabloSpawn"), // key for spawned directory
#else
TEXT("\\diabdat.mpq"), // default archive name
TEXT("DiabloCD"), // key for CDROM directory
#endif
1000, // priority
#if IS_VERSION(SHAREWARE)
FALSE // TRUE == CD ROM only
#else
TRUE // TRUE == CD ROM only
#endif
);
if (ghsMainArchive) break;
#if DIRECT_FILE_ACCESS
// we're in debugging mode, so we can just exit
break;
#endif
#if IS_VERSION(SHAREWARE)
// couldn't find spawn.mpq file
break;
#else
// tell the user to insert the CD
DWORD dwResult;
UiCopyProtError(&dwResult);
if (dwResult == COPYPROT_CANCEL)
FileErrorDlg("diabdat.mpq");
#endif
}
// make sure we have access to our data
HSFILE hsFile;
if (! patSFileOpenFile("ui_art\\title.pcx",&hsFile,TRUE)) {
#if IS_VERSION(SHAREWARE)
FileErrorDlg("Main program archive: spawn.mpq");
#else
FileErrorDlg("Main program archive: diabdat.mpq");
#endif
}
patSFileCloseFile(hsFile);
// open patch file
sghsPatchArchive = open_1_archive(
sgszPatchArchiveName, // saved full path
#if IS_VERSION(SHAREWARE)
TEXT("\\patch_sh.mpq"), // default archive name
TEXT("DiabloSpawn"), // key for spawned directory
#else
TEXT("\\patch_rt.mpq"), // default archive name
TEXT("DiabloInstall"), // key for installed directory
#endif
2000, // priority
FALSE // TRUE == CD ROM only
);
// open Hellfire file
sghsHFArchive = open_1_archive(
sgszHFArchiveName, // saved full path
TEXT("\\hellfire.mpq"), // default archive name
TEXT("DiabloInstall"), // key for installed directory
8000, // priority
FALSE // TRUE == CD ROM only
);
// open Hellfire Character file
sghsHFMonkArchive = open_1_archive(
sgszHFMonkArchiveName, // saved full path
TEXT("\\hfmonk.mpq"), // default archive name
TEXT("DiabloInstall"), // key for installed directory
8100, // priority
FALSE // TRUE == CD ROM only
);
// open Hellfire Character file
ghsHFBardArchive = open_1_archive(
sgszHFBardArchiveName, // saved full path
TEXT("\\hfbard.mpq"), // default archive name
TEXT("DiabloInstall"), // key for installed directory
8110, // priority
FALSE // TRUE == CD ROM only
);
// open Hellfire Character file
ghsHFBarbarianArchive = open_1_archive(
sgszHFBarbarianArchiveName, // saved full path
TEXT("\\hfbarb.mpq"), // default archive name
TEXT("DiabloInstall"), // key for installed directory
8120, // priority
FALSE // TRUE == CD ROM only
);
// open Hellfire Music file
sghsHFMusicArchive = open_1_archive(
sgszHFMusicArchiveName, // saved full path
TEXT("\\hfmusic.mpq"), // default archive name
TEXT("DiabloInstall"), // key for installed directory
8200, // priority
FALSE // TRUE == CD ROM only
);
// open Hellfire Voice file
sghsHFVoiceArchive = open_1_archive(
sgszHFVoiceArchiveName, // saved full path
TEXT("\\hfvoice.mpq"), // default archive name
TEXT("DiabloInstall"), // key for installed directory
8500, // priority
FALSE // TRUE == CD ROM only
);
// open Hellfire Option file #1
sghsHFOpt1Archive = open_1_archive(
sgszHFOpt1ArchiveName, // saved full path
TEXT("\\hfopt1.mpq"), // default archive name
TEXT("DiabloInstall"), // key for installed directory
8600, // priority
FALSE // TRUE == CD ROM only
);
// open Hellfire Option file #2
sghsHFOpt2Archive = open_1_archive(
sgszHFOpt2ArchiveName, // saved full path
TEXT("\\hfopt2.mpq"), // default archive name
TEXT("DiabloInstall"), // key for installed directory
8610, // priority
FALSE // TRUE == CD ROM only
);
}
//******************************************************************
//******************************************************************
void init_window(int nCmdShow) {
KillMom();
void check_disk_space();
check_disk_space();
// set up and register window class
WNDCLASSEX wc;
ZeroMemory(&wc,sizeof(wc));
wc.cbSize = sizeof(wc);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WndProc;
wc.hInstance = ghInst;
wc.hIcon = LoadIcon(ghInst,MAKEINTRESOURCE(IDI_ICON1));
wc.hCursor = LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = gszAppName;
// So the Diablo auto run won't.
wc.lpszClassName = gszDiabloName; //gszAppName;
wc.hIconSm = (HICON) LoadImage(ghInst,MAKEINTRESOURCE(IDI_ICON1),IMAGE_ICON,16,16,0);
if (! RegisterClassEx(&wc))
app_fatal("Unable to register window class");
#if ALLOW_WINDOWED_MODE
int nWdt = 640;
int nHgt = 480;
#else
int nWdt = max(640,GetSystemMetrics(SM_CXSCREEN));
int nHgt = max(480,GetSystemMetrics(SM_CYSCREEN));
#endif
// create main window
HWND hWnd = CreateWindow(
gszDiabloName,
gszAppName,
WS_POPUP,
0,
0,
nWdt,
nHgt,
NULL,
NULL,
ghInst,
NULL
);
if (! hWnd) app_fatal("Unable to create main window");
ShowWindow(hWnd,SW_SHOWNORMAL);
UpdateWindow(hWnd);
WaitMomDead();
init_directx(hWnd);
BlackPalette();
snd_init(hWnd);
open_archives();
disable_screen_saver(TRUE);
// init_caps_lock(TRUE);
}
//******************************************************************
//******************************************************************
static void app_activate(HWND hWnd,WPARAM wParam) {
bActive = wParam;
UiAppActivate(wParam);
// make our 16x16 icon show up on the taskbar
// -- have to have WM_SYSMENU set for the icon to show up
// -- don't want WM_SYSMENU during fullscreen mode, otherwise
// menu will pop up during gameplay!
DWORD dwStyle = GetWindowLong(hWnd,GWL_STYLE);
if (bActive && fullscreen)
dwStyle &= ~WS_SYSMENU;
else
dwStyle |= WS_SYSMENU;
SetWindowLong(hWnd,GWL_STYLE,dwStyle);
if (! bActive) return;
force_redraw = FULLDRAW;
ResetPal();
}
//******************************************************************
//******************************************************************
LRESULT CALLBACK DiabloDefProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) {
switch(uMsg) {
#if ALLOW_WINDOWED_MODE
case WM_SYSKEYUP:
if (wParam == VK_RETURN) {
fullscreen = !fullscreen;
ddraw_switch_modes();
return 0;
}
break;
#endif
case WM_CLOSE:
return 0;
case WM_ERASEBKGND:
// ignore erase messages
return 0;
case WM_PAINT:
force_redraw = FULLDRAW;
break;
case WM_ACTIVATEAPP:
app_activate(hWnd,wParam);
break;
case WM_QUERYNEWPALETTE:
SDrawRealizePalette();
return TRUE;
case WM_PALETTECHANGED:
// pjw.patch1.start
// if (bActive && (HWND)wParam != hWnd)
if ((HWND)wParam != hWnd)
// pjw.patch1.end
SDrawRealizePalette();
break;
case WM_CREATE:
ghMainWnd = hWnd;
break;
case WM_DESTROY:
cleanup(TRUE);
ghMainWnd = NULL;
PostQuitMessage(0);
break;
}
return DefWindowProc(hWnd,uMsg,wParam,lParam);
}
//******************************************************************
//******************************************************************
static LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) {
if (sgWndProc) return sgWndProc(hWnd,uMsg,wParam,lParam);
return DiabloDefProc(hWnd,uMsg,wParam,lParam);
}
//******************************************************************
//******************************************************************
WNDPROC my_SetWindowProc(WNDPROC wndProc) {
// we can't use SetWindowLong, because DirectDraw won't properly support
// stuff like alt-tabbing if we override the funky stuff it does to the
// window procedure.
WNDPROC tempProc = sgWndProc;
sgWndProc = wndProc;
return tempProc;
}

544
src/INTERFAC.CPP Normal file
View File

@ -0,0 +1,544 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Menu interface processing
**
** (C)1996 Condor, Inc. All rights reserved.
**
**-----------------------------------------------------------------------**
** $Header: /Diablo/INTERFAC.CPP 1 1/22/97 2:06p Dgartner $
**-----------------------------------------------------------------------*/
#include "diablo.h"
#pragma hdrstop
#include "storm.h"
#include "palette.h"
#include "engine.h"
#include "scrollrt.h"
#include "gendung.h"
#include "items.h"
#include "player.h"
#include "gamemenu.h"
#include "control.h"
#include "cursor.h"
#include "trigs.h"
#include "multi.h"
#include "msg.h"
#include "effects.h"
#include "portal.h"
#include "quests.h"
#include "setmaps.h"
//******************************************************************
// extern
//******************************************************************
extern BYTE gbSomebodyWonGameKludge;
WNDPROC my_SetWindowProc(WNDPROC wndProc);
void plrmsg_hold(BOOL bStart);
void BlackPalette();
void DestroyTempSaves();
LRESULT CALLBACK DisableInputWndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
//******************************************************************
// private
//******************************************************************
#define MAX_PROGRESS 534
static BYTE *sgpBackCel;
static DWORD sgdwProgress, sgdwXY;
//******************************************************************
//******************************************************************
static void ProgressFree() {
DiabloFreePtr(sgpBackCel);
}
//******************************************************************
//******************************************************************
static void ProgressLoad(UINT uMsg) {
app_assert(! sgpBackCel);
switch (uMsg) {
case WM_DIABNEXTLVL :
switch (gnLevelTypeTbl[currlevel]) {
case 0:
sgpBackCel = LoadFileInMemSig("Gendata\\Cuttt.CEL",NULL,'PROG');
LoadPalette("Gendata\\Cuttt.pal");
sgdwXY = 1;
break;
case 1:
if (currlevel < HIVESTART)
{
sgpBackCel = LoadFileInMemSig("Gendata\\Cutl1d.CEL",NULL,'PROG');
LoadPalette ("Gendata\\Cutl1d.pal");
sgdwXY = 0;
break;
}
else
{
sgpBackCel = LoadFileInMemSig("Nlevels\\cutl5.CEL",NULL,'PROG');
LoadPalette ("Nlevels\\cutl5.pal");
sgdwXY = 1;
break;
}
case 2:
sgpBackCel = LoadFileInMemSig("Gendata\\Cut2.CEL",NULL,'PROG');
LoadPalette ("Gendata\\Cut2.pal");
sgdwXY = 2;
break;
case 3:
if (currlevel < HIVESTART)
{
sgpBackCel = LoadFileInMemSig("Gendata\\Cut3.CEL",NULL,'PROG');
LoadPalette ("Gendata\\Cut3.pal");
sgdwXY = 1;
break;
}
else
{
sgpBackCel = LoadFileInMemSig("Nlevels\\cutl6.CEL",NULL,'PROG');
LoadPalette ("Nlevels\\cutl6.pal");
sgdwXY = 1;
break;
}
case 4:
if (currlevel < 15) {
sgpBackCel = LoadFileInMemSig("Gendata\\Cut4.CEL",NULL,'PROG');
LoadPalette ("Gendata\\Cut4.pal");
sgdwXY = 1;
} else {
sgpBackCel = LoadFileInMemSig("Gendata\\Cutgate.CEL",NULL,'PROG');
LoadPalette ("Gendata\\Cutgate.pal");
sgdwXY = 1;
}
break;
default:
sgpBackCel = LoadFileInMemSig("Gendata\\Cutl1d.CEL",NULL,'PROG');
LoadPalette ("Gendata\\Cutl1d.pal");
sgdwXY = 0;
break;
}
break;
case WM_DIABPREVLVL :
if (gnLevelTypeTbl[currlevel-1] == 0) {
sgpBackCel = LoadFileInMemSig("Gendata\\Cuttt.CEL",NULL,'PROG');
LoadPalette ("Gendata\\Cuttt.pal");
sgdwXY = 1;
} else {
switch (gnLevelTypeTbl[currlevel]) {
case 0:
sgpBackCel = LoadFileInMemSig("Gendata\\Cuttt.CEL",NULL,'PROG');
LoadPalette ("Gendata\\Cuttt.pal");
sgdwXY = 1;
break;
case 1:
if (currlevel < HIVESTART)
{
sgpBackCel = LoadFileInMemSig("Gendata\\Cutl1d.CEL",NULL,'PROG');
LoadPalette ("Gendata\\Cutl1d.pal");
sgdwXY = 0;
break;
}
else
{
sgpBackCel = LoadFileInMemSig("Nlevels\\cutl5.CEL",NULL,'PROG');
LoadPalette ("Nlevels\\cutl5.pal");
sgdwXY = 1;
break;
}
case 2:
sgpBackCel = LoadFileInMemSig("Gendata\\Cut2.CEL",NULL,'PROG');
LoadPalette ("Gendata\\Cut2.pal");
sgdwXY = 2;
break;
case 3:
if (currlevel < HIVESTART)
{
sgpBackCel = LoadFileInMemSig("Gendata\\Cut3.CEL",NULL,'PROG');
LoadPalette ("Gendata\\Cut3.pal");
sgdwXY = 1;
break;
}
else
{
sgpBackCel = LoadFileInMemSig("Nlevels\\cutl6.CEL",NULL,'PROG');
LoadPalette ("Nlevels\\cutl6.pal");
sgdwXY = 1;
break;
}
case 4:
sgpBackCel = LoadFileInMemSig("Gendata\\Cut4.CEL",NULL,'PROG');
LoadPalette ("Gendata\\Cut4.pal");
sgdwXY = 1;
break;
default:
sgpBackCel = LoadFileInMemSig("Gendata\\Cutl1d.CEL",NULL,'PROG');
LoadPalette ("Gendata\\Cutl1d.pal");
sgdwXY = 0;
break;
}
}
break;
case WM_DIABSETLVL :
if (setlvlnum == SL_BONECHAMB) {
sgpBackCel = LoadFileInMemSig("Gendata\\Cut2.CEL",NULL,'PROG');
LoadPalette ("Gendata\\Cut2.pal");
sgdwXY = 2;
} else if (setlvlnum == SL_VILEBETRAYER) {
sgpBackCel = LoadFileInMemSig("Gendata\\Cutportr.CEL",NULL,'PROG');
LoadPalette ("Gendata\\Cutportr.pal");
sgdwXY = 1;
} else {
sgpBackCel = LoadFileInMemSig("Gendata\\Cutl1d.CEL",NULL,'PROG');
LoadPalette ("Gendata\\Cutl1d.pal");
sgdwXY = 0;
}
break;
case WM_DIABRTNLVL :
if (setlvlnum == SL_BONECHAMB) { // bone chamber
sgpBackCel = LoadFileInMemSig("Gendata\\Cut2.CEL",NULL,'PROG');
LoadPalette ("Gendata\\Cut2.pal");
sgdwXY = 2;
} else if (setlvlnum == SL_VILEBETRAYER) { // vile betrayer
sgpBackCel = LoadFileInMemSig("Gendata\\Cutportr.CEL",NULL,'PROG');
LoadPalette ("Gendata\\Cutportr.pal");
sgdwXY = 1;
} else {
sgpBackCel = LoadFileInMemSig("Gendata\\Cutl1d.CEL",NULL,'PROG');
LoadPalette ("Gendata\\Cutl1d.pal");
sgdwXY = 0;
}
break;
case WM_DIABWARPLVL :
sgpBackCel = LoadFileInMemSig("Gendata\\Cutportl.CEL",NULL,'PROG');
LoadPalette ("Gendata\\Cutportl.pal");
sgdwXY = 1;
break;
case WM_DIABLOADGAME :
sgpBackCel = LoadFileInMemSig("Gendata\\Cutstart.CEL",NULL,'PROG');
LoadPalette ("Gendata\\Cutstart.pal");
sgdwXY = 1;
break;
case WM_DIABNEWGAME:
sgpBackCel = LoadFileInMemSig("Gendata\\Cutstart.CEL",NULL,'PROG');
LoadPalette ("Gendata\\Cutstart.pal");
sgdwXY = 1;
break;
case WM_DIABTOWNWARP:
case WM_DIABTWARPUP:
switch (gnLevelTypeTbl[plr[myplr].plrlevel]) {
case 0:
sgpBackCel = LoadFileInMemSig("Gendata\\Cuttt.CEL",NULL,'PROG');
LoadPalette ("Gendata\\Cuttt.pal");
sgdwXY = 1;
break;
case 1: // added to allow the crypt JKE
if (plr[myplr].plrlevel < HIVESTART)
{
sgpBackCel = LoadFileInMemSig("Gendata\\Cutl1d.CEL",NULL,'PROG');
LoadPalette ("Gendata\\Cutl1d.pal");
sgdwXY = 0;
break;
}
else
{
sgpBackCel = LoadFileInMemSig("Nlevels\\Cutl5.CEL",NULL,'PROG');
LoadPalette ("Nlevels\\Cutl5.pal");
sgdwXY = 1;
break;
}
case 2:
sgpBackCel = LoadFileInMemSig("Gendata\\Cut2.CEL",NULL,'PROG');
LoadPalette ("Gendata\\Cut2.pal");
sgdwXY = 2;
break;
case 3:
if (plr[myplr].plrlevel < HIVESTART)
{
sgpBackCel = LoadFileInMemSig("Gendata\\Cut3.CEL",NULL,'PROG');
LoadPalette ("Gendata\\Cut3.pal");
sgdwXY = 1;
break;
}
else
{
sgpBackCel = LoadFileInMemSig("Nlevels\\Cutl6.CEL",NULL,'PROG');
LoadPalette ("Nlevels\\Cutl6.pal");
sgdwXY = 1;
break;
}
case 4:
sgpBackCel = LoadFileInMemSig("Gendata\\Cut4.CEL",NULL,'PROG');
LoadPalette ("Gendata\\Cut4.pal");
sgdwXY = 1;
break;
}
break;
case WM_DIABRETOWN:
sgpBackCel = LoadFileInMemSig("Gendata\\Cuttt.CEL",NULL,'PROG');
LoadPalette ("Gendata\\Cuttt.pal");
sgdwXY = 1;
break;
default:
app_fatal("Unknown progress mode");
break;
}
// Indicates time for the progress bar
sgdwProgress = 0;
}
//******************************************************************
//******************************************************************
static void DrawBarXY(int x, int y, int v2) {
app_assert(gpBuffer);
static const BYTE pixel[3] = { 0x8a, 0x2b, 0xfe };
BYTE * pto = gpBuffer + nBuffWTbl[y] + x;
for (int i = 0; i < 22; i++) {
*pto = pixel[v2];
pto = pto + 768;
}
}
//******************************************************************
//******************************************************************
static void ProgressIntDraw() {
static const int xytable[3][2] = { {53, 37}, {53, 421}, {53, 37} };
// draw background
lock_buf(1);
app_assert(sgpBackCel);
DrawCel(64, 639, sgpBackCel, 1, 640);
// draw load/progress bar
for (DWORD i = 0; i < sgdwProgress; i++)
DrawBarXY (64 + xytable[sgdwXY][0] + i, xytable[sgdwXY][1] + 160, sgdwXY);
unlock_buf(1);
// force a full blit
force_redraw = FULLDRAW;
FullBlit(FALSE);
}
//******************************************************************
//******************************************************************
void interface_msg_pump() {
MSG msg;
while (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) {
if (msg.message != WM_QUIT) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
//******************************************************************
//******************************************************************
BOOL IntCheck() {
interface_msg_pump();
// make bar increase
sgdwProgress += 15;
if (sgdwProgress > MAX_PROGRESS)
sgdwProgress = MAX_PROGRESS;
// redraw the screen
if (sgpBackCel) ProgressIntDraw();
// are we done?
return (sgdwProgress >= MAX_PROGRESS);
}
//******************************************************************
//******************************************************************
void ShowProgress(UINT uMsg) {
gbSomebodyWonGameKludge = FALSE;
plrmsg_hold(TRUE);
app_assert(ghMainWnd);
WNDPROC saveProc = my_SetWindowProc(DisableInputWndProc);
interface_msg_pump();
// load progress background and fade in
ClrDraw();
FullBlit(TRUE);
ProgressLoad(uMsg);
BlackPalette();
ProgressIntDraw();
PaletteFadeIn(FADE_FAST);
IntCheck();
sound_init();
IntCheck();
switch (uMsg) {
case WM_DIABLOADGAME :
IntCheck();
GM_LoadGame(TRUE);
IntCheck();
break;
case WM_DIABNEWGAME :
IntCheck();
FreeGameMem();
IntCheck();
DestroyTempSaves();
LoadGameLevel(TRUE, LVL_DOWN);
IntCheck();
break;
case WM_DIABNEXTLVL :
IntCheck();
if (gbMaxPlayers == 1) SaveLevel();
else DeltaSaveLevel();
FreeGameMem();
currlevel++;
leveltype = gnLevelTypeTbl[currlevel];
app_assert(plr[myplr].plrlevel == currlevel);
IntCheck();
LoadGameLevel(FALSE, LVL_DOWN);
IntCheck();
break;
case WM_DIABPREVLVL :
IntCheck();
if (gbMaxPlayers == 1) SaveLevel();
else DeltaSaveLevel();
IntCheck();
FreeGameMem();
currlevel--;
leveltype = gnLevelTypeTbl[currlevel];
app_assert(plr[myplr].plrlevel == currlevel);
IntCheck();
LoadGameLevel(FALSE, LVL_UP);
IntCheck();
break;
case WM_DIABSETLVL :
SetReturnLvlPos();
if (gbMaxPlayers == 1) SaveLevel();
else DeltaSaveLevel();
setlevel = TRUE;
leveltype = setlvltype;
FreeGameMem();
IntCheck();
LoadGameLevel(FALSE, LVL_SET);
IntCheck();
break;
case WM_DIABRTNLVL :
if (gbMaxPlayers == 1) SaveLevel();
else DeltaSaveLevel();
setlevel = FALSE;
FreeGameMem();
IntCheck();
GetReturnLvlPos();
LoadGameLevel(FALSE, LVL_RTN);
IntCheck();
break;
case WM_DIABWARPLVL :
IntCheck();
if (gbMaxPlayers == 1) SaveLevel();
else DeltaSaveLevel();
FreeGameMem();
GetPortalLevel();
IntCheck();
LoadGameLevel(FALSE, LVL_WARP);
IntCheck();
break;
case WM_DIABTOWNWARP:
IntCheck();
if (gbMaxPlayers == 1) SaveLevel();
else DeltaSaveLevel();
FreeGameMem();
currlevel = plr[myplr].plrlevel;
leveltype = gnLevelTypeTbl[currlevel];
app_assert(plr[myplr].plrlevel == currlevel);
IntCheck();
LoadGameLevel(FALSE, LVL_TWARPDN);
IntCheck();
break;
case WM_DIABTWARPUP:
IntCheck();
if (gbMaxPlayers == 1) SaveLevel();
else DeltaSaveLevel();
FreeGameMem();
currlevel = plr[myplr].plrlevel;
leveltype = gnLevelTypeTbl[currlevel];
app_assert(plr[myplr].plrlevel == currlevel);
IntCheck();
LoadGameLevel(FALSE, LVL_TWARPUP);
IntCheck();
break;
case WM_DIABRETOWN:
IntCheck();
if (gbMaxPlayers == 1) SaveLevel();
else DeltaSaveLevel();
FreeGameMem();
currlevel = plr[myplr].plrlevel;
leveltype = gnLevelTypeTbl[currlevel];
app_assert(plr[myplr].plrlevel == currlevel);
IntCheck();
LoadGameLevel(FALSE, LVL_DOWN);
IntCheck();
break;
}
// cleanup
app_assert(ghMainWnd);
PaletteFadeOut(FADE_FAST);
ProgressFree();
// restore window procedure
saveProc = my_SetWindowProc(saveProc);
app_assert(saveProc == DisableInputWndProc);
NetSendCmdLocParam1(
TRUE,
CMD_PLAYER_JOINLEVEL,
plr[myplr]._px,
plr[myplr]._py,
plr[myplr].plrlevel
);
plrmsg_hold(FALSE);
ResetPal();
if (gbSomebodyWonGameKludge && plr[myplr].plrlevel == 16) {
// somebody killed diablo while we were on the stairs
void PrepDoEnding();
PrepDoEnding();
}
gbSomebodyWonGameKludge = FALSE;
}

19
src/INTERFAC.H Normal file
View File

@ -0,0 +1,19 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Constants and Variables
**
** (C)1996 Condor, Inc. All rights reserved.
**-----------------------------------------------------------------------**
** $Header: /Diablo/INTERFAC.H 1 1/22/97 2:06p Dgartner $
**-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------**
** Externs
**-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------**
** Prototypes
**-----------------------------------------------------------------------*/
BOOL IntCheck();

3086
src/INV.CPP Normal file

File diff suppressed because it is too large Load Diff

96
src/INV.H Normal file
View File

@ -0,0 +1,96 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Constants and Variables
**
** (C)1995 Condor, Inc. All rights reserved.
**-----------------------------------------------------------------------**
** $Header: /Diablo/INV.H 3 2/14/97 11:23a Dbrevik $
**-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------**
** Externs
**-----------------------------------------------------------------------*/
extern BOOL invflag;
extern BOOL drawsbarflag;
/*-----------------------------------------------------------------------**
** Prototypes
**-----------------------------------------------------------------------*/
void InitInv();
void DrawInv();
void DrawSpdBar();
void FreeInvGFX();
void CheckInvScrn();
void CheckSpdBar();
void InvGetItem(int, int);
void AutoGetItem(int, int);
int FindGetItem(int, WORD, int);
void SyncGetItem(int, int, int, WORD, int);
int InvPutItem(int, int, int);
int SyncPutItem(int,
int,
int,
int,
WORD,
int,
BOOL,
int,
int,
int,
int,
int,
DWORD,
int,
int,
int,
int,
int,
int);
BOOL TryInvPut();
char CheckInvHLight();
void RemoveInvItem(int, int);
void CheckInvPaste(int, int, int);
// drb.patch1.start.02/10/97
//void SyncInvPaste(int pnum, BYTE bLoc, int idx, WORD icreateinfo, int iseed);
void SyncInvPaste(int pnum, BYTE bLoc, int idx, WORD icreateinfo, int iseed, BOOL Id);
// drb.patch1.end.02/10/97
void CheckInvCut(int, int, int);
void SyncInvCut(int pnum, BYTE bLoc);
BOOL CheckUsable(int, int);
BOOL UseInvItem(int, int);
void RemoveScroll(int);
BOOL UseScroll();
void UseStaffCharge(int);
BOOL UseStaff();
BOOL UseStaffSBook(int);
BOOL AutoPlace(int, int, int, int, BOOL);
BOOL SpecialAutoPlace(int, int, int, int, BOOL);
void DoTelekinesis();
long CalculateGold(int pnum);
void RemoveSpdBarItem(int pnum, int iv);
BOOL DropItemBeforeTrig();
int GetHighRingValue(int /* myPlr */);
int GetHighBowValue(int /* myPlr */);
int GetHighStaffValue(int /* myPlr */);
int GetHighSwordValue(int /* myPlr */);
int GetHighHelmValue(int /* myPlr */);
int GetHighArmorValue(int /* myPlr */);
int GetHighMaceValue(int /* myPlr */);
int GetHighAmuletValue(int /* myPlr */);
int GetHighAxeValue(int /* myPlr */);
int GetHighShieldValue(int /* myPlr */);

2255
src/ITEMDAT.CPP Normal file

File diff suppressed because it is too large Load Diff

301
src/ITEMDAT.H Normal file
View File

@ -0,0 +1,301 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Constants and Variables
**
** (C)1995 Condor, Inc. All rights reserved.
**-----------------------------------------------------------------------**
** $Header: /Diablo/ITEMDAT.H 1 1/22/97 2:06p Dgartner $
**-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------**
** Powers List
**-----------------------------------------------------------------------*/
#define PL_TOHIT 0 // To hit
#define PL_NTOHIT 1 // Negative to hit
#define PL_TODAM 2 // Damage amount %
#define PL_NTODAM 3 // Negative damage amount %
#define PL_DAHT 4 // Damage and to hit %
#define PL_NDAHT 5 // Negative damage and to hit %
#define PL_AC 6 // Armor Class % increase
#define PL_NAC 7 // Negative % Armor Class
#define PL_RFIRE 8 // Resistance to fire %
#define PL_RLGHT 9 // Resistance to lightning %
#define PL_RMAG 10 // Resistance to misc magic %
#define PL_RALL 11 // Resistance to all
//#define PL_SCOST 12 // Spell cost (-) (removed by drb for multiplayer pickup flag)
//#define PL_SDUR 13 // Spell duration (removed by drb for unique crash)
#define PL_SLVL 14 // Spell levels
#define PL_CHRG 15 // Staff charges
#define PL_FHIT 16 // Fire hit
#define PL_LHIT 17 // Lightning hit
#define PL_CHAOS 18 //not in game
#define PL_STR 19 // Strength attribute
#define PL_NSTR 20 // Negative strength attribute
#define PL_MAG 21 // Magic attribute
#define PL_NMAG 22 // Negative magic attribute
#define PL_DEX 23 // Dexterity attribute
#define PL_NDEX 24 // Negative dexterity attribute
#define PL_VIT 25 // Vitality attribute
#define PL_NVIT 26 // Negative vitality attribute
#define PL_STATS 27 // All attributes
#define PL_NSTATS 28 // Negative all attributes
#define PL_GETHIT 29 // Add to every get hit
#define PL_NGETHIT 30 // Subtract from every get hit
#define PL_HP 31 // Hit points attribute
#define PL_NHP 32 // Negative hit points attribute
#define PL_MANA 33 // Mana attribute
#define PL_NMANA 34 // Negative mana attribute
#define PL_DUR 35 // Add to item's durability %
#define PL_NDUR 36 // Subtract from item's durability %
#define PL_IND 37 // Infinite durability
#define PL_LIGHT 38 // Add to player's light source
#define PL_NLIGHT 39 // Subtract from player's light source
#define PL_INVIS 40 //not in game Player invisible from radius
#define PL_NUMARWS 41 // Shoots multiple arrows
#define PL_FARROW 42 // Fire arrows
#define PL_LARROW 43 // Lightning arrows
#define PL_GFX 44 // Change to unique graphic
#define PL_THORN 45 // When item deals damage user gets damaged too
#define PL_LMANA 46 // Player looses all mana/ can't regen
#define PL_NOHEAL 47 // User can't heal
#define PL_FEAR 48 // When monster is struck, runs in fear (50%-ML)
#define PL_RABID 49 //not in game
#define PL_HITADD 50 // Half damage is added to player's hp
#define PL_SEEINVIS 51 //not in game See invisible
#define PL_TRAPDAM 52 // Half trap damage
#define PL_BEAR 53 // Knock monster back a square (if poss)
#define PL_MNOHEAL 54 // Monster no longer heals
#define PL_BAT 55 // Damage done adds to mana
#define PL_LEECH 56 // Damage dones adds to life
#define PL_ENAC 57 // Reduces the enemies ac by this
#define PL_ATANIM 58 // Attack anim quicker
#define PL_HTANIM 59 // Hit anim quicker
#define PL_BLANIM 60 // Block anim quicker
#define PL_DAMADD 61 // Damage Hit point modifier
// From here down, from uniques
#define PL_RNDARW 62 // Random arrow speeds
#define PL_DAMAGE 63 // Changes weapon damage to (param1-param2)
#define PL_DURNUM 64 // Durability set to param1
#define PL_NSTRREQ 65 // No minimum strength requirement
#define PL_SPELL 66 // Add charges to your staff
#define PL_FALCON 67 // Skips frames 1-3 of swing anim
#define PL_ONEHAND 68 // Change item to one handed
#define PL_DAMDEMON 69 // damage vs. demon only
#define PL_ZERORES 70 // All resistance equal to zero
#define PL_HYPER 71 // Hyperspace spell (param1 charges)
#define PL_CONST 72 // Constricting
#define PL_SKING 73 // Skeleton king power (life stealing)
#define PL_INFRA 74 // Infravision
#define PL_ACTUALAC 75 // Actual Armor Class
#define PL_HARQUN 76 // +(Armor Class)HP
#define PL_HARQUN2 77 // +(Mana/10)armor
#define PL_HARQUN3 78 // +(30-charlevel) resist fire
#define PL_NACTULAC 79 // Negative actual armor class
#define PL_NRFIRE 80 // Resistance to fire % (negative)
#define PL_NRLGHT 81 // Resistance to lightning % (negative)
#define PL_NRMAG 82 // Resistance to misc magic % (negative)
#define PL_NRALL 83 // Resistance to all % (negative)
#define PL_DEVAST 84
#define PL_DECAY 85
#define PL_PERIL 86
#define PL_RNDDAM 87
#define PL_FRAGILE 88
#define PL_DOPPEL 89
#define PL_DEMONAC 90
#define PL_UNDEADAC 91
#define PL_ACOLYTE 92
#define PL_GLADIATR 93
#define PL_X 94 // Unknown???? TEMP--------
/*-----------------------------------------------------------------------**
** Power List Bit flags
**-----------------------------------------------------------------------*/
#define PLF_ARMOR 0x100000
#define PLF_SHIELD 0x010000
#define PLF_WEAPON 0x001000
#define PLF_STAFF 0x000100
#define PLF_BOW 0x000010
#define PLF_RING 0x000001
/*-----------------------------------------------------------------------**
** Item Misc Id
**-----------------------------------------------------------------------*/
#define IMID_NONE 0 // No misc ability
#define IMID_FIRSTPOT 1
#define IMID_PHEAL 2 // Potion of full heal
#define IMID_PLHEAL 3 // Potion of Light heal
#define IMID_PSHEAL 4 // Potion of Serious heal
#define IMID_PDHEAL 5 // Potion of Deadly heal
#define IMID_PMANA 6 // Potion of Mana
#define IMID_PFMANA 7 // Potion of Full mana
#define IMID_PEXP 8 // Potion of Experience
#define IMID_PNEXP 9 // Potion of Negative Experience
#define IMID_ESTR 10 // Elixir of Strength
#define IMID_EMAG 11 // Elixir of Magic
#define IMID_EDEX 12 // Elixir of Dexterity
#define IMID_EVIT 13 // Elixir of Vitality
#define IMID_ENSTR 14 // Elixir of Negative Strength
#define IMID_ENMAG 15 // Elixir of Negative Magic
#define IMID_ENDEX 16 // Elixir of Negative Dexerity
#define IMID_ENVIT 17 // Elixir of Negative Vitaltiy
#define IMID_REJUV 18
#define IMID_FREJUV 19
#define IMID_LASTPOT 20
#define IMID_SCROLL 21 // Scroll of spell
#define IMID_TSCROLL 22 // Scroll of targeted spell
#define IMID_STAFF 23 // Item with a spell
#define IMID_BOOK 24 // Book of spell
#define IMID_RING 25
#define IMID_AMULET 26
#define IMID_UNIQUE 27 // Unique item so no magic / magic already built in
#define IMID_MEAT 28 // Slab of meat
#define IMID_FIRSTOIL 29
#define IMID_OIL 30
#define IMID_OILACC 31
#define IMID_OILMAST 32
#define IMID_OILSHRP 33
#define IMID_OILDEATH 34
#define IMID_OILSKILL 35
#define IMID_OILBLKSM 36
#define IMID_OILFORT 37
#define IMID_OILPERM 38
#define IMID_OILHARD 39
#define IMID_OILIMPER 40
#define IMID_LASTOIL 41
#define IMID_MAPOFDOOM 42 // The end quest map of doom item
#define IMID_EAR 43
#define IMID_SPECTRAL 44
#define IMID_BOMB 45
#define IMID_FIRSTRUNE 46
#define IMID_RUNEFIRE 47
#define IMID_RUNELIGHT 48
#define IMID_RUNENOVA 49
#define IMID_RUNEIMMOLATE 50
#define IMID_RUNESTONE 51
#define IMID_LASTRUNE 52
#define IMID_AURIC 53
#define IMID_FULLNOTE 54
/*-----------------------------------------------------------------------**
** Item Id's
**-----------------------------------------------------------------------*/
#define ITEMID_NONE 0
#define ITEMID_SHORTBOW 1
#define ITEMID_LONGBOW 2
#define ITEMID_BOW 3
#define ITEMID_COMPBOW 4
#define ITEMID_LWARBOW 5
#define ITEMID_LBATTLEBOW 6
#define ITEMID_DAGGER 7
#define ITEMID_FALCHION 8
#define ITEMID_CLAYMORE 9
#define ITEMID_BROADSWORD 10
#define ITEMID_SABRE 11
#define ITEMID_SCIMITAR 12
#define ITEMID_LONGSWORD 13
#define ITEMID_BASTSWORD 14
#define ITEMID_2HANDSWORD 15
#define ITEMID_GREATSWORD 16
#define ITEMID_CLEAVER 17
#define ITEMID_LARGEAXE 18
#define ITEMID_BROADAXE 19
#define ITEMID_SMALLAXE 20
#define ITEMID_BATTLEAXE 21
#define ITEMID_GREATAXE 22
#define ITEMID_MACE 23
#define ITEMID_MORNSTAR 24
#define ITEMID_CLUB 25
#define ITEMID_MAUL 26
#define ITEMID_WARHAMMER 27
#define ITEMID_FLAIL 28
#define ITEMID_LONGSTAFF 29
#define ITEMID_SHORTSTAFF 30
#define ITEMID_COMPSTAFF 31
#define ITEMID_QTRSTAFF 32
#define ITEMID_WARSTAFF 33
#define ITEMID_SKULLCAP 34
#define ITEMID_HELM 35
#define ITEMID_GREATHELM 36
#define ITEMID_CROWN 37
#define ITEMID_RAGS 39
#define ITEMID_STDLEATHER 40
#define ITEMID_CLOAK 41
#define ITEMID_ROBE 42
#define ITEMID_CHAINMAIL 43
#define ITEMID_LEATHER 44
#define ITEMID_BREASTPLATE 45
#define ITEMID_CAPE 46
#define ITEMID_PLATEMAIL 47
#define ITEMID_FULLPLATE 48
#define ITEMID_BUCKLER 49
#define ITEMID_SMALLSHLD 50
#define ITEMID_LARGESHLD 51
#define ITEMID_KITESHLD 52
#define ITEMID_TOWERSHLD 53
#define ITEMID_RING 54
#define ITEMID_BOOK 55
#define ITEMID_AMULET 56
#define ITEMID_SKCROWN 57
#define ITEMID_IRING 58
#define ITEMID_OPTAMULET 59
#define ITEMID_TRING 60
#define ITEMID_HALCREST 61
#define ITEMID_MAP 62
#define ITEMID_ELIXIR 63
#define ITEMID_ARMOFVAL 64
#define ITEMID_STEELVEIL 65
#define ITEMID_GRISWOLD 66
#define ITEMID_LGTFORGE 67
#define ITEMID_LAZSTAFF 68
#define ITEMID_ARMRCOW 69// dude!
/*-----------------------------------------------------------------------**
** Externs
**-----------------------------------------------------------------------*/
extern ItemDataStruct AllItemsList[];
extern const PLStruct PL_Prefix[];
extern const PLStruct PL_Suffix[];
extern const UItemStruct UniqueItemList[];

5532
src/ITEMS.BAK Normal file

File diff suppressed because it is too large Load Diff

5992
src/ITEMS.CPP Normal file

File diff suppressed because it is too large Load Diff

905
src/ITEMS.H Normal file
View File

@ -0,0 +1,905 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Constants and Variables
**
** (C)1995 Condor, Inc. All rights reserved.
**-----------------------------------------------------------------------**
** $Header: /Diablo/ITEMS.H 3 2/06/97 6:08p Jessmac $
**-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------**
** Defines
**-----------------------------------------------------------------------*/
#define MAXITEMS 127
#define MAXUITEMS 128 // Max number of uniques
#define TEMPAVAIL 127
#define ITEM_RND -1
#define INFINITE_DUR 255
#define GOLD_VT1 1000 // Gold gfx transition from 1 to several
#define GOLD_VT2 2500 // Gold gfx transition from several to many
//#define GOLD_VMAX 5000 // Max gold in an inv slot
extern int GOLD_VMAX;
extern const int GOLD_DOUBLE_VMAX;
// Used for cursors
// 1x1
typedef enum {
ITEM_BLUEBTL = 0,
ITEM_SCROLL , // 1
ITEM_SCROLL2 , // 2
ITEM_SCROLL3 , // 3
ITEM_1GOLD , // 4
ITEM_3GOLD , // 5
ITEM_5GOLD , // 6
ITEM_GOLDRING , // 7
ITEM_1JRING , // 8
ITEM_WOODRING , // 9
ITEM_BLUERING , // 10
ITEM_3JRING , // 11
ITEM_SLVRRING , // 12
ITEM_MJRING , // 13
ITEM_BRNRING , // 14
ITEM_SPECTRAL , // 15
ITEM_3COLORPOT , // 16
ITEM_GOLDENELIX , // 17
ITEM_EMPYBAND , // 18
ITEM_EAR1 , // 19
ITEM_EAR2 , // 20
ITEM_EAR3 , // 21
ITEM_SPHERE , // 22
ITEM_CUBE , // 23
ITEM_PYRIMID , // 24
ITEM_BLOODGEM , // 25
ITEM_JSPHERE , // 26
ITEM_JCUBE , // 27
ITEM_JPYRIMID , // 28
ITEM_VILE , // 29
ITEM_BLKBTL , // 30
ITEM_WHTEBTL , // 31
ITEM_REDBTL , // 32
ITEM_YELBTL , // 33
ITEM_ORGBTL , // 34
ITEM_BREDBTL , // 35
ITEM_BLKBTL2 , // 36
ITEM_GOLDBTL , // 37
ITEM_LTBLUEBTL , // 38
ITEM_BLUEBTL2 , // 39
ITEM_BRAIN , // 40
ITEM_CLAW , // 41
ITEM_FANG , // 42
ITEM_BREAD , // 43
ITEM_AMULET , // 44
ITEM_AMULET1 , // 45
ITEM_AMULET2 , // 46
ITEM_AMULET3 , // 47
ITEM_AMULET4 , // 48
ITEM_POUCH1 , // 49
// 1x2
ITEM_DAGGER1 , // 50
ITEM_DAGGER2 , // 51
ITEM_BIGBOTTLE , // 52
ITEM_DAGGER3 , // 53
ITEM_DAGGER4 , // 54
ITEM_DAGGER5 , // 55
// 1x3
ITEM_BLADE , // 56
ITEM_BASTSRD , // 57
ITEM_FALCHION , // 58
ITEM_MACE , // 59
ITEM_LONGSRD , // 60
ITEM_BROADSRD , // 61
ITEM_SCIMITAR , // 62
ITEM_MORNSTAR , // 63
ITEM_SHORTSRD , // 64
ITEM_CLAYMORE , // 65
ITEM_CLUB , // 66
ITEM_SABRE , // 67
ITEM_KNTSWORD , // 68
ITEM_CLUB1 , // 69
ITEM_CLUB2 , // 70
ITEM_CLUB3 , // 71
ITEM_SCIMITAR2 , // 72
ITEM_MAGSWORD , // 73
ITEM_SKULSWORD , // 74
// 2x2
ITEM_HELM , // 75
ITEM_ROCK , // 76
ITEM_CROWN , // 77
ITEM_SKCROWN , // 78
ITEM_MCROWN , // 79
ITEM_JESTER , // 80
ITEM_HARLEQ , // 81
ITEM_FHELM , // 82
ITEM_BUCKLER , // 83
ITEM_FHELM2 , // 84
ITEM_GRTHELM , // 85
ITEM_BOOK2 , // 86
ITEM_BOOK3 , // 87
ITEM_BOOK , // 88
ITEM_MUSHROOM , // 89
ITEM_SKLCAP , // 90
ITEM_LCAP , // 91
ITEM_FLESH , // 92
ITEM_SKLCAP2 , // 93
ITEM_CLOTHES , // 94
ITEM_CROWN2 , // 95
ITEM_MAP , // 96
ITEM_BOOK4 , // 97
ITEM_FHELM3 , // 98
ITEM_SAMHELM , // 99
///#define ITEM_MUSHROOM 100
// 2x3
ITEM_COMPSHLD , // 100
ITEM_BTLAXE , // 101
ITEM_LONGBOW , // 102
ITEM_PARMOR , // 103
ITEM_AXE , // 104
ITEM_WSHIELD , // 105
ITEM_CLEAVER , // 106
ITEM_STDARMOR , // 107
ITEM_COMPBOW , // 108
ITEM_SHRTSTAFF , // 109
ITEM_2HSWORD , // 110
ITEM_CHARMOR , // 111
ITEM_SMALLAXE , // 112
ITEM_HVYSHIELD , // 113
ITEM_SCLARMOR , // 114
ITEM_SMLSHLD , // 115
ITEM_SKULLSHLD , // 116
ITEM_WOLFSHLD , // 117
ITEM_SHORTBOW , // 118
ITEM_STLLONGBOW , // 119
ITEM_STLSHRTBOW , // 120
ITEM_SMLWARHAM , // 121
ITEM_MAUL , // 122
ITEM_IRONSTAFF , // 123
ITEM_STLSTAFF , // 124
ITEM_LONGSTAFF , // 125
ITEM_INNSIGN , // 126
ITEM_HLARMOR , // 127
ITEM_RAGS , // 128
ITEM_QARMOR , // 129
ITEM_BALLNCHN , // 130
ITEM_FLAIL , // 131
ITEM_TSHIELD , // 132
ITEM_HNTRBOW , // 133
ITEM_GRTSWORD , // 134
ITEM_LARMOR , // 135
ITEM_SPLTARMOR , // 136
ITEM_ROBE , // 137
ITEM_HVYROBE , // 138
ITEM_RINGARMOR , // 139
ITEM_ANVIL , // 140 //#define ITEM_OBOLISK 140
ITEM_BROADAXE , // 141
ITEM_LRGAXE , // 142
ITEM_WICKAXE , // 143
ITEM_HANDAXE , // 144
ITEM_GREATAXE , // 145
ITEM_IRONSHLD , // 146
ITEM_KITESHLD , // 147
ITEM_LRGSHLD , // 148
ITEM_CLOAK , // 149
ITEM_CAPE , // 150
ITEM_PARMOR2 , // 151
ITEM_PARMOR3 , // 152
ITEM_BPLATE , // 153
ITEM_RINGMAIL , // 154
ITEM_BISHOPSTF , // 155
ITEM_GEMGRTAXE , // 156
ITEM_ARKARMOR , // 157
ITEM_CROSBOW , // 158
ITEM_NAJARMOR , // 159
ITEM_GRIZZLY , // 160
ITEM_GRANDPA , // 161
ITEM_PROTECT , // 162
ITEM_REAVER , // 163
ITEM_WINDFOR , // 164
ITEM_SWARBOW , // 165
ITEM_COMPSTF , // 166
ITEM_SBATLBOW , // 167
ITEM_GOLD , // 168
// New 1x1
ITEM_MERLINRING = 168, // 168 // intentional duplicate to gold.
ITEM_MANARING , // 169
ITEM_AMULWARD , // 170
ITEM_NECMAGIC , // 171
ITEM_NECHEALTH , // 172
ITEM_KARIKSRING , // 173
ITEM_RINGGROUND , // 174
ITEM_AMULPROT , // 175
ITEM_MERCRING , // 176
ITEM_RINGTHUND , // 177
ITEM_NECTRUTH , // 178
ITEM_RINGGIANTS , // 179
ITEM_AMULGOLD , // 180
ITEM_RINGMYSTIC , // 181
ITEM_RINGCOPPER , // 182
ITEM_AMULACOLYT , // 183
ITEM_RINGMAGMA , // 184
ITEM_NECPURIFY , // 185
ITEM_RINGGLADTR , // 186
ITEM_RUNEBOMB , // 187
ITEM_THEODORE ,
ITEM_TORNPAPER1 ,
ITEM_TORNPAPER2 ,
ITEM_TORNPAPER3 ,
ITEM_WHOLEPAPER ,
ITEM_FIRERUNE1 ,
ITEM_FIRERUNE2 ,
ITEM_LIGHTRUNE1 ,
ITEM_LIGHTRUNE2 ,
ITEM_STONERUNE ,
// new 2x2
ITEM_SUITGREY,
ITEM_SUITBRWN,
// new 1x3
ITEM_SWORDEDGE , // 188
ITEM_SWORDGLAM , // 189
ITEM_SWORDSERR , // 190
// new 2x3
ITEM_ARMRDARK , // 191
ITEM_ARMRBONECH , // 192
ITEM_HAMRTHUND , // 193
ITEM_SWRDCRYSTL , // 194
ITEM_STAFJESTER , // 195
ITEM_STAFMANA , // 196
ITEM_BOWVULCAN , // 197
ITEM_BOWSPEED , // 198
ITEM_AXEANCIENT , // 199
ITEM_CLUBCARNAG , // 200
ITEM_MACEDARK , // 201
ITEM_CLUBDECAY , // 202
ITEM_AXEDECAY , // 203
ITEM_SWRDDECAY , // 204
ITEM_MACEDECAY , // 205
ITEM_STAFDECAY , // 206
ITEM_BOWDECAY , // 207
ITEM_CLUBOUCH , // 208
ITEM_SWRDDEVAST , // 209
ITEM_AXEDEVAST , // 210
ITEM_MORNDEVAST , // 211
ITEM_MACEDEVAST, // 212
ITEM_ARMRDMNPLT,
ITEM_ARMRCOW,
ITEM_LAST_ID
} ITEM_IDS;
// Split later
// Used for plr gfx
#define IT_MISC 0
#define IT_SWORD 1
#define IT_AXE 2
#define IT_BOW 3
#define IT_MACE 4
#define IT_SHIELD 5
#define IT_ARMOR 6
#define IT_HELM 7
#define IT_MARMOR 8
#define IT_HARMOR 9
#define IT_STAFF 10
#define IT_GOLD 11
#define IT_RING 12
#define IT_AMULET 13
#define IT_FOOD 14
// Used for inv location
#define IL_HAND 1
#define IL_2HAND 2
#define IL_BODY 3
#define IL_HEAD 4
#define IL_RING 5
#define IL_NECK 6
#define IL_INV 7
#define IL_SPD 8
// Item classification for treasure types
#define IC_WEAP 1
#define IC_ARMOR 2
#define IC_ITEM 3
#define IC_GOLD 4
#define IC_SPECIAL 5
// Set item indexes for first non-random items
enum _item_indexes {
IDI_GOLD=0, // Item Data Table indexes
// Init items
IDI_WARRIOR,
IDI_WARRSHLD,
IDI_WARRCLUB,
IDI_ROGUE,
IDI_SORCEROR,
// Quest items
IDI_FIRSTQUEST,
IDI_CLEAVER=IDI_FIRSTQUEST,
IDI_SKCROWN, // Same as cleaver
IDI_INFRARING, // Same as cleaver
IDI_ROCK,
IDI_OPTAMULET,
IDI_TRING, // Same as cleaver
IDI_BANNER,
IDI_HARCREST, // Same as cleaver
IDI_STEELVEIL, // Same as cleaver
IDI_GLDNELIX, // Golden Elixor
IDI_ANVIL, // Anvil of Dawn
IDI_MUSHROOM, // Black Mushroom
IDI_BRAIN, // Brain
IDI_FUNGALTM, // Fungal Tome
IDI_SPECELIX, // Spectral Elixir
IDI_BLDSTONE, // Blood Stones
IDI_MAPOFDOOM,
IDI_LASTQUEST=IDI_MAPOFDOOM,
// Ears
IDI_EAR,
// Useful item
IDI_HEAL,
IDI_MANA,
IDI_IDENTIFY,
IDI_PORTAL,
// New items
IDI_ARMOFVAL, // Same as cleaver
IDI_FULLHEAL,
IDI_FULLMANA,
IDI_GRISWOLD,
IDI_ARMRCOW,
IDI_LAZSTAFF,
IDI_RESURRECT,
IDI_OILACC,
IDI_MONK,
IDI_BARD,
IDI_BARDDAGGER,
IDI_RUNEBOMB,
IDI_THEODORE,
IDI_AURIC,
IDI_NOTE1,
IDI_NOTE2,
IDI_NOTE3,
IDI_FULLNOTE,
IDI_SUITBRWN,
IDI_SUITGREY,
// Items for randomizing.
// Helmets and caps
IDI_CAP,
IDI_SKULLCAP,
IDI_HELM,
IDI_FULLHELM,
IDI_CROWN,
IDI_GREATHEALM,
// Body Armor
IDI_CAPE,
IDI_RAGS,
IDI_CLOAK,
IDI_ROBE,
IDI_QUILTED_ARMOR,
IDI_LEATHER_ARMOR,
IDI_HARD_LEATHER_ARMOR,
IDI_STUDDED_LEATHER_ARMOR,
IDI_RING_MAIL,
IDI_CHAIN_MAIL,
IDI_SCALE_MAIL,
IDI_BREAST_PLATE,
IDI_SPLINT_MAIL,
IDI_PLATE_MAIL,
IDI_FIELD_PLATE,
IDI_GOTHIC_PLATE,
IDI_FULL_PLATE_MAIL,
IDI_BUCKLER,
IDI_SMALL_SHIELD,
IDI_LARGE_SHIELD,
IDI_KITE_SHIELD,
IDI_TOWER_SHIELD,
IDI_GOTHIC_SHIELD,
IDI_POTION_OF_HEALING,
IDI_POTION_OF_FULL_HEALING,
IDI_POTION_OF_MANA,
IDI_POTION_OF_FULL_MANA,
// unused IDI_POTION_OF_EXPERIENCE,
IDI_POTION_OF_REJUVENATION,
IDI_POTION_OF_FULL_REJUVENATION,
IDI_BLACKSMITH_OIL,
IDI_OIL_OF_ACCURACY,
IDI_OIL_OF_SHARPNESS,
IDI_OIL, // random attributes.
IDI_ELIXIR_OF_STRENGTH,
IDI_ELIXIR_OF_MAGIC,
IDI_ELIXIR_OF_DEXTERITY,
IDI_ELIXIR_OF_VITALITY,
// unused IDI_SCROLL_OF_FIREBOLT,
// unused IDI_SCROLL_OF_CHARGED_BOLT,
// unused IDI_SCROLL_OF_HOLY_BOLT,
IDI_SCROLL_OF_HEALING,
IDI_SCROLL_OF_SEARCH,
IDI_SCROLL_OF_LIGHTNING,
IDI_SCROLL_OF_IDENTIFY,
IDI_SCROLL_OF_RESURRECT,
IDI_SCROLL_OF_FIREWALL,
// unused IDI_SCROLL_OF_TELEKINESIS,
IDI_SCROLL_OF_INFERNO,
IDI_SCROLL_OF_TOWN_PORTAL,
IDI_SCROLL_OF_FLASH,
IDI_SCROLL_OF_INFRAVISION,
IDI_SCROLL_OF_PHASING,
IDI_SCROLL_OF_MANA_SHIELD,
IDI_SCROLL_OF_FLAMEWAVE,
IDI_SCROLL_OF_FIREBALL,
IDI_SCROLL_OF_STONECURSE,
IDI_SCROLL_OF_CHAIN_LIGHTNING,
IDI_SCROLL_OF_GUARDIAN,
IDI_UNUSED_SCROLL,
IDI_SCROLL_OF_NOVA,
IDI_SCROLL_OF_GOLEM,
IDI_SCROLL_OF_BLOODBOIL, // unused
IDI_SCROLL_OF_TELEPORT,
IDI_SCROLL_OF_APOCALYPSE,
// unused IDI_SCROLL_OF_BONESPIRIT,
// unused IDI_SCROLL_OF_BLOODSTAR,
IDI_FIRST_BOOK,
IDI_SECOND_BOOK,
IDI_THIRD_BOOK,
IDI_LAST_BOOK,
IDI_DAGGER,
IDI_SHORT_SWORD,
IDI_FALCHION,
IDI_SCIMITAR,
IDI_CLAYMORE,
IDI_BLADE,
IDI_SABRE,
IDI_LONG_SWORD,
IDI_BROAD_SWORD,
IDI_BASTARD_SWORD,
IDI_TWO_HANDED_SWORD,
IDI_GREAT_SWORD,
IDI_SMALL_AXE,
IDI_AXE,
IDI_LARGE_AXE,
IDI_BROAD_AXE,
IDI_BATTLE_AXE,
IDI_GREAT_AXE,
IDI_MACE,
IDI_MORNINGSTAR,
IDI_WAR_HAMMER,
IDI_SPIKED_CLUB,
IDI_CLUB,
IDI_FLAIL,
IDI_MAUL,
IDI_SHORT_BOW,
IDI_HUNTERS_BOW,
IDI_LONG_BOW,
IDI_COMPOSITE_BOW,
IDI_SHORT_WAR_BOW,
IDI_LONG_WAR_BOW,
IDI_SHORT_STAFF,
IDI_LONG_STAFF,
IDI_COMPOSITE_STAFF,
IDI_QUARTER_STAFF,
IDI_WAR_STAFF,
IDI_FIRST_RING,
IDI_SECOND_RING,
IDI_LAST_RING,
IDI_FIRST_AMULET,
IDI_LAST_AMULET,
IDI_RUNE_OF_FIRE,
IDI_RUNE_OF_LIGHTNING,
IDI_GREATER_RUNE_OF_FIRE,
IDI_GREATER_RUNE_OF_LIGHTNING,
IDI_RUNE_OF_STONE,
// Insert any new items above this line.
IDI_LAST_RANDOM_ITEM
};
#define IDI_BARBARIAN IDI_SPIKED_CLUB
#define IDI_BARSHLD IDI_WARRSHLD
#define IAF_INFRAVISION 0x00000001
#define IAF_SKING 0x00000002
#define IAF_RNDARROW 0x00000004
#define IAF_FIREARROW 0x00000008
#define IAF_FIREHIT 0x00000010
#define IAF_LIGHTHIT 0x00000020
#define IAF_CONSTRICT 0x00000040
#define IAF_NOMANA 0x00000080
#define IAF_NOHEAL 0x00000100
#define IAF_RABID 0x00000200 // not in game
#define IAF_HALFTRAP 0x00000400 // not in game -called TRAPDAM
#define IAF_KNOCKBACK 0x00000800
#define IAF_MNOHEAL 0x00001000
#define IAF_BAT10 0x00002000
#define IAF_BAT20 0x00004000
#define IAF_ALLBAT (IAF_BAT10 | IAF_BAT20)
#define IAF_LEECH10 0x00008000
#define IAF_LEECH20 0x00010000
#define IAF_ALLLEECH (IAF_LEECH10 | IAF_LEECH20)
#define IAF_ATANIM1 0x00020000
#define IAF_ATANIM2 0x00040000
#define IAF_ATANIM3 0x00080000
#define IAF_ATANIM4 0x00100000
#define IAF_ALLATANIM (IAF_ATANIM1 | IAF_ATANIM2 | IAF_ATANIM3 | IAF_ATANIM4 )
#define IAF_HTANIM1 0x00200000
#define IAF_HTANIM2 0x00400000
#define IAF_HTANIM3 0x00800000
#define IAF_ALLHTANIM (IAF_HTANIM1 | IAF_HTANIM2 | IAF_HTANIM3)
#define IAF_BLANIM 0x01000000
#define IAF_LARROW 0x02000000
#define IAF_THORN 0x04000000
#define IAF_LMANA 0x08000000
#define IAF_TRAPDAM 0x10000000
#define IAF_OMEHAND 0x20000000
#define IAF_DAMDEMON 0x40000000
#define IAF_ZERORES 0x80000000
#define IAF2_DEVASTATION 0x00000001
#define IAF2_DECAY 0x00000002
#define IAF2_PERIL 0x00000004
#define IAF2_JESTER 0x00000008
#define IAF2_CLONE 0x00000010
#define IAF2_DEMONAC 0x00000020
#define IAF2_UNDEADAC 0x00000040
#define ISEL_NONE 0 // Items start out unselectable
#define ISEL_FLR 1 // Most items
#define ISEL_TOP 2 // Items on objects usually
#define ISEL_ALL 3 // Large (2 square) items
#define IMAGIC_NONE 0
#define IMAGIC_MAGIC 1
#define IMAGIC_UNIQUE 2
// Item re-creation information
// Creation bits are as follows:
// bit# desc
// 1-6 Level
// 7 Item Goodonly (T/F)
// 8,9 Unique percentage (0 = 0%, 1 = 15%, 2 = 1%)
// 8&9 Useful item only
// 10 Unique item
// 11 Spawned by Blacksmith
// 12 Spawned by Blacksmith premium
// 13 Spawned by Pegboy
// 14 Spawned by Witch
// 15 Spawned by Healer
#define ICI_USEFUL 0x0180
#define ICI_UPER1 0x0100
#define ICI_UPER15 0x0080
#define ICI_ONLYGOOD 0x0040
#define ICI_UNIQUE 0x0200
#define ICI_SMITH 0x0400
#define ICI_PREMIUM 0x0800
#define ICI_BOY 0x1000
#define ICI_WITCH 0x2000
#define ICI_HEALER 0x4000
#define ICI_PREGEN 0x8000
#define ICI_LVLMASK 0x003f
#define ICI_TOWNMASK 0x7c00
#define ICI_PREGENMASK 0x7fff
// Unique item index list
#define UID_CLEAVER 0 // Butcher's cleaver
#define UID_SKCROWN 1 // Skeleton King's crown
#define UID_INFRARING 2 // Infravision ring
#define UID_OPTAMULET 3 // Optic Amulet
#define UID_TRING 4 // Ring of truth
#define UID_HARCREST 5 // Harlequin Crest
#define UID_STEELVEIL 6 // Veil of Steel
#define UID_ARMOFVAL 7 // Armor of Valor
#define UID_GRISWOLD 8 // Griswold's Edge
#define UID_ARMRCOW 9 // Cow Armor
#define UID_LGTFORGE 9
// item no random spawn, normal random spawn, or double chance random spawn
#define IRND_NO 0
#define IRND_NORMAL 1
#define IRND_DOUBLE 2
#define RESIST_MAX 75
/*-----------------------------------------------------------------------**
** Structures
**-----------------------------------------------------------------------*/
typedef struct {
char *PLName; // Name of power
int PLPower; // Power type
int PLParam1; // Misc param 1
int PLParam2; // Misc param 2
char PLMinLvl; // Min dungeon level of power appearing
long PLIType; // Item type (armor/shield/weapon/staff/bow/ring)
byte PLGOE; // Good/Evil/Either
BOOL PLDouble; // Double chance of spawning (more common magic)
BOOL PLOk; // Item good or bad
int PLMinVal; // Item min value modifier
int PLMaxVal; // Item max value modifier
int PLMultVal; // Item value multiplier
} PLStruct;
typedef struct {
char *UIName; // Unique item name
char UIItemId; // Item id for base stats
char UIMinLvl; // Min level can be found at
char UINumPL; // Number of power list items
int UIValue; // Items value
char UIPower1; // Power 1 and 2 params
int UIParam1;
int UIParam2;
char UIPower2; // Power 2 and 2 params
int UIParam3;
int UIParam4;
char UIPower3; // Power 3 and 2 params
int UIParam5;
int UIParam6;
char UIPower4; // Power 4 and 2 params
int UIParam7;
int UIParam8;
char UIPower5; // Power 5 and 2 params
int UIParam9;
int UIParam10;
char UIPower6; // Power 6 and 2 params
int UIParam11;
int UIParam12;
} UItemStruct;
typedef struct {
BOOL iRnd; // Random item or special
char iClass; // Item classification
char iLoc; // Item Body Location
int iCurs; // Item cursor gfx
char itype; // Item type
char iItemId; // Item id#
char *iName; // name
char *iSName; // short name
char iMinMLvl; // Min monster level to drop it
int iDurability; // Durability of the item
int iMinDam; // Min damage
int iMaxDam; // Max damage
int iMinAC; // Min Armor Class
int iMaxAC; // Max Armor Class
char iMinStr; // Min Strength stat to use item
char iMinMag; // Min Magic stat to use item
char iMinDex; // Min Dexterity stat to use item
long iFlags; // Item ability flags
int iMiscId; // Misc item uses id
long iSpell; // item spell
BOOL iUsable; // Usable item?
int iValue; // item min value
int iMaxValue; // item max value
} ItemDataStruct;
// PATCH1.JMM
typedef struct {
int nSeed;
WORD wCI;
int nIndex;
DWORD dwTimestamp;
} ItemGetRecordStruct;
// ENDPATCH1.JMM
typedef struct {
int _iSeed; // item seed to generate itself
WORD _iCreateInfo; // item re-creation info
int _itype; // item type
int _ix; // item map x
int _iy; // item map y
BOOL _iAnimFlag; // Does this item animate?
BYTE *_iAnimData; // Data pointer to anim tables
int _iAnimLen; // number of anim frames
int _iAnimFrame; // current anim frame
long _iAnimWidth; // Width of anim
long _iAnimWidth2; // (Width - 64) >> 1 of anim
// PATCH1.JMM
// FLAG IS NO LONGER USED
//BOOL _iDelFlag; // Delete this item
BOOL _iInvalid;
// ENDPATCH1.JMM
char _iSelFlag; // Select top, floor, or all
BOOL _iPostDraw; // Draw after objects or before?
BOOL _iIdentified; // Has item been identified?
char _iMagical; // (No/Reg/Unique) Does the item have magical attributes?
char _iName[64]; // item name
char _iIName[64]; // identified name
char _iLoc; // item body location
char _iClass; // item classification
int _iCurs; // item cursor type
int _ivalue; // item value
int _iIvalue; // item identified value
int _iMinDam; // item min damage
int _iMaxDam; // item max damage
int _iAC; // item armor class
long _iFlags; // item ability flags
int _iMiscId; // Misc item uses id
int _iSpell; // item spell
int _iCharges; // random number of charges
int _iMaxCharges; // Max Charges of a staff
int _iDurability; // How much strength until it breaks
int _iMaxDur; // Max Durability
int _iPLDam; // Power List damage multiplier
int _iPLToHit; // Power List to hit increase
int _iPLAC; // Power List AC increase
int _iPLStr; // Power List Strength increase
int _iPLMag; // Power List Magic increase
int _iPLDex; // Power List Dexterity increase
int _iPLVit; // Power List Vitality increase
int _iPLFR; // Power List Fire resistance
int _iPLLR; // Power List Lightning resistance
int _iPLMR; // Power List Misc Magic resistance
long _iPLMana; // Power List Mana
long _iPLHP; // Power List Hit Points
int _iPLDamMod; // Power List damage modifier (num, not %)
int _iPLGetHit; // Power List Get hit modifier (+/-)
int _iPLLight; // Power List light radius
char _iSplLvlAdd; // What to add to each spell level
char _iRequest; // If item has be requested to be picked up (drb 12/9)
int _iUid; // If unique item, index into unique table (drb 12/8)
int _iFMinDam; // Fire hit min damage
int _iFMaxDam; // Fire hit max damage
int _iLMinDam; // Lightning hit min damage
int _iLMaxDam; // Lightning hit max damage
int _iPLEnAc; // Enemy armor class reduced by this amount
char _iPrePower; // Power List index for prefix
char _iSufPower; // Power List index for suffix
int _iVAdd1; // value add #1
int _iVMult1; // value multiplier #1
int _iVAdd2; // value add #2
int _iVMult2; // value multiplier #2
char _iMinStr; // Min Strength stat to use item
byte _iMinMag; // Min Magic stat to use item
char _iMinDex; // Min Dexterity stat to use item
BOOL _iStatFlag; // Draw with red filter or not
int IDidx; // AllItemsData index
char _oldlight; // Old prelight val
long _iFlags2; // item ability flags
} ItemStruct;
#define SAVE_ITEM_SIZE sizeof(ItemStruct)
/*-----------------------------------------------------------------------**
** Externs
**-----------------------------------------------------------------------*/
extern ItemStruct item[MAXITEMS+1];
extern long numitems;
extern int itemactive[MAXITEMS];
extern int itemavail[MAXITEMS];
// PATCH1.JMM
extern ItemGetRecordStruct itemgets[MAXITEMS];
extern int gnNumGetRecords;
// ENDPATCH1.JMM
extern BOOL UniqueItemFlag[MAXUITEMS];
extern BOOL uitemflag;
extern int ItemInvSnds[];
extern BYTE ItemCAnimTbl[];
#if CHEATS
extern BOOL davecheat;
extern int tstQMsgSpd;
extern int tstQMsgIndex;
extern BOOL tstQMsgFlag;
extern BOOL tstQMsgIndexFlag;
#endif
/*-----------------------------------------------------------------------**
** Prototypes
**-----------------------------------------------------------------------*/
void InitItems();
void ProcessItems();
void InitItemGFX();
void FreeItemGFX();
void DaveGold();
void DaveNewPremium();
void DaveCleanUp();
void DaveSpells();
void DaveSpells2();
void DaveQuestText();
BOOL ItemSpaceOk(int, int);
void SpawnItem(int, int, int, BOOL); // Called by monsters
void SpawnUnique(int, int, int); // Called by monsters
void RespawnItem(int ii, BOOL FlipFlag); // Called by plr placing object back
void CreateItem(int, int, int); // Spawn a specific item at x, y
void CreateRndItem(int, int, BOOL, BOOL, BOOL); // Spawn any item around x,y (item level >= (currlevel*2))
void CreateRndUseful(int, int, int, BOOL); // Spawn either health, mana, or identify
void CreateTypeItem(int, int, BOOL, int, int, BOOL, BOOL); // Spawn a specific type of item
void CreateSpellBook(int x, int y, int ispell, BOOL sendmsg, BOOL delta); //Spawn a specific spell book
void CreateMagicArmor(int x, int y, int imisc, int icurs, BOOL sendmsg, BOOL delta); //Spawn specific magical armor
void CreateAmulet(int x, int y, int level, BOOL sendmsg, BOOL delta); //Spawn an amulet
void CreateMagicWeapon(int x, int y, int imisc, int icurs, BOOL sendmsg, BOOL delta); //Spawn specific magical weapon
void RecreateItem(int, int, WORD, int, int);
void RecreateEar(int, WORD, int, BOOL, int, int, int, int, int, int);
void SyncItemAnim(int);
void GetItemStr(int);
void CalcPlrItemVals(int,BOOL);
void CalcPlrScrolls(int);
void CalcPlrStaff(int);
void CalcPlrItemMin(int);
void CalcPlrInv(int,BOOL);
void CreatePlrItems(int);
void SpawnRock();
void CheckIdentify(int, int);
void DoRepair(int, int);
void DoRecharge(int, int);
void DoOil(int, int);
void PrintItemPower(char,const ItemStruct * x);
void PrintItemDetails(const ItemStruct * x);
void PrintItemDur(const ItemStruct * x);
void UseItem(int, int, int);
void SpawnSmith(int);
void SpawnPremium(int);
void SpawnWitch(int);
void SpawnBoy(int);
void SpawnHealer(int);
void SpawnStoreGold();
void SpawnQuestItem(int itemid, int x,int y, int randarea, int selflag);
void DrawUniqueInfo();
void GetItemAttrs(int i, int idata, int lvl);
int ItemNoFlippy();
void GetSuperItemLoc(int x, int y, int &xx, int &yy);
// PATCH1.JMM
BOOL CheckGetRecord( int nSeed, WORD wCI, int nIndex );
void AddGetRecord( int nSeed, WORD wCI, int nIndex );
void RemoveGetRecord( int nSeed, WORD wCI, int nIndex );
// ENDPATCH1.JMM
void SetPlrHandItem(ItemStruct *h, int idata);
void GetPlrHandSeed(ItemStruct *h);
typedef struct {
int x;
int y;
BOOL Initted;
ItemStruct item;
} CornerStoneType;
extern CornerStoneType CornerStone;
extern void CornerstoneRestore(int x, int y);
extern void CornerstoneSave();

752
src/ITEMS.HSV Normal file
View File

@ -0,0 +1,752 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Constants and Variables
**
** (C)1995 Condor, Inc. All rights reserved.
**-----------------------------------------------------------------------**
** $Header: /Diablo/ITEMS.H 3 2/06/97 6:08p Jessmac $
**-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------**
** Defines
**-----------------------------------------------------------------------*/
#define MAXITEMS 127
#define MAXUITEMS 128 // Max number of uniques
#define TEMPAVAIL 127
#define ITEM_RND -1
#define INFINITE_DUR 255
#define GOLD_VT1 1000 // Gold gfx transition from 1 to several
#define GOLD_VT2 2500 // Gold gfx transition from several to many
//#define GOLD_VMAX 5000 // Max gold in an inv slot
extern int GOLD_VMAX;
// Used for cursors
// 1x1
enum {
ITEM_BLUEBTL = 0,
ITEM_SCROLL , // 1
ITEM_SCROLL2 , // 2
ITEM_SCROLL3 , // 3
ITEM_1GOLD , // 4
ITEM_3GOLD , // 5
ITEM_5GOLD , // 6
ITEM_GOLDRING , // 7
ITEM_1JRING , // 8
ITEM_WOODRING , // 9
ITEM_BLUERING , // 10
ITEM_3JRING , // 11
ITEM_SLVRRING , // 12
ITEM_MJRING , // 13
ITEM_BRNRING , // 14
ITEM_SPECTRAL , // 15
ITEM_3COLORPOT , // 16
ITEM_GOLDENELIX , // 17
ITEM_EMPYBAND , // 18
ITEM_EAR1 , // 19
ITEM_EAR2 , // 20
ITEM_EAR3 , // 21
ITEM_SPHERE , // 22
ITEM_CUBE , // 23
ITEM_PYRIMID , // 24
ITEM_BLOODGEM , // 25
ITEM_JSPHERE , // 26
ITEM_JCUBE , // 27
ITEM_JPYRIMID , // 28
ITEM_VILE , // 29
ITEM_BLKBTL , // 30
ITEM_WHTEBTL , // 31
ITEM_REDBTL , // 32
ITEM_YELBTL , // 33
ITEM_ORGBTL , // 34
ITEM_BREDBTL , // 35
ITEM_BLKBTL2 , // 36
ITEM_GOLDBTL , // 37
ITEM_LTBLUEBTL , // 38
ITEM_BLUEBTL2 , // 39
ITEM_BRAIN , // 40
ITEM_CLAW , // 41
ITEM_FANG , // 42
ITEM_BREAD , // 43
ITEM_AMULET , // 44
ITEM_AMULET1 , // 45
ITEM_AMULET2 , // 46
ITEM_AMULET3 , // 47
ITEM_AMULET4 , // 48
ITEM_POUCH1 , // 49
// Add these back in when you can read them from the .cel file.
//ITEM_DOHICKY ,
//ITEM_THEODORE ,
//ITEM_PAPER1 ,
//ITEM_PAPER2 ,
//ITEM_PAPER3 ,
//ITEM_PAPER4 ,
// 1x2
ITEM_DAGGER1 , // 50
ITEM_DAGGER2 , // 51
ITEM_BIGBOTTLE , // 52
ITEM_DAGGER3 , // 53
ITEM_DAGGER4 , // 54
ITEM_DAGGER5 , // 55
// 1x3
ITEM_BLADE , // 56
ITEM_BASTSRD , // 57
ITEM_FALCHION , // 58
ITEM_MACE , // 59
ITEM_LONGSRD , // 60
ITEM_BROADSRD , // 61
ITEM_SCIMITAR , // 62
ITEM_MORNSTAR , // 63
ITEM_SHORTSRD , // 64
ITEM_CLAYMORE , // 65
ITEM_CLUB , // 66
ITEM_SABRE , // 67
ITEM_KNTSWORD , // 68
ITEM_CLUB1 , // 69
ITEM_CLUB2 , // 70
ITEM_CLUB3 , // 71
ITEM_SCIMITAR2 , // 72
ITEM_MAGSWORD , // 73
ITEM_SKULSWORD , // 74
// 2x2
ITEM_HELM , // 75
ITEM_ROCK , // 76
ITEM_CROWN , // 77
ITEM_SKCROWN , // 78
ITEM_MCROWN , // 79
ITEM_JESTER , // 80
ITEM_HARLEQ , // 81
ITEM_FHELM , // 82
ITEM_BUCKLER , // 83
ITEM_FHELM2 , // 84
ITEM_GRTHELM , // 85
ITEM_BOOK2 , // 86
ITEM_BOOK3 , // 87
ITEM_BOOK , // 88
ITEM_MUSHROOM , // 89
ITEM_SKLCAP , // 90
ITEM_LCAP , // 91
ITEM_FLESH , // 92
ITEM_SKLCAP2 , // 93
ITEM_CLOTHES , // 94
ITEM_CROWN2 , // 95
ITEM_MAP , // 96
ITEM_BOOK4 , // 97
ITEM_FHELM3 , // 98
ITEM_SAMHELM , // 99
///#define ITEM_MUSHROOM, // 100
// 2x3
ITEM_COMPSHLD , // 100
ITEM_BTLAXE , // 101
ITEM_LONGBOW , // 102
ITEM_PARMOR , // 103
ITEM_AXE , // 104
ITEM_WSHIELD , // 105
ITEM_CLEAVER , // 106
ITEM_STDARMOR , // 107
ITEM_COMPBOW , // 108
ITEM_SHRTSTAFF , // 109
ITEM_2HSWORD , // 110
ITEM_CHARMOR , // 111
ITEM_SMALLAXE , // 112
ITEM_HVYSHIELD , // 113
ITEM_SCLARMOR , // 114
ITEM_SMLSHLD , // 115
ITEM_SKULLSHLD , // 116
ITEM_WOLFSHLD , // 117
ITEM_SHORTBOW , // 118
ITEM_STLLONGBOW , // 119
ITEM_STLSHRTBOW , // 120
ITEM_SMLWARHAM , // 121
ITEM_MAUL , // 122
ITEM_IRONSTAFF , // 123
ITEM_STLSTAFF , // 124
ITEM_LONGSTAFF , // 125
ITEM_INNSIGN , // 126
ITEM_HLARMOR , // 127
ITEM_RAGS , // 128
ITEM_QARMOR , // 129
ITEM_BALLNCHN , // 130
ITEM_FLAIL , // 131
ITEM_TSHIELD , // 132
ITEM_HNTRBOW , // 133
ITEM_GRTSWORD , // 134
ITEM_LARMOR , // 135
ITEM_SPLTARMOR , // 136
ITEM_ROBE , // 137
ITEM_HVYROBE , // 138
ITEM_RINGARMOR , // 139
ITEM_ANVIL , // 140 //#define ITEM_OBOLISK 140
ITEM_BROADAXE , // 141
ITEM_LRGAXE , // 142
ITEM_WICKAXE , // 143
ITEM_HANDAXE , // 144
ITEM_GREATAXE , // 145
ITEM_IRONSHLD , // 146
ITEM_KITESHLD , // 147
ITEM_LRGSHLD , // 148
ITEM_CLOAK , // 149
ITEM_CAPE , // 150
ITEM_PARMOR2 , // 151
ITEM_PARMOR3 , // 152
ITEM_BPLATE , // 153
ITEM_RINGMAIL , // 154
ITEM_BISHOPSTF , // 155
ITEM_GEMGRTAXE , // 156
ITEM_ARKARMOR , // 157
ITEM_CROSBOW , // 158
ITEM_NAJARMOR , // 159
ITEM_GRIZZLY , // 160
ITEM_GRANDPA , // 161
ITEM_PROTECT , // 162
ITEM_REAVER , // 163
ITEM_WINDFOR , // 164
ITEM_SWARBOW , // 165
ITEM_COMPSTF , // 166
ITEM_SBATLBOW , // 167
ITEM_GOLD , // 168
// New 1x1
ITEM_MERLINRING , // 168
ITEM_MANARING , // 169
ITEM_AMULWARD , // 170
ITEM_NECMAGIC , // 171
ITEM_NECHEALTH , // 172
ITEM_KARIKSRING , // 173
ITEM_RINGGROUND , // 174
ITEM_AMULPROT , // 175
ITEM_MERCRING , // 176
ITEM_RINGTHUND , // 177
ITEM_NECTRUTH , // 178
ITEM_RINGGIANTS , // 179
ITEM_AMULGOLD , // 180
ITEM_RINGMYSTIC , // 181
ITEM_RINGCOPPER , // 182
ITEM_AMULACOLYT , // 183
ITEM_RINGMAGMA , // 184
ITEM_NECPURIFY , // 185
ITEM_RINGGLADTR , // 186
ITEM_RUNEBOMB , // 187
// new 1x3
ITEM_SWORDEDGE , // 188
ITEM_SWORDGLAM , // 189
ITEM_SWORDSERR , // 190
// new 2x3
ITEM_ARMRDARK , // 191
ITEM_ARMRBONECH , // 192
ITEM_HAMRTHUND , // 193
ITEM_SWRDCRYSTL , // 194
ITEM_STAFJESTER , // 195
ITEM_STAFMANA , // 196
ITEM_BOWVULCAN , // 197
ITEM_BOWSPEED , // 198
ITEM_AXEANCIENT , // 199
ITEM_CLUBCARNAG , // 200
ITEM_MACEDARK , // 201
ITEM_CLUBDECAY , // 202
ITEM_AXEDECAY , // 203
ITEM_SWRDDECAY , // 204
ITEM_MACEDECAY , // 205
ITEM_STAFDECAY , // 206
ITEM_BOWDECAY , // 207
ITEM_CLUBOUCH , // 208
ITEM_SWRDDEVAST , // 209
ITEM_AXEDEVAST , // 210
ITEM_MORNDEVAST , // 211
ITEM_MACEDEVAST , // 212
};
// Split later
// Used for plr gfx
#define IT_MISC 0
#define IT_SWORD 1
#define IT_AXE 2
#define IT_BOW 3
#define IT_MACE 4
#define IT_SHIELD 5
#define IT_ARMOR 6
#define IT_HELM 7
#define IT_MARMOR 8
#define IT_HARMOR 9
#define IT_STAFF 10
#define IT_GOLD 11
#define IT_RING 12
#define IT_AMULET 13
#define IT_FOOD 14
// Used for inv location
#define IL_HAND 1
#define IL_2HAND 2
#define IL_BODY 3
#define IL_HEAD 4
#define IL_RING 5
#define IL_NECK 6
#define IL_INV 7
#define IL_SPD 8
// Item classification for treasure types
#define IC_WEAP 1
#define IC_ARMOR 2
#define IC_ITEM 3
#define IC_GOLD 4
#define IC_SPECIAL 5
// Set item indexes for first non-random items
enum _item_indexes {
IDI_GOLD=0, // Item Data Table indexes
// Init items
IDI_WARRIOR,
IDI_WARRSHLD,
IDI_WARRCLUB,
IDI_ROGUE,
IDI_SORCEROR,
// Quest items
IDI_FIRSTQUEST,
IDI_CLEAVER=IDI_FIRSTQUEST,
IDI_SKCROWN, // Same as cleaver
IDI_INFRARING, // Same as cleaver
IDI_ROCK,
IDI_OPTAMULET,
IDI_TRING, // Same as cleaver
IDI_BANNER,
IDI_HARCREST, // Same as cleaver
IDI_STEELVEIL, // Same as cleaver
IDI_GLDNELIX, // Golden Elixor
IDI_ANVIL, // Anvil of Dawn
IDI_MUSHROOM, // Black Mushroom
IDI_BRAIN, // Brain
IDI_FUNGALTM, // Fungal Tome
IDI_SPECELIX, // Spectral Elixir
IDI_BLDSTONE, // Blood Stones
IDI_MAPOFDOOM,
IDI_LASTQUEST=IDI_MAPOFDOOM,
// Ears
IDI_EAR,
// Useful item
IDI_HEAL,
IDI_MANA,
IDI_IDENTIFY,
IDI_PORTAL,
// New items
IDI_ARMOFVAL, // Same as cleaver
IDI_FULLHEAL,
IDI_FULLMANA,
IDI_GRISWOLD,
IDI_LGTFORGE,
IDI_LAZSTAFF,
IDI_RESURRECT,
IDI_OILACC,
IDI_MONK,
IDI_BARD,
IDI_BARDDAGGER,
IDI_RUNEBOMB,
IDI_THEODORE,
IDI_AURIC
};
#define IAF_INFRAVISION 0x00000001
#define IAF_SKING 0x00000002
#define IAF_RNDARROW 0x00000004
#define IAF_FIREARROW 0x00000008
#define IAF_FIREHIT 0x00000010
#define IAF_LIGHTHIT 0x00000020
#define IAF_CONSTRICT 0x00000040
#define IAF_NOMANA 0x00000080
#define IAF_NOHEAL 0x00000100
#define IAF_RABID 0x00000200 // not in game
#define IAF_HALFTRAP 0x00000400 // not in game -called TRAPDAM
#define IAF_KNOCKBACK 0x00000800
#define IAF_MNOHEAL 0x00001000
#define IAF_BAT10 0x00002000
#define IAF_BAT20 0x00004000
#define IAF_ALLBAT (IAF_BAT10 | IAF_BAT20)
#define IAF_LEECH10 0x00008000
#define IAF_LEECH20 0x00010000
#define IAF_ALLLEECH (IAF_LEECH10 | IAF_LEECH20)
#define IAF_ATANIM1 0x00020000
#define IAF_ATANIM2 0x00040000
#define IAF_ATANIM3 0x00080000
#define IAF_ATANIM4 0x00100000
#define IAF_ALLATANIM (IAF_ATANIM1 | IAF_ATANIM2 | IAF_ATANIM3 | IAF_ATANIM4 )
#define IAF_HTANIM1 0x00200000
#define IAF_HTANIM2 0x00400000
#define IAF_HTANIM3 0x00800000
#define IAF_ALLHTANIM (IAF_HTANIM1 | IAF_HTANIM2 | IAF_HTANIM3)
#define IAF_BLANIM 0x01000000
#define IAF_LARROW 0x02000000
#define IAF_THORN 0x04000000
#define IAF_LMANA 0x08000000
#define IAF_TRAPDAM 0x10000000
#define IAF_OMEHAND 0x20000000
#define IAF_DAMDEMON 0x40000000
#define IAF_ZERORES 0x80000000
#define IAF2_DEVASTATION 0x00000001
#define IAF2_DECAY 0x00000002
#define IAF2_PERIL 0x00000004
#define IAF2_JESTER 0x00000008
#define IAF2_CLONE 0x00000010
#define IAF2_DEMONAC 0x00000020
#define IAF2_UNDEADAC 0x00000040
#define ISEL_NONE 0 // Items start out unselectable
#define ISEL_FLR 1 // Most items
#define ISEL_TOP 2 // Items on objects usually
#define ISEL_ALL 3 // Large (2 square) items
#define IMAGIC_NONE 0
#define IMAGIC_MAGIC 1
#define IMAGIC_UNIQUE 2
// Item re-creation information
// Creation bits are as follows:
// bit# desc
// 1-6 Level
// 7 Item Goodonly (T/F)
// 8,9 Unique percentage (0 = 0%, 1 = 15%, 2 = 1%)
// 8&9 Useful item only
// 10 Unique item
// 11 Spawned by Blacksmith
// 12 Spawned by Blacksmith premium
// 13 Spawned by Pegboy
// 14 Spawned by Witch
// 15 Spawned by Healer
#define ICI_USEFUL 0x0180
#define ICI_UPER1 0x0100
#define ICI_UPER15 0x0080
#define ICI_ONLYGOOD 0x0040
#define ICI_UNIQUE 0x0200
#define ICI_SMITH 0x0400
#define ICI_PREMIUM 0x0800
#define ICI_BOY 0x1000
#define ICI_WITCH 0x2000
#define ICI_HEALER 0x4000
#define ICI_PREGEN 0x8000
#define ICI_LVLMASK 0x003f
#define ICI_TOWNMASK 0x7c00
#define ICI_PREGENMASK 0x7fff
// Unique item index list
#define UID_CLEAVER 0 // Butcher's cleaver
#define UID_SKCROWN 1 // Skeleton King's crown
#define UID_INFRARING 2 // Infravision ring
#define UID_OPTAMULET 3 // Optic Amulet
#define UID_TRING 4 // Ring of truth
#define UID_HARCREST 5 // Harlequin Crest
#define UID_STEELVEIL 6 // Veil of Steel
#define UID_ARMOFVAL 7 // Armor of Valor
#define UID_GRISWOLD 8 // Griswold's Edge
#define UID_LGTFORGE 9 // LightForge
// item no random spawn, normal random spawn, or double chance random spawn
#define IRND_NO 0
#define IRND_NORMAL 1
#define IRND_DOUBLE 2
#define RESIST_MAX 75
/*-----------------------------------------------------------------------**
** Structures
**-----------------------------------------------------------------------*/
typedef struct {
char *PLName; // Name of power
int PLPower; // Power type
int PLParam1; // Misc param 1
int PLParam2; // Misc param 2
char PLMinLvl; // Min dungeon level of power appearing
long PLIType; // Item type (armor/shield/weapon/staff/bow/ring)
byte PLGOE; // Good/Evil/Either
BOOL PLDouble; // Double chance of spawning (more common magic)
BOOL PLOk; // Item good or bad
int PLMinVal; // Item min value modifier
int PLMaxVal; // Item max value modifier
int PLMultVal; // Item value multiplier
} PLStruct;
typedef struct {
char *UIName; // Unique item name
char UIItemId; // Item id for base stats
char UIMinLvl; // Min level can be found at
char UINumPL; // Number of power list items
int UIValue; // Items value
char UIPower1; // Power 1 and 2 params
int UIParam1;
int UIParam2;
char UIPower2; // Power 2 and 2 params
int UIParam3;
int UIParam4;
char UIPower3; // Power 3 and 2 params
int UIParam5;
int UIParam6;
char UIPower4; // Power 4 and 2 params
int UIParam7;
int UIParam8;
char UIPower5; // Power 5 and 2 params
int UIParam9;
int UIParam10;
char UIPower6; // Power 6 and 2 params
int UIParam11;
int UIParam12;
} UItemStruct;
typedef struct {
BOOL iRnd; // Random item or special
char iClass; // Item classification
char iLoc; // Item Body Location
int iCurs; // Item cursor gfx
char itype; // Item type
char iItemId; // Item id#
char *iName; // name
char *iSName; // short name
char iMinMLvl; // Min monster level to drop it
int iDurability; // Durability of the item
int iMinDam; // Min damage
int iMaxDam; // Max damage
int iMinAC; // Min Armor Class
int iMaxAC; // Max Armor Class
char iMinStr; // Min Strength stat to use item
char iMinMag; // Min Magic stat to use item
char iMinDex; // Min Dexterity stat to use item
long iFlags; // Item ability flags
int iMiscId; // Misc item uses id
long iSpell; // item spell
BOOL iUsable; // Usable item?
int iValue; // item min value
int iMaxValue; // item max value
} ItemDataStruct;
// PATCH1.JMM
typedef struct {
int nSeed;
WORD wCI;
int nIndex;
DWORD dwTimestamp;
} ItemGetRecordStruct;
// ENDPATCH1.JMM
typedef struct {
int _iSeed; // item seed to generate itself
WORD _iCreateInfo; // item re-creation info
int _itype; // item type
int _ix; // item map x
int _iy; // item map y
BOOL _iAnimFlag; // Does this item animate?
BYTE *_iAnimData; // Data pointer to anim tables
int _iAnimLen; // number of anim frames
int _iAnimFrame; // current anim frame
long _iAnimWidth; // Width of anim
long _iAnimWidth2; // (Width - 64) >> 1 of anim
// PATCH1.JMM
// FLAG IS NO LONGER USED
//BOOL _iDelFlag; // Delete this item
BOOL _iInvalid;
// ENDPATCH1.JMM
char _iSelFlag; // Select top, floor, or all
BOOL _iPostDraw; // Draw after objects or before?
BOOL _iIdentified; // Has item been identified?
char _iMagical; // (No/Reg/Unique) Does the item have magical attributes?
char _iName[64]; // item name
char _iIName[64]; // identified name
char _iLoc; // item body location
char _iClass; // item classification
int _iCurs; // item cursor type
int _ivalue; // item value
int _iIvalue; // item identified value
int _iMinDam; // item min damage
int _iMaxDam; // item max damage
int _iAC; // item armor class
long _iFlags; // item ability flags
int _iMiscId; // Misc item uses id
int _iSpell; // item spell
int _iCharges; // random number of charges
int _iMaxCharges; // Max Charges of a staff
int _iDurability; // How much strength until it breaks
int _iMaxDur; // Max Durability
int _iPLDam; // Power List damage multiplier
int _iPLToHit; // Power List to hit increase
int _iPLAC; // Power List AC increase
int _iPLStr; // Power List Strength increase
int _iPLMag; // Power List Magic increase
int _iPLDex; // Power List Dexterity increase
int _iPLVit; // Power List Vitality increase
int _iPLFR; // Power List Fire resistance
int _iPLLR; // Power List Lightning resistance
int _iPLMR; // Power List Misc Magic resistance
long _iPLMana; // Power List Mana
long _iPLHP; // Power List Hit Points
int _iPLDamMod; // Power List damage modifier (num, not %)
int _iPLGetHit; // Power List Get hit modifier (+/-)
int _iPLLight; // Power List light radius
char _iSplLvlAdd; // What to add to each spell level
char _iRequest; // If item has be requested to be picked up (drb 12/9)
int _iUid; // If unique item, index into unique table (drb 12/8)
int _iFMinDam; // Fire hit min damage
int _iFMaxDam; // Fire hit max damage
int _iLMinDam; // Lightning hit min damage
int _iLMaxDam; // Lightning hit max damage
int _iPLEnAc; // Enemy armor class reduced by this amount
char _iPrePower; // Power List index for prefix
char _iSufPower; // Power List index for suffix
int _iVAdd1; // value add #1
int _iVMult1; // value multiplier #1
int _iVAdd2; // value add #2
int _iVMult2; // value multiplier #2
char _iMinStr; // Min Strength stat to use item
byte _iMinMag; // Min Magic stat to use item
char _iMinDex; // Min Dexterity stat to use item
BOOL _iStatFlag; // Draw with red filter or not
int IDidx; // AllItemsData index
char _oldlight; // Old prelight val
long _iFlags2; // item ability flags
} ItemStruct;
#define SAVE_ITEM_SIZE sizeof(ItemStruct)
/*-----------------------------------------------------------------------**
** Externs
**-----------------------------------------------------------------------*/
extern ItemStruct item[MAXITEMS+1];
extern long numitems;
extern int itemactive[MAXITEMS];
extern int itemavail[MAXITEMS];
// PATCH1.JMM
extern ItemGetRecordStruct itemgets[MAXITEMS];
extern int gnNumGetRecords;
// ENDPATCH1.JMM
extern BOOL UniqueItemFlag[MAXUITEMS];
extern BOOL uitemflag;
extern int ItemInvSnds[];
extern BYTE ItemCAnimTbl[];
#if CHEATS
extern BOOL davecheat;
extern int tstQMsgSpd;
extern int tstQMsgIndex;
extern BOOL tstQMsgFlag;
extern BOOL tstQMsgIndexFlag;
#endif
/*-----------------------------------------------------------------------**
** Prototypes
**-----------------------------------------------------------------------*/
void InitItems();
void ProcessItems();
void InitItemGFX();
void FreeItemGFX();
void DaveGold();
void DaveNewPremium();
void DaveCleanUp();
void DaveSpells();
void DaveSpells2();
void DaveQuestText();
BOOL ItemSpaceOk(int, int);
void SpawnItem(int, int, int, BOOL); // Called by monsters
void SpawnUnique(int, int, int); // Called by monsters
void RespawnItem(int ii, BOOL FlipFlag); // Called by plr placing object back
void CreateItem(int, int, int); // Spawn a specific item at x, y
void CreateRndItem(int, int, BOOL, BOOL, BOOL); // Spawn any item around x,y (item level >= (currlevel*2))
void CreateRndUseful(int, int, int, BOOL); // Spawn either health, mana, or identify
void CreateTypeItem(int, int, BOOL, int, int, BOOL, BOOL); // Spawn a specific type of item
void CreateSpellBook(int x, int y, int ispell, BOOL sendmsg, BOOL delta); //Spawn a specific spell book
void CreateMagicArmor(int x, int y, int imisc, int icurs, BOOL sendmsg, BOOL delta); //Spawn specific magical armor
void CreateAmulet(int x, int y, int level, BOOL sendmsg, BOOL delta); //Spawn an amulet
void CreateMagicWeapon(int x, int y, int imisc, int icurs, BOOL sendmsg, BOOL delta); //Spawn specific magical weapon
void RecreateItem(int, int, WORD, int, int);
void RecreateEar(int, WORD, int, BOOL, int, int, int, int, int, int);
void SyncItemAnim(int);
void GetItemStr(int);
void CalcPlrItemVals(int,BOOL);
void CalcPlrScrolls(int);
void CalcPlrStaff(int);
void CalcPlrItemMin(int);
void CalcPlrInv(int,BOOL);
void CreatePlrItems(int);
void SpawnRock();
void CheckIdentify(int, int);
void DoRepair(int, int);
void DoRecharge(int, int);
void DoOil(int, int);
void PrintItemPower(char,const ItemStruct * x);
void PrintItemDetails(const ItemStruct * x);
void PrintItemDur(const ItemStruct * x);
void UseItem(int, int, int);
void SpawnSmith(int);
void SpawnPremium(int);
void SpawnWitch(int);
void SpawnBoy(int);
void SpawnHealer(int);
void SpawnStoreGold();
void SpawnQuestItem(int itemid, int x,int y, int randarea, int selflag);
void DrawUniqueInfo();
void GetItemAttrs(int i, int idata, int lvl);
int ItemNoFlippy();
void GetSuperItemLoc(int x, int y, int &xx, int &yy);
// PATCH1.JMM
BOOL CheckGetRecord( int nSeed, WORD wCI, int nIndex );
void AddGetRecord( int nSeed, WORD wCI, int nIndex );
void RemoveGetRecord( int nSeed, WORD wCI, int nIndex );
// ENDPATCH1.JMM
void SetPlrHandItem(ItemStruct *h, int idata);
void GetPlrHandSeed(ItemStruct *h);
typedef struct {
int x;
int y;
BOOL Initted;
ItemStruct item;
} CornerStoneType;
extern CornerStoneType CornerStone;
extern void CornerstoneRestore(int x, int y);
extern void CornerstoneSave();

1178
src/LIGHTING.CPP Normal file

File diff suppressed because it is too large Load Diff

132
src/LIGHTING.H Normal file
View File

@ -0,0 +1,132 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Constants and Variables
**
** (C)1995 Condor, Inc. All rights reserved.
**-----------------------------------------------------------------------**
** $Header: /Diablo/LIGHTING.H 1 1/22/97 2:06p Dgartner $
**-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------**
** Defines
**-----------------------------------------------------------------------*/
#define LIGHTSIZE 27*256
#define MAXLIGHTS 32
#define MAXVISION 32
#define MAXTRANS 32
#define PLRLRAD 10 // Player light radius
#define PLRVRAD 10 // Player vision radius
#define HALF_T 1
#define HALF_B 2
#define HALF_R 3
#define HALF_L 4
#define QTR_UR 5
#define QTR_LR 6
#define QTR_UL 7
#define QTR_LL 8
#define VERT_T 9
#define VERT_B 10
#define VERT_LINE 11
#define HORT_L 12
#define HORT_R 13
#define HORT_LINE 14
#define SELF 15
#define WHOLE 16
#define NEG_WHOLE 17
#define LIGHT_NORM 0 // Normal lighting
#define LIGHT_INFRA 1 // Infravision
#define LIGHT_STONE 2 // Stone curse
#define LIGHT_GREY 3 // Pause & death
#define LIGHT_U 4 // Unique monster transform 3-11
#define LFLAG_MINE 1 // whether or not my player is the source
// (used in ProcessVision)
/*-----------------------------------------------------------------------**
** Structures
**-----------------------------------------------------------------------*/
typedef struct {
int _lx;
int _ly;
int _lradius;
int _lid;
BOOL _ldel;
BOOL _lunflag;
BOOL _lneg;
int _lunx;
int _luny;
int _lunr;
int _xoff;
int _yoff;
BOOL _lflags;
} LightListStruct;
/*-----------------------------------------------------------------------**
** Externs
**-----------------------------------------------------------------------*/
extern int lightflag;
extern BYTE vCrawlTable[23][30];
extern BYTE RadiusAdj[23];
//extern int CrawlTable[2061];
extern char CrawlTable[2749];
extern char * pCrawlEntry[19];
extern LightListStruct LightList[MAXLIGHTS];
extern BYTE lightactive[MAXLIGHTS];
extern int numlights;
extern BOOL dolighting;
extern "C" {
extern char lightmax;
extern BYTE *pLightTbl;
}
extern LightListStruct VisionList[MAXVISION];
extern int numvision;
extern BOOL dovision;
extern int visionid;
/*-----------------------------------------------------------------------**
** Prototypes
**-----------------------------------------------------------------------*/
void DoLighting (int, int, int, int);
void DoUnLight (int, int, int);
void InitLighting();
void InitLightMax();
int AddLight(int, int, int);
void AddUnLight(int);
void ChangeLightRadius(int, int);
void ChangeLightXY(int, int, int);
void ChangeLight(int, int, int, int);
void ChangeLightOff(int id, int x, int y);
void ProcessLightList();
void SavePreLighting();
void DoVision (int, int, int, BOOL, BOOL);
void DoUnVision (int, int, int);
void InitVision();
int AddVision(int, int, int, BOOL);
void AddUnVision(int);
void ChangeVisionRadius(int, int);
void ChangeVisionXY(int, int, int);
void ChangeVision(int, int, int, int);
void ProcessVisionList();
void ResetLight();
void ToggleLight();
void InitLightTable();
void MakeLightTable();
void FreeLightTable();
void BloodCycle();

768
src/LOADSAVE.CPP Normal file
View File

@ -0,0 +1,768 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Game Menu file
**
** (C)1995 Condor, Inc. All rights reserved.
**
**-----------------------------------------------------------------------**
** $Header: /Diablo/LOADSAVE.CPP 2 1/23/97 12:21p Jmorin $
**-----------------------------------------------------------------------**
**
** File Routines
**-----------------------------------------------------------------------*/
#include "diablo.h"
#pragma hdrstop
#include <stddef.h>
#include "sound.h"
#include "engine.h"
#include "gendung.h"
#include "palette.h"
#include "items.h"
#include "player.h"
#include "monster.h"
#include "dead.h"
#include "objects.h"
#include "spells.h"
#include "missiles.h"
#include "quests.h"
#include "trigs.h"
#include "lighting.h"
#include "control.h"
#include "inv.h"
#include "interfac.h"
#include "town.h"
#include "stores.h"
#include "cursor.h"
#include "automap.h"
#include "multi.h"
#include "doom.h"
#include "portal.h"
/*-----------------------------------------------------------------------*
** extern
**-----------------------------------------------------------------------*/
DWORD CalcEncodeDstBytes(DWORD dwSrcBytes);
void CreateSaveLevelName(char szName[MAX_PATH]);
void CreateLoadLevelName(char szName[MAX_PATH]);
void CreateSaveGameName(char szName[MAX_PATH]);
void WriteSaveFile(const char * pszName,BYTE * pbData,DWORD dwLen,DWORD dwEncodeLen);
BYTE * ReadSaveFile(const char * pszName,DWORD * pdwLen);
void SyncPlrAnim(int);
void DestroyTempSaves();
void MoveTempSavesToPermanent();
void RedoPlayerVision();
/*-----------------------------------------------------------------------*
** private
**-----------------------------------------------------------------------*/
// Save only these bits in the dFlags
#define BFLAG_SAVEMASK (BFLAG_AUTOMAP | BFLAG_VISIBLE | BFLAG_PLRLR | BFLAG_MONSTLR | BFLAG_SETPC)
// save file buffer size
#define FILEBUFF 362147
// pointer into save file buffer
static BYTE *tbuff;
#define SHAREWARE_ID 'SHAR'
#define BETA_ID 'BETA'
#define RETAIL_ID 'RETL'
#define HELLFIRE_ID 'HELF'
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
static char BLoad() {
return *tbuff++;
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
static int ILoad() {
int rv;
// drb old because we used to think ints were 16 bit
/* if ((*tbuff & 0x80) != 0) rv = -1 & 0xffff0000;
else rv = 0;
rv |= *tbuff++ << 8;
rv |= *tbuff++;*/
rv = *tbuff++ << 24;
rv |= *tbuff++ << 16;
rv |= *tbuff++ << 8;
rv |= *tbuff++;
return(rv);
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
static long LLoad() {
long rv;
rv = *tbuff++ << 24;
rv |= *tbuff++ << 16;
rv |= *tbuff++ << 8;
rv |= *tbuff++;
return(rv);
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
static BOOL OLoad() {
if (*tbuff++ == 1) return(TRUE);
else return(FALSE);
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
static void LoadPlr(int i) {
memcpy(&plr[i], tbuff, SAVE_PLAYER_SIZE);
tbuff += SAVE_PLAYER_SIZE;
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
static void LoadMonst(int i) {
memcpy(&monster[i], tbuff, SAVE_MONSTER_SIZE);
tbuff += SAVE_MONSTER_SIZE;
SyncMonsterAnim(i);
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
static void LoadMissile(int i) {
memcpy(&missile[i], tbuff, SAVE_MISSILE_SIZE);
tbuff += SAVE_MISSILE_SIZE;
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
static void LoadSpell(int i) {
tbuff += 0;
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
static void LoadObject(int i) {
memcpy(&object[i], tbuff, SAVE_OBJECT_SIZE);
tbuff += SAVE_OBJECT_SIZE;
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
static void LoadItem(int i) {
memcpy(&item[i], tbuff, SAVE_ITEM_SIZE);
tbuff += SAVE_ITEM_SIZE;
SyncItemAnim(i);
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
static void LoadPremium(int i) {
memcpy(&premiumitem[i], tbuff, SAVE_ITEM_SIZE);
tbuff += SAVE_ITEM_SIZE;
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
static void LoadQuest(int i) {
memcpy(&quests[i], tbuff, SAVE_QUEST_SIZE);
tbuff += SAVE_QUEST_SIZE;
// where to go back to
ReturnLvlX = ILoad();
ReturnLvlY = ILoad();
ReturnLvl = ILoad();
ReturnLvlT = ILoad();
// Map of doom
doomtime = ILoad();
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
static void LoadLight(int i) {
memcpy(&LightList[i], tbuff, sizeof(LightListStruct));
tbuff += sizeof(LightListStruct);
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
static void LoadVision(int i) {
memcpy(&VisionList[i], tbuff, sizeof(LightListStruct));
tbuff += sizeof(LightListStruct);
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
static void LoadPortal(int i) {
memcpy(&portal[i], tbuff, sizeof(PortalStruct));
tbuff += sizeof(PortalStruct);
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
void GM_LoadGame(BOOL firstflag) {
#if !IS_VERSION(BETA)
int i,j;
int hvx, hvy;
int hnummonsters, hnumitems, hnummissiles, hnumobjects;
app_assert(gbMaxPlayers == 1);
FreeGameMem();
// since we are loading an existing game, any temporary
// save files which were created can be removed
DestroyTempSaves();
DWORD dwLen;
char szName[MAX_PATH];
CreateSaveGameName(szName);
BYTE *LoadBuff = ReadSaveFile(szName,&dwLen);
tbuff = LoadBuff;
DWORD dwVersion = LLoad();
#if IS_VERSION(SHAREWARE)
if (dwVersion != SHAREWARE_ID) app_fatal("Invalid save file");
#elif IS_VERSION(BETA)
if (dwVersion != BETA_ID) app_fatal("Invalid save file");
#elif IS_VERSION(RETAIL)
//if (dwVersion != RETAIL_ID) app_fatal("Invalid save file");
if (dwVersion != HELLFIRE_ID) app_fatal("Invalid save file");
#else
#error No version defined
#endif
setlevel = OLoad();
setlvlnum = ILoad();
currlevel = ILoad();
leveltype = ILoad();
hvx = ILoad();
hvy = ILoad();
invflag = OLoad();
chrflag = OLoad();
hnummonsters = ILoad();
hnumitems = ILoad();
hnummissiles = ILoad();
hnumobjects = ILoad();
for (i = 0; i < NUMLEVELS; i++) {
glSeedTbl[i] = LLoad();
gnLevelTypeTbl[i] = ILoad();
}
// Load player info
LoadPlr(myplr);
gnDifficulty = plr[myplr]._gnDifficulty;
if (gnDifficulty < D_NORMAL || gnDifficulty > D_HELL)
gnDifficulty = D_NORMAL;
// Load quest info
for (i = 0; i < MAXQUESTS; i++) LoadQuest(i);
// Load town portal info
for (i = 0; i < MAXPORTAL; i++) LoadPortal(i);
LoadGameLevel(firstflag, LVL_NODIR);
SyncInitPlr(myplr);
SyncPlrAnim(myplr);
ViewX = hvx;
ViewY = hvy;
nummonsters = hnummonsters;
numitems = hnumitems;
nummissiles = hnummissiles;
numobjects = hnumobjects;
for (i = 0; i < MONSTERTYPES; i++) monstkills[i] = LLoad();
if (leveltype != 0) {
// Load monster block
for (i = 0; i < MAXMONSTERS; i++) monstactive[i] = ILoad();
for (i = 0; i < nummonsters; i++) LoadMonst(monstactive[i]);
// Load missile block
for (i = 0; i < MAXMISSILES; i++) missileactive[i] = BLoad();
for (i = 0; i < MAXMISSILES; i++) missileavail[i] = BLoad();
for (i = 0; i < nummissiles; i++) LoadMissile(missileactive[i]);
// Load object block
for (i = 0; i < MAXOBJECTS; i++) objectactive[i] = BLoad();
for (i = 0; i < MAXOBJECTS; i++) objectavail[i] = BLoad();
for (i = 0; i < numobjects; i++) LoadObject(objectactive[i]);
for (i = 0; i < numobjects; i++) SyncObjectAnim(objectactive[i]);
// Load light and vision
numlights = ILoad();
for (i = 0; i < MAXLIGHTS; i++) lightactive[i] = BLoad();
for (i = 0; i < numlights; i++) LoadLight(lightactive[i]);
visionid = ILoad();
numvision = ILoad();
for (i = 0; i < numvision; i++) LoadVision(i);
}
// Load item block
for (i = 0; i < MAXITEMS; i++) itemactive[i] = BLoad();
for (i = 0; i < MAXITEMS; i++) itemavail[i] = BLoad();
for (i = 0; i < numitems; i++) LoadItem(itemactive[i]);
for (i = 0; i < MAXUITEMS; i++) UniqueItemFlag[i] = OLoad();
// Load map info
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) dLight[i][j] = BLoad();
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) dFlags[i][j] = BLoad();
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) dPlayer[i][j] = BLoad();
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) dItem[i][j] = BLoad();
if (leveltype != 0) {
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) dMonster[i][j] = ILoad();
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) dDead[i][j] = BLoad();
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) dObject[i][j] = BLoad();
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) dLight[i][j] = BLoad();
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) dSaveLight[i][j] = BLoad();
for (j = 0; j < AUTOMAPY; j++)
for (i = 0; i < AUTOMAPX; i++) automapview[i][j] = OLoad();
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) dMissile[i][j] = BLoad();
}
numpremium = ILoad();
premiumlevel = ILoad();
for (i = 0; i < MAXPREMIUM; i++) LoadPremium(i);
automapflag = OLoad();
automapscale = ILoad();
DiabloFreePtr(LoadBuff);
// Misc sync routines
SyncAutomap();
ResyncQuests();
if (leveltype)
ProcessLightList();
RedoPlayerVision();
ProcessVisionList();
SyncMissAnim();
ResetPal();
SetCursor(GLOVE_CURS);
gbProcessPlayers = TRUE;
#endif
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
static void BSave(char v) {
*tbuff++ = v;
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
static void ISave(int v) {
// Changed because we used to thing ints were 16 bit, but they are 32
/* *tbuff++ = (char) (v >> 8);
*tbuff++ = (char) v;*/
*tbuff++ = (char) (v >> 24);
*tbuff++ = (char) (v >> 16);
*tbuff++ = (char) (v >> 8);
*tbuff++ = (char) (v >> 0);
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
static void LSave(long v) {
*tbuff++ = (char) (v >> 24);
*tbuff++ = (char) (v >> 16);
*tbuff++ = (char) (v >> 8);
*tbuff++ = (char) (v >> 0);
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
static void OSave(BOOL v) {
if (v) *tbuff++ = 1;
else *tbuff++ = 0;
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
static void SavePlr(int i) {
memcpy(tbuff, &plr[i], SAVE_PLAYER_SIZE);
tbuff += SAVE_PLAYER_SIZE;
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
static void SaveMonst(int i) {
memcpy(tbuff, &monster[i], SAVE_MONSTER_SIZE);
tbuff += SAVE_MONSTER_SIZE;
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
static void SaveMissile(int i) {
memcpy(tbuff, &missile[i], SAVE_MISSILE_SIZE);
tbuff += SAVE_MISSILE_SIZE;
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
static void SaveSpell(int i) {
tbuff += 0;
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
static void SaveObject(int i) {
memcpy(tbuff, &object[i], SAVE_OBJECT_SIZE);
tbuff += SAVE_OBJECT_SIZE;
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
static void SaveItem(int i) {
memcpy(tbuff, &item[i], SAVE_ITEM_SIZE);
tbuff += SAVE_ITEM_SIZE;
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
static void SavePremium(int i) {
memcpy(tbuff, &premiumitem[i], SAVE_ITEM_SIZE);
tbuff += SAVE_ITEM_SIZE;
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
static void SaveQuest(int i) {
memcpy(tbuff, &quests[i], SAVE_QUEST_SIZE);
tbuff += SAVE_QUEST_SIZE;
ISave(ReturnLvlX);
ISave(ReturnLvlY);
ISave(ReturnLvl);
ISave(ReturnLvlT);
ISave(doomtime);
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
static void SaveLight(int i) {
memcpy(tbuff, &LightList[i], sizeof(LightListStruct));
tbuff += sizeof(LightListStruct);
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
static void SaveVision(int i) {
memcpy(tbuff, &VisionList[i], sizeof(LightListStruct));
tbuff += sizeof(LightListStruct);
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
static void SavePortal(int i) {
memcpy(tbuff, &portal[i], sizeof(PortalStruct));
tbuff += sizeof(PortalStruct);
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
void GM_SaveGame() {
#if !IS_VERSION(BETA)
BYTE *SaveBuff;
int i,j;
// allocate a ptr large enough for save file + encode data
app_assert(gbMaxPlayers == 1);
SaveBuff = DiabloAllocPtrSig(CalcEncodeDstBytes(FILEBUFF),'SAVt');
tbuff = SaveBuff;
#if IS_VERSION(SHAREWARE)
LSave(SHAREWARE_ID);
#elif IS_VERSION(BETA)
LSave(BETA_ID);
#elif IS_VERSION(RETAIL)
//LSave(RETAIL_ID);
LSave(HELLFIRE_ID);
#else
#error No version defined
#endif
OSave(setlevel);
ISave(setlvlnum);
ISave(currlevel);
ISave(leveltype);
ISave(ViewX);
ISave(ViewY);
OSave(invflag);
OSave(chrflag);
ISave(nummonsters);
ISave(numitems);
ISave(nummissiles);
ISave(numobjects);
for (i = 0; i < NUMLEVELS; i++) {
LSave(glSeedTbl[i]);
ISave(gnLevelTypeTbl[i]);
}
// Save player info
plr[myplr]._gnDifficulty = gnDifficulty;
SavePlr(myplr);
// Save quest info
for (i = 0; i < MAXQUESTS; i++) SaveQuest(i);
// Save town portal info
for (i = 0; i < MAXPORTAL; i++) SavePortal(i);
for (i = 0; i < MONSTERTYPES; i++) LSave(monstkills[i]);
if (leveltype != 0) {
// Save monster block
for (i = 0; i < MAXMONSTERS; i++) ISave(monstactive[i]);
for (i = 0; i < nummonsters; i++) SaveMonst(monstactive[i]);
// Save missile block
for (i = 0; i < MAXMISSILES; i++) BSave(missileactive[i]);
for (i = 0; i < MAXMISSILES; i++) BSave(missileavail[i]);
for (i = 0; i < nummissiles; i++) SaveMissile(missileactive[i]);
// Save object block
for (i = 0; i < MAXOBJECTS; i++) BSave(objectactive[i]);
for (i = 0; i < MAXOBJECTS; i++) BSave(objectavail[i]);
for (i = 0; i < numobjects; i++) SaveObject(objectactive[i]);
// Save light and vision
ISave(numlights);
for (i = 0; i < MAXLIGHTS; i++) BSave(lightactive[i]);
for (i = 0; i < numlights; i++) SaveLight(lightactive[i]);
ISave(visionid);
ISave(numvision);
for (i = 0; i < numvision; i++) SaveVision(i);
}
// Save item block
for (i = 0; i < MAXITEMS; i++) BSave(itemactive[i]);
for (i = 0; i < MAXITEMS; i++) BSave(itemavail[i]);
for (i = 0; i < numitems; i++) SaveItem(itemactive[i]);
for (i = 0; i < MAXUITEMS; i++) OSave(UniqueItemFlag[i]);
// Save map info
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) BSave(dLight[i][j]);
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) BSave(dFlags[i][j] & BFLAG_SAVEMASK);
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) BSave(dPlayer[i][j]);
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) BSave(dItem[i][j]);
if (leveltype != 0) {
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) ISave(dMonster[i][j]);
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) BSave(dDead[i][j]);
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) BSave(dObject[i][j]);
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) BSave(dLight[i][j]);
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) BSave(dSaveLight[i][j]);
for (j = 0; j < AUTOMAPY; j++)
for (i = 0; i < AUTOMAPX; i++) OSave(automapview[i][j]);
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) BSave(dMissile[i][j]);
}
ISave(numpremium);
ISave(premiumlevel);
for (i = 0; i < MAXPREMIUM; i++) SavePremium(i);
OSave(automapflag);
ISave(automapscale);
char szName[MAX_PATH];
CreateSaveGameName(szName);
// when we allocated SaveBuff, we made sure to include enough
// bytes for the encryption information
WriteSaveFile(
szName,
SaveBuff,
tbuff - SaveBuff,
CalcEncodeDstBytes(tbuff - SaveBuff)
);
DiabloFreePtr(SaveBuff);
gbValidSaveFile = TRUE;
// take all the temporary save files which have accumulated
// during the course of gameplay and make them part of the
// permanent save game
MoveTempSavesToPermanent();
void UpdatePlayerFile();
UpdatePlayerFile();
#endif
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
void SaveLevel()
{
#if !IS_VERSION(BETA)
BYTE *SaveBuff;
int i,j;
// make sure this code doesn't get called in multiplayer
// or everyone will have different results...
app_assert(gbMaxPlayers == 1);
if (currlevel == 0) glSeedTbl[0] = GetRndSeed();
// allocate a ptr large enough for save file + encode data
SaveBuff = DiabloAllocPtrSig(CalcEncodeDstBytes(FILEBUFF),'SAVt');
tbuff = SaveBuff;
// Moved here to sync dead unique monsters drb 12/15
if (leveltype != 0) {
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) BSave(dDead[i][j]);
}
ISave(nummonsters);
ISave(numitems);
ISave(numobjects);
if (leveltype != 0) {
// Save monster block
for (i = 0; i < MAXMONSTERS; i++) ISave(monstactive[i]);
for (i = 0; i < nummonsters; i++) SaveMonst(monstactive[i]);
// Save object block
for (i = 0; i < MAXOBJECTS; i++) BSave(objectactive[i]);
for (i = 0; i < MAXOBJECTS; i++) BSave(objectavail[i]);
for (i = 0; i < numobjects; i++) SaveObject(objectactive[i]);
}
// Save item block
for (i = 0; i < MAXITEMS; i++) BSave(itemactive[i]);
for (i = 0; i < MAXITEMS; i++) BSave(itemavail[i]);
for (i = 0; i < numitems; i++) SaveItem(itemactive[i]);
// Save map info
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++)
BSave(dFlags[i][j] & BFLAG_SAVEMASK);
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) BSave(dItem[i][j]);
if (leveltype != 0) {
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) ISave(dMonster[i][j]);
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) BSave(dObject[i][j]);
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) BSave(dLight[i][j]);
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) BSave(dSaveLight[i][j]);
for (j = 0; j < AUTOMAPY; j++)
for (i = 0; i < AUTOMAPX; i++) OSave(automapview[i][j]);
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) BSave(dMissile[i][j]);
}
app_assert(FILEBUFF >= tbuff - SaveBuff);
char szName[MAX_PATH];
CreateSaveLevelName(szName);
// when we allocated SaveBuff, we made sure to include enough
// bytes for the encryption information
WriteSaveFile(
szName,
SaveBuff,
tbuff - SaveBuff,
CalcEncodeDstBytes(tbuff - SaveBuff)
);
DiabloFreePtr(SaveBuff);
if (!setlevel) plr[myplr]._pLvlVisited[currlevel] = TRUE;
else plr[myplr]._pSLvlVisited[setlvlnum] = TRUE;
#endif
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
void LoadLevel() {
#if !IS_VERSION(BETA)
int i,j;
DWORD LoadSize;
char szName[MAX_PATH];
CreateLoadLevelName(szName);
BYTE * LoadBuff = ReadSaveFile(szName,&LoadSize);
tbuff = LoadBuff;
if (leveltype != 0) {
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) dDead[i][j] = BLoad();
SyncUniqDead();
}
nummonsters = ILoad();
numitems = ILoad();
numobjects = ILoad();
if (leveltype != 0) {
// Load monster block
for (i = 0; i < MAXMONSTERS; i++) monstactive[i] = ILoad();
for (i = 0; i < nummonsters; i++) LoadMonst(monstactive[i]);
// Load object block
for (i = 0; i < MAXOBJECTS; i++) objectactive[i] = BLoad();
for (i = 0; i < MAXOBJECTS; i++) objectavail[i] = BLoad();
for (i = 0; i < numobjects; i++) LoadObject(objectactive[i]);
for (i = 0; i < numobjects; i++) SyncObjectAnim(objectactive[i]);
}
// Load item block
for (i = 0; i < MAXITEMS; i++) itemactive[i] = BLoad();
for (i = 0; i < MAXITEMS; i++) itemavail[i] = BLoad();
for (i = 0; i < numitems; i++) LoadItem(itemactive[i]);
// Load map info
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) dFlags[i][j] = BLoad();
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) dItem[i][j] = BLoad();
if (leveltype != 0) {
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) dMonster[i][j] = ILoad();
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) dObject[i][j] = BLoad();
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) dLight[i][j] = BLoad();
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) dSaveLight[i][j] = BLoad();
for (j = 0; j < AUTOMAPY; j++)
for (i = 0; i < AUTOMAPX; i++) automapview[i][j] = OLoad();
for (j = 0; j < MAXDUNY; j++)
for (i = 0; i < MAXDUNX; i++) dMissile[i][j] = 0;
}
// Misc sync routines
SyncAutomap();
ResyncQuests();
SyncPortals();
// player lighting needs to be reset because players enter level at different
// location than where they leave
dolighting = TRUE;
for (i = 0; i < MAX_PLRS; i++) {
if (plr[i].plractive && currlevel == plr[i].plrlevel)
LightList[plr[i]._plid]._lunflag = TRUE;
}
DiabloFreePtr(LoadBuff);
#endif
}

203
src/MAINMENU.CPP Normal file
View File

@ -0,0 +1,203 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Main Menu
**
** (C)1996 Condor, Inc. All rights reserved.
**
**-----------------------------------------------------------------------**
** $Header: /Diablo/MAINMENU.CPP 2 1/23/97 12:21p Jmorin $
**-----------------------------------------------------------------------*/
#include "diablo.h"
#pragma hdrstop
#include "storm.h"
#include "diabloui.h"
#include "items.h"
#include "gendung.h"
#include "player.h"
#include "multi.h"
#include "sound.h"
/*-----------------------------------------------------------------------**
// externs
**-----------------------------------------------------------------------*/
extern char gszPrintVersion[];
void CALLBACK menusnd_play(LPBYTE lpWave);
BOOL CALLBACK UiEnumHeroes(ENUMHEROPROC enumproc);
BOOL CALLBACK UiCreateHero(TPUIHEROINFO heroinfo);
BOOL CALLBACK UiDeleteHero(TPUIHEROINFO heroinfo);
BOOL CALLBACK UiGetDefaultCharStats(int heroclass, TPUIDEFSTATS defaultstats);
void CALLBACK menusnd_play(LPCSTR pszFile);
void play_movie(const char * pszMovie,BOOL bAllowCancel);
BOOL StartGame(BOOL bNewGame,BOOL bSinglePlayer);
extern DWORD gbWalkOn;
extern const char *sgszWalkId;
extern char gszProgKey[];
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
#define PIXELS_PER_SEC 16
char gszHero[MAX_NAME_LEN];
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
void menu_music() {
static int snMusic = MUSIC_INTRO;
music_start(snMusic);
#if !IS_VERSION(SHAREWARE)
// look for a music track which is not the town, cause it's
// too wimpy for initial theme music, and is not l1, cause the
// players will hear waaaay too much of l1 music
do {
snMusic++; // next track
if (snMusic == NUM_MUSIC) snMusic = 0; // handle wrap
} while (snMusic == MUSIC_TOWN || snMusic == MUSIC_L1);
#endif
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
static BOOL do_menu(DWORD selection) {
if (selection == SELHERO_PREVIOUS)
return TRUE;
music_stop();
BOOL bResult = StartGame(
selection != SELHERO_CONTINUE, // new game ?
selection != SELHERO_CONNECT // single player game ?
);
if (bResult) menu_music();
return bResult;
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
static BOOL DoSinglePlayer() {
while (1) {
gbMaxPlayers = 1;
DWORD selection = 0;
if (!SRegLoadValue( gszProgKey,sgszWalkId,0,&gbWalkOn))
{
gbWalkOn = TRUE;
}
if (! UiSelHeroSingDialog(
UiEnumHeroes,
UiCreateHero,
UiDeleteHero,
UiGetDefaultCharStats,
&selection,
gszHero,
&gnDifficulty,
gbAllowBard,
gbAllowBarbarian
)) app_fatal(TEXT("Unable to display SelHeroSing"));
if (selection == SELHERO_PREVIOUS)
return TRUE;
if (! do_menu(selection))
return FALSE;
}
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
static BOOL DoMultiPlayer() {
while (1) {
gbMaxPlayers = MAX_PLRS;
DWORD selection = 0;
gbWalkOn = FALSE;
if (! UiSelHeroMultDialog(
UiEnumHeroes,
UiCreateHero,
UiDeleteHero,
UiGetDefaultCharStats,
&selection,
gszHero,
gbAllowBard,
gbAllowBarbarian
)) app_fatal(TEXT("Can't load multiplayer dialog"));
if (selection == SELHERO_PREVIOUS)
return TRUE;
if (! do_menu(selection))
return FALSE;
}
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
#if !IS_VERSION(SHAREWARE)
static void play_intro() {
music_stop();
play_movie("gendata\\Hellfire.smk",TRUE);
menu_music();
}
#endif
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
void DiabloMenu() {
menu_music();
BOOL bDone = FALSE;
while (! bDone) {
DWORD selection = 0;
if (! UiMainMenuDialog(gszPrintVersion,
&selection,
gbAllowMultiPlayer,
menusnd_play))
app_fatal(TEXT("Unable to display mainmenu"));
switch (selection) {
case MAINMENU_SINGLE_PLAYER:
#if IS_VERSION(BETA)
app_warning("Not available in beta version");
#else
if (! DoSinglePlayer()) bDone = TRUE;
#endif
break;
case MAINMENU_MULTIPLAYER:
if (! DoMultiPlayer()) bDone = TRUE;
break;
case MAINMENU_ATTRACT_MODE:
// it crashes after 20 minutes, so stop doing this.
break;
case MAINMENU_REPLAY_INTRO:
if (! bActive) break;
#if !IS_VERSION(SHAREWARE)
play_intro();
#endif
break;
case MAINMENU_SHOW_CREDITS:
UiCreditsDialog(PIXELS_PER_SEC);
break;
case MAINMENU_SUPPORT:
UiSupportDialog(PIXELS_PER_SEC);
break;
case MAINMENU_EXIT_DIABLO:
bDone = TRUE;
break;
}
}
music_stop();
}

19
src/MAINMENU.H Normal file
View File

@ -0,0 +1,19 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Constants and Variables
**
** (C)1996 Condor, Inc. All rights reserved.
**-----------------------------------------------------------------------**
** $Header: /Diablo/MAINMENU.H 2 1/23/97 12:21p Jmorin $
**-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------**
** Externs
**-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------**
** Prototypes
**-----------------------------------------------------------------------*/
void DiabloMenu();

287
src/MINITEXT.CPP Normal file
View File

@ -0,0 +1,287 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Miniquest Text file
**
** (C)1995 Condor, Inc. All rights reserved.
**
**-----------------------------------------------------------------------*/
#include "diablo.h"
#pragma hdrstop
#include "minitext.h"
#include "textdat.h"
#include "engine.h"
#include "scrollrt.h"
#include "quests.h"
#include "effects.h"
#include "items.h"
#include "gendung.h"
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
#define KERNSPACE 2
static const BYTE qfonttrans[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0-15
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16-31
0, 37, 49, 38, 0, 39, 40, 47, 42, 43, 41, 45, 52, 44, 53, 55, // 32-47
36, 27, 28, 29, 30, 31, 32, 33, 34, 35, 51, 50, 48, 46, 49, 54, // 48-63
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, // 64-79
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 42, 0, 43, 0, 0, // 80-95
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, // 96-111
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 48, 0, 49, 0, 0 }; // 112-127
/*char qfontkern[56] = { 8, // Space/Invalid
24, 16, 19, 20, 15, 15, 19, 18, 8, 8, 18, 14, 24, 20, 23, 15, // a-p
24, 20, 16, 21, 24, 25, 32, 24, 25, 18, // q-z
8, 16, 17, 17, 16, 16, 17, 16, 16, 24, // 1-0
8, 15, 26, 23, 13, 9, 8, 10, 13, 12, 8, 15, 15, 8, 8, 8, 8, 16, 17 }; // misc */
static const BYTE qfontkern[56] = { 5, // Space/Invalid
15, 10, 13, 14, 10, 9, 13, 11, 5, 5, 11, 10, 16, 13, 16, 10, // a-p
15, 12, 10, 14, 17, 17, 22, 17, 16, 11, // q-z
5, 11, 11, 11, 10, 11, 11, 11, 11, 15, // 1-0
5, 10, 18, 15, 8, 6, 6, 7, 10, 9, 6, 10, 10, 5, 5, 5, 5, 11, 12 }; // misc
BYTE qtextflag;
static BYTE *pMedTextCels;
static BYTE *pTextBoxCels;
static const char *qtextptr;
static int qtexty;
int qtextSpd;
static int qtextDelay;
static DWORD sgLastScroll;
//Quest text scrolling rate 1 = slowest, 5 = normal, 9 = fastest
int qtextDelaySpd[10] = { 2, 4, 6, 8, 0, -1, -2, -3, -4 };
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
#define MQTEXTX1 112
#define MQTEXTY1 241
#define MQTEXTW 543
#define MQTEXTY2 469
#define MQTEXTNL 38
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
void FreeQuestText() {
DiabloFreePtr(pMedTextCels);
DiabloFreePtr(pTextBoxCels);
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
void InitQuestText() {
app_assert(! pMedTextCels);
pMedTextCels = LoadFileInMemSig("Data\\MedTextS.CEL",NULL,'MINI');
pTextBoxCels = LoadFileInMemSig("Data\\TextBox.CEL",NULL,'MINI');
qtextflag = FALSE;
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
void InitQTextMsg(int m) {
app_assert((DWORD) m < gdwAllTextEntries);
if (alltext[m].scrlltxt)
{
questlog = FALSE;
qtextflag = TRUE;
qtextptr = alltext[m].txtstr;
qtexty = MQTEXTY2 + 31;
qtextSpd = qtextDelaySpd[alltext[m].txtspd-1];
qtextDelay = qtextSpd;
sgLastScroll = GetTickCount();
#if CHEATS
if ((currlevel == 0) && (davecheat)) {
qtextSpd = qtextDelaySpd[tstQMsgSpd-1];
qtextDelay = qtextSpd;
}
#endif
}
PlaySFX(alltext[m].sfxnr);
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
void DrawQTextBack()
{
DrawCel(88, 487, pTextBoxCels, 1, 591);
app_assert(gpBuffer);
__asm {
mov edi,dword ptr [gpBuffer]
add edi,371803
xor eax,eax
mov edx,148
_YLp: mov ecx,292
_XLp1: stosb
inc edi
loop _XLp1
stosb
sub edi,1353
mov ecx,292
_XLp2: inc edi
stosb
loop _XLp2
sub edi,1352
dec edx
jnz _YLp
mov ecx,292
_XLp3: stosb
inc edi
loop _XLp3
stosb
}
}
/*-----------------------------------------------------------------------**
**-----------------------------------------------------------------------*/
void DrawQTextCel (long xp, long yp, BYTE *pCelBuff, long nCel)
{
BYTE *pTo, *pY1, *pY2;
long RLELen;
app_assert(gpBuffer);
pTo = gpBuffer + nBuffWTbl[yp] + xp;
pY1 = gpBuffer + nBuffWTbl[MQTEXTY1-32];
pY2 = gpBuffer + nBuffWTbl[MQTEXTY2];
__asm {
mov ebx,dword ptr [pCelBuff]
mov eax,dword ptr [nCel]
shl eax,2
add ebx,eax
mov eax,dword ptr [ebx+4]
sub eax,dword ptr [ebx]
mov dword ptr [RLELen],eax
mov esi,dword ptr [pCelBuff]
add esi,dword ptr [ebx]
mov edi,dword ptr [pTo] // Dest
mov ebx,dword ptr [RLELen]
add ebx,esi
_T1Lp1: mov edx,22
_T1Lp2: xor eax,eax // Load control byte
lodsb
or al,al
js _T1J
sub edx,eax
cmp edi,dword ptr [pY1]
jb _T1C
cmp edi,dword ptr [pY2]
ja _T1C
mov ecx,eax
shr ecx,1
jnc _T1w
movsb
jecxz _T1x
_T1w: shr ecx,1
jnc _T1Lp3
movsw
jecxz _T1x
_T1Lp3: rep movsd
jmp _T1x
_T1C: add esi,eax
add edi,eax
_T1x: or edx,edx
jz _T1Nxt
jmp _T1Lp2
_T1J: neg al // Do jump
add edi,eax
sub edx,eax
jnz _T1Lp2
_T1Nxt: sub edi,790
cmp ebx,esi
jnz _T1Lp1
}
}
/*-----------------------------------------------------------------------*
**-----------------------------------------------------------------------*/
void DrawQText()
{
const char *p, *pt, *pnl;
char tempstr[128];
int tx, ty;
int l, i;
BOOL doneflag;
DrawQTextBack();
p = qtextptr;
pnl = NULL;
tx = MQTEXTX1;
ty = qtexty;
doneflag = FALSE;
while (!doneflag) {
l = 0;
pt = p;
for (i = 0; (*pt != '\n') && (*pt != '|') && (l < MQTEXTW); i++) {
BYTE c = char2print(*pt++);
if (c != 0) {
tempstr[i] = c;
c = qfonttrans[c];
l += qfontkern[c] + KERNSPACE;
} else i--;
}
tempstr[i] = 0;
if (*pt == '|') {
tempstr[i] = 0;
doneflag = TRUE;
} else if (*pt == '\n') {
pt++;
} else while ((tempstr[i] != ' ') && (i > 0)) {
tempstr[i] = 0;
i--;
}
for (i = 0; tempstr[i] != 0; i++) {
BYTE c = char2print(tempstr[i]);
c = qfonttrans[c];
// while (*p == 0) p++; <<< this look awfully dangerous -- pat
p++;
if (*p == '\n') p++;
if (c != 0) DrawQTextCel(tx, ty, pMedTextCels, c);
tx += qfontkern[c] + KERNSPACE;
}
if (pnl == NULL) pnl = p;
tx = MQTEXTX1;
ty += MQTEXTNL;
if (ty > (MQTEXTY2+32)) doneflag = TRUE;
}
//Delay for text scrolling
DWORD currTime = GetTickCount();
do {
if (qtextSpd <= 0) { //Go faster
qtexty--;
qtexty += qtextSpd;
} else { //Go slower
qtextDelay--;
if (qtextDelay != 0) qtexty--;
}
if (qtextDelay == 0) qtextDelay = qtextSpd;
if (qtexty <= (MQTEXTY1-32)) {
qtexty += MQTEXTNL;
qtextptr = pnl;
if (*qtextptr == '|') qtextflag = FALSE; // done?
break;
}
sgLastScroll += 1000/GAME_FRAMES_PER_SECOND;
} while (currTime-sgLastScroll < 0x7FFFFFFF);
}

43
src/MINITEXT.H Normal file
View File

@ -0,0 +1,43 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Constants and Variables
**
** (C)1995 Condor, Inc. All rights reserved.
**-----------------------------------------------------------------------**
** $Header: /Diablo/MINITEXT.H 2 1/23/97 12:21p Jmorin $
**-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------**
** Defines
**-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------**
** Structures
**-----------------------------------------------------------------------*/
typedef struct {
char *txtstr; // String to be called
BOOL scrlltxt; // will text scroll ?
BOOL txtspd; // text speed
int sfxnr; // Sound effect to be called
} TextDataStruct;
/*-----------------------------------------------------------------------**
** Externs
**-----------------------------------------------------------------------*/
extern BYTE qtextflag;
extern int qtextSpd;
extern int qtextDelaySpd[10];
/*-----------------------------------------------------------------------**
** Prototypes
**-----------------------------------------------------------------------*/
void InitQuestText();
void DrawQText();
void FreeQuestText();
void InitQTextMsg(int);
void DrawQTextBack();

1886
src/MISDAT.CPP Normal file

File diff suppressed because it is too large Load Diff

135
src/MISDAT.H Normal file
View File

@ -0,0 +1,135 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Constants and Variables
**
** (C)1996 Condor, Inc. All rights reserved.
**
**-----------------------------------------------------------------------**
** $Header: /Diablo/MISDAT.H 2 1/23/97 12:21p Jmorin $
**-----------------------------------------------------------------------**
**
** File Routines
**-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------**
** Defines
**-----------------------------------------------------------------------*/
typedef void (*MIADDPRC)(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, int id, int dam);
typedef void (*MIPROC)(int i);
#define MIS_WEAP 0
#define MIS_SPL 1
#define MIS_NONE 2
// Missile Magic Type
#define MIMT_NONE 0
#define MIMT_FIRE 1
#define MIMT_LGHT 2
#define MIMT_MISC 3
#define MIMT_ACID 4
// Missile File Flags
#define MFF_MONSTONLY 1 // Only loaded for particular monsters
#define MFF_STATIC 2 // Do not animate -- one frame per direction
#define MFF_MULTI 4 // All directions of anim are in one file
#define MF_NONE 255
#define MF_STARTLOAD 0
#define MF_ARROW 0
#define MF_FIREBOLT 1
#define MF_GUARDIAN 2
#define MF_LIGHTNING 3
#define MF_FIRE 4
#define MF_EXP1 5
#define MF_TOWN 6
#define MF_FLASH1 7
#define MF_FLASH2 8
#define MF_MANASHLD 9
#define MF_BLOOD 10
#define MF_BONE 11
#define MF_METAL 12
#define MF_FARROW 13
#define MF_DOOM 14
#define MF_GOLEM 15
#define MF_SPURT 16
#define MF_BOOM 17
#define MF_STONE 18
#define MF_BIGEXP 19
#define MF_FLAMES 20
#define MF_THINLIGHT 21
#define MF_FLARE 22
#define MF_FLAREXP 23
#define MF_MAGBALL 24
#define MF_KRULL 25
#define MF_CBOLT 26
#define MF_HBOLT 27
#define MF_HEXPL 28
#define MF_LARROW 29
#define MF_FAEXP 30
#define MF_ACID 31
#define MF_ACIDSPLAT 32
#define MF_ACIDPUD 33
#define MF_ETHER 34
#define MF_FIRERUN 35
#define MF_RESURRECT 36
#define MF_BONESPIRIT 37
#define MF_RPORTAL 38
#define MF_FIREPLAR 39
#define MF_BFLARE 40
#define MF_BFLAREXP 41
#define MF_CFLARE 42
#define MF_CFLAREXP 43
#define MF_DFLARE 44
#define MF_DFLAREXP 45
#define MF_HORKSPAWN 46
#define MF_REFLECTSHLD 47
#define MF_ORANGEFLARE 48
#define MF_BLUEFLARE 49
#define MF_REDFLARE 50
#define MF_YELLOWFLARE 51
#define MF_RUNEHOTSPOT 52
#define MF_YELLOWEXPLOSION 53
#define MF_BLUEEXPLOSION 54
#define MF_REDEXPLOSION 55
#define MF_BLUE2FLARE 56
#define MF_ORANGEEXPLOSION 57
#define MF_BLUE2EXPLOSION 58
/*-----------------------------------------------------------------------**
** Structures
**-----------------------------------------------------------------------*/
typedef struct {
BYTE mName; // #defines name of missile for ease of use
MIADDPRC mAddProc; // procedure for creating one of these missiles
MIPROC mProc; // procedure to run each frame
BOOL mDraw; // missile draw or not flag
BYTE mType; // missile type (weapon, spell, none)
BYTE mResist; // missile resistance type (fire, light, misc, none)
BYTE mFileNum; // file# of missile gfx table
int mlSFX; // missile launch sound
int miSFX; // missile impact sound
} MissileData;
typedef struct {
BYTE mAnimName; // #defines name of missile file for ease of use
BYTE mAnimFAmt; // amount of files
char *mAnimPath; // path for cels
BOOL mFlags; // e.g. MFF_MONSTOLY
BYTE *mAnimData[16]; // data pointer to anim tables
BYTE mAnimDelay[16]; // anim delay amount
BYTE mAnimLen[16]; // number of anim frames
long mAnimWidth[16]; // anim width
long mAnimWidth2[16]; // anim width2
} MisFileData;
/*-----------------------------------------------------------------------**
** Externs
**-----------------------------------------------------------------------*/
extern MissileData missiledata[];
extern MisFileData misfiledata[];
/*-----------------------------------------------------------------------**
** Prototypes
**-----------------------------------------------------------------------*/

7451
src/MISSILES.CPP Normal file

File diff suppressed because it is too large Load Diff

220
src/MISSILES.H Normal file
View File

@ -0,0 +1,220 @@
/*-----------------------------------------------------------------------**
** Diablo
**
** Constants and Variables
**
** (C)1995 Condor, Inc. All rights reserved.
**-----------------------------------------------------------------------**
** $Header: /Diablo/MISSILES.H 2 1/23/97 12:21p Jmorin $
**-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------**
** Defines
**-----------------------------------------------------------------------*/
#define MAXMISSILES 125
#define MIT_ARROW 0
#define MIT_FIREBOLT 1
#define MIT_GUARDIAN 2
#define MIT_PHASE 3
#define MIT_LIGHTBALL 4
#define MIT_FIREWALL 5
#define MIT_FIREBALL 6
#define MIT_LIGHTCTRL 7
#define MIT_LIGHTNING 8
#define MIT_MISEXP 9
#define MIT_TOWN 10
#define MIT_FLASH 11
#define MIT_FLASH2 12
#define MIT_MANASHIELD 13
#define MIT_FIREMOVE 14
#define MIT_CHAIN 15
#define MIT_CHAINBALL 16
#define MIT_BLOOD 17
#define MIT_BONE 18
#define MIT_METAL 19
#define MIT_RHINO 20
#define MIT_MAGMABALL 21
#define MIT_THINLIGHTCTRL 22
#define MIT_THINLIGHT 23
#define MIT_FLARE 24
#define MIT_FLAREXP 25
#define MIT_TELE 26
#define MIT_FARROW 27
#define MIT_DOOM 28
#define MIT_FIREONLY 29
#define MIT_STONE 30
#define MIT_BLOODR 31
#define MIT_INVIS 32
#define MIT_GOLEM 33
#define MIT_ETHER 34
#define MIT_SPURT 35
#define MIT_BOOM 36
#define MIT_HEAL 37
#define MIT_FIREWALLC 38
#define MIT_INFRA 39
#define MIT_IDENTIFY 40
#define MIT_WAVE 41
#define MIT_NOVA 42
//#define MIT_BLDBOIL 43
#define MIT_RAGE 43
#define MIT_APOCA 44
#define MIT_REPAIR 45
#define MIT_RECHARGE 46
#define MIT_DISARM 47
#define MIT_FLAME 48
#define MIT_FLAMEC 49
#define MIT_FIREMAN 50
#define MIT_KRULL 51
#define MIT_CBOLT 52
#define MIT_HBOLT 53
#define MIT_RESURRECT 54
#define MIT_TELEKINESIS 55
#define MIT_LARROW 56
#define MIT_ACID 57
#define MIT_ACIDSPLAT 58
#define MIT_ACIDPUD 59
#define MIT_HEALOTHER 60
#define MIT_ELEMENT 61
#define MIT_RESURRECTBEAM 62
#define MIT_BONESPIRIT 63
#define MIT_WEAPEXP 64
#define MIT_RPORTAL 65
#define MIT_FIREPLAR 66
#define MIT_DIABAPOCA 67
#define MIT_MANA 68
#define MIT_FMANA 69
#define MIT_LIGHTWALL 70
#define MIT_LIGHTWALLC 71
#define MIT_IMMOLATION 72
#define MIT_SPECARROW 73
#define MIT_FBARROW 74
#define MIT_LTARROW 75
#define MIT_CBARROW 76
#define MIT_HBARROW 77
#define MIT_TELESTAIRS 78
#define MIT_REFLECT 79
#define MIT_BERSERK 80
#define MIT_FLAMEBOX 81
#define MIT_DISENCHANT 82
#define MIT_MANAREMOVE 83
#define MIT_LIGHTBOX 84
#define MIT_SHOWMAGITEMS 85
#define MIT_AURA 86
#define MIT_AURA2 87
#define MIT_SPIRALFIREBALL 88
#define MIT_RUNEOFFIRE 89
#define MIT_RUNEOFLIGHT 90
#define MIT_RUNEOFNOVA 91
#define MIT_RUNEOFIMMOLATION 92
#define MIT_RUNEOFSTONE 93
#define MIT_BIGEXPLOSION 94
#define MIT_HORKSPAWN 95
#define MIT_RANDOM 96
#define MIT_OPENNEST 97
#define MIT_ORANGEFLARE 98
#define MIT_BLUEFLARE 99
#define MIT_REDFLARE 100
#define MIT_YELLOWFLARE 101
#define MIT_BLUE2FLARE 102
#define MIT_YELLOWEXPLOSION 103
#define MIT_REDEXPLOSION 104
#define MIT_BLUEEXPLOSION 105
#define MIT_BLUE2EXPLOSION 106
#define MIT_ORANGEEXPLOSION 107
#define NUMBER_OF_MISSILE_TYPES (1 + MIT_ORANGEEXPLOSION)
#define MI_ENEMYMONST 0
#define MI_ENEMYPLR 1
#define MI_ENEMYBOTH 2
/*-----------------------------------------------------------------------**
** Structures
**-----------------------------------------------------------------------*/
typedef struct {
int _mitype; // missile type
int _mix; // missile map x
int _miy; // missile map y
long _mixoff; // offset x from left of map tile
long _miyoff; // offset y from bottom of map tile
long _mixvel; // current x rate
long _miyvel; // current y rate
int _misx; // missile map start x
int _misy; // missile map start y
long _mitxoff; // missile total offset from start x
long _mityoff; // missile total offset from start y
int _mimfnum; // current facing direction
int _mispllvl; // level of missile
BOOL _miDelFlag; // delete flag
BYTE _miAnimType; // data pointer to anim tables
BOOL _miAnimFlags; // various animation related flags
BYTE *_miAnimData; // Data pointer to anim tables
int _miAnimDelay; // anim delay amount
int _miAnimLen; // number of anim frames
long _miAnimWidth; // anim width
long _miAnimWidth2; // anim width2
int _miAnimCnt; // current anim delay value
int _miAnimAdd; // anim number to add to next frame (-1 backwards)
int _miAnimFrame; // current anim frame
BOOL _miDrawFlag; // draw missile at all
BOOL _miLightFlag; // draw with light sourcing?
BOOL _miPreFlag; // draw missile behind plr,monsters,objects
BOOL _miUniqTrans; // draw missile with special palette translation
int _mirange; // max range of missile
int _misource; // which monster/plr shot me
int _micaster; // monst/plr/damages both.
int _midam; // missile damage
BOOL _miHitFlag; // did it hit a monster or plr?
int _midist; // how long have I been traveling
int _mlid; // light id
int _mirnd; // random seed
long _miVar1; // scratch var 1
long _miVar2; // scratch var 2
long _miVar3; // scratch var 3
long _miVar4; // scratch var 4
long _miVar5; // scratch var 5
long _miVar6; // scratch var 6
long _miVar7; // scratch var 7
long _miVar8; // scratch var 8
} MissileStruct;
#define SAVE_MISSILE_SIZE sizeof(MissileStruct)
/*-----------------------------------------------------------------------**
** Externs
**-----------------------------------------------------------------------*/
extern int nummissiles;
extern int missileactive[MAXMISSILES];
extern int missileavail[MAXMISSILES];
extern BOOL MissilePreFlag;
extern MissileStruct missile[MAXMISSILES];
extern int XDirAdd[8];
extern int YDirAdd[8];
/*-----------------------------------------------------------------------**
** Prototypes
**-----------------------------------------------------------------------*/
void InitMissileGFX();
void FreeMissileGFX();
void ILoadMissileGFX(BYTE);
void IFreeMissileGFX();
void InitMissiles();
void ProcessMissiles();
int AddMissile(int, int, int, int, int, int, char, int, int, int);
//void RndBlood (int, int, int, int, int);
BOOL MonsterTrapHit(int, int, int, int, int, byte);
BOOL PlayerMHit(int, int, int, int, int, int, byte, BOOL, bool *);
int GetSpellLevel(int, int);
void GetDamageAmt(int, int *, int *);
void SyncMissAnim();
void ClearMissileSpot(int mi);

6889
src/MISSILES.SAV Normal file

File diff suppressed because it is too large Load Diff

93
src/MONO.CPP Normal file
View File

@ -0,0 +1,93 @@
#include "mono.h"
// Allocate space for the MonoDriver data.
// and Call the constructor for one MonoDevice data object.
MonoDevice::DeviceData MonoDevice::MDA;
MonoDevice::DeviceData::DeviceData() :
fhDevice (CreateFile("\\\\.\\DARKMONO.VXD", 0, 0, NULL, NULL,
FILE_FLAG_DELETE_ON_CLOSE, NULL)),
fEnabled((fhDevice != INVALID_HANDLE_VALUE)),
fNextRow(0),
fNextCol(0)
{
ClearScreen();
}
MonoDevice::DeviceData::~DeviceData()
{
if( Status() )
{
CloseHandle(fhDevice);
fEnabled = false;
fhDevice = INVALID_HANDLE_VALUE;
fNextRow = 0;
fNextCol = 0;
}
}
int MonoDevice::PutString( int row, int col, char const * string )
{
int Result = 0;
if( Status() && row < HEIGHT && col < WIDTH)
{
short buff[3 + 41]; // allow WIDTH character string
int len = strlen( string );
Result = len;
int bufferLen = 0;
for (;len > 0; len -= WIDTH, ++row, col=0, string += bufferLen )
{
bufferLen = ((len + col) > WIDTH)? WIDTH - (len + col) : len;
if (row >= HEIGHT)
row = 0;
buff[0] = static_cast<short>(row);
buff[1] = static_cast<short>(col);
buff[2] = static_cast<short>(bufferLen);
if( buff[2] > (WIDTH - col) )
{
buff[2] = (WIDTH - col);
strncpy( reinterpret_cast<char *>(buff + 3), string, buff[2] );
}
else
strcpy( reinterpret_cast<char *>(buff + 3), string );
DeviceIoControl(MDA.fhDevice, PUT_STRING,
&(buff[0]), sizeof( buff ), NULL, 0, NULL, NULL);
}
}
return Result;
}
void __cdecl MonoDevice::Printf( int row, int col, char const * const format, ... )
{
if( Status() )
{
char strbuf [ 256 ];
va_list argptr;
va_start(argptr,format);
vsprintf(strbuf,format,argptr);
va_end(argptr);
PutString( row, col, strbuf );
}
}
void __cdecl MonoDevice::Printf( char const * const format, ... )
{
if( Status() )
{
char strbuf [ 256 ];
va_list argptr;
va_start(argptr,format);
vsprintf(strbuf,format,argptr);
va_end(argptr);
PutString( strbuf );
}
}

223
src/MONO.H Normal file
View File

@ -0,0 +1,223 @@
/* ========================================================================
Copyright (c) 1990,1997 Synergistic Software
All Rights Reserved
Author:
======================================================================== */
#ifndef _MONO_H_
#define _MONO_H_
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#include <string.h>
//#ifdef __BORLANDC__
//#pragma option -a4
//#endif
//#ifdef _MSC_VER
//#pragma pack(push,4)
//#endif
// Define __cdecl for non Microsoft compilers.
#if (!defined(_MSC_VER) && !defined(__cdecl) )
#define __cdecl
#endif
// This class is to help put text strings out to a monochrome monitor under
// Windows95.
// It requires the DARKMONO.VXD driver to be installed to work.
// It does do line wrapping.
// There is no stored buffer of the text, so no scrolling.
class MonoDevice
{
private:
// Helper class to do auto initialization and to keep from opening the
// driver more than once.
class DeviceData {
private:
friend class MonoDevice;
explicit DeviceData();
inline bool Status() const;
HANDLE fhDevice;
bool fEnabled;
int fNextRow;
int fNextCol;
protected:
public:
~DeviceData();
};
enum MonoDimisions
{
WIDTH = 80,
HEIGHT = 24
};
enum MonoFunctions
{
MONO_VERSION = 1,
CURSOR_ON = 2,
CURSOR_OFF = 3,
SET_ATTRIBUTE = 4,
CLEAR_SCREEN = 5,
PUT_CHAR = 6,
PUT_STRING = 7
};
// Can't create or distroy one of these.
MonoDevice();
~MonoDevice();
// Can only have one Monochrome display.
static DeviceData MDA;
public:
typedef enum Attrib
{
ERASE =0x00,NORM =0x07, NORM_BLNK =0x87,
INVRS =0x70,UNDRLN =0x01, UNDRLN_BLNK =0x81,
INVRS_BLNK=0xF0,HI =0x0F, HI_BLNK =0x8F,
HI_UNDRLN=0x09, HI_UNDRLN_BLNK=0x89
};
static inline bool Status() { return MDA.Status(); }
static inline bool IsEnabled();
static inline void Enable();
static inline void Disable();
static inline void SetAttribute( Attrib attribute );
static inline void CursorOn();
static inline void CursorOff();
static inline void ClearScreen( char fill = ERASE);
static inline bool PutChar( int row, int col, char value );
static inline bool PutChar( char value );
static int PutString( int row, int col, char const * const string );
static inline int PutString( char const * const string );
static void __cdecl Printf( int row, int col, char const * const format, ... );
static void __cdecl Printf(char const * const format, ... );
};
inline bool MonoDevice::DeviceData::Status() const
{
return fhDevice != INVALID_HANDLE_VALUE && fEnabled;
}
inline bool MonoDevice::IsEnabled()
{
return MDA.fEnabled;
}
inline void MonoDevice::Enable()
{
MDA.fEnabled = true;
}
inline void MonoDevice::Disable()
{
MDA.fEnabled = false;
}
inline void MonoDevice::SetAttribute( Attrib attribute )
{
if( Status() )
{
unsigned char attr = static_cast<unsigned char>(attribute);
DeviceIoControl(MDA.fhDevice, SET_ATTRIBUTE,
&attr, sizeof( attr ),
NULL, 0, NULL, NULL);
}
}
inline void MonoDevice::CursorOn()
{
if( Status() )
DeviceIoControl(MDA.fhDevice, CURSOR_ON,
NULL, 0, NULL, 0, NULL, NULL);
}
inline void MonoDevice::CursorOff()
{
if( Status() )
DeviceIoControl(MDA.fhDevice, CURSOR_OFF,
NULL, 0, NULL, 0, NULL, NULL);
}
inline void MonoDevice::ClearScreen( char fill )
{
if( Status() )
{
DeviceIoControl(MDA.fhDevice, CLEAR_SCREEN,
&fill, sizeof( fill ), NULL, 0, NULL, NULL);
MDA.fNextRow = 0;
MDA.fNextCol = 0;
}
}
inline bool MonoDevice::PutChar( int row, int col, char value )
{
bool Result = false;
if( Status() && row < HEIGHT && col < WIDTH)
{
short buff[3];
buff[0] = static_cast<short>(row);
buff[1] = static_cast<short>(col);
buff[2] = value; // high byte doesn't matter
DeviceIoControl(MDA.fhDevice, PUT_CHAR,
&(buff[0]), sizeof( buff ), NULL, 0, NULL, NULL);
Result = true;
}
return Result;
}
inline bool MonoDevice::PutChar( char value )
{
bool const Result = PutChar (MDA.fNextCol, MDA.fNextRow, value);
if (Result)
{
++MDA.fNextCol;
if (MDA.fNextCol > WIDTH)
{
MDA.fNextCol = 0;
++MDA.fNextRow;
if (MDA.fNextRow > HEIGHT)
{
MDA.fNextRow = 0;
}
}
}
return Result;
}
inline int MonoDevice::PutString( char const * const string )
{
int const Result = PutString(MDA.fNextRow, MDA.fNextCol, string);
MDA.fNextCol += Result % WIDTH;
if (MDA.fNextCol > WIDTH)
{
MDA.fNextCol %= WIDTH;
++MDA.fNextRow;
}
MDA.fNextRow += Result / WIDTH;
if (MDA.fNextRow > HEIGHT)
{
MDA.fNextRow %= HEIGHT;
}
return Result;
}
//#ifdef __BORLANDC__
//#pragma option -a.
//#endif
//#ifdef _MSC_VER
//#pragma pack(pop)
//#endif
#endif

148
src/MONO_C.CPP Normal file
View File

@ -0,0 +1,148 @@
#ifdef _DEBUG
#include <fcntl.h>
#include <sys\stat.h>
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include "mono_c.h"
//---------------------------------------------------------------------------
bool mono_getExist( void )
{
return MonoDevice::Status() ? true : false; // Returns TRUE, if device detected
} // else returns FALSE
int mono_getEnable( void )
{
return MonoDevice::IsEnabled() ? true : false; // Returns ON, if device enabled
} // else returns OFF
void mono_setEnable( int flag ) // flag = TRUE - use mono device
{ // flag = FALSE - don't use
if( flag == TRUE )
MonoDevice::Enable();
else
MonoDevice::Disable();
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void mono_cls(void)
{
MonoDevice::ClearScreen( ' ' );
}
//---------------------------------------------------------------------------
void mono_putc( short x, short y, char c)
{
MDA.PutChar( y, x, c );
}
//---------------------------------------------------------------------------
void mono_puts( short x, short y, char const * const str )
{
MDA.PutString( y, x, str );
}
//---------------------------------------------------------------------------
void __cdecl mono_printf( short x, short y, char const * const format, ... )
{
char strbuf [ 256 ];
va_list argptr;
va_start(argptr,format);
vsprintf(strbuf,format,argptr);
va_end(argptr);
MDA.PutString( y, x, strbuf );
}
//---------------------------------------------------------------------------
void mono_dump ( short port )
{
/*
if( MDA.IsEnabled() && MDA.Status() )
{
char linefeed[3] = "\r\n";
int fp;
char lptPort[] = "LPTx";
lptPort[3] = port + '0'; //set LPT port
short *ptr = 0;//(short *)(_x386_zero_base_ptr + MONOBASE);
short i;
short ch;
short attribute;
short col = 0;
if ((fp = open(lptPort, O_WRONLY) ) >= 0)
{
// Output screen
for (i=0; i<MONOHEIGHT*MONOWIDTH; i++)
{
attribute = (*ptr)>>8;
ch = (*ptr) & 0x00ff;
(*ptr) = 0x0fdb; //display a progress character
if (attribute == MONO_NORM)
write(fp, "(s0B", 5); //Normal on
else
write(fp, "(s7B", 5); //BOLD on
if (!ch)
ch = ' '; // char 0 is also a space on the mono
write(fp, &ch, 1); //write the character
if (++col == MONOWIDTH) //Next line?
{
col = 0;
write(fp,&linefeed,2);
}
(*ptr) = (attribute<<8)+ch; //remove progress character
ptr++;
}
close(fp);
}
}
*/
}
//---------------------------------------------------------------------------
void mono_setAttrib( MonoAttrib attrib )
{
MDA.SetAttribute( attrib );
}
MonoAttrib mono_getAttrib()
{
return MONO_NORM;
}
//---------------------------------------------------------------------------
void mono_setHardwareCursor( int flag ) // flag = TRUE - use mono device
{ // flag = FALSE - don't use
if( flag )
MDA.CursorOn();
else
MDA.CursorOff();
}
#endif


36
src/MONO_C.H Normal file
View File

@ -0,0 +1,36 @@
#ifdef _DEBUG
#ifndef _MONO_C_H_
#define _MONO_C_H_
#include "mono.h"
//°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
//
// Global Function Declarations
//
//°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
void mono_setAttrib( MonoAttrib aVal );
MonoAttrib mono_getAttrib( void );
int mono_getExist ( void );
int mono_getEnable( void );
void mono_setEnable( int flag );
void mono_cls ( void );
void mono_putc ( short x, short y, char c );
void mono_puts ( short x, short y, char const * const str );
void __cdecl mono_printf( short x, short y, char const * const format, ... );
void mono_dump ( short port = 1);
void mono_setHardwareCursor( int flag );
#endif
#endif


Some files were not shown because too many files have changed in this diff Show More