Subversion Repositories pentevo

Rev

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_atm6.h"
8
#include "fontatm2.h"
9
/*
10
const int text0_ofs = 0x01C0;
11
const int text1_ofs = 0x21C0;
12
const int text2_ofs = -4*PAGE+0x01C1;
13
const int text3_ofs = -4*PAGE+0x21C0;
14
*/
15
 
16
const int text0_ofs = 0x0;
17
const int text1_ofs = 0x2000;
18
const int text2_ofs = -4*int(PAGE)+1;
19
const int text3_ofs = -4*int(PAGE)+0x2000;
20
 
21
 
22
void line_atm6_8(unsigned char *dst, unsigned char *src, unsigned *tab0, unsigned char *font, int src_offset)
23
{
24
    for (unsigned x = 0; x < 640; x += 0x40) {
25
        src_offset &= 0x1FFF;
26
        unsigned p0 = *(unsigned*)(src + src_offset + text0_ofs),
27
                 p1 = *(unsigned*)(src + src_offset + text1_ofs),
28
                 a0 = *(unsigned*)(src + src_offset + text2_ofs),
29
                 a1 = *(unsigned*)(src + src_offset + text3_ofs);
30
        unsigned c, *tab;
31
        tab = tab0 + ((a1 << 4) & 0xFF0), c = font[p0 & 0xFF];
32
        *(unsigned*)(dst+x+0x00) = tab[((c >> 4)  & 0xF)];
33
        *(unsigned*)(dst+x+0x04) = tab[c & 0xF];
34
        tab = tab0 + ((a0 << 4) & 0xFF0); c = font[p1 & 0xFF];
35
        *(unsigned*)(dst+x+0x08) = tab[((c >> 4)  & 0xF)];
36
        *(unsigned*)(dst+x+0x0C) = tab[c & 0xF];
37
        tab = tab0 + ((a1 >> 4) & 0xFF0); c = font[(p0 >> 8) & 0xFF];
38
        *(unsigned*)(dst+x+0x10) = tab[((c >> 4) & 0xF)];
39
        *(unsigned*)(dst+x+0x14) = tab[c & 0xF];
40
        tab = tab0 + ((a0 >> 4) & 0xFF0); c = font[(p1 >> 8) & 0xFF];
41
        *(unsigned*)(dst+x+0x18) = tab[((c >> 4) & 0xF)];
42
        *(unsigned*)(dst+x+0x1C) = tab[c & 0xF];
43
        tab = tab0 + ((a1 >> 12) & 0xFF0); c = font[(p0 >> 16) & 0xFF];
44
        *(unsigned*)(dst+x+0x20) = tab[((c >> 4) & 0xF)];
45
        *(unsigned*)(dst+x+0x24) = tab[c & 0xF];
46
        tab = tab0 + ((a0 >> 12) & 0xFF0); c = font[(p1 >> 16) & 0xFF];
47
        *(unsigned*)(dst+x+0x28) = tab[((c >> 4) & 0xF)];
48
        *(unsigned*)(dst+x+0x2C) = tab[c & 0xF];
49
        tab = tab0 + ((a1 >> 20) & 0xFF0); c = font[p0 >> 24];
50
        *(unsigned*)(dst+x+0x30) = tab[((c >> 4) & 0xF)];
51
        *(unsigned*)(dst+x+0x34) = tab[c & 0xF];
52
        tab = tab0 + ((a0 >> 20) & 0xFF0); c = font[p1 >> 24];
53
        *(unsigned*)(dst+x+0x38) = tab[((c >> 4) & 0xF)];
54
        *(unsigned*)(dst+x+0x3C) = tab[c & 0xF];
55
        src_offset += 4;
56
    }
57
}
58
 
59
void line_atm6_16(unsigned char *dst, unsigned char *src, unsigned *tab0, unsigned char *font, int src_offset)
60
{
61
    for (unsigned x = 0; x < 640*2; x += 0x80) {
62
        src_offset &= 0x1FFF;
63
        unsigned p0 = *(unsigned*)(src + src_offset + text0_ofs),
64
                 p1 = *(unsigned*)(src + src_offset + text1_ofs),
65
                 a0 = *(unsigned*)(src + src_offset + text2_ofs),
66
                 a1 = *(unsigned*)(src + src_offset + text3_ofs);
67
        unsigned c, *tab;
68
        tab = tab0 + ((a1 << 2) & 0x3FC), c = font[p0 & 0xFF];
69
        *(unsigned*)(dst+x+0x00) = tab[((c >> 6)  & 0x03)];
70
        *(unsigned*)(dst+x+0x04) = tab[((c >> 4)  & 0x03)];
71
        *(unsigned*)(dst+x+0x08) = tab[((c >> 2)  & 0x03)];
72
        *(unsigned*)(dst+x+0x0C) = tab[((c >> 0)  & 0x03)];
73
        tab = tab0 + ((a0 << 2) & 0x3FC); c = font[p1 & 0xFF];
74
        *(unsigned*)(dst+x+0x10) = tab[((c >> 6)  & 0x03)];
75
        *(unsigned*)(dst+x+0x14) = tab[((c >> 4)  & 0x03)];
76
        *(unsigned*)(dst+x+0x18) = tab[((c >> 2)  & 0x03)];
77
        *(unsigned*)(dst+x+0x1C) = tab[((c >> 0)  & 0x03)];
78
        tab = tab0 + ((a1 >> 6) & 0x3FC); c = font[(p0 >> 8) & 0xFF];
79
        *(unsigned*)(dst+x+0x20) = tab[((c >> 6)  & 0x03)];
80
        *(unsigned*)(dst+x+0x24) = tab[((c >> 4)  & 0x03)];
81
        *(unsigned*)(dst+x+0x28) = tab[((c >> 2)  & 0x03)];
82
        *(unsigned*)(dst+x+0x2C) = tab[((c >> 0)  & 0x03)];
83
        tab = tab0 + ((a0 >> 6) & 0x3FC); c = font[(p1 >> 8) & 0xFF];
84
        *(unsigned*)(dst+x+0x30) = tab[((c >> 6)  & 0x03)];
85
        *(unsigned*)(dst+x+0x34) = tab[((c >> 4)  & 0x03)];
86
        *(unsigned*)(dst+x+0x38) = tab[((c >> 2)  & 0x03)];
87
        *(unsigned*)(dst+x+0x3C) = tab[((c >> 0)  & 0x03)];
88
        tab = tab0 + ((a1 >> 14) & 0x3FC); c = font[(p0 >> 16) & 0xFF];
89
        *(unsigned*)(dst+x+0x40) = tab[((c >> 6)  & 0x03)];
90
        *(unsigned*)(dst+x+0x44) = tab[((c >> 4)  & 0x03)];
91
        *(unsigned*)(dst+x+0x48) = tab[((c >> 2)  & 0x03)];
92
        *(unsigned*)(dst+x+0x4C) = tab[((c >> 0)  & 0x03)];
93
        tab = tab0 + ((a0 >> 14) & 0x3FC); c = font[(p1 >> 16) & 0xFF];
94
        *(unsigned*)(dst+x+0x50) = tab[((c >> 6)  & 0x03)];
95
        *(unsigned*)(dst+x+0x54) = tab[((c >> 4)  & 0x03)];
96
        *(unsigned*)(dst+x+0x58) = tab[((c >> 2)  & 0x03)];
97
        *(unsigned*)(dst+x+0x5C) = tab[((c >> 0)  & 0x03)];
98
        tab = tab0 + ((a1 >> 22) & 0x3FC); c = font[p0 >> 24];
99
        *(unsigned*)(dst+x+0x60) = tab[((c >> 6)  & 0x03)];
100
        *(unsigned*)(dst+x+0x64) = tab[((c >> 4)  & 0x03)];
101
        *(unsigned*)(dst+x+0x68) = tab[((c >> 2)  & 0x03)];
102
        *(unsigned*)(dst+x+0x6C) = tab[((c >> 0)  & 0x03)];
103
        tab = tab0 + ((a0 >> 22) & 0x3FC); c = font[p1 >> 24];
104
        *(unsigned*)(dst+x+0x70) = tab[((c >> 6)  & 0x03)];
105
        *(unsigned*)(dst+x+0x74) = tab[((c >> 4)  & 0x03)];
106
        *(unsigned*)(dst+x+0x78) = tab[((c >> 2)  & 0x03)];
107
        *(unsigned*)(dst+x+0x7C) = tab[((c >> 0)  & 0x03)];
108
        src_offset += 4;
109
    }
110
}
111
 
112
void line_atm6_32(unsigned char *dst, unsigned char *src, unsigned *tab0, unsigned char *font, int src_offset)
113
{
114
   for (unsigned x = 0; x < 640*4; x += 0x80) {
115
      unsigned c, *tab;
116
      src_offset &= 0x1FFF;
117
      tab = tab0 + src[src_offset + text3_ofs];
118
      c = font[src[src_offset + text0_ofs]];
119
      *(unsigned*)(dst+x+0x00) = tab[((c << 1) & 0x100)];
120
      *(unsigned*)(dst+x+0x04) = tab[((c << 2) & 0x100)];
121
      *(unsigned*)(dst+x+0x08) = tab[((c << 3) & 0x100)];
122
      *(unsigned*)(dst+x+0x0C) = tab[((c << 4) & 0x100)];
123
      *(unsigned*)(dst+x+0x10) = tab[((c << 5) & 0x100)];
124
      *(unsigned*)(dst+x+0x14) = tab[((c << 6) & 0x100)];
125
      *(unsigned*)(dst+x+0x18) = tab[((c << 7) & 0x100)];
126
      *(unsigned*)(dst+x+0x1C) = tab[((c << 8) & 0x100)];
127
 
128
      tab = tab0 + src[src_offset + text2_ofs];
129
      c = font[src[src_offset + text1_ofs]];
130
      *(unsigned*)(dst+x+0x20) = tab[((c << 1) & 0x100)];
131
      *(unsigned*)(dst+x+0x24) = tab[((c << 2) & 0x100)];
132
      *(unsigned*)(dst+x+0x28) = tab[((c << 3) & 0x100)];
133
      *(unsigned*)(dst+x+0x2C) = tab[((c << 4) & 0x100)];
134
      *(unsigned*)(dst+x+0x30) = tab[((c << 5) & 0x100)];
135
      *(unsigned*)(dst+x+0x34) = tab[((c << 6) & 0x100)];
136
      *(unsigned*)(dst+x+0x38) = tab[((c << 7) & 0x100)];
137
      *(unsigned*)(dst+x+0x3C) = tab[((c << 8) & 0x100)];
138
 
139
      tab = tab0 + src[src_offset + text3_ofs+1];
140
      c = font[src[src_offset + text0_ofs+1]];
141
      *(unsigned*)(dst+x+0x40) = tab[((c << 1) & 0x100)];
142
      *(unsigned*)(dst+x+0x44) = tab[((c << 2) & 0x100)];
143
      *(unsigned*)(dst+x+0x48) = tab[((c << 3) & 0x100)];
144
      *(unsigned*)(dst+x+0x4C) = tab[((c << 4) & 0x100)];
145
      *(unsigned*)(dst+x+0x50) = tab[((c << 5) & 0x100)];
146
      *(unsigned*)(dst+x+0x54) = tab[((c << 6) & 0x100)];
147
      *(unsigned*)(dst+x+0x58) = tab[((c << 7) & 0x100)];
148
      *(unsigned*)(dst+x+0x5C) = tab[((c << 8) & 0x100)];
149
 
150
      tab = tab0 + src[src_offset + text2_ofs+1];
151
      c = font[src[src_offset + text1_ofs+1]];
152
      *(unsigned*)(dst+x+0x60) = tab[((c << 1) & 0x100)];
153
      *(unsigned*)(dst+x+0x64) = tab[((c << 2) & 0x100)];
154
      *(unsigned*)(dst+x+0x68) = tab[((c << 3) & 0x100)];
155
      *(unsigned*)(dst+x+0x6C) = tab[((c << 4) & 0x100)];
156
      *(unsigned*)(dst+x+0x70) = tab[((c << 5) & 0x100)];
157
      *(unsigned*)(dst+x+0x74) = tab[((c << 6) & 0x100)];
158
      *(unsigned*)(dst+x+0x78) = tab[((c << 7) & 0x100)];
159
      *(unsigned*)(dst+x+0x7C) = tab[((c << 8) & 0x100)];
160
 
161
      src_offset += 2;
162
   }
163
}
164
 
165
// Textmode
166
void rend_atm6(unsigned char *dst, unsigned pitch, int y, int Offset)
167
{
168
   unsigned char *dst2 = dst + (temp.ox-640)*temp.obpp/16;
169
   if (temp.scy > 200)
170
       dst2 += (temp.scy-200)/2*pitch * ((temp.oy > temp.scy)?2:1);
171
 
172
    int v = y%8;
173
    if (conf.fast_sl) {
174
        dst2 += y*pitch;
175
        switch(temp.obpp)
176
        {
177
        case 8:
178
            line_atm6_8 (dst2, temp.base, t.zctab8 [0], fontatm2 + v*0x100, Offset);
179
            break;
180
        case 16:
181
            line_atm6_16(dst2, temp.base, t.zctab16[0], fontatm2 + v*0x100, Offset);
182
            break;
183
        case 32:
184
            line_atm6_32(dst2, temp.base, t.zctab32[0], fontatm2 + v*0x100, Offset);
185
            break;
186
        }
187
    } else {
188
        dst2 += 2*y*pitch;
189
        switch(temp.obpp)
190
        {
191
        case 8:
192
            line_atm6_8 (dst2, temp.base, t.zctab8 [0], fontatm2 + v*0x100, Offset);
193
            dst2 += pitch;
194
            line_atm6_8 (dst2, temp.base, t.zctab8 [1], fontatm2 + v*0x100, Offset);
195
            break;
196
        case 16:
197
            line_atm6_16(dst2, temp.base, t.zctab16[0], fontatm2 + v*0x100, Offset);
198
            dst2 += pitch;
199
            line_atm6_16(dst2, temp.base, t.zctab16[1], fontatm2 + v*0x100, Offset);
200
            break;
201
        case 32:
202
            line_atm6_32(dst2, temp.base, t.zctab32[0], fontatm2 + v*0x100, Offset);
203
            dst2 += pitch;
204
            line_atm6_32(dst2, temp.base, t.zctab32[1], fontatm2 + v*0x100, Offset);
205
            break;
206
        }
207
    }
208
}