Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
5496 leency 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 con_get_font_height)(void);
32
 int (* __stdcall con_set_cursor_height)(int new_height);
33
unsigned (*__stdcall con_get_flags)(void);
34
unsigned (*__stdcall con_set_flags)(unsigned new_flags);
35
void (*__stdcall con_cls)(void);
36
 
37
typedef struct
38
{
39
unsigned	p00 __attribute__((packed));
40
unsigned	p04 __attribute__((packed));
41
unsigned	p08 __attribute__((packed));
42
unsigned	p12 __attribute__((packed));
43
unsigned	p16 __attribute__((packed));
44
char		p20 __attribute__((packed));
45
char		*p21 __attribute__((packed));
46
} kol_struct70 __attribute__((packed));
47
 
48
typedef struct
49
{
50
char	*name __attribute__((packed));
51
void	*data __attribute__((packed));
52
} kol_struct_import __attribute__((packed));
53
 
54
///===========================
55
 
56
void kol_exit()
57
{
58
asm ("int $0x40"::"a"(-1));
59
}
60
 
61
int kol_file_70(kol_struct70 *k)
62
{
63
asm ("int $0x40"::"a"(70), "b"(k));
64
}
65
 
66
 
67
 
68
void* kol_cofflib_procload (kol_struct_import *imp, char *name)
69
{
70
int i;
71
for (i=0;;i++)
72
	if ( NULL == ((imp+i) -> name))
73
		break;
74
	else
75
		if ( 0 == strcmp(name, (imp+i)->name) )
76
			return (imp+i)->data;
77
return NULL;
78
}
79
 
80
 
81
 
82
 
83
void CONSOLE_INIT(char title[])
84
{
85
kol_struct_import *imp;
86
 
87
__menuet__debug_out ("console init");
88
imp = __kolibri__cofflib_load("/sys/lib/console.obj");
89
if (imp == NULL)
90
	{__menuet__debug_out ("imp NULL"); kol_exit();}
91
 
92
con_init = ( _stdcall  void (*)(unsigned, unsigned, unsigned, unsigned, const char*))
93
		kol_cofflib_procload (imp, "con_init");
94
if (con_init == NULL)
95
	{__menuet__debug_out ("con init failed"); kol_exit();}
96
 
97
printf = ( _cdecl void (*)(const char*,...))
98
		kol_cofflib_procload (imp, "con_printf");
99
if (printf == NULL)
100
	kol_exit();
101
 
102
_exit2 = ( _stdcall void (*)(char))
103
		kol_cofflib_procload (imp, "con_exit");
104
if (_exit2 == NULL)
105
	kol_exit();
106
 
107
gets = ( _stdcall void (*)(char*, int))
108
		kol_cofflib_procload (imp, "con_gets");
109
if (gets == NULL)
110
	kol_exit();
111
 
112
getch = ( _stdcall int (*)(void))
113
		kol_cofflib_procload (imp, "con_getch2");
114
if (getch == NULL)
115
	kol_exit();
116
 
117
con_get_font_height = ( _stdcall int (*)(void))
118
		kol_cofflib_procload (imp, "con_get_font_height");
119
if (con_get_font_height == NULL)
120
	kol_exit();
121
 
122
con_set_cursor_height = ( _stdcall int (*)(int))
123
		kol_cofflib_procload (imp, "con_set_cursor_height");
124
if (con_set_cursor_height == NULL)
125
	kol_exit();
126
 
127
con_get_flags = ( _stdcall unsigned (*)(void))
128
		kol_cofflib_procload (imp, "con_get_flags");
129
if (con_get_flags == NULL)
130
	kol_exit();
131
 
132
con_set_flags = ( _stdcall unsigned (*)(unsigned))
133
		kol_cofflib_procload (imp, "con_set_flags");
134
if (con_set_flags == NULL)
135
	kol_exit();
136
 
137
con_cls = ( _stdcall void (*)(void))
138
		kol_cofflib_procload (imp, "con_cls");
139
if (con_cls == NULL)
140
	kol_exit();
141
 
142
__menuet__debug_out ("success");
143
con_init(-1, -1, -1, -1, title);
144
}