Example #1
0
File: osint.c Project: zhuowei/vecx
AS3_Val flash_init(void *data, AS3_Val args){
	FILE *f;
	if(!(f = fopen(romfilename, "rb"))){
		perror(romfilename);
		return AS3_Int(1);
	}
	if(fread(rom, 1, sizeof (rom), f) != sizeof (rom)){
		printf("Invalid rom length\n");
		return AS3_Int(2);
	}
	fclose(f);

	memset(cart, 0, sizeof (cart));
	if(cartfilename){
		FILE *f;
		if(!(f = fopen(cartfilename, "rb"))){
			perror(cartfilename);
			return AS3_Int(2);
		}
		fread(cart, 1, sizeof (cart), f);
		fclose(f);
	}
	vecx_reset();
	return AS3_Int(0);
}
Example #2
0
File: main.c Project: Glideh/jfrec
static AS3_Val init(void * self, AS3_Val args)
{
	void * ref;
	void * src;
	void * dest;
	
	AS3_ArrayValue(args, "AS3ValType, AS3ValType, AS3ValType", &ref, &src, &dest);
	
	flashErrorsRef = (AS3_Val)ref;
	
	config.wave.file	= funopen((void *)src, readByteArray, writeByteArray, seekByteArray, closeByteArray);
	config.wave.output	= funopen((void *)dest, readByteArray, writeByteArray, seekByteArray, closeByteArray);
	
	if (config.wave.file == NULL || config.wave.output == NULL) {
		ERROR("Unable to set bytes arrays");
	}
	
	wave_open();
	
	set_defaults();
    check_config();
		
	start_compress();
	
	return AS3_Int(1);
}
Example #3
0
int push_as3_array_to_lua_stack_convert_values(lua_State * L, AS3_Val array)
{
  LCALL(L, stack);

  int len = 0;
  int i = 0;
  AS3_Val cur;
  AS3_Val len_v;

  if (!AS3_InstanceOf(array, Array_class))
  {
    LRETURN(L, stack, 0);
  }

  len_v = AS3_GetS(array, "length");
  len = AS3_IntValue(len_v);
  SAFE_RELEASE(len_v);

  for (i = 0; i < len; i++)
  {
    AS3_Val i_v = AS3_Int(i);
    cur = AS3_Get(array, i_v);
    SAFE_RELEASE(i_v);
    push_as3_to_lua_stack(L, cur);
    SAFE_RELEASE(cur);
  }

  LRETURN(L, stack, len);
}
Example #4
0
int push_as3_array_to_lua_stack(lua_State * L, AS3_Val array)
{
  LCALL(L, stack);

  int len = 0;
  int i = 0;
  AS3_Val cur;
  AS3_Val len_v;

  if (!AS3_InstanceOf(array, Array_class))
  {
    LRETURN(L, stack, 0);
  }

  len_v = AS3_GetS(array, "length");
  len = AS3_IntValue(len_v);
  SAFE_RELEASE(len_v);

  for (i = 0; i < len; i++)
  {
    AS3_Val i_v = AS3_Int(i);
    cur = AS3_Get(array, i_v);
    SAFE_RELEASE(i_v);
    /* TODO: This probably should be push_as3_to_lua_stack */
    push_as3_lua_userdata(L, cur);
    SAFE_RELEASE(cur);
  }

  LRETURN(L, stack, len);
}
Example #5
0
/**
 * Increases the memory allocation for this sample pointer
 */
static AS3_Val reallocateSampleMemory(void* self, AS3_Val args)
{
	int newframes;
	int oldframes;
	int channels;
	int newsize;
	int oldsize;
	float *buffer;
	
	AS3_ArrayValue(args, "IntType, IntType, IntType", &oldframes, &newframes, &channels);
 
	oldsize = oldframes * channels * sizeof(float);
	newsize = newframes * channels * sizeof(float);
	
	// realloc is slow :(
	buffer = (float *) realloc(buffer, newsize); 
	
	// zero out the new memory
	if(buffer) {
	  memset( buffer + oldframes*channels, 0, newsize - oldsize);
  }
	
	// Return the new sample pointer
	return AS3_Int((int)buffer);  
}
int resetPositionByteArray(AS3_Val byteArray)
{
	AS3_Val zero = AS3_Int(0);
	/* just reset the position */
	AS3_SetS((AS3_Val)byteArray, "position", zero);
	AS3_Release(zero);
	return 0;
}
Example #7
0
File: main.c Project: Glideh/jfrec
static AS3_Val update(void* self, AS3_Val args) {
	
	int statut = update_compress();
	
	if(statut==100) wave_close();
	
	return AS3_Int(statut);
}
Example #8
0
File: main.c Project: Glideh/jfrec
int closeByteArray(void * cookie)
{
	AS3_Val zero = AS3_Int(0);
	
	/* just reset the position */
	AS3_SetS((AS3_Val)cookie, "position", zero);
	AS3_Release(zero);
	return 0;
}
static AS3_Val choosemodel(void* self, AS3_Val args) {
    int il;

	AS3_ArrayValue( args, "IntType", &il );

	L = models + mod_i[il];
	nl = mod_i[il+1] - mod_i[il];
   
	return AS3_Int(0);
}
Example #10
0
/* setup some useful constants */
void initialize_as3_constants()
{
  no_params = AS3_Array("");
  zero_param = AS3_Int(0);
  Number_class = get_class2(NULL, "Number");
  int_class = get_class2(NULL, "int");
  String_class = get_class2(NULL, "String");
  Boolean_class = get_class2(NULL, "Boolean");
  flash_utils_namespace = AS3_String("flash.utils");
  getQualifiedClassName_method = AS3_NSGetS(flash_utils_namespace, "getQualifiedClassName");
  Array_class = get_class2(NULL, "Array");
}
static AS3_Val initparam(void* self, AS3_Val args) {
	AS3_Val	tmp = AS3_Undefined();
    int il, len;

    for (il=0; il < sizeof(models)/sizeof(LAYER); ++il) {
        tmp = AS3_Get(args, AS3_Int(2*il));
        len = AS3_IntValue(AS3_GetS(tmp, "length"));
        models[il].w = (float*) malloc(len);
        AS3_ByteArray_readBytes(models[il].w, tmp, len);

        tmp = AS3_Get(args, AS3_Int(2*il+1));
        len = AS3_IntValue(AS3_GetS(tmp, "length"));
        models[il].b = (float*) malloc(len);
        AS3_ByteArray_readBytes(models[il].b, tmp, len);
    }
    
    data = (float*) malloc(BUF_SIZE);
    o = (float*) malloc(BUF_SIZE);
        
	return AS3_Int(0);
}
Example #12
0
AS3_Val f_setup (void *data, AS3_Val args)
{
  pdfapp_init(&gapp);
  
  gapp.scrw = 300;
	gapp.scrh = 800;
	gapp.zoom = 100.0;
	gapp.pageno = 1;
	
  pdfapp_open(&gapp, "pdfBytes");
  
  return AS3_Int(0);
}
/* Получить количество элементов массива */
AS3_Val QSPGetVarValuesCount(void *param, AS3_Val args)
{
	char *name;
	QSP_CHAR *nameWC;
	QSPVar *var;
	AS3_ArrayValue(args, "StrType", &name);
	if (qspIsExitOnError && qspErrorNum) return AS3_Null();
	qspResetError();
	nameWC = qspC2W(name);
	var = qspVarReference(nameWC, QSP_FALSE);
	free(nameWC);
	if (qspErrorNum) return AS3_Null();
	return AS3_Int(var->ValsCount);
}
Example #14
0
/**
 * Returns a pointer to the memory allocated for this sample.
 * Every frame value is a float, as Flash's native sound format is a 32bit float
 *  and we don't want to waste time converting back and forth to doubles.
 * The sample is zeroed.
 * Stereo samples are interleaved.
 */ 
static AS3_Val allocateSampleMemory(void* self, AS3_Val args)
{
	int frames;
	int channels;
	int size;
	int zero;
	float *buffer;
	
	AS3_ArrayValue(args, "IntType, IntType, IntType", &frames, &channels, &zero);
 
	size = frames * channels * sizeof(float);
	buffer = (float *) malloc(size); 
	
	// If zero is true, then we must zero out this sample
	// Otherwise, it is more efficient to leave it full of junk, if it's going to be overwritten
	if (buffer && zero) {
		memset(buffer, 0, size);
	}
	
	// Return the sample pointer
	return AS3_Int((int)buffer);  
}
/* Количество объектов */
AS3_Val QSPGetObjectsCount(void *param, AS3_Val args)
{
	return AS3_Int(qspCurObjectsCount);
}
Example #16
0
static AS3_Val memFree(void* self, AS3_Val args)
{
	return AS3_Int(0);
}
Example #17
0
static AS3_Val callJsCallback(void* self, AS3_Val args)
{
	return AS3_Int(0);
}
Example #18
0
static AS3_Val memorySet(void* self, AS3_Val args)
{
	return AS3_Int(0);
}
Example #19
0
static AS3_Val memAlloc(void* self, AS3_Val args)
{
	return AS3_Int(0);
}
Example #20
0
File: osint.c Project: zhuowei/vecx
AS3_Val flash_keydown(void *data, AS3_Val args){
	return AS3_Int(0);
}
Example #21
0
static AS3_Val incValue(void* self, AS3_Val args)
{
	return AS3_Int(0);
}
Example #22
0
File: osint.c Project: zhuowei/vecx
AS3_Val flash_reset(void *data, AS3_Val args){
	vecx_reset();
	return AS3_Int(0);
}
Example #23
0
File: osint.c Project: zhuowei/vecx
AS3_Val flash_tick(void *data, AS3_Val args){
	vecx_emu((VECTREX_MHZ / 1000) * EMU_TIMER, 0);
	return AS3_Int(0);
}
/* Количество полных обновлений локаций */
AS3_Val QSPGetFullRefreshCount(void *param, AS3_Val args)
{
	return AS3_Int(qspFullRefreshCount);
}
/* Получить максимальное количество переменных */
AS3_Val QSPGetMaxVarsCount(void *param, AS3_Val args)
{
	return AS3_Int(QSP_VARSCOUNT);
}
/* Количество действий */
AS3_Val QSPGetActionsCount(void *param, AS3_Val args)
{
	return AS3_Int(qspCurActionsCount);
}
/* Получить индекс выбранного действия */
AS3_Val QSPGetSelActionIndex(void *param, AS3_Val args)
{
	return AS3_Int(qspCurSelAction);
}
Example #28
0
AS3_Val f_tick (void *data, AS3_Val args)
{
  // Blit
  
  return AS3_Int(0);
}
Example #29
0
AS3_Val f_teardown (void *data, AS3_Val args)
{
  pdfapp_close(&gapp);
  
  return AS3_Int(0);
}
/* Получить индекс выбранного объекта */
AS3_Val QSPGetSelObjectIndex(void *param, AS3_Val args)
{
	return AS3_Int(qspCurSelObject);
}