コード例 #1
0
        private static void ReadStringsInBlocks(List <MainDolString> output, IRomMapper dol, Stream stream, long pos, int byteSizeTotal, int blockSize, int stringsPerBlock, bool keepInvalid)
        {
            stream.Position = pos;
            int count = byteSizeTotal / blockSize;

            long[]   positions        = new long[stringsPerBlock];
            uint[]   ramAddresses     = new uint[stringsPerBlock];
            uint[]   romAddresses     = new uint[stringsPerBlock];
            string[] strings          = new string[stringsPerBlock];
            uint[]   stringByteCounts = new uint[stringsPerBlock];
            for (int i = 0; i < count; ++i)
            {
                for (int j = 0; j < stringsPerBlock; ++j)
                {
                    positions[j]    = stream.Position;
                    ramAddresses[j] = stream.ReadUInt32().FromEndian(EndianUtils.Endianness.BigEndian);
                }
                stream.DiscardBytes((uint)(blockSize - 4 * stringsPerBlock));
                bool isValid = false;
                for (int j = 0; j < stringsPerBlock; ++j)
                {
                    if (ramAddresses[j] == 0)
                    {
                        romAddresses[j]     = 0;
                        strings[j]          = null;
                        stringByteCounts[j] = 0;
                    }
                    else
                    {
                        romAddresses[j] = dol.MapRamToRom(ramAddresses[j]);

                        long tmp = stream.Position;
                        stream.Position = romAddresses[j];
                        string s         = stream.ReadNulltermString(TextUtils.GameTextEncoding.ShiftJIS);
                        uint   bytesRead = (uint)(stream.Position - romAddresses[j]);
                        stream.Position = tmp;

                        strings[j]          = s;
                        stringByteCounts[j] = bytesRead;
                        isValid             = true;
                    }
                }
                if (isValid || keepInvalid)
                {
                    for (int j = 0; j < stringsPerBlock; ++j)
                    {
                        output.Add(new MainDolString((uint)positions[j], romAddresses[j], strings[j], stringByteCounts[j]));
                    }
                }
            }
        }
コード例 #2
0
        private void Commit(ulong source)
        {
            long diff = (long)(Target.Value - (source + 1));

            if (diff < sbyte.MinValue || diff > sbyte.MaxValue)
            {
                throw new Exception("too far apart");
            }

            long  p = Binary.Position;
            ulong s = Mapper.MapRamToRom(source);

            Binary.Position = (long)s;
            Binary.WriteInt8((sbyte)diff);

            Binary.Position = p;
        }
コード例 #3
0
        private void Commit(ulong source)
        {
            long diff = (long)(Target.Value - (source + 4));

            if (diff < int.MinValue || diff > int.MaxValue)
            {
                throw new Exception("too far apart");
            }

            long  p = Binary.Position;
            ulong s = Mapper.MapRamToRom(source);

            Binary.Position = (long)s;
            Binary.WriteInt32((int)diff, EndianUtils.Endianness.LittleEndian);

            Binary.Position = p;
        }