From: DeaDDooMER Date: Thu, 12 Mar 2020 14:46:03 +0000 (+0300) Subject: fully move highter level rendering code in separate file X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=534310c1f131bb9a53be865c32d90342ed026734;p=flatwaifu.git fully move highter level rendering code in separate file --- diff --git a/src/dots.c b/src/dots.c index e318172..8b4bb8e 100644 --- a/src/dots.c +++ b/src/dots.c @@ -42,19 +42,13 @@ extern byte z_dot; -#pragma pack(1) -typedef struct{ - obj_t o; - byte c,t; -}dot_t; -#pragma pack() - typedef struct{ int xv,yv; byte c,t; }init_t; -static dot_t dot[MAXDOT]; +dot_t dot[MAXDOT]; + static init_t bl_ini[MAXINI],sp_ini[MAXINI]; static int bl_r,sp_r,sr_r,sxr[MAXSR],syr[MAXSR]; static int ldot; @@ -164,13 +158,6 @@ void DOT_act(void) { z_dot=0; } -void DOT_draw(void) { - int i; - - for(i=0;i>8)-w_x+WD/2,(fx[i].y>>8)-w_y+HT/2+1+w_o,0xC0+fx[i].s);//V_dot((fx[i].x>>8)-w_x+100,(fx[i].y>>8)-w_y+50+w_o,0xC0+fx[i].s); - continue; - } - if(s>=0) Z_drawspr(fx[i].x,fx[i].y,spr[s],sprd[s]); - } -} - static int findfree(void) { int i; diff --git a/src/fx.h b/src/fx.h index c8e9735..3f773b9 100644 --- a/src/fx.h +++ b/src/fx.h @@ -23,10 +23,18 @@ #define MAXFX 300 +#pragma pack(1) +typedef struct{ + int x,y,xv,yv; + char t,s; +}fx_t; +#pragma pack() + +extern fx_t fx[MAXFX]; + void FX_init(void); void FX_alloc(void); void FX_act(void); -void FX_draw(void); void FX_tfog(int,int); void FX_ifog(int,int); void FX_bubble(int x,int y,int xv,int yv,int n); diff --git a/src/game.c b/src/game.c index fe52751..a8edfc2 100644 --- a/src/game.c +++ b/src/game.c @@ -173,8 +173,8 @@ void load_game(int n) { set_trans(GS_GAME); V_setscr((g_trans)?fx_scr2:scrbuf);V_setrect(0,SCRW,0,SCRH);//V_setrect(0,320,0,200); V_clr(0,SCRW,0,SCRH,0);//V_clr(0,320,0,200,0); - if(_2pl) {w_o=0;Z_clrst();w_o=SCRH/2;Z_clrst();}//if(_2pl) {w_o=0;Z_clrst();w_o=100;Z_clrst();} - else {w_o=0;Z_clrst();}//else {w_o=50;Z_clrst();} +// if(_2pl) {w_o=0;Z_clrst();w_o=SCRH/2;Z_clrst();}//if(_2pl) {w_o=0;Z_clrst();w_o=100;Z_clrst();} +// else {w_o=0;Z_clrst();}//else {w_o=50;Z_clrst();} V_setscr(scrbuf); pl1.drawst=0xFF; if(_2pl) pl2.drawst=0xFF; @@ -195,8 +195,8 @@ void G_start(void) { set_trans(GS_GAME); V_setscr((g_trans)?fx_scr2:scrbuf);V_setrect(0,SCRW,0,SCRH);//V_setrect(0,320,0,200); V_clr(0,SCRW,0,SCRH,0);//V_clr(0,320,0,200,0); - if(_2pl) {w_o=0;Z_clrst();w_o=SCRH/2;Z_clrst();}//if(_2pl) {w_o=0;Z_clrst();w_o=100;Z_clrst();} - else {w_o=0;Z_clrst();}//else {w_o=50;Z_clrst();} +// if(_2pl) {w_o=0;Z_clrst();w_o=SCRH/2;Z_clrst();}//if(_2pl) {w_o=0;Z_clrst();w_o=100;Z_clrst();} +// else {w_o=0;Z_clrst();}//else {w_o=50;Z_clrst();} V_setscr(scrbuf); pl1.drawst=0xFF; if(_2pl) pl2.drawst=0xFF; @@ -224,15 +224,6 @@ void G_init(void) { logo("G_init: настройка ресурсов игры "); logo_gas(5,GGAS_TOTAL); telepsnd=Z_getsnd("TELEPT"); - scrnh[0]=V_loadvgaimg("TITLEPIC"); - scrnh[1]=V_loadvgaimg("INTERPIC"); - scrnh[2]=V_loadvgaimg("ENDPIC"); - cd_scr=V_loadvgaimg("CD1PIC"); - for(i=0;i<2;++i) { - sprintf(s,"LTN%c",i+'1'); - for(j=0;j<2;++j) - ltn[i][j]=Z_getspr(s,j,0,NULL); - } ltnsnd[0]=Z_getsnd("THUND1"); ltnsnd[1]=Z_getsnd("THUND2"); DOT_alloc(); diff --git a/src/items.c b/src/items.c index c9b23b5..8918203 100644 --- a/src/items.c +++ b/src/items.c @@ -35,18 +35,10 @@ extern map_block_t blk; -#pragma pack(1) -typedef struct{ - obj_t o; - int t; - int s; -}item_t; -#pragma pack() +item_t it[MAXITEM]; -static void *snd[4],*spr[58]; -static char sprd[58]; +static void *snd[4]; static int tsndtm,rsndtm; -static item_t it[MAXITEM]; int itm_rtime=1092; @@ -90,40 +82,18 @@ void IT_loadgame (FILE *h) { itm_rtime = myfread32(h); } -void IT_alloc(void) { - int i,j,n; - static char nm[][6]={ - "ITEMUP","WPNUP","GETPOW","ITMBK" - },snm[][4]={ - "CLIP","SHEL","ROCK","CELL","AMMO","SBOX","BROK","CELP", - "STIM","MEDI","BPAK", - "CSAW","SHOT","SGN2","MGUN","LAUN","PLAS","BFUG" - },n4[][4]={ - "SOUL","SMRT","SMGT","SMBT" - },n3[][4]={ - "GOR1","FCAN" +void IT_alloc (void) { + int i, j, n; + static char nm[][6] = { + "ITEMUP", "WPNUP", "GETPOW", "ITMBK" }; - -// logo(" items"); - for(i=0;i<18;++i) spr[i]=Z_getspr(snm[i],0,0,sprd+i); - for(;i<20;++i) { - spr[i]=Z_getspr("ARM1",i-18,0,sprd+i); - spr[i+2]=Z_getspr("ARM2",i-18,0,sprd+i); - }i+=2; - for(;i<26;++i) spr[i]=Z_getspr("MEGA",i-22,0,sprd+i); - for(;i<30;++i) spr[i]=Z_getspr("PINV",i-26,0,sprd+i); - spr[30]=Z_getspr("AQUA",0,0,sprd+30); - spr[31]=Z_getspr("KEYR",0,0,sprd+31); - spr[32]=Z_getspr("KEYG",0,0,sprd+32); - spr[33]=Z_getspr("KEYB",0,0,sprd+33); - spr[34]=Z_getspr("SUIT",0,0,sprd+34); - for(n=35,j=0;j<4;++j) - for(i=0;i<4;++i,++n) spr[n]=Z_getspr(n4[j],i,0,sprd+n); - for(j=0;j<2;++j) - for(i=0;i<3;++i,++n) spr[n]=Z_getspr(n3[j],i,0,sprd+n); - spr[57]=Z_getspr("GUN2",0,0,sprd+57); - for(i=0;i<4;++i) snd[i]=Z_getsnd(nm[i]); - for(i=0;i=0) switch(it[i].t&0x7FFF) { - case I_ARM1: - s=it[i].s/9+18;break; - case I_ARM2: - s=it[i].s/9+20;break; - case I_MEGA: - s=it[i].s/2+22;break; - case I_INVL: - s=it[i].s/2+26;break; - case I_SUPER: case I_RTORCH: case I_GTORCH: case I_BTORCH: - s=it[i].s/2+(it[i].t-I_SUPER)*4+35;break; - case I_GOR1: case I_FCAN: - s=it[i].s/2+(it[i].t-I_GOR1)*3+51;break; - case I_AQUA: s=30;break; - case I_SUIT: s=34;break; - case I_KEYR: case I_KEYG: case I_KEYB: - s=(it[i].t&0x7FFF)-I_KEYR+31;break; - case I_GUN2: s=57;break; - default: - s=(it[i].t&0x7FFF)-1; - } - if(s>=0) Z_drawspr(it[i].o.x,it[i].o.y,spr[s],sprd[s]); - } -} - void IT_spawn(int x,int y,int t) { int i; diff --git a/src/items.h b/src/items.h index 2eff458..37eace4 100644 --- a/src/items.h +++ b/src/items.h @@ -31,11 +31,20 @@ enum{I_NONE,I_CLIP,I_SHEL,I_ROCKET,I_CELL,I_AMMO,I_SBOX,I_RBOX,I_CELP, I_RTORCH,I_GTORCH,I_BTORCH,I_GOR1,I_FCAN,I_GUN2 }; +#pragma pack(1) +typedef struct{ + obj_t o; + int t; + int s; +}item_t; +#pragma pack() + +extern item_t it[MAXITEM]; + void IT_init(void); void IT_alloc(void); int IT_load(FILE*); void IT_act(void); -void IT_draw(void); void IT_spawn(int x,int y,int i); void IT_drop_ammo(int i,int n,int x,int y); diff --git a/src/main.c b/src/main.c index 2fc47ce..ceba887 100644 --- a/src/main.c +++ b/src/main.c @@ -128,6 +128,7 @@ int main(int argc, char *argv[]) { F_loadres(F_getresid("MIXMAP"),mixmap,0,0x10000); F_loadres(F_getresid("COLORMAP"),clrmap,0,256*12); G_init(); + R_alloc(); K_init(); logo("S_init: настройка звука\n"); S_init(); diff --git a/src/menu.c b/src/menu.c index faf5b3d..415b68d 100644 --- a/src/menu.c +++ b/src/menu.c @@ -54,16 +54,15 @@ void load_game(int); static byte panim[]= "BBDDAACCDDAABBDDAACCDDAABBDDAACCDDAAEEEEEFEFEFEFEFEFEFEFEFEFEEEEE"; -static byte *panimp=panim; +byte *panimp=panim; -#define PCOLORN 10 byte pcolortab[PCOLORN]={ 0x18,0x20,0x40,0x58,0x60,0x70,0x80,0xB0,0xC0,0xD0 }; int p1color=5,p2color=4; -static char ibuf[24]; -static byte input=0; +char ibuf[24]; +byte input=0; static int icur; enum{MENU,MSG}; @@ -115,7 +114,7 @@ static byte main_typ[]={ SAVE,SAVE,SAVE,SAVE,SAVE,SAVE,SAVE }; -static menu_t main_mnu={ +menu_t main_mnu={ MENU,5,0,80,"MENU",main_txt,main_typ },opt_mnu={ MENU,5,0,75,"OPTIONS",opt_txt,opt_typ @@ -145,14 +144,12 @@ static menu_t main_mnu={ static menu_t *qmsg[3]={&quit1_msg,&quit2_msg,&quit3_msg}; -static menu_t *mnu=NULL; +menu_t *mnu=NULL; +byte gm_redraw=0; -static byte gm_redraw=0; -static int gm_tm=0; short lastkey=0; static void *csnd1,*csnd2,*msnd1,*msnd2,*msnd3,*msnd4,*msnd5,*msnd6; static int movsndt=0; -static vgaimg *msklh[2],*mbarl,*mbarm,*mbarr,*mbaro,*mslotl,*mslotm,*mslotr; static byte cbuf[32]; static snd_t *voc=NULL; @@ -574,69 +571,5 @@ void GM_init(void) { msnd4=Z_getsnd("SWTCHX"); msnd5=Z_getsnd("SUDI"); msnd6=Z_getsnd("TUDI"); - msklh[0]=V_loadvgaimg("M_SKULL1"); -// msklh[0]=load_vga("vga\\spr.vga","M_SKULL1"); - msklh[1]=V_loadvgaimg("M_SKULL2"); - mbarl=V_loadvgaimg("M_THERML"); - mbarm=V_loadvgaimg("M_THERMM"); - mbarr=V_loadvgaimg("M_THERMR"); - mbaro=V_loadvgaimg("M_THERMO"); - mslotl=V_loadvgaimg("M_LSLEFT"); - mslotm=V_loadvgaimg("M_LSCNTR"); - mslotr=V_loadvgaimg("M_LSRGHT"); K_setkeyproc(G_keyf); } - -int GM_draw(void) { - int i,j,k,y; - - ++gm_tm; - V_setrect(0,SCRW,0,SCRH);//V_setrect(0,320,0,200); - if(!mnu && !gm_redraw) return 0; - gm_redraw=0; - if(!mnu) return 1; - if(mnu->type==MENU) { - y=(200-mnu->n*16-20)/2; - Z_gotoxy(mnu->x,y-10);Z_printbf(mnu->ttl); - for(i=0;in;++i) { - if(mnu->t[i]==LOAD || mnu->t[i]==SAVE) { - V_spr(mnu->x,j=y+i*16+29,mslotl); - for(k=8;k<184;k+=8) - V_spr(mnu->x+k,j,mslotm); - V_spr(mnu->x+184,j,mslotr); - Z_gotoxy(mnu->x+4,j-8); - if(input && i==save_mnu.cur) Z_printsf("%s_",ibuf); - else Z_printsf("%s",savname[i]); - }else{ - Z_gotoxy(mnu->x+((mnu->t[i]>=SVOLM)?((mnu->t[i]>=PL1CM)?50:152):0),y+i*16+20); - Z_printbf(mnu->m[i]); - } - if(mnu->t[i]==MUSIC) { - Z_printbf(" '%.8s'",g_music); - }else if(mnu->t[i]==INTERP) { - Z_printbf("%s",fullscreen?"ON":"OFF"); - }else if(mnu->t[i]>=PL1CM) { - V_manspr(mnu->x+((mnu->t[i]==PL1CM)?15:35),y+i*16+20+14, - PL_getspr(*panimp,0), - pcolortab[(mnu->t[i]==PL1CM)?p1color:p2color] - ); - }else if(mnu->t[i]>=SVOLM) { - V_spr(mnu->x,j=y+i*16+20,mbarl); - for(k=8;k<144;k+=8) - V_spr(mnu->x+k,j,mbarm); - V_spr(mnu->x+144,j,mbarr); - switch(mnu->t[i]) { - case SVOLM: k=snd_vol;break; - case MVOLM: k=mus_vol;break; - case GAMMAM: k=gammaa<<5;break; - } - V_spr(mnu->x+8+k,j,mbaro); - } - } - V_spr(mnu->x-25,y+mnu->cur*16+20-8,msklh[(gm_tm/6)&1]); - }else{ - Z_gotoxy((320-strlen(mnu->ttl)*7)/2,90);Z_printsf(mnu->ttl); - Z_gotoxy(136,100);Z_printsf("(Y/N)"); - } - return 1; -} diff --git a/src/menu.h b/src/menu.h index 39c7151..ed4a5e9 100644 --- a/src/menu.h +++ b/src/menu.h @@ -29,11 +29,25 @@ typedef struct{ byte *t; }menu_t; +extern menu_t save_mnu; + +extern byte *panimp; + +#define PCOLORN 10 +extern byte pcolortab[PCOLORN]; +extern int p1color; +extern int p2color; + +extern char ibuf[24]; +extern byte input; + +extern menu_t *mnu; +extern byte gm_redraw; + void GMV_say(char *); void GMV_stop(void); void GM_init(void); int GM_act(void); -int GM_draw(void); void G_code(void); diff --git a/src/misc.h b/src/misc.h index dad870a..9d81cfa 100644 --- a/src/misc.h +++ b/src/misc.h @@ -32,19 +32,9 @@ enum{ Z_INWATER=16,Z_HITWATER=32,Z_HITAIR=64,Z_BLOCK=128 }; -void *Z_getspr(char[4],int,int,char *); void *Z_getsnd(char[6]); -void Z_drawspr(int,int,void *,char); -void Z_drawmanspr(int,int,void *,char,byte); -void Z_drawstair(int); -void Z_drawstprcnt(int,int); -void Z_drawstnum(int); -void Z_drawstwpn(int,int); -void Z_drawstkeys(byte); -void Z_drawstlives(char); int Z_sound(void *,int); void Z_initst(void); -void Z_drawfld(byte *, int); int Z_sign(int); int Z_dec(int,int); int Z_canstand(int,int,int); @@ -76,15 +66,7 @@ void Z_set_speed(obj_t *,int); void Z_calc_time(dword t,word *h,word *m,word *s); -void Z_putbfch(int); -void Z_printbf(char *,...); -void Z_putsfch(int); -void Z_printsf(char *,...); -void Z_gotoxy(int,int); - int Z_getacid(int x,int y,int r,int h); -void Z_clrst(); - int16_t short2host (int16_t x); int32_t int2host (int32_t x); diff --git a/src/miscc.c b/src/miscc.c index 3479689..a174237 100644 --- a/src/miscc.c +++ b/src/miscc.c @@ -40,16 +40,13 @@ #define MAX_YV 30 -#define MAXAIR 1091 - extern dword walf[256]; byte z_dot=0; extern void *walp[256]; -static void *sth[22],*bfh[160-'!'],*sfh[160-'!'],*bulsnd[2],*stone, *stone2, *keys[3]; -static int prx=0,pry=0; +static void *bulsnd[2]; int Z_sign(int a) { if(a>0) return 1; @@ -64,15 +61,6 @@ int Z_dec(int a,int b) { return 0; } -void *Z_getspr(char n[4],int s,int d,char *dir) { - int h; - - h=F_getsprid(n,s,d); - if(dir) *dir=(h&0x8000)?1:0; - //return M_lock(h); - return V_getvgaimg(h); -} - void *Z_getsnd(char n[6]) { char s[8]; @@ -103,202 +91,10 @@ int Z_sound(void *s,int v) { #define GAS_TOTAL (MN__LAST-MN_DEMON+16+10) void Z_initst(void) { - int i; - char s[10]; - static char nm[22][8]={ - "STTNUM0","STTNUM1","STTNUM2","STTNUM3","STTNUM4", - "STTNUM5","STTNUM6","STTNUM7","STTNUM8","STTNUM9", - "STTMINUS","STTPRCNT", - "FISTA0","CSAWA0","PISTA0","SHOTA0","SGN2A0","MGUNA0","LAUNA0", - "PLASA0","BFUGA0","GUN2A0" - }; - - stone=V_loadvgaimg("STONE"); - stone2=V_loadvgaimg("STONE2"); - keys[0]=V_loadvgaimg("KEYRA0"); - keys[1]=V_loadvgaimg("KEYGA0"); - keys[2]=V_loadvgaimg("KEYBA0"); - for(i=0;i<22;++i) - sth[i]=V_loadvgaimg(nm[i]); - strcpy(s,"STBF_*"); - for(i='!';i<160;++i) { - s[5]=i; - bfh[i-'!']=V_getvgaimg(F_findres(s)); - if(!(i&15)) logo_gas(GAS_START+((i-'!')>>4),GAS_TOTAL); - } - for(i='!';i<160;++i) { - sprintf(s,"STCFN%03d",i); - sfh[i-'!']=V_getvgaimg(F_findres(s)); - if(!(i&15)) logo_gas(GAS_START+8+((i-'!')>>4),GAS_TOTAL); - } - strcpy(s,"WINUM*"); - for(i='0';i<='9';++i) { - s[5]=i; - bfh[i-'!']=V_loadvgaimg(s); - } - bfh[':'-'!']=V_loadvgaimg("WICOLON"); bulsnd[0]=Z_getsnd("BUL1"); bulsnd[1]=Z_getsnd("BUL2"); } -void Z_putbfch(int c) { - vgaimg *p; - - if(c>32 && c<160) p=bfh[c-'!']; else p=NULL; - if(p) { - V_spr(prx,pry,p); - prx+=p->w-1; - }else prx+=12; -} - -void Z_putsfch(int c) { - vgaimg *p; - - if(c>32 && c<160) p=sfh[c-'!']; else p=NULL; - if(p) { - V_spr(prx,pry,p); - prx+=p->w-1; - }else prx+=7; -} - -void Z_gotoxy(int x,int y) {prx=x;pry=y;} - -void Z_printbf(char *s,...) { - int i; - va_list ap; - char buf[80]; - - va_start(ap,s); - vsprintf(buf,s,ap); - va_end(ap); - for(i=0;buf[i];++i) switch(buf[i]) { - case '\n': - pry+=13; - case '\r': - prx=0;break; - default: - Z_putbfch((byte)buf[i]); - } -} - -void Z_printsf(char *s,...) { - int i; - va_list ap; - char buf[80]; - - va_start(ap,s); - vsprintf(buf,s,ap); - va_end(ap); - for(i=0;buf[i];++i) switch(buf[i]) { - case '\n': - pry+=8; - case '\r': - prx=0;break; - default: - Z_putsfch((byte)buf[i]); - } -} - -void Z_drawspr(int x,int y,void *p,char d) { - if(d) V_spr2(x-w_x+WD/2,y-w_y+HT/2+1+w_o,p);//if(d) V_spr2(x-w_x+100,y-w_y+HT/2+1+w_o,p); - else V_spr(x-w_x+WD/2,y-w_y+HT/2+1+w_o,p);//else V_spr(x-w_x+100,y-w_y+HT/2+1+w_o,p); -} - -void Z_clrst(void) { - V_pic(SCRW-120,w_o,stone);//V_pic(200,w_o,stone); - int y = ((vgaimg*)stone)->h; - while (yh; - } -} - - -void Z_drawstlives(char n) { - V_setrect(SCRW-40,30,w_o,40);Z_clrst();//V_setrect(280,30,w_o,40);Z_clrst(); - V_spr(SCRW-35,w_o+17,sth[n]);//V_spr(285,w_o+17,sth[n]); -} - -void Z_drawstkeys(byte k) { - int x,n; - - V_setrect(SCRW-120,70,w_o+77,23);Z_clrst();//V_setrect(200,70,w_o+77,23);Z_clrst(); - for(k>>=4,n=0,x=SCRW-75;n<3;++n,k>>=1,x+=9)//for(k>>=4,n=0,x=245;n<3;++n,k>>=1,x+=9) - if(k&1) V_spr(x,w_o+91,keys[n]); -} - -void Z_drawstair(int a) { - V_setrect(SCRW-120,120,w_o+49,2);Z_clrst();//V_setrect(200,120,w_o+49,2);Z_clrst(); - if(a<=0) return; - if(a>MAXAIR) a=MAXAIR; - a=a*100/MAXAIR; - if(!a) return; - V_clr(SCRW-110,a,w_o+49,2,0xC8);//V_clr(210,a,w_o+49,2,0xC8); -} - -void Z_drawstprcnt(int y,int n) { - char s[20]; - int l,i,x,c; - - V_setrect(SCRW-120,70,y*19+7+w_o,19);Z_clrst();//V_setrect(200,70,y*19+7+w_o,19);Z_clrst(); - sprintf(s,"%3d%%",n); - l=strlen(s);x=SCRW-110;//l=strlen(s);x=210; - for(i=0;i='0' && s[i]<='9') c=s[i]-'0'; - else if(s[i]=='-') c=10; - else if(s[i]=='%') c=11; - else c=-1; - if(c>=0) - V_spr(x,y*19+7+w_o,sth[c]); - } -} - -void Z_drawstnum(int n) { - char s[20]; - int l,i,x,c; - - V_setrect(SCRW-50,50,w_o+77,23);Z_clrst();//V_setrect(270,50,w_o+77,23);Z_clrst(); - if(!g_dm) return; - sprintf(s,"%d",n); - l=strlen(s);x=(115-l*14)+SCRW-120;//l=strlen(s);x=(115-l*14)+200; - for(i=0;i='0' && s[i]<='9') c=s[i]-'0'; - else if(s[i]=='-') c=10; - else if(s[i]=='%') c=11; - else c=-1; - if(c>=0) - V_spr(x,w_o+77+5,sth[c]); - } -} - -void Z_drawstwpn(int n,int a) { - char s[20]; - int l,i,x,c; - - i=n; - V_setrect(SCRW-120,120,w_o+58,23);Z_clrst();//V_setrect(200,120,w_o+58,23);Z_clrst(); - if(i>=0) V_spr(SCRW-88,w_o+58+19,sth[i+12]);//if(i>=0) V_spr(232,w_o+58+19,sth[i+12]); - if(n>=2) { - sprintf(s,"%d",a); - l=strlen(s);x=SCRW-10-l*14;//l=strlen(s);x=310-l*14; - for(i=0;i='0' && s[i]<='9') c=s[i]-'0'; - else if(s[i]=='-') c=10; - else if(s[i]=='%') c=11; - else c=-1; - if(c>=0) - V_spr(x,w_o+58+2,sth[c]); - } - } -} - - - -void Z_drawmanspr(int x,int y,void *p,char d,byte color) { - if(d) V_manspr2(x-w_x+WD/2,y-w_y+HT/2+1+w_o,p,color);//if(d) V_manspr2(x-w_x+100,y-w_y+HT/2+1+w_o,p,color); - else V_manspr(x-w_x+WD/2,y-w_y+HT/2+1+w_o,p,color);//else V_manspr(x-w_x+100,y-w_y+HT/2+1+w_o,p,color); -} - int Z_canstand(int x,int y,int r) { int i; diff --git a/src/monster.c b/src/monster.c index 749ef78..935b5c6 100644 --- a/src/monster.c +++ b/src/monster.c @@ -38,30 +38,14 @@ #include "smoke.h" #include "my.h" -#define MANCOLOR 0xD0 - #define MAX_ATM 90 -#define MN_TN (MN__LAST-MN_DEMON) - extern byte z_mon; enum{ SLEEP,GO,RUN,CLIMB,DIE,DEAD,ATTACK,SHOOT,PAIN,WAIT,REVIVE,RUNOUT }; -#pragma pack(1) -typedef struct{ - obj_t o; - byte t,d,st,ftime; - int fobj; - int s; - char *ap; - int aim,life,pain,ac,tx,ty,ammo; - short atm; -}mn_t; -#pragma pack(0) - typedef struct{ int r,h,l,mp,rv,jv,sp,minp; }mnsz_t; @@ -105,13 +89,12 @@ static char *sleepanim[MN_TN]={ }; int hit_xv,hit_yv; +mn_t mn[MAXMN]; -static void *spr[MN_TN][29*2],*fspr[8],*fsnd,*pauksnd,*trupsnd,*sgun[2]; -static char sprd[MN_TN][29*2]; +static void *fsnd,*pauksnd,*trupsnd; static void *snd[MN_TN][5],*impsitsnd[2],*impdthsnd[2],*firsnd,*slopsnd,*gsnd[4]; -static void *swgsnd,*pchsnd,*pl_spr[2],*telesnd; +static void *swgsnd,*pchsnd,*telesnd; static void *positsnd[3],*podthsnd[3]; -static mn_t mn[MAXMN]; static int mnum,gsndt; static mnsz_t mnsz[MN_TN+1]={ //rad ht life pain rv jv slop min_pn @@ -242,30 +225,16 @@ void MN_alloc(void) { {"","","","","BAREXP"}, {"BSPACT","","BSPWLK","BSPSIT","BSPDTH"}, {"HAHA1","PLPAIN","","STOP1","PDIEHI"} - },msn[MN_TN][4]={ - "SARG","TROO","POSS","SPOS","CYBR","CPOS","BOSS","BOS2","HEAD","SKUL", - "PAIN","SPID","BSPI","FATT","SKEL","VILE","FISH","BAR1","ROBO","PLAY" }; static char gsn[6]="GOOD0"; - static int mms[MN_TN]={ - 14*2,21*2,21*2,21*2,16*2,20*2,15*2,15*2,12*2,11*2,13*2,19*2,16*2, - 20*2,17*2,29*2,6*2,2*2,17*2,23*2 - }; - - sgun[0]=Z_getspr("PWP4",0,1,NULL); - sgun[1]=Z_getspr("PWP4",1,1,NULL); for(j=0;j=MN_PL_DEAD) { - Z_drawmanspr(mn[i].o.x,mn[i].o.y,pl_spr[mn[i].t-MN_PL_DEAD],0,mn[i].d); - continue; - } - if((mn[i].t!=MN_SOUL && mn[i].t!=MN_PAIN) || mn[i].st!=DEAD) { - if(mn[i].t!=MN_MAN) - Z_drawspr(mn[i].o.x,mn[i].o.y, - spr[mn[i].t-1][(mn[i].ap[mn[i].ac]-'A')*2+mn[i].d], - sprd[mn[i].t-1][(mn[i].ap[mn[i].ac]-'A')*2+mn[i].d]); - else{ - if(mn[i].ap[mn[i].ac]=='E' || mn[i].ap[mn[i].ac]=='F') - Z_drawspr(mn[i].o.x,mn[i].o.y,sgun[mn[i].ap[mn[i].ac]-'E'],mn[i].d); - Z_drawmanspr(mn[i].o.x,mn[i].o.y, - spr[mn[i].t-1][(mn[i].ap[mn[i].ac]-'A')*2+mn[i].d], - sprd[mn[i].t-1][(mn[i].ap[mn[i].ac]-'A')*2+mn[i].d],MANCOLOR); - } - } - if(mn[i].t==MN_VILE && mn[i].st==SHOOT) { - Z_drawspr(mn[i].tx,mn[i].ty,fspr[mn[i].ac/3],0); - } - } -} - int MN_hit(int n,int d,int o,int t) { int i; diff --git a/src/monster.h b/src/monster.h index b941427..7b822f6 100644 --- a/src/monster.h +++ b/src/monster.h @@ -31,13 +31,28 @@ enum{ MN_PL_DEAD=100,MN_PL_MESS }; +#define MN_TN (MN__LAST-MN_DEMON) + +#pragma pack(1) +typedef struct{ + obj_t o; + byte t,d,st,ftime; + int fobj; + int s; + char *ap; + int aim,life,pain,ac,tx,ty,ammo; + short atm; +}mn_t; +#pragma pack(0) + +extern mn_t mn[MAXMN]; + void MN_init(void); void MN_alloc(void); int MN_spawn(int,int,byte,int); int MN_spawn_deadpl(obj_t *,byte,int); void MN_act(void); void MN_mark(void); -void MN_draw(void); void MN_warning(int l,int t,int r,int b); void MN_killedp(void); diff --git a/src/player.c b/src/player.c index 7620493..fe4fe42 100644 --- a/src/player.c +++ b/src/player.c @@ -45,7 +45,6 @@ extern int hit_xv,hit_yv; #define PL_SWUP 4 #define PL_FLYUP 4 -#define PL_AIR 360 #define PL_AQUA_AIR 1091 byte p_immortal=0,p_fly=0; @@ -63,12 +62,10 @@ static int aitime; static void *aisnd[3]; static void *pdsnd[5]; -static void *spr[27*2],*snd[11]; -static char sprd[27*2]; -static void *wpn[11][6]; -static byte goanim[]="BDACDA", - dieanim[]="HHHHIIIIJJJJKKKKLLLLMMMM", - slopanim[]="OOPPQQRRSSTTUUVVWW"; +static void *snd[11]; +byte plr_goanim[]="BDACDA", + plr_dieanim[]="HHHHIIIIJJJJKKKKLLLLMMMM", + plr_slopanim[]="OOPPQQRRSSTTUUVVWW"; #pragma pack(1) @@ -317,17 +314,7 @@ void PL_alloc(void) { "SAWHIT", "PLFALL" }; - static char s[6]; - - for(i=0;i<27;++i) { - spr[i*2]=Z_getspr("PLAY",i,1,sprd+i*2); - spr[i*2+1]=Z_getspr("PLAY",i,2,sprd+i*2+1); - } - memcpy(s,"PWPx",4); - for(i=1;i<11;++i) { - s[3]=((i<10)?'0':('A'-10))+i; - for(j=0;j<6;++j) wpn[i][j]=Z_getspr(s,j,1,NULL); - } + char s[6]; for(i=0;i<11;++i) snd[i]=Z_getsnd(nm[i]); memcpy(s,"AIx",4); for(i=0;i<3;++i) { @@ -603,12 +590,12 @@ void PL_act(player_t *p) { switch(p->st) { case DIE: p->o.h=7; - if(!dieanim[++p->s]) {p->st=DEAD;MN_killedp();} + if(!plr_dieanim[++p->s]) {p->st=DEAD;MN_killedp();} p->o.xv=Z_dec(p->o.xv,1); break; case SLOP: p->o.h=6; - if(!slopanim[++p->s]) {p->st=MESS;MN_killedp();} + if(!plr_slopanim[++p->s]) {p->st=MESS;MN_killedp();} p->o.xv=Z_dec(p->o.xv,1); break; case GO: @@ -659,56 +646,6 @@ void PL_act(player_t *p) { } } -static int standspr(player_t *p) { - if(p->f&PLF_UP) return 'X'; - if(p->f&PLF_DOWN) return 'Z'; - return 'E'; -} - -static int wpnspr(player_t *p) { - if(p->f&PLF_UP) return 'C'; - if(p->f&PLF_DOWN) return 'E'; - return 'A'; -} - -void PL_draw(player_t *p) { - int s,w,wx,wy; - static int wytab[]={-1,-2,-1,0}; - - s='A';w=0;wx=wy=0; - switch(p->st) { - case STAND: - if(p->f&PLF_FIRE) {s=standspr(p)+1;w=wpnspr(p)+1;} - else if(p->pain) {s='G';w='A';wx=p->d?2:-2;wy=1;} - else {s=standspr(p);w=wpnspr(p);} - break; - case DEAD: - s='N';break; - case MESS: - s='W';break; - case GO: - if(p->pain) {s='G';w='A';wx=p->d?2:-2;wy=1;} - else { - s=goanim[p->s/8];w=(p->f&PLF_FIRE)?'B':'A'; - wx=p->d?2:-2;wy=1+wytab[s-'A']; - } - break; - case DIE: - s=dieanim[p->s];break; - case SLOP: - s=slopanim[p->s];break; - case OUT: - s=0;break; - } - if(p->wpn==0) w=0; - if(w) Z_drawspr(p->o.x+wx,p->o.y+wy,wpn[p->wpn][w-'A'],p->d); - if(s) Z_drawmanspr(p->o.x,p->o.y,spr[(s-'A')*2+p->d],sprd[(s-'A')*2+p->d],p->color); -} - -void *PL_getspr(int s,int d) { - return spr[(s-'A')*2+d]; -} - static void chk_bfg(player_t *p,int x,int y) { int dx,dy; @@ -730,34 +667,3 @@ void bfg_fly(int x,int y,int o) { if(_2pl) if(o!=-2) chk_bfg(&pl2,x,y); if(o==-1 || o==-2) MN_warning(x-50,y-50,x+50,y+50); } - -void PL_drawst(player_t *p) { - V_setrect(WD,120,w_o,HT);Z_clrst(); - int i; - - if(p->drawst&PL_DRAWAIR) - if (p->airair); - if(p->drawst&PL_DRAWLIFE) - Z_drawstprcnt(0,p->life); - if(p->drawst&PL_DRAWARMOR) - Z_drawstprcnt(1,p->armor); - if(p->drawst&PL_DRAWWPN) { - switch(p->wpn) { - case 2: case 5: - i=p->ammo;break; - case 3: case 4: case 9: - i=p->shel;break; - case 6: - i=p->rock;break; - case 10: - i=p->fuel;break; - case 7: case 8: - i=p->cell;break; - } - Z_drawstwpn(p->wpn,i); - } - if(p->drawst&PL_DRAWFRAG) Z_drawstnum(p->frag); - if(p->drawst&PL_DRAWKEYS) Z_drawstkeys(p->keys); - if(!_2pl) if(p->drawst&PL_DRAWLIVES) Z_drawstlives(p->lives); -} diff --git a/src/player.h b/src/player.h index e56357c..2ddb96f 100644 --- a/src/player.h +++ b/src/player.h @@ -46,6 +46,7 @@ #define PLF_UP 4 #define PLF_DOWN 8 +#define PL_AIR 360 #define PL_POWERUP_TIME 546 #pragma pack(1) @@ -73,21 +74,20 @@ typedef struct{ }player_t; #pragma pack() +extern byte plr_goanim[], plr_dieanim[], plr_slopanim[]; + +extern byte p_immortal; +extern player_t pl1, pl2; + void PL_init(void); void PL_alloc(void); void PL_spawn(player_t *,int,int,char); int PL_hit(player_t *,int,int,int); int PL_isdead(player_t *); void PL_act(player_t *); -void PL_draw(player_t *); -void PL_drawst(player_t *); void PL_cry(player_t *); void PL_damage(player_t *); int PL_give(player_t *,int); void G_respawn_player(player_t *); void PL_reset(void); -void *PL_getspr(int c,int d); - -extern byte p_immortal; -extern player_t pl1,pl2; diff --git a/src/render.c b/src/render.c index 4c9eb0c..67cfef4 100644 --- a/src/render.c +++ b/src/render.c @@ -1,3 +1,5 @@ +#include +#include #include "glob.h" #include "render.h" #include "view.h" @@ -6,20 +8,290 @@ #include "vga.h" #include "menu.h" #include "misc.h" +#include "dots.h" +#include "items.h" +#include "monster.h" +#include "weapons.h" +#include "smoke.h" +#include "fx.h" +#include "memory.h" + +// game +static vgaimg *scrnh[3]; // TITLEPIC INTERPIC ENDPIC +static vgaimg *ltn[2][2]; +static void *cd_scr; +// smoke +static vgaimg *smk_spr[SMSN]; +static vgaimg *smk_fspr[FLSN]; +// fx +static vgaimg *fx_spr[15]; +static char fx_sprd[15]; +// weapons +static vgaimg *wp_spr[49*2]; +static char wp_sprd[49*2]; +// items +static vgaimg *item_spr[58]; +static char item_sprd[58]; +// player +static vgaimg *plr_spr[27*2]; +static char plr_sprd[27*2]; +static vgaimg *plr_wpn[11][6]; +// monsters +static vgaimg *pl_spr[2]; +static vgaimg *mn_spr[MN_TN][29*2]; +static char mn_sprd[MN_TN][29*2]; +static vgaimg *mn_fspr[8]; +static vgaimg *mn_sgun[2]; +// misc +#define MAXAIR 1091 +static vgaimg *sth[22], *bfh[160 - '!'], *sfh[160 - '!'], *stone, *stone2, *keys[3]; +static int prx = 0, pry = 0; +// menu +static vgaimg *msklh[2], *mbarl, *mbarm, *mbarr, *mbaro, *mslotl, *mslotm, *mslotr; extern byte clrmap[256*12]; // main.c -extern void *scrnh[3]; // game.c + extern int g_trans; // game.c extern byte transdraw; // game.c extern void *horiz; // view.c extern int sky_type; // view.c extern int lt_time, lt_type, lt_side, lt_ypos, lt_force; // game.c -extern void *ltn[2][2]; // game.c + +extern byte savname[7][24]; // files.c +extern char g_music[8]; // game.c +extern short snd_vol; // sound.c +extern short mus_vol; // music.c + +void Z_drawfld(byte *, int); // vga.c + +/* --- misc --- */ + +static void *Z_getspr (char n[4], int s, int d, char *dir) { + int h = F_getsprid(n, s, d); + if (dir) { + *dir = (h & 0x8000) ? 1 : 0; + } + return V_getvgaimg(h); +} + +static void Z_putbfch (int c) { + vgaimg *p; + if (c > 32 && c < 160) { + p = bfh[c - '!']; + } else { + p = NULL; + } + if (p) { + V_spr(prx, pry, p); + prx += p->w - 1; + } else { + prx += 12; + } +} + +static void Z_putsfch(int c) { + vgaimg *p; + if (c > 32 && c < 160) { + p = sfh[c - '!']; + } else { + p = NULL; + } + if (p) { + V_spr(prx, pry, p); + prx += p->w - 1; + } else { + prx += 7; + } +} + +static void Z_gotoxy (int x, int y) { + prx = x; + pry = y; +} + +static void Z_printbf(char *s, ...) { + int i; + va_list ap; + char buf[80]; + va_start(ap, s); + vsprintf(buf, s, ap); + va_end(ap); + for (i = 0; buf[i]; ++i) { + switch (buf[i]) { + case '\n': + pry += 13; + case '\r': + prx = 0; + break; + default: + Z_putbfch((byte)buf[i]); + } + } +} + +static void Z_printsf (char *s, ...) { + int i; + va_list ap; + char buf[80]; + va_start(ap, s); + vsprintf(buf, s, ap); + va_end(ap); + for (i = 0; buf[i]; ++i) { + switch(buf[i]) { + case '\n': + pry += 8; + case '\r': + prx=0; + break; + default: + Z_putsfch((byte)buf[i]); + } + } +} + +static void Z_drawspr (int x, int y, void *p, char d) { + if (d) { + V_spr2(x - w_x + WD / 2, y - w_y + HT / 2 + 1 + w_o, p); + } else { + V_spr(x - w_x + WD / 2, y - w_y + HT / 2 + 1 + w_o, p); + } +} + +static void Z_clrst (void) { + V_pic(SCRW - 120, w_o, stone); + int y = ((vgaimg*)stone)->h; + while (y < HT) { + V_pic(SCRW - 120, w_o + y, stone2); + y += ((vgaimg*)stone)->h; + } +} + +static void Z_drawstlives (char n) { + V_setrect(SCRW - 40, 30, w_o, 40); + V_spr(SCRW - 35, w_o + 17, sth[n]); +} + +static void Z_drawstkeys (byte k) { + int x, n; + V_setrect(SCRW - 120, 70, w_o + 77, 23); + for (k >>= 4, n = 0, x = SCRW - 75; n < 3; ++n, k >>= 1, x += 9) { + if (k & 1) { + V_spr(x, w_o + 91, keys[n]); + } + } +} + +static void Z_drawstair (int a) { + V_setrect(SCRW - 120, 120, w_o + 49, 2); + if (a > 0) { + if (a > MAXAIR) { + a = MAXAIR; + } + a = a * 100 / MAXAIR; + V_clr(SCRW - 110, a, w_o + 49, 2, 0xC8); + } +} + +static void Z_drawstprcnt (int y, int n) { + char s[20]; + int l, i, x, c; + V_setrect(SCRW - 120, 70, y * 19 + 7 + w_o, 19); + sprintf(s, "%3d%%", n); + l = strlen(s); + x = SCRW - 110; + for (i = 0; i < l; ++i, x += 14) { + if (s[i] >='0' && s[i] <= '9') { + c = s[i] - '0'; + } else if (s[i] == '-') { + c = 10; + } else if (s[i] == '%') { + c = 11; + } else { + c = -1; + } + if (c >= 0) { + V_spr(x, y * 19 + 7 + w_o, sth[c]); + } + } +} + +static void Z_drawstnum (int n) { + char s[20]; + int l, i, x, c; + V_setrect(SCRW - 50, 50, w_o + 77, 23); + if (g_dm) { + sprintf(s, "%d", n); + l = strlen(s); + x = (115 - l * 14) + SCRW - 120; + for (i = 0; i < l; ++i, x += 14) { + if (s[i] >= '0' && s[i] <= '9') { + c = s[i] - '0'; + } else if (s[i] == '-') { + c = 10; + } else if(s[i] == '%') { + c = 11; + } else { + c =- 1; + } + if (c >= 0) { + V_spr(x, w_o + 77 + 5, sth[c]); + } + } + } +} + +static void Z_drawstwpn (int n, int a) { + char s[20]; + int l, i, x, c; + i = n; + V_setrect(SCRW - 120, 120, w_o + 58, 23); + if (i >= 0) { + V_spr(SCRW - 88, w_o + 58 + 19, sth[i + 12]); + } + if (n >= 2) { + sprintf(s, "%d", a); + l = strlen(s); + x = SCRW - 10 - l * 14; + for (i = 0; i < l; ++i, x += 14) { + if (s[i] >= '0' && s[i] <= '9') { + c = s[i] - '0'; + } else if (s[i] == '-') { + c = 10; + } else if (s[i] == '%') { + c = 11; + } else { + c = -1; + } + if (c >= 0) { + V_spr(x, w_o + 58 + 2, sth[c]); + } + } + } +} + +static void Z_drawmanspr (int x, int y, void *p, char d, byte color) { + if (d) { + V_manspr2(x - w_x + WD / 2, y - w_y + HT / 2 + 1 + w_o, p, color); + } else { + V_manspr(x - w_x + WD / 2, y - w_y + HT / 2 + 1 + w_o, p, color); + } +} /* --- menu --- */ -/* +static int gm_tm = 0; // ??? + +static vgaimg *PL_getspr (int s, int d) { + return plr_spr[(s - 'A') * 2 + d]; +} + static int GM_draw (void) { + enum {MENU, MSG}; // copypasted from menu.c! + enum { + CANCEL, NEWGAME, LOADGAME, SAVEGAME, OPTIONS, QUITGAME, QUIT, ENDGAME, ENDGM, + PLR1, PLR2, COOP, DM, VOLUME, GAMMA, LOAD, SAVE, PLCOLOR, PLCEND, MUSIC, INTERP, + SVOLM, SVOLP, MVOLM, MVOLP, GAMMAM, GAMMAP, PL1CM, PL1CP, PL2CM, PL2CP + }; // copypasted from menu.c! int i, j, k, y; ++gm_tm; V_setrect(0, SCRW, 0, SCRH); @@ -57,8 +329,8 @@ static int GM_draw (void) { Z_printbf("%s", fullscreen ? "ON" : "OFF"); } else if(mnu->t[i] >= PL1CM) { V_manspr(mnu->x + (mnu->t[i] == PL1CM ? 15 : 35), y + i * 16 + 20 + 14, PL_getspr(*panimp, 0), pcolortab[(mnu->t[i] == PL1CM) ? p1color : p2color]); - } else if(mnu->t[i]>=SVOLM) { - j = y + i * 16 + 20' + } else if(mnu->t[i] >= SVOLM) { + j = y + i * 16 + 20; V_spr(mnu->x, j, mbarl); for (k = 8; k < 144; k += 8) { V_spr(mnu->x + k, j, mbarm); @@ -69,7 +341,7 @@ static int GM_draw (void) { case MVOLM: k = mus_vol; break; case GAMMAM: k = gammaa << 5; break; } - V_spr(mnu->x+8+k,j,mbaro); + V_spr(mnu->x + 8 + k, j, mbaro); } } V_spr(mnu->x - 25, y + mnu->cur * 16 + 20 - 8, msklh[(gm_tm / 6) & 1]); @@ -79,7 +351,378 @@ static int GM_draw (void) { } return 1; } -*/ + +/* --- dots --- */ + +static void DOT_draw (void) { + int i; + for (i = 0; i < MAXDOT; ++i) { + if (dot[i].t) { + V_dot(dot[i].o.x - w_x + WD / 2, dot[i].o.y - w_y + HT / 2 + 1 + w_o, dot[i].c); + } + } +} + +/* --- items --- */ + +static void IT_draw (void) { + int i, s; + for (i = 0; i < MAXITEM; ++i) { + s = -1; + if (it[i].t && it[i].s >= 0) { + switch(it[i].t & 0x7FFF) { + case I_ARM1: + s = it[i].s / 9 + 18; + break; + case I_ARM2: + s = it[i].s / 9 + 20; + break; + case I_MEGA: + s = it[i].s / 2 + 22; + break; + case I_INVL: + s = it[i].s / 2 + 26; + break; + case I_SUPER: + case I_RTORCH: + case I_GTORCH: + case I_BTORCH: + s = it[i].s / 2 + (it[i].t - I_SUPER) * 4 + 35; + break; + case I_GOR1: case I_FCAN: + s = it[i].s / 2 + (it[i].t - I_GOR1) * 3 + 51; + break; + case I_AQUA: + s = 30; + break; + case I_SUIT: + s = 34; + break; + case I_KEYR: + case I_KEYG: + case I_KEYB: + s = (it[i].t & 0x7FFF) - I_KEYR + 31; + break; + case I_GUN2: + s = 57; + break; + default: + s = (it[i].t & 0x7FFF) - 1; + } + } + if (s >= 0) { + Z_drawspr(it[i].o.x, it[i].o.y, item_spr[s], item_sprd[s]); + } + } +} + +/* --- player --- */ + +static int standspr (player_t *p) { + if (p->f & PLF_UP) { + return 'X'; + } else if (p->f & PLF_DOWN) { + return 'Z'; + } else { + return 'E'; + } +} + +static int wpnspr (player_t *p) { + if (p->f & PLF_UP) { + return 'C'; + } else if(p->f & PLF_DOWN) { + return 'E'; + } else { + return 'A'; + } +} + +static void PL_draw (player_t *p) { + enum {STAND, GO, DIE, SLOP, DEAD, MESS, OUT, FALL}; // copypasted from player.c! + static int wytab[] = {-1, -2, -1, 0}; + int s = 'A'; + int w = 0; + int wx = 0; + int wy = 0; + switch (p->st) { + case STAND: + if (p->f & PLF_FIRE) { + s = standspr(p) + 1; + w = wpnspr(p) + 1; + } else if (p->pain) { + s = 'G'; + w = 'A'; + wx = p->d ? 2 : -2; + wy = 1; + } else { + s = standspr(p); + w = wpnspr(p); + } + break; + case DEAD: + s = 'N'; + break; + case MESS: + s = 'W'; + break; + case GO: + if (p->pain) { + s = 'G'; + w = 'A'; + wx = p->d ? 2 : -2; + wy = 1; + } else { + s = plr_goanim[p->s / 8]; + w = (p->f & PLF_FIRE) ? 'B' : 'A'; + wx = p->d ? 2 : -2; + wy = 1 + wytab[s - 'A']; + } + break; + case DIE: + s = plr_dieanim[p->s]; + break; + case SLOP: + s = plr_slopanim[p->s]; + break; + case OUT: + s = 0; + break; + } + if (p->wpn == 0) { + w = 0; + } + if (w) { + Z_drawspr(p->o.x + wx, p->o.y + wy, plr_wpn[p->wpn][w - 'A'], p->d); + } + if (s) { + Z_drawmanspr(p->o.x, p->o.y, plr_spr[(s - 'A') * 2 + p->d], plr_sprd[(s - 'A') * 2 + p->d], p->color); + } +} + +static void PL_drawst (player_t *p) { + int i; + V_setrect(WD, 120, w_o, HT); + Z_clrst(); + if (p->drawst & PL_DRAWAIR) { + if (p->air < PL_AIR) { + Z_drawstair(p->air); + } + } + if (p->drawst & PL_DRAWLIFE) { + Z_drawstprcnt(0, p->life); + } + if (p->drawst & PL_DRAWARMOR) { + Z_drawstprcnt(1, p->armor); + } + if (p->drawst & PL_DRAWWPN) { + switch(p->wpn) { + case 2: + case 5: + i = p->ammo; + break; + case 3: + case 4: + case 9: + i = p->shel; + break; + case 6: + i = p->rock; + break; + case 10: + i = p->fuel; + break; + case 7: + case 8: + i = p->cell; + break; + } + Z_drawstwpn(p->wpn, i); + } + if (p->drawst & PL_DRAWFRAG) { + Z_drawstnum(p->frag); + } + if (p->drawst & PL_DRAWKEYS) { + Z_drawstkeys(p->keys); + } + if (!_2pl) { + if (p->drawst & PL_DRAWLIVES) { + Z_drawstlives(p->lives); + } + } +} + +/* --- monster --- */ + +#define MANCOLOR 0xD0 + +static void MN_draw (void) { + enum {SLEEP, GO, RUN, CLIMB, DIE, DEAD, ATTACK, SHOOT, PAIN, WAIT, REVIVE, RUNOUT}; // copypasted from monster.c! + int i; + for (i = 0; i < MAXMN; ++i) { + if (mn[i].t) { + if (mn[i].t >= MN_PL_DEAD) { + Z_drawmanspr(mn[i].o.x, mn[i].o.y, pl_spr[mn[i].t - MN_PL_DEAD], 0, mn[i].d); + continue; + } + if ((mn[i].t != MN_SOUL && mn[i].t != MN_PAIN) || mn[i].st != DEAD) { + if (mn[i].t != MN_MAN) { + Z_drawspr(mn[i].o.x, mn[i].o.y, mn_spr[mn[i].t - 1][(mn[i].ap[mn[i].ac] - 'A') * 2 + mn[i].d], mn_sprd[mn[i].t - 1][(mn[i].ap[mn[i].ac] - 'A') * 2 + mn[i].d]); + } else { + if (mn[i].ap[mn[i].ac] == 'E' || mn[i].ap[mn[i].ac] == 'F') { + Z_drawspr(mn[i].o.x, mn[i].o.y, mn_sgun[mn[i].ap[mn[i].ac] - 'E'], mn[i].d); + } + Z_drawmanspr(mn[i].o.x, mn[i].o.y, mn_spr[mn[i].t - 1][(mn[i].ap[mn[i].ac] - 'A') * 2 + mn[i].d], mn_sprd[mn[i].t - 1][(mn[i].ap[mn[i].ac] - 'A') * 2 + mn[i].d], MANCOLOR); + } + } + if (mn[i].t == MN_VILE && mn[i].st == SHOOT) { + Z_drawspr(mn[i].tx, mn[i].ty, mn_fspr[mn[i].ac / 3], 0); + } + } + } +} + +/* --- weapon --- */ + +static void WP_draw (void) { + enum {NONE, ROCKET, PLASMA, APLASMA, BALL1, BALL2, BALL7, BFGBALL, BFGHIT, MANF, REVF, FIRE}; // copypasted from weapons.c! + int i, s, d, x, y; + for (i = 0; i < MAXWPN; ++i) { + s = -1; + d = 0; + switch (wp[i].t) { + case NONE: + default: + break; + case REVF: + case ROCKET: + d = wp[i].s; + if (d < 2) { + d = wp[i].o.xv > 0 ? 1 : 0; + x = abs(wp[i].o.xv); + y = wp[i].o.yv; + s = 0; + if (y < 0) { + if (-y >= x) { + s = 30; + } + } else if (y > 0) { + if (y >= x / 2) { + s = 31; + } + } + } else { + s = (d - 2) / 2 + 1; + d = 0; + } + break; + case MANF: + s=wp[i].s; + if (s >= 2) { + s /= 2; + break; + } + case PLASMA: + case APLASMA: + case BALL1: + case BALL7: + case BALL2: + s = wp[i].s; + if (s >= 2) { + s = s / 2 + 1; + } + switch (wp[i].t) { + case PLASMA: + s += 4; + break; + case APLASMA: + s += 11; + break; + case BALL1: + s += 32; + break; + case BALL2: + s += 42; + break; + case BALL7: + s += 37; + d = wp[i].o.xv >= 0 ? 1 : 0; + break; + case MANF: + s += 47; + d=(wp[i].o.xv>=0)?1:0;break; + } + break; + case BFGBALL: + s = wp[i].s; + if (s >= 2) { + s = s / 2 + 1; + } + s += 18; + break; + case BFGHIT: + s = wp[i].s / 2 + 26; + break; + } + if (s >= 0) { + Z_drawspr(wp[i].o.x, wp[i].o.y, wp_spr[s * 2 + d], wp_sprd[s * 2 + d]); + } + } +} + +/* --- smoke --- */ + +static void SMK_draw (void) { + int i, s; + for (i = 0; i < MAXSMOK; ++i) { + if (sm[i].t) { + switch (sm[i].s) { + case 0: + s = sm[i].t; + if (s >= (SMSN - 1) * 3) { + s = 0; + } else { + s = SMSN - 1 - s / 3; + } + V_sprf((sm[i].x >> 8) - w_x + WD / 2, (sm[i].y >> 8) - w_y + HT / 2 + 1 + w_o, smk_spr[s], &smoke_sprf); + break; + case 1: + s = sm[i].t; + if (s >= FLSN - 1) { + s = 0; + } else { + s = FLSN - 1 - s; + } + V_sprf((sm[i].x >> 8) - w_x + WD / 2, (sm[i].y >> 8) - w_y + HT / 2 + 1 + w_o, smk_fspr[s], &flame_sprf); + break; + } + } + } +} + +/* --- fx --- */ + +static void FX_draw (void) { + enum {NONE, TFOG, IFOG, BUBL}; // copypasted from fx.c + int i, s; + for (i = 0; i < MAXFX; ++i) { + s = -1; + switch (fx[i].t) { + case TFOG: + s = fx[i].s / 2; + break; + case IFOG: + s = fx[i].s / 2 + 10; + break; + case BUBL: + V_dot((fx[i].x >> 8) - w_x + WD / 2, (fx[i].y >> 8) - w_y + HT / 2 + 1 + w_o, 0xC0 + fx[i].s); + continue; + } + if (s >= 0) { + Z_drawspr(fx[i].x, fx[i].y, fx_spr[s], fx_sprd[s]); + } + } +} /* --- view --- */ @@ -126,7 +769,7 @@ static void W_draw(void) { DOT_draw(); IT_draw(); PL_draw(&pl1); - if(_2pl) { + if (_2pl) { PL_draw(&pl2); } MN_draw(); @@ -134,8 +777,8 @@ static void W_draw(void) { SMK_draw(); FX_draw(); Z_drawfld((byte*)fldf, 0); - if(sky_type == 2) { - if(lt_time == -4 || lt_time == -2) { + if (sky_type == 2) { + if (lt_time == -4 || lt_time == -2) { V_remap_rect(0, WD, w_o + 1, HT, clrmap + 256 * 11); } } @@ -313,3 +956,206 @@ void G_draw (void) { } } +void R_alloc (void) { + int i, j, n; + char s[10]; + // game + scrnh[0] = V_loadvgaimg("TITLEPIC"); + scrnh[1] = V_loadvgaimg("INTERPIC"); + scrnh[2] = V_loadvgaimg("ENDPIC"); + cd_scr = M_lock(F_getresid("CD1PIC")); + for (i = 0; i < 2; ++i) { + sprintf(s, "LTN%c", i + '1'); + for (j = 0; j < 2; ++j) { + ltn[i][j] = Z_getspr(s, j, 0, NULL); + } + } + // smoke + for (i = 0; i < SMSN; ++i) { + smk_spr[i] = Z_getspr("SMOK", i, 0, NULL); + } + for (i = 0; i < FLSN; ++i) { + smk_fspr[i] = Z_getspr("FLAM", i, 0, NULL); + } + // fx + for (i = 0; i < 10; ++i) { + fx_spr[i] = Z_getspr("TFOG", i, 0, fx_sprd + i); + } + for (; i < 15; ++i) { + fx_spr[i] = Z_getspr("IFOG", i - 10, 0, fx_sprd + i); + } + // weapons + for (i = 0; i < 4; ++i) { + wp_spr[i * 2] = Z_getspr("MISL", i, 1, wp_sprd + i * 2); + wp_spr[i * 2 + 1] = Z_getspr("MISL", i, 2, wp_sprd + i * 2 + 1); + } + for (; i < 6; ++i) { + wp_spr[i * 2] = Z_getspr("PLSS", i - 4, 1, wp_sprd + i * 2); + wp_spr[i * 2 + 1] = Z_getspr("PLSS", i - 4, 2, wp_sprd + i * 2 + 1); + } + for (; i < 11; ++i) { + wp_spr[i * 2] = Z_getspr("PLSE", i - 6, 1, wp_sprd + i * 2); + wp_spr[i * 2 + 1] = Z_getspr("PLSE", i - 6, 2, wp_sprd + i * 2 + 1); + } + for (; i < 13; ++i) { + wp_spr[i * 2] = Z_getspr("APLS", i - 11, 1, wp_sprd + i * 2); + wp_spr[i * 2 + 1] = Z_getspr("APLS", i - 11, 2, wp_sprd + i * 2 + 1); + } + for (; i < 18; ++i) { + wp_spr[i * 2] = Z_getspr("APBX", i - 13, 1, wp_sprd + i * 2); + wp_spr[i * 2 + 1] = Z_getspr("APBX", i - 13, 2, wp_sprd + i * 2 + 1); + } + for(; i < 20; ++i) { + wp_spr[i * 2] = Z_getspr("BFS1", i - 18, 1, wp_sprd + i * 2); + wp_spr[i * 2 + 1] = Z_getspr("BFS1", i - 18, 2, wp_sprd + i * 2 + 1); + } + for (; i < 26; ++i) { + wp_spr[i * 2] = Z_getspr("BFE1", i - 20, 1, wp_sprd + i * 2); + wp_spr[i * 2 + 1] = Z_getspr("BFE1", i - 20, 2, wp_sprd + i * 2 + 1); + } + for (; i < 30; ++i) { + wp_spr[i * 2] = Z_getspr("BFE2", i - 26, 1, wp_sprd + i * 2); + wp_spr[i * 2 + 1] = Z_getspr("BFE2", i - 26, 2, wp_sprd + i * 2 + 1); + } + for (; i < 32; ++i) { + wp_spr[i * 2] = Z_getspr("MISL", i - 30 + 4, 1, wp_sprd + i * 2); + wp_spr[i * 2 + 1] = Z_getspr("MISL", i - 30 + 4, 2, wp_sprd + i * 2 + 1); + } + for (; i < 37; ++i) { + wp_spr[i * 2] = Z_getspr("BAL1", i - 32, 1, wp_sprd + i * 2); + wp_spr[i * 2 + 1] = Z_getspr("BAL1", i - 32, 2, wp_sprd + i * 2 + 1); + } + for (; i < 42; ++i) { + wp_spr[i * 2] = Z_getspr("BAL7", i - 37, 1, wp_sprd + i * 2); + wp_spr[i * 2 + 1] = Z_getspr("BAL7", i - 37, 2, wp_sprd + i * 2 + 1); + } + for (; i < 47; ++i) { + wp_spr[i * 2] = Z_getspr("BAL2", i - 42, 1, wp_sprd + i * 2); + wp_spr[i * 2 + 1] = Z_getspr("BAL2", i - 42, 2, wp_sprd + i * 2 + 1); + } + for (; i < 49; ++i) { + wp_spr[i * 2] = Z_getspr("MANF", i - 47, 1, wp_sprd + i * 2); + wp_spr[i * 2 + 1] = Z_getspr("MANF", i - 47, 2, wp_sprd + i * 2 + 1); + } + // items + static char snm[18][4] = { + "CLIP", "SHEL", "ROCK", "CELL", "AMMO", "SBOX", "BROK", "CELP", + "STIM", "MEDI", "BPAK", + "CSAW", "SHOT", "SGN2", "MGUN", "LAUN", "PLAS", "BFUG" + }; + static char n4[4][4] = { + "SOUL", "SMRT", "SMGT", "SMBT" + }; + static char n3[2][4] = { + "GOR1", "FCAN" + }; + for (i = 0; i < 18; ++i) { + item_spr[i] = Z_getspr(snm[i], 0, 0, item_sprd + i); + } + for (; i < 20; ++i) { + item_spr[i] = Z_getspr("ARM1", i - 18, 0, item_sprd + i); + item_spr[i + 2] = Z_getspr("ARM2", i - 18, 0, item_sprd + i); + } + i+=2; + for (; i < 26; ++i) { + item_spr[i] = Z_getspr("MEGA", i - 22, 0, item_sprd + i); + } + for (; i < 30; ++i) { + item_spr[i] = Z_getspr("PINV", i - 26, 0, item_sprd + i); + } + item_spr[30] = Z_getspr("AQUA", 0, 0, item_sprd + 30); + item_spr[31] = Z_getspr("KEYR", 0, 0, item_sprd + 31); + item_spr[32] = Z_getspr("KEYG", 0, 0, item_sprd + 32); + item_spr[33] = Z_getspr("KEYB", 0, 0, item_sprd + 33); + item_spr[34] = Z_getspr("SUIT", 0, 0, item_sprd + 34); + for (n = 35, j = 0; j < 4; ++j) { + for (i = 0; i < 4; ++i, ++n) { + item_spr[n] = Z_getspr(n4[j], i, 0, item_sprd + n); + } + } + for (j = 0; j < 2; ++j) { + for (i = 0; i < 3; ++i, ++n) { + item_spr[n] = Z_getspr(n3[j], i, 0, item_sprd + n); + } + } + item_spr[57] = Z_getspr("GUN2", 0, 0, item_sprd + 57); + // player + for (i = 0; i < 27; ++i) { + plr_spr[i * 2] = Z_getspr("PLAY", i, 1, plr_sprd + i * 2); + plr_spr[i * 2 + 1] = Z_getspr("PLAY", i, 2, plr_sprd + i * 2 + 1); + } + strncpy(s, "PWPx", 4); + for (i = 1; i < 11; ++i) { + s[3] = (i < 10 ? '0' : 'A' - 10) + i; + for (j = 0; j < 6; ++j) { + plr_wpn[i][j] = Z_getspr(s, j, 1, NULL); + } + } + // monsters + static char msn[MN_TN][4] = { + "SARG", "TROO", "POSS", "SPOS", "CYBR", "CPOS", "BOSS", "BOS2", "HEAD", "SKUL", + "PAIN", "SPID", "BSPI", "FATT", "SKEL", "VILE", "FISH", "BAR1", "ROBO", "PLAY" + }; + static int mms[MN_TN] = { + 14*2, 21*2, 21*2, 21*2, 16*2, 20*2, 15*2, 15*2, 12*2, 11*2, 13*2, 19*2, 16*2, + 20*2, 17*2, 29*2, 6*2, 2*2, 17*2, 23*2 + }; + mn_sgun[0] = Z_getspr("PWP4", 0, 1, NULL); + mn_sgun[1] = Z_getspr("PWP4", 1, 1, NULL); + for (j = 0; j < MN_TN; ++j) { + for (i = 0; i < mms[j]; ++i) { + mn_spr[j][i] = Z_getspr(msn[j], i / 2, (i & 1) + 1, &mn_sprd[j][i]); + } + if (j == MN_BARREL - 1) { + for (i = 4; i < 14; ++i) { + mn_spr[j][i] = Z_getspr("BEXP", i / 2 - 2, (i & 1) + 1, &mn_sprd[j][i]); + } + } + } + for (i = 0; i < 8; ++i) { + mn_fspr[i] = Z_getspr("FIRE", i, 0, NULL); + } + pl_spr[0] = Z_getspr("PLAY", 'N' - 'A', 0, NULL); + pl_spr[1] = Z_getspr("PLAY", 'W' - 'A', 0, NULL); + // misc + static char mnm[22][8]={ + "STTNUM0","STTNUM1","STTNUM2","STTNUM3","STTNUM4", + "STTNUM5","STTNUM6","STTNUM7","STTNUM8","STTNUM9", + "STTMINUS","STTPRCNT", + "FISTA0","CSAWA0","PISTA0","SHOTA0","SGN2A0","MGUNA0","LAUNA0", + "PLASA0","BFUGA0","GUN2A0" + }; + stone=V_loadvgaimg("STONE"); + stone2=V_loadvgaimg("STONE2"); + keys[0]=V_loadvgaimg("KEYRA0"); + keys[1]=V_loadvgaimg("KEYGA0"); + keys[2]=V_loadvgaimg("KEYBA0"); + for (i = 0; i < 22; ++i) { + sth[i] = V_loadvgaimg(mnm[i]); + } + strcpy(s, "STBF_*"); + for (i = '!'; i < 160; ++i) { + s[5] = i; + bfh[i - '!'] = V_getvgaimg(F_findres(s)); + } + for (i = '!'; i < 160; ++i) { + sprintf(s, "STCFN%03d", i); + sfh[i - '!'] = V_getvgaimg(F_findres(s)); + } + strcpy(s, "WINUM*"); + for (i = '0'; i <= '9'; ++i) { + s[5] = i; + bfh[i - '!'] = V_loadvgaimg(s); + } + bfh[':' - '!'] = V_loadvgaimg("WICOLON"); + // menu + msklh[0] = V_loadvgaimg("M_SKULL1"); + msklh[1] = V_loadvgaimg("M_SKULL2"); + mbarl = V_loadvgaimg("M_THERML"); + mbarm = V_loadvgaimg("M_THERMM"); + mbarr = V_loadvgaimg("M_THERMR"); + mbaro = V_loadvgaimg("M_THERMO"); + mslotl = V_loadvgaimg("M_LSLEFT"); + mslotm = V_loadvgaimg("M_LSCNTR"); + mslotr = V_loadvgaimg("M_LSRGHT"); +} diff --git a/src/render.h b/src/render.h index 553ca98..4f16eb3 100644 --- a/src/render.h +++ b/src/render.h @@ -1 +1,2 @@ void G_draw (void); +void R_alloc (void); diff --git a/src/smoke.c b/src/smoke.c index 2be63ad..1596159 100644 --- a/src/smoke.c +++ b/src/smoke.c @@ -31,22 +31,11 @@ #define MAXSR 20 -#define SMSN 10 -#define FLSN 8 - -#pragma pack(1) -typedef struct{ - int x,y,xv,yv; - byte t,s; - short o; -}smoke_t; -#pragma pack() - -static smoke_t sm[MAXSMOK]; +smoke_t sm[MAXSMOK]; + static int sr_r,sxr[MAXSR],syr[MAXSR]; static int lsm; -static void *spr[SMSN],*fspr[FLSN]; static void *burnsnd; static int burntm=0; @@ -99,10 +88,7 @@ void SMK_init(void) { void SMK_alloc(void) { int i; - burnsnd=Z_getsnd("BURN"); - for(i=0;i=(SMSN-1)*3) s=0; else s=SMSN-1-s/3; - V_sprf((sm[i].x>>8)-w_x+WD/2,(sm[i].y>>8)-w_y+HT/2+1+w_o,spr[s],&smoke_sprf);//V_sprf((sm[i].x>>8)-w_x+100,(sm[i].y>>8)-w_y+50+w_o,spr[s],&smoke_sprf); - break; - case 1: - if((s=sm[i].t)>=(FLSN-1)) s=0; else s=FLSN-1-s; - V_sprf((sm[i].x>>8)-w_x+WD/2,(sm[i].y>>8)-w_y+HT/2+1+w_o,fspr[s],&flame_sprf);//V_sprf((sm[i].x>>8)-w_x+100,(sm[i].y>>8)-w_y+50+w_o,fspr[s],&flame_sprf); - break; - } -} - void SMK_add(int x,int y,int xv,int yv,byte t,byte s,short o) { int i; diff --git a/src/smoke.h b/src/smoke.h index cb2102e..1f33f1d 100644 --- a/src/smoke.h +++ b/src/smoke.h @@ -23,10 +23,22 @@ #define MAXSMOK 500 +#define SMSN 10 +#define FLSN 8 + +#pragma pack(1) +typedef struct{ + int x,y,xv,yv; + byte t,s; + short o; +}smoke_t; +#pragma pack() + +extern smoke_t sm[MAXSMOK]; + void SMK_init(void); void SMK_alloc(void); void SMK_act(void); -void SMK_draw(void); void SMK_add(int x,int y,int xv,int yv,byte t,byte s,short o); void SMK_gas(int x,int y,int rx,int ry,int xv,int yv,int k); void SMK_flame(int x,int y,int ox,int oy,int rx,int ry,int xv,int yv,int k,int o); diff --git a/src/weapons.c b/src/weapons.c index c05f456..34b5ed4 100644 --- a/src/weapons.c +++ b/src/weapons.c @@ -37,18 +37,9 @@ void bfg_fly(int x,int y,int own); enum{NONE=0,ROCKET,PLASMA,APLASMA,BALL1,BALL2,BALL7,BFGBALL,BFGHIT, MANF,REVF,FIRE}; -#pragma pack(1) -typedef struct{ - obj_t o; - byte t,s; - int own; - short target; -}weapon_t; -#pragma pack() +weapon_t wp[MAXWPN]; -static void *snd[14],*spr[49*2]; -static char sprd[49*2]; -static weapon_t wp[MAXWPN]; +static void *snd[14]; static void throw(int,int,int,int,int,int,int,int); @@ -112,59 +103,6 @@ void WP_alloc(void) { "SPARK1", "SPARK2" }; - - for(i=0;i<4;++i) { - spr[i*2]=Z_getspr("MISL",i,1,sprd+i*2); - spr[i*2+1]=Z_getspr("MISL",i,2,sprd+i*2+1); - } - for(;i<6;++i) { - spr[i*2]=Z_getspr("PLSS",i-4,1,sprd+i*2); - spr[i*2+1]=Z_getspr("PLSS",i-4,2,sprd+i*2+1); - } - for(;i<11;++i) { - spr[i*2]=Z_getspr("PLSE",i-6,1,sprd+i*2); - spr[i*2+1]=Z_getspr("PLSE",i-6,2,sprd+i*2+1); - } - for(;i<13;++i) { - spr[i*2]=Z_getspr("APLS",i-11,1,sprd+i*2); - spr[i*2+1]=Z_getspr("APLS",i-11,2,sprd+i*2+1); - } - for(;i<18;++i) { - spr[i*2]=Z_getspr("APBX",i-13,1,sprd+i*2); - spr[i*2+1]=Z_getspr("APBX",i-13,2,sprd+i*2+1); - } - for(;i<20;++i) { - spr[i*2]=Z_getspr("BFS1",i-18,1,sprd+i*2); - spr[i*2+1]=Z_getspr("BFS1",i-18,2,sprd+i*2+1); - } - for(;i<26;++i) { - spr[i*2]=Z_getspr("BFE1",i-20,1,sprd+i*2); - spr[i*2+1]=Z_getspr("BFE1",i-20,2,sprd+i*2+1); - } - for(;i<30;++i) { - spr[i*2]=Z_getspr("BFE2",i-26,1,sprd+i*2); - spr[i*2+1]=Z_getspr("BFE2",i-26,2,sprd+i*2+1); - } - for(;i<32;++i) { - spr[i*2]=Z_getspr("MISL",i-30+4,1,sprd+i*2); - spr[i*2+1]=Z_getspr("MISL",i-30+4,2,sprd+i*2+1); - } - for(;i<37;++i) { - spr[i*2]=Z_getspr("BAL1",i-32,1,sprd+i*2); - spr[i*2+1]=Z_getspr("BAL1",i-32,2,sprd+i*2+1); - } - for(;i<42;++i) { - spr[i*2]=Z_getspr("BAL7",i-37,1,sprd+i*2); - spr[i*2+1]=Z_getspr("BAL7",i-37,2,sprd+i*2+1); - } - for(;i<47;++i) { - spr[i*2]=Z_getspr("BAL2",i-42,1,sprd+i*2); - spr[i*2+1]=Z_getspr("BAL2",i-42,2,sprd+i*2+1); - } - for(;i<49;++i) { - spr[i*2]=Z_getspr("MANF",i-47,1,sprd+i*2); - spr[i*2+1]=Z_getspr("MANF",i-47,2,sprd+i*2+1); - } for(i=0;i<14;++i) snd[i]=Z_getsnd(nm[i]); } @@ -254,48 +192,6 @@ void WP_act(void) { } } -void WP_draw(void) { - int i,s,d,x,y; - - for(i=0;i0)?1:0; - x=abs(wp[i].o.xv);y=wp[i].o.yv;s=0; - if(y<0) {if(-y>=x) s=30;} - else if(y>0) if(y>=x/2) s=31; - }else {s=(d-2)/2+1;d=0;} - break; - case MANF: - if((s=wp[i].s)>=2) {s/=2;break;} - case PLASMA: - case APLASMA: - case BALL1: - case BALL7: - case BALL2: - if((s=wp[i].s)>=2) s=s/2+1; - switch(wp[i].t) { - case PLASMA: s+=4;break; - case APLASMA: s+=11;break; - case BALL1: s+=32;break; - case BALL2: s+=42;break; - case BALL7: s+=37;d=(wp[i].o.xv>=0)?1:0;break; - case MANF: s+=47;d=(wp[i].o.xv>=0)?1:0;break; - }break; - case BFGBALL: - if((s=wp[i].s)>=2) s=s/2+1; - s+=18;break; - case BFGHIT: - s=wp[i].s/2+26;break; - } - if(s>=0) Z_drawspr(wp[i].o.x,wp[i].o.y,spr[s*2+d],sprd[s*2+d]); - } -} - void WP_gun(int x,int y,int xd,int yd,int o,int v) { register dword d,m; int sx,sy,lx,ly; diff --git a/src/weapons.h b/src/weapons.h index 6ef7460..b31593c 100644 --- a/src/weapons.h +++ b/src/weapons.h @@ -23,10 +23,20 @@ #define MAXWPN 300 +#pragma pack(1) +typedef struct{ + obj_t o; + byte t,s; + int own; + short target; +}weapon_t; +#pragma pack() + +extern weapon_t wp[MAXWPN]; + void WP_init(void); void WP_alloc(void); void WP_act(void); -void WP_draw(void); void WP_punch(int,int,int,int); int WP_chainsaw(int,int,int,int); void WP_gun(int,int,int,int,int,int);