GAME ANY RESOLUTION
BY GUY DAVIS
Guy Davis lives in San Diego and is a member of the San Diego Atari Enthusiasts. He has been an Atari owner since 1981 when he bought an 800, and he has now owned an ST for about two years. An applications programmer for the last five years, Guy holds a bachelor of technology degree from the Rochester Institute of Technology.
Picture Puzzle was written to add another dimension to the artwork currently available on the Atari ST. With it, you can read in a picture file of type .NEO or .PI* and then break up that picture into rectangles of equal size. These rectangles are then shuffled up, and you are required to put the pieces in the correct order, restoring the picture to its original form. Picture Puzzle works in all three resolutions, so anyone can enjoy the program.
Listings 1 and 2 (PICPUZZL.PAS and BITBLIT.PAS) are the two source files needed to create the program. You may type in the listings and compile them with Personal Pascal, or you may find the complete program on this month's disk version or in the databases of the ST-Log users' group on DELPHI.
When the program is run, you will be greeted with a dialog box detailing the copyright information pertaining to the program. Click on the OK button. Next you will be presented with a file-selection dialog box. To exit the program, select the cancel button whenever this dialog box is active. Since we don't want to stop now, insert a picture disk, containing picture files of type .NEO or .PI* into Drive A. Select one of those files. If the file is the correct format and resolution, it will be loaded into memory. Otherwise, an alert box will be displayed describing your error. If everything went well, the picture will be displayed on the screen. At this point you may do several things.
First off, play with the arrow keys. By hitting the up-arrow key, you will be presented with a vertical line in the middle of the screen, splitting the picture up into two horizontal rectangles. Hit the up-arrow key again. Now you have three rectangles. By hitting the right-arrow key you will increase the number of vertical rectangles displayed on the screen. Hitting either the left-arrow key or the down-arrow key will decrease the number of vertical or horizontal rectangles displayed on the screen. You may have as much as 22 horizontal and/or vertical rectangles or as few as one of each (no lines at all). Anything more than 22 would make the picture hard to see and the puzzle too difficult to solve.
If the color of the lines is not to your liking, hit the F1 key. You will be presented with a dialog box displaying all the possible colors in the current color palette. The color currently being used to draw the lines will have a check mark on it. To change the color, click on the color you would like for the lines, and then click on the OK button. The lines will change immediately.
If you wish to load another pictures at this point, hit the escape key. Hitting this key at any point in the program will return you to the file-selection dialog box.
Finally, if you are satisfied with the way the picture is broken up, you may hit the return key. After you do this you will notice that the rectangles are shuffled up, thus mixing up the picture. It is now up to you to put the picture back together again.
What a mess!
You are faced with a mixed-up picture. Now what? In order to put the picture together, you must exchange rectangles. Click on any two rectangles with the left mouse button, and they will change places. Continue to do this until you have restored the picture. If you need help, you may hold down the right mouse button, which will display the original picture. Releasing the button will return you to the mixed-up picture. Again, if you wish to exit to the file-selection dialog box, hit the escape key at any time.
After completing the picture puzzle, you will be congratulated, and you may then load in another picture or exit the program.
For the programmers
The source code contains examples calls to the VDI and XBIOS. The major problem that I had to overcome was the fact that the GEM call to get an event will not support a mouse-button event if that button event occurred in the menu area. This was especially irritating because I was not using menus. Luckily a VDI call exists that allows the programmer to sample the mouse-button state without the use of the event routines. This call is No. 124 and returns the x and y mouse position along with a button status, where 0 equals no button pressed, 1 equals left button pressed, 2 equals right button pressed and 3 equals both buttons pressed.
If you wish to change the program to your own specifications and recompile it, you must first compile the source code in the file BITBLIT.PAS creating BITBLIT.O. Then enter BITBLIT.O as a file under your link options and compile and the source, PICPUZZL.PAS.
Happily ever after
That's it. I hope you enjoy the program. The program took me a little under two weeks to code and debug, with a major portion of that time spent refining the program. Personal Pascal is a fine language to program in, and I urge anyone looking for an alternative to BASIC to check it out.