Example of using anims.j2a
Just a very basic example, we'll use the first frame of the first animation of the first set for this tutorial. This assumes that you have already decompressed the first ANIM sub-file into Data1, Data2 and Data3 buffers.
Peeking into Data1 - Animation Info
Okay, we will just look at the first animation (8 bytes):
Code:
07 00 0A 00 00 00 00 00
The first "07 00" means it has 7 frames in the animation (first 7 * 24 bytes in Data2) and the "0A 00" stands for 10 something (I assumed FPS). Straightforward.
Peeking into Data2 - Frame Info
We shall just look at the first frame defined in this buffer (in this case, the first frame of the first animation), 24 bytes long:
Code:
11 00 10 00 00 00 00 00 F7 FF F5 FF 00 00 00 00 00 00 00 00 D0 05 02 00
I should probably have done this in a table, but I'm just too lazy:
The first "11 00" means a width of 17 pixels, "10 00" a height of 16 pixels. The "00 00" and "00 00" after it would refer to the coldspot's x and y, except a zero means that none is defined.
The "F7 FF" which converts to -9 in a signed short, means that the frame starts drawing
9 pixels to the left of the hotspot. Similarly the "F5 FF" means the frame starts drawing 11 pixels above.
The next four zeros obey the same rule as the coldspot.
The four zeros after that indicate the starting address of the image within Data3 (image data). Note that this address is aligned to 8 bytes (always a multiple of 8).
Finally the last four zeros indicate the starting address (in Data3) of the mask for this frame. This one is aligned to bytes. If the mask address is given as -1 (FF FF FF FF), then there is no mask given for it.
Peeking into Data3 - Image Data
Yay, we've come to the really fun part. It is slightly technical but not very difficult. If you are already familiar with RLE this concept should be a breeze. Remember we had an image address of 00000000, so we will read address 0 of Data3:
Code:
11 80 10 00 06 81 23 80 03 81 24 02 82 25 24 80
81 25 01 83 25 23 25 02 82 23 25 80 85 24 23 24
22 24 02 81 25 80 85 23 24 23 21 23 01 81 25 80
88 24 25 23 40 22 25 22 25 80 89 2f ......
As mentioned before the first 4 bytes of the image data for the frame is the width and height (again), except that the most significant bit of the width is set. This could possibly a flag, or something else, I haven't quite researched this yet. So after the 4 bytes, the image begins, as a series of codebytes. Refer to previous post(s) for more details, but you could imagine it as being rearranged like this:
Code:
06 81 23 80 skips 6 bytes, then copies one byte, then NEXT
03 81 24 02 82 25 24 80 skips 3 bytes, copies 1, skips 2, copies 2
81 25 01 83 25 23 25 02 82 23 25 80
85 24 23 24 22 24 02 81 25 80
85 23 24 23 21 23 01 81 25 80
88 24 25 23 40 22 25 22 25 80
89 2f ...
And you'll end up with something looking like this:
|
Note: I included a palette for convenience. But basically, those few bytes we just went through would have drawn the first 6 rows of the "flame" .
Also, I'm not a HTML expert or anything, so some stuff could not appear the way I wanted to. Anyway, it would be great if anyone could help convert this into an ERE-readable format, since I now hate Textile.
Oh yeah, and if anyone wondered what happened to Data4 (Sample Data), I have no idea how to use it. So figure it out yourself :P.
This ends the J2A section of the file formats, very dull stuff. So I'll probably be making the J2T and J2L versions much more condensed (even though they can be much more complicated than this).
|