Esempio n. 1
0
int dao_copy( unsigned short source, unsigned short dest,
              int simul, int ejsrc, int ejdst )
{
  int ret;
  struct idao_stream * in;
  struct odao_stream * out;

  log_begin();
  log_printf( "*** Begin of a DAO copy\n\n" );

  if( source == TST_FILE )
    in = idao_open_file( copy_info.source_file );
  else if( source == 20000 )
    in = idao_open_file( copy_info.int_file );
  else
    in = idao_open_cd( copy_info.source_dev );
  if( !in )
  {
    alert_msg( "AL_DAOSRCERR", 1 );
    return -1;
  }

  if( dest == TST_FILE )
    out = odao_open_file( copy_info.dest_file );
  else if( dest == 20000 )
    out = odao_open_file( copy_info.int_file );
  else
    out = odao_open_cd( copy_info.dest_dev );
  if( !out )
  {
    idao_close( in );
    alert_msg( "AL_DAODSTERR", 1 );
    return -1;
  }

  if( in->type == TST_CD )
  {
    if( ejsrc ) in->spec.cd.flags |= CDFLG_EJECT;
  }
  if( out->type == TST_CD )
  {
    if( ejdst ) out->spec.cd.flags |= CDFLG_EJECT;
    use_device( out->spec.cd.dev );
    set_dummy_write( simul );
    set_write_speed( copy_info.write_speed );
  }

  ret = dao_pipe( "TXT_COPY", in, out );

  odao_close( out );
  idao_close( in );

  log_printf( "*** End of the DAO copy\n\n" );
  log_end();

  return ret;
}
Esempio n. 2
0
static LPARAM
log_WM_DESTROY(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
	LPARAM ret;
	log_begin("WM_DESTROY");
		ret = on_WM_DESTROY(hwnd, msg, wp, lp);
	log_end();
	return ret;
}
Esempio n. 3
0
static LPARAM
log_WM_CREATE(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
	LPARAM ret;
	log_begin("WM_CREATE");
		ret = on_WM_CREATE(hwnd, msg, wp, lp);
	log_end();
	return ret;
}
Esempio n. 4
0
static LPARAM
log_DefWindowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
	LPARAM ret;
	log_begin("WM_%d", msg);
		ret = DefWindowProc(hwnd, msg, wp, lp);
	log_end();
	return ret;
}
Esempio n. 5
0
static LPARAM
log_WM_LBUTTONUP(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
	LPARAM ret;
	log_begin("WM_LBUTTONUP");
		ret = on_WM_LBUTTONUP(hwnd, msg, wp, lp);
	log_end();
	return ret;
}
Esempio n. 6
0
/** Log a message to the kernel log.
 * 
 * This atomically appends a log entry.
 * The resulting message should not contain a trailing newline, as the log
 * entries are explicitly delimited when stored in the log.
 */
int log(log_facility_t fac, log_level_t level, const char *fmt, ...)
{
	int ret;
	va_list args;
	
	log_begin(fac, level);
	
	va_start(args, fmt);
	ret = log_vprintf(fmt, args);
	va_end(args);
	
	log_end();
	
	return ret;
}
Esempio n. 7
0
blargg_err_t Gym_Emu::start_track_( int track )
{
	RETURN_ERR( Music_Emu::start_track_( track ) );
	
	pos         = log_begin();
	loop_remain = get_le32( header_.loop_start );
	
	prev_pcm_count = 0;
	pcm_enabled    = 0;
	pcm_amp        = -1;
	
	fm.reset();
	apu.reset();
	stereo_buf.clear();
	resampler.clear();
	pcm_buf = stereo_buf.center();
	return blargg_ok;
}
Esempio n. 8
0
void toc_extract( WINDOW * win )
{
  static const char * ext[] = { "avr", "raw", "raw", "wav" };
  char pathname[ 256 ];
  char prog_info[ 64 ];
  char buf[ 128 ];
  struct avr_header * avrh;
  struct wave_header * wavh;
  struct audio_entry entry;
  struct audio_stream * as;
  struct _toc_data * data;
  struct device_info * info;
  OBJECT * ck;
  int format, i, max, track_no;
  int fd, swap;
  long offset, length, position, end, progress, total_length;
  long max_buf_blocks, nblocks;
  void * buffer;

  if( !fileselect( preferences.toc_dest, "", "TXT_EXTDEST" ) )
    return;
  strrchr( preferences.toc_dest, '\\' )[1] = '\0';

  data = DataSearch( win, TW_MAGIC );
  max = data->n_tracks;
  format = fmt_popup.selected;
  total_length = 0;
  buffer = alloc_comm_buffer( BUFSIZE );
  if( !buffer )
    return;
  for( i = 0; i < max; i++ )
  {
    ck = data->tree + 1 + TF_CK + i * data->n_obj;
    if( ! (ck->ob_state & SELECTED) )
      continue;
    offset = toc_address( data->f[i].beg_time );
    length = toc_address( data->f[i].end_time ) + 1 - offset;
    if( length > 0 )
      total_length += length;
  }
  max_buf_blocks = BUFSIZE / 2352;

  progress = 0;
  progress_init( get_string( "TXT_EXTMSG" ), total_length );
  progress_activate_cancel( 1 );
  progress_init_timer();

  log_begin();
  log_printf( "*** Begin of a track extraction session\n\n" );
  as = NULL;
  for( i = 0; i < max; i++ )
  {
    ck = data->tree + 1 + TF_CK + i * data->n_obj;
    if( ! (ck->ob_state & SELECTED) )
      continue;
    offset = toc_address( data->f[i].beg_time );
    length = toc_address( data->f[i].end_time ) + 1 - offset;
    if( length <= 0 )
      continue;
    track_no = i + 1;
    position = get_track_offset( &data->toc, track_no, &end );
    if( toc_popup.selected == 0 )
      gen_daoimg_entry( &entry, toc_info.toc_file, track_no,
                        offset - position, end - offset - length );
    else
    {
      info = (struct device_info*)toc_popup.item[toc_popup.selected].info;
      gen_cd_entry( &entry, info, track_no, offset - position, end - offset - length );
    }
    if( as )
      as = audio_reopen( as, &entry );
    else
      as = audio_open( &entry );
    if( as == NULL )
      continue;

    sprintf( prog_info, get_string( "TXT_EXTTRK" ), track_no );
    progress_setinfo( prog_info );

    sprintf( pathname, "%strack%02d.%s", preferences.toc_dest, track_no, ext[ format ] );
    fd = open( pathname, O_WRONLY|O_CREAT|O_TRUNC );
    if( fd == -1 )
    {
      audio_close( as );
      alert_msg( "AL_FILERR", 1, pathname );
      goto error;
    }
    switch( format )
    {
    case 0:        /* AVR */
      avrh = (struct avr_header *) buf;
      avrh->avr_id = '2BIT';
      memset( avrh->name, 0, 8 );
      avrh->num_voices = 0xFFFF;
      avrh->num_bits = 16;
      avrh->signe = 0xffff;
      avrh->loop = 0;
      avrh->midi = 0xffff;
      avrh->freq_type.frequence = 0xff00ac44L;
      avrh->length = length * (2352 / 2);
      avrh->beg_loop = 0;
      avrh->end_loop = avrh->length;
      memset( avrh->reserved, 0, 26 + 64 );
      write( fd, avrh, sizeof( *avrh ) );
      swap = as->little_endian;
      break;
    case 1:        /* RAW big-endian */
      swap = as->little_endian;
      break;
    case 2:        /* RAW little-endian */
      swap = !as->little_endian;
      break;
    case 3:        /* WAVE */
      wavh = (struct wave_header *) buf;
      wavh->riff_id = 'RIFF';
      wavh->riff_len = swap_long( length * 2352 + 36 );
      wavh->wave_id = 'WAVE';
      wavh->fmt_id = 'fmt ';
      wavh->fmt_size = 0x10000000L;
      wavh->fmt_compression_code = 0x0100;
      wavh->fmt_channels = 0x0200;
      wavh->fmt_freq = 0x44ac0000L;
      wavh->fmt_bytes_sec = 0x10b10200L;
      wavh->fmt_block_align = 0x0400;
      wavh->fmt_num_bits = 0x1000;
      wavh->data_id = 'data';
      wavh->data_size = swap_long( length * 2352 );
      write( fd, wavh, sizeof( *wavh ) );
      swap = !as->little_endian;
      break;
    }
    while( length > 0 )
    {
      if( yield() )
      {
        audio_close( as );
        alert_msg( "AL_EXTINT", 1 );
        goto error;
      }
      nblocks = MIN( length, max_buf_blocks );
      if( audio_read( as, buffer, nblocks ) == 0 )
      {
        audio_close( as );
        goto error;
      }
      if( swap )
        swap_endian( buffer, nblocks * 2352 );
      if( write( fd, buffer, nblocks * 2352 ) == -1 )
      {
        close( fd );
        audio_close( as );
        alert_msg( "AL_FWRTERR", 1, pathname );
        goto error;
      }
      length -= nblocks;
      progress += nblocks;
      progress_setcount( progress );
    }
    close( fd );
  }
  audio_close( as );
error:
  log_printf( "*** End of the track extraction session\n\n" );
  log_end();
  progress_exit();
  free_comm_buffer( buffer );

}
Esempio n. 9
0
blargg_err_t Gym_Emu::track_info_( track_info_t* out, int ) const
{
	get_gym_info( header_, gym_track_length( log_begin(), file_end() ), out );
	return blargg_ok;
}
Esempio n. 10
0
int tao_launch2( int simul, int eject )
{
  char buf[256];
  size_t len;
  struct tao_ostream * out;
  struct tao_track * in[1];

  struct device_info * info;
  int ret;

  busybee();

  log_begin();
  log_printf( "*** Begin of a TAO write session\n\n" );

  info = tao_popup.item[ tao_popup.selected ].info;
  if( info )
    out = tao_open( info );
  else
    out = tao_open_file( dest_file );

  if( !out )
  {
    alert_msg( "AL_DAODSTERR", 1 );
    goto erreur;
  }

  len = strlen( src_file ) - 1;
  if( src_file[ len ] == '\\' )
  {
    memcpy( buf, src_file, len );
    buf[ len ] = '\0';
    in[0] = tao_track_new_ig( buf, 2048 );
  }
  else
    in[0] = tao_track_new_iso( src_file, 2048 );

  if( in[0] )
  {
    if( out->type == TAO_CDR )
    {
      set_dummy_write( simul );
      set_write_speed( preferences.tao_write_speed );
    }
    tao_pipe( in, 1, out );
    tao_track_dispose( in[0] );
  }
  tao_close( out );

  ret = 0;
  if( eject && preferences.pref_flags.eject_dst )
  {
    ret = prevent_allow_medium_removal( 0 );
    if( ret ) goto erreur;
    ret = start_stop_unit( 1, 1, 0 );
    if( ret ) goto erreur;
  }

  goto ok;
erreur:
  ret = -1;

ok:

  log_printf( "*** End of the TAO write session\n\n" );
  log_end();
  arrow();

  return ret;
}