/* ScummVM - Graphic Adventure Engine * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT * file distributed with this source distribution. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ /************************************************************************** * 様様様様様様様様様様様様様様様様様 * * Nayma Software srl * * e -= We create much MORE than ALL =- * * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * * .d" d$$$$$b "b. * * .z$* d$$$$$$$L ^*$c. * * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * * ^*$b 4$$$$$$$$$F .d$*" * * ^$$. 4$$$$$$$$$F .$P" Module: GfxCore.CPP.......... * * *$. '$$$$$$$$$ 4$P 4 * * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * * z$" "" #$F^ "" '$c * * z$$beu .ue=" $ "=e.. .zed$$c * * "#$e z$*" . `. ^*Nc e$"" * * "$$". .r" ^4. .^$$" * * ^.@*"6L=\ebu^+C$"*b." * * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * * * * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * * * **************************************************************************/ #ifndef TONY_GFXCORE_H #define TONY_GFXCORE_H #include "common/system.h" #include "tony/utils.h" namespace Tony { /****************************************************************************\ * Prototipi di classi \****************************************************************************/ // Nome della classe Albero genealogico Astratto? class RMGfxTask; // Si class RMGfxTaskSetPrior; // Task Si class RMGfxBuffer; // class RMGfxSourceBuffer; // TaskP+[Buffer] Si class RMGfxTargetBuffer; // [Buffer] class RMGfxSourceBufferPal; // Source Si class RMGfxSourceBuffer4; // SourcePal class RMGfxSourceBuffer8; // SourcePal class RMGfxSourceBuffer16; // Source class RMGfxWoodyBuffer; // Source16+Target class RMGfxClearTask; // Task /** * Graphics buffer */ class RMGfxBuffer { protected: int m_dimx, m_dimy; byte *m_buf; byte *m_origBuf; bool m_bUseDDraw; public: RMGfxBuffer(); RMGfxBuffer(int dimx, int dimy, int nBpp, bool bUseDDraw = false); virtual ~RMGfxBuffer(); // Attributes int Dimx() { return m_dimx; } int Dimy() { return m_dimy; } // Creation virtual void Create(int dimx, int dimy, int nBpp, bool bUseDDraw = false); virtual void Destroy(void); // Buffer access void Lock(void); void Unlock(void); // These are valid only if the buffer is locked operator byte *(); operator void *(); // Getting the offset for a given Y position void OffsetY(int nLines, int nBpp); }; /** * Graphics primitive */ class RMGfxPrimitive { public: RMGfxTask *m_task; protected: RMRect m_src; RMRect m_dst; bool m_bStretch; byte m_bFlag; public: RMGfxPrimitive() { m_bFlag = 0; m_task = NULL; m_src.SetEmpty(); m_dst.SetEmpty(); } RMGfxPrimitive(RMGfxTask *task) { m_task = task; m_bFlag = 0; } RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMRect &dst) { m_task = task; m_src = src; m_dst = dst; m_bFlag = 0; m_bStretch = (src.Width() != dst.Width() || src.Height() != dst.Height()); } RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMRect &dst) { m_task = task; m_src.TopLeft() = src; m_dst = dst; m_bFlag = 0; } RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMPoint &dst) { m_task = task; m_src.TopLeft() = src; m_dst.TopLeft() = dst; m_bFlag = 0; } RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMPoint &dst) { m_task = task; m_src = src; m_dst.TopLeft() = dst; m_bFlag = 0; } RMGfxPrimitive(RMGfxTask *task, const RMRect &dst) { m_task = task; m_dst = dst; m_src.SetEmpty(); m_bFlag = 0; } RMGfxPrimitive(RMGfxTask *task, const RMPoint &dst) { m_task = task; m_dst.TopLeft() = dst; m_src.SetEmpty(); m_bFlag = 0; } virtual ~RMGfxPrimitive() { } void SetFlag(byte bFlag) { m_bFlag=bFlag; } void SetTask(RMGfxTask *task) { m_task = task; } void SetSrc(const RMRect &src) { m_src = src; } void SetSrc(const RMPoint &src) { m_src.TopLeft() = src; } void SetDst(const RMRect &dst) { m_dst = dst; } void SetDst(const RMPoint &dst) { m_dst.TopLeft() = dst; } void SetStrecth(bool bStretch) { m_bStretch = bStretch; } bool HaveDst() { return !m_dst.IsEmpty(); } RMRect &Dst() { return m_dst; } bool HaveSrc() { return !m_src.IsEmpty(); } RMRect &Src() { return m_src; } // Flags bool IsFlipped() { return m_bFlag&1; } // Duplicate virtual RMGfxPrimitive* Duplicate() { return new RMGfxPrimitive(*this); } }; /** * Graphic drawing task */ class RMGfxTask { protected: int m_nPrior; int m_nInList; public: // Costruttore standard RMGfxTask(); virtual ~RMGfxTask() { } virtual int Priority(); virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) = 0; virtual bool RemoveThis(); // Registration virtual void Register(void) { m_nInList++; } virtual void Unregister(void) { m_nInList--; assert(m_nInList >= 0); } }; /** * Graphic drawing with priority */ class RMGfxTaskSetPrior : public RMGfxTask { public: virtual ~RMGfxTaskSetPrior() { } void SetPriority(int nPrior); }; /** * Task that cleans the destination buffer */ class RMGfxClearTask : public RMGfxTask { public: virtual ~RMGfxClearTask() { } int Priority(); void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); bool RemoveThis(); }; /** * Task that draws a coloured box */ class RMGfxBox : public RMGfxTaskSetPrior { protected: uint16 wFillColor; public: virtual ~RMGfxBox() { } void SetColor(byte r, byte g, byte b); void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); bool RemoveThis(); }; /** * Buffer source for the design, which is a task. This is an abstract base. */ class RMGfxSourceBuffer : public virtual RMGfxBuffer, public RMGfxTaskSetPrior { public: // Carica i dati della surface a basso livello virtual int Init(uint32 resID, int dimx, int dimy, bool bLoadPalette = false); virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); virtual ~RMGfxSourceBuffer(); protected: virtual void PrepareImage(void); bool Clip2D(int &x1, int &y1, int &u, int &v, int &width, int &height, bool bUseSrc, RMGfxTargetBuffer *buf); void OffsetY(int nLines) { RMGfxBuffer::OffsetY(nLines,Bpp()); } public: virtual int Bpp() = 0; }; /** * 16-bit colour source */ class RMGfxSourceBuffer16 : public RMGfxSourceBuffer { protected: virtual void PrepareImage(void); bool m_bTrasp0; public: RMGfxSourceBuffer16(bool bUseTrasp = false); RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw = false); virtual ~RMGfxSourceBuffer16(); // Inizializzazione void Create(int dimx, int dimy, bool bUseDDraw = false); int Bpp(); virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; /** * Buffer source with palette */ class RMGfxSourceBufferPal : public RMGfxSourceBuffer { protected: // The size of the palette is (1<