MUGEN-SFF文件格式(补充)

本文是对之前发布的MUGEN-SFF文件格式的补充

关于SFFV2下色表数据第四位字节的说明

在之前的文章中,提及到了储存在ldata中的色表数据,其中8位色表的数据长度为1024,5位色表的数据长度为128
这是因为对于每一个颜色,SFF都提供了四个字节来描述,前三个字节分别表示RGB颜色值,而第四个字节貌似并没有作用
实际上,对于使用颜色透明的图像,第四位字节确实没有作用,然而对于使用了Alpha透明的索引图像来说,第四位字节则描述了颜色的(不)透明度,分为256级(0~255),在SFFV2.00和SFFV2.01区分为透明度或者不透明度

术语解释:
1.颜色透明:在MUGEN中,对于储存在SFF中的索引图像,通常在游戏中不会显示色表第一位颜色以达到的效果称为颜色透明
通常,这个颜色被称为透明颜色,特别地,PCX的透明颜色位于色表最后一位
2.Alpha透明:图像通过自带的透明度信息达到的透明效果称为Alpha透明,在PS中Alpha透明常变现为灰白方块背景
Alpha透明大多出现于RGBA图像,其他出现于8位图像,即索引图像和真彩图像都有可能出现Alpha透明
而RGBA图像没有色表,其透明信息直接储存在PNG数据中,而索引图像的透明信息则储存在色表的第四位数据
对于上述两个概念,具体可详见MUGEN视频-浅谈图像索引

关于像素点阵数据(位图数据)的说明

在之前的文章中,提到了使用Rle8、Rle5、Lz5压缩算法的索引图像其图像数据为像素对阵数据(位图数据),而不是一个标准的图像文件,所以如果想要输出标准的图像文件,则需要通过对应图像格式来生成
对于PCX图像来说,其位图数据储存在文件头(128bytes)之后,调色板数据之前,并且可能经过Rle游程编码
对于BMP图像来说,其位图数据储存在调色板数据之后至文件结束
对于PNG图像来说,其位图数据储存在IDAT关键数据块当中
并且要注意各图像格式对于位图数据的记录顺序
当然,对于大多数图像处理库来说,都拥有置位图数据的方法,而不需要手工生成

Elecbyte提供的SFF格式信息

/*--| SFF file structure
|--------------------------------------------------*\
  Version 1.01
HEADER (512 bytes)
------
Bytes
00-11  "ElecbyteSpr\0" signature                [12]
12-15  1 verhi, 1 verlo, 1 verlo2, 1 verlo3            [04]
16-19  Number of groups                        [04]
20-24  Number of images                        [04]
24-27  File offset where first subfile is located        [04]
28-31  Size of subheader in bytes                [04]
32     Palette type (1=SPRPALTYPE_SHARED or 0=SPRPALTYPE_INDIV)    [01]
33-35  Blank; set to zero                    [03]
36-511 Blank; can be used for comments                [476]

SUBFILEHEADER (32 bytes)
-------
Bytes
00-03 File offset where next subfile in the "linked list" is    [04] 
      located.  Null if last subfile

04-07 Subfile length (not including header)            [04]
      Length is 0 if it is a linked sprite
08-09 Image axis X coordinate                    [02]
10-11 Image axis Y coordinate                    [02]
12-13 Group number                        [02]
14-15 Image number (in the group)                [02]
16-17 Index of previous copy of sprite (linked sprites only)    [02]
      This is the actual
18    True if palette is same as previous image            [01]
19-31 Blank; can be used for comments                [14]
32-   PCX graphic data. If palette data is available, it is the last
      768 bytes.
\*--------------------------------------------------------------------------*/

SFFV2(注意,Elecbyte仅提供了SFFV2.00的格式信息,而不包含SFFV2.01

Terminology

ldata

 literal data.  Must be loaded verbatim.  In M.U.G.E.N, sprite data in the
 ldata block is loaded verbatim into memory, and decompressed as necessary on-the-fly.

tdata

 translate data.  Must be translated (e.g. decompressed) during
 load.

SFF 2.00
SFF header 2.00

All values are little-endian.

512 bytes

dec  hex  size   meaning
 0    0    12   "ElecbyteSpr\0" signature
12    C     1   verlo3; 0
13    D     1   verlo2; 0
14    E     1   verlo1; 0
15    F     1   verhi; 2
16   10     4   reserved; 0
20   14     4   reserved; 0
24   18     1   compatverlo3; 0
25   19     1   compatverlo1; 0
26   1A     1   compatverlo2; 0
27   1B     1   compatverhi; 2
28   1C     4   reserved; 0
32   20     4   reserved; 0
36   24     4   offset where first sprite node header data is located
40   28     4   Total number of sprites
44   2C     4   offset where first palette node header data is located
48   30     4   Total number of palettes
52   34     4   ldata offset
56   38     4   ldata length
60   3C     4   tdata offset
64   40     4   tdata length
68   44     4   reserved; 0
72   48     4   reserved; 0
76   4C   436   unused

compatver

 Minimum version of loader needed to read this SFF: 2.00


Sprite node header 2.00

28 bytes

dec  hex  size   meaning
 0    0     2   groupno
 2    2     2   itemno
 4    4     2   width
 6    6     2   height
 8    8     2   axisx
10    A     2   axisy
12    C     2   Index number of the linked sprite (if linked)
14    E     1   fmt
15    F     1   coldepth
16   10     4   offset into ldata or tdata
20   14     4   Sprite data length (0: linked)
24   18     2   palette index
26   1A     2   flags

fmt

 0 raw
 1 invalid (no use)
 2 RLE8
 3 RLE5
 4 LZ5

flags

 0    unset: literal (use ldata); set: translate (use tdata; decompress on load)
 1-15 unused


Pal node header 2.00

16 bytes

dec  hex  size   meaning
 0    0     2  groupno
 2    2     2  itemno
 4    4     2  numcols
 6    6     2  Index number of the linked palette (if linked)
 8    8     4  Offset into ldata
12    C     4  Palette data length (0: linked)

Palette data is stored in 4 byte chunks per color. The first 3 bytes correspond to 8-bit values for RGB color, and the last byte is unused (set to 0). 

发表评论

电子邮件地址不会被公开。 必填项已用*标注