Devilution
Diablo devolved - magic behind the 1996 computer game
engine.h
Go to the documentation of this file.
1 
13 #ifndef __ENGINE_H__
14 #define __ENGINE_H__
15 
16 //offset 0
17 //pCelBuff->pFrameTable[0]
18 
20 extern char gbPixelCol;
22 extern BOOL gbRotateMap;
24 extern int orgseed;
26 extern int SeedCount;
28 extern BOOL gbNotInView;
29 
30 inline BYTE *CelGetFrameStart(BYTE *pCelBuff, int nCel)
31 {
32  DWORD *pFrameTable;
33 
34  pFrameTable = (DWORD *)pCelBuff;
35 
36  return pCelBuff + SwapLE32(pFrameTable[nCel]);
37 }
38 
39 #define LOAD_LE32(b) (((DWORD)(b)[3] << 24) | ((DWORD)(b)[2] << 16) | ((DWORD)(b)[1] << 8) | (DWORD)(b)[0])
40 inline BYTE *CelGetFrame(BYTE *pCelBuff, int nCel, int *nDataSize)
41 {
42  DWORD nCellStart;
43 
44  nCellStart = LOAD_LE32(&pCelBuff[nCel * 4]);
45  *nDataSize = LOAD_LE32(&pCelBuff[(nCel+1) * 4]) - nCellStart;
46  return pCelBuff + nCellStart;
47 }
48 
49 inline BYTE *CelGetFrameClipped(BYTE *pCelBuff, int nCel, int *nDataSize)
50 {
51  DWORD nDataStart;
52  BYTE *pRLEBytes = CelGetFrame(pCelBuff, nCel, nDataSize);
53 
54  nDataStart = pRLEBytes[1] << 8 | pRLEBytes[0];
55  *nDataSize -= nDataStart;
56 
57  return pRLEBytes + nDataStart;
58 }
59 
60 void CelDraw(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth);
61 void CelBlitFrame(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth);
62 void CelClippedDraw(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth);
63 void CelDrawLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, BYTE *tbl);
64 void CelClippedDrawLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth);
65 void CelClippedBlitLightTrans(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth);
66 void CelDrawLightRed(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, char light);
67 void CelBlitSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth);
68 void CelClippedDrawSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth);
69 void CelBlitLightSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, BYTE *tbl);
70 void CelBlitLightTransSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth);
71 void CelDrawLightRedSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, char light);
72 void CelBlitWidth(BYTE *pBuff, int x, int y, int wdt, BYTE *pCelBuff, int nCel, int nWidth);
73 void CelBlitOutline(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth);
74 void ENG_set_pixel(int sx, int sy, BYTE col);
75 void engine_draw_pixel(int sx, int sy);
76 void DrawLine(int x0, int y0, int x1, int y1, BYTE col);
77 int GetDirection(int x1, int y1, int x2, int y2);
78 void SetRndSeed(int s);
79 int GetRndSeed();
80 int random_(BYTE idx, int v);
81 void engine_debug_trap(BOOL show_cursor);
82 BYTE *DiabloAllocPtr(DWORD dwBytes);
83 void mem_free_dbg(void *p);
84 BYTE *LoadFileInMem(char *pszName, DWORD *pdwFileLen);
85 DWORD LoadFileWithMem(const char *pszName, void *p);
86 void Cl2ApplyTrans(BYTE *p, BYTE *ttbl, int nCel);
87 void Cl2Draw(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth);
88 void Cl2DrawOutline(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth);
89 void Cl2DrawLightTbl(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, char light);
90 void Cl2DrawLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth);
91 void Cl2BlitSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth);
92 void Cl2BlitOutlineSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, char col);
93 void Cl2BlitLightSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, BYTE *pTable);
94 void PlayInGameMovie(char *pszMovie);
95 
96 /* rdata */
97 
98 extern const int RndInc;
99 extern const int RndMult;
100 
101 #endif /* __ENGINE_H__ */
CelGetFrame
BYTE * CelGetFrame(BYTE *pCelBuff, int nCel, int *nDataSize)
Definition: engine.h:40
Cl2BlitLightSafe
void Cl2BlitLightSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, BYTE *pTable)
Blit CL2 sprite, and apply lighting, to the given buffer.
Definition: engine.cpp:1157
orgseed
int orgseed
Seed value before the most recent call to SetRndSeed()
Definition: engine.cpp:20
LoadFileInMem
BYTE * LoadFileInMem(char *pszName, DWORD *pdwFileLen)
Load a file in to a buffer.
Definition: engine.cpp:801
DiabloAllocPtr
BYTE * DiabloAllocPtr(DWORD dwBytes)
Multithreaded safe malloc.
Definition: engine.cpp:765
Cl2DrawLight
void Cl2DrawLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth)
Blit CL2 sprite, and apply lighting, to the back buffer at the given coordinates.
Definition: engine.cpp:1237
GetDirection
int GetDirection(int x1, int y1, int x2, int y2)
Calculate the best fit direction between two points.
Definition: engine.cpp:683
Cl2DrawOutline
void Cl2DrawOutline(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth)
Blit a solid colder shape one pixel larger then the given sprite shape, to the back buffer at the giv...
Definition: engine.cpp:1009
gbNotInView
BOOL gbNotInView
valid - if x/y are in bounds
Definition: engine.cpp:27
CelGetFrameStart
BYTE * CelGetFrameStart(BYTE *pCelBuff, int nCel)
Definition: engine.h:30
SeedCount
int SeedCount
Track number of calls to GetRndSeed() since last call to SetRndSeed()
Definition: engine.cpp:26
CelBlitWidth
void CelBlitWidth(BYTE *pBuff, int x, int y, int wdt, BYTE *pCelBuff, int nCel, int nWidth)
Blit to a buffer at given coordinates.
Definition: engine.cpp:509
CelBlitOutline
void CelBlitOutline(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth)
Blit a solid colder shape one pixel larger then the given sprite shape, to the back buffer at the giv...
Definition: engine.cpp:549
ENG_set_pixel
void ENG_set_pixel(int sx, int sy, BYTE col)
Set the value of a single pixel in the back buffer, checks bounds.
Definition: engine.cpp:609
Cl2DrawLightTbl
void Cl2DrawLightTbl(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, char light)
Blit CL2 sprite, and apply a given lighting, to the back buffer at the given coordianates.
Definition: engine.cpp:1123
Cl2ApplyTrans
void Cl2ApplyTrans(BYTE *p, BYTE *ttbl, int nCel)
Apply the color swaps to a CL2 sprite.
Definition: engine.cpp:859
Cl2Draw
void Cl2Draw(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth)
Blit CL2 sprite, to the back buffer at the given coordianates.
Definition: engine.cpp:904
CelDrawLightRedSafe
void CelDrawLightRedSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, char light)
Same as CelDrawLightRed but checks for drawing outside the buffer.
Definition: engine.cpp:450
Cl2BlitOutlineSafe
void Cl2BlitOutlineSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, char col)
Blit a solid colder shape one pixel larger then the given sprite shape, to the given buffer.
Definition: engine.cpp:1038
CelClippedDraw
void CelClippedDraw(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth)
Same as CelDraw but with the option to skip parts of the top and bottom of the sprite.
Definition: engine.cpp:79
LoadFileWithMem
DWORD LoadFileWithMem(const char *pszName, void *p)
Load a file in to the given buffer.
Definition: engine.cpp:830
random_
int random_(BYTE idx, int v)
Main RNG function.
Definition: engine.cpp:752
CelClippedBlitLightTrans
void CelClippedBlitLightTrans(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth)
Same as CelBlitLightTransSafe.
Definition: engine.cpp:424
LOAD_LE32
#define LOAD_LE32(b)
Definition: engine.h:39
CelBlitLightTransSafe
void CelBlitLightTransSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth)
Same as CelBlitLightSafe, with transparancy applied.
Definition: engine.cpp:334
GetRndSeed
int GetRndSeed()
Get the current RNG seed.
Definition: engine.cpp:739
CelDrawLightRed
void CelDrawLightRed(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, char light)
Blit CEL sprite, and apply lighting, to the back buffer at the given coordinates, translated to a red...
Definition: engine.cpp:155
CelGetFrameClipped
BYTE * CelGetFrameClipped(BYTE *pCelBuff, int nCel, int *nDataSize)
Definition: engine.h:49
RndInc
const int RndInc
Specifies the increment used in the Borland C/C++ pseudo-random.
Definition: engine.cpp:32
CelDrawLight
void CelDrawLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, BYTE *tbl)
Blit CEL sprite, and apply lighting, to the back buffer at the given coordinates.
Definition: engine.cpp:104
CelDraw
void CelDraw(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth)
Blit CEL sprite to the back buffer at the given coordinates.
Definition: engine.cpp:47
CelBlitLightSafe
void CelBlitLightSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, BYTE *tbl)
Blit CEL sprite, and apply lighting, to the given buffer, checks for drawing outside the buffer.
Definition: engine.cpp:271
gbPixelCol
char gbPixelCol
automap pixel color 8-bit (palette entry)
Definition: engine.cpp:18
mem_free_dbg
void mem_free_dbg(void *p)
Multithreaded safe memfree.
Definition: engine.cpp:786
gbRotateMap
BOOL gbRotateMap
flip - if y < x
Definition: engine.cpp:19
CelClippedDrawSafe
void CelClippedDrawSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth)
Same as CelClippedDraw but checks for drawing outside the buffer.
Definition: engine.cpp:246
DrawLine
void DrawLine(int x0, int y0, int x1, int y1, BYTE col)
Draw a line on the back buffer.
Definition: engine.cpp:657
RndMult
const int RndMult
Specifies the multiplier used in the Borland C/C++ pseudo-random number generator algorithm.
Definition: engine.cpp:37
engine_debug_trap
void engine_debug_trap(BOOL show_cursor)
SwapLE32
#define SwapLE32
Definition: defs.h:182
CelBlitFrame
void CelBlitFrame(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth)
Blit a given CEL frame to the given buffer.
Definition: engine.cpp:59
Cl2BlitSafe
void Cl2BlitSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth)
Blit CL2 sprite to the given buffer.
Definition: engine.cpp:929
SetRndSeed
void SetRndSeed(int s)
Set the RNG seed.
Definition: engine.cpp:728
engine_draw_pixel
void engine_draw_pixel(int sx, int sy)
Set the value of a single pixel in the back buffer to that of gbPixelCol, checks bounds.
Definition: engine.cpp:629
CelBlitSafe
void CelBlitSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth)
Blit CEL sprite to the given buffer, checks for drawing outside the buffer.
Definition: engine.cpp:205
PlayInGameMovie
void PlayInGameMovie(char *pszMovie)
Fade to black and play a video.
Definition: engine.cpp:1259
CelClippedDrawLight
void CelClippedDrawLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth)
Same as CelDrawLight but with the option to skip parts of the top and bottom of the sprite.
Definition: engine.cpp:129