Rev 470 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 470 | Rev 485 | ||
---|---|---|---|
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 | mcall |
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 | mcall |
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 | mcall |
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 | mcall ; 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 | 169 | ||
170 | mov eax, 15 |
170 | mov eax, 15 |
171 | mov ebx, 1 |
171 | mov ebx, 1 |
172 | mov ecx, [ebp + x_size] |
172 | mov ecx, [ebp + x_size] |
173 | mov edx, [ebp + y_size] |
173 | mov edx, [ebp + y_size] |
174 | int 0x40 |
174 | mcall |
175 | 175 | ||
176 | mov dword [ebp+draw_ptr],put_chunk_to_bgr |
176 | mov dword [ebp+draw_ptr],put_chunk_to_bgr |
177 | call jpeg_display |
177 | call jpeg_display |
178 | 178 | ||
179 | ; Stretch the image to fit |
179 | ; Stretch the image to fit |
180 | mov eax, 15 |
180 | mov eax, 15 |
181 | mov ebx, 4 |
181 | mov ebx, 4 |
182 | mov ecx, 2 |
182 | mov ecx, 2 |
183 | int 0x40 |
183 | mcall |
184 | 184 | ||
185 | mov eax, 15 |
185 | mov eax, 15 |
186 | mov ebx, 3 |
186 | mov ebx, 3 |
187 | int 0x40 |
187 | mcall |
188 | 188 | ||
189 | 189 | ||
190 | .end: |
190 | .end: |
191 | ret |
191 | ret |
192 | 192 | ||
193 | ;****************************************************************************** |
193 | ;****************************************************************************** |
194 | 194 | ||
195 | put_chunk_to_bgr: |
195 | put_chunk_to_bgr: |
196 | pushad |
196 | pushad |
197 | 197 | ||
198 | mov [x_pointer], edi |
198 | mov [x_pointer], edi |
199 | mov esi, ecx |
199 | mov esi, ecx |
200 | imul esi, 3 |
200 | imul esi, 3 |
201 | mov [x_numofbytes], esi |
201 | mov [x_numofbytes], esi |
202 | mov ecx, [ebp + x_size] |
202 | mov ecx, [ebp + x_size] |
203 | imul ecx, ebx |
203 | imul ecx, ebx |
204 | add ecx, eax |
204 | add ecx, eax |
205 | imul ecx, 3 |
205 | imul ecx, 3 |
206 | mov [x_offset], ecx |
206 | mov [x_offset], ecx |
207 | mov [x_counter], edx |
207 | mov [x_counter], edx |
208 | mov eax, [ebp + x_size] |
208 | mov eax, [ebp + x_size] |
209 | imul eax, 3 |
209 | imul eax, 3 |
210 | mov [x_numofb2], eax |
210 | mov [x_numofb2], eax |
211 | .new_string: |
211 | .new_string: |
212 | mov eax, 15 |
212 | mov eax, 15 |
213 | mov ebx, 5 |
213 | mov ebx, 5 |
214 | mov ecx, [x_pointer] |
214 | mov ecx, [x_pointer] |
215 | mov edx, [x_offset] |
215 | mov edx, [x_offset] |
216 | mov esi, [x_numofbytes] |
216 | mov esi, [x_numofbytes] |
217 | int 0x40 |
217 | mcall |
218 | mov eax, [x_numofbytes] |
218 | mov eax, [x_numofbytes] |
219 | add [x_pointer], eax |
219 | add [x_pointer], eax |
220 | mov eax, [x_numofb2] |
220 | mov eax, [x_numofb2] |
221 | add [x_offset], eax |
221 | add [x_offset], eax |
222 | dec [x_counter] |
222 | dec [x_counter] |
223 | jnz .new_string |
223 | jnz .new_string |
224 | 224 | ||
225 | popad |
225 | popad |
226 | ret |
226 | ret |
227 | 227 | ||
228 | ;****************************************************************************** |
228 | ;****************************************************************************** |
229 | 229 | ||
230 | 230 | ||
231 | 231 | ||
232 | ; ********************************************* |
232 | ; ********************************************* |
233 | ; ******* WINDOW DEFINITIONS AND DRAW ******** |
233 | ; ******* WINDOW DEFINITIONS AND DRAW ******** |
234 | ; ********************************************* |
234 | ; ********************************************* |
235 | 235 | ||
236 | 236 | ||
237 | draw_window: |
237 | draw_window: |
238 | 238 | ||
239 | mov eax,48 |
239 | mov eax,48 |
240 | mov ebx,3 |
240 | mov ebx,3 |
241 | mov ecx,sc |
241 | mov ecx,sc |
242 | mov edx,sizeof.system_colors |
242 | mov edx,sizeof.system_colors |
243 | int 0x40 |
243 | mcall |
244 | 244 | ||
245 | mov eax,12 |
245 | mov eax,12 |
246 | mov ebx,1 |
246 | mov ebx,1 |
247 | int 0x40 |
247 | mcall |
248 | 248 | ||
249 | ; Draw the window to the appropriate size - it may have |
249 | ; Draw the window to the appropriate size - it may have |
250 | ; been resized by the user |
250 | ; been resized by the user |
251 | cmp [winxs], 0 |
251 | cmp [winxs], 0 |
252 | jne dw_001 |
252 | jne dw_001 |
253 | 253 | ||
254 | ; Give the screen some inital defaults |
254 | ; Give the screen some inital defaults |
255 | mov [winxs], 400 |
255 | mov [winxs], 400 |
256 | mov [winys], 300 |
256 | mov [winys], 300 |
257 | mov ax, 100 |
257 | mov ax, 100 |
258 | mov [winxo], ax |
258 | mov [winxo], ax |
259 | mov [winyo], ax |
259 | mov [winyo], ax |
260 | jmp dw_002 |
260 | jmp dw_002 |
261 | 261 | ||
262 | dw_001: |
262 | dw_001: |
263 | mov eax, 9 |
263 | mov eax, 9 |
264 | mov ebx, memsize - 1024 |
264 | mov ebx, memsize - 1024 |
265 | mov ecx, -1 |
265 | mov ecx, -1 |
266 | int 0x40 |
266 | mcall |
267 | mov eax, [ebx + 34] |
267 | mov eax, [ebx + 34] |
268 | mov [winxo], ax |
268 | mov [winxo], ax |
269 | mov eax, [ebx + 38] |
269 | mov eax, [ebx + 38] |
270 | mov [winyo], ax |
270 | mov [winyo], ax |
271 | mov eax, [ebx + 42] |
271 | mov eax, [ebx + 42] |
272 | mov [winxs], ax |
272 | mov [winxs], ax |
273 | mov eax, [ebx + 46] |
273 | mov eax, [ebx + 46] |
274 | mov [winys], ax |
274 | mov [winys], ax |
275 | 275 | ||
276 | dw_002: |
276 | dw_002: |
277 | mov ebx, dword [winxo-2] |
277 | mov ebx, dword [winxo-2] |
278 | mov bx, [winxs] |
278 | mov bx, [winxs] |
279 | mov ecx, dword [winyo-2] |
279 | mov ecx, dword [winyo-2] |
280 | mov cx, [winys] |
280 | mov cx, [winys] |
281 | 281 | ||
282 | xor eax,eax ; DRAW WINDOW |
282 | xor eax,eax ; DRAW WINDOW |
283 | mov edx,[sc.work] |
283 | mov edx,[sc.work] |
284 | or edx,0x33000000 |
284 | or edx,0x33000000 |
285 | mov edi,header ; WINDOW LABEL |
285 | mov edi,title ; WINDOW LABEL |
286 | int 0x40 |
286 | mcall |
287 | 287 | ||
288 | 288 | ||
289 | mov eax,8 ; BUTTON 2: slideshow |
289 | mov eax,8 ; BUTTON 2: slideshow |
290 | mov ebx,57 |
290 | mov ebx,57 |
291 | mov cx, [winys] |
291 | mov cx, [winys] |
292 | sub cx, 39 |
292 | sub cx, 39 |
293 | shl ecx, 16 |
293 | shl ecx, 16 |
294 | add ecx, 12 |
294 | add ecx, 12 |
295 | mov esi, [sc.work_button] |
295 | mov esi, [sc.work_button] |
296 | mov edx,2 |
296 | mov edx,2 |
297 | int 0x40 |
297 | mcall |
298 | 298 | ||
299 | mov eax,4 ; Button text |
299 | mov eax,4 ; Button text |
300 | movzx ebx, word [winys] |
300 | movzx ebx, word [winys] |
301 | add ebx, 3 shl 16 - 36 |
301 | add ebx, 3 shl 16 - 36 |
302 | mov ecx,[sc.work_button_text] |
302 | mov ecx,[sc.work_button_text] |
303 | mov edx,setname |
303 | mov edx,setname |
304 | mov esi,setnamelen-setname |
304 | mov esi,setnamelen-setname |
305 | int 0x40 |
305 | mcall |
306 | 306 | ||
307 | 307 | ||
308 | mov eax,8 ; BUTTON 3: set as background |
308 | mov eax,8 ; BUTTON 3: set as background |
309 | mov bx, [winxs] |
309 | mov bx, [winxs] |
310 | sub bx, 65 |
310 | sub bx, 65 |
311 | shl ebx, 16 |
311 | shl ebx, 16 |
312 | mov bx,55 |
312 | mov bx,55 |
313 | mov cx, [winys] |
313 | mov cx, [winys] |
314 | sub cx, 39 |
314 | sub cx, 39 |
315 | shl ecx, 16 |
315 | shl ecx, 16 |
316 | add ecx, 12 |
316 | add ecx, 12 |
317 | mov esi, [sc.work_button] |
317 | mov esi, [sc.work_button] |
318 | mov edx,3 |
318 | mov edx,3 |
319 | int 0x40 |
319 | mcall |
320 | 320 | ||
321 | mov eax,4 ; Button text |
321 | mov eax,4 ; Button text |
322 | movzx ebx, word [winxs] |
322 | movzx ebx, word [winxs] |
323 | sub ebx, 63 |
323 | sub ebx, 63 |
324 | shl ebx,16 |
324 | shl ebx,16 |
325 | mov bx, word [winys] |
325 | mov bx, word [winys] |
326 | sub bx,36 |
326 | sub bx,36 |
327 | mov ecx,[sc.work_button_text] |
327 | mov ecx,[sc.work_button_text] |
328 | mov edx,setbgr |
328 | mov edx,setbgr |
329 | mov esi,setbgrlen-setbgr |
329 | mov esi,setbgrlen-setbgr |
330 | int 0x40 |
330 | mcall |
331 | call print_strings |
331 | call print_strings |
332 | call load_image |
332 | call load_image |
333 | mov eax,12 ; function 12:tell os about windowdraw |
333 | mov eax,12 ; function 12:tell os about windowdraw |
334 | mov ebx,2 ; 2, end of draw |
334 | mov ebx,2 ; 2, end of draw |
335 | int 0x40 |
335 | mcall |
336 | 336 | ||
337 | ret |
337 | ret |
338 | 338 | ||
339 | 339 | ||
340 | 340 | ||
341 | ; Read in the image file name. |
341 | ; Read in the image file name. |
342 | read_string: |
342 | read_string: |
343 | movzx edi,byte[name_string.cursor] |
343 | movzx edi,byte[name_string.cursor] |
344 | add edi,name_string |
344 | add edi,name_string |
345 | mov eax,2 |
345 | mov eax,2 |
346 | int 0x40 ; Get the key value |
346 | mcall ; Get the key value |
347 | shr eax,8 |
347 | shr eax,8 |
348 | cmp eax,13 ; Return key ends input |
348 | cmp eax,13 ; Return key ends input |
349 | je .rs_done |
349 | je .rs_done |
350 | cmp eax,8 |
350 | cmp eax,8 |
351 | jnz .nobsl |
351 | jnz .nobsl |
352 | cmp edi,name_string |
352 | cmp edi,name_string |
353 | je .exit |
353 | je .exit |
354 | dec edi |
354 | dec edi |
355 | mov [edi],byte 0;'_' |
355 | mov [edi],byte 0;'_' |
356 | dec byte[name_string.cursor] |
356 | dec byte[name_string.cursor] |
357 | jmp print_strings |
357 | jmp print_strings |
358 | .exit: ret |
358 | .exit: ret |
359 | .nobsl: |
359 | .nobsl: |
360 | cmp eax,31 |
360 | cmp eax,31 |
361 | jbe .exit |
361 | jbe .exit |
362 | cmp eax,97 |
362 | cmp eax,97 |
363 | jb .keyok |
363 | jb .keyok |
364 | sub eax,32 |
364 | sub eax,32 |
365 | .keyok: |
365 | .keyok: |
366 | mov ah,0 |
366 | mov ah,0 |
367 | stosw |
367 | stosw |
368 | cmp edi,name_string.end |
368 | cmp edi,name_string.end |
369 | jnc print_strings |
369 | jnc print_strings |
370 | inc byte[name_string.cursor] |
370 | inc byte[name_string.cursor] |
371 | jmp print_strings |
371 | jmp print_strings |
372 | .rs_done: |
372 | .rs_done: |
373 | call print_strings |
373 | call print_strings |
374 | mov esi,name_string |
374 | mov esi,name_string |
375 | call open |
375 | call open |
376 | test eax,eax |
376 | test eax,eax |
377 | jz .exit |
377 | jz .exit |
378 | call jpeg_info |
378 | call jpeg_info |
379 | test ebp,ebp |
379 | test ebp,ebp |
380 | jz close |
380 | jz close |
381 | xchg [jpeg_st],ebp |
381 | xchg [jpeg_st],ebp |
382 | call jpeg_close |
382 | call jpeg_close |
383 | 383 | ||
384 | load_image: |
384 | load_image: |
385 | 385 | ||
386 | mov eax,13 ; clear picture area |
386 | mov eax,13 ; clear picture area |
387 | movzx ebx, word [winxs] |
387 | movzx ebx, word [winxs] |
388 | add ebx, 1 shl 16 -10 |
388 | add ebx, 1 shl 16 -10 |
389 | movzx ecx, word [winys] |
389 | movzx ecx, word [winys] |
390 | sub ecx, 40 |
390 | sub ecx, 40 |
391 | add ecx, 1 shl 16 |
391 | add ecx, 1 shl 16 |
392 | 392 | ||
393 | mov edx,[sc.work] |
393 | mov edx,[sc.work] |
394 | int 0x40 |
394 | mcall |
395 | mov ebp,[jpeg_st] |
395 | mov ebp,[jpeg_st] |
396 | test ebp,ebp |
396 | test ebp,ebp |
397 | jz .exit |
397 | jz .exit |
398 | mov dword [ebp+draw_ptr],put_image |
398 | mov dword [ebp+draw_ptr],put_image |
399 | jmp jpeg_display |
399 | jmp jpeg_display |
400 | .exit: ret |
400 | .exit: ret |
401 | 401 | ||
402 | print_strings: |
402 | print_strings: |
403 | pusha |
403 | pusha |
404 | mov eax,13 ; clear text area |
404 | mov eax,13 ; clear text area |
405 | movzx ebx, word [winxs] |
405 | movzx ebx, word [winxs] |
406 | add ebx, 59 shl 16 -125 |
406 | add ebx, 59 shl 16 -125 |
407 | mov cx, [winys] |
407 | mov cx, [winys] |
408 | sub cx, 39 |
408 | sub cx, 39 |
409 | shl ecx, 16 |
409 | shl ecx, 16 |
410 | add ecx, 12 |
410 | add ecx, 12 |
411 | mov edx,0xffffff |
411 | mov edx,0xffffff |
412 | int 0x40 |
412 | mcall |
413 | 413 | ||
414 | mov eax,4 ; |
414 | mov eax,4 ; |
415 | movzx ebx, word [winys] |
415 | movzx ebx, word [winys] |
416 | add ebx, 61 shl 16 - 37 |
416 | add ebx, 61 shl 16 - 37 |
417 | mov ecx,0x000000 |
417 | mov ecx,0x000000 |
418 | mov edx,name_string |
418 | mov edx,name_string |
419 | mov esi,60 |
419 | mov esi,60 |
420 | int 0x40 |
420 | mcall |
421 | popa |
421 | popa |
422 | ret |
422 | ret |
423 | 423 | ||
424 | slideshow: |
424 | slideshow: |
425 | cmp [file_dir], 0 |
425 | cmp [file_dir], 0 |
426 | jnz .exit |
426 | jnz .exit |
427 | cmp [jpeg_st], 0 |
427 | cmp [jpeg_st], 0 |
428 | jz .exit |
428 | jz .exit |
429 | mov esi, name_string |
429 | mov esi, name_string |
430 | movzx ecx, byte [name_string.cursor] |
430 | movzx ecx, byte [name_string.cursor] |
431 | .l1: |
431 | .l1: |
432 | cmp byte [esi+ecx], '/' |
432 | cmp byte [esi+ecx], '/' |
433 | jz .l2 |
433 | jz .l2 |
434 | loop .l1 |
434 | loop .l1 |
435 | .exit: |
435 | .exit: |
436 | ret |
436 | ret |
437 | .l2: |
437 | .l2: |
438 | mov byte [esi+ecx], 0 |
438 | mov byte [esi+ecx], 0 |
439 | call open |
439 | call open |
440 | mov byte [esi+ecx], '/' |
440 | mov byte [esi+ecx], '/' |
441 | test eax, eax |
441 | test eax, eax |
442 | jz .exit |
442 | jz .exit |
443 | test byte [fileattr], 0x10 |
443 | test byte [fileattr], 0x10 |
444 | jz .exit |
444 | jz .exit |
445 | mov [file_dir], eax |
445 | mov [file_dir], eax |
446 | inc ecx |
446 | inc ecx |
447 | mov [name_string.cursor], cl |
447 | mov [name_string.cursor], cl |
448 | display_next: |
448 | display_next: |
449 | mov ebx, [file_dir] |
449 | mov ebx, [file_dir] |
450 | test ebx, ebx |
450 | test ebx, ebx |
451 | jnz @f |
451 | jnz @f |
452 | ret |
452 | ret |
453 | @@: |
453 | @@: |
454 | mov byte [ebx], 1 |
454 | mov byte [ebx], 1 |
455 | mov byte [ebx+12], 1 |
455 | mov byte [ebx+12], 1 |
456 | mov dword [ebx+16], dirinfo |
456 | mov dword [ebx+16], dirinfo |
457 | mov eax, 70 |
457 | mov eax, 70 |
458 | int 0x40 |
458 | mcall |
459 | mov eax, [file_dir] |
459 | mov eax, [file_dir] |
460 | inc dword [eax+4] |
460 | inc dword [eax+4] |
461 | cmp ebx, 1 |
461 | cmp ebx, 1 |
462 | jz @f |
462 | jz @f |
463 | mov eax, [file_dir] |
463 | mov eax, [file_dir] |
464 | and [file_dir], 0 |
464 | and [file_dir], 0 |
465 | jmp close |
465 | jmp close |
466 | @@: |
466 | @@: |
467 | movzx edi, byte [name_string.cursor] |
467 | movzx edi, byte [name_string.cursor] |
468 | add edi, name_string |
468 | add edi, name_string |
469 | lea esi, [dirinfo+32+40] |
469 | lea esi, [dirinfo+32+40] |
470 | @@: |
470 | @@: |
471 | lodsb |
471 | lodsb |
472 | stosb |
472 | stosb |
473 | test al, al |
473 | test al, al |
474 | jnz @b |
474 | jnz @b |
475 | mov ecx, name_string.end |
475 | mov ecx, name_string.end |
476 | sub ecx, edi |
476 | sub ecx, edi |
477 | rep stosb |
477 | rep stosb |
478 | call print_strings |
478 | call print_strings |
479 | mov esi,name_string |
479 | mov esi,name_string |
480 | call open |
480 | call open |
481 | test eax,eax |
481 | test eax,eax |
482 | jz display_next |
482 | jz display_next |
483 | call jpeg_info |
483 | call jpeg_info |
484 | test ebp,ebp |
484 | test ebp,ebp |
485 | jnz .l6 |
485 | jnz .l6 |
486 | call close |
486 | call close |
487 | jmp display_next |
487 | jmp display_next |
488 | .l6: |
488 | .l6: |
489 | mov dword[ebp+draw_ptr],put_image |
489 | mov dword[ebp+draw_ptr],put_image |
490 | push ebp |
490 | push ebp |
491 | xchg [jpeg_st],ebp |
491 | xchg [jpeg_st],ebp |
492 | call jpeg_close |
492 | call jpeg_close |
493 | pop ebp |
493 | pop ebp |
494 | jmp jpeg_display |
494 | jmp jpeg_display |
495 | 495 | ||
496 | 496 | ||
497 | include 'filelib.asm' |
497 | include 'filelib.asm' |
498 | include 'memlib.asm' |
498 | include 'memlib.asm' |
499 | include 'jpeglib.asm' |
499 | include 'jpeglib.asm' |
500 | 500 | ||
501 | 501 | ||
502 | ; DATA AREA |
502 | ; DATA AREA |
503 | 503 | ||
504 | wcolor dd 0x000000 |
504 | wcolor dd 0x000000 |
505 | header db appname,version,0 |
505 | title db appname,version,0 |
506 | setname db 'SLIDESHOW' |
506 | setname db 'SLIDESHOW' |
507 | setnamelen: |
507 | setnamelen: |
508 | 508 | ||
509 | setbgr db ' BGR ' |
509 | setbgr db ' BGR ' |
510 | setbgrlen: |
510 | setbgrlen: |
511 | 511 | ||
512 | x_pointer dd 0 |
512 | x_pointer dd 0 |
513 | x_offset dd 0 |
513 | x_offset dd 0 |
514 | x_numofbytes dd 0 |
514 | x_numofbytes dd 0 |
515 | x_numofb2 dd 0 |
515 | x_numofb2 dd 0 |
516 | x_counter dd 0 |
516 | x_counter dd 0 |
517 | winxo dw 0 |
517 | winxo dw 0 |
518 | winyo dw 0 |
518 | winyo dw 0 |
519 | winxs dw 0 |
519 | winxs dw 0 |
520 | winys dw 0 |
520 | winys dw 0 |
521 | jpeg_st dd 0 |
521 | jpeg_st dd 0 |
522 | file_dir dd 0 |
522 | file_dir dd 0 |
523 | name_string: db '/rd/1/jpegview.jpg',0 |
523 | name_string: db '/rd/1/jpegview.jpg',0 |
524 | rb 256 |
524 | rb 256 |
525 | .end: |
525 | .end: |
526 | .cursor: db 19 |
526 | .cursor: db 19 |
527 | .cursor2: db 0 |
527 | .cursor2: db 0 |
528 | 528 | ||
529 | align 4 |
529 | align 4 |
530 | 530 | ||
531 | 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 |
532 | rgb4: db 0,21,42,63 |
532 | rgb4: db 0,21,42,63 |
533 | 533 | ||
534 | include 'jpegdat.asm' |
534 | include 'jpegdat.asm' |
535 | 535 | ||
536 | align 4 |
536 | align 4 |
537 | 537 | ||
538 | iniciomemoria: |
538 | iniciomemoria: |
539 | dd -(iniciomemoria+4),-(iniciomemoria+4),(iniciomemoria+4),.l1,0 |
539 | dd -(iniciomemoria+4),-(iniciomemoria+4),(iniciomemoria+4),.l1,0 |
540 | .l1 dd 0 |
540 | .l1 dd 0 |
541 | 541 | ||
542 | fin: |
542 | fin: |
543 | I_END: |
543 | I_END: |
544 | sc system_colors |
544 | sc system_colors |
545 | fileattr: rb 40 |
545 | fileattr: rb 40 |
546 | dirinfo: rb 32+304 |
546 | dirinfo: rb 32+304 |