예제 #1
0
파일: matrix.cpp 프로젝트: 2asoft/xray-16
void dLDLTRemove (dReal **A, const int *p, dReal *L, dReal *d,
		  int n1, int n2, int r, int nskip)
{
  int i;
  dAASSERT(A && p && L && d && n1 > 0 && n2 > 0 && r >= 0 && r < n2 &&
	   n1 >= n2 && nskip >= n1);
  #ifndef dNODEBUG
  for (i=0; i<n2; i++) dIASSERT(p[i] >= 0 && p[i] < n1);
  #endif

  if (r==n2-1) {
    return;		// deleting last row/col is easy
  }
  else if (r==0) {
    dReal *a = (dReal*) ALLOCA (n2 * sizeof(dReal));
    for (i=0; i<n2; i++) a[i] = -GETA(p[i],p[0]);
    a[0] += REAL(1.0);
    dLDLTAddTL (L,d,a,n2,nskip);
  }
  else {
    dReal *t = (dReal*) ALLOCA (r * sizeof(dReal));
    dReal *a = (dReal*) ALLOCA ((n2-r) * sizeof(dReal));
    for (i=0; i<r; i++) t[i] = L[r*nskip+i] / d[i];
    for (i=0; i<(n2-r); i++)
      a[i] = dDot(L+(r+i)*nskip,t,r) - GETA(p[r+i],p[r]);
    a[0] += REAL(1.0);
    dLDLTAddTL (L + r*nskip+r, d+r, a, n2-r, nskip);
  }

  // snip out row/column r from L and d
  dRemoveRowCol (L,n2,nskip,r);
  if (r < (n2-1)) memmove (d+r,d+r+1,(n2-r-1)*sizeof(dReal));
}
예제 #2
0
파일: matrix.cpp 프로젝트: Belxjander/Asuna
void _dLDLTRemove (dReal **A, const int *p, dReal *L, dReal *d,
    int n1, int n2, int r, int nskip, void *tmpbuf/*n2 + 2*nskip*/)
{
  dAASSERT(A && p && L && d && n1 > 0 && n2 > 0 && r >= 0 && r < n2 &&
	   n1 >= n2 && nskip >= n1);
  #ifndef dNODEBUG
  for (int i=0; i<n2; ++i) dIASSERT(p[i] >= 0 && p[i] < n1);
  #endif

  if (r==n2-1) {
    return;		// deleting last row/col is easy
  }
  else {
    size_t LDLTAddTL_size = _dEstimateLDLTAddTLTmpbufSize(nskip);
    dIASSERT(LDLTAddTL_size % sizeof(dReal) == 0);
    dReal *tmp = tmpbuf ? (dReal *)tmpbuf : (dReal*) ALLOCA (LDLTAddTL_size + n2 * sizeof(dReal));
    if (r==0) {
      dReal *a = (dReal *)((char *)tmp + LDLTAddTL_size);
      const int p_0 = p[0];
      for (int i=0; i<n2; ++i) {
        a[i] = -GETA(p[i],p_0);
      }
      a[0] += REAL(1.0);
      dLDLTAddTL (L,d,a,n2,nskip,tmp);
    }
    else {
      dReal *t = (dReal *)((char *)tmp + LDLTAddTL_size);
      {
        dReal *Lcurr = L + r*nskip;
        for (int i=0; i<r; ++Lcurr, ++i) {
          dIASSERT(d[i] != dReal(0.0));
          t[i] = *Lcurr / d[i];
        }
      }
      dReal *a = t + r;
      {
        dReal *Lcurr = L + r*nskip;
        const int *pp_r = p + r, p_r = *pp_r;
        const int n2_minus_r = n2-r;
        for (int i=0; i<n2_minus_r; Lcurr+=nskip,++i) {
          a[i] = dDot(Lcurr,t,r) - GETA(pp_r[i],p_r);
        }
      }
      a[0] += REAL(1.0);
      dLDLTAddTL (L + r*nskip+r, d+r, a, n2-r, nskip, tmp);
    }
  }

  // snip out row/column r from L and d
  dRemoveRowCol (L,n2,nskip,r);
  if (r < (n2-1)) memmove (d+r,d+r+1,(n2-r-1)*sizeof(dReal));
}
예제 #3
0
파일: tcasfunc.c 프로젝트: Lichtavat/TCAX
static PyObject *_tcaxlib_convert_chunks_vector_to_tcas_list(VectorPtr chunksVector, int layer) {
    PyObject *tcasList;
    PyObject *pixDip;
    TCAS_Chunk chunk;
    int i, j, count, num;
    unsigned long pos, rgba;
    tcasList = PyList_New(0);
    count = vector_get_count(chunksVector);
    for (i = 0; i < count; i++) {
        vector_retrieve(chunksVector, i, &chunk);
        num = GETCOUNT(chunk.cltp);
        for (j = 0; j < num; j++) {
            pixDip = PyTuple_New(7);
            PyTuple_SET_ITEM(pixDip, 0, PyLong_FromLong(chunk.startTime));
            PyTuple_SET_ITEM(pixDip, 1, PyLong_FromLong(chunk.endTime));
            PyTuple_SET_ITEM(pixDip, 2, PyLong_FromUnsignedLong(layer));
            pos = chunk.pos_and_color[j << 1];
            rgba = chunk.pos_and_color[(j << 1) + 1];
            PyTuple_SET_ITEM(pixDip, 3, PyLong_FromLong(GETPOSX(pos)));
            PyTuple_SET_ITEM(pixDip, 4, PyLong_FromLong(GETPOSY(pos)));
            PyTuple_SET_ITEM(pixDip, 5, PyLong_FromLong(0x00FFFFFF & rgba));
            PyTuple_SET_ITEM(pixDip, 6, PyLong_FromLong(GETA(rgba)));
            PyList_Append(tcasList, pixDip);
            Py_CLEAR(pixDip);
        }
        free(chunk.pos_and_color);
    }
    return tcasList;
}
예제 #4
0
void ncGraphics::clear(unsigned int color) {
    glClearColor(
        GETR(color) / 255.f,
        GETG(color) / 255.f,
        GETB(color) / 255.f,
        GETA(color) / 255.f
    );
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
}
예제 #5
0
void HGE_CALL HGE_Impl::Gfx_Clear(hgeU32 color)
{
	float c[4] = {
		(float)GETA(color) / 256,
		(float)GETR(color) / 256,
		(float)GETG(color) / 256,
		(float)GETB(color) / 256 };
	m_pD3DDeviceContext->ClearRenderTargetView(pRTView, c);
	//m_pD3DDeviceContext->ClearDepthStencilView(pDSView, D3D11_CLEAR_DEPTH, 1.0f, 0);
}
예제 #6
0
    Color HGEImage::getPixel(int x, int y)
    {
        DWORD *pLockPtr = mHGE->Texture_Lock(mTexture);

        if (pLockPtr == NULL)
        {
            throw GCN_EXCEPTION("Locking of the texture failed. HGE only support locking of 32bit textures.");
        }

        DWORD color = pLockPtr[x + y * mHGE->Texture_GetWidth(mTexture, true)];

        mHGE->Texture_Unlock(mTexture);

        return Color(GETR(color),
                     GETG(color), 
                     GETB(color), 
                     GETA(color ));
    }
예제 #7
0
void CHUDActivateObject::UpdateLayout()
{
	if( !m_hLayout )
	{
		m_hLayout = g_pLayoutDB->GetHUDRecord("HUDActivateObject");
	}

	CHUDItem::UpdateLayout();

	// Set the alpha value to fade into...
	m_dwEffectAlpha = GETA(m_cIconColor);

	// Initially set the button and object positions to the base pos...
	m_vObjectBasePos = m_vButtonBasePos = m_vIconOffset;
	m_vObjectSize = m_vButtonSize = m_vIconSize;

	InitAdditionalTextureData( m_hLayout, 0, m_hIconTexture, m_vIconOffset, m_vIconSize, m_IconPoly );
	InitAdditionalTextureData( m_hLayout, 1, m_aButton, m_vButtonBasePos, m_vButtonSize, m_ButtonRect );
	InitAdditionalTextureData( m_hLayout, 2, m_aFallbacks[ AOT_GENERAL ], m_vObjectBasePos, m_vObjectSize, m_ObjectRect );
	InitAdditionalTextureData( m_hLayout, 3, m_aFallbacks[ AOT_PICKUP  ], m_vObjectBasePos, m_vObjectSize, m_ObjectRect );
}
예제 #8
0
static CImage &CreateImgFromBuffer( const CFileListManager::Buffer &buf, CImage &img, bool bCheck = false )
{
    if( !img.ReadBitmapFromMemory( (const BYTE*) buf.buf, buf.size ) )
    {
#ifdef RECORD_NAME
        PutoutLog( LOG_FILE, LT_ERROR, "Create BMP from memory failed : %s", buf.name.c_str() );
#else
        PutoutLog( LOG_FILE, LT_ERROR, "Create BMP from memory failed." );
#endif
        return img;
    }
    // check the image format
    if( bCheck && GETA( img.GetPixel( 0, 0 ) ) == 0 )
    {
#ifdef RECORD_NAME
        PutoutLog( LOG_FILE, LT_ERROR, "Alpha value is invalid : %s", buf.name.c_str() );
#else
        PutoutLog( LOG_FILE, LT_ERROR, "Alpha value is invalid." );
#endif
    }
    return img;
}
예제 #9
0
파일: modify.c 프로젝트: fcelda/openldap
int
slap_sort_vals(
	Modifications *ml,
	const char **text,
	int *dup,
	void *ctx )
{
	AttributeDescription *ad;
	MatchingRule *mr;
	int istack[sizeof(int)*16];
	int i, j, k, l, ir, jstack, match, *ix, itmp, nvals, rc = LDAP_SUCCESS;
	int is_norm;
	struct berval a, *cv;

#define SMALL	8
#define	SWAP(a,b,tmp)	tmp=(a);(a)=(b);(b)=tmp
#define	COMP(a,b)	match=0; rc = ordered_value_match( &match, \
						ad, mr, SLAP_MR_EQUALITY \
								| SLAP_MR_VALUE_OF_ASSERTION_SYNTAX \
								| SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH \
								| SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH, \
								&(a), &(b), text );

#define	IX(x)	ix[x]
#define	EXCH(x,y)	SWAP(ix[x],ix[y],itmp)
#define	SETA(x)	itmp = ix[x]; a = cv[itmp]
#define	GETA(x)	ix[x] = itmp;
#define	SET(x,y)	ix[x] = ix[y]

	ad = ml->sml_desc;
	nvals = ml->sml_numvals;
	if ( nvals <= 1 )
		goto ret;

	/* For Modifications, sml_nvalues is NULL if normalization wasn't needed.
	 * For Attributes, sml_nvalues == sml_values when normalization isn't needed.
	 */
	if ( ml->sml_nvalues && ml->sml_nvalues != ml->sml_values ) {
		cv = ml->sml_nvalues;
		is_norm = 1;
	} else {
		cv = ml->sml_values;
		is_norm = 0;
	}

	if ( ad == slap_schema.si_ad_objectClass )
		mr = NULL;	/* shortcut matching */
	else
		mr = ad->ad_type->sat_equality;

	/* record indices to preserve input ordering */
	ix = slap_sl_malloc( nvals * sizeof(int), ctx );
	for (i=0; i<nvals; i++) ix[i] = i;

	ir = nvals-1;
	l = 0;
	jstack = 0;

	for(;;) {
		if (ir - l < SMALL) {	/* Insertion sort */
			match=1;
			for (j=l+1;j<=ir;j++) {
				SETA(j);
				for (i=j-1;i>=0;i--) {
					COMP(cv[IX(i)], a);
					if ( match <= 0 )
						break;
					SET(i+1,i);
				}
				GETA(i+1);
				if ( match == 0 ) goto done;
			}
			if ( jstack == 0 ) break;
			if ( match == 0 ) break;
			ir = istack[jstack--];
			l = istack[jstack--];
		} else {
			k = (l + ir) >> 1;	/* Choose median of left, center, right */
			EXCH(k, l+1);
			COMP( cv[IX(l)], cv[IX(ir)] );
			if ( match > 0 ) {
				EXCH(l, ir);
			} else if ( match == 0 ) {
				i = ir;
				break;
			}
			COMP( cv[IX(l+1)], cv[IX(ir)] );
			if ( match > 0 ) {
				EXCH(l+1, ir);
			} else if ( match == 0 ) {
				i = ir;
				break;
			}
			COMP( cv[IX(l)], cv[IX(l+1)] );
			if ( match > 0 ) {
				EXCH(l, l+1);
			} else if ( match == 0 ) {
				i = l;
				break;
			}
			i = l+1;
			j = ir;
			a = cv[IX(i)];
			for(;;) {
				do {
					i++;
					COMP( cv[IX(i)], a );
				} while( match < 0 );
				while( match > 0 ) {
					j--;
					COMP( cv[IX(j)], a );
				}
				if (j < i) {
					match = 1;
					break;
				}
				if ( match == 0 ) {
					i = l+1;
					break;
				}
				EXCH(i,j);
			}
			if ( match == 0 )
				break;
			EXCH(l+1,j);
			jstack += 2;
			if (ir-i+1 >= j) {
				istack[jstack] = ir;
				istack[jstack-1] = i;
				ir = j;
			} else {
				istack[jstack] = j;
				istack[jstack-1] = l;
				l = i;
			}
		}
	}
	done:
	if ( match == 0 && i >= 0 )
		*dup = ix[i];

	/* For sorted attributes, put the values in index order */
	if ( rc == LDAP_SUCCESS && match &&
		( ad->ad_type->sat_flags & SLAP_AT_SORTED_VAL )) {
		BerVarray tmpv = slap_sl_malloc( sizeof( struct berval ) * nvals, ctx );
		for ( i = 0; i<nvals; i++ )
			tmpv[i] = cv[ix[i]];
		for ( i = 0; i<nvals; i++ )
			cv[i] = tmpv[i];
		/* Check if the non-normalized array needs to move too */
		if ( is_norm ) {
			cv = ml->sml_values;
			for ( i = 0; i<nvals; i++ )
				tmpv[i] = cv[ix[i]];
			for ( i = 0; i<nvals; i++ )
				cv[i] = tmpv[i];
		}
		slap_sl_free( tmpv, ctx );
	}

	slap_sl_free( ix, ctx );

	if ( rc == LDAP_SUCCESS && match == 0 ) {
		/* value exists already */
		assert( i >= 0 );
		assert( i < nvals );
		rc = LDAP_TYPE_OR_VALUE_EXISTS;
	}
 ret:
	return rc;
}
예제 #10
0
void CALL HGE_Impl::Gfx_Clear(DWORD color)
{
    //TODO: set given color
    glClearColor((float)GETR(color)/0xff, (float)GETG(color)/0xff, (float)GETB(color)/0xff, (float)GETA(color)/0xff);

    glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ACCUM_BUFFER_BIT);
}
예제 #11
0
void CALL HGE_Impl::Gfx_RenderQuad(const hgeQuad *quad)
{

    glEnable(GL_TEXTURE_2D); // Enable Texture Mapping
    glBindTexture(GL_TEXTURE_2D, quad->tex);

    _SetBlendMode(quad->blend);


    //TODO: insert code here
    GLfloat verteces[12] = {
        quad->v[3].x, quad->v[3].y, quad->v[3].z,
        quad->v[2].x, quad->v[2].y, quad->v[2].z,
        quad->v[1].x, quad->v[1].y, quad->v[1].z,
        quad->v[0].x, quad->v[0].y, quad->v[0].z,
    };

    GLfloat texCoords[8] = {
        quad->v[3].tx, quad->v[3].ty,
        quad->v[2].tx, quad->v[2].ty,
        quad->v[1].tx, quad->v[1].ty,
        quad->v[0].tx, quad->v[0].ty,
    };
    GLubyte colors[16] = {
        (GLubyte)GETR(quad->v[3].col), (GLubyte)GETG(quad->v[3].col), (GLubyte)GETB(quad->v[3].col), (GLubyte)GETA(quad->v[3].col),
        (GLubyte)GETR(quad->v[2].col), (GLubyte)GETG(quad->v[2].col), (GLubyte)GETB(quad->v[2].col), (GLubyte)GETA(quad->v[2].col),
        (GLubyte)GETR(quad->v[1].col), (GLubyte)GETG(quad->v[1].col), (GLubyte)GETB(quad->v[1].col), (GLubyte)GETA(quad->v[1].col),
        (GLubyte)GETR(quad->v[0].col), (GLubyte)GETG(quad->v[0].col), (GLubyte)GETB(quad->v[0].col), (GLubyte)GETA(quad->v[0].col),

    };


    glVertexPointer(3, GL_FLOAT, 0, verteces);
    glEnableClientState(GL_VERTEX_ARRAY);

    glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);


    glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors);
    glEnableClientState(GL_COLOR_ARRAY);

    glDrawArrays(GL_QUADS, 0, 4);

    glDisable(GL_TEXTURE_2D); // Enable Texture Mapping
    glDisable(GL_BLEND); // Enable Texture Mapping
    glBindTexture(GL_TEXTURE_2D, 0);


}
예제 #12
0
static void ALU( mb86233_state *cpustate, UINT32 alu)
{
	float	ftmp;

	switch(alu)
	{
		case 0x00:	/* NOP */
		break;

		case 0x01:	/* D = D & A */
			GETD().u &= GETA().u;
			FLAGSI(cpustate, GETD().u);
		break;

		case 0x02:	/* D = D | A */
			GETD().u |= GETA().u;
			FLAGSI(cpustate, GETD().u);
		break;

		case 0x03:	/* D = D ^ A */
			GETD().u ^= GETA().u;
			FLAGSI(cpustate, GETD().u);
		break;

		case 0x05:	/* CMP D,A */
			ftmp = GETD().f - GETA().f;
			FLAGSF(cpustate, ftmp);
			cpustate->icount--;
		break;

		case 0x06:	/* D = D + A */
			GETD().f += GETA().f;
			FLAGSF(cpustate, GETD().f);
			cpustate->icount--;
		break;

		case 0x07:	/* D = D - A */
			GETD().f -= GETA().f;
			FLAGSF(cpustate, GETD().f);
			cpustate->icount--;
		break;

		case 0x08:	/* P = A * B */
			GETP().f = GETA().f * GETB().f;
			cpustate->icount--;
		break;

		case 0x09:	/* D = D + P; P = A * B */
			GETD().f += GETP().f;
			GETP().f = GETA().f * GETB().f;
			FLAGSF(cpustate, GETD().f);
			cpustate->icount--;
		break;

		case 0x0A:	/* D = D - P; P = A * B */
			GETD().f -= GETP().f;
			GETP().f = GETA().f * GETB().f;
			FLAGSF(cpustate, GETD().f);
			cpustate->icount--;
		break;

		case 0x0B:	/* D = fabs(D) */
			GETD().f = fabs( GETD().f );
			FLAGSF(cpustate, GETD().f);
			cpustate->icount--;
		break;

		case 0x0C:	/* D = D + P */
			GETD().f += GETP().f;
			FLAGSF(cpustate, GETD().f);
			cpustate->icount--;
		break;

		case 0x0D:	/* D = P; P = A * B */
			GETD().f = GETP().f;
			GETP().f = GETA().f * GETB().f;
			FLAGSF(cpustate, GETD().f);
			cpustate->icount--;
		break;

		case 0x0E:	/* D = float(D) */
			GETD().f = (float)GETD().i;
			FLAGSF(cpustate, GETD().f);
			cpustate->icount--;
		break;

		case 0x0F:	/* D = int(D) */
			GETD().i = (INT32)GETD().f;
			FLAGSI(cpustate, GETD().u);
		break;

		case 0x10:	/* D = D / A */
			if ( GETA().u != 0 )
				GETD().f = GETD().f / GETA().f;
			FLAGSF(cpustate, GETD().f);
			cpustate->icount--;
		break;

		case 0x11:	/* D = -D */
			GETD().f = -GETD().f;
			FLAGSF(cpustate, GETD().f);
			cpustate->icount--;
		break;

		case 0x13:	/* D = A + B */
			GETD().f = GETA().f + GETB().f;
			FLAGSF(cpustate, GETD().f);
			cpustate->icount--;
		break;

		case 0x14:	/* D = B - A */
			GETD().f = GETB().f - GETA().f;
			FLAGSF(cpustate, GETD().f);
			cpustate->icount--;
		break;

		case 0x16:	/* LSR D, SHIFT */
			GETD().u >>= GETSHIFT();
			FLAGSI(cpustate, GETD().u);
		break;

		case 0x17:	/* LSL D, SHIFT */
			GETD().u <<= GETSHIFT();
			FLAGSI(cpustate, GETD().u);
		break;

		case 0x18:	/* ASR D, SHIFT */
//          GETD().u = (GETD().u & 0x80000000) | (GETD().u >> GETSHIFT());
			GETD().i >>= GETSHIFT();
			FLAGSI(cpustate, GETD().u);
		break;

		case 0x1A:	/* D = D + A */
			GETD().i += GETA().i;
			FLAGSI(cpustate, GETD().u);
		break;

		case 0x1B:	/* D = D - A */
			GETD().i -= GETA().i;
			FLAGSI(cpustate, GETD().u);
		break;

		default:
			logerror( "TGP: Unknown ALU op %x at PC:%04x\n", alu, GETPC() );
		break;
	}
}
예제 #13
0
파일: graphics.cpp 프로젝트: funcman/bsgl
void CALL BSGL_Impl::Gfx_Clear(DWORD color) {
    glClearColor((GLfloat)GETR(color), (GLfloat)GETG(color),
                 (GLfloat)GETB(color), (GLfloat)GETA(color));
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
}
예제 #14
0
파일: mb86233.cpp 프로젝트: Ashura-X/mame
void mb86233_cpu_device::ALU( UINT32 alu)
{
	float   ftmp;

	switch(alu)
	{
		case 0x00:  /* NOP */
		break;

		case 0x01:  /* D = D & A */
			GETD().u &= GETA().u;
			FLAGSI( GETD().u);
		break;

		case 0x02:  /* D = D | A */
			GETD().u |= GETA().u;
			FLAGSI( GETD().u);
		break;

		case 0x03:  /* D = D ^ A */
			GETD().u ^= GETA().u;
			FLAGSI( GETD().u);
		break;

		case 0x04:  /* D = D ~ A */
			GETD().u = ~GETA().u;
			FLAGSI( GETD().u);
		break;

		case 0x05:  /* CMP D,A */
			ftmp = GETD().f - GETA().f;
			FLAGSF( ftmp);
			m_icount--;
		break;

		case 0x06:  /* D = D + A */
			GETD().f += GETA().f;
			FLAGSF( GETD().f);
			m_icount--;
		break;

		case 0x07:  /* D = D - A */
			GETD().f -= GETA().f;
			FLAGSF( GETD().f);
			m_icount--;
		break;

		case 0x08:  /* P = A * B */
			GETP().f = GETA().f * GETB().f;
			m_icount--;
		break;

		case 0x09:  /* D = D + P; P = A * B */
			GETD().f += GETP().f;
			GETP().f = GETA().f * GETB().f;
			FLAGSF( GETD().f);
			m_icount--;
		break;

		case 0x0A:  /* D = D - P; P = A * B */
			GETD().f -= GETP().f;
			GETP().f = GETA().f * GETB().f;
			FLAGSF( GETD().f);
			m_icount--;
		break;

		case 0x0B:  /* D = fabs(D) */
			GETD().f = fabs( GETD().f );
			FLAGSF( GETD().f);
			m_icount--;
		break;

		case 0x0C:  /* D = D + P */
			GETD().f += GETP().f;
			FLAGSF( GETD().f);
			m_icount--;
		break;

		case 0x0D:  /* D = P; P = A * B */
			GETD().f = GETP().f;
			GETP().f = GETA().f * GETB().f;
			FLAGSF( GETD().f);
			m_icount--;
		break;

		case 0x0E:  /* D = float(D) */
			GETD().f = (float)GETD().i;
			FLAGSF( GETD().f);
			m_icount--;
		break;

		case 0x0F:  /* D = int(D) */
			switch((m_fpucontrol>>1)&3)
			{
				//case 0: GETD().i = floor(GETD().f+0.5f); break;
				//case 1: GETD().i = ceil(GETD().f); break;
				case 2: GETD().i = floor(GETD().f); break; // Manx TT
				case 3: GETD().i = (INT32)GETD().f; break;
				default: popmessage("TGP uses D = int(D) with FPU control = %02x, contact MAMEdev",m_fpucontrol>>1); break;
			}

			FLAGSI( GETD().i);
		break;

		case 0x10:  /* D = D / A */
			if ( GETA().u != 0 )
				GETD().f = GETD().f / GETA().f;
			FLAGSF( GETD().f);
			m_icount--;
		break;

		case 0x11:  /* D = -D */
			GETD().f = -GETD().f;
			FLAGSF( GETD().f);
			m_icount--;
		break;

		case 0x13:  /* D = A + B */
			GETD().f = GETA().f + GETB().f;
			FLAGSF( GETD().f);
			m_icount--;
		break;

		case 0x14:  /* D = B - A */
			GETD().f = GETB().f - GETA().f;
			FLAGSF( GETD().f);
			m_icount--;
		break;

		case 0x16:  /* LSR D, SHIFT */
			GETD().u >>= GETSHIFT();
			FLAGSI( GETD().u);
		break;

		case 0x17:  /* LSL D, SHIFT */
			GETD().u <<= GETSHIFT();
			FLAGSI( GETD().u);
		break;

		case 0x18:  /* ASR D, SHIFT */
//          GETD().u = (GETD().u & 0x80000000) | (GETD().u >> GETSHIFT());
			GETD().i >>= GETSHIFT();
			FLAGSI( GETD().u);
		break;

		case 0x1A:  /* D = D + A */
			GETD().i += GETA().i;
			FLAGSI( GETD().u);
		break;

		case 0x1B:  /* D = D - A */
			GETD().i -= GETA().i;
			FLAGSI( GETD().u);
		break;

		default:
			fatalerror( "TGP: Unknown ALU op %x at PC:%04x\n", alu, GETPC() );
	}
}
예제 #15
0
void CHUDActivateObject::SetObject( LTObjRef iObjRef, uint32 nNewType )
{
	// Check to see if this is a valid activate object...
	if( nNewType == AOT_INVALID )
	{
		if( m_iObjRef.GetData() )
		{
			m_iObjRef = NULL;
			m_nUserFlags = 0;
			m_pActivateObject = NULL;

			// Reset the fade time...
			if( m_fEffectTime <= 0 )
				m_fEffectTime = m_fFadeTime;
			else
				m_fEffectTime = m_fFadeTime - m_fEffectTime;
		}

		return;
	}


	m_Text.SetText(CreateHelpString("Training_Action"));


	if( m_iObjRef != iObjRef )
	{
		// A new object is being targeted...
		m_iObjRef = iObjRef;
		m_fEffectTime = m_fFadeTime;

		// Cache the activate object, if it has one...
		m_pActivateObject = CActivateObjectHandler::FindActivateObject( iObjRef );
	}


	// Assign the new activate object...
	m_iObjRef = iObjRef;
	g_pLTClient->Common()->GetObjectFlags( m_iObjRef.GetData(), OFT_User, m_nUserFlags );

	m_nType = nNewType;
	
	// fetch any specific textures
	switch( nNewType )
	{
		case AOT_GENERAL:
		{
			bool bUseFallbackIcon = true;
			if( m_pActivateObject )
			{
				HRECORD hRecord;
				HATTRIBUTE hStates;
				const char* pszHUDTexture = NULL;
				uint32 dwColor = m_cIconColor;

				// Fetch the proper string from the database depending on the state...
				hRecord = DATABASE_CATEGORY( Activate ).GetRecordByIndex( m_pActivateObject->m_nId );
				if( hRecord )
				{
					hStates = DATABASE_CATEGORY( Activate ).GETRECORDSTRUCT( hRecord, States );

					if( hStates )
					{
						pszHUDTexture = DATABASE_CATEGORY( Activate ).GETSTRUCTATTRIB( States, hStates, m_pActivateObject->m_eState, HudIcon );
					}

					// If a separate disabled icon is listed use that instead of the state icon...
					if( m_pActivateObject->m_bDisabled )
					{
						const char *pszDisabledIcon = DATABASE_CATEGORY( Activate ).GETRECORDATTRIB( hRecord, DisabledIcon );
						if( !LTStrEmpty( pszDisabledIcon ))
							pszHUDTexture = pszDisabledIcon;

						// Use the disabled color of the icon...
						dwColor = DATABASE_CATEGORY( Activate ).GETRECORDATTRIB( hRecord, DisabledColor );	
					}
				}

				// Set the color, alpha will be changed by the fade effect...
				DrawPrimSetRGBA( m_ObjectRect, dwColor );

				// Set the alpha value to fade into...
				m_dwEffectAlpha = GETA(dwColor);

				if( !LTStrEmpty( pszHUDTexture ) )
				{
					bUseFallbackIcon = false;

					// Don't change to the same icon...
					if( !LTStrIEquals( m_sObjectsIcon.c_str( ), pszHUDTexture ))
					{
						// Reset the effect time and load the new icon...
						m_sObjectsIcon = pszHUDTexture;
						m_aObjects[ AOT_GENERAL ].Load( pszHUDTexture );
					}
				}

			}
			else
			{
				// Use the default icon color...
				DrawPrimSetRGBA( m_ObjectRect, m_cIconColor );
				m_dwEffectAlpha = GETA(m_cIconColor);
			}

			if( bUseFallbackIcon )
			{
				// If no specific activate type was specified, use the fallback...
				m_aObjects[AOT_GENERAL] = m_aFallbacks[AOT_GENERAL];
				m_sObjectsIcon.clear( );
			}
		}
		break;

		case AOT_PICKUP:
		{
			// generic fallback texture
			m_aObjects[AOT_PICKUP] = m_aFallbacks[AOT_PICKUP];

			// get the client side pickup item
			CPickupItemFX* pPickupItemFX = static_cast< CPickupItemFX* >( g_pGameClientShell->GetSFXMgr()->FindSpecialFX( SFX_PICKUPITEM_ID, iObjRef ));
			if (pPickupItemFX && pPickupItemFX->GetPickupItemType( ) == kPickupItemType_Weapon )
			{
				// get pickup object record
				HRECORD hPickupType = pPickupItemFX->GetTypeRecord();
				if( hPickupType )
				{
					// get weapon data of pickup object
					HWEAPONDATA hWpnData = g_pWeaponDB->GetWeaponData( hPickupType, !USE_AI_DATA );
					if( hWpnData )
					{
						// get hud texture from weapon data
						const char* szTexture = g_pWeaponDB->GetString(hWpnData,WDB_WEAPON_sHUDTexture);
						if( !LTStrEmpty( szTexture ))
						{
							m_aObjects[ AOT_PICKUP ].Load( szTexture );
							m_bObjectTextureValid = false;
						}
					}
				}
			}
		}
		break;

		default:
		break;
	}
}