#include "mcdp.h"

/**
 * Copyright (C) 2001-2006 Tino Reichardt
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License Version 2, as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

void mcdp_update(void)
{
	if (cd->ds != DS_OKAY) {

		/* reset to some useful defaults */
		cd->repeat=R_OFF;
		cd->titles=0;
		cd->as=AS_NOSTATUS;
		cd->ds=DS_NODISC;
		cd->xs=XS_NONE;
		cd->db=DB_NOENT;

		/* check new disc status */
		cd->xs=XS_READING; show_status();
		cd_getstatus();
		if (cd->ds == DS_OKAY) {
			cd_initdisc();
			set(cd->updates, U_ALL);
		}
		cd->xs=XS_NONE; show_status();
	}

	/* get state changes */
	cd_getstatus();

	if (isset(cd->updates, U_INIT))     show_init();
	if (isset(cd->updates, U_DEVICE))   show_device();
	if (isset(cd->updates, U_STATUS))   show_status();
	if (isset(cd->updates, U_METHOD))   show_method();
	if (isset(cd->updates, U_REPEAT))   show_repeat();
	if (isset(cd->updates, U_VOLUME))   show_volume();
	if (isset(cd->updates, U_TIME))     show_time();
	if (isset(cd->updates, U_DBASE))    show_dbase();
	if (isset(cd->updates, U_MAIN))     show_tracks();
	if (isset(cd->updates, U_TRACKMOD)) show_trackmod();

	cd->updates=0; /* we updated! */

	return;
}

