Difference between revisions of "CDCommands"

From Yabause
Jump to: navigation, search
m (Put Sector Data(0x64))
(Open Tray(0x05))
Line 183: Line 183:
 
|}
 
|}
  
Notes: Disc stops spining and Drive status goes to Busy until a new disc is inserted or until Initialize CD System command is called.
+
Notes: Disc stops spining and Drive status goes to Busy until a new disc is inserted or until Initialize CD System command is called. Disc authentication status is also reset at this point.
  
 
==End Data Transfer(0x06)==
 
==End Data Transfer(0x06)==

Revision as of 19:45, 24 May 2016

Get CD Status(0x00)

Format:

CR1 0x0000
CR2 0x0000
CR3 0x0000
CR4 0x0000

Returns: CD status data

HIRQ N/A

Get Hardware Info(0x01)

Format:

CR1 0x0100
CR2 0x0000
CR3 0x0000
CR4 0x0000

Returns:

CR1 CD Status(high byte)
CR2 Hardware flag(high byte), hardware version(low byte)
CR3 MPEG version(low byte)
CR4 Drive version(high byte), Drive revision(low byte)
HIRQ N/A

Notes: Even if MPEG card is present, the hardware version will be set to 0 if it hasn't been authenticated.

Get TOC(0x02)

Format:

CR1 0x0200
CR2 0x0000
CR3 0x0000
CR4 0x0000

Returns:

CR1 CD Status(high byte)
CR2 TOC size in words(word)
CR3 0x0000
CR4 0x0000
HIRQ DRDY(when TOC data is ready)

Get Session Info(0x03)

Format:

CR1 0x0300, Session data type(low byte) - 0x00 = All sessions, otherwise the session number
CR2 0x0000
CR3 0x0000
CR4 0x0000

Returns:

CR1 CD Status(high byte)
CR2 0x0000
CR3 Session number/number of sessions(high byte), upper byte of session lba(low byte)
CR4 Lower word of session LBA(word)
HIRQ N/A

Initialize CD System(0x04)

Format:

CR1 0x04(high byte), Initialization flags(low byte)
CR2 Standby Time
CR3 0x0000
CR4 ECC(high byte), Retry Count(low byte)

Returns: CD status data

HIRQ ESEL, EHST, ECPY, EFLS, SCDQ(?), MPED(see notes)

Notes: Drive Status is briefly changed to BUSY status after command issuing. Hirq flags are only set if CD Block Software Reset bit of Initialization flags was originally set.

Open Tray(0x05)

Format:

CR1 0x0500
CR2 0x0000
CR3 0x0000
CR4 0x0000

Returns: CD status data

HIRQ EFLS, DCHG

Notes: Disc stops spining and Drive status goes to Busy until a new disc is inserted or until Initialize CD System command is called. Disc authentication status is also reset at this point.

End Data Transfer(0x06)

Format:

CR1 0x0600
CR2 0x0000
CR3 0x0000
CR4 0x0000

Returns:

CR1 CD Status(high byte), Upper byte of transfer word number(low byte)
CR2 Lower word of transfer word number(word)
CR3 0x0000
CR4 0x0000
HIRQ EHST(only for Get Sector, Get then Delete Sector, and Put Sector transfers)

Notes: transfer word number is set to 0xFFFFFF if there was no transfer currently going.

Play Disc(0x10)

Format:

CR1 0x1000, Upper byte of start play position(low byte)
CR2 Lower word of start play position
CR3 play mode(high byte), Upper byte of end play position(low byte)
CR4 Lower word of end play position

Returns: CD status data

HIRQ N/A

Notes: If start/end play position has highest bit set, the value is treated as a FAD position. Otherwise, the value is a track number.

After command is issued, CD Status is changed to Seek(if the read head isn't over the start sector already) and then changes to Play. When a sector is read in, CSCT hirq flag is set. If buffer fills completely, BFUL hirq flag is set and CD Status is set to Paused. Once there is free space again, CD Status is changed back to Play and reading resumes.

Seek Disc(0x11)

Format:

CR1 0x1000, Upper byte of start play position(low byte)
CR2 Lower word of start play position
CR3 0x0000
CR4 0x0000

Returns: CD status data

HIRQ N/A

Notes: If seek position has highest bit set, the value is treated as a FAD position. Otherwise, the value is a track number. Any previous playing is stopped and after seeking to the specified position the CD status is changed to paused. Specifying an invalid track causes the cd status to immediately change to standby. Specifying a FAD position of 0xFFFFFF stops any previous playing and sets the cd status to paused.

Scan Disc(0x12)

Format:

CR1 0x12(high byte), Scan Direction(low byte)
CR2 0x0000
CR3 0x0000
CR4 0x0000

Returns:

CR1 CD Status(high byte)
CR2 0x0000
CR3 0x0000
CR4 0x0000
HIRQ ????

Get Subcode Q/RW(0x20)

Format:

CR1 0x20(high byte), Type(low byte)
CR2 0x0000
CR3 0x0000
CR4 0x0000

Notes: Type is set to 0 for subcode Q. 1 for subcodes R-W.

If valid R-W subcodes available, returns:

CR1 CD Status(high byte)
CR2 Q/RW size in words(word)
CR3 0x0000
CR4 Subcode flags

Otherwise returns:

CR1 0x80(high byte)
CR2 0x0000
CR3 0x0000
CR4 0x0000
HIRQ DRDY(when data is ready)

Notes: CR2 should return 5 words when reading subcode q and 12 words for subcodes R-W

Set CD Device Connection(0x30)

Format:

CR1 0x3000
CR2 0x0000
CR3 Filter Number(high byte)
CR4 0x0000

Returns: CD status data

HIRQ ESEL

Notes: This connects the CD device's output to the specified filter. This needs to be done before any data can be received.

Get CD Device Connection(0x31)

Format:

CR1 0x3100
CR2 0x0000
CR3 0x0000
CR4 0x0000

Returns:

CR1 CD Status(high byte)
CR2 0x0000
CR3 Filter Number(high byte)
CR4 0x0000
HIRQ N/A

Notes: When CD Block Software Reset is done, the connection is reset to 0xFF.

Get Last Buffer Destination(0x32)

Format:

CR1 0x3200
CR2 0x0000
CR3 0x0000
CR4 0x0000

Returns:

CR1 CD Status(high byte)
CR2 0x0000
CR3 Buffer Number(high byte)
CR4 0x0000
HIRQ N/A

Set Filter Range(0x40)

Format:

CR1 0x40(high byte), Upper FAD byte(low byte)
CR2 Lower FAD word
CR3 Filter Number(high byte), Upper Range byte(low byte)
CR4 Lower Range word

Returns: CD status data

HIRQ ESEL

Notes: This command sets up the FAD range for the specified filter. If a read sector is within range it passes it to the true connection. Otherwise it passes it to the false connection.

Get Filter Range(0x41)

Set Filter Subheader Conditions(0x42)

Format:

CR1 0x42(high byte), Channel(low byte)
CR2 Sub Mode Mask(high byte), Coding Information Mask(low byte)
CR3 Filter Number(high byte), File ID(low byte)
CR4 Sub Mode Value(high byte), Coding Information Value(low byte)

Returns: CD status data

HIRQ ESEL

Get Filter Subheader Conditions(0x43)

Format:

CR1 0x4300
CR2 0x0000
CR3 Filter Number(high byte)
CR4 0x0000

Returns:

CR1 CD Status(high byte), Channel(low byte)
CR2 Sub Mode Mask(high byte), Coding Information Mask(low byte)
CR3 File ID(low byte)
CR4 Sub Mode Value(high byte), Coding Information Value(low byte)
HIRQ ESEL

Notes: This is only used for Mode 2 data sectors

Set Filter Mode(0x44)

Format:

CR1 0x44(high byte), Mode(low byte)
CR2 0x0000
CR3 Filter Number(high byte)
CR4 0x0000

Returns: CD status data

HIRQ ESEL

Get Filter Mode(0x45)

Format:

CR1 0x4500
CR2 0x0000
CR3 Filter Number(high byte)
CR4 0x0000

Returns:

CR1 CD Status(high byte), Mode(low byte)
CR2 0x0000
CR3 0x0000
CR4 0x0000
HIRQ ESEL

Set Filter Connection(0x46)

Format:

CR1 0x46(high byte), Which connection to set(low byte)
CR2 Connection for true condition(high byte), Connection for false condition(low byte)
CR3 Filter Number(high byte)
CR4 0x0000

Returns: CD status data

HIRQ ESEL

Get Filter Connection(0x47)

Format:

CR1 0x4700
CR2 0x0000
CR3 Filter Number(high byte)
CR4 0x0000

Returns:

CR1 CD Status(high byte)
CR2 Connection for true condition(high byte), Connection for false condition(low byte)
CR3 0x0000
CR4 0x0000
HIRQ ESEL

Reset Selector(0x48)

Format:

CR1 0x48(high byte), Reset Flags(low byte)
CR2 0x0000
CR3 Buffer Number(high byte)
CR4 0x0000

Returns: CD status data

HIRQ ESEL

Notes: Buffer Number is only used when Reset Flags is 0

Get Buffer Size(0x50)

Format:

CR1 0x5000
CR2 0x0000
CR3 0x0000
CR4 0x0000

Returns:

CR1 CD Status(high byte)
CR2 Block Free Space
CR3 Maximum Selectors(high byte)
CR4 Maximum Blocks
HIRQ N/A

Get Sector Number(0x51)

Format:

CR1 0x5100
CR2 0x0000
CR3 Buffer Number(high byte)
CR4 0x0000

Returns:

CR1 CD Status(high byte)
CR2 0x0000
CR3 0x0000
CR4 Number of Blocks
HIRQ DRDY

Calculate Actual Size(0x52)

Format:

CR1 0x5200
CR2 Sector Offset
CR3 Buffer Number(high byte)
CR4 Sector Number

Returns: CD status data

HIRQ ESEL

Get Actual Size(0x53)

Format:

CR1 0x5300
CR2 0x0000
CR3 0x0000
CR4 0x0000

Returns:

CR1 CD Status(high byte), Upper Calculated Size byte(low byte)
CR2 Lower Calculated Size word
CR3 0x0000
CR4 0x0000
HIRQ ESEL

Get Sector Info(0x54)

Format:

CR1 0x5400
CR2 Sector Number(low byte)
CR3 Buffer Number(high byte)
CR4 0x0000

Returns:

CR1 CD Status(high byte), Lower Sector FAD byte(low byte)
CR2 Lower Sector FAD word
CR3 Sector File Number(high byte), Sector Coding Number(low byte)
CR4 Sector Sub Mode(high byte), Sector Coding Information(low byte)
HIRQ ESEL

Notes: CD Status is set to rejected if Buffer Number is set higher than the maximum number of selectors or if Sector Number is set higher than the number of sectors in the requested buffer.

Execute FAD Search(0x55)

Format:

CR1 0x5500
CR2 Sector Position
CR3 Buffer Number(high byte), Upper FAD(low byte)
CR4 Lower FAD word

Returns: CD status data

HIRQ ESEL

Notes: CD Status is set to rejected if Buffer Number is set higher than the maximum number of selectors or if Sector Number is set higher than the number of sectors in the requested buffer.

Get FAD Search Results(0x56)

Format:

CR1 0x5600
CR2 0x0000
CR3 0x0000
CR4 0x0000

Returns:

CR1 CD Status(High Byte)
CR2 Sector Position
CR3 Buffer Number(high byte), Upper FAD(low byte)
CR4 Lower FAD word
HIRQ ESEL

Set Sector Length(0x60)

Format:

CR1 0x60(high byte), Get Sector Length(low byte)
CR2 Put Sector Length(high byte)
CR3 0x0000
CR4 0x0000

Returns: CD status data

HIRQ ESEL

Get Sector Data(0x61)

Format:

CR1 0x6100
CR2 Sector Offset
CR3 Buffer Number(high byte)
CR4 Sector Number

Returns: CD status data

HIRQ EHST

Notes: Sets CD Status to Data Transfer Request until the data is ready, then it clears it.

Delete Sector Data(0x62)

Format:

CR1 0x6200
CR2 Sector position(word) - If 0xFFFF, it deletes sectors [Sector Number] from the end. [Sector Number] must be either 1 or 0xFFFF
CR3 Buffer number(high byte)
CR4 Sector number(word) - If 0xFFFF, it deletes sectors from [Sector Position] to the end of the buffer partition

Returns: CD status data

HIRQ EHST

Get Then Delete Sector Data(0x63)

Format:

CR1 0x6300
CR2 Sector Offset
CR3 Buffer Number(high byte)
CR4 Sector Number

Returns: CD status data

HIRQ EHST, DRDY

Notes: Sets CD Status to Data Transfer Request until the data is ready, then it clears it.

Put Sector Data(0x64)

Format:

CR1 0x6400
CR2 0x0000
CR3 Buffer Number(high byte)
CR4 Sector Number

Returns: CD status data

HIRQ DRDY, EHST(only if it fails to allocate sectors)

Notes: Sets CD Status to Data Transfer Request until the data is ready, then it clears it.

Copy Sector Data(0x65)

Format:

CR1 0x65(high byte), Destination Filter Number(low byte)
CR2 Sector Offset
CR3 Source Buffer Number(high byte)
CR4 Sector Number

Returns: CD status data

HIRQ ECPY

Notes: Copies sector(s) like as if they were coming from the CD Device, etc. So basically we're talking about proper filtering, etc. Rejects command if buffer is full.

Move Sector Data(0x66)

Format:

CR1 0x66(high byte), Destination Filter Number(low byte)
CR2 Sector Offset
CR3 Source Buffer Number(high byte)
CR4 Sector Number

Returns: CD status data

HIRQ ECPY

Notes: Moves sector(s) like as if they were coming from the CD Device, etc. So basically we're talking about proper filtering, etc.

Get Copy Error(0x67)

Format:

CR1 0x6700
CR2 0x0000
CR3 0x0000
CR4 0x0000

Returns:

CR1 CD Status(high byte), Error Code(low byte)
CR2 0x0000
CR3 0x0000
CR4 0x0000
HIRQ N/A

Change Directory(0x70)

Format:

CR1 0x7000
CR2 0x0000
CR3 Filter Number(high byte), Upper File ID byte(lower byte)
CR4 Lower File ID word

Returns: CD status data

HIRQ EFLS

Read Directory(0x71)

Format:

CR1 0x7100
CR2 0x0000
CR3 Filter Number(high byte), Upper File ID byte(lower byte)
CR4 Lower File ID word

Returns: CD status data

HIRQ EFLS

If command is successful, directory data is stored internally starting from. Data can be retrieved via Get File Info command.

Notes: If specified filter number is invalid(such as 0xFF) or read fails CD status is set to reject.

Get File System Scope(0x72)

Format:

CR1 0x7200
CR2 0x0000
CR3 0x0000
CR4 0x0000

Format:

CR1 CD Status(high byte)
CR2 Index Number
CR3 Directory End Offset(high byte), Upper File ID Start byte(lower byte)
CR4 Lower File ID Start word
HIRQ EFLS

Get File Info(0x73)

Format:

CR1 0x7300
CR2 0x0000
CR3 Upper File ID byte(low byte)
CR4 Lower File ID word

Returns:

CR1 CD Status(high byte)
CR2 ????
CR3 ????
CR4 ????
HIRQ DRDY

Read File(0x74)

Format:

CR1 0x74(high byte), Upper Offset byte(low byte)
CR2 Lower Offset word
CR3 Filter Number(high byte), Upper File ID byte(low byte)
CR4 Lower File ID word

Returns: CD status data

HIRQ EFLS

Data format

(finish me)

Abort File(0x75)

Format:

CR1 0x7500
CR2 0x0000
CR3 0x0000
CR4 0x0000

Returns: CD status data

HIRQ EFLS