Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
716 | lvd | 1 | #include "std.h" |
2 | |||
3 | #include "emul.h" |
||
4 | #include "vars.h" |
||
5 | #include "draw.h" |
||
6 | #include "dxr_atmf.h" |
||
7 | #include "dxr_atm2.h" |
||
8 | |||
9 | const int atmh0_ofs = 0; |
||
10 | const int atmh1_ofs = 0x2000; |
||
11 | const int atmh2_ofs = -4*int(PAGE); |
||
12 | const int atmh3_ofs = -4*int(PAGE)+0x2000; |
||
13 | |||
14 | |||
15 | void line_atm2_8(unsigned char *dst, unsigned char *src, unsigned *tab0, int src_offset) |
||
16 | { |
||
17 | for (unsigned x = 0; x < 640; x += 0x40) { |
||
18 | src_offset &= 0x1FFF; |
||
19 | unsigned s = *(unsigned*)(src+atmh0_ofs+src_offset); |
||
20 | unsigned t = *(unsigned*)(src+atmh1_ofs+src_offset); |
||
21 | unsigned as = *(unsigned*)(src+atmh2_ofs+src_offset); |
||
22 | unsigned at = *(unsigned*)(src+atmh3_ofs+src_offset); |
||
23 | unsigned *tab = tab0 + ((as << 4) & 0xFF0); |
||
24 | *(unsigned*)(dst+x+0x00) = tab[((s >> 4) & 0xF)]; |
||
25 | *(unsigned*)(dst+x+0x04) = tab[((s >> 0) & 0xF)]; |
||
26 | tab = tab0 + ((at << 4) & 0xFF0); |
||
27 | *(unsigned*)(dst+x+0x08) = tab[((t >> 4) & 0xF)]; |
||
28 | *(unsigned*)(dst+x+0x0C) = tab[((t >> 0) & 0xF)]; |
||
29 | tab = tab0 + ((as >> 4) & 0xFF0); |
||
30 | *(unsigned*)(dst+x+0x10) = tab[((s >> 12) & 0xF)]; |
||
31 | *(unsigned*)(dst+x+0x14) = tab[((s >> 8) & 0xF)]; |
||
32 | tab = tab0 + ((at >> 4) & 0xFF0); |
||
33 | *(unsigned*)(dst+x+0x18) = tab[((t >> 12) & 0xF)]; |
||
34 | *(unsigned*)(dst+x+0x1C) = tab[((t >> 8) & 0xF)]; |
||
35 | tab = tab0 + ((as >> 12) & 0xFF0); |
||
36 | *(unsigned*)(dst+x+0x20) = tab[((s >> 20) & 0xF)]; |
||
37 | *(unsigned*)(dst+x+0x24) = tab[((s >> 16) & 0xF)]; |
||
38 | tab = tab0 + ((at >> 12) & 0xFF0); |
||
39 | *(unsigned*)(dst+x+0x28) = tab[((t >> 20) & 0xF)]; |
||
40 | *(unsigned*)(dst+x+0x2C) = tab[((t >> 16) & 0xF)]; |
||
41 | tab = tab0 + ((as >> 20) & 0xFF0); |
||
42 | *(unsigned*)(dst+x+0x30) = tab[((s >> 28) & 0xF)]; |
||
43 | *(unsigned*)(dst+x+0x34) = tab[((s >> 24) & 0xF)]; |
||
44 | tab = tab0 + ((at >> 20) & 0xFF0); |
||
45 | *(unsigned*)(dst+x+0x38) = tab[((t >> 28) & 0xF)]; |
||
46 | *(unsigned*)(dst+x+0x3C) = tab[((t >> 24) & 0xF)]; |
||
47 | src_offset+=4; |
||
48 | } |
||
49 | } |
||
50 | |||
51 | |||
52 | void line_atm2_16(unsigned char *dst, unsigned char *src, unsigned *tab0, int src_offset) |
||
53 | { |
||
54 | for (unsigned x = 0; x < 640*2; x += 0x80) { |
||
55 | src_offset &= 0x1FFF; |
||
56 | unsigned s = *(unsigned*)(src+atmh0_ofs+src_offset); |
||
57 | unsigned t = *(unsigned*)(src+atmh1_ofs+src_offset); |
||
58 | unsigned as = *(unsigned*)(src+atmh2_ofs+src_offset); |
||
59 | unsigned at = *(unsigned*)(src+atmh3_ofs+src_offset); |
||
60 | unsigned *tab = tab0 + ((as << 2) & 0x3FC); |
||
61 | *(unsigned*)(dst+x+0x00) = tab[((s >> 6) & 3)]; |
||
62 | *(unsigned*)(dst+x+0x04) = tab[((s >> 4) & 3)]; |
||
63 | *(unsigned*)(dst+x+0x08) = tab[((s >> 2) & 3)]; |
||
64 | *(unsigned*)(dst+x+0x0C) = tab[((s >> 0) & 3)]; |
||
65 | tab = tab0 + ((at << 2) & 0x3FC); |
||
66 | *(unsigned*)(dst+x+0x10) = tab[((t >> 6) & 3)]; |
||
67 | *(unsigned*)(dst+x+0x14) = tab[((t >> 4) & 3)]; |
||
68 | *(unsigned*)(dst+x+0x18) = tab[((t >> 2) & 3)]; |
||
69 | *(unsigned*)(dst+x+0x1C) = tab[((t >> 0) & 3)]; |
||
70 | tab = tab0 + ((as >> 6) & 0x3FC); |
||
71 | *(unsigned*)(dst+x+0x20) = tab[((s >>14) & 3)]; |
||
72 | *(unsigned*)(dst+x+0x24) = tab[((s >>12) & 3)]; |
||
73 | *(unsigned*)(dst+x+0x28) = tab[((s >>10) & 3)]; |
||
74 | *(unsigned*)(dst+x+0x2C) = tab[((s >> 8) & 3)]; |
||
75 | tab = tab0 + ((at >> 6) & 0x3FC); |
||
76 | *(unsigned*)(dst+x+0x30) = tab[((t >>14) & 3)]; |
||
77 | *(unsigned*)(dst+x+0x34) = tab[((t >>12) & 3)]; |
||
78 | *(unsigned*)(dst+x+0x38) = tab[((t >>10) & 3)]; |
||
79 | *(unsigned*)(dst+x+0x3C) = tab[((t >> 8) & 3)]; |
||
80 | tab = tab0 + ((as >> 14) & 0x3FC); |
||
81 | *(unsigned*)(dst+x+0x40) = tab[((s >>22) & 3)]; |
||
82 | *(unsigned*)(dst+x+0x44) = tab[((s >>20) & 3)]; |
||
83 | *(unsigned*)(dst+x+0x48) = tab[((s >>18) & 3)]; |
||
84 | *(unsigned*)(dst+x+0x4C) = tab[((s >>16) & 3)]; |
||
85 | tab = tab0 + ((at >> 14) & 0x3FC); |
||
86 | *(unsigned*)(dst+x+0x50) = tab[((t >>22) & 3)]; |
||
87 | *(unsigned*)(dst+x+0x54) = tab[((t >>20) & 3)]; |
||
88 | *(unsigned*)(dst+x+0x58) = tab[((t >>18) & 3)]; |
||
89 | *(unsigned*)(dst+x+0x5C) = tab[((t >>16) & 3)]; |
||
90 | tab = tab0 + ((as >> 22) & 0x3FC); |
||
91 | *(unsigned*)(dst+x+0x60) = tab[((s >>30) & 3)]; |
||
92 | *(unsigned*)(dst+x+0x64) = tab[((s >>28) & 3)]; |
||
93 | *(unsigned*)(dst+x+0x68) = tab[((s >>26) & 3)]; |
||
94 | *(unsigned*)(dst+x+0x6C) = tab[((s >>24) & 3)]; |
||
95 | tab = tab0 + ((at >> 22) & 0x3FC); |
||
96 | *(unsigned*)(dst+x+0x70) = tab[((t >>30) & 3)]; |
||
97 | *(unsigned*)(dst+x+0x74) = tab[((t >>28) & 3)]; |
||
98 | *(unsigned*)(dst+x+0x78) = tab[((t >>26) & 3)]; |
||
99 | *(unsigned*)(dst+x+0x7C) = tab[((t >>24) & 3)]; |
||
100 | src_offset+=4; |
||
101 | } |
||
102 | } |
||
103 | |||
104 | |||
105 | |||
106 | void line_atm2_32(unsigned char *dst, unsigned char *src, unsigned *tab0, int src_offset) |
||
107 | { |
||
108 | unsigned *tab; unsigned c; |
||
109 | for (unsigned x = 0; x < 640*4; x += 0x40) { |
||
110 | src_offset &= 0x1FFF; |
||
111 | |||
112 | tab = tab0 + src[atmh2_ofs+src_offset]; |
||
113 | c = src[atmh0_ofs+src_offset]; |
||
114 | *(unsigned*)(dst+x+0x00) = tab[((c << 1) & 0x100)]; |
||
115 | *(unsigned*)(dst+x+0x04) = tab[((c << 2) & 0x100)]; |
||
116 | *(unsigned*)(dst+x+0x08) = tab[((c << 3) & 0x100)]; |
||
117 | *(unsigned*)(dst+x+0x0C) = tab[((c << 4) & 0x100)]; |
||
118 | *(unsigned*)(dst+x+0x10) = tab[((c << 5) & 0x100)]; |
||
119 | *(unsigned*)(dst+x+0x14) = tab[((c << 6) & 0x100)]; |
||
120 | *(unsigned*)(dst+x+0x18) = tab[((c << 7) & 0x100)]; |
||
121 | *(unsigned*)(dst+x+0x1C) = tab[((c << 8) & 0x100)]; |
||
122 | |||
123 | tab = tab0 + src[atmh3_ofs+src_offset]; |
||
124 | c = src[atmh1_ofs+src_offset]; |
||
125 | *(unsigned*)(dst+x+0x20) = tab[((c << 1) & 0x100)]; |
||
126 | *(unsigned*)(dst+x+0x24) = tab[((c << 2) & 0x100)]; |
||
127 | *(unsigned*)(dst+x+0x28) = tab[((c << 3) & 0x100)]; |
||
128 | *(unsigned*)(dst+x+0x2C) = tab[((c << 4) & 0x100)]; |
||
129 | *(unsigned*)(dst+x+0x30) = tab[((c << 5) & 0x100)]; |
||
130 | *(unsigned*)(dst+x+0x34) = tab[((c << 6) & 0x100)]; |
||
131 | *(unsigned*)(dst+x+0x38) = tab[((c << 7) & 0x100)]; |
||
132 | *(unsigned*)(dst+x+0x3C) = tab[((c << 8) & 0x100)]; |
||
133 | |||
134 | ++src_offset; |
||
135 | } |
||
136 | } |
||
137 | |||
138 | // Hardware Multicolor |
||
139 | void rend_atm2(unsigned char *dst, unsigned pitch, int y, int Offset) |
||
140 | { |
||
141 | unsigned char *dst2 = dst + (temp.ox-640)*temp.obpp/16; |
||
142 | if (temp.scy > 200) |
||
143 | dst2 += (temp.scy-200)/2*pitch * ((temp.oy > temp.scy)?2:1); |
||
144 | |||
145 | if (conf.fast_sl) { |
||
146 | dst2 += y*pitch; |
||
147 | switch (temp.obpp) |
||
148 | { |
||
149 | case 8: |
||
150 | line_atm2_8 (dst2, temp.base, t.zctab8 [0], Offset); |
||
151 | break; |
||
152 | case 16: |
||
153 | line_atm2_16(dst2, temp.base, t.zctab16[0], Offset); |
||
154 | break; |
||
155 | case 32: |
||
156 | line_atm2_32(dst2, temp.base, t.zctab32[0], Offset); |
||
157 | break; |
||
158 | } |
||
159 | } else { |
||
160 | dst2 += 2*y*pitch; |
||
161 | switch (temp.obpp) |
||
162 | { |
||
163 | case 8: |
||
164 | line_atm2_8 (dst2, temp.base, t.zctab8 [0], Offset); |
||
165 | dst2 += pitch; |
||
166 | line_atm2_8 (dst2, temp.base, t.zctab8 [1], Offset); |
||
167 | break; |
||
168 | case 16: |
||
169 | line_atm2_16(dst2, temp.base, t.zctab16[0], Offset); |
||
170 | dst2 += pitch; |
||
171 | line_atm2_16(dst2, temp.base, t.zctab16[1], Offset); |
||
172 | break; |
||
173 | case 32: |
||
174 | line_atm2_32(dst2, temp.base, t.zctab32[0], Offset); |
||
175 | dst2 += pitch; |
||
176 | line_atm2_32(dst2, temp.base, t.zctab32[1], Offset); |
||
177 | break; |
||
178 | } |
||
179 | } |
||
180 | } |