Subversion Repositories Kolibri OS

Rev

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

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