# Maple bus, controllers and the VMU Sources: Comstedt *maplebus*, *controller*, *kbd*, *mouse*, *vms/index*, *vms/cpu*, *vms/fw*, *vms/flashmem*, *vms/fileheader* (tier 3); KOS `maple.h`, `maple/*.h`, `hardware/maple/` (tier 3); MAME's `maple_dc`, `dcctrl` and its separate `svmu` driver (Sanyo LC8670 core, BSD-3-Clause by its header) as closed boxes (tier 5). ## The bus (Comstedt *maplebus*) - Four ports (A-D). On each, one main peripheral (controller, keyboard, ...) with up to 5 sub-peripherals (memory cards, microphones, rumble packs). An address byte holds the port (two bits) and a unit bit-field. - Messages are **frames** of 32-bit words: a header (command or response code, recipient, sender, number of additional words; big-endian) and parameters. Positive codes are commands and success responses, negative ones errors. - Commands (Comstedt's table): 1 request device information, 2 request extended device information, 3 reset device, 4 shutdown device; responses 5 device information, 6 extended device information, 7 command acknowledge, 8 data transfer; then get condition (9), block read (11), block write (12) and the rest of the table, and negative error responses (among them "function code unsupported"). The full table is the board's to transcribe at milestone 6. - **Function codes** say which function of a multi-function device a command addresses (a VMU is a memory card, an LCD and a clock at once): controller $001, memory card $002, LCD $004, clock $008, microphone $010, AR gun $020, keyboard $040, light gun $080, rumble ("Puru-Puru pack") $100, mouse $200 (Comstedt's table; the field is big-endian on the wire, so KOS, reading the word little-endian, writes `MAPLE_FUNC_CONTROLLER` as 01000000h and `MAPLE_FUNC_MEMCARD` as 02000000h). - Device information: the supported functions (OR of codes), up to three function data words, region, connection direction, product name, licence string, standby and maximum power. ## The console side (KOS `maple.h`; Comstedt *maplebus*) One DMA channel: software builds a list of transfer descriptors and frames in system RAM (each descriptor: port, length, last-transfer bit, the receive buffer address), sets the DMA address register, and sets ENA; Holly sends each frame, waits for the response up to the timeout, writes it to the receive buffer, and raises event 000Ch when the list is done. Registers at 005F6C00: DMA address, trigger select, enable, status, speed (2 Mbit/s default; 1, 4, 8 settable) with a timeout field, a DMA protection key (61550000h in bits 31-16). The boot ROM and games poll pads once a frame, usually triggered by V-blank (a Holly setting; KOS names the "trigger select"). ## The board's model Frame level: when Maple DMA starts, the board walks the descriptor list, hands each frame to the device model on that port, and writes the device's response frame into RAM after a time computed from the frame's length at the bus speed (the 2 Mbit/s wire time: HYPOTHESIS that responses arrive at wire speed plus a device delay; U22). Devices: the standard controller (digital buttons, two analogue triggers, analogue stick: Comstedt *controller*), the VMU (memory card + LCD + clock), the rumble pack, keyboard, mouse, later the light gun (which needs the display's beam position: a channel to the video domain). ## The VMU Comstedt *vms/index* and *vms/cpu*: "A Sanyo LC86K87 8-bit cpu", "a customized Sanyo microcontroller which is code compatible with the LC86000 series", 128 KB of flash (the first half doubles as the ROM space for game code), 512 bytes of RAM split into general purpose RAM and the special function registers, a 48 x 32 monochrome LCD, buttons, a buzzer, a clock (Comstedt *vms/index*: "48 by 32 pixel LCD display"). MAME's VMU driver calls the CPU a "Sanyo LC8670 @ 32.76 kHz" (C3 in the brief: two names, likely one family; whether the CPU also runs from a faster oscillator than the 32.768 kHz clock is U23). Two models, by need: 1. **Functional VMU (milestone 7)**: a 128 KB memory-card store with the VMS file system (Comstedt *vms/flashmem*, *vms/fileheader*), the LCD as a 48 x 32 bitmap written by block writes, the clock. Enough for every game's saves and LCD pictures. This is what the Dreamcast sees: it only ever talks to the VMU through Maple frames, never to its CPU. 2. **LLE VMU (optional, later)**: a new CPU core for the LC86K87 family (a CPU, so its own repository by the chip rule: `lc86k87-python`, open decision 6), running the VMU's own firmware (identified by SHA-1 in census.md: MAME's `svmu` set has eight firmware versions) for VMU games (mini-games downloaded to the VMU and played on it). Its instruction set is described by Comstedt *vms/cpu*; Sanyo's LC86 data books would be tier 2 if found. MAME's `lc8670` core is a detector (BSD-3-Clause by its header; closed by this batch's brief).