Contiki 3.x
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  *
33  */
34 
35 #include <string.h>
36 #include "contiki.h"
37 #include "libconio.h"
38 
39 static unsigned char cursx, cursy;
40 static unsigned char reversed;
41 static unsigned char color;
42 
43 /*-----------------------------------------------------------------------------------*/
44 unsigned char
45 wherex(void)
46 {
47  return cursx;
48 }
49 /*-----------------------------------------------------------------------------------*/
50 unsigned char
51 wherey(void)
52 {
53  return cursy;
54 }
55 /*-----------------------------------------------------------------------------------*/
56 void
57 clrscr(void)
58 {
59  unsigned char x, y;
60 
61  for(x = 0; x < LIBCONIO_SCREEN_WIDTH; ++x) {
62  for(y = 0; y < LIBCONIO_SCREEN_HEIGHT; ++y) {
63  gotoxy(x, y);
64  cputc(' ');
65  }
66  }
67 }
68 /*-----------------------------------------------------------------------------------*/
69 void
70 revers(unsigned char c)
71 {
72  reversed = c;
73 }
74 /*-----------------------------------------------------------------------------------*/
75 void
76 cputc(char c)
77 {
78  ctk_arch_draw_char(c, cursx, cursy, reversed, color);
79  ++cursx;
80 }
81 /*-----------------------------------------------------------------------------------*/
82 void
83 cputs(char *str)
84 {
85  while(*str != 0) {
86  cputc(*str++);
87  }
88 
89  /* int i;
90  for(i = 0; i < strlen(str); ++i) {
91  cputc(str[i]);
92  }*/
93 }
94 /*-----------------------------------------------------------------------------------*/
95 void
96 cclear(unsigned char length)
97 {
98  int i;
99  for(i = 0; i < length; ++i) {
100  cputc(' ');
101  }
102 }
103 /*-----------------------------------------------------------------------------------*/
104 void
105 chline(unsigned char length)
106 {
107  int i;
108  for(i = 0; i < length; ++i) {
109  cputc('-');
110  }
111 }
112 /*-----------------------------------------------------------------------------------*/
113 void
114 cvline(unsigned char length)
115 {
116  int i;
117  for(i = 0; i < length; ++i) {
118  cputc('|');
119  --cursx;
120  ++cursy;
121  }
122 }
123 /*-----------------------------------------------------------------------------------*/
124 void
125 gotoxy(unsigned char x, unsigned char y)
126 {
127  cursx = x;
128  cursy = y;
129 }
130 /*-----------------------------------------------------------------------------------*/
131 void
132 cclearxy(unsigned char x, unsigned char y, unsigned char length)
133 {
134  gotoxy(x, y);
135  cclear(length);
136 }
137 /*-----------------------------------------------------------------------------------*/
138 void
139 chlinexy(unsigned char x, unsigned char y, unsigned char length)
140 {
141  gotoxy(x, y);
142  chline(length);
143 }
144 /*-----------------------------------------------------------------------------------*/
145 void
146 cvlinexy(unsigned char x, unsigned char y, unsigned char length)
147 {
148  gotoxy(x, y);
149  cvline(length);
150 }
151 /*-----------------------------------------------------------------------------------*/
152 void
153 cputsxy(unsigned char x, unsigned char y, char *str)
154 {
155  gotoxy(x, y);
156  cputs(str);
157 }
158 /*-----------------------------------------------------------------------------------*/
159 void
160 cputcxy(unsigned char x, unsigned char y, char c)
161 {
162  gotoxy(x, y);
163  cputc(c);
164 }
165 /*-----------------------------------------------------------------------------------*/
166 void
167 textcolor(unsigned char c)
168 {
169  color = c;
170 }
171 /*-----------------------------------------------------------------------------------*/
172 void
173 bgcolor(unsigned char c)
174 {
175 
176 }
177 /*-----------------------------------------------------------------------------------*/
178 void
179 bordercolor(unsigned char c)
180 {
181 
182 }
183 /*-----------------------------------------------------------------------------------*/
184 void
185 screensize(unsigned char *x, unsigned char *y)
186 {
187  *x = LIBCONIO_SCREEN_WIDTH;
188  *y = LIBCONIO_SCREEN_HEIGHT;
189 }
190 /*-----------------------------------------------------------------------------------*/