News:

Herr Otto Partz says you're all nothing but pipsqueaks!

Main Menu

Stunts code deep dig.

Started by Daniel3D, May 24, 2021, 02:12:30 PM

Previous topic - Next topic

Daniel3D

Back on topic.

I originally had a very ambitious idea of replacing the entire menu structure.

That plan is still on the table but it requires research beyond my capabilities. I was unsure of the project at first, that is why I chose to start a bit obscured. The Ferrari edition is a direct result of this and although not major, it has made me more confident.

I am more confident now that we can do things to improve the game (left corner bias can be fixed I believe)) or make it a bit better playable (do something about continue driving)

So let's see what we can do.
Edison once said,
"I have not failed 10,000 times,
I've successfully found 10,000 ways that will not work."
---------
Currently running over 20 separate instances of Stunts or 4D Sports Driving.

Cas

So this is the already-moved post, right?  Am I OK to post here? :)
Earth is my country. Science is my religion.

Daniel3D

Quote from: Cas on October 30, 2021, 02:00:06 AM
So this is the already-moved post, right?  Am I OK to post here? :)
Ehm.. yeah, it's ok.  8)
Edison once said,
"I have not failed 10,000 times,
I've successfully found 10,000 ways that will not work."
---------
Currently running over 20 separate instances of Stunts or 4D Sports Driving.

Daniel3D

#33
Last night I found part of the code responsible for the car limit in the garage. I successfully lowered the limit. To verify its function. I suspect that there will be issues when raising the limit.
I got into trouble with a limit of 120 and 110 cars. But I don't know what caused it.  8) I was to tired to continue messing with it.

To test better I am going to make 100 test cars from the originals. (Number them 0001 to 0100) and edit the Res file accordingly.
I want to see what happens when you exceed the limit in the original stunts. I never researched that.
And of course use turbo debugger.

I expect the 32 limited to be there with a reason. But I really want to know that reason.
Edison once said,
"I have not failed 10,000 times,
I've successfully found 10,000 ways that will not work."
---------
Currently running over 20 separate instances of Stunts or 4D Sports Driving.

Cas

I would "guess" that Stunts simply has an array of 12 character long strings that it loads with the car file names. This array has a fixed size, so when reading the files from the directory, it doesn't continue filling it if there are more files than a certain number. We programmers get used to "rounding" numbers to powers of two, so sometimes it may look like it's something in the program architecture, but it is really just the programmer's choice that went on to set the limit at 32 instead of 30 or 40.

Some testing you can make is, for example, put in your Stunts directory redundant files and see if this reduces the number of loaded cars. What I mean is this: normally, each car has four files. But if you have both a STXXXX.P3S and a STXXXX.3SH files, only one will be used, yet the other one may potentially have been loaded to the file list array. I wonder if adding four redundant files will cause only 31 cars to be loaded in the showroom. If this is so, then we'll know the limit has to do with the array where file names are loaded. If this doesn't happen, then it might be or might not be, because Stunts might just be smart enough to remove redundant files from the list.

Many similar tests can be made without changing the code that could give you an insight on how this works, but touching the value in the code is a good way of testing too, because you can just set it back to normal when you're done :)
Earth is my country. Science is my religion.

Daniel3D

Quote from: Daniel3D on November 06, 2021, 01:25:28 PM
Last night I found part of the code responsible for the car limit in the garage. I successfully lowered the limit. To verify its function. I suspect that there will be issues when raising the limit.

I expect the 32 limited to be there with a reason. But I really want to know that reason.
After some testing, I am sure that the 32 I found is a return counter. After the number is reached, it goes back to 1.
If set to 6 only the first 6 cars are shown, when set to 20, 20 cars are shown. If set to 36 the game crashes at 33.
I found no code that limits the amount of cars in some way, so fear that the car limit can not be increased in this engine without extensive rewriting.
Edison once said,
"I have not failed 10,000 times,
I've successfully found 10,000 ways that will not work."
---------
Currently running over 20 separate instances of Stunts or 4D Sports Driving.

llm

Quote from: Daniel3D on November 07, 2021, 10:28:30 PM
Quote from: Daniel3D on November 06, 2021, 01:25:28 PM
Last night I found part of the code responsible for the car limit in the garage. I successfully lowered the limit. To verify its function. I suspect that there will be issues when raising the limit.

I expect the 32 limited to be there with a reason. But I really want to know that reason.
After some testing, I am sure that the 32 I found is a return counter. After the number is reached, it goes back to 1.
If set to 6 only the first 6 cars are shown, when set to 20, 20 cars are shown. If set to 36 the game crashes at 33.
I found no code that limits the amount of cars in some way, so fear that the car limit can not be increased in this engine without extensive rewriting.

I think there is just a fixed size array with size 32 and the game starts to override other relevant data if you force it to go further, normaly there are no checks or dynamic constructs to just allow growing, due to the very limited memory/performance constraints of that time everything was static and as small as possible, the 32 is just a very typical programmers size value, there needs to be a 32 elements array in the data segment for this, plus some (index%32)+1 for the cycling, % means modulo

Daniel3D

That's what I thought to. And if we find that array and increase it, it might override other data or of the other data gets shifted to make room it could be unavailable for the game if it looks in a specific memory region. So it still might be possible but not without extensive research.
Edison once said,
"I have not failed 10,000 times,
I've successfully found 10,000 ways that will not work."
---------
Currently running over 20 separate instances of Stunts or 4D Sports Driving.