Beispiel #1
0
 static void blockmove_transmask16(_BytePtr srcdata, int srcwidth, int srcheight, int srcmodulo, _ShortPtr dstdata, int dstmodulo, UShortSubArray paldata, int transmask) { throw new Exception(); }
Beispiel #2
0
 static void blockmove_pen_table_flipx16(_BytePtr srcdata, int srcwidth, int srcheight, int srcmodulo, _ShortPtr dstdata, int dstmodulo, UShortSubArray paldata, int transcolor) { throw new Exception(); }
Beispiel #3
0
        static void blockmove_opaque16(_BytePtr srcdata, int srcwidth, int srcheight, int srcmodulo, _ShortPtr dstdata, int dstmodulo, UShortSubArray paldata)
        {
            //blockmove_opaque8(srcdata, srcwidth, srcheight, srcmodulo, (_BytePtr)dstdata, dstmodulo, paldata);
            //return;
            int end;
            srcmodulo -= srcwidth;
            dstmodulo -= srcwidth;
            while (srcheight != 0)
            {
                end = dstdata.offset + srcwidth;
                while (dstdata.offset <= end - 8)
                {
                    dstdata.write16(0, paldata[srcdata[0]]);
                    dstdata.write16(1, paldata[srcdata[1]]);
                    dstdata.write16(2, paldata[srcdata[2]]);
                    dstdata.write16(3, paldata[srcdata[3]]);
                    dstdata.write16(4, paldata[srcdata[4]]);
                    dstdata.write16(5, paldata[srcdata[5]]);
                    dstdata.write16(6, paldata[srcdata[6]]);
                    dstdata.write16(7, paldata[srcdata[7]]);
                    dstdata.offset += 8 * 2;
                    srcdata.offset++;
                }
                while (dstdata.offset < end)
                {
                    dstdata.write16(0, paldata[srcdata[0]]);
                    srcdata.offset++;
                    dstdata.offset += 2;
                }
                srcdata.inc(srcmodulo);
                dstdata.inc(dstmodulo);
                srcheight--;
            }

        }
Beispiel #4
0
 static void blockmove_opaque_flipx16(_BytePtr srcdata, int srcwidth, int srcheight, int srcmodulo, _ShortPtr dstdata, int dstmodulo, UShortSubArray paldata) { throw new Exception(); }
Beispiel #5
0
 static void blockmove_transthrough_flipx8(_BytePtr srcdata, int srcwidth, int srcheight, int srcmodulo, _BytePtr dstdata, int dstmodulo, UShortSubArray paldata, int transcolor)
 {
     FuncDict["blockmove_transthrough_flipx8"] = "blockmove_transthrough_flipx8";
     int end;
     srcmodulo += srcwidth;
     dstmodulo -= srcwidth;
     //srcdata += srcwidth-1; 
     while (srcheight != 0)
     {
         end = dstdata.offset + srcwidth;
         while (dstdata.offset < end)
         {
             if (dstdata[0] == transcolor)
                 dstdata[0] = (byte)paldata[srcdata[0]];
             srcdata.offset--;
             dstdata.offset++;
         }
         srcdata.offset += srcmodulo;
         dstdata.offset += dstmodulo;
         srcheight--;
     }
 }
Beispiel #6
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;
         }
     }
 }
Beispiel #7
0
        static void blockmove_transmask8(_BytePtr srcdata, int srcwidth, int srcheight, int srcmodulo, _BytePtr dstdata, int dstmodulo, UShortSubArray paldata, int transmask)
        {
            int end;
            _IntPtr sd4;

            srcmodulo -= srcwidth;
            dstmodulo -= srcwidth;

            while (srcheight != 0)
            {
                end = dstdata.offset + srcwidth;
                while (((long)srcdata.offset & 3) != 0 && dstdata.offset < end)	/* longword align */
                {
                    int col;

                    col = srcdata[0]; srcdata.offset++;
                    if (((1 << col) & transmask) == 0) dstdata[0] = (byte)paldata[col];
                    dstdata.offset++;
                }
                sd4 = new _IntPtr(srcdata);
                while (dstdata.offset <= end - 4)
                {
                    int col;
                    uint col4;

                    col4 = sd4.read32(0); sd4.offset += 4;
                    col = (int)((col4 >> 0) & 0xff);
                    if (((1 << col) & transmask) == 0) dstdata[BL0] = (byte)paldata[col];
                    col = (int)((col4 >> 8) & 0xff);
                    if (((1 << col) & transmask) == 0) dstdata[BL1] = (byte)paldata[col];
                    col = (int)((col4 >> 16) & 0xff);
                    if (((1 << col) & transmask) == 0) dstdata[BL2] = (byte)paldata[col];
                    col = (int)((col4 >> 24) & 0xff);
                    if (((1 << col) & transmask) == 0) dstdata[BL3] = (byte)paldata[col];
                    dstdata.offset += 4;
                }
                srcdata = new _BytePtr(sd4);
                while (dstdata.offset < end)
                {
                    int col;

                    col = srcdata[0]; srcdata.offset++;
                    if (((1 << col) & transmask) == 0) dstdata[0] = (byte)paldata[col];
                    dstdata.offset++;
                }

                srcdata.offset += srcmodulo;
                dstdata.offset += dstmodulo;
                srcheight--;
            }
        }
Beispiel #8
0
        static void blockmove_transcolor_flipx8(_BytePtr srcdata, int srcwidth, int srcheight, int srcmodulo, _BytePtr dstdata, int dstmodulo, UShortSubArray paldata, int transcolor)
        {
            FuncDict["blockmove_transcolor_flipx8"] = "blockmove_transcolor_flipx8";
            int end;

            int offset = paldata.offset;
            int length = Machine.game_colortable.Length - offset;
            ArraySegment<ushort> lookupdata = new ArraySegment<ushort>(Machine.game_colortable, offset, length);

            srcmodulo += srcwidth;
            dstmodulo -= srcwidth; //srcdata += srcwidth-1; 
            while (srcheight != 0)
            {
                end = (int)(dstdata.offset + srcwidth);
                while (dstdata.offset < end)
                {
                    if (lookupdata.Array[lookupdata.Offset+srcdata.buffer[srcdata.offset]] != transcolor)
                        dstdata.buffer[dstdata.offset] = (byte)paldata[srcdata.buffer[srcdata.offset]];
                    srcdata.offset--;
                    dstdata.offset++;
                }
                srcdata.offset += srcmodulo;
                dstdata.offset += dstmodulo;
                srcheight--;
            }
        }
Beispiel #9
0
 static void blockmove_opaque_flipx8(_BytePtr srcdata, int srcwidth, int srcheight, int srcmodulo, _BytePtr dstdata, int dstmodulo, UShortSubArray paldata)
 {
     FuncDict["blockmove_opaque_flipx8"] = "blockmove_opaque_flipx8";
     int end;
     srcmodulo += srcwidth;
     dstmodulo -= srcwidth; //srcdata += srcwidth-1;
     while (srcheight != 0)
     {
         end = (int)(dstdata.offset + srcwidth);
         while (dstdata.offset <= end - 8)
         {
             srcdata.offset = ((int)srcdata.offset - 8);
             dstdata.buffer[dstdata.offset] = (byte)paldata[srcdata.buffer[srcdata.offset + 8]];
             dstdata.buffer[dstdata.offset + 1] = (byte)paldata[srcdata.buffer[srcdata.offset + 7]];
             dstdata.buffer[dstdata.offset + 2] = (byte)paldata[srcdata.buffer[srcdata.offset + 6]];
             dstdata.buffer[dstdata.offset + 3] = (byte)paldata[srcdata.buffer[srcdata.offset + 5]];
             dstdata.buffer[dstdata.offset + 4] = (byte)paldata[srcdata.buffer[srcdata.offset + 4]];
             dstdata.buffer[dstdata.offset + 5] = (byte)paldata[srcdata.buffer[srcdata.offset + 3]];
             dstdata.buffer[dstdata.offset + 6] = (byte)paldata[srcdata.buffer[srcdata.offset + 2]];
             dstdata.buffer[dstdata.offset + 7] = (byte)paldata[srcdata.buffer[srcdata.offset + 1]];
             dstdata.offset += 8;
         }
         while (dstdata.offset < end)
         {
             dstdata.buffer[dstdata.offset] = (byte)paldata[srcdata.buffer[srcdata.offset]];
             dstdata.offset++;
             srcdata.offset--;
         }
         srcdata.offset += srcmodulo;
         dstdata.offset += dstmodulo;
         srcheight--;
     }
 }
Beispiel #10
0
        static void blockmove_transpen_flipx8(_BytePtr srcdata, int srcwidth, int srcheight, int srcmodulo, _BytePtr dstdata, int dstmodulo, UShortSubArray paldata, int transpen)
        {
            FuncDict["blockmove_transpen_flipx8"] = "blockmove_transpen_flipx8";
            int end;
            _IntPtr sd4 = new _IntPtr(srcdata);
            srcmodulo += srcwidth;
            dstmodulo -= srcwidth;
            srcdata.offset -= 3;
            int trans4 = transpen * 0x01010101;
            while (srcheight != 0)
            {
                end = dstdata.offset + srcwidth;
                while ((srcdata.offset & 3) != 0 && dstdata.offset < end) /* longword align */
                {
                    int col = srcdata[3];
                    srcdata.offset--;
                    if (col != transpen)
                        dstdata[0] = (byte)paldata[col];
                    dstdata.offset++;
                }
                sd4.offset = srcdata.offset;
                while (dstdata.offset <= end - 4)
                {
                    uint col4;
                    if ((col4 = sd4.read32(0)) != trans4)
                    {
                        uint xod4 = (uint)(col4 ^ trans4);
                        if ((xod4 & 0xff000000) != 0)
                            dstdata[BL0] = (byte)paldata[(int)col4 >> 24];
                        if ((xod4 & 0x00ff0000) != 0)
                            dstdata[BL1] = (byte)paldata[(int)(col4 >> 16) & 0xff];
                        if ((xod4 & 0x0000ff00) != 0)
                            dstdata[BL2] = (byte)paldata[(int)(col4 >> 8) & 0xff];
                        if ((xod4 & 0x000000ff) != 0)
                            dstdata[BL3] = (byte)paldata[((int)col4 & 0xff)];
                    }
                    sd4.offset -= 4;
                    dstdata.offset += 4;
                }

                srcdata.offset = sd4.offset;
                while (dstdata.offset < end)
                {
                    int col = srcdata[3];
                    srcdata.offset--;
                    if (col != transpen)
                        dstdata[0] = (byte)paldata[col];
                    dstdata.offset++;

                }
                srcdata.offset += srcmodulo;
                dstdata.offset += dstmodulo;
                srcheight--;
            }
        }
Beispiel #11
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;
                            }
                        }
                    }
                }
            }
        }
Beispiel #12
0
        static void draw_tile(osd_bitmap pixmap, int col, int row, int tile_width, int tile_height, _BytePtr pendata, UShortSubArray paldata, byte flags)
        {
            int x, sx = tile_width * col;
            int sy, y1, y2, dy;
            int pi = 0;
            if (Machine.scrbitmap.depth == 16)
            {
                if ((flags & TILE_FLIPY) != 0)
                {
                    y1 = tile_height * row + tile_height - 1;
                    y2 = y1 - tile_height;
                    dy = -1;
                }
                else
                {
                    y1 = tile_height * row;
                    y2 = y1 + tile_height;
                    dy = 1;
                }

                if ((flags & TILE_FLIPX) != 0)
                {
                    tile_width--;
                    for (sy = y1; sy != y2; sy += dy)
                    {
                        _ShortPtr dest = new _ShortPtr(pixmap.line[sy], sx);
                        for (x = tile_width; x >= 0; x--)
                        {
                            dest.write16(x, paldata[pendata[pi++]]);
                        }
                    }
                }
                else
                {
                    for (sy = y1; sy != y2; sy += dy)
                    {
                        _ShortPtr dest = new _ShortPtr(pixmap.line[sy], sx);
                        for (x = 0; x < tile_width; x++)
                        {
                            dest.write16(x, paldata[pendata[pi++]]);
                        }
                    }
                }
            }
            else
            {
                if ((flags & TILE_FLIPY) != 0)
                {
                    y1 = tile_height * row + tile_height - 1;
                    y2 = y1 - tile_height;
                    dy = -1;
                }
                else
                {
                    y1 = tile_height * row;
                    y2 = y1 + tile_height;
                    dy = 1;
                }

                if ((flags & TILE_FLIPX) != 0)
                {
                    tile_width--;
                    for (sy = y1; sy != y2; sy += dy)
                    {
                        _BytePtr dest = new _BytePtr(pixmap.line[sy], sx);
                        for (x = tile_width; x >= 0; x--)
                        { dest[x] = (byte)paldata[pendata[pi++]]; }
                    }
                }
                else
                {
                    for (sy = y1; sy != y2; sy += dy)
                    {
                        _BytePtr dest = new _BytePtr(pixmap.line[sy], sx);
                        for (x = 0; x < tile_width; x++)
                        { dest[x] = (byte)paldata[pendata[pi++]]; }
                    }
                }
            }
        }
Beispiel #13
0
 public UShortSubArray(UShortSubArray subarray, int offset = 0)
 {
     this.buffer = subarray.buffer;
     this.offset = subarray.offset + offset;
 }
Beispiel #14
0
        static int palette_start()
        {
            int num;

            game_palette = new byte[3 * Machine.drv.total_colors];
            palette_map = new ushort[Machine.drv.total_colors];
            if (Machine.drv.color_table_len != 0)
            {
                Machine.game_colortable = new ushort[(int)Machine.drv.color_table_len];
                Machine.remapped_colortable = new ushort[Machine.drv.color_table_len];// new UShortSubArray((int)Machine.drv.color_table_len);
            }
            else
            {
                Machine.game_colortable = null;
                Machine.remapped_colortable = null;
            }

            if (Machine.color_depth == 16 || (Machine.gamedrv.flags & GAME_REQUIRES_16BIT) != 0)
            {
                if (Machine.color_depth == 8 || Machine.drv.total_colors > 65532)
                    use_16bit = STATIC_16BIT;
                else
                    use_16bit = PALETTIZED_16BIT;
            }
            else
                use_16bit = NO_16BIT;

            switch (use_16bit)
            {
                case NO_16BIT:
                    if ((Machine.drv.video_attributes & VIDEO_MODIFIES_PALETTE) != 0)
                        total_shrinked_pens = DYNAMIC_MAX_PENS;
                    else
                        total_shrinked_pens = STATIC_MAX_PENS;
                    break;
                case STATIC_16BIT:
                    total_shrinked_pens = 32768;
                    break;
                case PALETTIZED_16BIT:
                    total_shrinked_pens = (int)(Machine.drv.total_colors + RESERVED_PENS);
                    break;
            }

            shrinked_pens = new ushort[total_shrinked_pens];
            shrinked_palette = new byte[3 * total_shrinked_pens];

            Machine.pens = new ushort[Machine.drv.total_colors];

            if ((Machine.drv.video_attributes & VIDEO_MODIFIES_PALETTE) != 0)
            {
                /* if the palette changes dynamically, */
                /* we'll need the usage arrays to help in shrinking. */
                palette_used_colors = new _BytePtr(((int)((1 + 1 + 1 + 3 + 1) * Machine.drv.total_colors * sizeof(byte))));
                pen_visiblecount = new IntSubArray((int)(2 * Machine.drv.total_colors));

                if (palette_used_colors == null || pen_visiblecount == null)
                {
                    palette_stop();
                    return 1;
                }

                old_used_colors = new _BytePtr(palette_used_colors, (int)Machine.drv.total_colors * sizeof(byte));
                just_remapped = new _BytePtr(old_used_colors, (int)Machine.drv.total_colors * sizeof(byte));
                new_palette = new _BytePtr(just_remapped, (int)Machine.drv.total_colors * sizeof(byte));
                palette_dirty = new _BytePtr(new_palette, 3 * (int)Machine.drv.total_colors * sizeof(byte));
                memset(palette_used_colors, PALETTE_COLOR_USED, (int)Machine.drv.total_colors * sizeof(byte));
                memset(old_used_colors, PALETTE_COLOR_UNUSED, (int)Machine.drv.total_colors * sizeof(byte));
                memset(palette_dirty, 0, (int)(Machine.drv.total_colors * sizeof(byte)));
                pen_cachedcount = new IntSubArray(pen_visiblecount, (int)Machine.drv.total_colors);
                for (int i = 0; i < Machine.drv.total_colors; i++)
                {
                    pen_visiblecount[i] = 0;
                    pen_cachedcount[i] = 0;
                }
            }
            else palette_used_colors = old_used_colors = just_remapped = new_palette = palette_dirty = null;

            if (Machine.color_depth == 8) num = 256;
            else num = 65536;
            palette_shadow_table = new UShortSubArray(2 * num);
            if (palette_shadow_table == null)
            {
                palette_stop();
                return 1;
            }
            palette_highlight_table = new UShortSubArray(palette_shadow_table, num);
            for (int i = 0; i < num; i++)
            {
                palette_shadow_table[i] = (ushort)i;
                palette_highlight_table[i] = (ushort)i;
            }

            if ((Machine.drv.color_table_len != 0 && (Machine.game_colortable == null || Machine.remapped_colortable == null))
                    || game_palette == null || palette_map == null
                    || shrinked_pens == null || shrinked_palette == null || Machine.pens == null)
            {
                palette_stop();
                return 1;
            }

            return 0;
        }
Beispiel #15
0
 static void palette_stop()
 {
     //free(palette_used_colors);
     palette_used_colors = old_used_colors = just_remapped = new_palette = palette_dirty = null;
     //free(pen_visiblecount);
     pen_visiblecount = null;
     //free(game_palette);
     game_palette = null;
     //free(palette_map);
     palette_map = null;
     //free(Machine.game_colortable);
     Machine.game_colortable = null;
     //free(Machine.remapped_colortable);
     Machine.remapped_colortable = null;
     //	free(shrinked_pens);
     shrinked_pens = null;
     //	free(shrinked_palette);
     shrinked_palette = null;
     //free(Machine.pens);
     Machine.pens = null;
     //free(palette_shadow_table);
     palette_shadow_table = null;
 }