Search
lxdream.org :: lxdream/src/gdrom/gdimage.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/gdrom/gdimage.c
changeset 837:4eae2ddccf9c
prev796:a2dc83592467
next840:c6a778c228a6
author nkeynes
date Thu Aug 28 01:39:51 2008 +0000 (12 years ago)
permissions -rw-r--r--
last change Extract the disc title (where available) and display in the title bar
file annotate diff log raw
1.1 --- a/src/gdrom/gdimage.c Wed Jul 30 22:50:44 2008 +0000
1.2 +++ b/src/gdrom/gdimage.c Thu Aug 28 01:39:51 2008 +0000
1.3 @@ -467,39 +467,6 @@
1.4 }
1.5 }
1.6
1.7 -void gdrom_image_dump_info( gdrom_disc_t d ) {
1.8 - gdrom_image_t disc = (gdrom_image_t)d;
1.9 - int i;
1.10 - int last_session = disc->track[disc->track_count-1].session;
1.11 - gboolean is_bootable = FALSE;
1.12 -
1.13 - INFO( "Disc ID: %s, %d tracks in %d sessions", disc->mcn, disc->track_count,
1.14 - disc->track[disc->track_count-1].session + 1 );
1.15 - if( last_session > 0 ) {
1.16 - /* Boot track is the first data track of the last session, provided that it
1.17 - * cannot be a single-session disc.
1.18 - */
1.19 - int boot_track = -1;
1.20 - for( i=disc->track_count-1; i>=0 && disc->track[i].session == last_session; i-- ) {
1.21 - if( disc->track[i].flags & TRACK_DATA ) {
1.22 - boot_track = i;
1.23 - }
1.24 - }
1.25 - if( boot_track != -1 ) {
1.26 - unsigned char boot_sector[MAX_SECTOR_SIZE];
1.27 - uint32_t length = sizeof(boot_sector);
1.28 - if( d->read_sector( d, disc->track[boot_track].lba, 0x28,
1.29 - boot_sector, &length ) == PKT_ERR_OK ) {
1.30 - bootstrap_dump(boot_sector, FALSE);
1.31 - is_bootable = TRUE;
1.32 - }
1.33 - }
1.34 - }
1.35 - if( !is_bootable ) {
1.36 - WARN( "Disc does not appear to be bootable" );
1.37 - }
1.38 -}
1.39 -
1.40 gdrom_device_t gdrom_device_new( const gchar *name, const gchar *dev_name )
1.41 {
1.42 struct gdrom_device *dev = g_malloc0( sizeof(struct gdrom_device) );
1.43 @@ -520,3 +487,41 @@
1.44 }
1.45 g_free( dev );
1.46 }
1.47 +
1.48 +/**
1.49 + * Check the disc for a useable DC bootstrap, and update the disc
1.50 + * with the title accordingly.
1.51 + * @return TRUE if we found a bootstrap, otherwise FALSE.
1.52 + */
1.53 +gboolean gdrom_image_read_info( gdrom_disc_t d ) {
1.54 + gdrom_image_t disc = (gdrom_image_t)d;
1.55 + if( disc->track_count > 0 ) {
1.56 + /* Find the first data track of the last session */
1.57 + int last_session = disc->track[disc->track_count-1].session;
1.58 + int i, boot_track = -1;
1.59 + for( i=disc->track_count-1; i>=0 && disc->track[i].session == last_session; i-- ) {
1.60 + if( disc->track[i].flags & TRACK_DATA ) {
1.61 + boot_track = i;
1.62 + }
1.63 + }
1.64 + if( boot_track != -1 ) {
1.65 + unsigned char boot_sector[MAX_SECTOR_SIZE];
1.66 + uint32_t length = sizeof(boot_sector);
1.67 + if( d->read_sector( d, disc->track[boot_track].lba, 0x28,
1.68 + boot_sector, &length ) == PKT_ERR_OK ) {
1.69 + if( memcmp( boot_sector, "SEGA SEGAKATANA SEGA ENTERPRISES", 32) == 0 ) {
1.70 + /* Got magic */
1.71 + memcpy( d->title, boot_sector+128, 128 );
1.72 + for( i=127; i>=0; i-- ) {
1.73 + if( !isspace(d->title[i]) )
1.74 + break;
1.75 + }
1.76 + d->title[i+1] = '\0';
1.77 + }
1.78 + bootstrap_dump(boot_sector, FALSE);
1.79 + return TRUE;
1.80 + }
1.81 + }
1.82 + }
1.83 + return FALSE;
1.84 +}
.