Example #1
0
void AudioEngine::InitializeTables()
{
    _wavetableMemory = new u8[WAVETABLE_SIZE * NESAUDIO_NUM_WAVETABLES];
    INIT_WAVETABLE_PTR(NESAUDIO_PULSE_DUTYCYCLE_12_5);
    INIT_WAVETABLE_PTR(NESAUDIO_PULSE_DUTYCYCLE_25);
    INIT_WAVETABLE_PTR(NESAUDIO_PULSE_DUTYCYCLE_25N);
    INIT_WAVETABLE_PTR(NESAUDIO_PULSE_DUTYCYCLE_50);
    INIT_WAVETABLE_PTR(NESAUDIO_TRIANGE);

    GenerateTable(_pulseMinFreq, _pulseMaxFreq, PulseFourierFunction50, _wavetables[NESAUDIO_PULSE_DUTYCYCLE_50]);
    GenerateTable(_triangleMinFreq, _triangleMaxFreq, TriangleFourierFunction, _wavetables[NESAUDIO_TRIANGE]);
    GenarateOtherPulseTables();
}
Example #2
0
void CAMRBitReorder::ToNetwork(ULONG32 frameType, UINT8* pInOut)
{
    HX_ASSERT(frameType < 8);
    
    if (!m_pToNetworkTbl[frameType])
	GenerateTable(frameType);

    ReorderBits(CAMRFrameInfo::FrameBits(m_flavor, frameType),
		m_pToNetworkTbl[m_flavor][frameType], 
		pInOut);
}
Example #3
0
PrimesTable::PrimesTable():
_DataFile("primestable.dat"),
_Offset(0),
_TotalSize(0),
_TableIndex(0),
_Bitv(100001)
{
  PATHTOKENIZER(Pathtok_, "PATH");
  size_t Max_ = Pathtok_.Max();
  size_t i;

  char* AbsPath_ = new_char_array(300 + strlen(_DataFile), _DataFile);    
  _File.open(AbsPath_, ios::in | ios::binary);
  
  for (i = 0; !_File.good() && i < Max_; i++)
  {
    strcpy(AbsPath_, Pathtok_[i]);
    strcat(AbsPath_, Pathtok_.DirSeparator());
    strcat(AbsPath_, _DataFile);
    _File.clear();
    _File.open(AbsPath_, ios::in | ios::binary);
  }
  
  if (!_File.good())
  {
    _File.open(_DataFile, ios::out | ios::in | ios::binary);

    if (_File.good())
    {
      _Bitv.BinaryWrite(_File);
      _File.write((char*)(&_TotalSize), sizeof(long));
      _Offset = _File.tellp();
      GenerateTable();
    }
  }
  else
  {
    _Bitv.BinaryRead(_File);
    _File.read((char*)(&_TotalSize), sizeof(long));
    _Offset = _File.tellg();    
    _File.seekg(_Offset);
  }

  ::DeleteArray(AbsPath_);  
}
Example #4
0
void GameTable::Init()
{
    ClearTable();

    score = 0;
    experience = 0;
    level = 0;
    expToLevelUp = baseExpToLevelUp;
    ended = false;
    
    // It will be on a Running state
    state = GameTableState::Running;
    
    // Generate the table
    GenerateTable();
    //UpdateTable();

    // Calculate all linked blocks
    CalcLinkedBlocks();

    // Reset timer
    timer->start();
}
Example #5
0
namespace {
	template<unsigned kRoundT, std::uint32_t kRegT>
	struct Generator
		: std::integral_constant<std::uint32_t, Generator<kRoundT + 1, (kRegT >> 1) ^ ((kRegT & 1) ? 0xEDB88320 : 0)>::value>
	{ };
	template<std::uint32_t kRegT>
	struct Generator<8, kRegT>
		: std::integral_constant<std::uint32_t, kRegT>
	{ };

	template<std::uint32_t ...kIndices>
	constexpr Array<std::uint32_t, sizeof...(kIndices)> GenerateTable(const std::integer_sequence<std::uint32_t, kIndices...> &) noexcept {
		return { Generator<0, kIndices>::value... };
	}

	constexpr auto kCrcTable = GenerateTable(std::make_integer_sequence<std::uint32_t, 256>());
}

Crc32OutputStream::~Crc32OutputStream(){ }

void Crc32OutputStream::X_Initialize() noexcept {
	x_u32Reg = static_cast<std::uint32_t>(-1);
}
void Crc32OutputStream::X_Update(const std::uint8_t (&abyChunk)[8]) noexcept {
	auto u64Word = LoadLe(reinterpret_cast<const std::uint64_t *>(abyChunk)[0]);
	for(unsigned uIndex = 0; uIndex < sizeof(u64Word); ++uIndex){
		const unsigned uLow = static_cast<unsigned char>(u64Word);
		u64Word >>= 8;
		x_u32Reg = kCrcTable[(x_u32Reg ^ uLow) & 0xFF] ^ (x_u32Reg >> 8);
	}
}