~ubuntu-branches/ubuntu/maverick/alevt/maverick

« back to all changes in this revision

Viewing changes to lang.c

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Schoepf
  • Date: 2002-03-17 15:09:36 UTC
  • Revision ID: james.westby@ubuntu.com-20020317150936-yglzziwcc0luz55k
Tags: upstream-1.6.0
Import upstream version 1.6.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <string.h>
 
2
#include "misc.h"
 
3
#include "vt.h"
 
4
#include "lang.h"
 
5
 
 
6
int latin1 = -1;
 
7
 
 
8
static u8 lang_char[256];
 
9
 
 
10
static u8 lang_chars[1+8+8][16] =
 
11
{
 
12
    { 0, 0x23,0x24,0x40,0x5b,0x5c,0x5d,0x5e,0x5f,0x60,0x7b,0x7c,0x7d,0x7e },
 
13
 
 
14
    // for latin-1 font
 
15
    // English (100%)
 
16
    { 0,  '�', '$', '@', '�', '�', '�', '�', '#', '�', '�', '�', '�', '�' },
 
17
    // German (100%)
 
18
    { 0,  '#', '$', '�', '�', '�', '�', '^', '_', '�', '�', '�', '�', '�' },
 
19
    // Swedish/Finnish/Hungarian (100%)
 
20
    { 0,  '#', '�', '�', '�', '�', '�', '�', '_', '�', '�', '�', '�', '�' },
 
21
    // Italian (100%)
 
22
    { 0,  '�', '$', '�', '�', '�', '�', '�', '#', '�', '�', '�', '�', '�' },
 
23
    // French (100%)
 
24
    { 0,  '�', '�', '�', '�', '�', '�', '�', '#', '�', '�', '�', '�', '�' },
 
25
    // Portuguese/Spanish (100%)
 
26
    { 0,  '�', '$', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�' },
 
27
    // Czech/Slovak (60%)
 
28
    { 0,  '#', 'u', 'c', 't', 'z', '�', '�', 'r', '�', '�', 'e', '�', 's' },
 
29
    // reserved (English mapping)
 
30
    { 0,  '�', '$', '@', '�', '�', '�', '�', '#', '�', '�', '�', '�', '�' },
 
31
 
 
32
    // for latin-2 font
 
33
    // Polish (100%)
 
34
    { 0,  '#', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�' },
 
35
    // German (100%)
 
36
    { 0,  '#', '$', '�', '�', '�', '�', '^', '_', '�', '�', '�', '�', '�' },
 
37
    // Estonian (100%)
 
38
    { 0,  '#', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�' },
 
39
    // Lettish/Lithuanian (90%)
 
40
    { 0,  '#', '$', '�', '�', '�', '�', '�', '�', '�', '�', 'u', '�', 'i' },
 
41
    // French (90%)
 
42
    { 0,  '�', 'i', 'a', '�', '�', 'u', '�', '#', 'e', '�', '�', 'u', '�' },
 
43
    // Serbian/Croation/Slovenian (100%)
 
44
    { 0,  '#', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�' },
 
45
    // Czech/Slovak (100%)
 
46
    { 0,  '#', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�' },
 
47
    // Rumanian (95%)
 
48
    { 0,  '#', '�', '�', '�', '�', '�', '�', 'i', '�', '�', '�', '�', '�' },
 
49
};
 
50
 
 
51
/* Yankable latin charset :-)
 
52
     !"#$%&'()*+,-./0123456789:;<=>?
 
53
    @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
 
54
    `abcdefghijklmnopqrstuvwxyz{|}~
 
55
     �������������������������������
 
56
    ��������������������������������
 
57
    ��������������������������������
 
58
*/
 
59
 
 
60
 
 
61
 
 
62
static struct mark { u8 *g0, *latin1, *latin2; } marks[16] =
 
63
{
 
64
    /* none */          { "#",
 
65
                          "�",
 
66
                          "$"                                   },
 
67
    /* grave - ` */     { " aeiouAEIOU",
 
68
                          "`����������",
 
69
                          "`aeiouAEIOU"                         },
 
70
    /* acute - ' */     { " aceilnorsuyzACEILNORSUYZ",
 
71
                          "'�c��ln�rs��z�C��LN�RS��Z",
 
72
                          "'���������������������ݬ"             },
 
73
    /* cirumflex - ^ */ { " aeiouAEIOU",
 
74
                          "^����������",
 
75
                          "^�e��u�E��U"                         },
 
76
    /* tilde - ~ */     { " anoANO",
 
77
                          "~������",
 
78
                          "~anoANO"                             },
 
79
    /* ??? - � */       { "",
 
80
                          "",
 
81
                          ""                                    },
 
82
    /* breve - u */     { "aA",
 
83
                          "aA",
 
84
                          "��"                                  },
 
85
    /* abovedot - � */  { "zZ",
 
86
                          "zZ",
 
87
                          "��"                                  },
 
88
    /* diaeresis � */   { "aeiouAEIOU",
 
89
                          "����������",
 
90
                          "��i����I��"                          },
 
91
    /* ??? - . */       { "",
 
92
                          "",
 
93
                          ""                                    },
 
94
    /* ringabove - � */ { " auAU",
 
95
                          "��u�U",
 
96
                          "�a�A�"                               },
 
97
    /* cedilla - � */   { "cstCST",
 
98
                          "�st�ST",
 
99
                          "��Ǫ�"                                },
 
100
    /* ??? - _ */       { " ",
 
101
                          "_",
 
102
                          "_"                                   },
 
103
    /* dbl acute - " */ { " ouOU",
 
104
                          "\"ouOU",
 
105
                          "\"����"                              },
 
106
    /* ogonek - \, */   { "aeAE",
 
107
                          "aeAE",
 
108
                          "���"                         },
 
109
    /* caron - v */     { "cdelnrstzCDELNRSTZ",
 
110
                          "cdelnrstzCDELNRSTZ",
 
111
                          "����������̥�ة��"                     },
 
112
};
 
113
 
 
114
static u8 g2map_latin1[] =
 
115
   /*0123456789abcdef*/
 
116
    " ���$�#��'\"�    "
 
117
    "����׵���'\"�����"
 
118
    " `�^~   �.��_\"  "
 
119
    "_���            "
 
120
    " �ЪH ILL� ��TNn"
 
121
    "K�d�hiill� ��tn\x7f";
 
122
 
 
123
static u8 g2map_latin2[] =
 
124
   /*0123456789abcdef*/
 
125
    " icL$Y#��'\"<    "
 
126
    "�   �u  �'\">    "
 
127
    " `�^~ ���.��_���"
 
128
    "- RC            "
 
129
    "  �aH iL�O opTNn"
 
130
    "K �dhiil�o �ptn\x7f";
 
131
 
 
132
 
 
133
 
 
134
void
 
135
lang_init(void)
 
136
{
 
137
    int i;
 
138
 
 
139
    memset(lang_char, 0, sizeof(lang_char));
 
140
    for (i = 1; i <= 13; i++)
 
141
        lang_char[lang_chars[0][i]] = i;
 
142
}
 
143
 
 
144
 
 
145
void
 
146
conv2latin(u8 *p, int n, int lang)
 
147
{
 
148
    int c, gfx = 0;
 
149
 
 
150
    while (n--)
 
151
    {
 
152
        if (lang_char[c = *p])
 
153
        {
 
154
            if (not gfx || (c & 0xa0) != 0x20)
 
155
                *p = lang_chars[lang + 1][lang_char[c]];
 
156
        }
 
157
        else if ((c & 0xe8) == 0)
 
158
            gfx = c & 0x10;
 
159
        p++;
 
160
    }
 
161
}
 
162
 
 
163
 
 
164
 
 
165
void
 
166
init_enhance(struct enhance *eh)
 
167
{
 
168
    eh->next_des = 0;
 
169
}
 
170
 
 
171
void
 
172
add_enhance(struct enhance *eh, int dcode, u32 *t)
 
173
{
 
174
    if (dcode == eh->next_des)
 
175
    {
 
176
        memcpy(eh->trip + dcode * 13, t, 13 * sizeof(*t));
 
177
        eh->next_des++;
 
178
    }
 
179
    else
 
180
        eh->next_des = -1;
 
181
}
 
182
 
 
183
void
 
184
enhance(struct enhance *eh, struct vt_page *vtp)
 
185
{
 
186
    int row = 0;
 
187
    u32 *p, *e;
 
188
 
 
189
    if (eh->next_des < 1)
 
190
        return;
 
191
 
 
192
    for (p = eh->trip, e = p + eh->next_des * 13; p < e; p++)
 
193
        if (*p % 2048 != 2047)
 
194
        {
 
195
            int adr = *p % 64;
 
196
            int mode = *p / 64 % 32;
 
197
            int data = *p / 2048 % 128;
 
198
 
 
199
            //printf("%2x,%d,%d ", mode, adr, data);
 
200
            if (adr < 40)
 
201
            {
 
202
                // col functions
 
203
                switch (mode)
 
204
                {
 
205
                    case 15: // char from G2 set
 
206
                        if (adr < W && row < H)
 
207
                            if (latin1)
 
208
                                vtp->data[row][adr] = g2map_latin1[data-32];
 
209
                            else
 
210
                                vtp->data[row][adr] = g2map_latin2[data-32];
 
211
                        break;
 
212
                    case 16 ... 31: // char from G0 set with diacritical mark
 
213
                        if (adr < W && row < H)
 
214
                        {
 
215
                            struct mark *mark = marks + (mode - 16);
 
216
                            u8 *x;
 
217
 
 
218
                            if (x = strchr(mark->g0, data))
 
219
                                if (latin1)
 
220
                                    data = mark->latin1[x - mark->g0];
 
221
                                else
 
222
                                    data = mark->latin2[x - mark->g0];
 
223
                            vtp->data[row][adr] = data;
 
224
                        }
 
225
                        break;
 
226
                }
 
227
            }
 
228
            else
 
229
            {
 
230
                // row functions
 
231
                if ((adr -= 40) == 0)
 
232
                    adr = 24;
 
233
                
 
234
                switch (mode)
 
235
                {
 
236
                    case 1: // full row color
 
237
                        row = adr;
 
238
                        break;
 
239
                    case 4: // set active position
 
240
                        row = adr;
 
241
                        break;
 
242
                    case 7: // address row 0 (+ full row color)
 
243
                        if (adr == 23)
 
244
                            row = 0;
 
245
                        break;
 
246
                }
 
247
            }
 
248
        }
 
249
    //printf("\n");
 
250
}