Subversion Repositories Kolibri OS

Rev

Rev 109 | 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
 
11
WND_COLOR equ 0x02aabbcc
12
; input line dimensions
13
INP_X equ 10 shl 16+680
14
INP_Y equ 25 shl 16+16
15
INP_XY equ 15 shl 16+30
16
 
17
use32
18
 
19
  org    0x0
20
 
21
  db     'MENUET01'
22
  dd     0x01
23
  dd     START
24
  dd     I_END
25
  dd     0x300000
26
  dd     0x27fff0
27
  dd     filename ;0x0
28
  dd     0x0
29
 
30
include 'lang.inc'
31
include 'macros.inc' ; decrease code size (optional)
32
;include '/hd/1/meos/debug.inc'
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
185
    mov  esi,WND_COLOR
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
196
    mov  ecx,0x00107a30            ; шрифт 1 и цвет ( 0xF0RRGGBB )
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
 
210
    mov  eax,12
211
    mov  ebx,1
212
    int  0x40
213
 
214
    mov  eax,0
215
    mov  ebx,50*65536+700
216
    mov  ecx,50*65536+500
217
    mov  edx,WND_COLOR
218
    mov  esi,0x805080d0
219
    mov  edi,0x005080d0
220
    int  0x40
221
 
222
 
223
    mov  eax,4
224
    mov  ebx,8*65536+8
225
    mov  ecx,0x10ddeeff
226
    mov  edx,zagolovok
227
    mov  esi,zag_konets-zagolovok
228
    int  0x40
229
 
230
    mov  eax,8
231
    mov  ebx,(700-19)*65536+12
232
    mov  ecx,5*65536+12
233
    mov  edx,1
234
    mov  esi,0x6688dd
235
    int  0x40
236
 
237
    call draw_input
238
 
239
    xor  ecx,ecx
240
    call draw_subimage
241
    cmp  [imgcount],1
242
    je   .enddraw
243
 
244
    mov  ecx,[img_index]
245
    call draw_subimage
246
  .enddraw:
247
    mov  eax,12
248
    mov  ebx,2
249
    int  0x40
250
    ret
251
 
252
draw_subimage:
253
    cmp  [imgcount],0
254
    jz   .enddraw
255
    mov  esi,Image
256
    mov  edi,gif_inf
257
    call GetGIFinfo
258
    test eax,eax
259
    jz   .enddraw
260
    movzx ebx,[gif_inf.Width]
261
    shl  ebx,16
262
    movzx ecx,[gif_inf.Height]
263
    add  ecx,ebx
264
    mov  ebx,eax
265
    movzx  eax,[gif_inf.Top]
266
    movzx  edx,[gif_inf.Left]
267
    shl  edx,16
268
    add  edx,eax
269
    add  edx,10 shl 16 +45
270
    mov  eax,7
271
    int  0x40
272
  .enddraw:
273
    ret
274
 
275
; Здесь находятся данные программы:
276
 
277
; интерфейс программы двуязычный - задайте язык в macros.inc
278
 
279
zagolovok:               ; строка заголовка
280
if lang eq ru
281
     db   'ПРОСМОТР GIF'
282
else
283
     db   'GIF  VIEWER'
284
end if
285
zag_konets:              ; и её конец
286
 
287
inp_pos    dd inp_end-fn_input
288
fn_input:
289
;   db '/hd/1/gif/smileys/sm100000.gif'
290
   db '/rd/1/meos.gif'
291
;    db '/hd/1/1/tex256.gif',0
292
;    db '/rd/1/tex256.gif'
293
inp_end:
294
     rb 256-(inp_end-fn_input)
295
 
296
file_info:
297
   dd 0
298
   dd 0
135 diamond 299
   dd 0
300
   dd 0x100000;0x200000
301
   dd workarea;0x100000
31 halyavin 302
I_END:  ; конец программы
303
filename:
304
;   db '/hd/1/gif/smileys/sm112000.gif',0
305
;   db '/hd/1/gif/test.gif',0
306
;   db '/hd/1/gif/explode1.gif',0
307
;   db '/hd/1/gif/tapeta.gif',0
308
;   db '/hd/1/gif/meos.gif',0
135 diamond 309
   rb 257
31 halyavin 310
;filename_len dd 0
311
entered    rd 1
312
 
313
imgcount  rd 1
314
img_index  rd 1
315
gif_inf  GIF_info
316
 
317
hashtable rd 4096
318
workarea rb 0x100000
319
 
320
Image: