Rev 134 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
31 | halyavin | 1 | ; @RCHER system-dependent and other stuff |
2 | ; Written in pure assembler by Ivushkin Andrey aka Willow |
||
3 | |||
4 | OpenFile: |
||
5 | mov [outp],output |
||
6 | mov esi,area |
||
7 | and [Finfo.block],0 |
||
8 | if SYS eq win |
||
9 | invoke CreateFile, filename, GENERIC_READ, FILE_SHARE_READ, NULL, \ |
||
10 | OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,NULL |
||
11 | inc eax |
||
12 | test eax,eax |
||
13 | jz .ex |
||
14 | dec eax |
||
15 | mov [hnd],eax |
||
16 | invoke GetFileSize,eax,NULL |
||
17 | .ex: |
||
18 | mov ebx,eax |
||
19 | mov [filesize],eax |
||
20 | else |
||
139 | diamond | 21 | and dword [attrinfo+32], 0 |
22 | mcall 70,attrinfo |
||
23 | mov eax,[attrinfo+32] |
||
31 | halyavin | 24 | mov [filesize],ebx |
139 | diamond | 25 | mcall 70,Finfo |
31 | halyavin | 26 | end if |
27 | ret |
||
28 | |||
29 | ResetFile: |
||
30 | and [file_count],0 |
||
31 | mov eax,[arc_base] |
||
32 | xor ebx,ebx |
||
33 | mov esi,area |
||
34 | call FileSeek |
||
35 | ret |
||
36 | |||
37 | |||
38 | FileSeek: |
||
39 | ; eax - offset |
||
40 | ; esi - current pointer (in memory!) |
||
41 | ; ebx - translation method: 0 - beginning, 1 - current, 2 - end |
||
42 | push eax ecx edx |
||
43 | sub esi,BUFPTR |
||
139 | diamond | 44 | add esi,[Finfo.block] |
31 | halyavin | 45 | cmp ebx,1 |
46 | je .cur |
||
47 | jb .begin |
||
48 | mov esi,[filesize] |
||
49 | not eax |
||
50 | .cur: |
||
51 | add eax,esi |
||
52 | .begin: |
||
139 | diamond | 53 | mov esi,BUFPTR |
31 | halyavin | 54 | mov [Finfo.block],eax |
55 | if SYS eq win |
||
56 | invoke SetFilePointer,[hnd],eax,NULL,FILE_BEGIN |
||
57 | invoke ReadFile,[hnd],area,INBUF, os_work, NULL |
||
58 | ; add [byte_count],area |
||
59 | else |
||
60 | ; pregs |
||
61 | ; wait |
||
139 | diamond | 62 | mov [Finfo.count],BUFSIZE*1024 |
63 | mcall 70,Finfo |
||
31 | halyavin | 64 | ; mov [byte_count],area+INBUF |
65 | end if |
||
66 | pop edx ecx eax |
||
67 | ret |
||
68 | |||
69 | macro QueryFile |
||
70 | { |
||
71 | local ex |
||
72 | if SYS eq win |
||
73 | invoke GetOpenFileName,ofstruc |
||
74 | else |
||
75 | opendialog draw_window,QFok,QFcanc,filename |
||
76 | QFok: |
||
77 | xor eax,eax |
||
78 | jmp ex |
||
79 | ret |
||
80 | QFcanc: |
||
81 | mov eax,1 |
||
82 | end if |
||
83 | ex: |
||
84 | } |
||
85 | |||
86 | RunViewer: |
||
87 | test [Flags],PNG_MODE |
||
88 | jz .ex |
||
89 | if SYS eq win |
||
90 | mov eax,[PNG_info.Width] |
||
91 | call int2str |
||
92 | invoke WritePrivateProfileString,ini_sec,ini_rwidth,os_work,ini_file |
||
93 | mov eax,[PNG_info.Height] |
||
94 | call int2str |
||
95 | invoke WritePrivateProfileString,ini_sec,ini_rheight,os_work,ini_file |
||
96 | invoke CreateProcess,NULL,iview_cmd,NULL,NULL,TRUE,\ |
||
97 | NORMAL_PRIORITY_CLASS,NULL,NULL,suinfo,pinfo |
||
98 | invoke WaitForInputIdle,dword[pinfo],0xFFFFFFFF |
||
99 | invoke FindWindowEx, NULL,NULL,NULL,rawwnd_txt |
||
100 | invoke FindWindowEx, eax,NULL,NULL,ok_txt |
||
101 | invoke SendMessage,eax,BM_CLICK,NULL,NULL |
||
102 | else |
||
103 | test [Flags],THREAD_YES |
||
104 | jnz .ex |
||
139 | diamond | 105 | mcall 51,1,thread,child_stack_top;MEMORY |
31 | halyavin | 106 | mov [child],eax |
107 | end if |
||
108 | .ex: |
||
109 | ret |
||
110 | |||
111 | if SYS eq win |
||
112 | int2str: |
||
113 | ; in: eax - number |
||
114 | ; out: formatted string -> os_work |
||
115 | invoke wsprintf,os_work,fmt_str,eax |
||
116 | add esp,12 |
||
117 | ret |
||
118 | |||
119 | rawwnd_txt db 'Set RAW open parameters',0 |
||
120 | ok_txt db 'OK',0 |
||
121 | ini_sec db 'RAW',0 |
||
122 | ini_rwidth db 'RWidth',0 |
||
123 | ini_rheight db 'RHeight',0 |
||
124 | ini_file db "C:\Program Files\IrfanView\i_view32.ini",0 |
||
125 | fmt_str db "%d",0 |
||
126 | iview_cmd db '"C:\Program Files\IrfanView\i_view32.exe"' |
||
127 | db ' "D:\Ivushkin\projects\zip\output.raw"',0 |
||
128 | filt_str: |
||
129 | db 'Pictures (*.png)',0,'*.png',0 |
||
130 | db 'Archives (*.zip;*.*gz)',0,'*.zip;*.*gz',0 |
||
131 | db 'All files (*.*)',0,'*.*',0,0 |
||
132 | |||
133 | suinfo STARTUPINFO |
||
134 | pinfo PROCESS_INFORMATION |
||
135 | cpstruc: |
||
136 | ofstruc: |
||
137 | dd ofstruc_end-ofstruc |
||
138 | dd NULL |
||
139 | dd NULL |
||
140 | dd filt_str |
||
141 | dd NULL |
||
142 | dd NULL |
||
143 | dd 0 |
||
144 | dd filename |
||
145 | dd 256 |
||
146 | dd NULL |
||
147 | dd 0 |
||
148 | dd NULL |
||
149 | dd NULL |
||
150 | dd NULL |
||
151 | dw NULL |
||
152 | dw NULL |
||
153 | dd NULL |
||
154 | dd NULL |
||
155 | dd NULL |
||
156 | dd NULL |
||
157 | dd NULL |
||
158 | dd NULL |
||
159 | dd NULL |
||
160 | ofstruc_end: |
||
161 | |||
162 | else |
||
163 | mov ebx,-1 |
||
164 | mov ecx,ebx |
||
165 | mov edx,[PNG_info.Width] |
||
166 | add edx,10 |
||
167 | mov esi,[PNG_info.Width] |
||
168 | add esi,30 |
||
169 | mcall 67 |
||
170 | mcall 7,outfile,[outfile.size],10 shl 16+15 |
||
171 | .ex: |
||
172 | ret |
||
173 | |||
174 | MIN_WIDTH equ 300 |
||
175 | thread: |
||
176 | .red: |
||
177 | mcall 12,1 |
||
178 | mov ebx,[PNG_info.Width] |
||
179 | cmp ebx,MIN_WIDTH |
||
180 | jae .more |
||
181 | mov ebx,MIN_WIDTH |
||
182 | .more: |
||
183 | add ebx,20 |
||
184 | mov ecx,[PNG_info.Height] |
||
185 | add ecx,30 |
||
186 | mcall 0,,,0x3808080 |
||
187 | mcall 4,<5,7>,0x10f0f0f0,filename,255 |
||
188 | mov ecx,[PNG_info.Width] |
||
189 | shl ecx,16 |
||
190 | add ecx,[PNG_info.Height] |
||
131 | diamond | 191 | mcall 7,[png_],,10 shl 16+25 |
31 | halyavin | 192 | mcall 12,2 |
193 | .still: |
||
194 | mcall 10 |
||
195 | cmp eax,1 |
||
196 | je .red |
||
197 | cmp eax,2 |
||
198 | jne .nokey |
||
199 | mcall 2 |
||
200 | cmp ah,27 ; Esc - close |
||
201 | je .close |
||
202 | jmp .still |
||
203 | .nokey: |
||
204 | cmp eax,3 |
||
205 | jne .still |
||
206 | .close: |
||
207 | and [child],0 |
||
131 | diamond | 208 | mcall 64,1,MEMINIT |
31 | halyavin | 209 | mcall -1 |
210 | |||
211 | KillViewer: |
||
212 | pusha |
||
213 | mov edi,[child] |
||
214 | test edi,edi |
||
215 | jz .noth |
||
216 | mcall 9,os_work,-1 |
||
217 | mov ecx,eax |
||
218 | .fchild: |
||
219 | push ecx |
||
220 | mcall 9,os_work |
||
221 | cmp edi,[ebx+30] |
||
222 | jne .lp |
||
223 | mov ecx,[esp] |
||
224 | mcall 18,2 |
||
225 | pop ecx |
||
226 | jmp .noth |
||
227 | .lp: |
||
228 | pop ecx |
||
229 | loop .fchild |
||
230 | .noth: |
||
231 | popa |
||
232 | ret |
||
233 | |||
234 | macro CmdLine |
||
235 | { |
||
236 | mov esi,PARAM_PTR |
||
237 | .parse: |
||
238 | lodsb |
||
239 | |||
240 | test al,al |
||
241 | jnz .noend |
||
242 | or [Flags],STAY_MODE |
||
243 | jmp red |
||
244 | .noend: |
||
245 | cmp al,' ' |
||
246 | je .stay |
||
247 | cmp al,'/' |
||
248 | jne .yespar |
||
249 | dec esi |
||
250 | mov ecx,255 |
||
251 | mov edi,filename |
||
252 | rep movsb |
||
131 | diamond | 253 | jmp again;cmdl |
31 | halyavin | 254 | .yespar: |
255 | cmp al,'N' |
||
256 | jne .nonum |
||
257 | call get_6ASCII_num |
||
258 | .fnum: |
||
259 | mov [FileNum],eax |
||
260 | jmp .parse |
||
261 | .nonum: |
||
262 | cmp al,'n' |
||
263 | jne .nonum2 |
||
264 | lodsd |
||
265 | jmp .fnum |
||
266 | .nonum2: |
||
267 | cmp al,'s' |
||
268 | jne .nostay |
||
269 | .stay: |
||
270 | or [Flags],STAY_MODE |
||
271 | jmp .parse |
||
272 | .nostay: |
||
273 | cmp al,'i' |
||
274 | jne .noclPID |
||
275 | lodsd |
||
276 | mov [clientPID],eax |
||
277 | or [Flags],IPC_MODE |
||
278 | jmp .parse |
||
279 | .noclPID: |
||
280 | cmp al,'R' |
||
281 | jne .noraw |
||
282 | or [Flags],RAW_MODE |
||
283 | jmp .parse |
||
284 | .noraw: |
||
285 | cmp al,'q' |
||
286 | jne .noofs |
||
287 | lodsd |
||
131 | diamond | 288 | .fofs: |
31 | halyavin | 289 | mov [arc_base],eax |
290 | jmp .parse |
||
291 | .noofs: |
||
292 | cmp al,'Q' |
||
293 | jne .noofs2 |
||
294 | call get_6ASCII_num |
||
295 | jmp .fofs |
||
131 | diamond | 296 | .noofs2: |
297 | cmp al,'L' |
||
298 | jne .nolist |
||
299 | or [Flags],LIST_MODE |
||
300 | .nolist: |
||
31 | halyavin | 301 | jmp .parse |
302 | |||
303 | get_6ASCII_num: |
||
304 | ; in: esi - str ptr, out: eax - num |
||
305 | xor edx,edx |
||
306 | mov ebx,10 |
||
307 | mov ecx,6 |
||
308 | .lp: |
||
309 | xor eax,eax |
||
310 | lodsb |
||
311 | sub al,'0' |
||
312 | imul edx,ebx |
||
313 | add edx,eax |
||
314 | loop .lp |
||
315 | mov eax,edx |
||
316 | ret |
||
317 | } |
||
318 | |||
319 | StartPad: |
||
131 | diamond | 320 | pusha |
321 | mov esi,[outfile.size] |
||
322 | ; dpd esi |
||
134 | diamond | 323 | ; convert number in esi to decimal representation |
324 | mov ecx, 10 |
||
325 | push -'0' |
||
326 | mov eax, esi |
||
327 | @@: |
||
328 | xor edx, edx |
||
329 | div ecx |
||
330 | push edx |
||
331 | test eax, eax |
||
332 | jnz @b |
||
333 | mov edi, par_fsize |
||
334 | @@: |
||
335 | pop eax |
||
336 | add al, '0' |
||
337 | stosb |
||
338 | jnz @b |
||
339 | mcall 70,fileinfo |
||
131 | diamond | 340 | mov ecx,eax |
341 | mcall 5,20 |
||
342 | mcall 60,2,,[outfile.out];output |
||
343 | mcall 64,1,MEMINIT |
||
344 | popa |
||
31 | halyavin | 345 | ret |
346 | |||
134 | diamond | 347 | fileinfo: |
348 | dd 7 |
||
349 | dd 0 |
||
350 | dd editor_par |
||
351 | dd 0 |
||
352 | dd 0 |
||
353 | db '/RD/1/TINYPAD',0 |
||
131 | diamond | 354 | editor_par db '*' |
134 | diamond | 355 | par_fsize rb 11 |
31 | halyavin | 356 | end if5,7> |