DEADSOFTWARE

71c44211460b9dc4b93b7ae6bc0e1dd1855f0a39
[flatwaifu.git] / src / anim.c
1 /*
2 Copyright (C) Prikol Software 1996-1997
3 Copyright (C) Aleksey Volynskov 1996-1997
5 This file is part of the Doom2D:Rembo project.
7 Doom2D:Rembo is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License version 2 as
9 published by the Free Software Foundation.
11 Doom2D:Rembo is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/> or
18 write to the Free Software Foundation, Inc.,
19 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21 /*
23 #include "glob.h"
24 #include <stdlib.h>
25 #include <string.h>
26 #include <vga.h>
27 //#include <keyb.h>
28 #include "error.h"
30 enum{AB_END,AB_SCREEN,AB_UPDATE};
32 typedef struct{
33 short t,st;
34 unsigned len;
35 }anm_blk_t;
37 #define SQ 4
39 static byte cnum[256];
41 static void init_cpack(void) {
42 int i;
44 for(i=0;i<256;++i) cnum[i]=i;
45 }
47 static byte cpack(byte n) {
48 byte c;
50 c=cnum[n];
51 if(n) memmove(cnum+1,cnum,n);
52 cnum[0]=c;
53 return c;
54 }
56 static byte *unpack(byte *d,byte *s,int l) {
57 for(;l>0;--l,++d,++s) {
58 if(*s==0) {memset(d,cpack(0),(dword)(*(++s))+1);d+=(dword)*s;l-=(dword)*s;}
59 else *d=cpack(*s);
60 }
61 return s;
62 }
64 static byte *line(int y,byte *u) {
65 int x,n,sy;
67 for(x=0;x<scrw/SQ;)
68 if(*u&0x80) {
69 n=(*u&0x7F)+1;++u;
70 for(sy=0;sy<SQ*320;sy+=320) {u=unpack(scra+y+sy+x*SQ,u,n*SQ);}
71 x+=n;
72 }else{x+=*u+1;++u;}
73 return u;
74 }
76 static anm_blk_t *anm;
78 void ANM_start(void *p) {
79 init_cpack();
80 anm=p;
81 }
83 int ANM_play(void) {
84 byte *u;
85 int x,y;
87 // while(!keys[0x39]);
88 // while(keys[0x39]);
89 if(anm->t==AB_END) return 0;
90 switch(anm->t) {
91 case AB_SCREEN:
92 unpack(scra,(byte*)(anm+1),64000);
93 break;
94 case AB_UPDATE:
95 for(u=(byte*)(anm+1),y=0;y<200/SQ;)
96 if(*u&0x80) {
97 for(x=(*u&0x7F)+1,++u;x;--x,++y)
98 u=line(y*320*SQ,u);
99 }else{y+=*u+1;++u;}
100 break;
101 default: ERR_fatal("\8f«®å®© ANM-ä ©«");
103 anm=((anm_blk_t*)((byte*)anm+anm->len))+1;
104 if(anm->t==AB_END) return 0;
105 return 1;
107 */