#ifndef ATRMEMORYIMAGE_H
#define ATRMEMORYIMAGE_H

/*
   AtrMemoryImage.h - access ATR images in RAM.

   Copyright (C) 2002 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.
*/

#include "AtrImage.h"

class AtrMemoryImage : public AtrImage {
public:

	AtrMemoryImage();

	virtual ~AtrMemoryImage();

	virtual int CreateImage(EDiskFormat format);
	virtual int CreateImage(ESectorLength density, size_t sectors);
	virtual int CreateImage(ESectorLength density, size_t sectorsPerTrack, size_t tracks, size_t sides);

	void FreeImageData();

	int ReadImageFromFile(const char* filename);
	int WriteBackImageToFile() const;
	int WriteImageToFile(const char* filename) const;

	int ReadSector(size_t sector,
		       unsigned char* buffer,
		       size_t buffer_length) const;

	int WriteSector(size_t sector,
		       const unsigned char* buffer,
		       size_t buffer_length);

	bool Changed() const;

	virtual bool IsAtrMemoryImage() const;

protected:

private:

	typedef AtrImage super;

	unsigned char *fData;

	mutable bool fChanged;

};

inline bool AtrMemoryImage::Changed() const
{
	return fChanged;
}
#endif
