/*========================================================================= FILENAME.CPP Author: Gary Liddon @ Created: Project: Purpose: Copyright (c) 1997 Climax Development Ltd ===========================================================================*/ #ifndef __TPAGE_HPP__ #define __TPAGE_HPP__ /*---------------------------------------------------------------------- Includes -------- */ /* Std Lib ------- */ #include /* Glib ---- */ #include /* Local ----- */ /*---------------------------------------------------------------------- Tyepdefs && Defines ------------------- */ /*---------------------------------------------------------------------- Structure defintions -------------------- */ struct POS_INFO { int MinXTp; /* Minimum x placeable within a Tpage */ int MaxXTp; /* Maximum x placeable within a Tpage */ int MinYTp; /* Minimum y placeable within a Tpage */ int MaxYTp; /* Maximum y placeable within a Tpage */ int MinX; /* Minimum global x */ int MaxX; /* Maximum global x */ int MinY; /* Minimum global y */ int MaxY; /* Maximum global y */ int XAlign; /* X Alignment */ int TpWidthPix; /* Width of each tpages for this rect */ }; /* Different Tpage Types --------------------- */ enum TPageType { TP_4= 0, TP_8, TP_16, TP_SCREEN, TP_PAL, TP_NUM_OF_TP_TYPES, }; /* A Rectangle in the Tpage ------------------------ */ class TPRect : public Rect { public: TPRect(void); TPRect(TPageType nType,int nW,int nH); TPRect(TPRect const & NewR) {MakeCopy(NewR);} void InitFromFrame(Frame const & Fr); void SetAlloced(bool nAlloced=true); bool SetRotate(bool Rot=true); void operator=(TPRect const & NewR) {MakeCopy(NewR);} bool operator< (TPRect const & R) const {return(GetId() TPRectVec; /* VRAM ---- */ typedef std::list TPRectList; typedef std::vector TPRectListVec; class VRAM : public GObject { public: VRAM(int nTpWidth=16,int nTpHeightInPixels=512); int GetNumOfItems(void); int GetNumOfUsedPages(); bool AllocVRAM(TPRect & OriginalRect); bool AllocVRAM(TPRectVec & RectVec,bool nRotateEveryEmpty,bool nBig2Little,bool nWiderThanHigher); TPRect const & GetVRAM(VHND hnd) const; TPRectVec & GetUsed(void) {return(Used);} TPRectVec & GetUnused(void) {return(Unused);} void Clear(int nTpWidth=-1,int nTpHeight=-1); void SetBig2Little(bool Val=true) { Big2Little=Val;} void SetRotateEveryEmpty(bool Val=true) { RotateEveryEmpty=Val;} bool CanRotate(TPRect & ThisRect); void getUnusedSpace(TPRectVec & unusedBoxes); protected: void PosFromTPrect(TPRect & ThisRect,POS_INFO & Pi); bool TryRect(TPRect & BlankRect,TPRect & ThisRect); TPRectListVec VecOfPages; bool TryNFit(TPRectList & TpList,TPRect & ThisRect); void AddEmpty(int x,int y,int w,int h); bool InColisionWithUsed(TPRect const & R); void InitEmpty(int vX,int vY,int W,int H); bool CheckValidAlloc(TPageType nType,int nW,int nH); int GetXAlign(TPageType nType); int GetMaxWidthTp(TPageType nType); void RemovedFromUnused(TPRect const & ThisRect); void AddToUsed(TPRect const & ThisRect); void RectFromTpRect(Rect & R,TPRect const & ThisRect); TPRect & NewItem(TPRectVec & TPRects); TPRect & NewUnused(void) { return(NewItem(Unused)); } TPRect & NewUsed(void) { return(NewItem(Used)); } TPRectVec Unused; TPRectVec Used; TPRect ErrorRect; int X,Y,W,H; int NumOfTPages; int TpWidth; int TpHeightInPixels; int VRAMWidthPages; int VRAMHeightPages; bool Big2Little; bool RotateEveryEmpty; bool WiderThanHigher; }; /* Error codes for VHND -------------------- */ enum { VHND_NULL = -1, }; /*---------------------------------------------------------------------- Globals ------- */ /* Vars ---- */ /* Data ---- */ /* Functions --------- */ void TestTPageStuff(void); /*---------------------------------------------------------------------- */ #endif /* __TPAGE_HPP__ */ /*=========================================================================== end */