User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11

Thread: [Idea/Request] Bit Mask Object

  1. #1
    Clicker Multimedia Fusion 2

    Join Date
    Sep 2006
    Location
    Britain, South Coast
    Posts
    1,030
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Idea/Request] Bit Mask Object

    Thought this object could be quite handy, and reasonably simple to develop. A similar one already existed for MMF1.5:

    A Bit Object for handling individual bits in a value (I think it was called the Bit Mask Object).

    It would have the following features:

    Bit Masking

    Taking a value, and changing its bits using a masking string. EG:

    changeBits("BMO", 32, "110--t--")

    BMO is the name of the object.
    This would take the value '32' (00100000) and convert it using the bit mask "110--t--"

    In the mask, the possible characters are:
    0 = force this bit to '0'
    1 = force this bit to '1'
    t = toggle this bit. So 1 becomes 0 and 0 becomes 1.
    - = leave this bit as it is.

    So the result would be 11000100 (196).

    It could be useful for storing flags in objects that may not inherently handle flags, since it's just one number. You could also pass traits on to other objects easily. For example, suppose you had a game where an object has a series of flags, and when it shoots another object, the flags it has are passed on to its opponent. This could be done by copying just one value, instead of loads of individual flags.

    You could also organise flags in alterable values, thereby giving them names. So a set of flags named 'Conversations' and 'Inventory data' and 'Level Settings' etc.


    It could have a few settings that could be altered at runtime, such as:
    - Left/Right aligned (e.g. if we have a 32 bit '0' and we have a mask of '011' (only 3 digits), LEFT align gives '01100000' and RIGHT align gives '00000011')
    - Reverse value (e.g. a value like 217 (11011001) would become 155 (10011011). Literally the bits go from abcdefgh to hgfedcba)



    It could potentially have a slightly more complex markup like this if people thought it might be useful, by adding a few more characters:

    ' = start a statement
    * = repeat the statement to the end

    eg:

    1* = 11111111 (1 repeated in all further bits)
    '10* = 10101010 (10 repeated in all further bits)
    111'10* = 11110101 (111, then 10 repeated afterwards)
    10*101 = 10101101 (10 repeated until the last three digits, which are 101)

    Can't think of a use for the additional statements above, but the rest would be very handy.

    Bit Blending with Mask

    This would allow two values to be blended with a mask, e.g.

    bitblend("BMO", 255, 217, "aox01fL0")

    a = ADD
    o = OR
    x = XOR
    0 = always a 0
    1 = always a 1
    f = the bit from the FIRST value
    L = the bit from the LAST value

  2. #2
    Clicker Multimedia Fusion 2 Developer
    Jax's Avatar
    Join Date
    Jul 2006
    Location
    UK
    Posts
    702
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: [Idea/Request] Bit Mask Object

    Here you go: http://people.pwf.cam.ac.uk/jlnw3/mmf/BitMask.zip

    I didn't add the repeating character things as this was only a quick thing. The left/right align isn't done either (I prefer to think of it as all right-to-left, even though that isn't how it is stored in memory)

    Feedback/Bugs/Better icon appreciated.

  3. #3
    Clicker Multimedia Fusion 2

    Join Date
    Sep 2006
    Location
    Britain, South Coast
    Posts
    1,030
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: [Idea/Request] Bit Mask Object

    WOW, thanks!

    You could possibly add a 'get number of bits' expression, for use with Get Nth Bit.

    So '6' (110) would return a bit length of 3.

    I'll try and make an icon for you.

  4. #4
    Clicker Multimedia Fusion 2 Developer
    Jax's Avatar
    Join Date
    Jul 2006
    Location
    UK
    Posts
    702
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: [Idea/Request] Bit Mask Object

    Would this really be so useful? There are always 32 bits. This would just let you know which the bit is the last 'on' bit. Well I'll add it sometime if you like. It is just ceil(log[x]/log[2]).

    I really need an icon for this!

    Edit: Just saw your edit, thanks!

  5. #5
    Clicker Multimedia Fusion 2

    Join Date
    Sep 2006
    Location
    Britain, South Coast
    Posts
    1,030
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: [Idea/Request] Bit Mask Object

    Lol, yeah, i hit Submit instead of preview! The ceil thing isn't too useful, just so you can choose not to have padded zeros if you wanna read only the relevant bits. It would be nice to have a little checkbox to toggle the endianness, cos I mostly work with the HO bit first (i forget if that's big endian or little endian), but this is lovely, thankyou!

    I'll do an icon when I can, gotta sleep now

  6. #6
    Clicker Multimedia Fusion 2 DeveloperSWF Export Module

    Join Date
    Jun 2006
    Posts
    6,773
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: [Idea/Request] Bit Mask Object

    I hope this is an incentive to keep you in one place

  7. #7
    Clicker Multimedia Fusion 2 Developer
    Jax's Avatar
    Join Date
    Jul 2006
    Location
    UK
    Posts
    702
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: [Idea/Request] Bit Mask Object

    *poke* Icon?

  8. #8
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export ModuleUnicode Add-on
    LIJI's Avatar
    Join Date
    Jun 2006
    Location
    Israel
    Posts
    1,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: [Idea/Request] Bit Mask Object

    http://clickteam.info/neatwares/stuff/LIJI/BitMask.bmp

    256 Colors BMP for VC++.

  9. #9
    Clicker Multimedia Fusion 2 Developer
    Jax's Avatar
    Join Date
    Jul 2006
    Location
    UK
    Posts
    702
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: [Idea/Request] Bit Mask Object

    Cool thanks LIJI. I've updated it, added some docs and included the source code. Download here: http://people.pwf.cam.ac.uk/jlnw3/mmf2/mmf2.htm

  10. #10
    Clickteam Clickteam
    Olivier's Avatar
    Join Date
    Jun 2006
    Posts
    3,000
    Mentioned
    9 Post(s)
    Tagged
    1 Thread(s)

    Re: [Idea/Request] Bit Mask Object

    Quote Originally Posted by Jax
    I haven't made any worthwhile MMF2 extensions yet
    You liar!

Page 1 of 2 1 2 LastLast

Similar Threads

  1. [Request/Idea] Line of Sight Object
    By Dines in forum Extension Development
    Replies: 15
    Last Post: 5th December 2009, 10:58 PM
  2. [Request / Idea] Expression Object
    By Dines in forum Extension Development
    Replies: 7
    Last Post: 29th October 2009, 11:43 PM
  3. [Request/Idea] Frame Ticker Object
    By Dines in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 28th February 2008, 03:56 PM
  4. [Request/Idea] Icon Object
    By LIJI in forum Extension Development
    Replies: 5
    Last Post: 15th July 2007, 09:35 AM
  5. [Request/Idea] Font Installer Object
    By Dines in forum Extension Development
    Replies: 15
    Last Post: 23rd January 2007, 02:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •