[Glide64] Sync Glide64/DepthBufferRender.cpp

This commit is contained in:
zilmar 2015-10-12 10:13:19 +11:00
parent 5ff5ff0b12
commit 6e810ef559
1 changed files with 32 additions and 22 deletions

View File

@ -85,34 +85,44 @@ static int right_height, left_height;
static int right_x, right_dxdy, left_x, left_dxdy;
static int left_z, left_dzdy;
int imul16(int x, int y)
__inline int imul16(int x, int y) // (x * y) >> 16
{
int64_t result;
const int64_t m = (int64_t)(x);
const int64_t n = (int64_t)(y);
result = (m * n) >> 16;
return (int)(result);
return (((long long)x) * ((long long)y)) >> 16;
}
int imul14(int x, int y)
__inline int imul14(int x, int y) // (x * y) >> 14
{
int64_t result;
const int64_t m = (int64_t)(x);
const int64_t n = (int64_t)(y);
result = (m * n) >> 14;
return (int)(result);
return (((long long)x) * ((long long)y)) >> 14;
}
int idiv16(int x, int y)
__inline int idiv16(int x, int y) // (x << 16) / y
{
int64_t result;
const int64_t m = (int64_t)(x);
const int64_t n = (int64_t)(y);
result = (m << 16) / n;
return (int)(result);
//x = (((long long)x) << 16) / ((long long)y);
/*
eax = x;
ebx = y;
edx = x;
(x << 16) | ()
*/
#if !defined(__GNUC__) && !defined(NO_ASM)
__asm {
mov eax, x
mov ebx, y
mov edx,eax
sar edx,16
shl eax,16
idiv ebx
mov x, eax
}
#elif !defined(NO_ASM)
int reminder;
asm ("idivl %[divisor]"
: "=a" (x), "=d" (reminder)
: [divisor] "g" (y), "d" (x >> 16), "a" (x << 16));
#else
x = (((long long)x) << 16) / ((long long)y);
#endif
return x;
}
__inline int iceil(int x)
@ -121,7 +131,7 @@ __inline int iceil(int x)
return (x >> 16);
}
void RightSection(void)
static void RightSection(void)
{
// Walk backwards trough the vertex array