Subversion Repositories Kolibri OS

Rev

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