PSF (Portable Sound Format) [Portable Sound Format] Specification V1.5

xiaoxiao2021-03-06  42

-------------------------------------------------- --------------------------- PSF (Portable Sound Format) {Portable Sound Format} Specification V1.5by Neill Corlett ----- -------------------------------------------------- ----------------------

introduction------------

PSF is a functionality of "NSF", "SID", "SPC", and "GBS" to the second era home machine {next-generation consoles}. PSF uses the original music driver {device of each game?} Code Perfect and touched back music sequence, and the size is excellent {size-effect} {still too large}.

A general method is a PSF file containing a Zlib-compressed program that can be executed on real households, which can make simple playback of music.

If you want to know what changes, please visit the bottom of this article correct history.

-------------------------------------------------- ---------------------------

Basic file structure --------------------

Each FSF file has the same basic structure, which is described below.

Not only is it larger than one byte (byte) that is connected in the PSF file. Practice proper cautious. {Translated garbage, tx = xt}

- First 3 bytes: ASCII characters: "PSF" (case sensitive)

- Then 1 byte: Version byte version bytes are used to determine the type of PSF file. It does not affect the basic structure of the file. {! Will not affect!}

The currently recognized version byte is: 0x01: PlayStation (PSF1) {ps} 0x02: PlayStation 2 (PSF2) {PS2} 0x11: Saturn (SSF) [Test] {SS Saturn !!} 0x12: Dreamcast (DSF) [Test] {DC !!} 0x21: Nintendo 64 (USF) N64 [Reserved] 0x41: Capcom Qsound (QSF) {CPS1-QSound, CPS2-QSound, CP-Zn1-QSound, CP-Zn2-QSound, and ?

- Then 4 bytes: the size of the reserved space ®, little-endian unsigned long shape {little-endian: low byte low bytes, highlights (??). For example, the x86 series memory Data format. Compared to 68K is BIG-endian.

- Then 4 bytes: Compressed program length (N), Little-endian unsigned long shape This length is the length of the program {program data} compression {_after_}.

- Then 4-byte: CRC-32 value of compressed programs, Little-endian unsigned long shape {CRC-32 32-bit cycle redundant school check} {!! CRC-32 !! is it, tx = xt It is not to do it recently.} This is the CRC-32 value after the program {program data} compressed {_after_}. This value must be forced to fill, as a PSF file If this value does not match, it means damage.

- Then r byte: Reserved space If r is 0 byte, empty

- Then n-byte: Compressed program, is compressed by Zlib. {Compress () is a shrimp (), maybe it is a zlib function. Remember.} If n is 0 bytes, empty

Then data is optional, omitted:

- Then 5 bytes: ASCII Character: "[Tag]" (Sensitive Sensitive) If this 5-byte does not match, the remaining part is invalid, will be discarded.

- The remainder of the file: there is no compressed ASCII tag {tag}. If the remaining data exceeds 50,000 bytes, the label data can be cut, including excess data of the resection of the file itself. This is deliberate.

For future compatibility, the label editor and compressor may assume that any PSF file uses this basic structure. However, the reserved area must remain intact, and there is no assumption that the program and reserved part may be caused. There is no version byte that is first checked by the format or content. {Is over ~~ This time I have a big hair .tx = xi}

For information on Zlib, please go to http://www.gzip.org/zlib/. ------------------------------- ----------------------------------------------

Tag format {tag} ----------

The label consists of a series of single lines such as variable = values, like the following example:

Title = Earth Painting Artist = Yoko Shimomura Game = Legend of Mana Year = 1999 {This is the legend I don't know, I'm going to khahaha}

The label will be analyzed as follows:

- All 0x01-0x20 characters will be filtered to space {Whitespace} - must have no null (0x00) characters; this time it is released, the behavior of Null bytes is not defined - 0x0A is a new line of characters {0x0A: ASCII The newline break, in accordance with UNIX standards, WIN series Enter is 2 bytes, one is 0x0D, then 0x0a} - "Variable = Numerical" This additional line can be followed back to - the variable name is insensitive, Must be a legitimate C language identifier - spaces in one line of start / end, = preamline / after it will be ignored - the space line will be ignored - the multi-line variable must be a continuous row and have the same variable name. Example:

Comment = this is a comment = multiple-line comment = Comment.

- Label text uses system default coding tables to encode / decoding. {Wow aaaaaa --- !!! Why don't you use UTF-8 !!! Why !!!}

The variable name is more than once, and the multi-line variables are not defined in the case, these behaviors are not defined.

The following variable names have been predefined:

Title, Artist, Game, Year, Genre, Comment, Copyright (these are not needed.) {I am YY: title, artist, game, distribution year, genre, note, copyright}

These names are the person in charge of the creation of these files. {???} This person does not mean that this person wrote a sound driver code. {???} {why !!! Forget, Everyone will look at it. Even the garbage ~~}

Volume PSF relative to the volume as a simple scaling coefficient. 1.0 is the default. It can be any real number, including negative numbers

Length, the end of the end, the end of the fade, these can be one of the following three formats: second. Score: second. Minimum hours: minutes: second. The decimal part may be ignored. The comma can also be used as a decimal separator. {translated too Straight. Cold ~~}

The following variable names are reserved, not available:

- Any of these starts with underscore (_) is reserved to vital play information, such as the _lib tag in the minipsf file.

- FileDir, FileName, FileExt has special meaning in highly experimental {with high experimental?} {file directory, file name, file extension}, these variables may not be used, they will not be used in header format strings {Title format strings}.

-------------------------------------------------- ---------------------------

Relying on version byte, reserved position, program bit interpretation is difficult. Some tags are also difficult to explain. Refer to the section below. ----------------------- -------------------------------------------------- ----

Version bytes 0x01: PlayStation (psf1) --------------------------------

Program Bit: PS-X EXE Product Format {Consumer-Format} Executable File, with head {header}. Reserved bit: unused. Can be ignored, remove, etc. {Please, you are a custom-form man, you Come and decide, don't come to ETC, don't come to May, Must how good. Cold ~~ Forget it, you are useless.}

File extension: - PSF, PSF1 (independent program) - minipsf, minipsf1 (program back depending on additional library data) - PSFLIB, PSF1LIB (the library file required when playing when playback in the MINIPSF)

In PSF1, the program bit is an executable program of a primitive PlayStation household. It is responsible for initializing the SPU, loading samples, setting interrupts, etc. - Any program should do. It runs at the shell level, it is completely Use the kernel function.

There are 2 important PSF1 variables: MiniPSF and PSFLIB later described later.

The decompression of the executable must be less than 2,033,664 bytes.

The executable must be a standard "PS-X EXE product format", please refer to the description below.

First 0x800 bytes - {file} head {header} then n-byte - text area

Head format:

0x000 (8 bytes): ASCII "PS-X EXE" 0x010 (4 bytes): Initial PC, Little-Endian No symbol long shape 0x018 (4 bytes): text area start address, Little-endian unsigned long shape 0x01c (4 bytes): Text Region Size, Little-Endian No Symbol Long Join 0x030 (4 bytes): Initial SP ($ 29), Little-Endian No Symbol Long Join 0x04c: ASCII Tag: "Sony Computer Entertainment Inc. North America Area "(or similar to other regions) The remaining parts are 0.

The text area should be an integer multiple of 2048 bytes.

The area information of the ASCII tag of 0x4c will be used to determine the screen refresh rate and the VBLANK interrupt occurrence frequency (NTSC vs. PAL):

"North American" = 60Hz "japan" = 60Hz "Europe" = 50Hz (if you have any other area I should include, please let me know)

Similarly, if the "_Refresh" tag appears, it directly determines the HZ number of refresh rates. This tag overwrites the area information of the EXE header. The current only _Refresh = 50 and _Refresh = 60 are effective.

-------------------------------------------------- ---------------------------

PSF1: MiniPSF and PSFLIB ------------------------

The MiniPSF file is a regular PSF1 file that introduces data from one or more PSFLIB files in the same directory. (To share the drive code, sound library, etc.)

The PSFLIB file is also a regular PSF1 file. They can be recursively "reference data that" recursively "recursive" "? {Recursively" recursive "???}"

The appropriate label variable is called _LIB, _LIB2, _LIB3, etc.

The following is a method of properly loading miniPSF:

- Loading EXED data - this Becomes the Current EXE

- Check the existing "_lib" tag. If there is: - "Remature" loads EXE data from a given library file (determined "recursive" limit, avoid crash - I limit it 10) - use _lib EXE Specifies the current. - We will use _LIB EXE to initialize PC / SP. {PC / SP ???} - Add current EXE to the original PSF EXE, with its text start address and text size.

- Check the existing "_libn" tab, n = 2 to higher ("_lib% D") - "Regenerated" loads and adds all of these EXEs on the original EXE. But does not modify the current PC / SP. - Start from n = 2. Stop in the first label name that does not exist.

- (carry out)

Exe must always be adjacent. When another is added to an EXE, increase the start / end point of the target EXE is required, and the unused space is filled with 0.

The file name given in any _lib * tag is a relative path, relative to the directory in which the PSF file itself is located. "/" And "/" are considered to be a path separator. {Still straight -_- "} :

- If c: /something/demo.minipsF contains "_lib = hello / library.psflib" - then library will load from "c :/something/hellobrary/library.psflib"

The file name can contain spaces, but there is no space with the beginning and end.

When you are detected "a PSF1 file or a minipsf file" or when you need additional data, you should use the existing _lib * tag to determine, better than the file extension. If you include _lib or _lib2 tag, then it is A minipsf.

Regional information will be ignored throughout the _lib exe header; only the area information of the original EXE is used when determining the refresh rate. For example, a "Europe Area" minipsf, it introduces data from a "North America Area" PSFLIB It is considered to be 50 Hz.

No matter which _Refresh label encounters during the PSF load process, only the first tag functions, ignores all the labels, and ignores the EXE header area information. Example:

- minipsf has _refresh = 50, and psflib does not _refresh tag: 50Hz, ignore the exe header - minipsf has _refresh = 50, and psflib has _Refresh = 60: 50Hz, ignoring the exe header - minipsf No _Refresh label, and psflib There is _refresh = 60: 60Hz, ignoring the exe header - minipsf and psflib do not _Refresh Tags: minipsf EXE header is used to determine refresh rate

-------------------------------------------------- ---------------------------

PSF1 simulation {simulation emulation} Remarks --------------------

Although it is independent of specific format, the following information is still useful. It is only available for PSF1.

The following is a useful psxcore0008: - R3000 CPU-Interrupt and system call - 2MB RAM (image penetration first 8MB) {???} - 1kb intermediate result Speaker {ScratchPad} - SPU-DMA Channel 4 (SPU) - Root Counters 0, 1, 2, VBLANK IRQS {???} - all kernel functions

The following is useless: - overflow error - breakpoint - GTE instruction - GPU, CDROM, SIO, et al. - Unrelated to the sound - Other DMA channels

The following R3000 code sequence is detected as IDLE {downtime}, in the host {finger PSF running environment} This can not be used to save the CPU clock: [jump or branch to the current line] {Jump or branch to Current line} NOP

-------------------------------------------------- ---------------------------

Version byte 0x02: PlayStation 2 (PSF2) ----------------------------------

Program Bit: Not used. You can be ignored, removed, etc. Reserved: virtual file system.

File extension: - PSF2 (self-included file system) - minipsf2 (file system depends on one or more PSF2LIB file systems) - PSF2LIB (file system provides additional data for miniPSF2 file system)

A PSF2 file consists of a virtual file system positioning point in the reserved bit. The program bit is not used. The file system may be composed of _lib, _lib2, ... tags, exhausted with MiniPSF and PSFLIB format.

Playing a PSF2 file first loads "PSF2.irx" IOP module from the virtual file system. Loading and executing this module should complete all the necessary hardware settings and play music.

PSF2 files are limited playback sequence music, using IOP and hardware synthesis (SPU2). Software synthesis, usually completed by EE, is not considered. {EE "emotion engine" PS2 main CPU}

_Refresh label can be used to specify the number of refresh rate hz (50 or 60), which is the same as PSF1.

-------------------------------------------------- ---------------------------

PSF2: Runtime Environment -------------------------

The IOP module can connect the following libraries in a PSF2. The version byte is not later than the version.

Name Ver. Name Ver. -------------- ------------------------- - dmacman 102 sifman 101 thmsgbx 101 excepman 101 ssbusc 101 thrdman 102 heaplib 101 stdio 103 thsemap 101 intrman 102 sysclib 103 thvpool 101 ioman 104 sysmem 101 timrman 103 loadcore 103 thbase 102 vblank 101 modload 106 thevent 101 sifcmd 101 thfpool 101

The IOP module should use the following method to access the file in the PSF2 virtual file system:

1. Get Argv [0], cut off directly after the separator at the right side. The separator is defined as front slash {division}, rear slash {backlash}, or colon (/ / :). This character The string becomes "device prefix". 2. Add the name of the expected file to the device prefix.3. Use the result string in the standard call, like Open or LoadModule.

For example, highly experimental may call PSF2.irx with argv [0] like "hefile: /psf2.irx". This situation, device prefix is ​​"hefile: /". You should open the following call "Test.File " document:

FD = Open ("Hefile: /Test.File", o_rdonly); Different player {Player} or environments are prefixed with different devices, so they don't always use "Hefile: /".

IOP module, usually, do not try to contact any hardware that is not related to music playback. They include, but not restricted: SIF, CD / DVD, USB, ILINK, ATA, handle, memory card, and network hardware. These hardware is analog Minimize, but not, you can work.

The IOP module should use the minimum amount of memory. Successful use of virtual file systems maintain a lot of data, better in an IRX data bit to include all data.

-------------------------------------------------- ---------------------------

PSF2: Virtual File System Format -------------------------------

The PSF2 virtual file system is a file name with up to 36 characters with a directory level. The file name is not sensitive to case, must be a sequence consisting of unique set of ASCII 32-126 characters, with before Character of the slash {Semonary}, rear slash {backlash}, or colon (/ / :). The total length of the path is not longer than 255 bytes.

All quantities are stored as a Little-Endian unsigned format. All offsets start relative to the reserved bit.

Starting the offset 0 is the root directory. The directory has the following format:

- Start 4 bytes: Number of catalog items (n) {Directory Entry directory item / directory registration word meaning} - then 48 * n bytes: n directory item

N can be zero, indicating that this directory is empty.

The format of the directory item is as follows:

- Start 36 bytes: file name. Must be non-zero length, you must add NULL (0x00) characters. If it is a strict 36 characters, there is no null-terminated. - then 4 bytes: file data or directory offset Quantity (O) - 4 bytes: decompression size (U) - then 4 bytes: block size (b)

If u, b, o is zero, then the entrance is described as zero length file. If u, b is zero, o is non-zero, then the entrance is described as subdirectory.

Otherwise, the file data is stored as a continuous ZLIB compression ()-format block sequence.

- Start 4 * x byte: Table size. Each entry contains the size of the compressed block. X = (u b - 1) / b; - the remainder of the file: the decompression size of the compressed block must be equal to B. Last The decompression size of the data block can be less than B.

All files and subdirectories must be greater than the offset of its entry directory. {Undes ???} This is for simple consistency checks.

-------------------------------------------------- ---------------------------

PSF2: MiniPSF2 and PSF2LIB ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

The MiniPSF2 file is a regular PSF2 file that references data from one or more PSF2 files in the same directory (for sharing drive code, sound library, etc.)

The PSF2LIB file is also a regular PSF2 file. They can be "recursted" "recursive" reference data by other PSF2lib files.

The appropriate label variable is called _LIB, _LIB2, _LIB3, etc.

The following is a method that correctly loads minipsf2:

1. Recursively loads a virtual file system from the name of each PSF2 file library tag. The initial label is "_lib". The label is "_libn", n> = 2 (using "_lib% d"). Stop in the first A non-existing label name. 2. Load the virtual file system from the current PSF2 file.

When a new file system is loaded, a directory entry with a collision {should refer to the same name} file name will be overwritten (of course the actual PSF2 file itself will not be overwritten.)

The file name given in any _lib * tag is a relative path, which is a directory in which the PSF2 file itself is located. "/" And "/" are considered to be the splitter of the path. {Still straight -_- "} : - If c: /something/demo.minipsf2 contains "_lib = hello / library.psf2lib" - then library will load from "c :/something/hellobrary/library.psf2lib"

The file name can contain spaces, but there is no space with the beginning and end.

When you are detected, "a PSF2 file or a minipsf2 file" or when you need additional data, you should use the existing _lib * tag to determine, better with the file extension. If you include _lib or _lib2 tag, then it is A minipsf2.

In MiniPSF2 and PSF2LIB, the _Refresh tag behavior is the same as MiniPSF and PSFLIB behavior.

-------------------------------------------------- ---------------------------

Version byte 0x11: Saturn (SSF) [Test] ----------------------------------------------------------------------------------------------------------------------------------------------

Program Bit: RAW 68000 Sound Program Mirror. {RAW generally refers to data format without head} Reserved bit: Not used. Can be ignored, remove, and so on.

File extension: - SSF (independent program) - minissf (Program Back Dependent Library Data) - SSFLIB (I need a library file required to play when playing in the MINISSF)

A SSF program bit is loaded by 4-byte LSB-First loading address FOLLOWED BY RAW 68000 program data. It is a specific address. After all programs are loaded, the 68000 processor restarts, and then starts from the restart vector {reset vector}.

The 68000 program is responsible for initializing and using SCSP. It must not be attempted to touch any other SATURN processor {SH2, VDP1, VDP2, SCU, SMPC}.

"Minissf and SSFLIB" are the same as "MiniPSF and PSFLIB" loading methods.

After the program bit is decompressed, it must be less than 524,292 bytes. {Lsb-first should refer to Big-endless, because the 68K system is BIG-endless, or may be small-endless, please check the information, I don't blame me. } {SCSP does not check the relevant information, it should refer to the DSP responsible for sound or means that YAMAHA FH1 sound processor} {SS sound processor is 68EC000 is not standard 68000, which should refer to the type of controller} {SS Document information is really scarce, nothing to find out> _ <} -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------

Version bytes 0x12: Dreamcast (DSF) [Test] -----------------------------

Program Bit: RAW ARM7 Sound Program Mirror. Reserved Bits: Unused. Can be ignored, removed, and so on.

File extension: - DSF (independent program) - minidsf (Program Back Dependent Library Data) - DSFLIB (the library file required when playing when playback of the MINIDSF)

The program bit of a DSF file is loaded by the 4-byte LSB-First load address FOLLOWED BY RAW ARM7 program data. It is a specific address. After the program is loaded, the ARM7 processor restarts and then executes from address 0.

The ARM7 program is responsible for initializing and using AICA. It must not be tried to touch the SH4 master CPU.

"MiniDSF and DSFLIB" are the same as "Minissf and SSFLIB".

After the program bit is decompressed, the size must be less than 2,097,156 bytes. {AICA ???} -------------------------------------------------------------------------------------------------------------- ------------------------------------------- Version bytes 0x21: Nintendo 64 (USF) [Reserved] -------------------------------

This version byte is reserved when "ADAM Gashlin's USF Format" is complete.

-------------------------------------------------- ---------------------------

Version byte 0x41: CAPCOM QSound (QSF) ---------------------------------

Program Bit: The following mirror contains Z80 program / sample ROM decryption key reserved: unused. It can be ignored, remove, and so on.

File extension: - QSF (independent image) - miniQSF (additional library data when mirror playback) - QSFLIB (I need to file when playing with MINIQSF)

The program bit of the QSF file, once the decompresses contain a series of data blocks, see below:

3 bytes - ASCII Name Tag 4 byte - Start Offset (LSB-First) 4 bytes - Length (N) (LSB-First) N bytes - Data

Then the data is loaded to a given start offset described by the ASCII tab.

The following part defines this:

"Key" - kabuki decryption key. This part should be 11 bytes, the content is as follows: 4 bytes - swap_key1 (msb is a shrimp ???} 4 bytes - swap_key2 (msb-first) 2 words Day - AddR_key (MSB-First) 1 byte - xor_key "z80" - z80 program ROM. "SMP" - QSound sample ROM.

The key bit is not or two swap_keys is zero, it is assumed that it is not encrypted.

The Z80 program ROM must play the desired track and do not accept any commands via shared memory. (Usually need to make some secondary interrupt modifications).

"MiniQSF and QSFLIB" are the same as "MiniPSF and PSFLIB" loading methods.

There is no limit to Z80 or SMP, but the Key bit cannot exceed 11 bytes.

-------------------------------------------------- ---------------------------

Correct history ----------------

V1.5 (2004-05-15) - Rename "Portable Sound Format" {Portable Sound Format} - Add to QSF Information - Keep USF version bytes

V1.4 (2004-01-23) - Add to SSF and DSF Information [Experiment] - Add NTSC and PAL information and add "_refresh" tag {refresh to PSF1 and PSF2 {refresh?}

V1.3 (2003-05-31) - PSF2 format change and finalization - Fixed PSF1 Simulation Note In order to reflect the change in the latest simulation code {9 vegetarian simulation}

V1.2 (2003-04-17) - Factory Formation of Variable Byte Action - Details How to operate a PSF variable in the future - all heads (_) tags are retained - Various Other Clarifications - Details PSF2 information, still Is [experimental]

V1.1 (2003-03-11) - Suggestions for some PSF2

Correct (2003-01-24) - Add information to minipsf and psflib

Original copy (?)

-------------------------------------------------- --------------------------- How to find Neill Corlett ------------------- -------- Email: neill@neillcorlett.com website: http://www.neillcorlett.com/

-------------------------------------------------- --------------------------- ======================== ===========================

转载请注明原文地址:https://www.9cbs.com/read-58939.html

New Post(0)