void framebuffer_update_display(

    DisplaySurface *ds,

    MemoryRegionSection *mem_section,

    int cols, /* Width in pixels.  */

    int rows, /* Height in pixels.  */

    int src_width, /* Length of source line, in bytes.  */

    int dest_row_pitch, /* Bytes between adjacent horizontal output pixels.  */

    int dest_col_pitch, /* Bytes between adjacent vertical output pixels.  */

    int invalidate, /* nonzero to redraw the whole image.  */

    drawfn fn,

    void *opaque,

    int *first_row, /* Input and output.  */

    int *last_row /* Output only */)

{

    hwaddr src_len;

    uint8_t *dest;

    uint8_t *src;

    int first, last = 0;

    int dirty;

    int i;

    ram_addr_t addr;

    MemoryRegion *mem;



    i = *first_row;

    *first_row = -1;

    src_len = src_width * rows;



    mem = mem_section->mr;

    if (!mem) {

        return;

    }

    memory_region_sync_dirty_bitmap(mem);



    addr = mem_section->offset_within_region;

    src = memory_region_get_ram_ptr(mem) + addr;



    dest = surface_data(ds);

    if (dest_col_pitch < 0) {

        dest -= dest_col_pitch * (cols - 1);

    }

    if (dest_row_pitch < 0) {

        dest -= dest_row_pitch * (rows - 1);

    }

    first = -1;



    addr += i * src_width;

    src += i * src_width;

    dest += i * dest_row_pitch;



    for (; i < rows; i++) {

        dirty = memory_region_get_dirty(mem, addr, src_width,

                                             DIRTY_MEMORY_VGA);

        if (dirty || invalidate) {

            fn(opaque, dest, src, cols, dest_col_pitch);

            if (first == -1)

                first = i;

            last = i;

        }

        addr += src_width;

        src += src_width;

        dest += dest_row_pitch;

    }

    if (first < 0) {

        return;

    }

    memory_region_reset_dirty(mem, mem_section->offset_within_region, src_len,

                              DIRTY_MEMORY_VGA);

    *first_row = first;

    *last_row = last;

}

void framebuffer_update_display(

    DisplaySurface *ds,

    MemoryRegionSection *mem_section,

    int cols, 

    int rows, 

    int src_width, 

    int dest_row_pitch, 

    int dest_col_pitch, 

    int invalidate, 

    drawfn fn,

    void *opaque,

    int *first_row, 

    int *last_row )

{

    hwaddr src_len;

    uint8_t *dest;

    uint8_t *src;

    int first, last = 0;

    int dirty;

    int i;

    ram_addr_t addr;

    MemoryRegion *mem;



    i = *first_row;

    *first_row = -1;

    src_len = src_width * rows;



    mem = mem_section->mr;

    if (!mem) {

        return;

    }

    memory_region_sync_dirty_bitmap(mem);



    addr = mem_section->offset_within_region;

    src = memory_region_get_ram_ptr(mem) + addr;



    dest = surface_data(ds);

    if (dest_col_pitch < 0) {

        dest -= dest_col_pitch * (cols - 1);

    }

    if (dest_row_pitch < 0) {

        dest -= dest_row_pitch * (rows - 1);

    }

    first = -1;



    addr += i * src_width;

    src += i * src_width;

    dest += i * dest_row_pitch;



    for (; i < rows; i++) {

        dirty = memory_region_get_dirty(mem, addr, src_width,

                                             DIRTY_MEMORY_VGA);

        if (dirty || invalidate) {

            fn(opaque, dest, src, cols, dest_col_pitch);

            if (first == -1)

                first = i;

            last = i;

        }

        addr += src_width;

        src += src_width;

        dest += dest_row_pitch;

    }

    if (first < 0) {

        return;

    }

    memory_region_reset_dirty(mem, mem_section->offset_within_region, src_len,

                              DIRTY_MEMORY_VGA);

    *first_row = first;

    *last_row = last;

}

    src_len = src_width * rows;
void FUNC_0(

    DisplaySurface *VAR_0,

    MemoryRegionSection *VAR_1,

    int VAR_2, 

    int VAR_3, 

    int VAR_4, 

    int VAR_5, 

    int VAR_6, 

    int VAR_7, 

    drawfn VAR_8,

    void *VAR_9,

    int *VAR_10, 

    int *VAR_11 )

{

    hwaddr src_len;

    uint8_t *dest;

    uint8_t *src;

    int VAR_12, VAR_13 = 0;

    int VAR_14;

    int VAR_15;

    ram_addr_t addr;

    MemoryRegion *mem;



    VAR_15 = *VAR_10;

    *VAR_10 = -1;

    src_len = VAR_4 * VAR_3;



    mem = VAR_1->mr;

    if (!mem) {

        return;

    }

    memory_region_sync_dirty_bitmap(mem);



    addr = VAR_1->offset_within_region;

    src = memory_region_get_ram_ptr(mem) + addr;



    dest = surface_data(VAR_0);

    if (VAR_6 < 0) {

        dest -= VAR_6 * (VAR_2 - 1);

    }

    if (VAR_5 < 0) {

        dest -= VAR_5 * (VAR_3 - 1);

    }

    VAR_12 = -1;



    addr += VAR_15 * VAR_4;

    src += VAR_15 * VAR_4;

    dest += VAR_15 * VAR_5;



    for (; VAR_15 < VAR_3; VAR_15++) {

        VAR_14 = memory_region_get_dirty(mem, addr, VAR_4,

                                             DIRTY_MEMORY_VGA);

        if (VAR_14 || VAR_7) {

            VAR_8(VAR_9, dest, src, VAR_2, VAR_6);

            if (VAR_12 == -1)

                VAR_12 = VAR_15;

            VAR_13 = VAR_15;

        }

        addr += VAR_4;

        src += VAR_4;

        dest += VAR_5;

    }

    if (VAR_12 < 0) {

        return;

    }

    memory_region_reset_dirty(mem, VAR_1->offset_within_region, src_len,

                              DIRTY_MEMORY_VGA);

    *VAR_10 = VAR_12;

    *VAR_11 = VAR_13;

}

void FUNC_0(
DisplaySurface *VAR_0,
MemoryRegionSection *VAR_1,
int VAR_2,
int VAR_3,
int VAR_4,
int VAR_5,
int VAR_6,
int VAR_7,
drawfn VAR_8,
void *VAR_9,
int *VAR_10,
int *VAR_11 )
{ hwaddr src_len; uint8_t *dest; uint8_t *src; int VAR_12, VAR_13 = 0; int VAR_14; int VAR_15; ram_addr_t addr; MemoryRegion *mem; VAR_15 = *VAR_10; *VAR_10 = -1; src_len = VAR_4 * VAR_3; mem = VAR_1->mr; if (!mem) { return; } memory_region_sync_dirty_bitmap(mem); addr = VAR_1->offset_within_region; src = memory_region_get_ram_ptr(mem) + addr; dest = surface_data(VAR_0); if (VAR_6 < 0) { dest -= VAR_6 * (VAR_2 - 1); } if (VAR_5 < 0) { dest -= VAR_5 * (VAR_3 - 1); } VAR_12 = -1; addr += VAR_15 * VAR_4; src += VAR_15 * VAR_4; dest += VAR_15 * VAR_5; for (; VAR_15 < VAR_3; VAR_15++) { VAR_14 = memory_region_get_dirty(mem, addr, VAR_4,
DIRTY_MEMORY_VGA); if (VAR_14 || VAR_7) { VAR_8(VAR_9, dest, src, VAR_2, VAR_6); if (VAR_12 == -1)
VAR_12 = VAR_15; VAR_13 = VAR_15; } addr += VAR_4; src += VAR_4; dest += VAR_5; } if (VAR_12 < 0) { return; } memory_region_reset_dirty(mem, VAR_1->offset_within_region, src_len,
DIRTY_MEMORY_VGA); *VAR_10 = VAR_12; *VAR_11 = VAR_13; }