Skip to content

Commit

Permalink
Compressed data handling improved.
Browse files Browse the repository at this point in the history
  • Loading branch information
yam-anssi committed Nov 25, 2016
1 parent eaeb27c commit c9de786
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ With the following arguments meaning:
```
## Changelog
```
25/11/2016 1.01 Compressed data handling improved.
25/11/2016 1.00c Unused variable removed.
10/08/2016 1.00b --dest parameter processing fixed.
01/07/2016 1.00a cacheXXXX.bin header detection fixed.
Expand Down
19 changes: 18 additions & 1 deletion bmc-tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def b_process(self):
if len(self.bdat) == 0:
self.b_log(sys.stderr, False, 3, "Nothing to process.")
return False
bl = 0
while len(self.bdat) > 0:
old = False
o_bmp = ""
Expand All @@ -63,7 +64,23 @@ def b_process(self):
t_len, t_params = unpack("<LL", t_hdr[-0x8:])
if t_params & 0x08: #This bit is always ONE when relevant data is smaller than expected data, thus it is most likely the "compression" bit flag.
self.b_log(sys.stdout, False, 3, "Tile data is compressed (%d bytes compressed in %d bytes); skipping." % (t_width*t_height*4, t_len))
bl = 64*64*2
if bl == 0:
if "22.bmc" in self.fname:
bl = 64*64*2
elif "24.bmc" in self.fname:
bl = 64*64*4
elif "2.bmc" in self.fname:
bl = 64*64
else:
for b in [1, 2, 4]:
if len(self.bdat) < len(t_hdr)+64*64*b+8:
break
elif unpack("<H", self.bdat[len(t_hdr)+64*64*b+8:][:2])[0] == 64:
bl = 64*64*b
break
if bl == 0:
self.b_log(sys.stderr, False, 3, "Unable to determine data pattern size; exiting before throwing any error!")
return False
else:
cf = t_len/(t_width*t_height)
if cf not in [1, 2, 4]:
Expand Down

0 comments on commit c9de786

Please sign in to comment.