forked from bibendovsky/bstone
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMARKHACK.C
More file actions
107 lines (73 loc) · 1.83 KB
/
MARKHACK.C
File metadata and controls
107 lines (73 loc) · 1.83 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
//
// Former MARKHACK.ASM
//
#include "3d_def.h"
#include "id_vl.h"
extern int viewwidth;
extern int viewheight;
extern unsigned bufferofs;
extern unsigned ylookup[MAXSCANLINES];
extern unsigned centery;
extern unsigned bufx;
extern unsigned postheight;
byte far* shadingtable;
typedef enum {
DRAW_DEFAULT,
DRAW_LIGHTED,
} DrawMode;
static void generic_draw_post(DrawMode draw_mode)
{
long step;
long cur_step;
unsigned i;
unsigned n;
unsigned fraction;
unsigned screen_column;
unsigned char pixel;
unsigned char pixel_index;
byte far* screen;
if (postheight == 0)
return;
cur_step = (32L * 65536L) / postheight;
step = cur_step;
cur_step >>= 1;
screen = MK_FP(0xA000, 0);
fraction = SCREENBWIDE;
screen_column = bufferofs + bufx + ylookup[centery] - SCREENBWIDE;
n = postheight;
if (postheight > centery)
n = centery;
for (i = 0; i < n; ++i) {
// top half
pixel_index = ((byte far*)postsource)[31 - (cur_step >> 16)];
if (draw_mode == DRAW_LIGHTED)
pixel = shadingtable[pixel_index];
else
pixel = pixel_index;
screen[screen_column] = pixel;
// bottom half
pixel_index = ((byte far*)postsource)[32 + (cur_step >> 16)];
if (draw_mode == DRAW_LIGHTED)
pixel = shadingtable[pixel_index];
else
pixel = pixel_index;
screen[screen_column + fraction] = pixel;
screen_column -= SCREENBWIDE;
fraction += 2 * SCREENBWIDE;
cur_step += step;
}
}
//
// Draws an unmasked post centered in the viewport
//
void DrawPost()
{
generic_draw_post(DRAW_DEFAULT);
}
//
// Draws an unmasked light sourced post centered in the viewport
//
void DrawLSPost()
{
generic_draw_post(DRAW_LIGHTED);
}