Bard's Tale Compression Algorithm

Talk about everything related to general reverse engineering of computer games!

Moderator: Kroah

Bard's Tale Compression Algorithm

Postby RevenantBob » 24 Jul 2015, 21:49

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.
RevenantBob
 
Posts: 4
Joined: 24 Jul 2015, 21:45

Re: Bard's Tale Compression Algorithm

Postby Kroah » 26 Jul 2015, 13:40

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
Kroah
Site Admin
 
Posts: 430
Joined: 07 Feb 2006, 01:01
Location: France

Re: Bard's Tale Compression Algorithm

Postby RevenantBob » 05 Aug 2015, 01:14

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.
RevenantBob
 
Posts: 4
Joined: 24 Jul 2015, 21:45

Re: Bard's Tale Compression Algorithm

Postby RevenantBob » 05 Aug 2015, 21:05

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.
RevenantBob
 
Posts: 4
Joined: 24 Jul 2015, 21:45

Re: Bard's Tale Compression Algorithm

Postby RevenantBob » 10 Aug 2015, 18:00

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.
RevenantBob
 
Posts: 4
Joined: 24 Jul 2015, 21:45

Re: Bard's Tale Compression Algorithm

Postby Kroah » 03 Sep 2015, 18:43

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.
Kroah
Site Admin
 
Posts: 430
Joined: 07 Feb 2006, 01:01
Location: France


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 4 guests

cron