• Welcome to Final Fantasy Hacktics. Please login or sign up.
 
March 28, 2024, 01:08:06 pm

News:

Use of ePSXe before 2.0 is highly discouraged. Mednafen, RetroArch, and Duckstation are recommended for playing/testing, pSX is recommended for debugging.


.SPR File Format

Started by andredoubleu, November 27, 2013, 11:48:22 pm

andredoubleu

Hi, I'm new to this forum!  For a school assignment in my computer graphics course, I'm trying to program Orbonne Monastery, insert a few sprites, and animate the sprites moving around and attacking each other.  For the sprites, I COULD use the .BMP files that I found here on FFH, but the .SPR files look more appealing since they probably contain meta data about how all the pieces of the sprites connect to each other.  Is the exact file format of a .SPR file described anywhere?  What I'm looking for exactly is something like: the first 4 bytes represent x, the next 12 bytes represent y, etc.  Thanks in advance!

lirmont

This is a link to the source code of the program that reads and replaces SPR files in ISO files: http://code.google.com/p/lioneditor/source/browse/branches/imageEditorv2/FFTPatcher/ShishiSpriteEditor/#ShishiSpriteEditor%2FDataTypes.

You should actually probably use that program (copious amounts of tutorials here on how) to investigate what a SPR actually entails first (note: there are more parts than just the SPR file, which acts like an index to said other parts + image container, from what I understand).

If you just want to hop right into writing something that shows something on the screen, you can use the almost functionally equivalent XML format documents from the program I wrote to write your own wrapper (to consume the XML and display an composited image). The link to that is here: http://ffhacktics.com/smf/index.php?topic=7409.0. You don't need a license for the program to grab the XML files from the zip file, and they should be pretty self-explanatory. You can also read the help (a CHM file) in the zip to help understand what those things do.

Choto

If you want to see how the frames come together and how the animations are chosen, you're going to want to investigate the .SHP and .SEQ files. The .SHP hold the frame information, while the .SEQ hold the animation information. The .SPR is just the actualy bitmap graphics of the different sprites.

The .SHP file is broken up into sections. There is some junk in the first couple words or so, then there are a bunch of 4 byte words. These words point from the address 0x40A I believe. So each "whatever it is" is 6 bytes long, starting from 0x40A. What these bytes correspond to, i'm not sure.

Then there's a similar 2 sections after that, the first being 4 byte offset words, and another table of data that those offsets point to. Although those "things" are 10 bytes long instead of 6.

What those sections correspond to i'm not sure. Looking at the program that imports them into ShiShi that Lirmont posted should help. My guess is that some contain "where on the sheet the frame is cut from",  and some contain "where the frame is displayed on screen. and perhaps the layer order.

Alternatively, if you just want to get stuff moving around on screen, There's the EasyEvent Editor that we use to make our custom events. It should be easy enough to get guys moving around and attacking each other. Elric is the resident expert there. That's probably the cheap way. If you're more ambitious, doing what Lirmont said seems like it would be a good way to go.

Xifanie may have other information about SHP or SEQ files too

andredoubleu

Wow, thanks for the swift replies.  Lirmont, I downloaded the Sprite Animator Tool and checked out the xml files.  It looks like exactly what I'm looking for.  However, I'm having some trouble deciphering it.  Under:

<frames>
    <frame id="1" s="240" t="176" w="8" h="8" />
    <frame id="2" s="0" t="0" w="32" h="40" />
    <frame id="3" s="32" t="0" w="32" h="40" />
    etc
</frames>

do the frame ids correspond to the same boxes in the reference.bmp file?

Also, I assume 'w' and 'h' are width and height, but what are 's' and 't'?

I assume composite frames are frames that are made up of several frames, like connecting an upper body with a lower body and some arms.  Also, composite frame sets probably connect multiple composite frames to give the appearance of movement, like walking and swinging the arms.  Is this understanding correct?

Finally, how do I go about getting a license to use the Sprite Animator Tool?  I tried running the program, thinking it would help me understand the xml file a little bit better, but I don't think I have a valid account to license.

Thanks again.

lirmont

"s" and "t" are just "x" and "y" in the pixel space defined by "base-width" and "base-height". It's one of the conventions of texture coordinates in 3d space (of which UVW is another and not used here). This creates a rectangle that contains the points: (0, 0) and (w, h). The points have the following texture coordinates: (s / base-width, t / base-height) and ((s + w) / base-width, (t + h) / base-height). Depending on how you load the image (if it gets loaded upside down), you may have to complement the vertical portion of the texture coordinates, which means that that becomes: (s / base-width, 1 - t / base-height) and ((s + w) / base-width, 1 - (t + h) / base-height).

The frame id's are not guaranteed to correspond to the reference bitmap (reference bitmaps are not created by the program).

Composite frames are frames in an animation, like a key frame in a video (except, in this codec there would only ever be key frames).

I sent you a username/password you can use to log into the program, but using it comes with the agreement that you'll either help make the program better (re: write what you think about it is good, bad, or especially confusing so I can fix it) or help advertise Tethical's existence.

Thanks.

andredoubleu

Okay, I think I'm getting this.  All of that with the texture coordinates makes sense now.

I opened Sprite Animator with a Type 1 Cloud that I found here on FFH, and used the arrow keys to select frame 12.  Then I examined the XML file and under "composite frame 12" I saw that it referenced frame id's 13, 14, and 15.  I looked at those 3 frames in the XML file and verified that the coordinates match a left arm, a body, and a right arm in the original BMP file.  Do the offset-x and offset-y also represent texture coordinates so that the different body parts align correctly?  Also, can you explain what "named attachment points" are?


<composite-frame id="12">
      <frame id="999" named-attachment-point-id="13" flip-x="True" offset-x="16" offset-y="25" />
      <frame id="13" offset-x="9" offset-y="15" />
      <frame id="999" named-attachment-point-id="3" flip-x="True" offset-x="16" offset-y="27" rotation-z="51" />
      <frame id="14" offset-x="6" offset-y="7" />
      <frame id="999" named-attachment-point-id="6" flip-x="True" offset-x="22" offset-y="29" rotation-z="45" />
      <frame id="15" offset-x="14" offset-y="19" />
      <frame id="999" named-attachment-point-id="11" offset-x="14" offset-y="8" />
      <frame id="999" named-attachment-point-id="12" offset-x="14" offset-y="8" />
</composite-frame>

lirmont

"offset-x" and "offset-y" are horizontal and vertical translation from the box created by: (0, 0) and (frame-width, frame-height). Positive x and y values go downwards towards the lower-right corner (which is the second point). Named attachment points are a data structure used to identify an external image (which you can realize onto the composite frame in "View" -> "Available Attachments"). The image you attach inherits whatever the frame call the named attachment point is applied to has. In other words, if you identify a certain frame call as the named attachment point for "Weapon.1.Forward", not only will the program attach the image you supply for "Weapon.1.Forward", it will also offset, rotate, scale, or flip the image to match the frame call. There are pictures in the help file ("About" -> "Help") and in this thread: http://ffhacktics.com/smf/index.php?topic=9891.0.