When I call a function in Alchemy, I find that AlchemyYield increase constantly. Some one can tell me why?
This is the C code:
#include <stdlib.h>
#include <stdio.h>
#include "AS3.h"
unsigned char g_aPlte[768];
unsigned int g_aRGBPlte[256];
unsigned char g_aAlpha[256];
unsigned char g_aRGBIndex[360000];
unsigned int g_aOutRGB[360000];
static AS3_Val UnfuckRGBFromCompactBuffer( void* self, AS3_Val args )
{
AS3_Val baBuffer;
AS3_ArrayValue( args, "AS3ValType", &baBuffer );
unsigned short usWidth;
unsigned short usHeight;
unsigned char bOneBitAlpha;
unsigned int uiTmp;
unsigned short usTmp;
unsigned int uiColor;
unsigned short usPlteItemNum;
AS3_ByteArray_readBytes( &usWidth, baBuffer, 2 );
AS3_ByteArray_readBytes( &usHeight, baBuffer, 2 );
AS3_ByteArray_readBytes( &bOneBitAlpha, baBuffer, 1 );
AS3_ByteArray_readBytes( &usPlteItemNum, baBuffer, 2 );
AS3_ByteArray_readBytes( &usTmp, baBuffer, 2 );
AS3_ByteArray_readBytes( g_aPlte, baBuffer, usTmp );
AS3_ByteArray_readBytes( &usTmp, baBuffer, 2 );
AS3_ByteArray_readBytes( g_aAlpha, baBuffer, usTmp );
AS3_ByteArray_readBytes( &uiTmp, baBuffer, 4 );
AS3_ByteArray_readBytes( g_aRGBIndex, baBuffer, uiTmp );
AS3_Release( args );
AS3_Release( baBuffer );
unsigned char ucAlpha = 0;
unsigned char ucRealAlpha = 0;
unsigned char ucRed = 0;
unsigned char ucGreen = 0;
unsigned char ucBlue = 0;
unsigned char ucAlphaReadBitNum = 8;
int i;
int j;
int iRGBPointer = 0;
int iAlphaPointer = 0;
int iOutPointer = 0;
for ( i = 0; i < usPlteItemNum; i++ )
{
ucRed = g_aPlte[iRGBPointer]; // R
iRGBPointer++;
ucGreen = g_aPlte[iRGBPointer]; // G
iRGBPointer++;
ucBlue = g_aPlte[iRGBPointer]; // B
iRGBPointer++;
if ( !bOneBitAlpha )
{
ucRealAlpha = g_aAlpha[iAlphaPointer];
iAlphaPointer++;
}
else
{
if ( ucAlphaReadBitNum == 8 )
{
ucAlpha = g_aAlpha[iAlphaPointer];
iAlphaPointer++;
ucAlphaReadBitNum = 0;
}
if ( ucAlpha & ( 0x00000001 << ucAlphaReadBitNum ) )
{
ucRealAlpha = 0xFF;
}
else
{
ucRealAlpha = 0;
}
ucAlphaReadBitNum += 1;
}
uiColor = ( ucRealAlpha << 24 ) | ( ucRed << 16 ) | ( ucGreen << 8 ) | ucBlue;
g_aRGBPlte[iOutPointer] = uiColor;
iOutPointer++;
}
unsigned char ucIndex;
iRGBPointer = 0;
for ( j = 0; j < usHeight; j ++ )
{
for ( i = 0; i < usWidth; i++ )
{
ucIndex = g_aRGBIndex[iRGBPointer];
g_aOutRGB[iRGBPointer] = g_aRGBPlte[ucIndex];
iRGBPointer++;
}
}
return AS3_Ptr( g_aOutRGB );
}
//entry point for code
int main()
{
//define the methods exposed to ActionScript
//typed as an ActionScript Function instance
AS3_Val DecodeMethod = AS3_Function( NULL, UnfuckRGBFromCompactBuffer );
// construct an object that holds references to the functions
AS3_Val result = AS3_Object( "UnfuckRGBFromCompactBuffer:AS3ValType", DecodeMethod );
// Release
AS3_Release( DecodeMethod );
// notify that we initialized -- THIS DOES NOT RETURN!
AS3_LibInit( result );
// should never get here!
return 0;
}
North America
Europe, Middle East and Africa
Asia Pacific