Dale’s Atari 800 Games › Stan Ockers
Maze Maker
By Stan Ockers, in the ACE newsletter of September 1984.
Play Maze MakerStan’s write-up
I had quite a few problems with this program including one I was never able to solve. If anyone can figure out what is wrong, I'd appreciate knowing about it. First, about the program ....
The program generates mazes having only one path through the maze. Any size up to 25X30 can be generated. Once generated the maze can be printed out on a printer, or viewed on the screen. The screen maze can be traversed using a cursor controlled by joystick #1. A third option is to have the maze put on the screen with invisible walls. This makes it quite a bit more difficult to traverse.
Now for the problem. Originally I had the menu return after the maze was run in order to select another option. If the generate new maze option was selected though, the program puts random characters on the screen while generating the maze and locks up. It seems to happen only after I do a runmaze.
In some cases I was able to get the second maze to appear but it displays all messed up with most of the rooms being completely closed off. It was as if calling Graphics 7 in the runmaze portion had made the program completely forget where the array ‘maze’ was. The only solution I could come up with was to make runmaze lock up in an infinite loop at the end so you have to push RESET to generate a new maze.
—Stan Ockers

The bug Stan couldn't find
Stan asked readers to tell him what was wrong. Forty-two years late, here is an answer. Runmaze slows the cursor down with two delay loops written FOR dely=1 TO 3000 DO OD. But dely is also the name of the program's INT ARRAY of up-and-down steps, and in Action! an array's name is the address of its first element. Each delay loop therefore left dely pointing at memory location 3001. The next time Genmaze moved up or down a row, it took the step from whatever happened to be there, wandered off the maze, and wrote all over memory. That is the random characters, the lock-up and the closed-off rooms Stan saw. Graphics 7 had nothing to do with it. Giving the delay loops their own counter would have let him put back his OPTION-to-menu line.
The game page runs the program as Stan printed it, endless loop and all. Press the 800's SYSTEM RESET key to make a new maze.
The program
The listing, “MAZE MAKER by Stan Ockers”, is on pages 8, 9 of the issue. Stan wrote it in Action!, the compiled language from Optimized Systems Software, and readers needed the Action! cartridge to type it in and compile it. There is no Action! compiler here, so the game page runs a hand translation of the listing into JavaScript: one function for each of Stan’s procedures, with his variable names, sizes and memory addresses, driving the same emulated Atari 800 (its screen, player-missile graphics, collisions and sound) that runs the BASIC games.
Where this copy came from: Written in Action!. The listing was transcribed by hand from the scan (pages 8-9; there is no typed-in or compiled copy). The game page runs a hand translation of the listing into JavaScript. Option 3 sends the maze to “the printer”: it appears on a sheet over the page, with a button to print it for real.
Show the listing
; MAZE MAKER
; Stan Ockers 8-84
; ACE Newsletter, 3662 Vine Maple Dr.
; Eugene, OR 97405 Sept 84 $12 year
;
; See Creative Computing Dec. '83 p294
; 'Polymaze Solver' by Dan Rollins
;
MODULE
INT
hsiz,vsiz,x,y,j,k,q,d,dir,nd
CARD
room,rmcnt,totrm
BYTE ARRAY
t(6),maze(1000),prev(1000),pwr2=[1 2
4 8]
INT ARRAY
dely(4),delx(4)
BYTE consol=53279,key=764
PROC Init()
FOR j=0 TO 3 DO dely(j)=0 delx(j)=0
OD dely(0)=-1 dely(2)=1 delx(1)=1
delx(3)=-1
RETURN
PROC Menu()
BYTE POINTER bptr
CARD dlst
Graphics(2) Poke(710,0) dlst=Peek(560)
dlst==+256*Peek(561) Poke(752,1)
FOR j=8 to 12 STEP 2 DO bptr=dlst+j
bptr^=6 OD
Position(6,0) PrintDE(6,"{inv}Maze{/inv} {inv}Maker{/inv}")
PrintDE(6)
PrintDE(6," 1-create new maze")
PrintDE(6)
PrintDE(6," 2-maze to screen")
PrintDE(6)
PrintDE(6," 3-maze to printer")
PrintDE(6)
PrintDE(6," 4-invisible maze")
PrintDE(6)
PrintD(6,"option-BACK TO MENU")
Poke(657,5)
Print("Written in ACTION! (c) 1983 ACS")
RETURN
PROC Cknxt()
IF y>0 THEN IF maze(room-hsiz-1)=0 THEN
q=q+1:t(q)=0 FI FI
IF x<hsiz THEN IF maze(room+1)=0 THEN
q=q+1:t(q)=1 FI FI
IF y<vsiz THEN IF maze(room+hsiz+1)=0
THEN q=q+1:t(q)=2 FI FI
IF x>0 THEN IF maze(room-1)=0 THEN
q=q+1:t(q)=3 FI FI
RETURN
PROC Genmaze()
Open(2,"K:",4,0)
Graphics(18) Position(1,3)
PrintDE(6," MAXIMUM size")
PrintDE(6," for screen display")
PrintDE(6," is 25 X 30") PrintDE(6,"")
PrintD(6,"{inv}HORIZONTAL{/inv} {inv}SIZE{/inv} ")
hsiz=InputBD(2) PrintBDE(6,hsiz)
PrintD(6,"{inv}VERTICAL{/inv} {inv}SIZE{/inv} ")
vsiz=InputBD(2) PrintBD(6,vsiz)
hsiz==-1 vsiz==-1
FOR room=0 TO 999 DO maze(room)=0 OD
x=Rand(hsiz) y=Rand(vsiz) rmcnt=0
totrm=(hsiz+1)*(vsiz+1)-1
WHILE rmcnt<totrm DO
q=0 room=y*(hsiz+1)+x Cknxt()
IF q=0 THEN DO DO
y=y+1:IF y>vsiz THEN y=0
x=x+1:IF x>hsiz THEN x=0 FI FI
room=y*(hsiz+1)+x
UNTIL maze(room)>0 OD q=0 Cknxt()
UNTIL q>0 OD FI
d=Rand(q)+1 dir=t(d)
maze(room)==+pwr2(dir)
y=y+dely(dir) x=x+delx(dir)
room=y*(hsiz+1)+x
nd=dir-2 IF nd<0 THEN nd==+4 FI
maze(room)==+pwr2(nd) rmcnt==+1
OD
maze(0)==%1
RETURN
PROC Prtmaze()
Open(1,"P:",8,0)
FOR y=0 TO vsiz DO
FOR x=0 TO hsiz DO room=y*(hsiz+1)+x
IF (maze(room)&1)=1 THEN PrintD(1,"+ ")
ELSE PrintD(1,"+--") FI OD PrintDE(1,"+")
FOR x=0 TO hsiz DO room=y*(hsiz+1)+x
IF maze(room)>7 THEN PrintD(1," ")
ELSE PrintD(1,"I ") FI OD PrintDE(1,"I")
OD
FOR x=0 TO hsiz-1 DO PrintD(1,"+--") OD
PrintDE(1,"+ +")
RETURN
PROC Ding(BYTE pitch)
CARD wait
BYTE loud
FOR loud=0 TO 15
DO Sound(0,pitch,10,15-loud)
FOR wait=1 TO 600 DO OD OD SndRst()
RETURN
PROC Ras()
CARD wait
Sound(0,100,12,10)
FOR wait=1 TO 3000 DO OD SndRst()
RETURN
PROC Square(BYTE colr)
color=colr Plot(j,k) DrawTo(j+3,k)
Plot(j,k+1) DrawTo(j+3,k+1)
RETURN
PROC Plotmaze()
Graphics(23) For y=0 TO vsiz DO
FOR x=0 TO hsiz DO room=y*(hsiz+1)+x
j=6*x+4 k=3*y+4
IF (maze(room)&1)=0 THEN color=1
Plot(j,k) DrawTo(j+7,k) FI
IF maze(room)<8 THEN color=1
Plot(j,k) DrawTo(j,k+3)
Plot(j+1,k) DrawTo(j+1,k+3) FI OD
j=6*x+4 color=1 plot(j,k) DrawTo(j,k+3)
Plot(j+1,k) DrawTo(j+1,k+3) OD
k=3*y+4 Plot(4,k) DrawTo(j-5,k)
RETURN
PROC Runmaze()
color=2 Plot(6,4) DrawTo(9,4)
x=0 y=0 j=6 k=5
FOR room=0 TO 999 DO prev(room)=0 OD
maze(0)==&14 room=0
DO
q=maze(room) d=Stick(0) prev(room)=1
Square(2)
IF d=14 THEN IF (q&1)=1 THEN Ding(50)
IF prev(room-hsiz-1)=1 THEN Square(3)
prev(room)=0 FI plot(j,k-1)
DrawTo(j+3,k-1) y==-1 ELSE Ras() FI FI
IF d=7 THEN IF (q&2)=2 THEN Ding(60)
IF prev(room+1)=1 THEN Square(3)
prev(room)=0 FI plot(j+4,k)
DrawTo(j+5,k) plot(j+4,k+1)
DrawTo(j+5,k+1) x==+1 ELSE RAS() FI FI
IF d=13 THEN IF (q&4)=4 THEN Ding(70)
IF prev(room+hsiz+1)=1 THEN Square(3)
prev(room)=0 FI plot(j,k+2)
Drawto(j+3,k+2) y==+1 ELSE RAS() FI FI
IF d=11 THEN IF (q&8)=8 THEN Ding(80)
IF prev(room-1)=1 THEN Square(3)
prev(room)=0 FI plot(j-2,k)
DrawTo(j-1,k) plot(j-2,k+1)
DrawTo(j-1,k+1) x==-1 ELSE Ras() FI FI
j=6*x+6 k=3*y+5 room=y*(hsiz+1)+x
FOR dely=1 TO 3000 DO OD Square(0)
FOR dely=1 TO 3000 DO OD
; originally I had the following line:
; IF consol=3 THEN maze(0)==%1 EXIT FI
UNTIL room=(hsiz+1)*(vsiz+1)-1
OD maze(0)==%1
; An endless loop to prevent going
; back to menu - must RESET to play
; again - see text for reason
Square(2) DO FOR j=0 TO 15 DO
Poke(709,47+j) FOR k=1 to 1000 DO OD
OD OD
RETURN
PROC Main()
Init() Menu() DO
IF key=31 THEN key=255 Genmaze()
Poke(656,2) Poke(657,9) PrintB(hsiz+1)
Print(" by ") PrintB(vsiz+1)
Print(" maze ready") FI
IF key=30 THEN key=255 Plotmaze()
Runmaze() Menu() FI
IF key=26 THEN key=255 Prtmaze()
Menu() FI
IF key=24 THEN key=255 Graphics(23)
color=1 Plot(10,4) j=6*(hsiz+1)+4
k=3*(vsiz+1)+4 DrawTo(j,4)
DrawTo(j,k) Plot(j+1,4)
DrawTo(j+1,k) Plot(5,4) DrawTo(5,k)
DrawTo(j-5,k) Plot(4,4) DrawTo(4,k)
Runmaze() Menu() FI
OD
RETURN