[PLUGIN] Bitwise Operations

Completed plugins, behaviors and effects.

Post » Tue Dec 06, 2011 8:26 am

I'd love to have my own data constructions to store them somewhere (e.g. to a hash table)

Something like id, x, y, animation frame could be a simple string like "A19EB408"

ACEs:
hex2decimal
returns the decimal expression of the hex-value

decimal2hex
returns the hexadecimal expression of the number

sethex (hex, number, byte position, byte length)
changes hex by converting number and change the specified part of hex ("A31C012B", 255, 3, 1 -> "A31CFF2B")

gethex (hex, byte position, byte length)
returns the decimal expression of the specified part of hex ("A31C012B", 2, 2 -> 7169)

Good luck for the contest :)
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Tue Dec 06, 2011 11:00 am

ok, I just hope that I can easily go back and forth between string and hexadecimal int in c++ 'cause I might not look like it but I'm still a c++ n00b

For instance dec2bin and bin2dec functions of the current plugin aren't really good/usefull because of int limitations.
'Cause after all, bitwise operations are made on decimal int.
So you will probably set things in decimal and the hexadecimal calculation will probably just be under the hood. Like with bitwise stuff.
Hmmm... maybe an hex2dec function to be able to set things in hexadecimal format with a string... hmmm... If I can easily typecast string to hex int as I said...
I'm thinking while typing...

Remind me at the end of the month I might get carried away in other projects (:Yann2011-12-06 11:06:57
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Wed Dec 07, 2011 8:51 pm

With C++ you have limits on the data type values you can use:

signed: -2147483648 to 2147483647
unsigned: 0 to 4294967295

etc, maybe use a long int for the Binary to decimal problem or maybe use doubles then round to int again etc.

Using a string input as a workaround then converting data types could also work.FireLight2011-12-07 20:54:32
B
9
S
3
G
4
Posts: 55
Reputation: 2,607

Post » Wed Dec 07, 2011 10:42 pm

well, it's a pain and I don't have that much room for conversion 'cause the param you enter in cc when you use the plugin are input in the plugin via either simple int or string (as far as I know param[0].GetInt() or param[0].GetString() are the function used to retrieve the param). I'm not knowledgeable enough to know if I can create my own GetLongInt() function to handle that.
And anyway, dec2bin and bin2dec really are just for checking how bitwise operation works, you really don't need that in the code itself.
you will do a 8 and 4 (knowing that "binarily" it is 1000 and 100) If you do a bin2dec(1000) and bin2dec(100) instead, you lose all the speed and efficiency of bitwise operation.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Wed Aug 01, 2012 9:30 am

I just wanted to say thanks for this. I'd been searching the manual for this kind of functionality, only to find that it isn't implemented in Construct. Good thing we can extend its functionality with plugins.
B
6
Posts: 27
Reputation: 404

Post » Wed Aug 01, 2012 9:06 pm

@Elyzius you're welcome (:
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Fri Aug 31, 2012 9:43 am

thanks, this is very handy. are singed binaries implemented?

and also, was the hex implementation any successful?
B
6
S
1
G
1
Posts: 52
Reputation: 858

Post » Fri Aug 31, 2012 12:31 pm

@superpowerjoe
I don't remember :D
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Previous

Return to Completed addons

Who is online

Users browsing this forum: No registered users and 0 guests