Rev 8777 | Rev 9354 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8777 | Rev 8930 | ||
---|---|---|---|
1 | #include <_ansi.h> |
1 | #include <_ansi.h> |
2 | #include |
2 | #include |
3 | #include |
3 | #include |
4 | #include "io.h" |
4 | #include "io.h" |
5 | #include |
5 | #include |
6 | 6 | ||
7 | 7 | ||
8 | void load_libconsole(); |
8 | void load_libconsole(); |
9 | void __stdcall con_init(unsigned w_w, unsigned w_h, unsigned s_w, unsigned s_h, const char* t); |
9 | void __stdcall con_init(unsigned w_w, unsigned w_h, unsigned s_w, unsigned s_h, const char* t); |
10 | void __stdcall con_exit(char bCloseWindow); |
10 | void __stdcall con_exit(char bCloseWindow); |
11 | unsigned __stdcall con_get_flags(void); |
11 | unsigned __stdcall con_get_flags(void); |
12 | unsigned __stdcall con_set_flags(unsigned new_flags); |
12 | unsigned __stdcall con_set_flags(unsigned new_flags); |
13 | void __stdcall con_cls(void); |
13 | void __stdcall con_cls(void); |
14 | void __stdcall con_write_string(const char* string, unsigned length); |
14 | void __stdcall con_write_string(const char* string, unsigned length); |
15 | short __stdcall con_getch2(void); |
15 | short __stdcall con_getch2(void); |
16 | char* __stdcall con_gets(char*, unsigned); |
16 | char* __stdcall con_gets(char*, unsigned); |
17 | 17 | ||
18 | int __gui_mode; |
18 | int __gui_mode; |
- | 19 | ||
- | 20 | void con_init_opt(unsigned w_w, unsigned w_h, unsigned s_w, unsigned s_h, const char* t){ |
|
- | 21 | con_init(w_w, w_h, s_w, s_h, t); |
|
- | 22 | } |
|
19 | 23 | ||
20 | static int console_read(const char *path, void *buff, |
24 | static int console_read(const char *path, void *buff, |
21 | size_t offset, size_t count, size_t *done) |
25 | size_t offset, size_t count, size_t *done) |
22 | { |
26 | { |
23 | char *p = buff; |
27 | char *p = buff; |
24 | /*int cnt = 0; |
28 | /*int cnt = 0; |
25 | short c; |
29 | short c; |
26 | char ch;*/ |
30 | char ch;*/ |
27 | con_gets(p, count+1); |
31 | con_gets(p, count+1); |
28 | *done = strlen(p); |
32 | *done = strlen(p); |
29 | 33 | ||
30 | // __asm__ volatile("int3"); |
34 | // __asm__ volatile("int3"); |
31 | /* |
35 | /* |
32 | do |
36 | do |
33 | { |
37 | { |
34 | c = con_getch2(); |
38 | c = con_getch2(); |
35 | printf("%d\n",(char)c); |
39 | printf("%d\n",(char)c); |
36 | ch = (char)c; |
40 | ch = (char)c; |
37 | if(ch != 0) |
41 | if(ch != 0) |
38 | { |
42 | { |
39 | p[cnt] = ch != 0x0D ? ch : 0x0A; |
43 | p[cnt] = ch != 0x0D ? ch : 0x0A; |
40 | con_write_string(p+cnt, 1); |
44 | con_write_string(p+cnt, 1); |
41 | cnt++; |
45 | cnt++; |
42 | } |
46 | } |
43 | }while(ch != 0x0D); |
47 | }while(ch != 0x0D); |
44 | *done = cnt; |
48 | *done = cnt; |
45 | */ |
49 | */ |
46 | return 0; |
50 | return 0; |
47 | } |
51 | } |
48 | 52 | ||
49 | static int console_write(const char *path, const void *buff, |
53 | static int console_write(const char *path, const void *buff, |
50 | size_t offset, size_t count, size_t *writes) |
54 | size_t offset, size_t count, size_t *writes) |
51 | { |
55 | { |
52 | con_write_string(buff, count); |
56 | con_write_string(buff, count); |
53 | 57 | ||
54 | *writes = count; |
58 | *writes = count; |
55 | return 0; |
59 | return 0; |
56 | }; |
60 | }; |
57 | 61 | ||
58 | void __init_conio() |
62 | void __init_conio() |
59 | { |
63 | { |
60 | __io_handle *ioh; |
64 | __io_handle *ioh; |
61 | 65 | ||
62 | load_libconsole(); |
66 | load_libconsole(); |
63 | con_init(80, 25, 80, 500, "Console application"); |
67 | con_init(80, 25, 80, 500, "Console application"); |
64 | 68 | ||
65 | ioh = &__io_tab[STDIN_FILENO]; |
69 | ioh = &__io_tab[STDIN_FILENO]; |
66 | ioh->mode = _READ|_ISTTY; |
70 | ioh->mode = _READ|_ISTTY; |
67 | ioh->read = &console_read; |
71 | ioh->read = &console_read; |
68 | 72 | ||
69 | ioh = &__io_tab[STDOUT_FILENO]; |
73 | ioh = &__io_tab[STDOUT_FILENO]; |
70 | ioh->mode = _WRITE|_ISTTY; |
74 | ioh->mode = _WRITE|_ISTTY; |
71 | ioh->write = &console_write; |
75 | ioh->write = &console_write; |
72 | }; |
76 | }; |
73 | 77 | ||
74 | void __fini_conio() |
78 | void __fini_conio() |
75 | { |
79 | { |
76 | con_exit(0); |
80 | con_exit(0); |
77 | } |
81 | } |