Subversion Repositories Kolibri OS

Rev

Rev 7500 | Rev 7504 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.  
  2. #pragma once
  3.  
  4. typedef unsigned __int32 Dword;
  5. typedef unsigned __int16 Word;
  6. typedef unsigned __int8 Byte;
  7. //typedef unsigned __int32 size_t;
  8.  
  9. #define NULL 0
  10.  
  11. #define MAX_PATH                                256
  12.  
  13. #define FO_READ                                 0
  14. #define FO_WRITE                                2
  15.  
  16. //Process Events
  17. #define EM_WINDOW_REDRAW                1
  18. #define EM_KEY_PRESS                    2
  19. #define EM_BUTTON_CLICK                 3
  20. #define EM_APP_CLOSE                    4
  21. #define EM_DRAW_BACKGROUND              5
  22. #define EM_MOUSE_EVENT                  6
  23. #define EM_IPC                                  7
  24. #define EM_NETWORK                              8
  25. #define EM_DEBUG                                9
  26.  
  27. //Event mask bits for function 40
  28. #define EVM_REDRAW        1
  29. #define EVM_KEY           2
  30. #define EVM_BUTTON        4
  31. #define EVM_EXIT          8
  32. #define EVM_BACKGROUND    16
  33. #define EVM_MOUSE         32
  34. #define EVM_IPC           64
  35. #define EVM_STACK         128
  36. #define EVM_DEBUG         256
  37. #define EVM_STACK2        512
  38. #define EVM_MOUSE_FILTER  0x80000000
  39. #define EVM_CURSOR_FILTER 0x40000000
  40.  
  41. //Button options
  42. #define BT_DEL      0x80000000
  43. #define BT_HIDE     0x40000000
  44. #define BT_NOFRAME  0x20000000
  45. #define BT_NODRAW   BT_HIDE+BT_NOFRAME
  46.  
  47. #define KM_CHARS                                0
  48. #define KM_SCANS                                1
  49.  
  50. #define WRS_BEGIN                               1
  51. #define WRS_END                                 2
  52.  
  53. #define PROCESS_ID_SELF                 -1
  54.  
  55. #define abs(a) (a<0?0-a:a)
  56.  
  57. extern "C" double __cdecl acos(double x);
  58. extern "C" double __cdecl asin(double x);
  59. extern "C" double __cdecl floor(double x);
  60. extern "C" double __cdecl round(double x);
  61. #pragma function(acos,asin)
  62. #if _MSC_VER > 1200
  63. #pragma function(floor)
  64. #endif
  65.  
  66.  
  67. struct kosFileInfo
  68. {
  69.         Dword rwMode;
  70.         Dword OffsetLow;
  71.         Dword OffsetHigh;
  72.         Dword dataCount;
  73.         Byte *bufferPtr;
  74.         char fileURL[MAX_PATH];
  75. };
  76.  
  77.  
  78. struct RGB
  79. {
  80.         Byte b;
  81.         Byte g;
  82.         Byte r;
  83.         //
  84.         RGB() {};
  85.         //
  86.         RGB( Dword value )
  87.         {
  88.                 r = (Byte)(value >> 16);
  89.                 g = (Byte)(value >> 8);
  90.                 b = (Byte)value;
  91.         };
  92.         //
  93.         bool operator != ( RGB &another )
  94.         {
  95.                 return this->b != another.b || this->g != another.g || this->r != another.r;
  96.         };
  97.         //
  98.         bool operator == ( RGB &another )
  99.         {
  100.                 return this->b == another.b && this->g == another.g && this->r == another.r;
  101.         };
  102. };
  103.  
  104.  
  105. #pragma pack(push, 1)
  106. union sProcessInfo
  107. {
  108.         Byte rawData[1024];
  109.         struct
  110.         {
  111.                 Dword cpu_usage;
  112.                 Word window_stack_position;
  113.                 Word window_slot; //slot
  114.                 Word reserved1;
  115.                 char process_name[12];
  116.                 Dword memory_start;
  117.                 Dword used_memory;
  118.                 Dword PID;
  119.                 Dword x_start;
  120.                 Dword y_start;
  121.                 Dword width;
  122.                 Dword height;
  123.                 Word slot_state;
  124.                 Word reserved3;
  125.                 Dword work_left;
  126.                 Dword work_top;
  127.                 Dword work_width;
  128.                 Dword work_height;
  129.                 char status_window;
  130.                 Dword cwidth;
  131.                 Dword cheight;
  132.         } processInfo;
  133. };
  134. #pragma pack(pop)
  135.  
  136. #ifndef AUTOBUILD
  137. //
  138. extern char *kosExePath;
  139. #endif
  140.  
  141. //
  142. void crtStartUp();
  143. //
  144. int __cdecl _purecall();
  145. //
  146. int __cdecl atexit( void (__cdecl *func )( void ));
  147. //
  148. void rtlSrand( Dword seed );
  149. Dword rtlRand( void );
  150. //
  151. char * __cdecl strcpy( char *target, const char *source );
  152. int __cdecl strlen( const char *line );
  153. char * __cdecl strrchr( const char * string, int c );
  154. //
  155. // if you have trouble here look at old SVN revisions for alternatives
  156. void memcpy( void *dst, const void *src, size_t bytesCount );
  157. void memset( Byte *dst, Byte filler, Dword count );
  158. //
  159. void sprintf( char *Str, char* Format, ... );
  160. //
  161. Dword rtlInterlockedExchange( Dword *target, Dword value );
  162. // function -1 çàâåðøåíèÿ ïðîöåññà
  163. void kos_ExitApp();
  164. // function 0
  165. void kos_DefineAndDrawWindow(
  166.         Word x, Word y,
  167.         Word sizeX, Word sizeY,
  168.         Byte mainAreaType, Dword mainAreaColour,
  169.         Byte headerType, Dword headerColour,
  170.         Dword borderColour
  171.         );
  172. // function 1 ïîñòàâèòü òî÷êó
  173. void kos_PutPixel( Dword x, Dword y, Dword colour );
  174. // function 2 ïîëó÷èòü êîä íàæàòîé êëàâèøè
  175. bool kos_GetKey( Byte &keyCode );
  176. // function 3 ïîëó÷èòü âðåìÿ
  177. Dword kos_GetSystemClock();
  178. // function 4
  179. void __declspec(noinline) kos_WriteTextToWindow(
  180.         Word x, Word y,
  181.         Byte fontType,
  182.         Dword textColour,
  183.         char *textPtr,
  184.         Dword textLen
  185.         );
  186. // function 7 íàðèñîâàòü èçîáðàæåíèå
  187. void kos_PutImage( RGB * imagePtr, Word sizeX, Word sizeY, Word x, Word y );
  188. // function 8 îïðåäåëèòü êíîïêó
  189. void __declspec(noinline) kos_DefineButton( Word x, Word y, Word sizeX, Word sizeY, Dword buttonID, Dword colour );
  190. //
  191. void __declspec(noinline) kos_UnsaveDefineButton( Word x, Word y, Word sizeX, Word sizeY, Dword buttonID, Dword colour );
  192. // function 5 ïàóçà, â ñîòûõ äîëÿõ ñåêóíäû
  193. void kos_Pause( Dword value );
  194. // function 9 - èíôîðìàöèÿ î ïðîöåññå
  195. Dword kos_ProcessInfo( sProcessInfo *targetPtr, Dword processID = PROCESS_ID_SELF );
  196. // function 10
  197. Dword kos_WaitForEvent();
  198. // function 11
  199. Dword kos_CheckForEvent();
  200. // function 12
  201. void kos_WindowRedrawStatus( Dword status );
  202. // function 13 íàðèñîâàòü ïîëîñó
  203. void __declspec(noinline) kos_DrawBar( Word x, Word y, Word sizeX, Word sizeY, Dword colour );
  204. // function 17
  205. bool kos_GetButtonID( Dword &buttonID );
  206. // function 23
  207. Dword kos_WaitForEventTimeout( Dword timeOut );
  208. //
  209. enum eNumberBase
  210. {
  211.         nbDecimal = 0,
  212.         nbHex,
  213.         nbBin
  214. };
  215. // ïîëó÷åíèå èíôîðìàöèè î ñîñòîÿíèè "ìûøè" function 37
  216. void kos_GetMouseState( Dword & buttons, int & cursorX, int & cursorY );
  217. // function 38
  218. void kos_DrawLine( Word x1, Word y1, Word x2, Word y2, Dword colour, Dword invert );
  219. // function 40 óñòàíîâèòü ìàñêó ñîáûòèé
  220. void kos_SetMaskForEvents( Dword mask );
  221. // function 47 âûâåñòè â îêíî ïðèëîæåíèÿ ÷èñëî
  222. void kos_DisplayNumberToWindow(
  223.    Dword value,
  224.    Dword digitsNum,
  225.    Word x,
  226.    Word y,
  227.    Dword colour,
  228.    eNumberBase nBase = nbDecimal,
  229.    bool valueIsPointer = false
  230.    );
  231. // function 58 äîñòóï ê ôàéëîâîé ñèñòåìå
  232. Dword kos_FileSystemAccess( kosFileInfo *fileInfo );
  233. // function 63
  234. void kos_DebugOutChar( char ccc );
  235. //
  236. void rtlDebugOutString( char *str );
  237. //
  238. void kos_DebugValue(char *str, int n);
  239. // function 64 èçìåíèòü ïàðàìåòðû îêíà, ïàðàìåòð == -1 íå ìåíÿåòñÿ
  240. void kos_ChangeWindow( Dword x, Dword y, Dword sizeX, Dword sizeY );
  241. // function 67 èçìåíåíèå êîëè÷åñòâà ïàìÿòè, âûäåëåííîé äëÿ ïðîãðàììû
  242. bool kos_ApplicationMemoryResize( Dword targetSize );
  243. // function 66 ðåæèì ïîëó÷åíèÿ äàííûõ îò êëàâèàòóðû
  244. void kos_SetKeyboardDataMode( Dword mode );
  245.  
  246. void kos_InitHeap();
  247.  
  248. //
  249. void kos_Main();
  250.