Ejemplo n.º 1
0
        private void OnSelectedItemsChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                bool first = true;
                foreach (GfxElement element in e.NewItems)
                {
                    if (first && m_selectedItem != element)
                    {
                        m_selectedItem = element;
                        OnPropertyChanged("SelectedItem");
                    }

                    element.IsSelected = true;
                    first = false;
                }
            }
            if (e.Action == NotifyCollectionChangedAction.Remove)
            {
                foreach (GfxElement element in e.OldItems)
                {
                    element.IsSelected = false;
                }
            }
            if (e.Action == NotifyCollectionChangedAction.Reset)
            {
                foreach (GfxElement element in e.OldItems)
                {
                    element.IsSelected = false;
                }
            }
        }
Ejemplo n.º 2
0
 static void drawgfx_core16(osd_bitmap dest, GfxElement gfx, uint code, uint color, bool flipx, bool flipy, int sx, int sy, rectangle clip, int transparency, int transparent_color)
 {
     int ox; int oy; int ex; int ey;
     /* check bounds */
     ox = sx; oy = sy;
     ex = sx + gfx.width - 1; if (sx < 0) sx = 0;
     if (clip != null && sx < clip.min_x) sx = clip.min_x;
     if (ex >= dest.width) ex = dest.width - 1;
     if (clip != null && ex > clip.max_x) ex = clip.max_x;
     if (sx > ex) return; ey = sy + gfx.height - 1;
     if (sy < 0) sy = 0;
     if (clip != null && sy < clip.min_y) sy = clip.min_y;
     if (ey >= dest.height) ey = dest.height - 1;
     if (clip != null && ey > clip.max_y) ey = clip.max_y;
     if (sy > ey) return; osd_mark_dirty(sx, sy, ex, ey, 0); /* ASG 971011 */
     {
         _BytePtr sd = new _BytePtr(gfx.gfxdata, (int)(code * gfx.char_modulo)); /* source data */
         int sw = ex - sx + 1; /* source width */
         int sh = ey - sy + 1; /* source height */
         int sm = gfx.line_modulo; /* source modulo */
         _ShortPtr dd = new _ShortPtr(dest.line[sy], sx); /* dest data */
         int dm = dest.line[1].offset - dest.line[0].offset; /* dest modulo */
         UShortSubArray paldata = new UShortSubArray(gfx.colortable, (int)((gfx.color_granularity * color)));
         if (flipx)
         {
             sd.offset += gfx.width - 1 - (sx - ox);
         }
         else
             sd.offset += (sx - ox); if (flipy)
         {
             sd.offset += sm * (gfx.height - 1 - (sy - oy));
             sm = -sm;
         }
         else
             sd.offset += sm * (sy - oy); switch (transparency)
         {
             case TRANSPARENCY_NONE:
                 if (flipx) blockmove_opaque_flipx16(sd, sw, sh, sm, dd, dm, paldata);
                 else
                     blockmove_opaque16(sd, sw, sh, sm, dd, dm, paldata);
                 break;
             case TRANSPARENCY_PEN:
                 if (flipx)
                     blockmove_transpen_flipx16(sd, sw, sh, sm, dd, dm, paldata, transparent_color);
                 else
                     blockmove_transpen16(sd, sw, sh, sm, dd, dm, paldata, transparent_color);
                 break;
             case TRANSPARENCY_PENS: if (flipx)
                     blockmove_transmask_flipx16(sd, sw, sh, sm, dd, dm, paldata, transparent_color);
                 else
                     blockmove_transmask16(sd, sw, sh, sm, dd, dm, paldata, transparent_color);
                 break;
             case TRANSPARENCY_COLOR: if (flipx)
                     blockmove_transcolor_flipx16(sd, sw, sh, sm, dd, dm, paldata, transparent_color);
                 else
                     blockmove_transcolor16(sd, sw, sh, sm, dd, dm, paldata, transparent_color);
                 break;
             case TRANSPARENCY_THROUGH: if (flipx)
                     blockmove_transthrough_flipx16(sd, sw, sh, sm, dd, dm, paldata, transparent_color);
                 else
                     blockmove_transthrough16(sd, sw, sh, sm, dd, dm, paldata, transparent_color);
                 break;
             case TRANSPARENCY_PEN_TABLE: if (flipx)
                     blockmove_pen_table_flipx16(sd, sw, sh, sm, dd, dm, paldata, transparent_color);
                 else
                     blockmove_pen_table16(sd, sw, sh, sm, dd, dm, paldata, transparent_color);
                 break;
         }
     }
 }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
        public static void drawgfx(osd_bitmap dest, GfxElement gfx, uint code, uint color, bool flipx, bool flipy, int sx, int sy, rectangle clip, int transparency, int transparent_color)
        {
            rectangle myclip = new rectangle();

            if (gfx == null)
            {
                usrintf_showmessage("drawgfx() gfx == 0");
                return;
            }
            if (gfx.colortable == null)
            {
                usrintf_showmessage("drawgfx() gfx.colortable == 0");
                return;
            }

            code %= gfx.total_elements;
            color %= (uint)gfx.total_colors;

            if (gfx.pen_usage != null && (transparency == TRANSPARENCY_PEN || transparency == TRANSPARENCY_PENS))
            {
                int transmask = 0;

                if (transparency == TRANSPARENCY_PEN)
                {
                    transmask = 1 << transparent_color;
                }
                else if (transparency == TRANSPARENCY_PENS)
                {
                    transmask = transparent_color;
                }

                if ((gfx.pen_usage[(int)code] & ~transmask) == 0)
                    /* character is totally transparent, no need to draw */
                    return;
                else if ((gfx.pen_usage[(int)code] & transmask) == 0 && transparency != TRANSPARENCY_THROUGH && transparency != TRANSPARENCY_PEN_TABLE)
                    /* character is totally opaque, can disable transparency */
                    transparency = TRANSPARENCY_NONE;
            }

            if ((Machine.orientation & ORIENTATION_SWAP_XY) != 0)
            {
                int temp;

                temp = sx;
                sx = sy;
                sy = temp;

                bool tempb = flipx;
                flipx = flipy;
                flipy = tempb;

                if (clip != null)
                {
                    /* clip and myclip might be the same, so we need a temporary storage */
                    temp = clip.min_x;
                    myclip.min_x = clip.min_y;
                    myclip.min_y = temp;
                    temp = clip.max_x;
                    myclip.max_x = clip.max_y;
                    myclip.max_y = temp;
                    clip = myclip;
                }
            }
            if ((Machine.orientation & ORIENTATION_FLIP_X) != 0)
            {
                sx = dest.width - gfx.width - sx;
                if (clip != null)
                {
                    int temp;


                    /* clip and myclip might be the same, so we need a temporary storage */
                    temp = clip.min_x;
                    myclip.min_x = dest.width - 1 - clip.max_x;
                    myclip.max_x = dest.width - 1 - temp;
                    myclip.min_y = clip.min_y;
                    myclip.max_y = clip.max_y;
                    clip = myclip;
                }
#if !PREROTATE_GFX
                flipx = !flipx;
#endif
            }
            if ((Machine.orientation & ORIENTATION_FLIP_Y) != 0)
            {
                sy = dest.height - gfx.height - sy;
                if (clip != null)
                {
                    int temp;


                    myclip.min_x = clip.min_x;
                    myclip.max_x = clip.max_x;
                    /* clip and myclip might be the same, so we need a temporary storage */
                    temp = clip.min_y;
                    myclip.min_y = dest.height - 1 - clip.max_y;
                    myclip.max_y = dest.height - 1 - temp;
                    clip = myclip;
                }
#if !PREROTATE_GFX
                flipy = !flipy;
#endif
            }

            if (dest.depth != 16)
                drawgfx_core8(dest, gfx, code, color, flipx, flipy, sx, sy, clip, transparency, transparent_color);
            else
                drawgfx_core16(dest, gfx, code, color, flipx, flipy, sx, sy, clip, transparency, transparent_color);

        }
Ejemplo n.º 5
0
        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;
                }
            }
        }
Ejemplo n.º 6
0
        public static void drawgfxzoom(osd_bitmap dest_bmp, GfxElement gfx, uint code, uint color, bool flipx, bool flipy, int sx, int sy, rectangle clip, int transparency, int transparent_color, int scalex, int scaley)
        {
            FuncDict["drawgfxzoom"] = "drawgfxzoom";
            rectangle myclip = new rectangle();


            /* only support TRANSPARENCY_PEN and TRANSPARENCY_COLOR */
            if (transparency != TRANSPARENCY_PEN && transparency != TRANSPARENCY_COLOR)
                return;

            if (transparency == TRANSPARENCY_COLOR)
                transparent_color = Machine.pens[transparent_color];


            /*
            scalex and scaley are 16.16 fixed point numbers
            1<<15 : shrink to 50%
            1<<16 : uniform scale
            1<<17 : double to 200%
            */


            if ((Machine.orientation & ORIENTATION_SWAP_XY) != 0)
            {
                int temp;

                temp = sx;
                sx = sy;
                sy = temp;

                var tempb = flipx;
                flipx = flipy;
                flipy = tempb;

                temp = scalex;
                scalex = scaley;
                scaley = temp;

                if (clip != null)
                {
                    /* clip and myclip might be the same, so we need a temporary storage */
                    temp = clip.min_x;
                    myclip.min_x = clip.min_y;
                    myclip.min_y = temp;
                    temp = clip.max_x;
                    myclip.max_x = clip.max_y;
                    myclip.max_y = temp;
                    clip = myclip;
                }
            }
            if ((Machine.orientation & ORIENTATION_FLIP_X) != 0)
            {
                sx = dest_bmp.width - ((gfx.width * scalex + 0x7fff) >> 16) - sx;
                if (clip != null)
                {
                    int temp;


                    /* clip and myclip might be the same, so we need a temporary storage */
                    temp = clip.min_x;
                    myclip.min_x = dest_bmp.width - 1 - clip.max_x;
                    myclip.max_x = dest_bmp.width - 1 - temp;
                    myclip.min_y = clip.min_y;
                    myclip.max_y = clip.max_y;
                    clip = myclip;
                }
#if !PREROTATE_GFX
                flipx = !flipx;
#endif
            }
            if ((Machine.orientation & ORIENTATION_FLIP_Y) != 0)
            {
                sy = dest_bmp.height - ((gfx.height * scaley + 0x7fff) >> 16) - sy;
                if (clip != null)
                {
                    int temp;


                    myclip.min_x = clip.min_x;
                    myclip.max_x = clip.max_x;
                    /* clip and myclip might be the same, so we need a temporary storage */
                    temp = clip.min_y;
                    myclip.min_y = dest_bmp.height - 1 - clip.max_y;
                    myclip.max_y = dest_bmp.height - 1 - temp;
                    clip = myclip;
                }
#if !PREROTATE_GFX
                flipy = !flipy;
#endif
            }

            /* KW 991012 -- Added code to force clip to bitmap boundary */
            if (clip != null)
            {
                myclip.min_x = clip.min_x;
                myclip.max_x = clip.max_x;
                myclip.min_y = clip.min_y;
                myclip.max_y = clip.max_y;

                if (myclip.min_x < 0) myclip.min_x = 0;
                if (myclip.max_x >= dest_bmp.width) myclip.max_x = dest_bmp.width - 1;
                if (myclip.min_y < 0) myclip.min_y = 0;
                if (myclip.max_y >= dest_bmp.height) myclip.max_y = dest_bmp.height - 1;

                clip = myclip;
            }


            /* ASG 980209 -- added 16-bit version */
            if (dest_bmp.depth != 16)
            {
                if (gfx != null && gfx.colortable != null)
                {
                    UShortSubArray pal = new UShortSubArray(gfx.colortable, (int)(gfx.color_granularity * (color % gfx.total_colors))); /* ASG 980209 */
                    int source_base = (int)((code % gfx.total_elements) * gfx.height);

                    int sprite_screen_height = (scaley * gfx.height + 0x8000) >> 16;
                    int sprite_screen_width = (scalex * gfx.width + 0x8000) >> 16;

                    /* compute sprite increment per screen pixel */
                    int dx = (gfx.width << 16) / sprite_screen_width;
                    int dy = (gfx.height << 16) / sprite_screen_height;

                    int ex = sx + sprite_screen_width;
                    int ey = sy + sprite_screen_height;

                    int x_index_base;
                    int y_index;

                    if (flipx)
                    {
                        x_index_base = (sprite_screen_width - 1) * dx;
                        dx = -dx;
                    }
                    else
                    {
                        x_index_base = 0;
                    }

                    if (flipy)
                    {
                        y_index = (sprite_screen_height - 1) * dy;
                        dy = -dy;
                    }
                    else
                    {
                        y_index = 0;
                    }

                    if (clip != null)
                    {
                        if (sx < clip.min_x)
                        { /* clip left */
                            int pixels = clip.min_x - sx;
                            sx += pixels;
                            x_index_base += pixels * dx;
                        }
                        if (sy < clip.min_y)
                        { /* clip top */
                            int pixels = clip.min_y - sy;
                            sy += pixels;
                            y_index += pixels * dy;
                        }
                        /* NS 980211 - fixed incorrect clipping */
                        if (ex > clip.max_x + 1)
                        { /* clip right */
                            int pixels = ex - clip.max_x - 1;
                            ex -= pixels;
                        }
                        if (ey > clip.max_y + 1)
                        { /* clip bottom */
                            int pixels = ey - clip.max_y - 1;
                            ey -= pixels;
                        }
                    }

                    if (ex > sx)
                    { /* skip if inner loop doesn't draw anything */
                        int y;

                        /* case 1: TRANSPARENCY_PEN */
                        if (transparency == TRANSPARENCY_PEN)
                        {
                            for (y = sy; y < ey; y++)
                            {
                                _BytePtr source = new _BytePtr(gfx.gfxdata, (source_base + (y_index >> 16)) * gfx.line_modulo);
                                _BytePtr dest = dest_bmp.line[y];

                                int x, x_index = x_index_base;
                                for (x = sx; x < ex; x++)
                                {
                                    int c = source[x_index >> 16];
                                    if (c != transparent_color) dest[x] = (byte)pal[c];
                                    x_index += dx;
                                }

                                y_index += dy;
                            }
                        }

                        /* case 2: TRANSPARENCY_COLOR */
                        else if (transparency == TRANSPARENCY_COLOR)
                        {
                            for (y = sy; y < ey; y++)
                            {
                                _BytePtr source = new _BytePtr(gfx.gfxdata, (source_base + (y_index >> 16)) * gfx.line_modulo);
                                _BytePtr dest = dest_bmp.line[y];

                                int x, x_index = x_index_base;
                                for (x = sx; x < ex; x++)
                                {
                                    int c = pal[source[x_index >> 16]];
                                    if (c != transparent_color) dest[x] = (byte)c;
                                    x_index += dx;
                                }

                                y_index += dy;
                            }
                        }
                    }

                }
            }

            /* ASG 980209 -- new 16-bit part */
            else
            {
                if (gfx != null && gfx.colortable != null)
                {
                    UShortSubArray pal = new UShortSubArray(gfx.colortable, (int)(gfx.color_granularity * (color % gfx.total_colors))); /* ASG 980209 */
                    int source_base = (int)((code % gfx.total_elements) * gfx.height);

                    int sprite_screen_height = (scaley * gfx.height + 0x8000) >> 16;
                    int sprite_screen_width = (scalex * gfx.width + 0x8000) >> 16;

                    /* compute sprite increment per screen pixel */
                    int dx = (gfx.width << 16) / sprite_screen_width;
                    int dy = (gfx.height << 16) / sprite_screen_height;

                    int ex = sx + sprite_screen_width;
                    int ey = sy + sprite_screen_height;

                    int x_index_base;
                    int y_index;

                    if (flipx)
                    {
                        x_index_base = (sprite_screen_width - 1) * dx;
                        dx = -dx;
                    }
                    else
                    {
                        x_index_base = 0;
                    }

                    if (flipy)
                    {
                        y_index = (sprite_screen_height - 1) * dy;
                        dy = -dy;
                    }
                    else
                    {
                        y_index = 0;
                    }

                    if (clip != null)
                    {
                        if (sx < clip.min_x)
                        { /* clip left */
                            int pixels = clip.min_x - sx;
                            sx += pixels;
                            x_index_base += pixels * dx;
                        }
                        if (sy < clip.min_y)
                        { /* clip top */
                            int pixels = clip.min_y - sy;
                            sy += pixels;
                            y_index += pixels * dy;
                        }
                        /* NS 980211 - fixed incorrect clipping */
                        if (ex > clip.max_x + 1)
                        { /* clip right */
                            int pixels = ex - clip.max_x - 1;
                            ex -= pixels;
                        }
                        if (ey > clip.max_y + 1)
                        { /* clip bottom */
                            int pixels = ey - clip.max_y - 1;
                            ey -= pixels;
                        }
                    }

                    if (ex > sx)
                    { /* skip if inner loop doesn't draw anything */
                        int y;

                        /* case 1: TRANSPARENCY_PEN */
                        if (transparency == TRANSPARENCY_PEN)
                        {
                            for (y = sy; y < ey; y++)
                            {
                                _BytePtr source = new _BytePtr(gfx.gfxdata, (source_base + (y_index >> 16)) * gfx.line_modulo);
                                _ShortPtr dest = new _ShortPtr(dest_bmp.line[y]);

                                int x, x_index = x_index_base;
                                for (x = sx; x < ex; x++)
                                {
                                    int c = source[x_index >> 16];
                                    if (c != transparent_color) dest[x] = (byte)pal[c];
                                    x_index += dx;
                                }

                                y_index += dy;
                            }
                        }

                        /* case 2: TRANSPARENCY_COLOR */
                        else if (transparency == TRANSPARENCY_COLOR)
                        {
                            for (y = sy; y < ey; y++)
                            {
                                _BytePtr source = new _BytePtr(gfx.gfxdata, (source_base + (y_index >> 16)) * gfx.line_modulo);
                                _ShortPtr dest = new _ShortPtr(dest_bmp.line[y]);

                                int x, x_index = x_index_base;
                                for (x = sx; x < ex; x++)
                                {
                                    int c = pal[source[x_index >> 16]];
                                    if (c != transparent_color) dest.write16(x, (ushort)c);
                                    x_index += dx;
                                }

                                y_index += dy;
                            }
                        }
                    }
                }
            }
        }