Line 99:
Line 99:
[Length bytes], CC
[Length bytes], CC
+
+
== Physical interface ==
+
The disk drive is connected to the motherboard via 2 cables, a power and a data cable.
+
+
=== Power cable ===
+
Power is delivered via a 12-pin Molex connector with the following pinout:
+
+
[[File:D32.jpg|thumb|right|Pinout of the power connector on the daughterboard]]
+
{|class=wikitable
+
!Pin
+
!Name
+
|-
+
|1
+
|GND
+
|-
+
|2
+
|GND
+
|-
+
|3
+
|3.3V
+
|-
+
|4
+
|3.3V
+
|-
+
|5
+
|GND
+
|-
+
|6
+
|GND
+
|-
+
|7
+
|5V
+
|-
+
|8
+
|5V
+
|-
+
|9
+
|GND
+
|-
+
|10
+
|GND
+
|-
+
|11
+
|12V
+
|-
+
|12
+
|12V
+
|}
+
+
=== Data cable ===
+
The 32 pin ribbon cable used to connect the disk drive to the motherboard seems to be very similar to the Gamecube, but with the order flipped a few rearranged. The overall design seems to draw heavily from parallel ports.{{ref|{{cite web|url=https://www.gc-forever.com/wiki/index.php?title=Using_a_Wii_drive_replacement_on_a_GameCube|title=Using a Wii drive replacement on a GameCube}}}}{{ref|{{cite web|url=https://www.gc-forever.com/forums/viewtopic.php?t=3362|title=The Definitive DI / DVD Interface Thread|author=hornpipe2}}}}
+
+
{|class=wikitable
+
!Pin
+
!Name
+
!Description
+
|-
+
|1
+
|DID0
+
|-
+
|2
+
|GND
+
|-
+
|3
+
|DID1
+
|-
+
|4
+
|GND
+
|-
+
|5
+
|DID2
+
|-
+
|6
+
|GND
+
|-
+
|7
+
|DID3
+
|-
+
|8
+
|GND
+
|-
+
|9
+
|DID4
+
|-
+
|10
+
|GND
+
|-
+
|11
+
|DID5
+
|-
+
|12
+
|GND
+
|-
+
|13
+
|DID6
+
|-
+
|14
+
|GND
+
|-
+
|15
+
|DID7
+
|-
+
|16
+
|GND
+
|-
+
|17
+
|DIDSTRB
+
|Drive IF device strobe
+
|-
+
|18
+
|GND
+
|-
+
|19
+
|DIHSTRB
+
|Drive IF host strobe
+
|-
+
|20
+
|GND
+
|-
+
|21
+
|DIDIR
+
|Drive IF direction
+
|-
+
|22
+
|DIRSTB
+
|Drive IF reset bit
+
|-
+
|23
+
|DICOVER
+
|Drive IF cover
+
|-
+
|24
+
|DIBRK
+
|Drive IF break
+
|-
+
|25
+
|DIERRB
+
|Drive IF error bit
+
|-
+
|26
+
|AISCLK
+
|Audio IF serial clock
+
|-
+
|27
+
|AISDATA
+
|Audio IF serial data
+
|-
+
|28
+
|AISLR
+
|Audio IF serial left/right
+
|-
+
|29
+
|DISC_EJECT
+
|-
+
|30
+
|DOOR_SNSR
+
|(NC)
+
|-
+
|31
+
|Unknown
+
|(NC)
+
|-
+
|32
+
|SENSE_PWR
+
|3.3V
+
|}
+
+
[[File:GC_TIMING.gif|thumb|right|Transactions strobe DIHSTRB first, then send a 12-byte transaction as described above. STRB lines are latched on rising edge]]
+
On power-up the Wii will set DRSTB, which starts the DVD processor working. The DVD drive should be reading from DID[0:7] in Input mode, and it should also monitor DIHSTRB and DIDIR. (Any time the Wii raises DIDIR, it wants the DVD to run the data bus. Any time it drops to Low, the DVD should stop what it's sending, and flip from output to input).
+
+
On the GameCube, the host will transmit at 20 MHz while the drive will respond at 13.5 MHz.
+
+
=== Audio Streaming ===
+
[[File:AI_CLK2.gif|thumb|right|Audio is streamed serially over AISD driven by AISCLK. AISLR signals whether the audio word is left or right.]]
+
The DVD drive has a built-in ability to decode regions of ADPCM sound. These are sent back on special pins which route to the sound processor. Thus, the CPU is freed from having to decode audio itself: it merely issues start/stop/queue commands and lets the drive do all the heavy lifting.
+
In order for this to work properly, a few things are needed:
+
* DVD drive has to be able to decode the ADPCM sound and send it back on the Audio pins 26-28
+
* Audio data must be aligned on 32kB sectors on disk, because the seek command is only this granular. Get the alignment wrong and only static will play.
+
+
Data is 16-bit big-endian stereo PCM. The clock is host-controlled and can be 32-48 kHz, effectively i2s.
== Example ==
== Example ==