| version 1.18, 2003/11/07 21:38:17 |
version 1.19, 2003/11/07 21:57:41 |
|
|
| * All rights reserved. |
* All rights reserved. |
| */ |
*/ |
| |
|
| /* $Platon: games/mines/mines.c,v 1.17 2003/11/07 18:17:35 nepto Exp $ */ |
/* $Platon: games/mines/mines.c,v 1.18 2003/11/07 21:38:17 nepto Exp $ */ |
| |
|
| /* LANGUAGE */ |
/* LANGUAGE */ |
| #define LANG_ENGLISH_NEW 0 |
#define LANG_ENGLISH_NEW 0 |
| Line 293 if (OpenNearSquares(x,y)==YES)break;\n\ |
|
| Line 293 if (OpenNearSquares(x,y)==YES)break;\n\ |
|
| #include <system.h> |
#include <system.h> |
| |
|
| #if PLATON_SYSTEM_SVGALIB || PLATON_SYSTEM_X11 |
#if PLATON_SYSTEM_SVGALIB || PLATON_SYSTEM_X11 |
| |
# include <sys/times.h> |
| # include <dos2linux.h> |
# include <dos2linux.h> |
| |
# define CLOCK_FNC times(NULL) |
| |
# define CLOCK_DIV sysconf(_SC_CLK_TCK) |
| #endif |
#endif |
| |
|
| #if PLATON_SYSTEM_MSDOS || PLATON_SYSTEM_WIN32 |
#if PLATON_SYSTEM_MSDOS || PLATON_SYSTEM_WIN32 |
| # include <conio.h> |
# include <conio.h> |
| # include <dos.h> |
# include <dos.h> |
| |
# define CLOCK_FNC clock() |
| |
# define CLOCK_DIV CLOCKS_PER_SEC |
| #endif |
#endif |
| |
|
| #if PLATON_SYSTEM_WIN32 |
#if PLATON_SYSTEM_WIN32 |
| Line 948 BYTE DoAll(void) /* {{{ */ |
|
| Line 953 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_FNC; |
| |
|
| xoff=(getmaxx()+1-nx*barsize)/2; |
xoff=(getmaxx()+1-nx*barsize)/2; |
| yoff=(getmaxy()+1-ny*barsize)/2; |
yoff=(getmaxy()+1-ny*barsize)/2; |
| Line 982 BYTE DoAll(void) /* {{{ */ |
|
| Line 987 BYTE DoAll(void) /* {{{ */ |
|
| if (!but) { |
if (!but) { |
| switch (but = getch()) { |
switch (but = getch()) { |
| case 59: /* F1 */ |
case 59: /* F1 */ |
| clktmp = clock(); |
clktmp = CLOCK_FNC; |
| hidemouse(); |
hidemouse(); |
| desktop_save_or_restore(DESKTOP_SAVE); |
desktop_save_or_restore(DESKTOP_SAVE); |
| FadeOut(); |
FadeOut(); |
| Line 991 BYTE DoAll(void) /* {{{ */ |
|
| Line 996 BYTE DoAll(void) /* {{{ */ |
|
| hidemouse(); |
hidemouse(); |
| desktop_save_or_restore(DESKTOP_RESTORE); |
desktop_save_or_restore(DESKTOP_RESTORE); |
| showmouse(); |
showmouse(); |
| start += clock() - clktmp; |
start += CLOCK_FNC - clktmp; |
| break; |
break; |
| case 62: /* F4 */ |
case 62: /* F4 */ |
| |
clktmp = CLOCK_FNC; |
| hidemouse(); |
hidemouse(); |
| desktop_save_or_restore(DESKTOP_SAVE); |
desktop_save_or_restore(DESKTOP_SAVE); |
| cleardevice(); |
cleardevice(); |
| Line 1014 BYTE DoAll(void) /* {{{ */ |
|
| Line 1020 BYTE DoAll(void) /* {{{ */ |
|
| hidemouse(); |
hidemouse(); |
| desktop_save_or_restore(DESKTOP_RESTORE); |
desktop_save_or_restore(DESKTOP_RESTORE); |
| showmouse(); |
showmouse(); |
| |
start += CLOCK_FNC - clktmp; |
| break; |
break; |
| } |
} |
| } |
} |
| } |
} |
| but = getmousepos(&x, &y); |
but = getmousepos(&x, &y); |
| if (!but && !sqclosed && !cmines) { |
if (!but && !sqclosed && !cmines) { |
| curr = clock() - start; |
curr = CLOCK_FNC - start; |
| break; |
break; |
| } /* All mines discovered */ |
} /* All mines discovered */ |
| if (cminesold != cmines) { /* Update Mines */ |
if (cminesold != cmines) { /* Update Mines */ |
| Line 1040 BYTE DoAll(void) /* {{{ */ |
|
| Line 1047 BYTE DoAll(void) /* {{{ */ |
|
| if (isininfo(x,y)) |
if (isininfo(x,y)) |
| showmouse(); |
showmouse(); |
| } |
} |
| if ((unsigned)(curr/CLOCKS_PER_SEC)!=(unsigned)(clock()/CLOCKS_PER_SEC)) { |
if ((unsigned) (curr / CLOCK_DIV) != (unsigned) (CLOCK_FNC / CLOCK_DIV)) { |
| /* Update Time */ |
/* Update Time */ |
| char txt[30] = "Û ÛÛ ÛÛ"; |
char txt[30] = "Û ÛÛ ÛÛ"; |
| curr = clock(); |
curr = CLOCK_FNC; |
| if (isininfo(x,y)) |
if (isininfo(x,y)) |
| hidemouse(); |
hidemouse(); |
| setcolor(I_BCKCOLOR); |
setcolor(I_BCKCOLOR); |
| Line 1051 BYTE DoAll(void) /* {{{ */ |
|
| Line 1058 BYTE DoAll(void) /* {{{ */ |
|
| + infoy + (6 * textheight(infostr3[0]))); |
+ infoy + (6 * textheight(infostr3[0]))); |
| outtext(txt); |
outtext(txt); |
| sprintf(txt,"%u %02u %02u", |
sprintf(txt,"%u %02u %02u", |
| (unsigned)(((clock()-start)/CLOCKS_PER_SEC)/60)/60, |
(unsigned) (((curr - start) / CLOCK_DIV) / 60) / 60, |
| (unsigned)(((clock()-start)/CLOCKS_PER_SEC)/60)%60, |
(unsigned) (((curr - start) / CLOCK_DIV) / 60) % 60, |
| (unsigned)((clock()-start)/CLOCKS_PER_SEC)%60); |
(unsigned) ((curr - start) / CLOCK_DIV) % 60); |
| setcolor(I_NUMCOLOR); |
setcolor(I_NUMCOLOR); |
| outtext(txt); |
outtext(txt); |
| if (isininfo(x,y)) |
if (isininfo(x,y)) |
| Line 1207 BYTE DoAll(void) /* {{{ */ |
|
| Line 1214 BYTE DoAll(void) /* {{{ */ |
|
| DrawDefWindow(500, 190, 290, STR_WELL_DONE); |
DrawDefWindow(500, 190, 290, STR_WELL_DONE); |
| DrawNormButton(getmaxx() / 2, 262, "", STR_OK, RED, WHITE, WHITE); |
DrawNormButton(getmaxx() / 2, 262, "", STR_OK, RED, WHITE, WHITE); |
| sprintf(s, STR_MINES_REPORT, getmines(nx, ny, diff), nx, ny, |
sprintf(s, STR_MINES_REPORT, getmines(nx, ny, diff), nx, ny, |
| (unsigned)((curr / CLOCKS_PER_SEC) / 60) / 60, |
(unsigned) ((curr / CLOCK_DIV) / 60) / 60, |
| (unsigned)((curr / CLOCKS_PER_SEC) / 60) % 60, |
(unsigned) ((curr / CLOCK_DIV) / 60) % 60, |
| (unsigned)(curr / CLOCKS_PER_SEC) % 60); |
(unsigned) (curr / CLOCK_DIV) % 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])) |
| Line 1268 BYTE DoAll(void) /* {{{ */ |
|
| Line 1275 BYTE DoAll(void) /* {{{ */ |
|
| 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 / CLOCK_DIV) / 60) / 60; |
| item.time.ti_min = (unsigned)((curr/CLOCKS_PER_SEC)/60)%60; |
item.time.ti_min = (unsigned) ((curr / CLOCK_DIV) / 60) % 60; |
| item.time.ti_sec = (unsigned)(curr/CLOCKS_PER_SEC)%60; |
item.time.ti_sec = (unsigned) (curr / CLOCK_DIV) % 60; |
| if (hiscore_set_item(&item, k) < 0) |
if (hiscore_set_item(&item, k) < 0) |
| WriteError(); |
WriteError(); |
| HscTable(); |
HscTable(); |
| Line 1826 void HscTable(void) /* {{{ */ |
|
| Line 1833 void HscTable(void) /* {{{ */ |
|
| |
|
| clock_t time2clock(struct time time) /* {{{ */ |
clock_t time2clock(struct time time) /* {{{ */ |
| { |
{ |
| return CLOCKS_PER_SEC * |
return CLOCK_DIV * |
| (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); |
| } /* }}} */ |
} /* }}} */ |
| |
|