v07i003: ularn - ultra-larn, an enhancement of the larn adventure game, Part03/08

7 views
Skip to first unread message

Bill Randle

unread,
Jul 6, 1989, 10:01:07 AM7/6/89
to
Submitted-by: "Philip A. Cordier" <ph...@sco.COM>
Posting-number: Volume 7, Issue 3
Archive-name: ularn/Part03

#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of archive 3 (of 8)."
# Contents: data.c io.c to_ansi.c
# Wrapped by billr@saab on Thu Jun 29 08:10:18 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'data.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'data.c'\"
else
echo shar: Extracting \"'data.c'\" \(29659 characters\)
sed "s/^X//" >'data.c' <<'END_OF_FILE'
X/* data.c */
X#include "header.h"
X
X/*
X class[c[LEVEL]-1] gives the correct name of the players experience level
X */
Xstatic char aa1[] = " mighty evil master";
Xstatic char aa2[] = "apprentice demi-god";
Xstatic char aa3[] = " minor demi-god ";
Xstatic char aa4[] = " major demi-god ";
Xstatic char aa5[] = " minor deity ";
Xstatic char aa6[] = " major deity ";
Xstatic char aa7[] = " novice guardian ";
Xstatic char aa8[] = "apprentice guardian";
Xstatic char aa9[] = " The Creator ";
Xchar *class[]=
X{
X" novice explorer ", "apprentice explorer", " practiced explorer",/* -3*/
X" expert explorer ", " novice adventurer", " adventurer ",/* -6*/
X"apprentice conjurer", " conjurer ", " master conjurer ",/* -9*/
X" apprentice mage ", " mage ", " experienced mage ",/* -12*/
X" master mage ", " apprentice warlord", " novice warlord ",/* -15*/
X" expert warlord ", " master warlord ", " apprentice gorgon ",/* -18*/
X" gorgon ", " practiced gorgon ", " master gorgon ",/* -21*/
X" demi-gorgon ", " evil master ", " great evil master ",/* -24*/
X aa1 , aa1 , aa1 ,/* -27*/
X aa1 , aa1 , aa1 ,/* -30*/
X aa1 , aa1 , aa1 ,/* -33*/
X aa1 , aa1 , aa1 ,/* -36*/
X aa1 , aa1 , aa1 ,/* -39*/
X aa2 , aa2 , aa2 ,/* -42*/
X aa2 , aa2 , aa2 ,/* -45*/
X aa2 , aa2 , aa2 ,/* -48*/
X aa3 , aa3 , aa3 ,/* -51*/
X aa3 , aa3 , aa3 ,/* -54*/
X aa3 , aa3 , aa3 ,/* -57*/
X aa4 , aa4 , aa4 ,/* -60*/
X aa4 , aa4 , aa4 ,/* -63*/
X aa4 , aa4 , aa4 ,/* -66*/
X aa5 , aa5 , aa5 ,/* -69*/
X aa5 , aa5 , aa5 ,/* -72*/
X aa5 , aa5 , aa5 ,/* -75*/
X aa6 , aa6 , aa6 ,/* -78*/
X aa6 , aa6 , aa6 ,/* -81*/
X aa6 , aa6 , aa6 ,/* -84*/
X aa7 , aa7 , aa7 ,/* -87*/
X aa8 , aa8 , aa8 ,/* -90*/
X aa8 , aa8 , aa8 ,/* -93*/
X" earth guardian ", " air guardian ", " fire guardian ",/* -96*/
X" water guardian ", " time guardian ", " ethereal guardian ",/* -99*/
X aa9 , aa9 , aa9 ,/* -102*/
X};
X
X/*
X table of experience needed to be a certain level of player
X skill[c[LEVEL]] is the experience required to attain the next level
X */
X#define MEG 1000000
Xlong skill[] = {
X0, 10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120, /* 1-11 */
X10240, 20480, 40960, 100000, 200000, 400000, 700000, 1*MEG, /* 12-19 */
X2*MEG,3*MEG,4*MEG,5*MEG,6*MEG,8*MEG,10*MEG, /* 20-26 */
X12*MEG,14*MEG,16*MEG,18*MEG,20*MEG,22*MEG,24*MEG,26*MEG,28*MEG, /* 27-35 */
X30*MEG,32*MEG,34*MEG,36*MEG,38*MEG,40*MEG,42*MEG,44*MEG,46*MEG, /* 36-44 */
X48*MEG,50*MEG,52*MEG,54*MEG,56*MEG,58*MEG,60*MEG,62*MEG,64*MEG, /* 45-53 */
X66*MEG,68*MEG,70*MEG,72*MEG,74*MEG,76*MEG,78*MEG,80*MEG,82*MEG, /* 54-62 */
X84*MEG,86*MEG,88*MEG,90*MEG,92*MEG,94*MEG,96*MEG,98*MEG,100*MEG, /* 63-71 */
X105*MEG,110*MEG,115*MEG,120*MEG, 125*MEG, 130*MEG, 135*MEG, 140*MEG, /* 72-79 */
X145*MEG,150*MEG,155*MEG,160*MEG, 165*MEG, 170*MEG, 175*MEG, 180*MEG, /* 80-87 */
X185*MEG,190*MEG,195*MEG,200*MEG, 210*MEG, 220*MEG, 230*MEG, 240*MEG, /* 88-95 */
X 260*MEG,280*MEG,300*MEG,320*MEG, 340*MEG, 370*MEG /* 96-101*/
X};
X#undef MEG
X
Xchar *lpbuf,*lpnt,
X *inbuffer,*lpend; /* input/output pointers to the buffers */
Xstruct cel *cell; /* pointer to the dungeon storage */
Xshort hitp[MAXX][MAXY]; /* monster hp on level */
Xshort iarg[MAXX][MAXY]; /* arg for the item array */
Xchar item[MAXX][MAXY]; /* objects in maze if any */
Xchar know[MAXX][MAXY]; /* 1 or 0 if here before */
Xchar mitem[MAXX][MAXY]; /* monster item array */
Xchar moved[MAXX][MAXY]; /* monster movement flags */
Xchar stealth[MAXX][MAXY];/* 0=sleeping 1=awake monst */
Xchar iven[26]; /* inventory for player */
Xshort ivenarg[26]; /* inventory args for player */
Xchar lastmonst[40]; /*this has the name of the current monster*/
Xchar beenhere[MAXLEVEL+MAXVLEVEL]={0}; /* 1 if have been on this level */
Xchar nosignal=0; /* set to 1 to disable the signals from doing anything*/
Xchar predostuff=0; /* 2 means that the trap handling routines must do a
X showplayer() after a trap. 0 means don't showplayer()
X 0 - we are in create player screen
X 1 - we are in welcome screen
X 2 - we are in the normal game */
Xchar loginname[20]; /* players login name */
Xchar logname[LOGNAMESIZE]; /* players name storage for scoring */
Xchar sex=1; /* default is a man 0=woman */
Xchar boldon=1; /* 1=bold objects 0=inverse objects */
Xchar ckpflag=0; /*1 if want checkpointing of game, 0 otherwise */
Xchar cheat=0; /*1 if the player has fudged save file */
Xchar level=0; /* cavelevel player is on = c[CAVELEVEL]*/
Xchar wizard=0; /* the wizard mode flag */
Xchar char_class[20]; /* character class */
Xshort lastnum=0; /* the number of the monster last hitting player*/
Xshort hitflag=0; /* flag for if player has been hit when running */
Xshort hit2flag=0; /* flag for if player has been hit when running */
Xshort hit3flag=0; /* flag for if player has been hit flush input*/
Xshort playerx,playery; /* the room on the present level of the player*/
Xshort lastpx,lastpy; /* 0 --- MAXX-1 or 0 --- MAXY-1 */
Xshort oldx,oldy;
Xshort lasthx=0,lasthy=0;/* location of monster last hit by player*/
Xshort nobeep=0; /* true if program is not to beep*/
Xunsigned long randx=33601; /* the random number seed */
Xlong initialtime=0; /* time playing began */
Xlong gtime=0; /* the clock for the game */
Xlong outstanding_taxes=0; /* present tax bill from score file */
Xlong c[100],cbak[100]; /* the character description arrays*/
Xint enable_scroll=0; /* constant for enabled/disabled scrolling regn */
Xchar aborted[] = " aborted";
Xstruct sphere *spheres=0; /*pointer to linked list for spheres of annihilation*/
X
Xchar *levelname[]= {
X" H"," 1"," 2"," 3"," 4"," 5"," 6"," 7"," 8"," 9","10","11","12","13","14","15",
X"V1","V2","V3","V4","V5"};
X
Xchar monstnamelist[]=" lGHJKOScjtAELNQRZabhiCTYdegmvzFWflorXV pqsyUkMwDDPxnDDuD ..............................................................";
X
Xchar objnamelist[]=" AToP%^F&^+M=%^$$f*OD#~][[)))(((||||||||{?!BC.o...<<<<EVV))([[]]](^ [H*** ^^ S tsTLcu...//))]:::::@.............................";
X
Xchar *objectname[]=
X{
X0,
X"a holy altar","a handsome jewel encrusted throne",
X"an orb of enlightenment",
X"a pit",
X"a staircase leading upwards",
X"an elevator going up",
X"a bubbling fountain",
X"a great marble statue",
X"a teleport trap",
X"the college of Larn",
X"a mirror",
X"the DND store",
X"a staircase going down",
X"an elevator going down",
X"the bank of Larn",
X"the 8th branch of the Bank of Larn",
X"a dead fountain",
X"gold",
X"an open door",
X"a closed door",
X"a wall",
X"The Eye of Larn",
X"plate mail",
X"chain mail",
X"leather armor",
X"a sword of slashing",
X"Bessman's flailing hammer",
X"a sunsword",
X"a two handed sword",
X"a spear",
X"a dagger",
X"ring of extra regeneration",
X"a ring of regeneration",
X"a ring of protection",
X"an energy ring",
X"a ring of dexterity",
X"a ring of strength",
X"a ring of cleverness",
X"a ring of increase damage",
X"a belt of striking",
X"a magic scroll",
X"a magic potion",
X"a book",
X"a chest",
X"an amulet of invisibility",
X"an orb of dragon slaying",
X"a scarab of negate spirit",
X"a cube of undead control",
X"a device of theft prevention",
X"a brilliant diamond",
X"a ruby",
X"an enchanting emerald",
X"a sparkling sapphire",
X"the dungeon entrance",
X"a volcanic shaft leaning downward",
X"the base of a volcanic shaft",
X"a battle axe",
X"a longsword",
X"a flail",
X"ring mail",
X"studded leather armor",
X"splint mail",
X"plate armor",
X"stainless plate armor",
X"a lance of death",
X"an arrow trap",
X"an arrow trap",
X"a shield",
X"your home",
X"gold",
X"gold",
X"gold",
X"a dart trap",
X"a dart trap",
X"a trapdoor",
X"a trapdoor",
X"the local trading post",
X"a teleport trap",
X"a massive throne",
X"a sphere of annihilation",
X"a handsome jewel encrusted throne",
X"the Larn Revenue Service",
X"a fortune cookie",
X"a golden urn",
X"a brass lamp",
X"The Hand of Fear",
X"The Talisman of the Sphere",
X"a wand of wonder",
X"a staff of power",
X"Vorpal",
X"Slayer",
X"elven chain",
X"some speed",
X"some LSD",
X"some hashish",
X"some magic mushrooms",
X"some cocaine",
X"Dealer McDope's Pad",
X"","","","","","","","","","",""
X};
X
X
X/*
X * for the monster data
X *
X * array to do rnd() to create monsters <= a given level
X */
Xchar monstlevel[] = {5, 11, 17, 22, 27, 33, 39, 42, 46, 50, 53, 56};
X
Xstruct monst monster[] = {
X/*NAME LV AC DAM ATT DEF GEN INT GOLD HP EXP
X ----------------------------------------------------------------- */
X{ "", 0, 0, 0, 0, 0, 0, 1, 0, 0, 0},
X{ "lemming",
X 1, 3, 0, 0, 0, 0, 3, 0, 0, 1},
X{ "gnome",
X 1, 10, 1, 0, 0, 0, 8, 30, 2, 2},
X{ "hobgoblin",
X 1, 13, 2, 0, 0, 0, 5, 25, 3, 2},
X{ "jackal",
X 1, 7, 1, 0, 0, 0, 4, 0, 1, 1},
X{ "kobold",
X 1, 15, 1, 0, 0, 0, 7, 10, 1, 1},
X{ "orc",
X 2, 15, 3, 0, 0, 0, 9, 40, 5, 2},
X{ "snake",
X 2, 10, 1, 0, 0, 0, 3, 0, 3, 1},
X{ "giant centipede",
X 2, 13, 1, 4, 0, 0, 3, 0, 2, 2},
X{ "jaculi",
X 2, 9, 1, 0, 0, 0, 3, 0, 2, 1} ,
X{ "troglodyte",
X 2, 10, 2, 0, 0, 0, 5, 80, 5, 3} ,
X{ "giant ant",
X 2, 8, 1, 4, 0, 0, 4, 0, 5, 4} ,
X
X/*NAME LV AC DAM ATT DEF GEN INT GOLD HP EXP
X ----------------------------------------------------------------- */
X{ "floating eye",
X 3, 8, 2, 0, 0, 0, 3, 0, 7, 2},
X{ "leprechaun",
X 3, 3, 0, 8, 0, 0, 3,1500, 15, 40},
X{ "nymph",
X 3, 3, 0, 14, 0, 0, 9, 0, 20, 40},
X{ "quasit",
X 3, 5, 3, 0, 0, 0, 3, 0, 14, 10},
X{ "rust monster",
X 3, 5, 0, 1, 0, 0, 3, 0, 18, 20} ,
X{ "zombie",
X 3, 12, 3, 0, 0, 0, 3, 0, 9, 7} ,
X{ "assassin bug",
X 4, 4, 3, 0, 0, 0, 3, 0, 23, 13} ,
X{ "bitbug",
X 4, 5, 4, 15, 0, 0, 5, 40, 24, 33} ,
X{ "hell hound",
X 4, 5, 2, 2, 0, 0, 6, 0, 20, 33} ,
X{ "ice lizard",
X 4, 11, 3, 10, 0, 0, 6, 50, 19, 23} ,
X{ "centaur",
X 4, 6, 4, 0, 0, 0, 10, 40, 25, 43} ,
X
X/*NAME LV AC DAM ATT DEF GEN INT GOLD HP EXP
X ----------------------------------------------------------------- */
X{ "troll",
X 5, 9, 5, 0, 0, 0, 9, 80, 55, 250} ,
X{ "yeti",
X 5, 8, 4, 0, 0, 0, 5, 50, 45, 90} ,
X{ "white dragon",
X 5, 4, 5, 5, 0, 0, 16, 500, 65, 1000} ,
X{ "elf",
X 5, 3, 3, 0, 0, 0, 15, 50, 25, 33} ,
X{ "gelatinous cube",
X 5, 9, 3, 0, 0, 0, 3, 0, 24, 43} ,
X{ "metamorph",
X 6, 9, 3, 0, 0, 0, 3, 0, 32, 40} ,
X{ "vortex",
X 6, 5, 4, 0, 0, 0, 3, 0, 33, 53} ,
X{ "ziller",
X 6, 15, 3, 0, 0, 0, 3, 0, 34, 33} ,
X{ "violet fungi",
X 6, 12, 3, 0, 0, 0, 3, 0, 39, 90} ,
X{ "wraith",
X 6, 3, 1, 6, 0, 0, 3, 0, 36, 300} ,
X{ "forvalaka",
X 6, 3, 5, 0, 0, 0, 7, 0, 55, 270} ,
X
X/*NAME LV AC DAM ATT DEF GEN INT GOLD HP EXP
X ----------------------------------------------------------------- */
X{ "lama nobe",
X 7, 14, 7, 0, 0, 0, 6, 0, 36, 70} ,
X{ "osequip",
X 7, 4, 7, 16, 0, 0, 4, 0, 36, 90} ,
X{ "rothe",
X 7, 15, 5, 0, 0, 0, 3, 100, 53, 230} ,
X{ "xorn",
X 7, 6, 7, 0, 0, 0, 13, 0, 63, 290} ,
X{ "vampire",
X 7, 5, 4, 6, 0, 0, 17, 0, 55, 950} ,
X{ "invisible stalker",
X 7, 5, 6, 0, 0, 0, 5, 0, 55, 330} ,
X{ "poltergeist",
X 8, 1, 8, 0, 0, 0, 3, 0, 55, 430} ,
X{ "disenchantress",
X 8, 3, 1, 9, 0, 0, 3, 0, 57, 500} ,
X{ "shambling mound",
X 8, 13, 5, 0, 0, 0, 6, 0, 47, 390} ,
X{ "yellow mold",
X 8, 12, 4, 0, 0, 0, 3, 0, 37, 240} ,
X{ "umber hulk",
X 8, 6, 7, 11, 0, 0, 14, 0, 67, 600} ,
X
X/*NAME LV AC DAM ATT DEF GEN INT GOLD HPEXP
X ----------------------------------------------------------------- */
X{ "gnome king",
X 9, -1, 10, 0, 0, 0, 18, 2000, 120,3000} ,
X{ "mimic",
X 9, 9, 7, 0, 0, 0, 8, 0, 57, 100} ,
X{ "water lord",
X 9, -10, 15, 7, 0, 0, 20, 0, 155,15000} ,
X{ "bronze dragon",
X 9, 5, 9, 3, 0, 0, 16, 300, 90, 4000} ,
X{ "green dragon",
X 9, 4, 4, 10, 0, 0, 15, 200, 80, 2500} ,
X{ "purple worm",
X 9, -1, 13, 0, 0, 0, 3, 100, 130,15000} ,
X{ "xvart",
X 9, -2, 14, 0, 0, 0, 13, 0, 100, 1000} ,
X{ "spirit naga",
X 10, -20, 15, 12, 0, 0, 23, 0, 100, 20000} ,
X{ "silver dragon",
X 10, -4, 10, 3, 0, 0, 20, 700, 110,10000} ,
X{ "platinum dragon",
X 10, -7, 15, 13, 0, 0, 22, 1000, 150,25000} ,
X{ "green urchin",
X 10, -5, 12, 0, 0, 0, 3, 0, 95, 5000} ,
X{ "red dragon",
X 10, -4, 13, 3, 0, 0, 19, 800, 120,14000} ,
X
X/*NAME LV AC DAM ATT DEF GEN INT GOLD HP EXP
X --------------------------------------------------------------------- */
X{ "type I demon lord",
X 12, -40, 20, 3, 0, 0, 20, 0, 150,50000} ,
X{ "type II demon lord",
X 13, -45, 25, 5, 0, 0, 22, 0, 200,75000} ,
X{ "type III demon lord",
X 14, -50, 30, 9, 0, 0, 24, 0, 250,100000} ,
X{ "type IV demon lord",
X 15, -55, 35, 11, 0, 0, 26, 0, 300,125000} ,
X{ "type V demon lord",
X 16, -60, 40, 13, 0, 0, 28, 0, 350,150000} ,
X{ "type VI demon lord",
X 17, -65, 45, 13, 0, 0, 30, 0, 400,175000} ,
X{ "type VII demon lord",
X 18, -70, 50, 6, 0, 0, 32, 0, 450,200000} ,
X{ "demon prince",
X 19, -100, 80, 6, 0, 0, 40, 0, 1000,500000} ,
X{ "God of Hellfire",
X 20, -127, 127, 6, 0, 0, 100, 0, 32767,1000000}
X};
X
X/* name array for scrolls */
Xchar *scrollname[] = {
X "\0enchant armor",
X "\0enchant weapon",
X "\0enlightenment",
X "\0blank paper",
X "\0create monster",
X "\0create artifact",
X "\0aggravate monsters",
X "\0time warp",
X "\0teleportation",
X "\0expanded awareness",
X "\0haste monsters",
X "\0monster healing",
X "\0spirit protection",
X "\0undead protection",
X "\0stealth",
X "\0magic mapping",
X "\0hold monsters",
X "\0gem perfection",
X "\0spell extension",
X "\0identify",
X "\0remove curse",
X "\0annihilation",
X "\0pulverization",
X "\0life protection",
X "\0 ",
X "\0 ",
X "\0 ",
X "\0 "
X};
X
X/* name array for magic potions */
Xchar *potionname[] = {
X "\0sleep",
X "\0healing",
X "\0raise level",
X "\0increase ability",
X "\0wisdom",
X "\0strength",
X "\0raise charisma",
X "\0dizziness",
X "\0learning",
X "\0gold detection",
X "\0monster detection",
X "\0forgetfulness",
X "\0water",
X "\0blindness",
X "\0confusion",
X "\0heroism",
X "\0sturdiness",
X "\0giant strength",
X "\0fire resistance",
X "\0treasure finding",
X "\0instant healing",
X " cure dianthroritis",
X "\0poison",
X "\0see invisible",
X "\0 ",
X "\0 ",
X "\0 ",
X "\0 ",
X "\0 ",
X "\0 ",
X "\0 ",
X "\0 ",
X "\0 ",
X "\0 ",
X "\0 "
X};
X
X
X/*
X i = rund((tmp=splev[lev])?tmp:1);
X i = rnd( (tmp=splev[lev]-9) ?tmp:1 ) + 9;
X */
Xchar spelknow[SPNUM]={0};
Xchar splev[] = {
X 1,4,7,11,15,
X 20,24,28,30,32,
X 33,34,35,36,37,
X 38,38,38,38,38,
X 38};
X
Xchar *spelcode[]={
X "pro", "mle", "dex", "sle", "chm", "ssp", /* 0 - 5 */
X "web", "str", "enl", "hel", "cbl", "cre", "pha", "inv", /*6-13 */
X "bal", "cld", "ply", "can", "has", "ckl", "vpr", /* 14-20 */
X "dry", "lit", "drl", "glo", "flo", "fgr", /* 21 - 26 */
X "sca", "hld", "stp", "tel", "mfi", "mkw", /* 27 - 34 */
X "sph", "gen", "sum", "wtw", "alt", "per" /* 35 - 38 */
X};
X
Xchar *spelname[]={
X "protection", /* 0 */
X "magic missile",
X "dexterity",
X "sleep",
X "charm monster",
X "sonic spear", /* 5 */
X "web",
X "strength",
X "enlightenment",
X "healing",
X "cure blindness", /* 10 */
X "create monster",
X "phantasmal forces",
X "invisibility",
X "fireball",
X "cold", /* 15 */
X "polymorph",
X "cancellation",
X "haste self",
X "cloud kill",
X "vaporize rock", /* 20 */
X "dehydration",
X "lightning",
X "drain life",
X "invulnerability",
X "flood", /* 25 */
X "finger of death",
X "scare monster",
X "hold monster",
X "time stop",
X "teleport away", /* 30 */
X "magic fire",
X "make a wall",
X "sphere of annihilation",
X "genocide", /* 34 */
X "summon demon",
X "walk through walls",
X "alter reality",
X "permanence", /* 38 */
X "" /* 39 */
X};
X
Xchar *speldescript[]={
X /* 1 */
X "generates a +2 protection field",
X "creates and hurls a magic missile equivalent to a + 1 magic arrow",
X "adds +2 to the casters dexterity",
X "causes some monsters to go to sleep",
X "some monsters may be awed at your magnificence",
X "causes your hands to emit a screeching sound toward what they point",
X /* 7 */
X "causes strands of sticky thread to entangle an enemy",
X "adds +2 to the casters strength for a short term",
X "the caster becomes aware of things around him",
X "restores some hp to the caster",
X "restores sight to one so unfortunate as to be blinded",
X "creates a monster near the caster appropriate for the location",
X "creates illusions, and if believed, monsters die",
X "the caster becomes invisible",
X /* 15 */
X "makes a ball of fire that burns on what it hits",
X "sends forth a cone of cold which freezes what it touches",
X "you can find out what this does for yourself",
X "negates the ability of a monster to use his special abilities",
X "speeds up the casters movements",
X "creates a fog of poisonous gas which kills all that is within it",
X "this changes rock to air",
X /* 22 */
X "dries up water in the immediate vicinity",
X "you finger will emit a lightning bolt when this spell is cast",
X "subtracts hit points from both you and a monster",
X "this globe helps to protect the player from physical attack",
X "this creates an avalanche of H2O to flood the immediate chamber",
X "this is a holy spell and calls upon your god to back you up",
X /* 28 */
X "terrifies the monster so that hopefully he wont hit the magic user",
X "the monster is frozen in his tracks if this is successful",
X "all movement in the caverns ceases for a limited duration",
X "moves a particular monster around in the dungeon (hopefully away from you)",
X "this causes a curtain of fire to appear all around you",
X /* 33 */
X "makes a wall in the place you specify",
X "anything caught in this sphere is instantly killed. Warning -- dangerous",
X "eliminates a species of monster from the game -- use sparingly",
X "summons a demon who hopefully helps you out",
X "allows the player to walk through walls for a short period of time",
X "god only knows what this will do",
X "makes a character spell permanent, i. e. protection, strength, etc.",
X ""
X};
X
Xchar spelweird[MAXMONST+8][SPNUM] = {
X/*p m d s c s w s e h c c p i b c p c h c v d l d g f f s h s t m s g s w a p */
X/* lemming */
X{ 0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/*gnome */
X{ 0,0,0,0,0,0, 0,0,0,0,0,0,0,5, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* hobgoblin */
X{ 0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* jackal */
X{ 0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* kobold */
X{ 0,0,0,0,0,0, 0,0,0,0,0,0,0,5, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X
X/*p m d s c s w s e h c c p i b c p c h c v d l d g f f s h s t m s g s w a p */
X /* orc */
X{ 0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* snake */
X{ 0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/*giant centipede */
X{ 0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* jaculi */
X{ 0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* troglodyte */
X{ 0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X
X/*p m d s c s w s e h c c p i b c p c h c v d l d g f f s h s t m s g s w a p */
X/* giant ant */
X{ 0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* floating eye */
X{ 0,0,0,8,0,10, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,4, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* leprechaun */
X{ 0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* nymph */
X{ 0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* quasit */
X{ 0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X
X/* rust monster */
X{ 0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* zombie */
X{ 0,0,0,8,0,4, 0,0,0,0,0,0,4,0, 0,0,0,0,0,4,0, 4,0,4,0,0,4, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* assassin bug */
X{ 0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* bugbear */
X{ 0,0,0,0,0,0, 0,0,0,0,0,0,0,5, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* hell hound */
X{ 0,6,0,0,0,0, 12,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X
X/*p m d s c s w s e h c c p i b c p c h c v d l d g f f s h s t m s g s w a p */
X/* ice lizard */
X{ 0,0,0,0,0,0, 11,0,0,0,0,0,0,0, 0,15,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* centaur */
X{ 0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* troll */
X{ 0,7,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 4,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* yeti */
X{ 0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,15,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* white dragon */
X{ 0,0,0,0,0,0, 0,0,0,0,0,0,14,0, 0,15,0,0,0,0,0, 4,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X
X/* elf */
X{ 0,0,0,0,0,0, 0,0,0,0,0,0,14,5, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/*gelatinous cube */
X{ 0,13,0,8,0,10, 2,0,0,0,0,0,0,0, 0,0,0,0,0,4,0, 0,0,0,0,0,4, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* metamorph */
X{ 0,13,0,0,0,0, 2,0,0,0,0,0,0,0, 0,0,0,0,0,4,0, 4,0,0,0,0,4, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* vortex */
X{ 0,13,0,0,0,10, 1,0,0,0,0,0,0,0, 0,0,0,0,0,4,0, 4,0,0,0,4,4, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* ziller */
X{ 0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X
X/*p m d s c s w s e h c c p i f c p c h c v d l d g f f s h s t m s g s w a p */
X/* violet fungi */
X{ 0,0,0,8,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,4, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* wraith */
X{ 0,13,0,8,0,4, 0,0,0,0,0,0,14,0, 0,0,0,0,0,4,0, 4,0,4,0,0,4, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* forvalaka */
X{ 0,0,0,0,0,0, 0,0,0,0,0,0,0,5, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* lama nobe */
X{ 0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* osequip */
X{ 0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* rothe */
X{ 0,7,0,0,0,0, 0,0,0,0,0,0,0,5, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* xorn */
X{ 0,7,0,8,0,0, 0,0,0,0,0,0,0,5, 0,0,0,0,0,0,0, 4,0,0,0,4,4, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* vampire */
X{ 0,0,0,0,0,4, 2,0,0,0,0,0,14,0, 0,0,0,0,0,4,0, 0,0,4,0,0,4, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/*invisible staker*/
X{ 0,0,0,0,0,0, 1,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* poltergeist */
X{ 0,13,0,8,0,4, 1,0,0,0,0,0,0,0, 0,4,0,0,0,4,0, 4,0,4,0,4,4, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X
X/*p m d s c s w s e h c c p i b c p c h c v d l d g f f s h s t m s g s w a p */
X/* disenchantress */
X{ 0,0,0,8,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/*shambling mound */
X{ 0,0,0,0,0,10, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* yellow mold */
X{ 0,0,0,8,0,10, 1,0,0,0,0,0,0,0, 0,0,0,0,0,4,0, 0,0,0,0,0,4, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* umber hulk */
X{ 0,7,0,0,0,0, 0,0,0,0,0,0,0,5, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* gnome king */
X{ 0,7,0,0,3,0, 0,0,0,0,0,0,0,5, 0,0,9,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X
X/* mimic */
X{ 0,0,0,0,0,0, 2,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* water lord */
X{ 0,13,0,8,3,4, 1,0,0,0,0,0,0,0, 0,0,9,0,0,4,0, 0,0,0,0,16,4, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* bronze dragon */
X{ 0,7,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* green dragon */
X{ 0,7,0,0,0,0, 11,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* purple worm */
X{ 0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X
X/*p m d s c s w s e h c c p i b c p c h c v d l d g f f s h s t m s g s w a p */
X/* xvart */
X{ 0,13,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,4,4, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* spirit naga */
X{ 0,13,0,8,3,4, 1,0,0,0,0,0,14,5, 0,4,9,0,0,4,0, 4,0,4,0,4,4, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* silver dragon */
X{ 0,6,0,9,0,0, 12,0,0,0,0,0,0,0, 0,0,9,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/*platinum dragon */
X{ 0,7,0,9,0,0, 11,0,0,0,0,0,14,0, 0,0,9,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* green urchin */
X{ 0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X/* red dragon */
X{ 0,6,0,0,0,0, 12,0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0 } ,
X
X/*p m d s c s w s e h c c p i b c p c h c v d l d g f f s h s t m s g s w a p */
X/*demon lord */
X{ 0,13,0,8,3,10, 1,0,0,0,0,0,14,5, 0,0,9,0,0,4,0, 4,0,9,0,4,4, 3,0,0,9,4, 9,0,0,0,0,0 } ,
X/*demon lord */
X{ 0,13,0,8,3,10, 1,0,0,0,0,0,14,5, 0,0,9,0,0,4,0, 4,0,9,0,4,4, 3,0,0,9,4, 9,0,0,0,0,0 } ,
X/*demon lord */
X{ 0,13,0,8,3,10, 1,0,0,0,0,0,14,5, 0,0,9,0,0,4,0, 4,0,9,0,4,4, 3,0,0,9,4, 9,0,0,0,0,0 } ,
X/*demon lord */
X{ 0,13,0,8,3,10, 1,0,0,0,0,0,14,5, 0,0,9,0,0,4,0, 4,0,9,0,4,4, 3,0,0,9,4, 9,0,0,0,0,0 } ,
X/*demon lord */
X{ 0,13,0,8,3,10, 1,0,0,0,0,0,14,5, 0,0,9,0,0,4,0, 4,0,9,0,4,4, 3,0,0,9,4, 9,0,0,0,0,0 } ,
X/*demon lord */
X{ 0,13,0,8,3,10, 1,0,0,0,0,0,14,5, 0,0,4,0,0,4,0, 4,0,0,0,4,4, 3,0,0,9,4, 9,0,0,0,0,0 } ,
X/*demon lord */
X{ 0,13,0,8,3,10, 1,0,0,0,0,0,14,5, 0,0,4,0,0,4,0, 4,0,0,0,4,4, 3,0,0,9,4, 9,0,0,0,0,0 } ,
X
X/*p m d s c s w s e h c c p i b c p c h c v d l d g f f s h s t m s g s w a p */
X/*demon prince */
X{ 0,13,0,8,3,10, 1,0,0,0,0,0,14,5, 0,0,4,0,0,4,0, 4,0,4,0,4,4, 3,0,0,9,4, 9,0,0,0,0,0 } ,
X/*p m d s c s w s e h c c p i b c p c h c v d l d g f f s h s t m s g s w a p */
X/* God of Hellfire */
X{ 0,13,0,8,3,10, 1,0,0,0,0,0,14,5, 18,0,9,0,0,4,0, 4,18,4,0,0,4, 4,4,0,9,4, 9,0,17,0,0,0 }
X};
X
Xchar *spelmes[] = {
X "",
X /* 1 */ "the web had no effect on the %s",
X /* 2 */ "the %s changed shape to avoid the web",
X /* 3 */ "the %s isn't afraid of you",
X /* 4 */ "the %s isn't affected",
X /* 5 */ "the %s can see you with his infravision",
X /* 6 */ "the %s vaporizes your missile",
X /* 7 */ "your missile bounces off the %s",
X /* 8 */ "the %s doesn't sleep",
X /* 9 */ "the %s resists",
X /* 10 */ "the %s can't hear the noise",
X /* 11 */ "the %s's tail cuts it free of the web",
X /* 12 */ "the %s burns through the web",
X /* 13 */ "your missiles pass right through the %s",
X /* 14 */ "the %s sees through your illusions",
X /* 15 */ "the %s loves the cold!",
X /* 16 */ "the %s loves the water!",
X /* 17 */ "the demon is terrified of the %s!",
X /* 18 */ "the %s loves fire and lightning!"
X};
X
X/*
X * function to create scroll numbers with appropriate probability of
X * occurrence
X *
X * 0 - armor 1 - weapon
X * 2 - enlightenment 3 - paper
X * 4 - create monster 5 - create item
X * 6 - aggravate 7 - time warp
X * 8 - teleportation 9 - expanded awareness
X * 10 - haste monst 11 - heal monster
X * 12 - spirit protection 13 - undead protection
X * 14 - stealth 15 - magic mapping
X * 16 - hold monster 17 - gem perfection
X * 18 - spell extension 19 - identify
X * 20 - remove curse 21 - annihilation
X * 22 - pulverization 23 - life protection
X */
Xchar scprob[]= {
X 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3,
X 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8,
X 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 13,
X 14, 14, 15, 15, 16, 16, 16, 17, 17, 18, 18, 19, 19, 19, 20, 20, 20, 20,
X 21, 22, 22, 22, 23 };
X
X/*
X * function to return a potion number created with appropriate probability
X * of occurrence
X *
X * 0 - sleep 1 - healing 2 - raise level
X * 3 - increase ability 4 - gain wisdom 5 - gain strength
X * 6 - charisma 7 - dizziness 8 - learning
X * 9 - gold detection 10 - monster detection 11 - forgetfulness
X * 12 - water 13 - blindness 14 - confusion
X * 15 - heroism 16 - sturdiness 17 - giant strength
X * 18 - fire resistance 19 - treasure finding 20 - instant healing
X * 21 - cure dianthroritis 22 - poison 23 - see invisible
X */
Xchar potprob[] = {
X0, 0, 1, 1, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 9, 9, 9, 10, 10, 10,
X11, 11, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 20, 22, 22, 23, 23 };
X
Xchar nlpts[] = { 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 5, 6, 7 };
Xchar nch[] = { 0, 0, 0, 1, 1, 1, 2, 2, 3, 4 };
Xchar nplt[] = { 0, 0, 0, 0, 1, 1, 2, 2, 3, 4 };
Xchar ndgg[] = { 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 4, 5 };
Xchar nsw[] = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 3 };
END_OF_FILE
if test 29659 -ne `wc -c <'data.c'`; then
echo shar: \"'data.c'\" unpacked with wrong size!
fi
# end of 'data.c'
fi
if test -f 'io.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'io.c'\"
else
echo shar: Extracting \"'io.c'\" \(20742 characters\)
sed "s/^X//" >'io.c' <<'END_OF_FILE'
X/* io.c
X *
X * Below are the functions in this file:
X *
X * setupvt100() Subroutine to set up terminal in correct mode for game
X * clearvt100() Subroutine to clean up terminal when the game is over
X * getcharacter() Routine to read in one character from the terminal
X * scbr() Function to set cbreak -echo for the terminal
X * sncbr() Function to set -cbreak echo for the terminal
X * newgame() Subroutine to save the initial time and seed rnd()
X *
X * FILE OUTPUT ROUTINES
X *
X * lprintf(format,args . . .) printf to the output buffer
X * lprint(integer) send binary integer to output buffer
X * lwrite(buf,len) write a buffer to the output buffer
X * lprcat(str) sent string to output buffer
X *
X * FILE OUTPUT MACROS (in header.h)
X *
X * lprc(character) put the character into the output buffer
X *
X * FILE INPUT ROUTINES
X *
X * long lgetc() read one character from input buffer
X * long lrint() read one integer from input buffer
X * lrfill(address,number) put input bytes into a buffer
X * char *lgetw() get a whitespace ended word from input
X * char *lgetl() get a \n or EOF ended line from input
X *
X * FILE OPEN / CLOSE ROUTINES
X *
X * lcreat(filename) create a new file for write
X * lopen(filename) open a file for read
X * lappend(filename) open for append to an existing file
X * lrclose() close the input file
X * lwclose() close output file
X * lflush() flush the output buffer
X *
X * Other Routines
X *
X * cursor(x,y) position cursor at [x,y]
X * cursors() position cursor at [1,24] (saves memory)
X * cl_line(x,y) Clear line at [1,y] and leave cursor at [x,y]
X * cl_up(x,y) Clear screen from [x,1] to current line.
X * cl_dn(x,y) Clear screen from [1,y] to end of display.
X * standout(str) Print the string in standout mode.
X * set_score_output() Called when output should be literally printed.
X ** putcharacter(ch) Print one character in decoded output buffer.
X ** flush_buf() Flush buffer with decoded output.
X ** init_term() Terminal initialization -- setup termcap info
X **char *tmcapcnv(sd,ss) Routine to convert vt100 \33's to termcap format
X * beep() Routine to emit a beep if enabled (see no-beep in .Ularnopts)
X *
X * Note: ** entries are available only in termcap mode.
X */
X#include "header.h"
X
X#ifdef BSD
X# define GTTY(arg) (ioctl(0, TIOCGETP, arg))
X# define STTY(arg) (ioctl(0, TIOCSETP, arg))
X static struct sgttyb inittyb, curttyb;
X#else /* SYSV */
X# define GTTY(arg) (ioctl(0, TCGETA, arg))
X# define STTY(arg) (ioctl(0, TCSETAW, arg))
X# define SPEED(x) ((x).c_cflag & CBAUD)
X static struct termio inittyb, curttyb;
X#endif /* BSD */
X
X#define ON 1
X#define OFF 0
X
Xextern short ospeed;
X
X#define LINBUFSIZE 128 /* size of the lgetw() and lgetl() buffer */
Xint lfd; /* output file numbers */
Xint fd; /* input file numbers */
Xstatic int ipoint=MAXIBUF,iepoint=MAXIBUF; /* input buffering pointers */
Xstatic char lgetwbuf[LINBUFSIZE]; /* get line (word) buffer*/
X
X/*
X * setupvt100()
X * Subroutine to set up terminal in correct mode for game
X * Attributes off, clear screen, set scrolling region, set tty mode
X */
Xsetupvt100()
X{
X clear();
X setscroll();
X gettty();
X}
X
X/*
X * clearvt100()
X * Subroutine to clean up terminal when the game is over
X * Attributes off, clear screen, unset scrolling region, restore tty mode
X */
Xclearvt100()
X{
X resetscroll();
X clear();
X settty();
X}
X
X/*
X** gettty
X**
X** Get initial state of terminal, set ospeed (for termcap routines)
X** and switch off tab expansion
X*/
Xgettty()
X{
X if(GTTY(&inittyb) < 0) {
X fprintf(stderr, "OOPS: gettty failed\n");
X fflush(stderr);
X return;
X }
X curttyb = inittyb;
X#ifndef BSD
X ospeed = SPEED(inittyb);
X /* do not expand tabs - they might be needed inside a cm sequence */
X if(curttyb.c_oflag & TAB3) {
X curttyb.c_oflag &= ~TAB3;
X setctty();
X }
X#endif /* BSD */
X setuptty();
X}
X
X/*
X** settty
X**
X** reset terminal to original state
X*/
Xsettty()
X{
X if(STTY(&inittyb) < 0) {
X fprintf(stderr, "OOPS: settty failed\n");
X fflush(stderr);
X }
X}
X
X/*
X** setctty
X**
X** set current tty
X*/
Xsetctty(){
X if(STTY(&curttyb) < 0) {
X fprintf(stderr, "OOPS: setctty failed\n");
X fflush(stderr);
X }
X}
X
X
X/*
X**
X** function to setup all required terminal modes for game
X*/
Xsetuptty(){
X int change = 0;
X#ifdef BSD
X scbr();
X#else /* SYSV */
X if((curttyb.c_lflag & ECHO) != OFF){
X curttyb.c_lflag &= ~ECHO;
X change++;
X }
X if((curttyb.c_lflag & ICANON) != !(ICANON)){
X curttyb.c_lflag &= ~ICANON;
X curttyb.c_lflag |= !(ICANON);
X /* be satisfied with one character; no timeout */
X curttyb.c_cc[VMIN] = 1; /* was VEOF */
X curttyb.c_cc[VTIME] = 0; /* was VEOL */
X change++;
X }
X if(change)
X setctty();
X#endif /* BSD */
X}
X
X/*
X * scbr() Function to set cbreak -echo for the terminal
X *
X * like: system("stty cbreak -echo")
X */
Xscbr()
X{
X#ifdef BSD
X curttyb.sg_flags |= CBREAK;
X curttyb.sg_flags &= ~ECHO;
X#else /* SYSV */
X curttyb.c_lflag &= ~ECHO;
X curttyb.c_lflag &= ~ICANON;
X#endif /* BSD */
X setctty();
X}
X
X/*
X * sncbr() Function to set -cbreak echo for the terminal
X *
X * like: system("stty -cbreak echo")
X */
Xsncbr()
X{
X#ifdef BSD
X curttyb.sg_flags &= ~CBREAK;
X curttyb.sg_flags |= ECHO;
X#else /* SYSV */
X curttyb.c_lflag |= ECHO;
X curttyb.c_lflag |= ICANON;
X#endif /* BSD */
X setctty();
X}
X
X/*
X * getcharacter() Routine to read in one character from the terminal
X */
Xgetcharacter()
X{
X char byt;
X
X lflush(); /* be sure output buffer is flushed */
X read(0,&byt,1); /* get byte from terminal */
X return(byt);
X}
X
X/*
X * newgame()
X * Subroutine to save the initial time and seed rnd()
X */
Xnewgame()
X{
X register long *p,*pe;
X
X for (p=c,pe=c+100; p<pe; *p++ =0)
X ;
X time(&initialtime);
X srand(initialtime);
X lcreat((char*)0); /* open buffering for output to terminal */
X}
X
X/*
X * lprintf(format,args . . .) printf to the output buffer
X * char *format;
X * ??? args . . .
X *
X * Enter with the format string in "format", as per printf() usage
X * and any needed arguments following it
X *Note: lprintf() only supports %s, %c and %d, with width modifier and left
X * or right justification.
X * No correct checking for output buffer overflow is done, but flushes
X * are done beforehand if needed.
X * Returns nothing of value.
X */
X/*VARARGS*/
Xlprintf(va_alist)
Xva_dcl
X{
X va_list ap; /* pointer for variable argument list */
X char *fmt;
X char *outb,*tmpb;
X long wide,left,cont,n; /* data for lprintf */
X char db[12]; /* %d buffer in lprintf */
X
X va_start(ap); /* initialize the var args pointer */
X fmt = va_arg(ap, char *); /* pointer to format string */
X if (lpnt >= lpend) lflush();
X outb = lpnt;
X for ( ; ; ) {
X while (*fmt != '%')
X if (*fmt) *outb++ = *fmt++;
X else {
X lpnt=outb;
X return;
X }
X wide = 0;
X left = 1;
X cont=1;
X while (cont)
X switch(*(++fmt)) {
X case 'd':
X n = va_arg(ap, long);
X if (n<0) {
X n = -n;
X *outb++ = '-';
X if (wide) --wide;
X }
X tmpb = db+11;
X *tmpb = (char)(n % 10 + '0');
X while (n>9)
X *(--tmpb) = (char)((n /= 10) % 10+'0');
X if (wide==0)
X while (tmpb < db+12)
X *outb++ = *tmpb++;
X else {
X wide -= db-tmpb+12;
X if (left)
X while (wide-- > 0)
X *outb++ = ' ';
X while (tmpb < db+12)
X *outb++ = *tmpb++;
X if (left==0)
X while (wide-- > 0)
X *outb++ = ' ';
X }
X cont=0;
X break;
X
X case 's':
X tmpb = va_arg(ap, char *);
X if (wide==0) {
X while (*outb++ = *tmpb++);
X --outb;
X }
X else {
X n = wide - strlen(tmpb);
X if (left)
X while (n-- > 0)
X *outb++ = ' ';
X while (*outb++ = *tmpb++)
X ;
X --outb;
X if (left==0)
X while (n-- > 0)
X *outb++ = ' ';
X }
X cont=0;
X break;
X
X case 'c':
X *outb++ = va_arg(ap, int);
X cont=0;
X break;
X
X case '0':
X case '1':
X case '2':
X case '3':
X case '4':
X case '5':
X case '6':
X case '7':
X case '8':
X case '9':
X wide = 10*wide + *fmt - '0';
X break;
X case '-':
X left = 0;
X break;
X default:
X *outb++ = *fmt;
X cont=0;
X break;
X };
X fmt++;
X }
X va_end(ap);
X}
X
X/*
X * lprint(long-integer)
X * long integer;
X *
X * send binary integer to output buffer
X *
X * +---------+---------+---------+---------+
X * | high | | | low |
X * | order | | | order |
X * | byte | | | byte |
X * +---------+---------+---------+---------+
X * 31 --- 24 23 --- 16 15 --- 8 7 --- 0
X *
X * The save order is low order first, to high order (4 bytes total)
X * and is written to be system independent.
X * No checking for output buffer overflow is done, but flushes if needed!
X * Returns nothing of value.
X */
Xlprint(x)
Xlong x;
X{
X if (lpnt >= lpend)
X lflush();
X *lpnt++ = 255 & x;
X *lpnt++ = 255 & (x>>8);
X *lpnt++ = 255 & (x>>16);
X *lpnt++ = 255 & (x>>24);
X}
X
X/*
X * lwrite(buf,len)
X * char *buf;
X * int len;
X *
X * write a buffer to the output buffer
X *
X * Enter with the address and number of bytes to write out
X * Returns nothing of value
X */
Xlwrite(buf,len)
Xchar *buf;
Xint len;
X{
X register char *str;
X register int num2;
X
X if (len > 399) /* don't copy data if can just write it */
X {
X for (str=buf; len>0; --len)
X lprc(*str++);
X lflush();
X write(lfd,buf,len);
X }
X else while (len) {
X if (lpnt >= lpend)
X lflush(); /* if buffer is full flush it */
X
X /* # bytes left in output buffer */
X num2 = lpbuf+BUFBIG-lpnt;
X
X if (num2 > len) num2=len;
X str = lpnt;
X len -= num2;
X while (num2--) *str++ = *buf++; /* copy in the bytes */
X lpnt = str;
X }
X}
X
X/*
X * long lgetc() Read one character from input buffer
X *
X * Returns 0 if EOF, otherwise the character
X */
Xlong lgetc()
X{
X int i;
X
X if (ipoint != iepoint)
X return(inbuffer[ipoint++]);
X if (iepoint!=MAXIBUF)
X return(0);
X if ((i=read(fd,inbuffer,MAXIBUF))<=0) {
X if (i!=0)
X fprintf(stderr,"error reading from input file\n");
X iepoint = ipoint = 0;
X return(0);
X }
X ipoint=1;
X iepoint=i;
X return(*inbuffer);
X}
X
X/*
X * long lrint() Read one integer from input buffer
X *
X * +---------+---------+---------+---------+
X * | high | | | low |
X * | order | | | order |
X * | byte | | | byte |
X * +---------+---------+---------+---------+
X * 31 --- 24 23 --- 16 15 --- 8 7 --- 0
X *
X * The save order is low order first, to high order (4 bytes total)
X * Returns the int read
X */
Xlong lrint()
X{
X unsigned long i;
X
X i = 255 & lgetc();
X i |= (255 & lgetc()) << 8;
X i |= (255 & lgetc()) << 16;
X i |= (255 & lgetc()) << 24;
X return(i);
X}
X
X/*
X * lrfill(address,number) put input bytes into a buffer
X * char *address;
X * int number;
X *
X * Reads "number" bytes into the buffer pointed to by "address".
X * Returns nothing of value
X */
Xlrfill(adr,num)
Xchar *adr;
Xint num;
X{
X char *pnt;
X int num2;
X
X while (num) {
X if (iepoint == ipoint) {
X if (num>5) {
X if (read(fd,adr,num) != num)
X fprintf(stderr,"error reading from input file\n");
X num=0;
X }
X else {
X *adr++ = lgetc();
X --num;
X }
X }
X else {
X /* # of bytes left in the buffer */
X num2 = iepoint-ipoint;
X
X if (num2 > num)
X num2=num;
X pnt = inbuffer+ipoint;
X num -= num2;
X ipoint += num2;
X while (num2--)
X *adr++ = *pnt++;
X }
X }
X}
X
X/*
X * char *lgetw() Get a whitespace ended word from input
X *
X * Returns pointer to a buffer that contains word. If EOF, returns a 0
X */
Xchar *lgetw()
X{
X char *lgp,cc;
X int n=LINBUFSIZE,quote=0;
X
X lgp = lgetwbuf;
X
X do
X cc=lgetc();
X while ((cc <= ' ') && (cc > 0)); /* eat whitespace */
X
X for ( ; ; --n,cc=lgetc()) {
X if ((cc==0) && (lgp==lgetwbuf)) return(0); /* EOF */
X if ((n<=1) || ((cc<=32) && (quote==0))) {
X *lgp=0;
X return(lgetwbuf);
X }
X if (cc != '"') *lgp++ = cc;
X else quote ^= 1;
X }
X}
X
X/*
X * char *lgetl()
X * Function to read in a line ended by newline or EOF
X *
X *Returns pointer to a buffer that contains the line. If EOF, returns 0
X */
Xchar *lgetl()
X{
X int i=LINBUFSIZE,ch;
X char *str=lgetwbuf;
X
X for ( ; ; --i) {
X if ((*str++ = ch = lgetc()) == 0) {
X if (str == lgetwbuf+1) return(0); /* EOF */
Xot:
X *str = 0;
X return(lgetwbuf); /* line ended by EOF */
X }
X if ((ch=='\n') || (i<=1))
X goto ot; /* line ended by \n */
X }
X}
X
X/*
X * lcreat(filename) Create a new file for write
X * char *filename;
X *
X * lcreat((char*)0); means to the terminal
X * Returns -1 if error, otherwise the file descriptor opened.
X */
Xlcreat(str)
Xchar *str;
X{
X lpnt = lpbuf;
X lpend = lpbuf+BUFBIG;
X if (str==0) return(lfd=1);
X if ((lfd=creat(str,0644)) < 0) {
X lfd=1;
X lprintf("error creating file <%s>\n",str);
X lflush();
X return(-1);
X }
X return(lfd);
X}
X
X/*
X * lopen(filename) Open a file for read
X * char *filename;
X *
X * lopen(0) means from the terminal
X * Returns -1 if error, otherwise the file descriptor opened.
X */
Xlopen(str)
Xchar *str;
X{
X ipoint = iepoint = MAXIBUF;
X if (str==0) return(fd=0);
X if ((fd=open(str,0)) < 0) {
X lwclose();
X lfd=1;
X lpnt=lpbuf;
X return(-1);
X }
X return(fd);
X}
X
X/*
X * lappend(filename) Open for append to an existing file
X * char *filename;
X *
X * lappend(0) means to the terminal
X * Returns -1 if error, otherwise the file descriptor opened.
X */
Xlappend(str)
Xchar *str;
X{
X lpnt = lpbuf;
X lpend = lpbuf+BUFBIG;
X if (str==0) return(lfd=1);
X if ((lfd=open(str,2)) < 0) {
X lfd=1;
X return(-1);
X }
X lseek(lfd,0,2); /* seek to end of file */
X return(lfd);
X}
X
X/*
X * lrclose()
X * close the input file
X *
X * Returns nothing of value.
X */
Xlrclose()
X{
X if (fd > 0) close(fd);
X}
X
X/*
X * lwclose() close output file flushing if needed
X *
X * Returns nothing of value.
X */
Xlwclose()
X{
X lflush();
X if (lfd > 2) close(lfd);
X}
X
X/*
X * lprcat(string) append a string to the output buffer
X * avoids calls to lprintf (time consuming)
X */
Xlprcat(str)
Xchar *str;
X{
X char *str2;
X
X if (lpnt >= lpend)
X lflush();
X str2 = lpnt;
X while (*str2++ = *str++)
X ;
X lpnt = str2 - 1;
X}
X
X/*
X * cursor(x,y) Put cursor at specified coordinates staring at [1,1] (termcap)
X */
Xcursor (x,y)
Xint x,y;
X{
X if (lpnt >= lpend) lflush ();
X
X *lpnt++ = CURSOR;
X *lpnt++ = x;
X *lpnt++ = y;
X}
X
X/*
X * Routine to position cursor at beginning of 24th line
X */
Xcursors()
X{
X cursor(1,24);
X}
X
X/*
X * Warning: ringing the bell is control code 7. Don't use in defines.
X * Don't change the order of these defines.
X * Also used in helpfiles. Codes used in helpfiles should be \E[1 to \E[7 with
X * obvious meanings.
X */
X
Xstatic char cap[256];
Xchar *CM, *CE, *CD, *CL, *SO, *SE, *AL, *DL;/* Termcap capabilities */
Xstatic char *outbuf=0; /* translated output buffer */
X
Xint putcharacter ();
X
X/*
X * init_term() Terminal initialization -- setup termcap info
X */
Xinit_term()
X{
X char termbuf[1024];
X char *capptr = cap+10;
X char *term;
X
X switch (tgetent(termbuf, term = getenv("TERM"))) {
X case -1:
X fprintf(stderr, "Cannot open termcap file.\n");
X fflush(stderr);
X exit(1);
X case 0:
X fprintf(stderr, "Cannot find entry of ");
X fprintf(stderr, term);
X fprintf(stderr, " in termcap\n");
X fflush(stderr);
X exit(1);
X };
X
X CM = tgetstr("cm", &capptr); /* Cursor motion */
X CE = tgetstr("ce", &capptr); /* Clear to eoln */
X CL = tgetstr("cl", &capptr); /* Clear screen */
X
X /* OPTIONAL */
X AL = tgetstr("al", &capptr); /* Insert line */
X DL = tgetstr("dl", &capptr); /* Delete line */
X SO = tgetstr("so", &capptr); /* Begin standout mode */
X SE = tgetstr("se", &capptr); /* End standout mode */
X CD = tgetstr("cd", &capptr); /* Clear to end of display */
X
X if (!CM) /* can't find cursor motion entry */
X {
X fprintf(stderr, "Sorry, for a ");
X fprintf(stderr, term);
X fprintf(stderr, ", I can't find the cursor motion entry in termcap\n");
X fflush(stderr);
X exit(1);
X }
X if (!CE) /* can't find clear to end of line entry */
X {
X fprintf(stderr, "Sorry, for a ");
X fprintf(stderr, term);
X fprintf(stderr,", I can't find the clear to end of line entry in termcap\n");
X fflush(stderr);
X exit(1);
X }
X if (!CL) /* can't find clear entire screen entry */
X {
X fprintf(stderr, "Sorry, for a ");
X fprintf(stderr, term);
X fprintf(stderr, ", I can't find the clear entire screen entry in termcap\n");
X fflush(stderr);
X exit(1);
X }
X /* get memory for decoded output buffer*/
X if ((outbuf=malloc(BUFBIG+16))==0) {
X fprintf(stderr,"Error malloc'ing memory for decoded output buffer\n");
X fflush(stderr);
X died(-285); /* malloc() failure */
X }
X}
X
X/*
X * cl_line(x,y) Clear the whole line indicated by 'y' and leave cursor at [x,y]
X */
Xcl_line(x,y)
Xint x,y;
X{
X cursor(1,y);
X *lpnt++ = CL_LINE;
X cursor(x,y);
X}
X
X/*
X * cl_up(x,y) Clear screen from [x,1] to current position. Leave cursor at [x,y]
X */
Xcl_up(x,y)
Xregister int x,y;
X{
X register int i;
X cursor(1,1);
X for (i=1; i<=y; i++) {
X *lpnt++ = CL_LINE;
X *lpnt++ = '\n';
X }
X cursor(x,y);
X}
X
X/*
X * cl_dn(x,y) Clear screen from [1,y] to end of display. Leave cursor at [x,y]
X */
Xcl_dn(x,y)
Xint x,y;
X{
X int i;
X
X cursor(1,y);
X if (!CD) {
X *lpnt++ = CL_LINE;
X for (i=y; i<=24; i++) {
X *lpnt++ = CL_LINE;
X if (i!=24) *lpnt++ = '\n';
X }
X cursor(x,y);
X }
X else
X *lpnt++ = CL_DOWN;
X cursor(x,y);
X}
X
X/*
X * standout(str) Print the argument string in inverse video (standout mode).
X */
Xstandout(str)
Xregister char *str;
X{
X if (boldon == 0) {
X lprcat(str);
X return;
X }
X *lpnt++ = ST_START;
X while (*str)
X *lpnt++ = *str++;
X *lpnt++ = ST_END;
X}
X
X/*
X * set_score_output() Called when output should be literally printed.
X */
Xset_score_output()
X{
X enable_scroll = -1;
X}
X
X/*
X * lflush() Flush the output buffer
X *
X * Returns nothing of value.
X * for termcap version: Flush output in output buffer according to output
X * status as indicated by `enable_scroll'
X */
Xstatic int scrline=18; /* line # for wraparound instead of scrolling if no DL */
Xlflush ()
X{
X int lpoint;
X char *str;
X static int curx = 0;
X static int cury = 0;
X
X if ((lpoint = lpnt - lpbuf) > 0) {
X if (enable_scroll <= -1) {
X flush_buf();
X if (write(lfd,lpbuf,lpoint) != lpoint) {
X fprintf(stderr,"error writing to output file\n");
X fflush(stderr);
X }
X lpnt = lpbuf; /* point back to beginning of buffer */
X return;
X }
X for (str = lpbuf; str < lpnt; str++) {
X if (*str>=32) {
X putcharacter (*str);
X curx++;
X }
X else switch (*str) {
X case CLEAR:
X tputs (CL, 0, putcharacter);
X curx = cury = 0;
X break;
X
X case CL_LINE:
X tputs (CE, 0, putcharacter);
X break;
X
X case CL_DOWN:
X tputs (CD, 0, putcharacter);
X break;
X
X case ST_START:
X tputs (SO, 0, putcharacter);
X break;
X
X case ST_END:
X tputs (SE, 0, putcharacter);
X break;
X
X case CURSOR:
X curx = *++str - 1;
X cury = *++str - 1;
X tputs (tgoto (CM, curx, cury), 0, putcharacter);
X break;
X case '\n':
X if ((cury == 23) && enable_scroll) {
X if (!DL || !AL) {
X if (++scrline > 23) scrline=19;
X if (++scrline > 23) scrline=19;
X tputs (tgoto (CM, 0, scrline), 0, putcharacter);
X tputs (CE, 0, putcharacter);
X
X if (--scrline < 19) scrline=23;
X tputs (tgoto (CM, 0, scrline), 0, putcharacter);
X tputs (CE, 0, putcharacter);
X }
X else {
X tputs (tgoto (CM, 0, 19), 0, putcharacter);
X tputs (DL, 0, putcharacter);
X tputs (tgoto (CM, 0, 23), 0, putcharacter);
X }
X }
X else {
X putcharacter ('\n');
X cury++;
X }
X curx = 0;
X break;
X
X default:
X putcharacter (*str);
X curx++;
X };
X }
X }
X lpnt = lpbuf;
X flush_buf(); /* flush real output buffer now */
X}
X
Xstatic int index=0;
X
X/*
X * putcharacter(ch) Print one character in decoded output buffer.
X */
Xint putcharacter(c)
Xint c;
X{
X outbuf[index++] = c;
X if (index >= BUFBIG)
X flush_buf();
X}
X
X/*
X * flush_buf() Flush buffer with decoded output.
X */
Xflush_buf()
X{
X if (index)
X write(lfd, outbuf, index);
X index = 0;
X}
X
X/*
X * char *tmcapcnv(sd,ss)
X * Routine to convert vt100 escapes to termcap format
X *
X * Processes only the \33[#m sequence (converts . files for termcap use
X */
Xchar *tmcapcnv(sd,ss)
Xchar *sd,*ss;
X{
X int tmstate=0; /* 0=normal, 1=\33 2=[ 3=# */
X char tmdigit=0; /* the # in \33[#m */
X
X while (*ss) {
X switch(tmstate) {
X case 0:
X if (*ss=='\33') {
X tmstate++;
X break;
X }
Xign:
X *sd++ = *ss;
Xign2:
X tmstate = 0;
X break;
X case 1:
X if (*ss!='[') goto ign;
X tmstate++;
X break;
X case 2:
X if (isdigit(*ss)) {
X tmdigit= *ss-'0';
X tmstate++;
X break;
X }
X if (*ss == 'm') {
X *sd++ = ST_END;
X goto ign2;
X }
X goto ign;
X case 3:
X if (*ss == 'm') {
X if (tmdigit) *sd++ = ST_START;
X else *sd++ = ST_END;
X goto ign2;
X }
X default:
X goto ign;
X };
X ss++;
X }
X *sd=0; /* 0 terminator */
X return(sd);
X}
X
X/*
X * beep() Routine to emit a beep if enabled (see no-beep in .Ularnopts)
X */
Xbeep()
X{
X if (!nobeep) *lpnt++ = '\7';
X}
END_OF_FILE
if test 20742 -ne `wc -c <'io.c'`; then
echo shar: \"'io.c'\" unpacked with wrong size!
fi
# end of 'io.c'
fi
if test -f 'to_ansi.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'to_ansi.c'\"
else
echo shar: Extracting \"'to_ansi.c'\" \(410 characters\)
sed "s/^X//" >'to_ansi.c' <<'END_OF_FILE'
X/*
X * convert ascii sequence '^[' into escape characters
X */
X#include <stdio.h>
X
Xmain()
X{
X int c, c2;
X
X while ((c = getc(stdin)) != EOF) {
X if (c == '^') {
X if ((c2 = getc(stdin)) != EOF) {
X if (c2 == '[')
X putc('\033', stdout);
X else {
X putc((char)c, stdout);
X putc((char)c2, stdout);
X }
X } else {
X putc((char)c, stdout);
X exit(0);
X }
X } else
X putc((char)c, stdout);
X }
X}
END_OF_FILE
if test 410 -ne `wc -c <'to_ansi.c'`; then
echo shar: \"'to_ansi.c'\" unpacked with wrong size!
fi
# end of 'to_ansi.c'
fi
echo shar: End of archive 3 \(of 8\).
cp /dev/null ark3isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 8 archives.
rm -f ark[1-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0

Reply all
Reply to author
Forward
0 new messages