public GfxDecodeInfo(int memory_region, int start, GfxLayout gfxlayout, int color_codes_start, int total_color_codes) { this.memory_region = memory_region; this.start = start; this.gfxlayout = gfxlayout; this.color_codes_start = color_codes_start; this.total_color_codes = total_color_codes; }
public static void decodechar(GfxElement gfx, int num, _BytePtr src, GfxLayout gl) { int plane, x, y; _BytePtr dp; int offs; offs = num * gl.charincrement; dp = new _BytePtr(gfx.gfxdata, (num * gfx.char_modulo)); for (y = 0; y < gfx.height; y++) { int yoffs; yoffs = y; #if PREROTATE_GFX if ((Machine.orientation & ORIENTATION_FLIP_Y)!=0) yoffs = gfx.height-1 - yoffs; #endif for (x = 0; x < gfx.width; x++) { int xoffs; xoffs = x; #if PREROTATE_GFX if ((Machine.orientation & ORIENTATION_FLIP_X)!=0) xoffs = gfx.width-1 - xoffs; #endif dp[x] = 0; if ((Machine.orientation & ORIENTATION_SWAP_XY) != 0) { for (plane = 0; plane < gl.planes; plane++) { if (readbit(src, (int)(offs + gl.planeoffset[plane] + gl.yoffset[xoffs] + gl.xoffset[yoffs])) != 0) dp[x] |= (byte)((1 << (gl.planes - 1 - plane))); } } else { for (plane = 0; plane < gl.planes; plane++) { if (readbit(src, (int)(offs + gl.planeoffset[plane] + gl.yoffset[yoffs] + gl.xoffset[xoffs])) != 0) dp[x] |= (byte)(1 << (gl.planes - 1 - plane)); } } } dp.offset += gfx.line_modulo; } if (gfx.pen_usage != null) { /* fill the pen_usage array with info on the used pens */ gfx.pen_usage[num] = 0; dp = new _BytePtr(gfx.gfxdata, (num * gfx.char_modulo)); for (y = 0; y < gfx.height; y++) { for (x = 0; x < gfx.width; x++) { gfx.pen_usage[num] = (uint)(gfx.pen_usage[num] | (1 << dp[x])); } dp.offset += gfx.line_modulo; } } }
public static GfxElement decodegfx(_BytePtr src, GfxLayout gl) { int c; GfxElement gfx; if ((gfx = new GfxElement()) == null) return null; if ((Machine.orientation & ORIENTATION_SWAP_XY) != 0) { gfx.width = gl.height; gfx.height = gl.width; } else { gfx.width = gl.width; gfx.height = gl.height; } gfx.line_modulo = gfx.width; gfx.char_modulo = gfx.line_modulo * gfx.height; if ((gfx.gfxdata = new byte[gl.total * gfx.char_modulo]) == null) { gfx = null; return null; } gfx.total_elements = gl.total; gfx.color_granularity = 1 << gl.planes; gfx.pen_usage = null; /* need to make sure this is NULL if the next test fails) */ if (gfx.color_granularity <= 32) /* can't handle more than 32 pens */ gfx.pen_usage = new uint[gfx.total_elements]; /* no need to check for failure, the code can work without pen_usage */ for (c = 0; c < gl.total; c++) decodechar(gfx, c, src, gl); return gfx; }
static int vh_open() { for (int i = 0; i < MAX_GFX_ELEMENTS; i++) Machine.gfx[i] = null; Machine.uifont = null; if (palette_start() != 0) { vh_close(); return 1; } /* convert the gfx ROMs into character sets. This is done BEFORE calling the driver's */ /* convert_color_prom() routine (in palette_init()) because it might need to check the */ /* Machine.gfx[] data */ if (drv.gfxdecodeinfo != null) { for (int i = 0; i < drv.gfxdecodeinfo.Length && i < MAX_GFX_ELEMENTS && drv.gfxdecodeinfo[i].memory_region != -1; i++) { int reglen = 8 * memory_region_length(drv.gfxdecodeinfo[i].memory_region); GfxLayout glcopy = new GfxLayout(); glcopy = drv.gfxdecodeinfo[i].gfxlayout; if (IS_FRAC(glcopy.total)) glcopy.total = (uint)(reglen / glcopy.charincrement * FRAC_NUM(glcopy.total) / FRAC_DEN(glcopy.total)); for (int j = 0; j < glcopy.planeoffset.Length && j < MAX_GFX_PLANES; j++) { if (IS_FRAC(glcopy.planeoffset[j])) { glcopy.planeoffset[j] = (uint)(FRAC_OFFSET(glcopy.planeoffset[j]) + reglen * FRAC_NUM(glcopy.planeoffset[j]) / FRAC_DEN(glcopy.planeoffset[j])); } } for (int j = 0; j < MAX_GFX_SIZE; j++) { if (j < glcopy.xoffset.Length && IS_FRAC(glcopy.xoffset[j])) { glcopy.xoffset[j] = (uint)(FRAC_OFFSET(glcopy.xoffset[j]) + reglen * FRAC_NUM(glcopy.xoffset[j]) / FRAC_DEN(glcopy.xoffset[j])); } if (j < glcopy.yoffset.Length && IS_FRAC(glcopy.yoffset[j])) { glcopy.yoffset[j] = (uint)(FRAC_OFFSET(glcopy.yoffset[j]) + reglen * FRAC_NUM(glcopy.yoffset[j]) / FRAC_DEN(glcopy.yoffset[j])); } } if ((Machine.gfx[i] = decodegfx(new _BytePtr(memory_region(drv.gfxdecodeinfo[i].memory_region), drv.gfxdecodeinfo[i].start), glcopy)) == null) { vh_close(); return 1; } if (Machine.remapped_colortable != null) Machine.gfx[i].colortable = new UShortSubArray(Machine.remapped_colortable, (int)drv.gfxdecodeinfo[i].color_codes_start); Machine.gfx[i].total_colors = drv.gfxdecodeinfo[i].total_color_codes; } } /* create the display bitmap, and allocate the palette */ if ((Machine.scrbitmap = osd_create_display( drv.screen_width, drv.screen_height, Machine.color_depth, drv.video_attributes)) == null) { vh_close(); return 1; } blit_buffer = new uint[Machine.scrbitmap.width * Machine.scrbitmap.height]; back_buffer = new byte[Machine.scrbitmap.line[0].buffer.Length]; /* create spriteram buffers if necessary */ if ((drv.video_attributes & VIDEO_BUFFERS_SPRITERAM) != 0) { if (Generic.spriteram_size[0] != 0) { Generic.buffered_spriteram = new _BytePtr(Generic.spriteram_size[0]); if (Generic.buffered_spriteram[0] != 0) { vh_close(); return 1; } if (Generic.spriteram_2_size[0] != 0) Generic.buffered_spriteram_2 = new _BytePtr(Generic.spriteram_2_size[0]); if (Generic.spriteram_2_size[0] != 0 && Generic.buffered_spriteram_2 != null) { vh_close(); return 1; } } else { printf("vh_open(): Video buffers spriteram but spriteram_size is 0\n"); Generic.buffered_spriteram = null; Generic.buffered_spriteram_2 = null; } } /* build our private user interface font */ /* This must be done AFTER osd_create_display() so the function knows the */ /* resolution we are running at and can pick a different font depending on it. */ /* It must be done BEFORE palette_init() because that will also initialize */ /* (through osd_allocate_colors()) the uifont colortable. */ if ((Machine.uifont = builduifont()) == null) { vh_close(); return 1; } /* initialize the palette - must be done after osd_create_display() */ if (palette_init() != 0) { vh_close(); return 1; } osd_create_backbuffer(Machine.scrbitmap.width, Machine.scrbitmap.height); return 0; }