-+-+-+-+-+-+-+-+ START OF PART 41 -+-+-+-+-+-+-+-+
X  register int32u item_flags;
X#if defined(ATARIST_MWC)
X  int32u holder;`09`09/* to avoid a compiler bug */
X#endif
X  int old_dis_ac;
X  register struct flags *p_ptr;
X  register struct misc *m_ptr;
X  register inven_type *i_ptr;
X  register int i;
X
X  p_ptr = &py.flags;
X  m_ptr = &py.misc;
X  if (p_ptr->slow_digest)
X    p_ptr->food_digested++;
X  if (p_ptr->regenerate)
X    p_ptr->food_digested -= 3;
X  p_ptr->see_inv     = FALSE;
X  p_ptr->teleport    = FALSE;
X  p_ptr->free_act    = FALSE;
X  p_ptr->slow_digest = FALSE;
X  p_ptr->aggravate   = FALSE;
X  p_ptr->sustain_str = FALSE;
X  p_ptr->sustain_int = FALSE;
X  p_ptr->sustain_wis = FALSE;
X  p_ptr->sustain_con = FALSE;
X  p_ptr->sustain_dex = FALSE;
X  p_ptr->sustain_chr = FALSE;
X  p_ptr->fire_resist = FALSE;
X  p_ptr->acid_resist = FALSE;
X  p_ptr->cold_resist = FALSE;
X  p_ptr->regenerate  = FALSE;
X  p_ptr->lght_resist = FALSE;
X  p_ptr->ffall`09     = FALSE;
X
X  old_dis_ac = m_ptr->dis_ac;
X  m_ptr->ptohit`09 = tohit_adj();`09      /* Real To Hit   */
X  m_ptr->ptodam`09 = todam_adj();`09      /* Real To Dam   */
X  m_ptr->ptoac`09 = toac_adj();`09      /* Real To AC    */
X  m_ptr->pac`09 = 0;`09`09    /* Real AC`09     */
X  m_ptr->dis_th`09 = m_ptr->ptohit;  /* Display To Hit`09    */
X  m_ptr->dis_td`09 = m_ptr->ptodam;  /* Display To Dam`09    */
X  m_ptr->dis_ac`09 = 0;`09`09/* Display AC`09`09 */
X  m_ptr->dis_tac = m_ptr->ptoac;   /* Display To AC`09    */
X  for (i = INVEN_WIELD; i < INVEN_LIGHT; i++)
X    `7B
X      i_ptr = &inventory`5Bi`5D;
X      if (i_ptr->tval != TV_NOTHING)
X`09`7B
X`09  m_ptr->ptohit += i_ptr->tohit;
X`09  if (i_ptr->tval != TV_BOW)`09`09/* Bows can't damage. -CJS- */
X`09    m_ptr->ptodam += i_ptr->todam;
X`09  m_ptr->ptoac`09+= i_ptr->toac;
X`09  m_ptr->pac += i_ptr->ac;
X`09  if (known2_p(i_ptr))
X`09    `7B
X`09      m_ptr->dis_th  += i_ptr->tohit;
X`09      if (i_ptr->tval != TV_BOW)
X`09`09m_ptr->dis_td  += i_ptr->todam;`09/* Bows can't damage. -CJS- */
X`09      m_ptr->dis_tac += i_ptr->toac;
X`09      m_ptr->dis_ac += i_ptr->ac;
X`09    `7D
X`09  else if (! (TR_CURSED & i_ptr->flags))
X`09    /* Base AC values should always be visible, as long as the item
X`09       is not cursed.  */
X`09    m_ptr->dis_ac += i_ptr->ac;
X`09`7D
X    `7D
X  m_ptr->dis_ac += m_ptr->dis_tac;
X
X  if (weapon_heavy)
X    m_ptr->dis_th += (py.stats.use_stat`5BA_STR`5D * 15 -
X`09`09      inventory`5BINVEN_WIELD`5D.weight);
X
X  /* Add in temporary spell increases`09*/
X  if (p_ptr->invuln > 0)
X    `7B
X      m_ptr->pac += 100;
X      m_ptr->dis_ac += 100;
X    `7D
X  if (p_ptr->blessed > 0)
X    `7B
X      m_ptr->pac    += 2;
X      m_ptr->dis_ac += 2;
X    `7D
X  if (p_ptr->detect_inv > 0)
X    p_ptr->see_inv = TRUE;
X
X  /* can't print AC here because might be in a store */
X  if (old_dis_ac != m_ptr->dis_ac)
X#ifdef ATARIST_MWC
X    p_ptr->status `7C= (holder = PY_ARMOR);
X#else
X    p_ptr->status `7C= PY_ARMOR;
X#endif
X
X  item_flags = 0;
X  i_ptr = &inventory`5BINVEN_WIELD`5D;
X  for (i = INVEN_WIELD; i < INVEN_LIGHT; i++)
X    `7B
X      item_flags `7C= i_ptr->flags;
X      i_ptr++;
X    `7D
X#if !defined(ATARIST_MWC)
X  if (TR_SLOW_DIGEST & item_flags)
X    p_ptr->slow_digest = TRUE;
X  if (TR_AGGRAVATE & item_flags)
X    p_ptr->aggravate = TRUE;
X  if (TR_TELEPORT & item_flags)
X    p_ptr->teleport = TRUE;
X  if (TR_REGEN & item_flags)
X    p_ptr->regenerate = TRUE;
X  if (TR_RES_FIRE & item_flags)
X    p_ptr->fire_resist = TRUE;
X  if (TR_RES_ACID & item_flags)
X    p_ptr->acid_resist = TRUE;
X  if (TR_RES_COLD & item_flags)
X    p_ptr->cold_resist = TRUE;
X  if (TR_FREE_ACT & item_flags)
X    p_ptr->free_act = TRUE;
X  if (TR_SEE_INVIS & item_flags)
X    p_ptr->see_inv = TRUE;
X  if (TR_RES_LIGHT & item_flags)
X    p_ptr->lght_resist = TRUE;
X  if (TR_FFALL & item_flags)
X    p_ptr->ffall = TRUE;
X#else
X  /* this avoids a bug in the Mark Williams C compiler for the Atari ST */
X  holder = TR_SLOW_DIGEST;
X  if (holder & item_flags)
X    p_ptr->slow_digest = TRUE;
X  holder = TR_AGGRAVATE;
X  if (holder & item_flags)
X    p_ptr->aggravate = TRUE;
X  holder = TR_TELEPORT;
X  if (holder & item_flags)
X    p_ptr->teleport = TRUE;
X  holder = TR_REGEN;
X  if (holder & item_flags)
X    p_ptr->regenerate = TRUE;
X  holder = TR_RES_FIRE;
X  if (holder & item_flags)
X    p_ptr->fire_resist = TRUE;
X  holder = TR_RES_ACID;
X  if (holder & item_flags)
X    p_ptr->acid_resist = TRUE;
X  holder = TR_RES_COLD;
X  if (holder & item_flags)
X    p_ptr->cold_resist = TRUE;
X  holder = TR_FREE_ACT;
X  if (holder & item_flags)
X    p_ptr->free_act = TRUE;
X  holder = TR_SEE_INVIS;
X  if (holder & item_flags)
X    p_ptr->see_inv = TRUE;
X  holder = TR_RES_LIGHT;
X  if (holder & item_flags)
X    p_ptr->lght_resist = TRUE;
X  holder = TR_FFALL;
X  if (holder & item_flags)
X    p_ptr->ffall = TRUE;
X#endif
X
X  i_ptr = &inventory`5BINVEN_WIELD`5D;
X  for (i = INVEN_WIELD; i < INVEN_LIGHT; i++)
X    `7B
X#ifdef ATARIST_MWC
X      if ((holder = TR_SUST_STAT) & i_ptr->flags)
X#else
X      if (TR_SUST_STAT & i_ptr->flags)
X#endif
X`09switch(i_ptr->p1)
X`09  `7B
X`09  case 1: p_ptr->sustain_str = TRUE; break;
X`09  case 2: p_ptr->sustain_int = TRUE; break;
X`09  case 3: p_ptr->sustain_wis = TRUE; break;
X`09  case 4: p_ptr->sustain_con = TRUE; break;
X`09  case 5: p_ptr->sustain_dex = TRUE; break;
X`09  case 6: p_ptr->sustain_chr = TRUE; break;
X`09  default: break;
X`09  `7D
X      i_ptr++;
X    `7D
X
X  if (p_ptr->slow_digest)
X    p_ptr->food_digested--;
X  if (p_ptr->regenerate)
X    p_ptr->food_digested += 3;
X`7D
X
X
X/* Displays inventory items from r1 to r2`09-RAK-`09*/
X/* Designed to keep the display as far to the right as possible.  The  -CJS-
X   parameter col gives a column at which to start, but if the display does
X   not fit, it may be moved left.  The return value is the left edge used. *
V/
X/* If mask is non-zero, then only display those items which have a non-zero
X   entry in the mask array.  */
Xint show_inven(r1, r2, weight, col, mask)
Xregister int r1, r2;
Xint weight, col;
Xchar *mask;
X`7B
X  register int i;
X  int total_weight, len, l, lim, current_line;
X  bigvtype tmp_val;
X  vtype out_val`5B23`5D;
X
X  len = 79 - col;
X  if (weight)
X    lim = 68;
X  else
X    lim = 76;
X
X  for (i = r1; i <= r2; i++)`09`09 /* Print the items`09  */
X    `7B
X      if (mask == CNIL `7C`7C mask`5Bi`5D)
X`09`7B
X`09  objdes(tmp_val, &inventory`5Bi`5D, TRUE);
X`09  tmp_val`5Blim`5D = 0;`09 /* Truncate if too long. */
X`09  (void) sprintf(out_val`5Bi`5D, "  %c) %s", 'a'+i, tmp_val);
X`09  l = strlen(out_val`5Bi`5D);
X`09  if (weight)
X`09    l += 9;
X`09  if (l > len)
X`09    len = l;
X`09`7D
X    `7D
X
X  col = 79 - len;
X  if (col < 0)
X    col = 0;
X
X  current_line = 1;
X  for (i = r1; i <= r2; i++)
X    `7B
X      if (mask == CNIL `7C`7C mask`5Bi`5D)
X`09`7B
X`09  /* don't need first two spaces if in first column */
X`09  if (col == 0)
X`09    prt(&out_val`5Bi`5D`5B2`5D, current_line, col);
X`09  else
X`09    prt(out_val`5Bi`5D, current_line, col);
X`09  if (weight)
X`09    `7B
X`09      total_weight = inventory`5Bi`5D.weight*inventory`5Bi`5D.number;
X`09      (void) sprintf (tmp_val, "%3d.%d lb",
X`09`09`09      (total_weight) / 10, (total_weight) % 10);
X`09      prt (tmp_val, current_line, 71);
X`09    `7D
X`09  current_line++;
X`09`7D
X    `7D
X  return col;
X`7D
X
X
X/* Return a string describing how a given equipment item is carried. -CJS- *
V/
Xchar *describe_use(i)
Xregister int i;
X`7B
X  register char *p;
X
X  switch(i)
X    `7B
X    case INVEN_WIELD:
X      p = "wielding"; break;
X    case INVEN_HEAD:
X      p = "wearing on your head"; break;
X    case INVEN_NECK:
X      p = "wearing around your neck"; break;
X    case INVEN_BODY:
X      p = "wearing on your body"; break;
X    case INVEN_ARM:
X      p = "wearing on your arm"; break;
X    case INVEN_HANDS:
X      p = "wearing on your hands"; break;
X    case INVEN_RIGHT:
X      p = "wearing on your right hand"; break;
X    case INVEN_LEFT:
X      p = "wearing on your left hand"; break;
X    case INVEN_FEET:
X      p = "wearing on your feet"; break;
X    case INVEN_OUTER:
X      p = "wearing about your body"; break;
X    case INVEN_LIGHT:
X      p = "using to light the way"; break;
X    case INVEN_AUX:
X      p = "holding ready by your side"; break;
X    default:
X      p = "carrying in your pack"; break;
X    `7D
X  return p;
X`7D
X
X
X/* Displays equipment items from r1 to end`09-RAK-`09*/
X/* Keep display as far right as possible. -CJS- */
Xint show_equip(weight, col)
Xint weight, col;
X`7B
X  register int i, line;
X  int total_weight, l, len, lim;
X  register char *prt1;
X  bigvtype prt2;
X  vtype out_val`5BINVEN_ARRAY_SIZE-INVEN_WIELD`5D;
X  register inven_type *i_ptr;
X
X  line = 0;
X  len = 79 - col;
X  if (weight)
X    lim = 52;
X  else
X    lim = 60;
X  for (i = INVEN_WIELD; i < INVEN_ARRAY_SIZE; i++) /* Range of equipment */
X    `7B
X      i_ptr = &inventory`5Bi`5D;
X      if (i_ptr->tval != TV_NOTHING)
X`09`7B
X`09  switch(i)`09     /* Get position`09      */
X`09    `7B
X`09    case INVEN_WIELD:
X`09      if (py.stats.use_stat`5BA_STR`5D*15 < i_ptr->weight)
X`09`09prt1 = "Just lifting";
X`09      else
X`09`09prt1 = "Wielding";
X`09      break;
X`09    case INVEN_HEAD:
X`09      prt1 = "On head"; break;
X`09    case INVEN_NECK:
X`09      prt1 = "Around neck"; break;
X`09    case INVEN_BODY:
X`09      prt1 = "On body"; break;
X`09    case INVEN_ARM:
X`09      prt1 = "On arm"; break;
X`09    case INVEN_HANDS:
X`09      prt1 = "On hands"; break;
X`09    case INVEN_RIGHT:
X`09      prt1 = "On right hand"; break;
X`09    case INVEN_LEFT:
X`09      prt1 = "On left hand"; break;
X`09    case INVEN_FEET:
X`09      prt1 = "On feet"; break;
X`09    case INVEN_OUTER:
X`09      prt1 = "About body"; break;
X`09    case INVEN_LIGHT:
X`09      prt1 = "Light source"; break;
X`09    case INVEN_AUX:
X`09      prt1 = "Spare weapon"; break;
X`09    default:
X`09      prt1 = "Unknown value"; break;
X`09    `7D
X`09  objdes(prt2, &inventory`5Bi`5D, TRUE);
X`09  prt2`5Blim`5D = 0; /* Truncate if necessary */
X`09  (void) sprintf(out_val`5Bline`5D, "  %c) %-14s: %s", line+'a',
X`09`09`09 prt1, prt2);
X`09  l = strlen(out_val`5Bline`5D);
X`09  if (weight)
X`09    l += 9;
X`09  if (l > len)
X`09    len = l;
X`09  line++;
X`09`7D
X    `7D
X  col = 79 - len;
X  if (col < 0)
X    col = 0;
X
X  line = 0;
X  for (i = INVEN_WIELD; i < INVEN_ARRAY_SIZE; i++) /* Range of equipment */
X    `7B
X      i_ptr = &inventory`5Bi`5D;
X      if (i_ptr->tval != TV_NOTHING)
X`09`7B
X`09  /* don't need first two spaces when using whole screen */
X`09  if (col == 0)
X`09    prt(&out_val`5Bline`5D`5B2`5D, line+1, col);
X`09  else
X`09    prt(out_val`5Bline`5D, line+1, col);
X`09  if (weight)
X`09    `7B
X`09      total_weight = i_ptr->weight*i_ptr->number;
X`09      (void) sprintf(prt2, "%3d.%d lb",
X`09`09`09     (total_weight) / 10, (total_weight) % 10);
X`09      prt(prt2, line+1, 71);
X`09    `7D
X`09  line++;
X`09`7D
X    `7D
X  erase_line(line+1, col);
X  return col;
X`7D
X
X/* Remove item from equipment list`09`09-RAK-`09*/
Xvoid takeoff(item_val, posn)
Xint item_val, posn;
X`7B
X  register char *p;
X  bigvtype out_val, prt2;
X  register inven_type *t_ptr;
X#ifdef ATARIST_MWC
X  int32u holder;
X#endif
X
X  equip_ctr--;
X  t_ptr = &inventory`5Bitem_val`5D;
X  inven_weight -= t_ptr->weight*t_ptr->number;
X#ifdef ATARIST_MWC
X  py.flags.status `7C= (holder = PY_STR_WGT);
X#else
X  py.flags.status `7C= PY_STR_WGT;
X#endif
X
X  if (item_val == INVEN_WIELD `7C`7C item_val == INVEN_AUX)
X    p = "Was wielding ";
X  else if (item_val == INVEN_LIGHT)
X    p = "Light source was ";
X  else
X    p = "Was wearing ";
X
X  objdes(prt2, t_ptr, TRUE);
X  if (posn >= 0)
X    (void) sprintf(out_val, "%s%s (%c)", p, prt2, 'a'+posn);
X  else
X    (void) sprintf(out_val, "%s%s", p, prt2);
X  msg_print(out_val);
X  if (item_val != INVEN_AUX)`09  /* For secondary weapon  */
X    py_bonuses(t_ptr, -1);
X  invcopy(t_ptr, OBJ_NOTHING);
X`7D
X
X
X/* Used to verify if this really is the item we wish to`09 -CJS-
X   wear or read. */
Xint verify(prompt, item)
Xchar *prompt;
Xint item;
X`7B
X  bigvtype out_str, object;
X
X  objdes(object, &inventory`5Bitem`5D, TRUE);
X  object`5Bstrlen(object)-1`5D = '?'; /* change the period to a question mar
Vk */
X  (void) sprintf(out_str, "%s %s", prompt, object);
X  return get_check(out_str);
X`7D
X
X
X/* All inventory commands (wear, exchange, take off, drop, inventory and
X   equipment) are handled in an alternative command input mode, which accept
Vs
X   any of the inventory commands.
X
X   It is intended that this function be called several times in succession,
X   as some commands take up a turn, and the rest of moria must proceed in th
Ve
X   interim. A global variable is provided, doing_inven, which is normally
X   zero; however if on return from inven_command it is expected that
X   inven_command should be called *again*, (being still in inventory command
X   input mode), then doing_inven is set to the inventory command character
X   which should be used in the next call to inven_command.
X
X   On return, the screen is restored, but not flushed. Provided no flush of
X   the screen takes place before the next call to inven_command, the invento
Vry
X   command screen is silently redisplayed, and no actual output takes place
V at
X   all. If the screen is flushed before a subsequent call, then the player i
Vs
X   prompted to see if we should continue. This allows the player to see any
X   changes that take place on the screen during inventory command input.
X
X  The global variable, screen_change, is cleared by inven_command, and set
X  when the screen is flushed. This is the means by which inven_command tell
X  if the screen has been flushed.
X
X  The display of inventory items is kept to the right of the screen to
X  minimize the work done to restore the screen afterwards.`09`09-CJS-*/
X
X/* Inventory command screen states. */
X#define BLANK_SCR`090
X#define EQUIP_SCR`091
X#define INVEN_SCR`092
X#define WEAR_SCR`093
X#define HELP_SCR`094
X#define WRONG_SCR`095
X
X/* Keep track of the state of the inventory screen. */
+-+-+-+-+-+-+-+-  END  OF PART 41 +-+-+-+-+-+-+-+-
