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