⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sma_swim_font.c

📁 sharp的arm920t 7A400的评估板附带光盘Sharp KEVLH7A400 v0.3b Welcome to the SHARP KEV7A400 Evaluation board
💻 C
📖 第 1 页 / 共 2 页
字号:
 * Returns:
 *  Nothing
 *
 * Notes:
 *  None
 *
 **********************************************************************/
void swim_put_ltext (INT_32 win, const CHAR *text)
{
    INT_32 i = 0;

    // Continue until the entire string is output
    while (text [i] != '\0')
    {
        if (text [i] == '\n')
        {
            swim_put_newline (win);
            i++;
        }
        else if (((UNS_8) text [i] >= window [win].font->first_char)
            && ((UNS_8) text [i] <= window [win].font->last_char))
        {
            // Check for entire words first
            if (((UNS_8) text [i] > ' ') && ((UNS_8) text [i] <= 0x7E))
            {
                // Put entire word on screen
                i = i + swim_put_word (win, &text [i]);
            }
            else
            {
                swim_put_char (win, text [i]);
                i++;
            }
        }
        else
        {
            // Put a space out
            swim_put_char (win, ' ');
            i++;
        }
    }
}

/***********************************************************************
 *
 * Function: swim_window_scroll
 *
 * Purpose:
 *  Scrolls the window up one line
 *
 * Processing:
 *  From the vertical font size and lower window limit, determine the
 *  move indices for the move operation. Move all lines up by the
 *  numbers of pixel in the present font height until the top of the
 *  window has been reached.
 *
 * Parameters: 
 *  win   : Window identifier
 *  lines : Number of lines to scroll up
 *
 * Outputs:
 *  None
 *
 * Returns:
 *  Nothing
 *
 * Notes:
 *  This function is private to this module.
 *
 **********************************************************************/
void swim_window_scroll (INT_32 win, INT_32 lines)
{
    color_type *fb1, *fb2;
    INT_32 yref1 = window [win].ypvmin;
    INT_32 yref2 = yref1 + lines;
    INT_32 ref;

    // Copy until 
    while (yref2 <= window [win].ypvmax)
    {
        // Line move addresses
        fb1 = window [win].fb + window [win].xpvmin +
            (yref1 * window [win].xpsize);
        fb2 = window [win].fb + window [win].xpvmin +
            (yref2 * window [win].xpsize);

        // Move a single line at a time
        ref = window [win].xpvmax - window [win].xpvmin + 1;
        while (ref > 0)
        {
            *fb1++ = *fb2++;
            ref--;
        }

        // Next lines
        yref1++;
        yref2++;
    }

    // Clear out bottom lines
    yref1 = window [win].yvpos;
    while (yref1 <= window [win].ypvmax)
    {
        // Line clear address
        fb1 = window [win].fb + window [win].xpvmin +
            (yref1 * window [win].xpsize);

        // Clear a single line at a time
        ref = window [win].xpvmax - window [win].xpvmin + 1;
        while (ref > 0)
        {
            *fb1++ = window [win].bkg;
            ref--;
        }

        yref1++;
    }
}

/***********************************************************************
 *
 * Function: swim_put_char
 *
 * Purpose:
 *  Puts a character in the window.
 *
 * Processing:
 *  See function.
 *
 * Parameters: 
 *  win      : Window identifier
 *  textchar : Text string to output in window
 *
 * Outputs:
 *  None
 *
 * Returns:
 *  Nothing
 *
 * Notes:
 *  None
 *
 **********************************************************************/
void swim_put_char (INT_32 win, const CHAR textchar)
{
    INT_32 i, j;
    INT_32 charindex;
    UNS_16 *charfields, chardata;
    color_type *fb;

    // If this is a carriage return, do a newline
    if (textchar == '\n')
    {
        swim_put_newline (win);
    }
    else
    {
        // Determine index to character data
        charindex = (INT_32) textchar -
            (INT_32) window [win].font->first_char;

        // Will the character fit on the display?
        if ((window [win].xvpos +
            (INT_32) window [win].font->font_width_table [charindex]) >
            window [win].xpvmax)
        {
            // Will not fit, do a newline
            swim_put_newline (win);
        }

        // Determine the start of the bitfields for the character
        charfields = window [win].font->font_table + (charindex *
            window [win].font->font_height);

        // Map character to the window
        for (i = 0;
            i < (INT_32) window [win].font->font_height; i++)
        {
            // Get starting pixel location for font mapping in window
            fb = window [win].fb + window [win].xvpos +
                ((window [win].yvpos + i) * window [win].xpsize);

            // Get character line mapping data
            chardata = charfields [i];

            // Convert character line bit data to a pixel line in window
            for (j =
                (INT_32) window [win].font->font_width_table [charindex];
                j > 0; j--)
            {
                if ((chardata & 0x8000) != 0)
                {
                    *fb++ = window [win].pen;
                }
                else
                {
                    *fb++ = window [win].bkg;
                }

                // Next bit in character line
                chardata = chardata << 1;
            }
        }

        // Increment to next text location
        window [win].xvpos = window [win].xvpos +
            (INT_32) window [win].font->font_width_table [charindex];
    }
}

/***********************************************************************
 *
 * Function: swim_put_newline
 *
 * Purpose:
 *  Performs a newline in a window.
 *
 * Processing:
 *  Set the text pointer for the next text character operation to
 *  the beginning of the following line. If the following line exceeds
 *  the window size, perform a line scroll.
 *
 * Parameters: 
 *  win : Window identifier
 *
 * Outputs:
 *  None
 *
 * Returns:
 *  Nothing
 *
 * Notes:
 *  None
 *
 **********************************************************************/
void swim_put_newline (INT_32 win)
{
    INT_32 diff;

    // Set text pointer to start of next line
    window [win].xvpos = window [win].xpvmin;
    window [win].yvpos = window [win].yvpos +
        (INT_32) window [win].font->font_height;

    // Next character is below bottom of window, scroll the window up
    while ((window [win].yvpos +
        (INT_32) window [win].font->font_height) > window [win].ypvmax)
    {
        // Scroll just enough for the next line
        diff = (INT_32) window [win].font->font_height -
            (window [win].ypvmax - window [win].yvpos);
        window [win].yvpos = window [win].yvpos - diff;
        swim_window_scroll (win, diff);
    }
}

/***********************************************************************
 *
 * Function: swim_set_font
 *
 * Purpose:
 *  Sets the active font.
 *
 * Processing:
 *  Switch to the selected font by setting the font structure pointer
 *  in the windows structure based on the passed enumeration. If the
 *  next character output in the new font will exceed the window limit,
 *  perform a window text scroll.
 *
 * Parameters: 
 *  win  : Window identifier
 *  font : New font enumerator
 *
 * Outputs:
 *  None
 *
 * Returns:
 *  Nothing
 *
 * Notes:
 *  None
 *
 **********************************************************************/
void swim_set_font (INT_32 win, font_sel_type font)
{
    INT_32 diff;

    window [win].font = (font_type *) fonts [font];

    // After changing to the new font, determine if there is enough
    // room for the font height on the existing line in the window.
    if ((window [win].yvpos + window [win].font->font_height) >
        window [win].ypvmax)
    {
        diff = (INT_32) window [win].font->font_height -
            (window [win].ypvmax - window [win].yvpos);
        window [win].yvpos = window [win].yvpos - diff;
        swim_window_scroll (win, diff);
    }
}

/***********************************************************************
 *
 * Function: swim_get_font_height
 *
 * Purpose:
 *  Returns the active font's height in pixels.
 *
 * Processing:
 *  See function.
 *
 * Parameters: 
 *  win  : Window identifier
 *
 * Outputs:
 *  None
 *
 * Returns:
 *  The height of the active font in pixels.
 *
 * Notes:
 *  None
 *
 **********************************************************************/
INT_16 swim_get_font_height (INT_32 win)
{
    return window [win].font->font_height;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -