# Patch:Ending sequence (Keen 2)

An ending sequence is a series of events that occur after the main game is completed. It ends with an entry or view of the high scores and a return to the main menu. Each game has its own unique ending sequence. This page lists patches relating to the ending sequence of Keen 2. This sequence starts after Keen has saved all eight cities.

Patches relating to ending sequences in general can be found at Patch:Ending sequence.

The patches on this page are organized chronologically, that is, those that affect things that happen early on in the ending sequence will appear first. Several patches may also be found on other pages.

# Ending Sequence in general

These patches affect the starting of the ending sequence and the ending sequence in general.

## What is needed to win the game

By default the game is won when 8 cities are saved. The number of cities can be altered. Changing the value to 0 wins the game when any level is exited. Note however that if Keen somehow saves more cities than this value he will never be able to win the game. (This will happen if for example it is set to 0 but Keen saves a city.)

The game does this by starting at a certain variable and checking the next 8 to see if they have a value of 1. Each value of 1 is added to a total, and if that total is exactly 8 the game is won.

There are two other repeats of this process; the first occurs when Keen gets a high score; to tell the player how many cities were saved. The second is in the High score screen itself to list the cities saved by each score entry.

### Number of saved cities needed to win

#Number of cities needed to win
%patch $8430 {$9AF4W}    #Start checking here...
%patch $8438 [$08]       #...check next 8 variables to see...
%patch $8432 [$01]       #...if they're 1...


# Leaving Mothership textbox sequence

This is the first part of the ending sequence proper and involves Keen's rocket leaving the Vorticon Mothership and heading towards earth.

## Mothership location and level

These patches affect where the Mars Map sequence of text boxes occur. By default a special level is used (level 81), but any other level can be used.

The position of events is 0,0 and as such cannot be altered.

### Keen 2

#Level used


## Mothership textbox BWB rocket sprite

Keen's BWB rocket appears alongside the textbox and the moves off to Earth. Each of these requires a different sprite. The moving rocket is considered after the first text box patches.

The position of the BWB is treated rather uniquely; both x and y position, in tiles are given, however they must be worked out in a very odd way. There are two values for each, the first is a number of tiles * $10, the second a number of tiles that needs to be multiplied by$10. As an example the vertical location of $03 tiles down is$30/$10 +$00 * $10 =$03 + $00. If this is confusing, then just fiddling with the values until a desired result is obtained works. ### Keen 2 #Sprites shown %patch$51B6 [$84] #Rocket sprite used as window text appears %patch$52C9 [$84] #Rocket sprite used for rocket going to and landing on Earth #Sprite position coordinates %patch$51A5 [$70] #x position (x10) %patch$51AA [$00] #x position (Total 0-7 =$07 tiles)
%patch $51AF [$30]     #Y position (x10)


## Mothership text box and text

These patches relate to the size, position and content of the text box that appears at the start of the Mothership sequence. The size and location of the box are given by four variables, each defining one corner of the text box. The box contains six lines of text. (See Patch:Text patches.) There is a significant pause after the text has finished writing to allow the text to be read.

### Keen 2

#Mothership textbox:
%patch $51CF [$0018W] #Top
%patch $51D3 [$0024W] #Bottom
%patch $51D7 [$0011W] #Right side
%patch $51DB [$0004W] #left side
%patch $51E8 [$2A21W] #First line
%patch $51F1 [$2A42W] #Second line
%patch $51FA [$2A62W] #Third line
%patch $5203 [$2A80W] #Fourth line
%patch $520C [$2A9FW] #Fifth line
%patch $5215 [$2ABAW] #Sixth line

%patch $521E [$012CW]

#Text
%patch $1A1A1 "After disabling the weaponry of"$00
%patch $1A1C2 "the Vorticon Mothership, Billy"$00
%patch $1A1E2 "heads for earth. Even great"$00
%patch $1A200 "space heroes need a nap after"$00
%patch $1A21F "defeating a vicious horde"$00
%patch $1A23A "of violence-bent aliens!"$00


# Flight to Earth sequence

This part of the sequence deals with Keen's BWB heading from the textbox location to Earth, moving down and right.

## BWB rocket sprite and speed

This works similarly to the textbox sprite and in fact starts from the same position as the still BWB.

### Keen 2

#Sprites shown
%patch $51B6 [$84] #Rocket sprite used as window text appears
%patch $52C9 [$84] #Rocket sprite used for rocket going to and landing on Earth


### No BWB rocket moving to Earth

This patch removes the BWB heading towards Earth, while the screen moves, nothing is shown. Combined with the patch in the section above the BWB can be totally removed from the map level.

### Keen 2

#No BWB rocket moving to Earth
%patch $52D8$90 $90$90


## BWB speed and movement

By default the BWB moves at a rate of approximately 2 tiles right to every tile down. This happens over $78 ticks. There are minor speed adjustments made tot his 2:1 rate, for example the rightwards rate is 2 tiles 8.5 pixels while downwards is 1 tile 3.5 pixels. Fiddling with the 'minor speed adjustments' can help position the BWB very accurately at the end of its journey. The screen also moves when the BWB is at a certain location. By default this is when the BWB is at or below-right of 9,13 tiles from the top left of the screen. Each position value comes in two parts; the first sets the sign;$0001W is 'below' and $FFFFW is 'above'. (Only the latter really works.) The second part controls the position in pixels. For example$90 is 144 pixels or 9 16-pixel tiles.

Finally the length of the rocket's journey is controlled by a single variable. It is very nearly as long as possible by default ($7F is the maximum length of journey allowed.) ### Keen 2 #How Keen's rocket moves %patch$5253 [$0078W] #How often Keen's rocket moves right %patch$525D [$0002W] #How much the rocket moves right each time (Tiles) %patch$5261 [$88] #Minor speed adjustment %patch$527B [$0078W] #How often Keen's rocket moves down %patch$5285 [$0001W] #How much the rocket moves right each time (Tiles) %patch$5289 [$38] #Minor speed adjustment #Where screen is relative to BwB (Default$FFFF90 : $FFFFB0) %patch$52A9     [$90] #H (Left of ship by$70)
%patch $52AB [$FFFFW]
%patch $52BD [$D0] #H (Above ship by )
%patch $52BF [$FFFFW]

#Journey length
%patch $52E4 [$78]


# Mothership leaving sequence

These patches relate to the Vorticon Mothership leaving. This includes moving the screen to a new location in the level, a textbox and a sprite moving. Following this is the 'Keen's house' sequence.

## Mothership sequence location

### Keen 2

#Sprites shown
%patch $5326 [$48] #Mothership still
%patch $53AA [$48] #Mothership moving

#Ship speed
%patch $539A [$0100W] #Horizontal
%patch $53A3 [$0100W] #Vertical

#Length of ship journey
%patch $53C5 [$78]


# Keen's House sequence

This covers everything from when the FINALE.CK2 image is loaded to the 'to be continued' text box. All of it is shown over the finale image.

## Finale and endtext level

Interestingly the level changes after the Vorticon Mothership sequence to level 81, the same level it was already changed to. However this means that a second level can be used when the Game Over\High Score window appears after the endtext.

### Keen 2

#Finale level


## Text boxes

Text boxes appear during the sequence. Each one needs its four corners defined, where its text is read from, the text itself and the time visible before it is removed. When a textbox is removed it leaves behind a white space.

Values for the locations of corners are in 8x8 blocks. A textbox must be wide enough to contain the text in it and its bottom\right values must be larger than its top\left values. The width\height in letters\8x8 blocks is obviously (top\left) - (right\bottom) Text boxes evidently involve Text patches



### Second textbox

#Size:
%patch $532D [$18]    #Bottom
%patch $5331 [$1D]    #Right side
%patch $5335 [$10]    #Top
%patch $5339 [$04]    #Left
%patch $5482 [$0078W] #Time visible

%patch $5443 {$2BB3W}
%patch $544C {$2BCDW}
%patch $5455 {$2BE7W}
%patch $545E {$2BFAW}
%patch $5467 {$2C0FW}
%patch $5470 {$2C27W}
%patch $5479 {$2C3DW}

#Text:
%patch $1A333 "Wonderful, Mother. That"$00
%patch $1A34D "will give me time to rid"$00
%patch $1A367 "the Galaxy of the"$00
%patch $1A37A "Vorticon menace and"$00
%patch $1A38F "discover the secret of"$00
%patch $1A3A7 "the mysterious Grand"$00
%patch $1A3BD "Intellect!"$00

#Stop second textbox appearing
%patch $542C$EB $5F #Stop first AND second textbox appearing %patch$53EF $E9$009BW


### Third textbox

#Size:
%patch $548E [$17]    #Bottom
%patch $5492 [$1D]    #Right side
%patch $5496 [$10]    #Top
%patch $549A [$04]    #Left
%patch $54C8 [$0078W] #Time visible

%patch $54A4 {$2C49W}
%patch $54AD {$2C5DW}
%patch $54B6 {$2C77W}
%patch $54BF {$2C8FW}

#Text:
%patch $1A3C9 "OK, hon, but you'd"$00
%patch $1A3DD "better have a nourishing"$00
%patch $1A3F7 "vitamin fortified bowl"$00
%patch $1A40F "of Sugar Stoopies first."$00

#Stop third textbox appearing
%patch $548D$EB $44 #Stop first, second AND third textbox appearing %patch$53EF $E9$00E1W


### Fourth textbox

#Size:
%patch $54D4 [$14]    #Bottom
%patch $54D8 [$10]    #Right side
%patch $54DC [$12]    #Top
%patch $54E0 [$04]    #Left
%patch $54F3 [$0078W] #Time visible

%patch $54EA {$2CA9W}

#Text:
%patch $1A429 "OK, mom..."$00

#Stop fourth textbox appearing
%patch $54D3$EB $29 #Stop first to fourth textboxes appearing %patch$53EF $E9$010CW


### Fifth textbox

#Size:
%patch $54D4 [$05]    #Bottom
%patch $54D8 [$20]    #Right side
%patch $54DC [$03]    #Top
%patch $54E0 [$0C]    #Left
%patch $54F3 [$0190W] #Time visible

%patch $5515 {$2CB4W}

#Text:
%patch $1A429 "TO BE CONTINUED...."$00

#Stop fifth textbox appearing
%patch $54FE$EB $26 #Stop ALL textboxes appearing %patch$53EF $E9$0134W


# End text

This is the final screen, appearing over the Keen's hosue level. It is a text window and covered under Patch:Large text files. When this is exited the game over will appear and Keen can possibly enter his name into the high scores.

The end text window appears with a specific sound (which can be disabled). It stretches across the screen but does have a specific height. By default the endtext window is as high as the screen, blocking the level behind it.

Finally the endtext can be patched as an external file, like in Keen 1.

### Keen 2

#Endtext:
%patch $5545$16 $00 #Window height when still %patch$5566 $16$00 #Window height when scrolling

#Sounds
%patch $555A$29     #Endtext window appears sound
%patch $5559$EB $07 #Endtext window appears sound disabled #Patch endtext %patchfile$15844 ENDTEXT.CK2