コード例 #1
0
        public void PrepForSaving(MG64RomFile file)
        {
            //Convert height map data back to encoded formats
            byte[] heightMap1, heightMap2;

            _HeightDataEncoding.EncodeHeightMap(HeightMapData, out heightMap1, out heightMap2);

            if (heightMap1.Length <= HeightData1.BlockLength)
            {
                HeightData1 = new BasicCourseBlock(heightMap1, HeightData1.RomOffset, heightMap1.Length);
            }
            else
            {
                HeightData1 = new BasicCourseBlock(heightMap1, file.NewDataOffset, heightMap1.Length);
                file.AdvanceNewData(heightMap1.Length);
            }

            if (heightMap2.Length <= HeightData2.BlockLength)
            {
                HeightData2 = new BasicCourseBlock(heightMap2, HeightData2.RomOffset, heightMap2.Length);
            }
            else
            {
                HeightData2 = new BasicCourseBlock(heightMap2, file.NewDataOffset, heightMap2.Length);
                file.AdvanceNewData(heightMap2.Length);
            }
        }
コード例 #2
0
        private void SerializeData(MG64RomFile file, CourseBlock block)
        {
            byte[] blockData = block.GetAsBytes();

            if (blockData.Length != block.BlockLength)    //size has changed
            {
                if (blockData.Length < block.BlockLength) //shrunk in size
                {
                    block.Update(block.RomOffset, blockData.Length);
                }
                else  //grown in size, needs to be appended to the rom
                {
                    block.Update(file.NewDataOffset, blockData.Length);
                    file.AdvanceNewData(block.BlockLength);
                }
            }

            Array.Copy(blockData, 0, file.RomData, block.RomOffset + MG64RomFile.COURSE_TABLE_OFFSET, block.BlockLength);
        }