Пример #1
0
        public CSBF1(Byte[] rawData, Byte[] ressourceName) : base(rawData, ressourceName)
        {
            //grab nb ressources used in scene
            int nbTextureScene = CGeneric.ConvertByteArrayToInt(CGeneric.GiveMeArray(rawData, 4, 4));

            //grab names of texture used (bif list)
            bifList = new List <byte[]>();

            for (int i = 0; i < nbTextureScene; i++)
            {
                byte[] tmpArray = new byte[16];
                Array.Copy(rawData, 8 + i * 16, tmpArray, 0, tmpArray.Length);
                bifList.Add(tmpArray);
            }

            //grab index number of scene
            int headerSize = 12 + bifList.Count * 0x10;
            int nbScene    = CGeneric.ConvertByteArrayToInt(CGeneric.GiveMeArray(rawData, headerSize - 4, 4));

            //send the data without SBF header for chuncking data..
            byte[] dataWithoutHeader = new byte[rawData.Length - headerSize];
            Array.Copy(rawData, headerSize, dataWithoutHeader, 0, dataWithoutHeader.Length);

            SetChunk(dataWithoutHeader, nbScene);
        }
Пример #2
0
        public byte[] GetRawData()
        {
            int flags = CGeneric.ConvertByteArrayToInt(CGeneric.GiveMeArray(rawData, 0, 4));

            //set unknown bit values
            //CGeneric.SetBitInInt(ref flags, 1, true);

            //Array.Copy(CGeneric.ConvertIntToByteArray(flags), 0, rawData, 0, 4);



            return(rawData);
        }
Пример #3
0
        public byte[] GetRawData()
        {
            //init
            byte[] res = new byte[0];

            //add the 4 unknown bytes...
            res = res.Concat(CGeneric.GiveMeArray(rawData, 0, 4)).ToArray();

            //title scene length
            res = res.Concat(CGeneric.ConvertIntToByteArray(this.sceneName.Length)).ToArray();

            //scene name
            res = res.Concat(sceneName).ToArray();

            //size dynamicObject
            res = res.Concat(CGeneric.ConvertIntToByteArray(dynamicObjectList.Count)).ToArray();

            //dynamic objectData
            foreach (CSBF1DynamicObject dynObj in dynamicObjectList)
            {
                res = res.Concat(dynObj.GetRawData()).ToArray();
            }

            //size TextObject
            res = res.Concat(CGeneric.ConvertIntToByteArray(textObjectList.Count)).ToArray();

            //TextObject
            foreach (CSBF1TextObject TexObj in textObjectList)
            {
                res = res.Concat(TexObj.GetRawData()).ToArray();
            }

            //Size textureManagement
            res = res.Concat(CGeneric.ConvertIntToByteArray(textureManagementObjectList.Count)).ToArray();

            //TextureManagement
            foreach (CSBF1TextureManagement texManObj in textureManagementObjectList)
            {
                res = res.Concat(texManObj.GetRawData()).ToArray();
            }

            //dont renember why.. but needed
            byte[] test = new byte[] { 0x00, 0x00, 0x00, 0x00 };
            res = res.Concat(test).ToArray();

            return(res);
        }
        private void decomposeHeader()
        {
            //data grabbed from 4 first bytes (converted to bits)
            int dataInitial = CGeneric.ConvertByteArrayToInt(CGeneric.GiveMeArray(rawData, 0, 4));

            //set flags
            transparencybit = CGeneric.GetBitStateFromInt(dataInitial, 22);
            extra2          = CGeneric.GetBitStateFromInt(dataInitial, 26);

            //set unknown flags
            bit19 = CGeneric.GetBitStateFromInt(dataInitial, 19);
            bit20 = CGeneric.GetBitStateFromInt(dataInitial, 20);
            bit21 = CGeneric.GetBitStateFromInt(dataInitial, 21);
            bit23 = CGeneric.GetBitStateFromInt(dataInitial, 23);
            bit24 = CGeneric.GetBitStateFromInt(dataInitial, 24);
            bit25 = CGeneric.GetBitStateFromInt(dataInitial, 25);
            bit27 = CGeneric.GetBitStateFromInt(dataInitial, 27);
            bit28 = CGeneric.GetBitStateFromInt(dataInitial, 28);
            bit29 = CGeneric.GetBitStateFromInt(dataInitial, 29);
            bit30 = CGeneric.GetBitStateFromInt(dataInitial, 30);
            bit31 = CGeneric.GetBitStateFromInt(dataInitial, 31);
            bit32 = CGeneric.GetBitStateFromInt(dataInitial, 32);

            if (transparencybit)
            {
                this.transparency = rawData[31];
            }

            if (rawData[3] != 8)
            {
                this.isCompressedTexture = true;
            }
            this.textureIndex = rawData[27];
            this.posX         = CGeneric.ConvertByteArrayToInt(CGeneric.GiveMeArray(rawData, 4, 4));
            this.posY         = CGeneric.ConvertByteArrayToInt(CGeneric.GiveMeArray(rawData, 8, 4));
        }
Пример #5
0
        private void ChunkScene(byte[] data, int headerSize)
        {
            //separate 3 types of data -> dynamicObject, text and textureManagment
            int generalIndex = 0;

            //get the number of dynamic object
            byte[] nbDynamicArray = new byte[4];
            Array.Copy(data, generalIndex, nbDynamicArray, 0, nbDynamicArray.Length);
            //increment the global index with 4 (the size of nbDynamicArray.Length)
            generalIndex += nbDynamicArray.Length;

            //fill dynamic objects
            this.dynamicObjectList = new List <CSBF1DynamicObject>();
            generalIndex          += ChunkDynamicObject(data, CGeneric.ConvertByteArrayToInt(nbDynamicArray), generalIndex);

            //get the number of text object
            byte[] nbTextArray = new byte[4];
            Array.Copy(data, generalIndex, nbTextArray, 0, nbTextArray.Length);
            //increment the global index with 4 (the size of nbDynamicArray.Length)
            generalIndex += nbTextArray.Length;

            //fill text objects
            this.textObjectList = new List <CSBF1TextObject>();
            generalIndex       += ChunkTextObject(data, CGeneric.ConvertByteArrayToInt(nbTextArray), generalIndex);

            //get the number of texture management object
            byte[] nbTextureArray = new byte[4];
            Array.Copy(data, generalIndex, nbTextureArray, 0, nbTextureArray.Length);
            //increment the global index with 4 (the size of nbDynamicArray.Length)
            generalIndex += nbTextureArray.Length;

            //fill texture management object
            this.textureManagementObjectList = new List <CSBF1TextureManagement>();
            generalIndex += ChunkTextureManagementObject(data, CGeneric.ConvertByteArrayToInt(nbTextureArray), generalIndex);

            //add 4 because 0x00000000 at the end of each scene..
            //add specific value for ISO file (the 4th hidden thing in sbf...
            var hidden4thData = CGeneric.ConvertByteArrayToInt(CGeneric.GiveMeArray(data, generalIndex, 4));

            generalIndex += 4;
            if (hidden4thData != 0)
            {
                for (int i = 0; i < hidden4thData; i++)
                {
                    var code4thData = CGeneric.ConvertByteArrayToInt(CGeneric.GiveMeArray(data, generalIndex, 4));
                    switch (code4thData)
                    {
                    case 0x1E:
                    case 0x9E:
                        generalIndex += 0x20;
                        break;

                    case 0x1F:
                        generalIndex += 0x24;
                        break;

                    default:
                        throw new NotImplementedException();
                    }
                }
            }
            var a = sceneNameDebug;

            //with the datasize determinated set the new rawData array
            byte[] newArrayRawData = new byte[generalIndex + headerSize];
            Array.Copy(this.rawData, 0, newArrayRawData, 0, newArrayRawData.Length);
            this.rawData = newArrayRawData;
        }
Пример #6
0
 private void AddTexture(int location, int sizeX, int sizeY, int bpp, string text, int paletteLocation = 0, int paletteSize = 0)
 {
     graphicsRom.Add(new UncompressedRomTextureData(CGeneric.GiveMeArray(rawData, location, sizeX * sizeY * (bpp / 8)), location, sizeX, sizeY, bpp, text, CGeneric.GiveMeArray(rawData, paletteLocation, paletteSize), paletteLocation));
 }