Subversion Repositories Kolibri OS

Rev

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