Categories
Avalanche engine

Avalanche: Bugs, Fixes, and Finishing Touches

Hello everyone, welcome back. This is the blog for the code changes in the Avalanche engine.

Crash on Exit

The game crashed on exit because Outro::run() was writing 350-line graphics onto a 320×200 surface. Calling _vm->_graphics->menuRestoreScreen() first restores the 640×350 resolution before drawing, preventing the out-of-bounds crash.

Missing bottom toolbar

The in-game bottom toolbar (compass, action icons, inventory) was missing when starting a new game or loading a save because drawToolbar() was never called during initialization; adding drawToolbar() in newGame() and replacing an incorrect drawDirection() call in loadGame() forces the toolbar graphics to render immediately.

Implementing missing shortcut keys

Implemented Alt+B (fake spreadsheet boss key), Alt+X (quit game), and Alt+D (secret easter egg message “Wrong game!”).

Crashes During NPC Dialogues

setRoom() and getRoom() crashed with out-of-bounds array access when passed invalid character IDs (like kPeoplePardon or kPeopleNone); adding validation bounds checks (persId < kPeopleAvalot || persId > kPeopleWisewoman) prevents array index overflows on _whereIs[] and safely defaults unallocated characters to kRoomNowhere.

Spludwick is always missing from the laboratory

When entering Spludwick’s laboratory at the start of the game, Spludwick was missing, making it impossible to interact with him or progress the potion quest properly.

_spludwickAtHome was initialized to false instead of true, and the original Pascal room count logic checking whether Spludwick was working at home was missing.

Restoring the default true initialization and the original room calculation logic !((_roomCount[kRoomWiseWomans] % 3) == 1))  ensures Spludwick appears reliably in his laboratory.

Crash when typing password guesses

Typing a password guess that was shorter than the actual secret password (e.g. typing a 3-letter word when a 6-letter password was expected) caused the game to crash.

The parser loop compared every character _vocabulary[pwdId]._word[j] against temp[j]. If temp (the player’s typed word) was shorter than j, accessing temp[j] accessed memory past the string’s length. Adding a bounds check ((j < temp.size()) ? temp[j] : '\0') safely fails the password match without crashing.

Implementing the Missing “Golden Slumbers” Cutscene

When Avy hands the lute to Geida in castle Cardiff, the original game displays an animated blue opening-box transition and scrolls the poem lyrics of “Golden Slumbers” across the screen as a lullaby before Baron du Lustie falls asleep.

This cutscene was missing in ScummVM.

Added reusable methods for MOD audio playback

Implemented playMod() and stopMod() in SoundHandler using ScummVM’s Audio::makeProtrackerStream(). It loads the requested .mod file, creates a ProTracker audio stream, and passes it to ScummVM’s mixer (kMusicSoundType) for background music playback.

Implementing the Original Animated Title Screen
Implementing The Sequel Teaser Preview

Selecting Option 3 (“Preview… perhaps…”) on the main menu was unhooked. Implemented MainMenu::showPreview() to read preview2.avd.

Implementing the Info Document Reader

Selecting Option 4 (‘View the documentation’) or Option 5 (‘Registration info’) on the main menu opens the game’s full text manual (avalot.doc) inside a custom document viewer, matching original DOS viewdocs.pas. To recreate this in ScummVM, I implemented MainMenu::showDoc() to parse and render avalot.doc directly.”

 

That was it for the Avalanche engine. Next blog will be about the DOS version of Dungeon Master. Till then, goodbye 🙂

 

Leave a Reply

Your email address will not be published. Required fields are marked *