{"id":383,"date":"2026-08-22T11:08:20","date_gmt":"2026-08-22T11:08:20","guid":{"rendered":"https:\/\/blogs.scummvm.org\/mohit\/?p=383"},"modified":"2026-08-22T11:08:20","modified_gmt":"2026-08-22T11:08:20","slug":"avalanche","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/mohit\/2026\/08\/22\/avalanche\/","title":{"rendered":"Avalanche: Bugs, Fixes, and Finishing Touches"},"content":{"rendered":"<p>Hello everyone, welcome back. This is the blog for the code changes in the Avalanche engine.<\/p>\n<h5><span style=\"color: #993366\">Crash on Exit<\/span><\/h5>\n<p>The game crashed on exit because <code>Outro::run()<\/code> was writing 350-line graphics onto a 320&#215;200 surface. Calling <code>_vm-&gt;_graphics-&gt;menuRestoreScreen()<\/code> first restores the 640&#215;350 resolution before drawing, preventing the out-of-bounds crash.<\/p>\n<h5><span style=\"color: #993366\">Missing bottom toolbar<\/span><\/h5>\n<p>The in-game bottom toolbar (compass, action icons, inventory) was missing when starting a new game or loading a save because\u00a0<code class=\"whitespace-pre-wrap\">drawToolbar()<\/code>\u00a0was never called during initialization; adding\u00a0<code class=\"whitespace-pre-wrap\">drawToolbar()<\/code>\u00a0in\u00a0<code class=\"whitespace-pre-wrap\">newGame()<\/code>\u00a0and replacing an incorrect\u00a0<code class=\"whitespace-pre-wrap\">drawDirection()<\/code>\u00a0call in\u00a0<code class=\"whitespace-pre-wrap\">loadGame()<\/code>\u00a0forces the toolbar graphics to render immediately.<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-397\" src=\"https:\/\/blogs.scummvm.org\/mohit\/wp-content\/uploads\/sites\/82\/2026\/08\/scummvm-avalanche-00001-1024x557.png\" alt=\"\" width=\"580\" height=\"315\" srcset=\"https:\/\/blogs.scummvm.org\/mohit\/wp-content\/uploads\/sites\/82\/2026\/08\/scummvm-avalanche-00001-1024x557.png 1024w, https:\/\/blogs.scummvm.org\/mohit\/wp-content\/uploads\/sites\/82\/2026\/08\/scummvm-avalanche-00001-300x163.png 300w, https:\/\/blogs.scummvm.org\/mohit\/wp-content\/uploads\/sites\/82\/2026\/08\/scummvm-avalanche-00001-768x418.png 768w, https:\/\/blogs.scummvm.org\/mohit\/wp-content\/uploads\/sites\/82\/2026\/08\/scummvm-avalanche-00001-1536x835.png 1536w, https:\/\/blogs.scummvm.org\/mohit\/wp-content\/uploads\/sites\/82\/2026\/08\/scummvm-avalanche-00001-1200x653.png 1200w, https:\/\/blogs.scummvm.org\/mohit\/wp-content\/uploads\/sites\/82\/2026\/08\/scummvm-avalanche-00001.png 1920w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-396\" src=\"https:\/\/blogs.scummvm.org\/mohit\/wp-content\/uploads\/sites\/82\/2026\/08\/scummvm-avalanche-00000-1024x557.png\" alt=\"\" width=\"580\" height=\"315\" srcset=\"https:\/\/blogs.scummvm.org\/mohit\/wp-content\/uploads\/sites\/82\/2026\/08\/scummvm-avalanche-00000-1024x557.png 1024w, https:\/\/blogs.scummvm.org\/mohit\/wp-content\/uploads\/sites\/82\/2026\/08\/scummvm-avalanche-00000-300x163.png 300w, https:\/\/blogs.scummvm.org\/mohit\/wp-content\/uploads\/sites\/82\/2026\/08\/scummvm-avalanche-00000-768x418.png 768w, https:\/\/blogs.scummvm.org\/mohit\/wp-content\/uploads\/sites\/82\/2026\/08\/scummvm-avalanche-00000-1536x835.png 1536w, https:\/\/blogs.scummvm.org\/mohit\/wp-content\/uploads\/sites\/82\/2026\/08\/scummvm-avalanche-00000-1200x653.png 1200w, https:\/\/blogs.scummvm.org\/mohit\/wp-content\/uploads\/sites\/82\/2026\/08\/scummvm-avalanche-00000.png 1920w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/p>\n<h5><span style=\"color: #993366\">Implementing missing shortcut keys<\/span><\/h5>\n<p>Implemented <code class=\"whitespace-pre-wrap\">Alt+B<\/code>\u00a0(fake spreadsheet boss key),\u00a0<code class=\"whitespace-pre-wrap\">Alt+X<\/code>\u00a0(quit game), and\u00a0<code class=\"whitespace-pre-wrap\">Alt+D<\/code> (secret easter egg message &#8220;Wrong game!&#8221;).<\/p>\n<h5><strong><span style=\"color: #993366\">Crashes During NPC Dialogues<\/span><\/strong><\/h5>\n<p><code class=\"whitespace-pre-wrap\">setRoom()<\/code>\u00a0and\u00a0<code class=\"whitespace-pre-wrap\">getRoom()<\/code>\u00a0crashed with out-of-bounds array access when passed invalid character IDs (like\u00a0<code class=\"whitespace-pre-wrap\">kPeoplePardon<\/code>\u00a0or\u00a0<code class=\"whitespace-pre-wrap\">kPeopleNone<\/code>); adding validation bounds checks (<code class=\"whitespace-pre-wrap\">persId &lt; kPeopleAvalot || persId &gt; kPeopleWisewoman<\/code>) prevents array index overflows on\u00a0<code class=\"whitespace-pre-wrap\">_whereIs[]<\/code>\u00a0and safely defaults unallocated characters to\u00a0<code class=\"whitespace-pre-wrap\">kRoomNowhere<\/code>.<\/p>\n<h5><span style=\"color: #993366\">Spludwick is always missing from the laboratory<\/span><\/h5>\n<p>When entering Spludwick&#8217;s laboratory at the start of the game, Spludwick was missing, making it impossible to interact with him or progress the potion quest properly.<\/p>\n<p><code class=\"whitespace-pre-wrap\">_spludwickAtHome<\/code>\u00a0was initialized to\u00a0<code class=\"whitespace-pre-wrap\">false<\/code>\u00a0instead of\u00a0<code class=\"whitespace-pre-wrap\">true<\/code>, and the original Pascal room count logic checking whether Spludwick was working at home was missing.<\/p>\n<p>Restoring the default\u00a0<code class=\"whitespace-pre-wrap\">true<\/code> initialization and the original room calculation logic <code class=\"whitespace-pre-wrap\">!((_roomCount[kRoomWiseWomans] % 3) == 1))<\/code> \u00a0ensures Spludwick appears reliably in his laboratory.<\/p>\n<h5><span style=\"color: #993366\">Crash w<strong>hen typing password guesses<\/strong><\/span><\/h5>\n<p>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.<\/p>\n<p>The parser loop compared every character\u00a0<code class=\"whitespace-pre-wrap\">_vocabulary[pwdId]._word[j]<\/code>\u00a0against\u00a0<code class=\"whitespace-pre-wrap\">temp[j]<\/code>. If\u00a0<code class=\"whitespace-pre-wrap\">temp<\/code>\u00a0(the player&#8217;s typed word) was shorter than\u00a0<code class=\"whitespace-pre-wrap\">j<\/code>, accessing\u00a0<code class=\"whitespace-pre-wrap\">temp[j]<\/code>\u00a0accessed memory past the string&#8217;s length.\u00a0Adding a bounds check\u00a0<code class=\"whitespace-pre-wrap\">((j &lt; temp.size()) ? temp[j] : '\\0')<\/code>\u00a0safely fails the password match without crashing.<\/p>\n<h5><span style=\"color: #993366\">I<strong>mplementing the Missing &#8220;Golden Slumbers&#8221; Cutscene<\/strong><\/span><\/h5>\n<p>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 <em>&#8220;Golden Slumbers&#8221;<\/em> across the screen as a lullaby before Baron du Lustie falls asleep.<\/p>\n<p>This cutscene was missing in ScummVM.<\/p>\n<h5><span style=\"color: #993366\">Added reusable methods for MOD audio playback<\/span><\/h5>\n<p>Implemented <code class=\"whitespace-pre-wrap\">playMod()<\/code>\u00a0and\u00a0<code class=\"whitespace-pre-wrap\">stopMod()<\/code>\u00a0in\u00a0<code class=\"whitespace-pre-wrap\">SoundHandler<\/code>\u00a0using ScummVM&#8217;s\u00a0<code class=\"whitespace-pre-wrap\">Audio::makeProtrackerStream()<\/code>. It loads the requested\u00a0<code class=\"whitespace-pre-wrap\">.mod<\/code>\u00a0file, creates a ProTracker audio stream, and passes it to ScummVM&#8217;s mixer (<code class=\"whitespace-pre-wrap\">kMusicSoundType<\/code>) for background music playback.<\/p>\n<h5><span style=\"color: #993366\">Impleme<strong>nting the Original Animated Title Screen<\/strong><\/span><\/h5>\n<div style=\"width: 580px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-383-1\" width=\"580\" height=\"427\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/blogs.scummvm.org\/mohit\/wp-content\/uploads\/sites\/82\/2026\/08\/TitleScreen.mp4?_=1\" \/><a href=\"https:\/\/blogs.scummvm.org\/mohit\/wp-content\/uploads\/sites\/82\/2026\/08\/TitleScreen.mp4\">https:\/\/blogs.scummvm.org\/mohit\/wp-content\/uploads\/sites\/82\/2026\/08\/TitleScreen.mp4<\/a><\/video><\/div>\n<h5><span style=\"color: #993366\">Implementing<strong>\u00a0The Sequel Teaser Preview<\/strong><\/span><\/h5>\n<p>Selecting Option 3 (<em>&#8220;Preview&#8230; perhaps&#8230;&#8221;<\/em>) on the main menu was unhooked. Implemented\u00a0<code class=\"whitespace-pre-wrap\">MainMenu::showPreview()<\/code>\u00a0to read\u00a0<code class=\"whitespace-pre-wrap\">preview2.avd<\/code>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-398\" src=\"https:\/\/blogs.scummvm.org\/mohit\/wp-content\/uploads\/sites\/82\/2026\/08\/scummvm-avalanche-00005-1024x557.png\" alt=\"\" width=\"580\" height=\"315\" srcset=\"https:\/\/blogs.scummvm.org\/mohit\/wp-content\/uploads\/sites\/82\/2026\/08\/scummvm-avalanche-00005-1024x557.png 1024w, https:\/\/blogs.scummvm.org\/mohit\/wp-content\/uploads\/sites\/82\/2026\/08\/scummvm-avalanche-00005-300x163.png 300w, https:\/\/blogs.scummvm.org\/mohit\/wp-content\/uploads\/sites\/82\/2026\/08\/scummvm-avalanche-00005-768x418.png 768w, https:\/\/blogs.scummvm.org\/mohit\/wp-content\/uploads\/sites\/82\/2026\/08\/scummvm-avalanche-00005-1536x835.png 1536w, https:\/\/blogs.scummvm.org\/mohit\/wp-content\/uploads\/sites\/82\/2026\/08\/scummvm-avalanche-00005-1200x653.png 1200w, https:\/\/blogs.scummvm.org\/mohit\/wp-content\/uploads\/sites\/82\/2026\/08\/scummvm-avalanche-00005.png 1920w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/p>\n<h5><span style=\"color: #993366\">Implementing <strong>the Info Document Reader<\/strong><\/span><\/h5>\n<p>Selecting Option 4 (&#8216;View the documentation&#8217;) or Option 5 (&#8216;Registration info&#8217;) on the main menu opens the game&#8217;s full text manual (<code class=\"whitespace-pre-wrap\">avalot.doc<\/code>) inside a custom document viewer, matching original DOS\u00a0<code class=\"whitespace-pre-wrap\">viewdocs.pas<\/code>. To recreate this in ScummVM, I implemented\u00a0<code class=\"whitespace-pre-wrap\">MainMenu::showDoc()<\/code>\u00a0to parse and render\u00a0<code class=\"whitespace-pre-wrap\">avalot.doc<\/code>\u00a0directly.&#8221;<\/p>\n<div style=\"width: 580px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-383-2\" width=\"580\" height=\"427\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/blogs.scummvm.org\/mohit\/wp-content\/uploads\/sites\/82\/2026\/08\/InfoDoc.mp4?_=2\" \/><a href=\"https:\/\/blogs.scummvm.org\/mohit\/wp-content\/uploads\/sites\/82\/2026\/08\/InfoDoc.mp4\">https:\/\/blogs.scummvm.org\/mohit\/wp-content\/uploads\/sites\/82\/2026\/08\/InfoDoc.mp4<\/a><\/video><\/div>\n<p>&nbsp;<\/p>\n<p>That was it for the Avalanche engine. Next blog will be about the DOS version of Dungeon Master. Till then, goodbye \ud83d\ude42<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#215;200 surface. Calling _vm-&gt;_graphics-&gt;menuRestoreScreen() first restores the 640&#215;350 resolution before drawing, preventing the out-of-bounds crash. Missing bottom toolbar The in-game bottom toolbar (compass, [&hellip;]<\/p>\n","protected":false},"author":30,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-383","post","type-post","status-publish","format-standard","hentry","category-avalanche-engine"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/mohit\/wp-json\/wp\/v2\/posts\/383","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.scummvm.org\/mohit\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.scummvm.org\/mohit\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/mohit\/wp-json\/wp\/v2\/users\/30"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/mohit\/wp-json\/wp\/v2\/comments?post=383"}],"version-history":[{"count":14,"href":"https:\/\/blogs.scummvm.org\/mohit\/wp-json\/wp\/v2\/posts\/383\/revisions"}],"predecessor-version":[{"id":404,"href":"https:\/\/blogs.scummvm.org\/mohit\/wp-json\/wp\/v2\/posts\/383\/revisions\/404"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/mohit\/wp-json\/wp\/v2\/media?parent=383"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/mohit\/wp-json\/wp\/v2\/categories?post=383"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/mohit\/wp-json\/wp\/v2\/tags?post=383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}