/////////////////////////////////////////////////////////
// readtrack: start reading at given address


// DVD5 hack (allows 160.2.0 - 319.59.74)
int min_160 = 0;

//#define DVD5_DEBUG


long CALLBACK CDRreadTrack(unsigned char *time)
{
#ifdef DVD5_DEBUG
 char str[256];

 sprintf( str, "[PEOPS] %X:%X:%X", time[0],time[1],time[2] );
 OutputDebugString( str );
#endif


 // 160-320 minute toggle
 if( time[1] & 0x80 )
 {
#ifdef DVD5_DEBUG
  OutputDebugString( "\n" );
#endif


  min_160 = time[2] & 0x80 ? 1 : 0;

  time[1] &= 0x7f; // seconds
  time[2] &= 0x7f; // frames

  time[0] = btoi(time[0]);
  time[1] = btoi(time[1]);
  time[2] = btoi(time[2]);

  return PSE_CDR_ERR_SUCCESS;
 }

 if(!bIsOpen)   CDRopen();                             // usual checks
 if(!iCDROK)    return PSE_ERR_FATAL;
 if(bCDDAPlay)  bCDDAPlay=FALSE;

 time[2] &= 0x7f;   // frames
 time[1] &= 0x7f;   // seconds
 lLastAccessedAddr=time2addrB(time);                   // calc adr
 if( min_160 )
   lLastAccessedAddr += 0xAFC80; // 160:0:0


#ifdef DVD5_DEBUG
 sprintf( str, "  [%X]\n", lLastAccessedAddr );
 OutputDebugString( str );
#endif


 if(!pReadTrackFunc(lLastAccessedAddr))
  return PSE_CDR_ERR_NOREAD;

 return PSE_CDR_ERR_SUCCESS;
}
