Search
lxdream.org :: lxdream :: r498:10d5ba99a778
lxdream 0.9.1
released Jun 29
Download Now
changeset498:10d5ba99a778
parent497:cd6e10c2e96b
child499:14b86c78d111
authornkeynes
dateThu Nov 08 10:48:41 2007 +0000 (12 years ago)
Preliminary support for raw sectors in image files
src/gdrom/gdi.c
src/gdrom/gdimage.c
1.1 --- a/src/gdrom/gdi.c Thu Nov 08 10:46:41 2007 +0000
1.2 +++ b/src/gdrom/gdi.c Thu Nov 08 10:48:41 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: gdi.c,v 1.1 2007-11-06 08:35:16 nkeynes Exp $
1.6 + * $Id: gdi.c,v 1.2 2007-11-08 10:48:41 nkeynes Exp $
1.7 *
1.8 * NullDC GDI image format
1.9 *
1.10 @@ -86,7 +86,7 @@
1.11 return NULL;
1.12 }
1.13 sscanf( line, "%d %d %d %d %s %d", &track_no, &start_lba, &flags, &size,
1.14 - &filename, &offset );
1.15 + filename, &offset );
1.16 if( start_lba >= 45000 ) {
1.17 image->track[i].session = 1;
1.18 } else {
1.19 @@ -110,14 +110,25 @@
1.20 }
1.21 fstat( fileno(image->track[i].file), &st );
1.22 image->track[i].sector_count = st.st_size / size;
1.23 - switch(size) {
1.24 - case 2048: image->track[i].mode = GDROM_MODE1; break;
1.25 - case 2336: image->track[i].mode = GDROM_GD; break;
1.26 - case 2352: image->track[i].mode = GDROM_CDDA; break;
1.27 - default:
1.28 - gdrom_image_destroy_no_close(disc);
1.29 - g_free(dirname);
1.30 - return NULL;
1.31 + if( image->track[i].flags & TRACK_DATA ) {
1.32 + /* Data track */
1.33 + switch(size) {
1.34 + case 2048: image->track[i].mode = GDROM_MODE1; break;
1.35 + case 2336: image->track[i].mode = GDROM_GD; break;
1.36 + case 2352: image->track[i].mode = GDROM_RAW; break;
1.37 + default:
1.38 + gdrom_image_destroy_no_close(disc);
1.39 + g_free(dirname);
1.40 + return NULL;
1.41 + }
1.42 + } else {
1.43 + /* Audio track */
1.44 + image->track[i].mode = GDROM_CDDA;
1.45 + if( size != 2352 ) {
1.46 + gdrom_image_destroy_no_close(disc);
1.47 + g_free(dirname);
1.48 + return NULL;
1.49 + }
1.50 }
1.51 }
1.52 image->track[i].offset = offset;
2.1 --- a/src/gdrom/gdimage.c Thu Nov 08 10:46:41 2007 +0000
2.2 +++ b/src/gdrom/gdimage.c Thu Nov 08 10:48:41 2007 +0000
2.3 @@ -1,5 +1,5 @@
2.4 /**
2.5 - * $Id: gdimage.c,v 1.6 2007-11-06 08:35:16 nkeynes Exp $
2.6 + * $Id: gdimage.c,v 1.7 2007-11-08 10:48:41 nkeynes Exp $
2.7 *
2.8 * GD-Rom image-file common functions.
2.9 *
2.10 @@ -30,6 +30,11 @@
2.11 static gdrom_error_t gdrom_image_read_position( gdrom_disc_t disc, uint32_t lba, unsigned char *buf );
2.12 static int gdrom_image_drive_status( gdrom_disc_t disc );
2.13
2.14 +struct cdrom_sector_header {
2.15 + uint8_t sync[12];
2.16 + uint8_t msf[3];
2.17 + uint8_t mode;
2.18 +};
2.19
2.20 /**
2.21 * Initialize a gdrom_disc structure with the gdrom_image_* methods
2.22 @@ -127,7 +132,7 @@
2.23 * Read a block from an image file, handling negative file offsets
2.24 * with 0-fill.
2.25 */
2.26 -static void gdrom_read_block( char *buf, int file_offset, int length, FILE *f )
2.27 +static void gdrom_read_block( unsigned char *buf, int file_offset, int length, FILE *f )
2.28 {
2.29 if( file_offset < 0 ) {
2.30 int size = -file_offset;
2.31 @@ -148,7 +153,9 @@
2.32 int mode, unsigned char *buf, uint32_t *length )
2.33 {
2.34 gdrom_image_t image = (gdrom_image_t)disc;
2.35 + struct cdrom_sector_header secthead;
2.36 int file_offset, read_len, track_no;
2.37 +
2.38 FILE *f;
2.39
2.40 track_no = gdrom_image_get_track_by_lba( image, lba );
2.41 @@ -169,16 +176,30 @@
2.42 switch( mode ) {
2.43 case 0x24:
2.44 case 0x28:
2.45 + read_len = 2048;
2.46 switch( track->mode ) {
2.47 case GDROM_MODE1:
2.48 case GDROM_MODE2_XA1:
2.49 gdrom_read_block( buf, file_offset, track->sector_size, f );
2.50 break;
2.51 case GDROM_MODE2:
2.52 - read_len = 2048;
2.53 file_offset += 8; /* skip the subheader */
2.54 gdrom_read_block( buf, file_offset, 2048, f );
2.55 break;
2.56 + case GDROM_RAW:
2.57 + gdrom_read_block( (unsigned char *)(&secthead), file_offset, sizeof(secthead), f );
2.58 + switch( secthead.mode ) {
2.59 + case 1:
2.60 + file_offset += 16;
2.61 + break;
2.62 + case 2:
2.63 + file_offset += 24;
2.64 + break;
2.65 + default:
2.66 + return PKT_ERR_BADREADMODE;
2.67 + }
2.68 + gdrom_read_block( buf, file_offset, 2048, f );
2.69 + break;
2.70 default:
2.71 return PKT_ERR_BADREADMODE;
2.72 }
.