1 /*
2  * (c) 2008-2009 Jork Löser <jork@os.inf.tu-dresden.de>
3  *     economic rights: Technische Universität Dresden (Germany)
4  * This file is part of TUD:OS and distributed under the terms of the
5  * GNU Lesser General Public License 2.1.
6  * Please see the COPYING-LGPL-2.1 file for details.
7  */
8 #include <l4/util/spin.h>
9 
spin_gen(void * addr,int x,int y)10 static void spin_gen(void*addr,int x,int y){
11   unsigned char c,*p;
12 
13   p=(unsigned char*)addr+(x+80*y)*2;
14   c=*p;
15   c=(c=='|')?'/':(c=='/')?'-':(c=='-')?'\\':(c=='\\')?'|':'-';
16   *p=c;
17 }
18 
19 /****************************************************************************
20 *                                                                           *
21 *  l4_spin()     - spinning wheel at the hercules screen, position is from  *
22 *                  upper left. Each call turns the wheel.                   *
23 *  l4_spin_vga() - the same for vga.                                        *
24 *                                                                           *
25 ****************************************************************************/
l4_spin(int x,int y)26 L4_CV void l4_spin(int x,int y){
27   spin_gen((void*)0xb0000, x, y);
28 }
l4_spin_vga(int x,int y)29 L4_CV void l4_spin_vga(int x, int y){
30   spin_gen((void*)0xb8000, x, y);
31 }
32 
spin_n_text_gen(void * addr,int x,int y,int len,const char * s)33 static void spin_n_text_gen(void*addr, int x,int y, int len, const char*s){
34   unsigned char c,*p;
35   int i;
36 
37   p=(unsigned char*)addr+(x+len+80*y)*2;
38   c=*p;
39   c=(c=='|')?'/':(c=='/')?'-':(c=='-')?'\\':(c=='\\')?'|':'.';
40   if(c=='.'){
41     if(s){
42       p=(unsigned char*)addr+(x+80*y)*2;
43       for(i=0;i<len;i++){
44         *p++ = *s++;p++;
45       }
46     }
47     c = '-';
48   }
49   *p=c;
50 }
51 
52 /****************************************************************************
53 *                                                                           *
54 *  l4_spin_n_text()     - like spin(), but prints a text before the wheel.  *
55 *                         You must specify the length of the text (without  *
56 *                         the 0 at the end). The text is printed if no      *
57 *                         wheel-element is found at the wheel position.     *
58 *                         See macro l4_spin_text() for constant text.       *
59 *  l4_spin_n_text_vga() - same for vga.                                     *
60 *                                                                           *
61 ****************************************************************************/
l4_spin_n_text(int x,int y,int len,const char * s)62 L4_CV void l4_spin_n_text(int x,int y, int len, const char*s){
63   spin_n_text_gen((void*)0xb0000, x, y, len, s);
64 }
l4_spin_n_text_vga(int x,int y,int len,const char * s)65 L4_CV void l4_spin_n_text_vga(int x,int y, int len, const char*s){
66   spin_n_text_gen((void*)0xb8000, x, y, len, s);
67 }
68