Search
lxdream.org :: lxdream/src/maple/maple.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/maple/maple.h
changeset 144:7f0714e89aaa
prev31:495e480360d7
next447:3e095bfcb476
author nkeynes
date Mon May 15 08:28:52 2006 +0000 (15 years ago)
permissions -rw-r--r--
last change Rename video_driver to display_driver
Add input source to display
Implement configuration file support
Hook controllers up to configuration
view annotate diff log raw
     1 /**
     2  * $Id: maple.h,v 1.5 2006-05-15 08:28:52 nkeynes Exp $
     3  *
     4  * Maple bus definitions
     5  *
     6  * Copyright (c) 2005 Nathan Keynes.
     7  *
     8  * This program is free software; you can redistribute it and/or modify
     9  * it under the terms of the GNU General Public License as published by
    10  * the Free Software Foundation; either version 2 of the License, or
    11  * (at your option) any later version.
    12  *
    13  * This program is distributed in the hope that it will be useful,
    14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16  * GNU General Public License for more details.
    17  */
    19 #ifndef dream_maple_H
    20 #define dream_maple_H 1
    22 #include "dreamcast.h"
    24 #define MAPLE_CMD_INFO        1  /* Request device information */
    25 #define MAPLE_CMD_EXT_INFO    2  /* Request extended information */
    26 #define MAPLE_CMD_RESET       3  /* Reset device */
    27 #define MAPLE_CMD_SHUTDOWN    4  /* Shutdown device */
    28 #define MAPLE_CMD_GET_COND    9  /* Get condition */
    29 #define MAPLE_CMD_MEM_INFO    10 /* Get memory information */
    30 #define MAPLE_CMD_READ_BLOCK  11 /* Block read */
    31 #define MAPLE_CMD_WRITE_BLOCK 12 /* Block write */
    32 #define MAPLE_CMD_SET_COND    14 /* Set condition */
    33 #define MAPLE_RESP_INFO       5  /* Device information response */
    34 #define MAPLE_RESP_EXT_INFO   6  /* Extended device information response */
    35 #define MAPLE_RESP_ACK        7  /* Acknowledge command */
    36 #define MAPLE_RESP_DATA       8  /* Bytes read */
    37 #define MAPLE_ERR_NO_RESPONSE -1 /* Device did not respond */
    38 #define MAPLE_ERR_FUNC_UNSUP  -2 /* Function code unsupported */
    39 #define MAPLE_ERR_CMD_UNKNOWN -3 /* Command code unknown */
    40 #define MAPLE_ERR_RETRY       -4 /* Retry command */
    41 #define MAPLE_ERR_FILE        -5 /* File error? */
    43 #define MAPLE_FUNC_CONTROLLER 0x01000000
    44 #define MAPLE_FUNC_MEMORY     0x02000000
    45 #define MAPLE_FUNC_LCD        0x04000000
    46 #define MAPLE_FUNC_CLOCK      0x08000000
    47 #define MAPLE_FUNC_MICROPHONE 0x10000000
    48 #define MAPLE_FUNC_AR_GUN     0x20000000
    49 #define MAPLE_FUNC_KEYBOARD   0x40000000
    50 #define MAPLE_FUNC_LIGHT_GUN  0x80000000
    51 #define MAPLE_FUNC_PURU_PURU  0x00010000
    52 #define MAPLE_FUNC_MOUSE      0x00020000
    54 #define MAPLE_DEVICE_TAG 0x4D41504C
    55 #define MAPLE_DEVICE(x) ((maple_device_t)x)
    57 typedef struct maple_device_class *maple_device_class_t;
    58 typedef struct maple_device *maple_device_t;
    60 struct maple_device_class {
    61     const char *name;
    62     maple_device_t (*new_device)();
    63 };
    65 /**
    66  * Table of functions to be implemented by any maple device.
    67  */
    68 struct maple_device {
    69     uint32_t _tag;
    70     maple_device_class_t device_class;
    71     unsigned char ident[112];
    72     unsigned char version[80];
    73     dreamcast_config_entry_t (*get_config)(struct maple_device *dev);
    74     void (*attach)(struct maple_device *dev);
    75     void (*detach)(struct maple_device *dev);
    76     void (*destroy)(struct maple_device *dev);
    78     int (*reset)(struct maple_device *dev);
    79     int (*shutdown)(struct maple_device *dev);
    80     int (*get_condition)(struct maple_device *dev,
    81                          int function, unsigned char *outbuf, int *buflen);
    82     int (*set_condition)(struct maple_device *dev,
    83                          int function, unsigned char *inbuf, int buflen);
    84     int (*read_block)(struct maple_device *dev,
    85                       int function, uint32_t block, unsigned char *outbuf, int *buflen);
    86     int (*write_block)(struct maple_device *dev,
    87                        int function, uint32_t block, unsigned char *inbuf, int buflen);
    88 };
    90 extern struct maple_device_class controller_class;
    92 maple_device_t maple_new_device( const char *name );
    93 maple_device_t maple_get_device( unsigned int port, unsigned int periph );
    94 dreamcast_config_entry_t maple_get_device_config( maple_device_t dev );
    96 void maple_handle_buffer( uint32_t buffer );
    97 void maple_attach_device( maple_device_t dev, unsigned int port, unsigned int periph );
    98 void maple_detach_device( unsigned int port, unsigned int periph );
    99 void maple_detach_all( );
   100 void maple_reattach_all( );
   102 #endif /* !dream_maple_H */
.