public static int K052109_vh_start(int gfx_memory_region, int plane0, int plane1, int plane2, int plane3, K052109_callbackProcPtr callback) {
        int gfx_index;
        GfxLayout charlayout = new GfxLayout(
                8, 8,
                0, /* filled in later */
                4,
                new int[]{0, 0, 0, 0}, /* filled in later */
                new int[]{0, 1, 2, 3, 4, 5, 6, 7},
                new int[]{0 * 32, 1 * 32, 2 * 32, 3 * 32, 4 * 32, 5 * 32, 6 * 32, 7 * 32},
                32 * 8
        );


        /* find first empty slot to decode gfx */
        for (gfx_index = 0; gfx_index < MAX_GFX_ELEMENTS; gfx_index++) {
            if (Machine.gfx[gfx_index] == null) {
                break;
            }
        }
        if (gfx_index == MAX_GFX_ELEMENTS) {
            return 1;
        }

        /* tweak the structure for the number of tiles we have */
        charlayout.total = memory_region_length(gfx_memory_region) / 32;
        charlayout.planeoffset[0] = plane3 * 8;
        charlayout.planeoffset[1] = plane2 * 8;
        charlayout.planeoffset[2] = plane1 * 8;
        charlayout.planeoffset[3] = plane0 * 8;

        /* decode the graphics */
        Machine.gfx[gfx_index] = decodegfx(memory_region(gfx_memory_region), charlayout);
        if (Machine.gfx[gfx_index] == null) {
            return 1;
        }

        /* set the color information */
        Machine.gfx[gfx_index].colortable = new CharPtr(Machine.remapped_colortable);
        Machine.gfx[gfx_index].total_colors = Machine.drv.color_table_len / 16;

        K052109_memory_region = gfx_memory_region;
        K052109_gfxnum = gfx_index;
        K052109_callback = callback;
        K052109_RMRD_line = CLEAR_LINE;

        has_extra_video_ram = 0;

        K052109_tilemap[0] = tilemap_create(K052109_get_tile_info, TILEMAP_TRANSPARENT, 8, 8, 64, 32);
        K052109_tilemap[1] = tilemap_create(K052109_get_tile_info, TILEMAP_TRANSPARENT, 8, 8, 64, 32);
        K052109_tilemap[2] = tilemap_create(K052109_get_tile_info, TILEMAP_TRANSPARENT, 8, 8, 64, 32);

        K052109_ram = new UBytePtr(0x6000);

        if (K052109_ram == null || K052109_tilemap[0] == null || K052109_tilemap[1] == null || K052109_tilemap[2] == null) {
            K052109_vh_stop();
            return 1;
        }

        for (int i = 0; i < 0x6000; i++) {
            K052109_ram.write(i, 0);//memset(K052109_ram,0,0x6000);
        }
        K052109_colorram_F = new UBytePtr(K052109_ram, 0x0000);
        K052109_colorram_A = new UBytePtr(K052109_ram, 0x0800);
        K052109_colorram_B = new UBytePtr(K052109_ram, 0x1000);
        K052109_videoram_F = new UBytePtr(K052109_ram, 0x2000);
        K052109_videoram_A = new UBytePtr(K052109_ram, 0x2800);
        K052109_videoram_B = new UBytePtr(K052109_ram, 0x3000);
        K052109_videoram2_F = new UBytePtr(K052109_ram, 0x4000);
        K052109_videoram2_A = new UBytePtr(K052109_ram, 0x4800);
        K052109_videoram2_B = new UBytePtr(K052109_ram, 0x5000);

        K052109_tilemap[0].transparent_pen = 0;
        K052109_tilemap[1].transparent_pen = 0;
        K052109_tilemap[2].transparent_pen = 0;

        return 0;
    }