forked from bibendovsky/bstone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
D3_D2.C
125 lines (94 loc) · 2.43 KB
/
D3_D2.C
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
122
123
124
125
//
// Former D3_DASM2.ASM.
//
#include <dos.h>
typedef enum {
DO_CEILING,
DO_FLOORING,
DO_CEILING_AND_FLOORING,
} DrawOptions;
typedef enum {
SO_NONE,
SO_DEFAULT,
} ShadingOptions;
extern int mr_rowofs;
extern int mr_count;
extern int mr_xstep;
extern int mr_ystep;
extern int mr_xfrac;
extern int mr_yfrac;
extern int mr_dest;
extern unsigned char far* shadingtable;
unsigned char far planepics[8192]; // 4k of ceiling, 4k of floor
static void generic_map_row(
DrawOptions draw_options,
ShadingOptions shading_options)
{
unsigned i;
unsigned dest;
unsigned count;
unsigned rowofs;
unsigned long xy;
unsigned long xy_step;
unsigned long xy_frac;
unsigned pics_index;
unsigned char ceiling_index;
unsigned char flooring_index;
unsigned char far* screen;
rowofs = (unsigned)mr_rowofs;
count = (unsigned)mr_count;
xy_step = ((unsigned long)mr_ystep) << 16;
xy_step |= ((unsigned long)mr_xstep) & 0xFFFF;
xy_frac = ((unsigned long)mr_yfrac) << 16;
xy_frac |= ((unsigned long)mr_xfrac) & 0xFFFF;
dest = (unsigned)mr_dest;
screen = MK_FP(0xA000, 0x0000);
for (i = 0; i < count; ++i) {
xy = ((xy_frac >> 3) & 0x1FFF1F80) | ((xy_frac >> 25) & 0x7E);
xy_frac += xy_step;
pics_index = xy & 0xFFFF;
if (draw_options == DO_CEILING ||
draw_options == DO_CEILING_AND_FLOORING)
{
ceiling_index = planepics[pics_index + 0];
if (shading_options == SO_DEFAULT)
screen[dest] = shadingtable[ceiling_index];
else
screen[dest] = ceiling_index;
}
if (draw_options == DO_FLOORING ||
draw_options == DO_CEILING_AND_FLOORING)
{
flooring_index = planepics[pics_index + 1];
if (shading_options == SO_DEFAULT)
screen[dest + rowofs] = shadingtable[flooring_index];
else
screen[dest + rowofs] = flooring_index;
}
++dest;
}
}
void MapLSRow()
{
generic_map_row(DO_CEILING_AND_FLOORING, SO_DEFAULT);
}
void F_MapLSRow()
{
generic_map_row(DO_FLOORING, SO_DEFAULT);
}
void C_MapLSRow()
{
generic_map_row(DO_CEILING, SO_DEFAULT);
}
void MapRow()
{
generic_map_row(DO_CEILING_AND_FLOORING, SO_NONE);
}
void F_MapRow()
{
generic_map_row(DO_FLOORING, SO_NONE);
}
void C_MapRow()
{
generic_map_row(DO_CEILING, SO_NONE);
}