Compucolor.org – Virtual Media

Listing of file='MAZI.BAS;01' on disk='vmedia/mazes_2-sector.ccvf'

1 REM  'MAZE' GBG 7802.17
5 GOTO 5100
10 CLEAR 100
11 PLOT 27,24
15 PLOT 6,39,14,12,3,27,17:PRINT "M A Z E":PLOT 3,65,30
20 DIM  D(4)
30 D(1)= 128:D(2)= 2:D(3)= - 2:D(4)= - 128
32 DIM W(31,15),V(31,15)
34 DEF  FN R(X)= INT (RND (1)* X+ 1)
40 REM  GENERA COLOR DE PAREDES CP Y COLOR DE RUTA CR
50 CP= FN R(7)
51 CR= FN R(7):IF CR= CPTHEN 51
52 CP$= CHR$ (30)+ CHR$ (CP+ 16)+ CHR$ (29)+ CHR$ (CP+ 16)
53 CN$= CHR$ (30)+ CHR$ (16)+ CHR$ (29)+ CHR$ (16)
54 A$= CP$+ "**":B$= CP$+ "*"+ CN$+ "B":C$= CP$+ "*"
55 D$= CN$+ "B"+ CP$+ "*"
110 PLOT 15,6,7,12,3,0,31
120 PLOT 7:INPUT "SIZE OF MAZE: WIDTH,HEIGTH ? ";H,V
122 PLOT 3,65,30
125 IF H> 31OR V> 15THEN H= 31:V= 15
130 IF H> 1AND V> 1THEN 150
140 PRINT "INCORRECT SIZE SPECIFICATION, TRY AGAIN."
145 GOTO 120
150 HV= H* V+ 1
152 OH= INT ((63- 2* H)/ 2):OV= INT ((31- 2* V)/ 2)
153 VV= OV
155 PLOT 27:PLOT 24:PLOT 6:PLOT 7:PLOT 12:PLOT 15
156 PLOT 3,0,31:PRINT "PLEASE WAIT, I AM BUILDING A MAZE."
157 PLOT 3,65,30
160 Q= 0:Z= 0:X= FN R(H):XX= X:GOTO 191
163 PLOT 3:PLOT OH:PLOT VV:FOR I= 1TO H:IF I= XXTHEN 173
171 PRINT A$;:GOTO 180
173 PRINT B$;
180 NEXT
190 PRINT C$:RETURN
191 C= 1:W(X,1)= C:C= C+ 1:R= X:S= 1
202 GOTO 260
210 IF R< > HTHEN 240
211 IF S< > VTHEN 230
220 R= 1:S= 1:GOTO 250
230 R= 1:S= S+ 1:GOTO 250
240 R= R+ 1
250 IF W(R,S)= 0THEN 210
260 IF R- 1= 0THEN 530
261 IF W(R- 1,S)< > 0THEN 530
270 IF S- 1= 0THEN 390
280 IF W(R,S- 1)< > 0THEN 390
290 IF R= HTHEN 330
300 IF W(R+ 1,S)< > 0THEN 330
310 X= FN R(3):ON XGOTO 790,820,860
330 IF S< > VTHEN 340
331 IF Z= 1THEN 370
332 Q= 1:GOTO 350
340 IF W(R,S+ 1)< > 0THEN 370
350 X= FN R(3):ON XGOTO 790,820,910
370 X= FN R(2):ON XGOTO 790,820
390 IF R= HTHEN 470
400 IF W(R+ 1,S)< > 0THEN 470
401 IF S< > VTHEN 420
410 IF Z= 1THEN 450
411 Q= 1:GOTO 430
420 IF W(R,S+ 1)< > 0THEN 450
430 X= FN R(3):ON XGOTO 790,860,910
450 X= FN R(2):ON XGOTO 790,860
470 IF S< > VTHEN 490
480 IF Z= 1THEN 520
481 Q= 1:GOTO 500
490 IF W(R,S+ 1)< > 0THEN 520
500 X= FN R(2):ON XGOTO 790,910
520 GOTO 790
530 IF S- 1= 0THEN 670
540 IF W(R,S- 1)< > 0THEN 670
541 IF R= HTHEN 610
542 IF W(R+ 1,S)< > 0THEN 610
550 IF S< > VTHEN 560
551 IF Z= 1THEN 590
552 Q= 1:GOTO 570
560 IF W(R,S+ 1)< > 0THEN 590
570 X= FN R(3):ON XGOTO 820,860,910
590 X= FN R(2):ON XGOTO 820,860
610 IF S< > VTHEN 630
620 IF Z= 1THEN 660
621 Q= 1:GOTO 640
630 IF W(R,S+ 1)< > 0THEN 660
640 X= FN R(2):ON XGOTO 820,910
660 GOTO 820
670 IF R= HTHEN 740
680 IF W(R+ 1,S)< > 0THEN 740
681 IF S< > VTHEN 700
690 IF Z= 1THEN 730
691 Q= 1:GOTO 830
700 IF W(R,S+ 1)< > 0THEN 730
710 X= FN R(2):ON XGOTO 860,910
730 GOTO 860
740 IF S< > VTHEN 760
750 IF Z= 1THEN 780
751 Q= 1:GOTO 770
760 IF W(R,S+ 1)< > 0THEN 780
770 GOTO 910
780 GOTO 1000
790 W(R- 1,S)= C:C= C+ 1:V(R- 1,S)= 2:R= R- 1
810 IF C= HVTHEN 1010
811 Q= 0:GOTO 260
820 W(R,S- 1)= C
830 C= C+ 1:V(R,S- 1)= 1:S= S- 1
842 IF C= HVTHEN 1010
850 Q= 0:GOTO 260
860 W(R+ 1,S)= C:C= C+ 1
871 IF V(R,S)= 0THEN 880
872 V(R,S)= 3:GOTO 890
880 V(R,S)= 2
890 R= R+ 1
900 IF C= HVTHEN 1010
902 GOTO 530
910 IF Q= 1THEN 960
920 W(R,S+ 1)= C:C= C+ 1
922 IF V(R,S)= 0THEN 940
930 V(R,S)= 3:GOTO 950
940 V(R,S)= 1
950 S= S+ 1
951 IF C= HVTHEN 1010
952 GOTO 260
960 Z= 1
970 IF V(R,S)= 0THEN 980
971 V(R,S)= 3:Q= 0:GOTO 1000
980 V(R,S)= 1:Q= 0:R= 1:S= 1:GOTO 250
1000 GOTO 210
1010 GOSUB 1011:GOTO 1500
1011 GOSUB 163:FOR J= 1TO V:VV= VV+ 1:PLOT 3:PLOT OH:PLOT VV:PRINT C$;
1012 FOR I= 1TO H:IF V(I,J)< 2THEN 1030
1020 PRINT "BB";
1021 GOTO 1040
1030 PRINT D$;
1040 NEXT
1041 PRINT
1042 VV= VV+ 1:PLOT 3:PLOT OH:PLOT VV
1043 FOR I= 1TO H:IF V(I,J)= 0OR V(I,J)= 2THEN 1060
1051 PRINT B$;
1052 GOTO 1070
1060 PRINT A$;
1070 NEXT
1071 PRINT C$
1072 NEXT
1073 PLOT 26:PLOT 6:PLOT 0:PRINT "":PLOT 6:PLOT 7
1074 RETURN
1500 REM  SOLUCION AL LABERINTO
1510 M= 128* OV+ 2* (OH+ 2* XX- 1)+ 28672
1520 PLOT 3,0,31,11,7
1525 INPUT "SHALL I SOLVE IT RAPIDLY OR SLOWLY ? ";X$
1526 PLOT 26:PLOT 11
1530 PLOT 3,65,30
1540 IF LEFT$ (X$,1)= "R"THEN GOSUB 4000:GOTO 1560
1550 GOSUB 2000:CP= CP/ 9:CR= CR/ 9
1560 IF NOT ERTHEN PRINT "READY, ";:GOTO 1570
1565 IF ERTHEN PRINT "NO WAY THRU, ";
1570 PLOT 7:INPUT "DO YOU WANT ME TO SOLVE IT AGAIN ? ";X$
1580 IF LEFT$ (X$,1)< > "N"THEN GOSUB 3000:GOTO 1500
1590 PLOT 3,0,31,11,7
1600 INPUT "DO YOU WANT TO SEE A DIFFERENT MAZE ? ";X$
1610 IF LEFT$ (X$,1)< > "N"THEN RUN 10
1620 LOAD "MENU":RUN
2000 REM  BUSCA RUTA DE SALIDA
2003 ER= 0:CP= 9* CP:CR= 9* CR
2005 POKE M,46:POKE M+ 1,CR
2010 FOR I= 1TO 4:IF PEEK (M+ D(I))< > 66THEN NEXT :GOTO 2050
2020 M= M+ D(I):POKE M,46:POKE M+ 1,CR
2030 IF PEEK (M+ 128)= 32THEN RETURN
2040 GOTO 2010
2050 FOR I= 1TO 4:IF PEEK (M+ D(I))< > 46THEN NEXT :ER= - 1:RETURN
2060 POKE M,88:POKE M+ 1,0:M= M+ D(I):GOTO 2010
3000 REM  BORRA SOLUCION
3010 POKE 33283,0:POKE 33284,189:REM  BD00 ERASE ROUTINE
3020 M= 128* OV+ 2* (OH+ 2* XX- 1)+ 28672
3030 ER= CALL (M)
3040 N= FN R(7):IF N= CROR N= CPTHEN 3040
3050 CR= N:RETURN
4000 REM  SOLUCION RAPIDA EN ASSEMBLER
4010 POKE 33283,0:POKE 33284,188:REM  BC00 SOLVE ROUTINE
4020 POKE 48249,9* CR:REM  BC79 COLOR FOR SOLUTION
4030 ER= CALL (M)
4040 RETURN
5000 REM  CONVIERTE NUMERO EN X$ HEX A X DECIMAL
5010 H= ASC (LEFT$ (X$,1))- 55:IF H< 3THEN H= H+ 7
5020 X= H* 16:H= ASC (RIGHT$ (X$,1))- 55:IF H< 3THEN H= H+ 7
5030 X= X+ H:RETURN
5100 REM  CARGA SUBRUTINAS A MEMORIA
5110 PLOT 6,39,14,12,3,27,17:PRINT "M A Z E":PLOT 3,65,0
5120 PLOT 27:PRINT "DLOAD MAZESB.PRG":PLOT 27,27
5180 RUN 10