001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019 #include <crt.h>
020 #include <libc.h>
021 #include <string.h>
022 #include <stdarg.h>
023 #include <debug.h>
024
025
026
027
028
029
030
031 static char *str1 =
032 " _ _ _ _ ___ _ _ _ _ _ "
033 " | | | | ___ | | | | ___ |_ _| __ _ _ __ ___ | |_ | |__ _ __ ___ __ _ __| | / | | |"
034 " | |_| | / _ \\ | | | | / _ \\ | | / _` | | '_ ` _ \\ | __| | '_ \\ | '__| / _ \\ / _` | / _` | | | | |"
035 " | _ | | __/ | | | | | (_) | _ | | | (_| | | | | | | | | |_ | | | | | | | __/ | (_| | | (_| | | | |_|"
036 " |_| |_| \\___| |_| |_| \\___/ ( ) |___| \\__,_| |_| |_| |_| \\__| |_| |_| |_| \\___| \\__,_| \\__,_| |_| (_)"
037 " |/ ";
038
039 static char *str2 =
040 " _ _ _ _ ___ _ _ _ ____ _ "
041 " | | | | ___ | | | | ___ |_ _| __ _ _ __ ___ | |_ | |__ _ __ ___ __ _ __| | |___ \\ | |"
042 " | |_| | / _ \\ | | | | / _ \\ | | / _` | | '_ ` _ \\ | __| | '_ \\ | '__| / _ \\ / _` | / _` | __) | | |"
043 " | _ | | __/ | | | | | (_) | _ | | | (_| | | | | | | | | |_ | | | | | | | __/ | (_| | | (_| | / __/ |_|"
044 " |_| |_| \\___| |_| |_| \\___/ ( ) |___| \\__,_| |_| |_| |_| \\__| |_| |_| |_| \\___| \\__,_| \\__,_| |_____| (_)"
045 " |/ ";
046
047
048
049
050 static struct x86_videomem_char
051 {
052 unsigned char character;
053 unsigned char attribute;
054 } * video;
055
056
057 static void print(int line, int col, char c, unsigned char attr)
058 {
059 video[line*80 + col].character = c;
060 video[line*80 + col].attribute = attr;
061 }
062
063
064
065
066
067 static void print_banner(int top_line, const char * str, int nlines,
068 unsigned char attr, unsigned pause_ms,
069 int direction)
070 {
071 int nbcols = strnlen(str, 16384) / nlines;
072 int base_char = 0;
073
074 while (1)
075 {
076 int col;
077
078 for (col = 0 ; col < 80 ; col ++)
079 {
080 int col_in_str = (col + base_char) % (nbcols + 20);
081 int line;
082
083 for (line = 0 ; line < nlines ; line ++)
084 if (col_in_str < nbcols)
085 print(top_line + line, col, str[line*nbcols + col_in_str], attr);
086 else
087 print(top_line + line, col, ' ', attr);
088 }
089
090 _sos_nanosleep(0, pause_ms * 1000000);
091
092 if (direction > 0)
093 base_char ++;
094 else
095 base_char --;
096
097 if (base_char < 0)
098 base_char = nbcols + 20 - 1;
099 }
100 }
101
102
103 struct thread_param
104 {
105 int top_line;
106 const char * str;
107 int nlines;
108 unsigned char attr;
109 unsigned int pause_ms;
110 int direction;
111 };
112
113
114 static void banner_thread(const struct thread_param *p)
115 {
116 print_banner(p->top_line, p->str, p->nlines, p->attr,
117 p->pause_ms, p->direction);
118 }
119
120 static struct thread_param p1, p2;
121 int main()
122 {
123 int fd;
124
125
126 fd = open("/dev/mem", O_RDWR);
127 video = mmap(0, 4096,
128 PROT_READ | PROT_WRITE,
129 MAP_SHARED,
130 fd, 0xb8000);
131 close(fd);
132
133 p1.top_line = 3;
134 p1.str = str1;
135 p1.nlines = 6;
136 p1.attr = 14 | (7 << 4);
137 p1.pause_ms = 10;
138 p1.direction = 1;
139 _sos_new_thread((sos_thread_func_t*)banner_thread, (void*) & p1, 8192);
140
141 p2.top_line = 10;
142 p2.str = str2;
143 p2.nlines = 6;
144 p2.attr = (4 << 4) | (7 << 4);
145 p2.pause_ms = 20;
146 p2.direction = -1;
147 _sos_new_thread((sos_thread_func_t*)banner_thread, (void*) & p2, 8192);
148
149 return 0;
150 }