Subversion Repositories Kolibri OS

Rev

Rev 1145 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
852 diamond 1
 
2
3
 
4
DLL_EXIT  equ -1
5
REQ_DLL_VER equ 4
6
7
 
8
        db      'MENUET01'
9
        dd      1
10
        dd      start
11
        dd      i_end
12
        dd      mem
13
        dd      mem
14
        dd      0
15
        dd      0
16
17
 
18
        stdcall load_dll_and_import, dllname, imports
19
        test    eax, eax
20
        jz      exit
21
22
 
23
        cmp     word [dll_ver], REQ_DLL_VER
24
        jb      exit
25
        cmp     word [dll_ver+2], REQ_DLL_VER
26
        ja      exit
27
        push    DLL_ENTRY
28
        call    [dll_start]
29
30
 
31
32
 
33
        push    25
853 diamond 34
        push    80
35
        push    25
36
        push    80
37
        call    [con_init]
852 diamond 38
39
 
40
; for (;;)
41
; {
42
;   con_write_asciiz("Enter string (empty for exit): ");
43
;   if (!con_gets2(mycallback,s,256)) break;
1145 diamond 44
;   if (s[0] == '\n') break;
852 diamond 45
;   con_write_asciiz("You entered: ");
46
;   con_write_asciiz(s);
47
; }
48
mainloop:
49
        push    str1
50
        call    [con_write_asciiz]
51
        push    256
52
        push    s
53
        push    mycallback
54
        call    [con_gets2]
55
        test    eax, eax
1145 diamond 56
        jz      done
57
        cmp     [s], 10
852 diamond 58
        jz      done
59
        push    str2
60
        call    [con_write_asciiz]
61
        push    s
62
        call    [con_write_asciiz]
63
        jmp     mainloop
64
done:
65
        push    1
66
        call    [con_exit]
67
exit:
68
        or      eax, -1
69
        int     0x40
70
71
 
72
        mov     eax, [keycode]
73
        cmp     al, 0x0F
74
        jz      .tab
75
        cmp     al, 0x3B
76
        jz      .f1
77
        cmp     al, 0x48
78
        jz      .up
79
        cmp     al, 0x50
80
        jz      .down
81
        xor     eax, eax
82
        ret
83
.tab:
84
; Tab pressed - insert "[autocomplete]" to current position
85
        push    esi edi
86
        mov     eax, [ppos]
87
        mov     eax, [eax]
88
        mov     ecx, [pn]
89
        mov     ecx, [ecx]
90
        mov     esi, [pstr]
91
        mov     esi, [esi]
92
        add     ecx, esi
93
        add     esi, eax
94
        mov     edx, esi
95
@@:
96
        lodsb
97
        test    al, al
98
        jnz     @b
99
        lea     edi, [esi+str3.len]
100
        cmp     edi, ecx
101
        jbe     @f
102
        mov     edi, ecx
103
        lea     esi, [edi-str3.len]
104
@@:
105
        cmp     esi, edx
106
        jbe     @f
107
        dec     esi
108
        dec     edi
109
        mov     al, [esi]
110
        mov     [edi], al
111
        jmp     @b
112
@@:
113
        cmp     edi, ecx
114
        jb      @f
115
        dec     edi
116
@@:
117
        mov     ecx, edi
118
        sub     ecx, edx
119
        mov     edi, edx
120
        mov     esi, str3
121
        rep     movsb
122
        mov     eax, [pstr]
123
        sub     edi, [eax]
124
        mov     eax, [ppos]
125
        mov     [eax], edi
126
        pop     edi esi
127
        xor     eax, eax
128
        inc     eax
129
        ret
130
.f1:
131
; F1 pressed - say message
132
        push    str4
133
        call    [con_write_asciiz]
134
        push    str1
135
        call    [con_write_asciiz]
136
        push    2
137
        pop     eax
138
        ret
139
.up:
140
        push    esi
141
        mov     esi, str5
142
        mov     ecx, str5.len
143
        jmp     @f
144
.down:
145
        push    esi
146
        mov     esi, str6
147
        mov     ecx, str6.len
148
@@:
149
        push    edi
150
        mov     edi, [pstr]
151
        mov     edi, [edi]
152
        mov     eax, [ppos]
153
        mov     [eax], ecx
154
        rep     movsb
155
        xor     eax, eax
156
        stosb
157
        pop     edi esi
158
        inc     eax
159
        ret
160
endp
161
162
 
163
        pushad
164
; load DLL
165
        push    68
166
        pop     eax
167
        push    19
168
        pop     ebx
169
        mov     ecx, [_dllname]
170
        int     0x40
171
        test    eax, eax
172
        jz      import_fail
173
174
 
175
        mov     edi, eax
176
        mov     esi, [_imports]
177
import_loop:
178
        lodsd
179
        test    eax, eax
180
        jz      import_done
181
        mov     edx, edi
182
import_find:
183
        mov     ebx, [edx]
184
        test    ebx, ebx
185
        jz      import_not_found
186
        push    eax
187
@@:
188
        mov     cl, [eax]
189
        cmp     cl, [ebx]
190
        jnz     import_find_next
191
        test    cl, cl
192
        jz      import_found
193
        inc     eax
194
        inc     ebx
195
        jmp     @b
196
import_find_next:
197
        pop     eax
198
        add     edx, 8
199
        jmp     import_find
200
import_found:
201
        pop     eax
202
        mov     eax, [edx+4]
203
        mov     [esi-4], eax
204
        jmp     import_loop
205
import_not_found:
206
import_fail:
207
        popad
208
        xor     eax, eax
209
        ret
210
import_done:
211
        popad
212
        xor     eax, eax
213
        inc     eax
214
        ret
215
endp
216
217
 
218
219
 
220
dll_start          dd szStart
221
dll_ver            dd szVersion
222
con_init           dd szcon_init
223
con_write_asciiz   dd szcon_write_asciiz
224
con_exit           dd szcon_exit
225
con_gets2          dd szcon_gets2
226
                   dd 0
227
228
 
229
szVersion          db 'version',0
230
szcon_init         db 'con_init',0
231
szcon_write_asciiz db 'con_write_asciiz',0
232
szcon_exit         db 'con_exit',0
233
szcon_gets2        db 'con_gets2',0
234
235
 
236
237
 
238
str1               db 'Enter string (empty for exit): ',0
239
str2               db 'You entered: ',0
240
str3               db '[autocomplete]'
241
str3.len = $ - str3
242
str4               db 13,10,'Help? What help do you need?',13,10,0
243
str5               db 'previous line in the history'
244
str5.len = $ - str5
245
str6               db 'next line in the history'
246
str6.len = $ - str6
247
248
 
249
250
 
251
252
 
253
rb 2048 ; stack
254
mem:
255