06-02-2008, 03:55 AM
Zalos Wrote:however to go straight out and say Its probably beyond your level already, with knowing next to nothing about me tells me alot about yourself, very assumptive
Actually I was saying that if you have no idea where to even begin when it comes to shrinking the map's size by using binary that it is beyond your level. I was not saying you yourself, but just you the reader. That would be like trying to optimize your code by doing some in-line assembly without even knowing assembly.
Zalos Wrote:I went through and read spodi's huge Post, Great explanations of how to do things your way rather impressive as well mind if I see If I can do something with it?
Of course, thats what its there for.

Vegeta Wrote:Hey Spodi, would you mind shedding a bit of light on how to do the decoding?
Sure. First just grab the name and revision as those will always be there in that order. Next grab the HeaderBitFlags integer. Then, in order, check if a bit is set and if it is, grab the bit for that value. It'll look a lot like how it is already for the output but using Get instead of Put:
Code:
If HeaderBitFlags And 1 Then Get #f, , .Moral
If HeaderBitFlags And 2 Then Get #f, , .Up
If HeaderBitFlags And 4 Then Get #f, , .Down
If HeaderBitFlags And 8 Then Get #f, , .Left
If HeaderBitFlags And 16 Then Get #f, , .Right
If HeaderBitFlags And 32 Then Get #f, , .Music
If HeaderBitFlags And 64 Then Get #f, , .BootMap
...etc
Now for the harder part. Initialize the LastTile values to the defaults (vital they're the same defaults as the encoder) then make a For loop just like above for the tiles. Then grab the TileBitFlags byte. Read the bits just like you wrote them, but you also have to add an "Else" for when the bit is not set which tells you it is going to be equal to the LastTile value. It'll look something kinda like this:
Code:
LastTile.Anim = 0
LastTile.Data1 = 0 '... I'm just using all 0's because I have no idea what the [edit] these typically are
For y = 0 To MAX_MAPY
For x = 0 To MAX_MAPX
TileBitFlags = 0
With .Tile(x, y)
Get #f, , TileBitFlags
' If you uncomment this line, you can remove all the Else statements
' I have below. The end result is the exact same.
'.Tile(x, y) = LastTile
If TileBitFlags And 1 Then Get #f, , .Anim Else .Anim = LastTile.Anim
If TileBitFlags And 2 Then Get #f, , .Data1 Else .Anim = LastTile.Data1
If TileBitFlags And 4 Then Get #f, , .Data2 Else .Anim = LastTile.Data2
If TileBitFlags And 8 Then Get #f, , .Data3 Else .Anim = LastTile.Data3
If TileBitFlags And 16 Then Get #f, , .Fringe Else...
If TileBitFlags And 32 Then Get #f, , .Ground
If TileBitFlags And 64 Then Get #f, , .Mask
If TileBitFlags And 128 Then Get #f, , .Type
End With
LastTile = .Tile(x, y)
Next x
Next y
The resemblance to the encoder is very strong as you can see. For the most part theres just the Put being changed to Get.