{"id":124,"date":"2025-08-26T14:05:51","date_gmt":"2025-08-26T14:05:51","guid":{"rendered":"https:\/\/blogs.scummvm.org\/superlemon\/?p=124"},"modified":"2025-08-26T14:06:54","modified_gmt":"2025-08-26T14:06:54","slug":"another-upgrade-to-the-imgui-debugger","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/superlemon\/2025\/08\/26\/another-upgrade-to-the-imgui-debugger\/","title":{"rendered":"Another upgrade to the ImGui Debugger"},"content":{"rendered":"<p>For the last week of GSoC, I was working on some more improvements to the ImGui Debugger in the Director engine. Making the ImGui debugger as close to the original Director engine as possible will be very helpful in adding support for games in the future.<\/p>\n<p>The first thing to do was to revamp the Functions window. It used to show all the handlers from all the scripts in the window in a single table. Since, that was not only messy and not properly navigable, @sev asked me to revamp it so that there are two views:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-127 alignleft\" src=\"https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_20250826_184424-227x300.png\" alt=\"\" width=\"227\" height=\"300\" srcset=\"https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_20250826_184424-227x300.png 227w, https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_20250826_184424.png 488w\" sizes=\"auto, (max-width: 227px) 100vw, 227px\" \/><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-128 alignleft\" src=\"https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_20250826_184432-227x300.png\" alt=\"\" width=\"227\" height=\"300\" srcset=\"https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_20250826_184432-227x300.png 227w, https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_20250826_184432.png 488w\" sizes=\"auto, (max-width: 227px) 100vw, 227px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>One: that shows all the handlers just like how it was shown previously and two: one that shows each script, and each script (&#8216;Lscr&#8217; context) and under each script we have all the handlers in that script. This allows us to navigate between scripts very easily. This also means, in the second view, the filtering works better, i.e. we can filter out all the handlers with a certain name (e.g. <code>mouseUp<\/code>) or those associated with a particular cast member (say no. 123) easily.<\/p>\n<p>After that, we noticed that some of the scripts didn&#8217;t show the cast member number in the Execution Context window properly (e.g. -1 for the topicmaker:mnew in the screenshot):<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-129\" src=\"https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_20250820_224026-300x130.png\" alt=\"\" width=\"489\" height=\"212\" srcset=\"https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_20250820_224026-300x130.png 300w, https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_20250820_224026.png 574w\" sizes=\"auto, (max-width: 489px) 100vw, 489px\" \/><\/p>\n<p>Now, the cast id (even though present in the &#8216;Lscr&#8217; data stream, is not reliable) is fetched from the associated cast member. Since cast IDs and script IDs are linked together, we can map the script ID to its corresponding cast ID. But, it was possible that some of the cast members are not loaded, because of lack of support or some error (e.g. Picture cast member). Hence, at first I thought, forcing the loading of their cast member info might solve this problem. However, I was wrong. But I thought it might still be a good and harmless addition, hence I made a <a href=\"https:\/\/github.com\/scummvm\/scummvm\/pull\/6889\">PR<\/a>.<\/p>\n<p>It turns out that some of the &#8216;Lscr&#8217; contexts are factory scripts, i.e. they have a parent script (which is associated with a cast member) and the handlers in the current script context are called in reference to the parent&#8217;s cast member. As you can see from the following screenshot of LCARS___.dir loaded into the origin Director engine, the handler `topicmaker:mnew` is part of a movie script (cast ID: 1285):<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-130\" src=\"https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_20250826_191147-300x169.png\" alt=\"\" width=\"414\" height=\"233\" srcset=\"https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_20250826_191147-300x169.png 300w, https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_20250826_191147-1024x576.png 1024w, https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_20250826_191147-768x432.png 768w, https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_20250826_191147-1536x864.png 1536w, https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_20250826_191147-1200x675.png 1200w, https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_20250826_191147.png 1920w\" sizes=\"auto, (max-width: 414px) 100vw, 414px\" \/><\/p>\n<p>Even while dumping the scripts, ProjectorRays\/ScummVM dumps the handlers in the current script as part of the parent script and completely ignores the current script (the one without a cast member associated):<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-132\" src=\"https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_20250826_190541-300x169.png\" alt=\"\" width=\"460\" height=\"259\" srcset=\"https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_20250826_190541-300x169.png 300w, https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_20250826_190541-1024x576.png 1024w, https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_20250826_190541-768x432.png 768w, https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_20250826_190541-1536x864.png 1536w, https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_20250826_190541-1200x675.png 1200w, https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_20250826_190541.png 1920w\" sizes=\"auto, (max-width: 460px) 100vw, 460px\" \/><\/p>\n<p>This is the list of all the parent scripts and their child script:<\/p>\n<p>&#8220;`<br \/>\nWho is: 236, whose parent: 89<br \/>\nWho is: 239, whose parent: 93<br \/>\nWho is: 232, whose parent: 234<br \/>\nWho is: 188, whose parent: 599<br \/>\nWho is: 597, whose parent: 623<br \/>\nWho is: 216, whose parent: 624<br \/>\nWho is: 21, whose parent: 646<br \/>\nWho is: 230, whose parent: 657<br \/>\nWho is: 26, whose parent: 721<br \/>\nWho is: 131, whose parent: 722<br \/>\nWho is: 24, whose parent: 723<br \/>\nWho is: 179, whose parent: 725<br \/>\nWho is: 131, whose parent: 727<br \/>\nWho is: 163, whose parent: 728<br \/>\nWho is: 199, whose parent: 729<br \/>\nWho is: 131, whose parent: 730<br \/>\n&#8220;`<br \/>\nHence, the solution was to not show the associated castID but rather the script ID, which is unique to each script. Hence, it required storing the parent number and the script number in the <code>ScriptContext<\/code> class, and show that in the Execution Context window. This solved the problem. @sev then asked me to change all the references to a handler in a similar way, including the way we name the dumped scripts. This honestly took way too much time to figure out.<\/p>\n<p>Also, the scripts are now shown in a separate window when we click on a handler in the Functions window rather than showing them in the Execution Context window. Hence, we can see as many scripts as we want at the same time.<\/p>\n<p>Also, the handlers in the call stack are now selectable. You can click on them to jump to the exact byte code in the script shown below in the Execution Context window. To make the scrolling work, I had to include a separate boolean in the <code>ImGuiState<\/code> struct.<\/p>\n<p>After that, there were a bunch of minor issues, like the scrolling in the Execution Context window when we jump to the definition, sanity checks for fetching `ScriptContext` through the handler <code>Director::DT::getScriptContext<\/code>, marking the script dirty when a button in the control panel is placed, and some other stuff too minor to notice here.<\/p>\n<p>Also, in the Score, the original director shows whether or not a sprite changes in subsequent frames. Like follows:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-133 aligncenter\" src=\"https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_2024-05-18_at_23.25.14-300x49.png\" alt=\"\" width=\"300\" height=\"49\" srcset=\"https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_2024-05-18_at_23.25.14-300x49.png 300w, https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_2024-05-18_at_23.25.14-1024x167.png 1024w, https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_2024-05-18_at_23.25.14-768x126.png 768w, https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_2024-05-18_at_23.25.14-1200x196.png 1200w, https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_2024-05-18_at_23.25.14.png 1284w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/> <img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-134 aligncenter\" src=\"https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_2024-05-21_at_11.17.04-300x211.png\" alt=\"\" width=\"300\" height=\"211\" srcset=\"https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_2024-05-21_at_11.17.04-300x211.png 300w, https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_2024-05-21_at_11.17.04-1024x722.png 1024w, https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_2024-05-21_at_11.17.04-768x541.png 768w, https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_2024-05-21_at_11.17.04-1536x1083.png 1536w, https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_2024-05-21_at_11.17.04-1200x846.png 1200w, https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/Screenshot_2024-05-21_at_11.17.04.png 1742w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>I was working on adding a similar functionality in the Score window, but I&#8217;m only halfway there.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-136\" src=\"https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/image-2-300x57.png\" alt=\"\" width=\"400\" height=\"76\" srcset=\"https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/image-2-300x57.png 300w, https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/image-2-768x147.png 768w, https:\/\/blogs.scummvm.org\/superlemon\/wp-content\/uploads\/sites\/79\/2025\/08\/image-2.png 779w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/p>\n<p>I&#8217;ll be adding the rest of the functionality in the next two days.<\/p>\n<p>Hence, overall a slightly less than average week. I was busy over the weekend for the academic project for final year (my faculty advisor is not happy with our progress). Initially I planned on making this post my final submission, but later decided against it. I&#8217;ll be making a separate post underlining all the progress that I made over the last\u00a0 12 weeks as my final submission.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For the last week of GSoC, I was working on some more improvements to the ImGui Debugger in the Director engine. Making the ImGui debugger as close to the original Director engine as possible will be very helpful in adding support for games in the future. The first thing to do was to revamp the [&hellip;]<\/p>\n","protected":false},"author":27,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"class_list":["post-124","post","type-post","status-publish","format-standard","hentry","category-week-12"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/superlemon\/wp-json\/wp\/v2\/posts\/124","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.scummvm.org\/superlemon\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.scummvm.org\/superlemon\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/superlemon\/wp-json\/wp\/v2\/users\/27"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/superlemon\/wp-json\/wp\/v2\/comments?post=124"}],"version-history":[{"count":3,"href":"https:\/\/blogs.scummvm.org\/superlemon\/wp-json\/wp\/v2\/posts\/124\/revisions"}],"predecessor-version":[{"id":139,"href":"https:\/\/blogs.scummvm.org\/superlemon\/wp-json\/wp\/v2\/posts\/124\/revisions\/139"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/superlemon\/wp-json\/wp\/v2\/media?parent=124"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/superlemon\/wp-json\/wp\/v2\/categories?post=124"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/superlemon\/wp-json\/wp\/v2\/tags?post=124"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}