PSP开发--PBP文件格式说明

PBP文件实际上是一个文件容器,其中可能容纳的文件格式包括:

  1. 说明文件 (PARAM.SFO)
  2. 预览图 (ICON0.PNG)
  3. 预览视频 (ICON1.PMF)
  4. 介绍图片 (PIC0.PNG)
  5. 背景图 (PIC1.PNG)
  6. 音乐 (SND0.AT3)
  7. 执行数据 (DATA.PSP)
  8. 其他数据文件 (DATA.PSAR)

这些文件之间没有任何分隔符,PBP文件头为固定的40字节,说明如下:

偏移量内容说明
0-3文件类型/说明 总是一个00跟着"PSP"
4-7PBP版本(?) 总是00 00 01 00
8-11PARAM.SFO的偏移量 
12-15ICON0.PNG的偏移量  
16-19ICON1.PMF的偏移量  
20-23PIC0.PNG的偏移量 
24-27PIC1.PNG的偏移量  
28-31SND0.AT3的偏移量 
32-35DATA.PSP的偏移量  
36-39DATA.PSAR的偏移量  

如果PBP中若没有包含某文件的话,则该文件的偏移量与上一个文件的偏移量相同。比如:如果一个PBP中只有PARAM.SFO, ICON0.PNG 和 DATA.PSP,则偏移量应与下面的类似:

文件PARAM.SFOICON0.PNGICON1.PMFPIC0.PNGPIC1.PNGSND0.AT3DATA.PSPDATA.PSAR
偏移量40177217721772177217722060620606

SFO 文件
SFO文件被PSP用来存储有关游戏和软件信息,比如固件升级和UMD游戏,他们本质上是一个键值对的文件。对齐方式是4字节(byte)。SFO的头文件共20个字节。如下:

偏移量内容说明
0-3文件类型/描述 总是一个00跟着"PSF".
4-7PSF版本总是 01 01 00 00.
8-11键表的偏移量 In bytes. Relative to start of file. 32-bit unsigned little endian.
12-15值表的偏移量 In bytes. Relative to start of file. 32-bit unsigned little endian.
16-19Number of Data Items. 32-bit unsigned little endian.  

紧接着是索引表,每条记录描述一条数据项。每个数据项在索引表里包括以下数据:

OffsetContentsRemarks
0-1Offset of Key Name in Key TableAlways a null byte followed by "PSF".
2Data-alignment requirements (?)Always 04. Single (1) byte.
3Data type of value Single (1) byte. See below for data-type information.
4-7Size of Value data In bytes. 32-bit unsigned little endian.
8-11Size of Value data and Padding 32-bit unsigned little endian.
12-15Offset of Data Value in Data Table 32-bit unsigned little endian.

"Offset of Key Name in Key Table" means just that. The first item will have offset 0 (ZERO). The same principle is true for "Offset of Data Value in Data Table"

Data types are one of 3:-

  • 0 - Binary data. Its format and interpretation depends on its Key.
  • 2 - Text. A null-terminated UTF-8 string. Note that "Size of Value data" includes the null byte. Also note that CRLF acts as a line break - this can be used for "Title" data and so forth.
  • 4 - Number. A 32-bin little endian integer value.


Next comes the Key Table. This is a simple list of all Key names. Each key name is null-terminated.
Key names need to be in alphabetical order. Presumably, a binary search is carried out to find data values and their respective keys.
The 'Key Table' must conform to 4-byte data alignment. Null padding can fulfill this requirement after the final key.

After this comes the all-important Value Table. Essentially, the Data items are listed one after another.
String (Type 2) and Binary (Type 0) data may have any amount of padding in the form of null bytes.
Each data item has to conform to the data alignment requirements. Once again, null bytes can fulfill this requirement by being added on the end of the data.

N.B.
The "Category" key describes the purpose of the SFO file. The three options are MS (MemoryStick SaveGame), MG (MemoryStick Game) and UG (UMD Game).
An interesting observation is that when "Category" is "MS", the "MS" string and only the "MS" string is not null terminated.
The practical implication of this is simply that "Size of Data" for "MS" is 2 (rather than 3) and null bytes must still fill the remaining 2 bytes as normal.



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值