<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://dreamcast.wiki/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Tails86</id>
	<title>dreamcast.wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://dreamcast.wiki/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Tails86"/>
	<link rel="alternate" type="text/html" href="https://dreamcast.wiki/Special:Contributions/Tails86"/>
	<updated>2026-04-06T03:45:40Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3851</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3851"/>
		<updated>2026-01-29T13:58:41Z</updated>

		<summary type="html">&lt;p&gt;Tails86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 50 Hz (PAL) or 60 Hz (NTSC) frame (every 20 or 16.7 ms) until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Packet End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection Sequence ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
This mode is only activated when the main peripheral implements both Controller and either Gun or AR Gun [[Maple_bus#Function_Codes|function code]]. Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the period of time marked blue in the image below once it detects that the electron beam of a CRT is in view of the light gun&#039;s lens. Once the Dreamcast brings SDCKA back HIGH, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun. No end sequence is sent after this is completed.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection is the time it takes to scan either only odd lines or the entire screen, depending on how the specific game is coded. For a 60 Hz screen (59.94 Hz actual) displaying 480i, this is about 16.68 milliseconds for half or 33.37 milliseconds for full. If no beam is detected, meaning SDCKB remains HIGH throughout the entire period, then the game normally treats this as a gun reload event.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Data Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt; For the communication direction, Host implies the Dreamcast and Device implies a peripheral.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|3 to 255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3 to 255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2 to 255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
===== Non-OEM Commands =====&lt;br /&gt;
&lt;br /&gt;
The following lists non-OEM commands supported by third party devices such as VM2 and VMUPro.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x21 || Game ID || Host-&amp;gt;Device || [[Maple_bus#Game_ID_Payload_Structure_.28cmd_0x21.29|4 or 36]] || 0x07 &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 0: Region code &amp;lt;br&amp;gt; Byte 1: Connection direction code &amp;lt;br&amp;gt; Bytes 2 and 3: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 0: Region code &amp;lt;br&amp;gt; Byte 1: Connection direction code &amp;lt;br&amp;gt; Bytes 2 and 3: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..254&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..254&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..254&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Game ID Payload Structure (cmd 0x21) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Words 4-35 (optional)&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Game ID bytes || Game Name String&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== Peripheral Implementation ==&lt;br /&gt;
&lt;br /&gt;
Refer to the following pages for a specific peripheral implementation.&lt;br /&gt;
&lt;br /&gt;
* [[Controller peripheral]]&lt;br /&gt;
* [[VMU peripheral]]&lt;br /&gt;
* [[Jump pack peripheral]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3850</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3850"/>
		<updated>2026-01-29T13:58:14Z</updated>

		<summary type="html">&lt;p&gt;Tails86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 50 Hz (PAL) or 60 Hz (NTSC) frame (every 20 or 16.6 ms) until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Packet End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection Sequence ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
This mode is only activated when the main peripheral implements both Controller and either Gun or AR Gun [[Maple_bus#Function_Codes|function code]]. Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the period of time marked blue in the image below once it detects that the electron beam of a CRT is in view of the light gun&#039;s lens. Once the Dreamcast brings SDCKA back HIGH, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun. No end sequence is sent after this is completed.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection is the time it takes to scan either only odd lines or the entire screen, depending on how the specific game is coded. For a 60 Hz screen (59.94 Hz actual) displaying 480i, this is about 16.68 milliseconds for half or 33.37 milliseconds for full. If no beam is detected, meaning SDCKB remains HIGH throughout the entire period, then the game normally treats this as a gun reload event.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Data Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt; For the communication direction, Host implies the Dreamcast and Device implies a peripheral.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|3 to 255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3 to 255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2 to 255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
===== Non-OEM Commands =====&lt;br /&gt;
&lt;br /&gt;
The following lists non-OEM commands supported by third party devices such as VM2 and VMUPro.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x21 || Game ID || Host-&amp;gt;Device || [[Maple_bus#Game_ID_Payload_Structure_.28cmd_0x21.29|4 or 36]] || 0x07 &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 0: Region code &amp;lt;br&amp;gt; Byte 1: Connection direction code &amp;lt;br&amp;gt; Bytes 2 and 3: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 0: Region code &amp;lt;br&amp;gt; Byte 1: Connection direction code &amp;lt;br&amp;gt; Bytes 2 and 3: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..254&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..254&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..254&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Game ID Payload Structure (cmd 0x21) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Words 4-35 (optional)&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Game ID bytes || Game Name String&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== Peripheral Implementation ==&lt;br /&gt;
&lt;br /&gt;
Refer to the following pages for a specific peripheral implementation.&lt;br /&gt;
&lt;br /&gt;
* [[Controller peripheral]]&lt;br /&gt;
* [[VMU peripheral]]&lt;br /&gt;
* [[Jump pack peripheral]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3842</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3842"/>
		<updated>2025-12-06T19:07:16Z</updated>

		<summary type="html">&lt;p&gt;Tails86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Packet End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection Sequence ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
This mode is only activated when the main peripheral implements both Controller and either Gun or AR Gun [[Maple_bus#Function_Codes|function code]]. Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the period of time marked blue in the image below once it detects that the electron beam of a CRT is in view of the light gun&#039;s lens. Once the Dreamcast brings SDCKA back HIGH, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun. No end sequence is sent after this is completed.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection is the time it takes to scan either only odd lines or the entire screen, depending on how the specific game is coded. For a 60 Hz screen (59.94 Hz actual) displaying 480i, this is about 16.68 milliseconds for half or 33.37 milliseconds for full. If no beam is detected, meaning SDCKB remains HIGH throughout the entire period, then the game normally treats this as a gun reload event.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Data Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt; For the communication direction, Host implies the Dreamcast and Device implies a peripheral.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|3 to 255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3 to 255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2 to 255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
===== Non-OEM Commands =====&lt;br /&gt;
&lt;br /&gt;
The following lists non-OEM commands supported by third party devices such as VM2 and VMUPro.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x21 || Game ID || Host-&amp;gt;Device || [[Maple_bus#Game_ID_Payload_Structure_.28cmd_0x21.29|4 or 36]] || 0x07 &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 0: Region code &amp;lt;br&amp;gt; Byte 1: Connection direction code &amp;lt;br&amp;gt; Bytes 2 and 3: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 0: Region code &amp;lt;br&amp;gt; Byte 1: Connection direction code &amp;lt;br&amp;gt; Bytes 2 and 3: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..254&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..254&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..254&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Game ID Payload Structure (cmd 0x21) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Words 4-35 (optional)&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Game ID bytes || Game Name String&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== Peripheral Implementation ==&lt;br /&gt;
&lt;br /&gt;
Refer to the following pages for a specific peripheral implementation.&lt;br /&gt;
&lt;br /&gt;
* [[Controller peripheral]]&lt;br /&gt;
* [[VMU peripheral]]&lt;br /&gt;
* [[Jump pack peripheral]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3841</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3841"/>
		<updated>2025-12-06T19:05:13Z</updated>

		<summary type="html">&lt;p&gt;Tails86: /* Non-OEM Commands */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Packet End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection Sequence ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
This mode is only activated when the main peripheral implements both Controller and either Gun or AR Gun [[Maple_bus#Function_Codes|function code]]. Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the period of time marked blue in the image below once it detects that the electron beam of a CRT is in view of the light gun&#039;s lens. Once the Dreamcast brings SDCKA back HIGH, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun. No end sequence is sent after this is completed.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection is the time it takes to scan either only odd lines or the entire screen, depending on how the specific game is coded. For a 60 Hz screen (59.94 Hz actual) displaying 480i, this is about 16.68 milliseconds for half or 33.37 milliseconds for full. If no beam is detected, meaning SDCKB remains HIGH throughout the entire period, then the game normally treats this as a gun reload event.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Data Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt; For the communication direction, Host implies the Dreamcast and Device implies a peripheral.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|3..256]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..256]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..256]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
===== Non-OEM Commands =====&lt;br /&gt;
&lt;br /&gt;
The following lists non-OEM commands supported by third party devices such as VM2 and VMUPro.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x21 || Game ID || Host-&amp;gt;Device || [[Maple_bus#Game_ID_Payload_Structure_.28cmd_0x21.29|4 or 36]] || 0x07 &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 0: Region code &amp;lt;br&amp;gt; Byte 1: Connection direction code &amp;lt;br&amp;gt; Bytes 2 and 3: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 0: Region code &amp;lt;br&amp;gt; Byte 1: Connection direction code &amp;lt;br&amp;gt; Bytes 2 and 3: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Game ID Payload Structure (cmd 0x21) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Words 4-35 (optional)&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Game ID bytes || Game Name String&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== Peripheral Implementation ==&lt;br /&gt;
&lt;br /&gt;
Refer to the following pages for a specific peripheral implementation.&lt;br /&gt;
&lt;br /&gt;
* [[Controller peripheral]]&lt;br /&gt;
* [[VMU peripheral]]&lt;br /&gt;
* [[Jump pack peripheral]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3840</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3840"/>
		<updated>2025-12-06T17:50:51Z</updated>

		<summary type="html">&lt;p&gt;Tails86: /* Game ID Payload Structure (cmd 0x21) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Packet End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection Sequence ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
This mode is only activated when the main peripheral implements both Controller and either Gun or AR Gun [[Maple_bus#Function_Codes|function code]]. Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the period of time marked blue in the image below once it detects that the electron beam of a CRT is in view of the light gun&#039;s lens. Once the Dreamcast brings SDCKA back HIGH, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun. No end sequence is sent after this is completed.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection is the time it takes to scan either only odd lines or the entire screen, depending on how the specific game is coded. For a 60 Hz screen (59.94 Hz actual) displaying 480i, this is about 16.68 milliseconds for half or 33.37 milliseconds for full. If no beam is detected, meaning SDCKB remains HIGH throughout the entire period, then the game normally treats this as a gun reload event.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Data Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt; For the communication direction, Host implies the Dreamcast and Device implies a peripheral.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|3..256]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..256]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..256]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
===== Non-OEM Commands =====&lt;br /&gt;
&lt;br /&gt;
The following lists non-OEM commands supported by third party devices such as VM2 and VMUPro.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x21 || Game ID || Host-&amp;gt;Device || [[Maple_bus#Game_ID_Payload_Structure_.28cmd_0x21.29|4..36]] || 0x07 &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 0: Region code &amp;lt;br&amp;gt; Byte 1: Connection direction code &amp;lt;br&amp;gt; Bytes 2 and 3: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 0: Region code &amp;lt;br&amp;gt; Byte 1: Connection direction code &amp;lt;br&amp;gt; Bytes 2 and 3: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Game ID Payload Structure (cmd 0x21) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Words 4-35 (optional)&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Game ID bytes || Game Name String&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== Peripheral Implementation ==&lt;br /&gt;
&lt;br /&gt;
Refer to the following pages for a specific peripheral implementation.&lt;br /&gt;
&lt;br /&gt;
* [[Controller peripheral]]&lt;br /&gt;
* [[VMU peripheral]]&lt;br /&gt;
* [[Jump pack peripheral]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3839</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3839"/>
		<updated>2025-12-06T17:49:35Z</updated>

		<summary type="html">&lt;p&gt;Tails86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Packet End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection Sequence ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
This mode is only activated when the main peripheral implements both Controller and either Gun or AR Gun [[Maple_bus#Function_Codes|function code]]. Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the period of time marked blue in the image below once it detects that the electron beam of a CRT is in view of the light gun&#039;s lens. Once the Dreamcast brings SDCKA back HIGH, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun. No end sequence is sent after this is completed.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection is the time it takes to scan either only odd lines or the entire screen, depending on how the specific game is coded. For a 60 Hz screen (59.94 Hz actual) displaying 480i, this is about 16.68 milliseconds for half or 33.37 milliseconds for full. If no beam is detected, meaning SDCKB remains HIGH throughout the entire period, then the game normally treats this as a gun reload event.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Data Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt; For the communication direction, Host implies the Dreamcast and Device implies a peripheral.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|3..256]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..256]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..256]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
===== Non-OEM Commands =====&lt;br /&gt;
&lt;br /&gt;
The following lists non-OEM commands supported by third party devices such as VM2 and VMUPro.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x21 || Game ID || Host-&amp;gt;Device || [[Maple_bus#Game_ID_Payload_Structure_.28cmd_0x21.29|4..36]] || 0x07 &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 0: Region code &amp;lt;br&amp;gt; Byte 1: Connection direction code &amp;lt;br&amp;gt; Bytes 2 and 3: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 0: Region code &amp;lt;br&amp;gt; Byte 1: Connection direction code &amp;lt;br&amp;gt; Bytes 2 and 3: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Game ID Payload Structure (cmd 0x21) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Words 4-36 (optional)&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Game ID bytes || Game Name String&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== Peripheral Implementation ==&lt;br /&gt;
&lt;br /&gt;
Refer to the following pages for a specific peripheral implementation.&lt;br /&gt;
&lt;br /&gt;
* [[Controller peripheral]]&lt;br /&gt;
* [[VMU peripheral]]&lt;br /&gt;
* [[Jump pack peripheral]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3838</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3838"/>
		<updated>2025-12-06T17:40:26Z</updated>

		<summary type="html">&lt;p&gt;Tails86: /* Game ID Payload Structure (cmd 0x21) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Packet End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection Sequence ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
This mode is only activated when the main peripheral implements both Controller and either Gun or AR Gun [[Maple_bus#Function_Codes|function code]]. Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the period of time marked blue in the image below once it detects that the electron beam of a CRT is in view of the light gun&#039;s lens. Once the Dreamcast brings SDCKA back HIGH, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun. No end sequence is sent after this is completed.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection is the time it takes to scan either only odd lines or the entire screen, depending on how the specific game is coded. For a 60 Hz screen (59.94 Hz actual) displaying 480i, this is about 16.68 milliseconds for half or 33.37 milliseconds for full. If no beam is detected, meaning SDCKB remains HIGH throughout the entire period, then the game normally treats this as a gun reload event.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Data Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt; For the communication direction, Host implies the Dreamcast and Device implies a peripheral.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|3..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
===== Non-OEM Commands =====&lt;br /&gt;
&lt;br /&gt;
The following lists non-OEM commands supported by third party devices such as VM2 and VMUPro.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x21 || Game ID || Host-&amp;gt;Device || [[Maple_bus#Game_ID_Payload_Structure_.28cmd_0x21.29|4..36]] || 0x07 &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 0: Region code &amp;lt;br&amp;gt; Byte 1: Connection direction code &amp;lt;br&amp;gt; Bytes 2 and 3: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 0: Region code &amp;lt;br&amp;gt; Byte 1: Connection direction code &amp;lt;br&amp;gt; Bytes 2 and 3: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Game ID Payload Structure (cmd 0x21) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..3 !! Words 4..36&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Game ID bytes || Game Name String (optional)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== Peripheral Implementation ==&lt;br /&gt;
&lt;br /&gt;
Refer to the following pages for a specific peripheral implementation.&lt;br /&gt;
&lt;br /&gt;
* [[Controller peripheral]]&lt;br /&gt;
* [[VMU peripheral]]&lt;br /&gt;
* [[Jump pack peripheral]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3837</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3837"/>
		<updated>2025-12-06T17:31:25Z</updated>

		<summary type="html">&lt;p&gt;Tails86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Packet End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection Sequence ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
This mode is only activated when the main peripheral implements both Controller and either Gun or AR Gun [[Maple_bus#Function_Codes|function code]]. Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the period of time marked blue in the image below once it detects that the electron beam of a CRT is in view of the light gun&#039;s lens. Once the Dreamcast brings SDCKA back HIGH, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun. No end sequence is sent after this is completed.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection is the time it takes to scan either only odd lines or the entire screen, depending on how the specific game is coded. For a 60 Hz screen (59.94 Hz actual) displaying 480i, this is about 16.68 milliseconds for half or 33.37 milliseconds for full. If no beam is detected, meaning SDCKB remains HIGH throughout the entire period, then the game normally treats this as a gun reload event.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Data Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt; For the communication direction, Host implies the Dreamcast and Device implies a peripheral.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|3..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
===== Non-OEM Commands =====&lt;br /&gt;
&lt;br /&gt;
The following lists non-OEM commands supported by third party devices such as VM2 and VMUPro.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x21 || Game ID || Host-&amp;gt;Device || [[Maple_bus#Game_ID_Payload_Structure_.28cmd_0x21.29|4..36]] || 0x07 &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 0: Region code &amp;lt;br&amp;gt; Byte 1: Connection direction code &amp;lt;br&amp;gt; Bytes 2 and 3: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 0: Region code &amp;lt;br&amp;gt; Byte 1: Connection direction code &amp;lt;br&amp;gt; Bytes 2 and 3: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Game ID Payload Structure (cmd 0x21) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..3 !! Words 4..36&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Game ID bytes || Game Name String&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== Peripheral Implementation ==&lt;br /&gt;
&lt;br /&gt;
Refer to the following pages for a specific peripheral implementation.&lt;br /&gt;
&lt;br /&gt;
* [[Controller peripheral]]&lt;br /&gt;
* [[VMU peripheral]]&lt;br /&gt;
* [[Jump pack peripheral]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3836</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3836"/>
		<updated>2025-12-06T17:28:42Z</updated>

		<summary type="html">&lt;p&gt;Tails86: Added VM2/WMUPro Game ID command&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Packet End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection Sequence ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
This mode is only activated when the main peripheral implements both Controller and either Gun or AR Gun [[Maple_bus#Function_Codes|function code]]. Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the period of time marked blue in the image below once it detects that the electron beam of a CRT is in view of the light gun&#039;s lens. Once the Dreamcast brings SDCKA back HIGH, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun. No end sequence is sent after this is completed.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection is the time it takes to scan either only odd lines or the entire screen, depending on how the specific game is coded. For a 60 Hz screen (59.94 Hz actual) displaying 480i, this is about 16.68 milliseconds for half or 33.37 milliseconds for full. If no beam is detected, meaning SDCKB remains HIGH throughout the entire period, then the game normally treats this as a gun reload event.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Data Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt; For the communication direction, Host implies the Dreamcast and Device implies a peripheral.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|3..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
===== Non-OEM Commands =====&lt;br /&gt;
&lt;br /&gt;
The following lists non-OEM commands supported by third party devices such as VM2 and VMUPro.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x21 || Game ID || Host-&amp;gt;Device || [[Maple_bus#Game_ID_Payload_Structure_.28cmd_0x21.29|4..36]] || 0x07 &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 0: Region code &amp;lt;br&amp;gt; Byte 1: Connection direction code &amp;lt;br&amp;gt; Bytes 2 and 3: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 0: Region code &amp;lt;br&amp;gt; Byte 1: Connection direction code &amp;lt;br&amp;gt; Bytes 2 and 3: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Game ID Payload Structure (cmd 0x21) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..3 !! Words 4..36&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Game ID bytes || Game Name String&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== Peripheral Implementation ==&lt;br /&gt;
&lt;br /&gt;
Refer to the following pages for a specific peripheral implementation.&lt;br /&gt;
&lt;br /&gt;
* [[Controller peripheral]]&lt;br /&gt;
* [[VMU peripheral]]&lt;br /&gt;
* [[Jump pack peripheral]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3835</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3835"/>
		<updated>2025-12-06T01:43:29Z</updated>

		<summary type="html">&lt;p&gt;Tails86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Packet End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection Sequence ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
This mode is only activated when the main peripheral implements both Controller and either Gun or AR Gun [[Maple_bus#Function_Codes|function code]]. Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the period of time marked blue in the image below once it detects that the electron beam of a CRT is in view of the light gun&#039;s lens. Once the Dreamcast brings SDCKA back HIGH, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun. No end sequence is sent after this is completed.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection is the time it takes to scan either only odd lines or the entire screen, depending on how the specific game is coded. For a 60 Hz screen (59.94 Hz actual) displaying 480i, this is about 16.68 milliseconds for half or 33.37 milliseconds for full. If no beam is detected, meaning SDCKB remains HIGH throughout the entire period, then the game normally treats this as a gun reload event.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Data Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt; For the communication direction, Host implies the Dreamcast and Device implies a peripheral.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|3..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 0: Region code &amp;lt;br&amp;gt; Byte 1: Connection direction code &amp;lt;br&amp;gt; Bytes 2 and 3: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 0: Region code &amp;lt;br&amp;gt; Byte 1: Connection direction code &amp;lt;br&amp;gt; Bytes 2 and 3: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== Peripheral Implementation ==&lt;br /&gt;
&lt;br /&gt;
Refer to the following pages for a specific peripheral implementation.&lt;br /&gt;
&lt;br /&gt;
* [[Controller peripheral]]&lt;br /&gt;
* [[VMU peripheral]]&lt;br /&gt;
* [[Jump pack peripheral]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3684</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3684"/>
		<updated>2025-02-15T06:48:10Z</updated>

		<summary type="html">&lt;p&gt;Tails86: /* Commands */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Packet End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection Sequence ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
This mode is only activated when the main peripheral implements both Controller and either Gun or AR Gun [[Maple_bus#Function_Codes|function code]]. Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the period of time marked blue in the image below once it detects that the electron beam of a CRT is in view of the light gun&#039;s lens. Once the Dreamcast brings SDCKA back HIGH, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun. No end sequence is sent after this is completed.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection is the time it takes to scan either only odd lines or the entire screen, depending on how the specific game is coded. For a 60 Hz screen (59.94 Hz actual) displaying 480i, this is about 16.68 milliseconds for half or 33.37 milliseconds for full. If no beam is detected, meaning SDCKB remains HIGH throughout the entire period, then the game normally treats this as a gun reload event.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Data Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt; For the communication direction, Host implies the Dreamcast and Device implies a peripheral.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|3..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== Peripheral Implementation ==&lt;br /&gt;
&lt;br /&gt;
Refer to the following pages for a specific peripheral implementation.&lt;br /&gt;
&lt;br /&gt;
* [[Controller peripheral]]&lt;br /&gt;
* [[VMU peripheral]]&lt;br /&gt;
* [[Jump pack peripheral]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3683</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3683"/>
		<updated>2025-02-15T06:47:52Z</updated>

		<summary type="html">&lt;p&gt;Tails86: /* Data Transfer Payload Structure (cmd 0x08) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Packet End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection Sequence ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
This mode is only activated when the main peripheral implements both Controller and either Gun or AR Gun [[Maple_bus#Function_Codes|function code]]. Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the period of time marked blue in the image below once it detects that the electron beam of a CRT is in view of the light gun&#039;s lens. Once the Dreamcast brings SDCKA back HIGH, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun. No end sequence is sent after this is completed.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection is the time it takes to scan either only odd lines or the entire screen, depending on how the specific game is coded. For a 60 Hz screen (59.94 Hz actual) displaying 480i, this is about 16.68 milliseconds for half or 33.37 milliseconds for full. If no beam is detected, meaning SDCKB remains HIGH throughout the entire period, then the game normally treats this as a gun reload event.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Data Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt; For the communication direction, Host implies the Dreamcast and Device implies a peripheral.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|2..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== Peripheral Implementation ==&lt;br /&gt;
&lt;br /&gt;
Refer to the following pages for a specific peripheral implementation.&lt;br /&gt;
&lt;br /&gt;
* [[Controller peripheral]]&lt;br /&gt;
* [[VMU peripheral]]&lt;br /&gt;
* [[Jump pack peripheral]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=VMU_peripheral&amp;diff=3680</id>
		<title>VMU peripheral</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=VMU_peripheral&amp;diff=3680"/>
		<updated>2025-02-03T00:31:07Z</updated>

		<summary type="html">&lt;p&gt;Tails86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The VMU peripheral on the [[Maple_bus|Maple Bus]] contains 3 functions: screen, storage, and timer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; Some information here is misleading and/or incomplete&lt;br /&gt;
&lt;br /&gt;
== Storage ==&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;block read&amp;quot; and &amp;quot;block write&amp;quot; commands (0x0B and 0x0C) with storage function code are used to read and write blocks of memory in the storage peripheral. &lt;br /&gt;
&lt;br /&gt;
Normally, there are 256 blocks of memory that make up the entire storage space, and normally each block consists of 512 bytes. That makes a total of 128 KB of memory. These values are configurable according to the Maple Bus spec, but anything other than these values is not practically usable by most games due to many high-level APIs and libraries within the SDKs not adhering properly to the Maple spec and making hardcoded assumptions about the volume information.&amp;lt;ref&amp;gt;&#039;&#039;[https://www.dreamcast-talk.com/forum/viewtopic.php?f=5&amp;amp;t=15562&amp;amp;p=171565] TapamN | 400 block VMU on emulator&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Function Definition ===&lt;br /&gt;
The function definition may be found in the peripheral&#039;s [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|device info packet]]. It is necessary to read this word to know how to access blocks of memory on the storage.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| bit 7: removable (1: true)&amp;lt;br&amp;gt;bit 6: CRC (1: needed)&amp;lt;br&amp;gt;bits 0-5: unused (0) || bits 4-7: number of write accesses per block&amp;lt;br&amp;gt;bits 0-3: number of read accesses per block || number of bytes per block&amp;lt;br&amp;gt;(x + 1)*32 bytes || number of partitions (x + 1)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Get Media Info ===&lt;br /&gt;
Execute a [[Maple_bus#Commands|get memory information]] command to get information about the size and locations of some information within the media. On successful execution, a [[Maple_bus#Commands|data transfer]] packet with the following payload will be returned. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Word 2 !! Word 3 !! Word 4 !! Word 5 !! Word 6&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] &amp;lt;br&amp;gt; 0x00000002 || 2 most sig bytes: total size &amp;lt;br&amp;gt; 2 least sig bytes: the partition number of this media || 2 most sig bytes: block number of system area &amp;lt;br&amp;gt; 2 least sig bytes: block number of start of FAT area || 2 most sig bytes: number of FAT blocks &amp;lt;br&amp;gt; 2 least sig bytes: block number of file information || 2 most sig bytes: number of file info blocks &amp;lt;br&amp;gt; 2 least sig bytes: icon number || 2 most sig bytes: block number of save area &amp;lt;br&amp;gt; 2 least sig bytes: number of blocks in save area || execution file info&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Block Read ===&lt;br /&gt;
Execute a sequence of [[Maple_bus#Commands|block reads]] to read data from storage. The number of sequences is dependent on the number of read accesses per block defined in the function definition above. On successful execution, a [[Maple_bus#Commands|data transfer]] packet will be returned.&lt;br /&gt;
&lt;br /&gt;
=== Block Write ===&lt;br /&gt;
Execute a sequence of [[Maple_bus#Commands|block writes]] to write data to storage. The number of sequences is dependent on the number of write accesses per block defined in the function definition above. On successful execution, a [[Maple_bus#Commands|acknowledge]] packet will be returned. After the final write sequence, execute a [[Maple_bus#Commands|get last error]] command with an incremented phase value to commit the block from RAM to storage. &lt;br /&gt;
* A VMU cannot handle successive block write packets faster than about 10 ms per write &lt;br /&gt;
** After such error, the storage functionality acts as if it never received this sequence and never returns a response packet - it may be possible to successfully resend this sequence, but writing a &amp;quot;get last error&amp;quot; command would be necessary before starting over at the first sequence&lt;br /&gt;
** The Dreamcast does each read/write sequence on the same cadence as controller polling (about every 16 ms)&lt;br /&gt;
&lt;br /&gt;
== Screen ==&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;block write&amp;quot; command (0x0C) with screen function code and 48 data words is used to write monochrome images to the screen. The payload of this command should look like the following.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..49&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] &amp;lt;br&amp;gt; 0x0000000C || [[Maple_bus#Location_Word|Location word]] &amp;lt;br&amp;gt; 0x00000000 || Screen data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
A screen is 48 bits wide and 32 bits tall. For each bit in the 48 data words, a value of 1 means the pixel is on (black) and 0 means the pixel is off (white). Data is written from left to right and top to bottom (when holding the VMU in the upright orientation i.e. controller flipped upside down). The most significant bit of the first word sets the pixel on the top, left of the screen. The two most significant bytes write to the 33rd through 48th bit of the first row. The next two bytes write to the 1st through 16th bits of the second row. This is repeated for the rest of the 48 words like pictured below.&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Screen Words.png|Dreamcast Screen Words]]&lt;br /&gt;
&lt;br /&gt;
== Timer ==&lt;br /&gt;
&lt;br /&gt;
The timer function allows the host to activate the buzzer on the VMU and get button conditions.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3504</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3504"/>
		<updated>2024-03-10T22:56:20Z</updated>

		<summary type="html">&lt;p&gt;Tails86: /* Light Gun CRT Beam Detection Sequence */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Packet End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection Sequence ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
This mode is only activated when the main peripheral implements both Controller and either Gun or AR Gun [[Maple_bus#Function_Codes|function code]]. Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the period of time marked blue in the image below once it detects that the electron beam of a CRT is in view of the light gun&#039;s lens. Once the Dreamcast brings SDCKA back HIGH, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun. No end sequence is sent after this is completed.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection is the time it takes to scan either only odd lines or the entire screen, depending on how the specific game is coded. For a 60 Hz screen (59.94 Hz actual) displaying 480i, this is about 16.68 milliseconds for half or 33.37 milliseconds for full. If no beam is detected, meaning SDCKB remains HIGH throughout the entire period, then the game normally treats this as a gun reload event.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Data Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt; For the communication direction, Host implies the Dreamcast and Device implies a peripheral.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|2..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== Peripheral Implementation ==&lt;br /&gt;
&lt;br /&gt;
Refer to the following pages for a specific peripheral implementation.&lt;br /&gt;
&lt;br /&gt;
* [[Controller peripheral]]&lt;br /&gt;
* [[VMU peripheral]]&lt;br /&gt;
* [[Jump pack peripheral]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3503</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3503"/>
		<updated>2024-03-10T19:47:51Z</updated>

		<summary type="html">&lt;p&gt;Tails86: /* Light Gun CRT Beam Detection Sequence */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Packet End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection Sequence ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
This mode is only activated when the main peripheral implements both Controller and either Gun or AR Gun [[Maple_bus#Function_Codes|function code]]. Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the period of time marked blue in the image below once it detects that the electron beam of a CRT is in view of the light gun&#039;s lens. Once the Dreamcast brings SDCKA back HIGH, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun. No end sequence is sent after this is completed.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection is the time it takes to scan either only odd lines or the entire screen, depending on how the specific game is coded. For a 60 Hz screen (59.94 Hz actual) displaying 480i, this is about 16.68 for half or 33.37 milliseconds for full. If no beam is detected, meaning SDCKB remains HIGH throughout the entire period, then the game normally treats this as a gun reload event.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Data Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt; For the communication direction, Host implies the Dreamcast and Device implies a peripheral.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|2..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== Peripheral Implementation ==&lt;br /&gt;
&lt;br /&gt;
Refer to the following pages for a specific peripheral implementation.&lt;br /&gt;
&lt;br /&gt;
* [[Controller peripheral]]&lt;br /&gt;
* [[VMU peripheral]]&lt;br /&gt;
* [[Jump pack peripheral]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3411</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3411"/>
		<updated>2024-02-10T02:11:12Z</updated>

		<summary type="html">&lt;p&gt;Tails86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Packet End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection Sequence ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
This mode is only activated when the main peripheral implements both Controller and either Gun or AR Gun [[Maple_bus#Function_Codes|function code]]. Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the period of time marked blue in the image below once it detects that the electron beam of a CRT is in view of the light gun&#039;s lens. Once the Dreamcast brings SDCKA back HIGH, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun. No end sequence is sent after this is completed.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection is the time it takes to scan the entire screen. For a 60 Hz screen (59.94 Hz actual) displaying 480i, this is about 33.36 milliseconds. Assuming a composite signal actually scans 525 lines and horizontal retrace takes 10 microseconds per line, the time window for each pixel on a 60 Hz screen is about 83.6 nanoseconds. If beam detection only occurs in the last 16.68 milliseconds, the shot won&#039;t count, and the Dreamcast may also flag the light gun as faulty. If no beam is detected, meaning SDCKB remains HIGH throughout the entire period, then the game normally treats this as a gun reload event.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Data Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt; For the communication direction, Host implies the Dreamcast and Device implies a peripheral.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|2..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== Peripheral Implementation ==&lt;br /&gt;
&lt;br /&gt;
Refer to the following pages for a specific peripheral implementation.&lt;br /&gt;
&lt;br /&gt;
* [[Controller peripheral]]&lt;br /&gt;
* [[VMU peripheral]]&lt;br /&gt;
* [[Jump pack peripheral]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3368</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3368"/>
		<updated>2024-02-04T02:42:32Z</updated>

		<summary type="html">&lt;p&gt;Tails86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Packet End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection Sequence ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
This mode is only activated when the main peripheral implements both Controller and either Gun or AR Gun [[Maple_bus#Function_Codes|function code]]. Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the period of time marked blue in the image below once it detects that the electron beam of a CRT is in view of the light gun&#039;s lens. Once the Dreamcast brings SDCKA back HIGH, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun. No end sequence is sent after this is completed.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection is the time it takes to scan the entire screen. For a 60 Hz screen (59.94 Hz actual) displaying 480i, this is about 33.36 milliseconds. Assuming a composite signal actually scans 525 lines, the time window for each pixel on a 60 Hz screen is about 99 nanoseconds. If beam detection only occurs in the last 16.68 milliseconds, the shot won&#039;t count, and the Dreamcast may also flag the light gun as faulty. If no beam is detected, meaning SDCKB remains HIGH throughout the entire period, then the game normally treats this as a gun reload event.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Data Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt; For the communication direction, Host implies the Dreamcast and Device implies a peripheral.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|2..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== Peripheral Implementation ==&lt;br /&gt;
&lt;br /&gt;
Refer to the following pages for a specific peripheral implementation.&lt;br /&gt;
&lt;br /&gt;
* [[Controller peripheral]]&lt;br /&gt;
* [[VMU peripheral]]&lt;br /&gt;
* [[Jump pack peripheral]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3367</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3367"/>
		<updated>2024-02-04T02:38:52Z</updated>

		<summary type="html">&lt;p&gt;Tails86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Packet End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection Sequence ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
This mode is only activated when the main peripheral implements both Controller and either Gun or AR Gun [[Maple_bus#Function_Codes|function code]]. Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the period of time marked blue in the image below once it detects that the electron beam of a CRT is in view of the light gun&#039;s lens. Once the Dreamcast brings SDCKA back HIGH, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun. No end sequence is sent after this is completed.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection is the time it takes to scan the entire screen. For a 60 Hz screen (59.94 Hz actual) displaying 480i, this is about 33.36 milliseconds. Assuming a composite signal actually scans 525 lines, the time window for each pixel on a 60 Hz screen is about 99 nanoseconds. A beam detection must occur within the first 16.68 milliseconds or the shot won&#039;t count, and the Dreamcast may also flag the light gun as faulty.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Data Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt; For the communication direction, Host implies the Dreamcast and Device implies a peripheral.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|2..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== Peripheral Implementation ==&lt;br /&gt;
&lt;br /&gt;
Refer to the following pages for a specific peripheral implementation.&lt;br /&gt;
&lt;br /&gt;
* [[Controller peripheral]]&lt;br /&gt;
* [[VMU peripheral]]&lt;br /&gt;
* [[Jump pack peripheral]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3366</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3366"/>
		<updated>2024-02-04T02:34:38Z</updated>

		<summary type="html">&lt;p&gt;Tails86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Packet End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection Sequence ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
This mode is only activated when the main peripheral implements both Controller and either Gun or AR Gun [[Maple_bus#Function_Codes|function code]]. Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the period of time marked blue in the image below once it detects that the electron beam of a CRT is in view of the light gun&#039;s lens. Once the Dreamcast brings SDCKA back HIGH, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun. No end sequence is sent after this is completed.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection is the time it takes to scan the entire screen. For a 60 Hz screen (59.94 Hz actual) displaying 480i, this is about 33.36 milliseconds. Assuming a composite signal actually scans 525 lines, the time window for each pixel on a 60 Hz screen is about 99 nanoseconds.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Data Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt; For the communication direction, Host implies the Dreamcast and Device implies a peripheral.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|2..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== Peripheral Implementation ==&lt;br /&gt;
&lt;br /&gt;
Refer to the following pages for a specific peripheral implementation.&lt;br /&gt;
&lt;br /&gt;
* [[Controller peripheral]]&lt;br /&gt;
* [[VMU peripheral]]&lt;br /&gt;
* [[Jump pack peripheral]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3365</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3365"/>
		<updated>2024-02-04T02:33:30Z</updated>

		<summary type="html">&lt;p&gt;Tails86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Packet End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection Sequence ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
This mode is only activated when the main peripheral implements Gun or AR Gun [[Maple_bus#Function_Codes|function code]]. Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the period of time marked blue in the image below once it detects that the electron beam of a CRT is in view of the light gun&#039;s lens. Once the Dreamcast brings SDCKA back HIGH, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun. No end sequence is sent after this is completed.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection is the time it takes to scan the entire screen. For a 60 Hz screen (59.94 Hz actual) displaying 480i, this is about 33.36 milliseconds. Assuming a composite signal actually scans 525 lines, the time window for each pixel on a 60 Hz screen is about 99 nanoseconds.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Data Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt; For the communication direction, Host implies the Dreamcast and Device implies a peripheral.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|2..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== Peripheral Implementation ==&lt;br /&gt;
&lt;br /&gt;
Refer to the following pages for a specific peripheral implementation.&lt;br /&gt;
&lt;br /&gt;
* [[Controller peripheral]]&lt;br /&gt;
* [[VMU peripheral]]&lt;br /&gt;
* [[Jump pack peripheral]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3303</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3303"/>
		<updated>2024-01-27T22:05:53Z</updated>

		<summary type="html">&lt;p&gt;Tails86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Packet End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection Sequence ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the period of time marked blue in the image below once it detects that the electron beam of a CRT is in view of the light gun&#039;s lens. Once the Dreamcast brings SDCKA back HIGH, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun. No end sequence is sent after this is completed.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection is the time it takes to scan the entire screen. For a 60 Hz screen (59.94 Hz actual) displaying 480i, this is about 33.36 milliseconds. Assuming a composite signal actually scans 525 lines, the time window for each pixel on a 60 Hz screen is about 97 nanoseconds.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Data Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt; For the communication direction, Host implies the Dreamcast and Device implies a peripheral.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|2..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== Peripheral Implementation ==&lt;br /&gt;
&lt;br /&gt;
Refer to the following pages for a specific peripheral implementation.&lt;br /&gt;
&lt;br /&gt;
* [[Controller peripheral]]&lt;br /&gt;
* [[VMU peripheral]]&lt;br /&gt;
* [[Jump pack peripheral]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3302</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3302"/>
		<updated>2024-01-27T15:25:38Z</updated>

		<summary type="html">&lt;p&gt;Tails86: /* Peripheral Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Packet End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection Sequence ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the period of time marked blue in the image below once it detects that the electron beam of a CRT is in view of the light gun&#039;s lens. Once the Dreamcast brings SDCKA back HIGH, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun. No end sequence is sent after this is completed.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection is the time it takes to scan the entire screen. For a 60 Hz screen (59.94 Hz actual) displaying 480i, this is about 33.36 milliseconds. Assuming a composite signal actually scans 525 lines, the time window for each pixel on a 60 Hz screen is about 97 nanoseconds.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt; For the communication direction, Host implies the Dreamcast and Device implies a peripheral.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|2..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== Peripheral Implementation ==&lt;br /&gt;
&lt;br /&gt;
Refer to the following pages for a specific peripheral implementation.&lt;br /&gt;
&lt;br /&gt;
* [[Controller peripheral]]&lt;br /&gt;
* [[VMU peripheral]]&lt;br /&gt;
* [[Jump pack peripheral]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3301</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3301"/>
		<updated>2024-01-27T15:25:05Z</updated>

		<summary type="html">&lt;p&gt;Tails86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Packet End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection Sequence ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the period of time marked blue in the image below once it detects that the electron beam of a CRT is in view of the light gun&#039;s lens. Once the Dreamcast brings SDCKA back HIGH, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun. No end sequence is sent after this is completed.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection is the time it takes to scan the entire screen. For a 60 Hz screen (59.94 Hz actual) displaying 480i, this is about 33.36 milliseconds. Assuming a composite signal actually scans 525 lines, the time window for each pixel on a 60 Hz screen is about 97 nanoseconds.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt; For the communication direction, Host implies the Dreamcast and Device implies a peripheral.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|2..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== Peripheral Implementation ==&lt;br /&gt;
&lt;br /&gt;
Refer to the following pages for a specific peripheral implementation.&lt;br /&gt;
&lt;br /&gt;
[[Controller peripheral]]&lt;br /&gt;
[[VMU peripheral]]&lt;br /&gt;
[[Jump pack peripheral]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3300</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3300"/>
		<updated>2024-01-27T14:55:25Z</updated>

		<summary type="html">&lt;p&gt;Tails86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Packet End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection Sequence ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the period of time marked blue in the image below once it detects that the electron beam of a CRT is in view of the light gun&#039;s lens. Once the Dreamcast brings SDCKA back HIGH, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun. No end sequence is sent after this is completed.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection is the time it takes to scan the entire screen. For a 60 Hz screen (59.94 Hz actual) displaying 480i, this is about 33.36 milliseconds. Assuming a composite signal actually scans 525 lines, the time window for each pixel on a 60 Hz screen is about 97 nanoseconds.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt; For the communication direction, Host implies the Dreamcast and Device implies a peripheral.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|2..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the [[Maple_bus#Word_Format|word format]] section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3299</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3299"/>
		<updated>2024-01-27T14:51:55Z</updated>

		<summary type="html">&lt;p&gt;Tails86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Packet End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection Sequence ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the period of time marked blue in the image below once it detects that the electron beam of a CRT is in view of the light gun&#039;s lens. Once the Dreamcast brings SDCKA back HIGH, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun. No end sequence is sent after this is completed.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection is the time it takes to scan the entire screen. For a 60 Hz screen (59.94 Hz actual) displaying 480i, this is about 33.36 milliseconds. Assuming a composite signal actually scans 525 lines, the time window for each pixel on a 60 Hz screen is about 97 nanoseconds.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt; For the communication direction, Host implies the Dreamcast and Device implies a peripheral.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|2..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the word format section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the word format section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3298</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3298"/>
		<updated>2024-01-27T14:43:58Z</updated>

		<summary type="html">&lt;p&gt;Tails86: Light gun does not hold down SDCKB - it only stays low for the period that the beam is in view of the lens&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Packet End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection Sequence ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the period of time marked blue in the image below once it detects that the electron beam of a CRT is in view of the light gun&#039;s lens. Once the Dreamcast brings SDCKA back HIGH, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun. No end sequence is sent after this is completed.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection is the time it takes to scan the entire screen. For a 60 Hz screen (59.94 Hz actual) displaying 480i, this is about 33.36 milliseconds. Assuming a composite signal actually scans 525 lines, the time window for each pixel on a 60 Hz screen is about 97 nanoseconds.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|2..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the word format section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the word format section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3297</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3297"/>
		<updated>2024-01-23T02:15:25Z</updated>

		<summary type="html">&lt;p&gt;Tails86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Packet End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection Sequence ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the period of time marked blue in the image below once it detects that the electron beam of a CRT is in view of the light gun&#039;s lens. SDCKB is then held LOW by the light gun until after Dreamcast brings SDCKA back HIGH. At that point, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun. No end sequence is sent after this is completed.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection is the time it takes to scan the entire screen. For a 60 Hz screen (59.94 Hz actual) displaying 480i, this is about 33.36 milliseconds. Assuming a composite signal actually scans 525 lines, the time window for each pixel on a 60 Hz screen is about 97 nanoseconds.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|2..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the word format section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the word format section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Talk:VMU_peripheral&amp;diff=3296</id>
		<title>Talk:VMU peripheral</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Talk:VMU_peripheral&amp;diff=3296"/>
		<updated>2024-01-23T02:04:32Z</updated>

		<summary type="html">&lt;p&gt;Tails86: I typed the wrong frequency&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I played around with the VMU buzzer control through the maple bus and came to the conclusion that it is probably referencing a clock frequency that is too high in this mode (seems like 1 MHz). All I can play are high pitched tones. I also can&#039;t remember off the top of my head any games which used this feature.&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Talk:VMU_peripheral&amp;diff=3295</id>
		<title>Talk:VMU peripheral</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Talk:VMU_peripheral&amp;diff=3295"/>
		<updated>2024-01-22T03:40:04Z</updated>

		<summary type="html">&lt;p&gt;Tails86: Created page with &amp;quot;I played around with the VMU buzzer control through the maple bus and came to the conclusion that it is probably referencing a clock frequency that is too high in this mode (seems like 2732 Hz). All I can play are high pitched tones. I also can&amp;#039;t remember off the top of my head any games which used this feature.&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I played around with the VMU buzzer control through the maple bus and came to the conclusion that it is probably referencing a clock frequency that is too high in this mode (seems like 2732 Hz). All I can play are high pitched tones. I also can&#039;t remember off the top of my head any games which used this feature.&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=User_talk:Tails86&amp;diff=3294</id>
		<title>User talk:Tails86</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=User_talk:Tails86&amp;diff=3294"/>
		<updated>2024-01-21T22:36:25Z</updated>

		<summary type="html">&lt;p&gt;Tails86: Blanked the page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=User_talk:Tails86&amp;diff=3293</id>
		<title>User talk:Tails86</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=User_talk:Tails86&amp;diff=3293"/>
		<updated>2024-01-21T22:35:52Z</updated>

		<summary type="html">&lt;p&gt;Tails86: Created page with &amp;quot;This image is incorrect - there should be no end sequence&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This image is incorrect - there should be no end sequence&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3292</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3292"/>
		<updated>2024-01-21T22:33:43Z</updated>

		<summary type="html">&lt;p&gt;Tails86: I was mistaken - no end sequence is sent on Light Gun CRT Beam Detection&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the period of time marked blue in the image below once it detects that the electron beam of a CRT is in view of the light gun&#039;s lens. SDCKB is then held LOW by the light gun until after Dreamcast brings SDCKA back HIGH. At that point, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun. No end sequence is sent after this is completed.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection is the time it takes to scan the entire screen. For a 60 Hz screen (59.94 Hz actual) displaying 480i, this is about 33.36 milliseconds. Assuming a composite signal actually scans 525 lines, the time window for each pixel on a 60 Hz screen is about 97 nanoseconds.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|2..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the word format section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the word format section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=File:Light_Gun_CRT_Beam_Detect.png&amp;diff=3291</id>
		<title>File:Light Gun CRT Beam Detect.png</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=File:Light_Gun_CRT_Beam_Detect.png&amp;diff=3291"/>
		<updated>2024-01-21T22:32:23Z</updated>

		<summary type="html">&lt;p&gt;Tails86: Tails86 uploaded a new version of File:Light Gun CRT Beam Detect.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Shows the bit sequence for light gun positioning on a CRT screen&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3290</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3290"/>
		<updated>2024-01-21T21:16:46Z</updated>

		<summary type="html">&lt;p&gt;Tails86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the period of time marked blue in the image below once it detects that the electron beam of a CRT is in view of the light gun&#039;s lens. SDCKB is then held LOW by the light gun until after Dreamcast brings SDCKA back HIGH. At that point, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun. A normal end sequence is then sent by the Dreamcast.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection is the time it takes to scan the entire screen. For a 60 Hz screen (59.94 Hz actual) displaying 480i, this is about 33.36 milliseconds. Assuming a composite signal actually scans 525 lines, the time window for each pixel on a 60 Hz screen is about 97 nanoseconds.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|2..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the word format section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the word format section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3289</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3289"/>
		<updated>2024-01-21T19:18:55Z</updated>

		<summary type="html">&lt;p&gt;Tails86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the period of time marked blue in the image below once it detects that the electron beam of a CRT is in view of the light gun&#039;s lens. SDCKB is then held LOW by the light gun until after Dreamcast brings SDCKA back HIGH. At that point, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun. A normal end sequence is then sent by the Dreamcast.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection lasts for a little longer than the time it takes to scan the entire screen. For a 60 Hz screen displaying 480i, this is a little longer than 33.3 milliseconds.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|2..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the word format section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the word format section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3288</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3288"/>
		<updated>2024-01-21T19:11:02Z</updated>

		<summary type="html">&lt;p&gt;Tails86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the period of time marked blue in the image below once it detects that the electron beam of a CRT is in view of the light gun&#039;s lens. SDCKB is then held LOW by the light gun until after Dreamcast brings SDCKA back HIGH. At that point, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun. A normal end sequence is then sent by the Dreamcast.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection lasts for a little longer than the time it takes to scan the entire screen. For 60 Hz screen displaying 480i, this is a little longer than 33.3 milliseconds.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|2..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the word format section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the word format section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3287</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3287"/>
		<updated>2024-01-21T19:09:25Z</updated>

		<summary type="html">&lt;p&gt;Tails86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the within the period of time marked blue in the below image once it detects that the electron beam of a CRT is in view of the lens of the light gun. SDCKB is then held LOW by the light gun until after Dreamcast brings SDCKA back HIGH. At that point, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun. A normal end sequence is then sent by the Dreamcast.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection lasts for a little longer than the time it takes to scan the entire screen. For 60 Hz screen displaying 480i, this is a little longer than 33.3 milliseconds.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|2..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the word format section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the word format section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=File:Light_Gun_CRT_Beam_Detect.png&amp;diff=3286</id>
		<title>File:Light Gun CRT Beam Detect.png</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=File:Light_Gun_CRT_Beam_Detect.png&amp;diff=3286"/>
		<updated>2024-01-21T19:08:19Z</updated>

		<summary type="html">&lt;p&gt;Tails86: Tails86 uploaded a new version of File:Light Gun CRT Beam Detect.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Shows the bit sequence for light gun positioning on a CRT screen&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3285</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3285"/>
		<updated>2024-01-21T18:51:34Z</updated>

		<summary type="html">&lt;p&gt;Tails86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB LOW within the within the period of time marked blue in the below image once it detects that the electron beam of a CRT is in view of the lens of the light gun. SDCKB is then held LOW by the light gun until after Dreamcast brings SDCKA back HIGH. At that point, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection lasts for a little longer than the time it takes to scan the entire screen. For 60 Hz screen displaying 480i, this is a little longer than 33.3 milliseconds.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|2..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the word format section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the word format section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3284</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3284"/>
		<updated>2024-01-21T18:31:51Z</updated>

		<summary type="html">&lt;p&gt;Tails86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB low within the within the period of time marked blue in the below image once it detects that the electron beam of a CRT is in view of the lens of the light gun. SDCKB is then held low by the light gun until after Dreamcast brings SDCKA back high. At that point, SDCKB must be brought back HIGH, and the control of SDCKB must be let go by the light gun.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection lasts for a little longer than the time it takes to scan the entire screen. For 60 Hz screen displaying 480i, this is a little longer than 33.3 milliseconds.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|2..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the word format section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the word format section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3283</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3283"/>
		<updated>2024-01-21T18:28:04Z</updated>

		<summary type="html">&lt;p&gt;Tails86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for position detection of the electron beam for a specific pixel on a CRT monitor which the light gun is currently aiming at. &lt;br /&gt;
&lt;br /&gt;
Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB low within the within the period of time marked blue in the below image once it detects that the electron beam of a CRT is in view of the lens of the light gun. SDCKB is then held low by the light gun until after Dreamcast brings SDCKA back high. At that point, SDCKB must be brought back HIGH and the control of SDCKB must be let go by the light gun.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection lasts for a little longer than the time it takes to scan the entire screen. For 60 Hz screen displaying 480i, this is a little longer than 33.3 milliseconds.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|2..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the word format section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the word format section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3282</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3282"/>
		<updated>2024-01-21T18:25:03Z</updated>

		<summary type="html">&lt;p&gt;Tails86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for light gun triggering. &lt;br /&gt;
&lt;br /&gt;
Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB low within the within the period of time marked blue in the below image once it detects that the electron beam of a CRT is in view of the lens of the light gun. SDCKB is then held low by the light gun until after Dreamcast brings SDCKA back high. At that point, SDCKB must be brought back HIGH and the control of SDCKB must be let go by the light gun.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection lasts for a little longer than the time it takes to scan the entire screen. For 60 Hz screen displaying 480i, this is a little longer than 33.3 milliseconds.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|Light Gun CRT Beam Detect]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|2..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the word format section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the word format section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3281</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3281"/>
		<updated>2024-01-21T18:24:31Z</updated>

		<summary type="html">&lt;p&gt;Tails86: Better describe light gun timing&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== Light Gun CRT Beam Detection ===&lt;br /&gt;
&lt;br /&gt;
The start sequence for light gun CRT beam detection looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for light gun triggering. &lt;br /&gt;
&lt;br /&gt;
Dreamcast initiates this sequence to a light gun once the Dreamcast detects that the trigger (A button) has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB low within the within the period of time marked blue in the below image once it detects that the electron beam of a CRT is in view of the lens of the light gun. SDCKB is then held low by the light gun until after Dreamcast brings SDCKA back high. At that point, SDCKB must be brought back HIGH and the control of SDCKB must be let go by the light gun.&lt;br /&gt;
&lt;br /&gt;
The duration of time given for beam detection lasts for a little longer than the time it takes to scan the entire screen. For 60 Hz screen displaying 480i, this is a little longer than 33.3 milliseconds.&lt;br /&gt;
&lt;br /&gt;
[[File:Light Gun CRT Beam Detect.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|2..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the word format section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the word format section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=File:Light_Gun_CRT_Beam_Detect.png&amp;diff=3280</id>
		<title>File:Light Gun CRT Beam Detect.png</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=File:Light_Gun_CRT_Beam_Detect.png&amp;diff=3280"/>
		<updated>2024-01-21T18:16:01Z</updated>

		<summary type="html">&lt;p&gt;Tails86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Shows the bit sequence for light gun positioning on a CRT screen&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3279</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3279"/>
		<updated>2024-01-21T03:17:04Z</updated>

		<summary type="html">&lt;p&gt;Tails86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== SDCKB Occupancy ===&lt;br /&gt;
&lt;br /&gt;
The SDCKB occupancy start sequence looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for light gun triggering. Dreamcast initiates this sequence to a light gun once Dreamcast detects that the trigger has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB low within the SDCKB Occupancy once it detects that the electron beam of a CRT is in view of the lens of the light gun. SDCKB is then held low until after Dreamcast brings SDCKA back high.&lt;br /&gt;
&lt;br /&gt;
The SDCKB occupancy lasts for a little longer than the time it takes to scan the entire screen. For 60 Hz screen displaying 480i, this is a little longer than 33.3 milliseconds.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus SDCKB Occupancy.png|Maple Bus SDCKB Occupancy]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|2..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the word format section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the word format section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
	<entry>
		<id>https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3278</id>
		<title>Maple bus</title>
		<link rel="alternate" type="text/html" href="https://dreamcast.wiki/wiki/index.php?title=Maple_bus&amp;diff=3278"/>
		<updated>2024-01-21T03:11:04Z</updated>

		<summary type="html">&lt;p&gt;Tails86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Maple bus is the communications bus the Dreamcast uses to connect controllers and other related peripherals. It is a symmetrical serial protocol.&lt;br /&gt;
&lt;br /&gt;
== Hardware Overview ==&lt;br /&gt;
&lt;br /&gt;
[[File:Dreamcast Port.png|thumb|Dreamcast Port]]&lt;br /&gt;
&lt;br /&gt;
Four separate Maple Buses exist on a Dreamcast system - one for each player. Each Maple Bus consists of 2 signal/clock lines that are labeled SDCKA and SDCKB. Hardware on the Maple Bus consists of one host, zero or one main peripheral, and zero to five sub-peripherals. The only difference between a main peripheral and a sub-peripheral is that a main peripheral communicates to the host what sub-peripherals are attached during normal communication. The main peripheral is something like a Dreamcast controller, and the sub-peripherals are things like a VMU, jump pack, and microphone. The host and all connected peripheral devices communicate on the same 2-line Maple Bus.&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot;&amp;gt;&#039;&#039;[https://tech-en.netlify.app/articles/en540236/index.html] Geek Tech Report | Maple BUS in a nutshell or SEGA Dreamcast Peripherals how to make&#039;&#039;&amp;lt;/ref&amp;gt; Devices are powered with 5V from the host, and signals on the Maple Bus operate at 3.3V TTL.&amp;lt;ref name=&amp;quot;raphnet&amp;quot;&amp;gt;&#039;&#039;[https://www.raphnet.net/programmation/dreamcast_usb/index_en.php] Raphaël Assenat | Dreamcast controller to USB build log&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Electronics Block Diagram.png|frameless|500px|Maple Bus Electronics Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
* Both lines on the Bus are pulled HIGH through weak pullup resistors&lt;br /&gt;
* Only one connected component on the bus may communicate at a time&lt;br /&gt;
* During communication, a device should not drive both lines HIGH for very long to prevent a downstream device from thinking the bus is free&lt;br /&gt;
* Before a component starts communicating, it must verify the bus is neutral for a sufficient amount of time&lt;br /&gt;
* A peripheral device will only communicate 1 packet of data in response to a request from the host&amp;lt;ref name=&amp;quot;MBNutshell&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Hardware Communication.png|frameless|600px|Maple Bus Hardware Communication]]&lt;br /&gt;
&lt;br /&gt;
=== Sense ===&lt;br /&gt;
&lt;br /&gt;
The Dreamcast does not rely on any sense line as some projects implement.&amp;lt;ref name=&amp;quot;raphnet&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[http://mc.pp.se/dc/controller.html] Dreamcast Programming - Controllers&#039;&#039;&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;&#039;&#039;[https://hackaday.com/2021/03/16/dreamcast-controller-adapter-even-works-with-mice/] Lewin Day | DREAMCAST CONTROLLER ADAPTER EVEN WORKS WITH MICE&#039;&#039;&amp;lt;/ref&amp;gt; Both ground wires from the controller are tied to ground at the controller port module on the Dreamcast. To detect the presence of a device, Dreamcast instead sends a device info request every 16 ms until a main peripheral responds on the bus.&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Signals ==&lt;br /&gt;
&lt;br /&gt;
There is no handshaking done to determine how fast each component may transmit on the Maple Bus. Transmission speeds are internally pre-determined by each hardware component. Generally speaking, for all signals, the minimum amount of time between an edge (transition between logic levels) of one line and an edge of the other is about 125 nanoseconds. The minimum amount of time between edges on the same line is about 225 nanoseconds.&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot;&amp;gt;&#039;&#039;[https://github.com/OrangeFox86/DreamcastControllerUsbPico/tree/main/measurements] Tails86 | DreamcastControllerUsbPico Maple Bus Measurements&#039;&#039;&amp;lt;/ref&amp;gt; There is no maximum time limit as long as both lines aren&#039;t held HIGH during active transmission for any extended amount of time. These guidelines may be applied for any sequence below.&lt;br /&gt;
&lt;br /&gt;
=== Data Packet Start Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Start Sequence.png|thumb|Maple Bus Start Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every data packet begins with a start sequence. &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought LOW&lt;br /&gt;
# SDCKB is toggled 4 times&lt;br /&gt;
# SDCKA is then brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplewire.html] Marcus Comstedt | Dreamcast Programming - Maple Bus Wire Protocol&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== End Sequence ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus End Sequence.png|thumb|Maple Bus End Sequence]]&lt;br /&gt;
&lt;br /&gt;
Every packet is completed with an end sequence to commit the data to the target component.  &lt;br /&gt;
&lt;br /&gt;
# SDCKA is brought HIGH&lt;br /&gt;
# SDCKB is toggled HIGH then LOW&lt;br /&gt;
# SDCKA is toggled 2 times&lt;br /&gt;
# SDCKB is brought back HIGH to complete the sequence&amp;lt;ref name=&amp;quot;MBWireProtocol&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Bit Sequences ===&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Clocking Phases.png|thumb|Maple Bus Clocking Phases]]&lt;br /&gt;
&lt;br /&gt;
For each bit, one line of the maple bus acts as a clock while the other is the data to be sampled. A data bit is clocked when the designated clock line transitions from HIGH to LOW. The two lines trade their function after each bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;B&#039;&#039;&#039; acts as data for the first bit. Line &#039;&#039;&#039;B&#039;&#039;&#039; acts as clock and &#039;&#039;&#039;A&#039;&#039;&#039; acts as data for the next bit. Line &#039;&#039;&#039;A&#039;&#039;&#039; acts as clock again for the bit after that. The pattern repeats until all data is transmitted.&lt;br /&gt;
&lt;br /&gt;
Each bit transmission sequence can be broken down into 3 phases&amp;lt;ref&amp;gt;&#039;&#039;[https://archive.org/details/MaplePatent/mode/1up]Maple Bus Patent&#039;&#039;&amp;lt;/ref&amp;gt;:&lt;br /&gt;
* Phase 1 - Clock Conditioning: Bring clock HIGH and keep data at the state it was previously&lt;br /&gt;
* Phase 2 - Data Conditioning: Transition the data bit to the target value&lt;br /&gt;
* Phase 3 - Clocking: Bring clock LOW in order to have the data bit sampled&lt;br /&gt;
&lt;br /&gt;
There are a total of 6 types of state transitions, depending on what the previous phase was and the target bit value. A depiction of state transitions can be seen in the image below.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Data.png|Maple Bus Data]]&lt;br /&gt;
&lt;br /&gt;
Notice that each line, A &amp;amp; B transitions states in a staggard pattern i.e., only one line may change its logic level within each phase. Because of the staggard pattern, the minimum time between an edge of one line and an edge of the other is 1 phase length, and the minimum time between edges on the same line is the sum of the time of 2 phases. The total bit transmission time is of course the sum of the time of all 3 phases. &lt;br /&gt;
&lt;br /&gt;
* The Dreamcast host transmits each phase at about 160 nanoseconds&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to be about 2 mbps raw data transfer speed&lt;br /&gt;
* Dreamcast controllers and other peripheral devices usually transmit a little slower at about 250 nanoseconds per phase and sometimes with about 110 to 130 microsecond delays between each 4-word chunk after the first frame word&amp;lt;ref name=&amp;quot;MBMeasurements&amp;quot; /&amp;gt;&lt;br /&gt;
** This works out to between about 0.5 and 1.3 mbps raw data transfer speed&lt;br /&gt;
&lt;br /&gt;
=== SDCKB Occupancy ===&lt;br /&gt;
&lt;br /&gt;
The SDCKB occupancy start sequence looks similar to a data packet start sequence, but 8 pulses on the SDCKB line signify the start of this mode. This mode is used to gain precise timing for light gun triggering. Dreamcast initiates this sequence to a light gun once Dreamcast detects that the trigger has been pressed through normal data packet sequences. The light gun is expected to bring SDCKB low within the SDCKB Occupancy once it detects that the electron beam of a CRT is in view of the lens of the light gun. SDCKB is then held low until after Dreamcast brings SDCKA back high.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus SDCKB Occupancy.png|Maple Bus SDCKB Occupancy]]&lt;br /&gt;
&lt;br /&gt;
=== Reset Sequence ===&lt;br /&gt;
&lt;br /&gt;
A reset sequence may be sent from the host in order to attempt to reset all devices on the bus. It is similar to a start sequence, but there are 14 pulses on SDCKB.&lt;br /&gt;
&lt;br /&gt;
[[File:Maple Bus Reset Sequence.png|Maple Bus Reset Sequence]]&lt;br /&gt;
&lt;br /&gt;
== Maple Bus Packet ==&lt;br /&gt;
&lt;br /&gt;
This section contains information about the packet structure inherent to the Maple Bus. Any data transmission follows this packet structure.&lt;br /&gt;
&lt;br /&gt;
=== Word Format ===&lt;br /&gt;
&lt;br /&gt;
Each word is 32 bits in length, transmitted in little-endian byte order. The most significant bit of each byte transmits first. This means that the most significant bit of the least significant byte of each word transmits first. All tables in this wiki list bytes in transmission order with the least significant bit (LSB) as the first byte.&lt;br /&gt;
&lt;br /&gt;
When ASCII text or a byte stream is transmitted, the most significant byte is the first character of the 4 character sequence in each word. This means that the byte order of each word needs to be flipped before parsing the payload as a character or byte array. The size of an ASCII payload section is pre-determined based on the command. No NULL termination byte is supplied at the end of the string, and spaces (0x20) are used to pad out remaining characters at the end of the string.&lt;br /&gt;
&lt;br /&gt;
=== Packet Data Format ===&lt;br /&gt;
&lt;br /&gt;
A packet consists of the following data.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Frame_Word|Frame]]:&#039;&#039;&#039; 1 32-Bit Word&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#Payload|Payload]]:&#039;&#039;&#039; 0 to 255 32-Bit Words&lt;br /&gt;
* &#039;&#039;&#039;[[Maple_bus#CRC|CRC]]:&#039;&#039;&#039; 1 Byte&lt;br /&gt;
==== Frame Word ====&lt;br /&gt;
&lt;br /&gt;
The following is how a frame word is broken down into its 4 parts&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;&amp;gt;&#039;&#039;[http://mc.pp.se/dc/maplebus.html] Marcus Comstedt | Dreamcast Programming - Maple Bus&#039;&#039;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Number of Words&amp;lt;br&amp;gt;in Payload&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Sender&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;Recipient&amp;lt;br&amp;gt;[[Maple_bus#Addressing|Address]]&amp;lt;/div&amp;gt; || &amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;[[Maple_bus#Commands|Command]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
&lt;br /&gt;
[[File:Frame Word.png|Frame Word Example]]&lt;br /&gt;
&lt;br /&gt;
===== Addressing =====&lt;br /&gt;
&lt;br /&gt;
The following addresses are used for all components on the bus.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Player Number !! Host !! Main Peripheral !! Sub-Peripheral 1 !! Sub-Peripheral 2 !! Sub-Peripheral 3 !! Sub-Peripheral 4 !! Sub-Peripheral 5&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x00 || 0x20* || 0x01 || 0x02 || 0x04 || 0x08 || 0x10&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x40  || 0x60* || 0x41 || 0x42 || 0x44 || 0x48 || 0x50&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x80 || 0xA0* || 0x81 || 0x82 || 0x84 || 0x88 || 0x90&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0xC0 || 0xE0* || 0xC1 || 0xC2 || 0xC4 || 0xC8 || 0xD0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;When the main peripheral responds with its sender address, it also sets the bits corresponding to which sub-peripherals are attached. For example, if sub-peripherals 1 and 2 are attached to player 1&#039;s main peripheral, the main peripheral will set its sender address to 0x23. This informs the host what else is attached. The host should still set the recipient address to 0x20 when sending data to this peripheral though.&lt;br /&gt;
&lt;br /&gt;
In testing, there have been cases where a peripheral will respond with a sender address as if it is player 1. As such, the host should ignore whatever the upper 2 bits that the device uses as its sender address.&lt;br /&gt;
&lt;br /&gt;
===== Commands =====&lt;br /&gt;
&lt;br /&gt;
Below shows command values and their meanings.&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;DCDocs&amp;quot;&amp;gt;&#039;&#039;[https://github.com/Kochise/dreamcast-docs/tree/master/CONTROLR/DOCS] Dreamcast Documents&#039;&#039;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command Value !! Description !! Communication Direction !! Number of Payload Words !! Expected Response**&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Device Info Request* || Host-&amp;gt;Device || 0 || 0x05 &lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Extended Device Info Request || Host-&amp;gt;Device || 0 || 0x06 &lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Reset || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Shutdown || Host-&amp;gt;Device || 0 || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Device Info || Device-&amp;gt;Host || [[Maple_bus#Device_Info_Payload_Structure_.28cmd_0x05.29|28]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Extended Device Info || Device-&amp;gt;Host || [[Maple_bus#Extended_Device_Info_Payload_Structure_.28cmd_0x06.29|48]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || Acknowledge || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Data Transfer || Device-&amp;gt;Host || [[Maple_bus#Data_Transfer_Payload_Structure_.28cmd_0x08.29|2..255]] || - &lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Get Condition || Host-&amp;gt;Device || [[Maple_bus#Get_Condition_Payload_Structure_.28cmd_0x09.29|1]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || Get Memory Information || Host-&amp;gt;Device || [[Maple_bus#Get_Memory_Information_Payload_Structure_.28cmd_0x0A.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || Block Read || Host-&amp;gt;Device || [[Maple_bus#Block_Read_Payload_Structure_.28cmd_0x0B.29|2]] || 0x08 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Block Write || Host-&amp;gt;Device || [[Maple_bus#Block_Write_Payload_Structure_.28cmd_0x0C.29|3..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Get Last Error || Host-&amp;gt;Device || [[Maple_bus#Get_Last_Error_Payload_Structure_.28cmd_0x0D.29|2]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Set Condition || Host-&amp;gt;Device || [[Maple_bus#Set_Condition_Payload_Structure_.28cmd_0x0E.29|2..255]] || 0x07 &lt;br /&gt;
|-&lt;br /&gt;
| 0xF9 || AR Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFA || LCD Error || Device-&amp;gt;Host || 0 || -&lt;br /&gt;
|-&lt;br /&gt;
| 0xFB || File Error || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFC || Request Resend || ANY || 0 || Last Sent Command &lt;br /&gt;
|-&lt;br /&gt;
| 0xFD || Unknown Command || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|-&lt;br /&gt;
| 0xFE || [[Maple_bus#Function_Codes|Function code]] Not Supported || Device-&amp;gt;Host || 0 || - &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Most peripheral devices won&#039;t respond to any other command until device info is requested for the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;This is the expected response when device didn&#039;t experience an error&lt;br /&gt;
&lt;br /&gt;
==== Payload ====&lt;br /&gt;
&lt;br /&gt;
The structure of a payload is dependent on the command used in the frame word.&lt;br /&gt;
&lt;br /&gt;
===== Device Info Payload Structure (cmd 0x05) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption****&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the word format section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Extended Device Info Payload Structure (cmd 0x06) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1-3 !! Word 4 !! Words 5-11 !! Words 12-26 !! Word 27 !! Words 28-47&lt;br /&gt;
|-&lt;br /&gt;
| Supported [[Maple_bus#Function_Codes|function codes]] mask* || Function definitions for up to 3 devices** || Byte 3 (MSB): Region code &amp;lt;br&amp;gt; Byte 2: Connection direction code &amp;lt;br&amp;gt; Bytes 1 and 0: first two characters of description ASCII string*** || The rest of the description ASCII string*** || Producer information ASCII string*** || 2 most significant bytes: standby current consumption &amp;lt;br&amp;gt; 2 least significant bytes: maximum current consumption**** || Version information and/or capabilities ASCII string***&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;The supported function codes mask in device info responses will contain the bitmask for 1 or more devices ex: a VMU will have a mask of 0x0000000E for Timer, Screen, and Storage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;The first word in this set is meant for the most significant bit that is set to 1 in the function codes word&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;Refer to the word format section about how to parse ASCII strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;****&amp;lt;/nowiki&amp;gt;Current values in (x / 10) mA, each two byte value is transmitted as big-endian&lt;br /&gt;
&lt;br /&gt;
===== Data Transfer Payload Structure (cmd 0x08) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Condition Payload Structure (cmd 0x09) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 &lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Memory Information Payload Structure (cmd 0x0A) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Only the partition number should be set in the location word. Set all other bytes in the location word to 0.&lt;br /&gt;
&lt;br /&gt;
===== Block Read Payload Structure (cmd 0x0B) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Block Write Payload Structure (cmd 0x0C) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1 !! Words 2..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]] || Data - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Get Last Error Payload Structure (cmd 0x0D) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Word 1&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || [[Maple_bus#Location_Word|Location word]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Set Condition Payload Structure (cmd 0x0E) =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Word 0 !! Words 1..255&lt;br /&gt;
|-&lt;br /&gt;
| [[Maple_bus#Function_Codes|Function code]] || Condition - device dependent structure&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Common Payload Word Types =====&lt;br /&gt;
&lt;br /&gt;
The following word types are used in some of the above payload structures.&lt;br /&gt;
&lt;br /&gt;
====== Function Codes ======&lt;br /&gt;
&lt;br /&gt;
The below are function codes which are used to address functionality in some payloads&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code / Mask !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000001 || Controller&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000002 || Storage&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000004 || Screen&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000008 || Timer&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Audio Input&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000020 || AR Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000040 || Keyboard&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000080 || Gun&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000100 || Vibration&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000200 || Mouse&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====== Location Word ======&lt;br /&gt;
&lt;br /&gt;
Below defines a location word which is used to address blocks of memory in some peripherals&amp;lt;ref name=&amp;quot;DPMapleBus&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)&lt;br /&gt;
|-&lt;br /&gt;
| Block LSB || Block MSB || Phase || Partition&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Block&#039;&#039;&#039;: Memory block number index&lt;br /&gt;
* &#039;&#039;&#039;Phase&#039;&#039;&#039;: Sequence number (starts at 0 and counts up)&lt;br /&gt;
* &#039;&#039;&#039;Partition&#039;&#039;&#039;: Partition number (normally 0)&lt;br /&gt;
&lt;br /&gt;
==== CRC ====&lt;br /&gt;
&lt;br /&gt;
CRC byte transmits last, just before the end sequence is transmitted. It is the value after starting with 0 and applying XOR against each byte in the packet.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tails86</name></author>
	</entry>
</feed>