libconio.c

00001 /*
00002  * Copyright (c) 2002, Adam Dunkels.
00003  * All rights reserved. 
00004  *
00005  * Redistribution and use in source and binary forms, with or without 
00006  * modification, are permitted provided that the following conditions 
00007  * are met: 
00008  * 1. Redistributions of source code must retain the above copyright 
00009  *    notice, this list of conditions and the following disclaimer. 
00010  * 2. Redistributions in binary form must reproduce the above
00011  *    copyright notice, this list of conditions and the following
00012  *    disclaimer in the documentation and/or other materials provided
00013  *    with the distribution. 
00014  * 3. The name of the author may not be used to endorse or promote
00015  *    products derived from this software without specific prior
00016  *    written permission.  
00017  *
00018  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
00019  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00020  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
00022  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00023  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
00024  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00025  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00026  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00027  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00028  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
00029  *
00030  * This file is part of the Contiki desktop environment
00031  *
00032  * $Id: libconio.c,v 1.2 2007/09/09 12:24:44 matsutsuka Exp $
00033  *
00034  */
00035 
00036 #include <string.h>
00037 #include "contiki.h"
00038 #include "libconio.h"
00039 
00040 static unsigned char cursx, cursy;
00041 static unsigned char reversed;
00042 static unsigned char color;
00043 
00044 /*-----------------------------------------------------------------------------------*/
00045 unsigned char
00046 wherex(void)
00047 {
00048   return cursx;
00049 }
00050 /*-----------------------------------------------------------------------------------*/
00051 unsigned char
00052 wherey(void)
00053 {
00054   return cursy;
00055 }
00056 /*-----------------------------------------------------------------------------------*/
00057 void
00058 clrscr(void)
00059 {
00060   unsigned char x, y;
00061 
00062   for(x = 0; x < LIBCONIO_SCREEN_WIDTH; ++x) {
00063     for(y = 0; y < LIBCONIO_SCREEN_HEIGHT; ++y) {
00064       gotoxy(x, y);
00065       cputc(' ');
00066     }
00067   }
00068 }
00069 /*-----------------------------------------------------------------------------------*/
00070 void
00071 revers(unsigned char c)
00072 {
00073   reversed = c;
00074 }
00075 /*-----------------------------------------------------------------------------------*/
00076 void
00077 cputc(char c)
00078 {
00079   ctk_arch_draw_char(c, cursx, cursy, reversed, color);
00080   ++cursx;
00081 }
00082 /*-----------------------------------------------------------------------------------*/
00083 void
00084 cputs(char *str)
00085 {
00086   while(*str != 0) {
00087     cputc(*str++);
00088   }
00089   
00090   /*  int i;
00091   for(i = 0; i < strlen(str); ++i) {
00092     cputc(str[i]);
00093     }*/
00094 }
00095 /*-----------------------------------------------------------------------------------*/
00096 void
00097 cclear(unsigned char length)
00098 {
00099   int i;
00100   for(i = 0; i < length; ++i) {
00101     cputc(' ');
00102   }  
00103 }
00104 /*-----------------------------------------------------------------------------------*/
00105 void
00106 chline(unsigned char length)
00107 {
00108   int i;
00109   for(i = 0; i < length; ++i) {
00110     cputc('-');
00111   }
00112 }
00113 /*-----------------------------------------------------------------------------------*/
00114 void
00115 cvline(unsigned char length)
00116 {
00117   int i;
00118   for(i = 0; i < length; ++i) {
00119     cputc('|');
00120     --cursx;
00121     ++cursy;
00122   }
00123 }
00124 /*-----------------------------------------------------------------------------------*/
00125 void
00126 gotoxy(unsigned char x, unsigned char y)
00127 {
00128   cursx = x;
00129   cursy = y;
00130 }
00131 /*-----------------------------------------------------------------------------------*/
00132 void
00133 cclearxy(unsigned char x, unsigned char y, unsigned char length)
00134 {
00135   gotoxy(x, y);
00136   cclear(length);
00137 }
00138 /*-----------------------------------------------------------------------------------*/
00139 void
00140 chlinexy(unsigned char x, unsigned char y, unsigned char length)
00141 {
00142   gotoxy(x, y);
00143   chline(length);
00144 }
00145 /*-----------------------------------------------------------------------------------*/
00146 void
00147 cvlinexy(unsigned char x, unsigned char y, unsigned char length)
00148 {
00149   gotoxy(x, y);
00150   cvline(length);
00151 }
00152 /*-----------------------------------------------------------------------------------*/
00153 void
00154 cputsxy(unsigned char x, unsigned char y, char *str)
00155 {
00156   gotoxy(x, y);
00157   cputs(str);
00158 }
00159 /*-----------------------------------------------------------------------------------*/
00160 void
00161 cputcxy(unsigned char x, unsigned char y, char c)
00162 {
00163   gotoxy(x, y);
00164   cputc(c);
00165 }
00166 /*-----------------------------------------------------------------------------------*/
00167 void
00168 textcolor(unsigned char c)
00169 {
00170   color = c;
00171 }
00172 /*-----------------------------------------------------------------------------------*/
00173 void
00174 bgcolor(unsigned char c)
00175 {
00176 
00177 }
00178 /*-----------------------------------------------------------------------------------*/
00179 void
00180 bordercolor(unsigned char c)
00181 {
00182 
00183 }
00184 /*-----------------------------------------------------------------------------------*/
00185 void
00186 screensize(unsigned char *x, unsigned char *y)
00187 {
00188   *x = LIBCONIO_SCREEN_WIDTH;
00189   *y = LIBCONIO_SCREEN_HEIGHT;
00190 }
00191 /*-----------------------------------------------------------------------------------*/

Generated on Mon Apr 11 14:23:28 2011 for Contiki 2.5 by  doxygen 1.6.1