psx.wiki

CD-ROM Disc Format

Sector modes, subchannel Q, addressing and the ISO 9660 file system of PlayStation discs.

Overview

Digital data is recorded on a CD-ROM in a spiral, the same as on a CD audio disc, and is divided into units called sectors. One second of data is 75 sectors, and a sector is an audio sector, an ADPCM sector or a data sector according to its use.1 An audio sector holds 44.1 kHz digital stereo audio and can only be played. A data sector normally holds 2048 bytes of user data in the mode 1 layout. An ADPCM sector is a real-time mode 2 form 2 sector that holds compressed audio.1

PlayStation discs follow the CD-ROM XA specification. The data tracks must come before any CD-DA tracks. A disc with data in track 1, audio in tracks 2 and 3 and data again in track 4 is therefore incorrect, and the two data tracks must be joined as track 1.2 psx-spx summarizes the format as an ISO 9660 file system on CD-XA mode 2 sectors.3

Addressing

For compatibility with CD audio, CD-ROM addressing uses track number, index number, minute, second and sector. There are 75 sectors in one second and 60 seconds in one minute, and the first sector of the data begins at 00 minutes 02 seconds 00 sector.4 A position can therefore be read as a track and index, as seen by an audio player, or as a time from the start of the disc.4

A track signal is recorded at the start of each track, and a table of the track positions is recorded at the start of the disc as the TOC (Table of Contents).4 For data sectors libcd also counts an absolute sector number from 00:02:00, and CdIntToPos() and CdPosToInt() convert between the two forms.4 The minute, second and sector are given in BCD, so decimal 60 is written 0x60.5

The disc rotates at normal speed or double speed. Normal speed is the speed of an ordinary CD player and transfers 150KB/sec, which is 75 sectors per second. Double speed transfers 300KB/sec, or 150 sectors per second.4

Table 1: Disc limits
Unit Count
Tracks per disc 99 (01h to 99h)
Indices per track 99 (01h to 99h)
Minutes per disc 74 (00h to 73h), or more with restrictions
Seconds per minute 60 (00h to 59h)
Sectors per second 75 (00h to 74h)
Frames per sector 98
Bytes per frame 33: 24 data, 1 subchannel, 8 error correction

The numbers are from psx-spx.6 The 98 frames of 24 data bytes give the 2352 (930h) bytes of a sector. The subchannel and the frame error correction lie outside the sector. Most drive controllers give access only to the 930h bytes and to subchannel Q.67

Sector Layout

ECMA-130 defines a sector as 2352 bytes. It begins with a 12-byte sync field (00h, ten FFh, 00h) and a 4-byte header of minute, second, sector and the sector mode byte.8 Mode 0 sets bytes 16 to 2351 to zero. Mode 1 holds 2048 bytes of user data, protected by a 4-byte EDC, 8 zero bytes and 276 bytes of P and Q parity. Mode 2 makes all 2336 bytes after the header user data, and only the CIRC of the frames protects them.8

CD-ROM XA divides mode 2 into two forms, and the PlayStation stores its data in them.9 The layouts, with offsets in hexadecimal, are as follows:9

Table 2: Sector layouts
Offset Audio Mode 1 Mode 2 form 1 Mode 2 form 2
000h Audio data, 930h bytes Sync, 0Ch bytes Sync, 0Ch bytes Sync, 0Ch bytes
00Ch Header (minute, second, sector, 01h) Header (minute, second, sector, 02h) Header (minute, second, sector, 02h)
010h Data, 800h bytes Subheader, 4 bytes Subheader, 4 bytes
014h Copy of subheader Copy of subheader
018h Data, 800h bytes Data, 914h bytes
810h EDC over 000h to 80Fh
814h 8 zero bytes
818h EDC over 010h to 817h
81Ch ECC, 114h bytes ECC, 114h bytes
92Ch EDC over 010h to 92Bh, or 0

Audio data is stored as left low byte, left high byte, right low byte and right high byte.9 Form 1 therefore keeps the error correction of mode 1 for 2048 bytes of data, while form 2 gives 2324 (914h) bytes of data with error detection only.9 A mode 0 sector has the sync and header and 920h zero bytes.9

Subheader

The 4-byte subheader of a mode 2 sector holds the file number, channel number, submode and coding information. A normal data sector has the subheader 00h 00h 08h 00h.10

Table 3: Subheader bytes
Byte Name Contents
0 File number (FN) 00h to FFh, for interleave
1 Channel number (CN) 00h to 1Fh in bits 0 to 4, for interleave
2 Submode (SM) Sector type and flags, below
3 Coding information (CI) 00h for data, the audio format for XA-ADPCM
Table 4: Submode bits
Bit Name Contents
7 EOF End of file, directory, path table or volume terminator
6 RT Real time
5 Form 2 0 = form 1 (800h bytes), 1 = form 2 (914h bytes)
4 Trigger For application use
3 Data Data sector
2 Audio Audio sector
1 Video Video sector
0 EOR End of record

Normally one of the Video, Audio and Data bits is set. PlayStation STR movie files are marked as data sectors.10 Every volume descriptor sector has EOR set, and the last one also EOF. EOR and EOF are both set in the last sector of each path table and directory and of each file.10

Table 5: Coding information for XA-ADPCM
Bits Contents
0 to 1 0 = mono, 1 = stereo
2 to 3 Sample rate. 0 = 37800 Hz, 1 = 18900 Hz.
4 to 5 Bits per sample. 0 = 4 bits, 1 = 8 bits.
6 Emphasis
7 Reserved

The audio sectors are described in XA Audio. With real-time sectors the drive may skip a read error in place of a retry, since a delay would be more disturbing to a stream than bad data.11

Subchannel Q

Each frame carries 8 subchannel bits, named P to W. A sector of 98 frames therefore holds 98 bits of each subchannel.12 Subchannel P marks pauses between audio tracks and has no checksum.13 Subchannel Q carries the position of the sector, the TOC in the lead-in and other information, as follows:14

Table 6: Subchannel Q
Bits Contents
2 Sync
8 ADR and control
72 Data, depending on ADR
16 CRC-16-CCITT, high byte first
Table 7: ADR and control byte
Bits Contents
0 to 3 ADR. 0 = no data, 1 to 3 = mode, 4 to 0Fh = reserved.
4 Audio preemphasis. Must be 0 for data.
5 Digital copy allowed
6 Data (0 = audio, 1 = data)
7 Four-channel audio. Must be 0 for data.

In the data area ADR 1 gives the track number, the index number (00h for the pause), the time within the track and the absolute time. All of them are in BCD. ADR 1 appears in at least 9 of every 10 sectors.1516 In the lead-out the track number is AAh. In the lead-in the track number is 00h, and the point field names a track (01h to 99h) or one of three entries: A0h for the first track number and disc type, A1h for the last track number and A2h for the start of the lead-out.15 The disc type byte is 00h for CD-DA or CD-ROM; it is 10h for CD-I and 20h for CD-ROM XA.15

ADR 2 carries the catalogue number of the disc and ADR 3 the ISRC of a track. ADR 5 carries the multisession information in the lead-in and lead-out.17 The PlayStation reads subchannel Q with CdlGetlocP during play. GetlocP also reads the LibCrypt protection data of some discs.1819

Track Gaps and the Outer Edge

The drive finds the start of an audio track from the TOC and the track signals.4 When CD-DA is played continuously, the access goes to the point where the index is 1, so the gap is not played. The audio may therefore differ slightly from an access by absolute time from the TOC, because the TOC may lag the real position.2

A track jump within three minutes of the outer edge of the disc can make the head fly off the disc. The outer three minutes should therefore not be accessed, and they are normally recorded with null data.2 Sony allows the area to be used for a long file that is always read from its start, such as an ending movie, or for a last CD-DA track of three minutes or more.20

File System

The file system of the PlayStation is based on ISO 9660 level 1, and it assumes that the files are on CD-ROM.21 A CD-ROM is read-only, so each file occupies one continuous run of sectors. A file is read from its start position alone, and nothing like a FAT is needed. libcd provides CdSearchFile() to find the start of a file by name.4

File names take the MS-DOS form of an 8-character base name and a 3-character extension with a period between them. The characters are 1-byte alphanumerics, and 1-byte katakana and kanji cannot be used.21 On the disc a name carries the version suffix ";1".22

The Operating System manual states that subdirectories cannot be created and that all files are in the root directory. It sets no limit on the number of files.21 However, the CD conference FAQ treats a subdirectory as a file in its parent directory.23 psx-spx also allows 8-character directory names and gives the kernel limit as one sector (800h bytes) per directory.2224

Disc Layout

The first 16 sectors of the first track form the disc's system area. psx-spx gives the contents of a PlayStation disc as follows:25

Table 8: System area
Sector Contents
0 to 3 Zero (mode 2 form 1)
4 License string
5 to 11 PlayStation logo, 3278h bytes, rest filled with FFh
12 to 15 Zero (mode 2 form 2)
16 Primary Volume Descriptor
17 Volume Descriptor Set Terminator

The license string in sector 4 begins with "Licensed by" and the name of the Sony company of the region. Japan has "Sony Computer Entertainment Inc."; America has "Sony Computer Entertainment Amer ica"; Europe has "Sony Computer Entertainment Euro pe".25 The logo sectors hold a TMD model of the PS logo shown at boot. The Japanese BIOS refuses a changed logo, the European BIOS from version 4.0E refuses it, and the American BIOS accepts it.25

The Primary Volume Descriptor carries "PLAYSTATION" in both its system identifier and its application identifier. Its logical block size is 800h bytes, and "CD-XA001" is stored at offset 400h.26 The path tables usually follow in sectors 18 to 21 and the root directory in sector 22.2724

Directory Records

A directory record holds the start sector and size of a file, both in both byte orders, a recording time, flags and the name.24 On a CD-XA disc each record ends with 14 bytes of system use data:24

Table 9: CD-XA system use field
Offset Size Contents
00h 2 Owner group ID, usually 0
02h 2 Owner user ID, usually 0
04h 2 Attributes, big endian
06h 2 Signature "XA"
08h 1 File number, which must match the subheader
09h 5 Reserved
Table 10: XA attribute bits
Bit Contents
15 Directory
14 CD-DA track
13 Interleaved
12 Mode 2 form 2
11 Mode 2
0 to 10 Owner, group and world read and execute permissions

The common values are 0D55h for a normal file in 800h-byte sectors, 3D55h for a streaming file of ADPCM or MDEC data, 4555h for a CD-DA track and 8D55h for a directory.24 Directory entries do not cross a sector boundary, and the names are sorted alphabetically whether they are files or directories. The first two entries, with the names 00h and 01h, are the current and parent directory.24

Copy Protection

Each licensed disc has a four-letter "SCEx" string in the wobble of its groove in the first seconds of the disc, which a normal CD writer cannot reproduce. The last letter gives the region (I for Japan; A for America; E for Europe).28 The firmware of the CD-ROM controller checks the string, not the BIOS, so a patched BIOS cannot bypass it. A disc with a missing or wrong-region string does not boot.28 The license string, the logo and the region strings in the executable headers can be copied by a CD writer, but their distribution on unlicensed discs may be illegal.29 The GetID command in CD-ROM Commands reports the result of the check.

References


  1. ^ a b Sony Computer Entertainment Inc. Run-Time Library Overview. January 1999. Page 11-3, Table 11-1.

  2. ^ a b c Sony Computer Entertainment Inc. Run-Time Library Overview. January 1999. Page 11-19.

  3. ^ psx-spx. CDROM Format, CDROM Disk Format, Overview. https://psx-spx.consoledev.net/cdromformat/

  4. ^ a b c d e f g Sony Computer Entertainment Inc. Run-Time Library Overview. January 1999. Page 11-4.

  5. ^ Sony Computer Entertainment Inc. Run-Time Library Overview. January 1999. Page 11-7.

  6. ^ a b psx-spx. CDROM Format, CDROM Disk Format, Stuff. https://psx-spx.consoledev.net/cdromformat/

  7. ^ psx-spx. CDROM Format, CDROM Disk Format, 930h-Byte Sectors. https://psx-spx.consoledev.net/cdromformat/

  8. ^ a b Ecma International. ECMA-130, Data interchange on read-only 120 mm optical data disks (CD-ROM). 2nd edition. June 1996. Clause 14, pages 15 and 16.

  9. ^ a b c d e psx-spx. CDROM Format, CDROM Sector Encoding. https://psx-spx.consoledev.net/cdromformat/

  10. ^ a b c psx-spx. CDROM Format, CDROM XA Subheader, File, Channel, Interleave. https://psx-spx.consoledev.net/cdromformat/

  11. ^ psx-spx. CDROM Format, CDROM XA Subheader, File, Channel, Interleave, Real Time Streaming. https://psx-spx.consoledev.net/cdromformat/

  12. ^ psx-spx. CDROM Format, CDROM Disk Format, Subchannels. https://psx-spx.consoledev.net/cdromformat/

  13. ^ psx-spx. CDROM Format, CDROM Subchannels, Subchannel P. https://psx-spx.consoledev.net/cdromformat/

  14. ^ psx-spx. CDROM Format, CDROM Subchannels, Subchannel Q. https://psx-spx.consoledev.net/cdromformat/

  15. ^ a b c psx-spx. CDROM Format, CDROM Subchannels, Subchannel Q with ADR=1. https://psx-spx.consoledev.net/cdromformat/

  16. ^ Ecma International. ECMA-130, Data interchange on read-only 120 mm optical data disks (CD-ROM). 2nd edition. June 1996. Clause 22.3.

  17. ^ psx-spx. CDROM Format, CDROM Subchannels, Subchannel Q with ADR=2, ADR=3 and ADR=5. https://psx-spx.consoledev.net/cdromformat/

  18. ^ Sony Computer Entertainment Inc. Run-Time Library Overview. January 1999. Page 11-11.

  19. ^ psx-spx. CDROM Drive, CDROM - Status Commands, GetlocP. https://psx-spx.consoledev.net/cdromdrive/

  20. ^ Sony Computer Entertainment Inc. Run-Time Library Overview. January 1999. Page 11-21.

  21. ^ a b c Sony Computer Entertainment Inc. PlayStation Operating System. August 1998. Page 2-4.

  22. ^ a b psx-spx. CDROM Format, CDROM Disk Format, CDROM Filesystem (ISO 9660 aka ECMA-119). https://psx-spx.consoledev.net/cdromformat/

  23. ^ Sony Computer Entertainment. The Un-Official PlayStation Development FAQ, CD Conference. Release v1.3. February 29, 1996. Question 1.6.5.

  24. ^ a b c d e f psx-spx. CDROM Format, CDROM ISO File and Directory Descriptors, Format of a Directory Record. https://psx-spx.consoledev.net/cdromformat/

  25. ^ a b c psx-spx. CDROM Format, CDROM ISO Volume Descriptors, System Area. https://psx-spx.consoledev.net/cdromformat/

  26. ^ psx-spx. CDROM Format, CDROM ISO Volume Descriptors, Primary Volume Descriptor. https://psx-spx.consoledev.net/cdromformat/

  27. ^ psx-spx. CDROM Format, CDROM ISO File and Directory Descriptors, Path Tables. https://psx-spx.consoledev.net/cdromformat/

  28. ^ a b psx-spx. CDROM Format, CDROM Protection - SCEx Strings, SCEx String. https://psx-spx.consoledev.net/cdromformat/

  29. ^ psx-spx. CDROM Format, CDROM Protection - SCEx Strings, Other Protections. https://psx-spx.consoledev.net/cdromformat/

Categories: Hardware · File formats