filename | src/maple/maple.c |
changeset | 447:3e095bfcb476 |
prev | 159:406161fea392 |
next | 450:207461e79f21 |
author | nkeynes |
date | Tue Oct 16 12:36:29 2007 +0000 (16 years ago) |
permissions | -rw-r--r-- |
last change | Add gui error reporting Add initial controller settings dialog |
file | annotate | diff | log | raw |
1.1 --- a/src/maple/maple.c Thu Jun 15 10:33:08 2006 +00001.2 +++ b/src/maple/maple.c Tue Oct 16 12:36:29 2007 +00001.3 @@ -1,5 +1,5 @@1.4 /**1.5 - * $Id: maple.c,v 1.9 2006-06-15 10:33:05 nkeynes Exp $1.6 + * $Id: maple.c,v 1.10 2007-10-16 12:36:29 nkeynes Exp $1.7 *1.8 * Implements the core Maple bus, including DMA transfers to and from the bus.1.9 *1.10 @@ -37,14 +37,28 @@1.12 maple_device_t maple_new_device( const gchar *name )1.13 {1.14 + maple_device_class_t clz = maple_get_device_class(name);1.15 + if( clz != NULL ) {1.16 + return clz->new_device();1.17 + }1.18 + return NULL;1.19 +}1.20 +1.21 +const maple_device_class_t maple_get_device_class( 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 + return maple_device_classes[i];1.28 }1.29 return NULL;1.30 }1.32 +const struct maple_device_class **maple_get_device_classes()1.33 +{1.34 + return maple_device_classes;1.35 +}1.36 +1.37 dreamcast_config_entry_t maple_get_device_config( maple_device_t dev )1.38 {1.39 if( dev->get_config == NULL )1.40 @@ -105,8 +119,10 @@1.41 gun = GETBYTE(1) & 0x01;1.42 length = GETBYTE(0) & 0xFF;1.43 return_addr = GETWORD(4);1.44 - if( return_addr == 0 ) {1.45 - /* ERROR */1.46 +1.47 + if( (return_addr & 0x1C000000) != 0x0C000000 ) {1.48 + ERROR( "Bad return address in maple packet: %08X", return_addr );1.49 + break;1.50 }1.51 return_buf = mem_get_region(return_addr);1.52 cmd = GETBYTE(8);1.53 @@ -114,10 +130,13 @@1.54 send_addr = GETBYTE(10);1.55 /* Sanity checks */1.56 if( GETBYTE(11) != length ||1.57 - send_addr != (port<<6) ||1.58 + send_addr >> 6 != port ||1.59 recv_addr >> 6 != port ||1.60 return_buf == NULL ) {1.61 - /* ERROR */1.62 + ERROR( "Received bad packet: %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X",1.63 + buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7],1.64 + buf[8], buf[9], buf[10], buf[11] );1.65 + break;1.66 }1.67 periph = 0;1.68 periph_id = recv_addr & 0x3F;1.69 @@ -221,6 +240,7 @@1.70 return_buf[3] = out_length;1.71 }1.72 buf += 12 + (length<<2);1.73 + address += 12 + (length<<2);1.74 }1.75 asic_event( EVENT_MAPLE_DMA );1.76 }1.77 @@ -256,6 +276,9 @@1.78 if( dev->detach != NULL ) {1.79 dev->detach(dev);1.80 }1.81 + if( dev->destroy != NULL ) {1.82 + dev->destroy(dev);1.83 + }1.84 if( periph == 0 ) {1.85 /* If we detach the main peripheral, we also have to detach all the1.86 * subperipherals, or the system could get quite confused
.