filename | src/maple/maple.c |
changeset | 144:7f0714e89aaa |
prev | 121:795fec623ce9 |
next | 159:406161fea392 |
author | nkeynes |
date | Mon May 15 08:28:52 2006 +0000 (17 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 |
file | annotate | diff | log | raw |
1.1 --- a/src/maple/maple.c Mon Mar 20 12:00:15 2006 +00001.2 +++ b/src/maple/maple.c Mon May 15 08:28:52 2006 +00001.3 @@ -1,5 +1,5 @@1.4 /**1.5 - * $Id: maple.c,v 1.7 2006-03-20 12:00:15 nkeynes Exp $1.6 + * $Id: maple.c,v 1.8 2006-05-15 08:28:52 nkeynes Exp $1.7 *1.8 * Implements the core Maple bus, including DMA transfers to and from the bus.1.9 *1.10 @@ -28,11 +28,30 @@1.11 struct dreamcast_module maple_module = { "Maple", maple_init, NULL, NULL, NULL,1.12 NULL, NULL, NULL };1.14 +struct maple_device_class *maple_device_classes[] = { &controller_class, NULL };1.15 +1.16 void maple_init( void )1.17 {1.19 }1.21 +maple_device_t maple_new_device( const gchar *name )1.22 +{1.23 + int i;1.24 + for( i=0; maple_device_classes[i] != NULL; i++ ) {1.25 + if( g_strcasecmp(maple_device_classes[i]->name, name ) == 0 )1.26 + return maple_device_classes[i]->new_device();1.27 + }1.28 + return NULL;1.29 +}1.30 +1.31 +dreamcast_config_entry_t maple_get_device_config( maple_device_t dev )1.32 +{1.33 + if( dev->get_config == NULL )1.34 + return NULL;1.35 + return dev->get_config(dev);1.36 +}1.37 +1.38 /**1.39 * Input data looks like this:1.40 * 0: transfer control word1.41 @@ -60,6 +79,14 @@1.42 #define PUTBYTE(n,x) (buf[n] = (char)x)1.43 #define PUTWORD(n,x) (*((uint32_t *)(return_buf+(n))) = (x))1.45 +maple_device_t maple_get_device( unsigned int port, unsigned int periph ) {1.46 + if( port >= 4 )1.47 + return NULL;1.48 + if( periph >= 6 )1.49 + return NULL;1.50 + return maple_devices[port][periph];1.51 +}1.52 +1.53 void maple_handle_buffer( uint32_t address ) {1.54 unsigned char *buf = (unsigned char *)mem_get_region(address);1.55 if( buf == NULL ) {1.56 @@ -242,5 +269,34 @@1.57 } else {1.58 maple_periph_mask[port] &= (~(1<<(periph-1)));1.59 }1.60 -1.61 +1.62 }1.63 +1.64 +void maple_detach_all() {1.65 + int i, j;1.66 + for( i=0; i<4; i++ ) {1.67 + for( j=0; j<6; j++ ) {1.68 + if( maple_devices[i][j] != NULL ) {1.69 + maple_device_t dev = maple_devices[i][j];1.70 + if( dev->detach != NULL )1.71 + dev->detach(dev);1.72 + if( dev->destroy != NULL )1.73 + dev->destroy(dev);1.74 + }1.75 + }1.76 + maple_periph_mask[i] = 0;1.77 + }1.78 +}1.79 +1.80 +void maple_reattach_all() {1.81 + int i, j;1.82 + for( i=0; i<4; i++ ) {1.83 + for( j=0; j<6; j++ ) {1.84 + if( maple_devices[i][j] != NULL ) {1.85 + maple_device_t dev = maple_devices[i][j];1.86 + if( dev->attach != NULL )1.87 + dev->attach(dev);1.88 + }1.89 + }1.90 + }1.91 +}
.