MCPcopy Create free account
hub / github.com/JACoders/OpenJK / CL_InitCGameVM

Function CL_InitCGameVM

code/client/cl_cgame.cpp:61–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59void UI_SetActiveMenu( const char* menuname,const char *menuID );
60
61qboolean CL_InitCGameVM( void *gameLibrary )
62{
63 typedef intptr_t SyscallProc( intptr_t, ... );
64 typedef void DllEntryProc( SyscallProc * );
65
66 DllEntryProc *dllEntry = (DllEntryProc *)Sys_LoadFunction( gameLibrary, "dllEntry" );
67
68 // NOTE: arm64 mac has a different calling convention for fixed parameters vs. variadic parameters.
69 // As the cgame entryPoints (vmMain) in jk2 and jka use fixed arg0 to arg7 we can't use "..." around here or we end up with undefined behavior.
70 // See: https://developer.apple.com/documentation/apple-silicon/addressing-architectural-differences-in-your-macos-code
71 cgvm.entryPoint = (intptr_t (*)(int,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))Sys_LoadFunction( gameLibrary, "vmMain" );
72
73 if ( !cgvm.entryPoint || !dllEntry ) {
74#ifdef JK2_MODE
75 const char *gamename = "jospgame";
76#else
77 const char *gamename = "jagame";
78#endif
79
80 Com_Printf( "CL_InitCGameVM: client game entry point not found in %s" ARCH_STRING DLL_EXT ": %s\n",
81 gamename, Sys_LibraryError() );
82 return qfalse;
83 }
84
85 dllEntry( VM_DllSyscall );
86
87 return qtrue;
88}
89
90/*
91====================

Callers 1

SV_InitGameProgsFunction · 0.85

Calls 2

Com_PrintfFunction · 0.50
dllEntryFunction · 0.50

Tested by

no test coverage detected