Do you know how to add your own trap function ?
I put my function in qcommon directory and I want to call it from the game directory (like for example the trap_FS_Write function).
I do the same (definition/declaration) like the other trap functions but I suppose the problem is to find the correct id for the g_syscalls.asm.
For example :
In qcommon/common.c :
void example_trap_function( void )
{
int i = 12345; // only for for debug
}
In qcommon/q_shared.h :
void example_trap_function( void );
In game/g_local.h :
void example_trap_function( void );
In game/gpublic.h :
in the gameImport_t enum adding the line :
EXAMPLE_TRAP_FUNCTION
In game/g_syscalls.c :
void example_trap_function( void )
{
syscall( EXAMPLE_TRAP_FUNCTION );
}
You have to modify the game.q3asm for compiling g_syscalls.c (replace line ../g_syscalls with g_syscalls) with ioquake3.
In game/g_syscalls.asm :
adding this line at the end of the file :
equ trap_example_trap_function -600
Is it my problem ?
How to know the number ?
In game/g_main.c :
Use the example function in G_InitGame :
trap_example_trap_function( );
Compiling is ok
After installing everything (bin and qvm) and starting the game it's ok.
When the map is launching (G_InitGame function) I have this message :
bad game system trap -582
582 is the number for the trap_BotLibSourceFileAndLine in the g_syscalls.asm file.
I add my line after it...
Quake 3 : Add a trap function ?
-
- Posts: 4022
- Joined: Sat Mar 12, 2005 6:24 pm
Re: Quake 3 : Add a trap function ?
I think you'll want to make that:Alf2010 wrote:in the gameImport_t enum adding the line :
EXAMPLE_TRAP_FUNCTION
Code: Select all
EXAMPLE_TRAP_FUNCTION = -600
-
- Posts: 4022
- Joined: Sat Mar 12, 2005 6:24 pm