Jump to content
  • Advertisement
Sign in to follow this  
losethos

Adaptive Runge-Kutta Built-in

This topic is 3631 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I did something cool. I wrote an operating system for amateur video games and built-in an adaptive step-size runge-kutta integrator from Numeric Recipes into it for physics calculations. The step size is variable so it automatically interpolates the state vector to the correct time for the screen refresh. Does everybody use Euler in video games? I don't get-out much. To handle collisions, you simulate repulsive forces on overlap using any crazy formula you want based on how much overlap. Don't you love video games ;-) http://www.losethos.com LoseThos is free and open souce if you're interested in making crappy resolution games with top-notch fluid motion. It supports MultiCore and is 64-bit, also. There's a video... the asteroids rip-off uses the runge-kutta.

Share this post


Link to post
Share on other sites
Advertisement
wow dude, that's seriously impressive. I'm actually pretty tempted to give it a go, since it sounds like fun to have direct access to all the hardware with a 2 second reboot. The only thing holding me back is, I'm not sure what language your compiler uses? The only reference I found was that it used something like C+ (more than C, less than C++). Also, the no modern-graphics cards thing is kind of a bummer. :) Still, awesome work man. Wow.

Share this post


Link to post
Share on other sites
It's a flavor of C/C++, a little more than C and less then C++ but a little different.

I wanted one language for everything, including the command-line. I started with C, but typing,

Dir();

was kinda verbose, so I made parenthesis optional when you have no arguments or just default arguments. At that point I said, might as well change everything I don't like.

To specify the address of a function, you use an ampersand & in front.

You don't have a main() function -- statements outside functions execute immediately. If you wanted to name something "main" you would end your file with "main()" to call it. (It would notice no type in front.)

The other main change is the operator precidence. I'm always merging bits together and the shift operators are now the same precidence as exponentials. I made a backward single quote an exponential. You can change to normal C precidence with a compiler option.

cmd=GetMsg(&p1,&p2, 1<<MSG_KEY_DOWN+1<<MSG_IP_MOVE+1<<MSG_KEY_UP);

The message routine takes a mask -- there are max of 64 possible message types and it flushes all types not in the mask until it gets one in the mask and returns the bit number so cmd would be MSG_IP_MOVE if the input pointer(mouse) moved and created a message. Notice you don't need parenthesis around the bits being added because it's exponential precedence.


In C++, "struct" is obsolete, so I eliminated it and used "class" from C++. Lots of minor things like that.

Some really cool things are variable argument lists. Say you have

void SPrintF_LikeFunction(char *buf,char *fmt,...)
{
int i;
PrintF("Format String: %s\r\n",fmt);
for (i=0;i<argc;i++)
PrintF("Arg %d = %X\r\n",i+3,argv);
}

When you say "...", it causes two variable to appear in the scope -- "argc" and "argv[]". All arguments are 64-bit on the stack so the array always works.

Exceptions are a little different -- simpler. There's a function "throw(...)" which you can pass any number of 64-bit values to and you access the arguments from a special area of the opearting system's task information, "Fs->except_argc" and "Fs->except_argv[]".

I got lazy and did type-casting different. It was uncalled-for making a change, but it was way easier for the compiler making it post-fix.

suppose one of your argv[] values is a double. You'll need to cast it. It reinterprets it as double as if that what it always was.

double d=argv[3]><(double);

I use I0,I1,I2,I4,I8 for 0,1,2,4,8 byte signed and U0,U1,U2,U4,U8 for unsigned. It's bytes not bits.

There's a special feature which lets you have unions that are treated as a whole.

I8 union whatever
{
I1 bytes[8];
}


You can do this:

void AddBytes(whatever w)
{
I8 i;
PrintF("As a whole: %X\r\n",w);
for (i=0;i<8;i++)
PrintF("Byte[%d]:%X\r\n",i,w.bytes);
}

The standard types all allow easy access to sub bytes words and dwords because I2,I4,I8, etc are declared as these unions. You do not say "union" by the way. It's like a class.



There are drawbacks to being nonstandard, but there's almost no point doing it if it's just an inferior immitation of what exists.... so I took the opportunity of starting with a clean slate and tried for something better.


Share this post


Link to post
Share on other sites
this is so cool! lots of innovative stuff (graphics in code comments, yay!) not to mention the insane amount of effort that must have been put into this... waay to hardcore for me though.

Share this post


Link to post
Share on other sites
Not just graphics in comments, but graphics for plotting on the screen or sending to the command line. No resource files. The files are ASCII followed by graphics and the compiler can pass a pointer to a graphic in your code.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!