Jump to content


Photo

Bit Write/Read Dll


  • Please log in to reply
14 replies to this topic

#1 h0bbel

h0bbel

    GMC Member

  • New Member
  • 252 posts

Posted 18 September 2006 - 06:29 PM

Hobbel Bit DLL

This DLL allows you to write and read bits from a file with Game Maker.
A very useful feature is that you can set a size of bits you want to read or write.

So you can write a 3 bits integer without creating to much file size on writing a byte (8 bits).

For example view this:
(link removed)

In the download a file called "bitlist.txt" is included wich has a list of bit size 1 till 31, followed by the maximum value can be writed with that number of bits.
Ofcourse a .gmd example, the .gml scripts, and .gmd and .gm6 embed files are included.

Example screenshot:
(link removed)


(link removed)


Edit:
The multi bit writing goes in one call,
like writing 16 bits
Bit_MWrite (handle,16,value);

Writing 4 bits twice, only writes one byte like this:
val 1: 1111 val 2: 1111
Data writed: 11111111

My dll only writes the bits into a byte when enough bits are given (except you close writing),
the same fact goes for reading.


I've added this to stop confusion for a bit ...


Edited by h0bbel, 19 September 2013 - 06:55 PM.

  • 0
The empty archive bug should be fixed on my site.
Please use the "report bug" button on my site to report bugs, makes things clearer.

#2 Ruby

Ruby

    Ruby Software

  • New Member
  • 203 posts

Posted 18 September 2006 - 06:59 PM

What can I do with it?
  • 0
No longer active on GMC

#3 IsmAvatar

IsmAvatar

    Good Samaritan

  • GMC Member
  • 2411 posts
  • Version:GM8

Posted 18 September 2006 - 07:09 PM

Read/Write bits from/to files. It's like file_bin_open, but it's file_bit_open, because you're dealing with bits instead of bytes.

I was planning on writing such an extension for my bin dll.
  • 0
Posted Image LateralGM is an IDE for editing GM files on Linux, Mac, and Windows.
We also house the GM File Format Documentation and other projects of that nature.
IsmAvatar.com | Examples | Scripts | Particles | DLLs | Credit Me
Email | Registered

#4 Ruby

Ruby

    Ruby Software

  • New Member
  • 203 posts

Posted 18 September 2006 - 07:11 PM

Oh.

vvvvvvvvvvv
  • 0
No longer active on GMC

#5 petersvp

petersvp

    GMC Member

  • GMC Member
  • 129 posts

Posted 18 September 2006 - 07:14 PM

This seems great. Now I can make my game to save smaller files than before. Idea seems good
  • 0

#6 Darth

Darth

    GMC Member

  • New Member
  • 436 posts

Posted 18 September 2006 - 07:17 PM

Cool, this is what I thought the file_bin functions were.
After doing some more reading I found out they write bytes. I still don't see the point of the functions/how to use them (usefully too).
But this I can see many uses for.
  • 0
Game maker 8 Pro

#7 IsmAvatar

IsmAvatar

    Good Samaritan

  • GMC Member
  • 2411 posts
  • Version:GM8

Posted 18 September 2006 - 07:58 PM

The most difficult part would be converting your numbers into bits. Not to mention, it would be incredibly slow because of all the dll calls (8 per byte, 32 per integer, 64 per double, mass horror per string). Which is why I was only planning on "implementing" it into my bin dll. It would be a small aspect that allows you to offset the entire file by 1 bit (thus, size efficiency) each call. That in addition to all the other calls like byte, word, smallint, integer, double, and String
  • 0
Posted Image LateralGM is an IDE for editing GM files on Linux, Mac, and Windows.
We also house the GM File Format Documentation and other projects of that nature.
IsmAvatar.com | Examples | Scripts | Particles | DLLs | Credit Me
Email | Registered

#8 h0bbel

h0bbel

    GMC Member

  • New Member
  • 252 posts

Posted 18 September 2006 - 08:22 PM

The most difficult part would be converting your numbers into bits. Not to mention, it would be incredibly slow because of all the dll calls (8 per byte, 32 per integer, 64 per double, mass horror per string). Which is why I was only planning on "implementing" it into my bin dll. It would be a small aspect that allows you to offset the entire file by 1 bit (thus, size efficiency) each call. That in addition to all the other calls like byte, word, smallint, integer, double, and String

<{POST_SNAPBACK}>


My DLL càn write 8,32 or 64 bits in one call.

Bit_MWrite (handle,8,value);
Bit_MWrite (handle,32,value);
Bit_MWrite (handle,64,value);

The function to write òne bit is called Bit_Write (handle,value);

Edited by h0bbel, 18 September 2006 - 08:28 PM.

  • 0
The empty archive bug should be fixed on my site.
Please use the "report bug" button on my site to report bugs, makes things clearer.

#9 IsmAvatar

IsmAvatar

    Good Samaritan

  • GMC Member
  • 2411 posts
  • Version:GM8

Posted 18 September 2006 - 09:31 PM

Actually I don't think it can write a double. I haven't tried yet, but recall that a double includes the decimal part. But thanks for pointing that out.

Also, it doesn't handle Strings or Endienness, whereas mine does. At any rate, good work.
  • 0
Posted Image LateralGM is an IDE for editing GM files on Linux, Mac, and Windows.
We also house the GM File Format Documentation and other projects of that nature.
IsmAvatar.com | Examples | Scripts | Particles | DLLs | Credit Me
Email | Registered

#10 BZGaming

BZGaming

    GMC Member

  • New Member
  • 514 posts

Posted 18 September 2006 - 09:52 PM

doubles in files are technically longs (or long ints), they are stored in 8 bytes and then when loaded they are converted back into doubles from longs.

BZ
  • 0

#11 h0bbel

h0bbel

    GMC Member

  • New Member
  • 252 posts

Posted 19 October 2006 - 02:57 PM

The most difficult part would be converting your numbers into bits. Not to mention, it would be incredibly slow because of all the dll calls (8 per byte, 32 per integer, 64 per double, mass horror per string). Which is why I was only planning on "implementing" it into my bin dll. It would be a small aspect that allows you to offset the entire file by 1 bit (thus, size efficiency) each call. That in addition to all the other calls like byte, word, smallint, integer, double, and String

<{POST_SNAPBACK}>


My DLL càn write 8,32 or 64 bits in one call.

Bit_MWrite (handle,8,value);
Bit_MWrite (handle,32,value);
Bit_MWrite (handle,64,value);

The function to write òne bit is called Bit_Write (handle,value);

<{POST_SNAPBACK}>


What do you exactly mean with endieness ? :P
  • 0
The empty archive bug should be fixed on my site.
Please use the "report bug" button on my site to report bugs, makes things clearer.

#12 Core_12

Core_12

    Commander

  • New Member
  • 154 posts

Posted 19 October 2006 - 04:22 PM

It means the order at which bits are stored, either most significant bit first or least significant bit first.

http://en.wikipedia....wiki/Endianness
  • 0

#13 h0bbel

h0bbel

    GMC Member

  • New Member
  • 252 posts

Posted 19 October 2006 - 07:13 PM

It means the order at which bits are stored, either most significant bit first or least significant bit first.

http://en.wikipedia....wiki/Endianness

<{POST_SNAPBACK}>


OK, thanks for the link.
  • 0
The empty archive bug should be fixed on my site.
Please use the "report bug" button on my site to report bugs, makes things clearer.

#14 alexmason

alexmason

    GMC Member

  • New Member
  • 3 posts

Posted 23 June 2008 - 09:48 PM

Very nice ^^. Now I was also wondering, is there anyway to output text to a file, like for instance, how in msdos you can echo to files. Can this be dont from game maker? See I'm making a game somewhat like runescape, but a 2d version, and need a way to save the player's progress without using global variables and such, because there are too many items and such things to keep track of. So i was looking for a sort of: write to file game.txt "variable_shield1=465" or something. It would be much more complicated than that, or else script kiddies could screw with the game lol.

Thanks,

Alex Mason ^^
  • 0

#15 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • GMC Elder
  • 9603 posts
  • Version:GM:Studio

Posted 24 June 2008 - 12:55 AM

Very nice ^^. Now I was also wondering, is there anyway to output text to a file, like for instance, how in msdos you can echo to files. Can this be dont from game maker? See I'm making a game somewhat like runescape, but a 2d version, and need a way to save the player's progress without using global variables and such, because there are too many items and such things to keep track of. So i was looking for a sort of: write to file game.txt "variable_shield1=465" or something. It would be much more complicated than that, or else script kiddies could screw with the game lol.

Thanks,

Alex Mason ^^

I don't know why you posted that here, but look up in the GM Help File the file_text_open and file_text_write functions.

-IMP :) :)
  • 0

:GM123: Are you an artist who likes creating original creature designs? Maybe you can help out with Elementa here! Give it a look; you might like the idea :)

:bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: