/*============================================================================*/
/*  Res.c: By Kevin T. Seghetti 					      */
/*  Change screen resolutions						      */
/*============================================================================*/

#include "equates.h"
#include <functions.h>
#include <exec/types.h>
#include <intuition/intuition.h>

#include <graphics/gfx.h>
#include "iff/jiff.h"

/*----------------------------------------------------------------------------*/

extern struct NewScreen NewMPaintScreen;
extern struct NewWindow NewPaintWindow;
/*extern struct Window *MPaintWindow,*ToolWindow,*PaletteWindow,*CoordWindow,*HistWindow; */
extern int MaxColor;
extern SHORT PaintWidth,PaintHeight;
extern UBYTE *TempPlane;
extern struct Menu *MPaintMenu;

/*============================================================================*/

ChangeRes(Res)
int Res;
{
    FLAG Tool,Palette,Coord;

    ShutDownOldScreen();

    if(TempPlane)
	FreeRaster(TempPlane,(long)PaintWidth,(long)PaintHeight);
    TempPlane = NULL;

    switch(Res)
     {
	case 0: 			/* 320x200 */
	    NewMPaintScreen.ViewModes = NULL;
	    PaintWidth = 320;
	    PaintHeight = 200;
	    break;
	case 1: 			/* 320x400 */
	    NewMPaintScreen.ViewModes = LACE;
	    PaintWidth = 320;
	    PaintHeight = 400;
	    break;
	case 2: 			/* 640x200 */
	    NewMPaintScreen.ViewModes = HIRES;
	    PaintWidth = 640;
	    PaintHeight = 200;
	    break;
	case 3: 			/* 640x400 */
	    NewMPaintScreen.ViewModes = LACE|HIRES;
	    PaintWidth = 640;
	    PaintHeight = 400;
	    break;
     }

    NewMPaintScreen.Width = PaintWidth;
    NewMPaintScreen.Height = PaintHeight;

    if(PaintWidth > 320)
     {
	MPaintMenu->NextMenu->NextMenu->NextMenu->FirstItem->Flags &= ~ITEMENABLED;
	if(MaxColor > 16)
	 {
	    MaxColor = 16;
	    NewMPaintScreen.Depth = 4;
	 }
     }
    else
	MPaintMenu->NextMenu->NextMenu->NextMenu->FirstItem->Flags |= ITEMENABLED;

    SetUpNewScreen();
}


