Subversion Repositories Kolibri OS

Rev

Rev 529 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 529 Rev 532
Line 31... Line 31...
31
               memsize=20000h
31
               memsize=20000h
32
               org 0
32
               org 0
33
 PARAMS     =    memsize - 1024
33
 PARAMS     =    memsize - 1024
Line 34... Line 34...
34
 
34
 
35
appname equ 'Jpegview '
35
appname equ 'Jpegview '
Line 36... Line 36...
36
version equ '0.15'
36
version equ '0.16'
Line 37... Line 37...
37
 
37
 
38
use32
38
use32
Line 130... Line 130...
130
    cmp     [PARAMS], word "CO"
130
    cmp     [PARAMS], word "CO"
131
    jne     @f
131
    jne     @f
132
    cmp     [PARAMS+2], byte "L"
132
    cmp     [PARAMS+2], byte "L"
133
    je      boot_set_background    
133
    je      boot_set_background    
134
@@:
134
@@:
-
 
135
        cmp     byte [PARAMS], 1
-
 
136
        jz      ipc_service
135
    mov     edi, name_string       ; clear string with file name
137
    mov     edi, name_string       ; clear string with file name
136
    mov     al,  0
138
    mov     al,  0
137
    mov     ecx, 100
139
    mov     ecx, 100
138
    rep     stosb
140
    rep     stosb
Line 248... Line 250...
248
 .end:
250
 .end:
249
    ret
251
    ret
Line 250... Line 252...
250
 
252
 
Line -... Line 253...
-
 
253
;******************************************************************************
-
 
254
 
-
 
255
ipc_service:
-
 
256
        mcall   68, 11
-
 
257
        mov     esi, PARAMS+1
-
 
258
        xor     eax, eax
-
 
259
        xor     ecx, ecx
-
 
260
@@:
-
 
261
        lodsb
-
 
262
        test    al, al
-
 
263
        jz      @f
-
 
264
        lea     ecx, [ecx*5]
-
 
265
        lea     ecx, [ecx*2+eax-'0']
-
 
266
        jmp     @b
-
 
267
@@:
-
 
268
        add     ecx, 16
-
 
269
        mov     edx, ecx
-
 
270
        mcall   68, 12
-
 
271
        test    eax, eax
-
 
272
        jnz     @f
-
 
273
.exit:
-
 
274
        mcall   -1
-
 
275
@@:
-
 
276
        mov     ecx, eax
-
 
277
        and     dword [ecx], 0
-
 
278
        mov     dword [ecx+4], 8
-
 
279
        mov     [ipc_mem], ecx
-
 
280
        mcall   60, 1
-
 
281
        mcall   40, 1 shl 6
-
 
282
        mcall   23, 500         ; wait up to 5 seconds for IPC message
-
 
283
        test    eax, eax
-
 
284
        jz      .exit
-
 
285
; we got message with JPEG data, now decode it
-
 
286
        mov     eax, [ecx+12]
-
 
287
        mov     [ipc_mem_size], eax
-
 
288
; init JPEG decoder
-
 
289
    mov     ecx,memsize-fin-stack_size  ; size
-
 
290
    mov     edi,fin                     ; pointer
-
 
291
    call    add_mem             ; mark memory from fin to 0x100000-1024 as free
-
 
292
    call    colorprecalc        ; calculate colors
-
 
293
; hook file functions
-
 
294
        mov     ecx, 4
-
 
295
        call    malloc
-
 
296
        and     dword [edi], 0
-
 
297
        lea     eax, [edi-file_handler.position]
-
 
298
        mov     byte [read], 0xE9
-
 
299
        mov     dword [read+1], read_from_mem - (read+5)
-
 
300
; decode
-
 
301
    call    jpeg_info
-
 
302
    mov     dword [jpeg_st],ebp
-
 
303
    test    ebp,ebp
-
 
304
    jz      .end
-
 
305
 
-
 
306
        mov     eax, [ebp + x_size]
-
 
307
        mul     dword [ebp + y_size]
-
 
308
        lea     eax, [eax*3+8]
-
 
309
        mov     ecx, eax
-
 
310
        mcall   68, 12
-
 
311
        test    eax, eax
-
 
312
        jz      .end
-
 
313
        mov     [ipc_mem_out], eax
-
 
314
        mov     ebx, [ebp + x_size]
-
 
315
        mov     [eax], ebx
-
 
316
        mov     ebx, [ebp + y_size]
-
 
317
        mov     [eax+4], ebx
-
 
318
 
-
 
319
    mov     dword [ebp+draw_ptr],put_chunk_to_mem
-
 
320
    call    jpeg_display
-
 
321
 
-
 
322
; IPC response
-
 
323
        mov     esi, [ebp + x_size]
-
 
324
        imul    esi, [ebp + y_size]
-
 
325
        lea     esi, [esi*3+8]
-
 
326
        mov     edx, [ipc_mem_out]
-
 
327
.response:
-
 
328
        mov     ecx, [ipc_mem]
-
 
329
        mov     ecx, [ecx+8]
-
 
330
        mcall   60,2
-
 
331
 
-
 
332
    jmp     close_program       ; close the program right now
-
 
333
 
-
 
334
.end:
-
 
335
        mov     esi, 8
-
 
336
        mov     edx, x_pointer  ; points to 2 null dwords
-
 
337
        jmp     .response
-
 
338
 
-
 
339
read_from_mem:
-
 
340
; in: eax=handle, ecx=size, edi=pointer to buffer
-
 
341
; out: ecx=number of read bytes, buffer filled
-
 
342
        pushad
-
 
343
        mov     esi, [ipc_mem]
-
 
344
        add     esi, 16
-
 
345
        add     esi, [eax+file_handler.position]
-
 
346
        add     ecx, [eax+file_handler.position]
-
 
347
        cmp     ecx, [ipc_mem_size]
-
 
348
        jb      @f
-
 
349
        mov     ecx, [ipc_mem_size]
-
 
350
@@:
-
 
351
        sub     ecx, [eax+file_handler.position]
-
 
352
        add     [eax+file_handler.position], ecx
-
 
353
        rep     movsb
-
 
354
        popad
-
 
355
        ret
-
 
356
 
251
;******************************************************************************
357
;******************************************************************************
252
 
358
 
Line 253... Line 359...
253
put_chunk_to_bgr:
359
put_chunk_to_bgr:
254
    pushad
360
    pushad
Line 283... Line 389...
283
    popad
389
    popad
284
    ret
390
    ret
Line 285... Line 391...
285
 
391
 
Line -... Line 392...
-
 
392
;******************************************************************************
-
 
393
 
-
 
394
put_chunk_to_mem:
-
 
395
; in: (eax,ebx) = start coordinates of chunk
-
 
396
;     (ecx,edx) = sizes of chunk
-
 
397
;     edi -> chunk data
-
 
398
        push    esi edi edx
-
 
399
        mov     esi, edi
-
 
400
        mov     edi, ebx
-
 
401
        imul    edi, [ebp + x_size]
-
 
402
        add     edi, eax
-
 
403
        lea     edi, [edi*3+8]
-
 
404
        add     edi, [ipc_mem_out]
-
 
405
@@:
-
 
406
        push    ecx edi
-
 
407
        lea     ecx, [ecx*3]
-
 
408
        rep     movsb
-
 
409
        pop     edi ecx
-
 
410
        add     edi, [ebp + x_size]
-
 
411
        add     edi, [ebp + x_size]
-
 
412
        add     edi, [ebp + x_size]
-
 
413
        dec     edx
-
 
414
        jnz     @b
-
 
415
        pop     edx edi esi
-
 
416
        ret
-
 
417
 
Line 286... Line 418...
286
;******************************************************************************
418
;******************************************************************************
287
 
419
 
288
 
420
 
Line 595... Line 727...
595
 
727
 
596
iniciomemoria:
728
iniciomemoria:
597
              dd -(iniciomemoria+4),-(iniciomemoria+4),(iniciomemoria+4),.l1,0
729
              dd -(iniciomemoria+4),-(iniciomemoria+4),(iniciomemoria+4),.l1,0
Line 598... Line -...
598
.l1           dd 0
-
 
599
 
730
.l1           dd 0
600
fin:
731
 
-
 
732
I_END:
-
 
733
sc     system_colors
-
 
734
ipc_mem dd ?
601
I_END:
735
ipc_mem_size dd ?
602
sc     system_colors
736
ipc_mem_out dd ?
-
 
737
fileattr: rb 40