-
Notifications
You must be signed in to change notification settings - Fork 0
/
FLI2.PAS
368 lines (350 loc) · 5.43 KB
/
FLI2.PAS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
unit fli2;
interface
procedure show_fli(spd:word);
implementation
uses dos,crt,drk_vga,drk_pcx;
type start_struc=record
startx:word;starty:byte;
stopx:word;stopy:byte;
bytes:word;
end;
{8 bytes}
com_struc=record
startx:word;starty:byte;
stopx:word;stopy:byte;
bytes:word;
bc: word;
end;
type buf_struc=record
s:word;
l:byte
end;
var s: start_struc;
t: array[1..75] of com_struc;
f: file of start_struc;
i: file of com_struc;
g: file of byte;
h,j: file;
a:string;c,z:word;
buf: array[0..14000] of byte;
com: array[0..6000] of byte;
{mem}
m1,m2,m3,m4:pointer;
ind:word;
buf_ind:byte;
cur_buf:word;
change: array[1..5] of buf_struc;
idc: string[54];
k,k1,k2: com_struc;
const id:string[54]='K-Boom vid file,format by M.Richtarsky,anim by unknown';
procedure show_vid2(spd:word);
var bb,e,f,a,b,d,a1,b1,d1: word;
m:byte;
s1,s2: word;
procedure decompress_com;
var b: word;
begin
b:=t[z].bc;
asm
mov si, offset com
mov di, offset buf
xor bx, bx
xor ch, ch
mov dx,[b]
@loop:
mov al, [si+bx]
cmp al, 253
je @sp
mov [di], al
inc bx
inc di
dec dx
jnz @loop
jmp @end
@sp:
mov al, [si+bx+1]
mov cl, [si+bx+2]
add bx, 3
rep stosb
sub dx, 3
jnz @loop
@end:
end;
end;
begin
k.startx:=0;k.stopx:=0;k.starty:=0;k.stopy:=0;
s1:=16000;s2:=0;
buf_ind:=1;
for z:=1 to 75 do begin
if change[buf_ind].l=z then begin
cur_buf:=change[buf_ind].s;
ind:=0;
inc(buf_ind);
end;
k2:=k1;
k1:=k;
k:=t[z];
asm
push ds
mov si, offset k
add si, 8
mov cx, [si]
mov si, ind
mov di, offset com
mov ax, ds
mov es, ax
mov ax, cur_buf
mov ds, ax
shr cx, 1
jnc @w
movsb
@w:
rep movsw
pop ds
end;
move(mem[cur_buf:ind],com[0],k.bc);
ind:=ind+k.bc;
decompress_com;
a:=k2.starty*320+k2.startx;
b:=k2.stopx-k2.startx+1;
d:=k2.stopy-k2.starty;
a1:=k.starty*320+k.startx;
{startofs}
b1:=k.stopx-k.startx+1;
bb:=b1;
{width}
d1:=k.stopy-k.starty;
{height}
port[$3c4]:=2;
port[$3c5]:=$f;
asm
mov ax, $a000
mov es, ax
mov di, a
shr di, 2
add di, s1
mov dx, 320
sub dx, [b]
shr dx, 2
xor ax, ax
mov bx, [b]
shr bx, 2
@ll:
mov cx, bx
shr cx, 1
jnc @t
stosb
@t:
rep stosw
add di, dx
dec [d]
jnz @ll
mov m, 1
mov cx, a1
and cx, 3
shl m, cl
mov ax, $a000
mov es, ax
mov si, offset buf
mov di, s1
mov ax, [a1]
shr ax, 2
add di, ax
mov dx, $3c4
mov al, 2
out dx, al
mov al, m
and al, 15
inc dx
out dx, al
mov bx, [d1]
mov dx, 320
sub dx, [bb]
shr dx, 2
mov cx, [bb]
shr cx, 2
push cx
@l:
movsb
add si, 3
dec cx
jnz @l
pop cx
push cx
add di, dx
dec bx
jnz @l
pop cx
shl m, 1
and m, 15
cmp m, 0
jne @w1
inc m
add a1, 4
@w1:
mov si, offset buf
inc si
mov di, s1
mov ax, [a1]
shr ax, 2
add di, ax
mov dx, $3c4
mov al, 2
out dx, al
mov al, m
and al, 15
inc dx
out dx, al
mov bx, [d1]
mov dx, 320
sub dx, [bb]
shr dx, 2
mov cx, [bb]
shr cx, 2
push cx
@l1:
movsb
add si, 3
dec cx
jnz @l1
pop cx
push cx
add di, dx
dec bx
jnz @l1
pop cx
shl m, 1
and m, 15
cmp m, 0
jne @w2
inc m
add a1, 4
@w2:
mov si, offset buf
add si, 2
mov di, s1
mov ax, [a1]
shr ax, 2
add di, ax
mov dx, $3c4
mov al, 2
out dx, al
mov al, m
and al, 15
inc dx
out dx, al
mov bx, [d1]
mov dx, 320
sub dx, [bb]
shr dx, 2
mov cx, [bb]
shr cx, 2
push cx
@l2:
movsb
add si, 3
dec cx
jnz @l2
pop cx
push cx
add di, dx
dec bx
jnz @l2
pop cx
shl m, 1
and m, 15
cmp m, 0
jne @w3
inc m
add a1, 4
@w3:
mov si, offset buf
add si, 3
mov di, s1
mov ax, [a1]
shr ax, 2
add di, ax
mov dx, $3c4
mov al, 2
out dx, al
mov al, m
and al, 15
inc dx
out dx, al
mov bx, [d1]
mov dx, 320
sub dx, [bb]
shr dx, 2
mov cx, [bb]
shr cx, 2
push cx
@l3:
movsb
add si, 3
dec cx
jnz @l3
pop cx
push cx
add di, dx
dec bx
jnz @l3
pop cx
end;
set_start(s1);
if spd>0 then begin
delay(spd);
waitretrace;
end;
asm
push s1
push s2
pop s1
pop s2
end;
end;
end;
procedure show_fli(spd:word);
begin
getmem(m1,65000);change[1].s:=seg(m1^);
getmem(m2,65000);change[2].s:=seg(m2^);
getmem(m3,65000);change[3].s:=seg(m3^);
getmem(m4,65000);change[4].s:=seg(m4^);
change[1].l:=1;
change[2].l:=16;
change[3].l:=27;
change[4].l:=45;
change[5].l:=255;
setmode($13);
port[$3c4]:=4;port[$3c5]:=port[$3c5] and not $08;
port[$3d4]:=$14;port[$3d5]:=port[$3d5] and not $40;
port[$3d4]:=$17;port[$3d5]:=port[$3d5] or $40;
fillchar(mem[$a000:0],$ffff,0);
assign(h,'fish.dat');
reset(h,1);
{check id}
blockread(h,idc[1],54);
idc[0]:=chr(54);
if idc<>id then exit;
{pal}
blockread(h,buf[0],768);
for c:=0 to 255 do
setreg(c,buf[c*3],buf[c*3+1],buf[c*3+2]);
{data ids}
for c:=1 to 75 do
blockread(h,t[c],10);
{data}
buf_ind:=1;
for c:=1 to 75 do begin
if change[buf_ind].l=c then begin
cur_buf:=change[buf_ind].s;
inc(buf_ind);
ind:=0;
end;
blockread(h,mem[cur_buf:ind],t[c].bc);
ind:=ind+t[c].bc;
end;
close(h);
show_vid2(spd);
end;
begin
end.