From a931697f3be302466855163a7e216ffee7766445 Mon Sep 17 00:00:00 2001 From: kamil Date: Mon, 9 Nov 2020 23:37:05 +0000 Subject: Add Warp Kit, Version 7.0 by Larry Wall Warp is a real-time space war game that doesn't get boring very quickly. Read warp.doc and the manual page for more information. games/warp originally distributed with 4.3BSD-Reno, is back to the BSD world via NetBSD. Its remnants were still mentioned in games/Makefile. Larry Wall, the original author and the copyright holder, generously donated the game and copyright to The NetBSD Foundation, Inc. Import the game sources as-is from 4.3BSD-Reno, with the cession of the copyright and license to BSD-2-clause NetBSD-style. Signed-off-by: Larry Wall Signed-off-by: Kamil Rytarowski --- warp/bang.c | 171 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 warp/bang.c (limited to 'warp/bang.c') diff --git a/warp/bang.c b/warp/bang.c new file mode 100644 index 00000000..fa2cdeac --- /dev/null +++ b/warp/bang.c @@ -0,0 +1,171 @@ +/* $Header: /cvsroot/src/games/warp/bang.c,v 1.1 2020/11/09 23:37:05 kamil Exp $ */ + +/* $Log: bang.c,v $ +/* Revision 1.1 2020/11/09 23:37:05 kamil +/* Add Warp Kit, Version 7.0 by Larry Wall +/* +/* Warp is a real-time space war game that doesn't get boring very quickly. +/* Read warp.doc and the manual page for more information. +/* +/* games/warp originally distributed with 4.3BSD-Reno, is back to the BSD +/* world via NetBSD. Its remnants were still mentioned in games/Makefile. +/* +/* Larry Wall, the original author and the copyright holder, generously +/* donated the game and copyright to The NetBSD Foundation, Inc. +/* +/* Import the game sources as-is from 4.3BSD-Reno, with the cession +/* of the copyright and license to BSD-2-clause NetBSD-style. +/* +/* Signed-off-by: Larry Wall +/* Signed-off-by: Kamil Rytarowski +/* + * Revision 7.0.1.3 86/12/12 16:57:00 lwall + * Made circular explosions. + * + * Revision 7.0.1.2 86/10/20 14:36:02 lwall + * Picked some lint. + * + * Revision 7.0.1.1 86/10/16 10:49:45 lwall + * Added Damage. Fixed random bugs. + * + * Revision 7.0 86/10/08 15:11:57 lwall + * Split into separate files. Added amoebas and pirates. + * + */ + +#include "EXTERN.h" +#include "warp.h" +#include "object.h" +#include "move.h" +#include "sig.h" +#include "term.h" +#include "them.h" +#include "INTERN.h" +#include "bang.h" + +void +bang_init() +{ + ; +} + +void +make_plink(y,x) +Reg1 int x; +Reg2 int y; +{ + Reg3 OBJECT *obj; + + move(y+1,x*2,0); + beg_qwrite(); + *filler = '@'; + qwrite(); + obj = occupant[y][x]; + if (obj) { + if (numamoebas && obj->image == ' ') + qaddc(amb[y][x]); + else + qaddc(obj->image); + } + else if (numamoebas) + qaddc(amb[y][x]); + else + qaddspace(); + end_qwrite(); +} + +void +make_blast(y,x,mass,size) +Reg1 int x; +Reg2 int y; +int size; +long mass; +{ + bangy[nxtbang] = y; + bangx[nxtbang] = x; + bangm[nxtbang] = mass; + bangs[nxtbang++] = size; + assert(nxtbang <= XSIZE * YSIZE); + if (numamoebas && amb[y][x] == '~') { + if (mass > 10000) + modify_amoeba(y,x,1,'~', 10); + else if (mass > 100) + modify_amoeba(y,x,1,'~', 5); + bangs[nxtbang-1] = 0; /* don't propagate */ + return; + } + else if (mass >= 0) { + Reg3 OBJECT *obj; + + move(y+1,x*2,0); + beg_qwrite(); + *filler = '@'; + qwrite(); + *filler = '#'; + qwrite(); + *filler = '@'; + qwrite(); + *filler = '#'; + qwrite(); + *filler = '@'; + qwrite(); + obj = occupant[y][x]; + if (obj) { + if (numamoebas && obj->image == ' ') + qaddc(amb[y][x]); + else + qaddc(obj->image); + } + else if (numamoebas) + qaddc(amb[y][x]); + else + qaddspace(); + end_qwrite(); + } +} + +void +do_bangs() +{ + Reg1 int x; + Reg2 int y; + Reg3 int i; + Reg4 int j; + Reg7 int k; + Reg5 int lastxy; + Reg6 OBJECT *obj; + + /* read blast list and update blast array */ + assert(nxtbang >= 0 && nxtbang <= XSIZE * YSIZE); + for (i=0; i= MAXBDIST) + lastxy = MAXBDIST - 1; + for (y=bangy[i]-bangs[i],x=bangx[i]-bangs[i],j=lastxy; + j>=0; + y++,x++,--j) { + yblasted[yy[j] = (y+YSIZE00) % YSIZE] |= 1; + xblasted[xx[j] = (x+XSIZE00) % XSIZE] |= 1; + } + blasted = TRUE; + for (y=lastxy;y>=0;--y) { + for (x=lastxy;x>=0;--x) { + if (lastxy > 2) { + j = abs(y-bangs[i]); + k = abs(x-bangs[i]); + if (j < k) /* distance is long + 1/2 short */ + j += k + k; + else + j += j + k; + if (--j > lastxy) + continue; + } + if (bangm[i] != 32767 || + !(obj=occupant[yy[y]][xx[x]]) || obj->type != Web) + blast[yy[y]][xx[x]] += bangm[i]; + } + } + } +} -- cgit v1.2.3-56-ge451