fix more mixups in bulk reading (fixes #1903)

This commit is contained in:
zeromus 2020-03-30 17:18:16 -04:00
parent 905b18e429
commit 97beecc4c9
1 changed files with 10 additions and 6 deletions

View File

@ -129,14 +129,16 @@ namespace BizHawk.Emulation.Common
throw new ArgumentException();
}
if (addresses.EndInclusive - addresses.Start != values.Length)
long start = addresses.Start;
long nAddresses = addresses.EndInclusive - addresses.Start + 1;
if (nAddresses != values.Length)
{
throw new InvalidOperationException("Invalid length of values array");
}
for (var i = addresses.Start; i < addresses.EndInclusive; i++)
for (var i = 0; i<nAddresses; i++)
{
values[i] = PeekUshort(i, bigEndian);
values[i] = PeekUshort(start + i*2, bigEndian);
}
}
@ -147,14 +149,16 @@ namespace BizHawk.Emulation.Common
throw new ArgumentException();
}
if (addresses.EndInclusive - addresses.Start + 1 != values.Length)
long start = addresses.Start;
long nAddresses = addresses.EndInclusive - addresses.Start + 1;
if (nAddresses != values.Length)
{
throw new InvalidOperationException("Invalid length of values array");
}
for (var i = addresses.Start; i <= addresses.EndInclusive; i++)
for (var i = 0; i<nAddresses; i++)
{
values[i - addresses.Start] = PeekUint(i, bigEndian);
values[i] = PeekUint(start + i*4, bigEndian);
}
}
}