PBP文件格式说明
1 PBP文件
PBP文件实际上是一个文件容器,其中可能容纳的文件格式包括:
这些文件之间没有任何分隔符,PBP文件头为固定的40字节,说明如下:
如果PBP中若没有包含某文件的话,则该文件的偏移量与上一个文件的偏移量相同。比如:如果一个PBP中只有PARAM.SFO, ICON0.PNG 和 DATA.PSP,则偏移量应与下面的类似:
2 SFO Files
SFO files are used by the Sony PSP to provide information about SaveGames and software such as firmware updates and UMD games. They are essentially a file of Key/Data pairs. It is important to know that SFO files have 4-byte data-alignment requirements. That is, the size of some parts must be divisible by 4. Where and how this is applicable will be explained. The 20-byte SFO header is as follows:-
Next comes the Index table. Each entry in this 'table' describes a data item. Each item in the Index table contains the following data:-
"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:-
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.
PBP文件实际上是一个文件容器,其中可能容纳的文件格式包括:
- 说明文件 (PARAM.SFO)
- 预览图 (ICON0.PNG)
- 预览视频 (ICON1.PMF)
- 介绍图片 (PIC0.PNG)
- 背景图 (PIC1.PNG)
- 音乐 (SND0.AT3)
- 执行数据 (DATA.PSP)
- 其他数据文件 (DATA.PSAR)
这些文件之间没有任何分隔符,PBP文件头为固定的40字节,说明如下:
偏移量 | 内容 | 说明 |
---|---|---|
0-3 | 文件类型/说明 | 总是一个00跟着"PSP" |
4-7 | PBP版本(?) | 总是00 00 01 00 |
8-11 | PARAM.SFO的偏移量 | |
12-15 | ICON0.PNG的偏移量 | |
16-19 | ICON1.PMF的偏移量 | |
20-23 | PIC0.PNG的偏移量 | |
24-27 | PIC1.PNG的偏移量 | |
28-31 | SND0.AT3的偏移量 | |
32-35 | DATA.PSP的偏移量 | |
36-39 | DATA.PSAR的偏移量 |
如果PBP中若没有包含某文件的话,则该文件的偏移量与上一个文件的偏移量相同。比如:如果一个PBP中只有PARAM.SFO, ICON0.PNG 和 DATA.PSP,则偏移量应与下面的类似:
文件 | PARAM.SFO | ICON0.PNG | ICON1.PMF | PIC0.PNG | PIC1.PNG | SND0.AT3 | DATA.PSP | DATA.PSAR |
---|---|---|---|---|---|---|---|---|
偏移量 | 40 | 1772 | 1772 | 1772 | 1772 | 1772 | 20606 | 20606 |
2 SFO Files
SFO files are used by the Sony PSP to provide information about SaveGames and software such as firmware updates and UMD games. They are essentially a file of Key/Data pairs. It is important to know that SFO files have 4-byte data-alignment requirements. That is, the size of some parts must be divisible by 4. Where and how this is applicable will be explained. The 20-byte SFO header is as follows:-
Offset | Contents | Remarks |
---|---|---|
0-3 | File type/descriptor | Always a null byte followed by "PSF". |
4-7 | PSF Version (?) | Always 01 01 00 00. |
8-11 | Offset of Key Table | In bytes. Relative to start of file. 32-bit unsigned little endian. |
12-15 | Offset of Value Table | In bytes. Relative to start of file. 32-bit unsigned little endian. |
16-19 | Number of Data Items. 32-bit unsigned little endian. |
Next comes the Index table. Each entry in this 'table' describes a data item. Each item in the Index table contains the following data:-
Offset | Contents | Remarks |
---|---|---|
0-1 | Offset of Key Name in Key Table | Always a null byte followed by "PSF". |
2 | Data-alignment requirements (?) | Always 04. Single (1) byte. |
3 | Data type of value | Single (1) byte. See below for data-type information. |
4-7 | Size of Value data | In bytes. 32-bit unsigned little endian. |
8-11 | Size of Value data and Padding | 32-bit unsigned little endian. |
12-15 | Offset 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.