<html>
<body>
  <div id="body" style="background-color:#ffffff;" >
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head" style="border-bottom-width:1px;border-bottom-style:solid;" ><td class="headtd" style="padding:0;padding-top:.2em;" colspan="4">Commit in <b><tt>lxdream/src/drivers/cdrom</tt></b></td></tr>
<tr><td><tt><a href="#file1">cd_nrg.c</a></tt></td><td id="added" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ddffdd;" align="right">+8</td><td id="removed" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ffdddd;" align="right">-3</td><td class="headtd2" style="padding-left:.3em;padding-right:.3em;" nowrap="nowrap">bd5893522efc -> e55ec927d55d</td></tr>
<tr class="alt" style=";" ><td><tt><a href="#file2">defs.h</a></tt></td><td id="addedalt" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ccf7cc;" align="right">+2</td><td></td><td class="headtd2" style="padding-left:.3em;padding-right:.3em;" nowrap="nowrap">bd5893522efc -> e55ec927d55d</td></tr>
<tr><td><tt><a href="#file3">sector.c</a></tt></td><td id="added" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ddffdd;" align="right">+18</td><td id="removed" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ffdddd;" align="right">-5</td><td class="headtd2" style="padding-left:.3em;padding-right:.3em;" nowrap="nowrap">bd5893522efc -> e55ec927d55d</td></tr>
<tr><td></td><td id="added" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ddffdd;" align="right">+28</td><td id="removed" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ffdddd;" align="right">-8</td><td></td></tr>
</table>
<small id="info" style="color: #888888;" >3 modified files</small><br />
<pre class="comment" style="white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;white-space:pre-wrap;word-wrap:break-word;padding:4px;border:1px dashed #000000;background-color:#ffffdd;" >
Fix structure packing on v55 nero images (64-bit)
Add basic support for track mode 16 (CDDA + subchannel data, 2448 bytes)
</pre>
<hr /><a name="file1" /><div class="file" style="border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;" >
<span class="pathname" style="font-family:monospace; float:right;" >lxdream/src/drivers/cdrom</span><br />
<div class="fileheader" style="margin-bottom:.5em;" ><big><b>cd_nrg.c</b></big> <small id="info" style="color: #888888;" >bd5893522efc -> e55ec927d55d</small></div>
<pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >--- lxdream/src/drivers/cdrom/cd_nrg.c
+++ lxdream/src/drivers/cdrom/cd_nrg.c
@@ -58,7 +58,7 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     struct nrg_footer_v55 {
         uint32_t id;
         uint64_t offset;
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-    } v55;
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+    } __attribute__((packed)) v55;
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > };
 
 struct nrg_chunk {
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -132,6 +132,7 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     case 2: return SECTOR_MODE2_FORM1;
     case 3: return SECTOR_SEMIRAW_MODE2;
     case 7: return SECTOR_CDDA;
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+    case 16: return SECTOR_CDDA_SUBCHANNEL;
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     default: return -1;
     }
 }
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -172,14 +173,18 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > 
     fseek( f, -12, SEEK_END );
     fread( &footer, sizeof(footer), 1, f );
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+    uint32_t start = 0;
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     if( GUINT32_FROM_BE(footer.v50.id) == NERO_V50_ID ) {
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-        fseek( f, GUINT32_FROM_BE(footer.v50.offset), SEEK_SET );
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+        start = GUINT32_FROM_BE(footer.v50.offset);
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     } else if( GUINT32_FROM_BE(footer.v55.id) == NERO_V55_ID ) {
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-        fseek( f, (uint32_t)GUINT64_FROM_BE(footer.v55.offset), SEEK_SET );
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+        start = (uint32_t)GUINT64_FROM_BE(footer.v55.offset);
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     } else {
         /* Not a (recognized) Nero image (should never happen) */
         RETURN_PARSE_ERROR("File is not an NRG image" );
     }
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+    if( fseek( f, start, SEEK_SET) != 0 ) {
+        RETURN_PARSE_ERROR("File is not a valid NRG image" );
+    }
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > 
     do {
         fread( &chunk, sizeof(chunk), 1, f );
</pre></div>
<hr /><a name="file2" /><div class="file" style="border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;" >
<span class="pathname" style="font-family:monospace; float:right;" >lxdream/src/drivers/cdrom</span><br />
<div class="fileheader" style="margin-bottom:.5em;" ><big><b>defs.h</b></big> <small id="info" style="color: #888888;" >bd5893522efc -> e55ec927d55d</small></div>
<pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >--- lxdream/src/drivers/cdrom/defs.h
+++ lxdream/src/drivers/cdrom/defs.h
@@ -74,6 +74,8 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     SECTOR_RAW_XA,
     /* 2352-byte raw data sector in a non-XA session */
     SECTOR_RAW_NONXA,
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+    /* CDDA + subchannel data */
+    SECTOR_CDDA_SUBCHANNEL
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > } sector_mode_t;
 
 
</pre></div>
<hr /><a name="file3" /><div class="file" style="border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;" >
<span class="pathname" style="font-family:monospace; float:right;" >lxdream/src/drivers/cdrom</span><br />
<div class="fileheader" style="margin-bottom:.5em;" ><big><b>sector.c</b></big> <small id="info" style="color: #888888;" >bd5893522efc -> e55ec927d55d</small></div>
<pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >--- lxdream/src/drivers/cdrom/sector.c
+++ lxdream/src/drivers/cdrom/sector.c
@@ -43,13 +43,14 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >         CDROM_READ_MODE2|CDROM_READ_DATA, CDROM_READ_MODE2_FORM1|CDROM_READ_DATA,
         CDROM_READ_MODE2_FORM1|CDROM_READ_DATA,
         CDROM_READ_MODE2|CDROM_READ_DATA|CDROM_READ_SUBHEADER|CDROM_READ_ECC,
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-        CDROM_READ_RAW, CDROM_READ_RAW<span id="removedchars" style="background-color:#ff9999;font-weight:bolder;" > };</span>
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+        CDROM_READ_RAW, CDROM_READ_RAW<span id="addedchars" style="background-color:#99ff99;font-weight:bolder;" >,</span>
+        CDROM_READ_CDDA|CDROM_READ_DATA};
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > 
 /* Block size for each sector mode */
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-const uint32_t cdrom_sector_size[] = { 0, 2352, 2048, 2336, 2048, 2324, 2336, 2352, 2352 };
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+const uint32_t cdrom_sector_size[] = { 0, 2352, 2048, 2336, 2048, 2324, 2336, 2352, 2352<span id="addedchars" style="background-color:#99ff99;font-weight:bolder;" >, 2448</span> };
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > 
 const char *cdrom_sector_mode_names[] = { "Unknown", "Audio", "Mode 1", "Mode 2", "Mode 2 Form 1", "Mode 2 Form 2",
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-        "Mode 2 semiraw", "XA Raw", "Non-XA Raw" };
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+        "Mode 2 semiraw", "XA Raw", "Non-XA Raw"<span id="addedchars" style="background-color:#99ff99;font-weight:bolder;" >, "CDDA+Subchan"</span> };
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > 
 
 /********************* Public functions *************************/
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -152,7 +153,7 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     switch( read_sector_type ) {
     case CDROM_READ_ANY: break;
     case CDROM_READ_CDDA:
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-        if( sector_mode != SECTOR_CDDA )
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+        if( sector_mode != SECTOR_CDDA && sector_mode != SECTOR_CDDA_SUBCHANNEL )
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >             return CDROM_ERROR_BADREADMODE;
         break;
     case CDROM_READ_MODE1:
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -175,6 +176,7 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     /* Check the fields requested are sane per MMC (non-contiguous regions prohibited) */
     switch( sector_mode ) {
     case SECTOR_CDDA:
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+    case SECTOR_CDDA_SUBCHANNEL:
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >         return CDROM_ERROR_OK; /* Everything is OK */
     case SECTOR_MODE2_FORM1:
     case SECTOR_MODE2_FORM2:
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -301,7 +303,7 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >         cdrom_lba_t lba, cdrom_count_t block_count, cdrom_read_mode_t mode,
         unsigned char *buf, size_t *length )
 {
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-    unsigned char tmp[CDROM_MAX_SECTOR_SIZE];
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+    unsigned char tmp[2448];
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     int read_sector_type = CDROM_READ_TYPE(mode);
     int read_sector_fields = CDROM_READ_FIELDS(mode);
     int i;
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -319,6 +321,17 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >             device->read_blocks( device, lba, block_count, buf );
         }
         break;
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+    case SECTOR_CDDA_SUBCHANNEL:
+        if( read_sector_type != CDROM_READ_ANY && read_sector_type != CDROM_READ_CDDA )
+            return CDROM_ERROR_BADREADMODE;
+        if( read_sector_fields != 0 ) {
+            len = block_count * 2352;
+            for( i=0; i<block_count; i++ ) {
+                device->read_blocks( device, lba+i, 1, tmp );
+                memcpy( &buf[2352*i], tmp, 2352 );
+            }
+        }
+        break;
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     case SECTOR_RAW_XA:
     case SECTOR_RAW_NONXA:
     case SECTOR_SEMIRAW_MODE2:
</pre></div>
<center><small>Chaos Theory</small></center>
</div></body></html>