From 19c58edb40f237bab0caecf9471ae3fa16400588 Mon Sep 17 00:00:00 2001 From: terminx Date: Sat, 8 Jul 2017 19:41:36 +0000 Subject: [PATCH] Add support for bitmap gamearrays and expose gotpic to CON git-svn-id: https://svn.eduke32.com/eduke32@6342 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/duke3d/src/gameexec.cpp | 7 ++++++- source/duke3d/src/gamevars.cpp | 18 +++++++----------- source/duke3d/src/gamevars.h | 6 ++++-- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/source/duke3d/src/gameexec.cpp b/source/duke3d/src/gameexec.cpp index 287d8546e..96a34edd1 100644 --- a/source/duke3d/src/gameexec.cpp +++ b/source/duke3d/src/gameexec.cpp @@ -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; } diff --git a/source/duke3d/src/gamevars.cpp b/source/duke3d/src/gamevars.cpp index 5171fdead..7109c4bac 100644 --- a/source/duke3d/src/gamevars.cpp +++ b/source/duke3d/src/gamevars.cpp @@ -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> 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 } diff --git a/source/duke3d/src/gamevars.h b/source/duke3d/src/gamevars.h index f2fc1a77d..40331d053 100644 --- a/source/duke3d/src/gamevars.h +++ b/source/duke3d/src/gamevars.h @@ -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)