Пример #1
0
    //-------------------------------------------------------------------------------------------------------------------
    public static ObjRec[] getBlocksAbadox(int blockIndex)
    {
        var addr      = ConfigScript.getTilesAddr(blockIndex);
        var count     = ConfigScript.getBlocksCount();
        var objects   = new ObjRec[count];
        int w         = 4;
        int h         = 30;
        int blockSize = w * h;

        for (int i = 0; i < count; i++)
        {
            var indexes   = new int[blockSize];
            var palBytes  = new int[32];
            var attrAdd   = i * 8;
            int blockAddr = addr + i * blockSize + attrAdd;
            Array.Copy(Globals.romdata, blockAddr, indexes, 0, blockSize);
            indexes = Utils.transpose(indexes, w, h);
            //
            int palBytesAddr = blockAddr + blockSize;
            for (int j = 0; j < 8; j++)
            {
                int palByte = Globals.romdata[palBytesAddr + j];
                palBytes[j * 4 + 0] = (palByte >> 0) & 3;
                palBytes[j * 4 + 1] = (palByte >> 2) & 3;
                palBytes[j * 4 + 2] = (palByte >> 4) & 3;
                palBytes[j * 4 + 3] = (palByte >> 6) & 3;
            }
            //
            objects[i] = new ObjRec(w, h, indexes, palBytes);
        }
        return(objects);
    }
Пример #2
0
    //-------------------------------------------------------------------------------------------------------------------
    public static ObjRec[] getBlocks4x8(int blockIndex)
    {
        var addr      = ConfigScript.getTilesAddr(blockIndex);
        var count     = ConfigScript.getBlocksCount(blockIndex);
        var objects   = new ObjRec[count];
        int w         = 4;
        int h         = 8;
        int blockSize = w * h;

        for (int i = 0; i < count; i++)
        {
            var indexes   = new int[blockSize];
            var palBytes  = new int[w * h / 4];
            var attrAdd   = i * 2;
            int blockAddr = addr + i * blockSize + attrAdd + 2;
            Array.Copy(Globals.romdata, blockAddr, indexes, 0, blockSize);

            //
            int palBytesAddr = blockAddr - 2;
            for (int j = 0; j < 2; j++)
            {
                int palByte = Globals.romdata[palBytesAddr + j];
                palBytes[j * 4 + 0] = (palByte >> 0) & 3;
                palBytes[j * 4 + 1] = (palByte >> 2) & 3;
                palBytes[j * 4 + 2] = (palByte >> 4) & 3;
                palBytes[j * 4 + 3] = (palByte >> 6) & 3;
            }
            //
            objects[i] = new ObjRec(w, h, 0, indexes, palBytes);
        }
        return(objects);
    }
Пример #3
0
    public static ObjRec vertMirror(ObjRec obj)
    {
        var ind = new int[16];

        ind[0] = obj.indexes[12];
        ind[1] = obj.indexes[13];
        ind[2] = obj.indexes[14];
        ind[3] = obj.indexes[15];

        ind[4] = obj.indexes[8];
        ind[5] = obj.indexes[9];
        ind[6] = obj.indexes[10];
        ind[7] = obj.indexes[11];

        ind[8]  = obj.indexes[4];
        ind[9]  = obj.indexes[5];
        ind[10] = obj.indexes[6];
        ind[11] = obj.indexes[7];

        ind[12] = obj.indexes[0];
        ind[13] = obj.indexes[1];
        ind[14] = obj.indexes[2];
        ind[15] = obj.indexes[2];

        return(new ObjRec(4, 4, obj.type, ind, obj.palBytes));
    }
Пример #4
0
    public void setBlocksJB(int blockIndex, ObjRec[] objects)
    {
        int loCount    = BlocksAddrs[blockIndex].loCount;
        var secondPart = new ObjRec[loCount];

        Array.Copy(objects, loCount, secondPart, 0, loCount);
        Utils.writeBlocksToAlignedArrays(objects, Globals.romdata, BlocksAddrs[blockIndex].hiAddr, BlocksAddrs[blockIndex].hiCount);
        Utils.writeBlocksToAlignedArrays(secondPart, Globals.romdata, BlocksAddrs[blockIndex].loAddr, loCount);
    }
Пример #5
0
    public static ObjRec[] getBlocks(int tileId)
    {
        var blocks = new ObjRec[64];

        for (int i = 0; i < 64; i++)
        {
            blocks[i] = new ObjRec(i * 4, i * 4 + 2, i * 4 + 1, i * 4 + 3, 0, 0);
        }
        return(blocks);
    }
Пример #6
0
    //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    public static ObjRec[] getBlocksJB(int blockIndex)
    {
        var part1 = Utils.readBlocksFromAlignedArrays(Globals.romdata, BlocksAddrs[blockIndex].hiAddr, BlocksAddrs[blockIndex].hiCount);
        var part2 = Utils.readBlocksFromAlignedArrays(Globals.romdata, BlocksAddrs[blockIndex].loAddr, BlocksAddrs[blockIndex].loCount);
        var total = new ObjRec[256];

        Array.Copy(part1, total, part1.Length);
        Array.Copy(part2, 0, total, BlocksAddrs[blockIndex].loCount, part2.Length); //copy to index 110, no 128!!! bug of game developers?
        return(total);
    }
Пример #7
0
    //----------------------------------------------------------------------------
    public static ObjRec[] getBlocks(int tileId)
    {
        int bc      = ConfigScript.getBlocksCount(tileId);
        int palAddr = getPalBytesAddr();

        byte[] blocksData = Utils.readDataFromUnalignedArrays(Globals.romdata, blockAddr1, blockAddr2, blockAddr3, blockAddr4, bc);
        var    blocks     = new ObjRec[bc];

        for (int i = 0; i < blocks.Length; i++)
        {
            var tileData = new int[] { blocksData[i * 4 + 0], blocksData[i * 4 + 1], blocksData[i * 4 + 2], blocksData[i * 4 + 3] };
            var attrData = new int[] { Globals.romdata[palAddr + i] };
            blocks[i] = new ObjRec(2, 2, 0, tileData, attrData);
        }
        return(blocks);
    }
Пример #8
0
    //----------------------------------------------------------------------------
    public ObjRec[] getBlocksConsts(int blockIndex)
    {
        var objects = new ObjRec[getBlocksCount()];

        for (int i = 0; i < objects.Length; i++)
        {
            var indexes  = new int[4];
            var palBytes = new int[1];
            int bi       = (i / 8) * 32 + i % 8 * 2;
            indexes[0] = bi;
            indexes[1] = bi + 1;
            indexes[2] = bi + 16;
            indexes[3] = bi + 17;
            objects[i] = new ObjRec(2, 2, indexes, palBytes);
        }
        return(objects);
    }
Пример #9
0
        //------------------------------------------------------------------------------------------------

        private static void applyBlockToMap(int[] mapData, ObjRec block, int x, int y, int mapWidth)
        {
            int width  = block.w;
            int height = block.h;

            for (int w = 0; w < width; w++)
            {
                for (int h = 0; h < height; h++)
                {
                    int mdIndex = (y * height + h) * mapWidth + x * width + w;
                    int bIndex  = width * h + w;
                    if ((mdIndex >= 0) && (mdIndex < mapData.Length))
                    {
                        mapData[mdIndex] = block.indexes[bIndex];
                    }
                }
            }
        }
    //blocks are intersects.
    public static ObjRec[] getBlocksLinear4x2withoutAttribT(int blockIndex)
    {
        var singleBlocks = Utils.readBlocksLinear(Globals.romdata, ConfigScript.getTilesAddr(blockIndex), 2, 2, ConfigScript.getBlocksCount(blockIndex) + 1, false, true);
        var newBlocks    = new ObjRec[ConfigScript.getBlocksCount(blockIndex)];

        for (int i = 0; i < newBlocks.Length; i++)
        {
            var indexes  = new int[8];
            var palBytes = new int[2];
            indexes[0]   = singleBlocks[i].indexes[0];
            indexes[1]   = singleBlocks[i].indexes[1];
            indexes[2]   = singleBlocks[i + 1].indexes[0];
            indexes[3]   = singleBlocks[i + 1].indexes[1];
            indexes[4]   = singleBlocks[i].indexes[2];
            indexes[5]   = singleBlocks[i].indexes[3];
            indexes[6]   = singleBlocks[i + 1].indexes[2];
            indexes[7]   = singleBlocks[i + 1].indexes[3];
            newBlocks[i] = new ObjRec(4, 2, 0, indexes, palBytes);
        }
        return(newBlocks);
    }
Пример #11
0
 public Dt2ObjRec(ObjRec b, int _index)
     : base(b)
 {
     index = _index;
 }