//////////////////////////////////////////////////////////////////////////////
//
// Asura_Platform_Huffman.cpp
//
// Copyright (c) 2004 Rebellion. All rights reserved.
//
//////////////////////////////////////////////////////////////////////////////

// I N C L U D E S ///////////////////////////////////////////////////////////

#include "Core/Asura.h"

// Engine independent.
#include "ChunkSystem/Asura_Huffman.h"
#ifdef ASURA_ASSERT
#include "FileAccess/Asura_FileAccess.h"
#endif

// Engine platform-specific.
#include "Core/Asura_PlatformBasics.h"

// C L A S S   I M P L E M E N T A T I O N S /////////////////////////////////

//
// Asura_Huffman_Decoder
//

void Asura_Huffman_Decoder::Platform_AllocTableBfr( void )
{
#ifdef ASURA_ASSERT
    // This will break if more than one compressed file is open
    // simultaneously. We could support up to two (since each uses 8192 bytes
    // of SPR) but I haven't bothered simply because it's currently
    // unnecessary.
	// SNH: changed from '== 1' to '<= 1' since decompressing from buffer has no open files.
    Asura_Assert( Asura_FileAccess::GetNumOpenCompressedFiles() <= 1, "" );
#endif

    m_piTable = (Asura_PS2_SPR_Alloc(0, (ASURA_HUFFMAN_TABLE_SIZE + 3) >> 2))->i32s;
}

void Asura_Huffman_Decoder::Platform_DeallocTableBfr( void )
{
    Asura_PS2_SPR_Dealloc( reinterpret_cast<Asura_PS2_QW*>(m_piTable) );
}
