Search
lxdream.org :: lxdream/src/gdrom/gdimage.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/gdrom/gdimage.c
changeset 498:10d5ba99a778
prev492:84e33e4dda1c
next561:533f6b478071
author nkeynes
date Thu Nov 08 10:48:41 2007 +0000 (13 years ago)
permissions -rw-r--r--
last change Preliminary support for raw sectors in image files
file annotate diff log raw
1.1 --- a/src/gdrom/gdimage.c Tue Nov 06 08:35:16 2007 +0000
1.2 +++ b/src/gdrom/gdimage.c Thu Nov 08 10:48:41 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: gdimage.c,v 1.6 2007-11-06 08:35:16 nkeynes Exp $
1.6 + * $Id: gdimage.c,v 1.7 2007-11-08 10:48:41 nkeynes Exp $
1.7 *
1.8 * GD-Rom image-file common functions.
1.9 *
1.10 @@ -30,6 +30,11 @@
1.11 static gdrom_error_t gdrom_image_read_position( gdrom_disc_t disc, uint32_t lba, unsigned char *buf );
1.12 static int gdrom_image_drive_status( gdrom_disc_t disc );
1.13
1.14 +struct cdrom_sector_header {
1.15 + uint8_t sync[12];
1.16 + uint8_t msf[3];
1.17 + uint8_t mode;
1.18 +};
1.19
1.20 /**
1.21 * Initialize a gdrom_disc structure with the gdrom_image_* methods
1.22 @@ -127,7 +132,7 @@
1.23 * Read a block from an image file, handling negative file offsets
1.24 * with 0-fill.
1.25 */
1.26 -static void gdrom_read_block( char *buf, int file_offset, int length, FILE *f )
1.27 +static void gdrom_read_block( unsigned char *buf, int file_offset, int length, FILE *f )
1.28 {
1.29 if( file_offset < 0 ) {
1.30 int size = -file_offset;
1.31 @@ -148,7 +153,9 @@
1.32 int mode, unsigned char *buf, uint32_t *length )
1.33 {
1.34 gdrom_image_t image = (gdrom_image_t)disc;
1.35 + struct cdrom_sector_header secthead;
1.36 int file_offset, read_len, track_no;
1.37 +
1.38 FILE *f;
1.39
1.40 track_no = gdrom_image_get_track_by_lba( image, lba );
1.41 @@ -169,16 +176,30 @@
1.42 switch( mode ) {
1.43 case 0x24:
1.44 case 0x28:
1.45 + read_len = 2048;
1.46 switch( track->mode ) {
1.47 case GDROM_MODE1:
1.48 case GDROM_MODE2_XA1:
1.49 gdrom_read_block( buf, file_offset, track->sector_size, f );
1.50 break;
1.51 case GDROM_MODE2:
1.52 - read_len = 2048;
1.53 file_offset += 8; /* skip the subheader */
1.54 gdrom_read_block( buf, file_offset, 2048, f );
1.55 break;
1.56 + case GDROM_RAW:
1.57 + gdrom_read_block( (unsigned char *)(&secthead), file_offset, sizeof(secthead), f );
1.58 + switch( secthead.mode ) {
1.59 + case 1:
1.60 + file_offset += 16;
1.61 + break;
1.62 + case 2:
1.63 + file_offset += 24;
1.64 + break;
1.65 + default:
1.66 + return PKT_ERR_BADREADMODE;
1.67 + }
1.68 + gdrom_read_block( buf, file_offset, 2048, f );
1.69 + break;
1.70 default:
1.71 return PKT_ERR_BADREADMODE;
1.72 }
.