Path: blob/main/misc/emulator/xnes/snes9x/jma/winout.h
28798 views
/*1Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net )2Copyright (C) 2001-4 Igor Pavlov ( http://www.7-zip.org )34This library is free software; you can redistribute it and/or5modify it under the terms of the GNU Lesser General Public6License version 2.1 as published by the Free Software Foundation.78This library is distributed in the hope that it will be useful,9but WITHOUT ANY WARRANTY; without even the implied warranty of10MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU11Lesser General Public License for more details.1213You should have received a copy of the GNU Lesser General Public14License along with this library; if not, write to the Free Software15Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA16*/1718#ifndef __STREAM_WINDOWOUT_H19#define __STREAM_WINDOWOUT_H2021#include "iiostrm.h"2223namespace NStream {24namespace NWindow {2526// m_KeepSizeBefore: how mach BYTEs must be in buffer before m_Pos;27// m_KeepSizeAfter: how mach BYTEs must be in buffer after m_Pos;28// m_KeepSizeReserv: how mach BYTEs must be in buffer for Moving Reserv;29// must be >= aKeepSizeAfter; // test it3031class COut32{33BYTE *m_Buffer;34UINT32 m_Pos;35UINT32 m_PosLimit;36UINT32 m_KeepSizeBefore;37UINT32 m_KeepSizeAfter;38UINT32 m_KeepSizeReserv;39UINT32 m_StreamPos;4041UINT32 m_WindowSize;42UINT32 m_MoveFrom;4344ISequentialOutStream *m_Stream;4546virtual void MoveBlockBackward();47public:48COut(): m_Buffer(0), m_Stream(0) {}49virtual ~COut();50void Create(UINT32 aKeepSizeBefore,51UINT32 aKeepSizeAfter, UINT32 aKeepSizeReserv = (1<<17));52void SetWindowSize(UINT32 aWindowSize);5354void Init(ISequentialOutStream *aStream, bool aSolid = false);55HRESULT Flush();5657UINT32 GetCurPos() const { return m_Pos; }58const BYTE *GetPointerToCurrentPos() const { return m_Buffer + m_Pos;};5960void CopyBackBlock(UINT32 aDistance, UINT32 aLen)61{62if (m_Pos >= m_PosLimit)63MoveBlockBackward();64BYTE *p = m_Buffer + m_Pos;65aDistance++;66BYTE *p2 = p - aDistance;67for(UINT32 i = 0; i < aLen; i++)68p[i] = p2[i];69m_Pos += aLen;70}7172void PutOneByte(BYTE aByte)73{74if (m_Pos >= m_PosLimit)75MoveBlockBackward();76m_Buffer[m_Pos++] = aByte;77}7879BYTE GetOneByte(UINT32 anIndex) const80{81return m_Buffer[m_Pos + anIndex];82}8384BYTE *GetBuffer() const { return m_Buffer; }85};8687}}8889#endif909192