1 /******************************************************************************
4 * modified: [ 03-08-15 ] Ge van Geldorp <ge@gse.nl>
6 * modified: [ 94-10-8 ] Ge van Geldorp <Ge.vanGeldorp@lr.tudelft.nl>
8 * modified: [ 3-7-93 ] Jamie Zawinski <jwz@lucid.com>
9 * added the XRoger logo, cleaned up resources, made
10 * grid size a parameter.
11 * modified: [ 3-3-93 ] Jim Randell <jmr@mddjmr.fc.hp.com>
12 * Added the colour stuff and integrated it with jwz's
13 * screenhack stuff. There's still some work that could
14 * be done on this, particularly allowing a resource to
15 * specify how big the squares are.
16 * modified: [ 10-4-88 ] Richard Hess ...!uunet!cimshop!rhess
17 * [ Revised primary execution loop within main()...
18 * [ Extended X event handler, check_events()...
19 * modified: [ 1-29-88 ] Dave Lemke lemke@sun.com
21 * [ Note the word "hacked" -- this is extremely ugly, but at
22 * [ least it does the job. NOT a good programming example
24 * original: [ 6/21/85 ] Martin Weiss Sun Microsystems [ SunView ]
26 ******************************************************************************
27 Copyright 1988 by Sun Microsystems, Inc. Mountain View, CA.
31 Permission to use, copy, modify, and distribute this software and its
32 documentation for any purpose and without fee is hereby granted,
33 provided that the above copyright notice appear in all copies and that
34 both that copyright notice and this permission notice appear in
35 supporting documentation, and that the names of Sun or MIT not be
36 used in advertising or publicity pertaining to distribution of the
37 software without specific prior written permission. Sun and M.I.T.
38 make no representations about the suitability of this software for
39 any purpose. It is provided "as is" without any express or implied warranty.
41 SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
42 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43 PURPOSE. IN NO EVENT SHALL SUN BE LIABLE FOR ANY SPECIAL, INDIRECT
44 OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
45 OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
46 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
47 OR PERFORMANCE OF THIS SOFTWARE.
48 *****************************************************************************/
55 #include <windows.h> /* required for all Windows applications */
57 #if !defined (APIENTRY) /* Windows NT defines APIENTRY, but 3.x doesn't */
58 #define APIENTRY far pascal
61 #if !defined(WIN32) /* Windows 3.x uses a FARPROC for dialogs */
62 #define DLGPROC FARPROC
65 static BOOL
InitApplication(HINSTANCE hInstance
);
66 static BOOL
InitInstance(HINSTANCE hInstance
, int nCmdShow
);
67 LRESULT CALLBACK
WndProc(HWND hWnd
, UINT message
, WPARAM uParam
,
70 HINSTANCE hInst
; /* current instance */
71 HWND hWnd
; /* Main window handle.*/
78 char szAppName
[] = "Maze"; /* The name of this application */
79 char szTitle
[] = "Maze"; /* The title bar text */
81 static int solve_delay
, pre_solve_delay
, post_solve_delay
;
83 #define MAX_MAZE_SIZE_X ((unsigned long) 250)
84 #define MAX_MAZE_SIZE_Y ((unsigned long) 250)
86 #define MOVE_LIST_SIZE (MAX_MAZE_SIZE_X * MAX_MAZE_SIZE_Y)
88 #define WALL_TOP 0x8000
89 #define WALL_RIGHT 0x4000
90 #define WALL_BOTTOM 0x2000
91 #define WALL_LEFT 0x1000
93 #define DOOR_IN_TOP 0x800
94 #define DOOR_IN_RIGHT 0x400
95 #define DOOR_IN_BOTTOM 0x200
96 #define DOOR_IN_LEFT 0x100
97 #define DOOR_IN_ANY 0xF00
99 #define DOOR_OUT_TOP 0x80
100 #define DOOR_OUT_RIGHT 0x40
101 #define DOOR_OUT_BOTTOM 0x20
102 #define DOOR_OUT_LEFT 0x10
104 #define START_SQUARE 0x2
105 #define END_SQUARE 0x1
110 #define get_random(x) (rand() % (x))
112 static unsigned short maze
[MAX_MAZE_SIZE_X
][MAX_MAZE_SIZE_Y
];
119 } move_list
[MOVE_LIST_SIZE
], save_path
[MOVE_LIST_SIZE
], path
[MOVE_LIST_SIZE
];
121 static int maze_size_x
, maze_size_y
;
122 static long sqnum
, path_length
;
123 static int cur_sq_x
, cur_sq_y
;
124 static int start_x
, start_y
, start_dir
, end_x
, end_y
, end_dir
;
125 static int grid_width
, grid_height
;
127 static int state
= 1, pathi
= 0;
130 set_maze_sizes (width
, height
)
133 maze_size_x
= width
/ grid_width
;
134 maze_size_y
= height
/ grid_height
;
139 initialize_maze() /* draw the surrounding wall and start/end squares */
141 register int i
, j
, wall
;
143 /* initialize all squares */
144 for ( i
=0; i
<maze_size_x
; i
++) {
145 for ( j
=0; j
<maze_size_y
; j
++) {
151 for ( i
=0; i
<maze_size_x
; i
++ ) {
152 maze
[i
][0] |= WALL_TOP
;
156 for ( j
=0; j
<maze_size_y
; j
++ ) {
157 maze
[maze_size_x
-1][j
] |= WALL_RIGHT
;
161 for ( i
=0; i
<maze_size_x
; i
++ ) {
162 maze
[i
][maze_size_y
-1] |= WALL_BOTTOM
;
166 for ( j
=0; j
<maze_size_y
; j
++ ) {
167 maze
[0][j
] |= WALL_LEFT
;
170 /* set start square */
171 wall
= get_random(4);
174 i
= get_random(maze_size_x
);
179 j
= get_random(maze_size_y
);
182 i
= get_random(maze_size_x
);
187 j
= get_random(maze_size_y
);
190 maze
[i
][j
] |= START_SQUARE
;
191 maze
[i
][j
] |= ( DOOR_IN_TOP
>> wall
);
192 maze
[i
][j
] &= ~( WALL_TOP
>> wall
);
204 i
= get_random(maze_size_x
);
209 j
= get_random(maze_size_y
);
212 i
= get_random(maze_size_x
);
217 j
= get_random(maze_size_y
);
220 maze
[i
][j
] |= END_SQUARE
;
221 maze
[i
][j
] |= ( DOOR_OUT_TOP
>> wall
);
222 maze
[i
][j
] &= ~( WALL_TOP
>> wall
);
228 static int choose_door ();
229 static long backup ();
230 static void draw_wall ();
231 static void draw_solid_square(int, int, int, HDC
, HBRUSH
);
232 static void enter_square(int, HDC
, HBRUSH
);
235 create_maze() /* create a maze layout given the intiialized maze */
237 register int i
, newdoor
= 0;
242 move_list
[sqnum
].x
= cur_sq_x
;
243 move_list
[sqnum
].y
= cur_sq_y
;
244 move_list
[sqnum
].dir
= newdoor
;
245 while ( ( newdoor
= choose_door(hDC
) ) == -1 ) { /* pick a door */
246 if ( backup() == -1 ) { /* no more doors ... backup */
247 ReleaseDC(hWnd
, hDC
);
248 return; /* done ... return */
252 /* mark the out door */
253 maze
[cur_sq_x
][cur_sq_y
] |= ( DOOR_OUT_TOP
>> newdoor
);
267 /* mark the in door */
268 maze
[cur_sq_x
][cur_sq_y
] |= ( DOOR_IN_TOP
>> ((newdoor
+2)%4) );
270 /* if end square set path length and save path */
271 if ( maze
[cur_sq_x
][cur_sq_y
] & END_SQUARE
) {
273 for ( i
=0; i
<path_length
; i
++) {
274 save_path
[i
].x
= move_list
[i
].x
;
275 save_path
[i
].y
= move_list
[i
].y
;
276 save_path
[i
].dir
= move_list
[i
].dir
;
286 choose_door(HDC hDC
) /* pick a new path */
289 register int num_candidates
;
294 if ( maze
[cur_sq_x
][cur_sq_y
] & DOOR_IN_TOP
)
296 if ( maze
[cur_sq_x
][cur_sq_y
] & DOOR_OUT_TOP
)
298 if ( maze
[cur_sq_x
][cur_sq_y
] & WALL_TOP
)
300 if ( maze
[cur_sq_x
][cur_sq_y
- 1] & DOOR_IN_ANY
) {
301 maze
[cur_sq_x
][cur_sq_y
] |= WALL_TOP
;
302 maze
[cur_sq_x
][cur_sq_y
- 1] |= WALL_BOTTOM
;
303 draw_wall(cur_sq_x
, cur_sq_y
, 0, hDC
);
306 candidates
[num_candidates
++] = 0;
310 if ( maze
[cur_sq_x
][cur_sq_y
] & DOOR_IN_RIGHT
)
312 if ( maze
[cur_sq_x
][cur_sq_y
] & DOOR_OUT_RIGHT
)
314 if ( maze
[cur_sq_x
][cur_sq_y
] & WALL_RIGHT
)
316 if ( maze
[cur_sq_x
+ 1][cur_sq_y
] & DOOR_IN_ANY
) {
317 maze
[cur_sq_x
][cur_sq_y
] |= WALL_RIGHT
;
318 maze
[cur_sq_x
+ 1][cur_sq_y
] |= WALL_LEFT
;
319 draw_wall(cur_sq_x
, cur_sq_y
, 1, hDC
);
322 candidates
[num_candidates
++] = 1;
326 if ( maze
[cur_sq_x
][cur_sq_y
] & DOOR_IN_BOTTOM
)
328 if ( maze
[cur_sq_x
][cur_sq_y
] & DOOR_OUT_BOTTOM
)
330 if ( maze
[cur_sq_x
][cur_sq_y
] & WALL_BOTTOM
)
332 if ( maze
[cur_sq_x
][cur_sq_y
+ 1] & DOOR_IN_ANY
) {
333 maze
[cur_sq_x
][cur_sq_y
] |= WALL_BOTTOM
;
334 maze
[cur_sq_x
][cur_sq_y
+ 1] |= WALL_TOP
;
335 draw_wall(cur_sq_x
, cur_sq_y
, 2, hDC
);
338 candidates
[num_candidates
++] = 2;
342 if ( maze
[cur_sq_x
][cur_sq_y
] & DOOR_IN_LEFT
)
344 if ( maze
[cur_sq_x
][cur_sq_y
] & DOOR_OUT_LEFT
)
346 if ( maze
[cur_sq_x
][cur_sq_y
] & WALL_LEFT
)
348 if ( maze
[cur_sq_x
- 1][cur_sq_y
] & DOOR_IN_ANY
) {
349 maze
[cur_sq_x
][cur_sq_y
] |= WALL_LEFT
;
350 maze
[cur_sq_x
- 1][cur_sq_y
] |= WALL_RIGHT
;
351 draw_wall(cur_sq_x
, cur_sq_y
, 3, hDC
);
354 candidates
[num_candidates
++] = 3;
357 if (num_candidates
== 0)
359 if (num_candidates
== 1)
360 return ( candidates
[0] );
361 return ( candidates
[ get_random(num_candidates
) ] );
367 backup() /* back up a move */
371 cur_sq_x
= move_list
[sqnum
].x
;
372 cur_sq_y
= move_list
[sqnum
].y
;
380 draw_solid_square(i
, j
, dir
, hDC
, hBrush
) /* draw a solid square in a square */
381 register int i
, j
, dir
;
389 rc
.left
= border_x
+ bw
+ grid_width
* i
;
390 rc
.right
= rc
.left
+ grid_width
- (bw
+ bw
);
391 rc
.top
= border_y
- bw
+ grid_height
* j
;
392 rc
.bottom
= rc
.top
+ grid_height
;
395 rc
.left
= border_x
+ bw
+ grid_width
* i
;
396 rc
.right
= rc
.left
+ grid_width
;
397 rc
.top
= border_y
+ bw
+ grid_height
* j
;
398 rc
.bottom
= rc
.top
+ grid_height
- (bw
+ bw
);
401 rc
.left
= border_x
+ bw
+ grid_width
* i
;
402 rc
.right
= rc
.left
+ grid_width
- (bw
+ bw
);
403 rc
.top
= border_y
+ bw
+ grid_height
* j
;
404 rc
.bottom
= rc
.top
+ grid_height
;
407 rc
.left
= border_x
- bw
+ grid_width
* i
;
408 rc
.right
= rc
.left
+ grid_width
;
409 rc
.top
= border_y
+ bw
+ grid_height
* j
;
410 rc
.bottom
= rc
.top
+ grid_height
- (bw
+ bw
);
413 (void) FillRect(hDC
, &rc
, hBrush
);
417 draw_maze_border(HWND hWnd
, HDC hDC
) /* draw the maze outline */
423 for ( i
=0; i
<maze_size_x
; i
++) {
424 if ( maze
[i
][0] & WALL_TOP
) {
425 MoveToEx(hDC
, border_x
+ grid_width
* i
, border_y
, NULL
);
426 (void) LineTo(hDC
, border_x
+ grid_width
* (i
+ 1) - 1, border_y
);
428 if ((maze
[i
][maze_size_y
- 1] & WALL_BOTTOM
)) {
429 MoveToEx(hDC
, border_x
+ grid_width
* i
,
430 border_y
+ grid_height
* (maze_size_y
) - 1, NULL
);
431 (void) LineTo(hDC
, border_x
+ grid_width
* (i
+1) - 1,
432 border_y
+ grid_height
* (maze_size_y
) - 1);
435 for ( j
=0; j
<maze_size_y
; j
++) {
436 if ( maze
[maze_size_x
- 1][j
] & WALL_RIGHT
) {
437 MoveToEx(hDC
, border_x
+ grid_width
* maze_size_x
- 1,
438 border_y
+ grid_height
* j
, NULL
);
439 (void) LineTo(hDC
, border_x
+ grid_width
* maze_size_x
- 1,
440 border_y
+ grid_height
* (j
+1) - 1);
442 if ( maze
[0][j
] & WALL_LEFT
) {
443 MoveToEx(hDC
, border_x
, border_y
+ grid_height
* j
, NULL
);
444 (void) LineTo(hDC
, border_x
, border_y
+ grid_height
* (j
+1) - 1);
448 hBrush
= GetStockObject(BLACK_BRUSH
);
449 draw_solid_square (start_x
, start_y
, start_dir
, hDC
, hBrush
);
450 draw_solid_square (end_x
, end_y
, end_dir
, hDC
, hBrush
);
455 draw_wall(i
, j
, dir
, hDC
) /* draw a single wall */
461 MoveToEx(hDC
, border_x
+ grid_width
* i
, border_y
+ grid_height
* j
, NULL
);
462 (void) LineTo(hDC
, border_x
+ grid_width
* (i
+1),
463 border_y
+ grid_height
* j
);
466 MoveToEx(hDC
, border_x
+ grid_width
* (i
+1), border_y
+ grid_height
* j
,
468 (void) LineTo(hDC
, border_x
+ grid_width
* (i
+1),
469 border_y
+ grid_height
* (j
+1));
472 MoveToEx(hDC
, border_x
+ grid_width
* i
, border_y
+ grid_height
* (j
+1),
474 (void) LineTo(hDC
, border_x
+ grid_width
* (i
+1),
475 border_y
+ grid_height
* (j
+1));
478 MoveToEx(hDC
, border_x
+ grid_width
* i
, border_y
+ grid_height
* j
,
480 (void) LineTo(hDC
, border_x
+ grid_width
* i
,
481 border_y
+ grid_height
* (j
+1));
487 begin_solve_maze() /* solve it with graphical feedback */
489 static long grayPattern
[] = {
499 static RGBQUAD argbq
[] = {
506 pbmi
= malloc(sizeof(BITMAPINFOHEADER
) + sizeof(argbq
) + sizeof(grayPattern
));
507 pbmi
->bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
508 pbmi
->bmiHeader
.biWidth
= 8;
509 pbmi
->bmiHeader
.biHeight
= 8;
510 pbmi
->bmiHeader
.biPlanes
= 1;
511 pbmi
->bmiHeader
.biBitCount
= 1;
512 pbmi
->bmiHeader
.biCompression
= BI_RGB
;
513 (void) memcpy(pbmi
->bmiColors
, argbq
, sizeof(argbq
));
514 (void) memcpy(pbmi
->bmiColors
+ 2, grayPattern
, sizeof(grayPattern
));
516 /* FIXME Pattern brushes not yet implemented in ReactOS */
517 hBrushDead
= CreateDIBPatternBrushPt(pbmi
, DIB_RGB_COLORS
);
519 hBrushDead
= CreateSolidBrush(RGB(255, 0, 0));
521 // hBrushDead = CreateHatchBrush(HS_DIAGCROSS, RGB(255, 0, 0));
523 hBrushLiving
= CreateSolidBrush(RGB(0, 255, 0));
525 /* plug up the surrounding wall */
526 maze
[start_x
][start_y
] |= (WALL_TOP
>> start_dir
);
527 maze
[end_x
][end_y
] |= (WALL_TOP
>> end_dir
);
529 /* initialize search path */
531 path
[pathi
].x
= end_x
;
532 path
[pathi
].y
= end_y
;
533 path
[pathi
].dir
= -1;
537 solve_maze() /* solve it with graphical feedback */
544 if ( ++path
[pathi
].dir
>= 4 ) {
546 draw_solid_square( (int)(path
[pathi
].x
), (int)(path
[pathi
].y
),
547 (int)(path
[pathi
].dir
), hDC
, hBrushDead
);
550 else if ( ! (maze
[path
[pathi
].x
][path
[pathi
].y
] &
551 (WALL_TOP
>> path
[pathi
].dir
)) &&
552 ( (pathi
== 0) || ( (path
[pathi
].dir
!=
553 (int)(path
[pathi
-1].dir
+2)%4) ) ) ) {
554 enter_square(pathi
, hDC
, hBrushLiving
);
556 if ( maze
[path
[pathi
].x
][path
[pathi
].y
] & START_SQUARE
) {
557 DeleteObject(hBrushLiving
);
558 DeleteObject(hBrushDead
);
559 ReleaseDC(hWnd
, hDC
);
567 } while (! action_done
);
574 enter_square(int n
, HDC hDC
, HBRUSH hBrush
) /* move into a neighboring square */
576 draw_solid_square( (int)path
[n
].x
, (int)path
[n
].y
,
577 (int)path
[n
].dir
, hDC
, hBrush
);
580 switch (path
[n
].dir
) {
581 case 0: path
[n
+1].x
= path
[n
].x
;
582 path
[n
+1].y
= path
[n
].y
- 1;
584 case 1: path
[n
+1].x
= path
[n
].x
+ 1;
585 path
[n
+1].y
= path
[n
].y
;
587 case 2: path
[n
+1].x
= path
[n
].x
;
588 path
[n
+1].y
= path
[n
].y
+ 1;
590 case 3: path
[n
+1].x
= path
[n
].x
- 1;
591 path
[n
+1].y
= path
[n
].y
;
597 start_timer(HWND hWnd
, int iTimeout
)
600 SetTimer(hWnd
, 1, iTimeout
, NULL
);
603 /****************************************************************************
605 FUNCTION: WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
607 PURPOSE: calls initialization function, processes message loop
611 Windows recognizes this function by name as the initial entry point
612 for the program. This function calls the application initialization
613 routine, if no other instance of the program is running, and always
614 calls the instance initialization routine. It then executes a message
615 retrieval and dispatch loop that is the top-level control structure
616 for the remainder of execution. The loop is terminated when a WM_QUIT
617 message is received, at which time this function exits the application
618 instance by returning the value passed by PostQuitMessage().
620 If this function must abort before entering the message loop, it
621 returns the conventional value NULL.
623 ****************************************************************************/
624 int APIENTRY
WinMain(
626 HINSTANCE hPrevInstance
,
633 if (!hPrevInstance
) { /* Other instances of app running? */
634 if (!InitApplication(hInstance
)) { /* Initialize shared things */
635 return (FALSE
); /* Exits if unable to initialize */
639 /* Perform initializations that apply to a specific instance */
641 if (!InitInstance(hInstance
, nCmdShow
)) {
648 /* Acquire and dispatch messages until a WM_QUIT message is received. */
652 (void) WaitMessage();
654 while (0 != state
&& PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
)) {
655 if (WM_QUIT
== msg
.message
) {
658 DispatchMessage(&msg
); /* Dispatches message to window */
668 SendMessage(hWnd
, WM_ERASEBKGND
, (WPARAM
) hDC
, (LPARAM
) 0);
669 draw_maze_border(hWnd
, hDC
);
670 ReleaseDC(hWnd
, hDC
);
678 start_timer(hWnd
, pre_solve_delay
);
688 if (0 != solve_delay
) {
689 start_timer(hWnd
, solve_delay
);
701 if (! solve_maze()) {
702 if (0 != solve_delay
) {
703 start_timer(hWnd
, solve_delay
);
711 start_timer(hWnd
, post_solve_delay
);
725 return (msg
.wParam
); /* Returns the value from PostQuitMessage */
729 /****************************************************************************
731 FUNCTION: InitApplication(HINSTANCE)
733 PURPOSE: Initializes window data and registers window class
737 This function is called at initialization time only if no other
738 instances of the application are running. This function performs
739 initialization tasks that can be done once for any number of running
742 In this case, we initialize a window class by filling out a data
743 structure of type WNDCLASS and calling the Windows RegisterClass()
744 function. Since all instances of this application use the same window
745 class, we only need to do this when the first instance is initialized.
748 ****************************************************************************/
750 static BOOL
InitApplication(HINSTANCE hInstance
)
754 // Fill in window class structure with parameters that describe the
757 wc
.style
= CS_HREDRAW
| CS_VREDRAW
;// Class style(s).
758 wc
.lpfnWndProc
= (WNDPROC
)WndProc
; // Window Procedure
759 wc
.cbClsExtra
= 0; // No per-class extra data.
760 wc
.cbWndExtra
= 0; // No per-window extra data.
761 wc
.hInstance
= hInstance
; // Owner of this class
762 wc
.hIcon
= LoadIcon (hInstance
, szAppName
); // Icon name from .RC
763 wc
.hCursor
= LoadCursor(NULL
, (LPCTSTR
) IDC_ARROW
);// Cursor
764 wc
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+1);// Default color
765 wc
.lpszMenuName
= NULL
; // No menu
766 wc
.lpszClassName
= szAppName
; // Name to register as
768 // Register the window class and return success/failure code.
769 return (RegisterClass(&wc
));
773 /****************************************************************************
775 FUNCTION: InitInstance(HINSTANCE, int)
777 PURPOSE: Saves instance handle and creates main window
781 This function is called at initialization time for every instance of
782 this application. This function performs initialization tasks that
783 cannot be shared by multiple instances.
785 In this case, we save the instance handle in a static variable and
786 create and display the main program window.
788 ****************************************************************************/
790 static BOOL
InitInstance(
794 /* Save the instance handle in static variable, which will be used in
795 many subsequence calls from this application to Windows. */
797 hInst
= hInstance
; /* Store instance handle in our global variable */
799 /* Create a main window for this application instance. */
802 szAppName
, /* See RegisterClass() call. */
803 szTitle
, /* Text for window title bar. */
804 WS_OVERLAPPEDWINDOW
,/* Window style. */
805 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
, /* Use default positioning */
806 NULL
, /* Overlapped windows have no parent. */
807 NULL
, /* Use the window class menu. */
808 hInstance
, /* This instance owns this window. */
809 NULL
/* We don't use any data in our WM_CREATE */
812 // If window could not be created, return "failure"
817 // Make the window visible; update its client area; and return "success"
818 ShowWindow(hWnd
, nCmdShow
); // Show the window
819 UpdateWindow(hWnd
); // Sends WM_PAINT message
821 return (TRUE
); // We succeeded...
826 OnCreate(HWND hWnd
, LPCREATESTRUCT lpCreateStruct
)
831 srand((unsigned) time(NULL
));
834 /* FIXME GetPrivateProfileInt not yet implemented in ReactOS */
835 size
= GetPrivateProfileInt("maze", "gridsize", 0, "maze.ini");
836 pre_solve_delay
= GetPrivateProfileInt("maze", "predelay", 5000,
838 post_solve_delay
= GetPrivateProfileInt("maze", "postdelay", 5000,
840 solve_delay
= GetPrivateProfileInt("maze", "solvedelay", 10,
844 pre_solve_delay
= 5000;
845 post_solve_delay
= 5000;
850 size
= 7 + (rand() % 30);
852 grid_width
= grid_height
= size
;
853 bw
= (size
> 6 ? 3 : (size
-1)/2);
855 GetClientRect(hWnd
, &rc
);
856 set_maze_sizes(rc
.right
- rc
.left
, rc
.bottom
- rc
.top
);
861 void OnTimer(HWND hwnd
, UINT id
)
866 /****************************************************************************
868 FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
870 PURPOSE: Processes messages
874 WM_DESTROY - destroy window
878 ****************************************************************************/
880 LRESULT CALLBACK
WndProc(
881 HWND hWnd
, // window handle
882 UINT message
, // type of message
883 WPARAM wParam
, // additional information
884 LPARAM lParam
) // additional information
890 OnCreate(hWnd
, (LPCREATESTRUCT
) lParam
);
893 BeginPaint(hWnd
, &ps
);
897 OnTimer(hWnd
, wParam
);
899 case WM_DESTROY
: // message: window being destroyed
903 default: // Passes it on if unproccessed
904 return (DefWindowProc(hWnd
, message
, wParam
, lParam
));