Subversion Repositories Kolibri OS

Rev

Rev 539 | 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
485 heavyiron 171
 .ext:
31 halyavin 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
936 leency 187
    ;mcall 4,<5,7>,0x10f0f0f0,filename,255
188
    mcall 71,1,filename,255 ;by Leency
31 halyavin 189
    mov  ecx,[PNG_info.Width]
190
    shl  ecx,16
191
    add  ecx,[PNG_info.Height]
131 diamond 192
    mcall 7,[png_],,10 shl 16+25
31 halyavin 193
    mcall 12,2
194
  .still:
195
    mcall 10
196
    cmp  eax,1
197
    je   .red
198
    cmp  eax,2
199
    jne  .nokey
200
    mcall 2
201
    cmp  ah,27 ; Esc - close
202
    je   .close
203
    jmp  .still
204
  .nokey:
205
    cmp  eax,3
206
    jne  .still
207
  .close:
208
    and  [child],0
131 diamond 209
    mcall 64,1,MEMINIT
31 halyavin 210
    mcall -1
211
 
212
KillViewer:
213
    pusha
214
    mov  edi,[child]
215
    test edi,edi
216
    jz   .noth
217
    mcall 9,os_work,-1
218
    mov  ecx,eax
219
  .fchild:
220
    push ecx
221
    mcall 9,os_work
222
    cmp  edi,[ebx+30]
223
    jne  .lp
224
    mov  ecx,[esp]
225
    mcall 18,2
226
    pop  ecx
227
    jmp  .noth
228
  .lp:
229
    pop  ecx
230
    loop .fchild
231
  .noth:
232
    popa
233
    ret
234
 
235
macro CmdLine
236
{
237
    mov  esi,PARAM_PTR
238
  .parse:
239
    lodsb
240
 
241
    test al,al
242
    jnz  .noend
243
    or  [Flags],STAY_MODE
244
    jmp  red
245
  .noend:
246
    cmp  al,' '
247
    je   .stay
248
    cmp  al,'/'
249
    jne  .yespar
250
    dec  esi
251
    mov  ecx,255
252
    mov  edi,filename
253
    rep  movsb
131 diamond 254
    jmp  again;cmdl
31 halyavin 255
  .yespar:
256
    cmp  al,'N'
257
    jne  .nonum
258
    call get_6ASCII_num
259
  .fnum:
260
    mov  [FileNum],eax
261
    jmp  .parse
262
  .nonum:
263
    cmp  al,'n'
264
    jne  .nonum2
265
    lodsd
266
    jmp  .fnum
267
  .nonum2:
268
    cmp  al,'s'
269
    jne  .nostay
270
  .stay:
271
    or   [Flags],STAY_MODE
272
    jmp  .parse
273
  .nostay:
274
    cmp  al,'i'
275
    jne  .noclPID
276
    lodsd
277
    mov  [clientPID],eax
278
    or   [Flags],IPC_MODE
279
    jmp  .parse
280
  .noclPID:
281
    cmp  al,'R'
282
    jne  .noraw
283
    or   [Flags],RAW_MODE
284
    jmp  .parse
285
  .noraw:
286
    cmp  al,'q'
287
    jne  .noofs
288
    lodsd
131 diamond 289
  .fofs:
31 halyavin 290
    mov  [arc_base],eax
291
    jmp  .parse
292
  .noofs:
293
    cmp  al,'Q'
294
    jne  .noofs2
295
    call get_6ASCII_num
296
    jmp  .fofs
131 diamond 297
  .noofs2:
298
    cmp  al,'L'
299
    jne  .nolist
300
    or   [Flags],LIST_MODE
301
  .nolist:
31 halyavin 302
    jmp  .parse
303
 
304
get_6ASCII_num:
305
; in: esi - str ptr, out: eax - num
306
    xor  edx,edx
307
    mov  ebx,10
308
    mov  ecx,6
309
  .lp:
310
    xor  eax,eax
311
    lodsb
312
    sub  al,'0'
313
    imul edx,ebx
314
    add  edx,eax
315
    loop .lp
316
    mov  eax,edx
317
    ret
318
}
319
 
320
StartPad:
131 diamond 321
    pusha
322
    mov   esi,[outfile.size]
323
;    dpd  esi
134 diamond 324
; convert number in esi to decimal representation
325
        mov     ecx, 10
326
        push    -'0'
327
        mov     eax, esi
328
@@:
329
        xor	edx, edx
330
        div     ecx
331
        push    edx
332
        test    eax, eax
333
        jnz     @b
334
        mov     edi, par_fsize
335
@@:
336
        pop     eax
337
        add     al, '0'
338
        stosb
339
        jnz     @b
340
    mcall 70,fileinfo
131 diamond 341
    mov  ecx,eax
342
    mcall 5,20
343
    mcall 60,2,,[outfile.out];output
344
    mcall 64,1,MEMINIT
345
    popa
31 halyavin 346
    ret
347
 
134 diamond 348
fileinfo:
349
        dd      7
350
        dd      0
351
        dd      editor_par
352
        dd      0
353
        dd      0
539 spraid 354
        db      '/sys/TINYPAD',0
131 diamond 355
editor_par db '*'
134 diamond 356
par_fsize rb 11
31 halyavin 357
end if