Rev 6429 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6429 | siemargl | 1 | #include |
2 | #include |
||
3 | |||
4 | char* con_caption = "Console app"; |
||
5 | extern int __argc; |
||
6 | extern char** __argv; |
||
7 | extern char* __path; |
||
8 | dword *con_dll_ver; |
||
9 | int __console_initdll_status; |
||
10 | |||
11 | char* con_dllname="/sys/lib/console.obj"; |
||
12 | |||
13 | struct import{ |
||
14 | char *name; |
||
15 | void *data; |
||
16 | }; |
||
17 | |||
18 | void stdcall (*con_init)(dword wnd_width, dword wnd_height, |
||
19 | dword scr_width, dword scr_height, const char* title); |
||
20 | void stdcall (*con_exit)(int bCloseWindow); |
||
21 | void stdcall (*con_set_title)(const char* title); |
||
22 | void stdcall (*con_write_asciiz)(const char* str); |
||
23 | void stdcall (*con_write_string)(const char* str, dword length); |
||
24 | int cdecl (*con_printf)(const char* format, ...); |
||
25 | dword stdcall (*con_get_flags)(void); |
||
26 | dword stdcall (*con_set_flags)(dword new_flags); |
||
27 | int stdcall (*con_get_font_height)(void); |
||
28 | int stdcall (*con_get_cursor_height)(void); |
||
29 | int stdcall (*con_set_cursor_height)(int new_height); |
||
30 | int stdcall (*con_getch)(void); |
||
31 | word stdcall (*con_getch2)(void); |
||
32 | int stdcall (*con_kbhit)(void); |
||
33 | char* stdcall (*con_gets)(char* str, int n); |
||
34 | char* stdcall (*con_gets2)(con_gets2_callback callback, char* str, int n); |
||
35 | void stdcall (*con_cls)(); |
||
36 | void stdcall (*con_get_cursor_pos)(int* px, int* py); |
||
37 | void stdcall (*con_set_cursor_pos)(int x, int y); |
||
38 | |||
39 | |||
40 | // don't change order in this! linked by index |
||
41 | char* con_imports[] = { |
||
42 | "START", "version", "con_init", "con_write_asciiz", "con_write_string", |
||
43 | "con_printf", "con_exit", "con_get_flags", "con_set_flags", "con_kbhit", |
||
44 | "con_getch", "con_getch2", "con_gets", "con_gets2", "con_get_font_height", |
||
45 | "con_get_cursor_height", "con_set_cursor_height", "con_cls", |
||
7172 | siemargl | 46 | "con_get_cursor_pos", "con_set_cursor_pos", "con_set_title", |
6429 | siemargl | 47 | (char*)0 |
48 | }; |
||
49 | |||
50 | void con_lib_link(struct import *exp, char** imports){ |
||
51 | |||
52 | con_dll_ver = _ksys_cofflib_getproc(exp, imports[1]); |
||
53 | con_init = _ksys_cofflib_getproc(exp, imports[2]); |
||
54 | con_write_asciiz = _ksys_cofflib_getproc(exp, imports[3]); |
||
55 | con_write_string = _ksys_cofflib_getproc(exp, imports[4]); |
||
56 | con_printf = _ksys_cofflib_getproc(exp, imports[5]); |
||
57 | con_exit = _ksys_cofflib_getproc(exp, imports[6]); |
||
58 | con_get_flags = _ksys_cofflib_getproc(exp, imports[7]); |
||
59 | con_set_flags = _ksys_cofflib_getproc(exp, imports[8]); |
||
60 | con_kbhit = _ksys_cofflib_getproc(exp, imports[9]); |
||
61 | con_getch = _ksys_cofflib_getproc(exp, imports[10]); |
||
62 | con_getch2 = _ksys_cofflib_getproc(exp, imports[11]); |
||
63 | con_gets = _ksys_cofflib_getproc(exp, imports[12]); |
||
64 | con_gets2 = _ksys_cofflib_getproc(exp, imports[13]); |
||
65 | con_get_font_height = _ksys_cofflib_getproc(exp, imports[14]); |
||
66 | con_get_cursor_height=_ksys_cofflib_getproc(exp, imports[15]); |
||
67 | con_set_cursor_height=_ksys_cofflib_getproc(exp, imports[16]); |
||
68 | con_cls = _ksys_cofflib_getproc(exp, imports[17]); |
||
69 | con_get_cursor_pos = _ksys_cofflib_getproc(exp, imports[18]); |
||
7172 | siemargl | 70 | con_set_cursor_pos = _ksys_cofflib_getproc(exp, imports[19]); |
71 | con_set_title = _ksys_cofflib_getproc(exp, imports[20]); |
||
6429 | siemargl | 72 | } |
73 | |||
74 | |||
75 | int con_init_console_dll(void) |
||
76 | { |
||
77 | struct import * hDll; |
||
78 | |||
79 | if (__console_initdll_status == 1) return 0; |
||
80 | |||
81 | if((hDll = (struct import *)_ksys_cofflib_load(con_dllname)) == 0){ |
||
82 | debug_out_str("can't load lib\n"); |
||
83 | return 1; |
||
84 | } |
||
85 | con_lib_link(hDll, con_imports); |
||
86 | |||
87 | con_init(-1, -1, -1, -1, con_caption); //__argv[0] && __path dont work |
||
88 | |||
89 | __console_initdll_status = 1; |
||
90 | |||
91 | return(0); |
||
92 | } |
||
93 |