diff --git a/BAK/CHAT.CXX b/BAK/CHAT.CXX new file mode 100644 index 0000000..26088d9 --- /dev/null +++ b/BAK/CHAT.CXX @@ -0,0 +1,163 @@ +#define IPXDEBUG + +#include "int.h" // My asm header file.. +#include +#include +#include +#include +#include + +#include "ipx.c" // More ipx code.. + +#define SERVER 1 +#define CLIENT 0 +#define SOCKET 0x869c // DOOM Socket +#define RECEIVERS 10 + +#define IPX_END 0 +#define IPX_SERVERSEARCH 1 +#define IPX_TEXTMESSAGE 2 + +int mode; +char str[255]; + +struct packet far *send,far *rec[RECEIVERS]; +unsigned short sendl,sendseg,recl[RECEIVERS],recseg[RECEIVERS]; + +void init_memory() +{ int a; + send=(struct packet far *)MK_FP(getlowmem(sizeof(struct packet)/16+1),0); + sendl=lsel; + sendseg=lseg; + initsendpacket(send,sendseg); + + for (a=0;a>4]; + str[1]=hex[ch&0xf]; +} + +char *decode_localaddress(char *str,struct localaddr far *la) +{ int a; + + for (a=0;a<4;a++) + char2hex(str+(a*2),la->network[a]); + str[8]=':'; + + for (a=0;a<6;a++) + char2hex(str+(a*2)+9,la->node[a]); + str[21]=0; + return(str); +} + +char *decode_address(char *str,struct netaddress far *la) +{ int a; + for (a=0;a<6;a++) + char2hex(str+(a*2),la->node[a]); + str[12]=0; + return(str); +} + +askserver() +{ + send->data[0]=IPX_SERVERSEARCH; + send->data[1]=IPX_END; + sendpacket(sendseg,MAXNODES,send,10); +} + +sendtext(char *string) +{ int a,l; + + l=strlen(string); + send->data[0]=IPX_TEXTMESSAGE; + for (a=0;adata[a+1]=string[a]; + send->data[l+1]=IPX_END; + sendpacket(sendseg,MAXNODES,send,l+2); +} + +clientloop() +{ + askserver(); + sendtext("Allu on mulukku"); + sendtext("Allu on mulukku2"); + sendtext("Allu on mulukku5"); +// waitserver(); +} + +serverloop() +{ int a; + int quit; + int data,ofs; + + quit=0; + while (kbhit()) getch(); + while (!quit) + for (a=0;aecb.inuse==0) + { + data=-1; + ofs=0; + while(data!=IPX_END) + { + data=rec[a]->data[ofs++]; + switch (data) + { + case IPX_SERVERSEARCH: + printf("Search request received from %s\n",decode_address(str,&(rec[a]->ipx.src))); + break; + case IPX_TEXTMESSAGE: + while ((data=rec[a]->data[ofs++])!=0) + putch(data); + printf("\n"); + break; + case IPX_END: + break; + default:printf("unknown command %d\n",data,data,data); + }; + + } + listenforpacket(recseg[a]); + } + else if (kbhit()) quit=1; +} + + +main(int argc, char *argv[]) +{ + argv=argv; + if (argc>1) mode=SERVER; + else mode=CLIENT; + + initipx(); // initialize the ipx routines. + + if (!opensocket(0,SOCKET)) + { + init_memory(); + printf("SocketID = %x\n",(dword)socketid); + getlocaladdress(); + printf("Local address: %s\n",decode_localaddress(str,localadd)); + + if (mode==SERVER) serverloop(); + else clientloop(); + + // Closing down IPX... + printf("Done.\n"); + closesocket(socketid); + } + else + { + printf("Unable to open socket (%x)!",(dword)SOCKET); + exit(0); + } +} diff --git a/BAK/CLASSES.CPP b/BAK/CLASSES.CPP new file mode 100644 index 0000000..6284412 --- /dev/null +++ b/BAK/CLASSES.CPP @@ -0,0 +1,1259 @@ +#include +#include +#include +#include +#include +#include +#include +#include "defines.h" +#include "globvar.h" +#include "classes.h" +#include "rout.h" +#include "newfuncs.h" +#include "miscfunc.h" +#include "write.h" +#include "draw.h" +#include "efp/efp.h" +#include "fade.h" + +void Light::make(int size) +{ + int a,b,pow,offs,dist,hsize; + + hsize=size/2; + + data=(char *)malloc(size*size); + + memset(data,0,size*size); + + for (a=0;a15) pow=15; + if (pow<0) pow=0; + data[offs]=(char)pow; + } + +} + +void Crate::move_text(){ +if (text_count>0){ +text_x+=cosi[text_angle]*4; +text_y+=sini[text_angle]*4; +text_count-=4; +if (text_count<=0) {IN_USE=0;if (KILLING_MODE==DEATHMATCH) wake_up_count=1;} +} +} + +void Crate::chk_wake_up(){ +if (wake_up_count>0){ + wake_up_count++; + if (wake_up_count>=300) { + new_effect(&normal_l,TELEPORT,x+8,y+8,0,0); + text_count=0;IN_USE=1;wake_up_count=0; + } +} +} + +void Player::random_place(){ +int a,size=20,ret=1; + +while (ret){ +ret=0; + x=rand()%level_x_size*20; + y=rand()%level_y_size*20; + if (level[(int)((y/20)*level_x_size+(x/20))].type!=FLOOR) ret=1; + if (level[(int)(((y+size)/20)*level_x_size+(x/20))].type!=FLOOR) ret=1; + if (level[(int)((y/20)*level_x_size+((x+size)/20))].type!=FLOOR) ret=1; + if (level[(int)(((y+size)/20)*level_x_size+((x+size)/20))].type!=FLOOR) ret=1; + if (ENEMIES_ON_GAME) + for (a=0;abody_part[a].x) + if (x+14body_part[a].y) + if (y+14=360) ang-=360; + body_part[a].angle=ang; + body_part[a].speed=6; + MIDASplaySample(hitwav,MIDAS_CHANNEL_AUTO,0,10000,EFFECT_VOLUME,MIDAS_PAN_MIDDLE); + } + +} + +void Player::chk_keys(int index){ + +int walk_chk=0; +int speedi=speed; + + if (k.state[K_LEFT]) if (! k.state[K_STRAFE]) rotate(9); + if ((k.state[K_STRAFE] && k.state[K_LEFT]) || k.state[K_LSTRAFE]) + { + move(int(rangle2+90)%360,speed*0.9,index); + walk_chk=1; + speedi=speed*0.8; + } + if (k.state[K_RIGHT]) if (! k.state[K_STRAFE]) rotate(-9); + if ((k.state[K_STRAFE] && k.state[K_RIGHT]) || k.state[K_RSTRAFE]) + { + move(int(rangle2+270)%360,speed*0.9,index); + walk_chk=1; + speedi=speed*0.8; + } + if (k.state[K_UP]) { move(rangle2,speedi,index); walk_chk=1;if (rand()%20==0) kick_body_parts();} + if (k.state[K_DOWN]) { move((int)(rangle2+180)%360,0.75*speedi,index); walk_chk=1;} + + if (walk_chk) if (WALK==0) WALK=1; + if (! walk_chk) WALK=0; + + if (k.state[K_SHOOT]) if (load_cnt==weapon[curr_weapon].loading_time) + if (bullets[weapon[curr_weapon].btype-1]>0) {shoot(index);if (curr_weapon==0) kick_body_parts();} + else {curr_weapon=0;shoot_cnt=0; } + if (! k.state[K_SHOOT]) shoot_cnt=0; else shoot_cnt++; + if (k.state[K_SHIFT]){ change_weapon(); k.state[K_SHIFT]=0;} + +if (GAME_MODE!=SPLIT_SCREEN){ + if (k.state[41]) curr_weapon=0; + if (k.state[2]) if (weapons[1]) {curr_weapon=1;load_cnt=0; } + if (k.state[3]) if (weapons[2]) {curr_weapon=2;load_cnt=0; } + if (k.state[4]) if (weapons[3]) {curr_weapon=3;load_cnt=0; } + if (k.state[5]) if (weapons[4]) {curr_weapon=4;load_cnt=0; } + if (k.state[6]) if (weapons[5]) {curr_weapon=5;load_cnt=0; } + if (k.state[7]) if (weapons[6]) {curr_weapon=6;load_cnt=0; } + if (k.state[8]) if (weapons[7]) {curr_weapon=7;load_cnt=0; } + if (k.state[9]) if (weapons[8]) {curr_weapon=8;load_cnt=0; } + if (k.state[10]) if (weapons[9]) {curr_weapon=9;load_cnt=0;} + if (k.state[11]) if (weapons[10]) {curr_weapon=10;load_cnt=0; } + if (k.state[12]) if (weapons[11]) {curr_weapon=11;load_cnt=0; } + } +} + +void Body_part::move(){ +int offs[2*4]; // ** +int reuna=4; //* * chk pointit on n„in +int reuna2=4; //* * +int rnx,rny; // ** +float newx,newy; + +newx=x+((int)speed*sini[angle]); +newy=y+((int)speed*cosi[angle]); + +rnx=newx; +rny=newy; + +if (num<12) +if ( rand()%3!=0 ) new_effect(0,BLOOD2,int(x)+10,int(y)+10,0,0); + +offs[0]=((rny+reuna)/20)*level_x_size+((rnx+10-reuna2)/20); +offs[1]=((rny+reuna)/20)*level_x_size+((rnx+10+reuna2)/20); + +offs[2]=((rny+20-reuna)/20)*level_x_size+((rnx+10-reuna2)/20); +offs[3]=((rny+20-reuna)/20)*level_x_size+((rnx+10+reuna2)/20); + +offs[4]=((rny+10-reuna2)/20)*level_x_size+((rnx+reuna)/20); +offs[5]=((rny+10+reuna2)/20)*level_x_size+((rnx+reuna)/20); + +offs[6]=((rny+10-reuna2)/20)*level_x_size+((rnx+20-reuna)/20); +offs[7]=((rny+10+reuna2)/20)*level_x_size+((rnx+20-reuna)/20); + + if (newyy) + + if (level[offs[2]].type==FLOOR) + if (level[offs[3]].type==FLOOR) + y=newy; + + if (newxx) + + if (level[offs[6]].type==FLOOR) + if (level[offs[7]].type==FLOOR) + x=newx; +} + +void Player::animate(){ + + if (weapon[curr_weapon].gun==0) ANIM=1; else ANIM=4; + if (WALK){ + + if (WALK-1=3) ANIM=1 ; + if (weapon[curr_weapon].gun==1) ANIM+=3; + } + if (FIRE) {FIRE++; + if (FIRE>3) FIRE=0; + if (weapon[curr_weapon].gun==0) ANIM=7;else ANIM=6; + } + + if (DEAD){ + + if (DEAD-15) KICK=0; + if (curr_weapon==0) ANIM=19; else ANIM=20; + if (energy<20) ANIM+=2; + } + +} + + +void Enemy::animate() +{ + +ANIM=1; +if (WALK){ + + if (WALK-1=3) ANIM=1 ; + } + + if (FIRE) {FIRE++; + if (FIRE>3) FIRE=0; + ANIM=3; + } + +if (! DEAD) +if (energy<10) ANIM+=4; + +} + + + + +void Effect::roll(){ +if (IN_USE) { + if (counttcount*type->delay) + if (type->random==0) count++; + else + count+=rand()%3; + if (count>=type->tcount*type->delay) IN_USE=0; + if (speed>0) { + x+=speed*sini[angle]; + y+=speed*cosi[angle]; + if (level[(int)(y/20)*level_x_size+(int)(x/20)].type!=FLOOR) IN_USE=0; + } + if (IN_USE==0) if (type->index==BLOOD) new_effect(0,BLOOD2,x,y,0,0); +} +} + + +void Player::change_weapon(){ + + curr_weapon++; + while (weapons[curr_weapon%=DIFF_WEAPONS+1]==0) {curr_weapon++;curr_weapon%=DIFF_WEAPONS+1;} + load_cnt=0; +} + +void Player::footprint(int side){ +int a,do_it=0,footx,footy,footoffs; + +footx=x+15+(sini[(rangle2+90+(side*180))%360]*4); +footy=y+15+(cosi[(rangle2+90+(side*180))%360]*4); +footoffs=(footy/20)*level_x_size+(footx/20); + +if (level[footoffs].type==FLOOR) + for (a=0;aenemy[a].x) + if (rnx+15enemy[a].y+reuna) + if (rny+reunaplayer[b].x) + if (rnx+15player[b].y+reuna) + if (rny+reunay) + + if (level[offs[2]].type==FLOOR) + if (level[offs[3]].type==FLOOR){ + + for (chk=0,a=0;aenemy[a].x) + if (rnx+15enemy[a].y+reuna) + if (rny+28-reunaplayer[b].x) + if (rnx+15player[b].y+reuna) + if (rny+28-reunaenemy[a].x+reuna) + if (rnx+reunaenemy[a].y) + if (rny+15player[b].x+reuna) + if (rnx+reunaplayer[b].y) + if (rny+15x) + + if (level[offs[6]].type==FLOOR) + if (level[offs[7]].type==FLOOR){ + + for (chk=0,a=0;aenemy[a].x+reuna) + if (rnx+28-reunaenemy[a].y) + if (rny+15player[b].x+reuna) + if (rnx+28-reunaplayer[b].y) + if (rny+15x) + if (crate[a].x+7y) + if (crate[a].y+7bullet_type[crate[a].bullet+1].max*bullet_type[crate[a].bullet+1].mul) bullets[crate[a].bullet]=bullet_type[crate[a].bullet+1].max*bullet_type[crate[a].bullet+1].mul; + crate_taken=1;} + if (crate[a].type==2) if (energymax_energy+shield*10) energy=max_energy+shield*10;crate_taken=1;} + if (crate_taken){ + MIDASplaySample(klikwav,MIDAS_CHANNEL_AUTO,0,11250,EFFECT_VOLUME,MIDAS_PAN_MIDDLE); + + if (crate[a].type==0) + strcpy(crate[a].text,weapon[crate[a].weapon+1].name); + if (crate[a].type==1) + strcpy(crate[a].text,bullet_type[crate[a].bullet+1].name); + if (crate[a].type==2) + strcpy(crate[a].text,"Energy"); + + if (index==0){ + crate[a].text_x=crate[a].x+7-str_length(crate[a].text)-scr_x; + crate[a].text_y=crate[a].y+7-scr_y; + crate[a].text_count=get_dist(crate[a].text_x,crate[a].text_y,10,scr_y_size-20)+1; + crate[a].text_angle=get_angle(crate[a].text_x,crate[a].text_y,10,scr_y_size-20); + } + if (GAME_MODE==SPLIT_SCREEN) + if (index==1){ + crate[a].text_x=crate[a].x+7-str_length(crate[a].text)-scr_x+160; + crate[a].text_y=crate[a].y+7-scr_y; + crate[a].text_count=get_dist(crate[a].text_x,crate[a].text_y,170,scr_y_size-20)+1; + crate[a].text_angle=get_angle(crate[a].text_x,crate[a].text_y,170,scr_y_size-20); + } + } +} + +} + +void Player::rotate(int change){ + + angle+=change; + if (angle>=360) angle-=360; + if (angle<0) angle+=360; + rangle=angle/9; + rangle2=rangle*9; +} + +void Player::move_scr(){ +int spd; + +if (GAME_MODE==SPLIT_SCREEN){ + + if (abs((scr_x+80)-(x+14))>100) scr_x=x-80; + + spd=abs((scr_x+80)-((35*sini[angle])+x+14))/4; + + if (scr_x+80<(35*sini[angle])+x+14) scr_x+=spd; + if (scr_x+80>(35*sini[angle])+x+14) scr_x-=spd; + + if (scr_x<0) scr_x=0; + if (scr_x>(level_x_size*20)-160) scr_x=(level_x_size*20)-160; + +} else { + + if (abs((scr_x+160)-(x+14))>160) scr_x=x-160; + + spd=abs((scr_x+160)-((25*sini[angle])+x+14))/4; + + if (scr_x+160<(25*sini[angle])+x+14) scr_x+=spd; + if (scr_x+160>(25*sini[angle])+x+14) scr_x-=spd; + + if (scr_x<0) scr_x=0; + if (scr_x>(level_x_size*20)-320) scr_x=(level_x_size*20)-320; + +} + + if (abs((scr_y+(scr_y_size/2))-(y+14))>120) scr_y=y-(scr_y_size/2); + + spd=abs((scr_y+(scr_y_size/2))-((25*cosi[angle])+y+14))/4; + + if (scr_y+(scr_y_size/2)<(25*cosi[angle])+y+14) scr_y+=spd; + if (scr_y+(scr_y_size/2)>(25*cosi[angle])+y+14) scr_y-=spd; + + if (scr_y>(level_y_size*20)-scr_y_size) scr_y=(level_y_size*20)-scr_y_size; + if (scr_y<0) scr_y=0; + +} + + +void Player::load(){ + +if (load_cnt360) max-=360; + +for (b=0;b90){ // n„k”kentt„ 180 astetta + if (angle_pl[b]>min && angle_pl[b]min || angle_pl[b]player[b].x+5) + if (rxplayer[b].y+5) + if (ry1) + for (b=0;benemy[a].x) + if (rnx+15enemy[a].y+reuna) + if (rny+reunaplayer[a].x) + if (rnx+15player[a].y+reuna) + if (rny+reunay) + + if (level[offs[2]].type==FLOOR) + if (level[offs[3]].type==FLOOR){ + + for (chk=0,a=0;aenemy[a].x) + if (rnx+15enemy[a].y+reuna) + if (rny+28-reunaplayer[a].x) + if (rnx+15player[a].y+reuna) + if (rny+28-reunaenemy[a].x+reuna) + if (rnx+reunaenemy[a].y) + if (rny+15player[a].x+reuna) + if (rnx+reunaplayer[a].y) + if (rny+15x) + + if (level[offs[6]].type==FLOOR) + if (level[offs[7]].type==FLOOR){ + + for (chk=0,a=0;aenemy[a].x+reuna) + if (rnx+28-reunaenemy[a].y) + if (rny+15player[a].x+reuna) + if (rnx+28-reunaplayer[a].y) + if (rny+155) spd=5; + +if (GAME_MODE!=SPLIT_SCREEN) { // stereo effect + pan=(float)(-(player[0].x-x))/2; + if (pan<-63) pan=-63; + if (pan>63) pan=63; +} + + energy-=damage; + if (energy<=0) { + if (burning) { + MIDASplaySample(wooshwav,MIDAS_CHANNEL_AUTO,0,20000,EFFECT_VOLUME,pan); + new_effect(&explo_l,EXPLO,x+12,y+12,0,0); + new_effect(&explo_l,EXPLO,x+18,y+12,0,0); + new_effect(&explo_l,EXPLO,x+15,y+18,0,0); + for (a=0;a<3;a++) + new_body_part(x+4,y+4,rand()%360,5,a+12); + } + else { + for (a=0;a<16;a++) + if (rand()%2) + new_effect(0,BLOOD,x+15,y+15,a*22.5,4); + for (a=0;a<3;a++) + new_body_part(x+4,y+4,rand()%360,spd+(rand()%2),(a+alku)%7); + MIDASplaySample(deathwav,MIDAS_CHANNEL_AUTO,0,20000-(rand()%3000),EFFECT_VOLUME,pan); + } + DEAD=1; + DEAD_ENEMIES++; + if (KILLING_MODE!=DEATHMATCH) if (DEAD_ENEMIES>=ENEMIES) next_level=1; + if (P!=NULL) + P->kills[type]++; + } +} + +void Player::get_damage(float damage,Player *P){ +int a; + + HIT=15; + energy-=damage; + if (energy<=0) { + if (burning) { + MIDASplaySample(wooshwav,MIDAS_CHANNEL_AUTO,0,20000,EFFECT_VOLUME,MIDAS_PAN_MIDDLE); + new_effect(&explo_l,EXPLO,x+12,y+12,0,0); + new_effect(&explo_l,EXPLO,x+18,y+12,0,0); + new_effect(&explo_l,EXPLO,x+15,y+18,0,0); + } + else {for (a=0;a<16;a++) + if (rand()%2) + new_effect(0,BLOOD,x+15,y+15,a*22.5,4); + MIDASplaySample(deathwav,MIDAS_CHANNEL_AUTO,0,20000-(rand()%3000),EFFECT_VOLUME,MIDAS_PAN_MIDDLE); + } + DEAD=1; + if (P!=NULL){ + if (P!=this) + P->player_kills++; + else P->player_kills--; + } + } +} + +void Player::see(){ +int offs,a,b,ang,stop; +int tx,ty,mx,my,ox,oy,nx,ny; +int range=12,korona=2*pi*range+5; + +tx=(x+15)/20; +ty=(y+15)/20; + +for (a=0;aspeed; + looptimes=speed>>2; + if (speed==0) looptimes=1; + + time--; + count++; + + for(a=0;a0) { + x+=(float) speed/(speed>>2)*sini[angle]; + y+=(float) speed/(speed>>2)*cosi[angle]; + } + + rx=x; + ry=y; + + if (type->speed>0) + if (level[(int)(ry/20)*level_x_size+(int)(rx/20)].type!=FLOOR) {kosh=1;} + +if (count>type->sleep_time) +if (type->stop) { + + +if (GAME_MODE!=NETWORK|| + (GAME_MODE==NETWORK&&NETWORK_MODE==SERVER)) + for (b=0;benemy[b].x+5) + if (rxenemy[b].y+5) + if (rypush_power>enemy[b].PUSH_POWER) + enemy[b].PUSH_POWER=(float)type->push_power; // „ij„ lent„„ + enemy[b].get_damage(type->power,P); + if (type->type==INCENDIARY) {enemy[b].burning+=10; + enemy[b].Frying_player=P;} + } + +for (b=0;bplayer[b].x+5) + if (rxplayer[b].y+5) + if (rypush_power>player[b].PUSH_POWER) + player[b].PUSH_POWER=(float)type->push_power; // „ij„ lent„„ + player[b].get_damage(type->power,P); + if (type->type==INCENDIARY) { player[b].burning+=10; + player[b].Frying_player=P;} + } + } + +} + +if (type->type==NORMAL) + if (kosh) if (rand()%8==1) new_effect(&normal_l,METAL,rx,ry,rand()%360,(rand()%3)+5); + + if (hit) { + +if (type->type==NORMAL){ + + bp=6+(type->power/3)+rand()%3; + if (bp>8) bp=8; + + for (a=0;a<(type->power/5)+1;a++) + new_effect(0,BLOOD,vx+(rand()%6)-3,vy+(rand()%6)-3,angle+((rand()%30)-15),bp); +} + + if (P!=0) + P->hitten++; + + if (type->speed<10 && type->time==1) // if fist + MIDASplaySample(*weapon[0].sound,MIDAS_CHANNEL_AUTO,0,sample_rates[0],EFFECT_VOLUME,MIDAS_PAN_MIDDLE); + } + +if (type->type==NORMAL) +if (! hit) + if (time==0 || kosh){ + if (type->speed<10 && type->time==1) { } + else new_effect(&normal_l,SMOKE,rx,ry,0,0); } + + if (hit || kosh || time==0) { + if (type->type==EXPLOSIVE) explo(rx-(5*sini[angle]),ry-(5*cosi[angle]),type->explos,P,index); + IN_USE=0; + } + + if (type->effect!=0) + if (type->effect==EXPLO) new_effect(&explo_l,type->effect,rx,ry,angle+180,1); + else new_effect(0,type->effect,rx,ry,0,0); + +} + +void Player::shoot(int index){ +int r,a,rx=x,ry=y; + +FIRE=1; + +load_cnt=0; + + +for (a=0;a>1)-rand()%weapon[curr_weapon].angle_add; + new_bullet(weapon[curr_weapon].btype,rx+14+(10*sini[rangle2]),ry+14+(10*cosi[rangle2]),rangle2+r,0,this,index); +} + +if (curr_weapon>0) bullets[weapon[curr_weapon].btype-1]--; + +if (curr_weapon>0) +if (weapon[curr_weapon].sound != NULL) +if (shoot_cnt%bullet_type[weapon[curr_weapon].btype].mul==0) + MIDASplaySample(*weapon[curr_weapon].sound,MIDAS_CHANNEL_AUTO,0,sample_rates[curr_weapon],EFFECT_VOLUME,MIDAS_PAN_MIDDLE); + +if (shoot_cnt%bullet_type[weapon[curr_weapon].btype].mul==0) + if (weapon[curr_weapon].smoke) + new_effect(0,SMOKE3,rx+14+(8*sini[rangle2]+8*sini[(rangle2+270)%360]),ry+14+(8*cosi[rangle2]+8*cosi[(rangle2+270)%360]),rangle2,1); +} + + + +void Enemy::shoot(){ +int r,a,rx=x,ry=y,weaponi=enemy_info[type].curr_weapon; +int pan=0; + +FIRE=1; +load_cnt=0; + +for (a=0;a63) pan=63; +} + +if (weaponi>0) +if (shoot_cnt%bullet_type[weapon[weaponi].btype].mul==0) + MIDASplaySample(*weapon[weaponi].sound,MIDAS_CHANNEL_AUTO,0,sample_rates[weaponi],EFFECT_VOLUME,pan); + +if (shoot_cnt%bullet_type[weapon[weaponi].btype].mul==0) + if (weapon[weaponi].smoke) + new_effect(0,SMOKE3,rx+14+(8*sini[(int)(rangle*9)]+5*sini[((int)(rangle*9)+270)%360]),ry+14+(8*cosi[(int)(rangle*9)]+5*cosi[((int)(rangle*9)+270)%360]),angle,1); + +} + +void Enemy::chk_for_shoot(){ + +int dist,a,wannashoot=0; + +if (enemy_info[type].curr_weapon>0) + +for (a=0;abullet_type[weapon[enemy_info[type].curr_weapon].btype].time*bullet_type[weapon[enemy_info[type].curr_weapon].btype].speed) + walk_cnt=20/enemy_info[type].speed; + } + } + +if (! wannashoot) shoot_cnt=0; + +} + +void Enemy::rotate(){ // Nerokas k„„ntymis funktio !!! +int kaanty_jo=0; + +if (angle!=tangle){ +if (angle<180){ +if (tangleangle) angle+=ROT_SPEED;else angle-=ROT_SPEED; +kaanty_jo=1; +} + +if (angle>=180 && kaanty_jo==0) +if (tangle>angle-180 && tangle23) cnt=0; + } + + MIDASplaySample(klikwav,MIDAS_CHANNEL_AUTO,0,22500,EFFECT_VOLUME,MIDAS_PAN_MIDDLE); + + if (k.state[94]) {selected--;if (selected<0) selected=DIFF_K-1;k.state[94]=0;} + if (k.state[99]) {selected++;if (selected>=DIFF_K) selected=0;k.state[99]=0;} + if (k.state[28]) { + k.state[28]=0; + k.clear_stack(); + if (selected==0) {clear_shit(47);K_UP=get_key(160,45);} + if (selected==1) {clear_shit(47+8);K_DOWN=get_key(160,45+8);} + if (selected==2) {clear_shit(47+(2*8));K_LEFT=get_key(160,45+(2*8));} + if (selected==3) {clear_shit(47+(3*8));K_RIGHT=get_key(160,45+(3*8));} + if (selected==4) {clear_shit(47+(4*8));K_SHOOT=get_key(160,45+(4*8));} + if (selected==5) {clear_shit(47+(5*8));K_SHIFT=get_key(160,45+(5*8));} + if (selected==6) {clear_shit(47+(6*8));K_STRAFE=get_key(160,45+(6*8));} + if (selected==7) {clear_shit(47+(7*8));K_LSTRAFE=get_key(160,45+(7*8));} + if (selected==8) {clear_shit(47+(8*8));K_RSTRAFE=get_key(160,45+(8*8));} + if (selected==9) {quit=1;} + } + if (k.state[1]) {quit=1;k.state[1]=0;} +} + +fadeout(virbuff,pal); + +} + diff --git a/BAK/CLASSES.H b/BAK/CLASSES.H new file mode 100644 index 0000000..7b0793f --- /dev/null +++ b/BAK/CLASSES.H @@ -0,0 +1,255 @@ +#ifndef __TK__CLASSES__ +#define __TK__CLASSES__ + + +#include "defines.h" +#include "types.h" +#include "ipx/ipx.h" + +class Crate +{ + public: + int type; + int weapon; + int bullet; + int energy; + int x,y; + int IN_USE; + int text_angle; + int text_count; + int wake_up_count; + float text_x,text_y; + char text[20]; + + void move_text(); + void chk_wake_up(); +}; + +class General_level_info{ + public: + char comment[20]; + int time_limit; // seconds + int enemies[DIFF_ENEMIES]; +}; + +class Normal_game_level_info{ + public: + int weapon_crates[DIFF_WEAPONS]; + int bullet_crates[DIFF_BULLETS]; + int energy_crates; +}; + +class Death_match_level_info{ + public: + int weapon_crates[DIFF_WEAPONS]; + int bullet_crates[DIFF_BULLETS]; + int energy_crates; +}; + +class Spot{ + public: + int x; + int y; + int size; +}; + +class Steam{ + public: + int x; + int y; + int angle; + int speed; +}; + +class Light_table{ + public: + char data[256][16]; +}; + +class Body_part{ + public: + float x,y; + int angle; + int num; + float speed; + int IN_USE; + + void move(); +}; + +class Effect_type +{ + +public: + int index; + int tcount; + int order; + int delay; + int random; // boolean + int xs,ys,offs; + +}; + +class Bullet_type{ + public: + + char name[20]; + + int type; + int stop; + int speed; + float power; + int time; + int explos; // power of explosive + int push_power; + int cost; + int amount_in_crate; + int mul; + int sleep_time; + int max; + + char *sprite; + int xs,ys,offs,xsize; + Light_table *light; + int lsize; + int llum; + float ladd; + + int effect; +}; + + +class Effect{ + public: + float x,y; + int angle; + int speed; + Effect_type *type; + int count; + int IN_USE; + Light_table *lt; + int age; + + void roll(); +}; + + +class Player{ + + public: + float x,y; + char *see_level; + int speed,angle,rangle,rangle2,scr_x,scr_y; + int weapons[DIFF_WEAPONS+1]; + int curr_weapon,load_cnt; + int shoot_cnt; + int bullets[DIFF_BULLETS]; + int cash; + int max_energy; + float energy; + int shield; + int color; + int burning; + Player *Frying_player; + nodeaddr ipxnode; + char name[10]; + + int HIT,WALK,FIRE,DEAD,KICK,ANIM; + + int K_LEFT,K_RIGHT,K_UP,K_DOWN,K_SHOOT,K_SHIFT,K_STRAFE,K_LSTRAFE,K_RSTRAFE; + + int TARGET; + + float PUSH_POWER; + int PUSH_ANGLE; + + int kills[DIFF_ENEMIES]; + int total_kills; + int shooted,hitten; + int player_kills; + + void footprint(int side); + void kick_body_parts(); + void chk_keys(int index); + void animate(); + void move(int angle,float spd,int index); + void shoot(int index); + void load(); + void change_weapon(); + void get_damage(float damage,Player *P); + void rotate(int change); + void move_scr(); + void shop(); + void see(); + void random_place(); + void death_match_start_up(); +}; + +class Bullet{ + public: + float x,y; + Bullet_type *type; + Player *P; + int index; + int angle; + int time; + int count; + int IN_USE; + + void move(); +}; + +class Keys{ + + public: + int K_LEFT,K_RIGHT,K_UP,K_DOWN,K_SHOOT,K_SHIFT,K_STRAFE,K_LSTRAFE,K_RSTRAFE; + + void change(); +}; + +class Enemy{ + + public: + float x,y; + int angle,rangle,tangle,walk_cnt,load_cnt; + float energy; + int shoot_cnt; + int angle_pl[MAX_PLAYERS]; + int type; + int burning; + Player *Frying_player; + + float PUSH_POWER; + int PUSH_ANGLE; + + int WALK,FIRE,SEE_PL[MAX_PLAYERS],DEAD,ANIM; + int see_somebody; + + void footprint(int side); + void animate(); + void move(int angle,int spd); + void shoot(); + void rotate(); + void get_angles(); + void get_damage(float damage,Player *P); + void try_see_players(); + void load(); + void chk_for_shoot(); +}; + +class Light{ + public: + char *data; + void make(int size); +}; + +class Level{ + +public: +int version; +void load(char name[13]); + +}; + + +#endif diff --git a/BAK/CLASSES.OBJ b/BAK/CLASSES.OBJ new file mode 100644 index 0000000..5fc0749 Binary files /dev/null and b/BAK/CLASSES.OBJ differ diff --git a/BAK/DEFINES.H b/BAK/DEFINES.H new file mode 100644 index 0000000..76a299a --- /dev/null +++ b/BAK/DEFINES.H @@ -0,0 +1,81 @@ +#ifndef __TK__DEFINES__ +#define __TK__DEFINES__ + +#define Version "v1.2" + +#define pi 3.14159265358979 +#define MAX_PLAYERS 8 // max amount of players in game + +#define DIFF_BULLETS 9 +#define DIFF_WEAPONS 11 +#define DIFF_ENEMIES 7 + +#define ONE_PLAYER 0 +#define SPLIT_SCREEN 1 +#define NETWORK 2 + +#define COOPERATIVE 0 +#define DEATHMATCH 1 + +#define NORMAL 0 // panos tyyppej„ +#define EXPLOSIVE 1 +#define INCENDIARY 2 + +#define FLOOR 0 // blockki tyyppej„ +#define WALLS 1 + +#define MAX_ENEMIES 100 // max amount of enemies in game +#define MAX_BODY_PARTS 300 // max amount of bodyparts in game +#define MAX_EFFECTS 300 // max amount of effects in game +#define MAX_BULLETS 300 // max amount of bullets in game +#define MAX_SPOTS 100 // max amount of spot lights in game +#define MAX_STEAM 100 // max amount of steams in game +#define MAX_CRATES 100 // max amount of crates in game + +#define WALK_DELAY 20 // walk animation delay +#define DEAD_DELAY 15 // dead animation delay +#define C_DELAY 300 // level complete delay + +#define ROT_SPEED 9 // computer players rotate speed + +#define M_BLUE 113 // punainen +#define M_RED 64 // sinert„v„ +#define M_YELLOW 144 // keltainen + +#define TIME_ADD 1.1 // action time'll be multiplied with this +#define LIGHTS 10 +#define TARGET_FRAMES 40 + +#define DUST_BLOCKS 10 +#define Menu_texts 4 + +#define SERVER 1 +#define CLIENT 0 +#define RECEIVERS 10 + +#define num_options 5 +#define num_player_options 5 +#define num_game_options 4 +#define num_sound_options 3 +#define num_deathmatch_options 3 +#define num_multip_options 7 + +#define DIFF_K 10 +#define SPEC_K 21 + +// Effects... + +#define BLOOD 0 // effects +#define SMOKE 1 +#define EXPLO 2 +#define METAL 3 +#define SMOKE2 4 +#define BLOOD2 5 +#define SMOKE3 6 +#define STEAM 7 +#define TELEPORT 8 +#define FOOTPRINT 9 +#define EXPLO_RAY 10 + + +#endif diff --git a/BAK/DRAW.CPP b/BAK/DRAW.CPP new file mode 100644 index 0000000..2bd55dd --- /dev/null +++ b/BAK/DRAW.CPP @@ -0,0 +1,996 @@ +#include +#include +#include +#include +#include "defines.h" +#include "types.h" +#include "globvar.h" +#include "classes.h" +#include "write.h" + +// 20 x 20 +void draw_block(int x,int y,int type, int num,int mode){ +int a,offs,offs2; +char *texture,*gofs; +int sx=0,ex=20,sy=0,ey=20; + +if (x<0) sx=-x; +if (sx>20) sx=20; +if (x>300) ex=20-(x-300); +if (ex<0) ex=0; +if (y<0) sy=-y; +if (sy>20) sy=20; +if (y>scr_y_size-20) ey=20-(y-(scr_y_size-20)); +if (ey<0) ey=0; + +if (mode==1){ // 2 pl mode pl1 + if (x>140) ex=20-(x-140); + if (ex<0) ex=0; + } + +if (mode==2){ // 2 pl mode pl2 + if (x<161) sx=161-x; + if (sx>20) sx=20; + } +offs=((num&15)*20)+(num/16*320*20)+sy*320; +offs2=(y+sy)*320+x+sx; +gofs=virbuff+offs2; +if (type==FLOOR) texture=floorspr+offs+sx; +if (type==WALLS) texture=wallspr+offs+sx; + +for (a=sy;a20) sx=20; +if (x>300) ex=20-(x-300); +if (ex<0) ex=0; +if (y<0) sy=-y; +if (sy>20) sy=20; +if (y>scr_y_size-20) ey=20-(y-(scr_y_size-20)); +if (ey<0) ey=0; + +if (mode==1){ // 2 pl mode pl1 + if (x>140) ex=20-(x-140); + if (ex<0) ex=0; + } + +if (mode==2){ // 2 pl mode pl2 + if (x<161) sx=161-x; + if (sx>20) sx=20; + } +offs=((num&15)*20)+(num/16*320*20)+sy*320; +offs2=(y+sy)*320+x+sx; + +for (a=sy;a20) sx=20; +if (x>300) ex=20-(x-300); +if (ex<0) ex=0; +if (y<0) sy=-y; +if (sy>20) sy=20; +if (y>scr_y_size-20) ey=20-(y-(scr_y_size-20)); +if (ey<0) ey=0; + +if (mode==1){ // 2 pl mode pl1 + if (x>140) ex=20-(x-(140)); + if (ex<0) ex=0; + } + +if (mode==2){ // 2 pl mode pl2 + if (x<161) sx=161-x; + if (sx>20) sx=20; + } + +offs1=(y+sy)*320+x; +offs2=(sy*320)+num*20; +s=shadowspr+offs2; +vb=virbuff+offs1; + +for (a=sy;a28) sx=28; +if (x>292) ex=28-(x-292); +if (ex<0) ex=0; +if (y<0) sy=-y; +if (sy>28) sy=28; +if (y>scr_y_size-28) ey=28-(y-(scr_y_size-28)); +if (ey<0) ey=0; + +if (mode==1){ // 2 pl mode pl1 + if (x>132) ex=28-(x-132); + if (ex<0) ex=0; + } + +if (mode==2){ // 2 pl mode pl2 + if (x<161) sx=161-x; + if (sx>28) sx=28; + } + +offs1=(y+sy)*320+x; +offs2=((sy+1+(num*29))*1160)+(angle*29)+1; + +for (a=sy,c=0,d=0;a=80 && colo<=80+15) virbuff[offs1+c+b]=(char)(col+(colo-80)); else virbuff[offs1+c+b]=(char)colo; +} + +} + +void draw_sprite(int x,int y,int xs,int ys,char *spr,int xsize,int offs,int mode){ +int a,b,offs1,offs2,sx=0,ex=xs,sy=0,ey=ys; +char *src,*dest; +char colo; + +if (x<0) sx=-x; +if (sx>xs) sx=xs; +if (x>320-xs) ex=xs-(x-(320-xs)); +if (ex<0) ex=0; +if (y<0) sy=-y; +if (sy>ys) sy=ys; +if (y>scr_y_size-ys) ey=ys-(y-(scr_y_size-ys)); +if (ey<0) ey=0; + +if (mode==1){ // 2 pl mode pl1 + if (x>160-xs) ex=xs-(x-(160-xs)); + if (ex<0) ex=0; + } + +if (mode==2){ // 2 pl mode pl2 + if (x<161) sx=161-x; + if (sx>xs) sx=xs; + } + +offs1=(y+sy)*320+x; +offs2=(sy*xsize)+offs; +src=spr+offs2+sx; +dest=virbuff+offs1+sx; + +for (a=sy;axs) sx=xs; +if (x>320-xs) ex=xs-(x-(320-xs)); +if (ex<0) ex=0; +if (y<0) sy=-y; +if (sy>ys) sy=ys; +if (y>scr_y_size-ys) ey=ys-(y-(scr_y_size-ys)); +if (ey<0) ey=0; + +if (mode==1){ // 2 pl mode pl1 + if (x>160-xs) ex=xs-(x-(160-xs)); + if (ex<0) ex=0; + } + +if (mode==2){ // 2 pl mode pl2 + if (x<161) sx=161-x; + if (sx>xs) sx=xs; + } + +offs1=(y+sy)*320+x; +offs2=(sy*xsize)+offs; +src=spr+offs2+sx; +dest=virbuff+offs1+sx; + +for (a=sy;aindex!=FOOTPRINT && type->index!=SMOKE2 && type->index!=BLOOD2 && type->index!=SMOKE3 && type->index!=STEAM) + draw_sprite(x-type->xs/2,y-type->ys/2,type->xs,type->ys,effectspr,320,type->offs+((type->xs+1)*num)+321,mode); + else + draw_trans_sprite(x-type->xs/2,y-type->ys/2,type->xs,type->ys,effectspr,320,type->offs+((type->xs+1)*num)+321,mode); +} +void draw_body_part(int x,int y,int num,int mode){ + draw_sprite(x,y,20,20,bodypartspr,320,(num*21),mode); +} + +void draw_light(Light_table *lt,int x,int y,int num,int add,int mode){ + +int xs=Light_sizes[num],ys=Light_sizes[num]; +int a,b,c,sum,offs1,offs2,sx=0,ex=xs,sy=0,ey=ys; + +x-=(xs/2); +y-=(ys/2); + +if (x<0) sx=-x; +if (sx>xs) sx=xs; +if (x>320-xs) ex=xs-(x-(320-xs)); +if (ex<0) ex=0; +if (y<0) sy=-y; +if (sy>ys) sy=ys; +if (y>scr_y_size-ys) ey=ys-(y-(scr_y_size-ys)); +if (ey<0) ey=0; + +if (mode==1){ // 2 pl mode pl1 + if (x>160-xs) ex=xs-(x-(160-xs)); + if (ex<0) ex=0; + } + +if (mode==2){ // 2 pl mode pl2 + if (x<161) sx=161-x; + if (sx>xs) sx=xs; + } + +offs1=(y+sy)*320+x; + +for (a=sy,offs2=a*xs,c=0;a15) sum=15; +virbuff[offs1+c+b]=lt->data[virbuff[offs1+c+b]][sum]; +} + +} + + +void draw_ball(int x,int y,int num){ + +int a,b,offs1,offs2; + +offs1=((num%16)*20)+(59*320)+((num/16)*(320*20)); +offs2=(y*320)+x; + +for (a=0;a<20;a++) +memcpy(virbuff+offs2+(a*320),picture+offs2+(a*320),20); + +for (a=0;a<20;a++,offs1+=300,offs2+=300) +for (b=0;b<20;b++,offs1++,offs2++) +if (warespr[offs1]!=0) virbuff[offs2]=warespr[offs1]; + +offs2=(y*320)+x; + +for (a=0;a<20;a++) +memcpy(screen+offs2+(a*320),virbuff+offs2+(a*320),20); +} + + +void draw_ware(int x,int y,int row,int colu){ + +int a,b,offs1,offs2; + +offs1=row*320*17+colu*17; +offs2=(y*320)+x; + +for (a=0;a<16;a++,offs1+=304,offs2+=304) +for (b=0;b<16;b++,offs1++,offs2++) +if (warespr[offs1]!=0) virbuff[offs2]=warespr[offs1]; + else virbuff[offs2]=picture[offs2]; +} + +void draw_black(){ +int level_size=level_x_size*level_y_size,a,b,ovx1,ovy1,ovy2,ovx2,offs; + +ovx1=player[0].scr_x%20; +ovy1=player[0].scr_y%20; + +if (GAME_MODE!=SPLIT_SCREEN){ + +offs=(player[0].scr_y/20)*level_x_size+(player[0].scr_x/20); +for (a=0;a0){ +dou=1; +if (level[offs].type==FLOOR) if (DARK_MODE) if (! player[0].see_level[offs]) dou=0; +if (dou) draw_shadow((b*20)-ovx1,(a*20)-ovy1,level[offs].shadow-1,0); +} + +} else{ + +ovx2=player[1].scr_x%20; +ovy2=player[1].scr_y%20; + +offs=(player[0].scr_y/20)*level_x_size+(player[0].scr_x/20); +for (a=0;a0){ +dou=1; +if (level[offs].type==FLOOR) if (DARK_MODE) if (! player[0].see_level[offs]) dou=0; +if (dou) draw_shadow((b*20)-ovx1,(a*20)-ovy1,level[offs].shadow-1,1); +} + +offs=(player[1].scr_y/20)*level_x_size+(player[1].scr_x/20); +for (a=0;a0){ +dou=1; +if (level[offs].type==FLOOR) if (DARK_MODE) if (! player[1].see_level[offs]) dou=0; +if (dou) draw_shadow((b*20)-ovx2+160,(a*20)-ovy2,level[offs].shadow-1,2); +} + +} + +} + +void draw_walls(){ + +int a,b,ovx1,ovy1,ovy2,ovx2,offs; +int level_size=level_x_size*level_y_size; + +ovx1=player[0].scr_x%20; +ovy1=player[0].scr_y%20; + +if (GAME_MODE!=SPLIT_SCREEN){ + +offs=(player[0].scr_y/20)*level_x_size+(player[0].scr_x/20); +for (a=0;asx- size && + xsy- size && + y0) + if (x>sx- size && + xsy- size && + yorder==pos) + { + if (GAME_MODE!=SPLIT_SCREEN){ + if (chk4draw(effect[a].x-(effect[a].type->xs/2),effect[a].y-(effect[a].type->ys/2),player[0].scr_x,player[0].scr_y,25,0)) + if (LIGHT_EFFECTS) + switch(effect[a].type->index){ + case EXPLO:draw_light(effect[a].lt,effect[a].x-player[0].scr_x,effect[a].y-player[0].scr_y,7,5-effect[a].count*0.8,0);break; + case METAL:draw_light(effect[a].lt,effect[a].x-player[0].scr_x,effect[a].y-player[0].scr_y,0,-effect[a].count,0);break; + case SMOKE:draw_light(effect[a].lt,effect[a].x-player[0].scr_x,effect[a].y-player[0].scr_y,1,-effect[a].count,0);break; + case TELEPORT:draw_light(effect[a].lt,effect[a].x-player[0].scr_x,effect[a].y-player[0].scr_y,4,0,0);break; + } + +if (LIGHT_EFFECTS && effect[a].type->index==EXPLO) { } else + draw_effect(effect[a].x-player[0].scr_x,effect[a].y-player[0].scr_y,effect[a].type,effect[a].count/effect[a].type->delay,0); + } + + if (GAME_MODE==SPLIT_SCREEN){ + if (chk4draw(effect[a].x-(effect[a].type->xs/2),effect[a].y-(effect[a].type->ys/2),player[0].scr_x,player[0].scr_y,25,1)) + { + if (LIGHT_EFFECTS) + switch(effect[a].type->index){ + case EXPLO:draw_light(effect[a].lt,effect[a].x-player[0].scr_x,effect[a].y-player[0].scr_y,7,5-effect[a].count*0.8,1);break; + case METAL:draw_light(effect[a].lt,effect[a].x-player[0].scr_x,effect[a].y-player[0].scr_y,0,-effect[a].count,1);break; + case SMOKE:draw_light(effect[a].lt,effect[a].x-player[0].scr_x,effect[a].y-player[0].scr_y,1,-effect[a].count,1);break; + case TELEPORT:draw_light(effect[a].lt,effect[a].x-player[0].scr_x,effect[a].y-player[0].scr_y,4,0,1);break; + } +if (LIGHT_EFFECTS && effect[a].type->index==EXPLO) { } else + draw_effect(effect[a].x-player[0].scr_x,effect[a].y-player[0].scr_y,effect[a].type,effect[a].count/effect[a].type->delay,1); + } + + if (chk4draw(effect[a].x-(effect[a].type->xs/2),effect[a].y-(effect[a].type->ys/2),player[1].scr_x,player[1].scr_y,25,1)) + { + if (LIGHT_EFFECTS) + switch(effect[a].type->index){ + case EXPLO:draw_light(effect[a].lt,effect[a].x-player[1].scr_x+160,effect[a].y-player[1].scr_y,7,5-effect[a].count*0.8,2);break; + case METAL:draw_light(effect[a].lt,effect[a].x-player[1].scr_x+160,effect[a].y-player[1].scr_y,0,-effect[a].count,2);break; + case SMOKE:draw_light(effect[a].lt,effect[a].x-player[1].scr_x+160,effect[a].y-player[1].scr_y,1,-effect[a].count,2);break; + case TELEPORT:draw_light(effect[a].lt,effect[a].x-player[1].scr_x+160,effect[a].y-player[1].scr_y,4,0,2);break; + } +if (LIGHT_EFFECTS && effect[a].type->index==EXPLO) { } else + draw_effect(effect[a].x-player[1].scr_x+160,effect[a].y-player[1].scr_y,effect[a].type,effect[a].count/effect[a].type->delay,2); + } + } + + } + +} + +void draw_spots(){ +int a; + +for (a=0;alight != NULL) + draw_light(bullet[a].type->light,bullet[a].x-player[0].scr_x,bullet[a].y-player[0].scr_y,bullet[a].type->lsize,bullet[a].type->llum+bullet[a].count*bullet[a].type->ladd,0); + if (bullet[a].type->sprite != NULL) + draw_sprite(bullet[a].x-(int)(bullet[a].type->xs>>1)-player[0].scr_x,bullet[a].y-(int)(bullet[a].type->ys>>1)-player[0].scr_y,bullet[a].type->xs,bullet[a].type->ys,bullet[a].type->sprite,bullet[a].type->xsize,bullet[a].type->offs,0); + } + + if (GAME_MODE==SPLIT_SCREEN){ + if (chk4draw(bullet[a].x,bullet[a].y,player[0].scr_x,player[0].scr_y,20,1)) + { + if (LIGHT_EFFECTS) + if (bullet[a].type->light != NULL) + draw_light(bullet[a].type->light,bullet[a].x-player[0].scr_x,bullet[a].y-player[0].scr_y,bullet[a].type->lsize,bullet[a].type->llum+bullet[a].count*bullet[a].type->ladd,1); + if (bullet[a].type->sprite != NULL) + draw_sprite(bullet[a].x-(int)(bullet[a].type->xs>>1)-player[0].scr_x,bullet[a].y-(int)(bullet[a].type->ys>>1)-player[0].scr_y,bullet[a].type->xs,bullet[a].type->ys,bullet[a].type->sprite,bullet[a].type->xsize,bullet[a].type->offs,1); + } + + if (chk4draw(bullet[a].x,bullet[a].y,player[1].scr_x,player[1].scr_y,20,1)) + { + if (LIGHT_EFFECTS) + if (bullet[a].type->light != NULL) + draw_light(bullet[a].type->light,bullet[a].x-player[1].scr_x+160,bullet[a].y-player[1].scr_y,bullet[a].type->lsize,bullet[a].type->llum+bullet[a].count*bullet[a].type->ladd,2); + if (bullet[a].type->sprite != NULL) + draw_sprite(bullet[a].x-(int)(bullet[a].type->xs>>1)-player[1].scr_x+160,bullet[a].y-(int)(bullet[a].type->ys>>1)-player[1].scr_y,bullet[a].type->xs,bullet[a].type->ys,bullet[a].type->sprite,bullet[a].type->xsize,bullet[a].type->offs,2); + } + + } + + } + +} + +void draw_body_parts(){ +int a; + +for (a=0;a0) writefonts(3,scr_y_size-23,text,7*16); + +if (GAME_MODE==SPLIT_SCREEN){ +writefonts(3+160,scr_y_size-15,weapon[player[1].curr_weapon].name,1); +x=player[1].bullets[weapon[player[1].curr_weapon].btype-1]/bullet_type[weapon[player[1].curr_weapon].btype].mul; +if (x<0) x=1; +itoa(x,text,10); +if (player[1].curr_weapon>0) writefonts(3+160,scr_y_size-23,text,7*16); +} + +} + +void draw_energies(){ +int a,offs=((scr_y_size-5)*320)+3; +float div=( (float) (player[0].max_energy+(player[0].shield*10)) /5)/15; + +for (a=0;a63) c=63; + + picture[offs]=(char)c; } + +} + +void rectangle(int x1,int y1,int x2,int y2,int col){ +int a,offs,offs1,offs2,offs3; + +offs1=y1*320+x1; +offs2=y1*320+x2; +offs3=y2*320+x1; + +memset(virbuff+offs1,col,(x2-x1)+1); +memset(virbuff+offs3,col,(x2-x1)+1); + +for(a=0,offs=offs1+320;a<(y2-y1)-1;a++,offs+=320) +virbuff[offs]=(char)col; + +for(a=0,offs=offs2+320;a<(y2-y1)-1;a++,offs+=320) +virbuff[offs]=(char)col; +} + +void draw_hits(){ + +if (GAME_MODE!=SPLIT_SCREEN) +if (player[0].HIT>0) +rectangle(0,0,319,scr_y_size-1,((4*16)-1)-player[0].HIT); + +if (GAME_MODE==SPLIT_SCREEN){ +if (player[0].HIT>0) +rectangle(0,0,159,scr_y_size-1,((4*16)-1)-player[0].HIT); +if (player[1].HIT>0) +rectangle(161,0,319,scr_y_size-1,((4*16)-1)-player[1].HIT); +} + +} + +void draw_targets(){ +int a,dist; +float x,y; +static int plot_count=0; +plot_count++; + +if (GAME_MODE!=SPLIT_SCREEN) +if (! player[1].DEAD) + if (weapon[player[0].curr_weapon].gun) + if (player[0].TARGET){ + x=player[0].x+14+10*sini[player[0].rangle2]; + y=player[0].y+14+10*cosi[player[0].rangle2]; + dist=bullet_type[weapon[player[0].curr_weapon].btype].time*bullet_type[weapon[player[0].curr_weapon].btype].speed; + for (a=0;a=0 && x-player[0].scr_x<320 && y-player[0].scr_y>=0 && y-player[0].scr_y=0 && x-player[0].scr_x<160 && y-player[0].scr_y>=0 && y-player[0].scr_y0 && x-player[1].scr_x<160 && y-player[1].scr_y>=0 && y-player[1].scr_y0) + writefonts(crate[a].text_x,crate[a].text_y,crate[a].text,32); +} + +void draw_kills(){ +char text[5],text2[20]; +int a; +if (GAME_MODE==SPLIT_SCREEN){ + itoa(player[0].player_kills,text,10); + writefonts(3,3,text,48); + itoa(player[1].player_kills,text,10); + writefonts(317-str_length(text),3,text,144); +} else + for (a=0;a +#include +#include +#include "../error/error.h" + +void load_efp(char *name,char *kuva,int offs){ + +char header[7]; +unsigned int p; +unsigned short w,h; + +short tavu,tavu2; +FILE *efp=fopen(name,"rb"); + +if (!efp) error("File %s is missing\n",name); + +fseek(efp,offs,SEEK_SET); + +fread(header,6,1,efp); +if (strncmp(header,"EF pic",6) ) error("File is not an EF pic!\n"); + +fseek(efp,6+offs,SEEK_SET); + +fread(&w,2,1,efp); +fread(&h,2,1,efp); + +for(p=0;p192) { + tavu2=(short)fgetc(efp); + memset(kuva+p,tavu2,tavu-192); + p+=tavu-192; + } else kuva[p++]=(char)tavu; + } +fclose(efp); + +} + + +void load_efp_pal(char *name,char *paletti){ +short c; +FILE *efp=fopen(name,"rb"); +fseek(efp,-768,SEEK_END); + for(c=0;c<768;c++) paletti[c]=(char)fgetc(efp); +fclose(efp); +} + diff --git a/BAK/EFP/EFP.CPP b/BAK/EFP/EFP.CPP new file mode 100644 index 0000000..8f9128e --- /dev/null +++ b/BAK/EFP/EFP.CPP @@ -0,0 +1,48 @@ +#include +#include +#include +#include "efp.h" +#include "../error/error.h" + +void load_efp(char *name,char *kuva,int offs){ + +char header[7]; +unsigned int p; +unsigned short w,h; + +short tavu,tavu2; +FILE *efp=fopen(name,"rb"); + +if (!efp) error("File %s is missing\n",name); + +fseek(efp,offs,SEEK_SET); + +fread(header,6,1,efp); +if (strncmp(header,"EF pic",6) ) error("File is not an EF pic!\n"); + +fseek(efp,6+offs,SEEK_SET); + +fread(&w,2,1,efp); +fread(&h,2,1,efp); + +for(p=0;p192) { + tavu2=(short)fgetc(efp); + memset(kuva+p,tavu2,tavu-192); + p+=tavu-192; + } else kuva[p++]=(char)tavu; + } +fclose(efp); + +} + + +void load_efp_pal(char *name,char *paletti){ +short c; +FILE *efp=fopen(name,"rb"); +fseek(efp,-768,SEEK_END); + for(c=0;c<768;c++) paletti[c]=(char)fgetc(efp); +fclose(efp); +} + diff --git a/BAK/EFP/EFP.H b/BAK/EFP/EFP.H new file mode 100644 index 0000000..42f724c --- /dev/null +++ b/BAK/EFP/EFP.H @@ -0,0 +1,11 @@ +#ifndef __EFP___H_ +#define __EFP___H_ + +extern "C" +{ + +void load_efp(char *name,char *kuva,int offs); +void load_efp_pal(char *name,char *paletti); + +} +#endif diff --git a/BAK/ERROR.OBJ b/BAK/ERROR.OBJ new file mode 100644 index 0000000..eaffe7e Binary files /dev/null and b/BAK/ERROR.OBJ differ diff --git a/BAK/ERROR/ERROR.BAK b/BAK/ERROR/ERROR.BAK new file mode 100644 index 0000000..240ad3c --- /dev/null +++ b/BAK/ERROR/ERROR.BAK @@ -0,0 +1,20 @@ +#include +#include +#include +#include +#include + +void error(char *fmt,...) +{ auto va_list ap; + extern KeyboardHandler *CURRENTHANDLER; + + vesa_set_mode(0x3); + if (CURRENTHANDLER!=NULL) CURRENTHANDLER->deinit(); + + va_start(ap,fmt); + vprintf(fmt,ap); + va_end(ap); + + exit(1); +} + diff --git a/BAK/ERROR/ERROR.CPP b/BAK/ERROR/ERROR.CPP new file mode 100644 index 0000000..240ad3c --- /dev/null +++ b/BAK/ERROR/ERROR.CPP @@ -0,0 +1,20 @@ +#include +#include +#include +#include +#include + +void error(char *fmt,...) +{ auto va_list ap; + extern KeyboardHandler *CURRENTHANDLER; + + vesa_set_mode(0x3); + if (CURRENTHANDLER!=NULL) CURRENTHANDLER->deinit(); + + va_start(ap,fmt); + vprintf(fmt,ap); + va_end(ap); + + exit(1); +} + diff --git a/BAK/ERROR/ERROR.H b/BAK/ERROR/ERROR.H new file mode 100644 index 0000000..992f304 --- /dev/null +++ b/BAK/ERROR/ERROR.H @@ -0,0 +1,4 @@ +#ifndef __ERROR_H_ +#define __ERROR_H_ +void error(char *fmt,...); +#endif diff --git a/BAK/ERROR/ERROR.OBJ b/BAK/ERROR/ERROR.OBJ new file mode 100644 index 0000000..19cc9dd Binary files /dev/null and b/BAK/ERROR/ERROR.OBJ differ diff --git a/BAK/FADE.CPP b/BAK/FADE.CPP new file mode 100644 index 0000000..5ea089d --- /dev/null +++ b/BAK/FADE.CPP @@ -0,0 +1,70 @@ +#include "globvar.h" +#include +#include +#include +#include + +#define max(a,b) a>b?a:b + +int sine[256]; + +void Draw_Phase(int phase,char *image,char *pal){ + int x,y,yfix,xfix,yg,l; + + l=(phase*30)>>8; + + for (y=0,yg=0;y>8); + if (yfix+yg<0||yfix+yg>=320*scr_y_size) memset(screen+yg,0,320); + else for (x=0;x<320;x++){ + xfix=x+((l*sine[(x+phase)&0xff])>>8); + if (xfix>0&&xfix<320) screen[yg+x]=image[yg+xfix+yfix]; + else screen[yg+x]=0; + + } + yg+=320; + } + setpal(pal,max(256-phase,0)); +} +#define FADE_SPEED 10 + +void fadein(char *image,char *pal){ + + int old_c=0,alku; + + setpal(pal,0); + alku=framecount; + while(alku+(256/FADE_SPEED)>framecount){ + + while (framecount==old_c); + old_c=framecount; + Draw_Phase(256-(framecount-alku)*FADE_SPEED,image,pal); + + } + setpal(pal,256); + memcpy(screen,image,320*scr_y_size); +} + +void fadeout(char *image,char *pal){ + + int alku,old_c; + + alku=framecount; + while(alku+(256/FADE_SPEED)>framecount){ + while (framecount==old_c); + old_c=framecount; + Draw_Phase((framecount-alku)*FADE_SPEED,image,pal); + } + setpal(pal,0); + memset(screen,0,320*scr_y_size); +} + +void CalCuLaTE_Sine_Table_AND_Be_Happy(){ + int a; + + for (a=0;a<256;a++) + sine[a]=255*(sin((float)a/256*pi*2)); +} + + + diff --git a/BAK/FADE.H b/BAK/FADE.H new file mode 100644 index 0000000..b4fff86 --- /dev/null +++ b/BAK/FADE.H @@ -0,0 +1,9 @@ +#ifndef __TK___FADE__ +#define __TK___FADE__ + +void Draw_Phase(int phase,char *image,char *pal); +void fadein(char *image,char *pal); +void fadeout(char *image,char *pal); +void CalCuLaTE_Sine_Table_AND_Be_Happy(); + +#endif diff --git a/BAK/FADE.OBJ b/BAK/FADE.OBJ new file mode 100644 index 0000000..70a00b0 Binary files /dev/null and b/BAK/FADE.OBJ differ diff --git a/BAK/FUNCS.H b/BAK/FUNCS.H new file mode 100644 index 0000000..6c10314 --- /dev/null +++ b/BAK/FUNCS.H @@ -0,0 +1,63 @@ +char *quitexts[]={ + "no: let's kill !", + "yes: i'm a loser" +}; + +int wanna_quit(){ +int a,cnt=0,selected=0,quit=0,oclock; +int done=0; + +int starty=100-((3*15)/2); + +load_efp("efps\\cool.efp",picture,0); + +draw_box1(65,starty-5-10,320-65,starty+5+(3*15),10); + +while(! done){ +memcpy(virbuff,picture,64000); + + FONT_NUM=0; + writefonts2(160-(str_length("quit to menu")/2),starty-10,"quit to menu",1); + +for (a=0;a<2;a++){ + if (a==selected) { + FONT_NUM=0; + writefonts2(160-(str_length(quitexts[a])/2),starty+15+(a*15),quitexts[a],1); + } else + { + FONT_NUM=2; + writefonts2(160-(str_length(quitexts[a])/2),starty+15+(a*15),quitexts[a],1); + } + +} + +memcpy(screen,virbuff,64000); + +while (! k.state[94] && ! k.state[99] && ! k.state[28]) { + + if (clock()!=oclock){ + oclock=clock(); + draw_ball(65,starty+15+(selected*15)-2,cnt); + draw_ball(320-85,starty+15+(selected*15)-2,cnt); + cnt++; + if (cnt>23) cnt=0; + } + + } + + MIDASplaySample(klikwav,MIDAS_CHANNEL_AUTO,0,22500,EFFECT_VOLUME,MIDAS_PAN_MIDDLE); + + if (k.state[94]) {selected--;if (selected<0) selected=1;k.state[94]=0;} + if (k.state[99]) {selected++;if (selected>1) selected=0;k.state[99]=0;} + if (k.state[28]) { + if (selected==0) quit=0; + if (selected==1) quit=1; + done=1; + } +} + +return(quit); + +} + + diff --git a/BAK/GAME.BAK b/BAK/GAME.BAK new file mode 100644 index 0000000..ad87a4b --- /dev/null +++ b/BAK/GAME.BAK @@ -0,0 +1,1490 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void game(); +#include "defines.h" +#include "error/error.h" +#include "efp/efp.h" +#include "globvar.h" + +/* ************************ NET STUFF **************************************/ + +#include "int/int.h" +#include "ipx/ipx.h" + +word SOCKET=0x869C; // DOOM Socket + +#define IPX_END 0 +#define IPX_SERVERSEARCH 1 +#define IPX_TEXTMESSAGE 2 +#define IPX_SERVERANSWER 3 + +int IPXMSGLEN[]={1, // END + 1, // SERVERSEARCH + 0, // TEXTMESSAGE + 17}; // SERVERANSWER + +int ipxofs[MAX_PLAYERS]={0,0,0,0 + ,0,0,0,0}; +char ipxstream[MAX_PLAYERS][MAXDATASIZE]; + +struct nodeaddr serveraddr; +char servername[10]; +struct packet far *send,far *rec[RECEIVERS]; +unsigned short sendl,sendseg,recl[RECEIVERS],recseg[RECEIVERS]; + + +/* ************************ NET STUFF **************************************/ + + +VBEINFO *vbeInfo; +VBESURFACE *vbe; + +#include "miscfunc.h" +#include "write.h" // tosi paskoja rutiineja !!! +#include "classes.h" +#include "rout.h" +#include "fade.h" + +#include "draw.h" +#include "funcs.h" +#include "shop.h" +#include "newfuncs.h" +#include "options.h" + +void menu_biisi() +{ +if (ph) MIDASstopModule(ph); +if (biisi!=NULL) MIDASfreeModule(biisi); +biisi=MIDASloadModule("music\\menu.s3m"); +ph=MIDASplayModule(biisi,TRUE); +MIDASsetMusicVolume(ph,MUSIC_VOLUME); +} + +void peli_biisi() +{ + static int biisi_count; + + if (ph) MIDASstopModule(ph); + + if (biisi!=NULL) MIDASfreeModule(biisi); + + biisi_count++; + biisi_count%=2; + + if (biisi_count==0) + biisi=MIDASloadModule("music\\back.s3m"); + if (biisi_count==1) + biisi=MIDASloadModule("music\\mielip2.s3m"); + + ph=MIDASplayModule(biisi,TRUE); + MIDASsetMusicVolume(ph,MUSIC_VOLUME); +} + +void MIDAS_CALL prevr(void){ +framecount++; +} + +void make_floors(){ +int a,lum; +char col; + +for (a=0;a<64000;a++){ +lum=(int)((float)(pal[floorspr[a]*3]*0.2)+(float)(pal[floorspr[a]*3+1]*0.5)+(float)(pal[floorspr[a]*3+2]*0.3))>>2; +col=(char)((208+15)-lum); +floorspr2[a]=col; +} + +} + +void load_tables(){ +FILE *tab; +tab=fopen("palette.tab","rb"); +fread(trans_table,sizeof(trans_table),1,tab); +fread(shadow_table,sizeof(shadow_table),1,tab); +fread(&normal_l,sizeof(normal_l),1,tab); +fread(&red_l,sizeof(red_l),1,tab); +fread(&yellow_l,sizeof(yellow_l),1,tab); +fread(&explo_l,sizeof(explo_l),1,tab); +fclose(tab); +} + +void allocipxmem() +{ int a; + + send=(struct packet far *)MK_FP(getlowmem(sizeof(struct packet)/16+1),0); + if (send==NULL) + { + cout <<"Can't alloc lowmem!\n"<< endl; + ipxavail=0; + return; + } + sendl=lsel; + sendseg=lseg; + + for (a=0;aVbeVersion>>8, + vbeInfo->VbeVersion&0xFF, + vbeInfo->OemStringPtr, + ((float)vbeInfo->TotalMemory*64000.0f)/1024.0f); + if (vbeInfo->VbeVersion>>8>=2) VESA2=1; + } + +if (initipx()) + { + char str[256]; + cout <<"IPX protocol detected!\n"; + getlocaladdress(); + printf("IPX address: %s\n",decode_localaddress(str,localadd)); + ipxavail=1; + allocipxmem(); + } else cout <<"IPX _NOT_ detected!\n"; + +if (MIDASstartup()){ +if (MIDASloadConfig("sound.cfg")){ + cout<<"Sound configuration loaded\n"; +if (MIDASinit()){ + cout<<"MIDAS initialized\n"; + if (MIDASsetTimerCallbacks(target_frames*1000,FALSE,&prevr,NULL,NULL)) cout<<"Timer synchronized\n"; + } + else error("Midas initialization failed\n"); + } else error("Sound configuration not found! run SETUP.exe\n"); + +if (! MIDASopenChannels(16)) error("Error opening sound channels\n"); +if (! MIDASallocAutoEffectChannels(4)) error("Error allocating effect channels\n"); + +magnumwav = MIDASloadWaveSample("wavs\\magnum.wav",FALSE); +pistolwav = MIDASloadWaveSample("wavs\\pistol.wav",FALSE); +shotgunwav= MIDASloadWaveSample("wavs\\rifle.wav",FALSE); +explowav = MIDASloadWaveSample("wavs\\explo.wav",FALSE); +deathwav = MIDASloadWaveSample("wavs\\death.wav",FALSE); +klikwav = MIDASloadWaveSample("wavs\\klik.wav",FALSE); +hitwav = MIDASloadWaveSample("wavs\\hit.wav",FALSE); +sinkowav = MIDASloadWaveSample("wavs\\sinko.wav",FALSE); +wooshwav = MIDASloadWaveSample("wavs\\woosh.wav",FALSE); +flamewav = MIDASloadWaveSample("wavs\\flame.wav",FALSE); + +cout<<"Sound effects loaded\n"; + +} else error("Error in MIDAS startup !!!\n"); + +set_keyb_rate(); +k.init(0); +cout << "Keyboard handler initialized\n" ; + +FONT_NUM=0;loadfonts("fnts\\bloody.fnt"); +FONT_NUM=1;loadfonts("fnts\\8x8b.fnt"); +FONT_NUM=2;loadfonts("fnts\\bloody2.fnt"); +FONT_NUM=3;loadfonts("fnts\\snumbers.fnt"); +cout << "Fonts loaded\n" ; +load_efp("efps\\floor1.efp",floorspr,0); +load_efp("efps\\walls1.efp",wallspr,0); +load_efp("efps\\enemy0.efp",enemyspr0,0); +load_efp("efps\\enemy1.efp",enemyspr1,0); +load_efp("efps\\enemy2.efp",enemyspr2,0); +load_efp("efps\\enemy3.efp",enemyspr3,0); +load_efp("efps\\enemy4.efp",enemyspr4,0); +load_efp("efps\\enemy5.efp",enemyspr5,0); +load_efp("efps\\enemy6.efp",enemyspr6,0); +load_efp("efps\\rambo2.efp",rambospr,0); +load_efp("efps\\bodyp.efp",bodypartspr,0); +load_efp("efps\\effects.efp",effectspr,0); +load_efp("efps\\ware.efp",warespr,0); +load_efp("efps\\target.efp",targetspr,0); +load_efp("efps\\c4.efp",c4spr,0); +load_efp("efps\\mine.efp",minespr,0); +load_efp("efps\\bomb.efp",grenadespr,0); +load_efp("efps\\shadows.efp",shadowspr,0); +load_efp("efps\\crates.efp",cratespr,0); +cout << "Bitmaps loaded\n"; + +pre_count(); +CalCuLaTE_Sine_Table_AND_Be_Happy(); // for fade +cout<<"Sine and Cosine tables ready\n"; + +for (a=0;a0) + for (b=0;bMAX_ENEMIES) ENEMIES=MAX_ENEMIES; + +} + +void null_effects(){ +int a; + +for (a=0;a0){ +body_part[a].move(); +body_part[a].speed-=0.2; +} + +} + +void roll_enemies(){ +int a; + +for (a=0;a0) {enemy[a].move(enemy[a].rangle*9,0);enemy[a].walk_cnt--;if (enemy[a].WALK==0) enemy[a].WALK=1;} else enemy[a].WALK=0; +} + +if (enemy[a].PUSH_POWER>0){ + if ((int)enemy[a].PUSH_POWER>0) + enemy[a].move(enemy[a].PUSH_ANGLE,(int)enemy[a].PUSH_POWER); + enemy[a].PUSH_POWER-=0.2; +} + +} + +} + +void push_players(){ + +int a; + +for (a=0;a0){ + if ((int)player[a].PUSH_POWER>0) + player[a].move(player[a].PUSH_ANGLE,(int)player[a].PUSH_POWER,a); + player[a].PUSH_POWER-=0.2; +} + +} + +void roll_effects(){ +int a; +for (a=0;ageneral_level_info.time_limit*TIME_ADD) col=3*16; + + writefonts(151,10,c_2_c(complete_time),col); + +} + +void frames_per_sec(){ + +char text[5]; + +itoa((int)F_PER_SEC,text,10); +writefonts(151,20,text,9*16); +itoa((1000-OVER_POWER*F_PER_SEC)/10,text,10); +writefonts(151,30,text,7*16); + +} + +void dec_hits(){ +int a; + +for (a=0;a0) player[a].HIT--; + +} + +void are_all_dead(){ + +int a; + +if (KILLING_MODE!=DEATHMATCH){ +all_dead=1; +for (a=0;aplayer[0].scr_x-160) +if (steam[a].xplayer[0].scr_y-yl1) +if (steam[a].yplayer[1].scr_x-160) +if (steam[a].xplayer[1].scr_y-yl1) +if (steam[a].y0) + if (oclock!=clock()) + { + oclock=clock(); + a-=10; + setpal(pal,a); + } +} + +void flushipx() +{ + int a; + for (a=0;adata,ipxstream[a],ipxofs[a]); + sendpacket(sendl,player[a].ipxnode,send,(word)ipxofs[a]); + // RESET + ipxofs[a]=0; + } +} + +void sendipxnow(struct nodeaddr *node, int type, ...) +{ int a=0; + +// TEMP VARIABLES + int b; + struct nodeaddr n; + char *str; +// TEMP VARIABLES END + + auto va_list ap; + va_start(ap,type); + + switch(type) + { + case IPX_SERVERSEARCH: + send->data[a++]=(char)type; + break; + case IPX_SERVERANSWER: + send->data[a++]=(char)type; + n=va_arg(ap,struct nodeaddr); + for (b=0;b<6;b++) + send->data[a++]=n.node[b]; + str=va_arg(ap,char *); + for (b=0;b<10;b++) + send->data[a++]=str[b]; + break; + default: error("IPX message %d not yet implemented\n",type); + } + send->data[a++]=IPX_END; + sendpacket(sendl,*node,send,(word)a); + + va_end( ap ); + +} + +void sendipx(int dest, int type, ...) +{ + va_list ap; + va_start(ap,type); + + switch(type) + { + case IPX_SERVERSEARCH: + error("sendipx: Use sendipxnow for serversearch\n"); + break; + case IPX_SERVERANSWER: + error("sendipx: Use sendipxnow for serveranswer\n"); + break; + default: error("sendipx: Not implemented yet!\n"); + /*ipxstream[dest][ipxofs[dest]++]=(char)type; + n=va_arg(ap,struct nodeaddr node); + for (a=0;a<6;a++) + ipxstream[dest][ipxofs[dest]++]=n.node[a]; + break;*/ + } + va_end(ap); +} + + +void setup_ipx() +{ + int a; + if (opensocket(0,SOCKET)) + error("Couldn't open socket (%Xh)\n",SOCKET); + + strcpy(servername,name1); + for (a=0;aecb.inuse==0) + { + data=-1; + ofs=0; + while(data!=IPX_END) + { + data=rec[a]->data[ofs++]; + switch (data) + { + case IPX_SERVERSEARCH: + sendipxnow(&rec[a]->ipx.src.node, + IPX_SERVERANSWER, + serveraddr, + servername); + break; + case IPX_TEXTMESSAGE: + while ((data=rec[a]->data[ofs++])!=0) + putch(data); + printf("\n"); + break; + case IPX_END: + break; + + default:error("IPX: receiver %d: unknown command %d\n",a,data); + }; + + } + listenforpacket(recseg[a]); + } + flushipx(); +} + +void do_client_shit() +{ +} + +void game(){ + +int c,a; +int frame_count; +int oclock; +int op[5],opcnt=0,opcnt2=0; +char match_level[50]; +char filename[50]; +char text[10]; + +if (GAME_MODE==SPLIT_SCREEN && KILLING_MODE!=DEATHMATCH) episode=DEATH_MATCH_EPISODE-1; + +if (GAME_MODE==ONE_PLAYER) PLAYERS=1; +if (GAME_MODE==SPLIT_SCREEN){ PLAYERS=2; + ACTIVE_PLAYERS=2; + } + else ACTIVE_PLAYERS=1; + +strcpy(match_level,"levs\\"); +if (DEATH_MATCH_EPISODE>0){ + strcat(match_level,dirlist[DEATH_MATCH_EPISODE-1].name); + strcat(match_level,"\\"); +} +strcat(match_level,DEATH_MATCH_LEVEL); + +fadeout(virbuff,pal); + +alusta_players1(); + +LEVELS=files_in_episode[episode+1]; + +LEVEL=START_LEVEL; +if (LEVEL>LEVELS-1) LEVEL=LEVELS-1; + +quit=0; + +all_dead=0; + +BACK_TO_MENU=0; + +while (! quit && ! BACK_TO_MENU){ //// + +strcpy(filename,"levs\\"); +strcat(filename,dirlist[episode].name); +strcat(filename,"\\level"); +itoa(LEVEL+1,text,10); +strcat(filename,text); +strcat(filename,".lev"); + +if (KILLING_MODE!=DEATHMATCH) leveldata.load(filename); + else (leveldata.load(match_level)); + +if (KILLING_MODE!=DEATHMATCH) level_info(); + +if (! BACK_TO_MENU){ + +if (DARK_MODE) { +for (a=0;a0){ + for (a=0;alfb; + } + +peli_biisi(); + +load_efp_pal("efps\\walls1.efp",pal); + +alusta_players2(); + +DEAD_ENEMIES=0; + +if (ENEMIES_ON_GAME==0 && KILLING_MODE==DEATHMATCH) ENEMIES=0; else { + alusta_enemies(); + place_enemies(); +} + +null_body_parts(); +null_effects(); +null_bullets(); +null_crates(); + +if (KILLING_MODE==COOPERATIVE) place_normal_game_crates(); + else place_death_match_crates(); + +FONT_NUM=1; +frame_count=0; +oclock=clock(); +st=clock(); + +first=1; + +OVER_POWER=0; + +Spot_count=0; +Steam_count=0; + +next_level=0; + +if (KILLING_MODE==DEATHMATCH) + for (a=0;a2){ + F_PER_SEC=((float)frame_count/(c-oclock))*CLOCKS_PER_SEC; + oclock=c; + + frame_count=0; + } + +opcnt++; // OVER_POWER count +delay(1); +if (framecount){ + + op[opcnt2]=opcnt; + opcnt2++; + if (opcnt2>5) opcnt2=0; + + opcnt=0; + framecount=0; // incremented by MIDAS timer + + game_shit(); // do the game !!!! + + Steam_count++; + Steam_count%=360; + + Spot_count+=2; + Spot_count%=360; + + if (opcnt2==0) + OVER_POWER=(op[0]+op[1]+op[2]+op[3]+op[4])/5; + + frame_count++; +} + +if (GAME_MODE==NETWORK&&NETWORK_MODE==CLIENT) + do_client_shit(); +if (GAME_MODE==NETWORK&&NETWORK_MODE==SERVER) + do_server_shit(); + +} + +if (DARK_MODE) +for (a=0;a23) cnt=0; + } + }; + MIDASplaySample(klikwav,MIDAS_CHANNEL_AUTO,0,22500,EFFECT_VOLUME,MIDAS_PAN_MIDDLE); + if (k.state[94]) {selected--;if (selected<0) selected=Menu_texts-1;k.state[94]=0;} + if (k.state[99]) {selected++;if (selected>Menu_texts-1) selected=0;k.state[99]=0;} + if (k.state[28]) + { + if (selected==0) {GAME_MODE=ONE_PLAYER;KILLING_MODE=COOPERATIVE;set_keys();episode=choose_episode();game();menu_scr();} + if (selected==1) {multiplayer_options();menu_scr();} + if (selected==2) {options();menu_scr();} + if (selected==3) quit=1; + } + } + fadeout(virbuff,pal); +} + +void credits() +{ + cout<<"\n"; + cout<<" Thanks for playing --The Ultimate TK-- (Tapan Kaikki) ! \n"; + cout<<"\n"; + cout<<" Credits: \n"; + cout<<"\n"; + cout<<" Coding: Allu and Unski \n"; + cout<<" Graphics: Allu \n"; + cout<<" Music: Allu and Unski \n"; + cout<<" Sound effects: Not from DOOM \n"; + cout<<" Thanks to MIDAS the best Sound System !!! \n"; + cout<<" The game name idea by Janne Laitinen (PM rules !) \n"; + cout<<" New episode and some ideas by Blanket \n"; + cout<<" Also thanks to Jaakko Pimperi for new blocks \n"; + cout<<" EF would also like to thank Niko Kotilainen, etc.\n"; + cout<<"\n"; + cout<<" Contact the Error Free Productions by e-mail: \n"; + cout<<"\n"; + cout<<" ef@tuusniemi.fi \n"; + cout<<" allu@tuusniemi.fi \n"; + cout<<" unski@tuusniemi.fi \n"; + cout<<"\n"; + cout<<" And visit the Error Free Productions homepage: \n"; + cout<<"\n"; + cout<<" http://www.tuusniemi.fi/~ef \n"; +} + +void logo() +{ + int a=0,oclock; + + load_efp("efps\\eflogo.efp",picture,0); + load_efp_pal("efps\\eflogo.efp",pal); + setpal(pal,0); + memcpy(screen,picture,64000); + + oclock=clock(); + + while (a<255) + if (oclock!=clock()) + { + oclock=clock(); + a+=10; + setpal(pal,a); + } + + while (! k.kbhit() && abs(oclock-clock())<500) ; + + while (a>0) + if (oclock!=clock()) + { + oclock=clock(); + a-=10; + setpal(pal,a); + } +} + +main(int argc, char *argv[]) +{ + int a=0,b; + int pause=0; + + for (a=1;a=30 && b<=500) target_frames=b; + break; + + case 'L': + b=atoi(argv[++a]); + if (b>0) START_LEVEL=b-1; + break; + + case 'P': + pause=1; + break; + + case 'M': + SHOW_ENEMIES=1; + break; + + case 'V': + FORCE_0x13=1; + break; + + case 'H': + case '?': + cout << endl; + cout <<"Ultimate Tapan Kaikki "<< Version << endl; + cout <<"Compiled at " << __DATE__ << ' ' << __TIME__ << endl; + cout <<"parameters:"<< endl; + cout <<"-?,-h this help" << endl; + cout <<"-v force mcga mode"<< endl; + cout <<"-p pause at startup"<< endl; + cout <<"-m show enemies on map"<< endl; + cout <<"-l ## start at level ##"<< endl; + cout <<"-f ## set gamespeed to ## fps (def. 40)"<< endl; + cout << endl; + exit(1); + break; + } + + } + + randomize(); + do_all(); + k.clear_stack(); + + if (pause) k.getch(); + + vesa_set_mode(0x13); + +// logo(); + menu(); + + if (ph) MIDASstopModule(ph); + + vesa_set_mode(0x3); + free_all(); + credits(); +} + diff --git a/BAK/GAME.BAT b/BAK/GAME.BAT new file mode 100644 index 0000000..f0ecdd4 --- /dev/null +++ b/BAK/GAME.BAT @@ -0,0 +1,4 @@ +@echo off +cd .. +game -v %1 %2 %3 %4 %5 %6 %7 +cd src diff --git a/BAK/GAME.CPP b/BAK/GAME.CPP new file mode 100644 index 0000000..0c88fca --- /dev/null +++ b/BAK/GAME.CPP @@ -0,0 +1,1492 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void game(); +#include "defines.h" +#include "error/error.h" +#include "efp/efp.h" +#include "globvar.h" + +/* ************************ NET STUFF **************************************/ + +#include "int/int.h" +#include "ipx/ipx.h" + +word SOCKET=0x869C; // DOOM Socket + +#define IPX_END 0 +#define IPX_SERVERSEARCH 1 +#define IPX_TEXTMESSAGE 2 +#define IPX_SERVERANSWER 3 + +int IPXMSGLEN[]={1, // END + 1, // SERVERSEARCH + 0, // TEXTMESSAGE + 17}; // SERVERANSWER + +int ipxofs[MAX_PLAYERS]={0,0,0,0 + ,0,0,0,0}; +char ipxstream[MAX_PLAYERS][MAXDATASIZE]; + +struct nodeaddr serveraddr; +char servername[10]; +struct packet far *send,far *rec[RECEIVERS]; +unsigned short sendl,sendseg,recl[RECEIVERS],recseg[RECEIVERS]; + + +/* ************************ NET STUFF **************************************/ + + +VBEINFO *vbeInfo; +VBESURFACE *vbe; + +#include "miscfunc.h" +#include "write.h" // tosi paskoja rutiineja !!! +#include "classes.h" +#include "rout.h" +#include "fade.h" + +#include "draw.h" +#include "funcs.h" +#include "shop.h" +#include "newfuncs.h" +#include "options.h" + +void menu_biisi() +{ +if (ph) MIDASstopModule(ph); +if (biisi!=NULL) MIDASfreeModule(biisi); +biisi=MIDASloadModule("music\\menu.s3m"); +ph=MIDASplayModule(biisi,TRUE); +MIDASsetMusicVolume(ph,MUSIC_VOLUME); +} + +void peli_biisi() +{ + static int biisi_count; + + if (ph) MIDASstopModule(ph); + + if (biisi!=NULL) MIDASfreeModule(biisi); + + biisi_count++; + biisi_count%=3; + + if (biisi_count==0) + biisi=MIDASloadModule("music\\unic_1x.s3m"); + if (biisi_count==1) + biisi=MIDASloadModule("music\\unic_2x.s3m"); + if (biisi_count==2) + biisi=MIDASloadModule("music\\unic_3x.s3m"); + + ph=MIDASplayModule(biisi,TRUE); + MIDASsetMusicVolume(ph,MUSIC_VOLUME); +} + +void MIDAS_CALL prevr(void){ +framecount++; +} + +void make_floors(){ +int a,lum; +char col; + +for (a=0;a<64000;a++){ +lum=(int)((float)(pal[floorspr[a]*3]*0.2)+(float)(pal[floorspr[a]*3+1]*0.5)+(float)(pal[floorspr[a]*3+2]*0.3))>>2; +col=(char)((208+15)-lum); +floorspr2[a]=col; +} + +} + +void load_tables(){ +FILE *tab; +tab=fopen("palette.tab","rb"); +fread(trans_table,sizeof(trans_table),1,tab); +fread(shadow_table,sizeof(shadow_table),1,tab); +fread(&normal_l,sizeof(normal_l),1,tab); +fread(&red_l,sizeof(red_l),1,tab); +fread(&yellow_l,sizeof(yellow_l),1,tab); +fread(&explo_l,sizeof(explo_l),1,tab); +fclose(tab); +} + +void allocipxmem() +{ int a; + + send=(struct packet far *)MK_FP(getlowmem(sizeof(struct packet)/16+1),0); + if (send==NULL) + { + cout <<"Can't alloc lowmem!\n"<< endl; + ipxavail=0; + return; + } + sendl=lsel; + sendseg=lseg; + + for (a=0;aVbeVersion>>8, + vbeInfo->VbeVersion&0xFF, + vbeInfo->OemStringPtr, + ((float)vbeInfo->TotalMemory*64000.0f)/1024.0f); + if (vbeInfo->VbeVersion>>8>=2) VESA2=1; + } + +if (initipx()) + { + char str[256]; + cout <<"IPX protocol detected!\n"; + getlocaladdress(); + printf("IPX address: %s\n",decode_localaddress(str,localadd)); + ipxavail=1; + allocipxmem(); + } else cout <<"IPX _NOT_ detected!\n"; + +if (MIDASstartup()){ +if (MIDASloadConfig("sound.cfg")){ + cout<<"Sound configuration loaded\n"; +if (MIDASinit()){ + cout<<"MIDAS initialized\n"; + if (MIDASsetTimerCallbacks(target_frames*1000,FALSE,&prevr,NULL,NULL)) cout<<"Timer synchronized\n"; + } + else error("Midas initialization failed\n"); + } else error("Sound configuration not found! run SETUP.exe\n"); + +if (! MIDASopenChannels(16)) error("Error opening sound channels\n"); +if (! MIDASallocAutoEffectChannels(4)) error("Error allocating effect channels\n"); + +magnumwav = MIDASloadWaveSample("wavs\\magnum.wav",FALSE); +pistolwav = MIDASloadWaveSample("wavs\\pistol.wav",FALSE); +shotgunwav= MIDASloadWaveSample("wavs\\rifle.wav",FALSE); +explowav = MIDASloadWaveSample("wavs\\explo.wav",FALSE); +deathwav = MIDASloadWaveSample("wavs\\death.wav",FALSE); +klikwav = MIDASloadWaveSample("wavs\\klik.wav",FALSE); +hitwav = MIDASloadWaveSample("wavs\\hit.wav",FALSE); +sinkowav = MIDASloadWaveSample("wavs\\sinko.wav",FALSE); +wooshwav = MIDASloadWaveSample("wavs\\woosh.wav",FALSE); +flamewav = MIDASloadWaveSample("wavs\\flame.wav",FALSE); + +cout<<"Sound effects loaded\n"; + +} else error("Error in MIDAS startup !!!\n"); + +set_keyb_rate(); +k.init(0); +cout << "Keyboard handler initialized\n" ; + +FONT_NUM=0;loadfonts("fnts\\bloody.fnt"); +FONT_NUM=1;loadfonts("fnts\\8x8b.fnt"); +FONT_NUM=2;loadfonts("fnts\\bloody2.fnt"); +FONT_NUM=3;loadfonts("fnts\\snumbers.fnt"); +cout << "Fonts loaded\n" ; +load_efp("efps\\floor1.efp",floorspr,0); +load_efp("efps\\walls1.efp",wallspr,0); +load_efp("efps\\enemy0.efp",enemyspr0,0); +load_efp("efps\\enemy1.efp",enemyspr1,0); +load_efp("efps\\enemy2.efp",enemyspr2,0); +load_efp("efps\\enemy3.efp",enemyspr3,0); +load_efp("efps\\enemy4.efp",enemyspr4,0); +load_efp("efps\\enemy5.efp",enemyspr5,0); +load_efp("efps\\enemy6.efp",enemyspr6,0); +load_efp("efps\\rambo2.efp",rambospr,0); +load_efp("efps\\bodyp.efp",bodypartspr,0); +load_efp("efps\\effects.efp",effectspr,0); +load_efp("efps\\ware.efp",warespr,0); +load_efp("efps\\target.efp",targetspr,0); +load_efp("efps\\c4.efp",c4spr,0); +load_efp("efps\\mine.efp",minespr,0); +load_efp("efps\\bomb.efp",grenadespr,0); +load_efp("efps\\shadows.efp",shadowspr,0); +load_efp("efps\\crates.efp",cratespr,0); +cout << "Bitmaps loaded\n"; + +pre_count(); +CalCuLaTE_Sine_Table_AND_Be_Happy(); // for fade +cout<<"Sine and Cosine tables ready\n"; + +for (a=0;a0) + for (b=0;bMAX_ENEMIES) ENEMIES=MAX_ENEMIES; + +} + +void null_effects(){ +int a; + +for (a=0;a0){ +body_part[a].move(); +body_part[a].speed-=0.2; +} + +} + +void roll_enemies(){ +int a; + +for (a=0;a0) {enemy[a].move(enemy[a].rangle*9,0);enemy[a].walk_cnt--;if (enemy[a].WALK==0) enemy[a].WALK=1;} else enemy[a].WALK=0; +} + +if (enemy[a].PUSH_POWER>0){ + if ((int)enemy[a].PUSH_POWER>0) + enemy[a].move(enemy[a].PUSH_ANGLE,(int)enemy[a].PUSH_POWER); + enemy[a].PUSH_POWER-=0.2; +} + +} + +} + +void push_players(){ + +int a; + +for (a=0;a0){ + if ((int)player[a].PUSH_POWER>0) + player[a].move(player[a].PUSH_ANGLE,(int)player[a].PUSH_POWER,a); + player[a].PUSH_POWER-=0.2; +} + +} + +void roll_effects(){ +int a; +for (a=0;ageneral_level_info.time_limit*TIME_ADD) col=3*16; + + writefonts(151,10,c_2_c(complete_time),col); + +} + +void frames_per_sec(){ + +char text[5]; + +itoa((int)F_PER_SEC,text,10); +writefonts(151,20,text,9*16); +itoa((1000-OVER_POWER*F_PER_SEC)/10,text,10); +writefonts(151,30,text,7*16); + +} + +void dec_hits(){ +int a; + +for (a=0;a0) player[a].HIT--; + +} + +void are_all_dead(){ + +int a; + +if (KILLING_MODE!=DEATHMATCH){ +all_dead=1; +for (a=0;aplayer[0].scr_x-160) +if (steam[a].xplayer[0].scr_y-yl1) +if (steam[a].yplayer[1].scr_x-160) +if (steam[a].xplayer[1].scr_y-yl1) +if (steam[a].y0) + if (oclock!=clock()) + { + oclock=clock(); + a-=10; + setpal(pal,a); + } +} + +void flushipx() +{ + int a; + for (a=0;adata,ipxstream[a],ipxofs[a]); + sendpacket(sendl,player[a].ipxnode,send,(word)ipxofs[a]); + // RESET + ipxofs[a]=0; + } +} + +void sendipxnow(struct nodeaddr *node, int type, ...) +{ int a=0; + +// TEMP VARIABLES + int b; + struct nodeaddr n; + char *str; +// TEMP VARIABLES END + + auto va_list ap; + va_start(ap,type); + + switch(type) + { + case IPX_SERVERSEARCH: + send->data[a++]=(char)type; + break; + case IPX_SERVERANSWER: + send->data[a++]=(char)type; + n=va_arg(ap,struct nodeaddr); + for (b=0;b<6;b++) + send->data[a++]=n.node[b]; + str=va_arg(ap,char *); + for (b=0;b<10;b++) + send->data[a++]=str[b]; + break; + default: error("IPX message %d not yet implemented\n",type); + } + send->data[a++]=IPX_END; + sendpacket(sendl,*node,send,(word)a); + + va_end( ap ); + +} + +void sendipx(int dest, int type, ...) +{ + va_list ap; + va_start(ap,type); + + switch(type) + { + case IPX_SERVERSEARCH: + error("sendipx: Use sendipxnow for serversearch\n"); + break; + case IPX_SERVERANSWER: + error("sendipx: Use sendipxnow for serveranswer\n"); + break; + default: error("sendipx: Not implemented yet!\n"); + /*ipxstream[dest][ipxofs[dest]++]=(char)type; + n=va_arg(ap,struct nodeaddr node); + for (a=0;a<6;a++) + ipxstream[dest][ipxofs[dest]++]=n.node[a]; + break;*/ + } + va_end(ap); +} + + +void setup_ipx() +{ + int a; + if (opensocket(0,SOCKET)) + error("Couldn't open socket (%Xh)\n",SOCKET); + + strcpy(servername,name1); + for (a=0;aecb.inuse==0) + { + data=-1; + ofs=0; + while(data!=IPX_END) + { + data=rec[a]->data[ofs++]; + switch (data) + { + case IPX_SERVERSEARCH: + sendipxnow(&rec[a]->ipx.src.node, + IPX_SERVERANSWER, + serveraddr, + servername); + break; + case IPX_TEXTMESSAGE: + while ((data=rec[a]->data[ofs++])!=0) + putch(data); + printf("\n"); + break; + case IPX_END: + break; + + default:error("IPX: receiver %d: unknown command %d\n",a,data); + }; + + } + listenforpacket(recseg[a]); + } + flushipx(); +} + +void do_client_shit() +{ +} + +void game(){ + +int c,a; +int frame_count; +int oclock; +int op[5],opcnt=0,opcnt2=0; +char match_level[50]; +char filename[50]; +char text[10]; + +if (GAME_MODE==SPLIT_SCREEN && KILLING_MODE!=DEATHMATCH) episode=DEATH_MATCH_EPISODE-1; + +if (GAME_MODE==ONE_PLAYER) PLAYERS=1; +if (GAME_MODE==SPLIT_SCREEN){ PLAYERS=2; + ACTIVE_PLAYERS=2; + } + else ACTIVE_PLAYERS=1; + +strcpy(match_level,"levs\\"); +if (DEATH_MATCH_EPISODE>0){ + strcat(match_level,dirlist[DEATH_MATCH_EPISODE-1].name); + strcat(match_level,"\\"); +} +strcat(match_level,DEATH_MATCH_LEVEL); + +fadeout(virbuff,pal); + +alusta_players1(); + +LEVELS=files_in_episode[episode+1]; + +LEVEL=START_LEVEL; +if (LEVEL>LEVELS-1) LEVEL=LEVELS-1; + +quit=0; + +all_dead=0; + +BACK_TO_MENU=0; + +while (! quit && ! BACK_TO_MENU){ //// + +strcpy(filename,"levs\\"); +strcat(filename,dirlist[episode].name); +strcat(filename,"\\level"); +itoa(LEVEL+1,text,10); +strcat(filename,text); +strcat(filename,".lev"); + +if (KILLING_MODE!=DEATHMATCH) leveldata.load(filename); + else (leveldata.load(match_level)); + +if (KILLING_MODE!=DEATHMATCH) level_info(); + +if (! BACK_TO_MENU){ + +if (DARK_MODE) { +for (a=0;a0){ + for (a=0;alfb; + } + +peli_biisi(); + +load_efp_pal("efps\\walls1.efp",pal); + +alusta_players2(); + +DEAD_ENEMIES=0; + +if (ENEMIES_ON_GAME==0 && KILLING_MODE==DEATHMATCH) ENEMIES=0; else { + alusta_enemies(); + place_enemies(); +} + +null_body_parts(); +null_effects(); +null_bullets(); +null_crates(); + +if (KILLING_MODE==COOPERATIVE) place_normal_game_crates(); + else place_death_match_crates(); + +FONT_NUM=1; +frame_count=0; +oclock=clock(); +st=clock(); + +first=1; + +OVER_POWER=0; + +Spot_count=0; +Steam_count=0; + +next_level=0; + +if (KILLING_MODE==DEATHMATCH) + for (a=0;a2){ + F_PER_SEC=((float)frame_count/(c-oclock))*CLOCKS_PER_SEC; + oclock=c; + + frame_count=0; + } + +opcnt++; // OVER_POWER count +delay(1); +if (framecount){ + + op[opcnt2]=opcnt; + opcnt2++; + if (opcnt2>5) opcnt2=0; + + opcnt=0; + framecount=0; // incremented by MIDAS timer + + game_shit(); // do the game !!!! + + Steam_count++; + Steam_count%=360; + + Spot_count+=2; + Spot_count%=360; + + if (opcnt2==0) + OVER_POWER=(op[0]+op[1]+op[2]+op[3]+op[4])/5; + + frame_count++; +} + +if (GAME_MODE==NETWORK&&NETWORK_MODE==CLIENT) + do_client_shit(); +if (GAME_MODE==NETWORK&&NETWORK_MODE==SERVER) + do_server_shit(); + +} + +if (DARK_MODE) +for (a=0;a23) cnt=0; + } + }; + MIDASplaySample(klikwav,MIDAS_CHANNEL_AUTO,0,22500,EFFECT_VOLUME,MIDAS_PAN_MIDDLE); + if (k.state[94]) {selected--;if (selected<0) selected=Menu_texts-1;k.state[94]=0;} + if (k.state[99]) {selected++;if (selected>Menu_texts-1) selected=0;k.state[99]=0;} + if (k.state[28]) + { + if (selected==0) {GAME_MODE=ONE_PLAYER;KILLING_MODE=COOPERATIVE;set_keys();episode=choose_episode();game();menu_scr();} + if (selected==1) {multiplayer_options();menu_scr();} + if (selected==2) {options();menu_scr();} + if (selected==3) quit=1; + } + } + fadeout(virbuff,pal); +} + +void credits() +{ + cout<<"\n"; + cout<<" Thanks for playing --The Ultimate TK-- (Tapan Kaikki) ! \n"; + cout<<"\n"; + cout<<" Credits: \n"; + cout<<"\n"; + cout<<" Coding: Allu and Unski \n"; + cout<<" Graphics: Allu \n"; + cout<<" Music: Allu and Unski \n"; + cout<<" Sound effects: Not from DOOM \n"; + cout<<" Thanks to MIDAS the best Sound System !!! \n"; + cout<<" The game name idea by Janne Laitinen (PM rules !) \n"; + cout<<" New episode and some ideas by Blanket \n"; + cout<<" Also thanks to Jaakko Pimperi for new blocks \n"; + cout<<" EF would also like to thank Niko Kotilainen, etc.\n"; + cout<<"\n"; + cout<<" Contact the Error Free Productions by e-mail: \n"; + cout<<"\n"; + cout<<" ef@tuusniemi.fi \n"; + cout<<" allu@tuusniemi.fi \n"; + cout<<" unski@tuusniemi.fi \n"; + cout<<"\n"; + cout<<" And visit the Error Free Productions homepage: \n"; + cout<<"\n"; + cout<<" http://www.tuusniemi.fi/~ef \n"; +} + +void logo() +{ + int a=0,oclock; + + load_efp("efps\\eflogo.efp",picture,0); + load_efp_pal("efps\\eflogo.efp",pal); + setpal(pal,0); + memcpy(screen,picture,64000); + + oclock=clock(); + + while (a<255) + if (oclock!=clock()) + { + oclock=clock(); + a+=10; + setpal(pal,a); + } + + while (! k.kbhit() && abs(oclock-clock())<500) ; + + while (a>0) + if (oclock!=clock()) + { + oclock=clock(); + a-=10; + setpal(pal,a); + } +} + +main(int argc, char *argv[]) +{ + int a=0,b; + int pause=0; + + for (a=1;a=30 && b<=500) target_frames=b; + break; + + case 'L': + b=atoi(argv[++a]); + if (b>0) START_LEVEL=b-1; + break; + + case 'P': + pause=1; + break; + + case 'M': + SHOW_ENEMIES=1; + break; + + case 'V': + FORCE_0x13=1; + break; + + case 'H': + case '?': + cout << endl; + cout <<"Ultimate Tapan Kaikki "<< Version << endl; + cout <<"Compiled at " << __DATE__ << ' ' << __TIME__ << endl; + cout <<"parameters:"<< endl; + cout <<"-?,-h this help" << endl; + cout <<"-v force mcga mode"<< endl; + cout <<"-p pause at startup"<< endl; + cout <<"-m show enemies on map"<< endl; + cout <<"-l ## start at level ##"<< endl; + cout <<"-f ## set gamespeed to ## fps (def. 40)"<< endl; + cout << endl; + exit(1); + break; + } + + } + + randomize(); + do_all(); + k.clear_stack(); + + if (pause) k.getch(); + + vesa_set_mode(0x13); + +// logo(); + menu(); + + if (ph) MIDASstopModule(ph); + + vesa_set_mode(0x3); + free_all(); + credits(); +} + diff --git a/BAK/GAME.ERR b/BAK/GAME.ERR new file mode 100644 index 0000000..67c335b --- /dev/null +++ b/BAK/GAME.ERR @@ -0,0 +1,3 @@ +GAME.CPP(1049): Warning! W014: (col 1) no reference to symbol 'dest' +GAME.CPP(1049): Note! N392: (col 1) 'int dest' in 'void sendipx( int, int, ... )' defined in: GAME.CPP(1028) (col 18) +GAME.CPP(1085): Warning! W005: (col 45) pointer or reference truncated diff --git a/BAK/GAME.OBJ b/BAK/GAME.OBJ new file mode 100644 index 0000000..d16ca4f Binary files /dev/null and b/BAK/GAME.OBJ differ diff --git a/BAK/GLOBVAR.CPP b/BAK/GLOBVAR.CPP new file mode 100644 index 0000000..f855bd3 --- /dev/null +++ b/BAK/GLOBVAR.CPP @@ -0,0 +1,421 @@ +#include "defines.h" +#include "types.h" +#include "classes.h" +#include +#include + +int BACK_TO_MENU=0; + +int VESA2=0,FORCE_0x13=0; +int scr_y_size=200; + +int ipxavail=0; +int GAME_MODE=0,NETWORK_MODE=CLIENT; +int KILLING_MODE=0; +int SHOW_ENEMIES=0; +int target_cost=500; // t„ht„imen hinta +volatile unsigned framecount=0; +int effect_age_count; + +int dust_blocks[DUST_BLOCKS]={0, + 16*4, + 16*5, + 16*5+2, + 16*6+1, + 16*6+1, + 16*6+2, + 16*7+1, + 16*7+2, + 16*7+3}; + +int Light_sizes[LIGHTS]={ + 15,20,25,30,35,40,45,50,55,60 + }; + +int DARK_MODE=1; +int LIGHT_EFFECTS=1; +int SHADOWS=1; +int SMOKE_EFFECTS=1; + +int sell_price[DIFF_WEAPONS+2]; // myyntihinnat muuttuvia + +struct BLOCK *level; + +char *see_level; + +char cratespr[320*14], + shadowspr[320*20], + c4spr[8*8], + grenadespr[7*7], + targetspr[7*7], + floorspr[64000], + wallspr[64000], + floorspr2[64000], + rambospr[1160*667], + bodypartspr[320*20], + effectspr[320*82], + pal[256*3], + picture[64000], + warespr[64000], + enemyspr0[1160*232], + enemyspr1[1160*232], + enemyspr2[1160*232], + enemyspr3[1160*232], + enemyspr4[1160*232], + enemyspr5[1160*232], + enemyspr6[1160*232], + minespr[7*7]; + +char name1[10],name2[10]; + +char trans_table[256][256]; +char shadow_table[256][16]; + +char *menu_text[Menu_texts]={"single pl game", + "multiplayer game", + "options", + "exit to dos"}; + +int first=0,all_dead=0,quit=0,MAP_ON=0,next_level=0,complete_time=0; +char DEATH_MATCH_LEVEL[13]; +int DEATH_MATCH_EPISODE=0; +int DEATH_MATCH_SPEED; +int episode=0; + +int EFFECT_VOLUME=63; +int MUSIC_VOLUME=63; + +clock_t st,et; + +int F_PER_SEC,OVER_POWER; + +int START_LEVEL; +int LEVELS; + +int Spot_amount; +int Steam_amount; + +int Spot_count; +int Steam_count; + +int level_x_size,level_y_size; + +int pl_start_x[MAX_PLAYERS],pl_start_y[MAX_PLAYERS]; + +int PLAYERS; +int ACTIVE_PLAYERS; +int ENEMIES,LEVEL,DEAD_ENEMIES; +int ENEMIES_ON_GAME=1; + +int FRAMES_ON; +int target_frames=TARGET_FRAMES; // pelin p„ivitys nopeus +int delau=10; + +char *k_text[DIFF_K]={ + "walk forward", + "walk backward", + "turn c.clockw.", + "turn clockw.", + "fire", + "change weapon", + "strafe", + "strafe left", + "strafe right", + "back to menu" +}; + +struct special spec[SPEC_K]={ + 1,"esc", + 15,"tab", + 28,"enter", + 29,"left ctrl", + 90,"right ctrl", + 42,"left shift", + 54,"right shift", + 57,"space", + 58,"caps lock", + 56,"alt", + 92,"alt gr", + 93,"home", + 94,"arrow up", + 100,"page down", + 95,"page up", + 96,"arrow left", + 97,"arrow right", + 98,"end", + 99,"arrow down", + 101,"insert", + 102,"delete" + }; + +Effect_type effect_type[10]; + +char virbuff[320*240]; +float sini[360],cosi[360]; +char *thefonts[10]; +int f_x_size[10],f_y_size[10]; + +int FONT_NUM; +KeyboardHandler k; +Keys keys1,keys2; +Player player[MAX_PLAYERS]; // PLAYERS +Body_part body_part[MAX_BODY_PARTS]; +Enemy enemy[MAX_ENEMIES]; +Effect effect[MAX_EFFECTS]; +Bullet bullet[MAX_BULLETS]; +Spot spot_light[MAX_SPOTS]; +Steam steam[MAX_STEAM]; +Light light[LIGHTS]; +Light_table normal_l,red_l,yellow_l,explo_l; +General_level_info general_level_info; +Normal_game_level_info normal_game_level_info; +Death_match_level_info death_match_level_info; +Crate crate[MAX_CRATES]; + +MIDASsample magnumwav, + shotgunwav, + pistolwav, + sinkowav, + hitwav, + explowav, + klikwav, + deathwav, + wooshwav, + flamewav + ; + +MIDASmodule biisi; + +MIDASmodulePlayHandle ph; + +int sample_rates[DIFF_WEAPONS+1]={ + 10000, // nyrkki + 30000, + 13000, + 22000, + 16000, + 17000, + 18000, + 16000, + 15000, + 0, + 11025, + 0 +}; + +struct WEapon weapon[DIFF_WEAPONS+1]={ + "fist", + 0, + 10, + 0, + 1, + 1, + 0, + 0, + &hitwav, + "Pistola", + 400, + 10, + 1, + 1, + 10, + 1, + 1, + &magnumwav, + "Shotgun", + 1000, + 17, + 1, + 6, + 20, + 1, + 3, + &shotgunwav, + "Uzi", + 2000, + 4, + 1, + 1, + 10, + 1, + 1, + &pistolwav, + "Auto rifle", + 4000, + 5, + 1, + 1, + 10, + 1, + 2, + &pistolwav, + "Grenade launcher", + 4000, + 30, + 0, + 1, + 10, + 1, + 5, + &sinkowav, + "Auto grenadier", + 6000, + 10, + 0, + 1, + 10, + 1, + 4, + &sinkowav, + "Heavy launcher", + 6000, + 40, + 0, + 1, + 10, + 1, + 6, + &sinkowav, + "Auto shotgun", + 6000, + 5, + 1, + 6, + 20, + 1, + 3, + &shotgunwav, + "C4-Activator", + 1000, + 10, + 0, + 1, + 1, + 0, + 7, + 0, + "Flame thrower", + 3000, + 1, + 0, + 1, + 10, + 1, + 8, + &flamewav, + "Mine dropper", + 1000, + 20, + 0, + 1, + 1, + 0, + 9, + 0 + }; + +Bullet_type bullet_type[DIFF_BULLETS+2]; + + +struct s shield_data ={ + "Shield", + 160, + 15}; // muuta t„t„ shop.h:ssa + +struct juu enemy_info[DIFF_ENEMIES]={ + "pistol boy", + enemyspr0, + 2, + 1, + 18, + 200, + "shotgun maniac", + enemyspr1, + 2, + 2, + 28, + 350, + "uzi rebel", + enemyspr2, + 2, + 3, + 40, + 400, + "commando", + enemyspr3, + 3, + 4, + 50, + 600, + "grenade gay", + enemyspr4, + 2, + 5, + 40, + 700, + "civilian", + enemyspr5, + 2, + 0, + 10, + 50, + "punisher", + enemyspr6, + 1, + 8, + 150, + 650 +}; +Level leveldata; + +char *player_opt_text[num_player_options]={ + "define keys 1", + "define keys 2", + "change pl1 name", + "change pl2 name", + "previous menu" + }; + +char *game_opt_text[num_game_options]={ + "darkness", + "light effects", + "shadows", + "previous menu" + }; + +char *sound_opt_text[num_sound_options]={ + "music volume", + "effects volume", + "previous menu" + }; + +char *opt_text[num_options]={ + "player options", + "game options", + "sound options", + "deathmatch options", + "previous menu" + }; + +char *deathmatch_opt_text[num_deathmatch_options]={ + "moving", + "enemies", + "previous menu" + }; + +char *multip_opt_text[num_multip_options]={ + "start game", + "join game", + "episode", + "level", + "game type", + "game mode", + "previous menu" + }; + +vile filelist[256][1024]; +vile dirlist[256]; +int files_in_episode[256]; +int dirs=0; + + diff --git a/BAK/GLOBVAR.H b/BAK/GLOBVAR.H new file mode 100644 index 0000000..9408622 --- /dev/null +++ b/BAK/GLOBVAR.H @@ -0,0 +1,119 @@ +#ifndef __TK__GLOBVAR__ +#define __TK__GLOBVAR__ + +#include +#include +#include "defines.h" +#include "types.h" +#include "classes.h" + +extern int ipxavail; +extern int BACK_TO_MENU; +extern int VESA2,FORCE_0x13,scr_y_size,GAME_MODE,NETWORK_MODE; +extern int KILLING_MODE,SHOW_ENEMIES,target_cost; // t„ht„imen hinta +extern volatile unsigned framecount; +extern int effect_age_count; +extern int dust_blocks[]; +extern int Light_sizes[LIGHTS]; +extern int DARK_MODE,LIGHT_EFFECTS,SHADOWS,SMOKE_EFFECTS; +extern int sell_price[DIFF_WEAPONS+2]; // myyntihinnat muuttuvia +extern struct BLOCK *level; +extern char *see_level; +extern char cratespr[],shadowspr[], + c4spr[], + grenadespr[], + targetspr[], + floorspr[], + wallspr[], + floorspr2[], + rambospr[], + bodypartspr[], + effectspr[], + pal[], + picture[], + warespr[], + enemyspr0[], + enemyspr1[], + enemyspr2[], + enemyspr3[], + enemyspr4[], + enemyspr5[], + enemyspr6[], + minespr[]; +extern char name1[10],name2[10]; +extern char trans_table[256][256]; +extern char shadow_table[256][16]; +extern char *menu_text[Menu_texts]; +extern int first,all_dead,quit,MAP_ON,next_level,complete_time; +extern char DEATH_MATCH_LEVEL[13]; +extern int DEATH_MATCH_EPISODE; +extern int DEATH_MATCH_SPEED; +extern int episode; + +extern int EFFECT_VOLUME,MUSIC_VOLUME; +extern clock_t st,et; +extern int F_PER_SEC,OVER_POWER,START_LEVEL,LEVELS; + +extern int Spot_amount,Steam_amount,Spot_count,Steam_count; +extern int level_x_size,level_y_size; +extern int pl_start_x[MAX_PLAYERS],pl_start_y[MAX_PLAYERS]; +extern int PLAYERS,ACTIVE_PLAYERS,ENEMIES,LEVEL,DEAD_ENEMIES,ENEMIES_ON_GAME; + +extern int FRAMES_ON,target_frames,delau; +extern char *k_text[DIFF_K]; +extern struct special spec[SPEC_K]; +extern Effect_type effect_type[10]; +extern char virbuff[]; +extern float sini[],cosi[]; +extern char *thefonts[10]; +extern int f_x_size[10],f_y_size[10]; +extern int FONT_NUM; +extern KeyboardHandler k; +extern Keys keys1,keys2; +extern Player player[MAX_PLAYERS]; // PLAYERS +extern Body_part body_part[MAX_BODY_PARTS]; +extern Enemy enemy[MAX_ENEMIES]; +extern Effect effect[MAX_EFFECTS]; +extern Bullet bullet[MAX_BULLETS]; +extern Spot spot_light[MAX_SPOTS]; +extern Steam steam[MAX_STEAM]; +extern Light light[LIGHTS]; +extern Light_table normal_l,red_l,yellow_l,explo_l; +extern General_level_info general_level_info; +extern Normal_game_level_info normal_game_level_info; +extern Death_match_level_info death_match_level_info; +extern Crate crate[MAX_CRATES]; +extern Bullet_type bullet_type[DIFF_BULLETS+2]; +extern struct s shield_data; +extern struct WEapon weapon[DIFF_WEAPONS+1]; +extern struct juu enemy_info[DIFF_ENEMIES]; + +extern MIDASsample magnumwav, + shotgunwav, + pistolwav, + sinkowav, + hitwav, + explowav, + klikwav, + deathwav, + wooshwav, + flamewav; + +extern MIDASmodule biisi; +extern MIDASmodulePlayHandle ph; +extern int sample_rates[DIFF_WEAPONS+1]; +extern Level leveldata; + +extern char *player_opt_text[num_player_options]; +extern char *game_opt_text[num_game_options]; +extern char *sound_opt_text[num_sound_options]; +extern char *opt_text[num_options]; +extern char *deathmatch_opt_text[num_deathmatch_options]; +extern char *multip_opt_text[num_multip_options]; +extern vile filelist[256][1024]; +extern vile dirlist[256]; +extern int files_in_episode[256]; +extern int dirs; + +#endif + diff --git a/BAK/GLOBVAR.OBJ b/BAK/GLOBVAR.OBJ new file mode 100644 index 0000000..718bf1a Binary files /dev/null and b/BAK/GLOBVAR.OBJ differ diff --git a/BAK/INT.OBJ b/BAK/INT.OBJ new file mode 100644 index 0000000..7761554 Binary files /dev/null and b/BAK/INT.OBJ differ diff --git a/BAK/INT/INT.ASM b/BAK/INT/INT.ASM new file mode 100644 index 0000000..a960850 --- /dev/null +++ b/BAK/INT/INT.ASM @@ -0,0 +1,104 @@ +; IPX EXAMPLE FOR WATCOM C/C++ (10.0a) UNDER DOS4GW PMODE DPMI. +; Written by Daniel Jeppson d94dj@efd.lth.se 960511 03:28 AM (8 + +; You are hearby granted the right to use this code freely but +; I would appreciate a credit or greet if you find it useful... + +; Please see the readme.txt and chat.c for more information... + + .386p + .model flat,c + locals + jumps + + ; Macros to Decrement Counter & Jump on Condition +LOOPx MACRO Register, Destination + DEC Register ; Counter-- + JNZ Destination ; Jump if not 0 +ENDM +LOOPjz MACRO Register, Destination + DEC Register ; Counter-- + JZ Destination ; Jump if 0 +ENDM + +PUSHALL MACRO ; Pushes all registers onto stack = 18c + PUSH EAX + PUSH EBX + PUSH ECX + PUSH EDX + PUSH ESI + PUSH EDI +ENDM + +POPALL MACRO ; Pops all registers from stack = 18c + POP EDI + POP ESI + POP EDX + POP ECX + POP EBX + POP EAX +ENDM + +POPALLSEGS MACRO + POP GS + POP FS + POP ES + POP DS +ENDM + +PUSHALLSEGS MACRO + PUSH DS + PUSH ES + PUSH FS + PUSH GS +ENDM + +SWAPPA MACRO Register ; Swaps low and high byte in a word... + ROL Register,8 +ENDM + + assume CS:_TEXT,DS:DGROUP + + dataseg + + global lseg:word + lseg DW 0 + global lsel:word + lsel DW 0 + + global getlowmem:PROC + global freelowmem:PROC + + codeseg + + getlowmem PROC ; Get low memory! (BX = paragraphs of memory) + PUSH EBX ; AX = segment to memory + PUSH ECX + PUSH EDX + PUSH ESI + PUSH EDI + MOV AX,0100h ; Get BX paragraphs of memory... + INT 31h ; (1 paragraph = 16 bytes) + MOV lseg,AX + MOV lsel,DX + ;XOR EAX,EAX + MOV AX,DX + POP EDI + POP ESI + POP EDX + POP ECX + POP EBX + RET + getlowmem ENDP + + freelowmem PROC ; Free low memory! (DX = selector) + PUSHALL + PUSHALLSEGS + MOV AX,0101h + INT 31h + POPALLSEGS + POPALL + RET + freelowmem ENDP + +END diff --git a/BAK/INT/INT.ERR b/BAK/INT/INT.ERR new file mode 100644 index 0000000..d967784 Binary files /dev/null and b/BAK/INT/INT.ERR differ diff --git a/BAK/INT/INT.H b/BAK/INT/INT.H new file mode 100644 index 0000000..26aace8 --- /dev/null +++ b/BAK/INT/INT.H @@ -0,0 +1,37 @@ +// IPX EXAMPLE FOR WATCOM C/C++ (10.0a) UNDER DOS4GW PMODE DPMI. +// Written by Daniel Jeppson d94dj@efd.lth.se 960511 03:28 AM (8 + +// You are hearby granted the right to use this code freely but +// I would appreciate a credit or greet if you find it useful... + +// Please see the readme.txt and chat.c for more information... + +#ifndef __INT_H_ +#define __INT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +unsigned short getlowmem(unsigned short size); +void freelowmem(unsigned short sel); + +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +extern unsigned short lseg; +extern unsigned short lsel; + +#ifdef __cplusplus +} +#endif + +#pragma aux getlowmem "_*" parm [EBX] caller; +#pragma aux freelowmem "_*" parm [EDX] caller; + +#endif diff --git a/BAK/INT/INT.OBJ b/BAK/INT/INT.OBJ new file mode 100644 index 0000000..7761554 Binary files /dev/null and b/BAK/INT/INT.OBJ differ diff --git a/BAK/IPX.OBJ b/BAK/IPX.OBJ new file mode 100644 index 0000000..3f2c9bc Binary files /dev/null and b/BAK/IPX.OBJ differ diff --git a/BAK/IPX/IPX.BAK b/BAK/IPX/IPX.BAK new file mode 100644 index 0000000..66514eb --- /dev/null +++ b/BAK/IPX/IPX.BAK @@ -0,0 +1,79 @@ +// IPX EXAMPLE FOR WATCOM C/C++ (10.0a) UNDER DOS4GW PMODE DPMI. +// Written by Daniel Jeppson d94dj@efd.lth.se 960511 03:28 AM (8 + +// You are hearby granted the right to use this code freely but +// I would appreciate a credit or greet if you find it useful... + +// Please see the readme.txt and chat.c for more information... + +#ifndef __IPX_H_ +#define __IPX_H_ + +#define byte unsigned char // commonly defined ever.. (8 +#define word unsigned short +#define dword unsigned long +#define MAXDATASIZE 128 + +extern dword socketid; + +struct nodeaddr +{ + byte node[6]; +}; + +struct localaddr +{ + byte network[4]; + struct nodeaddr node; +}; + +struct ecbtype +{ + word link[2]; + word esr[2]; + byte inuse; + byte complete; + word socket; + byte ipxwork[4]; + byte dwork[12]; + byte immedaddr[6]; + word fragcount; + word fragdata[2]; + word fragsize; +}; + +struct netaddress +{ + byte net[4]; + struct nodeaddr node; + word socket; +}; + +struct ipxheader +{ + word check; + word length; + byte tc; + byte ptype; + struct netaddress dest; + struct netaddress src; +}; + +struct packet +{ + struct ecbtype ecb; + struct ipxheader ipx; + char data[MAXDATASIZE]; +}; + +extern struct localaddr far *localadd; + +int opensocket(byte,word); +void closesocket(word); +int initipx(void); +void getlocaladdress(void); +void listenforpacket(word packetseg); +char *decode_localaddress(char *str,struct localaddr far *la); +char *decode_address(char *str,struct netaddress far *la); +void sendpacket(word ecbseg,struct nodeaddr destnode, struct packet far *packetet,word len); +#endif diff --git a/BAK/IPX/IPX.CPP b/BAK/IPX/IPX.CPP new file mode 100644 index 0000000..c3b50b1 --- /dev/null +++ b/BAK/IPX/IPX.CPP @@ -0,0 +1,242 @@ +// IPX EgotoXAMPLE FOR WATCOM C/C++ (10.0a) UNDER DOS4GW PMODE DPMI. +// Written by Daniel Jeppson d94dj@efd.lth.se 960511 03:28 AM (8 + +// You are hearby granted the right to use this code freely but +// I would appreciate a credit or greet if you find it useful... + +// Please see the readme.txt and chat.c for more information... + +#define MAXNODES 1 // Maximum number of nodes + +#include +#include +#include +#include +#include "../error/error.h" +#include "ipx.h" // My ipx header file.. +#include "../int/int.h" + +struct nodeaddr nodes[MAXNODES+1]; // Last is broadcast and first is local... +dword socketid=0; + +static struct rminfo +{ + long EDI; + long ESI; + long EBP; + long reserved_by_system; + long EBX; + long EDX; + long ECX; + long EAX; + short flags; + short ES,DS,FS,GS,IP,CS,SP,SS; +} RMI; + +word localaddl=0; // Selector to the localadd lowmem allocated. +struct localaddr far *localadd=NULL; + +union REGS regs; +struct SREGS sregs; + +void clearrmi(void) +{ // Clear the RMI registers... + memset(&sregs,0,sizeof(sregs)); + memset(&RMI,0,sizeof(RMI)); +} + +void callrealint(byte inten) +{ // This routine calls a realmode interrupt (interrupt inten) + int interrupt_no=0x31; + + // Use DMPI call 300h to issue the DOS interrupt + regs.w.ax = 0x0300; + regs.h.bh = 0; + regs.h.bl = inten; + regs.w.cx = 0; + sregs.es = FP_SEG(&RMI); + regs.x.edi = FP_OFF(&RMI); + int386x( interrupt_no, ®s, ®s, &sregs ); +} + +int swap(int swappen) +{ // swap the low and high order byte of a word... + swappen&=0xffff; + return (swappen<<8)+((swappen&65280)>>8); +} + +int opensocket(byte longevity,word socket) +{ // Open up a socket.. Returns 0xff if everything went fine.. + + //Set up real-mode call structure + clearrmi(); + RMI.EBX=0x0; + RMI.EAX=longevity; + RMI.EDX=swap(socket); + callrealint(0x7a); + socketid=(word)swap(RMI.EDX); + + return (byte)(RMI.EAX); +} + +void closesocket(word socket) +{ // Closes an open socket.. Do not forget to call this routine!! + clearrmi(); + RMI.EBX=0x1; + RMI.EDX=swap(socket); + callrealint(0x7a); +} + +int initipx(void) +{ // Does what it is called... (8 + int q; + + clearrmi(); + RMI.EAX=0x7A00; + callrealint(0x2f); + if ((RMI.EAX&255)!=255) return(0); + + getlocaladdress(); + for (q=0;q<6;q++) + { + nodes[0].node[q]=localadd->node.node[q]; // HOME + nodes[MAXNODES].node[q]=0xff; // BROADCAST + } + return(1); +} + +void getlocaladdress(void) +{ + if (localadd==NULL) + { + localadd=(struct localaddr far *)MK_FP(getlowmem(sizeof(struct localaddr)/16+1),0); + localaddl=lsel; + }; + clearrmi(); + RMI.EBX=9; + RMI.ES=lseg; + RMI.ESI=0; + callrealint(0x7a); +} + +void listenforpacket(word packetseg) +{ + clearrmi(); + RMI.ESI=0; // Offset to ECB is 0 when you allocate lowmem... + RMI.ES=packetseg; + RMI.EBX=4; + RMI.EAX=0; + callrealint(0x7a); + if (RMI.EAX&255) error("Listenforpacket failed!\n"); + +} + +void initreceivepacket(struct packet far *packetet,word lseg) +{ + _fmemset(packetet,0,sizeof(struct packet)); + + packetet->ecb.inuse=0x1d; + packetet->ecb.socket=(word)swap(socketid); + packetet->ecb.fragcount=1; + packetet->ecb.fragdata[0]=sizeof(struct ecbtype); + // fragdata[0] is the offset to the ipx header. + // Since ipx comes after ecb it's sizeof(ecb) bytes + // after the allocated memory... + + packetet->ecb.fragdata[1]=lseg; + // lseg contains the latest allocated lowmem segment. + + packetet->ecb.fragsize=sizeof(struct packet)-sizeof(struct ecbtype); + listenforpacket(lseg); +} + +void initsendpacket(struct packet far *packetet,word lseg) +{ + _fmemset(packetet,0,sizeof(struct packet)); + + packetet->ecb.socket=(word)swap(socketid); + packetet->ecb.fragcount=1; + packetet->ecb.fragdata[0]=sizeof(struct ecbtype); + packetet->ecb.fragdata[1]=lseg; + + packetet->ecb.immedaddr[0]=0xff; + packetet->ecb.immedaddr[1]=0xff; + packetet->ecb.immedaddr[2]=0xff; + packetet->ecb.immedaddr[3]=0xff; + packetet->ecb.immedaddr[4]=0xff; + packetet->ecb.immedaddr[5]=0xff; + packetet->ipx.dest.node.node[0]=0xff; + packetet->ipx.dest.node.node[1]=0xff; + packetet->ipx.dest.node.node[2]=0xff; + packetet->ipx.dest.node.node[3]=0xff; + packetet->ipx.dest.node.node[4]=0xff; + packetet->ipx.dest.node.node[5]=0xff; + + packetet->ipx.check=0xffff; + packetet->ipx.ptype=0x00; + packetet->ipx.tc=0x00; + packetet->ipx.dest.net[0]=localadd->network[0]; + packetet->ipx.dest.net[1]=localadd->network[1]; + packetet->ipx.dest.net[2]=localadd->network[2]; + packetet->ipx.dest.net[3]=localadd->network[3]; + packetet->ipx.dest.socket=(word)swap(socketid); + packetet->ipx.src.net[0]=localadd->network[0]; + packetet->ipx.src.net[1]=localadd->network[1]; + packetet->ipx.src.net[2]=localadd->network[2]; + packetet->ipx.src.net[3]=localadd->network[3]; + packetet->ipx.src.node.node[0]=localadd->node.node[0]; + packetet->ipx.src.node.node[1]=localadd->node.node[1]; + packetet->ipx.src.node.node[2]=localadd->node.node[2]; + packetet->ipx.src.node.node[3]=localadd->node.node[3]; + packetet->ipx.src.node.node[4]=localadd->node.node[4]; + packetet->ipx.src.node.node[5]=localadd->node.node[5]; + packetet->ipx.src.socket=(word)swap(socketid); +} + +void sendpacket(word ecbseg,struct nodeaddr destnode, struct packet far *packetet,word len) +{ // Sends a packet... + // ecbseg is the senders segment... + int q; + clearrmi(); + + for (q=0;q<6;q++) + packetet->ecb.immedaddr[q]=packetet->ipx.dest.node.node[q]=destnode.node[q]; + + if (len>MAXDATASIZE) len=MAXDATASIZE; + packetet->ecb.fragsize=(word)(sizeof(struct ipxheader)+len); + + RMI.ESI=0; + RMI.ES=ecbseg; + RMI.EBX=3; + callrealint(0x7a); + if (RMI.EAX&255) error("sendpacket : sending failed\n"); +} + +void char2hex(char *str,char ch) +{ char hex[]="0123456789ABCDEF"; + str[0]=hex[ch>>4]; + str[1]=hex[ch&0xf]; +} + +char *decode_localaddress(char *str,struct localaddr far *la) +{ int a; + + for (a=0;a<4;a++) + char2hex(str+(a*2),la->network[a]); + str[8]=':'; + + for (a=0;a<6;a++) + char2hex(str+(a*2)+9,la->node.node[a]); + str[21]=0; + return(str); +} + +char *decode_address(char *str,struct netaddress far *la) +{ int a; + for (a=0;a<6;a++) + char2hex(str+(a*2),la->node.node[a]); + str[12]=0; + return(str); +} + + diff --git a/BAK/IPX/IPX.H b/BAK/IPX/IPX.H new file mode 100644 index 0000000..66514eb --- /dev/null +++ b/BAK/IPX/IPX.H @@ -0,0 +1,79 @@ +// IPX EXAMPLE FOR WATCOM C/C++ (10.0a) UNDER DOS4GW PMODE DPMI. +// Written by Daniel Jeppson d94dj@efd.lth.se 960511 03:28 AM (8 + +// You are hearby granted the right to use this code freely but +// I would appreciate a credit or greet if you find it useful... + +// Please see the readme.txt and chat.c for more information... + +#ifndef __IPX_H_ +#define __IPX_H_ + +#define byte unsigned char // commonly defined ever.. (8 +#define word unsigned short +#define dword unsigned long +#define MAXDATASIZE 128 + +extern dword socketid; + +struct nodeaddr +{ + byte node[6]; +}; + +struct localaddr +{ + byte network[4]; + struct nodeaddr node; +}; + +struct ecbtype +{ + word link[2]; + word esr[2]; + byte inuse; + byte complete; + word socket; + byte ipxwork[4]; + byte dwork[12]; + byte immedaddr[6]; + word fragcount; + word fragdata[2]; + word fragsize; +}; + +struct netaddress +{ + byte net[4]; + struct nodeaddr node; + word socket; +}; + +struct ipxheader +{ + word check; + word length; + byte tc; + byte ptype; + struct netaddress dest; + struct netaddress src; +}; + +struct packet +{ + struct ecbtype ecb; + struct ipxheader ipx; + char data[MAXDATASIZE]; +}; + +extern struct localaddr far *localadd; + +int opensocket(byte,word); +void closesocket(word); +int initipx(void); +void getlocaladdress(void); +void listenforpacket(word packetseg); +char *decode_localaddress(char *str,struct localaddr far *la); +char *decode_address(char *str,struct netaddress far *la); +void sendpacket(word ecbseg,struct nodeaddr destnode, struct packet far *packetet,word len); +#endif diff --git a/BAK/IPX/IPX.OBJ b/BAK/IPX/IPX.OBJ new file mode 100644 index 0000000..450fa0f Binary files /dev/null and b/BAK/IPX/IPX.OBJ differ diff --git a/BAK/I_FUNCS.H b/BAK/I_FUNCS.H new file mode 100644 index 0000000..58bb007 --- /dev/null +++ b/BAK/I_FUNCS.H @@ -0,0 +1,208 @@ +void level_info(){ +char text[20]; +int a,b; + +load_efp("efps\\cool.efp",picture,0); +load_efp_pal("efps\\ware.efp",pal); +draw_box1(10,10,10+100,10+20,10); +draw_box1(10,50,310,50+20,10); +draw_box1(10,90,160,190,10); + +memcpy(virbuff,picture,64000); + +FONT_NUM=0; + +writefonts2(16,13,"level",1); +itoa(LEVEL+1,text,10); +writefonts2(71,13,text,1); +writefonts2(160-(str_length(general_level_info.comment)/2),13+40,general_level_info.comment,1); + +FONT_NUM=1; + +writefonts(16,96,"The killing list:",M_RED); + +for (a=0,b=111;a0) +{ +itoa(general_level_info.enemies[a],text,10); +strcat(text," "); +strcat(text,enemy_info[a].name); +if (general_level_info.enemies[a]>1) +strcat(text,"s"); + +writefonts(16,b,text,M_YELLOW); + +b+=8; +} + +writefonts(16,173,"Your action time is:",M_RED); + +writefonts(16+95,173,c_2_c(general_level_info.time_limit*TIME_ADD),M_YELLOW); + +fadein(virbuff,pal); + +k.clear_stack(); +if (k.getch()==27) if (wanna_quit()) BACK_TO_MENU=1; + +if (! BACK_TO_MENU) fadeout(virbuff,pal); + +} + +void statics(){ + +char text[20],text2[20]; +int a,b,timebonus; + +load_efp("efps\\cool.efp",picture,0); +load_efp_pal("efps\\ware.efp",pal); + +draw_box1(10,10,310,32,10); +draw_box1(10,40,310,190,10); + +memcpy(virbuff,picture,64000); + +timebonus=((general_level_info.time_limit*TIME_ADD)-complete_time)*5; + +if (timebonus<-500) timebonus=-500; + +FONT_NUM=0; + +if (next_level && ! quit) +writefonts2(160-(str_length("completed !")/2),13,"completed !",1); +if (quit || next_level==0) +writefonts2(160-(str_length("game over")/2),13,"game over",1); + +FONT_NUM=1; + +for (a=0,b=0;a0) b=1; + +if (b==1){ +strcpy(text,"Kills for "); +} +if (b==0){ +strcpy(text,"No kills for "); +} + +strcat(text,player[0].name); + +writefonts(16,50,text,M_YELLOW); + +for (a=0,b=65;a0) +{ +player[0].total_kills+=player[0].kills[a]; + +itoa(player[0].kills[a],text,10); +strcat(text," "); +strcat(text,enemy_info[a].name); +if (player[0].kills[a]>1) +strcat(text,"s"); + +writefonts(16,b,text,M_YELLOW); + +strcpy(text,"+"); +itoa(enemy_info[a].reward*player[0].kills[a],text2,10); +player[0].cash+=enemy_info[a].reward*player[0].kills[a]; +strcat(text,text2); + +writefonts(103,b,text,M_RED); + +b+=8; +} + +player[0].cash+=timebonus; +if (player[0].cash<0) player[0].cash=0; + +writefonts(16,130,"Total kills:",M_RED); +itoa(player[0].total_kills,text,10); +writefonts(76,130,text,M_YELLOW); + +writefonts(16,140,"Accuracy:",M_RED); +if (player[0].shooted>0) +itoa(((float)player[0].hitten/player[0].shooted)*100,text,10); +else strcpy(text,"0"); +strcat(text,"%"); +writefonts(76,140,text,M_YELLOW); + +writefonts(16,150,"Cash:",M_RED); +itoa(player[0].cash,text,10); +writefonts(76,150,text,M_YELLOW); + +if (GAME_MODE==SPLIT_SCREEN){ + +for (a=0,b=0;a0) b=1; + +if (b==1){ +strcpy(text,"Kills for "); +} +if (b==0){ +strcpy(text,"No kills for "); +} + +strcat(text,player[1].name); + +writefonts(16+160,50,text,M_YELLOW); + +for (a=0,b=65;a0) +{ +player[1].total_kills+=player[1].kills[a]; + +itoa(player[1].kills[a],text,10); +strcat(text," "); +strcat(text,enemy_info[a].name); +if (player[1].kills[a]>1) +strcat(text,"s"); + +writefonts(16+160,b,text,M_YELLOW); + +strcpy(text,"+"); +itoa(enemy_info[a].reward*player[1].kills[a],text2,10); +player[1].cash+=enemy_info[a].reward*player[1].kills[a]; +strcat(text,text2); + +writefonts(103+160,b,text,M_RED); + +b+=8; +} + +player[1].cash+=timebonus; +if (player[1].cash<0) player[1].cash=0; + +writefonts(16+160,130,"Total kills:",M_RED); +itoa(player[1].total_kills,text,10); +writefonts(76+160,130,text,M_YELLOW); + +writefonts(16+160,140,"Accuracy:",M_RED); +if (player[1].shooted>0) +itoa(((float)player[1].hitten/player[1].shooted)*100,text,10); +else strcpy(text,"0"); +strcat(text,"%"); +writefonts(76+160,140,text,M_YELLOW); + +writefonts(16+160,150,"Cash:",M_RED); +itoa(player[1].cash,text,10); +writefonts(76+160,150,text,M_YELLOW); + +} + +writefonts(16,170,"Time limit:",M_RED); +writefonts(16+55,170,c_2_c(general_level_info.time_limit*TIME_ADD),M_BLUE); +writefonts(16+80,170,"Your time:",M_RED); +writefonts(16+80+55,170,c_2_c(complete_time),M_BLUE); + +writefonts(16+80+80,170,"Time bonus:",M_RED); +itoa(timebonus,text,10); +writefonts(16+80+55+80,170,text,M_YELLOW); + +fadein(virbuff,pal); + +k.clear_stack(); +if (k.getch()==27) if (! quit) {if (wanna_quit()) BACK_TO_MENU=1;} + +if (! BACK_TO_MENU) fadeout(virbuff,pal); + +} + diff --git a/BAK/LINUXM~1 b/BAK/LINUXM~1 new file mode 100644 index 0000000..e81a700 --- /dev/null +++ b/BAK/LINUXM~1 @@ -0,0 +1,29 @@ +../game: game.o efp.o ipx.o error.o int.o rgbhsl.o globvar.o miscfunc.o fade.o draw.o write.o classes.o rout.o newfuncs.o options.o + ld game.o error.o efp.o ipx.o int.o rgbhsl.o globvar.o miscfunc.o draw.o fade.o write.o classes.o rout.o newfuncs.o options.o -o ../game + +options.o: options.cpp globvar.h types.h defines.h + gcc -O2 -c options.cpp -o options.o +newfuncs.o: newfuncs.cpp globvar.h types.h defines.h + gcc -O2 -c newfuncs.cpp +rout.o: rout.cpp globvar.h types.h defines.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c rout.cpp +classes.o: classes.cpp globvar.h types.h defines.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c classes.cpp +write.o: write.cpp globvar.h types.h defines.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c write.cpp +fade.o: fade.cpp globvar.h types.h defines.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c fade.cpp +draw.o: draw.cpp draw.h types.h globvar.h defines.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c draw.cpp +miscfunc.o: miscfunc.cpp miscfunc.h types.h globvar.h defines.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c miscfunc.cpp +globvar.o: globvar.cpp globvar.h defines.h types.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c globvar.cpp +rgbhsl.o: rgbhsl.c rgbhsl.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c rgbhsl.c +error.o: error/error.cpp error/error.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c error/error.cpp +game.o: game.cpp efp/efp.h error/error.h ipx/ipx.h defines.h types.h globvar.h miscfunc.h newfuncs.h options.h + gcc -O2 -c game.cpp +efp.o: efp/efp.cpp efp/efp.h error/error.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c efp/efp.cpp diff --git a/BAK/MAKEFILE b/BAK/MAKEFILE new file mode 100644 index 0000000..fcbeb73 --- /dev/null +++ b/BAK/MAKEFILE @@ -0,0 +1,31 @@ +..\game.exe: game.obj efp.obj ipx.obj error.obj int.obj midas.lib rgbhsl.obj globvar.obj miscfunc.obj fade.obj draw.obj write.obj classes.obj rout.obj newfuncs.obj options.obj + wlink @tk.lnk + +options.obj: options.cpp globvar.h types.h defines.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c options.cpp +newfuncs.obj: newfuncs.cpp globvar.h types.h defines.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c newfuncs.cpp +rout.obj: rout.cpp globvar.h types.h defines.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c rout.cpp +classes.obj: classes.cpp globvar.h types.h defines.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c classes.cpp +write.obj: write.cpp globvar.h types.h defines.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c write.cpp +fade.obj: fade.cpp globvar.h types.h defines.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c fade.cpp +draw.obj: draw.cpp draw.h types.h globvar.h defines.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c draw.cpp +miscfunc.obj: miscfunc.cpp miscfunc.h types.h globvar.h defines.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c miscfunc.cpp +globvar.obj: globvar.cpp globvar.h defines.h types.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c globvar.cpp +rgbhsl.obj: rgbhsl.c rgbhsl.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c rgbhsl.c +error.obj: error\error.cpp error\error.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c error\error.cpp +game.obj: game.cpp efp\efp.h error\error.h ipx/ipx.h defines.h types.h globvar.h miscfunc.h newfuncs.h options.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c game.cpp +ipx.obj: ipx/ipx.cpp ipx/ipx.h int/int.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c ipx\ipx.cpp +efp.obj: efp\efp.cpp efp\efp.h error\error.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c efp\efp.cpp diff --git a/BAK/MAKET/MAKET.CPP b/BAK/MAKET/MAKET.CPP new file mode 100644 index 0000000..02963fb --- /dev/null +++ b/BAK/MAKET/MAKET.CPP @@ -0,0 +1,191 @@ +#include +#include +#include +#include +#include + +#include "efp.h" +#include "rgbhsl.h" + +class Light_table{ + public: + char data[256][16]; + void make(int R,int G,int B); + void make2(); +}; + +Light_table normal_l,red_l,yellow_l,explo_l; + +char pal[256*3]; +char trans_table[256][256]; +char shadow_table[256][16]; + +char get_closest(int re,int gr,int bl){ + int a,v,col,minv=1000; + char closest=0; + + for (a=0,col=0;a<256;a++,col+=3){ + v=abs(pal[col]-re)+abs(pal[col+1]-gr)+abs(pal[col+2]-bl); + if (v>1,(g1+g2)>>1,(b1+b2)>>1); +} + +} +} + +void do_shadow_table(){ +int a,z; +float r,g,b,h,s,l,e; + +for (a=0;a<256;a++){ +r=pal[a*3]; +g=pal[a*3+1]; +b=pal[a*3+2]; +rgb2hsl(r,g,b,&h,&s,&l); +e=l/16; +for (z=0;z<16;z++){ +l-=e/2.5; +if (l<0) l=0; +hsl2rgb(h,s,l,&r,&g,&b); +shadow_table[a][z]=get_closest(r,g,b); +} +} + +} + +void Light_table::make(int R,int G,int B){ + + int a,b; + float re,gr,bl,h,s,l; + + for (a=0;a<256;a++){ + + if (a%(16*3)==0) cout<<"."; + + re=pal[a*3]+R; + gr=pal[(a*3)+1]+G; + bl=pal[(a*3)+2]+B; + + if (re>63) re=63; + if (gr>63) gr=63; + if (bl>63) bl=63; + + if (re<0) re=0; + if (gr<0) gr=0; + if (bl<0) bl=0; + + rgb2hsl(re,gr,bl,&h,&s,&l); + for (b=0;b<16;b++){ + + if (R==0 && G==0 && B==0) + if (b>0) { + l+=((float)(b)/255)/2; + if (l>1) l=1; + hsl2rgb(h,s,l,&re,&gr,&bl); + } + + re+=R/2; + gr+=G/2; + bl+=B/2; + + if (re>63) re=63; + if (gr>63) gr=63; + if (bl>63) bl=63; + + if (re<0) re=0; + if (gr<0) gr=0; + if (bl<0) bl=0; + + data[a][b]=get_closest(re,gr,bl); + } + + } + +} + +void Light_table::make2(){ // explosive palette + + int a,b,re,gr,bl,ra,ga,ba; + + for (a=0;a<256;a++){ + + ra=20; + ga=0; + ba=0; + + re=pal[a*3]; + gr=pal[(a*3)+1]; + bl=pal[(a*3)+2]; + + for (b=0;b<16;b++){ + + if (b>1) { + if (b<9){ + ra+=1; + ga+=5; + ba+=1; + } + if (b>8) + ba+=5; + +// re=(pal[a*3]+ra)/2; +// gr=(pal[(a*3)+1]+ga)/2; +// bl=(pal[(a*3)+2]+ba)/2; + + re=(pal[a*3]+ra); + gr=(pal[(a*3)+1]+ga); + bl=(pal[(a*3)+2]+ba); + + } + + if (re>63) re=63; + if (gr>63) gr=63; + if (bl>63) bl=63; + + data[a][b]=get_closest(re,gr,bl); + } + + } +} + +void write_tables(){ +FILE *tab; +tab=fopen("palette.tab","wb"); +fwrite(&trans_table,sizeof(trans_table),1,tab); +fwrite(&shadow_table,sizeof(shadow_table),1,tab); +fwrite(&normal_l.data,sizeof(normal_l.data),1,tab); +fwrite(&red_l.data,sizeof(red_l.data),1,tab); +fwrite(&yellow_l.data,sizeof(yellow_l.data),1,tab); +fwrite(&explo_l.data,sizeof(explo_l.data),1,tab); +fclose(tab); +} + +main(){ + +load_efp_pal("efps\\walls1.efp",pal); +do_trans_table(); +do_shadow_table(); +normal_l.make(0,0,0); +red_l.make(5,0,0); +yellow_l.make(5,5,0); +explo_l.make2(); + +write_tables(); +} + diff --git a/BAK/MAKET/MAKET.EXE b/BAK/MAKET/MAKET.EXE new file mode 100644 index 0000000..2a042b3 Binary files /dev/null and b/BAK/MAKET/MAKET.EXE differ diff --git a/BAK/MAKET/MAKET.OBJ b/BAK/MAKET/MAKET.OBJ new file mode 100644 index 0000000..59f4a88 Binary files /dev/null and b/BAK/MAKET/MAKET.OBJ differ diff --git a/BAK/MAKET/PALETTE.TAB b/BAK/MAKET/PALETTE.TAB new file mode 100644 index 0000000..c685dc4 Binary files /dev/null and b/BAK/MAKET/PALETTE.TAB differ diff --git a/BAK/MIDAS.LIB b/BAK/MIDAS.LIB new file mode 100644 index 0000000..61ea7a3 Binary files /dev/null and b/BAK/MIDAS.LIB differ diff --git a/BAK/MISCFUNC.CPP b/BAK/MISCFUNC.CPP new file mode 100644 index 0000000..f28aad0 --- /dev/null +++ b/BAK/MISCFUNC.CPP @@ -0,0 +1,571 @@ +#include +#include +#include +#include +#include +#include +#include "efp/efp.h" +#include "draw.h" +#include "globvar.h" +#include "fade.h" +#include "write.h" +#include "newfuncs.h" + +void change_name(int num) +{ int x; + + fadeout(virbuff,pal); + load_efp("efps\\cool.efp",picture,0); + FONT_NUM=0; + + x=160-(str_length("enter your name")/2); + draw_box1(x-10,75,320-x+10,125,5); + memcpy(virbuff,picture,64000); + writefonts2(x,85,"enter your name",1); + fadein(virbuff,pal); + k.clear_stack(); + + if (num==1) + readline(x,100,10,name1,screen); + if (num==2) + readline(x,100,10,name2,screen); + + fadeout(virbuff,pal); + +} + +char *k_2_c(int key) +{ + char *t,text[15]; + int a; + + strset(text,0); + text[0]=(char)k.tt.Non[key]; + for (a=0;a23) cnt=0; + } + + for (a=0;a<0x80 && ! pressed;a++) + if (a!=42) + if (k.state[a]) {key=a;pressed=1;} + + } + + for (a=0;a<0x80;a++) + k.state[a]=0; + + return(key); +} + +void clear_shit(int y) +{ + int a; + + for (a=0;a<20;a++) + memcpy(screen+((y+a)*320)+20,picture+((y+a)*320)+20,20); + + for (a=0;a<8;a++) + memcpy(screen+((y+a+3)*320)+190,picture+((y+a+3)*320)+190,130); +} + +void set_keys(){ + +if (GAME_MODE!=SPLIT_SCREEN){ + +player[0].K_LEFT=keys1.K_LEFT; +player[0].K_RIGHT=keys1.K_RIGHT; +player[0].K_UP=keys1.K_UP; +player[0].K_DOWN=keys1.K_DOWN; +player[0].K_SHOOT=keys1.K_SHOOT; +player[0].K_SHIFT=keys1.K_SHIFT; +player[0].K_STRAFE=keys1.K_STRAFE; +player[0].K_LSTRAFE=keys1.K_LSTRAFE; +player[0].K_RSTRAFE=keys1.K_RSTRAFE; + +} + +if (GAME_MODE==SPLIT_SCREEN){ + +player[0].K_LEFT=keys2.K_LEFT; +player[0].K_RIGHT=keys2.K_RIGHT; +player[0].K_UP=keys2.K_UP; +player[0].K_DOWN=keys2.K_DOWN; +player[0].K_SHOOT=keys2.K_SHOOT; +player[0].K_SHIFT=keys2.K_SHIFT; +player[0].K_STRAFE=keys2.K_STRAFE; +player[0].K_RSTRAFE=keys2.K_RSTRAFE; +player[0].K_LSTRAFE=keys2.K_LSTRAFE; + +player[1].K_LEFT=keys1.K_LEFT; +player[1].K_RIGHT=keys1.K_RIGHT; +player[1].K_UP=keys1.K_UP; +player[1].K_DOWN=keys1.K_DOWN; +player[1].K_SHOOT=keys1.K_SHOOT; +player[1].K_SHIFT=keys1.K_SHIFT; +player[1].K_STRAFE=keys1.K_STRAFE; +player[1].K_RSTRAFE=keys1.K_RSTRAFE; +player[1].K_LSTRAFE=keys1.K_LSTRAFE; + +} + +} + +void alusta_players1(){ +int a,b; + +strcpy(player[0].name,name1); +strcpy(player[1].name,name2); +player[0].color=16*3; +player[1].color=16*9; + +for (b=0;b63) pan=63; +} + + MIDASplaySample(explowav,MIDAS_CHANNEL_AUTO,0,14000-(size*1000),EFFECT_VOLUME,pan); +} + +void list_files(int *no,vile *filelist,char *wildcard,int type){ + struct find_t fbuf; + int er; + er = _dos_findfirst(wildcard,type,&fbuf); + while (er==0){ + if ((fbuf.attrib&type) == type) + { + if (strcmp(fbuf.name,".") && strcmp(fbuf.name,"..")) + { + strcpy(filelist[*no].name,fbuf.name); + (*no)++; + } + } + er=_dos_findnext(&fbuf); + } + _dos_findclose(&fbuf); +} + +void set_keyb_rate() +{ + union REGS inregs; + inregs.h.ah=0x03; + inregs.h.al=0x05; + inregs.h.bh=0x00; // delay + inregs.h.bl=0x00; // rate + int386(0x16,&inregs,&inregs); +} diff --git a/BAK/MISCFUNC.H b/BAK/MISCFUNC.H new file mode 100644 index 0000000..882bc6c --- /dev/null +++ b/BAK/MISCFUNC.H @@ -0,0 +1,19 @@ +#ifndef __TK__MISCFUNC__ +#define __TK__MISCFUNC__ +void change_name(int num); +char *k_2_c(int key); +int get_key(int x,int y); +void clear_shit(int y); + +void set_keys(); +void alusta_players1(); +void alusta_players2(); +void two_to_one(); +void define_bullet_types(); +void define_effects(); +void explo(int x,int y,int size,Player *P,int index); +void list_files(int *no,vile *filelist,char *wildcard,int type); +void set_keyb_rate(); + +#endif + diff --git a/BAK/MISCFUNC.OBJ b/BAK/MISCFUNC.OBJ new file mode 100644 index 0000000..0fe9a38 Binary files /dev/null and b/BAK/MISCFUNC.OBJ differ diff --git a/BAK/NEWFUNCS.CPP b/BAK/NEWFUNCS.CPP new file mode 100644 index 0000000..51535ed --- /dev/null +++ b/BAK/NEWFUNCS.CPP @@ -0,0 +1,78 @@ +#include "defines.h" +#include "globvar.h" +#include "types.h" +#include "classes.h" + +void new_body_part(int x,int y,int angle,int speed,int num){ +int a=0; + +if (angle>=360) angle-=360; +if (angle<0) angle+=360; + +while (body_part[a].IN_USE && a=360) angle-=360; +if (angle<0) angle+=360; + +effect_age_count++; // can be large after 10 hour session :) + +while (effect[a].IN_USE && a=360) angle-=360; +if (angle<0) angle+=360; + +while (bullet[a].IN_USE && a +#include +#include +#include +#include + +#include "efp/efp.h" +#include "defines.h" +#include "types.h" +#include "globvar.h" +#include "miscfunc.h" +#include "fade.h" +#include "draw.h" +#include "write.h" + +extern void setup_ipx(); +extern void desetup_ipx(); +extern void game(); + +void save_options(){ +FILE *cfg; + +cfg=fopen("options.cfg","wb"); + +fwrite(&keys1,sizeof(class Keys),1,cfg); + +fwrite(&keys2,sizeof(class Keys),1,cfg); + +fwrite(name1,sizeof(name1),1,cfg); +fwrite(name2,sizeof(name2),1,cfg); + +fwrite(&DARK_MODE,sizeof(DARK_MODE),1,cfg); +fwrite(&LIGHT_EFFECTS,sizeof(LIGHT_EFFECTS),1,cfg); +fwrite(&SHADOWS,sizeof(SHADOWS),1,cfg); + +fwrite(&MUSIC_VOLUME,sizeof(MUSIC_VOLUME),1,cfg); +fwrite(&EFFECT_VOLUME,sizeof(EFFECT_VOLUME),1,cfg); + +fwrite(&ENEMIES_ON_GAME,sizeof(ENEMIES_ON_GAME),1,cfg); +fwrite(DEATH_MATCH_LEVEL,sizeof(DEATH_MATCH_LEVEL),1,cfg); +fwrite(&DEATH_MATCH_EPISODE,sizeof(DEATH_MATCH_EPISODE),1,cfg); +fwrite(&DEATH_MATCH_SPEED,sizeof(DEATH_MATCH_SPEED),1,cfg); + +fwrite(&KILLING_MODE,sizeof(KILLING_MODE),1,cfg); + +fclose(cfg); +} + +void load_options(){ +FILE *cfg; + +cfg=fopen("options.cfg","rb"); + +if (cfg){ + +fread(&keys1,sizeof(class Keys),1,cfg); + +fread(&keys2,sizeof(class Keys),1,cfg); + +fread(name1,sizeof(name1),1,cfg); +fread(name2,sizeof(name2),1,cfg); + +fread(&DARK_MODE,sizeof(DARK_MODE),1,cfg); +fread(&LIGHT_EFFECTS,sizeof(LIGHT_EFFECTS),1,cfg); +fread(&SHADOWS,sizeof(SHADOWS),1,cfg); + +fread(&MUSIC_VOLUME,sizeof(MUSIC_VOLUME),1,cfg); +fread(&EFFECT_VOLUME,sizeof(EFFECT_VOLUME),1,cfg); + +fread(&ENEMIES_ON_GAME,sizeof(ENEMIES_ON_GAME),1,cfg); +fread(DEATH_MATCH_LEVEL,sizeof(DEATH_MATCH_LEVEL),1,cfg); +fread(&DEATH_MATCH_EPISODE,sizeof(DEATH_MATCH_EPISODE),1,cfg); +fread(&DEATH_MATCH_SPEED,sizeof(DEATH_MATCH_SPEED),1,cfg); + +fread(&KILLING_MODE,sizeof(KILLING_MODE),1,cfg); + +fclose(cfg); + +} + +} + +int choose_load_file(char *name,int episode){ + +int a,b,sel=0,pos=0,cnt=0,oclock=0; +int files=files_in_episode[episode]; + +load_efp("efps\\cool.efp",picture,0); + +draw_box1(60,10,320-60,190,15); + +first=1; + +while (! k.state[1] && ! k.state[28]){ + +memcpy(virbuff,picture,64000); + +FONT_NUM=0; + +writefonts2(160-(str_length("select level:")>>1),20,"select level:",1); + +b=files; +if (b>15) b=15; + +FONT_NUM=1; + +for (a=0;a>1),50+a*8,strlwr(filelist[episode][a+pos].name),M_YELLOW); + else + writefonts(160-(str_length(strlwr(filelist[episode][a+pos].name))>>1),50+a*8,strlwr(filelist[episode][a+pos].name),M_BLUE); + + if (pos>0) writefonts(156,42,"",M_BLUE); + if (files>15) if (pos23) cnt=0; + } + + if (k.state[94]) {if (sel>0) sel--; k.state[94]=0; } + if (k.state[99]) {if (sel15) if (pos>files-15) pos=files-15; + if (files<=15) if (pos>0) pos=0; + +} + +a=0; + +strcpy(name,filelist[episode][sel].name);a=1;k.state[28]=0; + +return(a); +} + +int choose_episode(){ + +int a,b,sel=0,pos=0,cnt=0,oclock=0; +char text[20]; + +load_efp("efps\\cool.efp",picture,0); +draw_box1(60,10,320-60,190,15); +first=1; + +k.state[1]=0; +k.state[28]=0; + +fadeout(virbuff,pal); + +while (! k.state[1] && ! k.state[28]){ + +memcpy(virbuff,picture,64000); + +FONT_NUM=0; + +writefonts2(160-(str_length("select episode")>>1),20,"select episode",1); + +b=dirs; +if (b>7) b=7; + +for (a=0;a>1),50+a*16,strlwr(dirlist[a+pos].name),1); +} else { + FONT_NUM=2; + writefonts2(160-(str_length(strlwr(dirlist[a+pos].name))>>1),50+a*16,strlwr(dirlist[a+pos].name),1); +} +} + +FONT_NUM=1; + itoa(files_in_episode[sel+1],text,10); + strcat(text," levels"); + writefonts(70,175,text,M_BLUE); + +if (first==1) {fadein(virbuff,pal);first=0;} +memcpy(screen,virbuff,64000); + +while(! k.state[94] && ! k.state[99] && ! k.state[28]) + + if (clock()!=oclock){ + oclock=clock(); + draw_ball(65,48+((sel-pos)*16),cnt); + draw_ball(320-85,48+((sel-pos)*16),cnt); + cnt++; + if (cnt>23) cnt=0; + } + + if (k.state[94]) {if (sel>0) sel--; k.state[94]=0; } + if (k.state[99]) {if (sel7) if (pos>dirs-7) pos=dirs-7; + if (dirs<=7) if (pos>0) pos=0; + +} + +k.state[28]=0; + +return(sel); +} + + +void options_scr(int opt,char *filename){ + +load_efp(filename,picture,0); +load_efp_pal("efps\\ware.efp",pal); +draw_box1(45,90-((opt*15)/2),320-45,110+((opt*15)/2),13); + +first=1; +} + +void multip_options_scr(int opt,char *filename){ + +load_efp(filename,picture,0); +load_efp_pal("efps\\ware.efp",pal); +draw_box1(10,90-((opt*15)/2),320-10,110+((opt*15)/2),13); + +first=1; +} + +void player_options(){ +int yoffs=(15*num_player_options)/2,a,cnt=0,selected=0,quit=0,oclock; + +fadeout(virbuff,pal); + +options_scr(num_player_options,"efps\\cool.efp"); + +k.state[28]=0; + +while(! quit){ +memcpy(virbuff,picture,64000); + +for (a=0;a23) cnt=0; + } + + }; + + MIDASplaySample(klikwav,MIDAS_CHANNEL_AUTO,0,22500,EFFECT_VOLUME,MIDAS_PAN_MIDDLE); + + if (k.state[94]) {selected--;if (selected<0) selected=num_player_options-1;k.state[94]=0;} + if (k.state[99]) {selected++;if (selected>=num_player_options) selected=0;k.state[99]=0;} + if (k.state[28]) { + if (selected==0) {keys1.change();options_scr(num_player_options,"efps\\cool.efp");} + if (selected==1) {keys2.change();options_scr(num_player_options,"efps\\cool.efp");} + if (selected==2) {change_name(1);options_scr(num_player_options,"efps\\cool.efp");} + if (selected==3) {change_name(2);options_scr(num_player_options,"efps\\cool.efp");} + if (selected==4) {quit=1;} + } + if (k.state[1]) {quit=1; k.state[1]=0;} +} + +fadeout(virbuff,pal); + +} + +void game_options(){ + +int yoffs=(15*num_game_options)/2,a,cnt=0,selected=0,quit=0,oclock; + +fadeout(virbuff,pal); +options_scr(num_game_options,"efps\\cool.efp"); +k.state[28]=0; + +while(! quit){ +memcpy(virbuff,picture,64000); + +if (DARK_MODE) game_opt_text[0]=strdup("darkness on"); +if (! DARK_MODE) game_opt_text[0]=strdup("darkness off"); +if (LIGHT_EFFECTS) game_opt_text[1]=strdup("lights on"); +if (! LIGHT_EFFECTS) game_opt_text[1]=strdup("lights off"); +if (SHADOWS) game_opt_text[2]=strdup("shadows on"); +if (! SHADOWS) game_opt_text[2]=strdup("shadows off"); + +for (a=0;a23) cnt=0; + } + + }; + + MIDASplaySample(klikwav,MIDAS_CHANNEL_AUTO,0,22500,EFFECT_VOLUME,MIDAS_PAN_MIDDLE); + + if (k.state[94]) {selected--;if (selected<0) selected=num_game_options-1;k.state[94]=0;} + if (k.state[99]) {selected++;if (selected>=num_game_options) selected=0;k.state[99]=0;} + if (k.state[28]) { + if (selected==0) {if (! DARK_MODE) DARK_MODE=1; else DARK_MODE=0; k.state[28]=0;} + if (selected==1) {if (! LIGHT_EFFECTS) LIGHT_EFFECTS=1; else LIGHT_EFFECTS=0; k.state[28]=0;} + if (selected==2) {if (! SHADOWS) SHADOWS=1; else SHADOWS=0; k.state[28]=0;} + if (selected==3) {quit=1;} + } + if (k.state[1]) {quit=1; k.state[1]=0;} +} + +fadeout(virbuff,pal); +} + +void sound_options(){ + +int yoffs=(15*num_sound_options)/2,a,cnt=0,selected=0,quit=0,oclock; +char text[30],text2[30]; + +fadeout(virbuff,pal); + +options_scr(num_sound_options,"efps\\subbari.efp"); + +k.state[28]=0; + +while(! quit){ +memcpy(virbuff,picture,64000); + +strcpy(text,"music volume "); +itoa((float)MUSIC_VOLUME/63*100,text2,10); +strcat(text2,"%"); +strcat(text,text2); +sound_opt_text[0]=strdup(text); + +strcpy(text,"effect volume "); +itoa((float)EFFECT_VOLUME/63*100,text2,10); +strcat(text2,"%"); +strcat(text,text2); +sound_opt_text[1]=strdup(text); + +for (a=0;a23) cnt=0; + } + + } + + MIDASplaySample(klikwav,MIDAS_CHANNEL_AUTO,0,22500,EFFECT_VOLUME,MIDAS_PAN_MIDDLE); + + if (k.state[94]) {selected--;if (selected<0) selected=num_sound_options-1;k.state[94]=0;} + if (k.state[99]) {selected++;if (selected>=num_sound_options) selected=0;k.state[99]=0;} + if (k.state[96]) { + if (selected==0) MUSIC_VOLUME-=5; + if (selected==1) EFFECT_VOLUME-=5; + if (MUSIC_VOLUME<0) MUSIC_VOLUME=0; + if (EFFECT_VOLUME<0) EFFECT_VOLUME=0; + if (selected==0) MIDASsetMusicVolume(ph,MUSIC_VOLUME); + k.state[96]=0; + } + if (k.state[97]) { + if (selected==0) MUSIC_VOLUME+=5; + if (selected==1) EFFECT_VOLUME+=5; + if (MUSIC_VOLUME>63) MUSIC_VOLUME=63; + if (EFFECT_VOLUME>63) EFFECT_VOLUME=63; + if (selected==0) MIDASsetMusicVolume(ph,MUSIC_VOLUME); + k.state[97]=0; + } + if (k.state[28]) if (selected==2) {quit=1;} + if (k.state[1]) {quit=1; k.state[1]=0;} +} + +fadeout(virbuff,pal); +} + + +void deathmatch_options(){ + +int yoffs=(15*num_deathmatch_options)/2,a,cnt=0,selected=0,quit=0,oclock; + +fadeout(virbuff,pal); + +options_scr(num_deathmatch_options,"efps\\cool.efp"); + +k.state[28]=0; + +while(! quit){ +memcpy(virbuff,picture,64000); + +if (DEATH_MATCH_SPEED==2) +deathmatch_opt_text[0]=strdup("normal moving"); +else +deathmatch_opt_text[0]=strdup("fast moving"); + +if (ENEMIES_ON_GAME) +deathmatch_opt_text[1]=strdup("enemies on"); +else +deathmatch_opt_text[1]=strdup("enemies off"); + +for (a=0;a23) cnt=0; + } + + }; + + MIDASplaySample(klikwav,MIDAS_CHANNEL_AUTO,0,22500,EFFECT_VOLUME,MIDAS_PAN_MIDDLE); + + if (k.state[94]) {selected--;if (selected<0) selected=num_deathmatch_options-1;k.state[94]=0;} + if (k.state[99]) {selected++;if (selected>=num_deathmatch_options) selected=0;k.state[99]=0;} + if (k.state[28]) { + k.state[28]=0; + if (selected==0) if (DEATH_MATCH_SPEED==2) DEATH_MATCH_SPEED=3; else DEATH_MATCH_SPEED=2; + if (selected==1) if (ENEMIES_ON_GAME) ENEMIES_ON_GAME=0; else ENEMIES_ON_GAME=1; + if (selected==2) {quit=1;} + } + if (k.state[1]) {quit=1; k.state[1]=0;} +} + +fadeout(virbuff,pal); +} + +void multiplayer_options() +{ + int yoffs=(15*num_multip_options)/2,a,cnt=0,selected=0,quit=0,oclock; + int dontfade=0; + char text[50]; + + fadeout(virbuff,pal); + multip_options_scr(num_multip_options,"efps\\cool.efp"); + + k.state[28]=0; + GAME_MODE=1; + + while(! quit) + { + memcpy(virbuff,picture,64000); + if (KILLING_MODE==COOPERATIVE && DEATH_MATCH_EPISODE==0) + { + DEATH_MATCH_EPISODE=1; + strcpy(DEATH_MATCH_LEVEL,strlwr(filelist[DEATH_MATCH_EPISODE][0].name)); + } + strcpy(text,"episode: "); + if (DEATH_MATCH_EPISODE>0) strcat(text,strlwr(dirlist[DEATH_MATCH_EPISODE-1].name)); + else strcat(text,"dm levels"); + multip_opt_text[2]=strdup(text); + strcpy(text,"level: "); + if (KILLING_MODE==DEATHMATCH) + strcat(text,DEATH_MATCH_LEVEL); + multip_opt_text[3]=strdup(text); + strcpy(text,"game type: "); + if (GAME_MODE==SPLIT_SCREEN) + strcat(text,"split screen"); + if (GAME_MODE==NETWORK) + strcat(text,"network"); + multip_opt_text[4]=strdup(text); + strcpy(text,"game mode: "); + if (KILLING_MODE==COOPERATIVE) + strcat(text,"cooperative"); + if (KILLING_MODE==DEATHMATCH) + strcat(text,"deathmatch"); + multip_opt_text[5]=strdup(text); + + for (a=0;a23) cnt=0; + } + }; + MIDASplaySample(klikwav,MIDAS_CHANNEL_AUTO,0,22500,EFFECT_VOLUME,MIDAS_PAN_MIDDLE); + if (k.state[94]) {selected--;if (selected<0) selected=num_multip_options-1;k.state[94]=0;} + if (k.state[99]) {selected++;if (selected>=num_multip_options) selected=0;k.state[99]=0;} + if (k.state[28]) + { + k.state[28]=0; + if (selected==0) + { + NETWORK_MODE=SERVER; + set_keys(); + if (GAME_MODE==NETWORK) setup_ipx(); + game(); + if (GAME_MODE==NETWORK) desetup_ipx(); + quit=1; + dontfade=1; + } + if (selected==1) + { + GAME_MODE=NETWORK; + NETWORK_MODE=CLIENT; + set_keys(); + setup_ipx(); + // selectgame(); + game(); + desetup_ipx(); + quit=1; + dontfade=1; + } + if (selected==2) {DEATH_MATCH_EPISODE++;if (DEATH_MATCH_EPISODE>dirs) DEATH_MATCH_EPISODE=0;strcpy(DEATH_MATCH_LEVEL,strlwr(filelist[DEATH_MATCH_EPISODE][0].name));} + if (selected==3) if (KILLING_MODE==DEATHMATCH) {choose_load_file(DEATH_MATCH_LEVEL,DEATH_MATCH_EPISODE);multip_options_scr(num_multip_options,"efps\\cool.efp"); } + if (selected==4) {GAME_MODE++;if (GAME_MODE>2) GAME_MODE=1;} + if (selected==5) {KILLING_MODE++;if (KILLING_MODE>1) KILLING_MODE=0;} + if (selected==6) {quit=1;} + } + if (k.state[1]) {quit=1; k.state[1]=0;} + } + if (! dontfade) fadeout(virbuff,pal); + save_options(); +} + +void options(){ + +int yoffs=(15*num_options)/2,a,cnt=0,selected=0,quit=0,oclock; + +fadeout(virbuff,pal); + +options_scr(num_options,"efps\\cool.efp"); + +k.state[28]=0; + +while(! quit){ +memcpy(virbuff,picture,64000); + +for (a=0;a23) cnt=0; + } + + }; + + MIDASplaySample(klikwav,MIDAS_CHANNEL_AUTO,0,22500,EFFECT_VOLUME,MIDAS_PAN_MIDDLE); + + if (k.state[94]) {selected--;if (selected<0) selected=num_options-1;k.state[94]=0;} + if (k.state[99]) {selected++;if (selected>=num_options) selected=0;k.state[99]=0;} + if (k.state[28]) { + if (selected==0) {player_options();options_scr(num_options,"efps\\cool.efp");} + if (selected==1) {game_options();options_scr(num_options,"efps\\cool.efp");} + if (selected==2) {sound_options();options_scr(num_options,"efps\\cool.efp");} + if (selected==3) {deathmatch_options();options_scr(num_options,"efps\\cool.efp");} + if (selected==4) {quit=1;} + } + if (k.state[1]) {quit=1; k.state[1]=0;} +} + +save_options(); + +fadeout(virbuff,pal); + +} diff --git a/BAK/OPTIONS.H b/BAK/OPTIONS.H new file mode 100644 index 0000000..27517ab --- /dev/null +++ b/BAK/OPTIONS.H @@ -0,0 +1,17 @@ +#ifndef __TK___OPTIONS__ +#define __TK___OPTIONS__ + +void save_options(); +void load_options(); +int choose_episode(); +int choose_load_file(char *name,int episode); +void options_scr(int opt,char *filename); +void multip_options_scr(int opt,char *filename); +void player_options(); +void game_options(); +void sound_options(); +void deathmatch_options(); +void multiplayer_options(); +void options(); + +#endif diff --git a/BAK/OPTIONS.OBJ b/BAK/OPTIONS.OBJ new file mode 100644 index 0000000..b3221ab Binary files /dev/null and b/BAK/OPTIONS.OBJ differ diff --git a/BAK/RGBHSL.C b/BAK/RGBHSL.C new file mode 100644 index 0000000..df278ac --- /dev/null +++ b/BAK/RGBHSL.C @@ -0,0 +1,76 @@ +#include + +#define max(a,b) (a>b?a:b) +#define min(a,b) (a 1 ) h -= 1.0; + if( 6.0*h < 1 ) + return (m1+(m2-m1)*h*6.0); + if( 2.0*h < 1 ) + return m2; + if( 3.0*h < 2.0 ) + return (m1+(m2-m1)*((2.0/3.0)-h)*6.0); + return m1; +} + +void hsl2rgb(float H, float S, float L,float *R,float *G,float *B) +{ + float m1, m2; + + if(S==0) { + *R=*G=*B=L; + } else { + if(L <=0.5) + m2 = L*(1.0+S); + else + m2 = L+S-L*S; + m1 = 2.0*L-m2; + *R = HuetoRGB(m1,m2,H+1.0/3.0); + *G = HuetoRGB(m1,m2,H); + *B = HuetoRGB(m1,m2,H-1.0/3.0); + } + + *R*=63; + *G*=63; + *B*=63; + +} diff --git a/BAK/RGBHSL.H b/BAK/RGBHSL.H new file mode 100644 index 0000000..b30a1ec --- /dev/null +++ b/BAK/RGBHSL.H @@ -0,0 +1,11 @@ +#ifndef __RGBHSL__H_ +#define __RGBHSL__H_ + +extern "C" +{ +void rgb2hsl(float r,float g,float b, float *H, float *S,float *L ); +static float HuetoRGB(float m1, float m2, float h ); +void hsl2rgb(float H, float S, float L,float *R,float *G,float *B); +} + +#endif diff --git a/BAK/RGBHSL.OBJ b/BAK/RGBHSL.OBJ new file mode 100644 index 0000000..597708c Binary files /dev/null and b/BAK/RGBHSL.OBJ differ diff --git a/BAK/ROUT.CPP b/BAK/ROUT.CPP new file mode 100644 index 0000000..5710bf8 --- /dev/null +++ b/BAK/ROUT.CPP @@ -0,0 +1,65 @@ +#include < math.h > +#include < conio.h > +#include < stdlib.h > +#include < stdio.h > +#include < i86.h > +#include < string.h > +#include "defines.h" +#include "globvar.h" +int get_dist( int x1, int y1, int x2, int y2 ) +{ + int xs, ys, dist; + xs = x1 - x2; + ys = y1 - y2; + dist = sqrt( ( xs*xs ) + ( ys*ys ) ); + return( dist ); +} +int get_angle( int x, int y, int x2, int y2 ) +{ + int s1, s2, ang; + float jako; + s1 = x - x2; + s2 = y - y2; + if ( s1!= 0 ) + { + jako = ( float ) ( s2 ) /( float ) ( s1 ); + ang = atan( jako ) *360/2/pi; + if ( x > x2 ) ang = ang + 180; + } + if ( s1 == 0 ) + { + if ( y < y2 ) ang = 90; + if ( y > y2 ) ang = 270; + } + return( ang ); +} +void pre_count() +{ + int a; + for ( a = 0; a < 360; a ++ ) + { + sini[a] = sin( ( float ) a/360*2*pi ); + cosi[a] = cos( ( float ) a/360*2*pi ); + } +} +void randomize() +{ + union REGS regs; + regs.h.ah = 0x2c; + int386( 0x21, ®s, ®s ); + srand( regs.h.dl + regs.h.dh*100 + regs.h.cl*6000 + regs.h.ch*36000 ); +} +char *c_2_c( int aika ) +{ + int min, sec; + char text[10], text2[10], *t; + min = aika/60; + sec = aika%60; + itoa( min, text, 10 ); + itoa( sec, text2, 10 ); + strcat( text, ":" ); + if ( sec < 10 ) strcat( text, "0" ); + strcat( text, text2 ); + t = strdup( text ); + return( t ); +} diff --git a/BAK/ROUT.H b/BAK/ROUT.H new file mode 100644 index 0000000..41912dd --- /dev/null +++ b/BAK/ROUT.H @@ -0,0 +1,10 @@ +#ifndef __TK__ROUT__ +#define __TK__ROUT__ + +int get_dist(int x1,int y1,int x2,int y2); +int get_angle(int x,int y,int x2,int y2); +void pre_count(); +void randomize(); +char *c_2_c(int aika); + +#endif diff --git a/BAK/ROUT.OBJ b/BAK/ROUT.OBJ new file mode 100644 index 0000000..a12897f Binary files /dev/null and b/BAK/ROUT.OBJ differ diff --git a/BAK/SETUP/SETUP.CPP b/BAK/SETUP/SETUP.CPP new file mode 100644 index 0000000..8c959a8 --- /dev/null +++ b/BAK/SETUP/SETUP.CPP @@ -0,0 +1,25 @@ +#include +#include +#include +#include +#include + +#pragma library ("midas.lib") + + +void vmode(short); +#pragma aux vmode=\ + "int 10h",\ + parm [ax] modify[ax] + +main() { + if (MIDASstartup()) + if (MIDASconfig()){ + vmode(0x3); + if (MIDASsaveConfig("SOUND.CFG")) cout<<"Configuration saved !"<<"\n"; + +} + +} + + diff --git a/BAK/SETUP/SETUP.OBJ b/BAK/SETUP/SETUP.OBJ new file mode 100644 index 0000000..f817158 Binary files /dev/null and b/BAK/SETUP/SETUP.OBJ differ diff --git a/BAK/SHOP.H b/BAK/SHOP.H new file mode 100644 index 0000000..23e4674 --- /dev/null +++ b/BAK/SHOP.H @@ -0,0 +1,250 @@ +#define OTHER_STUFF 2 + +void draw_wares(int row,int colu){ +int a; + + for (a=0;ashield*15,text,10); + writefonts(20+str_length("Cost: "),70,text,M_YELLOW); + writefonts(20,80,"Sell price:",M_BLUE); + a=P->shield-1; if (a<0) a=0; + itoa(sell_price[DIFF_WEAPONS]+((a*15)>>1),text,10); + writefonts(20+str_length("Sell_price: "),80,text,M_YELLOW); + } + if (sel2==1){ + writefonts(20,50,"Target system",M_YELLOW); + writefonts(20,70,"Cost:",M_BLUE); + itoa(target_cost,text,10); + writefonts(20+str_length("Cost: "),70,text,M_YELLOW); + writefonts(20,80,"Sell price:",M_BLUE); + itoa(sell_price[DIFF_WEAPONS+1],text,10); + writefonts(20+str_length("Sell_price: "),80,text,M_YELLOW); + } +} + +} + +void Player::shop(){ + +int a,sx,sel1=0,sel2=0,quit=0,x; +char text[20]; + +load_efp("efps\\shop.efp",picture,0); + +for (a=0;a<17;a++){ +draw_box1(9+a*18,130,25+a*18,130+16,8); +draw_box1(9+a*18,130+18,25+a*18,130+16+18,8); +draw_box1(9+a*18,130+18+18,25+a*18,130+16+18+18,8); +} + +draw_box1(115,7,205,27,13); +draw_box1(10,10,80,33,13); +draw_box1(10,40,230,113,13); + +FONT_NUM=0; + +sx=160-(str_length("the shop")/2); + +first=1; + +shield_data.max=30; + +while (! quit){ + +memcpy(virbuff,picture,64000); + +FONT_NUM=0; + +writefonts2(sx,10,"the shop",1); + +FONT_NUM=1; + + writefonts(10,190,"Press FIRE to buy, CHANGE to sell, ESC to exit",M_BLUE); + + writefonts(15,12,name,M_YELLOW); + itoa(cash,text,10); + writefonts(15,20,"Cash:",M_RED); + writefonts(40,20,text,M_YELLOW); + +draw_wares(sel1,sel2); +draw_ware_info(this,sel1,sel2); + +FONT_NUM=3; + +for (a=0;a0){ + x=bullets[a]/bullet_type[a+1].mul; + if (x<1) x=1; + itoa(x,text,10); + writefonts(8+a*18,131+11+18,text,0); + writefonts(9+a*18,130+11+18,text,M_YELLOW); + } + +if (shield>0){ + itoa(shield,text,10); + writefonts(8,131+11+18+18,text,0); + writefonts(9,130+11+18+18,text,M_YELLOW); +} + +if (TARGET==1){ + writefonts(8+18,131+11+18+18,"1",0); + writefonts(9+18,130+11+18+18,"1",M_YELLOW); +} + +if (! first) memcpy(screen,virbuff,64000); + +if (first==1){ + fadein(virbuff,pal); + first=0; +} + +while (! k.state[1] && + ! k.state[K_LEFT] && + ! k.state[K_RIGHT] && + ! k.state[K_UP] && + ! k.state[K_DOWN] && + ! k.state[K_SHOOT] && + ! k.state[K_SHIFT] ); + +if (k.state[K_UP]) if (sel1>0) sel1--; +if (k.state[K_DOWN]) if (sel1<2) sel1++; +if (k.state[K_LEFT]) sel2--; +if (k.state[K_RIGHT]) sel2++; +if (sel2<0) sel2=0; + if (sel1==0) if (sel2>=DIFF_WEAPONS) sel2=DIFF_WEAPONS-1; + if (sel1==1) if (sel2>=DIFF_BULLETS) sel2=DIFF_BULLETS-1; + if (sel1==2) if (sel2>=OTHER_STUFF) sel2=OTHER_STUFF-1; + +if (k.state[K_SHOOT]){ + if (sel1==0) + if (weapons[sel2+1]==0) + if (cash>=weapon[sel2+1].cost){ + weapons[sel2+1]=1; + cash-=weapon[sel2+1].cost; + } + if (sel1==1) + if (bullets[sel2]=bullet_type[sel2+1].cost){ + bullets[sel2]+=bullet_type[sel2+1].mul; + cash-=bullet_type[sel2+1].cost; + } + if (sel1==2){ + if (sel2==0) + if (cash>=shield_data.cost+shield*15) + if (shield=target_cost) + { + TARGET=1; + cash-=target_cost; + } + } + } + +if (k.state[K_SHIFT]){ + if (sel1==0) + if (weapons[sel2+1]>0){ + weapons[sel2+1]=0; + cash+=sell_price[sel2]; + } + if (sel1==1) + if (bullets[sel2]>0){ + bullets[sel2]-=bullet_type[sel2+1].mul; + if (bullets[sel2]<0) bullets[sel2]=0; + cash+=bullet_type[sel2+1].cost; + } + if (sel1==2){ + if (sel2==0) + if (shield>0) + { + a=shield-1;if (a<0) a=0; + cash+=sell_price[DIFF_WEAPONS]+((15*a)/2); + shield--; + } + if (sel2==1) + if (TARGET==1) + { + TARGET=0; + cash+=sell_price[DIFF_WEAPONS+1]; + } + } + } + +k.state[K_UP]=0; +k.state[K_DOWN]=0; +k.state[K_LEFT]=0; +k.state[K_RIGHT]=0; +k.state[K_SHOOT]=0; +k.state[K_SHIFT]=0; + + MIDASplaySample(klikwav,MIDAS_CHANNEL_AUTO,0,22000,EFFECT_VOLUME,MIDAS_PAN_MIDDLE); + + if (k.state[1]) { + FONT_NUM=0; + writefonts2(10,115,"press fire to confirm",1); + memcpy(screen,virbuff,64000); + k.clear_stack(); + while (! k.kbhit()) ; + if (k.state[K_SHOOT]) quit=1; + k.state[1]=0; } +} + +fadeout(virbuff,pal); +} + diff --git a/BAK/TK.LNK b/BAK/TK.LNK new file mode 100644 index 0000000..a601d0b --- /dev/null +++ b/BAK/TK.LNK @@ -0,0 +1,5 @@ +system dos4g +file game,error,efp,ipx,int,rgbhsl,globvar,miscfunc,draw,fade,write,classes,rout,newfuncs,options +library midas.lib +name ..\game + diff --git a/BAK/TYPES.H b/BAK/TYPES.H new file mode 100644 index 0000000..ef0b6e4 --- /dev/null +++ b/BAK/TYPES.H @@ -0,0 +1,54 @@ +#ifndef __TK__TYPES__ +#define __TK__TYPES__ + +#include + +struct special +{ + int num; + char text[15]; +}; + +struct BLOCK +{ + int type; + int num; + int shadow; +}; + +struct s +{ + char *name; + int cost; + int max; +}; + +struct WEapon{ + char *name; + int cost; + int loading_time; + int smoke; + int bullet_amount; + int angle_add; + int gun; + int btype; + MIDASsample *sound; +}; + +struct juu +{ + char name[15]; + char *spr; + int speed; + int curr_weapon; + int energy; + int reward; +}; + +struct vile{ + char name[13]; +}; + + + +#endif diff --git a/BAK/UNIC_3X.S3M b/BAK/UNIC_3X.S3M new file mode 100644 index 0000000..8795118 Binary files /dev/null and b/BAK/UNIC_3X.S3M differ diff --git a/BAK/WRITE.CPP b/BAK/WRITE.CPP new file mode 100644 index 0000000..cd07e9c --- /dev/null +++ b/BAK/WRITE.CPP @@ -0,0 +1,188 @@ +#include "globvar.h" +#include +#include +#include + +void pixeli(int x,int y,char col){ + virbuff[(y<<8)+(y<<6)+x]=col; +} + +void loadfonts(char *name){ + FILE *fnt; + int a; + + fnt=fopen(name,"rb"); + + f_x_size[FONT_NUM]=fgetc(fnt); + f_y_size[FONT_NUM]=fgetc(fnt); + + thefonts[FONT_NUM]=(char *)malloc(f_y_size[FONT_NUM]*f_x_size[FONT_NUM]*256); + + fseek(fnt,256*2,0); + + for (a=0;a1) col=2; + if (col<2) c++; + } + xpos1=c; + + c=f_x_size[FONT_NUM]; + col=0; + while (col<2 & c>0){ // check from right + for (d=0;d1) col=2; + if (col<2) c--; + } + xpos2=c; + + if (xpos1>xpos2){ xpos1=0; xpos2=f_x_size[FONT_NUM]/2; + } + + x1=xpos1-1; if (x1<0) x1=0; + x2=xpos2+1; if (x2>f_x_size[FONT_NUM]) x2=f_x_size[FONT_NUM]; + + for( d=0;d=0) if (px<320) if (py>=0) if (py0){ // check from right + for (d=0;dxpos2){ xpos1=0; xpos2=f_x_size[FONT_NUM]/2; + } + + for( d=0;d1) col=2; + if (col<2) c++; + }; + xpos1=c; + + c=f_x_size[FONT_NUM]; + col=0; + while (col<2 && c>0){ // check from right + for (d=0;d1) col=2; + if (col<2) c--; + }; + xpos2=c; + +if (xpos1>xpos2){ xpos1=0; xpos2=f_x_size[FONT_NUM]/2; } + + length+=xpos2-xpos1+1; + } + +return(length); +} + +void readline(int x,int y,int len,char *str,char *screen){ + + int done=0,a,dy; + char *bg; + int key; + + bg=(char*)malloc(320*f_y_size[FONT_NUM]); + memcpy(bg,screen+x+(y*320),320*f_y_size[FONT_NUM]); + + while (!done){ + writefonts2(x,y,str,1); + + for (dy=0;dy0) + str[strlen(str)-1]=0; + a=str_length(str)+x; + for (dy=0;dy +#include +#include +#include +#include + +#include "ipx.c" // More ipx code.. + +#define SERVER 1 +#define CLIENT 0 +#define SOCKET 0x869c // DOOM Socket +#define RECEIVERS 10 + +#define IPX_END 0 +#define IPX_SERVERSEARCH 1 +#define IPX_TEXTMESSAGE 2 + +int mode; +char str[255]; + +struct packet far *send,far *rec[RECEIVERS]; +unsigned short sendl,sendseg,recl[RECEIVERS],recseg[RECEIVERS]; + +void init_memory() +{ int a; + send=(struct packet far *)MK_FP(getlowmem(sizeof(struct packet)/16+1),0); + sendl=lsel; + sendseg=lseg; + initsendpacket(send,sendseg); + + for (a=0;a>4]; + str[1]=hex[ch&0xf]; +} + +char *decode_localaddress(char *str,struct localaddr far *la) +{ int a; + + for (a=0;a<4;a++) + char2hex(str+(a*2),la->network[a]); + str[8]=':'; + + for (a=0;a<6;a++) + char2hex(str+(a*2)+9,la->node[a]); + str[21]=0; + return(str); +} + +char *decode_address(char *str,struct netaddress far *la) +{ int a; + for (a=0;a<6;a++) + char2hex(str+(a*2),la->node[a]); + str[12]=0; + return(str); +} + +askserver() +{ + send->data[0]=IPX_SERVERSEARCH; + send->data[1]=IPX_END; + sendpacket(sendseg,MAXNODES,send,10); +} + +sendtext(char *string) +{ int a,l; + + l=strlen(string); + send->data[0]=IPX_TEXTMESSAGE; + for (a=0;adata[a+1]=string[a]; + send->data[l+1]=IPX_END; + sendpacket(sendseg,MAXNODES,send,l+2); +} + +clientloop() +{ + askserver(); + sendtext("Allu on mulukku"); + sendtext("Allu on mulukku2"); + sendtext("Allu on mulukku5"); +// waitserver(); +} + +serverloop() +{ int a; + int quit; + int data,ofs; + + quit=0; + while (kbhit()) getch(); + while (!quit) + for (a=0;aecb.inuse==0) + { + data=-1; + ofs=0; + while(data!=IPX_END) + { + data=rec[a]->data[ofs++]; + switch (data) + { + case IPX_SERVERSEARCH: + printf("Search request received from %s\n",decode_address(str,&(rec[a]->ipx.src))); + break; + case IPX_TEXTMESSAGE: + while ((data=rec[a]->data[ofs++])!=0) + putch(data); + printf("\n"); + break; + case IPX_END: + break; + default:printf("unknown command %d\n",data,data,data); + }; + + } + listenforpacket(recseg[a]); + } + else if (kbhit()) quit=1; +} + + +main(int argc, char *argv[]) +{ + argv=argv; + if (argc>1) mode=SERVER; + else mode=CLIENT; + + initipx(); // initialize the ipx routines. + + if (!opensocket(0,SOCKET)) + { + init_memory(); + printf("SocketID = %x\n",(dword)socketid); + getlocaladdress(); + printf("Local address: %s\n",decode_localaddress(str,localadd)); + + if (mode==SERVER) serverloop(); + else clientloop(); + + // Closing down IPX... + printf("Done.\n"); + closesocket(socketid); + } + else + { + printf("Unable to open socket (%x)!",(dword)SOCKET); + exit(0); + } +} diff --git a/SRC/CLASSES.BAK b/SRC/CLASSES.BAK new file mode 100644 index 0000000..6b2aade --- /dev/null +++ b/SRC/CLASSES.BAK @@ -0,0 +1,1425 @@ +#include < iostream.h > +#include < string.h > +#include < stdio.h > +#include < midasdll.h > +#include < math.h > +#include < stdlib.h > +#include < vesa.h > +#include < gfunc.h > +#include "error/error.h" +#include "defines.h" +#include "globvar.h" +#include "classes.h" +#include "rout.h" +#include "newfuncs.h" +#include "miscfunc.h" +#include "write.h" +#include "draw.h" +#include "efp/efp.h" +#include "fade.h" + +int ktexts=8; +char killtexts[][MAX_MESSAGE_LENGTH-20]= +{ "%s slaughtered %s.", + "%s killed %s.", + "%s punished %s.", + "%s didn't like %s.", + "%s made %s leave..", + "%s cleaned %s.", + "%s massacred %s.", + "%s shot %s." +}; + +int stexts=5; +char suicidetexts[][MAX_MESSAGE_LENGTH-20]= +{ "%s had to go...", + "%s got bored.", + "%s had problems.", + "%s shot himself.", + "%s ain't EF..." +}; + + + +extern void sendipx(int, int, ... ); + +void Message_board::add_message(char msg[]) +{ + int a; + msg[MAX_MESSAGE_LENGTH-1]=NULL; + + if (messages0) time_count--; else clear(); + for (a=0;a 15 ) pow = 15; + if ( pow < 0 ) pow = 0; + data[offs] = ( char ) pow; + } +} + +void Crate::move_text() +{ + if ( text_count > 0 ) + { + text_x += cosi[text_angle]*4; + text_y += sini[text_angle]*4; + text_count -= 4; + if ( text_count <= 0 ) + { + IN_USE = 0; if ( KILLING_MODE == DEATHMATCH ) wake_up_count = 1; + } + } +} + +void Crate::chk_wake_up(int qwe) +{ int a; + + if ( wake_up_count > 0 ) + { + wake_up_count ++; + if ( wake_up_count >= CRATE_WAKE_UP_COUNT ) + { + new_effect( &normal_l, TELEPORT, x + 8, y + 8, 0, 0 ); + text_count = 0; IN_USE = 1; wake_up_count = 0; + if (GAME_MODE==NETWORK) + { + for(a=1;a body_part[a].x ) + if ( x + 14 < body_part[a].x + 20 ) + if ( y + 14 > body_part[a].y ) + if ( y + 14 < body_part[a].y + 20 ) + { + KICK = 1; + ang = ( rangle2 - 5 ) + ( rand() % 10 ); + if ( ang < 0 ) ang += 360; + if ( ang >= 360 ) ang -= 360; + body_part[a].angle = ang; + body_part[a].speed = 6; + MIDASplaySample( hitwav, MIDAS_CHANNEL_AUTO, 0, 10000, EFFECT_VOLUME, MIDAS_PAN_MIDDLE ); + } +} + +void Player::chk_keys( int index ) +{ + int walk_chk = 0; + int speedi = speed; + if ( k.state[K_LEFT] ) if ( !k.state[K_STRAFE] ) rotate( 9 ); + if ( ( k.state[K_STRAFE]&&k.state[K_LEFT] ) ||k.state[K_LSTRAFE] ) + { + move( int( rangle2 + 90 ) % 360, speed*0.9, index ); + walk_chk = 1; + speedi = speed*0.8; + } + if ( k.state[K_RIGHT] ) if ( !k.state[K_STRAFE] ) rotate( - 9 ); + if ( ( k.state[K_STRAFE]&&k.state[K_RIGHT] ) ||k.state[K_RSTRAFE] ) + { + move( int( rangle2 + 270 ) % 360, speed*0.9, index ); + walk_chk = 1; + speedi = speed*0.8; + } + if ( k.state[K_UP] ) + { + move( rangle2, speedi, index );walk_chk = 1; if ( rand() % 20 == 0 ) kick_body_parts(); + } + if ( k.state[K_DOWN] ) + { + move( ( int ) ( rangle2 + 180 ) % 360, 0.75*speedi, index );walk_chk = 1; + } + if ( walk_chk ) if ( WALK == 0 ) WALK = 1; + if ( !walk_chk ) WALK = 0; + if ( k.state[K_SHOOT] ) if ( load_cnt == weapon[curr_weapon].loading_time ){ + if (curr_weapon!=0){ + if ( bullets[weapon[curr_weapon].btype - 1] > 0 ) + shoot(); else { + curr_weapon = 0; load_cnt = 0; + } + } + if ( curr_weapon == 0 ) { shoot();kick_body_parts();} + } + if ( !k.state[K_SHOOT] ) shoot_cnt = 0;else shoot_cnt ++; + if ( k.state[K_SHIFT] ) + { + change_weapon();k.state[K_SHIFT] = 0; + } + if ( GAME_MODE!= SPLIT_SCREEN ) + { + if ( k.state[41] ) { + curr_weapon = 0; load_cnt=0; + } + if ( k.state[2] ) if ( weapons[1] ){ + curr_weapon = 1; load_cnt = 0; + } + if ( k.state[3] ) if ( weapons[2] ){ + curr_weapon = 2; load_cnt = 0; + } + if ( k.state[4] ) if ( weapons[3] ){ + curr_weapon = 3; load_cnt = 0; + } + if ( k.state[5] ) if ( weapons[4] ){ + curr_weapon = 4; load_cnt = 0; + } + if ( k.state[6] ) if ( weapons[5] ){ + curr_weapon = 5; load_cnt = 0; + } + if ( k.state[7] ) if ( weapons[6] ){ + curr_weapon = 6; load_cnt = 0; + } + if ( k.state[8] ) if ( weapons[7] ){ + curr_weapon = 7; load_cnt = 0; + } + if ( k.state[9] ) if ( weapons[8] ){ + curr_weapon = 8; load_cnt = 0; + } + if ( k.state[10] ) if ( weapons[9] ){ + curr_weapon = 9; load_cnt = 0; + } + if ( k.state[11] ) if ( weapons[10] ){ + curr_weapon = 10; load_cnt = 0; + } + if ( k.state[12] ) if ( weapons[11] ){ + curr_weapon = 11; load_cnt = 0; + } + } +} + +void Body_part::move() +{ + int offs[2*4]; //** + int reuna = 4; //**chk pointit on n„in + int reuna2 = 4; //** + int rnx, rny; //** + float newx, newy; + newx = x + ( ( int ) speed*sini[angle] ); + newy = y + ( ( int ) speed*cosi[angle] ); + rnx = newx; + rny = newy; + if ( num < 12 ) + if ( rand() % 3!= 0 ) new_effect( 0, BLOOD2, int( x ) + 10, int( y ) + 10, 0, 0 ); + offs[0] = ( ( rny + reuna ) / 20 ) *level_x_size + ( ( rnx + 10 - reuna2 ) / 20 ); + offs[1] = ( ( rny + reuna ) / 20 ) *level_x_size + ( ( rnx + 10 + reuna2 ) / 20 ); + offs[2] = ( ( rny + 20 - reuna ) / 20 ) *level_x_size + ( ( rnx + 10 - reuna2 ) / 20 ); + offs[3] = ( ( rny + 20 - reuna ) / 20 ) *level_x_size + ( ( rnx + 10 + reuna2 ) / 20 ); + offs[4] = ( ( rny + 10 - reuna2 ) / 20 ) *level_x_size + ( ( rnx + reuna ) / 20 ); + offs[5] = ( ( rny + 10 + reuna2 ) / 20 ) *level_x_size + ( ( rnx + reuna ) / 20 ); + offs[6] = ( ( rny + 10 - reuna2 ) / 20 ) *level_x_size + ( ( rnx + 20 - reuna ) / 20 ); + offs[7] = ( ( rny + 10 + reuna2 ) / 20 ) *level_x_size + ( ( rnx + 20 - reuna ) / 20 ); + if ( newy < y ) + if ( level[offs[0]].type == FLOOR ) + if ( level[offs[1]].type == FLOOR ) + y = newy; + if ( newy > y ) + if ( level[offs[2]].type == FLOOR ) + if ( level[offs[3]].type == FLOOR ) + y = newy; + if ( newx < x ) + if ( level[offs[4]].type == FLOOR ) + if ( level[offs[5]].type == FLOOR ) + x = newx; + if ( newx > x ) + if ( level[offs[6]].type == FLOOR ) + if ( level[offs[7]].type == FLOOR ) + x = newx; +} + +void Player::animate() +{ int a; + + if ( weapon[curr_weapon].gun == 0 ) ANIM = 1;else ANIM = 4; + if ( WALK ) + { + if ( WALK - 1 < WALK_DELAY ) WALK ++;else WALK = 1; + ANIM = ( WALK - 1 ) / ( WALK_DELAY / 4 ); + if ( ANIM >= 3 ) ANIM = 1 ; + if ( weapon[curr_weapon].gun == 1 ) ANIM += 3; + } + if ( FIRE ) + { + FIRE ++; + if ( FIRE > 3 ) FIRE = 0; + if ( weapon[curr_weapon].gun == 0 ) ANIM = 7; else ANIM = 6; + } + if ( DEAD ) + { + if ( DEAD - 1 < DEAD_DELAY ) DEAD ++; + ANIM = 8 + ( ( DEAD - 1 ) / ( DEAD_DELAY / 2 ) ); + if ( KILLING_MODE == DEATHMATCH ) + if ( DEAD - 1 == DEAD_DELAY ) + death_match_start_up(); + } + if ( !DEAD ) + if ( energy < 20 ) ANIM += 11; + if ( KICK ) + { + KICK ++;if ( KICK > 5 ) KICK = 0; + if ( curr_weapon == 0 ) ANIM = 19;else ANIM = 20; + if ( energy < 20 ) ANIM += 2; + } + + if (GAME_MODE==NETWORK) + { + if (NETWORK_MODE==CLIENT) sendipx(0,IPX_PLYANIM,(char)aplayer[0]->tindex); + else + for(a=1;a= 3 ) ANIM = 1 ; + } + if ( FIRE ) + { + FIRE ++; + if ( FIRE > 3 ) FIRE = 0; + ANIM = 3; + } + if ( !DEAD ) + if ( energy < 10 ) ANIM += 4; +} + +void Effect::roll() +{ + if ( IN_USE ) + { + if ( count < type-> tcount*type-> delay ) + if ( type-> random == 0 ) count ++; + else + count += rand() % 3; + if ( count >= type-> tcount*type-> delay ) IN_USE = 0; + if ( speed > 0 ) + { + x += speed*sini[angle]; + y += speed*cosi[angle]; + if ( level[( int ) ( y / 20 ) *level_x_size + ( int ) ( x / 20 ) ].type!= FLOOR ) IN_USE = 0; + } + if ( IN_USE == 0 ) if ( type-> index == BLOOD ) new_effect( 0, BLOOD2, x, y, 0, 0 ); + } +} + +void Player::change_weapon() +{ + curr_weapon ++; + while ( weapons[curr_weapon%= DIFF_WEAPONS + 1] == 0 ) + { + curr_weapon ++;curr_weapon%= DIFF_WEAPONS + 1; + } + load_cnt = 0; +} + +void Player::footprint( int side ) +{ + int a, do_it = 0, footx, footy, footoffs; + footx = x + 15 + ( sini[( rangle2 + 90 + ( side*180 ) ) % 360]*4 ); + footy = y + 15 + ( cosi[( rangle2 + 90 + ( side*180 ) ) % 360]*4 ); + footoffs = ( footy / 20 ) *level_x_size + ( footx / 20 ); + if ( level[footoffs].type == FLOOR ) + for ( a = 0; a < DUST_BLOCKS &&do_it == 0; a ++ ) + if ( level[footoffs].num == dust_blocks[a] ) do_it = 1; + if ( do_it ) + new_effect( 0, FOOTPRINT, footx, footy, 0, 0 ); +} + +void Player::move( int angle, float spd, int index ) +{ + int offs[2*4]; // ** + int reuna = 6; // * * chk pointit on n„in + int reuna2 = 4; // * * + int rnx, rny; // ** + int crate_taken = 0; + float newx, newy; + float speedi; + int chk, a, b; + + if ( WALK == ( int ) ( WALK_DELAY*0.25 ) ||WALK == ( int ) ( WALK_DELAY*0.75 ) ) footprint( 0 ); + if ( WALK == ( int ) ( WALK_DELAY*0.5 ) ||WALK == WALK_DELAY - 1 ) footprint( 1 ); + if ( energy < 20 ) // veren tiputus + if ( WALK % 4 == 0 ) + if ( rand() % 3 == 0 ) + new_effect( 0, BLOOD2, int( x ) + 15, int( y ) + 15, 0, 0 ); + speedi = spd; + newx = x + ( speedi*sini[angle] ); + newy = y + ( speedi*cosi[angle] ); + rnx = newx; + rny = newy; + offs[0] = ( ( rny + reuna ) / 20 ) *level_x_size + ( ( rnx + 14 - reuna2 ) / 20 ); + offs[1] = ( ( rny + reuna ) / 20 ) *level_x_size + ( ( rnx + 14 + reuna2 ) / 20 ); + offs[2] = ( ( rny + 28 - reuna ) / 20 ) *level_x_size + ( ( rnx + 14 - reuna2 ) / 20 ); + offs[3] = ( ( rny + 28 - reuna ) / 20 ) *level_x_size + ( ( rnx + 14 + reuna2 ) / 20 ); + offs[4] = ( ( rny + 14 - reuna2 ) / 20 ) *level_x_size + ( ( rnx + reuna ) / 20 ); + offs[5] = ( ( rny + 14 + reuna2 ) / 20 ) *level_x_size + ( ( rnx + reuna ) / 20 ); + offs[6] = ( ( rny + 14 - reuna2 ) / 20 ) *level_x_size + ( ( rnx + 28 - reuna ) / 20 ); + offs[7] = ( ( rny + 14 + reuna2 ) / 20 ) *level_x_size + ( ( rnx + 28 - reuna ) / 20 ); + if ( newy < y ) + if ( level[offs[0]].type == FLOOR ) + if ( level[offs[1]].type == FLOOR ) + { + for ( chk = 0, a = 0; a < ENEMIES; a ++ ) + if ( !enemy[a].DEAD ) + if ( rnx + 15 > enemy[a].x ) + if ( rnx + 15 < enemy[a].x + 30 ) + if ( rny + reuna > enemy[a].y + reuna ) + if ( rny + reuna < enemy[a].y + 28 - reuna ) chk = 1; + for ( b = 0; b < MAX_PLAYERS &&chk == 0; b ++ ) + if ( player[b].enabled) + if ( this != &player[b] ) + if ( !player[b].DEAD ) + if ( rnx + 15 > player[b].x ) + if ( rnx + 15 < player[b].x + 30 ) + if ( rny + reuna > player[b].y + reuna ) + if ( rny + reuna < player[b].y + 28 - reuna ) chk = 1; + if ( !chk ) y = newy; + } + if ( newy > y ) + if ( level[offs[2]].type == FLOOR ) + if ( level[offs[3]].type == FLOOR ) + { + for ( chk = 0, a = 0; a < ENEMIES; a ++ ) + if ( !enemy[a].DEAD ) + if ( rnx + 15 > enemy[a].x ) + if ( rnx + 15 < enemy[a].x + 30 ) + if ( rny + 28 - reuna > enemy[a].y + reuna ) + if ( rny + 28 - reuna < enemy[a].y + 28 - reuna ) chk = 1; + for ( b = 0; b < MAX_PLAYERS &&chk == 0; b ++ ) + if ( player[b].enabled) + if ( this != &player[b] ) + if ( !player[b].DEAD ) + if ( rnx + 15 > player[b].x ) + if ( rnx + 15 < player[b].x + 30 ) + if ( rny + 28 - reuna > player[b].y + reuna ) + if ( rny + 28 - reuna < player[b].y + 28 - reuna ) chk = 1; + if ( !chk ) y = newy; + } + if ( newx < x ) + if ( level[offs[4]].type == FLOOR ) + if ( level[offs[5]].type == FLOOR ) + { + for ( chk = 0, a = 0; a < ENEMIES; a ++ ) + if ( !enemy[a].DEAD ) + if ( rnx + reuna > enemy[a].x + reuna ) + if ( rnx + reuna < enemy[a].x + 28 - reuna ) + if ( rny + 15 > enemy[a].y ) + if ( rny + 15 < enemy[a].y + 30 ) chk = 1; + for ( b = 0; b < MAX_PLAYERS &&chk == 0; b ++ ) + if ( player[b].enabled) + if ( this != &player[b] ) + if ( !player[b].DEAD ) + if ( rnx + reuna > player[b].x + reuna ) + if ( rnx + reuna < player[b].x + 28 - reuna ) + if ( rny + 15 > player[b].y ) + if ( rny + 15 < player[b].y + 30 ) chk = 1; + if ( !chk ) x = newx; + } + if ( newx > x ) + if ( level[offs[6]].type == FLOOR ) + if ( level[offs[7]].type == FLOOR ) + { + for ( chk = 0, a = 0; a < ENEMIES; a ++ ) + if ( !enemy[a].DEAD ) + if ( rnx + 28 - reuna > enemy[a].x + reuna ) + if ( rnx + 28 - reuna < enemy[a].x + 28 - reuna ) + if ( rny + 15 > enemy[a].y ) + if ( rny + 15 < enemy[a].y + 30 ) chk = 1; + for ( b = 0; b < MAX_PLAYERS &&chk == 0; b ++ ) + if ( this != &player[b] ) + if ( player[b].enabled) + if ( !player[b].DEAD ) + if ( rnx + 28 - reuna > player[b].x + reuna ) + if ( rnx + 28 - reuna < player[b].x + 28 - reuna ) + if ( rny + 15 > player[b].y ) + if ( rny + 15 < player[b].y + 30 ) chk = 1; + if ( !chk ) x = newx; + } + for ( a = 0; a < MAX_CRATES; a ++ ) // laatikoiden ker„ys + if ( crate[a].IN_USE ) + if ( crate[a].text_count == 0 ) + if ( crate[a].x + 7 > x ) + if ( crate[a].x + 7 < x + 30 ) + if ( crate[a].y + 7 > y ) + if ( crate[a].y + 7 < y + 30 ) + { + crate_taken = 0; + if ( crate[a].type == 0 ) + if ( weapons[crate[a].weapon + 1] == 0 ) + { + weapons[crate[a].weapon + 1] = 1; crate_taken = 1; + } + if ( crate[a].type == 1 ) + if ( bullets[crate[a].bullet] < bullet_type[crate[a].bullet + 1].max*bullet_type[crate[a].bullet + 1].mul ) + { + bullets[crate[a].bullet] += bullet_type[crate[a].bullet + 1].amount_in_crate; + if ( bullets[crate[a].bullet] > bullet_type[crate[a].bullet + 1].max*bullet_type[crate[a].bullet + 1].mul ) bullets[crate[a].bullet] = bullet_type[crate[a].bullet + 1].max*bullet_type[crate[a].bullet + 1].mul; + crate_taken = 1; + } + if ( crate[a].type == 2 ) if ( energy < max_energy + shield*10 ) + { + energy += 40; if ( energy > max_energy + shield*10 ) energy = max_energy + shield*10; crate_taken = 1; + } + if ( crate_taken ) + { + MIDASplaySample( klikwav, MIDAS_CHANNEL_AUTO, 0, 11250, EFFECT_VOLUME, MIDAS_PAN_MIDDLE ); + if ( crate[a].type == 0 ) + strcpy( crate[a].text, weapon[crate[a].weapon + 1].name ); + if ( crate[a].type == 1 ) + strcpy( crate[a].text, bullet_type[crate[a].bullet + 1].name ); + if ( crate[a].type == 2 ) + strcpy( crate[a].text, "Energy" ); + if ( index == 0 ) + { + crate[a].text_x = crate[a].x + 7 - str_length( crate[a].text ) - scr_x; + crate[a].text_y = crate[a].y + 7 - scr_y; + crate[a].text_count = get_dist( crate[a].text_x, crate[a].text_y, 10, scr_y_size - 20 ) + 1; + crate[a].text_angle = get_angle( crate[a].text_x, crate[a].text_y, 10, scr_y_size - 20 ); + } + if ( GAME_MODE == SPLIT_SCREEN ) + if ( index == 1 ) + { + crate[a].text_x = crate[a].x + 7 - str_length( crate[a].text ) - scr_x + 160; + crate[a].text_y = crate[a].y + 7 - scr_y; + crate[a].text_count = get_dist( crate[a].text_x, crate[a].text_y, 170, scr_y_size - 20 ) + 1; + crate[a].text_angle = get_angle( crate[a].text_x, crate[a].text_y, 170, scr_y_size - 20 ); + } + if (enabled) + if (GAME_MODE==NETWORK) + { + if (NETWORK_MODE==CLIENT) sendipx(0,IPX_UPDCRATE,(char)aplayer[0]->tindex,a); + else + for(b=1;btindex); + else + for(a=1;a= 360 ) angle -= 360; + if ( angle < 0 ) angle += 360; + rangle = angle / 9; + rangle2 = rangle*9; + + if (GAME_MODE==NETWORK) + { + if (NETWORK_MODE==CLIENT) sendipx(0,IPX_PLYRANGLE,(char)aplayer[0]->tindex); + else + for(a=1;a 100 ) scr_x = x - 80; + spd = abs( ( scr_x + 80 ) - ( ( 35*sini[angle] ) + x + 14 ) ) / 4; + if ( scr_x + 80 < ( 35*sini[angle] ) + x + 14 ) scr_x += spd; + if ( scr_x + 80 > ( 35*sini[angle] ) + x + 14 ) scr_x -= spd; + if ( scr_x < 0 ) scr_x = 0; + if ( scr_x > ( level_x_size*20 ) - 160 ) scr_x = ( level_x_size*20 ) - 160; + } + else + { + if ( abs( ( scr_x + 160 ) - ( x + 14 ) ) > 160 ) scr_x = x - 160; + spd = abs( ( scr_x + 160 ) - ( ( 25*sini[angle] ) + x + 14 ) ) / 4; + if ( scr_x + 160 < ( 25*sini[angle] ) + x + 14 ) scr_x += spd; + if ( scr_x + 160 > ( 25*sini[angle] ) + x + 14 ) scr_x -= spd; + if ( scr_x < 0 ) scr_x = 0; + if ( scr_x > ( level_x_size*20 ) - 320 ) scr_x = ( level_x_size*20 ) - 320; + } + if ( abs( ( scr_y + ( scr_y_size / 2 ) ) - ( y + 14 ) ) > 120 ) scr_y = y - ( scr_y_size / 2 ); + spd = abs( ( scr_y + ( scr_y_size / 2 ) ) - ( ( 25*cosi[angle] ) + y + 14 ) ) / 4; + if ( scr_y + ( scr_y_size / 2 ) < ( 25*cosi[angle] ) + y + 14 ) scr_y += spd; + if ( scr_y + ( scr_y_size / 2 ) > ( 25*cosi[angle] ) + y + 14 ) scr_y -= spd; + if ( scr_y > ( level_y_size*20 ) - scr_y_size ) scr_y = ( level_y_size*20 ) - scr_y_size; + if ( scr_y < 0 ) scr_y = 0; +} + +void Player::load() +{ + if ( load_cnt < weapon[curr_weapon].loading_time ) load_cnt ++; +} + +void Enemy::load() +{ + if ( load_cnt < weapon[enemy_info[type].curr_weapon].loading_time ) load_cnt ++; +} + +void Enemy::get_angles() +{ + int a, b; + for ( b = 0; b < MAX_PLAYERS; b ++ ) + if ( player[b].enabled) + { + a = 270 - get_angle( player[b].x, player[b].y, x, y ); + if ( a < 0 ) a += 360; + angle_pl[b] = a; + } +} + +void Enemy::try_see_players() +{ + int dist, a, b, min, max, rx, ry, hit = 0, go_on = 0; + int see[MAX_PLAYERS], saw[MAX_PLAYERS]; + int weakest = 0; + see_somebody = 0; + min = angle - 90; + if ( min < 0 ) min += 360; + max = angle + 90; + if ( max > 360 ) max -= 360; + for ( b = 0; b < MAX_PLAYERS; b ++ ) + if ( player[b].enabled) + see[b] = 0; + for ( b = 0; b < MAX_PLAYERS; b ++ ) + if ( player[b].enabled){ + if ( SEE_PL[b] ) saw[b] = 1;else saw[b] = 0; + } + for ( b = 0; b < MAX_PLAYERS; b ++ ) + if ( player[b].enabled) + SEE_PL[b] = 0; + for ( b = 0; b < MAX_PLAYERS; b ++ ) + if ( player[b].enabled) + { + go_on = 0; + hit = 0; + if ( !player[b].DEAD ) + { + if ( angle < 270 &&angle > 90 ) + { + // n„k”kentt„180 astetta + if ( angle_pl[b] > min &&angle_pl[b] < max ) go_on = 1; + } + else if ( angle_pl[b] > min ||angle_pl[b] < max ) go_on = 1; + } + if ( go_on ) + for ( a = 0; a < 8*4 &&hit == 0; a ++ ) + { + rx = 14 + x + ( a*5*sini[angle_pl[b]] ); + ry = 14 + y + ( a*5*cosi[angle_pl[b]] ); + if ( level[( ry / 20 ) *level_x_size + ( rx / 20 ) ].type!= FLOOR ) hit = 1; + if ( rx > player[b].x + 5 ) + if ( rx < player[b].x + 25 ) + if ( ry > player[b].y + 5 ) + if ( ry < player[b].y + 25 ) + { + SEE_PL[b] = 1; see[b] = 1; see_somebody = 1; + }; + } + } + if ( see_somebody ) + { + for ( b = 0; b < MAX_PLAYERS; b ++ ) + if (player[b].enabled) + if ( !player[b].DEAD ) + if ( see[b] ) weakest = b; + for ( b = 0; b < MAX_PLAYERS; b ++ ) + if ( player[b].enabled) + if ( !player[b].DEAD ) + if ( see[b] ) + { + if ( player[b].energy < player[weakest].energy ) weakest = b; + } + tangle = angle_pl[weakest]; + } + else + { + for ( b = 0; b < MAX_PLAYERS; b ++ ) + if ( player[b].enabled) + if ( saw[b] ) + { + dist = get_dist( x, y, player[b].x, player[b].y ); // chk the dist and be clever + walk_cnt = dist / enemy_info[type].speed; + if ( walk_cnt < 0 ) walk_cnt = 0; + } + } +} + +void Enemy::footprint( int side ) +{ + int a, do_it = 0, footx, footy, footoffs; + footx = x + 15 + ( sini[( angle + 90 + ( side*180 ) ) % 360]*4 ); + footy = y + 15 + ( cosi[( angle + 90 + ( side*180 ) ) % 360]*4 ); + footoffs = ( footy / 20 ) *level_x_size + ( footx / 20 ); + if ( level[footoffs].type == FLOOR ) + for ( a = 0; a < DUST_BLOCKS &&do_it == 0; a ++ ) + if ( level[footoffs].num == dust_blocks[a] ) do_it = 1; + if ( do_it ) + new_effect( 0, FOOTPRINT, footx, footy, 0, 0 ); +} + +void Enemy::move( int angle, int spd ) +{ + int offs[2*4]; + int reuna = 6; // p„„chk pointien et„isyys reunasta + int reuna2 = 4; // sivu chk pointien et„isyys p„„chk pointeista + int rnx, rny, speedi, chk, a; + float newx, newy, ox = x, oy = y; + if ( WALK == ( int ) ( WALK_DELAY*0.25 ) ||WALK == ( int ) ( WALK_DELAY*0.75 ) ) footprint( 0 ); + if ( WALK == ( int ) ( WALK_DELAY*0.5 ) ||WALK == WALK_DELAY - 1 ) footprint( 1 ); + if ( energy < 10 ) + if ( WALK % 4 == 0 ) + if ( rand() % 3 == 0 ) + new_effect( 0, BLOOD2, int( x ) + 15, int( y ) + 15, 0, 0 ); + if ( spd == 0 ) speedi = enemy_info[type].speed; + else speedi = spd; + newx = x + ( speedi*sini[angle] ); + newy = y + ( speedi*cosi[angle] ); + rnx = newx; + rny = newy; + offs[0] = ( ( rny + reuna ) / 20 ) *level_x_size + ( ( rnx + 14 - reuna2 ) / 20 ); + offs[1] = ( ( rny + reuna ) / 20 ) *level_x_size + ( ( rnx + 14 + reuna2 ) / 20 ); + offs[2] = ( ( rny + 28 - reuna ) / 20 ) *level_x_size + ( ( rnx + 14 - reuna2 ) / 20 ); + offs[3] = ( ( rny + 28 - reuna ) / 20 ) *level_x_size + ( ( rnx + 14 + reuna2 ) / 20 ); + offs[4] = ( ( rny + 14 - reuna2 ) / 20 ) *level_x_size + ( ( rnx + reuna ) / 20 ); + offs[5] = ( ( rny + 14 + reuna2 ) / 20 ) *level_x_size + ( ( rnx + reuna ) / 20 ); + offs[6] = ( ( rny + 14 - reuna2 ) / 20 ) *level_x_size + ( ( rnx + 28 - reuna ) / 20 ); + offs[7] = ( ( rny + 14 + reuna2 ) / 20 ) *level_x_size + ( ( rnx + 28 - reuna ) / 20 ); + chk = 0; + if ( newy < y ) + if ( level[offs[0]].type == FLOOR ) + if ( level[offs[1]].type == FLOOR ) + { + for ( chk = 0, a = 0; a < ENEMIES; a ++ ) + if ( &enemy[a]!= this ) + if ( !enemy[a].DEAD ) + if ( rnx + 15 > enemy[a].x ) + if ( rnx + 15 < enemy[a].x + 30 ) + if ( rny + reuna > enemy[a].y + reuna ) + if ( rny + reuna < enemy[a].y + 28 - reuna ) chk = 1; + for ( a = 0; a < MAX_PLAYERS &&chk == 0; a ++ ) + if ( player[a].enabled) + if ( !player[a].DEAD ) + if ( rnx + 15 > player[a].x ) + if ( rnx + 15 < player[a].x + 30 ) + if ( rny + reuna > player[a].y + reuna ) + if ( rny + reuna < player[a].y + 28 - reuna ) chk = 1; + if ( !chk ) y = newy; + } + chk = 0; + if ( newy > y ) + if ( level[offs[2]].type == FLOOR ) + if ( level[offs[3]].type == FLOOR ) + { + for ( chk = 0, a = 0; a < ENEMIES; a ++ ) + if ( &enemy[a]!= this ) + if ( !enemy[a].DEAD ) + if ( rnx + 15 > enemy[a].x ) + if ( rnx + 15 < enemy[a].x + 30 ) + if ( rny + 28 - reuna > enemy[a].y + reuna ) + if ( rny + 28 - reuna < enemy[a].y + 28 - reuna ) chk = 1; + for ( a = 0; a < MAX_PLAYERS &&chk == 0; a ++ ) + if ( player[a].enabled) + if ( !player[a].DEAD ) + if ( rnx + 15 > player[a].x ) + if ( rnx + 15 < player[a].x + 30 ) + if ( rny + 28 - reuna > player[a].y + reuna ) + if ( rny + 28 - reuna < player[a].y + 28 - reuna ) chk = 1; + if ( !chk ) y = newy; + } + chk = 0; + if ( newx < x ) + if ( level[offs[4]].type == FLOOR ) + if ( level[offs[5]].type == FLOOR ) + { + for ( chk = 0, a = 0; a < ENEMIES; a ++ ) + if ( &enemy[a]!= this ) + if ( !enemy[a].DEAD ) + if ( rnx + reuna > enemy[a].x + reuna ) + if ( rnx + reuna < enemy[a].x + 28 - reuna ) + if ( rny + 15 > enemy[a].y ) + if ( rny + 15 < enemy[a].y + 30 ) chk = 1; + for ( a = 0; a < MAX_PLAYERS &&chk == 0; a ++ ) + if ( player[a].enabled) + if ( !player[a].DEAD ) + if ( rnx + reuna > player[a].x + reuna ) + if ( rnx + reuna < player[a].x + 28 - reuna ) + if ( rny + 15 > player[a].y ) + if ( rny + 15 < player[a].y + 30 ) chk = 1; + if ( !chk ) x = newx; + } + chk = 0; + if ( newx > x ) + if ( level[offs[6]].type == FLOOR ) + if ( level[offs[7]].type == FLOOR ) + { + for ( chk = 0, a = 0; a < ENEMIES; a ++ ) + if ( &enemy[a]!= this ) + if ( !enemy[a].DEAD ) + if ( rnx + 28 - reuna > enemy[a].x + reuna ) + if ( rnx + 28 - reuna < enemy[a].x + 28 - reuna ) + if ( rny + 15 > enemy[a].y ) + if ( rny + 15 < enemy[a].y + 30 ) chk = 1; + for ( a = 0; a < MAX_PLAYERS &&chk == 0; a ++ ) + if ( player[a].enabled) + if ( !player[a].DEAD ) + if ( rnx + 28 - reuna > player[a].x + reuna ) + if ( rnx + 28 - reuna < player[a].x + 28 - reuna ) + if ( rny + 15 > player[a].y ) + if ( rny + 15 < player[a].y + 30 ) chk = 1; + if ( !chk ) x = newx; + } +} + +void Enemy::get_damage( float damage, Player *P ) +{ + int pan = 0, a, alku = rand() % 7, spd = 1 + damage / 3; + spd += ( PUSH_POWER / 3 ); + if ( spd > 5 ) spd = 5; + if ( GAME_MODE!= SPLIT_SCREEN ) + pan = get_pan( player[0].x , x ); + energy -= damage; + if ( energy <= 0 ) + { + if ( burning && ! enemy_info[type].explo_death) + { + MIDASplaySample( wooshwav, MIDAS_CHANNEL_AUTO, 0, 20000, EFFECT_VOLUME, pan ); + new_effect( &explo_l, EXPLO, x + 12, y + 12, 0, 0 ); + new_effect( &explo_l, EXPLO, x + 18, y + 12, 0, 0 ); + new_effect( &explo_l, EXPLO, x + 15, y + 18, 0, 0 ); + for ( a = 0; a < 3; a ++ ) + new_body_part( x + 4, y + 4, rand() % 360, 5, a + 12 ); + } + if ( ! burning && ! enemy_info[type].explo_death) + { + for ( a = 0; a < 16; a ++ ) + if ( rand() % 2 ) + new_effect( 0, BLOOD, x + 15, y + 15, a*22.5, 4 ); + for ( a = 0; a < 3; a ++ ) + new_body_part( x + 4, y + 4, rand() % 360, spd + ( rand() % 2 ), ( a + alku ) % 7 ); + MIDASplaySample( deathwav, MIDAS_CHANNEL_AUTO, 0, 20000 - ( rand() % 3000 ), EFFECT_VOLUME, pan ); + } + if (enemy_info[type].explo_death) + { + explo( x+4, y+4, 2, -1); + for ( a = 0; a < 3; a ++ ) + new_body_part( x + 4, y + 4, rand() % 360, 5, a + 12 ); + } + + DEAD = 1; + DEAD_ENEMIES ++; + if ( KILLING_MODE!= DEATHMATCH ) if ( DEAD_ENEMIES >= ENEMIES ) next_level = 1; + if ( P!= NULL ) + P-> kills[type] ++; + } +} + +void Player::get_damage( float damage, Player *P ) +{ char buf[MAX_MESSAGE_LENGTH]; + int a,b; + HIT = 15; + energy -= damage; + if ( energy <= 0 ) + { + + if (KILLING_MODE==DEATHMATCH) + { + if (P->tindex!=tindex) + sprintf(buf,killtexts[rand()%ktexts],P->name,name); + else + sprintf(buf,suicidetexts[rand()%stexts],P->name,name); + message_board.add_message(buf); + } + + for (a=0;aplayer_kills++; + else player_kills --; + + if (GAME_MODE==NETWORK) + { + if (NETWORK_MODE==CLIENT) sendipx(0,IPX_UPDKILLS,(char)aplayer[0]->tindex,P->tindex); + else + for(b=1;btindex); + } + + } + } +} + +void Player::see() +{ + int offs, a, b, ang, stop; + int tx, ty, mx, my, ox, oy, nx, ny; + int range = 12, korona = 2*pi*range + 5; + tx = ( x + 15 ) / 20; + ty = ( y + 15 ) / 20; + for ( a = 0; a < korona; a ++ ) + { + ang = ( int ) ( a*( 360 / ( float ) korona ) ) % 360; + stop = 0; + nx = 0; + ny = 0; + for ( b = 0; b < range &&stop == 0; b ++ ) + { + ox = nx; + oy = ny; + nx = ( int ) ( b*sini[ang] ); + ny = ( int ) ( b*cosi[ang] ); + mx = nx - ox; + my = ny - oy; + offs = ( ( ty + oy ) *level_x_size ) + ox + tx; + if ( abs( mx ) == 1 &&abs( my ) == 1 ) + if ( level[offs + mx].type!= FLOOR &&level[offs + ( my*level_x_size ) ].type!= FLOOR ) + stop = 1; + offs = ( ( ty + ny ) *level_x_size ) + nx + tx; + if ( level[offs].type!= FLOOR ) stop = 1; + if ( !stop ) see_level[offs] = 1; + } + } +} + +void Bullet::move() +{ + int bp, speed, vx, vy, a, b, rx = x, ry = y, hit = 0, kosh = 0; + int looptimes; + + speed = type-> speed; + looptimes = speed >> 2; + if ( speed == 0 ) looptimes = 1; + time --; + count ++; + for( a = 0; a < looptimes &&hit == 0 &&kosh == 0 ; a ++ ) + { + if ( speed > 0 ) + { + x += ( float ) speed / ( speed >> 2 ) *sini[angle]; + y += ( float ) speed / ( speed >> 2 ) *cosi[angle]; + } + rx = x; + ry = y; + if ( type-> speed > 0 ) + if ( level[( int ) ( ry / 20 ) *level_x_size + ( int ) ( rx / 20 ) ].type!= FLOOR ) + { + kosh = 1; + } + if ( count > type-> sleep_time ) + if ( type-> stop ) + { + if (!(GAME_MODE == NETWORK && NETWORK_MODE == CLIENT)) + for ( b = 0; b < ENEMIES; b ++ ) // chk for enemy + if ( !enemy[b].DEAD ) + if ( rx > enemy[b].x + 5 ) + if ( rx < enemy[b].x + 22 ) + if ( ry > enemy[b].y + 5 ) + if ( ry < enemy[b].y + 22 ) + { + hit = 1; + if ( P!= NULL ) + enemy[b].tangle = enemy[b].angle_pl[index];// „ij„k„„ntyy kohti, kun sit„ampuu + vx = enemy[b].x + 14 + ( 4*sini[angle] ); + vy = enemy[b].y + 14 + ( 4*cosi[angle] ); + enemy[b].PUSH_ANGLE = angle;// „ij„lent„„ + if ( type-> push_power > enemy[b].PUSH_POWER ) + enemy[b].PUSH_POWER = ( float ) type-> push_power;// „ij„lent„„ + enemy[b].get_damage( type-> power, P ); + if ( type-> type == INCENDIARY ) + { + enemy[b].burning += 10; + enemy[b].Frying_player = P; + } + } + + for ( b = 0; b < MAX_PLAYERS; b ++ ) + if ( player[b].enabled ) + if ( !player[b].DEAD ) + if ( rx > player[b].x + 5 ) + if ( rx < player[b].x + 22 ) + if ( ry > player[b].y + 5 ) + if ( ry < player[b].y + 22 ) + { + hit = 1; + vx = player[b].x + 14 + ( 4*sini[angle] ); + vy = player[b].y + 14 + ( 4*cosi[angle] ); + if ( (GAME_MODE!=NETWORK) || (aplayer[0]==&player[b])) + { + player[b].PUSH_ANGLE = angle;// „ij„lent„„ + if ( type-> push_power > player[b].PUSH_POWER ) + player[b].PUSH_POWER = ( float ) type-> push_power;// „ij„lent„„ + player[b].get_damage( type-> power, P ); + if ( type-> type == INCENDIARY ) + { + player[b].burning += 10; + player[b].Frying_player = P; + } + } + } + } + } + if ( type-> type == NORMAL ) + if ( kosh ) if ( rand() % 8 == 1 ) new_effect( &normal_l, METAL, rx, ry, rand() % 360, ( rand() % 3 ) + 5 ); + + if ( hit ) + { + if ( type-> type == NORMAL ) + { + + bp = 6 + ( type-> power / 3 ) + rand() % 3; + if ( bp > 8 ) bp = 8; + for ( a = 0; a < ( type-> power / 5 ) + 1; a ++ ) + new_effect( 0, BLOOD, vx + ( rand() % 6 ) - 3, vy + ( rand() % 6 ) - 3, angle + ( ( rand() % 30 ) - 15 ), bp ); + } + if ( P!=NULL ) P->hitten++; + if ( type-> speed < 10 &&type-> time == 1 ) // if fist + { + if (GAME_MODE==SPLIT_SCREEN) + MIDASplaySample( samplep[weapon[0].sound], MIDAS_CHANNEL_AUTO, 0, sample_rates[0], EFFECT_VOLUME, MIDAS_PAN_MIDDLE ); + else + MIDASplaySample( samplep[weapon[0].sound], MIDAS_CHANNEL_AUTO, 0, sample_rates[0], get_volume(aplayer[0]->x,aplayer[0]->y,rx,ry),get_pan(aplayer[0]->x,rx) ); + } + } + + + if ( type-> type == NORMAL ) + if ( !hit ) + if ( time == 0 ||kosh ) + { + if ( type-> speed < 10 &&type-> time == 1 ) + { + } + else new_effect( &normal_l, SMOKE, rx, ry, 0, 0 ); + } + if ( hit ||kosh ||time == 0 ) + { + if ( type-> type == EXPLOSIVE ) explo( rx - ( 5*sini[angle] ), ry - ( 5*cosi[angle] ), type-> explos, index ); + IN_USE = 0; + } + if ( type-> effect!= 0 ) + if ( type-> effect == EXPLO ) new_effect( &explo_l, type-> effect, rx, ry, angle + 180, 1 ); + else new_effect( 0, type-> effect, rx, ry, 0, 0 ); +} + +void Player::shoot() +{ + int r, a, rx = x, ry = y; + FIRE = 1; + load_cnt = 0; + for ( a = 0; a < weapon[curr_weapon].bullet_amount; a ++ ) + { + shooted ++; + r = ( weapon[curr_weapon].angle_add >> 1 ) - rand() % weapon[curr_weapon].angle_add; + new_bullet( weapon[curr_weapon].btype, rx + 14 + ( 10*sini[rangle2] ), ry + 14 + ( 10*cosi[rangle2] ), rangle2 + r, 0, tindex); + } + if ( curr_weapon > 0 ) bullets[weapon[curr_weapon].btype - 1] --; + if ( curr_weapon > 0 ) + if ( shoot_cnt % bullet_type[weapon[curr_weapon].btype].mul == 0 ) + { + if ( weapon[curr_weapon].sound != NULL ) + MIDASplaySample( samplep[weapon[curr_weapon].sound], MIDAS_CHANNEL_AUTO, 0, sample_rates[curr_weapon], EFFECT_VOLUME, MIDAS_PAN_MIDDLE ); + if ( weapon[curr_weapon].smoke ) + new_effect( 0, SMOKE3, rx + 14 + ( 8*sini[rangle2] + 8*sini[( rangle2 + 270 ) % 360] ), ry + 14 + ( 8*cosi[rangle2] + 8*cosi[( rangle2 + 270 ) % 360] ), rangle2, 1 ); + } +} + +void Enemy::shoot() +{ + int r, a, rx = x, ry = y, weaponi = enemy_info[type].curr_weapon; + int pan = 0; + FIRE = 1; + load_cnt = 0; + for ( a = 0; a < weapon[weaponi].bullet_amount; a ++ ) + { + r = ( weapon[weaponi].angle_add / 2 ) - rand() % weapon[weaponi].angle_add; + new_bullet( weapon[weaponi].btype, rx + 14 + ( 10*sini[angle] ), ry + 14 + ( 10*cosi[angle] ), angle + r, 0, -1); + } + if ( GAME_MODE!= SPLIT_SCREEN ) + { + // stereo effect + pan = ( float ) ( - ( player[0].x - x ) ) / 2; + if ( pan < - 63 ) pan = - 63; + if ( pan > 63 ) pan = 63; + } + if ( weaponi > 0 ) + if ( shoot_cnt % bullet_type[weapon[weaponi].btype].mul == 0 ) + MIDASplaySample( samplep[weapon[weaponi].sound], MIDAS_CHANNEL_AUTO, 0, sample_rates[weaponi], EFFECT_VOLUME, pan ); + if ( shoot_cnt % bullet_type[weapon[weaponi].btype].mul == 0 ) + if ( weapon[weaponi].smoke ) + new_effect( 0, SMOKE3, rx + 14 + ( 8*sini[( int ) ( rangle*9 ) ] + 5*sini[( ( int ) ( rangle*9 ) + 270 ) % 360] ), ry + 14 + ( 8*cosi[( int ) ( rangle*9 ) ] + 5*cosi[( ( int ) ( rangle*9 ) + 270 ) % 360] ), angle, 1 ); +} + +void Enemy::chk_for_shoot() +{ + int dist, a, wannashoot = 0; + if ( enemy_info[type].curr_weapon > 0 ) + for ( a = 0; a < MAX_PLAYERS; a ++ ) + if ( player[a].enabled) + if ( SEE_PL[a] ) + if ( tangle == angle ) + { + shoot_cnt ++; + wannashoot = 1; + if ( load_cnt == weapon[enemy_info[type].curr_weapon].loading_time ) + { + shoot(); + dist = get_dist( x, y, player[a].x, player[a].y ); // chk if close enough + if ( dist > bullet_type[weapon[enemy_info[type].curr_weapon].btype].time*bullet_type[weapon[enemy_info[type].curr_weapon].btype].speed ) + walk_cnt = 20 / enemy_info[type].speed; + } + } + if ( !wannashoot ) shoot_cnt = 0; + } + +void Enemy::rotate() +{ + // Nerokas k„„ntymis funktio !!! + int kaanty_jo = 0; + if ( angle!= tangle ) + { + if ( angle < 180 ) + { + if ( tangle < angle + 180 &&tangle > angle ) angle += ROT_SPEED; else angle -= ROT_SPEED; + kaanty_jo = 1; + } + if ( angle >= 180 &&kaanty_jo == 0 ) + if ( tangle > angle - 180 &&tangle < angle ) angle -= ROT_SPEED; else angle += ROT_SPEED; + angle%= 360; + if ( angle < 0 ) angle += 360; + // v„h„n py”ristyst„, niin angle saavuttaa joskus tanglen ... + if ( abs( angle - tangle ) < ROT_SPEED ||abs( ( angle + 360 ) - tangle ) < ROT_SPEED ) angle = tangle; + } +} + +void Level::load( char name[13] ) +{ + int a, bullets, weapons; + FILE *dat; + dat = fopen( name, "rb" ); + if ( dat != NULL ) + { + fread( &version, 4, 1, dat ); + if (version>5) {vesa_set_mode(0x3);cout<<"Invalid level version: Get newer version of TK !";exit(1);} + fread( &level_x_size, 4, 1, dat ); + fread( &level_y_size, 4, 1, dat ); + level = ( struct BLOCK* ) malloc( level_y_size*level_x_size*sizeof( struct BLOCK ) ); + fread( level, sizeof( struct BLOCK ) *level_x_size*level_y_size, 1, dat ); + fread( &pl_start_x[0], 4, 1, dat ); + fread( &pl_start_y[0], 4, 1, dat ); + fread( &pl_start_x[1], 4, 1, dat ); + fread( &pl_start_y[1], 4, 1, dat ); + fread( &Spot_amount, 4, 1, dat ); + for ( a = 0; a < Spot_amount; a ++ ) + { + fread( &spot_light[a].x, 4, 1, dat ); + fread( &spot_light[a].y, 4, 1, dat ); + fread( &spot_light[a].size, 4, 1, dat ); + } + fread( &Steam_amount, 4, 1, dat ); + for ( a = 0; a < Steam_amount; a ++ ) + { + fread( &steam[a].x, 4, 1, dat ); + fread( &steam[a].y, 4, 1, dat ); + fread( &steam[a].angle, 4, 1, dat ); + fread( &steam[a].speed, 4, 1, dat ); + } + + fread(general_level_info.comment,20, 1, dat); + fread(&general_level_info.time_limit,4, 1, dat); + memset(general_level_info.enemies,0,4*DIFF_ENEMIES); + if (version>=4) + fread(general_level_info.enemies,4*DIFF_ENEMIES, 1, dat); + if (version<4) + fread(general_level_info.enemies,4*(DIFF_ENEMIES-1), 1, dat); + + if ( version == 1 ){ + weapons = DIFF_WEAPONS - 2; bullets = DIFF_BULLETS - 2; + } + if ( version == 2 ){ + weapons = DIFF_WEAPONS - 1; bullets = DIFF_BULLETS - 1; + } + if ( version == 3 || version >= 4){ + weapons = DIFF_WEAPONS; bullets = DIFF_BULLETS; + } + fread( normal_game_level_info.weapon_crates, 4 * weapons, 1, dat ); + fread( normal_game_level_info.bullet_crates, 4 * bullets, 1, dat ); + fread( &normal_game_level_info.energy_crates, 4, 1, dat ); + fread( death_match_level_info.weapon_crates, 4 * weapons, 1, dat ); + fread( death_match_level_info.bullet_crates, 4 * bullets, 1, dat ); + fread( &death_match_level_info.energy_crates, 4, 1, dat ); + + if (version>=5){ + fread( &normal_crate_amount, 4, 1, dat ); + fread( normal_crate_info, sizeof(Crate_info) * normal_crate_amount, 1, dat ); + fread( &deathmatch_crate_amount, 4, 1, dat ); + fread( deathmatch_crate_info, sizeof(Crate_info) * deathmatch_crate_amount, 1, dat ); + } + fclose( dat ); + } + else cout << "Level file missing ! \n"; +} + +void Keys::change() +{ + int a = 0, quit = 0, cnt = 0, oclock = 0, selected = 0, b = 0; + first = 1; + fadeout( virbuff, pal ); + load_efp( "efps\\cool.efp", picture, 0 ); + draw_box1( 10, 10, 310, 32, 10 ); + draw_box1( 10, 40, 310, 190, 10 ); + while( !quit ) + { + memcpy( virbuff, picture, 64000 ); + FONT_NUM = 0; + writefonts2( 160 - ( str_length( "define keys" ) / 2 ), 13, "define keys", 1 ); + for ( a = 0; a < DIFF_K; a ++ ) + { + if ( a == selected ) + { + FONT_NUM = 1; + writefonts( 40, 50 + ( a*8 ), k_text[a], M_YELLOW ); + } + else + { + FONT_NUM = 1; + writefonts( 40, 50 + ( a*8 ), k_text[a], M_RED ); + } + } + for ( a = 0; a < DIFF_K - 1; a ++ ) + { + switch ( a ) + { + case 0:b = K_UP;break; + case 1:b = K_DOWN;break; + case 2:b = K_LEFT;break; + case 3:b = K_RIGHT;break; + case 4:b = K_SHOOT;break; + case 5:b = K_SHIFT;break; + case 6:b = K_STRAFE;break; + case 7:b = K_LSTRAFE;break; + case 8:b = K_RSTRAFE;break; + } + if ( selected == a ) + { + FONT_NUM = 1; + writefonts( 190, 50 + ( a*8 ), k_2_c( b ), M_YELLOW ); + } + else + { + FONT_NUM = 1; + writefonts( 190, 50 + ( a*8 ), k_2_c( b ), M_RED ); + } + } + if ( first == 1 ) + { + fadein( virbuff, pal ); first = 0; + } + memcpy( screen, virbuff, 64000 ); + while ( !k.state[1]&&!k.state[94]&&!k.state[99]&&!k.state[28] ) + if ( clock() != oclock ) + { + oclock = clock(); + draw_ball( 20, 45 + ( selected*8 ), cnt ); + cnt ++; + if ( cnt > 23 ) cnt = 0; + } + MIDASplaySample( klikwav, MIDAS_CHANNEL_AUTO, 0, 22500, EFFECT_VOLUME, MIDAS_PAN_MIDDLE ); + if ( k.state[94] ) + { + selected --;if ( selected < 0 ) selected = DIFF_K - 1; k.state[94] = 0; + } + if ( k.state[99] ) + { + selected ++;if ( selected >= DIFF_K ) selected = 0; k.state[99] = 0; + } + if ( k.state[28] ) + { + k.state[28] = 0; + k.clear_stack(); + if ( selected == 0 ) + { + clear_shit( 47 ); K_UP = get_key( 160, 45 ); + } + if ( selected == 1 ) + { + clear_shit( 47 + 8 ); K_DOWN = get_key( 160, 45 + 8 ); + } + if ( selected == 2 ) + { + clear_shit( 47 + ( 2*8 ) ); K_LEFT = get_key( 160, 45 + ( 2*8 ) ); + } + if ( selected == 3 ) + { + clear_shit( 47 + ( 3*8 ) ); K_RIGHT = get_key( 160, 45 + ( 3*8 ) ); + } + if ( selected == 4 ) + { + clear_shit( 47 + ( 4*8 ) ); K_SHOOT = get_key( 160, 45 + ( 4*8 ) ); + } + if ( selected == 5 ) + { + clear_shit( 47 + ( 5*8 ) ); K_SHIFT = get_key( 160, 45 + ( 5*8 ) ); + } + if ( selected == 6 ) + { + clear_shit( 47 + ( 6*8 ) ); K_STRAFE = get_key( 160, 45 + ( 6*8 ) ); + } + if ( selected == 7 ) + { + clear_shit( 47 + ( 7*8 ) ); K_LSTRAFE = get_key( 160, 45 + ( 7*8 ) ); + } + if ( selected == 8 ) + { + clear_shit( 47 + ( 8*8 ) ); K_RSTRAFE = get_key( 160, 45 + ( 8*8 ) ); + } + if ( selected == 9 ) + { + quit = 1; + } + } + if ( k.state[1] ) + { + quit = 1; k.state[1] = 0; + } + } + fadeout( virbuff, pal ); +} + diff --git a/SRC/CLASSES.CPP b/SRC/CLASSES.CPP new file mode 100644 index 0000000..d92732c --- /dev/null +++ b/SRC/CLASSES.CPP @@ -0,0 +1,1436 @@ +#include < iostream.h > +#include < string.h > +#include < stdio.h > +#include < midasdll.h > +#include < math.h > +#include < stdlib.h > +#include < vesa.h > +#include < gfunc.h > +#include "error/error.h" +#include "defines.h" +#include "globvar.h" +#include "classes.h" +#include "rout.h" +#include "newfuncs.h" +#include "miscfunc.h" +#include "write.h" +#include "draw.h" +#include "efp/efp.h" +#include "fade.h" + +int ktexts=8; +char killtexts[][MAX_MESSAGE_LENGTH-20]= +{ "%s slaughtered %s.", + "%s killed %s.", + "%s punished %s.", + "%s didn't like %s.", + "%s made %s leave..", + "%s cleaned %s.", + "%s massacred %s.", + "%s shot %s." +}; + +int stexts=5; +char suicidetexts[][MAX_MESSAGE_LENGTH-20]= +{ "%s had to go...", + "%s got bored.", + "%s had problems.", + "%s shot himself.", + "%s ain't EF..." +}; + + + +extern void sendipx(int, int, ... ); + +void Message_board::add_message(char msg[]) +{ + int a; + msg[MAX_MESSAGE_LENGTH-1]=NULL; + + if (messages0) time_count--; else clear(); + for (a=0;a 15 ) pow = 15; + if ( pow < 0 ) pow = 0; + data[offs] = ( char ) pow; + } +} + +void Crate::move_text() +{ + if ( text_count > 0 ) + { + text_x += cosi[text_angle]*4; + text_y += sini[text_angle]*4; + text_count -= 4; + if ( text_count <= 0 ) + { + IN_USE = 0; if ( KILLING_MODE == DEATHMATCH ) wake_up_count = 1; + } + } +} + +void Crate::chk_wake_up(int qwe) +{ int a; + + if ( wake_up_count > 0 ) + { + wake_up_count ++; + if ( wake_up_count >= CRATE_WAKE_UP_COUNT ) + { + new_effect( &normal_l, TELEPORT, x + 8, y + 8, 0, 0 ); + text_count = 0; IN_USE = 1; wake_up_count = 0; + if (GAME_MODE==NETWORK) + { + for(a=1;a body_part[a].x ) + if ( x + 14 < body_part[a].x + 20 ) + if ( y + 14 > body_part[a].y ) + if ( y + 14 < body_part[a].y + 20 ) + { + KICK = 1; + ang = ( rangle2 - 5 ) + ( rand() % 10 ); + if ( ang < 0 ) ang += 360; + if ( ang >= 360 ) ang -= 360; + body_part[a].angle = ang; + body_part[a].speed = 6; + MIDASplaySample( samplep[HITWAV], MIDAS_CHANNEL_AUTO, 0, 10000, EFFECT_VOLUME, MIDAS_PAN_MIDDLE ); + } +} + +void Player::chk_keys( int index ) +{ + int walk_chk = 0; + int speedi = speed; + if ( k.state[K_LEFT] ) if ( !k.state[K_STRAFE] ) rotate( 9 ); + if ( ( k.state[K_STRAFE]&&k.state[K_LEFT] ) ||k.state[K_LSTRAFE] ) + { + move( int( rangle2 + 90 ) % 360, speed*0.9, index ); + walk_chk = 1; + speedi = speed*0.8; + } + if ( k.state[K_RIGHT] ) if ( !k.state[K_STRAFE] ) rotate( - 9 ); + if ( ( k.state[K_STRAFE]&&k.state[K_RIGHT] ) ||k.state[K_RSTRAFE] ) + { + move( int( rangle2 + 270 ) % 360, speed*0.9, index ); + walk_chk = 1; + speedi = speed*0.8; + } + if ( k.state[K_UP] ) + { + move( rangle2, speedi, index );walk_chk = 1; if ( rand() % 20 == 0 ) kick_body_parts(); + } + if ( k.state[K_DOWN] ) + { + move( ( int ) ( rangle2 + 180 ) % 360, 0.75*speedi, index );walk_chk = 1; + } + if ( walk_chk ) if ( WALK == 0 ) WALK = 1; + if ( !walk_chk ) WALK = 0; + if ( k.state[K_SHOOT] ) if ( load_cnt == weapon[curr_weapon].loading_time ){ + if (curr_weapon!=0){ + if ( bullets[weapon[curr_weapon].btype - 1] > 0 ) + shoot(); else { + curr_weapon = 0; load_cnt = 0; + } + } + if ( curr_weapon == 0 ) { shoot();kick_body_parts();} + } + if ( !k.state[K_SHOOT] ) shoot_cnt = 0;else shoot_cnt ++; + if ( k.state[K_SHIFT] ) + { + change_weapon();k.state[K_SHIFT] = 0; + } + if ( GAME_MODE!= SPLIT_SCREEN ) + { + if ( k.state[41] ) { + curr_weapon = 0; load_cnt=0; + } + if ( k.state[2] ) if ( weapons[1] ){ + curr_weapon = 1; load_cnt = 0; + } + if ( k.state[3] ) if ( weapons[2] ){ + curr_weapon = 2; load_cnt = 0; + } + if ( k.state[4] ) if ( weapons[3] ){ + curr_weapon = 3; load_cnt = 0; + } + if ( k.state[5] ) if ( weapons[4] ){ + curr_weapon = 4; load_cnt = 0; + } + if ( k.state[6] ) if ( weapons[5] ){ + curr_weapon = 5; load_cnt = 0; + } + if ( k.state[7] ) if ( weapons[6] ){ + curr_weapon = 6; load_cnt = 0; + } + if ( k.state[8] ) if ( weapons[7] ){ + curr_weapon = 7; load_cnt = 0; + } + if ( k.state[9] ) if ( weapons[8] ){ + curr_weapon = 8; load_cnt = 0; + } + if ( k.state[10] ) if ( weapons[9] ){ + curr_weapon = 9; load_cnt = 0; + } + if ( k.state[11] ) if ( weapons[10] ){ + curr_weapon = 10; load_cnt = 0; + } + if ( k.state[12] ) if ( weapons[11] ){ + curr_weapon = 11; load_cnt = 0; + } + } +} + +void Body_part::move() +{ + int offs[2*4]; //** + int reuna = 4; //**chk pointit on n„in + int reuna2 = 4; //** + int rnx, rny; //** + float newx, newy; + newx = x + ( ( int ) speed*sini[angle] ); + newy = y + ( ( int ) speed*cosi[angle] ); + rnx = newx; + rny = newy; + if ( num < 12 ) + if ( rand() % 3!= 0 ) new_effect( 0, BLOOD2, int( x ) + 10, int( y ) + 10, 0, 0 ); + offs[0] = ( ( rny + reuna ) / 20 ) *level_x_size + ( ( rnx + 10 - reuna2 ) / 20 ); + offs[1] = ( ( rny + reuna ) / 20 ) *level_x_size + ( ( rnx + 10 + reuna2 ) / 20 ); + offs[2] = ( ( rny + 20 - reuna ) / 20 ) *level_x_size + ( ( rnx + 10 - reuna2 ) / 20 ); + offs[3] = ( ( rny + 20 - reuna ) / 20 ) *level_x_size + ( ( rnx + 10 + reuna2 ) / 20 ); + offs[4] = ( ( rny + 10 - reuna2 ) / 20 ) *level_x_size + ( ( rnx + reuna ) / 20 ); + offs[5] = ( ( rny + 10 + reuna2 ) / 20 ) *level_x_size + ( ( rnx + reuna ) / 20 ); + offs[6] = ( ( rny + 10 - reuna2 ) / 20 ) *level_x_size + ( ( rnx + 20 - reuna ) / 20 ); + offs[7] = ( ( rny + 10 + reuna2 ) / 20 ) *level_x_size + ( ( rnx + 20 - reuna ) / 20 ); + if ( newy < y ) + if ( level[offs[0]].type == FLOOR ) + if ( level[offs[1]].type == FLOOR ) + y = newy; + if ( newy > y ) + if ( level[offs[2]].type == FLOOR ) + if ( level[offs[3]].type == FLOOR ) + y = newy; + if ( newx < x ) + if ( level[offs[4]].type == FLOOR ) + if ( level[offs[5]].type == FLOOR ) + x = newx; + if ( newx > x ) + if ( level[offs[6]].type == FLOOR ) + if ( level[offs[7]].type == FLOOR ) + x = newx; +} + +void Player::animate() +{ int a; + + if ( weapon[curr_weapon].gun == 0 ) ANIM = 1;else ANIM = 4; + if ( WALK ) + { + if ( WALK - 1 < WALK_DELAY ) WALK ++;else WALK = 1; + ANIM = ( WALK - 1 ) / ( WALK_DELAY / 4 ); + if ( ANIM >= 3 ) ANIM = 1 ; + if ( weapon[curr_weapon].gun == 1 ) ANIM += 3; + } + if ( FIRE ) + { + FIRE ++; + if ( FIRE > 3 ) FIRE = 0; + if ( weapon[curr_weapon].gun == 0 ) ANIM = 7; else ANIM = 6; + } + if ( DEAD ) + { + if ( DEAD - 1 < DEAD_DELAY ) DEAD ++; + ANIM = 8 + ( ( DEAD - 1 ) / ( DEAD_DELAY / 2 ) ); + if ( KILLING_MODE == DEATHMATCH ) + if ( DEAD - 1 == DEAD_DELAY ) + death_match_start_up(); + } + if ( !DEAD ) + if ( energy < 20 ) ANIM += 11; + if ( KICK ) + { + KICK ++;if ( KICK > 5 ) KICK = 0; + if ( curr_weapon == 0 ) ANIM = 19;else ANIM = 20; + if ( energy < 20 ) ANIM += 2; + } + + if (GAME_MODE==NETWORK) + { + if (NETWORK_MODE==CLIENT) sendipx(0,IPX_PLYANIM,(char)aplayer[0]->tindex); + else + for(a=1;a= 3 ) ANIM = 1 ; + } + if ( FIRE ) + { + FIRE ++; + if ( FIRE > 3 ) FIRE = 0; + ANIM = 3; + } + if ( !DEAD ) + if ( energy < 10 ) ANIM += 4; +} + +void Effect::roll() +{ + if ( IN_USE ) + { + if ( count < type-> tcount*type-> delay ) + if ( type-> random == 0 ) count ++; + else + count += rand() % 3; + if ( count >= type-> tcount*type-> delay ) IN_USE = 0; + if ( speed > 0 ) + { + x += speed*sini[angle]; + y += speed*cosi[angle]; + if ( level[( int ) ( y / 20 ) *level_x_size + ( int ) ( x / 20 ) ].type!= FLOOR ) IN_USE = 0; + } + if ( IN_USE == 0 ) if ( type-> index == BLOOD ) new_effect( 0, BLOOD2, x, y, 0, 0 ); + } +} + +void Player::change_weapon() +{ + curr_weapon ++; + while ( weapons[curr_weapon%= DIFF_WEAPONS + 1] == 0 ) + { + curr_weapon ++;curr_weapon%= DIFF_WEAPONS + 1; + } + load_cnt = 0; +} + +void Player::footprint( int side ) +{ + int a, do_it = 0, footx, footy, footoffs; + footx = x + 15 + ( sini[( rangle2 + 90 + ( side*180 ) ) % 360]*4 ); + footy = y + 15 + ( cosi[( rangle2 + 90 + ( side*180 ) ) % 360]*4 ); + footoffs = ( footy / 20 ) *level_x_size + ( footx / 20 ); + if ( level[footoffs].type == FLOOR ) + for ( a = 0; a < DUST_BLOCKS &&do_it == 0; a ++ ) + if ( level[footoffs].num == dust_blocks[a] ) do_it = 1; + if ( do_it ) + new_effect( 0, FOOTPRINT, footx, footy, 0, 0 ); +} + +void Player::move( int angle, float spd, int index ) +{ + int offs[2*4]; // ** + int reuna = 6; // * * chk pointit on n„in + int reuna2 = 4; // * * + int rnx, rny; // ** + int crate_taken = 0; + float newx, newy; + float speedi; + int chk, a, b; + + if ( WALK == ( int ) ( WALK_DELAY*0.25 ) ||WALK == ( int ) ( WALK_DELAY*0.75 ) ) footprint( 0 ); + if ( WALK == ( int ) ( WALK_DELAY*0.5 ) ||WALK == WALK_DELAY - 1 ) footprint( 1 ); + if ( energy < 20 ) // veren tiputus + if ( WALK % 4 == 0 ) + if ( rand() % 3 == 0 ) + new_effect( 0, BLOOD2, int( x ) + 15, int( y ) + 15, 0, 0 ); + speedi = spd; + newx = x + ( speedi*sini[angle] ); + newy = y + ( speedi*cosi[angle] ); + rnx = newx; + rny = newy; + offs[0] = ( ( rny + reuna ) / 20 ) *level_x_size + ( ( rnx + 14 - reuna2 ) / 20 ); + offs[1] = ( ( rny + reuna ) / 20 ) *level_x_size + ( ( rnx + 14 + reuna2 ) / 20 ); + offs[2] = ( ( rny + 28 - reuna ) / 20 ) *level_x_size + ( ( rnx + 14 - reuna2 ) / 20 ); + offs[3] = ( ( rny + 28 - reuna ) / 20 ) *level_x_size + ( ( rnx + 14 + reuna2 ) / 20 ); + offs[4] = ( ( rny + 14 - reuna2 ) / 20 ) *level_x_size + ( ( rnx + reuna ) / 20 ); + offs[5] = ( ( rny + 14 + reuna2 ) / 20 ) *level_x_size + ( ( rnx + reuna ) / 20 ); + offs[6] = ( ( rny + 14 - reuna2 ) / 20 ) *level_x_size + ( ( rnx + 28 - reuna ) / 20 ); + offs[7] = ( ( rny + 14 + reuna2 ) / 20 ) *level_x_size + ( ( rnx + 28 - reuna ) / 20 ); + if ( newy < y ) + if ( level[offs[0]].type == FLOOR ) + if ( level[offs[1]].type == FLOOR ) + { + for ( chk = 0, a = 0; a < ENEMIES; a ++ ) + if ( !enemy[a].DEAD ) + if ( rnx + 15 > enemy[a].x ) + if ( rnx + 15 < enemy[a].x + 30 ) + if ( rny + reuna > enemy[a].y + reuna ) + if ( rny + reuna < enemy[a].y + 28 - reuna ) chk = 1; + for ( b = 0; b < MAX_PLAYERS &&chk == 0; b ++ ) + if ( player[b].enabled) + if ( this != &player[b] ) + if ( !player[b].DEAD ) + if ( rnx + 15 > player[b].x ) + if ( rnx + 15 < player[b].x + 30 ) + if ( rny + reuna > player[b].y + reuna ) + if ( rny + reuna < player[b].y + 28 - reuna ) chk = 1; + if ( !chk ) y = newy; + } + if ( newy > y ) + if ( level[offs[2]].type == FLOOR ) + if ( level[offs[3]].type == FLOOR ) + { + for ( chk = 0, a = 0; a < ENEMIES; a ++ ) + if ( !enemy[a].DEAD ) + if ( rnx + 15 > enemy[a].x ) + if ( rnx + 15 < enemy[a].x + 30 ) + if ( rny + 28 - reuna > enemy[a].y + reuna ) + if ( rny + 28 - reuna < enemy[a].y + 28 - reuna ) chk = 1; + for ( b = 0; b < MAX_PLAYERS &&chk == 0; b ++ ) + if ( player[b].enabled) + if ( this != &player[b] ) + if ( !player[b].DEAD ) + if ( rnx + 15 > player[b].x ) + if ( rnx + 15 < player[b].x + 30 ) + if ( rny + 28 - reuna > player[b].y + reuna ) + if ( rny + 28 - reuna < player[b].y + 28 - reuna ) chk = 1; + if ( !chk ) y = newy; + } + if ( newx < x ) + if ( level[offs[4]].type == FLOOR ) + if ( level[offs[5]].type == FLOOR ) + { + for ( chk = 0, a = 0; a < ENEMIES; a ++ ) + if ( !enemy[a].DEAD ) + if ( rnx + reuna > enemy[a].x + reuna ) + if ( rnx + reuna < enemy[a].x + 28 - reuna ) + if ( rny + 15 > enemy[a].y ) + if ( rny + 15 < enemy[a].y + 30 ) chk = 1; + for ( b = 0; b < MAX_PLAYERS &&chk == 0; b ++ ) + if ( player[b].enabled) + if ( this != &player[b] ) + if ( !player[b].DEAD ) + if ( rnx + reuna > player[b].x + reuna ) + if ( rnx + reuna < player[b].x + 28 - reuna ) + if ( rny + 15 > player[b].y ) + if ( rny + 15 < player[b].y + 30 ) chk = 1; + if ( !chk ) x = newx; + } + if ( newx > x ) + if ( level[offs[6]].type == FLOOR ) + if ( level[offs[7]].type == FLOOR ) + { + for ( chk = 0, a = 0; a < ENEMIES; a ++ ) + if ( !enemy[a].DEAD ) + if ( rnx + 28 - reuna > enemy[a].x + reuna ) + if ( rnx + 28 - reuna < enemy[a].x + 28 - reuna ) + if ( rny + 15 > enemy[a].y ) + if ( rny + 15 < enemy[a].y + 30 ) chk = 1; + for ( b = 0; b < MAX_PLAYERS &&chk == 0; b ++ ) + if ( this != &player[b] ) + if ( player[b].enabled) + if ( !player[b].DEAD ) + if ( rnx + 28 - reuna > player[b].x + reuna ) + if ( rnx + 28 - reuna < player[b].x + 28 - reuna ) + if ( rny + 15 > player[b].y ) + if ( rny + 15 < player[b].y + 30 ) chk = 1; + if ( !chk ) x = newx; + } + for ( a = 0; a < MAX_CRATES; a ++ ) // laatikoiden ker„ys + if ( crate[a].IN_USE ) + if ( crate[a].text_count == 0 ) + if ( crate[a].x + 7 > x ) + if ( crate[a].x + 7 < x + 30 ) + if ( crate[a].y + 7 > y ) + if ( crate[a].y + 7 < y + 30 ) + { + crate_taken = 0; + if ( crate[a].type == 0 ) + if ( weapons[crate[a].weapon + 1] == 0 ) + { + weapons[crate[a].weapon + 1] = 1; crate_taken = 1; + } + if ( crate[a].type == 1 ) + if ( bullets[crate[a].bullet] < bullet_type[crate[a].bullet + 1].max*bullet_type[crate[a].bullet + 1].mul ) + { + bullets[crate[a].bullet] += bullet_type[crate[a].bullet + 1].amount_in_crate; + if ( bullets[crate[a].bullet] > bullet_type[crate[a].bullet + 1].max*bullet_type[crate[a].bullet + 1].mul ) bullets[crate[a].bullet] = bullet_type[crate[a].bullet + 1].max*bullet_type[crate[a].bullet + 1].mul; + crate_taken = 1; + } + if ( crate[a].type == 2 ) if ( energy < max_energy + shield*10 ) + { + energy += 40; if ( energy > max_energy + shield*10 ) energy = max_energy + shield*10; crate_taken = 1; + } + if ( crate_taken ) + { + MIDASplaySample( samplep[KLIKWAV], MIDAS_CHANNEL_AUTO, 0, 11250, EFFECT_VOLUME, MIDAS_PAN_MIDDLE ); + if ( crate[a].type == 0 ) + strcpy( crate[a].text, weapon[crate[a].weapon + 1].name ); + if ( crate[a].type == 1 ) + strcpy( crate[a].text, bullet_type[crate[a].bullet + 1].name ); + if ( crate[a].type == 2 ) + strcpy( crate[a].text, "Energy" ); + if ( index == 0 ) + { + crate[a].text_x = crate[a].x + 7 - str_length( crate[a].text ) - scr_x; + crate[a].text_y = crate[a].y + 7 - scr_y; + crate[a].text_count = get_dist( crate[a].text_x, crate[a].text_y, 10, scr_y_size - 20 ) + 1; + crate[a].text_angle = get_angle( crate[a].text_x, crate[a].text_y, 10, scr_y_size - 20 ); + } + if ( GAME_MODE == SPLIT_SCREEN ) + if ( index == 1 ) + { + crate[a].text_x = crate[a].x + 7 - str_length( crate[a].text ) - scr_x + 160; + crate[a].text_y = crate[a].y + 7 - scr_y; + crate[a].text_count = get_dist( crate[a].text_x, crate[a].text_y, 170, scr_y_size - 20 ) + 1; + crate[a].text_angle = get_angle( crate[a].text_x, crate[a].text_y, 170, scr_y_size - 20 ); + } + if (enabled) + if (GAME_MODE==NETWORK) + { + if (NETWORK_MODE==CLIENT) sendipx(0,IPX_UPDCRATE,(char)aplayer[0]->tindex,a); + else + for(b=1;btindex); + else + for(a=1;a= 360 ) angle -= 360; + if ( angle < 0 ) angle += 360; + rangle = angle / 9; + rangle2 = rangle*9; + + if (GAME_MODE==NETWORK) + { + if (NETWORK_MODE==CLIENT) sendipx(0,IPX_PLYRANGLE,(char)aplayer[0]->tindex); + else + for(a=1;a 100 ) scr_x = x - 80; + spd = abs( ( scr_x + 80 ) - ( ( 35*sini[angle] ) + x + 14 ) ) / 4; + if ( scr_x + 80 < ( 35*sini[angle] ) + x + 14 ) scr_x += spd; + if ( scr_x + 80 > ( 35*sini[angle] ) + x + 14 ) scr_x -= spd; + if ( scr_x < 0 ) scr_x = 0; + if ( scr_x > ( level_x_size*20 ) - 160 ) scr_x = ( level_x_size*20 ) - 160; + } + else + { + if ( abs( ( scr_x + 160 ) - ( x + 14 ) ) > 160 ) scr_x = x - 160; + spd = abs( ( scr_x + 160 ) - ( ( 25*sini[angle] ) + x + 14 ) ) / 4; + if ( scr_x + 160 < ( 25*sini[angle] ) + x + 14 ) scr_x += spd; + if ( scr_x + 160 > ( 25*sini[angle] ) + x + 14 ) scr_x -= spd; + if ( scr_x < 0 ) scr_x = 0; + if ( scr_x > ( level_x_size*20 ) - 320 ) scr_x = ( level_x_size*20 ) - 320; + } + if ( abs( ( scr_y + ( scr_y_size / 2 ) ) - ( y + 14 ) ) > 120 ) scr_y = y - ( scr_y_size / 2 ); + spd = abs( ( scr_y + ( scr_y_size / 2 ) ) - ( ( 25*cosi[angle] ) + y + 14 ) ) / 4; + if ( scr_y + ( scr_y_size / 2 ) < ( 25*cosi[angle] ) + y + 14 ) scr_y += spd; + if ( scr_y + ( scr_y_size / 2 ) > ( 25*cosi[angle] ) + y + 14 ) scr_y -= spd; + if ( scr_y > ( level_y_size*20 ) - scr_y_size ) scr_y = ( level_y_size*20 ) - scr_y_size; + if ( scr_y < 0 ) scr_y = 0; +} + +void Player::load() +{ + if ( load_cnt < weapon[curr_weapon].loading_time ) load_cnt ++; +} + +void Enemy::load() +{ + if ( load_cnt < weapon[enemy_info[type].curr_weapon].loading_time ) load_cnt ++; +} + +void Enemy::get_angles() +{ + int a, b; + for ( b = 0; b < MAX_PLAYERS; b ++ ) + if ( player[b].enabled) + { + a = 270 - get_angle( player[b].x, player[b].y, x, y ); + if ( a < 0 ) a += 360; + angle_pl[b] = a; + } +} + +void Enemy::try_see_players() +{ + int dist, a, b, min, max, rx, ry, hit = 0, go_on = 0; + int see[MAX_PLAYERS], saw[MAX_PLAYERS]; + int weakest = 0; + see_somebody = 0; + min = angle - 90; + if ( min < 0 ) min += 360; + max = angle + 90; + if ( max > 360 ) max -= 360; + for ( b = 0; b < MAX_PLAYERS; b ++ ) + if ( player[b].enabled) + see[b] = 0; + for ( b = 0; b < MAX_PLAYERS; b ++ ) + if ( player[b].enabled){ + if ( SEE_PL[b] ) saw[b] = 1;else saw[b] = 0; + } + for ( b = 0; b < MAX_PLAYERS; b ++ ) + if ( player[b].enabled) + SEE_PL[b] = 0; + for ( b = 0; b < MAX_PLAYERS; b ++ ) + if ( player[b].enabled) + { + go_on = 0; + hit = 0; + if ( !player[b].DEAD ) + { + if ( angle < 270 &&angle > 90 ) + { + // n„k”kentt„180 astetta + if ( angle_pl[b] > min &&angle_pl[b] < max ) go_on = 1; + } + else if ( angle_pl[b] > min ||angle_pl[b] < max ) go_on = 1; + } + if ( go_on ) + for ( a = 0; a < 8*4 &&hit == 0; a ++ ) + { + rx = 14 + x + ( a*5*sini[angle_pl[b]] ); + ry = 14 + y + ( a*5*cosi[angle_pl[b]] ); + if ( level[( ry / 20 ) *level_x_size + ( rx / 20 ) ].type!= FLOOR ) hit = 1; + if ( rx > player[b].x + 5 ) + if ( rx < player[b].x + 25 ) + if ( ry > player[b].y + 5 ) + if ( ry < player[b].y + 25 ) + { + SEE_PL[b] = 1; see[b] = 1; see_somebody = 1; + }; + } + } + if ( see_somebody ) + { + for ( b = 0; b < MAX_PLAYERS; b ++ ) + if (player[b].enabled) + if ( !player[b].DEAD ) + if ( see[b] ) weakest = b; + for ( b = 0; b < MAX_PLAYERS; b ++ ) + if ( player[b].enabled) + if ( !player[b].DEAD ) + if ( see[b] ) + { + if ( player[b].energy < player[weakest].energy ) weakest = b; + } + tangle = angle_pl[weakest]; + } + else + { + for ( b = 0; b < MAX_PLAYERS; b ++ ) + if ( player[b].enabled) + if ( saw[b] ) + { + dist = get_dist( x, y, player[b].x, player[b].y ); // chk the dist and be clever + walk_cnt = dist / enemy_info[type].speed; + if ( walk_cnt < 0 ) walk_cnt = 0; + } + } +} + +void Enemy::footprint( int side ) +{ + int a, do_it = 0, footx, footy, footoffs; + footx = x + 15 + ( sini[( angle + 90 + ( side*180 ) ) % 360]*4 ); + footy = y + 15 + ( cosi[( angle + 90 + ( side*180 ) ) % 360]*4 ); + footoffs = ( footy / 20 ) *level_x_size + ( footx / 20 ); + if ( level[footoffs].type == FLOOR ) + for ( a = 0; a < DUST_BLOCKS &&do_it == 0; a ++ ) + if ( level[footoffs].num == dust_blocks[a] ) do_it = 1; + if ( do_it ) + new_effect( 0, FOOTPRINT, footx, footy, 0, 0 ); +} + +void Enemy::move( int angle, int spd ) +{ + int offs[2*4]; + int reuna = 6; // p„„chk pointien et„isyys reunasta + int reuna2 = 4; // sivu chk pointien et„isyys p„„chk pointeista + int rnx, rny, speedi, chk, a; + float newx, newy, ox = x, oy = y; + if ( WALK == ( int ) ( WALK_DELAY*0.25 ) ||WALK == ( int ) ( WALK_DELAY*0.75 ) ) footprint( 0 ); + if ( WALK == ( int ) ( WALK_DELAY*0.5 ) ||WALK == WALK_DELAY - 1 ) footprint( 1 ); + if ( energy < 10 ) + if ( WALK % 4 == 0 ) + if ( rand() % 3 == 0 ) + new_effect( 0, BLOOD2, int( x ) + 15, int( y ) + 15, 0, 0 ); + if ( spd == 0 ) speedi = enemy_info[type].speed; + else speedi = spd; + newx = x + ( speedi*sini[angle] ); + newy = y + ( speedi*cosi[angle] ); + rnx = newx; + rny = newy; + offs[0] = ( ( rny + reuna ) / 20 ) *level_x_size + ( ( rnx + 14 - reuna2 ) / 20 ); + offs[1] = ( ( rny + reuna ) / 20 ) *level_x_size + ( ( rnx + 14 + reuna2 ) / 20 ); + offs[2] = ( ( rny + 28 - reuna ) / 20 ) *level_x_size + ( ( rnx + 14 - reuna2 ) / 20 ); + offs[3] = ( ( rny + 28 - reuna ) / 20 ) *level_x_size + ( ( rnx + 14 + reuna2 ) / 20 ); + offs[4] = ( ( rny + 14 - reuna2 ) / 20 ) *level_x_size + ( ( rnx + reuna ) / 20 ); + offs[5] = ( ( rny + 14 + reuna2 ) / 20 ) *level_x_size + ( ( rnx + reuna ) / 20 ); + offs[6] = ( ( rny + 14 - reuna2 ) / 20 ) *level_x_size + ( ( rnx + 28 - reuna ) / 20 ); + offs[7] = ( ( rny + 14 + reuna2 ) / 20 ) *level_x_size + ( ( rnx + 28 - reuna ) / 20 ); + chk = 0; + if ( newy < y ) + if ( level[offs[0]].type == FLOOR ) + if ( level[offs[1]].type == FLOOR ) + { + for ( chk = 0, a = 0; a < ENEMIES; a ++ ) + if ( &enemy[a]!= this ) + if ( !enemy[a].DEAD ) + if ( rnx + 15 > enemy[a].x ) + if ( rnx + 15 < enemy[a].x + 30 ) + if ( rny + reuna > enemy[a].y + reuna ) + if ( rny + reuna < enemy[a].y + 28 - reuna ) chk = 1; + for ( a = 0; a < MAX_PLAYERS &&chk == 0; a ++ ) + if ( player[a].enabled) + if ( !player[a].DEAD ) + if ( rnx + 15 > player[a].x ) + if ( rnx + 15 < player[a].x + 30 ) + if ( rny + reuna > player[a].y + reuna ) + if ( rny + reuna < player[a].y + 28 - reuna ) chk = 1; + if ( !chk ) y = newy; + } + chk = 0; + if ( newy > y ) + if ( level[offs[2]].type == FLOOR ) + if ( level[offs[3]].type == FLOOR ) + { + for ( chk = 0, a = 0; a < ENEMIES; a ++ ) + if ( &enemy[a]!= this ) + if ( !enemy[a].DEAD ) + if ( rnx + 15 > enemy[a].x ) + if ( rnx + 15 < enemy[a].x + 30 ) + if ( rny + 28 - reuna > enemy[a].y + reuna ) + if ( rny + 28 - reuna < enemy[a].y + 28 - reuna ) chk = 1; + for ( a = 0; a < MAX_PLAYERS &&chk == 0; a ++ ) + if ( player[a].enabled) + if ( !player[a].DEAD ) + if ( rnx + 15 > player[a].x ) + if ( rnx + 15 < player[a].x + 30 ) + if ( rny + 28 - reuna > player[a].y + reuna ) + if ( rny + 28 - reuna < player[a].y + 28 - reuna ) chk = 1; + if ( !chk ) y = newy; + } + chk = 0; + if ( newx < x ) + if ( level[offs[4]].type == FLOOR ) + if ( level[offs[5]].type == FLOOR ) + { + for ( chk = 0, a = 0; a < ENEMIES; a ++ ) + if ( &enemy[a]!= this ) + if ( !enemy[a].DEAD ) + if ( rnx + reuna > enemy[a].x + reuna ) + if ( rnx + reuna < enemy[a].x + 28 - reuna ) + if ( rny + 15 > enemy[a].y ) + if ( rny + 15 < enemy[a].y + 30 ) chk = 1; + for ( a = 0; a < MAX_PLAYERS &&chk == 0; a ++ ) + if ( player[a].enabled) + if ( !player[a].DEAD ) + if ( rnx + reuna > player[a].x + reuna ) + if ( rnx + reuna < player[a].x + 28 - reuna ) + if ( rny + 15 > player[a].y ) + if ( rny + 15 < player[a].y + 30 ) chk = 1; + if ( !chk ) x = newx; + } + chk = 0; + if ( newx > x ) + if ( level[offs[6]].type == FLOOR ) + if ( level[offs[7]].type == FLOOR ) + { + for ( chk = 0, a = 0; a < ENEMIES; a ++ ) + if ( &enemy[a]!= this ) + if ( !enemy[a].DEAD ) + if ( rnx + 28 - reuna > enemy[a].x + reuna ) + if ( rnx + 28 - reuna < enemy[a].x + 28 - reuna ) + if ( rny + 15 > enemy[a].y ) + if ( rny + 15 < enemy[a].y + 30 ) chk = 1; + for ( a = 0; a < MAX_PLAYERS &&chk == 0; a ++ ) + if ( player[a].enabled) + if ( !player[a].DEAD ) + if ( rnx + 28 - reuna > player[a].x + reuna ) + if ( rnx + 28 - reuna < player[a].x + 28 - reuna ) + if ( rny + 15 > player[a].y ) + if ( rny + 15 < player[a].y + 30 ) chk = 1; + if ( !chk ) x = newx; + } +} + +void Enemy::get_damage( float damage, Player *P ) +{ + int pan = 0, a, alku = rand() % 7, spd = 1 + damage / 3; + spd += ( PUSH_POWER / 3 ); + if ( spd > 5 ) spd = 5; + if ( GAME_MODE!= SPLIT_SCREEN ) + pan = get_pan( player[0].x , x ); + energy -= damage; + if ( energy <= 0 ) + { + if ( burning && ! enemy_info[type].explo_death) + { + MIDASplaySample( samplep[WOOSHWAV], MIDAS_CHANNEL_AUTO, 0, 20000, EFFECT_VOLUME, pan ); + new_effect( &explo_l, EXPLO, x + 12, y + 12, 0, 0 ); + new_effect( &explo_l, EXPLO, x + 18, y + 12, 0, 0 ); + new_effect( &explo_l, EXPLO, x + 15, y + 18, 0, 0 ); + for ( a = 0; a < 3; a ++ ) + new_body_part( x + 4, y + 4, rand() % 360, 5, a + 12 ); + } + if ( ! burning && ! enemy_info[type].explo_death) + { + for ( a = 0; a < 16; a ++ ) + if ( rand() % 2 ) + new_effect( 0, BLOOD, x + 15, y + 15, a*22.5, 4 ); + for ( a = 0; a < 3; a ++ ) + new_body_part( x + 4, y + 4, rand() % 360, spd + ( rand() % 2 ), ( a + alku ) % 7 ); + MIDASplaySample( samplep[DEATHWAV], MIDAS_CHANNEL_AUTO, 0, 20000 - ( rand() % 3000 ), EFFECT_VOLUME, pan ); + } + if (enemy_info[type].explo_death) + { + explo( x+4, y+4, 2, -1); + for ( a = 0; a < 3; a ++ ) + new_body_part( x + 4, y + 4, rand() % 360, 5, a + 12 ); + } + + DEAD = 1; + DEAD_ENEMIES ++; + if ( KILLING_MODE!= DEATHMATCH ) if ( DEAD_ENEMIES >= ENEMIES ) next_level = 1; + if ( P!= NULL ) + P-> kills[type] ++; + } +} + +void Player::get_damage( float damage, Player *P ) +{ char buf[MAX_MESSAGE_LENGTH]; + int a,b; + HIT = 15; + energy -= damage; + if ( energy <= 0 ) + { + + if (KILLING_MODE==DEATHMATCH) + { + if (P->tindex!=tindex) + sprintf(buf,killtexts[rand()%ktexts],P->name,name); + else + sprintf(buf,suicidetexts[rand()%stexts],P->name,name); + message_board.add_message(buf); + } + + for (a=0;aplayer_kills++; + else player_kills --; + + if (GAME_MODE==NETWORK) + { + if (NETWORK_MODE==CLIENT) sendipx(0,IPX_UPDKILLS,(char)aplayer[0]->tindex,P->tindex); + else + for(b=1;btindex); + } + + } + } +} + +void Player::see() +{ + int offs, a, b, ang, stop; + int tx, ty, mx, my, ox, oy, nx, ny; + int range = 12, korona = 2*pi*range + 5; + tx = ( x + 15 ) / 20; + ty = ( y + 15 ) / 20; + for ( a = 0; a < korona; a ++ ) + { + ang = ( int ) ( a*( 360 / ( float ) korona ) ) % 360; + stop = 0; + nx = 0; + ny = 0; + for ( b = 0; b < range &&stop == 0; b ++ ) + { + ox = nx; + oy = ny; + nx = ( int ) ( b*sini[ang] ); + ny = ( int ) ( b*cosi[ang] ); + mx = nx - ox; + my = ny - oy; + offs = ( ( ty + oy ) *level_x_size ) + ox + tx; + if ( abs( mx ) == 1 &&abs( my ) == 1 ) + if ( level[offs + mx].type!= FLOOR &&level[offs + ( my*level_x_size ) ].type!= FLOOR ) + stop = 1; + offs = ( ( ty + ny ) *level_x_size ) + nx + tx; + if ( level[offs].type!= FLOOR ) stop = 1; + if ( !stop ) see_level[offs] = 1; + } + } +} + +void Bullet::move() +{ + int bp, speed, vx, vy, a, b, rx = x, ry = y, hit = 0, kosh = 0; + int looptimes; + + speed = type-> speed; + looptimes = speed >> 2; + if ( speed == 0 ) looptimes = 1; + time --; + count ++; + for( a = 0; a < looptimes &&hit == 0 &&kosh == 0 ; a ++ ) + { + if ( speed > 0 ) + { + x += ( float ) speed / ( speed >> 2 ) *sini[angle]; + y += ( float ) speed / ( speed >> 2 ) *cosi[angle]; + } + rx = x; + ry = y; + if ( type-> speed > 0 ) + if ( level[( int ) ( ry / 20 ) *level_x_size + ( int ) ( rx / 20 ) ].type!= FLOOR ) + { + kosh = 1; + } + if ( count > type-> sleep_time ) + if ( type-> stop ) + { + if (!(GAME_MODE == NETWORK && NETWORK_MODE == CLIENT)) + for ( b = 0; b < ENEMIES; b ++ ) // chk for enemy + if ( !enemy[b].DEAD ) + if ( rx > enemy[b].x + 5 ) + if ( rx < enemy[b].x + 22 ) + if ( ry > enemy[b].y + 5 ) + if ( ry < enemy[b].y + 22 ) + { + hit = 1; + if ( P!= NULL ) + enemy[b].tangle = enemy[b].angle_pl[index];// „ij„k„„ntyy kohti, kun sit„ampuu + vx = enemy[b].x + 14 + ( 4*sini[angle] ); + vy = enemy[b].y + 14 + ( 4*cosi[angle] ); + enemy[b].PUSH_ANGLE = angle;// „ij„lent„„ + if ( type-> push_power > enemy[b].PUSH_POWER ) + enemy[b].PUSH_POWER = ( float ) type-> push_power;// „ij„lent„„ + enemy[b].get_damage( type-> power, P ); + if ( type-> type == INCENDIARY ) + { + enemy[b].burning += 10; + enemy[b].Frying_player = P; + } + } + + for ( b = 0; b < MAX_PLAYERS; b ++ ) + if ( player[b].enabled ) + if ( !player[b].DEAD ) + if ( rx > player[b].x + 5 ) + if ( rx < player[b].x + 22 ) + if ( ry > player[b].y + 5 ) + if ( ry < player[b].y + 22 ) + { + hit = 1; + vx = player[b].x + 14 + ( 4*sini[angle] ); + vy = player[b].y + 14 + ( 4*cosi[angle] ); + if ( (GAME_MODE!=NETWORK) || (aplayer[0]==&player[b])) + { + player[b].PUSH_ANGLE = angle;// „ij„lent„„ + if ( type-> push_power > player[b].PUSH_POWER ) + player[b].PUSH_POWER = ( float ) type-> push_power;// „ij„lent„„ + player[b].get_damage( type-> power, P ); + if ( type-> type == INCENDIARY ) + { + player[b].burning += 10; + player[b].Frying_player = P; + } + } + } + } + } + if ( type-> type == NORMAL ) + if ( kosh ) if ( rand() % 8 == 1 ) new_effect( &normal_l, METAL, rx, ry, rand() % 360, ( rand() % 3 ) + 5 ); + + if ( hit ) + { + if ( type-> type == NORMAL ) + { + + bp = 6 + ( type-> power / 3 ) + rand() % 3; + if ( bp > 8 ) bp = 8; + for ( a = 0; a < ( type-> power / 5 ) + 1; a ++ ) + new_effect( 0, BLOOD, vx + ( rand() % 6 ) - 3, vy + ( rand() % 6 ) - 3, angle + ( ( rand() % 30 ) - 15 ), bp ); + } + if ( P!=NULL ) P->hitten++; + if ( type-> speed < 10 &&type-> time == 1 ) // if fist + { + if (GAME_MODE==SPLIT_SCREEN) + MIDASplaySample( samplep[weapon[0].sound], MIDAS_CHANNEL_AUTO, 0, sample_rates[0], EFFECT_VOLUME, MIDAS_PAN_MIDDLE ); + else + MIDASplaySample( samplep[weapon[0].sound], MIDAS_CHANNEL_AUTO, 0, sample_rates[0], get_volume(aplayer[0]->x,aplayer[0]->y,rx,ry),get_pan(aplayer[0]->x,rx) ); + } + } + + + if ( type-> type == NORMAL ) + if ( !hit ) + if ( time == 0 ||kosh ) + { + if ( type-> speed < 10 &&type-> time == 1 ) + { + } + else new_effect( &normal_l, SMOKE, rx, ry, 0, 0 ); + } + if ( hit ||kosh ||time == 0 ) + { + if ( type-> type == EXPLOSIVE ) explo( rx - ( 5*sini[angle] ), ry - ( 5*cosi[angle] ), type-> explos, index ); + IN_USE = 0; + } + if ( type-> effect!= 0 ) + if ( type-> effect == EXPLO ) new_effect( &explo_l, type-> effect, rx, ry, angle + 180, 1 ); + else new_effect( 0, type-> effect, rx, ry, 0, 0 ); +} + +void Player::shoot() +{ + int r, a, rx = x, ry = y; + FIRE = 1; + load_cnt = 0; + for ( a = 0; a < weapon[curr_weapon].bullet_amount; a ++ ) + { + shooted ++; + r = ( weapon[curr_weapon].angle_add >> 1 ) - rand() % weapon[curr_weapon].angle_add; + new_bullet( weapon[curr_weapon].btype, rx + 14 + ( 10*sini[rangle2] ), ry + 14 + ( 10*cosi[rangle2] ), rangle2 + r, 0, tindex); + } + if ( curr_weapon > 0 ) bullets[weapon[curr_weapon].btype - 1] --; + if ( curr_weapon > 0 ) + if ( shoot_cnt % bullet_type[weapon[curr_weapon].btype].mul == 0 ) + { + if ( weapon[curr_weapon].sound != NULL ) + { + MIDASplaySample( samplep[weapon[curr_weapon].sound], MIDAS_CHANNEL_AUTO, 0, sample_rates[curr_weapon], EFFECT_VOLUME, MIDAS_PAN_MIDDLE ); + if (GAME_MODE==NETWORK) + { + if (NETWORK_MODE==CLIENT) + sendipx(0,IPX_SOUND,tindex,(char)weapon[curr_weapon].sound,sample_rates[curr_weapon],rx,ry); + else + for (a=1;a 63 ) pan = 63; + } + if ( weaponi > 0 ) + if ( shoot_cnt % bullet_type[weapon[weaponi].btype].mul == 0 ) + MIDASplaySample( samplep[weapon[weaponi].sound], MIDAS_CHANNEL_AUTO, 0, sample_rates[weaponi], EFFECT_VOLUME, pan ); + if ( shoot_cnt % bullet_type[weapon[weaponi].btype].mul == 0 ) + if ( weapon[weaponi].smoke ) + new_effect( 0, SMOKE3, rx + 14 + ( 8*sini[( int ) ( rangle*9 ) ] + 5*sini[( ( int ) ( rangle*9 ) + 270 ) % 360] ), ry + 14 + ( 8*cosi[( int ) ( rangle*9 ) ] + 5*cosi[( ( int ) ( rangle*9 ) + 270 ) % 360] ), angle, 1 ); +} + +void Enemy::chk_for_shoot() +{ + int dist, a, wannashoot = 0; + if ( enemy_info[type].curr_weapon > 0 ) + for ( a = 0; a < MAX_PLAYERS; a ++ ) + if ( player[a].enabled) + if ( SEE_PL[a] ) + if ( tangle == angle ) + { + shoot_cnt ++; + wannashoot = 1; + if ( load_cnt == weapon[enemy_info[type].curr_weapon].loading_time ) + { + shoot(); + dist = get_dist( x, y, player[a].x, player[a].y ); // chk if close enough + if ( dist > bullet_type[weapon[enemy_info[type].curr_weapon].btype].time*bullet_type[weapon[enemy_info[type].curr_weapon].btype].speed ) + walk_cnt = 20 / enemy_info[type].speed; + } + } + if ( !wannashoot ) shoot_cnt = 0; + } + +void Enemy::rotate() +{ + // Nerokas k„„ntymis funktio !!! + int kaanty_jo = 0; + if ( angle!= tangle ) + { + if ( angle < 180 ) + { + if ( tangle < angle + 180 &&tangle > angle ) angle += ROT_SPEED; else angle -= ROT_SPEED; + kaanty_jo = 1; + } + if ( angle >= 180 &&kaanty_jo == 0 ) + if ( tangle > angle - 180 &&tangle < angle ) angle -= ROT_SPEED; else angle += ROT_SPEED; + angle%= 360; + if ( angle < 0 ) angle += 360; + // v„h„n py”ristyst„, niin angle saavuttaa joskus tanglen ... + if ( abs( angle - tangle ) < ROT_SPEED ||abs( ( angle + 360 ) - tangle ) < ROT_SPEED ) angle = tangle; + } +} + +void Level::load( char name[13] ) +{ + int a, bullets, weapons; + FILE *dat; + dat = fopen( name, "rb" ); + if ( dat != NULL ) + { + fread( &version, 4, 1, dat ); + if (version>5) {vesa_set_mode(0x3);cout<<"Invalid level version: Get newer version of TK !";exit(1);} + fread( &level_x_size, 4, 1, dat ); + fread( &level_y_size, 4, 1, dat ); + level = ( struct BLOCK* ) malloc( level_y_size*level_x_size*sizeof( struct BLOCK ) ); + fread( level, sizeof( struct BLOCK ) *level_x_size*level_y_size, 1, dat ); + fread( &pl_start_x[0], 4, 1, dat ); + fread( &pl_start_y[0], 4, 1, dat ); + fread( &pl_start_x[1], 4, 1, dat ); + fread( &pl_start_y[1], 4, 1, dat ); + fread( &Spot_amount, 4, 1, dat ); + for ( a = 0; a < Spot_amount; a ++ ) + { + fread( &spot_light[a].x, 4, 1, dat ); + fread( &spot_light[a].y, 4, 1, dat ); + fread( &spot_light[a].size, 4, 1, dat ); + } + fread( &Steam_amount, 4, 1, dat ); + for ( a = 0; a < Steam_amount; a ++ ) + { + fread( &steam[a].x, 4, 1, dat ); + fread( &steam[a].y, 4, 1, dat ); + fread( &steam[a].angle, 4, 1, dat ); + fread( &steam[a].speed, 4, 1, dat ); + } + + fread(general_level_info.comment,20, 1, dat); + fread(&general_level_info.time_limit,4, 1, dat); + memset(general_level_info.enemies,0,4*DIFF_ENEMIES); + if (version>=4) + fread(general_level_info.enemies,4*DIFF_ENEMIES, 1, dat); + if (version<4) + fread(general_level_info.enemies,4*(DIFF_ENEMIES-1), 1, dat); + + if ( version == 1 ){ + weapons = DIFF_WEAPONS - 2; bullets = DIFF_BULLETS - 2; + } + if ( version == 2 ){ + weapons = DIFF_WEAPONS - 1; bullets = DIFF_BULLETS - 1; + } + if ( version == 3 || version >= 4){ + weapons = DIFF_WEAPONS; bullets = DIFF_BULLETS; + } + fread( normal_game_level_info.weapon_crates, 4 * weapons, 1, dat ); + fread( normal_game_level_info.bullet_crates, 4 * bullets, 1, dat ); + fread( &normal_game_level_info.energy_crates, 4, 1, dat ); + fread( death_match_level_info.weapon_crates, 4 * weapons, 1, dat ); + fread( death_match_level_info.bullet_crates, 4 * bullets, 1, dat ); + fread( &death_match_level_info.energy_crates, 4, 1, dat ); + + if (version>=5){ + fread( &normal_crate_amount, 4, 1, dat ); + fread( normal_crate_info, sizeof(Crate_info) * normal_crate_amount, 1, dat ); + fread( &deathmatch_crate_amount, 4, 1, dat ); + fread( deathmatch_crate_info, sizeof(Crate_info) * deathmatch_crate_amount, 1, dat ); + } + fclose( dat ); + } + else cout << "Level file missing ! \n"; +} + +void Keys::change() +{ + int a = 0, quit = 0, cnt = 0, oclock = 0, selected = 0, b = 0; + first = 1; + fadeout( virbuff, pal ); + load_efp( "efps\\cool.efp", picture, 0 ); + draw_box1( 10, 10, 310, 32, 10 ); + draw_box1( 10, 40, 310, 190, 10 ); + while( !quit ) + { + memcpy( virbuff, picture, 64000 ); + FONT_NUM = 0; + writefonts2( 160 - ( str_length( "define keys" ) / 2 ), 13, "define keys", 1 ); + for ( a = 0; a < DIFF_K; a ++ ) + { + if ( a == selected ) + { + FONT_NUM = 1; + writefonts( 40, 50 + ( a*8 ), k_text[a], M_YELLOW ); + } + else + { + FONT_NUM = 1; + writefonts( 40, 50 + ( a*8 ), k_text[a], M_RED ); + } + } + for ( a = 0; a < DIFF_K - 1; a ++ ) + { + switch ( a ) + { + case 0:b = K_UP;break; + case 1:b = K_DOWN;break; + case 2:b = K_LEFT;break; + case 3:b = K_RIGHT;break; + case 4:b = K_SHOOT;break; + case 5:b = K_SHIFT;break; + case 6:b = K_STRAFE;break; + case 7:b = K_LSTRAFE;break; + case 8:b = K_RSTRAFE;break; + } + if ( selected == a ) + { + FONT_NUM = 1; + writefonts( 190, 50 + ( a*8 ), k_2_c( b ), M_YELLOW ); + } + else + { + FONT_NUM = 1; + writefonts( 190, 50 + ( a*8 ), k_2_c( b ), M_RED ); + } + } + if ( first == 1 ) + { + fadein( virbuff, pal ); first = 0; + } + memcpy( screen, virbuff, 64000 ); + while ( !k.state[1]&&!k.state[94]&&!k.state[99]&&!k.state[28] ) + if ( clock() != oclock ) + { + oclock = clock(); + draw_ball( 20, 45 + ( selected*8 ), cnt ); + cnt ++; + if ( cnt > 23 ) cnt = 0; + } + MIDASplaySample( samplep[KLIKWAV], MIDAS_CHANNEL_AUTO, 0, 22500, EFFECT_VOLUME, MIDAS_PAN_MIDDLE ); + if ( k.state[94] ) + { + selected --;if ( selected < 0 ) selected = DIFF_K - 1; k.state[94] = 0; + } + if ( k.state[99] ) + { + selected ++;if ( selected >= DIFF_K ) selected = 0; k.state[99] = 0; + } + if ( k.state[28] ) + { + k.state[28] = 0; + k.clear_stack(); + if ( selected == 0 ) + { + clear_shit( 47 ); K_UP = get_key( 160, 45 ); + } + if ( selected == 1 ) + { + clear_shit( 47 + 8 ); K_DOWN = get_key( 160, 45 + 8 ); + } + if ( selected == 2 ) + { + clear_shit( 47 + ( 2*8 ) ); K_LEFT = get_key( 160, 45 + ( 2*8 ) ); + } + if ( selected == 3 ) + { + clear_shit( 47 + ( 3*8 ) ); K_RIGHT = get_key( 160, 45 + ( 3*8 ) ); + } + if ( selected == 4 ) + { + clear_shit( 47 + ( 4*8 ) ); K_SHOOT = get_key( 160, 45 + ( 4*8 ) ); + } + if ( selected == 5 ) + { + clear_shit( 47 + ( 5*8 ) ); K_SHIFT = get_key( 160, 45 + ( 5*8 ) ); + } + if ( selected == 6 ) + { + clear_shit( 47 + ( 6*8 ) ); K_STRAFE = get_key( 160, 45 + ( 6*8 ) ); + } + if ( selected == 7 ) + { + clear_shit( 47 + ( 7*8 ) ); K_LSTRAFE = get_key( 160, 45 + ( 7*8 ) ); + } + if ( selected == 8 ) + { + clear_shit( 47 + ( 8*8 ) ); K_RSTRAFE = get_key( 160, 45 + ( 8*8 ) ); + } + if ( selected == 9 ) + { + quit = 1; + } + } + if ( k.state[1] ) + { + quit = 1; k.state[1] = 0; + } + } + fadeout( virbuff, pal ); +} + diff --git a/SRC/CLASSES.H b/SRC/CLASSES.H new file mode 100644 index 0000000..27adc32 --- /dev/null +++ b/SRC/CLASSES.H @@ -0,0 +1,262 @@ +#ifndef __TK__CLASSES__ +#define __TK__CLASSES__ +#include "defines.h" +#include "types.h" +#include "ipx/ipx.h" + +class Crate_info +{ + public: + int type1; + int type2; + int x,y; +}; + +class Message_board +{ + public: + int messages; + int time_count; + char message[MAX_MESSAGES][MAX_MESSAGE_LENGTH]; + void add_message(char msg[MAX_MESSAGE_LENGTH]); + void draw(); + void clear(); +}; + +class Crate +{ + public: + int type; + int weapon; + int bullet; + int energy; + int x, y; + int IN_USE; + int text_angle; + int text_count; + int wake_up_count; + float text_x, text_y; + char text[20]; + void move_text(); + void chk_wake_up(int); +}; + +class General_level_info +{ + public: + char comment[20]; + int time_limit;// seconds + int enemies[DIFF_ENEMIES]; +}; + +class Normal_game_level_info +{ + public: + int weapon_crates[DIFF_WEAPONS]; + int bullet_crates[DIFF_BULLETS]; + int energy_crates; +}; + +class Death_match_level_info +{ + public: + int weapon_crates[DIFF_WEAPONS]; + int bullet_crates[DIFF_BULLETS]; + int energy_crates; +}; + +class Spot +{ + public: + int x; + int y; + int size; +}; + +class Steam +{ + public: + int x; + int y; + int angle; + int speed; +}; + +class Light_table +{ + public: + char data[256][16]; +}; + +class Body_part +{ + public: + float x, y; + int angle; + int num; + float speed; + int IN_USE; + void move(); +}; + +class Effect_type +{ + public: + int index; + int tcount; + int order; + int delay; + int random;// boolean + int xs, ys, offs; +}; + +class Bullet_type +{ + public: + char name[20]; + int type; + int stop; + int speed; + float power; + int time; + int explos;// power of explosive + int push_power; + int cost; + int amount_in_crate; + int mul; + int sleep_time; + int max; + char *sprite; + int xs, ys, offs, xsize; + Light_table *light; + int lsize; + int llum; + float ladd; + int effect; +}; + +class Effect +{ + public: + float x, y; + int angle; + int speed; + Effect_type *type; + int count; + int IN_USE; + Light_table *lt; + int age; + void roll(); +}; + +class Player +{ + public: + int tindex; + float x, y; + int enabled; + char *see_level; + int time_since_last_alive; + int speed, angle, rangle, rangle2, scr_x, scr_y; + int weapons[DIFF_WEAPONS + 1]; + int curr_weapon, load_cnt; + int shoot_cnt; + int bullets[DIFF_BULLETS]; + int cash; + int max_energy; + float energy; + int shield; + int color; + int burning; + Player *Frying_player; + nodeaddr ipxnode; + char name[10]; + int HIT, WALK, FIRE, DEAD, KICK, ANIM; + int K_LEFT, K_RIGHT, K_UP, K_DOWN, K_SHOOT, K_SHIFT, K_STRAFE, K_LSTRAFE, K_RSTRAFE; + int TARGET; + float PUSH_POWER; + int PUSH_ANGLE; + int kills[DIFF_ENEMIES]; + int total_kills; + int shooted, hitten; + int player_kills; + void footprint( int side ); + void kick_body_parts(); + void chk_keys( int index ); + void animate(); + void move( int angle, float spd, int index ); + void shoot(); + void load(); + void change_weapon(); + void get_damage( float damage, Player *P ); + void rotate( int change ); + void move_scr(); + void shop(); + void see(); + void random_place(); + void death_match_start_up(); +}; + +class Bullet +{ + public: + float x, y; + Bullet_type *type; + Player *P; + int index; + int angle; + int time; + int count; + int IN_USE; + void move(); +}; + +class Keys +{ + public: + int K_LEFT, K_RIGHT, K_UP, K_DOWN, K_SHOOT, K_SHIFT, K_STRAFE, K_LSTRAFE, K_RSTRAFE; + void change(); +}; + +class Enemy +{ + public: + float x, y; + int angle, rangle, tangle, walk_cnt, load_cnt; + float energy; + int shoot_cnt; + int angle_pl[MAX_PLAYERS]; + int type; + int burning; + Player *Frying_player; + float PUSH_POWER; + int PUSH_ANGLE; + int WALK, FIRE, SEE_PL[MAX_PLAYERS], DEAD, ANIM; + int see_somebody; + void footprint( int side ); + void animate(); + void move( int angle, int spd ); + void shoot(); + void rotate(); + void get_angles(); + void get_damage( float damage, Player *P ); + void try_see_players(); + void load(); + void chk_for_shoot(); +}; + +class Light +{ + public: + char *data; + void make( int size ); +}; + +class Level +{ + public: + int version; + void load( char name[13] ); +}; + +#endif diff --git a/SRC/CLASSES.OBJ b/SRC/CLASSES.OBJ new file mode 100644 index 0000000..b3783ca Binary files /dev/null and b/SRC/CLASSES.OBJ differ diff --git a/SRC/DEFINES.BAK b/SRC/DEFINES.BAK new file mode 100644 index 0000000..6f749cb --- /dev/null +++ b/SRC/DEFINES.BAK @@ -0,0 +1,66 @@ +#ifndef __TK__DEFINES__ +#define __TK__DEFINES__ +#define Version "v1.2 beta" +#define pi 3.14159265358979 +#define CRATE_WAKE_UP_COUNT 500 // = 12.5 secs if 40 frames per sec +#define MESSAGE_TIME_ON_SCREEN 200 // = 5 secs if 40 frames per sec +#define MAX_MESSAGES 6 +#define MAX_MESSAGE_LENGTH 40 +#define MAX_PLAYERS 8 // max amount of players in game +#define DIFF_BULLETS 9 +#define DIFF_WEAPONS 11 +#define DIFF_ENEMIES 8 +#define ONE_PLAYER 0 +#define SPLIT_SCREEN 1 +#define NETWORK 2 +#define COOPERATIVE 0 +#define DEATHMATCH 1 +#define NORMAL 0 // panos tyyppej„ +#define EXPLOSIVE 1 +#define INCENDIARY 2 +#define FLOOR 0 // blockki tyyppej„ +#define WALLS 1 +#define MAX_ENEMIES 100 // max amount of enemies in game +#define MAX_BODY_PARTS 300 // max amount of bodyparts in game +#define MAX_EFFECTS 300 // max amount of effects in game +#define MAX_BULLETS 300 // max amount of bullets in game +#define MAX_SPOTS 100 // max amount of spot lights in game +#define MAX_STEAM 100 // max amount of steams in game +#define MAX_CRATES 200 // max amount of crates in game +#define MAX_CRATE_INFO 100 // max amount of crates in game +#define WALK_DELAY 20 // walk animation delay +#define DEAD_DELAY 15 // dead animation delay +#define C_DELAY 300 // level complete delay +#define ROT_SPEED 9 // computer players rotate speed +#define M_BLUE 113 // punainen +#define M_RED 64 // sinert„v„ +#define M_YELLOW 144 // keltainen +#define TIME_ADD 1.1 // action time'll be multiplied with this +#define LIGHTS 10 +#define TARGET_FRAMES 40 +#define DUST_BLOCKS 10 +#define Menu_texts 4 +#define num_options 4 +#define num_player_options 5 +#define num_game_options 4 +#define num_sound_options 3 +#define num_deathmatch_options 4 +#define num_multip_options 7 +#define DIFF_K 10 +#define SPEC_K 21 + // Effects... +#define BLOOD 0 // effects +#define SMOKE 1 +#define EXPLO 2 +#define METAL 3 +#define SMOKE2 4 +#define BLOOD2 5 +#define SMOKE3 6 +#define STEAM 7 +#define TELEPORT 8 +#define FOOTPRINT 9 +#define EXPLO_RAY 10 + +#define min(a,b) ((a)<=(b)? (a):(b)) + +#endif diff --git a/SRC/DEFINES.H b/SRC/DEFINES.H new file mode 100644 index 0000000..ca6001d --- /dev/null +++ b/SRC/DEFINES.H @@ -0,0 +1,79 @@ +#ifndef __TK__DEFINES__ +#define __TK__DEFINES__ +#define Version "v1.2 beta" +#define pi 3.14159265358979 +#define CRATE_WAKE_UP_COUNT 500 // = 12.5 secs if 40 frames per sec +#define MESSAGE_TIME_ON_SCREEN 200 // = 5 secs if 40 frames per sec +#define MAX_MESSAGES 6 +#define MAX_MESSAGE_LENGTH 40 +#define MAX_PLAYERS 8 // max amount of players in game +#define DIFF_BULLETS 9 +#define DIFF_WEAPONS 11 +#define DIFF_ENEMIES 8 +#define ONE_PLAYER 0 +#define SPLIT_SCREEN 1 +#define NETWORK 2 +#define COOPERATIVE 0 +#define DEATHMATCH 1 +#define NORMAL 0 // panos tyyppej„ +#define EXPLOSIVE 1 +#define INCENDIARY 2 +#define FLOOR 0 // blockki tyyppej„ +#define WALLS 1 +#define MAX_ENEMIES 100 // max amount of enemies in game +#define MAX_BODY_PARTS 300 // max amount of bodyparts in game +#define MAX_EFFECTS 300 // max amount of effects in game +#define MAX_BULLETS 300 // max amount of bullets in game +#define MAX_SPOTS 100 // max amount of spot lights in game +#define MAX_STEAM 100 // max amount of steams in game +#define MAX_CRATES 200 // max amount of crates in game +#define MAX_CRATE_INFO 100 // max amount of pointed crates in game +#define WALK_DELAY 20 // walk animation delay +#define DEAD_DELAY 15 // dead animation delay +#define C_DELAY 300 // level complete delay +#define ROT_SPEED 9 // computer players rotate speed +#define M_BLUE 113 // punainen +#define M_RED 64 // sinert„v„ +#define M_YELLOW 144 // keltainen +#define TIME_ADD 1.1 // action time'll be multiplied with this +#define LIGHTS 10 +#define TARGET_FRAMES 40 // framerate +#define DUST_BLOCKS 10 +#define Menu_texts 4 +#define num_options 4 +#define num_player_options 5 +#define num_game_options 4 +#define num_sound_options 3 +#define num_deathmatch_options 4 +#define num_multip_options 7 +#define DIFF_K 10 +#define SPEC_K 21 + // Effects... +#define BLOOD 0 +#define SMOKE 1 +#define EXPLO 2 +#define METAL 3 +#define SMOKE2 4 +#define BLOOD2 5 +#define SMOKE3 6 +#define STEAM 7 +#define TELEPORT 8 +#define FOOTPRINT 9 +#define EXPLO_RAY 10 +// Sounds... +#define DIFF_WAVS 10 + +#define MAGNUMWAV 1 +#define SHOTGUNWAV 2 +#define PISTOLWAV 3 +#define SINKOWAV 4 +#define HITWAV 5 +#define EXPLOWAV 6 +#define KLIKWAV 7 +#define DEATHWAV 8 +#define WOOSHWAV 9 +#define FLAMEWAV 10 + +#define min(a,b) ((a)<=(b)? (a):(b)) + +#endif diff --git a/SRC/DRAW.BAK b/SRC/DRAW.BAK new file mode 100644 index 0000000..b86d9ac --- /dev/null +++ b/SRC/DRAW.BAK @@ -0,0 +1,976 @@ +#include < stdlib.h > +#include < stdio.h > +#include < string.h > +#include < gfunc.h > +#include "defines.h" +#include "types.h" +#include "globvar.h" +#include "classes.h" +#include "write.h" + + // 20 x 20 +void draw_block( int x, int y, int type, int num, int mode ) +{ + int a, offs; + char *texture, *gofs; + int sx = 0, ex = 20, sy = 0, ey = 20; + if ( x < 0 ) sx = - x; + if ( sx > 20 ) sx = 20; + if ( x > 300 ) ex = 20 - ( x - 300 ); + if ( ex < 0 ) ex = 0; + if ( y < 0 ) sy = - y; + if ( sy > 20 ) sy = 20; + if ( y > scr_y_size - 20 ) ey = 20 - ( y - ( scr_y_size - 20 ) ); + if ( ey < 0 ) ey = 0; + if ( mode == 1 ) + { + // split mode pl1 + if ( x > 140 ) ex = 20 - ( x - 140 ); + if ( ex < 0 ) ex = 0; + } + if ( mode == 2 ) + { + // split mode pl2 + if ( x < 161 ) sx = 161 - x; + if ( sx > 20 ) sx = 20; + } + offs = ( ( num&15 ) *20 ) + ( num / 16*320*20 ) + sy*320; + gofs = virbuff + (( y + sy ) *320 + x + sx); + if ( type == FLOOR ) texture = floorspr + offs + sx; + if ( type == WALLS ) texture = wallspr + offs + sx; + for ( a = sy; a < ey; a ++ ) + { + memcpy( gofs, texture, ex - sx ); + texture += 320; + gofs += 320; + } +} + + // 20 x 20 +void draw_dark_block( int x, int y, int num, int mode ) +{ + int a, offs; + char *gofs; + + int sx = 0, ex = 20, sy = 0, ey = 20; + if ( x < 0 ) sx = - x; + if ( sx > 20 ) sx = 20; + if ( x > 300 ) ex = 20 - ( x - 300 ); + if ( ex < 0 ) ex = 0; + if ( y < 0 ) sy = - y; + if ( sy > 20 ) sy = 20; + if ( y > scr_y_size - 20 ) ey = 20 - ( y - ( scr_y_size - 20 ) ); + if ( ey < 0 ) ey = 0; + if ( mode == 1 ) + { + // split mode pl1 + if ( x > 140 ) ex = 20 - ( x - 140 ); + if ( ex < 0 ) ex = 0; + } + if ( mode == 2 ) + { + // split mode pl2 + if ( x < 161 ) sx = 161 - x; + if ( sx > 20 ) sx = 20; + } + offs = ( ( num&15 ) *20 ) + ( num / 16*320*20 ) + sy*320; + gofs = virbuff + (( y + sy ) *320 + x + sx); + for ( a = sy; a < ey; a ++ ) + { + memcpy( gofs, floorspr2 + offs + sx, ex - sx ); + offs += 320; + gofs += 320; + } +} + +void draw_shadow( int x, int y, int num, int mode ) +{ + int a, b, sx = 0, ex = 20, sy = 0, ey = 20; + char *s, *vb; + char colo; + if ( x < 0 ) sx = - x; + if ( sx > 20 ) sx = 20; + if ( x > 300 ) ex = 20 - ( x - 300 ); + if ( ex < 0 ) ex = 0; + if ( y < 0 ) sy = - y; + if ( sy > 20 ) sy = 20; + if ( y > scr_y_size - 20 ) ey = 20 - ( y - ( scr_y_size - 20 ) ); + if ( ey < 0 ) ey = 0; + if ( mode == 1 ) + { + // split mode pl1 + if ( x > 140 ) ex = 20 - ( x - ( 140 ) ); + if ( ex < 0 ) ex = 0; + } + if ( mode == 2 ) + { + // split mode pl2 + if ( x < 161 ) sx = 161 - x; + if ( sx > 20 ) sx = 20; + } + + s = shadowspr + (( sy*320 ) + num*20); + vb = virbuff + (( y + sy ) *320 + x); + + for ( a = sy; a < ey; a ++ , vb += 320, s += 320 ) + for ( b = sx; b < ex; b ++ ) + { + colo = s[b]; + if ( colo!= 0 ) vb[b] = shadow_table[vb[b]][colo]; + } +} + + // 28 x 28 +void draw_rambo( int x, int y, int angle, int num, int mode, int col ) +{ + int a, b, c, d, offs1, offs2, sx = 0, ex = 28, sy = 0, ey = 28; + int colo; + if ( x < 0 ) sx = - x; + if ( sx > 28 ) sx = 28; + if ( x > 292 ) ex = 28 - ( x - 292 ); + if ( ex < 0 ) ex = 0; + if ( y < 0 ) sy = - y; + if ( sy > 28 ) sy = 28; + if ( y > scr_y_size - 28 ) ey = 28 - ( y - ( scr_y_size - 28 ) ); + if ( ey < 0 ) ey = 0; + if ( mode == 1 ) + { + // split mode pl1 + if ( x > 132 ) ex = 28 - ( x - 132 ); + if ( ex < 0 ) ex = 0; + } + if ( mode == 2 ) + { + // split mode pl2 + if ( x < 161 ) sx = 161 - x; + if ( sx > 28 ) sx = 28; + } + offs1 = ( y + sy ) *320 + x; + offs2 = ( ( sy + 1 + ( num*29 ) ) *1160 ) + ( angle*29 ) + 1; + for ( a = sy, c = 0, d = 0; a < ey; a ++ , c += 320, d += 1160 ) + for ( b = sx; b < ex; b ++ ) + { + colo = rambospr[offs2 + d + b]; + if ( colo ) + if ( colo >= 80 &&colo <= 80 + 15 ) virbuff[offs1 + c + b] = ( char ) ( col + ( colo - 80 ) );else virbuff[offs1 + c + b] = ( char ) colo; + } +} + +void draw_sprite( int x, int y, int xs, int ys, char *spr, int xsize, int offs, int mode ) +{ + int a, b, offs1, offs2, sx = 0, ex = xs, sy = 0, ey = ys; + char *src, *dest; + char colo; + if ( x < 0 ) sx = - x; + if ( sx > xs ) sx = xs; + if ( x > 320 - xs ) ex = xs - ( x - ( 320 - xs ) ); + if ( ex < 0 ) ex = 0; + if ( y < 0 ) sy = - y; + if ( sy > ys ) sy = ys; + if ( y > scr_y_size - ys ) ey = ys - ( y - ( scr_y_size - ys ) ); + if ( ey < 0 ) ey = 0; + if ( mode == 1 ) + { + // split mode pl1 + if ( x > 160 - xs ) ex = xs - ( x - ( 160 - xs ) ); + if ( ex < 0 ) ex = 0; + } + if ( mode == 2 ) + { + // split mode pl2 + if ( x < 161 ) sx = 161 - x; + if ( sx > xs ) sx = xs; + } + offs1 = ( y + sy ) *320 + x; + offs2 = ( sy*xsize ) + offs; + src = spr + offs2 + sx; + dest = virbuff + offs1 + sx; + for ( a = sy; a < ey; a ++ , dest += 320 - ( ex - sx ), src += xsize - ( ex - sx ) ) + for ( b = sx; b < ex; b ++ ) + { + colo = *( src ++ ); + if ( colo!= 0 ) ( *dest ) = colo; + dest ++; + } +} + +void draw_trans_sprite( int x, int y, int xs, int ys, char *spr, int xsize, int offs, int mode ) +{ + int a, b, offs1, offs2, sx = 0, ex = xs, sy = 0, ey = ys; + char *src, *dest; + char colo; + if ( x < 0 ) sx = - x; + if ( sx > xs ) sx = xs; + if ( x > 320 - xs ) ex = xs - ( x - ( 320 - xs ) ); + if ( ex < 0 ) ex = 0; + if ( y < 0 ) sy = - y; + if ( sy > ys ) sy = ys; + if ( y > scr_y_size - ys ) ey = ys - ( y - ( scr_y_size - ys ) ); + if ( ey < 0 ) ey = 0; + if ( mode == 1 ) + { + // split mode pl1 + if ( x > 160 - xs ) ex = xs - ( x - ( 160 - xs ) ); + if ( ex < 0 ) ex = 0; + } + if ( mode == 2 ) + { + // split mode pl2 + if ( x < 161 ) sx = 161 - x; + if ( sx > xs ) sx = xs; + } + offs1 = ( y + sy ) *320 + x; + offs2 = ( sy*xsize ) + offs; + src = spr + offs2 + sx; + dest = virbuff + offs1 + sx; + for ( a = sy; a < ey; a ++ , dest += 320 - ( ex - sx ), src += xsize - ( ex - sx ) ) + for ( b = sx; b < ex; b ++ ) + { + colo = *( src ++ ); + if ( colo!= 0 ) + ( *dest ) = trans_table[colo][( *dest ) ]; + dest ++; + } +} + +void draw_crate( int x, int y, int type, int mode ) +{ + draw_sprite( x, y, 14, 14, cratespr, 320, type*14, mode ); +} + +void draw_enemy( int x, int y, int angle, int num, int mode, char *spr ) +{ + draw_sprite( x, y, 28, 28, spr, 1160, ( num*29*1160 ) + ( angle*29 ) + 1160 + 1, mode ); +} + +void draw_target( int x, int y, int mode ) +{ + draw_sprite( x, y, 7, 7, targetspr, 7, 0, mode ); +} + +void draw_effect( int x, int y, Effect_type *type, int num, int mode ) +{ + if ( type-> index!= FOOTPRINT &&type-> index!= SMOKE2 &&type-> index!= BLOOD2 &&type-> index!= SMOKE3 &&type-> index!= STEAM ) + draw_sprite( x - type-> xs / 2, y - type-> ys / 2, type-> xs, type-> ys, effectspr, 320, type-> offs + ( ( type-> xs + 1 ) *num ) + 321, mode ); + else + draw_trans_sprite( x - type-> xs / 2, y - type-> ys / 2, type-> xs, type-> ys, effectspr, 320, type-> offs + ( ( type-> xs + 1 ) *num ) + 321, mode ); +} + +void draw_body_part( int x, int y, int num, int mode ) +{ + draw_sprite( x, y, 20, 20, bodypartspr, 320, ( num*21 ), mode ); +} + +void draw_light( Light_table *lt, int x, int y, int num, int add, int mode ) +{ + int xs = Light_sizes[num], ys = Light_sizes[num]; + int a, b, c, sum, offs1, offs2, sx = 0, ex = xs, sy = 0, ey = ys; + x -= ( xs / 2 ); + y -= ( ys / 2 ); + if ( x < 0 ) sx = - x; + if ( sx > xs ) sx = xs; + if ( x > 320 - xs ) ex = xs - ( x - ( 320 - xs ) ); + if ( ex < 0 ) ex = 0; + if ( y < 0 ) sy = - y; + if ( sy > ys ) sy = ys; + if ( y > scr_y_size - ys ) ey = ys - ( y - ( scr_y_size - ys ) ); + if ( ey < 0 ) ey = 0; + if ( mode == 1 ) + { + // 2 pl mode pl1 + if ( x > 160 - xs ) ex = xs - ( x - ( 160 - xs ) ); + if ( ex < 0 ) ex = 0; + } + if ( mode == 2 ) + { + // 2 pl mode pl2 + if ( x < 161 ) sx = 161 - x; + if ( sx > xs ) sx = xs; + } + offs1 = ( y + sy ) *320 + x; + for ( a = sy, offs2 = a*xs, c = 0; a < ey; a ++ , c += 320, offs2 += xs ) + for ( b = sx; b < ex; b ++ ) + if ( light[num].data[offs2 + b] ) + { + sum = light[num].data[offs2 + b] + add; + if ( sum < 0 ) sum = 0;if ( sum > 15 ) sum = 15; + virbuff[offs1 + c + b] = lt-> data[virbuff[offs1 + c + b]][sum]; + } +} + +void draw_ball( int x, int y, int num ) +{ + int a, b, offs1, offs2; + offs1 = ( ( num % 16 ) *20 ) + ( 59*320 ) + ( ( num / 16 ) *( 320*20 ) ); + offs2 = ( y*320 ) + x; + for ( a = 0; a < 20; a ++ ) + memcpy( virbuff + offs2 + ( a*320 ), picture + offs2 + ( a*320 ), 20 ); + for ( a = 0; a < 20; a ++ , offs1 += 300, offs2 += 300 ) + for ( b = 0; b < 20; b ++ , offs1 ++ , offs2 ++ ) + if ( warespr[offs1]!= 0 ) virbuff[offs2] = warespr[offs1]; + offs2 = ( y*320 ) + x; + for ( a = 0; a < 20; a ++ ) + memcpy( screen + offs2 + ( a*320 ), virbuff + offs2 + ( a*320 ), 20 ); +} + +void draw_ware( int x, int y, int row, int colu ) +{ + int a, b, offs1, offs2; + offs1 = row*320*17 + colu*17; + offs2 = ( y*320 ) + x; + for ( a = 0; a < 16; a ++ , offs1 += 304, offs2 += 304 ) + for ( b = 0; b < 16; b ++ , offs1 ++ , offs2 ++ ) + if ( warespr[offs1]!= 0 ) virbuff[offs2] = warespr[offs1]; + else virbuff[offs2] = picture[offs2]; +} + +void draw_black() +{ + int level_size = level_x_size*level_y_size, a, b, ovx1, ovy1, ovy2, ovx2, offs; + ovx1 = aplayer[0]->scr_x % 20; + ovy1 = aplayer[0]->scr_y % 20; + if ( GAME_MODE!= SPLIT_SCREEN ) + { + offs = ( aplayer[0]->scr_y / 20 ) *level_x_size + ( aplayer[0]->scr_x / 20 ); + for ( a = 0; a < scr_y_size / 20 + 1; a ++ , offs += level_x_size - 17 ) + for ( b = 0; b < 17; b ++ , offs ++ ) + if ( offs < level_size ) + if ( level[offs].type == FLOOR ) + if ( !aplayer[0]->see_level[offs] ) + draw_dark_block( ( b*20 ) - ovx1, ( a*20 ) - ovy1, level[offs].num, 0 ); + } + else + { + ovx2 = aplayer[1]->scr_x % 20; + ovy2 = aplayer[1]->scr_y % 20; + offs = ( aplayer[0]->scr_y / 20 ) *level_x_size + ( aplayer[0]->scr_x / 20 ); + for ( a = 0; a < scr_y_size / 20 + 1; a ++ , offs += level_x_size - 9 ) + for ( b = 0; b < 9; b ++ , offs ++ ) + if ( offs < level_size ) + if ( level[offs].type == FLOOR ) + if ( !aplayer[0]->see_level[offs] ) + draw_dark_block( ( b*20 ) - ovx1, ( a*20 ) - ovy1, level[offs].num, 1 ); + offs = ( aplayer[1]->scr_y / 20 ) *level_x_size + ( aplayer[1]->scr_x / 20 ); + for ( a = 0; a < scr_y_size / 20 + 1; a ++ , offs += level_x_size - 9 ) + for ( b = 0; b < 9; b ++ , offs ++ ) + if ( offs < level_size ) + if ( level[offs].type == FLOOR ) + if ( !aplayer[1]->see_level[offs] ) + draw_dark_block( ( b*20 ) - ovx2 + 160, ( a*20 ) - ovy2, level[offs].num, 2 ); + } +} + +void draw_floor() +{ + int a, b, do_it, ovx1, ovy1, ovy2, ovx2, offs; + int level_size = level_x_size*level_y_size; + ovx1 = aplayer[0]->scr_x % 20; + ovy1 = aplayer[0]->scr_y % 20; + if ( GAME_MODE!= SPLIT_SCREEN ) + { + offs = ( aplayer[0]->scr_y / 20 ) *level_x_size + ( aplayer[0]->scr_x / 20 ); + for ( a = 0; a < scr_y_size / 20 + 1; a ++ , offs += level_x_size - 17 ) + for ( b = 0; b < 17; b ++ , offs ++ ) + if ( offs < level_size ) + if ( level[offs].type == FLOOR ) + { + do_it = 1; + if ( DARK_MODE ) if ( !aplayer[0]->see_level[offs] ) do_it = 0; + if ( do_it ) + draw_block( ( b*20 ) - ovx1, ( a*20 ) - ovy1, level[offs].type, level[offs].num, 0 ); + } + } + else + { + ovx2 = aplayer[1]->scr_x % 20; + ovy2 = aplayer[1]->scr_y % 20; + offs = ( aplayer[0]->scr_y / 20 ) *level_x_size + ( aplayer[0]->scr_x / 20 ); + for ( a = 0; a < scr_y_size / 20 + 1; a ++ , offs += level_x_size - 9 ) + for ( b = 0; b < 9; b ++ , offs ++ ) + if ( offs < level_size ) + if ( level[offs].type == FLOOR ) + { + do_it = 1; + if ( DARK_MODE ) if ( !aplayer[0]->see_level[offs] ) do_it = 0; + if ( do_it ) + draw_block( ( b*20 ) - ovx1, ( a*20 ) - ovy1, level[offs].type, level[offs].num, 1 ); + } + offs = ( aplayer[1]->scr_y / 20 ) *level_x_size + ( aplayer[1]->scr_x / 20 ); + for ( a = 0; a < scr_y_size / 20 + 1; a ++ , offs += level_x_size - 9 ) + for ( b = 0; b < 9; b ++ , offs ++ ) + if ( offs < level_size ) + if ( level[offs].type == FLOOR ) + { + do_it = 1; + if ( DARK_MODE ) if ( !aplayer[1]->see_level[offs] ) do_it = 0; + if ( do_it ) + draw_block( ( b*20 ) - ovx2 + 160, ( a*20 ) - ovy2, level[offs].type, level[offs].num, 2 ); + } + } +} + +void draw_shadows() +{ + int a, b, ovx1, ovy1, ovy2, ovx2, offs; + int dou, level_size = level_x_size*level_y_size; + ovx1 = aplayer[0]->scr_x % 20; + ovy1 = aplayer[0]->scr_y % 20; + if ( GAME_MODE!= SPLIT_SCREEN ) + { + offs = ( aplayer[0]->scr_y / 20 ) *level_x_size + ( aplayer[0]->scr_x / 20 ); + for ( a = 0; a < scr_y_size / 20 + 1; a ++ , offs += level_x_size - 17 ) + for ( b = 0; b < 17; b ++ , offs ++ ) + if ( offs < level_size ) + if ( level[offs].shadow > 0 ) + { + dou = 1; + if ( level[offs].type == FLOOR ) if ( DARK_MODE ) if ( !aplayer[0]->see_level[offs] ) dou = 0; + if ( dou ) draw_shadow( ( b*20 ) - ovx1, ( a*20 ) - ovy1, level[offs].shadow - 1, 0 ); + } + } + else + { + ovx2 = aplayer[1]->scr_x % 20; + ovy2 = aplayer[1]->scr_y % 20; + offs = ( aplayer[0]->scr_y / 20 ) *level_x_size + ( aplayer[0]->scr_x / 20 ); + for ( a = 0; a < scr_y_size / 20 + 1; a ++ , offs += level_x_size - 9 ) + for ( b = 0; b < 9; b ++ , offs ++ ) + if ( offs < level_size ) + if ( level[offs].shadow > 0 ) + { + dou = 1; + if ( level[offs].type == FLOOR ) if ( DARK_MODE ) if ( !aplayer[0]->see_level[offs] ) dou = 0; + if ( dou ) draw_shadow( ( b*20 ) - ovx1, ( a*20 ) - ovy1, level[offs].shadow - 1, 1 ); + } + offs = ( aplayer[1]->scr_y / 20 ) *level_x_size + ( aplayer[1]->scr_x / 20 ); + for ( a = 0; a < scr_y_size / 20 + 1; a ++ , offs += level_x_size - 9 ) + for ( b = 0; b < 9; b ++ , offs ++ ) + if ( offs < level_size ) + if ( level[offs].shadow > 0 ) + { + dou = 1; + if ( level[offs].type == FLOOR ) if ( DARK_MODE ) if ( !aplayer[1]->see_level[offs] ) dou = 0; + if ( dou ) draw_shadow( ( b*20 ) - ovx2 + 160, ( a*20 ) - ovy2, level[offs].shadow - 1, 2 ); + } + } +} + +void draw_walls() +{ + int a, b, ovx1, ovy1, ovy2, ovx2, offs; + int level_size = level_x_size*level_y_size; + ovx1 = aplayer[0]->scr_x % 20; + ovy1 = aplayer[0]->scr_y % 20; + if ( GAME_MODE!= SPLIT_SCREEN ) + { + offs = ( aplayer[0]->scr_y / 20 ) *level_x_size + ( aplayer[0]->scr_x / 20 ); + for ( a = 0; a < scr_y_size / 20 + 1; a ++ , offs += level_x_size - 17 ) + for ( b = 0; b < 17; b ++ , offs ++ ) + if ( offs < level_size ) + { + if ( level[offs].type == WALLS ) + draw_block( ( b*20 ) - ovx1, ( a*20 ) - ovy1, level[offs].type, level[offs].num, 0 ); + } + else draw_block( ( b*20 ) - ovx1, ( a*20 ) - ovy1, WALLS, 19, 0 ); + } + else + { + ovx2 = aplayer[1]->scr_x % 20; + ovy2 = aplayer[1]->scr_y % 20; + offs = ( aplayer[0]->scr_y / 20 ) *level_x_size + ( aplayer[0]->scr_x / 20 ); + for ( a = 0; a < scr_y_size / 20 + 1; a ++ , offs += level_x_size - 9 ) + for ( b = 0; b < 9; b ++ , offs ++ ) + if ( offs < level_size ) + { + if ( level[offs].type == WALLS ) + draw_block( ( b*20 ) - ovx1, ( a*20 ) - ovy1, level[offs].type, level[offs].num, 1 ); + } + else draw_block( ( b*20 ) - ovx1, ( a*20 ) - ovy1, WALLS, 19, 1 ); + offs = ( aplayer[1]->scr_y / 20 ) *level_x_size + ( aplayer[1]->scr_x / 20 ); + for ( a = 0; a < scr_y_size / 20 + 1; a ++ , offs += level_x_size - 9 ) + for ( b = 0; b < 9; b ++ , offs ++ ) + if ( offs < level_size ) + { + if ( level[offs].type == WALLS ) + draw_block( ( b*20 ) - ovx2 + 160, ( a*20 ) - ovy2, level[offs].type, level[offs].num, 2 ); + } + else draw_block( ( b*20 ) - ovx2 + 160, ( a*20 ) - ovy2, WALLS, 19, 2 ); + } + if ( GAME_MODE == SPLIT_SCREEN ) + for ( a = 160; a < 320*scr_y_size; a+=320) + virbuff[a] = 0; +} + +int chk4draw( int x, int y, int sx, int sy, int size, int mode ) +{ + if ( mode == 0 ) + if ( x > sx - size && + x < sx + 320 && + y > sy - size && + y < sy + scr_y_size ) return( 1 ); + if ( mode > 0 ) + if ( x > sx - size && + x < sx + 160 && + y > sy - size && + y < sy + scr_y_size ) return( 1 ); + return( 0 ); +} + +void draw_live_enemies() +{ + int a; + for ( a = 0; a < ENEMIES; a ++ ) + { + enemy[a].rangle = enemy[a].angle / 9; + if ( GAME_MODE!= SPLIT_SCREEN ) + if ( !enemy[a].DEAD ) + if ( chk4draw( enemy[a].x, enemy[a].y, aplayer[0]->scr_x, aplayer[0]->scr_y, 28, 0 ) ) + draw_enemy( enemy[a].x - aplayer[0]->scr_x, enemy[a].y - aplayer[0]->scr_y, enemy[a].rangle, enemy[a].ANIM, 0, enemy_info[enemy[a].type].spr ); + if ( GAME_MODE == SPLIT_SCREEN ) + if ( !enemy[a].DEAD ) + { + if ( chk4draw( enemy[a].x, enemy[a].y, aplayer[0]->scr_x, aplayer[0]->scr_y, 28, 1 ) ) + draw_enemy( enemy[a].x - aplayer[0]->scr_x, enemy[a].y - aplayer[0]->scr_y, enemy[a].rangle, enemy[a].ANIM, 1, enemy_info[enemy[a].type].spr ); + if ( chk4draw( enemy[a].x, enemy[a].y, aplayer[1]->scr_x, aplayer[1]->scr_y, 28, 1 ) ) + { + draw_enemy( ( enemy[a].x - aplayer[1]->scr_x ) + 160, enemy[a].y - aplayer[1]->scr_y, enemy[a].rangle, enemy[a].ANIM, 2, enemy_info[enemy[a].type].spr ); + } + } + } +} + +void draw_players( int pos ) +{ + int a, draw1 = 0, draw2 = 0; + if ( GAME_MODE!= SPLIT_SCREEN ) + for ( a = 0; a < MAX_PLAYERS; a ++ ) + if (player[a].enabled) + { + draw1 = 0; + if ( pos == 0 ) if ( player[a].DEAD ) draw1 = 1; + if ( pos == 1 ) if ( !player[a].DEAD ) draw1 = 1; + if ( draw1 ) + if ( chk4draw( player[a].x, player[a].y, aplayer[0]->scr_x, aplayer[0]->scr_y, 28, 0 ) ) + draw_rambo( player[a].x - aplayer[0]->scr_x, player[a].y - aplayer[0]->scr_y, player[a].rangle, player[a].ANIM, 0, player[a].color ); + } + if ( GAME_MODE == SPLIT_SCREEN ) + { + for ( a = 0; a < MAX_PLAYERS; a ++ ) + if (player[a].enabled) + { + draw1 = 0; + if ( pos == 0 ) if ( player[a].DEAD ) draw1 = 1; + if ( pos == 1 ) if ( !player[a].DEAD ) draw1 = 1; + if ( draw1 ) + { + if ( chk4draw( player[a].x, player[a].y, aplayer[0]->scr_x, aplayer[0]->scr_y, 28, 1 ) ) + draw_rambo( player[a].x - aplayer[0]->scr_x, player[a].y - aplayer[0]->scr_y, player[a].rangle, player[a].ANIM, 1, player[a].color ); + if ( chk4draw( player[a].x, player[a].y, aplayer[1]->scr_x, aplayer[1]->scr_y, 28, 2 ) ) + draw_rambo( player[a].x - aplayer[1]->scr_x + 160, player[a].y - aplayer[1]->scr_y, player[a].rangle, player[a].ANIM, 2, player[a].color ); + } + } + } +} + +void draw_gae_shadows() +{ + int a, xo = - 1, yo = 7; + for ( a = 0; a < ENEMIES; a ++ ) + { + if ( GAME_MODE!= SPLIT_SCREEN ) + if ( !enemy[a].DEAD ) + if ( chk4draw( enemy[a].x, enemy[a].y, aplayer[0]->scr_x, aplayer[0]->scr_y, 28, 0 ) ) + draw_shadow( enemy[a].x - aplayer[0]->scr_x + xo, enemy[a].y - aplayer[0]->scr_y + yo, 5, 0 ); + if ( GAME_MODE == SPLIT_SCREEN ) + if ( !enemy[a].DEAD ) + { + if ( chk4draw( enemy[a].x, enemy[a].y, aplayer[0]->scr_x, aplayer[0]->scr_y, 28, 1 ) ) + draw_shadow( enemy[a].x - aplayer[0]->scr_x + xo, enemy[a].y - aplayer[0]->scr_y + yo, 5, 1 ); + if ( chk4draw( enemy[a].x, enemy[a].y, player[1].scr_x, player[1].scr_y, 28, 1 ) ) + draw_shadow( enemy[a].x - aplayer[1]->scr_x + 160 + xo, enemy[a].y - aplayer[1]->scr_y + yo, 5, 2 ); + } + } + if ( GAME_MODE!= SPLIT_SCREEN ) + for ( a = 0; a < MAX_PLAYERS; a ++ ) + if (player[a].enabled) + if ( !player[a].DEAD ) + if ( chk4draw( player[a].x, player[a].y, aplayer[0]->scr_x, aplayer[0]->scr_y, 28, 0 ) ) + draw_shadow( player[a].x - aplayer[0]->scr_x + xo, player[a].y - aplayer[0]->scr_y + yo, 5, 0 ); + if ( GAME_MODE == SPLIT_SCREEN ) + { + for ( a = 0; a < MAX_PLAYERS; a ++ ) + if (player[a].enabled) + if ( !player[a].DEAD ) + if ( chk4draw( player[a].x, player[a].y, aplayer[0]->scr_x, aplayer[0]->scr_y, 28, 1 ) ) + draw_shadow( player[a].x - aplayer[0]->scr_x + xo, player[a].y - aplayer[0]->scr_y + yo, 5, 1 ); + for ( a = 0; a < MAX_PLAYERS; a ++ ) + if (player[a].enabled) + if ( !player[a].DEAD ) + if ( chk4draw( player[a].x, player[a].y, aplayer[1]->scr_x, aplayer[1]->scr_y, 28, 2 ) ) + draw_shadow( player[a].x - aplayer[1]->scr_x + 160 + xo, player[a].y - aplayer[1]->scr_y + yo, 5, 2 ); + } +} + +void draw_effects( int pos ) +{ + int a; + for ( a = 0; a < MAX_EFFECTS; a ++ ) + if ( effect[a].IN_USE ) + if ( effect[a].type-> order == pos ) + { + if ( GAME_MODE!= SPLIT_SCREEN ) + { + if ( chk4draw( effect[a].x - ( effect[a].type-> xs / 2 ), effect[a].y - ( effect[a].type-> ys / 2 ), aplayer[0]->scr_x, aplayer[0]->scr_y, 25, 0 ) ) + switch( effect[a].type-> index ) + { + case EXPLO:draw_light( effect[a].lt, effect[a].x - aplayer[0]->scr_x, effect[a].y - aplayer[0]->scr_y, 7, 5 - effect[a].count*0.8, 0 ); break; + case METAL:if (LIGHT_EFFECTS) draw_light( effect[a].lt, effect[a].x - aplayer[0]->scr_x, effect[a].y - aplayer[0]->scr_y, 0, - effect[a].count, 0 ); break; + case SMOKE:if (LIGHT_EFFECTS) draw_light( effect[a].lt, effect[a].x - aplayer[0]->scr_x, effect[a].y - aplayer[0]->scr_y, 1, - effect[a].count, 0 ); break; + case TELEPORT:if (LIGHT_EFFECTS) draw_light( effect[a].lt, effect[a].x - aplayer[0]->scr_x, effect[a].y - aplayer[0]->scr_y, 4, 0, 0 ); break; + } + if (effect[a].type-> index != EXPLO) + draw_effect( effect[a].x - aplayer[0]->scr_x, effect[a].y - aplayer[0]->scr_y, effect[a].type, effect[a].count / effect[a].type-> delay, 0 ); + } + if ( GAME_MODE == SPLIT_SCREEN ) + { + if ( chk4draw( effect[a].x - ( effect[a].type-> xs / 2 ), effect[a].y - ( effect[a].type-> ys / 2 ), aplayer[0]->scr_x, aplayer[0]->scr_y, 25, 1 ) ) + { + if ( LIGHT_EFFECTS ) + switch( effect[a].type-> index ) + { + case EXPLO:draw_light( effect[a].lt, effect[a].x - aplayer[0]->scr_x, effect[a].y - aplayer[0]->scr_y, 7, 5 - effect[a].count*0.8, 1 ); break; + case METAL:if (LIGHT_EFFECTS) draw_light( effect[a].lt, effect[a].x - aplayer[0]->scr_x, effect[a].y - aplayer[0]->scr_y, 0, - effect[a].count, 1 ); break; + case SMOKE:if (LIGHT_EFFECTS) draw_light( effect[a].lt, effect[a].x - aplayer[0]->scr_x, effect[a].y - aplayer[0]->scr_y, 1, - effect[a].count, 1 ); break; + case TELEPORT:if (LIGHT_EFFECTS) draw_light( effect[a].lt, effect[a].x - aplayer[0]->scr_x, effect[a].y - aplayer[0]->scr_y, 4, 0, 1 ); break; + } + if (effect[a].type-> index != EXPLO) + draw_effect( effect[a].x - aplayer[0]->scr_x, effect[a].y - aplayer[0]->scr_y, effect[a].type, effect[a].count / effect[a].type-> delay, 1 ); + } + if ( chk4draw( effect[a].x - ( effect[a].type-> xs / 2 ), effect[a].y - ( effect[a].type-> ys / 2 ), aplayer[1]->scr_x, aplayer[1]->scr_y, 25, 1 ) ) + { + if ( LIGHT_EFFECTS ) + switch( effect[a].type-> index ) + { + case EXPLO:draw_light( effect[a].lt, effect[a].x - aplayer[1]->scr_x + 160, effect[a].y - aplayer[1]->scr_y, 7, 5 - effect[a].count*0.8, 2 ); break; + case METAL:if (LIGHT_EFFECTS) draw_light( effect[a].lt, effect[a].x - aplayer[1]->scr_x + 160, effect[a].y - aplayer[1]->scr_y, 0, - effect[a].count, 2 ); break; + case SMOKE:if (LIGHT_EFFECTS) draw_light( effect[a].lt, effect[a].x - aplayer[1]->scr_x + 160, effect[a].y - aplayer[1]->scr_y, 1, - effect[a].count, 2 ); break; + case TELEPORT:if (LIGHT_EFFECTS) draw_light( effect[a].lt, effect[a].x - aplayer[1]->scr_x + 160, effect[a].y - aplayer[1]->scr_y, 4, 0, 2 ); break; + } + if (effect[a].type-> index != EXPLO) + draw_effect( effect[a].x - aplayer[1]->scr_x + 160, effect[a].y - aplayer[1]->scr_y, effect[a].type, effect[a].count / effect[a].type-> delay, 2 ); + } + } + } +} + +void draw_spots() +{ + int a; + for ( a = 0; a < Spot_amount; a ++ ) + { + if ( GAME_MODE!= SPLIT_SCREEN ) + if ( chk4draw( spot_light[a].x - 30, spot_light[a].y - 30, aplayer[0]->scr_x, aplayer[0]->scr_y, 60, 0 ) ) + draw_light( &normal_l, spot_light[a].x - aplayer[0]->scr_x, spot_light[a].y - aplayer[0]->scr_y, spot_light[a].size, 2.5*sini[Spot_count] + 2, 0 ); + if ( GAME_MODE == SPLIT_SCREEN ) + { + if ( chk4draw( spot_light[a].x - 30, spot_light[a].y - 30, aplayer[0]->scr_x, aplayer[0]->scr_y, 60, 1 ) ) + draw_light( &normal_l, spot_light[a].x - aplayer[0]->scr_x, spot_light[a].y - aplayer[0]->scr_y, spot_light[a].size, 2.5*sini[Spot_count] + 2, 1 ); + if ( chk4draw( spot_light[a].x - 30, spot_light[a].y - 30, aplayer[1]->scr_x, aplayer[1]->scr_y, 60, 1 ) ) + draw_light( &normal_l, spot_light[a].x - aplayer[1]->scr_x + 160, spot_light[a].y - aplayer[1]->scr_y, spot_light[a].size, 2.5*sini[Spot_count] + 2, 2 ); + } + } +} + +void draw_bullets() +{ + int a; + for ( a = 0; a < MAX_BULLETS; a ++ ) + if ( bullet[a].IN_USE ) + { + if ( GAME_MODE!= SPLIT_SCREEN ) + if ( chk4draw( bullet[a].x, bullet[a].y, aplayer[0]->scr_x, aplayer[0]->scr_y, 20, 0 ) ) + { + if ( bullet[a].type-> light != NULL ) + draw_light( bullet[a].type-> light, bullet[a].x - aplayer[0]->scr_x, bullet[a].y - aplayer[0]->scr_y, bullet[a].type-> lsize, bullet[a].type-> llum + bullet[a].count*bullet[a].type-> ladd, 0 ); + if ( bullet[a].type-> sprite != NULL ) + draw_sprite( bullet[a].x - ( int ) ( bullet[a].type-> xs >> 1 ) - aplayer[0]->scr_x, bullet[a].y - ( int ) ( bullet[a].type-> ys >> 1 ) - aplayer[0]->scr_y, bullet[a].type-> xs, bullet[a].type-> ys, bullet[a].type-> sprite, bullet[a].type-> xsize, bullet[a].type-> offs, 0 ); + } + if ( GAME_MODE == SPLIT_SCREEN ) + { + if ( chk4draw( bullet[a].x, bullet[a].y, aplayer[0]->scr_x, aplayer[0]->scr_y, 20, 1 ) ) + { + if ( bullet[a].type-> light != NULL ) + draw_light( bullet[a].type-> light, bullet[a].x - aplayer[0]->scr_x, bullet[a].y - aplayer[0]->scr_y, bullet[a].type-> lsize, bullet[a].type-> llum + bullet[a].count*bullet[a].type-> ladd, 1 ); + if ( bullet[a].type-> sprite != NULL ) + draw_sprite( bullet[a].x - ( int ) ( bullet[a].type-> xs >> 1 ) - aplayer[0]->scr_x, bullet[a].y - ( int ) ( bullet[a].type-> ys >> 1 ) - aplayer[0]->scr_y, bullet[a].type-> xs, bullet[a].type-> ys, bullet[a].type-> sprite, bullet[a].type-> xsize, bullet[a].type-> offs, 1 ); + } + if ( chk4draw( bullet[a].x, bullet[a].y, aplayer[1]->scr_x, aplayer[1]->scr_y, 20, 1 ) ) + { + if ( bullet[a].type-> light != NULL ) + draw_light( bullet[a].type-> light, bullet[a].x - aplayer[1]->scr_x + 160, bullet[a].y - aplayer[1]->scr_y, bullet[a].type-> lsize, bullet[a].type-> llum + bullet[a].count*bullet[a].type-> ladd, 2 ); + if ( bullet[a].type-> sprite != NULL ) + draw_sprite( bullet[a].x - ( int ) ( bullet[a].type-> xs >> 1 ) - aplayer[1]->scr_x + 160, bullet[a].y - ( int ) ( bullet[a].type-> ys >> 1 ) - aplayer[1]->scr_y, bullet[a].type-> xs, bullet[a].type-> ys, bullet[a].type-> sprite, bullet[a].type-> xsize, bullet[a].type-> offs, 2 ); + } + } + } +} + +void draw_body_parts() +{ + int a; + for ( a = 0; a < MAX_BODY_PARTS; a ++ ) + if ( body_part[a].IN_USE ) + { + if ( GAME_MODE!= SPLIT_SCREEN ) + if ( chk4draw( body_part[a].x, body_part[a].y, aplayer[0]->scr_x, aplayer[0]->scr_y, 20, 0 ) ) + draw_body_part( body_part[a].x - aplayer[0]->scr_x, body_part[a].y - aplayer[0]->scr_y, body_part[a].num, 0 ); + if ( GAME_MODE == SPLIT_SCREEN ) + { + if ( chk4draw( body_part[a].x, body_part[a].y, aplayer[0]->scr_x, aplayer[0]->scr_y, 20, 1 ) ) + draw_body_part( body_part[a].x - aplayer[0]->scr_x, body_part[a].y - aplayer[0]->scr_y, body_part[a].num, 1 ); + if ( chk4draw( body_part[a].x, body_part[a].y, aplayer[1]->scr_x, aplayer[1]->scr_y, 20, 1 ) ) + draw_body_part( body_part[a].x - aplayer[1]->scr_x + 160, body_part[a].y - aplayer[1]->scr_y, body_part[a].num, 2 ); + } + } +} + +void draw_infos() +{ + char text[20]; + int x; + writefonts( 3, scr_y_size - 15, weapon[aplayer[0]->curr_weapon].name, 1 ); + x = aplayer[0]->bullets[weapon[aplayer[0]->curr_weapon].btype - 1] / bullet_type[weapon[aplayer[0]->curr_weapon].btype].mul; + if ( x < 0 ) x = 1; + itoa( x, text, 10 ); + if ( aplayer[0]->curr_weapon > 0 ) writefonts( 3, scr_y_size - 23, text, 7*16 ); + if ( GAME_MODE == SPLIT_SCREEN ) + { + writefonts( 3 + 160, scr_y_size - 15, weapon[aplayer[1]->curr_weapon].name, 1 ); + x = aplayer[1]->bullets[weapon[aplayer[1]->curr_weapon].btype - 1] / bullet_type[weapon[aplayer[1]->curr_weapon].btype].mul; + if ( x < 0 ) x = 1; + itoa( x, text, 10 ); + if ( aplayer[1]->curr_weapon > 0 ) writefonts( 3 + 160, scr_y_size - 23, text, 7*16 ); + } +} + +void draw_energies() +{ + int a, offs = ( ( scr_y_size - 5 ) *320 ) + 3; + float div = ( ( float ) ( aplayer[0]->max_energy + ( aplayer[0]->shield*10 ) ) / 5 ) / 15; + for ( a = 0; a < aplayer[0]->energy / 5; a ++ ) + { + virbuff[offs + a] = 239 - ( a / div ); + virbuff[offs + a + 320] = 239 - ( a / div ); + } + if ( GAME_MODE == SPLIT_SCREEN ) + { + offs = ( ( scr_y_size - 5 ) *320 ) + 3 + 160; + div = ( ( float ) ( aplayer[1]->max_energy + ( aplayer[1]->shield*10 ) ) / 5 ) / 15; + for ( a = 0; a < aplayer[1]->energy / 5; a ++ ) + { + virbuff[offs + a] = 239 - ( a / div ); + virbuff[offs + a + 320] = 239 - ( a / div ); + } + } +} + +void map() +{ + int a, b, offs, cx, cy, type; + if ( GAME_MODE!= SPLIT_SCREEN ) + { + cx = 320 - ( level_x_size ); + cy = 0; + } + if ( GAME_MODE == SPLIT_SCREEN ) + { + cx = 160 - ( level_x_size / 2 ); + cy = ( scr_y_size / 2 ) - ( level_y_size / 2 ); + } + offs = cy*320 + cx; + for ( a = 0; a < level_y_size; a ++ , offs += ( 320 - level_x_size ) ) + for ( b = 0; b < level_x_size; b ++ , offs ++ ) + { + type = level[a*level_x_size + b].type; + if ( type == WALLS ) virbuff[offs] = 16; + else virbuff[offs] = shadow_table[virbuff[offs]][15]; + } + for ( a = 0; a < ENEMIES; a ++ ) + if ( enemy[a].DEAD ) + virbuff[( ( int ) ( ( enemy[a].y + 15 ) / 20 ) + cy ) *320 + ( int ) ( ( enemy[a].x + 15 ) / 20 ) + cx] = 9; + if ( SHOW_ENEMIES ) + for ( a = 0; a < ENEMIES; a ++ ) + if ( !enemy[a].DEAD ) + virbuff[( ( int ) ( ( enemy[a].y + 15 ) / 20 ) + cy ) *320 + ( int ) ( ( enemy[a].x + 15 ) / 20 ) + cx] = 3; + if (KILLING_MODE!=SPLIT_SCREEN) + for ( a = 0; a < MAX_PLAYERS; a ++ ) + if (GAME_MODE!=DEATHMATCH || aplayer[0]->tindex==a) + if (player[a].enabled) + virbuff[( ( int ) ( ( player[a].y + 15 ) / 20 ) + cy ) *320 + ( int ) ( ( player[a].x + 15 ) / 20 ) + cx] = ( char ) player[a].color; +} + +void draw_box1( int x1, int y1, int x2, int y2, int add ) +{ + int a, b, c, offs = ( y1*320 ) + x1; + for ( a = 0; a < ( y2 - y1 ); a ++ , offs += ( 320 - ( x2 - x1 ) ) ) + for ( b = 0; b < ( x2 - x1 ); b ++ , offs ++ ) + { + if ( a == 0 ||a == y2 - y1 - 1 ||b == 0 ||b == x2 - x1 - 1 ) + c = picture[offs] + 1; + else c = picture[offs] - add; + if ( c < 0 ) c = 0; + if ( c > 63 ) c = 63; + picture[offs] = ( char ) c; + } +} + +void rectangle( int x1, int y1, int x2, int y2, int col ) +{ + int a, offs, offs1, offs2, offs3; + offs1 = y1*320 + x1; + offs2 = y1*320 + x2; + offs3 = y2*320 + x1; + memset( virbuff + offs1, col, ( x2 - x1 ) + 1 ); + memset( virbuff + offs3, col, ( x2 - x1 ) + 1 ); + for( a = 0, offs = offs1 + 320; a < ( y2 - y1 ) - 1; a ++ , offs += 320 ) + virbuff[offs] = ( char ) col; + for( a = 0, offs = offs2 + 320; a < ( y2 - y1 ) - 1; a ++ , offs += 320 ) + virbuff[offs] = ( char ) col; +} + +void draw_hits() +{ + if ( GAME_MODE!= SPLIT_SCREEN ) + if ( aplayer[0]->HIT > 0 ) + rectangle( 0, 0, 319, scr_y_size - 1, ( ( 4*16 ) - 1 ) - aplayer[0]->HIT ); + if ( GAME_MODE == SPLIT_SCREEN ) + { + if ( aplayer[0]->HIT > 0 ) + rectangle( 0, 0, 159, scr_y_size - 1, ( ( 4*16 ) - 1 ) - aplayer[0]->HIT ); + if ( aplayer[1]->HIT > 0 ) + rectangle( 161, 0, 319, scr_y_size - 1, ( ( 4*16 ) - 1 ) - aplayer[1]->HIT ); + } +} + +void draw_targets() +{ + int a, dist; + float x, y; + static int plot_count = 0; + plot_count ++; + if ( GAME_MODE!= SPLIT_SCREEN ) + if ( !aplayer[0]->DEAD ) + if ( weapon[aplayer[0]->curr_weapon].gun ) + if ( aplayer[0]->TARGET ) + { + x = aplayer[0]->x + 14 + 10*sini[aplayer[0]->rangle2]; + y = aplayer[0]->y + 14 + 10*cosi[aplayer[0]->rangle2]; + dist = bullet_type[weapon[aplayer[0]->curr_weapon].btype].time*bullet_type[weapon[aplayer[0]->curr_weapon].btype].speed; + for ( a = 0; a < dist &&x - aplayer[0]->scr_x >= 0 &&x - aplayer[0]->scr_x < 320 &&y - aplayer[0]->scr_y >= 0 &&y - aplayer[0]->scr_y < scr_y_size &&level[( int ) ( y / 20 ) *level_x_size + ( int ) ( x / 20 ) ].type == FLOOR; a ++ ) + { + if ( ( a - ( int ) ( plot_count / 2 ) ) % 6 == 0 ) + virbuff[( int ) ( y - aplayer[0]->scr_y ) *320 + ( int ) ( x - aplayer[0]->scr_x ) ] = 9*16; + x += sini[aplayer[0]->rangle2]; + y += cosi[aplayer[0]->rangle2]; + } + if ( a == dist ||level[( int ) ( y / 20 ) *level_x_size + ( int ) ( x / 20 ) ].type == WALLS ) draw_target( x - 3 - aplayer[0]->scr_x, y - 3 - aplayer[0]->scr_y, 0 ); + } + if ( GAME_MODE == SPLIT_SCREEN ) + { + if ( !aplayer[0]->DEAD ) + if ( weapon[aplayer[0]->curr_weapon].gun ) + if ( aplayer[0]->TARGET ) + { + x = aplayer[0]->x + 14 + 10*sini[aplayer[0]->rangle2]; + y = aplayer[0]->y + 14 + 10*cosi[aplayer[0]->rangle2]; + dist = bullet_type[weapon[aplayer[0]->curr_weapon].btype].time*bullet_type[weapon[aplayer[0]->curr_weapon].btype].speed; + for ( a = 0; a < dist &&x - aplayer[0]->scr_x >= 0 &&x - aplayer[0]->scr_x < 160 &&y - aplayer[0]->scr_y >= 0 &&y - aplayer[0]->scr_y < scr_y_size &&level[( int ) ( y / 20 ) *level_x_size + ( int ) ( x / 20 ) ].type == FLOOR; a ++ ) + { + if ( ( a - ( int ) ( plot_count / 2 ) ) % 6 == 0 ) + virbuff[( int ) ( y - aplayer[0]->scr_y ) *320 + ( int ) ( x - aplayer[0]->scr_x ) ] = 9*16; + x += sini[aplayer[0]->rangle2]; + y += cosi[aplayer[0]->rangle2]; + } + if ( a == dist ||level[( int ) ( y / 20 ) *level_x_size + ( int ) ( x / 20 ) ].type == WALLS ) draw_target( x - 3 - aplayer[0]->scr_x, y - 3 - aplayer[0]->scr_y, 1 ); + } + if ( !aplayer[1]->DEAD ) + if ( weapon[aplayer[1]->curr_weapon].gun ) + if ( aplayer[1]->TARGET ) + { + dist = bullet_type[weapon[aplayer[1]->curr_weapon].btype].time*bullet_type[weapon[aplayer[1]->curr_weapon].btype].speed; + x = aplayer[1]->x + 14 + 10*sini[aplayer[1]->rangle2]; + y = aplayer[1]->y + 14 + 10*cosi[aplayer[1]->rangle2]; + for ( a = 0; a < dist &&x - aplayer[1]->scr_x > 0 &&x - aplayer[1]->scr_x < 160 &&y - aplayer[1]->scr_y >= 0 &&y - aplayer[1]->scr_y < scr_y_size &&level[( int ) ( y / 20 ) *level_x_size + ( int ) ( x / 20 ) ].type == FLOOR; a ++ ) + { + if ( ( a - ( int ) ( plot_count / 2 ) ) % 6 == 0 ) + virbuff[( int ) ( y - aplayer[1]->scr_y ) *320 + ( int ) ( x - aplayer[1]->scr_x ) + 160] = 9*16; + x += sini[aplayer[1]->rangle2]; + y += cosi[aplayer[1]->rangle2]; + } + if ( a == dist ||level[( int ) ( y / 20 ) *level_x_size + ( int ) ( x / 20 ) ].type == WALLS ) draw_target( x - 3 - aplayer[1]->scr_x + 160, y - 3 - aplayer[1]->scr_y, 2 ); + } + } +} + +void draw_crates() +{ + int a; + for ( a = 0; a < MAX_CRATES; a ++ ) + if ( crate[a].IN_USE ) + if ( crate[a].text_count == 0 ) + { + if ( GAME_MODE!= SPLIT_SCREEN ) + if ( chk4draw( crate[a].x, crate[a].y, aplayer[0]->scr_x, aplayer[0]->scr_y, 14, 0 ) ) + { + if ( LIGHT_EFFECTS ) draw_light( &normal_l, crate[a].x - aplayer[0]->scr_x + 7, crate[a].y - aplayer[0]->scr_y + 7, 4, 2, 0 ); + draw_crate( crate[a].x - aplayer[0]->scr_x, crate[a].y - aplayer[0]->scr_y, crate[a].type, 0 ); + } + if ( GAME_MODE == SPLIT_SCREEN ) + { + if ( chk4draw( crate[a].x, crate[a].y, aplayer[0]->scr_x, aplayer[0]->scr_y, 14, 1 ) ) + { + if ( LIGHT_EFFECTS ) draw_light( &normal_l, crate[a].x - aplayer[0]->scr_x + 7, crate[a].y - aplayer[0]->scr_y + 7, 4, 2, 1 ); + draw_crate( crate[a].x - aplayer[0]->scr_x, crate[a].y - aplayer[0]->scr_y, crate[a].type, 1 ); + } + if ( chk4draw( crate[a].x, crate[a].y, aplayer[1]->scr_x, aplayer[1]->scr_y, 14, 1 ) ) + { + if ( LIGHT_EFFECTS ) draw_light( &normal_l, crate[a].x - aplayer[1]->scr_x + 7 + 160, crate[a].y - aplayer[1]->scr_y + 7, 4, 2, 2 ); + draw_crate( crate[a].x - aplayer[1]->scr_x + 160, crate[a].y - aplayer[1]->scr_y, crate[a].type, 2 ); + } + } + } +} + +void draw_crate_texts() +{ + int a; + for ( a = 0; a < MAX_CRATES; a ++ ) + if ( crate[a].IN_USE ) + if ( crate[a].text_count > 0 ) + writefonts( crate[a].text_x, crate[a].text_y, crate[a].text, 32 ); +} + +void draw_kills() +{ + char text[5], text2[20]; + int a,b=0; + if ( GAME_MODE == SPLIT_SCREEN ) + { + itoa( aplayer[0]->player_kills, text, 10 ); + writefonts( 3, 3, text, 48 ); + itoa( aplayer[1]->player_kills, text, 10 ); + writefonts( 317 - str_length( text ), 3, text, 144 ); + } + else + for ( a = 0; a < MAX_PLAYERS;a++) + if (player[a].enabled) + { + strcpy( text2, player[a].name ); + itoa( player[a].player_kills, text, 10 ); + strcat( text2, " " ); + strcat( text2, text ); + writefonts( 3 + ( b % 4 ) *80, 3 + ( b / 4 ) *10, text2, player[a].color ); + b++; + } +} + diff --git a/SRC/DRAW.CPP b/SRC/DRAW.CPP new file mode 100644 index 0000000..aac4b99 --- /dev/null +++ b/SRC/DRAW.CPP @@ -0,0 +1,976 @@ +#include < stdlib.h > +#include < stdio.h > +#include < string.h > +#include < gfunc.h > +#include "defines.h" +#include "types.h" +#include "globvar.h" +#include "classes.h" +#include "write.h" + + // 20 x 20 +void draw_block( int x, int y, int type, int num, int mode ) +{ + int a, offs; + char *texture, *gofs; + int sx = 0, ex = 20, sy = 0, ey = 20; + if ( x < 0 ) sx = - x; + if ( sx > 20 ) sx = 20; + if ( x > 300 ) ex = 20 - ( x - 300 ); + if ( ex < 0 ) ex = 0; + if ( y < 0 ) sy = - y; + if ( sy > 20 ) sy = 20; + if ( y > scr_y_size - 20 ) ey = 20 - ( y - ( scr_y_size - 20 ) ); + if ( ey < 0 ) ey = 0; + if ( mode == 1 ) + { + // split mode pl1 + if ( x > 140 ) ex = 20 - ( x - 140 ); + if ( ex < 0 ) ex = 0; + } + if ( mode == 2 ) + { + // split mode pl2 + if ( x < 161 ) sx = 161 - x; + if ( sx > 20 ) sx = 20; + } + offs = ( ( num&15 ) *20 ) + ( num / 16*320*20 ) + sy*320; + gofs = virbuff + (( y + sy ) *320 + x + sx); + if ( type == FLOOR ) texture = floorspr + offs + sx; + if ( type == WALLS ) texture = wallspr + offs + sx; + for ( a = sy; a < ey; a ++ ) + { + memcpy( gofs, texture, ex - sx ); + texture += 320; + gofs += 320; + } +} + + // 20 x 20 +void draw_dark_block( int x, int y, int num, int mode ) +{ + int a, offs; + char *gofs; + + int sx = 0, ex = 20, sy = 0, ey = 20; + if ( x < 0 ) sx = - x; + if ( sx > 20 ) sx = 20; + if ( x > 300 ) ex = 20 - ( x - 300 ); + if ( ex < 0 ) ex = 0; + if ( y < 0 ) sy = - y; + if ( sy > 20 ) sy = 20; + if ( y > scr_y_size - 20 ) ey = 20 - ( y - ( scr_y_size - 20 ) ); + if ( ey < 0 ) ey = 0; + if ( mode == 1 ) + { + // split mode pl1 + if ( x > 140 ) ex = 20 - ( x - 140 ); + if ( ex < 0 ) ex = 0; + } + if ( mode == 2 ) + { + // split mode pl2 + if ( x < 161 ) sx = 161 - x; + if ( sx > 20 ) sx = 20; + } + offs = ( ( num&15 ) *20 ) + ( num / 16*320*20 ) + sy*320; + gofs = virbuff + (( y + sy ) *320 + x + sx); + for ( a = sy; a < ey; a ++ ) + { + memcpy( gofs, floorspr2 + offs + sx, ex - sx ); + offs += 320; + gofs += 320; + } +} + +void draw_shadow( int x, int y, int num, int mode ) +{ + int a, b, sx = 0, ex = 20, sy = 0, ey = 20; + char *s, *vb; + char colo; + if ( x < 0 ) sx = - x; + if ( sx > 20 ) sx = 20; + if ( x > 300 ) ex = 20 - ( x - 300 ); + if ( ex < 0 ) ex = 0; + if ( y < 0 ) sy = - y; + if ( sy > 20 ) sy = 20; + if ( y > scr_y_size - 20 ) ey = 20 - ( y - ( scr_y_size - 20 ) ); + if ( ey < 0 ) ey = 0; + if ( mode == 1 ) + { + // split mode pl1 + if ( x > 140 ) ex = 20 - ( x - ( 140 ) ); + if ( ex < 0 ) ex = 0; + } + if ( mode == 2 ) + { + // split mode pl2 + if ( x < 161 ) sx = 161 - x; + if ( sx > 20 ) sx = 20; + } + + s = shadowspr + (( sy*320 ) + num*20); + vb = virbuff + (( y + sy ) *320 + x); + + for ( a = sy; a < ey; a ++ , vb += 320, s += 320 ) + for ( b = sx; b < ex; b ++ ) + { + colo = s[b]; + if ( colo!= 0 ) vb[b] = shadow_table[vb[b]][colo]; + } +} + + // 28 x 28 +void draw_rambo( int x, int y, int angle, int num, int mode, int col ) +{ + int a, b, c, d, offs1, offs2, sx = 0, ex = 28, sy = 0, ey = 28; + int colo; + if ( x < 0 ) sx = - x; + if ( sx > 28 ) sx = 28; + if ( x > 292 ) ex = 28 - ( x - 292 ); + if ( ex < 0 ) ex = 0; + if ( y < 0 ) sy = - y; + if ( sy > 28 ) sy = 28; + if ( y > scr_y_size - 28 ) ey = 28 - ( y - ( scr_y_size - 28 ) ); + if ( ey < 0 ) ey = 0; + if ( mode == 1 ) + { + // split mode pl1 + if ( x > 132 ) ex = 28 - ( x - 132 ); + if ( ex < 0 ) ex = 0; + } + if ( mode == 2 ) + { + // split mode pl2 + if ( x < 161 ) sx = 161 - x; + if ( sx > 28 ) sx = 28; + } + offs1 = ( y + sy ) *320 + x; + offs2 = ( ( sy + 1 + ( num*29 ) ) *1160 ) + ( angle*29 ) + 1; + for ( a = sy, c = 0, d = 0; a < ey; a ++ , c += 320, d += 1160 ) + for ( b = sx; b < ex; b ++ ) + { + colo = rambospr[offs2 + d + b]; + if ( colo ) + if ( colo >= 80 &&colo <= 80 + 15 ) virbuff[offs1 + c + b] = ( char ) ( col + ( colo - 80 ) );else virbuff[offs1 + c + b] = ( char ) colo; + } +} + +void draw_sprite( int x, int y, int xs, int ys, char *spr, int xsize, int offs, int mode ) +{ + int a, b, offs1, offs2, sx = 0, ex = xs, sy = 0, ey = ys; + char *src, *dest; + char colo; + if ( x < 0 ) sx = - x; + if ( sx > xs ) sx = xs; + if ( x > 320 - xs ) ex = xs - ( x - ( 320 - xs ) ); + if ( ex < 0 ) ex = 0; + if ( y < 0 ) sy = - y; + if ( sy > ys ) sy = ys; + if ( y > scr_y_size - ys ) ey = ys - ( y - ( scr_y_size - ys ) ); + if ( ey < 0 ) ey = 0; + if ( mode == 1 ) + { + // split mode pl1 + if ( x > 160 - xs ) ex = xs - ( x - ( 160 - xs ) ); + if ( ex < 0 ) ex = 0; + } + if ( mode == 2 ) + { + // split mode pl2 + if ( x < 161 ) sx = 161 - x; + if ( sx > xs ) sx = xs; + } + offs1 = ( y + sy ) *320 + x; + offs2 = ( sy*xsize ) + offs; + src = spr + offs2 + sx; + dest = virbuff + offs1 + sx; + for ( a = sy; a < ey; a ++ , dest += 320 - ( ex - sx ), src += xsize - ( ex - sx ) ) + for ( b = sx; b < ex; b ++ ) + { + colo = *( src ++ ); + if ( colo!= 0 ) ( *dest ) = colo; + dest ++; + } +} + +void draw_trans_sprite( int x, int y, int xs, int ys, char *spr, int xsize, int offs, int mode ) +{ + int a, b, offs1, offs2, sx = 0, ex = xs, sy = 0, ey = ys; + char *src, *dest; + char colo; + if ( x < 0 ) sx = - x; + if ( sx > xs ) sx = xs; + if ( x > 320 - xs ) ex = xs - ( x - ( 320 - xs ) ); + if ( ex < 0 ) ex = 0; + if ( y < 0 ) sy = - y; + if ( sy > ys ) sy = ys; + if ( y > scr_y_size - ys ) ey = ys - ( y - ( scr_y_size - ys ) ); + if ( ey < 0 ) ey = 0; + if ( mode == 1 ) + { + // split mode pl1 + if ( x > 160 - xs ) ex = xs - ( x - ( 160 - xs ) ); + if ( ex < 0 ) ex = 0; + } + if ( mode == 2 ) + { + // split mode pl2 + if ( x < 161 ) sx = 161 - x; + if ( sx > xs ) sx = xs; + } + offs1 = ( y + sy ) *320 + x; + offs2 = ( sy*xsize ) + offs; + src = spr + offs2 + sx; + dest = virbuff + offs1 + sx; + for ( a = sy; a < ey; a ++ , dest += 320 - ( ex - sx ), src += xsize - ( ex - sx ) ) + for ( b = sx; b < ex; b ++ ) + { + colo = *( src ++ ); + if ( colo!= 0 ) + ( *dest ) = trans_table[colo][( *dest ) ]; + dest ++; + } +} + +void draw_crate( int x, int y, int type, int mode ) +{ + draw_sprite( x, y, 14, 14, cratespr, 320, type*14, mode ); +} + +void draw_enemy( int x, int y, int angle, int num, int mode, char *spr ) +{ + draw_sprite( x, y, 28, 28, spr, 1160, ( num*29*1160 ) + ( angle*29 ) + 1160 + 1, mode ); +} + +void draw_target( int x, int y, int mode ) +{ + draw_sprite( x, y, 7, 7, targetspr, 7, 0, mode ); +} + +void draw_effect( int x, int y, Effect_type *type, int num, int mode ) +{ + if ( type-> index!= FOOTPRINT &&type-> index!= SMOKE2 &&type-> index!= BLOOD2 &&type-> index!= SMOKE3 &&type-> index!= STEAM ) + draw_sprite( x - type-> xs / 2, y - type-> ys / 2, type-> xs, type-> ys, effectspr, 320, type-> offs + ( ( type-> xs + 1 ) *num ) + 321, mode ); + else + draw_trans_sprite( x - type-> xs / 2, y - type-> ys / 2, type-> xs, type-> ys, effectspr, 320, type-> offs + ( ( type-> xs + 1 ) *num ) + 321, mode ); +} + +void draw_body_part( int x, int y, int num, int mode ) +{ + draw_sprite( x, y, 20, 20, bodypartspr, 320, ( num*21 ), mode ); +} + +void draw_light( Light_table *lt, int x, int y, int num, int add, int mode ) +{ + int xs = Light_sizes[num], ys = Light_sizes[num]; + int a, b, c, sum, offs1, offs2, sx = 0, ex = xs, sy = 0, ey = ys; + x -= ( xs / 2 ); + y -= ( ys / 2 ); + if ( x < 0 ) sx = - x; + if ( sx > xs ) sx = xs; + if ( x > 320 - xs ) ex = xs - ( x - ( 320 - xs ) ); + if ( ex < 0 ) ex = 0; + if ( y < 0 ) sy = - y; + if ( sy > ys ) sy = ys; + if ( y > scr_y_size - ys ) ey = ys - ( y - ( scr_y_size - ys ) ); + if ( ey < 0 ) ey = 0; + if ( mode == 1 ) + { + // 2 pl mode pl1 + if ( x > 160 - xs ) ex = xs - ( x - ( 160 - xs ) ); + if ( ex < 0 ) ex = 0; + } + if ( mode == 2 ) + { + // 2 pl mode pl2 + if ( x < 161 ) sx = 161 - x; + if ( sx > xs ) sx = xs; + } + offs1 = ( y + sy ) *320 + x; + for ( a = sy, offs2 = a*xs, c = 0; a < ey; a ++ , c += 320, offs2 += xs ) + for ( b = sx; b < ex; b ++ ) + if ( light[num].data[offs2 + b] ) + { + sum = light[num].data[offs2 + b] + add; + if ( sum < 0 ) sum = 0;if ( sum > 15 ) sum = 15; + virbuff[offs1 + c + b] = lt-> data[virbuff[offs1 + c + b]][sum]; + } +} + +void draw_ball( int x, int y, int num ) +{ + int a, b, offs1, offs2; + offs1 = ( ( num % 16 ) *20 ) + ( 59*320 ) + ( ( num / 16 ) *( 320*20 ) ); + offs2 = ( y*320 ) + x; + for ( a = 0; a < 20; a ++ ) + memcpy( virbuff + offs2 + ( a*320 ), picture + offs2 + ( a*320 ), 20 ); + for ( a = 0; a < 20; a ++ , offs1 += 300, offs2 += 300 ) + for ( b = 0; b < 20; b ++ , offs1 ++ , offs2 ++ ) + if ( warespr[offs1]!= 0 ) virbuff[offs2] = warespr[offs1]; + offs2 = ( y*320 ) + x; + for ( a = 0; a < 20; a ++ ) + memcpy( screen + offs2 + ( a*320 ), virbuff + offs2 + ( a*320 ), 20 ); +} + +void draw_ware( int x, int y, int row, int colu ) +{ + int a, b, offs1, offs2; + offs1 = row*320*17 + colu*17; + offs2 = ( y*320 ) + x; + for ( a = 0; a < 16; a ++ , offs1 += 304, offs2 += 304 ) + for ( b = 0; b < 16; b ++ , offs1 ++ , offs2 ++ ) + if ( warespr[offs1]!= 0 ) virbuff[offs2] = warespr[offs1]; + else virbuff[offs2] = picture[offs2]; +} + +void draw_black() +{ + int level_size = level_x_size*level_y_size, a, b, ovx1, ovy1, ovy2, ovx2, offs; + ovx1 = aplayer[0]->scr_x % 20; + ovy1 = aplayer[0]->scr_y % 20; + if ( GAME_MODE!= SPLIT_SCREEN ) + { + offs = ( aplayer[0]->scr_y / 20 ) *level_x_size + ( aplayer[0]->scr_x / 20 ); + for ( a = 0; a < scr_y_size / 20 + 1; a ++ , offs += level_x_size - 17 ) + for ( b = 0; b < 17; b ++ , offs ++ ) + if ( offs < level_size ) + if ( level[offs].type == FLOOR ) + if ( !aplayer[0]->see_level[offs] ) + draw_dark_block( ( b*20 ) - ovx1, ( a*20 ) - ovy1, level[offs].num, 0 ); + } + else + { + ovx2 = aplayer[1]->scr_x % 20; + ovy2 = aplayer[1]->scr_y % 20; + offs = ( aplayer[0]->scr_y / 20 ) *level_x_size + ( aplayer[0]->scr_x / 20 ); + for ( a = 0; a < scr_y_size / 20 + 1; a ++ , offs += level_x_size - 9 ) + for ( b = 0; b < 9; b ++ , offs ++ ) + if ( offs < level_size ) + if ( level[offs].type == FLOOR ) + if ( !aplayer[0]->see_level[offs] ) + draw_dark_block( ( b*20 ) - ovx1, ( a*20 ) - ovy1, level[offs].num, 1 ); + offs = ( aplayer[1]->scr_y / 20 ) *level_x_size + ( aplayer[1]->scr_x / 20 ); + for ( a = 0; a < scr_y_size / 20 + 1; a ++ , offs += level_x_size - 9 ) + for ( b = 0; b < 9; b ++ , offs ++ ) + if ( offs < level_size ) + if ( level[offs].type == FLOOR ) + if ( !aplayer[1]->see_level[offs] ) + draw_dark_block( ( b*20 ) - ovx2 + 160, ( a*20 ) - ovy2, level[offs].num, 2 ); + } +} + +void draw_floor() +{ + int a, b, do_it, ovx1, ovy1, ovy2, ovx2, offs; + int level_size = level_x_size*level_y_size; + ovx1 = aplayer[0]->scr_x % 20; + ovy1 = aplayer[0]->scr_y % 20; + if ( GAME_MODE!= SPLIT_SCREEN ) + { + offs = ( aplayer[0]->scr_y / 20 ) *level_x_size + ( aplayer[0]->scr_x / 20 ); + for ( a = 0; a < scr_y_size / 20 + 1; a ++ , offs += level_x_size - 17 ) + for ( b = 0; b < 17; b ++ , offs ++ ) + if ( offs < level_size ) + if ( level[offs].type == FLOOR ) + { + do_it = 1; + if ( DARK_MODE ) if ( !aplayer[0]->see_level[offs] ) do_it = 0; + if ( do_it ) + draw_block( ( b*20 ) - ovx1, ( a*20 ) - ovy1, level[offs].type, level[offs].num, 0 ); + } + } + else + { + ovx2 = aplayer[1]->scr_x % 20; + ovy2 = aplayer[1]->scr_y % 20; + offs = ( aplayer[0]->scr_y / 20 ) *level_x_size + ( aplayer[0]->scr_x / 20 ); + for ( a = 0; a < scr_y_size / 20 + 1; a ++ , offs += level_x_size - 9 ) + for ( b = 0; b < 9; b ++ , offs ++ ) + if ( offs < level_size ) + if ( level[offs].type == FLOOR ) + { + do_it = 1; + if ( DARK_MODE ) if ( !aplayer[0]->see_level[offs] ) do_it = 0; + if ( do_it ) + draw_block( ( b*20 ) - ovx1, ( a*20 ) - ovy1, level[offs].type, level[offs].num, 1 ); + } + offs = ( aplayer[1]->scr_y / 20 ) *level_x_size + ( aplayer[1]->scr_x / 20 ); + for ( a = 0; a < scr_y_size / 20 + 1; a ++ , offs += level_x_size - 9 ) + for ( b = 0; b < 9; b ++ , offs ++ ) + if ( offs < level_size ) + if ( level[offs].type == FLOOR ) + { + do_it = 1; + if ( DARK_MODE ) if ( !aplayer[1]->see_level[offs] ) do_it = 0; + if ( do_it ) + draw_block( ( b*20 ) - ovx2 + 160, ( a*20 ) - ovy2, level[offs].type, level[offs].num, 2 ); + } + } +} + +void draw_shadows() +{ + int a, b, ovx1, ovy1, ovy2, ovx2, offs; + int dou, level_size = level_x_size*level_y_size; + ovx1 = aplayer[0]->scr_x % 20; + ovy1 = aplayer[0]->scr_y % 20; + if ( GAME_MODE!= SPLIT_SCREEN ) + { + offs = ( aplayer[0]->scr_y / 20 ) *level_x_size + ( aplayer[0]->scr_x / 20 ); + for ( a = 0; a < scr_y_size / 20 + 1; a ++ , offs += level_x_size - 17 ) + for ( b = 0; b < 17; b ++ , offs ++ ) + if ( offs < level_size ) + if ( level[offs].shadow > 0 ) + { + dou = 1; + if ( level[offs].type == FLOOR ) if ( DARK_MODE ) if ( !aplayer[0]->see_level[offs] ) dou = 0; + if ( dou ) draw_shadow( ( b*20 ) - ovx1, ( a*20 ) - ovy1, level[offs].shadow - 1, 0 ); + } + } + else + { + ovx2 = aplayer[1]->scr_x % 20; + ovy2 = aplayer[1]->scr_y % 20; + offs = ( aplayer[0]->scr_y / 20 ) *level_x_size + ( aplayer[0]->scr_x / 20 ); + for ( a = 0; a < scr_y_size / 20 + 1; a ++ , offs += level_x_size - 9 ) + for ( b = 0; b < 9; b ++ , offs ++ ) + if ( offs < level_size ) + if ( level[offs].shadow > 0 ) + { + dou = 1; + if ( level[offs].type == FLOOR ) if ( DARK_MODE ) if ( !aplayer[0]->see_level[offs] ) dou = 0; + if ( dou ) draw_shadow( ( b*20 ) - ovx1, ( a*20 ) - ovy1, level[offs].shadow - 1, 1 ); + } + offs = ( aplayer[1]->scr_y / 20 ) *level_x_size + ( aplayer[1]->scr_x / 20 ); + for ( a = 0; a < scr_y_size / 20 + 1; a ++ , offs += level_x_size - 9 ) + for ( b = 0; b < 9; b ++ , offs ++ ) + if ( offs < level_size ) + if ( level[offs].shadow > 0 ) + { + dou = 1; + if ( level[offs].type == FLOOR ) if ( DARK_MODE ) if ( !aplayer[1]->see_level[offs] ) dou = 0; + if ( dou ) draw_shadow( ( b*20 ) - ovx2 + 160, ( a*20 ) - ovy2, level[offs].shadow - 1, 2 ); + } + } +} + +void draw_walls() +{ + int a, b, ovx1, ovy1, ovy2, ovx2, offs; + int level_size = level_x_size*level_y_size; + ovx1 = aplayer[0]->scr_x % 20; + ovy1 = aplayer[0]->scr_y % 20; + if ( GAME_MODE!= SPLIT_SCREEN ) + { + offs = ( aplayer[0]->scr_y / 20 ) *level_x_size + ( aplayer[0]->scr_x / 20 ); + for ( a = 0; a < scr_y_size / 20 + 1; a ++ , offs += level_x_size - 17 ) + for ( b = 0; b < 17; b ++ , offs ++ ) + if ( offs < level_size ) + { + if ( level[offs].type == WALLS ) + draw_block( ( b*20 ) - ovx1, ( a*20 ) - ovy1, level[offs].type, level[offs].num, 0 ); + } + else draw_block( ( b*20 ) - ovx1, ( a*20 ) - ovy1, WALLS, 19, 0 ); + } + else + { + ovx2 = aplayer[1]->scr_x % 20; + ovy2 = aplayer[1]->scr_y % 20; + offs = ( aplayer[0]->scr_y / 20 ) *level_x_size + ( aplayer[0]->scr_x / 20 ); + for ( a = 0; a < scr_y_size / 20 + 1; a ++ , offs += level_x_size - 9 ) + for ( b = 0; b < 9; b ++ , offs ++ ) + if ( offs < level_size ) + { + if ( level[offs].type == WALLS ) + draw_block( ( b*20 ) - ovx1, ( a*20 ) - ovy1, level[offs].type, level[offs].num, 1 ); + } + else draw_block( ( b*20 ) - ovx1, ( a*20 ) - ovy1, WALLS, 19, 1 ); + offs = ( aplayer[1]->scr_y / 20 ) *level_x_size + ( aplayer[1]->scr_x / 20 ); + for ( a = 0; a < scr_y_size / 20 + 1; a ++ , offs += level_x_size - 9 ) + for ( b = 0; b < 9; b ++ , offs ++ ) + if ( offs < level_size ) + { + if ( level[offs].type == WALLS ) + draw_block( ( b*20 ) - ovx2 + 160, ( a*20 ) - ovy2, level[offs].type, level[offs].num, 2 ); + } + else draw_block( ( b*20 ) - ovx2 + 160, ( a*20 ) - ovy2, WALLS, 19, 2 ); + } + if ( GAME_MODE == SPLIT_SCREEN ) + for ( a = 160; a < 320*scr_y_size; a+=320) + virbuff[a] = 0; +} + +int chk4draw( int x, int y, int sx, int sy, int size, int mode ) +{ + if ( mode == 0 ) + if ( x > sx - size && + x < sx + 320 && + y > sy - size && + y < sy + scr_y_size ) return( 1 ); + if ( mode > 0 ) + if ( x > sx - size && + x < sx + 160 && + y > sy - size && + y < sy + scr_y_size ) return( 1 ); + return( 0 ); +} + +void draw_live_enemies() +{ + int a; + for ( a = 0; a < ENEMIES; a ++ ) + { + enemy[a].rangle = enemy[a].angle / 9; + if ( GAME_MODE!= SPLIT_SCREEN ) + if ( !enemy[a].DEAD ) + if ( chk4draw( enemy[a].x, enemy[a].y, aplayer[0]->scr_x, aplayer[0]->scr_y, 28, 0 ) ) + draw_enemy( enemy[a].x - aplayer[0]->scr_x, enemy[a].y - aplayer[0]->scr_y, enemy[a].rangle, enemy[a].ANIM, 0, enemy_info[enemy[a].type].spr ); + if ( GAME_MODE == SPLIT_SCREEN ) + if ( !enemy[a].DEAD ) + { + if ( chk4draw( enemy[a].x, enemy[a].y, aplayer[0]->scr_x, aplayer[0]->scr_y, 28, 1 ) ) + draw_enemy( enemy[a].x - aplayer[0]->scr_x, enemy[a].y - aplayer[0]->scr_y, enemy[a].rangle, enemy[a].ANIM, 1, enemy_info[enemy[a].type].spr ); + if ( chk4draw( enemy[a].x, enemy[a].y, aplayer[1]->scr_x, aplayer[1]->scr_y, 28, 1 ) ) + { + draw_enemy( ( enemy[a].x - aplayer[1]->scr_x ) + 160, enemy[a].y - aplayer[1]->scr_y, enemy[a].rangle, enemy[a].ANIM, 2, enemy_info[enemy[a].type].spr ); + } + } + } +} + +void draw_players( int pos ) +{ + int a, draw1 = 0, draw2 = 0; + if ( GAME_MODE!= SPLIT_SCREEN ) + for ( a = 0; a < MAX_PLAYERS; a ++ ) + if (player[a].enabled) + { + draw1 = 0; + if ( pos == 0 ) if ( player[a].DEAD ) draw1 = 1; + if ( pos == 1 ) if ( !player[a].DEAD ) draw1 = 1; + if ( draw1 ) + if ( chk4draw( player[a].x, player[a].y, aplayer[0]->scr_x, aplayer[0]->scr_y, 28, 0 ) ) + draw_rambo( player[a].x - aplayer[0]->scr_x, player[a].y - aplayer[0]->scr_y, player[a].rangle, player[a].ANIM, 0, player[a].color ); + } + if ( GAME_MODE == SPLIT_SCREEN ) + { + for ( a = 0; a < MAX_PLAYERS; a ++ ) + if (player[a].enabled) + { + draw1 = 0; + if ( pos == 0 ) if ( player[a].DEAD ) draw1 = 1; + if ( pos == 1 ) if ( !player[a].DEAD ) draw1 = 1; + if ( draw1 ) + { + if ( chk4draw( player[a].x, player[a].y, aplayer[0]->scr_x, aplayer[0]->scr_y, 28, 1 ) ) + draw_rambo( player[a].x - aplayer[0]->scr_x, player[a].y - aplayer[0]->scr_y, player[a].rangle, player[a].ANIM, 1, player[a].color ); + if ( chk4draw( player[a].x, player[a].y, aplayer[1]->scr_x, aplayer[1]->scr_y, 28, 2 ) ) + draw_rambo( player[a].x - aplayer[1]->scr_x + 160, player[a].y - aplayer[1]->scr_y, player[a].rangle, player[a].ANIM, 2, player[a].color ); + } + } + } +} + +void draw_gae_shadows() +{ + int a, xo = - 1, yo = 7; + for ( a = 0; a < ENEMIES; a ++ ) + { + if ( GAME_MODE!= SPLIT_SCREEN ) + if ( !enemy[a].DEAD ) + if ( chk4draw( enemy[a].x, enemy[a].y, aplayer[0]->scr_x, aplayer[0]->scr_y, 28, 0 ) ) + draw_shadow( enemy[a].x - aplayer[0]->scr_x + xo, enemy[a].y - aplayer[0]->scr_y + yo, 5, 0 ); + if ( GAME_MODE == SPLIT_SCREEN ) + if ( !enemy[a].DEAD ) + { + if ( chk4draw( enemy[a].x, enemy[a].y, aplayer[0]->scr_x, aplayer[0]->scr_y, 28, 1 ) ) + draw_shadow( enemy[a].x - aplayer[0]->scr_x + xo, enemy[a].y - aplayer[0]->scr_y + yo, 5, 1 ); + if ( chk4draw( enemy[a].x, enemy[a].y, player[1].scr_x, player[1].scr_y, 28, 1 ) ) + draw_shadow( enemy[a].x - aplayer[1]->scr_x + 160 + xo, enemy[a].y - aplayer[1]->scr_y + yo, 5, 2 ); + } + } + if ( GAME_MODE!= SPLIT_SCREEN ) + for ( a = 0; a < MAX_PLAYERS; a ++ ) + if (player[a].enabled) + if ( !player[a].DEAD ) + if ( chk4draw( player[a].x, player[a].y, aplayer[0]->scr_x, aplayer[0]->scr_y, 28, 0 ) ) + draw_shadow( player[a].x - aplayer[0]->scr_x + xo, player[a].y - aplayer[0]->scr_y + yo, 5, 0 ); + if ( GAME_MODE == SPLIT_SCREEN ) + { + for ( a = 0; a < MAX_PLAYERS; a ++ ) + if (player[a].enabled) + if ( !player[a].DEAD ) + if ( chk4draw( player[a].x, player[a].y, aplayer[0]->scr_x, aplayer[0]->scr_y, 28, 1 ) ) + draw_shadow( player[a].x - aplayer[0]->scr_x + xo, player[a].y - aplayer[0]->scr_y + yo, 5, 1 ); + for ( a = 0; a < MAX_PLAYERS; a ++ ) + if (player[a].enabled) + if ( !player[a].DEAD ) + if ( chk4draw( player[a].x, player[a].y, aplayer[1]->scr_x, aplayer[1]->scr_y, 28, 2 ) ) + draw_shadow( player[a].x - aplayer[1]->scr_x + 160 + xo, player[a].y - aplayer[1]->scr_y + yo, 5, 2 ); + } +} + +void draw_effects( int pos ) +{ + int a; + for ( a = 0; a < MAX_EFFECTS; a ++ ) + if ( effect[a].IN_USE ) + if ( effect[a].type-> order == pos ) + { + if ( GAME_MODE!= SPLIT_SCREEN ) + { + if ( chk4draw( effect[a].x - ( effect[a].type-> xs / 2 ), effect[a].y - ( effect[a].type-> ys / 2 ), aplayer[0]->scr_x, aplayer[0]->scr_y, 25, 0 ) ) + switch( effect[a].type-> index ) + { + case EXPLO:draw_light( effect[a].lt, effect[a].x - aplayer[0]->scr_x, effect[a].y - aplayer[0]->scr_y, 7, 5 - effect[a].count*0.8, 0 ); break; + case METAL:if (LIGHT_EFFECTS) draw_light( effect[a].lt, effect[a].x - aplayer[0]->scr_x, effect[a].y - aplayer[0]->scr_y, 0, - effect[a].count, 0 ); break; + case SMOKE:if (LIGHT_EFFECTS) draw_light( effect[a].lt, effect[a].x - aplayer[0]->scr_x, effect[a].y - aplayer[0]->scr_y, 1, - effect[a].count, 0 ); break; + case TELEPORT:if (LIGHT_EFFECTS) draw_light( effect[a].lt, effect[a].x - aplayer[0]->scr_x, effect[a].y - aplayer[0]->scr_y, 4, 0, 0 ); break; + } + if (effect[a].type-> index != EXPLO) + draw_effect( effect[a].x - aplayer[0]->scr_x, effect[a].y - aplayer[0]->scr_y, effect[a].type, effect[a].count / effect[a].type-> delay, 0 ); + } + if ( GAME_MODE == SPLIT_SCREEN ) + { + if ( chk4draw( effect[a].x - ( effect[a].type-> xs / 2 ), effect[a].y - ( effect[a].type-> ys / 2 ), aplayer[0]->scr_x, aplayer[0]->scr_y, 25, 1 ) ) + { + if ( LIGHT_EFFECTS ) + switch( effect[a].type-> index ) + { + case EXPLO:draw_light( effect[a].lt, effect[a].x - aplayer[0]->scr_x, effect[a].y - aplayer[0]->scr_y, 7, 5 - effect[a].count*0.8, 1 ); break; + case METAL:if (LIGHT_EFFECTS) draw_light( effect[a].lt, effect[a].x - aplayer[0]->scr_x, effect[a].y - aplayer[0]->scr_y, 0, - effect[a].count, 1 ); break; + case SMOKE:if (LIGHT_EFFECTS) draw_light( effect[a].lt, effect[a].x - aplayer[0]->scr_x, effect[a].y - aplayer[0]->scr_y, 1, - effect[a].count, 1 ); break; + case TELEPORT:if (LIGHT_EFFECTS) draw_light( effect[a].lt, effect[a].x - aplayer[0]->scr_x, effect[a].y - aplayer[0]->scr_y, 4, 0, 1 ); break; + } + if (effect[a].type-> index != EXPLO) + draw_effect( effect[a].x - aplayer[0]->scr_x, effect[a].y - aplayer[0]->scr_y, effect[a].type, effect[a].count / effect[a].type-> delay, 1 ); + } + if ( chk4draw( effect[a].x - ( effect[a].type-> xs / 2 ), effect[a].y - ( effect[a].type-> ys / 2 ), aplayer[1]->scr_x, aplayer[1]->scr_y, 25, 1 ) ) + { + if ( LIGHT_EFFECTS ) + switch( effect[a].type-> index ) + { + case EXPLO:draw_light( effect[a].lt, effect[a].x - aplayer[1]->scr_x + 160, effect[a].y - aplayer[1]->scr_y, 7, 5 - effect[a].count*0.8, 2 ); break; + case METAL:if (LIGHT_EFFECTS) draw_light( effect[a].lt, effect[a].x - aplayer[1]->scr_x + 160, effect[a].y - aplayer[1]->scr_y, 0, - effect[a].count, 2 ); break; + case SMOKE:if (LIGHT_EFFECTS) draw_light( effect[a].lt, effect[a].x - aplayer[1]->scr_x + 160, effect[a].y - aplayer[1]->scr_y, 1, - effect[a].count, 2 ); break; + case TELEPORT:if (LIGHT_EFFECTS) draw_light( effect[a].lt, effect[a].x - aplayer[1]->scr_x + 160, effect[a].y - aplayer[1]->scr_y, 4, 0, 2 ); break; + } + if (effect[a].type-> index != EXPLO) + draw_effect( effect[a].x - aplayer[1]->scr_x + 160, effect[a].y - aplayer[1]->scr_y, effect[a].type, effect[a].count / effect[a].type-> delay, 2 ); + } + } + } +} + +void draw_spots() +{ + int a; + for ( a = 0; a < Spot_amount; a ++ ) + { + if ( GAME_MODE!= SPLIT_SCREEN ) + if ( chk4draw( spot_light[a].x - 30, spot_light[a].y - 30, aplayer[0]->scr_x, aplayer[0]->scr_y, 60, 0 ) ) + draw_light( &normal_l, spot_light[a].x - aplayer[0]->scr_x, spot_light[a].y - aplayer[0]->scr_y, spot_light[a].size, 2.5*sini[Spot_count] + 2, 0 ); + if ( GAME_MODE == SPLIT_SCREEN ) + { + if ( chk4draw( spot_light[a].x - 30, spot_light[a].y - 30, aplayer[0]->scr_x, aplayer[0]->scr_y, 60, 1 ) ) + draw_light( &normal_l, spot_light[a].x - aplayer[0]->scr_x, spot_light[a].y - aplayer[0]->scr_y, spot_light[a].size, 2.5*sini[Spot_count] + 2, 1 ); + if ( chk4draw( spot_light[a].x - 30, spot_light[a].y - 30, aplayer[1]->scr_x, aplayer[1]->scr_y, 60, 1 ) ) + draw_light( &normal_l, spot_light[a].x - aplayer[1]->scr_x + 160, spot_light[a].y - aplayer[1]->scr_y, spot_light[a].size, 2.5*sini[Spot_count] + 2, 2 ); + } + } +} + +void draw_bullets() +{ + int a; + for ( a = 0; a < MAX_BULLETS; a ++ ) + if ( bullet[a].IN_USE ) + { + if ( GAME_MODE!= SPLIT_SCREEN ) + if ( chk4draw( bullet[a].x, bullet[a].y, aplayer[0]->scr_x, aplayer[0]->scr_y, 20, 0 ) ) + { + if ( bullet[a].type-> light != NULL ) + draw_light( bullet[a].type-> light, bullet[a].x - aplayer[0]->scr_x, bullet[a].y - aplayer[0]->scr_y, bullet[a].type-> lsize, bullet[a].type-> llum + bullet[a].count*bullet[a].type-> ladd, 0 ); + if ( bullet[a].type-> sprite != NULL ) + draw_sprite( bullet[a].x - ( int ) ( bullet[a].type-> xs >> 1 ) - aplayer[0]->scr_x, bullet[a].y - ( int ) ( bullet[a].type-> ys >> 1 ) - aplayer[0]->scr_y, bullet[a].type-> xs, bullet[a].type-> ys, bullet[a].type-> sprite, bullet[a].type-> xsize, bullet[a].type-> offs, 0 ); + } + if ( GAME_MODE == SPLIT_SCREEN ) + { + if ( chk4draw( bullet[a].x, bullet[a].y, aplayer[0]->scr_x, aplayer[0]->scr_y, 20, 1 ) ) + { + if ( bullet[a].type-> light != NULL ) + draw_light( bullet[a].type-> light, bullet[a].x - aplayer[0]->scr_x, bullet[a].y - aplayer[0]->scr_y, bullet[a].type-> lsize, bullet[a].type-> llum + bullet[a].count*bullet[a].type-> ladd, 1 ); + if ( bullet[a].type-> sprite != NULL ) + draw_sprite( bullet[a].x - ( int ) ( bullet[a].type-> xs >> 1 ) - aplayer[0]->scr_x, bullet[a].y - ( int ) ( bullet[a].type-> ys >> 1 ) - aplayer[0]->scr_y, bullet[a].type-> xs, bullet[a].type-> ys, bullet[a].type-> sprite, bullet[a].type-> xsize, bullet[a].type-> offs, 1 ); + } + if ( chk4draw( bullet[a].x, bullet[a].y, aplayer[1]->scr_x, aplayer[1]->scr_y, 20, 1 ) ) + { + if ( bullet[a].type-> light != NULL ) + draw_light( bullet[a].type-> light, bullet[a].x - aplayer[1]->scr_x + 160, bullet[a].y - aplayer[1]->scr_y, bullet[a].type-> lsize, bullet[a].type-> llum + bullet[a].count*bullet[a].type-> ladd, 2 ); + if ( bullet[a].type-> sprite != NULL ) + draw_sprite( bullet[a].x - ( int ) ( bullet[a].type-> xs >> 1 ) - aplayer[1]->scr_x + 160, bullet[a].y - ( int ) ( bullet[a].type-> ys >> 1 ) - aplayer[1]->scr_y, bullet[a].type-> xs, bullet[a].type-> ys, bullet[a].type-> sprite, bullet[a].type-> xsize, bullet[a].type-> offs, 2 ); + } + } + } +} + +void draw_body_parts() +{ + int a; + for ( a = 0; a < MAX_BODY_PARTS; a ++ ) + if ( body_part[a].IN_USE ) + { + if ( GAME_MODE!= SPLIT_SCREEN ) + if ( chk4draw( body_part[a].x, body_part[a].y, aplayer[0]->scr_x, aplayer[0]->scr_y, 20, 0 ) ) + draw_body_part( body_part[a].x - aplayer[0]->scr_x, body_part[a].y - aplayer[0]->scr_y, body_part[a].num, 0 ); + if ( GAME_MODE == SPLIT_SCREEN ) + { + if ( chk4draw( body_part[a].x, body_part[a].y, aplayer[0]->scr_x, aplayer[0]->scr_y, 20, 1 ) ) + draw_body_part( body_part[a].x - aplayer[0]->scr_x, body_part[a].y - aplayer[0]->scr_y, body_part[a].num, 1 ); + if ( chk4draw( body_part[a].x, body_part[a].y, aplayer[1]->scr_x, aplayer[1]->scr_y, 20, 1 ) ) + draw_body_part( body_part[a].x - aplayer[1]->scr_x + 160, body_part[a].y - aplayer[1]->scr_y, body_part[a].num, 2 ); + } + } +} + +void draw_infos() +{ + char text[20]; + int x; + writefonts( 3, scr_y_size - 15, weapon[aplayer[0]->curr_weapon].name, 1 ); + x = aplayer[0]->bullets[weapon[aplayer[0]->curr_weapon].btype - 1] / bullet_type[weapon[aplayer[0]->curr_weapon].btype].mul; + if ( x < 0 ) x = 1; + itoa( x, text, 10 ); + if ( aplayer[0]->curr_weapon > 0 ) writefonts( 3, scr_y_size - 23, text, 7*16 ); + if ( GAME_MODE == SPLIT_SCREEN ) + { + writefonts( 3 + 160, scr_y_size - 15, weapon[aplayer[1]->curr_weapon].name, 1 ); + x = aplayer[1]->bullets[weapon[aplayer[1]->curr_weapon].btype - 1] / bullet_type[weapon[aplayer[1]->curr_weapon].btype].mul; + if ( x < 0 ) x = 1; + itoa( x, text, 10 ); + if ( aplayer[1]->curr_weapon > 0 ) writefonts( 3 + 160, scr_y_size - 23, text, 7*16 ); + } +} + +void draw_energies() +{ + int a, offs = ( ( scr_y_size - 5 ) *320 ) + 3; + float div = ( ( float ) ( aplayer[0]->max_energy + ( aplayer[0]->shield*10 ) ) / 5 ) / 15; + for ( a = 0; a < aplayer[0]->energy / 5; a ++ ) + { + virbuff[offs + a] = 239 - ( a / div ); + virbuff[offs + a + 320] = 239 - ( a / div ); + } + if ( GAME_MODE == SPLIT_SCREEN ) + { + offs = ( ( scr_y_size - 5 ) *320 ) + 3 + 160; + div = ( ( float ) ( aplayer[1]->max_energy + ( aplayer[1]->shield*10 ) ) / 5 ) / 15; + for ( a = 0; a < aplayer[1]->energy / 5; a ++ ) + { + virbuff[offs + a] = 239 - ( a / div ); + virbuff[offs + a + 320] = 239 - ( a / div ); + } + } +} + +void map() +{ + int a, b, offs, cx, cy, type; + if ( GAME_MODE!= SPLIT_SCREEN ) + { + cx = 320 - ( level_x_size ); + cy = 0; + } + if ( GAME_MODE == SPLIT_SCREEN ) + { + cx = 160 - ( level_x_size / 2 ); + cy = ( scr_y_size / 2 ) - ( level_y_size / 2 ); + } + offs = cy*320 + cx; + for ( a = 0; a < level_y_size; a ++ , offs += ( 320 - level_x_size ) ) + for ( b = 0; b < level_x_size; b ++ , offs ++ ) + { + type = level[a*level_x_size + b].type; + if ( type == WALLS ) virbuff[offs] = 16; + else virbuff[offs] = shadow_table[virbuff[offs]][15]; + } + for ( a = 0; a < ENEMIES; a ++ ) + if ( enemy[a].DEAD ) + virbuff[( ( int ) ( ( enemy[a].y + 15 ) / 20 ) + cy ) *320 + ( int ) ( ( enemy[a].x + 15 ) / 20 ) + cx] = 9; + if ( SHOW_ENEMIES ) + for ( a = 0; a < ENEMIES; a ++ ) + if ( !enemy[a].DEAD ) + virbuff[( ( int ) ( ( enemy[a].y + 15 ) / 20 ) + cy ) *320 + ( int ) ( ( enemy[a].x + 15 ) / 20 ) + cx] = 3; + if (GAME_MODE!=SPLIT_SCREEN) + for ( a = 0; a < MAX_PLAYERS; a ++ ) + if (KILLING_MODE!=DEATHMATCH || aplayer[0]->tindex==a) + if (player[a].enabled) + virbuff[( ( int ) ( ( player[a].y + 15 ) / 20 ) + cy ) *320 + ( int ) ( ( player[a].x + 15 ) / 20 ) + cx] = ( char ) player[a].color; +} + +void draw_box1( int x1, int y1, int x2, int y2, int add ) +{ + int a, b, c, offs = ( y1*320 ) + x1; + for ( a = 0; a < ( y2 - y1 ); a ++ , offs += ( 320 - ( x2 - x1 ) ) ) + for ( b = 0; b < ( x2 - x1 ); b ++ , offs ++ ) + { + if ( a == 0 ||a == y2 - y1 - 1 ||b == 0 ||b == x2 - x1 - 1 ) + c = picture[offs] + 1; + else c = picture[offs] - add; + if ( c < 0 ) c = 0; + if ( c > 63 ) c = 63; + picture[offs] = ( char ) c; + } +} + +void rectangle( int x1, int y1, int x2, int y2, int col ) +{ + int a, offs, offs1, offs2, offs3; + offs1 = y1*320 + x1; + offs2 = y1*320 + x2; + offs3 = y2*320 + x1; + memset( virbuff + offs1, col, ( x2 - x1 ) + 1 ); + memset( virbuff + offs3, col, ( x2 - x1 ) + 1 ); + for( a = 0, offs = offs1 + 320; a < ( y2 - y1 ) - 1; a ++ , offs += 320 ) + virbuff[offs] = ( char ) col; + for( a = 0, offs = offs2 + 320; a < ( y2 - y1 ) - 1; a ++ , offs += 320 ) + virbuff[offs] = ( char ) col; +} + +void draw_hits() +{ + if ( GAME_MODE!= SPLIT_SCREEN ) + if ( aplayer[0]->HIT > 0 ) + rectangle( 0, 0, 319, scr_y_size - 1, ( ( 4*16 ) - 1 ) - aplayer[0]->HIT ); + if ( GAME_MODE == SPLIT_SCREEN ) + { + if ( aplayer[0]->HIT > 0 ) + rectangle( 0, 0, 159, scr_y_size - 1, ( ( 4*16 ) - 1 ) - aplayer[0]->HIT ); + if ( aplayer[1]->HIT > 0 ) + rectangle( 161, 0, 319, scr_y_size - 1, ( ( 4*16 ) - 1 ) - aplayer[1]->HIT ); + } +} + +void draw_targets() +{ + int a, dist; + float x, y; + static int plot_count = 0; + plot_count ++; + if ( GAME_MODE!= SPLIT_SCREEN ) + if ( !aplayer[0]->DEAD ) + if ( weapon[aplayer[0]->curr_weapon].gun ) + if ( aplayer[0]->TARGET ) + { + x = aplayer[0]->x + 14 + 10*sini[aplayer[0]->rangle2]; + y = aplayer[0]->y + 14 + 10*cosi[aplayer[0]->rangle2]; + dist = bullet_type[weapon[aplayer[0]->curr_weapon].btype].time*bullet_type[weapon[aplayer[0]->curr_weapon].btype].speed; + for ( a = 0; a < dist &&x - aplayer[0]->scr_x >= 0 &&x - aplayer[0]->scr_x < 320 &&y - aplayer[0]->scr_y >= 0 &&y - aplayer[0]->scr_y < scr_y_size &&level[( int ) ( y / 20 ) *level_x_size + ( int ) ( x / 20 ) ].type == FLOOR; a ++ ) + { + if ( ( a - ( int ) ( plot_count / 2 ) ) % 6 == 0 ) + virbuff[( int ) ( y - aplayer[0]->scr_y ) *320 + ( int ) ( x - aplayer[0]->scr_x ) ] = 9*16; + x += sini[aplayer[0]->rangle2]; + y += cosi[aplayer[0]->rangle2]; + } + if ( a == dist ||level[( int ) ( y / 20 ) *level_x_size + ( int ) ( x / 20 ) ].type == WALLS ) draw_target( x - 3 - aplayer[0]->scr_x, y - 3 - aplayer[0]->scr_y, 0 ); + } + if ( GAME_MODE == SPLIT_SCREEN ) + { + if ( !aplayer[0]->DEAD ) + if ( weapon[aplayer[0]->curr_weapon].gun ) + if ( aplayer[0]->TARGET ) + { + x = aplayer[0]->x + 14 + 10*sini[aplayer[0]->rangle2]; + y = aplayer[0]->y + 14 + 10*cosi[aplayer[0]->rangle2]; + dist = bullet_type[weapon[aplayer[0]->curr_weapon].btype].time*bullet_type[weapon[aplayer[0]->curr_weapon].btype].speed; + for ( a = 0; a < dist &&x - aplayer[0]->scr_x >= 0 &&x - aplayer[0]->scr_x < 160 &&y - aplayer[0]->scr_y >= 0 &&y - aplayer[0]->scr_y < scr_y_size &&level[( int ) ( y / 20 ) *level_x_size + ( int ) ( x / 20 ) ].type == FLOOR; a ++ ) + { + if ( ( a - ( int ) ( plot_count / 2 ) ) % 6 == 0 ) + virbuff[( int ) ( y - aplayer[0]->scr_y ) *320 + ( int ) ( x - aplayer[0]->scr_x ) ] = 9*16; + x += sini[aplayer[0]->rangle2]; + y += cosi[aplayer[0]->rangle2]; + } + if ( a == dist ||level[( int ) ( y / 20 ) *level_x_size + ( int ) ( x / 20 ) ].type == WALLS ) draw_target( x - 3 - aplayer[0]->scr_x, y - 3 - aplayer[0]->scr_y, 1 ); + } + if ( !aplayer[1]->DEAD ) + if ( weapon[aplayer[1]->curr_weapon].gun ) + if ( aplayer[1]->TARGET ) + { + dist = bullet_type[weapon[aplayer[1]->curr_weapon].btype].time*bullet_type[weapon[aplayer[1]->curr_weapon].btype].speed; + x = aplayer[1]->x + 14 + 10*sini[aplayer[1]->rangle2]; + y = aplayer[1]->y + 14 + 10*cosi[aplayer[1]->rangle2]; + for ( a = 0; a < dist &&x - aplayer[1]->scr_x > 0 &&x - aplayer[1]->scr_x < 160 &&y - aplayer[1]->scr_y >= 0 &&y - aplayer[1]->scr_y < scr_y_size &&level[( int ) ( y / 20 ) *level_x_size + ( int ) ( x / 20 ) ].type == FLOOR; a ++ ) + { + if ( ( a - ( int ) ( plot_count / 2 ) ) % 6 == 0 ) + virbuff[( int ) ( y - aplayer[1]->scr_y ) *320 + ( int ) ( x - aplayer[1]->scr_x ) + 160] = 9*16; + x += sini[aplayer[1]->rangle2]; + y += cosi[aplayer[1]->rangle2]; + } + if ( a == dist ||level[( int ) ( y / 20 ) *level_x_size + ( int ) ( x / 20 ) ].type == WALLS ) draw_target( x - 3 - aplayer[1]->scr_x + 160, y - 3 - aplayer[1]->scr_y, 2 ); + } + } +} + +void draw_crates() +{ + int a; + for ( a = 0; a < MAX_CRATES; a ++ ) + if ( crate[a].IN_USE ) + if ( crate[a].text_count == 0 ) + { + if ( GAME_MODE!= SPLIT_SCREEN ) + if ( chk4draw( crate[a].x, crate[a].y, aplayer[0]->scr_x, aplayer[0]->scr_y, 14, 0 ) ) + { + if ( LIGHT_EFFECTS ) draw_light( &normal_l, crate[a].x - aplayer[0]->scr_x + 7, crate[a].y - aplayer[0]->scr_y + 7, 4, 2, 0 ); + draw_crate( crate[a].x - aplayer[0]->scr_x, crate[a].y - aplayer[0]->scr_y, crate[a].type, 0 ); + } + if ( GAME_MODE == SPLIT_SCREEN ) + { + if ( chk4draw( crate[a].x, crate[a].y, aplayer[0]->scr_x, aplayer[0]->scr_y, 14, 1 ) ) + { + if ( LIGHT_EFFECTS ) draw_light( &normal_l, crate[a].x - aplayer[0]->scr_x + 7, crate[a].y - aplayer[0]->scr_y + 7, 4, 2, 1 ); + draw_crate( crate[a].x - aplayer[0]->scr_x, crate[a].y - aplayer[0]->scr_y, crate[a].type, 1 ); + } + if ( chk4draw( crate[a].x, crate[a].y, aplayer[1]->scr_x, aplayer[1]->scr_y, 14, 1 ) ) + { + if ( LIGHT_EFFECTS ) draw_light( &normal_l, crate[a].x - aplayer[1]->scr_x + 7 + 160, crate[a].y - aplayer[1]->scr_y + 7, 4, 2, 2 ); + draw_crate( crate[a].x - aplayer[1]->scr_x + 160, crate[a].y - aplayer[1]->scr_y, crate[a].type, 2 ); + } + } + } +} + +void draw_crate_texts() +{ + int a; + for ( a = 0; a < MAX_CRATES; a ++ ) + if ( crate[a].IN_USE ) + if ( crate[a].text_count > 0 ) + writefonts( crate[a].text_x, crate[a].text_y, crate[a].text, 32 ); +} + +void draw_kills() +{ + char text[5], text2[20]; + int a,b=0; + if ( GAME_MODE == SPLIT_SCREEN ) + { + itoa( aplayer[0]->player_kills, text, 10 ); + writefonts( 3, 3, text, 48 ); + itoa( aplayer[1]->player_kills, text, 10 ); + writefonts( 317 - str_length( text ), 3, text, 144 ); + } + else + for ( a = 0; a < MAX_PLAYERS;a++) + if (player[a].enabled) + { + strcpy( text2, player[a].name ); + itoa( player[a].player_kills, text, 10 ); + strcat( text2, " " ); + strcat( text2, text ); + writefonts( 3 + ( b % 4 ) *80, 3 + ( b / 4 ) *10, text2, player[a].color ); + b++; + } +} + diff --git a/SRC/DRAW.H b/SRC/DRAW.H new file mode 100644 index 0000000..96e4ce6 --- /dev/null +++ b/SRC/DRAW.H @@ -0,0 +1,40 @@ +#ifndef __TK___DRAW__ +#define __TK___DRAW__ +#include "classes.h" +void draw_block( int x, int y, int type, int num, int mode ); +void draw_dark_block( int x, int y, int num, int mode ); +void draw_rambo( int x, int y, int angle, int num, int mode, int col ); +void draw_shadow( int x, int y, int num, int mode ); +void draw_sprite( int x, int y, int xs, int ys, char *spr, int xsize, int offs, int mode ); +void draw_trans_sprite( int x, int y, int xs, int ys, char *spr, int xsize, int offs, int mode ); +void draw_crate( int x, int y, int type, int mode ); +void draw_enemy( int x, int y, int angle, int num, int mode, char *spr ); +void draw_target( int x, int y, int mode ); +void draw_effect( int x, int y, Effect_type *type, int num, int mode ); +void draw_body_part( int x, int y, int num, int mode ); +void draw_light( Light_table *lt, int x, int y, int num, int add, int mode ); +void draw_ball( int x, int y, int num ); +void draw_ware( int x, int y, int row, int colu ); +void draw_black(); +void draw_floor(); +void draw_shadows(); +void draw_walls(); +int chk4draw( int x, int y, int sx, int sy, int size, int mode ); +void draw_live_enemies(); +void draw_players( int pos ); +void draw_gae_shadows(); +void draw_effects( int pos ); +void draw_spots(); +void draw_bullets(); +void draw_body_parts(); +void draw_infos(); +void draw_energies(); +void map(); +void draw_box1( int x1, int y1, int x2, int y2, int add ); +void rectangle( int x1, int y1, int x2, int y2, int col ); +void draw_hits(); +void draw_targets(); +void draw_crates(); +void draw_crate_texts(); +void draw_kills(); +#endif diff --git a/SRC/DRAW.OBJ b/SRC/DRAW.OBJ new file mode 100644 index 0000000..4a7167a Binary files /dev/null and b/SRC/DRAW.OBJ differ diff --git a/SRC/EFP.OBJ b/SRC/EFP.OBJ new file mode 100644 index 0000000..faa0533 Binary files /dev/null and b/SRC/EFP.OBJ differ diff --git a/SRC/EFP/EFP.BAK b/SRC/EFP/EFP.BAK new file mode 100644 index 0000000..95a7574 --- /dev/null +++ b/SRC/EFP/EFP.BAK @@ -0,0 +1,47 @@ +#include +#include +#include +#include "../error/error.h" + +void load_efp(char *name,char *kuva,int offs){ + +char header[7]; +unsigned int p; +unsigned short w,h; + +short tavu,tavu2; +FILE *efp=fopen(name,"rb"); + +if (!efp) error("File %s is missing\n",name); + +fseek(efp,offs,SEEK_SET); + +fread(header,6,1,efp); +if (strncmp(header,"EF pic",6) ) error("File is not an EF pic!\n"); + +fseek(efp,6+offs,SEEK_SET); + +fread(&w,2,1,efp); +fread(&h,2,1,efp); + +for(p=0;p192) { + tavu2=(short)fgetc(efp); + memset(kuva+p,tavu2,tavu-192); + p+=tavu-192; + } else kuva[p++]=(char)tavu; + } +fclose(efp); + +} + + +void load_efp_pal(char *name,char *paletti){ +short c; +FILE *efp=fopen(name,"rb"); +fseek(efp,-768,SEEK_END); + for(c=0;c<768;c++) paletti[c]=(char)fgetc(efp); +fclose(efp); +} + diff --git a/SRC/EFP/EFP.CPP b/SRC/EFP/EFP.CPP new file mode 100644 index 0000000..8f9128e --- /dev/null +++ b/SRC/EFP/EFP.CPP @@ -0,0 +1,48 @@ +#include +#include +#include +#include "efp.h" +#include "../error/error.h" + +void load_efp(char *name,char *kuva,int offs){ + +char header[7]; +unsigned int p; +unsigned short w,h; + +short tavu,tavu2; +FILE *efp=fopen(name,"rb"); + +if (!efp) error("File %s is missing\n",name); + +fseek(efp,offs,SEEK_SET); + +fread(header,6,1,efp); +if (strncmp(header,"EF pic",6) ) error("File is not an EF pic!\n"); + +fseek(efp,6+offs,SEEK_SET); + +fread(&w,2,1,efp); +fread(&h,2,1,efp); + +for(p=0;p192) { + tavu2=(short)fgetc(efp); + memset(kuva+p,tavu2,tavu-192); + p+=tavu-192; + } else kuva[p++]=(char)tavu; + } +fclose(efp); + +} + + +void load_efp_pal(char *name,char *paletti){ +short c; +FILE *efp=fopen(name,"rb"); +fseek(efp,-768,SEEK_END); + for(c=0;c<768;c++) paletti[c]=(char)fgetc(efp); +fclose(efp); +} + diff --git a/SRC/EFP/EFP.H b/SRC/EFP/EFP.H new file mode 100644 index 0000000..42f724c --- /dev/null +++ b/SRC/EFP/EFP.H @@ -0,0 +1,11 @@ +#ifndef __EFP___H_ +#define __EFP___H_ + +extern "C" +{ + +void load_efp(char *name,char *kuva,int offs); +void load_efp_pal(char *name,char *paletti); + +} +#endif diff --git a/SRC/ERROR.OBJ b/SRC/ERROR.OBJ new file mode 100644 index 0000000..a8b8d11 Binary files /dev/null and b/SRC/ERROR.OBJ differ diff --git a/SRC/ERROR/ERROR.BAK b/SRC/ERROR/ERROR.BAK new file mode 100644 index 0000000..240ad3c --- /dev/null +++ b/SRC/ERROR/ERROR.BAK @@ -0,0 +1,20 @@ +#include +#include +#include +#include +#include + +void error(char *fmt,...) +{ auto va_list ap; + extern KeyboardHandler *CURRENTHANDLER; + + vesa_set_mode(0x3); + if (CURRENTHANDLER!=NULL) CURRENTHANDLER->deinit(); + + va_start(ap,fmt); + vprintf(fmt,ap); + va_end(ap); + + exit(1); +} + diff --git a/SRC/ERROR/ERROR.CPP b/SRC/ERROR/ERROR.CPP new file mode 100644 index 0000000..240ad3c --- /dev/null +++ b/SRC/ERROR/ERROR.CPP @@ -0,0 +1,20 @@ +#include +#include +#include +#include +#include + +void error(char *fmt,...) +{ auto va_list ap; + extern KeyboardHandler *CURRENTHANDLER; + + vesa_set_mode(0x3); + if (CURRENTHANDLER!=NULL) CURRENTHANDLER->deinit(); + + va_start(ap,fmt); + vprintf(fmt,ap); + va_end(ap); + + exit(1); +} + diff --git a/SRC/ERROR/ERROR.H b/SRC/ERROR/ERROR.H new file mode 100644 index 0000000..992f304 --- /dev/null +++ b/SRC/ERROR/ERROR.H @@ -0,0 +1,4 @@ +#ifndef __ERROR_H_ +#define __ERROR_H_ +void error(char *fmt,...); +#endif diff --git a/SRC/ERROR/ERROR.OBJ b/SRC/ERROR/ERROR.OBJ new file mode 100644 index 0000000..19cc9dd Binary files /dev/null and b/SRC/ERROR/ERROR.OBJ differ diff --git a/SRC/FADE.CPP b/SRC/FADE.CPP new file mode 100644 index 0000000..aabd7d4 --- /dev/null +++ b/SRC/FADE.CPP @@ -0,0 +1,63 @@ +#include "globvar.h" +#include < gfunc.h > +#include < math.h > +#include < stdlib.h > +#include < string.h > +#define max( a, b ) a > b?a:b +int sine[256]; +void Draw_Phase( int phase, char *image, char *pal ) +{ + int x, y, yfix, xfix, yg, l; + l = ( phase*30 ) >> 8; + for ( y = 0, yg = 0; y < scr_y_size; y ++ ) + { + yfix = 320*( ( l*sine[( y + phase ) &0xff] ) >> 8 ); + if ( yfix + yg < 0||yfix + yg >= 320*scr_y_size ) memset( screen + yg, 0, 320 ); + else for ( x = 0; x < 320; x ++ ) + { + xfix = x + ( ( l*sine[( x + phase ) &0xff] ) >> 8 ); + if ( xfix > 0&&xfix < 320 ) screen[yg + x] = image[yg + xfix + yfix]; + else screen[yg + x] = 0; + } + yg += 320; + } + setpal( pal, max( 256 - phase, 0 ) ); +} + +#define FADE_SPEED 10 +void fadein( char *image, char *pal ) +{ + int old_c = 0, alku; + setpal( pal, 0 ); + alku = framecount; + while( alku + ( 256 / FADE_SPEED ) > framecount ) + { + while ( framecount == old_c ); + old_c = framecount; + Draw_Phase( 256 - ( framecount - alku ) *FADE_SPEED, image, pal ); + } + setpal( pal, 256 ); + memcpy( screen, image, 320*scr_y_size ); +} + +void fadeout( char *image, char *pal ) +{ + int alku, old_c; + alku = framecount; + while( alku + ( 256 / FADE_SPEED ) > framecount ) + { + while ( framecount == old_c ); + old_c = framecount; + Draw_Phase( ( framecount - alku ) *FADE_SPEED, image, pal ); + } + setpal( pal, 0 ); + memset( screen, 0, 320*scr_y_size ); +} + +void CalCuLaTE_Sine_Table_AND_Be_Happy() +{ + int a; + for ( a = 0; a < 256; a ++ ) + sine[a] = 255*( sin( ( float ) a / 256*pi*2 ) ); +} + diff --git a/SRC/FADE.H b/SRC/FADE.H new file mode 100644 index 0000000..16d2e1f --- /dev/null +++ b/SRC/FADE.H @@ -0,0 +1,7 @@ +#ifndef __TK___FADE__ +#define __TK___FADE__ +void Draw_Phase( int phase, char *image, char *pal ); +void fadein( char *image, char *pal ); +void fadeout( char *image, char *pal ); +void CalCuLaTE_Sine_Table_AND_Be_Happy(); +#endif diff --git a/SRC/FADE.OBJ b/SRC/FADE.OBJ new file mode 100644 index 0000000..c3ee182 Binary files /dev/null and b/SRC/FADE.OBJ differ diff --git a/SRC/FUNCS.BAK b/SRC/FUNCS.BAK new file mode 100644 index 0000000..e999c51 --- /dev/null +++ b/SRC/FUNCS.BAK @@ -0,0 +1,62 @@ +char *quitexts[] = +{ + "no: let's kill !", + "yes: i'm a loser" +}; + +int wanna_quit() +{ + int a, cnt = 0, selected = 0, quit = 0, oclock; + int done = 0; + int starty = 100 - ( ( 3*15 ) / 2 ); + load_efp( "efps\\cool.efp", picture, 0 ); + draw_box1( 65, starty - 5 - 10, 320 - 65, starty + 5 + ( 3*15 ), 10 ); + while( !done ) + { + memcpy( virbuff, picture, 64000 ); + FONT_NUM = 0; + writefonts2( 160 - ( str_length( "quit to menu" ) / 2 ), starty - 10, "quit to menu", 1 ); + for ( a = 0; a < 2; a ++ ) + { + if ( a == selected ) + { + FONT_NUM = 0; + writefonts2( 160 - ( str_length( quitexts[a] ) / 2 ), starty + 15 + ( a*15 ), quitexts[a], 1 ); + } + else + { + FONT_NUM = 2; + writefonts2( 160 - ( str_length( quitexts[a] ) / 2 ), starty + 15 + ( a*15 ), quitexts[a], 1 ); + } + } + memcpy( screen, virbuff, 64000 ); + while ( !k.state[94]&&!k.state[99]&&!k.state[28] ) + { + if ( clock() != oclock ) + { + oclock = clock(); + draw_ball( 65, starty + 15 + ( selected*15 ) - 2, cnt ); + draw_ball( 320 - 85, starty + 15 + ( selected*15 ) - 2, cnt ); + cnt ++; + if ( cnt > 23 ) cnt = 0; + } + } + MIDASplaySample( klikwav, MIDAS_CHANNEL_AUTO, 0, 22500, EFFECT_VOLUME, MIDAS_PAN_MIDDLE ); + if ( k.state[94] ) + { + selected --;if ( selected < 0 ) selected = 1; k.state[94] = 0; + } + if ( k.state[99] ) + { + selected ++;if ( selected > 1 ) selected = 0; k.state[99] = 0; + } + if ( k.state[28] ) + { + if ( selected == 0 ) quit = 0; + if ( selected == 1 ) quit = 1; + done = 1; + } + } + return( quit ); +} + diff --git a/SRC/FUNCS.H b/SRC/FUNCS.H new file mode 100644 index 0000000..3cc7568 --- /dev/null +++ b/SRC/FUNCS.H @@ -0,0 +1,62 @@ +char *quitexts[] = +{ + "no: let's kill !", + "yes: i'm a loser" +}; + +int wanna_quit() +{ + int a, cnt = 0, selected = 0, quit = 0, oclock; + int done = 0; + int starty = 100 - ( ( 3*15 ) / 2 ); + load_efp( "efps\\cool.efp", picture, 0 ); + draw_box1( 65, starty - 5 - 10, 320 - 65, starty + 5 + ( 3*15 ), 10 ); + while( !done ) + { + memcpy( virbuff, picture, 64000 ); + FONT_NUM = 0; + writefonts2( 160 - ( str_length( "quit to menu" ) / 2 ), starty - 10, "quit to menu", 1 ); + for ( a = 0; a < 2; a ++ ) + { + if ( a == selected ) + { + FONT_NUM = 0; + writefonts2( 160 - ( str_length( quitexts[a] ) / 2 ), starty + 15 + ( a*15 ), quitexts[a], 1 ); + } + else + { + FONT_NUM = 2; + writefonts2( 160 - ( str_length( quitexts[a] ) / 2 ), starty + 15 + ( a*15 ), quitexts[a], 1 ); + } + } + memcpy( screen, virbuff, 64000 ); + while ( !k.state[94]&&!k.state[99]&&!k.state[28] ) + { + if ( clock() != oclock ) + { + oclock = clock(); + draw_ball( 65, starty + 15 + ( selected*15 ) - 2, cnt ); + draw_ball( 320 - 85, starty + 15 + ( selected*15 ) - 2, cnt ); + cnt ++; + if ( cnt > 23 ) cnt = 0; + } + } + MIDASplaySample( samplep[KLIKWAV], MIDAS_CHANNEL_AUTO, 0, 22500, EFFECT_VOLUME, MIDAS_PAN_MIDDLE ); + if ( k.state[94] ) + { + selected --;if ( selected < 0 ) selected = 1; k.state[94] = 0; + } + if ( k.state[99] ) + { + selected ++;if ( selected > 1 ) selected = 0; k.state[99] = 0; + } + if ( k.state[28] ) + { + if ( selected == 0 ) quit = 0; + if ( selected == 1 ) quit = 1; + done = 1; + } + } + return( quit ); +} + diff --git a/SRC/GAME.BAK b/SRC/GAME.BAK new file mode 100644 index 0000000..24702f0 --- /dev/null +++ b/SRC/GAME.BAK @@ -0,0 +1,2616 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "defines.h" +#include "error/error.h" +#include "efp/efp.h" +#include "globvar.h" + +/*************************NET STUFF **************************************/ +#include "int/int.h" +#include "ipx/ipx.h" + +#include "ipxdefs.h" + +int ipxofs[MAX_PLAYERS]; +char ipxstream[MAX_PLAYERS][MAXDATASIZE]; +struct nodeaddr serveraddr; +char servername[10]; +struct packet far *send, far *rec[RECEIVERS]; +unsigned short sendl, sendseg, recl[RECEIVERS], recseg[RECEIVERS]; + +void sendipx( int dest, int type, ... ); // predefine +/************************* NET STUFF **************************************/ +VBEINFO *vbeInfo; +VBESURFACE *vbe; +#include "miscfunc.h" +#include "write.h"// tosi paskoja rutiineja !!! +#include "classes.h" +#include "rout.h" +#include "fade.h" +#include "draw.h" +#include "funcs.h" +#include "shop.h" +#include "newfuncs.h" +#include "options.h" +#include "i_funcs.h" // paska funkkareita + +void menu_biisi() +{ + if ( ph ) MIDASstopModule( ph ); + ph = MIDASplayModule( biisi[0], TRUE ); + MIDASsetMusicVolume( ph, MUSIC_VOLUME ); +} + +void peli_biisi() +{ + static int biisi_count=0; + + if ( ph ) MIDASstopModule( ph ); + if (biisi[biisi_count+1]==NULL) error("peli_biisi():biisi[biisi_count+1]==NULL!!!\nbiisi_count: %d\n",biisi_count); + ph = MIDASplayModule( biisi[biisi_count+1], TRUE ); + MIDASsetMusicVolume( ph, MUSIC_VOLUME ); + biisi_count++; + biisi_count%= 5; +} + +void MIDAS_CALL prevr( void ) +{ + framecount++; +} + +void make_floors() +{ + int a, lum; + char col; + for ( a = 0; a < 64000; a++ ) + { + lum = ( int ) ( ( float ) ( pal[floorspr[a]*3]*0.2 ) + ( float ) ( pal[floorspr[a]*3 + 1]*0.5 ) + ( float ) ( pal[floorspr[a]*3 + 2]*0.3 ) ) >> 2; + col = ( char ) ( ( 208 + 15 ) - lum ); + floorspr2[a] = col; + } +} + +void load_tables() +{ + FILE *tab; + tab = fopen( "palette.tab", "rb" ); + fread( trans_table, sizeof( trans_table ), 1, tab ); + fread( shadow_table, sizeof( shadow_table ), 1, tab ); + fread( &normal_l, sizeof( normal_l ), 1, tab ); + fread( &red_l, sizeof( red_l ), 1, tab ); + fread( &yellow_l, sizeof( yellow_l ), 1, tab ); + fread( &explo_l, sizeof( explo_l ), 1, tab ); + fclose( tab ); +} + +void allocipxmem() +{ + int a; + send = ( struct packet far * ) MK_FP( getlowmem( sizeof( struct packet ) / 16 + 1 ), 0 ); + if ( send == NULL ) + { + cout << "Can't alloc lowmem!\n" << endl; + ipxavail = 0; + return; + } + sendl = lsel; + sendseg = lseg; + for ( a = 0; a < RECEIVERS; a ++ ) + { + rec[a] = ( struct packet far * ) MK_FP( getlowmem( sizeof( struct packet ) / 16 + 1 ), 0 ); + if ( rec[a] == NULL ) + { + cout << "Can't alloc lowmem!\n"<< endl; + ipxavail = 0; + return; + } + recl[a] = lsel; + recseg[a] = lseg; + } +} + +void freeipxmem() +{ + int a; + if (ipxavail) + { + freelowmem( sendl ); + for ( a = 0; a < RECEIVERS; a ++ ) + { + freelowmem( recl[a] ); + recseg[a] = lseg; + } + } +} + +void do_all() +{ + int a; + char text[30]; + vesa_set_mode( 0x3 ); + cout << "\n ================== Starting TK =================\n\n"; + if( ( vbeInfo = vbeDetect() ) == NULL ) + printf( "VESA not supported\n" ); + else + { + printf( "VESA found..." ); + printf( "\nVBE Version : %d.%d\n" + "Oem : %s\n" + "Total memory : %gK\n", + vbeInfo-> VbeVersion >> 8, + vbeInfo-> VbeVersion&0xFF, + vbeInfo-> OemStringPtr, + ( ( float ) vbeInfo-> TotalMemory*64000.0f ) / 1024.0f ); + if ( vbeInfo-> VbeVersion >> 8 >= 2 ) VESA2 = 1; + } + if ( initipx() ) + { + char str[256]; + cout << "IPX protocol detected!\n"; + getlocaladdress(); + printf( "IPX address: %s\n", decode_localaddress( str, localadd ) ); + ipxavail = 1; + allocipxmem(); + } + else cout << "IPX _NOT_ detected!\n"; + if ( MIDASstartup() ) + { + if ( MIDASloadConfig( "sound.cfg" ) ) + { + cout << "Sound configuration loaded\n"; + if ( MIDASinit() ) + { + cout << "MIDAS initialized\n"; + if ( MIDASsetTimerCallbacks( target_frames*1000, FALSE, &prevr, NULL, NULL ) ) cout << "Timer synchronized\n"; + } + else error( "Midas initialization failed\n" ); + } + else error( "Sound configuration not found! run SETUP.exe\n" ); + if (!MIDASopenChannels( 20 )) error( "Error opening sound channels\n" ); + if (!MIDASallocAutoEffectChannels( 4 )) error( "Error allocating effect channels\n" ); + cout << "Loading sounds";fflush(stdout); + samplep[MAGNUMWAV] = MIDASloadWaveSample( "wavs\\magnum.wav", FALSE );putch('.'); + samplep[PISTOLWAV] = MIDASloadWaveSample( "wavs\\pistol.wav", FALSE );putch('.'); + samplep[SHOTGUNWAV] = MIDASloadWaveSample( "wavs\\rifle.wav", FALSE );putch('.'); + samplep[EXPLOWAV] = MIDASloadWaveSample( "wavs\\explo.wav", FALSE );putch('.'); + samplep[DEATHWAV] = MIDASloadWaveSample( "wavs\\death.wav", FALSE );putch('.'); + samplep[KLIKWAV] = MIDASloadWaveSample( "wavs\\klik.wav", FALSE );putch('.'); + samplep[HITWAV] = MIDASloadWaveSample( "wavs\\hit.wav", FALSE );putch('.'); + samplep[SINKOWAV] = MIDASloadWaveSample( "wavs\\sinko.wav", FALSE );putch('.'); + samplep[WOOSHWAV] = MIDASloadWaveSample( "wavs\\woosh.wav", FALSE );putch('.'); + samplep[FLAMEWAV] = MIDASloadWaveSample( "wavs\\flame.wav", FALSE );putch('.'); + cout << "\nLoading musics";fflush(stdout); + biisi[0] = MIDASloadModule("music\\menu.s3m");putch('.'); + biisi[1] = MIDASloadModule("music\\back.s3m");putch('.'); + biisi[2] = MIDASloadModule("music\\mielip2.s3m");putch('.'); + biisi[3] = MIDASloadModule("music\\mielip2.s3m");putch('.'); + biisi[4] = MIDASloadModule("music\\back.s3m");putch('.'); + biisi[5] = MIDASloadModule("music\\back.s3m");putch('.'); +// biisi[2] = MIDASloadModule("music\\back.s3m");putch('.'); +// biisi[3] = MIDASloadModule("music\\unic_3x.s3m");putch('.'); +// biisi[4] = MIDASloadModule("music\\mielip2.s3m");putch('.'); +// biisi[5] = MIDASloadModule("music\\unic_2x.s3m");putch('.'); +// biisi[1] = MIDASloadModule("music\\unic_1x.s3m");putch('.'); + for (a=0;a<6;a++) + if (biisi[a]==NULL) error("Musicmodule #%d NULL!\n",a); + cout << endl; + } + else error( "Error in MIDAS startup !!!\n" ); + set_keyb_rate(); + k.init( 0 ); + cout << "Keyboard handler initialized\n"; + cout << "Loading fonts"; + FONT_NUM = 0; loadfonts( "fnts\\bloody.fnt" ); putch('.'); + FONT_NUM = 1; loadfonts( "fnts\\8x8b.fnt" ); putch('.'); + FONT_NUM = 2; loadfonts( "fnts\\bloody2.fnt" ); putch('.'); + FONT_NUM = 3; loadfonts( "fnts\\snumbers.fnt" ); putch('.'); + cout << "\nLoading bitmaps"; + load_efp( "efps\\floor1.efp", floorspr, 0 ); putch('.'); + load_efp( "efps\\walls1.efp", wallspr, 0 ); putch('.'); + load_efp( "efps\\enemy0.efp", enemyspr0, 0 ); putch('.'); + load_efp( "efps\\enemy1.efp", enemyspr1, 0 ); putch('.'); + load_efp( "efps\\enemy2.efp", enemyspr2, 0 ); putch('.'); + load_efp( "efps\\enemy3.efp", enemyspr3, 0 ); putch('.'); + load_efp( "efps\\enemy4.efp", enemyspr4, 0 ); putch('.'); + load_efp( "efps\\enemy5.efp", enemyspr5, 0 ); putch('.'); + load_efp( "efps\\enemy6.efp", enemyspr6, 0 ); putch('.'); + load_efp( "efps\\enemy7.efp", enemyspr7, 0 ); putch('.'); + load_efp( "efps\\rambo2.efp", rambospr, 0 ); putch('.'); + load_efp( "efps\\bodyp.efp", bodypartspr, 0 ); putch('.'); + load_efp( "efps\\effects.efp", effectspr, 0 ); putch('.'); + load_efp( "efps\\ware.efp", warespr, 0 ); putch('.'); + load_efp( "efps\\target.efp", targetspr, 0 ); putch('.'); + load_efp( "efps\\c4.efp", c4spr, 0 ); putch('.'); + load_efp( "efps\\mine.efp", minespr, 0 ); putch('.'); + load_efp( "efps\\bomb.efp", grenadespr, 0 ); putch('.'); + load_efp( "efps\\shadows.efp", shadowspr, 0 ); putch('.'); + load_efp( "efps\\crates.efp", cratespr, 0 ); putch('.'); + pre_count(); + CalCuLaTE_Sine_Table_AND_Be_Happy();// for fade + cout << "\nSine and Cosine tables ready\n"; + for ( a = 0; a < LIGHTS; a ++ ) + light[a].make( Light_sizes[a] );cout << "Lights mapped\n"; + load_tables();cout << "Palette tables loaded \n"; + load_efp_pal( "efps\\walls1.efp", pal ); + cout << "Calculating dark floor... "; + make_floors(); + cout << "OK \n"; + load_options();cout << "Options loaded\n"; + list_files( &dirs, dirlist, "levs\\*.*", _A_SUBDIR ); + cout << dirs << " episodes found\n"; + list_files( &files_in_episode[0], filelist[0], "levs\\*.lev", _A_NORMAL ); + for ( a = 0; a < dirs &&a < 256; a ++ ) + { + strcpy( text, "levs\\" ); + strcat( text, dirlist[a].name ); + strcat( text, "\\*.lev" ); + list_files( &files_in_episode[a + 1], filelist[a + 1], text, _A_NORMAL ); + } + define_bullet_types(); + define_effects(); +} + +void free_all() +{ + MIDASclose(); + free( filelist ); + free( dirlist ); + freeipxmem(); + k.deinit(); +} + +int check_place( int x, int y, int size ) +{ + int a, ret = 0; + if ( level[( y / 20 ) *level_x_size + ( x / 20 ) ].type!= FLOOR ) ret = 1; + if ( level[( ( y + size ) / 20 ) *level_x_size + ( x / 20 ) ].type!= FLOOR ) ret = 1; + if ( level[( y / 20 ) *level_x_size + ( ( x + size ) / 20 ) ].type!= FLOOR ) ret = 1; + if ( level[( ( y + size ) / 20 ) *level_x_size + ( ( x + size ) / 20 ) ].type!= FLOOR ) ret = 1; + for ( a = 0; a < ACTIVE_PLAYERS; a ++ ) + if ( get_dist( x, y, aplayer[a]->x, aplayer[a]->y ) < 50 ) ret = 1; + return( ret ); +} + +void place_enemies() + +{ + int a, done, nx, ny, b, c; + for ( a = 0; a < ENEMIES; a ++ ) + { + done = 0; + while ( done == 0 ) + { + nx = ( rand() % ( level_x_size - 2 ) ) + 1; + ny = ( rand() % ( level_y_size - 2 ) ) + 1; + if ( level[ny*level_x_size + nx].type == FLOOR ) + { + done = 1; + if ( a > 0 ) + for ( b = 0; b < a; b ++ ) + if ( nx == enemy[b].x &&ny == enemy[b].y ) done = 0; + for ( c = 0; c < ACTIVE_PLAYERS &&done == 1; c ++ ) + if ( get_dist( nx, ny, pl_start_x[c], pl_start_y[c] ) < 8 ) done = 0; + } + } + enemy[a].x = nx; + enemy[a].y = ny; + } + for ( a = 0; a < ENEMIES; a ++ ) + { + enemy[a].x = ( ( enemy[a].x*20 ) - 5 ); + enemy[a].y = ( ( enemy[a].y*20 ) - 5 ); + enemy[a].angle = rand() % 360; + } +} + +void place_normal_game_crates() +{ + int a, b, x = 0, y = 0, crat = 0, bullets, weapons; + if ( leveldata.version == 1 ) + { + weapons = DIFF_WEAPONS - 2; bullets = DIFF_BULLETS - 2; + } + if ( leveldata.version == 2 ) + { + weapons = DIFF_WEAPONS - 1; bullets = DIFF_BULLETS - 1; + } + if ( leveldata.version == 3 || leveldata.version >= 4) + { + weapons = DIFF_WEAPONS; bullets = DIFF_BULLETS; + } + for ( a = 0; a < weapons; a ++ ) + for ( b = 0; b < normal_game_level_info.weapon_crates[a]; b ++ , crat ++ ) + if ( crat < MAX_CRATES ) + { + x = 0; y = 0; + crate[crat].type = 0; + crate[crat].weapon = a; + while ( check_place( x, y, 14 ) ) if ( check_place( x, y, 14 ) ) + { + x = rand() % ( level_x_size*20 ); y = rand() % ( level_y_size*20 ); + } + crate[crat].x = x; + crate[crat].y = y; + crate[crat].IN_USE = 1; + } + for ( a = 0; a < bullets; a ++ ) + for ( b = 0; b < normal_game_level_info.bullet_crates[a]; b ++ , crat ++ ) + if ( crat < MAX_CRATES ) + { + x = 0; y = 0; + crate[crat].type = 1; + crate[crat].bullet = a; + while ( check_place( x, y, 14 ) ) if ( check_place( x, y, 14 ) ) + { + x = rand() % ( level_x_size*20 ); y = rand() % ( level_y_size*20 ); + } + crate[crat].x = x; + crate[crat].y = y; + crate[crat].IN_USE = 1; + } + for ( b = 0; b < normal_game_level_info.energy_crates; b ++ , crat ++ ) + if ( crat < MAX_CRATES ) + { + x = 0; y = 0; + crate[crat].type = 2; + crate[crat].energy = 1; + while ( check_place( x, y, 14 ) ) if ( check_place( x, y, 14 ) ) + { + x = rand() % ( level_x_size*20 ); y = rand() % ( level_y_size*20 ); + } + crate[crat].x = x; + crate[crat].y = y; + crate[crat].IN_USE = 1; + } + if (leveldata.version>=5) + for (a=0;a= 4) + { + weapons = DIFF_WEAPONS; bullets = DIFF_BULLETS; + } + for ( a = 0; a < weapons; a ++ ) + for ( b = 0; b < death_match_level_info.weapon_crates[a]; b ++ , crat ++ ) + if ( crat < MAX_CRATES ) + { + x = 0; y = 0; + crate[crat].type = 0; + crate[crat].weapon = a; + while ( check_place( x, y, 14 ) ) if ( check_place( x, y, 14 ) ) + { + x = rand() % ( level_x_size*20 ); y = rand() % ( level_y_size*20 ); + } + crate[crat].x = x; + crate[crat].y = y; + crate[crat].IN_USE = 1; + } + for ( a = 0; a < bullets; a ++ ) + for ( b = 0; b < death_match_level_info.bullet_crates[a]; b ++ , crat ++ ) + if ( crat < MAX_CRATES ) + { + x = 0; y = 0; + crate[crat].type = 1; + crate[crat].bullet = a; + while ( check_place( x, y, 14 ) ) if ( check_place( x, y, 14 ) ) + { + x = rand() % ( level_x_size*20 ); y = rand() % ( level_y_size*20 ); + } + crate[crat].x = x; + crate[crat].y = y; + crate[crat].IN_USE = 1; + } + for ( b = 0; b < death_match_level_info.energy_crates; b ++ , crat ++ ) + if ( crat < MAX_CRATES ) + { + x = 0; y = 0; + crate[crat].type = 2; + crate[crat].energy = 1; + while ( check_place( x, y, 14 ) ) if ( check_place( x, y, 14 ) ) + { + x = rand() % ( level_x_size*20 ); y = rand() % ( level_y_size*20 ); + } + crate[crat].x = x; + crate[crat].y = y; + crate[crat].IN_USE = 1; + } + + if (leveldata.version>=5) + for (a=0;a MAX_ENEMIES) ENEMIES = MAX_ENEMIES; +} + +void null_effects() +{ + int a; + for ( a = 0; a < MAX_EFFECTS; a ++ ) + effect[a].IN_USE = 0; +} + +void null_crates() +{ + int a; + for ( a = 0; a < MAX_CRATES; a ++ ) + { + crate[a].text_count = 0; + crate[a].weapon = 0; + crate[a].bullet = 0; + crate[a].wake_up_count = 0; + crate[a].IN_USE = 0; + } +} + +void null_body_parts() +{ + int a; + for ( a = 0; a < MAX_BODY_PARTS; a ++ ) + body_part[a].IN_USE = 0; +} + +void null_bullets() +{ + int a; + for ( a = 0; a < MAX_BULLETS; a ++ ) + bullet[a].IN_USE = 0; +} + +void animate_players() +{ + int a; + for ( a = 0; a < ACTIVE_PLAYERS; a ++ ) + aplayer[a]->animate(); +} + +int player_amount() +{ + int a,b=0; + for (a=0;aDEAD ) + aplayer[a]->chk_keys( a ); + if ( k.state[57] ) + { + if ( !MAP_ON ) MAP_ON = 1;else MAP_ON = 0;k.state[57] = 0; + } + if ( k.state[33] ) + { + if ( FRAMES_ON == 0 ) FRAMES_ON = 1;else FRAMES_ON = 0;k.state[33] = 0; + } + if ( k.state[88] ) + { + screen_capture(); k.state[88] = 0; + } +} + +void chk_wake_ups() +{ + int a; + for ( a = 0; a < MAX_CRATES; a ++ ) + if ( crate[a].IN_USE == 0 ) + crate[a].chk_wake_up(a); +} + +void move_crate_texts() +{ + int a; + for ( a = 0; a < MAX_CRATES; a ++ ) + if ( crate[a].IN_USE ) + crate[a].move_text(); +} + +void move_body_parts() +{ + int a; + for ( a = 0; a < MAX_BODY_PARTS; a ++ ) + if ( body_part[a].IN_USE ) + if ( body_part[a].speed > 0 ) + { + body_part[a].move(); + body_part[a].speed -= 0.2; + } +} + +void roll_enemies() +{ + int a; + for ( a = 0; a < ENEMIES; a ++ ) + if ( !enemy[a].DEAD ) + { + if ( enemy[a].tangle == enemy[a].angle ) + if ( enemy[a].walk_cnt == 0 ) + { + if ( enemy[a].see_somebody == 0 ) + if ( rand() % 50 == 1 ) + enemy[a].tangle = rand() % 360; + } + enemy[a].rotate(); + } +} + +void move_enemies() +{ + int a, b, see; + for ( a = 0; a < ENEMIES; a ++ ) + { + if ( !enemy[a].DEAD ) + { + see = 0; + for ( b = 0; b < MAX_PLAYERS &&see == 0; b ++ ) + if ( player[b].enabled) + if ( enemy[a].SEE_PL[b] ) see = 1; + if ( see == 0 ) + if ( enemy[a].walk_cnt == 0 ) + if ( rand() % 100 == 1 ) enemy[a].walk_cnt = ( rand() % 40 ) + 20; + if ( enemy[a].walk_cnt > 0 ) + { + enemy[a].move( enemy[a].rangle*9, 0 ); enemy[a].walk_cnt --;if ( enemy[a].WALK == 0 ) enemy[a].WALK = 1; + } + else enemy[a].WALK = 0; + } + if ( enemy[a].PUSH_POWER > 0 ) + { + if ( ( int ) enemy[a].PUSH_POWER > 0 ) + enemy[a].move( enemy[a].PUSH_ANGLE, ( int ) enemy[a].PUSH_POWER ); + enemy[a].PUSH_POWER -= 0.2; + } + } +} + +void push_players() +{ + int a; + for ( a = 0; a < ACTIVE_PLAYERS; a ++ ) + if ( aplayer[a]->PUSH_POWER > 0 ) + { + if ( ( int ) aplayer[a]->PUSH_POWER > 0 ) + aplayer[a]->move( aplayer[a]->PUSH_ANGLE, ( int ) aplayer[a]->PUSH_POWER, a ); + aplayer[a]->PUSH_POWER -= 0.2; + } +} + +void roll_effects() +{ + int a; + for ( a = 0; a < MAX_EFFECTS; a ++ ) + effect[a].roll(); +} + +void move_bullets() +{ + int a; + for ( a = 0; a < MAX_BULLETS; a ++ ) + if ( bullet[a].IN_USE == 1 ) + bullet[a].move(); +} + +void get_angles() +{ + int a; + for ( a = 0; a < ENEMIES; a ++ ) + if ( !enemy[a].DEAD ) + enemy[a].get_angles(); +} + +void try_see_players() +{ + int a; + for ( a = 0; a < ENEMIES; a ++ ) + if ( !enemy[a].DEAD ) + enemy[a].try_see_players(); +} + +void enemies_load() +{ + int a; + for ( a = 0; a < ENEMIES; a ++ ) + if ( !enemy[a].DEAD ) + enemy[a].load(); +} + +void chk_for_shoot() +{ + int a; + for ( a = 0; a < ENEMIES; a ++ ) + if ( !enemy[a].DEAD ) + enemy[a].chk_for_shoot(); +} + +void complete() +{ + int a; + next_level ++ ; + a = ( next_level*5 ) % 360; + writefonts( 160 + ( ( 160 - ( ( float ) next_level / ( ( float ) C_DELAY / 160 ) ) ) *sini[a] ) - 45, ( scr_y_size / 2 ) + ( 100 - ( ( float ) next_level / ( ( float ) C_DELAY / 100 ) ) ) *cosi[a], "MISSION COMPLETED", 3*16 ); +} + +void kello() +{ + char col = 1; + if ( !next_level ) + complete_time = ( clock() - st ) / CLOCKS_PER_SEC; + if ( complete_time > general_level_info.time_limit*TIME_ADD ) col = 3*16; + writefonts( 151, 10, c_2_c( complete_time ), col ); +} + +void frames_per_sec() +{ + char text[5]; + itoa( ( int ) F_PER_SEC, text, 10 ); + writefonts( 151, 20, text, 9*16 ); + itoa( OVER_POWER , text, 10 ); + writefonts( 151, 30, text, 7*16 ); +} + +void dec_hits() +{ + int a; + for ( a = 0; a < ACTIVE_PLAYERS; a ++ ) + if ( aplayer[a]->HIT > 0 ) aplayer[a]->HIT --; +} + +void are_all_dead() +{ + int a; + if ( KILLING_MODE!= DEATHMATCH ) + { + all_dead = 1; + for ( a = 0; a < ACTIVE_PLAYERS; a ++ ) + if ( aplayer[a]->enabled) + if ( aplayer[a]->DEAD <= 14 ) all_dead = 0; + } + if ( all_dead ) + complete_time = ( general_level_info.time_limit*TIME_ADD ) + 100; +} + +void seeing() +{ + int a; + for ( a = 0; a < ACTIVE_PLAYERS; a ++ ) + { + memset( aplayer[a]->see_level, 0, level_x_size*level_y_size ); + aplayer[a]->see(); + } +} + +void fire_lights() +{ + int a, xoffs, yoffs; + if ( GAME_MODE!= SPLIT_SCREEN ) + for ( a = 0; a < MAX_PLAYERS; a ++ ) + if (player[a].enabled) + { + if ( weapon[player[a].curr_weapon].gun == 1 ) + if ( player[a].FIRE ) + { + xoffs = ( sini[player[a].rangle2]*10 ) + ( sini[( int ) ( ( player[a].rangle2 ) + 270 ) % 360]*6 ); + yoffs = ( cosi[player[a].rangle2]*10 ) + ( cosi[( int ) ( ( player[a].rangle2 ) + 270 ) % 360]*6 ); + draw_light( &normal_l, player[a].x + 14 + xoffs - aplayer[0]->scr_x, player[a].y + 13 + yoffs - aplayer[0]->scr_y, 3, 2 - player[a].FIRE, 0 ); + } + } + if ( GAME_MODE == SPLIT_SCREEN ) + { + for ( a = 0; a < ACTIVE_PLAYERS; a ++ ) + { + if ( weapon[player[a].curr_weapon].gun == 1 ) + if ( player[a].FIRE ) + { + xoffs = ( sini[player[a].rangle2]*10 ) + ( sini[( int ) ( ( player[a].rangle2 ) + 270 ) % 360]*6 ); + yoffs = ( cosi[player[a].rangle2]*10 ) + ( cosi[( int ) ( ( player[a].rangle2 ) + 270 ) % 360]*6 ); + draw_light( &normal_l, player[a].x + 14 + xoffs - aplayer[0]->scr_x, player[a].y + 13 + yoffs - aplayer[0]->scr_y, 3, 2 - player[a].FIRE, 1 ); + draw_light( &normal_l, ( player[a].x + 14 + xoffs - aplayer[1]->scr_x ) + 160, player[a].y + 13 + yoffs - aplayer[1]->scr_y, 3, 2 - player[a].FIRE, 2 ); + } + } + } + if ( GAME_MODE!= SPLIT_SCREEN ) + for ( a = 0; a < ENEMIES; a ++ ) + if ( !enemy[a].DEAD ) + if ( enemy[a].FIRE ) + { + xoffs = ( sini[( int ) ( enemy[a].rangle*9 ) ]*10 ) + ( sini[( int ) ( ( enemy[a].rangle*9 ) + 270 ) % 360]*3 ); + yoffs = ( cosi[( int ) ( enemy[a].rangle*9 ) ]*10 ) + ( cosi[( int ) ( ( enemy[a].rangle*9 ) + 270 ) % 360]*3 ); + draw_light( &normal_l, enemy[a].x + 14 + xoffs - aplayer[0]->scr_x, enemy[a].y + 13 + yoffs - aplayer[0]->scr_y, 3, 2 - enemy[a].FIRE, 0 ); + } + if ( GAME_MODE == SPLIT_SCREEN ) + for ( a = 0; a < ENEMIES; a ++ ) + if ( !enemy[a].DEAD ) + if ( enemy[a].FIRE ) + { + xoffs = ( sini[( int ) ( enemy[a].rangle*9 ) ]*10 ) + ( sini[( int ) ( ( enemy[a].rangle*9 ) + 270 ) % 360]*3 ); + yoffs = ( cosi[( int ) ( enemy[a].rangle*9 ) ]*10 ) + ( cosi[( int ) ( ( enemy[a].rangle*9 ) + 270 ) % 360]*3 ); + draw_light( &normal_l, enemy[a].x + 14 + xoffs - player[0].scr_x, enemy[a].y + 13 + yoffs - player[0].scr_y, 3, 2 - enemy[a].FIRE, 1 ); + draw_light( &normal_l, ( enemy[a].x + 14 + xoffs - player[1].scr_x ) + 160, enemy[a].y + 13 + yoffs - player[1].scr_y, 3, 2 - enemy[a].FIRE, 2 ); + } +} + +void chk_burn() +{ + int a,b; + + for ( a = 0; a < MAX_PLAYERS; a ++ ) + if ( player[a].enabled ) + if ( !player[a].DEAD ) + if ( player[a].burning ) + { + if (a==aplayer[0]->tindex || (GAME_MODE==SPLIT_SCREEN && a==aplayer[1]->tindex)) + { + player[a].burning --; + player[a].get_damage( 0.4, player[a].Frying_player ); + } + + if (aplayer[0]->tindex==a && GAME_MODE==NETWORK) + { + if (NETWORK_MODE==CLIENT) + sendipx(0,IPX_BURNING,player[a].tindex,player[a].burning); + else + for(b=1;b aplayer[0]->scr_x - 160 ) + if ( steam[a].x < aplayer[0]->scr_x + 480 ) + if ( steam[a].y > aplayer[0]->scr_y - yl1 ) + if ( steam[a].y < aplayer[0]->scr_y + yl2 ) + du = 1; + if ( GAME_MODE == SPLIT_SCREEN ) + if ( steam[a].x > aplayer[1]->scr_x - 160 ) + if ( steam[a].x < aplayer[1]->scr_x + 480 ) + if ( steam[a].y > aplayer[1]->scr_y - yl1 ) + if ( steam[a].y < aplayer[1]->scr_y + yl2 ) + du = 1; + if ( du ) + { + if ( steam[a].speed < s_r_a ) b = steam_rates[steam[a].speed]; + else b = 1; + if ( Steam_count % b == 0 ) + new_effect( 0, STEAM, steam[a].x, steam[a].y, steam[a].angle, steam[a].speed ); + } + } +} + +void game_shit() +{ + int a; + chkeys(); + push_players(); + chk_burn(); + move_bullets(); + move_body_parts(); + move_crate_texts(); + if ( KILLING_MODE == DEATHMATCH ) + if ( (GAME_MODE != NETWORK) || (NETWORK_MODE==SERVER)) chk_wake_ups(); + for ( a = 0; a < ACTIVE_PLAYERS; a ++ ) + aplayer[a]->move_scr(); + if ( DARK_MODE ) seeing(); + if (ENEMIES_ON_GAME || GAME_MODE==ONE_PLAYER) + if ( (GAME_MODE!= NETWORK)||(NETWORK_MODE == SERVER )) + { + roll_enemies(); + get_angles(); + try_see_players(); + move_enemies(); + chk_for_shoot(); + enemies_load(); + animate_enemies(); + } + draw_floor(); + for ( a = 0; a < ACTIVE_PLAYERS; a++ ) aplayer[a]->load(); + animate_players(); + draw_players( 0 );// DEad players + draw_effects( 0 ); + draw_body_parts(); + if ( SHADOWS ) draw_gae_shadows(); + draw_crates(); + draw_bullets(); + if ( LIGHT_EFFECTS ) fire_lights(); + draw_live_enemies(); + draw_players( 1 );// Live players + if ( SMOKE_EFFECTS ) do_steam(); + draw_walls(); + if ( SHADOWS ) draw_shadows(); + draw_effects( 1 ); + if ( LIGHT_EFFECTS ) draw_spots(); + draw_targets(); + if ( DARK_MODE ) draw_black(); + dec_hits(); + draw_hits(); + if ( MAP_ON ) map(); + draw_crate_texts(); + if ( FRAMES_ON ) frames_per_sec(); + if ( KILLING_MODE == DEATHMATCH ) draw_kills(); + draw_infos(); + draw_energies(); + message_board.draw(); + if ( next_level ) complete(); + if ( KILLING_MODE!= DEATHMATCH ) + kello(); + if ( first == 1 ) + { + if (! (GAME_MODE==NETWORK && NETWORK_MODE==CLIENT)) + fadein( virbuff, pal ); else setpal(pal,256); + first = 0; + } + memcpy( screen, virbuff, 320*scr_y_size ); + roll_effects(); + are_all_dead(); +} + +void do_prices() +{ + int a; + for ( a = 0; a < DIFF_WEAPONS; a ++ ) + sell_price[a] = ( 0.8*weapon[a + 1].cost ) - ( rand() % ( weapon[a + 1].cost / 2 ) ); + sell_price[DIFF_WEAPONS] = ( 0.8*shield_data.cost ) - ( rand() % ( shield_data.cost / 2 ) ); + sell_price[DIFF_WEAPONS + 1] = ( 0.8*target_cost ) - ( rand() % ( target_cost / 2 ) ); +} + +void victory() +{ + int a = 0, oclock; + load_efp( "efps\\sunset.efp", picture, 0 ); + load_efp_pal( "efps\\sunset.efp", pal ); + setpal( pal, 0 ); + memcpy( screen, picture, 64000 ); + oclock = clock(); + while ( a < 255 ) + if ( oclock!= clock() ) + { + oclock = clock(); + a += 10; + setpal( pal, a ); + } + k.state[1] = 0; + while ( !k.state[1] ); + while ( a > 0 ) + if ( oclock!= clock() ) + { + oclock = clock(); + a -= 10; + setpal( pal, a ); + } +} + +void flushipx() +{ + int a,b; + char jee[100]; + for ( a = 0; a < MAX_PLAYERS; a++ ) + if (player[a].enabled) + { + sprintf(jee,"streami[%d][%d]",a,ipxofs[a]); +// message_board.add_message(jee); + if (ipxofs[a]!=0) + { + ipxstream[a][ ipxofs[a]++ ] = IPX_END; + for (b=0;bdata[b]=ipxstream[a][b]; + while (send->ecb.inuse); + sendpacket( sendseg, player[a].ipxnode, send, (word)(ipxofs[a]+1) ); + // RESET + ipxofs[a] = 0; + } + } +// message_board.add_message("flushed..."); +} + +void docheckflush() +{ + int a,b; + char jee[100]; + + for ( a = 0; a < MAX_PLAYERS; a++ ) + if (player[a].enabled) + { + sprintf(jee,"streami[%d][%d]",a,ipxofs[a]); +// message_board.add_message(jee); + if (ipxofs[a]>(MAXDATASIZE-100)) + { + ipxstream[a][ ipxofs[a]++ ] = IPX_END; + for (b=0;bdata[b]=ipxstream[a][b]; + while (send->ecb.inuse); + sendpacket( sendseg, player[a].ipxnode, send, (word)(ipxofs[a]+1) ); + // RESET + ipxofs[a] = 0; + } + } +// message_board.add_message("flushed2..."); +} + + +void sendipxnow( struct nodeaddr *node, int type, ... ) +{ + int a = 0; +// TEMP VARIABLES + int b,c,d; + char *str; + char *p; + +// TEMP VARIABLES END + auto va_list ap; + va_start( ap, type ); + + if (send->ecb.inuse) + while (send->ecb.inuse); + switch( type ) + { + case IPX_GAMEDATA: send->data[a++] = ( char ) type; + b = va_arg( ap, int); + // for (c=0;c<6;c++) + // player[b].ipxnode.node[c]=node->node[c]; + send->data[a++] = ( char ) player_amount()+1; + send->data[a++] = ( char ) b; + send->data[a++] = ( char ) DEATH_MATCH_SPEED; + for (d=0;ddata[a++] = ( char ) d; + str = (char *) &player[d].x; + for (c=0;cdata[a++]=*(str++); + str = (char *) &player[d].y; + for (c=0;cdata[a++]=*(str++); + str = (char *) &player[d].rangle; + for (c=0;cdata[a++]=*(str++); + send->data[a++]=(char) player[d].color; + str = (char *) &player[d].burning; + for (c=0;cdata[a++]=*(str++); + str = (char *) &player[d].ipxnode; + for (c=0;cdata[a++]=*(str++); + for (c=0;c<10;c++) send->data[a++]=player[d].name[c]; + str = (char *) &player[d].ANIM; + for (c=0;cdata[a++]=*(str++); + str = (char *) &player[d].player_kills; + for (c=0;cdata[a++]=*(str++); + str = (char *) &player[d].DEAD; + for (c=0;cdata[a++]=*(str++); + } + message_board.add_message("Gamedata sent"); + break; +/* case IPX_NEWPLAYERDATA: + break;*/ + case IPX_IMJOININGNOW:send->data[a++] = ( char ) type; + str = va_arg( ap, char *); + for (b=0;b<10;b++) + send->data[a++]=*(str++); + break; + case IPX_SERVERSEARCH:send->data[a++] = ( char ) type; + break; + case IPX_SERVERANSWER:send->data[a++] = ( char ) type; + str = va_arg( ap, char * ); + for ( b = 0; b < 10; b++ ) + send->data[a++ ] = str[b]; + break; + case IPX_SERVERSHUTDOWN:send->data[a++] = ( char ) type; + break; + case IPX_JOINREQUEST:send->data[a++] = ( char ) type; + break; + case IPX_SENDLEVELINFO:send->data[a++] = ( char ) type; + break; + case IPX_SENDLEVEL:send->data[a++] = ( char ) type; + b = va_arg( ap, int); + send->data[a++] = (char)(b & 255); + send->data[a++] = (char)(b >> 8 ); + break; + case IPX_TRANSMITLEVEL: + send->data[a++] = ( char ) type; + b = va_arg( ap, int); + send->data[a++] = (char)(b & 255); + send->data[a++] = (char)(b >> 8 ); + str=(char*)level; + for (c=b*(MAXDATASIZE-24);(c<(b+1)*(MAXDATASIZE-24))&&(c<(12*level_x_size*level_y_size));c++) + send->data[a++] = str[c]; + + break; + case IPX_JOINACCEPT:send->data[a++] = ( char ) type; + b = va_arg(ap, int); + send->data[a++] = (char) b; + if (b) message_board.add_message("Accepting player..."); + else message_board.add_message("Player NOT accepted..."); + + break; + case IPX_LEVELINFO: send->data[a++]=(char)type; + send->data[a++]=(char)(level_x_size&255); + send->data[a++]=(char)(level_x_size>>8); + send->data[a++]=(char)(level_y_size&255); + send->data[a++]=(char)(level_y_size>>8); + p=(char *)&general_level_info; + for (b=0;bdata[a++]=p[b]; + break; + default:error("sendipxnow: message %d not yet implemented\n", type ); + } + send->data[a++] = IPX_END; + sendpacket( sendseg, *node, send, (word)(a+1) ); + va_end( ap ); +} + +void sendipx( int dest, int type, ... ) +{ int c,b,a; + char *str; + char d; + + float x,y; +// char kakka[102]; + + va_list ap; + va_start( ap, type ); + + switch( type ) + { + case IPX_SOUND: + ipxstream[dest][ipxofs[dest]++] = (char)type; + d=va_arg(ap,char); + ipxstream[dest][ipxofs[dest] ++ ] = d; + d=va_arg(ap,char); + ipxstream[dest][ipxofs[dest] ++ ] = d; + b= va_arg(ap,int); + str = (char *) &b; + for (c=0;ctindex; + break; + + case IPX_MESSAGE: + ipxstream[dest][ipxofs[dest] ++ ] = (char)type; + str=va_arg(ap,char *); + for (c=0;cnode.node[a]; + } + initsendpacket(send,sendseg); + for (a=0;aecb.inuse) + cancelpacket(recseg[a]); + closesocket( (word) socketid ); +} + +void server_add_player(char *name,struct nodeaddr *n) +{ + int colors[]={3*16,9*16,10*16,5*16,1*16,2*16,4*16,6*16}; + int a,b; + + for (a=0;a ecb.inuse == 0 ) + { + data = - 1; + ofs = 0; + while( data!= IPX_END ) + { + data = rec[a]->data[ofs++]; + switch ( data ) + { + case IPX_ALIVE: + pcom[pcoms++]=data; + pl=rec[a]->data[ofs++]; + player[pl].enabled=1; + player[pl].time_since_last_alive=0; + break; + + case IPX_MESSAGE: + pcom[pcoms++]=data; + for(c=0;cdata[ofs++]; + message_board.add_message(buf); + break; + + case IPX_BURNING: + pcom[pcoms++]=data; + pl=rec[a]->data[ofs++]; + player[pl].burning=rec[a]->data[ofs++]; + for (c=1;cdata[ofs++]; //tindex + param1=rec[a]->data[ofs++]; + str = (char *) ¶m2; + for (c=0;cdata[ofs++]; + str = (char *) ¶m3; + for (c=0;cdata[ofs++]; + str = (char *) ¶m4; + for (c=0;cdata[ofs++]; + MIDASplaySample( param1, MIDAS_CHANNEL_AUTO, 0, param2, get_volume(aplayer[0]->x,aplayer[0]->y,param3,param4),get_pan(aplayer[0]->x,param3)); + for (c=1;cdata[ofs++]; //tindex + for (b=0;bdata[ofs++]; + bullet[b].type=&bullet_type[d]; + str = (char *) &bullet[b].x; + for (c=0;cdata[ofs++]; + str = (char *) &bullet[b].y; + for (c=0;cdata[ofs++]; + str = (char *) &bullet[b].angle; + for (c=0;cdata[ofs++]; + str = (char *) &bullet[b].time; + for (c=0;cdata[ofs++]; + + for (c=1;cdata[ofs++]; + str = (char *) &pl; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].type; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].weapon; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].bullet; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].energy; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].x; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].y; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].IN_USE; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].text_count; + for (c=0;cdata[ofs++]; + crate[pl].text_angle=0; + if (crate[pl].text_count!=0) + { + crate[pl].IN_USE=0; + crate[pl].wake_up_count=1; + } + for (c=1;cdata[ofs++]; + + for (c=0;cdata[ofs++]; + str = (char *)&x; + for (c=0;cdata[ofs++]; + str = (char *)&y; + for (c=0;cdata[ofs++]; + player[pl].x=x; + player[pl].y=y; + for (c=1;cdata[ofs++]; //tindex + b=rec[a]->data[ofs++]; + + str = (char *) &player[b].player_kills; + for (c=0;cdata[ofs++]; + for (c=1;cdata[ofs++]; + str = (char *)&player[pl].rangle; + for (c=0;cdata[ofs++]; + for (c=1;cdata[ofs++]; + str = (char *)&player[pl].ANIM; + for (c=0;cdata[ofs++]; + for (c=1;cipx.src.node.node[b]; + for(b=0;b<10;b++) + buf[b]=rec[a]->data[ofs++]; + server_add_player(buf,&n); + break; + + case IPX_SERVERSEARCH: + pcom[pcoms++]=data; + for (b=0;b<6;b++) + n.node[b]=rec[a]->ipx.src.node.node[b]; + sendipxnow(&n, IPX_SERVERANSWER,servername); + break; + + case IPX_TEXTMESSAGE: + pcom[pcoms++]=data; + ofs+=IPXMSGLEN[IPX_TEXTMESSAGE]-1; + break; + + case IPX_END: + pcom[pcoms++]=data; + break; + + case IPX_JOINREQUEST: + pcom[pcoms++]=data; + for (b=0;b<6;b++) + n.node[b]=rec[a]->ipx.src.node.node[b]; + if (player_amount()ipx.src.node.node[b]; + sendipxnow(&n, IPX_LEVELINFO); + break; + + case IPX_SENDLEVEL: + pcom[pcoms++]=data; + for (b=0;b<6;b++) + n.node[b]=rec[a]->ipx.src.node.node[b]; + b=rec[a]->data[ofs++]; + b+=rec[a]->data[ofs++]<<8; + sendipxnow(&n, IPX_TRANSMITLEVEL, (int) b); + break; + + default: + sprintf(buf,"do_server_shit: receiver %d\nunknown server command %d at offset %d\n", a, data,ofs ); + sprintf(buf2,"Previous commands:\n"); + strcat(buf,buf2); + for (b=0;b ecb.inuse == 0 ) + { + data = - 1; + ofs = 0; + while( data!= IPX_END ) + { + data = rec[a]->data[ofs++]; + switch ( data ) + { + case IPX_SOUND: + pcom[pcoms++]=data; + pl=rec[a]->data[ofs++]; //tindex + param1=rec[a]->data[ofs++]; + str = (char *) ¶m2; + for (c=0;cdata[ofs++]; + str = (char *) ¶m3; + for (c=0;cdata[ofs++]; + str = (char *) ¶m4; + for (c=0;cdata[ofs++]; + MIDASplaySample( param1, MIDAS_CHANNEL_AUTO, 0, param2, get_volume(aplayer[0]->x,aplayer[0]->y,param3,param4),get_pan(aplayer[0]->x,param3)); + break; + + case IPX_NEWBULLET: + pcom[pcoms++]=data; + pl=rec[a]->data[ofs++]; //tindex + for (b=0;bdata[ofs++]; + bullet[b].type=&bullet_type[d]; + str = (char *) &bullet[b].x; + for (c=0;cdata[ofs++]; + str = (char *) &bullet[b].y; + for (c=0;cdata[ofs++]; + str = (char *) &bullet[b].angle; + for (c=0;cdata[ofs++]; + str = (char *) &bullet[b].time; + for (c=0;cdata[ofs++]; + break; + + case IPX_SERVERSHUTDOWN: + quit=1; + break; + + case IPX_MESSAGE: + pcom[pcoms++]=data; + for(c=0;cdata[ofs++]; + message_board.add_message(buf); + break; + + + case IPX_BURNING: + pcom[pcoms++]=data; + pl=rec[a]->data[ofs++]; + player[pl].burning=rec[a]->data[ofs++]; + break; + + case IPX_UPDKILLS: + pcom[pcoms++]=data; + pl=rec[a]->data[ofs++]; //tindex + b=rec[a]->data[ofs++]; + + str = (char *) &player[b].player_kills; + for (c=0;cdata[ofs++]; + break; + + case IPX_UPDCRATE: + pcom[pcoms++]=data; + + b=rec[a]->data[ofs++]; + str = (char *) &pl; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].type; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].weapon; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].bullet; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].energy; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].x; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].y; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].IN_USE; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].text_count; + for (c=0;cdata[ofs++]; + crate[pl].text_angle=0; + if (crate[pl].text_count!=0) crate[pl].IN_USE=0; else + new_effect( &normal_l, TELEPORT, crate[pl].x + 8, crate[pl].y + 8, 0, 0 ); + break; + + case IPX_PLYXY: + pcom[pcoms++]=data; + pl=rec[a]->data[ofs++]; + str = (char *)&x; + for (c=0;cdata[ofs++]; + str = (char *)&y; + for (c=0;cdata[ofs++]; + player[pl].x=x; + player[pl].y=y; + break; + + case IPX_PLYRANGLE: + pcom[pcoms++]=data; + pl=rec[a]->data[ofs++]; + str = (char *)&player[pl].rangle; + for (c=0;cdata[ofs++]; + break; + + case IPX_PLYANIM: + pcom[pcoms++]=data; + pl=rec[a]->data[ofs++]; + str = (char *)&player[pl].ANIM; + for (c=0;cdata[ofs++]; + break; + + case IPX_END: + pcom[pcoms++]=data; + break; + + default: + sprintf(buf,"do_client_shit: receiver %d\nunknown client command %d at offset %d\n", a, data,ofs ); + sprintf(buf2,"Previous commands:\n"); + strcat(buf,buf2); + for (b=0;becb.inuse==0) + { + data = - 1; + ofs = 0; + while( data!= IPX_END ) + { + data = rec[a]->data[ofs++]; + switch ( data ) + { + case IPX_GAMEDATA: + plyers=rec[a]->data[ofs++]; + aplayer[0]=&(player[rec[a]->data[ofs++]]); + aplayer[0]->speed=rec[a]->data[ofs++]; + for (c=0;cdata[ofs++]; + if (player[pno].enabled) error("realjoin: IPX_GAMEDATA mismatch detected!\n(player[%d].enabled==1)",pno); + str=(char *)&player[pno].x; + for (b=0;bdata[ofs++]; + str=(char *)&player[pno].y; + for (b=0;bdata[ofs++]; + str=(char *)&player[pno].rangle; + for (b=0;bdata[ofs++]; + player[pno].color=rec[a]->data[ofs++]; + str=(char *)&player[pno].burning; + for (b=0;bdata[ofs++]; + str=(char *)&player[pno].ipxnode; + for (b=0;bdata[ofs++]; + for (b=0;b<10;b++) player[pno].name[b]=rec[a]->data[ofs++]; + str=(char *)&player[pno].ANIM; + for (b=0;bdata[ofs++]; + str=(char *)&player[pno].player_kills; + for (b=0;bdata[ofs++]; + str=(char *)&player[pno].DEAD; + for (b=0;bdata[ofs++]; + player[pno].enabled=1; + } + if (!aplayer[0]->enabled) message_board.add_message("realjoin: something missing..."); + received=1; + if (rec[a]->data[ofs+1]!=IPX_END) error("realjoin: IPX packet mismatching!"); + + break; + default:ofs+=IPXMSGLEN[data]-1; + }; + } + listenforpacket( recseg[a] ); + } + if ((framecount-s)>target_frames) timeout=1; + } + } + return 1; +} + +int getlevel() +{ + int received,timeout; + int blocks,bno,c; + int s,b,a,data,ofs; + char *p; + + blocks=(12*level_x_size*level_y_size)/(MAXDATASIZE-24); + if ((12*level_x_size*level_y_size)%(MAXDATASIZE-24)) blocks++; + level=(struct BLOCK*)malloc(12*level_x_size*level_y_size); + + for (b=0;becb.inuse==0) + { + data = - 1; + ofs = 0; + while( data!= IPX_END ) + { + data = rec[a]->data[ofs++]; + switch ( data ) + { + case IPX_TRANSMITLEVEL: + bno = rec[a]->data[ofs++]; + bno+= rec[a]->data[ofs++]<<8; + if (bno!=b) return 0; + p = (char*)level; + for (c=b*(MAXDATASIZE-24);(c<(b+1)*(MAXDATASIZE-24))&&(c<(12*level_x_size*level_y_size));c++) + p[c]=rec[a]->data[ofs++]; + received=1; + break; + default:ofs+=IPXMSGLEN[data]-1; + }; + } + listenforpacket( recseg[a] ); + } + if ((framecount-s)>target_frames) timeout=1; + } + } + } + return 1; +} + +int getlevelinfo() +{ int received,timeout; + int s,b,a,data,ofs; + char *p; + + received=0; + while(!received) + { + sendipxnow(&serveraddr,IPX_SENDLEVELINFO); + timeout=0; + + s=framecount; + + while((!received)&&(!timeout)) + { + if (k.state[1]) return 0; + for ( a = 0; a < RECEIVERS; a ++ ) + if (rec[a]->ecb.inuse==0) + { + data = - 1; + ofs = 0; + while( data!= IPX_END ) + { + data = rec[a]->data[ofs++]; + switch ( data ) + { + case IPX_LEVELINFO: + level_x_size =rec[a]->data[ofs++]; + level_x_size+=rec[a]->data[ofs++]<<8; + level_y_size =rec[a]->data[ofs++]; + level_y_size+=rec[a]->data[ofs++]<<8; + p=(char *)&general_level_info; + for (b=0;bdata[ofs++]; + received=1; + break; + default:ofs+=IPXMSGLEN[data]-1; + }; + } + listenforpacket( recseg[a] ); + } + if ((framecount-s)>target_frames) timeout=1; + } + } + return 1; +} + +int join_game(struct nodeaddr n) +{ char buf[256]; + + memcpy(&serveraddr,&n,sizeof(serveraddr)); + load_efp( "efps\\cool.efp", picture, 0 ); + draw_box1( 60, 10, 320 - 60, 190, 15 ); + fadeout( virbuff, pal ); + memcpy(virbuff,picture,64000); + FONT_NUM = 0; + writefonts2( 160 - ( str_length( "joining game" ) >> 1 ), 20, "joining game", 1 ); + fadein(virbuff,pal); + FONT_NUM = 1; + writefonts( 80, 50, "receiving levelinfo...", M_BLUE ); + memcpy(screen,virbuff,64000); + if (!getlevelinfo()) return 0; + sprintf(buf," \"%s\" (%d x %d)...",general_level_info.comment,level_x_size,level_y_size); + writefonts( 80, 60,buf, M_BLUE ); + writefonts( 80, 70,"receiving level...", M_BLUE ); + memcpy(screen,virbuff,64000); + if (!getlevel()) return 0; + writefonts( 80, 80,"joining game...", M_BLUE ); + memcpy(screen,virbuff,64000); + if (!realjoin()) return 0; + sprintf(buf,"%d players",player_amount()); + writefonts( 80, 90,buf, M_BLUE ); + writefonts( 80, 100,"done!", M_BLUE ); + memcpy(screen,virbuff,64000); + k.clear_stack(); + k.getch(); + + return 1; +} + +int waitfor(int msg,int secs) +{ int timeout=0,s; + int a,data,ofs,yes=0; + + s=framecount; + + while ((!timeout)&&(yes!=0)) + { + for ( a = 0; a < RECEIVERS; a ++ ) + if (rec[a]->ecb.inuse==0) + { + data = - 1; + ofs = 0; + while( data!= IPX_END ) + { + data = rec[a]-> data[ofs ++ ]; + if (data==msg) + { + if (rec[a]-> data[ofs ++ ]) yes=1; + else yes=-1; + } else ofs+=IPXMSGLEN[data]-1; + } + listenforpacket( recseg[a] ); + } + if ((framecount-s)>target_frames*secs) timeout=1; + } + if ((yes<0)||(timeout)) return 0; + else return 1; +} + +int join_server(struct nodeaddr n) +{ + memcpy(&serveraddr,&n,sizeof(serveraddr)); + FONT_NUM = 1; + writefonts(80,190,"waiting...",M_BLUE); + memcpy(screen,virbuff,64000); + sendipxnow(&serveraddr,IPX_JOINREQUEST); + if (!waitfor(IPX_JOINACCEPT,3)) return 0; + return 1; +} + +int select_server() +{ + int a, b, c,data,ofs,first=1,done=0,cnt=0,oclock=0; + int select=0; + int chg=1; + int servers=0; + char servernames[10][10],tempname[10]; + struct nodeaddr nodez[10],tempnode; + struct nodeaddr bc; + + load_efp( "efps\\cool.efp", picture, 0 ); + draw_box1( 60, 10, 320 - 60, 190, 15 ); + fadeout( virbuff, pal ); + + k.state[1] = 0; + k.state[28] = 0; + bc=BROADCAST(); + + while ( !done ) + { + if (k.state[28] && servers>0) + { + if (join_server(nodez[select])) done=1; + else + { + chg=1; + servers--; + for (c=select;c0){ + if (k.state[94] && select>0) {select--;k.state[94]=0;} + if (k.state[99] && select> 1 ), 20, "select server", 1 ); + FONT_NUM = 1; + if (chg) + for (a=0;a 23 ) cnt = 0; + } + sendipxnow(&bc,IPX_SERVERSEARCH); + + for ( a = 0; a < RECEIVERS; a ++ ) + if (rec[a]->ecb.inuse==0) + { + data = - 1; + ofs = 0; + while( data!= IPX_END ) + { + data = rec[a]-> data[ofs ++ ]; + switch ( data ) + { + case IPX_SERVERANSWER: + for (b=0;b<6;b++) + tempnode.node[b]=rec[a]->ipx.src.node.node[b]; + for (b=0;b<10;b++) + tempname[b]=rec[a]->data[ofs++]; + if (servers<10) + { + for (b=0;(bipx.src.node.node[b]; + for (b=0;b data[ofs ++ ] ) != 0 ); + break; + + case IPX_END: + break; + default:ofs+=IPXMSGLEN[data]-1; + }; + } + listenforpacket( recseg[a] ); + } + if (k.state[1]) return 0; + } + + if (join_game(nodez[select])) return 1; + else return 0; +} + +void chk_for_loosers() +{ + int a,b; + char kakka[100]; + + for (a=1;a=40*3) + { + player[a].enabled=0; + sprintf(kakka,"%s (%d) left the game",player[a].name,player[a].tindex); + for (b=1;bipxnode.node[a]=localadd->node.node[a]; + } + + if ((GAME_MODE!=NETWORK)|| + (NETWORK_MODE==SERVER)) + { + strcpy( match_level, "levs\\" ); + if ( DEATH_MATCH_EPISODE > 0 ) + { + strcat( match_level, dirlist[DEATH_MATCH_EPISODE - 1].name ); + strcat( match_level, "\\" ); + } + strcat( match_level, DEATH_MATCH_LEVEL ); + LEVELS = files_in_episode[episode + 1]; + LEVEL = START_LEVEL; + if ( LEVEL > LEVELS - 1 ) LEVEL = LEVELS - 1; + } + + fadeout( virbuff, pal ); + set_keys(); + if ( GAME_MODE==NETWORK && NETWORK_MODE==CLIENT) + { + alusta_client(); + sendipx(0,IPX_ALIVE); + sendipx(0,IPX_SENDCRATES,(char)aplayer[0]->tindex); + } + else alusta_players1(); + quit = 0; + all_dead = 0; + BACK_TO_MENU = 0; + while ( !quit &&!BACK_TO_MENU ) + { + // // + if ((GAME_MODE!=NETWORK)|| + (NETWORK_MODE==SERVER)) + { + strcpy( filename, "levs\\" ); + strcat( filename, dirlist[episode].name ); + strcat( filename, "\\level" ); + itoa( LEVEL + 1, text, 10 ); + strcat( filename, text ); + strcat( filename, ".lev" ); + if ( KILLING_MODE!= DEATHMATCH ) leveldata.load( filename ); + else (leveldata.load( match_level)); + if ( KILLING_MODE!= DEATHMATCH ) + level_info(); + } + if ( !BACK_TO_MENU ) + { + if ( DARK_MODE ) + { + for ( a = 0; a < ACTIVE_PLAYERS; a ++ ) + aplayer[a]->see_level = (char *)malloc( level_x_size*level_y_size ); + } + if ( KILLING_MODE!= DEATHMATCH ) + { + do_prices(); + if ( LEVEL > 0 ) + for ( a = 0; a < ACTIVE_PLAYERS; a ++ ) aplayer[a]->shop(); + } + + if ( !FORCE_0x13 ) + if ( VESA2 ) + { + vbe = vbeOpen( 320, 240, 8 ); + if (vbe!=NULL){ + scr_y_size = 240; + screen = vbe-> lfb; + } else FORCE_0x13=1; + } + + peli_biisi(); + + load_efp_pal( "efps\\walls1.efp", pal ); + + + if ( !(GAME_MODE==NETWORK && NETWORK_MODE==CLIENT)) + alusta_players2(); + DEAD_ENEMIES = 0; + + + if ((GAME_MODE!=NETWORK)|| + (NETWORK_MODE==SERVER)) + { + if ( ENEMIES_ON_GAME == 0 && KILLING_MODE == DEATHMATCH ) ENEMIES = 0; + else { + alusta_enemies(); + place_enemies(); + } + } else ENEMIES=0; + + null_body_parts(); + null_effects(); + null_bullets(); + null_crates(); + if ((GAME_MODE!=NETWORK)|| + (NETWORK_MODE==SERVER)) + { + if ( KILLING_MODE == COOPERATIVE ) place_normal_game_crates(); + else place_death_match_crates(); + } + FONT_NUM = 1; + frame_count = 0; + oclock = clock(); + st = clock(); + first = 1; + OVER_POWER = 0; + Spot_count = 0; + Steam_count = 0; + next_level = 0; + + if ((GAME_MODE!=NETWORK)|| + (NETWORK_MODE==SERVER)) + if ( KILLING_MODE == DEATHMATCH ) + for ( a = 0; a < ACTIVE_PLAYERS; a++ ) aplayer[a]->random_place(); + + effect_age_count = 0; + message_board.clear(); + + while( !all_dead &&!quit &&next_level < C_DELAY ) + { + // GAME loop + c = clock(); + if ( ( ( float ) c / CLOCKS_PER_SEC ) - ( ( float ) oclock / CLOCKS_PER_SEC ) > 2 ) + { + F_PER_SEC = ( ( float ) frame_count / ( c - oclock ) ) *CLOCKS_PER_SEC; + oclock = c; + frame_count = 0; + } + if (FRAMES_ON) opcnt ++; // OVER_POWER count + + if ( framecount ) + { + if (FRAMES_ON){ + op[opcnt2] = opcnt; + opcnt2 ++; + if ( opcnt2 > 5 ) opcnt2 = 0; + opcnt = 0; + if ( opcnt2 == 0 ) + OVER_POWER = ( op[0] + op[1] + op[2] + op[3] + op[4] ) / 5; + } + framecount = 0;// incremented by MIDAS timer + game_shit();// do the game !!!! + if (GAME_MODE==NETWORK && NETWORK_MODE==SERVER) + chk_for_loosers(); + Steam_count ++; + Steam_count%= 360; + Spot_count += 2; + Spot_count%= 360; + frame_count ++; + } + if ( GAME_MODE == NETWORK) + { + if (NETWORK_MODE == CLIENT ) do_client_shit(); + if (NETWORK_MODE == SERVER ) do_server_shit(); + } + } // game loop end + + if ( DARK_MODE ) + for ( a = 0; a < ACTIVE_PLAYERS; a ++ ) + free( aplayer[a]->see_level ); + } + fadeout( virbuff, pal ); + menu_biisi(); + if ( !FORCE_0x13 ) + if ( VESA2 ) + { + scr_y_size = 200; + vbeClose( vbe ); + vesa_set_mode( 0x13 ); + screen = ( char * ) 0xA0000; + } + + if ( KILLING_MODE!= DEATHMATCH ) + { + all_dead = 0; + are_all_dead(); + if ( all_dead ) quit = 1; + else next_level = 1; + if ( LEVEL == 0 &&BACK_TO_MENU ) + { } + else statics(); + + if ( !all_dead && GAME_MODE == SPLIT_SCREEN ) two_to_one(); + + if ( LEVEL == LEVELS - 1 ) + if ( !BACK_TO_MENU ) + if ( next_level == 1 ) + if ( quit == 0 ) + { + quit = 1; next_level = 0; victory(); + } + if ( next_level ) LEVEL ++; + next_level = 0; + } + } + load_efp_pal( "efps\\ware.efp", pal ); +} + +void menu_scr() +{ + load_efp( "efps\\tk.efp", picture, 0 ); + load_efp_pal( "efps\\ware.efp", pal ); + draw_box1( 55, 90 - ( ( Menu_texts*15 ) / 2 ), 320 - 55, 110 + ( ( Menu_texts*15 ) / 2 ), 10 ); + k.state[28] = 0; + first = 1; +} + +void menu() +{ + int a, cnt = 0, selected = 0, quit = 0, oclock; + int starty = ( Menu_texts*15 ) / 2; + ph = 0; + menu_scr(); + menu_biisi(); + while( !quit ) + { + memcpy( virbuff, picture, 64000 ); + FONT_NUM = 1; + writefonts( 320 - str_length( Version ), 190, Version, M_BLUE ); + for ( a = 0; a < Menu_texts; a ++ ) + { + if ( a == selected ) + { + FONT_NUM = 0; + writefonts2( 160 - ( str_length( menu_text[a] ) / 2 ), 100 - starty + ( a*15 ), menu_text[a], 1 ); + } + else + { + FONT_NUM = 2; + writefonts2( 160 - ( str_length( menu_text[a] ) / 2 ), 100 - starty + ( a*15 ), menu_text[a], M_RED ); + } + } + if ( first == 1 ) + { + fadein( virbuff, pal ); first = 0; + } + memcpy( screen, virbuff, 64000 ); + while ( !k.state[94]&&!k.state[99]&&!k.state[28] ) + { + if ( clock() != oclock ) + { + oclock = clock(); + draw_ball( 55, 100 - starty + ( selected*15 ) - 2, cnt ); + draw_ball( 320 - 75, 100 - starty + ( selected*15 ) - 2, cnt ); + cnt ++; + if ( cnt > 23 ) cnt = 0; + } + }; + MIDASplaySample( samplep[KLIKWAV], MIDAS_CHANNEL_AUTO, 0, 22500, EFFECT_VOLUME, MIDAS_PAN_MIDDLE ); + if ( k.state[94] ) + { + selected --;if ( selected < 0 ) selected = Menu_texts - 1; k.state[94] = 0; + } + if ( k.state[99] ) + { + selected ++;if ( selected > Menu_texts - 1 ) selected = 0; k.state[99] = 0; + } + if ( k.state[28] ) + { + if ( selected == 0 ) + { + GAME_MODE = ONE_PLAYER; + KILLING_MODE = COOPERATIVE; + episode = choose_episode(); + game(); + menu_scr(); + } + if ( selected == 1 ) + { + multiplayer_options(); menu_scr(); + } + if ( selected == 2 ) + { + options(); menu_scr(); + } + if ( selected == 3 ) quit = 1; + } + } + fadeout( virbuff, pal ); +} + +void credits() +{ + cout << "\n"; + cout << " Thanks for playing --The Ultimate TK-- (Tapan Kaikki) ! \n"; + cout << "\n"; + cout << " Credits: \n"; + cout << "\n"; + cout << " Coding: Allu & Unski \n"; + cout << " Graphics: Allu \n"; + cout << " Music: Raipe, Allu & Unski \n"; + cout << " Sound effects: Allu (let's rip) \n"; + cout << " Episodes: Blanket & Allu \n"; + cout << " Thanks to - MIDAS sound system \n"; + cout << " - Vertigo for svga routines\n"; + cout << "\n"; + cout << " Also thanks to Janne Laitinen (game name), Niko Kotilainen & \n"; + cout << " all TK fans in the world ! \n"; + cout << "\n"; + cout << " Contact the Error Free Productions by e-mail: \n"; + cout << "\n"; + cout << " ef@tuusniemi.fi \n"; + cout << "\n"; + cout << " And visit the Error Free Productions homepage: \n"; + cout << "\n"; + cout << " http://www.tuusniemi.fi/~ef \n"; +} + +void logo() +{ + int a = 0, oclock; + load_efp( "efps\\eflogo.efp", picture, 0 ); + load_efp_pal( "efps\\eflogo.efp", pal ); + setpal( pal, 0 ); + memcpy( screen, picture, 64000 ); + oclock = clock(); + while ( a < 255 ) + if ( oclock!= clock() ) + { + oclock = clock(); + a += 10; + setpal( pal, a ); + } + while ( !k.kbhit() &&abs( oclock - clock() ) < 500 ) ; + while ( a > 0 ) + if ( oclock!= clock() ) + { + oclock = clock(); + a -= 10; + setpal( pal, a ); + } +} + +main( int argc, char *argv[] ) +{ + int a = 0, b; + int pause = 0; + for ( a = 1; a < argc; a ++ ) + { + strupr( argv[a] ); + if ( ( argv[a][0] == '-')||( argv[a][0] == '/')) + switch( argv[a][1] ) + { + case 'F':b = atoi( argv[ ++ a] ); + if ( b >= 30 &&b <= 500 ) target_frames = b; + break; + case 'L':b = atoi( argv[ ++ a] ); + if ( b > 0 ) START_LEVEL = b - 1; + break; + case 'P':pause = 1; + break; + case 'M':SHOW_ENEMIES = 1; + break; + case 'V':FORCE_0x13 = 1; + break; + case 'H':case '?': + cout << endl; + cout << "Ultimate Tapan Kaikki " << Version << endl; + cout << "Compiled at "<< __DATE__<< ' ' << __TIME__ << endl; + cout << "parameters:" << endl; + cout << "-?,-h this help"<< endl; + cout << "-v force mcga mode" << endl; + cout << "-p pause at startup" << endl; + cout << "-m show enemies on map" << endl; + cout << "-l ## start at level ##" << endl; + cout << "-f ## set gamespeed to ## fps (def. 40)" << endl; + cout << endl; + exit( 1 ); + break; + } + } + randomize(); + do_all(); + k.clear_stack(); + if ( pause ) k.getch(); + vesa_set_mode( 0x13 ); + // logo(); + menu(); + if ( ph ) MIDASstopModule( ph ); + vesa_set_mode( 0x3 ); + free_all(); +// credits(); +} + diff --git a/SRC/GAME.BAT b/SRC/GAME.BAT new file mode 100644 index 0000000..7dbc46b --- /dev/null +++ b/SRC/GAME.BAT @@ -0,0 +1,4 @@ +@echo off +cd .. +game %1 %2 %3 %4 %5 %6 %7 +cd src diff --git a/SRC/GAME.CPP b/SRC/GAME.CPP new file mode 100644 index 0000000..ede8cac --- /dev/null +++ b/SRC/GAME.CPP @@ -0,0 +1,2616 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "defines.h" +#include "error/error.h" +#include "efp/efp.h" +#include "globvar.h" + +/*************************NET STUFF **************************************/ +#include "int/int.h" +#include "ipx/ipx.h" + +#include "ipxdefs.h" + +int ipxofs[MAX_PLAYERS]; +char ipxstream[MAX_PLAYERS][MAXDATASIZE]; +struct nodeaddr serveraddr; +char servername[10]; +struct packet far *send, far *rec[RECEIVERS]; +unsigned short sendl, sendseg, recl[RECEIVERS], recseg[RECEIVERS]; + +void sendipx( int dest, int type, ... ); // predefine +/************************* NET STUFF **************************************/ +VBEINFO *vbeInfo; +VBESURFACE *vbe; +#include "miscfunc.h" +#include "write.h"// tosi paskoja rutiineja !!! +#include "classes.h" +#include "rout.h" +#include "fade.h" +#include "draw.h" +#include "funcs.h" +#include "shop.h" +#include "newfuncs.h" +#include "options.h" +#include "i_funcs.h" // paska funkkareita + +void menu_biisi() +{ + if ( ph ) MIDASstopModule( ph ); + ph = MIDASplayModule( biisi[0], TRUE ); + MIDASsetMusicVolume( ph, MUSIC_VOLUME ); +} + +void peli_biisi() +{ + static int biisi_count=0; + + if ( ph ) MIDASstopModule( ph ); + if (biisi[biisi_count+1]==NULL) error("peli_biisi():biisi[biisi_count+1]==NULL!!!\nbiisi_count: %d\n",biisi_count); + ph = MIDASplayModule( biisi[biisi_count+1], TRUE ); + MIDASsetMusicVolume( ph, MUSIC_VOLUME ); + biisi_count++; + biisi_count%= 5; +} + +void MIDAS_CALL prevr( void ) +{ + framecount++; +} + +void make_floors() +{ + int a, lum; + char col; + for ( a = 0; a < 64000; a++ ) + { + lum = ( int ) ( ( float ) ( pal[floorspr[a]*3]*0.2 ) + ( float ) ( pal[floorspr[a]*3 + 1]*0.5 ) + ( float ) ( pal[floorspr[a]*3 + 2]*0.3 ) ) >> 2; + col = ( char ) ( ( 208 + 15 ) - lum ); + floorspr2[a] = col; + } +} + +void load_tables() +{ + FILE *tab; + tab = fopen( "palette.tab", "rb" ); + fread( trans_table, sizeof( trans_table ), 1, tab ); + fread( shadow_table, sizeof( shadow_table ), 1, tab ); + fread( &normal_l, sizeof( normal_l ), 1, tab ); + fread( &red_l, sizeof( red_l ), 1, tab ); + fread( &yellow_l, sizeof( yellow_l ), 1, tab ); + fread( &explo_l, sizeof( explo_l ), 1, tab ); + fclose( tab ); +} + +void allocipxmem() +{ + int a; + send = ( struct packet far * ) MK_FP( getlowmem( sizeof( struct packet ) / 16 + 1 ), 0 ); + if ( send == NULL ) + { + cout << "Can't alloc lowmem!\n" << endl; + ipxavail = 0; + return; + } + sendl = lsel; + sendseg = lseg; + for ( a = 0; a < RECEIVERS; a ++ ) + { + rec[a] = ( struct packet far * ) MK_FP( getlowmem( sizeof( struct packet ) / 16 + 1 ), 0 ); + if ( rec[a] == NULL ) + { + cout << "Can't alloc lowmem!\n"<< endl; + ipxavail = 0; + return; + } + recl[a] = lsel; + recseg[a] = lseg; + } +} + +void freeipxmem() +{ + int a; + if (ipxavail) + { + freelowmem( sendl ); + for ( a = 0; a < RECEIVERS; a ++ ) + { + freelowmem( recl[a] ); + recseg[a] = lseg; + } + } +} + +void do_all() +{ + int a; + char text[30]; + vesa_set_mode( 0x3 ); + cout << "\n ================== Starting TK =================\n\n"; + if( ( vbeInfo = vbeDetect() ) == NULL ) + printf( "VESA not supported\n" ); + else + { + printf( "VESA found..." ); + printf( "\nVBE Version : %d.%d\n" + "Oem : %s\n" + "Total memory : %gK\n", + vbeInfo-> VbeVersion >> 8, + vbeInfo-> VbeVersion&0xFF, + vbeInfo-> OemStringPtr, + ( ( float ) vbeInfo-> TotalMemory*64000.0f ) / 1024.0f ); + if ( vbeInfo-> VbeVersion >> 8 >= 2 ) VESA2 = 1; + } + if ( initipx() ) + { + char str[256]; + cout << "IPX protocol detected!\n"; + getlocaladdress(); + printf( "IPX address: %s\n", decode_localaddress( str, localadd ) ); + ipxavail = 1; + allocipxmem(); + } + else cout << "IPX _NOT_ detected!\n"; + if ( MIDASstartup() ) + { + if ( MIDASloadConfig( "sound.cfg" ) ) + { + cout << "Sound configuration loaded\n"; + if ( MIDASinit() ) + { + cout << "MIDAS initialized\n"; + if ( MIDASsetTimerCallbacks( target_frames*1000, FALSE, &prevr, NULL, NULL ) ) cout << "Timer synchronized\n"; + } + else error( "Midas initialization failed\n" ); + } + else error( "Sound configuration not found! run SETUP.exe\n" ); + if (!MIDASopenChannels( 20 )) error( "Error opening sound channels\n" ); + if (!MIDASallocAutoEffectChannels( 4 )) error( "Error allocating effect channels\n" ); + cout << "Loading sounds";fflush(stdout); + samplep[MAGNUMWAV] = MIDASloadWaveSample( "wavs\\magnum.wav", FALSE );putch('.'); + samplep[PISTOLWAV] = MIDASloadWaveSample( "wavs\\pistol.wav", FALSE );putch('.'); + samplep[SHOTGUNWAV] = MIDASloadWaveSample( "wavs\\rifle.wav", FALSE );putch('.'); + samplep[EXPLOWAV] = MIDASloadWaveSample( "wavs\\explo.wav", FALSE );putch('.'); + samplep[DEATHWAV] = MIDASloadWaveSample( "wavs\\death.wav", FALSE );putch('.'); + samplep[KLIKWAV] = MIDASloadWaveSample( "wavs\\klik.wav", FALSE );putch('.'); + samplep[HITWAV] = MIDASloadWaveSample( "wavs\\hit.wav", FALSE );putch('.'); + samplep[SINKOWAV] = MIDASloadWaveSample( "wavs\\sinko.wav", FALSE );putch('.'); + samplep[WOOSHWAV] = MIDASloadWaveSample( "wavs\\woosh.wav", FALSE );putch('.'); + samplep[FLAMEWAV] = MIDASloadWaveSample( "wavs\\flame.wav", FALSE );putch('.'); + cout << "\nLoading musics";fflush(stdout); + biisi[0] = MIDASloadModule("music\\menu.s3m");putch('.'); + biisi[1] = MIDASloadModule("music\\back.s3m");putch('.'); + biisi[2] = MIDASloadModule("music\\mielip2.s3m");putch('.'); + biisi[3] = MIDASloadModule("music\\mielip2.s3m");putch('.'); + biisi[4] = MIDASloadModule("music\\back.s3m");putch('.'); + biisi[5] = MIDASloadModule("music\\back.s3m");putch('.'); +// biisi[2] = MIDASloadModule("music\\back.s3m");putch('.'); +// biisi[3] = MIDASloadModule("music\\unic_3x.s3m");putch('.'); +// biisi[4] = MIDASloadModule("music\\mielip2.s3m");putch('.'); +// biisi[5] = MIDASloadModule("music\\unic_2x.s3m");putch('.'); +// biisi[1] = MIDASloadModule("music\\unic_1x.s3m");putch('.'); + for (a=0;a<6;a++) + if (biisi[a]==NULL) error("Musicmodule #%d NULL!\n",a); + cout << endl; + } + else error( "Error in MIDAS startup !!!\n" ); + set_keyb_rate(); + k.init( 0 ); + cout << "Keyboard handler initialized\n"; + cout << "Loading fonts"; + FONT_NUM = 0; loadfonts( "fnts\\bloody.fnt" ); putch('.'); + FONT_NUM = 1; loadfonts( "fnts\\8x8b.fnt" ); putch('.'); + FONT_NUM = 2; loadfonts( "fnts\\bloody2.fnt" ); putch('.'); + FONT_NUM = 3; loadfonts( "fnts\\snumbers.fnt" ); putch('.'); + cout << "\nLoading bitmaps"; + load_efp( "efps\\floor1.efp", floorspr, 0 ); putch('.'); + load_efp( "efps\\walls1.efp", wallspr, 0 ); putch('.'); + load_efp( "efps\\enemy0.efp", enemyspr0, 0 ); putch('.'); + load_efp( "efps\\enemy1.efp", enemyspr1, 0 ); putch('.'); + load_efp( "efps\\enemy2.efp", enemyspr2, 0 ); putch('.'); + load_efp( "efps\\enemy3.efp", enemyspr3, 0 ); putch('.'); + load_efp( "efps\\enemy4.efp", enemyspr4, 0 ); putch('.'); + load_efp( "efps\\enemy5.efp", enemyspr5, 0 ); putch('.'); + load_efp( "efps\\enemy6.efp", enemyspr6, 0 ); putch('.'); + load_efp( "efps\\enemy7.efp", enemyspr7, 0 ); putch('.'); + load_efp( "efps\\rambo2.efp", rambospr, 0 ); putch('.'); + load_efp( "efps\\bodyp.efp", bodypartspr, 0 ); putch('.'); + load_efp( "efps\\effects.efp", effectspr, 0 ); putch('.'); + load_efp( "efps\\ware.efp", warespr, 0 ); putch('.'); + load_efp( "efps\\target.efp", targetspr, 0 ); putch('.'); + load_efp( "efps\\c4.efp", c4spr, 0 ); putch('.'); + load_efp( "efps\\mine.efp", minespr, 0 ); putch('.'); + load_efp( "efps\\bomb.efp", grenadespr, 0 ); putch('.'); + load_efp( "efps\\shadows.efp", shadowspr, 0 ); putch('.'); + load_efp( "efps\\crates.efp", cratespr, 0 ); putch('.'); + pre_count(); + CalCuLaTE_Sine_Table_AND_Be_Happy();// for fade + cout << "\nSine and Cosine tables ready\n"; + for ( a = 0; a < LIGHTS; a ++ ) + light[a].make( Light_sizes[a] );cout << "Lights mapped\n"; + load_tables();cout << "Palette tables loaded \n"; + load_efp_pal( "efps\\walls1.efp", pal ); + cout << "Calculating dark floor... "; + make_floors(); + cout << "OK \n"; + load_options();cout << "Options loaded\n"; + list_files( &dirs, dirlist, "levs\\*.*", _A_SUBDIR ); + cout << dirs << " episodes found\n"; + list_files( &files_in_episode[0], filelist[0], "levs\\*.lev", _A_NORMAL ); + for ( a = 0; a < dirs &&a < 256; a ++ ) + { + strcpy( text, "levs\\" ); + strcat( text, dirlist[a].name ); + strcat( text, "\\*.lev" ); + list_files( &files_in_episode[a + 1], filelist[a + 1], text, _A_NORMAL ); + } + define_bullet_types(); + define_effects(); +} + +void free_all() +{ + MIDASclose(); + free( filelist ); + free( dirlist ); + freeipxmem(); + k.deinit(); +} + +int check_place( int x, int y, int size ) +{ + int a, ret = 0; + if ( level[( y / 20 ) *level_x_size + ( x / 20 ) ].type!= FLOOR ) ret = 1; + if ( level[( ( y + size ) / 20 ) *level_x_size + ( x / 20 ) ].type!= FLOOR ) ret = 1; + if ( level[( y / 20 ) *level_x_size + ( ( x + size ) / 20 ) ].type!= FLOOR ) ret = 1; + if ( level[( ( y + size ) / 20 ) *level_x_size + ( ( x + size ) / 20 ) ].type!= FLOOR ) ret = 1; + for ( a = 0; a < ACTIVE_PLAYERS; a ++ ) + if ( get_dist( x, y, aplayer[a]->x, aplayer[a]->y ) < 50 ) ret = 1; + return( ret ); +} + +void place_enemies() + +{ + int a, done, nx, ny, b, c; + for ( a = 0; a < ENEMIES; a ++ ) + { + done = 0; + while ( done == 0 ) + { + nx = ( rand() % ( level_x_size - 2 ) ) + 1; + ny = ( rand() % ( level_y_size - 2 ) ) + 1; + if ( level[ny*level_x_size + nx].type == FLOOR ) + { + done = 1; + if ( a > 0 ) + for ( b = 0; b < a; b ++ ) + if ( nx == enemy[b].x &&ny == enemy[b].y ) done = 0; + for ( c = 0; c < ACTIVE_PLAYERS &&done == 1; c ++ ) + if ( get_dist( nx, ny, pl_start_x[c], pl_start_y[c] ) < 8 ) done = 0; + } + } + enemy[a].x = nx; + enemy[a].y = ny; + } + for ( a = 0; a < ENEMIES; a ++ ) + { + enemy[a].x = ( ( enemy[a].x*20 ) - 5 ); + enemy[a].y = ( ( enemy[a].y*20 ) - 5 ); + enemy[a].angle = rand() % 360; + } +} + +void place_normal_game_crates() +{ + int a, b, x = 0, y = 0, crat = 0, bullets, weapons; + if ( leveldata.version == 1 ) + { + weapons = DIFF_WEAPONS - 2; bullets = DIFF_BULLETS - 2; + } + if ( leveldata.version == 2 ) + { + weapons = DIFF_WEAPONS - 1; bullets = DIFF_BULLETS - 1; + } + if ( leveldata.version == 3 || leveldata.version >= 4) + { + weapons = DIFF_WEAPONS; bullets = DIFF_BULLETS; + } + for ( a = 0; a < weapons; a ++ ) + for ( b = 0; b < normal_game_level_info.weapon_crates[a]; b ++ , crat ++ ) + if ( crat < MAX_CRATES ) + { + x = 0; y = 0; + crate[crat].type = 0; + crate[crat].weapon = a; + while ( check_place( x, y, 14 ) ) if ( check_place( x, y, 14 ) ) + { + x = rand() % ( level_x_size*20 ); y = rand() % ( level_y_size*20 ); + } + crate[crat].x = x; + crate[crat].y = y; + crate[crat].IN_USE = 1; + } + for ( a = 0; a < bullets; a ++ ) + for ( b = 0; b < normal_game_level_info.bullet_crates[a]; b ++ , crat ++ ) + if ( crat < MAX_CRATES ) + { + x = 0; y = 0; + crate[crat].type = 1; + crate[crat].bullet = a; + while ( check_place( x, y, 14 ) ) if ( check_place( x, y, 14 ) ) + { + x = rand() % ( level_x_size*20 ); y = rand() % ( level_y_size*20 ); + } + crate[crat].x = x; + crate[crat].y = y; + crate[crat].IN_USE = 1; + } + for ( b = 0; b < normal_game_level_info.energy_crates; b ++ , crat ++ ) + if ( crat < MAX_CRATES ) + { + x = 0; y = 0; + crate[crat].type = 2; + crate[crat].energy = 1; + while ( check_place( x, y, 14 ) ) if ( check_place( x, y, 14 ) ) + { + x = rand() % ( level_x_size*20 ); y = rand() % ( level_y_size*20 ); + } + crate[crat].x = x; + crate[crat].y = y; + crate[crat].IN_USE = 1; + } + if (leveldata.version>=5) + for (a=0;a= 4) + { + weapons = DIFF_WEAPONS; bullets = DIFF_BULLETS; + } + for ( a = 0; a < weapons; a ++ ) + for ( b = 0; b < death_match_level_info.weapon_crates[a]; b ++ , crat ++ ) + if ( crat < MAX_CRATES ) + { + x = 0; y = 0; + crate[crat].type = 0; + crate[crat].weapon = a; + while ( check_place( x, y, 14 ) ) if ( check_place( x, y, 14 ) ) + { + x = rand() % ( level_x_size*20 ); y = rand() % ( level_y_size*20 ); + } + crate[crat].x = x; + crate[crat].y = y; + crate[crat].IN_USE = 1; + } + for ( a = 0; a < bullets; a ++ ) + for ( b = 0; b < death_match_level_info.bullet_crates[a]; b ++ , crat ++ ) + if ( crat < MAX_CRATES ) + { + x = 0; y = 0; + crate[crat].type = 1; + crate[crat].bullet = a; + while ( check_place( x, y, 14 ) ) if ( check_place( x, y, 14 ) ) + { + x = rand() % ( level_x_size*20 ); y = rand() % ( level_y_size*20 ); + } + crate[crat].x = x; + crate[crat].y = y; + crate[crat].IN_USE = 1; + } + for ( b = 0; b < death_match_level_info.energy_crates; b ++ , crat ++ ) + if ( crat < MAX_CRATES ) + { + x = 0; y = 0; + crate[crat].type = 2; + crate[crat].energy = 1; + while ( check_place( x, y, 14 ) ) if ( check_place( x, y, 14 ) ) + { + x = rand() % ( level_x_size*20 ); y = rand() % ( level_y_size*20 ); + } + crate[crat].x = x; + crate[crat].y = y; + crate[crat].IN_USE = 1; + } + + if (leveldata.version>=5) + for (a=0;a MAX_ENEMIES) ENEMIES = MAX_ENEMIES; +} + +void null_effects() +{ + int a; + for ( a = 0; a < MAX_EFFECTS; a ++ ) + effect[a].IN_USE = 0; +} + +void null_crates() +{ + int a; + for ( a = 0; a < MAX_CRATES; a ++ ) + { + crate[a].text_count = 0; + crate[a].weapon = 0; + crate[a].bullet = 0; + crate[a].wake_up_count = 0; + crate[a].IN_USE = 0; + } +} + +void null_body_parts() +{ + int a; + for ( a = 0; a < MAX_BODY_PARTS; a ++ ) + body_part[a].IN_USE = 0; +} + +void null_bullets() +{ + int a; + for ( a = 0; a < MAX_BULLETS; a ++ ) + bullet[a].IN_USE = 0; +} + +void animate_players() +{ + int a; + for ( a = 0; a < ACTIVE_PLAYERS; a ++ ) + aplayer[a]->animate(); +} + +int player_amount() +{ + int a,b=0; + for (a=0;aDEAD ) + aplayer[a]->chk_keys( a ); + if ( k.state[57] ) + { + if ( !MAP_ON ) MAP_ON = 1;else MAP_ON = 0;k.state[57] = 0; + } + if ( k.state[33] ) + { + if ( FRAMES_ON == 0 ) FRAMES_ON = 1;else FRAMES_ON = 0;k.state[33] = 0; + } + if ( k.state[88] ) + { + screen_capture(); k.state[88] = 0; + } +} + +void chk_wake_ups() +{ + int a; + for ( a = 0; a < MAX_CRATES; a ++ ) + if ( crate[a].IN_USE == 0 ) + crate[a].chk_wake_up(a); +} + +void move_crate_texts() +{ + int a; + for ( a = 0; a < MAX_CRATES; a ++ ) + if ( crate[a].IN_USE ) + crate[a].move_text(); +} + +void move_body_parts() +{ + int a; + for ( a = 0; a < MAX_BODY_PARTS; a ++ ) + if ( body_part[a].IN_USE ) + if ( body_part[a].speed > 0 ) + { + body_part[a].move(); + body_part[a].speed -= 0.2; + } +} + +void roll_enemies() +{ + int a; + for ( a = 0; a < ENEMIES; a ++ ) + if ( !enemy[a].DEAD ) + { + if ( enemy[a].tangle == enemy[a].angle ) + if ( enemy[a].walk_cnt == 0 ) + { + if ( enemy[a].see_somebody == 0 ) + if ( rand() % 50 == 1 ) + enemy[a].tangle = rand() % 360; + } + enemy[a].rotate(); + } +} + +void move_enemies() +{ + int a, b, see; + for ( a = 0; a < ENEMIES; a ++ ) + { + if ( !enemy[a].DEAD ) + { + see = 0; + for ( b = 0; b < MAX_PLAYERS &&see == 0; b ++ ) + if ( player[b].enabled) + if ( enemy[a].SEE_PL[b] ) see = 1; + if ( see == 0 ) + if ( enemy[a].walk_cnt == 0 ) + if ( rand() % 100 == 1 ) enemy[a].walk_cnt = ( rand() % 40 ) + 20; + if ( enemy[a].walk_cnt > 0 ) + { + enemy[a].move( enemy[a].rangle*9, 0 ); enemy[a].walk_cnt --;if ( enemy[a].WALK == 0 ) enemy[a].WALK = 1; + } + else enemy[a].WALK = 0; + } + if ( enemy[a].PUSH_POWER > 0 ) + { + if ( ( int ) enemy[a].PUSH_POWER > 0 ) + enemy[a].move( enemy[a].PUSH_ANGLE, ( int ) enemy[a].PUSH_POWER ); + enemy[a].PUSH_POWER -= 0.2; + } + } +} + +void push_players() +{ + int a; + for ( a = 0; a < ACTIVE_PLAYERS; a ++ ) + if ( aplayer[a]->PUSH_POWER > 0 ) + { + if ( ( int ) aplayer[a]->PUSH_POWER > 0 ) + aplayer[a]->move( aplayer[a]->PUSH_ANGLE, ( int ) aplayer[a]->PUSH_POWER, a ); + aplayer[a]->PUSH_POWER -= 0.2; + } +} + +void roll_effects() +{ + int a; + for ( a = 0; a < MAX_EFFECTS; a ++ ) + effect[a].roll(); +} + +void move_bullets() +{ + int a; + for ( a = 0; a < MAX_BULLETS; a ++ ) + if ( bullet[a].IN_USE == 1 ) + bullet[a].move(); +} + +void get_angles() +{ + int a; + for ( a = 0; a < ENEMIES; a ++ ) + if ( !enemy[a].DEAD ) + enemy[a].get_angles(); +} + +void try_see_players() +{ + int a; + for ( a = 0; a < ENEMIES; a ++ ) + if ( !enemy[a].DEAD ) + enemy[a].try_see_players(); +} + +void enemies_load() +{ + int a; + for ( a = 0; a < ENEMIES; a ++ ) + if ( !enemy[a].DEAD ) + enemy[a].load(); +} + +void chk_for_shoot() +{ + int a; + for ( a = 0; a < ENEMIES; a ++ ) + if ( !enemy[a].DEAD ) + enemy[a].chk_for_shoot(); +} + +void complete() +{ + int a; + next_level ++ ; + a = ( next_level*5 ) % 360; + writefonts( 160 + ( ( 160 - ( ( float ) next_level / ( ( float ) C_DELAY / 160 ) ) ) *sini[a] ) - 45, ( scr_y_size / 2 ) + ( 100 - ( ( float ) next_level / ( ( float ) C_DELAY / 100 ) ) ) *cosi[a], "MISSION COMPLETED", 3*16 ); +} + +void kello() +{ + char col = 1; + if ( !next_level ) + complete_time = ( clock() - st ) / CLOCKS_PER_SEC; + if ( complete_time > general_level_info.time_limit*TIME_ADD ) col = 3*16; + writefonts( 151, 10, c_2_c( complete_time ), col ); +} + +void frames_per_sec() +{ + char text[5]; + itoa( ( int ) F_PER_SEC, text, 10 ); + writefonts( 151, 20, text, 9*16 ); + itoa( OVER_POWER , text, 10 ); + writefonts( 151, 30, text, 7*16 ); +} + +void dec_hits() +{ + int a; + for ( a = 0; a < ACTIVE_PLAYERS; a ++ ) + if ( aplayer[a]->HIT > 0 ) aplayer[a]->HIT --; +} + +void are_all_dead() +{ + int a; + if ( KILLING_MODE!= DEATHMATCH ) + { + all_dead = 1; + for ( a = 0; a < ACTIVE_PLAYERS; a ++ ) + if ( aplayer[a]->enabled) + if ( aplayer[a]->DEAD <= 14 ) all_dead = 0; + } + if ( all_dead ) + complete_time = ( general_level_info.time_limit*TIME_ADD ) + 100; +} + +void seeing() +{ + int a; + for ( a = 0; a < ACTIVE_PLAYERS; a ++ ) + { + memset( aplayer[a]->see_level, 0, level_x_size*level_y_size ); + aplayer[a]->see(); + } +} + +void fire_lights() +{ + int a, xoffs, yoffs; + if ( GAME_MODE!= SPLIT_SCREEN ) + for ( a = 0; a < MAX_PLAYERS; a ++ ) + if (player[a].enabled) + { + if ( weapon[player[a].curr_weapon].gun == 1 ) + if ( player[a].FIRE ) + { + xoffs = ( sini[player[a].rangle2]*10 ) + ( sini[( int ) ( ( player[a].rangle2 ) + 270 ) % 360]*6 ); + yoffs = ( cosi[player[a].rangle2]*10 ) + ( cosi[( int ) ( ( player[a].rangle2 ) + 270 ) % 360]*6 ); + draw_light( &normal_l, player[a].x + 14 + xoffs - aplayer[0]->scr_x, player[a].y + 13 + yoffs - aplayer[0]->scr_y, 3, 2 - player[a].FIRE, 0 ); + } + } + if ( GAME_MODE == SPLIT_SCREEN ) + { + for ( a = 0; a < ACTIVE_PLAYERS; a ++ ) + { + if ( weapon[player[a].curr_weapon].gun == 1 ) + if ( player[a].FIRE ) + { + xoffs = ( sini[player[a].rangle2]*10 ) + ( sini[( int ) ( ( player[a].rangle2 ) + 270 ) % 360]*6 ); + yoffs = ( cosi[player[a].rangle2]*10 ) + ( cosi[( int ) ( ( player[a].rangle2 ) + 270 ) % 360]*6 ); + draw_light( &normal_l, player[a].x + 14 + xoffs - aplayer[0]->scr_x, player[a].y + 13 + yoffs - aplayer[0]->scr_y, 3, 2 - player[a].FIRE, 1 ); + draw_light( &normal_l, ( player[a].x + 14 + xoffs - aplayer[1]->scr_x ) + 160, player[a].y + 13 + yoffs - aplayer[1]->scr_y, 3, 2 - player[a].FIRE, 2 ); + } + } + } + if ( GAME_MODE!= SPLIT_SCREEN ) + for ( a = 0; a < ENEMIES; a ++ ) + if ( !enemy[a].DEAD ) + if ( enemy[a].FIRE ) + { + xoffs = ( sini[( int ) ( enemy[a].rangle*9 ) ]*10 ) + ( sini[( int ) ( ( enemy[a].rangle*9 ) + 270 ) % 360]*3 ); + yoffs = ( cosi[( int ) ( enemy[a].rangle*9 ) ]*10 ) + ( cosi[( int ) ( ( enemy[a].rangle*9 ) + 270 ) % 360]*3 ); + draw_light( &normal_l, enemy[a].x + 14 + xoffs - aplayer[0]->scr_x, enemy[a].y + 13 + yoffs - aplayer[0]->scr_y, 3, 2 - enemy[a].FIRE, 0 ); + } + if ( GAME_MODE == SPLIT_SCREEN ) + for ( a = 0; a < ENEMIES; a ++ ) + if ( !enemy[a].DEAD ) + if ( enemy[a].FIRE ) + { + xoffs = ( sini[( int ) ( enemy[a].rangle*9 ) ]*10 ) + ( sini[( int ) ( ( enemy[a].rangle*9 ) + 270 ) % 360]*3 ); + yoffs = ( cosi[( int ) ( enemy[a].rangle*9 ) ]*10 ) + ( cosi[( int ) ( ( enemy[a].rangle*9 ) + 270 ) % 360]*3 ); + draw_light( &normal_l, enemy[a].x + 14 + xoffs - player[0].scr_x, enemy[a].y + 13 + yoffs - player[0].scr_y, 3, 2 - enemy[a].FIRE, 1 ); + draw_light( &normal_l, ( enemy[a].x + 14 + xoffs - player[1].scr_x ) + 160, enemy[a].y + 13 + yoffs - player[1].scr_y, 3, 2 - enemy[a].FIRE, 2 ); + } +} + +void chk_burn() +{ + int a,b; + + for ( a = 0; a < MAX_PLAYERS; a ++ ) + if ( player[a].enabled ) + if ( !player[a].DEAD ) + if ( player[a].burning ) + { + if (a==aplayer[0]->tindex || (GAME_MODE==SPLIT_SCREEN && a==aplayer[1]->tindex)) + { + player[a].burning --; + player[a].get_damage( 0.4, player[a].Frying_player ); + } + + if (aplayer[0]->tindex==a && GAME_MODE==NETWORK) + { + if (NETWORK_MODE==CLIENT) + sendipx(0,IPX_BURNING,player[a].tindex,player[a].burning); + else + for(b=1;b aplayer[0]->scr_x - 160 ) + if ( steam[a].x < aplayer[0]->scr_x + 480 ) + if ( steam[a].y > aplayer[0]->scr_y - yl1 ) + if ( steam[a].y < aplayer[0]->scr_y + yl2 ) + du = 1; + if ( GAME_MODE == SPLIT_SCREEN ) + if ( steam[a].x > aplayer[1]->scr_x - 160 ) + if ( steam[a].x < aplayer[1]->scr_x + 480 ) + if ( steam[a].y > aplayer[1]->scr_y - yl1 ) + if ( steam[a].y < aplayer[1]->scr_y + yl2 ) + du = 1; + if ( du ) + { + if ( steam[a].speed < s_r_a ) b = steam_rates[steam[a].speed]; + else b = 1; + if ( Steam_count % b == 0 ) + new_effect( 0, STEAM, steam[a].x, steam[a].y, steam[a].angle, steam[a].speed ); + } + } +} + +void game_shit() +{ + int a; + chkeys(); + push_players(); + chk_burn(); + move_bullets(); + move_body_parts(); + move_crate_texts(); + if ( KILLING_MODE == DEATHMATCH ) + if ( (GAME_MODE != NETWORK) || (NETWORK_MODE==SERVER)) chk_wake_ups(); + for ( a = 0; a < ACTIVE_PLAYERS; a ++ ) + aplayer[a]->move_scr(); + if ( DARK_MODE ) seeing(); + if (ENEMIES_ON_GAME || GAME_MODE==ONE_PLAYER) + if ( (GAME_MODE!= NETWORK)||(NETWORK_MODE == SERVER )) + { + roll_enemies(); + get_angles(); + try_see_players(); + move_enemies(); + chk_for_shoot(); + enemies_load(); + animate_enemies(); + } + draw_floor(); + for ( a = 0; a < ACTIVE_PLAYERS; a++ ) aplayer[a]->load(); + animate_players(); + draw_players( 0 );// DEad players + draw_effects( 0 ); + draw_body_parts(); + if ( SHADOWS ) draw_gae_shadows(); + draw_crates(); + draw_bullets(); + if ( LIGHT_EFFECTS ) fire_lights(); + draw_live_enemies(); + draw_players( 1 );// Live players + if ( SMOKE_EFFECTS ) do_steam(); + draw_walls(); + if ( SHADOWS ) draw_shadows(); + draw_effects( 1 ); + if ( LIGHT_EFFECTS ) draw_spots(); + draw_targets(); + if ( DARK_MODE ) draw_black(); + dec_hits(); + draw_hits(); + if ( MAP_ON ) map(); + draw_crate_texts(); + if ( FRAMES_ON ) frames_per_sec(); + if ( KILLING_MODE == DEATHMATCH ) draw_kills(); + draw_infos(); + draw_energies(); + message_board.draw(); + if ( next_level ) complete(); + if ( KILLING_MODE!= DEATHMATCH ) + kello(); + if ( first == 1 ) + { + if (! (GAME_MODE==NETWORK && NETWORK_MODE==CLIENT)) + fadein( virbuff, pal ); else setpal(pal,256); + first = 0; + } + memcpy( screen, virbuff, 320*scr_y_size ); + roll_effects(); + are_all_dead(); +} + +void do_prices() +{ + int a; + for ( a = 0; a < DIFF_WEAPONS; a ++ ) + sell_price[a] = ( 0.8*weapon[a + 1].cost ) - ( rand() % ( weapon[a + 1].cost / 2 ) ); + sell_price[DIFF_WEAPONS] = ( 0.8*shield_data.cost ) - ( rand() % ( shield_data.cost / 2 ) ); + sell_price[DIFF_WEAPONS + 1] = ( 0.8*target_cost ) - ( rand() % ( target_cost / 2 ) ); +} + +void victory() +{ + int a = 0, oclock; + load_efp( "efps\\sunset.efp", picture, 0 ); + load_efp_pal( "efps\\sunset.efp", pal ); + setpal( pal, 0 ); + memcpy( screen, picture, 64000 ); + oclock = clock(); + while ( a < 255 ) + if ( oclock!= clock() ) + { + oclock = clock(); + a += 10; + setpal( pal, a ); + } + k.state[1] = 0; + while ( !k.state[1] ); + while ( a > 0 ) + if ( oclock!= clock() ) + { + oclock = clock(); + a -= 10; + setpal( pal, a ); + } +} + +void flushipx() +{ + int a,b; + char jee[100]; + for ( a = 0; a < MAX_PLAYERS; a++ ) + if (player[a].enabled) + { + sprintf(jee,"streami[%d][%d]",a,ipxofs[a]); +// message_board.add_message(jee); + if (ipxofs[a]!=0) + { + ipxstream[a][ ipxofs[a]++ ] = IPX_END; + for (b=0;bdata[b]=ipxstream[a][b]; + while (send->ecb.inuse); + sendpacket( sendseg, player[a].ipxnode, send, (word)(ipxofs[a]+1) ); + // RESET + ipxofs[a] = 0; + } + } +// message_board.add_message("flushed..."); +} + +void docheckflush() +{ + int a,b; + char jee[100]; + + for ( a = 0; a < MAX_PLAYERS; a++ ) + if (player[a].enabled) + { + sprintf(jee,"streami[%d][%d]",a,ipxofs[a]); +// message_board.add_message(jee); + if (ipxofs[a]>(MAXDATASIZE-100)) + { + ipxstream[a][ ipxofs[a]++ ] = IPX_END; + for (b=0;bdata[b]=ipxstream[a][b]; + while (send->ecb.inuse); + sendpacket( sendseg, player[a].ipxnode, send, (word)(ipxofs[a]+1) ); + // RESET + ipxofs[a] = 0; + } + } +// message_board.add_message("flushed2..."); +} + + +void sendipxnow( struct nodeaddr *node, int type, ... ) +{ + int a = 0; +// TEMP VARIABLES + int b,c,d; + char *str; + char *p; + +// TEMP VARIABLES END + auto va_list ap; + va_start( ap, type ); + + if (send->ecb.inuse) + while (send->ecb.inuse); + switch( type ) + { + case IPX_GAMEDATA: send->data[a++] = ( char ) type; + b = va_arg( ap, int); + // for (c=0;c<6;c++) + // player[b].ipxnode.node[c]=node->node[c]; + send->data[a++] = ( char ) player_amount()+1; + send->data[a++] = ( char ) b; + send->data[a++] = ( char ) DEATH_MATCH_SPEED; + for (d=0;ddata[a++] = ( char ) d; + str = (char *) &player[d].x; + for (c=0;cdata[a++]=*(str++); + str = (char *) &player[d].y; + for (c=0;cdata[a++]=*(str++); + str = (char *) &player[d].rangle; + for (c=0;cdata[a++]=*(str++); + send->data[a++]=(char) player[d].color; + str = (char *) &player[d].burning; + for (c=0;cdata[a++]=*(str++); + str = (char *) &player[d].ipxnode; + for (c=0;cdata[a++]=*(str++); + for (c=0;c<10;c++) send->data[a++]=player[d].name[c]; + str = (char *) &player[d].ANIM; + for (c=0;cdata[a++]=*(str++); + str = (char *) &player[d].player_kills; + for (c=0;cdata[a++]=*(str++); + str = (char *) &player[d].DEAD; + for (c=0;cdata[a++]=*(str++); + } + message_board.add_message("Gamedata sent"); + break; +/* case IPX_NEWPLAYERDATA: + break;*/ + case IPX_IMJOININGNOW:send->data[a++] = ( char ) type; + str = va_arg( ap, char *); + for (b=0;b<10;b++) + send->data[a++]=*(str++); + break; + case IPX_SERVERSEARCH:send->data[a++] = ( char ) type; + break; + case IPX_SERVERANSWER:send->data[a++] = ( char ) type; + str = va_arg( ap, char * ); + for ( b = 0; b < 10; b++ ) + send->data[a++ ] = str[b]; + break; + case IPX_SERVERSHUTDOWN:send->data[a++] = ( char ) type; + break; + case IPX_JOINREQUEST:send->data[a++] = ( char ) type; + break; + case IPX_SENDLEVELINFO:send->data[a++] = ( char ) type; + break; + case IPX_SENDLEVEL:send->data[a++] = ( char ) type; + b = va_arg( ap, int); + send->data[a++] = (char)(b & 255); + send->data[a++] = (char)(b >> 8 ); + break; + case IPX_TRANSMITLEVEL: + send->data[a++] = ( char ) type; + b = va_arg( ap, int); + send->data[a++] = (char)(b & 255); + send->data[a++] = (char)(b >> 8 ); + str=(char*)level; + for (c=b*(MAXDATASIZE-24);(c<(b+1)*(MAXDATASIZE-24))&&(c<(12*level_x_size*level_y_size));c++) + send->data[a++] = str[c]; + + break; + case IPX_JOINACCEPT:send->data[a++] = ( char ) type; + b = va_arg(ap, int); + send->data[a++] = (char) b; + if (b) message_board.add_message("Accepting player..."); + else message_board.add_message("Player NOT accepted..."); + + break; + case IPX_LEVELINFO: send->data[a++]=(char)type; + send->data[a++]=(char)(level_x_size&255); + send->data[a++]=(char)(level_x_size>>8); + send->data[a++]=(char)(level_y_size&255); + send->data[a++]=(char)(level_y_size>>8); + p=(char *)&general_level_info; + for (b=0;bdata[a++]=p[b]; + break; + default:error("sendipxnow: message %d not yet implemented\n", type ); + } + send->data[a++] = IPX_END; + sendpacket( sendseg, *node, send, (word)(a+1) ); + va_end( ap ); +} + +void sendipx( int dest, int type, ... ) +{ int c,b,a; + char *str; + char d; + + float x,y; +// char kakka[102]; + + va_list ap; + va_start( ap, type ); + + switch( type ) + { + case IPX_SOUND: + ipxstream[dest][ipxofs[dest]++] = (char)type; + d=va_arg(ap,char); + ipxstream[dest][ipxofs[dest] ++ ] = d; + d=va_arg(ap,char); + ipxstream[dest][ipxofs[dest] ++ ] = d; + b= va_arg(ap,int); + str = (char *) &b; + for (c=0;ctindex; + break; + + case IPX_MESSAGE: + ipxstream[dest][ipxofs[dest] ++ ] = (char)type; + str=va_arg(ap,char *); + for (c=0;cnode.node[a]; + } + initsendpacket(send,sendseg); + for (a=0;aecb.inuse) + cancelpacket(recseg[a]); + closesocket( (word) socketid ); +} + +void server_add_player(char *name,struct nodeaddr *n) +{ + int colors[]={3*16,9*16,10*16,5*16,1*16,2*16,4*16,6*16}; + int a,b; + + for (a=0;a ecb.inuse == 0 ) + { + data = - 1; + ofs = 0; + while( data!= IPX_END ) + { + data = rec[a]->data[ofs++]; + switch ( data ) + { + case IPX_ALIVE: + pcom[pcoms++]=data; + pl=rec[a]->data[ofs++]; + player[pl].enabled=1; + player[pl].time_since_last_alive=0; + break; + + case IPX_MESSAGE: + pcom[pcoms++]=data; + for(c=0;cdata[ofs++]; + message_board.add_message(buf); + break; + + case IPX_BURNING: + pcom[pcoms++]=data; + pl=rec[a]->data[ofs++]; + player[pl].burning=rec[a]->data[ofs++]; + for (c=1;cdata[ofs++]; //tindex + param1=rec[a]->data[ofs++]; + str = (char *) ¶m2; + for (c=0;cdata[ofs++]; + str = (char *) ¶m3; + for (c=0;cdata[ofs++]; + str = (char *) ¶m4; + for (c=0;cdata[ofs++]; + MIDASplaySample( samplep[param1], MIDAS_CHANNEL_AUTO, 0, param2, get_volume(aplayer[0]->x,aplayer[0]->y,param3,param4),get_pan(aplayer[0]->x,param3)); + for (c=1;cdata[ofs++]; //tindex + for (b=0;bdata[ofs++]; + bullet[b].type=&bullet_type[d]; + str = (char *) &bullet[b].x; + for (c=0;cdata[ofs++]; + str = (char *) &bullet[b].y; + for (c=0;cdata[ofs++]; + str = (char *) &bullet[b].angle; + for (c=0;cdata[ofs++]; + str = (char *) &bullet[b].time; + for (c=0;cdata[ofs++]; + + for (c=1;cdata[ofs++]; + str = (char *) &pl; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].type; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].weapon; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].bullet; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].energy; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].x; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].y; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].IN_USE; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].text_count; + for (c=0;cdata[ofs++]; + crate[pl].text_angle=0; + if (crate[pl].text_count!=0) + { + crate[pl].IN_USE=0; + crate[pl].wake_up_count=1; + } + for (c=1;cdata[ofs++]; + + for (c=0;cdata[ofs++]; + str = (char *)&x; + for (c=0;cdata[ofs++]; + str = (char *)&y; + for (c=0;cdata[ofs++]; + player[pl].x=x; + player[pl].y=y; + for (c=1;cdata[ofs++]; //tindex + b=rec[a]->data[ofs++]; + + str = (char *) &player[b].player_kills; + for (c=0;cdata[ofs++]; + for (c=1;cdata[ofs++]; + str = (char *)&player[pl].rangle; + for (c=0;cdata[ofs++]; + for (c=1;cdata[ofs++]; + str = (char *)&player[pl].ANIM; + for (c=0;cdata[ofs++]; + for (c=1;cipx.src.node.node[b]; + for(b=0;b<10;b++) + buf[b]=rec[a]->data[ofs++]; + server_add_player(buf,&n); + break; + + case IPX_SERVERSEARCH: + pcom[pcoms++]=data; + for (b=0;b<6;b++) + n.node[b]=rec[a]->ipx.src.node.node[b]; + sendipxnow(&n, IPX_SERVERANSWER,servername); + break; + + case IPX_TEXTMESSAGE: + pcom[pcoms++]=data; + ofs+=IPXMSGLEN[IPX_TEXTMESSAGE]-1; + break; + + case IPX_END: + pcom[pcoms++]=data; + break; + + case IPX_JOINREQUEST: + pcom[pcoms++]=data; + for (b=0;b<6;b++) + n.node[b]=rec[a]->ipx.src.node.node[b]; + if (player_amount()ipx.src.node.node[b]; + sendipxnow(&n, IPX_LEVELINFO); + break; + + case IPX_SENDLEVEL: + pcom[pcoms++]=data; + for (b=0;b<6;b++) + n.node[b]=rec[a]->ipx.src.node.node[b]; + b=rec[a]->data[ofs++]; + b+=rec[a]->data[ofs++]<<8; + sendipxnow(&n, IPX_TRANSMITLEVEL, (int) b); + break; + + default: + sprintf(buf,"do_server_shit: receiver %d\nunknown server command %d at offset %d\n", a, data,ofs ); + sprintf(buf2,"Previous commands:\n"); + strcat(buf,buf2); + for (b=0;b ecb.inuse == 0 ) + { + data = - 1; + ofs = 0; + while( data!= IPX_END ) + { + data = rec[a]->data[ofs++]; + switch ( data ) + { + case IPX_SOUND: + pcom[pcoms++]=data; + pl=rec[a]->data[ofs++]; //tindex + param1=rec[a]->data[ofs++]; + str = (char *) ¶m2; + for (c=0;cdata[ofs++]; + str = (char *) ¶m3; + for (c=0;cdata[ofs++]; + str = (char *) ¶m4; + for (c=0;cdata[ofs++]; + MIDASplaySample( samplep[param1], MIDAS_CHANNEL_AUTO, 0, param2, get_volume(aplayer[0]->x,aplayer[0]->y,param3,param4),get_pan(aplayer[0]->x,param3)); + break; + + case IPX_NEWBULLET: + pcom[pcoms++]=data; + pl=rec[a]->data[ofs++]; //tindex + for (b=0;bdata[ofs++]; + bullet[b].type=&bullet_type[d]; + str = (char *) &bullet[b].x; + for (c=0;cdata[ofs++]; + str = (char *) &bullet[b].y; + for (c=0;cdata[ofs++]; + str = (char *) &bullet[b].angle; + for (c=0;cdata[ofs++]; + str = (char *) &bullet[b].time; + for (c=0;cdata[ofs++]; + break; + + case IPX_SERVERSHUTDOWN: + quit=1; + break; + + case IPX_MESSAGE: + pcom[pcoms++]=data; + for(c=0;cdata[ofs++]; + message_board.add_message(buf); + break; + + + case IPX_BURNING: + pcom[pcoms++]=data; + pl=rec[a]->data[ofs++]; + player[pl].burning=rec[a]->data[ofs++]; + break; + + case IPX_UPDKILLS: + pcom[pcoms++]=data; + pl=rec[a]->data[ofs++]; //tindex + b=rec[a]->data[ofs++]; + + str = (char *) &player[b].player_kills; + for (c=0;cdata[ofs++]; + break; + + case IPX_UPDCRATE: + pcom[pcoms++]=data; + + b=rec[a]->data[ofs++]; + str = (char *) &pl; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].type; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].weapon; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].bullet; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].energy; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].x; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].y; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].IN_USE; + for (c=0;cdata[ofs++]; + str = (char *) &crate[pl].text_count; + for (c=0;cdata[ofs++]; + crate[pl].text_angle=0; + if (crate[pl].text_count!=0) crate[pl].IN_USE=0; else + new_effect( &normal_l, TELEPORT, crate[pl].x + 8, crate[pl].y + 8, 0, 0 ); + break; + + case IPX_PLYXY: + pcom[pcoms++]=data; + pl=rec[a]->data[ofs++]; + str = (char *)&x; + for (c=0;cdata[ofs++]; + str = (char *)&y; + for (c=0;cdata[ofs++]; + player[pl].x=x; + player[pl].y=y; + break; + + case IPX_PLYRANGLE: + pcom[pcoms++]=data; + pl=rec[a]->data[ofs++]; + str = (char *)&player[pl].rangle; + for (c=0;cdata[ofs++]; + break; + + case IPX_PLYANIM: + pcom[pcoms++]=data; + pl=rec[a]->data[ofs++]; + str = (char *)&player[pl].ANIM; + for (c=0;cdata[ofs++]; + break; + + case IPX_END: + pcom[pcoms++]=data; + break; + + default: + sprintf(buf,"do_client_shit: receiver %d\nunknown client command %d at offset %d\n", a, data,ofs ); + sprintf(buf2,"Previous commands:\n"); + strcat(buf,buf2); + for (b=0;becb.inuse==0) + { + data = - 1; + ofs = 0; + while( data!= IPX_END ) + { + data = rec[a]->data[ofs++]; + switch ( data ) + { + case IPX_GAMEDATA: + plyers=rec[a]->data[ofs++]; + aplayer[0]=&(player[rec[a]->data[ofs++]]); + aplayer[0]->speed=rec[a]->data[ofs++]; + for (c=0;cdata[ofs++]; + if (player[pno].enabled) error("realjoin: IPX_GAMEDATA mismatch detected!\n(player[%d].enabled==1)",pno); + str=(char *)&player[pno].x; + for (b=0;bdata[ofs++]; + str=(char *)&player[pno].y; + for (b=0;bdata[ofs++]; + str=(char *)&player[pno].rangle; + for (b=0;bdata[ofs++]; + player[pno].color=rec[a]->data[ofs++]; + str=(char *)&player[pno].burning; + for (b=0;bdata[ofs++]; + str=(char *)&player[pno].ipxnode; + for (b=0;bdata[ofs++]; + for (b=0;b<10;b++) player[pno].name[b]=rec[a]->data[ofs++]; + str=(char *)&player[pno].ANIM; + for (b=0;bdata[ofs++]; + str=(char *)&player[pno].player_kills; + for (b=0;bdata[ofs++]; + str=(char *)&player[pno].DEAD; + for (b=0;bdata[ofs++]; + player[pno].enabled=1; + } + if (!aplayer[0]->enabled) message_board.add_message("realjoin: something missing..."); + received=1; + if (rec[a]->data[ofs+1]!=IPX_END) error("realjoin: IPX packet mismatching!"); + + break; + default:ofs+=IPXMSGLEN[data]-1; + }; + } + listenforpacket( recseg[a] ); + } + if ((framecount-s)>target_frames) timeout=1; + } + } + return 1; +} + +int getlevel() +{ + int received,timeout; + int blocks,bno,c; + int s,b,a,data,ofs; + char *p; + + blocks=(12*level_x_size*level_y_size)/(MAXDATASIZE-24); + if ((12*level_x_size*level_y_size)%(MAXDATASIZE-24)) blocks++; + level=(struct BLOCK*)malloc(12*level_x_size*level_y_size); + + for (b=0;becb.inuse==0) + { + data = - 1; + ofs = 0; + while( data!= IPX_END ) + { + data = rec[a]->data[ofs++]; + switch ( data ) + { + case IPX_TRANSMITLEVEL: + bno = rec[a]->data[ofs++]; + bno+= rec[a]->data[ofs++]<<8; + if (bno!=b) return 0; + p = (char*)level; + for (c=b*(MAXDATASIZE-24);(c<(b+1)*(MAXDATASIZE-24))&&(c<(12*level_x_size*level_y_size));c++) + p[c]=rec[a]->data[ofs++]; + received=1; + break; + default:ofs+=IPXMSGLEN[data]-1; + }; + } + listenforpacket( recseg[a] ); + } + if ((framecount-s)>target_frames) timeout=1; + } + } + } + return 1; +} + +int getlevelinfo() +{ int received,timeout; + int s,b,a,data,ofs; + char *p; + + received=0; + while(!received) + { + sendipxnow(&serveraddr,IPX_SENDLEVELINFO); + timeout=0; + + s=framecount; + + while((!received)&&(!timeout)) + { + if (k.state[1]) return 0; + for ( a = 0; a < RECEIVERS; a ++ ) + if (rec[a]->ecb.inuse==0) + { + data = - 1; + ofs = 0; + while( data!= IPX_END ) + { + data = rec[a]->data[ofs++]; + switch ( data ) + { + case IPX_LEVELINFO: + level_x_size =rec[a]->data[ofs++]; + level_x_size+=rec[a]->data[ofs++]<<8; + level_y_size =rec[a]->data[ofs++]; + level_y_size+=rec[a]->data[ofs++]<<8; + p=(char *)&general_level_info; + for (b=0;bdata[ofs++]; + received=1; + break; + default:ofs+=IPXMSGLEN[data]-1; + }; + } + listenforpacket( recseg[a] ); + } + if ((framecount-s)>target_frames) timeout=1; + } + } + return 1; +} + +int join_game(struct nodeaddr n) +{ char buf[256]; + + memcpy(&serveraddr,&n,sizeof(serveraddr)); + load_efp( "efps\\cool.efp", picture, 0 ); + draw_box1( 60, 10, 320 - 60, 190, 15 ); + fadeout( virbuff, pal ); + memcpy(virbuff,picture,64000); + FONT_NUM = 0; + writefonts2( 160 - ( str_length( "joining game" ) >> 1 ), 20, "joining game", 1 ); + fadein(virbuff,pal); + FONT_NUM = 1; + writefonts( 80, 50, "receiving levelinfo...", M_BLUE ); + memcpy(screen,virbuff,64000); + if (!getlevelinfo()) return 0; + sprintf(buf," \"%s\" (%d x %d)...",general_level_info.comment,level_x_size,level_y_size); + writefonts( 80, 60,buf, M_BLUE ); + writefonts( 80, 70,"receiving level...", M_BLUE ); + memcpy(screen,virbuff,64000); + if (!getlevel()) return 0; + writefonts( 80, 80,"joining game...", M_BLUE ); + memcpy(screen,virbuff,64000); + if (!realjoin()) return 0; + sprintf(buf,"%d players",player_amount()); + writefonts( 80, 90,buf, M_BLUE ); + writefonts( 80, 100,"done!", M_BLUE ); + memcpy(screen,virbuff,64000); + k.clear_stack(); + k.getch(); + + return 1; +} + +int waitfor(int msg,int secs) +{ int timeout=0,s; + int a,data,ofs,yes=0; + + s=framecount; + + while ((!timeout)&&(yes!=0)) + { + for ( a = 0; a < RECEIVERS; a ++ ) + if (rec[a]->ecb.inuse==0) + { + data = - 1; + ofs = 0; + while( data!= IPX_END ) + { + data = rec[a]-> data[ofs ++ ]; + if (data==msg) + { + if (rec[a]-> data[ofs ++ ]) yes=1; + else yes=-1; + } else ofs+=IPXMSGLEN[data]-1; + } + listenforpacket( recseg[a] ); + } + if ((framecount-s)>target_frames*secs) timeout=1; + } + if ((yes<0)||(timeout)) return 0; + else return 1; +} + +int join_server(struct nodeaddr n) +{ + memcpy(&serveraddr,&n,sizeof(serveraddr)); + FONT_NUM = 1; + writefonts(80,190,"waiting...",M_BLUE); + memcpy(screen,virbuff,64000); + sendipxnow(&serveraddr,IPX_JOINREQUEST); + if (!waitfor(IPX_JOINACCEPT,3)) return 0; + return 1; +} + +int select_server() +{ + int a, b, c,data,ofs,first=1,done=0,cnt=0,oclock=0; + int select=0; + int chg=1; + int servers=0; + char servernames[10][10],tempname[10]; + struct nodeaddr nodez[10],tempnode; + struct nodeaddr bc; + + load_efp( "efps\\cool.efp", picture, 0 ); + draw_box1( 60, 10, 320 - 60, 190, 15 ); + fadeout( virbuff, pal ); + + k.state[1] = 0; + k.state[28] = 0; + bc=BROADCAST(); + + while ( !done ) + { + if (k.state[28] && servers>0) + { + if (join_server(nodez[select])) done=1; + else + { + chg=1; + servers--; + for (c=select;c0){ + if (k.state[94] && select>0) {select--;k.state[94]=0;} + if (k.state[99] && select> 1 ), 20, "select server", 1 ); + FONT_NUM = 1; + if (chg) + for (a=0;a 23 ) cnt = 0; + } + sendipxnow(&bc,IPX_SERVERSEARCH); + + for ( a = 0; a < RECEIVERS; a ++ ) + if (rec[a]->ecb.inuse==0) + { + data = - 1; + ofs = 0; + while( data!= IPX_END ) + { + data = rec[a]-> data[ofs ++ ]; + switch ( data ) + { + case IPX_SERVERANSWER: + for (b=0;b<6;b++) + tempnode.node[b]=rec[a]->ipx.src.node.node[b]; + for (b=0;b<10;b++) + tempname[b]=rec[a]->data[ofs++]; + if (servers<10) + { + for (b=0;(bipx.src.node.node[b]; + for (b=0;b data[ofs ++ ] ) != 0 ); + break; + + case IPX_END: + break; + default:ofs+=IPXMSGLEN[data]-1; + }; + } + listenforpacket( recseg[a] ); + } + if (k.state[1]) return 0; + } + + if (join_game(nodez[select])) return 1; + else return 0; +} + +void chk_for_loosers() +{ + int a,b; + char kakka[100]; + + for (a=1;a=40*3) + { + player[a].enabled=0; + sprintf(kakka,"%s (%d) left the game",player[a].name,player[a].tindex); + for (b=1;bipxnode.node[a]=localadd->node.node[a]; + } + + if ((GAME_MODE!=NETWORK)|| + (NETWORK_MODE==SERVER)) + { + strcpy( match_level, "levs\\" ); + if ( DEATH_MATCH_EPISODE > 0 ) + { + strcat( match_level, dirlist[DEATH_MATCH_EPISODE - 1].name ); + strcat( match_level, "\\" ); + } + strcat( match_level, DEATH_MATCH_LEVEL ); + LEVELS = files_in_episode[episode + 1]; + LEVEL = START_LEVEL; + if ( LEVEL > LEVELS - 1 ) LEVEL = LEVELS - 1; + } + + fadeout( virbuff, pal ); + set_keys(); + if ( GAME_MODE==NETWORK && NETWORK_MODE==CLIENT) + { + alusta_client(); + sendipx(0,IPX_ALIVE); + sendipx(0,IPX_SENDCRATES,(char)aplayer[0]->tindex); + } + else alusta_players1(); + quit = 0; + all_dead = 0; + BACK_TO_MENU = 0; + while ( !quit &&!BACK_TO_MENU ) + { + // // + if ((GAME_MODE!=NETWORK)|| + (NETWORK_MODE==SERVER)) + { + strcpy( filename, "levs\\" ); + strcat( filename, dirlist[episode].name ); + strcat( filename, "\\level" ); + itoa( LEVEL + 1, text, 10 ); + strcat( filename, text ); + strcat( filename, ".lev" ); + if ( KILLING_MODE!= DEATHMATCH ) leveldata.load( filename ); + else (leveldata.load( match_level)); + if ( KILLING_MODE!= DEATHMATCH ) + level_info(); + } + if ( !BACK_TO_MENU ) + { + if ( DARK_MODE ) + { + for ( a = 0; a < ACTIVE_PLAYERS; a ++ ) + aplayer[a]->see_level = (char *)malloc( level_x_size*level_y_size ); + } + if ( KILLING_MODE!= DEATHMATCH ) + { + do_prices(); + if ( LEVEL > 0 ) + for ( a = 0; a < ACTIVE_PLAYERS; a ++ ) aplayer[a]->shop(); + } + + if ( !FORCE_0x13 ) + if ( VESA2 ) + { + vbe = vbeOpen( 320, 240, 8 ); + if (vbe!=NULL){ + scr_y_size = 240; + screen = vbe-> lfb; + } else FORCE_0x13=1; + } + + peli_biisi(); + + load_efp_pal( "efps\\walls1.efp", pal ); + + + if ( !(GAME_MODE==NETWORK && NETWORK_MODE==CLIENT)) + alusta_players2(); + DEAD_ENEMIES = 0; + + + if ((GAME_MODE!=NETWORK)|| + (NETWORK_MODE==SERVER)) + { + if ( ENEMIES_ON_GAME == 0 && KILLING_MODE == DEATHMATCH ) ENEMIES = 0; + else { + alusta_enemies(); + place_enemies(); + } + } else ENEMIES=0; + + null_body_parts(); + null_effects(); + null_bullets(); + null_crates(); + if ((GAME_MODE!=NETWORK)|| + (NETWORK_MODE==SERVER)) + { + if ( KILLING_MODE == COOPERATIVE ) place_normal_game_crates(); + else place_death_match_crates(); + } + FONT_NUM = 1; + frame_count = 0; + oclock = clock(); + st = clock(); + first = 1; + OVER_POWER = 0; + Spot_count = 0; + Steam_count = 0; + next_level = 0; + + if ((GAME_MODE!=NETWORK)|| + (NETWORK_MODE==SERVER)) + if ( KILLING_MODE == DEATHMATCH ) + for ( a = 0; a < ACTIVE_PLAYERS; a++ ) aplayer[a]->random_place(); + + effect_age_count = 0; + message_board.clear(); + + while( !all_dead &&!quit &&next_level < C_DELAY ) + { + // GAME loop + c = clock(); + if ( ( ( float ) c / CLOCKS_PER_SEC ) - ( ( float ) oclock / CLOCKS_PER_SEC ) > 2 ) + { + F_PER_SEC = ( ( float ) frame_count / ( c - oclock ) ) *CLOCKS_PER_SEC; + oclock = c; + frame_count = 0; + } + if (FRAMES_ON) opcnt ++; // OVER_POWER count + + if ( framecount ) + { + if (FRAMES_ON){ + op[opcnt2] = opcnt; + opcnt2 ++; + if ( opcnt2 > 5 ) opcnt2 = 0; + opcnt = 0; + if ( opcnt2 == 0 ) + OVER_POWER = ( op[0] + op[1] + op[2] + op[3] + op[4] ) / 5; + } + framecount = 0;// incremented by MIDAS timer + game_shit();// do the game !!!! + if (GAME_MODE==NETWORK && NETWORK_MODE==SERVER) + chk_for_loosers(); + Steam_count ++; + Steam_count%= 360; + Spot_count += 2; + Spot_count%= 360; + frame_count ++; + } + if ( GAME_MODE == NETWORK) + { + if (NETWORK_MODE == CLIENT ) do_client_shit(); + if (NETWORK_MODE == SERVER ) do_server_shit(); + } + } // game loop end + + if ( DARK_MODE ) + for ( a = 0; a < ACTIVE_PLAYERS; a ++ ) + free( aplayer[a]->see_level ); + } + fadeout( virbuff, pal ); + menu_biisi(); + if ( !FORCE_0x13 ) + if ( VESA2 ) + { + scr_y_size = 200; + vbeClose( vbe ); + vesa_set_mode( 0x13 ); + screen = ( char * ) 0xA0000; + } + + if ( KILLING_MODE!= DEATHMATCH ) + { + all_dead = 0; + are_all_dead(); + if ( all_dead ) quit = 1; + else next_level = 1; + if ( LEVEL == 0 &&BACK_TO_MENU ) + { } + else statics(); + + if ( !all_dead && GAME_MODE == SPLIT_SCREEN ) two_to_one(); + + if ( LEVEL == LEVELS - 1 ) + if ( !BACK_TO_MENU ) + if ( next_level == 1 ) + if ( quit == 0 ) + { + quit = 1; next_level = 0; victory(); + } + if ( next_level ) LEVEL ++; + next_level = 0; + } + } + load_efp_pal( "efps\\ware.efp", pal ); +} + +void menu_scr() +{ + load_efp( "efps\\tk.efp", picture, 0 ); + load_efp_pal( "efps\\ware.efp", pal ); + draw_box1( 55, 90 - ( ( Menu_texts*15 ) / 2 ), 320 - 55, 110 + ( ( Menu_texts*15 ) / 2 ), 10 ); + k.state[28] = 0; + first = 1; +} + +void menu() +{ + int a, cnt = 0, selected = 0, quit = 0, oclock; + int starty = ( Menu_texts*15 ) / 2; + ph = 0; + menu_scr(); + menu_biisi(); + while( !quit ) + { + memcpy( virbuff, picture, 64000 ); + FONT_NUM = 1; + writefonts( 320 - str_length( Version ), 190, Version, M_BLUE ); + for ( a = 0; a < Menu_texts; a ++ ) + { + if ( a == selected ) + { + FONT_NUM = 0; + writefonts2( 160 - ( str_length( menu_text[a] ) / 2 ), 100 - starty + ( a*15 ), menu_text[a], 1 ); + } + else + { + FONT_NUM = 2; + writefonts2( 160 - ( str_length( menu_text[a] ) / 2 ), 100 - starty + ( a*15 ), menu_text[a], M_RED ); + } + } + if ( first == 1 ) + { + fadein( virbuff, pal ); first = 0; + } + memcpy( screen, virbuff, 64000 ); + while ( !k.state[94]&&!k.state[99]&&!k.state[28] ) + { + if ( clock() != oclock ) + { + oclock = clock(); + draw_ball( 55, 100 - starty + ( selected*15 ) - 2, cnt ); + draw_ball( 320 - 75, 100 - starty + ( selected*15 ) - 2, cnt ); + cnt ++; + if ( cnt > 23 ) cnt = 0; + } + }; + MIDASplaySample( samplep[KLIKWAV], MIDAS_CHANNEL_AUTO, 0, 22500, EFFECT_VOLUME, MIDAS_PAN_MIDDLE ); + if ( k.state[94] ) + { + selected --;if ( selected < 0 ) selected = Menu_texts - 1; k.state[94] = 0; + } + if ( k.state[99] ) + { + selected ++;if ( selected > Menu_texts - 1 ) selected = 0; k.state[99] = 0; + } + if ( k.state[28] ) + { + if ( selected == 0 ) + { + GAME_MODE = ONE_PLAYER; + KILLING_MODE = COOPERATIVE; + episode = choose_episode(); + game(); + menu_scr(); + } + if ( selected == 1 ) + { + multiplayer_options(); menu_scr(); + } + if ( selected == 2 ) + { + options(); menu_scr(); + } + if ( selected == 3 ) quit = 1; + } + } + fadeout( virbuff, pal ); +} + +void credits() +{ + cout << "\n"; + cout << " Thanks for playing --The Ultimate TK-- (Tapan Kaikki) ! \n"; + cout << "\n"; + cout << " Credits: \n"; + cout << "\n"; + cout << " Coding: Allu & Unski \n"; + cout << " Graphics: Allu \n"; + cout << " Music: Raipe, Allu & Unski \n"; + cout << " Sound effects: Allu (let's rip) \n"; + cout << " Episodes: Blanket & Allu \n"; + cout << " Thanks to - MIDAS sound system \n"; + cout << " - Vertigo for svga routines\n"; + cout << "\n"; + cout << " Also thanks to Janne Laitinen (game name), Niko Kotilainen & \n"; + cout << " all TK fans in the world ! \n"; + cout << "\n"; + cout << " Contact the Error Free Productions by e-mail: \n"; + cout << "\n"; + cout << " ef@tuusniemi.fi \n"; + cout << "\n"; + cout << " And visit the Error Free Productions homepage: \n"; + cout << "\n"; + cout << " http://www.tuusniemi.fi/~ef \n"; +} + +void logo() +{ + int a = 0, oclock; + load_efp( "efps\\eflogo.efp", picture, 0 ); + load_efp_pal( "efps\\eflogo.efp", pal ); + setpal( pal, 0 ); + memcpy( screen, picture, 64000 ); + oclock = clock(); + while ( a < 255 ) + if ( oclock!= clock() ) + { + oclock = clock(); + a += 10; + setpal( pal, a ); + } + while ( !k.kbhit() &&abs( oclock - clock() ) < 500 ) ; + while ( a > 0 ) + if ( oclock!= clock() ) + { + oclock = clock(); + a -= 10; + setpal( pal, a ); + } +} + +main( int argc, char *argv[] ) +{ + int a = 0, b; + int pause = 0; + for ( a = 1; a < argc; a ++ ) + { + strupr( argv[a] ); + if ( ( argv[a][0] == '-')||( argv[a][0] == '/')) + switch( argv[a][1] ) + { + case 'F':b = atoi( argv[ ++ a] ); + if ( b >= 30 &&b <= 500 ) target_frames = b; + break; + case 'L':b = atoi( argv[ ++ a] ); + if ( b > 0 ) START_LEVEL = b - 1; + break; + case 'P':pause = 1; + break; + case 'M':SHOW_ENEMIES = 1; + break; + case 'V':FORCE_0x13 = 1; + break; + case 'H':case '?': + cout << endl; + cout << "Ultimate Tapan Kaikki " << Version << endl; + cout << "Compiled at "<< __DATE__<< ' ' << __TIME__ << endl; + cout << "parameters:" << endl; + cout << "-?,-h this help"<< endl; + cout << "-v force mcga mode" << endl; + cout << "-p pause at startup" << endl; + cout << "-m show enemies on map" << endl; + cout << "-l ## start at level ##" << endl; + cout << "-f ## set gamespeed to ## fps (def. 40)" << endl; + cout << endl; + exit( 1 ); + break; + } + } + randomize(); + do_all(); + k.clear_stack(); + if ( pause ) k.getch(); + vesa_set_mode( 0x13 ); + // logo(); + menu(); + if ( ph ) MIDASstopModule( ph ); + vesa_set_mode( 0x3 ); + free_all(); +// credits(); +} + diff --git a/SRC/GAME.ERR b/SRC/GAME.ERR new file mode 100644 index 0000000..ceafeea --- /dev/null +++ b/SRC/GAME.ERR @@ -0,0 +1,4 @@ +GAME.CPP(1099): Warning! W389: (col 101) integral value may be truncated during assignment or initialization +GAME.CPP(1292): Warning! W389: (col 53) integral value may be truncated during assignment or initialization +GAME.CPP(1390): Warning! W014: (col 1) no reference to symbol 'b' +GAME.CPP(1390): Note! N392: (col 1) 'int b' in 'void server_add_player( char *, nodeaddr * )' defined in: GAME.CPP(1369) (col 15) diff --git a/SRC/GAME.OBJ b/SRC/GAME.OBJ new file mode 100644 index 0000000..3d91868 Binary files /dev/null and b/SRC/GAME.OBJ differ diff --git a/SRC/GLOBVAR.BAK b/SRC/GLOBVAR.BAK new file mode 100644 index 0000000..55a8950 --- /dev/null +++ b/SRC/GLOBVAR.BAK @@ -0,0 +1,431 @@ +#include "defines.h" +#include "ipxdefs.h" +#include "types.h" +#include "classes.h" +#include < time.h > +#include < keyb.hpp > +int BACK_TO_MENU = 0; +int VESA2 = 0, FORCE_0x13 = 0; +int scr_y_size = 200; +int ipxavail = 0; +int GAME_MODE = 0, NETWORK_MODE = CLIENT; +int KILLING_MODE = 0; +int SHOW_ENEMIES = 0; +int target_cost = 500;// t„ht„imen hinta +volatile unsigned framecount = 0; +int effect_age_count; +int dust_blocks[DUST_BLOCKS] = +{ + 0, + 16*4, + 16*5, + 16*5 + 2, + 16*6 + 1, + 16*6 + 1, + 16*6 + 2, + 16*7 + 1, + 16*7 + 2, + 16*7 + 3 +}; + +int Light_sizes[LIGHTS] = +{ + 15, 20, 25, 30, 35, 40, 45, 50, 55, 60 +}; + +int DARK_MODE = 1; +int LIGHT_EFFECTS = 1; +int SHADOWS = 1; +int SMOKE_EFFECTS = 1; +int sell_price[DIFF_WEAPONS + 2];// myyntihinnat muuttuvia +struct BLOCK *level; +char *see_level; +char cratespr[320*14]; +char shadowspr[320*20]; +char c4spr[8*8]; +char grenadespr[7*7]; +char targetspr[7*7]; +char floorspr[64000]; +char wallspr[64000]; +char floorspr2[64000]; +char rambospr[1160*667]; +char bodypartspr[320*20]; +char effectspr[320*82]; +char pal[256*3]; +char picture[64000]; +char warespr[64000]; +char enemyspr0[1160*232]; +char enemyspr1[1160*232]; +char enemyspr2[1160*232]; +char enemyspr3[1160*232]; +char enemyspr4[1160*232]; +char enemyspr5[1160*232]; +char enemyspr6[1160*232]; +char enemyspr7[1160*232]; +char minespr[7*7]; +char name1[10], name2[10]; +char trans_table[256][256]; +char shadow_table[256][16]; +char *menu_text[Menu_texts] = +{ + "single pl game", + "multiplayer game", + "options", + "exit to dos" +}; + +int saved_game_mode; +int saved_killing_mode; +int first = 0, all_dead = 0, quit = 0, MAP_ON = 0, next_level = 0, complete_time = 0; +char DEATH_MATCH_LEVEL[13]; +int DEATH_MATCH_EPISODE = 0; +int DEATH_MATCH_SPEED; +int episode = 0; +int EFFECT_VOLUME = 63; +int MUSIC_VOLUME = 63; +clock_t st, et; +int F_PER_SEC, OVER_POWER; +int START_LEVEL; +int LEVELS; +int Spot_amount; +int Steam_amount; +int Spot_count; +int Steam_count; +int level_x_size, level_y_size; +int pl_start_x[MAX_PLAYERS], pl_start_y[MAX_PLAYERS]; +int ACTIVE_PLAYERS; +int ENEMIES, LEVEL, DEAD_ENEMIES; +int ENEMIES_ON_GAME = 1; +int FRAMES_ON; +int target_frames = TARGET_FRAMES;// pelin p„ivitys nopeus +int delau = 10; +char *k_text[DIFF_K] = +{ + "walk forward", + "walk backward", + "turn c.clockw.", + "turn clockw.", + "fire", + "change weapon", + "strafe", + "strafe left", + "strafe right", + "back to menu" +}; + +struct special spec[SPEC_K] = +{ + 1, "esc", + 15, "tab", + 28, "enter", + 29, "left ctrl", + 90, "right ctrl", + 42, "left shift", + 54, "right shift", + 57, "space", + 58, "caps lock", + 56, "alt", + 92, "alt gr", + 93, "home", + 94, "arrow up", + 100, "page down", + 95, "page up", + 96, "arrow left", + 97, "arrow right", + 98, "end", + 99, "arrow down", + 101, "insert", + 102, "delete" +}; + +Effect_type effect_type[10]; +char virbuff[320*240]; +float sini[360], cosi[360]; +char *thefonts[10]; +int f_x_size[10], f_y_size[10]; +int FONT_NUM; +KeyboardHandler k; +Keys keys1, keys2; +Message_board message_board; +Player *aplayer[2]; +Player player[MAX_PLAYERS];// PLAYERS +Body_part body_part[MAX_BODY_PARTS]; +Enemy enemy[MAX_ENEMIES]; +Effect effect[MAX_EFFECTS]; +Bullet bullet[MAX_BULLETS]; +Spot spot_light[MAX_SPOTS]; +Steam steam[MAX_STEAM]; +Light light[LIGHTS]; +Light_table normal_l, red_l, yellow_l, explo_l; +General_level_info general_level_info; +Normal_game_level_info normal_game_level_info; +Death_match_level_info death_match_level_info; +Crate crate[MAX_CRATES]; +Crate_info normal_crate_info[MAX_CRATE_INFO]; +Crate_info deathmatch_crate_info[MAX_CRATE_INFO]; +int normal_crate_amount; +int deathmatch_crate_amount; +MIDASsample magnumwav, + shotgunwav, + pistolwav, + sinkowav, + hitwav, + explowav, + klikwav, + deathwav, + wooshwav, + flamewav; +MIDASmodule biisi[6]; +MIDASmodulePlayHandle ph; +int sample_rates[DIFF_WEAPONS + 1] = +{ + 10000, // nyrkki + 30000, + 13000, + 22000, + 16000, + 17000, + 18000, + 16000, + 15000, + 0, + 11025, + 0 +}; + +struct WEapon weapon[DIFF_WEAPONS + 1] = +{ + "fist", + 0, + 10, + 0, + 1, + 1, + 0, + 0, + &hitwav, + "Pistola", + 400, + 10, + 1, + 1, + 10, + 1, + 1, + &magnumwav, + "Shotgun", + 1000, + 17, + 1, + 6, + 20, + 1, + 3, + &shotgunwav, + "Uzi", + 2000, + 4, + 1, + 1, + 10, + 1, + 1, + &pistolwav, + "Auto rifle", + 4000, + 5, + 1, + 1, + 10, + 1, + 2, + &pistolwav, + "Grenade launcher", + 4000, + 30, + 0, + 1, + 10, + 1, + 5, + &sinkowav, + "Auto grenadier", + 6000, + 10, + 0, + 1, + 10, + 1, + 4, + &sinkowav, + "Heavy launcher", + 6000, + 40, + 0, + 1, + 10, + 1, + 6, + &sinkowav, + "Auto shotgun", + 6000, + 5, + 1, + 6, + 20, + 1, + 3, + &shotgunwav, + "C4-Activator", + 1000, + 10, + 0, + 1, + 1, + 0, + 7, + 0, + "Flame thrower", + 3000, + 1, + 0, + 1, + 10, + 1, + 8, + &flamewav, + "Mine dropper", + 1000, + 20, + 0, + 1, + 1, + 0, + 9, + 0 +}; + +Bullet_type bullet_type[DIFF_BULLETS + 2]; +struct s shield_data = +{ + "Shield", + 160, // muuta t„t„ shop.h:ssa + 15 +}; + +struct juu enemy_info[DIFF_ENEMIES] = +{ + "pistol boy", + enemyspr0, + 2, + 1, + 18, + 200, + 0, + "shotgun maniac", + enemyspr1, + 2, + 2, + 28, + 350, + 0, + "uzi rebel", + enemyspr2, + 2, + 3, + 40, + 400, + 0, + "commando", + enemyspr3, + 3, + 4, + 50, + 600, + 0, + "grenade gay", + enemyspr4, + 2, + 5, + 40, + 700, + 0, + "civilian", + enemyspr5, + 2, + 0, + 10, + 50, + 0, + "punisher", + enemyspr6, + 1, + 8, + 150, + 650, + 0, + "flamer", + enemyspr7, + 2, // speed + 10, // curr_weapon + 100, // energy + 600, // reward + 1 // explo_death +}; + +Level leveldata; +char player_opt_text[num_player_options][50] = +{ + "define keys 1", + "define keys 2", + "change pl1 name", + "change pl2 name", + "previous menu" +}; + +char game_opt_text[num_game_options][50] = +{ + "darkness", + "light effects", + "shadows", + "previous menu" +}; + +char sound_opt_text[num_sound_options][50] = +{ + "music volume", + "effects volume", + "previous menu" +}; + +char opt_text[num_options][50] = +{ + "player options", + "game options", + "sound options", + "previous menu" +}; + +char deathmatch_opt_text[num_deathmatch_options][50] = +{ + "start game", + "moving", + "enemies", + "previous menu" +}; + +char multip_opt_text[num_multip_options][50] = +{ + "start game", + "join game", + "episode", + "level", + "game type", + "game mode", + "previous menu" +}; + +vile filelist[256][1024]; +vile dirlist[256]; +int files_in_episode[256]; +int dirs = 0; diff --git a/SRC/GLOBVAR.CPP b/SRC/GLOBVAR.CPP new file mode 100644 index 0000000..5e3dcb2 --- /dev/null +++ b/SRC/GLOBVAR.CPP @@ -0,0 +1,424 @@ +#include "defines.h" +#include "ipxdefs.h" +#include "types.h" +#include "classes.h" +#include < time.h > +#include < keyb.hpp > +int BACK_TO_MENU = 0; +int VESA2 = 0, FORCE_0x13 = 0; +int scr_y_size = 200; +int ipxavail = 0; +int GAME_MODE = 0, NETWORK_MODE = CLIENT; +int KILLING_MODE = 0; +int SHOW_ENEMIES = 0; +int target_cost = 500;// t„ht„imen hinta +volatile unsigned framecount = 0; +int effect_age_count; +int dust_blocks[DUST_BLOCKS] = +{ + 0, + 16*4, + 16*5, + 16*5 + 2, + 16*6 + 1, + 16*6 + 1, + 16*6 + 2, + 16*7 + 1, + 16*7 + 2, + 16*7 + 3 +}; + +int Light_sizes[LIGHTS] = +{ + 15, 20, 25, 30, 35, 40, 45, 50, 55, 60 +}; + +int DARK_MODE = 1; +int LIGHT_EFFECTS = 1; +int SHADOWS = 1; +int SMOKE_EFFECTS = 1; +int sell_price[DIFF_WEAPONS + 2];// myyntihinnat muuttuvia +struct BLOCK *level; +char *see_level; +char cratespr[320*14]; +char shadowspr[320*20]; +char c4spr[8*8]; +char grenadespr[7*7]; +char targetspr[7*7]; +char floorspr[64000]; +char wallspr[64000]; +char floorspr2[64000]; +char rambospr[1160*667]; +char bodypartspr[320*20]; +char effectspr[320*82]; +char pal[256*3]; +char picture[64000]; +char warespr[64000]; +char enemyspr0[1160*232]; +char enemyspr1[1160*232]; +char enemyspr2[1160*232]; +char enemyspr3[1160*232]; +char enemyspr4[1160*232]; +char enemyspr5[1160*232]; +char enemyspr6[1160*232]; +char enemyspr7[1160*232]; +char minespr[7*7]; +char name1[10], name2[10]; +char trans_table[256][256]; +char shadow_table[256][16]; +char *menu_text[Menu_texts] = +{ + "single pl game", + "multiplayer game", + "options", + "exit to dos" +}; + +int saved_game_mode; +int saved_killing_mode; +int first = 0, all_dead = 0, quit = 0, MAP_ON = 0, next_level = 0, complete_time = 0; +char DEATH_MATCH_LEVEL[13]; +int DEATH_MATCH_EPISODE = 0; +int DEATH_MATCH_SPEED; +int episode = 0; +int EFFECT_VOLUME = 63; +int MUSIC_VOLUME = 63; +clock_t st, et; +int F_PER_SEC, OVER_POWER; +int START_LEVEL; +int LEVELS; +int Spot_amount; +int Steam_amount; +int Spot_count; +int Steam_count; +int level_x_size, level_y_size; +int pl_start_x[MAX_PLAYERS], pl_start_y[MAX_PLAYERS]; +int ACTIVE_PLAYERS; +int ENEMIES, LEVEL, DEAD_ENEMIES; +int ENEMIES_ON_GAME = 1; +int FRAMES_ON; +int target_frames = TARGET_FRAMES;// pelin p„ivitys nopeus +int delau = 10; +char *k_text[DIFF_K] = +{ + "walk forward", + "walk backward", + "turn c.clockw.", + "turn clockw.", + "fire", + "change weapon", + "strafe", + "strafe left", + "strafe right", + "back to menu" +}; + +struct special spec[SPEC_K] = +{ + 1, "esc", + 15, "tab", + 28, "enter", + 29, "left ctrl", + 90, "right ctrl", + 42, "left shift", + 54, "right shift", + 57, "space", + 58, "caps lock", + 56, "alt", + 92, "alt gr", + 93, "home", + 94, "arrow up", + 100, "page down", + 95, "page up", + 96, "arrow left", + 97, "arrow right", + 98, "end", + 99, "arrow down", + 101, "insert", + 102, "delete" +}; + +Effect_type effect_type[10]; +char virbuff[320*240]; +float sini[360], cosi[360]; +char *thefonts[10]; +int f_x_size[10], f_y_size[10]; +int FONT_NUM; +KeyboardHandler k; +Keys keys1, keys2; +Message_board message_board; +Player *aplayer[2]; +Player player[MAX_PLAYERS];// PLAYERS +Body_part body_part[MAX_BODY_PARTS]; +Enemy enemy[MAX_ENEMIES]; +Effect effect[MAX_EFFECTS]; +Bullet bullet[MAX_BULLETS]; +Spot spot_light[MAX_SPOTS]; +Steam steam[MAX_STEAM]; +Light light[LIGHTS]; +Light_table normal_l, red_l, yellow_l, explo_l; +General_level_info general_level_info; +Normal_game_level_info normal_game_level_info; +Death_match_level_info death_match_level_info; +Crate crate[MAX_CRATES]; +Crate_info normal_crate_info[MAX_CRATE_INFO]; +Crate_info deathmatch_crate_info[MAX_CRATE_INFO]; +int normal_crate_amount; +int deathmatch_crate_amount; + +MIDASsample samplep[DIFF_WAVS+1]; + +MIDASmodule biisi[6]; +MIDASmodulePlayHandle ph; +int sample_rates[DIFF_WEAPONS + 1] = +{ + 10000, // nyrkki + 30000, + 13000, + 22000, + 16000, + 17000, + 18000, + 16000, + 15000, + 0, + 11025, + 0 +}; + +struct WEapon weapon[DIFF_WEAPONS + 1] = +{ + "fist", + 0, + 10, + 0, + 1, + 1, + 0, + 0, + HITWAV, + "Pistola", + 400, + 10, + 1, + 1, + 10, + 1, + 1, + MAGNUMWAV, + "Shotgun", + 1000, + 17, + 1, + 6, + 20, + 1, + 3, + SHOTGUNWAV, + "Uzi", + 2000, + 4, + 1, + 1, + 10, + 1, + 1, + PISTOLWAV, + "Auto rifle", + 4000, + 5, + 1, + 1, + 10, + 1, + 2, + PISTOLWAV, + "Grenade launcher", + 4000, + 30, + 0, + 1, + 10, + 1, + 5, + SINKOWAV, + "Auto grenadier", + 6000, + 10, + 0, + 1, + 10, + 1, + 4, + SINKOWAV, + "Heavy launcher", + 6000, + 40, + 0, + 1, + 10, + 1, + 6, + SINKOWAV, + "Auto shotgun", + 6000, + 5, + 1, + 6, + 20, + 1, + 3, + SHOTGUNWAV, + "C4-Activator", + 1000, + 10, + 0, + 1, + 1, + 0, + 7, + 0, + "Flame thrower", + 3000, + 1, + 0, + 1, + 10, + 1, + 8, + FLAMEWAV, + "Mine dropper", + 1000, + 20, + 0, + 1, + 1, + 0, + 9, + 0 +}; + +Bullet_type bullet_type[DIFF_BULLETS + 2]; +struct s shield_data = +{ + "Shield", + 160, // muuta t„t„ shop.h:ssa + 15 +}; + +struct juu enemy_info[DIFF_ENEMIES] = +{ + "pistol boy", + enemyspr0, + 2, + 1, + 18, + 200, + 0, + "shotgun maniac", + enemyspr1, + 2, + 2, + 28, + 350, + 0, + "uzi rebel", + enemyspr2, + 2, + 3, + 40, + 400, + 0, + "commando", + enemyspr3, + 3, + 4, + 50, + 600, + 0, + "grenade gay", + enemyspr4, + 2, + 5, + 40, + 700, + 0, + "civilian", + enemyspr5, + 2, + 0, + 10, + 50, + 0, + "punisher", + enemyspr6, + 1, + 8, + 150, + 650, + 0, + "flamer", + enemyspr7, + 2, // speed + 10, // curr_weapon + 100, // energy + 600, // reward + 1 // explo_death +}; + +Level leveldata; +char player_opt_text[num_player_options][50] = +{ + "define keys 1", + "define keys 2", + "change pl1 name", + "change pl2 name", + "previous menu" +}; + +char game_opt_text[num_game_options][50] = +{ + "darkness", + "light effects", + "shadows", + "previous menu" +}; + +char sound_opt_text[num_sound_options][50] = +{ + "music volume", + "effects volume", + "previous menu" +}; + +char opt_text[num_options][50] = +{ + "player options", + "game options", + "sound options", + "previous menu" +}; + +char deathmatch_opt_text[num_deathmatch_options][50] = +{ + "start game", + "moving", + "enemies", + "previous menu" +}; + +char multip_opt_text[num_multip_options][50] = +{ + "start game", + "join game", + "episode", + "level", + "game type", + "game mode", + "previous menu" +}; + +vile filelist[256][1024]; +vile dirlist[256]; +int files_in_episode[256]; +int dirs = 0; diff --git a/SRC/GLOBVAR.H b/SRC/GLOBVAR.H new file mode 100644 index 0000000..afd91dc --- /dev/null +++ b/SRC/GLOBVAR.H @@ -0,0 +1,92 @@ +#ifndef __TK__GLOBVAR__ +#define __TK__GLOBVAR__ +#include < time.h > +#include < keyb.hpp > +#include "defines.h" +#include "ipxdefs.h" +#include "types.h" +#include "classes.h" +extern int saved_game_mode; +extern int saved_killing_mode; +extern int ipxavail; +extern int BACK_TO_MENU; +extern int VESA2, FORCE_0x13, scr_y_size, GAME_MODE, NETWORK_MODE; +extern int KILLING_MODE, SHOW_ENEMIES, target_cost;// t„ht„imen hinta +extern volatile unsigned framecount; +extern int effect_age_count; +extern int dust_blocks[]; +extern int Light_sizes[LIGHTS]; +extern int DARK_MODE, LIGHT_EFFECTS, SHADOWS, SMOKE_EFFECTS; +extern int sell_price[DIFF_WEAPONS + 2];// myyntihinnat muuttuvia +extern struct BLOCK *level; +extern char *see_level; +extern char cratespr[], shadowspr[], c4spr[], grenadespr[], targetspr[], floorspr[]; +extern char wallspr[], floorspr2[], rambospr[], bodypartspr[], effectspr[]; +extern char pal[], picture[], warespr[], enemyspr0[], enemyspr1[], enemyspr2[]; +extern char enemyspr3[], enemyspr4[], enemyspr5[], enemyspr6[], enemyspr7[], minespr[]; +extern char name1[10], name2[10]; +extern char trans_table[256][256]; +extern char shadow_table[256][16]; +extern char *menu_text[Menu_texts]; +extern int first, all_dead, quit, MAP_ON, next_level, complete_time; +extern char DEATH_MATCH_LEVEL[13]; +extern int DEATH_MATCH_EPISODE; +extern int DEATH_MATCH_SPEED; +extern int episode; +extern int EFFECT_VOLUME, MUSIC_VOLUME; +extern clock_t st, et; +extern int F_PER_SEC, OVER_POWER, START_LEVEL, LEVELS; +extern int Spot_amount, Steam_amount, Spot_count, Steam_count; +extern int level_x_size, level_y_size; +extern int pl_start_x[MAX_PLAYERS], pl_start_y[MAX_PLAYERS]; +extern int ACTIVE_PLAYERS, ENEMIES, LEVEL, DEAD_ENEMIES, ENEMIES_ON_GAME; +extern int FRAMES_ON, target_frames, delau; +extern char *k_text[DIFF_K]; +extern struct special spec[SPEC_K]; +extern Effect_type effect_type[10]; +extern char virbuff[]; +extern float sini[], cosi[]; +extern char *thefonts[10]; +extern int f_x_size[10], f_y_size[10]; +extern int FONT_NUM; +extern KeyboardHandler k; +extern Keys keys1, keys2; +extern Message_board message_board; +extern Player player[MAX_PLAYERS];// PLAYERS +extern Player *aplayer[2]; +extern Body_part body_part[MAX_BODY_PARTS]; +extern Enemy enemy[MAX_ENEMIES]; +extern Effect effect[MAX_EFFECTS]; +extern Bullet bullet[MAX_BULLETS]; +extern Spot spot_light[MAX_SPOTS]; +extern Steam steam[MAX_STEAM]; +extern Light light[LIGHTS]; +extern Light_table normal_l, red_l, yellow_l, explo_l; +extern General_level_info general_level_info; +extern Normal_game_level_info normal_game_level_info; +extern Death_match_level_info death_match_level_info; +extern Crate crate[MAX_CRATES]; +extern Crate_info normal_crate_info[MAX_CRATE_INFO]; +extern Crate_info deathmatch_crate_info[MAX_CRATE_INFO]; +extern int normal_crate_amount; +extern int deathmatch_crate_amount; +extern Bullet_type bullet_type[DIFF_BULLETS + 2]; +extern struct s shield_data; +extern struct WEapon weapon[DIFF_WEAPONS + 1]; +extern struct juu enemy_info[DIFF_ENEMIES]; +extern MIDASsample samplep[]; +extern MIDASmodule biisi[]; +extern MIDASmodulePlayHandle ph; +extern int sample_rates[DIFF_WEAPONS + 1]; +extern Level leveldata; +extern char player_opt_text[num_player_options][50]; +extern char game_opt_text[num_game_options][50]; +extern char sound_opt_text[num_sound_options][50]; +extern char opt_text[num_options][50]; +extern char deathmatch_opt_text[num_deathmatch_options][50]; +extern char multip_opt_text[num_multip_options][50]; +extern vile filelist[256][1024]; +extern vile dirlist[256]; +extern int files_in_episode[256]; +extern int dirs; +#endif diff --git a/SRC/GLOBVAR.OBJ b/SRC/GLOBVAR.OBJ new file mode 100644 index 0000000..5524c48 Binary files /dev/null and b/SRC/GLOBVAR.OBJ differ diff --git a/SRC/INT.OBJ b/SRC/INT.OBJ new file mode 100644 index 0000000..7761554 Binary files /dev/null and b/SRC/INT.OBJ differ diff --git a/SRC/INT/INT.ASM b/SRC/INT/INT.ASM new file mode 100644 index 0000000..a960850 --- /dev/null +++ b/SRC/INT/INT.ASM @@ -0,0 +1,104 @@ +; IPX EXAMPLE FOR WATCOM C/C++ (10.0a) UNDER DOS4GW PMODE DPMI. +; Written by Daniel Jeppson d94dj@efd.lth.se 960511 03:28 AM (8 + +; You are hearby granted the right to use this code freely but +; I would appreciate a credit or greet if you find it useful... + +; Please see the readme.txt and chat.c for more information... + + .386p + .model flat,c + locals + jumps + + ; Macros to Decrement Counter & Jump on Condition +LOOPx MACRO Register, Destination + DEC Register ; Counter-- + JNZ Destination ; Jump if not 0 +ENDM +LOOPjz MACRO Register, Destination + DEC Register ; Counter-- + JZ Destination ; Jump if 0 +ENDM + +PUSHALL MACRO ; Pushes all registers onto stack = 18c + PUSH EAX + PUSH EBX + PUSH ECX + PUSH EDX + PUSH ESI + PUSH EDI +ENDM + +POPALL MACRO ; Pops all registers from stack = 18c + POP EDI + POP ESI + POP EDX + POP ECX + POP EBX + POP EAX +ENDM + +POPALLSEGS MACRO + POP GS + POP FS + POP ES + POP DS +ENDM + +PUSHALLSEGS MACRO + PUSH DS + PUSH ES + PUSH FS + PUSH GS +ENDM + +SWAPPA MACRO Register ; Swaps low and high byte in a word... + ROL Register,8 +ENDM + + assume CS:_TEXT,DS:DGROUP + + dataseg + + global lseg:word + lseg DW 0 + global lsel:word + lsel DW 0 + + global getlowmem:PROC + global freelowmem:PROC + + codeseg + + getlowmem PROC ; Get low memory! (BX = paragraphs of memory) + PUSH EBX ; AX = segment to memory + PUSH ECX + PUSH EDX + PUSH ESI + PUSH EDI + MOV AX,0100h ; Get BX paragraphs of memory... + INT 31h ; (1 paragraph = 16 bytes) + MOV lseg,AX + MOV lsel,DX + ;XOR EAX,EAX + MOV AX,DX + POP EDI + POP ESI + POP EDX + POP ECX + POP EBX + RET + getlowmem ENDP + + freelowmem PROC ; Free low memory! (DX = selector) + PUSHALL + PUSHALLSEGS + MOV AX,0101h + INT 31h + POPALLSEGS + POPALL + RET + freelowmem ENDP + +END diff --git a/SRC/INT/INT.ERR b/SRC/INT/INT.ERR new file mode 100644 index 0000000..d967784 Binary files /dev/null and b/SRC/INT/INT.ERR differ diff --git a/SRC/INT/INT.H b/SRC/INT/INT.H new file mode 100644 index 0000000..26aace8 --- /dev/null +++ b/SRC/INT/INT.H @@ -0,0 +1,37 @@ +// IPX EXAMPLE FOR WATCOM C/C++ (10.0a) UNDER DOS4GW PMODE DPMI. +// Written by Daniel Jeppson d94dj@efd.lth.se 960511 03:28 AM (8 + +// You are hearby granted the right to use this code freely but +// I would appreciate a credit or greet if you find it useful... + +// Please see the readme.txt and chat.c for more information... + +#ifndef __INT_H_ +#define __INT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +unsigned short getlowmem(unsigned short size); +void freelowmem(unsigned short sel); + +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +extern unsigned short lseg; +extern unsigned short lsel; + +#ifdef __cplusplus +} +#endif + +#pragma aux getlowmem "_*" parm [EBX] caller; +#pragma aux freelowmem "_*" parm [EDX] caller; + +#endif diff --git a/SRC/INT/INT.OBJ b/SRC/INT/INT.OBJ new file mode 100644 index 0000000..7761554 Binary files /dev/null and b/SRC/INT/INT.OBJ differ diff --git a/SRC/IPX.OBJ b/SRC/IPX.OBJ new file mode 100644 index 0000000..4162d30 Binary files /dev/null and b/SRC/IPX.OBJ differ diff --git a/SRC/IPX/IPX.BAK b/SRC/IPX/IPX.BAK new file mode 100644 index 0000000..45f9b9d --- /dev/null +++ b/SRC/IPX/IPX.BAK @@ -0,0 +1,267 @@ +// IPX EgotoXAMPLE FOR WATCOM C/C++ (10.0a) UNDER DOS4GW PMODE DPMI. +// Written by Daniel Jeppson d94dj@efd.lth.se 960511 03:28 AM (8 + +// You are hearby granted the right to use this code freely but +// I would appreciate a credit or greet if you find it useful... + +// Please see the readme.txt and chat.c for more information... + +#define MAXNODES 1 // Maximum number of nodes + +#include +#include +#include +#include +#include "../error/error.h" +#include "ipx.h" // My ipx header file.. +#include "../int/int.h" + +struct nodeaddr nodes[MAXNODES+1]; // Last is broadcast and first is local... +dword socketid=0; + +static struct rminfo +{ + long EDI; + long ESI; + long EBP; + long reserved_by_system; + long EBX; + long EDX; + long ECX; + long EAX; + short flags; + short ES,DS,FS,GS,IP,CS,SP,SS; +} RMI; + +word localaddl=0; // Selector to the localadd lowmem allocated. +struct localaddr far *localadd=NULL; + +union REGS regs; +struct SREGS sregs; + +void clearrmi(void) +{ // Clear the RMI registers... + memset(&sregs,0,sizeof(sregs)); + memset(&RMI,0,sizeof(RMI)); +} + +void callrealint(byte inten) +{ // This routine calls a realmode interrupt (interrupt inten) + int interrupt_no=0x31; + + // Use DMPI call 300h to issue the DOS interrupt + regs.w.ax = 0x0300; + regs.h.bh = 0; + regs.h.bl = inten; + regs.w.cx = 0; + sregs.es = FP_SEG(&RMI); + regs.x.edi = FP_OFF(&RMI); + int386x( interrupt_no, ®s, ®s, &sregs ); +} + +int swap(int swappen) +{ // swap the low and high order byte of a word... + swappen&=0xffff; + return (swappen<<8)+((swappen&65280)>>8); +} + +int opensocket(byte longevity,word socket) +{ // Open up a socket.. Returns 0xff if everything went fine.. + + //Set up real-mode call structure + clearrmi(); + RMI.EBX=0x0; + RMI.EAX=longevity; + RMI.EDX=swap(socket); + callrealint(0x7a); + socketid=(word)swap(RMI.EDX); + + return (byte)(RMI.EAX); +} + +void closesocket(word socket) +{ // Closes an open socket.. Do not forget to call this routine!! + clearrmi(); + RMI.EBX=0x1; + RMI.EDX=swap(socket); + callrealint(0x7a); +} + +int initipx(void) +{ // Does what it is called... (8 + int q; + + clearrmi(); + RMI.EAX=0x7A00; + callrealint(0x2f); + if ((RMI.EAX&255)!=255) return(0); + + getlocaladdress(); + for (q=0;q<6;q++) + { + nodes[0].node[q]=localadd->node.node[q]; // HOME + nodes[MAXNODES].node[q]=0xff; // BROADCAST + } + return(1); +} + +struct nodeaddr BROADCAST() +{ + return nodes[MAXNODES]; +} + +void getlocaladdress(void) +{ + if (localadd==NULL) + { + localadd=(struct localaddr far *)MK_FP(getlowmem(sizeof(struct localaddr)/16+1),0); + localaddl=lsel; + }; + clearrmi(); + RMI.EBX=9; + RMI.ES=lseg; + RMI.ESI=0; + callrealint(0x7a); +} + +void listenforpacket(word packetseg) +{ + clearrmi(); + RMI.ESI=0; // Offset to ECB is 0 when you allocate lowmem... + RMI.ES=packetseg; + RMI.EBX=4; + RMI.EAX=0; + callrealint(0x7a); + if (RMI.EAX&255) error("Listenforpacket: failed!\n"); +} + +void cancelpacket(word packetseg) +{ + clearrmi(); + RMI.ESI=0; // Offset to ECB is 0 when you allocate lowmem... + RMI.ES=packetseg; + RMI.EBX=6; + RMI.EAX=0; + callrealint(0x7a); + if (RMI.EAX&255) error("Cancelpacket: failed!\n"); +} + +void initreceivepacket(struct packet far *packetet,word lseg) +{ + _fmemset(packetet,0,sizeof(struct packet)); + packetet->ecb.inuse=0x1d; + packetet->ecb.socket=(word)swap(socketid); + packetet->ecb.fragcount=1; + packetet->ecb.fragdata[0]=sizeof(struct ecbtype); + // fragdata[0] is the offset to the ipx header. + // Since ipx comes after ecb it's sizeof(ecb) bytes + // after the allocated memory... + + packetet->ecb.fragdata[1]=lseg; + // lseg contains the latest allocated lowmem segment. + + packetet->ecb.fragsize=sizeof(struct packet)-sizeof(struct ecbtype); +} + +void initsendpacket(struct packet far *packetet,word lseg) +{ + _fmemset(packetet,0,sizeof(struct packet)); + + packetet->ecb.socket=(word)swap(socketid); + packetet->ecb.fragcount=1; + packetet->ecb.fragdata[0]=sizeof(struct ecbtype); + packetet->ecb.fragdata[1]=lseg; + + packetet->ecb.immedaddr[0]=0xff; + packetet->ecb.immedaddr[1]=0xff; + packetet->ecb.immedaddr[2]=0xff; + packetet->ecb.immedaddr[3]=0xff; + packetet->ecb.immedaddr[4]=0xff; + packetet->ecb.immedaddr[5]=0xff; + packetet->ipx.dest.node.node[0]=0xff; + packetet->ipx.dest.node.node[1]=0xff; + packetet->ipx.dest.node.node[2]=0xff; + packetet->ipx.dest.node.node[3]=0xff; + packetet->ipx.dest.node.node[4]=0xff; + packetet->ipx.dest.node.node[5]=0xff; + + packetet->ipx.check=0xffff; + packetet->ipx.ptype=0x0; + packetet->ipx.tc=0x0; + packetet->ipx.dest.net[0]=localadd->network[0]; + packetet->ipx.dest.net[1]=localadd->network[1]; + packetet->ipx.dest.net[2]=localadd->network[2]; + packetet->ipx.dest.net[3]=localadd->network[3]; + packetet->ipx.dest.socket=(word)swap(socketid); + packetet->ipx.src.net[0]=localadd->network[0]; + packetet->ipx.src.net[1]=localadd->network[1]; + packetet->ipx.src.net[2]=localadd->network[2]; + packetet->ipx.src.net[3]=localadd->network[3]; + packetet->ipx.src.node.node[0]=localadd->node.node[0]; + packetet->ipx.src.node.node[1]=localadd->node.node[1]; + packetet->ipx.src.node.node[2]=localadd->node.node[2]; + packetet->ipx.src.node.node[3]=localadd->node.node[3]; + packetet->ipx.src.node.node[4]=localadd->node.node[4]; + packetet->ipx.src.node.node[5]=localadd->node.node[5]; + packetet->ipx.src.socket=(word)swap(socketid); +} + +void sendpacket(word ecbseg,struct nodeaddr destnode, struct packet far *packetet,word len) +{ // Sends a packet... + // ecbseg is the senders segment... + int q; + clearrmi(); + + for (q=0;q<6;q++) + packetet->ecb.immedaddr[q]=packetet->ipx.dest.node.node[q]=destnode.node[q]; + + if (len>MAXDATASIZE) len=MAXDATASIZE; + packetet->ecb.fragsize=(word)(sizeof(struct ipxheader)+len); + + RMI.ESI=0; + RMI.ES=ecbseg; + RMI.EBX=3; + callrealint(0x7a); + +/* if (RMI.EAX&255) error("sendpacket: sending failed (%x)\ncompletioncode: %d\ndestination: 0x%x%x%x%x%x%x\nfragsize: %d\nDatalen: %d\n", + RMI.EAX, + packetet->ecb.complete, + packetet->ecb.immedaddr[0], + packetet->ecb.immedaddr[1], + packetet->ecb.immedaddr[2], + packetet->ecb.immedaddr[3], + packetet->ecb.immedaddr[4], + packetet->ecb.immedaddr[5], + packetet->ecb.fragsize, + len); + */ +} + +void char2hex(char *str,char ch) +{ char hex[]="0123456789ABCDEF"; + str[0]=hex[ch>>4]; + str[1]=hex[ch&0xf]; +} + +char *decode_localaddress(char *str,struct localaddr far *la) +{ int a; + + for (a=0;a<4;a++) + char2hex(str+(a*2),la->network[a]); + str[8]=':'; + + for (a=0;a<6;a++) + char2hex(str+(a*2)+9,la->node.node[a]); + str[21]=0; + return(str); +} + +char *decode_address(char *str,struct netaddress far *la) +{ int a; + for (a=0;a<6;a++) + char2hex(str+(a*2),la->node.node[a]); + str[12]=0; + return(str); +} + + diff --git a/SRC/IPX/IPX.CPP b/SRC/IPX/IPX.CPP new file mode 100644 index 0000000..30941e8 --- /dev/null +++ b/SRC/IPX/IPX.CPP @@ -0,0 +1,267 @@ +// IPX EgotoXAMPLE FOR WATCOM C/C++ (10.0a) UNDER DOS4GW PMODE DPMI. +// Written by Daniel Jeppson d94dj@efd.lth.se 960511 03:28 AM (8 + +// You are hearby granted the right to use this code freely but +// I would appreciate a credit or greet if you find it useful... + +// Please see the readme.txt and chat.c for more information... + +#define MAXNODES 1 // Maximum number of nodes + +#include +#include +#include +#include +#include "../error/error.h" +#include "ipx.h" // My ipx header file.. +#include "../int/int.h" + +struct nodeaddr nodes[MAXNODES+1]; // Last is broadcast and first is local... +dword socketid=0; + +static struct rminfo +{ + long EDI; + long ESI; + long EBP; + long reserved_by_system; + long EBX; + long EDX; + long ECX; + long EAX; + short flags; + short ES,DS,FS,GS,IP,CS,SP,SS; +} RMI; + +word localaddl=0; // Selector to the localadd lowmem allocated. +struct localaddr far *localadd=NULL; + +union REGS regs; +struct SREGS sregs; + +void clearrmi(void) +{ // Clear the RMI registers... + memset(&sregs,0,sizeof(sregs)); + memset(&RMI,0,sizeof(RMI)); +} + +void callrealint(byte inten) +{ // This routine calls a realmode interrupt (interrupt inten) + int interrupt_no=0x31; + + // Use DMPI call 300h to issue the DOS interrupt + regs.w.ax = 0x0300; + regs.h.bh = 0; + regs.h.bl = inten; + regs.w.cx = 0; + sregs.es = FP_SEG(&RMI); + regs.x.edi = FP_OFF(&RMI); + int386x( interrupt_no, ®s, ®s, &sregs ); +} + +int swap(int swappen) +{ // swap the low and high order byte of a word... + swappen&=0xffff; + return (swappen<<8)+((swappen&65280)>>8); +} + +int opensocket(byte longevity,word socket) +{ // Open up a socket.. Returns 0xff if everything went fine.. + + //Set up real-mode call structure + clearrmi(); + RMI.EBX=0x0; + RMI.EAX=longevity; + RMI.EDX=swap(socket); + callrealint(0x7a); + socketid=(word)swap(RMI.EDX); + + return (byte)(RMI.EAX); +} + +void closesocket(word socket) +{ // Closes an open socket.. Do not forget to call this routine!! + clearrmi(); + RMI.EBX=0x1; + RMI.EDX=swap(socket); + callrealint(0x7a); +} + +int initipx(void) +{ // Does what it is called... (8 + int q; + + clearrmi(); + RMI.EAX=0x7A00; + callrealint(0x2f); + if ((RMI.EAX&255)!=255) return(0); + + getlocaladdress(); + for (q=0;q<6;q++) + { + nodes[0].node[q]=localadd->node.node[q]; // HOME + nodes[MAXNODES].node[q]=0xff; // BROADCAST + } + return(1); +} + +struct nodeaddr BROADCAST() +{ + return nodes[MAXNODES]; +} + +void getlocaladdress(void) +{ + if (localadd==NULL) + { + localadd=(struct localaddr far *)MK_FP(getlowmem(sizeof(struct localaddr)/16+1),0); + localaddl=lsel; + }; + clearrmi(); + RMI.EBX=9; + RMI.ES=lseg; + RMI.ESI=0; + callrealint(0x7a); +} + +void listenforpacket(word packetseg) +{ + clearrmi(); + RMI.ESI=0; // Offset to ECB is 0 when you allocate lowmem... + RMI.ES=packetseg; + RMI.EBX=4; + RMI.EAX=0; + callrealint(0x7a); + if (RMI.EAX&255) error("Listenforpacket: failed!\n"); +} + +void cancelpacket(word packetseg) +{ + clearrmi(); + RMI.ESI=0; // Offset to ECB is 0 when you allocate lowmem... + RMI.ES=packetseg; + RMI.EBX=6; + RMI.EAX=0; + callrealint(0x7a); + if (RMI.EAX&255) error("Cancelpacket: failed!\n"); +} + +void initreceivepacket(struct packet far *packetet,word lseg) +{ + _fmemset(packetet,0,sizeof(struct packet)); + packetet->ecb.inuse=0x1d; + packetet->ecb.socket=(word)swap(socketid); + packetet->ecb.fragcount=1; + packetet->ecb.fragdata[0]=sizeof(struct ecbtype); + // fragdata[0] is the offset to the ipx header. + // Since ipx comes after ecb it's sizeof(ecb) bytes + // after the allocated memory... + + packetet->ecb.fragdata[1]=lseg; + // lseg contains the latest allocated lowmem segment. + + packetet->ecb.fragsize=sizeof(struct packet)-sizeof(struct ecbtype); +} + +void initsendpacket(struct packet far *packetet,word lseg) +{ + _fmemset(packetet,0,sizeof(struct packet)); + + packetet->ecb.socket=(word)swap(socketid); + packetet->ecb.fragcount=1; + packetet->ecb.fragdata[0]=sizeof(struct ecbtype); + packetet->ecb.fragdata[1]=lseg; + + packetet->ecb.immedaddr[0]=0xff; + packetet->ecb.immedaddr[1]=0xff; + packetet->ecb.immedaddr[2]=0xff; + packetet->ecb.immedaddr[3]=0xff; + packetet->ecb.immedaddr[4]=0xff; + packetet->ecb.immedaddr[5]=0xff; + packetet->ipx.dest.node.node[0]=0xff; + packetet->ipx.dest.node.node[1]=0xff; + packetet->ipx.dest.node.node[2]=0xff; + packetet->ipx.dest.node.node[3]=0xff; + packetet->ipx.dest.node.node[4]=0xff; + packetet->ipx.dest.node.node[5]=0xff; + + packetet->ipx.check=0xffff; + packetet->ipx.ptype=0x0; + packetet->ipx.tc=0x0; + packetet->ipx.dest.net[0]=localadd->network[0]; + packetet->ipx.dest.net[1]=localadd->network[1]; + packetet->ipx.dest.net[2]=localadd->network[2]; + packetet->ipx.dest.net[3]=localadd->network[3]; + packetet->ipx.dest.socket=(word)swap(socketid); + packetet->ipx.src.net[0]=localadd->network[0]; + packetet->ipx.src.net[1]=localadd->network[1]; + packetet->ipx.src.net[2]=localadd->network[2]; + packetet->ipx.src.net[3]=localadd->network[3]; + packetet->ipx.src.node.node[0]=localadd->node.node[0]; + packetet->ipx.src.node.node[1]=localadd->node.node[1]; + packetet->ipx.src.node.node[2]=localadd->node.node[2]; + packetet->ipx.src.node.node[3]=localadd->node.node[3]; + packetet->ipx.src.node.node[4]=localadd->node.node[4]; + packetet->ipx.src.node.node[5]=localadd->node.node[5]; + packetet->ipx.src.socket=(word)swap(socketid); +} + +void sendpacket(word ecbseg,struct nodeaddr destnode, struct packet far *packetet,word len) +{ // Sends a packet... + // ecbseg is the senders segment... + int q; + clearrmi(); + + for (q=0;q<6;q++) + packetet->ecb.immedaddr[q]=packetet->ipx.dest.node.node[q]=destnode.node[q]; + + if (len>MAXDATASIZE) len=MAXDATASIZE; + packetet->ecb.fragsize=(word)(sizeof(struct ipxheader)+len); + + RMI.ESI=0; + RMI.ES=ecbseg; + RMI.EBX=3; + callrealint(0x7a); + + if (RMI.EAX&255) error("sendpacket: sending failed (%x)\ncompletioncode: %d\ndestination: 0x%x%x%x%x%x%x\nfragsize: %d\nDatalen: %d\n", + RMI.EAX, + packetet->ecb.complete, + packetet->ecb.immedaddr[0], + packetet->ecb.immedaddr[1], + packetet->ecb.immedaddr[2], + packetet->ecb.immedaddr[3], + packetet->ecb.immedaddr[4], + packetet->ecb.immedaddr[5], + packetet->ecb.fragsize, + len); + +} + +void char2hex(char *str,char ch) +{ char hex[]="0123456789ABCDEF"; + str[0]=hex[ch>>4]; + str[1]=hex[ch&0xf]; +} + +char *decode_localaddress(char *str,struct localaddr far *la) +{ int a; + + for (a=0;a<4;a++) + char2hex(str+(a*2),la->network[a]); + str[8]=':'; + + for (a=0;a<6;a++) + char2hex(str+(a*2)+9,la->node.node[a]); + str[21]=0; + return(str); +} + +char *decode_address(char *str,struct netaddress far *la) +{ int a; + for (a=0;a<6;a++) + char2hex(str+(a*2),la->node.node[a]); + str[12]=0; + return(str); +} + + diff --git a/SRC/IPX/IPX.H b/SRC/IPX/IPX.H new file mode 100644 index 0000000..4c5bb68 --- /dev/null +++ b/SRC/IPX/IPX.H @@ -0,0 +1,83 @@ +// IPX EXAMPLE FOR WATCOM C/C++ (10.0a) UNDER DOS4GW PMODE DPMI. +// Written by Daniel Jeppson d94dj@efd.lth.se 960511 03:28 AM (8 + +// You are hearby granted the right to use this code freely but +// I would appreciate a credit or greet if you find it useful... + +// Please see the readme.txt and chat.c for more information... + +#ifndef __IPX_H_ +#define __IPX_H_ + +#define byte unsigned char // commonly defined ever.. (8 +#define word unsigned short +#define dword unsigned long +#define MAXDATASIZE 1024 + +extern dword socketid; + +struct nodeaddr +{ + byte node[6]; +}; + +struct localaddr +{ + byte network[4]; + struct nodeaddr node; +}; + +struct ecbtype +{ + word link[2]; + word esr[2]; + byte inuse; + byte complete; + word socket; + byte ipxwork[4]; + byte dwork[12]; + byte immedaddr[6]; + word fragcount; + word fragdata[2]; + word fragsize; +}; + +struct netaddress +{ + byte net[4]; + struct nodeaddr node; + word socket; +}; + +struct ipxheader +{ + word check; + word length; + byte tc; + byte ptype; + struct netaddress dest; + struct netaddress src; +}; + +struct packet +{ + volatile struct ecbtype ecb; + struct ipxheader ipx; + char data[MAXDATASIZE]; +}; + +extern struct localaddr far *localadd; + +int opensocket(byte,word); +void closesocket(word); +int initipx(void); +void getlocaladdress(void); +void listenforpacket(word packetseg); +void cancelpacket(word packetseg); +char *decode_localaddress(char *str,struct localaddr far *la); +char *decode_address(char *str,struct netaddress far *la); +void sendpacket(word ecbseg,struct nodeaddr destnode, struct packet far *packetet,word len); +void initsendpacket(struct packet far *packetet,word lseg); +void initreceivepacket(struct packet far *packetet,word lseg); +struct nodeaddr BROADCAST(); +#endif diff --git a/SRC/IPX/IPX.OBJ b/SRC/IPX/IPX.OBJ new file mode 100644 index 0000000..450fa0f Binary files /dev/null and b/SRC/IPX/IPX.OBJ differ diff --git a/SRC/IPXDEFS.BAK b/SRC/IPXDEFS.BAK new file mode 100644 index 0000000..26bc85e --- /dev/null +++ b/SRC/IPXDEFS.BAK @@ -0,0 +1,33 @@ +#include "ipx\ipx.h" +#include "ipxdefs.h" +#include "classes.h" + +word SOCKET = 0x869C;// DOOM Socket +int IPXMSGLEN[] = +{ + 1, // END + 1, // SERVERSEARCH + 20, // TEXTMESSAGE (text) + 11, // SERVERANSWER (name) + 1, // SERVERSHUTDOWN + 1, // JOINREQUEST + 2, // JOINACCEPT (1/0) + 1, // SENDLEVELINFO + 3, // SENDLEVEL (short packetno) + 4+sizeof(General_level_info), // LEVELINFO + 0, // TRANSMITLEVEL + 0, // GAMEDATA + 0, // IMJOININGNOW + 10,// PLYXY + 5, // PLYRANGLE + 1, // ALIVE + 5, // PLYANIM + 2, // SENDCRATES + 0, // UPDCRATE + 0, // UPDKILLS + 0, // NEWBULLET + 0, // B””ning + 0 // messsssssaaaaaaaaaaage +}; + + diff --git a/SRC/IPXDEFS.CPP b/SRC/IPXDEFS.CPP new file mode 100644 index 0000000..fa85c8e --- /dev/null +++ b/SRC/IPXDEFS.CPP @@ -0,0 +1,34 @@ +#include "ipx\ipx.h" +#include "ipxdefs.h" +#include "classes.h" + +word SOCKET = 0x869C;// DOOM Socket +int IPXMSGLEN[] = +{ + 1, // END + 1, // SERVERSEARCH + 20, // TEXTMESSAGE (text) + 11, // SERVERANSWER (name) + 1, // SERVERSHUTDOWN + 1, // JOINREQUEST + 2, // JOINACCEPT (1/0) + 1, // SENDLEVELINFO + 3, // SENDLEVEL (short packetno) + 4+sizeof(General_level_info), // LEVELINFO + 0, // TRANSMITLEVEL + 0, // GAMEDATA + 0, // IMJOININGNOW + 10,// PLYXY + 5, // PLYRANGLE + 1, // ALIVE + 5, // PLYANIM + 2, // SENDCRATES + 0, // UPDCRATE + 0, // UPDKILLS + 0, // NEWBULLET + 0, // B””ning + 0, // messsssssaaaaaaaaaaage + 0 // saund +}; + + diff --git a/SRC/IPXDEFS.H b/SRC/IPXDEFS.H new file mode 100644 index 0000000..3c37eb9 --- /dev/null +++ b/SRC/IPXDEFS.H @@ -0,0 +1,37 @@ +#ifndef __IPX__DEFS__ +#define __IPX__DEFS__ + +#include "ipx\ipx.h" + +#define IPX_END 0 +#define IPX_SERVERSEARCH 1 +#define IPX_TEXTMESSAGE 2 +#define IPX_SERVERANSWER 3 +#define IPX_SERVERSHUTDOWN 4 +#define IPX_JOINREQUEST 5 +#define IPX_JOINACCEPT 6 +#define IPX_SENDLEVELINFO 7 +#define IPX_SENDLEVEL 8 +#define IPX_LEVELINFO 9 +#define IPX_TRANSMITLEVEL 10 +#define IPX_GAMEDATA 11 +#define IPX_IMJOININGNOW 12 +#define IPX_PLYXY 13 +#define IPX_PLYRANGLE 14 +#define IPX_ALIVE 15 +#define IPX_PLYANIM 16 +#define IPX_SENDCRATES 17 +#define IPX_UPDCRATE 18 +#define IPX_UPDKILLS 19 +#define IPX_NEWBULLET 20 +#define IPX_BURNING 21 +#define IPX_MESSAGE 22 +#define IPX_SOUND 23 + +#define SERVER 1 +#define CLIENT 0 +#define RECEIVERS 16 + +extern word SOCKET;// DOOM Socket +extern int IPXMSGLEN[]; +#endif diff --git a/SRC/IPXDEFS.OBJ b/SRC/IPXDEFS.OBJ new file mode 100644 index 0000000..e5c44a3 Binary files /dev/null and b/SRC/IPXDEFS.OBJ differ diff --git a/SRC/I_FUNCS.BAK b/SRC/I_FUNCS.BAK new file mode 100644 index 0000000..439abc8 --- /dev/null +++ b/SRC/I_FUNCS.BAK @@ -0,0 +1,158 @@ +void level_info() +{ + char text[20]; + int a, b; + load_efp( "efps\\cool.efp", picture, 0 ); + load_efp_pal( "efps\\ware.efp", pal ); + draw_box1( 10, 10, 10 + 100, 10 + 20, 10 ); + draw_box1( 10, 50, 310, 50 + 20, 10 ); + draw_box1( 10, 90, 160, 190, 10 ); + memcpy( virbuff, picture, 64000 ); + FONT_NUM = 0; + writefonts2( 16, 13, "level", 1 ); + itoa( LEVEL + 1, text, 10 ); + writefonts2( 71, 13, text, 1 ); + writefonts2( 160 - ( str_length( general_level_info.comment ) / 2 ), 13 + 40, general_level_info.comment, 1 ); + FONT_NUM = 1; + writefonts( 16, 96, "The killing list:", M_RED ); + for ( a = 0, b = 111; a < DIFF_ENEMIES; a ++ ) + if ( general_level_info.enemies[a] > 0 ) + { + itoa( general_level_info.enemies[a], text, 10 ); + strcat( text, " " ); + strcat( text, enemy_info[a].name ); + if ( general_level_info.enemies[a] > 1 ) + strcat( text, "s" ); + writefonts( 16, b, text, M_YELLOW ); + b += 8; + } + writefonts( 16, 173, "Your action time is:", M_RED ); + writefonts( 16 + 95, 173, c_2_c( general_level_info.time_limit*TIME_ADD ), M_YELLOW ); + fadein( virbuff, pal ); + k.clear_stack(); + if ( k.getch() == 27 ) if ( wanna_quit() ) BACK_TO_MENU = 1; + if ( !BACK_TO_MENU ) fadeout( virbuff, pal ); +} + +void statics() +{ + char text[20], text2[20]; + int a, b, timebonus; + load_efp( "efps\\cool.efp", picture, 0 ); + load_efp_pal( "efps\\ware.efp", pal ); + draw_box1( 10, 10, 310, 32, 10 ); + draw_box1( 10, 40, 310, 190, 10 ); + memcpy( virbuff, picture, 64000 ); + timebonus = ( ( general_level_info.time_limit*TIME_ADD ) - complete_time ) *5; + if ( timebonus < - 500 ) timebonus = - 500; + FONT_NUM = 0; + if ( next_level &&!quit ) + writefonts2( 160 - ( str_length( "completed !" ) / 2 ), 13, "completed !", 1 ); + if ( quit ||next_level == 0 ) + writefonts2( 160 - ( str_length( "game over" ) / 2 ), 13, "game over", 1 ); + FONT_NUM = 1; + for ( a = 0, b = 0; a < DIFF_ENEMIES; a ++ ) + if ( player[0].kills[a] > 0 ) b = 1; + if ( b == 1 ) + { + strcpy( text, "Kills for " ); + } + if ( b == 0 ) + { + strcpy( text, "No kills for " ); + } + strcat( text, player[0].name ); + writefonts( 16, 50, text, M_YELLOW ); + for ( a = 0, b = 65; a < DIFF_ENEMIES; a ++ ) + if ( player[0].kills[a] > 0 ) + { + player[0].total_kills += player[0].kills[a]; + itoa( player[0].kills[a], text, 10 ); + strcat( text, " " ); + strcat( text, enemy_info[a].name ); + if ( player[0].kills[a] > 1 ) + strcat( text, "s" ); + writefonts( 16, b, text, M_YELLOW ); + strcpy( text, "+" ); + itoa( enemy_info[a].reward*player[0].kills[a], text2, 10 ); + player[0].cash += enemy_info[a].reward*player[0].kills[a]; + strcat( text, text2 ); + writefonts( 103, b, text, M_RED ); + b += 8; + } + player[0].cash += timebonus; + if ( player[0].cash < 0 ) player[0].cash = 0; + writefonts( 16, 130, "Total kills:", M_RED ); + itoa( player[0].total_kills, text, 10 ); + writefonts( 76, 130, text, M_YELLOW ); + writefonts( 16, 140, "Accuracy:", M_RED ); + if ( player[0].shooted > 0 ) + itoa( ( ( float ) player[0].hitten / player[0].shooted ) *100, text, 10 ); + else strcpy( text, "0" ); + strcat( text, "%" ); + writefonts( 76, 140, text, M_YELLOW ); + writefonts( 16, 150, "Cash:", M_RED ); + itoa( player[0].cash, text, 10 ); + writefonts( 76, 150, text, M_YELLOW ); + if ( GAME_MODE == SPLIT_SCREEN ) + { + for ( a = 0, b = 0; a < DIFF_ENEMIES; a ++ ) + if ( player[1].kills[a] > 0 ) b = 1; + if ( b == 1 ) + { + strcpy( text, "Kills for " ); + } + if ( b == 0 ) + { + strcpy( text, "No kills for " ); + } + strcat( text, player[1].name ); + writefonts( 16 + 160, 50, text, M_YELLOW ); + for ( a = 0, b = 65; a < DIFF_ENEMIES; a ++ ) + if ( player[1].kills[a] > 0 ) + { + player[1].total_kills += player[1].kills[a]; + itoa( player[1].kills[a], text, 10 ); + strcat( text, " " ); + strcat( text, enemy_info[a].name ); + if ( player[1].kills[a] > 1 ) + strcat( text, "s" ); + writefonts( 16 + 160, b, text, M_YELLOW ); + strcpy( text, "+" ); + itoa( enemy_info[a].reward*player[1].kills[a], text2, 10 ); + player[1].cash += enemy_info[a].reward*player[1].kills[a]; + strcat( text, text2 ); + writefonts( 103 + 160, b, text, M_RED ); + b += 8; + } + player[1].cash += timebonus; + if ( player[1].cash < 0 ) player[1].cash = 0; + writefonts( 16 + 160, 130, "Total kills:", M_RED ); + itoa( player[1].total_kills, text, 10 ); + writefonts( 76 + 160, 130, text, M_YELLOW ); + writefonts( 16 + 160, 140, "Accuracy:", M_RED ); + if ( player[1].shooted > 0 ) + itoa( ( ( float ) player[1].hitten / player[1].shooted ) *100, text, 10 ); + else strcpy( text, "0" ); + strcat( text, "%" ); + writefonts( 76 + 160, 140, text, M_YELLOW ); + writefonts( 16 + 160, 150, "Cash:", M_RED ); + itoa( player[1].cash, text, 10 ); + writefonts( 76 + 160, 150, text, M_YELLOW ); + } + writefonts( 16, 170, "Time limit:", M_RED ); + writefonts( 16 + 55, 170, c_2_c( general_level_info.time_limit*TIME_ADD ), M_BLUE ); + writefonts( 16 + 80, 170, "Your time:", M_RED ); + writefonts( 16 + 80 + 55, 170, c_2_c( complete_time ), M_BLUE ); + writefonts( 16 + 80 + 80, 170, "Time bonus:", M_RED ); + itoa( timebonus, text, 10 ); + writefonts( 16 + 80 + 55 + 80, 170, text, M_YELLOW ); + fadein( virbuff, pal ); + k.clear_stack(); + if ( k.getch() == 27 ) if ( !quit ) + { + if ( wanna_quit() ) BACK_TO_MENU = 1; + } + if ( !BACK_TO_MENU ) fadeout( virbuff, pal ); +} + diff --git a/SRC/I_FUNCS.H b/SRC/I_FUNCS.H new file mode 100644 index 0000000..20eb121 --- /dev/null +++ b/SRC/I_FUNCS.H @@ -0,0 +1,158 @@ +void level_info() +{ + char text[20]; + int a, b; + load_efp( "efps\\cool.efp", picture, 0 ); + load_efp_pal( "efps\\ware.efp", pal ); + draw_box1( 10, 10, 10 + 100, 10 + 20, 10 ); + draw_box1( 10, 50, 310, 50 + 20, 10 ); + draw_box1( 10, 90, 160, 190, 10 ); + memcpy( virbuff, picture, 64000 ); + FONT_NUM = 0; + writefonts2( 16, 13, "level", 1 ); + itoa( LEVEL + 1, text, 10 ); + writefonts2( 71, 13, text, 1 ); + writefonts2( 160 - ( str_length( general_level_info.comment ) / 2 ), 13 + 40, general_level_info.comment, 1 ); + FONT_NUM = 1; + writefonts( 16, 96, "The killing list:", M_RED ); + for ( a = 0, b = 111; a < DIFF_ENEMIES; a ++ ) + if ( general_level_info.enemies[a] > 0 ) + { + itoa( general_level_info.enemies[a], text, 10 ); + strcat( text, " " ); + strcat( text, enemy_info[a].name ); + if ( general_level_info.enemies[a] > 1 ) + strcat( text, "s" ); + writefonts( 16, b, text, M_YELLOW ); + b += 8; + } + writefonts( 16, 173, "Your action time is:", M_RED ); + writefonts( 16 + 95, 173, c_2_c( general_level_info.time_limit*TIME_ADD ), M_YELLOW ); + fadein( virbuff, pal ); + k.clear_stack(); + if ( k.getch() == 27 ) if ( wanna_quit() ) BACK_TO_MENU = 1; + if ( !BACK_TO_MENU ) fadeout( virbuff, pal ); +} + +void statics() +{ + char text[20], text2[20]; + int a, b, timebonus; + load_efp( "efps\\cool.efp", picture, 0 ); + load_efp_pal( "efps\\ware.efp", pal ); + draw_box1( 10, 10, 310, 32, 10 ); + draw_box1( 10, 40, 310, 190, 10 ); + memcpy( virbuff, picture, 64000 ); + timebonus = ( ( general_level_info.time_limit*TIME_ADD ) - complete_time ) *5; + if ( timebonus < - 500 ) timebonus = - 500; + FONT_NUM = 0; + if ( next_level &&!quit ) + writefonts2( 160 - ( str_length( "completed !" ) / 2 ), 13, "completed !", 1 ); + if ( quit ||next_level == 0 ) + writefonts2( 160 - ( str_length( "game over" ) / 2 ), 13, "game over", 1 ); + FONT_NUM = 1; + for ( a = 0, b = 0; a < DIFF_ENEMIES; a ++ ) + if ( aplayer[0]->kills[a] > 0 ) b = 1; + if ( b == 1 ) + { + strcpy( text, "Kills for " ); + } + if ( b == 0 ) + { + strcpy( text, "No kills for " ); + } + strcat( text, aplayer[0]->name ); + writefonts( 16, 50, text, M_YELLOW ); + for ( a = 0, b = 65; a < DIFF_ENEMIES; a ++ ) + if ( aplayer[0]->kills[a] > 0 ) + { + aplayer[0]->total_kills += aplayer[0]->kills[a]; + itoa( aplayer[0]->kills[a], text, 10 ); + strcat( text, " " ); + strcat( text, enemy_info[a].name ); + if ( aplayer[0]->kills[a] > 1 ) + strcat( text, "s" ); + writefonts( 16, b, text, M_YELLOW ); + strcpy( text, "+" ); + itoa( enemy_info[a].reward*aplayer[0]->kills[a], text2, 10 ); + aplayer[0]->cash += enemy_info[a].reward*aplayer[0]->kills[a]; + strcat( text, text2 ); + writefonts( 103, b, text, M_RED ); + b += 8; + } + aplayer[0]->cash += timebonus; + if ( aplayer[0]->cash < 0 ) aplayer[0]->cash = 0; + writefonts( 16, 130, "Total kills:", M_RED ); + itoa( aplayer[0]->total_kills, text, 10 ); + writefonts( 76, 130, text, M_YELLOW ); + writefonts( 16, 140, "Accuracy:", M_RED ); + if ( aplayer[0]->shooted > 0 ) + itoa( ( ( float ) aplayer[0]->hitten / aplayer[0]->shooted ) *100, text, 10 ); + else strcpy( text, "0" ); + strcat( text, "%" ); + writefonts( 76, 140, text, M_YELLOW ); + writefonts( 16, 150, "Cash:", M_RED ); + itoa( aplayer[0]->cash, text, 10 ); + writefonts( 76, 150, text, M_YELLOW ); + if ( GAME_MODE == SPLIT_SCREEN ) + { + for ( a = 0, b = 0; a < DIFF_ENEMIES; a ++ ) + if ( aplayer[1]->kills[a] > 0 ) b = 1; + if ( b == 1 ) + { + strcpy( text, "Kills for " ); + } + if ( b == 0 ) + { + strcpy( text, "No kills for " ); + } + strcat( text, aplayer[1]->name ); + writefonts( 16 + 160, 50, text, M_YELLOW ); + for ( a = 0, b = 65; a < DIFF_ENEMIES; a ++ ) + if ( aplayer[1]->kills[a] > 0 ) + { + aplayer[1]->total_kills += aplayer[1]->kills[a]; + itoa( aplayer[1]->kills[a], text, 10 ); + strcat( text, " " ); + strcat( text, enemy_info[a].name ); + if ( aplayer[1]->kills[a] > 1 ) + strcat( text, "s" ); + writefonts( 16 + 160, b, text, M_YELLOW ); + strcpy( text, "+" ); + itoa( enemy_info[a].reward*aplayer[1]->kills[a], text2, 10 ); + aplayer[1]->cash += enemy_info[a].reward*aplayer[1]->kills[a]; + strcat( text, text2 ); + writefonts( 103 + 160, b, text, M_RED ); + b += 8; + } + aplayer[1]->cash += timebonus; + if ( aplayer[1]->cash < 0 ) aplayer[1]->cash = 0; + writefonts( 16 + 160, 130, "Total kills:", M_RED ); + itoa( aplayer[1]->total_kills, text, 10 ); + writefonts( 76 + 160, 130, text, M_YELLOW ); + writefonts( 16 + 160, 140, "Accuracy:", M_RED ); + if ( aplayer[1]->shooted > 0 ) + itoa( ( ( float ) aplayer[1]->hitten / aplayer[1]->shooted ) *100, text, 10 ); + else strcpy( text, "0" ); + strcat( text, "%" ); + writefonts( 76 + 160, 140, text, M_YELLOW ); + writefonts( 16 + 160, 150, "Cash:", M_RED ); + itoa( aplayer[1]->cash, text, 10 ); + writefonts( 76 + 160, 150, text, M_YELLOW ); + } + writefonts( 16, 170, "Time limit:", M_RED ); + writefonts( 16 + 55, 170, c_2_c( general_level_info.time_limit*TIME_ADD ), M_BLUE ); + writefonts( 16 + 80, 170, "Your time:", M_RED ); + writefonts( 16 + 80 + 55, 170, c_2_c( complete_time ), M_BLUE ); + writefonts( 16 + 80 + 80, 170, "Time bonus:", M_RED ); + itoa( timebonus, text, 10 ); + writefonts( 16 + 80 + 55 + 80, 170, text, M_YELLOW ); + fadein( virbuff, pal ); + k.clear_stack(); + if ( k.getch() == 27 ) if ( !quit ) + { + if ( wanna_quit() ) BACK_TO_MENU = 1; + } + if ( !BACK_TO_MENU ) fadeout( virbuff, pal ); +} + diff --git a/SRC/LINUXM~1 b/SRC/LINUXM~1 new file mode 100644 index 0000000..e81a700 --- /dev/null +++ b/SRC/LINUXM~1 @@ -0,0 +1,29 @@ +../game: game.o efp.o ipx.o error.o int.o rgbhsl.o globvar.o miscfunc.o fade.o draw.o write.o classes.o rout.o newfuncs.o options.o + ld game.o error.o efp.o ipx.o int.o rgbhsl.o globvar.o miscfunc.o draw.o fade.o write.o classes.o rout.o newfuncs.o options.o -o ../game + +options.o: options.cpp globvar.h types.h defines.h + gcc -O2 -c options.cpp -o options.o +newfuncs.o: newfuncs.cpp globvar.h types.h defines.h + gcc -O2 -c newfuncs.cpp +rout.o: rout.cpp globvar.h types.h defines.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c rout.cpp +classes.o: classes.cpp globvar.h types.h defines.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c classes.cpp +write.o: write.cpp globvar.h types.h defines.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c write.cpp +fade.o: fade.cpp globvar.h types.h defines.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c fade.cpp +draw.o: draw.cpp draw.h types.h globvar.h defines.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c draw.cpp +miscfunc.o: miscfunc.cpp miscfunc.h types.h globvar.h defines.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c miscfunc.cpp +globvar.o: globvar.cpp globvar.h defines.h types.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c globvar.cpp +rgbhsl.o: rgbhsl.c rgbhsl.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c rgbhsl.c +error.o: error/error.cpp error/error.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c error/error.cpp +game.o: game.cpp efp/efp.h error/error.h ipx/ipx.h defines.h types.h globvar.h miscfunc.h newfuncs.h options.h + gcc -O2 -c game.cpp +efp.o: efp/efp.cpp efp/efp.h error/error.h + wcl386 -oneatx -zp4 -5r -7 -fp5 -wx /c efp/efp.cpp diff --git a/SRC/MAKEFILE b/SRC/MAKEFILE new file mode 100644 index 0000000..eb27ed1 --- /dev/null +++ b/SRC/MAKEFILE @@ -0,0 +1,39 @@ +.ERASE +compopt= -oneatx -zp4 -5r -7 -fp5 -wx +cc= wcl386 -c + +all: ..\game.exe + +..\game.exe: game.obj efp.obj ipx.obj error.obj int.obj midas.lib rgbhsl.obj globvar.obj miscfunc.obj fade.obj draw.obj write.obj classes.obj rout.obj newfuncs.obj options.obj ipxdefs.obj + wlink @tk.lnk + +ipxdefs.obj: ipxdefs.cpp ipxdefs.h + $(cc) $(compopt) ipxdefs.cpp +options.obj: options.cpp globvar.h types.h defines.h + $(cc) $(compopt) options.cpp +newfuncs.obj: newfuncs.cpp globvar.h types.h defines.h + $(cc) $(compopt) newfuncs.cpp +rout.obj: rout.cpp globvar.h types.h defines.h + $(cc) $(compopt) rout.cpp +classes.obj: classes.cpp globvar.h types.h defines.h + $(cc) $(compopt) classes.cpp +write.obj: write.cpp globvar.h types.h defines.h + $(cc) $(compopt) write.cpp +fade.obj: fade.cpp globvar.h types.h defines.h + $(cc) $(compopt) fade.cpp +draw.obj: draw.cpp draw.h types.h globvar.h defines.h + $(cc) $(compopt) draw.cpp +miscfunc.obj: miscfunc.cpp miscfunc.h types.h globvar.h defines.h + $(cc) $(compopt) miscfunc.cpp +globvar.obj: globvar.cpp globvar.h defines.h types.h + $(cc) $(compopt) globvar.cpp +rgbhsl.obj: rgbhsl.c rgbhsl.h + $(cc) $(compopt) rgbhsl.c +error.obj: error\error.cpp error\error.h + $(cc) $(compopt) error\error.cpp +game.obj: game.cpp efp\efp.h error\error.h ipx/ipx.h defines.h types.h globvar.h miscfunc.h newfuncs.h options.h + $(cc) $(compopt) game.cpp +ipx.obj: ipx/ipx.cpp ipx/ipx.h int/int.h + $(cc) $(compopt) ipx\ipx.cpp +efp.obj: efp\efp.cpp efp\efp.h error\error.h + $(cc) $(compopt) efp\efp.cpp diff --git a/SRC/MAKET/MAKET.CPP b/SRC/MAKET/MAKET.CPP new file mode 100644 index 0000000..02963fb --- /dev/null +++ b/SRC/MAKET/MAKET.CPP @@ -0,0 +1,191 @@ +#include +#include +#include +#include +#include + +#include "efp.h" +#include "rgbhsl.h" + +class Light_table{ + public: + char data[256][16]; + void make(int R,int G,int B); + void make2(); +}; + +Light_table normal_l,red_l,yellow_l,explo_l; + +char pal[256*3]; +char trans_table[256][256]; +char shadow_table[256][16]; + +char get_closest(int re,int gr,int bl){ + int a,v,col,minv=1000; + char closest=0; + + for (a=0,col=0;a<256;a++,col+=3){ + v=abs(pal[col]-re)+abs(pal[col+1]-gr)+abs(pal[col+2]-bl); + if (v>1,(g1+g2)>>1,(b1+b2)>>1); +} + +} +} + +void do_shadow_table(){ +int a,z; +float r,g,b,h,s,l,e; + +for (a=0;a<256;a++){ +r=pal[a*3]; +g=pal[a*3+1]; +b=pal[a*3+2]; +rgb2hsl(r,g,b,&h,&s,&l); +e=l/16; +for (z=0;z<16;z++){ +l-=e/2.5; +if (l<0) l=0; +hsl2rgb(h,s,l,&r,&g,&b); +shadow_table[a][z]=get_closest(r,g,b); +} +} + +} + +void Light_table::make(int R,int G,int B){ + + int a,b; + float re,gr,bl,h,s,l; + + for (a=0;a<256;a++){ + + if (a%(16*3)==0) cout<<"."; + + re=pal[a*3]+R; + gr=pal[(a*3)+1]+G; + bl=pal[(a*3)+2]+B; + + if (re>63) re=63; + if (gr>63) gr=63; + if (bl>63) bl=63; + + if (re<0) re=0; + if (gr<0) gr=0; + if (bl<0) bl=0; + + rgb2hsl(re,gr,bl,&h,&s,&l); + for (b=0;b<16;b++){ + + if (R==0 && G==0 && B==0) + if (b>0) { + l+=((float)(b)/255)/2; + if (l>1) l=1; + hsl2rgb(h,s,l,&re,&gr,&bl); + } + + re+=R/2; + gr+=G/2; + bl+=B/2; + + if (re>63) re=63; + if (gr>63) gr=63; + if (bl>63) bl=63; + + if (re<0) re=0; + if (gr<0) gr=0; + if (bl<0) bl=0; + + data[a][b]=get_closest(re,gr,bl); + } + + } + +} + +void Light_table::make2(){ // explosive palette + + int a,b,re,gr,bl,ra,ga,ba; + + for (a=0;a<256;a++){ + + ra=20; + ga=0; + ba=0; + + re=pal[a*3]; + gr=pal[(a*3)+1]; + bl=pal[(a*3)+2]; + + for (b=0;b<16;b++){ + + if (b>1) { + if (b<9){ + ra+=1; + ga+=5; + ba+=1; + } + if (b>8) + ba+=5; + +// re=(pal[a*3]+ra)/2; +// gr=(pal[(a*3)+1]+ga)/2; +// bl=(pal[(a*3)+2]+ba)/2; + + re=(pal[a*3]+ra); + gr=(pal[(a*3)+1]+ga); + bl=(pal[(a*3)+2]+ba); + + } + + if (re>63) re=63; + if (gr>63) gr=63; + if (bl>63) bl=63; + + data[a][b]=get_closest(re,gr,bl); + } + + } +} + +void write_tables(){ +FILE *tab; +tab=fopen("palette.tab","wb"); +fwrite(&trans_table,sizeof(trans_table),1,tab); +fwrite(&shadow_table,sizeof(shadow_table),1,tab); +fwrite(&normal_l.data,sizeof(normal_l.data),1,tab); +fwrite(&red_l.data,sizeof(red_l.data),1,tab); +fwrite(&yellow_l.data,sizeof(yellow_l.data),1,tab); +fwrite(&explo_l.data,sizeof(explo_l.data),1,tab); +fclose(tab); +} + +main(){ + +load_efp_pal("efps\\walls1.efp",pal); +do_trans_table(); +do_shadow_table(); +normal_l.make(0,0,0); +red_l.make(5,0,0); +yellow_l.make(5,5,0); +explo_l.make2(); + +write_tables(); +} + diff --git a/SRC/MAKET/MAKET.EXE b/SRC/MAKET/MAKET.EXE new file mode 100644 index 0000000..2a042b3 Binary files /dev/null and b/SRC/MAKET/MAKET.EXE differ diff --git a/SRC/MAKET/MAKET.OBJ b/SRC/MAKET/MAKET.OBJ new file mode 100644 index 0000000..59f4a88 Binary files /dev/null and b/SRC/MAKET/MAKET.OBJ differ diff --git a/SRC/MAKET/PALETTE.TAB b/SRC/MAKET/PALETTE.TAB new file mode 100644 index 0000000..c685dc4 Binary files /dev/null and b/SRC/MAKET/PALETTE.TAB differ diff --git a/SRC/MIDAS.LIB b/SRC/MIDAS.LIB new file mode 100644 index 0000000..61ea7a3 Binary files /dev/null and b/SRC/MIDAS.LIB differ diff --git a/SRC/MISCFUNC.BAK b/SRC/MISCFUNC.BAK new file mode 100644 index 0000000..97472bf --- /dev/null +++ b/SRC/MISCFUNC.BAK @@ -0,0 +1,542 @@ +#include < stdlib.h > +#include < stdio.h > +#include < keyb.hpp > +#include < string.h > +#include < gfunc.h > +#include < dos.h > +#include "efp/efp.h" +#include "draw.h" +#include "globvar.h" +#include "fade.h" +#include "write.h" +#include "newfuncs.h" +#include "rout.h" + +void change_name( int num ) +{ + int x; + fadeout( virbuff, pal ); + load_efp( "efps\\cool.efp", picture, 0 ); + FONT_NUM = 0; + x = 160 - ( str_length( "enter your name" ) / 2 ); + draw_box1( x - 10, 75, 320 - x + 10, 125, 5 ); + memcpy( virbuff, picture, 64000 ); + writefonts2( x, 85, "enter your name", 1 ); + fadein( virbuff, pal ); + k.clear_stack(); + if ( num == 1 ) + readline( x, 100, 10, name1, screen ); + if ( num == 2 ) + readline( x, 100, 10, name2, screen ); + fadeout( virbuff, pal ); +} + +char *k_2_c( int key ) +{ + char *t, text[15]; + int a; + strset( text, 0 ); + text[0] = ( char ) k.tt.Non[key]; + for ( a = 0; a < SPEC_K; a ++ ) + if ( key == spec[a].num ) strcpy( text, spec[a].text ); + t = strdup( text ); + return( t ); +} + +int get_key( int x, int y ) +{ + int a = 0, key = 0, oclock = 0, cnt = 0, pressed = 0; + while ( !pressed ) + { + if ( clock() != oclock ) + { + oclock = clock(); + draw_ball( x, y, cnt ); + cnt ++; + if ( cnt > 23 ) cnt = 0; + } + for ( a = 0; a < 0x80 &&!pressed; a ++ ) + if ( a!= 42 ) + if ( k.state[a] ) + { + key = a; pressed = 1; + } + } + for ( a = 0; a < 0x80; a ++ ) + k.state[a] = 0; + return( key ); +} + +void clear_shit( int y ) +{ + int a; + for ( a = 0; a < 20; a ++ ) + memcpy( screen + ( ( y + a ) *320 ) + 20, picture + ( ( y + a ) *320 ) + 20, 20 ); + for ( a = 0; a < 8; a ++ ) + memcpy( screen + ( ( y + a + 3 ) *320 ) + 190, picture + ( ( y + a + 3 ) *320 ) + 190, 130 ); +} + +void set_keys() +{ + if ( GAME_MODE != SPLIT_SCREEN ) + { + aplayer[0]->K_LEFT = keys1.K_LEFT; + aplayer[0]->K_RIGHT = keys1.K_RIGHT; + aplayer[0]->K_UP = keys1.K_UP; + aplayer[0]->K_DOWN = keys1.K_DOWN; + aplayer[0]->K_SHOOT = keys1.K_SHOOT; + aplayer[0]->K_SHIFT = keys1.K_SHIFT; + aplayer[0]->K_STRAFE = keys1.K_STRAFE; + aplayer[0]->K_LSTRAFE = keys1.K_LSTRAFE; + aplayer[0]->K_RSTRAFE = keys1.K_RSTRAFE; + } + else + { + aplayer[0]->K_LEFT = keys2.K_LEFT; + aplayer[0]->K_RIGHT = keys2.K_RIGHT; + aplayer[0]->K_UP = keys2.K_UP; + aplayer[0]->K_DOWN = keys2.K_DOWN; + aplayer[0]->K_SHOOT = keys2.K_SHOOT; + aplayer[0]->K_SHIFT = keys2.K_SHIFT; + aplayer[0]->K_STRAFE = keys2.K_STRAFE; + aplayer[0]->K_RSTRAFE = keys2.K_RSTRAFE; + aplayer[0]->K_LSTRAFE = keys2.K_LSTRAFE; + aplayer[1]->K_LEFT = keys1.K_LEFT; + aplayer[1]->K_RIGHT = keys1.K_RIGHT; + aplayer[1]->K_UP = keys1.K_UP; + aplayer[1]->K_DOWN = keys1.K_DOWN; + aplayer[1]->K_SHOOT = keys1.K_SHOOT; + aplayer[1]->K_SHIFT = keys1.K_SHIFT; + aplayer[1]->K_STRAFE = keys1.K_STRAFE; + aplayer[1]->K_RSTRAFE = keys1.K_RSTRAFE; + aplayer[1]->K_LSTRAFE = keys1.K_LSTRAFE; + } +} + +void alusta_client() +{ + int a; + + aplayer[0]->TARGET = 0; + aplayer[0]->shooted = 0; + aplayer[0]->hitten = 0; + aplayer[0]->curr_weapon = 0; + aplayer[0]->KICK = 0; + aplayer[0]->HIT = 0; +// aplayer[0]->move( 0, 0, 0 ); + aplayer[0]->move_scr(); + aplayer[0]->load_cnt = 0; + aplayer[0]->max_energy = 100; + for ( a = 0; a < DIFF_WEAPONS + 1; a ++ ) aplayer[0]->weapons[a] = 0; + for ( a = 0; a < DIFF_BULLETS ; a ++ ) aplayer[0]->bullets[a] = 0; + aplayer[0]->weapons[0] = 1; + if (KILLING_MODE==DEATHMATCH) + { + aplayer[0]->shield = 30; + aplayer[0]->energy = ( aplayer[0]->max_energy + ( aplayer[0]->shield*10 ) ) / 3; + } else { + aplayer[0]->shield = 0; + } +} + +void alusta_players1() +{ + int a, b; + strcpy( aplayer[0]->name, name1 ); + if (ACTIVE_PLAYERS==2) + strcpy( aplayer[1]->name, name2 ); + aplayer[0]->color = 16*3; + if (ACTIVE_PLAYERS==2) + aplayer[1]->color = 16*9; + for ( b = 0; b < ACTIVE_PLAYERS; b ++ ) + { + aplayer[b]->enabled=1; + aplayer[b]->cash = 900; + aplayer[b]->total_kills = 0; + aplayer[b]->TARGET = 0; + if ( KILLING_MODE!= DEATHMATCH ) aplayer[b]->shield = 0; + else aplayer[b]->shield = 30; + aplayer[b]->DEAD = 0; + if ( KILLING_MODE!= DEATHMATCH ) aplayer[b]->speed = 2;else aplayer[b]->speed = DEATH_MATCH_SPEED; + aplayer[b]->max_energy = 100; + for ( a = 0; a < DIFF_WEAPONS + 1; a ++ ) aplayer[b]->weapons[a] = 0; + for ( a = 0; a < DIFF_BULLETS; a ++ ) aplayer[b]->bullets[a] = 0; + aplayer[b]->weapons[0] = 1; + if ( KILLING_MODE!= DEATHMATCH ) + aplayer[b]->bullets[0] = 10; + } + if ( !strcmp( aplayer[0]->name, "iron" ) ) aplayer[0]->cash = 50000; + if (ACTIVE_PLAYERS==2) + if ( !strcmp( aplayer[1]->name, "maiden" ) ) aplayer[1]->cash = 50000; +} + +void alusta_players2() +{ + int a, b; + for ( b = 0; b < ACTIVE_PLAYERS; b ++ ) + { + aplayer[b]->PUSH_POWER = 0; + aplayer[b]->x = ( pl_start_x[b]*20 ); + aplayer[b]->y = ( pl_start_y[b]*20 ); + aplayer[b]->burning = 0; + aplayer[b]->shooted = 0; + aplayer[b]->hitten = 0; + aplayer[b]->player_kills = 0; + aplayer[b]->curr_weapon = 0; + aplayer[b]->KICK = 0; + aplayer[b]->HIT = 0; + aplayer[b]->move( 0, 0, 0 ); + aplayer[b]->move_scr(); + aplayer[b]->load_cnt = 0; + if ( KILLING_MODE!= DEATHMATCH ) aplayer[b]->energy = aplayer[b]->max_energy + ( aplayer[b]->shield*10 ); + else aplayer[b]->energy = ( aplayer[b]->max_energy + ( aplayer[b]->shield*10 ) ) / 2; + for ( a = 0; a < DIFF_ENEMIES; a ++ ) + aplayer[b]->kills[a] = 0; + } +} + +void two_to_one() +{ + if (aplayer[0]->DEAD || aplayer[1]->DEAD){ + ACTIVE_PLAYERS=1; + GAME_MODE = ONE_PLAYER; + if (aplayer[0]->DEAD) {aplayer[0]->enabled=0;aplayer[0]=aplayer[1];} + else aplayer[1]->enabled=0; + } + +} + +void define_bullet_types() +{ + strcpy( bullet_type[0].name, "fist" ); + bullet_type[0].type = NORMAL; + bullet_type[0].stop = 1; + bullet_type[0].speed = 5; + bullet_type[0].power = 3; + bullet_type[0].push_power = 3; + bullet_type[0].time = 1; + bullet_type[0].sprite = 0; + bullet_type[0].light = 0; + bullet_type[0].effect = 0; + bullet_type[0].mul = 1; + bullet_type[0].sleep_time = 0; + strcpy( bullet_type[1].name, "9mm bullets" ); + bullet_type[1].type = NORMAL; + bullet_type[1].stop = 1; + bullet_type[1].speed = 6*18; + bullet_type[1].power = 5; + bullet_type[1].push_power = 2; + bullet_type[1].time = 1; + bullet_type[1].sprite = 0; + bullet_type[1].light = 0; + bullet_type[1].effect = 0; + bullet_type[1].cost = 3; + bullet_type[1].amount_in_crate = 50; + bullet_type[1].mul = 1; + bullet_type[1].sleep_time = 0; + bullet_type[1].max = 300; + strcpy( bullet_type[2].name, "12mm bullets" ); + bullet_type[2].type = NORMAL; + bullet_type[2].stop = 1; + bullet_type[2].speed = 7*18; + bullet_type[2].power = 9; + bullet_type[2].push_power = 2; + bullet_type[2].time = 1; + bullet_type[2].sprite = 0; + bullet_type[2].light = 0; + bullet_type[2].effect = 0; + bullet_type[2].cost = 5; + bullet_type[2].amount_in_crate = 50; + bullet_type[2].mul = 1; + bullet_type[2].sleep_time = 0; + bullet_type[2].max = 300; + strcpy( bullet_type[3].name, "shotgun shells" ); + bullet_type[3].type = NORMAL; + bullet_type[3].stop = 1; + bullet_type[3].speed = 6*18; + bullet_type[3].power = 3; + bullet_type[3].push_power = 3; + bullet_type[3].time = 1; + bullet_type[3].sprite = 0; + bullet_type[3].light = 0; + bullet_type[3].effect = 0; + bullet_type[3].cost = 6; + bullet_type[3].amount_in_crate = 20; + bullet_type[3].mul = 1; + bullet_type[3].sleep_time = 0; + bullet_type[3].max = 300; + strcpy( bullet_type[4].name, "light grenades" ); + bullet_type[4].type = EXPLOSIVE; + bullet_type[4].stop = 1; + bullet_type[4].speed = 8; + bullet_type[4].power = 0; + bullet_type[4].push_power = 0; + bullet_type[4].time = ( 15*18 ) / 8; + bullet_type[4].explos = 1; + bullet_type[4].sprite = grenadespr; + bullet_type[4].xs = 7; + bullet_type[4].ys = 7; + bullet_type[4].xsize = 7; + bullet_type[4].offs = 0; + bullet_type[4].light = &normal_l; + bullet_type[4].lsize = 3; + bullet_type[4].llum = 0; + bullet_type[4].ladd = 0; + bullet_type[4].effect = SMOKE2; + bullet_type[4].cost = 70; + bullet_type[4].amount_in_crate = 15; + bullet_type[4].mul = 1; + bullet_type[4].sleep_time = 0; + bullet_type[4].max = 150; + strcpy( bullet_type[5].name, "medium grenades" ); + bullet_type[5].type = EXPLOSIVE; + bullet_type[5].stop = 1; + bullet_type[5].speed = 8; + bullet_type[5].power = 0; + bullet_type[5].push_power = 0; + bullet_type[5].time = ( 15*18 ) / 8; + bullet_type[5].explos = 2; + bullet_type[5].sprite = grenadespr; + bullet_type[5].xs = 7; + bullet_type[5].ys = 7; + bullet_type[5].xsize = 7; + bullet_type[5].offs = 0; + bullet_type[5].light = &normal_l; + bullet_type[5].lsize = 3; + bullet_type[5].llum = 0; + bullet_type[5].ladd = 0; + bullet_type[5].effect = SMOKE2; + bullet_type[5].cost = 100; + bullet_type[5].amount_in_crate = 10; + bullet_type[5].mul = 1; + bullet_type[5].sleep_time = 0; + bullet_type[5].max = 125; + strcpy( bullet_type[6].name, "heavy grenades" ); + bullet_type[6].type = EXPLOSIVE; + bullet_type[6].stop = 1; + bullet_type[6].speed = 8; + bullet_type[6].power = 0; + bullet_type[6].push_power = 0; + bullet_type[6].time = ( 15*18 ) / 8; + bullet_type[6].explos = 4; + bullet_type[6].sprite = grenadespr; + bullet_type[6].xs = 7; + bullet_type[6].ys = 7; + bullet_type[6].xsize = 7; + bullet_type[6].offs = 0; + bullet_type[6].light = &normal_l; + bullet_type[6].lsize = 4; + bullet_type[6].llum = 0; + bullet_type[6].ladd = 0; + bullet_type[6].effect = SMOKE2; + bullet_type[6].cost = 200; + bullet_type[6].amount_in_crate = 5; + bullet_type[6].mul = 1; + bullet_type[6].sleep_time = 0; + bullet_type[6].max = 100; + strcpy( bullet_type[7].name, "C4-explosives" ); + bullet_type[7].type = EXPLOSIVE; + bullet_type[7].stop = 0; + bullet_type[7].speed = 0; + bullet_type[7].power = 0; + bullet_type[7].push_power = 0; + bullet_type[7].time = 100; + bullet_type[7].explos = 4; + bullet_type[7].sprite = c4spr; + bullet_type[7].xs = 8; + bullet_type[7].ys = 8; + bullet_type[7].xsize = 8; + bullet_type[7].offs = 0; + bullet_type[7].light = 0; + bullet_type[7].lsize = 0; + bullet_type[7].effect = 0; + bullet_type[7].cost = 150; + bullet_type[7].amount_in_crate = 5; + bullet_type[7].mul = 1; + bullet_type[7].sleep_time = 0; + bullet_type[7].max = 100; + strcpy( bullet_type[8].name, "Gas" ); + bullet_type[8].type = INCENDIARY; + bullet_type[8].stop = 1; + bullet_type[8].speed = 5; + bullet_type[8].power = 0.4; + bullet_type[8].push_power = 0; + bullet_type[8].time = ( 5*18 ) / 5; + bullet_type[8].explos = 0; + bullet_type[8].sprite = 0; + bullet_type[8].light = &explo_l; + bullet_type[8].lsize = 2; + bullet_type[8].llum = - 10; + bullet_type[8].ladd = 0.7; + bullet_type[8].effect = 0; + bullet_type[8].cost = 6; + bullet_type[8].amount_in_crate = 500;// div mul = 50 + bullet_type[8].mul = 10; + bullet_type[8].sleep_time = 0; + bullet_type[8].max = 300; + strcpy( bullet_type[9].name, "Mines" ); + bullet_type[9].type = EXPLOSIVE; + bullet_type[9].stop = 1; + bullet_type[9].speed = 0; + bullet_type[9].power = 0; + bullet_type[9].push_power = 0; + bullet_type[9].time = 2000; + bullet_type[9].explos = 1; + bullet_type[9].sprite = minespr; + bullet_type[9].xs = 7; + bullet_type[9].ys = 7; + bullet_type[9].xsize = 7; + bullet_type[9].offs = 0; + bullet_type[9].light = 0; + bullet_type[9].lsize = 0; + bullet_type[9].effect = 0; + bullet_type[9].cost = 150; + bullet_type[9].amount_in_crate = 5; + bullet_type[9].mul = 1; + bullet_type[9].sleep_time = 25; + bullet_type[9].max = 100; + strcpy( bullet_type[10].name, "Explosive ray" ); + bullet_type[10].type = NORMAL; + bullet_type[10].stop = 1; + bullet_type[10].speed = 20; + bullet_type[10].power = 30; + bullet_type[10].push_power = 8; + bullet_type[10].time = 0; // define in new_bullet() + bullet_type[10].sprite = 0; + bullet_type[10].effect = EXPLO; + bullet_type[10].mul = 1; + bullet_type[10].sleep_time = 0; +} + +void define_effects() +{ + effect_type[0].index = 0; + effect_type[0].tcount = 4; + effect_type[0].order = 1; + effect_type[0].delay = 2; + effect_type[0].random = 0; + effect_type[0].xs = 12; + effect_type[0].ys = 12; + effect_type[0].offs = 0; + effect_type[1].index = 1; + effect_type[1].tcount = 4; + effect_type[1].order = 0; + effect_type[1].delay = 2; + effect_type[1].random = 0; + effect_type[1].xs = 12; + effect_type[1].ys = 12; + effect_type[1].offs = 13*4; + effect_type[2].index = 2; + effect_type[2].tcount = 9; + effect_type[2].order = 1; + effect_type[2].delay = 2; + effect_type[2].random = 0; + effect_type[2].xs = 25; + effect_type[2].ys = 25; + effect_type[2].offs = 320*13; + effect_type[3].index = 3; + effect_type[3].tcount = 8; + effect_type[3].order = 1; + effect_type[3].delay = 2; + effect_type[3].random = 0; + effect_type[3].xs = 12; + effect_type[3].ys = 12; + effect_type[3].offs = 13*8; + effect_type[4].index = 4; + effect_type[4].tcount = 12; + effect_type[4].order = 1; + effect_type[4].delay = 5; + effect_type[4].random = 1; + effect_type[4].xs = 20; + effect_type[4].ys = 20; + effect_type[4].offs = 320*39; + effect_type[5].index = 5; + effect_type[5].tcount = 8; + effect_type[5].order = 0; + effect_type[5].delay = 20; + effect_type[5].random = 1; + effect_type[5].xs = 6; + effect_type[5].ys = 6; + effect_type[5].offs = 13*20; + effect_type[6].index = 6; + effect_type[6].tcount = 4; + effect_type[6].order = 1; + effect_type[6].delay = 2; + effect_type[6].random = 0; + effect_type[6].xs = 12; + effect_type[6].ys = 12; + effect_type[6].offs = 13*16; + effect_type[7].index = 7; + effect_type[7].tcount = 12; + effect_type[7].order = 1; + effect_type[7].delay = 2; + effect_type[7].random = 0; + effect_type[7].xs = 20; + effect_type[7].ys = 20; + effect_type[7].offs = 320*39; + effect_type[8].index = 8; + effect_type[8].tcount = 7; + effect_type[8].order = 1; + effect_type[8].delay = 2; + effect_type[8].random = 0; + effect_type[8].xs = 20; + effect_type[8].ys = 20; + effect_type[8].offs = 320*60; + effect_type[9].index = 9; + effect_type[9].tcount = 4; + effect_type[9].order = 0; + effect_type[9].delay = 50; + effect_type[9].random = 1; + effect_type[9].xs = 6; + effect_type[9].ys = 6; + effect_type[9].offs = ( 13*20 ) + ( 320*7 ); +} + +void explo( int x, int y, int size, int index ) +{ + int a, rays, pan = 0; + rays = size*5; + for ( a = 0; a < rays; a ++ ) + new_bullet( EXPLO_RAY, x, y, a*( float ) ( 360 / rays ), size,index); + for ( a = 0; a < ( rand() % 5 ) + 1; a ++ ) + if ( rand() % 2 ) + new_effect( &yellow_l, METAL, x, y, rand() % 360, ( rand() % 3 ) + 4 ); + else + new_effect( &red_l, METAL, x, y, rand() % 360, ( rand() % 3 ) + 4 ); + + if (GAME_MODE!=SPLIT_SCREEN) + MIDASplaySample( samplep[EXPLOWAV], MIDAS_CHANNEL_AUTO, 0, 14000 - ( size*1000 ), get_volume(aplayer[0]->x,aplayer[0]->y,x,y), get_pan(aplayer[0]->x,x)); + else + MIDASplaySample( samplep[EXPLOWAV], MIDAS_CHANNEL_AUTO, 0, 14000 - ( size*1000 ), EFFECT_VOLUME, 0 ); +} + +void list_files( int *no, vile *filelist, char *wildcard, int type ) +{ + struct find_t fbuf; + int er; + er = _dos_findfirst( wildcard, type, &fbuf ); + while ( er == 0 ) + { + if ( ( fbuf.attrib&type ) == type ) + { + if ( strcmp( fbuf.name, "." ) &&strcmp( fbuf.name, ".." ) ) + { + strcpy( filelist[*no].name, fbuf.name ); + ( *no ) ++; + } + } + er = _dos_findnext( &fbuf ); + } + _dos_findclose( &fbuf ); +} + +void set_keyb_rate() +{ + union REGS inregs; + inregs.h.ah = 0x03; + inregs.h.al = 0x05; + inregs.h.bh = 0x00;// delay + inregs.h.bl = 0x00;// rate + int386( 0x16, &inregs, &inregs ); +} + diff --git a/SRC/MISCFUNC.CPP b/SRC/MISCFUNC.CPP new file mode 100644 index 0000000..ce3202b --- /dev/null +++ b/SRC/MISCFUNC.CPP @@ -0,0 +1,541 @@ +#include < stdlib.h > +#include < stdio.h > +#include < keyb.hpp > +#include < string.h > +#include < gfunc.h > +#include < dos.h > +#include "efp/efp.h" +#include "draw.h" +#include "globvar.h" +#include "fade.h" +#include "write.h" +#include "newfuncs.h" +#include "rout.h" + +void change_name( int num ) +{ + int x; + fadeout( virbuff, pal ); + load_efp( "efps\\cool.efp", picture, 0 ); + FONT_NUM = 0; + x = 160 - ( str_length( "enter your name" ) / 2 ); + draw_box1( x - 10, 75, 320 - x + 10, 125, 5 ); + memcpy( virbuff, picture, 64000 ); + writefonts2( x, 85, "enter your name", 1 ); + fadein( virbuff, pal ); + k.clear_stack(); + if ( num == 1 ) + readline( x, 100, 10, name1, screen ); + if ( num == 2 ) + readline( x, 100, 10, name2, screen ); + fadeout( virbuff, pal ); +} + +char *k_2_c( int key ) +{ + char *t, text[15]; + int a; + strset( text, 0 ); + text[0] = ( char ) k.tt.Non[key]; + for ( a = 0; a < SPEC_K; a ++ ) + if ( key == spec[a].num ) strcpy( text, spec[a].text ); + t = strdup( text ); + return( t ); +} + +int get_key( int x, int y ) +{ + int a = 0, key = 0, oclock = 0, cnt = 0, pressed = 0; + while ( !pressed ) + { + if ( clock() != oclock ) + { + oclock = clock(); + draw_ball( x, y, cnt ); + cnt ++; + if ( cnt > 23 ) cnt = 0; + } + for ( a = 0; a < 0x80 &&!pressed; a ++ ) + if ( a!= 42 ) + if ( k.state[a] ) + { + key = a; pressed = 1; + } + } + for ( a = 0; a < 0x80; a ++ ) + k.state[a] = 0; + return( key ); +} + +void clear_shit( int y ) +{ + int a; + for ( a = 0; a < 20; a ++ ) + memcpy( screen + ( ( y + a ) *320 ) + 20, picture + ( ( y + a ) *320 ) + 20, 20 ); + for ( a = 0; a < 8; a ++ ) + memcpy( screen + ( ( y + a + 3 ) *320 ) + 190, picture + ( ( y + a + 3 ) *320 ) + 190, 130 ); +} + +void set_keys() +{ + if ( GAME_MODE != SPLIT_SCREEN ) + { + aplayer[0]->K_LEFT = keys1.K_LEFT; + aplayer[0]->K_RIGHT = keys1.K_RIGHT; + aplayer[0]->K_UP = keys1.K_UP; + aplayer[0]->K_DOWN = keys1.K_DOWN; + aplayer[0]->K_SHOOT = keys1.K_SHOOT; + aplayer[0]->K_SHIFT = keys1.K_SHIFT; + aplayer[0]->K_STRAFE = keys1.K_STRAFE; + aplayer[0]->K_LSTRAFE = keys1.K_LSTRAFE; + aplayer[0]->K_RSTRAFE = keys1.K_RSTRAFE; + } + else + { + aplayer[0]->K_LEFT = keys2.K_LEFT; + aplayer[0]->K_RIGHT = keys2.K_RIGHT; + aplayer[0]->K_UP = keys2.K_UP; + aplayer[0]->K_DOWN = keys2.K_DOWN; + aplayer[0]->K_SHOOT = keys2.K_SHOOT; + aplayer[0]->K_SHIFT = keys2.K_SHIFT; + aplayer[0]->K_STRAFE = keys2.K_STRAFE; + aplayer[0]->K_RSTRAFE = keys2.K_RSTRAFE; + aplayer[0]->K_LSTRAFE = keys2.K_LSTRAFE; + aplayer[1]->K_LEFT = keys1.K_LEFT; + aplayer[1]->K_RIGHT = keys1.K_RIGHT; + aplayer[1]->K_UP = keys1.K_UP; + aplayer[1]->K_DOWN = keys1.K_DOWN; + aplayer[1]->K_SHOOT = keys1.K_SHOOT; + aplayer[1]->K_SHIFT = keys1.K_SHIFT; + aplayer[1]->K_STRAFE = keys1.K_STRAFE; + aplayer[1]->K_RSTRAFE = keys1.K_RSTRAFE; + aplayer[1]->K_LSTRAFE = keys1.K_LSTRAFE; + } +} + +void alusta_client() +{ + int a; + + aplayer[0]->TARGET = 0; + aplayer[0]->shooted = 0; + aplayer[0]->hitten = 0; + aplayer[0]->curr_weapon = 0; + aplayer[0]->KICK = 0; + aplayer[0]->HIT = 0; +// aplayer[0]->move( 0, 0, 0 ); + aplayer[0]->move_scr(); + aplayer[0]->load_cnt = 0; + aplayer[0]->max_energy = 100; + for ( a = 0; a < DIFF_WEAPONS + 1; a ++ ) aplayer[0]->weapons[a] = 0; + for ( a = 0; a < DIFF_BULLETS ; a ++ ) aplayer[0]->bullets[a] = 0; + aplayer[0]->weapons[0] = 1; + if (KILLING_MODE==DEATHMATCH) + { + aplayer[0]->shield = 30; + aplayer[0]->energy = ( aplayer[0]->max_energy + ( aplayer[0]->shield*10 ) ) / 3; + } else { + aplayer[0]->shield = 0; + } +} + +void alusta_players1() +{ + int a, b; + strcpy( aplayer[0]->name, name1 ); + if (ACTIVE_PLAYERS==2) + strcpy( aplayer[1]->name, name2 ); + aplayer[0]->color = 16*3; + if (ACTIVE_PLAYERS==2) + aplayer[1]->color = 16*9; + for ( b = 0; b < ACTIVE_PLAYERS; b ++ ) + { + aplayer[b]->enabled=1; + aplayer[b]->cash = 900; + aplayer[b]->total_kills = 0; + aplayer[b]->TARGET = 0; + if ( KILLING_MODE!= DEATHMATCH ) aplayer[b]->shield = 0; + else aplayer[b]->shield = 30; + aplayer[b]->DEAD = 0; + if ( KILLING_MODE!= DEATHMATCH ) aplayer[b]->speed = 2;else aplayer[b]->speed = DEATH_MATCH_SPEED; + aplayer[b]->max_energy = 100; + for ( a = 0; a < DIFF_WEAPONS + 1; a ++ ) aplayer[b]->weapons[a] = 0; + for ( a = 0; a < DIFF_BULLETS; a ++ ) aplayer[b]->bullets[a] = 0; + aplayer[b]->weapons[0] = 1; + if ( KILLING_MODE!= DEATHMATCH ) + aplayer[b]->bullets[0] = 10; + } + if ( !strcmp( aplayer[0]->name, "iron" ) ) aplayer[0]->cash = 50000; + if (ACTIVE_PLAYERS==2) + if ( !strcmp( aplayer[1]->name, "maiden" ) ) aplayer[1]->cash = 50000; +} + +void alusta_players2() +{ + int a, b; + for ( b = 0; b < ACTIVE_PLAYERS; b ++ ) + { + aplayer[b]->PUSH_POWER = 0; + aplayer[b]->x = ( pl_start_x[b]*20 ); + aplayer[b]->y = ( pl_start_y[b]*20 ); + aplayer[b]->burning = 0; + aplayer[b]->shooted = 0; + aplayer[b]->hitten = 0; + aplayer[b]->player_kills = 0; + aplayer[b]->curr_weapon = 0; + aplayer[b]->KICK = 0; + aplayer[b]->HIT = 0; + aplayer[b]->move( 0, 0, 0 ); + aplayer[b]->move_scr(); + aplayer[b]->load_cnt = 0; + if ( KILLING_MODE!= DEATHMATCH ) aplayer[b]->energy = aplayer[b]->max_energy + ( aplayer[b]->shield*10 ); + else aplayer[b]->energy = ( aplayer[b]->max_energy + ( aplayer[b]->shield*10 ) ) / 3; + for ( a = 0; a < DIFF_ENEMIES; a ++ ) + aplayer[b]->kills[a] = 0; + } +} + +void two_to_one() +{ + if (aplayer[0]->DEAD || aplayer[1]->DEAD){ + ACTIVE_PLAYERS=1; + GAME_MODE = ONE_PLAYER; + if (aplayer[0]->DEAD) {aplayer[0]->enabled=0;aplayer[0]=aplayer[1];} + else aplayer[1]->enabled=0; + } +} + +void define_bullet_types() +{ + strcpy( bullet_type[0].name, "fist" ); + bullet_type[0].type = NORMAL; + bullet_type[0].stop = 1; + bullet_type[0].speed = 5; + bullet_type[0].power = 3; + bullet_type[0].push_power = 3; + bullet_type[0].time = 1; + bullet_type[0].sprite = 0; + bullet_type[0].light = 0; + bullet_type[0].effect = 0; + bullet_type[0].mul = 1; + bullet_type[0].sleep_time = 0; + strcpy( bullet_type[1].name, "9mm bullets" ); + bullet_type[1].type = NORMAL; + bullet_type[1].stop = 1; + bullet_type[1].speed = 6*18; + bullet_type[1].power = 5; + bullet_type[1].push_power = 2; + bullet_type[1].time = 1; + bullet_type[1].sprite = 0; + bullet_type[1].light = 0; + bullet_type[1].effect = 0; + bullet_type[1].cost = 3; + bullet_type[1].amount_in_crate = 50; + bullet_type[1].mul = 1; + bullet_type[1].sleep_time = 0; + bullet_type[1].max = 300; + strcpy( bullet_type[2].name, "12mm bullets" ); + bullet_type[2].type = NORMAL; + bullet_type[2].stop = 1; + bullet_type[2].speed = 7*18; + bullet_type[2].power = 9; + bullet_type[2].push_power = 2; + bullet_type[2].time = 1; + bullet_type[2].sprite = 0; + bullet_type[2].light = 0; + bullet_type[2].effect = 0; + bullet_type[2].cost = 5; + bullet_type[2].amount_in_crate = 50; + bullet_type[2].mul = 1; + bullet_type[2].sleep_time = 0; + bullet_type[2].max = 300; + strcpy( bullet_type[3].name, "shotgun shells" ); + bullet_type[3].type = NORMAL; + bullet_type[3].stop = 1; + bullet_type[3].speed = 6*18; + bullet_type[3].power = 3; + bullet_type[3].push_power = 3; + bullet_type[3].time = 1; + bullet_type[3].sprite = 0; + bullet_type[3].light = 0; + bullet_type[3].effect = 0; + bullet_type[3].cost = 6; + bullet_type[3].amount_in_crate = 20; + bullet_type[3].mul = 1; + bullet_type[3].sleep_time = 0; + bullet_type[3].max = 300; + strcpy( bullet_type[4].name, "light grenades" ); + bullet_type[4].type = EXPLOSIVE; + bullet_type[4].stop = 1; + bullet_type[4].speed = 8; + bullet_type[4].power = 0; + bullet_type[4].push_power = 0; + bullet_type[4].time = ( 15*18 ) / 8; + bullet_type[4].explos = 1; + bullet_type[4].sprite = grenadespr; + bullet_type[4].xs = 7; + bullet_type[4].ys = 7; + bullet_type[4].xsize = 7; + bullet_type[4].offs = 0; + bullet_type[4].light = &normal_l; + bullet_type[4].lsize = 3; + bullet_type[4].llum = 0; + bullet_type[4].ladd = 0; + bullet_type[4].effect = SMOKE2; + bullet_type[4].cost = 70; + bullet_type[4].amount_in_crate = 15; + bullet_type[4].mul = 1; + bullet_type[4].sleep_time = 0; + bullet_type[4].max = 150; + strcpy( bullet_type[5].name, "medium grenades" ); + bullet_type[5].type = EXPLOSIVE; + bullet_type[5].stop = 1; + bullet_type[5].speed = 8; + bullet_type[5].power = 0; + bullet_type[5].push_power = 0; + bullet_type[5].time = ( 15*18 ) / 8; + bullet_type[5].explos = 2; + bullet_type[5].sprite = grenadespr; + bullet_type[5].xs = 7; + bullet_type[5].ys = 7; + bullet_type[5].xsize = 7; + bullet_type[5].offs = 0; + bullet_type[5].light = &normal_l; + bullet_type[5].lsize = 3; + bullet_type[5].llum = 0; + bullet_type[5].ladd = 0; + bullet_type[5].effect = SMOKE2; + bullet_type[5].cost = 100; + bullet_type[5].amount_in_crate = 10; + bullet_type[5].mul = 1; + bullet_type[5].sleep_time = 0; + bullet_type[5].max = 125; + strcpy( bullet_type[6].name, "heavy grenades" ); + bullet_type[6].type = EXPLOSIVE; + bullet_type[6].stop = 1; + bullet_type[6].speed = 8; + bullet_type[6].power = 0; + bullet_type[6].push_power = 0; + bullet_type[6].time = ( 15*18 ) / 8; + bullet_type[6].explos = 4; + bullet_type[6].sprite = grenadespr; + bullet_type[6].xs = 7; + bullet_type[6].ys = 7; + bullet_type[6].xsize = 7; + bullet_type[6].offs = 0; + bullet_type[6].light = &normal_l; + bullet_type[6].lsize = 4; + bullet_type[6].llum = 0; + bullet_type[6].ladd = 0; + bullet_type[6].effect = SMOKE2; + bullet_type[6].cost = 200; + bullet_type[6].amount_in_crate = 5; + bullet_type[6].mul = 1; + bullet_type[6].sleep_time = 0; + bullet_type[6].max = 100; + strcpy( bullet_type[7].name, "C4-explosives" ); + bullet_type[7].type = EXPLOSIVE; + bullet_type[7].stop = 0; + bullet_type[7].speed = 0; + bullet_type[7].power = 0; + bullet_type[7].push_power = 0; + bullet_type[7].time = 100; + bullet_type[7].explos = 4; + bullet_type[7].sprite = c4spr; + bullet_type[7].xs = 8; + bullet_type[7].ys = 8; + bullet_type[7].xsize = 8; + bullet_type[7].offs = 0; + bullet_type[7].light = 0; + bullet_type[7].lsize = 0; + bullet_type[7].effect = 0; + bullet_type[7].cost = 150; + bullet_type[7].amount_in_crate = 5; + bullet_type[7].mul = 1; + bullet_type[7].sleep_time = 0; + bullet_type[7].max = 100; + strcpy( bullet_type[8].name, "Gas" ); + bullet_type[8].type = INCENDIARY; + bullet_type[8].stop = 1; + bullet_type[8].speed = 5; + bullet_type[8].power = 0.4; + bullet_type[8].push_power = 0; + bullet_type[8].time = ( 5*18 ) / 5; + bullet_type[8].explos = 0; + bullet_type[8].sprite = 0; + bullet_type[8].light = &explo_l; + bullet_type[8].lsize = 2; + bullet_type[8].llum = - 10; + bullet_type[8].ladd = 0.7; + bullet_type[8].effect = 0; + bullet_type[8].cost = 6; + bullet_type[8].amount_in_crate = 500;// div mul = 50 + bullet_type[8].mul = 10; + bullet_type[8].sleep_time = 0; + bullet_type[8].max = 300; + strcpy( bullet_type[9].name, "Mines" ); + bullet_type[9].type = EXPLOSIVE; + bullet_type[9].stop = 1; + bullet_type[9].speed = 0; + bullet_type[9].power = 0; + bullet_type[9].push_power = 0; + bullet_type[9].time = 2000; + bullet_type[9].explos = 1; + bullet_type[9].sprite = minespr; + bullet_type[9].xs = 7; + bullet_type[9].ys = 7; + bullet_type[9].xsize = 7; + bullet_type[9].offs = 0; + bullet_type[9].light = 0; + bullet_type[9].lsize = 0; + bullet_type[9].effect = 0; + bullet_type[9].cost = 150; + bullet_type[9].amount_in_crate = 5; + bullet_type[9].mul = 1; + bullet_type[9].sleep_time = 25; + bullet_type[9].max = 100; + strcpy( bullet_type[10].name, "Explosive ray" ); + bullet_type[10].type = NORMAL; + bullet_type[10].stop = 1; + bullet_type[10].speed = 20; + bullet_type[10].power = 30; + bullet_type[10].push_power = 8; + bullet_type[10].time = 0; // define in new_bullet() + bullet_type[10].sprite = 0; + bullet_type[10].effect = EXPLO; + bullet_type[10].mul = 1; + bullet_type[10].sleep_time = 0; +} + +void define_effects() +{ + effect_type[0].index = 0; + effect_type[0].tcount = 4; + effect_type[0].order = 1; + effect_type[0].delay = 2; + effect_type[0].random = 0; + effect_type[0].xs = 12; + effect_type[0].ys = 12; + effect_type[0].offs = 0; + effect_type[1].index = 1; + effect_type[1].tcount = 4; + effect_type[1].order = 0; + effect_type[1].delay = 2; + effect_type[1].random = 0; + effect_type[1].xs = 12; + effect_type[1].ys = 12; + effect_type[1].offs = 13*4; + effect_type[2].index = 2; + effect_type[2].tcount = 9; + effect_type[2].order = 1; + effect_type[2].delay = 2; + effect_type[2].random = 0; + effect_type[2].xs = 25; + effect_type[2].ys = 25; + effect_type[2].offs = 320*13; + effect_type[3].index = 3; + effect_type[3].tcount = 8; + effect_type[3].order = 1; + effect_type[3].delay = 2; + effect_type[3].random = 0; + effect_type[3].xs = 12; + effect_type[3].ys = 12; + effect_type[3].offs = 13*8; + effect_type[4].index = 4; + effect_type[4].tcount = 12; + effect_type[4].order = 1; + effect_type[4].delay = 5; + effect_type[4].random = 1; + effect_type[4].xs = 20; + effect_type[4].ys = 20; + effect_type[4].offs = 320*39; + effect_type[5].index = 5; + effect_type[5].tcount = 8; + effect_type[5].order = 0; + effect_type[5].delay = 20; + effect_type[5].random = 1; + effect_type[5].xs = 6; + effect_type[5].ys = 6; + effect_type[5].offs = 13*20; + effect_type[6].index = 6; + effect_type[6].tcount = 4; + effect_type[6].order = 1; + effect_type[6].delay = 2; + effect_type[6].random = 0; + effect_type[6].xs = 12; + effect_type[6].ys = 12; + effect_type[6].offs = 13*16; + effect_type[7].index = 7; + effect_type[7].tcount = 12; + effect_type[7].order = 1; + effect_type[7].delay = 2; + effect_type[7].random = 0; + effect_type[7].xs = 20; + effect_type[7].ys = 20; + effect_type[7].offs = 320*39; + effect_type[8].index = 8; + effect_type[8].tcount = 7; + effect_type[8].order = 1; + effect_type[8].delay = 2; + effect_type[8].random = 0; + effect_type[8].xs = 20; + effect_type[8].ys = 20; + effect_type[8].offs = 320*60; + effect_type[9].index = 9; + effect_type[9].tcount = 4; + effect_type[9].order = 0; + effect_type[9].delay = 50; + effect_type[9].random = 1; + effect_type[9].xs = 6; + effect_type[9].ys = 6; + effect_type[9].offs = ( 13*20 ) + ( 320*7 ); +} + +void explo( int x, int y, int size, int index ) +{ + int a, rays, pan = 0; + rays = size*5; + for ( a = 0; a < rays; a ++ ) + new_bullet( EXPLO_RAY, x, y, a*( float ) ( 360 / rays ), size,index); + for ( a = 0; a < ( rand() % 5 ) + 1; a ++ ) + if ( rand() % 2 ) + new_effect( &yellow_l, METAL, x, y, rand() % 360, ( rand() % 3 ) + 4 ); + else + new_effect( &red_l, METAL, x, y, rand() % 360, ( rand() % 3 ) + 4 ); + + if (GAME_MODE!=SPLIT_SCREEN) + MIDASplaySample( samplep[EXPLOWAV], MIDAS_CHANNEL_AUTO, 0, 14000 - ( size*1000 ), get_volume(aplayer[0]->x,aplayer[0]->y,x,y), get_pan(aplayer[0]->x,x)); + else + MIDASplaySample( samplep[EXPLOWAV], MIDAS_CHANNEL_AUTO, 0, 14000 - ( size*1000 ), EFFECT_VOLUME, 0 ); +} + +void list_files( int *no, vile *filelist, char *wildcard, int type ) +{ + struct find_t fbuf; + int er; + er = _dos_findfirst( wildcard, type, &fbuf ); + while ( er == 0 ) + { + if ( ( fbuf.attrib&type ) == type ) + { + if ( strcmp( fbuf.name, "." ) &&strcmp( fbuf.name, ".." ) ) + { + strcpy( filelist[*no].name, fbuf.name ); + ( *no ) ++; + } + } + er = _dos_findnext( &fbuf ); + } + _dos_findclose( &fbuf ); +} + +void set_keyb_rate() +{ + union REGS inregs; + inregs.h.ah = 0x03; + inregs.h.al = 0x05; + inregs.h.bh = 0x00;// delay + inregs.h.bl = 0x00;// rate + int386( 0x16, &inregs, &inregs ); +} + diff --git a/SRC/MISCFUNC.H b/SRC/MISCFUNC.H new file mode 100644 index 0000000..1b764c7 --- /dev/null +++ b/SRC/MISCFUNC.H @@ -0,0 +1,17 @@ +#ifndef __TK__MISCFUNC__ +#define __TK__MISCFUNC__ +void change_name( int num ); +char *k_2_c( int key ); +int get_key( int x, int y ); +void clear_shit( int y ); +void set_keys(); +void alusta_client(); +void alusta_players1(); +void alusta_players2(); +void two_to_one(); +void define_bullet_types(); +void define_effects(); +void explo( int x, int y, int size, int index); +void list_files( int *no, vile *filelist, char *wildcard, int type ); +void set_keyb_rate(); +#endif diff --git a/SRC/MISCFUNC.OBJ b/SRC/MISCFUNC.OBJ new file mode 100644 index 0000000..9c7a290 Binary files /dev/null and b/SRC/MISCFUNC.OBJ differ diff --git a/SRC/NEWFUNCS.BAK b/SRC/NEWFUNCS.BAK new file mode 100644 index 0000000..ad49eb2 --- /dev/null +++ b/SRC/NEWFUNCS.BAK @@ -0,0 +1,7 @@ +#ifndef ___NEW___FUNCS__ +#define ___NEW___FUNCS__ +#include "classes.h" +void new_body_part( int x, int y, int angle, int speed, int num ); +void new_effect( Light_table *lt, int type, int x, int y, int angle, int speed ); +void new_bullet( int type, int x, int y, int angle, int time_add, int index ); +#endif diff --git a/SRC/NEWFUNCS.CPP b/SRC/NEWFUNCS.CPP new file mode 100644 index 0000000..cb7c55a --- /dev/null +++ b/SRC/NEWFUNCS.CPP @@ -0,0 +1,91 @@ +#include "defines.h" +#include "globvar.h" +#include "types.h" +#include "classes.h" + +extern void sendipx(int, int, ... ); + +void new_body_part( int x, int y, int angle, int speed, int num ) +{ + int a = 0; + if ( angle >= 360 ) angle -= 360; + if ( angle < 0 ) angle += 360; + while ( body_part[a].IN_USE &&a < MAX_BODY_PARTS ) if ( body_part[a].IN_USE ) a ++; + if ( a < MAX_BODY_PARTS ) + { + body_part[a].num = num; + body_part[a].x = x; + body_part[a].y = y; + body_part[a].angle = angle; + body_part[a].speed = speed; + body_part[a].IN_USE = 1; + } +} + +void new_effect( Light_table *lt, int type, int x, int y, int angle, int speed ) +{ + int min, a = 0, num = 0; + + if ( angle >= 360 ) angle -= 360; + if ( angle < 0 ) angle += 360; + + effect_age_count ++; // can be large after 10 hour session : ) + + + while ( effect[a].IN_USE &&a < MAX_EFFECTS ) if ( effect[a].IN_USE ) a++; + if ( a < MAX_EFFECTS ) num = a; + else + { + min = 0; + for ( a = 1; a < MAX_EFFECTS; a ++ ) if ( effect[a].age < effect[min].age ) + min = a; + num = min; + } + effect[num].age = effect_age_count; + effect[num].lt = lt; + effect[num].type = &effect_type[type]; + effect[num].x = x; + effect[num].y = y; + effect[num].count = 0; + effect[num].angle = angle; + effect[num].speed = speed; + effect[num].IN_USE = 1; + + +} + +void new_bullet( int type, int x, int y, int angle, int time_add, int index) +{ + int a = 0,b; + + if ( angle >= 360 ) angle -= 360; + if ( angle < 0 ) angle += 360; + while ( bullet[a].IN_USE &&a < MAX_BULLETS ) a ++; + if ( a < MAX_BULLETS ) + { + bullet[a].type = &bullet_type[type]; + bullet[a].x = x; + bullet[a].y = y; + if (index>-1) + bullet[a].P = &player[index]; + else + bullet[a].P =0; + bullet[a].index = index; + bullet[a].angle = angle; + bullet[a].time = bullet_type[type].time + time_add; + bullet[a].count = 0; + bullet[a].IN_USE = 1; + + if (GAME_MODE==NETWORK) + if (type != EXPLO_RAY) + { + if (NETWORK_MODE==CLIENT) sendipx(0,IPX_NEWBULLET,(char)index,(int)type,(int)a); + else + for(b=1;b +#include < stdio.h > +#include < gfunc.h > +#include < string.h > +#include < dos.h > +#include < conio.h > +#include "efp/efp.h" +#include "defines.h" +#include "types.h" +#include "globvar.h" +#include "miscfunc.h" +#include "fade.h" +#include "draw.h" +#include "write.h" + +extern void setup_ipx(); +extern void desetup_ipx(); +extern void game(); +extern int select_server(); + +void save_options() +{ + FILE *cfg; + cfg = fopen( "options.cfg", "wb" ); + fwrite( &keys1, sizeof( class Keys ), 1, cfg ); + fwrite( &keys2, sizeof( class Keys ), 1, cfg ); + fwrite( name1, sizeof( name1 ), 1, cfg ); + fwrite( name2, sizeof( name2 ), 1, cfg ); + fwrite( &DARK_MODE, sizeof( DARK_MODE ), 1, cfg ); + fwrite( &LIGHT_EFFECTS, sizeof( LIGHT_EFFECTS ), 1, cfg ); + fwrite( &SHADOWS, sizeof( SHADOWS ), 1, cfg ); + fwrite( &MUSIC_VOLUME, sizeof( MUSIC_VOLUME ), 1, cfg ); + fwrite( &EFFECT_VOLUME, sizeof( EFFECT_VOLUME ), 1, cfg ); + fwrite( &ENEMIES_ON_GAME, sizeof( ENEMIES_ON_GAME ), 1, cfg ); + fwrite( DEATH_MATCH_LEVEL, sizeof( DEATH_MATCH_LEVEL ), 1, cfg ); + fwrite( &DEATH_MATCH_EPISODE, sizeof( DEATH_MATCH_EPISODE ), 1, cfg ); + fwrite( &DEATH_MATCH_SPEED, sizeof( DEATH_MATCH_SPEED ), 1, cfg ); + fwrite( &saved_killing_mode, sizeof( saved_killing_mode ), 1, cfg ); + fwrite( &saved_game_mode, sizeof( saved_game_mode ), 1, cfg ); + fclose( cfg ); +} + +void load_options() +{ + FILE *cfg; + cfg = fopen( "options.cfg", "rb" ); + if ( cfg ) + { + fread( &keys1, sizeof( class Keys ), 1, cfg ); + fread( &keys2, sizeof( class Keys ), 1, cfg ); + fread( name1, sizeof( name1 ), 1, cfg ); + fread( name2, sizeof( name2 ), 1, cfg ); + fread( &DARK_MODE, sizeof( DARK_MODE ), 1, cfg ); + fread( &LIGHT_EFFECTS, sizeof( LIGHT_EFFECTS ), 1, cfg ); + fread( &SHADOWS, sizeof( SHADOWS ), 1, cfg ); + fread( &MUSIC_VOLUME, sizeof( MUSIC_VOLUME ), 1, cfg ); + fread( &EFFECT_VOLUME, sizeof( EFFECT_VOLUME ), 1, cfg ); + fread( &ENEMIES_ON_GAME, sizeof( ENEMIES_ON_GAME ), 1, cfg ); + fread( DEATH_MATCH_LEVEL, sizeof( DEATH_MATCH_LEVEL ), 1, cfg ); + fread( &DEATH_MATCH_EPISODE, sizeof( DEATH_MATCH_EPISODE ), 1, cfg ); + fread( &DEATH_MATCH_SPEED, sizeof( DEATH_MATCH_SPEED ), 1, cfg ); + fread( &saved_killing_mode, sizeof( saved_killing_mode ), 1, cfg ); + fread( &saved_game_mode, sizeof( saved_game_mode ), 1, cfg ); + fclose( cfg ); + } +} + +int choose_load_file( char *name, int episode ) +{ + int a, b, sel = 0, pos = 0, cnt = 0, oclock = 0; + int files = files_in_episode[episode]; + load_efp( "efps\\cool.efp", picture, 0 ); + draw_box1( 60, 10, 320 - 60, 190, 15 ); + first = 1; + while ( !k.state[1]&&!k.state[28] ) + { + memcpy( virbuff, picture, 64000 ); + FONT_NUM = 0; + writefonts2( 160 - ( str_length( "select level:" ) >> 1 ), 20, "select level:", 1 ); + b = files; + if ( b > 15 ) b = 15; + FONT_NUM = 1; + for ( a = 0; a < b; a ++ ) + if ( a + pos == sel ) + writefonts( 160 - ( str_length( strlwr( filelist[episode][a + pos].name ) ) >> 1 ), 50 + a*8, strlwr( filelist[episode][a + pos].name ), M_YELLOW ); + else + writefonts( 160 - ( str_length( strlwr( filelist[episode][a + pos].name ) ) >> 1 ), 50 + a*8, strlwr( filelist[episode][a + pos].name ), M_BLUE ); + if ( pos > 0 ) writefonts( 156, 42, "", M_BLUE ); + if ( files > 15 ) if ( pos < files - 15 ) writefonts( 156, 50 + 15*8, "", M_BLUE ); + if ( first == 1 ) + { + fadein( virbuff, pal ); first = 0; + } + memcpy( screen, virbuff, 64000 ); + while( !k.state[94]&&!k.state[99]&&!k.state[28] ) + if ( clock() != oclock ) + { + oclock = clock(); + draw_ball( 65, 46 + ( ( sel - pos ) *8 ), cnt ); + draw_ball( 320 - 85, 46 + ( ( sel - pos ) *8 ), cnt ); + cnt ++; + if ( cnt > 23 ) cnt = 0; + } + if ( k.state[94] ) + { + if ( sel > 0 ) sel --;k.state[94] = 0; + } + if ( k.state[99] ) + { + if ( sel < files - 1 ) sel ++;k.state[99] = 0; + } + pos = sel - 8; + if ( pos < 0 ) pos = 0; + if ( files > 15 ) if ( pos > files - 15 ) pos = files - 15; + if ( files <= 15 ) if ( pos > 0 ) pos = 0; + } + a = 0; + strcpy( name, filelist[episode][sel].name ); a = 1; k.state[28] = 0; + return( a ); +} + +int choose_episode() +{ + int a, b, sel = 0, pos = 0, cnt = 0, oclock = 0; + char text[20]; + load_efp( "efps\\cool.efp", picture, 0 ); + draw_box1( 60, 10, 320 - 60, 190, 15 ); + first = 1; + k.state[1] = 0; + k.state[28] = 0; + fadeout( virbuff, pal ); + while ( !k.state[1]&&!k.state[28] ) + { + memcpy( virbuff, picture, 64000 ); + FONT_NUM = 0; + writefonts2( 160 - ( str_length( "select episode" ) >> 1 ), 20, "select episode", 1 ); + b = dirs; + if ( b > 7 ) b = 7; + for ( a = 0; a < b; a ++ ) + { + if ( a + pos == sel ) + { + FONT_NUM = 0; + writefonts2( 160 - ( str_length( strlwr( dirlist[a + pos].name ) ) >> 1 ), 50 + a*16, strlwr( dirlist[a + pos].name ), 1 ); + } + else + { + FONT_NUM = 2; + writefonts2( 160 - ( str_length( strlwr( dirlist[a + pos].name ) ) >> 1 ), 50 + a*16, strlwr( dirlist[a + pos].name ), 1 ); + } + } + FONT_NUM = 1; + itoa( files_in_episode[sel + 1], text, 10 ); + strcat( text, " levels" ); + writefonts( 70, 175, text, M_BLUE ); + if ( first == 1 ) + { + fadein( virbuff, pal ); first = 0; + } + memcpy( screen, virbuff, 64000 ); + while( !k.state[94]&&!k.state[99]&&!k.state[28] ) + if ( clock() != oclock ) + { + oclock = clock(); + draw_ball( 65, 48 + ( ( sel - pos ) *16 ), cnt ); + draw_ball( 320 - 85, 48 + ( ( sel - pos ) *16 ), cnt ); + cnt ++; + if ( cnt > 23 ) cnt = 0; + } + if ( k.state[94] ) + { + if ( sel > 0 ) sel --;k.state[94] = 0; + } + if ( k.state[99] ) + { + if ( sel < dirs - 1 ) sel ++;k.state[99] = 0; + } + pos = sel - 3; + if ( pos < 0 ) pos = 0; + if ( dirs > 7 ) if ( pos > dirs - 7 ) pos = dirs - 7; + if ( dirs <= 7 ) if ( pos > 0 ) pos = 0; + } + k.state[28] = 0; + return( sel ); +} + +void options_scr( int opt, char *filename ) +{ + load_efp( filename, picture, 0 ); + load_efp_pal( "efps\\ware.efp", pal ); + draw_box1( 45, 90 - ( ( opt*15 ) / 2 ), 320 - 45, 110 + ( ( opt*15 ) / 2 ), 13 ); + first = 1; +} + +void multip_options_scr( int opt, char *filename ) +{ + load_efp( filename, picture, 0 ); + load_efp_pal( "efps\\ware.efp", pal ); + draw_box1( 10, 90 - ( ( opt*15 ) / 2 ), 320 - 10, 110 + ( ( opt*15 ) / 2 ), 13 ); + first = 1; +} + +void player_options() +{ + int yoffs = ( 15*num_player_options ) / 2, a, cnt = 0, selected = 0, quit = 0, oclock; + fadeout( virbuff, pal ); + options_scr( num_player_options, "efps\\cool.efp" ); + k.state[28] = 0; + while( !quit ) + { + memcpy( virbuff, picture, 64000 ); + for ( a = 0; a < num_player_options; a ++ ) + { + if ( a == selected ) + { + FONT_NUM = 0; + writefonts2( 160 - ( str_length( player_opt_text[a] ) / 2 ), ( 100 - yoffs ) + ( a*15 ), player_opt_text[a], 1 ); + } + else + { + FONT_NUM = 2; + writefonts2( 160 - ( str_length( player_opt_text[a] ) / 2 ), ( 100 - yoffs ) + ( a*15 ), player_opt_text[a], M_RED ); + } + } + if ( first == 1 ) + { + fadein( virbuff, pal ); first = 0; + } + memcpy( screen, virbuff, 64000 ); + while ( !k.state[1]&&!k.state[94]&&!k.state[99]&&!k.state[28] ) + { + if ( clock() != oclock ) + { + oclock = clock(); + draw_ball( 65, ( 98 - yoffs ) + ( selected*15 ), cnt ); + draw_ball( 320 - 85, ( 98 - yoffs ) + ( selected*15 ), cnt ); + cnt ++; + if ( cnt > 23 ) cnt = 0; + } + }; + MIDASplaySample( klikwav, MIDAS_CHANNEL_AUTO, 0, 22500, EFFECT_VOLUME, MIDAS_PAN_MIDDLE ); + if ( k.state[94] ) + { + selected --;if ( selected < 0 ) selected = num_player_options - 1; k.state[94] = 0; + } + if ( k.state[99] ) + { + selected ++;if ( selected >= num_player_options ) selected = 0; k.state[99] = 0; + } + if ( k.state[28] ) + { + if ( selected == 0 ) + { + keys1.change(); options_scr( num_player_options, "efps\\cool.efp" ); + } + if ( selected == 1 ) + { + keys2.change(); options_scr( num_player_options, "efps\\cool.efp" ); + } + if ( selected == 2 ) + { + change_name( 1 ); options_scr( num_player_options, "efps\\cool.efp" ); + } + if ( selected == 3 ) + { + change_name( 2 ); options_scr( num_player_options, "efps\\cool.efp" ); + } + if ( selected == 4 ) + { + quit = 1; + } + } + if ( k.state[1] ) + { + quit = 1;k.state[1] = 0; + } + } + fadeout( virbuff, pal ); +} + +void game_options() +{ + int yoffs = ( 15*num_game_options ) / 2, a, cnt = 0, selected = 0, quit = 0, oclock; + fadeout( virbuff, pal ); + options_scr( num_game_options, "efps\\cool.efp" ); + k.state[28] = 0; + while( !quit ) + { + memcpy( virbuff, picture, 64000 ); + if ( DARK_MODE ) strcpy(game_opt_text[0],"darkness on"); + if ( !DARK_MODE ) strcpy(game_opt_text[0],"darkness off" ); + if ( LIGHT_EFFECTS ) strcpy(game_opt_text[1],"lights on" ); + if ( !LIGHT_EFFECTS ) strcpy(game_opt_text[1],"lights off" ); + if ( SHADOWS ) strcpy(game_opt_text[2],"shadows on" ); + if ( !SHADOWS ) strcpy(game_opt_text[2],"shadows off" ); + for ( a = 0; a < num_game_options; a ++ ) + { + if ( a == selected ) + { + FONT_NUM = 0; + writefonts2( 160 - ( str_length( game_opt_text[a] ) / 2 ), ( 100 - yoffs ) + ( a*15 ), game_opt_text[a], 1 ); + } + else + { + FONT_NUM = 2; + writefonts2( 160 - ( str_length( game_opt_text[a] ) / 2 ), ( 100 - yoffs ) + ( a*15 ), game_opt_text[a], M_RED ); + } + } + if ( first == 1 ) + { + fadein( virbuff, pal ); first = 0; + } + memcpy( screen, virbuff, 64000 ); + while ( !k.state[1]&&!k.state[94]&&!k.state[99]&&!k.state[28] ) + { + if ( clock() != oclock ) + { + oclock = clock(); + draw_ball( 65, ( 98 - yoffs ) + ( selected*15 ), cnt ); + draw_ball( 320 - 85, ( 98 - yoffs ) + ( selected*15 ), cnt ); + cnt ++; + if ( cnt > 23 ) cnt = 0; + } + }; + MIDASplaySample( klikwav, MIDAS_CHANNEL_AUTO, 0, 22500, EFFECT_VOLUME, MIDAS_PAN_MIDDLE ); + if ( k.state[94] ) + { + selected --;if ( selected < 0 ) selected = num_game_options - 1; k.state[94] = 0; + } + if ( k.state[99] ) + { + selected ++;if ( selected >= num_game_options ) selected = 0; k.state[99] = 0; + } + if ( k.state[28] ) + { + if ( selected == 0 ) + { + if ( !DARK_MODE ) DARK_MODE = 1;else DARK_MODE = 0;k.state[28] = 0; + } + if ( selected == 1 ) + { + if ( !LIGHT_EFFECTS ) LIGHT_EFFECTS = 1;else LIGHT_EFFECTS = 0;k.state[28] = 0; + } + if ( selected == 2 ) + { + if ( !SHADOWS ) SHADOWS = 1;else SHADOWS = 0;k.state[28] = 0; + } + if ( selected == 3 ) + { + quit = 1; + } + } + if ( k.state[1] ) + { + quit = 1;k.state[1] = 0; + } + } + fadeout( virbuff, pal ); +} + +void sound_options() +{ + int yoffs = ( 15*num_sound_options ) / 2, a, cnt = 0, selected = 0, quit = 0, oclock; + char text[30], text2[30]; + fadeout( virbuff, pal ); + options_scr( num_sound_options, "efps\\subbari.efp" ); + k.state[28] = 0; + while( !quit ) + { + memcpy( virbuff, picture, 64000 ); + strcpy( text, "music volume " ); + itoa( ( float ) MUSIC_VOLUME / 63*100, text2, 10 ); + strcat( text2, "%" ); + strcat( text, text2 ); + strcpy(sound_opt_text[0],text ); + strcpy( text, "effect volume " ); + itoa( ( float ) EFFECT_VOLUME / 63*100, text2, 10 ); + strcat( text2, "%" ); + strcat( text, text2 ); + strcpy(sound_opt_text[1],text ); + for ( a = 0; a < num_sound_options; a ++ ) + { + if ( a == selected ) + { + FONT_NUM = 0; + writefonts2( 160 - ( str_length( sound_opt_text[a] ) / 2 ), ( 100 - yoffs ) + ( a*15 ), sound_opt_text[a], 1 ); + } + else + { + FONT_NUM = 2; + writefonts2( 160 - ( str_length( sound_opt_text[a] ) / 2 ), ( 100 - yoffs ) + ( a*15 ), sound_opt_text[a], M_RED ); + } + } + if ( first == 1 ) + { + fadein( virbuff, pal ); first = 0; + } + memcpy( screen, virbuff, 64000 ); + while ( !k.state[1]&&!k.state[94]&&!k.state[99]&&!k.state[96]&&!k.state[97]&&!k.state[28] ) + { + if ( clock() != oclock ) + { + oclock = clock(); + draw_ball( 55, ( 98 - yoffs ) + ( selected*15 ), cnt ); + draw_ball( 320 - 75, ( 98 - yoffs ) + ( selected*15 ), cnt ); + cnt ++; + if ( cnt > 23 ) cnt = 0; + } + } + MIDASplaySample( klikwav, MIDAS_CHANNEL_AUTO, 0, 22500, EFFECT_VOLUME, MIDAS_PAN_MIDDLE ); + if ( k.state[94] ) + { + selected --;if ( selected < 0 ) selected = num_sound_options - 1; k.state[94] = 0; + } + if ( k.state[99] ) + { + selected ++;if ( selected >= num_sound_options ) selected = 0; k.state[99] = 0; + } + if ( k.state[96] ) + { + if ( selected == 0 ) MUSIC_VOLUME -= 5; + if ( selected == 1 ) EFFECT_VOLUME -= 5; + if ( MUSIC_VOLUME < 0 ) MUSIC_VOLUME = 0; + if ( EFFECT_VOLUME < 0 ) EFFECT_VOLUME = 0; + if ( selected == 0 ) MIDASsetMusicVolume( ph, MUSIC_VOLUME ); + k.state[96] = 0; + } + if ( k.state[97] ) + { + if ( selected == 0 ) MUSIC_VOLUME += 5; + if ( selected == 1 ) EFFECT_VOLUME += 5; + if ( MUSIC_VOLUME > 63 ) MUSIC_VOLUME = 63; + if ( EFFECT_VOLUME > 63 ) EFFECT_VOLUME = 63; + if ( selected == 0 ) MIDASsetMusicVolume( ph, MUSIC_VOLUME ); + k.state[97] = 0; + } + if ( k.state[28] ) if ( selected == 2 ) + { + quit = 1; + } + if ( k.state[1] ) + { + quit = 1;k.state[1] = 0; + } + } + fadeout( virbuff, pal ); +} + +int deathmatch_options() +{ + int start=0; + int yoffs = ( 15*num_deathmatch_options ) / 2, a, cnt = 0, selected = 0, quit = 0, oclock; + fadeout( virbuff, pal ); + options_scr( num_deathmatch_options, "efps\\cool.efp" ); + k.state[28] = 0; + while( !quit ) + { + memcpy( virbuff, picture, 64000 ); + if ( DEATH_MATCH_SPEED == 2 ) + strcpy(deathmatch_opt_text[1],"normal moving"); + else strcpy(deathmatch_opt_text[1],"fast moving"); + if ( ENEMIES_ON_GAME ) + strcpy(deathmatch_opt_text[2],"enemies on" ); + else strcpy(deathmatch_opt_text[2],"enemies off" ); + for ( a = 0; a < num_deathmatch_options; a ++ ) + { + if ( a == selected ) + { + FONT_NUM = 0; + writefonts2( 160 - ( str_length( deathmatch_opt_text[a] ) / 2 ), ( 100 - yoffs ) + ( a*15 ), deathmatch_opt_text[a], 1 ); + } + else + { + FONT_NUM = 2; + writefonts2( 160 - ( str_length( deathmatch_opt_text[a] ) / 2 ), ( 100 - yoffs ) + ( a*15 ), deathmatch_opt_text[a], 1 ); + } + } + if ( first == 1 ) + { + fadein( virbuff, pal ); first = 0; + } + memcpy( screen, virbuff, 64000 ); + while ( !k.state[1]&&!k.state[94]&&!k.state[99]&&!k.state[28] ) + { + if ( clock() != oclock ) + { + oclock = clock(); + draw_ball( 50, ( 98 - yoffs ) + ( selected*15 ), cnt ); + draw_ball( 320 - 70, ( 98 - yoffs ) + ( selected*15 ), cnt ); + cnt ++; + if ( cnt > 23 ) cnt = 0; + } + }; + MIDASplaySample( klikwav, MIDAS_CHANNEL_AUTO, 0, 22500, EFFECT_VOLUME, MIDAS_PAN_MIDDLE ); + if ( k.state[94] ) + { + selected --;if ( selected < 0 ) selected = num_deathmatch_options - 1; k.state[94] = 0; + } + if ( k.state[99] ) + { + selected ++;if ( selected >= num_deathmatch_options ) selected = 0; k.state[99] = 0; + } + if ( k.state[28] ) + { + k.state[28] = 0; + if ( selected == 0 ) { quit = 1;start = 1;} + if ( selected == 1 ) if ( DEATH_MATCH_SPEED == 2 ) DEATH_MATCH_SPEED = 3;else DEATH_MATCH_SPEED = 2; + if ( selected == 2 ) if ( ENEMIES_ON_GAME ) ENEMIES_ON_GAME = 0;else ENEMIES_ON_GAME = 1; + if ( selected == 3 ) quit = 1; + + } + if ( k.state[1] ) + { + quit = 1;k.state[1] = 0; + } + } + if (! start) fadeout( virbuff, pal ); + save_options(); + return(start); +} + +void multiplayer_options() +{ + int yoffs = ( 15*num_multip_options ) / 2, a, cnt = 0, selected = 0, quit = 0, oclock; + int dontfade = 0; + char text[50]; + fadeout( virbuff, pal ); + multip_options_scr( num_multip_options, "efps\\cool.efp" ); + k.state[28] = 0; + GAME_MODE = saved_game_mode; + KILLING_MODE = saved_killing_mode; + while( !quit ) + { + memcpy( virbuff, picture, 64000 ); + if ( KILLING_MODE == COOPERATIVE &&DEATH_MATCH_EPISODE == 0 ) + { + DEATH_MATCH_EPISODE = 1; + strcpy( DEATH_MATCH_LEVEL, strlwr( filelist[DEATH_MATCH_EPISODE][0].name ) ); + } + strcpy( text, "episode: " ); + if ( DEATH_MATCH_EPISODE > 0 ) strcat( text, strlwr( dirlist[DEATH_MATCH_EPISODE - 1].name ) ); + else strcat( text, "dm levels" ); + strcpy(multip_opt_text[2] ,text ); + strcpy( text, "level: " ); + if ( KILLING_MODE == DEATHMATCH ) + strcat( text, DEATH_MATCH_LEVEL ); + strcpy(multip_opt_text[3] , text ); + strcpy( text, "game type: " ); + if ( GAME_MODE == SPLIT_SCREEN ) + strcat( text, "split screen" ); + if ( GAME_MODE == NETWORK ) + strcat( text, "network" ); + strcpy(multip_opt_text[4], text ); + strcpy( text, "game mode: " ); + if ( KILLING_MODE == COOPERATIVE ) + strcat( text, "cooperative" ); + if ( KILLING_MODE == DEATHMATCH ) + strcat( text, "deathmatch" ); + strcpy(multip_opt_text[5],text ); + for ( a = 0; a < num_multip_options; a ++ ) + { + if ( a == selected ) + { + FONT_NUM = 0; + writefonts2( 45, ( 100 - yoffs ) + ( a*15 ), multip_opt_text[a], 1 ); + } + else + { + FONT_NUM = 2; + writefonts2( 45, ( 100 - yoffs ) + ( a*15 ), multip_opt_text[a], 1 ); + } + } + if ( first == 1 ) + { + fadein( virbuff, pal ); first = 0; + } + memcpy( screen, virbuff, 64000 ); + while ( !k.state[1]&&!k.state[94]&&!k.state[99]&&!k.state[28] ) + { + if ( clock() != oclock ) + { + oclock = clock(); + draw_ball( 20, ( 98 - yoffs ) + ( selected*15 ), cnt ); + cnt ++; + if ( cnt > 23 ) cnt = 0; + } + }; + MIDASplaySample( klikwav, MIDAS_CHANNEL_AUTO, 0, 22500, EFFECT_VOLUME, MIDAS_PAN_MIDDLE ); + if ( k.state[94] ) + { + selected --;if ( selected < 0 ) selected = num_multip_options - 1; k.state[94] = 0; + } + if ( k.state[99] ) + { + selected ++;if ( selected >= num_multip_options ) selected = 0; k.state[99] = 0; + } + if ( k.state[28] ) + { + k.state[28] = 0; + if ( selected == 0 ) + { + if (KILLING_MODE == DEATHMATCH) + { + if ( GAME_MODE == NETWORK ) + if (deathmatch_options()) + { + NETWORK_MODE = SERVER; + setup_ipx(); + game(); + desetup_ipx(); + quit = 1; + dontfade = 1; + } else multip_options_scr( num_multip_options, "efps\\cool.efp" ); + if ( GAME_MODE == SPLIT_SCREEN ) + if (deathmatch_options()) + { + game(); + quit = 1; + dontfade = 1; + } else multip_options_scr( num_multip_options, "efps\\cool.efp" ); + } else + { + if ( GAME_MODE == NETWORK) + { + NETWORK_MODE = SERVER; + setup_ipx(); + game(); + desetup_ipx(); + quit = 1; + dontfade = 1; + } + if ( GAME_MODE == SPLIT_SCREEN ) + { + save_options(); + game(); + quit = 1; + dontfade = 1; + } + } + } + if ( selected == 1 ) + { + + GAME_MODE = NETWORK; + NETWORK_MODE = CLIENT; + + k.getch(); + + setup_ipx(); + save_options(); + if (select_server()) game(); + desetup_ipx(); + + quit = 1; + dontfade = 1; + + } + if ( selected == 2 ) + { + DEATH_MATCH_EPISODE ++;if ( DEATH_MATCH_EPISODE > dirs ) DEATH_MATCH_EPISODE = 0; strcpy( DEATH_MATCH_LEVEL, strlwr( filelist[DEATH_MATCH_EPISODE][0].name ) ); + } + if ( selected == 3 ) if ( KILLING_MODE == DEATHMATCH ) + { + choose_load_file( DEATH_MATCH_LEVEL, DEATH_MATCH_EPISODE ); multip_options_scr( num_multip_options, "efps\\cool.efp" ); + } + if ( selected == 4 ) + { + if (GAME_MODE==SPLIT_SCREEN) + { + if (ipxavail) GAME_MODE=NETWORK; + } + else GAME_MODE=SPLIT_SCREEN; + saved_game_mode=GAME_MODE; + } + if ( selected == 5 ) + { + KILLING_MODE ++;if ( KILLING_MODE > 1 ) KILLING_MODE = 0; + saved_killing_mode=KILLING_MODE; + } + if ( selected == 6 ) + { + quit = 1; + } + } + if ( k.state[1] ) + { + quit = 1;k.state[1] = 0; + } + } + if ( !dontfade ) fadeout( virbuff, pal ); + save_options(); +} + +void options() +{ + int yoffs = ( 15*num_options ) / 2, a, cnt = 0, selected = 0, quit = 0, oclock; + fadeout( virbuff, pal ); + options_scr( num_options, "efps\\cool.efp" ); + k.state[28] = 0; + while( !quit ) + { + memcpy( virbuff, picture, 64000 ); + for ( a = 0; a < num_options; a ++ ) + { + if ( a == selected ) + { + FONT_NUM = 0; + writefonts2( 160 - ( str_length( opt_text[a] ) / 2 ), ( 100 - yoffs ) + ( a*15 ), opt_text[a], 1 ); + } + else + { + FONT_NUM = 2; + writefonts2( 160 - ( str_length( opt_text[a] ) / 2 ), ( 100 - yoffs ) + ( a*15 ), opt_text[a], M_RED ); + } + } + if ( first == 1 ) + { + fadein( virbuff, pal ); first = 0; + } + memcpy( screen, virbuff, 64000 ); + while ( !k.state[1]&&!k.state[94]&&!k.state[99]&&!k.state[28] ) + { + if ( clock() != oclock ) + { + oclock = clock(); + draw_ball( 50, ( 98 - yoffs ) + ( selected*15 ), cnt ); + draw_ball( 320 - 70, ( 98 - yoffs ) + ( selected*15 ), cnt ); + cnt ++; + if ( cnt > 23 ) cnt = 0; + } + }; + MIDASplaySample( klikwav, MIDAS_CHANNEL_AUTO, 0, 22500, EFFECT_VOLUME, MIDAS_PAN_MIDDLE ); + if ( k.state[94] ) + { + selected --;if ( selected < 0 ) selected = num_options - 1; k.state[94] = 0; + } + if ( k.state[99] ) + { + selected ++;if ( selected >= num_options ) selected = 0; k.state[99] = 0; + } + if ( k.state[28] ) + { + if ( selected == 0 ) + { + player_options(); options_scr( num_options, "efps\\cool.efp" ); + } + if ( selected == 1 ) + { + game_options(); options_scr( num_options, "efps\\cool.efp" ); + } + if ( selected == 2 ) + { + sound_options(); options_scr( num_options, "efps\\cool.efp" ); + } + if ( selected == 3 ) + { + quit = 1; + } + } + if ( k.state[1] ) + { + quit = 1;k.state[1] = 0; + } + } + save_options(); + fadeout( virbuff, pal ); +} + diff --git a/SRC/OPTIONS.CPP b/SRC/OPTIONS.CPP new file mode 100644 index 0000000..4501106 --- /dev/null +++ b/SRC/OPTIONS.CPP @@ -0,0 +1,768 @@ +#include < stdlib.h > +#include < stdio.h > +#include < gfunc.h > +#include < string.h > +#include < dos.h > +#include < conio.h > +#include "efp/efp.h" +#include "defines.h" +#include "types.h" +#include "globvar.h" +#include "miscfunc.h" +#include "fade.h" +#include "draw.h" +#include "write.h" + +extern void setup_ipx(); +extern void desetup_ipx(); +extern void game(); +extern int select_server(); + +void save_options() +{ + FILE *cfg; + cfg = fopen( "options.cfg", "wb" ); + fwrite( &keys1, sizeof( class Keys ), 1, cfg ); + fwrite( &keys2, sizeof( class Keys ), 1, cfg ); + fwrite( name1, sizeof( name1 ), 1, cfg ); + fwrite( name2, sizeof( name2 ), 1, cfg ); + fwrite( &DARK_MODE, sizeof( DARK_MODE ), 1, cfg ); + fwrite( &LIGHT_EFFECTS, sizeof( LIGHT_EFFECTS ), 1, cfg ); + fwrite( &SHADOWS, sizeof( SHADOWS ), 1, cfg ); + fwrite( &MUSIC_VOLUME, sizeof( MUSIC_VOLUME ), 1, cfg ); + fwrite( &EFFECT_VOLUME, sizeof( EFFECT_VOLUME ), 1, cfg ); + fwrite( &ENEMIES_ON_GAME, sizeof( ENEMIES_ON_GAME ), 1, cfg ); + fwrite( DEATH_MATCH_LEVEL, sizeof( DEATH_MATCH_LEVEL ), 1, cfg ); + fwrite( &DEATH_MATCH_EPISODE, sizeof( DEATH_MATCH_EPISODE ), 1, cfg ); + fwrite( &DEATH_MATCH_SPEED, sizeof( DEATH_MATCH_SPEED ), 1, cfg ); + fwrite( &saved_killing_mode, sizeof( saved_killing_mode ), 1, cfg ); + fwrite( &saved_game_mode, sizeof( saved_game_mode ), 1, cfg ); + fclose( cfg ); +} + +void load_options() +{ + FILE *cfg; + cfg = fopen( "options.cfg", "rb" ); + if ( cfg ) + { + fread( &keys1, sizeof( class Keys ), 1, cfg ); + fread( &keys2, sizeof( class Keys ), 1, cfg ); + fread( name1, sizeof( name1 ), 1, cfg ); + fread( name2, sizeof( name2 ), 1, cfg ); + fread( &DARK_MODE, sizeof( DARK_MODE ), 1, cfg ); + fread( &LIGHT_EFFECTS, sizeof( LIGHT_EFFECTS ), 1, cfg ); + fread( &SHADOWS, sizeof( SHADOWS ), 1, cfg ); + fread( &MUSIC_VOLUME, sizeof( MUSIC_VOLUME ), 1, cfg ); + fread( &EFFECT_VOLUME, sizeof( EFFECT_VOLUME ), 1, cfg ); + fread( &ENEMIES_ON_GAME, sizeof( ENEMIES_ON_GAME ), 1, cfg ); + fread( DEATH_MATCH_LEVEL, sizeof( DEATH_MATCH_LEVEL ), 1, cfg ); + fread( &DEATH_MATCH_EPISODE, sizeof( DEATH_MATCH_EPISODE ), 1, cfg ); + fread( &DEATH_MATCH_SPEED, sizeof( DEATH_MATCH_SPEED ), 1, cfg ); + fread( &saved_killing_mode, sizeof( saved_killing_mode ), 1, cfg ); + fread( &saved_game_mode, sizeof( saved_game_mode ), 1, cfg ); + fclose( cfg ); + } +} + +int choose_load_file( char *name, int episode ) +{ + int a, b, sel = 0, pos = 0, cnt = 0, oclock = 0; + int files = files_in_episode[episode]; + load_efp( "efps\\cool.efp", picture, 0 ); + draw_box1( 60, 10, 320 - 60, 190, 15 ); + first = 1; + while ( !k.state[1]&&!k.state[28] ) + { + memcpy( virbuff, picture, 64000 ); + FONT_NUM = 0; + writefonts2( 160 - ( str_length( "select level:" ) >> 1 ), 20, "select level:", 1 ); + b = files; + if ( b > 15 ) b = 15; + FONT_NUM = 1; + for ( a = 0; a < b; a ++ ) + if ( a + pos == sel ) + writefonts( 160 - ( str_length( strlwr( filelist[episode][a + pos].name ) ) >> 1 ), 50 + a*8, strlwr( filelist[episode][a + pos].name ), M_YELLOW ); + else + writefonts( 160 - ( str_length( strlwr( filelist[episode][a + pos].name ) ) >> 1 ), 50 + a*8, strlwr( filelist[episode][a + pos].name ), M_BLUE ); + if ( pos > 0 ) writefonts( 156, 42, "", M_BLUE ); + if ( files > 15 ) if ( pos < files - 15 ) writefonts( 156, 50 + 15*8, "", M_BLUE ); + if ( first == 1 ) + { + fadein( virbuff, pal ); first = 0; + } + memcpy( screen, virbuff, 64000 ); + while( !k.state[94]&&!k.state[99]&&!k.state[28] ) + if ( clock() != oclock ) + { + oclock = clock(); + draw_ball( 65, 46 + ( ( sel - pos ) *8 ), cnt ); + draw_ball( 320 - 85, 46 + ( ( sel - pos ) *8 ), cnt ); + cnt ++; + if ( cnt > 23 ) cnt = 0; + } + if ( k.state[94] ) + { + if ( sel > 0 ) sel --;k.state[94] = 0; + } + if ( k.state[99] ) + { + if ( sel < files - 1 ) sel ++;k.state[99] = 0; + } + pos = sel - 8; + if ( pos < 0 ) pos = 0; + if ( files > 15 ) if ( pos > files - 15 ) pos = files - 15; + if ( files <= 15 ) if ( pos > 0 ) pos = 0; + } + a = 0; + strcpy( name, filelist[episode][sel].name ); a = 1; k.state[28] = 0; + return( a ); +} + +int choose_episode() +{ + int a, b, sel = 0, pos = 0, cnt = 0, oclock = 0; + char text[20]; + load_efp( "efps\\cool.efp", picture, 0 ); + draw_box1( 60, 10, 320 - 60, 190, 15 ); + first = 1; + k.state[1] = 0; + k.state[28] = 0; + fadeout( virbuff, pal ); + while ( !k.state[1]&&!k.state[28] ) + { + memcpy( virbuff, picture, 64000 ); + FONT_NUM = 0; + writefonts2( 160 - ( str_length( "select episode" ) >> 1 ), 20, "select episode", 1 ); + b = dirs; + if ( b > 7 ) b = 7; + for ( a = 0; a < b; a ++ ) + { + if ( a + pos == sel ) + { + FONT_NUM = 0; + writefonts2( 160 - ( str_length( strlwr( dirlist[a + pos].name ) ) >> 1 ), 50 + a*16, strlwr( dirlist[a + pos].name ), 1 ); + } + else + { + FONT_NUM = 2; + writefonts2( 160 - ( str_length( strlwr( dirlist[a + pos].name ) ) >> 1 ), 50 + a*16, strlwr( dirlist[a + pos].name ), 1 ); + } + } + FONT_NUM = 1; + itoa( files_in_episode[sel + 1], text, 10 ); + strcat( text, " levels" ); + writefonts( 70, 175, text, M_BLUE ); + if ( first == 1 ) + { + fadein( virbuff, pal ); first = 0; + } + memcpy( screen, virbuff, 64000 ); + while( !k.state[94]&&!k.state[99]&&!k.state[28] ) + if ( clock() != oclock ) + { + oclock = clock(); + draw_ball( 65, 48 + ( ( sel - pos ) *16 ), cnt ); + draw_ball( 320 - 85, 48 + ( ( sel - pos ) *16 ), cnt ); + cnt ++; + if ( cnt > 23 ) cnt = 0; + } + if ( k.state[94] ) + { + if ( sel > 0 ) sel --;k.state[94] = 0; + } + if ( k.state[99] ) + { + if ( sel < dirs - 1 ) sel ++;k.state[99] = 0; + } + pos = sel - 3; + if ( pos < 0 ) pos = 0; + if ( dirs > 7 ) if ( pos > dirs - 7 ) pos = dirs - 7; + if ( dirs <= 7 ) if ( pos > 0 ) pos = 0; + } + k.state[28] = 0; + return( sel ); +} + +void options_scr( int opt, char *filename ) +{ + load_efp( filename, picture, 0 ); + load_efp_pal( "efps\\ware.efp", pal ); + draw_box1( 45, 90 - ( ( opt*15 ) / 2 ), 320 - 45, 110 + ( ( opt*15 ) / 2 ), 13 ); + first = 1; +} + +void multip_options_scr( int opt, char *filename ) +{ + load_efp( filename, picture, 0 ); + load_efp_pal( "efps\\ware.efp", pal ); + draw_box1( 10, 90 - ( ( opt*15 ) / 2 ), 320 - 10, 110 + ( ( opt*15 ) / 2 ), 13 ); + first = 1; +} + +void player_options() +{ + int yoffs = ( 15*num_player_options ) / 2, a, cnt = 0, selected = 0, quit = 0, oclock; + fadeout( virbuff, pal ); + options_scr( num_player_options, "efps\\cool.efp" ); + k.state[28] = 0; + while( !quit ) + { + memcpy( virbuff, picture, 64000 ); + for ( a = 0; a < num_player_options; a ++ ) + { + if ( a == selected ) + { + FONT_NUM = 0; + writefonts2( 160 - ( str_length( player_opt_text[a] ) / 2 ), ( 100 - yoffs ) + ( a*15 ), player_opt_text[a], 1 ); + } + else + { + FONT_NUM = 2; + writefonts2( 160 - ( str_length( player_opt_text[a] ) / 2 ), ( 100 - yoffs ) + ( a*15 ), player_opt_text[a], M_RED ); + } + } + if ( first == 1 ) + { + fadein( virbuff, pal ); first = 0; + } + memcpy( screen, virbuff, 64000 ); + while ( !k.state[1]&&!k.state[94]&&!k.state[99]&&!k.state[28] ) + { + if ( clock() != oclock ) + { + oclock = clock(); + draw_ball( 65, ( 98 - yoffs ) + ( selected*15 ), cnt ); + draw_ball( 320 - 85, ( 98 - yoffs ) + ( selected*15 ), cnt ); + cnt ++; + if ( cnt > 23 ) cnt = 0; + } + }; + MIDASplaySample( samplep[KLIKWAV], MIDAS_CHANNEL_AUTO, 0, 22500, EFFECT_VOLUME, MIDAS_PAN_MIDDLE ); + if ( k.state[94] ) + { + selected --;if ( selected < 0 ) selected = num_player_options - 1; k.state[94] = 0; + } + if ( k.state[99] ) + { + selected ++;if ( selected >= num_player_options ) selected = 0; k.state[99] = 0; + } + if ( k.state[28] ) + { + if ( selected == 0 ) + { + keys1.change(); options_scr( num_player_options, "efps\\cool.efp" ); + } + if ( selected == 1 ) + { + keys2.change(); options_scr( num_player_options, "efps\\cool.efp" ); + } + if ( selected == 2 ) + { + change_name( 1 ); options_scr( num_player_options, "efps\\cool.efp" ); + } + if ( selected == 3 ) + { + change_name( 2 ); options_scr( num_player_options, "efps\\cool.efp" ); + } + if ( selected == 4 ) + { + quit = 1; + } + } + if ( k.state[1] ) + { + quit = 1;k.state[1] = 0; + } + } + fadeout( virbuff, pal ); +} + +void game_options() +{ + int yoffs = ( 15*num_game_options ) / 2, a, cnt = 0, selected = 0, quit = 0, oclock; + fadeout( virbuff, pal ); + options_scr( num_game_options, "efps\\cool.efp" ); + k.state[28] = 0; + while( !quit ) + { + memcpy( virbuff, picture, 64000 ); + if ( DARK_MODE ) strcpy(game_opt_text[0],"darkness on"); + if ( !DARK_MODE ) strcpy(game_opt_text[0],"darkness off" ); + if ( LIGHT_EFFECTS ) strcpy(game_opt_text[1],"lights on" ); + if ( !LIGHT_EFFECTS ) strcpy(game_opt_text[1],"lights off" ); + if ( SHADOWS ) strcpy(game_opt_text[2],"shadows on" ); + if ( !SHADOWS ) strcpy(game_opt_text[2],"shadows off" ); + for ( a = 0; a < num_game_options; a ++ ) + { + if ( a == selected ) + { + FONT_NUM = 0; + writefonts2( 160 - ( str_length( game_opt_text[a] ) / 2 ), ( 100 - yoffs ) + ( a*15 ), game_opt_text[a], 1 ); + } + else + { + FONT_NUM = 2; + writefonts2( 160 - ( str_length( game_opt_text[a] ) / 2 ), ( 100 - yoffs ) + ( a*15 ), game_opt_text[a], M_RED ); + } + } + if ( first == 1 ) + { + fadein( virbuff, pal ); first = 0; + } + memcpy( screen, virbuff, 64000 ); + while ( !k.state[1]&&!k.state[94]&&!k.state[99]&&!k.state[28] ) + { + if ( clock() != oclock ) + { + oclock = clock(); + draw_ball( 65, ( 98 - yoffs ) + ( selected*15 ), cnt ); + draw_ball( 320 - 85, ( 98 - yoffs ) + ( selected*15 ), cnt ); + cnt ++; + if ( cnt > 23 ) cnt = 0; + } + }; + MIDASplaySample( samplep[KLIKWAV], MIDAS_CHANNEL_AUTO, 0, 22500, EFFECT_VOLUME, MIDAS_PAN_MIDDLE ); + if ( k.state[94] ) + { + selected --;if ( selected < 0 ) selected = num_game_options - 1; k.state[94] = 0; + } + if ( k.state[99] ) + { + selected ++;if ( selected >= num_game_options ) selected = 0; k.state[99] = 0; + } + if ( k.state[28] ) + { + if ( selected == 0 ) + { + if ( !DARK_MODE ) DARK_MODE = 1;else DARK_MODE = 0;k.state[28] = 0; + } + if ( selected == 1 ) + { + if ( !LIGHT_EFFECTS ) LIGHT_EFFECTS = 1;else LIGHT_EFFECTS = 0;k.state[28] = 0; + } + if ( selected == 2 ) + { + if ( !SHADOWS ) SHADOWS = 1;else SHADOWS = 0;k.state[28] = 0; + } + if ( selected == 3 ) + { + quit = 1; + } + } + if ( k.state[1] ) + { + quit = 1;k.state[1] = 0; + } + } + fadeout( virbuff, pal ); +} + +void sound_options() +{ + int yoffs = ( 15*num_sound_options ) / 2, a, cnt = 0, selected = 0, quit = 0, oclock; + char text[30], text2[30]; + fadeout( virbuff, pal ); + options_scr( num_sound_options, "efps\\subbari.efp" ); + k.state[28] = 0; + while( !quit ) + { + memcpy( virbuff, picture, 64000 ); + strcpy( text, "music volume " ); + itoa( ( float ) MUSIC_VOLUME / 63*100, text2, 10 ); + strcat( text2, "%" ); + strcat( text, text2 ); + strcpy(sound_opt_text[0],text ); + strcpy( text, "effect volume " ); + itoa( ( float ) EFFECT_VOLUME / 63*100, text2, 10 ); + strcat( text2, "%" ); + strcat( text, text2 ); + strcpy(sound_opt_text[1],text ); + for ( a = 0; a < num_sound_options; a ++ ) + { + if ( a == selected ) + { + FONT_NUM = 0; + writefonts2( 160 - ( str_length( sound_opt_text[a] ) / 2 ), ( 100 - yoffs ) + ( a*15 ), sound_opt_text[a], 1 ); + } + else + { + FONT_NUM = 2; + writefonts2( 160 - ( str_length( sound_opt_text[a] ) / 2 ), ( 100 - yoffs ) + ( a*15 ), sound_opt_text[a], M_RED ); + } + } + if ( first == 1 ) + { + fadein( virbuff, pal ); first = 0; + } + memcpy( screen, virbuff, 64000 ); + while ( !k.state[1]&&!k.state[94]&&!k.state[99]&&!k.state[96]&&!k.state[97]&&!k.state[28] ) + { + if ( clock() != oclock ) + { + oclock = clock(); + draw_ball( 55, ( 98 - yoffs ) + ( selected*15 ), cnt ); + draw_ball( 320 - 75, ( 98 - yoffs ) + ( selected*15 ), cnt ); + cnt ++; + if ( cnt > 23 ) cnt = 0; + } + } + MIDASplaySample( samplep[KLIKWAV], MIDAS_CHANNEL_AUTO, 0, 22500, EFFECT_VOLUME, MIDAS_PAN_MIDDLE ); + if ( k.state[94] ) + { + selected --;if ( selected < 0 ) selected = num_sound_options - 1; k.state[94] = 0; + } + if ( k.state[99] ) + { + selected ++;if ( selected >= num_sound_options ) selected = 0; k.state[99] = 0; + } + if ( k.state[96] ) + { + if ( selected == 0 ) MUSIC_VOLUME -= 5; + if ( selected == 1 ) EFFECT_VOLUME -= 5; + if ( MUSIC_VOLUME < 0 ) MUSIC_VOLUME = 0; + if ( EFFECT_VOLUME < 0 ) EFFECT_VOLUME = 0; + if ( selected == 0 ) MIDASsetMusicVolume( ph, MUSIC_VOLUME ); + k.state[96] = 0; + } + if ( k.state[97] ) + { + if ( selected == 0 ) MUSIC_VOLUME += 5; + if ( selected == 1 ) EFFECT_VOLUME += 5; + if ( MUSIC_VOLUME > 63 ) MUSIC_VOLUME = 63; + if ( EFFECT_VOLUME > 63 ) EFFECT_VOLUME = 63; + if ( selected == 0 ) MIDASsetMusicVolume( ph, MUSIC_VOLUME ); + k.state[97] = 0; + } + if ( k.state[28] ) if ( selected == 2 ) + { + quit = 1; + } + if ( k.state[1] ) + { + quit = 1;k.state[1] = 0; + } + } + fadeout( virbuff, pal ); +} + +int deathmatch_options() +{ + int start=0; + int yoffs = ( 15*num_deathmatch_options ) / 2, a, cnt = 0, selected = 0, quit = 0, oclock; + fadeout( virbuff, pal ); + options_scr( num_deathmatch_options, "efps\\cool.efp" ); + k.state[28] = 0; + while( !quit ) + { + memcpy( virbuff, picture, 64000 ); + if ( DEATH_MATCH_SPEED == 2 ) + strcpy(deathmatch_opt_text[1],"normal moving"); + else strcpy(deathmatch_opt_text[1],"fast moving"); + if ( ENEMIES_ON_GAME ) + strcpy(deathmatch_opt_text[2],"enemies on" ); + else strcpy(deathmatch_opt_text[2],"enemies off" ); + for ( a = 0; a < num_deathmatch_options; a ++ ) + { + if ( a == selected ) + { + FONT_NUM = 0; + writefonts2( 160 - ( str_length( deathmatch_opt_text[a] ) / 2 ), ( 100 - yoffs ) + ( a*15 ), deathmatch_opt_text[a], 1 ); + } + else + { + FONT_NUM = 2; + writefonts2( 160 - ( str_length( deathmatch_opt_text[a] ) / 2 ), ( 100 - yoffs ) + ( a*15 ), deathmatch_opt_text[a], 1 ); + } + } + if ( first == 1 ) + { + fadein( virbuff, pal ); first = 0; + } + memcpy( screen, virbuff, 64000 ); + while ( !k.state[1]&&!k.state[94]&&!k.state[99]&&!k.state[28] ) + { + if ( clock() != oclock ) + { + oclock = clock(); + draw_ball( 50, ( 98 - yoffs ) + ( selected*15 ), cnt ); + draw_ball( 320 - 70, ( 98 - yoffs ) + ( selected*15 ), cnt ); + cnt ++; + if ( cnt > 23 ) cnt = 0; + } + }; + MIDASplaySample( samplep[KLIKWAV], MIDAS_CHANNEL_AUTO, 0, 22500, EFFECT_VOLUME, MIDAS_PAN_MIDDLE ); + if ( k.state[94] ) + { + selected --;if ( selected < 0 ) selected = num_deathmatch_options - 1; k.state[94] = 0; + } + if ( k.state[99] ) + { + selected ++;if ( selected >= num_deathmatch_options ) selected = 0; k.state[99] = 0; + } + if ( k.state[28] ) + { + k.state[28] = 0; + if ( selected == 0 ) { quit = 1;start = 1;} + if ( selected == 1 ) if ( DEATH_MATCH_SPEED == 2 ) DEATH_MATCH_SPEED = 3;else DEATH_MATCH_SPEED = 2; + if ( selected == 2 ) if ( ENEMIES_ON_GAME ) ENEMIES_ON_GAME = 0;else ENEMIES_ON_GAME = 1; + if ( selected == 3 ) quit = 1; + + } + if ( k.state[1] ) + { + quit = 1;k.state[1] = 0; + } + } + if (! start) fadeout( virbuff, pal ); + save_options(); + return(start); +} + +void multiplayer_options() +{ + int yoffs = ( 15*num_multip_options ) / 2, a, cnt = 0, selected = 0, quit = 0, oclock; + int dontfade = 0; + char text[50]; + fadeout( virbuff, pal ); + multip_options_scr( num_multip_options, "efps\\cool.efp" ); + k.state[28] = 0; + GAME_MODE = saved_game_mode; + KILLING_MODE = saved_killing_mode; + while( !quit ) + { + memcpy( virbuff, picture, 64000 ); + if ( KILLING_MODE == COOPERATIVE &&DEATH_MATCH_EPISODE == 0 ) + { + DEATH_MATCH_EPISODE = 1; + strcpy( DEATH_MATCH_LEVEL, strlwr( filelist[DEATH_MATCH_EPISODE][0].name ) ); + } + strcpy( text, "episode: " ); + if ( DEATH_MATCH_EPISODE > 0 ) strcat( text, strlwr( dirlist[DEATH_MATCH_EPISODE - 1].name ) ); + else strcat( text, "dm levels" ); + strcpy(multip_opt_text[2] ,text ); + strcpy( text, "level: " ); + if ( KILLING_MODE == DEATHMATCH ) + strcat( text, DEATH_MATCH_LEVEL ); + strcpy(multip_opt_text[3] , text ); + strcpy( text, "game type: " ); + if ( GAME_MODE == SPLIT_SCREEN ) + strcat( text, "split screen" ); + if ( GAME_MODE == NETWORK ) + strcat( text, "network" ); + strcpy(multip_opt_text[4], text ); + strcpy( text, "game mode: " ); + if ( KILLING_MODE == COOPERATIVE ) + strcat( text, "cooperative" ); + if ( KILLING_MODE == DEATHMATCH ) + strcat( text, "deathmatch" ); + strcpy(multip_opt_text[5],text ); + for ( a = 0; a < num_multip_options; a ++ ) + { + if ( a == selected ) + { + FONT_NUM = 0; + writefonts2( 45, ( 100 - yoffs ) + ( a*15 ), multip_opt_text[a], 1 ); + } + else + { + FONT_NUM = 2; + writefonts2( 45, ( 100 - yoffs ) + ( a*15 ), multip_opt_text[a], 1 ); + } + } + if ( first == 1 ) + { + fadein( virbuff, pal ); first = 0; + } + memcpy( screen, virbuff, 64000 ); + while ( !k.state[1]&&!k.state[94]&&!k.state[99]&&!k.state[28] ) + { + if ( clock() != oclock ) + { + oclock = clock(); + draw_ball( 20, ( 98 - yoffs ) + ( selected*15 ), cnt ); + cnt ++; + if ( cnt > 23 ) cnt = 0; + } + }; + MIDASplaySample( samplep[KLIKWAV], MIDAS_CHANNEL_AUTO, 0, 22500, EFFECT_VOLUME, MIDAS_PAN_MIDDLE ); + if ( k.state[94] ) + { + selected --;if ( selected < 0 ) selected = num_multip_options - 1; k.state[94] = 0; + } + if ( k.state[99] ) + { + selected ++;if ( selected >= num_multip_options ) selected = 0; k.state[99] = 0; + } + if ( k.state[28] ) + { + k.state[28] = 0; + if ( selected == 0 ) + { + if (KILLING_MODE == DEATHMATCH) + { + if ( GAME_MODE == NETWORK ) + if (deathmatch_options()) + { + NETWORK_MODE = SERVER; + setup_ipx(); + game(); + desetup_ipx(); + quit = 1; + dontfade = 1; + } else multip_options_scr( num_multip_options, "efps\\cool.efp" ); + if ( GAME_MODE == SPLIT_SCREEN ) + if (deathmatch_options()) + { + game(); + quit = 1; + dontfade = 1; + } else multip_options_scr( num_multip_options, "efps\\cool.efp" ); + } else + { + if ( GAME_MODE == NETWORK) + { + NETWORK_MODE = SERVER; + setup_ipx(); + game(); + desetup_ipx(); + quit = 1; + dontfade = 1; + } + if ( GAME_MODE == SPLIT_SCREEN ) + { + save_options(); + game(); + quit = 1; + dontfade = 1; + } + } + } + if ( selected == 1 ) + { + + GAME_MODE = NETWORK; + NETWORK_MODE = CLIENT; + + k.getch(); + + setup_ipx(); + save_options(); + if (select_server()) game(); + desetup_ipx(); + + quit = 1; + dontfade = 1; + + } + if ( selected == 2 ) + { + DEATH_MATCH_EPISODE ++;if ( DEATH_MATCH_EPISODE > dirs ) DEATH_MATCH_EPISODE = 0; strcpy( DEATH_MATCH_LEVEL, strlwr( filelist[DEATH_MATCH_EPISODE][0].name ) ); + } + if ( selected == 3 ) if ( KILLING_MODE == DEATHMATCH ) + { + choose_load_file( DEATH_MATCH_LEVEL, DEATH_MATCH_EPISODE ); multip_options_scr( num_multip_options, "efps\\cool.efp" ); + } + if ( selected == 4 ) + { + if (GAME_MODE==SPLIT_SCREEN) + { + if (ipxavail) GAME_MODE=NETWORK; + } + else GAME_MODE=SPLIT_SCREEN; + saved_game_mode=GAME_MODE; + } + if ( selected == 5 ) + { + KILLING_MODE ++;if ( KILLING_MODE > 1 ) KILLING_MODE = 0; + saved_killing_mode=KILLING_MODE; + } + if ( selected == 6 ) + { + quit = 1; + } + } + if ( k.state[1] ) + { + quit = 1;k.state[1] = 0; + } + } + if ( !dontfade ) fadeout( virbuff, pal ); + save_options(); +} + +void options() +{ + int yoffs = ( 15*num_options ) / 2, a, cnt = 0, selected = 0, quit = 0, oclock; + fadeout( virbuff, pal ); + options_scr( num_options, "efps\\cool.efp" ); + k.state[28] = 0; + while( !quit ) + { + memcpy( virbuff, picture, 64000 ); + for ( a = 0; a < num_options; a ++ ) + { + if ( a == selected ) + { + FONT_NUM = 0; + writefonts2( 160 - ( str_length( opt_text[a] ) / 2 ), ( 100 - yoffs ) + ( a*15 ), opt_text[a], 1 ); + } + else + { + FONT_NUM = 2; + writefonts2( 160 - ( str_length( opt_text[a] ) / 2 ), ( 100 - yoffs ) + ( a*15 ), opt_text[a], M_RED ); + } + } + if ( first == 1 ) + { + fadein( virbuff, pal ); first = 0; + } + memcpy( screen, virbuff, 64000 ); + while ( !k.state[1]&&!k.state[94]&&!k.state[99]&&!k.state[28] ) + { + if ( clock() != oclock ) + { + oclock = clock(); + draw_ball( 50, ( 98 - yoffs ) + ( selected*15 ), cnt ); + draw_ball( 320 - 70, ( 98 - yoffs ) + ( selected*15 ), cnt ); + cnt ++; + if ( cnt > 23 ) cnt = 0; + } + }; + MIDASplaySample( samplep[KLIKWAV], MIDAS_CHANNEL_AUTO, 0, 22500, EFFECT_VOLUME, MIDAS_PAN_MIDDLE ); + if ( k.state[94] ) + { + selected --;if ( selected < 0 ) selected = num_options - 1; k.state[94] = 0; + } + if ( k.state[99] ) + { + selected ++;if ( selected >= num_options ) selected = 0; k.state[99] = 0; + } + if ( k.state[28] ) + { + if ( selected == 0 ) + { + player_options(); options_scr( num_options, "efps\\cool.efp" ); + } + if ( selected == 1 ) + { + game_options(); options_scr( num_options, "efps\\cool.efp" ); + } + if ( selected == 2 ) + { + sound_options(); options_scr( num_options, "efps\\cool.efp" ); + } + if ( selected == 3 ) + { + quit = 1; + } + } + if ( k.state[1] ) + { + quit = 1;k.state[1] = 0; + } + } + save_options(); + fadeout( virbuff, pal ); +} + diff --git a/SRC/OPTIONS.H b/SRC/OPTIONS.H new file mode 100644 index 0000000..39bc430 --- /dev/null +++ b/SRC/OPTIONS.H @@ -0,0 +1,16 @@ +#ifndef __TK___OPTIONS__ +#define __TK___OPTIONS__ + +void save_options(); +void load_options(); +int choose_episode(); +int choose_load_file( char *name, int episode ); +void options_scr( int opt, char *filename ); +void multip_options_scr( int opt, char *filename ); +void player_options(); +void game_options(); +void sound_options(); +void deathmatch_options(); +void multiplayer_options(); +void options(); +#endif diff --git a/SRC/OPTIONS.OBJ b/SRC/OPTIONS.OBJ new file mode 100644 index 0000000..200ae17 Binary files /dev/null and b/SRC/OPTIONS.OBJ differ diff --git a/SRC/RGBHSL.C b/SRC/RGBHSL.C new file mode 100644 index 0000000..0c7aa70 --- /dev/null +++ b/SRC/RGBHSL.C @@ -0,0 +1,75 @@ +#include < math.h > +#define max( a, b ) ( a > b?a:b ) +#define min( a, b ) ( a < b?a:b ) +void rgb2hsl( float r, float g, float b, float *H, float *S, float *L ) +{ + float delta; + float cmax; + float cmin; + r /= 63; + g /= 63; + b /= 63; + cmax = max( r, max( g, b ) ); + cmin = min( r, min( g, b ) ); +* L = ( cmax + cmin ) / 2.0; + if( cmax == cmin ) + { + *S = 0; +* H = 0;// it's really undefined + + } + else + { + if( *L < 0.5 ) +* S = ( cmax - cmin ) / ( cmax + cmin ); + else +* S = ( cmax - cmin ) / ( 2.0 - cmax - cmin ); + delta = cmax - cmin; + if( r == cmax ) +* H = ( g - b ) / delta; + else if( g == cmax ) +* H = 2.0 + ( b - r ) / delta; + else +* H = 4.0 + ( r - g ) / delta; +* H /= 6.0; + if( *H < 0.0 ) +* H += 1; + } +} + +static float HuetoRGB( float m1, float m2, float h ) +{ + if( h < 0 ) h += 1.0; + if( h > 1 ) h -= 1.0; + if( 6.0*h < 1 ) + return ( m1 + ( m2 - m1 ) *h*6.0 ); + if( 2.0*h < 1 ) + return m2; + if( 3.0*h < 2.0 ) + return ( m1 + ( m2 - m1 ) *( ( 2.0 / 3.0 ) - h ) *6.0 ); + return m1; +} + +void hsl2rgb( float H, float S, float L, float *R, float *G, float *B ) +{ + float m1, m2; + if( S == 0 ) + { + *R = *G = *B = L; + } + else + { + if( L <= 0.5 ) + m2 = L*( 1.0 + S ); + else + m2 = L + S - L*S; + m1 = 2.0*L - m2; +* R = HuetoRGB( m1, m2, H + 1.0 / 3.0 ); +* G = HuetoRGB( m1, m2, H ); +* B = HuetoRGB( m1, m2, H - 1.0 / 3.0 ); + } +* R*=63; +* G*=63; +* B*=63; +} + diff --git a/SRC/RGBHSL.H b/SRC/RGBHSL.H new file mode 100644 index 0000000..1406af5 --- /dev/null +++ b/SRC/RGBHSL.H @@ -0,0 +1,10 @@ +#ifndef __RGBHSL__H_ +#define __RGBHSL__H_ +extern "C" +{ + void rgb2hsl( float r, float g, float b, float *H, float *S, float *L ); + static float HuetoRGB( float m1, float m2, float h ); + void hsl2rgb( float H, float S, float L, float *R, float *G, float *B ); +} + +#endif diff --git a/SRC/RGBHSL.OBJ b/SRC/RGBHSL.OBJ new file mode 100644 index 0000000..7d7d1eb Binary files /dev/null and b/SRC/RGBHSL.OBJ differ diff --git a/SRC/ROUT.BAK b/SRC/ROUT.BAK new file mode 100644 index 0000000..d84b29f --- /dev/null +++ b/SRC/ROUT.BAK @@ -0,0 +1,70 @@ +#include < math.h > +#include < conio.h > +#include < stdlib.h > +#include < stdio.h > +#include < i86.h > +#include < string.h > +#include "defines.h" +#include "globvar.h" +int get_dist( int x1, int y1, int x2, int y2 ) +{ + int xs, ys, dist; + xs = x1 - x2; + ys = y1 - y2; + dist = sqrt( ( xs*xs ) + ( ys*ys ) ); + return( dist ); +} + +int get_angle( int x, int y, int x2, int y2 ) +{ + int s1, s2, ang; + float jako; + s1 = x - x2; + s2 = y - y2; + if ( s1!= 0 ) + { + jako = ( float ) ( s2 ) / ( float ) ( s1 ); + ang = atan( jako ) *360 / 2 / pi; + if ( x > x2 ) ang = ang + 180; + } + if ( s1 == 0 ) + { + if ( y < y2 ) ang = 90; + if ( y > y2 ) ang = 270; + } + return( ang ); +} + +void pre_count() +{ + int a; + for ( a = 0;a < 360;a ++ ) + { + sini[a]= sin( ( float ) a / 360*2*pi ); + cosi[a]= cos( ( float ) a / 360*2*pi ); + } +} + +void randomize() +{ + union REGS regs; + regs.h.ah = 0x2c; + int386( 0x21, ®s, ®s ); + srand( regs.h.dl + regs.h.dh*100 + regs.h.cl*6000 + regs.h.ch*36000 ); +} + +char *c_2_c( int aika ) +{ + int min, sec; + char text[10], text2[10], *t; + min = aika / 60; + sec = aika % 60; + itoa( min, text, 10 ); + itoa( sec, text2, 10 ); + strcat( text, ":"); + if ( sec < 10 ) strcat( text, "0"); + strcat( text, text2 ); + t = strdup( text ); + return( t ); +} + diff --git a/SRC/ROUT.CPP b/SRC/ROUT.CPP new file mode 100644 index 0000000..15ab43a --- /dev/null +++ b/SRC/ROUT.CPP @@ -0,0 +1,98 @@ +#include < math.h > +#include < conio.h > +#include < stdlib.h > +#include < stdio.h > +#include < i86.h > +#include < string.h > +#include "defines.h" +#include "globvar.h" + +int get_dist( int x1, int y1, int x2, int y2 ) +{ + int xs, ys, dist; + xs = x1 - x2; + ys = y1 - y2; + dist = sqrt( ( xs*xs ) + ( ys*ys ) ); + return( dist ); +} + +int get_pan( int x1, int x2) +{ + int pan; + int diff; + // stereo effect + diff= - ( x1 - x2 ); + if (diff!=0){ + pan = diff / 2; + if ( pan < - 63 ) pan = - 63; + if ( pan > 63 ) pan = 63; + } else pan=0; + return(pan); +} + +int get_volume( int x1, int y1, int x2 , int y2) +{ + float dist; + int shit; + dist=get_dist(x1,y1,x2,y2); + if (dist<500){ + dist/=200; + if (dist<1) dist=1; + shit=(int)(EFFECT_VOLUME/(float)dist); + } else shit=0; + return(shit); +} + +int get_angle( int x, int y, int x2, int y2 ) +{ + int s1, s2, ang; + float jako; + s1 = x - x2; + s2 = y - y2; + if ( s1!= 0 ) + { + jako = ( float ) ( s2 ) / ( float ) ( s1 ); + ang = atan( jako ) *360 / 2 / pi; + if ( x > x2 ) ang = ang + 180; + } + if ( s1 == 0 ) + { + if ( y < y2 ) ang = 90; + if ( y > y2 ) ang = 270; + } + return( ang ); +} + +void pre_count() +{ + int a; + for ( a = 0;a < 360;a ++ ) + { + sini[a]= sin( ( float ) a / 360*2*pi ); + cosi[a]= cos( ( float ) a / 360*2*pi ); + } +} + +void randomize() +{ + union REGS regs; + regs.h.ah = 0x2c; + int386( 0x21, ®s, ®s ); + srand( regs.h.dl + regs.h.dh*100 + regs.h.cl*6000 + regs.h.ch*36000 ); +} + +char *c_2_c( int aika ) +{ + int min, sec; + char text[10], text2[10], *t; + min = aika / 60; + sec = aika % 60; + itoa( min, text, 10 ); + itoa( sec, text2, 10 ); + strcat( text, ":"); + if ( sec < 10 ) strcat( text, "0"); + strcat( text, text2 ); + t = strdup( text ); + return( t ); +} + diff --git a/SRC/ROUT.H b/SRC/ROUT.H new file mode 100644 index 0000000..1afcc1c --- /dev/null +++ b/SRC/ROUT.H @@ -0,0 +1,10 @@ +#ifndef __TK__ROUT__ +#define __TK__ROUT__ +int get_pan(int x1,int x2); +int get_volume( int x1, int y1, int x2, int y2 ); +int get_dist( int x1, int y1, int x2, int y2 ); +int get_angle( int x, int y, int x2, int y2 ); +void pre_count(); +void randomize(); +char *c_2_c( int aika ); +#endif diff --git a/SRC/ROUT.OBJ b/SRC/ROUT.OBJ new file mode 100644 index 0000000..bf13462 Binary files /dev/null and b/SRC/ROUT.OBJ differ diff --git a/SRC/SETUP/SETUP.CPP b/SRC/SETUP/SETUP.CPP new file mode 100644 index 0000000..8c959a8 --- /dev/null +++ b/SRC/SETUP/SETUP.CPP @@ -0,0 +1,25 @@ +#include +#include +#include +#include +#include + +#pragma library ("midas.lib") + + +void vmode(short); +#pragma aux vmode=\ + "int 10h",\ + parm [ax] modify[ax] + +main() { + if (MIDASstartup()) + if (MIDASconfig()){ + vmode(0x3); + if (MIDASsaveConfig("SOUND.CFG")) cout<<"Configuration saved !"<<"\n"; + +} + +} + + diff --git a/SRC/SETUP/SETUP.OBJ b/SRC/SETUP/SETUP.OBJ new file mode 100644 index 0000000..f817158 Binary files /dev/null and b/SRC/SETUP/SETUP.OBJ differ diff --git a/SRC/SHOP.BAK b/SRC/SHOP.BAK new file mode 100644 index 0000000..a64614b --- /dev/null +++ b/SRC/SHOP.BAK @@ -0,0 +1,240 @@ +#define OTHER_STUFF 2 +void draw_wares( int row, int colu ) +{ + int a; + for ( a = 0; a < DIFF_WEAPONS; a ++ ) + { + draw_ware( 9 + a*18, 130, 0, a ); + if ( row == 0 ) if ( colu == a ) + rectangle( 8 + a*18, 129, 8 + 17 + a*18, 129 + 17, 98 ); + } + for ( a = 0; a < DIFF_BULLETS; a ++ ) + { + draw_ware( 9 + a*18, 130 + 18, 1, a ); + if ( row == 1 ) if ( colu == a ) + rectangle( 8 + a*18, 129 + 18, 8 + 17 + a*18, 129 + 17 + 18, 98 ); + } + for ( a = 0; a < OTHER_STUFF; a ++ ) + { + draw_ware( 9 + a*18, 130 + 18 + 18, 2, a ); + if ( row == 2 ) if ( colu == a ) + rectangle( 8 + a*18, 129 + 18 + 18, 8 + 17 + a*18, 129 + 17 + 18 + 18, 98 ); + } +} + +void draw_ware_info( Player *P, int sel1, int sel2 ) +{ + char text[20]; + int a; + FONT_NUM = 1; + if ( sel1 == 0 ) + { + writefonts( 20, 50, weapon[sel2 + 1].name, M_YELLOW ); + writefonts( 20, 70, "Cost:", M_BLUE ); + itoa( weapon[sel2 + 1].cost, text, 10 ); + writefonts( 20 + str_length( "Cost: " ), 70, text, M_YELLOW ); + writefonts( 20, 80, "Sell price:", M_BLUE ); + itoa( sell_price[sel2], text, 10 ); + writefonts( 20 + str_length( "Sell_price: " ), 80, text, M_YELLOW ); + writefonts( 20, 90, "Bullet type:", M_BLUE ); + writefonts( 20 + str_length( "Bullet type: " ), 90, bullet_type[weapon[sel2 + 1].btype].name, M_YELLOW ); + } + if ( sel1 == 1 ) + { + writefonts( 20, 50, bullet_type[sel2 + 1].name, M_YELLOW ); + writefonts( 20, 70, "Cost:", M_BLUE ); + itoa( bullet_type[sel2 + 1].cost, text, 10 ); + writefonts( 20 + str_length( "Cost: " ), 70, text, M_YELLOW ); + } + if ( sel1 == 2 ) + { + if ( sel2 == 0 ) + { + writefonts( 20, 50, "Shield", M_YELLOW ); + writefonts( 20, 70, "Cost:", M_BLUE ); + itoa( shield_data.cost + P-> shield*15, text, 10 ); + writefonts( 20 + str_length( "Cost: " ), 70, text, M_YELLOW ); + writefonts( 20, 80, "Sell price:", M_BLUE ); + a = P-> shield - 1;if ( a < 0 ) a = 0; + itoa( sell_price[DIFF_WEAPONS] + ( ( a*15 ) >> 1 ), text, 10 ); + writefonts( 20 + str_length( "Sell_price: " ), 80, text, M_YELLOW ); + } + if ( sel2 == 1 ) + { + writefonts( 20, 50, "Target system", M_YELLOW ); + writefonts( 20, 70, "Cost:", M_BLUE ); + itoa( target_cost, text, 10 ); + writefonts( 20 + str_length( "Cost: " ), 70, text, M_YELLOW ); + writefonts( 20, 80, "Sell price:", M_BLUE ); + itoa( sell_price[DIFF_WEAPONS + 1], text, 10 ); + writefonts( 20 + str_length( "Sell_price: " ), 80, text, M_YELLOW ); + } + } +} + +void Player::shop() +{ + int a, sx, sel1 = 0, sel2 = 0, quit = 0, x; + char text[20]; + load_efp( "efps\\shop.efp", picture, 0 ); + for ( a = 0; a < 17; a ++ ) + { + draw_box1( 9 + a*18, 130, 25 + a*18, 130 + 16, 8 ); + draw_box1( 9 + a*18, 130 + 18, 25 + a*18, 130 + 16 + 18, 8 ); + draw_box1( 9 + a*18, 130 + 18 + 18, 25 + a*18, 130 + 16 + 18 + 18, 8 ); + } + draw_box1( 115, 7, 205, 27, 13 ); + draw_box1( 10, 10, 80, 33, 13 ); + draw_box1( 10, 40, 230, 113, 13 ); + FONT_NUM = 0; + sx = 160 - ( str_length( "the shop" ) / 2 ); + first = 1; + shield_data.max = 30; + while ( !quit ) + { + memcpy( virbuff, picture, 64000 ); + FONT_NUM = 0; + writefonts2( sx, 10, "the shop", 1 ); + FONT_NUM = 1; + writefonts( 10, 190, "Press FIRE to buy, CHANGE to sell, ESC to exit", M_BLUE ); + writefonts( 15, 12, name, M_YELLOW ); + itoa( cash, text, 10 ); + writefonts( 15, 20, "Cash:", M_RED ); + writefonts( 40, 20, text, M_YELLOW ); + draw_wares( sel1, sel2 ); + draw_ware_info( this, sel1, sel2 ); + FONT_NUM = 3; + for ( a = 0; a < DIFF_WEAPONS; a ++ ) + if ( weapons[a + 1] == 1 ) + { + writefonts( 8 + a*18, 131 + 11, "1", 0 ); + writefonts( 9 + a*18, 130 + 11, "1", M_YELLOW ); + } + for ( a = 0; a < DIFF_BULLETS; a ++ ) + if ( bullets[a] > 0 ) + { + x = bullets[a] / bullet_type[a + 1].mul; + if ( x < 1 ) x = 1; + itoa( x, text, 10 ); + writefonts( 8 + a*18, 131 + 11 + 18, text, 0 ); + writefonts( 9 + a*18, 130 + 11 + 18, text, M_YELLOW ); + } + if ( shield > 0 ) + { + itoa( shield, text, 10 ); + writefonts( 8, 131 + 11 + 18 + 18, text, 0 ); + writefonts( 9, 130 + 11 + 18 + 18, text, M_YELLOW ); + } + if ( TARGET == 1 ) + { + writefonts( 8 + 18, 131 + 11 + 18 + 18, "1", 0 ); + writefonts( 9 + 18, 130 + 11 + 18 + 18, "1", M_YELLOW ); + } + if ( !first ) memcpy( screen, virbuff, 64000 ); + if ( first == 1 ) + { + fadein( virbuff, pal ); + first = 0; + } + while ( !k.state[1]&& + !k.state[K_LEFT]&& + !k.state[K_RIGHT]&& + !k.state[K_UP]&& + !k.state[K_DOWN]&& + !k.state[K_SHOOT]&& + !k.state[K_SHIFT]); + if ( k.state[K_UP] ) if ( sel1 > 0 ) sel1 --; + if ( k.state[K_DOWN] ) if ( sel1 < 2 ) sel1 ++; + if ( k.state[K_LEFT] ) sel2 --; + if ( k.state[K_RIGHT] ) sel2 ++; + if ( sel2 < 0 ) sel2 = 0; + if ( sel1 == 0 ) if ( sel2 >= DIFF_WEAPONS ) sel2 = DIFF_WEAPONS - 1; + if ( sel1 == 1 ) if ( sel2 >= DIFF_BULLETS ) sel2 = DIFF_BULLETS - 1; + if ( sel1 == 2 ) if ( sel2 >= OTHER_STUFF ) sel2 = OTHER_STUFF - 1; + if ( k.state[K_SHOOT] ) + { + if ( sel1 == 0 ) + if ( weapons[sel2 + 1] == 0 ) + if ( cash >= weapon[sel2 + 1].cost ) + { + weapons[sel2 + 1] = 1; + cash -= weapon[sel2 + 1].cost; + } + if ( sel1 == 1 ) + if ( bullets[sel2] < bullet_type[sel2 + 1].max*bullet_type[sel2 + 1].mul ) + if ( cash >= bullet_type[sel2 + 1].cost ) + { + bullets[sel2] += bullet_type[sel2 + 1].mul; + cash -= bullet_type[sel2 + 1].cost; + } + if ( sel1 == 2 ) + { + if ( sel2 == 0 ) + if ( cash >= shield_data.cost + shield*15 ) + if ( shield < shield_data.max ) + { + cash -= shield_data.cost + shield*15; + shield ++; + } + if ( sel2 == 1 ) + if ( TARGET == 0 ) + if ( cash >= target_cost ) + { + TARGET = 1; + cash -= target_cost; + } + } + } + if ( k.state[K_SHIFT] ) + { + if ( sel1 == 0 ) + if ( weapons[sel2 + 1] > 0 ) + { + weapons[sel2 + 1] = 0; + cash += sell_price[sel2]; + } + if ( sel1 == 1 ) + if ( bullets[sel2] > 0 ) + { + bullets[sel2] -= bullet_type[sel2 + 1].mul; + if ( bullets[sel2] < 0 ) bullets[sel2] = 0; + cash += bullet_type[sel2 + 1].cost; + } + if ( sel1 == 2 ) + { + if ( sel2 == 0 ) + if ( shield > 0 ) + { + a = shield - 1; if ( a < 0 ) a = 0; + cash += sell_price[DIFF_WEAPONS] + ( ( 15*a ) / 2 ); + shield --; + } + if ( sel2 == 1 ) + if ( TARGET == 1 ) + { + TARGET = 0; + cash += sell_price[DIFF_WEAPONS + 1]; + } + } + } + k.state[K_UP] = 0; + k.state[K_DOWN] = 0; + k.state[K_LEFT] = 0; + k.state[K_RIGHT] = 0; + k.state[K_SHOOT] = 0; + k.state[K_SHIFT] = 0; + MIDASplaySample( klikwav, MIDAS_CHANNEL_AUTO, 0, 22000, EFFECT_VOLUME, MIDAS_PAN_MIDDLE ); + if ( k.state[1] ) + { + FONT_NUM = 0; + writefonts2( 10, 115, "press fire to confirm", 1 ); + memcpy( screen, virbuff, 64000 ); + k.clear_stack(); + while ( !k.kbhit() ) ; + if ( k.state[K_SHOOT] ) quit = 1; + k.state[1] = 0; + } + } + fadeout( virbuff, pal ); +} + diff --git a/SRC/SHOP.H b/SRC/SHOP.H new file mode 100644 index 0000000..b0ffc9a --- /dev/null +++ b/SRC/SHOP.H @@ -0,0 +1,240 @@ +#define OTHER_STUFF 2 +void draw_wares( int row, int colu ) +{ + int a; + for ( a = 0; a < DIFF_WEAPONS; a ++ ) + { + draw_ware( 9 + a*18, 130, 0, a ); + if ( row == 0 ) if ( colu == a ) + rectangle( 8 + a*18, 129, 8 + 17 + a*18, 129 + 17, 98 ); + } + for ( a = 0; a < DIFF_BULLETS; a ++ ) + { + draw_ware( 9 + a*18, 130 + 18, 1, a ); + if ( row == 1 ) if ( colu == a ) + rectangle( 8 + a*18, 129 + 18, 8 + 17 + a*18, 129 + 17 + 18, 98 ); + } + for ( a = 0; a < OTHER_STUFF; a ++ ) + { + draw_ware( 9 + a*18, 130 + 18 + 18, 2, a ); + if ( row == 2 ) if ( colu == a ) + rectangle( 8 + a*18, 129 + 18 + 18, 8 + 17 + a*18, 129 + 17 + 18 + 18, 98 ); + } +} + +void draw_ware_info( Player *P, int sel1, int sel2 ) +{ + char text[20]; + int a; + FONT_NUM = 1; + if ( sel1 == 0 ) + { + writefonts( 20, 50, weapon[sel2 + 1].name, M_YELLOW ); + writefonts( 20, 70, "Cost:", M_BLUE ); + itoa( weapon[sel2 + 1].cost, text, 10 ); + writefonts( 20 + str_length( "Cost: " ), 70, text, M_YELLOW ); + writefonts( 20, 80, "Sell price:", M_BLUE ); + itoa( sell_price[sel2], text, 10 ); + writefonts( 20 + str_length( "Sell_price: " ), 80, text, M_YELLOW ); + writefonts( 20, 90, "Bullet type:", M_BLUE ); + writefonts( 20 + str_length( "Bullet type: " ), 90, bullet_type[weapon[sel2 + 1].btype].name, M_YELLOW ); + } + if ( sel1 == 1 ) + { + writefonts( 20, 50, bullet_type[sel2 + 1].name, M_YELLOW ); + writefonts( 20, 70, "Cost:", M_BLUE ); + itoa( bullet_type[sel2 + 1].cost, text, 10 ); + writefonts( 20 + str_length( "Cost: " ), 70, text, M_YELLOW ); + } + if ( sel1 == 2 ) + { + if ( sel2 == 0 ) + { + writefonts( 20, 50, "Shield", M_YELLOW ); + writefonts( 20, 70, "Cost:", M_BLUE ); + itoa( shield_data.cost + P-> shield*15, text, 10 ); + writefonts( 20 + str_length( "Cost: " ), 70, text, M_YELLOW ); + writefonts( 20, 80, "Sell price:", M_BLUE ); + a = P-> shield - 1;if ( a < 0 ) a = 0; + itoa( sell_price[DIFF_WEAPONS] + ( ( a*15 ) >> 1 ), text, 10 ); + writefonts( 20 + str_length( "Sell_price: " ), 80, text, M_YELLOW ); + } + if ( sel2 == 1 ) + { + writefonts( 20, 50, "Target system", M_YELLOW ); + writefonts( 20, 70, "Cost:", M_BLUE ); + itoa( target_cost, text, 10 ); + writefonts( 20 + str_length( "Cost: " ), 70, text, M_YELLOW ); + writefonts( 20, 80, "Sell price:", M_BLUE ); + itoa( sell_price[DIFF_WEAPONS + 1], text, 10 ); + writefonts( 20 + str_length( "Sell_price: " ), 80, text, M_YELLOW ); + } + } +} + +void Player::shop() +{ + int a, sx, sel1 = 0, sel2 = 0, quit = 0, x; + char text[20]; + load_efp( "efps\\shop.efp", picture, 0 ); + for ( a = 0; a < 17; a ++ ) + { + draw_box1( 9 + a*18, 130, 25 + a*18, 130 + 16, 8 ); + draw_box1( 9 + a*18, 130 + 18, 25 + a*18, 130 + 16 + 18, 8 ); + draw_box1( 9 + a*18, 130 + 18 + 18, 25 + a*18, 130 + 16 + 18 + 18, 8 ); + } + draw_box1( 115, 7, 205, 27, 13 ); + draw_box1( 10, 10, 80, 33, 13 ); + draw_box1( 10, 40, 230, 113, 13 ); + FONT_NUM = 0; + sx = 160 - ( str_length( "the shop" ) / 2 ); + first = 1; + shield_data.max = 30; + while ( !quit ) + { + memcpy( virbuff, picture, 64000 ); + FONT_NUM = 0; + writefonts2( sx, 10, "the shop", 1 ); + FONT_NUM = 1; + writefonts( 10, 190, "Press FIRE to buy, CHANGE to sell, ESC to exit", M_BLUE ); + writefonts( 15, 12, name, M_YELLOW ); + itoa( cash, text, 10 ); + writefonts( 15, 20, "Cash:", M_RED ); + writefonts( 40, 20, text, M_YELLOW ); + draw_wares( sel1, sel2 ); + draw_ware_info( this, sel1, sel2 ); + FONT_NUM = 3; + for ( a = 0; a < DIFF_WEAPONS; a ++ ) + if ( weapons[a + 1] == 1 ) + { + writefonts( 8 + a*18, 131 + 11, "1", 0 ); + writefonts( 9 + a*18, 130 + 11, "1", M_YELLOW ); + } + for ( a = 0; a < DIFF_BULLETS; a ++ ) + if ( bullets[a] > 0 ) + { + x = bullets[a] / bullet_type[a + 1].mul; + if ( x < 1 ) x = 1; + itoa( x, text, 10 ); + writefonts( 8 + a*18, 131 + 11 + 18, text, 0 ); + writefonts( 9 + a*18, 130 + 11 + 18, text, M_YELLOW ); + } + if ( shield > 0 ) + { + itoa( shield, text, 10 ); + writefonts( 8, 131 + 11 + 18 + 18, text, 0 ); + writefonts( 9, 130 + 11 + 18 + 18, text, M_YELLOW ); + } + if ( TARGET == 1 ) + { + writefonts( 8 + 18, 131 + 11 + 18 + 18, "1", 0 ); + writefonts( 9 + 18, 130 + 11 + 18 + 18, "1", M_YELLOW ); + } + if ( !first ) memcpy( screen, virbuff, 64000 ); + if ( first == 1 ) + { + fadein( virbuff, pal ); + first = 0; + } + while ( !k.state[1]&& + !k.state[K_LEFT]&& + !k.state[K_RIGHT]&& + !k.state[K_UP]&& + !k.state[K_DOWN]&& + !k.state[K_SHOOT]&& + !k.state[K_SHIFT]); + if ( k.state[K_UP] ) if ( sel1 > 0 ) sel1 --; + if ( k.state[K_DOWN] ) if ( sel1 < 2 ) sel1 ++; + if ( k.state[K_LEFT] ) sel2 --; + if ( k.state[K_RIGHT] ) sel2 ++; + if ( sel2 < 0 ) sel2 = 0; + if ( sel1 == 0 ) if ( sel2 >= DIFF_WEAPONS ) sel2 = DIFF_WEAPONS - 1; + if ( sel1 == 1 ) if ( sel2 >= DIFF_BULLETS ) sel2 = DIFF_BULLETS - 1; + if ( sel1 == 2 ) if ( sel2 >= OTHER_STUFF ) sel2 = OTHER_STUFF - 1; + if ( k.state[K_SHOOT] ) + { + if ( sel1 == 0 ) + if ( weapons[sel2 + 1] == 0 ) + if ( cash >= weapon[sel2 + 1].cost ) + { + weapons[sel2 + 1] = 1; + cash -= weapon[sel2 + 1].cost; + } + if ( sel1 == 1 ) + if ( bullets[sel2] < bullet_type[sel2 + 1].max*bullet_type[sel2 + 1].mul ) + if ( cash >= bullet_type[sel2 + 1].cost ) + { + bullets[sel2] += bullet_type[sel2 + 1].mul; + cash -= bullet_type[sel2 + 1].cost; + } + if ( sel1 == 2 ) + { + if ( sel2 == 0 ) + if ( cash >= shield_data.cost + shield*15 ) + if ( shield < shield_data.max ) + { + cash -= shield_data.cost + shield*15; + shield ++; + } + if ( sel2 == 1 ) + if ( TARGET == 0 ) + if ( cash >= target_cost ) + { + TARGET = 1; + cash -= target_cost; + } + } + } + if ( k.state[K_SHIFT] ) + { + if ( sel1 == 0 ) + if ( weapons[sel2 + 1] > 0 ) + { + weapons[sel2 + 1] = 0; + cash += sell_price[sel2]; + } + if ( sel1 == 1 ) + if ( bullets[sel2] > 0 ) + { + bullets[sel2] -= bullet_type[sel2 + 1].mul; + if ( bullets[sel2] < 0 ) bullets[sel2] = 0; + cash += bullet_type[sel2 + 1].cost; + } + if ( sel1 == 2 ) + { + if ( sel2 == 0 ) + if ( shield > 0 ) + { + a = shield - 1; if ( a < 0 ) a = 0; + cash += sell_price[DIFF_WEAPONS] + ( ( 15*a ) / 2 ); + shield --; + } + if ( sel2 == 1 ) + if ( TARGET == 1 ) + { + TARGET = 0; + cash += sell_price[DIFF_WEAPONS + 1]; + } + } + } + k.state[K_UP] = 0; + k.state[K_DOWN] = 0; + k.state[K_LEFT] = 0; + k.state[K_RIGHT] = 0; + k.state[K_SHOOT] = 0; + k.state[K_SHIFT] = 0; + MIDASplaySample( samplep[KLIKWAV], MIDAS_CHANNEL_AUTO, 0, 22000, EFFECT_VOLUME, MIDAS_PAN_MIDDLE ); + if ( k.state[1] ) + { + FONT_NUM = 0; + writefonts2( 10, 115, "press fire to confirm", 1 ); + memcpy( screen, virbuff, 64000 ); + k.clear_stack(); + while ( !k.kbhit() ) ; + if ( k.state[K_SHOOT] ) quit = 1; + k.state[1] = 0; + } + } + fadeout( virbuff, pal ); +} + diff --git a/SRC/T.BAT b/SRC/T.BAT new file mode 100644 index 0000000..26bbe4e --- /dev/null +++ b/SRC/T.BAT @@ -0,0 +1,5 @@ +@echo off +wmake +cd .. +game +cd src diff --git a/SRC/TESTI/TEST.BAK b/SRC/TESTI/TEST.BAK new file mode 100644 index 0000000..24cd2d0 --- /dev/null +++ b/SRC/TESTI/TEST.BAK @@ -0,0 +1,323 @@ +#include +#include +#include +#include +#include +#include + +#include "int/int.h" +#include "ipx/ipx.h" +#include "ipxdefs.h" +#include "error/error.h" + +#define MAX_PLAYERS 8 + +int ipxofs[MAX_PLAYERS] = +{ + 0, 0, 0, 0, + 0, 0, 0, 0 +}; + +char ipxstream[MAX_PLAYERS][MAXDATASIZE]; +struct nodeaddr serveraddr; +char servername[10]; +struct packet far *send, far *rec[RECEIVERS]; +unsigned short sendl, sendseg, recl[RECEIVERS], recseg[RECEIVERS]; +int ipxavail; +int NETWORK_MODE=SERVER; +char name1[]="Hanunpeli"; + +int PLAYERS=1; + +void allocipxmem() +{ + int a; + send = ( struct packet far * ) MK_FP( getlowmem( sizeof( struct packet ) / 16 + 1 ), 0 ); + if ( send == NULL ) + { + cout << "Can't alloc lowmem!\n" << endl; + ipxavail = 0; + return; + } + sendl = lsel; + sendseg = lseg; + for ( a = 0; a < RECEIVERS; a ++ ) + { + rec[a] = ( struct packet far * ) MK_FP( getlowmem( sizeof( struct packet ) / 16 + 1 ), 0 ); + if ( rec[a] == NULL ) + { + cout << "Can't alloc lowmem!\n"<< endl; + ipxavail = 0; + return; + } + recl[a] = lsel; + recseg[a] = lseg; + } +} + +void freeipxmem() +{ + int a; + if (ipxavail) + { + freelowmem( sendl ); + for ( a = 0; a < RECEIVERS; a ++ ) + { + freelowmem( recl[a] ); + recseg[a] = lseg; + } + } +} + +void init() +{ + if ( initipx() ) + { + char str[256]; + cout << "IPX protocol detected!\n"; + getlocaladdress(); + printf( "IPX address: %s\n", decode_localaddress( str, localadd ) ); + ipxavail = 1; + allocipxmem(); + } + else cout << "IPX _NOT_ detected!\n"; +} +void flushipx() +{ + int a,b; + for ( a = 0; a < PLAYERS; a++ ) + if (ipxofs[a]!=0) + { + ipxstream[a][ ipxofs[a]++ ] = IPX_END; + for (b=0;bdata[b]=ipxstream[a][b]; + while (send->ecb.inuse); + //sendpacket( sendseg,TŽHŽN NODE!!! , send, ( word ) ipxofs[a] ); + // RESET + ipxofs[a] = 0; + } +} + +void sendipxnow( struct nodeaddr *node, int type, ... ) +{ + int a = 0; +// TEMP VARIABLES + int b; + struct nodeaddr n; + char *str; +// TEMP VARIABLES END + auto va_list ap; + va_start( ap, type ); + + while (send->ecb.inuse); + switch( type ) + { + case IPX_SERVERSEARCH:send->data[a++] = ( char ) type; + for (b=0;b<6;b++) + send->data[a++] = localadd->node.node[b]; + break; + case IPX_SERVERANSWER:send->data[a++] = ( char ) type; + n = va_arg( ap, struct nodeaddr ); + for ( b = 0; b < 6; b++ ) + send->data[a++ ] = n.node[b]; + str = va_arg( ap, char * ); + for ( b = 0; b < 10; b++ ) + send->data[a++ ] = str[b]; + break; + case IPX_SERVERSHUTDOWN:send->data[a++] = ( char ) type; + n = va_arg( ap, struct nodeaddr ); + for ( b = 0; b < 6; b++ ) + send->data[a++ ] = n.node[b]; + break; + default:error( "IPX message %d not yet implemented\n", type ); + } + + send->data[a++] = IPX_END; + sendpacket( sendseg, *node, send, ( word ) a ); + va_end( ap ); +} + +void sendipx( int dest, int type, ... ) +{ + va_list ap; + va_start( ap, type ); + switch( type ) + { + case IPX_SERVERSEARCH: + error( "sendipx: Use sendipxnow for serversearch\n" ); + break; + case IPX_SERVERANSWER: + error( "sendipx: Use sendipxnow for serveranswer\n" ); + break; + default:error( "sendipx: Not implemented yet!\n" ); + /* ipxstream[dest][ipxofs[dest] ++ ] = ( char ) type; + n = va_arg( ap, struct nodeaddr node ); + for ( a = 0; a < 6; a ++ ) + ipxstream[dest][ipxofs[dest] ++ ] = n.node[a]; + break;*/ + } + va_end( ap ); +} + +void setup_ipx() +{ + int a; + if ( opensocket( 0, SOCKET) ) + error( "setup_ipx: Couldn't open socket (%Xh)\n", SOCKET ); + for ( a = 0; a < MAX_PLAYERS; a ++ ) ipxofs[a] = 0; + PLAYERS = 1; + if ( NETWORK_MODE == SERVER ) + { + strcpy( servername, name1 ); + for (a=0;a<6;a++) + serveraddr.node[a]=localadd->node.node[a]; + } + initsendpacket(send,sendseg); + for (a=0;aecb.inuse) + cancelpacket(recseg[a]); + flushipx(); + closesocket( ( word ) socketid ); +} + +void do_server_shit() +{ + int a,b, data, ofs; + struct nodeaddr n; + for ( a = 0; a < RECEIVERS; a ++ ) + if ( rec[a]-> ecb.inuse == 0 ) + { + data = - 1; + ofs = 0; + while( data!= IPX_END ) + { + data = rec[a]-> data[ofs ++ ]; + switch ( data ) + { + case IPX_SERVERSEARCH: + for (b=0;b<6;b++) + n.node[b]=rec[a]->data[ofs++]; + sendipxnow( &n, IPX_SERVERANSWER,serveraddr,servername ); + break; + + case IPX_TEXTMESSAGE: + while ( ( data = rec[a]-> data[ofs ++ ] ) != 0 ); + printf( "\n" ); + break; + + case IPX_END: + break; + + default:error( "IPX: receiver %d: unknown command %d\n", a, data ); + }; + } + listenforpacket( recseg[a] ); + } + flushipx(); +} + +void do_client_shit() +{ + +} + +int select_server() +{ + int a, b, c,data,ofs,quit,done=0; + int servers; + char servernames[10][10],tempname[10]; + struct nodeaddr nodez[10],tempnode; + struct nodeaddr bc; + + servers=0; + bc=BROADCAST(); + + while ( (!done)&&(!quit) ) + { + printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); + printf("\t\tSelect server\n\n"); + for (a=0;aecb.inuse) + { + data = - 1; + ofs = 0; + while( data!= IPX_END ) + { + data = rec[a]-> data[ofs ++ ]; + switch ( data ) + { + case IPX_SERVERANSWER: + for (b=0;b<6;b++) + tempnode.node[b]=rec[a]->data[ofs++]; + for (b=0;b<6;b++) + tempname[b]=rec[a]->data[ofs++]; + if (servers<10) + { + for (b=0;(bdata[ofs++]; + for (b=0;b data[ofs ++ ] ) != 0 ); + break; + + case IPX_END: + break; + default:ofs+=IPXMSGLEN[data]; + }; + } + listenforpacket( recseg[a] ); + } + if (kbhit()) if (getch()==27) return 0; + } + + return 1; +} + +main() +{ + init(); + printf("ready to setup_ipx?\n"); + getch(); + setup_ipx(); + printf("ready to desetup_ipx?\n"); + getch(); + desetup_ipx(); + printf("Selevittiin ehjin nahoin.\nkai...\n"); +} + diff --git a/SRC/TESTI/TEST.CPP b/SRC/TESTI/TEST.CPP new file mode 100644 index 0000000..baf6e57 --- /dev/null +++ b/SRC/TESTI/TEST.CPP @@ -0,0 +1,332 @@ +#include +#include +#include +#include +#include +#include + +#include "int/int.h" +#include "ipx/ipx.h" +#include "ipxdefs.h" +#include "error/error.h" + +#define MAX_PLAYERS 8 + +int ipxofs[MAX_PLAYERS] = +{ + 0, 0, 0, 0, + 0, 0, 0, 0 +}; + +char ipxstream[MAX_PLAYERS][MAXDATASIZE]; +struct nodeaddr serveraddr; +char servername[10]; +struct packet far *send, far *rec[RECEIVERS]; +unsigned short sendl, sendseg, recl[RECEIVERS], recseg[RECEIVERS]; +int ipxavail; +int NETWORK_MODE=SERVER; +char name1[]="Hanunpeli"; + +int PLAYERS=1; + +void allocipxmem() +{ + int a; + send = ( struct packet far * ) MK_FP( getlowmem( sizeof( struct packet ) / 16 + 1 ), 0 ); + if ( send == NULL ) + { + cout << "Can't alloc lowmem!\n" << endl; + ipxavail = 0; + return; + } + sendl = lsel; + if (sendl==0) + { + cout << "sendl check failed"<< endl; + ipxavail = 0; + } + sendseg = lseg; + if (sendseg==0) + { + cout << "sendseg check failed"<< endl; + ipxavail = 0; + } + for ( a = 0; a < RECEIVERS; a ++ ) + { + rec[a] = ( struct packet far * ) MK_FP( getlowmem( sizeof( struct packet ) / 16 + 1 ), 0 ); + if ( rec[a] == NULL ) + { + cout << "Can't alloc lowmem!"<< endl; + ipxavail = 0; + return; + } + recl[a] = lsel; + recseg[a] = lseg; + if (recseg[a]==0) + { + cout << "recseg check failed ("<< a <<')'<< endl; + ipxavail = 0; + } + if (recl[a]==0) + { + cout << "recl check failed ("<< a <<')'<< endl; + ipxavail = 0; + } + + } +} + +void freeipxmem() +{ + int a; + if (ipxavail) + { + freelowmem( sendl ); + for ( a = 0; a < RECEIVERS; a ++ ) + { + freelowmem( recl[a] ); + recseg[a] = lseg; + } + } +} + +void init() +{ + if ( initipx() ) + { + char str[256]; + cout << "IPX protocol detected!\n"; + getlocaladdress(); + printf( "IPX address: %s\n", decode_localaddress( str, localadd ) ); + ipxavail = 1; + allocipxmem(); + } + else cout << "IPX _NOT_ detected!\n"; +} +void flushipx() +{ + int a,b; + for ( a = 0; a < PLAYERS; a++ ) + if (ipxofs[a]!=0) + { + ipxstream[a][ ipxofs[a]++ ] = IPX_END; + for (b=0;bdata[b]=ipxstream[a][b]; + while (send->ecb.inuse); + //sendpacket( sendseg,TŽHŽN NODE!!! , send, ( word ) ipxofs[a] ); + // RESET + ipxofs[a] = 0; + } +} + +void sendipxnow( struct nodeaddr *node, int type, ... ) +{ + int a = 0; +// TEMP VARIABLES + int b; + struct nodeaddr n; + char *str; +// TEMP VARIABLES END + auto va_list ap; + va_start( ap, type ); + + while (send->ecb.inuse); + switch( type ) + { + case IPX_SERVERSEARCH:send->data[a++] = ( char ) type; + for (b=0;b<6;b++) + send->data[a++] = localadd->node.node[b]; + break; + case IPX_SERVERANSWER:send->data[a++] = ( char ) type; + n = va_arg( ap, struct nodeaddr ); + for ( b = 0; b < 6; b++ ) + send->data[a++ ] = n.node[b]; + str = va_arg( ap, char * ); + for ( b = 0; b < 10; b++ ) + send->data[a++ ] = str[b]; + break; + case IPX_SERVERSHUTDOWN:send->data[a++] = ( char ) type; + n = va_arg( ap, struct nodeaddr ); + for ( b = 0; b < 6; b++ ) + send->data[a++ ] = n.node[b]; + break; + default:error( "IPX message %d not yet implemented\n", type ); + } + + send->data[a++] = IPX_END; + sendpacket( sendseg, *node, send, ( word ) a ); + va_end( ap ); +} + +void sendipx( int dest, int type, ... ) +{ + va_list ap; + va_start( ap, type ); + switch( type ) + { + case IPX_SERVERSEARCH: + error( "sendipx: Use sendipxnow for serversearch\n" ); + break; + case IPX_SERVERANSWER: + error( "sendipx: Use sendipxnow for serveranswer\n" ); + break; + default:error( "sendipx: Not implemented yet!\n" ); + /* ipxstream[dest][ipxofs[dest] ++ ] = ( char ) type; + n = va_arg( ap, struct nodeaddr node ); + for ( a = 0; a < 6; a ++ ) + ipxstream[dest][ipxofs[dest] ++ ] = n.node[a]; + break;*/ + } + va_end( ap ); +} + +void setup_ipx() +{ + int a; + if ( opensocket( 0, SOCKET) ) + error( "setup_ipx: Couldn't open socket (%Xh)\n", SOCKET ); + for ( a = 0; a < MAX_PLAYERS; a ++ ) ipxofs[a] = 0; + PLAYERS = 1; + if ( NETWORK_MODE == SERVER ) + { + strcpy( servername, name1 ); + for (a=0;a<6;a++) + serveraddr.node[a]=localadd->node.node[a]; + } + initsendpacket(send,sendseg); + for (a=0;aecb.inuse) + cancelpacket(recseg[a]); + flushipx(); + closesocket( ( word ) socketid ); +} + +void do_server_shit() +{ + int a,b, data, ofs; + struct nodeaddr n; + for ( a = 0; a < RECEIVERS; a ++ ) + if ( rec[a]-> ecb.inuse == 0 ) + { + data = - 1; + ofs = 0; + while( data!= IPX_END ) + { + data = rec[a]-> data[ofs ++ ]; + switch ( data ) + { + case IPX_SERVERSEARCH: + for (b=0;b<6;b++) + n.node[b]=rec[a]->data[ofs++]; + sendipxnow( &n, IPX_SERVERANSWER,serveraddr,servername ); + break; + + case IPX_TEXTMESSAGE: + while ( ( data = rec[a]-> data[ofs ++ ] ) != 0 ); + printf( "\n" ); + break; + + case IPX_END: + break; + + default:error( "IPX: receiver %d: unknown command %d\n", a, data ); + }; + } + listenforpacket( recseg[a] ); + } + flushipx(); +} + +void do_client_shit() +{ + +} + +int select_server() +{ + int a, b, c,data,ofs,quit,done=0; + int servers; + char servernames[10][10],tempname[10]; + struct nodeaddr nodez[10],tempnode; + struct nodeaddr bc; + + servers=0; + bc=BROADCAST(); + + while ( (!done)&&(!quit) ) + { + printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); + printf("\t\tSelect server\n\n"); + for (a=0;aecb.inuse) + { + data = - 1; + ofs = 0; + while( data!= IPX_END ) + { + data = rec[a]-> data[ofs ++ ]; + switch ( data ) + { + case IPX_SERVERANSWER: + for (b=0;b<6;b++) + tempnode.node[b]=rec[a]->data[ofs++]; + for (b=0;b<6;b++) + tempname[b]=rec[a]->data[ofs++]; + if (servers<10) + { + for (b=0;(bdata[ofs++]; + for (b=0;b data[ofs ++ ] ) != 0 ); + break; + + case IPX_END: + break; + default:ofs+=IPXMSGLEN[data]; + }; + } + listenforpacket( recseg[a] ); + } + if (kbhit()) if (getch()==27) return 0; + } + + return 1; +} + diff --git a/SRC/TESTI/TEST.ERR b/SRC/TESTI/TEST.ERR new file mode 100644 index 0000000..76f9394 --- /dev/null +++ b/SRC/TESTI/TEST.ERR @@ -0,0 +1,2 @@ +TEST.CPP(181): Warning! W014: (col 1) no reference to symbol 'dest' +TEST.CPP(181): Note! N392: (col 1) 'int dest' in 'void sendipx( int, int, ... )' defined in: TEST.CPP(161) (col 19) diff --git a/SRC/TESTI/TEST.EXE b/SRC/TESTI/TEST.EXE new file mode 100644 index 0000000..420c321 Binary files /dev/null and b/SRC/TESTI/TEST.EXE differ diff --git a/SRC/TESTI/TEST.OBJ b/SRC/TESTI/TEST.OBJ new file mode 100644 index 0000000..24d32b3 Binary files /dev/null and b/SRC/TESTI/TEST.OBJ differ diff --git a/SRC/TK.LNK b/SRC/TK.LNK new file mode 100644 index 0000000..18331c4 --- /dev/null +++ b/SRC/TK.LNK @@ -0,0 +1,6 @@ +system dos4g +option stack=256000 +file game,error,efp,ipx,int,rgbhsl,globvar,miscfunc,draw,fade,write,classes,rout,newfuncs,options,ipxdefs +library midas.lib +name ..\game + diff --git a/SRC/TYPES.BAK b/SRC/TYPES.BAK new file mode 100644 index 0000000..dcbb919 --- /dev/null +++ b/SRC/TYPES.BAK @@ -0,0 +1,53 @@ +#ifndef __TK__TYPES__ +#define __TK__TYPES__ +#include < midasdll.h > +struct special +{ + int num; + char text[15]; +}; + +struct BLOCK +{ + int type; + int num; + int shadow; +}; + +struct s +{ + char *name; + int cost; + int max; +}; + +struct WEapon +{ + char *name; + int cost; + int loading_time; + int smoke; + int bullet_amount; + int angle_add; + int gun; + int btype; + MIDASsample *sound; +}; + +struct juu +{ + char name[15]; + char *spr; + int speed; + int curr_weapon; + int energy; + int reward; + int explo_death; +}; + +struct vile +{ + char name[13]; +}; + +#endif diff --git a/SRC/TYPES.H b/SRC/TYPES.H new file mode 100644 index 0000000..240a5ea --- /dev/null +++ b/SRC/TYPES.H @@ -0,0 +1,53 @@ +#ifndef __TK__TYPES__ +#define __TK__TYPES__ +#include < midasdll.h > +struct special +{ + int num; + char text[15]; +}; + +struct BLOCK +{ + int type; + int num; + int shadow; +}; + +struct s +{ + char *name; + int cost; + int max; +}; + +struct WEapon +{ + char *name; + int cost; + int loading_time; + int smoke; + int bullet_amount; + int angle_add; + int gun; + int btype; + int sound; +}; + +struct juu +{ + char name[15]; + char *spr; + int speed; + int curr_weapon; + int energy; + int reward; + int explo_death; +}; + +struct vile +{ + char name[13]; +}; + +#endif diff --git a/SRC/WRITE.BAK b/SRC/WRITE.BAK new file mode 100644 index 0000000..6b176b7 --- /dev/null +++ b/SRC/WRITE.BAK @@ -0,0 +1,189 @@ +#include "globvar.h" +#include < stdlib.h > +#include < stdio.h > +#include < string.h > +void pixeli( int x, int y, char col ) +{ + virbuff[( y << 8 ) + ( y << 6 ) + x] = col; +} + +void loadfonts( char *name ) +{ + FILE *fnt; + int a; + fnt = fopen( name, "rb" ); + f_x_size[FONT_NUM] = fgetc( fnt ); + f_y_size[FONT_NUM] = fgetc( fnt ); + thefonts[FONT_NUM] = ( char * ) malloc( f_y_size[FONT_NUM]*f_x_size[FONT_NUM]*256 ); + fseek( fnt, 256*2, 0 ); + for ( a = 0; a < f_x_size[FONT_NUM]*f_y_size[FONT_NUM]*256; a ++ ) + thefonts[FONT_NUM][a] = ( char ) fgetc( fnt ); + fclose( fnt ); +} + +void writefonts( int x, int y, char *str, int cq ) +{ + int a, c, d, xpos1, xpos2, col, textcnt, fsize = f_x_size[FONT_NUM]*f_y_size[FONT_NUM]; + int x1, x2, px, py; + textcnt = 0; + for ( a = 0; str[a]!= 0; a ++ ) + { + c = 0; + col = 0; + while ( col < 2 &c < f_x_size[FONT_NUM] ) + { + // check from left + for ( d = 0; d < f_y_size[FONT_NUM]; d ++ ) + if ( thefonts[FONT_NUM][str[a]*fsize + d*f_x_size[FONT_NUM] + ( c ) ] > 1 ) col = 2; + if ( col < 2 ) c ++; + } + xpos1 = c; + c = f_x_size[FONT_NUM]; + col = 0; + while ( col < 2 &c > 0 ) + { + // check from right + for ( d = 0; d < f_y_size[FONT_NUM]; d ++ ) + if ( thefonts[FONT_NUM][str[a]*fsize + d*f_x_size[FONT_NUM] + ( c - 1 ) ] > 1 ) col = 2; + if ( col < 2 ) c --; + } + xpos2 = c; + if ( xpos1 > xpos2 ) + { + xpos1 = 0;xpos2 = f_x_size[FONT_NUM] / 2; + } + x1 = xpos1 - 1;if ( x1 < 0 ) x1 = 0; + x2 = xpos2 + 1;if ( x2 > f_x_size[FONT_NUM] ) x2 = f_x_size[FONT_NUM]; + for( d = 0; d < f_y_size[FONT_NUM]; d ++ ) + for( c = x1; c < x2; c ++ ) + { + px = ( c - xpos1 ) + x + ( textcnt ); + py = d + y; + col = thefonts[FONT_NUM][str[a]*fsize + ( d*f_x_size[FONT_NUM] ) + c]; + if ( px >= 0 ) if ( px < 320 ) if ( py >= 0 ) if ( py < scr_y_size ) + if ( col!= 0 ) + if ( cq!= 0 &&col!= 1 ) pixeli( px, py, ( char ) ( cq + d ) ); + else pixeli( px, py, 0 ); + } + textcnt += xpos2 - xpos1 + 1; + } +}; + +void writefonts2( int x, int y, char *str, int cq ) +{ + int a, c, d, xpos1, xpos2, col, textcnt, fsize = f_x_size[FONT_NUM]*f_y_size[FONT_NUM]; + textcnt = 0; + for ( a = 0; str[a]!= 0; a ++ ) + { + c = 0; + col = 0; + while ( col == 0 &c < f_x_size[FONT_NUM] ) + { + // check from left + for ( d = 0; d < f_y_size[FONT_NUM]; d ++ ) + if ( thefonts[FONT_NUM][str[a]*fsize + d*f_x_size[FONT_NUM] + ( c ) ]!= 0 ) col = 1; + if ( col == 0 ) c ++; + } + xpos1 = c; + c = f_x_size[FONT_NUM]; + col = 0; + while ( col == 0 &c > 0 ) + { + // check from right + for ( d = 0; d < f_y_size[FONT_NUM]; d ++ ) + if ( thefonts[FONT_NUM][str[a]*fsize + d*f_x_size[FONT_NUM] + ( c - 1 ) ]!= 0 ) col = 1; + if ( col == 0 ) c --; + } + xpos2 = c; + if ( xpos1 > xpos2 ) + { + xpos1 = 0;xpos2 = f_x_size[FONT_NUM] / 2; + } + for( d = 0; d < f_y_size[FONT_NUM]; d ++ ) + for( c = xpos1; c < xpos2; c ++ ) + if ( thefonts[FONT_NUM][str[a]*fsize + ( d*f_x_size[FONT_NUM] ) + c]!= 0 ) + if ( cq!= 0 ) pixeli( ( c - xpos1 ) + x + ( textcnt ), d + y, thefonts[FONT_NUM][str[a]*fsize + ( d*f_x_size[FONT_NUM] ) + c] ); + else pixeli( ( c - xpos1 ) + x + ( textcnt ), d + y, 0 ); + textcnt += xpos2 - xpos1 + 1; + } +}; + +int str_length( char *str ) +{ + int length = 0; + int a, c, d, col, xpos1, xpos2; + for ( a = 0; str[a]!= 0; a ++ ) + { + c = 0; + col = 0; + while ( col < 2 &&c < f_x_size[FONT_NUM] ) + { + // check from left + for ( d = 0; d < f_y_size[FONT_NUM]; d ++ ) + if ( thefonts[FONT_NUM][str[a]*( f_x_size[FONT_NUM]*f_y_size[FONT_NUM] ) + d*f_x_size[FONT_NUM] + ( c ) ] > 1 ) col = 2; + if ( col < 2 ) c ++; + }; + xpos1 = c; + c = f_x_size[FONT_NUM]; + col = 0; + while ( col < 2 &&c > 0 ) + { + // check from right + for ( d = 0; d < f_y_size[FONT_NUM]; d ++ ) + if ( thefonts[FONT_NUM][str[a]*( f_x_size[FONT_NUM]*f_y_size[FONT_NUM] ) + d*f_x_size[FONT_NUM] + ( c - 1 ) ] > 1 ) col = 2; + if ( col < 2 ) c --; + }; + xpos2 = c; + if ( xpos1 > xpos2 ) + { + xpos1 = 0;xpos2 = f_x_size[FONT_NUM] / 2; + } + length += xpos2 - xpos1 + 1; + } + return( length ); +} + +void readline( int x, int y, int len, char *str, char *screen ) +{ + int done = 0, a, dy; + char *bg; + int key; + bg = ( char* ) malloc( 320*f_y_size[FONT_NUM] ); + memcpy( bg, screen + x + ( y*320 ), 320*f_y_size[FONT_NUM] ); + while ( !done ) + { + writefonts2( x, y, str, 1 ); + for ( dy = 0; dy < f_y_size[FONT_NUM]; dy ++ ) + memcpy( screen + x + ( ( dy + y ) *320 ), virbuff + x + ( ( dy + y ) *320 ), len*f_x_size[FONT_NUM] ); + key = k.getch(); + if ( key!= 27&&key!= 8&&key!= 13 ) + if ( strlen( str ) < ( len - 1 ) ) + { + str[strlen( str ) + 1] = 0; + str[strlen( str ) ] = ( char ) key; + } + if ( key == 27 ) + { + str[0] = 0; + done = 1; + } + if ( key == 13 ) + { + done = 1; + } + if ( key == 8 ) + { + if ( strlen( str ) > 0 ) + str[strlen( str ) - 1] = 0; + a = str_length( str ) + x; + for ( dy = 0; dy < f_y_size[FONT_NUM]; dy ++ ) + memcpy( virbuff + a + ( ( dy + y ) *320 ), bg + ( dy*320 ) + str_length( str ), f_x_size[FONT_NUM] ); + } + } +} + +void freefonts() +{ + free( thefonts ); +} + diff --git a/SRC/WRITE.CPP b/SRC/WRITE.CPP new file mode 100644 index 0000000..4a6e0c7 --- /dev/null +++ b/SRC/WRITE.CPP @@ -0,0 +1,190 @@ +#include "globvar.h" +#include < stdlib.h > +#include < stdio.h > +#include < string.h > + +void pixeli( int x, int y, char col ) +{ + virbuff[( y * 320 ) + x] = col; +} + +void loadfonts( char *name ) +{ + FILE *fnt; + int a; + fnt = fopen( name, "rb" ); + f_x_size[FONT_NUM] = fgetc( fnt ); + f_y_size[FONT_NUM] = fgetc( fnt ); + thefonts[FONT_NUM] = ( char * ) malloc( f_y_size[FONT_NUM]*f_x_size[FONT_NUM]*256 ); + fseek( fnt, 256*2, 0 ); + for ( a = 0; a < f_x_size[FONT_NUM]*f_y_size[FONT_NUM]*256; a ++ ) + thefonts[FONT_NUM][a] = ( char ) fgetc( fnt ); + fclose( fnt ); +} + +void writefonts( int x, int y, char *str, int cq ) +{ + int a, c, d, xpos1, xpos2, col, textcnt, fsize = f_x_size[FONT_NUM]*f_y_size[FONT_NUM]; + int x1, x2, px, py; + textcnt = 0; + for ( a = 0; str[a]!= 0; a ++ ) + { + c = 0; + col = 0; + while ( col < 2 &c < f_x_size[FONT_NUM] ) + { + // check from left + for ( d = 0; d < f_y_size[FONT_NUM]; d ++ ) + if ( thefonts[FONT_NUM][str[a]*fsize + d*f_x_size[FONT_NUM] + ( c ) ] > 1 ) col = 2; + if ( col < 2 ) c ++; + } + xpos1 = c; + c = f_x_size[FONT_NUM]; + col = 0; + while ( col < 2 &c > 0 ) + { + // check from right + for ( d = 0; d < f_y_size[FONT_NUM]; d ++ ) + if ( thefonts[FONT_NUM][str[a]*fsize + d*f_x_size[FONT_NUM] + ( c - 1 ) ] > 1 ) col = 2; + if ( col < 2 ) c --; + } + xpos2 = c; + if ( xpos1 > xpos2 ) + { + xpos1 = 0;xpos2 = f_x_size[FONT_NUM] / 2; + } + x1 = xpos1 - 1;if ( x1 < 0 ) x1 = 0; + x2 = xpos2 + 1;if ( x2 > f_x_size[FONT_NUM] ) x2 = f_x_size[FONT_NUM]; + for( d = 0; d < f_y_size[FONT_NUM]; d ++ ) + for( c = x1; c < x2; c ++ ) + { + px = ( c - xpos1 ) + x + ( textcnt ); + py = d + y; + col = thefonts[FONT_NUM][str[a]*fsize + ( d*f_x_size[FONT_NUM] ) + c]; + if ( px >= 0 ) if ( px < 320 ) if ( py >= 0 ) if ( py < scr_y_size ) + if ( col!= 0 ) + if ( cq!= 0 &&col!= 1 ) pixeli( px, py, ( char ) ( cq + d ) ); + else pixeli( px, py, 0 ); + } + textcnt += xpos2 - xpos1 + 1; + } +}; + +void writefonts2( int x, int y, char *str, int cq ) +{ + int a, c, d, xpos1, xpos2, col, textcnt, fsize = f_x_size[FONT_NUM]*f_y_size[FONT_NUM]; + textcnt = 0; + for ( a = 0; str[a]!= 0; a ++ ) + { + c = 0; + col = 0; + while ( col == 0 &c < f_x_size[FONT_NUM] ) + { + // check from left + for ( d = 0; d < f_y_size[FONT_NUM]; d ++ ) + if ( thefonts[FONT_NUM][str[a]*fsize + d*f_x_size[FONT_NUM] + ( c ) ]!= 0 ) col = 1; + if ( col == 0 ) c ++; + } + xpos1 = c; + c = f_x_size[FONT_NUM]; + col = 0; + while ( col == 0 &c > 0 ) + { + // check from right + for ( d = 0; d < f_y_size[FONT_NUM]; d ++ ) + if ( thefonts[FONT_NUM][str[a]*fsize + d*f_x_size[FONT_NUM] + ( c - 1 ) ]!= 0 ) col = 1; + if ( col == 0 ) c --; + } + xpos2 = c; + if ( xpos1 > xpos2 ) + { + xpos1 = 0;xpos2 = f_x_size[FONT_NUM] / 2; + } + for( d = 0; d < f_y_size[FONT_NUM]; d ++ ) + for( c = xpos1; c < xpos2; c ++ ) + if ( thefonts[FONT_NUM][str[a]*fsize + ( d*f_x_size[FONT_NUM] ) + c]!= 0 ) + if ( cq!= 0 ) pixeli( ( c - xpos1 ) + x + ( textcnt ), d + y, thefonts[FONT_NUM][str[a]*fsize + ( d*f_x_size[FONT_NUM] ) + c] ); + else pixeli( ( c - xpos1 ) + x + ( textcnt ), d + y, 0 ); + textcnt += xpos2 - xpos1 + 1; + } +}; + +int str_length( char *str ) +{ + int length = 0; + int a, c, d, col, xpos1, xpos2; + for ( a = 0; str[a]!= 0; a ++ ) + { + c = 0; + col = 0; + while ( col < 2 &&c < f_x_size[FONT_NUM] ) + { + // check from left + for ( d = 0; d < f_y_size[FONT_NUM]; d ++ ) + if ( thefonts[FONT_NUM][str[a]*( f_x_size[FONT_NUM]*f_y_size[FONT_NUM] ) + d*f_x_size[FONT_NUM] + ( c ) ] > 1 ) col = 2; + if ( col < 2 ) c ++; + }; + xpos1 = c; + c = f_x_size[FONT_NUM]; + col = 0; + while ( col < 2 &&c > 0 ) + { + // check from right + for ( d = 0; d < f_y_size[FONT_NUM]; d ++ ) + if ( thefonts[FONT_NUM][str[a]*( f_x_size[FONT_NUM]*f_y_size[FONT_NUM] ) + d*f_x_size[FONT_NUM] + ( c - 1 ) ] > 1 ) col = 2; + if ( col < 2 ) c --; + }; + xpos2 = c; + if ( xpos1 > xpos2 ) + { + xpos1 = 0;xpos2 = f_x_size[FONT_NUM] / 2; + } + length += xpos2 - xpos1 + 1; + } + return( length ); +} + +void readline( int x, int y, int len, char *str, char *screen ) +{ + int done = 0, a, dy; + char *bg; + int key; + bg = ( char* ) malloc( 320*f_y_size[FONT_NUM] ); + memcpy( bg, screen + x + ( y*320 ), 320*f_y_size[FONT_NUM] ); + while ( !done ) + { + writefonts2( x, y, str, 1 ); + for ( dy = 0; dy < f_y_size[FONT_NUM]; dy ++ ) + memcpy( screen + x + ( ( dy + y ) *320 ), virbuff + x + ( ( dy + y ) *320 ), len*f_x_size[FONT_NUM] ); + key = k.getch(); + if ( key!= 27&&key!= 8&&key!= 13 ) + if ( strlen( str ) < ( len - 1 ) ) + { + str[strlen( str ) + 1] = 0; + str[strlen( str ) ] = ( char ) key; + } + if ( key == 27 ) + { + str[0] = 0; + done = 1; + } + if ( key == 13 ) + { + done = 1; + } + if ( key == 8 ) + { + if ( strlen( str ) > 0 ) + str[strlen( str ) - 1] = 0; + a = str_length( str ) + x; + for ( dy = 0; dy < f_y_size[FONT_NUM]; dy ++ ) + memcpy( virbuff + a + ( ( dy + y ) *320 ), bg + ( dy*320 ) + str_length( str ), f_x_size[FONT_NUM] ); + } + } +} + +void freefonts() +{ + free( thefonts ); +} + diff --git a/SRC/WRITE.H b/SRC/WRITE.H new file mode 100644 index 0000000..f45dfc9 --- /dev/null +++ b/SRC/WRITE.H @@ -0,0 +1,10 @@ +#ifndef __TK___WRITE__ +#define __TK___WRITE__ +void pixeli( int x, int y, char col ); +void loadfonts( char *name ); +void writefonts( int x, int y, char *str, int cq ); +void writefonts2( int x, int y, char *str, int cq ); +int str_length( char *str ); +void readline( int x, int y, int len, char *str, char *screen ); +void freefonts(); +#endif diff --git a/SRC/WRITE.OBJ b/SRC/WRITE.OBJ new file mode 100644 index 0000000..225c893 Binary files /dev/null and b/SRC/WRITE.OBJ differ diff --git a/TETRIS.FN2 b/TETRIS.FN2 new file mode 100644 index 0000000..4fb81f0 Binary files /dev/null and b/TETRIS.FN2 differ diff --git a/WAVS/DEATH.WAV b/WAVS/DEATH.WAV new file mode 100644 index 0000000..7e22117 Binary files /dev/null and b/WAVS/DEATH.WAV differ diff --git a/WAVS/EXPLO.WAV b/WAVS/EXPLO.WAV new file mode 100644 index 0000000..60325cf Binary files /dev/null and b/WAVS/EXPLO.WAV differ diff --git a/WAVS/FLAME.WAV b/WAVS/FLAME.WAV new file mode 100644 index 0000000..87a5cdb Binary files /dev/null and b/WAVS/FLAME.WAV differ diff --git a/WAVS/HIT.WAV b/WAVS/HIT.WAV new file mode 100644 index 0000000..f1a1393 Binary files /dev/null and b/WAVS/HIT.WAV differ diff --git a/WAVS/KLIK.WAV b/WAVS/KLIK.WAV new file mode 100644 index 0000000..e122e65 Binary files /dev/null and b/WAVS/KLIK.WAV differ diff --git a/WAVS/MAGNUM.WAV b/WAVS/MAGNUM.WAV new file mode 100644 index 0000000..35afbe7 Binary files /dev/null and b/WAVS/MAGNUM.WAV differ diff --git a/WAVS/PISTOL.WAV b/WAVS/PISTOL.WAV new file mode 100644 index 0000000..1178df7 Binary files /dev/null and b/WAVS/PISTOL.WAV differ diff --git a/WAVS/RIFLE.WAV b/WAVS/RIFLE.WAV new file mode 100644 index 0000000..479380e Binary files /dev/null and b/WAVS/RIFLE.WAV differ diff --git a/WAVS/SINKO.WAV b/WAVS/SINKO.WAV new file mode 100644 index 0000000..da5464d Binary files /dev/null and b/WAVS/SINKO.WAV differ diff --git a/WAVS/WOOSH.WAV b/WAVS/WOOSH.WAV new file mode 100644 index 0000000..50d4926 Binary files /dev/null and b/WAVS/WOOSH.WAV differ diff --git a/WHAT'S.NEW b/WHAT'S.NEW new file mode 100644 index 0000000..e299e6b --- /dev/null +++ b/WHAT'S.NEW @@ -0,0 +1,59 @@ + + + History of The --TK-- (Tapan Kaikki) + + + ---------------------------------------------------------------------------- + + * The Ultimate TK -------> + + 1.2 - * LAN (IPX) - Game! + * More Music. 3 More In-game songs added. + * TK has moved to SVGA! 320*240 resolution gives more visibility. + * Mines added. + * Shortcut keys for weapons added. + * Limits for bullet amounts added. + * Screen capture to PCX. + * Player rotation has now 40 positions instead of 32. + * Some new episodes by Blanket + * With editor v1.3 crates can be placed to certain points on levels. + + Many bugs fixed. + + 1.1 - Lots of work done with the source code. Episodes added -> + Users can make their own episodes by creating new directories under + LEVS dir. Flamethrower added !!!!! Some other improvements + (can't remember them all). One new episode (Blanket) included. + Moving speed for deathmatch can now be set to normal or fast. + This version was supposed to have network game but we had no time to + make it :( Maybe in next version... + + 1.0 - The first version of The Ultimate TK !!!!!! + Totally new game including Deathmatch game and Level editor. + Lots of other new features... + Because of new graphic effects game needs much more CPU speed + than The Original TK -> Pentium rules !!! + Lots of Original TK is still remaining for the spirit (ugh ugh). + + * The Original TK -------> + + 2.1 - The update to version 2.0 !!!!!! + Graphically better than v2.0. Some cool LIGHT EFFECTS added !!!! + Player can kick body parts and you have 900 money when you begin. + Screen fades are even more faster and some optimizations to code have + been made. For player rotation there are 32 positions instead of 16 now. + + 2.0 - MANY new things !!! New weapons (including auto shotgun), + few new levels and many other nice features. Now all enemies have + different graphics and if you want, you can't see through walls. + Screen fades were too slow in earlier versions and so they are + faster now. Changes to GUS problems have NOT been made !!! + STRAFE added and in two player game screen follows player very nicely ! + Even if it's not possible some bugs were found in version 1.1. + These bugs are now fixed and there are no known bugs in this version !!! + + 2.0 beta - The beta version of version 2.0. Lots of things were fixed + after this for full version 2.0 !!!!! + + 1.1 - Faster than v 1.0 because of optimized compiling. Now uses DOS4G + instead of PMODEW (just for fun). Still problems with GUS ??? + + 1.0 - The First version of TK ! GUS sounds didn't work properly in some + machines ???