1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
////////////////////////////////////////////////////////////////////////////////////////
//
// Nestopia - NES/Famicom emulator written in C++
//
// Copyright (C) 2003-2008 Martin Freij
//
// This file is part of Nestopia.
//
// Nestopia 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.
//
// Nestopia 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 Nestopia; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
////////////////////////////////////////////////////////////////////////////////////////
#include "NstAssert.hpp"
#include "NstZlib.hpp"
#ifndef NST_NO_ZLIB
#ifdef NST_WIN32
#if NST_MSVC >= 800
#define ZEXPORT __stdcall
#else
#define ZLIB_WINAPI
#endif
#endif
#include "zlib.h"
#endif
namespace Nes
{
namespace Core
{
namespace Zlib
{
#ifndef NST_NO_ZLIB
ulong NST_CALL Compress(const byte* src,ulong srcSize,byte* dst,ulong dstSize,Compression compression)
{
if (srcSize && dstSize)
{
NST_ASSERT( src && dst );
int result;
if (compression == BEST_COMPRESSION)
result = compress2( dst, &dstSize, src, srcSize, Z_BEST_COMPRESSION );
else
result = compress( dst, &dstSize, src, srcSize );
if (result == Z_OK)
return dstSize;
}
return 0;
}
ulong NST_CALL Uncompress(const byte* src,ulong srcSize,byte* dst,ulong dstSize)
{
if (srcSize && dstSize)
{
NST_ASSERT( src && dst );
if (uncompress( dst, &dstSize, src, srcSize ) == Z_OK)
return dstSize;
}
return 0;
}
#else
ulong NST_CALL Compress(const byte*,ulong,byte*,ulong,Compression)
{
return 0;
}
ulong NST_CALL Uncompress(const byte*,ulong,byte*,ulong)
{
return 0;
}
#endif
}
}
}
|