|
Addition of new functions! Displaying 1-19 of 19 total.
1
Overkill
|
sgn(int a) returns if a number is positive, negative or zero.
abs(int a) returns the absolute value of a number.
max(int a, int b) returns the largest of two numbers.
min(int a, int b) returns the smallest of two numbers.
GetH(int color) returns the hue of a color (0 - 360).
GetS(int color) returns the saturation of a color (0 - 255).
GetV(int color) returns the value (brightness) of a color (0 - 255).
HSV(int h, int s, int v) allocates a colors based on Hue-Saturation-Value.
HueSwap(int find, int tolerance, int replace, int image) replaces a range of hues within an image.
TokenLeft(string s, string delim, int tokenpos) returns the leftmost tokens of a string.
TokenRight(string s, string delim, int tokenpos) returns the rightmost tokens of a string.
GetTokenPos(string s, string delim, int tokenpos, int includedelim) returns the position within a string that a token is located.
strstrp(string sub, string s, int start) returns the position of the first occurence of the substring inside the string, starting at start.
WrapText(int f, string text, int linelen) wraps a string with newlines to fit with in the specified maximum line width in pixels.
Many of these functions are credited to Zip, since he wrote a string library and hsv library within VC, and I've just more or less hardcoded them. The function count is now 240, we're almost at forced to have two-byte byte code for functions! :0
PrintString() now parses \n, \r, even checks for a \r\n pair, for some full support! This allows multiline Printstrings, but this doesn't look right for a multilined PrintCenter() or PrintRight() at the moment since they rely on Printstring for some reason.
Anyway, if someone could hook me up with SVN commit priveleges, it'd be appreciated!
Posted on 2005-12-20 17:11:58 (last edited on 2005-12-20 17:40:41)
|
Omni
|
That's really cool.
Posted on 2005-12-20 17:26:49
|
blues_zodiakos
|
You have 666 posts! O.O
Posted on 2005-12-20 21:18:33
|
CrazyAznGamer
|
Quote: Originally posted by Blues Zodiakos
You have 666 posts! O.O DIOS MIOS DIOS MIOS DIOS MIOS
*slaps self a la Omni*
Sorry, this is cool news, and 666 seems a bit Satanic(and please don't use 2 byte bytecode, as I feel XVC should be compact. I'd probably stop using later builds if the XVC doubles in size. Of course, you can always keep a "build before 2 byte bytecode" handy and I'd be happy)
Posted on 2005-12-20 22:35:23
|
Overkill
|
It'd only be two bytes for builtin function calls, and everything else would stay the same size. Also, I don't see what the big deal is. Most system.xvc files are small anyway, a change from 500kb to possibly 700kb doesn't really bother me.
Posted on 2005-12-21 06:23:02
|
resident
|
I'm guessing it would also add room for further expansion.
Posted on 2005-12-21 06:55:46
|
blues_zodiakos
|
If this is any indication of the amount of user-contributed functions which are likely to come rolling in now that the engine is open-source... that move seems pretty inevitable anyways. But I don't see anything wrong with it, hehe.
Posted on 2005-12-21 11:58:13
|
CrazyAznGamer
|
Quote: Originally posted by Overkill
It'd only be two bytes for builtin function calls, and everything else would stay the same size. Also, I don't see what the big deal is. Most system.xvc files are small anyway, a change from 500kb to possibly 700kb doesn't really bother me. You gotta point. But don't mind me, I'm crazy, and it bothers me. =P
I mean, that's 7 wasted bits per function. But I digress, It'd probably not matter.
Posted on 2005-12-21 12:37:22
|
mcgrue
|
The sad thing is that your post makes you sound serious.
Posted on 2005-12-22 02:29:49
|
vecna
|
Quote: Originally posted by CrazyAznGamerQuote: Originally posted by Overkill
It'd only be two bytes for builtin function calls, and everything else would stay the same size. Also, I don't see what the big deal is. Most system.xvc files are small anyway, a change from 500kb to possibly 700kb doesn't really bother me. You gotta point. But don't mind me, I'm crazy, and it bothers me. =P
I mean, that's 7 wasted bits per function. But I digress, It'd probably not matter.
Yes, well, look at it this way, if the function count hits 512, which is totally feasible, it'd only be 6 wasted bits per function!!
I think you're overestimating the impact it'll have on the compiled VC size. The format is a <single byte opcode=builtin_func_call><two byte index number>. so each BUILTIN function call will take 3 bytes instead of 2... only for builtin functions. The base opcode size is still 1 byte.
And if you think thats wasting space, you'd cringe to know how much space is wasted in the name of having all indexes be ints even if they dont strictly need to be :D the builtin limit is an exception.
Posted on 2005-12-22 20:43:27
|
aen
|
sgn, abs, max, min I like. Very commonly used items and the programmer shouldn't have to code them. About time!
GetH, GetS, GetV and HSV all are great too. For more advanced users I'm sure, but nevertheless alleviates a bit of mathematical burden.
HueSwap also sounds good. I don't personally know what this would be used for, but if it's processing an entire image, it's best to have that sort of an operation builtin for best possible speed.
TokenLeft and TokenRight I am not clear on. What is the common use for these? Someone mentioned parsing simple text data files, but I would like to see it in action. I'm also interested to know what the return value looks like.
If I run
TokenLeft("a, \t\tb ,c", ",", 2) what is the result? I use \t for sake of argument -- pretend they are actual tabs. Do you get
"a b" or
"a \t\tb " The second would seem to make more sense to me personally. Though I would welcome any rationale one way or the other!
GetTokenPos seems like a great idea to me. I can imagine its utility.
The naming of strstrp seems a little dubious. If you're going for similarity to the standard C library, I say just go with strstr verbatim. The standard C strstr returns a char* and obviously VC doesn't, but I think it's obvious enough that you will be receiving the position of the substring, and that the best VC can do is an integer.
WrapText generating newlines at the appropriate positions seems potentially useful, but why add the extra step for newbies? Provide a method that automatically renders the text in wrapped form, such as PrintStringWrapped or WrapPrintString -- it will be far more accessible. The more advanced users may still be able to find a use for WrapText.
And while on the topic of wrapping text, it would also be useful to know the number of lines a string would get broken into, were it wrapped. The exact pixel height of a wrapped string would also be nice! Each of these with any given font.
Thoughts?
Posted on 2005-12-22 21:14:56
|
Overkill
|
aen: HueSwap() lets you swap, say, the red segments of an image for blue, which makes it easier to recolor sprites and enemy images and such. I *think* TokenLeft() and TokenRight() run like the latter example you supplied. Also, perhaps I should rename strstrp() to strpos(), after all, it makes more sense and is used like that in PHP. And yeah, PrintWrapString() or something would be nice, my only concern is that it would be a bit slow.
Posted on 2005-12-23 07:07:21
|
zonker6666
|
I've been playing with the source as well and added a couple of functions...
int Point3dX(int xpos, int zpos);
int Point3dY(int ypos, int zpos);
these return the screen position of a 3d point - after running a speed test on these they are 500% faster than the equivalent function written in vc.
void eval(string codetorun);
compiles and executes chunks of code on the fly --- (unlike CallFunction() it allows function parameters and the declaration of variables.... example
eval("rectfill(200,200,500,500,50,screen);");
or
eval("int x;int y; int result; x=5; y=20; result=x+y; messagebox(str(result));");
would both work
Posted on 2005-12-29 19:36:14
|
Jesse
|
How do your 3D functions calculate that? They have to assume certain viewpoint and camera, don't they?
And how does eval work? I assume you're using the same mechanism as the editcode gui? In which case, what happens in release mode?
Posted on 2005-12-29 20:08:43
|
zonker6666
|
Code for the 2 3d functions follows ---- to clarify yes they do need to be paired with certain information for the viewports -- that being xtranlation ytranslation ztranslation - xrotation yrot and zrot .... that is your worldspace (containing all the verts after having been transformed) --- but to actually plot a 3d point onto a 2d space you will need to pass them through these functions.
int __3dPointX(int xxxx, int zzzz)
{
return (((640*(xxxx-160))/(640+zzzz))+160);
}
int __3dPointY(int yyyy, int zzzz)
{
return (((640*(yyyy-100))/(640+zzzz))+100);
}
Posted on 2005-12-30 17:21:07
|
Omni
|
Zonker, is that the same 3D code you used in your ship shooting demo?
Posted on 2005-12-30 19:24:13
|
zonker6666
|
Omni - yes I've used those for a few different projects -
the one youre thinking of is probably the start of a zaxxon 3d
also used in a 3d breakout game i submitted for a compo and lately in a milkshape 3d model loader / viewer which is now quickly becoming a modeling app :)
actually i just changed those last night and gained a measely 20 ticks
int x3dpoint(int xvalue, int zvalue)
{
return (((xvalue-160)<<10)+((xvalue-160)<<7)) / ((640+zvalue)+160);
}
int y3dpoint(int yvalue, int zvalue)
{
return (((yvalue-100)<<10) + ((yvalue-100)<<7)) / ((640+zvalue)+100);
}
Posted on 2006-01-01 14:13:22
|
Omni
|
So this would radically increase the speed of the viewer demo too? That included castle model (I think it was a castle) was pretty complex but pretty slow.
Posted on 2006-01-01 14:23:26 (last edited on 2006-01-01 14:24:07)
|
zonker6666
|
Yes indeed --- that castle model demo now runs fairly quickly --- by verge 3d standards of course :) ill upload a new version of that later today ---
Should also gain a good chunk of speed by porting basil's matrix transformation and zsorting functions too but I havent gotten around to that just yet ;)
Posted on 2006-01-01 14:31:08
|
Displaying 1-19 of 19 total.
1
|
|