#include "AllTools.h"

videoInfo GetVideoInfo(void)
{
videoInfo	theScreen;
short		count;

theScreen.isVideo = TRUE;
theScreen.screenBase = GetScrnBase();
theScreen.resolutionX = GetScrnWidth();
theScreen.resolutionY = GetScrnHeight();
theScreen.rowBytes = GetScrnRowBytes();
theScreen.bitsPerPixel = GetScrnDepth();
theScreen.screenRect = GetScreenRect();

for (count = 0; count < 64; count ++)
{
	theScreen.BitDepthPossible[count] = gotDepth(count);
}

return theScreen;
}

Ptr				GetScrnBase(void)
{
GDHandle		theGDHandle;
GDevice			theGDDevice;
PixMapHandle	thePixMapHandle;
PixMap			thePixMap;
Ptr				ScrnBase;

theGDHandle  = GetTheGDevice();
theGDDevice  = **(theGDHandle);
thePixMapHandle = theGDDevice.gdPMap;
thePixMap = **(thePixMapHandle);
ScrnBase = thePixMap.baseAddr;

return ScrnBase;
}

short 			GetScrnWidth(void)
{
GDHandle		theGDHandle;
GDevice			theGDDevice;
PixMapHandle	thePixMapHandle;
PixMap			thePixMap;	
Rect			theScreenRect;
short			theWidth;

theGDHandle  = GetTheGDevice();
theGDDevice  = **(theGDHandle);
thePixMapHandle = theGDDevice.gdPMap;
thePixMap = **(thePixMapHandle);
theScreenRect = thePixMap.bounds;
theWidth = theScreenRect.right - theScreenRect.left;

return theWidth;
}

short			GetScrnHeight(void)
{
GDHandle		theGDHandle;
GDevice			theGDDevice;
PixMapHandle	thePixMapHandle;
PixMap			thePixMap;	
Rect			theScreenRect;
short			theHeight;

theGDHandle  = GetTheGDevice();
theGDDevice  = **(theGDHandle);
thePixMapHandle = theGDDevice.gdPMap;
thePixMap = **(thePixMapHandle);
theScreenRect = thePixMap.bounds;
theHeight = theScreenRect.bottom - theScreenRect.top;

return theHeight;
}

short 			GetScrnDepth(void)
{
GDHandle		theGDHandle;
GDevice			theGDDevice;
PixMapHandle	thePixMapHandle;
PixMap			thePixMap;
short			theDepth;

theGDHandle  = GetTheGDevice();
theGDDevice  = **(theGDHandle);
thePixMapHandle = theGDDevice.gdPMap;
thePixMap = **(thePixMapHandle);
theDepth = thePixMap.pixelSize;

return theDepth;
}

Boolean gotDepth(short count)
{
GDHandle		theGDHandle;
short			theMode;

theGDHandle  = GetTheGDevice();

theMode = HasDepth(theGDHandle, count, 1, 1);

return (theMode > 0);
}

short 			GetScrnRowBytes(void)
{
GDHandle		theGDHandle;
GDevice			theGDDevice;
PixMapHandle	thePixMapHandle;
PixMap			thePixMap;
short			rowBytes;

theGDHandle  = GetTheGDevice();
theGDDevice  = **(theGDHandle);
thePixMapHandle = theGDDevice.gdPMap;
thePixMap = **(thePixMapHandle);
rowBytes = (short)thePixMap.rowBytes;
rowBytes = (short)((unsigned long)rowBytes & 4093);

return rowBytes;
}

unsigned char	GetVolume(void)
{
return LMGetSdVolume();
}

void 			SetVolume(unsigned char SdVolumeValue)
{
LMSetSdVolume(SdVolumeValue);
}

StringPtr 		GetFinderName(void)
{
return LMGetFinderName();
}

void 			SetFinderName(StringPtr FinderNameValue)
{
LMSetFinderName(FinderNameValue);
}

Ptr				GetTheA5(void)
{
return LMGetCurrentA5();
}

void 			SetTheA5(Ptr CurrentA5Value)
{
LMSetCurrentA5(CurrentA5Value);
}

GDHandle GetTheGDevice(void)
{
return LMGetTheGDevice();
}

Rect			GetScreenRect(void)
{
	return qd.screenBits.bounds;
}