Classic Computer Magazine Archive ANTIC VOL. 2, NO. 5 / AUGUST 1983


Maze Maniac

By Scott McKissock


NOTE!!--The screen will go blank for about 30 seconds before the game starts.

Page flipping is a graphics programming technique that you can use to instantly switch the screen display from one picture to another. Maze Maniac uses this technique to switch you between six different full-screen mazes, each with a different prize and its own distinctive color. The object of the game is to collect all six prizes as many times as possible within the time limit. You must clear all mazes of prizes before the rooms can be restocked with prizes.

We cannot provide you with a complete tutorial on page flipping here. However, we hope that this brief explanation and the program take-apart below will intrigue you enough to start exploring these topics on your own.

To understand page flipping, you should know about three two-byte memory locations. Each of these locations holds an address in "low-byte high-byte" form, which means that value of the second byte of the location should be multiplied by 256, then added to the value of the first byte at the location. The sum is itself an address to which the program is directed. The address of the display list is found at 560 and 561, the screen display address is found at the fifth and sixth bytes in the display list, and the address of the area of memory which BASIC uses for drawing is found at location 88 and 89 (called SAVMSC).

When you first call a graphics mode, for example GRAPHICS 20 (4 + 16), as in this program, the screen addresses in the display and in SAVMSC are the same. However, you can POKE new values into SAVMSC that will tell BASIC to execute any subsequent graphics commands in any section of RAM that you specify. Of course, areas of RAM that are used by the program or by BASIC should not be used. To flip to the new screen, simply change the fifth and sixth bytes of the display list to point to the new screen memory.

--David Duberman


1 Pass control to initialization at 700.
10 Set initial X and Y coordinates, and display room 6.
15 Print time remaining in mode 1 line at top of screen.
20 Uses ATARI's internal realtime clock at location 20 to keep time. Change sound according to time.
25 Read joystick. If new player location is not in background color then branch to 65.
30 If new player location is in background color then plot it.
35-38 If new X or Y position are about to exceed screen boundaries, adjust to put player on opposite side of screen. Determine new SCR, which is the new screen which will be flipped to. R is also adjusted to indicate new room.
39 End of main loop.
40 Print time if necessary.
45 Check for end of game.
50 If not flipping pages, SCR = -1. Branch to stick-read routine.
55 Change DL to display new screen (SCR). Set SCR to -1, no more page flipping until necessary. Change color, return.
60 Set Graphics Mode 1 to print. Set screen address to correct location. GOTO 40 to print time.
65 Branch here if new player location is not in background color. If not a prize, change X and Y and return.
70 If a prize, then pick it up. No more prizes in room. Add one to number of prizes picked up (PZ).
75 A beep for each prize that has been picked up.
80 Erase prize and see if all six have been picked up. If so, then place new prizes.
90 If not, re-enter main loop.
100 After display list. DL = sixth byte of display list. POKE DL-2, 70 changes LMS (load memory scan) byte, putting on one row of GR. 1. POKE DL + 44,65 sets the end of the display list higher to account for the line of GR. 1 at screen top.
110 SAV = high byte of screen memory address in the display list. If ST = 0 (game has just started), then POKE 89 (high byte of SAVMSC) with high byte of screen memory in display list minus two, and control is passed to screen-draw routine at 400.
120 Start in room 6 at coordinates 40,23. POKE DL,SAV -2*R displays screen 6. Then go to main loop at 10.
200 Place prizes for next level.
210 Makes next level harder--5 seconds less time.
220 POKE 106,P106-18. Lower RAMTOP by 18 pages (4608 bytes) so that message is not placed in memory where rooms are drawn.
240 Score = time left * level + number of prizes.
250 Flash message. If button pressed, re-initialize and start again.
300 Place new prizes. POKE 106,P106 to make sure it has the correct number of pages. POKE 87,4 to plot in mode 4. It starts with room 1.
310 Change sound's pitch depending on which room you're in.
320-330 Find random spot for prize in room. Make sure there is no wall there already.
350 PLOT prize. If all rooms not done, go back and PLOT another prize.
360 All rooms done--turn offsound and RETURN from subroutine.
400 Memory location 87 (DINDEX) contains the current BASIC graphics mode. With a modified display list containing different graphics modes, you POKE this location with the correct BASIC mode number to write to the area of the screen containing that mode. Therefore, POKE DINDEX with 1 to print in the mode 1 line at screen top, then POKE a 4 to draw in the GRAPHICS 4 area. 3 is the first Y value at which a line is drawn.
410 X is where a point is PLOTted, XD is the point to which it is drawn. If X = 0 then end of line, GOTO 440 to add to Y and start to draw the next line.
410-440 Draw all horizontal lines.
450-490 Draw all vertical lines.
495 If rooms are finished being drawn, display room 6, GOSUB 300 to place prizes, and start game.
499 If not, draw next room. Change memory locations 106 and 89 so it draws them in the right place in memory and return to line 400 to start drawing again.
500 Data for screens.
700 Turn off screen, set time. P106 = number of pages of free RAM.
710 Clear 16 pages of memory for screens.
720 Dimensions for variables for up-U(R), down-D(R), left L(R), and right R(R), and the coordinates of the prize-Q(R), B(R). R stands for room number (1-6).
730-750 Gives values for up, down, left, and, right. For instance, if you are in room 1 and you go up, you go to room 4.
760 Set number of pages back to original value. GOTO 100.

Scott McKissock is a sophomore at Camp LeJeune High School in North Carolina. His maze game is devilishly hard, requiring the player to discover and remember the relationship of the various mazes to each other.

MZMANIAC.BAS ERROR: file not found

What Is a Typo Table?

Newcomers to ANTIC may wonder about the "Typo Table" that appears at the end of most of our basic listings. TYPO is a program that helps you find typing errors made when entering programs that appear in ANTIC. TYPO will produce a table of values which can be used to pinpoint where an error was made. The TYPO program and instructions originally appeared in Volume 1, Number 3 of ANTIC, and was reprinted in Volume 2, Number 1. The latter issue is still available as a back issue, and the TYPO program itself is included in ANTIC UTILITIES DISK #2. Also, you can obtain a copy of the article by sending a stamped, self-addressed envelope to: c/o ANTIC, 600 18th Street, San Francisco, CA 94107. We regret we cannot fulfill requests unless SASE is included.

NOTE: When comparing your TYPO TABLE with the one we publish, first look at the length column. For a given line number range, if your length is only off by one or two, it may be due to spacing. Missing or extra spaces generally occur between quotes or in a REM statement. Spaces must be accurately placed for TYPO to work, so first experiment with the spacing.