{"id":108,"date":"2023-07-21T23:00:15","date_gmt":"2023-07-21T23:00:15","guid":{"rendered":"https:\/\/blogs.scummvm.org\/hsk\/?p=108"},"modified":"2023-07-21T23:00:28","modified_gmt":"2023-07-21T23:00:28","slug":"its-not-you-its-me","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/hsk\/2023\/07\/21\/its-not-you-its-me\/","title":{"rendered":"It&#8217;s not you, It&#8217;s me!"},"content":{"rendered":"<p>Greetings, everybody. Welcome to this week&#8217;s blog post! I hope you are all doing fine, so first of all let&#8217;s start by this blog&#8217;s name, why <em>&#8220;It&#8217;s not you, It&#8217;s me&#8221;,\u00a0<\/em>Well there&#8217;s the reason behind it as one of the bugs that I encountered has to do something related to this term &#8216;<em>me<\/em>&#8216; and thus when referring to this problem, rvanlaar (discord) used this as a joke&#8230; more ahead..<\/p>\n<p>Let&#8217;s start with good news<\/p>\n<h3>Frame Loading Revamped<\/h3>\n<p>As presented in so many previous blogs, we are finally reaching the completion of demand frame loading and successfully working on total distortion&#8217;s bed dream games, this single big change took so many weeks, and after much effort frame loading has been completely revamped and the master branch is now updated to use on-demand frame load. If you do no know what I am talking about, read <a href=\"https:\/\/blogs.scummvm.org\/hsk\/2023\/06\/10\/i-am-a-developer-and-i-add-bugs-in-code\/\">this<\/a> and <a href=\"https:\/\/blogs.scummvm.org\/hsk\/2023\/06\/18\/because-spaces-should-have-height-too\/\">this<\/a> to get a basic idea about the change!<\/p>\n<p>PR <a href=\"https:\/\/github.com\/scummvm\/scummvm\/pull\/5124\">#5124<\/a> by super mentor Sev laid the groundwork for frame loading by merging some 40 commits into master and thus the era of demand loading came! However, some more tweaking had to be done to get everything working properly and most importantly, getting total distortion bed dream games working, for which all this was started!<\/p>\n<p>So after I made more changes and fine-tuned things after which bed dream games started to function normally.<\/p>\n<p>Preview:<\/p>\n<div style=\"width: 512px;\" class=\"wp-video\"><!--[if lt IE 9]><script>document.createElement('video');<\/script><![endif]-->\n<video class=\"wp-video-shortcode\" id=\"video-108-1\" width=\"512\" height=\"384\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/blogs.scummvm.org\/hsk\/wp-content\/uploads\/sites\/71\/2023\/07\/2023-07-22-03-18-53.mp4?_=1\" \/><a href=\"https:\/\/blogs.scummvm.org\/hsk\/wp-content\/uploads\/sites\/71\/2023\/07\/2023-07-22-03-18-53.mp4\">https:\/\/blogs.scummvm.org\/hsk\/wp-content\/uploads\/sites\/71\/2023\/07\/2023-07-22-03-18-53.mp4<\/a><\/video><\/div>\n<p>PR Link &#8211; <a href=\"https:\/\/github.com\/scummvm\/scummvm\/pull\/5163\">#5163<\/a><\/p>\n<h3>It&#8217;s not you, It&#8217;s ME<\/h3>\n<p>Finally, to the fun part, bed dream games were fixed, so what next? To go next part and play the minigames (the bulb one you see in the above video, at the end).. but while testing it, I encountered another bug <a href=\"https:\/\/trello.com\/c\/kyCsj2EJ\/648-lingo-compilation-error-in-dreamlights-game\">documented here<\/a>, that is:<\/p>\n<pre data-pm-slice=\"1 1 []\"><span class=\"code\">################ LINGO: syntax error, unexpected tINT at line 1 col 13 in NoneScript id: 0!\r\n<\/span><\/pre>\n<p data-pm-slice=\"1 1 []\"><em>What does this mean?<\/em><\/p>\n<p data-pm-slice=\"1 1 []\">To explain it better, I would have to give you a brief idea of what lingo is, and how is it used! But first, you need to know that the Director engine(for which I fix bugs) is a multimedia authoring platform, oh btw<\/p>\n<blockquote>\n<div id=\"N_-6ZO7mGcTs4-EPvvqrsAs__14\">\n<div class=\"wDYxhc\" data-md=\"61\">\n<div class=\"LGOjhe\" role=\"heading\" data-attrid=\"wa:\/description\" data-hveid=\"CB8QAA\"><span class=\"ILfuVd\" lang=\"en\"><span class=\"hgKElc\">Multimedia authoring is a process of assembling different types of media contents like text, audio, image, animations and video as a single stream of information with the help of various software tools available in the market.<\/span><\/span><\/div>\n<\/div>\n<\/div>\n<\/blockquote>\n<p data-pm-slice=\"1 1 []\">ie such a platform needs different tools and things to control\/create movies, and games.. Similarly in director engine, there is Lingo, a programming language that can be used to control various elements of games, like sound, images, etc!<\/p>\n<p data-pm-slice=\"1 1 []\">Quoting from <a href=\"https:\/\/en.wikipedia.org\/wiki\/Lingo_(programming_language)\">this Wikipedia page about lingo<\/a><\/p>\n<blockquote><p><b>Lingo<\/b>\u00a0is a verbose\u00a0<a title=\"Object-oriented programming\" href=\"https:\/\/en.wikipedia.org\/wiki\/Object-oriented_programming\">object-oriented<\/a>\u00a0(OO)\u00a0<a title=\"Scripting language\" href=\"https:\/\/en.wikipedia.org\/wiki\/Scripting_language\">scripting language<\/a>\u00a0developed by\u00a0<a title=\"John Thompson (inventor)\" href=\"https:\/\/en.wikipedia.org\/wiki\/John_Thompson_(inventor)\">John H. Thompson<\/a>\u00a0for use in\u00a0<a title=\"Adobe Director\" href=\"https:\/\/en.wikipedia.org\/wiki\/Adobe_Director\">Adobe Director<\/a>\u00a0(formerly Macromedia Director). Lingo is used to develop desktop\u00a0<a title=\"Application software\" href=\"https:\/\/en.wikipedia.org\/wiki\/Application_software\">application software<\/a>,\u00a0<a title=\"Interactive kiosk\" href=\"https:\/\/en.wikipedia.org\/wiki\/Interactive_kiosk\">interactive kiosks<\/a>,\u00a0<a title=\"CD-ROM\" href=\"https:\/\/en.wikipedia.org\/wiki\/CD-ROM\">CD-ROMs<\/a>\u00a0and\u00a0<a title=\"Adobe Shockwave\" href=\"https:\/\/en.wikipedia.org\/wiki\/Adobe_Shockwave\">Adobe Shockwave<\/a>\u00a0content.<sup id=\"cite_ref-1\" class=\"reference\"><a href=\"https:\/\/en.wikipedia.org\/wiki\/Lingo_(programming_language)#cite_note-1\">[1]<\/a><\/sup><sup id=\"cite_ref-2\" class=\"reference\"><a href=\"https:\/\/en.wikipedia.org\/wiki\/Lingo_(programming_language)#cite_note-2\">[2]<\/a><br \/>\n<\/sup><\/p><\/blockquote>\n<p>So it is a language that was originally used with director engines, now to replicate that engine in scummvm, scummvm <em>must support reading\/parsing this custom language right?<br \/>\n<\/em><\/p>\n<p>How is a programming language understood by the computer? or more specifically, <em>how is lingo being read by scummvm?<\/em> Well to understand so, we have to deep-dive into compiler designs and things even I am not comfortable with, but in a nutshell there are these components:<\/p>\n<ol>\n<li>A compiler, which takes for example Lingo and converts it to C++ comfortable instructions.<\/li>\n<li>AST Trees for operands, operations, etc.<\/li>\n<\/ol>\n<p>Oh, Lingo is a context-free language, I would really love to go deep inside automata theory but that&#8217;s an article for some other time!<\/p>\n<p>But what happens, in a nutshell, is a simple instruction like <em>put &#8220;Hello&#8221; <\/em>when read by our compiler\/parser, jumps into state, ie, converts everything to the token and then token-by-token creates logic\/relations etc about different components of instructions, for example here let&#8217;s say our parser was initially in state X where it can accept a,b,c,d&#8230;. tokens, &#8220;put&#8221; being one of them, once it received &#8220;put&#8221; token, it simultaneously jumps into state Y where now it can only accept token like <code>\"<\/code> , etc.. well, all these are then converted to C++ objects which will later be used to execute lingo!<\/p>\n<p><strong>What did go wrong with this bug?<\/strong><\/p>\n<p>Well, as seen by the error, called syntax error, what happened was that the game was trying to execute an instruction that is little different than what scummvm expects, here in this case, the game tried to execute lingo instruction<\/p>\n<pre data-pm-slice=\"1 1 []\"><span class=\"code\">me(bubdie2 5, 75)<\/span><\/pre>\n<p>however, we expected an instruction of this type to be written something like this:<\/p>\n<pre><span class=\"code\">me(bubdie2, 5, 75)<\/span><\/pre>\n<p>(Please note the comma there), until now, there were no cases observed when a game used the wrong syntax (well correct, to be precise, just non-documented syntax), which was working fine in the original engine, and once again, we didn&#8217;t implement this peculiarity!<\/p>\n<p>To be extra sure that it&#8217;s &#8220;us&#8221; not &#8220;them&#8221; who did this wrong, I verified this by creating testing movies for the director engine and trying to work this off and as expected our Lingo parsing was incomplete as it didn&#8217;t account for this edge case! Well time to fix it (but with a twist)<\/p>\n<p><em>As this was too difficult for me<\/em>, again super mentor Sev came to the rescue, he told me the problem and after discussions,<strong> djsrv implemented this, Link to PR: <a href=\"https:\/\/github.com\/scummvm\/scummvm\/pull\/5170\">#5170<\/a><\/strong><\/p>\n<p>Here&#8217;s a working screenshot:<\/p>\n<figure id=\"attachment_116\" aria-describedby=\"caption-attachment-116\" style=\"width: 496px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-116\" src=\"https:\/\/blogs.scummvm.org\/hsk\/wp-content\/uploads\/sites\/71\/2023\/07\/Screenshot-from-2023-07-22-04-12-54-300x248.png\" alt=\"\" width=\"496\" height=\"410\" srcset=\"https:\/\/blogs.scummvm.org\/hsk\/wp-content\/uploads\/sites\/71\/2023\/07\/Screenshot-from-2023-07-22-04-12-54-300x248.png 300w, https:\/\/blogs.scummvm.org\/hsk\/wp-content\/uploads\/sites\/71\/2023\/07\/Screenshot-from-2023-07-22-04-12-54.png 511w\" sizes=\"auto, (max-width: 496px) 100vw, 496px\" \/><figcaption id=\"caption-attachment-116\" class=\"wp-caption-text\">screenshot showing working dreamlights minigame<\/figcaption><\/figure>\n<p>Oh, by the way, this title was inspired by this message of <em>rvanlaar<img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-118\" src=\"https:\/\/blogs.scummvm.org\/hsk\/wp-content\/uploads\/sites\/71\/2023\/07\/Screenshot-from-2023-07-22-04-20-20-300x182.png\" alt=\"\" width=\"499\" height=\"303\" srcset=\"https:\/\/blogs.scummvm.org\/hsk\/wp-content\/uploads\/sites\/71\/2023\/07\/Screenshot-from-2023-07-22-04-20-20-300x182.png 300w, https:\/\/blogs.scummvm.org\/hsk\/wp-content\/uploads\/sites\/71\/2023\/07\/Screenshot-from-2023-07-22-04-20-20.png 580w\" sizes=\"auto, (max-width: 499px) 100vw, 499px\" \/><\/em><\/p>\n<p>You can always join our discord using <a href=\"https:\/\/discord.gg\/WBsuFVCmwj\">this link<\/a> and watch progress, and even better contribute and help improve ScummVM!<\/p>\n<h3>More Work this Week:<\/h3>\n<h5>Fixing leaks in lingo-tests: <a href=\"https:\/\/github.com\/scummvm\/scummvm\/pull\/5164\">#5164<\/a><\/h5>\n<p>This fixes leaks, and errors in lingo-tests which makes the build bot green yet again!<\/p>\n<h3>The End<\/h3>\n<p>Thanks for reading so far, I hope you like it, as usual apologies for any grammar mistakes, etc! With that being said see you in next week!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Greetings, everybody. Welcome to this week&#8217;s blog post! I hope you are all doing fine, so first of all let&#8217;s start by this blog&#8217;s name, why &#8220;It&#8217;s not you, It&#8217;s me&#8221;,\u00a0Well there&#8217;s the reason behind it as one of the bugs that I encountered has to do something related to this term &#8216;me&#8216; and thus [&hellip;]<\/p>\n","protected":false},"author":19,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,4,7,9],"tags":[],"class_list":["post-108","post","type-post","status-publish","format-standard","hentry","category-coding","category-experience","category-fun","category-technical"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/hsk\/wp-json\/wp\/v2\/posts\/108","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.scummvm.org\/hsk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.scummvm.org\/hsk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/hsk\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/hsk\/wp-json\/wp\/v2\/comments?post=108"}],"version-history":[{"count":7,"href":"https:\/\/blogs.scummvm.org\/hsk\/wp-json\/wp\/v2\/posts\/108\/revisions"}],"predecessor-version":[{"id":119,"href":"https:\/\/blogs.scummvm.org\/hsk\/wp-json\/wp\/v2\/posts\/108\/revisions\/119"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/hsk\/wp-json\/wp\/v2\/media?parent=108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/hsk\/wp-json\/wp\/v2\/categories?post=108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/hsk\/wp-json\/wp\/v2\/tags?post=108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}