Libdream 0.7 includes Jordan DeLong's rewritten maple access code. This is a lot more modular and it is setup for future expansion with queueing multiple frames and DMA completion interrupts. For now it basically does the same as Marcus' old maple routines but with cleaner code.
In general using the maple bus consists of finding your peripheral (using DEVINFO queries), and storing this address; when you want to use the peripheral, you send it a condition query message and get a frame back describing the state of the peripheral. Most of the exported functions in maple.c won't be useful to mere mortals =) but that's a good thing since there are specific support modules for each of the major peripherals we have had access to.
The following functions are available:
Initialize the maple bus; if ``quiet'' is non-zero, then the bus scan will not produce any output.
Shut down all maple bus operations.
Create a maple address for the given port and unit.
Parameters omitted for topic brevity: int8 cmd, uint8 addr, uint8 datalen, void *data, maple_frame_t retframe. This is the main ``work horse'' of the maple system. ``cmd'' should be one of the maple command constants in maple.h; ``addr'' should be created with maple_create_addr (or one of the maple_*_addr functions below); ``datalen'' is the length of the extra data (beyond what's in the frame header), ``data'' is a pointer to extra data (if any) that goes after the frame header; and ``retframe'' is a maple_frame_t that you should pass in to be filled in with return data. Zero is returned on success, and -1 returned on error. For some examples of using docmd_block directly, please check one of the maple peripheral modules.
Rescans the maple bus. This will be neccessary if the user swaps out any controllers or memory cards. It also determines what is where and stores that info for later usage. If ``quiet'' is non-zero, it produces no output.
Pass a maple function code, and it returns the address of the first one that matches it.
These include controller, mouse, kb, lcd, and vmu currently. Each one searches the maple bus to find the first matching type of peripheral and returns an address.