2000-03-15 20:06:39 +01:00
|
|
|
/*
|
|
|
|
* WineMine (main.c)
|
2002-06-01 01:06:46 +02:00
|
|
|
*
|
2003-11-26 04:40:01 +01:00
|
|
|
* Copyright 2000 Joshua Thielen
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2000-03-15 20:06:39 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <windows.h>
|
|
|
|
#include "main.h"
|
|
|
|
#include "dialog.h"
|
|
|
|
#include "resource.h"
|
|
|
|
|
2000-03-30 22:25:07 +02:00
|
|
|
/* Work around a Wine bug which defines handles as UINT rather than LPVOID */
|
|
|
|
#ifdef WINE_STRICT
|
|
|
|
#define NULL_HANDLE NULL
|
|
|
|
#else
|
|
|
|
#define NULL_HANDLE 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef DUMB_DEBUG
|
|
|
|
#include <stdio.h>
|
|
|
|
#define DEBUG(x) fprintf(stderr,x)
|
|
|
|
#else
|
2002-06-01 01:06:46 +02:00
|
|
|
#define DEBUG(x)
|
2000-03-30 22:25:07 +02:00
|
|
|
#endif
|
2000-03-15 20:06:39 +01:00
|
|
|
|
|
|
|
int WINAPI WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdline, int cmdshow )
|
2002-06-01 01:06:46 +02:00
|
|
|
{
|
2000-03-15 20:06:39 +01:00
|
|
|
MSG msg;
|
|
|
|
WNDCLASS wc;
|
|
|
|
HWND hWnd;
|
2002-06-01 01:06:46 +02:00
|
|
|
HACCEL haccel;
|
2000-03-15 20:06:39 +01:00
|
|
|
char appname[9];
|
|
|
|
|
|
|
|
LoadString( hInst, IDS_APPNAME, appname, sizeof(appname));
|
|
|
|
|
|
|
|
wc.style = 0;
|
|
|
|
wc.lpfnWndProc = MainProc;
|
|
|
|
wc.cbClsExtra = 0;
|
|
|
|
wc.cbWndExtra = 0;
|
|
|
|
wc.hInstance = hInst;
|
|
|
|
wc.hIcon = LoadIcon( hInst, appname );
|
2000-03-30 22:25:07 +02:00
|
|
|
wc.hCursor = LoadCursor( NULL_HANDLE, IDI_APPLICATION );
|
2000-03-15 20:06:39 +01:00
|
|
|
wc.hbrBackground = (HBRUSH) GetStockObject( BLACK_BRUSH );
|
|
|
|
wc.lpszMenuName = "MENU_WINEMINE";
|
|
|
|
wc.lpszClassName = appname;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-03-15 20:06:39 +01:00
|
|
|
if (!RegisterClass(&wc)) exit(1);
|
2002-06-01 01:06:46 +02:00
|
|
|
hWnd = CreateWindow( appname, appname,
|
|
|
|
WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME & ~WS_MAXIMIZEBOX,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
2000-03-30 22:25:07 +02:00
|
|
|
NULL_HANDLE, NULL_HANDLE, hInst, NULL );
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-03-15 20:06:39 +01:00
|
|
|
if (!hWnd) exit(1);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-03-15 20:06:39 +01:00
|
|
|
ShowWindow( hWnd, cmdshow );
|
|
|
|
UpdateWindow( hWnd );
|
|
|
|
|
2004-03-02 00:13:30 +01:00
|
|
|
haccel = LoadAccelerators( hInst, MAKEINTRESOURCE(IDA_WINEMINE) );
|
2000-03-30 22:25:07 +02:00
|
|
|
SetTimer( hWnd, ID_TIMER, 1000, NULL );
|
2000-03-15 20:06:39 +01:00
|
|
|
|
2000-03-30 22:25:07 +02:00
|
|
|
while( GetMessage(&msg, NULL_HANDLE, 0, 0) ) {
|
2000-03-15 20:06:39 +01:00
|
|
|
if (!TranslateAccelerator( hWnd, haccel, &msg ))
|
|
|
|
TranslateMessage( &msg );
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-03-15 20:06:39 +01:00
|
|
|
DispatchMessage( &msg );
|
|
|
|
}
|
|
|
|
return msg.wParam;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT WINAPI MainProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
HDC hdc;
|
|
|
|
PAINTSTRUCT ps;
|
2002-06-01 01:06:46 +02:00
|
|
|
HMENU hMenu;
|
|
|
|
static BOARD board;
|
2000-03-15 20:06:39 +01:00
|
|
|
|
|
|
|
switch( msg ) {
|
2002-06-01 01:06:46 +02:00
|
|
|
case WM_CREATE:
|
2000-03-15 20:06:39 +01:00
|
|
|
board.hInst = ((LPCREATESTRUCT) lParam)->hInstance;
|
|
|
|
board.hWnd = hWnd;
|
|
|
|
InitBoard( &board );
|
|
|
|
CreateBoard( &board );
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case WM_PAINT:
|
2000-03-30 22:25:07 +02:00
|
|
|
{
|
|
|
|
HDC hMemDC;
|
|
|
|
|
|
|
|
DEBUG("WM_PAINT\n");
|
2000-03-15 20:06:39 +01:00
|
|
|
hdc = BeginPaint( hWnd, &ps );
|
2000-03-30 22:25:07 +02:00
|
|
|
hMemDC = CreateCompatibleDC( hdc );
|
|
|
|
|
|
|
|
DrawBoard( hdc, hMemDC, &ps, &board );
|
|
|
|
|
|
|
|
DeleteDC( hMemDC );
|
2000-03-15 20:06:39 +01:00
|
|
|
EndPaint( hWnd, &ps );
|
2000-03-30 22:25:07 +02:00
|
|
|
|
2000-03-15 20:06:39 +01:00
|
|
|
return 0;
|
2000-03-30 22:25:07 +02:00
|
|
|
}
|
2000-03-15 20:06:39 +01:00
|
|
|
|
|
|
|
case WM_MOVE:
|
2000-03-30 22:25:07 +02:00
|
|
|
DEBUG("WM_MOVE\n");
|
2000-03-15 20:06:39 +01:00
|
|
|
board.pos.x = (unsigned) LOWORD(lParam);
|
2002-06-01 01:06:46 +02:00
|
|
|
board.pos.y = (unsigned) HIWORD(lParam);
|
2000-03-15 20:06:39 +01:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
case WM_DESTROY:
|
|
|
|
SaveBoard( &board );
|
2002-06-01 01:06:46 +02:00
|
|
|
DestroyBoard( &board );
|
2000-03-15 20:06:39 +01:00
|
|
|
PostQuitMessage( 0 );
|
|
|
|
return 0;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-03-15 20:06:39 +01:00
|
|
|
case WM_TIMER:
|
|
|
|
if( board.status == PLAYING ) {
|
|
|
|
board.time++;
|
2002-06-01 01:06:46 +02:00
|
|
|
RedrawWindow( hWnd, &board.timer_rect, NULL_HANDLE,
|
|
|
|
RDW_INVALIDATE | RDW_UPDATENOW );
|
2000-03-15 20:06:39 +01:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case WM_LBUTTONDOWN:
|
2000-03-30 22:25:07 +02:00
|
|
|
DEBUG("WM_LBUTTONDOWN\n");
|
2000-03-15 20:06:39 +01:00
|
|
|
if( wParam & MK_RBUTTON )
|
2002-06-01 01:06:46 +02:00
|
|
|
msg = WM_MBUTTONDOWN;
|
2000-03-15 20:06:39 +01:00
|
|
|
TestBoard( hWnd, &board, LOWORD(lParam), HIWORD(lParam), msg );
|
|
|
|
SetCapture( hWnd );
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case WM_LBUTTONUP:
|
2000-03-30 22:25:07 +02:00
|
|
|
DEBUG("WM_LBUTTONUP\n");
|
2000-03-15 20:06:39 +01:00
|
|
|
if( wParam & MK_RBUTTON )
|
2002-06-01 01:06:46 +02:00
|
|
|
msg = WM_MBUTTONUP;
|
2000-03-15 20:06:39 +01:00
|
|
|
TestBoard( hWnd, &board, LOWORD(lParam), HIWORD(lParam), msg );
|
|
|
|
ReleaseCapture();
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case WM_RBUTTONDOWN:
|
2000-03-30 22:25:07 +02:00
|
|
|
DEBUG("WM_RBUTTONDOWN\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
if( wParam & MK_LBUTTON ) {
|
2000-03-15 20:06:39 +01:00
|
|
|
board.press.x = 0;
|
2002-06-01 01:06:46 +02:00
|
|
|
board.press.y = 0;
|
2000-03-15 20:06:39 +01:00
|
|
|
msg = WM_MBUTTONDOWN;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2000-03-15 20:06:39 +01:00
|
|
|
TestBoard( hWnd, &board, LOWORD(lParam), HIWORD(lParam), msg );
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case WM_RBUTTONUP:
|
2000-03-30 22:25:07 +02:00
|
|
|
DEBUG("WM_RBUTTONUP\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
if( wParam & MK_LBUTTON )
|
|
|
|
msg = WM_MBUTTONUP;
|
2000-03-15 20:06:39 +01:00
|
|
|
TestBoard( hWnd, &board, LOWORD(lParam), HIWORD(lParam), msg );
|
|
|
|
return 0;
|
|
|
|
|
2000-11-08 06:06:58 +01:00
|
|
|
case WM_MBUTTONDOWN:
|
|
|
|
DEBUG("WM_MBUTTONDOWN\n");
|
|
|
|
TestBoard( hWnd, &board, LOWORD(lParam), HIWORD(lParam), msg );
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case WM_MBUTTONUP:
|
|
|
|
DEBUG("WM_MBUTTONUP\n");
|
|
|
|
TestBoard( hWnd, &board, LOWORD(lParam), HIWORD(lParam), msg );
|
|
|
|
return 0;
|
|
|
|
|
2000-03-15 20:06:39 +01:00
|
|
|
case WM_MOUSEMOVE:
|
2000-03-30 22:25:07 +02:00
|
|
|
{
|
|
|
|
if( (wParam & MK_LBUTTON) && (wParam & MK_RBUTTON) ) {
|
|
|
|
msg = WM_MBUTTONDOWN;
|
|
|
|
}
|
|
|
|
else if( wParam & MK_LBUTTON ) {
|
|
|
|
msg = WM_LBUTTONDOWN;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
TestBoard( hWnd, &board, LOWORD(lParam), HIWORD(lParam), msg );
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2000-03-15 20:06:39 +01:00
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch(LOWORD(wParam)) {
|
|
|
|
case IDM_NEW:
|
|
|
|
CreateBoard( &board );
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case IDM_MARKQ:
|
2002-06-01 01:06:46 +02:00
|
|
|
hMenu = GetMenu( hWnd );
|
2000-03-15 20:06:39 +01:00
|
|
|
board.IsMarkQ = !board.IsMarkQ;
|
|
|
|
if( board.IsMarkQ )
|
|
|
|
CheckMenuItem( hMenu, IDM_MARKQ, MF_CHECKED );
|
2002-06-01 01:06:46 +02:00
|
|
|
else
|
2000-03-15 20:06:39 +01:00
|
|
|
CheckMenuItem( hMenu, IDM_MARKQ, MF_UNCHECKED );
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case IDM_BEGINNER:
|
2002-06-01 01:06:46 +02:00
|
|
|
SetDifficulty( &board, BEGINNER );
|
2000-03-15 20:06:39 +01:00
|
|
|
CreateBoard( &board );
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case IDM_ADVANCED:
|
2002-06-01 01:06:46 +02:00
|
|
|
SetDifficulty( &board, ADVANCED );
|
2000-03-15 20:06:39 +01:00
|
|
|
CreateBoard( &board );
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case IDM_EXPERT:
|
2002-06-01 01:06:46 +02:00
|
|
|
SetDifficulty( &board, EXPERT );
|
2000-03-15 20:06:39 +01:00
|
|
|
CreateBoard( &board );
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case IDM_CUSTOM:
|
|
|
|
SetDifficulty( &board, CUSTOM );
|
|
|
|
CreateBoard( &board );
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case IDM_EXIT:
|
|
|
|
SendMessage( hWnd, WM_CLOSE, 0, 0);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case IDM_TIMES:
|
2002-06-01 01:06:46 +02:00
|
|
|
DialogBoxParam( board.hInst, "DLG_TIMES", hWnd,
|
2000-03-15 20:06:39 +01:00
|
|
|
TimesDlgProc, (LPARAM) &board);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case IDM_ABOUT:
|
|
|
|
DialogBox( board.hInst, "DLG_ABOUT", hWnd, AboutDlgProc );
|
|
|
|
return 0;
|
2000-03-30 22:25:07 +02:00
|
|
|
default:
|
|
|
|
DEBUG("Unknown WM_COMMAND command message received\n");
|
|
|
|
break;
|
2000-03-15 20:06:39 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2000-03-15 20:06:39 +01:00
|
|
|
return( DefWindowProc( hWnd, msg, wParam, lParam ));
|
|
|
|
}
|
|
|
|
|
|
|
|
void InitBoard( BOARD *p_board )
|
|
|
|
{
|
|
|
|
HMENU hMenu;
|
|
|
|
|
|
|
|
p_board->hMinesBMP = LoadBitmap( p_board->hInst, "mines");
|
|
|
|
p_board->hFacesBMP = LoadBitmap( p_board->hInst, "faces");
|
2002-06-01 01:06:46 +02:00
|
|
|
p_board->hLedsBMP = LoadBitmap( p_board->hInst, "leds");
|
|
|
|
|
|
|
|
LoadBoard( p_board );
|
|
|
|
|
2000-03-15 20:06:39 +01:00
|
|
|
if( p_board->pos.x < (unsigned) GetSystemMetrics( SM_CXFIXEDFRAME ))
|
|
|
|
p_board->pos.x = GetSystemMetrics( SM_CXFIXEDFRAME );
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
if( p_board->pos.x > (unsigned) (GetSystemMetrics( SM_CXSCREEN )
|
2000-03-15 20:06:39 +01:00
|
|
|
- GetSystemMetrics( SM_CXFIXEDFRAME ))) {
|
2002-06-01 01:06:46 +02:00
|
|
|
p_board->pos.x = GetSystemMetrics( SM_CXSCREEN )
|
2000-03-15 20:06:39 +01:00
|
|
|
- GetSystemMetrics( SM_CXFIXEDFRAME );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( p_board->pos.y < (unsigned) (GetSystemMetrics( SM_CYMENU )
|
|
|
|
+ GetSystemMetrics( SM_CYCAPTION )
|
|
|
|
+ GetSystemMetrics( SM_CYFIXEDFRAME ))) {
|
|
|
|
p_board->pos.y = GetSystemMetrics( SM_CYMENU ) +
|
|
|
|
GetSystemMetrics( SM_CYCAPTION ) +
|
|
|
|
GetSystemMetrics( SM_CYFIXEDFRAME );
|
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
if( p_board->pos.y > (unsigned) (GetSystemMetrics( SM_CYSCREEN )
|
2000-03-15 20:06:39 +01:00
|
|
|
- GetSystemMetrics( SM_CYFIXEDFRAME ))) {
|
|
|
|
p_board->pos.y = GetSystemMetrics( SM_CYSCREEN )
|
|
|
|
- GetSystemMetrics( SM_CYFIXEDFRAME );
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-03-15 20:06:39 +01:00
|
|
|
hMenu = GetMenu( p_board->hWnd );
|
2002-06-01 01:06:46 +02:00
|
|
|
CheckMenuItem( hMenu, IDM_BEGINNER + (unsigned) p_board->difficulty,
|
2000-03-15 20:06:39 +01:00
|
|
|
MF_CHECKED );
|
|
|
|
if( p_board->IsMarkQ )
|
|
|
|
CheckMenuItem( hMenu, IDM_MARKQ, MF_CHECKED );
|
2002-06-01 01:06:46 +02:00
|
|
|
else
|
2000-03-15 20:06:39 +01:00
|
|
|
CheckMenuItem( hMenu, IDM_MARKQ, MF_UNCHECKED );
|
|
|
|
CheckLevel( p_board );
|
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
void LoadBoard( BOARD *p_board )
|
2000-03-15 20:06:39 +01:00
|
|
|
{
|
|
|
|
DWORD size;
|
|
|
|
DWORD type;
|
|
|
|
HKEY hkey;
|
|
|
|
char data[16];
|
|
|
|
char key_name[8];
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\Wine\\WineMine",
|
2000-03-15 20:06:39 +01:00
|
|
|
0, KEY_QUERY_VALUE, &hkey );
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-03-15 20:06:39 +01:00
|
|
|
size = sizeof( data );
|
2002-06-01 01:06:46 +02:00
|
|
|
if( RegQueryValueEx( hkey, "Xpos", NULL, (LPDWORD) &type,
|
2000-03-15 20:06:39 +01:00
|
|
|
(LPBYTE) data, (LPDWORD) &size ) == ERROR_SUCCESS ) {
|
|
|
|
p_board->pos.x = atoi( data );
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
else
|
2000-03-15 20:06:39 +01:00
|
|
|
p_board->pos.x = GetSystemMetrics( SM_CXFIXEDFRAME );
|
|
|
|
|
|
|
|
size = sizeof( data );
|
2002-06-01 01:06:46 +02:00
|
|
|
if( RegQueryValueEx( hkey, "Ypos", NULL, (LPDWORD) &type,
|
2000-03-15 20:06:39 +01:00
|
|
|
(LPBYTE) data, (LPDWORD) &size ) == ERROR_SUCCESS )
|
2000-04-09 20:37:50 +02:00
|
|
|
p_board->pos.y = atoi( data );
|
2002-06-01 01:06:46 +02:00
|
|
|
else
|
2000-04-09 20:37:50 +02:00
|
|
|
p_board->pos.y = GetSystemMetrics( SM_CYMENU )
|
2002-06-01 01:06:46 +02:00
|
|
|
+ GetSystemMetrics( SM_CYCAPTION )
|
2000-03-15 20:06:39 +01:00
|
|
|
+ GetSystemMetrics( SM_CYFIXEDFRAME );
|
|
|
|
|
|
|
|
size = sizeof( data );
|
2002-06-01 01:06:46 +02:00
|
|
|
if( RegQueryValueEx( hkey, "Rows", NULL, (LPDWORD) &type,
|
2000-03-15 20:06:39 +01:00
|
|
|
(LPBYTE) data, (LPDWORD) &size ) == ERROR_SUCCESS )
|
|
|
|
p_board->rows = atoi( data );
|
|
|
|
else
|
|
|
|
p_board->rows = BEGINNER_ROWS;
|
|
|
|
|
|
|
|
size = sizeof( data );
|
2002-06-01 01:06:46 +02:00
|
|
|
if( RegQueryValueEx( hkey, "Cols", NULL, (LPDWORD) &type,
|
2000-03-15 20:06:39 +01:00
|
|
|
(LPBYTE) data, (LPDWORD) &size ) == ERROR_SUCCESS )
|
|
|
|
p_board->cols = atoi( data );
|
|
|
|
else
|
2002-06-01 01:06:46 +02:00
|
|
|
p_board->cols = BEGINNER_COLS;
|
|
|
|
|
2000-03-15 20:06:39 +01:00
|
|
|
size = sizeof( data );
|
2002-06-01 01:06:46 +02:00
|
|
|
if( RegQueryValueEx( hkey, "Mines", NULL, (LPDWORD) &type,
|
2000-03-15 20:06:39 +01:00
|
|
|
(LPBYTE) data, (LPDWORD) &size ) == ERROR_SUCCESS )
|
|
|
|
p_board->mines = atoi( data );
|
2002-06-01 01:06:46 +02:00
|
|
|
else
|
2000-03-15 20:06:39 +01:00
|
|
|
p_board->rows = BEGINNER_ROWS;
|
|
|
|
|
|
|
|
size = sizeof( data );
|
2002-06-01 01:06:46 +02:00
|
|
|
if( RegQueryValueEx( hkey, "Difficulty", NULL, (LPDWORD) &type,
|
2000-03-15 20:06:39 +01:00
|
|
|
(LPBYTE) data, (LPDWORD) &size ) == ERROR_SUCCESS )
|
|
|
|
p_board->difficulty = (DIFFICULTY) atoi( data );
|
2002-06-01 01:06:46 +02:00
|
|
|
else
|
2000-03-15 20:06:39 +01:00
|
|
|
p_board->difficulty = BEGINNER;
|
|
|
|
|
|
|
|
size = sizeof( data );
|
2002-06-01 01:06:46 +02:00
|
|
|
if( RegQueryValueEx( hkey, "MarkQ", NULL, (LPDWORD) &type,
|
2000-03-15 20:06:39 +01:00
|
|
|
(LPBYTE) data, (LPDWORD) &size ) == ERROR_SUCCESS )
|
|
|
|
p_board->IsMarkQ = atoi( data );
|
2002-06-01 01:06:46 +02:00
|
|
|
else
|
2000-03-15 20:06:39 +01:00
|
|
|
p_board->IsMarkQ = TRUE;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-03-15 20:06:39 +01:00
|
|
|
for( i = 0; i < 3; i++ ) {
|
|
|
|
wsprintf( key_name, "Name%d", i );
|
|
|
|
size = sizeof( data );
|
2002-06-01 01:06:46 +02:00
|
|
|
if( RegQueryValueEx( hkey, key_name, NULL, (LPDWORD) &type,
|
|
|
|
(LPBYTE) data,
|
2000-03-15 20:06:39 +01:00
|
|
|
(LPDWORD) &size ) == ERROR_SUCCESS )
|
|
|
|
strncpy( p_board->best_name[i], data, sizeof( data ) );
|
2002-06-01 01:06:46 +02:00
|
|
|
else
|
2000-03-15 20:06:39 +01:00
|
|
|
wsprintf( p_board->best_name[i], "Nobody");
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-03-15 20:06:39 +01:00
|
|
|
for( i = 0; i < 3; i++ ) {
|
|
|
|
wsprintf( key_name, "Time%d", i );
|
|
|
|
size = sizeof( data );
|
2002-06-01 01:06:46 +02:00
|
|
|
if( RegQueryValueEx( hkey, key_name, NULL, (LPDWORD) &type,
|
|
|
|
(LPBYTE) data,
|
2000-03-15 20:06:39 +01:00
|
|
|
(LPDWORD) &size ) == ERROR_SUCCESS )
|
|
|
|
p_board->best_time[i] = atoi( data );
|
2002-06-01 01:06:46 +02:00
|
|
|
else
|
2000-03-15 20:06:39 +01:00
|
|
|
p_board->best_time[i] = 999;
|
|
|
|
}
|
|
|
|
RegCloseKey( hkey );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SaveBoard( BOARD *p_board )
|
|
|
|
{
|
|
|
|
HKEY hkey;
|
|
|
|
unsigned i;
|
|
|
|
char data[16];
|
|
|
|
char key_name[8];
|
2002-06-01 01:06:46 +02:00
|
|
|
|
|
|
|
if( RegCreateKeyEx( HKEY_LOCAL_MACHINE,
|
2000-04-09 20:37:50 +02:00
|
|
|
"Software\\Wine\\WineMine", 0, NULL,
|
2003-10-04 05:07:16 +02:00
|
|
|
REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
|
|
|
|
&hkey, NULL ) != ERROR_SUCCESS)
|
2002-06-01 01:06:46 +02:00
|
|
|
return;
|
2001-04-10 23:31:58 +02:00
|
|
|
|
2000-03-15 20:06:39 +01:00
|
|
|
wsprintf( data, "%d", p_board->pos.x );
|
2001-04-10 23:31:58 +02:00
|
|
|
RegSetValueEx( hkey, "Xpos", 0, REG_SZ, (LPBYTE) data, strlen(data)+1 );
|
2000-03-15 20:06:39 +01:00
|
|
|
|
|
|
|
wsprintf( data, "%d", p_board->pos.x );
|
2001-04-10 23:31:58 +02:00
|
|
|
RegSetValueEx( hkey, "Ypos", 0, REG_SZ, (LPBYTE) data, strlen(data)+1 );
|
2000-03-15 20:06:39 +01:00
|
|
|
|
|
|
|
wsprintf( data, "%d", (int) p_board->difficulty );
|
2001-04-10 23:31:58 +02:00
|
|
|
RegSetValueEx( hkey, "Difficulty", 0, REG_SZ, (LPBYTE) data, strlen(data)+1 );
|
2000-03-15 20:06:39 +01:00
|
|
|
|
|
|
|
wsprintf( data, "%d", p_board->rows );
|
2001-04-10 23:31:58 +02:00
|
|
|
RegSetValueEx( hkey, "Rows", 0, REG_SZ, (LPBYTE) data, strlen(data)+1 );
|
2000-03-15 20:06:39 +01:00
|
|
|
|
|
|
|
wsprintf( data, "%d", p_board->cols );
|
2001-04-10 23:31:58 +02:00
|
|
|
RegSetValueEx( hkey, "Cols", 0, REG_SZ, (LPBYTE) data, strlen(data)+1 );
|
2000-03-15 20:06:39 +01:00
|
|
|
|
|
|
|
wsprintf( data, "%d", p_board->mines );
|
2001-04-10 23:31:58 +02:00
|
|
|
RegSetValueEx( hkey, "Mines", 0, REG_SZ, (LPBYTE) data, strlen(data)+1 );
|
|
|
|
|
2000-03-15 20:06:39 +01:00
|
|
|
wsprintf( data, "%d", (int) p_board->IsMarkQ );
|
2001-04-10 23:31:58 +02:00
|
|
|
RegSetValueEx( hkey, "MarkQ", 0, REG_SZ, (LPBYTE) data, strlen(data)+1 );
|
2000-03-15 20:06:39 +01:00
|
|
|
|
|
|
|
for( i = 0; i < 3; i++ ) {
|
|
|
|
wsprintf( key_name, "Name%u", i );
|
|
|
|
strncpy( data, p_board->best_name[i], sizeof( data ) );
|
2001-04-10 23:31:58 +02:00
|
|
|
RegSetValueEx( hkey, key_name, 0, REG_SZ, (LPBYTE) data, strlen(data)+1 );
|
2000-03-15 20:06:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
for( i = 0; i < 3; i++ ) {
|
|
|
|
wsprintf( key_name, "Time%u", i );
|
|
|
|
wsprintf( data, "%d", p_board->best_time[i] );
|
2001-04-10 23:31:58 +02:00
|
|
|
RegSetValueEx( hkey, key_name, 0, REG_SZ, (LPBYTE) data, strlen(data)+1 );
|
2000-03-15 20:06:39 +01:00
|
|
|
}
|
|
|
|
RegCloseKey( hkey );
|
|
|
|
}
|
|
|
|
|
2000-04-04 20:55:55 +02:00
|
|
|
void DestroyBoard( BOARD *p_board )
|
|
|
|
{
|
|
|
|
DeleteObject( p_board->hFacesBMP );
|
|
|
|
DeleteObject( p_board->hLedsBMP );
|
|
|
|
DeleteObject( p_board->hMinesBMP );
|
|
|
|
}
|
|
|
|
|
2000-03-15 20:06:39 +01:00
|
|
|
void SetDifficulty( BOARD *p_board, DIFFICULTY difficulty )
|
|
|
|
{
|
2003-09-29 22:13:14 +02:00
|
|
|
HMENU hMenu;
|
|
|
|
|
|
|
|
if ( difficulty == CUSTOM )
|
|
|
|
if (DialogBoxParam( p_board->hInst, "DLG_CUSTOM", p_board->hWnd,
|
|
|
|
CustomDlgProc, (LPARAM) p_board) != 0)
|
|
|
|
return;
|
2000-03-15 20:06:39 +01:00
|
|
|
|
2003-09-29 22:13:14 +02:00
|
|
|
hMenu = GetMenu( p_board->hWnd );
|
2000-03-15 20:06:39 +01:00
|
|
|
CheckMenuItem( hMenu, IDM_BEGINNER + p_board->difficulty, MF_UNCHECKED );
|
2002-06-01 01:06:46 +02:00
|
|
|
p_board->difficulty = difficulty;
|
2000-03-15 20:06:39 +01:00
|
|
|
CheckMenuItem( hMenu, IDM_BEGINNER + difficulty, MF_CHECKED );
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-03-15 20:06:39 +01:00
|
|
|
switch( difficulty ) {
|
2002-06-01 01:06:46 +02:00
|
|
|
case BEGINNER:
|
2000-03-15 20:06:39 +01:00
|
|
|
p_board->cols = BEGINNER_COLS;
|
|
|
|
p_board->rows = BEGINNER_ROWS;
|
|
|
|
p_board->mines = BEGINNER_MINES;
|
|
|
|
break;
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
case ADVANCED:
|
2000-03-15 20:06:39 +01:00
|
|
|
p_board->cols = ADVANCED_COLS;
|
|
|
|
p_board->rows = ADVANCED_ROWS;
|
|
|
|
p_board->mines = ADVANCED_MINES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EXPERT:
|
|
|
|
p_board->cols = EXPERT_COLS;
|
|
|
|
p_board->rows = EXPERT_ROWS;
|
2002-06-01 01:06:46 +02:00
|
|
|
p_board->mines = EXPERT_MINES;
|
|
|
|
break;
|
2000-03-15 20:06:39 +01:00
|
|
|
|
|
|
|
case CUSTOM:
|
2002-06-01 01:06:46 +02:00
|
|
|
break;
|
2000-03-15 20:06:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreateBoard( BOARD *p_board )
|
|
|
|
{
|
|
|
|
int left, top, bottom, right, wnd_x, wnd_y, wnd_width, wnd_height;
|
|
|
|
|
|
|
|
p_board->mb = MB_NONE;
|
|
|
|
p_board->boxes_left = p_board->cols * p_board->rows - p_board->mines;
|
|
|
|
p_board->num_flags = 0;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-03-15 20:06:39 +01:00
|
|
|
CreateBoxes( p_board );
|
|
|
|
|
|
|
|
p_board->width = p_board->cols * MINE_WIDTH + BOARD_WMARGIN * 2;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
|
|
|
p_board->height = p_board->rows * MINE_HEIGHT + LED_HEIGHT
|
2000-03-15 20:06:39 +01:00
|
|
|
+ BOARD_HMARGIN * 3;
|
|
|
|
|
|
|
|
wnd_x = p_board->pos.x - GetSystemMetrics( SM_CXFIXEDFRAME );
|
2002-06-01 01:06:46 +02:00
|
|
|
wnd_y = p_board->pos.y - GetSystemMetrics( SM_CYMENU )
|
|
|
|
- GetSystemMetrics( SM_CYCAPTION )
|
2000-03-15 20:06:39 +01:00
|
|
|
- GetSystemMetrics( SM_CYFIXEDFRAME );
|
2002-06-01 01:06:46 +02:00
|
|
|
wnd_width = p_board->width
|
2000-03-15 20:06:39 +01:00
|
|
|
+ GetSystemMetrics( SM_CXFIXEDFRAME ) * 2;
|
2002-06-01 01:06:46 +02:00
|
|
|
wnd_height = p_board->height
|
|
|
|
+ GetSystemMetrics( SM_CYMENU )
|
|
|
|
+ GetSystemMetrics( SM_CYCAPTION )
|
2000-03-15 20:06:39 +01:00
|
|
|
+ GetSystemMetrics( SM_CYFIXEDFRAME ) * 2;
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
/* setting the mines rectangle boundary */
|
|
|
|
left = BOARD_WMARGIN;
|
|
|
|
top = BOARD_HMARGIN * 2 + LED_HEIGHT;
|
2000-03-15 20:06:39 +01:00
|
|
|
right = left + p_board->cols * MINE_WIDTH;
|
|
|
|
bottom = top + p_board->rows * MINE_HEIGHT;
|
|
|
|
SetRect( &p_board->mines_rect, left, top, right, bottom );
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
/* setting the face rectangle boundary */
|
2000-03-15 20:06:39 +01:00
|
|
|
left = p_board->width / 2 - FACE_WIDTH / 2;
|
|
|
|
top = BOARD_HMARGIN;
|
|
|
|
right = left + FACE_WIDTH;
|
2002-06-01 01:06:46 +02:00
|
|
|
bottom = top + FACE_HEIGHT;
|
2000-03-15 20:06:39 +01:00
|
|
|
SetRect( &p_board->face_rect, left, top, right, bottom );
|
2002-06-01 01:06:46 +02:00
|
|
|
|
|
|
|
/* setting the timer rectangle boundary */
|
2000-03-15 20:06:39 +01:00
|
|
|
left = BOARD_WMARGIN;
|
|
|
|
top = BOARD_HMARGIN;
|
|
|
|
right = left + LED_WIDTH * 3;
|
2002-06-01 01:06:46 +02:00
|
|
|
bottom = top + LED_HEIGHT;
|
2000-03-15 20:06:39 +01:00
|
|
|
SetRect( &p_board->timer_rect, left, top, right, bottom );
|
2002-06-01 01:06:46 +02:00
|
|
|
|
|
|
|
/* setting the counter rectangle boundary */
|
2000-03-15 20:06:39 +01:00
|
|
|
left = p_board->width - BOARD_WMARGIN - LED_WIDTH * 3;
|
|
|
|
top = BOARD_HMARGIN;
|
|
|
|
right = p_board->width - BOARD_WMARGIN;
|
2002-06-01 01:06:46 +02:00
|
|
|
bottom = top + LED_HEIGHT;
|
2000-03-15 20:06:39 +01:00
|
|
|
SetRect( &p_board->counter_rect, left, top, right, bottom );
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-03-15 20:06:39 +01:00
|
|
|
p_board->status = WAITING;
|
2002-06-01 01:06:46 +02:00
|
|
|
p_board->face_bmp = SMILE_BMP;
|
2000-03-15 20:06:39 +01:00
|
|
|
p_board->time = 0;
|
|
|
|
|
|
|
|
MoveWindow( p_board->hWnd, wnd_x, wnd_y, wnd_width, wnd_height, TRUE );
|
2002-06-01 01:06:46 +02:00
|
|
|
RedrawWindow( p_board->hWnd, NULL, NULL_HANDLE,
|
2000-03-15 20:06:39 +01:00
|
|
|
RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CheckLevel( BOARD *p_board )
|
|
|
|
{
|
|
|
|
if( p_board->rows < BEGINNER_ROWS )
|
|
|
|
p_board->rows = BEGINNER_ROWS;
|
|
|
|
|
|
|
|
if( p_board->rows > MAX_ROWS )
|
|
|
|
p_board->rows = MAX_ROWS;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-03-15 20:06:39 +01:00
|
|
|
if( p_board->cols < BEGINNER_COLS )
|
|
|
|
p_board->cols = BEGINNER_COLS;
|
|
|
|
|
|
|
|
if( p_board->cols > MAX_COLS )
|
|
|
|
p_board->cols = MAX_COLS;
|
|
|
|
|
|
|
|
if( p_board->mines < BEGINNER_MINES )
|
2002-06-01 01:06:46 +02:00
|
|
|
p_board->mines = BEGINNER_MINES;
|
2000-03-15 20:06:39 +01:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
if( p_board->mines > p_board->cols * p_board->rows - 1 )
|
|
|
|
p_board->mines = p_board->cols * p_board->rows - 1;
|
2000-03-15 20:06:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CreateBoxes( BOARD *p_board )
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
unsigned col, row;
|
|
|
|
|
|
|
|
srand( (unsigned) time( NULL ) );
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
/* Create the boxes...
|
2000-03-15 20:06:39 +01:00
|
|
|
* We actually create them with an empty border,
|
|
|
|
* so special care doesn't have to be taken on the edges
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-03-15 20:06:39 +01:00
|
|
|
for( col = 0; col <= p_board->cols + 1; col++ )
|
2000-03-30 22:25:07 +02:00
|
|
|
for( row = 0; row <= p_board->rows + 1; row++ ) {
|
2002-06-01 01:06:46 +02:00
|
|
|
p_board->box[col][row].IsPressed = FALSE;
|
2000-03-15 20:06:39 +01:00
|
|
|
p_board->box[col][row].IsMine = FALSE;
|
|
|
|
p_board->box[col][row].FlagType = NORMAL;
|
|
|
|
p_board->box[col][row].NumMines = 0;
|
2000-03-30 22:25:07 +02:00
|
|
|
}
|
2000-03-15 20:06:39 +01:00
|
|
|
|
|
|
|
/* create mines */
|
|
|
|
i = 0;
|
|
|
|
while( (unsigned) i < p_board->mines ) {
|
|
|
|
col = (int) (p_board->cols * (float) rand() / RAND_MAX + 1);
|
|
|
|
row = (int) (p_board->rows * (float) rand() / RAND_MAX + 1);
|
|
|
|
|
|
|
|
if( !p_board->box[col][row].IsMine ) {
|
|
|
|
i++;
|
|
|
|
p_board->box[col][row].IsMine = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now we label the remaining boxes with the
|
|
|
|
* number of mines surrounding them.
|
|
|
|
*/
|
|
|
|
|
|
|
|
for( col = 1; col < p_board->cols + 1; col++ )
|
|
|
|
for( row = 1; row < p_board->rows + 1; row++ ) {
|
|
|
|
for( i = -1; i <= 1; i++ )
|
|
|
|
for( j = -1; j <= 1; j++ ) {
|
|
|
|
if( p_board->box[col + i][row + j].IsMine ) {
|
|
|
|
p_board->box[col][row].NumMines++ ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-03-30 22:25:07 +02:00
|
|
|
void DrawMines ( HDC hdc, HDC hMemDC, BOARD *p_board )
|
2000-03-15 20:06:39 +01:00
|
|
|
{
|
2000-04-04 20:55:55 +02:00
|
|
|
HGDIOBJ hOldObj;
|
2000-03-15 20:06:39 +01:00
|
|
|
unsigned col, row;
|
2000-04-04 20:55:55 +02:00
|
|
|
hOldObj = SelectObject (hMemDC, p_board->hMinesBMP);
|
2000-03-15 20:06:39 +01:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
for( row = 1; row <= p_board->rows; row++ ) {
|
2000-03-30 22:25:07 +02:00
|
|
|
for( col = 1; col <= p_board->cols; col++ ) {
|
2002-06-01 01:06:46 +02:00
|
|
|
DrawMine( hdc, hMemDC, p_board, col, row, FALSE );
|
2000-03-30 22:25:07 +02:00
|
|
|
}
|
|
|
|
}
|
2000-04-04 20:55:55 +02:00
|
|
|
SelectObject( hMemDC, hOldObj );
|
2000-03-15 20:06:39 +01:00
|
|
|
}
|
|
|
|
|
2000-03-30 22:25:07 +02:00
|
|
|
void DrawMine( HDC hdc, HDC hMemDC, BOARD *p_board, unsigned col, unsigned row, BOOL IsPressed )
|
2000-03-15 20:06:39 +01:00
|
|
|
{
|
|
|
|
MINEBMP_OFFSET offset = BOX_BMP;
|
|
|
|
|
|
|
|
if( col == 0 || col > p_board->cols || row == 0 || row > p_board->rows )
|
2002-06-01 01:06:46 +02:00
|
|
|
return;
|
2000-03-15 20:06:39 +01:00
|
|
|
|
|
|
|
if( p_board->status == GAMEOVER ) {
|
|
|
|
if( p_board->box[col][row].IsMine ) {
|
|
|
|
switch( p_board->box[col][row].FlagType ) {
|
|
|
|
case FLAG:
|
|
|
|
offset = FLAG_BMP;
|
|
|
|
break;
|
|
|
|
case COMPLETE:
|
2002-06-01 01:06:46 +02:00
|
|
|
offset = EXPLODE_BMP;
|
2000-03-15 20:06:39 +01:00
|
|
|
break;
|
2003-11-26 04:40:01 +01:00
|
|
|
case QUESTION:
|
|
|
|
/* fall through */
|
2000-03-15 20:06:39 +01:00
|
|
|
case NORMAL:
|
|
|
|
offset = MINE_BMP;
|
|
|
|
}
|
2000-03-30 22:25:07 +02:00
|
|
|
} else {
|
2002-06-01 01:06:46 +02:00
|
|
|
switch( p_board->box[col][row].FlagType ) {
|
2000-03-15 20:06:39 +01:00
|
|
|
case QUESTION:
|
2002-06-01 01:06:46 +02:00
|
|
|
offset = QUESTION_BMP;
|
2000-03-15 20:06:39 +01:00
|
|
|
break;
|
|
|
|
case FLAG:
|
|
|
|
offset = WRONG_BMP;
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case NORMAL:
|
2000-03-15 20:06:39 +01:00
|
|
|
offset = BOX_BMP;
|
2000-03-30 22:25:07 +02:00
|
|
|
break;
|
|
|
|
case COMPLETE:
|
|
|
|
/* Do nothing */
|
|
|
|
break;
|
|
|
|
default:
|
2002-06-01 01:06:46 +02:00
|
|
|
DEBUG("Unknown FlagType during game over in DrawMine\n");
|
2000-03-30 22:25:07 +02:00
|
|
|
break;
|
2000-03-15 20:06:39 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2000-03-30 22:25:07 +02:00
|
|
|
} else { /* WAITING or PLAYING */
|
2000-03-15 20:06:39 +01:00
|
|
|
switch( p_board->box[col][row].FlagType ) {
|
|
|
|
case QUESTION:
|
2002-06-01 01:06:46 +02:00
|
|
|
if( !IsPressed )
|
|
|
|
offset = QUESTION_BMP;
|
2000-03-15 20:06:39 +01:00
|
|
|
else
|
2002-06-01 01:06:46 +02:00
|
|
|
offset = QPRESS_BMP;
|
2000-03-15 20:06:39 +01:00
|
|
|
break;
|
|
|
|
case FLAG:
|
|
|
|
offset = FLAG_BMP;
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case NORMAL:
|
2000-03-15 20:06:39 +01:00
|
|
|
if( !IsPressed )
|
|
|
|
offset = BOX_BMP;
|
2002-06-01 01:06:46 +02:00
|
|
|
else
|
2000-03-15 20:06:39 +01:00
|
|
|
offset = MPRESS_BMP;
|
2000-03-30 22:25:07 +02:00
|
|
|
break;
|
|
|
|
case COMPLETE:
|
|
|
|
/* Do nothing */
|
|
|
|
break;
|
|
|
|
default:
|
2002-06-01 01:06:46 +02:00
|
|
|
DEBUG("Unknown FlagType while playing in DrawMine\n");
|
2000-03-30 22:25:07 +02:00
|
|
|
break;
|
2000-03-15 20:06:39 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2000-03-15 20:06:39 +01:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
if( p_board->box[col][row].FlagType == COMPLETE
|
2000-03-30 22:25:07 +02:00
|
|
|
&& !p_board->box[col][row].IsMine )
|
2000-03-15 20:06:39 +01:00
|
|
|
offset = (MINEBMP_OFFSET) p_board->box[col][row].NumMines;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-03-15 20:06:39 +01:00
|
|
|
BitBlt( hdc,
|
2000-03-30 22:25:07 +02:00
|
|
|
(col - 1) * MINE_WIDTH + p_board->mines_rect.left,
|
|
|
|
(row - 1) * MINE_HEIGHT + p_board->mines_rect.top,
|
|
|
|
MINE_WIDTH, MINE_HEIGHT,
|
|
|
|
hMemDC, 0, offset * MINE_HEIGHT, SRCCOPY );
|
2000-03-15 20:06:39 +01:00
|
|
|
}
|
|
|
|
|
2000-03-30 22:25:07 +02:00
|
|
|
void DrawLeds( HDC hdc, HDC hMemDC, BOARD *p_board, int number, int x, int y )
|
2000-03-15 20:06:39 +01:00
|
|
|
{
|
2000-04-04 20:55:55 +02:00
|
|
|
HGDIOBJ hOldObj;
|
2000-03-15 20:06:39 +01:00
|
|
|
unsigned led[3], i;
|
2002-06-01 01:06:46 +02:00
|
|
|
int count;
|
2000-03-15 20:06:39 +01:00
|
|
|
|
|
|
|
count = number;
|
|
|
|
if( count < 1000 ) {
|
|
|
|
if( count >= 0 ) {
|
|
|
|
led[0] = count / 100 ;
|
|
|
|
count -= led[0] * 100;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
led[0] = 10; /* negative sign */
|
|
|
|
count = -count;
|
|
|
|
}
|
|
|
|
led[1] = count / 10;
|
|
|
|
count -= led[1] * 10;
|
|
|
|
led[2] = count;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for( i = 0; i < 3; i++ )
|
|
|
|
led[i] = 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* use unlit led if not playing */
|
|
|
|
if( p_board->status == WAITING )
|
|
|
|
for( i = 0; i < 3; i++ )
|
2002-06-01 01:06:46 +02:00
|
|
|
led[i] = 11;
|
|
|
|
|
2000-04-04 20:55:55 +02:00
|
|
|
hOldObj = SelectObject (hMemDC, p_board->hLedsBMP);
|
2000-03-30 22:25:07 +02:00
|
|
|
|
2000-03-15 20:06:39 +01:00
|
|
|
for( i = 0; i < 3; i++ ) {
|
|
|
|
BitBlt( hdc,
|
|
|
|
i * LED_WIDTH + x,
|
|
|
|
y,
|
|
|
|
LED_WIDTH,
|
|
|
|
LED_HEIGHT,
|
2002-06-01 01:06:46 +02:00
|
|
|
hMemDC,
|
|
|
|
0,
|
|
|
|
led[i] * LED_HEIGHT,
|
2000-03-15 20:06:39 +01:00
|
|
|
SRCCOPY);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-04-04 20:55:55 +02:00
|
|
|
SelectObject( hMemDC, hOldObj );
|
2000-03-15 20:06:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-30 22:25:07 +02:00
|
|
|
void DrawFace( HDC hdc, HDC hMemDC, BOARD *p_board )
|
2000-03-15 20:06:39 +01:00
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
HGDIOBJ hOldObj;
|
2000-04-04 20:55:55 +02:00
|
|
|
|
|
|
|
hOldObj = SelectObject (hMemDC, p_board->hFacesBMP);
|
2000-03-15 20:06:39 +01:00
|
|
|
|
|
|
|
BitBlt( hdc,
|
|
|
|
p_board->face_rect.left,
|
|
|
|
p_board->face_rect.top,
|
|
|
|
FACE_WIDTH,
|
|
|
|
FACE_HEIGHT,
|
|
|
|
hMemDC, 0, p_board->face_bmp * FACE_HEIGHT, SRCCOPY);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-04-04 20:55:55 +02:00
|
|
|
SelectObject( hMemDC, hOldObj );
|
2000-03-15 20:06:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-30 22:25:07 +02:00
|
|
|
void DrawBoard( HDC hdc, HDC hMemDC, PAINTSTRUCT *ps, BOARD *p_board )
|
2000-03-15 20:06:39 +01:00
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
RECT tmp_rect;
|
|
|
|
|
|
|
|
if( IntersectRect( &tmp_rect, &ps->rcPaint, &p_board->counter_rect ) )
|
2000-03-30 22:25:07 +02:00
|
|
|
DrawLeds( hdc, hMemDC, p_board, p_board->mines - p_board->num_flags,
|
|
|
|
p_board->counter_rect.left,
|
|
|
|
p_board->counter_rect.top );
|
2000-03-15 20:06:39 +01:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
if( IntersectRect( &tmp_rect, &ps->rcPaint, &p_board->timer_rect ) )
|
2000-03-30 22:25:07 +02:00
|
|
|
DrawLeds( hdc, hMemDC, p_board, p_board->time,
|
2002-06-01 01:06:46 +02:00
|
|
|
p_board->timer_rect.left,
|
2000-03-30 22:25:07 +02:00
|
|
|
p_board->timer_rect.top );
|
2002-06-01 01:06:46 +02:00
|
|
|
|
|
|
|
if( IntersectRect( &tmp_rect, &ps->rcPaint, &p_board->face_rect ) )
|
2000-03-30 22:25:07 +02:00
|
|
|
DrawFace( hdc, hMemDC, p_board );
|
2002-06-01 01:06:46 +02:00
|
|
|
|
|
|
|
if( IntersectRect( &tmp_rect, &ps->rcPaint, &p_board->mines_rect ) )
|
2000-03-30 22:25:07 +02:00
|
|
|
DrawMines( hdc, hMemDC, p_board );
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2000-03-15 20:06:39 +01:00
|
|
|
|
|
|
|
|
|
|
|
void TestBoard( HWND hWnd, BOARD *p_board, unsigned x, unsigned y, int msg )
|
|
|
|
{
|
|
|
|
POINT pt;
|
2004-03-02 00:13:30 +01:00
|
|
|
unsigned col,row;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-03-15 20:06:39 +01:00
|
|
|
pt.x = x;
|
|
|
|
pt.y = y;
|
|
|
|
|
|
|
|
if( PtInRect( &p_board->mines_rect, pt ) && p_board->status != GAMEOVER
|
2002-06-01 01:06:46 +02:00
|
|
|
&& p_board->status != WON )
|
2000-03-15 20:06:39 +01:00
|
|
|
TestMines( p_board, pt, msg );
|
|
|
|
else {
|
2002-06-01 01:06:46 +02:00
|
|
|
UnpressBoxes( p_board,
|
|
|
|
p_board->press.x,
|
|
|
|
p_board->press.y );
|
2000-03-15 20:06:39 +01:00
|
|
|
p_board->press.x = 0;
|
|
|
|
p_board->press.y = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( p_board->boxes_left == 0 ) {
|
|
|
|
p_board->status = WON;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-03-02 00:13:30 +01:00
|
|
|
if (p_board->num_flags < p_board->mines) {
|
|
|
|
for( row = 1; row <= p_board->rows; row++ ) {
|
|
|
|
for( col = 1; col <= p_board->cols; col++ ) {
|
|
|
|
if (p_board->box[col][row].IsMine && p_board->box[col][row].FlagType != FLAG)
|
|
|
|
p_board->box[col][row].FlagType = FLAG;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
p_board->num_flags = p_board->mines;
|
|
|
|
|
|
|
|
RedrawWindow( p_board->hWnd, NULL, NULL_HANDLE,
|
|
|
|
RDW_INVALIDATE | RDW_UPDATENOW );
|
|
|
|
}
|
|
|
|
|
2000-03-15 20:06:39 +01:00
|
|
|
if( p_board->difficulty != CUSTOM &&
|
|
|
|
p_board->time < p_board->best_time[p_board->difficulty] ) {
|
|
|
|
p_board->best_time[p_board->difficulty] = p_board->time;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
|
|
|
DialogBoxParam( p_board->hInst, "DLG_CONGRATS", hWnd,
|
2000-03-15 20:06:39 +01:00
|
|
|
CongratsDlgProc, (LPARAM) p_board);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
|
|
|
DialogBoxParam( p_board->hInst, "DLG_TIMES", hWnd,
|
2000-03-15 20:06:39 +01:00
|
|
|
TimesDlgProc, (LPARAM) p_board);
|
|
|
|
}
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
TestFace( p_board, pt, msg );
|
2000-03-15 20:06:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestMines( BOARD *p_board, POINT pt, int msg )
|
|
|
|
{
|
|
|
|
BOOL draw = TRUE;
|
2002-06-01 01:06:46 +02:00
|
|
|
unsigned col, row;
|
2000-03-15 20:06:39 +01:00
|
|
|
|
|
|
|
col = (pt.x - p_board->mines_rect.left) / MINE_WIDTH + 1;
|
|
|
|
row = (pt.y - p_board->mines_rect.top ) / MINE_HEIGHT + 1;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-03-15 20:06:39 +01:00
|
|
|
switch ( msg ) {
|
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
if( p_board->press.x != col || p_board->press.y != row ) {
|
2002-06-01 01:06:46 +02:00
|
|
|
UnpressBox( p_board,
|
2000-03-15 20:06:39 +01:00
|
|
|
p_board->press.x, p_board->press.y );
|
|
|
|
p_board->press.x = col;
|
|
|
|
p_board->press.y = row;
|
2002-06-01 01:06:46 +02:00
|
|
|
PressBox( p_board, col, row );
|
|
|
|
}
|
|
|
|
draw = FALSE;
|
2000-03-15 20:06:39 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_LBUTTONUP:
|
|
|
|
if( p_board->press.x != col || p_board->press.y != row )
|
2002-06-01 01:06:46 +02:00
|
|
|
UnpressBox( p_board,
|
2000-03-15 20:06:39 +01:00
|
|
|
p_board->press.x, p_board->press.y );
|
|
|
|
p_board->press.x = 0;
|
|
|
|
p_board->press.y = 0;
|
|
|
|
if( p_board->box[col][row].FlagType != FLAG )
|
2002-06-01 01:06:46 +02:00
|
|
|
p_board->status = PLAYING;
|
2000-03-15 20:06:39 +01:00
|
|
|
CompleteBox( p_board, col, row );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_MBUTTONDOWN:
|
|
|
|
PressBoxes( p_board, col, row );
|
2000-03-30 22:25:07 +02:00
|
|
|
draw = FALSE;
|
2000-03-15 20:06:39 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_MBUTTONUP:
|
|
|
|
if( p_board->press.x != col || p_board->press.y != row )
|
2002-06-01 01:06:46 +02:00
|
|
|
UnpressBoxes( p_board,
|
2000-03-15 20:06:39 +01:00
|
|
|
p_board->press.x, p_board->press.y );
|
|
|
|
p_board->press.x = 0;
|
|
|
|
p_board->press.y = 0;
|
|
|
|
CompleteBoxes( p_board, col, row );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_RBUTTONDOWN:
|
|
|
|
AddFlag( p_board, col, row );
|
2002-06-01 01:06:46 +02:00
|
|
|
p_board->status = PLAYING;
|
2000-03-30 22:25:07 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
DEBUG("Unknown message type received in TestMines\n");
|
2000-03-15 20:06:39 +01:00
|
|
|
break;
|
|
|
|
}
|
2000-03-30 22:25:07 +02:00
|
|
|
|
2000-03-15 20:06:39 +01:00
|
|
|
if( draw )
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
RedrawWindow( p_board->hWnd, NULL, NULL_HANDLE,
|
2000-03-15 20:06:39 +01:00
|
|
|
RDW_INVALIDATE | RDW_UPDATENOW );
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2000-03-15 20:06:39 +01:00
|
|
|
|
|
|
|
|
|
|
|
void TestFace( BOARD *p_board, POINT pt, int msg )
|
|
|
|
{
|
|
|
|
if( p_board->status == PLAYING || p_board->status == WAITING ) {
|
|
|
|
if( msg == WM_LBUTTONDOWN || msg == WM_MBUTTONDOWN )
|
|
|
|
p_board->face_bmp = OOH_BMP;
|
|
|
|
else p_board->face_bmp = SMILE_BMP;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
else if( p_board->status == GAMEOVER )
|
2000-03-15 20:06:39 +01:00
|
|
|
p_board->face_bmp = DEAD_BMP;
|
2002-06-01 01:06:46 +02:00
|
|
|
else if( p_board->status == WON )
|
2000-03-15 20:06:39 +01:00
|
|
|
p_board->face_bmp = COOL_BMP;
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
if( PtInRect( &p_board->face_rect, pt ) ) {
|
|
|
|
if( msg == WM_LBUTTONDOWN )
|
2000-03-15 20:06:39 +01:00
|
|
|
p_board->face_bmp = SPRESS_BMP;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
|
|
|
if( msg == WM_LBUTTONUP )
|
|
|
|
CreateBoard( p_board );
|
2000-03-15 20:06:39 +01:00
|
|
|
}
|
2000-03-30 22:25:07 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
RedrawWindow( p_board->hWnd, &p_board->face_rect, NULL_HANDLE,
|
2000-03-15 20:06:39 +01:00
|
|
|
RDW_INVALIDATE | RDW_UPDATENOW );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CompleteBox( BOARD *p_board, unsigned col, unsigned row )
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
if( p_board->box[col][row].FlagType != COMPLETE &&
|
|
|
|
p_board->box[col][row].FlagType != FLAG &&
|
|
|
|
col > 0 && col < p_board->cols + 1 &&
|
2000-03-15 20:06:39 +01:00
|
|
|
row > 0 && row < p_board->rows + 1 ) {
|
|
|
|
p_board->box[col][row].FlagType = COMPLETE;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-03-15 20:06:39 +01:00
|
|
|
if( p_board->box[col][row].IsMine ) {
|
2002-06-01 01:06:46 +02:00
|
|
|
p_board->face_bmp = DEAD_BMP;
|
2000-03-15 20:06:39 +01:00
|
|
|
p_board->status = GAMEOVER;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
else if( p_board->status != GAMEOVER )
|
2000-03-15 20:06:39 +01:00
|
|
|
p_board->boxes_left--;
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
if( p_board->box[col][row].NumMines == 0 )
|
2000-03-15 20:06:39 +01:00
|
|
|
{
|
|
|
|
for( i = -1; i <= 1; i++ )
|
|
|
|
for( j = -1; j <= 1; j++ )
|
|
|
|
CompleteBox( p_board, col + i, row + j );
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2000-03-15 20:06:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CompleteBoxes( BOARD *p_board, unsigned col, unsigned row )
|
|
|
|
{
|
|
|
|
unsigned numFlags = 0;
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
if( p_board->box[col][row].FlagType == COMPLETE ) {
|
|
|
|
for( i = -1; i <= 1; i++ )
|
2000-03-30 22:25:07 +02:00
|
|
|
for( j = -1; j <= 1; j++ ) {
|
2002-06-01 01:06:46 +02:00
|
|
|
if( p_board->box[col+i][row+j].FlagType == FLAG )
|
2000-03-15 20:06:39 +01:00
|
|
|
numFlags++;
|
2000-03-30 22:25:07 +02:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-03-15 20:06:39 +01:00
|
|
|
if( numFlags == p_board->box[col][row].NumMines ) {
|
|
|
|
for( i = -1; i <= 1; i++ )
|
2000-03-30 22:25:07 +02:00
|
|
|
for( j = -1; j <= 1; j++ ) {
|
2002-06-01 01:06:46 +02:00
|
|
|
if( p_board->box[col+i][row+j].FlagType != FLAG )
|
2000-03-15 20:06:39 +01:00
|
|
|
CompleteBox( p_board, col+i, row+j );
|
2000-03-30 22:25:07 +02:00
|
|
|
}
|
2000-03-15 20:06:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void AddFlag( BOARD *p_board, unsigned col, unsigned row )
|
|
|
|
{
|
|
|
|
if( p_board->box[col][row].FlagType != COMPLETE ) {
|
|
|
|
switch( p_board->box[col][row].FlagType ) {
|
|
|
|
case FLAG:
|
|
|
|
if( p_board->IsMarkQ )
|
|
|
|
p_board->box[col][row].FlagType = QUESTION;
|
2002-06-01 01:06:46 +02:00
|
|
|
else
|
2000-03-15 20:06:39 +01:00
|
|
|
p_board->box[col][row].FlagType = NORMAL;
|
|
|
|
p_board->num_flags--;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QUESTION:
|
|
|
|
p_board->box[col][row].FlagType = NORMAL;
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-03-15 20:06:39 +01:00
|
|
|
default:
|
|
|
|
p_board->box[col][row].FlagType = FLAG;
|
|
|
|
p_board->num_flags++;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
|
|
|
}
|
2000-03-15 20:06:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PressBox( BOARD *p_board, unsigned col, unsigned row )
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
HDC hdc;
|
|
|
|
HGDIOBJ hOldObj;
|
2000-03-30 22:25:07 +02:00
|
|
|
HDC hMemDC;
|
2000-03-15 20:06:39 +01:00
|
|
|
|
|
|
|
hdc = GetDC( p_board->hWnd );
|
2000-03-30 22:25:07 +02:00
|
|
|
hMemDC = CreateCompatibleDC( hdc );
|
2000-04-04 20:55:55 +02:00
|
|
|
hOldObj = SelectObject (hMemDC, p_board->hMinesBMP);
|
2000-03-30 22:25:07 +02:00
|
|
|
|
|
|
|
DrawMine( hdc, hMemDC, p_board, col, row, TRUE );
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
SelectObject( hMemDC, hOldObj );
|
2000-03-30 22:25:07 +02:00
|
|
|
DeleteDC( hMemDC );
|
2000-03-15 20:06:39 +01:00
|
|
|
ReleaseDC( p_board->hWnd, hdc );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PressBoxes( BOARD *p_board, unsigned col, unsigned row )
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
for( i = -1; i <= 1; i++ )
|
2000-03-30 22:25:07 +02:00
|
|
|
for( j = -1; j <= 1; j++ ) {
|
2002-06-01 01:06:46 +02:00
|
|
|
p_board->box[col + i][row + j].IsPressed = TRUE;
|
2000-03-15 20:06:39 +01:00
|
|
|
PressBox( p_board, col + i, row + j );
|
|
|
|
}
|
|
|
|
|
|
|
|
for( i = -1; i <= 1; i++ )
|
2000-03-30 22:25:07 +02:00
|
|
|
for( j = -1; j <= 1; j++ ) {
|
2002-06-01 01:06:46 +02:00
|
|
|
if( !p_board->box[p_board->press.x + i][p_board->press.y + j].IsPressed )
|
2000-03-15 20:06:39 +01:00
|
|
|
UnpressBox( p_board, p_board->press.x + i, p_board->press.y + j );
|
|
|
|
}
|
|
|
|
|
|
|
|
for( i = -1; i <= 1; i++ )
|
2000-03-30 22:25:07 +02:00
|
|
|
for( j = -1; j <= 1; j++ ) {
|
2002-06-01 01:06:46 +02:00
|
|
|
p_board->box[col + i][row + j].IsPressed = FALSE;
|
2000-03-15 20:06:39 +01:00
|
|
|
PressBox( p_board, col + i, row + j );
|
|
|
|
}
|
|
|
|
|
|
|
|
p_board->press.x = col;
|
2002-06-01 01:06:46 +02:00
|
|
|
p_board->press.y = row;
|
2000-03-15 20:06:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UnpressBox( BOARD *p_board, unsigned col, unsigned row )
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
HDC hdc;
|
|
|
|
HGDIOBJ hOldObj;
|
2000-03-30 22:25:07 +02:00
|
|
|
HDC hMemDC;
|
2000-03-15 20:06:39 +01:00
|
|
|
|
|
|
|
hdc = GetDC( p_board->hWnd );
|
2000-03-30 22:25:07 +02:00
|
|
|
hMemDC = CreateCompatibleDC( hdc );
|
2000-04-04 20:55:55 +02:00
|
|
|
hOldObj = SelectObject( hMemDC, p_board->hMinesBMP );
|
2000-03-30 22:25:07 +02:00
|
|
|
|
|
|
|
DrawMine( hdc, hMemDC, p_board, col, row, FALSE );
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
SelectObject( hMemDC, hOldObj );
|
2000-03-30 22:25:07 +02:00
|
|
|
DeleteDC( hMemDC );
|
2000-03-15 20:06:39 +01:00
|
|
|
ReleaseDC( p_board->hWnd, hdc );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UnpressBoxes( BOARD *p_board, unsigned col, unsigned row )
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
int i, j;
|
|
|
|
|
2000-03-15 20:06:39 +01:00
|
|
|
for( i = -1; i <= 1; i++ )
|
2000-03-30 22:25:07 +02:00
|
|
|
for( j = -1; j <= 1; j++ ) {
|
2000-03-15 20:06:39 +01:00
|
|
|
UnpressBox( p_board, col + i, row + j );
|
2000-03-30 22:25:07 +02:00
|
|
|
}
|
2000-03-15 20:06:39 +01:00
|
|
|
}
|