Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
5203 clevermous 1
#include
2
 
3
 
4
///===========================
5
 
6
#define CON_COLOR_BLUE		1
7
#define CON_COLOR_GREEN		2
8
#define CON_COLOR_RED		4
9
#define CON_COLOR_BRIGHT	8
10
/* цвет фона */
11
#define CON_BGR_BLUE		0x10
12
#define CON_BGR_GREEN		0x20
13
#define CON_BGR_RED		0x40
14
#define CON_BGR_BRIGHT		0x80
15
 
16
///===========================
17
#define _stdcall __attribute__((stdcall))
18
#define __stdcall __attribute__((stdcall))
19
#define _cdecl __attribute__((cdecl))
20
#define __cdecl __attribute__((cdecl))
21
 
22
 
23
 
24
 
25
 
26
void (* _stdcall con_init)(unsigned w_w, unsigned w_h, unsigned s_w, unsigned s_h, const char* t);
27
void (* _cdecl printf)(const char* format,...);
28
void (* _stdcall _exit2)(char bCloseWindow);
29
void (* __stdcall gets)(char* str, int n);
30
 int (* __stdcall getch)(void);
31
 int (* __stdcall kbhit)(void);
32
 int (* __stdcall con_get_font_height)(void);
33
 int (* __stdcall con_set_cursor_height)(int new_height);
34
unsigned (*__stdcall con_get_flags)(void);
35
unsigned (*__stdcall con_set_flags)(unsigned new_flags);
36
void (*__stdcall con_cls)(void);
37
 
38
typedef struct
39
{
40
unsigned	p00 __attribute__((packed));
41
unsigned	p04 __attribute__((packed));
42
unsigned	p08 __attribute__((packed));
43
unsigned	p12 __attribute__((packed));
44
unsigned	p16 __attribute__((packed));
45
char		p20 __attribute__((packed));
46
char		*p21 __attribute__((packed));
47
} kol_struct70 __attribute__((packed));
48
 
49
typedef struct
50
{
51
char	*name __attribute__((packed));
52
void	*data __attribute__((packed));
53
} kol_struct_import __attribute__((packed));
54
 
55
///===========================
56
 
57
void kol_exit()
58
{
59
__asm ("int $0x40"::"a"(-1));
60
}
61
 
62
int kol_file_70(kol_struct70 *k)
63
{
64
__asm ("int $0x40"::"a"(70), "b"(k));
65
}
66
 
67
 
68
 
69
void* kol_cofflib_procload (kol_struct_import *imp, char *name)
70
{
71
int i;
72
for (i=0;;i++)
73
	if ( NULL == ((imp+i) -> name))
74
		break;
75
	else
76
		if ( 0 == strcmp(name, (imp+i)->name) )
77
			return (imp+i)->data;
78
return NULL;
79
}
80
 
81
 
82
 
83
 
84
void CONSOLE_INIT(char title[])
85
{
86
kol_struct_import *imp;
87
 
88
__menuet__debug_out ("console init");
89
imp = __kolibri__cofflib_load("/sys/lib/console.obj");
90
if (imp == NULL)
91
	{__menuet__debug_out ("imp NULL"); kol_exit();}
92
 
93
con_init = ( _stdcall  void (*)(unsigned, unsigned, unsigned, unsigned, const char*))
94
		kol_cofflib_procload (imp, "con_init");
95
if (con_init == NULL)
96
	{__menuet__debug_out ("con init failed"); kol_exit();}
97
 
98
printf = ( _cdecl void (*)(const char*,...))
99
		kol_cofflib_procload (imp, "con_printf");
100
if (printf == NULL)
101
	kol_exit();
102
 
103
_exit2 = ( _stdcall void (*)(char))
104
		kol_cofflib_procload (imp, "con_exit");
105
if (_exit2 == NULL)
106
	kol_exit();
107
 
108
gets = ( _stdcall void (*)(char*, int))
109
		kol_cofflib_procload (imp, "con_gets");
110
if (gets == NULL)
111
	kol_exit();
112
 
113
getch = ( _stdcall int (*)(void))
114
		kol_cofflib_procload (imp, "con_getch2");
115
if (getch == NULL)
116
	kol_exit();
117
 
118
kbhit = ( _stdcall int (*)(void))
119
		kol_cofflib_procload (imp, "con_kbhit");
120
if (getch == NULL)
121
	kol_exit();
122
 
123
con_get_font_height = ( _stdcall int (*)(void))
124
		kol_cofflib_procload (imp, "con_get_font_height");
125
if (con_get_font_height == NULL)
126
	kol_exit();
127
 
128
con_set_cursor_height = ( _stdcall int (*)(int))
129
		kol_cofflib_procload (imp, "con_set_cursor_height");
130
if (con_set_cursor_height == NULL)
131
	kol_exit();
132
 
133
con_get_flags = ( _stdcall unsigned (*)(void))
134
		kol_cofflib_procload (imp, "con_get_flags");
135
if (con_get_flags == NULL)
136
	kol_exit();
137
 
138
con_set_flags = ( _stdcall unsigned (*)(unsigned))
139
		kol_cofflib_procload (imp, "con_set_flags");
140
if (con_set_flags == NULL)
141
	kol_exit();
142
 
143
con_cls = ( _stdcall void (*)(void))
144
		kol_cofflib_procload (imp, "con_cls");
145
if (con_cls == NULL)
146
	kol_exit();
147
 
148
__menuet__debug_out ("success");
149
con_init(-1, -1, -1, -1, title);
150
}