Reordering and renaming for cleaner code
This commit is contained in:
parent
3296fc9b2f
commit
0a0d9f569a
|
@ -335,10 +335,11 @@ enum XRefDataBaseOffset
|
||||||
// XREF_XFreeSectionByHandle,
|
// XREF_XFreeSectionByHandle,
|
||||||
|
|
||||||
XREF_COUNT // XREF_COUNT must always be last.
|
XREF_COUNT // XREF_COUNT must always be last.
|
||||||
// Also, if XREF_COUNT > sizeof(byte), enlarge struct OOVPA.XRefSaveIndex (and Value somehow)
|
// Also, if XREF_COUNT > sizeof(uint16), enlarge struct OOVPA.XRefSaveIndex (and Value somehow)
|
||||||
};
|
};
|
||||||
|
|
||||||
#define XREF_UNKNOWN -1
|
#define XREF_ADDR_UNDETERMINED -1
|
||||||
|
#define XREF_ADDR_NOT_FOUND ((xbaddr)nullptr)
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
// * XRefDataBase
|
// * XRefDataBase
|
||||||
|
|
|
@ -177,7 +177,7 @@ void EmuHLEIntercept(Xbe::Header *pXbeHeader)
|
||||||
|
|
||||||
bXRefFirstPass = true; // Set to false for search speed optimization
|
bXRefFirstPass = true; // Set to false for search speed optimization
|
||||||
|
|
||||||
memset((void*)XRefDataBase, XREF_UNKNOWN, sizeof(XRefDataBase));
|
memset((void*)XRefDataBase, XREF_ADDR_UNDETERMINED, sizeof(XRefDataBase));
|
||||||
|
|
||||||
|
|
||||||
for(int p=0;UnResolvedXRefs < LastUnResolvedXRefs;p++)
|
for(int p=0;UnResolvedXRefs < LastUnResolvedXRefs;p++)
|
||||||
|
@ -653,7 +653,7 @@ static xbaddr EmuLocateFunction(OOVPA *Oovpa, xbaddr lower, xbaddr upper)
|
||||||
xbaddr XRefValue = XRefDataBase[XRef];
|
xbaddr XRefValue = XRefDataBase[XRef];
|
||||||
|
|
||||||
// unknown XRef cannot be checked yet
|
// unknown XRef cannot be checked yet
|
||||||
if (XRefValue == XREF_UNKNOWN)
|
if (XRefValue == XREF_ADDR_UNDETERMINED)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
xbaddr RealValue = *(xbaddr*)(cur + Offset);
|
xbaddr RealValue = *(xbaddr*)(cur + Offset);
|
||||||
|
@ -684,7 +684,7 @@ static xbaddr EmuLocateFunction(OOVPA *Oovpa, xbaddr lower, xbaddr upper)
|
||||||
if (Oovpa->XRefSaveIndex != XRefNoSaveIndex)
|
if (Oovpa->XRefSaveIndex != XRefNoSaveIndex)
|
||||||
{
|
{
|
||||||
// is the XRef not saved yet?
|
// is the XRef not saved yet?
|
||||||
if (XRefDataBase[Oovpa->XRefSaveIndex] == XREF_UNKNOWN)
|
if (XRefDataBase[Oovpa->XRefSaveIndex] == XREF_ADDR_UNDETERMINED)
|
||||||
{
|
{
|
||||||
// save and count the found address
|
// save and count the found address
|
||||||
UnResolvedXRefs--;
|
UnResolvedXRefs--;
|
||||||
|
|
|
@ -60,17 +60,12 @@ template <class BaseClass, typename MFT> inline void *MFPtoFP(MFT pMemFunc)
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
struct OOVPA
|
struct OOVPA
|
||||||
{
|
{
|
||||||
// This OOVPA field (uint16 Count) indicates the number of
|
// This OOVPA field (uint08 Count) indicates the number of
|
||||||
// {Offset, Value}-pairs present in the Lovp array,
|
// {Offset, Value}-pairs present in the Lovp array,
|
||||||
// available after casting this OOVPA to LOOVPA.
|
// available after casting this OOVPA to LOOVPA.
|
||||||
// (This Count INCLUDES optional leading {Offset, XREF_*-enum}-
|
// (This Count INCLUDES optional leading {Offset, XREF_*-enum}-
|
||||||
// pairs - see comment at XRefCount.)
|
// pairs - see comment at XRefCount.)
|
||||||
uint16 Count : 15;
|
uint08 Count;
|
||||||
|
|
||||||
// This OOVPA field (uint08 XRefSaveIndex) contains either an
|
|
||||||
// XREF_* enum value, or the XRefNoSaveIndex marker when there's
|
|
||||||
// no XREF_* enum defined for this OOVPA.
|
|
||||||
uint08 XRefSaveIndex;
|
|
||||||
|
|
||||||
// This OOVPA field (uint08 XRefCount) contains the number of
|
// This OOVPA field (uint08 XRefCount) contains the number of
|
||||||
// {Offset, XREF_*-enum}-pairs that come before all other
|
// {Offset, XREF_*-enum}-pairs that come before all other
|
||||||
|
@ -79,6 +74,11 @@ struct OOVPA
|
||||||
// (Also, see comments at XRefZero and XRefOne.)
|
// (Also, see comments at XRefZero and XRefOne.)
|
||||||
uint08 XRefCount;
|
uint08 XRefCount;
|
||||||
|
|
||||||
|
// This OOVPA field (uint16 XRefSaveIndex) contains either an
|
||||||
|
// XREF_* enum value, or the XRefNoSaveIndex marker when there's
|
||||||
|
// no XREF_* enum defined for this OOVPA.
|
||||||
|
uint16 XRefSaveIndex;
|
||||||
|
|
||||||
// Define LOVP here to reduce type definition complexity.
|
// Define LOVP here to reduce type definition complexity.
|
||||||
// (Otherwise, if defined in the template classes, that would mean
|
// (Otherwise, if defined in the template classes, that would mean
|
||||||
// that for each template instance, the type is redefined. Let's
|
// that for each template instance, the type is redefined. Let's
|
||||||
|
@ -92,11 +92,6 @@ struct OOVPA
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// This XRefNoSaveIndex constant, when set in the OOVPA.XRefSaveIndex
|
|
||||||
// field, functions as a marker indicating there's no XREF_* enum
|
|
||||||
// defined for the OOVPA.
|
|
||||||
const uint08 XRefNoSaveIndex = (uint08)-1;
|
|
||||||
|
|
||||||
// This XRefZero constant, when set in the OOVPA.XRefCount field,
|
// This XRefZero constant, when set in the OOVPA.XRefCount field,
|
||||||
// indicates there are no {offset, XREF_*-enum} present in the OOVPA.
|
// indicates there are no {offset, XREF_*-enum} present in the OOVPA.
|
||||||
const uint08 XRefZero = (uint08)0;
|
const uint08 XRefZero = (uint08)0;
|
||||||
|
@ -105,9 +100,13 @@ const uint08 XRefZero = (uint08)0;
|
||||||
// indicates the OOVPA contains one (1) {offset, XREF_* enum} pair.
|
// indicates the OOVPA contains one (1) {offset, XREF_* enum} pair.
|
||||||
const uint08 XRefOne = (uint08)1;
|
const uint08 XRefOne = (uint08)1;
|
||||||
|
|
||||||
// Note : Theoretically, there can be more than one {offset, XREF_*-enum}
|
// Note : Theoretically, there can be more than one {Offset, XREF_*-enum}
|
||||||
// pair at the start of the OOVPA's, but there are no examples of that yet.
|
// pair at the start of the OOVPA's, but there are no examples of that yet.
|
||||||
// (Also, EmuLocateFunction might not cater for this well enough?)
|
|
||||||
|
// This XRefNoSaveIndex constant, when set in the OOVPA.XRefSaveIndex
|
||||||
|
// field, functions as a marker indicating there's no XREF_* enum
|
||||||
|
// defined for the OOVPA.
|
||||||
|
const uint16 XRefNoSaveIndex = (uint16)-1;
|
||||||
|
|
||||||
// Macro used for storing an XRef {Offset, XRef}-Pair.
|
// Macro used for storing an XRef {Offset, XRef}-Pair.
|
||||||
//
|
//
|
||||||
|
@ -136,7 +135,7 @@ template <uint16 COUNT> struct LOOVPA
|
||||||
};
|
};
|
||||||
|
|
||||||
#define OOVPA_XREF(Name, Version, Count, XRefSaveIndex, XRefCount) \
|
#define OOVPA_XREF(Name, Version, Count, XRefSaveIndex, XRefCount) \
|
||||||
LOOVPA<Count> Name##_##Version = { { Count, XRefSaveIndex, XRefCount }, {
|
LOOVPA<Count> Name##_##Version = { { Count, XRefCount, XRefSaveIndex }, {
|
||||||
|
|
||||||
#define OOVPA_NO_XREF(Name, Version, Count) \
|
#define OOVPA_NO_XREF(Name, Version, Count) \
|
||||||
OOVPA_XREF(Name, Version, Count, XRefNoSaveIndex, XRefZero)
|
OOVPA_XREF(Name, Version, Count, XRefNoSaveIndex, XRefZero)
|
||||||
|
|
Loading…
Reference in New Issue