Contiki 2.5
libconio.c
1 /*
2  * Copyright (c) 2002, Adam Dunkels.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following
12  * disclaimer in the documentation and/or other materials provided
13  * with the distribution.
14  * 3. The name of the author may not be used to endorse or promote
15  * products derived from this software without specific prior
16  * written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
19  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  *
30  * This file is part of the Contiki desktop environment
31  *
32  * $Id: libconio.c,v 1.2 2007/09/09 12:24:44 matsutsuka Exp $
33  *
34  */
35 
36 #include <string.h>
37 #include "contiki.h"
38 #include "libconio.h"
39 
40 static unsigned char cursx, cursy;
41 static unsigned char reversed;
42 static unsigned char color;
43 
44 /*-----------------------------------------------------------------------------------*/
45 unsigned char
46 wherex(void)
47 {
48  return cursx;
49 }
50 /*-----------------------------------------------------------------------------------*/
51 unsigned char
52 wherey(void)
53 {
54  return cursy;
55 }
56 /*-----------------------------------------------------------------------------------*/
57 void
58 clrscr(void)
59 {
60  unsigned char x, y;
61 
62  for(x = 0; x < LIBCONIO_SCREEN_WIDTH; ++x) {
63  for(y = 0; y < LIBCONIO_SCREEN_HEIGHT; ++y) {
64  gotoxy(x, y);
65  cputc(' ');
66  }
67  }
68 }
69 /*-----------------------------------------------------------------------------------*/
70 void
71 revers(unsigned char c)
72 {
73  reversed = c;
74 }
75 /*-----------------------------------------------------------------------------------*/
76 void
77 cputc(char c)
78 {
79  ctk_arch_draw_char(c, cursx, cursy, reversed, color);
80  ++cursx;
81 }
82 /*-----------------------------------------------------------------------------------*/
83 void
84 cputs(char *str)
85 {
86  while(*str != 0) {
87  cputc(*str++);
88  }
89 
90  /* int i;
91  for(i = 0; i < strlen(str); ++i) {
92  cputc(str[i]);
93  }*/
94 }
95 /*-----------------------------------------------------------------------------------*/
96 void
97 cclear(unsigned char length)
98 {
99  int i;
100  for(i = 0; i < length; ++i) {
101  cputc(' ');
102  }
103 }
104 /*-----------------------------------------------------------------------------------*/
105 void
106 chline(unsigned char length)
107 {
108  int i;
109  for(i = 0; i < length; ++i) {
110  cputc('-');
111  }
112 }
113 /*-----------------------------------------------------------------------------------*/
114 void
115 cvline(unsigned char length)
116 {
117  int i;
118  for(i = 0; i < length; ++i) {
119  cputc('|');
120  --cursx;
121  ++cursy;
122  }
123 }
124 /*-----------------------------------------------------------------------------------*/
125 void
126 gotoxy(unsigned char x, unsigned char y)
127 {
128  cursx = x;
129  cursy = y;
130 }
131 /*-----------------------------------------------------------------------------------*/
132 void
133 cclearxy(unsigned char x, unsigned char y, unsigned char length)
134 {
135  gotoxy(x, y);
136  cclear(length);
137 }
138 /*-----------------------------------------------------------------------------------*/
139 void
140 chlinexy(unsigned char x, unsigned char y, unsigned char length)
141 {
142  gotoxy(x, y);
143  chline(length);
144 }
145 /*-----------------------------------------------------------------------------------*/
146 void
147 cvlinexy(unsigned char x, unsigned char y, unsigned char length)
148 {
149  gotoxy(x, y);
150  cvline(length);
151 }
152 /*-----------------------------------------------------------------------------------*/
153 void
154 cputsxy(unsigned char x, unsigned char y, char *str)
155 {
156  gotoxy(x, y);
157  cputs(str);
158 }
159 /*-----------------------------------------------------------------------------------*/
160 void
161 cputcxy(unsigned char x, unsigned char y, char c)
162 {
163  gotoxy(x, y);
164  cputc(c);
165 }
166 /*-----------------------------------------------------------------------------------*/
167 void
168 textcolor(unsigned char c)
169 {
170  color = c;
171 }
172 /*-----------------------------------------------------------------------------------*/
173 void
174 bgcolor(unsigned char c)
175 {
176 
177 }
178 /*-----------------------------------------------------------------------------------*/
179 void
180 bordercolor(unsigned char c)
181 {
182 
183 }
184 /*-----------------------------------------------------------------------------------*/
185 void
186 screensize(unsigned char *x, unsigned char *y)
187 {
188  *x = LIBCONIO_SCREEN_WIDTH;
189  *y = LIBCONIO_SCREEN_HEIGHT;
190 }
191 /*-----------------------------------------------------------------------------------*/