void vga_common_init(VGAState *s, DisplayState *ds, uint8_t *vga_ram_base,

                     unsigned long vga_ram_offset, int vga_ram_size)

{

    int i, j, v, b;



    for(i = 0;i < 256; i++) {

        v = 0;

        for(j = 0; j < 8; j++) {

            v |= ((i >> j) & 1) << (j * 4);

        }

        expand4[i] = v;



        v = 0;

        for(j = 0; j < 4; j++) {

            v |= ((i >> (2 * j)) & 3) << (j * 4);

        }

        expand2[i] = v;

    }

    for(i = 0; i < 16; i++) {

        v = 0;

        for(j = 0; j < 4; j++) {

            b = ((i >> j) & 1);

            v |= b << (2 * j);

            v |= b << (2 * j + 1);

        }

        expand4to8[i] = v;

    }



    vga_reset(s);



    s->vram_ptr = vga_ram_base;

    s->vram_offset = vga_ram_offset;

    s->vram_size = vga_ram_size;

    s->ds = ds;

    s->get_bpp = vga_get_bpp;

    s->get_offsets = vga_get_offsets;

    s->get_resolution = vga_get_resolution;

    s->update = vga_update_display;

    s->invalidate = vga_invalidate_display;

    s->screen_dump = vga_screen_dump;

    s->text_update = vga_update_text;

    switch (vga_retrace_method) {

    case VGA_RETRACE_DUMB:

        s->retrace = vga_dumb_retrace;

        s->update_retrace_info = vga_dumb_update_retrace_info;

        break;



    case VGA_RETRACE_PRECISE:

        s->retrace = vga_precise_retrace;

        s->update_retrace_info = vga_precise_update_retrace_info;

        memset(&s->retrace_info, 0, sizeof (s->retrace_info));

        break;

    }

}

void vga_common_init(VGAState *s, DisplayState *ds, uint8_t *vga_ram_base,

                     unsigned long vga_ram_offset, int vga_ram_size)

{

    int i, j, v, b;



    for(i = 0;i < 256; i++) {

        v = 0;

        for(j = 0; j < 8; j++) {

            v |= ((i >> j) & 1) << (j * 4);

        }

        expand4[i] = v;



        v = 0;

        for(j = 0; j < 4; j++) {

            v |= ((i >> (2 * j)) & 3) << (j * 4);

        }

        expand2[i] = v;

    }

    for(i = 0; i < 16; i++) {

        v = 0;

        for(j = 0; j < 4; j++) {

            b = ((i >> j) & 1);

            v |= b << (2 * j);

            v |= b << (2 * j + 1);

        }

        expand4to8[i] = v;

    }



    vga_reset(s);



    s->vram_ptr = vga_ram_base;

    s->vram_offset = vga_ram_offset;

    s->vram_size = vga_ram_size;

    s->ds = ds;

    s->get_bpp = vga_get_bpp;

    s->get_offsets = vga_get_offsets;

    s->get_resolution = vga_get_resolution;

    s->update = vga_update_display;

    s->invalidate = vga_invalidate_display;

    s->screen_dump = vga_screen_dump;

    s->text_update = vga_update_text;

    switch (vga_retrace_method) {

    case VGA_RETRACE_DUMB:

        s->retrace = vga_dumb_retrace;

        s->update_retrace_info = vga_dumb_update_retrace_info;

        break;



    case VGA_RETRACE_PRECISE:

        s->retrace = vga_precise_retrace;

        s->update_retrace_info = vga_precise_update_retrace_info;

        memset(&s->retrace_info, 0, sizeof (s->retrace_info));

        break;

    }

}

void FUNC_0(VGAState *VAR_0, DisplayState *VAR_1, uint8_t *VAR_2,

                     unsigned long VAR_3, int VAR_4)

{

    int VAR_5, VAR_6, VAR_7, VAR_8;



    for(VAR_5 = 0;VAR_5 < 256; VAR_5++) {

        VAR_7 = 0;

        for(VAR_6 = 0; VAR_6 < 8; VAR_6++) {

            VAR_7 |= ((VAR_5 >> VAR_6) & 1) << (VAR_6 * 4);

        }

        expand4[VAR_5] = VAR_7;



        VAR_7 = 0;

        for(VAR_6 = 0; VAR_6 < 4; VAR_6++) {

            VAR_7 |= ((VAR_5 >> (2 * VAR_6)) & 3) << (VAR_6 * 4);

        }

        expand2[VAR_5] = VAR_7;

    }

    for(VAR_5 = 0; VAR_5 < 16; VAR_5++) {

        VAR_7 = 0;

        for(VAR_6 = 0; VAR_6 < 4; VAR_6++) {

            VAR_8 = ((VAR_5 >> VAR_6) & 1);

            VAR_7 |= VAR_8 << (2 * VAR_6);

            VAR_7 |= VAR_8 << (2 * VAR_6 + 1);

        }

        expand4to8[VAR_5] = VAR_7;

    }



    vga_reset(VAR_0);



    VAR_0->vram_ptr = VAR_2;

    VAR_0->vram_offset = VAR_3;

    VAR_0->vram_size = VAR_4;

    VAR_0->VAR_1 = VAR_1;

    VAR_0->get_bpp = vga_get_bpp;

    VAR_0->get_offsets = vga_get_offsets;

    VAR_0->get_resolution = vga_get_resolution;

    VAR_0->update = vga_update_display;

    VAR_0->invalidate = vga_invalidate_display;

    VAR_0->screen_dump = vga_screen_dump;

    VAR_0->text_update = vga_update_text;

    switch (vga_retrace_method) {

    case VGA_RETRACE_DUMB:

        VAR_0->retrace = vga_dumb_retrace;

        VAR_0->update_retrace_info = vga_dumb_update_retrace_info;

        break;



    case VGA_RETRACE_PRECISE:

        VAR_0->retrace = vga_precise_retrace;

        VAR_0->update_retrace_info = vga_precise_update_retrace_info;

        memset(&VAR_0->retrace_info, 0, sizeof (VAR_0->retrace_info));

        break;

    }

}

void FUNC_0(VGAState *VAR_0, DisplayState *VAR_1, uint8_t *VAR_2,
unsigned long VAR_3, int VAR_4)
{ int VAR_5, VAR_6, VAR_7, VAR_8; for(VAR_5 = 0;VAR_5 < 256; VAR_5++) { VAR_7 = 0; for(VAR_6 = 0; VAR_6 < 8; VAR_6++) { VAR_7 |= ((VAR_5 >> VAR_6) & 1) << (VAR_6 * 4); } expand4[VAR_5] = VAR_7; VAR_7 = 0; for(VAR_6 = 0; VAR_6 < 4; VAR_6++) { VAR_7 |= ((VAR_5 >> (2 * VAR_6)) & 3) << (VAR_6 * 4); } expand2[VAR_5] = VAR_7; } for(VAR_5 = 0; VAR_5 < 16; VAR_5++) { VAR_7 = 0; for(VAR_6 = 0; VAR_6 < 4; VAR_6++) { VAR_8 = ((VAR_5 >> VAR_6) & 1); VAR_7 |= VAR_8 << (2 * VAR_6); VAR_7 |= VAR_8 << (2 * VAR_6 + 1); } expand4to8[VAR_5] = VAR_7; } vga_reset(VAR_0); VAR_0->vram_ptr = VAR_2; VAR_0->vram_offset = VAR_3; VAR_0->vram_size = VAR_4; VAR_0->VAR_1 = VAR_1; VAR_0->get_bpp = vga_get_bpp; VAR_0->get_offsets = vga_get_offsets; VAR_0->get_resolution = vga_get_resolution; VAR_0->update = vga_update_display; VAR_0->invalidate = vga_invalidate_display; VAR_0->screen_dump = vga_screen_dump; VAR_0->text_update = vga_update_text; switch (vga_retrace_method) { case VGA_RETRACE_DUMB:
VAR_0->retrace = vga_dumb_retrace; VAR_0->update_retrace_info = vga_dumb_update_retrace_info; break; case VGA_RETRACE_PRECISE:
VAR_0->retrace = vga_precise_retrace; VAR_0->update_retrace_info = vga_precise_update_retrace_info; memset(&VAR_0->retrace_info, 0, sizeof (VAR_0->retrace_info)); break; } }