Example #1
0
//컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴
//Procedure		GETALT
//Author		Paul.
//Date			Wed 26 Aug 1998
//------------------------------------------------------------------------------
ULong GETALT(inptr)
{
    ULong altVal=ULong((ULong(STARPLUSPLUS(inptr))*scaleAltitude)+baseAltitude);
    if (altVal<lowestAlt) lowestAlt=altVal;
    if (altVal>highestAlt) highestAlt=altVal;
    return altVal;
}
Example #2
0
	ATHENAError Track::GetKeyLength(const SLong & k_id, ULong & length)
	{
		Float f_lgt(0.0F);
		SLong s_id;
		Sample * sample;

		if (ULong(k_id) >= key_c) return ATHENA_ERROR_HANDLE;

		s_id = GetSampleID(s_id);

		if (_sample.IsNotValid(s_id))
		{
			length = 0;
			return ATHENA_OK;
		}

		sample = _sample[s_id];

		TrackKey * key = &key_l[k_id];

		if (key->pitch.interval)
		{
			Float min, max, cur;
			Float size;

			length = sample->length;
			size = Float(length) * (key->loop + 1);

			min = key->pitch.min * sample->format.frequency * key->pitch.interval * 0.001F;
			max = key->pitch.max * sample->format.frequency * key->pitch.interval * 0.001F;

			cur = max;

			while (size > 0.0F)
			{
				f_lgt += key->pitch.interval;
				size -= cur = cur == min ? max : min;
			}

			if (size < 0.0F) f_lgt += key->pitch.interval * (size / cur);

			f_lgt *= 0.5F;
		}
		else
		{
			ULong size, loop;

			sample->GetLength(size);

			loop = (key->loop + 1) / 2;
			f_lgt = (size * loop) * (1.0F / key->pitch.max);
			loop = (key->loop + 1) - loop;
			f_lgt += (size * loop) * (1.0F / key->pitch.min);
		}

		length = key->start + (key->loop + 1) * key->delay_max;
		length += ULong(f_lgt);

		return ATHENA_OK;
	}
Example #3
0
	ATHENAError Track::SetKeyPositionZ(const SLong & k_id, const ATHENAKeySetting & setting)
	{
		if (ULong(k_id) >= key_c) return ATHENA_ERROR_HANDLE;

		TrackKey * key = &key_l[k_id];

		key->z.min = setting.min;
		key->z.max = setting.max;
		key->z.interval = setting.interval;
		key->z.flags = setting.flags;

		if (flags & (IS_PLAYING | IS_PAUSED) && key_i == ULong(k_id))
		{
			SLong i_id(GetInstanceID(s_id));

			if (_inst.IsValid(i_id))
			{
				ATHENAVector position;

				_inst[i_id]->GetPosition(position);
				position.z = key->z.cur = (setting.min + setting.max) / 2.0F;
				_inst[i_id]->SetPosition(position);
			}
		}

		return ATHENA_OK;
	}
Example #4
0
void graph_edge::CalcLine( void )
{
  PrecRational dx,dy,adx,ady;

  dx = v[1]->v.v().m_x - v[0]->v.v().m_x;
  dy = v[1]->v.v().m_y - v[0]->v.v().m_y;
  if( !dx.IsZero() ) ady = dy/dx; else ady = PrecRational(ULong(1));
  if( !dy.IsZero() ) adx = dx/dy; else adx = PrecRational(ULong(1));
  l = line( v[0]->v.v(),adx,ady);
}
Example #5
0
	ATHENAError Track::GetKeyLoopLength(const SLong & k_id, const ULong & loop_i, ULong & length)
	{
		Float f_lgt(0.0F);

		if (ULong(k_id) >= key_c || loop_i > key_l[k_id].loop) return ATHENA_ERROR_HANDLE;

		SLong s_id(GetSampleID(s_id));

		if (_sample.IsNotValid(s_id))
		{
			length = 0;
			return ATHENA_OK;
		}

		Sample * sample = _sample[s_id];
		TrackKey * key = &key_l[k_id];

		if (key->pitch.interval)
		{
			Float min, max, cur;
			Float size;

			length = sample->length; //length in bytes
			size = Float(length) * (key->loop + 1);

			min = key->pitch.min * sample->format.frequency * key->pitch.interval * 0.001F;
			max = key->pitch.max * sample->format.frequency * key->pitch.interval * 0.001F;

			cur = max;

			while (size > 0.0F)
			{
				f_lgt += key->pitch.interval;
				size -= cur = cur == min ? max : min;
			}

			if (size < 0.0F) f_lgt += key->pitch.interval * (size / cur);
		}
		else
		{
			sample->GetLength(length);

			length = ULong((loop_i & 0x00000001 ? key->pitch.max : key->pitch.min) * length);
		}

		return ATHENA_OK;
	}
Example #6
0
	ATHENAError Track::SetKeyLoop(const SLong & k_id, const ULong & loop)
	{
		if (ULong(k_id) >= key_c) return ATHENA_ERROR_HANDLE;

		key_l[k_id].loop = loop;

		return ATHENA_OK;
	}
Example #7
0
	///////////////////////////////////////////////////////////////////////////////
	//                                                                           //
	// Key setup                                                                 //
	//                                                                           //
	///////////////////////////////////////////////////////////////////////////////
	ATHENAError Track::SetKeyStart(const SLong & k_id, const ULong & start)
	{
		if (ULong(k_id) >= key_c) return ATHENA_ERROR_HANDLE;

		key_l[k_id].start = start;

		return ATHENA_OK;
	}
Example #8
0
	ATHENAError Track::SetKeyDelay(const SLong & k_id, const ULong & min, const ULong & max)
	{
		if (ULong(k_id) >= key_c) return ATHENA_ERROR_HANDLE;

		key_l[k_id].delay_min = min;
		key_l[k_id].delay_max = max;

		return ATHENA_OK;
	}
Example #9
0
	ATHENAError Track::GetKeyDelay(const SLong & k_id, ULong & min, ULong & max)
	{
		if (ULong(k_id) >= key_c) return ATHENA_ERROR_HANDLE;

		TrackKey * key = &key_l[k_id];

		min = key->delay_min;
		max = key->delay_max;

		return ATHENA_OK;
	}
Example #10
0
	ATHENAError Track::SetKeyPitch(const SLong & k_id, const ATHENAKeySetting & setting)
	{
		if (ULong(k_id) >= key_c) return ATHENA_ERROR_HANDLE;

		TrackKey * key = &key_l[k_id];

		key->pitch.min = setting.min;
		key->pitch.max = setting.max;
		key->pitch.interval = setting.interval;
		key->pitch.flags = setting.flags;

		if (flags & (IS_PLAYING | IS_PAUSED) && key_i == ULong(k_id))
		{
			SLong i_id(GetInstanceID(s_id));
			key->pitch.cur = (setting.min + setting.max) / 2.0F;

			if (_inst.IsValid(i_id)) _inst[i_id]->SetPitch(key->pitch.cur);
		}

		return ATHENA_OK;
	}
Example #11
0
	ATHENAError Track::GetKeyPositionZ(const SLong & k_id, ATHENAKeySetting & setting)
	{
		if (ULong(k_id) >= key_c) return ATHENA_ERROR_HANDLE;

		TrackKey * key = &key_l[k_id];

		setting.min = key->z.min;
		setting.max = key->z.max;
		setting.interval = key->z.interval;
		setting.flags = key->z.flags;

		return ATHENA_OK;
	}
Example #12
0
int		RowanTasks::StartTask()
{
	int	count=lasttasknum;
	while (count<MAX_TASKS)
		breakif (taskstacks[++count]==0);
	if (count==MAX_TASKS)
		for (count=0;count<lasttasknum;)
			breakif (taskstacks[++count]==0);
	if (count==lasttasknum)
		INT3;	//oh dear... run out of tasks?
	taskstacks[count]=ULong(&count);	//get address of local variable...
	return count;
}
Example #13
0
int		RowanTasks::GetCurrTask()
{
	ULong testval=ULong(&testval);
	ULong	lowestvalueabove=0xffffffff;
	int	entforlowest=-1;
	int	count;
	for (count=0;count<MAX_TASKS;count++)
		if (taskstacks[count]>testval && taskstacks[count]<lowestvalueabove)
		{
			lowestvalueabove=taskstacks[count];
			entforlowest=count;
		}
	return count;
}
Example #14
0
UBool PathFinder::WanderAround(const ULong & flags, const ULong & f, const Float & rad, SLong * rstep, UWord ** rlist)
{

    Void * ptr;
    ULong step_c, last, next;
    SLong temp_c(0), path_c(0);
    UWord * temp_d = NULL, *path_d = NULL;

    Clean();
    //Check if params are valid
    if (!rlist || !rstep) return UFALSE;

    if (!map_d[f].nblinked)
    {
        *rstep = 0;
        return UFALSE;
    }

    if (rad <= MIN_RADIUS)
    {
        *rlist = (UWord *)malloc(sizeof(UWord));
        ** rlist = (UWord)f;
        *rstep = 1;
        return UTRUE;
    }

    last = f;

    step_c = Random() % 5 + 5;

    for (ULong i(0); i < step_c; i++)
    {
        ULong nb = ULong(rad * rnd() * DIV50);
        long _current = f;

        while (nb)
        {
            if ((map_d[_current].nblinked)
               )
            {

                long notfinished = 4;

                while (notfinished--)
                {
                    ULong r = ULong(rnd() * (Float)map_d[_current].nblinked);

                    if (r >= (ULong)map_d[_current].nblinked)
                        r = ULong(map_d[_current].nblinked - 1);

                    if ((!(map_d[map_d[_current].linked[r]].flags & ANCHOR_FLAG_BLOCKED))
                            &&	(map_d[map_d[_current].linked[r]].nblinked)
                            &&	(map_d[map_d[_current].linked[r]].height <= height)
                            &&	(map_d[map_d[_current].linked[r]].radius >= radius))
                    {
                        _current = map_d[_current].linked[r];
                        notfinished = 0;
                    }
                }
            }

            nb--;
        }

        if (_current < 0) continue;

        next = nb = _current;

        if (Move(flags, last, next, &temp_c, &temp_d) && temp_c)
        {
            if (!(ptr = realloc(path_d, sizeof(UWord) * (path_c + temp_c))))
            {
                free(temp_d);
                free(path_d);
                Clean();
                *rstep = 0;
                return UFALSE;
            }

            //Add temp path to wander around path
            path_d = (UWord *)ptr;
            memcpy(&path_d[path_c], temp_d, sizeof(UWord) * temp_c);
            path_c += temp_c;

            //Free temp path
            free(temp_d), temp_d = NULL, temp_c = 0;
        }
        else i--;

        last = next;
    }

    //Close wander around path (return to start position)
    if (!path_c || !Move(flags, last, f, &temp_c, &temp_d))
    {
        *rstep = 0;
        return UFALSE;
    }

    if (!(ptr = realloc(path_d, sizeof(UWord) * (path_c + temp_c))))
    {
        free(temp_d);
        free(path_d);
        Clean();
        *rstep = 0;
        return UFALSE;
    }

    //Add temp path to wander around path
    path_d = (UWord *)ptr;
    memcpy(&path_d[path_c], temp_d, sizeof(UWord) * temp_c);
    path_c += temp_c;

    free(temp_d);

    *rlist = path_d;
    *rstep = path_c;
    Clean();
    return UTRUE;
}