Subversion Repositories Kolibri OS

Rev

Rev 1764 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
968 leency 1
typedef unsigned __int32 Dword;
2
typedef unsigned __int16 Word;
3
typedef unsigned __int8 Byte;
4
//typedef unsigned __int32 size_t;
5
 
6
#define NULL 0
7
 
8
#define MAX_PATH				256
9
 
10
#define FO_READ					0
11
#define FO_WRITE				2
12
 
13
#define EM_WINDOW_REDRAW		1
14
#define EM_KEY_PRESS			2
15
#define EM_BUTTON_CLICK			4
16
#define EM_APP_CLOSE			8
17
#define EM_DRAW_BACKGROUND		16
18
#define EM_MOUSE_EVENT			32
19
#define EM_IPC					64
20
#define EM_NETWORK				256
21
 
22
#define KM_CHARS				0
23
#define KM_SCANS				1
24
 
25
#define WRS_BEGIN				1
26
#define WRS_END					2
27
 
28
#define PROCESS_ID_SELF			-1
29
 
30
#define abs(a) (a<0?0-a:a)
31
 
32
extern "C" double acos(double x);
33
extern "C" double asin(double x);
34
extern "C" double floor(double x);
35
extern "C" double round(double x);
36
#pragma function(acos,asin)
37
#if _MSC_VER > 1200
38
#pragma function(floor)
39
#endif
40
 
41
 
42
struct kosFileInfo
43
{
44
	Dword rwMode;
45
	Dword OffsetLow;
46
	Dword OffsetHigh;
47
	Dword dataCount;
48
	Byte *bufferPtr;
49
	char fileURL[MAX_PATH];
50
};
51
 
52
 
53
struct RGB
54
{
55
	Byte b;
56
	Byte g;
57
	Byte r;
58
	//
59
	RGB() {};
60
	//
61
	RGB( Dword value )
62
	{
63
		r = (Byte)(value >> 16);
64
		g = (Byte)(value >> 8);
65
		b = (Byte)value;
66
	};
67
	//
68
	bool operator != ( RGB &another )
69
	{
70
		return this->b != another.b || this->g != another.g || this->r != another.r;
71
	};
72
	//
73
	bool operator == ( RGB &another )
74
	{
75
		return this->b == another.b && this->g == another.g && this->r == another.r;
76
	};
77
};
78
 
79
 
80
union sProcessInfo
81
{
82
	Byte rawData[1024];
83
	struct
84
	{
85
		Dword cpu_usage;
86
		Word window_stack_position;
87
		Word window_stack_value;
88
		Word reserved1;
89
		char process_name[12];
90
		Dword memory_start;
91
		Dword used_memory;
92
		Dword PID;
93
		Dword x_start;
94
		Dword y_start;
95
		Dword x_size;
96
		Dword y_size;
97
		Word slot_state;
98
	} processInfo;
99
};
100
 
101
//
1143 diamond 102
extern char kosExePath[];
968 leency 103
 
104
//
105
void crtStartUp();
106
//
107
int __cdecl _purecall();
108
//
109
int __cdecl atexit( void (__cdecl *func )( void ));
110
//
111
void rtlSrand( Dword seed );
112
Dword rtlRand( void );
113
//
114
char * __cdecl strcpy( char *target, const char *source );
115
int __cdecl strlen( const char *line );
116
char * __cdecl strrchr( const char * string, int c );
117
 
118
#if _MSC_VER < 1400
119
extern "C" void * __cdecl memcpy( void *dst, const void *src, size_t bytesCount );
120
extern "C" void memset( Byte *dst, Byte filler, Dword count );
121
#pragma intrinsic(memcpy,memset)
122
#else
123
void * __cdecl memcpy( void *dst, const void *src, size_t bytesCount );
124
void memset( Byte *dst, Byte filler, Dword count );
125
#endif
126
 
127
void sprintf( char *Str, char* Format, ... );
128
//
129
Dword rtlInterlockedExchange( Dword *target, Dword value );
130
// функция -1 завершения процесса
1143 diamond 131
void __declspec(noreturn) kos_ExitApp();
968 leency 132
// функция 0
1764 clevermous 133
void __declspec(noinline) kos_DefineAndDrawWindow(
968 leency 134
	Word x, Word y,
135
	Word sizeX, Word sizeY,
136
	Byte mainAreaType, Dword mainAreaColour,
137
	Byte headerType, Dword headerColour,
138
	Dword borderColour
139
	);
140
// функция 1 поставить точку
141
void kos_PutPixel( Dword x, Dword y, Dword colour );
142
// функция 2 получить код нажатой клавиши
143
bool kos_GetKey( Byte &keyCode );
144
// функция 3 получить время
1143 diamond 145
Dword __cdecl kos_GetSystemClock();
146
#if 0
968 leency 147
// функция 4
148
void kos_WriteTextToWindow(
149
	Word x, Word y,
150
	Byte fontType,
151
	Dword textColour,
152
	char *textPtr,
153
	Dword textLen
154
	);
1143 diamond 155
#else
156
void kos_WriteTextToWindow_internal(Dword pos, Dword font, const char* textPtr, Dword textLen);
157
#define kos_WriteTextToWindow(x, y, fontType, textColour, textPtr, textLen) \
158
	kos_WriteTextToWindow_internal(((x)<<16)|(y), ((fontType)<<24)|(textColour), textPtr, textLen)
159
#endif
968 leency 160
// функция 7 нарисовать изображение
1764 clevermous 161
void __declspec(noinline) kos_PutImage( RGB * imagePtr, Word sizeX, Word sizeY, Word x, Word y );
968 leency 162
// функция 8 определить кнопку
163
void kos_DefineButton( Word x, Word y, Word sizeX, Word sizeY, Dword buttonID, Dword colour );
164
// функция 5 пауза, в сотых долях секунды
1764 clevermous 165
void __declspec(noinline) __cdecl kos_Pause( Dword value );
968 leency 166
// функция 9 - информация о процессе
167
Dword kos_ProcessInfo( sProcessInfo *targetPtr, Dword processID = PROCESS_ID_SELF );
168
// функция 10
1143 diamond 169
Dword __cdecl kos_WaitForEvent();
968 leency 170
// функция 11
171
Dword kos_CheckForEvent();
172
// функция 12
1143 diamond 173
void __cdecl kos_WindowRedrawStatus( Dword status );
968 leency 174
// функция 13 нарисовать полосу
1764 clevermous 175
void __declspec(noinline) kos_DrawBar( Word x, Word y, Word sizeX, Word sizeY, Dword colour );
968 leency 176
// функция 17
177
bool kos_GetButtonID( Dword &buttonID );
178
// функция 23
1143 diamond 179
Dword __cdecl kos_WaitForEvent( Dword timeOut );
968 leency 180
//
181
enum eNumberBase
182
{
183
	nbDecimal = 0,
184
	nbHex,
185
	nbBin
186
};
187
// получение информации о состоянии "мыши" функция 37
188
void kos_GetMouseState( Dword & buttons, int & cursorX, int & cursorY );
189
// функция 40 установить маску событий
190
void kos_SetMaskForEvents( Dword mask );
191
// функция 47 вывести в окно приложения число
1764 clevermous 192
void __declspec(noinline) kos_DisplayNumberToWindow(
968 leency 193
   Dword value,
194
   Dword digitsNum,
195
   Word x,
196
   Word y,
197
   Dword colour,
198
   eNumberBase nBase = nbDecimal,
199
   bool valueIsPointer = false
200
   );
969 leency 201
// функция 48.4 получить высоту скина
3132 leency 202
Dword kos_GetSkinHeight();
968 leency 203
// функция 58 доступ к файловой системе
1143 diamond 204
Dword __fastcall kos_FileSystemAccess( kosFileInfo *fileInfo );
968 leency 205
// функция 63
1143 diamond 206
void __fastcall kos_DebugOutChar( char ccc );
968 leency 207
//
208
void rtlDebugOutString( char *str );
209
// функция 64 изменить параметры окна, параметр == -1 не меняется
210
void kos_ChangeWindow( Dword x, Dword y, Dword sizeX, Dword sizeY );
211
// функция 67 изменение количества памяти, выделенной для программы
212
bool kos_ApplicationMemoryResize( Dword targetSize );
213
// функция 66 режим получения данных от клавиатуры
214
void kos_SetKeyboardDataMode( Dword mode );
215
 
216
//
217
void kos_Main();