M.A.C.E. Journal / VOL. 5 NO.6 / JUNE 1985 / PAGE 39
Maze games have been around for a while. So when you see another maze game, you don’t think much of it. Well, I’m going to try to change that.
When Amazed is run, a maze in graphics 7 will be drawn. You are then ‘shrunk’ to fit inside the maze. At this reduced size, everything is much bigger, EVEN THE MAZE WALLS. The maze has been divided into 16 Graphics 3 screens. That’s rights you can only see one sixteenth of the maze at a time!
Using joystick number 1, move yourself (the green dot) around the maze, trying to find the exit (a blue dot). You start at the upper left hand corner and must get to the lower right hand corner. The screen scrolls independently of you. This may seem an annoyance, because you may hit a wall but the screen will continue scrolling, but I did this so you can see how far you are from the exit at any time. Just move all the way to the lower right hand corner and you will see the blue dot. Just remember where you were when you started scrolling the screen around.
I am an 18 year old senior at Warren Woods Tower High school. I’ve known assembly language for a couple of years now and enjoy the increase in speed from BASIC. This program took about 3 weeks to do. The hardest part was the fine scrolling routines. If anybody has any questions about this program, leave a message to ‘Remington Steele’, at the Trading Post BBS (882-5909) or the MACE EAST BBS (978-1685).
Enjoy the mazes and have fun!!
[The following listing is the source code for the machine language program. The assembled version of Amazed will be available from the MACE disk library and on the MACE BBSs. -Ed.]
0100 WSYNC=54282 ;wait for horiz. sync. 0110 COLPF0=53270 ;color 0 0120 DLIST=560 ;display list pointer 0130 DISP=$5000 ;screen display RAM 0140 RANDOM=53770 ;random # 0150 SETVBI=$E45C ;set VBI vector 0160 RETURN=$E462 ;ret. from vbi 0170 HSCROLL=54276 ;horiz. scroll 0180 VSCROLL=54277 ;vert. scroll 0190 STICK=632 ;stick 0 0200 TIMER=540 ;countdown timer 0210 XPNT=$8000 ;x,y coordinate 0220 YPNT=$9000 ;save RAM 0230 *=$B0 0240 X *=*+1 ;misc. 0250 Y *=*+1 ;variables 0260 XP *=*+1 0279 YP *=*+1 0280 LO *=*+1 ;a lo and hi pntr. 0290 HI *=*+1 0300 DIR *=*+1 ;direction of movement 0310 LOHOLD *=*+1 ;temporary hold 0320 HIHOLD *=*+1 ;registers 0330 XPOINT *=*+2 0340 YPOINT *=*+2 0350 Z1 *=*+1 ;used for the LOCATE 0360 Z2 *=*+1 ;of the four points which 0370 Z3 *=*+1 ;surround the current 0380 Z4 *=*+1 ;x,y point 0390 HS *=*+1 ;horiz. scroll value 0400 VS *=*+1 ;vert. scroll value 0410 HD *=*+1 0420 VD *=*+1 0430 OX *=*+1 0440 OY *=*+1 0450 *=$600 0460 ; 0470 ; masks for plotting 0480 ; 0490 COLOR0 0500 .BYTE $3F,$CF,$F3,$FC 0510 COLOR1 0520 .BYTE $40,$10,$04,$01 0530 COLOR2 0540 .BYTE $80,$20,$08,$02 0550 COLOR3 0560 .BYTE $C0,$30,$0C,$03 0561 ; 0562 ; mask bits for locate 0563 ; 0570 TEST 0580 .BYTE $C0,$30,$0C,$03 0581 ; 0582 ; GR.7 display list 0583 ; 0590 LIST 0600 .BYTE 112,112,112,77 0610 .WORD DISP 0620 .BYTE 13,13,13,13,13,13,13,13 0630 .BYTE 13,13,13,13,13,13,13,13 0640 .BYTE 13,13,13,13,13,13,13,13 0650 .BYTE 13,13,13,13,13,13,13,13 0660 .BYTE 13,13,13,13,13,13,13,13 0670 .BYTE 13,13,13,13,13,13,13,13 0680 .BYTE 13,13,13,13,13,13,13,13 0699 .BYTE 13,13,13,13,13,13,13,13 0700 .BYTE 13,13,13,13,13,13,13,13 0710 .BYTE 13,13,13,13,13,13,13,13 0720 .BYTE 13,13,13,13,13,13,13,13 0730 .BYTE 13,13,13,13,13,13,13,65 0740 .WORD LIST 0750 GR3LIST 0760 .BYTE 112,112,112 0770 .BYTE 120,0,0,120,0,0,120,0,0 0780 .BYTE 120,0,0,120,0,0,120,0,0 0790 .BYTE 120,0,0,120,0,0,120,0,0 0800 .BYTE 120,0,0,120,0,0,120,0,0 0810 .BYTE 120,0,0,120,0,0,120,0,0 0820 .BYTE 120,0,0,120,0,0,120,0,0 0830 .BYTE 120,0,0,120,0,0,120,0,0 0840 .BYTE 120,0,0,120,0,0,120,0,0 0850 .BYTE 65 0860 .WORD GR3LIST 0861 ; 0862 ; x,y increments for joystick 0863 ; movement 0864 ; 0870 XI 0880 .BYTE 0,0,0,0,0,0,0,1,0,0 0890 .BYTE 0,255,0,0,0,0 0900 YI 0910 .BYTE 0,0,0,0,0,0,0,0,0,0,0 0920 .BYTE 0,0,1,255,0 0930 *=$6000 0940 JMP START 0941 ; 0942 ; area for saving the addr of each 0943 ; line of the gr.7 display 0944 ; 0950 LMSLO *=*+95 0960 LMSHI *=*+95 0961 ; 0962 ; plot calculator: 0963 ; multiply YP times 40 then get the 0964 ; addr of the screen RAM to be 0965 ; modified. 0966 ; 0970 PLOTCL 0980 LDA YP 0990 ASL A 1000 STA LO 1010 LDA #0 1020 STA HI ;*2 1030 ASL LO 1040 ROL HI ;*4 1050 ASL LO 1060 ROL HI ;*8 1070 LDA LO 1080 STA LOHOLD 1090 LDA HI 1100 STA HIHOLD 1110 ASL LO 1120 ROL HI ;*16 1130 ASL LO 1140 ROL HI ;*32 1150 LDA LO 1160 CLC 1170 ADC LOHOLD 1180 STA LO 1190 LDA HI 1200 ADC HIHOLD 1210 STA HI ;*32+*8=*40 1220 LDA LO ;add offset for 1230 CLC ;the screen RAH 1240 ADC #DISP&255 1250 STA LO 1260 LDA HI 1270 ADC #DISP/256 1280 STA HI 1290 LDA XP ;mask x-pos. 1300 AND #3 1310 TAX 1320 LDA XP 1330 LSR A 1340 LSR A 1350 CLC 1360 ADC LO 1370 STA LO 1380 LDA HI 1390 ADC #0 1400 STA HI 1410 RTS ;all done! 1420 PLOT0 1430 LDA X ;save x,y pos. 1440 STA XP 1450 LDA Y 1460 STA YP 1470 P0 1480 JSR PLOTCL 1490 LDA COLOR0,X ;plot a point in 1500 LDY #0 ;color 0 1510 AND (LO),Y 1520 STA (LO),Y 1530 RTS ;all done! 1540 XYUPDATE 1550 LDY #0 ;update the x,y 1560 LDA X ;pointers in RAM 1570 STA (XPOINT),Y 1580 LDA Y 1590 STA (YPOINT),Y 1600 LDA XPOINT 1610 CLC 1620 ADC #1 1630 STA XPOINT 1640 LDA XPOINT+1 1650 ADC #0 1660 STA XPOINT+1 1670 LDA YPOINT 1680 CLC 1690 ADC #1 1700 STA YPOINT 1710 LDA YPOINT+1 1720 ADC #0 1730 STA YPOINT+1 1740 RTS 1750 NEWXY 1760 LDA XPOINT ;get a new x,y 1770 SEC ;position after 1780 SBC #1 ;it has been determined 1790 STA XPOINT ;that the current 1800 LDA XPOINT+1 ;x,y point has no where 1810 SBC #0 ;to go, but in reverse! 1820 STA XPOINT+1 1830 LDA YPOINT 1840 SEC 1850 SBC #1 1860 STA YPOINT 1870 LDA YPOINT+1 1880 SBC #0 1890 STA YPOINT+1 1900 LDY #0 1910 LDA (XPOINT),Y 1920 STA X 1930 LDA (YPOINT),Y 1940 STA Y 1950 LDA X ;is x=2 1960 CMP #2 1970 BNE NOTDONE 1980 LDA Y ;and y=2 1990 CMP #2 2000 BNE NOTDONE 2010 PLA ;then we are all 2020 PLA ;done drawing!! 2030 JMP LOADLMS 2040 NOTDONE 2050 RTS ;do some more mazing ! 2060 LOCATE 2070 LDY #0 2080 LDA TEST,X ;get the test bit 2090 AND (LO),Y ;mask it with current x,y pos. 2100 CMP COLOR1,X ;is it color 1 2110 BNE COL0 2120 LDA #1 ;yes! 2130 RTS 2140 COL0 2150 LDA #0 ;it must be color 0 2160 RTS 2170 START 2180 LDA #0 ;set horiz. and vert. 2190 STA VS ;scroll regs. to 0 2200 STA HD 2210 STA VD 2220 LDA #15 2230 STA HS 2240 LDA #XPNT&255 ;set the x,y 2250 STA XPOINT ;table pointers 2260 LDA #XPNT/256 2270 STA XPOINT+1 2280 LDA #YPNT&255 2290 STA YPOINT 2300 LDA #YPNT/256 2310 STA YPOINT+1 2320 LDA #LIST&255 ;point to. display 2330 STA DLIST ;list 2340 LDA #LIST/256 2350 STA DLIST+1 2360 CLEARSCRN 2370 LDA #0 ;start at x=0 2380 STA XP 2390 LDA #95 ;and y=95 2400 STA YP 2410 CLEAR 2420 JSR PLOTCL ;get addr. of line 2430 LDA #0 ;and clear out 2440 LDY #39 ;all 40 bytes in 2450 CLR ;it 2460 STA (LO),Y 2470 DEY ;loop.. 2480 BPL CLR 2490 DEC YP 2500 LDA YP 2510 CMP #$FF 2520 BNE CLEAR ;until done 2530 LDA #1 2540 STA YP 2550 LDA #0 2560 STA XP 2570 FIELD 2580 JSR PLOTCL ;draw out the 2590 LDA #21 ;field on which 2600 LDY #0 ;the maze will be 2610 STA (LO),Y ;drawn 2620 LDA #80 2630 LDY #39 2640 STA (LO),Y 2650 LDY #1 2660 LDA #85 2670 DRAW 2680 STA (LO),Y 2690 INY 2700 CPY #39 2710 BNE DRAW 2720 INC YP 2730 LDA yp 2740 CMP #94 2750 BNE FIELD 2760 MAZE 2770 LDA #2 ;start at 2,2 2780 STA X 2790 STA Y 2800 MOVE 2810 JSR XYUPDATE ;and save those points 2820 GETZ 2830 JSR PLOT0 ;plot, color 0 2840 LDX Y ;now locate 2850 DEX ;the four points 2860 DEX ;around x,y 2870 STX YP 2880 LDA X 2890 STA XP 2900 JSR PLOTCL ;this is the locate for... 2910 JSR LOCATE ;x,y-2 2920 STA Z1 2930 LDA Y 2940 STA YP 2950 LDX X 2960 INX 2970 INX 2980 STX XP 2990 JSR PLOTCL 3000 JSR LOCATE 3010 STA Z2 ;x+2,y 3020 LDA X 3030 STA XP 3040 LDX Y 3050 INX 3060 INX 3070 STX YP 3080 JSR PLOTCL 3090 JSR LOCATE 3100 STA Z3 ;x,y+2 3110 LDA Y 3120 STA YP 3130 LDX X 3140 DEX 3150 DEX 3160 STX XP 3170 JSR PLOTCL 3180 JSR LOCATE 3190 STA Z4 ;x-2,y 3200 LDA #0 ;add them all up 3210 CLC 3220 ADC Z1 3230 ADC Z2 3240 ADC Z3 3250 ADC Z4 3260 BNE GETDIR ;if its not zero then maze!! 3270 JSR NEWXY ;else, get a new x,y 3280 JMP GETZ ;and start checking again 3290 GETDIR 3300 LDA RANDOM ;get a rand. 3310 CMP #4 ;direction 3320 BCS GETDIR 3330 STA DIR ;and save it. 3340 LDA DIR 3350 BNE NOT0 ;if dir=0 3360 LDA Z1 ;decrement y by 3370 BEQ GETDIR ;2 and plot each 3330 DEC Y ;point in color 0 3390 JSR PLOT0 3400 DEC Y 3410 JMP MOVE 3420 NOT0 3430 CMP #1 ;if dir=1 3440 BNE NOT1 3450 LDA Z2 ;and point.. if 0 3460 BEQ GETDIR 3470 INC X ;increment x by 3480 JSR PLOT0 ;2 3490 INC X 3500 JMP MOVE 3510 NOT1 3520 CMP #2 ;if dir=2 3530 BNE NOT2 3540 LDA Z3 ;and point is 0 3550 BEQ GETDIR 3560 INC Y ;inc. y by 2 3570 JSR PLOT0 3580 INC Y 3590 JMP MOVE 3600 NOT2 3610 CMP #3 ;if dir=3 3620 BNE OOPS 3630 LDA Z4 ;and point it 0 3640 BEQ GETDIR 3650 DEC X ;dec. X by 2 3660 JSR PLOT0 3670 DEC X 3680 JMP MOVE 3690 OOPS 3700 LDA #15 ;this will never 3710 STA 708 ;happen! 3720 BRK 3730 LOADLMS 3740 LDA #0 ;xp=0 and yp=1 3750 STA XP 3760 LDA #1 3770 STA YP 3780 LMS 3790 JSR PLOTCL ;find addr of RAM 3800 LDY YP 3810 DEY 3820 LDA LO ;and save it 3830 STA LMSLO,Y 3840 LDA HI 3850 STA LMSHI,Y 3860 INC YP ;get next line 3870 INY 3880 CPY #95 ;do all 95 3890 BNE LMS 3900 LDX #4 3910 LDY #0 3920 GETLMS 3930 LDA LMSLO,Y ;put the current 3940 STA GR3LIST,X ;pos. in the gr.3 3950 LDA LMSHI,Y ;display list. 3960 STA GR3LIST+1,X 3970 INY 3980 INX 3990 INX 4000 INX 4010 CPX #76 4020 BNE GETLMS 4030 LDA #GR3LIST&255;point to gr.3 4040 STA DLIST ;display 4050 LDA #GR3LIST/256 4060 STA DLIST+1 4070 LDA #7 ;set the vert. 4080 LDX #VBI/256 ;blank. 4090 LDY #VBI&255 4100 JSR SETVBI 4110 LDA #156 ;put a color 3 4120 STA XP ;dot at the end 4130 LDA #92 ;of the maze. 4140 STA YP 4150 JSR PLOTCL ;it'll be there 4160 LDY #0 ;if you ever get 4170 LDA COLOR3,X ;there! 4180 ORA (LO),Y ;ha!ha!ha! 4190 STA (LO),Y 4200 LDA #2 ;start your journey 4210 STA X ;at 2.2 4220 STA Y 4230 PLXY 4240 LDA X ; save x and y 4250 STA XP 4260 STA OX 4270 LDA Y 4280 STA YP 4290 STA OY 4300 JSR PLOTCL 4310 LDY #0 4320 LDA (LO),Y 4330 AND TEST,X ;check if we hit 4340 CMP COLOR3,X ;color 3 4350 BNE NOTCOL3 ;nope. keep trying! 4360 JMP WIN ;FINALLY!! 4370 NOTCOL3 4380 LDA (LO),Y ;plot x,y 4390 ORA COLOR2,X ;in color 2 4400 STA (LO),Y 4410 LDA #2 ;a short delay 4420 STA TIMER 4430 WAIT 4440 LDA TIMER 4450 BNE WAIT 4460 LDX STICK ;get stick dir. 4470 LDA XP 4480 CLC ;and add it to 4490 ADC XI,X 4500 STA XP ;the x and y 4510 LDA YP ;pos.'s 4520 CLC 4530 ADC YI,X 4540 STA YP 4550 JSR PLOTCL ;get addr. 4560 JSR LOCATE ;check if 0 4570 BEQ XYOK ;its ok to move there! 4580 JMP PLOTDONE ;no movement. 4590 XYOK 4600 LDA XP ;now actually move 4610 STA X ;x and y points 4620 LDA YP 4630 STA Y 4640 LDA OX 4650 STA XP 4660 LDA OY 4670 STA YP 4680 JSR P0 ;erase old spot 4690 PLOTDONE 4700 JMP PLXY ;keep looping. 4710 LOOP 4720 JMP LOOP 4730 VBI 4740 LDA STICK ;moving right? 4750 CMP #7 4760 BNE CHK11 ;nope, check left 4770 LDA HS ;if HS isnt 0, 4780 BEQ HS0 4790 DEC HS ;we can dec. it 4800 JMP DONE 4810 HS0 4820 LDA HD ;otherwise, if were 4830 CMP #29 ;not at the bottom 4840 BNE GO7 ;of the screen 4850 JMP DONE 4860 GO7 4870 INC HD 4880 LDA #15 ;reset the scroll 4890 STA HS ;pointers and 4900 LDY #4 4910 ADD1 4920 LDA GR3LIST,Y ;get the new memory 4930 CLC ;address's for the 4940 ADC #1 ;gr.3 displat list 4950 STA GR3LIST,Y 4960 LDA GR3LIST+1,Y;move over 1 byte 4970 ADC #0 4980 STA GR3LIST+1,Y 4990 INY 5000 INY 5010 INY 5020 CPY #76 ;loop until done 5030 BNE ADD1 5040 JMP DONE 5050 CHK11 5060 CMP #11 ;moving left? 5070 BNE CHK13 ;no, try down 5080 LDA HS ;can we move 5090 CMP #15 ;anymore?? 5100 BEQ HS15 5110 INC HS ;YEP! 5120 JMP DONE 5130 HS15 5140 LDA HD ;check for 5150 BNE GO11 ;left edge of screen 5160 JMP DONE 5170 GO11 5180 DEC HD ;reset the scroll 5190 LDA #0 ;registers 5200 STA HS 5210 LDY #4 5220 SUB1 5230 LDA GR3LIST,Y ;and change the 5240 SEC ;display 5250 SBC #1 5260 STA GR3LIST,Y ;move back 1 byte 5270 LDA GR3LIST+1,Y 5280 SBC #0 5290 STA GR3LIST+1,Y 5300 INY 5310 INY 5320 INY 5330 CPY #76 5340 BNE SUB1 5350 JMP DONE 5360 CHK13 5370 CMP #13 ;moving down?? 5380 BNE CHK 14 ;no, check up 5390 LDA vs 5400 CMP #7 ;can we move down 5410 BEQ VS7 5420 INC VS ;sure can!! 5430 JMP DONE 5440 VS7 5450 LDA VD ;check for bottom 5460 CMP #70 ;of screen. 5470 BNE GO13 5480 JMP DONE 5490 GO13 5500 INC VD ;reset the scroll 5510 LDA #0 ;registers 5520 STA VS 5530 LDY #4 5540 ADD40 5550 LDA GR3LIST,Y ;and orange 5560 CLC ;display list 5570 ADC #40 5580 STA GR3LIST,Y ;move down 40 bytes, 5590 LDA GR3LIST+1,Y;or 1 gr.7 line 5600 ADC #0 5610 STA GR3LIST+1,Y 5620 INY 5630 INY 5640 INY 5650 CPY #76 5660 BNE ADD40 5670 JMP DONE 5680 CHK14 5690 CMP #14 ;moving up?? 5700 BNE DONE ;nopey all done. 5710 LDA VS 5720 BEQ VS0 ;can we move up? 5730 DEC VS ;yep. 5740 JMP DONE 5750 VS0 5760 LDA VD ;are we at the to P? 5770 BEQ DONE ;yes, dont move. 5780 DEC VD 5790 LDA #7 ;reset the scroll 5800 STA VS ;registers 5810 LDY #4 5820 SUB40 5830 LDA GR3LIST,Y ;and change the 5840 SEC ;display list 5850 SBC #40 5860 STA GR3LIST,Y ;move up 40 bytes 5870 LDA GR3LIST+1,Y;or 1 gr.7 line 5880 SBC #0 5890 STA GR3LIST+1,Y 5900 INY 5910 INY 5920 INY 5930 CPY #76 5940 BNE SUB40 5950 DONE 5960 LDA HS ;update the scroll 5970 STA HSCROLL ;registers 5980 LDA VS 5990 STA VSCROLL 6000 JMP RETURN ;and finis! 6010 WIN 6020 INX ;YEAH!! get a new color 6030 STX WSYNC ;wait for sync. 6040 STX COLPF0 ;and display it. 6050 JMP WIN 7000 *=$02E0 ;autorun 7010 .WORD START 7020 .END