void PointSet::Draw ( float* view_mat, float rad )
{
	char* dat;
	Point* p;
	glEnable ( GL_NORMALIZE );	

	if ( m_Param[PNT_DRAWMODE] == 0 ) {
		glLoadMatrixf ( view_mat );
		dat = mBuf[0].data;	
		for (int n = 0; n < NumPoints(); n++) {
			p = (Point*) dat;
			glPushMatrix ();
			glTranslatef ( p->pos.x, p->pos.y, p->pos.z );		
			glScalef ( 0.2, 0.2, 0.2 );	
			if(p->type == 0)
			glColor4f ( 0.1,0.3,1.0,1.0 );//glColor4f ( RED(p->clr), GRN(p->clr), BLUE(p->clr), ALPH(p->clr) );
			else
            glColor4f ( RED(p->clr), GRN(p->clr), BLUE(p->clr), 0.0 );
			drawSphere ();
			glPopMatrix ();		
			dat += mBuf[0].stride;
		}	
	} else if ( m_Param[PNT_DRAWMODE] == 1 ) {
		glLoadMatrixf ( view_mat );
		dat = mBuf[0].data;
		glBegin ( GL_POINTS );
		for (int n=0; n < NumPoints(); n++) {
			p = (Point*) dat;
			glColor3f ( RED(p->clr), GRN(p->clr), BLUE(p->clr) );			
			glVertex3f ( p->pos.x, p->pos.y, p->pos.z );			
			dat += mBuf[0].stride;
		}
		glEnd ();
	}
}
Beispiel #2
0
/* For IOCTL */
static INT D_SetEnable(
			PBND_STRG_CLI_TABLE table,
			BOOLEAN enable)
{
	INT ret_val = BND_STRG_SUCCESS;
	PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) table->priv;

	DBGPRINT(RT_DEBUG_OFF, 
			("%s(): enable = %u\n", __FUNCTION__,  enable));

	if (!(table->bEnabled ^ enable))
	{
		/* Already enabled/disabled */
		BND_STRG_DBGPRINT(RT_DEBUG_OFF, /* TRACE */
				(GRN("%s(): Band steering is already %s.\n"),
				__FUNCTION__, (enable ? "enabled" : "disabled")));
		return BND_STRG_SUCCESS;
	}

	pAd->ApCfg.BandSteering = enable;

	if (enable)
		ret_val = BndStrg_Init(pAd);
	else
		ret_val = BndStrg_Release(pAd);

	if (ret_val != BND_STRG_SUCCESS)
	{
		BND_STRG_DBGPRINT(RT_DEBUG_ERROR,
					("Error in %s(), error code = %d!\n", __FUNCTION__, ret_val));
	}

	return TRUE;
}
Beispiel #3
0
INT BndStrg_Enable(PBND_STRG_CLI_TABLE table, BOOLEAN enable)
{
	BNDSTRG_MSG msg;
	PRTMP_ADAPTER pAd = NULL;

	if (table == NULL)
		return BND_STRG_TABLE_IS_NULL;

	if (table->bInitialized == FALSE)
		return BND_STRG_NOT_INITIALIZED;
	if (!(table->bEnabled ^ enable))
	{
		/* Already enabled/disabled */
		BND_STRG_DBGPRINT(RT_DEBUG_OFF, /* TRACE */
				(GRN("%s(): Band steering is already %s.\n"),
				__FUNCTION__, (enable ? "enabled" : "disabled")));
		return BND_STRG_SUCCESS;
	}

	if (enable)
	{
		table->bEnabled = TRUE;
	}
	else
	{

		table->bEnabled = FALSE;
	}

		pAd = (PRTMP_ADAPTER) table->priv;
		msg.Action = BNDSTRG_ONOFF;
		msg.OnOff = table->bEnabled;
		RtmpOSWrielessEventSend(
			pAd->net_dev,
			RT_WLAN_EVENT_CUSTOM,
			OID_BNDSTRG_MSG,
			NULL,
			(UCHAR *)&msg,
			sizeof(msg));

	BND_STRG_DBGPRINT(RT_DEBUG_OFF,
				(GRN("%s(): Band steering %s running.\n"),
				__FUNCTION__, (enable ? "start" : "stop")));

	return BND_STRG_SUCCESS;
}
/* ------------------------------------------------------------------------- */
static UINT32 alpha_add(
    UINT32 c1,
    UINT32 c2)
{
	UINT32 a1 = ALF(c1);
	UINT32 r1 = RED(c1);
	UINT32 g1 = GRN(c1);
	UINT32 b1 = BLU(c1);
	UINT32 a2 = ALF(c2);
	UINT32 r2 = RED(c2);
	UINT32 g2 = GRN(c2);
	UINT32 b2 = BLU(c2);
	UINT32 a3 = ((a1 * a1 + (255 - a1) * a2) / 255) & 0xff;
	UINT32 r3 = ((a1 * r1 + (255 - a1) * r2) / 255) & 0xff;
	UINT32 g3 = ((a1 * g1 + (255 - a1) * g2) / 255) & 0xff;
	UINT32 b3 = ((a1 * b1 + (255 - a1) * b2) / 255) & 0xff;
	return (a3 << 24) | (r3 << 16) | (g3 << 8) | b3;
}
Beispiel #5
0
static int getPixel( gxCanvas *c,float x,float y ){
	debugCanvas( c );

	x-=.5f;y-=.5f;
	float fx=floor(x),fy=floor(y);
	int ix=fx,iy=fy;fx=x-fx;fy=y-fy;

	int tl=c->getPixel( ix,iy );
	int tr=c->getPixel( ix+1,iy );
	int br=c->getPixel( ix+1,iy+1 );
	int bl=c->getPixel( ix,iy+1 );

	float w1=(1-fx)*(1-fy),w2=fx*(1-fy),w3=(1-fx)*fy,w4=fx*fy;

	float r=RED(tl)*w1+RED(tr)*w2+RED(bl)*w3+RED(br)*w4;
	float g=GRN(tl)*w1+GRN(tr)*w2+GRN(bl)*w3+GRN(br)*w4;
	float b=BLU(tl)*w1+BLU(tr)*w2+BLU(bl)*w3+BLU(br)*w4;

	return (int(r+.5f)<<16)|(int(g+.5f)<<8)|int(b+.5f);
}
/* ------------------------------------------------------------------------- */
static UINT32 colordist(
    UINT32 c1,
    UINT32 c2)
{
	int d, maxd = 0;
	d = ABS((INT32)(ALF(c1) - ALF(c2)));

	if (d > maxd) maxd = d;

	d = ABS((INT32)(RED(c1) - RED(c2)));

	if (d > maxd) maxd = d;

	d = ABS((INT32)(GRN(c1) - GRN(c2)));

	if (d > maxd) maxd = d;

	d = ABS((INT32)(BLU(c1) - BLU(c2)));

	if (d > maxd) maxd = d;

	return maxd;
}
DWORD PointSet::GetColor ( float x, float y, float z )
{
	Vector3DF clr;  
	float dx, dy, dz, dsq;
	float sum;
	int pndx;
	Point* pcurr;
	float R2 = (m_GridCellsize/2.0)*(m_GridCellsize/2.0);

	Grid_FindCells ( Vector3DF(x,y,z), m_GridCellsize/2.0 );

	int cnt = 0;
	sum = 0.0;
	clr.Set (0,0,0);
	for (int cell=0; cell < 8; cell++ ) {
		if ( m_GridCell[cell] != -1 ) {
			pndx = m_Grid [ m_GridCell[cell] ];
			while ( pndx != -1 ) {					
				pcurr = (Point*) (mBuf[0].data + pndx*mBuf[0].stride);
				dx = x - pcurr->pos.x;
				dy = y - pcurr->pos.y;
				dz = z - pcurr->pos.z;
				dsq = dx*dx+dy*dy+dz*dz;				
				if ( dsq < R2 ) {
					dsq = 2.0*R2 / (dsq*dsq);					
					clr.x += RED(pcurr->clr) * dsq;
					clr.y += GRN(pcurr->clr) * dsq;
					clr.z += BLUE(pcurr->clr) * dsq;						
				}
				pndx = pcurr->next;
			}	
		}
	}
	clr.Normalize ();
	return COLORA(clr.x, clr.y, clr.z, 1.0);
}
Beispiel #8
0
void col_apply_weight(double w, GLfloat *gl_c, Color col)
{
  gl_c[0] = w*RED(col); gl_c[1] = w*GRN(col); gl_c[2] = w*BLU(col);
}
    std::string DisassemblyTR3200 (const VComputer& vc, dword_t pc) {
#define BUF_SIZE (32)
      char buf[BUF_SIZE] = {0};

      dword_t inst = vc.ReadDW(pc); // Fetch
      pc = pc +4;

      dword_t opcode, rd, rn, rs;
      rd = GRD(inst);
      rs = GRS(inst);
      // Here beging the Decoding
      bool literal = HAVE_LITERAL(inst);
      opcode = GET_OP_CODE(inst);

      if (IS_P3(inst)) {
        // 3 parameter instruction ********************************************
        if (literal) {
          rn = LIT15(inst);
          if (IS_BIG_LITERAL_L15(rn)) { // Next dword is literal value
            rn = vc.ReadDW(pc);
            pc +=4;
          } else if (RN_SIGN_BIT(inst)) { // Negative Literal -> Extend sign
            rn |= 0xFFFF8000;
          }
        } else {
          rn = GRN(inst);
        }

        switch (opcode) {
          case P3_OPCODE::AND :
            if (literal)
              snprintf(buf, BUF_SIZE, "AND %%r%u, %%r%u, 0x%08X",  rd, rs, rn);
            else
              snprintf(buf, BUF_SIZE, "AND %%r%u, %%r%u, %%r%u", rd, rs, rn);
            break;

          case P3_OPCODE::OR :
            if (literal)
              snprintf(buf, BUF_SIZE, "OR %%r%u, %%r%u, 0x%08X",  rd, rs, rn);
            else
              snprintf(buf, BUF_SIZE, "OR %%r%u, %%r%u, %%r%u", rd, rs, rn);
            break;

          case P3_OPCODE::XOR :
            if (literal)
              snprintf(buf, BUF_SIZE, "XOR %%r%u, %%r%u, 0x%08X",  rd, rs, rn);
            else
              snprintf(buf, BUF_SIZE, "XOR %%r%u, %%r%u, %%r%u", rd, rs, rn);
            break;

          case P3_OPCODE::BITC :
            if (literal)
              snprintf(buf, BUF_SIZE, "BITC %%r%u, %%r%u, 0x%08X",  rd, rs, rn);
            else
              snprintf(buf, BUF_SIZE, "BITC %%r%u, %%r%u, %%r%u", rd, rs, rn);
            break;

          case P3_OPCODE::ADD :
            if (literal)
              snprintf(buf, BUF_SIZE, "ADD %%r%u, %%r%u, 0x%08X",  rd, rs, rn);
            else
              snprintf(buf, BUF_SIZE, "ADD %%r%u, %%r%u, %%r%u", rd, rs, rn);
            break;

          case P3_OPCODE::ADDC :
            if (literal)
              snprintf(buf, BUF_SIZE, "ADDC %%r%u, %%r%u, 0x%08X",  rd, rs, rn);
            else
              snprintf(buf, BUF_SIZE, "ADDC %%r%u, %%r%u, %%r%u", rd, rs, rn);
            break;

          case P3_OPCODE::SUB :
            if (literal)
              snprintf(buf, BUF_SIZE, "SUB %%r%u, %%r%u, 0x%08X",  rd, rs, rn);
            else
              snprintf(buf, BUF_SIZE, "SUB %%r%u, %%r%u, %%r%u", rd, rs, rn);
            break;

          case P3_OPCODE::SUBB :
            if (literal)
              snprintf(buf, BUF_SIZE, "SUBB %%r%u, %%r%u, 0x%08X",  rd, rs, rn);
            else
              snprintf(buf, BUF_SIZE, "SUBB %%r%u, %%r%u, %%r%u", rd, rs, rn);
            break;

          case P3_OPCODE::RSB :
            if (literal)
              snprintf(buf, BUF_SIZE, "RSB %%r%u, %%r%u, 0x%08X",  rd, rs, rn);
            else
              snprintf(buf, BUF_SIZE, "RSB %%r%u, %%r%u, %%r%u", rd, rs, rn);
            break;

          case P3_OPCODE::RSBB :
            if (literal)
              snprintf(buf, BUF_SIZE, "RSBB %%r%u, %%r%u, 0x%08X",  rd, rs, rn);
            else
              snprintf(buf, BUF_SIZE, "RSBB %%r%u, %%r%u, %%r%u", rd, rs, rn);
            break;

          case P3_OPCODE::LLS :
            if (literal)
              snprintf(buf, BUF_SIZE, "LLS %%r%u, %%r%u, 0x%08X",  rd, rs, rn);
            else
              snprintf(buf, BUF_SIZE, "LLS %%r%u, %%r%u, %%r%u", rd, rs, rn);
            break;

          case P3_OPCODE::RLS :
            if (literal)
              snprintf(buf, BUF_SIZE, "RLS %%r%u, %%r%u, 0x%08X",  rd, rs, rn);
            else
              snprintf(buf, BUF_SIZE, "RLS %%r%u, %%r%u, %%r%u", rd, rs, rn);
            break;

          case P3_OPCODE::ARS :
            if (literal)
              snprintf(buf, BUF_SIZE, "ARS %%r%u, %%r%u, 0x%08X",  rd, rs, rn);
            else
              snprintf(buf, BUF_SIZE, "ARS %%r%u, %%r%u, %%r%u", rd, rs, rn);
            break;

          case P3_OPCODE::ROTL :
            if (literal)
              snprintf(buf, BUF_SIZE, "ROTL %%r%u, %%r%u, 0x%08X",  rd, rs, rn);
            else
              snprintf(buf, BUF_SIZE, "ROTL %%r%u, %%r%u, %%r%u", rd, rs, rn);
            break;

          case P3_OPCODE::ROTR :
            if (literal)
              snprintf(buf, BUF_SIZE, "ROTR %%r%u, %%r%u, 0x%08X",  rd, rs, rn);
            else
              snprintf(buf, BUF_SIZE, "ROTR %%r%u, %%r%u, %%r%u", rd, rs, rn);
            break;


          case P3_OPCODE::MUL :
            if (literal)
              snprintf(buf, BUF_SIZE, "MUL %%r%u, %%r%u, 0x%08X",  rd, rs, rn);
            else
              snprintf(buf, BUF_SIZE, "MUL %%r%u, %%r%u, %%r%u", rd, rs, rn);
            break;

          case P3_OPCODE::SMUL :
            if (literal)
              snprintf(buf, BUF_SIZE, "SMUL %%r%u, %%r%u, 0x%08X",  rd, rs, rn);
            else
              snprintf(buf, BUF_SIZE, "SMUL %%r%u, %%r%u, %%r%u", rd, rs, rn);
            break;

          case P3_OPCODE::DIV :
            if (literal)
              snprintf(buf, BUF_SIZE, "DIV %%r%u, %%r%u, 0x%08X",  rd, rs, rn);
            else
              snprintf(buf, BUF_SIZE, "DIV %%r%u, %%r%u, %%r%u", rd, rs, rn);
            break;

          case P3_OPCODE::SDIV :
            if (literal)
              snprintf(buf, BUF_SIZE, "SDIV %%r%u, %%r%u, 0x%08X",  rd, rs, rn);
            else
              snprintf(buf, BUF_SIZE, "SDIV %%r%u, %%r%u, %%r%u", rd, rs, rn);
            break;


          case P3_OPCODE::LOAD :
            if (literal)
              snprintf(buf, BUF_SIZE, "LOAD %%r%u, [%%r%u + 0x%08X]",  rd, rs, rn);
            else
              snprintf(buf, BUF_SIZE, "LOAD %%r%u, [%%r%u + %%r%u]", rd, rs, rn);
            break;

          case P3_OPCODE::LOADW :
            if (literal)
              snprintf(buf, BUF_SIZE, "LOADW %%r%u, [%%r%u + 0x%08X]",  rd, rs, rn);
            else
              snprintf(buf, BUF_SIZE, "LOADW %%r%u, [%%r%u + %%r%u]", rd, rs, rn);
            break;

          case P3_OPCODE::LOADB :
            if (literal)
              snprintf(buf, BUF_SIZE, "LOADB %%r%u, [%%r%u + 0x%08X]",  rd, rs, rn);
            else
              snprintf(buf, BUF_SIZE, "LOADB %%r%u, [%%r%u + %%r%u]", rd, rs, rn);
            break;

          case P3_OPCODE::STORE :
            if (literal)
              snprintf(buf, BUF_SIZE, "STORE [%%r%u + 0x%08X], %%r%u", rs, rn, rd);
            else
              snprintf(buf, BUF_SIZE, "STORE [%%r%u + %%r%u], %%r%u",rs, rn, rd);
            break;

          case P3_OPCODE::STOREW :
            if (literal)
              snprintf(buf, BUF_SIZE, "STOREW [%%r%u + 0x%08X], %%r%u", rs, rn, rd);
            else
              snprintf(buf, BUF_SIZE, "STOREW [%%r%u + %%r%u], %%r%u", rs, rn, rd);
            break;

          case P3_OPCODE::STOREB :
            if (literal)
              snprintf(buf, BUF_SIZE, "STOREB [%%r%u + 0x%08X], %%r%u", rs, rn, rd);
            else
              snprintf(buf, BUF_SIZE, "STOREB [%%r%u + %%r%u], %%r%u", rs, rn, rd);
            break;


          default:
            if (literal)
              snprintf(buf, BUF_SIZE, "???? %%r%u, %%r%u, 0x%08X",  rd, rs, rn);
            else
              snprintf(buf, BUF_SIZE, "???? %%r%u, %%r%u, %%r%u", rd, rs, rn);
            break;
        }
      } else if (IS_P2(inst)) {
        // Fetch Rn operand
        if (literal) {
          rn = LIT19(inst);
          if (IS_BIG_LITERAL_L19(rn)) { // Next dword is literal value
            rn = vc.ReadDW(pc);
            pc +=4;
          } else if (RN_SIGN_BIT(inst)) { // Negative Literal -> Extend sign
            rn |= 0xFFF80000;
          }
        } else {
          rn = GRS(inst);
        }

        switch (opcode) {
          case P2_OPCODE::MOV :
            if (literal)
              snprintf(buf, BUF_SIZE, "MOV %%r%u, 0x%08X",  rd, rn);
            else
              snprintf(buf, BUF_SIZE, "MOV %%r%u, %%r%u", rd, rn);
            break;

          case P2_OPCODE::SWP :
            if (literal)
              snprintf(buf, BUF_SIZE, "SWP %%r%u, 0x%08X",  rd, rn);
            else
              snprintf(buf, BUF_SIZE, "SWP %%r%u, %%r%u", rd, rn);
            break;

          case P2_OPCODE::SIGXB :
            if (literal)
              snprintf(buf, BUF_SIZE, "SIGXB %%r%u, 0x%08X",  rd, rn);
            else
              snprintf(buf, BUF_SIZE, "SIGXB %%r%u, %%r%u", rd, rn);
            break;

          case P2_OPCODE::SIGXW :
            if (literal)
              snprintf(buf, BUF_SIZE, "SIGXW %%r%u, 0x%08X",  rd, rn);
            else
              snprintf(buf, BUF_SIZE, "SIGXW %%r%u, %%r%u", rd, rn);
            break;

          case P2_OPCODE::NOT :
            if (literal)
              snprintf(buf, BUF_SIZE, "NOT %%r%u, 0x%08X",  rd, rn);
            else
              snprintf(buf, BUF_SIZE, "NOT %%r%u, %%r%u", rd, rn);
            break;

          case P2_OPCODE::LOAD2 :
            if (literal)
              snprintf(buf, BUF_SIZE, "LOAD %%r%u, [0x%08X]",  rd, rn);
            else
              snprintf(buf, BUF_SIZE, "LOAD %%r%u, [%%r%u]", rd,  rn);
            break;

          case P2_OPCODE::LOADW2 :
            if (literal)
              snprintf(buf, BUF_SIZE, "LOADW %%r%u, [0x%08X]",  rd, rn);
            else
              snprintf(buf, BUF_SIZE, "LOADW %%r%u, [%%r%u]", rd, rn);
            break;

          case P2_OPCODE::LOADB2 :
            if (literal)
              snprintf(buf, BUF_SIZE, "LOADB %%r%u, [0x%08X]",  rd, rn);
            else
              snprintf(buf, BUF_SIZE, "LOADB %%r%u, [%%r%u]", rd, rn);
            break;

          case P2_OPCODE::STORE2 :
            if (literal)
              snprintf(buf, BUF_SIZE, "STORE [0x%08X], %%r%u",  rn, rd);
            else
              snprintf(buf, BUF_SIZE, "STORE [%%r%u], %%r%u", rn, rd);
            break;

          case P2_OPCODE::STOREW2 :
            if (literal)
              snprintf(buf, BUF_SIZE, "STOREW [0x%08X], %%r%u", rn, rd);
            else
              snprintf(buf, BUF_SIZE, "STOREW [%%r%u], %%r%u", rn, rd);
            break;

          case P2_OPCODE::STOREB2 :
            if (literal)
              snprintf(buf, BUF_SIZE, "STOREB [0x%08X], %%r%u", rn, rd);
            else
              snprintf(buf, BUF_SIZE, "STOREB [%%r%u], %%r%u", rn, rd);
            break;


          case P2_OPCODE::IFEQ :
            if (literal)
              snprintf(buf, BUF_SIZE, "IFEQ %%r%u, 0x%08X",  rd, rn);
            else
              snprintf(buf, BUF_SIZE, "IFEQ %%r%u, %%r%u", rd, rn);
            break;

          case P2_OPCODE::IFNEQ :
            if (literal)
              snprintf(buf, BUF_SIZE, "IFNEQ %%r%u, 0x%08X",  rd, rn);
            else
              snprintf(buf, BUF_SIZE, "IFNEQ %%r%u, %%r%u", rd, rn);
            break;

          case P2_OPCODE::IFL :
            if (literal)
              snprintf(buf, BUF_SIZE, "IFL %%r%u, 0x%08X",  rd, rn);
            else
              snprintf(buf, BUF_SIZE, "IFL %%r%u, %%r%u", rd, rn);
            break;

          case P2_OPCODE::IFSL :
            if (literal)
              snprintf(buf, BUF_SIZE, "IFSL %%r%u, 0x%08X",  rd, rn);
            else
              snprintf(buf, BUF_SIZE, "IFSL %%r%u, %%r%u", rd, rn);
            break;

          case P2_OPCODE::IFLE :
            if (literal)
              snprintf(buf, BUF_SIZE, "IFLE %%r%u, 0x%08X",  rd, rn);
            else
              snprintf(buf, BUF_SIZE, "IFLE %%r%u, %%r%u", rd, rn);
            break;

          case P2_OPCODE::IFSLE :
            if (literal)
              snprintf(buf, BUF_SIZE, "IFSLE %%r%u, 0x%08X",  rd, rn);
            else
              snprintf(buf, BUF_SIZE, "IFSLE %%r%u, %%r%u", rd, rn);
            break;

          case P2_OPCODE::IFBITS :
            if (literal)
              snprintf(buf, BUF_SIZE, "IFBITS %%r%u, 0x%08X",  rd, rn);
            else
              snprintf(buf, BUF_SIZE, "IFBITS %%r%u, %%r%u", rd, rn);
            break;

          case P2_OPCODE::IFCLEAR :
            if (literal)
              snprintf(buf, BUF_SIZE, "IFCLEAR %%r%u, 0x%08X",  rd, rn);
            else
              snprintf(buf, BUF_SIZE, "IFCLEAR %%r%u, %%r%u", rd, rn);
            break;


          case P2_OPCODE::JMP2 :
            if (literal)
              snprintf(buf, BUF_SIZE, "JMP %%r%u + 0x%08X",  rd, rn);
            else
              snprintf(buf, BUF_SIZE, "JMP %%r%u + %%r%u", rd, rn);
            break;

          case P2_OPCODE::CALL2 :
            if (literal)
              snprintf(buf, BUF_SIZE, "CALL %%r%u + 0x%08X",  rd, rn);
            else
              snprintf(buf, BUF_SIZE, "CALL %%r%u + %%r%u", rd, rn);
            break;


          default:
            if (literal)
              snprintf(buf, BUF_SIZE, "???? %%r%u, 0x%08X",  rd, rn);
            else
              snprintf(buf, BUF_SIZE, "???? %%r%u, %%r%u", rd, rn);
            break;
        }

      } else if (IS_P1(inst)) {
        // 1 parameter instrucction *******************************************
        // Fetch Rn operand
        if (literal) {
          rn = LIT23(inst);
          if (IS_BIG_LITERAL_L23(rn)) { // Next dword is literal value
            rn = vc.ReadDW(pc);
            pc +=4;
          } else if (RN_SIGN_BIT(inst)) { // Negative Literal -> Extend sign
            rn |= 0xFF800000;
          }
        } else {
          rn = GRD(inst);
        }

        switch (opcode) {
          case P1_OPCODE::XCHGB :
            if (literal)
              snprintf(buf, BUF_SIZE, "XCHGB? 0x%08X",  rn);
            else
              snprintf(buf, BUF_SIZE, "XCHGB %%r%u", rn);
            break;

          case P1_OPCODE::XCHGW :
            if (literal)
              snprintf(buf, BUF_SIZE, "XCHGW? 0x%08X",  rn);
            else
              snprintf(buf, BUF_SIZE, "XCHGW %%r%u", rn);
            break;

          case P1_OPCODE::GETPC :
            if (literal)
              snprintf(buf, BUF_SIZE, "GETPC? 0x%08X",  rn);
            else
              snprintf(buf, BUF_SIZE, "GETPC %%r%u", rn);
            break;


          case P1_OPCODE::POP :
            if (literal)
              snprintf(buf, BUF_SIZE, "POP? 0x%08X",  rn);
            else
              snprintf(buf, BUF_SIZE, "POP %%r%u", rn);
            break;

          case P1_OPCODE::PUSH :
            if (literal)
              snprintf(buf, BUF_SIZE, "PUSH 0x%08X",  rn);
            else
              snprintf(buf, BUF_SIZE, "PUSH %%r%u", rn);
            break;


          case P1_OPCODE::JMP :
            if (literal)
              snprintf(buf, BUF_SIZE, "JMP 0x%08X",  rn);
            else
              snprintf(buf, BUF_SIZE, "JMP %%r%u", rn);
            break;

          case P1_OPCODE::CALL :
            if (literal)
              snprintf(buf, BUF_SIZE, "CALL 0x%08X",  rn);
            else
              snprintf(buf, BUF_SIZE, "CALL %%r%u", rn);
            break;

          case P1_OPCODE::RJMP :
            if (literal)
              snprintf(buf, BUF_SIZE, "JMP %%pc +0x%08X",  rn);
            else
              snprintf(buf, BUF_SIZE, "JMP %%pc +%%r%u", rn);
            break;

          case P1_OPCODE::RCALL :
            if (literal)
              snprintf(buf, BUF_SIZE, "CALL %%pc +0x%08X",  rn);
            else
              snprintf(buf, BUF_SIZE, "CALL %%pc +%%r%u", rn);
            break;

          case P1_OPCODE::INT :
            if (literal)
              snprintf(buf, BUF_SIZE, "INT %08Xh", rn);
            else
              snprintf(buf, BUF_SIZE, "INT %%r%u", rn);
            break;



          default:
            if (literal)
              snprintf(buf, BUF_SIZE, "???? 0x%08X",  rn);
            else
              snprintf(buf, BUF_SIZE, "???? %%r%u", rn);
            break;
        }
      } else {
        // 0 parameter instrucction *******************************************

        switch (opcode) {
          case NP_OPCODE::SLEEP :
            snprintf(buf, BUF_SIZE, "SLEEP");
            break;

          case NP_OPCODE::RET :
            snprintf(buf, BUF_SIZE, "RET");
            break;

          case NP_OPCODE::RFI :
            snprintf(buf, BUF_SIZE, "RFI");
            break;

          default:
            snprintf(buf, BUF_SIZE, "????");
        }
      }


      std::string out(buf);
      return out;

#undef BUF_SIZE
    }