RE: [squeak-dev] for the operation MAP := B bitOr:( M bitShift:3)    given MAP how do I derive B and M?

Ron Teitelbaum ron at usmedrec.com
Wed Feb 12 20:27:48 UTC 2014


Yep.  That is exactly right.  

 

It’s all just 1’s and 0’s J

 

Ron

 

From: squeak-dev-bounces at lists.squeakfoundation.org [mailto:squeak-dev-bounces at lists.squeakfoundation.org] On Behalf Of gettimothy
Sent: Wednesday, February 12, 2014 6:44 AM
To: The general-purpose Squeak developers list    
Subject: RE: [squeak-dev] for the operation MAP := B bitOr:( M bitShift:3)    given MAP how do I derive B and M?

 

David and Ron.

Thank you. 

Its been decades since I have done any bit manipulation and I froze up (:

The answer came to me last night when I half-asleep.

It is clear now what was going on. Somebody needed the data in one field, so they scooched the modifiers up to the next three bits and then tacked on the button.

To reverse this I need to unscooch and un-tack.

When I posted  the question, I was looking at MAP and thinking, "Ok, its close to 64 that means its this, so do that" which is way off base.


Sorry for the noise; I am better now (:


humbly.


tty





---- On Tue, 11 Feb 2014 19:49:12 -0800 Ron Teitelbaum<ron at usmedrec.com> wrote ---- 

 

Hello,

 

B= map bitAnd: 7.

M= map bitShift: -3.

 

All the best,

 

Ron Teitelbaum

 

 

From: squeak-dev-bounces at lists.squeakfoundation.org [mailto:squeak-dev-bounces at lists.squeakfoundation.org] On Behalf Of gettimothy
Sent: Tuesday, February 11, 2014 9:06 PM
To: The general-purpose Squeak developers list
Subject: [squeak-dev] for the operation MAP := B bitOr:( M bitShift:3) given MAP how do I derive B and M?

 

To reverse a MorphicEvent into an primitive event I need to unmap the buttons and modifiers.
In a primitive event, the fifth element (buttons) can be 1,2 or 4 and the sixth element (modifiers)  1,2,4 or 8.

HandMorph >> generateMouseEvent combines them into one field as such:

    buttons := evtBuf fifth.
    modifiers := evtBuf sixth.
    buttons := buttons bitOr: (modifiers bitShift: 3).


I need to reverse that   "buttons bitOr: (modifiers bitShift: 3)" back into the original values to recreate the primitive event.
Here are the possible values of B(uttons) and M(odifiers) under that operation:


B           M                 MAP
1 bitOr:(1 bitShift:3 ) 9
1 bitOr:(2 bitShift:3 ) 17
1 bitOr:(4 bitShift:3 ) 33
1 bitOr:(8 bitShift:3 ) 65


2 bitOr:(1 bitShift:3 )  10
2 bitOr:(2 bitShift:3 )  18
2 bitOr:(4 bitShift:3 )  34
2 bitOr:(8 bitShift:3 )  66


4 bitOr:(1 bitShift:3 )   12
4 bitOr:(2 bitShift:3 )   20
4 bitOr:(4 bitShift:3 )   36
4 bitOr:(8 bitShift:3 )   68

So, given a MAP on the right, I need to derive a B and a M.

I can figure something out, but it will probably be ugly. Hence, this email to the list.
Any bit-fiddlers on the board who know an elegant method?

thx.

tty.

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20140212/62db6e1d/attachment.htm


More information about the Squeak-dev mailing list