/*
   DiskManager - collection of helper routines to manage disk images
   and load/unload them into the SIO server (SIOManager)

   Copyright (C) 2003 Matthias Reichl <hias@horus.com>

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   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.
*/

#ifndef DISKMANAGER_H
#define DISKMANAGER_H

#include "SIOManager.h"
#include "AtrImage.h"

class DiskManager {
public:
	DiskManager();
	~DiskManager();

	enum {eMinDriveNumber=1, eMaxDriveNumber=8};

	enum {eSIODriveBase=0x30};

	/* floppy disk functions: */
	int LoadAtrMemoryImage(int driveno, const char* filename);
	int CreateAtrMemoryImage(int driveno, EDiskFormat format);
	int CreateAtrMemoryImage(int driveno, ESectorLength density, size_t sectors);
	int WriteAtrMemoryImage(int driveno, const char* filename);
	int UnloadAtrImage(int driveno);
	int SetWriteProtectImage(int driveno, bool on);
	int WriteBackImagesIfChanged();
	const char* GetImageFilename(int driveno) const;
	int ExchangeDrives(int drive1, int drive2);
	bool DriveInUse(int driveno) const;
	bool DriveIsWriteProtected(int driveno) const;
	bool DriveIsChanged(int driveno) const;
	size_t GetDriveImageSize(int driveno) const;
	bool DriveNumberOK(int driveno) const;

	int SetUseHighSpeed(bool);
	bool GetUseHighSpeed() const;

	int DoServing(int otherReadPollDevice=-1);

	SIOManager& GetSIOManager();
	SIOWrapper& GetSIOWrapper();

private:

	SIOWrapper fSIOWrapper;
	SIOManager fSIOManager;

	bool fUseHighSpeed;
};

inline SIOManager& DiskManager::GetSIOManager()
{
	return fSIOManager;
}

inline SIOWrapper& DiskManager::GetSIOWrapper()
{
	return fSIOWrapper;
}

inline bool DiskManager::GetUseHighSpeed() const
{
	return fUseHighSpeed;
}
#endif
