static void vga_draw_text(VGACommonState *s, int full_update)

{

    DisplaySurface *surface = qemu_console_surface(s->con);

    int cx, cy, cheight, cw, ch, cattr, height, width, ch_attr;

    int cx_min, cx_max, linesize, x_incr, line, line1;

    uint32_t offset, fgcol, bgcol, v, cursor_offset;

    uint8_t *d1, *d, *src, *dest, *cursor_ptr;

    const uint8_t *font_ptr, *font_base[2];

    int dup9, line_offset;

    uint32_t *palette;

    uint32_t *ch_attr_ptr;

    int64_t now = qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL);



    /* compute font data address (in plane 2) */

    v = s->sr[VGA_SEQ_CHARACTER_MAP];

    offset = (((v >> 4) & 1) | ((v << 1) & 6)) * 8192 * 4 + 2;

    if (offset != s->font_offsets[0]) {

        s->font_offsets[0] = offset;

        full_update = 1;

    }

    font_base[0] = s->vram_ptr + offset;



    offset = (((v >> 5) & 1) | ((v >> 1) & 6)) * 8192 * 4 + 2;

    font_base[1] = s->vram_ptr + offset;

    if (offset != s->font_offsets[1]) {

        s->font_offsets[1] = offset;

        full_update = 1;

    }

    if (s->plane_updated & (1 << 2) || s->has_chain4_alias) {

        /* if the plane 2 was modified since the last display, it

           indicates the font may have been modified */

        s->plane_updated = 0;

        full_update = 1;

    }

    full_update |= update_basic_params(s);



    line_offset = s->line_offset;



    vga_get_text_resolution(s, &width, &height, &cw, &cheight);

    if ((height * width) <= 1) {

        /* better than nothing: exit if transient size is too small */

        return;

    }

    if ((height * width) > CH_ATTR_SIZE) {

        /* better than nothing: exit if transient size is too big */

        return;

    }



    if (width != s->last_width || height != s->last_height ||

        cw != s->last_cw || cheight != s->last_ch || s->last_depth) {

        s->last_scr_width = width * cw;

        s->last_scr_height = height * cheight;

        qemu_console_resize(s->con, s->last_scr_width, s->last_scr_height);

        surface = qemu_console_surface(s->con);

        dpy_text_resize(s->con, width, height);

        s->last_depth = 0;

        s->last_width = width;

        s->last_height = height;

        s->last_ch = cheight;

        s->last_cw = cw;

        full_update = 1;

    }

    full_update |= update_palette16(s);

    palette = s->last_palette;

    x_incr = cw * surface_bytes_per_pixel(surface);



    if (full_update) {

        s->full_update_text = 1;

    }

    if (s->full_update_gfx) {

        s->full_update_gfx = 0;

        full_update |= 1;

    }



    cursor_offset = ((s->cr[VGA_CRTC_CURSOR_HI] << 8) |

                     s->cr[VGA_CRTC_CURSOR_LO]) - s->start_addr;

    if (cursor_offset != s->cursor_offset ||

        s->cr[VGA_CRTC_CURSOR_START] != s->cursor_start ||

        s->cr[VGA_CRTC_CURSOR_END] != s->cursor_end) {

      /* if the cursor position changed, we update the old and new

         chars */

        if (s->cursor_offset < CH_ATTR_SIZE)

            s->last_ch_attr[s->cursor_offset] = -1;

        if (cursor_offset < CH_ATTR_SIZE)

            s->last_ch_attr[cursor_offset] = -1;

        s->cursor_offset = cursor_offset;

        s->cursor_start = s->cr[VGA_CRTC_CURSOR_START];

        s->cursor_end = s->cr[VGA_CRTC_CURSOR_END];

    }

    cursor_ptr = s->vram_ptr + (s->start_addr + cursor_offset) * 4;

    if (now >= s->cursor_blink_time) {

        s->cursor_blink_time = now + VGA_TEXT_CURSOR_PERIOD_MS / 2;

        s->cursor_visible_phase = !s->cursor_visible_phase;

    }



    dest = surface_data(surface);

    linesize = surface_stride(surface);

    ch_attr_ptr = s->last_ch_attr;

    line = 0;

    offset = s->start_addr * 4;

    for(cy = 0; cy < height; cy++) {

        d1 = dest;

        src = s->vram_ptr + offset;

        cx_min = width;

        cx_max = -1;

        for(cx = 0; cx < width; cx++) {

            ch_attr = *(uint16_t *)src;

            if (full_update || ch_attr != *ch_attr_ptr || src == cursor_ptr) {

                if (cx < cx_min)

                    cx_min = cx;

                if (cx > cx_max)

                    cx_max = cx;

                *ch_attr_ptr = ch_attr;

#ifdef HOST_WORDS_BIGENDIAN

                ch = ch_attr >> 8;

                cattr = ch_attr & 0xff;

#else

                ch = ch_attr & 0xff;

                cattr = ch_attr >> 8;

#endif

                font_ptr = font_base[(cattr >> 3) & 1];

                font_ptr += 32 * 4 * ch;

                bgcol = palette[cattr >> 4];

                fgcol = palette[cattr & 0x0f];

                if (cw == 16) {

                    vga_draw_glyph16(d1, linesize,

                                     font_ptr, cheight, fgcol, bgcol);

                } else if (cw != 9) {

                    vga_draw_glyph8(d1, linesize,

                                    font_ptr, cheight, fgcol, bgcol);

                } else {

                    dup9 = 0;

                    if (ch >= 0xb0 && ch <= 0xdf &&

                        (s->ar[VGA_ATC_MODE] & 0x04)) {

                        dup9 = 1;

                    }

                    vga_draw_glyph9(d1, linesize,

                                    font_ptr, cheight, fgcol, bgcol, dup9);

                }

                if (src == cursor_ptr &&

                    !(s->cr[VGA_CRTC_CURSOR_START] & 0x20) &&

                    s->cursor_visible_phase) {

                    int line_start, line_last, h;

                    /* draw the cursor */

                    line_start = s->cr[VGA_CRTC_CURSOR_START] & 0x1f;

                    line_last = s->cr[VGA_CRTC_CURSOR_END] & 0x1f;

                    /* XXX: check that */

                    if (line_last > cheight - 1)

                        line_last = cheight - 1;

                    if (line_last >= line_start && line_start < cheight) {

                        h = line_last - line_start + 1;

                        d = d1 + linesize * line_start;

                        if (cw == 16) {

                            vga_draw_glyph16(d, linesize,

                                             cursor_glyph, h, fgcol, bgcol);

                        } else if (cw != 9) {

                            vga_draw_glyph8(d, linesize,

                                            cursor_glyph, h, fgcol, bgcol);

                        } else {

                            vga_draw_glyph9(d, linesize,

                                            cursor_glyph, h, fgcol, bgcol, 1);

                        }

                    }

                }

            }

            d1 += x_incr;

            src += 4;

            ch_attr_ptr++;

        }

        if (cx_max != -1) {

            dpy_gfx_update(s->con, cx_min * cw, cy * cheight,

                           (cx_max - cx_min + 1) * cw, cheight);

        }

        dest += linesize * cheight;

        line1 = line + cheight;

        offset += line_offset;

        if (line < s->line_compare && line1 >= s->line_compare) {

            offset = 0;

        }

        line = line1;

    }

}

static void vga_draw_text(VGACommonState *s, int full_update)

{

    DisplaySurface *surface = qemu_console_surface(s->con);

    int cx, cy, cheight, cw, ch, cattr, height, width, ch_attr;

    int cx_min, cx_max, linesize, x_incr, line, line1;

    uint32_t offset, fgcol, bgcol, v, cursor_offset;

    uint8_t *d1, *d, *src, *dest, *cursor_ptr;

    const uint8_t *font_ptr, *font_base[2];

    int dup9, line_offset;

    uint32_t *palette;

    uint32_t *ch_attr_ptr;

    int64_t now = qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL);



    

    v = s->sr[VGA_SEQ_CHARACTER_MAP];

    offset = (((v >> 4) & 1) | ((v << 1) & 6)) * 8192 * 4 + 2;

    if (offset != s->font_offsets[0]) {

        s->font_offsets[0] = offset;

        full_update = 1;

    }

    font_base[0] = s->vram_ptr + offset;



    offset = (((v >> 5) & 1) | ((v >> 1) & 6)) * 8192 * 4 + 2;

    font_base[1] = s->vram_ptr + offset;

    if (offset != s->font_offsets[1]) {

        s->font_offsets[1] = offset;

        full_update = 1;

    }

    if (s->plane_updated & (1 << 2) || s->has_chain4_alias) {

        



        s->plane_updated = 0;

        full_update = 1;

    }

    full_update |= update_basic_params(s);



    line_offset = s->line_offset;



    vga_get_text_resolution(s, &width, &height, &cw, &cheight);

    if ((height * width) <= 1) {

        

        return;

    }

    if ((height * width) > CH_ATTR_SIZE) {

        

        return;

    }



    if (width != s->last_width || height != s->last_height ||

        cw != s->last_cw || cheight != s->last_ch || s->last_depth) {

        s->last_scr_width = width * cw;

        s->last_scr_height = height * cheight;

        qemu_console_resize(s->con, s->last_scr_width, s->last_scr_height);

        surface = qemu_console_surface(s->con);

        dpy_text_resize(s->con, width, height);

        s->last_depth = 0;

        s->last_width = width;

        s->last_height = height;

        s->last_ch = cheight;

        s->last_cw = cw;

        full_update = 1;

    }

    full_update |= update_palette16(s);

    palette = s->last_palette;

    x_incr = cw * surface_bytes_per_pixel(surface);



    if (full_update) {

        s->full_update_text = 1;

    }

    if (s->full_update_gfx) {

        s->full_update_gfx = 0;

        full_update |= 1;

    }



    cursor_offset = ((s->cr[VGA_CRTC_CURSOR_HI] << 8) |

                     s->cr[VGA_CRTC_CURSOR_LO]) - s->start_addr;

    if (cursor_offset != s->cursor_offset ||

        s->cr[VGA_CRTC_CURSOR_START] != s->cursor_start ||

        s->cr[VGA_CRTC_CURSOR_END] != s->cursor_end) {

      



        if (s->cursor_offset < CH_ATTR_SIZE)

            s->last_ch_attr[s->cursor_offset] = -1;

        if (cursor_offset < CH_ATTR_SIZE)

            s->last_ch_attr[cursor_offset] = -1;

        s->cursor_offset = cursor_offset;

        s->cursor_start = s->cr[VGA_CRTC_CURSOR_START];

        s->cursor_end = s->cr[VGA_CRTC_CURSOR_END];

    }

    cursor_ptr = s->vram_ptr + (s->start_addr + cursor_offset) * 4;

    if (now >= s->cursor_blink_time) {

        s->cursor_blink_time = now + VGA_TEXT_CURSOR_PERIOD_MS / 2;

        s->cursor_visible_phase = !s->cursor_visible_phase;

    }



    dest = surface_data(surface);

    linesize = surface_stride(surface);

    ch_attr_ptr = s->last_ch_attr;

    line = 0;

    offset = s->start_addr * 4;

    for(cy = 0; cy < height; cy++) {

        d1 = dest;

        src = s->vram_ptr + offset;

        cx_min = width;

        cx_max = -1;

        for(cx = 0; cx < width; cx++) {

            ch_attr = *(uint16_t *)src;

            if (full_update || ch_attr != *ch_attr_ptr || src == cursor_ptr) {

                if (cx < cx_min)

                    cx_min = cx;

                if (cx > cx_max)

                    cx_max = cx;

                *ch_attr_ptr = ch_attr;

#ifdef HOST_WORDS_BIGENDIAN

                ch = ch_attr >> 8;

                cattr = ch_attr & 0xff;

#else

                ch = ch_attr & 0xff;

                cattr = ch_attr >> 8;

#endif

                font_ptr = font_base[(cattr >> 3) & 1];

                font_ptr += 32 * 4 * ch;

                bgcol = palette[cattr >> 4];

                fgcol = palette[cattr & 0x0f];

                if (cw == 16) {

                    vga_draw_glyph16(d1, linesize,

                                     font_ptr, cheight, fgcol, bgcol);

                } else if (cw != 9) {

                    vga_draw_glyph8(d1, linesize,

                                    font_ptr, cheight, fgcol, bgcol);

                } else {

                    dup9 = 0;

                    if (ch >= 0xb0 && ch <= 0xdf &&

                        (s->ar[VGA_ATC_MODE] & 0x04)) {

                        dup9 = 1;

                    }

                    vga_draw_glyph9(d1, linesize,

                                    font_ptr, cheight, fgcol, bgcol, dup9);

                }

                if (src == cursor_ptr &&

                    !(s->cr[VGA_CRTC_CURSOR_START] & 0x20) &&

                    s->cursor_visible_phase) {

                    int line_start, line_last, h;

                    

                    line_start = s->cr[VGA_CRTC_CURSOR_START] & 0x1f;

                    line_last = s->cr[VGA_CRTC_CURSOR_END] & 0x1f;

                    

                    if (line_last > cheight - 1)

                        line_last = cheight - 1;

                    if (line_last >= line_start && line_start < cheight) {

                        h = line_last - line_start + 1;

                        d = d1 + linesize * line_start;

                        if (cw == 16) {

                            vga_draw_glyph16(d, linesize,

                                             cursor_glyph, h, fgcol, bgcol);

                        } else if (cw != 9) {

                            vga_draw_glyph8(d, linesize,

                                            cursor_glyph, h, fgcol, bgcol);

                        } else {

                            vga_draw_glyph9(d, linesize,

                                            cursor_glyph, h, fgcol, bgcol, 1);

                        }

                    }

                }

            }

            d1 += x_incr;

            src += 4;

            ch_attr_ptr++;

        }

        if (cx_max != -1) {

            dpy_gfx_update(s->con, cx_min * cw, cy * cheight,

                           (cx_max - cx_min + 1) * cw, cheight);

        }

        dest += linesize * cheight;

        line1 = line + cheight;

        offset += line_offset;

        if (line < s->line_compare && line1 >= s->line_compare) {

            offset = 0;

        }

        line = line1;

    }

}

    v = s->sr[VGA_SEQ_CHARACTER_MAP];
static void FUNC_0(VGACommonState *VAR_0, int VAR_1)

{

    DisplaySurface *surface = qemu_console_surface(VAR_0->con);

    int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;

    int VAR_11, VAR_12, VAR_13, VAR_14, VAR_15, VAR_16;

    uint32_t offset, fgcol, bgcol, v, cursor_offset;

    uint8_t *d1, *d, *src, *dest, *cursor_ptr;

    const uint8_t *VAR_17, *font_base[2];

    int VAR_18, VAR_19;

    uint32_t *palette;

    uint32_t *ch_attr_ptr;

    int64_t now = qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL);



    

    v = VAR_0->sr[VGA_SEQ_CHARACTER_MAP];

    offset = (((v >> 4) & 1) | ((v << 1) & 6)) * 8192 * 4 + 2;

    if (offset != VAR_0->font_offsets[0]) {

        VAR_0->font_offsets[0] = offset;

        VAR_1 = 1;

    }

    font_base[0] = VAR_0->vram_ptr + offset;



    offset = (((v >> 5) & 1) | ((v >> 1) & 6)) * 8192 * 4 + 2;

    font_base[1] = VAR_0->vram_ptr + offset;

    if (offset != VAR_0->font_offsets[1]) {

        VAR_0->font_offsets[1] = offset;

        VAR_1 = 1;

    }

    if (VAR_0->plane_updated & (1 << 2) || VAR_0->has_chain4_alias) {

        



        VAR_0->plane_updated = 0;

        VAR_1 = 1;

    }

    VAR_1 |= update_basic_params(VAR_0);



    VAR_19 = VAR_0->VAR_19;



    vga_get_text_resolution(VAR_0, &VAR_9, &VAR_8, &VAR_5, &VAR_4);

    if ((VAR_8 * VAR_9) <= 1) {

        

        return;

    }

    if ((VAR_8 * VAR_9) > CH_ATTR_SIZE) {

        

        return;

    }



    if (VAR_9 != VAR_0->last_width || VAR_8 != VAR_0->last_height ||

        VAR_5 != VAR_0->last_cw || VAR_4 != VAR_0->last_ch || VAR_0->last_depth) {

        VAR_0->last_scr_width = VAR_9 * VAR_5;

        VAR_0->last_scr_height = VAR_8 * VAR_4;

        qemu_console_resize(VAR_0->con, VAR_0->last_scr_width, VAR_0->last_scr_height);

        surface = qemu_console_surface(VAR_0->con);

        dpy_text_resize(VAR_0->con, VAR_9, VAR_8);

        VAR_0->last_depth = 0;

        VAR_0->last_width = VAR_9;

        VAR_0->last_height = VAR_8;

        VAR_0->last_ch = VAR_4;

        VAR_0->last_cw = VAR_5;

        VAR_1 = 1;

    }

    VAR_1 |= update_palette16(VAR_0);

    palette = VAR_0->last_palette;

    VAR_14 = VAR_5 * surface_bytes_per_pixel(surface);



    if (VAR_1) {

        VAR_0->full_update_text = 1;

    }

    if (VAR_0->full_update_gfx) {

        VAR_0->full_update_gfx = 0;

        VAR_1 |= 1;

    }



    cursor_offset = ((VAR_0->cr[VGA_CRTC_CURSOR_HI] << 8) |

                     VAR_0->cr[VGA_CRTC_CURSOR_LO]) - VAR_0->start_addr;

    if (cursor_offset != VAR_0->cursor_offset ||

        VAR_0->cr[VGA_CRTC_CURSOR_START] != VAR_0->cursor_start ||

        VAR_0->cr[VGA_CRTC_CURSOR_END] != VAR_0->cursor_end) {

      



        if (VAR_0->cursor_offset < CH_ATTR_SIZE)

            VAR_0->last_ch_attr[VAR_0->cursor_offset] = -1;

        if (cursor_offset < CH_ATTR_SIZE)

            VAR_0->last_ch_attr[cursor_offset] = -1;

        VAR_0->cursor_offset = cursor_offset;

        VAR_0->cursor_start = VAR_0->cr[VGA_CRTC_CURSOR_START];

        VAR_0->cursor_end = VAR_0->cr[VGA_CRTC_CURSOR_END];

    }

    cursor_ptr = VAR_0->vram_ptr + (VAR_0->start_addr + cursor_offset) * 4;

    if (now >= VAR_0->cursor_blink_time) {

        VAR_0->cursor_blink_time = now + VGA_TEXT_CURSOR_PERIOD_MS / 2;

        VAR_0->cursor_visible_phase = !VAR_0->cursor_visible_phase;

    }



    dest = surface_data(surface);

    VAR_13 = surface_stride(surface);

    ch_attr_ptr = VAR_0->last_ch_attr;

    VAR_15 = 0;

    offset = VAR_0->start_addr * 4;

    for(VAR_3 = 0; VAR_3 < VAR_8; VAR_3++) {

        d1 = dest;

        src = VAR_0->vram_ptr + offset;

        VAR_11 = VAR_9;

        VAR_12 = -1;

        for(VAR_2 = 0; VAR_2 < VAR_9; VAR_2++) {

            VAR_10 = *(uint16_t *)src;

            if (VAR_1 || VAR_10 != *ch_attr_ptr || src == cursor_ptr) {

                if (VAR_2 < VAR_11)

                    VAR_11 = VAR_2;

                if (VAR_2 > VAR_12)

                    VAR_12 = VAR_2;

                *ch_attr_ptr = VAR_10;

#ifdef HOST_WORDS_BIGENDIAN

                VAR_6 = VAR_10 >> 8;

                VAR_7 = VAR_10 & 0xff;

#else

                VAR_6 = VAR_10 & 0xff;

                VAR_7 = VAR_10 >> 8;

#endif

                VAR_17 = font_base[(VAR_7 >> 3) & 1];

                VAR_17 += 32 * 4 * VAR_6;

                bgcol = palette[VAR_7 >> 4];

                fgcol = palette[VAR_7 & 0x0f];

                if (VAR_5 == 16) {

                    vga_draw_glyph16(d1, VAR_13,

                                     VAR_17, VAR_4, fgcol, bgcol);

                } else if (VAR_5 != 9) {

                    vga_draw_glyph8(d1, VAR_13,

                                    VAR_17, VAR_4, fgcol, bgcol);

                } else {

                    VAR_18 = 0;

                    if (VAR_6 >= 0xb0 && VAR_6 <= 0xdf &&

                        (VAR_0->ar[VGA_ATC_MODE] & 0x04)) {

                        VAR_18 = 1;

                    }

                    vga_draw_glyph9(d1, VAR_13,

                                    VAR_17, VAR_4, fgcol, bgcol, VAR_18);

                }

                if (src == cursor_ptr &&

                    !(VAR_0->cr[VGA_CRTC_CURSOR_START] & 0x20) &&

                    VAR_0->cursor_visible_phase) {

                    int VAR_20, VAR_21, VAR_22;

                    

                    VAR_20 = VAR_0->cr[VGA_CRTC_CURSOR_START] & 0x1f;

                    VAR_21 = VAR_0->cr[VGA_CRTC_CURSOR_END] & 0x1f;

                    

                    if (VAR_21 > VAR_4 - 1)

                        VAR_21 = VAR_4 - 1;

                    if (VAR_21 >= VAR_20 && VAR_20 < VAR_4) {

                        VAR_22 = VAR_21 - VAR_20 + 1;

                        d = d1 + VAR_13 * VAR_20;

                        if (VAR_5 == 16) {

                            vga_draw_glyph16(d, VAR_13,

                                             cursor_glyph, VAR_22, fgcol, bgcol);

                        } else if (VAR_5 != 9) {

                            vga_draw_glyph8(d, VAR_13,

                                            cursor_glyph, VAR_22, fgcol, bgcol);

                        } else {

                            vga_draw_glyph9(d, VAR_13,

                                            cursor_glyph, VAR_22, fgcol, bgcol, 1);

                        }

                    }

                }

            }

            d1 += VAR_14;

            src += 4;

            ch_attr_ptr++;

        }

        if (VAR_12 != -1) {

            dpy_gfx_update(VAR_0->con, VAR_11 * VAR_5, VAR_3 * VAR_4,

                           (VAR_12 - VAR_11 + 1) * VAR_5, VAR_4);

        }

        dest += VAR_13 * VAR_4;

        VAR_16 = VAR_15 + VAR_4;

        offset += VAR_19;

        if (VAR_15 < VAR_0->line_compare && VAR_16 >= VAR_0->line_compare) {

            offset = 0;

        }

        VAR_15 = VAR_16;

    }

}

static void FUNC_0(VGACommonState *VAR_0, int VAR_1)
{ DisplaySurface *surface = qemu_console_surface(VAR_0->con); int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10; int VAR_11, VAR_12, VAR_13, VAR_14, VAR_15, VAR_16; uint32_t offset, fgcol, bgcol, v, cursor_offset; uint8_t *d1, *d, *src, *dest, *cursor_ptr; const uint8_t *VAR_17, *font_base[2]; int VAR_18, VAR_19; uint32_t *palette; uint32_t *ch_attr_ptr; int64_t now = qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL); v = VAR_0->sr[VGA_SEQ_CHARACTER_MAP]; offset = (((v >> 4) & 1) | ((v << 1) & 6)) * 8192 * 4 + 2; if (offset != VAR_0->font_offsets[0]) { VAR_0->font_offsets[0] = offset; VAR_1 = 1; } font_base[0] = VAR_0->vram_ptr + offset; offset = (((v >> 5) & 1) | ((v >> 1) & 6)) * 8192 * 4 + 2; font_base[1] = VAR_0->vram_ptr + offset; if (offset != VAR_0->font_offsets[1]) { VAR_0->font_offsets[1] = offset; VAR_1 = 1; } if (VAR_0->plane_updated & (1 << 2) || VAR_0->has_chain4_alias) { VAR_0->plane_updated = 0; VAR_1 = 1; } VAR_1 |= update_basic_params(VAR_0); VAR_19 = VAR_0->VAR_19; vga_get_text_resolution(VAR_0, &VAR_9, &VAR_8, &VAR_5, &VAR_4); if ((VAR_8 * VAR_9) <= 1) { return; } if ((VAR_8 * VAR_9) > CH_ATTR_SIZE) { return; } if (VAR_9 != VAR_0->last_width || VAR_8 != VAR_0->last_height ||
VAR_5 != VAR_0->last_cw || VAR_4 != VAR_0->last_ch || VAR_0->last_depth) { VAR_0->last_scr_width = VAR_9 * VAR_5; VAR_0->last_scr_height = VAR_8 * VAR_4; qemu_console_resize(VAR_0->con, VAR_0->last_scr_width, VAR_0->last_scr_height); surface = qemu_console_surface(VAR_0->con); dpy_text_resize(VAR_0->con, VAR_9, VAR_8); VAR_0->last_depth = 0; VAR_0->last_width = VAR_9; VAR_0->last_height = VAR_8; VAR_0->last_ch = VAR_4; VAR_0->last_cw = VAR_5; VAR_1 = 1; } VAR_1 |= update_palette16(VAR_0); palette = VAR_0->last_palette; VAR_14 = VAR_5 * surface_bytes_per_pixel(surface); if (VAR_1) { VAR_0->full_update_text = 1; } if (VAR_0->full_update_gfx) { VAR_0->full_update_gfx = 0; VAR_1 |= 1; } cursor_offset = ((VAR_0->cr[VGA_CRTC_CURSOR_HI] << 8) |
VAR_0->cr[VGA_CRTC_CURSOR_LO]) - VAR_0->start_addr; if (cursor_offset != VAR_0->cursor_offset ||
VAR_0->cr[VGA_CRTC_CURSOR_START] != VAR_0->cursor_start ||
VAR_0->cr[VGA_CRTC_CURSOR_END] != VAR_0->cursor_end) { if (VAR_0->cursor_offset < CH_ATTR_SIZE)
VAR_0->last_ch_attr[VAR_0->cursor_offset] = -1; if (cursor_offset < CH_ATTR_SIZE)
VAR_0->last_ch_attr[cursor_offset] = -1; VAR_0->cursor_offset = cursor_offset; VAR_0->cursor_start = VAR_0->cr[VGA_CRTC_CURSOR_START]; VAR_0->cursor_end = VAR_0->cr[VGA_CRTC_CURSOR_END]; } cursor_ptr = VAR_0->vram_ptr + (VAR_0->start_addr + cursor_offset) * 4; if (now >= VAR_0->cursor_blink_time) { VAR_0->cursor_blink_time = now + VGA_TEXT_CURSOR_PERIOD_MS / 2; VAR_0->cursor_visible_phase = !VAR_0->cursor_visible_phase; } dest = surface_data(surface); VAR_13 = surface_stride(surface); ch_attr_ptr = VAR_0->last_ch_attr; VAR_15 = 0; offset = VAR_0->start_addr * 4; for(VAR_3 = 0; VAR_3 < VAR_8; VAR_3++) { d1 = dest; src = VAR_0->vram_ptr + offset; VAR_11 = VAR_9; VAR_12 = -1; for(VAR_2 = 0; VAR_2 < VAR_9; VAR_2++) { VAR_10 = *(uint16_t *)src; if (VAR_1 || VAR_10 != *ch_attr_ptr || src == cursor_ptr) { if (VAR_2 < VAR_11)
VAR_11 = VAR_2; if (VAR_2 > VAR_12)
VAR_12 = VAR_2; *ch_attr_ptr = VAR_10; #ifdef HOST_WORDS_BIGENDIAN
VAR_6 = VAR_10 >> 8; VAR_7 = VAR_10 & 0xff; #else
VAR_6 = VAR_10 & 0xff; VAR_7 = VAR_10 >> 8; #endif
VAR_17 = font_base[(VAR_7 >> 3) & 1]; VAR_17 += 32 * 4 * VAR_6; bgcol = palette[VAR_7 >> 4]; fgcol = palette[VAR_7 & 0x0f]; if (VAR_5 == 16) { vga_draw_glyph16(d1, VAR_13,
VAR_17, VAR_4, fgcol, bgcol); } else if (VAR_5 != 9) { vga_draw_glyph8(d1, VAR_13,
VAR_17, VAR_4, fgcol, bgcol); } else { VAR_18 = 0; if (VAR_6 >= 0xb0 && VAR_6 <= 0xdf &&
(VAR_0->ar[VGA_ATC_MODE] & 0x04)) { VAR_18 = 1; } vga_draw_glyph9(d1, VAR_13,
VAR_17, VAR_4, fgcol, bgcol, VAR_18); } if (src == cursor_ptr &&
!(VAR_0->cr[VGA_CRTC_CURSOR_START] & 0x20) &&
VAR_0->cursor_visible_phase) { int VAR_20, VAR_21, VAR_22; VAR_20 = VAR_0->cr[VGA_CRTC_CURSOR_START] & 0x1f; VAR_21 = VAR_0->cr[VGA_CRTC_CURSOR_END] & 0x1f; if (VAR_21 > VAR_4 - 1)
VAR_21 = VAR_4 - 1; if (VAR_21 >= VAR_20 && VAR_20 < VAR_4) { VAR_22 = VAR_21 - VAR_20 + 1; d = d1 + VAR_13 * VAR_20; if (VAR_5 == 16) { vga_draw_glyph16(d, VAR_13,
cursor_glyph, VAR_22, fgcol, bgcol); } else if (VAR_5 != 9) { vga_draw_glyph8(d, VAR_13,
cursor_glyph, VAR_22, fgcol, bgcol); } else { vga_draw_glyph9(d, VAR_13,
cursor_glyph, VAR_22, fgcol, bgcol, 1); } } } } d1 += VAR_14; src += 4; ch_attr_ptr++; } if (VAR_12 != -1) { dpy_gfx_update(VAR_0->con, VAR_11 * VAR_5, VAR_3 * VAR_4,
(VAR_12 - VAR_11 + 1) * VAR_5, VAR_4); } dest += VAR_13 * VAR_4; VAR_16 = VAR_15 + VAR_4; offset += VAR_19; if (VAR_15 < VAR_0->line_compare && VAR_16 >= VAR_0->line_compare) { offset = 0; } VAR_15 = VAR_16; } }