{"id":90,"date":"2024-06-17T06:34:56","date_gmt":"2024-06-17T06:34:56","guid":{"rendered":"https:\/\/blogs.scummvm.org\/kunxl\/?p=90"},"modified":"2024-06-17T11:25:08","modified_gmt":"2024-06-17T11:25:08","slug":"more-resource-loading","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/kunxl\/2024\/06\/17\/more-resource-loading\/","title":{"rendered":"More Resource Loading"},"content":{"rendered":"<p>This week\u2019s work revolved around loading resources from data files and developing the splash screen. I&#8217;ve previously discussed the splash screen in detail, so feel free to refer to my earlier <a href=\"https:\/\/blogs.scummvm.org\/kunxl\/2024\/06\/11\/the-first-visuals\/\">blog post <\/a>if you\u2019re curious about my approach.<\/p>\n<h2>Loading the QML file<\/h2>\n<p>The first task was to load the QML file. Interestingly, the contents of the QML file are stored in a tree data structure. This tree contains all the necessary information required to load the game, ranging from screen sizes to resource file paths.<\/p>\n<h2>Re-writing qdFileManager and qdFilePackage Classes<\/h2>\n<p>The next task was to re-write the <code>qdFileManager<\/code> and <code>qdFilePackage<\/code> classes to use our zip utilities. These two classes are crucial for loading <code>.pak<\/code> files, which are frequently used in games to &#8220;pack&#8221; all the resources together. In this re-write, we changed the internal of the class methods to detect pack files and use are zip utilites to unpack them. Refer to these commits for a detailed understanding of the changes.<\/p>\n<p>This led to the method <code>qdFileManager::instance()::open_file(Common::SeekableReadStream *fh, const char *fname)<\/code> working with Common::SeekableReadStream which made it easier to read buffers from here on.<\/p>\n<h2>Using readUint32LE() instead of read()<\/h2>\n<p>While making all these refactors, Sev explained the concept of Endianness and highlighted its importance in our codebase. Endianness in simple terms is the order in which multi-byte data is stored in memory. There are two systems in Endianness, Little Endian and Big Endian. In a system that follows Little Endian, the least significant byte is stored in the smallest address of memory, while in a Big Endian system, it is the complete opposite, the most significant byte is stored in the smallest address of memory. So let&#8217;s say you have a number 0x01. In the two systems it would look something like this.<\/p>\n<ul>\n<li>Little Endian: 01 00 00 00<\/li>\n<li>Big Endian: 00 00 00 01<\/li>\n<\/ul>\n<p>Our files are written in Little Endian, but ScummVM works on many Big Endian systems. Thus, data could be misinterpreted, e.g., 0x01 might be read as 0x01000000 (16777216 in decimal), on a Big Endian system<\/p>\n<h2>Finishing things up<\/h2>\n<p>Following the initial commits, the subsequent tasks followed a straightforward pattern. They involved:<\/p>\n<ol>\n<li>Opening a file and getting the stream from it.<\/li>\n<li>Passing the stream as a parameter to <code>qdFileManager::instance()::open_file<\/code>.<\/li>\n<li>Reading from the stream and storing the required values as needed.<\/li>\n<li>Deleting the stream later on.<\/li>\n<\/ol>\n<p>You can go through this <a href=\"https:\/\/github.com\/sev-\/qdengine\/commit\/bd0faa324c48b1da90d9bba53b0560e38340064c\">commit<\/a> to understand this change in greater detail.<\/p>\n<div class=\"group\/conversation-turn relative flex w-full min-w-0 flex-col agent-turn\">\n<div class=\"flex-col gap-1 md:gap-3\">\n<div class=\"flex flex-grow flex-col max-w-full\">\n<div class=\"min-h-[20px] text-message flex flex-col items-start whitespace-pre-wrap break-words [.text-message+&amp;]:mt-5 juice:w-full juice:items-end overflow-x-auto gap-2\" dir=\"auto\" data-message-author-role=\"assistant\" data-message-id=\"978354c7-fe92-431a-ac4b-b00d20101a5e\">\n<div class=\"flex w-full flex-col gap-1 juice:empty:hidden juice:first:pt-[3px]\">\n<div class=\"markdown prose w-full break-words dark:prose-invert light\">\n<p>This marked the end of my week, and we are now at the quarter mark of the program. There is still a lot of work to be done, and I am hopeful to show more exciting progress in the coming blogs. On a closing note, here is a picture of me displaying fonts on the screen to test if they were read accurately or not.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-96 size-large\" src=\"https:\/\/blogs.scummvm.org\/kunxl\/wp-content\/uploads\/sites\/75\/2024\/06\/Screenshot_2024-06-12_at_3.00.58_PM-1024x576.png\" alt=\"\" width=\"1024\" height=\"576\" srcset=\"https:\/\/blogs.scummvm.org\/kunxl\/wp-content\/uploads\/sites\/75\/2024\/06\/Screenshot_2024-06-12_at_3.00.58_PM-1024x576.png 1024w, https:\/\/blogs.scummvm.org\/kunxl\/wp-content\/uploads\/sites\/75\/2024\/06\/Screenshot_2024-06-12_at_3.00.58_PM-300x169.png 300w, https:\/\/blogs.scummvm.org\/kunxl\/wp-content\/uploads\/sites\/75\/2024\/06\/Screenshot_2024-06-12_at_3.00.58_PM-768x432.png 768w, https:\/\/blogs.scummvm.org\/kunxl\/wp-content\/uploads\/sites\/75\/2024\/06\/Screenshot_2024-06-12_at_3.00.58_PM-1536x864.png 1536w, https:\/\/blogs.scummvm.org\/kunxl\/wp-content\/uploads\/sites\/75\/2024\/06\/Screenshot_2024-06-12_at_3.00.58_PM-480x270.png 480w, https:\/\/blogs.scummvm.org\/kunxl\/wp-content\/uploads\/sites\/75\/2024\/06\/Screenshot_2024-06-12_at_3.00.58_PM-960x540.png 960w, https:\/\/blogs.scummvm.org\/kunxl\/wp-content\/uploads\/sites\/75\/2024\/06\/Screenshot_2024-06-12_at_3.00.58_PM.png 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p>Stay tuned for more updates!<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This week\u2019s work revolved around loading resources from data files and developing the splash screen. I&#8217;ve previously discussed the splash screen in detail, so feel free to refer to my earlier blog post if you\u2019re curious about my approach. Loading the QML file The first task was to load the QML file. Interestingly, the contents [&hellip;]<\/p>\n","protected":false},"author":23,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[3,4],"class_list":["post-90","post","type-post","status-publish","format-standard","hentry","category-gsoc","tag-c","tag-game-engines"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/kunxl\/wp-json\/wp\/v2\/posts\/90","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.scummvm.org\/kunxl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.scummvm.org\/kunxl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/kunxl\/wp-json\/wp\/v2\/users\/23"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/kunxl\/wp-json\/wp\/v2\/comments?post=90"}],"version-history":[{"count":12,"href":"https:\/\/blogs.scummvm.org\/kunxl\/wp-json\/wp\/v2\/posts\/90\/revisions"}],"predecessor-version":[{"id":103,"href":"https:\/\/blogs.scummvm.org\/kunxl\/wp-json\/wp\/v2\/posts\/90\/revisions\/103"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/kunxl\/wp-json\/wp\/v2\/media?parent=90"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/kunxl\/wp-json\/wp\/v2\/categories?post=90"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/kunxl\/wp-json\/wp\/v2\/tags?post=90"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}