OpenCores
URL https://opencores.org/ocsvn/eco32/eco32/trunk

Subversion Repositories eco32

[/] [eco32/] [trunk/] [monitor/] [monitor/] [kbdtbls/] [mkkbdtbls.c] - Blame information for rev 156

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 16 hellwig
/*
2
 * mkkbdtbls.c -- construct keyboard translation tables
3
 */
4
 
5
 
6
#include <stdio.h>
7
#include <stdlib.h>
8
#include <string.h>
9
 
10
 
11
typedef struct {
12
  unsigned char ascii;
13
  unsigned char key;
14
} Entry;
15
 
16
 
17
Entry tbl1[] = {
18
  { 0x1B, 0x76 },
19
  { '1',  0x16 },
20
  { '2',  0x1E },
21
  { '3',  0x26 },
22
  { '4',  0x25 },
23
  { '5',  0x2E },
24
  { '6',  0x36 },
25
  { '7',  0x3D },
26
  { '8',  0x3E },
27
  { '9',  0x46 },
28
  { '0',  0x45 },
29
  { '^',  0x0E },
30
  { 0x08, 0x66 },
31
  { 0x09, 0x0D },
32
  { 'q',  0x15 },
33
  { 'w',  0x1D },
34
  { 'e',  0x24 },
35
  { 'r',  0x2D },
36
  { 't',  0x2C },
37
  { 'z',  0x35 },
38
  { 'u',  0x3C },
39
  { 'i',  0x43 },
40
  { 'o',  0x44 },
41
  { 'p',  0x4D },
42
  { '\r', 0x5A },
43
  { ' ',  0x29 },
44
  { 'a',  0x1C },
45
  { 's',  0x1B },
46
  { 'd',  0x23 },
47
  { 'f',  0x2B },
48
  { 'g',  0x34 },
49
  { 'h',  0x33 },
50
  { 'j',  0x3B },
51
  { 'k',  0x42 },
52
  { 'l',  0x4B },
53
  { 'y',  0x1A },
54
  { 'x',  0x22 },
55
  { 'c',  0x21 },
56
  { 'v',  0x2A },
57
  { 'b',  0x32 },
58
  { 'n',  0x31 },
59
  { 'm',  0x3A },
60
  { ',',  0x41 },
61
  { '.',  0x49 },
62
  { '-',  0x4A },
63
  { '+',  0x5B },
64
  { '#',  0x5D },
65
  { '<',  0x61 },
66
};
67
 
68
 
69
Entry tbl2[] = {
70
  { 0x1B, 0x76 },
71
  { '!',  0x16 },
72
  { '"',  0x1E },
73
  { '3',  0x26 },
74
  { '$',  0x25 },
75
  { '%',  0x2E },
76
  { '&',  0x36 },
77
  { '/',  0x3D },
78
  { '(',  0x3E },
79
  { ')',  0x46 },
80
  { '=',  0x45 },
81
  { '^',  0x0E },
82
  { 0x08, 0x66 },
83
  { 0x09, 0x0D },
84
  { 'Q',  0x15 },
85
  { 'W',  0x1D },
86
  { 'E',  0x24 },
87
  { 'R',  0x2D },
88
  { 'T',  0x2C },
89
  { 'Z',  0x35 },
90
  { 'U',  0x3C },
91
  { 'I',  0x43 },
92
  { 'O',  0x44 },
93
  { 'P',  0x4D },
94
  { '\r', 0x5A },
95
  { ' ',  0x29 },
96
  { 'A',  0x1C },
97
  { 'S',  0x1B },
98
  { 'D',  0x23 },
99
  { 'F',  0x2B },
100
  { 'G',  0x34 },
101
  { 'H',  0x33 },
102
  { 'J',  0x3B },
103
  { 'K',  0x42 },
104
  { 'L',  0x4B },
105
  { 'Y',  0x1A },
106
  { 'X',  0x22 },
107
  { 'C',  0x21 },
108
  { 'V',  0x2A },
109
  { 'B',  0x32 },
110
  { 'N',  0x31 },
111
  { 'M',  0x3A },
112
  { ';',  0x41 },
113
  { ':',  0x49 },
114
  { '_',  0x4A },
115
  { '*',  0x5B },
116
  { '\'',  0x5D },
117
  { '>',  0x61 },
118
};
119
 
120
 
121
int main(void) {
122
  unsigned char codes[256];
123
  int i, j;
124
 
125
  for (i = 0; i < 256; i++) {
126
    codes[i] = '\0';
127
  }
128
  for (i = 0; i < sizeof(tbl1)/sizeof(tbl1[0]); i++) {
129
    codes[tbl1[i].key] = tbl1[i].ascii;
130
  }
131
  printf(";\n");
132
  printf("; keyboard code tables\n");
133
  printf(";\n");
134
  printf("\n");
135
  printf("\t.export\txltbl1\n");
136
  printf("\t.export\txltbl2\n");
137
  printf("\n");
138
  printf("\t.code\n");
139
  printf("\t.align\t4\n");
140
  printf("\n");
141
  printf("xltbl1:\n");
142
  for (i = 0; i < 32; i++) {
143
    printf("\t.byte\t");
144
    for (j = 0; j < 8; j++) {
145
      printf("0x%02X", codes[i * 8 + j]);
146
      if (j < 7) {
147
        printf(", ");
148
      }
149
    }
150
    printf("\n");
151
  }
152
  printf("\n");
153
  for (i = 0; i < 256; i++) {
154
    codes[i] = '\0';
155
  }
156
  for (i = 0; i < sizeof(tbl2)/sizeof(tbl2[0]); i++) {
157
    codes[tbl2[i].key] = tbl2[i].ascii;
158
  }
159
  printf("xltbl2:\n");
160
  for (i = 0; i < 32; i++) {
161
    printf("\t.byte\t");
162
    for (j = 0; j < 8; j++) {
163
      printf("0x%02X", codes[i * 8 + j]);
164
      if (j < 7) {
165
        printf(", ");
166
      }
167
    }
168
    printf("\n");
169
  }
170
  return 0;
171
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.