mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 17:01:51 +00:00
Add support for bitmap gamearrays and expose gotpic to CON
git-svn-id: https://svn.eduke32.com/eduke32@6342 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
1e647ca499
commit
19c58edb40
3 changed files with 17 additions and 14 deletions
|
@ -4621,9 +4621,14 @@ finish_qsprintf:
|
|||
case GAMEARRAY_INT32: ((int32_t *)aGameArrays[tw].pValues)[arrayIndex] = newValue; break;
|
||||
case GAMEARRAY_INT16: ((int16_t *)aGameArrays[tw].pValues)[arrayIndex] = newValue; break;
|
||||
case GAMEARRAY_UINT8: ((uint8_t *)aGameArrays[tw].pValues)[arrayIndex] = newValue; break;
|
||||
case GAMEARRAY_BITMAP:
|
||||
if (newValue)
|
||||
((uint8_t *)aGameArrays[tw].pValues)[arrayIndex >> 3] |= (1 << (arrayIndex & 7));
|
||||
else
|
||||
((uint8_t *)aGameArrays[tw].pValues)[arrayIndex >> 3] &= ~(1 << (arrayIndex & 7));
|
||||
break;
|
||||
}
|
||||
|
||||
aGameArrays[tw].pValues[arrayIndex]=newValue;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -132,10 +132,7 @@ int Gv_ReadSave(int32_t kFile)
|
|||
if (kdfread(&aGameVars[i], sizeof(gamevar_t), 1, kFile) != 1)
|
||||
goto corrupt;
|
||||
|
||||
if (olabel == NULL)
|
||||
aGameVars[i].szLabel = (char *)Xmalloc(MAXVARLABEL * sizeof(uint8_t));
|
||||
else
|
||||
aGameVars[i].szLabel = olabel;
|
||||
aGameVars[i].szLabel = (char *)Xrealloc(olabel, MAXVARLABEL * sizeof(uint8_t));
|
||||
|
||||
if (kdfread(aGameVars[i].szLabel, MAXVARLABEL, 1, kFile) != 1)
|
||||
goto corrupt;
|
||||
|
@ -164,7 +161,7 @@ int Gv_ReadSave(int32_t kFile)
|
|||
if (kdfread(&g_gameArrayCount,sizeof(g_gameArrayCount),1,kFile) != 1) goto corrupt;
|
||||
for (bssize_t i=0; i<g_gameArrayCount; i++)
|
||||
{
|
||||
if (aGameArrays[i].flags&GAMEARRAY_READONLY)
|
||||
if (!(aGameArrays[i].flags & GAMEARRAY_ALLOCATED))
|
||||
continue;
|
||||
|
||||
char *const olabel = aGameArrays[i].szLabel;
|
||||
|
@ -173,10 +170,7 @@ int Gv_ReadSave(int32_t kFile)
|
|||
if (kdfread(&aGameArrays[i], sizeof(gamearray_t), 1, kFile) != 1)
|
||||
goto corrupt;
|
||||
|
||||
if (olabel == NULL)
|
||||
aGameArrays[i].szLabel = (char *)Xmalloc(MAXARRAYLABEL * sizeof(uint8_t));
|
||||
else
|
||||
aGameArrays[i].szLabel = olabel;
|
||||
aGameArrays[i].szLabel = (char *) Xrealloc(olabel, MAXARRAYLABEL * sizeof(uint8_t));
|
||||
|
||||
if (kdfread(aGameArrays[i].szLabel,sizeof(uint8_t) * MAXARRAYLABEL, 1, kFile) != 1)
|
||||
goto corrupt;
|
||||
|
@ -286,7 +280,7 @@ void Gv_WriteSave(FILE *fil)
|
|||
|
||||
for (bssize_t i=0; i<g_gameArrayCount; i++)
|
||||
{
|
||||
if (aGameArrays[i].flags&GAMEARRAY_READONLY)
|
||||
if (!(aGameArrays[i].flags & GAMEARRAY_ALLOCATED))
|
||||
continue;
|
||||
|
||||
// write for .size and .dwFlags (the rest are pointers):
|
||||
|
@ -413,7 +407,7 @@ int32_t Gv_NewArray(const char *pszLabel, void *pArray, intptr_t arraySize, uint
|
|||
|
||||
g_warningCnt++;
|
||||
|
||||
if (aGameArrays[i].flags&GAMEARRAY_TYPE_MASK)
|
||||
if (aGameArrays[i].flags & GAMEARRAY_TYPE_MASK)
|
||||
{
|
||||
C_ReportError(-1);
|
||||
initprintf("ignored redefining system array `%s'.", pszLabel);
|
||||
|
@ -586,6 +580,7 @@ int __fastcall Gv_GetArrayValue(int const id, int index)
|
|||
case GAMEARRAY_INT32: returnValue = ((int32_t *)aGameArrays[id].pValues)[index]; break;
|
||||
case GAMEARRAY_INT16: returnValue = ((int16_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;
|
||||
|
@ -1537,6 +1532,7 @@ static void Gv_AddSystemVars(void)
|
|||
Gv_NewArray("tilesizx", (void *)&tilesiz[0].x, MAXTILES, GAMEARRAY_STRIDE2|GAMEARRAY_READONLY|GAMEARRAY_INT16);
|
||||
Gv_NewArray("tilesizy", (void *)&tilesiz[0].y, MAXTILES, GAMEARRAY_STRIDE2|GAMEARRAY_READONLY|GAMEARRAY_INT16);
|
||||
Gv_NewArray("walock", (void *) &walock[0], MAXTILES, GAMEARRAY_UINT8);
|
||||
Gv_NewArray("gotpic", (void *) &gotpic[0], MAXTILES, GAMEARRAY_BITMAP);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -66,11 +66,13 @@ enum GamearrayFlags_t
|
|||
GAMEARRAY_INT16 = 0x00000002,
|
||||
GAMEARRAY_INT32 = 0x00000004,
|
||||
GAMEARRAY_RESET = 0x00000008,
|
||||
GAMEARRAY_TYPE_MASK = GAMEARRAY_UINT8 | GAMEARRAY_INT16 | GAMEARRAY_INT32,
|
||||
GAMEARRAY_RESTORE = 0x00000010,
|
||||
GAMEARRAY_VARSIZE = 0x00000020,
|
||||
GAMEARRAY_STRIDE2 = 0x00000100,
|
||||
GAMEARRAY_ALLOCATED = 0100000200, // memory allocated for user array
|
||||
GAMEARRAY_ALLOCATED = 0x00000200, // memory allocated for user array
|
||||
GAMEARRAY_BITMAP = 0x00000400,
|
||||
|
||||
GAMEARRAY_TYPE_MASK = GAMEARRAY_UINT8 | GAMEARRAY_INT16 | GAMEARRAY_INT32 | GAMEARRAY_BITMAP,
|
||||
};
|
||||
|
||||
#pragma pack(push,1)
|
||||
|
|
Loading…
Reference in a new issue