Browse Source

Move assembly to _asm.cpp (#388)

pull/25/head
galaxyhaxz 8 years ago committed by GitHub
parent
commit
0f184f2b71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      Makefile
  2. 4
      MakefileVC
  3. 135
      Source/_asm.cpp
  4. 153
      Source/render.cpp

2
Makefile

@ -25,7 +25,7 @@ debug: CXXFLAGS += -D_DEBUG
debug: CPPFLAGS += -D_DEBUG
debug: devilution.exe
DIABLO_SRC=$(wildcard Source/*.cpp)
DIABLO_SRC=$(sort $(filter-out Source/_asm.cpp, $(wildcard Source/*.cpp)))
OBJS=$(DIABLO_SRC:.cpp=.o)
PKWARE_SRC=$(wildcard 3rdParty/PKWare/*.cpp)

4
MakefileVC

@ -52,8 +52,8 @@ all: Diablo.exe
debug: CFLAGS += /D "_DEBUG"
debug: Diablo.exe
# fix compilation order to match the VC6 workspace files
DIABLO_SRC=$(sort $(filter-out Source/render.cpp, $(wildcard Source/*.cpp)))
# fix compilation order to match the VC6 workspace files and exclude local assembly functions
DIABLO_SRC=$(sort $(filter-out Source/_asm.cpp Source/render.cpp, $(wildcard Source/*.cpp)))
DIABLO_SRC += Source/render.cpp
OBJS=$(DIABLO_SRC:.cpp=.obj)

135
Source/_asm.cpp

@ -0,0 +1,135 @@
static inline void asm_cel_light_edge(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src);
static inline void asm_cel_light_square(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src);
static inline void asm_trans_light_cel_0_2(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src);
static inline void asm_trans_light_edge_0_2(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src);
static inline void asm_trans_light_square_0_2(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src);
static inline void asm_trans_light_cel_1_3(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src);
static inline void asm_trans_light_edge_1_3(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src);
static inline void asm_trans_light_square_1_3(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src);
static inline void asm_trans_light_mask(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src, unsigned int mask);
static inline void asm_cel_light_edge(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src)
{
unsigned char l = w >> 1;
if ( w & 1 )
{
dst[0] = tbl[src[0]];
src++;
dst++;
}
if ( l & 1 )
{
dst[0] = tbl[src[0]];
dst[1] = tbl[src[1]];
src += 2;
dst += 2;
}
asm_cel_light_square(l >> 1, tbl, dst, src);
}
static inline void asm_cel_light_square(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src)
{
for ( ; w; --w )
{
dst[0] = tbl[src[0]];
dst[1] = tbl[src[1]];
dst[2] = tbl[src[2]];
dst[3] = tbl[src[3]];
src += 4;
dst += 4;
}
}
static inline void asm_trans_light_cel_0_2(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src)
{
if ( !(w & 1) )
{
asm_trans_light_edge_1_3(w >> 1, tbl, dst, src);
}
else
{
src++;
dst++;
asm_trans_light_edge_0_2(w >> 1, tbl, dst, src);
}
}
static inline void asm_trans_light_edge_0_2(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src)
{
unsigned char l = w >> 1;
if ( w & 1 )
{
dst[0] = tbl[src[0]];
src += 2;
dst += 2;
}
if ( l )
{
asm_trans_light_square_0_2(l, tbl, dst, src);
}
}
static inline void asm_trans_light_square_0_2(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src)
{
for ( ; w; --w )
{
dst[0] = tbl[src[0]];
dst[2] = tbl[src[2]];
src += 4;
dst += 4;
}
}
static inline void asm_trans_light_cel_1_3(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src)
{
if ( !(w & 1) )
{
asm_trans_light_edge_0_2(w >> 1, tbl, dst, src);
}
else
{
dst[0] = tbl[src[0]];
src++;
dst++;
asm_trans_light_edge_1_3(w >> 1, tbl, dst, src);
}
}
static inline void asm_trans_light_edge_1_3(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src)
{
unsigned char l = w >> 1;
if ( w & 1 )
{
dst[1] = tbl[src[1]];
src += 2;
dst += 2;
}
if ( l )
{
asm_trans_light_square_1_3(l, tbl, dst, src);
}
}
static inline void asm_trans_light_square_1_3(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src)
{
for ( ; w; --w )
{
dst[1] = tbl[src[1]];
dst[3] = tbl[src[3]];
src += 4;
dst += 4;
}
}
static inline void asm_trans_light_mask(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src, unsigned int mask)
{
for ( ; w; --w, src++, dst++, mask *= 2 )
{
if ( mask & 0x80000000 )
dst[0] = tbl[src[0]];
}
}

153
Source/render.cpp

@ -1,6 +1,7 @@
//HEADER_GOES_HERE
#include "../types.h"
#include "_asm.cpp"
int WorldBoolFlag = 0;
unsigned int gdwCurrentMask = 0;
@ -80,142 +81,6 @@ int WorldTbl17_2[17] = { 0, 32, 60, 88, 112, 136, 156, 176, 192, 208, 220, 232,
|/
*/
inline void asm_cel_light_edge(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src);
inline void asm_cel_light_square(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src);
inline void asm_cel_light_mask(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src, unsigned int mask);
inline void asm_trans_light_cel_0_2(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src);
inline void asm_trans_light_edge_0_2(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src);
inline void asm_trans_light_square_0_2(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src);
inline void asm_trans_light_cel_1_3(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src);
inline void asm_trans_light_edge_1_3(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src);
inline void asm_trans_light_square_1_3(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src);
inline void asm_cel_light_edge(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src)
{
unsigned char l = w >> 1;
if ( w & 1 )
{
dst[0] = tbl[src[0]];
src++;
dst++;
}
if ( l & 1 )
{
dst[0] = tbl[src[0]];
dst[1] = tbl[src[1]];
src += 2;
dst += 2;
}
asm_cel_light_square(l >> 1, tbl, dst, src);
}
inline void asm_cel_light_square(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src)
{
for ( ; w; --w )
{
dst[0] = tbl[src[0]];
dst[1] = tbl[src[1]];
dst[2] = tbl[src[2]];
dst[3] = tbl[src[3]];
src += 4;
dst += 4;
}
}
inline void asm_cel_light_mask(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src, unsigned int mask)
{
for ( ; w; --w, src++, dst++, mask *= 2 )
{
if ( mask & 0x80000000 )
dst[0] = tbl[src[0]];
}
}
inline void asm_trans_light_cel_0_2(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src)
{
if ( !(w & 1) )
{
asm_trans_light_edge_1_3(w >> 1, tbl, dst, src);
}
else
{
src++;
dst++;
asm_trans_light_edge_0_2(w >> 1, tbl, dst, src);
}
}
inline void asm_trans_light_edge_0_2(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src)
{
unsigned char l = w >> 1;
if ( w & 1 )
{
dst[0] = tbl[src[0]];
src += 2;
dst += 2;
}
if ( l )
{
asm_trans_light_square_0_2(l, tbl, dst, src);
}
}
inline void asm_trans_light_square_0_2(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src)
{
for ( ; w; --w )
{
dst[0] = tbl[src[0]];
dst[2] = tbl[src[2]];
src += 4;
dst += 4;
}
}
inline void asm_trans_light_cel_1_3(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src)
{
if ( !(w & 1) )
{
asm_trans_light_edge_0_2(w >> 1, tbl, dst, src);
}
else
{
dst[0] = tbl[src[0]];
src++;
dst++;
asm_trans_light_edge_1_3(w >> 1, tbl, dst, src);
}
}
inline void asm_trans_light_edge_1_3(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src)
{
unsigned char l = w >> 1;
if ( w & 1 )
{
dst[1] = tbl[src[1]];
src += 2;
dst += 2;
}
if ( l )
{
asm_trans_light_square_1_3(l, tbl, dst, src);
}
}
inline void asm_trans_light_square_1_3(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src)
{
for ( ; w; --w )
{
dst[1] = tbl[src[1]];
dst[3] = tbl[src[3]];
src += 4;
dst += 4;
}
}
void __fastcall drawTopArchesUpperScreen(unsigned char *pbDst)
{
unsigned char *dst; // edi MAPDST
@ -1820,7 +1685,7 @@ LABEL_129:
{
if ( dst < gpBufEnd )
break;
asm_cel_light_mask(32, tbl, dst, src, *gpDrawMask);
asm_trans_light_mask(32, tbl, dst, src, *gpDrawMask);
dst -= 800;
--gpDrawMask;
--xx_32;
@ -1851,7 +1716,7 @@ LABEL_129:
yy_32 -= width;
if ( dst < gpBufEnd )
return;
asm_cel_light_mask(width, tbl, dst, src, gdwCurrentMask);
asm_trans_light_mask(width, tbl, dst, src, gdwCurrentMask);
}
while ( yy_32 );
LABEL_50:
@ -1931,7 +1796,7 @@ LABEL_50:
if ( dst < gpBufEnd )
break;
src += (unsigned char)src & 2;
asm_cel_light_mask(32, tbl, dst, src, *gpDrawMask);
asm_trans_light_mask(32, tbl, dst, src, *gpDrawMask);
dst -= 800;
--gpDrawMask;
--yy_32;
@ -1957,7 +1822,7 @@ LABEL_50:
{
if ( dst < gpBufEnd )
break;
asm_cel_light_mask(32, tbl, dst, src, *gpDrawMask);
asm_trans_light_mask(32, tbl, dst, src, *gpDrawMask);
src += (unsigned char)src & 2;
dst -= 800;
--gpDrawMask;
@ -5005,7 +4870,7 @@ LABEL_252:
{
if ( dst < gpBufEnd )
{
asm_cel_light_mask(32, tbl, dst, src, *gpDrawMask);
asm_trans_light_mask(32, tbl, dst, src, *gpDrawMask);
}
else
{
@ -5034,7 +4899,7 @@ LABEL_252:
yy_32 -= width;
if ( dst < gpBufEnd )
{
asm_cel_light_mask(width, tbl, dst, src, gdwCurrentMask);
asm_trans_light_mask(width, tbl, dst, src, gdwCurrentMask);
}
else
{
@ -5167,7 +5032,7 @@ LABEL_98:
{
if ( dst < gpBufEnd )
{
asm_cel_light_mask(32, tbl, dst, src, *gpDrawMask);
asm_trans_light_mask(32, tbl, dst, src, *gpDrawMask);
}
else
{
@ -5212,7 +5077,7 @@ LABEL_117:
{
if ( dst < gpBufEnd )
{
asm_cel_light_mask(32, tbl, dst, src, *gpDrawMask);
asm_trans_light_mask(32, tbl, dst, src, *gpDrawMask);
src += (unsigned char)src & 2;
}
else

Loading…
Cancel
Save