KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
maple.h File Reference

Maple Bus driver interface. More...

#include <sys/cdefs.h>
#include <arch/types.h>
#include <sys/queue.h>

Go to the source code of this file.

Data Structures

struct  maple_frame_t
 Maple frame to be queued for transport. More...
 
struct  maple_devinfo_t
 Maple device info structure. More...
 
struct  maple_response_t
 Maple response frame structure. More...
 
struct  maple_device_t
 One maple device. More...
 
struct  maple_port_t
 Internal representation of a Maple port. More...
 
struct  maple_driver_t
 A maple device driver. More...
 
struct  maple_state_t
 Maple state structure. More...
 

Macros

#define MAPLE_DMA_DEBUG   0
 Enable Maple DMA debugging.
 
#define MAPLE_IRQ_DEBUG   0
 Enable Maple IRQ debugging.
 
#define MAPLE_BASE   0xa05f6c00
 Maple register base.
 
#define MAPLE_DMAADDR   (MAPLE_BASE+0x04)
 DMA address register.
 
#define MAPLE_RESET2   (MAPLE_BASE+0x10)
 Reset register #2.
 
#define MAPLE_ENABLE   (MAPLE_BASE+0x14)
 Enable register.
 
#define MAPLE_STATE   (MAPLE_BASE+0x18)
 Status register.
 
#define MAPLE_SPEED   (MAPLE_BASE+0x80)
 Speed register.
 
#define MAPLE_RESET1   (MAPLE_BASE+0x8c)
 Reset register #1.
 
#define MAPLE_RESET2_MAGIC   0
 2nd reset value
 
#define MAPLE_ENABLE_ENABLED   1
 Enable Maple.
 
#define MAPLE_ENABLE_DISABLED   0
 Disable Maple.
 
#define MAPLE_STATE_IDLE   0
 Idle state.
 
#define MAPLE_STATE_DMA   1
 DMA in-progress.
 
#define MAPLE_SPEED_2MBPS   0
 2Mbps bus speed
 
#define MAPLE_SPEED_TIMEOUT(n)
 Bus timeout macro.
 
#define MAPLE_RESET1_MAGIC   0x6155404f
 First reset value.
 
#define MAPLE_RESPONSE_FILEERR   -5
 File error.
 
#define MAPLE_RESPONSE_AGAIN   -4
 Try again later.
 
#define MAPLE_RESPONSE_BADCMD   -3
 Bad command sent.
 
#define MAPLE_RESPONSE_BADFUNC   -2
 Bad function code.
 
#define MAPLE_RESPONSE_NONE   -1
 No response.
 
#define MAPLE_COMMAND_DEVINFO   1
 Device info request.
 
#define MAPLE_COMMAND_ALLINFO   2
 All info request.
 
#define MAPLE_COMMAND_RESET   3
 Reset device request.
 
#define MAPLE_COMMAND_KILL   4
 Kill device request.
 
#define MAPLE_RESPONSE_DEVINFO   5
 Device info response.
 
#define MAPLE_RESPONSE_ALLINFO   6
 All info response.
 
#define MAPLE_RESPONSE_OK   7
 Command completed ok.
 
#define MAPLE_RESPONSE_DATATRF   8
 Data transfer.
 
#define MAPLE_COMMAND_GETCOND   9
 Get condition request.
 
#define MAPLE_COMMAND_GETMINFO   10
 Get memory information.
 
#define MAPLE_COMMAND_BREAD   11
 Block read.
 
#define MAPLE_COMMAND_BWRITE   12
 Block write.
 
#define MAPLE_COMMAND_BSYNC   13
 Block sync.
 
#define MAPLE_COMMAND_SETCOND   14
 Set condition request.
 
#define MAPLE_COMMAND_MICCONTROL   15
 Microphone control.
 
#define MAPLE_COMMAND_CAMCONTROL   17
 Camera control.
 
#define MAPLE_FUNC_PURUPURU   0x00010000
 Jump pack.
 
#define MAPLE_FUNC_MOUSE   0x00020000
 Mouse.
 
#define MAPLE_FUNC_CAMERA   0x00080000
 Camera (Dreameye)
 
#define MAPLE_FUNC_CONTROLLER   0x01000000
 Controller.
 
#define MAPLE_FUNC_MEMCARD   0x02000000
 Memory card.
 
#define MAPLE_FUNC_LCD   0x04000000
 LCD screen.
 
#define MAPLE_FUNC_CLOCK   0x08000000
 Clock.
 
#define MAPLE_FUNC_MICROPHONE   0x10000000
 Microphone.
 
#define MAPLE_FUNC_ARGUN   0x20000000
 AR gun?
 
#define MAPLE_FUNC_KEYBOARD   0x40000000
 Keyboard.
 
#define MAPLE_FUNC_LIGHTGUN   0x80000000
 Lightgun.
 
#define MAPLE_FRAME_VACANT   0
 Ready to be used.
 
#define MAPLE_FRAME_UNSENT   1
 Ready to be sent.
 
#define MAPLE_FRAME_SENT   2
 Frame has been sent, but no response yet.
 
#define MAPLE_FRAME_RESPONDED   3
 Frame has a response.
 
#define MAPLE_PORT_COUNT   4
 Number of ports on the bus.
 
#define MAPLE_UNIT_COUNT   6
 Max number of units per port.
 
#define MAPLE_DMA_SIZE   16384
 Maple DMA buffer size.
 
#define maple_read(A)
 Maple memory read macro.
 
#define maple_write(A, V)
 Maple memory write macro.
 
#define MAPLE_EOK   0
 No error.
 
#define MAPLE_EFAIL   -1
 Command failed.
 
#define MAPLE_EAGAIN   -2
 Try again later.
 
#define MAPLE_EINVALID   -3
 Invalid command.
 
#define MAPLE_ENOTSUPP   -4
 Command not supported by device.
 
#define MAPLE_ETIMEOUT   -5
 Command timed out.
 
#define MAPLE_FOREACH_BEGIN(TYPE, VARTYPE, VAR)
 Begin a foreach loop over Maple devices.
 
#define MAPLE_FOREACH_END()
 End a foreach loop over Maple devices.
 

Typedefs

typedef void(* maple_attach_callback_t) (maple_device_t *dev)
 Maple attach callback type.
 
typedef void(* maple_detach_callback_t) (maple_device_t *dev)
 Maple detach callback type.
 

Functions

void maple_bus_enable (void)
 Enable the Maple bus.
 
void maple_bus_disable (void)
 Disable the Maple bus.
 
void maple_dma_start (void)
 Start a Maple DMA.
 
void maple_dma_stop (void)
 Stop a Maple DMA.
 
int maple_dma_in_progress (void)
 Is a Maple DMA in progress?
 
void maple_dma_addr (void *ptr)
 Set the Maple DMA address.
 
uint8 maple_addr (int port, int unit)
 Return a "maple address" for a port, unit pair.
 
void maple_raddr (uint8 addr, int *port, int *unit)
 Decompose a "maple address" into a port, unit pair.
 
const char * maple_pcaps (uint32 functions)
 Return a string with the capabilities of a given function code.
 
const char * maple_perror (int response)
 Return a string representing the maple response code.
 
int maple_dev_valid (int p, int u)
 Determine if a given device is valid.
 
int maple_gun_enable (int port)
 Enable light gun mode for this frame.
 
void maple_gun_disable (void)
 Disable light gun mode.
 
void maple_gun_read_pos (int *x, int *y)
 Read the light gun position values.
 
void maple_queue_flush (void)
 Send all queued frames.
 
int maple_queue_frame (maple_frame_t *frame)
 Submit a frame for queueing.
 
int maple_queue_remove (maple_frame_t *frame)
 Remove a used frame from the queue.
 
void maple_frame_init (maple_frame_t *frame)
 Initialize a new frame to prepare it to be placed on the queue.
 
int maple_frame_lock (maple_frame_t *frame)
 Lock a frame so that someone else can't use it in the mean time.
 
void maple_frame_unlock (maple_frame_t *frame)
 Unlock a frame.
 
int maple_driver_reg (maple_driver_t *driver)
 Register a maple device driver.
 
int maple_driver_unreg (maple_driver_t *driver)
 Unregister a maple device driver.
 
int maple_driver_attach (maple_frame_t *det)
 Attach a maple device to a driver, if possible.
 
int maple_driver_detach (int p, int u)
 Detach an attached maple device.
 
int maple_driver_foreach (maple_driver_t *drv, int(*callback)(maple_device_t *))
 For each device which the given driver controls, call the callback.
 
void maple_attach_callback (uint32 functions, maple_attach_callback_t cb)
 Set an automatic maple attach callback.
 
void maple_detach_callback (uint32 functions, maple_detach_callback_t cb)
 Set an automatic maple detach callback.
 
void maple_vbl_irq_hnd (uint32 code, void *data)
 Called on every VBL (~60fps).
 
void maple_dma_irq_hnd (uint32 code, void *data)
 Called after a Maple DMA send / receive pair completes.
 
int maple_enum_count (void)
 Return the number of connected devices.
 
maple_device_tmaple_enum_dev (int p, int u)
 Get a raw device info struct for the given device.
 
maple_device_tmaple_enum_type (int n, uint32 func)
 Get the Nth device of the requested type (where N is zero-indexed).
 
maple_device_tmaple_enum_type_ex (int n, uint32 func, uint32 cap)
 Return the Nth device that is of the requested type and supports the list of capabilities given.
 
void * maple_dev_status (maple_device_t *dev)
 Get the status struct for the requested maple device.
 
void maple_init (void)
 Initialize Maple.
 
void maple_shutdown (void)
 Shutdown Maple.
 
void maple_wait_scan (void)
 Wait for the initial bus scan to complete.
 

Detailed Description

Maple Bus driver interface.

This file provides support for accessing the Maple bus on the Dreamcast. Maple is the bus that all of your controllers and memory cards and the like connect to, so this is one of those types of things that are quite important to know how to use.

Each peripheral device registers their driver within this system, and can be accessed through the functions here. Most of the drivers have their own functionality that is implemented in their header files, as well.

Author
Megan Potter
Lawrence Sebald
See also
dc/maple/controller.h
dc/maple/dreameye.h
dc/maple/keyboard.h
dc/maple/mouse.h
dc/maple/purupuru.h
dc/maple/sip.h
dc/maple/vmu.h

Macro Definition Documentation

◆ MAPLE_PORT_COUNT

#define MAPLE_PORT_COUNT   4

Number of ports on the bus.

◆ MAPLE_UNIT_COUNT

#define MAPLE_UNIT_COUNT   6

Max number of units per port.