예제 #1
0
        private unsafe void BuildTiles16Gfx(IntPtr allgfx8Ptr, IntPtr allgfx16Ptr)
        {
            var gfx16Data = (byte *)allgfx16Ptr.ToPointer();
            var gfx8Data  = (byte *)allgfx8Ptr.ToPointer();

            int[] offsets = { 0, 8, 1024, 1032 };
            var   yy      = 0;
            var   xx      = 0;

            //TODO : Get rid of that magic number
            //I think that number doesn't actually appear anywhere
            //tiles must stay below that number that's it, if it goes over it will use junk data
            for (var i = 0; i < 3748; i++) //number of tiles16
            {
                //8x8 tile draw
                //gfx8 = 4bpp so everyting is /2
                var tiles = TilesLoader.tiles16[i];

                for (var tile = 0; tile < 4; tile++)
                {
                    Tile8Data info   = tiles.tile8data[tile];
                    int       offset = offsets[tile];

                    for (var y = 0; y < 8; y++)
                    {
                        for (var x = 0; x < 4; x++)
                        {
                            CopyTile(x, y, xx, yy, offset, info, gfx16Data, gfx8Data);
                        }
                    }
                }

                xx += 16;
                if (xx >= 128)
                {
                    yy += 2048;
                    xx  = 0;
                }
            }
        }
예제 #2
0
        private unsafe void CopyTile(int x, int y, int xx, int yy, int offset, Tile8Data tile, byte *gfx16Pointer, byte *gfx8Pointer)
        {
            int  mx = x;
            int  my = y;
            byte r  = 0;

            if (tile.mirror_h)
            {
                mx = 3 - x;
                r  = 1;
            }
            if (tile.mirror_v)
            {
                my = 7 - y;
            }

            int tx    = ((tile.id / 16) * 512) + ((tile.id - ((tile.id / 16) * 16)) * 4);
            var index = xx + yy + offset + (mx * 2) + (my * 128);
            var pixel = gfx8Pointer[tx + (y * 64) + x];

            gfx16Pointer[index + r ^ 1] = (byte)((pixel & 0x0F) + tile.palette * 16);
            gfx16Pointer[index + r]     = (byte)(((pixel >> 4) & 0x0F) + tile.palette * 16);
        }