diff --git a/programs/develop/examples/template/trunk/template.asm b/programs/develop/examples/template/trunk/template.asm index e1843ea96c..1298cecb44 100644 --- a/programs/develop/examples/template/trunk/template.asm +++ b/programs/develop/examples/template/trunk/template.asm @@ -28,6 +28,8 @@ CODE redraw: ; redraw event handler call draw_window ; at first create and draw the window + mcall 9, procinfo, -1 + wait_event: ; main cycle mov eax, 10 mcall @@ -88,5 +90,7 @@ end if UDATA sc system_colors +procinfo rb 1024 + MEOS_APP_END ; <--- end of MenuetOS application ---> \ No newline at end of file diff --git a/programs/games/kosilka/KosFile.h b/programs/games/kosilka/KosFile.h index 5f7c18e9bc..da7326f46f 100644 --- a/programs/games/kosilka/KosFile.h +++ b/programs/games/kosilka/KosFile.h @@ -12,15 +12,15 @@ class CKosFile { public: CKosFile(char *fileName); - virtual ~CKosFile(void); - virtual int Read(Byte *targetPtr, int readCount); - virtual int Write(Byte *sourcePtr, int writeCount); - virtual int Seek(int seekFrom, int seekStep); + ~CKosFile(void); + int Read(Byte *targetPtr, int readCount); + int Write(Byte *sourcePtr, int writeCount); + int Seek(int seekFrom, int seekStep); protected: int filePointer; int bufferPointer; bool validBuffer; kosFileInfo fileInfo; - virtual void ValidateBuffer(void); - virtual void UpdateBuffer(void); + void ValidateBuffer(void); + void UpdateBuffer(void); }; diff --git a/programs/games/kosilka/compile.bat b/programs/games/kosilka/compile.bat index 578c08f528..c28a101b63 100644 --- a/programs/games/kosilka/compile.bat +++ b/programs/games/kosilka/compile.bat @@ -1,5 +1,3 @@ -cl /c /O2 /nologo kosilka.cpp kosFile.cpp kosSyst.cpp mcsmemm.cpp -link /nologo /entry:crtStartUp /subsystem:native /base:0 /fixed /align:16 /nodefaultlib kosilka.obj kosFile.obj kosSyst.obj mcsmemm.obj -pe2kos kosilka.exe kosilka -del kosilka.exe -pause \ No newline at end of file +cl /c /O2 /Ox /Os /GL /Gr /Oi /nologo /GS- /GR- kosilka.cpp kosFile.cpp kosSyst.cpp mcsmemm.cpp +link /section:.bss,E /nologo /ltcg /map /entry:crtStartUp /subsystem:native /base:0 /fixed:no /nodefaultlib /merge:.data=.text /merge:.rdata=.text kosilka.obj kosFile.obj kosSyst.obj mcsmemm.obj +fasm doexe2.asm kosilka diff --git a/programs/games/kosilka/kosSyst.cpp b/programs/games/kosilka/kosSyst.cpp index 064d06bd97..36bbd1ee34 100644 --- a/programs/games/kosilka/kosSyst.cpp +++ b/programs/games/kosilka/kosSyst.cpp @@ -1,13 +1,41 @@ #include "kosSyst.h" #include -#define atexitBufferSize 32 +char stack[16384]; +char kosExePath[257]; +struct __MENUET_header_t +{ + char signature[8]; + unsigned version; + void* entry; + unsigned init_size; + unsigned memsize; + void* stackptr; + void* command_line_ptr; + void* app_path_ptr; +}; +__MENUET_header_t __MENUET_header = +{ + {'M','E','N','U','E','T','0','1'}, + 1, + &crtStartUp, + -1, + -1, + stack + sizeof(stack), + NULL, + &kosExePath +}; + +#if 0 +#define atexitBufferSize 32 +#endif char pureCallMessage[] = "PURE function call!"; -char *kosExePath = NULL; +//char *kosExePath = NULL; +#if 0 // void (__cdecl *atExitList[atexitBufferSize])(); int atExitFnNum = 0; @@ -26,7 +54,7 @@ int __cdecl atexit( void (__cdecl *func )( void )) return 1; } } - +#endif // Dword RandomSeed = 1; @@ -341,8 +369,9 @@ void sprintf( char *Str, char* Format, ... ) // функция -1 завершения процесса -void kos_ExitApp() +void __declspec(noreturn) kos_ExitApp() { +#if 0 int i; // @@ -352,6 +381,7 @@ void kos_ExitApp() atExitList[i](); } // +#endif __asm{ mov eax, -1 int 0x40 @@ -433,9 +463,8 @@ getkeyii: return ( result & 0xFF ) == 0; } - // функция 3 получить время -Dword kos_GetSystemClock() +Dword __cdecl kos_GetSystemClock() { // Dword result; @@ -449,7 +478,7 @@ Dword kos_GetSystemClock() // return result; } - +#if 0 // функция 4 void kos_WriteTextToWindow( Word x, @@ -475,10 +504,29 @@ void kos_WriteTextToWindow( int 0x40 } } +#else +// функция 4 +void kos_WriteTextToWindow_internal( + Dword pos, + Dword font, + const char *textPtr, + Dword textLen + ) +{ + __asm{ + mov eax, 4 + mov ebx, pos + mov ecx, font + mov edx, textPtr + mov esi, textLen + int 0x40 + } +} +#endif // функция 5 пауза, в сотых долях секунды -void kos_Pause( Dword value ) +void __cdecl kos_Pause( Dword value ) { // __asm{ @@ -548,7 +596,7 @@ Dword kos_ProcessInfo( sProcessInfo *targetPtr, Dword processID ) // функция 10 -Dword kos_WaitForEvent() +Dword __cdecl kos_WaitForEvent() { // Dword result; @@ -578,7 +626,7 @@ Dword kos_CheckForEvent() // функция 12 -void kos_WindowRedrawStatus( Dword status ) +void __cdecl kos_WindowRedrawStatus( Dword status ) { __asm{ mov eax, 12 @@ -606,7 +654,6 @@ void kos_DrawBar( Word x, Word y, Word sizeX, Word sizeY, Dword colour ) } } - // функция 17 bool kos_GetButtonID( Dword &buttonID ) { @@ -626,7 +673,7 @@ bool kos_GetButtonID( Dword &buttonID ) // функция 23 -Dword kos_WaitForEvent( Dword timeOut ) +Dword __cdecl kos_WaitForEvent( Dword timeOut ) { // Dword result; @@ -724,14 +771,14 @@ Dword kos_GetSkinWidth() // функция 70 доступ к файловой системе -Dword kos_FileSystemAccess( kosFileInfo *fileInfo ) +Dword __fastcall kos_FileSystemAccess( kosFileInfo *fileInfo ) { // Dword result; // __asm{ mov eax, 70 - mov ebx, fileInfo + mov ebx, ecx //fileInfo int 0x40 // mov result, eax } @@ -741,13 +788,13 @@ Dword kos_FileSystemAccess( kosFileInfo *fileInfo ) // функция 63 вывод символя в окно отладки -void kos_DebugOutChar( char ccc ) +void __fastcall kos_DebugOutChar( char ccc ) { // __asm{ mov eax, 63 mov ebx, 1 - mov cl, ccc + //mov cl, ccc int 0x40 } } @@ -827,27 +874,13 @@ int __cdecl _purecall() // заодно инициализация генератора случайных чисел //#pragma section(".CRT$XCA",long,read,write) //#pragma section(".CRT$XCZ",long,read,write) -#pragma data_seg(".CRT$XCA") -#pragma data_seg(".CRT$XCZ") -typedef void (__cdecl *_PVFV)(void); -__declspec(allocate(".CRT$XCA")) _PVFV __xc_a[1] = { NULL }; -__declspec(allocate(".CRT$XCZ")) _PVFV __xc_z[1] = { NULL }; -// -#pragma comment(linker, "/merge:.CRT=.rdata") -// void crtStartUp() { - // вызываем инициализаторы по списку, NULL'ы игнорируем - for ( _PVFV *pbegin = __xc_a; pbegin < __xc_z; pbegin++ ) - { - // - if ( *pbegin != NULL ) - (**pbegin)(); - } + __MENUET_header.app_path_ptr; // инициализируем генератор случайных чисел rtlSrand( kos_GetSystemClock() ); // путь к файлу процесса - kosExePath = *((char **)0x20); + //kosExePath = *((char **)0x20); // вызов главной функции приложения kos_Main(); // выход diff --git a/programs/games/kosilka/kosSyst.h b/programs/games/kosilka/kosSyst.h index a7caff9b16..cd55f58ad5 100644 --- a/programs/games/kosilka/kosSyst.h +++ b/programs/games/kosilka/kosSyst.h @@ -99,7 +99,7 @@ union sProcessInfo }; // -extern char *kosExePath; +extern char kosExePath[]; // void crtStartUp(); @@ -128,7 +128,7 @@ void sprintf( char *Str, char* Format, ... ); // Dword rtlInterlockedExchange( Dword *target, Dword value ); // функция -1 завершения процесса -void kos_ExitApp(); +void __declspec(noreturn) kos_ExitApp(); // функция 0 void kos_DefineAndDrawWindow( Word x, Word y, @@ -142,7 +142,8 @@ void kos_PutPixel( Dword x, Dword y, Dword colour ); // функция 2 получить код нажатой клавиши bool kos_GetKey( Byte &keyCode ); // функция 3 получить время -Dword kos_GetSystemClock(); +Dword __cdecl kos_GetSystemClock(); +#if 0 // функция 4 void kos_WriteTextToWindow( Word x, Word y, @@ -151,26 +152,31 @@ void kos_WriteTextToWindow( char *textPtr, Dword textLen ); +#else +void kos_WriteTextToWindow_internal(Dword pos, Dword font, const char* textPtr, Dword textLen); +#define kos_WriteTextToWindow(x, y, fontType, textColour, textPtr, textLen) \ + kos_WriteTextToWindow_internal(((x)<<16)|(y), ((fontType)<<24)|(textColour), textPtr, textLen) +#endif // функция 7 нарисовать изображение void kos_PutImage( RGB * imagePtr, Word sizeX, Word sizeY, Word x, Word y ); // функция 8 определить кнопку void kos_DefineButton( Word x, Word y, Word sizeX, Word sizeY, Dword buttonID, Dword colour ); // функция 5 пауза, в сотых долях секунды -void kos_Pause( Dword value ); +void __cdecl kos_Pause( Dword value ); // функция 9 - информация о процессе Dword kos_ProcessInfo( sProcessInfo *targetPtr, Dword processID = PROCESS_ID_SELF ); // функция 10 -Dword kos_WaitForEvent(); +Dword __cdecl kos_WaitForEvent(); // функция 11 Dword kos_CheckForEvent(); // функция 12 -void kos_WindowRedrawStatus( Dword status ); +void __cdecl kos_WindowRedrawStatus( Dword status ); // функция 13 нарисовать полосу void kos_DrawBar( Word x, Word y, Word sizeX, Word sizeY, Dword colour ); // функция 17 bool kos_GetButtonID( Dword &buttonID ); // функция 23 -Dword kos_WaitForEvent( Dword timeOut ); +Dword __cdecl kos_WaitForEvent( Dword timeOut ); // enum eNumberBase { @@ -195,9 +201,9 @@ void kos_DisplayNumberToWindow( // функция 48.4 получить высоту скина Dword kos_GetSkinWidth(); // функция 58 доступ к файловой системе -Dword kos_FileSystemAccess( kosFileInfo *fileInfo ); +Dword __fastcall kos_FileSystemAccess( kosFileInfo *fileInfo ); // функция 63 -void kos_DebugOutChar( char ccc ); +void __fastcall kos_DebugOutChar( char ccc ); // void rtlDebugOutString( char *str ); // функция 64 изменить параметры окна, параметр == -1 не меняется diff --git a/programs/games/kosilka/kosilka.cpp b/programs/games/kosilka/kosilka.cpp index b8f202e943..58ee62c628 100644 --- a/programs/games/kosilka/kosilka.cpp +++ b/programs/games/kosilka/kosilka.cpp @@ -323,29 +323,29 @@ char * getLevelsPathName(){ void decode_graphics(Byte * source, RGB * target){ - static RGB palette[] = { - 0x978A31,0x8B7F2E,0x867B2B,0x82762B,0x7F7428,0x79702B,0x766C26,0x90832E, - 0x978A2F,0x9A8C31,0x9B8D32,0x998C31,0x9C8E33,0x9D8F34,0x988B30,0x928531, - 0x887532,0xBAA454,0xA18C3D,0xC6B26A,0xA08E46,0x6B5F26,0xAF9844,0x9C873B, - 0xAB964D,0x988338,0xA89140,0xB49D4C,0xC1AC5C,0x94872F,0x303030,0x343435, - 0x827933,0x806E2F,0x8B8134,0x938632,0x96892F,0x988C33,0x8F873B,0x7E9F39, - 0x8E812D,0x92803F,0x75715C,0x676462,0x6D6A68,0x666260,0x6B6866,0x6A6664, - 0x8E7B35,0x626161,0x797641,0x9B8E33,0x7F7954,0x776A67,0xB29E55,0xBCA75E, - 0x978C3E,0x3E3E3D,0x434245,0x373938,0x3C9737,0x209437,0xB97934,0xE6863E, - 0xF28C41,0xE2833D,0xDD803B,0xD77C3A,0xD17938,0xEA883F,0x605D5B,0x686563, - 0x706D6B,0x5F5F5E,0x656566,0xB56931,0xAC663B,0xC17D36,0xC88338,0x997246, - 0x737271,0xA89546,0x4D4D4E,0x515152,0x565656,0x5A5A59,0x687B41,0x098933, - 0x5B9B38,0x009036,0x069136,0xF18B41,0xC27034,0xCD7737,0xEE8A40,0xA0774B, - 0xF18C41,0x948037,0x988B34,0x49484A,0x5D5D5D,0x039036,0x0E9236,0xB06B7B, - 0x949CF8,0x7C85F6,0x6A74F5,0x5A66F4,0x4653F1,0x5F53B6,0x726462,0x9C7449, - 0xD0C472,0x696969,0x998B32,0x9D6676,0x3B47DD,0x5349A0,0xD8CD77,0x343EC1, - 0x4F438C,0x8E5538,0xC37341,0x895D71,0x483B74,0x433359,0x9C8D34,0x2A329A, - 0x995F49,0x1D236D,0x756E37,0x524819,0x8D8848,0x9B8D34,0x157F2F,0x2D6C28, - 0xAA778B,0x663C15,0x4E5924,0x9D8F31,0xBCAD48 + static const char palette[] = { + 0x31,0x8A,0x97,0x2E,0x7F,0x8B,0x2B,0x7B,0x86,0x2B,0x76,0x82,0x28,0x74,0x7F,0x2B,0x70,0x79,0x26,0x6C,0x76,0x2E,0x83,0x90, + 0x2F,0x8A,0x97,0x31,0x8C,0x9A,0x32,0x8D,0x9B,0x31,0x8C,0x99,0x33,0x8E,0x9C,0x34,0x8F,0x9D,0x30,0x8B,0x98,0x31,0x85,0x92, + 0x32,0x75,0x88,0x54,0xA4,0xBA,0x3D,0x8C,0xA1,0x6A,0xB2,0xC6,0x46,0x8E,0xA0,0x26,0x5F,0x6B,0x44,0x98,0xAF,0x3B,0x87,0x9C, + 0x4D,0x96,0xAB,0x38,0x83,0x98,0x40,0x91,0xA8,0x4C,0x9D,0xB4,0x5C,0xAC,0xC1,0x2F,0x87,0x94,0x30,0x30,0x30,0x35,0x34,0x34, + 0x33,0x79,0x82,0x2F,0x6E,0x80,0x34,0x81,0x8B,0x32,0x86,0x93,0x2F,0x89,0x96,0x33,0x8C,0x98,0x3B,0x87,0x8F,0x39,0x9F,0x7E, + 0x2D,0x81,0x8E,0x3F,0x80,0x92,0x5C,0x71,0x75,0x62,0x64,0x67,0x68,0x6A,0x6D,0x60,0x62,0x66,0x66,0x68,0x6B,0x64,0x66,0x6A, + 0x35,0x7B,0x8E,0x61,0x61,0x62,0x41,0x76,0x79,0x33,0x8E,0x9B,0x54,0x79,0x7F,0x67,0x6A,0x77,0x55,0x9E,0xB2,0x5E,0xA7,0xBC, + 0x3E,0x8C,0x97,0x3D,0x3E,0x3E,0x45,0x42,0x43,0x38,0x39,0x37,0x37,0x97,0x3C,0x37,0x94,0x20,0x34,0x79,0xB9,0x3E,0x86,0xE6, + 0x41,0x8C,0xF2,0x3D,0x83,0xE2,0x3B,0x80,0xDD,0x3A,0x7C,0xD7,0x38,0x79,0xD1,0x3F,0x88,0xEA,0x5B,0x5D,0x60,0x63,0x65,0x68, + 0x6B,0x6D,0x70,0x5E,0x5F,0x5F,0x66,0x65,0x65,0x31,0x69,0xB5,0x3B,0x66,0xAC,0x36,0x7D,0xC1,0x38,0x83,0xC8,0x46,0x72,0x99, + 0x71,0x72,0x73,0x46,0x95,0xA8,0x4E,0x4D,0x4D,0x52,0x51,0x51,0x56,0x56,0x56,0x59,0x5A,0x5A,0x41,0x7B,0x68,0x33,0x89,0x09, + 0x38,0x9B,0x5B,0x36,0x90,0x00,0x36,0x91,0x06,0x41,0x8B,0xF1,0x34,0x70,0xC2,0x37,0x77,0xCD,0x40,0x8A,0xEE,0x4B,0x77,0xA0, + 0x41,0x8C,0xF1,0x37,0x80,0x94,0x34,0x8B,0x98,0x4A,0x48,0x49,0x5D,0x5D,0x5D,0x36,0x90,0x03,0x36,0x92,0x0E,0x7B,0x6B,0xB0, + 0xF8,0x9C,0x94,0xF6,0x85,0x7C,0xF5,0x74,0x6A,0xF4,0x66,0x5A,0xF1,0x53,0x46,0xB6,0x53,0x5F,0x62,0x64,0x72,0x49,0x74,0x9C, + 0x72,0xC4,0xD0,0x69,0x69,0x69,0x32,0x8B,0x99,0x76,0x66,0x9D,0xDD,0x47,0x3B,0xA0,0x49,0x53,0x77,0xCD,0xD8,0xC1,0x3E,0x34, + 0x8C,0x43,0x4F,0x38,0x55,0x8E,0x41,0x73,0xC3,0x71,0x5D,0x89,0x74,0x3B,0x48,0x59,0x33,0x43,0x34,0x8D,0x9C,0x9A,0x32,0x2A, + 0x49,0x5F,0x99,0x6D,0x23,0x1D,0x37,0x6E,0x75,0x19,0x48,0x52,0x48,0x88,0x8D,0x34,0x8D,0x9B,0x2F,0x7F,0x15,0x28,0x6C,0x2D, + 0x8B,0x77,0xAA,0x15,0x3C,0x66,0x24,0x59,0x4E,0x31,0x8F,0x9D,0x48,0xAD,0xBC }; for (int lc=0;lc<576;lc++) - target[lc] = palette[source[lc]]; + target[lc] = ((RGB*)palette)[source[lc]]; } diff --git a/programs/media/kiv/trunk/kiv.asm b/programs/media/kiv/trunk/kiv.asm index 46172d8672..53cfe70b2a 100644 --- a/programs/media/kiv/trunk/kiv.asm +++ b/programs/media/kiv/trunk/kiv.asm @@ -25,7 +25,7 @@ START: or eax, eax jnz exit - invoke sort.START, 1 +; invoke sort.START, 1 mov ecx, 1 ; for 15.4: 1 = tile cmp word [@PARAMS], '\T' @@ -540,20 +540,20 @@ load_directory: mov [eax+4], ebx test ebx, ebx jz free_directory - push 0 ; sort mode - push ebx - add eax, 32 - push eax - call [SortDir] +; push 0 ; sort mode +; push ebx +; add eax, 32 +; push eax +; call [SortDir] xor eax, eax mov edi, [directory_ptr] add edi, 32 + 40 .scan: mov esi, [last_name_component] inc esi - push edi - invoke strcmpi - pop edi +; push edi +; invoke strcmpi +; pop edi jz .found inc eax add edi, 304 @@ -995,8 +995,8 @@ align 4 library \ libio , 'libio.obj' , \ libgfx , 'libgfx.obj' , \ - libimg , 'libimg.obj' , \ - sort , 'sort.obj' + libimg , 'libimg.obj' ;, \ +; sort , 'sort.obj' import libio , \ libio.init , 'lib_init' , \ @@ -1022,7 +1022,7 @@ import libimg , \ img.destroy , 'img_destroy', \ img.draw , 'img_draw' -import sort, sort.START, 'START', SortDir, 'SortDir', strcmpi, 'strcmpi' +;import sort, sort.START, 'START', SortDir, 'SortDir', strcmpi, 'strcmpi' bFirstDraw db 0 ;----------------------------------------------------------------------------- diff --git a/test.tmp b/test.tmp deleted file mode 100644 index 51520cd48c..0000000000 --- a/test.tmp +++ /dev/null @@ -1 +0,0 @@ -qwe4 \ No newline at end of file