////////////////////////////////////////////////////////////////////////////// // // 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. // ////////////////////////////////////////////////////////////////////////////// #include "screen.h" #include "resolution.h" #include "ca_pack.h" #include "ca_unpac.h" #include #include #include #include static void *Page(void *adr) { unsigned long a=(unsigned long)adr; return (void *)((a & 0xffffff00)+0x100); } Screen::Screen(const Screen& Same) : Res(Same.Res), AllocSize(BytesPerLine[Res]*ScreenHeight[Res]+254), AllocArea(new char[AllocSize]), location(Page(AllocArea)), Palette(new short[NumberOfColours[Res]]) { memcpy(location,Same.location,BytesPerLine[Res]*ScreenHeight[Res]); memcpy(Palette,Same.Palette,sizeof(Palette[0])*NumberOfColours[Res]); } Screen::Screen(Resolution res) : Res(res), AllocSize(BytesPerLine[Res]*ScreenHeight[Res]+254), AllocArea(new char[AllocSize]), location(Page(AllocArea)), Palette(new short[NumberOfColours[Res]]) { } Screen::Screen(short LinesAbove, short LinesBelow) : Res(Getrez()), AllocSize(BytesPerLine[Res]*(ScreenHeight[Res]+LinesAbove+LinesBelow)+254), AllocArea(new char[AllocSize]), location(Page(AllocArea)), Palette(new short[NumberOfColours[Res]]) { } Screen::Screen() : Res(Getrez()), AllocSize(BytesPerLine[Res]*ScreenHeight[Res]+254), AllocArea(new char[AllocSize]), location(Page(AllocArea)), Palette(new short[NumberOfColours[Res]]) { } Screen::Screen(char *At) { Res=Getrez(); AllocSize=0; AllocArea=0; if (At) { location=At; } else { location=Physbase(); } Palette=malloc(sizeof(Palette[0])*NumberOfColours[Res]); for (int i=0; i0; ignore--) CHECK(fread(&junk,sizeof(short),1,file)); CHECK(fread(location,1,BytesPerLine[Res]*ScreenHeight[Res],file)); fclose(file); return 1; } int Screen::SaveDegas(const char *filename) { FILE *file; short res; file=fopen(filename,"wb"); if (!file) return 0; res=Res; CHECK(fwrite(&res,sizeof(short),1,file)); CHECK(fwrite(Palette,sizeof(short),NumberOfColours[Res],file)); if (NumberOfColours[Res] < 16) { short junk=0; for (int ignore=16-NumberOfColours[Res]; ignore; ignore--) CHECK(fwrite(&junk,sizeof(short),1,file)); } CHECK(fwrite(location,1,BytesPerLine[Res]*ScreenHeight[Res],file)); fclose(file); return 1; } PaletteChange::PaletteChange() : ncols(16), col(new short[ncols]) { for (int i=0; i