diff --git a/ArcFormats/ImageDRG.cs b/ArcFormats/ImageDRG.cs index 8c92c4f3..8d99b33b 100644 --- a/ArcFormats/ImageDRG.cs +++ b/ArcFormats/ImageDRG.cs @@ -151,7 +151,7 @@ namespace GameRes.Formats.DRS src_offset = out_pos - 3 * input.ReadByte (); if (count < 0 || count > pixel_count || src_offset < 0 || src_offset == out_pos) return null; - CopyOverlapped (output, src_offset, out_pos, count); + Binary.CopyOverlapped (output, src_offset, out_pos, count); out_pos += count; pixel_count -= count; break; @@ -163,7 +163,7 @@ namespace GameRes.Formats.DRS src_offset = out_pos - 3 * (off_hi << 8 | off_lo); if (count < 0 || count > pixel_count || src_offset < 0 || src_offset == out_pos) return null; - CopyOverlapped (output, src_offset, out_pos, count); + Binary.CopyOverlapped (output, src_offset, out_pos, count); out_pos += count; pixel_count -= count; break; @@ -205,20 +205,6 @@ namespace GameRes.Formats.DRS return output; } - static internal void CopyOverlapped (byte[] data, int src, int dst, int count) - { - int preceding = dst-src; - while (count > 0) - { - if (preceding > count) - preceding = count; - Array.Copy (data, src, data, dst, preceding); - src = dst; - dst += preceding; - count -= preceding; - } - } - internal class Writer : IDisposable { BinaryWriter m_out; diff --git a/ArcFormats/ImageRCT.cs b/ArcFormats/ImageRCT.cs index 3ef2bbcd..27b4545f 100644 --- a/ArcFormats/ImageRCT.cs +++ b/ArcFormats/ImageRCT.cs @@ -399,26 +399,12 @@ namespace GameRes.Formats.Majiro shift *= 3; if (shift >= 0 || data_pos+shift < 0) throw new InvalidFormatException(); - CopyOverlapped (m_data, data_pos+shift, data_pos, count); + Binary.CopyOverlapped (m_data, data_pos+shift, data_pos, count); data_pos += count; } } } - static internal void CopyOverlapped (byte[] data, int src, int dst, int count) - { - int preceding = dst-src; - while (count > 0) - { - if (preceding > count) - preceding = count; - Array.Copy (data, src, data, dst, preceding); - src = dst; - dst += preceding; - count -= preceding; - } - } - #region IDisposable Members bool disposed = false; @@ -575,7 +561,7 @@ namespace GameRes.Formats.Majiro shift -= shift_row; if (shift >= 0 || data_pos+shift < 0) throw new InvalidFormatException(); - RctFormat.Reader.CopyOverlapped (m_data, data_pos+shift, data_pos, count); + Binary.CopyOverlapped (m_data, data_pos+shift, data_pos, count); data_pos += count; } } diff --git a/GameRes/Utility.cs b/GameRes/Utility.cs index 1341fb77..072dea93 100644 --- a/GameRes/Utility.cs +++ b/GameRes/Utility.cs @@ -69,6 +69,20 @@ namespace GameRes.Utility return false; return true; } + + public static void CopyOverlapped (byte[] data, int src, int dst, int count) + { + int preceding = dst-src; + while (count > 0) + { + if (preceding > count) + preceding = count; + System.Array.Copy (data, src, data, dst, preceding); + src = dst; + dst += preceding; + count -= preceding; + } + } } public static class LittleEndian