Subversion Repositories Kolibri OS

Rev

Rev 997 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 997 Rev 1122
1
virtual at 0
1
virtual at 0
2
viewer_data:
2
viewer_data:
3
        .hPlugin        dd      ?
3
        .hPlugin        dd      ?
4
        .hFile          dd      ?
4
        .hFile          dd      ?
5
        .buf_start      dq      ?
5
        .buf_start      dq      ?
6
        .cur_pos        dq      ?
6
        .cur_pos        dq      ?
7
        .filesize       dq      ?
7
        .filesize       dq      ?
8
        .buf_pos        dd      ?
8
        .buf_pos        dd      ?
9
        .buf_size       dd      ?
9
        .buf_size       dd      ?
10
        .col            dq      ?
10
        .col            dq      ?
11
        .hWorkFile      dd      ?
11
        .hWorkFile      dd      ?
12
        .encoding       db      ?
12
        .encoding       db      ?
13
        .flags          db      ?       ; & 1: hex mode
13
        .flags          db      ?       ; & 1: hex mode
14
                                        ; & 2: unwrap
14
                                        ; & 2: unwrap
15
                                        ; & 4: big-endian unicode
15
                                        ; & 4: big-endian unicode
16
        .bEofReached    db      ?
16
        .bEofReached    db      ?
17
                        rb      1
17
                        rb      1
18
        .selected_start dq      ?
18
        .selected_start dq      ?
19
        .selected_len   dq      ?
19
        .selected_len   dq      ?
20
        align 200h
20
        align 200h
21
        .filename       rb      1024
21
        .filename       rb      1024
22
        .hostname       rb      1024
22
        .hostname       rb      1024
23
        .buf            rb      16384
23
        .buf            rb      16384
24
        .size = $
24
        .size = $
25
end virtual
25
end virtual
26
 
26
 
27
view_file:
27
view_file:
28
        push    eax ecx
28
        push    eax ecx
29
        mov     ecx, viewer_data.size
29
        mov     ecx, viewer_data.size
30
        mov     edx, viewer_vtable
30
        mov     edx, viewer_vtable
31
        call    new_screen
31
        call    new_screen
32
        pop     ecx
32
        pop     ecx
33
        test    eax, eax
33
        test    eax, eax
34
        pop     eax
34
        pop     eax
35
        jnz     @f
35
        jnz     @f
36
        ret
36
        ret
37
@@:
37
@@:
38
        test    eax, eax
38
        test    eax, eax
39
        jz      .frompanel
39
        jz      .frompanel
40
        and     dword [ebp+viewer_data.hPlugin], 0
40
        and     dword [ebp+viewer_data.hPlugin], 0
41
        and     dword [ebp+viewer_data.hFile], 0
41
        and     dword [ebp+viewer_data.hFile], 0
42
        mov     byte [ebp+viewer_data.hostname], 0
42
        mov     byte [ebp+viewer_data.hostname], 0
43
        lea     edi, [ebp+viewer_data.filename]
43
        lea     edi, [ebp+viewer_data.filename]
44
        push    edi
44
        push    edi
45
@@:
45
@@:
46
        lodsb
46
        lodsb
47
        stosb
47
        stosb
48
        test    al, al
48
        test    al, al
49
        jnz     @b
49
        jnz     @b
50
        jmp     .namecopied
50
        jmp     .namecopied
51
.frompanel:
51
.frompanel:
52
        mov     eax, dword [esi+panel1_hPlugin-panel1_dir]
52
        mov     eax, dword [esi+panel1_hPlugin-panel1_dir]
53
        mov     [ebp+viewer_data.hPlugin], eax
53
        mov     [ebp+viewer_data.hPlugin], eax
54
        test    eax, eax
54
        test    eax, eax
55
        jz      .nocopyhostname
55
        jz      .nocopyhostname
56
        lea     edi, [ebp+viewer_data.hostname]
56
        lea     edi, [ebp+viewer_data.hostname]
57
        push    esi
57
        push    esi
58
        mov     eax, dword [esi+panel1_parents-panel1_dir]
58
        mov     eax, dword [esi+panel1_parents-panel1_dir]
59
        mov     esi, dword [esi+panel1_parents_sz-panel1_dir]
59
        mov     esi, dword [esi+panel1_parents_sz-panel1_dir]
60
        add     esi, eax
60
        add     esi, eax
61
@@:
61
@@:
62
        dec     esi
62
        dec     esi
63
        cmp     byte [esi-1], 0
63
        cmp     byte [esi-1], 0
64
        jz      @f
64
        jz      @f
65
        cmp     byte [esi-1], '/'
65
        cmp     byte [esi-1], '/'
66
        jnz     @b
66
        jnz     @b
67
@@:
67
@@:
68
        lodsb
68
        lodsb
69
        stosb
69
        stosb
70
        test    al, al
70
        test    al, al
71
        jnz     @b
71
        jnz     @b
72
        pop     esi
72
        pop     esi
73
.nocopyhostname:
73
.nocopyhostname:
74
        mov     eax, dword [esi+panel1_hFile-panel1_dir]
74
        mov     eax, dword [esi+panel1_hFile-panel1_dir]
75
        mov     [ebp+viewer_data.hFile], eax
75
        mov     [ebp+viewer_data.hFile], eax
76
        lea     edi, [ebp+viewer_data.filename]
76
        lea     edi, [ebp+viewer_data.filename]
77
        push    edi
77
        push    edi
78
@@:
78
@@:
79
        lodsb
79
        lodsb
80
        test    al, al
80
        test    al, al
81
        jz      @f
81
        jz      @f
82
        stosb
82
        stosb
83
        jmp     @b
83
        jmp     @b
84
@@:
84
@@:
85
        lea     esi, [ecx+40]
85
        lea     esi, [ecx+40]
86
        cmp     byte [edi-1], '/'
86
        cmp     byte [edi-1], '/'
87
        jz      @f
87
        jz      @f
88
        mov     al, '/'
88
        mov     al, '/'
89
        stosb
89
        stosb
90
@@:
90
@@:
91
        lodsb
91
        lodsb
92
        stosb
92
        stosb
93
        test    al, al
93
        test    al, al
94
        jnz     @b
94
        jnz     @b
95
.namecopied:
95
.namecopied:
96
        xor     eax, eax
96
        xor     eax, eax
97
        mov     [ebp+viewer_data.encoding], al ;encodings.cp866 = 0
97
        mov     [ebp+viewer_data.encoding], al ;encodings.cp866 = 0
98
        mov     [ebp+viewer_data.flags], al
98
        mov     [ebp+viewer_data.flags], al
99
        mov     dword [ebp+viewer_data.col], eax
99
        mov     dword [ebp+viewer_data.col], eax
100
        mov     dword [ebp+viewer_data.col+4], eax
100
        mov     dword [ebp+viewer_data.col+4], eax
101
        call    viewer_clear_selection
101
        call    viewer_clear_selection
102
        pop     eax
102
        pop     eax
103
        push    eax
-
 
104
        mov     ebx, attrinfo
103
        mov     ebx, attrinfo
105
        mov     [ebx+21], eax
104
        mov     [ebx+21], eax
-
 
105
        mov     [readinfo.name], eax
106
.attr_retry:
106
.attr_retry:
107
        mov     edx, [ebp+viewer_data.hPlugin]
107
        mov     edx, [ebp+viewer_data.hPlugin]
108
        test    edx, edx
108
        test    edx, edx
109
        jz      .attr_native
109
        jz      .attr_native
110
        push    ebp
110
        push    ebp
111
        push    dword [ebx+16]
111
        push    dword [ebx+16]
112
        push    eax
112
        push    eax
113
        push    [ebp+viewer_data.hFile]
113
        push    [ebp+viewer_data.hFile]
114
        call    [edx+PluginInfo.getattr]
114
        call    [edx+PluginInfo.getattr]
115
        pop     ebp
115
        pop     ebp
116
        jmp     .attr_common
116
        jmp     .attr_common
117
.attr_native:
117
.attr_native:
118
        push    70
118
        push    70
119
        pop     eax
119
        pop     eax
120
        int     40h
120
        int     40h
121
.attr_common:
121
.attr_common:
122
        test    eax, eax
122
        test    eax, eax
123
        jz      @f
123
        jz      @f
124
        lea     ebx, [ebp+viewer_data.filename]
124
        lea     ebx, [ebp+viewer_data.filename]
125
        push    ebx
125
        push    ebx
126
        push    aCannotReadFile
126
        push    aCannotReadFile
127
        call    get_error_msg
127
        call    get_error_msg
128
        push    eax
128
        push    eax
129
        mov     eax, esp
129
        mov     eax, esp
130
        push    RetryOrCancelBtn
130
        push    RetryOrCancelBtn
131
        push    2
131
        push    2
132
        push    eax
132
        push    eax
133
        push    3
133
        push    3
134
        call    SayErr
134
        call    SayErr
135
        add     esp, 3*4
135
        add     esp, 3*4
136
        mov     ebx, attrinfo
136
        mov     ebx, attrinfo
137
        test    eax, eax
137
        test    eax, eax
138
        jz      .attr_retry
138
        jz      .attr_retry
139
        pop     eax
139
        pop     eax
140
        jmp     delete_active_screen
140
        jmp     delete_active_screen
141
@@:
141
@@:
142
        mov     eax, dword [attrinfo.attr+32]
142
        mov     eax, dword [attrinfo.attr+32]
143
        mov     dword [ebp+viewer_data.filesize], eax
143
        mov     dword [ebp+viewer_data.filesize], eax
144
        mov     eax, dword [attrinfo.attr+36]
144
        mov     eax, dword [attrinfo.attr+36]
145
        mov     dword [ebp+viewer_data.filesize+4], eax
145
        mov     dword [ebp+viewer_data.filesize+4], eax
146
        mov     ebx, readinfo
146
        mov     ebx, readinfo
147
        xor     eax, eax
147
        xor     eax, eax
148
        mov     dword [ebx+readinfo.first-readinfo], eax
148
        mov     dword [ebx+readinfo.first-readinfo], eax
149
        mov     dword [ebx+readinfo.first+4-readinfo], eax
149
        mov     dword [ebx+readinfo.first+4-readinfo], eax
150
        mov     dword [ebp+viewer_data.buf_start], eax
150
        mov     dword [ebp+viewer_data.buf_start], eax
151
        mov     dword [ebp+viewer_data.buf_start+4], eax
151
        mov     dword [ebp+viewer_data.buf_start+4], eax
152
        mov     dword [ebp+viewer_data.cur_pos], eax
152
        mov     dword [ebp+viewer_data.cur_pos], eax
153
        mov     dword [ebp+viewer_data.cur_pos+4], eax
153
        mov     dword [ebp+viewer_data.cur_pos+4], eax
154
        mov     [ebx+readinfo.size-readinfo], 16384
154
        mov     [ebx+readinfo.size-readinfo], 16384
155
        lea     eax, [ebp+viewer_data.buf]
155
        lea     eax, [ebp+viewer_data.buf]
156
        mov     [readinfo.data], eax
156
        mov     [readinfo.data], eax
157
        mov     [ebp+viewer_data.buf_pos], eax
157
        mov     [ebp+viewer_data.buf_pos], eax
158
        pop     dword [readinfo.name]
-
 
159
        mov     eax, [ebp+viewer_data.hPlugin]
158
        mov     eax, [ebp+viewer_data.hPlugin]
160
        test    eax, eax
159
        test    eax, eax
161
        jz      .retry
160
        jz      .retry
162
        push    ebx ebp
161
        push    ebx ebp
163
        push    O_READ
162
        push    O_READ
164
        push    dword [readinfo.name]
163
        push    dword [readinfo.name]
165
        push    [ebp+viewer_data.hFile]
164
        push    [ebp+viewer_data.hFile]
166
        call    [eax+PluginInfo.open]
165
        call    [eax+PluginInfo.open]
167
        pop     ebp ebx
166
        pop     ebp ebx
168
        mov     [ebp+viewer_data.hWorkFile], eax
167
        mov     [ebp+viewer_data.hWorkFile], eax
169
        test    eax, eax
168
        test    eax, eax
170
        jnz     .retry
169
        jnz     .retry
171
..openerr_in_screen:
170
..openerr_in_screen:
172
        push    ContinueBtn
171
        push    ContinueBtn
173
        push    1
172
        push    1
174
        push    aCannotOpenFile_ptr
173
        push    aCannotOpenFile_ptr
175
        push    1
174
        push    1
176
        call    SayErr
175
        call    SayErr
177
        jmp     delete_active_screen
176
        jmp     delete_active_screen
178
.retry:
177
.retry:
179
        mov     eax, [ebp+viewer_data.hPlugin]
178
        mov     eax, [ebp+viewer_data.hPlugin]
180
        test    eax, eax
179
        test    eax, eax
181
        jz      .read_native
180
        jz      .read_native
182
        push    ebp
181
        push    ebp
183
        push    16384
182
        push    16384
184
        push    [ebx+readinfo.data-readinfo]
183
        push    [ebx+readinfo.data-readinfo]
185
        push    [ebp+viewer_data.hWorkFile]
184
        push    [ebp+viewer_data.hWorkFile]
186
        call    [eax+PluginInfo.read]
185
        call    [eax+PluginInfo.read]
187
        pop     ebp
186
        pop     ebp
188
        cmp     eax, -1
187
        cmp     eax, -1
189
        jz      .readok         ; let's hope that plugin says error itself
188
        jz      .readok         ; let's hope that plugin says error itself
190
        mov     [ebp+viewer_data.buf_size], eax
189
        mov     [ebp+viewer_data.buf_size], eax
191
        mov     ebx, eax
190
        mov     ebx, eax
192
        jmp     .readok
191
        jmp     .readok
193
.read_native:
192
.read_native:
194
        push    70
193
        push    70
195
        pop     eax
194
        pop     eax
196
        int     40h
195
        int     40h
197
        mov     [ebp+viewer_data.buf_size], ebx
196
        mov     [ebp+viewer_data.buf_size], ebx
198
        test    eax, eax
197
        test    eax, eax
199
        jz      .readok
198
        jz      .readok
200
        cmp     eax, 6
199
        cmp     eax, 6
201
        jz      .readok
200
        jz      .readok
202
.readerr:
201
.readerr:
203
        lea     ebx, [ebp+viewer_data.filename]
202
        lea     ebx, [ebp+viewer_data.filename]
204
        push    ebx
203
        push    ebx
205
        push    aCannotReadFile
204
        push    aCannotReadFile
206
        call    get_error_msg
205
        call    get_error_msg
207
        push    eax
206
        push    eax
208
        mov     eax, esp
207
        mov     eax, esp
209
        push    RetryOrCancelBtn
208
        push    RetryOrCancelBtn
210
        push    2
209
        push    2
211
        push    eax
210
        push    eax
212
        push    3
211
        push    3
213
        call    SayErr
212
        call    SayErr
214
        add     esp, 3*4
213
        add     esp, 3*4
215
        mov     ebx, readinfo
214
        mov     ebx, readinfo
216
        test    eax, eax
215
        test    eax, eax
217
        jz      .attr_retry
216
        jz      .attr_retry
218
        jmp     delete_active_screen
217
        jmp     delete_active_screen
219
.readok:
218
.readok:
220
        cmp     ebx, 2
219
        cmp     ebx, 2
221
        jb      .nounicode
220
        jb      .nounicode
222
        cmp     word [ebp+viewer_data.buf], 0xFEFF
221
        cmp     word [ebp+viewer_data.buf], 0xFEFF
223
        jz      @f
222
        jz      @f
224
        cmp     word [ebp+viewer_data.buf], 0xFFFE
223
        cmp     word [ebp+viewer_data.buf], 0xFFFE
225
        jnz     .nounicode
224
        jnz     .nounicode
226
        or      byte [ebp+viewer_data.flags], 4
225
        or      byte [ebp+viewer_data.flags], 4
227
@@:
226
@@:
228
        mov     [ebp+viewer_data.encoding], encodings.unicode
227
        mov     [ebp+viewer_data.encoding], encodings.unicode
229
.nounicode:
228
.nounicode:
230
viewer_OnRedraw:
229
viewer_OnRedraw:
231
        or      [cursor_x], -1
230
        or      [cursor_x], -1
232
        or      [cursor_y], -1
231
        or      [cursor_y], -1
233
        call    viewer_set_keybar
232
        call    viewer_set_keybar
234
        call    viewer_draw_text
233
        call    viewer_draw_text
235
        ret
234
        ret
236
 
235
 
237
viewer_skip_unicode_marker:
236
viewer_skip_unicode_marker:
238
        cmp     [ebp+viewer_data.encoding], encodings.unicode
237
        cmp     [ebp+viewer_data.encoding], encodings.unicode
239
        jnz     @f
238
        jnz     @f
240
        cmp     [bForHex], 0
239
        cmp     [bForHex], 0
241
        jnz     @f
240
        jnz     @f
242
        cmp     dword [ebp+viewer_data.buf_start], 0
241
        cmp     dword [ebp+viewer_data.buf_start], 0
243
        jnz     @f
242
        jnz     @f
244
        cmp     dword [ebp+viewer_data.buf_start+4], 0
243
        cmp     dword [ebp+viewer_data.buf_start+4], 0
245
        jnz     @f
244
        jnz     @f
246
        lea     eax, [ebp+viewer_data.buf]
245
        lea     eax, [ebp+viewer_data.buf]
247
        cmp     eax, [ebp+viewer_data.buf_pos]
246
        cmp     eax, [ebp+viewer_data.buf_pos]
248
        jnz     @f
247
        jnz     @f
249
        cmp     word [eax], 0xFFFE
248
        cmp     word [eax], 0xFFFE
250
        jz      .skip
249
        jz      .skip
251
        cmp     word [eax], 0xFEFF
250
        cmp     word [eax], 0xFEFF
252
        jnz     @f
251
        jnz     @f
253
.skip:
252
.skip:
254
        add     [ebp+viewer_data.buf_pos], 2
253
        add     [ebp+viewer_data.buf_pos], 2
255
@@:
254
@@:
256
        ret
255
        ret
257
 
256
 
258
viewer_load_next:
257
viewer_load_next:
259
        mov     eax, dword [ebp+viewer_data.buf_start]
258
        mov     eax, dword [ebp+viewer_data.buf_start]
260
        add     eax, 8192
259
        add     eax, 8192
261
        mov     dword [ebp+viewer_data.buf_start], eax
260
        mov     dword [ebp+viewer_data.buf_start], eax
262
        mov     edx, dword [ebp+viewer_data.buf_start+4]
261
        mov     edx, dword [ebp+viewer_data.buf_start+4]
263
        adc     edx, 0
262
        adc     edx, 0
264
        mov     dword [ebp+viewer_data.buf_start+4], edx
263
        mov     dword [ebp+viewer_data.buf_start+4], edx
265
        add     eax, 16384-8192
264
        add     eax, 16384-8192
266
        adc     edx, 0
265
        adc     edx, 0
267
        mov     dword [readinfo.first], eax
266
        mov     dword [readinfo.first], eax
268
        mov     dword [readinfo.first+4], edx
267
        mov     dword [readinfo.first+4], edx
269
        mov     dword [readinfo.size], 8192
268
        mov     dword [readinfo.size], 8192
270
        lea     edi, [ebp+viewer_data.buf]
269
        lea     edi, [ebp+viewer_data.buf]
271
        lea     esi, [edi+8192]
270
        lea     esi, [edi+8192]
272
        mov     ecx, (16384-8192)/4
271
        mov     ecx, (16384-8192)/4
273
        rep     movsd
272
        rep     movsd
274
        mov     [readinfo.data], edi
273
        mov     [readinfo.data], edi
275
        lea     eax, [ebp+viewer_data.filename]
274
        lea     eax, [ebp+viewer_data.filename]
276
        mov     [readinfo.name], eax
275
        mov     [readinfo.name], eax
277
.readretry:
276
.readretry:
278
        mov     ebx, readinfo
277
        mov     ebx, readinfo
279
        mov     eax, [ebp+viewer_data.hPlugin]
278
        mov     eax, [ebp+viewer_data.hPlugin]
280
        test    eax, eax
279
        test    eax, eax
281
        jz      .native
280
        jz      .native
282
        push    ecx ebp
281
        push    ecx ebp
283
        push    8192
282
        push    8192
284
        push    [ebx+readinfo.data-readinfo]
283
        push    [ebx+readinfo.data-readinfo]
285
        push    [ebp+viewer_data.hWorkFile]
284
        push    [ebp+viewer_data.hWorkFile]
286
        call    [eax+PluginInfo.read]
285
        call    [eax+PluginInfo.read]
287
        pop     ebp ecx
286
        pop     ebp ecx
288
        mov     ebx, eax
287
        mov     ebx, eax
289
        cmp     eax, -1
288
        cmp     eax, -1
290
        jnz     .readok
289
        jnz     .readok
291
        xor     ebx, ebx
290
        xor     ebx, ebx
292
        jmp     .readok
291
        jmp     .readok
293
.native:
292
.native:
294
        push    70
293
        push    70
295
        pop     eax
294
        pop     eax
296
        int     40h
295
        int     40h
297
        test    eax, eax
296
        test    eax, eax
298
        jz      .readok
297
        jz      .readok
299
        cmp     eax, 6
298
        cmp     eax, 6
300
        jz      .readok
299
        jz      .readok
301
.readerr:
300
.readerr:
302
        call    ask_retry_ignore
301
        call    ask_retry_ignore
303
        jz      .readretry
302
        jz      .readretry
304
.readok:
303
.readok:
305
        sub     [ebp+viewer_data.buf_pos], 8192
304
        sub     [ebp+viewer_data.buf_pos], 8192
306
        add     ebx, 16384-8192
305
        add     ebx, 16384-8192
307
        mov     [ebp+viewer_data.buf_size], ebx
306
        mov     [ebp+viewer_data.buf_size], ebx
308
        mov     eax, [ebp+viewer_data.buf_pos]
307
        mov     eax, [ebp+viewer_data.buf_pos]
309
        cmp     ebx, 16384-8192
308
        cmp     ebx, 16384-8192
310
        ret
309
        ret
311
 
310
 
312
viewer_get_next_char:
311
viewer_get_next_char:
313
        pusha
312
        pusha
314
        call    viewer_skip_unicode_marker
313
        call    viewer_skip_unicode_marker
315
        mov     eax, [ebp+viewer_data.buf_pos]
314
        mov     eax, [ebp+viewer_data.buf_pos]
316
        lea     ecx, [ebp+viewer_data.buf]
315
        lea     ecx, [ebp+viewer_data.buf]
317
        add     ecx, [ebp+viewer_data.buf_size]
316
        add     ecx, [ebp+viewer_data.buf_size]
318
        cmp     eax, ecx
317
        cmp     eax, ecx
319
        jb      .buffered
318
        jb      .buffered
320
        mov     al, ' '
319
        mov     al, ' '
321
        sub     ecx, ebp
320
        sub     ecx, ebp
322
        cmp     ecx, viewer_data.buf + 16384
321
        cmp     ecx, viewer_data.buf + 16384
323
        jb      .err
322
        jb      .err
324
        call    viewer_load_next
323
        call    viewer_load_next
325
        jnz     .buffered
324
        jnz     .buffered
326
.err:
325
.err:
327
        stc
326
        stc
328
        popa
327
        popa
329
        ret
328
        ret
330
.buffered:
329
.buffered:
331
        cmp     [ebp+viewer_data.encoding], encodings.unicode
330
        cmp     [ebp+viewer_data.encoding], encodings.unicode
332
        jz      .unicode
331
        jz      .unicode
333
        mov     al, [eax]
332
        mov     al, [eax]
334
.done:
333
.done:
335
        mov     [esp+28], al
334
        mov     [esp+28], al
336
        inc     [ebp+viewer_data.buf_pos]
335
        inc     [ebp+viewer_data.buf_pos]
337
        clc
336
        clc
338
        popa
337
        popa
339
        ret
338
        ret
340
 
339
 
341
.unicode:
340
.unicode:
342
        inc     [ebp+viewer_data.buf_pos]
341
        inc     [ebp+viewer_data.buf_pos]
343
        cmp     [bForHex], 0
342
        cmp     [bForHex], 0
344
        jnz     @f
343
        jnz     @f
345
        call    read_unicode_char
344
        call    read_unicode_char
346
        jmp     .done
345
        jmp     .done
347
@@:
346
@@:
348
        mov     ax, [eax]
347
        mov     ax, [eax]
349
        mov     [esp+29], ah
348
        mov     [esp+29], ah
350
        jmp     .done
349
        jmp     .done
351
 
350
 
352
viewer_get_prev_char:
351
viewer_get_prev_char:
353
        pusha
352
        pusha
354
        lea     ecx, [ebp+viewer_data.buf]
353
        lea     ecx, [ebp+viewer_data.buf]
355
        cmp     [ebp+viewer_data.buf_pos], ecx
354
        cmp     [ebp+viewer_data.buf_pos], ecx
356
        ja      .buffered
355
        ja      .buffered
357
        mov     eax, dword [ebp+viewer_data.buf_start]
356
        mov     eax, dword [ebp+viewer_data.buf_start]
358
        mov     edx, dword [ebp+viewer_data.buf_start+4]
357
        mov     edx, dword [ebp+viewer_data.buf_start+4]
359
        test    eax, eax
358
        test    eax, eax
360
        jnz     @f
359
        jnz     @f
361
        test    edx, edx
360
        test    edx, edx
362
        jnz     @f
361
        jnz     @f
363
        stc
362
        stc
364
        jmp     .ret
363
        jmp     .ret
365
@@:
364
@@:
366
        sub     eax, 8192
365
        sub     eax, 8192
367
        sbb     edx, 0
366
        sbb     edx, 0
368
        jnc     @f
367
        jnc     @f
369
        xor     eax, eax
368
        xor     eax, eax
370
        xor     edx, edx
369
        xor     edx, edx
371
@@:
370
@@:
372
        call    viewer_seek
371
        call    viewer_seek
373
        add     [ebp+viewer_data.buf_pos], 8192
372
        add     [ebp+viewer_data.buf_pos], 8192
374
.buffered:
373
.buffered:
375
        mov     eax, [ebp+viewer_data.buf_pos]
374
        mov     eax, [ebp+viewer_data.buf_pos]
376
        dec     eax
375
        dec     eax
377
        cmp     [ebp+viewer_data.encoding], encodings.unicode
376
        cmp     [ebp+viewer_data.encoding], encodings.unicode
378
        jz      .unicode
377
        jz      .unicode
379
        mov     [ebp+viewer_data.buf_pos], eax
378
        mov     [ebp+viewer_data.buf_pos], eax
380
        mov     al, [eax]
379
        mov     al, [eax]
381
        mov     [esp+28], al
380
        mov     [esp+28], al
382
.done:
381
.done:
383
        clc
382
        clc
384
.ret:
383
.ret:
385
        popa
384
        popa
386
        ret
385
        ret
387
 
386
 
388
.unicode:
387
.unicode:
389
        dec     eax
388
        dec     eax
390
        mov     [ebp+viewer_data.buf_pos], eax
389
        mov     [ebp+viewer_data.buf_pos], eax
391
        call    read_unicode_char
390
        call    read_unicode_char
392
        jmp     .done
391
        jmp     .done
393
 
392
 
394
read_unicode_char:
393
read_unicode_char:
395
        mov     ax, [eax]
394
        mov     ax, [eax]
396
uni2ansi_char:
395
uni2ansi_char:
397
        test    [ebp+viewer_data.flags], 4
396
        test    [ebp+viewer_data.flags], 4
398
        jz      @f
397
        jz      @f
399
        xchg    al, ah
398
        xchg    al, ah
400
@@:
399
@@:
401
        cmp     ax, 0x80
400
        cmp     ax, 0x80
402
        jb      .ret
401
        jb      .ret
403
        cmp     ax, 0x401
402
        cmp     ax, 0x401
404
        jz      .yo1
403
        jz      .yo1
405
        cmp     ax, 0x451
404
        cmp     ax, 0x451
406
        jz      .yo2
405
        jz      .yo2
407
        cmp     ax, 0x410
406
        cmp     ax, 0x410
408
        jb      .unk
407
        jb      .unk
409
        cmp     ax, 0x440
408
        cmp     ax, 0x440
410
        jb      .rus1
409
        jb      .rus1
411
        cmp     ax, 0x450
410
        cmp     ax, 0x450
412
        jb      .rus2
411
        jb      .rus2
413
.unk:
412
.unk:
414
        mov     al, ' '
413
        mov     al, ' '
415
.ret:
414
.ret:
416
        ret
415
        ret
417
.yo1:
416
.yo1:
418
        mov     al, 'ð'
417
        mov     al, 'ð'
419
        ret
418
        ret
420
.yo2:
419
.yo2:
421
        mov     al, 'ñ'
420
        mov     al, 'ñ'
422
        ret
421
        ret
423
.rus1:
422
.rus1:
424
; 0x410-0x43F -> 0x80-0xAF
423
; 0x410-0x43F -> 0x80-0xAF
425
        add     al, 0x70
424
        add     al, 0x70
426
        ret
425
        ret
427
.rus2:
426
.rus2:
428
; 0x440-0x44F -> 0xE0-0xEF
427
; 0x440-0x44F -> 0xE0-0xEF
429
        add     al, 0xA0
428
        add     al, 0xA0
430
        ret
429
        ret
431
 
430
 
432
viewer_clear_selection:
431
viewer_clear_selection:
433
        and     dword [ebp+viewer_data.selected_start], 0
432
        and     dword [ebp+viewer_data.selected_start], 0
434
        and     dword [ebp+viewer_data.selected_start+4], 0
433
        and     dword [ebp+viewer_data.selected_start+4], 0
435
        and     dword [ebp+viewer_data.selected_len], 0
434
        and     dword [ebp+viewer_data.selected_len], 0
436
        and     dword [ebp+viewer_data.selected_len+4], 0
435
        and     dword [ebp+viewer_data.selected_len+4], 0
437
        ret
436
        ret
438
 
437
 
439
fld_uint64:
438
fld_uint64:
440
        fild    qword [eax]
439
        fild    qword [eax]
441
        test    byte [eax+7], 80h
440
        test    byte [eax+7], 80h
442
        jz      .ret
441
        jz      .ret
443
        fadd    [@f]
442
        fadd    [@f]
444
.ret:
443
.ret:
445
        ret
444
        ret
446
@@      dq      18446744073709551616.0 ;0x10000000000000000
445
@@      dq      18446744073709551616.0 ;0x10000000000000000
447
 
446
 
448
viewer_draw_text:
447
viewer_draw_text:
449
        call    viewer_seek_to_current
448
        call    viewer_seek_to_current
450
        xor     eax, eax
449
        xor     eax, eax
451
        xor     edx, edx
450
        xor     edx, edx
452
        call    get_console_ptr
451
        call    get_console_ptr
453
        mov     ah, [view_status_color]
452
        mov     ah, [view_status_color]
454
        mov     ecx, [cur_width]
453
        mov     ecx, [cur_width]
455
        sub     ecx, 44
454
        sub     ecx, 44
456
        cmp     ecx, 20
455
        cmp     ecx, 20
457
        jae     @f
456
        jae     @f
458
        mov     cl, 20
457
        mov     cl, 20
459
@@:
458
@@:
460
        call    viewedit_draw_filename
459
        call    viewedit_draw_filename
461
        add     ecx, 11
460
        add     ecx, 11
462
        rep     stosw
461
        rep     stosw
463
        movzx   esi, [ebp+viewer_data.encoding]
462
        movzx   esi, [ebp+viewer_data.encoding]
464
        lea     esi, [encodings.names+esi*8]
463
        lea     esi, [encodings.names+esi*8]
465
        push    edi esi
464
        push    edi esi
466
        dec     edi
465
        dec     edi
467
        dec     edi
466
        dec     edi
468
        std
467
        std
469
        add     esi, 8
468
        add     esi, 8
470
@@:
469
@@:
471
        dec     esi
470
        dec     esi
472
        cmp     byte [esi], ' '
471
        cmp     byte [esi], ' '
473
        jz      @b
472
        jz      @b
474
@@:
473
@@:
475
        lodsb
474
        lodsb
476
        stosw
475
        stosw
477
        cmp     esi, [esp]
476
        cmp     esi, [esp]
478
        jae     @b
477
        jae     @b
479
        cld
478
        cld
480
        pop     esi edi
479
        pop     esi edi
481
        mov     al, ' '
480
        mov     al, ' '
482
        mov     cl, 13
481
        mov     cl, 13
483
        rep     stosw
482
        rep     stosw
484
        std
483
        std
485
        push    edi
484
        push    edi
486
        mov     edx, dword [ebp+viewer_data.filesize+4]
485
        mov     edx, dword [ebp+viewer_data.filesize+4]
487
        mov     eax, dword [ebp+viewer_data.filesize]
486
        mov     eax, dword [ebp+viewer_data.filesize]
488
        mov     cl, 10
487
        mov     cl, 10
489
@@:
488
@@:
490
        push    eax
489
        push    eax
491
        mov     eax, edx
490
        mov     eax, edx
492
        xor     edx, edx
491
        xor     edx, edx
493
        div     ecx
492
        div     ecx
494
        xchg    eax, [esp]
493
        xchg    eax, [esp]
495
        div     ecx
494
        div     ecx
496
        xchg    eax, edx
495
        xchg    eax, edx
497
        add     al, '0'
496
        add     al, '0'
498
        mov     ah, [view_status_color]
497
        mov     ah, [view_status_color]
499
        stosw
498
        stosw
500
        xchg    eax, edx
499
        xchg    eax, edx
501
        pop     edx
500
        pop     edx
502
        test    eax, eax
501
        test    eax, eax
503
        jnz     @b
502
        jnz     @b
504
        test    edx, edx
503
        test    edx, edx
505
        jnz     @b
504
        jnz     @b
506
        mov     al, ' '
505
        mov     al, ' '
507
        mov     ah, [view_status_color]
506
        mov     ah, [view_status_color]
508
        stosw
507
        stosw
509
        cld
508
        cld
510
        pop     edi
509
        pop     edi
511
        inc     edi
510
        inc     edi
512
        inc     edi
511
        inc     edi
513
        mov     al, ' '
512
        mov     al, ' '
514
        mov     cl, 5
513
        mov     cl, 5
515
        rep     stosw
514
        rep     stosw
516
if lang eq ru
515
if lang eq ru
517
        mov     al, 'Š'
516
        mov     al, 'Š'
518
        stosw
517
        stosw
519
        mov     al, '®'
518
        mov     al, '®'
520
        stosw
519
        stosw
521
        mov     al, '«'
520
        mov     al, '«'
522
        stosw
521
        stosw
523
else
522
else
524
        mov     al, 'C'
523
        mov     al, 'C'
525
        stosw
524
        stosw
526
        mov     al, 'o'
525
        mov     al, 'o'
527
        stosw
526
        stosw
528
        mov     al, 'l'
527
        mov     al, 'l'
529
        stosw
528
        stosw
530
end if
529
end if
531
        mov     al, ' '
530
        mov     al, ' '
532
        stosw
531
        stosw
533
        push    edi
532
        push    edi
534
        mov     eax, dword [ebp+viewer_data.col]
533
        mov     eax, dword [ebp+viewer_data.col]
535
        mov     edx, dword [ebp+viewer_data.col+4]
534
        mov     edx, dword [ebp+viewer_data.col+4]
536
        test    edx, edx
535
        test    edx, edx
537
        jnz     .col_big
536
        jnz     .col_big
538
        cmp     eax, 100000
537
        cmp     eax, 100000
539
        jae     .col_big
538
        jae     .col_big
540
        mov     cl, 10
539
        mov     cl, 10
541
        push    -'0'
540
        push    -'0'
542
@@:
541
@@:
543
        div     ecx
542
        div     ecx
544
        push    edx
543
        push    edx
545
        xor     edx, edx
544
        xor     edx, edx
546
        test    eax, eax
545
        test    eax, eax
547
        jnz     @b
546
        jnz     @b
548
@@:
547
@@:
549
        pop     eax
548
        pop     eax
550
        add     eax, '0'
549
        add     eax, '0'
551
        jz      .col_done
550
        jz      .col_done
552
        mov     ah, [view_status_color]
551
        mov     ah, [view_status_color]
553
        stosw
552
        stosw
554
        jmp     @b
553
        jmp     @b
555
.col_big:
554
.col_big:
556
        push    eax
555
        push    eax
557
        mov     al, '.'
556
        mov     al, '.'
558
        mov     ah, [view_status_color]
557
        mov     ah, [view_status_color]
559
        stosw
558
        stosw
560
        stosw
559
        stosw
561
        stosw
560
        stosw
562
        xor     eax, eax
561
        xor     eax, eax
563
        xchg    eax, edx
562
        xchg    eax, edx
564
        mov     cl, 100
563
        mov     cl, 100
565
        div     ecx
564
        div     ecx
566
        pop     eax
565
        pop     eax
567
        div     ecx
566
        div     ecx
568
        mov     cl, 10
567
        mov     cl, 10
569
        xor     eax, eax
568
        xor     eax, eax
570
        xchg    eax, edx
569
        xchg    eax, edx
571
        div     ecx
570
        div     ecx
572
        add     al, '0'
571
        add     al, '0'
573
        mov     ah, [view_status_color]
572
        mov     ah, [view_status_color]
574
        stosw
573
        stosw
575
        mov     al, dl
574
        mov     al, dl
576
        add     al, '0'
575
        add     al, '0'
577
        stosw
576
        stosw
578
.col_done:
577
.col_done:
579
        pop     ecx
578
        pop     ecx
580
        add     ecx, 10*2
579
        add     ecx, 10*2
581
        sub     ecx, edi
580
        sub     ecx, edi
582
        shr     ecx, 1
581
        shr     ecx, 1
583
        mov     al, ' '
582
        mov     al, ' '
584
        mov     ah, [view_status_color]
583
        mov     ah, [view_status_color]
585
        rep     stosw
584
        rep     stosw
586
        finit
585
        finit
587
        fldcw   [fpu_cw]
586
        fldcw   [fpu_cw]
588
        mov     [tmp], 100
587
        mov     [tmp], 100
589
        lea     eax, [ebp+viewer_data.filesize]
588
        lea     eax, [ebp+viewer_data.filesize]
590
        cmp     dword [eax], 0
589
        cmp     dword [eax], 0
591
        jnz     @f
590
        jnz     @f
592
        cmp     dword [eax+4], 0
591
        cmp     dword [eax+4], 0
593
        jz      .size_zero
592
        jz      .size_zero
594
@@:
593
@@:
595
        call    fld_uint64
594
        call    fld_uint64
596
        lea     eax, [ebp+viewer_data.cur_pos]
595
        lea     eax, [ebp+viewer_data.cur_pos]
597
        call    fld_uint64
596
        call    fld_uint64
598
        fdivrp
597
        fdivrp
599
        fimul   [_100d]
598
        fimul   [_100d]
600
        fistp   [tmp]
599
        fistp   [tmp]
601
.size_zero:
600
.size_zero:
602
        mov     byte [edi-2], '%'
601
        mov     byte [edi-2], '%'
603
        sub     edi, 4
602
        sub     edi, 4
604
        mov     eax, [tmp]
603
        mov     eax, [tmp]
605
        mov     cl, 10
604
        mov     cl, 10
606
@@:
605
@@:
607
        xor     edx, edx
606
        xor     edx, edx
608
        div     ecx
607
        div     ecx
609
        xchg    eax, edx
608
        xchg    eax, edx
610
        add     al, '0'
609
        add     al, '0'
611
        mov     [edi], al
610
        mov     [edi], al
612
        sub     edi, 2
611
        sub     edi, 2
613
        xchg    eax, edx
612
        xchg    eax, edx
614
        test    eax, eax
613
        test    eax, eax
615
        jnz     @b
614
        jnz     @b
616
        xor     eax, eax
615
        xor     eax, eax
617
        push    1
616
        push    1
618
        pop     edx
617
        pop     edx
619
        call    get_console_ptr
618
        call    get_console_ptr
620
        test    [ebp+viewer_data.flags], 1
619
        test    [ebp+viewer_data.flags], 1
621
        jnz     .DrawHex
620
        jnz     .DrawHex
622
        push    2
621
        push    2
623
        pop     edx
622
        pop     edx
624
        xor     ecx, ecx
623
        xor     ecx, ecx
625
        mov     dword [scrpos], ecx
624
        mov     dword [scrpos], ecx
626
        mov     dword [scrpos+4], ecx
625
        mov     dword [scrpos+4], ecx
627
        mov     dword [viewer_right_side], ecx
626
        mov     dword [viewer_right_side], ecx
628
        mov     dword [viewer_right_side+4], ecx
627
        mov     dword [viewer_right_side+4], ecx
629
.1:
628
.1:
630
        call    viewer_get_next_char
629
        call    viewer_get_next_char
631
        jc      .done
630
        jc      .done
632
.2:
631
.2:
633
        cmp     al, 0xD
632
        cmp     al, 0xD
634
        jz      .newline
633
        jz      .newline
635
        cmp     al, 0xA
634
        cmp     al, 0xA
636
        jz      .newline
635
        jz      .newline
637
        cmp     ecx, [cur_width]
636
        cmp     ecx, [cur_width]
638
        jb      .no_newline
637
        jb      .no_newline
639
        test    [ebp+viewer_data.flags], 2
638
        test    [ebp+viewer_data.flags], 2
640
        jnz     .no_newline
639
        jnz     .no_newline
641
.newline:
640
.newline:
642
        push    eax
641
        push    eax
643
        mov     ecx, dword [scrpos]
642
        mov     ecx, dword [scrpos]
644
        mov     eax, dword [scrpos+4]
643
        mov     eax, dword [scrpos+4]
645
        sub     ecx, dword [ebp+viewer_data.col]
644
        sub     ecx, dword [ebp+viewer_data.col]
646
        sbb     eax, dword [ebp+viewer_data.col+4]
645
        sbb     eax, dword [ebp+viewer_data.col+4]
647
        ja      .line_filled
646
        ja      .line_filled
648
        jb      .line_full
647
        jb      .line_full
649
        cmp     ecx, [cur_width]
648
        cmp     ecx, [cur_width]
650
        ja      .line_filled
649
        ja      .line_filled
651
        jmp     @f
650
        jmp     @f
652
.line_full:
651
.line_full:
653
        xor     ecx, ecx
652
        xor     ecx, ecx
654
@@:
653
@@:
655
        test    ecx, ecx
654
        test    ecx, ecx
656
        jnz     @f
655
        jnz     @f
657
        mov     eax, dword [scrpos]
656
        mov     eax, dword [scrpos]
658
        or      eax, dword [scrpos+4]
657
        or      eax, dword [scrpos+4]
659
        jz      @f
658
        jz      @f
660
        inc     ecx
659
        inc     ecx
661
@@:
660
@@:
662
        sub     ecx, [cur_width]
661
        sub     ecx, [cur_width]
663
        neg     ecx
662
        neg     ecx
664
        mov     al, ' '
663
        mov     al, ' '
665
        mov     ah, [view_normal_color]
664
        mov     ah, [view_normal_color]
666
        rep     stosw
665
        rep     stosw
667
.line_filled:
666
.line_filled:
668
        mov     eax, dword [scrpos]
667
        mov     eax, dword [scrpos]
669
        sub     eax, dword [viewer_right_side]
668
        sub     eax, dword [viewer_right_side]
670
        mov     eax, dword [scrpos+4]
669
        mov     eax, dword [scrpos+4]
671
        sbb     eax, dword [viewer_right_side+4]
670
        sbb     eax, dword [viewer_right_side+4]
672
        jb      @f
671
        jb      @f
673
        mov     eax, dword [scrpos]
672
        mov     eax, dword [scrpos]
674
        mov     dword [viewer_right_side], eax
673
        mov     dword [viewer_right_side], eax
675
        mov     eax, dword [scrpos+4]
674
        mov     eax, dword [scrpos+4]
676
        mov     dword [viewer_right_side+4], eax
675
        mov     dword [viewer_right_side+4], eax
677
@@:
676
@@:
678
        xor     ecx, ecx
677
        xor     ecx, ecx
679
        mov     dword [scrpos], ecx
678
        mov     dword [scrpos], ecx
680
        mov     dword [scrpos+4], ecx
679
        mov     dword [scrpos+4], ecx
681
        inc     edx
680
        inc     edx
682
        pop     eax
681
        pop     eax
683
        cmp     edx, [cur_height]
682
        cmp     edx, [cur_height]
684
        jae     .done
683
        jae     .done
685
.no_newline:
684
.no_newline:
686
        cmp     al, 0xD
685
        cmp     al, 0xD
687
        jz      .3
686
        jz      .3
688
        cmp     al, 0xA
687
        cmp     al, 0xA
689
        jz      .3
688
        jz      .3
690
.4:
689
.4:
691
        test    al, al
690
        test    al, al
692
        jns     @f
691
        jns     @f
693
        movzx   esi, [ebp+viewer_data.encoding]
692
        movzx   esi, [ebp+viewer_data.encoding]
694
        cmp     esi, encodings.unicode
693
        cmp     esi, encodings.unicode
695
        jz      @f
694
        jz      @f
696
        shl     esi, 7
695
        shl     esi, 7
697
        movzx   eax, al
696
        movzx   eax, al
698
        mov     al, [encodings.tables-80h+esi+eax]
697
        mov     al, [encodings.tables-80h+esi+eax]
699
@@:
698
@@:
700
        cmp     al, 9
699
        cmp     al, 9
701
        jz      .tab
700
        jz      .tab
702
        call    .write_char
701
        call    .write_char
703
        inc     ecx
702
        inc     ecx
704
        jns     .1
703
        jns     .1
705
        push    edx
704
        push    edx
706
        mov     eax, ecx
705
        mov     eax, ecx
707
        xor     edx, edx
706
        xor     edx, edx
708
        div     [viewer_tabsize]
707
        div     [viewer_tabsize]
709
        mov     ecx, edx
708
        mov     ecx, edx
710
        pop     edx
709
        pop     edx
711
        jmp     .1
710
        jmp     .1
712
.3:
711
.3:
713
        mov     bl, al
712
        mov     bl, al
714
        call    viewer_get_next_char
713
        call    viewer_get_next_char
715
        jc      .done
714
        jc      .done
716
        xor     bl, al
715
        xor     bl, al
717
        cmp     bl, 0xA xor 0xD
716
        cmp     bl, 0xA xor 0xD
718
        jz      .1
717
        jz      .1
719
        jmp     .2
718
        jmp     .2
720
.tab:
719
.tab:
721
        push    edx
720
        push    edx
722
        push    ecx
721
        push    ecx
723
        mov     eax, ecx
722
        mov     eax, ecx
724
        mov     ecx, [viewer_tabsize]
723
        mov     ecx, [viewer_tabsize]
725
        xor     edx, edx
724
        xor     edx, edx
726
        div     ecx
725
        div     ecx
727
        pop     eax
726
        pop     eax
728
        sub     ecx, edx
727
        sub     ecx, edx
729
        pop     edx
728
        pop     edx
730
        add     eax, ecx
729
        add     eax, ecx
731
        test    [ebp+viewer_data.flags], 2
730
        test    [ebp+viewer_data.flags], 2
732
        jnz     @f
731
        jnz     @f
733
        cmp     eax, [cur_width]
732
        cmp     eax, [cur_width]
734
        jbe     @f
733
        jbe     @f
735
        sub     eax, [cur_width]
734
        sub     eax, [cur_width]
736
        sub     ecx, eax
735
        sub     ecx, eax
737
        mov     eax, [cur_width]
736
        mov     eax, [cur_width]
738
@@:
737
@@:
739
        push    eax
738
        push    eax
740
        mov     al, ' '
739
        mov     al, ' '
741
@@:
740
@@:
742
        call    .write_char
741
        call    .write_char
743
        loop    @b
742
        loop    @b
744
        pop     ecx
743
        pop     ecx
745
        jmp     .1
744
        jmp     .1
746
.done:
745
.done:
747
        setc    [ebp+viewer_data.bEofReached]
746
        setc    [ebp+viewer_data.bEofReached]
748
.done2:
747
.done2:
749
        inc     edx
748
        inc     edx
750
        cmp     edx, [cur_height]
749
        cmp     edx, [cur_height]
751
        jnc     @f
750
        jnc     @f
752
        mov     eax, dword [ebp+viewer_data.cur_pos]
751
        mov     eax, dword [ebp+viewer_data.cur_pos]
753
        or      eax, dword [ebp+viewer_data.cur_pos+4]
752
        or      eax, dword [ebp+viewer_data.cur_pos+4]
754
        jz      @f
753
        jz      @f
755
        call    viewer_seek_to_current
754
        call    viewer_seek_to_current
756
        call    viewer_prev_newline
755
        call    viewer_prev_newline
757
        jmp     viewer_draw_text
756
        jmp     viewer_draw_text
758
@@:
757
@@:
759
        push    edi
758
        push    edi
760
        xor     eax, eax
759
        xor     eax, eax
761
        mov     edx, [cur_height]
760
        mov     edx, [cur_height]
762
        dec     edx
761
        dec     edx
763
        call    get_console_ptr
762
        call    get_console_ptr
764
        mov     ecx, edi
763
        mov     ecx, edi
765
        pop     edi
764
        pop     edi
766
        sub     ecx, edi
765
        sub     ecx, edi
767
        shr     ecx, 1
766
        shr     ecx, 1
768
        mov     al, ' '
767
        mov     al, ' '
769
        mov     ah, [view_normal_color]
768
        mov     ah, [view_normal_color]
770
        rep     stosw
769
        rep     stosw
771
        cmp     [ebp+viewer_data.bEofReached], 0
770
        cmp     [ebp+viewer_data.bEofReached], 0
772
        jz      @f
771
        jz      @f
773
        xor     edx, edx
772
        xor     edx, edx
774
        mov     eax, [cur_width]
773
        mov     eax, [cur_width]
775
        sub     eax, 4
774
        sub     eax, 4
776
        call    get_console_ptr
775
        call    get_console_ptr
777
        mov     ah, [view_status_color]
776
        mov     ah, [view_status_color]
778
        mov     al, '1'
777
        mov     al, '1'
779
        stosw
778
        stosw
780
        mov     al, '0'
779
        mov     al, '0'
781
        stosw
780
        stosw
782
        stosw
781
        stosw
783
@@:
782
@@:
784
        call    draw_image
783
        call    draw_image
785
        ret
784
        ret
786
.DrawHex:
785
.DrawHex:
787
        xor     esi, esi
786
        xor     esi, esi
788
        mov     [ebp+viewer_data.bEofReached], 0
787
        mov     [ebp+viewer_data.bEofReached], 0
789
.line:
788
.line:
790
        mov     al, ' '
789
        mov     al, ' '
791
        mov     ah, [view_normal_color]
790
        mov     ah, [view_normal_color]
792
        push    edi
791
        push    edi
793
        mov     ecx, [cur_width]
792
        mov     ecx, [cur_width]
794
        rep     stosw
793
        rep     stosw
795
        mov     ebx, edi
794
        mov     ebx, edi
796
        pop     edi
795
        pop     edi
797
        mov     [bForHex], 1
796
        mov     [bForHex], 1
798
        call    viewer_get_next_char
797
        call    viewer_get_next_char
799
        mov     [bForHex], 0
798
        mov     [bForHex], 0
800
        jc      .hexdone
799
        jc      .hexdone
801
        push    eax
800
        push    eax
802
        push    edi
801
        push    edi
803
        add     edi, 36*2
802
        add     edi, 36*2
804
        mov     al, 0xB3
803
        mov     al, 0xB3
805
        mov     ah, [view_normal_color]
804
        mov     ah, [view_normal_color]
806
        call    .safechar
805
        call    .safechar
807
        pop     edi
806
        pop     edi
808
        mov     eax, dword [ebp+viewer_data.cur_pos]
807
        mov     eax, dword [ebp+viewer_data.cur_pos]
809
        mov     edx, dword [ebp+viewer_data.cur_pos+4]
808
        mov     edx, dword [ebp+viewer_data.cur_pos+4]
810
        push    esi
809
        push    esi
811
        shl     esi, 4
810
        shl     esi, 4
812
        add     eax, esi
811
        add     eax, esi
813
        adc     edx, 0
812
        adc     edx, 0
814
        pop     esi
813
        pop     esi
815
        push    eax
814
        push    eax
816
        mov     al, dl
815
        mov     al, dl
817
        shr     eax, 4
816
        shr     eax, 4
818
        and     al, 0xF
817
        and     al, 0xF
819
        call    .hex_digit
818
        call    .hex_digit
820
        mov     al, dl
819
        mov     al, dl
821
        and     al, 0xF
820
        and     al, 0xF
822
        call    .hex_digit
821
        call    .hex_digit
823
        pop     eax
822
        pop     eax
824
        push    8
823
        push    8
825
        pop     ecx
824
        pop     ecx
826
        add     edi, 7*2
825
        add     edi, 7*2
827
        std
826
        std
828
@@:
827
@@:
829
        push    eax
828
        push    eax
830
        and     al, 0xF
829
        and     al, 0xF
831
        call    .hex_digit
830
        call    .hex_digit
832
        pop     eax
831
        pop     eax
833
        shr     eax, 4
832
        shr     eax, 4
834
        loop    @b
833
        loop    @b
835
        cld
834
        cld
836
        add     edi, 9*2
835
        add     edi, 9*2
837
        mov     al, ':'
836
        mov     al, ':'
838
        mov     ah, [view_normal_color]
837
        mov     ah, [view_normal_color]
839
        stosw
838
        stosw
840
        mov     al, ' '
839
        mov     al, ' '
841
        stosw
840
        stosw
842
        xor     ecx, ecx
841
        xor     ecx, ecx
843
        pop     eax
842
        pop     eax
844
        jmp     @f
843
        jmp     @f
845
.hexchar:
844
.hexchar:
846
        mov     [bForHex], 1
845
        mov     [bForHex], 1
847
        call    viewer_get_next_char
846
        call    viewer_get_next_char
848
        mov     [bForHex], 0
847
        mov     [bForHex], 0
849
        jc      .hexdone
848
        jc      .hexdone
850
@@:
849
@@:
851
        cmp     [ebp+viewer_data.encoding], encodings.unicode
850
        cmp     [ebp+viewer_data.encoding], encodings.unicode
852
        jz      .hexchar_unicode
851
        jz      .hexchar_unicode
853
        push    eax
852
        push    eax
854
        shr     al, 4
853
        shr     al, 4
855
        call    .hex_digit
854
        call    .hex_digit
856
        pop     eax
855
        pop     eax
857
        push    eax
856
        push    eax
858
        and     al, 0xF
857
        and     al, 0xF
859
        call    .hex_digit
858
        call    .hex_digit
860
        mov     al, ' '
859
        mov     al, ' '
861
        call    .safechar
860
        call    .safechar
862
        pop     eax
861
        pop     eax
863
        push    edi
862
        push    edi
864
        add     edi, 48*2
863
        add     edi, 48*2
865
        push    ecx
864
        push    ecx
866
        shl     ecx, 2
865
        shl     ecx, 2
867
        sub     edi, ecx
866
        sub     edi, ecx
868
        pop     ecx
867
        pop     ecx
869
        cmp     ecx, 8
868
        cmp     ecx, 8
870
        jb      @f
869
        jb      @f
871
        sub     edi, 4
870
        sub     edi, 4
872
@@:
871
@@:
873
        test    al, al
872
        test    al, al
874
        jns     @f
873
        jns     @f
875
        movzx   edx, [ebp+viewer_data.encoding]
874
        movzx   edx, [ebp+viewer_data.encoding]
876
        shl     edx, 7
875
        shl     edx, 7
877
        movzx   eax, al
876
        movzx   eax, al
878
        mov     al, [encodings.tables+eax+edx-80h]
877
        mov     al, [encodings.tables+eax+edx-80h]
879
        mov     ah, [view_normal_color]
878
        mov     ah, [view_normal_color]
880
@@:
879
@@:
881
        call    .safechar
880
        call    .safechar
882
        pop     edi
881
        pop     edi
883
        inc     ecx
882
        inc     ecx
884
        cmp     ecx, 8
883
        cmp     ecx, 8
885
        jnz     @f
884
        jnz     @f
886
        mov     al, 0xB3
885
        mov     al, 0xB3
887
        call    .safechar
886
        call    .safechar
888
        mov     al, ' '
887
        mov     al, ' '
889
        call    .safechar
888
        call    .safechar
890
@@:
889
@@:
891
        cmp     ecx, 16
890
        cmp     ecx, 16
892
        jnz     .hexchar
891
        jnz     .hexchar
893
        jmp     .hexchar_nextline
892
        jmp     .hexchar_nextline
894
.hexchar_unicode:
893
.hexchar_unicode:
895
        push    eax
894
        push    eax
896
        shr     eax, 12
895
        shr     eax, 12
897
        call    .hex_digit
896
        call    .hex_digit
898
        pop     eax
897
        pop     eax
899
        push    eax
898
        push    eax
900
        shr     eax, 8
899
        shr     eax, 8
901
        and     al, 0xF
900
        and     al, 0xF
902
        call    .hex_digit
901
        call    .hex_digit
903
        pop     eax
902
        pop     eax
904
        push    eax
903
        push    eax
905
        shr     al, 4
904
        shr     al, 4
906
        call    .hex_digit
905
        call    .hex_digit
907
        pop     eax
906
        pop     eax
908
        push    eax
907
        push    eax
909
        and     al, 0xF
908
        and     al, 0xF
910
        call    .hex_digit
909
        call    .hex_digit
911
        mov     al, ' '
910
        mov     al, ' '
912
        mov     ah, [view_normal_color]
911
        mov     ah, [view_normal_color]
913
        call    .safechar
912
        call    .safechar
914
        pop     eax
913
        pop     eax
915
        push    edi
914
        push    edi
916
        add     edi, 38*2
915
        add     edi, 38*2
917
        push    ecx
916
        push    ecx
918
        shl     ecx, 3
917
        shl     ecx, 3
919
        sub     edi, ecx
918
        sub     edi, ecx
920
        pop     ecx
919
        pop     ecx
921
        cmp     ecx, 4
920
        cmp     ecx, 4
922
        jb      @f
921
        jb      @f
923
        sub     edi, 4
922
        sub     edi, 4
924
@@:
923
@@:
925
        call    uni2ansi_char
924
        call    uni2ansi_char
926
        mov     ah, [view_normal_color]
925
        mov     ah, [view_normal_color]
927
        call    .safechar
926
        call    .safechar
928
        pop     edi
927
        pop     edi
929
        inc     ecx
928
        inc     ecx
930
        cmp     ecx, 4
929
        cmp     ecx, 4
931
        jnz     @f
930
        jnz     @f
932
        mov     al, 0xB3
931
        mov     al, 0xB3
933
        call    .safechar
932
        call    .safechar
934
        mov     al, ' '
933
        mov     al, ' '
935
        call    .safechar
934
        call    .safechar
936
@@:
935
@@:
937
        cmp     ecx, 8
936
        cmp     ecx, 8
938
        jnz     .hexchar
937
        jnz     .hexchar
939
.hexchar_nextline:
938
.hexchar_nextline:
940
        mov     edi, ebx
939
        mov     edi, ebx
941
        add     esi, 3
940
        add     esi, 3
942
        mov     edx, esi
941
        mov     edx, esi
943
        cmp     esi, [cur_height]
942
        cmp     esi, [cur_height]
944
        jae     .done2
943
        jae     .done2
945
        dec     esi
944
        dec     esi
946
        dec     esi
945
        dec     esi
947
        jmp     .line
946
        jmp     .line
948
.hexdone:
947
.hexdone:
949
        mov     [ebp+viewer_data.bEofReached], 1
948
        mov     [ebp+viewer_data.bEofReached], 1
950
        mov     edi, ebx
949
        mov     edi, ebx
951
        lea     edx, [esi+2]
950
        lea     edx, [esi+2]
952
        jmp     .done2
951
        jmp     .done2
953
 
952
 
954
.hex_digit:
953
.hex_digit:
955
        push    eax
954
        push    eax
956
        cmp     al, 10
955
        cmp     al, 10
957
        sbb     al, 69h
956
        sbb     al, 69h
958
        das
957
        das
959
        mov     ah, [view_normal_color]
958
        mov     ah, [view_normal_color]
960
        call    .safechar
959
        call    .safechar
961
        pop     eax
960
        pop     eax
962
        ret
961
        ret
963
.safechar:
962
.safechar:
964
        cmp     edi, ebx
963
        cmp     edi, ebx
965
        jae     @f
964
        jae     @f
966
        stosw
965
        stosw
967
@@:
966
@@:
968
        ret
967
        ret
969
.write_char:
968
.write_char:
970
        push    ecx eax
969
        push    ecx eax
971
        mov     ecx, dword [scrpos]
970
        mov     ecx, dword [scrpos]
972
        mov     eax, dword [scrpos+4]
971
        mov     eax, dword [scrpos+4]
973
        sub     ecx, dword [ebp+viewer_data.col]
972
        sub     ecx, dword [ebp+viewer_data.col]
974
        sbb     eax, dword [ebp+viewer_data.col+4]
973
        sbb     eax, dword [ebp+viewer_data.col+4]
975
        jb      .left
974
        jb      .left
976
        ja      .skip
975
        ja      .skip
977
        test    ecx, ecx
976
        test    ecx, ecx
978
        jnz     @f
977
        jnz     @f
979
        mov     eax, dword [scrpos]
978
        mov     eax, dword [scrpos]
980
        or      eax, dword [scrpos+4]
979
        or      eax, dword [scrpos+4]
981
        jnz     .skip
980
        jnz     .skip
982
@@:
981
@@:
983
        cmp     ecx, [cur_width]
982
        cmp     ecx, [cur_width]
984
        ja      .skip
983
        ja      .skip
985
        jb      .do
984
        jb      .do
986
        mov     al, '>'
985
        mov     al, '>'
987
        mov     [edi-2], al
986
        mov     [edi-2], al
988
        mov     al, [view_arrows_color]
987
        mov     al, [view_arrows_color]
989
        mov     [edi-1], al
988
        mov     [edi-1], al
990
        jmp     .skip
989
        jmp     .skip
991
.left:
990
.left:
992
        mov     eax, dword [scrpos]
991
        mov     eax, dword [scrpos]
993
        or      eax, dword [scrpos+4]
992
        or      eax, dword [scrpos+4]
994
        jnz     .skip
993
        jnz     .skip
995
        mov     al, '<'
994
        mov     al, '<'
996
        mov     ah, [view_arrows_color]
995
        mov     ah, [view_arrows_color]
997
        stosw
996
        stosw
998
        jmp     .skip
997
        jmp     .skip
999
.do:
998
.do:
1000
        mov     al, [esp]
999
        mov     al, [esp]
1001
        mov     ah, [view_normal_color]
1000
        mov     ah, [view_normal_color]
1002
        push    edx
1001
        push    edx
1003
        mov     ecx, [ebp+viewer_data.buf_pos]
1002
        mov     ecx, [ebp+viewer_data.buf_pos]
1004
        sub     ecx, ebp
1003
        sub     ecx, ebp
1005
        sub     ecx, viewer_data.buf + 1
1004
        sub     ecx, viewer_data.buf + 1
1006
        xor     edx, edx
1005
        xor     edx, edx
1007
        add     ecx, dword [ebp+viewer_data.buf_start]
1006
        add     ecx, dword [ebp+viewer_data.buf_start]
1008
        adc     edx, dword [ebp+viewer_data.buf_start+4]
1007
        adc     edx, dword [ebp+viewer_data.buf_start+4]
1009
        sub     ecx, dword [ebp+viewer_data.selected_start]
1008
        sub     ecx, dword [ebp+viewer_data.selected_start]
1010
        sbb     edx, dword [ebp+viewer_data.selected_start+4]
1009
        sbb     edx, dword [ebp+viewer_data.selected_start+4]
1011
        cmp     edx, dword [ebp+viewer_data.selected_len+4]
1010
        cmp     edx, dword [ebp+viewer_data.selected_len+4]
1012
        ja      .color_ok
1011
        ja      .color_ok
1013
        jb      @f
1012
        jb      @f
1014
        cmp     ecx, dword [ebp+viewer_data.selected_len]
1013
        cmp     ecx, dword [ebp+viewer_data.selected_len]
1015
        jae     .color_ok
1014
        jae     .color_ok
1016
@@:
1015
@@:
1017
        mov     ah, [view_selected_color]
1016
        mov     ah, [view_selected_color]
1018
.color_ok:
1017
.color_ok:
1019
        pop     edx
1018
        pop     edx
1020
        stosw
1019
        stosw
1021
.skip:
1020
.skip:
1022
        pop     eax ecx
1021
        pop     eax ecx
1023
        add     dword [scrpos], 1
1022
        add     dword [scrpos], 1
1024
        adc     dword [scrpos+4], 0
1023
        adc     dword [scrpos+4], 0
1025
        ret
1024
        ret
1026
 
1025
 
1027
viewedit_draw_filename:
1026
viewedit_draw_filename:
1028
        lea     esi, [ebp+viewer_data.filename]
1027
        lea     esi, [ebp+viewer_data.filename]
1029
        xor     edx, edx
1028
        xor     edx, edx
1030
        cmp     [ebp+viewer_data.hPlugin], edx
1029
        cmp     [ebp+viewer_data.hPlugin], edx
1031
        mov     dl, 3
1030
        mov     dl, 3
1032
        jz      .5
1031
        jz      .5
1033
        mov     dl, 1
1032
        mov     dl, 1
1034
.5:
1033
.5:
1035
        lodsb
1034
        lodsb
1036
        cmp     al, '/'
1035
        cmp     al, '/'
1037
        jnz     @f
1036
        jnz     @f
1038
        dec     edx
1037
        dec     edx
1039
        jz      .6
1038
        jz      .6
1040
@@:
1039
@@:
1041
        stosw
1040
        stosw
1042
        loop    .5
1041
        loop    .5
1043
.6:
1042
.6:
1044
        dec     ecx
1043
        dec     ecx
1045
        stosw
1044
        stosw
1046
        push    esi
1045
        push    esi
1047
@@:
1046
@@:
1048
        inc     esi
1047
        inc     esi
1049
        cmp     byte [esi-1], 0
1048
        cmp     byte [esi-1], 0
1050
        jnz     @b
1049
        jnz     @b
1051
        sub     esi, [esp]
1050
        sub     esi, [esp]
1052
        dec     esi
1051
        dec     esi
1053
        cmp     ecx, esi
1052
        cmp     ecx, esi
1054
        jae     .7
1053
        jae     .7
1055
        mov     al, '.'
1054
        mov     al, '.'
1056
        stosw
1055
        stosw
1057
        stosw
1056
        stosw
1058
        stosw
1057
        stosw
1059
        sub     ecx, 3
1058
        sub     ecx, 3
1060
        sub     esi, ecx
1059
        sub     esi, ecx
1061
        add     [esp], esi
1060
        add     [esp], esi
1062
.7:
1061
.7:
1063
        pop     esi
1062
        pop     esi
1064
@@:
1063
@@:
1065
        lodsb
1064
        lodsb
1066
        test    al, al
1065
        test    al, al
1067
        jz      @f
1066
        jz      @f
1068
        dec     ecx
1067
        dec     ecx
1069
        stosw
1068
        stosw
1070
        jmp     @b
1069
        jmp     @b
1071
@@:
1070
@@:
1072
        mov     al, ' '
1071
        mov     al, ' '
1073
        ret
1072
        ret
1074
 
1073
 
1075
viewer_seek_to_current:
1074
viewer_seek_to_current:
1076
        mov     eax, dword [ebp+viewer_data.cur_pos]
1075
        mov     eax, dword [ebp+viewer_data.cur_pos]
1077
        mov     edx, dword [ebp+viewer_data.cur_pos+4]
1076
        mov     edx, dword [ebp+viewer_data.cur_pos+4]
1078
viewer_seek:
1077
viewer_seek:
1079
        push    eax edx
1078
        push    eax edx
1080
        sub     eax, dword [ebp+viewer_data.buf_start]
1079
        sub     eax, dword [ebp+viewer_data.buf_start]
1081
        sbb     edx, dword [ebp+viewer_data.buf_start+4]
1080
        sbb     edx, dword [ebp+viewer_data.buf_start+4]
1082
        jb      .prev
1081
        jb      .prev
1083
        ja      .next
1082
        ja      .next
1084
        cmp     eax, 16384
1083
        cmp     eax, 16384
1085
        jae     .next
1084
        jae     .next
1086
        lea     eax, [ebp+viewer_data.buf+eax]
1085
        lea     eax, [ebp+viewer_data.buf+eax]
1087
        mov     [ebp+viewer_data.buf_pos], eax
1086
        mov     [ebp+viewer_data.buf_pos], eax
1088
        pop     edx eax
1087
        pop     edx eax
1089
        ret
1088
        ret
1090
.prev:
1089
.prev:
1091
        inc     edx
1090
        inc     edx
1092
        jnz     .read_full
1091
        jnz     .read_full
1093
        and     eax, not 511
1092
        and     eax, not 511
1094
        cmp     eax, -16384
1093
        cmp     eax, -16384
1095
        jbe     .read_full
1094
        jbe     .read_full
1096
        lea     edi, [ebp+viewer_data.buf+16384-4]
1095
        lea     edi, [ebp+viewer_data.buf+16384-4]
1097
        lea     esi, [edi+eax]
1096
        lea     esi, [edi+eax]
1098
        lea     ecx, [eax+16384]
1097
        lea     ecx, [eax+16384]
1099
        push    ecx
1098
        push    ecx
1100
        shr     ecx, 2
1099
        shr     ecx, 2
1101
        std
1100
        std
1102
        rep     movsd
1101
        rep     movsd
1103
        cld
1102
        cld
1104
        pop     ecx
1103
        pop     ecx
1105
        add     dword [ebp+viewer_data.buf_start], eax
1104
        add     dword [ebp+viewer_data.buf_start], eax
1106
        adc     dword [ebp+viewer_data.buf_start+4], -1
1105
        adc     dword [ebp+viewer_data.buf_start+4], -1
1107
        neg     eax
1106
        neg     eax
1108
        cmp     dword [ebp+viewer_data.buf_size], ecx
1107
        cmp     dword [ebp+viewer_data.buf_size], ecx
1109
        jb      .doread
1108
        jb      .doread
1110
        mov     dword [ebp+viewer_data.buf_size], ecx
1109
        mov     dword [ebp+viewer_data.buf_size], ecx
1111
        jmp     .doread
1110
        jmp     .doread
1112
.read_full:
1111
.read_full:
1113
        pop     edx eax
1112
        pop     edx eax
1114
        push    eax edx
1113
        push    eax edx
1115
        and     eax, not 511
1114
        and     eax, not 511
1116
        sub     eax, 8192-512
1115
        sub     eax, 8192-512
1117
        sbb     edx, 0
1116
        sbb     edx, 0
1118
        jnc     @f
1117
        jnc     @f
1119
        xor     eax, eax
1118
        xor     eax, eax
1120
        xor     edx, edx
1119
        xor     edx, edx
1121
@@:
1120
@@:
1122
        mov     dword [ebp+viewer_data.buf_start], eax
1121
        mov     dword [ebp+viewer_data.buf_start], eax
1123
        mov     dword [ebp+viewer_data.buf_start+4], edx
1122
        mov     dword [ebp+viewer_data.buf_start+4], edx
1124
        and     dword [ebp+viewer_data.buf_size], 0
1123
        and     dword [ebp+viewer_data.buf_size], 0
1125
        mov     eax, 16384
1124
        mov     eax, 16384
1126
.doread:
1125
.doread:
1127
        mov     ebx, readinfo
1126
        mov     ebx, readinfo
1128
        push    dword [ebp+viewer_data.buf_start]
1127
        push    dword [ebp+viewer_data.buf_start]
1129
        pop     dword [ebx+4]
1128
        pop     dword [ebx+4]
1130
        push    dword [ebp+viewer_data.buf_start+4]
1129
        push    dword [ebp+viewer_data.buf_start+4]
1131
        pop     dword [ebx+8]
1130
        pop     dword [ebx+8]
1132
        mov     [ebx+12], eax
1131
        mov     [ebx+12], eax
1133
        lea     eax, [ebp+viewer_data.buf]
1132
        lea     eax, [ebp+viewer_data.buf]
1134
        mov     [ebx+16], eax
1133
        mov     [ebx+16], eax
1135
        lea     eax, [ebp+viewer_data.filename]
1134
        lea     eax, [ebp+viewer_data.filename]
1136
        mov     [ebx+21], eax
1135
        mov     [ebx+21], eax
1137
        call    .q
1136
        call    .q
1138
        cmp     ebx, [readinfo.size]
1137
        cmp     ebx, [readinfo.size]
1139
        jnz     @f
1138
        jnz     @f
1140
        add     ebx, [ebp+viewer_data.buf_size]
1139
        add     ebx, [ebp+viewer_data.buf_size]
1141
@@:
1140
@@:
1142
.ret:
1141
.ret:
1143
        mov     [ebp+viewer_data.buf_size], ebx
1142
        mov     [ebp+viewer_data.buf_size], ebx
1144
        pop     edx eax
1143
        pop     edx eax
1145
        sub     eax, dword [ebp+viewer_data.buf_start]
1144
        sub     eax, dword [ebp+viewer_data.buf_start]
1146
        lea     eax, [ebp+eax+viewer_data.buf]
1145
        lea     eax, [ebp+eax+viewer_data.buf]
1147
        mov     [ebp+viewer_data.buf_pos], eax
1146
        mov     [ebp+viewer_data.buf_pos], eax
1148
        ret
1147
        ret
1149
.next:
1148
.next:
1150
        or      eax, 511
1149
        or      eax, 511
1151
        sub     eax, 16384-1
1150
        sub     eax, 16384-1
1152
        sbb     edx, 0
1151
        sbb     edx, 0
1153
        jnz     .read_full
1152
        jnz     .read_full
1154
        cmp     eax, 16384
1153
        cmp     eax, 16384
1155
        jae     .read_full
1154
        jae     .read_full
1156
        cmp     [ebp+viewer_data.buf_size], 16384
1155
        cmp     [ebp+viewer_data.buf_size], 16384
1157
        jb      .read_full
1156
        jb      .read_full
1158
        lea     edi, [ebp+viewer_data.buf]
1157
        lea     edi, [ebp+viewer_data.buf]
1159
        lea     esi, [edi+eax]
1158
        lea     esi, [edi+eax]
1160
        mov     ecx, 16384
1159
        mov     ecx, 16384
1161
        sub     ecx, eax
1160
        sub     ecx, eax
1162
        shr     ecx, 2
1161
        shr     ecx, 2
1163
        rep     movsd
1162
        rep     movsd
1164
        add     dword [ebp+viewer_data.buf_start], eax
1163
        add     dword [ebp+viewer_data.buf_start], eax
1165
        adc     dword [ebp+viewer_data.buf_start+4], 0
1164
        adc     dword [ebp+viewer_data.buf_start+4], 0
1166
        mov     ebx, readinfo
1165
        mov     ebx, readinfo
1167
        mov     [ebx+16], edi
1166
        mov     [ebx+16], edi
1168
        sub     edi, ebp
1167
        sub     edi, ebp
1169
        sub     edi, viewer_data.buf
1168
        sub     edi, viewer_data.buf
1170
        mov     edx, dword [ebp+viewer_data.buf_start]
1169
        mov     edx, dword [ebp+viewer_data.buf_start]
1171
        add     edx, edi
1170
        add     edx, edi
1172
        mov     [ebx+4], edx
1171
        mov     [ebx+4], edx
1173
        mov     edx, dword [ebp+viewer_data.buf_start+4]
1172
        mov     edx, dword [ebp+viewer_data.buf_start+4]
1174
        adc     edx, 0
1173
        adc     edx, 0
1175
        mov     [ebx+8], edx
1174
        mov     [ebx+8], edx
1176
        mov     [ebx+12], eax
1175
        mov     [ebx+12], eax
1177
        lea     eax, [ebp+viewer_data.filename]
1176
        lea     eax, [ebp+viewer_data.filename]
1178
        mov     [ebx+21], eax
1177
        mov     [ebx+21], eax
1179
        call    .q
1178
        call    .q
1180
        sub     ebx, [readinfo.size]
1179
        sub     ebx, [readinfo.size]
1181
        add     ebx, 16384
1180
        add     ebx, 16384
1182
        jmp     .ret
1181
        jmp     .ret
1183
 
1182
 
1184
.q:
1183
.q:
1185
        mov     ebx, readinfo
1184
        mov     ebx, readinfo
1186
        mov     eax, [ebp+viewer_data.hPlugin]
1185
        mov     eax, [ebp+viewer_data.hPlugin]
1187
        test    eax, eax
1186
        test    eax, eax
1188
        jz      .native
1187
        jz      .native
1189
        push    ebp
1188
        push    ebp
1190
        push    dword [ebx+12]
1189
        push    dword [ebx+12]
1191
        push    dword [ebx+16]
1190
        push    dword [ebx+16]
1192
        push    [ebp+viewer_data.hWorkFile]
1191
        push    [ebp+viewer_data.hWorkFile]
1193
        push    eax
1192
        push    eax
1194
        push    dword [ebx+8]
1193
        push    dword [ebx+8]
1195
        push    dword [ebx+4]
1194
        push    dword [ebx+4]
1196
        push    [ebp+viewer_data.hWorkFile]
1195
        push    [ebp+viewer_data.hWorkFile]
1197
        call    [eax+PluginInfo.setpos]
1196
        call    [eax+PluginInfo.setpos]
1198
        pop     eax
1197
        pop     eax
1199
        call    [eax+PluginInfo.read]
1198
        call    [eax+PluginInfo.read]
1200
        pop     ebp
1199
        pop     ebp
1201
        mov     ebx, eax
1200
        mov     ebx, eax
1202
        cmp     eax, -1
1201
        cmp     eax, -1
1203
        jnz     @f
1202
        jnz     @f
1204
        xor     ebx, ebx
1203
        xor     ebx, ebx
1205
@@:
1204
@@:
1206
        ret
1205
        ret
1207
.native:
1206
.native:
1208
        push    70
1207
        push    70
1209
        pop     eax
1208
        pop     eax
1210
        int     40h
1209
        int     40h
1211
        test    eax, eax
1210
        test    eax, eax
1212
        jz      .readok
1211
        jz      .readok
1213
        cmp     eax, 6
1212
        cmp     eax, 6
1214
        jz      .readok
1213
        jz      .readok
1215
.readerr:
1214
.readerr:
1216
        call    ask_retry_ignore
1215
        call    ask_retry_ignore
1217
        jz      .q
1216
        jz      .q
1218
.readok:
1217
.readok:
1219
        ret
1218
        ret
1220
 
1219
 
1221
ask_retry_ignore:
1220
ask_retry_ignore:
1222
        push    esi
1221
        push    esi
1223
        lea     esi, [ebp+viewer_data.filename]
1222
        lea     esi, [ebp+viewer_data.filename]
1224
        push    esi
1223
        push    esi
1225
        push    aCannotReadFile
1224
        push    aCannotReadFile
1226
        call    get_error_msg
1225
        call    get_error_msg
1227
        push    eax
1226
        push    eax
1228
        mov     eax, esp
1227
        mov     eax, esp
1229
        push    RetryOrIgnoreBtn
1228
        push    RetryOrIgnoreBtn
1230
        push    2
1229
        push    2
1231
        push    eax
1230
        push    eax
1232
        push    3
1231
        push    3
1233
        call    SayErr
1232
        call    SayErr
1234
        add     esp, 3*4
1233
        add     esp, 3*4
1235
        pop     esi
1234
        pop     esi
1236
        test    eax, eax
1235
        test    eax, eax
1237
        ret
1236
        ret
1238
 
1237
 
1239
viewer_set_curpos:
1238
viewer_set_curpos:
1240
        mov     eax, [ebp+viewer_data.buf_pos]
1239
        mov     eax, [ebp+viewer_data.buf_pos]
1241
        sub     eax, ebp
1240
        sub     eax, ebp
1242
        sub     eax, viewer_data.buf
1241
        sub     eax, viewer_data.buf
1243
        xor     edx, edx
1242
        xor     edx, edx
1244
        add     eax, dword [ebp+viewer_data.buf_start]
1243
        add     eax, dword [ebp+viewer_data.buf_start]
1245
        adc     edx, dword [ebp+viewer_data.buf_start+4]
1244
        adc     edx, dword [ebp+viewer_data.buf_start+4]
1246
        mov     dword [ebp+viewer_data.cur_pos], eax
1245
        mov     dword [ebp+viewer_data.cur_pos], eax
1247
        mov     dword [ebp+viewer_data.cur_pos+4], edx
1246
        mov     dword [ebp+viewer_data.cur_pos+4], edx
1248
        ret
1247
        ret
1249
 
1248
 
1250
viewer_next_newline:
1249
viewer_next_newline:
1251
        test    [ebp+viewer_data.flags], 1
1250
        test    [ebp+viewer_data.flags], 1
1252
        jz      .nohex
1251
        jz      .nohex
1253
        push    8
1252
        push    8
1254
        pop     ecx
1253
        pop     ecx
1255
        cmp     [ebp+viewer_data.encoding], encodings.unicode
1254
        cmp     [ebp+viewer_data.encoding], encodings.unicode
1256
        jz      @f
1255
        jz      @f
1257
        add     ecx, ecx
1256
        add     ecx, ecx
1258
@@:
1257
@@:
1259
        call    viewer_get_next_char
1258
        call    viewer_get_next_char
1260
        jc      @f
1259
        jc      @f
1261
        loop    @b
1260
        loop    @b
1262
        call    viewer_set_curpos
1261
        call    viewer_set_curpos
1263
        clc
1262
        clc
1264
@@:     ret
1263
@@:     ret
1265
.nohex:
1264
.nohex:
1266
        xor     ecx, ecx
1265
        xor     ecx, ecx
1267
@@:
1266
@@:
1268
        call    viewer_get_next_char
1267
        call    viewer_get_next_char
1269
        jc      .ret
1268
        jc      .ret
1270
        cmp     al, 0xD
1269
        cmp     al, 0xD
1271
        jz      .1
1270
        jz      .1
1272
        cmp     al, 0xA
1271
        cmp     al, 0xA
1273
        jz      .1
1272
        jz      .1
1274
        cmp     al, 9
1273
        cmp     al, 9
1275
        jz      .tab
1274
        jz      .tab
1276
        inc     ecx
1275
        inc     ecx
1277
.next:
1276
.next:
1278
        test    [ebp+viewer_data.flags], 2
1277
        test    [ebp+viewer_data.flags], 2
1279
        jnz     @b
1278
        jnz     @b
1280
        cmp     ecx, [cur_width]
1279
        cmp     ecx, [cur_width]
1281
        jbe     @b
1280
        jbe     @b
1282
        call    viewer_get_prev_char
1281
        call    viewer_get_prev_char
1283
        jmp     .2
1282
        jmp     .2
1284
.tab:
1283
.tab:
1285
        push    ecx
1284
        push    ecx
1286
        mov     eax, ecx
1285
        mov     eax, ecx
1287
        mov     ecx, [viewer_tabsize]
1286
        mov     ecx, [viewer_tabsize]
1288
        xor     edx, edx
1287
        xor     edx, edx
1289
        div     ecx
1288
        div     ecx
1290
        sub     ecx, edx
1289
        sub     ecx, edx
1291
        add     [esp], ecx
1290
        add     [esp], ecx
1292
        pop     ecx
1291
        pop     ecx
1293
        jmp     .next
1292
        jmp     .next
1294
.1:
1293
.1:
1295
        mov     cl, al
1294
        mov     cl, al
1296
        call    viewer_get_next_char
1295
        call    viewer_get_next_char
1297
        jc      .ret
1296
        jc      .ret
1298
        xor     cl, al
1297
        xor     cl, al
1299
        cmp     cl, 0xD xor 0xA
1298
        cmp     cl, 0xD xor 0xA
1300
        jz      .2
1299
        jz      .2
1301
        dec     [ebp+viewer_data.buf_pos]
1300
        dec     [ebp+viewer_data.buf_pos]
1302
        cmp     [ebp+viewer_data.encoding], encodings.unicode
1301
        cmp     [ebp+viewer_data.encoding], encodings.unicode
1303
        jnz     .2
1302
        jnz     .2
1304
        dec     [ebp+viewer_data.buf_pos]
1303
        dec     [ebp+viewer_data.buf_pos]
1305
.2:
1304
.2:
1306
        clc
1305
        clc
1307
.ret:
1306
.ret:
1308
        pushf
1307
        pushf
1309
        call    viewer_set_curpos
1308
        call    viewer_set_curpos
1310
        popf
1309
        popf
1311
        ret
1310
        ret
1312
 
1311
 
1313
viewer_prev_newline:
1312
viewer_prev_newline:
1314
        test    [ebp+viewer_data.flags], 1
1313
        test    [ebp+viewer_data.flags], 1
1315
        jz      .nohex
1314
        jz      .nohex
1316
        push    8
1315
        push    8
1317
        pop     ecx
1316
        pop     ecx
1318
        cmp     [ebp+viewer_data.encoding], encodings.unicode
1317
        cmp     [ebp+viewer_data.encoding], encodings.unicode
1319
        jz      @f
1318
        jz      @f
1320
        add     ecx, ecx
1319
        add     ecx, ecx
1321
@@:
1320
@@:
1322
        call    viewer_get_prev_char
1321
        call    viewer_get_prev_char
1323
        jc      @f
1322
        jc      @f
1324
        loop    @b
1323
        loop    @b
1325
@@:     call    viewer_set_curpos
1324
@@:     call    viewer_set_curpos
1326
        ret
1325
        ret
1327
.nohex:
1326
.nohex:
1328
        mov     eax, 8192
1327
        mov     eax, 8192
1329
        push    eax
1328
        push    eax
1330
        cdq
1329
        cdq
1331
        div     [cur_width]
1330
        div     [cur_width]
1332
        pop     eax
1331
        pop     eax
1333
        sub     eax, edx
1332
        sub     eax, edx
1334
        mov     edx, eax
1333
        mov     edx, eax
1335
        call    viewer_get_prev_char
1334
        call    viewer_get_prev_char
1336
        jc      .0
1335
        jc      .0
1337
        dec     edx
1336
        dec     edx
1338
        cmp     al, 0xD
1337
        cmp     al, 0xD
1339
        jz      .2
1338
        jz      .2
1340
        cmp     al, 0xA
1339
        cmp     al, 0xA
1341
        jnz     .3
1340
        jnz     .3
1342
.2:
1341
.2:
1343
        mov     cl, al
1342
        mov     cl, al
1344
        call    viewer_get_prev_char
1343
        call    viewer_get_prev_char
1345
        jc      .0
1344
        jc      .0
1346
        dec     edx
1345
        dec     edx
1347
        xor     cl, al
1346
        xor     cl, al
1348
        cmp     cl, 0xD xor 0xA
1347
        cmp     cl, 0xD xor 0xA
1349
        jnz     .3
1348
        jnz     .3
1350
@@:
1349
@@:
1351
        call    viewer_get_prev_char
1350
        call    viewer_get_prev_char
1352
        jc      .0
1351
        jc      .0
1353
        dec     edx
1352
        dec     edx
1354
        jz      .0
1353
        jz      .0
1355
.3:
1354
.3:
1356
        cmp     al, 0xD
1355
        cmp     al, 0xD
1357
        jz      .1
1356
        jz      .1
1358
        cmp     al, 0xA
1357
        cmp     al, 0xA
1359
        jnz     @b
1358
        jnz     @b
1360
.1:
1359
.1:
1361
        call    viewer_get_next_char
1360
        call    viewer_get_next_char
1362
.0:
1361
.0:
1363
        push    dword [ebp+viewer_data.cur_pos+4]
1362
        push    dword [ebp+viewer_data.cur_pos+4]
1364
        push    dword [ebp+viewer_data.cur_pos]
1363
        push    dword [ebp+viewer_data.cur_pos]
1365
        call    viewer_set_curpos
1364
        call    viewer_set_curpos
1366
@@:
1365
@@:
1367
        push    dword [ebp+viewer_data.cur_pos+4]
1366
        push    dword [ebp+viewer_data.cur_pos+4]
1368
        push    dword [ebp+viewer_data.cur_pos]
1367
        push    dword [ebp+viewer_data.cur_pos]
1369
        call    viewer_next_newline
1368
        call    viewer_next_newline
1370
        jc      .ret3
1369
        jc      .ret3
1371
        mov     eax, dword [ebp+viewer_data.cur_pos]
1370
        mov     eax, dword [ebp+viewer_data.cur_pos]
1372
        mov     edx, dword [ebp+viewer_data.cur_pos+4]
1371
        mov     edx, dword [ebp+viewer_data.cur_pos+4]
1373
        sub     eax, [esp+8]
1372
        sub     eax, [esp+8]
1374
        sbb     edx, [esp+12]
1373
        sbb     edx, [esp+12]
1375
        jae     .ret3
1374
        jae     .ret3
1376
        pop     eax
1375
        pop     eax
1377
        pop     eax
1376
        pop     eax
1378
        jmp     @b
1377
        jmp     @b
1379
.ret3:
1378
.ret3:
1380
        pop     dword [ebp+viewer_data.cur_pos]
1379
        pop     dword [ebp+viewer_data.cur_pos]
1381
        pop     dword [ebp+viewer_data.cur_pos+4]
1380
        pop     dword [ebp+viewer_data.cur_pos+4]
1382
.ret:
1381
.ret:
1383
        pop     eax
1382
        pop     eax
1384
        pop     eax
1383
        pop     eax
1385
        jmp     viewer_seek_to_current
1384
        jmp     viewer_seek_to_current
1386
 
1385
 
1387
viewer_set_keybar:
1386
viewer_set_keybar:
1388
        mov     eax, keybar_viewer
1387
        mov     eax, keybar_viewer
1389
if lang eq ru
1388
if lang eq ru
1390
        test    [ebp+viewer_data.flags], 1
1389
        test    [ebp+viewer_data.flags], 1
1391
        jnz     .hex
1390
        jnz     .hex
1392
        mov     dword [eax+(4-1)*6], 'Š®¤ '
1391
        mov     dword [eax+(4-1)*6], 'Š®¤ '
1393
        mov     word [eax+(4-1)*6+4], '  '
1392
        mov     word [eax+(4-1)*6+4], '  '
1394
        jmp     @f
1393
        jmp     @f
1395
.hex:
1394
.hex:
1396
        mov     dword [eax+(4-1)*6], '’¥ªá'
1395
        mov     dword [eax+(4-1)*6], '’¥ªá'
1397
        mov     word [eax+(4-1)*6+4], 'â '
1396
        mov     word [eax+(4-1)*6+4], 'â '
1398
@@:
1397
@@:
1399
        test    [ebp+viewer_data.flags], 2
1398
        test    [ebp+viewer_data.flags], 2
1400
        jnz     .unwrap
1399
        jnz     .unwrap
1401
        mov     dword [eax+6], ' §¢'
1400
        mov     dword [eax+6], ' §¢'
1402
        mov     word [eax+6+4], '¥à'
1401
        mov     word [eax+6+4], '¥à'
1403
        jmp     @f
1402
        jmp     @f
1404
.unwrap:
1403
.unwrap:
1405
        mov     dword [eax+6], '‘¢¥à'
1404
        mov     dword [eax+6], '‘¢¥à'
1406
        mov     word [eax+6+4], '­ '
1405
        mov     word [eax+6+4], '­ '
1407
@@:
1406
@@:
1408
else
1407
else
1409
        test    [ebp+viewer_data.flags], 1
1408
        test    [ebp+viewer_data.flags], 1
1410
        jnz     .hex
1409
        jnz     .hex
1411
        mov     dword [eax+(4-1)*6], 'Hex '
1410
        mov     dword [eax+(4-1)*6], 'Hex '
1412
;        mov     word [eax+(4-1)*6+4], '  '
1411
;        mov     word [eax+(4-1)*6+4], '  '
1413
        jmp     @f
1412
        jmp     @f
1414
.hex:
1413
.hex:
1415
        mov     dword [eax+(4-1)*6], 'Text'
1414
        mov     dword [eax+(4-1)*6], 'Text'
1416
;        mov     word [eax+(4-1)*6+4], '  '
1415
;        mov     word [eax+(4-1)*6+4], '  '
1417
@@:
1416
@@:
1418
        test    [ebp+viewer_data.flags], 2
1417
        test    [ebp+viewer_data.flags], 2
1419
        jnz     .unwrap
1418
        jnz     .unwrap
1420
        mov     dword [eax+6], 'Unwr'
1419
        mov     dword [eax+6], 'Unwr'
1421
        mov     word [eax+6+4], 'ap'
1420
        mov     word [eax+6+4], 'ap'
1422
        jmp     @f
1421
        jmp     @f
1423
.unwrap:
1422
.unwrap:
1424
        mov     dword [eax+6], 'Wrap'
1423
        mov     dword [eax+6], 'Wrap'
1425
        mov     word [eax+6+4], '  '
1424
        mov     word [eax+6+4], '  '
1426
@@:
1425
@@:
1427
end if
1426
end if
1428
        movzx   esi, [ebp+viewer_data.encoding]
1427
        movzx   esi, [ebp+viewer_data.encoding]
1429
        dec     esi
1428
        dec     esi
1430
        jz      @f
1429
        jz      @f
1431
        push    1
1430
        push    1
1432
        pop     esi
1431
        pop     esi
1433
@@:
1432
@@:
1434
        lea     esi, [encodings.names+esi*8]
1433
        lea     esi, [encodings.names+esi*8]
1435
        lea     edi, [eax+keybar_cp-keybar_viewer]
1434
        lea     edi, [eax+keybar_cp-keybar_viewer]
1436
        movsd
1435
        movsd
1437
        movsw
1436
        movsw
1438
        jmp     draw_keybar
1437
        jmp     draw_keybar
1439
 
1438
 
1440
viewer_OnExit:
1439
viewer_OnExit:
1441
        mov     edx, [ebp+viewer_data.hPlugin]
1440
        mov     edx, [ebp+viewer_data.hPlugin]
1442
        test    edx, edx
1441
        test    edx, edx
1443
        jz      @f
1442
        jz      @f
1444
        and     [ebp+viewer_data.hPlugin], 0
1443
        and     [ebp+viewer_data.hPlugin], 0
1445
        push    edx ebp
1444
        push    edx ebp
1446
        push    [ebp+viewer_data.hWorkFile]
1445
        push    [ebp+viewer_data.hWorkFile]
1447
        call    [edx+PluginInfo.close]
1446
        call    [edx+PluginInfo.close]
1448
        pop     ebp edx
1447
        pop     ebp edx
1449
        mov     ebx, [ebp+viewer_data.hFile]
1448
        mov     ebx, [ebp+viewer_data.hFile]
1450
        call    close_handle_if_unused
1449
        call    close_handle_if_unused
1451
@@:
1450
@@:
1452
        ret
1451
        ret
1453
 
1452
 
1454
viewer_IsHandleUsed:
1453
viewer_IsHandleUsed:
1455
editor_IsHandleUsed:
1454
editor_IsHandleUsed:
1456
        cmp     edx, [ebp+viewer_data.hPlugin]
1455
        cmp     edx, [ebp+viewer_data.hPlugin]
1457
        jnz     @f
1456
        jnz     @f
1458
        cmp     ebx, [ebp+viewer_data.hFile]
1457
        cmp     ebx, [ebp+viewer_data.hFile]
1459
@@:
1458
@@:
1460
        ret
1459
        ret
1461
 
1460
 
1462
viewer_OnKey:
1461
viewer_OnKey:
1463
        mov     esi, viewer_ctrlkeys
1462
        mov     esi, viewer_ctrlkeys
1464
        jmp     process_ctrl_keys
1463
        jmp     process_ctrl_keys
1465
.exit:
1464
.exit:
1466
        call    viewer_OnExit
1465
        call    viewer_OnExit
1467
        jmp     delete_active_screen
1466
        jmp     delete_active_screen
1468
.down:
1467
.down:
1469
        cmp     [ebp+viewer_data.bEofReached], 0
1468
        cmp     [ebp+viewer_data.bEofReached], 0
1470
        jnz     .ret
1469
        jnz     .ret
1471
        call    viewer_seek_to_current
1470
        call    viewer_seek_to_current
1472
        call    viewer_next_newline
1471
        call    viewer_next_newline
1473
        jc      .ret
1472
        jc      .ret
1474
        call    viewer_draw_text
1473
        call    viewer_draw_text
1475
        ret
1474
        ret
1476
.pgdn:
1475
.pgdn:
1477
        cmp     [ebp+viewer_data.bEofReached], 0
1476
        cmp     [ebp+viewer_data.bEofReached], 0
1478
        jnz     .ret
1477
        jnz     .ret
1479
        call    viewer_seek_to_current
1478
        call    viewer_seek_to_current
1480
        mov     ebx, [cur_height]
1479
        mov     ebx, [cur_height]
1481
        sub     ebx, 3
1480
        sub     ebx, 3
1482
@@:
1481
@@:
1483
        call    viewer_next_newline
1482
        call    viewer_next_newline
1484
        jc      .ret
1483
        jc      .ret
1485
        dec     ebx
1484
        dec     ebx
1486
        jnz     @b
1485
        jnz     @b
1487
        call    viewer_draw_text
1486
        call    viewer_draw_text
1488
        ret
1487
        ret
1489
.up:
1488
.up:
1490
        call    viewer_seek_to_current
1489
        call    viewer_seek_to_current
1491
        call    viewer_prev_newline
1490
        call    viewer_prev_newline
1492
        call    viewer_draw_text
1491
        call    viewer_draw_text
1493
        ret
1492
        ret
1494
.pgup:
1493
.pgup:
1495
        call    viewer_seek_to_current
1494
        call    viewer_seek_to_current
1496
        mov     ebx, [cur_height]
1495
        mov     ebx, [cur_height]
1497
        sub     ebx, 3
1496
        sub     ebx, 3
1498
@@:
1497
@@:
1499
        call    viewer_prev_newline
1498
        call    viewer_prev_newline
1500
        dec     ebx
1499
        dec     ebx
1501
        jnz     @b
1500
        jnz     @b
1502
.done_redraw:
1501
.done_redraw:
1503
        call    viewer_draw_text
1502
        call    viewer_draw_text
1504
.ret:
1503
.ret:
1505
        ret
1504
        ret
1506
.f8:
1505
.f8:
1507
        movzx   esi, [ebp+viewer_data.encoding]
1506
        movzx   esi, [ebp+viewer_data.encoding]
1508
        dec     [ebp+viewer_data.encoding]
1507
        dec     [ebp+viewer_data.encoding]
1509
        jz      .done_redraw_keybar
1508
        jz      .done_redraw_keybar
1510
        mov     [ebp+viewer_data.encoding], 1
1509
        mov     [ebp+viewer_data.encoding], 1
1511
        jmp     .done_redraw_keybar
1510
        jmp     .done_redraw_keybar
1512
.f2:
1511
.f2:
1513
        xor     [ebp+viewer_data.flags], 2
1512
        xor     [ebp+viewer_data.flags], 2
1514
.done_redraw_keybar:
1513
.done_redraw_keybar:
1515
        call    viewer_set_keybar
1514
        call    viewer_set_keybar
1516
        jmp     .done_redraw
1515
        jmp     .done_redraw
1517
.f4:
1516
.f4:
1518
        xor     [ebp+viewer_data.flags], 1
1517
        xor     [ebp+viewer_data.flags], 1
1519
        pushf
1518
        pushf
1520
        call    viewer_set_keybar
1519
        call    viewer_set_keybar
1521
        popf
1520
        popf
1522
        jnz     .tohex
1521
        jnz     .tohex
1523
        push    1
1522
        push    1
1524
        pop     eax
1523
        pop     eax
1525
        cmp     [ebp+viewer_data.encoding], encodings.unicode
1524
        cmp     [ebp+viewer_data.encoding], encodings.unicode
1526
        jnz     @f
1525
        jnz     @f
1527
        add     eax, eax
1526
        add     eax, eax
1528
@@:
1527
@@:
1529
        add     dword [ebp+viewer_data.cur_pos], eax
1528
        add     dword [ebp+viewer_data.cur_pos], eax
1530
        adc     dword [ebp+viewer_data.cur_pos+4], 0
1529
        adc     dword [ebp+viewer_data.cur_pos+4], 0
1531
        call    viewer_seek_to_current
1530
        call    viewer_seek_to_current
1532
        call    viewer_prev_newline
1531
        call    viewer_prev_newline
1533
        jmp     .done_redraw
1532
        jmp     .done_redraw
1534
.tohex:
1533
.tohex:
1535
        and     byte [ebp+viewer_data.cur_pos], 0xF0
1534
        and     byte [ebp+viewer_data.cur_pos], 0xF0
1536
        jmp     .done_redraw
1535
        jmp     .done_redraw
1537
.home:
1536
.home:
1538
        xor     eax, eax
1537
        xor     eax, eax
1539
        mov     dword [ebp+viewer_data.cur_pos], eax
1538
        mov     dword [ebp+viewer_data.cur_pos], eax
1540
        mov     dword [ebp+viewer_data.cur_pos+4], eax
1539
        mov     dword [ebp+viewer_data.cur_pos+4], eax
1541
        mov     dword [ebp+viewer_data.col], eax
1540
        mov     dword [ebp+viewer_data.col], eax
1542
        mov     dword [ebp+viewer_data.col+4], eax
1541
        mov     dword [ebp+viewer_data.col+4], eax
1543
        jmp     .done_redraw
1542
        jmp     .done_redraw
1544
.end:
1543
.end:
1545
        mov     eax, dword [ebp+viewer_data.filesize]
1544
        mov     eax, dword [ebp+viewer_data.filesize]
1546
        mov     edx, dword [ebp+viewer_data.filesize+4]
1545
        mov     edx, dword [ebp+viewer_data.filesize+4]
1547
        and     al, 0xF0
1546
        and     al, 0xF0
1548
        mov     dword [ebp+viewer_data.cur_pos], eax
1547
        mov     dword [ebp+viewer_data.cur_pos], eax
1549
        mov     dword [ebp+viewer_data.cur_pos+4], edx
1548
        mov     dword [ebp+viewer_data.cur_pos+4], edx
1550
        and     dword [ebp+viewer_data.col], 0
1549
        and     dword [ebp+viewer_data.col], 0
1551
        and     dword [ebp+viewer_data.col+4], 0
1550
        and     dword [ebp+viewer_data.col+4], 0
1552
        jmp     .done_redraw
1551
        jmp     .done_redraw
1553
.right:
1552
.right:
1554
        add     dword [ebp+viewer_data.col], 1
1553
        add     dword [ebp+viewer_data.col], 1
1555
        adc     dword [ebp+viewer_data.col+4], 0
1554
        adc     dword [ebp+viewer_data.col+4], 0
1556
        jnc     .done_redraw
1555
        jnc     .done_redraw
1557
        sub     dword [ebp+viewer_data.col], 1
1556
        sub     dword [ebp+viewer_data.col], 1
1558
        sbb     dword [ebp+viewer_data.col+4], 0
1557
        sbb     dword [ebp+viewer_data.col+4], 0
1559
        ret
1558
        ret
1560
.left:
1559
.left:
1561
        sub     dword [ebp+viewer_data.col], 1
1560
        sub     dword [ebp+viewer_data.col], 1
1562
        sbb     dword [ebp+viewer_data.col+4], 0
1561
        sbb     dword [ebp+viewer_data.col+4], 0
1563
        jnc     .done_redraw
1562
        jnc     .done_redraw
1564
        add     dword [ebp+viewer_data.col], 1
1563
        add     dword [ebp+viewer_data.col], 1
1565
        adc     dword [ebp+viewer_data.col+4], 0
1564
        adc     dword [ebp+viewer_data.col+4], 0
1566
        ret
1565
        ret
1567
.ctrl_left:
1566
.ctrl_left:
1568
        test    [ebp+viewer_data.flags], 1
1567
        test    [ebp+viewer_data.flags], 1
1569
        jnz     .ctrl_left_hex
1568
        jnz     .ctrl_left_hex
1570
        sub     dword [ebp+viewer_data.col], 20
1569
        sub     dword [ebp+viewer_data.col], 20
1571
        sbb     dword [ebp+viewer_data.col+4], 0
1570
        sbb     dword [ebp+viewer_data.col+4], 0
1572
        jnc     .done_redraw
1571
        jnc     .done_redraw
1573
.ctrl_shift_left:
1572
.ctrl_shift_left:
1574
        and     dword [ebp+viewer_data.col], 0
1573
        and     dword [ebp+viewer_data.col], 0
1575
        and     dword [ebp+viewer_data.col+4], 0
1574
        and     dword [ebp+viewer_data.col+4], 0
1576
        jmp     .done_redraw
1575
        jmp     .done_redraw
1577
.ctrl_left_hex:
1576
.ctrl_left_hex:
1578
        call    viewer_seek_to_current
1577
        call    viewer_seek_to_current
1579
        call    viewer_get_prev_char
1578
        call    viewer_get_prev_char
1580
        jc      @f
1579
        jc      @f
1581
        call    viewer_set_curpos
1580
        call    viewer_set_curpos
1582
        jmp     .done_redraw
1581
        jmp     .done_redraw
1583
.ctrl_right:
1582
.ctrl_right:
1584
        test    [ebp+viewer_data.flags], 1
1583
        test    [ebp+viewer_data.flags], 1
1585
        jnz     .ctrl_right_hex
1584
        jnz     .ctrl_right_hex
1586
        add     dword [ebp+viewer_data.col], 20
1585
        add     dword [ebp+viewer_data.col], 20
1587
        adc     dword [ebp+viewer_data.col+4], 0
1586
        adc     dword [ebp+viewer_data.col+4], 0
1588
        jnc     .done_redraw
1587
        jnc     .done_redraw
1589
        sub     dword [ebp+viewer_data.col], 20
1588
        sub     dword [ebp+viewer_data.col], 20
1590
        sbb     dword [ebp+viewer_data.col+4], 0
1589
        sbb     dword [ebp+viewer_data.col+4], 0
1591
@@:     ret
1590
@@:     ret
1592
.ctrl_right_hex:
1591
.ctrl_right_hex:
1593
        call    viewer_seek_to_current
1592
        call    viewer_seek_to_current
1594
        call    viewer_get_next_char
1593
        call    viewer_get_next_char
1595
        call    viewer_set_curpos
1594
        call    viewer_set_curpos
1596
        jmp     .done_redraw
1595
        jmp     .done_redraw
1597
.ctrl_shift_right:
1596
.ctrl_shift_right:
1598
        test    [ebp+viewer_data.flags], 1
1597
        test    [ebp+viewer_data.flags], 1
1599
        jnz     @b
1598
        jnz     @b
1600
        mov     eax, dword [viewer_right_side]
1599
        mov     eax, dword [viewer_right_side]
1601
        mov     edx, dword [viewer_right_side+4]
1600
        mov     edx, dword [viewer_right_side+4]
1602
        sub     eax, [cur_width]
1601
        sub     eax, [cur_width]
1603
        sbb     edx, 0
1602
        sbb     edx, 0
1604
        jnc     @f
1603
        jnc     @f
1605
        xor     eax, eax
1604
        xor     eax, eax
1606
        xor     edx, edx
1605
        xor     edx, edx
1607
@@:
1606
@@:
1608
        mov     dword [ebp+viewer_data.col], eax
1607
        mov     dword [ebp+viewer_data.col], eax
1609
        mov     dword [ebp+viewer_data.col+4], edx
1608
        mov     dword [ebp+viewer_data.col+4], edx
1610
        jmp     .done_redraw
1609
        jmp     .done_redraw
1611
.shift_f8:
1610
.shift_f8:
1612
        mov     ecx, encodings.menu.1
1611
        mov     ecx, encodings.menu.1
1613
        mov     al, [ebp+viewer_data.encoding]
1612
        mov     al, [ebp+viewer_data.encoding]
1614
@@:
1613
@@:
1615
        cmp     byte [ecx-1], al
1614
        cmp     byte [ecx-1], al
1616
        jz      @f
1615
        jz      @f
1617
        mov     ecx, [ecx]
1616
        mov     ecx, [ecx]
1618
        jmp     @b
1617
        jmp     @b
1619
@@:
1618
@@:
1620
        push    1
1619
        push    1
1621
        push    aTables
1620
        push    aTables
1622
        push    ecx
1621
        push    ecx
1623
        call    menu
1622
        call    menu
1624
        cmp     eax, -1
1623
        cmp     eax, -1
1625
        jz      .ret
1624
        jz      .ret
1626
        mov     al, [eax-1]
1625
        mov     al, [eax-1]
1627
        mov     [ebp+viewer_data.encoding], al
1626
        mov     [ebp+viewer_data.encoding], al
1628
        cmp     al, encodings.unicode
1627
        cmp     al, encodings.unicode
1629
        jnz     .done_redraw_keybar
1628
        jnz     .done_redraw_keybar
1630
        add     dword [ebp+viewer_data.cur_pos], 1
1629
        add     dword [ebp+viewer_data.cur_pos], 1
1631
        adc     dword [ebp+viewer_data.cur_pos+4], 0
1630
        adc     dword [ebp+viewer_data.cur_pos+4], 0
1632
        and     dword [ebp+viewer_data.cur_pos], not 1
1631
        and     dword [ebp+viewer_data.cur_pos], not 1
1633
        jmp     .done_redraw_keybar
1632
        jmp     .done_redraw_keybar
1634
.f7:
1633
.f7:
1635
        call    viewer_clear_selection
1634
        call    viewer_clear_selection
1636
        call    find_in_file_dlg
1635
        call    find_in_file_dlg
1637
        jz      .shift_f7
1636
        jz      .shift_f7
1638
.ret2:
1637
.ret2:
1639
        ret
1638
        ret
1640
.shift_f7:
1639
.shift_f7:
1641
; search string SearchString in file starting from current position
1640
; search string SearchString in file starting from current position
1642
        cmp     byte [SearchString], 0
1641
        cmp     byte [SearchString], 0
1643
        jz      .ret2
1642
        jz      .ret2
1644
        mov     eax, dword [ebp+viewer_data.selected_start]
1643
        mov     eax, dword [ebp+viewer_data.selected_start]
1645
        mov     edx, dword [ebp+viewer_data.selected_start+4]
1644
        mov     edx, dword [ebp+viewer_data.selected_start+4]
1646
        inc     eax
1645
        inc     eax
1647
        jnz     @f
1646
        jnz     @f
1648
        inc     edx
1647
        inc     edx
1649
@@:
1648
@@:
1650
        cmp     dword [ebp+viewer_data.selected_len], 0
1649
        cmp     dword [ebp+viewer_data.selected_len], 0
1651
        jnz     @f
1650
        jnz     @f
1652
        cmp     dword [ebp+viewer_data.selected_len+4], 0
1651
        cmp     dword [ebp+viewer_data.selected_len+4], 0
1653
        jnz     @f
1652
        jnz     @f
1654
        mov     eax, dword [ebp+viewer_data.cur_pos]
1653
        mov     eax, dword [ebp+viewer_data.cur_pos]
1655
        mov     edx, dword [ebp+viewer_data.cur_pos+4]
1654
        mov     edx, dword [ebp+viewer_data.cur_pos+4]
1656
@@:
1655
@@:
1657
        call    viewer_clear_selection
1656
        call    viewer_clear_selection
1658
        call    viewer_seek
1657
        call    viewer_seek
1659
        call    viewer_skip_unicode_marker
1658
        call    viewer_skip_unicode_marker
1660
        mov     esi, tolower_table
1659
        mov     esi, tolower_table
1661
        test    [find_in_file_dlgdata.flags_case], 10h
1660
        test    [find_in_file_dlgdata.flags_case], 10h
1662
        jz      @f
1661
        jz      @f
1663
        mov     esi, identical_table
1662
        mov     esi, identical_table
1664
@@:
1663
@@:
1665
        mov     ebx, SearchString
1664
        mov     ebx, SearchString
1666
 	test	[find_in_file_dlgdata.flags_whole], 10h
1665
 	test	[find_in_file_dlgdata.flags_whole], 10h
1667
	setnz	al
1666
	setnz	al
1668
	push	eax
1667
	push	eax
1669
        push    dword [ebp+viewer_data.encoding]
1668
        push    dword [ebp+viewer_data.encoding]
1670
        call    search_string_pre
1669
        call    search_string_pre
1671
        mov     esi, [ebp+viewer_data.buf_pos]
1670
        mov     esi, [ebp+viewer_data.buf_pos]
1672
        lea     ebx, [ebp+viewer_data.buf]
1671
        lea     ebx, [ebp+viewer_data.buf]
1673
        add     ebx, [ebp+viewer_data.buf_size]
1672
        add     ebx, [ebp+viewer_data.buf_size]
1674
        mov     edi, edx
1673
        mov     edi, edx
1675
        cmp     esi, ebx
1674
        cmp     esi, ebx
1676
        jb      @f
1675
        jb      @f
1677
        sub     ebx, ebp
1676
        sub     ebx, ebp
1678
        cmp     ebx, viewer_data.buf + 16384
1677
        cmp     ebx, viewer_data.buf + 16384
1679
        jnz     .f7.notfound
1678
        jnz     .f7.notfound
1680
        pusha
1679
        pusha
1681
        call    viewer_load_next
1680
        call    viewer_load_next
1682
        popa
1681
        popa
1683
        jz      .f7.notfound
1682
        jz      .f7.notfound
1684
        mov     esi, [ebp+viewer_data.buf_pos]
1683
        mov     esi, [ebp+viewer_data.buf_pos]
1685
        lea     ebx, [ebp+viewer_data.buf]
1684
        lea     ebx, [ebp+viewer_data.buf]
1686
        add     ebx, [ebp+viewer_data.buf_size]
1685
        add     ebx, [ebp+viewer_data.buf_size]
1687
@@:
1686
@@:
1688
        test    [find_in_file_dlgdata.flags_whole], 10h
1687
        test    [find_in_file_dlgdata.flags_whole], 10h
1689
        jz      .search_loop
1688
        jz      .search_loop
1690
        cmp     dword [ebp+viewer_data.buf_start], 0
1689
        cmp     dword [ebp+viewer_data.buf_start], 0
1691
        jnz     @f
1690
        jnz     @f
1692
        cmp     dword [ebp+viewer_data.buf_start+4], 0
1691
        cmp     dword [ebp+viewer_data.buf_start+4], 0
1693
        jnz     @f
1692
        jnz     @f
1694
        lea     eax, [ebp+viewer_data.buf]
1693
        lea     eax, [ebp+viewer_data.buf]
1695
        cmp     [ebp+viewer_data.buf_pos], eax
1694
        cmp     [ebp+viewer_data.buf_pos], eax
1696
        jz      .f7.startspace
1695
        jz      .f7.startspace
1697
@@:
1696
@@:
1698
        xor     eax, eax
1697
        xor     eax, eax
1699
        call    viewer_get_prev_char
1698
        call    viewer_get_prev_char
1700
        inc     esi
1699
        inc     esi
1701
        cmp     [isspace_table+eax], 0
1700
        cmp     [isspace_table+eax], 0
1702
        jz      .search_loop
1701
        jz      .search_loop
1703
.f7.startspace:
1702
.f7.startspace:
1704
        add     edi, 256
1703
        add     edi, 256
1705
.search_loop:
1704
.search_loop:
1706
; edx -> FSM, ecx = last state, edi = current state,
1705
; edx -> FSM, ecx = last state, edi = current state,
1707
; esi = buf_pos, ebx = end of buffer
1706
; esi = buf_pos, ebx = end of buffer
1708
; get current symbol
1707
; get current symbol
1709
        movzx   eax, byte [esi]
1708
        movzx   eax, byte [esi]
1710
; calculate next state
1709
; calculate next state
1711
        movzx   edi, byte [edi+eax]
1710
        movzx   edi, byte [edi+eax]
1712
; done?
1711
; done?
1713
        cmp     edi, ecx
1712
        cmp     edi, ecx
1714
        jz      .f7.found
1713
        jz      .f7.found
1715
.search_loop_next:
1714
.search_loop_next:
1716
; no; proceed to next symbol
1715
; no; proceed to next symbol
1717
        shl     edi, 8
1716
        shl     edi, 8
1718
        add     esi, 1
1717
        add     esi, 1
1719
        add     edi, edx
1718
        add     edi, edx
1720
        cmp     esi, ebx
1719
        cmp     esi, ebx
1721
        jb      .search_loop
1720
        jb      .search_loop
1722
        sub     ebx, ebp
1721
        sub     ebx, ebp
1723
        cmp     ebx, viewer_data.buf + 16384
1722
        cmp     ebx, viewer_data.buf + 16384
1724
        jnz     .f7.notfound
1723
        jnz     .f7.notfound
1725
        mov     [ebp+viewer_data.buf_pos], esi
1724
        mov     [ebp+viewer_data.buf_pos], esi
1726
        pusha
1725
        pusha
1727
        call    viewer_load_next
1726
        call    viewer_load_next
1728
        popa
1727
        popa
1729
        jz      .f7.notfoundt
1728
        jz      .f7.notfoundt
1730
        mov     esi, [ebp+viewer_data.buf_pos]
1729
        mov     esi, [ebp+viewer_data.buf_pos]
1731
        lea     ebx, [ebp+viewer_data.buf]
1730
        lea     ebx, [ebp+viewer_data.buf]
1732
        add     ebx, [ebp+viewer_data.buf_size]
1731
        add     ebx, [ebp+viewer_data.buf_size]
1733
        jmp     .search_loop
1732
        jmp     .search_loop
1734
.f7.notfoundt:
1733
.f7.notfoundt:
1735
; last chance - if we are looking for a whole word, EOF is ok for last symbol
1734
; last chance - if we are looking for a whole word, EOF is ok for last symbol
1736
        test    [find_in_file_dlgdata.flags_whole], 10h
1735
        test    [find_in_file_dlgdata.flags_whole], 10h
1737
        jz      .f7.notfound
1736
        jz      .f7.notfound
1738
        movzx   edi, byte [edi+' ']
1737
        movzx   edi, byte [edi+' ']
1739
        inc     esi
1738
        inc     esi
1740
        cmp     edi, ecx
1739
        cmp     edi, ecx
1741
        jz      .f7.found
1740
        jz      .f7.found
1742
.f7.notfound:
1741
.f7.notfound:
1743
        call    search_failed
1742
        call    search_failed
1744
        jmp     .done_redraw
1743
        jmp     .done_redraw
1745
.f7.found:
1744
.f7.found:
1746
        push    ecx
1745
        push    ecx
1747
        mov     ecx, edx
1746
        mov     ecx, edx
1748
        call    pgfree
1747
        call    pgfree
1749
        mov     [ebp+viewer_data.buf_pos], esi
1748
        mov     [ebp+viewer_data.buf_pos], esi
1750
        call    viewer_set_curpos
1749
        call    viewer_set_curpos
1751
        pop     ecx
1750
        pop     ecx
1752
        mov     dword [ebp+viewer_data.selected_len], ecx
1751
        mov     dword [ebp+viewer_data.selected_len], ecx
1753
        and     dword [ebp+viewer_data.selected_len+4], 0
1752
        and     dword [ebp+viewer_data.selected_len+4], 0
1754
        dec     ecx
1753
        dec     ecx
1755
        sub     eax, ecx
1754
        sub     eax, ecx
1756
        sbb     edx, 0
1755
        sbb     edx, 0
1757
        mov     dword [ebp+viewer_data.selected_start], eax
1756
        mov     dword [ebp+viewer_data.selected_start], eax
1758
        mov     dword [ebp+viewer_data.selected_start+4], edx
1757
        mov     dword [ebp+viewer_data.selected_start+4], edx
1759
        inc     eax
1758
        inc     eax
1760
        jnz     @f
1759
        jnz     @f
1761
        inc     edx
1760
        inc     edx
1762
@@:
1761
@@:
1763
        test    [find_in_file_dlgdata.flags_whole], 10h
1762
        test    [find_in_file_dlgdata.flags_whole], 10h
1764
        jz      @f
1763
        jz      @f
1765
        sub     dword [ebp+viewer_data.selected_len], 2
1764
        sub     dword [ebp+viewer_data.selected_len], 2
1766
        sbb     dword [ebp+viewer_data.selected_len+4], 0
1765
        sbb     dword [ebp+viewer_data.selected_len+4], 0
1767
        mov     dword [ebp+viewer_data.selected_start], eax
1766
        mov     dword [ebp+viewer_data.selected_start], eax
1768
        mov     dword [ebp+viewer_data.selected_start+4], edx
1767
        mov     dword [ebp+viewer_data.selected_start+4], edx
1769
        inc     eax
1768
        inc     eax
1770
        jnz     @f
1769
        jnz     @f
1771
        inc     edx
1770
        inc     edx
1772
@@:
1771
@@:
1773
        mov     dword [ebp+viewer_data.cur_pos], eax
1772
        mov     dword [ebp+viewer_data.cur_pos], eax
1774
        mov     dword [ebp+viewer_data.cur_pos+4], edx
1773
        mov     dword [ebp+viewer_data.cur_pos+4], edx
1775
        call    viewer_seek
1774
        call    viewer_seek
1776
        call    viewer_prev_newline
1775
        call    viewer_prev_newline
1777
        jmp     .done_redraw
1776
        jmp     .done_redraw
1778
 
1777
 
1779
search_failed:
1778
search_failed:
1780
	mov	ecx, edx
1779
	mov	ecx, edx
1781
	call	pgfree
1780
	call	pgfree
1782
	mov	eax, SearchString-1
1781
	mov	eax, SearchString-1
1783
	push	dword [eax-3]
1782
	push	dword [eax-3]
1784
	push	eax
1783
	push	eax
1785
	mov	byte [eax], '"'
1784
	mov	byte [eax], '"'
1786
@@:
1785
@@:
1787
	inc	eax
1786
	inc	eax
1788
	cmp	byte [eax], 0
1787
	cmp	byte [eax], 0
1789
	jnz	@b
1788
	jnz	@b
1790
	mov	word [eax], '"'
1789
	mov	word [eax], '"'
1791
	xchg	eax, [esp]
1790
	xchg	eax, [esp]
1792
	push	eax
1791
	push	eax
1793
	push	aStringNotFound
1792
	push	aStringNotFound
1794
	mov	eax, esp
1793
	mov	eax, esp
1795
	push	ContinueBtn
1794
	push	ContinueBtn
1796
	push	1
1795
	push	1
1797
	push	eax
1796
	push	eax
1798
	push	2
1797
	push	2
1799
	push	aSearch
1798
	push	aSearch
1800
	call	SayErrTitle
1799
	call	SayErrTitle
1801
	pop	eax
1800
	pop	eax
1802
	pop	eax
1801
	pop	eax
1803
	pop	ecx
1802
	pop	ecx
1804
	mov	byte [ecx], 0
1803
	mov	byte [ecx], 0
1805
	pop	dword [eax-3]
1804
	pop	dword [eax-3]
1806
	ret
1805
	ret
1807
 
1806
 
1808
viewer_getname:
1807
viewer_getname:
1809
if lang eq ru
1808
if lang eq ru
1810
        mov     eax, 'à®á'
1809
        mov     eax, 'à®á'
1811
        stosd
1810
        stosd
1812
        mov     eax, '¬®âà'
1811
        mov     eax, '¬®âà'
1813
        stosd
1812
        stosd
1814
        mov     eax, '    '
1813
        mov     eax, '    '
1815
        stosd
1814
        stosd
1816
        stosb
1815
        stosb
1817
else
1816
else
1818
        mov     eax, 'View'
1817
        mov     eax, 'View'
1819
        stosd
1818
        stosd
1820
        mov     eax, '    '
1819
        mov     eax, '    '
1821
        stosd
1820
        stosd
1822
        stosd
1821
        stosd
1823
        stosb
1822
        stosb
1824
end if
1823
end if
1825
        jmp     viewedit_getname
1824
        jmp     viewedit_getname
1826
editor_getname:
1825
editor_getname:
1827
if lang eq ru
1826
if lang eq ru
1828
        mov     eax, '¥¤ '
1827
        mov     eax, '¥¤ '
1829
        stosd
1828
        stosd
1830
        mov     eax, 'ªâ®à'
1829
        mov     eax, 'ªâ®à'
1831
        stosd
1830
        stosd
1832
        mov     eax, '    '
1831
        mov     eax, '    '
1833
        stosd
1832
        stosd
1834
        stosb
1833
        stosb
1835
else
1834
else
1836
        mov     eax, 'Edit'
1835
        mov     eax, 'Edit'
1837
        stosd
1836
        stosd
1838
        mov     eax, '    '
1837
        mov     eax, '    '
1839
        stosd
1838
        stosd
1840
        stosd
1839
        stosd
1841
        stosb
1840
        stosb
1842
end if
1841
end if
1843
viewedit_getname:
1842
viewedit_getname:
1844
        sub     ecx, 13
1843
        sub     ecx, 13
1845
        cmp     [ebp+viewer_data.hPlugin], 0
1844
        cmp     [ebp+viewer_data.hPlugin], 0
1846
        jz      .native
1845
        jz      .native
1847
        lea     esi, [ebp+viewer_data.hostname]
1846
        lea     esi, [ebp+viewer_data.hostname]
1848
        push    ecx edi
1847
        push    ecx edi
1849
        shr     ecx, 1
1848
        shr     ecx, 1
1850
@@:
1849
@@:
1851
        lodsb
1850
        lodsb
1852
        test    al, al
1851
        test    al, al
1853
        jz      @f
1852
        jz      @f
1854
        stosb
1853
        stosb
1855
        loop    @b
1854
        loop    @b
1856
@@:
1855
@@:
1857
        sub     edi, [esp]
1856
        sub     edi, [esp]
1858
        sub     [esp+4], edi
1857
        sub     [esp+4], edi
1859
        add     [esp], edi
1858
        add     [esp], edi
1860
        pop     edi ecx
1859
        pop     edi ecx
1861
        lea     esi, [ebp+viewer_data.filename]
1860
        lea     esi, [ebp+viewer_data.filename]
1862
        jmp     .main
1861
        jmp     .main
1863
.native:
1862
.native:
1864
        lea     esi, [ebp+viewer_data.filename]
1863
        lea     esi, [ebp+viewer_data.filename]
1865
        push    3
1864
        push    3
1866
        pop     edx
1865
        pop     edx
1867
@@:
1866
@@:
1868
        lodsb
1867
        lodsb
1869
        stosb
1868
        stosb
1870
        dec     ecx
1869
        dec     ecx
1871
        test    al, al
1870
        test    al, al
1872
        jz      .ret
1871
        jz      .ret
1873
        cmp     al, '/'
1872
        cmp     al, '/'
1874
        jnz     @b
1873
        jnz     @b
1875
        dec     edx
1874
        dec     edx
1876
        jnz     @b
1875
        jnz     @b
1877
.main:
1876
.main:
1878
        push    esi
1877
        push    esi
1879
@@:
1878
@@:
1880
        lodsb
1879
        lodsb
1881
        test    al, al
1880
        test    al, al
1882
        jnz     @b
1881
        jnz     @b
1883
        sub     esi, [esp]
1882
        sub     esi, [esp]
1884
        dec     esi
1883
        dec     esi
1885
        cmp     esi, ecx
1884
        cmp     esi, ecx
1886
        jbe     @f
1885
        jbe     @f
1887
        mov     al, '.'
1886
        mov     al, '.'
1888
        stosb
1887
        stosb
1889
        stosb
1888
        stosb
1890
        stosb
1889
        stosb
1891
        sub     ecx, 3
1890
        sub     ecx, 3
1892
        sub     esi, ecx
1891
        sub     esi, ecx
1893
        add     [esp], esi
1892
        add     [esp], esi
1894
@@:
1893
@@:
1895
        pop     esi
1894
        pop     esi
1896
@@:
1895
@@:
1897
        lodsb
1896
        lodsb
1898
        stosb
1897
        stosb
1899
        test    al, al
1898
        test    al, al
1900
        jnz     @b
1899
        jnz     @b
1901
.ret:
1900
.ret:
1902
        ret
1901
        ret
1903
>
1902
>