示例#1
0
void find_align(ea_t ea, ea_t maxea, asize_t length, int alignment)
{
	ea_t ret = next_unknown(ea, maxea);
	msg("next_unknown: %08X. get_word: %04X", ret, get_word(ret));
	if (ret != BADADDR && get_word(ret) == 0x0009)
		doAlign(ret, length, alignment);
}
示例#2
0
//=============================================================================
// Print string at x,y
// pre: spriteBegin()
// post: spriteEnd()
//=============================================================================
void Text::print(const std::string &str, int x, int y)
{
    UCHAR ch = 0, chN = 0;
    std::string str2;
    width = textNS::FONT_WIDTH;
    int scaledWidth = static_cast<int>(textNS::FONT_WIDTH*spriteData.scale);
    float saveY=0;
    int tabX=0, tabW=0;
    
    spriteData.x = (float)x;
    spriteData.y = (float)y;
    doAlign(str);

    for(UINT i=0; i<str.length(); i++)
    {
        ch = str.at(i);
        if (ch > textNS::MIN_CHAR && ch <= textNS::MAX_CHAR)    // if displayable character
        {
            chN = ch - textNS::MIN_CHAR;                // make min_char index 0
            spriteData.rect.top = chN / textNS::COLUMNS * textNS::GRID_HEIGHT + 1;
            spriteData.rect.bottom = spriteData.rect.top + textNS::FONT_HEIGHT;
            if(proportional)
            {
                spriteData.rect.left = fontData[chN/textNS::COLUMNS][chN % textNS::COLUMNS].left;
                // DirectX wants right + 1
                spriteData.rect.right = fontData[chN/textNS::COLUMNS][chN % textNS::COLUMNS].right + 1;
                width = spriteData.rect.right - spriteData.rect.left;
                if(width >= textNS::FONT_WIDTH)         // if full width character do not add spacing
                {
                    width = textNS::FONT_WIDTH;         // limit width
                    spriteData.rect.left = chN % textNS::COLUMNS * textNS::GRID_WIDTH + 1;
                    spriteData.rect.right = spriteData.rect.left + textNS::FONT_WIDTH;
                }
                else    // not full width so add spacing between characters
                    width += proportionalSpacing;
                scaledWidth = static_cast<int>(width*spriteData.scale);
                drawChar(ch);
            }
            else    // fixed pitch
            {
                width = textNS::FONT_WIDTH;
                spriteData.rect.left = chN % textNS::COLUMNS * textNS::GRID_WIDTH + 1;
                spriteData.rect.right = spriteData.rect.left + textNS::FONT_WIDTH;
                drawChar(ch);
            }
            spriteData.x += scaledWidth;
        } 
        else    // else, non displayable character
        {
            switch(ch)
            {
            case ' ':                            // space
                if(proportional)
                {
                    width = textNS::FONT_WIDTH/2;
                    scaledWidth = static_cast<int>(width*spriteData.scale);
                }
                drawChar(' ');
                spriteData.x += scaledWidth;
                break;
            // newline advances 1 line down and sets left edge to starting x screen position,
            // not left edge of screen
            case '\n':                            // newline
                spriteData.x = (float)x;
                spriteData.y += static_cast<int>(height*spriteData.scale);
                saveY = spriteData.y;
                str2 = str.substr(i,str.length());
                doAlign(str2);
                spriteData.y = saveY;
                break;
            case '\r':                            // return to starting x position
                spriteData.x = (float)x;
                str2 = str.substr(i,str.length());
                doAlign(str2);
                break;
            case '\t':                            // tab
                width = textNS::FONT_WIDTH;
                scaledWidth = static_cast<int>(width*spriteData.scale);
                tabX = static_cast<int>(spriteData.x) / (scaledWidth * tabSize);
                tabX = (tabX+1) * scaledWidth * tabSize;
                tabW = tabX - static_cast<int>(spriteData.x);
                while(tabW > 0)
                {
                    if(tabW >= scaledWidth)
                    {
                        drawChar(' ');
                        spriteData.x += scaledWidth;
                    }
                    else
                    {
                        width = tabW;        // fractional part of character to align with tab stop
                        drawChar(' ');
                        spriteData.x += tabW;
                    }
                    tabW -= scaledWidth;
                }
                break;
            case '\b':                            // backspace
                spriteData.x -= scaledWidth;
                if(spriteData.x < 0)
                    spriteData.x = 0;
                break;
            case '\v':                            // vertical tab
                spriteData.y += static_cast<int>(height*spriteData.scale);
                break;
            case 0x01:                            // font signature character
                spriteData.rect.top = 1;
                spriteData.rect.bottom = 1 + textNS::FONT_HEIGHT;
                spriteData.rect.left = 1;
                spriteData.rect.right = 1 + textNS::FONT_WIDTH;
                Draw(spriteData);
                spriteData.x += scaledWidth;
                break;
            }
        }
    }
    return;
}