News:

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

Main Menu

Variable options storred in active memory,

Started by Daniel3D, November 08, 2021, 12:20:12 PM

Previous topic - Next topic

Daniel3D

Quote from: llm on November 14, 2021, 12:39:46 PM
that uses the widely in use Bullet physic engine/and OpenGL - that project is so small that its a very good start -
It looks indeed promising like i said.
but upon reading further i noticed this remark by the creator:
QuoteEventually I think I'm going to implement my own vehicle class or a simple physics engine since I'm not sure if I will be able to configure Bullet so that it mimicks the physics engine of the original game closely enough.

That is an issue with main stream, out of the box physics engines. They can not do what stunts physics does. (and I dont know if they can be simplified enough to do so) so it could be that writing it from scratch is the way to do it.
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
---------
Check out the STUNTS resources on my Mega (globe icon)

Daniel3D

Quote from: Cas on November 14, 2021, 05:37:34 PM
If I could have a very simple library like this one, free software, totally portable, statically linkable and not crazy big, that I can use with C, I would probably have chosen to write the engine in C to make it more comfortable for the programmers in the community current and future. And this is still open. Find the jewel and you'll get the prize  ;D
well, FBGFX is compatible with c apparently,

How can I use fbgfx in C?
https://www.freebasic.net/forum/viewtopic.php?t=28745#p274795
Main Ingredients are:
- fbgfx lib and fbrt lib compiled for your target system (win/lin 32/64bit non/multi-threaded ... etc)
- gfxlib and rtlib headers from sources
- command line options for gcc to let it know where the headers and libs are
- reading fbgfx lib source code, because we don't document the public API or internal functions anywhere.


8) 8) Just trying to help..
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
---------
Check out the STUNTS resources on my Mega (globe icon)

llm

#32
here is the source: https://github.com/freebasic/fbc/tree/master/src/gfxlib2

should build from root with the correct environment using

https://github.com/freebasic/fbc/blob/master/makefile

in root folder:
make gfxlib2

should build the libs

Cas

Yes, well, I forgot to mention that fbgfx is actually written in C. I already know this. The thing is when you install FreeBasic, this library is already blended with the project and you just build your source like: fbc myprogram.bas, so you don't actually get to the linking part of the library manually or compiling it to be used separately and all that. I need to become familiar with how that works and then yes, I could just use that same library from C.

If I can eventually go a little further, I could strip some things out from it, because this is a very completely library with functions for things like alpha channel blitting and double precision coordinate line rendering, plus several other things that are not really needed for a 3D rendering engine, but I guess the library is not that huge anyway, so that could be left for later. If I get to play around with it in C, I'll let you know. I tried some time ago and I'm sure I was doing something wrong. I had problems importing/exporting the function identifiers and I must admit I didn't feel like trying to solve the problem at the moment. Not precisely a fun part of programming, but it'd be nice once I do get it working.
Earth is my country. Science is my religion.

Daniel3D

Quote from: Daniel3D on November 08, 2021, 12:20:12 PMIs there a way to find out how, what and where stunts stores temporary information.
I'm referring to the Global variables.
I can see they are set in some cases, like here at the end of seg000:
set_default_car proc far

    mov     gameconfig.game_playercarid, 43h ; 'C'
loc_146E9:
    mov     gameconfig.game_playercarid+1, 4Fh ; 'O'
loc_146EE:
    mov     gameconfig.game_playercarid+2, 55h ; 'U'
loc_146F3:
    mov     gameconfig.game_playercarid+3, 4Eh ; 'N'
loc_146F8:
    mov     gameconfig.game_playermaterial, 0
loc_146FD:
    mov     gameconfig.game_opponenttype, 0
loc_14702:
    mov     gameconfig.game_opponentmaterial, 0
loc_14707:
    mov     gameconfig.game_playertransmission, 1
loc_1470C:
    mov     gameconfig.game_opponentcarid, 0FFh
locret_14711:
    retf
set_default_car endp
seg000 ends

Curiously, the player car is set by the four letters of the car individually.
But the opponent car id is a single value. 0FFh. (255 in decimal, but it could mean something else)
Upon reading some bits on replay files, they have this set stored as well and load it into memory.
So we could see from a repay file how an opponent is set.
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
---------
Check out the STUNTS resources on my Mega (globe icon)

Cas

Yep, that 0ffh is not a single byte, but the first of four. That is the way to set the car to "none" when you're not playing against any opponent. This is a static variable. Some variables are dynamic. This is common in functions inside which a variable is defined. The memory is allocated for them when the function is called and freed when you exit the function, so you won't find a location where the variable is. Still, you will find it's definition if it's initialised and you can change the value of initialisation, but you have to take into account that, if the function is called recursively, there will be many instances of the variable a different locations, so the fact that you find a definition like this does not imply that there will be a fixed place in memory where you'll find the variable.

In this case, for player and opponent car, it's static.
Earth is my country. Science is my religion.

Daniel3D

Exactly. But I want to make sure that we know how the game stores the opponent car. I think the easiest way is to look at how replays are loaded into memory.
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
---------
Check out the STUNTS resources on my Mega (globe icon)

Cas

Reading the code, of course, is the only source to the truth, ha, ha. I often give you my guesses on how something was probably done because it's quicker that way and I've worked with similar tools in the past and programmed that way, but you always get surprises when you get to the source code.

What I know is that there is a memory region in which all the paramaters from the simd field in the RES file are loaded in the same order, as a single block and I've used that to make the needle colour mod. I assume exactly the same thing is true for the pipsqueak's car and it makes sense to also think the 3D shapes of both cars as well as their dashboard graphics are also kept in memory all the time during the game until you switch to another car. This means that, if you just change the car ID of one car in memory, not much will change. You have to load all car files.
Earth is my country. Science is my religion.

Daniel3D

Quote from: Cas on October 20, 2022, 01:30:33 AMit makes sense to also think the 3D shapes of both cars as well as their dashboard graphics are also kept in memory all the time during the game until you switch to another car.
I know that is not true. In the showroom only the res file data and the shape that is needed are loaded, not the whole car. The car is set, but only in name. The car is loaded when you actually start driving.
So if you change the name in memory before you press let's drive the new care is loaded.
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
---------
Check out the STUNTS resources on my Mega (globe icon)

Cas

Oh!  I didn't expect that!  Very interesting
Earth is my country. Science is my religion.