A8 Version 8.012 Public Beta

Posted By: jcl

A8 Version 8.012 Public Beta - 07/13/10 14:46

A new public beta version 8.012 is available.

This version fixes the two reported bugs of 8.010: The free version can now be installed without copying an extra file (hopefully) and model animation does not stop anymore after 30 seconds.

You can find a list of the new features here:

http://manual.3dgamestudio.net/newfeatures8.htm

Please install this version in a new folder or in your 8.010 folder; do not install it in your old A7 folder. Test everything carefully and if you find a bug, please report it to the bug forum. Please disregard the ominous error messages when you start GED the first time.

Users who already own a key file with "*.dta" extension can unlock the free version to Extra, Com, or Pro. Users who purchased or upgraded A7 since March 2010, but have not yet a *.dta key, can contact Support and will receive the new key file.

Posted By: Liamissimo

Re: A8 Version 8.012 Public Beta - 07/13/10 15:21

I can't run the A8 Engine Preview because it can't open %1.c
Posted By: Rackscha

Re: A8 Version 8.012 Public Beta - 07/13/10 15:34

@JCL:
Any changes planned for lite-c?

For example removing the ugly brackets when initialising a multidimensional object at runtime?

it ends up like this:

(name[x])[y]

Greets
Rackscha
Posted By: Rich

Re: A8 Version 8.012 Public Beta - 07/13/10 15:44

Animations play as expected, it correctly says "free version" when starting the engine, And no longer crashes with the old A6 maps laugh.
Posted By: jcl

Re: A8 Version 8.012 Public Beta - 07/13/10 16:01

A8 engine preview: In users\yourname\sendto you'll find a "Preview in A8 Engine.lnk". Right click, Properties, and remove the "%1" from the command line.

Ugly brackets: We don't know of any ugly brackets.
Posted By: Liamissimo

Re: A8 Version 8.012 Public Beta - 07/13/10 16:15

@JCL Yes, it works. I just have a plain black window, is it that?
Posted By: Rackscha

Re: A8 Version 8.012 Public Beta - 07/13/10 16:45

With "ugly" i meaned the example i wrote above.

In C/c++ you dont have to add those brackets but in lite-c you have. Its just an obstacle frown
Posted By: sebbi91

Re: A8 Version 8.012 Public Beta - 07/13/10 17:27

Hi JCL

I dont know if you read my "Bug"-report post in A8.01.1, I though I post it here again.
Maybe its a Bug!



i dont know if this is a bug or bad programming style of my own.

I worked on a RPG with A7 - free.
I startet my this script with A8 and it seems there is aproblem with ent_create.

i've written a ent_create - script in the "void main()" like this:
Quote:


ent_create("Longsword.mdl",vector(80,-18,70),longsword);
ent_create("Longsword.mdl",vector(80,-28,70),longsword);
ent_create("Longsword.mdl",vector(80,-38,70),longsword);
ent_create("Longsword.mdl",vector(80,-48,70),longsword);


it works perfect with A7-free edition.
Every Model had the Polygon -flag and shadow.
if my player looks with c-trace at the Model a text apears.

Now script didnt working correctly with A8-free-edition!
Only one modell of them show the message!

It only works if I write something like this in the main script:

Quote:


ent_create("Longsword1.mdl",vector(80,-18,70),longsword);
ent_create("Longsword2.mdl",vector(80,-28,70),longsword);
ent_create("Longsword3.mdl",vector(80,-38,70),longsword);


Is it a bug or a bad programming style of me?

regards
Basti
Posted By: jcl

Re: A8 Version 8.012 Public Beta - 07/14/10 07:22

In both cases - "ugly brackets" and "missing message" - you can contact the support and send them the project, or upload it to the bug forum. It can be a bug in the engine, or it can be a bug in your script - but I can't see from your post why you need ugly brackets or get no message.
Posted By: bart_the_13th

Re: A8 Version 8.012 Public Beta - 07/14/10 07:42

I have this error message when I try the samples program in my office PC



Everything polygon based did not shown up, panel and particles do shown up. Also tried it with -w3d command.
PC Spec:
Intel Pentium D 2.4GHz, 1Gb RAM, 64Mb Intel 82865G Onboard Graphic

I also tried at my home PC. It show the first frame before it crash to garbled screen without warning(it also crashed my OS so I have to reset it), tried a couple of time with other samples too.

PC Spec
Intel Pentium D 3.2 GHz, 1Gb RAM, 256Mb Ati Radeon 9600 AGP
Posted By: Quad

Re: A8 Version 8.012 Public Beta - 07/14/10 08:32

install directx and up-to-date video drivers.
Posted By: Rackscha

Re: A8 Version 8.012 Public Beta - 07/14/10 13:50

@JCL:
Thought for the support i need a support ticket from the shop?(cant find it).

Here is the code, short,simple laugh

Code:
#include<acknex.h>



int **array;


function main()
{
	int counter = 0;
array = (int**)sys_malloc(sizeof(int*)*10);	
for(counter=0;counter<=10;counter++)
{
	array[counter] = (int*)sys_malloc(sizeof(int)*10);
}
//array[1][1] = 5; Dimension of array error. This SHOULD work, but doesnt in Lite-c
(array[1])[1] = 5;	//Thats the only way it works with Lite-c
}



GReets
Rackscha
Posted By: jcl

Re: A8 Version 8.012 Public Beta - 07/14/10 14:53

A little user quiz: Who shows Rakscha what's wrong with his "array"?
Posted By: WretchedSid

Re: A8 Version 8.012 Public Beta - 07/14/10 15:04

Well, he allocates too much memory and I think the style is ugly.
But this isn't his point, his point is the assigning of the array.

Oh and btw, my wish: C99 style for loops!
Posted By: Quad

Re: A8 Version 8.012 Public Beta - 07/14/10 15:10

If you are going to look in this stuff, please also look in ternary operators while you are at it.
Posted By: Liamissimo

Re: A8 Version 8.012 Public Beta - 07/14/10 15:15

He forgot the definition of the array or not?

I just guessed, not good at quizzes grin
Posted By: Rackscha

Re: A8 Version 8.012 Public Beta - 07/14/10 15:20

@JustSid:
With too much memory, do you mean cause i used only [1][1] or did i something in general wrong?(if its the first case, its just and example laugh )


GReets
Rackscha
Posted By: WretchedSid

Re: A8 Version 8.012 Public Beta - 07/14/10 15:33

I'm talking about your for loop:
Code:
for(counter=0;counter<=10;counter++)


you are allocating place for 10 integer pointers, but then you try to assign 11 pointers something.

@TheLiam:
Of course he has an array. He allocates the memory for the array at runtime and assigns some value to the array. It's described here in detail: http://c-faq.com/aryptr/dynmuldimary.html

Edit: Second wish: Please build variable argument lists into the compiler.
Posted By: Rackscha

Re: A8 Version 8.012 Public Beta - 07/14/10 15:52

@JustSid: ou year, my bad. Ofcourse wrong^^
Posted By: Lukas

Re: A8 Version 8.012 Public Beta - 07/14/10 16:57

I don't see any error apart from that <=10 either, and I have to agree about the ugly brackets. Something seems to be wrong with the operator priorities of Lite-C. I have encountered stuff like this, too. For example:

ebx->text->pstring[0] // does not work
(ebx->text->pstring)[0] // works, but looks ugly

In "normal" C/C++ code, you don't need those brackets. Look at the operator priorities:
http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Operator_precedence
The operators "->" and "[]" have the same priorotity and the associativity is from left to right. This means, the "->" in my code above has to be "called" first, which means the [0] refers to "ebx->text->pstring" and nothing else. And I'm wondering what Lite-C tries to make it refer to...

Same for Rackscha's code. The first [] brackets should have a higher priority making the brackets unnecessary.

And now that we are talking about flaws of the Lite-C compiler, could you please answer to this thread:
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=330463#Post330463
Posted By: Rackscha

Re: A8 Version 8.012 Public Beta - 07/14/10 17:38

@Lukas:

Using one bracket isnt heavy enough^^.
My old cube project had a 3 dimensional cube struct...imagen that kind of bracket-war o.o.
Posted By: Lukas

Re: A8 Version 8.012 Public Beta - 07/14/10 17:50

"My old cube project had a 3 dimensional cube struct...imagen that kind of bracket-war o.o."
Hmm... wait a second! I discovered something very weird! This sentence reminded me that for Kubetris I used a 3-dimensional array and for one of my current projects I even use a 4-dimensional array and they work without any problems.

And I found out why mine work and yours don't: If you define an array the "usual" way, like this:
int array[10][10];
then it works! But if you define it like you did:
int **array;
then it doesn't work! This means, Lite-C distinguishes between arrays and pointers!! But normally each defined pointer can be used as an array and compilers shouldn't make a difference between them. But apparently, Lite-C does.

Now I realize that jcl could have meant that you defined your array as a pointer. I guess that's why he put the word "array" into quotation marks. But it still should work!
Posted By: Quad

Re: A8 Version 8.012 Public Beta - 07/14/10 18:39

that is one advantadge of lite-c i guess, it knows what is pointer and what is not, so it can understand what you meant at somepoint (i.e. when a function needs a pointer and you pass a variable instead, it recognizes the variable and understands you meant pointer and acts as the way you meant.)

I would not always want it to get pointer pointers as arrays, so it's good this way i guess?


*:did anyone understand what i am talking about grin ?
Posted By: sebbi91

Re: A8 Version 8.012 Public Beta - 07/14/10 18:53

@jcl: Pease check your PM.
I sent the "bug-file to you.

hope you can fix it.

regards
Basti
Posted By: Rackscha

Re: A8 Version 8.012 Public Beta - 07/14/10 19:15

@LUkas: It wa ssupposed to be used as pointer, cause the system needs to be FLEXIBLE.
A fixed array is no problem but not suitable.


GReets
Rackscha
Posted By: MasterQ32

Re: A8 Version 8.012 Public Beta - 07/14/10 20:37

hey guys, i played around with the new physics engine and i think, it's very easy to create a cool physics game, if you use PH_CHAR for actors!
you can download my sample project (some strange football/soccer game) here:
Football Game
The controls are W,A,S,D to walk, SPACE to kick the ball and ESC to exit. Look aound with the mouse.

Try it!
Posted By: Lukas

Re: A8 Version 8.012 Public Beta - 07/14/10 20:37

@Quadraxas: Yeah that's the pointer protection, but this doesn't have to make it have different operator priorities for arrays and pointers. And if you call an array just by its name, it's considered a pointer to the first array element (which is then protected wink ). Basically there is no big difference between arrays and pointers. And they should be treated the same.

@Rackscha: I didn't mean you should use fixed arrays. I was just telling that fixed arrays work correctly, but "pointer arrays" don't. And I think Lite-C should be changed to make it work.

And I also noticed that you can't define pointers of indefinite size, like it can be useful in function parameters:
void myfunction(int myarray[]) // works in C/C++, but not in Lite-C
This means, even if you use fixed arrays, but want to pass them as parameter to a function, you have to use them as pointers, and then have to use the brackets!
Posted By: Liamissimo

Re: A8 Version 8.012 Public Beta - 07/14/10 20:45

@Richi: Nothing works. Just a voice saying hurry up. If I press WASD (i read your script) nothing happens. But I have got the same problem, also another user, we are waiting for help.

MAYBE it has to do sth. with the grpahic card? Mine is a ATI x1400 Mobility Radeon with 128Mb
Posted By: sebbi91

Re: A8 Version 8.012 Public Beta - 07/14/10 21:19

only the .exe isnt working!
You can test it with "run current script"

@Richi007 : Not bad, its nice^^
Posted By: Liamissimo

Re: A8 Version 8.012 Public Beta - 07/14/10 21:30

Yes, tested it. Nice game, I dont talk about graphics or kinda like that because it really just is a demonstration of phsx.
Posted By: jcl

Re: A8 Version 8.012 Public Beta - 07/15/10 08:29

Here's the solution to the user quiz. Aside from the memory bug, there's one main problem. A one dimensional array is indeed identical to a pointer, but a multi dimensional array is not. int array[x][y] is very different to int **array. In fact a pointer to a pointer is no array at all.

Whenever you access this construct, the program hits two different memory areas. This is much slower than using an array, which is a single contiguous memory area. There are further subtle problems with this coding style, so better don't use it in a real application.

If you do, you must use brackets, and you should use them even when not required by the language syntax. Otherwise either you or some other poor fellow working with your code will confuse this construct with a real multidimensional array, and then you'll get the nicest bugs and crashes.

To be on the safe side, use a normal multidimensional array for a static definition, and a single pointer for a dynamic definition, no matter how many dimensions.
Posted By: WretchedSid

Re: A8 Version 8.012 Public Beta - 07/15/10 10:29

I use this construct in many real applications, in fact my iPhone engine bases heavily on this kind of pointer to pointer to memory access relation.

There is a performance problem, but this has nothing todo with those pointers but with copying the data into the GPU memory and blocking the CPU in the meantime.

I just checked the access time on my very old iPhone 3G running iOS 4.1 and the difference between fixed array and pointer to pointer is not visible in the log (about 0.010 seconds to read and write into the memory).

I know that I can't compare a RISC CPU with an x86 CISC CPU, so I checked it also on my 2 Ghz Intel Dual Core Machine running Mac OS X 10.6.4, the result:
Read and write into the memory was about 0.001 seconds (both, fixed arrays and pointer to pointer).

Both versions had debug symbols and was build with LLVM 1.5 and Clang. No optimizations and no link time optimization.
I have checked the assembler code that was generated to make sure that the loops will be executed.
The test function has written PI into every member of the array and then read the value and saved it into another float.

Output:
OS X:
Code:
2010-07-15 12:19:57.766 Test[1375:903] Writing fixed
2010-07-15 12:19:57.766 Test[1375:903] Reading fixed
2010-07-15 12:19:57.767 Test[1375:903] Writing pointer
2010-07-15 12:19:57.767 Test[1375:903] Reading pointer
2010-07-15 12:19:57.768 Test[1375:903] Writing fixed
2010-07-15 12:19:57.769 Test[1375:903] Reading fixed
2010-07-15 12:19:57.769 Test[1375:903] Writing pointer
2010-07-15 12:19:57.770 Test[1375:903] Reading pointer



iPhone:
Code:
2010-07-15 12:24:23.859 iTest[507:307] Writing fixed
2010-07-15 12:24:23.872 iTest[507:307] Reading fixed
2010-07-15 12:24:23.885 iTest[507:307] Writing pointer
2010-07-15 12:24:23.900 iTest[507:307] Reading pointer
2010-07-15 12:24:23.913 iTest[507:307] Writing fixed
2010-07-15 12:24:23.926 iTest[507:307] Reading fixed
2010-07-15 12:24:23.940 iTest[507:307] Writing pointer
2010-07-15 12:24:23.953 iTest[507:307] Reading pointer



Could you please explain what is so much slower? Because I really can't reproduce this (was too lazy to boot windows, so I haven't tested it with Gamestudio).
I use this construct very often, and if there is really a performance problem with that, I wish to know about that so I can avoid this.
Posted By: jcl

Re: A8 Version 8.012 Public Beta - 07/15/10 10:58

0.001 seconds seems very slow even for copying a huge memory area, regardless of the method.

Anyway, the reason of the performance problem is the CPU cache. When you access a memory location, a cache line is filled. The next time you hit that area, the CPU reads from the cache instead of the memory.

The more different memory areas are accessed, the more cache lines are created. When the cache is full, old lines are removed and new lines filled. This causes a severe performance hit. That's why in time critical programs, especially 3D engines, the programmers avoid reading from different allocated memory areas at the same time. Of course this effect is the worse, the bigger the memory areas are and the more fragmented the memory is.

Of course there are more problems with that method - for instance, you'll risk a crash when you initialize that construct with a memset call, as you would do with an array. I would not use that method for non time critical applications either.
Posted By: WretchedSid

Re: A8 Version 8.012 Public Beta - 07/15/10 11:20

Originally Posted By: jcl
0.001 seconds seems very slow even for copying a huge memory area, regardless of the method.


Well, I'm sure that it is much faster, but the log function needs some time too. On the iPhone it also needs to tether the log message to the host and burn some CPU time on this task.


Thanks for explaining, I didn't know about this issue and I will try to avoid this kind of pointer to pointer relation in the future too.

Edit: Another wish for the A8 compiler: Closures and thread-safe engine functions.
Both together would be perfect for multi-threaded projects. Or even better than Closures, Blocks: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1370.pdf
Posted By: Rackscha

Re: A8 Version 8.012 Public Beta - 07/15/10 13:29

@JCL:
Ok how to use a single pointer for a dynamic definition?

when i use:

int *array;

and try to write/read like this:

(array[1])[1] = 5;

i always get:
Subscript requires array or pointer type.
Posted By: WretchedSid

Re: A8 Version 8.012 Public Beta - 07/15/10 14:16

You can use something like this:

Code:
int *array;

array[(row * n) + col] = x



While n is the number of elements, row the row and col the column. To make it more convenient, you can use this makro:

Code:
int *array;

#define M(row,col)  array[(row * n) + col]
M(1, 1) = x;



Of course you need to allocate the memory as one dimensional array. Like this:
Code:
int *array = (int *)malloc((rows * cols) * sizeof(int));


Posted By: Liamissimo

Re: A8 Version 8.012 Public Beta - 07/15/10 16:16

@JCL

I found a bug. Maybe. I can move through all my models, even if I am setting BBOX or Polygon in WED/SED. Anyone else has this problem?
Posted By: Lukas

Re: A8 Version 8.012 Public Beta - 07/15/10 16:49

Originally Posted By: jcl
Here's the solution to the user quiz. Aside from the memory bug, there's one main problem. A one dimensional array is indeed identical to a pointer, but a multi dimensional array is not. int array[x][y] is very different to int **array. In fact a pointer to a pointer is no array at all.

Whenever you access this construct, the program hits two different memory areas. This is much slower than using an array, which is a single contiguous memory area. There are further subtle problems with this coding style, so better don't use it in a real application.

If you do, you must use brackets, and you should use them even when not required by the language syntax. Otherwise either you or some other poor fellow working with your code will confuse this construct with a real multidimensional array, and then you'll get the nicest bugs and crashes.

To be on the safe side, use a normal multidimensional array for a static definition, and a single pointer for a dynamic definition, no matter how many dimensions.


Really? REALLY? This sounds weird. In fact, afair I learned that multidimensional arrays are nothing else than an array of pointers to other arrays, which don't necessarily have to be in one contiguous memory area.
However, if this is true, what you say, why can I use pointers to pointers in function parameters if I want to pass an array to a function? And if that makes a difference, then Lite-C should support arrays with indefinite size as function parameters.
However, I think whenever I saw an example how to create a multidimensional array at runtime, it was always like Rackscha did it. If it is true what you say creating a "real" multidimensional array would look like this:
Code:
int** create_2darray (int sx, int sy)
{
	int** array;
	int* p = malloc(sx*sy*sizeof(int)+sx*sizeof(int)); // allocate one single contiguous memory area (for the data and the pointers)
	array = p; // set the array pointer to its beginning
	int i;
	for(i=0;i<sx;i++) array[i] = p+sx+sy*i; //fill the beginning of the memory with pointers to the 1-dimensional pointers
	return(array);
}


Is that right? But in this case, the pointers to the arrays would be a waste of memory in comparision to a 1-dimensional array of the size sx*sy.
Posted By: Spirit

Re: A8 Version 8.012 Public Beta - 07/15/10 20:32

Quote:
In fact, afair I learned that multidimensional arrays are nothing else than an array of pointers to other arrays, which don't necessarily have to be in one contiguous memory area.

I am sure this is wrong, no compiler that I know uses an array of pointers to other arrays or something like your code for substituting a multidimensional array. All normal C/C++ compilers support multidimensional arrays natively.
Posted By: Lukas

Re: A8 Version 8.012 Public Beta - 07/15/10 20:36

So this means that multidimensional arrays are indeed just the same as a one-dimensional array, just that it's preceeded by an array of pointers? In this case multi-dimensional arrays would indeed be just a waste of memory and wouldn't make sense to use as it would always be better to use one-dimensional arrays. But then, why do they exist? o.O
Posted By: Spirit

Re: A8 Version 8.012 Public Beta - 07/15/10 20:44

No there is no array of pointers. This would really be a waste of memory. The compiler translates your two indexes to an expression like in the example from JustSid.

array[row][col] => array[(row * n) + col]

Posted By: Lukas

Re: A8 Version 8.012 Public Beta - 07/15/10 20:48

Oh, ok, that makes sense. And then there is really a hige difference between arrays and pointers. But that somehow makes me really wonder why I can use pointers to pointers as function parameters to pass a 2-dimensional array. confused
And this also means that there is really no way to create a native array that can be used with [x][y] brackets. shocked
Posted By: FlorianP

Re: A8 Version 8.012 Public Beta - 07/15/10 21:58

As the memory itself is pretty much a one-diemensional array (as it has one index) there is of course no way to create a 'native' two-diemensional array. The CPU only knows adresses in the memory and doenst care about higher data-structures - its the compilers task to make sure that the resulting assembler-code adresses the memory like the programmer intented. So the only reason for these sturctures to exist is indeed their convenience for programmer in higher-languages.

The pointer (aka indirect adressing-modes) on the other hand is one of the most native concepts of a CPU. The compiled assembler-code uses it for nearly every memory- or function-call made by a higher language.
And a pointer only directs to annother memore-location - and if that location directs to the next, and to the next...and so on - you can also use '******' (and the compiled code maybe really does [see Binding]) to direct to an two-diemensional array. The pointers just lead you the way - whats on the end of it doesnt matter.
Posted By: Lukas

Re: A8 Version 8.012 Public Beta - 07/15/10 22:29

By "native" I meant a fixed size array like int myarray[3][5], in comparision to an array created by malloc. I know how the CPU and the memory works. What I meant, when I said, you can't create native arrays on runtime, was that you can't create arrays that work like if you defined them like int myarray[3][5].

My point about the **-pointer is that I thought this works:
Code:
int myarray[3][5];
void dosomething(int **array)
{
	(array[2])[3] = 3;
}


But now I tried it and it doesn't work. I always thought it would work, because it does work for 1-dimensional arraye. That's why I was confused when I heard that there is a huge difference between **-pointers and 2-dimensional arrays.
But now that I found out that this doesn't work, everything sounds logical again. laugh

Good that I learned that.


But then, Lite-C should support arrays with indefinite size (or arrays at all...) in function parameters, like this:
void myfunction (int myarray[])
Posted By: WretchedSid

Re: A8 Version 8.012 Public Beta - 07/15/10 22:57

Code:
int test[1][1];

void foo(int **bar)
{
	(bar[0])[0] = 1;	
}

...

foo(test);



This works pretty good inside the VM
Posted By: Lukas

Re: A8 Version 8.012 Public Beta - 07/15/10 23:01

Yeah but it crashes. (Maybe not for you now, because you use [0][0]...)
Posted By: WretchedSid

Re: A8 Version 8.012 Public Beta - 07/15/10 23:02

Uhm... possible, but I don't want't to start the VM again to check it out tongue
Posted By: Liamissimo

Re: A8 Version 8.012 Public Beta - 07/15/10 23:10

This thread now have 3 sites about a theme I understand in no way grin
Posted By: Joey

Re: A8 Version 8.012 Public Beta - 07/16/10 13:40

In C you are able to pass multidimensional arrays as pointers. Although the compiler does not know the length of the array itself (char a[2] stores no length) it does need to know the length of the rows in order to make the replacement spirit mentioned in his post. So how do we declare such a function? In C, it is

Code:
void foo(int array[][20]);
// or equivalently (pointer and array are more or less the same data type in C)
void foo(int (*array)[20]);


the following code is wrong since it receives a pointer to an array, not a pointer to a pointer:

Code:
void foo(int **array);


Posted By: Sajeth

Re: A8 Version 8.012 Public Beta - 07/17/10 18:25

How do I upgrade my A7 commercial license?
© 2024 lite-C Forums