This source file includes following definitions.
- ttyRead
- mytty_nextline
- mytty_putc
- ttyWrite
- replaceConsoleDriver
- h_ios_tty_Init
1 #include "lolevel.h"
2 #include "stdlib.h"
3 #include "script.h"
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 #if 0
40
41 extern void msleep(long);
42
43 typedef struct {
44 long dev_hdr[4];
45 long opened;
46 long fill[64];
47 } MY_DEV;
48
49 #define CONS_W (45)
50 #define CONS_H (128)
51
52 char console_buf[CONS_H][CONS_W];
53 long console_buf_line = 0;
54 long console_buf_line_ptr = 0;
55
56 char cmd[100] = "ShowCameraLog\n\0";
57 int cons_cmd_ptr = -1;
58
59 void mytty_putc(char c);
60
61 int ttyRead(MY_DEV* tty, char* buffer, int nBytes) {
62 int r = 1;
63
64 if (cons_cmd_ptr == -1) {
65 msleep(2000);
66 cons_cmd_ptr = 0;
67 }
68
69 mytty_putc('r');
70
71 if (cmd[cons_cmd_ptr] != 0) {
72 *buffer = cmd[cons_cmd_ptr];
73 cons_cmd_ptr++;
74 } else {
75 while (cons_cmd_ptr != 0) {
76 msleep(10);
77 }
78 *buffer = cmd[cons_cmd_ptr];
79 cons_cmd_ptr++;
80 }
81
82 return r;
83 }
84
85 void mytty_nextline() {
86 int i;
87
88 console_buf_line_ptr=0;
89 console_buf_line++;
90 if (console_buf_line>=CONS_H) {
91 console_buf_line = 0;
92 }
93 for (i=0;i<15;i++) {
94 int l=i+console_buf_line;
95 if (l>=CONS_H)
96 l-=CONS_H;
97 console_buf[l][0] = 0;
98 }
99 }
100
101 void mytty_putc(char c) {
102 if (c == 0xa) {
103 mytty_nextline();
104 } else {
105 if (console_buf_line_ptr>=(CONS_W-1)){
106 mytty_nextline();
107 }
108
109 console_buf[console_buf_line][console_buf_line_ptr++] = c;
110 console_buf[console_buf_line][console_buf_line_ptr] = 0;
111 }
112 }
113
114 int tyWrite = 0xFFB5EC84;
115
116
117 int ttyWrite(MY_DEV* tty, char* buffer, int nBytes) {
118 int i;
119
120 for (i=0;i<nBytes;i++){
121 mytty_putc(buffer[i]);
122 }
123
124 return ((int(*)(void *p, void *p2, int l))tyWrite)(tty, buffer, nBytes);
125
126 }
127
128
129
130
131
132
133
134 int *TTY_DRV_NUM = (int*)0x00011a44;
135
136
137 static void replaceConsoleDriver() {
138
139 int f0 = 0xffcdccd0;
140 int f1 = 0;
141 int f2 = 0xffcdccd0;
142 int f3 = 0xffcdcd10;
143 int f6 = 0xffcdcd54;
144 int fRead = (int)&ttyRead;
145 int fWrite = (int)&ttyWrite;
146 int newdriver_id = _iosDrvInstall((void*)f0, (void*)f1, (void*)f2, (void*)f3, (void*)fRead, (void*)fWrite, (void*)f6);
147
148 *TTY_DRV_NUM = newdriver_id;
149 }
150
151
152 void h_ios_tty_Init() {
153
154
155
156
157
158
159
160
161
162
163
164 _iosInit(0x14, 0x32, "/null");
165 replaceConsoleDriver();
166
167
168
169
170
171 }
172 #endif