{"id":9,"date":"2016-03-02T06:11:24","date_gmt":"2016-03-02T06:11:24","guid":{"rendered":"http:\/\/jaytheham.com\/tink\/?p=9"},"modified":"2016-09-13T03:46:27","modified_gmt":"2016-09-13T03:46:27","slug":"textures-and-compression","status":"publish","type":"post","link":"http:\/\/jaytheham.com\/tink\/?p=9","title":{"rendered":"Textures and compression"},"content":{"rendered":"<div id=\"attachment_20\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/jaytheham.com\/tink\/wp-content\/uploads\/2016\/03\/nearlyButNotReally.jpg\" rel=\"attachment wp-att-20\"><img aria-describedby=\"caption-attachment-20\" decoding=\"async\" loading=\"lazy\" class=\"size-medium wp-image-20\" src=\"http:\/\/jaytheham.com\/tink\/wp-content\/uploads\/2016\/03\/nearlyButNotReally-300x175.jpg\" alt=\"Your car when you load a texture but forgot to set half the UVs\" width=\"300\" height=\"175\" srcset=\"http:\/\/jaytheham.com\/tink\/wp-content\/uploads\/2016\/03\/nearlyButNotReally-300x175.jpg 300w, http:\/\/jaytheham.com\/tink\/wp-content\/uploads\/2016\/03\/nearlyButNotReally-768x449.jpg 768w, http:\/\/jaytheham.com\/tink\/wp-content\/uploads\/2016\/03\/nearlyButNotReally-1024x599.jpg 1024w, http:\/\/jaytheham.com\/tink\/wp-content\/uploads\/2016\/03\/nearlyButNotReally-624x365.jpg 624w, http:\/\/jaytheham.com\/tink\/wp-content\/uploads\/2016\/03\/nearlyButNotReally.jpg 1296w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-20\" class=\"wp-caption-text\">Your car when you load a texture but forgot to set half the UVs<\/p><\/div>\n<p>Well on the path to getting car texture support done, but there have been a few trials along the way.<br \/>\nFirstly the game uses a format I haven&#8217;t run into before:<br \/>\nThe indices are stored in interleaved order (all even rows, then all odd rows) and the odd rows are word swapped (xxxxxxxx yyyyyyyy is stored as yyyyyyyy xxxxxxxx), very strange.<\/p>\n<p>Second problem I have yet to resolve, I haven&#8217;t found how the game keeps track of the texture sizes. This may be hard-coded for car data, as they seem to use 80&#215;38 textures for everything except the wheels, and the wheels have a separate block of texture pointers to the rest of the car parts. Hopefully looking at the track data which has a variety of texture sizes will shed more light on this.<\/p>\n<p>Finally, and perhaps most frustrating, the game appears to use a slightly modified version of zlib 1.0.4 (there&#8217;s a string referring to this version in the ROM) to inflate the compressed data. You can use vanilla zlib to decompress and compress data and more often than not you&#8217;ll get the same output as the game, buuut not 100% of the time. Hoping that it was perhaps just some breaking change in zlib (which is currently v2.x) I grabbed the source for 1.0.4 and tried that, but it gives the exact same output. So now I have to reverse the game&#8217;s inflate routine to be able to extract correct data. Reversing an ASM routine is kinda fun, but can be painful as well.<\/p>\n<p>Such is life.<\/p>\n<div id=\"attachment_24\" style=\"width: 635px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/jaytheham.com\/tink\/wp-content\/uploads\/2016\/03\/LoD.jpg\" rel=\"attachment wp-att-24\"><img aria-describedby=\"caption-attachment-24\" decoding=\"async\" loading=\"lazy\" class=\"size-large wp-image-24\" src=\"http:\/\/jaytheham.com\/tink\/wp-content\/uploads\/2016\/03\/LoD-1024x599.jpg\" alt=\"The most detailed of the three LoD models\" width=\"625\" height=\"366\" srcset=\"http:\/\/jaytheham.com\/tink\/wp-content\/uploads\/2016\/03\/LoD-1024x599.jpg 1024w, http:\/\/jaytheham.com\/tink\/wp-content\/uploads\/2016\/03\/LoD-300x175.jpg 300w, http:\/\/jaytheham.com\/tink\/wp-content\/uploads\/2016\/03\/LoD-768x449.jpg 768w, http:\/\/jaytheham.com\/tink\/wp-content\/uploads\/2016\/03\/LoD-624x365.jpg 624w, http:\/\/jaytheham.com\/tink\/wp-content\/uploads\/2016\/03\/LoD.jpg 1296w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/a><p id=\"caption-attachment-24\" class=\"wp-caption-text\">The most detailed of the three LoD models<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Well on the path to getting car texture support done, but there have been a few trials along the way. Firstly the game uses a format I haven&#8217;t run into before: The indices are stored in interleaved order (all even rows, then all odd rows) and the odd rows are word swapped (xxxxxxxx yyyyyyyy is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6,7],"tags":[8,2,9,4],"_links":{"self":[{"href":"http:\/\/jaytheham.com\/tink\/index.php?rest_route=\/wp\/v2\/posts\/9"}],"collection":[{"href":"http:\/\/jaytheham.com\/tink\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/jaytheham.com\/tink\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/jaytheham.com\/tink\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/jaytheham.com\/tink\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9"}],"version-history":[{"count":7,"href":"http:\/\/jaytheham.com\/tink\/index.php?rest_route=\/wp\/v2\/posts\/9\/revisions"}],"predecessor-version":[{"id":26,"href":"http:\/\/jaytheham.com\/tink\/index.php?rest_route=\/wp\/v2\/posts\/9\/revisions\/26"}],"wp:attachment":[{"href":"http:\/\/jaytheham.com\/tink\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/jaytheham.com\/tink\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/jaytheham.com\/tink\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}