示例#1
0
static unsigned getMADMaxFormatWidth( mad_type_handle th )
{
    mad_radix           radix;
    void                *tmp;
    unsigned            max;
    mad_type_info       mti;
    int                 sign;
    unsigned long       mask;
    char                TxtBuff[100];

    sign = 0;
    MADTypeInfo( th, &mti );
    tmp=alloca( mti.b.bits );
    switch( mti.b.kind ) {
    case MTK_ADDRESS:
    case MTK_INTEGER:
        memset( tmp, -1, mti.b.bits );
        if( mti.i.nr != MNR_UNSIGNED ) {
            mask = 1L << mti.i.sign_pos;
            (*(unsigned_32 *)(tmp)) &= ~mask;
            ++sign;
        }
        break;
    case MTK_FLOAT:
        memset( tmp, 0, mti.b.bits );
        break;
    }
    radix = MADTypePreferredRadix( th );
    max = 0;
    MADTypeToString( radix, &mti, tmp, TxtBuff, &max );
    return( max + sign );
}
示例#2
0
static  void    RegModify( a_window *wnd, int row, int piece )
{
    int                     i;
    item_mach               value;
    reg_window              *reg = WndReg( wnd );
    bool                    ok;
    mad_radix               old_radix;
    reg_display_piece       disp;
    mad_type_info           tinfo;
    mad_modify_list const   *possible;
    int                     num_possible;

    if( row < 0 )
        return;
    piece >>= 1;
    i = GetRegIdx( reg, row, piece );
    if( i == -1 )
        return;
    if( !GetDisplayPiece( &disp, reg, DbgRegs, i ) )
        return;
    if( disp.reginfo == NULL )
        return;
    if( MADRegSetDisplayModify( reg->data, disp.reginfo, &possible, &num_possible ) != MS_OK )
        return;
    old_radix = NewCurrRadix( MADTypePreferredRadix( disp.disp_type ) );
    MADRegFullName( disp.reginfo, ".", TxtBuff, TXT_LEN );
    RegValue( &value, disp.reginfo, DbgRegs );
    if( num_possible == 1 ) {
        ok = DlgMadTypeExpr( TxtBuff, &value, disp.disp_type );
        if( ok ) {
            RegNewValue( disp.reginfo, &value, possible->type );
        }
    } else {
        for( i = 0; i < num_possible; ++i ) {
            MADTypeInfo( possible[i].type, &tinfo );
            if( memcmp( &value, possible[i].data, tinfo.b.bits / BITS_PER_BYTE ) == 0 ) {
                break;
            }
        }
        if( num_possible == 2 ) {
            if( i == 0 ) {
                i = 1;
            } else {
                i = 0;
            }
        } else {  //MJC const cast
            i = DlgPickWithRtn( TxtBuff, possible, i, RegValueName, num_possible );
        }
        if( i != -1 ) {
            RegNewValue( disp.reginfo, possible[i].data, possible[i].type );
        }
    }
    NewCurrRadix( old_radix );
}
示例#3
0
static const char *RegValueName( const void *data_handle, int item )
{
    mad_modify_list const *possible = (mad_modify_list const *)data_handle + item;
    size_t          buff_len;

    buff_len = TXT_LEN;
    if( possible->name == MAD_MSTR_NIL ) {
        MADTypeHandleToString( MADTypePreferredRadix( possible->type ),
                possible->type, possible->data, TxtBuff, &buff_len );
    } else {
        MADCliString( possible->name, TxtBuff, buff_len );
    }
    return( TxtBuff );
}
示例#4
0
static  bool    RegGetLine( a_window *wnd, int row, int piece,
                            wnd_line_piece *line )
{
    int                 column;
    int                 i;
    reg_window          *reg = WndReg( wnd );
    size_t              max = TXT_LEN;
    mad_radix           old_radix, new_radix;
    item_mach           value;
    reg_display_piece   disp;

    column = piece >> 1;
    if( column >= reg->up )
        return( false );
    i = GetRegIdx( reg, row, column );
    if( i >= reg->count )
        return( false );
    if( i == -1 )
        return( false );
    if( !GetDisplayPiece( &disp, reg, DbgRegs, i ) )
        return( false );
    line->text = TxtBuff;
    if( piece & 1 ) {
        line->indent = reg->indents[column].value;
        if( reg->info[i].info == NULL ) {
            strcpy( TxtBuff, "   " );
        } else {
            new_radix = MADTypePreferredRadix( disp.disp_type );
            old_radix = NewCurrRadix( new_radix );
            RegValue( &value, reg->info[i].info, DbgRegs );
            max = reg->info[i].max_value + 1;
            MADTypeHandleToString( new_radix, disp.disp_type, &value, TxtBuff, &max );
            NewCurrRadix( old_radix );
            reg->info[i].standout = false;
            if( MADRegModified( reg->data, reg->info[i].info, &PrevRegs->mr, &DbgRegs->mr ) == MS_MODIFIED_SIGNIFICANTLY ) {
                reg->info[i].standout = true;
                line->attr = WND_STANDOUT;
            }
        }
    } else {
        line->indent = reg->indents[column].descript;
        strcpy( TxtBuff, disp.descript );
        if( TxtBuff[0] != NULLCHAR ) {
            strcat( TxtBuff, ":" );
        }
        line->tabstop = false;
    }
    return( true );
}
示例#5
0
static void getMadString( mad_reg_set_data *data, mad_registers *regs, int i,
    RegStringCreateData *create )
{
    mad_type_handle mtype;
    mad_type_info   mti;
    mad_radix       radix;
    const mad_reg_info    *rinfo;
    void            *value;
    unsigned        max_len;
    const char      *descript;

    MADRegSetDisplayGetPiece( data, regs, i, &descript, &( create[i].maxd ), &rinfo, &mtype, &( create[i].length ) );

    if ( create[i].maxd == 0 && descript != NULL ){
        create[i].maxd = strlen( descript );
    }
    if ( descript != NULL && IsEmptyString( descript ) == FALSE ){
        strcpy( create[i].buffer, descript );
        create[i].maxd ++;
    } else {
        create[i].buffer[0] = '\0';
        create[i].maxd = 0;
    }

    if( create[i].length == 0 && rinfo != NULL ) {
       create[i].length = getMADMaxFormatWidth(mtype);
    }

    if( rinfo != NULL ) {
        MADTypeInfo( rinfo->type, &mti );
        value = alloca( BITS2BYTES( mti.b.bits ) );
        BitGet( value, (unsigned char *)regs, rinfo->bit_start, rinfo->bit_size );
        radix = MADTypePreferredRadix( mtype );
        max_len = create[i].length + 1;
        MADTypeHandleToString( radix, mtype, value, create[i].value, &max_len );
    } else {
        create[i].value[0] = '\0';
    }
}
示例#6
0
static void InitChangeRegisterDialog(HWND hwnd,LPARAM lparam)
{
    RegModifyData   *data;
    char            *name;
    unsigned        len;
    mad_radix       radix;
    mad_type_info   mti;
    mad_type_info   cmp;
    char            s[255];
    RECT            p_rect;
    RECT            c_rect;
    HWND            field;
    int             i;
    unsigned        max_len;
    HDC             dc;
    TEXTMETRIC      tm;
    HWND            cancel;

    SetWindowLong( hwnd, DWL_USER, (LONG)lparam);
    data = (RegModifyData *)lparam;
    len = MADRegFullName( data->curr_info, ".", NULL, 0 );
    if( len > 0 ) {
        name = alloca( ( len + 1 ) * sizeof( char ) );
        MADRegFullName( data->curr_info, ".", name, len );
        SetWindowText( hwnd, name );
    } else {
        SetWindowText( hwnd, "" );
    }

    if( data->num_possible == 1 ) {
        field = GetDlgItem( hwnd, REG_EDIT_FIELD );
    } else {
        field = GetDlgItem( hwnd, CH_REG_COMBO_LIST );
    }
    SetMonoFont( field );
    GetChildPos( hwnd, field, &c_rect);
    dc = GetDC( field );
    GetTextMetrics( dc, &tm );
    MADTypeInfo( data->th, &mti );
    radix = MADTypePreferredRadix( data->th );

    if( data->num_possible == 1 ) {
        if( data->maxv == 0 ) {
            len = 255;
        } else {
            len = data->maxv;
        }
        MADTypeToString( radix, &mti, data->curr_value, s, &len );
        if( data->maxv == 0 ) {
            max_len = strlen( s );
        } else {
            max_len = data->maxv;
        }
        SetDlgItemText(hwnd,REG_EDIT_FIELD,s);
    } else {
        MADTypeInfo( data->curr_info->type, &cmp );
        max_len = 0;
        for( i = 0; i < data->num_possible; i++ ) {
            if( data->m_list[i].name == MAD_MSTR_NIL ) {
                len = sizeof( s );
                MADTypeToString( radix, &mti, data->m_list[i].data, s, &len );
            } else {
                MADCliString( data->m_list[i].name, s, sizeof( s ) );
            }
            if( max_len < strlen( s ) )
                max_len = strlen( s );
            SendDlgItemMessage( hwnd, CH_REG_COMBO_LIST, CB_ADDSTRING, 0, (LPARAM)s );
            if( memcmp( data->curr_value, data->m_list[i].data, cmp.b.bits / BITS_PER_BYTE ) == 0 ){
                SendDlgItemMessage( hwnd, CH_REG_COMBO_LIST, CB_SETCURSEL, (WPARAM)i, 0 );
            }
        }
        c_rect.bottom += SendMessage( field, CB_GETITEMHEIGHT, 0, 0 ) * (i + 1);
    }
    max_len *= tm.tmMaxCharWidth;
    if( max_len > c_rect.right ) {
        max_len -= max_len%2;
        GetWindowRect( hwnd, &p_rect );
        p_rect.right -= p_rect.left;
        p_rect.bottom -= p_rect.top;
        p_rect.left -= ( max_len - c_rect.right )/2;
        p_rect.right += ( max_len - c_rect.right );
        MoveWindow( hwnd, p_rect.left, p_rect.top, p_rect.right, p_rect.bottom, FALSE );
        cancel = GetDlgItem( hwnd, IDCANCEL );
        GetChildPos( hwnd, cancel, &p_rect );
        p_rect.left += ( max_len - c_rect.right );
        MoveWindow( cancel, p_rect.left, p_rect.top, p_rect.right, p_rect.bottom, FALSE );
        c_rect.right = max_len;
    }
    ReleaseDC( field, dc );
    MoveWindow( field, c_rect.left, c_rect.top, c_rect.right, c_rect.bottom, FALSE );
}