Codevault questions and contributions!
Displaying 41-51 of 51 total.
prev 1 2 3
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
Ness

Fodder for the Alcove of Redundancy [Here]

It was an attempt at writing my own pathfinding system based on nodes, I even made an editor to place the nodes and everything. But somewhere things went very wrong. It works, but it's so slow that I just ended up using Rage's A* pathfinding. Oh well

Posted on 2004-12-30 08:37:22

zonker6666

Converts a binary number (stored in a string)
into a decimal #

example Bin2Dec('1111111')
would return 255


int Bin2Dec(string bits)
{
int i;
int bitlength=len(bits);
int temp;
int total;
int multiplier=1;
for(i=bitlength;i>0;i--)
{
temp=val(mid(bits, i-1, 1));
total+=temp * multiplier;
multiplier+=multiplier;
}
return total;
}

Posted on 2005-01-02 19:26:26

RageCage

Quote:Originally posted by Ness

Fodder for the Alcove of Redundancy [Here]

It was an attempt at writing my own pathfinding system based on nodes, I even made an editor to place the nodes and everything. But somewhere things went very wrong. It works, but it's so slow that I just ended up using Rage's A* pathfinding. Oh well


haha, that's crazy.. I created something almost exactly like that before I relaized what I was doing and made my Astar library.

Posted on 2005-01-03 00:15:36

Kildorf

[ This is where I had a function to do something until Zip pointed out that I am a redundant fool! :D ]

Sorry about that.

Posted on 2005-01-16 14:02:48 (last edited on 2005-01-18 15:58:31)

Zip

Looks like a broken version of the FileReadLine() that's already in the vault to be Kildorf...

Must add the rest of the contributions soon, bin busy... ;_;

Rar

Posted on 2005-01-18 04:34:40

OniFLOP

Just my first post in this forum.
I've been playing around with v3 a couple of weeks, and today I wrote some bit flags functions.
Hope they help.


/*
It can be useful for making easier status changes (that why i designed it)
Remember the limit of bits is 32 per int.

The functions RETURN the new value instead of changing the original.
To do that you have to use something like:

originalFlag = WhateverFlagBitOperation ( originalFlag, flagMaskOrOffset );

For more information on bit flags, visit: http://www.vipan.com/htdocs/bitwisehelp.html

*/

//The first two are simplified functions for reading or setting one bit at time
//Keep in mind that flagOffset can be 0-31.
//
int GetFlagBit ( int flagSource, int flagOffset )
{

int flagMask = ( pow(2, flagOffset));
return CheckFlagBits( flagSource, flagMask);

}

//Here flagNewValue can be 0, 1, or 2 (for switching to the opossite (1-bit not)
//any other value will return the flag without any change
int PutFlagBit ( int flagSource, int flagOffset , int flagNewValue )
{
int flagBuffer = flagSource;
int flagMask = ( pow(2, flagOffset));
switch (flagNewValue)
{
case 0 : flagBuffer = UnSetFlagBits( flagSource, flagMask );
case 1 : flagBuffer = SetFlagBits( flagSource, flagMask );
case 2 : flagBuffer = SwitchFlagBits( flagSource, flagMask );
}

return flagBuffer;
}



//The next four functions are the direct flag managing
//the bits that are 'on' (value==1) on flagMask indicate
//which bits is the operation made on flagSource
//
int CheckFlagBits ( int flagSource, int flagMask )
{

//Checks if ALL the set (value=1) bits on the mask are set on the flag
//and returns 1 if true or 0 if false

if ((flagSource & flagMask ) == FlagMask) {
return 1;
}
else {
return 0;
}
}


//Sets ALL the the bits on the flag that are set on the mask. All the other bits are left.
int SetFlagBits ( int flagSource, int flagMask )
{
return flagSource | flagMask;
}

//The same but it unsets (value=0) instead of setting
int UnSetFlagBits ( int flagSource, int flagMask )
{
return flagSource & BitwiseNot(flagMask);
}

//It sets the unset and unsets the set
//
int SwitchFlagBits ( int flagSource, int flagMask )
{
return flagSource ^ flagMask;
}


//A workaround for making a bitwise NOT in vergeC
//
int BitwiseNot(int sourceNumber)
{
return (pow(2, 32)-1)-sourceNumber;
}

Posted on 2005-03-01 20:53:47

OniFLOP

Just my first post in this forum.
I've been playing around with v3 a couple of weeks, and today I wrote some bit flags functions.
Hope they help.


/*
It can be useful for making easier status changes (that why i designed it)
Remember the limit of bits is 32 per int.

The functions RETURN the new value instead of changing the original.
To do that you have to use something like:

originalFlag = WhateverFlagBitOperation ( originalFlag, flagMaskOrOffset );

For more information on bit flags, visit: http://www.vipan.com/htdocs/bitwisehelp.html

*/

//The first two are simplified functions for reading or setting one bit at time
//Keep in mind that flagOffset can be 0-31.
//
int GetFlagBit ( int flagSource, int flagOffset )
{

int flagMask = ( pow(2, flagOffset));
return CheckFlagBits( flagSource, flagMask);

}

//Here flagNewValue can be 0, 1, or 2 (for switching to the opossite (1-bit not)
//any other value will return the flag without any change
int PutFlagBit ( int flagSource, int flagOffset , int flagNewValue )
{
int flagBuffer = flagSource;
int flagMask = ( pow(2, flagOffset));
switch (flagNewValue)
{
case 0 : flagBuffer = UnSetFlagBits( flagSource, flagMask );
case 1 : flagBuffer = SetFlagBits( flagSource, flagMask );
case 2 : flagBuffer = SwitchFlagBits( flagSource, flagMask );
}

return flagBuffer;
}



//The next four functions are the direct flag managing
//the bits that are 'on' (value==1) on flagMask indicate
//which bits is the operation made on flagSource
//
int CheckFlagBits ( int flagSource, int flagMask )
{

//Checks if ALL the set (value=1) bits on the mask are set on the flag
//and returns 1 if true or 0 if false

if ((flagSource & flagMask ) == FlagMask) {
return 1;
}
else {
return 0;
}
}


//Sets ALL the the bits on the flag that are set on the mask. All the other bits are left.
int SetFlagBits ( int flagSource, int flagMask )
{
return flagSource | flagMask;
}

//The same but it unsets (value=0) instead of setting
int UnSetFlagBits ( int flagSource, int flagMask )
{
return flagSource & BitwiseNot(flagMask);
}

//It sets the unset and unsets the set
//
int SwitchFlagBits ( int flagSource, int flagMask )
{
return flagSource ^ flagMask;
}


//A workaround for making a bitwise NOT in vergeC
//
int BitwiseNot(int sourceNumber)
{
return (pow(2, 32)-1)-sourceNumber;
}

Posted on 2005-03-01 20:53:54

Overkill

I've just done a similar code to that of yours after seeing this and getting inspired. I discovered a less hacky way to do the NOT operator! Emulation of other operators is a better idea than using integer limits to get the inverted value. Here is my code:



// Description: Performs a bit-wise OR operation.
// (Turns on a bit.)
// Pass: bit_field: Field of bits
// bit_mask: Individual bit.
// Returns: Result of the bit operation
// Credit: Overkill
int bit_or (int bit_field, int bit_mask)
{
return bit_field | bit_mask;
}

// Description: Performs a bit-wise AND operation.
// (Detect if a bit is on)
// Pass: bit_field: Field of bits
// bit_mask: Individual bit.
// Returns: Result of the bit operation
// Credit: Overkill
int bit_and (int bit_field, int bit_mask)
{
return bit_field & bit_mask;
}

// Description: Performs a bit-wise XOR operation.
// (Toggles a bit.)
// Pass: bit_field: Field of bits
// bit_mask: Individual bit.
// Returns: Result of the bit operation
// Credit: Overkill
int bit_xor (int bit_field, int bit_mask)
{
return bit_field ^ bit_mask;
}

// Description: Performs an *emulated* bit-wise NOT operation.
// (Turns off a bit.)
// Pass: bit_field: Field of bits
// bit_mask: Individual bit.
// Returns: Result of the bit operation
// Credit: Overkill
int bit_not (int bit_field, int bit_mask)
{
return (bit_field | bit_mask) ^ bit_mask;
}


EDIT: An even less hacky method for an emulated NOT operator has been created! Now it doesn't have needless if statements in it! Yay me.

Posted on 2005-03-02 15:06:57 (last edited on 2005-03-05 13:54:22)

Omni

How about this? Like ZSNES' scanline interpolation.



//Interpolate

//By Omni.
//
//Simply lets you generate horizontal interpolation on the screen.
//IE, a 320x240 screen becomes a 640x240 screen with interpolated values,
//smoothing out (some) sharp pixel edges.
//
//SETUP:
//1. Run your game in twice the desired resolution.
// (IE, if you run in 320x240, run in 640x480)
//2. Call O_Interpolate() right before ShowPage().



int oint_2xscale=0;
//If this is set to 1, O_interpolate will draw the screen without
//interpolation. Allows you to compare and see the difference.
int screen_shell = NewImage(ImageWidth(screen), ImageHeight(screen));

int oint_2xinterpolate=0;
//If set to 1, O_Interpolate interpolates the screen
//horizontally and vertically. This causes some slowdown.
//If zero, O_Interpolate only interpolates the screen horizontally.



void O_Interpolate() {
//Interpolate the screen horizontally.
//Essentially, the screen is now twice the horizontal width.
//Every new pixel column is a mix of the pixels from the left and right
//of it from the original source image.
//
//To accomplish in a hacky but hopefully fast way:
//1. Make an imageshell of the desired screen section.
// (will be half of the V3 resolution.
// (IE, if res = 640x480, we are then interpolating a 320x240 source image).
//2. Scale blit the shell to a temporary buffer.
//3. Additive blit the buffer at 50% lucency to the screen, twice, with a one
// pixel offset so that every other pixel column will be new and a composite
// blending of two pixel columns from the source image.
//
//AFTER CALLING THIS FUNCTION, LUCENCY IS RESET TO ZERO

int get_screen = ImageShell(0, 0, ImageWidth(screen)/2, ImageHeight(screen)/2, screen);
ScaleBlit(0, 0, ImageWidth(screen), ImageHeight(screen), get_screen, screen_shell);
FreeImage(get_screen);

if (!oint_2xscale)
{
RectFill(0, 0, ImageWidth(screen), ImageHeight(screen), RGB(0, 0, 0), screen);

//I need to set lucency to 1/4th (to compose new data from four blits)
//if interpolation is horizontal & vertical. Otherwise,
//lucency = 1/2th for just horizontal.
//
//Keep in mind when I say lucency I mean the intensity of the image, not it's see-through-ability.
//Thus for me I need 25% opacity and use 75% with SetLucent. Yeah. I screw terms up.

if (oint_2xinterpolate) SetLucent(75); else SetLucent(50);

AdditiveBlit(0, 0, screen_shell, screen);
AdditiveBlit(1, 0, screen_shell, screen);

if (oint_2xinterpolate) {
AdditiveBlit(1, 1, screen_shell, screen);
AdditiveBlit(0, 1, screen_shell, screen);
}

SetLucent(0);
}

if (oint_2xscale) Blit(0, 0, screen_shell, screen);
}

Posted on 2005-04-12 15:05:18 (last edited on 2005-04-12 17:09:40)

blues_zodiakos

I thought Verge3 already had those options hardcoded, available in verge.cfg? Or maybe that was an earlier version... I could have sworn it had 2xScale and EAGLE...

Posted on 2005-04-13 11:18:57

Omni

Er, according to the Docs that's not an option in Verge.cfg. WinVerge2 did have 2xSAI, but not Verge3.

Posted on 2005-04-13 13:13:31 (last edited on 2005-04-13 13:13:57)


Displaying 41-51 of 51 total.
prev 1 2 3
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.