conio.c
Go to the documentation of this file.
1 
22 /*
23  * The contents of this file are subject to the Mozilla Public License
24  * Version 1.0 (the "License"); you may not use this file except in
25  * compliance with the License. You may obtain a copy of the License at
26  * http://www.mozilla.org/MPL/
27  *
28  * Software distributed under the License is distributed on an "AS IS"
29  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
30  * License for the specific language governing rights and limitations
31  * under the License.
32  *
33  * The Original Code is legOS code, released October 17, 1999.
34  *
35  * The Initial Developer of the Original Code is Markus L. Noga.
36  * Portions created by Markus L. Noga are Copyright (C) 1999
37  * Markus L. Noga. All Rights Reserved.
38  *
39  * Contributor(s): Markus L. Noga <markus@noga.de>
40  */
41 
42 #include <conio.h>
43 #include <mem.h>
44 
45 #ifdef CONF_CONIO
46 
48 //
49 // Definitions
50 //
52 
54 //
55 const char hex_display_codes[] =
56 {
57  0x7e, // 0
58  0x42, // 1
59  0x37, // 2
60  0x67, // 3
61  0x4b, // 4
62  0x6d, // 5
63  0x7d, // 6
64  0x46, // 7
65  0x7f, // 8
66  0x6f, // 9
67  0x5f, // A
68  0x79, // b
69  0x31, // c
70  0x73, // d
71  0x3d, // E
72  0x1d, // F
73 };
74 
75 #ifdef CONF_ASCII
76 
78 
80 const char ascii_display_codes[] =
81 {
82  0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // non-printables
83  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // -> underscore
84  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // except 0x00.
85  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
86 
87  0x00, // 32 ' '
88  0x42, // 33 ! 1
89  0x0a, // 34 "
90  0x7b, // 35 #
91  0x6d, // 36 $ 5 S Z
92  0x13, // 37 % /
93  0x7d, // 38 & 6
94  0x08, // 39 ' alt: `
95  0x3c, // 40 ( C [ {
96  0x66, // 41 ) ] }
97  0x5b, // 42 * H K X
98  0x43, // 43 + alt: 0x19 (worse)
99  0x10, // 44 , . alt: 0x40
100  0x01, // 45 -
101  0x10, // 46 . alt: 0x40
102  0x13, // 47 /
103 
104  0x7e, // 48 0 0
105  0x42, // 49 1
106  0x37, // 50 2
107  0x67, // 51 3
108  0x4b, // 52 4
109  0x6d, // 53 5
110  0x7d, // 54 6
111  0x46, // 55 7
112  0x7f, // 56 8
113  0x6f, // 57 9
114 
115  0x21, // 58 : ; = alt:0x5 (worse)
116  0x21, // 59 ;
117  0x31, // 60 < c alt:0xd (worse)
118  0x21, // 61 =
119  0x61, // 62 > alt: 0x7 (worse)
120  0x17, // 63 ?
121  0x3f, // 64 @ alt: e
122 
123  0x5f, // 65 A
124  0x79, // 66 b
125  0x3c, // 67 C
126  0x73, // 68 d
127  0x3d, // 69 E
128  0x1d, // 70 F
129  0x7c, // 71 G
130  0x5b, // 72 H
131  0x42, // 73 I 1
132  0x62, // 74 J
133  0x5b, // 75 K
134  0x38, // 76 L
135  0x5e, // 77 M N
136  0x5e, // 78 N
137  0x7e, // 79 O alt: o
138  0x1f, // 80 P
139  0x4f, // 81 Q
140  0x11, // 82 r
141  0x6d, // 83 S
142  0x46, // 84 T alt: t
143  0x7a, // 85 U V W
144  0x7a, // 86 V
145  0x7a, // 87 W
146  0x5b, // 88 X
147  0x6b, // 89 Y
148  0x37, // 90 Z
149 
150  0x3c, // 91 [
151  0x49, // 92 '\\'
152  0x66, // 93 ]
153  0x0e, // 94 ^ ~
154  0x20, // 95 _
155  0x02, // 96 ` alt: '
156 
157  0x5f, // 97 A R
158  0x79, // 98 b
159  0x31, // 99 c
160  0x73, // 100 d
161  0x3d, // 101 E
162  0x1d, // 102 F
163  0x7c, // 103 G
164  0x59, // 104 h
165  0x42, // 105 I 1
166  0x62, // 106 J alt 0x60 (worse)
167  0x5b, // 107 K alt h (worse?)
168  0x38, // 108 L
169  0x51, // 109 m n
170  0x51, // 110 n
171  0x71, // 111 o
172  0x1f, // 112 P
173  0x4f, // 113 q
174  0x11, // 114 r
175  0x6d, // 115 S
176  0x39, // 116 t
177  0x70, // 117 u v w
178  0x70, // 118 v
179  0x70, // 119 w
180  0x5b, // 120 X
181  0x6b, // 121 Y
182  0x37, // 122 Z
183 
184  0x3c, // 123 {
185  0x18, // 124 | (left) alt: 1 (worse)
186  0x66, // 125 }
187  0x0e, // 126 ~
188  0x00 // 127 "" 127 empty
189 };
190 
191 #endif // CONF_ASCII
192 
194 //
195 // Functions
196 //
198 
199 #endif // CONF_CONIO
200 
202 
204 void delay(unsigned ms)
205 {
206  unsigned i;
207 
208  while (ms-- > 0)
209  for (i = 0; i < 600; i++) // not well calibrated.
210  ;
211 
212 }
213 
214 #ifdef CONF_CONIO
215 
217 
222 void cputc_native(char mask, int pos)
223 {
224  switch (pos) {
225  case 0:
226  cputc_native_0(mask);
227  break;
228  case 1:
229  cputc_native_1(mask);
230  break;
231  case 2:
232  cputc_native_2(mask);
233  break;
234  case 3:
235  cputc_native_3(mask);
236  break;
237  case 4:
238  cputc_native_4(mask);
239  break;
240  case 5:
241  cputc_native_5(mask);
242  }
243 }
244 
246 
248 void cputc_native_0(char mask)
249 {
250  // gcc is stupid
251  // doesn't re-use constant values in registers.
252  // re-ordered stores to help him.
253 
254  bit_load(mask, 0x2);
256  bit_load(mask, 0x0);
258  bit_load(mask, 0x5);
260  bit_load(mask, 0x1);
262  bit_load(mask, 0x6);
264  bit_load(mask, 0x3);
266  bit_load(mask, 0x4);
268 }
269 
271 
273 void cputc_native_1(char mask)
274 {
275  bit_load(mask, 0x2);
277  bit_load(mask, 0x0);
279  bit_load(mask, 0x5);
281  bit_load(mask, 0x1);
283  bit_load(mask, 0x6);
285  bit_load(mask, 0x3);
287  bit_load(mask, 0x4);
289 }
290 
292 
294 void cputc_native_2(char mask)
295 {
296  bit_load(mask, 0x2);
298  bit_load(mask, 0x0);
300  bit_load(mask, 0x5);
303  bit_load(mask, 0x1);
305  bit_load(mask, 0x6);
307  bit_load(mask, 0x3);
309  bit_load(mask, 0x4);
311 }
312 
314 
316 void cputc_native_3(char mask)
317 {
319  bit_load(mask, 0x2);
321  bit_load(mask, 0x0);
323  bit_load(mask, 0x5);
325  bit_load(mask, 0x1);
327  bit_load(mask, 0x6);
329  bit_load(mask, 0x3);
331  bit_load(mask, 0x4);
333 }
334 
336 
338 void cputc_native_4(char mask)
339 {
341  bit_load(mask, 0x2);
343  bit_load(mask, 0x0);
345  bit_load(mask, 0x5);
347  bit_load(mask, 0x1);
349  bit_load(mask, 0x6);
351  bit_load(mask, 0x3);
353  bit_load(mask, 0x4);
355 }
356 
358 
361 void cputc_native_5(char mask)
362 {
363  bit_load(mask, 0x0);
365 }
366 
368 
372 void cputw(unsigned word)
373 {
374  int i;
375 
376  cputc_native(0, 5);
377  for (i = 1; i <= 4; i++) {
378  cputc_hex(word & 0x0f, i);
379  word >>= 4;
380  }
381 
382 #if !defined(CONF_LCD_REFRESH)
383  lcd_refresh();
384 #endif
385 }
386 
387 #ifdef CONF_ASCII
388 
390 
396 void cputs(char *s)
397 {
398  int i;
399 
400  cputc_native(0, 5);
401  for (i = 4; (*s) && (i >= 0);)
402  cputc(*(s++), i--);
403  while (i >= 1)
404  cputc_native(0, i--);
405 
406 #if !defined(CONF_LCD_REFRESH)
407  lcd_refresh();
408 #endif
409 }
410 
412 void cls() {
413  cputs(" ");
414 }
415 #endif // CONF_ASCII
416 
417 #endif // CONF_CONIO
conio.h
Interface: console input / output.
LCD_3_BOTR
#define LCD_3_BOTR
Definition: dlcd.h:93
LCD_2_BOT
#define LCD_2_BOT
Definition: dlcd.h:82
lcd_refresh
void lcd_refresh(void)
refresh the entire LCD display
Definition: lcd.c:254
LCD_3_MID
#define LCD_3_MID
Definition: dlcd.h:90
cputc_native_2
void cputc_native_2(char mask)
write bit-pattern for segments at position 2 of LCD
LCD_4_TOP
#define LCD_4_TOP
Definition: dlcd.h:98
LCD_1_BOTR
#define LCD_1_BOTR
Definition: dlcd.h:76
LCD_2_TOPR
#define LCD_2_TOPR
Definition: dlcd.h:83
LCD_1_MID
#define LCD_1_MID
Definition: dlcd.h:73
LCD_0_TOPL
#define LCD_0_TOPL
Definition: dlcd.h:69
LCD_3_BOTL
#define LCD_3_BOTL
Definition: dlcd.h:95
cputw
void cputw(unsigned word)
Write a HEX word to LCD.
LCD_0_TOP
#define LCD_0_TOP
Definition: dlcd.h:64
LCD_3_DOT
#define LCD_3_DOT
Definition: dlcd.h:96
cputc_native_5
void cputc_native_5(char mask)
write bit-pattern for segments at position 5 of LCD
LCD_0_BOTR
#define LCD_0_BOTR
Definition: dlcd.h:68
LCD_4_BOTL
#define LCD_4_BOTL
Definition: dlcd.h:104
LCD_3_TOP
#define LCD_3_TOP
Definition: dlcd.h:89
cputc_native
void cputc_native(char mask, int pos)
Set/Clear individual segments at specified position of LCD.
cputc_hex
void cputc_hex(char c, int pos)
Write HEX digit to specified position of LCD.
Definition: conio.h:164
LCD_1_BOTL
#define LCD_1_BOTL
Definition: dlcd.h:78
LCD_2_TOPL
#define LCD_2_TOPL
Definition: dlcd.h:85
LCD_1_TOPL
#define LCD_1_TOPL
Definition: dlcd.h:77
LCD_4_MID
#define LCD_4_MID
Definition: dlcd.h:99
LCD_4_BOTR
#define LCD_4_BOTR
Definition: dlcd.h:102
LCD_2_BOTR
#define LCD_2_BOTR
Definition: dlcd.h:84
cputc_native_0
void cputc_native_0(char mask)
write bit-pattern for segments at position 0 of LCD
LCD_4_TOPR
#define LCD_4_TOPR
Definition: dlcd.h:101
LCD_2_BOTL
#define LCD_2_BOTL
Definition: dlcd.h:86
LCD_1_TOP
#define LCD_1_TOP
Definition: dlcd.h:72
LCD_3_BOT
#define LCD_3_BOT
Definition: dlcd.h:91
LCD_1_BOT
#define LCD_1_BOT
Definition: dlcd.h:74
cputc_native_3
void cputc_native_3(char mask)
write bit-pattern for segments at position 3 of LCD
cputs
void cputs(char *s)
Write string s to LCD (Only first 5 chars)
LCD_5_MID
#define LCD_5_MID
Definition: dlcd.h:107
LCD_4_TOPL
#define LCD_4_TOPL
Definition: dlcd.h:103
dlcd_store
#define dlcd_store(a)
store the carry flag to a segment directly in the LCD buffer
Definition: dlcd.h:187
LCD_0_BOT
#define LCD_0_BOT
Definition: dlcd.h:66
LCD_3_TOPR
#define LCD_3_TOPR
Definition: dlcd.h:92
delay
void delay(unsigned ms)
uncalibrated delay loop
Definition: conio.c:204
LCD_0_MID
#define LCD_0_MID
Definition: dlcd.h:65
LCD_2_TOP
#define LCD_2_TOP
Definition: dlcd.h:80
bit_load
#define bit_load(mask, bit)
load a single bit from a mask to the carry flag
Definition: bitops.h:71
LCD_0_BOTL
#define LCD_0_BOTL
Definition: dlcd.h:70
cls
void cls()
clear user portion of LCD
cputc_native_4
void cputc_native_4(char mask)
write bit-pattern for segments at position 4 of LCD
LCD_4_BOT
#define LCD_4_BOT
Definition: dlcd.h:100
cputc
void cputc(char c, int pos)
Write ASCII character to specified position of LCD.
Definition: conio.h:210
LCD_1_TOPR
#define LCD_1_TOPR
Definition: dlcd.h:75
LCD_4_DOT
#define LCD_4_DOT
Definition: dlcd.h:105
LCD_2_MID
#define LCD_2_MID
Definition: dlcd.h:81
dlcd_hide
#define dlcd_hide(a)
clear a segment directly in the LCD buffer
Definition: dlcd.h:180
hex_display_codes
const char hex_display_codes[]
Table: list of native patterns, one for each HEX character.
mem.h
Interface: memory data types.
LCD_0_TOPR
#define LCD_0_TOPR
Definition: dlcd.h:67
LCD_3_TOPL
#define LCD_3_TOPL
Definition: dlcd.h:94
ascii_display_codes
const char ascii_display_codes[]
Table: list of native patterns, one for each ASCII character.
LCD_2_DOT
#define LCD_2_DOT
Definition: dlcd.h:87
cputc_native_1
void cputc_native_1(char mask)
write bit-pattern for segments at position 1 of LCD

brickOS is released under the Mozilla Public License.
Original code copyright 1998-2005 by the authors.

Generated for brickOS Kernel Developer by doxygen 1.8.16