From 9b9c009de9dfd2fb3ad7cb83a9716d9b6ef9911d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 15 Dec 2019 21:06:41 +0100 Subject: [PATCH] - copybyte is not the same as memcpy. It should be inlined to use it, though, because homegrown loops for this stuff may have been ok in 1995, but not in 2019. --- source/build/include/pragmas.h | 6 ++++++ source/build/src/engine.cpp | 22 ++++++++++++++++------ source/build/src/pragmas.cpp | 21 +++++++++++++++++++++ source/rr/src/net.cpp | 14 +++++++------- source/sw/src/sector.cpp | 2 +- 5 files changed, 51 insertions(+), 14 deletions(-) diff --git a/source/build/include/pragmas.h b/source/build/include/pragmas.h index 527cb03eb..922917289 100644 --- a/source/build/include/pragmas.h +++ b/source/build/include/pragmas.h @@ -189,6 +189,9 @@ void qinterpolatedown16short(intptr_t bufptr, int32_t num, int32_t val, int32_t #ifndef pragmas_have_clearbuf void clearbuf(void *d, int32_t c, int32_t a); #endif +#ifndef pragmas_have_copybuf +void copybuf(const void *s, void *d, int32_t c); +#endif #ifndef pragmas_have_swaps void swapbuf4(void *a, void *b, int32_t c); #endif @@ -196,6 +199,9 @@ void swapbuf4(void *a, void *b, int32_t c); #ifndef pragmas_have_clearbufbyte void clearbufbyte(void *D, int32_t c, int32_t a); #endif +#ifndef pragmas_have_copybufbyte +void copybufbyte(const void *S, void *D, int32_t c); +#endif #ifndef pragmas_have_copybufreverse void copybufreverse(const void *S, void *D, int32_t c); #endif diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 81cdea343..bce1a3be7 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -4478,7 +4478,7 @@ static void classicDrawBunches(int32_t bunch) smostwall[smostwallcnt] = z; smostwalltype[smostwallcnt] = 1; //1 for umost smostwallcnt++; - memcpy(&umost[x1],&smost[smostcnt],i*sizeof(smost[0])); + copybufbyte(&umost[x1],&smost[smostcnt],i*sizeof(smost[0])); smostcnt += i; } } @@ -4564,7 +4564,7 @@ static void classicDrawBunches(int32_t bunch) smostwall[smostwallcnt] = z; smostwalltype[smostwallcnt] = 2; //2 for dmost smostwallcnt++; - memcpy(&dmost[x1],&smost[smostcnt],i*sizeof(smost[0])); + copybufbyte(&dmost[x1],&smost[smostcnt],i*sizeof(smost[0])); smostcnt += i; } } @@ -5033,6 +5033,16 @@ static void classicDrawVoxel(int32_t dasprx, int32_t daspry, int32_t dasprz, int } } +#if 0 + for (x=0; x=0 && daumost[x]=0 && dadmost[x]=1;j--) { - memcpy(&nsyn[i],&inputfifo[g_player[i].movefifoend&(MOVEFIFOSIZ-1)][i],sizeof(input_t)); + copybufbyte(&nsyn[i],&inputfifo[g_player[i].movefifoend&(MOVEFIFOSIZ-1)][i],sizeof(input_t)); g_player[i].movefifoend++; } @@ -2233,7 +2233,7 @@ void Net_ParsePacket(uint8_t *packbuf, int packbufleng) osyn = (input_t *)&inputfifo[(g_player[other].movefifoend-1)&(MOVEFIFOSIZ-1)][0]; nsyn = (input_t *)&inputfifo[(g_player[other].movefifoend)&(MOVEFIFOSIZ-1)][0]; - memcpy(&osyn[other],&nsyn[other],sizeof(input_t)); + copybufbyte(&osyn[other],&nsyn[other],sizeof(input_t)); if (k&1) nsyn[other].fvel = packbuf[j]+((short)packbuf[j+1]<<8), j += 2; if (k&2) nsyn[other].svel = packbuf[j]+((short)packbuf[j+1]<<8), j += 2; if (k&4) @@ -2272,7 +2272,7 @@ void Net_ParsePacket(uint8_t *packbuf, int packbufleng) for (i=g_movesPerPacket-1;i>=1;i--) { - memcpy(&nsyn[other],&inputfifo[g_player[other].movefifoend&(MOVEFIFOSIZ-1)][other],sizeof(input_t)); + copybufbyte(&nsyn[other],&inputfifo[g_player[other].movefifoend&(MOVEFIFOSIZ-1)][other],sizeof(input_t)); g_player[other].movefifoend++; } @@ -2296,7 +2296,7 @@ void Net_ParsePacket(uint8_t *packbuf, int packbufleng) osyn = (input_t *)&inputfifo[(g_player[other].movefifoend-1)&(MOVEFIFOSIZ-1)][0]; nsyn = (input_t *)&inputfifo[(g_player[other].movefifoend)&(MOVEFIFOSIZ-1)][0]; - memcpy(&osyn[other],&nsyn[other],sizeof(input_t)); + copybufbyte(&osyn[other],&nsyn[other],sizeof(input_t)); k = packbuf[j] + (int)(packbuf[j+1]<<8); j += 2; @@ -2332,7 +2332,7 @@ void Net_ParsePacket(uint8_t *packbuf, int packbufleng) for (i=g_movesPerPacket-1;i>=1;i--) { - memcpy(&nsyn[other],&inputfifo[g_player[other].movefifoend&(MOVEFIFOSIZ-1)][other],sizeof(input_t)); + copybufbyte(&nsyn[other],&inputfifo[g_player[other].movefifoend&(MOVEFIFOSIZ-1)][other],sizeof(input_t)); g_player[other].movefifoend++; } diff --git a/source/sw/src/sector.cpp b/source/sw/src/sector.cpp index e62347ed8..d393242e2 100644 --- a/source/sw/src/sector.cpp +++ b/source/sw/src/sector.cpp @@ -3178,7 +3178,7 @@ void movelava(char *dapic) offs2 = (LAVASIZ + 2) + 1 + ((intptr_t) lavabakpic); for (x = 0; x < LAVASIZ; x++) { - memcpy(offs, offs2, LAVASIZ); + copybuf(offs, offs2, LAVASIZ >> 2); offs += LAVASIZ; offs2 += LAVASIZ + 2; }