Esempio n. 1
0
static int SetupDisass(int nArea)
{
	nDisassAddress[0] = 0;
	nDisassArea = nArea;
	nDisassAttrib = 0;

	nDisassCPUType = SekDbgGetCPUType();

	if (nDisassArea) {
		SekDbgFetchByteDisassembler = DbgFetchByteArea;
		SekDbgFetchWordDisassembler = DbgFetchWordArea;
		SekDbgFetchLongDisassembler = DbgFetchLongArea;
	} else {
		SekDbgFetchByteDisassembler = DbgFetchByte;
		SekDbgFetchWordDisassembler = DbgFetchWord;
		SekDbgFetchLongDisassembler = DbgFetchLong;

		nDisassAddress[0] = TraceBack(SekDbgGetRegister(SEK_REG_PC), 5, nDisassCPUType);
	}

	CreateDisass(GetDlgItem(hDbgDlg, nDisassWindow), nDisassAddress[0], nDisassCPUType);
	SendDlgItemMessage(hDbgDlg, IDC_DBG_MAINWN1_DRP1, CB_SETCURSEL, (WPARAM)nDisassArea, (LPARAM)0);

	SendDlgItemMessage(hDbgDlg, IDC_DBG_MAINWN1_DRP2, CB_RESETCONTENT, (WPARAM)0, (LPARAM)0);
	if (nArea) {
		SendDlgItemMessage(hDbgDlg, IDC_DBG_MAINWN1_DRP2, CB_ADDSTRING, (WPARAM)0, (LPARAM)_T("little-endian 8-bit / big-endian"));
		SendDlgItemMessage(hDbgDlg, IDC_DBG_MAINWN1_DRP2, CB_ADDSTRING, (WPARAM)0, (LPARAM)_T("little-endian 16-bit"));
		SendDlgItemMessage(hDbgDlg, IDC_DBG_MAINWN1_DRP2, CB_ADDSTRING, (WPARAM)0, (LPARAM)_T("little-endian 32-bit"));
	} else {
		SendDlgItemMessage(hDbgDlg, IDC_DBG_MAINWN1_DRP2, CB_ADDSTRING, (WPARAM)0, (LPARAM)_T("Auto"));
	}
	SendDlgItemMessage(hDbgDlg, IDC_DBG_MAINWN1_DRP2, CB_SETCURSEL, (WPARAM)0, (LPARAM)0);

	return 0;
}
Esempio n. 2
0
int main(int argc, char const *argv[])
{
	MNS(11);
	TraceBack(10);
	for(int i = 0;i < 11;i++){
		printf("%d ",Net[i] );
	}
	printf("\n\n\n");
	for(int i = 1;i <= 10;i++){
		for(int j = 1;j <= 10;j++){
			printf("%d ",size[i][j]);
		}
		printf("\n");
	}
	return 0;
}
bool unXmlParseTree::ParseTree( unXmlNode*& node, unXmlParser* parser )
{
    Reset(node);

    while( true )
    {
        if( node == NULL )
        {
            if( !ParseCount.IsValid() )
                throw exception( wxString::Format( wxT("Expected: %s<%s>, got: nothing"), TraceBack().c_str(), Name.c_str() ).c_str() );
            //wxLogMessage( wxT("[?][%s] %d"), Name.c_str(), ParseCount );
            return true;
        }
        else if( !xml::IsSameName(node,Name) )
        {
            if( !ParseCount.IsValid() )
                throw exception( wxString::Format( wxT("Expected: %s<%s>, got: %s"), TraceBack().c_str(), Name.c_str(), xml::TraceBack(node).c_str() ).c_str() );

            //wxLogMessage( wxT("[!%s][%s] %d"), node->GetName().c_str(), Name.c_str(), ParseCount );
            return true;
        }
        else
        {
            //wxLogMessage( wxT("[%s][%s] %d"), node->GetName().c_str(), Name.c_str(), ParseCount );

            // parse element
            ParseCount.Increase();
            Node = node;
            parser->SetNode(node);
            parser->SetParseTree(this);
            xpCommandEvent( Commands, &xpCommand::OnParseNode, this, node );
            //parser->ClearParseTree();
            //parser->ClearNode();
            //Node = NULL;

            // Parse children
            unXmlNode* next = node->GetChildren();
            for( iterator it=begin(); it!=end(); ++it )
            {
                // parse only elements
                while( next!=NULL && next->GetType()!=wxXML_ELEMENT_NODE )
                    next = next->GetNext();

                unXmlParseTree* pt = static_cast<unXmlParseTree*>(*it);
                pt->ParseTree(next,parser);
            }

            // Unknown element!
            if( next != NULL && next->GetType() == wxXML_ELEMENT_NODE )
                throw exception( wxString::Format( wxT("Unknown element: %s"), xml::TraceBack(node).c_str() ).c_str() );

            //Node = node;
            parser->SetNode(node);
            parser->SetParseTree(this);
            xpCommandEvent( PostCommands, &xpCommand::OnParseNode, this, node );
            //parser->ClearParseTree();
            //parser->ClearNode();
            //Node = NULL;

            node = node->GetNext();
            if( !ParseCount.IsNextValid() )
                return true;
        }
    }

    return true;
}
Esempio n. 4
0
/*>int blAffinealignuc(char *seq1, int length1, char *seq2, int length2, 
                       BOOL verbose, BOOL identity, int penalty, 
                       int penext, char *align1, char *align2, 
                       int *align_len)
   ---------------------------------------------------------------------
*//**

   \param[in]     *seq1         First sequence
   \param[in]     length1       First sequence length
   \param[in]     *seq2         Second sequence
   \param[in]     length2       Second sequence length
   \param[in]     verbose       Display N&W matrix
   \param[in]     identity      Use identity matrix
   \param[in]     penalty       Gap insertion penalty value
   \param[in]     penext        Extension penalty
   \param[out]    *align1       Sequence 1 aligned
   \param[out]    *align2       Sequence 2 aligned
   \param[out]    *align_len    Alignment length
   \return                         Alignment score (0 on error)
            
   Perform simple N&W alignment of seq1 and seq2. No window is used, so
   will be slow for long sequences.

   Note that you must allocate sufficient memory for the aligned 
   sequences.
   The easy way to do this is to ensure that align1 and align2 are
   of length (length1+length2).

-  07.10.92 Adapted from original written while at NIMR
-  08.10.92 Split into separate routines
-  09.10.92 Changed best structure to simple integers, moved 
            SearchForBest() into TraceBack()
-  21.08.95 Was only filling in the bottom right cell at initialisation
            rather than all the right hand column and bottom row
-  11.07.96 Changed calls to calcscore() to CalcMDMScore()
-  06.03.00 Changed name to affinealign() (the routine align() is
            provided as a backwards compatible wrapper). Added penext 
            parameter. Now supports affine gap penalties with separate
            opening and extension penalties. The code now maintains
            the path as it goes.
-  27.02.07 Exactly as affinealign() but upcases characters before
            comparison
-  07.07.14 Use bl prefix for functions By: CTP

**************************************************************************
******    NOTE AND CHANGES SHOULD BE PROPAGATED TO affinealign()    ******
**************************************************************************
*/
int blAffinealignuc(char *seq1, 
                    int  length1, 
                    char *seq2, 
                    int  length2, 
                    BOOL verbose, 
                    BOOL identity, 
                    int  penalty, 
                    int  penext,
                    char *align1, 
                    char *align2,
                    int  *align_len)
{
   XY    **dirn   = NULL;
   int   **matrix = NULL,
         maxdim,
         i,    j,    k,    l,
         i1,   j1,
         dia,  right, down,
         rcell, dcell, maxoff,
         match = 1,
         thisscore,
         gapext,
         score;
   
   maxdim = MAX(length1, length2);
   
   /* Initialise the score matrix                                       */
   if((matrix = (int **)blArray2D(sizeof(int), maxdim, maxdim))==NULL)
      return(0);
   if((dirn   = (XY **)blArray2D(sizeof(XY), maxdim, maxdim))==NULL)
      return(0);
      
   for(i=0;i<maxdim;i++)
   {
      for(j=0;j<maxdim;j++)
      {
         matrix[i][j] = 0;
         dirn[i][j].x = -1;
         dirn[i][j].y = -1;
      }
   }
    
   /* Fill in scores up the right hand side of the matrix               */
   for(j=0; j<length2; j++)
   {
      if(identity)
      {
         if(seq1[length1-1] == seq2[j]) matrix[length1-1][j] = match;
      }
      else
      {
         matrix[length1-1][j] = blCalcMDMScoreUC(seq1[length1-1],seq2[j]);
      }
   }

   /* Fill in scores along the bottom row of the matrix                 */
   for(i=0; i<length1; i++)
   {
      if(identity)
      {
         if(seq1[i] == seq2[length2-1]) matrix[i][length2-1] = match;
      }
      else
      {
         matrix[i][length2-1] = blCalcMDMScoreUC(seq1[i],seq2[length2-1]);
      }
   }

   i = length1 - 1;
   j = length2 - 1;
   
   /* Move back along the diagonal                                      */
   while(i > 0 && j > 0)
   {
      i--;
      j--;

      /* Fill in the scores along this row                              */
      for(i1 = i; i1 > -1; i1--)
      {
         dia   = matrix[i1+1][j+1];

         /* Find highest score to right of diagonal                     */
         rcell = i1+2;
         if(i1+2 >= length1)  right = 0;
         else                 right = matrix[i1+2][j+1] - penalty;
         
         gapext = 1;
         for(k = i1+3; k<length1; k++, gapext++)
         {
            thisscore = matrix[k][j+1] - (penalty + gapext*penext);
            
            if(thisscore > right) 
            {
               right = thisscore;
               rcell = k;
            }
         }

         /* Find highest score below diagonal                           */
         dcell = j+2;
         if(j+2 >= length2)  down = 0;
         else                down   = matrix[i1+1][j+2] - penalty;
         
         gapext = 1;
         for(l = j+3; l<length2; l++, gapext++)
         {
            thisscore = matrix[i1+1][l] - (penalty + gapext*penext);

            if(thisscore > down) 
            {
               down = thisscore;
               dcell = l;
            }
         }
         
         /* Set score to best of these                                  */
         maxoff = MAX(right, down);
         if(dia >= maxoff)
         {
            matrix[i1][j] = dia;
            dirn[i1][j].x = i1+1;
            dirn[i1][j].y = j+1;
         }
         else
         {
            if(right > down)
            {
               matrix[i1][j] = right;
               dirn[i1][j].x = rcell;
               dirn[i1][j].y = j+1;
            }
            else
            {
               matrix[i1][j] = down;
               dirn[i1][j].x = i1+1;
               dirn[i1][j].y = dcell;
            }
         }
       
         /* Add the score for a match                                   */
         if(identity)
         {
            if(seq1[i1] == seq2[j]) matrix[i1][j] += match;
         }
         else
         {
            matrix[i1][j] += blCalcMDMScoreUC(seq1[i1],seq2[j]);
         }
      }

      /* Fill in the scores in this column                              */
      for(j1 = j; j1 > -1; j1--)
      {
         dia   = matrix[i+1][j1+1];
         
         /* Find highest score to right of diagonal                     */
         rcell = i+2;
         if(i+2 >= length1)   right = 0;
         else                 right = matrix[i+2][j1+1] - penalty;

         gapext = 1;
         for(k = i+3; k<length1; k++, gapext++)
         {
            thisscore = matrix[k][j1+1] - (penalty + gapext*penext);
            
            if(thisscore > right) 
            {
               right = thisscore;
               rcell = k;
            }
         }

         /* Find highest score below diagonal                           */
         dcell = j1+2;
         if(j1+2 >= length2)  down = 0;
         else                 down = matrix[i+1][j1+2] - penalty;

         gapext = 1;
         for(l = j1+3; l<length2; l++, gapext++)
         {
            thisscore = matrix[i+1][l] - (penalty + gapext*penext);
            
            if(thisscore > down) 
            {
               down = thisscore;
               dcell = l;
            }
         }

         /* Set score to best of these                                  */
         maxoff = MAX(right, down);
         if(dia >= maxoff)
         {
            matrix[i][j1] = dia;
            dirn[i][j1].x = i+1;
            dirn[i][j1].y = j1+1;
         }
         else
         {
            if(right > down)
            {
               matrix[i][j1] = right;
               dirn[i][j1].x = rcell;
               dirn[i][j1].y = j1+1;
            }
            else
            {
               matrix[i][j1] = down;
               dirn[i][j1].x = i+1;
               dirn[i][j1].y = dcell;
            }
         }
       
         /* Add the score for a match                                   */
         if(identity)
         {
            if(seq1[i] == seq2[j1]) matrix[i][j1] += match;
         }
         else
         {
            matrix[i][j1] += blCalcMDMScoreUC(seq1[i],seq2[j1]);
         }
      }
   } 
   
   score = TraceBack(matrix, dirn, length1, length2,
                     seq1, seq2, align1, align2, align_len);

   if(verbose)
   {
      printf("Matrix:\n-------\n");
      for(j=0; j<length2;j++)
      {
         for(i=0; i<length1; i++)
         {
            printf("%3d ",matrix[i][j]);
         }
         printf("\n");
      }

      printf("Path:\n-----\n");
      for(j=0; j<length2;j++)
      {
         for(i=0; i<length1; i++)
         {
            printf("(%3d,%3d) ",dirn[i][j].x,dirn[i][j].y);
         }
         printf("\n");
      }
   }
    
   blFreeArray2D((char **)matrix, maxdim, maxdim);
   blFreeArray2D((char **)dirn,   maxdim, maxdim);
    
   return(score);
}