home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format 112 / af112sub.adf / Modelsim.lzx / modelsim / modelsim.amos / modelsim.amosSourceCode < prev    next >
Encoding:
AMOS Source Code  |  1998-04-19  |  12.4 KB  |  359 lines

  1. '
  2. '
  3. '
  4. 'Goto HERE 
  5. '
  6. D$=Dir$
  7. Load D$+"banks/jetnoises.abk",5
  8. '
  9. Screen Open 1,640,264,2,Hires : Colour 1,$BCD : Colour 0,$445
  10. Screen Open 2,936,256,8,LORES
  11. Screen Open 3,936,256,8,LORES
  12. Screen Open 4,320,240,16,LORES : Curs Off : Rem 3d screen
  13.  'Screen Open 5,36,56,2,LORES : Screen Hide 5 : Rem  hope to stop gurus   
  14. Screen To Front 1
  15. '
  16. Screen 1 : Hide : Gosub PRYNT
  17. Load Iff D$+"pictures/monta",2 : Screen Hide 2
  18. Load Iff D$+"pictures/montb",3 : Screen Hide 3
  19. '
  20. Dim SYN#(361)
  21. Dim COZN#(361)
  22.  Dim TRAILX(60)
  23.  Dim TRAILY(60)
  24.  Dim TRAILZ(60)
  25. Degree 
  26. For X=0 To 360 : SYN#(X)=Sin(X) : COZN#(X)=Cos(X) : Next 
  27.  Extension_4_04D6 D$+"objects"
  28. Hide 
  29. Screen 4
  30.  Extension_4_0054 240
  31. RT1=16384 : RT2=32768 : RT3=49152 : RT4=65536
  32. Double Buffer 
  33. Autoback 0
  34.   TPSPEED=750 : Rem this is max,  to limit sound  max loop rate for jet  
  35.   STALL=160
  36.   THRUST=0
  37.   INDRAG=0 : Rem 65 is max for input..  (30 is pretty slow)   
  38.   DRAG=65-INDRAG
  39.   WEIGHT=9 : Rem  jet standard 9 (a max wing loading effect), 3 a minimum           
  40.  SENK=WEIGHT*4 : Rem 40 for sink rate  , increases on turn  
  41.   RESPONSE=900 : Rem standard 900 
  42.   UPDOWN=RESPONSE/2
  43.  HOLDIT=0
  44.  TAANK=50000 : FUEL=TAANK
  45.  TRAILOFF=1
  46.  'Td Keep On  
  47.  Extension_4_0016 "jetplane3"
  48.  Extension_4_0016 "runway"
  49.  Extension_4_01A6 0,RT3,0,RT1
  50.  Extension_4_00EC 0,900,2200,1500
  51.  Extension_4_0036 1,"jetplane3",5400,-200,50,RT1-200,RT2,-500
  52.  Extension_4_0036 2,"runway",12000,100,-200,RT1,RT2,1000
  53.  Extension_4_058A 2,-1
  54. Get Palette 2
  55. Palette $69F,,,,,,,,$F96,$FEF,$573,$0,$333,$444,$FFF
  56. '
  57.   Extension_4_05E2 1,1,15
  58. For Y=1 To 8
  59.    Colour Y,Colour(Y)-$222
  60. Next 
  61. '
  62. Volume 10 : Sam Loop On : Sam Play %1001,1,9000
  63. HERE:
  64. Clear Key : Wait Key 
  65. Screen Hide 1
  66. 'End 
  67. '
  68. '           ---------------- START  OF LOOP------------------  
  69. '
  70. Repeat 
  71.    X=Joy(1)
  72.    MORE=0
  73.    If Jleft(1)=-1 Then Add A,RESPONSE
  74.    If Jright(1)=-1 Then Add A,-RESPONSE
  75.    A=A-A/3
  76.    If Jdown(1)=-1 Then Add B,-UPDOWN
  77.    If Jup(1)=-1
  78.         If WZ>GRZ or BAT<30500
  79.           Add B,UPDOWN
  80.          End If 
  81.     End If 
  82.    B=B-B/3
  83.    F$=Inkey$
  84.     Clear Key 
  85.    If F$<>"" Then Gosub KEYBOARD
  86.    AAT= Extension_4_01BC(1)
  87.    BAT= Extension_4_01D0(1)
  88.    CAT= Extension_4_01E4(1)
  89.    '               --------------------the tricky bit!!!!---------- 
  90.    '  
  91.    '          angles first  
  92.    '
  93.    INVERT=1 : If BAT<RT1 or BAT>RT3 Then INVERT=-1
  94.    USEFUL#=COZN#(AAT/182)
  95.   MOREUSE#=SYN#(BAT/182)
  96.    ELEVT=USEFUL#*B*INVERT
  97.         VERT=0 : AMORE=0
  98.      If BAT<21000 and BAT>11000 or BAT>43000 and BAT<55000
  99.         ' these  lines allow direct c rotation from vert when vertical     
  100.        '  <21000 >11000  >43000 <55000   to 20k- 12k  44k- 54k  
  101. '
  102.    If AAT<RT1-700 : AMORE=500 : End If : Rem 4 lines to stop bad alignment of c and a     
  103.    If AAT>RT3+700 : AMORE=-500 : End If 
  104.    If AAT>RT1 and AAT<RT2 : AMORE=-500 : End If 
  105.    If AAT>RT2 and AAT<RT3 : AMORE=500 : End If 
  106.      If BAT<21000 and BAT>11000
  107.                VERT=A*MOREUSE#-AMORE
  108.        End If 
  109.       If BAT>43000 and BAT<55000
  110.                VERT=A*MOREUSE#+AMORE
  111.        End If 
  112.  End If 
  113.      ' finally set angle..... 
  114.     Extension_4_018C 1,A*Abs(COZN#(BAT/182))+AMORE,B*SYN#(AAT/182),USEFUL#*300*INVERT-ELEVT+VERT
  115.     If HOLDIT=0 and WZ>GRZ+400 and SPEED<STALL Then Extension_4_018C 1,0,1800*INVERT,0
  116.    '              above line is for stall     
  117.    '
  118.    '         then movement
  119.    '
  120.    Add FUEL,-THRUST : If FUEL<0 Then THRUST=0
  121.    GRAVITY=Int(MOREUSE#*WEIGHT) : Rem          ..........speed alter with climb/ fall  
  122.    Add SPEED,THRUST-(SPEED/DRAG)-GRAVITY
  123.  If SPEED<0 Then SPEED=0
  124. If SPEED<65 and WZ<(GRZ-180) Then SPEED=0 : THRUST=0 : Rem To give Stop On landing
  125. If SPEED>TPSPEED Then SPEED=TPSPEED : Rem else the sound goes too high 
  126. '
  127. '                 main movement..  
  128.     MZ#=MOREUSE#*SPEED : Rem   vertical move
  129.     TEMP#=-(COZN#(BAT/182)*SPEED) : Rem    split rest between x/y  
  130.    MX#=COZN#(CAT/182)*TEMP#
  131.    MY#=SYN#(CAT/182)*TEMP#
  132.     If WZ<GRZ Then MZ#=0 : Rem to prevent underground on runway 
  133.     Extension_4_00D4 1,MX#,MY#,MZ#-LOSS : Rem   actual plane move
  134.    LOSS=0 : If WZ>GRZ Then LOSS=SENK+(Abs(USEFUL#)*SENK*2) : Rem   loss is sink rate  
  135.    '
  136.        Dec HOLDIT : If HOLDIT<0 Then HOLDIT=0
  137.      ' above prevents nose down on runway after stall 
  138. '
  139.    '
  140.    '                    then viewpoint
  141.    '
  142.    WX= Extension_4_0114(1) : WY= Extension_4_0128(1) : WZ= Extension_4_013C(1)
  143.    SCX= Extension_4_0474(WX,WY,WZ)
  144.    SCY= Extension_4_0480 
  145.    GRZ=200-RNG/26
  146.    If WZ<GRZ
  147.       CRASH=1 : If WY>1000 or WY<-1700 : CRASH=0 : End If : Rem sideways limit runway    
  148.       If CRASH=1 and WX>24000 or WX<0 : CRASH=0 : End If : Rem  Ends Runway   
  149.       If CRASH=0 : Gosub CRASH : End If 
  150.    End If 
  151.    '
  152.    '            ------- horizontal change of view-------- 
  153.    '
  154.    SP=SP/1.2 : Rem     damping for viewpoint turn 
  155.    FOOL=0
  156.    If SCX>1 and SCX<230 Then CORRECT=0
  157.    If CORRECT=1 Then FOOL=-350 : Goto AVOID
  158.    If SCX<100 Then FOOL=105-SCX
  159.    If SCX<65 Then FOOL=(90-SCX)*4 : Rem  was 350 
  160.    AVOID:
  161.    If SCX>230 Then FOOL=205-SCX
  162.    If SCX>255 Then FOOL=(190-SCX)*4 : CORRECT=1
  163.    Add SP,FOOL
  164.    '
  165.    '                 ------ vertical change------ 
  166.    '
  167.      If SCY=-1 Then Gosub MISS : Rem MISS =attempt to swing to pick up dive/vanish
  168.    TAD= Extension_4_01BC(0)
  169.    If SCY<55 and SCY>-1 Then Add UP,(55-SCY)*100 : Rem to follow overhead pass    
  170.    If WZ<5000 and TAD>RT3 Then Add UP,-(5100-WZ)/14 : THING=1 : Rem moves bcgrnd up as plane nears ground        
  171.    If TAD>51800 and SCY>100 : Rem when PLANE HIGH and comes low on screen    
  172.         HOPE=-SCY*3
  173.        Add UP,HOPE
  174.         End If 
  175.    If WZ>5200 and TAD<51000 Then Add UP,128 : Rem move bkgd DOWN for mid flight
  176.    UP=UP/3
  177.    '
  178.     Extension_4_018C 0,UP,0,-SP
  179.    ' If TAD>55000 and SCY<80 and SCY>0 Then Gosub DESPERATE 
  180.    If Extension_4_01BC(0)<RT1 Then Extension_4_01A6 0,RT4-(UP*20),0, Extension_4_01E4(0)+RT2
  181. '        above line flicks view over the vertical  
  182. '
  183.     Extension_4_053C 
  184.     Extension_4_0318 
  185.         QUICK=(SPEED/5)+1
  186.        Paper 0 : Ink 1
  187.         Bar 0,0 To QUICK,2 : Draw 130,4 To 130,7 : Draw 50,4 To 50,7
  188.      Locate 15,0 : Print " <airspeed"
  189.      Locate 28,0 : Print THRUST;" <power"
  190.      Bar 0,9 To FUEL/1000,11 : Locate 7,1 : Print "<fuel"
  191.    '        -----------------    now the background.. confounded size limits!!! ----------    
  192.    UPPER=(TAD-49152)/35
  193.    If UPPER<0 Then UPPER=0
  194.    '                
  195.    BACPOS= Extension_4_01E4(0)/35
  196.    EXTRA2=1 : OVER2=0 : EXTRA3=1 : OVER3=0
  197.    WID1=320 : If BACPOS>616 and BACPOS<936 Then WID1=936-BACPOS : EXTRA3=0 : OVER3=1
  198.    WID2=320 : If BACPOS>1552 Then WID2=1872-BACPOS : EXTRA2=0 : OVER2=1
  199.    If BACPOS>930 and BACPOS<1553 Then Goto SKIP1
  200.     Extension_4_049E 2,BACPOS*EXTRA2,80,WID1,256 To WID2*OVER2,62+UPPER
  201.    SKIP1:
  202.    If BACPOS<617 Then Goto SKIP2
  203.     Extension_4_049E 3,(BACPOS-936)*EXTRA3,80,WID2,256 To WID1*OVER3,62+UPPER
  204.    SKIP2:
  205.    '  
  206.    '
  207.    Dec CHOOK
  208.    If CHOOK<1 Then CHOOK=6 : Gosub SOUND
  209.    OVERDONE:
  210.     If Timer<3 Then Goto OVERDONE : Rem To LIMIT SPEED On FASTER MACHINE 
  211.     Timer=0
  212.     Gosub TRAIL
  213.    Screen Swap 
  214.    Wait Vbl 
  215. Until False
  216. '--------------------------=END    LOOP ---------------------- 
  217. '
  218. '
  219. '========================================================================
  220. PRYNT:
  221. Locate 22,1 : Print "A SIMPLE MODEL JET FLIGHT SIMULATOR ..."
  222. '
  223. Locate 20,2 : Print "(  miniature gas turbines are in use now ) "
  224. Locate 20,3 : Print "     Programmed using AMOS 3D "
  225. Locate 2,4
  226. Print " "
  227. Print " Turning is done by first banking the plane ( using joystick) "
  228. Print " A slight natural turn occurs, which increases as the bank increases."
  229. Print " "
  230. Print " Elevator action (..joystick) is normal with wings level, but when the"
  231. Print " wings are tilted,  elevator will cause the turn to increase or decrease."
  232. Print "(limitations in amos3d allowed only partial rudder control so it is ommitted)"
  233. Print ""
  234. Print " NOTE..    most aerobatics are possible, but it takes time to get used to the "
  235. Print " controls being relative to the plane's attitude, and not the viewpoint."
  236. Print " Very slow speed will help- reducing WEIGHT variable will allow slowest speed "
  237. Print " Runway landing is difficult as there's none of the 3d depth perception and"
  238. Print " sense of orientation in a landscape that you get with the real thing. "
  239. Print ""
  240. Print " Power level is from 0-11,using keys..'tab,0,1,2.. etc. up to -'"
  241. Print " Key P will pause  "
  242. Print " Key R will reset the plane to the runway"
  243. Print " Key Z will flick zoom the plane closer if it gets too distant"
  244. Print " Key T will toggle the 'smoke trail' On /Off.. off speeds frame rate"
  245. Print " Key H will bring back this screen "
  246. Print " Key C will end program "
  247. Print " "
  248. Print " Background and viewpoint movement proved to be tricky but normally the view"
  249. Print " angle will swing after, or over and catch up to the plane going past. "
  250. Print " Once disc activity stops....   PRESS ANY KEY TO CONTINUE"
  251. Print ""
  252.  Print " Programmer... David Lawrence.   First done about 1994, improved 1997 "
  253. Return 
  254. '======================================================= 
  255. SOUND:
  256.   ' about 50,000 seems to be max visible comfortably 
  257.  RNG= Extension_4_007E(0,1)
  258. FACTOR=(RNG/700)-10
  259. If FACTOR>50 Then FACTOR=50 : Rem limit low sound at dist
  260. If FACTOR<0 Then FACTOR=0
  261. VOL=63-((500-SPEED)/10)-FACTOR
  262.   If VOL<8 Then VOL=8
  263.  If VOL>63 Then VOL=63
  264. Volume VOL
  265.  Doke $DFF0D6,800-(THRUST*60)
  266.  Doke $DFF0A6,800-SPEED
  267.   'above sets frequency --amos sound has to break the loop to change@#!
  268. Return 
  269. '========================================================
  270. CRASH:
  271.       TEMP1=4+(SPEED/20)
  272.          VOL=1
  273.           For H=0 To 20
  274.      Extension_4_018C 1,Rnd(200)*TEMP1,Rnd(200)*TEMP1,Rnd(600)*TEMP1
  275.      Extension_4_00D4 1,MX#,MY#,0
  276.   Extension_4_053C 
  277.  Extension_4_0318 
  278.    If BACPOS>930 and BACPOS<1553 Then Goto SKIP3
  279.     Extension_4_049E 2,BACPOS*EXTRA2,80,WID1,256 To WID2*OVER2,62+UPPER
  280.    SKIP3:
  281.    If BACPOS<617 Then Goto SKIP4
  282.     Extension_4_049E 3,(BACPOS-936)*EXTRA3,80,WID2,256 To WID1*OVER3,62+UPPER
  283.    SKIP4:
  284.       Screen Swap : Wait Vbl 
  285.          TEMP1=TEMP1-2 : If TEMP1<1 Then TEMP1=1
  286.          MX#=MX#/1.4 : MY#=MY#/1.4
  287.         Add VOL,12 : If VOL>63 Then VOL=63
  288.         If VOL=63 Then Volume 1 Else Volume VOL
  289.        Next 
  290. Volume 0 : Locate 4,20 : Print "... below ground zero! " : Locate 7,23
  291. Print "    resetting..... " : Screen Swap : Wait 100
  292.  Extension_4_01A6 1,RT1-200,RT2,-500 : SPEED=0 : THRUST=0
  293.  Extension_4_00EC 1,5400,-200,250 : C1=0 : C2=0 : BAT=16384 : B=0 : A=0 : FOOL=0 : WZ=0
  294.  Extension_4_01A6 0,RT3,0,RT1 : SP=0 : UP=0 : UPPER=0 : CORRECT=0 : HOLDIT=20 : FUEL=TAANK
  295. Return 
  296. '=================================================================== 
  297. KEYBOARD:
  298. '                   plane speed                
  299. '
  300.  HOLD=Scancode
  301. If HOLD>-1 and HOLD<12 Then THRUST=HOLD
  302. If F$="c" Then Volume 0 : End 
  303.  If F$="t" and TRAILOFF=0
  304.         TRAILOFF=1
  305.       For X=0 To 45 : TRAILZ(X)=50000 : Next : Return 
  306.  End If 
  307.  If F$="t" and TRAILOFF=1 Then TRAILOFF=0
  308.  If F$="h"
  309.  Screen Show 1
  310.   Wait Key : Screen Hide 1 : Screen 4
  311.  End If 
  312. If F$="r" : Rem                 ......  reset if plane lost
  313.     Extension_4_01A6 1,RT1-200,RT2,-500 : SPEED=0 : THRUST=0
  314.     Extension_4_00EC 1,5400,-200,250 : C1=0 : C2=0 : BAT=16384 : B=0 : A=0 : FOOL=0
  315.     Extension_4_01A6 0,RT3,0,RT1 : SP=0 : UP=0 : UPPER=0 : CORRECT=0 : WZ=0 : HOLDIT=20 : FUEL=TAANK
  316. End If 
  317. If F$="p" Then Volume 0 : Wait Key 
  318.  If F$="z" Then Extension_4_00EC 1,WX/2,WY/2,WZ/1.8
  319. Return 
  320. '==========================================================================
  321. MISS:
  322.               HELPA= Extension_4_0236(0,WY,WZ,WX)
  323.               HELPB= Extension_4_0244 
  324.       If HELPA<RT1 and HELPA>0 Then TEMPA=49152+HELPA
  325.       If HELPA<0 Then TEMPA=49152
  326.       If HELPA>RT1 Then TEMPA=49152+(RT2-HELPA)
  327.                Extension_4_01A6 0,TEMPA,0, Extension_4_01E4(0)
  328.               TAD= Extension_4_01BC(0)
  329.               ' FOOL=0 
  330.             ' SP=0 
  331.              ' UP=0 
  332. Return 
  333. '==================================================================
  334.  DESPERATE:
  335.     LAST= Extension_4_01BC(0)
  336.         LEVER=(LAST-TAD)/4
  337.      If LEVER>600 or LEVER<1 : LEVER=600 : End If 
  338.         If SCX<160 : Add SP,100+LEVER : End If : Rem try and swivel overhead
  339.         If SCX>159 : Add SP,-100-LEVER : End If 
  340.         'Print LEVER; : Screen Swap : Wait Key 
  341.     Return 
  342. '========================================================
  343. TRAIL:
  344. '
  345.  If TRAILOFF=1 Then Return 
  346.  If THRUST<1 Then For X=0 To 45 : TRAILZ(X)=50000 : Next : Return 
  347.   Colour 15,$AAA
  348.    Add MARK,1,0 To 45
  349.    TRAILX(MARK)=WX+Rnd(250)
  350.    TRAILY(MARK)=WY+Rnd(250)
  351.    TRAILZ(MARK)=WZ-70+Rnd(200)
  352. '
  353.    For TR=0 To 35+Rnd(4) : Rem Step 2 
  354.   TX= Extension_4_0474(TRAILX(TR),TRAILY(TR),TRAILZ(TR))
  355.   TY= Extension_4_0480 
  356.   Ink 15
  357.   Plot TX,TY+Rnd(2)
  358.   Next 
  359. Return