Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - ZH

#1
Quote from: Lyaer on Fri 01/01/2010 09:49:41Is using bits in a char or int to store a series of binary values any faster

No, it's definitely slower. Additionally, as of version 0.3, certain short and int functions are slower than the corresponding char function, due to slight optimizations I made to the char one but not to the others. I'll probably do the same with those for the next release.

Quote from: Lyaer on Fri 01/01/2010 09:49:41or more space efficient than using multiple bools?

Yes. I don't know the details of AGS's implementation, but boolean types usually take one byte; some compilers (for example, pre-.NET Visual Basic) use two bytes per boolean. You can use as many as eight bits on a char, sixteen bits on a short, or thirty-two bits on an int. If you have to store very many boolean values, storing eight per byte rather than one per byte would reduce memory consumption. The number of boolean values you have to store would have to be very large to overcome the overhead of writing and reading the bits, though.
Edit: I don't remember why I thought the stricken-out part. If you have more than a few status effects, it would reduce memory consumption.

Quote from: Lyaer on Fri 01/01/2010 09:49:41is there a chance that storing all these values in one int per struct instead of several bools would notably improve ... filesize?

Probably, but to be certain I would have to know how the AGS savegame format works.
#2
Quote from: marcusbuggerSorry, I don 't know how 2 use the /code function what you mean.

“[code]
// Automatically converted interaction variables
int IntVar_Global_1 = 0;
export IntVar_Global_1;
int brick;
int small;
int seck;
int dor;
int second = 5;
int dorp;
int min;
// main global script file
[/code]”

is rendered as:

Code: ags

// Automatically converted interaction variables
int IntVar_Global_1 = 0;
export IntVar_Global_1;
int brick;
int small;
int seck;
int dor;
int second = 5;
int dorp;
int min;
// main global script file
#3
Quote from: Dualnames on Wed 30/12/2009 13:32:08I mean where would I need it?
You never really need it, but it makes getting or changing specific bits easier.
Edit: To be more specific, it's useful mostly for

  • moving sequences of bits across byte boundaries
  • copying some bits but not others
Quote from: Khris on Wed 30/12/2009 15:29:18
I've started creating a tile map editor, and the tile map format exported by ProMotion uses bits to store stuff like whether the tile is flipped, etc. so I had to write those functions myself.
That's just one possible use for that module
Yes.
Quote from: Khris
Weird.
How so?
#4
The bit manips module includes bit manipulation functions (getting bits, changing bits, and copying sequences of bits) for char, short, and int.

This module is written for AGS 3.1.

The only documentation that should be necessary is in the comments of the script header file.

This module does not conform to the Script Module Guidelines; if its deviation bothers you, you can change it.

Quote from: ZH, 2009/Dec/30
I, the copyright holder of this work, hereby release it into the public domain. This applies worldwide.
In case this is not legally possible:
 I grant anyone the right to use this work for any purpose, without any conditions, unless such conditions are required by law.

Changes:

  • v. 0.4:
    • made more speed optimizations
  • v. 0.3:
    • added the function construct_byte
    • made various speed optimizations
  • v. 0.2:
    • fixed the functions that copy sequences of bits
  • v. 0.1:
    • first version




Download (Add ".zip" to the end of the filename.)
SMF spam blocked by CleanTalk