示例#1
0
文件: sprites.c 项目: nlasheras/gamba
void sprite_init(Sprite* sprite, int gfxID)
{
    const int oamIdx = oam_pool_find_fist_empty();

    sprite->gfxID = gfxID;

    SpriteEntry* oam = &sm_OAMCopy[oamIdx];
    sprite->oam = oam;

    oam->attribute[0] = OBJ_256_COLOR | OBJ_SHAPE(0);
    oam->attribute[1] = OBJ_SIZE(1);
    oam->attribute[2] = gfxID;
}
示例#2
0
文件: wav.c 项目: jbmulligan/quip
//int _wav_to_dp(QSP_ARG_DECL  Data_Obj *dp,Wav_Header *hd_p)
FIO_FT_TO_DP_FUNC(wav,Wav_Header)
{
	Precision * prec_p;
	dimension_t total_samples, samples_per_channel;

	switch( hd_p->wh_bits_per_sample ){
		case 8:  prec_p=PREC_FOR_CODE(PREC_UBY); break;
		case 16: prec_p=PREC_FOR_CODE(PREC_IN); break;
		default:
			sprintf(ERROR_STRING,
		"wav_to_dp:  unexpected # of bits per sample %d",
				hd_p->wh_bits_per_sample);
			warn(ERROR_STRING);
			return(-1);
	}
	SET_OBJ_PREC_PTR(dp, prec_p);

	SET_OBJ_COMPS(dp, hd_p->wh_n_channels );

	total_samples = (dimension_t) (hd_p->wh_datasize / PREC_SIZE( prec_p ));
	samples_per_channel = total_samples / OBJ_COMPS(dp);

	SET_OBJ_COLS(dp, samples_per_channel);
	SET_OBJ_ROWS(dp, 1);
	SET_OBJ_FRAMES(dp, 1);
	SET_OBJ_SEQS(dp, 1);

	SET_OBJ_COMP_INC(dp, 1);
	SET_OBJ_PXL_INC(dp, 1);
	SET_OBJ_ROW_INC(dp, 1);
	SET_OBJ_FRM_INC(dp, 1);
	SET_OBJ_SEQ_INC(dp, 1);

	SET_OBJ_PARENT(dp, NULL);
	SET_OBJ_CHILDREN(dp, NULL);

	SET_OBJ_AREA(dp, ram_area_p);		/* the default */

	/* dp->dt_data = hd_p->image; */		/* where do we allocate data??? */

	SET_OBJ_N_TYPE_ELTS(dp, OBJ_COMPS(dp) * OBJ_COLS(dp) * OBJ_ROWS(dp)
			* OBJ_FRAMES(dp) * OBJ_SEQS(dp) );

	auto_shape_flags(OBJ_SHAPE(dp));

	return 0;
}
示例#3
0
void _gen_xpose(QSP_ARG_DECL  Data_Obj *dp,int dim1,int dim2)
{
	dimension_t	tmp_dim;
	incr_t		tmp_inc;

	assert( dim1 >= 0 && dim1 < N_DIMENSIONS );
	assert( dim2 >= 0 && dim2 < N_DIMENSIONS );

	EXCHANGE_DIMS(OBJ_TYPE_DIMS(dp),dim1,dim2)
	EXCHANGE_DIMS(OBJ_MACH_DIMS(dp),dim1,dim2)

	EXCHANGE_INCS(OBJ_TYPE_INCS(dp),dim1,dim2)
	EXCHANGE_INCS(OBJ_MACH_INCS(dp),dim1,dim2)

	/* should this be CAUTIOUS??? */ 
	if( auto_shape_flags(OBJ_SHAPE(dp)) < 0 )
		warn("gen_xpose:  RATS!?");

	check_contiguity(dp);
}
示例#4
0
void transpose(QSP_ARG_DECL  Data_Obj *dpto,Data_Obj *dpfr)
{
	/* new version using gen_xpose */

	Data_Obj *tmp_dp;
	Vec_Obj_Args oa1, *oap=&oa1;

	// BUG use a macro for this...
	tmp_dp=NEW_DOBJ;

	OBJ_COPY_FROM(tmp_dp,dpfr);
	// after the copy, the shape pointer is the same as the parent's...
	DUP_OBJ_SHAPE(tmp_dp,dpfr);

	gen_xpose(tmp_dp,1,2);		/* switch rows, cols */

	setvarg2(oap,dpto,tmp_dp);
	perf_vfunc(QSP_ARG  FVMOV,oap);

	// tmp_dp has no resources except is shape...
	rls_shape( OBJ_SHAPE(tmp_dp) );
	givbuf(tmp_dp);
}
示例#5
0
double _get_dobj_il_flg(QSP_ARG_DECL  Data_Obj *dp)
{
	if( INTERLACED_SHAPE( OBJ_SHAPE(dp) ) ) return(1.0);
	else return(0.0);
}
示例#6
0
void _delvec(QSP_ARG_DECL  Data_Obj *dp)
{

	assert(dp!=NULL);
	assert(OBJ_NAME(dp)!=NULL);

#ifdef ZOMBIE_SUPPORT
	// This should go back in eventually!
	if( OBJ_FLAGS(dp) & DT_STATIC && OWNS_DATA(dp) ){
sprintf(ERROR_STRING,"delvec:  static object %s will be made a zombie",OBJ_NAME(dp));
advise(ERROR_STRING);
		make_zombie(dp);
		return;
	}


	if( OBJ_REFCOUNT(dp) > 0 ){
		/* This zombie business was introduced at a time
		 * when a displayed image had to be kept around
		 * to refresh its window...  with the current
		 * X windows implementation of viewers that is
		 * no longer the case, so this may be unecessary...
		 *
		 * But another case arises when we have a static
		 * object in the expression language, that gets
		 * deleted outside of the expression language.
		 * This shouldn't be done, but we don't want to
		 * be able to crash the program either...
		 */

sprintf(ERROR_STRING,"delvec:  object %s (refcount = %d) will be made a zombie",OBJ_NAME(dp),dp->dt_refcount);
advise(ERROR_STRING);
		make_zombie(dp);
		return;
	}
#endif /* ZOMBIE_SUPPORT */

	// If the object has been exported, we need to delete
	// the associated identifier...
	//
	// BUT if it was exported, then it may be referenced!?
	// So it should be static...
	//
	// If we have references, and are therefore keeping the
	// object as a zombie, then we don't want to delete the
	// identifier, and we probably don't want to change the
	// object's name...

	if( IS_EXPORTED(dp) ){
		Identifier *idp;

		idp = id_of(OBJ_NAME(dp));
		assert( idp != NULL );
		delete_id((Item *)idp);
	}

	if( OBJ_CHILDREN( dp ) != NULL ){
		delete_subobjects(dp);
	}
	if( OBJ_PARENT(dp) != NULL ){
		disown_child(dp);
	}

	if( IS_TEMP(dp) ){

if( OBJ_DECLFILE(dp) != NULL ){
sprintf(ERROR_STRING,"delvec %s:  temp object has declfile %s!?\n",
OBJ_NAME(dp),OBJ_DECLFILE(dp));
advise(ERROR_STRING);
}
		release_tmp_obj(dp);
		/*
		 * Most likely called when parent is deleted.
		 * Temp objects are not hashed, and are not dynamically
		 * allocated.
		 *
		 * Simply mark as free by clearing name field.
		 */
		return;
	}

	// We might clean this up by making the release
	// function a platform member...

	if( OWNS_DATA(dp) ){
		if( ! UNKNOWN_SHAPE(OBJ_SHAPE(dp)) ){
			release_data(dp);
		}
	}
	// In the first OpenCL implementation, we used subbuffers, which had
	// to be released here even for subimages.  But now we handle subobjects
	// ourselves, managing offsets, so non-data-owners don't need to release.

	rls_shape( OBJ_SHAPE(dp) );

	// We don't need to do this if we have garbage collection?
	/* The name might be null if we had an error creating the object... */
	if( OBJ_DECLFILE(dp) != NULL ){
		rls_str( OBJ_DECLFILE(dp) );
	}

#ifdef ZOMBIE_SUPPORT
	/* BUG context code assumes that this is really deleted... */
	// not sure I understand the above comment?
	if( IS_ZOMBIE(dp) ){
		// The object is a zombie that is no longer referenced...

		/* NOTE:  we used to release the struct here with givbuf,
		 * but in the current implementation of the item package,
		 * objects aren't allocated with getbuf!
		 */

		// The object has already been removed from the dictionary,
		// so we don't need to call del_item...

		/* put this back on the free list... */
		recycle_item(dobj_itp,dp);
	} else {
		del_item(dobj_itp, dp );
	}
#else /* ! ZOMBIE_SUPPORT */

	DELETE_OBJ_ITEM(dp);	// del_dobj - item function

#endif /* ! ZOMBIE_SUPPORT */

	// used to release the name here
	// and set to null, but that is done in del_item
}
void
SpriteRenderer::update()
{
  for(int i = 0; i < 128; ++i)
    {
      // OAM[i].attr0 = OBJ_Y(80)  | OBJ_SHAPE(0) | OBJ_256_COLOR;
      // OAM[i].attr1 = OBJ_X(120) | OBJ_SIZE(2);
      // OAM[i].attr2 = OBJ_CHAR(8) | OBJ_PALETTE(0) | OBJ_PRIORITY(0);
      Sprite& sprite = sprites[i];
      if (sprite.is_enabled())
        {
          OAM[i].attr0 = OBJ_Y((sprite.get_y() - sprite.get_data().get_y_align() - y_offset) & 0xFF) | OBJ_SHAPE(0) | OBJ_256_COLOR;
          OAM[i].attr1 = 
            OBJ_X((sprite.get_x() - sprite.get_data().get_x_align() - x_offset) & 0xFF) |
            OBJ_SIZE(2) |
            (sprite.get_vflip() ? OBJ_VFLIP : 0) |
            (sprite.get_hflip() ? OBJ_HFLIP : 0);
          OAM[i].attr2 = OBJ_CHAR(sprite.get_data().get_char_addr(sprite.get_frame())) | OBJ_PALETTE(0) | OBJ_PRIORITY(0);          
        }
      else
        {
          OAM[i].attr0 = OBJ_DISABLE; // OBJ_Y(80)  | OBJ_SHAPE(0) | OBJ_256_COLOR;
          OAM[i].attr1 = 0; // OBJ_X(120) | OBJ_SIZE(2);
          OAM[i].attr2 = 0; // OBJ_CHAR(8) | OBJ_PALETTE(0) | OBJ_PRIORITY(0);
        }
    }
}