Subversion Repositories Kolibri OS

Rev

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

Rev 195 Rev 470
1
;    IMGVIEW.ASM
1
;    IMGVIEW.ASM
2
;
2
;
3
;    This program displays jpeg images. The window can be resized.
3
;    This program displays jpeg images. The window can be resized.
4
;
4
;
5
;    Version 0.0    END OF 2003
5
;    Version 0.0    END OF 2003
6
;                   Octavio Vega
6
;                   Octavio Vega
7
;    Version 0.1    7th March 2004
7
;    Version 0.1    7th March 2004
8
;                   Mike Hibbett ( very small part! )
8
;                   Mike Hibbett ( very small part! )
9
;    Version 0.11   7th April 2004
9
;    Version 0.11   7th April 2004
10
;                   Ville Turjanmaa ( 'set_as_bgr' function )
10
;                   Ville Turjanmaa ( 'set_as_bgr' function )
11
;    Version 0.12   29th May 2004
11
;    Version 0.12   29th May 2004
12
;                   Ivan Poddubny (correct "set_as_bgr"+parameters+boot+...)
12
;                   Ivan Poddubny (correct "set_as_bgr"+parameters+boot+...)
13
;    Version 0.12   30 de mayo 2004
13
;    Version 0.12   30 de mayo 2004
14
;                   Octavio Vega
14
;                   Octavio Vega
15
;                   bugs correction and slideshow
15
;                   bugs correction and slideshow
16
;    version 0.13   3 de junio 2004
16
;    version 0.13   3 de junio 2004
17
;                   Octavio Vega
17
;                   Octavio Vega
18
;                   unos retoques
18
;                   unos retoques
19
;    version 0.14   10th August 2004
19
;    version 0.14   10th August 2004
20
;                   Mike Hibbett Added setting default colours
20
;                   Mike Hibbett Added setting default colours
21
;    version 0.15   24th August 2006
21
;    version 0.15   24th August 2006
22
;                   diamond (rewritten to function 70)
22
;                   diamond (rewritten to function 70)
23
;
23
;
24
 
24
 
25
               memsize=20000h
25
               memsize=20000h
26
               org 0
26
               org 0
27
 PARAMS     =    memsize - 1024
27
 PARAMS     =    memsize - 1024
28
 
28
 
29
appname equ 'Jpegview '
29
appname equ 'Jpegview '
30
version equ '0.15'
30
version equ '0.15'
31
 
31
 
32
use32
32
use32
33
 
33
 
34
               db     'MENUET01'              ; 8 byte id
34
               db     'MENUET01'              ; 8 byte id
35
               dd     0x01                    ; header version
35
               dd     0x01                    ; header version
36
               dd     START                   ; start of code
36
               dd     START                   ; start of code
37
               dd     I_END                   ; size of image
37
               dd     I_END                   ; size of image
38
               dd     memsize                 ; memory for app
38
               dd     memsize                 ; memory for app
39
               dd     memsize - 1024           ; esp
39
               dd     memsize - 1024           ; esp
40
               dd     PARAMS , 0x0               ; I_Param , I_Icon
40
               dd     PARAMS , 0x0               ; I_Param , I_Icon
41
 
41
 
42
stack_size=4096 + 1024
42
stack_size=4096 + 1024
43
 
43
 
44
include 'macros.inc'
44
include 'macros.inc'
45
 
45
 
46
START:                          ; start of execution
46
START:                          ; start of execution
47
 
47
 
48
    cmp     [PARAMS], byte 0
48
    cmp     [PARAMS], byte 0
49
    jne     check_parameters
49
    jne     check_parameters
50
 
50
 
51
    ; Calculate the 'free' memory available
51
    ; Calculate the 'free' memory available
52
    ; to the application, and create the malloc block from it
52
    ; to the application, and create the malloc block from it
53
  .l1:
53
  .l1:
54
    mov     ecx,memsize-fin-stack_size
54
    mov     ecx,memsize-fin-stack_size
55
    mov     edi,fin
55
    mov     edi,fin
56
    call    add_mem
56
    call    add_mem
57
 
57
 
58
    call    colorprecalc ;inicializa tablas usadas para pasar de ybr a bgr
58
    call    colorprecalc ;inicializa tablas usadas para pasar de ybr a bgr
59
    call    draw_window
59
    call    draw_window
60
    call    read_string.rs_done
60
    call    read_string.rs_done
61
 
61
 
62
still:
62
still:
63
    push still
63
    push still
64
    mov ebx,100                ;1 second
64
    mov ebx,100                ;1 second
65
    mov  eax,23                 ; wait here for event
65
    mov  eax,23                 ; wait here for event
66
    int  0x40
66
    int  0x40
67
    cmp  eax,1                  ; redraw request ?
67
    cmp  eax,1                  ; redraw request ?
68
    je   draw_window
68
    je   draw_window
69
    cmp  eax,2                  ; key in buffer ?
69
    cmp  eax,2                  ; key in buffer ?
70
    je   read_string
70
    je   read_string
71
    cmp  eax,3                  ; button in buffer ?
71
    cmp  eax,3                  ; button in buffer ?
72
    je   button
72
    je   button
73
    jmp display_next
73
    jmp display_next
74
 
74
 
75
button:                       ; BUTTON
75
button:                       ; BUTTON
76
    mov  eax,17
76
    mov  eax,17
77
    int  0x40
77
    int  0x40
78
    cmp ah,3
78
    cmp ah,3
79
    je set_as_bgr2
79
    je set_as_bgr2
80
    cmp ah,2
80
    cmp ah,2
81
    je slideshow
81
    je slideshow
82
    cmp  ah,1                   ; CLOSE PROGRAM
82
    cmp  ah,1                   ; CLOSE PROGRAM
83
    jne  close_program.exit
83
    jne  close_program.exit
84
close_program:
84
close_program:
85
    mov  eax,-1
85
    mov  eax,-1
86
    int  0x40
86
    int  0x40
87
  .exit:
87
  .exit:
88
    ret
88
    ret
89
 
89
 
90
   ; Put a 'chunk' of the image on the window
90
   ; Put a 'chunk' of the image on the window
91
put_image:
91
put_image:
92
    pushad
92
    pushad
93
 
93
 
94
    lea ebp,[edx+eax+7]
94
    lea ebp,[edx+eax+7]
95
    cmp  [winxs],bp
95
    cmp  [winxs],bp
96
    jc     .l1
96
    jc     .l1
97
    lea ebp,[ecx+ebx+20+2+17]
97
    lea ebp,[ecx+ebx+20+2+17]
98
    cmp [winys],bp
98
    cmp [winys],bp
99
    jc     .l1
99
    jc     .l1
100
 
100
 
101
    add     eax,2  ; offset for boarder
101
    add     eax,2  ; offset for boarder
102
    add     ebx,2 ; offset for title bar
102
    add     ebx,2 ; offset for title bar
103
    push    ax ; pox
103
    push    ax ; pox
104
    push    bx ; pos
104
    push    bx ; pos
105
    push    cx ; size
105
    push    cx ; size
106
    push    dx ; size
106
    push    dx ; size
107
    pop     ecx
107
    pop     ecx
108
    pop     edx
108
    pop     edx
109
    mov     ebx,edi
109
    mov     ebx,edi
110
    mov     eax,7
110
    mov     eax,7
111
 
111
 
112
    int     40h                         ; Put image function
112
    int     40h                         ; Put image function
113
.l1:
113
.l1:
114
    popad
114
    popad
115
    ret
115
    ret
116
 
116
 
117
 
117
 
118
 
118
 
119
;******************************************************************************
119
;******************************************************************************
120
 
120
 
121
check_parameters:
121
check_parameters:
122
    cmp     [PARAMS], dword "BOOT" ; received BOOT parameter -> goto handler
122
    cmp     [PARAMS], dword "BOOT" ; received BOOT parameter -> goto handler
123
    je      boot_set_background
123
    je      boot_set_background
124
 
124
 
125
    mov     edi, name_string       ; clear string with file name
125
    mov     edi, name_string       ; clear string with file name
126
    mov     al,  0
126
    mov     al,  0
127
    mov     ecx, 100
127
    mov     ecx, 100
128
    rep     stosb
128
    rep     stosb
129
 
129
 
130
    mov     ecx, 100               ; calculate length of parameter string
130
    mov     ecx, 100               ; calculate length of parameter string
131
    mov     edi, PARAMS
131
    mov     edi, PARAMS
132
    repne   scasb
132
    repne   scasb
133
    sub     edi, PARAMS
133
    sub     edi, PARAMS
134
    mov     ecx, edi
134
    mov     ecx, edi
135
 
135
 
136
    mov     esi, PARAMS            ; copy parameters to file name
136
    mov     esi, PARAMS            ; copy parameters to file name
137
    mov     edi, name_string
137
    mov     edi, name_string
138
    cld
138
    cld
139
    rep     movsb
139
    rep     movsb
140
 
140
 
141
    jmp     START.l1       ; return to beggining of the progra
141
    jmp     START.l1       ; return to beggining of the progra
142
 
142
 
143
;******************************************************************************
143
;******************************************************************************
144
 
144
 
145
 
145
 
146
 
146
 
147
boot_set_background:
147
boot_set_background:
148
 
148
 
149
    mov     ecx,memsize-fin-stack_size  ; size
149
    mov     ecx,memsize-fin-stack_size  ; size
150
    mov     edi,fin                     ; pointer
150
    mov     edi,fin                     ; pointer
151
    call    add_mem             ; mark memory from fin to 0x100000-1024 as free
151
    call    add_mem             ; mark memory from fin to 0x100000-1024 as free
152
    call    colorprecalc        ; calculate colors
152
    call    colorprecalc        ; calculate colors
153
    mov     esi,name_string
153
    mov     esi,name_string
154
    call    open
154
    call    open
155
    test    eax,eax
155
    test    eax,eax
156
    jz      close_program
156
    jz      close_program
157
    call    jpeg_info
157
    call    jpeg_info
158
    mov dword [jpeg_st],ebp
158
    mov dword [jpeg_st],ebp
159
    call    set_as_bgr2         ; set wallpaper
159
    call    set_as_bgr2         ; set wallpaper
160
    jmp     close_program       ; close the program right now
160
    jmp     close_program       ; close the program right now
161
 
161
 
162
;******************************************************************************
162
;******************************************************************************
163
;******************************************************************************
163
;******************************************************************************
164
 
164
 
165
set_as_bgr2:
165
set_as_bgr2:
166
    mov ebp,dword[jpeg_st]
166
    mov ebp,dword[jpeg_st]
167
    test    ebp,ebp
167
    test    ebp,ebp
168
    jz      .end
168
    jz      .end
169
 
-
 
170
    mov     dword [ebp+draw_ptr],put_chunk_to_bgr
-
 
171
    call    jpeg_display
169
    
172
    mov     eax, 15
170
    mov     eax, 15
173
    mov     ebx, 1
171
    mov     ebx, 1
174
    mov     ecx, [ebp + x_size]
172
    mov     ecx, [ebp + x_size]
175
    mov     edx, [ebp + y_size]
173
    mov     edx, [ebp + y_size]
176
    int     0x40
174
    int     0x40
-
 
175
 
-
 
176
    mov     dword [ebp+draw_ptr],put_chunk_to_bgr
-
 
177
    call    jpeg_display
177
 
178
 
178
    ; Stretch the image to fit
179
    ; Stretch the image to fit
179
    mov     eax, 15
180
    mov     eax, 15
180
    mov     ebx, 4
181
    mov     ebx, 4
181
    mov     ecx, 2
182
    mov     ecx, 2
182
    int     0x40
183
    int     0x40
183
 
184
 
184
    mov     eax, 15
185
    mov     eax, 15
185
    mov     ebx, 3
186
    mov     ebx, 3
186
    int     0x40
187
    int     0x40
187
 
188
 
188
 
189
 
189
 .end:
190
 .end:
190
    ret
191
    ret
191
 
192
 
192
;******************************************************************************
193
;******************************************************************************
193
 
194
 
194
put_chunk_to_bgr:
195
put_chunk_to_bgr:
195
    pushad
196
    pushad
196
 
197
 
197
    mov     [x_pointer], edi
198
    mov     [x_pointer], edi
198
    mov     esi, ecx
199
    mov     esi, ecx
199
    imul    esi, 3
200
    imul    esi, 3
200
    mov     [x_numofbytes], esi
201
    mov     [x_numofbytes], esi
201
    mov     ecx, [ebp + x_size]
202
    mov     ecx, [ebp + x_size]
202
    imul    ecx, ebx
203
    imul    ecx, ebx
203
    add     ecx, eax
204
    add     ecx, eax
204
    imul    ecx, 3
205
    imul    ecx, 3
205
    mov     [x_offset], ecx
206
    mov     [x_offset], ecx
206
    mov     [x_counter], edx
207
    mov     [x_counter], edx
207
    mov     eax, [ebp + x_size]
208
    mov     eax, [ebp + x_size]
208
    imul    eax, 3
209
    imul    eax, 3
209
    mov     [x_numofb2], eax
210
    mov     [x_numofb2], eax
210
 .new_string:
211
 .new_string:
211
    mov     eax, 15
212
    mov     eax, 15
212
    mov     ebx, 5
213
    mov     ebx, 5
213
    mov     ecx, [x_pointer]
214
    mov     ecx, [x_pointer]
214
    mov     edx, [x_offset]
215
    mov     edx, [x_offset]
215
    mov     esi, [x_numofbytes]
216
    mov     esi, [x_numofbytes]
216
    int     0x40
217
    int     0x40
217
    mov     eax, [x_numofbytes]
218
    mov     eax, [x_numofbytes]
218
    add     [x_pointer], eax
219
    add     [x_pointer], eax
219
    mov     eax, [x_numofb2]
220
    mov     eax, [x_numofb2]
220
    add     [x_offset], eax
221
    add     [x_offset], eax
221
    dec     [x_counter]
222
    dec     [x_counter]
222
    jnz     .new_string
223
    jnz     .new_string
223
 
224
 
224
    popad
225
    popad
225
    ret
226
    ret
226
 
227
 
227
;******************************************************************************
228
;******************************************************************************
228
 
229
 
229
 
230
 
230
 
231
 
231
;   *********************************************
232
;   *********************************************
232
;   *******  WINDOW DEFINITIONS AND DRAW ********
233
;   *******  WINDOW DEFINITIONS AND DRAW ********
233
;   *********************************************
234
;   *********************************************
234
 
235
 
235
 
236
 
236
draw_window:
237
draw_window:
237
 
238
 
238
    mov  eax,48
239
    mov  eax,48
239
    mov  ebx,3
240
    mov  ebx,3
240
    mov  ecx,sc
241
    mov  ecx,sc
241
    mov  edx,sizeof.system_colors
242
    mov  edx,sizeof.system_colors
242
    int  0x40
243
    int  0x40
243
 
244
 
244
    mov  eax,12
245
    mov  eax,12
245
    mov  ebx,1
246
    mov  ebx,1
246
    int  0x40
247
    int  0x40
247
 
248
 
248
    ; Draw the window to the appropriate size - it may have
249
    ; Draw the window to the appropriate size - it may have
249
    ; been resized by the user
250
    ; been resized by the user
250
    cmp     [winxs], 0
251
    cmp     [winxs], 0
251
    jne     dw_001
252
    jne     dw_001
252
 
253
 
253
    ; Give the screen some inital defaults
254
    ; Give the screen some inital defaults
254
    mov     [winxs], 400
255
    mov     [winxs], 400
255
    mov     [winys], 300
256
    mov     [winys], 300
256
    mov     ax, 100
257
    mov     ax, 100
257
    mov     [winxo], ax
258
    mov     [winxo], ax
258
    mov     [winyo], ax
259
    mov     [winyo], ax
259
    jmp     dw_002
260
    jmp     dw_002
260
 
261
 
261
dw_001:
262
dw_001:
262
    mov     eax, 9
263
    mov     eax, 9
263
    mov ebx, memsize - 1024
264
    mov ebx, memsize - 1024
264
    mov ecx, -1
265
    mov ecx, -1
265
    int     0x40
266
    int     0x40
266
    mov     eax, [ebx + 34]
267
    mov     eax, [ebx + 34]
267
    mov     [winxo], ax
268
    mov     [winxo], ax
268
    mov     eax, [ebx + 38]
269
    mov     eax, [ebx + 38]
269
    mov     [winyo], ax
270
    mov     [winyo], ax
270
    mov     eax, [ebx + 42]
271
    mov     eax, [ebx + 42]
271
    mov     [winxs], ax
272
    mov     [winxs], ax
272
    mov     eax, [ebx + 46]
273
    mov     eax, [ebx + 46]
273
    mov     [winys], ax
274
    mov     [winys], ax
274
 
275
 
275
dw_002:
276
dw_002:
276
        mov     ebx, dword [winxo-2]
277
        mov     ebx, dword [winxo-2]
277
        mov     bx, [winxs]
278
        mov     bx, [winxs]
278
        mov     ecx, dword [winyo-2]
279
        mov     ecx, dword [winyo-2]
279
        mov     cx, [winys]
280
        mov     cx, [winys]
280
 
281
 
281
    xor  eax,eax                   ; DRAW WINDOW
282
    xor  eax,eax                   ; DRAW WINDOW
282
    mov  edx,[sc.work]
283
    mov  edx,[sc.work]
283
    or   edx,0x33000000
284
    or   edx,0x33000000
284
    mov  edi,header                ; WINDOW LABEL
285
    mov  edi,header                ; WINDOW LABEL
285
    int  0x40
286
    int  0x40
286
 
287
 
287
 
288
 
288
    mov  eax,8                     ; BUTTON 2: slideshow
289
    mov  eax,8                     ; BUTTON 2: slideshow
289
    mov  ebx,57
290
    mov  ebx,57
290
    mov  cx, [winys]
291
    mov  cx, [winys]
291
    sub  cx, 39
292
    sub  cx, 39
292
    shl  ecx, 16
293
    shl  ecx, 16
293
    add  ecx, 12
294
    add  ecx, 12
294
    mov  esi, [sc.work_button]
295
    mov  esi, [sc.work_button]
295
    mov  edx,2
296
    mov  edx,2
296
    int  0x40
297
    int  0x40
297
 
298
 
298
    mov  eax,4                     ; Button text
299
    mov  eax,4                     ; Button text
299
    movzx ebx, word [winys]
300
    movzx ebx, word [winys]
300
    add   ebx, 3 shl 16 - 36
301
    add   ebx, 3 shl 16 - 36
301
    mov  ecx,[sc.work_button_text]
302
    mov  ecx,[sc.work_button_text]
302
    mov  edx,setname
303
    mov  edx,setname
303
    mov  esi,setnamelen-setname
304
    mov  esi,setnamelen-setname
304
    int  0x40
305
    int  0x40
305
 
306
 
306
 
307
 
307
    mov  eax,8                     ; BUTTON 3: set as background
308
    mov  eax,8                     ; BUTTON 3: set as background
308
    mov  bx, [winxs]
309
    mov  bx, [winxs]
309
    sub  bx, 65
310
    sub  bx, 65
310
    shl  ebx, 16
311
    shl  ebx, 16
311
    mov  bx,55
312
    mov  bx,55
312
    mov  cx, [winys]
313
    mov  cx, [winys]
313
    sub  cx, 39
314
    sub  cx, 39
314
    shl  ecx, 16
315
    shl  ecx, 16
315
    add  ecx, 12
316
    add  ecx, 12
316
    mov  esi, [sc.work_button]
317
    mov  esi, [sc.work_button]
317
    mov  edx,3
318
    mov  edx,3
318
    int  0x40
319
    int  0x40
319
 
320
 
320
    mov  eax,4                     ; Button text
321
    mov  eax,4                     ; Button text
321
    movzx ebx, word [winxs]
322
    movzx ebx, word [winxs]
322
    sub   ebx, 63
323
    sub   ebx, 63
323
    shl   ebx,16
324
    shl   ebx,16
324
    mov   bx, word [winys]
325
    mov   bx, word [winys]
325
    sub   bx,36
326
    sub   bx,36
326
    mov  ecx,[sc.work_button_text]
327
    mov  ecx,[sc.work_button_text]
327
    mov  edx,setbgr
328
    mov  edx,setbgr
328
    mov  esi,setbgrlen-setbgr
329
    mov  esi,setbgrlen-setbgr
329
    int  0x40
330
    int  0x40
330
    call    print_strings
331
    call    print_strings
331
    call    load_image
332
    call    load_image
332
    mov     eax,12                    ; function 12:tell os about windowdraw
333
    mov     eax,12                    ; function 12:tell os about windowdraw
333
    mov     ebx,2                     ; 2, end of draw
334
    mov     ebx,2                     ; 2, end of draw
334
    int     0x40
335
    int     0x40
335
 
336
 
336
    ret
337
    ret
337
 
338
 
338
 
339
 
339
 
340
 
340
    ; Read in the image file name.
341
    ; Read in the image file name.
341
read_string:
342
read_string:
342
    movzx edi,byte[name_string.cursor]
343
    movzx edi,byte[name_string.cursor]
343
    add     edi,name_string
344
    add     edi,name_string
344
    mov     eax,2
345
    mov     eax,2
345
    int     0x40                        ; Get the key value
346
    int     0x40                        ; Get the key value
346
    shr     eax,8
347
    shr     eax,8
347
    cmp     eax,13                      ; Return key ends input
348
    cmp     eax,13                      ; Return key ends input
348
    je      .rs_done
349
    je      .rs_done
349
    cmp     eax,8
350
    cmp     eax,8
350
    jnz     .nobsl
351
    jnz     .nobsl
351
    cmp     edi,name_string
352
    cmp     edi,name_string
352
    je      .exit
353
    je      .exit
353
    dec     edi
354
    dec     edi
354
    mov     [edi],byte 0;'_'
355
    mov     [edi],byte 0;'_'
355
    dec     byte[name_string.cursor]
356
    dec     byte[name_string.cursor]
356
    jmp     print_strings
357
    jmp     print_strings
357
.exit:   ret
358
.exit:   ret
358
.nobsl:
359
.nobsl:
359
    cmp     eax,31
360
    cmp     eax,31
360
    jbe     .exit
361
    jbe     .exit
361
    cmp     eax,97
362
    cmp     eax,97
362
    jb      .keyok
363
    jb      .keyok
363
    sub     eax,32
364
    sub     eax,32
364
.keyok:
365
.keyok:
365
    mov ah,0
366
    mov ah,0
366
    stosw
367
    stosw
367
    cmp edi,name_string.end
368
    cmp edi,name_string.end
368
    jnc print_strings
369
    jnc print_strings
369
    inc byte[name_string.cursor]
370
    inc byte[name_string.cursor]
370
    jmp    print_strings
371
    jmp    print_strings
371
.rs_done:
372
.rs_done:
372
    call   print_strings
373
    call   print_strings
373
    mov     esi,name_string
374
    mov     esi,name_string
374
    call    open
375
    call    open
375
    test    eax,eax
376
    test    eax,eax
376
    jz      .exit
377
    jz      .exit
377
    call    jpeg_info
378
    call    jpeg_info
378
    test    ebp,ebp
379
    test    ebp,ebp
379
    jz      close
380
    jz      close
380
    xchg    [jpeg_st],ebp
381
    xchg    [jpeg_st],ebp
381
    call jpeg_close
382
    call jpeg_close
382
 
383
 
383
load_image:
384
load_image:
384
 
385
 
385
    mov     eax,13              ; clear picture area
386
    mov     eax,13              ; clear picture area
386
    movzx    ebx, word [winxs]
387
    movzx    ebx, word [winxs]
387
    add     ebx, 1  shl 16 -10
388
    add     ebx, 1  shl 16 -10
388
    movzx    ecx, word [winys]
389
    movzx    ecx, word [winys]
389
    sub     ecx, 40
390
    sub     ecx, 40
390
    add     ecx, 1  shl 16
391
    add     ecx, 1  shl 16
391
 
392
 
392
    mov     edx,[sc.work]
393
    mov     edx,[sc.work]
393
    int     0x40
394
    int     0x40
394
    mov    ebp,[jpeg_st]
395
    mov    ebp,[jpeg_st]
395
    test    ebp,ebp
396
    test    ebp,ebp
396
    jz      .exit
397
    jz      .exit
397
    mov     dword [ebp+draw_ptr],put_image
398
    mov     dword [ebp+draw_ptr],put_image
398
    jmp    jpeg_display
399
    jmp    jpeg_display
399
 .exit: ret
400
 .exit: ret
400
 
401
 
401
print_strings:
402
print_strings:
402
    pusha
403
    pusha
403
    mov     eax,13              ; clear text area
404
    mov     eax,13              ; clear text area
404
    movzx   ebx, word [winxs]
405
    movzx   ebx, word [winxs]
405
    add     ebx, 59 shl 16 -125
406
    add     ebx, 59 shl 16 -125
406
    mov     cx, [winys]
407
    mov     cx, [winys]
407
    sub     cx, 39
408
    sub     cx, 39
408
    shl     ecx, 16
409
    shl     ecx, 16
409
    add     ecx, 12
410
    add     ecx, 12
410
    mov     edx,0xffffff
411
    mov     edx,0xffffff
411
    int     0x40
412
    int     0x40
412
 
413
 
413
    mov     eax,4               ;
414
    mov     eax,4               ;
414
    movzx   ebx, word [winys]
415
    movzx   ebx, word [winys]
415
    add     ebx, 61 shl 16 - 37
416
    add     ebx, 61 shl 16 - 37
416
    mov     ecx,0x000000
417
    mov     ecx,0x000000
417
    mov     edx,name_string
418
    mov     edx,name_string
418
    mov     esi,60
419
    mov     esi,60
419
    int     0x40
420
    int     0x40
420
    popa
421
    popa
421
    ret
422
    ret
422
 
423
 
423
slideshow:
424
slideshow:
424
        cmp     [file_dir], 0
425
        cmp     [file_dir], 0
425
        jnz     .exit
426
        jnz     .exit
426
        cmp     [jpeg_st], 0
427
        cmp     [jpeg_st], 0
427
        jz      .exit
428
        jz      .exit
428
        mov     esi, name_string
429
        mov     esi, name_string
429
        movzx   ecx, byte [name_string.cursor]
430
        movzx   ecx, byte [name_string.cursor]
430
.l1:
431
.l1:
431
        cmp     byte [esi+ecx], '/'
432
        cmp     byte [esi+ecx], '/'
432
        jz      .l2
433
        jz      .l2
433
        loop    .l1
434
        loop    .l1
434
.exit:
435
.exit:
435
        ret
436
        ret
436
.l2:
437
.l2:
437
        mov     byte [esi+ecx], 0
438
        mov     byte [esi+ecx], 0
438
        call    open
439
        call    open
439
        mov     byte [esi+ecx], '/'
440
        mov     byte [esi+ecx], '/'
440
        test    eax, eax
441
        test    eax, eax
441
        jz      .exit
442
        jz      .exit
442
        test    byte [fileattr], 0x10
443
        test    byte [fileattr], 0x10
443
        jz      .exit
444
        jz      .exit
444
        mov     [file_dir], eax
445
        mov     [file_dir], eax
445
        inc     ecx
446
        inc     ecx
446
        mov     [name_string.cursor], cl
447
        mov     [name_string.cursor], cl
447
display_next:
448
display_next:
448
        mov     ebx, [file_dir]
449
        mov     ebx, [file_dir]
449
        test    ebx, ebx
450
        test    ebx, ebx
450
        jnz     @f
451
        jnz     @f
451
        ret
452
        ret
452
@@:
453
@@:
453
        mov     byte [ebx], 1
454
        mov     byte [ebx], 1
454
        mov     byte [ebx+12], 1
455
        mov     byte [ebx+12], 1
455
        mov     dword [ebx+16], dirinfo
456
        mov     dword [ebx+16], dirinfo
456
        mov     eax, 70
457
        mov     eax, 70
457
        int     0x40
458
        int     0x40
458
        mov     eax, [file_dir]
459
        mov     eax, [file_dir]
459
        inc     dword [eax+4]
460
        inc     dword [eax+4]
460
        cmp     ebx, 1
461
        cmp     ebx, 1
461
        jz      @f
462
        jz      @f
462
        mov     eax, [file_dir]
463
        mov     eax, [file_dir]
463
        and     [file_dir], 0
464
        and     [file_dir], 0
464
        jmp     close
465
        jmp     close
465
@@:
466
@@:
466
        movzx   edi, byte [name_string.cursor]
467
        movzx   edi, byte [name_string.cursor]
467
        add     edi, name_string
468
        add     edi, name_string
468
        lea     esi, [dirinfo+32+40]
469
        lea     esi, [dirinfo+32+40]
469
@@:
470
@@:
470
        lodsb
471
        lodsb
471
        stosb
472
        stosb
472
        test    al, al
473
        test    al, al
473
        jnz     @b
474
        jnz     @b
474
        mov     ecx, name_string.end
475
        mov     ecx, name_string.end
475
        sub     ecx, edi
476
        sub     ecx, edi
476
        rep     stosb
477
        rep     stosb
477
    call   print_strings
478
    call   print_strings
478
    mov     esi,name_string
479
    mov     esi,name_string
479
    call    open
480
    call    open
480
    test    eax,eax
481
    test    eax,eax
481
    jz      display_next
482
    jz      display_next
482
    call    jpeg_info
483
    call    jpeg_info
483
    test    ebp,ebp
484
    test    ebp,ebp
484
    jnz     .l6
485
    jnz     .l6
485
    call close
486
    call close
486
    jmp display_next
487
    jmp display_next
487
   .l6:
488
   .l6:
488
    mov dword[ebp+draw_ptr],put_image
489
    mov dword[ebp+draw_ptr],put_image
489
    push ebp
490
    push ebp
490
    xchg [jpeg_st],ebp
491
    xchg [jpeg_st],ebp
491
    call jpeg_close
492
    call jpeg_close
492
    pop ebp
493
    pop ebp
493
    jmp jpeg_display
494
    jmp jpeg_display
494
 
495
 
495
 
496
 
496
include 'filelib.asm'
497
include 'filelib.asm'
497
include 'memlib.asm'
498
include 'memlib.asm'
498
include 'jpeglib.asm'
499
include 'jpeglib.asm'
499
 
500
 
500
 
501
 
501
; DATA AREA
502
; DATA AREA
502
 
503
 
503
wcolor          dd  0x000000
504
wcolor          dd  0x000000
504
header          db  appname,version,0
505
header          db  appname,version,0
505
setname          db  'SLIDESHOW'
506
setname          db  'SLIDESHOW'
506
setnamelen:
507
setnamelen:
507
 
508
 
508
setbgr           db  '   BGR  '
509
setbgr           db  '   BGR  '
509
setbgrlen:
510
setbgrlen:
510
 
511
 
511
x_pointer       dd  0
512
x_pointer       dd  0
512
x_offset        dd  0
513
x_offset        dd  0
513
x_numofbytes    dd  0
514
x_numofbytes    dd  0
514
x_numofb2       dd  0
515
x_numofb2       dd  0
515
x_counter       dd  0
516
x_counter       dd  0
516
winxo           dw  0
517
winxo           dw  0
517
winyo           dw  0
518
winyo           dw  0
518
winxs           dw  0
519
winxs           dw  0
519
winys           dw  0
520
winys           dw  0
520
jpeg_st         dd  0
521
jpeg_st         dd  0
521
file_dir        dd  0
522
file_dir        dd  0
522
name_string:    db '/rd/1/jpegview.jpg',0
523
name_string:    db '/rd/1/jpegview.jpg',0
523
rb 256
524
rb 256
524
    .end:
525
    .end:
525
    .cursor: db 19
526
    .cursor: db 19
526
    .cursor2: db 0
527
    .cursor2: db 0
527
 
528
 
528
align 4
529
align 4
529
 
530
 
530
rgb16:          db 0,4,8,13,17,21,25,29,34,38,42,46,50,55,59,63
531
rgb16:          db 0,4,8,13,17,21,25,29,34,38,42,46,50,55,59,63
531
rgb4:           db 0,21,42,63
532
rgb4:           db 0,21,42,63
532
 
533
 
533
include 'jpegdat.asm'
534
include 'jpegdat.asm'
534
 
535
 
535
align 4
536
align 4
536
 
537
 
537
iniciomemoria:
538
iniciomemoria:
538
              dd -(iniciomemoria+4),-(iniciomemoria+4),(iniciomemoria+4),.l1,0
539
              dd -(iniciomemoria+4),-(iniciomemoria+4),(iniciomemoria+4),.l1,0
539
.l1           dd 0
540
.l1           dd 0
540
 
541
 
541
fin:
542
fin:
542
I_END:
543
I_END:
543
sc     system_colors
544
sc     system_colors
544
fileattr: rb 40
545
fileattr: rb 40
545
dirinfo: rb 32+304
546
dirinfo: rb 32+304