{"id":114,"date":"2025-08-04T16:10:10","date_gmt":"2025-08-04T16:10:10","guid":{"rendered":"https:\/\/blogs.scummvm.org\/alikhan\/?p=114"},"modified":"2025-08-04T16:10:10","modified_gmt":"2025-08-04T16:10:10","slug":"week-9-macventure-iii","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/alikhan\/2025\/08\/04\/week-9-macventure-iii\/","title":{"rendered":"Week 9: MacVenture III"},"content":{"rendered":"<p>Another week spent on improving and finishing the MacVenture engine. In the last week I focused on improving things that happen after the winning the game, i.e, loading diploma window &amp; dialog, implementing &#8220;Clean\/Mess up&#8221; functions. I also fixed the bitmap problem I had with with a few items in <em>Uninvited<\/em> game. Lastly, I spent time fixing the resize button and porting the leftover methods from the original codebase.<\/p>\n<p>I started the week with adding support for the diploma window. There was already a pointer variable in the codebase, but until before I did not know what kind of diploma it was referring to. The diploma we are talking about here is the certificate you get after completing the games.<\/p>\n<p>To implement it, a first added another constructor for the ImageAsset class, as the format for the diploma image was a little different from the rest of images. Once that was done, the diploma image already started showing:<\/p>\n<figure id=\"attachment_117\" aria-describedby=\"caption-attachment-117\" style=\"width: 300px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-117 size-medium\" src=\"https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/08\/scummvm-shadowgate-1-00001-300x187.png\" alt=\"\" width=\"300\" height=\"187\" srcset=\"https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/08\/scummvm-shadowgate-1-00001-300x187.png 300w, https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/08\/scummvm-shadowgate-1-00001-1024x637.png 1024w, https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/08\/scummvm-shadowgate-1-00001-768x478.png 768w, https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/08\/scummvm-shadowgate-1-00001-1200x746.png 1200w, https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/08\/scummvm-shadowgate-1-00001.png 1283w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><figcaption id=\"caption-attachment-117\" class=\"wp-caption-text\">Diploma after completing Shadowgate<\/figcaption><\/figure>\n<p>After that, I needed to add the dialog that had with &#8220;Print&#8221; and &#8220;Exit&#8221; buttons. There was already a Dialog class for that, however only with prebuilt options. Similarly, I added the constructor for this, however, the text was a little off. To mitigate the issue, I added an additional MacText text so that line wrapping can be easily handled. Once that was added the dialog at the bottom started showing correctly:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-118\" src=\"https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/08\/scummvm-shadowgate-1-00003-300x197.png\" alt=\"\" width=\"300\" height=\"197\" srcset=\"https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/08\/scummvm-shadowgate-1-00003-300x197.png 300w, https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/08\/scummvm-shadowgate-1-00003-1024x672.png 1024w, https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/08\/scummvm-shadowgate-1-00003-768x504.png 768w, https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/08\/scummvm-shadowgate-1-00003-1200x787.png 1200w, https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/08\/scummvm-shadowgate-1-00003.png 1296w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>After that I started fixing the bug where certain items (charm and statue) in Uninvited game were incorrectly displayed:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-115\" src=\"https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/08\/scummvm-uninvited-00002.png\" alt=\"\" width=\"299\" height=\"201\" \/><\/p>\n<p>In fact, you can see the issue in one of the images in the previous <a href=\"https:\/\/blogs.scummvm.org\/alikhan\/2025\/07\/28\/week-8-macventure-ii\/\">post<\/a>. For debugging, I first identified the object id of the item, then looked how the image was loaded. The problem was in <code>ImageAsset::decodePPIC0()<\/code> method, in particular, in the section where 32 bits were read and then bitshifted to the right, until most significant byte was taken. At first I thought the problem was that <code>BitStream32BEMSB<\/code> which was used here was behaving a little different from the GFile class in the original, and because of that these artifacts were happening. And indeed, in the original codebase, the position of the stream did not advance right away after <code>getBits()<\/code> was called, but was incrementing the internal variable and advanced the position only after that variable was greater than 0xa. I thought maybe I should wrap BitStream template inside the custom class to imitate the behavior of the original code. However, after thinking a little more and checking the <code>walkHuff()<\/code> method, where similar thing was happening, I realized than none of that actually needed. <code>BitStream32BEMSB<\/code> was advancing stream position correctly in the first place, so the only thing which was needed was to read the first 16 bits, and skip the other half. And indeed, this two line change fixed the issue:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-116\" src=\"https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/08\/scummvm-uninvited-00005.png\" alt=\"\" width=\"163\" height=\"186\" \/><\/p>\n<p>Another thing I copied from the original javascript codebase was &#8220;Clean\/Mess up&#8221; functions. Clean up is handy when there a lot items in the inventory, and you want the thing sorted. This was a simply copy-n-paste, however, the end result is quite satisfying and as said, useful for players:<\/p>\n<div style=\"width: 580px;\" class=\"wp-video\"><!--[if lt IE 9]><script>document.createElement('video');<\/script><![endif]-->\n<video class=\"wp-video-shortcode\" id=\"video-114-1\" width=\"580\" height=\"326\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/08\/cleanup.mp4?_=1\" \/><a href=\"https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/08\/cleanup.mp4\">https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/08\/cleanup.mp4<\/a><\/video><\/div>\n<p>At the end of week, I started polishing the console window The window where text (log) is displayed. There were small issues fixed away: numbers not showing and resize button not working. The last one was similar to the close button covered in this <a href=\"https:\/\/blogs.scummvm.org\/alikhan\/2025\/07\/21\/week-7-macventure\/\">post<\/a>. The last thing which needs to be properly done with console window is getting rid of unnecessary new lines, making the scrolling properly work and showing the text correctly when resizing (it gets clipped, not wrapped).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Another week spent on improving and finishing the MacVenture engine. In the last week I focused on improving things that happen after the winning the game, i.e, loading diploma window &amp; dialog, implementing &#8220;Clean\/Mess up&#8221; functions. I also fixed the bitmap problem I had with with a few items in Uninvited game. Lastly, I spent [&hellip;]<\/p>\n","protected":false},"author":26,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-114","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/alikhan\/wp-json\/wp\/v2\/posts\/114","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.scummvm.org\/alikhan\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.scummvm.org\/alikhan\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/alikhan\/wp-json\/wp\/v2\/users\/26"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/alikhan\/wp-json\/wp\/v2\/comments?post=114"}],"version-history":[{"count":1,"href":"https:\/\/blogs.scummvm.org\/alikhan\/wp-json\/wp\/v2\/posts\/114\/revisions"}],"predecessor-version":[{"id":120,"href":"https:\/\/blogs.scummvm.org\/alikhan\/wp-json\/wp\/v2\/posts\/114\/revisions\/120"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/alikhan\/wp-json\/wp\/v2\/media?parent=114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/alikhan\/wp-json\/wp\/v2\/categories?post=114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/alikhan\/wp-json\/wp\/v2\/tags?post=114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}