#include "graph16.h"
#include "mode16.h"
// le pointeur vers l'ecran
char far *screen=(char far*)MK_FP(0xb800,0);
// position x , y dans l'ecran
int xpos=0,ypos=0;
// couleur par defaut
int def_color=7;
// Fonction gotoxy
void gotoxy(int x,int y)
{
xpos=x;
ypos=y;
}
// Fonction clear_screen
void clear_screen()
{
char far *s=screen;
while(s<screen+MAX_COL*2*MAX_LI)
{
*(s++)=0;
}
}
// Fonction scroll_screen
void scroll_screen()
{
char far *s1=screen;
char far *s2=screen+MAX_COL*2;
int i,j;
for(i=0;i<MAX_LI-1;i++)
{
for(j=0;j<MAX_COL*2;j++)
{
*(s1++)=*(s2++);
}
}
for(j=0;j<MAX_COL*2;j++)
*(s1++)=0;
}
// Fonction print_text
void print_text(char * c)
{
char far * s;
while(*c!=0)
{
if(*c=='\n')
{
ypos++;
xpos=0;
c++;
}else
{
if(xpos>MAX_COL-1)
{
ypos++;
xpos=0;
}
if(ypos>MAX_LI-1)
{
scroll_screen();
ypos--;
}
s=screen+(ypos*MAX_COL+xpos)*2;
*(s++)=*(c++);
*s=def_color;
xpos++;
}
}
}
// Fonction set_color
int set_color(int color)
{
int old_color=def_color;
def_color=color;
return old_color;
}
void draw_bar(int percent)
{
int i=0;
gotoxy(0,22);
while(i<(percent*8/10)+1)
{
print_text("Û");
i++;
}
while(i<80)
{
print_text("³");
i++;
}
}