engine/core/bitTables.cc
2024-01-07 04:36:33 +00:00

28 lines
898 B
C++

//-----------------------------------------------------------------------------
// V12 Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#include "Core/BitTables.h"
bool BitTables::mTablesBuilt = false;
S8 BitTables::mHighBit[256];
S8 BitTables::mWhichOn[256][8];
S8 BitTables::mNumOn[256];
static BitTables sBuildTheTables; // invoke ctor first-time work
BitTables::BitTables()
{
if(! mTablesBuilt){
// This code only happens once - it relies on the tables being clear.
for( U32 byte = 0; byte < 256; byte++ )
for( U32 bit = 0; bit < 8; bit++ )
if( byte & (1 << bit) )
mHighBit[byte] = (mWhichOn[byte][mNumOn[byte]++] = bit) + 1;
mTablesBuilt = true;
}
}