Skip to main content

The ending

The engine in ten minutes · The game loop › How the game ends · Loading, failures and the end of the game › The end of the game · Overlay 256

In brief​

When the final opponent dies on level 16, the game writes FINAL.SAV, then plays the ending: an animated story of 13 pictures and 20 texts with music, the scrolling credits, and a last picture showing the portraits of the party. The ending cannot be cut short. It stays on the last picture until the player presses Escape, then the program returns to DOS. Along the way it writes the credits to the file CREDITS.TXT. It changes nothing in the game: it only reads which characters are present and their portraits.

The whole ending is played by overlay 256. Pictures are CPS files; durations are counted in ticks of the game's free-running counter, 18.2 per second.

How it works​

The ending is built from the same kinds of steps as the introduction, with its own pictures, animation lists and texts:

StepWhat happens
Load a sceneA picture is loaded into a work page; the shapes it holds are cut out for later animations.
ShowThe 304 × 128 picture area of the work page is copied to (8, 8) on the screen.
DissolveThe picture area is revealed dot by dot through the pixel dissolve.
Run an animationOne of 21 animation lists: blocks of a picture copied to the screen, shapes drawn, sound effects, each with its delay.
Print a textA text is centred in the window below the picture.
Fade the textThe text fades out and its window is cleared.
WaitA number of ticks.
Wait for the musicWith sound driver 1 only, until the music reaches the next of five markers.
Palette fadeIn mode 3, the palette moves step by step towards another while the sequence goes on.

The sequence​

Animations are given by their list number.

#PicturesSteps
1—The credits are written to CREDITS.TXT; the eight palettes FINALE_0 to FINALE_7 and the sound file FINALE1 are loaded; the screen is cleared.
2DRAGON1, DRAGON2DRAGON1 appears after 18 ticks and sound 1 starts the music; DRAGON2 serves as a source of blocks. Animations 0, 0, 2, 2, 2, 1, 2, 2 · text 0 with animation 2 seven times · music marker 1.
3DRAGON1Text 1 with animations 4 and 2 · texts 2 to 8, each with three to five runs of animation 5 and two of animation 2; animation 6 after text 2.
4HURRY1, HURRY2HURRY1 shown; HURRY2 serves for its shapes · texts 9 to 11 with animations 7, 8 and 9 and waits of 18 or 36 ticks.
5MAGIC, DESTROY0, DESTROY3, DESTROY2MAGIC serves for its shapes · marker 2 · the screen is cleared and DESTROY0 shown · text 12 for 90 ticks · marker 3 · sound 7 · animations 10 to 15 and 11 while the palette fades towards FINALE_3, then FINALE_1 · texts 13 and 14 for 72 ticks each · marker 4 · sound 7 · animations 10, 13, 14, 12 and 16 to 18 while the palette fades towards FINALE_4 · text 15 while it fades towards FINALE_5, twice as fast · sound 11.
6THANKSMarker 5 · sound 6 · THANKS dissolves in · texts 16 to 19 with animations 19 and 20 and sounds 11 and 12.
7DESTROY1Sound 6 · DESTROY1 dissolves in · sounds 12 and 11 in turn.
8CreditsCREDITS3 and CREDITS2 are loaded for their pictures · FINALE2 is loaded and sound 1 starts its music · the credits scroll over DESTROY1 · wait 90 ticks.
9HEROESIn mode 3 the screen fades to black · the screen is cleared · HEROES with the portraits (below) fills the screen and fades in · Escape ends the ending.

Texts 0, 1 and 12 to 15 use colour 10, the others colour 15. The 20 texts are stored in the executable; three of them have more than one line.

What the scenes show​

The numbers are those of the sequence above; the texts are paraphrased, not quoted.

#On screen
2A great red dragon lies on the floor of a hall. It stirs: its eye opens, its jaws open and close, green blood drips from its mouth. The text says that Dran has been defeated.
3Khelben appears beside the dragon in a burst of sparkling light, opens his arms to greet the party and speaks: he did not know that Dran was a dragon, centuries old; Dran's power is gone, but Darkmoon remains a source of evil with many minions, and the party must leave.
4A close-up of Khelben, the dragon behind him: he speaks, blinks, and his hand comes in from the left to point the way. His forces will destroy the place.
5Outside, the Temple Darkmoon on its hill under a darkened sky, with three white-robed mages around it. The mages raise their arms and send lightning at the temple; lightning crackles over its walls while the temple glows blue and darkens again. The temple flickers, turns transparent and vanishes, and the light of day returns.
6Khelben in close-up in front of the empty hill: he speaks and blinks as he thanks the party.
7–8The empty hill, over which the credits scroll.
9The party's portraits on the last picture.

What each animation list shows​

Blocks are copied from the work picture named in the table. In scene 5, lists 10 to 16 take the mages and the lightning from DESTROY2 and put the temple back from DESTROY3 after each lightning, then draw the crackles from MAGIC.

ListPictureOn screen
0, 1DRAGON2Sound 4: the dragon's eye opens; sound 5: its jaws open and close; then the eye closes again. List 1 is slower and leaves out one frame.
2DRAGON2Green blood drips from the dragon's mouth, in three frames.
3—The same drip with part of the dragon put back. The sequence never runs it.
4DRAGON2Sound 6: sparkles gather and Khelben appears, standing by the dragon.
5DRAGON2Khelben's face moves as he speaks, while the blood drips.
6DRAGON2Khelben opens his arms.
7HURRY2Khelben speaks: five mouth frames.
8HURRY2Khelben blinks.
9HURRY2 shapesKhelben's hand slides in from the left edge and stops, pointing.
10DESTROY2The three mages raise their arms; sound 8; lightning leaves their hands.
11DESTROY2, DESTROY3The mages' lightning goes on; the temple is put back.
12–15DESTROY2, DESTROY3, MAGICLightning from the mages strikes the temple, and crackles of lightning cover it in turn (sounds 15 and 9).
16DESTROY3, MAGICOnly the crackles over the temple, three times with sound 15.
17DESTROY3The temple flickers between solid, transparent and gone; sound 10 halfway.
18DESTROY3The same flicker, ending on the empty hill.
19THANKSKhelben speaks: six mouth frames.
20THANKSKhelben blinks.

The sequence calls the animation player 118 times, always with a fixed list number; list 3 is never among them. In mode 3 the palette fades of scene 5 make the light change: the scene starts dark with a grey temple; FINALE_3 and FINALE_4 turn the temple bright blue, FINALE_1 dims it again, and FINALE_5, close to the first palette of the ending, brings back daylight after the temple has gone.

The credits​

The credits text is stored in the executable: 281 lines, most of them empty, with 59 lines of text, 3 lines in the small font and 8 pictures cut from CREDITS2 and CREDITS3. The lines scroll up inside the picture area, 2 pixels every 2 ticks, over the picture that was on screen. Each text line is centred and drawn twice, in colour 12 one pixel down and left as a shadow, then in colour 240. Lines are spaced by their height plus a quarter. The scroll ends when the text is exhausted and its last line reaches the bottom of the area.

At the very start of the ending, the same text is written to the file CREDITS.TXT in the game directory, replacing any older file. The game never reads that file.

The last picture​

HEROES is drawn full screen. On it, the portrait of every character present in the party is drawn at a fixed place:

CharacterPosition
1(80, 80)
2(208, 80)
3(80, 144)
4(208, 144)
5(144, 80)
6(144, 144)

Characters 5 and 6 also get a frame taken from CREDITS2, 16 pixels up and left of the portrait. A character only needs to be present: dead characters are drawn too. Their names are not shown. The picture then waits until the Escape key is pressed; other keys are ignored. The ending's graphics are freed, the screen is cleared and the program returns to DOS.

At start-up the game places the first character's portrait in the memory of work page 7, after the dungeon tiles, the script buffer and some colour tables, 62,788 bytes from its start. The ending loads the 64,000-byte DESTROY2 picture into that same page, which would cover the first 1,212 of the portrait's 1,400 bytes. So, before the ending starts, the game looks for the character whose portrait is still at that place — the first character unless the party was reordered — and moves the portrait to a block of its own. The last picture then shows it intact.1

Music and sounds​

FINALE1 holds the music of the story and FINALE2 that of the credits and the last picture; sound 1 starts each, and sound 0 is played before each file is loaded and at the very end. With sound driver 1, five waits hold the story until the music reaches its markers; with other sound settings these waits are skipped. With the PC speaker or the Tandy sound chip there is no music: sound 1 is 0 in both .SND files, FINALE1.SND plays some of the story's sound effects and every entry of FINALE2.SND is 0, so the credits are silent. The markers are set by the first voice of the tune in FINALE1.ADL, at these times from the start of the music, counted in driver ticks of 1/72.8 second:2

Marker12345
Ticks133459816429811310158
Seconds18.382.188.3111.4139.4

The FINALE1 tune ends 11,469 ticks (157.4 seconds) after it starts, and the FINALE2 music of the credits lasts 13,745 ticks (188.7 seconds). A wait for a marker that has already passed returns at once. Sound effects come from the animation lists (sounds 4, 5, 6, 8, 9, 10 and 15) and from the sequence itself (sounds 6, 7, 11 and 12).

Display modes​

Mode 3 (VGA)Other modes
PaletteFINALE_0, then FINALE_2 from MAGIC on, then the palette of HEROESFINALE_6, then FINALE_7 from MAGIC on
Palette fades during the destructionYes, towards FINALE_3, FINALE_1, FINALE_4 and FINALE_5No
TextsFade outDrawn in colour 15 and cleared
Before the last pictureFade to black, then fade inShown at once

The dissolves, animations and credits are the same in every mode.

The fade to black after the credits and the fade-in of the last picture take a speed n, 10 and 18. The game measures d, the largest difference between a colour component of the current palette and of the target, then repeats one step until the palette reaches the target:

  1. move every component towards the target by at most max (1, ⌊ d / n⌋);
  2. set the palette;
  3. wait until the game's tick counter has advanced by ⌊ k × ⌊256 n / d⌋ / 256⌋ since the fade began, k being the number of steps done.

The step size spreads the fade over about n steps, and the wait gives each step n / d of a tick, so the fade lasts about n² / d ticks rather than n. With the shipped palettes d is 63: the fade to black takes 11 steps within about one tick (0.05 s), and the fade-in 21 steps in about 5 ticks (0.27 s); consecutive steps that fall within the same tick follow each other at once.3

Details and edge cases​

  • The animation lists have no palette flashes and no shape fades: the commands that would do them are present but unused or empty.

Anomalies​

Anomaly

The ending cannot be skipped. The ending keeps a skip flag that every step tests, as the introduction does, but nothing ever sets it: no key shortens the ending. Keys pressed meanwhile stay queued and are discarded when the last picture appears, which then waits for Escape. A faithful reimplementation plays the ending in full and ends it only on Escape at the last picture. (ANOMALY-93)

Anomaly

Bug: removing a picture from the credits writes into the picture's data. When a picture line leaves the top of the credits, the routine restores a line ending through the line's pointer, which for a picture line has been replaced by the picture's shape pointer: a carriage return is written into the shape instead of the text. Nothing visible follows (inferred): each of the eight pictures appears once, is not drawn again and is freed. A reimplementation does not need to reproduce it. (ANOMALY-94)

Anomaly

The credits stop 8 pixels early. The end test compares the last line's position, counted inside the window, with the window's bottom counted on the screen, so the scroll stops while the last line is still 8 pixels below the picture area. With the shipped text the last lines are empty, so nothing is missing (inferred). (ANOMALY-95)

Sources​

Footnotes​

  1. Write FINAL.SAV, which makes the copy, the start-up place of the portrait, the page 7 buffer and load a scene. ↩

  2. Counted by running the AdLib driver of START.EXE on FINALE1.ADL and FINALE2.ADL in a processor emulator, with the sound card ports intercepted; the tick rate follows from the driver's timer set-up. ↩

  3. Fade the palette, one palette fade step and the free-running counter; the largest differences come from the reference FINALE_*.PAL and HEROES.CPS palettes of the file inventory. ↩