Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, October 16, 2026

Diff for games/mines/mines.c between version 1.1 and 1.2

version 1.1, 2003/05/11 18:48:45 version 1.2, 2003/05/18 22:51:41
Line 1 
Line 1 
 /* $Platon: $ */  /* $Platon: games/mines/mines.c,v 1.1.1.1 2003/05/11 18:48:45 nepto Exp $ */
   
 #define EXESIZE/* or mines.exe EOF pointer */52650L  
 /* CONSTS */  /* CONSTS */
 #define EXENAME     "mines.exe"  #define EXENAME     "mines.exe"
 #define ERR_ARGC    "Pr¡lis vela argumentov v pr¡kazovom riadku."  #define ERR_ARGC    "Pr¡lis vela argumentov v pr¡kazovom riadku."
Line 11 
Line 10 
 #define ERR_MEMORY  "Nedostatok volnej pam„te."  #define ERR_MEMORY  "Nedostatok volnej pam„te."
 #define ERR_GRAPH   "Chyba grafiky:"  #define ERR_GRAPH   "Chyba grafiky:"
   
 #define MAXHSCITEMS (10) /* min.10, max.10 */  
 #define HSCNAMELEN  (20) /* min.N/A, max.35 */  
   
 #define MINBARSIZE      (8)  #define MINBARSIZE      (8)
 #define MAXBARSIZE      (18)  #define MAXBARSIZE      (18)
 #define DEFDIFF         (1)  #define DEFDIFF         (1)
Line 82 
Line 78 
 #include <menu.h>  #include <menu.h>
   
 /* #include "data.h" FOR MINES IMAGE */  /* #include "data.h" FOR MINES IMAGE */
   #include "hiscore.h"
   
 #if PLATON_SYSTEM_MSDOS  #if PLATON_SYSTEM_MSDOS
 #  define RAND_INT(__lo, __hi)  (__lo + random(__hi - __lo + 1))  #  define RAND_INT(__lo, __hi)  (__lo + random(__hi - __lo + 1))
Line 105  typedef struct stsquare
Line 102  typedef struct stsquare
         BYTE sqmark;        /* Square is marked */          BYTE sqmark;        /* Square is marked */
 } STSQUARE;  } STSQUARE;
   
 typedef struct hscitem  
 {  
         char name[HSCNAMELEN+1];  
         BYTE nx,ny,diff;  
         struct date date;  
         struct time time;  
 } HSCITEM;  
 /* /////////////////////////////////////////////////////////////////////// */  /* /////////////////////////////////////////////////////////////////////// */
 /* GLOBAL IDENTIFICATORS */  /* GLOBAL IDENTIFICATORS */
 #if PLATON_SYSTEM_MSDOS  #if PLATON_SYSTEM_MSDOS
Line 185  void fade_in(WORD steps);
Line 175  void fade_in(WORD steps);
   
 /* High scores handling */  /* High scores handling */
 void HscTable(void);  void HscTable(void);
 FILE*OpenHsc(void);  clock_t time2clock(struct time time);
 BYTE GetItems(void);  
 void GetHscItem(HSCITEM*item,BYTE n);  
 void SetHscItem(HSCITEM*item,BYTE n);  
 void CodeStruct(BYTE*p,BYTE size);  
 clock_t Time2Clock(struct time time);  
   
 /* strplus.h extract */  /* strplus.h extract */
 char *strdel(char *s);  char *strdel(char *s);
Line 225  int main(int argc,char*argv[])
Line 210  int main(int argc,char*argv[])
                 puts(ERR_MOUSE);                  puts(ERR_MOUSE);
                 return 1;                  return 1;
         }          }
   #if PLATON_SYSTEM_MSDOS
           hiscore_init(argv[0], HISCORE_AUTODETECT);
   #endif
   #if PLATON_SYSTEM_LINUX
           hiscore_init("/var/lib/games/mines/hiscore.dat", 0L);
   #endif
         if (GraphInit() < 0)          if (GraphInit() < 0)
                 return 1;                  return 1;
         strncpy(strchr(infostr1,'?'),__APPVERSION__,strlen(__APPVERSION__));          strncpy(strchr(infostr1,'?'),__APPVERSION__,strlen(__APPVERSION__));
Line 260  int main(int argc,char*argv[])
Line 251  int main(int argc,char*argv[])
  *                           F U N C T I O N S                           *   *                           F U N C T I O N S                           *
  *                                                                       *   *                                                                       *
  *************************************************************************/   *************************************************************************/
 int brkfnc(void)  int brkfnc(void) /* {{{ */
 {  {
         gotoxy(1,1);          gotoxy(1,1);
         return(1);          return(1);
 }  } /* }}} */
   
 void koniec(void)  void koniec(void) /* {{{ */
 {  {
         my_graph_close();          my_graph_close();
           hiscore_close();
         fcloseall();          fcloseall();
         endstring("MINES");          endstring("MINES");
   
Line 314  void koniec(void)
Line 306  void koniec(void)
                         break;                          break;
         }          }
         textattr(0x07);cputs("\n\r");          textattr(0x07);cputs("\n\r");
 }  } /* }}} */
   
 void WriteError(void)  void WriteError(void) /* {{{ */
 {  {
         my_graph_close();          my_graph_close();
         puts(ERR_WRITE);          puts(ERR_WRITE);
         exit(1);          exit(1);
 }  } /* }}} */
   
 /*----------------------------------------------------------------------*/  /*----------------------------------------------------------------------*/
 BYTE MainMenu(void)  BYTE MainMenu(void) /* {{{ */
 {  {
         register BYTE but;          register BYTE but;
         WORD x,y;          WORD x,y;
Line 458  BYTE MainMenu(void)
Line 450  BYTE MainMenu(void)
                                 break;                                  break;
                 };                  };
         }          }
 }  } /* }}} */
   
 /*----------------------------------------------------------------------*/  /*----------------------------------------------------------------------*/
 int GraphInit(void)  int GraphInit(void) /* {{{ */
 {  {
 #if 0  #if 0
         int gdriver=9,gmode=2,errorcode;          int gdriver=9,gmode=2,errorcode;
Line 480  int GraphInit(void)
Line 472  int GraphInit(void)
         settextjustify(CENTER_TEXT, CENTER_TEXT);          settextjustify(CENTER_TEXT, CENTER_TEXT);
         settextstyle(0,0,1);          settextstyle(0,0,1);
         return 0;          return 0;
 }  } /* }}} */
   
 /*----------------------------------------------------------------------*/  /*----------------------------------------------------------------------*/
 void SetData(void)  void SetData(void) /* {{{ */
 {  {
         nx = min(nx,MAXNX);          nx = min(nx,MAXNX);
         ny = min(ny,MAXNY);          ny = min(ny,MAXNY);
Line 496  void SetData(void)
Line 488  void SetData(void)
                 puts(ERR_MEMORY);                  puts(ERR_MEMORY);
                 exit(1);                  exit(1);
         }          }
 }  } /* }}} */
   
 /*----------------------------------------------------------------------*/  /*----------------------------------------------------------------------*/
 void SetMines()  void SetMines() /* {{{ */
 {  {
         STSQUARE *p;          STSQUARE *p;
         int i,x,y,a,b;          int i,x,y,a,b;
Line 545  void SetMines()
Line 537  void SetMines()
                                 value(x,y)+=(value(a,b) == MINE);                                  value(x,y)+=(value(a,b) == MINE);
                 }                  }
         }          }
 }  } /* }}} */
   
 /*----------------------------------------------------------------------*/  /*----------------------------------------------------------------------*/
 /*   If status=1 then draw the square up, if it's 0 then draw it down */  /*   If status=1 then draw the square up, if it's 0 then draw it down */
 void SetSquare(WORD x,WORD y,BYTE status)  void SetSquare(WORD x,WORD y,BYTE status) /* {{{ */
 {  {
         WORD x1,x2,y1,y2;          WORD x1,x2,y1,y2;
         if (underinfo(x,y)&&infosafe!=NULL)          if (underinfo(x,y)&&infosafe!=NULL)
Line 588  void SetSquare(WORD x,WORD y,BYTE status
Line 580  void SetSquare(WORD x,WORD y,BYTE status
                 line(x1,y1,x1,y2);                  line(x1,y1,x1,y2);
                 line(x1,y1,x2,y1);                  line(x1,y1,x2,y1);
         }          }
 }  } /* }}} */
   
 /*----------------------------------------------------------------------*/  /*----------------------------------------------------------------------*/
 /* this expect mouse turned on */  /* this expect mouse turned on */
 void WriteInfo(WORD x,WORD y)  void WriteInfo(WORD x, WORD y) /* {{{ */
 {  {
         register BYTE k;          register BYTE k;
         char txt[8];          char txt[8];
Line 633  void WriteInfo(WORD x,WORD y)
Line 625  void WriteInfo(WORD x,WORD y)
                 }                  }
         }          }
         showmouse();          showmouse();
 }  } /* }}} */
   
 /*----------------------------------------------------------------------*/  /*----------------------------------------------------------------------*/
 /*   Here we do all the job */  /*   Here we do all the job */
 BYTE DoAll(void)  BYTE DoAll(void) /* {{{ */
 {  {
         WORD x,y,xold=0xffff,yold=0,mlstant=0,mrstant=0,cminesold=0;          WORD x,y,xold=0xffff,yold=0,mlstant=0,mrstant=0,cminesold=0;
         BYTE but = 0, first_click = 1;          BYTE but = 0, first_click = 1;
Line 907  BYTE DoAll(void)
Line 899  BYTE DoAll(void)
                                         return(0);                                          return(0);
                         }                          }
                 } else { /* GAME WIN */                  } else { /* GAME WIN */
                         register BYTE k;                          register int k, items;
                         HSCITEM item;                          HISCORE_ITEM item;
                         char s[80];                          char s[80];
                         hidemouse();                          hidemouse();
                         DrawDefWindow(500,190,290,"Hotovo!");                          DrawDefWindow(500,190,290,"Hotovo!");
Line 919  BYTE DoAll(void)
Line 911  BYTE DoAll(void)
                                         (unsigned)((curr/CLOCKS_PER_SEC)/60)%60,                                          (unsigned)((curr/CLOCKS_PER_SEC)/60)%60,
                                         (unsigned)(curr/CLOCKS_PER_SEC)%60);                                          (unsigned)(curr/CLOCKS_PER_SEC)%60);
                         setcolor(LIGHTGREEN);outtextxy(getmaxx()/2,245,s);                          setcolor(LIGHTGREEN);outtextxy(getmaxx()/2,245,s);
                         k=0;while (s[k]!=EOS) {if (!isdigit(s[k]))s[k]=SPC;k++;}                          for (k=0; s[k]!=EOS; k++)
                                   if (!isdigit(s[k]))
                                           s[k]=SPC;
                         setcolor(RED);outtextxy(getmaxx()/2+1,245+1,s);                          setcolor(RED);outtextxy(getmaxx()/2+1,245+1,s);
                         setcolor(LIGHTRED);outtextxy(getmaxx()/2,245,s);                          setcolor(LIGHTRED);outtextxy(getmaxx()/2,245,s);
                         showmouse();                          showmouse();
                         while (!(releasebutton(0,&x,&y))||!isinnormbutton(x,y,getmaxx()/2,262))if (kbhit())getch();                          while (!(releasebutton(0,&x,&y))
                         k=GetItems();                                          ||!isinnormbutton(x,y,getmaxx()/2,262))
                         for (k=0;k<=min(GetItems(),MAXHSCITEMS-1);k++) {                                  if (kbhit())
                                 if (k==GetItems())break;                                          getch();
                                 GetHscItem(&item,k);                          if ((items = hiscore_items()) >= 0) {
                                 if (getmines(nx,ny,diff)>getmines(item.nx,item.ny,item.diff))break;                                  for (k = 0; k <= min(items, HISCORE_MAX_ITEMS - 1); k++) {
                                 if (getmines(nx,ny,diff)==getmines(item.nx,item.ny,item.diff)) {                                          if (k == items)
                                         if (diff>item.diff)break;                                                  break;
                                         if (diff==item.diff) {                                          if (hiscore_get_item(&item, k) < 0)
                                                 if (curr<Time2Clock(item.time))break;                                                  WriteError();
                                           if (getmines(nx,ny,diff) > getmines(item.nx,item.ny,item.diff))
                                                   break;
                                           if (getmines(nx,ny,diff) == getmines(item.nx,item.ny,item.diff)) {
                                                   if (diff > item.diff)
                                                           break;
                                                   if (diff == item.diff) {
                                                           if (curr < time2clock(item.time))
                                                                   break;
                                                   }
                                           }
                                           if (k == HISCORE_MAX_ITEMS - 1) {
                                                   k = 0xff;
                                                   break;
                                         }                                          }
                                 }                                  }
                                 if (k==MAXHSCITEMS-1) {k=0xff;break;}                                  if (k!=0xff) {
                         }                                          register BYTE count=0,c;
                         if (k!=0xff) {                                          hidemouse();
                                 register BYTE count=0,c;                                          DrawDefWindow(550,207,273,"Zadaj svoje meno:");
                                 hidemouse();DrawDefWindow(550,207,273,"Zadaj svoje meno:");                                          memset(item.name,EOS,HISCORE_NAME_LEN+1);
                                 memset(item.name,EOS,HSCNAMELEN+1);                                          while (((c=getch())!=EOL)||(!strlen(item.name))) {
                                 while (((c=getch())!=EOL)||(!strlen(item.name))) {                                                  setcolor(BLUE);outtextxy(getmaxx()/2,257,item.name);
                                         setcolor(BLUE);outtextxy(getmaxx()/2,257,item.name);                                                  switch (c) {
                                         switch (c) {                                                          case EOL:break;
                                                 case EOL:break;                                                          case NUL:if (getch()!=DELETE)break;
                                                 case NUL:if (getch()!=DELETE)break;                                                          case BS:if (count) {count--;item.name[count]=EOS;}
                                                 case BS:if (count) {count--;item.name[count]=EOS;}                                                                                  break;
                                                           default:if (c>=0x20&&c<0xff) /* better than isprint(c) */
                                                                                   if (count < HISCORE_NAME_LEN) {
                                                                                           item.name[count] = c;
                                                                                           count++;
                                                                                   }
                                                                         break;                                                                          break;
                                                 default:if (c>=0x20&&c<0xff) /* better than isprint(c) */                                                  }
                                                                         if (count<HSCNAMELEN) {                                                  setcolor(k>2?LIGHTCYAN:ColorConvert(4-k));outtextxy(getmaxx()/2,257,item.name);
                                                                                 item.name[count]=c;  
                                                                                 count++;  
                                                                         }  
                                                                 break;  
                                         }                                          }
                                         setcolor(k>2?LIGHTCYAN:ColorConvert(4-k));outtextxy(getmaxx()/2,257,item.name);                                          showmouse();
                                           item.nx   = nx;
                                           item.ny   = ny;
                                           item.diff = diff;
                                           getdate(&item.date);
                                           item.time.ti_hour = (unsigned)((curr/CLOCKS_PER_SEC)/60)/60;
                                           item.time.ti_min  = (unsigned)((curr/CLOCKS_PER_SEC)/60)%60;
                                           item.time.ti_sec  = (unsigned)(curr/CLOCKS_PER_SEC)%60;
                                           if (hiscore_set_item(&item, k) < 0)
                                                   WriteError();
                                           HscTable();
                                           FadeOut();
                                 }                                  }
                                 showmouse();  
                                 item.nx   = nx;  
                                 item.ny   = ny;  
                                 item.diff = diff;  
                                 getdate(&item.date);  
                                 item.time.ti_hour = (unsigned)((curr/CLOCKS_PER_SEC)/60)/60;  
                                 item.time.ti_min  = (unsigned)((curr/CLOCKS_PER_SEC)/60)%60;  
                                 item.time.ti_sec  = (unsigned)(curr/CLOCKS_PER_SEC)%60;  
                                 SetHscItem(&item, k);  
                                 HscTable();  
                                 FadeOut();  
                         }                          }
                 }                  }
         }          }
         return 0;          return 0;
 }  } /* }}} */
   
 /*----------------------------------------------------------------------*/  /*----------------------------------------------------------------------*/
 void Help(void)  void Help(void) /* {{{ */
 {  {
         WORD x,y;          WORD x,y;
         do{          do{
Line 1106  if (OpenNearSquares(x,y)==YES)break;\n\
Line 1114  if (OpenNearSquares(x,y)==YES)break;\n\
                                 }                                  }
                         }                          }
                 }                  }
         }while (x!=0xffff||y!=0xffff);          } while (x != 0xffff || y != 0xffff);
 }  } /* }}} */
   
 /*----------------------------------------------------------------------*/  /*----------------------------------------------------------------------*/
 void ShowHelpText(WORD x,WORD y,WORD linesize,WORD defcolor,WORD inscolor,char*helpstr)  void ShowHelpText(WORD x,WORD y,WORD linesize,WORD defcolor,WORD inscolor,char*helpstr) /* {{{ */
 {  {
         register BYTE count=0;          register BYTE count=0;
         register WORD posx;          register WORD posx;
Line 1147  void ShowHelpText(WORD x,WORD y,WORD lin
Line 1155  void ShowHelpText(WORD x,WORD y,WORD lin
                 count++;                  count++;
         }          }
         settextjustify(CENTER_TEXT,CENTER_TEXT);          settextjustify(CENTER_TEXT,CENTER_TEXT);
 }  } /* }}} */
   
 /*----------------------------------------------------------------------*/  /*----------------------------------------------------------------------*/
 /* !!! mouse must be turned off when entering function */  /* !!! mouse must be turned off when entering function */
 void OpenSquare(WORD x,WORD y)  void OpenSquare(WORD x, WORD y) /* {{{ */
 {  {
         char num[2]="0";          char num[2]="0";
         register int a,b;          register int a,b;
Line 1209  void OpenSquare(WORD x,WORD y)
Line 1217  void OpenSquare(WORD x,WORD y)
                 }                  }
         }          }
         settextstyle(0,0,itabsize+1);          settextstyle(0,0,itabsize+1);
 }       /* OpenSquare */  } /* }}} */
   
 /*----------------------------------------------------------------------*/  /*----------------------------------------------------------------------*/
 /* Open the sorrounded squares. Returns != 0 if I activated a mine */  /* Open the sorrounded squares. Returns != 0 if I activated a mine */
 WORD  OpenNearSquares(WORD x,WORD y){  WORD  OpenNearSquares(WORD x,WORD y) /* {{{ */
   {
         register int a,b;          register int a,b;
         register WORD suma=0;          register WORD suma=0;
   
Line 1299  WORD  OpenNearSquares(WORD x,WORD y){
Line 1308  WORD  OpenNearSquares(WORD x,WORD y){
         }          }
         else          else
                 return 0;                  return 0;
 }       /* OpenNearSquares */  } /* }}} */
   
 /*----------------------------------------------------------------------*/  /*----------------------------------------------------------------------*/
 void DrawDiffButton(WORD x,WORD y,BYTE diff,BYTE label)  void DrawDiffButton(WORD x,WORD y,BYTE diff,BYTE label) /* {{{ */
 {  {
         char*diffstr[]={"Lahk ","Norm lna","Tazk ","Velmi tazk "};          char*diffstr[]={"Lahk ","Norm lna","Tazk ","Velmi tazk "};
         DrawNormButton(x,y,label?"Obtiaznost":"",diffstr[diff],BLUE,!diff?CYAN:ColorConvert(diff+1),WHITE);          DrawNormButton(x,y,label?"Obtiaznost":"",diffstr[diff],BLUE,
 }                          !diff?CYAN:ColorConvert(diff+1),WHITE);
   } /* }}} */
   
 void DrawDefWindow(WORD sizex,WORD y1,WORD y2,char*text)  void DrawDefWindow(WORD sizex,WORD y1,WORD y2,char*text) /* {{{ */
 {  {
         DrawWindow((getmaxx()-sizex)/2,y1,getmaxx()-(getmaxx()-sizex)/2,y2,BLUE,WHITE);          DrawWindow((getmaxx()-sizex)/2,y1,getmaxx()-(getmaxx()-sizex)/2,y2,BLUE,WHITE);
         if (text!=NULL) {          if (text!=NULL) {
                 line((getmaxx()-sizex)/2+10,y1+33,getmaxx()-10-(getmaxx()-sizex)/2,y1+33);                  line((getmaxx()-sizex)/2+10,y1+33,getmaxx()-10-(getmaxx()-sizex)/2,y1+33);
                 settextstyle(0,0,2);outtextxy(getmaxx()/2,y1+19,text);                  settextstyle(0,0,2);outtextxy(getmaxx()/2,y1+19,text);
         }          }
 }  } /* }}} */
   
 void DrawWindow(WORD x1,WORD y1,WORD x2,WORD y2,BYTE bckcolor,BYTE rctcolor)  void DrawWindow(WORD x1,WORD y1,WORD x2,WORD y2,BYTE bckcolor,BYTE rctcolor) /* {{{ */
 {  {
         setfillstyle(1,bckcolor);setcolor(rctcolor);          setfillstyle(1,bckcolor);setcolor(rctcolor);
         bar(x1,y1,x2,y2);          bar(x1,y1,x2,y2);
         rectangle(x1+1,y1+1,x2-1,y2-1);          rectangle(x1+1,y1+1,x2-1,y2-1);
 }  } /* }}} */
   
 void DrawNormButton(WORD x,WORD y,char*label,char*str,BYTE bckcolor,BYTE rctcolor,BYTE txtcolor)  void DrawNormButton(WORD x,WORD y,char*label,char*str,BYTE bckcolor,BYTE rctcolor,BYTE txtcolor) /* {{{ */
 {  {
         DrawWindow(x-49,y,x+49,y+18,bckcolor,rctcolor);          DrawWindow(x-49,y,x+49,y+18,bckcolor,rctcolor);
         settextstyle(0,0,1);outtextxy(x,y+10,str);          settextstyle(0,0,1);
         setcolor(txtcolor);outtextxy(x,y-7,label);          outtextxy(x,y+10,str);
 }          setcolor(txtcolor);
           outtextxy(x,y-7,label);
   } /* }}} */
   
 void DrawNumButton(WORD x,WORD y,char*label,WORD num,BYTE bckcolor,BYTE rctcolor,BYTE txtcolor)  void DrawNumButton(WORD x,WORD y,char*label,WORD num,BYTE bckcolor,BYTE rctcolor,BYTE txtcolor) /* {{{ */
 {  {
         char str[4];          char str[4];
         DrawWindow(x-49,y,x+49,y+18,bckcolor,rctcolor);          DrawWindow(x-49,y,x+49,y+18,bckcolor,rctcolor);
Line 1348  void DrawNumButton(WORD x,WORD y,char*la
Line 1360  void DrawNumButton(WORD x,WORD y,char*la
         outtextxy(x+36,y+11,"+");          outtextxy(x+36,y+11,"+");
         DrawNumPlus10(x-46,y+14,'-');          DrawNumPlus10(x-46,y+14,'-');
         DrawNumPlus10(x+38,y+14,'+');          DrawNumPlus10(x+38,y+14,'+');
 }  } /* }}} */
   
 void DrawNumPlus10(WORD x,WORD y,BYTE c)  void DrawNumPlus10(WORD x,WORD y,BYTE c) /* {{{ */
 {  {
         switch (c) {          switch (c) {
                 case '+':line(x+1,y,x+1,y+2);                  case '+':line(x+1,y,x+1,y+2);
Line 1359  void DrawNumPlus10(WORD x,WORD y,BYTE c)
Line 1371  void DrawNumPlus10(WORD x,WORD y,BYTE c)
                                  rectangle(x+6,y,x+8,y+2);                                   rectangle(x+6,y,x+8,y+2);
                                  break;                                   break;
         }          }
 }  } /* }}} */
   
 BYTE YesNo(int x,int y)  BYTE YesNo(int x,int y) /* {{{ */
 {  {
         void*safe;          void*safe;
         register BYTE ret;          register BYTE ret;
Line 1375  BYTE YesNo(int x,int y)
Line 1387  BYTE YesNo(int x,int y)
         ret=menu(yesnostr,x+28,y+5,0,2,17,RED,LIGHTGREEN);          ret=menu(yesnostr,x+28,y+5,0,2,17,RED,LIGHTGREEN);
         hidemouse();putimage(x,y,safe,COPY_PUT);showmouse();          hidemouse();putimage(x,y,safe,COPY_PUT);showmouse();
         free(safe);          free(safe);
         if (ret)return(NO);          return ret ? NO : YES;
         return(YES);  } /* }}} */
 }  
   
 BYTE ColorConvert(BYTE c)  BYTE ColorConvert(BYTE c) /* {{{ */
 {  {
         return(c==1?LIGHTBLUE:c==2?LIGHTGREEN:c==3?YELLOW:c==4?LIGHTRED:LIGHTMAGENTA);          switch (c) {
 }                  case 1: return LIGHTBLUE;
                   case 2: return LIGHTGREEN;
                   case 3: return YELLOW;
                   case 4: return LIGHTRED;
                   default: return LIGHTMAGENTA;
           }
   } /* }}} */
   
 void fade_out(WORD steps)  void fade_out(WORD steps) /* {{{ */
 {  {
         register WORD k,l;          register WORD k,l;
         struct palettetype start_pal,curr_pal;          struct palettetype start_pal,curr_pal;
Line 1396  void fade_out(WORD steps)
Line 1413  void fade_out(WORD steps)
                 }                  }
                 setallpalette(&curr_pal);                  setallpalette(&curr_pal);
         }          }
 }  } /* }}} */
   
 void fade_in(WORD steps)  void fade_in(WORD steps) /* {{{ */
 {  {
         register WORD k,l;          register WORD k,l;
         struct palettetype curr_pal;          struct palettetype curr_pal;
Line 1408  void fade_in(WORD steps)
Line 1425  void fade_in(WORD steps)
                         curr_pal.colors[k]=getdefaultpalette()->colors[k]*(l+1)/steps;                          curr_pal.colors[k]=getdefaultpalette()->colors[k]*(l+1)/steps;
                 setallpalette(&curr_pal);                  setallpalette(&curr_pal);
         }          }
 }  } /* }}} */
   
 /* /////////////////////////////////////////////// */  /* /////////////////////////////////////////////// */
 void HscTable(void)  void HscTable(void) /* {{{ */
 {  {
         register BYTE k,l;          register BYTE k,l;
         WORD x,y;          WORD x,y;
         HSCITEM item;          HISCORE_ITEM item;
         char s[80];          char s[80];
         hidemouse();          hidemouse();
         DrawDefWindow(getmaxx(),0,getmaxy(),"Tabulka najleps¡ch");          DrawDefWindow(getmaxx(),0,getmaxy(),"Tabulka najleps¡ch");
         for (k=0;k<min(GetItems(),MAXHSCITEMS);k++) {          for (k=0;k<min(hiscore_items(),HISCORE_MAX_ITEMS);k++) {
                 GetHscItem(&item,k);                  if (hiscore_get_item(&item,k) < 0)
                           WriteError();
                 /* LINE */                  /* LINE */
                 setcolor(WHITE);                  setcolor(WHITE);
                 if (k)                  if (k)
Line 1455  void HscTable(void)
Line 1473  void HscTable(void)
                         ||!isinnormbutton(x,y,getmaxx()/2,getmaxy()-31))                          ||!isinnormbutton(x,y,getmaxx()/2,getmaxy()-31))
                 if (kbhit())                  if (kbhit())
                         getch();                          getch();
 }  } /* }}} */
   
 FILE*OpenHsc(void)  clock_t time2clock(struct time time) /* {{{ */
 {  
         FILE*f=fopen(EXENAME,"rb+");  
         if (f==NULL)  
                 WriteError();  
         /*  if (f==NULL) {  
                 if ((f=fopen(HSCNAME,"wb+"))==NULL)WriteError();  
                 }*/  
         return(f);  
 }  
   
 BYTE GetItems(void)  
 {  
         register BYTE items;  
         FILE*f=OpenHsc();  
         fseek(f,0L,SEEK_END);  
         items=(ftell(f)-EXESIZE)/sizeof(HSCITEM);  
         fclose(f);  
         return(items);  
 }  
   
 void GetHscItem(HSCITEM*item,BYTE n)  
 {  
         FILE*f=OpenHsc();  
         if (fseek(f,EXESIZE+n*sizeof(HSCITEM),SEEK_SET)  
                         ||fread((void*)item,sizeof(HSCITEM),1,f)!=1)WriteError();  
         fclose(f);  
         CodeStruct((BYTE*)item,sizeof(HSCITEM));  
 }  
   
 void SetHscItem(HSCITEM*item,BYTE n)  
 {  
         int k=GetItems();  
         FILE*f=OpenHsc();  
         HSCITEM pom;  
         for (k=min(k,MAXHSCITEMS-1)-1;k>=n;k--) {  
                 if (fseek(f,EXESIZE+k*sizeof(HSCITEM),SEEK_SET)  
                                 ||fread((void*)&pom,sizeof(HSCITEM),1,f)!=1)  
                         WriteError();  
                 if (fseek(f,EXESIZE+(k+1)*sizeof(HSCITEM),SEEK_SET)  
                                 ||fwrite((void*)&pom,sizeof(HSCITEM),1,f)!=1)  
                         WriteError();  
         }  
         CodeStruct((BYTE*)item,sizeof(HSCITEM));  
         if (fseek(f,EXESIZE+n*sizeof(HSCITEM),SEEK_SET)  
                         ||fwrite((void*)item,sizeof(HSCITEM),1,f)!=1)  
                 WriteError();  
         fclose(f);  
 }  
   
 clock_t Time2Clock(struct time time)  
 {  {
         return CLOCKS_PER_SEC *          return CLOCKS_PER_SEC *
                 (long)((long)time.ti_sec+(long)time.ti_min*60+(long)time.ti_hour*3600);                  (long)((long)time.ti_sec+(long)time.ti_min*60+(long)time.ti_hour*3600);
 }  } /* }}} */
   
 void CodeStruct(BYTE*p,BYTE size)  
 {  
         register BYTE k;  
         for (k=0;k<size;k++)  
                 p[k]^=0xff;  
 }  
   
 /* strplus.c extract */  /* strplus.c extract */
 char * strdel(char *s)  char * strdel(char *s) /* {{{ */
 {  {
 #if 1  #if 1
         return (char *) memmove(s, s + 1, strlen(s));          return (char *) memmove(s, s + 1, strlen(s));
Line 1533  char * strdel(char *s)
Line 1494  char * strdel(char *s)
   
         return s;          return s;
 #endif  #endif
 }  } /* }}} */
   
 /* Modeline for ViM {{{  /* Modeline for ViM {{{
  * vim: set ts=4:   * vim: set ts=4:

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top