2 * Copyright 2000 Joshua Thielen
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define BEGINNER_MINES 10
22 #define BEGINNER_COLS 9
23 #define BEGINNER_ROWS 9
25 #define ADVANCED_MINES 40
26 #define ADVANCED_COLS 16
27 #define ADVANCED_ROWS 16
29 #define EXPERT_MINES 99
30 #define EXPERT_COLS 30
31 #define EXPERT_ROWS 16
36 #define BOTTOM_MARGIN 20
37 #define BOARD_WMARGIN 5
38 #define BOARD_HMARGIN 5
42 #define MINE_HEIGHT 16
46 #define FACE_HEIGHT 24
48 #define MAX_PLAYER_NAME_SIZE 31
50 typedef enum { SPRESS_BMP, COOL_BMP, DEAD_BMP, OOH_BMP, SMILE_BMP } FACE_BMP;
52 typedef enum { WAITING, PLAYING, GAMEOVER, WON } GAME_STATUS;
55 MPRESS_BMP, ONE_BMP, TWO_BMP, THREE_BMP, FOUR_BMP, FIVE_BMP, SIX_BMP,
56 SEVEN_BMP, EIGHT_BMP, BOX_BMP, FLAG_BMP, QUESTION_BMP, EXPLODE_BMP,
57 WRONG_BMP, MINE_BMP, QPRESS_BMP
60 typedef enum { BEGINNER, ADVANCED, EXPERT, CUSTOM } DIFFICULTY;
62 typedef struct tagBOARD
89 char best_name [3][MAX_PLAYER_NAME_SIZE+1];
91 DIFFICULTY difficulty;
99 #define MB_RIGHTDOWN 3
101 #define MB_BOTHDOWN 5
110 unsigned IsPressed : 1;
111 unsigned FlagType : 2;
112 unsigned NumMines : 4;
113 } box [MAX_COLS + 2] [MAX_ROWS + 2];
115 /* defines for FlagType */
123 void ExitApp( int error );
125 void InitBoard( BOARD *p_board );
127 void LoadBoard( BOARD *p_board );
129 void SaveBoard( BOARD *p_board );
131 void DestroyBoard( BOARD *p_board );
133 void SetDifficulty( BOARD *p_board, DIFFICULTY difficulty );
135 void CheckLevel( BOARD *p_board );
137 void CreateBoard( BOARD *p_board );
139 void PlaceMines ( BOARD *p_board, int selected_col, int selected_row );
141 void TestBoard( HWND hWnd, BOARD *p_board, int x, int y, int msg );
143 void TestMines( BOARD *p_board, POINT pt, int msg );
145 void TestFace( BOARD *p_board, POINT pt, int msg );
147 void DrawBoard( HDC hdc, HDC hMemDC, PAINTSTRUCT *ps, BOARD *p_board );
149 void DrawMines( HDC hdc, HDC hMemDC, BOARD *p_board );
151 void DrawMine( HDC hdc, HDC hMemDC, BOARD *p_board, unsigned col, unsigned row, BOOL IsPressed );
153 void AddFlag( BOARD *p_board, unsigned col, unsigned row );
155 void CompleteBox( BOARD *p_board, unsigned col, unsigned row );
157 void CompleteBoxes( BOARD *p_board, unsigned col, unsigned row );
159 void PressBox( BOARD *p_board, unsigned col, unsigned row );
161 void PressBoxes( BOARD *p_board, unsigned col, unsigned row );
163 void UnpressBox( BOARD *p_board, unsigned col, unsigned row );
165 void UnpressBoxes( BOARD *p_board, unsigned col, unsigned row );
167 void UpdateTimer( BOARD *p_board );
169 void DrawLeds( HDC hdc, HDC hMemDC, BOARD *p_board, int number, int x, int y);
171 void DrawFace( HDC hdc, HDC hMemDC, BOARD *p_board );
173 LRESULT WINAPI MainProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
175 INT_PTR CALLBACK CustomDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
177 INT_PTR CALLBACK CongratsDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
179 INT_PTR CALLBACK TimesDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
181 INT_PTR CALLBACK AboutDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );