static void vga_draw_graphic(VGAState *s, int full_update)

{

    int y1, y, update, page_min, page_max, linesize, y_start, double_scan, mask, depth;

    int width, height, shift_control, line_offset, page0, page1, bwidth, bits;

    int disp_width, multi_scan, multi_run;

    uint8_t *d;

    uint32_t v, addr1, addr;

    vga_draw_line_func *vga_draw_line;



    full_update |= update_basic_params(s);



    if (!full_update)

        vga_sync_dirty_bitmap(s);



    s->get_resolution(s, &width, &height);

    disp_width = width;



    shift_control = (s->gr[0x05] >> 5) & 3;

    double_scan = (s->cr[0x09] >> 7);

    if (shift_control != 1) {

        multi_scan = (((s->cr[0x09] & 0x1f) + 1) << double_scan) - 1;

    } else {

        /* in CGA modes, multi_scan is ignored */

        /* XXX: is it correct ? */

        multi_scan = double_scan;

    }

    multi_run = multi_scan;

    if (shift_control != s->shift_control ||

        double_scan != s->double_scan) {

        full_update = 1;

        s->shift_control = shift_control;

        s->double_scan = double_scan;

    }



    depth = s->get_bpp(s);

    if (s->line_offset != s->last_line_offset ||

        disp_width != s->last_width ||

        height != s->last_height ||

        s->last_depth != depth) {

#if defined(WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN)

        if (depth == 16 || depth == 32) {

#else

        if (depth == 32) {

#endif

            if (is_graphic_console()) {

                qemu_free_displaysurface(s->ds);

                s->ds->surface = qemu_create_displaysurface_from(disp_width, height, depth,

                                                               s->line_offset,

                                                               s->vram_ptr + (s->start_addr * 4));

#if defined(WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN)

                s->ds->surface->pf = qemu_different_endianness_pixelformat(depth);

#endif

                dpy_resize(s->ds);

            } else {

                qemu_console_resize(s->ds, disp_width, height);

            }

        } else {

            qemu_console_resize(s->ds, disp_width, height);

        }

        s->last_scr_width = disp_width;

        s->last_scr_height = height;

        s->last_width = disp_width;

        s->last_height = height;

        s->last_line_offset = s->line_offset;

        s->last_depth = depth;

        full_update = 1;

    } else if (is_graphic_console() && is_buffer_shared(s->ds->surface) &&

               (full_update || s->ds->surface->data != s->vram_ptr + (s->start_addr * 4))) {

        s->ds->surface->data = s->vram_ptr + (s->start_addr * 4);

        dpy_setdata(s->ds);

    }



    s->rgb_to_pixel =

        rgb_to_pixel_dup_table[get_depth_index(s->ds)];



    if (shift_control == 0) {

        full_update |= update_palette16(s);

        if (s->sr[0x01] & 8) {

            v = VGA_DRAW_LINE4D2;

            disp_width <<= 1;

        } else {

            v = VGA_DRAW_LINE4;

        }

        bits = 4;

    } else if (shift_control == 1) {

        full_update |= update_palette16(s);

        if (s->sr[0x01] & 8) {

            v = VGA_DRAW_LINE2D2;

            disp_width <<= 1;

        } else {

            v = VGA_DRAW_LINE2;

        }

        bits = 4;

    } else {

        switch(s->get_bpp(s)) {

        default:

        case 0:

            full_update |= update_palette256(s);

            v = VGA_DRAW_LINE8D2;

            bits = 4;

            break;

        case 8:

            full_update |= update_palette256(s);

            v = VGA_DRAW_LINE8;

            bits = 8;

            break;

        case 15:

            v = VGA_DRAW_LINE15;

            bits = 16;

            break;

        case 16:

            v = VGA_DRAW_LINE16;

            bits = 16;

            break;

        case 24:

            v = VGA_DRAW_LINE24;

            bits = 24;

            break;

        case 32:

            v = VGA_DRAW_LINE32;

            bits = 32;

            break;

        }

    }

    vga_draw_line = vga_draw_line_table[v * NB_DEPTHS + get_depth_index(s->ds)];



    if (!is_buffer_shared(s->ds->surface) && s->cursor_invalidate)

        s->cursor_invalidate(s);



    line_offset = s->line_offset;

#if 0

    printf("w=%d h=%d v=%d line_offset=%d cr[0x09]=0x%02x cr[0x17]=0x%02x linecmp=%d sr[0x01]=0x%02x\n",

           width, height, v, line_offset, s->cr[9], s->cr[0x17], s->line_compare, s->sr[0x01]);

#endif

    addr1 = (s->start_addr * 4);

    bwidth = (width * bits + 7) / 8;

    y_start = -1;

    page_min = 0x7fffffff;

    page_max = -1;

    d = ds_get_data(s->ds);

    linesize = ds_get_linesize(s->ds);

    y1 = 0;

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

        addr = addr1;

        if (!(s->cr[0x17] & 1)) {

            int shift;

            /* CGA compatibility handling */

            shift = 14 + ((s->cr[0x17] >> 6) & 1);

            addr = (addr & ~(1 << shift)) | ((y1 & 1) << shift);

        }

        if (!(s->cr[0x17] & 2)) {

            addr = (addr & ~0x8000) | ((y1 & 2) << 14);

        }

        page0 = s->vram_offset + (addr & TARGET_PAGE_MASK);

        page1 = s->vram_offset + ((addr + bwidth - 1) & TARGET_PAGE_MASK);

        update = full_update |

            cpu_physical_memory_get_dirty(page0, VGA_DIRTY_FLAG) |

            cpu_physical_memory_get_dirty(page1, VGA_DIRTY_FLAG);

        if ((page1 - page0) > TARGET_PAGE_SIZE) {

            /* if wide line, can use another page */

            update |= cpu_physical_memory_get_dirty(page0 + TARGET_PAGE_SIZE,

                                                    VGA_DIRTY_FLAG);

        }

        /* explicit invalidation for the hardware cursor */

        update |= (s->invalidated_y_table[y >> 5] >> (y & 0x1f)) & 1;

        if (update) {

            if (y_start < 0)

                y_start = y;

            if (page0 < page_min)

                page_min = page0;

            if (page1 > page_max)

                page_max = page1;

            if (!(is_buffer_shared(s->ds->surface))) {

                vga_draw_line(s, d, s->vram_ptr + addr, width);

                if (s->cursor_draw_line)

                    s->cursor_draw_line(s, d, y);

            }

        } else {

            if (y_start >= 0) {

                /* flush to display */

                dpy_update(s->ds, 0, y_start,

                           disp_width, y - y_start);

                y_start = -1;

            }

        }

        if (!multi_run) {

            mask = (s->cr[0x17] & 3) ^ 3;

            if ((y1 & mask) == mask)

                addr1 += line_offset;

            y1++;

            multi_run = multi_scan;

        } else {

            multi_run--;

        }

        /* line compare acts on the displayed lines */

        if (y == s->line_compare)

            addr1 = 0;

        d += linesize;

    }

    if (y_start >= 0) {

        /* flush to display */

        dpy_update(s->ds, 0, y_start,

                   disp_width, y - y_start);

    }

    /* reset modified pages */

    if (page_max != -1) {

        cpu_physical_memory_reset_dirty(page_min, page_max + TARGET_PAGE_SIZE,

                                        VGA_DIRTY_FLAG);

    }

    memset(s->invalidated_y_table, 0, ((height + 31) >> 5) * 4);

}

static void vga_draw_graphic(VGAState *s, int full_update)

{

    int y1, y, update, page_min, page_max, linesize, y_start, double_scan, mask, depth;

    int width, height, shift_control, line_offset, page0, page1, bwidth, bits;

    int disp_width, multi_scan, multi_run;

    uint8_t *d;

    uint32_t v, addr1, addr;

    vga_draw_line_func *vga_draw_line;



    full_update |= update_basic_params(s);



    if (!full_update)

        vga_sync_dirty_bitmap(s);



    s->get_resolution(s, &width, &height);

    disp_width = width;



    shift_control = (s->gr[0x05] >> 5) & 3;

    double_scan = (s->cr[0x09] >> 7);

    if (shift_control != 1) {

        multi_scan = (((s->cr[0x09] & 0x1f) + 1) << double_scan) - 1;

    } else {

        

        

        multi_scan = double_scan;

    }

    multi_run = multi_scan;

    if (shift_control != s->shift_control ||

        double_scan != s->double_scan) {

        full_update = 1;

        s->shift_control = shift_control;

        s->double_scan = double_scan;

    }



    depth = s->get_bpp(s);

    if (s->line_offset != s->last_line_offset ||

        disp_width != s->last_width ||

        height != s->last_height ||

        s->last_depth != depth) {

#if defined(WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN)

        if (depth == 16 || depth == 32) {

#else

        if (depth == 32) {

#endif

            if (is_graphic_console()) {

                qemu_free_displaysurface(s->ds);

                s->ds->surface = qemu_create_displaysurface_from(disp_width, height, depth,

                                                               s->line_offset,

                                                               s->vram_ptr + (s->start_addr * 4));

#if defined(WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN)

                s->ds->surface->pf = qemu_different_endianness_pixelformat(depth);

#endif

                dpy_resize(s->ds);

            } else {

                qemu_console_resize(s->ds, disp_width, height);

            }

        } else {

            qemu_console_resize(s->ds, disp_width, height);

        }

        s->last_scr_width = disp_width;

        s->last_scr_height = height;

        s->last_width = disp_width;

        s->last_height = height;

        s->last_line_offset = s->line_offset;

        s->last_depth = depth;

        full_update = 1;

    } else if (is_graphic_console() && is_buffer_shared(s->ds->surface) &&

               (full_update || s->ds->surface->data != s->vram_ptr + (s->start_addr * 4))) {

        s->ds->surface->data = s->vram_ptr + (s->start_addr * 4);

        dpy_setdata(s->ds);

    }



    s->rgb_to_pixel =

        rgb_to_pixel_dup_table[get_depth_index(s->ds)];



    if (shift_control == 0) {

        full_update |= update_palette16(s);

        if (s->sr[0x01] & 8) {

            v = VGA_DRAW_LINE4D2;

            disp_width <<= 1;

        } else {

            v = VGA_DRAW_LINE4;

        }

        bits = 4;

    } else if (shift_control == 1) {

        full_update |= update_palette16(s);

        if (s->sr[0x01] & 8) {

            v = VGA_DRAW_LINE2D2;

            disp_width <<= 1;

        } else {

            v = VGA_DRAW_LINE2;

        }

        bits = 4;

    } else {

        switch(s->get_bpp(s)) {

        default:

        case 0:

            full_update |= update_palette256(s);

            v = VGA_DRAW_LINE8D2;

            bits = 4;

            break;

        case 8:

            full_update |= update_palette256(s);

            v = VGA_DRAW_LINE8;

            bits = 8;

            break;

        case 15:

            v = VGA_DRAW_LINE15;

            bits = 16;

            break;

        case 16:

            v = VGA_DRAW_LINE16;

            bits = 16;

            break;

        case 24:

            v = VGA_DRAW_LINE24;

            bits = 24;

            break;

        case 32:

            v = VGA_DRAW_LINE32;

            bits = 32;

            break;

        }

    }

    vga_draw_line = vga_draw_line_table[v * NB_DEPTHS + get_depth_index(s->ds)];



    if (!is_buffer_shared(s->ds->surface) && s->cursor_invalidate)

        s->cursor_invalidate(s);



    line_offset = s->line_offset;

#if 0

    printf("w=%d h=%d v=%d line_offset=%d cr[0x09]=0x%02x cr[0x17]=0x%02x linecmp=%d sr[0x01]=0x%02x\n",

           width, height, v, line_offset, s->cr[9], s->cr[0x17], s->line_compare, s->sr[0x01]);

#endif

    addr1 = (s->start_addr * 4);

    bwidth = (width * bits + 7) / 8;

    y_start = -1;

    page_min = 0x7fffffff;

    page_max = -1;

    d = ds_get_data(s->ds);

    linesize = ds_get_linesize(s->ds);

    y1 = 0;

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

        addr = addr1;

        if (!(s->cr[0x17] & 1)) {

            int shift;

            

            shift = 14 + ((s->cr[0x17] >> 6) & 1);

            addr = (addr & ~(1 << shift)) | ((y1 & 1) << shift);

        }

        if (!(s->cr[0x17] & 2)) {

            addr = (addr & ~0x8000) | ((y1 & 2) << 14);

        }

        page0 = s->vram_offset + (addr & TARGET_PAGE_MASK);

        page1 = s->vram_offset + ((addr + bwidth - 1) & TARGET_PAGE_MASK);

        update = full_update |

            cpu_physical_memory_get_dirty(page0, VGA_DIRTY_FLAG) |

            cpu_physical_memory_get_dirty(page1, VGA_DIRTY_FLAG);

        if ((page1 - page0) > TARGET_PAGE_SIZE) {

            

            update |= cpu_physical_memory_get_dirty(page0 + TARGET_PAGE_SIZE,

                                                    VGA_DIRTY_FLAG);

        }

        

        update |= (s->invalidated_y_table[y >> 5] >> (y & 0x1f)) & 1;

        if (update) {

            if (y_start < 0)

                y_start = y;

            if (page0 < page_min)

                page_min = page0;

            if (page1 > page_max)

                page_max = page1;

            if (!(is_buffer_shared(s->ds->surface))) {

                vga_draw_line(s, d, s->vram_ptr + addr, width);

                if (s->cursor_draw_line)

                    s->cursor_draw_line(s, d, y);

            }

        } else {

            if (y_start >= 0) {

                

                dpy_update(s->ds, 0, y_start,

                           disp_width, y - y_start);

                y_start = -1;

            }

        }

        if (!multi_run) {

            mask = (s->cr[0x17] & 3) ^ 3;

            if ((y1 & mask) == mask)

                addr1 += line_offset;

            y1++;

            multi_run = multi_scan;

        } else {

            multi_run--;

        }

        

        if (y == s->line_compare)

            addr1 = 0;

        d += linesize;

    }

    if (y_start >= 0) {

        

        dpy_update(s->ds, 0, y_start,

                   disp_width, y - y_start);

    }

    

    if (page_max != -1) {

        cpu_physical_memory_reset_dirty(page_min, page_max + TARGET_PAGE_SIZE,

                                        VGA_DIRTY_FLAG);

    }

    memset(s->invalidated_y_table, 0, ((height + 31) >> 5) * 4);

}

static void FUNC_0(VGAState *VAR_0, int VAR_1)

{

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

    int VAR_12, VAR_13, VAR_14, VAR_15, VAR_16, VAR_17, VAR_18, VAR_19;

    int VAR_20, VAR_21, VAR_22;

    uint8_t *d;

    uint32_t v, addr1, addr;

    vga_draw_line_func *vga_draw_line;



    VAR_1 |= update_basic_params(VAR_0);



    if (!VAR_1)

        vga_sync_dirty_bitmap(VAR_0);



    VAR_0->get_resolution(VAR_0, &VAR_12, &VAR_13);

    VAR_20 = VAR_12;



    VAR_14 = (VAR_0->gr[0x05] >> 5) & 3;

    VAR_9 = (VAR_0->cr[0x09] >> 7);

    if (VAR_14 != 1) {

        VAR_21 = (((VAR_0->cr[0x09] & 0x1f) + 1) << VAR_9) - 1;

    } else {

        

        

        VAR_21 = VAR_9;

    }

    VAR_22 = VAR_21;

    if (VAR_14 != VAR_0->VAR_14 ||

        VAR_9 != VAR_0->VAR_9) {

        VAR_1 = 1;

        VAR_0->VAR_14 = VAR_14;

        VAR_0->VAR_9 = VAR_9;

    }



    VAR_11 = VAR_0->get_bpp(VAR_0);

    if (VAR_0->VAR_15 != VAR_0->last_line_offset ||

        VAR_20 != VAR_0->last_width ||

        VAR_13 != VAR_0->last_height ||

        VAR_0->last_depth != VAR_11) {

#if defined(WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN)

        if (VAR_11 == 16 || VAR_11 == 32) {

#else

        if (VAR_11 == 32) {

#endif

            if (is_graphic_console()) {

                qemu_free_displaysurface(VAR_0->ds);

                VAR_0->ds->surface = qemu_create_displaysurface_from(VAR_20, VAR_13, VAR_11,

                                                               VAR_0->VAR_15,

                                                               VAR_0->vram_ptr + (VAR_0->start_addr * 4));

#if defined(WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN)

                VAR_0->ds->surface->pf = qemu_different_endianness_pixelformat(VAR_11);

#endif

                dpy_resize(VAR_0->ds);

            } else {

                qemu_console_resize(VAR_0->ds, VAR_20, VAR_13);

            }

        } else {

            qemu_console_resize(VAR_0->ds, VAR_20, VAR_13);

        }

        VAR_0->last_scr_width = VAR_20;

        VAR_0->last_scr_height = VAR_13;

        VAR_0->last_width = VAR_20;

        VAR_0->last_height = VAR_13;

        VAR_0->last_line_offset = VAR_0->VAR_15;

        VAR_0->last_depth = VAR_11;

        VAR_1 = 1;

    } else if (is_graphic_console() && is_buffer_shared(VAR_0->ds->surface) &&

               (VAR_1 || VAR_0->ds->surface->data != VAR_0->vram_ptr + (VAR_0->start_addr * 4))) {

        VAR_0->ds->surface->data = VAR_0->vram_ptr + (VAR_0->start_addr * 4);

        dpy_setdata(VAR_0->ds);

    }



    VAR_0->rgb_to_pixel =

        rgb_to_pixel_dup_table[get_depth_index(VAR_0->ds)];



    if (VAR_14 == 0) {

        VAR_1 |= update_palette16(VAR_0);

        if (VAR_0->sr[0x01] & 8) {

            v = VGA_DRAW_LINE4D2;

            VAR_20 <<= 1;

        } else {

            v = VGA_DRAW_LINE4;

        }

        VAR_19 = 4;

    } else if (VAR_14 == 1) {

        VAR_1 |= update_palette16(VAR_0);

        if (VAR_0->sr[0x01] & 8) {

            v = VGA_DRAW_LINE2D2;

            VAR_20 <<= 1;

        } else {

            v = VGA_DRAW_LINE2;

        }

        VAR_19 = 4;

    } else {

        switch(VAR_0->get_bpp(VAR_0)) {

        default:

        case 0:

            VAR_1 |= update_palette256(VAR_0);

            v = VGA_DRAW_LINE8D2;

            VAR_19 = 4;

            break;

        case 8:

            VAR_1 |= update_palette256(VAR_0);

            v = VGA_DRAW_LINE8;

            VAR_19 = 8;

            break;

        case 15:

            v = VGA_DRAW_LINE15;

            VAR_19 = 16;

            break;

        case 16:

            v = VGA_DRAW_LINE16;

            VAR_19 = 16;

            break;

        case 24:

            v = VGA_DRAW_LINE24;

            VAR_19 = 24;

            break;

        case 32:

            v = VGA_DRAW_LINE32;

            VAR_19 = 32;

            break;

        }

    }

    vga_draw_line = vga_draw_line_table[v * NB_DEPTHS + get_depth_index(VAR_0->ds)];



    if (!is_buffer_shared(VAR_0->ds->surface) && VAR_0->cursor_invalidate)

        VAR_0->cursor_invalidate(VAR_0);



    VAR_15 = VAR_0->VAR_15;

#if 0

    printf("w=%d h=%d v=%d VAR_15=%d cr[0x09]=0x%02x cr[0x17]=0x%02x linecmp=%d sr[0x01]=0x%02x\n",

           VAR_12, VAR_13, v, VAR_15, VAR_0->cr[9], VAR_0->cr[0x17], VAR_0->line_compare, VAR_0->sr[0x01]);

#endif

    addr1 = (VAR_0->start_addr * 4);

    VAR_18 = (VAR_12 * VAR_19 + 7) / 8;

    VAR_8 = -1;

    VAR_5 = 0x7fffffff;

    VAR_6 = -1;

    d = ds_get_data(VAR_0->ds);

    VAR_7 = ds_get_linesize(VAR_0->ds);

    VAR_2 = 0;

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

        addr = addr1;

        if (!(VAR_0->cr[0x17] & 1)) {

            int VAR_23;

            

            VAR_23 = 14 + ((VAR_0->cr[0x17] >> 6) & 1);

            addr = (addr & ~(1 << VAR_23)) | ((VAR_2 & 1) << VAR_23);

        }

        if (!(VAR_0->cr[0x17] & 2)) {

            addr = (addr & ~0x8000) | ((VAR_2 & 2) << 14);

        }

        VAR_16 = VAR_0->vram_offset + (addr & TARGET_PAGE_MASK);

        VAR_17 = VAR_0->vram_offset + ((addr + VAR_18 - 1) & TARGET_PAGE_MASK);

        VAR_4 = VAR_1 |

            cpu_physical_memory_get_dirty(VAR_16, VGA_DIRTY_FLAG) |

            cpu_physical_memory_get_dirty(VAR_17, VGA_DIRTY_FLAG);

        if ((VAR_17 - VAR_16) > TARGET_PAGE_SIZE) {

            

            VAR_4 |= cpu_physical_memory_get_dirty(VAR_16 + TARGET_PAGE_SIZE,

                                                    VGA_DIRTY_FLAG);

        }

        

        VAR_4 |= (VAR_0->invalidated_y_table[VAR_3 >> 5] >> (VAR_3 & 0x1f)) & 1;

        if (VAR_4) {

            if (VAR_8 < 0)

                VAR_8 = VAR_3;

            if (VAR_16 < VAR_5)

                VAR_5 = VAR_16;

            if (VAR_17 > VAR_6)

                VAR_6 = VAR_17;

            if (!(is_buffer_shared(VAR_0->ds->surface))) {

                vga_draw_line(VAR_0, d, VAR_0->vram_ptr + addr, VAR_12);

                if (VAR_0->cursor_draw_line)

                    VAR_0->cursor_draw_line(VAR_0, d, VAR_3);

            }

        } else {

            if (VAR_8 >= 0) {

                

                dpy_update(VAR_0->ds, 0, VAR_8,

                           VAR_20, VAR_3 - VAR_8);

                VAR_8 = -1;

            }

        }

        if (!VAR_22) {

            VAR_10 = (VAR_0->cr[0x17] & 3) ^ 3;

            if ((VAR_2 & VAR_10) == VAR_10)

                addr1 += VAR_15;

            VAR_2++;

            VAR_22 = VAR_21;

        } else {

            VAR_22--;

        }

        

        if (VAR_3 == VAR_0->line_compare)

            addr1 = 0;

        d += VAR_7;

    }

    if (VAR_8 >= 0) {

        

        dpy_update(VAR_0->ds, 0, VAR_8,

                   VAR_20, VAR_3 - VAR_8);

    }

    

    if (VAR_6 != -1) {

        cpu_physical_memory_reset_dirty(VAR_5, VAR_6 + TARGET_PAGE_SIZE,

                                        VGA_DIRTY_FLAG);

    }

    memset(VAR_0->invalidated_y_table, 0, ((VAR_13 + 31) >> 5) * 4);

}

static void FUNC_0(VGAState *VAR_0, int VAR_1)
{ int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11; int VAR_12, VAR_13, VAR_14, VAR_15, VAR_16, VAR_17, VAR_18, VAR_19; int VAR_20, VAR_21, VAR_22; uint8_t *d; uint32_t v, addr1, addr; vga_draw_line_func *vga_draw_line; VAR_1 |= update_basic_params(VAR_0); if (!VAR_1)
vga_sync_dirty_bitmap(VAR_0); VAR_0->get_resolution(VAR_0, &VAR_12, &VAR_13); VAR_20 = VAR_12; VAR_14 = (VAR_0->gr[0x05] >> 5) & 3; VAR_9 = (VAR_0->cr[0x09] >> 7); if (VAR_14 != 1) { VAR_21 = (((VAR_0->cr[0x09] & 0x1f) + 1) << VAR_9) - 1; } else { VAR_21 = VAR_9; } VAR_22 = VAR_21; if (VAR_14 != VAR_0->VAR_14 ||
VAR_9 != VAR_0->VAR_9) { VAR_1 = 1; VAR_0->VAR_14 = VAR_14; VAR_0->VAR_9 = VAR_9; } VAR_11 = VAR_0->get_bpp(VAR_0); if (VAR_0->VAR_15 != VAR_0->last_line_offset ||
VAR_20 != VAR_0->last_width ||
VAR_13 != VAR_0->last_height ||
VAR_0->last_depth != VAR_11) { #if defined(WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN)
if (VAR_11 == 16 || VAR_11 == 32) { #else
if (VAR_11 == 32) { #endif
if (is_graphic_console()) { qemu_free_displaysurface(VAR_0->ds); VAR_0->ds->surface = qemu_create_displaysurface_from(VAR_20, VAR_13, VAR_11,
VAR_0->VAR_15,
VAR_0->vram_ptr + (VAR_0->start_addr * 4)); #if defined(WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN)
VAR_0->ds->surface->pf = qemu_different_endianness_pixelformat(VAR_11); #endif
dpy_resize(VAR_0->ds); } else { qemu_console_resize(VAR_0->ds, VAR_20, VAR_13); } } else { qemu_console_resize(VAR_0->ds, VAR_20, VAR_13); } VAR_0->last_scr_width = VAR_20; VAR_0->last_scr_height = VAR_13; VAR_0->last_width = VAR_20; VAR_0->last_height = VAR_13; VAR_0->last_line_offset = VAR_0->VAR_15; VAR_0->last_depth = VAR_11; VAR_1 = 1; } else if (is_graphic_console() && is_buffer_shared(VAR_0->ds->surface) && (VAR_1 || VAR_0->ds->surface->data != VAR_0->vram_ptr + (VAR_0->start_addr * 4))) { VAR_0->ds->surface->data = VAR_0->vram_ptr + (VAR_0->start_addr * 4); dpy_setdata(VAR_0->ds); } VAR_0->rgb_to_pixel =
rgb_to_pixel_dup_table[get_depth_index(VAR_0->ds)]; if (VAR_14 == 0) { VAR_1 |= update_palette16(VAR_0); if (VAR_0->sr[0x01] & 8) { v = VGA_DRAW_LINE4D2; VAR_20 <<= 1; } else { v = VGA_DRAW_LINE4; } VAR_19 = 4; } else if (VAR_14 == 1) { VAR_1 |= update_palette16(VAR_0); if (VAR_0->sr[0x01] & 8) { v = VGA_DRAW_LINE2D2; VAR_20 <<= 1; } else { v = VGA_DRAW_LINE2; } VAR_19 = 4; } else { switch(VAR_0->get_bpp(VAR_0)) { default:
case 0:
VAR_1 |= update_palette256(VAR_0); v = VGA_DRAW_LINE8D2; VAR_19 = 4; break; case 8:
VAR_1 |= update_palette256(VAR_0); v = VGA_DRAW_LINE8; VAR_19 = 8; break; case 15:
v = VGA_DRAW_LINE15; VAR_19 = 16; break; case 16:
v = VGA_DRAW_LINE16; VAR_19 = 16; break; case 24:
v = VGA_DRAW_LINE24; VAR_19 = 24; break; case 32:
v = VGA_DRAW_LINE32; VAR_19 = 32; break; } } vga_draw_line = vga_draw_line_table[v * NB_DEPTHS + get_depth_index(VAR_0->ds)]; if (!is_buffer_shared(VAR_0->ds->surface) && VAR_0->cursor_invalidate)
VAR_0->cursor_invalidate(VAR_0); VAR_15 = VAR_0->VAR_15; #if 0
printf("w=%d h=%d v=%d VAR_15=%d cr[0x09]=0x%02x cr[0x17]=0x%02x linecmp=%d sr[0x01]=0x%02x\n",
VAR_12, VAR_13, v, VAR_15, VAR_0->cr[9], VAR_0->cr[0x17], VAR_0->line_compare, VAR_0->sr[0x01]); #endif
addr1 = (VAR_0->start_addr * 4); VAR_18 = (VAR_12 * VAR_19 + 7) / 8; VAR_8 = -1; VAR_5 = 0x7fffffff; VAR_6 = -1; d = ds_get_data(VAR_0->ds); VAR_7 = ds_get_linesize(VAR_0->ds); VAR_2 = 0; for(VAR_3 = 0; VAR_3 < VAR_13; VAR_3++) { addr = addr1; if (!(VAR_0->cr[0x17] & 1)) { int VAR_23; VAR_23 = 14 + ((VAR_0->cr[0x17] >> 6) & 1); addr = (addr & ~(1 << VAR_23)) | ((VAR_2 & 1) << VAR_23); } if (!(VAR_0->cr[0x17] & 2)) { addr = (addr & ~0x8000) | ((VAR_2 & 2) << 14); } VAR_16 = VAR_0->vram_offset + (addr & TARGET_PAGE_MASK); VAR_17 = VAR_0->vram_offset + ((addr + VAR_18 - 1) & TARGET_PAGE_MASK); VAR_4 = VAR_1 |
cpu_physical_memory_get_dirty(VAR_16, VGA_DIRTY_FLAG) |
cpu_physical_memory_get_dirty(VAR_17, VGA_DIRTY_FLAG); if ((VAR_17 - VAR_16) > TARGET_PAGE_SIZE) { VAR_4 |= cpu_physical_memory_get_dirty(VAR_16 + TARGET_PAGE_SIZE,
VGA_DIRTY_FLAG); } VAR_4 |= (VAR_0->invalidated_y_table[VAR_3 >> 5] >> (VAR_3 & 0x1f)) & 1; if (VAR_4) { if (VAR_8 < 0)
VAR_8 = VAR_3; if (VAR_16 < VAR_5)
VAR_5 = VAR_16; if (VAR_17 > VAR_6)
VAR_6 = VAR_17; if (!(is_buffer_shared(VAR_0->ds->surface))) { vga_draw_line(VAR_0, d, VAR_0->vram_ptr + addr, VAR_12); if (VAR_0->cursor_draw_line)
VAR_0->cursor_draw_line(VAR_0, d, VAR_3); } } else { if (VAR_8 >= 0) { dpy_update(VAR_0->ds, 0, VAR_8,
VAR_20, VAR_3 - VAR_8); VAR_8 = -1; } } if (!VAR_22) { VAR_10 = (VAR_0->cr[0x17] & 3) ^ 3; if ((VAR_2 & VAR_10) == VAR_10)
addr1 += VAR_15; VAR_2++; VAR_22 = VAR_21; } else { VAR_22--; } if (VAR_3 == VAR_0->line_compare)
addr1 = 0; d += VAR_7; } if (VAR_8 >= 0) { dpy_update(VAR_0->ds, 0, VAR_8,
VAR_20, VAR_3 - VAR_8); } if (VAR_6 != -1) { cpu_physical_memory_reset_dirty(VAR_5, VAR_6 + TARGET_PAGE_SIZE,
VGA_DIRTY_FLAG); } memset(VAR_0->invalidated_y_table, 0, ((VAR_13 + 31) >> 5) * 4); }