Beispiel #1
0
void I_PlayCD (UINT8 track, UINT8 looping)
{
#ifdef NOSDLCD
	(void)track;
	(void)looping;
#else
	if (!cdrom || !cdEnabled)
		return;

	if (!cdValid)
	{
		CDAudio_GetAudioDiskInfo();
		if (!cdValid)
			return;
	}

	track = cdRemap[track];

	if (track < 1 || track > maxTrack)
	{
		CONS_Printf("I_PlayCD: Bad track number %u.\n", track);
		return;
	}

	// don't try to play a non-audio track
	if (cdrom->track[track].type == SDL_DATA_TRACK)
	{
		CONS_Printf("I_PlayCD: track %u is not audio\n", track);
		return;
	}

	if (cdPlaying)
	{
		if (playTrack == track)
			return;
		I_StopCD();
	}

	if (SDL_CDPlayTracks(cdrom, track, 0, 1, 0))
	{
		CONS_Printf("Error playing track %d: %s\n",
				track, SDL_GetError());
		return;
	}

	playLooping = looping;
	playTrack = (Uint8)track;
	cdPlaying = true;

	if (cd_volume.value == 0)
		I_PauseCD();
#endif
}
Beispiel #2
0
void I_PlayCD(int track, bool looping)
{
  if (cdrom == NULL || !enabled)
    return;
    
  if (!cdValid)
    {
      CDAudio_GetAudioDiskInfo();
      if (!cdValid)
	return;
    }
    
  track = cdRemap[track];
    
  if (track < 1 || track > maxTrack)
    {
      CONS_Printf("I_PlayCD: Bad track number %u.\n", track);
      return;
    }
    
  // don't try to play a non-audio track
  if (cdrom->track[track].type == SDL_DATA_TRACK)
    {
      CONS_Printf("I_PlayCD: track %i is not audio\n", track);
      return;
    }
	
  if (playing)
    {
      if (playTrack == track)
	return;
      I_StopCD();
    }
    
  if (SDL_CDPlayTracks(cdrom, track, 0, 1, 0))
    {
      CONS_Printf("Error playing track %d: %s\n",
		  track, SDL_GetError());
      return;
    }
    
  playLooping = looping;
  playTrack = track;
  playing = true;

  if (cd_volume.value == 0)
    {
      I_PauseCD();
    }
    
}
Beispiel #3
0
int I_SetVolumeCD(int volume)
{
  if (volume != cdvolume)
    {
      if (volume > 0 && volume < 16)
	{
	  cd_volume.Set(31);
	  cdvolume = 31;
	  
	  I_ResumeCD();
	}
      else if (volume > 15 && volume < 31)
	{
	  cd_volume.Set(0);
	  cdvolume = 0;
	    
	  I_PauseCD();
	}
    }
    
  return 0;
}
Beispiel #4
0
boolean I_SetVolumeCD (INT32 volume)
{
#ifdef NOSDLCD
	(void)volume;
#else
	if (volume != cdvolume)
	{
		if (volume > 0 && volume < 16)
		{
			CV_SetValue(&cd_volume, 31);
			cdvolume = 31;
			I_ResumeCD();
		}
		else if (volume > 15 && volume < 31)
		{
			CV_SetValue(&cd_volume, 0);
			cdvolume = 0;
			I_PauseCD();
		}
	}
#endif
	return false;
}
Beispiel #5
0
static void Command_Cd_f()
{
  const char *command;
  int   ret, n;

  if (!initialized)
    return;

  if (COM.Argc() < 2) {
    CONS_Printf("cd [on] [off] [remap] [reset] [open]\n"
		"   [info] [play <track>] [resume]\n"
		"   [stop] [pause] [loop <track>]\n");
    return;
  }

  command = COM.Argv(1);

  if (!strncmp(command, "on", 2)) {
    enabled = true;
    return;
  }

  if (!strncmp(command, "off", 3)) {
    I_StopCD();
    enabled = false;
    return;
  }
	
  if (!strncmp(command, "remap", 5)) {
    ret = COM.Argc() - 2;
    if (ret <= 0) {
      for (n = 1; n < MAX_CD_TRACKS; n++)
	if (cdRemap[n] != n)
	  CONS_Printf("  %u -> %u\n", n, cdRemap[n]);
      return;
    }
    for (n = 1; n <= ret; n++)
      cdRemap[n] = atoi(COM.Argv(n+1));
    return;
  }
        
  if (!strncmp(command, "reset", 5)) {
    enabled = true;
    I_StopCD();
            
    for (n = 0; n < MAX_CD_TRACKS; n++)
      cdRemap[n] = n;
    CDAudio_GetAudioDiskInfo();
    return;
  }
        
  if (!cdValid)
    {
      CDAudio_GetAudioDiskInfo();
      if (!cdValid)
	return;
    }

  if (!strncmp(command, "open", 4)) {
    I_EjectCD();
    cdValid = false;
    return;
  }

  if (!strncmp(command, "info", 4)) {
    CONS_Printf("%u tracks\n", maxTrack);
    if (playing)
      CONS_Printf("Currently %s track %u\n", playLooping ? "looping" : "playing", playTrack);
    else if (wasPlaying)
      CONS_Printf("Paused %s track %u\n", playLooping ? "looping" : "playing", playTrack);
    CONS_Printf("Volume is %d\n", cdvolume);
    return;
  }

  if (!strncmp(command, "play", 4)) {
    I_PlayCD((byte)atoi(COM.Argv(2)), false);
    return;
  }

  if (!strncmp(command, "loop", 4)) {
    I_PlayCD((byte)atoi(COM.Argv(2)), true);
    return;
  }

  if (!strncmp(command, "stop", 4)) {
    I_StopCD();
    return;
  }
        
  if (!strncmp(command, "pause", 5)) {
    I_PauseCD();
    return;
  }
        
  if (!strncmp(command, "resume", 6)) {
    I_ResumeCD();
    return;
  }
        
  CONS_Printf("Invalid command \"cd %s\"\n", COM.Argv(1));
}
Beispiel #6
0
/**************************************************************************
 *
 * function: Command_Cd_f
 *
 * description:
 * handles all CD commands from the console
 *
 **************************************************************************/
static void Command_Cd_f (void)
{
	const char *command;
	size_t ret, n;

	if (!cdaudio_started)
		return;

	if (COM_Argc() < 2)
	{
		CONS_Printf ("%s", M_GetText("cd [on] [off] [remap] [reset] [select]\n"
		"   [open] [info] [play <track>] [resume]\n"
		"   [stop] [pause] [loop <track>]\n"));
		return;
	}

	command = COM_Argv (1);

	if (!strncmp(command, "on", 2))
	{
		cdEnabled = SDL_TRUE;
		return;
	}

	if (!strncmp(command, "off", 3))
	{
		I_StopCD();
		cdEnabled = SDL_FALSE;
		return;
	}

	if (!strncmp(command, "select", 6))
	{
		INT32 newcddrive;
		newcddrive = atoi(COM_Argv(2));
		command = SDL_CDName(newcddrive);
		I_StopCD();
		cdEnabled = SDL_FALSE;
		SDL_CDClose(cdrom);
		cdrom = SDL_CDOpen(newcddrive);
		if (cdrom)
		{
			cdEnabled = SDL_TRUE;
			CONS_Printf(M_GetText("Opened CD-ROM drive %s\n"), command ? command : COM_Argv(2));
		}
		else CONS_Printf(M_GetText("Couldn't open CD-ROM drive %s: %s\n"), command ? command : COM_Argv(2), SDL_GetError());
		return;
	}

	if (!strncmp(command, "remap", 5))
	{
		ret = COM_Argc() - 2;
		if (ret <= 0)
		{
			for (n = 1; n < MAX_CD_TRACKS; n++)
			{
				if (cdRemap[n] != n)
					CONS_Printf("  %s -> %u\n", sizeu1(n), cdRemap[n]);
			}
			return;
		}
		for (n = 1; n <= ret; n++)
			cdRemap[n] = (Uint8)atoi(COM_Argv (n+1));
		return;
	}

	if (!strncmp(command, "reset", 5))
	{
		if (!cdrom) return;
		cdEnabled = SDL_TRUE;
		I_StopCD();
		for (n = 0; n < MAX_CD_TRACKS; n++)
			cdRemap[n] = (Uint8)n;
		CDAudio_GetAudioDiskInfo();
		return;
	}

	if (!cdValid)
	{
		if (CDAudio_GetAudioDiskInfo()==-1 && !cdValid)
		{
			CONS_Printf("%s", M_GetText("No CD in drive\n"));
			return;
		}
	}

	if (!strncmp(command, "open", 4))
	{
		I_EjectCD();
		cdValid = SDL_FALSE;
		return;
	}

	if (!strncmp(command, "info", 4))
	{
		CONS_Printf(M_GetText("%u tracks\n"), maxTrack);
		if (cdPlaying)
			CONS_Printf(M_GetText("Currently %s track %u\n"), playLooping ? M_GetText("looping") : M_GetText("playing"), playTrack);
		else if (wasPlaying)
			CONS_Printf(M_GetText("Paused %s track %u\n"), playLooping ? M_GetText("looping") : M_GetText("playing"), playTrack);
		CONS_Printf(M_GetText("Volume is %d\n"), cdvolume);
		return;
	}

	if (!strncmp(command, "play", 4))
	{
		I_PlayCD((UINT8)atoi(COM_Argv (2)), SDL_FALSE);
		return;
	}

	if (!strncmp(command, "loop", 4))
	{
		I_PlayCD((UINT8)atoi(COM_Argv (2)), true);
		return;
	}

	if (!strncmp(command, "stop", 4))
	{
		I_StopCD();
		return;
	}
	if (!strncmp(command, "pause", 5))
	{
		I_PauseCD();
		return;
	}

	if (!strncmp(command, "resume", 6))
	{
		I_ResumeCD();
		return;
	}

	CONS_Printf(M_GetText("Invalid CD command \"CD %s\"\n"), COM_Argv(1));
}