{"id":13,"date":"2017-05-27T08:54:03","date_gmt":"2017-05-27T08:54:03","guid":{"rendered":"https:\/\/blogs.scummvm.org\/yinsimei\/?p=13"},"modified":"2022-05-24T08:54:34","modified_gmt":"2022-05-24T08:54:34","slug":"gsoc-week-1","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/yinsimei\/2017\/05\/27\/gsoc-week-1\/","title":{"rendered":"GSoC Week 1"},"content":{"rendered":"<h1>GSoC 2017: Sludge Engine Week 1<\/h1>\n<h1>Week task conclusion<\/h1>\n<p>In general, my first week of working for GSoC project was going smoothly. And a huge thank you to my mentors _sev(Eugene Sandulenko), t0by(Tobia Tesan) and all scummvm team members that has helped me during this week.<\/p>\n<p>Due to my project plan, my task for this week was originally :<\/p>\n<table>\n<tbody>\n<tr>\n<td>Task 1-1 Read game data file, initialization, timer , main_loop:&nbsp;<\/p>\n<ol>\n<li>Use Common:File to read and slice game data file to init game objects and get index of sources in data file<\/li>\n<li>Main loop: checkInput, playAnimation, handleInput, display, wait_frame\n<ol type=\"a\">\n<li>Use TimerManager for timer<\/li>\n<\/ol>\n<\/li>\n<li>Define macros and built-in functions<\/li>\n<\/ol>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>We have modified the plan, though, because it\u2019s not to rewrite the whole engine bit by bit as I originally thought, but to add whole engine files at first and stub all the parts calling libraries and functions forbidden by scummvm, then gradually unstub them using scummvm functions, till we have the whole engine.<\/p>\n<p>To make a brief conclusion about what we have achieved and changed for<b>\u00a0this week<\/b>\u00a0:<\/p>\n<p><b>Achieved :<\/b><\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<ol>\n<li><a href=\"https:\/\/github.com\/yinsimei\/scummvm\/commit\/e68247fc0016e5520d4e6552258718985171da9f\">Add all sludge engine files into the scummvm and make it compile under Linux<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/yinsimei\/scummvm\/commit\/496a405f11e59443df38803028bdd6a72ae2a297\">Replace original data reading functions by Common::File\/SeekabbleReadStream<\/a><\/li>\n<li>We are moving to make graphics work for sludge<\/li>\n<\/ol>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><b>For later (They don\u2019t have much effects for now):<\/b><\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<ol>\n<li>Timer, input, \u2026<\/li>\n<li>File writing stuff<\/li>\n<\/ol>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><b>Some problems left to be solved :<\/b><\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<ol>\n<li>There is an segmentation fault due to the incomplete data loading of image files and animations whenever animation or sprite variables are referenced, at not initialized yet.<\/li>\n<li>The code don\u2019t compile yet for Mac or Windows at present<\/li>\n<\/ol>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h1>What\u2019s for next week: Graphics<\/h1>\n<p>Generally, what we will do next week is :<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<ol>\n<li>Get backdrop (background) reading and displaying work<\/li>\n<li>Get the sprite system up based on 1<\/li>\n<li>Get spritebank up to have animations<\/li>\n<\/ol>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>We have started a little on making graphics works, hopefully the \u201csegmentation fault\u201d could be fixed then if we would be able to load animations.<\/p>\n<h1>Some findings about sludge<\/h1>\n<h2>How game data works<\/h2>\n<p>Find out how do they parse the game data file and try to adapt engine objects<\/p>\n<p>Inner structure of .slg file:<\/p>\n<p>A string here is composed of:<\/p>\n<ul>\n<li>2 bytes to indicate the string length<\/li>\n<li>a series of chars for the string<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"\" src=\"https:\/\/yinsimei.files.wordpress.com\/2017\/05\/image.png?w=569&amp;h=493\" srcset=\"https:\/\/yinsimei.files.wordpress.com\/2017\/05\/image.png?w=569&amp;h=493&amp;zoom=2 2x\" alt=\"\" width=\"569\" height=\"493\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"\" src=\"https:\/\/yinsimei.files.wordpress.com\/2017\/05\/image1.png?w=565&amp;h=392\" srcset=\"https:\/\/yinsimei.files.wordpress.com\/2017\/05\/image1.png?w=565&amp;h=392&amp;zoom=2 2x\" alt=\"\" width=\"565\" height=\"392\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"\" src=\"https:\/\/yinsimei.files.wordpress.com\/2017\/05\/image2.png?w=564&amp;h=475\" srcset=\"https:\/\/yinsimei.files.wordpress.com\/2017\/05\/image2.png?w=564&amp;h=475&amp;zoom=2 2x\" alt=\"\" width=\"564\" height=\"475\" \/><\/p>\n<p>A resource block is like: (same for text, sub, object, data)<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"\" src=\"https:\/\/yinsimei.files.wordpress.com\/2017\/05\/image3.png?w=577&amp;h=164\" srcset=\"https:\/\/yinsimei.files.wordpress.com\/2017\/05\/image3.png?w=577&amp;h=164&amp;zoom=2 2x\" alt=\"\" width=\"577\" height=\"164\" \/><\/p>\n<ul>\n<li><b>Text<\/b>\u00a0is a string.<\/li>\n<li><b>Sub\u00a0<\/b>contains<b>\u00a0<\/b>functions used and defined by user<\/li>\n<li><b>Object<\/b>\u00a0(items that can be put into inventory and combined and characters)<\/li>\n<li><b>Data<\/b>\u00a0(image, audio, video)<\/li>\n<\/ul>\n<p>In Sludge, we stock the beginning position of the index of resources (<b>startOfObjectIndex, startOfDataIndex, startOfDataIndex<\/b>) to access them.<\/p>\n<h2>Built-in function<\/h2>\n<p>In sludge, not only the events, but also all resources are integrated through built-in functions and everything except raw bitmaps and waveforms is handled through a constructor in the scripts. To take a simple script for example :<\/p>\n<table>\n<tbody>\n<tr>\n<td>sub init () {&nbsp;<\/p>\n<p>addOverlay (\u2018image.tga\u2019, 0, 0);<\/p>\n<p>playSound (\u2018tada.wav\u2019);<\/p>\n<p>pause (60);<\/p>\n<p>quitGame ();<\/p>\n<p>}<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>We can see that the background and sound are all added through built-in functions called in these game scripts.<\/p>\n<p>The whole game interpreter is basing on a stack machine to work. For built-in functions as well. That is to say, when a built-in function is called, all its attributes will be pushed into a stack which will be pop() inside the function for using.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>GSoC 2017: Sludge Engine Week 1 Week task conclusion In general, my first week of working for GSoC project was going smoothly. And a huge thank you to my mentors _sev(Eugene Sandulenko), t0by(Tobia Tesan) and all scummvm team members that has helped me during this week. Due to my project plan, my task for this [&hellip;]<\/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-13","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/yinsimei\/wp-json\/wp\/v2\/posts\/13","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.scummvm.org\/yinsimei\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.scummvm.org\/yinsimei\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/yinsimei\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/yinsimei\/wp-json\/wp\/v2\/comments?post=13"}],"version-history":[{"count":1,"href":"https:\/\/blogs.scummvm.org\/yinsimei\/wp-json\/wp\/v2\/posts\/13\/revisions"}],"predecessor-version":[{"id":14,"href":"https:\/\/blogs.scummvm.org\/yinsimei\/wp-json\/wp\/v2\/posts\/13\/revisions\/14"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/yinsimei\/wp-json\/wp\/v2\/media?parent=13"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/yinsimei\/wp-json\/wp\/v2\/categories?post=13"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/yinsimei\/wp-json\/wp\/v2\/tags?post=13"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}