1 
2 /*
3  *  Diverse Bristol audio routines.
4  *  Copyright (c) by Nick Copeland <nickycopeland@hotmail.com> 1996,2012
5  *
6  *
7  *   This program is free software; you can redistribute it and/or modify
8  *   it under the terms of the GNU General Public License as published by
9  *   the Free Software Foundation; either version 3 of the License, or
10  *   (at your option) any later version.
11  *
12  *   This program is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with this program; if not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 /* #define BRISTOL_FIXEDWIDTH */
22 
23 /*
24  * This needs to be changed to allow it to have a couple of different fonts,
25  * at least to include another one for the menus - a little larger. This would
26  * give access to 3 fonts, this one totally compact, the new one, and the new
27  * one rendered in double res
28  */
29 
30 #define KEYTAB_SIZE 256
31 #define KEY_HEIGHT 5
32 
33 #define BIT_ON 1
34 #define BIT_OFF 2
35 
36 typedef struct Bkey {
37 	int map;
38 	int width;
39 	unsigned char bitmap[KEY_HEIGHT];
40 } bkey;
41 
42 bkey key[KEYTAB_SIZE];
43 
44 void
brightonsetkey(int index,int width,unsigned char ch0,unsigned char ch1,unsigned char ch2,unsigned char ch3,unsigned char ch4)45 brightonsetkey(int index, int width, unsigned char ch0, unsigned char ch1,
46 unsigned char ch2, unsigned char ch3, unsigned char ch4)
47 {
48 	if (index >= KEYTAB_SIZE)
49 		return;
50 
51 	key[index].map = index;
52 
53 #ifdef BRISTOL_FIXEDWIDTH
54 	key[index].width = 5;
55 #else
56 	key[index].width = width;
57 #endif
58 
59 	key[index].bitmap[0] = ch0;
60 	key[index].bitmap[1] = ch1;
61 	key[index].bitmap[2] = ch2;
62 	key[index].bitmap[3] = ch3;
63 	key[index].bitmap[4] = ch4;
64 }
65 
66 void
initkeys()67 initkeys()
68 {
69 	int i;
70 
71 	for (i = 0; i < KEYTAB_SIZE; i++)
72 	{
73 		key[i].map = -1;
74 		key[i].width = -1;
75 	}
76 
77 	key[0].width = 4;
78 	key[0].bitmap[0] = 0xf0;
79 	key[0].bitmap[1] = 0xf0;
80 	key[0].bitmap[2] = 0xf0;
81 	key[0].bitmap[3] = 0xf0;
82 	key[0].bitmap[4] = 0xf0;
83 
84 	brightonsetkey(' ', 3, 0x00, 0x00, 0x00, 0x00, 0x00);
85 
86 	brightonsetkey('A', 5, 0x20, 0x50, 0x50, 0xa8, 0x88);
87 	brightonsetkey('B', 4, 0xe0, 0x90, 0xe0, 0x90, 0xe0);
88 	brightonsetkey('C', 4, 0x60, 0x90, 0x80, 0x90, 0x60);
89 	brightonsetkey('D', 4, 0xe0, 0x90, 0x90, 0x90, 0xe0);
90 	brightonsetkey('E', 3, 0xf0, 0x80, 0xd0, 0x80, 0xf0);
91 	brightonsetkey('F', 3, 0xf0, 0x80, 0xd0, 0x80, 0x80);
92 
93 	brightonsetkey('G', 4, 0x60, 0x90, 0x80, 0xb0, 0x60);
94 	brightonsetkey('H', 4, 0x90, 0x90, 0xf0, 0x90, 0x90);
95 #ifdef BRISTOL_FIXEDWIDTH
96 	brightonsetkey('I', 1, 0x70, 0x20, 0x20, 0x20, 0x70);
97 #else
98 	brightonsetkey('I', 1, 0x80, 0x80, 0x80, 0x80, 0x80);
99 #endif
100 	brightonsetkey('J', 4, 0x70, 0x20, 0x20, 0xa0, 0x40);
101 	brightonsetkey('K', 4, 0x90, 0xa0, 0xc0, 0xa0, 0x90);
102 	brightonsetkey('L', 4, 0x80, 0x80, 0x80, 0x80, 0xf0);
103 
104 	brightonsetkey('M', 5, 0x88, 0xd8, 0xa8, 0x88, 0x88);
105 	brightonsetkey('N', 4, 0x90, 0xd0, 0xb0, 0x90, 0x90);
106 	brightonsetkey('O', 4, 0x60, 0x90, 0x90, 0x90, 0x60);
107 	brightonsetkey('P', 4, 0xe0, 0x90, 0xe0, 0x80, 0x80);
108 	brightonsetkey('Q', 4, 0x60, 0x90, 0x90, 0xb0, 0x70);
109 	brightonsetkey('R', 4, 0xe0, 0x90, 0xe0, 0xa0, 0x90);
110 	brightonsetkey('S', 4, 0x70, 0x80, 0x60, 0x10, 0xe0);
111 	brightonsetkey('T', 5, 0xf8, 0x20, 0x20, 0x20, 0x20);
112 
113 	brightonsetkey('U', 4, 0x90, 0x90, 0x90, 0x90, 0x60);
114 	brightonsetkey('V', 5, 0x88, 0x88, 0x50, 0x50, 0x20);
115 	brightonsetkey('W', 5, 0x88, 0x88, 0xa8, 0xd8, 0x88);
116 	brightonsetkey('X', 4, 0x90, 0x90, 0x60, 0x60, 0x90);
117 	brightonsetkey('Y', 5, 0x88, 0x50, 0x20, 0x20, 0x20);
118 	brightonsetkey('Z', 4, 0xf0, 0x10, 0x20, 0x40, 0xf0);
119 
120 	brightonsetkey('0', 4, 0x60, 0x90, 0x90, 0x90, 0x60);
121 #ifdef BRISTOL_FIXEDWIDTH
122 	brightonsetkey('1', 5, 0x60, 0x20, 0x20, 0x20, 0x70);
123 #else
124 	brightonsetkey('1', 3, 0x40, 0xc0, 0x40, 0x40, 0xe0);
125 #endif
126 	brightonsetkey('2', 4, 0x60, 0x90, 0x20, 0x40, 0xf0);
127 	brightonsetkey('3', 4, 0x60, 0x90, 0x20, 0x90, 0x60);
128 	brightonsetkey('4', 4, 0x10, 0x30, 0x50, 0xf0, 0x10);
129 	brightonsetkey('5', 4, 0xf0, 0x80, 0xe0, 0x10, 0xe0);
130 
131 	brightonsetkey('6', 4, 0x60, 0x80, 0xe0, 0x90, 0x60);
132 	brightonsetkey('7', 4, 0xf0, 0x10, 0x20, 0x40, 0x40);
133 	brightonsetkey('8', 4, 0x60, 0x90, 0x60, 0x90, 0x60);
134 	brightonsetkey('9', 4, 0x60, 0x90, 0x70, 0x10, 0x60);
135 
136 	brightonsetkey('-', 3, 0x00, 0x00, 0xe0, 0x00, 0x00);
137 	brightonsetkey('_', 3, 0x00, 0x00, 0x00, 0x00, 0x70);
138 	brightonsetkey(':', 1, 0x00, 0x80, 0x00, 0x80, 0x00);
139 	brightonsetkey(';', 1, 0x00, 0x80, 0x00, 0x80, 0x00);
140 	brightonsetkey('?', 4, 0x60, 0x90, 0x20, 0x00, 0x20);
141 	brightonsetkey('/', 5, 0x08, 0x10, 0x20, 0x40, 0x80);
142 	brightonsetkey('.', 1, 0x00, 0x00, 0x00, 0x00, 0x80);
143 	brightonsetkey('+', 3, 0x00, 0x40, 0xe0, 0x40, 0x00);
144 
145 	key['a'].map = 'A';
146 	key['b'].map = 'B';
147 	key['c'].map = 'C';
148 	key['d'].map = 'D';
149 	key['e'].map = 'E';
150 	key['f'].map = 'F';
151 	key['g'].map = 'G';
152 	key['h'].map = 'H';
153 	key['i'].map = 'I';
154 	key['j'].map = 'J';
155 	key['k'].map = 'K';
156 	key['l'].map = 'L';
157 	key['m'].map = 'M';
158 
159 	key['n'].map = 'N';
160 	key['o'].map = 'O';
161 	key['p'].map = 'P';
162 	key['q'].map = 'Q';
163 	key['r'].map = 'R';
164 	key['s'].map = 'S';
165 	key['t'].map = 'T';
166 	key['u'].map = 'U';
167 	key['v'].map = 'V';
168 	key['w'].map = 'W';
169 	key['x'].map = 'X';
170 	key['y'].map = 'Y';
171 	key['z'].map = 'Z';
172 
173 }
174 
175