Subversion Repositories Kolibri OS

Rev

Rev 31 | 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
7
; Last changed: September 9, 2004
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
53
    mov  byte[edi],al
54
openfile2:
55
    mov  eax,58
56
    mov  ebx,file_info
57
    int  0x40
58
    cmp  eax,6
59
    je   temp
60
    test eax,eax
61
    jnz  ok2
62
temp:
63
    cmp  ebx,64
64
    jbe  ok2
65
 
66
    and  [entered],0
67
    xor  eax,eax
68
    mov  [imgcount],eax
69
    mov  esi,filename
70
    mov  edi,fn_input
71
    mov  ecx,256  ;[filename_len]
72
    rep  movsb
73
 
74
    mov  edi,fn_input
75
    mov  ecx,50
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:
104
    mov  ebx,DELAY
105
    mov  eax,23
106
    int  0x40
107
 
108
    cmp  eax,1
109
    je   red
110
    cmp  eax,2
111
    je   key
112
    cmp  eax,3
113
    je   button
114
    mov  eax,[imgcount]
115
    cmp  eax,1
116
    je   still
117
    inc  [img_index]
118
    cmp  eax,[img_index]
119
    jne  redsub
120
    and  [img_index],0
121
  redsub:
122
    mov  ecx,[img_index]
123
    call draw_subimage
124
    jmp  still
125
 
126
  key:
127
    mov  eax,2
128
    int  0x40
129
    cmp  ah,13
130
    je   is_input
131
    jmp  still
132
 
133
  button:
134
    mov  eax,17
135
    int  0x40
136
 
137
    cmp  ah,1
138
    jne  noclose
139
  _close:
140
    or   eax,-1
141
    int  0x40
142
 
143
  noclose:
144
  is_input:             ; simple input line with backspace feature
145
    inc  [entered]      ; sorry - no cursor
146
  wait_input:
147
    call draw_input
148
    mov  eax,10
149
    int  0x40
150
    cmp  eax,2
151
    jne  still
152
    mov  edi,[inp_pos]
153
    mov  eax,2
154
    int  0x40
155
    shr  eax,8
156
    cmp  eax,27
157
    je   still
158
    cmp  eax,13
159
    je   openfile
160
    cmp  eax,8
161
    je   backsp
162
    mov  [fn_input+edi],al
163
    inc  [inp_pos]
164
    jmp  wait_input
165
  backsp:
166
    test edi,edi
167
    jz   wait_input
168
    dec  [inp_pos]
169
    jmp  wait_input
170
    jmp  still
171
 
172
;****************************************
173
;******* DRAW CONTENTS OF INPUT LINE ****
174
;****************************************
175
draw_input:
176
    push edi
177
    cmp  [entered],0
178
    jne  highlight
179
    mov  esi,WND_COLOR
180
    jmp  di_draw
181
  highlight:
182
    mov  esi,0xe0e0e0
183
  di_draw:
184
    mov  eax,8
185
    mov  ebx,INP_X
186
    mov  ecx,INP_Y
187
    mov  edx,2
188
    int  0x40
189
    mov  eax,4
190
    mov  ecx,0x00107a30            ; шрифт 1 и цвет ( 0xF0RRGGBB )
191
    mov  ebx,INP_XY
192
    mov  edx,fn_input
193
    mov  esi,[inp_pos]
194
    int  0x40
195
    pop  edi
196
    ret
197
 
198
;   *********************************************
199
;   *******  ОПРЕДЕЛЕНИЕ И ОТРИСОВКА ОКНА *******
200
;   *********************************************
201
 
202
draw_window:
203
 
204
    mov  eax,12
205
    mov  ebx,1
206
    int  0x40
207
 
208
    mov  eax,0
209
    mov  ebx,50*65536+700
210
    mov  ecx,50*65536+500
211
    mov  edx,WND_COLOR
212
    mov  esi,0x805080d0
213
    mov  edi,0x005080d0
214
    int  0x40
215
 
216
 
217
    mov  eax,4
218
    mov  ebx,8*65536+8
219
    mov  ecx,0x10ddeeff
220
    mov  edx,zagolovok
221
    mov  esi,zag_konets-zagolovok
222
    int  0x40
223
 
224
    mov  eax,8
225
    mov  ebx,(700-19)*65536+12
226
    mov  ecx,5*65536+12
227
    mov  edx,1
228
    mov  esi,0x6688dd
229
    int  0x40
230
 
231
    call draw_input
232
 
233
    xor  ecx,ecx
234
    call draw_subimage
235
    cmp  [imgcount],1
236
    je   .enddraw
237
 
238
    mov  ecx,[img_index]
239
    call draw_subimage
240
  .enddraw:
241
    mov  eax,12
242
    mov  ebx,2
243
    int  0x40
244
    ret
245
 
246
draw_subimage:
247
    cmp  [imgcount],0
248
    jz   .enddraw
249
    mov  esi,Image
250
    mov  edi,gif_inf
251
    call GetGIFinfo
252
    test eax,eax
253
    jz   .enddraw
254
    movzx ebx,[gif_inf.Width]
255
    shl  ebx,16
256
    movzx ecx,[gif_inf.Height]
257
    add  ecx,ebx
258
    mov  ebx,eax
259
    movzx  eax,[gif_inf.Top]
260
    movzx  edx,[gif_inf.Left]
261
    shl  edx,16
262
    add  edx,eax
263
    add  edx,10 shl 16 +45
264
    mov  eax,7
265
    int  0x40
266
  .enddraw:
267
    ret
268
 
269
; Здесь находятся данные программы:
270
 
271
; интерфейс программы двуязычный - задайте язык в macros.inc
272
 
273
zagolovok:               ; строка заголовка
274
if lang eq ru
275
     db   'ПРОСМОТР GIF'
276
else
277
     db   'GIF  VIEWER'
278
end if
279
zag_konets:              ; и её конец
280
 
281
inp_pos    dd inp_end-fn_input
282
fn_input:
283
;   db '/hd/1/gif/smileys/sm100000.gif'
284
   db '/rd/1/meos.gif'
285
;    db '/hd/1/1/tex256.gif',0
286
;    db '/rd/1/tex256.gif'
287
inp_end:
288
     rb 256-(inp_end-fn_input)
289
 
290
file_info:
291
   dd 0
292
   dd 0
293
   dd 0x100000/512;0x200000
294
   dd workarea
295
   dd Image;0x100000
296
I_END:  ; конец программы
297
filename:
298
;   db '/hd/1/gif/smileys/sm112000.gif',0
299
;   db '/hd/1/gif/test.gif',0
300
;   db '/hd/1/gif/explode1.gif',0
301
;   db '/hd/1/gif/tapeta.gif',0
302
;   db '/hd/1/gif/meos.gif',0
303
   rb 256
304
;filename_len dd 0
305
entered    rd 1
306
 
307
imgcount  rd 1
308
img_index  rd 1
309
gif_inf  GIF_info
310
 
311
hashtable rd 4096
312
workarea rb 0x100000
313
 
314
Image: