From d38d28ab8f115b5c9faaac3346416949db0d9875 Mon Sep 17 00:00:00 2001 From: Andriy Shinkarchuck Date: Sun, 24 Jul 2011 17:19:01 +0300 Subject: [PATCH] Added license notification --- a8.c | 610 +++++++++++++++++++++++++++++++---------------------------- 1 file changed, 316 insertions(+), 294 deletions(-) diff --git a/a8.c b/a8.c index fda8e6e..7d521d3 100755 --- a/a8.c +++ b/a8.c @@ -1,296 +1,318 @@ -#include "glob.h" -#include -//#include -#include -#include -#include -#include "vga.h" -#include "keyb.h" -#include "error.h" -#include "files.h" -#include "sound.h" - - -/* -#define WAIT_SZ 400000 - -extern byte gamcor[5][64]; - -extern char cd_path[]; - -extern int gammaa; -void setgamma(int); - -extern void *cd_scr; - -static byte skipping=0,credits=0; - -#define A8_ID 0xA8 - -enum{ - A8C_ENDFR,A8C_PAL,A8C_CLRSCR,A8C_DRAW, - A8C_FILL,A8C_DRAW2C,A8C_DRAW2 -}; - -typedef struct{ - unsigned char id,ver; - short width,height,frames; - long maxfsize; - long f1size; -}a8_hdr_t; - -typedef unsigned char uchar; - -#define SQ 4 - -static int sqw,sqh; - -static int norm_gamma; - -static unsigned char *frp,sqc[2][50][80]; -static int frame; -static a8_hdr_t ah; -static snd_t *strk; -static int strk_ch; - -static signed char *unpack(char *d,signed char *p,int l) { - for(;l>0;) if(*p>0) { - memcpy(d,p+1,*p);d+=*p;l-=*p;p+=*p+1; - }else if(*p<0) { - memset(d,p[1],-*p);d+=-*p;l-=-*p;p+=2; - }else return p+1; - return p; -} - -static unsigned char *draw(signed char *p) { - int x,y,sy,yc,n; - - for(y=0;y0) { - for(yc=*p++;yc;--yc,++y) for(x=0;x0) { - n=(*p++)*SQ; - for(sy=0;sy0) { - for(yc=*p++;yc;--yc,++y) for(x=0;x0) { - for(n=*p++;n;--n,++p,++x) - V_clr(x*SQ,SQ,y*SQ,SQ,*p); - }else x+=-*p++; - }else y+=-*p++; - return p; -} - -static unsigned char *draw2c(signed char *p) { - int x,y,sx,sy,yc,n; - unsigned short w; - - for(y=0;y0) { - for(yc=*p++;yc;--yc,++y) for(x=0;x0) { - for(n=*p++;n;--n,++x) { - sqc[0][y][x]=*p++; - sqc[1][y][x]=*p++; - w=*(unsigned short*)p;p+=2; - for(sy=0;sy>=1) - scra[(y*SQ+sy)*320+x*SQ+sx]=sqc[w&1][y][x]; - } - }else x+=-*p++; - }else y+=-*p++; - return p; -} - -static unsigned char *draw2(signed char *p) { - int x,y,sx,sy,yc,n; - unsigned short w; - - for(y=0;y0) { - for(yc=*p++;yc;--yc,++y) for(x=0;x0) { - for(n=*p++;n;--n,++x) { - w=*(unsigned short*)p;p+=2; - for(sy=0;sy>=1) - scra[(y*SQ+sy)*320+x*SQ+sx]=sqc[w&1][y][x]; - } - }else x+=-*p++; - }else y+=-*p++; - return p; -} - -//---------------------------------------------------------------// - -static int fsz,fdptr; -static FILE *fh; -static char *fdata; - - -static void f_close(void) { - if(fdata) { - free(fdata);fdata=NULL; - }else if(fh!=NULL) {fclose(fh);fh=NULL;} -} - -static char end_clr=1; -*/ - -void A8_close(void) { -/* - if(strk) if(strk_ch) S_stop(strk_ch); - f_close(); - if(frp) {free(frp);frp=NULL;} - if(strk) {free(strk);strk=NULL;} - if(end_clr) { - VP_fill(0,0,0); - V_clr(0,320,0,200,0);V_copytoscr(0,320,0,200); - setgamma(norm_gamma); - } -*/ -} - -int A8_nextframe(void) { -/* - unsigned char *p; - int i,j,k; - static int len; - - if(credits) if(keys[0x33] && keys[0x34]) skipping=1; - if(frame==-1) if(strk) strk_ch=S_play(strk,-1,1024,255); - if(fdata) { - len=*(int*)(fdata+fdptr);fdptr+=4; - }else {len=0;myfread(&len,1,4,fh);} - len-=4; - if(len<=0) { - A8_close(); - return 0; - } - if(fdata) { - p=fdata+fdptr;fdptr+=len; - }else {myfread(frp,1,len,fh);p=frp;} - for(;*p;) switch(*p++) { - case A8C_PAL: - i=*p++;j=*p++;if(!j) j=256; - for(k=0;krate=11000; - strk->len=sz; - strk->lstart=strk->llen=0; - for(p=(unsigned char *)(strk+1);sz;--sz,++p) *p^=0x80; - } - fclose(h); - } - } - sprintf(s,"%sA8\\%s.A8",cd_path,nm); - if((fh=fopen(s,"rb"))==NULL) { - ERR_fatal("Не могу открыть файл %s",s); - } - myfread(&ah,1,sizeof(ah)-4,fh); - if(ah.id!=A8_ID || ah.ver!=0) ERR_fatal("Испорченный файл A8 %s",s); - fseek(fh,0,SEEK_END); - fsz=ftell(fh)-sizeof(ah)+4; - fseek(fh,sizeof(ah)-4,SEEK_SET); - if((fdata=malloc(fsz))!=NULL) { - wait_scr(fsz); - myfread(fdata,1,fsz,fh); - fdptr=0; - fclose(fh);fh=NULL; - }else if(!(frp=malloc(ah.maxfsize))) { - if(strk) {free(strk);strk=NULL;} - if(!(frp=malloc(ah.maxfsize))) { - fclose(fh);fh=NULL;return 0; - } - } - sqw=ah.width/SQ;sqh=ah.height/SQ; - frame=-1; - norm_gamma=gammaa; - if(wscr) blank_scr(); - - - return 1; -*/ - - return 0; -} - +/* + Copyright (C) Prikol Software 1996-1997 + Copyright (C) Aleksey Volynskov 1996-1997 + Copyright (C) 2011 + + This file is part of the Doom2D:Rembo project. + + Doom2D:Rembo is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License version 2 as + published by the Free Software Foundation. + + Doom2D:Rembo is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see or + write to the Free Software Foundation, Inc., + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "glob.h" +#include +//#include +#include +#include +#include +#include "vga.h" +#include "keyb.h" +#include "error.h" +#include "files.h" +#include "sound.h" + + +/* +#define WAIT_SZ 400000 + +extern byte gamcor[5][64]; + +extern char cd_path[]; + +extern int gammaa; +void setgamma(int); + +extern void *cd_scr; + +static byte skipping=0,credits=0; + +#define A8_ID 0xA8 + +enum{ + A8C_ENDFR,A8C_PAL,A8C_CLRSCR,A8C_DRAW, + A8C_FILL,A8C_DRAW2C,A8C_DRAW2 +}; + +typedef struct{ + unsigned char id,ver; + short width,height,frames; + long maxfsize; + long f1size; +}a8_hdr_t; + +typedef unsigned char uchar; + +#define SQ 4 + +static int sqw,sqh; + +static int norm_gamma; + +static unsigned char *frp,sqc[2][50][80]; +static int frame; +static a8_hdr_t ah; +static snd_t *strk; +static int strk_ch; + +static signed char *unpack(char *d,signed char *p,int l) { + for(;l>0;) if(*p>0) { + memcpy(d,p+1,*p);d+=*p;l-=*p;p+=*p+1; + }else if(*p<0) { + memset(d,p[1],-*p);d+=-*p;l-=-*p;p+=2; + }else return p+1; + return p; +} + +static unsigned char *draw(signed char *p) { + int x,y,sy,yc,n; + + for(y=0;y0) { + for(yc=*p++;yc;--yc,++y) for(x=0;x0) { + n=(*p++)*SQ; + for(sy=0;sy0) { + for(yc=*p++;yc;--yc,++y) for(x=0;x0) { + for(n=*p++;n;--n,++p,++x) + V_clr(x*SQ,SQ,y*SQ,SQ,*p); + }else x+=-*p++; + }else y+=-*p++; + return p; +} + +static unsigned char *draw2c(signed char *p) { + int x,y,sx,sy,yc,n; + unsigned short w; + + for(y=0;y0) { + for(yc=*p++;yc;--yc,++y) for(x=0;x0) { + for(n=*p++;n;--n,++x) { + sqc[0][y][x]=*p++; + sqc[1][y][x]=*p++; + w=*(unsigned short*)p;p+=2; + for(sy=0;sy>=1) + scra[(y*SQ+sy)*320+x*SQ+sx]=sqc[w&1][y][x]; + } + }else x+=-*p++; + }else y+=-*p++; + return p; +} + +static unsigned char *draw2(signed char *p) { + int x,y,sx,sy,yc,n; + unsigned short w; + + for(y=0;y0) { + for(yc=*p++;yc;--yc,++y) for(x=0;x0) { + for(n=*p++;n;--n,++x) { + w=*(unsigned short*)p;p+=2; + for(sy=0;sy>=1) + scra[(y*SQ+sy)*320+x*SQ+sx]=sqc[w&1][y][x]; + } + }else x+=-*p++; + }else y+=-*p++; + return p; +} + +//---------------------------------------------------------------// + +static int fsz,fdptr; +static FILE *fh; +static char *fdata; + + +static void f_close(void) { + if(fdata) { + free(fdata);fdata=NULL; + }else if(fh!=NULL) {fclose(fh);fh=NULL;} +} + +static char end_clr=1; +*/ + +void A8_close(void) { +/* + if(strk) if(strk_ch) S_stop(strk_ch); + f_close(); + if(frp) {free(frp);frp=NULL;} + if(strk) {free(strk);strk=NULL;} + if(end_clr) { + VP_fill(0,0,0); + V_clr(0,320,0,200,0);V_copytoscr(0,320,0,200); + setgamma(norm_gamma); + } +*/ +} + +int A8_nextframe(void) { +/* + unsigned char *p; + int i,j,k; + static int len; + + if(credits) if(keys[0x33] && keys[0x34]) skipping=1; + if(frame==-1) if(strk) strk_ch=S_play(strk,-1,1024,255); + if(fdata) { + len=*(int*)(fdata+fdptr);fdptr+=4; + }else {len=0;myfread(&len,1,4,fh);} + len-=4; + if(len<=0) { + A8_close(); + return 0; + } + if(fdata) { + p=fdata+fdptr;fdptr+=len; + }else {myfread(frp,1,len,fh);p=frp;} + for(;*p;) switch(*p++) { + case A8C_PAL: + i=*p++;j=*p++;if(!j) j=256; + for(k=0;krate=11000; + strk->len=sz; + strk->lstart=strk->llen=0; + for(p=(unsigned char *)(strk+1);sz;--sz,++p) *p^=0x80; + } + fclose(h); + } + } + sprintf(s,"%sA8\\%s.A8",cd_path,nm); + if((fh=fopen(s,"rb"))==NULL) { + ERR_fatal("Не могу открыть файл %s",s); + } + myfread(&ah,1,sizeof(ah)-4,fh); + if(ah.id!=A8_ID || ah.ver!=0) ERR_fatal("Испорченный файл A8 %s",s); + fseek(fh,0,SEEK_END); + fsz=ftell(fh)-sizeof(ah)+4; + fseek(fh,sizeof(ah)-4,SEEK_SET); + if((fdata=malloc(fsz))!=NULL) { + wait_scr(fsz); + myfread(fdata,1,fsz,fh); + fdptr=0; + fclose(fh);fh=NULL; + }else if(!(frp=malloc(ah.maxfsize))) { + if(strk) {free(strk);strk=NULL;} + if(!(frp=malloc(ah.maxfsize))) { + fclose(fh);fh=NULL;return 0; + } + } + sqw=ah.width/SQ;sqh=ah.height/SQ; + frame=-1; + norm_gamma=gammaa; + if(wscr) blank_scr(); + + + return 1; +*/ + + return 0; +} + //----------// //----------// -- 2.29.2