コード例 #1
0
ファイル: SpookyHash.cpp プロジェクト: Abioy/folly
// add a message fragment to the state
void SpookyHash::Update(const void *message, size_t length)
{
    uint64_t h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11;
    size_t newLength = length + m_remainder;
    uint8_t  remainder;
    union
    {
        const uint8_t *p8;
        uint64_t *p64;
        size_t i;
    } u;
    const uint64_t *end;

    // Is this message fragment too short?  If it is, stuff it away.
    if (newLength < sc_bufSize)
    {
        memcpy(&((uint8_t *)m_data)[m_remainder], message, length);
        m_length = length + m_length;
        m_remainder = (uint8_t)newLength;
        return;
    }

    // init the variables
    if (m_length < sc_bufSize)
    {
        h0=h3=h6=h9  = m_state[0];
        h1=h4=h7=h10 = m_state[1];
        h2=h5=h8=h11 = sc_const;
    }
    else
    {
        h0 = m_state[0];
        h1 = m_state[1];
        h2 = m_state[2];
        h3 = m_state[3];
        h4 = m_state[4];
        h5 = m_state[5];
        h6 = m_state[6];
        h7 = m_state[7];
        h8 = m_state[8];
        h9 = m_state[9];
        h10 = m_state[10];
        h11 = m_state[11];
    }
    m_length = length + m_length;

    // if we've got anything stuffed away, use it now
    if (m_remainder)
    {
        uint8_t prefix = sc_bufSize-m_remainder;
        memcpy(&(((uint8_t *)m_data)[m_remainder]), message, prefix);
        u.p64 = m_data;
        Mix(u.p64, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
        Mix(&u.p64[sc_numVars], h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
        u.p8 = ((const uint8_t *)message) + prefix;
        length -= prefix;
    }
    else
    {
        u.p8 = (const uint8_t *)message;
    }

    // handle all whole blocks of sc_blockSize bytes
    end = u.p64 + (length/sc_blockSize)*sc_numVars;
    remainder = (uint8_t)(length-((const uint8_t *)end-u.p8));
    if (ALLOW_UNALIGNED_READS || (u.i & 0x7) == 0)
    {
        while (u.p64 < end)
        {
            Mix(u.p64, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
            u.p64 += sc_numVars;
        }
    }
    else
    {
        while (u.p64 < end)
        {
            memcpy(m_data, u.p8, sc_blockSize);
            Mix(m_data, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
            u.p64 += sc_numVars;
        }
    }

    // stuff away the last few bytes
    m_remainder = remainder;
    memcpy(m_data, end, remainder);

    // stuff away the variables
    m_state[0] = h0;
    m_state[1] = h1;
    m_state[2] = h2;
    m_state[3] = h3;
    m_state[4] = h4;
    m_state[5] = h5;
    m_state[6] = h6;
    m_state[7] = h7;
    m_state[8] = h8;
    m_state[9] = h9;
    m_state[10] = h10;
    m_state[11] = h11;
}
コード例 #2
0
VReadResult_e VisDataHistory_cl<dataType, iHistoryLength, Mix>::Interpolate (dataType* out_pData, __int64 iInterpolationPoint)
{
  if (m_iHistoryEntries == 0)
    return VRR_None;

  __int64 iOldestTime = m_history[m_iHistoryStart].m_iTime;
  __int64 iNewestTime = m_history[(m_iHistoryStart + m_iHistoryEntries - 1) % iHistoryLength].m_iTime;
  
  VASSERT (iOldestTime <= iNewestTime);
  // 'iInterpolationPoint' is too old, taking earliest known value (extrapolate in the past?)
  if (iInterpolationPoint <= iOldestTime)
  {
    //Vision::Error.SystemMessage("  oldest = %d, newest = %d, iInterpolationPoint: %d", (int)iOldestTime, (int)iNewestTime, (int)iInterpolationPoint);

    *out_pData = m_history[m_iHistoryStart].m_data;
    return VRR_Oldest;
  }
  // 'iInterpolationPoint' is newer than the history, so we have to extrapolate the value
  else if (iInterpolationPoint >= iNewestTime)
  {
    // Taking the last value for the time being
    if (m_iHistoryEntries == 1)
    {
      *out_pData = m_history[(m_iHistoryStart + m_iHistoryEntries - 1) % iHistoryLength].m_data;
      return VRR_Extrapolated;
    }
    //extrapolate to the future
    else
    {
      const VisDataHistoryCell<dataType> &current = m_history[(m_iHistoryStart + m_iHistoryEntries - 1) % iHistoryLength];
      const VisDataHistoryCell<dataType> &prev = m_history[(m_iHistoryStart + m_iHistoryEntries - 2) % iHistoryLength];

      float fDivisor = float(current.m_iTime - prev.m_iTime);
      float fStep = float(iInterpolationPoint - current.m_iTime);

      //*out_pData = current.m_data + diff * (fStep / fDivisor);
      *out_pData = Mix() (prev.m_data, current.m_data, 1.0f + (fStep / fDivisor) );
      return VRR_Extrapolated;
    }
  }
  else
  {
    for (int i = m_iHistoryEntries-1;  i > 0; --i)
    {
      const VisDataHistoryCell<dataType> &current = m_history[(m_iHistoryStart + i) % iHistoryLength];
      const VisDataHistoryCell<dataType> &prev = m_history[(m_iHistoryStart + i - 1) % iHistoryLength];

      VASSERT (prev.m_iTime < current.m_iTime);

      if (iInterpolationPoint > prev.m_iTime)
      {
        float fDivisor = float(current.m_iTime - prev.m_iTime);
        float fLerp = float(iInterpolationPoint - prev.m_iTime);
        float fLerpFactor = fLerp / fDivisor;

        *out_pData = Mix()(current.m_data, prev.m_data, 1.0f - fLerpFactor);
        return VRR_Interpolated;
      }
      else
        continue;
    }
  }
  VASSERT_MSG (false, "Unreachable code reached!");
  return VRR_None; //impossible to reach
}
コード例 #3
0
ファイル: spooky2.c プロジェクト: Zealsathish/snapraid
void SpookyHash128(const void* message, size_t length, const uint8_t* seed, uint8_t* digest)
{
	uint64_t h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11;
	uint64_t buf[sc_numVars];
	uint64_t* end;

	union {
		const uint8_t* p8;
		uint64_t* p64;
		size_t i;
	} u;
	size_t remainder;
#if WORDS_BIGENDIAN
	unsigned i;
#endif

	h9 = ((const uint64_t*)seed)[0];
	h10 = ((const uint64_t*)seed)[1];

#if WORDS_BIGENDIAN
	h9 = util_swap64(h9);
	h10 = util_swap64(h10);
#endif

	h0 = h3 = h6 = h9;
	h1 = h4 = h7 = h10;
	h2 = h5 = h8 = h11 = sc_const;

	u.p8 = message;
	end = u.p64 + (length / sc_blockSize) * sc_numVars;

	/* body */

	while (u.p64 < end) {
#if WORDS_BIGENDIAN
		for (i = 0; i < sc_numVars; ++i)
			buf[i] = util_swap64(u.p64[i]);
		Mix(buf, h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11);
#else
		Mix(u.p64, h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11);
#endif
		u.p64 += sc_numVars;
	}

	/* tail */

	remainder = (length - ((const uint8_t*)end - (const uint8_t*)message));
	memcpy(buf, end, remainder);
	memset(((uint8_t*)buf) + remainder, 0, sc_blockSize - remainder);
	((uint8_t*)buf)[sc_blockSize - 1] = remainder;

	/* finalization */
#if WORDS_BIGENDIAN
	for (i = 0; i < sc_numVars; ++i)
		buf[i] = util_swap64(buf[i]);
#endif

	End(buf, h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11);

#if WORDS_BIGENDIAN
	h0 = util_swap64(h0);
	h1 = util_swap64(h1);
#endif

	((uint64_t*)digest)[0] = h0;
	((uint64_t*)digest)[1] = h1;
}
コード例 #4
0
ファイル: SpookyHash.cpp プロジェクト: Abioy/folly
// do the whole hash in one call
void SpookyHash::Hash128(
    const void *message,
    size_t length,
    uint64_t *hash1,
    uint64_t *hash2)
{
    if (length < sc_bufSize)
    {
        Short(message, length, hash1, hash2);
        return;
    }

    uint64_t h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11;
    uint64_t buf[sc_numVars];
    uint64_t *end;
    union
    {
        const uint8_t *p8;
        uint64_t *p64;
        size_t i;
    } u;
    size_t remainder;

    h0=h3=h6=h9  = *hash1;
    h1=h4=h7=h10 = *hash2;
    h2=h5=h8=h11 = sc_const;

    u.p8 = (const uint8_t *)message;
    end = u.p64 + (length/sc_blockSize)*sc_numVars;

    // handle all whole sc_blockSize blocks of bytes
    if (ALLOW_UNALIGNED_READS || ((u.i & 0x7) == 0))
    {
        while (u.p64 < end)
        {
            Mix(u.p64, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
            u.p64 += sc_numVars;
        }
    }
    else
    {
        while (u.p64 < end)
        {
            memcpy(buf, u.p64, sc_blockSize);
            Mix(buf, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
            u.p64 += sc_numVars;
        }
    }

    // handle the last partial block of sc_blockSize bytes
    remainder = (length - ((const uint8_t *)end-(const uint8_t *)message));
    memcpy(buf, end, remainder);
    memset(((uint8_t *)buf)+remainder, 0, sc_blockSize-remainder);
    ((uint8_t *)buf)[sc_blockSize-1] = remainder;
    Mix(buf, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);

    // do some final mixing
    End(h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
    *hash1 = h0;
    *hash2 = h1;
}
コード例 #5
0
ファイル: warpup.c プロジェクト: BackupTheBerlios/arp2-svn
static int
CallMixroutine( struct PowerPCContext* context )
{
  struct AHIPrivAudioCtrl* audioctrl;
  struct AHISoundData*     sd;
  int                      i;

  audioctrl = context->AudioCtrl;

//  *((ULONG*) 0x100000) = 1;

  // Wait for start signal...

  while( audioctrl->ahiac_PowerPCContext->Command != PPCC_COM_START );

//  *((ULONG*) 0x100000) = 4;

  // Start m68k interrupt handler

  audioctrl->ahiac_PowerPCContext->Command = PPCC_COM_INIT;
  *((WORD*) 0xdff09C)  = INTF_SETCLR | INTF_PORTS;

//  *((ULONG*) 0x100000) = 5;

#if 0

  // Invalidate dynamic sample sounds (which is faster than flushing).
  // Currently, the PPC is assumed not to modify dynamic samples.
  // It makes sense as long as no PPC hooks can be called from AHI.
  // Anyway, each dynamic sample is flushed on the m68k side before
  // this routine is called, and invalidated here on the PPC side.
  // However, should a dynamic sample start at address 0, which
  // probably means that the whole address space is used for that
  // sample, all of the data caches are instead flushed.

  sd = audioctrl->ahiac_SoundDatas;

  for( i = 0; i < audioctrl->ac.ahiac_Sounds; i++)
  {
    if( sd->sd_Type == AHIST_DYNAMICSAMPLE )
    {
      if( sd->sd_Addr == NULL )
      {
        // *Flush* all and exit (add an L2 cache and watch this code break!)

        FlushCacheAll();
        break;
      }
      else
      {
        // *Invalidate* block

        InvalidateCache( sd->sd_Addr,
                         sd->sd_Length * SampleFrameSize( sd->sd_Type, AHIBase ) );
      }
    }
    sd++;
  }

#endif

  // Wait for m68k interrupt handler to go active

  while( audioctrl->ahiac_PowerPCContext->Command != PPCC_COM_ACK );

//  *((ULONG*) 0x100000) = 6;

#if 0

  // Mix

  Mix( context->Hook, context->Dst, audioctrl );
  DoMasterVolume( context->Dst, audioctrl );

  // Flush mixed samples to memory

  FlushCache( context->Dst, audioctrl->ahiac_BuffSizeNow );

#endif

//  *((ULONG*) 0x100000) = 7;

  // Kill the m68k interrupt handler

  audioctrl->ahiac_PowerPCContext->Command = PPCC_COM_QUIT;
  *((WORD*) 0xdff09C)  = INTF_SETCLR | INTF_PORTS;

//  *((ULONG*) 0x100000) = 8;

  // Wait for it

  while( audioctrl->ahiac_PowerPCContext->Command != PPCC_COM_ACK );

//  *((ULONG*) 0x100000) = 9;

  audioctrl->ahiac_PowerPCContext->Command = PPCC_COM_FINISHED;

//  *((ULONG*) 0x100000) = 10;

  return 0;
}
コード例 #6
0
ファイル: sound.cpp プロジェクト: CytraL/MineTee
static void SdlCallback(void *pUnused, Uint8 *pStream, int Len)
{
	(void)pUnused;
	Mix((short *)pStream, Len/2/2);
}
コード例 #7
0
ファイル: spu2sys.cpp プロジェクト: docbray/pcsx2-online
__forceinline void TimeUpdate(u32 cClocks)
{
	u32 dClocks = cClocks - lClocks;

	// Sanity Checks:
	//  It's not totally uncommon for the IOP's clock to jump backwards a cycle or two, and in
	//  such cases we just want to ignore the TimeUpdate call.

	if( dClocks > (u32)-15 ) return;

	//  But if for some reason our clock value seems way off base (typically due to bad dma
	//  timings from PCSX2), just mix out a little bit, skip the rest, and hope the ship
	//  "rights" itself later on.

	if( dClocks > (u32)(TickInterval*SanityInterval) )
	{
		if(MsgToConsole()) ConLog( " * SPU2 > TimeUpdate Sanity Check (Tick Delta: %d) (PS2 Ticks: %d)\n", dClocks/TickInterval, cClocks/TickInterval );
		dClocks = TickInterval * SanityInterval;
		lClocks = cClocks - dClocks;
	}

	// Visual debug display showing all core's activity! Disabled via #define on release builds.
#ifdef __WIN32__
	UpdateDebugDialog();
#endif

	if( SynchMode == 1 ) // AsyncMix on
		SndBuffer::UpdateTempoChangeAsyncMixing();
	else TickInterval = 768; // Reset to default, in case the user hotswitched from async to something else.

	//Update Mixing Progress
	while(dClocks>=TickInterval)
	{
		if(has_to_call_irq)
		{
			//ConLog("* SPU2-X: Irq Called (%04x) at cycle %d.\n", Spdif.Info, Cycles);
			has_to_call_irq=false;
			if(_irqcallback) _irqcallback();
		}

#ifndef ENABLE_NEW_IOPDMA_SPU2
		//Update DMA4 interrupt delay counter
		if(Cores[0].DMAICounter>0)
		{
			Cores[0].DMAICounter-=TickInterval;
			if(Cores[0].DMAICounter<=0)
			{
				Cores[0].MADR=Cores[0].TADR;
				Cores[0].DMAICounter=0;
				if(dma4callback) dma4callback();
			}
			else {
				Cores[0].MADR+=TickInterval<<1;
			}
		}

		//Update DMA7 interrupt delay counter
		if(Cores[1].DMAICounter>0)
		{
			Cores[1].DMAICounter-=TickInterval;
			if(Cores[1].DMAICounter<=0)
			{
				Cores[1].MADR=Cores[1].TADR;
				Cores[1].DMAICounter=0;
				//ConLog( "* SPU2 > DMA 7 Callback!  %d\n", Cycles );
				if(dma7callback) dma7callback();
			}
			else {
				Cores[1].MADR+=TickInterval<<1;
			}
		}
#endif

		dClocks -= TickInterval;
		lClocks += TickInterval;
		Cycles++;

		// Note: IOP does not use MMX regs, so no need to save them.
		//SaveMMXRegs();
		Mix();
		//RestoreMMXRegs();
	}
}
コード例 #8
0
ファイル: Threefish1024.cpp プロジェクト: Steppenwolfe65/CEX
void Threefish1024::Encrypt(const std::vector<ulong> &Input, std::vector<ulong> &Output)
{
	// cache the block, key, and tweak
	ulong B0 = Input[0];
	ulong B1 = Input[1];
	ulong B2 = Input[2];
	ulong B3 = Input[3];
	ulong B4 = Input[4];
	ulong B5 = Input[5];
	ulong B6 = Input[6];
	ulong B7 = Input[7];
	ulong B8 = Input[8];
	ulong B9 = Input[9];
	ulong B10 = Input[10];
	ulong B11 = Input[11];
	ulong B12 = Input[12];
	ulong B13 = Input[13];
	ulong B14 = Input[14];
	ulong B15 = Input[15];
	ulong K0 = m_expandedKey[0];
	ulong K1 = m_expandedKey[1];
	ulong K2 = m_expandedKey[2];
	ulong K3 = m_expandedKey[3];
	ulong K4 = m_expandedKey[4];
	ulong K5 = m_expandedKey[5];
	ulong K6 = m_expandedKey[6];
	ulong K7 = m_expandedKey[7];
	ulong K8 = m_expandedKey[8];
	ulong K9 = m_expandedKey[9];
	ulong K10 = m_expandedKey[10];
	ulong K11 = m_expandedKey[11];
	ulong K12 = m_expandedKey[12];
	ulong K13 = m_expandedKey[13];
	ulong K14 = m_expandedKey[14];
	ulong K15 = m_expandedKey[15];
	ulong K16 = m_expandedKey[16];
	ulong T0 = m_expandedTweak[0];
	ulong T1 = m_expandedTweak[1];
	ulong T2 = m_expandedTweak[2];

	Mix(B0, B1, 24, K0, K1);
	Mix(B2, B3, 13, K2, K3);
	Mix(B4, B5, 8, K4, K5);
	Mix(B6, B7, 47, K6, K7);
	Mix(B8, B9, 8, K8, K9);
	Mix(B10, B11, 17, K10, K11);
	Mix(B12, B13, 22, K12, K13 + T0);
	Mix(B14, B15, 37, K14 + T1, K15);
	Mix(B0, B9, 38);
	Mix(B2, B13, 19);
	Mix(B6, B11, 10);
	Mix(B4, B15, 55);
	Mix(B10, B7, 49);
	Mix(B12, B3, 18);
	Mix(B14, B5, 23);
	Mix(B8, B1, 52);
	Mix(B0, B7, 33);
	Mix(B2, B5, 4);
	Mix(B4, B3, 51);
	Mix(B6, B1, 13);
	Mix(B12, B15, 34);
	Mix(B14, B13, 41);
	Mix(B8, B11, 59);
	Mix(B10, B9, 17);
	Mix(B0, B15, 5);
	Mix(B2, B11, 20);
	Mix(B6, B13, 48);
	Mix(B4, B9, 41);
	Mix(B14, B1, 47);
	Mix(B8, B5, 28);
	Mix(B10, B3, 16);
	Mix(B12, B7, 25);
	Mix(B0, B1, 41, K1, K2);
	Mix(B2, B3, 9, K3, K4);
	Mix(B4, B5, 37, K5, K6);
	Mix(B6, B7, 31, K7, K8);
	Mix(B8, B9, 12, K9, K10);
	Mix(B10, B11, 47, K11, K12);
	Mix(B12, B13, 44, K13, K14 + T1);
	Mix(B14, B15, 30, K15 + T2, K16 + 1);
	Mix(B0, B9, 16);
	Mix(B2, B13, 34);
	Mix(B6, B11, 56);
	Mix(B4, B15, 51);
	Mix(B10, B7, 4);
	Mix(B12, B3, 53);
	Mix(B14, B5, 42);
	Mix(B8, B1, 41);
	Mix(B0, B7, 31);
	Mix(B2, B5, 44);
	Mix(B4, B3, 47);
	Mix(B6, B1, 46);
	Mix(B12, B15, 19);
	Mix(B14, B13, 42);
	Mix(B8, B11, 44);
	Mix(B10, B9, 25);
	Mix(B0, B15, 9);
	Mix(B2, B11, 48);
	Mix(B6, B13, 35);
	Mix(B4, B9, 52);
	Mix(B14, B1, 23);
	Mix(B8, B5, 31);
	Mix(B10, B3, 37);
	Mix(B12, B7, 20);
	Mix(B0, B1, 24, K2, K3);
	Mix(B2, B3, 13, K4, K5);
	Mix(B4, B5, 8, K6, K7);
	Mix(B6, B7, 47, K8, K9);
	Mix(B8, B9, 8, K10, K11);
	Mix(B10, B11, 17, K12, K13);
	Mix(B12, B13, 22, K14, K15 + T2);
	Mix(B14, B15, 37, K16 + T0, K0 + 2);
	Mix(B0, B9, 38);
	Mix(B2, B13, 19);
	Mix(B6, B11, 10);
	Mix(B4, B15, 55);
	Mix(B10, B7, 49);
	Mix(B12, B3, 18);
	Mix(B14, B5, 23);
	Mix(B8, B1, 52);
	Mix(B0, B7, 33);
	Mix(B2, B5, 4);
	Mix(B4, B3, 51);
	Mix(B6, B1, 13);
	Mix(B12, B15, 34);
	Mix(B14, B13, 41);
	Mix(B8, B11, 59);
	Mix(B10, B9, 17);
	Mix(B0, B15, 5);
	Mix(B2, B11, 20);
	Mix(B6, B13, 48);
	Mix(B4, B9, 41);
	Mix(B14, B1, 47);
	Mix(B8, B5, 28);
	Mix(B10, B3, 16);
	Mix(B12, B7, 25);
	Mix(B0, B1, 41, K3, K4);
	Mix(B2, B3, 9, K5, K6);
	Mix(B4, B5, 37, K7, K8);
	Mix(B6, B7, 31, K9, K10);
	Mix(B8, B9, 12, K11, K12);
	Mix(B10, B11, 47, K13, K14);
	Mix(B12, B13, 44, K15, K16 + T0);
	Mix(B14, B15, 30, K0 + T1, K1 + 3);
	Mix(B0, B9, 16);
	Mix(B2, B13, 34);
	Mix(B6, B11, 56);
	Mix(B4, B15, 51);
	Mix(B10, B7, 4);
	Mix(B12, B3, 53);
	Mix(B14, B5, 42);
	Mix(B8, B1, 41);
	Mix(B0, B7, 31);
	Mix(B2, B5, 44);
	Mix(B4, B3, 47);
	Mix(B6, B1, 46);
	Mix(B12, B15, 19);
	Mix(B14, B13, 42);
	Mix(B8, B11, 44);
	Mix(B10, B9, 25);
	Mix(B0, B15, 9);
	Mix(B2, B11, 48);
	Mix(B6, B13, 35);
	Mix(B4, B9, 52);
	Mix(B14, B1, 23);
	Mix(B8, B5, 31);
	Mix(B10, B3, 37);
	Mix(B12, B7, 20);
	Mix(B0, B1, 24, K4, K5);
	Mix(B2, B3, 13, K6, K7);
	Mix(B4, B5, 8, K8, K9);
	Mix(B6, B7, 47, K10, K11);
	Mix(B8, B9, 8, K12, K13);
	Mix(B10, B11, 17, K14, K15);
	Mix(B12, B13, 22, K16, K0 + T1);
	Mix(B14, B15, 37, K1 + T2, K2 + 4);
	Mix(B0, B9, 38);
	Mix(B2, B13, 19);
	Mix(B6, B11, 10);
	Mix(B4, B15, 55);
	Mix(B10, B7, 49);
	Mix(B12, B3, 18);
	Mix(B14, B5, 23);
	Mix(B8, B1, 52);
	Mix(B0, B7, 33);
	Mix(B2, B5, 4);
	Mix(B4, B3, 51);
	Mix(B6, B1, 13);
	Mix(B12, B15, 34);
	Mix(B14, B13, 41);
	Mix(B8, B11, 59);
	Mix(B10, B9, 17);
	Mix(B0, B15, 5);
	Mix(B2, B11, 20);
	Mix(B6, B13, 48);
	Mix(B4, B9, 41);
	Mix(B14, B1, 47);
	Mix(B8, B5, 28);
	Mix(B10, B3, 16);
	Mix(B12, B7, 25);
	Mix(B0, B1, 41, K5, K6);
	Mix(B2, B3, 9, K7, K8);
	Mix(B4, B5, 37, K9, K10);
	Mix(B6, B7, 31, K11, K12);
	Mix(B8, B9, 12, K13, K14);
	Mix(B10, B11, 47, K15, K16);
	Mix(B12, B13, 44, K0, K1 + T2);
	Mix(B14, B15, 30, K2 + T0, K3 + 5);
	Mix(B0, B9, 16);
	Mix(B2, B13, 34);
	Mix(B6, B11, 56);
	Mix(B4, B15, 51);
	Mix(B10, B7, 4);
	Mix(B12, B3, 53);
	Mix(B14, B5, 42);
	Mix(B8, B1, 41);
	Mix(B0, B7, 31);
	Mix(B2, B5, 44);
	Mix(B4, B3, 47);
	Mix(B6, B1, 46);
	Mix(B12, B15, 19);
	Mix(B14, B13, 42);
	Mix(B8, B11, 44);
	Mix(B10, B9, 25);
	Mix(B0, B15, 9);
	Mix(B2, B11, 48);
	Mix(B6, B13, 35);
	Mix(B4, B9, 52);
	Mix(B14, B1, 23);
	Mix(B8, B5, 31);
	Mix(B10, B3, 37);
	Mix(B12, B7, 20);
	Mix(B0, B1, 24, K6, K7);
	Mix(B2, B3, 13, K8, K9);
	Mix(B4, B5, 8, K10, K11);
	Mix(B6, B7, 47, K12, K13);
	Mix(B8, B9, 8, K14, K15);
	Mix(B10, B11, 17, K16, K0);
	Mix(B12, B13, 22, K1, K2 + T0);
	Mix(B14, B15, 37, K3 + T1, K4 + 6);
	Mix(B0, B9, 38);
	Mix(B2, B13, 19);
	Mix(B6, B11, 10);
	Mix(B4, B15, 55);
	Mix(B10, B7, 49);
	Mix(B12, B3, 18);
	Mix(B14, B5, 23);
	Mix(B8, B1, 52);
	Mix(B0, B7, 33);
	Mix(B2, B5, 4);
	Mix(B4, B3, 51);
	Mix(B6, B1, 13);
	Mix(B12, B15, 34);
	Mix(B14, B13, 41);
	Mix(B8, B11, 59);
	Mix(B10, B9, 17);
	Mix(B0, B15, 5);
	Mix(B2, B11, 20);
	Mix(B6, B13, 48);
	Mix(B4, B9, 41);
	Mix(B14, B1, 47);
	Mix(B8, B5, 28);
	Mix(B10, B3, 16);
	Mix(B12, B7, 25);
	Mix(B0, B1, 41, K7, K8);
	Mix(B2, B3, 9, K9, K10);
	Mix(B4, B5, 37, K11, K12);
	Mix(B6, B7, 31, K13, K14);
	Mix(B8, B9, 12, K15, K16);
	Mix(B10, B11, 47, K0, K1);
	Mix(B12, B13, 44, K2, K3 + T1);
	Mix(B14, B15, 30, K4 + T2, K5 + 7);
	Mix(B0, B9, 16);
	Mix(B2, B13, 34);
	Mix(B6, B11, 56);
	Mix(B4, B15, 51);
	Mix(B10, B7, 4);
	Mix(B12, B3, 53);
	Mix(B14, B5, 42);
	Mix(B8, B1, 41);
	Mix(B0, B7, 31);
	Mix(B2, B5, 44);
	Mix(B4, B3, 47);
	Mix(B6, B1, 46);
	Mix(B12, B15, 19);
	Mix(B14, B13, 42);
	Mix(B8, B11, 44);
	Mix(B10, B9, 25);
	Mix(B0, B15, 9);
	Mix(B2, B11, 48);
	Mix(B6, B13, 35);
	Mix(B4, B9, 52);
	Mix(B14, B1, 23);
	Mix(B8, B5, 31);
	Mix(B10, B3, 37);
	Mix(B12, B7, 20);
	Mix(B0, B1, 24, K8, K9);
	Mix(B2, B3, 13, K10, K11);
	Mix(B4, B5, 8, K12, K13);
	Mix(B6, B7, 47, K14, K15);
	Mix(B8, B9, 8, K16, K0);
	Mix(B10, B11, 17, K1, K2);
	Mix(B12, B13, 22, K3, K4 + T2);
	Mix(B14, B15, 37, K5 + T0, K6 + 8);
	Mix(B0, B9, 38);
	Mix(B2, B13, 19);
	Mix(B6, B11, 10);
	Mix(B4, B15, 55);
	Mix(B10, B7, 49);
	Mix(B12, B3, 18);
	Mix(B14, B5, 23);
	Mix(B8, B1, 52);
	Mix(B0, B7, 33);
	Mix(B2, B5, 4);
	Mix(B4, B3, 51);
	Mix(B6, B1, 13);
	Mix(B12, B15, 34);
	Mix(B14, B13, 41);
	Mix(B8, B11, 59);
	Mix(B10, B9, 17);
	Mix(B0, B15, 5);
	Mix(B2, B11, 20);
	Mix(B6, B13, 48);
	Mix(B4, B9, 41);
	Mix(B14, B1, 47);
	Mix(B8, B5, 28);
	Mix(B10, B3, 16);
	Mix(B12, B7, 25);
	Mix(B0, B1, 41, K9, K10);
	Mix(B2, B3, 9, K11, K12);
	Mix(B4, B5, 37, K13, K14);
	Mix(B6, B7, 31, K15, K16);
	Mix(B8, B9, 12, K0, K1);
	Mix(B10, B11, 47, K2, K3);
	Mix(B12, B13, 44, K4, K5 + T0);
	Mix(B14, B15, 30, K6 + T1, K7 + 9);
	Mix(B0, B9, 16);
	Mix(B2, B13, 34);
	Mix(B6, B11, 56);
	Mix(B4, B15, 51);
	Mix(B10, B7, 4);
	Mix(B12, B3, 53);
	Mix(B14, B5, 42);
	Mix(B8, B1, 41);
	Mix(B0, B7, 31);
	Mix(B2, B5, 44);
	Mix(B4, B3, 47);
	Mix(B6, B1, 46);
	Mix(B12, B15, 19);
	Mix(B14, B13, 42);
	Mix(B8, B11, 44);
	Mix(B10, B9, 25);
	Mix(B0, B15, 9);
	Mix(B2, B11, 48);
	Mix(B6, B13, 35);
	Mix(B4, B9, 52);
	Mix(B14, B1, 23);
	Mix(B8, B5, 31);
	Mix(B10, B3, 37);
	Mix(B12, B7, 20);
	Mix(B0, B1, 24, K10, K11);
	Mix(B2, B3, 13, K12, K13);
	Mix(B4, B5, 8, K14, K15);
	Mix(B6, B7, 47, K16, K0);
	Mix(B8, B9, 8, K1, K2);
	Mix(B10, B11, 17, K3, K4);
	Mix(B12, B13, 22, K5, K6 + T1);
	Mix(B14, B15, 37, K7 + T2, K8 + 10);
	Mix(B0, B9, 38);
	Mix(B2, B13, 19);
	Mix(B6, B11, 10);
	Mix(B4, B15, 55);
	Mix(B10, B7, 49);
	Mix(B12, B3, 18);
	Mix(B14, B5, 23);
	Mix(B8, B1, 52);
	Mix(B0, B7, 33);
	Mix(B2, B5, 4);
	Mix(B4, B3, 51);
	Mix(B6, B1, 13);
	Mix(B12, B15, 34);
	Mix(B14, B13, 41);
	Mix(B8, B11, 59);
	Mix(B10, B9, 17);
	Mix(B0, B15, 5);
	Mix(B2, B11, 20);
	Mix(B6, B13, 48);
	Mix(B4, B9, 41);
	Mix(B14, B1, 47);
	Mix(B8, B5, 28);
	Mix(B10, B3, 16);
	Mix(B12, B7, 25);
	Mix(B0, B1, 41, K11, K12);
	Mix(B2, B3, 9, K13, K14);
	Mix(B4, B5, 37, K15, K16);
	Mix(B6, B7, 31, K0, K1);
	Mix(B8, B9, 12, K2, K3);
	Mix(B10, B11, 47, K4, K5);
	Mix(B12, B13, 44, K6, K7 + T2);
	Mix(B14, B15, 30, K8 + T0, K9 + 11);
	Mix(B0, B9, 16);
	Mix(B2, B13, 34);
	Mix(B6, B11, 56);
	Mix(B4, B15, 51);
	Mix(B10, B7, 4);
	Mix(B12, B3, 53);
	Mix(B14, B5, 42);
	Mix(B8, B1, 41);
	Mix(B0, B7, 31);
	Mix(B2, B5, 44);
	Mix(B4, B3, 47);
	Mix(B6, B1, 46);
	Mix(B12, B15, 19);
	Mix(B14, B13, 42);
	Mix(B8, B11, 44);
	Mix(B10, B9, 25);
	Mix(B0, B15, 9);
	Mix(B2, B11, 48);
	Mix(B6, B13, 35);
	Mix(B4, B9, 52);
	Mix(B14, B1, 23);
	Mix(B8, B5, 31);
	Mix(B10, B3, 37);
	Mix(B12, B7, 20);
	Mix(B0, B1, 24, K12, K13);
	Mix(B2, B3, 13, K14, K15);
	Mix(B4, B5, 8, K16, K0);
	Mix(B6, B7, 47, K1, K2);
	Mix(B8, B9, 8, K3, K4);
	Mix(B10, B11, 17, K5, K6);
	Mix(B12, B13, 22, K7, K8 + T0);
	Mix(B14, B15, 37, K9 + T1, K10 + 12);
	Mix(B0, B9, 38);
	Mix(B2, B13, 19);
	Mix(B6, B11, 10);
	Mix(B4, B15, 55);
	Mix(B10, B7, 49);
	Mix(B12, B3, 18);
	Mix(B14, B5, 23);
	Mix(B8, B1, 52);
	Mix(B0, B7, 33);
	Mix(B2, B5, 4);
	Mix(B4, B3, 51);
	Mix(B6, B1, 13);
	Mix(B12, B15, 34);
	Mix(B14, B13, 41);
	Mix(B8, B11, 59);
	Mix(B10, B9, 17);
	Mix(B0, B15, 5);
	Mix(B2, B11, 20);
	Mix(B6, B13, 48);
	Mix(B4, B9, 41);
	Mix(B14, B1, 47);
	Mix(B8, B5, 28);
	Mix(B10, B3, 16);
	Mix(B12, B7, 25);
	Mix(B0, B1, 41, K13, K14);
	Mix(B2, B3, 9, K15, K16);
	Mix(B4, B5, 37, K0, K1);
	Mix(B6, B7, 31, K2, K3);
	Mix(B8, B9, 12, K4, K5);
	Mix(B10, B11, 47, K6, K7);
	Mix(B12, B13, 44, K8, K9 + T1);
	Mix(B14, B15, 30, K10 + T2, K11 + 13);
	Mix(B0, B9, 16);
	Mix(B2, B13, 34);
	Mix(B6, B11, 56);
	Mix(B4, B15, 51);
	Mix(B10, B7, 4);
	Mix(B12, B3, 53);
	Mix(B14, B5, 42);
	Mix(B8, B1, 41);
	Mix(B0, B7, 31);
	Mix(B2, B5, 44);
	Mix(B4, B3, 47);
	Mix(B6, B1, 46);
	Mix(B12, B15, 19);
	Mix(B14, B13, 42);
	Mix(B8, B11, 44);
	Mix(B10, B9, 25);
	Mix(B0, B15, 9);
	Mix(B2, B11, 48);
	Mix(B6, B13, 35);
	Mix(B4, B9, 52);
	Mix(B14, B1, 23);
	Mix(B8, B5, 31);
	Mix(B10, B3, 37);
	Mix(B12, B7, 20);
	Mix(B0, B1, 24, K14, K15);
	Mix(B2, B3, 13, K16, K0);
	Mix(B4, B5, 8, K1, K2);
	Mix(B6, B7, 47, K3, K4);
	Mix(B8, B9, 8, K5, K6);
	Mix(B10, B11, 17, K7, K8);
	Mix(B12, B13, 22, K9, K10 + T2);
	Mix(B14, B15, 37, K11 + T0, K12 + 14);
	Mix(B0, B9, 38);
	Mix(B2, B13, 19);
	Mix(B6, B11, 10);
	Mix(B4, B15, 55);
	Mix(B10, B7, 49);
	Mix(B12, B3, 18);
	Mix(B14, B5, 23);
	Mix(B8, B1, 52);
	Mix(B0, B7, 33);
	Mix(B2, B5, 4);
	Mix(B4, B3, 51);
	Mix(B6, B1, 13);
	Mix(B12, B15, 34);
	Mix(B14, B13, 41);
	Mix(B8, B11, 59);
	Mix(B10, B9, 17);
	Mix(B0, B15, 5);
	Mix(B2, B11, 20);
	Mix(B6, B13, 48);
	Mix(B4, B9, 41);
	Mix(B14, B1, 47);
	Mix(B8, B5, 28);
	Mix(B10, B3, 16);
	Mix(B12, B7, 25);
	Mix(B0, B1, 41, K15, K16);
	Mix(B2, B3, 9, K0, K1);
	Mix(B4, B5, 37, K2, K3);
	Mix(B6, B7, 31, K4, K5);
	Mix(B8, B9, 12, K6, K7);
	Mix(B10, B11, 47, K8, K9);
	Mix(B12, B13, 44, K10, K11 + T0);
	Mix(B14, B15, 30, K12 + T1, K13 + 15);
	Mix(B0, B9, 16);
	Mix(B2, B13, 34);
	Mix(B6, B11, 56);
	Mix(B4, B15, 51);
	Mix(B10, B7, 4);
	Mix(B12, B3, 53);
	Mix(B14, B5, 42);
	Mix(B8, B1, 41);
	Mix(B0, B7, 31);
	Mix(B2, B5, 44);
	Mix(B4, B3, 47);
	Mix(B6, B1, 46);
	Mix(B12, B15, 19);
	Mix(B14, B13, 42);
	Mix(B8, B11, 44);
	Mix(B10, B9, 25);
	Mix(B0, B15, 9);
	Mix(B2, B11, 48);
	Mix(B6, B13, 35);
	Mix(B4, B9, 52);
	Mix(B14, B1, 23);
	Mix(B8, B5, 31);
	Mix(B10, B3, 37);
	Mix(B12, B7, 20);
	Mix(B0, B1, 24, K16, K0);
	Mix(B2, B3, 13, K1, K2);
	Mix(B4, B5, 8, K3, K4);
	Mix(B6, B7, 47, K5, K6);
	Mix(B8, B9, 8, K7, K8);
	Mix(B10, B11, 17, K9, K10);
	Mix(B12, B13, 22, K11, K12 + T1);
	Mix(B14, B15, 37, K13 + T2, K14 + 16);
	Mix(B0, B9, 38);
	Mix(B2, B13, 19);
	Mix(B6, B11, 10);
	Mix(B4, B15, 55);
	Mix(B10, B7, 49);
	Mix(B12, B3, 18);
	Mix(B14, B5, 23);
	Mix(B8, B1, 52);
	Mix(B0, B7, 33);
	Mix(B2, B5, 4);
	Mix(B4, B3, 51);
	Mix(B6, B1, 13);
	Mix(B12, B15, 34);
	Mix(B14, B13, 41);
	Mix(B8, B11, 59);
	Mix(B10, B9, 17);
	Mix(B0, B15, 5);
	Mix(B2, B11, 20);
	Mix(B6, B13, 48);
	Mix(B4, B9, 41);
	Mix(B14, B1, 47);
	Mix(B8, B5, 28);
	Mix(B10, B3, 16);
	Mix(B12, B7, 25);
	Mix(B0, B1, 41, K0, K1);
	Mix(B2, B3, 9, K2, K3);
	Mix(B4, B5, 37, K4, K5);
	Mix(B6, B7, 31, K6, K7);
	Mix(B8, B9, 12, K8, K9);
	Mix(B10, B11, 47, K10, K11);
	Mix(B12, B13, 44, K12, K13 + T2);
	Mix(B14, B15, 30, K14 + T0, K15 + 17);
	Mix(B0, B9, 16);
	Mix(B2, B13, 34);
	Mix(B6, B11, 56);
	Mix(B4, B15, 51);
	Mix(B10, B7, 4);
	Mix(B12, B3, 53);
	Mix(B14, B5, 42);
	Mix(B8, B1, 41);
	Mix(B0, B7, 31);
	Mix(B2, B5, 44);
	Mix(B4, B3, 47);
	Mix(B6, B1, 46);
	Mix(B12, B15, 19);
	Mix(B14, B13, 42);
	Mix(B8, B11, 44);
	Mix(B10, B9, 25);
	Mix(B0, B15, 9);
	Mix(B2, B11, 48);
	Mix(B6, B13, 35);
	Mix(B4, B9, 52);
	Mix(B14, B1, 23);
	Mix(B8, B5, 31);
	Mix(B10, B3, 37);
	Mix(B12, B7, 20);
	Mix(B0, B1, 24, K1, K2);
	Mix(B2, B3, 13, K3, K4);
	Mix(B4, B5, 8, K5, K6);
	Mix(B6, B7, 47, K7, K8);
	Mix(B8, B9, 8, K9, K10);
	Mix(B10, B11, 17, K11, K12);
	Mix(B12, B13, 22, K13, K14 + T0);
	Mix(B14, B15, 37, K15 + T1, K16 + 18);
	Mix(B0, B9, 38);
	Mix(B2, B13, 19);
	Mix(B6, B11, 10);
	Mix(B4, B15, 55);
	Mix(B10, B7, 49);
	Mix(B12, B3, 18);
	Mix(B14, B5, 23);
	Mix(B8, B1, 52);
	Mix(B0, B7, 33);
	Mix(B2, B5, 4);
	Mix(B4, B3, 51);
	Mix(B6, B1, 13);
	Mix(B12, B15, 34);
	Mix(B14, B13, 41);
	Mix(B8, B11, 59);
	Mix(B10, B9, 17);
	Mix(B0, B15, 5);
	Mix(B2, B11, 20);
	Mix(B6, B13, 48);
	Mix(B4, B9, 41);
	Mix(B14, B1, 47);
	Mix(B8, B5, 28);
	Mix(B10, B3, 16);
	Mix(B12, B7, 25);
	Mix(B0, B1, 41, K2, K3);
	Mix(B2, B3, 9, K4, K5);
	Mix(B4, B5, 37, K6, K7);
	Mix(B6, B7, 31, K8, K9);
	Mix(B8, B9, 12, K10, K11);
	Mix(B10, B11, 47, K12, K13);
	Mix(B12, B13, 44, K14, K15 + T1);
	Mix(B14, B15, 30, K16 + T2, K0 + 19);
	Mix(B0, B9, 16);
	Mix(B2, B13, 34);
	Mix(B6, B11, 56);
	Mix(B4, B15, 51);
	Mix(B10, B7, 4);
	Mix(B12, B3, 53);
	Mix(B14, B5, 42);
	Mix(B8, B1, 41);
	Mix(B0, B7, 31);
	Mix(B2, B5, 44);
	Mix(B4, B3, 47);
	Mix(B6, B1, 46);
	Mix(B12, B15, 19);
	Mix(B14, B13, 42);
	Mix(B8, B11, 44);
	Mix(B10, B9, 25);
	Mix(B0, B15, 9);
	Mix(B2, B11, 48);
	Mix(B6, B13, 35);
	Mix(B4, B9, 52);
	Mix(B14, B1, 23);
	Mix(B8, B5, 31);
	Mix(B10, B3, 37);
	Mix(B12, B7, 20);

	// final key schedule
	Output[0] = B0 + K3;
	Output[1] = B1 + K4;
	Output[2] = B2 + K5;
	Output[3] = B3 + K6;
	Output[4] = B4 + K7;
	Output[5] = B5 + K8;
	Output[6] = B6 + K9;
	Output[7] = B7 + K10;
	Output[8] = B8 + K11;
	Output[9] = B9 + K12;
	Output[10] = B10 + K13;
	Output[11] = B11 + K14;
	Output[12] = B12 + K15;
	Output[13] = B13 + K16 + T2;
	Output[14] = B14 + K0 + T0;
	Output[15] = B15 + K1 + 20;
}
コード例 #9
0
ファイル: Spu2.cpp プロジェクト: 0xZERO3/PCSX2-rr-lua
void __fastcall TimeUpdate(u32 cClocks)
{
	u32 dClocks = cClocks-lClocks;

	// [Air]: Sanity Check
	//  If for some reason our clock value seems way off base, just mix
	//  out a little bit, skip the rest, and hope the ship "rights" itself later on.

	if( dClocks > TickInterval*SanityInterval )
	{
		ConLog( " * SPU2 > TimeUpdate Sanity Check (Tick Delta: %d) (PS2 Ticks: %d)\n", dClocks/TickInterval, cClocks/TickInterval );
		dClocks = TickInterval*SanityInterval;
		lClocks = cClocks-dClocks;
	}

	//UpdateDebugDialog();

	//Update Mixing Progress
	while(dClocks>=TickInterval)
	{
		if(has_to_call_irq)
		{
			ConLog(" * SPU2: Irq Called (%04x).\n",Spdif.Info);
			has_to_call_irq=false;
			if(_irqcallback) _irqcallback();
		}

		if(Cores[0].InitDelay>0)
		{
			Cores[0].InitDelay--;
			if(Cores[0].InitDelay==0)
			{
				Cores[0].Reset();
			}
		}

		if(Cores[1].InitDelay>0)
		{
			Cores[1].InitDelay--;
			if(Cores[1].InitDelay==0)
			{
				Cores[1].Reset();
			}
		}

		//Update DMA4 interrupt delay counter
		if(Cores[0].DMAICounter>0) 
		{
			Cores[0].DMAICounter-=TickInterval;
			if(Cores[0].DMAICounter<=0)
			{
				Cores[0].MADR=Cores[0].TADR;
				Cores[0].DMAICounter=0;
				if(dma4callback) dma4callback();
			}
			else {
				Cores[0].MADR+=TickInterval<<1;
			}
		}

		//Update DMA7 interrupt delay counter
		if(Cores[1].DMAICounter>0) 
		{
			Cores[1].DMAICounter-=TickInterval;
			if(Cores[1].DMAICounter<=0)
			{
				Cores[1].MADR=Cores[1].TADR;
				Cores[1].DMAICounter=0;
				//ConLog( "* SPU2 > DMA 7 Callback!  %d\n", Cycles );
				if(dma7callback) dma7callback();
			}
			else {
				Cores[1].MADR+=TickInterval<<1;
			}
		}

		dClocks-=TickInterval;
		lClocks+=TickInterval;
		Cycles++;

		Mix();
	}
}