Subversion Repositories Kolibri OS

Rev

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

Rev 529 Rev 552
1
; GIF VIEWER FOR MENUET v1.0
1
; GIF VIEWER FOR MENUET v1.0
2
; Written in pure assembler by Ivushkin Andrey aka Willow
2
; Written in pure assembler by Ivushkin Andrey aka Willow
3
;
3
;
4
; Uses GIF_LITE 2.0
4
; Uses GIF_LITE 2.0
5
;
5
;
6
; Created:      August 31, 2004
6
; Created:      August 31, 2004
7
; Last changed: August 25, 2006
7
; Last changed: August 25, 2006
8
;
8
;
9
; COMPILE WITH FASM
9
; COMPILE WITH FASM
10
 
10
 
11
appname equ 'GIF  VIEWER'
11
appname equ 'GIF  VIEWER'
12
 
12
 
13
; input line dimensions
13
; input line dimensions
14
INP_X equ 5 shl 16+680
14
INP_X equ 5 shl 16+680
15
INP_Y equ 5 shl 16+16
15
INP_Y equ 5 shl 16+16
16
INP_XY equ 10 shl 16+10
16
INP_XY equ 10 shl 16+10
17
 
17
 
18
use32
18
use32
19
 
19
 
20
  org    0x0
20
  org    0x0
21
 
21
 
22
  db     'MENUET01'
22
  db     'MENUET01'
23
  dd     0x01
23
  dd     0x01
24
  dd     START
24
  dd     START
25
  dd     I_END
25
  dd     I_END
26
  dd     0x300000
26
  dd     0x400000
27
  dd     0x27fff0
27
  dd     0x400000
28
  dd     filename ;0x0
28
  dd     filename ;0x0
29
  dd     0x0
29
  dd     0x0
30
 
30
 
31
include 'lang.inc'
31
include 'lang.inc'
32
include '..\..\..\macros.inc' ; decrease code size (optional)
32
include '..\..\..\macros.inc' ; decrease code size (optional)
33
include 'debug.inc'
-
 
34
COLOR_ORDER equ MENUETOS
-
 
35
 
33
 
36
DELAY equ 20         ; animation speed
-
 
37
 
34
COLOR_ORDER equ PALETTE
38
;include '/hd/1/gif/gif_lite.inc'
35
GIF_SUPPORT_INTERLACED = 1
39
include 'gif_lite.inc'
36
include 'gif_lite.inc'
40
 
37
 
41
START:
38
START:
42
    cmp [filename],byte 0
39
    cmp [filename],byte 0
43
    jne openfile2
40
    jne openfile2
44
;    jmp openfile2
41
;    jmp openfile2
45
openfile:
42
openfile:
46
    and  [entered],0
-
 
47
    xor  eax,eax
43
    xor  eax,eax
-
 
44
    mov  [entered], eax
48
    mov  [imgcount],eax
45
    mov  [gif_img_count],eax
49
    mov  esi,fn_input
46
    mov  esi,fn_input
50
    mov  edi,filename
47
    mov  edi,filename
51
    mov  ecx,[inp_pos]
48
    mov  ecx,[inp_pos]
52
    rep  movsb
49
    rep  movsb
53
    stosb
50
    stosb
54
openfile2:
51
openfile2:
55
    mov  eax,70
-
 
56
    mov  ebx,file_info
52
    mov  ebx,file_info
-
 
53
    mov  eax,70
57
    mcall
54
    mcall
58
    cmp  eax,6
55
    cmp  eax,6
59
    je   temp
56
    je   temp
60
    test eax,eax
57
    test eax,eax
61
    jnz  ok2
58
    jnz  ok2
62
temp:
59
temp:
63
;    cmp  ebx,64
60
;    cmp  ebx,64
64
;    jbe  ok2
61
;    jbe  ok2
65
 
-
 
66
    and  [entered],0
62
 
67
    xor  eax,eax
63
    xor  eax,eax
68
    mov  [imgcount],eax
64
    mov  [entered], eax
69
    mov  esi,filename
65
    mov  esi,filename
70
    mov  edi,fn_input
66
    mov  edi,fn_input
71
    mov  ecx,256/4  ;[filename_len]
67
    mov  ecx,256/4  ;[filename_len]
72
    rep  movsd
68
    rep  movsd
73
 
69
 
74
    mov  edi,fn_input
70
    mov  edi,fn_input
75
    mov  ecx,256
71
    mov  ecx,256
76
    xor  eax,eax
-
 
77
    repne scasb
72
    repne scasb
78
    sub  edi,fn_input
73
    sub  edi,fn_input
79
    dec  edi
-
 
80
    mov  [inp_pos],edi
74
    mov  [inp_pos],edi
81
    inc  [inp_pos]
-
 
82
 
75
 
83
;    test eax,eax
76
;    test eax,eax
84
;    jnz  .ok2
77
;    jnz  .ok2
85
;    cmp  ebx,64
78
;    cmp  ebx,64
86
;    jbe  .ok2
79
;    jbe  .ok2
87
    mov  esi,workarea
80
    mov  esi,workarea
88
    mov  edi,Image
81
    mov  edi,Image
89
    mov  eax,hashtable
-
 
90
    call ReadGIF
82
    call ReadGIF
91
    test eax,eax
83
    test eax,eax
92
    jz   .ok
84
    jz   .ok
93
    xor  ecx,ecx
85
    and  [gif_img_count], 0
94
  .ok:
86
  .ok:
95
    mov  [imgcount],ecx
-
 
96
  ok2:
87
  ok2:
97
    and  dword[img_index],0
88
    and  dword[img_index],0
98
 
-
 
99
    mov  eax,48
89
 
100
    mov  ebx,3
90
    mov  ebx,3
101
    mov  ecx,sc
91
    mov  ecx,sc
102
    mov  edx,sizeof.system_colors
92
    mov  edx,sizeof.system_colors
-
 
93
    mov  eax,48
103
    mcall
94
    mcall
104
 
95
 
105
red:
96
red:
-
 
97
 
-
 
98
;   *********************************************
-
 
99
;   *******  Ž…„…‹…ˆ… ˆ Ž’ˆ‘Ž‚Š€ ŽŠ€ *******
-
 
100
;   *********************************************
-
 
101
 
-
 
102
draw_window:
-
 
103
 
-
 
104
    mov  ebx,1
-
 
105
    mov  eax,12
-
 
106
    mcall
-
 
107
 
-
 
108
    xor  eax,eax
-
 
109
    mov  ebx,50*65536+700
-
 
110
    mov  ecx,50*65536+500
-
 
111
    mov  edx,[sc.work]
-
 
112
    or   edx,0x33000000
-
 
113
    mov  edi,title
-
 
114
    mcall
106
 
115
 
-
 
116
    call draw_input
-
 
117
 
-
 
118
    xor  ecx,ecx
-
 
119
    call draw_subimage
-
 
120
    cmp  [gif_img_count],1
-
 
121
    jz   @f
-
 
122
 
-
 
123
    mov  ecx,[img_index]
-
 
124
    call draw_subimage
-
 
125
@@:
-
 
126
 
-
 
127
    mov  ebx,2
-
 
128
    mov  eax,12
107
    call draw_window
129
    mcall
108
 
130
 
109
still:
131
still:
110
        cmp     [imgcount], 1
132
        cmp     [gif_img_count], 1
111
        jnz     .delay
133
        jbe     .infinite
112
        mov     eax, 10
134
        mov     ebx, [cur_anim_delay]
113
        int     0x40
-
 
114
        jmp     @f
-
 
115
.delay:
135
        test    ebx, ebx
116
    mov  ebx,DELAY
136
        jz      .infinite
-
 
137
        mov     eax, 23
-
 
138
        mcall
-
 
139
        jmp     @f
-
 
140
.infinite:
117
    mov  eax,23
141
        mov     eax, 10
118
    mcall
142
        mcall
119
@@:
143
@@:
120
        dec     eax
144
        dec     eax
121
        jz      red
145
        jz      red
122
        dec     eax
146
        dec     eax
123
        jz      key
147
        jz      key
124
        dec     eax
148
        dec     eax
125
        jz      button
149
        jz      button
126
    mov  eax,[imgcount]
150
    mov  eax,[gif_img_count]
127
    cmp  eax,1
151
    cmp  eax,1
128
    je   still
152
    je   still
129
    inc  [img_index]
153
    inc  [img_index]
130
    cmp  eax,[img_index]
154
    cmp  eax,[img_index]
131
    jne  redsub
155
    jne  redsub
132
    and  [img_index],0
156
    and  [img_index],0
133
  redsub:
157
  redsub:
134
    mov  ecx,[img_index]
158
    mov  ecx,[img_index]
135
    call draw_subimage
159
    call draw_subimage
136
    jmp  still
160
    jmp  still
137
 
161
 
138
  key:
162
  key:
139
    mov  eax,2
163
    mov  eax,2
140
    mcall
164
    mcall
141
    cmp  ah,13
165
    cmp  ah,13
142
    je   is_input
166
    je   is_input
143
    jmp  still
167
    jmp  still
144
 
168
 
145
  button:
169
  button:
146
    mov  eax,17
-
 
147
    mcall
170
    mcall 17
148
 
-
 
149
    cmp  ah,1
171
    cmp  ah,1
150
    jne  noclose
172
    jnz  wait_input
-
 
173
 
151
  _close:
174
  _close:
152
    or   eax,-1
175
    or   eax,-1
153
    mcall
176
    mcall
154
 
-
 
155
  noclose:
177
 
156
  is_input:             ; simple input line with backspace feature
178
  is_input:             ; simple input line with backspace feature
157
    inc  [entered]      ; sorry - no cursor
179
    inc  [entered]      ; sorry - no cursor
158
  wait_input:
180
  wait_input:
159
    call draw_input
181
    call draw_input
160
    mov  eax,10
182
    mov  eax,10
161
    mcall
183
    mcall
162
    cmp  eax,2
184
    cmp  al,2
163
    jne  still
185
    jne  still
164
    mov  edi,[inp_pos]
186
    mov  edi,[inp_pos]
165
    mov  eax,2
187
;    mov  eax,2
166
    mcall
188
    mcall
167
    shr  eax,8
189
    shr  eax,8
168
    cmp  eax,27
190
    cmp  al,27
169
    je   still
191
    je   still
170
    cmp  eax,13
192
    cmp  al,13
171
    je   openfile
193
    je   openfile
172
    cmp  eax,8
194
    cmp  al,8
173
    je   backsp
195
    je   backsp
174
    mov  [fn_input+edi],al
196
    mov  [fn_input+edi],al
175
    inc  [inp_pos]
197
    inc  [inp_pos]
176
    jmp  wait_input
198
    jmp  wait_input
177
  backsp:
199
  backsp:
178
    test edi,edi
200
    test edi,edi
179
    jz   wait_input
201
    jz   wait_input
180
    dec  [inp_pos]
202
    dec  [inp_pos]
181
    jmp  wait_input
203
    jmp  wait_input
182
;    jmp  still
204
;    jmp  still
183
 
205
 
184
;****************************************
206
;****************************************
185
;******* DRAW CONTENTS OF INPUT LINE ****
207
;******* DRAW CONTENTS OF INPUT LINE ****
186
;****************************************
208
;****************************************
187
draw_input:
209
draw_input:
188
    push edi
210
    mov  esi,0xe0e0e0
189
    cmp  [entered],0
211
    cmp  [entered],0
190
    jne  highlight
212
    jne  highlight
191
    mov  esi,0x00aabbcc
213
    mov  esi,0x00aabbcc
192
    jmp  di_draw
-
 
193
  highlight:
214
  highlight:
194
    mov  esi,0xe0e0e0
-
 
195
  di_draw:
-
 
196
    mov  eax,8
-
 
197
    mov  ebx,INP_X
-
 
198
    mov  ecx,INP_Y
215
    mov  ecx,INP_Y
199
    mov  edx,2
216
    mov  edx,2
-
 
217
    mov  ebx,INP_X
-
 
218
    mov  eax,8
200
    mcall
219
    mcall
201
    mov  eax,4
-
 
202
    mov  ecx,0x00107a30
220
    mov  ecx,0x00107a30
203
    mov  ebx,INP_XY
-
 
204
    mov  edx,fn_input
221
    mov  edx,fn_input
205
    mov  esi,[inp_pos]
222
    mov  esi,[inp_pos]
206
    mcall
-
 
207
    pop  edi
-
 
208
    ret
-
 
209
 
-
 
210
;   *********************************************
-
 
211
;   *******  Ž…„…‹…ˆ… ˆ Ž’ˆ‘Ž‚Š€ ŽŠ€ *******
-
 
212
;   *********************************************
-
 
213
 
-
 
214
draw_window:
-
 
215
 
-
 
216
    mov  eax,12
-
 
217
    mov  ebx,1
223
    mov  ebx,INP_XY
218
    mcall
-
 
219
 
-
 
220
    mov  eax,0
224
    mov  eax,4
221
    mov  ebx,50*65536+700
-
 
222
    mov  ecx,50*65536+500
-
 
223
    mov  edx,[sc.work]
-
 
224
    or   edx,0x33000000
-
 
225
    mov  edi,title
-
 
226
    mcall
-
 
227
 
-
 
228
    call draw_input
-
 
229
 
-
 
230
    xor  ecx,ecx
-
 
231
    call draw_subimage
-
 
232
    cmp  [imgcount],1
-
 
233
    je   .enddraw
-
 
234
 
-
 
235
    mov  ecx,[img_index]
-
 
236
    call draw_subimage
-
 
237
  .enddraw:
-
 
238
    mov  eax,12
-
 
239
    mov  ebx,2
-
 
240
    mcall
225
    mcall
241
    ret
226
    ret
242
 
227
 
243
draw_subimage:
228
draw_subimage:
244
    cmp  [imgcount],0
229
    cmp  [gif_img_count],0
245
    jz   .enddraw
230
    jz   .enddraw
246
    mov  esi,Image
231
    mov  esi,Image
247
    mov  edi,gif_inf
232
    mov  edi,gif_inf
248
    call GetGIFinfo
233
    call GetGIFinfo
249
    test eax,eax
234
    test eax,eax
250
    jz   .enddraw
235
    jz   .enddraw
251
    movzx ebx,[gif_inf.Width]
236
    mov  ecx, dword [edi+GIF_info.Width-2]
252
    shl  ebx,16
-
 
253
    movzx ecx,[gif_inf.Height]
237
    mov  cx, [edi+GIF_info.Height]
254
    add  ecx,ebx
-
 
255
    mov  ebx,eax
238
    mov  ebx,eax
256
    movzx  eax,[gif_inf.Top]
239
    mov  eax, [edi+GIF_info.Delay]
257
    movzx  edx,[gif_inf.Left]
240
    mov  [cur_anim_delay],eax
258
    shl  edx,16
241
    mov  edx, dword [edi+GIF_info.Left-2]
259
    add  edx,eax
242
    mov  dx, [edi+GIF_info.Top]
260
    add  edx,5 shl 16 +25
243
    add  edx,5 shl 16 +25
-
 
244
    mov  esi, 8
-
 
245
    mov  edi, [edi+GIF_info.Palette]
-
 
246
    xor  ebp, ebp
261
    mov  eax,7
247
    mov  eax, 65
262
    mcall
248
    mcall
263
  .enddraw:
249
  .enddraw:
264
    ret
250
    ret
265
 
251
 
266
; ‡¤¥áì ­ å®¤ïâáï ¤ ­­ë¥ ¯à®£à ¬¬ë:
252
; ‡¤¥áì ­ å®¤ïâáï ¤ ­­ë¥ ¯à®£à ¬¬ë:
267
 
253
 
268
title db appname,0               ; áâப  § £®«®¢ª 
254
title db appname,0               ; áâப  § £®«®¢ª 
269
 
255
 
270
inp_pos    dd inp_end-fn_input
256
inp_pos    dd inp_end-fn_input
271
fn_input:
257
fn_input:
272
;   db '/hd/1/gif/smileys/sm100000.gif'
258
;   db '/hd/1/gif/smileys/sm100000.gif'
273
   db '/sys/meos.gif'
259
   db '/sys/meos.gif'
274
;    db '/hd/1/1/tex256.gif',0
260
;    db '/hd/1/1/tex256.gif',0
275
;    db '/rd/1/tex256.gif'
261
;    db '/rd/1/tex256.gif'
276
inp_end:
262
inp_end:
277
     rb 256-(inp_end-fn_input)
263
     rb 256-(inp_end-fn_input)
278
 
264
 
279
file_info:
265
file_info:
280
   dd 0
266
   dd 0
281
   dd 0
267
   dd 0
282
   dd 0
268
   dd 0
283
   dd 0x100000;0x200000
269
   dd 0x100000;0x200000
284
   dd workarea;0x100000
270
   dd workarea;0x100000
285
I_END:  ; ª®­¥æ ¯à®£à ¬¬ë
271
I_END:  ; ª®­¥æ ¯à®£à ¬¬ë
286
filename:
272
filename:
287
;   db '/hd/1/gif/smileys/sm112000.gif',0
273
;   db '/hd/1/gif/smileys/sm112000.gif',0
288
;   db '/hd/1/gif/test.gif',0
274
;   db '/hd/1/gif/test.gif',0
289
;   db '/hd/1/gif/explode1.gif',0
275
;   db '/hd/1/gif/explode1.gif',0
290
;   db '/hd/1/gif/tapeta.gif',0
276
;   db '/hd/1/gif/tapeta.gif',0
291
;   db '/hd/1/gif/meos.gif',0
277
;   db '/hd/1/gif/meos.gif',0
292
   rb 257
278
   rb 257
293
;filename_len dd 0
279
;filename_len dd 0
-
 
280
 
294
entered    rd 1
281
entered    rd 1
295
sc system_colors
282
sc system_colors
296
 
283
 
-
 
284
gif_img_count  rd 1
297
imgcount  rd 1
285
cur_anim_delay rd 1
298
img_index  rd 1
286
img_index  rd 1
299
gif_inf  GIF_info
287
gif_inf  GIF_info
300
 
288
 
-
 
289
IncludeUGlobals
301
hashtable rd 4096
290
 
302
workarea rb 0x100000
291
workarea rb 0x100000
303
 
292
 
304
Image:
293
Image: