Пример #1
0
 public static int K051316_vh_start_0(int gfx_memory_region, int bpp, _K051316_callback callback)
 {
     return K051316_vh_start(0, gfx_memory_region, bpp, callback);
 }
Пример #2
0
        public static int K051316_vh_start(int chip, int gfx_memory_region, int bpp, _K051316_callback callback)
        {
            int gfx_index;


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

            if (bpp == 4)
            {
                Mame.GfxLayout charlayout =
                new Mame.GfxLayout(
                    16, 16,
                    0,				/* filled in later */
                    4,
                    new uint[] { 0, 1, 2, 3 },
                    new uint[] { 0 * 4, 1 * 4, 2 * 4, 3 * 4, 4 * 4, 5 * 4, 6 * 4, 7 * 4, 8 * 4, 9 * 4, 10 * 4, 11 * 4, 12 * 4, 13 * 4, 14 * 4, 15 * 4 },
                    new uint[] { 0 * 64, 1 * 64, 2 * 64, 3 * 64, 4 * 64, 5 * 64, 6 * 64, 7 * 64, 8 * 64, 9 * 64, 10 * 64, 11 * 64, 12 * 64, 13 * 64, 14 * 64, 15 * 64 },
                    128 * 8
                );


                /* tweak the structure for the number of tiles we have */
                charlayout.total = (uint)Mame.memory_region_length(gfx_memory_region) / 128;

                /* decode the graphics */
                Mame.Machine.gfx[gfx_index] = Mame.decodegfx(Mame.memory_region(gfx_memory_region), charlayout);
            }
            else if (bpp == 7)
            {
                Mame.GfxLayout charlayout =
                new Mame.GfxLayout(
                    16, 16,
                    0,				/* filled in later */
                    7,
                    new uint[] { 1, 2, 3, 4, 5, 6, 7 },
                    new uint[] { 0 * 8, 1 * 8, 2 * 8, 3 * 8, 4 * 8, 5 * 8, 6 * 8, 7 * 8, 8 * 8, 9 * 8, 10 * 8, 11 * 8, 12 * 8, 13 * 8, 14 * 8, 15 * 8 },
                    new uint[] { 0 * 128, 1 * 128, 2 * 128, 3 * 128, 4 * 128, 5 * 128, 6 * 128, 7 * 128, 8 * 128, 9 * 128, 10 * 128, 11 * 128, 12 * 128, 13 * 128, 14 * 128, 15 * 128 },
                    256 * 8
                );


                /* tweak the structure for the number of tiles we have */
                charlayout.total = (uint)Mame.memory_region_length(gfx_memory_region) / 256;

                /* decode the graphics */
                Mame.Machine.gfx[gfx_index] = Mame.decodegfx(Mame.memory_region(gfx_memory_region), charlayout);
            }
            else
            {
                //Mame.printf("K051316_vh_start supports only 4 or 7 bpp\n");
                return 1;
            }

            if (Mame.Machine.gfx[gfx_index] == null)
                return 1;

            /* set the color information */
            Mame.Machine.gfx[gfx_index].colortable = new UShortSubArray(Mame.Machine.remapped_colortable);
            Mame.Machine.gfx[gfx_index].total_colors = (int)(Mame.Machine.drv.color_table_len / (1 << bpp));

            K051316_memory_region[chip] = gfx_memory_region;
            K051316_gfxnum[chip] = gfx_index;
            K051316_bpp[chip] = bpp;
            K051316_callback[chip] = callback;

            K051316_tilemap[chip] = Mame.tilemap_create(K051316_get_tile_info, Mame.TILEMAP_OPAQUE, 16, 16, 32, 32);

            K051316_ram[chip] = new _BytePtr(0x800);

            if (K051316_ram[chip] == null || K051316_tilemap[chip] == null)
            {
                K051316_vh_stop(chip);
                return 1;
            }

            Mame.tilemap_set_clip(K051316_tilemap[chip], null);

            K051316_wraparound[chip] = 0;	/* default = no wraparound */
            K051316_offset[chip][0] = K051316_offset[chip][1] = 0;

            return 0;
        }