Commit d7db07f3 authored by Richard Gobeille's avatar Richard Gobeille

Duke3d: inline the array get/set functions

parent 2a6a35bf
......@@ -1211,7 +1211,7 @@ void Screen_Play(void)
} while (running);
}
static void SetArray(int const arrayNum, int const arrayIndex, int const newValue)
static inline void SetArray(int const arrayNum, int const arrayIndex, int const newValue)
{
auto &arr = aGameArrays[arrayNum];
......
......@@ -829,29 +829,6 @@ size_t __fastcall Gv_GetArrayCountForAllocSize(int const arrayIdx, size_t const
return tabledivide64(filelength + denominator - 1, denominator);
}
int __fastcall Gv_GetArrayValue(int const id, int index)
{
if (aGameArrays[id].flags & GAMEARRAY_STRIDE2)
index <<= 1;
int returnValue = 0;
switch (aGameArrays[id].flags & GAMEARRAY_TYPE_MASK)
{
case 0: returnValue = (aGameArrays[id].pValues)[index]; break;
case GAMEARRAY_INT16: returnValue = ((int16_t *)aGameArrays[id].pValues)[index]; break;
case GAMEARRAY_INT8: returnValue = ((int8_t *)aGameArrays[id].pValues)[index]; break;
case GAMEARRAY_UINT16: returnValue = ((uint16_t *)aGameArrays[id].pValues)[index]; break;
case GAMEARRAY_UINT8: returnValue = ((uint8_t *)aGameArrays[id].pValues)[index]; break;
case GAMEARRAY_BITMAP:returnValue = !!(((uint8_t *)aGameArrays[id].pValues)[index >> 3] & pow2char[index & 7]); break;
}
return returnValue;
}
#define CHECK_INDEX(range) \
if (EDUKE32_PREDICT_FALSE((unsigned)arrayIndex >= (unsigned)range)) \
{ \
......
......@@ -124,7 +124,23 @@ size_t __fastcall Gv_GetArrayAllocSizeForCount(int const arrayIdx, size_t const
size_t __fastcall Gv_GetArrayCountForAllocSize(int const arrayIdx, size_t const filelength);
static FORCE_INLINE size_t Gv_GetArrayAllocSize(int const arrayIdx) { return Gv_GetArrayAllocSizeForCount(arrayIdx, aGameArrays[arrayIdx].size); }
unsigned __fastcall Gv_GetArrayElementSize(int const arrayIdx);
int __fastcall Gv_GetArrayValue(int const id, int index);
static FORCE_INLINE int __fastcall Gv_GetArrayValue(int const id, int index)
{
if (aGameArrays[id].flags & GAMEARRAY_STRIDE2)
index <<= 1;
switch (aGameArrays[id].flags & GAMEARRAY_TYPE_MASK)
{
default: return (aGameArrays[id].pValues)[index];
case GAMEARRAY_INT16: return ((int16_t *)aGameArrays[id].pValues)[index];
case GAMEARRAY_INT8: return ((int8_t *)aGameArrays[id].pValues)[index];
case GAMEARRAY_UINT16: return ((uint16_t *)aGameArrays[id].pValues)[index];
case GAMEARRAY_UINT8: return ((uint8_t *)aGameArrays[id].pValues)[index];
case GAMEARRAY_BITMAP: return !!(((uint8_t *)aGameArrays[id].pValues)[index >> 3] & pow2char[index & 7]);
}
}
int __fastcall Gv_GetVar(int const gameVar, int const spriteNum, int const playerNum);
void __fastcall Gv_SetVar(int const gameVar, int const newValue, int const spriteNum, int const playerNum);
int __fastcall Gv_GetVar(int const gameVar);
......
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