Jump to content


Photo

BinMan


  • Please log in to reply
3 replies to this topic

#1 top hunter7

top hunter7

    GMC Member

  • New Member
  • 1043 posts

Posted 23 July 2010 - 03:12 PM


Posted Image
Written by Andrew Bennett (top hunter7)

What is the BinMan Library?
The BinMan Library is a collection of scripts that extend the binary capabilities of the built-in GM functions, without the need for DLL's or Pro.

Why use BinMan?
If you just used GM's built-in binary functions, you can only handle real values between 0 and 255.
Using these scripts you can use much larger values as well as other data types.


What does BinMan support?
BinMan currently supports:

  • Signed / Unsigned Byte (1 byte | 8bit)
  • Signed / Unsigned Short (2 bytes | 16bit)
  • Signed / Unsigned Int (4 bytes | 32bit)
  • Signed / Unsigned Long (8 bytes | 64bit)
  • Null terminated/fixed length strings (length+null byte)
  • Single characters (1 byte | 8bit)
  • Including files (size+3 bytes | max. 16MB size)
  • Password protected encryption


This is slower than xxx.DLL?!
Because all the scripts I wrote use built in GM functions, you would expect them to be slower than a compiled language. The main use for these scripts is that they are simple to use and they do not require Pro.

Are these scripts compatible with how other files would read/write these data types?
They should be. I don't know enough in other languages to be able to test with, but the scripts deal with the bytes the way all documentation describes they should.

I have a suggestion/error I'd like to tell you about.
Please send me a PM on the GMC and I will get back to you as soon as possible.

Download
Download BinManlib from Host-A.NET

Terms of Use
When using this library in your projects, please give credit to Andrew Bennett or top hunter7


  • 0

Posted Image


#2 score_under

score_under

    Least kawaii

  • GMC Member
  • 1321 posts

Posted 23 July 2010 - 10:59 PM

Just so you know, you aren't handling signed values correctly and you're using the wrong endian encoding.

Examples:
Number: 258.
Your DLL outputs: 00 00 01 02
Should output: 02 01 00 00

Number: -1
Your DLL outputs: 80 00 00 00
Should output: FF FF FF FF

Also, I threw together a few functions to write float and double values (yes, compatible with other languages and DLLs). Just wondering if you wanted to use them. A float can represent, to a low accuracy, a non-integer. (For example, 4.56). A double represents it to the same accuracy that Game Maker does, as it is Game Maker's internal storage type.

I wrote them to follow the same syntax as yours. Here they are, feel free to use and/or integrate them:
http://dl.dropbox.co...loat_double.gml

Edit - Float is 4-byte, 32-bit, with 1 sign bit, an 8-bit exponent and a 23-bit significand, while Double is 64-bit, with 1 sign bit, an 11-bit exponent and a 52-bit significand. There is no unsigned option.

Edit2 - This is what your fileBinWriteInt and fileBinReadInt functions should do to comply to standards (and endiannesses): http://dl.dropbox.co...3/write_int.gml
Hopefully it shouldn't be too hard for you to adapt that to short, long, and byte types too. (Though be wary, as "long" values are just very slightly out of GM's range for precision.)

Edited by score_under, 23 July 2010 - 11:30 PM.

  • 1

Anti-Decompiler for GM6.1 to GM8.1.91! :GM8_new: [Main skin by Sindarin]
Discontinued.

decimal2.png
^ Signature image because it's been sorta empty since the old host died

If you need to contact me, I still get notification emails from PMs.


#3 top hunter7

top hunter7

    GMC Member

  • New Member
  • 1043 posts

Posted 24 July 2010 - 10:33 AM

Thanks for the reply score_under.

So basically what you're saying is that when writing bytes to the file, I'm writing them in reverse?

As for the handling of signed values, I could've swore I was doing it right. :P

Thanks for the scripts as well, I was going to look into how floats/doubles worked. :P

I'll be releasing an update as soon as I fix what is not correct thus far. :)
  • 0

Posted Image


#4 score_under

score_under

    Least kawaii

  • GMC Member
  • 1321 posts

Posted 26 July 2010 - 09:32 PM

If you're having any trouble implementing the newer functions, just send a PM my way and I'll see if there's anything I can help with.
  • 0

Anti-Decompiler for GM6.1 to GM8.1.91! :GM8_new: [Main skin by Sindarin]
Discontinued.

decimal2.png
^ Signature image because it's been sorta empty since the old host died

If you need to contact me, I still get notification emails from PMs.