Rev 7873 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
7873 | rgimad | 1 | |
2 | //extern int __argc; |
||
3 | //extern char** __argv; |
||
4 | //extern char* __path; |
||
5 | uint32_t *con_dll_ver; |
||
6 | int __console_initdll_status = 0; |
||
7 | |||
8 | |||
9 | |||
10 | |||
11 | |||
12 | |||
13 | |||
14 | void stdcall (*con_exit)(int bCloseWindow) = 0; |
||
15 | void stdcall (*con_set_title)(const char* title) = 0; |
||
16 | void stdcall (*con_write_asciiz)(const char* str) = 0; |
||
17 | void stdcall (*con_write_string)(const char* str, uint32_t length) = 0; |
||
18 | int cdecl (*con_printf)(const char* format, ...) = 0; |
||
19 | uint32_t stdcall (*con_get_flags)(void) = 0; |
||
20 | uint32_t stdcall (*con_set_flags)(uint32_t new_flags) = 0; |
||
21 | int stdcall (*con_get_font_height)(void) = 0; |
||
22 | int stdcall (*con_get_cursor_height)(void) = 0; |
||
23 | int stdcall (*con_set_cursor_height)(int new_height) = 0; |
||
24 | int stdcall (*con_getch)(void) = 0; |
||
25 | uint16_t stdcall (*con_getch2)(void) = 0; |
||
26 | int stdcall (*con_kbhit)(void) = 0; |
||
27 | char* stdcall (*con_gets)(char* str, int n) = 0; |
||
28 | char* stdcall (*con_gets2)(con_gets2_callback callback, char* str, int n) = 0; |
||
29 | void stdcall (*con_cls)() = 0; |
||
30 | void stdcall (*con_get_cursor_pos)(int* px, int* py) = 0; |
||
31 | void stdcall (*con_set_cursor_pos)(int x, int y) = 0; |
||
32 | |||
33 | |||
34 | |||
35 | |||
36 | void *exports; |
||
37 | asm volatile ("int $0x40":"=a"(exports):"a"(68), "b"(19), "c"(name)); |
||
38 | return exports; |
||
39 | } |
||
40 | |||
41 | |||
42 | { |
||
43 | if (exports == NULL) { return 0; } |
||
44 | while (*(uint32_t*)exports != 0) |
||
7894 | rgimad | 45 | { |
7873 | rgimad | 46 | char *str1 = (char*)(*(uint32_t*)exports); |
47 | if (strcmp(str1, name) == 0) |
||
48 | { |
||
49 | void *ptr = (void*)*(uint32_t*)(exports + 4); |
||
7894 | rgimad | 50 | |
7873 | rgimad | 51 | |
52 | /*debug_board_write_string(name); |
||
53 | char otv[16]; |
||
54 | itoa(ptr, otv); |
||
55 | debug_board_write_string(otv); |
||
56 | debug_board_write_byte('\n');*/ |
||
57 | |||
58 | |||
59 | } |
||
60 | exports += 8; |
||
61 | } |
||
62 | return 0; |
||
63 | } |
||
64 | |||
65 | |||
66 | |||
67 | char* con_imports[] = { |
||
68 | "START", "version", "con_init", "con_write_asciiz", "con_write_string", |
||
69 | "con_printf", "con_exit", "con_get_flags", "con_set_flags", "con_kbhit", |
||
70 | "con_getch", "con_getch2", "con_gets", "con_gets2", "con_get_font_height", |
||
71 | "con_get_cursor_height", "con_set_cursor_height", "con_cls", |
||
72 | "con_get_cursor_pos", "con_set_cursor_pos", "con_set_title", |
||
73 | (char*)0 |
||
74 | }; |
||
75 | |||
76 | |||
77 | { |
||
78 | con_dll_ver = getprocaddress(exp, imports[1]); |
||
79 | con_init = getprocaddress(exp, imports[2]); |
||
80 | con_write_asciiz = getprocaddress(exp, imports[3]); |
||
81 | con_write_string = getprocaddress(exp, imports[4]); |
||
82 | con_printf = getprocaddress(exp, imports[5]); |
||
83 | con_exit = getprocaddress(exp, imports[6]); |
||
84 | con_get_flags = getprocaddress(exp, imports[7]); |
||
85 | con_set_flags = getprocaddress(exp, imports[8]); |
||
86 | con_kbhit = getprocaddress(exp, imports[9]); |
||
87 | con_getch = getprocaddress(exp, imports[10]); |
||
88 | con_getch2 = getprocaddress(exp, imports[11]); |
||
89 | con_gets = getprocaddress(exp, imports[12]); |
||
90 | con_gets2 = getprocaddress(exp, imports[13]); |
||
91 | con_get_font_height = getprocaddress(exp, imports[14]); |
||
92 | con_get_cursor_height = getprocaddress(exp, imports[15]); |
||
93 | con_set_cursor_height = getprocaddress(exp, imports[16]); |
||
94 | con_cls = getprocaddress(exp, imports[17]); |
||
95 | con_get_cursor_pos = getprocaddress(exp, imports[18]); |
||
96 | con_set_cursor_pos = getprocaddress(exp, imports[19]); |
||
97 | con_set_title = getprocaddress(exp, imports[20]); |
||
98 | } |
||
99 | |||
100 | |||
101 | |||
102 | /*works as con_init_console_dll, but call con_init with params*/ |
||
103 | { |
||
104 | void *hDll; |
||
105 | if (__console_initdll_status == 1) return 0; |
||
106 | if((hDll = load_library(con_dllname)) == 0) |
||
107 | { |
||
108 | debug_out_str("can't load lib\n"); |
||
109 | return 1; |
||
110 | } |
||
111 | //debug_board_write_byte('I'); |
||
112 | con_lib_link(hDll, con_imports); |
||
113 | /*if (con_dll_ver != (uint32_t*)0x00020008) |
||
114 | { |
||
115 | //debug_board_write_byte(48 + sizeof(KosExp)); |
||
116 | //char otv[16]; |
||
117 | //itoa(con_init, otv); |
||
118 | //debug_board_write_string(otv); |
||
119 | |||
120 | |||
121 | char otv[16]; |
||
122 | itoa(con_dll_ver, otv); |
||
123 | debug_board_write_string(otv); |
||
124 | debug_board_write_byte('\n'); |
||
125 | |||
126 | |||
127 | //char otv[16]; |
||
128 | itoa(con_init, otv); |
||
129 | debug_board_write_string(otv); |
||
130 | debug_board_write_byte('\n'); |
||
131 | |||
132 | |||
133 | }*/ |
||
134 | con_init(wnd_width, wnd_height, scr_width, scr_height, title); |
||
135 | __console_initdll_status = 1; |
||
136 | return 0; |
||
137 | } |
||
138 | |||
139 | |||
140 | |||
141 | { |
||
142 | return con_init_console_dll_param(-1, -1, -1, -1, con_caption); |
||
143 | } |
||
144 | |||
145 | |||
146 | |||
147 | |||
148 | |||
7894 | rgimad | 149 | { |
7873 | rgimad | 150 | con_init_console_dll(); |
151 | return con_getch(); |
||
152 | } |
||
153 | |||
154 | |||
7894 | rgimad | 155 | { |
7873 | rgimad | 156 | con_init_console_dll(); |
157 | return con_kbhit(); |
||
158 | } |
||
159 |