//////////////////////////////////////////////////////////////////////////////
//
//  This file is part of the Atari Machine Specific Library,
//  and is Copyright 1992 by Warwick W. Allison.
//
//  You are free to copy and modify these sources, provided you acknoledge
//  the origin by retaining this notice, and adhere to the conditions
//  described in the file COPYING.
//
//////////////////////////////////////////////////////////////////////////////

#ifndef _Screen_h
#define _Screen_h
//
//  Support for direct Atari screens.
//
//  Screens are memory areas (possibly extending above and below the
//  visible area) with palettes.  Palettes are fairly independent, but
//  are included here, because most picture file formats include the
//  palette in the file.
//
//  One good thing.  Palette is spelt correctly!
//
//  The LoadDegas and SaveDegas routines support TT resolutions as
//  logical extensions (all still have 16 colours, except TTLow which
//  has 256 colours).  LoadCrackArt and SaveCrackArt routines also
//  support TT resolutions logically.
//
//  Note that CrackArt is a compressed format.
//
//  Recommended suffixes:
//
//   CrackArt  Degas  Resolution  Getrez()
//    CA1       PI1    STLow       0
//    CA2       PI2    STMedium    1
//    CA3       PI3    STHigh      2
//    CA8       PI8    TTLow       7
//    CA5       PI5    TTMedium    4
//    CA6       PI6    TTHigh      5
//
//   ie.
//     "CA"+('1'+Resolution)
//     "PI"+('1'+Resolution)
//

#include "resolution.h"
#include "osbind.h"

#define DESKSCREEN ((char *)0)


class Screen {
private:
	char *AllocArea;
	long AllocSize;
	char *location;
	Resolution Res;
	short *Palette;

public:
	Screen(const Screen&);	// Copy image & Palette
	Screen(Resolution);
	Screen(Resolution, short LinesAbove, short LinesBelow);
	Screen(short LinesAbove, short LinesBelow);
	Screen();		// In current resolution
	Screen(char *At); // DESKSCREEN = current screen, else specify desired location
	~Screen();

	void Clear();

	int LoadDegas(const char *);
	int SaveDegas(const char *);
	int LoadDegasPalette(const char *);
	int LoadCrackArtPalette(const char *);
	int LoadCrackArt(const char *);
	int SaveCrackArt(const char *, int Compression=3);
	// Compression 0 = minimal compression attempt
	// Compression 8 = maximal compression attempt

	void ShowPalette();
	void Show();	// Physically show
	void Use();		// Logically activate (for VDI/BIOS writes)

	short* Colour(); // Returns array of RGB

	char *Location();
	Resolution Rez();
};

class PaletteChange // Resolution sensitive
{
public:
	PaletteChange();
	~PaletteChange();

private:
	short *col;
	short ncols;
};

// Always inline:

inline	char* Screen::Location() { return location; }
inline	Resolution Screen::Rez() { return Res; }
inline	void Screen::ShowPalette() { Setpallete(Palette); }
inline	void Screen::Show() { Setscreen(-1,location,-1); }
inline	void Screen::Use() { Setscreen(location,-1,-1); }
inline 	short* Screen::Colour() { return Palette; }


#endif
