Page 1 of 1

Bard's Tale Compression Algorithm

PostPosted: 24 Jul 2015, 21:49
by RevenantBob
I've been porting Bard's Tale PC 1 to Win32 and C++. The reason is mostly so I can do Mods and such while gleaning more information.

I've been using IDA to disassemble and reverse engineer with DOS Box for debugging.

The game has a complicated decompression function which was clearly written in assembly. I thought perhaps some light could be shed on this compression algorithm? I noticed there is .NET source for dealing with individual files, but I wasn't sure if it was using the same compression algorithm for every graphics file yet.

I thought I might save time here and ask in this forum.

Otherwise I'll be trying to get a clear view of how it's turning these files into their uncompressed state.

Thanks in advance.

Re: Bard's Tale Compression Algorithm

PostPosted: 26 Jul 2015, 13:40
by Kroah
Welcome RevenantBob,

I'm sorry, but i can't stand x86 ASM.

Each version of the compression and animation scheme i disassembled differs slightly.

You can download and browse the source of some decompression routines on my Bard's Tale page, but i can't give you more, especially on PC...
On PC, i don't know if BT1 uses the same routines as the BTCS, but the source includes everything for BTCS PC, this could help you.

Imho, by understanding how the animations are handled, you will have some hints while disassembling your version (for example, animations use XOR blitting).

Have fun with IDA :),
Pascal

Re: Bard's Tale Compression Algorithm

PostPosted: 05 Aug 2015, 01:14
by RevenantBob
I figured out the compression.

It uses Huffman with bit reading.

I got the title screens and spell icons figured out.

Working on the bigpic file. It's not straight forward since it has RLE encoding after the huffman. I think I got the pixel indices right, but I don't think it just renders straight through as is. Still hammering away.

Re: Bard's Tale Compression Algorithm

PostPosted: 05 Aug 2015, 21:05
by RevenantBob
If I understand these animation frames right there's a 16-bit offset, then 8 pixels to be XOR'd. However, this 16-bit offset is odd to me. Your calculation in your tool don't seem to match it (Amiga vs PC?) unless I got something else wrong in my code. The X/Y goes outside the view window.

Re: Bard's Tale Compression Algorithm

PostPosted: 10 Aug 2015, 18:00
by RevenantBob
I got it working awhile ago, figured I'd just post so you can ignore it =) Been reversing the gameplay now, and actually have the whole adventurer's guild implemented.

Re: Bard's Tale Compression Algorithm

PostPosted: 03 Sep 2015, 18:43
by Kroah
RevenantBob wrote:I got it working awhile ago, figured I'd just post so you can ignore it =) Been reversing the gameplay now, and actually have the whole adventurer's guild implemented.

Thanks for your feedbacks and glad you figured out the decoding scheme.

Good luck with reversing the engine, i started working on the Atari ST engine but eventually losing interest.