Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. #pragma once
  2.  
  3. typedef unsigned __int32 Dword;
  4. typedef unsigned __int16 Word;
  5. typedef unsigned __int8 Byte;
  6. //typedef unsigned __int32 size_t;
  7.  
  8. extern "C" char kosCmdLine[];   // command line initialized by OS
  9. extern "C" char kosExePath[];   // path to binary initialized by OS
  10.  
  11. #define NULL 0
  12.  
  13. #define MAX_PATH                                256
  14.  
  15. #define FO_READ                                 0
  16. #define FO_WRITE                                2
  17.  
  18. #define EM_WINDOW_REDRAW                1
  19. #define EM_KEY_PRESS                    2
  20. #define EM_BUTTON_CLICK                 4
  21. #define EM_APP_CLOSE                    8
  22. #define EM_DRAW_BACKGROUND              16
  23. #define EM_MOUSE_EVENT                  32
  24. #define EM_IPC                                  64
  25. #define EM_NETWORK                              256
  26.  
  27. #define KM_CHARS                                0
  28. #define KM_SCANS                                1
  29.  
  30. #define WRS_BEGIN                               1
  31. #define WRS_END                                 2
  32.  
  33. #define PROCESS_ID_SELF                 -1
  34.  
  35. #define abs(a) (a<0?0-a:a)
  36.  
  37. extern "C" double __cdecl acos(double x);
  38. extern "C" double __cdecl asin(double x);
  39. extern "C" double __cdecl floor(double x);
  40. extern "C" double __cdecl round(double x);
  41. #pragma function(acos,asin)
  42. #if _MSC_VER > 1200
  43. #pragma function(floor)
  44. #endif
  45.  
  46.  
  47. struct kosFileInfo
  48. {
  49.         Dword rwMode;
  50.         Dword OffsetLow;
  51.         Dword OffsetHigh;
  52.         Dword dataCount;
  53.         Byte *bufferPtr;
  54.         char fileURL[MAX_PATH];
  55. };
  56.  
  57. struct Point
  58. {
  59.         int X;
  60.         int Y;
  61.  
  62.         Point() {};
  63.         Point(int x, int y)
  64.         {
  65.                 this->X = x;
  66.                 this->Y = y;
  67.         };
  68.         bool operator != (Point &a){ return this->X != a.X || this->Y != a.Y; };
  69.         bool operator == (Point &a){ return this->X == a.X && this->Y == a.Y; };
  70.         Point operator + (Point &a){ return Point(this->X + a.X, this->Y + a.Y); }
  71.         Point operator + (int a){ return Point(this->X + a, this->Y + a); }
  72.         Point operator - (Point &a){ return Point(this->X - a.X, this->Y - a.Y); }
  73.         Point operator - (int a){ return Point(this->X - a, this->Y - a); }
  74.         Point operator * (Point &a){ return Point(this->X * a.X, this->Y * a.Y); }
  75.         Point operator * (int a){ return Point(this->X * a, this->Y * a); }
  76.         Point operator / (Point &a){ return Point(this->X / a.X, this->Y / a.Y); }
  77.         Point operator / (int a){ return Point(this->X / a, this->Y / a); }
  78.        
  79.         float Lingrh();
  80.         float Angle();
  81. };
  82.  
  83. struct Rect
  84. {
  85.         int X;
  86.         int Y;
  87.         int Width;
  88.         int Height;
  89.         Rect() {}
  90.         Rect(int X, int Y, int Width, int Height)
  91.         {
  92.                 this->X = X;
  93.                 this->Y = Y;
  94.                 this->Width = Width;
  95.                 this->Height = Height;
  96.         }
  97. };
  98.  
  99. struct RGBA
  100. {
  101.         Byte b;
  102.         Byte g;
  103.         Byte r;
  104.         Byte a;
  105.  
  106.         RGBA() {};
  107.  
  108.         RGBA(Dword value)
  109.         {
  110.                 a = (Byte)(value >> 24);
  111.                 r = (Byte)(value >> 16);
  112.                 g = (Byte)(value >> 8);
  113.                 b = (Byte)value;
  114.         };
  115.         //
  116.         bool operator != (RGBA &another)
  117.         {
  118.                 return this->b != another.b || this->g != another.g || this->r != another.r || this->a != another.a;
  119.         };
  120.         //
  121.         bool operator == (RGBA &another)
  122.         {
  123.                 return this->b == another.b && this->g == another.g && this->r == another.r && this->a == another.a;
  124.         };
  125. };
  126.  
  127.  
  128. struct RGB
  129. {
  130.         Byte b;
  131.         Byte g;
  132.         Byte r;
  133.         //
  134.         RGB() {};
  135.         //
  136.         RGB( Dword value )
  137.         {
  138.                 r = (Byte)(value >> 16);
  139.                 g = (Byte)(value >> 8);
  140.                 b = (Byte)value;
  141.         };
  142.         //
  143.         bool operator != ( RGB &another )
  144.         {
  145.                 return this->b != another.b || this->g != another.g || this->r != another.r;
  146.         };
  147.         //
  148.         bool operator == ( RGB &another )
  149.         {
  150.                 return this->b == another.b && this->g == another.g && this->r == another.r;
  151.         };
  152. };
  153.  
  154. struct Player
  155. {
  156.         Point vector;
  157.         Point position;
  158.         float angle;
  159.  
  160.         Player() {}
  161.         Player(Point position)
  162.         {
  163.                 this->vector = Point(0, -1);
  164.                 this->position = position;
  165.                 this->angle = 270;
  166.         };
  167. };
  168.  
  169. #pragma pack(push, 1)
  170. union sProcessInfo
  171. {
  172.         Byte rawData[1024];
  173.         struct
  174.         {
  175.                 Dword cpu_usage;
  176.                 Word window_stack_position;
  177.                 Word window_stack_value;
  178.                 Word reserved1;
  179.                 char process_name[12];
  180.                 Dword memory_start;
  181.                 Dword used_memory;
  182.                 Dword PID;
  183.                 Dword x_start;
  184.                 Dword y_start;
  185.                 Dword x_size;
  186.                 Dword y_size;
  187.                 Word slot_state;
  188.         } processInfo;
  189. };
  190. #pragma pack(pop)
  191.  
  192. //
  193. extern "C" void __cdecl crtStartUp();
  194. //
  195. int __cdecl _purecall();
  196. //
  197. int __cdecl atexit( void (__cdecl *func )( void ));
  198. //
  199. void rtlSrand( Dword seed );
  200. Dword rtlRand( void );
  201. //
  202. char * __cdecl strcpy( char *target, const char *source );
  203. int __cdecl strlen( const char *line );
  204. char * __cdecl strrchr( const char * string, int c );
  205.  
  206. #if _MSC_VER < 1400
  207. extern "C" void * __cdecl memcpy( void *dst, const void *src, size_t bytesCount );
  208. extern "C" void memset( Byte *dst, Byte filler, Dword count );
  209. //#pragma intrinsic(memcpy,memset)
  210. #else
  211. void * __cdecl memcpy( void *dst, const void *src, size_t bytesCount );
  212. void memset( Byte *dst, Byte filler, Dword count );
  213. #endif
  214.  
  215. unsigned int num2hex( unsigned int num );
  216. void sprintf( char *Str, char* Format, ... );
  217. //
  218. Dword rtlInterlockedExchange( Dword *target, Dword value );
  219. // ôóíêöèÿ -1 çàâåðøåíèÿ ïðîöåññà
  220. void __declspec(noreturn) kos_ExitApp();
  221. // ôóíêöèÿ 0
  222. void kos_DefineAndDrawWindow(
  223.         Word x, Word y,
  224.         Word sizeX, Word sizeY,
  225.         Byte mainAreaType, Dword mainAreaColour,
  226.         Byte headerType, Dword headerColour,
  227.         Dword borderColour
  228.         );
  229. // ôóíêöèÿ 1 ïîñòàâèòü òî÷êó
  230. void kos_PutPixel( Dword x, Dword y, Dword colour );
  231. // ôóíêöèÿ 2 ïîëó÷èòü êîä íàæàòîé êëàâèøè
  232. bool kos_GetKey( Byte &keyCode );
  233. // ôóíêöèÿ 3 ïîëó÷èòü âðåìÿ
  234. Dword kos_GetSystemClock();
  235. // ôóíêöèÿ 4
  236. void kos_WriteTextToWindow(
  237.         Word x, Word y,
  238.         Byte fontType,
  239.         Dword textColour,
  240.         const char *textPtr,
  241.         Dword textLen
  242.         );
  243. // ôóíêöèÿ 7 íàðèñîâàòü èçîáðàæåíèå
  244. void kos_PutImage( RGB * imagePtr, Word sizeX, Word sizeY, Word x, Word y );
  245. // ôóíêöèÿ 8 îïðåäåëèòü êíîïêó
  246. void __declspec(noinline) kos_DefineButton( Word x, Word y, Word sizeX, Word sizeY, Dword buttonID, Dword colour );
  247. // ôóíêöèÿ 5 ïàóçà, â ñîòûõ äîëÿõ ñåêóíäû
  248. void kos_Pause( Dword value );
  249. // ôóíêöèÿ 9 - èíôîðìàöèÿ î ïðîöåññå
  250. Dword kos_ProcessInfo( sProcessInfo *targetPtr, Dword processID = PROCESS_ID_SELF );
  251. // ôóíêöèÿ 10
  252. Dword kos_WaitForEvent();
  253. // ôóíêöèÿ 11
  254. Dword kos_CheckForEvent();
  255. // ôóíêöèÿ 12
  256. void kos_WindowRedrawStatus( Dword status );
  257. // ôóíêöèÿ 13 íàðèñîâàòü ïîëîñó
  258. void __declspec(noinline) kos_DrawBar( Word x, Word y, Word sizeX, Word sizeY, Dword colour );
  259. // ôóíêöèÿ 17
  260. bool kos_GetButtonID( Dword &buttonID );
  261. // ôóíêöèÿ 23
  262. Dword kos_WaitForEventTimeout( Dword timeOut );
  263. //
  264. enum eNumberBase
  265. {
  266.         nbDecimal = 0,
  267.         nbHex,
  268.         nbBin
  269. };
  270. // ïîëó÷åíèå èíôîðìàöèè î ñîñòîÿíèè "ìûøè" ôóíêöèÿ 37
  271. void kos_GetMouseState( Dword & buttons, int & cursorX, int & cursorY );
  272. // ôóíêöèÿ 40 óñòàíîâèòü ìàñêó ñîáûòèé
  273. void kos_SetMaskForEvents( Dword mask );
  274. // ôóíêöèÿ 47 âûâåñòè â îêíî ïðèëîæåíèÿ ÷èñëî
  275. void kos_DisplayNumberToWindow(
  276.    Dword value,
  277.    Dword digitsNum,
  278.    Word x,
  279.    Word y,
  280.    Dword colour,
  281.    eNumberBase nBase = nbDecimal,
  282.    bool valueIsPointer = false
  283.    );
  284. // ôóíêöèÿ 58 äîñòóï ê ôàéëîâîé ñèñòåìå
  285. Dword kos_FileSystemAccess( kosFileInfo *fileInfo );
  286. // ôóíêöèÿ 63
  287. void kos_DebugOutChar( char ccc );
  288. //
  289. void rtlDebugOutString( char *str );
  290. // ôóíêöèÿ 64 èçìåíèòü ïàðàìåòðû îêíà, ïàðàìåòð == -1 íå ìåíÿåòñÿ
  291. void kos_ChangeWindow( Dword x, Dword y, Dword sizeX, Dword sizeY );
  292. // ôóíêöèÿ 67 èçìåíåíèå êîëè÷åñòâà ïàìÿòè, âûäåëåííîé äëÿ ïðîãðàììû
  293. bool kos_ApplicationMemoryResize( Dword targetSize );
  294. // ôóíêöèÿ 66 ðåæèì ïîëó÷åíèÿ äàííûõ îò êëàâèàòóðû
  295. void kos_SetKeyboardDataMode( Dword mode );
  296.  
  297. void kos_InitHeap();
  298.  
  299. //
  300. void kos_Main();
  301.