File: TEXTMODE.C | Size: 3,136 bytes | Download file | Back to directory listing | BWPOW's homepage
#include <string.h>
#include <conio.h>
#include <all312.h>
 
typedef struct TEMP{
  int temp[2000];
  unsigned char zx1,zx2,zy1,zy2;
}TEMP;
TEMP temp[5];
 
 
int t=-1;
 
void _box_maker(int x1,int y1,int x2,int y2,char c1,char c2)
{
  char tbuf[80];
  int x,y,c;
  t++;
  gettext(x1,y1,x2+2,y2+1,temp[t].temp);
  temp[t].zx1=x1;temp[t].zx2=x2;
  temp[t].zy1=y1;temp[t].zy2=y2;
 
  textcolor(c1);textbackground(c2);
 
  tbuf[0]='É';
  for(x=0;x<x2-x1;x++)
    tbuf[x+1]='Í';
  tbuf[x]='»';
  tbuf[x+1]=0;
 
  gotoxy(x1,y1);
  cprintf("%s",tbuf);
 
  for(y=y1+1;y<y2;y++)
  {
    tbuf[0]='º';
    for(x=0;x<x2-x1;x++)
      tbuf[x+1]=' ';
    tbuf[x]='º';
    tbuf[x+1]=0;
 
    gotoxy(x1,y);
    cprintf("%s",tbuf);
  }
 
  tbuf[0]='È';
  for(x=0;x<x2-x1;x++)
    tbuf[x+1]='Í';
  tbuf[x]='¼';
  tbuf[x+1]=0;
 
  gotoxy(x1,y2);
  cprintf("%s",tbuf);
  textcolor(8);
  textbackground(0);
 
  for(y=y1+1;y<=y2;y++)
    for(x=0;x<2;x++){
      ScreenGetChar(&c,NULL,x+x2,y-1);
      gotoxy(x+1+x2,y);
      cprintf("%c",c);
    }
 
  for(x=x1+2;x<=x2+2;x++){
    ScreenGetChar(&c,NULL,x-1,y2);
    gotoxy(x,y2+1);
    cprintf("%c",c);
  }
 
  textcolor(c1);textbackground(c2);
}
 
void outtext_centre(char text[80])
{
  int x;
  x=wherex();
  gotoxy(x-strlen(text)/2,wherey());
  cprintf("%s",text);
}
 
 
 
void _delete_box()
{
  puttext(temp[t].zx1,temp[t].zy1,temp[t].zx2+2,temp[t].zy2+1,temp[t].temp);
  t--;
}
 
 
 
void smkalert3(char text1[40],char text2[40],char text3[40])
{
  _box_maker(18,8,61,17,15,4);
  textcolor(15);
  textbackground(4);
 
  gotoxy(40,10);
  outtext_centre(text1);
 
  gotoxy(40,12);
  outtext_centre(text2);
  gotoxy(40,13);
  outtext_centre(text3);
 
  gotoxy(40,16);
  textcolor(0);
  outtext_centre("Press ENTER");
 
  while(!key[KEY_ENTER]);
  while(key[KEY_ENTER]);
  _delete_box();
}
 
void smkalertg(char text1[40],char text2[40],char text3[40])
{
  _box_maker(18,8,61,17,15,1);
 
  gotoxy(40,10);
  outtext_centre(text1);
 
  gotoxy(40,12);
  outtext_centre(text2);
  gotoxy(40,13);
  outtext_centre(text3);
 
  gotoxy(40,16);
  textcolor(0);
  outtext_centre("Press ENTER");
 
  while(getch()!=13);
  _delete_box();
}
 
void prehral1()
{
  _box_maker(18,10,61,15,15,4);
 
  gotoxy(40,11);
  outtext_centre("You have lost!");
 
  gotoxy(40,12);
  outtext_centre("Your ship was destroyed!");
 
  gotoxy(40,14);
  textcolor(0);
  outtext_centre("Press ENTER");
 
  while(getch()!=13);
  _delete_box();
}
 
void prehral2()
{
  _box_maker(18,10,61,15,15,4);
 
  gotoxy(40,11);
  outtext_centre("Prehral si!");
 
  gotoxy(40,12);
  outtext_centre("Mesto bolo znicene.");
 
  gotoxy(40,14);
  textcolor(0);
  outtext_centre("Press ENTER");
 
  while(getch()!=13);
  _delete_box();
}
 
void vyhral1()
{
  _box_maker(18,10,61,15,15,2);
 
  gotoxy(40,11);
  outtext_centre("You won!");
 
  gotoxy(40,12);
  outtext_centre("You have saved your city.");
 
  gotoxy(40,14);
  textcolor(0);
  outtext_centre("Press ENTER");
 
  while(getch()!=13);
  _delete_box();
}