-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdxr_atm0.cpp
181 lines (169 loc) · 6.05 KB
/
dxr_atm0.cpp
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#include "std.h"
#include "emul.h"
#include "vars.h"
#include "draw.h"
#include "dxr_atmf.h"
#include "dxr_atm0.h"
static const int ega0_ofs = -4*int(PAGE);
static const int ega1_ofs = 0;
static const int ega2_ofs = -4*int(PAGE)+0x2000;
static const int ega3_ofs = 0x2000;
static void line_atm0_8(unsigned char *dst, unsigned char *src, unsigned *tab, int src_offset)
{
u8 *d = (u8 *)dst;
for (unsigned x = 0; x < 320; x += 8, ++src_offset)
{
src_offset &= 0x1FFF;
d[x+0] = tab[src[ega0_ofs + src_offset]];
d[x+1] = tab[src[ega0_ofs + src_offset]] >> 16;
d[x+2] = tab[src[ega1_ofs + src_offset]];
d[x+3] = tab[src[ega1_ofs + src_offset]] >> 16;
d[x+4] = tab[src[ega2_ofs + src_offset]];
d[x+5] = tab[src[ega2_ofs + src_offset]] >> 16;
d[x+6] = tab[src[ega3_ofs + src_offset]];
d[x+7] = tab[src[ega3_ofs + src_offset]] >> 16;
}
}
static void line_atm0_8d(unsigned char *dst, unsigned char *src, unsigned *tab, int src_offset)
{
u32 *d = (u32 *)dst;
for (unsigned x = 0; x < 640/4; x += 4, ++src_offset)
{
src_offset &= 0x1FFF;
d[x+0] = tab[src[ega0_ofs + src_offset]];
d[x+1] = tab[src[ega1_ofs + src_offset]];
d[x+2] = tab[src[ega2_ofs + src_offset]];
d[x+3] = tab[src[ega3_ofs + src_offset]];
}
}
static void line_atm0_16(unsigned char *dst, unsigned char *src, unsigned *tab, int src_offset)
{
u16 *d = (u16 *)dst;
for (unsigned x = 0; x < 320; x += 8, ++src_offset)
{
src_offset &= 0x1FFF;
d[x+0] = tab[0+2*src[ega0_ofs + src_offset]];
d[x+1] = tab[1+2*src[ega0_ofs + src_offset]];
d[x+2] = tab[0+2*src[ega1_ofs + src_offset]];
d[x+3] = tab[1+2*src[ega1_ofs + src_offset]];
d[x+4] = tab[0+2*src[ega2_ofs + src_offset]];
d[x+5] = tab[1+2*src[ega2_ofs + src_offset]];
d[x+6] = tab[0+2*src[ega3_ofs + src_offset]];
d[x+7] = tab[1+2*src[ega3_ofs + src_offset]];
}
}
static void line_atm0_16d(unsigned char *dst, unsigned char *src, unsigned *tab, int src_offset)
{
u32 *d = (u32 *)dst;
for (unsigned x = 0; x < 640/2; x += 8, ++src_offset)
{
src_offset &= 0x1FFF;
d[x+0] = tab[0+2*src[ega0_ofs + src_offset]];
d[x+1] = tab[1+2*src[ega0_ofs + src_offset]];
d[x+2] = tab[0+2*src[ega1_ofs + src_offset]];
d[x+3] = tab[1+2*src[ega1_ofs + src_offset]];
d[x+4] = tab[0+2*src[ega2_ofs + src_offset]];
d[x+5] = tab[1+2*src[ega2_ofs + src_offset]];
d[x+6] = tab[0+2*src[ega3_ofs + src_offset]];
d[x+7] = tab[1+2*src[ega3_ofs + src_offset]];
}
}
static void line_atm0_32(unsigned char *dst, unsigned char *src, unsigned *tab, int src_offset)
{
u32 *d = (u32 *)dst;
for (unsigned x = 0; x < 320; x += 8, ++src_offset)
{
src_offset &= 0x1FFF;
d[x+0] = tab[0+2*src[ega0_ofs + src_offset]];
d[x+1] = tab[1+2*src[ega0_ofs + src_offset]];
d[x+2] = tab[0+2*src[ega1_ofs + src_offset]];
d[x+3] = tab[1+2*src[ega1_ofs + src_offset]];
d[x+4] = tab[0+2*src[ega2_ofs + src_offset]];
d[x+5] = tab[1+2*src[ega2_ofs + src_offset]];
d[x+6] = tab[0+2*src[ega3_ofs + src_offset]];
d[x+7] = tab[1+2*src[ega3_ofs + src_offset]];
}
}
static void line_atm0_32d(unsigned char *dst, unsigned char *src, unsigned *tab, int src_offset)
{
u32 *d = (u32 *)dst;
for (unsigned x = 0; x < 640; x += 16, ++src_offset)
{
src_offset &= 0x1FFF;
d[x+0] = d[x+1] = tab[0+2*src[ega0_ofs + src_offset]];
d[x+2] = d[x+3] = tab[1+2*src[ega0_ofs + src_offset]];
d[x+4] = d[x+5] = tab[0+2*src[ega1_ofs + src_offset]];
d[x+6] = d[x+7] = tab[1+2*src[ega1_ofs + src_offset]];
d[x+8] = d[x+9] = tab[0+2*src[ega2_ofs + src_offset]];
d[x+10] = d[x+11] = tab[1+2*src[ega2_ofs + src_offset]];
d[x+12] = d[x+13] = tab[0+2*src[ega3_ofs + src_offset]];
d[x+14] = d[x+15] = tab[1+2*src[ega3_ofs + src_offset]];
}
}
void rend_atm0_small(unsigned char *dst, unsigned pitch, int y, int Offset)
{
unsigned char *dst2 = dst + (temp.ox-320)*temp.obpp/16;
if (temp.scy > 200)
dst2 += (temp.scy-200)/2*pitch * ((temp.oy > temp.scy)?2:1);
dst2 += y*pitch;
switch(temp.obpp)
{
case 8:
line_atm0_8(dst2, temp.base, t.p4bpp8[0], Offset);
dst2 += pitch;
break;
case 16:
line_atm0_16(dst2, temp.base, t.p4bpp16[0], Offset);
dst2 += pitch;
break;
case 32:
line_atm0_32(dst2, temp.base, t.p4bpp32[0], Offset);
dst2 += pitch;
break;
}
}
// EGA 320x200, double
void rend_atm0(unsigned char *dst, unsigned pitch, int y, int Offset)
{
unsigned char *dst2 = dst + (temp.ox-640)*temp.obpp/16;
if (temp.scy > 200)
dst2 += (temp.scy-200)/2*pitch * ((temp.oy > temp.scy)?2:1);
if(conf.fast_sl)
{
dst2 += y*pitch;
switch(temp.obpp)
{
case 8:
line_atm0_8d(dst2, temp.base, t.p4bpp8[0], Offset);
break;
case 16:
line_atm0_16d(dst2, temp.base, t.p4bpp16[0], Offset);
break;
case 32:
line_atm0_32d(dst2, temp.base, t.p4bpp32[0], Offset);
break;
}
}
else
{
dst2 += 2*y*pitch;
switch(temp.obpp)
{
case 8:
line_atm0_8d(dst2, temp.base, t.p4bpp8[0], Offset);
dst2 += pitch;
line_atm0_8d(dst2, temp.base, t.p4bpp8[1], Offset);
break;
case 16:
line_atm0_16d(dst2, temp.base, t.p4bpp16[0], Offset);
dst2 += pitch;
line_atm0_16d(dst2, temp.base, t.p4bpp16[1], Offset);
break;
case 32:
line_atm0_32d(dst2, temp.base, t.p4bpp32[0], Offset);
dst2 += pitch;
line_atm0_32d(dst2, temp.base, t.p4bpp32[1], Offset);
break;
}
}
}