Subversion Repositories Kolibri OS

Rev

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

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