{"id":76,"date":"2020-07-19T06:50:48","date_gmt":"2020-07-19T04:50:48","guid":{"rendered":"https:\/\/blogs.scummvm.org\/ar28\/?p=76"},"modified":"2022-04-15T06:54:24","modified_gmt":"2022-04-15T04:54:24","slug":"getting-a-better-understanding-a-little-progress","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/ar28\/2020\/07\/19\/getting-a-better-understanding-a-little-progress\/","title":{"rendered":"Getting a better understanding &#038; a little progress"},"content":{"rendered":"<p>Hello! The first few days this week, I spent trying to understand my task, and work on a small number of engines, and try to make games detect\/work as a means to see if everything would work as expected. But first, some context.<\/p>\n<p>ScummVM has a MetaEngine and a Engine.<\/p>\n<p><!--more--><\/p>\n<h4>MetaEngine<\/h4>\n<div>A MetaEngine is responsible for, as the name would suggest, a meta-data related things before we actually start the engine. This is an abstract class, and each specific engine must inherit it and have their own implementation of it.<\/div>\n<div><\/div>\n<div>Alternatively, we also have an AdvancedMetaEngine, inheriting from MetaEngine, which provides a default Game Detection algorithm &#8211; which saves individual engine developers the hassle of providing detection tools. The detection algorithm is an Md5 + filename check and makes game detection easier for engines. These engines can inherit from AdvancedMetaEngine and provide some other metadata\/utility functions, like getting supported games, querying which features an engine has, etc.<\/div>\n<div><\/div>\n<div>AdvancedMetaEngine provides a means for engines to detect games. But, how does it know that a specific game belongs to a particular engine? Each engine provides a set of detector tables i.e a list of games it can support. Then, the default game detection algorithm checks each engine&#8217;s detection tables for a match. These files are often separated into a new file, and it is called &#8220;detection_tables.h&#8221;<\/div>\n<div><\/div>\n<div>So, each engine&#8217;s implementation of their own version of AdvancedMetaEngine (or MetaEngine) and other detection-related code is located in detection.cpp. This file includes the detection_tables header file, so the resulting object file generated has all the necessary information which it would need for detection.<\/div>\n<div>\n<h4>Engine<\/h4>\n<div>An engine is the actual game engine, which is created when we try to run a game.<\/div>\n<div>\n<h4>So, what is the task exactly?<\/h4>\n<div>I gave a very brief overview in my last post, but basically, the detection related code &#8211; which lives in detection.cpp, will need to be isolated in a way that actual detection related code goes to the executable, while the other kind of functions will be available as-is, on-demand at runtime.<\/div>\n<div><\/div>\n<div>So, the detector-tables, and other detection related code &#8211; like fallback detection moves in and is linked against the scummvm executable. So, the ScummVM executable depends on these (detection) object files.<\/div>\n<div><\/div>\n<div>Fallback detection is a way for engines to provide a means to find a &#8220;closest&#8221; match if the detector found no matches in the directory.<\/div>\n<div><\/div>\n<div>So, I have a little progress this week! It&#8217;s not much, but I worked towards the most basic thing as a few of small steps:<\/div>\n<ul>\n<li>For makefiles, introduce a variable for Detection Objects and add it as a dependency for the scummvm executable. This way, before scummvm.exe is built, these are compiled and linked with scummvm.exe<\/li>\n<li>For engines, isolate MetaEngine code and temporarily comment a bridge function<\/li>\n<li>createInstance. Creating an instance means we actually try to instantiate an engine. This is a method of MetaEngine and connects an Engine with MetaEngine.<\/li>\n<\/ul>\n<p>That&#8217;s it! I did the above for 3 engines &#8211; AGI, CINE, PLUMBERS. I had no need for the latter two though, but I wanted more than one engine as part of the preview? or whatever I was doing.<\/p>\n<p>A while back, Eugene had given me a link, which had a huge number (197 or so!) of AGI (fanmade) Games. I thought it would be a good point to see if the above steps worked correctly or not. It worked well, and the result from before\/after the work was the same. Fallback detection worked too!<\/p>\n<p>Perhaps it was not a big deal, but I finally had something to share! I&#8217;m taking a lot of time to think and understand this task, and many days had passed by without me sharing any update. I could finally share a small update and make a few commits for my mentors or community to check out, so that was good. It feels a little weird that I&#8217;d check-in and out without showing code progress for so many days, so for me to actually show something was good.<\/p>\n<p><a href=\"https:\/\/blogs.scummvm.org\/ar28\/wp-content\/uploads\/sites\/13\/2022\/04\/first_accomp.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-77\" src=\"https:\/\/blogs.scummvm.org\/ar28\/wp-content\/uploads\/sites\/13\/2022\/04\/first_accomp-1024x576.png\" alt=\"\" width=\"660\" height=\"371\" srcset=\"https:\/\/blogs.scummvm.org\/ar28\/wp-content\/uploads\/sites\/13\/2022\/04\/first_accomp-1024x576.png 1024w, https:\/\/blogs.scummvm.org\/ar28\/wp-content\/uploads\/sites\/13\/2022\/04\/first_accomp-300x169.png 300w, https:\/\/blogs.scummvm.org\/ar28\/wp-content\/uploads\/sites\/13\/2022\/04\/first_accomp-768x432.png 768w, https:\/\/blogs.scummvm.org\/ar28\/wp-content\/uploads\/sites\/13\/2022\/04\/first_accomp-1536x864.png 1536w, https:\/\/blogs.scummvm.org\/ar28\/wp-content\/uploads\/sites\/13\/2022\/04\/first_accomp.png 1600w\" sizes=\"auto, (max-width: 660px) 100vw, 660px\" \/><\/a><\/p>\n<p>I also took a small test, I uncommented code in createInstance where engines were being instantiated and added plugins as a dependency for the executable.<\/p>\n<p>That means all engine.dll&#8217;s depend directly on the executable i.e implicit linking. This type of linking would mean a .dll file to be present for the executable to run. If it does not exist, the application would crash.<\/p>\n<p>That&#8217;s not really how it should work &#8211; engine.dll&#8217;s are explicitly linked i.e they&#8217;re not dependent on executable. It&#8217;s loaded on-demand and if not present, the application would not crash.<\/p>\n<p>However, I just did the test to see if engines could instantiate and run properly &#8211; and they did, indeed!<\/p>\n<p>Eugene recently reviewed my newly made commits and left a lot of comments. I made some mistakes, or rather &#8211; didn&#8217;t correctly understand why some things were the way they were. A small discussion in the group took place, and I think I know the way to move forward now and incorporate the changes in a better way.<\/p>\n<p>Overall, I think I have the basic idea of the end goal, as well as a temporary piece of code that achieves this (with a few incorrect assumptions). Now, I need to implement everything in a correct manner and maintain the engine changes in a clean and maintainable manner.<\/p>\n<p>Though I think there are still some key things I don&#8217;t fully understand, but the discussion recently should be enough to guide me in the right direction.<\/p>\n<p>Lastly, my finals were scheduled to start tomorrow, but it was postponed again. I am glad about it, because I can work till the end of summer without taking a break of 1-2 weeks. Phew!<\/p>\n<p>That&#8217;s it for this week! My previous PR has some more comments now, which I will have a look now, review it myself and make the necessary changes.<\/p>\n<p>This next week, I want to accomplish the changes (for the new task) in a way that my mentors expect and have a few more commits and enable a few engines regarding that. Once I have the &#8220;go&#8221; for that \/ everything seems ok, I can start going engine by engine to incorporate the changes on a bigger scale.<\/p>\n<p>Thanks for reading!<\/p>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Hello! The first few days this week, I spent trying to understand my task, and work on a small number of engines, and try to make games detect\/work as a means to see if everything would work as expected. But first, some context. ScummVM has a MetaEngine and a Engine.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-76","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/ar28\/wp-json\/wp\/v2\/posts\/76","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.scummvm.org\/ar28\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.scummvm.org\/ar28\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/ar28\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/ar28\/wp-json\/wp\/v2\/comments?post=76"}],"version-history":[{"count":1,"href":"https:\/\/blogs.scummvm.org\/ar28\/wp-json\/wp\/v2\/posts\/76\/revisions"}],"predecessor-version":[{"id":78,"href":"https:\/\/blogs.scummvm.org\/ar28\/wp-json\/wp\/v2\/posts\/76\/revisions\/78"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/ar28\/wp-json\/wp\/v2\/media?parent=76"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/ar28\/wp-json\/wp\/v2\/categories?post=76"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/ar28\/wp-json\/wp\/v2\/tags?post=76"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}