diff --git a/programs/games/rforces/trunk/kosSyst.cpp b/programs/games/rforces/trunk/kosSyst.cpp index 7f32412691..91aa7400ae 100644 --- a/programs/games/rforces/trunk/kosSyst.cpp +++ b/programs/games/rforces/trunk/kosSyst.cpp @@ -3,11 +3,40 @@ #define atexitBufferSize 32 +// Autobuild uses FASM method for exe->kos, +// MENUET01 header should be present in EXE. +#ifdef AUTOBUILD +char kosExePath[1024]; +char exeStack[16384]; +// must be alphabetically first in the image +#pragma data_seg(".1seg") +extern "C" struct +{ + char header[8]; + int headerver; + void* entry; + void* i_end; + void* memsize; + void* stack; + void* params; + void* icon; +} header = { + {'M', 'E', 'N', 'U', 'E', 'T', '0', '1'}, + 1, + &crtStartUp, + 0, // filled by doexe2.asm + 0, // filled by doexe2.asm + exeStack + sizeof(exeStack), + NULL, + kosExePath +}; +#pragma data_seg() +#else +char *kosExePath = NULL; +#endif char pureCallMessage[] = "PURE function call!"; -char *kosExePath = NULL; - // void (__cdecl *atExitList[atexitBufferSize])(); int atExitFnNum = 0; @@ -950,6 +979,10 @@ __declspec(allocate(".CRT$XCZ")) _PVFV __xc_z[1] = { NULL }; // void crtStartUp() { +#ifdef AUTOBUILD +// linker will try to remove unused variables; force header to be included + header.header; +#endif // вызываем инициализаторы по списку, NULL'ы игнорируем for ( _PVFV *pbegin = __xc_a; pbegin < __xc_z; pbegin++ ) { @@ -959,8 +992,10 @@ void crtStartUp() } // инициализируем генератор случайных чисел rtlSrand( kos_GetSystemClock() ); +#ifndef AUTOBUILD // путь к файлу процесса kosExePath = *((char **)0x20); +#endif // вызов главной функции приложения kos_Main(); // выход diff --git a/programs/games/rforces/trunk/kosSyst.h b/programs/games/rforces/trunk/kosSyst.h index a69c4b8bc5..c33b802874 100644 --- a/programs/games/rforces/trunk/kosSyst.h +++ b/programs/games/rforces/trunk/kosSyst.h @@ -89,8 +89,10 @@ union sProcessInfo } processInfo; }; +#ifndef AUTOBUILD // extern char *kosExePath; +#endif // void crtStartUp();