{"id":23,"date":"2008-06-16T10:42:47","date_gmt":"2008-06-16T08:42:47","guid":{"rendered":"https:\/\/blogs.scummvm.org\/buddha\/?p=23"},"modified":"2022-04-15T10:55:59","modified_gmt":"2022-04-15T08:55:59","slug":"delphine-compression-format-deciphering","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/buddha\/2008\/06\/16\/delphine-compression-format-deciphering\/","title":{"rendered":"Delphine compression format deciphering"},"content":{"rendered":"<p>Spent most of my work time last week deciphering Delphine\u2019s compression format. Now I feel satisfied by having made the implementation in ScummVM\u2019s Cine-engine quite robust and hopefully understandable too (I documented it and really made myself understand what the darn thing does).<\/p>\n<p>The decompression code had been initially reverse engineered from disassembly by someone else and there were no comments to speak of so that\u2019s why it wasn\u2019t very understandable to me in the beginning. Just compare the older version that I started with (<a href=\"http:\/\/scummvm.svn.sourceforge.net\/viewvc\/scummvm\/scummvm\/trunk\/engines\/cine\/unpack.h?revision=29466&amp;view=markup\">Header file<\/a> &amp; <a href=\"http:\/\/scummvm.svn.sourceforge.net\/viewvc\/scummvm\/scummvm\/trunk\/engines\/cine\/unpack.cpp?revision=29466&amp;view=markup\">code file<\/a>) with the version that\u2019s now in place (<a href=\"http:\/\/scummvm.svn.sourceforge.net\/viewvc\/scummvm\/scummvm\/trunk\/engines\/cine\/unpack.h?revision=32689&amp;view=markup\">Header file<\/a> &amp; <a href=\"http:\/\/scummvm.svn.sourceforge.net\/viewvc\/scummvm\/scummvm\/trunk\/engines\/cine\/unpack.cpp?revision=32689&amp;view=markup\">code file<\/a>).<\/p>\n<p><!--more--><\/p>\n<p>I also wrote <a href=\"http:\/\/wiki.scummvm.org\/index.php\/Cine\/Specifications#Compression_format\">documentation for the compression format<\/a> to ScummVM\u2019s wiki (Look there if you want to intimately know how the compression format works).<\/p>\n<p>So in the end it turned out the compression algorithm used by Delphine\u2019s adventure games uses sliding window compression (Quite like <a class=\"external text\" title=\"http:\/\/en.wikipedia.org\/wiki\/LZ77\" href=\"http:\/\/en.wikipedia.org\/wiki\/LZ77\" rel=\"nofollow\">LZ77<\/a>) combined with a fixed non-adaptive <a class=\"external text\" title=\"http:\/\/en.wikipedia.org\/wiki\/Entropy_coding\" href=\"http:\/\/en.wikipedia.org\/wiki\/Entropy_coding\" rel=\"nofollow\">entropy coding<\/a> scheme (Not of any type I could recognize).<\/p>\n<p>Now to use the decompressor and unpack all those scripts and do the comparison\u2026<\/p>\n<p>P.S. Oh, and I also tried IDA\u2019s graph view for the first time and worked with it on Delphine\u2019s unpacking routine\u2019s disassembly. Here\u2019s an image of the <a href=\"https:\/\/buddhahacks.files.wordpress.com\/2008\/06\/cineunpack-graph-idapro52.png\">abstracted graph of the unpacking function<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Spent most of my work time last week deciphering Delphine\u2019s compression format. Now I feel satisfied by having made the implementation in ScummVM\u2019s Cine-engine quite robust and hopefully understandable too (I documented it and really made myself understand what the darn thing does). The decompression code had been initially reverse engineered from disassembly by someone [&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-23","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/buddha\/wp-json\/wp\/v2\/posts\/23","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.scummvm.org\/buddha\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.scummvm.org\/buddha\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/buddha\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/buddha\/wp-json\/wp\/v2\/comments?post=23"}],"version-history":[{"count":1,"href":"https:\/\/blogs.scummvm.org\/buddha\/wp-json\/wp\/v2\/posts\/23\/revisions"}],"predecessor-version":[{"id":24,"href":"https:\/\/blogs.scummvm.org\/buddha\/wp-json\/wp\/v2\/posts\/23\/revisions\/24"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/buddha\/wp-json\/wp\/v2\/media?parent=23"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/buddha\/wp-json\/wp\/v2\/categories?post=23"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/buddha\/wp-json\/wp\/v2\/tags?post=23"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}