forked from diasurgical/devilution
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_asm.cpp
More file actions
121 lines (107 loc) · 3.19 KB
/
_asm.cpp
File metadata and controls
121 lines (107 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
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 unsigned int 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 unsigned int 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]];
}
return mask;
}