1 ' FLUGSIMULATOR		83-08-16
2 ' ---BILDSCHIRM
3 CLEAR ,&HCBD8
5 DEF FNP$(X,Y)=CHR$(27)+"="+CHR$(X+31)+CHR$(Y+31)	'P2711
6 REV$=CHR$(27)+"G4"+CHR$(27)+")"	'P2711	invers half
7 BLI$=CHR$(27)+"G2"			'P2711	blink
8 ENAT$=CHR$(27)+"G0"+CHR$(27)+"("	'P2711	normal
9 CLS$=CHR$(12)				'BILDSCHIRM L\SCHEN
15 DIM F(10),TC$(10),TC(10),M$(20)
17 DIM XM(13),WM(13),P$(31)
19 DIM XE(13),WE(13),XL(14),XR(14),S$(25)
20 REM:IFR FLIGHT SIMULATOR (BOEING 747)
30 REM:CREATED 06-28-81 BY GENE SZYMANSKI
40 REM:REVISED 02-25-82, 23-02-83
50 REATIM=&HCBD9
70 WIDTH 255
80 GRON$=CHR$(14):GROUT$=CHR$(15)
90 GOSUB 4080
100 'SYSTEM "CLOCK OFF"
110 GOSUB 3820:GOTO 150
120 REM:BEGIN CRUISE MODULE HERE
130 PRINT CLS$
140 'DIM M$(20)
150 REM:BEGIN TAKE-OFF MODULE HERE
160 RANDOMIZE:PRINT CLS$
170 KR=57.2958
180 'DIM XM(13),WM(13)
190 'DIM P$(31)
200 DATA 37,35,32,30,27,25,22,20,17,15,12,10,7,5
210 DATA 6,11,16,21,26,31,36,41,46,51,56,61,66,71
220 RESTORE 200
230 FOR I=0 TO 13:READ XM(I):NEXT
240 FOR I=0 TO 13:READ WM(I):NEXT
250 M$(1)="_":M$(2)="_":M$(3)="_"
260 'DIM XE(13),WE(13)
270 K1=29:K2=23
280 FOR I=0 TO 13
290 XE(I)=K1:WE(I)=K2
300 K1=K1-2:K2=K2+4
310 NEXT
320 IO=40
330 RN=RND(0)
340 RS=1:IF RN<.5 THEN RS=-1
350 W1=75:IF RS=-1 THEN W1=255
360 W2=INT(RND*20)+1:W3=RS*W2
370 'DIM XL(14),XR(14)
380 J=31:K=49
390 FOR I=0 TO 14
400 XL(I)=J:XR(I)=K
410 J=J-2:K=K+2
420 NEXT
430 DATA FUEL,LBS,%,VHF,MHZ,THRUST,MAX,IDLE,REV
440 DATA PITCH," +"," -",DEG,FLAPS,UP,DWN,WHEELS,UP,MID,DOWN
450 DATA COMPAS,AIRSPEED,KTS," VERT",SPEED,FPM
460 DATA ALTITUDE,FEET,CLOCK,BRAKE,SET,REL
470 RESTORE 430
480 FOR I=0 TO 31:READ P$(I):NEXT
490 'DIM S$(25)
500 FOR I=1 TO 25:S$(I)=SPACE$(I):NEXT
510 FOR I=0 TO 9:F(I)=0:NEXT
520 REM:INIT VARIABLES FOR TAKEOFF MODE
530 FU=200000!:FP=0:CC=75:SAS=0:RC=0:AL=0
540 MZ=77:TR=6:FL=2:FA=0:WH=13:IX=40:HY=9:BR=11:BK=11
550 AB=0
560 PRINT FNP$(9,18);"UNITED 312    ";REV$;"CLEARED";ENAT$;" AS FILED"
570 PRINT:PRINT
580 PRINT"        SURFACE WINDS VARIABLE. GUSTING TO 15."
590 PRINT"        MINIMUM CEILING CONDITIONS ARE IN EFFECT."
600 PRINT"        SKY CONDITIONS AT 20,000 SCATTERED."
610 PRINT"                       AT 30,000 BROKEN."
620 PRINT:PRINT
630 PRINT"UPON TAKEOFF, MAINTAIN HEADING 075 TO 3000, THEN PROCEED AS FILED."
640 PRINT:PRINT:PRINT"        STANDBY FOR TAKEOFF CLEARANCE."
645 PRINT:PRINT"hit any key ";:X$=INPUT$(1)
650 TQ=7000:GOSUB 3350
660 PRINT CLS$
670 PRINT FNP$(11,18);"UNITED 312":PRINT:PRINT
680 PRINT"YOU ARE ";REV$;"CLEARED";ENAT$;" FOR TAKEOFF AT ";BLI$;"0800";ENAT$;" HOURS"
685 FOR I=1 TO 2000:NEXT
690 TQ=3000:GOSUB 3350
700 PRINT CLS$
710 'SYSTEM "TIME 07.59.00":SYSTEM "CLOCK":PRINT CLS$
720 GOSUB 3910:GOSUB 3390:TL=TD
730 GOSUB 800
740 GOSUB 970
750 GOSUB 1110
760 GOSUB 1380
770 K$=INKEY$:IF LEN(K$)=0 THEN 790
780 GOSUB 1740
790 GOTO 2180
800 REM:DISPLAY PANEL (HEADERS ONLY)
810 PRINT FNP$(1,4);P$(0);S$(4);P$(5);S$(3);P$(9);S$(3);S$(6);S$(3);P$(20)
820 PRINT FNP$(11,60);P$(13);S$(3);P$(16);S$(2);P$(29)
830 PRINT FNP$(12,62);P$(14);S$(6);P$(14);S$(6);P$(30)
840 PRINT FNP$(14,62);P$(15);S$(5);P$(15);S$(5);P$(31)
850 IF F(9)=1 THEN RETURN
860 PRINT FNP$(2,14);P$(6);S$(6);P$(10);S$(6)
870 PRINT FNP$(2,69);P$(28)
880 PRINT FNP$(3,2);P$(1);S$(4);P$(2);S$(21);S$(3);S$(13);P$(23)
890 PRINT FNP$(4,23);P$(11);S$(13);P$(21);S$(2);P$(24);S$(2);P$(26)
900 PRINT FNP$(5,1);P$(3)
910 PRINT FNP$(6,40);P$(22);S$(6);P$(25);S$(5);P$(27)
920 PRINT FNP$(7,1);P$(4);S$(10);P$(7);S$(3);P$(12);S$(7)
930 PRINT FNP$(8,14);P$(8)
940 FOR Y=1 TO 7:PRINT FNP$(Y+1,13);CHR$(14);CHR$(86);CHR$(15):NEXT
950 FOR Y=1 TO 3:PRINT FNP$(Y+1,22);CHR$(14);CHR$(86);CHR$(15):NEXT
960 RETURN
970 REM : DISPLAY HORIZONTAL LINE
980 IF F(9)=0 THEN GOTO 1010
990 PRINT FNP$(10,1);SPACE$(80);
1000 IF HY=20 THEN 1030
1010 PRINT FNP$(HY+1,1);STRING$(80,"_");
1020 RETURN
1030 OH=9:HY=10
1040 FOR I=HY TO 22
1050 PRINT FNP$(OH+1,1);SPACE$(80);
1060 PRINT FNP$(I+1,1)STRING$(80,"_");
1070 OH=I
1080 NEXT I
1090 PRINT FNP$(24,IO+1);" ";
1100 RETURN
1110 REM :DISPLAY RUNWAY
1120 IF F(4)=1 THEN 1200
1130 S=10:X=29
1140 FOR Y=10 TO 22
1150 PRINT FNP$(Y+1,X+1);".";SPACE$(S);" ";SPACE$(S);".";
1160 X=X-2:S=S+2
1170 NEXT
1180 S$=S$(13)
1190 RETURN
1200 REM :PRINT RUNWAY GRAPHICS
1210 IF N>3 GOTO 1350
1220 PRINT FNP$(OY+1,OX+1);SPACE$(WM);
1230 PRINT FNP$(NY+1,NX+1);MK$;
1240 OY=NY:OX=NX
1250 WM=FW
1260 RETURN
1270 REM:ENTRY WHEN SHIP IN FINAL ZONE
1280 PRINT FNP$(OY+1,OX+1);SPACE$(WM):IF F(9)=1 THEN RETURN
1290 FOR I=10 TO NY-1
1300 PRINT FNP$(I+1,XE(J)+1);SPACE$(WE(J))
1310 NEXT I
1320 IF N>4 THEN RETURN
1330 PRINT FNP$(NY+1,NX+1);MK$;
1340 RETURN
1350 IF F(2)=1 THEN 1270 ELSE F(2)=1
1360 FOR I=10 TO 13:PRINT FNP$(I+1,60);SPACE$(21):NEXT
1370 GOTO 1270
1380 REM:DISPLAY INSTRUMENT READINGS
1390 YP=1:XP=0:F$="**####":V1=FU:GOSUB 3480
1400 YP=1:XP=7:F$="**#":V1=FP:GOSUB 3480
1410 YP=1:XP=39:V1=CC:GOSUB 3480
1420 YP=4:XP=39:V1=SAS:GOSUB 3480
1430 YP=4:XP=46:F$="**####":V1=RC:GOSUB 3480
1440 YP=4:XP=55:F$="**,###":V1=AL:GOSUB 3480
1450 YP=5:XP=0:F$="**#":V1=MZ:GOSUB 3480
1460 REM:DISPLAY THRUST
1470 FOR I=1 TO 7
1480 PRINT FNP$(I+1,12);REV$;" "
1490 NEXT
1500 PRINT FNP$(TR+1,12);">";
1510 REM:DISPLAY PITCH
1520 FOR I=1 TO 3:PRINT FNP$(I+1,21);" ":NEXT
1530 PRINT FNP$(FL+1,21);">";
1540 F$="+**#"
1550 YP=5:XP=20:V1=FA:GOSUB 3480
1560 REM:DISPLAY FLAPS
1570 IF F(2)=1 GOTO 1680
1580 PRINT REV$;
1590 FOR I=11 TO 13:PRINT FNP$(I+1,60);" ":NEXT
1600 PRINT FNP$(BR+1,60);">";
1610 REM:WHEELS
1620 FOR I=11 TO 13:PRINT FNP$(I+1,68);" ":NEXT
1630 PRINT FNP$(WH+1,68);">"
1640 REM:BRAKES
1650 FOR I=11 TO 13:PRINT FNP$(I+1,76);" ":NEXT
1660 PRINT FNP$(BK+1,76);">"
1670 PRINT ENAT$
1680 REM:DISPLAY RUNWAY ALIGNMENTS
1690 IF F(9)=1 THEN RETURN
1700 PRINT FNP$(24,IO+1);" ";
1710 PRINT FNP$(24,IX+1);GRON$;CHR$(53);GROUT$;
1720 IO=IX
1730 RETURN
1740 REM:KEY POLL SUBROUT
1750 IF K$="I" THEN KK=1:GOTO 1830
1760 IF K$="4" OR K$="6" THEN KK=2:GOTO 1830
1770 IF K$="B" THEN KK=3:GOTO 1830
1780 IF K$="8" OR K$="2"THEN KK=4:GOTO 1830
1790 IF K$="F" THEN KK=5:GOTO 1830
1800 IF K$="W" THEN KK=6:GOTO 1830
1810 IF K$="D" THEN KK=7:GOTO 1830
1820 PRINT CHR$(7);
1830 ON KK GOSUB 1880,1920,1970,2000,2100,2150,1850
1840 RETURN
1850 REM:THRUST KEY (DECREASE)
1860 IF F(7)=1 AND BR=11 THEN TR=4
1870 RETURN
1880 REM:THRUST KEY (INCREASE)
1890 IF F(7)=1 THEN RETURN
1900 IF F(0)=0 THEN RETURN
1910 F(1)=1:TR=1:RETURN
1920 REM:RUDDER KEYS
1930 IF F(7)=1 THEN RETURN
1940 IF SAS<=50 THEN RETURN
1950 IF K$="4" THEN CC=CC-1 ELSE CC=CC+1
1960 RETURN
1970 REM:BRAKES
1980 IF F(0)=1 THEN RETURN
1990 F(0)=1:BK=13:RETURN
2000 REM:PITCH
2010 IF F(7)=1 THEN RETURN
2020 IF SAS<=50 THEN RETURN
2030 FD=-10:IF K$="8" THEN FD=10
2040 FA=FA+FD
2050 IF FA>60 THEN FA=60
2060 IF FA<-60 THEN FA=-60
2070 IF FA>0 THEN FL=1:RETURN
2080 IF FA=0 THEN FL=2:RETURN
2090 FL=3:RETURN
2100 REM:FLAPS
2110 IF F(7)=1 AND WH=11 THEN BR=11:RETURN
2120 IF F(3)=1 THEN RETURN
2130 IF F(3)=0 THEN F(3)=1:BR=13:RETURN
2140 RETURN
2150 REM:WHEELS
2160 IF F(7)=1 THEN WH=11
2170 RETURN
2180 REM:SITUATION UPDATE ROUTINE
2190 GOSUB 3900:GOSUB 3390:TJ=TD-TL:TL=TD
2200 IF F(9)=1 THEN 3530
2210 IF F(0)=1 THEN 2230
2220 GOSUB 2540:GOTO 760
2230 IF F(4)=1 THEN 2270
2240 F(4)=1
2250 XX=0:YY=0
2260 TX=TD:V0=0:N=1:OY=23:OX=5:WM=71
2270 REM
2280 A=(118-18*TR)*.04028
2290 GOSUB 2660
2300 IF AL>0 THEN 2410
2310 IF YY>10500 OR ABS(XX)>100 THEN 3060
2320 IF FA<=0 GOTO 2490
2330 IF SAS<150 GOTO 3050
2340 IF FA>10 GOTO 3050
2350 IF F(3)=0 GOTO 2490
2360 AL=25
2370 GOSUB 2540
2380 GOSUB 2580
2390 GOSUB 2880
2400 GOTO 750
2410 F(9)=1
2420 GOSUB 2540
2430 GOSUB 2580
2440 GOSUB 2620
2450 FOR I=10 TO 22:PRINT FNP$(I+1,1);SPACE$(80);:NEXT
2460 HY=20
2470 GOSUB 970
2480 GOTO 2520
2490 GOSUB 2540
2500 GOSUB 2880
2510 GOTO 750
2520 REM:NOW DO DEPARTURE PROCEDURES
2530 GOTO 760
2540 REM:UPDATE FUEL
2550 FU=FU-40*TJ
2560 FP=FU/3120
2570 RETURN
2580 REM:UPDATE RATE OF CLIMB
2590 RC=SAS*SIN(ABS(FA/57.3))*1.693*60
2600 IF FA<0 THEN RC=-1*RC
2610 RETURN
2620 REM:UPDATE ALT
2630 AL=AL+TJ*RC/60
2640 IF AL<=0 THEN AL=0
2650 RETURN
2660 REM:EQUATIONS OF MOTION
2670 T=TJ
2680 V=V0+A*T
2690 VB=(V+V0)/2:V0=V
2700 S=VB*T
2710 IF TD<(TX+18) GOTO 2750
2720 TX=TD
2730 WB=RS*(INT(RND*2)+1)
2740 CC=CC+WB
2750 DA=(CC-75)/57.3
2760 DY=S*COS(ABS(DA))
2770 DX=S*SIN(ABS(DA))
2780 IF DA<0 THEN DX=-1*DX
2790 YY=YY+DY
2800 XX=XX+DX
2810 SAS=V/1.69278
2820 IF SAS>20 THEN SAS=SAS+WS
2830 IX=40 +FIX(XX*7/20):IF IX>79 THEN IX=79
2840 IF IX<0 THEN IX=0
2850 ZP=FIX(YY-2500*(N-1))
2860 IF ZP>2500 THEN N=N+1:GOTO 2850
2870 RETURN
2880 REM:VARIABLES FOR RUNWAY GRAPHICS
2890 MP=FIX(10+(13*ZP)/2500)
2900 IF N>3 GOTO 2980
2910 NY=MP
2920 J=NY-10
2930 NX=XM(J)
2940 FM=WM(J)
2950 S$=SPACE$(J)
2960 MK$=M$(N)+S$(J)+"_"+S$(J)+"_"+S$(J)+"_"+S$(J)+"_"+S$(J)+"_"
2970 RETURN
2980 REM:IN ZONE 4-MARKER IS RuNWAY EDGE
2990 NY=MP
3000 J=NY-10
3010 NX=XE(J)
3020 IF N>4 THEN RETURN
3030 MK$=STRING$(WE(J),"_")
3040 RETURN
3050 AB=1:GOTO 3110
3060 AB=2:IF YY<10500 GOTO 3110
3070 FOR I=10 TO 22
3080 PRINT FNP$(I+1,1);SPACE$(80);
3090 NEXT I
3100 GOTO 3110
3110 REM ABORT
3120 GOSUB 3760
3130 PRINT FNP$(I+1,1);REV$;SPACE$(80);
3140 'NEXT I
3150 PRINT FNP$(11,30);"*** TAKEOFF FAILED ***":PRINT:PRINT
3160 ON AB GOSUB 3190,3240
3170 PRINT FNP$(20,35);ENAT$;"END OF PROGRAM "
3180 END
3190 PRINT "YOU PULLED BACK ON THE STICK AT TOO SLOW A SPEED, OR YOU"
3200 PRINT "PULLED BACK THE STICK TOO FAR WHEN AT PROPER SPEED."
3210 PRINT "AS A RESULT THE TAIL END OF THE FUSELAGE SCRAPED THE RUNWAY"
3220 PRINT "AND THE AIRCRAFT SPUN OUT OF CONTROL."
3230 RETURN
3240 IF YY>10500 GOTO 3290
3250 PRINT "YOU FAILED TO STAY WITHIN THE RUNWAY BOUNDRIES."
3260 PRINT "AS A RESULT YOU VEERED OFF THE RUNWAY AND COLLIDED WITH"
3270 PRINT "THE RUNWAY LIGHTS."
3280 RETURN
3290 PRINT "YOU RAN OUT OF RUNWAY. AS A RESULT YOU ROLLED INTO THE"
3300 PRINT "MARSHLANDS LOCATED";FIX(YY)-10500;"FEET PAST THE END OF THE RUNWAY"
3310 IF F(3)=1 THEN RETURN
3320 PRINT:PRINT:PRINT "YOU FORGOT TO LOWER THE FLAPS,."
3330 PRINT "AS A RESULT THE AIRCRAFT COULD NOT DEVELOP SUFFICIENT LIFT"
3340 RETURN
3350 REM:TIME DELAY PAD
3360 FOR I=1 TO TQ/10
3370 NEXT I
3380 RETURN
3390 REM :CONVERT RTC TO TIME OF DAY IN SECONDS ABSOLUTE
3400 J=7
3410 FOR I=0 TO 2
3420 TC$(I)=MID$(TV$,J,2)
3430 J=J-3
3440 TC(I)=VAL(TC$(I))
3450 TD=(3600*TC(2))+(60*TC(1))+TC(0)
3460 NEXT I
3470 RETURN
3480 REM:PLOT VARIABLES ON REVERSE BACKGROUND
3490 PRINT FNP$(YP+1,XP+1);REV$;
3500 PRINT USING F$;V1;
3510 PRINT ENAT$;
3520 RETURN
3530 REM:DEPARTURE ROUTINE
3540 IF F(7)=1 GOTO 3570 ELSE F(7)=1
3550 GOSUB 820
3560 F(2)=0
3570 IF WH<>11 GOTO 3600 ELSE SAS=SAS+5
3580 IF BR<>11 GOTO 3600 ELSE SAS=SAS+5
3590 IF TR=4 AND AL>1800 GOTO 5000 ELSE GOTO 3710
3600 IF AL<1200 GOTO 3710
3610 GOSUB 3760:PRINT FNP$(13,1);"****************** FLIGHT ABORTED ******************"
3620 PRINT:PRINT
3630 PRINT "YOU FAILED TO PERFORM CRUCIAL TRIM MANEUVERS FOLLOWING LIFTOFF."
3640 PRINT "THE PROPER TRIM SEQUENCE,WHICH MUST BE COMPLETED BELOW 1200 FEET, IS AS FOLLOWS:"
3650 PRINT "   1-RAISE LANDING GEAR"
3660 PRINT "   2-RETRACT FLAPS"
3670 PRINT "   3-REDUCE THRUST"
3680 PRINT
3690 PRINT ENAT$;"---------- END OF PROGRAM ---------- "
3700 END
3710 GOSUB 2540
3720 GOSUB 2580
3730 GOSUB 2620
3740 GOTO 760
3750 REM:END OF LISTING
3760 REM INVERSE BAKGROUND FOR FAILURE
3770 FOR I=10 TO 22
3780 PRINT FNP$(I+1,1);REV$;SPACE$(80);
3790 NEXT I
3800 RETURN
3810 STOP
3820 REM TIME READING FOR P3500 UNDER TURBODOS (PAR=UUR,MIN,SEC)
3830 RESTORE 3840
3840 DATA E5,D5,C5,0E,54,CD,05,00,78,E1,77,7B,E1,77,7A,E1,77,C9
3850 FOR I=REATIM TO REATIM+17:READ X$:POKE I,VAL("&H"+X$):NEXT
3860 REM TIME SETTING FOR P3500 UNDER TURBODOS )PAR=UUR,MIN,SEC)
3870 CALL REATIM(UUR%,MIN%,SEC%)
3880 DUUR%=UUR%-7:DMIN%=MIN%-58:DSEC%=SEC%-60
3890 RETURN
3900 REM MAKE DISPLAY VARIABLE AS IN TRS-80
3910 REATIM=&HCBD9
3920 UUR%=0:MIN%=0:SEC%=0
3930 CALL REATIM(UUR%,MIN%,SEC%)
3940 UUR%=UUR%-DUUR%:MIN%=MIN%-DMIN%:SEC%=SEC%-DSEC%
3950 IF SEC%>59 THEN SEC%=SEC%-60:MIN%=MIN%+1
3960 IF MIN%>59 THEN MIN%=MIN%-60:UUR%=UUR%+1
3970 IF UUR%>23 THEN UUR%=0
3980 VT$="00:00:00"
3990 MID$(VT$,1,2)=RIGHT$(STR$(UUR%),2)
4000 MID$(VT$,4,2)=RIGHT$(STR$(MIN%),2)
4010 MID$(VT$,7,2)=RIGHT$(STR$(SEC%),2)
4020 IF MID$(VT$,1,1)=" " THEN MID$(VT$,1,1)="0"
4030 IF MID$(VT$,4,1)=" " THEN MID$(VT$,4,1)="0"
4040 IF MID$(VT$,7,1)=" " THEN MID$(VT$,7,1)="0"
4050 PRINT FNP$(1,68);REV$;VT$;ENAT$
4060 TV$=VT$
4070 RETURN
4080 'KEY-DESCRIPTION
4090 PRINT CHR$(12);"FLIGHT SIMULATOR (BOEING 747)"
4100 PRINT:PRINT"I  .....  THRUST KEY (INCREASE)"
4110 PRINT"D  .....  THRUST KEY (DECREASE)"
4120 PRINT"B  .....  BRAKES"
4130 PRINT"F  .....  FLAPS"
4140 PRINT"W  .....  WHEELS"
4150 PRINT"4  .....  RUDDER LEFT"
4160 PRINT"6  .....  RUDDER RIGHT"
4170 PRINT"2  .....  PITCH DOWN"
4180 PRINT"8  .....  PITCH UP"
4190 PRINT:PRINT"hit any key ! ";
4200 K$=INKEY$:IF K$="" THEN 4200 ELSE PRINT CHR$(12);:RETURN
5000 'FLIGHT OK.
5010 PRINT FNP$(23,1);BLI$;">>> YOU ARE A PERFECT PILOT ! <<<"
5020 PRINT ENAT$;"TRY AGAIN (Y/N)?: ";
5030 K$=INKEY$:IF K$="N" OR K$="n" THEN PRINT CLS$;:END
5040 IF K$<>"Y" AND K$<>"y" THEN 5030 ELSE 130
TRY AGAIN (Y/N)?: ";
5030 K$=INKEY$:IF K$="N" OR K$="n" THEN PRINT CLS$;:END