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)); }
/************************************************************************** * * 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)); }