/* Copyright (C) Prikol Software 1996-1997 Copyright (C) Aleksey Volynskov 1996-1997 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 #include #include //#include "..\averr.h" #include "vga.h" #include "glob.h" /* #define MAXRECT 500 typedef struct{short x,w,y,h;}rect; static rect *rt,*rp; static redraw_f *fn; static short sl,st,sr,sb; void *RD_init(short x,short w,short y,short h) { rect *p; if(!(p=malloc((MAXRECT*2+1)*sizeof(rect)))) {error(0,0,ENOMEM,NULL,NULL);return NULL;}//{error(EZ_VGALIB,ET_STD,ENOMEM,NULL,NULL);return NULL;} p->x=x;p->w=x+w-1;p->y=y;p->h=y+h-1; memset(p+1,0,MAXRECT*2*sizeof(rect)); return p; } void RD_start(void *p,redraw_f *f) { rt=p;fn=f; sl=rt->x;sr=rt->w; st=rt->y;sb=rt->h; ++rt; rp=rt; } static void add(short x,short r,short y,short b) { int i; short rx,rr,ry,rb; for(i=0;i(rr=(rx=rp[i].x)+rp[i].w-1)) continue; if(r(rb=(ry=rp[i].y)+rp[i].h-1)) continue; if(brr) add(rr+1,r,y,b); if(yrb) add(max(rx,x),min(rr,r),rb+1,b); return; } for(i=0;isr) return; if(x+w<=sl) return; if(y>sb) return; if(y+h<=st) return; w+=x-1;h+=y-1; if(xsr) w=sr; if(h>sb) h=sb; add(x,w,y,h); } void RD_spr(short x,short y,vgaimg *v) { RD_rect(x-v->sx,v->w,y-v->sy,v->h); } void RD_spr2(short x,short y,vgaimg *v) { RD_rect(x-v->w+v->sx,v->w,y-v->sy,v->h); } void RD_end(void) { int i; V_setscr(scrbuf); rp=rt+MAXRECT; for(i=0;i