[Bug 18916] Thief 2 crashes when bringing up in-game menu

wine-bugs at winehq.org wine-bugs at winehq.org
Tue Jun 16 07:59:36 CDT 2009


http://bugs.winehq.org/show_bug.cgi?id=18916





--- Comment #14 from Michael Abbott <michael at araneidae.co.uk>  2009-06-16 07:59:35 ---
(In reply to comment #12)
> We essentially need to multiply by (0xffffff/0x7fff) and round correctly

Ok, I get it.

How about this then (I take it WORD is unsigned, otherwise this won't quite
work):

    WORD d15 = source[x] & 0xfffe;
    DWORD d24 = (d15 << 8) + (d15 >> 7);

?  Saves multiplies and more importantly divides and is pretty accurate:
effectively I've rewritten 

    1/(2^15-1) ~~ 2^-15 + 2^-30

(the 2^-45 term won't interest us) and so

    (2^24-1)/(2^15-1) * d15/2  ~~  2^8 d15 + 2^-7 d15 .

Certainly this works properly for d15 = 0xfffe.  I'm not worried about the
dangling half bit.  I can do a detailed error analysis if you're not convinced,
the worst error is just under half a bit -- if we really care, I can try to
figure out how to get it back, but I'm sure we don't ;-)

I do this kind of nonsense a lot on the ARM, where divide is to be studiously
avoided in inner loops!

I'll test your patch this evening.

-- 
Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email
Do not reply to this email, post in Bugzilla using the
above URL to reply.
------- You are receiving this mail because: -------
You are watching all bug changes.



More information about the wine-bugs mailing list