Skip to content

Commit 6433573

Browse files
committed
Simplify Calc_invw() for ZSort ucode.
1 parent 90db9eb commit 6433573

File tree

1 file changed

+4
-41
lines changed

1 file changed

+4
-41
lines changed

src/uCodes/ZSort.cpp

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -58,48 +58,11 @@ void ZSort_RDPCMD( u32, u32 _w1 )
5858
}
5959
}
6060

61-
//RSP command VRCPL
62-
static
61+
inline
6362
int Calc_invw (int _w) {
64-
int count, neg;
65-
union {
66-
s32 W;
67-
u32 UW;
68-
s16 HW[2];
69-
u16 UHW[2];
70-
} Result;
71-
Result.W = _w;
72-
if (Result.UW == 0) {
73-
Result.UW = 0x7FFFFFFF;
74-
} else {
75-
if (Result.W < 0) {
76-
neg = TRUE;
77-
if (Result.UHW[1] == 0xFFFF && Result.HW[0] < 0) {
78-
Result.W = ~Result.W + 1;
79-
} else {
80-
Result.W = ~Result.W;
81-
}
82-
} else {
83-
neg = FALSE;
84-
}
85-
for (count = 31; count > 0; --count) {
86-
if ((Result.W & (1 << count))) {
87-
Result.W &= (0xFFC00000 >> (31 - count) );
88-
count = 0;
89-
}
90-
}
91-
Result.W = 0x7FFFFFFF / Result.W;
92-
for (count = 31; count > 0; --count) {
93-
if ((Result.W & (1 << count))) {
94-
Result.W &= (0xFFFF8000 >> (31 - count) );
95-
count = 0;
96-
}
97-
}
98-
if (neg == TRUE) {
99-
Result.W = ~Result.W;
100-
}
101-
}
102-
return Result.W;
63+
if (_w == 0)
64+
return 0x7FFFFFFF;
65+
return 0x7FFFFFFF / _w;
10366
}
10467

10568
static

0 commit comments

Comments
 (0)