00001 00022 /* 00023 * The contents of this file are subject to the Mozilla Public License 00024 * Version 1.0 (the "License"); you may not use this file except in 00025 * compliance with the License. You may obtain a copy of the License at 00026 * http://www.mozilla.org/MPL/ 00027 * 00028 * Software distributed under the License is distributed on an "AS IS" 00029 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 00030 * License for the specific language governing rights and limitations 00031 * under the License. 00032 * 00033 * The Original Code is legOS code, released October 17, 1999. 00034 * 00035 * The Initial Developer of the Original Code is Markus L. Noga. 00036 * Portions created by Markus L. Noga are Copyright (C) 1999 00037 * Markus L. Noga. All Rights Reserved. 00038 * 00039 * Contributor(s): Markus L. Noga <markus@noga.de> 00040 */ 00041 00042 #include <conio.h> 00043 #include <mem.h> 00044 00045 #ifdef CONF_CONIO 00046 00048 // 00049 // Definitions 00050 // 00052 00054 // 00055 const char hex_display_codes[] = 00056 { 00057 0x7e, // 0 00058 0x42, // 1 00059 0x37, // 2 00060 0x67, // 3 00061 0x4b, // 4 00062 0x6d, // 5 00063 0x7d, // 6 00064 0x46, // 7 00065 0x7f, // 8 00066 0x6f, // 9 00067 0x5f, // A 00068 0x79, // b 00069 0x31, // c 00070 0x73, // d 00071 0x3d, // E 00072 0x1d, // F 00073 }; 00074 00075 #ifdef CONF_ASCII 00076 00078 00080 const char ascii_display_codes[] = 00081 { 00082 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // non-printables 00083 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // -> underscore 00084 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // except 0x00. 00085 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 00086 00087 0x00, // 32 ' ' 00088 0x42, // 33 ! 1 00089 0x0a, // 34 " 00090 0x7b, // 35 # 00091 0x6d, // 36 $ 5 S Z 00092 0x13, // 37 % / 00093 0x7d, // 38 & 6 00094 0x08, // 39 ' alt: ` 00095 0x3c, // 40 ( C [ { 00096 0x66, // 41 ) ] } 00097 0x5b, // 42 * H K X 00098 0x43, // 43 + alt: 0x19 (worse) 00099 0x10, // 44 , . alt: 0x40 00100 0x01, // 45 - 00101 0x10, // 46 . alt: 0x40 00102 0x13, // 47 / 00103 00104 0x7e, // 48 0 0 00105 0x42, // 49 1 00106 0x37, // 50 2 00107 0x67, // 51 3 00108 0x4b, // 52 4 00109 0x6d, // 53 5 00110 0x7d, // 54 6 00111 0x46, // 55 7 00112 0x7f, // 56 8 00113 0x6f, // 57 9 00114 00115 0x21, // 58 : ; = alt:0x5 (worse) 00116 0x21, // 59 ; 00117 0x31, // 60 < c alt:0xd (worse) 00118 0x21, // 61 = 00119 0x61, // 62 > alt: 0x7 (worse) 00120 0x17, // 63 ? 00121 0x3f, // 64 @ alt: e 00122 00123 0x5f, // 65 A 00124 0x79, // 66 b 00125 0x3c, // 67 C 00126 0x73, // 68 d 00127 0x3d, // 69 E 00128 0x1d, // 70 F 00129 0x7c, // 71 G 00130 0x5b, // 72 H 00131 0x42, // 73 I 1 00132 0x62, // 74 J 00133 0x5b, // 75 K 00134 0x38, // 76 L 00135 0x5e, // 77 M N 00136 0x5e, // 78 N 00137 0x7e, // 79 O alt: o 00138 0x1f, // 80 P 00139 0x4f, // 81 Q 00140 0x11, // 82 r 00141 0x6d, // 83 S 00142 0x46, // 84 T alt: t 00143 0x7a, // 85 U V W 00144 0x7a, // 86 V 00145 0x7a, // 87 W 00146 0x5b, // 88 X 00147 0x6b, // 89 Y 00148 0x37, // 90 Z 00149 00150 0x3c, // 91 [ 00151 0x49, // 92 '\\' 00152 0x66, // 93 ] 00153 0x0e, // 94 ^ ~ 00154 0x20, // 95 _ 00155 0x02, // 96 ` alt: ' 00156 00157 0x5f, // 97 A R 00158 0x79, // 98 b 00159 0x31, // 99 c 00160 0x73, // 100 d 00161 0x3d, // 101 E 00162 0x1d, // 102 F 00163 0x7c, // 103 G 00164 0x59, // 104 h 00165 0x42, // 105 I 1 00166 0x62, // 106 J alt 0x60 (worse) 00167 0x5b, // 107 K alt h (worse?) 00168 0x38, // 108 L 00169 0x51, // 109 m n 00170 0x51, // 110 n 00171 0x71, // 111 o 00172 0x1f, // 112 P 00173 0x4f, // 113 q 00174 0x11, // 114 r 00175 0x6d, // 115 S 00176 0x39, // 116 t 00177 0x70, // 117 u v w 00178 0x70, // 118 v 00179 0x70, // 119 w 00180 0x5b, // 120 X 00181 0x6b, // 121 Y 00182 0x37, // 122 Z 00183 00184 0x3c, // 123 { 00185 0x18, // 124 | (left) alt: 1 (worse) 00186 0x66, // 125 } 00187 0x0e, // 126 ~ 00188 0x00 // 127 "" 127 empty 00189 }; 00190 00191 #endif // CONF_ASCII 00192 00194 // 00195 // Functions 00196 // 00198 00199 #endif // CONF_CONIO 00200 00202 00204 void delay(unsigned ms) 00205 { 00206 unsigned i; 00207 00208 while (ms-- > 0) 00209 for (i = 0; i < 600; i++) // not well calibrated. 00210 ; 00211 00212 } 00213 00214 #ifdef CONF_CONIO 00215 00217 00222 void cputc_native(char mask, int pos) 00223 { 00224 switch (pos) { 00225 case 0: 00226 cputc_native_0(mask); 00227 break; 00228 case 1: 00229 cputc_native_1(mask); 00230 break; 00231 case 2: 00232 cputc_native_2(mask); 00233 break; 00234 case 3: 00235 cputc_native_3(mask); 00236 break; 00237 case 4: 00238 cputc_native_4(mask); 00239 break; 00240 case 5: 00241 cputc_native_5(mask); 00242 } 00243 } 00244 00246 00248 void cputc_native_0(char mask) 00249 { 00250 // gcc is stupid 00251 // doesn't re-use constant values in registers. 00252 // re-ordered stores to help him. 00253 00254 bit_load(mask, 0x2); 00255 dlcd_store(LCD_0_TOP); 00256 bit_load(mask, 0x0); 00257 dlcd_store(LCD_0_MID); 00258 bit_load(mask, 0x5); 00259 dlcd_store(LCD_0_BOT); 00260 bit_load(mask, 0x1); 00261 dlcd_store(LCD_0_TOPR); 00262 bit_load(mask, 0x6); 00263 dlcd_store(LCD_0_BOTR); 00264 bit_load(mask, 0x3); 00265 dlcd_store(LCD_0_TOPL); 00266 bit_load(mask, 0x4); 00267 dlcd_store(LCD_0_BOTL); 00268 } 00269 00271 00273 void cputc_native_1(char mask) 00274 { 00275 bit_load(mask, 0x2); 00276 dlcd_store(LCD_1_TOP); 00277 bit_load(mask, 0x0); 00278 dlcd_store(LCD_1_MID); 00279 bit_load(mask, 0x5); 00280 dlcd_store(LCD_1_BOT); 00281 bit_load(mask, 0x1); 00282 dlcd_store(LCD_1_TOPR); 00283 bit_load(mask, 0x6); 00284 dlcd_store(LCD_1_BOTR); 00285 bit_load(mask, 0x3); 00286 dlcd_store(LCD_1_TOPL); 00287 bit_load(mask, 0x4); 00288 dlcd_store(LCD_1_BOTL); 00289 } 00290 00292 00294 void cputc_native_2(char mask) 00295 { 00296 bit_load(mask, 0x2); 00297 dlcd_store(LCD_2_TOP); 00298 bit_load(mask, 0x0); 00299 dlcd_store(LCD_2_MID); 00300 bit_load(mask, 0x5); 00301 dlcd_store(LCD_2_BOT); 00302 dlcd_hide(LCD_2_DOT); 00303 bit_load(mask, 0x1); 00304 dlcd_store(LCD_2_TOPR); 00305 bit_load(mask, 0x6); 00306 dlcd_store(LCD_2_BOTR); 00307 bit_load(mask, 0x3); 00308 dlcd_store(LCD_2_TOPL); 00309 bit_load(mask, 0x4); 00310 dlcd_store(LCD_2_BOTL); 00311 } 00312 00314 00316 void cputc_native_3(char mask) 00317 { 00318 dlcd_hide(LCD_3_DOT); 00319 bit_load(mask, 0x2); 00320 dlcd_store(LCD_3_TOP); 00321 bit_load(mask, 0x0); 00322 dlcd_store(LCD_3_MID); 00323 bit_load(mask, 0x5); 00324 dlcd_store(LCD_3_BOT); 00325 bit_load(mask, 0x1); 00326 dlcd_store(LCD_3_TOPR); 00327 bit_load(mask, 0x6); 00328 dlcd_store(LCD_3_BOTR); 00329 bit_load(mask, 0x3); 00330 dlcd_store(LCD_3_TOPL); 00331 bit_load(mask, 0x4); 00332 dlcd_store(LCD_3_BOTL); 00333 } 00334 00336 00338 void cputc_native_4(char mask) 00339 { 00340 dlcd_hide(LCD_4_DOT); 00341 bit_load(mask, 0x2); 00342 dlcd_store(LCD_4_TOP); 00343 bit_load(mask, 0x0); 00344 dlcd_store(LCD_4_MID); 00345 bit_load(mask, 0x5); 00346 dlcd_store(LCD_4_BOT); 00347 bit_load(mask, 0x1); 00348 dlcd_store(LCD_4_TOPR); 00349 bit_load(mask, 0x6); 00350 dlcd_store(LCD_4_BOTR); 00351 bit_load(mask, 0x3); 00352 dlcd_store(LCD_4_TOPL); 00353 bit_load(mask, 0x4); 00354 dlcd_store(LCD_4_BOTL); 00355 } 00356 00358 00361 void cputc_native_5(char mask) 00362 { 00363 bit_load(mask, 0x0); 00364 dlcd_store(LCD_5_MID); 00365 } 00366 00368 00372 void cputw(unsigned word) 00373 { 00374 int i; 00375 00376 cputc_native(0, 5); 00377 for (i = 1; i <= 4; i++) { 00378 cputc_hex(word & 0x0f, i); 00379 word >>= 4; 00380 } 00381 00382 #if !defined(CONF_LCD_REFRESH) 00383 lcd_refresh(); 00384 #endif 00385 } 00386 00387 #ifdef CONF_ASCII 00388 00390 00396 void cputs(char *s) 00397 { 00398 int i; 00399 00400 cputc_native(0, 5); 00401 for (i = 4; (*s) && (i >= 0);) 00402 cputc(*(s++), i--); 00403 while (i >= 1) 00404 cputc_native(0, i--); 00405 00406 #if !defined(CONF_LCD_REFRESH) 00407 lcd_refresh(); 00408 #endif 00409 } 00410 00412 void cls() { 00413 cputs(" "); 00414 } 00415 #endif // CONF_ASCII 00416 00418 void cputc_hex_0(unsigned nibble) 00419 { 00420 cputc_native_0(hex_display_codes[(nibble) & 0x0f]); 00421 } 00423 void cputc_hex_1(unsigned nibble) 00424 { 00425 cputc_native_1(hex_display_codes[(nibble) & 0x0f]); 00426 } 00428 void cputc_hex_2(unsigned nibble) 00429 { 00430 cputc_native_2(hex_display_codes[(nibble) & 0x0f]); 00431 } 00433 void cputc_hex_3(unsigned nibble) 00434 { 00435 cputc_native_3(hex_display_codes[(nibble) & 0x0f]); 00436 } 00438 void cputc_hex_4(unsigned nibble) 00439 { 00440 cputc_native_4(hex_display_codes[(nibble) & 0x0f]); 00441 } 00443 void cputc_hex_5(unsigned nibble) 00444 { 00445 cputc_native_5(hex_display_codes[(nibble) & 0x0f]); 00446 } 00447 00449 00454 void cputc_hex(char c, int pos) 00455 { 00456 cputc_native(hex_display_codes[(c) & 0x7f], pos); 00457 } 00458 00460 extern void cputw(unsigned word); 00461 00462 #ifdef CONF_ASCII 00463 00464 void cputc_0(unsigned c) 00465 { 00466 cputc_native_0(ascii_display_codes[(c) & 0x7f]); 00467 } 00469 void cputc_1(unsigned c) 00470 { 00471 cputc_native_1(ascii_display_codes[(c) & 0x7f]); 00472 } 00474 void cputc_2(unsigned c) 00475 { 00476 cputc_native_2(ascii_display_codes[(c) & 0x7f]); 00477 } 00479 void cputc_3(unsigned c) 00480 { 00481 cputc_native_3(ascii_display_codes[(c) & 0x7f]); 00482 } 00484 void cputc_4(unsigned c) 00485 { 00486 cputc_native_4(ascii_display_codes[(c) & 0x7f]); 00487 } 00489 void cputc_5(unsigned c) 00490 { 00491 cputc_native_5(ascii_display_codes[(c) & 0x7f]); 00492 } 00493 00495 00500 void cputc(char c, int pos) 00501 { 00502 cputc_native(ascii_display_codes[(c) & 0x7f], pos); 00503 } 00504 00505 #ifdef __cplusplus 00506 } 00507 #endif 00508 00509 #endif // __conio_h__ 00510 00511 #endif // CONF_CONIO
brickOS is released under the
Mozilla Public License.
Original code copyright 1998-2002 by the authors. |