logo Sign In

Post #279397

Author
Laserman
Parent topic
I will be away for three weeks.
Link to post in topic
https://originaltrilogy.com/post/id/279397/action/topic#279397
Date created
26-Mar-2007, 10:46 PM
Originally posted by: boba feta
.SAN files Laserman, they're what the rare stuff on Making Magic is encoded in. What do you know about them and is there some sort of tool ala grisc that we might be able to use to decode them?

And I hope it all goes well for you this time round. I'll have a beer in your honour.

Cheers man

e-mail me a .san file and I'll take a quick look, I have the scumm documentation on my machine, but don't have BTM with me.

Multimedia format research based on ScummVM

* a chunked multimedia format possibly with several variations
* multi-byte numbers are little endian (always?)
* no: the chunk lengths are big endian
* chunks are marked by FOURCCs; known FOURCCs:
- ANIM
- AHDR
- FRME
- NPAL
- FOBJ
- PSAD
- TRES
- XPAL
- LACT
- STOR
- FTCH
- SKIP
- STRK
- SMRK
- SHDR
- SDAT
- SAUD
- iMUS
- FRMT
- TEXT
- REGN
- STOP
- MAP_
- DATA
- ETRS
* carries a payload comprised of different chunk types
* these chunk types are known:
- codec 1
- codec 37
- codec 44
- codec 47

* codec 1: RLE encoding:
- for each line in image height:
- 16-bit number indicates encoded line size
- while there are still encoded data bytes for this line:
- next byte is code
- length = code / 2 + 1
- if bit 0 of code is set:
- value = next byte
- if value is 0:
- skip (length) pixels in output
- else:
- put (value) in output (length) times
- else:
- for each count in length:
- value = next byte
- if value is 0:
- skip pixel in output
- else:
- put value in output


* codec 37:
- assign width and height
- assign bw as block width
- assign bh as block height
- codec must operate on 4x4 blocks
- assign pitch as block width * 4 (not the same as width necessarily since
block width is rounded up to nearest multiple of 4)
- assign chunk size as size of input chunk - 14
- allocate a buffer with that size
- read chunk_size bytes into new buffer
- sequence number LE_16 @ chunk[2]
- decoded size is LE_32 @ chunk[4]
- maskflags = chunk[12]
- make table with pitch and chunk_buffer[1] as index:
- index *= 255
- if (index + 254 < sizeof(table) / 2)
- assert error condition
- for i = 0..255
- j = (i + index) * 2
- offsettable = maketable_bytes[j+1] * pitch + maketable_bytes[j]
- if (chunk[0] == 0)

- else if (chunk[0] == 1)
- "missing opcode codec47" (?)

- else if (chunk[0] == 2)

- else if (chunk[0] == 3)

- else if (chunk[0] == 4)


* codec 44:
- iterate through the encoded chunk from 0 to size - 14 (?):
- size of encoded line = next LE_16 in chunk
- while size is not 0:
- count = next byte
- pixel = next byte
- put (pixel) in output (count) times
- if size of line is not 0 at this point:
- count = next LE_16 + 1
- copy (count) pixels from encoded stream to output
- at the end of line, output buffer rewinds by one pixel (?)


* codec 47:
- chunk size = size of chunk passed in minus 14 bytes
- sequence number = first LE_16 of chunk
- encoded graphic data begins at chunk + 26
- the bytes at chunk[12] and chunk[13] serve as initializers for
deltabufs[0] and [1] respectively