Exemple #1
0
/*
=================
CG_UI_DrawProportionalString
=================
*/
void CG_UI_DrawProportionalString( int x, int y, const char* str, int style, vec4_t color ) {
	vec4_t	drawcolor;
	int		width;
	gfixed	sizeScale;

	sizeScale = CG_UI_ProportionalSizeScale( style );

	switch( style & UI_FORMATMASK ) {
		case UI_CENTER:
			width = FIXED_TO_INT(MAKE_GFIXED(CG_UI_ProportionalStringWidth( str ) ) * sizeScale);
			x -= width / 2;
			break;

		case UI_RIGHT:
			width = FIXED_TO_INT(MAKE_GFIXED(CG_UI_ProportionalStringWidth( str ) ) * sizeScale);
			x -= width;
			break;

		case UI_LEFT:
		default:
			break;
	}

	if ( style & UI_DROPSHADOW ) {
		drawcolor[0] = drawcolor[1] = drawcolor[2] = GFIXED_0;
		drawcolor[3] = color[3];
		CG_UI_DrawProportionalString2( x+2, y+2, str, drawcolor, sizeScale, cgs.media.charsetProp );
	}

	if ( style & UI_INVERSE ) {
		drawcolor[0] = color[0] * GFIXED(0,8);
		drawcolor[1] = color[1] * GFIXED(0,8);
		drawcolor[2] = color[2] * GFIXED(0,8);
		drawcolor[3] = color[3];
		CG_UI_DrawProportionalString2( x, y, str, drawcolor, sizeScale, cgs.media.charsetProp );
		return;
	}

	if ( style & UI_PULSE ) {
		drawcolor[0] = color[0] * GFIXED(0,8);
		drawcolor[1] = color[1] * GFIXED(0,8);
		drawcolor[2] = color[2] * GFIXED(0,8);
		drawcolor[3] = color[3];
		CG_UI_DrawProportionalString2( x, y, str, color, sizeScale, cgs.media.charsetProp );

		drawcolor[0] = color[0];
		drawcolor[1] = color[1];
		drawcolor[2] = color[2];
		drawcolor[3] = GFIXED(0,5) + GFIXED(0,5) * FIXED_SIN( FIXED_INT32RATIO_G(cg.time,PULSE_DIVISOR) );
		CG_UI_DrawProportionalString2( x, y, str, drawcolor, sizeScale, cgs.media.charsetPropGlow );
		return;
	}

	CG_UI_DrawProportionalString2( x, y, str, color, sizeScale, cgs.media.charsetProp );
}
Exemple #2
0
/*
==================
CG_BubbleTrail

Bullets shot underwater
==================
*/
void CG_BubbleTrail( bvec3_t start, bvec3_t end, bfixed spacing ) {
	bvec3_t		move;
	bvec3_t		vec;
	bfixed		len;
	int			i;

	if ( cg_noProjectileTrail.integer ) {
		return;
	}

	VectorCopy (start, move);
	VectorSubtract (end, start, vec);
	len = VectorNormalize (vec);

	// advance a random amount first
	i = rand() % FIXED_TO_INT(spacing);
	FIXED_VEC3MA( move, MAKE_BFIXED(i), vec, move );

	FIXED_VEC3SCALE (vec, spacing, vec);

	for ( ; MAKE_BFIXED(i) < len; i += FIXED_TO_INT(spacing) ) {
		localEntity_t	*le;
		refEntity_t		*re;

		le = CG_AllocLocalEntity();
		le->leFlags = LEF_PUFF_DONT_SCALE;
		le->leType = LE_MOVE_SCALE_FADE;
		le->startTime = cg.time;
		le->endTime = cg.time + 1000 + FIXED_TO_INT(random() * GFIXED(250,0));
		le->lifeRate = FIXED_INT32RATIO_G(1,( le->endTime - le->startTime ));

		re = &le->refEntity;
		re->shaderTime = MSECTIME_G(cg.time);

		re->reType = RT_SPRITE;
		re->rotation = AFIXED_0;
		re->radius = BFIXED(3,0);
		re->customShader = cgs.media.waterBubbleShader;
		re->shaderRGBA[0] = 0xff;
		re->shaderRGBA[1] = 0xff;
		re->shaderRGBA[2] = 0xff;
		re->shaderRGBA[3] = 0xff;

		le->color[3] = GFIXED_1;

		le->pos.trType = TR_LINEAR;
		le->pos.trTime = cg.time;
		VectorCopy( move, le->pos.trBase );
		le->pos.trDelta[0] = crandom_b()*BFIXED(5,0);
		le->pos.trDelta[1] = crandom_b()*BFIXED(5,0);
		le->pos.trDelta[2] = crandom_b()*BFIXED(5,0) + BFIXED(6,0);

		VectorAdd (move, vec, move);
	}
}
void dungeon2_wild_pokemon_sample_level_boundaries(u8 *level_min, u8 *level_max, u8 mean,
    u8 std_deviation, dungeon_generator2 *dg2) {
  FIXED fx1 = FIXED_ADD(INT_TO_FIXED(mean), FIXED_MUL(INT_TO_FIXED(std_deviation),
      dungeon2_rnd_normal(dg2)));
  FIXED fx2 = FIXED_ADD(INT_TO_FIXED(mean), FIXED_MUL(INT_TO_FIXED(std_deviation),
      dungeon2_rnd_normal(dg2)));
  int x1 = min(100, max(2, FIXED_TO_INT(fx1)));
  int x2 = min(100, max(2, FIXED_TO_INT(fx2)));
  *level_min = (u8)min(x1, x2);
  *level_max = (u8)max(x1, x2);
}
Exemple #4
0
/*
================
CG_CenterGiantLine
================
*/
static void CG_CenterGiantLine( gfixed y, const char *string ) {
	gfixed		x;
	vec4_t		color;

	color[0] = GFIXED_1;
	color[1] = GFIXED_1;
	color[2] = GFIXED_1;
	color[3] = GFIXED_1;

	x = GFIXED(0,5) * MAKE_GFIXED( 640 - GIANT_WIDTH * CG_DrawStrlen( string ) );

	CG_DrawStringExt( FIXED_TO_INT(x), FIXED_TO_INT(y), string, color, qtrue, qtrue, GIANT_WIDTH, GIANT_HEIGHT, 0 );
}
Exemple #5
0
// Precomputes tables for 8-bit on input devicelink. 
// 
LPLUT _cmsBlessLUT8(LPLUT Lut)
{
   int i, j;
   WORD StageABC[3];
   Fixed32 v1, v2, v3;
   LPL8PARAMS p8; 
   LPL16PARAMS p = &Lut ->CLut16params;

  
   p8 = (LPL8PARAMS) malloc(sizeof(L8PARAMS));
   if (p8 == NULL) return NULL;

  // values comes * 257, so we can safely take first byte (x << 8 + x)
  // if there are prelinearization, is already smelted in tables

   for (i=0; i < 256; i++) {

           StageABC[0] = StageABC[1] = StageABC[2] = RGB_8_TO_16(i);

           if (Lut ->wFlags & LUT_HASTL1) {

              for (j=0; j < 3; j++)
                     StageABC[i] = cmsLinearInterpLUT16(StageABC[i],
                                                        Lut -> L1[i],
                                                       &Lut -> In16params);
              Lut ->wFlags &= ~LUT_HASTL1;
           }
    
               
           v1 = ToFixedDomain(StageABC[0] * p -> Domain);
           v2 = ToFixedDomain(StageABC[1] * p -> Domain);
           v3 = ToFixedDomain(StageABC[2] * p -> Domain);

           p8 ->X0[i] = p->opta3 * FIXED_TO_INT(v1);
           p8 ->Y0[i] = p->opta2 * FIXED_TO_INT(v2);
           p8 ->Z0[i] = p->opta1 * FIXED_TO_INT(v3);

           p8 ->rx[i] = (WORD) FIXED_REST_TO_INT(v1);
           p8 ->ry[i] = (WORD) FIXED_REST_TO_INT(v2);
           p8 ->rz[i] = (WORD) FIXED_REST_TO_INT(v3);
  
  }

   Lut -> CLut16params.p8 = p8;
   Lut -> CLut16params.Interp3D = cmsTetrahedralInterp8;

   return Lut;

}
Exemple #6
0
/*
==================
CG_LaunchGib
==================
*/
void CG_LaunchExplode( bvec3_t origin, bvec3_t velocity, qhandle_t hModel ) {
	localEntity_t	*le;
	refEntity_t		*re;

	le = CG_AllocLocalEntity();
	re = &le->refEntity;

	le->leType = LE_FRAGMENT;
	le->startTime = cg.time;
	le->endTime = le->startTime + 10000 + FIXED_TO_INT(random() * GFIXED(6000,0));

	VectorCopy( origin, re->origin );
	AxisCopy( aaxisDefault, re->axis );
	re->hModel = hModel;

	le->pos.trType = TR_GRAVITY;
	VectorCopy( origin, le->pos.trBase );
	VectorCopy( velocity, le->pos.trDelta );
	le->pos.trTime = cg.time;

	le->bounceFactor = BFIXED(0,1);

	le->leBounceSoundType = LEBS_BRASS;
	le->leMarkType = LEMT_NONE;
}
Exemple #7
0
/*
================
CheckArmor
================
*/
int CheckArmor (gentity_t *ent, int damage, int dflags)
{
	gclient_t	*client;
	int			save;
	int			count;

	if (!damage)
		return 0;

	client = ent->client;

	if (!client)
		return 0;

	if (dflags & DAMAGE_NO_ARMOR)
		return 0;

	// armor
	count = client->ps.stats[STAT_ARMOR];
	save = FIXED_TO_INT(FIXED_CEIL( MAKE_GFIXED(damage) * ARMOR_PROTECTION ));
	if (save >= count)
		save = count;

	if (!save)
		return 0;

	client->ps.stats[STAT_ARMOR] -= save;

	return save;
}
Exemple #8
0
static
void Eval8Inputs(WORD StageABC[], WORD StageLMN[], WORD LutTable[], LPL16PARAMS p16)
{       
       Fixed32 fk;
       Fixed32 k0, rk;
       int K0, K1;
       LPWORD T;
       int i;
       WORD Tmp1[MAXCHANNELS], Tmp2[MAXCHANNELS];

       
       fk = ToFixedDomain((Fixed32) StageABC[0] * p16 -> Domain);
       k0 = FIXED_TO_INT(fk);
       rk = FIXED_REST_TO_INT(fk);

       K0 = p16 -> opta8 * k0;
       K1 = p16 -> opta8 * (k0 + (StageABC[0] != 0xFFFFU ? 1 : 0));

       p16 -> nInputs = 7;

       T = LutTable + K0;

       Eval7Inputs(StageABC + 1, Tmp1, T, p16);

       T = LutTable + K1;

       Eval7Inputs(StageABC + 1, Tmp2, T, p16);

       p16 -> nInputs = 8;
       for (i=0; i < p16 -> nOutputs; i++)
       {
              StageLMN[i] = (WORD) FixedLERP(rk, Tmp1[i], Tmp2[i]);
       }

}
Exemple #9
0
/*
================
CG_AddSpriteExplosion
================
*/
static void CG_AddSpriteExplosion( localEntity_t *le ) {
	refEntity_t	re;
	gfixed c;

	re = le->refEntity;

	c = FIXED_INT32RATIO_G(( le->endTime - cg.time ),( le->endTime - le->startTime ));
	if ( c > GFIXED_1 ) {
		c = GFIXED_1;	// can happen during connection problems
	}

	re.shaderRGBA[0] = 255;
	re.shaderRGBA[1] = 255;
	re.shaderRGBA[2] = 255;
	re.shaderRGBA[3] = FIXED_TO_INT(GFIXED(255,0) * c * GFIXED(0,33));

	re.reType = RT_SPRITE;
	re.radius = BFIXED(42,0) * MAKE_BFIXED( GFIXED_1 - c ) + BFIXED(30,0);

	_CG_trap_R_AddRefEntityToScene( &re );

	// add the dlight
	if ( FIXED_NOT_ZERO(le->light) ) {
		gfixed		light;

		light = FIXED_INT32RATIO_G(( cg.time - le->startTime ),( le->endTime - le->startTime ));
		if ( light < GFIXED(0,5) ) {
			light = GFIXED_1;
		} else {
			light = GFIXED_1 - ( light - GFIXED(0,5) ) * GFIXED(2,0);
		}
		light = le->light * light;
		_CG_trap_R_AddLightToScene(re.origin, light, le->lightColor[0], le->lightColor[1], le->lightColor[2] );
	}
}
Exemple #10
0
/*
=================
CG_AddFallScaleFade

This is just an optimized CG_AddMoveScaleFade
For blood mists that drift down, fade out, and are
removed if the view passes through them.
There are often 100+ of these, so it needs to be simple.
=================
*/
static void CG_AddFallScaleFade( localEntity_t *le ) {
	refEntity_t	*re;
	gfixed		c;
	bvec3_t		delta;
	bfixed		len;

	re = &le->refEntity;

	// fade time
	c = MAKE_GFIXED( le->endTime - cg.time ) * le->lifeRate;

	re->shaderRGBA[3] = FIXED_TO_INT(GFIXED(255,0) * c * le->color[3]);

	re->origin[2] = le->pos.trBase[2] - MAKE_BFIXED( GFIXED_1 - c ) * le->pos.trDelta[2];

	re->radius = le->radius * MAKE_BFIXED( GFIXED_1 - c ) + BFIXED(16,0);

	// if the view would be "inside" the sprite, kill the sprite
	// so it doesn't add too much overdraw
	VectorSubtract( re->origin, cg.refdef.vieworg, delta );
	len = FIXED_VEC3LEN( delta );
	if ( len < le->radius ) {
		CG_FreeLocalEntity( le );
		return;
	}

	_CG_trap_R_AddRefEntityToScene( re );
}
Exemple #11
0
/*
===============
UI_SetBestScore

Set the player's best finish for a level
===============
*/
void UI_SetBestScore( int level, int score ) {
	int		skill;
	int		oldScore;
	char	arenaKey[16];
	char	scores[MAX_INFO_VALUE];

	// validate score
	if( score < 1 || score > 8 ) {
		return;
	}

	// validate skill
	skill = FIXED_TO_INT(_UI_trap_Cvar_VariableValue( "g_spSkill" ));
	if( skill < 1 || skill > 5 ) {
		return;
	}

	// get scores
	_UI_trap_Cvar_VariableStringBuffer( va( "g_spScores%i", skill ), scores, MAX_INFO_VALUE );

	// see if this is better
	Com_sprintf( arenaKey, sizeof( arenaKey ), "l%i", level );
	oldScore = atoi( Info_ValueForKey( scores, arenaKey ) );
	if( oldScore && oldScore <= score ) {
		return;
	}

	// update scores
	Info_SetValueForKey( scores, arenaKey, va( "%i", score ) );
	_UI_trap_Cvar_Set( va( "g_spScores%i", skill ), scores );
}
Exemple #12
0
/*
====================
CG_AddFadeRGB
====================
*/
void CG_AddFadeRGB( localEntity_t *le ) {
	refEntity_t *re;
	gfixed c;

	re = &le->refEntity;

	c = MAKE_GFIXED( le->endTime - cg.time ) * le->lifeRate;
	c *= GFIXED(255,0);

	re->shaderRGBA[0] = FIXED_TO_INT(le->color[0] * c);
	re->shaderRGBA[1] = FIXED_TO_INT(le->color[1] * c);
	re->shaderRGBA[2] = FIXED_TO_INT(le->color[2] * c);
	re->shaderRGBA[3] = FIXED_TO_INT(le->color[3] * c);

	_CG_trap_R_AddRefEntityToScene( re );
}
Exemple #13
0
/*
================
CG_ReflectVelocity
================
*/
void CG_ReflectVelocity( localEntity_t *le, trace_t *trace ) {
	bvec3_t	velocity;
	bfixed	dot;
	int		hitTime;

	// reflect the velocity on the trace plane
	hitTime = cg.time - cg.frametime + FIXED_TO_INT(MAKE_GFIXED(cg.frametime) * trace->fraction);
	BG_EvaluateTrajectoryDelta( &le->pos, hitTime, velocity );
	dot = FIXED_VEC3DOT( velocity, trace->plane.normal );
	FIXED_VEC3MA_R( velocity, -BFIXED(2,0)*dot, trace->plane.normal, le->pos.trDelta );

	FIXED_VEC3SCALE( le->pos.trDelta, le->bounceFactor, le->pos.trDelta );

	VectorCopy( trace->endpos, le->pos.trBase );
	le->pos.trTime = cg.time;


	// check for stop, making sure that even on low FPS systems it doesn't bobble
	if ( trace->allsolid || 
		( trace->plane.normal[2] > AFIXED_0 && 
		( le->pos.trDelta[2] < BFIXED(40,0) || le->pos.trDelta[2] < -MAKE_BFIXED(cg.frametime) * le->pos.trDelta[2] ) ) ) {
		le->pos.trType = TR_STATIONARY;
	} else {

	}
}
Exemple #14
0
void playerUpdate(PlayerData* pData, unsigned long dt) {
  Note note;
  
  if (pData->pNote == 0) {
    // end of data reached
    return;
  }
  
  pData->elapsedMsec += FIXED_MAKE(dt);
  if (pData->elapsedMsec < pData->t) {
    dprintf(
        "interpolate: elapsedMsec=%d t=%d\n",
        FIXED_TO_INT(pData->elapsedMsec), FIXED_TO_INT(pData->t));
    // interpolate
    FIXED tt = (pData->t == 0) ? FIXED_MAKE(1) : FIXED_DIV(pData->elapsedMsec, pData->t);
    pData->r = lerp(pData->r0, pData->r1, tt);
    pData->g = lerp(pData->g0, pData->g1, tt);
    pData->b = lerp(pData->b0, pData->b1, tt);
    
  } else {
    while (pData->elapsedMsec >= pData->t) {
      // advance index and see if end of data reached
      ++pData->pNote;
      memcpy_P(&note, pData->pNote, sizeof(note));

      if (note.msec < 0) {
        // set the final color
        pData->r = pData->r1;
        pData->g = pData->g1;
        pData->b = pData->b1;
	pData->pNote = 0;
	return;
      }

      pData->r = pData->r0 = pData->r1;
      pData->g = pData->g0 = pData->g1;
      pData->b = pData->b0 = pData->b1;

      pData->r1 = FIXED_MAKE(note.r);
      pData->g1 = FIXED_MAKE(note.g);
      pData->b1 = FIXED_MAKE(note.b);

      pData->t = FIXED_MAKE(note.msec);
      pData->elapsedMsec -= pData->t;
    }
  }
}
Exemple #15
0
//===========================================================================
// called when the library is first loaded
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
int AAS_Setup(void)
{
	aasworld.maxclients = FIXED_TO_INT(LibVarValue("maxclients", "128"));
	aasworld.maxentities = FIXED_TO_INT(LibVarValue("maxentities", "1024"));
	// as soon as it's set to 1 the routing cache will be saved
	saveroutingcache = LibVar("saveroutingcache", "0");
	//allocate memory for the entities
	if (aasworld.entities) FreeMemory(aasworld.entities);
	aasworld.entities = (aas_entity_t *) GetClearedHunkMemory(aasworld.maxentities * sizeof(aas_entity_t));
	//invalidate all the entities
	AAS_InvalidateEntities();
	//force some recalculations
	//LibVarSet("forceclustering", "1");			//force clustering calculation
	//LibVarSet("forcereachability", "1");		//force reachability calculation
	aasworld.numframes = 0;
	return BLERR_NOERROR;
} //end of the function AAS_Setup
int main(void) {

    // Init PIC24
    InitMain();

    // Init modules
    AudioInInit();
    Uart2Init(UART_BAUD_250000, 0);
    LedsInit();

    // Main loop
    while(1) {
        if(AudioInIsGetReady()) {
            Fixed audioSample = AudioInGet();

            // Update LEDs
            LedsUpdate(audioSample);

            // Print audio sample
            Uart2RxTasks();
            if(Uart2IsPutReady() >= 6) {
                static const char asciiDigits[10] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
                int i = FIXED_TO_INT(audioSample);
                div_t n;
                int print = 0;
                if(i < 0) {
                    Uart2PutChar('-');
                    i = -i;
                }
                if(i >= 10000) {
                    n = div(i, 10000);
                    Uart2PutChar(asciiDigits[n.quot]);
                    i = n.rem;
                    print = 1;
                }
                if(i >= 1000 || print) {
                    n = div(i, 1000);
                    Uart2PutChar(asciiDigits[n.quot]);
                    i = n.rem;
                    print = 1;
                }
                if(i >= 100 || print) {
                    n = div(i, 100);
                    Uart2PutChar(asciiDigits[n.quot]);
                    i = n.rem;
                    print = 1;
                }
                if(i >= 10 || print) {
                    n = div(i, 10);
                    Uart2PutChar(asciiDigits[n.quot]);
                    i = n.rem;
                }
                Uart2PutChar(asciiDigits[i]);
                Uart2PutChar('\r');
            }
        }
    }
}
Exemple #17
0
/*
===========
SelectRandomFurthestSpawnPoint

Chooses a player start, deathmatch start, etc
============
*/
gentity_t *SelectRandomFurthestSpawnPoint ( bvec3_t avoidPoint, bvec3_t origin, avec3_t angles ) {
	gentity_t	*spot;
	bvec3_t		delta;
	bfixed		dist;
	bfixed		list_dist[64];
	gentity_t	*list_spot[64];
	int			numSpots, rnd, i, j;

	numSpots = 0;
	spot = NULL;

	while ((spot = G_Find (spot, FOFS(classname), "info_player_deathmatch")) != NULL) {
		if ( SpotWouldTelefrag( spot ) ) {
			continue;
		}
		VectorSubtract( spot->s.origin, avoidPoint, delta );
		dist = FIXED_VEC3LEN( delta );
		for (i = 0; i < numSpots; i++) {
			if ( dist > list_dist[i] ) {
				if ( numSpots >= 64 )
					numSpots = 64-1;
				for (j = numSpots; j > i; j--) {
					list_dist[j] = list_dist[j-1];
					list_spot[j] = list_spot[j-1];
				}
				list_dist[i] = dist;
				list_spot[i] = spot;
				numSpots++;
				if (numSpots > 64)
					numSpots = 64;
				break;
			}
		}
		if (i >= numSpots && numSpots < 64) {
			list_dist[numSpots] = dist;
			list_spot[numSpots] = spot;
			numSpots++;
		}
	}
	if (!numSpots) {
		spot = G_Find( NULL, FOFS(classname), "info_player_deathmatch");
		if (!spot)
			G_Error( "Couldn't find a spawn point" );
		VectorCopy (spot->s.origin, origin);
		origin[2] += BFIXED(9,0);
		VectorCopy (spot->s.angles, angles);
		return spot;
	}

	// select a random spot from the spawn points furthest away
	rnd = FIXED_TO_INT(random() * FIXED_DIVPOW2(MAKE_GFIXED(numSpots),1));

	VectorCopy (list_spot[rnd]->s.origin, origin);
	origin[2] += BFIXED(9,0);
	VectorCopy (list_spot[rnd]->s.angles, angles);

	return list_spot[rnd];
}
Exemple #18
0
Bool AnimateObject(object_node *obj, int dt)
{
   Bool need_redraw = False;
   list_type over_list;

   if (OF_FLICKERING == (OF_FLICKERING & obj->flags))
   {
      obj->lightAdjust = rand() % FLICKER_LEVEL;
      need_redraw = TRUE;
   }

   if (OF_FLASHING == (OF_FLASHING & obj->flags))
   {
      DWORD angleFlash;
      obj->bounceTime += min(dt,50);
      if (obj->bounceTime > TIME_FLASH)
         obj->bounceTime -= TIME_FLASH;
      angleFlash = NUMDEGREES * obj->bounceTime / TIME_FLASH;
      obj->lightAdjust = FIXED_TO_INT(fpMul(FLASH_LEVEL, SIN(angleFlash)));
      need_redraw = TRUE;
   }

   if (obj->animate->animation != ANIMATE_NONE)
   {
      object_bitmap_type obj_bmap;
      obj_bmap = FindObjectBitmap(obj->icon_res);
      if (obj_bmap != NULL)
    need_redraw |= AnimateSingle(obj->animate, BitmapsNumGroups(obj_bmap->bmaps), dt);
   }
   
   if (OF_PHASING == (OF_PHASING & obj->flags))
   {
      int anglePhase;
      obj->phaseTime += min(dt,40);
      if (obj->phaseTime > TIME_FULL_OBJECT_PHASE)
         obj->phaseTime -= TIME_FULL_OBJECT_PHASE;
      anglePhase = numPhases * obj->phaseTime / TIME_FULL_OBJECT_PHASE;
      obj->drawingtype = phaseStates[anglePhase];
      need_redraw = TRUE;
   }
   // Animate object's overlays
   for (over_list = *(obj->overlays); over_list != NULL; over_list = over_list->next)
   {
      object_bitmap_type obj_bmap;
      Overlay *overlay = (Overlay *) (over_list->data);
      if (overlay->animate.animation == ANIMATE_NONE)
    continue;

      obj_bmap = FindObjectBitmap(overlay->icon_res);
      if (obj_bmap != NULL)
      {
    need_redraw |= AnimateSingle(&overlay->animate, BitmapsNumGroups(obj_bmap->bmaps), dt);
      }      
   }
   return need_redraw;
}
  T1_Get_Advances( FT_Face    t1face,        /* T1_Face */
                   FT_UInt    first,
                   FT_UInt    count,
                   FT_Int32   load_flags,
                   FT_Fixed*  advances )
  {
    T1_Face        face  = (T1_Face)t1face;
    T1_DecoderRec  decoder;
    T1_Font        type1 = &face->type1;
    PSAux_Service  psaux = (PSAux_Service)face->psaux;
    FT_UInt        nn;
    FT_Error       error;


    if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
    {
      for ( nn = 0; nn < count; nn++ )
        advances[nn] = 0;

      return FT_Err_Ok;
    }

    error = psaux->t1_decoder_funcs->init( &decoder,
                                           (FT_Face)face,
                                           0, /* size       */
                                           0, /* glyph slot */
                                           (FT_Byte**)type1->glyph_names,
                                           face->blend,
                                           0,
                                           FT_RENDER_MODE_NORMAL,
                                           T1_Parse_Glyph );
    if ( error )
      return error;

    decoder.builder.metrics_only = 1;
    decoder.builder.load_points  = 0;

    decoder.num_subrs  = type1->num_subrs;
    decoder.subrs      = type1->subrs;
    decoder.subrs_len  = type1->subrs_len;
    decoder.subrs_hash = type1->subrs_hash;

    decoder.buildchar     = face->buildchar;
    decoder.len_buildchar = face->len_buildchar;

    for ( nn = 0; nn < count; nn++ )
    {
      error = T1_Parse_Glyph( &decoder, first + nn );
      if ( !error )
        advances[nn] = FIXED_TO_INT( decoder.builder.advance.x );
      else
        advances[nn] = 0;
    }

    return FT_Err_Ok;
  }
Exemple #20
0
/*
==================
LookAtKiller
==================
*/
void LookAtKiller( gentity_t *self, gentity_t *inflictor, gentity_t *attacker ) {
	bvec3_t		dir;
	avec3_t		angles;

	if ( attacker && attacker != self ) {
		VectorSubtract (attacker->s.pos.trBase, self->s.pos.trBase, dir);
	} else if ( inflictor && inflictor != self ) {
		VectorSubtract (inflictor->s.pos.trBase, self->s.pos.trBase, dir);
	} else {
		self->client->ps.stats[STAT_DEAD_YAW] = FIXED_TO_INT(self->s.angles[YAW]);
		return;
	}

	self->client->ps.stats[STAT_DEAD_YAW] = FIXED_TO_INT(vectoyaw ( dir ));

	angles[YAW] = vectoyaw ( dir );
	angles[PITCH] = AFIXED_0; 
	angles[ROLL] = AFIXED_0;
}
void anim_staraptor_oam_callback(oam_object *self){
    FIXED period = INT_TO_FIXED(32);
    FIXED amplitude = INT_TO_FIXED(3);
    FIXED x = INT_TO_FIXED((self->private[0])++);
    x = FIXED_DIV(x, period);
    FIXED y = FIXED_COS(x);
    y = FIXED_MUL(y, amplitude);
    int y2 = FIXED_TO_INT(y);
    self->y2 = (s16)y2;
    
}
Exemple #22
0
WORD cmsLinearInterpLUT16(WORD Value1, WORD LutTable[], LPL16PARAMS p)
{
       WORD y1, y0;
       WORD y;
       int dif, a1;
       int cell0, rest;
       int val3, Value;

       // if last value...


       Value = Value1;
       if (Value == 0xffff) return LutTable[p -> Domain];

       val3 = p -> Domain * Value;
       val3 = ToFixedDomain(val3);              // To fixed 15.16

       cell0 = FIXED_TO_INT(val3);             // Cell is 16 MSB bits
       rest  = FIXED_REST_TO_INT(val3);        // Rest is 16 LSB bits

       y0 = LutTable[cell0] ;
       y1 = LutTable[cell0+1] ;

       dif = (int) y1 - y0;        // dif is in domain -ffff ... ffff

       if (dif >= 0)
       {
       a1 = ToFixedDomain(dif * rest);
       a1 += 0x8000;
       }
       else
       {
              a1 = ToFixedDomain((- dif) * rest);
              a1 -= 0x8000;
              a1 = -a1;
       }

       y = (WORD) (y0 + FIXED_TO_INT(a1));

       return y;
}
Exemple #23
0
/*
===========
Team_GetLocation

Report a location for the player. Uses placed nearby target_location entities
============
*/
gentity_t *Team_GetLocation(gentity_t *ent)
{
	gentity_t		*eloc, *best;
	int bestlen, len;
	bvec3_t			origin;

	best = NULL;
	bestlen = 3*8192*8192;

	VectorCopy( ent->r.currentOrigin, origin );

	for (eloc = level.locationHead; eloc; eloc = eloc->nextTrain) {
		len = FIXED_TO_INT( origin[0] - eloc->r.currentOrigin[0] ) * FIXED_TO_INT( origin[0] - eloc->r.currentOrigin[0] )
			+ FIXED_TO_INT( origin[1] - eloc->r.currentOrigin[1] ) * FIXED_TO_INT( origin[1] - eloc->r.currentOrigin[1] )
			+ FIXED_TO_INT( origin[2] - eloc->r.currentOrigin[2] ) * FIXED_TO_INT( origin[2] - eloc->r.currentOrigin[2] );

		if ( len > bestlen ) {
			continue;
		}

		if ( !_G_trap_InPVS( origin, eloc->r.currentOrigin ) ) {
			continue;
		}

		bestlen = len;
		best = eloc;
	}

	return best;
}
Exemple #24
0
  cid_face_compute_max_advance( CID_Face  face,
                                FT_Int*   max_advance )
  {
    FT_Error       error;
    T1_DecoderRec  decoder;
    FT_Int         glyph_index;

    PSAux_Service  psaux = (PSAux_Service)face->psaux;


    *max_advance = 0;

    /* Initialize load decoder */
    error = psaux->t1_decoder_funcs->init( &decoder,
                                           (FT_Face)face,
                                           0, /* size       */
                                           0, /* glyph slot */
                                           0, /* glyph names! XXX */
                                           0, /* blend == 0 */
                                           0, /* hinting == 0 */
                                           cid_load_glyph );
    if ( error )
      return error;

    /* TODO: initialize decoder.len_buildchar and decoder.buildchar */
    /*       if we ever support CID-keyed multiple master fonts     */

    decoder.builder.metrics_only = 1;
    decoder.builder.load_points  = 0;

    /* for each glyph, parse the glyph charstring and extract */
    /* the advance width                                      */
    for ( glyph_index = 0; glyph_index < face->root.num_glyphs;
          glyph_index++ )
    {
      /* now get load the unscaled outline */
      error = cid_load_glyph( &decoder, glyph_index );
      /* ignore the error if one occurred - skip to next glyph */
    }

    *max_advance = FIXED_TO_INT( decoder.builder.advance.x );

    psaux->t1_decoder_funcs->done( &decoder );

    return CID_Err_Ok;
  }
void dungeon2_set_encounter_cave() {
  dungeon_generator2 *dg2 = &(cmem.dg2);
  dungeon2_cave_init_state(dg2);
  pokemon_clear_opponent_party();

  u16 species = *var_access(DUNGEON_OVERWORLD_SPECIES);
  u8 mean = 0, std_deviation = 0;
  dungeon2_cave_wild_pokemon_level_distribution(&mean, &std_deviation);
  mean = (u8)(mean + std_deviation + std_deviation / 2); // High level for this pokemon

  int level = FIXED_TO_INT(FIXED_ADD(INT_TO_FIXED(mean), FIXED_MUL(INT_TO_FIXED(std_deviation),
        dungeon2_rnd_normal(dg2))));
  level = max(min(level, 100), 2);

  pid_t p = {dungeon2_rnd(dg2)};

  pokemon_spawn_by_seed_algorithm(&opponent_pokemon[0], species, (u8)level, 32, true, p, false, 0,
      dungeon2_encounter_rnd_generator, dungeon2_encounter_rnd_generator);
}
Exemple #26
0
static
void Eval1Input(WORD StageABC[], WORD StageLMN[], WORD LutTable[], LPL16PARAMS p16)
{
       Fixed32 fk;
       Fixed32 k0, k1, rk, K0, K1;
       int OutChan;

       fk = ToFixedDomain((Fixed32) StageABC[0] * p16 -> Domain);
       k0 = FIXED_TO_INT(fk);
       rk = (WORD) FIXED_REST_TO_INT(fk);

       k1 = k0 + (StageABC[0] != 0xFFFFU ? 1 : 0);

       K0 = p16 -> opta1 * k0;
       K1 = p16 -> opta1 * k1;

       for (OutChan=0; OutChan < p16->nOutputs; OutChan++) {

           StageLMN[OutChan] = (WORD) FixedLERP(rk, LutTable[K0+OutChan],
                                                    LutTable[K1+OutChan]);
       }
}
Exemple #27
0
Fixed32 cmsLinearInterpFixed(WORD Value1, WORD LutTable[], LPL16PARAMS p)
{
       Fixed32 y1, y0;
       int cell0;
       int val3, Value;

       // if last value...


       Value = Value1;
       if (Value == 0xffffU) return LutTable[p -> Domain];

       val3 = p -> Domain * Value;
       val3 = ToFixedDomain(val3);              // To fixed 15.16

       cell0 = FIXED_TO_INT(val3);             // Cell is 16 MSB bits

       y0 = LutTable[cell0] ;
       y1 = LutTable[cell0+1] ;


       return y0 + FixedMul((y1 - y0), (val3 & 0xFFFFL));
}
Exemple #28
0
/*
=================
CG_GetColorForHealth
=================
*/
void CG_GetColorForHealth( int health, int armor, vec4_t hcolor ) {
	int		count;
	int		max;

	// calculate the total points of damage that can
	// be sustained at the current health / armor level
	if ( health <= 0 ) {
		VectorClear( hcolor );	// black
		hcolor[3] = GFIXED_1;
		return;
	}
	count = armor;
	max = FIXED_TO_INT(MAKE_GFIXED(health) * ARMOR_PROTECTION / ( GFIXED_1 - ARMOR_PROTECTION ));
	if ( max < count ) {
		count = max;
	}
	health += count;

	// set the color based on health
	hcolor[0] = GFIXED_1;
	hcolor[3] = GFIXED_1;
	if ( health >= 100 ) {
		hcolor[2] = GFIXED_1;
	} else if ( health < 66 ) {
		hcolor[2] = GFIXED_0;
	} else {
		hcolor[2] = FIXED_INT32RATIO_G(health-66,33);
	}

	if ( health > 60 ) {
		hcolor[1] = GFIXED_1;
	} else if ( health < 30 ) {
		hcolor[1] = GFIXED_0;
	} else {
		hcolor[1] = FIXED_INT32RATIO_G(health-30,30);
	}
}
Exemple #29
0
/*
==================
CG_AddMoveScaleFade
==================
*/
static void CG_AddMoveScaleFade( localEntity_t *le ) {
	refEntity_t	*re;
	gfixed		c;
	bvec3_t		delta;
	bfixed		len;

	re = &le->refEntity;

	if ( le->fadeInTime > le->startTime && cg.time < le->fadeInTime ) {
		// fade / grow time
		c = GFIXED_1 - MAKE_GFIXED( le->fadeInTime - cg.time ) / MAKE_GFIXED( le->fadeInTime - le->startTime );
	}
	else {
		// fade / grow time
		c = MAKE_GFIXED( le->endTime - cg.time ) * le->lifeRate;
	}

	re->shaderRGBA[3] = FIXED_TO_INT( GFIXED(255,0) * c * le->color[3] );

	if ( !( le->leFlags & LEF_PUFF_DONT_SCALE ) ) {
		re->radius = (le->radius * ( GFIXED_1 - c )) + BFIXED(8,0);
	}

	BG_EvaluateTrajectory( &le->pos, cg.time, re->origin );

	// if the view would be "inside" the sprite, kill the sprite
	// so it doesn't add too much overdraw
	VectorSubtract( re->origin, cg.refdef.vieworg, delta );
	len = FIXED_VEC3LEN( delta );
	if ( len < le->radius ) {
		CG_FreeLocalEntity( le );
		return;
	}

	_CG_trap_R_AddRefEntityToScene( re );
}
Exemple #30
0
static void FillCloudBox( const shader_t *shader, int stage )
{
	int i;

	for ( i =0; i < 6; i++ )
	{
		int sky_mins_subd[2], sky_maxs_subd[2];
		int s, t;
		gfixed MIN_T;

		if ( 1 ) // FIXME? shader->sky.fullClouds )
		{
			MIN_T = -GFIXED(HALF_SKY_SUBDIVISIONS,0);

			// still don't want to draw the bottom, even if fullClouds
			if ( i == 5 )
				continue;
		}
		else
		{
			switch( i )
			{
			case 0:
			case 1:
			case 2:
			case 3:
				MIN_T = -GFIXED_1;
				break;
			case 5:
				// don't draw clouds beneath you
				continue;
			case 4:		// top
			default:
				MIN_T = -GFIXED(HALF_SKY_SUBDIVISIONS,0);
				break;
			}
		}

		sky_mins[0][i] = MAKE_GFIXED(FIXED_FLOOR( MAKE_LFIXED(sky_mins[0][i]) * LFIXED(HALF_SKY_SUBDIVISIONS ,0)) / LFIXED(HALF_SKY_SUBDIVISIONS,0));
		sky_mins[1][i] = MAKE_GFIXED(FIXED_FLOOR( MAKE_LFIXED(sky_mins[1][i]) * LFIXED(HALF_SKY_SUBDIVISIONS ,0)) / LFIXED(HALF_SKY_SUBDIVISIONS,0));
		sky_maxs[0][i] = MAKE_GFIXED(FIXED_CEIL( MAKE_LFIXED(sky_maxs[0][i]) * LFIXED(HALF_SKY_SUBDIVISIONS ,0)) / LFIXED(HALF_SKY_SUBDIVISIONS,0));
		sky_maxs[1][i] = MAKE_GFIXED(FIXED_CEIL( MAKE_LFIXED(sky_maxs[1][i]) * LFIXED(HALF_SKY_SUBDIVISIONS ,0)) / LFIXED(HALF_SKY_SUBDIVISIONS,0));

		if ( ( sky_mins[0][i] >= sky_maxs[0][i] ) ||
			 ( sky_mins[1][i] >= sky_maxs[1][i] ) )
		{
			continue;
		}

		sky_mins_subd[0] = FIXED_INT32SCALE(HALF_SKY_SUBDIVISIONS, sky_mins[0][i]);
		sky_mins_subd[1] = FIXED_INT32SCALE(HALF_SKY_SUBDIVISIONS, sky_mins[1][i]);
		sky_maxs_subd[0] = FIXED_INT32SCALE(HALF_SKY_SUBDIVISIONS, sky_maxs[0][i]);
		sky_maxs_subd[1] = FIXED_INT32SCALE(HALF_SKY_SUBDIVISIONS, sky_maxs[1][i]);

		if ( sky_mins_subd[0] < -HALF_SKY_SUBDIVISIONS ) 
			sky_mins_subd[0] = -HALF_SKY_SUBDIVISIONS;
		else if ( sky_mins_subd[0] > HALF_SKY_SUBDIVISIONS ) 
			sky_mins_subd[0] = HALF_SKY_SUBDIVISIONS;
		if ( MAKE_GFIXED(sky_mins_subd[1]) < MIN_T )
			sky_mins_subd[1] = FIXED_TO_INT(MIN_T);
		else if ( sky_mins_subd[1] > HALF_SKY_SUBDIVISIONS ) 
			sky_mins_subd[1] = HALF_SKY_SUBDIVISIONS;

		if ( sky_maxs_subd[0] < -HALF_SKY_SUBDIVISIONS ) 
			sky_maxs_subd[0] = -HALF_SKY_SUBDIVISIONS;
		else if ( sky_maxs_subd[0] > HALF_SKY_SUBDIVISIONS ) 
			sky_maxs_subd[0] = HALF_SKY_SUBDIVISIONS;
		if ( MAKE_GFIXED(sky_maxs_subd[1]) < MIN_T )
			sky_maxs_subd[1] = FIXED_TO_INT(MIN_T);
		else if ( sky_maxs_subd[1] > HALF_SKY_SUBDIVISIONS ) 
			sky_maxs_subd[1] = HALF_SKY_SUBDIVISIONS;

		//
		// iterate through the subdivisions
		//
		for ( t = sky_mins_subd[1]+HALF_SKY_SUBDIVISIONS; t <= sky_maxs_subd[1]+HALF_SKY_SUBDIVISIONS; t++ )
		{
			for ( s = sky_mins_subd[0]+HALF_SKY_SUBDIVISIONS; s <= sky_maxs_subd[0]+HALF_SKY_SUBDIVISIONS; s++ )
			{
				MakeSkyVec( FIXED_INT32RATIO_G( s - HALF_SKY_SUBDIVISIONS, HALF_SKY_SUBDIVISIONS), 
							FIXED_INT32RATIO_G( t - HALF_SKY_SUBDIVISIONS, HALF_SKY_SUBDIVISIONS), 
							i, 
							NULL,
							s_skyPoints[t][s] );

				s_skyTexCoords[t][s][0] = s_cloudTexCoords[i][t][s][0];
				s_skyTexCoords[t][s][1] = s_cloudTexCoords[i][t][s][1];
			}
		}

		// only add indexes for first stage
		FillCloudySkySide( sky_mins_subd, sky_maxs_subd, ( stage == 0 ) );
	}
}