| version 1.2, 2003/05/18 22:51:41 |
version 1.3, 2003/05/21 13:58:30 |
|
|
| /* $Platon: games/mines/mines.c,v 1.1.1.1 2003/05/11 18:48:45 nepto Exp $ */
|
/* $Platon: games/mines/mines.c,v 1.2 2003/05/18 22:51:41 nepto Exp $ */ |
|
|
|
| /* 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." |
| #define ERR_EXEC "Nem“zem spustit"
|
#define ERR_EXEC "Nem“zem spustit" |
| #define ERR_BREAK "Chyba v presmerovan¡ Ctrl-Break." /* N/A */
|
#define ERR_BREAK "Chyba v presmerovan¡ Ctrl-Break." /* N/A */ |
| #define ERR_MOUSE "Tento program potrebuje mys."
|
#define ERR_MOUSE "Tento program potrebuje mys." |
| #define ERR_WRITE "Chyba pri z pise. Plny disk?"
|
#define ERR_WRITE "Chyba pri z pise. Plny disk?" |
| #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 MINBARSIZE (8)
|
#define MINBARSIZE (8) |
| #define MAXBARSIZE (18)
|
#define MAXBARSIZE (18) |
| #define DEFDIFF (1)
|
#define DEFDIFF (1) |
| #define DIFFOFFSET (13)
|
#define DIFFOFFSET (13) |
| #define DIFFPOINT (3) /* !!! DIFFOFFSET+DIFFPOINT must equal 16 */
|
#define DIFFPOINT (3) /* !!! DIFFOFFSET+DIFFPOINT must equal 16 */ |
| #define DEFNX (30) /* default x size */
|
#define DEFNX (30) /* default x size */ |
| #define DEFNY (25) /* default y size */
|
#define DEFNY (25) /* default y size */ |
| #define MAXNX ((getmaxx()+1)/MINBARSIZE) /* MAXIMUM x size */
|
#define MAXNX ((getmaxx()+1)/MINBARSIZE) /* MAXIMUM x size */ |
| #define MAXNY ((getmaxy()+1)/MINBARSIZE) /* MAXIMUM y size */
|
#define MAXNY ((getmaxy()+1)/MINBARSIZE) /* MAXIMUM y size */ |
| #define INFOXSIZE (textwidth(infostr3[0])+10)
|
#define INFOXSIZE (textwidth(infostr3[0])+10) |
| #define INFOYSIZE (textheight(infostr3[0])*INFOLINES+(itabsize+1)*6)
|
#define INFOYSIZE (textheight(infostr3[0])*INFOLINES+(itabsize+1)*6) |
| #define INFOLINES (14)
|
#define INFOLINES (14) |
| #define DEFITABSIZE (0)
|
#define DEFITABSIZE (0) |
| #define FADESTEPS (1)
|
#define FADESTEPS (1) |
|
|
|
| #define I_BCKCOLOR BLACK
|
#define I_BCKCOLOR BLACK |
| #define I_RCTCOLOR LIGHTGRAY
|
#define I_RCTCOLOR LIGHTGRAY |
| #define I_TXTCOLOR LIGHTGREEN
|
#define I_TXTCOLOR LIGHTGREEN |
| #define I_NUMCOLOR YELLOW
|
#define I_NUMCOLOR YELLOW |
| #define H_DEFCOLOR LIGHTGREEN
|
#define H_DEFCOLOR LIGHTGREEN |
| #define H_INSCOLOR YELLOW
|
#define H_INSCOLOR YELLOW |
|
|
|
| #define isinbar(x,y,x1,y1,x2,y2) (x>=x1&&x<=x2&&y>=y1&&y<=y2)
|
#define isinbar(x,y,x1,y1,x2,y2) (x>=x1&&x<=x2&&y>=y1&&y<=y2) |
| #define isinnormbutton(x,y,xx,yy) (isinbar(x,y,xx-47,yy-1,xx+47,yy+19))
|
#define isinnormbutton(x,y,xx,yy) (isinbar(x,y,xx-47,yy-1,xx+47,yy+19)) |
| #define isinnumbutton(x,y,xx,yy) \
|
#define isinnumbutton(x,y,xx,yy) \ |
| (isinbar(x,y,xx-47,yy-1,xx-20,yy+19)?(isinbar(x,y,xx-47,yy+13,xx-37,yy+17)?3:1): \
|
(isinbar(x,y,xx-47,yy-1,xx-20,yy+19)?(isinbar(x,y,xx-47,yy+13,xx-37,yy+17)?3:1): \ |
| isinbar(x,y,xx+20,yy-1,xx+47,yy+19)?(isinbar(x,y,xx+37,yy+13,xx+47,yy+17)?4:2):0)
|
isinbar(x,y,xx+20,yy-1,xx+47,yy+19)?(isinbar(x,y,xx+37,yy+13,xx+47,yy+17)?4:2):0) |
| #define isininfo(x,y) isinbar(x,y,infox,infoy,infox+INFOXSIZE,infoy+INFOYSIZE)
|
#define isininfo(x,y) isinbar(x,y,infox,infoy,infox+INFOXSIZE,infoy+INFOYSIZE) |
| #define underinfo(x,y) (isininfo(xoff+x*barsize,yoff+y*barsize) \
|
#define underinfo(x,y) (isininfo(xoff+x*barsize,yoff+y*barsize) \ |
| ||isininfo(xoff-1+(x+1)*barsize,yoff+y*barsize) \
|
||isininfo(xoff-1+(x+1)*barsize,yoff+y*barsize) \ |
| ||isininfo(xoff-1+(x+1)*barsize,yoff-1+(y+1)*barsize)||isininfo(xoff+x*barsize,yoff-1+(y+1)*barsize))
|
||isininfo(xoff-1+(x+1)*barsize,yoff-1+(y+1)*barsize)||isininfo(xoff+x*barsize,yoff-1+(y+1)*barsize)) |
| #define HideInfo() WriteInfo(0xffff,0xffff)
|
#define HideInfo() WriteInfo(0xffff,0xffff) |
| #define ShowInfo() WriteInfo(infox,infoy)
|
#define ShowInfo() WriteInfo(infox,infoy) |
| #define FadeIn() fade_in(FADESTEPS)
|
#define FadeIn() fade_in(FADESTEPS) |
| #define FadeOut() fade_out(FADESTEPS)
|
#define FadeOut() fade_out(FADESTEPS) |
|
|
|
| #define YES 1
|
#define YES 1 |
| #define NO 0
|
#define NO 0 |
| #define MINE 255-'0' /* So that when it prints, it prints char 0xff */
|
#define MINE 255-'0' /* So that when it prints, it prints char 0xff */ |
| #define getmines(__nx,__ny,__diff) \
|
#define getmines(__nx,__ny,__diff) \ |
| (max(1,((WORD)(((long)(__nx)*(long)(__ny)*(long)(DIFFOFFSET+(__diff)*DIFFPOINT))/100))))
|
(max(1,((WORD)(((long)(__nx)*(long)(__ny)*(long)(DIFFOFFSET+(__diff)*DIFFPOINT))/100)))) |
|
|
|
| /* INCLUDE */
|
/* INCLUDE */ |
| #include <stdio.h>
|
#include <stdio.h> |
| #include <stdlib.h>
|
#include <stdlib.h> |
| #include <string.h>
|
#include <string.h> |
| #include <ctype.h>
|
#include <ctype.h> |
| #include <time.h>
|
#include <time.h> |
|
|
|
| #include <system.h>
|
#include <system.h> |
|
|
|
| #if PLATON_SYSTEM_LINUX
|
#if PLATON_SYSTEM_LINUX |
| # include <dos2linux.h>
|
# include <dos2linux.h> |
| #endif
|
#endif |
|
|
|
| #if PLATON_SYSTEM_MSDOS
|
#if PLATON_SYSTEM_MSDOS |
| # include <conio.h>
|
# include <conio.h> |
| # include <dos.h>
|
# include <dos.h> |
| # include <alloc.h>
|
# include <alloc.h> |
| #endif
|
#endif |
|
|
|
| #include <typedef.h>
|
#include <typedef.h> |
| #include <standart.h>
|
#include <standart.h> |
| #include <my-graph.h>
|
#include <my-graph.h> |
| #include <mouse.h>
|
#include <mouse.h> |
| #include <menu.h>
|
#include <menu.h> |
|
|
|
| /* #include "data.h" FOR MINES IMAGE */
|
/* #include "data.h" FOR MINES IMAGE */ |
| #include "hiscore.h"
|
#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)) |
| #endif
|
#endif |
|
|
|
| #if PLATON_SYSTEM_LINUX
|
#if PLATON_SYSTEM_LINUX |
| # define RAND_INT(__lo, __hi) (__lo + (random() % (__hi - __lo + 1)))
|
# define RAND_INT(__lo, __hi) (__lo + (random() % (__hi - __lo + 1))) |
| #endif
|
#endif |
|
|
|
| /* NEW TYPES */
|
/* NEW TYPES */ |
| #define value(x,y) ((psquare+(x)*ny+(y))->value)
|
#define value(x,y) ((psquare+(x)*ny+(y))->value) |
| #define sqopen(x,y) ((psquare+(x)*ny+(y))->sqopen)
|
#define sqopen(x,y) ((psquare+(x)*ny+(y))->sqopen) |
| #define sqpress(x,y) ((psquare+(x)*ny+(y))->sqpress)
|
#define sqpress(x,y) ((psquare+(x)*ny+(y))->sqpress) |
| #define sqmark(x,y) ((psquare+(x)*ny+(y))->sqmark)
|
#define sqmark(x,y) ((psquare+(x)*ny+(y))->sqmark) |
|
|
|
| typedef struct stsquare
|
typedef struct stsquare |
| {
|
{ |
| BYTE value; /* Number of mines in the surround squares */
|
BYTE value; /* Number of mines in the surround squares */ |
| BYTE sqopen; /* Square is open */
|
BYTE sqopen; /* Square is open */ |
| BYTE sqpress; /* Square is pressed */
|
BYTE sqpress; /* Square is pressed */ |
| BYTE sqmark; /* Square is marked */
|
BYTE sqmark; /* Square is marked */ |
| } STSQUARE;
|
} STSQUARE; |
|
|
|
| /* /////////////////////////////////////////////////////////////////////// */
|
/* /////////////////////////////////////////////////////////////////////// */ |
| /* GLOBAL IDENTIFICATORS */
|
/* GLOBAL IDENTIFICATORS */ |
| #if PLATON_SYSTEM_MSDOS
|
#if PLATON_SYSTEM_MSDOS |
| extern unsigned _stklen = 65000U;
|
extern unsigned _stklen = 65000U; |
| #endif
|
#endif |
| STSQUARE *psquare;
|
STSQUARE *psquare; |
| /* All unneccessary question marks will be removed. */
|
/* All unneccessary question marks will be removed. */ |
| char infostr1[]="Super Mines v????????? - (c) 1999 Condy software inc.",
|
char infostr1[]="Super Mines v????????? - (c) 1999 Condy software inc.", |
| infostr2[]="Ondrej Jomb¡k - Gymn zium Bil¡kova 24 - Okt va C - 1998/99",
|
infostr2[]="Ondrej Jomb¡k - Gymn zium Bil¡kova 24 - Okt va C - 1998/99", |
| *infostr3[]={" "," MINES ",""," x ",""," Cas "," : : ",""," M¡n ","-- --","","EscMenu","F1Pomoc","F4Pauza"};
|
*infostr3[]={" "," MINES ",""," x ",""," Cas "," : : ",""," M¡n ","-- --","","EscMenu","F1Pomoc","F4Pauza"}; |
| char*yesnostr[]={"Ano","Nie",NULL};
|
char*yesnostr[]={"Ano","Nie",NULL}; |
| BYTE barsize, /* pixels by square */
|
BYTE barsize, /* pixels by square */ |
| diff=DEFDIFF,
|
diff=DEFDIFF, |
| itabsize=DEFITABSIZE, /* Info Tab Size */
|
itabsize=DEFITABSIZE, /* Info Tab Size */ |
| nx=DEFNX, /* Number of squares in X */
|
nx=DEFNX, /* Number of squares in X */ |
| ny=DEFNY;
|
ny=DEFNY; |
| void*infosafe=NULL;
|
void*infosafe=NULL; |
| WORD xoff, /* Offset of first pixel X */
|
WORD xoff, /* Offset of first pixel X */ |
| yoff,
|
yoff, |
| infox=30,infoy=30,
|
infox=30,infoy=30, |
| cmines, /* Mines UN-discovered */
|
cmines, /* Mines UN-discovered */ |
| sqclosed; /* Squares still closed */
|
sqclosed; /* Squares still closed */ |
| /* GAME ENDS IF cmines==0 AND sqclosed==0 */
|
/* GAME ENDS IF cmines==0 AND sqclosed==0 */ |
| char gastxt[]="\
|
char gastxt[]="\ |
| ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ\n\r\
|
ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ\n\r\ |
| Ý Þ\n\r\
|
Ý Þ\n\r\ |
| Ý N'=NSvt/6V | p'=-p | p'-p=2p Þ\n\r\
|
Ý N'=NSvt/6V | p'=-p | p'-p=2p Þ\n\r\ |
| Ý p=N'(p'-p)=2pN'=NSmtvý/3V Þ\n\r\
|
Ý p=N'(p'-p)=2pN'=NSmtvý/3V Þ\n\r\ |
| Ý F=p/t=NSmtvý/3Vt=NSmvý/3V Þ\n\r\
|
Ý F=p/t=NSmtvý/3Vt=NSmvý/3V Þ\n\r\ |
| Ý p=F/S=NSmvý/3VS=Nmvý/3V Þ\n\r\
|
Ý p=F/S=NSmvý/3VS=Nmvý/3V Þ\n\r\ |
| Ý pV=Nmvý/3 | v=û(3kT/m) Þ\n\r\
|
Ý pV=Nmvý/3 | v=û(3kT/m) Þ\n\r\ |
| Ý pV=NkT | n=m/M=N/Nø Þ\n\r\
|
Ý pV=NkT | n=m/M=N/Nø Þ\n\r\ |
| Ý pV=nkNøT | R=kNø Þ\n\r\
|
Ý pV=nkNøT | R=kNø Þ\n\r\ |
| Ý pV=nRT | p'V'=nRT' Þ\n\r\
|
Ý pV=nRT | p'V'=nRT' Þ\n\r\ |
| Ý nR=pV/T=p'V'/T' Þ\n\r\
|
Ý nR=pV/T=p'V'/T' Þ\n\r\ |
| Ý constðpV/T Þ\n\r\
|
Ý constðpV/T Þ\n\r\ |
| Ý constðp ÷> izobar_process Þ\n\r\
|
Ý constðp ÷> izobar_process Þ\n\r\ |
| Ý constðV ÷> izochor_process Þ\n\r\
|
Ý constðV ÷> izochor_process Þ\n\r\ |
| Ý constðT ÷> izoterm_process Þ\n\r\
|
Ý constðT ÷> izoterm_process Þ\n\r\ |
| Ý (p+a/Vý)(V-b)=RT ÷> Van_der_Waals Þ\n\r\
|
Ý (p+a/Vý)(V-b)=RT ÷> Van_der_Waals Þ\n\r\ |
| Ý Þ\n\r\
|
Ý Þ\n\r\ |
| ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß";
|
ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß"; |
| /* /////////////////////////////////////////////////////////////////////// */
|
/* /////////////////////////////////////////////////////////////////////// */ |
| /* FUNCTIONS DECLARATION */
|
/* FUNCTIONS DECLARATION */ |
| int brkfnc(void);
|
int brkfnc(void); |
| void koniec(void);
|
void koniec(void); |
| void WriteError(void);
|
void WriteError(void); |
|
|
|
| BYTE MainMenu(void);
|
BYTE MainMenu(void); |
| int GraphInit(void);
|
int GraphInit(void); |
| void SetData(void);
|
void SetData(void); |
| void SetMines();
|
void SetMines(); |
| void SetSquare(WORD x,WORD y,BYTE status);
|
void SetSquare(WORD x,WORD y,BYTE status); |
| void WriteInfo(WORD x,WORD y);
|
void WriteInfo(WORD x,WORD y); |
| BYTE DoAll(void);
|
BYTE DoAll(void); |
| void Help(void);
|
void Help(void); |
| 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); |
| void OpenSquare(WORD x,WORD y);
|
void OpenSquare(WORD x,WORD y); |
| WORD OpenNearSquares(WORD x,WORD y);
|
WORD OpenNearSquares(WORD x,WORD y); |
|
|
|
| void DrawDiffButton(WORD x,WORD y,BYTE diff,BYTE label);
|
void DrawDiffButton(WORD x,WORD y,BYTE diff,BYTE label); |
| void DrawDefWindow(WORD sizex,WORD y1,WORD y2,char*text);
|
void DrawDefWindow(WORD sizex,WORD y1,WORD y2,char*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); |
| 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); |
| 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); |
| void DrawNumPlus10(WORD x,WORD y,BYTE c);
|
void DrawNumPlus10(WORD x,WORD y,BYTE c); |
| BYTE YesNo(int x,int y);
|
BYTE YesNo(int x,int y); |
| BYTE ColorConvert(BYTE value);
|
BYTE ColorConvert(BYTE value); |
| void fade_out(WORD steps);
|
void fade_out(WORD steps); |
| void fade_in(WORD steps);
|
void fade_in(WORD steps); |
|
|
|
| /* High scores handling */
|
/* High scores handling */ |
| void HscTable(void);
|
void HscTable(void); |
| clock_t time2clock(struct time time);
|
clock_t time2clock(struct time time); |
|
|
|
| /* strplus.h extract */
|
/* strplus.h extract */ |
| char *strdel(char *s);
|
char *strdel(char *s); |
|
|
|
| /* /////////////////////////////////////////////////////////////////////// */
|
/* /////////////////////////////////////////////////////////////////////// */ |
| /* MAIN */
|
/* MAIN */ |
| int main(int argc,char*argv[])
|
int main(int argc,char*argv[]) |
| {
|
{ |
| register WORD k;
|
register WORD k; |
| gotoxy(1,25);
|
gotoxy(1,25); |
| textattr(0x07);
|
textattr(0x07); |
| for (k=0;k<80;k++)
|
for (k=0;k<80;k++) |
| putch('_'); /* putch('Ä'); */
|
putch('_'); /* putch('Ä'); */ |
| putch('\n');
|
putch('\n'); |
| setcbrk(1);
|
setcbrk(1); |
| ctrlbrk(brkfnc);
|
ctrlbrk(brkfnc); |
| atexit(koniec);
|
atexit(koniec); |
| if (argc>1) {
|
if (argc>1) { |
| puts(ERR_ARGC);
|
puts(ERR_ARGC); |
| return 1;
|
return 1; |
| }
|
} |
| #if PLATON_SYSTEM_MSDOS
|
#if PLATON_SYSTEM_MSDOS |
| {
|
{ |
| char exename[]=EXENAME;
|
char exename[]=EXENAME; |
| if (strcmpi(exename,argv[0]+strlen(argv[0])-strlen(exename))) {
|
if (strcmpi(exename,argv[0]+strlen(argv[0])-strlen(exename))) { |
| printf("\n%s %s\n",ERR_EXEC,strupr(exename));
|
printf("\n%s %s\n",ERR_EXEC,strupr(exename)); |
| return 1;
|
return 1; |
| }
|
} |
| }
|
} |
| #endif
|
#endif |
| if (!initmouse()) {
|
if (!initmouse()) { |
| puts(ERR_MOUSE);
|
puts(ERR_MOUSE); |
| return 1;
|
return 1; |
| }
|
} |
| #if PLATON_SYSTEM_MSDOS
|
#if PLATON_SYSTEM_MSDOS |
| hiscore_init(argv[0], HISCORE_AUTODETECT);
|
hiscore_init(argv[0], HISCORE_AUTODETECT); |
| #endif
|
#endif |
| #if PLATON_SYSTEM_LINUX
|
#if PLATON_SYSTEM_LINUX |
| hiscore_init("/var/lib/games/mines/hiscore.dat", 0L);
|
hiscore_init("/var/lib/games/mines/hiscore.dat", 0L); |
| #endif
|
#endif |
| if (GraphInit() < 0)
|
if (GraphInit() < 0) |
| return 1;
|
return 1; |
| strncpy(strchr(infostr1,'?'),__APPVERSION__,strlen(__APPVERSION__));
|
strncpy(strchr(infostr1,'?'),__APPVERSION__,strlen(__APPVERSION__)); |
| while (strchr(infostr1,'?')!=NULL)
|
while (strchr(infostr1,'?')!=NULL) |
| strdel(strchr(infostr1,'?'));
|
strdel(strchr(infostr1,'?')); |
| while (1) {
|
while (1) { |
| switch (MainMenu()) {
|
switch (MainMenu()) { |
| case 0:
|
case 0: |
| do {
|
do { |
| SetData();
|
SetData(); |
| SetMines();
|
SetMines(); |
| } while (DoAll());
|
} while (DoAll()); |
| free(psquare);psquare=NULL;
|
free(psquare);psquare=NULL; |
| free(infosafe);infosafe=NULL;
|
free(infosafe);infosafe=NULL; |
| break;
|
break; |
| case 2:
|
case 2: |
| HscTable();
|
HscTable(); |
| break;
|
break; |
| case 3:
|
case 3: |
| Help();
|
Help(); |
| break;
|
break; |
| case 4:
|
case 4: |
| return 0;
|
return 0; |
| }
|
} |
| }
|
} |
| /* never reached */
|
/* never reached */ |
| }
|
} |
|
|
|
| /* ////////////////////////////////////////////////////////////////////// */
|
/* ////////////////////////////////////////////////////////////////////// */ |
| /* FUNCTIONS DEFINITIONS */
|
/* FUNCTIONS DEFINITIONS */ |
| /*************************************************************************
|
/************************************************************************* |
| * *
|
* * |
| * 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();
|
hiscore_close(); |
| fcloseall();
|
fcloseall(); |
| endstring("MINES");
|
endstring("MINES"); |
|
|
|
| randomize();
|
randomize(); |
| switch (RAND_INT(0, 3)) {
|
switch (RAND_INT(0, 3)) { |
| case 0:
|
case 0: |
| textattr(0x03);
|
textattr(0x03); |
| cputs(gastxt);
|
cputs(gastxt); |
| break;
|
break; |
| default:
|
default: |
| textattr(LIGHTMAGENTA);cputs("\n\r e-mail");
|
textattr(LIGHTMAGENTA);cputs("\n\r e-mail"); |
| textattr(128+LIGHTMAGENTA);cputs(":");
|
textattr(128+LIGHTMAGENTA);cputs(":"); |
| textattr(WHITE);
|
textattr(WHITE); |
| cputs(" Jombik@pobox.sk");
|
cputs(" Jombik@pobox.sk"); |
|
|
|
| textattr(LIGHTMAGENTA);cputs("\n\r homepage");
|
textattr(LIGHTMAGENTA);cputs("\n\r homepage"); |
| textattr(128+LIGHTMAGENTA);cputs(":");
|
textattr(128+LIGHTMAGENTA);cputs(":"); |
| textattr(WHITE);
|
textattr(WHITE); |
| cputs(" http://Jombik.w3.to");
|
cputs(" http://Jombik.w3.to"); |
|
|
|
| if (!RAND_INT(0, 2)) {
|
if (!RAND_INT(0, 2)) { |
| textattr(0x02);
|
textattr(0x02); |
| cputs("\n\n\n\rSo doN'T foRgeT To ViSit ouR inCreDibLe _talker_ ");
|
cputs("\n\n\n\rSo doN'T foRgeT To ViSit ouR inCreDibLe _talker_ "); |
| textattr(WHITE);
|
textattr(WHITE); |
| cputs("telnet://atlantis.sk:7000\n");
|
cputs("telnet://atlantis.sk:7000\n"); |
| }
|
} |
| else{
|
else{ |
| textattr(LIGHTMAGENTA);cputs("\n\r talker");
|
textattr(LIGHTMAGENTA);cputs("\n\r talker"); |
| textattr(128+LIGHTMAGENTA);cputs(":");
|
textattr(128+LIGHTMAGENTA);cputs(":"); |
| textattr(WHITE);
|
textattr(WHITE); |
| cputs(" telnet://atlantis.sk:7000");
|
cputs(" telnet://atlantis.sk:7000"); |
| }
|
} |
|
|
|
| textattr(GREEN);cputs("\n\n\rThis is an ");
|
textattr(GREEN);cputs("\n\n\rThis is an "); |
| textattr(LIGHTCYAN);cputs("eXtreme & precizion ");
|
textattr(LIGHTCYAN);cputs("eXtreme & precizion "); |
| textattr(LIGHTGREEN);cputs("Neptun ");
|
textattr(LIGHTGREEN);cputs("Neptun "); |
| textattr(GREEN);cputs("software production.");
|
textattr(GREEN);cputs("software production."); |
|
|
|
| textattr(GREEN);cputs("\n\rEspecially thanx 2 ");
|
textattr(GREEN);cputs("\n\rEspecially thanx 2 "); |
| textattr(LIGHTCYAN);cputs("neverending ");
|
textattr(LIGHTCYAN);cputs("neverending "); |
| textattr(LIGHTGREEN);cputs("Wolcaan ");
|
textattr(LIGHTGREEN);cputs("Wolcaan "); |
| textattr(GREEN);cputs("bug reporting.");
|
textattr(GREEN);cputs("bug reporting."); |
| 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; |
| char*menustr[]={"Nov Hra","Nastavenie","Tabulka najleps¡ch","Inform cie","Odchod do DOSu",NULL};
|
char*menustr[]={"Nov Hra","Nastavenie","Tabulka najleps¡ch","Inform cie","Odchod do DOSu",NULL}; |
| char*itabstr[]={"Norm lna","Velk ","Velmi velk "};
|
char*itabstr[]={"Norm lna","Velk ","Velmi velk "}; |
| char*infostr[]={"Systematicky analyzoval,","psychicky transformoval", "a v konecnom d“sledku naprogramoval:","Ondrej Jomb¡k"};
|
char*infostr[]={"Systematicky analyzoval,","psychicky transformoval", "a v konecnom d“sledku naprogramoval:","Ondrej Jomb¡k"}; |
| FadeOut();
|
FadeOut(); |
| hidemouse();
|
hidemouse(); |
| DrawWindow(0,0,getmaxx(),getmaxy(),BLACK,DARKGRAY);
|
DrawWindow(0,0,getmaxx(),getmaxy(),BLACK,DARKGRAY); |
| DrawWindow(140,50,getmaxx()-140,110,RED,GREEN);
|
DrawWindow(140,50,getmaxx()-140,110,RED,GREEN); |
| setcolor(LIGHTGREEN);settextstyle(0,0,4);
|
setcolor(LIGHTGREEN);settextstyle(0,0,4); |
| outtextxy(getmaxx()/2+2,82,"M I N E S");
|
outtextxy(getmaxx()/2+2,82,"M I N E S"); |
| DrawWindow(40,410,getmaxx()-40,440,DARKGRAY,LIGHTGRAY);
|
DrawWindow(40,410,getmaxx()-40,440,DARKGRAY,LIGHTGRAY); |
| setcolor(WHITE);settextstyle(0,0,1);
|
setcolor(WHITE);settextstyle(0,0,1); |
| outtextxy(getmaxx()/2,420,infostr1);
|
outtextxy(getmaxx()/2,420,infostr1); |
| outtextxy(getmaxx()/2,432,infostr2);
|
outtextxy(getmaxx()/2,432,infostr2); |
| rangex(111,getmaxx()-111);
|
rangex(111,getmaxx()-111); |
| rangey(196,324);
|
rangey(196,324); |
| DrawDefWindow(420,195,325,NULL);
|
DrawDefWindow(420,195,325,NULL); |
| showmouse();
|
showmouse(); |
| FadeIn();
|
FadeIn(); |
| while (1) {
|
while (1) { |
| hidemouse();
|
hidemouse(); |
| DrawDefWindow(420,195,325,NULL);
|
DrawDefWindow(420,195,325,NULL); |
| showmouse();
|
showmouse(); |
| switch (but=menu(menustr,getmaxx()/2,205,0,2,24,BLACK,WHITE)) {
|
switch (but=menu(menustr,getmaxx()/2,205,0,2,24,BLACK,WHITE)) { |
| case 4: /* Quit to DOS */
|
case 4: /* Quit to DOS */ |
| hidemouse();
|
hidemouse(); |
| DrawDefWindow(420,195,325,menustr[but]);
|
DrawDefWindow(420,195,325,menustr[but]); |
| showmouse();
|
showmouse(); |
| if (menu(yesnostr,getmaxx()/2,256,0,2,25,RED,LIGHTGREEN))
|
if (menu(yesnostr,getmaxx()/2,256,0,2,25,RED,LIGHTGREEN)) |
| break;
|
break; |
| case 0: /* Start game */
|
case 0: /* Start game */ |
| case 2: /* Hall of fame */
|
case 2: /* Hall of fame */ |
| rangex(0,getmaxx());
|
rangex(0,getmaxx()); |
| rangey(0,getmaxy());
|
rangey(0,getmaxy()); |
| FadeOut();
|
FadeOut(); |
| return(but);
|
return(but); |
| case 1:
|
case 1: |
| hidemouse();
|
hidemouse(); |
| DrawDefWindow(420,195,325,menustr[but]);
|
DrawDefWindow(420,195,325,menustr[but]); |
| DrawNumButton(190,254,"S¡rka pola",nx,GREEN,BLUE,WHITE);
|
DrawNumButton(190,254,"S¡rka pola",nx,GREEN,BLUE,WHITE); |
| DrawNumButton(190,296,"Vyska pola",ny,GREEN,BLUE,WHITE);
|
DrawNumButton(190,296,"Vyska pola",ny,GREEN,BLUE,WHITE); |
| DrawDiffButton(320,254,diff,1);
|
DrawDiffButton(320,254,diff,1); |
| DrawNormButton(320,296,"Info tabulka",itabstr[itabsize],BLUE,ColorConvert(itabsize+2),WHITE);
|
DrawNormButton(320,296,"Info tabulka",itabstr[itabsize],BLUE,ColorConvert(itabsize+2),WHITE); |
| DrawNormButton(450,254,"","Reset",RED,WHITE,WHITE);
|
DrawNormButton(450,254,"","Reset",RED,WHITE,WHITE); |
| DrawNormButton(450,296,"","OK",RED,WHITE,WHITE);
|
DrawNormButton(450,296,"","OK",RED,WHITE,WHITE); |
| showmouse();
|
showmouse(); |
| while (!(but=releasebutton(0,&x,&y))||!isinnormbutton(x,y,450,296)) {
|
while (!(but=releasebutton(0,&x,&y))||!isinnormbutton(x,y,450,296)) { |
| if (but) {
|
if (but) { |
| if (isinnormbutton(x,y,450,254) != 0) { /* Reset */
|
if (isinnormbutton(x,y,450,254) != 0) { /* Reset */ |
| hidemouse();
|
hidemouse(); |
| nx=DEFNX;DrawNumButton(190,254,"S¡rka pola",nx,GREEN,BLUE,WHITE);
|
nx=DEFNX;DrawNumButton(190,254,"S¡rka pola",nx,GREEN,BLUE,WHITE); |
| ny=DEFNY;DrawNumButton(190,296,"Vyska pola",ny,GREEN,BLUE,WHITE);
|
ny=DEFNY;DrawNumButton(190,296,"Vyska pola",ny,GREEN,BLUE,WHITE); |
| itabsize=DEFITABSIZE;
|
itabsize=DEFITABSIZE; |
| DrawNormButton(320,296,"Info tabulka",itabstr[itabsize],BLUE,ColorConvert(itabsize+2),WHITE);
|
DrawNormButton(320,296,"Info tabulka",itabstr[itabsize],BLUE,ColorConvert(itabsize+2),WHITE); |
| diff=DEFDIFF;
|
diff=DEFDIFF; |
| DrawDiffButton(320,254,diff,1);
|
DrawDiffButton(320,254,diff,1); |
| showmouse();
|
showmouse(); |
| }
|
} |
| if (isinnormbutton(x,y,320,296) != 0) { /* Info table */
|
if (isinnormbutton(x,y,320,296) != 0) { /* Info table */ |
| itabsize++;
|
itabsize++; |
| if (itabsize>2)
|
if (itabsize>2) |
| itabsize=0;
|
itabsize=0; |
| hidemouse();
|
hidemouse(); |
| DrawNormButton(320,296,"Info tabulka",itabstr[itabsize],BLUE,ColorConvert(itabsize+2),WHITE);
|
DrawNormButton(320,296,"Info tabulka",itabstr[itabsize],BLUE,ColorConvert(itabsize+2),WHITE); |
| showmouse();
|
showmouse(); |
| }
|
} |
| if ((but=isinnormbutton(x,y,320,254))!=0) {
|
if ((but=isinnormbutton(x,y,320,254))!=0) { |
| diff++;
|
diff++; |
| if (diff>3)
|
if (diff>3) |
| diff=0;
|
diff=0; |
| hidemouse();
|
hidemouse(); |
| DrawDiffButton(320,254,diff,1);
|
DrawDiffButton(320,254,diff,1); |
| showmouse();
|
showmouse(); |
| }
|
} |
| if ((but=isinnumbutton(x,y,190,254))!=0&&((but%2&&nx>1)||(!(but%2)&&nx<MAXNX))) {
|
if ((but=isinnumbutton(x,y,190,254))!=0&&((but%2&&nx>1)||(!(but%2)&&nx<MAXNX))) { |
| switch (but) {
|
switch (but) { |
| case 1:nx--;break;
|
case 1:nx--;break; |
| case 2:nx++;break;
|
case 2:nx++;break; |
| case 3:nx-=min(10,nx-1);break;
|
case 3:nx-=min(10,nx-1);break; |
| case 4:nx+=min(10,MAXNX-nx);break;
|
case 4:nx+=min(10,MAXNX-nx);break; |
| }
|
} |
| hidemouse();
|
hidemouse(); |
| DrawNumButton(190,254,"S¡rka pola",nx,GREEN,BLUE,WHITE);
|
DrawNumButton(190,254,"S¡rka pola",nx,GREEN,BLUE,WHITE); |
| showmouse();
|
showmouse(); |
| }
|
} |
| if ((but=isinnumbutton(x,y,190,296))!=0&&((but%2&&ny>1)||(!(but%2)&&ny<MAXNY))) {
|
if ((but=isinnumbutton(x,y,190,296))!=0&&((but%2&&ny>1)||(!(but%2)&&ny<MAXNY))) { |
| switch (but) {
|
switch (but) { |
| case 1:ny--;break;
|
case 1:ny--;break; |
| case 2:ny++;break;
|
case 2:ny++;break; |
| case 3:ny-=min(10,ny-1);break;
|
case 3:ny-=min(10,ny-1);break; |
| case 4:ny+=min(10,MAXNY-ny);break;
|
case 4:ny+=min(10,MAXNY-ny);break; |
| }
|
} |
| hidemouse();
|
hidemouse(); |
| DrawNumButton(190,296,"Vyska pola",ny,GREEN,BLUE,WHITE);
|
DrawNumButton(190,296,"Vyska pola",ny,GREEN,BLUE,WHITE); |
| showmouse();
|
showmouse(); |
| }
|
} |
| }
|
} |
| }
|
} |
| break;
|
break; |
| case 3: /* Information */
|
case 3: /* Information */ |
| hidemouse();
|
hidemouse(); |
| DrawDefWindow(420,195,325,menustr[but]);
|
DrawDefWindow(420,195,325,menustr[but]); |
| DrawNormButton(getmaxx()/2-65,297,"","OK",RED,WHITE,WHITE);
|
DrawNormButton(getmaxx()/2-65,297,"","OK",RED,WHITE,WHITE); |
| DrawNormButton(getmaxx()/2+65,297,"","viac info",RED,WHITE,WHITE);
|
DrawNormButton(getmaxx()/2+65,297,"","viac info",RED,WHITE,WHITE); |
| for (but=0;but<3;but++) {
|
for (but=0;but<3;but++) { |
| setcolor(ColorConvert(but+2));
|
setcolor(ColorConvert(but+2)); |
| outtextxy(getmaxx()/2,242+but*11,infostr[but]);
|
outtextxy(getmaxx()/2,242+but*11,infostr[but]); |
| }
|
} |
| setcolor(DARKGRAY);
|
setcolor(DARKGRAY); |
| outtextxy(getmaxx()/2+2,281+2,infostr[3]);
|
outtextxy(getmaxx()/2+2,281+2,infostr[3]); |
| setcolor(LIGHTGRAY);
|
setcolor(LIGHTGRAY); |
| outtextxy(getmaxx()/2+1,281+1,infostr[3]);
|
outtextxy(getmaxx()/2+1,281+1,infostr[3]); |
| setcolor(WHITE);
|
setcolor(WHITE); |
| outtextxy(getmaxx()/2,281,infostr[3]);
|
outtextxy(getmaxx()/2,281,infostr[3]); |
| showmouse();
|
showmouse(); |
| while (1) {
|
while (1) { |
| if (kbhit())getch();
|
if (kbhit())getch(); |
| if (releasebutton(0,&x,&y)) {
|
if (releasebutton(0,&x,&y)) { |
| if (isinnormbutton(x,y,getmaxx()/2-65,297))
|
if (isinnormbutton(x,y,getmaxx()/2-65,297)) |
| break;
|
break; |
| if (isinnormbutton(x,y,getmaxx()/2+65,297)) {
|
if (isinnormbutton(x,y,getmaxx()/2+65,297)) { |
| rangex(0,getmaxx());
|
rangex(0,getmaxx()); |
| rangey(0,getmaxy());
|
rangey(0,getmaxy()); |
| FadeOut();
|
FadeOut(); |
| return(3);
|
return(3); |
| }
|
} |
| }
|
} |
| }
|
} |
| break;
|
break; |
| };
|
}; |
| }
|
} |
| } /* }}} */
|
} /* }}} */ |
|
|
|
| /*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/ |
| int GraphInit(void) /* {{{ */
|
int GraphInit(void) /* {{{ */ |
| {
|
{ |
| #if 0
|
#if 0 |
| int gdriver=9,gmode=2,errorcode;
|
int gdriver=9,gmode=2,errorcode; |
| if (set_egavga_bgi()!=1) {puts(ERR_WRITE);exit(1);}
|
if (set_egavga_bgi()!=1) {puts(ERR_WRITE);exit(1);} |
| initgraph(&gdriver,&gmode,"");
|
initgraph(&gdriver,&gmode,""); |
| if ((errorcode=graphresult())!=grOk) {printf("\n%s %s\n",ERR_GRAPH,grapherrormsg(errorcode));exit(1);}
|
if ((errorcode=graphresult())!=grOk) {printf("\n%s %s\n",ERR_GRAPH,grapherrormsg(errorcode));exit(1);} |
| remove("eGaVgA.bGI");
|
remove("eGaVgA.bGI"); |
| #endif
|
#endif |
| if (my_graph_init(0) < 0) {
|
if (my_graph_init(0) < 0) { |
| return -1;
|
return -1; |
| }
|
} |
|
|
|
| FadeOut();
|
FadeOut(); |
| showmouse();
|
showmouse(); |
| /* !!! for whole game !!! */
|
/* !!! for whole game !!! */ |
| 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); |
| for (barsize = MAXBARSIZE; barsize >= MINBARSIZE; barsize--)
|
for (barsize = MAXBARSIZE; barsize >= MINBARSIZE; barsize--) |
| if ((barsize*nx<=getmaxx()+1)&&(barsize*ny<=getmaxy()+1))
|
if ((barsize*nx<=getmaxx()+1)&&(barsize*ny<=getmaxy()+1)) |
| break;
|
break; |
|
|
|
| if ((psquare=(STSQUARE *)calloc(nx*ny,sizeof(STSQUARE))) == NULL) {
|
if ((psquare=(STSQUARE *)calloc(nx*ny,sizeof(STSQUARE))) == NULL) { |
| my_graph_close();
|
my_graph_close(); |
| 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; |
|
|
|
| randomize();
|
randomize(); |
| cmines=getmines(nx,ny,diff);
|
cmines=getmines(nx,ny,diff); |
| sqclosed=(nx*ny)-cmines;
|
sqclosed=(nx*ny)-cmines; |
| p=psquare;
|
p=psquare; |
| for (i=nx*ny;i>0;i--,p++)
|
for (i=nx*ny;i>0;i--,p++) |
| p->value = p->sqopen = p->sqpress = p->sqmark=NO;
|
p->value = p->sqopen = p->sqpress = p->sqmark=NO; |
| for (i=getmines(nx,ny,diff);i>0;i--) {
|
for (i=getmines(nx,ny,diff);i>0;i--) { |
| while (value(x=RAND_INT(0, nx - 1),y=RAND_INT(0, ny - 1))==MINE);
|
while (value(x=RAND_INT(0, nx - 1),y=RAND_INT(0, ny - 1))==MINE); |
| value(x,y)=MINE;
|
value(x,y)=MINE; |
| }
|
} |
| for (x=nx-1;x>=0;x--) {
|
for (x=nx-1;x>=0;x--) { |
| for (y=ny-1;y>=0;y--) {
|
for (y=ny-1;y>=0;y--) { |
| if (value(x,y)==MINE)
|
if (value(x,y)==MINE) |
| continue;
|
continue; |
| a=x-1;
|
a=x-1; |
| b=y-1;
|
b=y-1; |
| if (a>=0 && b>=0 && a<nx && b<ny)
|
if (a>=0 && b>=0 && a<nx && b<ny) |
| value(x,y)+=(value(a,b) == MINE);
|
value(x,y)+=(value(a,b) == MINE); |
| a++;
|
a++; |
| if (a>=0 && b>=0 && a<nx && b<ny)
|
if (a>=0 && b>=0 && a<nx && b<ny) |
| value(x,y)+=(value(a,b) == MINE);
|
value(x,y)+=(value(a,b) == MINE); |
| a++;
|
a++; |
| if (a>=0 && b>=0 && a<nx && b<ny)
|
if (a>=0 && b>=0 && a<nx && b<ny) |
| value(x,y)+=(value(a,b) == MINE);
|
value(x,y)+=(value(a,b) == MINE); |
| b++;
|
b++; |
| if (a>=0 && b>=0 && a<nx && b<ny)
|
if (a>=0 && b>=0 && a<nx && b<ny) |
| value(x,y)+=(value(a,b) == MINE);
|
value(x,y)+=(value(a,b) == MINE); |
| a-=2;
|
a-=2; |
| if (a>=0 && b>=0 && a<nx && b<ny)
|
if (a>=0 && b>=0 && a<nx && b<ny) |
| value(x,y)+=(value(a,b) == MINE);
|
value(x,y)+=(value(a,b) == MINE); |
| b++;
|
b++; |
| if (a>=0 && b>=0 && a<nx && b<ny)
|
if (a>=0 && b>=0 && a<nx && b<ny) |
| value(x,y)+=(value(a,b) == MINE);
|
value(x,y)+=(value(a,b) == MINE); |
| a++;
|
a++; |
| if (a>=0 && b>=0 && a<nx && b<ny)
|
if (a>=0 && b>=0 && a<nx && b<ny) |
| value(x,y)+=(value(a,b) == MINE);
|
value(x,y)+=(value(a,b) == MINE); |
| a++;
|
a++; |
| if (a>=0 && b>=0 && a<nx && b<ny)
|
if (a>=0 && b>=0 && a<nx && b<ny) |
| 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) |
| HideInfo();
|
HideInfo(); |
| x1=xoff+barsize*x;
|
x1=xoff+barsize*x; |
| x2=x1+barsize-1;
|
x2=x1+barsize-1; |
| y1=yoff+barsize*y;
|
y1=yoff+barsize*y; |
| y2=y1+barsize-1;
|
y2=y1+barsize-1; |
| setfillstyle(SOLID_FILL, LIGHTGRAY);
|
setfillstyle(SOLID_FILL, LIGHTGRAY); |
| bar(x1, y1, x2, y2);
|
bar(x1, y1, x2, y2); |
| if (status) {
|
if (status) { |
| setcolor(WHITE);
|
setcolor(WHITE); |
| line(x1,y1,x1,y2-1);
|
line(x1,y1,x1,y2-1); |
| line(x1,y1,x2-1,y1);
|
line(x1,y1,x2-1,y1); |
| setcolor(DARKGRAY);
|
setcolor(DARKGRAY); |
| line(x2,y2,x1,y2);
|
line(x2,y2,x1,y2); |
| line(x2,y2,x2,y1);
|
line(x2,y2,x2,y1); |
| switch (sqmark(x,y)) {
|
switch (sqmark(x,y)) { |
| case 2 : setfillstyle(SOLID_FILL, LIGHTBLUE);
|
case 2 : setfillstyle(SOLID_FILL, LIGHTBLUE); |
| setcolor(LIGHTBLUE);
|
setcolor(LIGHTBLUE); |
| break;
|
break; |
| case 1 : setfillstyle(SOLID_FILL, LIGHTRED);
|
case 1 : setfillstyle(SOLID_FILL, LIGHTRED); |
| setcolor(LIGHTRED);
|
setcolor(LIGHTRED); |
| break;
|
break; |
| default: setcolor(LIGHTGRAY);
|
default: setcolor(LIGHTGRAY); |
| }
|
} |
| fillellipse(xoff+barsize*x+barsize/2, yoff+barsize*y+barsize/2, 3, 3);
|
fillellipse(xoff+barsize*x+barsize/2, yoff+barsize*y+barsize/2, 3, 3); |
| switch (sqmark(x,y)) {
|
switch (sqmark(x,y)) { |
| case 2 :
|
case 2 : |
| case 1 : setfillstyle(SOLID_FILL, YELLOW);
|
case 1 : setfillstyle(SOLID_FILL, YELLOW); |
| setcolor(YELLOW);
|
setcolor(YELLOW); |
| fillellipse(xoff+barsize*x+barsize/2, yoff+barsize*y+barsize/2, 1, 1);
|
fillellipse(xoff+barsize*x+barsize/2, yoff+barsize*y+barsize/2, 1, 1); |
| }
|
} |
| } else{
|
} else{ |
| setcolor(DARKGRAY);
|
setcolor(DARKGRAY); |
| 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]; |
| hidemouse();
|
hidemouse(); |
| if (infosafe==NULL) {
|
if (infosafe==NULL) { |
| if ((infosafe=malloc(imagesize(infox,infoy,infox+INFOXSIZE,infoy+INFOYSIZE)))==NULL) {
|
if ((infosafe=malloc(imagesize(infox,infoy,infox+INFOXSIZE,infoy+INFOYSIZE)))==NULL) { |
| my_graph_close();
|
my_graph_close(); |
| puts(ERR_MEMORY);
|
puts(ERR_MEMORY); |
| exit(1);
|
exit(1); |
| }
|
} |
| } else
|
} else |
| putimage(infox,infoy,infosafe,COPY_PUT);
|
putimage(infox,infoy,infosafe,COPY_PUT); |
|
|
|
| if (x==0xffff&&y==0xffff) {
|
if (x==0xffff&&y==0xffff) { |
| free(infosafe);
|
free(infosafe); |
| infosafe=NULL;
|
infosafe=NULL; |
| } else {
|
} else { |
| infox=max(0,min((int)x,getmaxx()-INFOXSIZE));
|
infox=max(0,min((int)x,getmaxx()-INFOXSIZE)); |
| infoy=max(0,min((int)y,getmaxy()-INFOYSIZE));
|
infoy=max(0,min((int)y,getmaxy()-INFOYSIZE)); |
| getimage(infox,infoy,infox+INFOXSIZE,infoy+INFOYSIZE,infosafe);
|
getimage(infox,infoy,infox+INFOXSIZE,infoy+INFOYSIZE,infosafe); |
| DrawWindow(infox,infoy,infox+INFOXSIZE,infoy+INFOYSIZE,
|
DrawWindow(infox,infoy,infox+INFOXSIZE,infoy+INFOYSIZE, |
| I_BCKCOLOR,I_RCTCOLOR);
|
I_BCKCOLOR,I_RCTCOLOR); |
|
|
|
| for (k=0;k<INFOLINES;k++) {
|
for (k=0;k<INFOLINES;k++) { |
| setcolor(I_TXTCOLOR);
|
setcolor(I_TXTCOLOR); |
| moveto(infox+INFOXSIZE/2,textheight(infostr3[0])/2+infoy+(k*textheight(infostr3[k])));
|
moveto(infox+INFOXSIZE/2,textheight(infostr3[0])/2+infoy+(k*textheight(infostr3[k]))); |
| outtext(infostr3[k]);
|
outtext(infostr3[k]); |
| switch (k) {
|
switch (k) { |
| case 3:sprintf(txt," %02u %02u ",nx,ny);break;
|
case 3:sprintf(txt," %02u %02u ",nx,ny);break; |
| case 9:sprintf(txt," %03u ",cmines);break;
|
case 9:sprintf(txt," %03u ",cmines);break; |
| case 11:sprintf(txt,"%.3s ",infostr3[k]);break;
|
case 11:sprintf(txt,"%.3s ",infostr3[k]);break; |
| case 12:
|
case 12: |
| case 13:sprintf(txt,"%.2s ",infostr3[k]);break;
|
case 13:sprintf(txt,"%.2s ",infostr3[k]);break; |
| default:txt[0]=EOS;
|
default:txt[0]=EOS; |
| }
|
} |
| setcolor(I_NUMCOLOR);
|
setcolor(I_NUMCOLOR); |
| outtext(txt);
|
outtext(txt); |
| }
|
} |
| }
|
} |
| 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; |
| clock_t start,curr,clktmp;
|
clock_t start,curr,clktmp; |
| start=curr=clock();
|
start=curr=clock(); |
|
|
|
| xoff=(getmaxx()+1-nx*barsize)/2;
|
xoff=(getmaxx()+1-nx*barsize)/2; |
| yoff=(getmaxy()+1-ny*barsize)/2;
|
yoff=(getmaxy()+1-ny*barsize)/2; |
| hidemouse();
|
hidemouse(); |
| cleardevice();
|
cleardevice(); |
| setcolor(WHITE);
|
setcolor(WHITE); |
| settextstyle(0,0,1);
|
settextstyle(0,0,1); |
| if (yoff>textheight(infostr1)) {
|
if (yoff>textheight(infostr1)) { |
| outtextxy(getmaxx()/2,yoff/2,infostr1);
|
outtextxy(getmaxx()/2,yoff/2,infostr1); |
| outtextxy(getmaxx()/2,getmaxy()-yoff/2,infostr2);
|
outtextxy(getmaxx()/2,getmaxy()-yoff/2,infostr2); |
| }
|
} |
| else if (yoff>textheight(infostr1)/2) {
|
else if (yoff>textheight(infostr1)/2) { |
| yoff=getmaxy()+1-ny*barsize;
|
yoff=getmaxy()+1-ny*barsize; |
| outtextxy(getmaxx()/2,yoff/2,infostr1);
|
outtextxy(getmaxx()/2,yoff/2,infostr1); |
| }
|
} |
| for (x=0;x<nx;x++)
|
for (x=0;x<nx;x++) |
| for (y=0;y<ny;y++)
|
for (y=0;y<ny;y++) |
| SetSquare(x,y,1);
|
SetSquare(x,y,1); |
| showmouse();
|
showmouse(); |
|
|
|
| settextstyle(0,0,itabsize+1);
|
settextstyle(0,0,itabsize+1); |
| ShowInfo();
|
ShowInfo(); |
| FadeIn();
|
FadeIn(); |
| while (1) {
|
while (1) { |
| if (kbhit()) {
|
if (kbhit()) { |
| if ((but=getch())==ESC) {
|
if ((but=getch())==ESC) { |
| (void)getmousepos(&x,&y);
|
(void)getmousepos(&x,&y); |
| if (YesNo(x-27,y-22)==YES)
|
if (YesNo(x-27,y-22)==YES) |
| break;
|
break; |
| }
|
} |
| if (!but) {
|
if (!but) { |
| switch (but = getch()) {
|
switch (but = getch()) { |
| case 59: /* F1 */ {
|
case 59: /* F1 */ { |
| register WORD k,l;
|
register WORD k,l; |
| FILE*tmp=tmpfile();
|
FILE*tmp=tmpfile(); |
| if (tmp==NULL)
|
if (tmp==NULL) |
| WriteError();
|
WriteError(); |
| clktmp = clock();
|
clktmp = clock(); |
| hidemouse();
|
hidemouse(); |
| for (l=0;l<=getmaxy();l++) {
|
for (l=0;l<=getmaxy();l++) { |
| for (k=0;k<=getmaxx();k+=2) {
|
for (k=0;k<=getmaxx();k+=2) { |
| but=getpixel(k,l)+getpixel(k+1,l)*16;
|
but=getpixel(k,l)+getpixel(k+1,l)*16; |
| if (fwrite(&but,sizeof(BYTE),1,tmp)!=1)
|
if (fwrite(&but,sizeof(BYTE),1,tmp)!=1) |
| WriteError();
|
WriteError(); |
| putpixel(k,l,BLACK);
|
putpixel(k,l,BLACK); |
| putpixel(k+1,l,BLACK);
|
putpixel(k+1,l,BLACK); |
| }
|
} |
| }
|
} |
| FadeOut();
|
FadeOut(); |
| showmouse();
|
showmouse(); |
| Help();
|
Help(); |
| hidemouse();
|
hidemouse(); |
| rewind(tmp);
|
rewind(tmp); |
| for (l=0;l<=getmaxy();l++) {
|
for (l=0;l<=getmaxy();l++) { |
| for (k=0;k<=getmaxx();k+=2) {
|
for (k=0;k<=getmaxx();k+=2) { |
| if (fread(&but,sizeof(BYTE),1,tmp)!=1)
|
if (fread(&but,sizeof(BYTE),1,tmp)!=1) |
| WriteError();
|
WriteError(); |
| putpixel(k,l,but);
|
putpixel(k,l,but); |
| putpixel(k+1,l,but/16);
|
putpixel(k+1,l,but/16); |
| }
|
} |
| }
|
} |
| fclose(tmp);
|
fclose(tmp); |
| showmouse();
|
showmouse(); |
| start+=clock()-clktmp;
|
start+=clock()-clktmp; |
| }break;
|
}break; |
| case 62:/* F4 */ {
|
case 62:/* F4 */ { |
| void*pictmp;
|
void*pictmp; |
| clktmp=clock();
|
clktmp=clock(); |
| FadeOut();
|
FadeOut(); |
| HideInfo();
|
HideInfo(); |
| setpalette(0,0x3f);
|
setpalette(0,0x3f); |
| pictmp=malloc(imagesize(getmaxx()/2-150,getmaxy()/2-20,getmaxx()/2+150,getmaxy()/2+20));
|
pictmp=malloc(imagesize(getmaxx()/2-150,getmaxy()/2-20,getmaxx()/2+150,getmaxy()/2+20)); |
| if (pictmp != NULL) {
|
if (pictmp != NULL) { |
| hidemouse();
|
hidemouse(); |
| getimage(getmaxx()/2-150,getmaxy()/2-20,getmaxx()/2+150,getmaxy()/2+20,pictmp);
|
getimage(getmaxx()/2-150,getmaxy()/2-20,getmaxx()/2+150,getmaxy()/2+20,pictmp); |
| DrawWindow(getmaxx()/2-150,getmaxy()/2-20,getmaxx()/2+150,getmaxy()/2+20,1,0);
|
DrawWindow(getmaxx()/2-150,getmaxy()/2-20,getmaxx()/2+150,getmaxy()/2+20,1,0); |
| settextstyle(0,0,2);
|
settextstyle(0,0,2); |
| outtextxy(getmaxx()/2,getmaxy()/2-6,"P A U Z A");
|
outtextxy(getmaxx()/2,getmaxy()/2-6,"P A U Z A"); |
| settextstyle(0,0,1);
|
settextstyle(0,0,1); |
| outtextxy(getmaxx()/2,getmaxy()/2+10,"Klikni sem pre pokracovanie...");
|
outtextxy(getmaxx()/2,getmaxy()/2+10,"Klikni sem pre pokracovanie..."); |
| showmouse();
|
showmouse(); |
| }
|
} |
| while ((!releasebutton(0,&x,&y)
|
while ((!releasebutton(0,&x,&y) |
| ||!isinbar(x,y,getmaxx()/2-150,getmaxy()/2-20,getmaxx()/2+150,getmaxy()/2+20)))
|
||!isinbar(x,y,getmaxx()/2-150,getmaxy()/2-20,getmaxx()/2+150,getmaxy()/2+20))) |
| if (kbhit())
|
if (kbhit()) |
| getch();
|
getch(); |
| if (pictmp!=NULL) {
|
if (pictmp!=NULL) { |
| hidemouse();
|
hidemouse(); |
| putimage(getmaxx()/2-150,getmaxy()/2-20,pictmp,COPY_PUT);
|
putimage(getmaxx()/2-150,getmaxy()/2-20,pictmp,COPY_PUT); |
| showmouse();
|
showmouse(); |
| free(pictmp);
|
free(pictmp); |
| }
|
} |
| settextstyle(0,0,itabsize+1);
|
settextstyle(0,0,itabsize+1); |
| ShowInfo();
|
ShowInfo(); |
| FadeIn();
|
FadeIn(); |
| start+=clock()-clktmp;
|
start+=clock()-clktmp; |
| } break;
|
} break; |
| }
|
} |
| }
|
} |
| }
|
} |
| but=getmousepos(&x,&y);
|
but=getmousepos(&x,&y); |
| if (!but && !sqclosed && !cmines) {
|
if (!but && !sqclosed && !cmines) { |
| curr=clock()-start;
|
curr=clock()-start; |
| break;
|
break; |
| } /* All mines discovered */
|
} /* All mines discovered */ |
| if (cminesold != cmines) { /* Update Mines */
|
if (cminesold != cmines) { /* Update Mines */ |
| char txt[6]=" ÛÛÛ ";
|
char txt[6]=" ÛÛÛ "; |
| if (cminesold>999) {
|
if (cminesold>999) { |
| txt[0]=txt[1];
|
txt[0]=txt[1]; |
| txt[4]=EOS;
|
txt[4]=EOS; |
| }
|
} |
| cminesold=cmines;
|
cminesold=cmines; |
| if (isininfo(x,y))
|
if (isininfo(x,y)) |
| hidemouse();
|
hidemouse(); |
| setcolor(I_BCKCOLOR);
|
setcolor(I_BCKCOLOR); |
| outtextxy(infox+INFOXSIZE/2,textheight(infostr3[0])/2+infoy+(9*textheight(infostr3[0])),txt);
|
outtextxy(infox+INFOXSIZE/2,textheight(infostr3[0])/2+infoy+(9*textheight(infostr3[0])),txt); |
| sprintf(txt,"%03u",cmines);
|
sprintf(txt,"%03u",cmines); |
| setcolor(I_NUMCOLOR);
|
setcolor(I_NUMCOLOR); |
| outtextxy(infox+INFOXSIZE/2,textheight(infostr3[0])/2+infoy+(9*textheight(infostr3[0])),txt);
|
outtextxy(infox+INFOXSIZE/2,textheight(infostr3[0])/2+infoy+(9*textheight(infostr3[0])),txt); |
| if (isininfo(x,y))
|
if (isininfo(x,y)) |
| showmouse();
|
showmouse(); |
| }
|
} |
| if ((unsigned)(curr/CLOCKS_PER_SEC)!=(unsigned)(clock()/CLOCKS_PER_SEC)) {
|
if ((unsigned)(curr/CLOCKS_PER_SEC)!=(unsigned)(clock()/CLOCKS_PER_SEC)) { |
| /* Update Time */
|
/* Update Time */ |
| char txt[9] = "Û ÛÛ ÛÛ";
|
char txt[9] = "Û ÛÛ ÛÛ"; |
| curr = clock();
|
curr = clock(); |
| if (isininfo(x,y))
|
if (isininfo(x,y)) |
| hidemouse();
|
hidemouse(); |
| setcolor(I_BCKCOLOR);
|
setcolor(I_BCKCOLOR); |
| outtextxy(infox+INFOXSIZE/2,textheight(infostr3[0])/2+infoy+(6*textheight(infostr3[0])),txt);
|
outtextxy(infox+INFOXSIZE/2,textheight(infostr3[0])/2+infoy+(6*textheight(infostr3[0])),txt); |
| sprintf(txt,"%u %02u %02u",
|
sprintf(txt,"%u %02u %02u", |
| (unsigned)(((clock()-start)/CLOCKS_PER_SEC)/60)/60,
|
(unsigned)(((clock()-start)/CLOCKS_PER_SEC)/60)/60, |
| (unsigned)(((clock()-start)/CLOCKS_PER_SEC)/60)%60,
|
(unsigned)(((clock()-start)/CLOCKS_PER_SEC)/60)%60, |
| (unsigned)((clock()-start)/CLOCKS_PER_SEC)%60);
|
(unsigned)((clock()-start)/CLOCKS_PER_SEC)%60); |
| setcolor(I_NUMCOLOR);
|
setcolor(I_NUMCOLOR); |
| outtextxy(infox+INFOXSIZE/2,textheight(infostr3[0])/2+infoy+(6*textheight(infostr3[0])),txt);
|
outtextxy(infox+INFOXSIZE/2,textheight(infostr3[0])/2+infoy+(6*textheight(infostr3[0])),txt); |
| if (isininfo(x,y))
|
if (isininfo(x,y)) |
| showmouse();
|
showmouse(); |
| }
|
} |
| if (but&&isininfo(x,y)) {
|
if (but&&isininfo(x,y)) { |
| WORD xx,yy;
|
WORD xx,yy; |
| while (!releasebutton(but-1,&xx,&yy));
|
while (!releasebutton(but-1,&xx,&yy)); |
| hidemouse();
|
hidemouse(); |
| if (xx!=x||yy!=y)
|
if (xx!=x||yy!=y) |
| WriteInfo(xx-(x-infox),yy-(y-infoy));
|
WriteInfo(xx-(x-infox),yy-(y-infoy)); |
| showmouse();
|
showmouse(); |
| but=0;
|
but=0; |
| }
|
} |
| but &= 3;
|
but &= 3; |
| x = (x-xoff) / barsize;
|
x = (x-xoff) / barsize; |
| y = (y-yoff) / barsize;
|
y = (y-yoff) / barsize; |
| if (xold==0xffff) {
|
if (xold==0xffff) { |
| xold=x;
|
xold=x; |
| yold=y;
|
yold=y; |
| }
|
} |
| if ((x!=xold||y!=yold)) {
|
if ((x!=xold||y!=yold)) { |
| /* Position change */
|
/* Position change */ |
| if (xold<nx&&yold<ny&&sqpress(xold,yold)&&!sqopen(xold,yold)) {
|
if (xold<nx&&yold<ny&&sqpress(xold,yold)&&!sqopen(xold,yold)) { |
| sqpress(xold,yold)=NO;
|
sqpress(xold,yold)=NO; |
| hidemouse();
|
hidemouse(); |
| SetSquare(xold,yold,1);
|
SetSquare(xold,yold,1); |
| showmouse();
|
showmouse(); |
| }
|
} |
| xold=x;
|
xold=x; |
| yold=y;
|
yold=y; |
| }
|
} |
| if (x<nx&&y<ny&&!underinfo(x,y)){
|
if (x<nx&&y<ny&&!underinfo(x,y)){ |
| if (!but){
|
if (!but){ |
| mlstant=mrstant=0;
|
mlstant=mrstant=0; |
| (void)releasebutton(0,NULL,NULL);
|
(void)releasebutton(0,NULL,NULL); |
| (void)releasebutton(1,NULL,NULL);
|
(void)releasebutton(1,NULL,NULL); |
| }
|
} |
| if ((but==2)&&!sqopen(x,y)&&mlstant!=but) {
|
if ((but==2)&&!sqopen(x,y)&&mlstant!=but) { |
| /* Right button pressed */
|
/* Right button pressed */ |
| mlstant=but;
|
mlstant=but; |
| switch (((sqmark(x,y)+(!sqmark(x,y)&&!cmines?2:1))%3)) {
|
switch (((sqmark(x,y)+(!sqmark(x,y)&&!cmines?2:1))%3)) { |
| case 1:cmines--;sqmark(x,y)=1;break;
|
case 1:cmines--;sqmark(x,y)=1;break; |
| case 2:if (sqmark(x,y)==1)cmines++;sqmark(x,y)=2;break;
|
case 2:if (sqmark(x,y)==1)cmines++;sqmark(x,y)=2;break; |
| default:sqmark(x,y)=0;break;
|
default:sqmark(x,y)=0;break; |
| }
|
} |
| hidemouse();
|
hidemouse(); |
| SetSquare(x,y,1);
|
SetSquare(x,y,1); |
| showmouse();
|
showmouse(); |
| } else {
|
} else { |
| if (but==1&&!sqopen(x,y)&&!sqpress(x,y)&&sqmark(x,y)!=1) {
|
if (but==1&&!sqopen(x,y)&&!sqpress(x,y)&&sqmark(x,y)!=1) { |
| /* Left button pressed and square not pressed */
|
/* Left button pressed and square not pressed */ |
| sqpress(x,y)=YES;
|
sqpress(x,y)=YES; |
| hidemouse();
|
hidemouse(); |
| SetSquare(x,y,0);
|
SetSquare(x,y,0); |
| showmouse();
|
showmouse(); |
| } else {
|
} else { |
| if (!but &&
|
if (!but && |
| !sqopen(x,y) && sqpress(x,y) && sqmark(x,y) != 1) {
|
!sqopen(x,y) && sqpress(x,y) && sqmark(x,y) != 1) { |
| if (first_click) {
|
if (first_click) { |
| while (value(x, y) != 0) {
|
while (value(x, y) != 0) { |
| SetMines();
|
SetMines(); |
| }
|
} |
| first_click = 0;
|
first_click = 0; |
| }
|
} |
| /* Left button released; Open the square */
|
/* Left button released; Open the square */ |
| if (value(x,y) == MINE)
|
if (value(x,y) == MINE) |
| break;
|
break; |
| hidemouse();
|
hidemouse(); |
| OpenSquare(x,y);
|
OpenSquare(x,y); |
| showmouse();
|
showmouse(); |
| if (infosafe == NULL)
|
if (infosafe == NULL) |
| ShowInfo();
|
ShowInfo(); |
| /* previous info hide was done by Set Square */
|
/* previous info hide was done by Set Square */ |
| } else {
|
} else { |
| if (but==3&&sqopen(x,y)&&mrstant!=but) {
|
if (but==3&&sqopen(x,y)&&mrstant!=but) { |
| /* Open near squares */
|
/* Open near squares */ |
| mrstant=but;
|
mrstant=but; |
| HideInfo();
|
HideInfo(); |
| if (OpenNearSquares(x,y)==YES)
|
if (OpenNearSquares(x,y)==YES) |
| break;
|
break; |
| ShowInfo();
|
ShowInfo(); |
| }
|
} |
| }
|
} |
| }
|
} |
| }
|
} |
| }
|
} |
| }
|
} |
| HideInfo();
|
HideInfo(); |
| (void)releasebutton(0,NULL,NULL);
|
(void)releasebutton(0,NULL,NULL); |
| if (but!=ESC) { /* game end (not break) */
|
if (but!=ESC) { /* game end (not break) */ |
| if (sqclosed) {/* GAME LOST */
|
if (sqclosed) {/* GAME LOST */ |
| settextstyle(0,0,1);
|
settextstyle(0,0,1); |
| hidemouse();
|
hidemouse(); |
| for (x=0;x<nx;x++) {
|
for (x=0;x<nx;x++) { |
| for (y=0;y<ny;y++) {
|
for (y=0;y<ny;y++) { |
| if (value(x,y)==MINE) {
|
if (value(x,y)==MINE) { |
| setcolor(LIGHTRED);
|
setcolor(LIGHTRED); |
| outtextxy(xoff+barsize*x+barsize/2-1, yoff+barsize*y+barsize/2, "Û");
|
outtextxy(xoff+barsize*x+barsize/2-1, yoff+barsize*y+barsize/2, "Û"); |
| setcolor(BLACK);
|
setcolor(BLACK); |
| outtextxy(xoff+barsize*x+barsize/2-1, yoff+barsize*y+barsize/2, "*");
|
outtextxy(xoff+barsize*x+barsize/2-1, yoff+barsize*y+barsize/2, "*"); |
| }
|
} |
| else if (sqmark(x,y)==1) {
|
else if (sqmark(x,y)==1) { |
| setcolor(YELLOW);
|
setcolor(YELLOW); |
| line(xoff+barsize*x,yoff+barsize*y,xoff+barsize*x+barsize-1,yoff+barsize*y+barsize-1);
|
line(xoff+barsize*x,yoff+barsize*y,xoff+barsize*x+barsize-1,yoff+barsize*y+barsize-1); |
| line(xoff+barsize*x,yoff+barsize*y+barsize-1,xoff+barsize*x+barsize-1,yoff+barsize*y);
|
line(xoff+barsize*x,yoff+barsize*y+barsize-1,xoff+barsize*x+barsize-1,yoff+barsize*y); |
| }
|
} |
| }
|
} |
| }
|
} |
| showmouse();
|
showmouse(); |
| while (kbhit())(void)getch();
|
while (kbhit())(void)getch(); |
| while (!releasebutton(0,NULL,NULL)&&!kbhit());
|
while (!releasebutton(0,NULL,NULL)&&!kbhit()); |
| hidemouse();
|
hidemouse(); |
| DrawDefWindow(500,190,290,"Upsss... SMOLA!");
|
DrawDefWindow(500,190,290,"Upsss... SMOLA!"); |
| outtextxy(getmaxx()/2,243,"Chces hrat znovu?");
|
outtextxy(getmaxx()/2,243,"Chces hrat znovu?"); |
| DrawNormButton(getmaxx()/2-65,262,"","Ano",GREEN,WHITE,WHITE);
|
DrawNormButton(getmaxx()/2-65,262,"","Ano",GREEN,WHITE,WHITE); |
| DrawNormButton(getmaxx()/2+65,262,"","Nie",RED,WHITE,WHITE);
|
DrawNormButton(getmaxx()/2+65,262,"","Nie",RED,WHITE,WHITE); |
| showmouse();
|
showmouse(); |
| while (kbhit())(void)getch();
|
while (kbhit())(void)getch(); |
| while (1) {
|
while (1) { |
| if ((releasebutton(0,&x,&y)&&isinnormbutton(x,y,getmaxx()/2-65,262))
|
if ((releasebutton(0,&x,&y)&&isinnormbutton(x,y,getmaxx()/2-65,262)) |
| ||(kbhit()&&getch()==EOL)){
|
||(kbhit()&&getch()==EOL)){ |
| FadeOut();
|
FadeOut(); |
| return(1);
|
return(1); |
| }
|
} |
| if ((releasebutton(0,&x,&y)&&isinnormbutton(x,y,getmaxx()/2+65,262))
|
if ((releasebutton(0,&x,&y)&&isinnormbutton(x,y,getmaxx()/2+65,262)) |
| ||(kbhit()&&getch()==ESC))
|
||(kbhit()&&getch()==ESC)) |
| return(0);
|
return(0); |
| }
|
} |
| } else { /* GAME WIN */
|
} else { /* GAME WIN */ |
| register int k, items;
|
register int k, items; |
| HISCORE_ITEM item;
|
HISCORE_ITEM item; |
| char s[80];
|
char s[80]; |
| hidemouse();
|
hidemouse(); |
| DrawDefWindow(500,190,290,"Hotovo!");
|
DrawDefWindow(500,190,290,"Hotovo!"); |
| DrawNormButton(getmaxx()/2,262,"","OK",RED,WHITE,WHITE);
|
DrawNormButton(getmaxx()/2,262,"","OK",RED,WHITE,WHITE); |
| sprintf(s,"%u m¡n si zlikvidoval(a) na ploche %ux%u za %u:%02u:%02u",
|
sprintf(s,"%u m¡n si zlikvidoval(a) na ploche %ux%u za %u:%02u:%02u", |
| getmines(nx,ny,diff),nx,ny,
|
getmines(nx,ny,diff),nx,ny, |
| (unsigned)((curr/CLOCKS_PER_SEC)/60)/60,
|
(unsigned)((curr/CLOCKS_PER_SEC)/60)/60, |
| (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); |
| for (k=0; s[k]!=EOS; k++)
|
for (k=0; s[k]!=EOS; k++) |
| if (!isdigit(s[k]))
|
if (!isdigit(s[k])) |
| s[k]=SPC;
|
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))
|
while (!(releasebutton(0,&x,&y)) |
| ||!isinnormbutton(x,y,getmaxx()/2,262))
|
||!isinnormbutton(x,y,getmaxx()/2,262)) |
| if (kbhit())
|
if (kbhit()) |
| getch();
|
getch(); |
| if ((items = hiscore_items()) >= 0) {
|
if ((items = hiscore_items()) >= 0) { |
| for (k = 0; k <= min(items, HISCORE_MAX_ITEMS - 1); k++) {
|
for (k = 0; k <= min(items, HISCORE_MAX_ITEMS - 1); k++) { |
| if (k == items)
|
if (k == items) |
| break;
|
break; |
| if (hiscore_get_item(&item, k) < 0)
|
if (hiscore_get_item(&item, k) < 0) |
| WriteError();
|
WriteError(); |
| if (getmines(nx,ny,diff) > getmines(item.nx,item.ny,item.diff))
|
if (getmines(nx,ny,diff) > getmines(item.nx,item.ny,item.diff)) |
| break;
|
break; |
| if (getmines(nx,ny,diff) == getmines(item.nx,item.ny,item.diff)) {
|
if (getmines(nx,ny,diff) == getmines(item.nx,item.ny,item.diff)) { |
| if (diff > item.diff)
|
if (diff > item.diff) |
| break;
|
break; |
| if (diff == item.diff) {
|
if (diff == item.diff) { |
| if (curr < time2clock(item.time))
|
if (curr < time2clock(item.time)) |
| break;
|
break; |
| }
|
} |
| }
|
} |
| if (k == HISCORE_MAX_ITEMS - 1) {
|
if (k == HISCORE_MAX_ITEMS - 1) { |
| k = 0xff;
|
k = 0xff; |
| break;
|
break; |
| }
|
} |
| }
|
} |
| if (k!=0xff) {
|
if (k!=0xff) { |
| register BYTE count=0,c;
|
register BYTE count=0,c; |
| hidemouse();
|
hidemouse(); |
| DrawDefWindow(550,207,273,"Zadaj svoje meno:");
|
DrawDefWindow(550,207,273,"Zadaj svoje meno:"); |
| memset(item.name,EOS,HISCORE_NAME_LEN+1);
|
memset(item.name,EOS,HISCORE_NAME_LEN+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;
|
break; |
| default:if (c>=0x20&&c<0xff) /* better than isprint(c) */
|
default:if (c>=0x20&&c<0xff) /* better than isprint(c) */ |
| if (count < HISCORE_NAME_LEN) {
|
if (count < HISCORE_NAME_LEN) { |
| item.name[count] = c;
|
item.name[count] = c; |
| count++;
|
count++; |
| }
|
} |
| break;
|
break; |
| }
|
} |
| setcolor(k>2?LIGHTCYAN:ColorConvert(4-k));outtextxy(getmaxx()/2,257,item.name);
|
setcolor(k>2?LIGHTCYAN:ColorConvert(4-k));outtextxy(getmaxx()/2,257,item.name); |
| }
|
} |
| showmouse();
|
showmouse(); |
| item.nx = nx;
|
item.nx = nx; |
| item.ny = ny;
|
item.ny = ny; |
| item.diff = diff;
|
item.diff = diff; |
| getdate(&item.date);
|
getdate(&item.date); |
| item.time.ti_hour = (unsigned)((curr/CLOCKS_PER_SEC)/60)/60;
|
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_min = (unsigned)((curr/CLOCKS_PER_SEC)/60)%60; |
| item.time.ti_sec = (unsigned)(curr/CLOCKS_PER_SEC)%60;
|
item.time.ti_sec = (unsigned)(curr/CLOCKS_PER_SEC)%60; |
| if (hiscore_set_item(&item, k) < 0)
|
if (hiscore_set_item(&item, k) < 0) |
| WriteError();
|
WriteError(); |
| HscTable();
|
HscTable(); |
| FadeOut();
|
FadeOut(); |
| }
|
} |
| }
|
} |
| }
|
} |
| }
|
} |
| return 0;
|
return 0; |
| } /* }}} */
|
} /* }}} */ |
|
|
|
| /*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/ |
| void Help(void) /* {{{ */
|
void Help(void) /* {{{ */ |
| {
|
{ |
| WORD x,y;
|
WORD x,y; |
| do{
|
do{ |
| char helptext[]="\
|
char helptext[]="\ |
| Cielom je odm¡novat cel‚ pole.\n\
|
Cielom je odm¡novat cel‚ pole.\n\ |
| Je nutn‚ oznacit vsetky m¡ny a odokryt vsetky nezam¡novane pol¡cka.\n\
|
Je nutn‚ oznacit vsetky m¡ny a odokryt vsetky nezam¡novane pol¡cka.\n\ |
| Hra sa ovl da pomocou mysi a kl vesnice.\n\
|
Hra sa ovl da pomocou mysi a kl vesnice.\n\ |
| \n\
|
\n\ |
| <ôLav‚ tlacidloõ odkryva policko. V pr¡pade, ze sa tam nach dza\n\
|
<ôLav‚ tlacidloõ odkryva policko. V pr¡pade, ze sa tam nach dza\n\ |
| < m¡na hra ne£spesne konc¡. Inak sa odokryj£ vsetky\n\
|
< m¡na hra ne£spesne konc¡. Inak sa odokryj£ vsetky\n\ |
| < nezam¡novan‚ pol¡cka nach dzaj£ce sa v jeho okol¡.\n\
|
< nezam¡novan‚ pol¡cka nach dzaj£ce sa v jeho okol¡.\n\ |
| \n\
|
\n\ |
| <ôPrav‚ tlacidloõ oznac¡ pol¡cko ako m¡nu. Po dalsom stlacen¡ ako\n\
|
<ôPrav‚ tlacidloõ oznac¡ pol¡cko ako m¡nu. Po dalsom stlacen¡ ako\n\ |
| < potencialnu m¡nu a po dalsom oznacenie zrus¡. Miesta\n\
|
< potencialnu m¡nu a po dalsom oznacenie zrus¡. Miesta\n\ |
| < oznacen‚ ako m¡na s£ zabezpecen‚ pred odokryvan¡m.\n\
|
< oznacen‚ ako m¡na s£ zabezpecen‚ pred odokryvan¡m.\n\ |
| \n\
|
\n\ |
| <ôEscõ vykon priame ukoncenie hry a n vrat do menu.\n\
|
<ôEscõ vykon priame ukoncenie hry a n vrat do menu.\n\ |
| <ôF1õ zobraz¡ okno pomoci.\n\
|
<ôF1õ zobraz¡ okno pomoci.\n\ |
| <ôF4õ docasne prerus¡ hru (PAUZA).\n\
|
<ôF4õ docasne prerus¡ hru (PAUZA).\n\ |
| \n\
|
\n\ |
| Po oznacen¡ vsetkych m¡n a odkryt¡ vsetkych nezam¡novanych pol¡cok\n\
|
Po oznacen¡ vsetkych m¡n a odkryt¡ vsetkych nezam¡novanych pol¡cok\n\ |
| sa hra £spesne konc¡ a moze byt zap¡san do ôTabulky najleps¡chõ.\n\
|
sa hra £spesne konc¡ a moze byt zap¡san do ôTabulky najleps¡chõ.\n\ |
| Hlavnym krit‚riom pre z pis je vacs¡ pocet m¡n, pri rovnosti\n\
|
Hlavnym krit‚riom pre z pis je vacs¡ pocet m¡n, pri rovnosti\n\ |
| rozhoduje mens¡ cas.\n\
|
rozhoduje mens¡ cas.\n\ |
| \n\
|
\n\ |
| <Tato hra vznikla z podnetu nezn meho autora ako pr¡klad softv‚rov‚ho\n\
|
<Tato hra vznikla z podnetu nezn meho autora ako pr¡klad softv‚rov‚ho\n\ |
| <produktu. Je volne s¡riteln a ak‚kolvek vyuz¡vanie na komercn‚\n\
|
<produktu. Je volne s¡riteln a ak‚kolvek vyuz¡vanie na komercn‚\n\ |
| <£cely je mozn‚ len so s£hlasom autora. V pr¡pade z ujmu o dalsie\n\
|
<£cely je mozn‚ len so s£hlasom autora. V pr¡pade z ujmu o dalsie\n\ |
| <programy sa informujte na adrese:\n\
|
<programy sa informujte na adrese:\n\ |
| \n\
|
\n\ |
| >ôOndrej Jomb¡k ml.õ\n\
|
>ôOndrej Jomb¡k ml.õ\n\ |
| >ôHol¡cska 26õ \n\
|
>ôHol¡cska 26õ \n\ |
| >ô851 01 Bratislavaõ \n";
|
>ô851 01 Bratislavaõ \n"; |
| FadeOut();
|
FadeOut(); |
| hidemouse();
|
hidemouse(); |
| cleardevice();
|
cleardevice(); |
| DrawDefWindow(getmaxx()-30,15,getmaxy()-15,"Pomoc");
|
DrawDefWindow(getmaxx()-30,15,getmaxy()-15,"Pomoc"); |
| DrawNormButton(getmaxx()/2,getmaxy()-93,"","OK",RED,WHITE,WHITE);
|
DrawNormButton(getmaxx()/2,getmaxy()-93,"","OK",RED,WHITE,WHITE); |
| DrawNormButton(40+50,getmaxy()-93,"In‚ programy","Pexeso",BLUE,H_DEFCOLOR,H_INSCOLOR);
|
DrawNormButton(40+50,getmaxy()-93,"In‚ programy","Pexeso",BLUE,H_DEFCOLOR,H_INSCOLOR); |
| DrawNormButton(40+75,getmaxy()-78,"","ImageEdit",BLUE,H_DEFCOLOR,H_INSCOLOR);
|
DrawNormButton(40+75,getmaxy()-78,"","ImageEdit",BLUE,H_DEFCOLOR,H_INSCOLOR); |
| DrawNormButton(40+100,getmaxy()-63,"","2D / 3D",BLUE,H_DEFCOLOR,H_INSCOLOR);
|
DrawNormButton(40+100,getmaxy()-63,"","2D / 3D",BLUE,H_DEFCOLOR,H_INSCOLOR); |
| DrawNormButton(40+125,getmaxy()-48,"","...",BLUE,H_DEFCOLOR,H_INSCOLOR);
|
DrawNormButton(40+125,getmaxy()-48,"","...",BLUE,H_DEFCOLOR,H_INSCOLOR); |
| DrawWindow(getmaxx()/2-49,getmaxy()-48,getmaxx()-40,getmaxy()-33,MAGENTA,LIGHTCYAN);
|
DrawWindow(getmaxx()/2-49,getmaxy()-48,getmaxx()-40,getmaxy()-33,MAGENTA,LIGHTCYAN); |
| setcolor(WHITE);outtextxy((getmaxx()/2-49+getmaxx()-40)/2,getmaxy()-40,"Uk zka zdrojov‚ho textu z tohto programu");
|
setcolor(WHITE);outtextxy((getmaxx()/2-49+getmaxx()-40)/2,getmaxy()-40,"Uk zka zdrojov‚ho textu z tohto programu"); |
| ShowHelpText(40,70,12,H_DEFCOLOR,H_INSCOLOR,helptext);
|
ShowHelpText(40,70,12,H_DEFCOLOR,H_INSCOLOR,helptext); |
| showmouse();
|
showmouse(); |
| FadeIn();
|
FadeIn(); |
| while (1) {
|
while (1) { |
| if (kbhit())
|
if (kbhit()) |
| if (getch()==EOL); /* break; */
|
if (getch()==EOL); /* break; */ |
| if (releasebutton(0,&x,&y)) {
|
if (releasebutton(0,&x,&y)) { |
| if (isinnormbutton(x,y,40+50,getmaxy()-93)||
|
if (isinnormbutton(x,y,40+50,getmaxy()-93)|| |
| isinnormbutton(x,y,40+75,getmaxy()-78)||
|
isinnormbutton(x,y,40+75,getmaxy()-78)|| |
| isinnormbutton(x,y,40+100,getmaxy()-63)||
|
isinnormbutton(x,y,40+100,getmaxy()-63)|| |
| isinnormbutton(x,y,40+125,getmaxy()-48)){
|
isinnormbutton(x,y,40+125,getmaxy()-48)){ |
| char ineprogtext[]="\
|
char ineprogtext[]="\ |
| < In‚ programyô?õ Niektor‚ sa nach dzaj£\n\
|
< In‚ programyô?õ Niektor‚ sa nach dzaj£\n\ |
| <na mojej ôhomepageõ, ale viac informaci¡\n\
|
<na mojej ôhomepageõ, ale viac informaci¡\n\ |
| < sa dozviete prostredn¡ctvom ôe-mailõu.\n";
|
< sa dozviete prostredn¡ctvom ôe-mailõu.\n"; |
| void*safe;
|
void*safe; |
| static WORD fontcolor=2;
|
static WORD fontcolor=2; |
| hidemouse();
|
hidemouse(); |
| if ((safe=malloc(imagesize(229,374,getmaxx()-9,getmaxy()-9)))==NULL)exit(1);
|
if ((safe=malloc(imagesize(229,374,getmaxx()-9,getmaxy()-9)))==NULL)exit(1); |
| getimage(229,374,getmaxx()-9,getmaxy()-9,safe);
|
getimage(229,374,getmaxx()-9,getmaxy()-9,safe); |
| DrawWindow(229,374,getmaxx()-9,getmaxy()-9,BLUE,WHITE);
|
DrawWindow(229,374,getmaxx()-9,getmaxy()-9,BLUE,WHITE); |
| DrawNormButton((getmaxx()+229)/2,getmaxy()-38,"","<--sp„t--",GREEN,WHITE,WHITE);
|
DrawNormButton((getmaxx()+229)/2,getmaxy()-38,"","<--sp„t--",GREEN,WHITE,WHITE); |
| ShowHelpText(280,392,15,11+(fontcolor++)%3,WHITE,ineprogtext);
|
ShowHelpText(280,392,15,11+(fontcolor++)%3,WHITE,ineprogtext); |
| showmouse();
|
showmouse(); |
| while (!(releasebutton(0,&x,&y))
|
while (!(releasebutton(0,&x,&y)) |
| ||!isinnormbutton(x,y,(getmaxx()+229)/2,getmaxy()-38))
|
||!isinnormbutton(x,y,(getmaxx()+229)/2,getmaxy()-38)) |
| if (kbhit())
|
if (kbhit()) |
| getch();
|
getch(); |
| hidemouse();putimage(229,374,safe,COPY_PUT);showmouse();
|
hidemouse();putimage(229,374,safe,COPY_PUT);showmouse(); |
| free(safe);
|
free(safe); |
| x=y=0;
|
x=y=0; |
| }
|
} |
| if (isinnormbutton(x,y,getmaxx()/2,getmaxy()-93)) {
|
if (isinnormbutton(x,y,getmaxx()/2,getmaxy()-93)) { |
| x=y=0xffff;
|
x=y=0xffff; |
| break;
|
break; |
| }
|
} |
| if (isinbar(x,y,getmaxx()/2-49,getmaxy()-48,getmaxx()-40,getmaxy()-33)) {
|
if (isinbar(x,y,getmaxx()/2-49,getmaxy()-48,getmaxx()-40,getmaxy()-33)) { |
| char zdrojtext[]="\
|
char zdrojtext[]="\ |
| < Tak toto je cast hlavn‚ho ovl dacieho modulu tohto programu,\n\
|
< Tak toto je cast hlavn‚ho ovl dacieho modulu tohto programu,\n\ |
| <ktory m (zatial) nieco cez ô10 000 riadkovõ. Ako programovac¡ jazyk\n\
|
<ktory m (zatial) nieco cez ô10 000 riadkovõ. Ako programovac¡ jazyk\n\ |
| <bol zvoleny ôBorland C++ v3.1õ od firmy Borland International, Inc.\n\
|
<bol zvoleny ôBorland C++ v3.1õ od firmy Borland International, Inc.\n\ |
| <Samozrejme, ze v skutocnosti zdrojovy k¢d nevyzer takto, tu je\n\
|
<Samozrejme, ze v skutocnosti zdrojovy k¢d nevyzer takto, tu je\n\ |
| <len trosku zhustenz, aby sa toho viac zmestilo na obrazovku.\n\
|
<len trosku zhustenz, aby sa toho viac zmestilo na obrazovku.\n\ |
| ôÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜõ\n\
|
ôÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜõ\n\ |
| if (but&&isininfo(x,y)){register WORD xx,yy;\n\
|
if (but&&isininfo(x,y)){register WORD xx,yy;\n\ |
| while (!releasebutton(but-1,&xx,&yy));hidemouse();\n\
|
while (!releasebutton(but-1,&xx,&yy));hidemouse();\n\ |
| if (xx!=x||yy!=y)WriteInfo(xx-(x-infox),yy-(y-infoy));\n\
|
if (xx!=x||yy!=y)WriteInfo(xx-(x-infox),yy-(y-infoy));\n\ |
| showmouse();but=0;}\n\
|
showmouse();but=0;}\n\ |
| but&=3;x=(x-xoff)/barsize;y=(y-yoff)/barsize;\n\
|
but&=3;x=(x-xoff)/barsize;y=(y-yoff)/barsize;\n\ |
| if (xold==0xffff){xold=x;yold=y;}\n\
|
if (xold==0xffff){xold=x;yold=y;}\n\ |
| if ((x!=xold||y!=yold)){\n\
|
if ((x!=xold||y!=yold)){\n\ |
| if (xold<nx&&yold<ny&&sqpress(xold,yold)&&!sqopen(xold,yold)){\n\
|
if (xold<nx&&yold<ny&&sqpress(xold,yold)&&!sqopen(xold,yold)){\n\ |
| sqpress(xold,yold)=NO;hidemouse();\n\
|
sqpress(xold,yold)=NO;hidemouse();\n\ |
| SetSquare(xold,yold,1);showmouse();}\n\
|
SetSquare(xold,yold,1);showmouse();}\n\ |
| xold=x;yold=y;}if (x<nx&&y<ny&&!underinfo(x,y)){\n\
|
xold=x;yold=y;}if (x<nx&&y<ny&&!underinfo(x,y)){\n\ |
| if (!but){mlstant=mrstant=0;\n\
|
if (!but){mlstant=mrstant=0;\n\ |
| (void)releasebutton(0,NULL,NULL);(void)releasebutton(1,NULL,NULL);}\n\
|
(void)releasebutton(0,NULL,NULL);(void)releasebutton(1,NULL,NULL);}\n\ |
| if ((but==2)&&!sqopen(x,y)&&mlstant!=but){mlstant=but;\n\
|
if ((but==2)&&!sqopen(x,y)&&mlstant!=but){mlstant=but;\n\ |
| switch(((sqmark(x,y)+(!sqmark(x,y)&&!cmines?2:1))%3)){\n\
|
switch(((sqmark(x,y)+(!sqmark(x,y)&&!cmines?2:1))%3)){\n\ |
| case 1:cmines--;sqmark(x,y)=1;break;\n\
|
case 1:cmines--;sqmark(x,y)=1;break;\n\ |
| case 2:if (sqmark(x,y)==1)cmines++;sqmark(x,y)=2;break;\n\
|
case 2:if (sqmark(x,y)==1)cmines++;sqmark(x,y)=2;break;\n\ |
| default:sqmark(x,y)=0;break;}hidemouse();SetSquare(x,y,1);showmouse();}\n\
|
default:sqmark(x,y)=0;break;}hidemouse();SetSquare(x,y,1);showmouse();}\n\ |
| else{if (but==1&&!sqopen(x,y)&&!sqpress(x,y)&&sqmark(x,y)!=1){\n\
|
else{if (but==1&&!sqopen(x,y)&&!sqpress(x,y)&&sqmark(x,y)!=1){\n\ |
| sqpress(x,y)=YES; hidemouse();SetSquare(x,y,0);showmouse();}\n\
|
sqpress(x,y)=YES; hidemouse();SetSquare(x,y,0);showmouse();}\n\ |
| else{if (!but&&!sqopen(x,y)&&sqpress(x,y)&&sqmark(x,y)!=1){\n\
|
else{if (!but&&!sqopen(x,y)&&sqpress(x,y)&&sqmark(x,y)!=1){\n\ |
| if (value(x,y)==MINE)break;hidemouse();OpenSquare(x,y);showmouse();\n\
|
if (value(x,y)==MINE)break;hidemouse();OpenSquare(x,y);showmouse();\n\ |
| if (infosafe==NULL)ShowInfo();}else{\n\
|
if (infosafe==NULL)ShowInfo();}else{\n\ |
| if (but==3&&sqopen(x,y)&&mrstant!=but){mrstant=but;\n\
|
if (but==3&&sqopen(x,y)&&mrstant!=but){mrstant=but;\n\ |
| if (OpenNearSquares(x,y)==YES)break;\n\
|
if (OpenNearSquares(x,y)==YES)break;\n\ |
| }}}}}}HideInfo();(void)releasebutton(0,NULL,NULL);\n\
|
}}}}}}HideInfo();(void)releasebutton(0,NULL,NULL);\n\ |
| ôßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßõ\n";
|
ôßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßõ\n"; |
| FadeOut();
|
FadeOut(); |
| hidemouse();
|
hidemouse(); |
| DrawDefWindow(getmaxx(),0,getmaxy(),"Uk zka zdrojov‚ho textu");
|
DrawDefWindow(getmaxx(),0,getmaxy(),"Uk zka zdrojov‚ho textu"); |
| DrawNormButton(getmaxx()/2,getmaxy()-31,"","OK",RED,WHITE,WHITE);
|
DrawNormButton(getmaxx()/2,getmaxy()-31,"","OK",RED,WHITE,WHITE); |
| ShowHelpText(30,52,12,LIGHTGREEN,LIGHTCYAN,zdrojtext);
|
ShowHelpText(30,52,12,LIGHTGREEN,LIGHTCYAN,zdrojtext); |
| showmouse();
|
showmouse(); |
| FadeIn();
|
FadeIn(); |
| while (!(releasebutton(0,&x,&y))
|
while (!(releasebutton(0,&x,&y)) |
| ||!isinnormbutton(x,y,getmaxx()/2,getmaxy()-31))
|
||!isinnormbutton(x,y,getmaxx()/2,getmaxy()-31)) |
| if (kbhit())
|
if (kbhit()) |
| getch();
|
getch(); |
| break;
|
break; |
| }
|
} |
| }
|
} |
| }
|
} |
| } 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; |
| char*tmpbegin,*tmpend = NULL,*endline;
|
char*tmpbegin,*tmpend = NULL,*endline; |
| settextstyle(0,0,1);
|
settextstyle(0,0,1); |
| while ((endline=strchr(helpstr,'\n'))!=NULL) {
|
while ((endline=strchr(helpstr,'\n'))!=NULL) { |
| *(endline)=EOS;
|
*(endline)=EOS; |
| switch (helpstr[0]) {
|
switch (helpstr[0]) { |
| case'<':posx=x;settextjustify(LEFT_TEXT,CENTER_TEXT);strdel(helpstr);break;
|
case'<':posx=x;settextjustify(LEFT_TEXT,CENTER_TEXT);strdel(helpstr);break; |
| case'>':posx=getmaxx()-x;settextjustify(RIGHT_TEXT,CENTER_TEXT);strdel(helpstr);break;
|
case'>':posx=getmaxx()-x;settextjustify(RIGHT_TEXT,CENTER_TEXT);strdel(helpstr);break; |
| default:posx=getmaxx()/2;settextjustify(CENTER_TEXT,CENTER_TEXT);break;
|
default:posx=getmaxx()/2;settextjustify(CENTER_TEXT,CENTER_TEXT);break; |
| }
|
} |
| if ((tmpbegin=strchr(helpstr,'ô'))!=NULL&&(tmpbegin<strchr(helpstr,EOS))) {
|
if ((tmpbegin=strchr(helpstr,'ô'))!=NULL&&(tmpbegin<strchr(helpstr,EOS))) { |
| if (*(tmpbegin+1)=='ô')tmpbegin=NULL;
|
if (*(tmpbegin+1)=='ô')tmpbegin=NULL; |
| else{
|
else{ |
| strdel(tmpbegin);
|
strdel(tmpbegin); |
| strdel(tmpend=strchr(helpstr,'õ'));
|
strdel(tmpend=strchr(helpstr,'õ')); |
| tmpend-=1;
|
tmpend-=1; |
| }
|
} |
| }
|
} |
| else tmpbegin=tmpend=NULL;
|
else tmpbegin=tmpend=NULL; |
| setcolor(defcolor);
|
setcolor(defcolor); |
| if (strlen(helpstr))outtextxy(posx,y+count*linesize,helpstr);
|
if (strlen(helpstr))outtextxy(posx,y+count*linesize,helpstr); |
| if (tmpbegin!=NULL) {
|
if (tmpbegin!=NULL) { |
| char*tmpstr=helpstr;
|
char*tmpstr=helpstr; |
| while (*helpstr!=EOS) {
|
while (*helpstr!=EOS) { |
| if ((helpstr<tmpbegin)||(helpstr>tmpend))*(helpstr)=SPC;
|
if ((helpstr<tmpbegin)||(helpstr>tmpend))*(helpstr)=SPC; |
| helpstr++;
|
helpstr++; |
| }
|
} |
| setcolor(inscolor);
|
setcolor(inscolor); |
| outtextxy(posx,y+count*linesize,tmpstr);
|
outtextxy(posx,y+count*linesize,tmpstr); |
| }
|
} |
| helpstr=endline+1;
|
helpstr=endline+1; |
| 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; |
|
|
|
| settextstyle(0,0,1);
|
settextstyle(0,0,1); |
| sqopen(x,y)=YES;
|
sqopen(x,y)=YES; |
| sqclosed--;
|
sqclosed--; |
| if ((num[0]=value(x,y)) != 0) {
|
if ((num[0]=value(x,y)) != 0) { |
| setcolor(ColorConvert(num[0]));
|
setcolor(ColorConvert(num[0])); |
| num[0]+='0';
|
num[0]+='0'; |
| outtextxy(barsize/2+min(getmaxx()-textwidth(num),xoff+barsize*x),
|
outtextxy(barsize/2+min(getmaxx()-textwidth(num),xoff+barsize*x), |
| 1+barsize/2+min(getmaxy()-textheight(num),yoff+barsize*y),num);
|
1+barsize/2+min(getmaxy()-textheight(num),yoff+barsize*y),num); |
| }
|
} |
| else{ /* Open near squares if the current number is 0 */
|
else{ /* Open near squares if the current number is 0 */ |
| a=x-1;
|
a=x-1; |
| b=y-1;
|
b=y-1; |
| if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) {
|
if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) { |
| SetSquare(a,b,0);
|
SetSquare(a,b,0); |
| OpenSquare(a,b);
|
OpenSquare(a,b); |
| }
|
} |
| a++;
|
a++; |
| if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) {
|
if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) { |
| SetSquare(a,b,0);
|
SetSquare(a,b,0); |
| OpenSquare(a,b);
|
OpenSquare(a,b); |
| }
|
} |
| a++;
|
a++; |
| if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) {
|
if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) { |
| SetSquare(a,b,0);
|
SetSquare(a,b,0); |
| OpenSquare(a,b);
|
OpenSquare(a,b); |
| }
|
} |
| b++;
|
b++; |
| if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) {
|
if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) { |
| SetSquare(a,b,0);
|
SetSquare(a,b,0); |
| OpenSquare(a,b);
|
OpenSquare(a,b); |
| }
|
} |
| a-=2;
|
a-=2; |
| if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) {
|
if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) { |
| SetSquare(a,b,0);
|
SetSquare(a,b,0); |
| OpenSquare(a,b);
|
OpenSquare(a,b); |
| }
|
} |
| b++;
|
b++; |
| if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) {
|
if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) { |
| SetSquare(a,b,0);
|
SetSquare(a,b,0); |
| OpenSquare(a,b);
|
OpenSquare(a,b); |
| }
|
} |
| a++;
|
a++; |
| if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) {
|
if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) { |
| SetSquare(a,b,0);
|
SetSquare(a,b,0); |
| OpenSquare(a,b);
|
OpenSquare(a,b); |
| }
|
} |
| a++;
|
a++; |
| if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) {
|
if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) { |
| SetSquare(a,b,0);
|
SetSquare(a,b,0); |
| OpenSquare(a,b);
|
OpenSquare(a,b); |
| }
|
} |
| }
|
} |
| settextstyle(0,0,itabsize+1);
|
settextstyle(0,0,itabsize+1); |
| } /* }}} */
|
} /* }}} */ |
|
|
|
| /*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/ |
| /* 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; |
|
|
|
| a=x-1;
|
a=x-1; |
| b=y-1;
|
b=y-1; |
| if (a>=0 && b>=0 && a<nx && b<ny && sqmark(a,b)==1)
|
if (a>=0 && b>=0 && a<nx && b<ny && sqmark(a,b)==1) |
| suma++;
|
suma++; |
| a++;
|
a++; |
| if (a>=0 && b>=0 && a<nx && b<ny && sqmark(a,b)==1)
|
if (a>=0 && b>=0 && a<nx && b<ny && sqmark(a,b)==1) |
| suma++;
|
suma++; |
| a++;
|
a++; |
| if (a>=0 && b>=0 && a<nx && b<ny && sqmark(a,b)==1)
|
if (a>=0 && b>=0 && a<nx && b<ny && sqmark(a,b)==1) |
| suma++;
|
suma++; |
| b++;
|
b++; |
| if (a>=0 && b>=0 && a<nx && b<ny && sqmark(a,b)==1)
|
if (a>=0 && b>=0 && a<nx && b<ny && sqmark(a,b)==1) |
| suma++;
|
suma++; |
| a-=2;
|
a-=2; |
| if (a>=0 && b>=0 && a<nx && b<ny && sqmark(a,b)==1)
|
if (a>=0 && b>=0 && a<nx && b<ny && sqmark(a,b)==1) |
| suma++;
|
suma++; |
| b++;
|
b++; |
| if (a>=0 && b>=0 && a<nx && b<ny && sqmark(a,b)==1)
|
if (a>=0 && b>=0 && a<nx && b<ny && sqmark(a,b)==1) |
| suma++;
|
suma++; |
| a++;
|
a++; |
| if (a>=0 && b>=0 && a<nx && b<ny && sqmark(a,b)==1)
|
if (a>=0 && b>=0 && a<nx && b<ny && sqmark(a,b)==1) |
| suma++;
|
suma++; |
| a++;
|
a++; |
| if (a>=0 && b>=0 && a<nx && b<ny && sqmark(a,b)==1)
|
if (a>=0 && b>=0 && a<nx && b<ny && sqmark(a,b)==1) |
| suma++;
|
suma++; |
| if (suma == value(x,y)) {
|
if (suma == value(x,y)) { |
| suma=0;
|
suma=0; |
| a=x-1;
|
a=x-1; |
| b=y-1;
|
b=y-1; |
| hidemouse();
|
hidemouse(); |
| if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) {
|
if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) { |
| suma|=(value(a,b)==MINE);
|
suma|=(value(a,b)==MINE); |
| SetSquare(a,b,0);
|
SetSquare(a,b,0); |
| OpenSquare(a,b);
|
OpenSquare(a,b); |
| }
|
} |
| a++;
|
a++; |
| if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) {
|
if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) { |
| suma|=(value(a,b)==MINE);
|
suma|=(value(a,b)==MINE); |
| SetSquare(a,b,0);
|
SetSquare(a,b,0); |
| OpenSquare(a,b);
|
OpenSquare(a,b); |
| }
|
} |
| a++;
|
a++; |
| if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) {
|
if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) { |
| suma|=(value(a,b)==MINE);
|
suma|=(value(a,b)==MINE); |
| SetSquare(a,b,0);
|
SetSquare(a,b,0); |
| OpenSquare(a,b);
|
OpenSquare(a,b); |
| }
|
} |
| b++;
|
b++; |
| if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) {
|
if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) { |
| suma|=(value(a,b)==MINE);
|
suma|=(value(a,b)==MINE); |
| SetSquare(a,b,0);
|
SetSquare(a,b,0); |
| OpenSquare(a,b);
|
OpenSquare(a,b); |
| }
|
} |
| a-=2;
|
a-=2; |
| if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) {
|
if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) { |
| suma|=(value(a,b)==MINE);
|
suma|=(value(a,b)==MINE); |
| SetSquare(a,b,0);
|
SetSquare(a,b,0); |
| OpenSquare(a,b);
|
OpenSquare(a,b); |
| }
|
} |
| b++;
|
b++; |
| if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) {
|
if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) { |
| suma|=(value(a,b)==MINE);
|
suma|=(value(a,b)==MINE); |
| SetSquare(a,b,0);
|
SetSquare(a,b,0); |
| OpenSquare(a,b);
|
OpenSquare(a,b); |
| }
|
} |
| a++;
|
a++; |
| if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) {
|
if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) { |
| suma|=(value(a,b)==MINE);
|
suma|=(value(a,b)==MINE); |
| SetSquare(a,b,0);
|
SetSquare(a,b,0); |
| OpenSquare(a,b);
|
OpenSquare(a,b); |
| }
|
} |
| a++;
|
a++; |
| if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) {
|
if (a>=0 && b>=0 && a<nx && b<ny && !sqopen(a,b) && sqmark(a,b)!=1) { |
| suma|=(value(a,b)==MINE);
|
suma|=(value(a,b)==MINE); |
| SetSquare(a,b,0);
|
SetSquare(a,b,0); |
| OpenSquare(a,b);
|
OpenSquare(a,b); |
| }
|
} |
| showmouse();
|
showmouse(); |
| return(suma);
|
return(suma); |
| }
|
} |
| else
|
else |
| return 0;
|
return 0; |
| } /* }}} */
|
} /* }}} */ |
|
|
|
| /*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/ |
| 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,
|
DrawNormButton(x,y,label?"Obtiaznost":"",diffstr[diff],BLUE, |
| !diff?CYAN:ColorConvert(diff+1),WHITE);
|
!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);
|
settextstyle(0,0,1); |
| outtextxy(x,y+10,str);
|
outtextxy(x,y+10,str); |
| setcolor(txtcolor);
|
setcolor(txtcolor); |
| outtextxy(x,y-7,label);
|
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); |
| DrawWindow(x-49,y-1,x-20,y+19,rctcolor,bckcolor);
|
DrawWindow(x-49,y-1,x-20,y+19,rctcolor,bckcolor); |
| DrawWindow(x+20,y-1,x+49,y+19,rctcolor,bckcolor);
|
DrawWindow(x+20,y-1,x+49,y+19,rctcolor,bckcolor); |
| settextstyle(0,0,1);
|
settextstyle(0,0,1); |
| sprintf(str,"%u",num);
|
sprintf(str,"%u",num); |
| setcolor(rctcolor);
|
setcolor(rctcolor); |
| outtextxy(x,y+10,str);
|
outtextxy(x,y+10,str); |
| setcolor(txtcolor);
|
setcolor(txtcolor); |
| outtextxy(x,y-7,label);
|
outtextxy(x,y-7,label); |
| settextstyle(0,0,2);
|
settextstyle(0,0,2); |
| outtextxy(x-34,y+11,"-");
|
outtextxy(x-34,y+11,"-"); |
| 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); |
| case '-':line(x,y+1,x+2,y+1);
|
case '-':line(x,y+1,x+2,y+1); |
| line(x+4,y,x+4,y+2);
|
line(x+4,y,x+4,y+2); |
| 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; |
| x=max(0,min(x,getmaxx()-56));
|
x=max(0,min(x,getmaxx()-56)); |
| y=max(0,min(y,getmaxy()-40));
|
y=max(0,min(y,getmaxy()-40)); |
| hidemouse();
|
hidemouse(); |
| if ((safe=malloc(imagesize(x,y,x+56,y+40)))==NULL)exit(1);
|
if ((safe=malloc(imagesize(x,y,x+56,y+40)))==NULL)exit(1); |
| getimage(x,y,x+56,y+40,safe);
|
getimage(x,y,x+56,y+40,safe); |
| DrawWindow(x,y,x+56,y+40,BLUE,WHITE);
|
DrawWindow(x,y,x+56,y+40,BLUE,WHITE); |
| showmouse();
|
showmouse(); |
| 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); |
| return ret ? NO : YES;
|
return ret ? NO : YES; |
| } /* }}} */
|
} /* }}} */ |
|
|
|
| BYTE ColorConvert(BYTE c) /* {{{ */
|
BYTE ColorConvert(BYTE c) /* {{{ */ |
| {
|
{ |
| switch (c) {
|
switch (c) { |
| case 1: return LIGHTBLUE;
|
case 1: return LIGHTBLUE; |
| case 2: return LIGHTGREEN;
|
case 2: return LIGHTGREEN; |
| case 3: return YELLOW;
|
case 3: return YELLOW; |
| case 4: return LIGHTRED;
|
case 4: return LIGHTRED; |
| default: return LIGHTMAGENTA;
|
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; |
| getpalette(&start_pal);
|
getpalette(&start_pal); |
| curr_pal.size=start_pal.size;
|
curr_pal.size=start_pal.size; |
| for (l=0;l<steps;l++) {
|
for (l=0;l<steps;l++) { |
| for (k=0;k<start_pal.size;k++) {
|
for (k=0;k<start_pal.size;k++) { |
| curr_pal.colors[k]=start_pal.colors[k]*(steps-l-1)/steps;
|
curr_pal.colors[k]=start_pal.colors[k]*(steps-l-1)/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; |
| curr_pal.size=getdefaultpalette()->size;
|
curr_pal.size=getdefaultpalette()->size; |
| for (l=0;l<steps;l++) {
|
for (l=0;l<steps;l++) { |
| for (k=0;k<getdefaultpalette()->size;k++)
|
for (k=0;k<getdefaultpalette()->size;k++) |
| 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; |
| HISCORE_ITEM 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(hiscore_items(),HISCORE_MAX_ITEMS);k++) {
|
for (k=0;k<min(hiscore_items(),HISCORE_MAX_ITEMS);k++) { |
| if (hiscore_get_item(&item,k) < 0)
|
if (hiscore_get_item(&item,k) < 0) |
| WriteError();
|
WriteError(); |
| /* LINE */
|
/* LINE */ |
| setcolor(WHITE);
|
setcolor(WHITE); |
| if (k)
|
if (k) |
| line(25,39+k*40,getmaxx()-25,39+k*40);
|
line(25,39+k*40,getmaxx()-25,39+k*40); |
| /* NAME */
|
/* NAME */ |
| settextjustify(LEFT_TEXT,TOP_TEXT);
|
settextjustify(LEFT_TEXT,TOP_TEXT); |
| settextstyle(0,0,2);
|
settextstyle(0,0,2); |
| sprintf(s,"%2d. %s",k+1,item.name);
|
sprintf(s,"%2d. %s",k+1,item.name); |
| setcolor(k>2?LIGHTCYAN:ColorConvert(4-k));
|
setcolor(k>2?LIGHTCYAN:ColorConvert(4-k)); |
| outtextxy(10,47+k*40,s);
|
outtextxy(10,47+k*40,s); |
| /* STATUS */
|
/* STATUS */ |
| settextstyle(0,0,1);
|
settextstyle(0,0,1); |
| sprintf(s,"M¡n:%u / Velkost:%ux%u / Cas:%u:%02u:%02u / D tum:%u.%u.%u",
|
sprintf(s,"M¡n:%u / Velkost:%ux%u / Cas:%u:%02u:%02u / D tum:%u.%u.%u", |
| getmines(item.nx,item.ny,item.diff),item.nx,item.ny,
|
getmines(item.nx,item.ny,item.diff),item.nx,item.ny, |
| item.time.ti_hour,item.time.ti_min,item.time.ti_sec,
|
item.time.ti_hour,item.time.ti_min,item.time.ti_sec, |
| item.date.da_day,item.date.da_mon,item.date.da_year);
|
item.date.da_day,item.date.da_mon,item.date.da_year); |
| setcolor(k>2?LIGHTCYAN:ColorConvert(4-k));
|
setcolor(k>2?LIGHTCYAN:ColorConvert(4-k)); |
| outtextxy(75,66+k*40,s);
|
outtextxy(75,66+k*40,s); |
| for (l=0; s[l]!=EOS; l++)
|
for (l=0; s[l]!=EOS; l++) |
| if (!isdigit(s[l]))
|
if (!isdigit(s[l])) |
| s[l]=SPC;
|
s[l]=SPC; |
| setcolor(WHITE);
|
setcolor(WHITE); |
| outtextxy(75,66+k*40,s);
|
outtextxy(75,66+k*40,s); |
| /* DIFF ICON */
|
/* DIFF ICON */ |
| settextjustify(CENTER_TEXT,CENTER_TEXT);
|
settextjustify(CENTER_TEXT,CENTER_TEXT); |
| DrawDiffButton(566,51+k*40,item.diff,k?0:1);
|
DrawDiffButton(566,51+k*40,item.diff,k?0:1); |
| }
|
} |
| DrawNormButton(getmaxx()/2,getmaxy()-31,"","OK",RED,WHITE,WHITE);
|
DrawNormButton(getmaxx()/2,getmaxy()-31,"","OK",RED,WHITE,WHITE); |
| showmouse();
|
showmouse(); |
| FadeIn();
|
FadeIn(); |
| while (!(releasebutton(0,&x,&y))
|
while (!(releasebutton(0,&x,&y)) |
| ||!isinnormbutton(x,y,getmaxx()/2,getmaxy()-31))
|
||!isinnormbutton(x,y,getmaxx()/2,getmaxy()-31)) |
| if (kbhit())
|
if (kbhit()) |
| getch();
|
getch(); |
| } /* }}} */
|
} /* }}} */ |
|
|
|
| clock_t time2clock(struct time time) /* {{{ */
|
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); |
| } /* }}} */
|
} /* }}} */ |
|
|
|
| /* 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)); |
| #else
|
#else |
| register int i;
|
register int i; |
|
|
|
| for (i = 0; s[i] != '\0'; i++)
|
for (i = 0; s[i] != '\0'; i++) |
| s[i] = s[i + 1];
|
s[i] = s[i + 1]; |
|
|
|
| return s;
|
return s; |
| #endif
|
#endif |
| } /* }}} */
|
} /* }}} */ |
|
|
|
| /* Modeline for ViM {{{
|
/* Modeline for ViM {{{ |
| * vim: set ts=4:
|
* vim: set ts=4: |
| * vim600: fdm=marker fdl=0 fdc=0:
|
* vim600: fdm=marker fdl=0 fdc=0: |
| * }}} */
|
* }}} */ |
|
|
|