Subversion Repositories Kolibri OS

Rev

Rev 135 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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