VMU peripheral: Difference between revisions

From dreamcast.wiki
Jump to navigation Jump to search
 
(7 intermediate revisions by the same user not shown)
Line 3: Line 3:
'''NOTE:''' Some information here is misleading and/or incomplete
'''NOTE:''' Some information here is misleading and/or incomplete


=== Screen ===
== Storage ==
 
The "block write" command (0x0C) with screen function code and 48 data words is used to write monochrome images to the screen. 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. 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.
 
[[File:Dreamcast Screen Words.png|Dreamcast Screen Words]]
 
=== Storage ===


The "block read" and "block write" commands (0x0B and 0x0C) with storage function code are used to read and write blocks of memory in the storage peripheral.  
The "block read" and "block write" commands (0x0B and 0x0C) with storage function code are used to read and write blocks of memory in the storage peripheral.  
Line 15: Line 9:
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 are not practically usable by most games due to memory access APIs.<ref>''[https://www.dreamcast-talk.com/forum/viewtopic.php?f=5&t=15562&p=171565] TapamN | 400 block VMU on emulator''</ref>
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 are not practically usable by most games due to memory access APIs.<ref>''[https://www.dreamcast-talk.com/forum/viewtopic.php?f=5&t=15562&p=171565] TapamN | 400 block VMU on emulator''</ref>


==== Function Definition ====
=== Function Definition ===
The function definition may be found in the peripheral'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.
The function definition may be found in the peripheral'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.
{| class="wikitable"
{| class="wikitable"
Line 21: Line 15:
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)
! Byte 0 (LSB) !! Byte 1 !! Byte 2 !! Byte 3 (MSB)
|-
|-
| bit 7: removable (1: true)<br>bit 6: CRC (1: needed)<br>bits 0-5: unused (0) || bits 4-7: number of write accesses per block<br>bits 0-3: number of read accesses per block || number of bytes per block<br>(x + 1)*32 bytes || number of partitions
| bit 7: removable (1: true)<br>bit 6: CRC (1: needed)<br>bits 0-5: unused (0) || bits 4-7: number of write accesses per block<br>bits 0-3: number of read accesses per block || number of bytes per block<br>(x + 1)*32 bytes || number of partitions (x + 1)
|}
|}


==== Block Read ====
=== Get Media Info ===
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.
 
{| class="wikitable"
|-
! Word 0 !! Word 1 !! Word 2 !! Word 3 !! Word 4 !! Word 5 !! Word 6
|-
| [[Maple_bus#Function_Codes|Function code]] <br> 0x00000002 || 2 most sig bytes: total size <br> 2 least sig bytes: the partition number of this media || 2 most sig bytes: block number of system area <br> 2 least sig bytes: block number of start of FAT area || 2 most sig bytes: number of FAT blocks <br> 2 least sig bytes: block number of file information || 2 most sig bytes: number of file info blocks <br> 2 least sig bytes: icon number || 2 most sig bytes: block number of save area <br> 2 least sig bytes: number of blocks in save area || execution file info
|}
 
=== Block Read ===
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.
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.


==== Block Write ====
=== Block Write ===
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.  
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.  
* If any block write fails, it is necessary to send "get last error" before starting over at the first write sequence.
* A VMU cannot handle successive block write packets faster than about 10 ms per write
* A VMU cannot handle successive block write packets faster than about 10 ms. If writing too fast, the response of "get last error" will be "file error".
** 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 "get last error" command would be necessary before starting over at the first sequence
** The Dreamcast does each read/write sequence on the same cadence as controller polling (about every 16 ms)
 
== Screen ==


=== Timer ===
The "block write" command (0x0C) with screen function code and 48 data words is used to write monochrome images to the screen. 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.
 
[[File:Dreamcast Screen Words.png|Dreamcast Screen Words]]
 
== Timer ==


The timer function allows the host to activate the buzzer on the VMU and get button conditions.
The timer function allows the host to activate the buzzer on the VMU and get button conditions.
== References ==
<references />

Latest revision as of 02:47, 11 March 2023

The VMU peripheral on the Maple Bus contains 3 functions: screen, storage, and timer.

NOTE: Some information here is misleading and/or incomplete

Storage

The "block read" and "block write" commands (0x0B and 0x0C) with storage function code are used to read and write blocks of memory in the storage peripheral.

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 are not practically usable by most games due to memory access APIs.[1]

Function Definition

The function definition may be found in the peripheral's device info packet. It is necessary to read this word to know how to access blocks of memory on the storage.

Byte 0 (LSB) Byte 1 Byte 2 Byte 3 (MSB)
bit 7: removable (1: true)
bit 6: CRC (1: needed)
bits 0-5: unused (0)
bits 4-7: number of write accesses per block
bits 0-3: number of read accesses per block
number of bytes per block
(x + 1)*32 bytes
number of partitions (x + 1)

Get Media Info

Execute a get memory information command to get information about the size and locations of some information within the media. On successful execution, a data transfer packet with the following payload will be returned.

Word 0 Word 1 Word 2 Word 3 Word 4 Word 5 Word 6
Function code
0x00000002
2 most sig bytes: total size
2 least sig bytes: the partition number of this media
2 most sig bytes: block number of system area
2 least sig bytes: block number of start of FAT area
2 most sig bytes: number of FAT blocks
2 least sig bytes: block number of file information
2 most sig bytes: number of file info blocks
2 least sig bytes: icon number
2 most sig bytes: block number of save area
2 least sig bytes: number of blocks in save area
execution file info

Block Read

Execute a sequence of 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 data transfer packet will be returned.

Block Write

Execute a sequence of 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 acknowledge packet will be returned. After the final write sequence, execute a get last error command with an incremented phase value to commit the block from RAM to storage.

  • A VMU cannot handle successive block write packets faster than about 10 ms per write
    • 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 "get last error" command would be necessary before starting over at the first sequence
    • The Dreamcast does each read/write sequence on the same cadence as controller polling (about every 16 ms)

Screen

The "block write" command (0x0C) with screen function code and 48 data words is used to write monochrome images to the screen. 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.

Dreamcast Screen Words

Timer

The timer function allows the host to activate the buzzer on the VMU and get button conditions.

References

  1. [1] TapamN | 400 block VMU on emulator