'                                Henry's House 
'
'                           END SEQUENCE SOURCE CODE 
'
'                          by : Gurmita & Sucha Singh
'
'----------------------------------------------------------------------------- 
' NOTE:This source code can not be Run through the AMOS editor as some files 
' need to be copied into memory which is done in the startup-sequence of the 
' full Game(see Intro source code).
'
' The following source code displays the end sequence animation fading between 
' the 3 scenes and then scrolls the credits into view finally fading the 
' 'State Of The Art' logo into view. 
'
' Memory Banks Used: 
'  3 - Music - Endseq Music
' 10 - Chip Data - First part of sequence
' 11 - Chip Data - Secound part of sequence
' 12 - Chip Data - Third part of sequence
' 13 - Pac Pic - Credit picture
' 14 - Pac Pic - Insert Disc2 picture
'
' Variables Used:
' SC - Your Score. 
' N  - Total number of frames for an animation.
'
'-----------------------------------------------------------------------------   
'
' Closes the Amos editor to save memory. 
Close Editor 
'
' Makes variable Global so the whole program can access it.
Global SC
'
'----------------------------------------------------------------------------- 
'Calls the ENDSEQ procedure
_ENDSEQ
'
'----------------------------------------------------------------------------- 
'
' Reseaves the Score and plays the end-sequence animation from memory then 
' calls the CREDIT and CHANGE_DISK procedures. 
Procedure _ENDSEQ
   '
   ' Reseaves the command line$ then takes the score out of it. 
   S$=Left$(Command Line$,6)
   ' Converts the Score string into a variable. 
   SC=Val(S$)
   '
   ' Opens up screen then hides screen and mouse pointer. 
   Screen Open 0,320,200,16,Lowres : Screen Hide 0
   Curs Off : Flash Off : Cls 0 : Hide On 
   Screen 0
   ' Sets directory to Disk1. 
   Dir$="Henry's_House:"
   '
   '----------------------------  Scene 1 ------------------------------------
   ' Sets the total number of frames in the first Scene.
   N=12
   '
   ' Displays the Screen,sets where the animation is coming from ,Bank 10,
   ' its channel number(1) and screen number(0).  
   Screen Show 0
   P=Frame Play(10,1,0)
   '
   ' Double Buffers the screen so the animation dos'nt flicker. 
   Double Buffer 
   '
   ' For next' loop is used to flick through each frame one at a time with 'N'
   ' holding the total number of Frames and 'X' holding the individual frame
   ' number which increases until it matches 'N' and finishes the loop. 
   For X=2 To N-2
      If X=2 Then Wait 30
      P=Frame Play(P,1)
      Screen Swap 
      Wait Vbl : Wait Vbl : Wait Vbl : Wait Vbl 
   Next X
   '
   ' Pauses on the open door then fades the screen to black.
   Freeze 
   Wait 30
   Fade 1 : Wait 15
   '
   '----------------------------  Scene 2 ------------------------------------
   ' Sets the total number of frames in the secound Scene.
   N=48
   '
   ' Displays the Screen,sets where the animation is coming from ,Bank 11,
   ' its channel number(1) and screen number(0).
   Screen Show 0
   F=Frame Play(11,1,0)
   '
   Double Buffer 
   '
   ' Uses the same method of animation as scene one.
   For X=2 To N-2
      F=Frame Play(F,1)
      Screen Swap 
      Wait Vbl : Wait Vbl : Wait Vbl : Wait Vbl 
   Next X
   '
   ' Pauses on Henry then fades the screen to black.
   Freeze 
   Wait 20
   Fade 1 : Wait 15
   '
   '----------------------------  Scene 3 ------------------------------------
   ' Sets the total number of frames in the third Scene.
   N=30
   '
   ' Displays the Screen,sets where the animation is coming from ,Bank 12,
   ' its channel number(1) and screen number(0).
   Screen Show 0
   R=Frame Play(12,1,0)
   '
   Double Buffer 
   '
   ' Uses the same method of animation as scene one.
   For X=2 To N-2
      If X=2 Then Wait 15
      R=Frame Play(R,1)
      Screen Swap 
      Wait Vbl : Wait Vbl : Wait Vbl : Wait Vbl 
   Next X
   '
   ' Pauses on the open trunk then fades the screen to black. 
   Wait 20
   Fade 2 : Wait 30
   '
   ' Close screen and erase the 3 memory banks which contain the animations.
   Screen Close 0
   Erase 10 : Erase 11 : Erase 12
   '
   ' Calls the relevant procedures. 
   _CREDITS
   _CHANGE_DISC
   '
End Proc
'
' Scrolls the credits into view then fades the logo into view and waits until
' you have pressed the Fire button to exit.
Procedure _CREDITS
   '
   ' Play the end-sequence music. 
   Music 1
   Wait 15
   '
   ' Unpack the Credit picture to screen 1,hide it then set the display.
   Unpack 13 To 1 : Screen Hide 1
   Screen Display 1,130,50,320,200
   ' Fade only the logo colours to black. 
   Fade 1,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,,,,,, : Wait 15
   '
   ' Show Credit screen.
   Screen 1
   Screen Show 1
   '
   ' Small Loop which scrolls the screen up then exits. 
   Repeat 
      Inc Y
      Screen Offset 1,0,Y
      Wait Vbl : Wait Vbl 
   Until Y=200
   '
   ' Pause then fade the logo colours to normal making the logo appear. 
   Wait 20
   Fade 2,$0,$8BD,$BDE,$FFF,$6AB,$59A,$379,$268,$156,$46,,,,,,
   '
   ' Small loop which exits once you have pressed the Fire button.
   Repeat 
   Until Fire(1)=-1
   Fade 2 : Wait 30 : Cls 0
   '
End Proc
'
' Asks for Disk2 then fades the screen,clears the memory and loads the game. 
Procedure _CHANGE_DISC
   '
   ' Unpacks bank 14 to screen 1 then hides screen 1 while fadeing picture to 
   ' black. 
   Unpack 14 To 1 : Screen Hide 1 : Fade 1 : Wait 15
   '
   ' Checks for an error and goes to HELP: if one is detected.
   On Error Goto HELP
   '
   ' Creates an error. This stops the system message popping up.
   Error 86
   '
   ' Sets directory to Disk2 and fades screen 1.
   Dir$="Henry's_HouseD2:"
   Screen 1 : Fade 1 : Wait 15
   '
   ' Prepare a string to hold the score string. 
   A$="      "
   ' Convert the score to a string. 
   S$=Str$(SC)
   ' Place score string into 'A$' then place it in the command line$. 
   Left$(A$,6)=S$
   Command Line$=A$
   '
   ' Closes the screen,erases all banks to clear the memory for next program
   ' then runs the Title program. 
   Screen Close 1
   For B=1 To 15 : Erase B : Next B
   Run "HenryGame/Title"
   '
   HELP:
   '
   ' Small Loop to check if Disk 2 has been inserted.The vaiable 'D' is used
   ' to store a true(-1) or false(0) value. 
   Do 
      ' If Disk2 has been inserted then the dirctory is set to Disk2, D=1 and
      ' exits out of loop. 
      If Exist("Henry's_HouseD2:")=-1 Then Dir$="Henry's_HouseD2:" : D=1 : Exit 
      '
      ' If Disk2 has not been inserted it fades screen 1 into view which asks
      ' you to 'insert Disc2', D=0 and exits out of loop.
      If Exist("Henry's_HouseD2:")=0
         Screen Show 1
         Fade 1,$0,$8BD,$BDE,$FFF,$6AB,$59A,$379,$268,$156,$46,$E52,$E82,$FA3,$FC4,$FE5,$0
         Wait 15
         D=0 : Exit 
      End If 
   Loop 
   '
   ' If D=1 then the program jumps to the line after Error86 and continues,if 
   ' D<>1 ie=0 then the program jumps to Error86 then back to the loop. 
   If D=1 Then Resume Next Else Resume 
   '
End Proc
