Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | 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.         char* OffsetHigh;
  72.         Dword dataCount;
  73.         Byte *bufferPtr;
  74.         char fileURL[MAX_PATH];
  75. };
  76.  
  77.  
  78. struct kosSysColors {
  79.         Dword nonset1;
  80.         Dword nonset2;
  81.         Dword work_dark;
  82.         Dword work_light;
  83.         Dword window_title;
  84.         Dword work;
  85.         Dword work_button;
  86.         Dword work_button_text;
  87.         Dword work_text;
  88.         Dword work_graph;
  89. };
  90.  
  91.  
  92. struct RGB
  93. {
  94.         Byte b;
  95.         Byte g;
  96.         Byte r;
  97.         //
  98.         RGB() {};
  99.         //
  100.         RGB( Dword value )
  101.         {
  102.                 r = (Byte)(value >> 16);
  103.                 g = (Byte)(value >> 8);
  104.                 b = (Byte)value;
  105.         };
  106.         //
  107.         bool operator != ( RGB &another )
  108.         {
  109.                 return this->b != another.b || this->g != another.g || this->r != another.r;
  110.         };
  111.         //
  112.         bool operator == ( RGB &another )
  113.         {
  114.                 return this->b == another.b && this->g == another.g && this->r == another.r;
  115.         };
  116. };
  117.  
  118.  
  119. #pragma pack(push, 1)
  120. union sProcessInfo
  121. {
  122.         Byte rawData[1024];
  123.         struct
  124.         {
  125.                 Dword cpu_usage;
  126.                 Word window_stack_position;
  127.                 Word window_slot; //slot
  128.                 Word reserved1;
  129.                 char process_name[12];
  130.                 Dword memory_start;
  131.                 Dword used_memory;
  132.                 Dword PID;
  133.                 Dword x_start;
  134.                 Dword y_start;
  135.                 Dword width;
  136.                 Dword height;
  137.                 Word slot_state;
  138.                 Word reserved3;
  139.                 Dword work_left;
  140.                 Dword work_top;
  141.                 Dword work_width;
  142.                 Dword work_height;
  143.                 char status_window;
  144.                 Dword cwidth;
  145.                 Dword cheight;
  146.         } processInfo;
  147. };
  148. #pragma pack(pop)
  149.  
  150. #ifndef AUTOBUILD
  151. //
  152. extern char *kosExePath;
  153. #endif
  154.  
  155. //
  156. void crtStartUp();
  157. //
  158. int __cdecl _purecall();
  159. //
  160. int __cdecl atexit( void (__cdecl *func )( void ));
  161. //
  162. void rtlSrand( Dword seed );
  163. Dword rtlRand( void );
  164. //
  165. char * __cdecl strcpy( char *target, const char *source );
  166. int __cdecl strlen( const char *line );
  167. char * __cdecl strrchr( const char * string, int c );
  168. //
  169. // if you have trouble here look at old SVN revisions for alternatives
  170. void memcpy( void *dst, const void *src, size_t bytesCount );
  171. void memset( Byte *dst, Byte filler, Dword count );
  172. //
  173. void sprintf( char *Str, char* Format, ... );
  174. //
  175. Dword rtlInterlockedExchange( Dword *target, Dword value );
  176. // function -1 çàâåðøåíèÿ ïðîöåññà
  177. void kos_ExitApp();
  178. // function 0
  179. void kos_DefineAndDrawWindow(
  180.         Word x, Word y,
  181.         Word sizeX, Word sizeY,
  182.         Byte mainAreaType, Dword mainAreaColour,
  183.         Byte headerType, Dword headerColour,
  184.         Dword borderColour
  185.         );
  186. // function 1 ïîñòàâèòü òî÷êó
  187. void kos_PutPixel( Dword x, Dword y, Dword colour );
  188. // function 2 ïîëó÷èòü êîä íàæàòîé êëàâèøè
  189. bool kos_GetKey( Byte &keyCode );
  190. bool kos_GetKeys( Dword &key_editbox, Byte &key_ascii, Byte &key_scancode );
  191. // function 3 ïîëó÷èòü âðåìÿ
  192. Dword kos_GetSystemClock();
  193. // function 4
  194. void __declspec(noinline) kos_WriteTextToWindow(
  195.         Word x, Word y,
  196.         Byte fontType,
  197.         Dword textColour,
  198.         char *textPtr,
  199.         Dword textLen
  200.         );
  201. // function 7 íàðèñîâàòü èçîáðàæåíèå
  202. void kos_PutImage( RGB * imagePtr, Word sizeX, Word sizeY, Word x, Word y );
  203. // function 8 îïðåäåëèòü êíîïêó
  204. void __declspec(noinline) kos_DefineButton( Word x, Word y, Word sizeX, Word sizeY, Dword buttonID, Dword colour );
  205. //
  206. void __declspec(noinline) kos_UnsaveDefineButton( Word x, Word y, Word sizeX, Word sizeY, Dword buttonID, Dword colour );
  207. // function 5 ïàóçà, â ñîòûõ äîëÿõ ñåêóíäû
  208. void kos_Pause( Dword value );
  209. // function 9 - èíôîðìàöèÿ î ïðîöåññå
  210. Dword kos_ProcessInfo( sProcessInfo *targetPtr, Dword processID = PROCESS_ID_SELF );
  211. // function 10
  212. Dword kos_WaitForEvent();
  213. // function 11
  214. Dword kos_CheckForEvent();
  215. // function 12
  216. void kos_WindowRedrawStatus( Dword status );
  217. // function 13 íàðèñîâàòü ïîëîñó
  218. void __declspec(noinline) kos_DrawBar( Word x, Word y, Word sizeX, Word sizeY, Dword colour );
  219. // function 17
  220. bool kos_GetButtonID( Dword &buttonID );
  221. // function 23
  222. Dword kos_WaitForEventTimeout( Dword timeOut );
  223. //
  224. enum eNumberBase
  225. {
  226.         nbDecimal = 0,
  227.         nbHex,
  228.         nbBin
  229. };
  230. // ïîëó÷åíèå èíôîðìàöèè î ñîñòîÿíèè "ìûøè" function 37
  231. void kos_GetMouseState( Dword & buttons, int & cursorX, int & cursorY );
  232. // function 38
  233. void kos_DrawLine( Word x1, Word y1, Word x2, Word y2, Dword colour, Dword invert );
  234. // function 40 óñòàíîâèòü ìàñêó ñîáûòèé
  235. void kos_SetMaskForEvents( Dword mask );
  236. // function 47 âûâåñòè â îêíî ïðèëîæåíèÿ ÷èñëî
  237. void kos_DisplayNumberToWindow(
  238.    Dword value,
  239.    Dword digitsNum,
  240.    Word x,
  241.    Word y,
  242.    Dword colour,
  243.    eNumberBase nBase = nbDecimal,
  244.    bool valueIsPointer = false
  245.    );
  246. // 48.3: get system colors
  247. bool kos_GetSystemColors( kosSysColors *sc );
  248. // function 63
  249. void kos_DebugOutChar( char ccc );
  250. //
  251. void rtlDebugOutString( char *str );
  252. //
  253. void kos_DebugValue(char *str, int n);
  254. // function 64 èçìåíèòü ïàðàìåòðû îêíà, ïàðàìåòð == -1 íå ìåíÿåòñÿ
  255. void kos_ChangeWindow( Dword x, Dword y, Dword sizeX, Dword sizeY );
  256. // function 67 èçìåíåíèå êîëè÷åñòâà ïàìÿòè, âûäåëåííîé äëÿ ïðîãðàììû
  257. bool kos_ApplicationMemoryResize( Dword targetSize );
  258. // function 66 ðåæèì ïîëó÷åíèÿ äàííûõ îò êëàâèàòóðû
  259. void kos_SetKeyboardDataMode( Dword mode );
  260. // 68.11: init heap
  261. void kos_InitHeap();
  262. // function 70 äîñòóï ê ôàéëîâîé ñèñòåìå
  263. Dword kos_FileSystemAccess( kosFileInfo *fileInfo );
  264. // 70.7: run Kolibri application with param
  265. int kos_AppRun(char* app_path, char* param);
  266. //
  267. void kos_Main();
  268.  
  269. //SCAN CODE KEYS
  270. #define SCAN_CODE_BS    14
  271. #define SCAN_CODE_TAB   15
  272. #define SCAN_CODE_ENTER 28
  273. #define SCAN_CODE_ESC    1
  274. #define SCAN_CODE_DEL   83
  275. #define SCAN_CODE_INS   82
  276. #define SCAN_CODE_SPACE 57
  277. #define SCAN_CODE_MENU  93
  278.  
  279. #define SCAN_CODE_LEFT  75
  280. #define SCAN_CODE_RIGHT 77
  281. #define SCAN_CODE_DOWN  80
  282. #define SCAN_CODE_UP    72
  283. #define SCAN_CODE_HOME  71
  284. #define SCAN_CODE_END   79
  285. #define SCAN_CODE_PGDN  81
  286. #define SCAN_CODE_PGUP  73
  287.  
  288. #define SCAN_CODE_MINUS 12
  289. #define SCAN_CODE_PLUS  13
  290.  
  291. #define SCAN_CODE_F1    59
  292. #define SCAN_CODE_F2    60
  293. #define SCAN_CODE_F3    61
  294. #define SCAN_CODE_F4    62
  295. #define SCAN_CODE_F5    63
  296. #define SCAN_CODE_F6    64
  297. #define SCAN_CODE_F7    65
  298. #define SCAN_CODE_F8    66
  299. #define SCAN_CODE_F9    67
  300. #define SCAN_CODE_F10   68
  301. #define SCAN_CODE_F11   87
  302. #define SCAN_CODE_F12   88
  303.  
  304. #define SCAN_CODE_KEY_A 30
  305. #define SCAN_CODE_KEY_B 48
  306. #define SCAN_CODE_KEY_C 46
  307. #define SCAN_CODE_KEY_D 32
  308. #define SCAN_CODE_KEY_E 18
  309. #define SCAN_CODE_KEY_F 33
  310. #define SCAN_CODE_KEY_H 35
  311. #define SCAN_CODE_KEY_I 23
  312. #define SCAN_CODE_KEY_L 38
  313. #define SCAN_CODE_KEY_M 50
  314. #define SCAN_CODE_KEY_N 49
  315. #define SCAN_CODE_KEY_O 24
  316. #define SCAN_CODE_KEY_P 25
  317. #define SCAN_CODE_KEY_R 19
  318. #define SCAN_CODE_KEY_S 31
  319. #define SCAN_CODE_KEY_T 20
  320. #define SCAN_CODE_KEY_U 22
  321. #define SCAN_CODE_KEY_V 47
  322. #define SCAN_CODE_KEY_X 45
  323. #define SCAN_CODE_KEY_Y 21
  324. #define SCAN_CODE_KEY_Z 44