Quick and dirty memcpy_xray implementation

This commit is contained in:
Adam Greenwood-Byrne 2021-03-12 10:28:59 +00:00
parent 22ac7a36cd
commit ffaa704be5
3 changed files with 18 additions and 2 deletions

View file

@ -19,7 +19,6 @@ void *memset(void *dest, unsigned int val, unsigned len)
return dest; return dest;
} }
void *memcpy(void *dest, const void *src, unsigned len) void *memcpy(void *dest, const void *src, unsigned len)
{ {
unsigned int *d = dest; unsigned int *d = dest;
@ -29,6 +28,22 @@ void *memcpy(void *dest, const void *src, unsigned len)
return dest; return dest;
} }
void *memcpy_xray(void *dest, const void *src, unsigned len)
{
unsigned int *d = dest;
const unsigned int *s = src;
while (len--) {
if (*s != 0) {
*d++ = *s++;
} else {
d++;
s++;
}
}
return dest;
}
int abs(int i) int abs(int i)
{ {
return i < 0 ? -i : i; return i < 0 ? -i : i;

View file

@ -48,6 +48,7 @@ extern short bx,by,tx,ty;
void *memset(void *dest, unsigned int val, unsigned len); void *memset(void *dest, unsigned int val, unsigned len);
void *memcpy(void *dest, const void *src, unsigned len); void *memcpy(void *dest, const void *src, unsigned len);
void *memcpy_xray(void *dest, const void *src, unsigned len);
int abs(int i); int abs(int i);
int strlen(const char *str); int strlen(const char *str);

View file

@ -3,7 +3,7 @@
// We should replace this with faster version (and xray needs to do the right thing - not sure memcpy is a good replacement) // We should replace this with faster version (and xray needs to do the right thing - not sure memcpy is a good replacement)
#define fastcopy memcpy #define fastcopy memcpy
#define putxray memcpy #define putxray memcpy_xray
block wnewblock (short x, short y, short x2, short y2) block wnewblock (short x, short y, short x2, short y2)
{ {