Commit ef75d7a3 authored by Steven Fuller's avatar Steven Fuller

CalcFileChecksum now uses a buffer for calculating the checksum.

parent 4320f938
...@@ -116,17 +116,32 @@ static void DiskFlopAnim(int x, int y) ...@@ -116,17 +116,32 @@ static void DiskFlopAnim(int x, int y)
static int32_t CalcFileChecksum(int fd, int len) static int32_t CalcFileChecksum(int fd, int len)
{ {
int8_t buf[4096];
int32_t cs; int32_t cs;
int i; int i, j;
int8_t c1, c2; int8_t c1;
c1 = ReadInt8(fd);
cs = 0; cs = 0;
for (i = 0; i < len - 1; i++) { c1 = ReadInt8(fd);
c2 = ReadInt8(fd);
cs += c1 ^ c2; len--;
c1 = c2; while (len > 0) {
i = 4096;
if (len < i) {
i = len;
} }
ReadBytes(fd, buf, i);
for (j = 0; j < i; j++) {
cs += c1 ^ buf[j];
c1 = buf[j];
}
len -= 4096;
}
return cs; return cs;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment