1. Fix cheat column in the list of RAM Search dialog show the wrong number.

2. Some mysterious things:
In RAM Search, when the Data size was set to 4 Bytes, the value in the list was changed to 4 bytes but the gap of the items is still 2 bytes. I'm unclear it's an old bug or intentional, since some of the macros are used in comparison, they describe the template of the function as a short even in 4 bytes situation, but that might not compare 4 bytes value correctly.
This commit is contained in:
owomomo 2019-04-01 00:58:23 +08:00
parent 68993285f8
commit c2b39fdf3f
1 changed files with 19 additions and 20 deletions

View File

@ -412,22 +412,21 @@ void ItemIndexToVirtualRegion(unsigned int itemIndex, MemoryRegion& virtualRegio
return; return;
} }
MemoryRegion* regionPtr = s_itemIndexToRegionPointer[itemIndex]; MemoryRegion* region = s_itemIndexToRegionPointer[itemIndex];
MemoryRegion& region = *regionPtr;
int bytesWithinRegion = (itemIndex - region.itemIndex) * sizeof(stepType); int bytesWithinRegion = (itemIndex - region->itemIndex) * sizeof(stepType);
int startSkipSize = ((unsigned int)(sizeof(stepType) - region.hardwareAddress)) % sizeof(stepType); int startSkipSize = ((unsigned int)(sizeof(stepType) - region->hardwareAddress)) % sizeof(stepType);
bytesWithinRegion += startSkipSize; bytesWithinRegion += startSkipSize;
virtualRegion.size = sizeof(compareType); virtualRegion.size = sizeof(compareType);
virtualRegion.hardwareAddress = region.hardwareAddress + bytesWithinRegion; virtualRegion.hardwareAddress = region->hardwareAddress + bytesWithinRegion;
virtualRegion.virtualIndex = region.virtualIndex + bytesWithinRegion; virtualRegion.virtualIndex = region->virtualIndex + bytesWithinRegion;
virtualRegion.itemIndex = itemIndex; virtualRegion.itemIndex = itemIndex;
region.cheatAffect = 0; virtualRegion.cheatAffect = 0;
for (int i = 0; i < numsubcheats; i++) for (int i = 0; i < numsubcheats; ++i)
if (SubCheats[i].addr >= region.hardwareAddress && SubCheats[i].addr < region.hardwareAddress + region.size) if (SubCheats[i].addr >= virtualRegion.hardwareAddress && SubCheats[i].addr < virtualRegion.hardwareAddress + virtualRegion.size)
++region.cheatAffect; ++virtualRegion.cheatAffect;
} }
template<typename stepType, typename compareType> template<typename stepType, typename compareType>
@ -541,10 +540,10 @@ unsigned int HardwareAddressToItemIndex(HWAddressType hardwareAddress)
: sizeTypeID == 'd' \ : sizeTypeID == 'd' \
? (isSigned \ ? (isSigned \
? (requiresAligned \ ? (requiresAligned \
? functionName<short, signed long>() \ ? functionName<long, signed long>() \
: functionName<char, signed long>()) \ : functionName<char, signed long>()) \
: (requiresAligned \ : (requiresAligned \
? functionName<short, unsigned long>() \ ? functionName<long, unsigned long>() \
: functionName<char, unsigned long>())) \ : functionName<char, unsigned long>())) \
: functionName<char, signed char>()) : functionName<char, signed char>())
@ -564,10 +563,10 @@ unsigned int HardwareAddressToItemIndex(HWAddressType hardwareAddress)
: sizeTypeID == 'd' \ : sizeTypeID == 'd' \
? (isSigned \ ? (isSigned \
? (requiresAligned \ ? (requiresAligned \
? functionName<short, signed long>(p0) \ ? functionName<long, signed long>(p0) \
: functionName<char, signed long>(p0)) \ : functionName<char, signed long>(p0)) \
: (requiresAligned \ : (requiresAligned \
? functionName<short, unsigned long>(p0) \ ? functionName<long, unsigned long>(p0) \
: functionName<char, unsigned long>(p0))) \ : functionName<char, unsigned long>(p0))) \
: functionName<char, signed char>(p0)) : functionName<char, signed char>(p0))
@ -587,10 +586,10 @@ unsigned int HardwareAddressToItemIndex(HWAddressType hardwareAddress)
: sizeTypeID == 'd' \ : sizeTypeID == 'd' \
? (isSigned \ ? (isSigned \
? (requiresAligned \ ? (requiresAligned \
? functionName<short, signed long>(p0, p1, p2) \ ? functionName<long, signed long>(p0, p1, p2) \
: functionName<char, signed long>(p0, p1, p2)) \ : functionName<char, signed long>(p0, p1, p2)) \
: (requiresAligned \ : (requiresAligned \
? functionName<short, unsigned long>(p0, p1, p2) \ ? functionName<long, unsigned long>(p0, p1, p2) \
: functionName<char, unsigned long>(p0, p1, p2))) \ : functionName<char, unsigned long>(p0, p1, p2))) \
: functionName<char, signed char>(p0, p1, p2)) : functionName<char, signed char>(p0, p1, p2))
@ -610,10 +609,10 @@ unsigned int HardwareAddressToItemIndex(HWAddressType hardwareAddress)
: sizeTypeID == 'd' \ : sizeTypeID == 'd' \
? (isSigned \ ? (isSigned \
? (requiresAligned \ ? (requiresAligned \
? functionName<short, signed long>(p0, p1, p2, p3) \ ? functionName<long, signed long>(p0, p1, p2, p3) \
: functionName<char, signed long>(p0, p1, p2, p3)) \ : functionName<char, signed long>(p0, p1, p2, p3)) \
: (requiresAligned \ : (requiresAligned \
? functionName<short, unsigned long>(p0, p1, p2, p3) \ ? functionName<long, unsigned long>(p0, p1, p2, p3) \
: functionName<char, unsigned long>(p0, p1, p2, p3))) \ : functionName<char, unsigned long>(p0, p1, p2, p3))) \
: functionName<char, signed char>(p0, p1, p2, p3)) : functionName<char, signed char>(p0, p1, p2, p3))
@ -627,7 +626,7 @@ unsigned int HardwareAddressToItemIndex(HWAddressType hardwareAddress)
: functionName<char, type>(p0, p1, p2)) \ : functionName<char, type>(p0, p1, p2)) \
: sizeTypeID == 'd' \ : sizeTypeID == 'd' \
? (requiresAligned \ ? (requiresAligned \
? functionName<short, type>(p0, p1, p2) \ ? functionName<long, type>(p0, p1, p2) \
: functionName<char, type>(p0, p1, p2)) \ : functionName<char, type>(p0, p1, p2)) \
: functionName<char, type>(p0, p1, p2)) : functionName<char, type>(p0, p1, p2))
@ -641,7 +640,7 @@ unsigned int HardwareAddressToItemIndex(HWAddressType hardwareAddress)
: functionName<char, type>(p0, p1, p2, p3)) \ : functionName<char, type>(p0, p1, p2, p3)) \
: sizeTypeID == 'd' \ : sizeTypeID == 'd' \
? (requiresAligned \ ? (requiresAligned \
? functionName<short, type>(p0, p1, p2, p3) \ ? functionName<long, type>(p0, p1, p2, p3) \
: functionName<char, type>(p0, p1, p2, p3)) \ : functionName<char, type>(p0, p1, p2, p3)) \
: functionName<char, type>(p0, p1, p2, p3)) : functionName<char, type>(p0, p1, p2, p3))