Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 52 additions & 5 deletions src/SB/Core/x/xWad5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,41 @@ char* xUtil_idtag2string(U32 srctag, S32 bufidx)

S32 xUtilShutdown()
{
return g_xutilinit--;
return --g_xutilinit;
}

S32 xUtilStartup()
{
if (!g_xutilinit++)
{
xUtil_crc_init();
// From xUtil_crc_init:

S32 i, j;
U32 crc_accum;

if (g_crc_needinit)
{
for (i = 0; i < 256; i++)
{
crc_accum = (U32)i << 24;

for (j = 0; j < 8; j++)
{
if (crc_accum & (1 << 31))
{
crc_accum = (crc_accum << 1) ^ 0x04C11DB7;
}
else
{
crc_accum = (crc_accum << 1);
}
}

g_crc32_table[i] = crc_accum;
}

g_crc_needinit = 0;
}
}

return g_xutilinit;
Expand Down Expand Up @@ -468,6 +495,26 @@ S32 icompare(const substr& s1, const substr& s2)
return result;
}

S32 imemcmp(const void* d1, const void* d2, unsigned long size)
{
char* s1 = (char*)d1;
char* s2 = (char*)d2;
U32 i = 0;
while (i < size)
{
S32 v1 = *s1 | ((*s1 >> 1) & 0x20);
S32 v2 = *s2 | ((*s2 >> 1) & 0x20);
if (v1 != v2)
{
return v1 - v2;
}
s1++;
s2++;
i++;
}
return 0;
}

char* xStrupr(char* string)
{
char* p = string;
Expand All @@ -490,7 +537,7 @@ U32 xStrHashCat(U32 prefix, const char* str)
while (i = *str, i != NULL)
{
str++;
hash = (i - (i & (S32)i >> 1 & 0x20) & 0xff) + hash * 0x83;
hash = (i - (i & (U8)i >> 1 & 0x20) & 0xff) + hash * 0x83;
}

return hash;
Expand All @@ -506,7 +553,7 @@ U32 xStrHash(const char* str, size_t size)
{
i++;
str++;
hash = (c - (c & (S32)c >> 1 & 0x20) & 0xff) + hash * 0x83;
hash = (c - (c & (U8)c >> 1 & 0x20) & 0xff) + hash * 0x83;
}

return hash;
Expand All @@ -519,7 +566,7 @@ U32 xStrHash(const char* str)

while (i = *str, i != NULL)
{
hash = (i - (i & (S32)i >> 1 & 0x20) & 0xff) + hash * 0x83;
hash = (i - (i & (U8)i >> 1 & 0x20) & 0xff) + hash * 0x83;
str++;
}

Expand Down